Commit a18397f1 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan

minor changes mostly around editing posts

parent 1c60426b
......@@ -64,8 +64,11 @@ if ($postid == 0) { // post reply
$moderator = $admin || is_forum_moderator((int)$parent->forum);
if (!$membership || (!$moderator && $parent->topicclosed)) {
throw new AccessDeniedException(get_string('cantaddpost', 'interaction.forum'));
if (!$membership) {
throw new AccessDeniedException(get_string('cantaddposttoforum', 'interaction.forum'));
}
if (!$moderator && $parent->topicclosed) {
throw new AccessDeniedException(get_string('cantaddposttotopic', 'interaction.forum'));
}
define('TITLE', $parent->topicsubject . ' - ' . get_string('postreply','interaction.forum'));
......@@ -120,7 +123,8 @@ else { // edit post
$moderator = $admin || is_forum_moderator((int)$post->forum);
if ($post->poster == $userid && (time() - $post->ctime) < (30 * 60)) {
// no record for edits to own posts with 30 minutes
if ($post->poster == $userid && $post->ctime > (time() - 30 * 60)) {
$post->editrecord = false;
}
else if ($moderator) {
......@@ -147,7 +151,7 @@ else { // edit post
),
array(
get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid,
$topicsubject
$post->topicsubject
),
array(
get_config('wwwroot') . 'interaction/forum/editpost.php?id=' . $postid,
......@@ -267,7 +271,6 @@ function addpost_submit(Pieform $form, $values) {
$smarty = smarty();
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('heading', TITLE);
$smarty->assign('topic', $topicsubject);
$smarty->assign('editform', $editform);
if (isset($parent)) {
$smarty->assign('parent', $parent);
......
......@@ -30,7 +30,8 @@ $string['addtitle'] = 'Add forum';
$string['addtopic'] = 'Add topic';
$string['addtopicsuccess'] = 'Added topic successfully';
$string['body'] = 'Body';
$string['cantaddpost'] = 'You are not allowed to post in this forum';
$string['cantaddposttoforum'] = 'You are not allowed to post in this forum';
$string['cantaddposttotopic'] = 'You are not allowed to post in this topic';
$string['cantaddtopic'] = 'You are not allowed to add topics to this forum';
$string['cantdeletepost'] = 'You are not allowed to delete posts in this forum';
$string['cantdeletetopic'] = 'You are not allowed to delete topics in this forum';
......
......@@ -6,12 +6,12 @@
<h2>{$heading|escape}</h2>
{include file="interaction:forum:breadcrumbs.tpl" breadcrumbs=$breadcrumbs}
{$editform}
{if $parent}
<h4>{str tag="replyto" section="interaction.forum"}</h4>
{include file="interaction:forum:simplepost.tpl" post=$parent}
{/if}
{$editform}
{include file="columnleftend.tpl"}
{include file="footer.tpl"}
......@@ -4,8 +4,8 @@
{include file="interaction:forum:simplepost.tpl" post=$post}
<div>
{if $moderator || !$closed}<a href="{$WWWROOT}interaction/forum/editpost.php?parent={$post->id|escape}">{str tag="reply" section=interaction.forum}</a>{/if}
{if $moderator || (!$closed && $post->editor)} | {/if}
{if $moderator || $post->editor}<a href="{$WWWROOT}interaction/forum/editpost.php?id={$post->id|escape}"> {str tag="edit"}</a>{/if}
{if $moderator || (!$closed && $post->canedit)} | {/if}
{if $moderator || $post->canedit}<a href="{$WWWROOT}interaction/forum/editpost.php?id={$post->id|escape}"> {str tag="edit"}</a>{/if}
{if $moderator} | <a href="{$WWWROOT}interaction/forum/deletepost.php?id={$post->id|escape}"> {str tag="delete"}</a>{/if}
</div>
{if $post->edit}
......
......@@ -2,5 +2,5 @@
{$post->ctime}
<h5><a href="{$WWWROOT}user/view.php?id={$post->poster}">{$post->poster|display_name|escape}</a></h5>
<div><img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=100&amp;id={$post->poster}" alt=""></div>
<h5>{str tag="posts" section=interaction.forum} {$post->count|escape}</h5>
{$post->body}
\ No newline at end of file
<h5>{str tag="postsvariable" section=interaction.forum args=$post->count}</h5>
{$post->body}
......@@ -20,7 +20,7 @@
</td>
<td>
<a href="{$WWWROOT}user/view.php?id={$topic->poster}">
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;size=20x20&amp;id={$topic->poster}" alt="">
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=20&amp;id={$topic->poster}" alt="">
{$topic->poster|display_name|escape}
</a>
</td>
......
......@@ -37,7 +37,7 @@
{/if}
<table>
<tr>
<th> &nbsp; </th>
<th></th>
{if !$forum->subscribed || $moderator}<th></th>{/if}
<th>{str tag="topic" section="interaction.forum"}</th>
<th>{str tag="poster" section="interaction.forum"}</th>
......
......@@ -111,8 +111,8 @@ $posts = get_records_sql_array(
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1 AND f.group = ?)
LEFT JOIN {interaction_forum_edit} e ON e.post = p1.id
WHERE p1.topic = ?
GROUP BY 1, 2, 3, 4, 5, p1.ctime, 7, 9, 10
ORDER BY p1.ctime, p1.id',
GROUP BY 1, 2, 3, 4, 5, p1.ctime, 7, 9, 10, e.ctime
ORDER BY p1.ctime, p1.id, e.ctime',
array($topic->group, $topicid)
);
// $posts has an object for every edit to a post
......@@ -133,10 +133,11 @@ for ($i = 0; $i < $count; $i++) {
$posts[$temp]->edit = $postedits;
}
// works out if the logged in user can edit each post
// users can edit own posts within 30 minutes of making them
// and formats the post time
foreach ($posts as $post) {
if ($moderator ||
($post->poster == $USER->get('id') && (time() - $post->ctime) < (30 * 60))) {
($post->poster == $USER->get('id') && $post->ctime > (time() - 30 * 60))) {
$post->canedit = true;
}
else {
......
......@@ -184,7 +184,7 @@ $sql = 'SELECT t.id, p1.subject, p1.body, p1.poster, p1.deleted, COUNT(p2.*), t.
AND t.sticky = ?
AND t.deleted != 1
GROUP BY 1, 2, 3, 4, 5, 7, 8, p4.ctime, p4.poster, p4.deleted, p4.id
ORDER BY p4.ctime DESC, t.id, p4.id DESC';
ORDER BY p4.ctime DESC, p4.id DESC';
$stickytopics = get_records_sql_array($sql, array($userid, $forumid, 1));
......@@ -237,7 +237,7 @@ function setup_topics(&$topics) {
}
if (!$topic->lastpostdeleted) {
$topic->lastposttime = strftime(get_string('strftimerecent'), $topic->lastposttime);
}
}
}
}
}
......
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