Commit e3189ab4 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

Added breadcrumbs to top of pages

parent 2972699b
...@@ -32,7 +32,7 @@ require_once('group.php'); ...@@ -32,7 +32,7 @@ require_once('group.php');
$postid = param_integer('id'); $postid = param_integer('id');
$post = get_record_sql( $post = get_record_sql(
'SELECT p.subject, p.topic, p.parent, t.forum, p2.subject as topicsubject, f.group 'SELECT p.subject, p.topic, p.parent, t.forum, p2.subject as topicsubject, f.group, f.title as forumtitle
FROM {interaction_forum_post} p FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id ON p.topic = t.id
...@@ -62,7 +62,26 @@ if (!$moderator) { ...@@ -62,7 +62,26 @@ if (!$moderator) {
throw new AccessDeniedException(get_string('cantdeletepost', 'interaction.forum')); throw new AccessDeniedException(get_string('cantdeletepost', 'interaction.forum'));
} }
define('TITLE', get_string('deletepost', 'interaction.forum', $post->subject)); define('TITLE', get_string('deletepostvariable', 'interaction.forum', $post->subject));
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $post->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forum,
$post->forumtitle
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topic,
$post->topicsubject
),
array(
get_config('wwwroot') . 'interaction/forum/deletepost.php?id=' . $postid,
get_string('deletepost', 'interaction.forum')
)
);
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
...@@ -92,6 +111,7 @@ function deletepost_submit(Pieform $form, $values) { ...@@ -92,6 +111,7 @@ function deletepost_submit(Pieform $form, $values) {
} }
$smarty = smarty(); $smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('topicsubject', $post->topicsubject); $smarty->assign('topicsubject', $post->topicsubject);
$smarty->assign('heading', TITLE); $smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form); $smarty->assign('deleteform', $form);
......
...@@ -31,40 +31,54 @@ safe_require('interaction' ,'forum'); ...@@ -31,40 +31,54 @@ safe_require('interaction' ,'forum');
require('group.php'); require('group.php');
$topicid = param_integer('id'); $topicid = param_integer('id');
$forum = get_record_sql( $topic = get_record_sql(
'SELECT f."group", f.id, f.title 'SELECT f."group", f.id as forumid, f.title, p.subject, p.body
FROM {interaction_forum_topic} t FROM {interaction_forum_topic} t
INNER JOIN {interaction_instance} f INNER JOIN {interaction_instance} f
ON f.id = t.forum ON f.id = t.forum
AND f.deleted != 1 AND f.deleted != 1
INNER JOIN {interaction_forum_post} p
ON p.topic = t.id
AND p.parent IS NULL
WHERE t.id = ? WHERE t.id = ?
AND t.deleted != 1', AND t.deleted != 1',
array($topicid) array($topicid)
); );
if (!$forum) { if (!$topic) {
throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid)); throw new NotFoundException(get_string('cantfindtopic', 'interaction.forum', $topicid));
} }
$membership = user_can_access_group((int)$forum->group); $membership = user_can_access_group((int)$topic->group);
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER); $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$forum->id); $moderator = $admin || is_forum_moderator((int)$topic->forumid);
if (!$moderator) { if (!$moderator) {
throw new AccessDeniedException(get_string('cantdeletetopic', 'interaction.forum')); throw new AccessDeniedException(get_string('cantdeletetopic', 'interaction.forum'));
} }
$post = get_record_sql( define('TITLE', get_string('deletetopicvariable', 'interaction.forum', $topic->subject));
'SELECT p.subject, p.body
FROM {interaction_forum_post} p
WHERE p.topic = ?
AND p.parent IS NULL',
array($topicid)
);
define('TITLE', get_string('deletetopic', 'interaction.forum', $post->subject)); $breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $topic->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $topic->forumid,
$topic->title
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
$topic->subject
),
array(
get_config('wwwroot') . 'interaction/forum/deletetopic.php?id=' . $topicid,
get_string('deletetopic', 'interaction.forum')
)
);
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
...@@ -94,13 +108,13 @@ function deletepost_submit(Pieform $form, $values) { ...@@ -94,13 +108,13 @@ function deletepost_submit(Pieform $form, $values) {
FROM interaction_forum_topic FROM interaction_forum_topic
WHERE id = ?', WHERE id = ?',
array($topicid) array($topicid)
); )->forum;
$forumid = $forumid->forum;
redirect('/interaction/forum/view.php?id=' . $forumid); redirect('/interaction/forum/view.php?id=' . $forumid);
} }
$smarty = smarty(); $smarty = smarty();
$smarty->assign('forum', $forum->title); $smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('forum', $topic->title);
$smarty->assign('heading', TITLE); $smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form); $smarty->assign('deleteform', $form);
$smarty->display('interaction:forum:deletetopic.tpl'); $smarty->display('interaction:forum:deletetopic.tpl');
......
...@@ -40,7 +40,7 @@ if ($postid==0) { ...@@ -40,7 +40,7 @@ if ($postid==0) {
define('TITLE', get_string('postreply','interaction.forum')); define('TITLE', get_string('postreply','interaction.forum'));
$parentid = param_integer('parent'); $parentid = param_integer('parent');
$topic = get_record_sql( $topic = get_record_sql(
'SELECT p.topic AS id, p2.subject, t.closed, f.id AS forum, f.group 'SELECT p.topic AS id, p2.subject, t.closed, f.id AS forum, f.title AS forumtitle, f.group
FROM {interaction_forum_post} p FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id ON p.topic = t.id
...@@ -72,12 +72,31 @@ if ($postid==0) { ...@@ -72,12 +72,31 @@ if ($postid==0) {
$topicid = $topic->id; $topicid = $topic->id;
$topicsubject = $topic->subject; $topicsubject = $topic->subject;
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $topic->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $topic->forum,
$topic->forumtitle
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
$topic->subject
),
array(
get_config('wwwroot') . 'interaction/forum/editpost.php?parent=' . $parentid,
get_string('postreply', 'interaction.forum')
)
);
} }
if (isset($postid)) { if (isset($postid)) {
define('TITLE', get_string('editpost','interaction.forum')); define('TITLE', get_string('editpost','interaction.forum'));
$post = get_record_sql( $post = get_record_sql(
'SELECT p.subject, p.body, p.parent, p.topic, p.poster, p.ctime, t.forum, p2.subject AS topicsubject, f.group 'SELECT p.subject, p.body, p.parent, p.topic, p.poster, p.ctime, t.forum, p2.subject AS topicsubject, f.title AS forumtitle, f.group
FROM {interaction_forum_post} p FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id ON p.topic = t.id
...@@ -96,7 +115,7 @@ if (isset($postid)) { ...@@ -96,7 +115,7 @@ if (isset($postid)) {
if (!$post) { if (!$post) {
throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $postid)); throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $postid));
} }
$topicid = $post->topic; $topicid = $post->topic;
$topicsubject = $post->topicsubject; $topicsubject = $post->topicsubject;
...@@ -111,6 +130,25 @@ if (isset($postid)) { ...@@ -111,6 +130,25 @@ if (isset($postid)) {
|| (time() - strtotime($post->ctime)) > (30 * 60))) { || (time() - strtotime($post->ctime)) > (30 * 60))) {
throw new AccessDeniedException(get_string('canteditpost', 'interaction.forum')); throw new AccessDeniedException(get_string('canteditpost', 'interaction.forum'));
} }
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $post->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forum,
$post->forumtitle
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
$topicsubject
),
array(
get_config('wwwroot') . 'interaction/forum/editpost.php?id=' . $postid,
get_string('editpost', 'interaction.forum')
)
);
} }
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
...@@ -202,6 +240,7 @@ function editpost_submit(Pieform $form, $values) { ...@@ -202,6 +240,7 @@ function editpost_submit(Pieform $form, $values) {
} }
$smarty = smarty(); $smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('topicsubject', $topicsubject); $smarty->assign('topicsubject', $topicsubject);
$smarty->assign('heading', TITLE); $smarty->assign('heading', TITLE);
$smarty->assign('topic', $topicsubject); $smarty->assign('topic', $topicsubject);
......
...@@ -38,8 +38,8 @@ if ($topicid==0) { ...@@ -38,8 +38,8 @@ if ($topicid==0) {
define('TITLE', get_string('addtopic','interaction.forum')); define('TITLE', get_string('addtopic','interaction.forum'));
$forumid = param_integer('forum'); $forumid = param_integer('forum');
$forum = get_record_sql( $forum = get_record_sql(
'SELECT "group" AS groupid, title 'SELECT f.group AS group, f.title
FROM {interaction_instance} FROM {interaction_instance} f
WHERE id = ? WHERE id = ?
AND deleted != 1', AND deleted != 1',
array($forumid) array($forumid)
...@@ -50,7 +50,7 @@ if ($topicid==0) { ...@@ -50,7 +50,7 @@ if ($topicid==0) {
} }
$forumtitle = $forum->title; $forumtitle = $forum->title;
$membership = user_can_access_group((int)$forum->groupid); $membership = user_can_access_group((int)$forum->group);
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER); $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
...@@ -59,12 +59,27 @@ if ($topicid==0) { ...@@ -59,12 +59,27 @@ if ($topicid==0) {
if (!$membership) { if (!$membership) {
throw new AccessDeniedException(get_string('cantaddtopic', 'interaction.forum')); throw new AccessDeniedException(get_string('cantaddtopic', 'interaction.forum'));
} }
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $forum->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $forumid,
$forum->title
),
array(
get_config('wwwroot') . 'interaction/forum/edittopic.php?forum=' . $forumid,
get_string('addtopic', 'interaction.forum')
)
);
} }
if (isset($topicid)) { if (isset($topicid)) {
define('TITLE', get_string('edittopic','interaction.forum')); define('TITLE', get_string('edittopic','interaction.forum'));
$topic = get_record_sql( $topic = get_record_sql(
'SELECT p.subject, p.body, p.topic AS id, t.sticky, t.closed, f.id as forumid, f.group as groupid, f.title 'SELECT p.subject, p.body, p.topic AS id, t.sticky, t.closed, f.id as forumid, f.group as group, f.title
FROM {interaction_forum_post} p FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id ON p.topic = t.id
...@@ -84,7 +99,7 @@ if (isset($topicid)) { ...@@ -84,7 +99,7 @@ if (isset($topicid)) {
$forumid = $topic->forumid; $forumid = $topic->forumid;
$forumtitle = $topic->title; $forumtitle = $topic->title;
$membership = user_can_access_group((int)$topic->groupid); $membership = user_can_access_group((int)$topic->group);
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER); $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
...@@ -93,6 +108,26 @@ if (isset($topicid)) { ...@@ -93,6 +108,26 @@ if (isset($topicid)) {
if (!$moderator) { if (!$moderator) {
throw new AccessDeniedException(get_string('cantedittopic', 'interaction.forum')); throw new AccessDeniedException(get_string('cantedittopic', 'interaction.forum'));
} }
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $topic->group,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $topic->forumid,
$topic->title
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
$topic->subject
),
array(
get_config('wwwroot') . 'interaction/forum/edittopic.php?id=' . $topicid,
get_string('edittopic', 'interaction.forum')
)
);
} }
require_once('pieforms/pieform.php'); require_once('pieforms/pieform.php');
...@@ -216,6 +251,7 @@ function edittopic_submit(Pieform $form, $values) { ...@@ -216,6 +251,7 @@ function edittopic_submit(Pieform $form, $values) {
} }
$smarty = smarty(); $smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('heading', TITLE); $smarty->assign('heading', TITLE);
$smarty->assign('forum', $forumtitle); $smarty->assign('forum', $forumtitle);
$smarty->assign('editform', $editform); $smarty->assign('editform', $editform);
......
...@@ -51,6 +51,13 @@ if (!$membership) { ...@@ -51,6 +51,13 @@ if (!$membership) {
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER); $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $groupid,
get_string('nameplural', 'interaction.forum')
)
);
$forums = get_records_sql_array( $forums = get_records_sql_array(
'SELECT f.id, f.title, f.description, COUNT(t.*), s.forum AS subscribed 'SELECT f.id, f.title, f.description, COUNT(t.*), s.forum AS subscribed
FROM {interaction_instance} f FROM {interaction_instance} f
...@@ -125,6 +132,7 @@ function subscribe_submit(Pieform $form, $values) { ...@@ -125,6 +132,7 @@ function subscribe_submit(Pieform $form, $values) {
} }
$smarty = smarty(); $smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('groupid', $groupid); $smarty->assign('groupid', $groupid);
$smarty->assign('groupname', $groupname); $smarty->assign('groupname', $groupname);
$smarty->assign('admin', $admin); $smarty->assign('admin', $admin);
......
...@@ -19,9 +19,11 @@ $string['count'] = 'Count'; ...@@ -19,9 +19,11 @@ $string['count'] = 'Count';
$string['currentmoderators'] = 'Current Moderators'; $string['currentmoderators'] = 'Current Moderators';
$string['delete'] = 'Delete'; $string['delete'] = 'Delete';
$string['deletedpost'] = 'This post has been deleted'; $string['deletedpost'] = 'This post has been deleted';
$string['deletepost'] = 'Delete post \'%s\''; $string['deletepost'] = 'Delete post';
$string['deletepostvariable'] = 'Delete post \'%s\'';
$string['deletepostsure'] = 'Are you sure you want to do this? It cannot be undone.'; $string['deletepostsure'] = 'Are you sure you want to do this? It cannot be undone.';
$string['deletetopic'] = 'Delete topic \'%s\''; $string['deletetopic'] = 'Delete topic';
$string['deletetopicvariable'] = 'Delete topic \'%s\'';
$string['deletetopicsure'] = 'Are you sure you want to do this? It cannot be undone.'; $string['deletetopicsure'] = 'Are you sure you want to do this? It cannot be undone.';
$string['edited'] = 'Edited'; $string['edited'] = 'Edited';
$string['editpost'] = 'Edit post'; $string['editpost'] = 'Edit post';
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$topicsubject|escape}</h2> <h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3> <h3>{$heading|escape}</h3>
{$deleteform} {$deleteform}
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$forum|escape}</h2> <h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3> <h3>{$heading|escape}</h3>
{$deleteform} {$deleteform}
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$topicsubject|escape}</h2> <h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3> <h3>{$heading|escape}</h3>
{$editform} {$editform}
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$forum|escape}</h2> <h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3> <h3>{$heading|escape}</h3>
{$editform} {$editform}
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$groupname|escape}</h2> <h2>{$groupname|escape}</h2>
<h3>{str tag=nameplural section=interaction.forum}</h3> <h3>{str tag=nameplural section=interaction.forum}</h3>
{if $admin} {if $admin}
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
{include file="sidebar.tpl"} {include file="sidebar.tpl"}
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$topic->forumtitle|escape}</h2> <h2>{$topic->forumtitle|escape}</h2>
<h3>{$topic->subject|escape}</h3> <h3>{$topic->subject|escape}</h3>
{if $moderator} {if $moderator}
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
{include file="sidebar.tpl"} {include file="sidebar.tpl"}
{include file="columnleftstart.tpl"} {include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$groupname|escape}</h2> <h2>{$groupname|escape}</h2>
<h3>{$forum->title|escape}</h3> <h3>{$forum->title|escape}</h3>
<p>{$forum->description}</p> <p>{$forum->description}</p>
......
...@@ -67,6 +67,21 @@ $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER); ...@@ -67,6 +67,21 @@ $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$topic->forumid); $moderator = $admin || is_forum_moderator((int)$topic->forumid);
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $topic->group,