Commit 5a2737c4 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1794189: Fixing edit post/topic time remaining message



Things done:
1) Giving it alert styling
2) Getting the number of minutes to count down so to be less confusing

behatnotneeded

Change-Id: Ic28d2f6b266a011a40f03cf6a4d9474b6007053a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 3772eb16)
parent 9f680929
......@@ -100,7 +100,7 @@ else { // edit post
// no record for edits to own posts with 30 minutes
if (user_can_edit_post($post->poster, $post->ctime)) {
$post->editrecord = false;
$timeleft = (int)get_config_plugin('interaction', 'forum', 'postdelay') - round((time() - $post->ctime) / 60);
$timeleft = ceil(get_config_plugin('interaction', 'forum', 'postdelay') - (time() - $post->ctime) / 60);
}
else if ($moderator) {
$post->editrecord = true;
......@@ -280,6 +280,7 @@ $smarty = smarty();
$smarty->assign('deleteduser', $poster->get('deleted'));
$smarty->assign('poster', $poster);
$smarty->assign('editform', $editform);
$smarty->assign('moderator', $moderator);
$smarty->assign('parent', $parent);
$smarty->assign('action', $action);
$smarty->assign('groupadmins', group_get_admin_ids($parent->group));
......
......@@ -88,7 +88,7 @@ else { // edit topic
// no record for edits to own posts with 30 minutes
if (user_can_edit_post($topic->poster, $topic->ctime)) {
$topic->editrecord = false;
$timeleft = (int)get_config_plugin('interaction', 'forum', 'postdelay') - round((time() - $topic->ctime) / 60);
$timeleft = ceil(get_config_plugin('interaction', 'forum', 'postdelay') - (time() - $topic->ctime) / 60);
}
else if ($moderator) {
$topic->editrecord = true;
......@@ -302,6 +302,7 @@ function edittopic_submit(Pieform $form, $values) {
$smarty = smarty();
$smarty->assign('heading', $forum->groupname);
$smarty->assign('subheading', $topictype);
$smarty->assign('moderator', $moderator);
$smarty->assign('editform', $editform);
if (isset($timeleft)) {
$smarty->assign('timeleft', $timeleft);
......
......@@ -117,7 +117,7 @@ $string['Open'] = 'Open';
$string['Order'] = 'Order';
$string['orderdescription'] = 'Choose at which position this forum shall appear in the list of forums';
$string['Post'] = 'Post';
$string['postaftertimeout'] = 'You have submitted your change after timeout of %s minutes. Your change has not been applied.';
$string['postaftertimeout'] = 'You have submitted your change after the timeout of %s minutes. Your change has not been applied.';
$string['postbyuserwasdeleted'] = 'A post by %s was deleted';
$string['postsbyuserweredeleted'] = '%s posts by %s were deleted';
$string['postdelay'] = 'Post delay';
......@@ -203,7 +203,9 @@ $string['closetopicsdescription1'] = 'Close all new topics by default. Only mode
$string['activetopicsdescription'] = 'Recently updated topics in your groups.';
$string['timeleftnotice'] = 'You have %s minutes left to finish editing.';
$string['timeleftnotice1'] = 'You have <span class="num">%s</span> minutes left to finish editing.';
$string['timeleftnoticeexpired'] = 'The edit time is over. Your changes will not be saved.';
$string['timeleftnoticeexpiredmoderator'] = 'Your changes will now be saved with an edit notice.';
$string['objectionablecontentpost'] = 'Objectionable content on forum topic "%s" reported by %s';
$string['objectionablecontentposthtml'] = '<div style="padding: 0.5em 0; border-bottom: 1px solid #999;">Objectionable content on forum topic "%s" reported by %s
......
{include file="header.tpl"}
{if $timeleft}<div class="fr timeleftnotice">{str tag="timeleftnotice" section="interaction.forum" args=$timeleft}</div>{/if}
{if $timeleft}
<div class="alert alert-warning" id="timeleft">{str tag="timeleftnotice1" section="interaction.forum" args=$timeleft}</div>
<div class="timeexpired hidden">{if $moderator}{str tag="timeleftnoticeexpiredmoderator" section="interaction.forum"}{else}{str tag="timeleftnoticeexpired" section="interaction.forum"}{/if}</div>
{/if}
<h2><a href="{$WWWROOT}interaction/forum/topic.php?id={$parent->topic}">{$parent->topicsubject}</a> - {$action}</h2>
<script type='application/javascript'>
// Set the number we're counting down from
var countfrom = {$timeleft};
// Update the count down every 1 minute
var x = setInterval(function() {
countfrom = countfrom -1;
jQuery('#timeleft .num').html(countfrom);
// If the count down is finished, write some text
if (countfrom <= 0) {
clearInterval(x);
jQuery('#timeleft').html(jQuery('.timeexpired').html());
}
}, 60000);
</script>
{$editform|safe}
<div class="replyto"><h4>{str tag="replyto" section="interaction.forum"}</h4>
......
{include file="header.tpl"}
{if $timeleft}<div class="fr timeleftnotice">{str tag="timeleftnotice" section="interaction.forum" args=$timeleft}</div>{/if}
{if $timeleft}
<div class="alert alert-warning" id="timeleft">{str tag="timeleftnotice1" section="interaction.forum" args=$timeleft}</div>
<div class="timeexpired hidden">{if $moderator}{str tag="timeleftnoticeexpiredmoderator" section="interaction.forum"}{else}{str tag="timeleftnoticeexpired" section="interaction.forum"}{/if}</div>
{/if}
<h2>{$subheading}</h2>
<script type='application/javascript'>
// Set the number we're counting down from
var countfrom = {$timeleft};
// Update the count down every 1 minute
var x = setInterval(function() {
countfrom = countfrom -1;
jQuery('#timeleft .num').html(countfrom);
// If the count down is finished, write some text
if (countfrom <= 0) {
clearInterval(x);
jQuery('#timeleft').html(jQuery('.timeexpired').html());
}
}, 60000);
</script>
{$editform|safe}
{include file="footer.tpl"}
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