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');
$postid = param_integer('id');
$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
INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id
......@@ -62,7 +62,26 @@ if (!$moderator) {
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');
......@@ -92,6 +111,7 @@ function deletepost_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('topicsubject', $post->topicsubject);
$smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form);
......
......@@ -31,40 +31,54 @@ safe_require('interaction' ,'forum');
require('group.php');
$topicid = param_integer('id');
$forum = get_record_sql(
'SELECT f."group", f.id, f.title
$topic = get_record_sql(
'SELECT f."group", f.id as forumid, f.title, p.subject, p.body
FROM {interaction_forum_topic} t
INNER JOIN {interaction_instance} f
ON f.id = t.forum
AND f.deleted != 1
INNER JOIN {interaction_forum_post} p
ON p.topic = t.id
AND p.parent IS NULL
WHERE t.id = ?
AND t.deleted != 1',
array($topicid)
);
if (!$forum) {
if (!$topic) {
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);
$moderator = $admin || is_forum_moderator((int)$forum->id);
$moderator = $admin || is_forum_moderator((int)$topic->forumid);
if (!$moderator) {
throw new AccessDeniedException(get_string('cantdeletetopic', 'interaction.forum'));
}
$post = get_record_sql(
'SELECT p.subject, p.body
FROM {interaction_forum_post} p
WHERE p.topic = ?
AND p.parent IS NULL',
array($topicid)
);
define('TITLE', get_string('deletetopicvariable', 'interaction.forum', $topic->subject));
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');
......@@ -94,13 +108,13 @@ function deletepost_submit(Pieform $form, $values) {
FROM interaction_forum_topic
WHERE id = ?',
array($topicid)
);
$forumid = $forumid->forum;
)->forum;
redirect('/interaction/forum/view.php?id=' . $forumid);
}
$smarty = smarty();
$smarty->assign('forum', $forum->title);
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('forum', $topic->title);
$smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form);
$smarty->display('interaction:forum:deletetopic.tpl');
......
......@@ -40,7 +40,7 @@ if ($postid==0) {
define('TITLE', get_string('postreply','interaction.forum'));
$parentid = param_integer('parent');
$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
INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id
......@@ -72,12 +72,31 @@ if ($postid==0) {
$topicid = $topic->id;
$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)) {
define('TITLE', get_string('editpost','interaction.forum'));
$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
INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id
......@@ -96,7 +115,7 @@ if (isset($postid)) {
if (!$post) {
throw new NotFoundException(get_string('cantfindpost', 'interaction.forum', $postid));
}
$topicid = $post->topic;
$topicsubject = $post->topicsubject;
......@@ -111,6 +130,25 @@ if (isset($postid)) {
|| (time() - strtotime($post->ctime)) > (30 * 60))) {
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');
......@@ -202,6 +240,7 @@ function editpost_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('topicsubject', $topicsubject);
$smarty->assign('heading', TITLE);
$smarty->assign('topic', $topicsubject);
......
......@@ -38,8 +38,8 @@ if ($topicid==0) {
define('TITLE', get_string('addtopic','interaction.forum'));
$forumid = param_integer('forum');
$forum = get_record_sql(
'SELECT "group" AS groupid, title
FROM {interaction_instance}
'SELECT f.group AS group, f.title
FROM {interaction_instance} f
WHERE id = ?
AND deleted != 1',
array($forumid)
......@@ -50,7 +50,7 @@ if ($topicid==0) {
}
$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);
......@@ -59,12 +59,27 @@ if ($topicid==0) {
if (!$membership) {
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)) {
define('TITLE', get_string('edittopic','interaction.forum'));
$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
INNER JOIN {interaction_forum_topic} t
ON p.topic = t.id
......@@ -84,7 +99,7 @@ if (isset($topicid)) {
$forumid = $topic->forumid;
$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);
......@@ -93,6 +108,26 @@ if (isset($topicid)) {
if (!$moderator) {
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');
......@@ -216,6 +251,7 @@ function edittopic_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('heading', TITLE);
$smarty->assign('forum', $forumtitle);
$smarty->assign('editform', $editform);
......
......@@ -51,6 +51,13 @@ if (!$membership) {
$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(
'SELECT f.id, f.title, f.description, COUNT(t.*), s.forum AS subscribed
FROM {interaction_instance} f
......@@ -125,6 +132,7 @@ function subscribe_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('groupid', $groupid);
$smarty->assign('groupname', $groupname);
$smarty->assign('admin', $admin);
......
......@@ -19,9 +19,11 @@ $string['count'] = 'Count';
$string['currentmoderators'] = 'Current Moderators';
$string['delete'] = 'Delete';
$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['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['edited'] = 'Edited';
$string['editpost'] = 'Edit post';
......
......@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3>
{$deleteform}
......
......@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3>
{$deleteform}
......
......@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3>
{$editform}
......
......@@ -3,6 +3,12 @@
{include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3>
{$editform}
......
......@@ -3,6 +3,11 @@
{include file="columnleftstart.tpl"}
<p>
{foreach from=$breadcrumbs item=item}
<a href="{$item[0]}">{$item[1]|escape}</a>
{/foreach}
</p>
<h2>{$groupname|escape}</h2>
<h3>{str tag=nameplural section=interaction.forum}</h3>
{if $admin}
......
......@@ -2,6 +2,13 @@
{include file="sidebar.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>
<h3>{$topic->subject|escape}</h3>
{if $moderator}
......
......@@ -2,6 +2,13 @@
{include file="sidebar.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>
<h3>{$forum->title|escape}</h3>
<p>{$forum->description}</p>
......
......@@ -67,6 +67,21 @@ $admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$topic->forumid);
$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->forumtitle
),
array(
get_config('wwwroot') . 'interaction/forum/topic?id=' . $topic->id,
$topic->subject
)
);
require_once('pieforms/pieform.php');
if (!$topic->forumsubscribed) {
......@@ -135,6 +150,7 @@ foreach ($posts as $post) {
$threadedposts = buildthread(0, '', $posts);
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('topic', $topic);
$smarty->assign('moderator', $moderator);
$smarty->assign('posts', $threadedposts);
......
......@@ -36,21 +36,29 @@ $offset = param_integer('offset', 0);
$userid = $USER->get('id');
$topicsperpage = 25;
$group = get_record_sql(
'SELECT g.id, g.name
$forum = get_record_sql(
'SELECT f.title, f.description, f.id, COUNT(t.*), s.forum AS subscribed, g.id as groupid, g.name as groupname
FROM {interaction_instance} f
INNER JOIN {group} g
ON g.id = f."group"
LEFT JOIN {interaction_forum_topic} t
ON t.forum = f.id
AND t.deleted != 1
AND t.sticky != 1
LEFT JOIN {interaction_forum_subscription_forum} s
ON s.forum = f.id
AND s."user" = ?
WHERE f.id = ?
AND f.deleted != 1',
array($forumid)
AND f.deleted != 1
GROUP BY 1, 2, 3, 5, 6, 7',
array($userid, $forumid)
);
if (!$group) {
if (!$forum) {
throw new InteractionInstanceNotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid));
}
$membership = user_can_access_group((int)$group->id);
$membership = user_can_access_group((int)$forum->groupid);
if (!$membership) {
throw new AccessDeniedException(get_string('cantviewforums', 'interaction.forum'));
......@@ -99,20 +107,15 @@ if ($moderator && isset($_POST['update'])) {
updatetopics($_POST['prevclosed'], $_POST['closed'], 'closed = 0');
}
$forum = get_record_sql(
'SELECT f.title, f.description, f.id, COUNT(t.*), s.forum AS subscribed
FROM {interaction_instance} f
LEFT JOIN {interaction_forum_topic} t
ON t.forum = f.id
AND t.deleted != 1
AND t.sticky != 1
LEFT JOIN {interaction_forum_subscription_forum} s
ON s.forum = f.id
AND s."user" = ?
WHERE f.id = ?
AND f.deleted != 1
GROUP BY 1, 2, 3, 5',
array($userid, $forumid)
$breadcrumbs = array(
array(
get_config('wwwroot') . 'interaction/forum/index.php?group=' . $forum->groupid,
get_string('nameplural', 'interaction.forum')
),
array(
get_config('wwwroot') . 'interaction/forum/view.php?id=' . $forumid,
$forum->title
)
);
require_once('pieforms/pieform.php');
......@@ -177,7 +180,8 @@ $pagination = build_pagination(array(
));
$smarty = smarty();
$smarty->assign('groupname', $group->name);
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('groupname', $forum->groupname);
$smarty->assign('forum', $forum);
$smarty->assign('moderator', $moderator);
$smarty->assign('admin', $admin);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment