Commit 13da8b1d authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

Changed headings of pages

parent 4b363fae
......@@ -33,15 +33,17 @@ require_once('group.php');
$userid = $USER->get('id');
$postid = param_integer('id');
$info = get_record_sql(
'SELECT p.topic, p.parent, t.forum, f.group
'SELECT p.topic, p.parent, t.forum, p2.subject, f.group
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t
ON (p.topic = t.id)
ON p.topic = t.id
INNER JOIN {interaction_forum_post} p2
ON p2.topic = t.id
AND p2.parent IS NULL
INNER JOIN {interaction_instance} f
ON (t.forum = f.id)
ON t.forum = f.id
WHERE p.id = ?',
array($postid)
);
if (!$info) {
......@@ -69,7 +71,7 @@ $postinfo = get_record_sql(
array($postid)
);
define('TITLE', get_string('deletepost', 'interaction.forum') . ' \'' . $postinfo->subject . '\'');
define('TITLE', get_string('deletepost', 'interaction.forum', $postinfo->subject));
require_once('pieforms/pieform.php');
......@@ -104,6 +106,7 @@ function deletepost_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('topicsubject', $info->subject);
$smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form);
$smarty->display('interaction:forum:deletepost.tpl');
......
......@@ -34,7 +34,7 @@ $userid = $USER->get('id');
$topicid = param_integer('id');
$forum = get_record_sql(
'SELECT f."group", f.id
'SELECT f."group", f.id, f.title
FROM {interaction_forum_topic} t
INNER JOIN {interaction_instance} f
ON (f.id = t.forum)
......@@ -64,7 +64,7 @@ $postinfo = get_record_sql(
array($topicid)
);
define('TITLE', get_string('deletetopic', 'interaction.forum') . ' \'' . $postinfo->subject . '\'');
define('TITLE', get_string('deletetopic', 'interaction.forum', $postinfo->subject));
require_once('pieforms/pieform.php');
......@@ -100,6 +100,7 @@ function deletepost_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('forum', $forum->title);
$smarty->assign('heading', TITLE);
$smarty->assign('deleteform', $form);
$smarty->display('interaction:forum:deletetopic.tpl');
......
......@@ -30,7 +30,6 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('interaction', 'forum');
require('group.php');
define('TITLE', get_string('editpost','interaction.forum'));
$userid = $USER->get('id');
......@@ -38,14 +37,18 @@ $postid = param_integer('id',0);
$topicid = 0;
if ($postid==0) {
unset($postid);
define('TITLE', get_string('postreply','interaction.forum'));
$parentid = param_integer('parent');
$topic = get_record_sql(
'SELECT p.topic AS id, t.closed, f.id as forum, f.group
'SELECT p.topic AS id, p2.subject, t.closed, f.id AS forum, f.group
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t
ON (p.topic = t.id)
ON p.topic = t.id
INNER JOIN {interaction_forum_post} p2
ON p2.topic = t.id
AND p2.parent IS NULL
INNER JOIN {interaction_instance} f
ON (t.forum = f.id)
ON t.forum = f.id
WHERE p.id = ?',
array($parentid)
);
......@@ -64,16 +67,21 @@ if ($postid==0) {
throw new NotFoundException("Couldn't find topic with id $parentid");
}
$topicid = $topic->id;
$topicsubject = $topic->subject;
}
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, f.group
'SELECT p.subject, p.body, p.parent, p.topic, p.poster, p.ctime, t.forum, p2.subject AS topicsubject, f.group
FROM {interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t
ON (p.topic = t.id)
ON p.topic = t.id
INNER JOIN {interaction_forum_post} p2
ON p2.topic = t.id
AND p2.parent IS NULL
INNER JOIN {interaction_instance} f
ON (t.forum = f.id)
ON t.forum = f.id
WHERE p.id = ?',
array($postid)
);
......@@ -83,6 +91,7 @@ if (isset($postid)) {
}
$topicid = $post->topic;
$topicsubject = $post->topicsubject;
$membership = user_can_access_group((int)$post->group);
......@@ -186,6 +195,9 @@ function editpost_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('topicsubject', $topicsubject);
$smarty->assign('heading', TITLE);
$smarty->assign('topic', $topicsubject);
$smarty->assign('editform', $editform);
$smarty->display('interaction:forum:editpost.tpl');
......
......@@ -29,13 +29,13 @@ define('MENUITEM', 'groups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('interaction', 'forum');
require_once('group.php');
define('TITLE', get_string('edittopic','interaction.forum'));
$userid = $USER->get('id');
$moderator = false;
$topicid = param_integer('id',0);
if ($topicid==0) {
unset($topicid);
define('TITLE', get_string('addtopic','interaction.forum'));
$forumid = param_integer('forum');
$group = get_record_sql(
'SELECT "group" AS id
......@@ -60,6 +60,7 @@ if ($topicid==0) {
}
if (isset($topicid)) {
define('TITLE', get_string('edittopic','interaction.forum'));
$topicinfo = get_record_sql(
'SELECT p.subject, p.body, p.topic AS id, t.sticky, t.closed
FROM {interaction_forum_post} p
......@@ -83,20 +84,28 @@ if (isset($topicid)) {
array($topicinfo->id)
);
$forumid = $info->forum;
$membership = user_can_access_group((int)$info->group);
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$info->forum);
$moderator = $admin || is_forum_moderator($forumid);
if (!$moderator) {
throw new AccessDeniedException();
}
}
$forum = get_record_sql(
'SELECT title
FROM {interaction_instance}
WHERE id = ?',
array($forumid)
);
require_once('pieforms/pieform.php');
$editform =array(
$editform = array(
'name' => 'edittopic',
'method' => 'post',
'elements' => array(
......@@ -215,6 +224,8 @@ function edittopic_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('heading', TITLE);
$smarty->assign('forum', $forum->title);
$smarty->assign('editform',$editform);
$smarty->display('interaction:forum:edittopic.tpl');
......
......@@ -30,13 +30,20 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('group.php');
define('TITLE', get_string('nameplural', 'interaction.forum'));
$group = param_integer('group');
$groupid = param_integer('group');
if (!record_exists('group', 'id', $group)) {
throw new GroupNotFoundException("Couldn't find group with id $group");
if (!record_exists('group', 'id', $groupid)) {
throw new GroupNotFoundException("Couldn't find group with id $groupid");
}
$membership = user_can_access_group($group);
$groupname = get_record_sql(
'SELECT name
FROM {group}
WHERE id = ?',
array($groupid)
)->name;
$membership = user_can_access_group($groupid);
if (!$membership) {
throw new AccessDeniedException();
......@@ -57,7 +64,7 @@ $forums = get_records_sql_array(
AND f.deleted!=1
GROUP BY 1, 2, 3, 5, c.value
ORDER BY c.value',
array($USER->get('id'), $group)
array($USER->get('id'), $groupid)
);
require_once('pieforms/pieform.php');
......@@ -115,7 +122,8 @@ function subscribe_submit(Pieform $form, $values) {
}
$smarty = smarty();
$smarty->assign('group', $group);
$smarty->assign('groupid', $groupid);
$smarty->assign('groupname', $groupname);
$smarty->assign('admin', $admin);
$smarty->assign('forums', $forums);
$smarty->display('interaction:forum:index.tpl');
......
......@@ -3,7 +3,8 @@
{include file="columnleftstart.tpl"}
<h2>{$heading|escape}</h2>
<h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3>
{$deleteform}
{include file="columnleftend.tpl"}
......
......@@ -3,7 +3,8 @@
{include file="columnleftstart.tpl"}
<h2>{$heading|escape}</h2>
<h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3>
{$deleteform}
{include file="columnleftend.tpl"}
......
......@@ -3,6 +3,8 @@
{include file="columnleftstart.tpl"}
<h2>{$topicsubject|escape}</h2>
<h3>{$heading|escape}</h3>
{$editform}
{include file="columnleftend.tpl"}
......
......@@ -3,6 +3,8 @@
{include file="columnleftstart.tpl"}
<h2>{$forum|escape}</h2>
<h3>{$heading|escape}</h3>
{$editform}
{include file="columnleftend.tpl"}
......
......@@ -3,9 +3,10 @@
{include file="columnleftstart.tpl"}
<h2>{str tag=nameplural section=interaction.forum}</h2>
<h2>{$groupname|escape}</h2>
<h3>{str tag=nameplural section=interaction.forum}</h3>
{if $admin}
<a href="{$WWWROOT}interaction/edit.php?group={$group|escape}&plugin=forum">{str tag="newforum" section=interaction.forum}</a>
<a href="{$WWWROOT}interaction/edit.php?group={$groupid|escape}&plugin=forum">{str tag="newforum" section=interaction.forum}</a>
{/if}
{if $forums}
<ul>
......
......@@ -2,8 +2,8 @@
{include file="sidebar.tpl"}
{include file="columnleftstart.tpl"}
<h2>{$topic->subject}</h2>
<h2>{$topic->forumtitle|escape}</h2>
<h3>{$topic->subject|escape}</h3>
{if $moderator}
<a href="{$WWWROOT}interaction/forum/edittopic.php?id={$topic->id|escape}">{str tag="edit"}</a>
<a href="{$WWWROOT}interaction/forum/deletetopic.php?id={$topic->id|escape}">{str tag="delete"}</a>
......
......@@ -2,7 +2,8 @@
{include file="sidebar.tpl"}
{include file="columnleftstart.tpl"}
<h2>{$forum->title|escape}</h2>
<h2>{$groupname|escape}</h2>
<h3>{$forum->title|escape}</h3>
<p>{$forum->description}</p>
<a href="{$WWWROOT}interaction/forum/edittopic.php?forum={$forum->id|escape}">{str tag="newtopic" section="interaction.forum}</a>
{if $admin}
......
......@@ -34,7 +34,7 @@ define('TITLE', get_string('topic','interaction.forum'));
$topicid = param_integer('id');
$topic = get_record_sql(
'SELECT p.subject, f.group, f.id AS forum, t.closed, sf.forum AS forumsubscribed, st.topic AS topicsubscribed
'SELECT p.subject, f.group, f.id AS forumid, f.title as forumtitle, t.closed, sf.forum AS forumsubscribed, st.topic AS topicsubscribed
FROM {interaction_forum_topic} t
INNER JOIN {interaction_instance} f
ON (t.forum = f.id)
......@@ -60,7 +60,7 @@ if (!$membership) {
$admin = (bool)($membership & GROUP_MEMBERSHIP_OWNER);
$moderator = $admin || is_forum_moderator((int)$topic->forum);
$moderator = $admin || is_forum_moderator((int)$topic->forumid);
require_once('pieforms/pieform.php');
......
......@@ -28,8 +28,8 @@ define('INTERNAL', 1);
define('MENUITEM', 'groups');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('group.php');
safe_require('interaction' ,'forum');
define('TITLE', get_string('name','interaction.forum'));
safe_require('interaction', 'forum');
define('TITLE', get_string('name', 'interaction.forum'));
$forumid = param_integer('id');
$offset = param_integer('offset', 0);
......@@ -37,9 +37,11 @@ $userid = $USER->get('id');
$topicsperpage = 25;
$group = get_record_sql(
'SELECT "group" AS id
FROM {interaction_instance}
WHERE id = ?',
'SELECT g.id, g.name
FROM {interaction_instance} f
INNER JOIN {group} g
ON g.id = f."group"
WHERE f.id = ?',
array($forumid)
);
......@@ -78,12 +80,18 @@ if (isset($_POST['subscribe'])) {
}
if ($moderator && isset($_POST['update'])) {
if (!isset($_POST['sticky'])) {
$_POST['sticky'] = array();
}
if (!isset($_POST['closed'])) {
$_POST['closed'] = array();
}
if (!isset($_POST['sticky'])) {
$_POST['sticky'] = array();
}
if (!isset($_POST['closed'])) {
$_POST['closed'] = array();
}
if (!isset($POST['prevsticky'])) {
$_POST['prevsticky'] = array();
}
if (!isset($POST['prevclosed'])) {
$_POST['prevclosed'] = array();
}
updatetopics($_POST['sticky'], $_POST['prevsticky'], 'sticky = 1');
updatetopics($_POST['prevsticky'], $_POST['sticky'], 'sticky = 0');
updatetopics($_POST['closed'], $_POST['prevclosed'], 'closed = 1');
......@@ -158,6 +166,7 @@ $pagination = build_pagination(array(
));
$smarty = smarty();
$smarty->assign('groupname', $group->name);
$smarty->assign('forum', $forum);
$smarty->assign('moderator', $moderator);
$smarty->assign('admin', $admin);
......@@ -200,13 +209,6 @@ function subscribe_forum_submit(Pieform $form, $values) {
}
function updatetopics($new, $old, $set) {
if (empty($new)) {
log_debug($new);
$new = array();
}
if (empty($old)) {
$old = array();
}
$keydiff = array_keys(array_diff_key($new, $old));
if (!empty($keydiff)) {
execute_sql(
......
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