Commit b44e024d authored by Tobias Zeuch's avatar Tobias Zeuch Committed by Robert Lyon

Inbox and outbox: show 'reply' and 'reply all' links in own column

Bug 1387330: Show reply and reply all buttons in a separate column in the inbox
and outbox, like email clients usually do. Also remove the reply-links after
the message text.
The buttons should only appear where applicalbe, e.g. only show a button reply
all when there were multiple recipients and don't show a reply-button for system
messages. Also other links remain in the message text, like links to new pages
in new-page-access notifications.

Change-Id: I938dda6210f4a0a8ab57b56c654cf60931ef7a6a
Signed-off-by: default avatarTobias Zeuch <tobias.zeuch@kit.edu>
parent 9aae02c7
......@@ -117,12 +117,13 @@ function markread(form, action) {
});
}
function showHideMessage(id, table) {
var message = $('message-' + table + '-' + id);
if (!message) {
function toggleMessageDisplay(table, id) {
var messages = jQuery('#message-' + table + '-' + id);
if (messages.length <= 0) {
return;
}
jQuery(message).parents("tr.unread").removeClass("unread")
message = messages[0];
messages.parents("tr.unread").removeClass("unread");
if (hasElementClass(message, 'hidden')) {
var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode
......@@ -140,10 +141,17 @@ function showHideMessage(id, table) {
updateUnreadCount(data);
});
}
removeElementClass(message, 'hidden');
}
else {
addElementClass(message, 'hidden');
var rows = messages.parents("tr");
if (rows.length > 0) {
if (jQuery(rows[0]).find(".messagedisplaylong.hidden").length > 0) {
jQuery(rows[0]).find(".messagedisplaylong").removeClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").addClass("hidden");
}
else {
jQuery(rows[0]).find(".messagedisplaylong").addClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").removeClass("hidden");
}
}
}
......@@ -182,6 +190,17 @@ addLoadEvent(function () {
connect('notifications_type', 'onchange', changeactivitytype);
});
jQuery(function() {
jQuery('#activitylist tr').hover(
function() {
jQuery(this).addClass('highlight');
},
function() {
jQuery(this).removeClass('highlight');
}
);
});
JAVASCRIPT;
$deleteall = pieform(array(
......
/**
* Multi-Recipient Notification Toggle Recipients
* @source: http://gitorious.org/mahara/mahara
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
function toggleMe(a, b){
var on = document.getElementById(a);
var off = document.getElementById(b);
if (!on || !off) {
return true;
}
on.style.display = "block";
off.style.display = "none";
return true;
}
......@@ -30,8 +30,8 @@ $string['fromuser'] = 'From';
$string['touser'] = 'To';
// Notification Inbox URL Text
$string['returnurltext'] = 'Reply';
$string['replyurltext'] = 'Reply all';
$string['reply'] = 'Reply';
$string['replyall'] = 'Reply all';
$string['linkindicator'] = '»';
$string['labeloutbox1'] = 'Sent';
......@@ -40,6 +40,7 @@ $string['labelinbox'] = 'Inbox';
$string['inboxdesc'] = 'Messages received from Mahara system and other users';
$string['nothingtorender'] = '';
$string['replybuttonplaceholder'] = '...';
$string['selectallread'] = 'All unread notifications';
$string['selectalldelete'] = 'All notifications for deletion';
......
......@@ -116,32 +116,21 @@ function markread(form, action) {
});
}
function showHideMessage(id, table) {
var message = $('message-' + table + '-' + id);
if (!message) {
function toggleMessageDisplay(table, id) {
var messages = jQuery('#message-' + table + '-' + id);
if (messages.length <= 0) {
return;
}
if (hasElementClass(message, 'hidden')) {
var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode
);
var unreadicon = getFirstElementByTagAndClassName(
'img', 'unreadmessage', message.parentNode.parentNode
);
if (unread) {
var pd = {'readone':id, 'table':table};
sendjsonrequest('indexout.json.php', pd, 'GET', function(data) {
swapDOM(unread, IMG({'src' : {$star}, 'alt' : {$strread}}));
if (unreadicon) {
swapDOM(unreadicon, IMG({'src' : {$readicon}, 'alt' : getNodeAttribute(unreadicon, 'alt') + ' - ' + {$strread}}));
};
updateUnreadCount(data);
});
var rows = messages.parents("tr");
if (rows.length > 0) {
if (jQuery(rows[0]).find(".messagedisplaylong.hidden").length > 0) {
jQuery(rows[0]).find(".messagedisplaylong").removeClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").addClass("hidden");
}
else {
jQuery(rows[0]).find(".messagedisplaylong").addClass("hidden");
jQuery(rows[0]).find(".messagedisplayshort").removeClass("hidden");
}
removeElementClass(message, 'hidden');
}
else {
addElementClass(message, 'hidden');
}
}
......@@ -180,6 +169,17 @@ addLoadEvent(function () {
connect('notifications_type', 'onchange', changeactivitytype);
});
jQuery(function() {
jQuery('#activitylist tr').hover(
function() {
jQuery(this).addClass('highlight');
},
function() {
jQuery(this).removeClass('highlight');
}
);
});
JAVASCRIPT;
$deleteall = pieform(array(
......
......@@ -52,40 +52,9 @@ class PluginBlocktypeInbox extends SystemBlocktype {
if (record_exists('artefact_installed', 'name', 'multirecipientnotification', 'active', '1') && safe_require_plugin('artefact', 'multirecipientnotification')) {
global $USER;
$userid = $USER->get('id');
$activitylist = activitylistin(join(',', $desiredtypes), $maxitems);
$records = array();
foreach ($activitylist->msgidrecords as $msgidrecord) {
if ($msgidrecord->msgtable == 'notification_internal_activity') {
$sql = "
SELECT n.id, n.subject, n.message, n.url, n.urltext, n.read, t.name AS type
FROM {notification_internal_activity} n JOIN {activity_type} t ON n.type = t.id
WHERE n.id = ?";
$notificationrecords = get_records_sql_array($sql, array($msgidrecord->id));
if (count($notificationrecords) === 1) {
$record = $notificationrecords[0];
// need to adjust the url to avoid it clashing with multiplerecipient url
$record->url = preg_replace('/replyto/', 'oldreplyto', $record->url);
$record->msgtable = $msgidrecord->msgtable;
$records[] = $record;
}
}
else {
$record = get_message_mr($userid, $msgidrecord->id);
if (null === $record) {
continue;
}
$record->url = 'artefact/multirecipientnotification/sendmessage.php?replyto=' . $msgidrecord->id . '&returnto=outbox';
if (count($record->userids) > 1) {
$record->urltext = get_string('replyurltext', 'artefact.multirecipientnotification');
}
else {
$record->urltext = get_string('returnurltext', 'artefact.multirecipientnotification');
}
$record->msgtable = $msgidrecord->msgtable;
$records[] = $record;
}
}
safe_require('artefact', 'multirecipientnotification');
$activitylist = activityblocklistin(join(',', $desiredtypes), $maxitems);
$records = $activitylist->records;
$showmore = ($activitylist->count > $maxitems);
// use a different template
$smartytemplate = 'blocktype:inbox:inboxmr.tpl';
......
{foreach from=$data item=item}
<script type="application/javascript" src="js/toggle_recipient.js"></script>
<tr class="{cycle values='r0,r1'}{if !$item->read} unread{/if}">
<td class="inboxicon">
<td class="inboxicon" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if $item->read && $item->type == 'usermessage'}
<img src="{theme_url filename=cat('images/read' $item->type '.png')}" alt="{$item->strtype} - {str tag='read' section='activity'}" />
{elseif $item->strtype == 'usermessage'}
......@@ -19,15 +18,15 @@
{str tag="system"}
{/if}
</td>
<td>
<td onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if $item->message}
<a href="" onclick="showHideMessage({$item->id}, '{$item->table}'); return false;">
<a href="" onclick="return false;">
{if !$item->read} <span class="accessible-hidden">{str tag='unread' section='activity'}: </span> {/if}
{$item->subject|truncate:60}
<span class="accessible-hidden">{str tag='clickformore' section='artefact.multirecipientnotification'}</span>
</a>
<div id="message-{$item->table}-{$item->id}" class="hidden">{$item->message|safe}
<div id="message-{$item->table}-{$item->id}" class="hidden messagedisplaylong">{$item->message|safe}
{if $item->url}
<br />
<a href="{$WWWROOT}{$item->url}">
......@@ -39,9 +38,6 @@
{str tag='linkindicator' section="artefact.multirecipientnotification"}
</a>
{/if}
{if $item->return}
<br /><a href="{$WWWROOT}{$item->return}">{$item->returnoutput}</a>
{/if}
</div>
{elseif $item->url}
......@@ -51,20 +47,20 @@
{/if}
</td>
<td class="userlist">
{if $item->return}
<span id="short{$item->id}">
<a onclick="return toggleMe('long{$item->id}', 'short{$item->id}')" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expand.png'}" />
{if count($item->tousr) > 1}
<span id="short{$item->id}" class="messagedisplayshort">
<a onclick="return false;" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expand.png'}" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');"/>
</a>
{assign var="tousr" value=$item->tousr[0]}
{if $tousr['link']}<a href="{$tousr['link']}">{/if}
{$tousr['display']|truncate:$maxnamestrlength}
{if $tousr['link']}</a>{/if}
</span>
<span style="display:none;" id="long{$item->id}">
<a onclick="return toggleMe('short{$item->id}', 'long{$item->id}')" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expanded.png'}" />
</a>
<span class="hidden messagedisplaylong" id="long{$item->id}">
<a onclick="return false;" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expanded.png'}" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');"/>
</a>
<span class="recipientlist">
{foreach from=$item->tousr item=tousr key=break}
{if ($tousr['link'])}<a href="{$tousr['link']}">{/if}
......@@ -81,7 +77,28 @@
{if ($tousr['link'])}</a>{/if}
{/if}
</td>
<td>{$item->date}</td>
<td onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">{$item->date}</td>
<td class="right" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if ($item->canreply || $item->canreplyall)}
<span class="hidden messagedisplaylong">
{if $item->canreply}
<a title="{str tag=reply section=artefact.multirecipientnotification}" href="{$WWWROOT}artefact/multirecipientnotification/sendmessage.php?id={$item->fromusr}{if !$item->startnewthread}&replyto={$item->id}{/if}&returnto=outbox">
<img src="{theme_url filename='images/reply.png'}" alt="{str tag=reply section=artefact.multirecipientnotification}">
</a>
{/if}
{if $item->canreplyall}
<a title="{str tag=replyall section=artefact.multirecipientnotification}" href="{$WWWROOT}artefact/multirecipientnotification/sendmessage.php?replyto={$item->id}&returnto=outbox">
<img src="{theme_url filename='images/replyall.png'}" alt="{str tag=replyall section=artefact.multirecipientnotification}">
</a>
{/if}
</span>
<span class="messagedisplayshort">
<a href="javascript:void(0)" onclick="return false;">
{str tag='replybuttonplaceholder' section='artefact.multirecipientnotification'}
</a>
</span>
{/if}
</td>
<td class="center">
{if $item->read}
<img src="{theme_url filename='images/star.png'}" alt="{str tag=read section=activity}">
......
{foreach from=$data item=item}
<script type="application/javascript" src="js/toggle_recipient.js"></script>
<tr class="{cycle values='r0,r1'}">
<td class="inboxicon">
<td class="inboxicon" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if $item->read && $item->type == 'usermessage'}
<img src="{theme_url filename=cat('images/read' $item->type '.png')}" alt="{$item->strtype} - {str tag='read' section='activity'}" />
{elseif $item->type == 'usermessage'}
......@@ -10,14 +9,14 @@
<img src="{theme_url filename=cat('images/' $item->type '.png')}" alt="{$item->strtype}" />
{/if}
</td>
<td>{$item->fromusr|display_name|truncate:$maxnamestrlength}</td>
<td>
<td onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">{$item->fromusr|display_name|truncate:$maxnamestrlength}</td>
<td onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if $item->message}
<a href="" onclick="showHideMessage({$item->id}, '{$item->table}'); return false;">
<a href="" onclick="return false;">
{$item->subject|truncate:60}
<span class="accessible-hidden">{str tag='clickformore' section='artefact.multirecipientnotification'}</span>
</a>
<div id="message-{$item->table}-{$item->id}" class="hidden">
<div id="message-{$item->table}-{$item->id}" class="hidden messagedisplaylong">
{$item->message|safe}
{if $item->url}
<br />
......@@ -38,9 +37,9 @@
</td>
<td class="userlist">
{if count($item->tousr) > 1}
<span id="short{$item->id}">
<a onclick="return toggleMe('long{$item->id}', 'short{$item->id}');" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expand.png'}" />
<span id="short{$item->id}" class="messagedisplayshort">
<a onclick="return false;" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expand.png'}" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');"/>
{*<span class="accessible-hidden">{str tag='clickformore' section='artefact.multirecipientnotification'}</span>*}
</a>
{assign var="tousr" value=$item->tousr[0]}
......@@ -48,9 +47,9 @@
{$tousr['display']|truncate:$maxnamestrlength}
{if $tousr['link']}</a>{/if}
</span>
<span style="display:none;" id="long{$item->id}">
<a onclick="return toggleMe('short{$item->id}', 'long{$item->id}');" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expanded.png'}" />
<span class="hidden messagedisplaylong" id="long{$item->id}">
<a onclick="return false;" href="javascript:void(0)">
<img class="togglebtn" src="{theme_url filename='images/expanded.png'}" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');"/>
</a>
<span class="recipientlist">
{foreach from=$item->tousr item=tousr key=break}
......@@ -68,7 +67,27 @@
{if $tousr['link']}</a>{/if}
{/if}
</td>
<td>{$item->date}</td>
<td onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">{$item->date}</td>
<td class="center" onclick="toggleMessageDisplay('{$item->table}','{$item->id}');">
{if ($item->canreply || $item->canreplyall)}
<span class="hidden messagedisplaylong">
{if $item->canreplyall}
<a title="{str tag=replyall section=artefact.multirecipientnotification}" href="{$WWWROOT}artefact/multirecipientnotification/sendmessage.php?{if $item->startnewthread}id={$item->usr}{else}replyto={$item->id}{/if}&returnto=outbox">
<img src="{theme_url filename='images/replyall.png'}" alt="{str tag=replyall section=artefact.multirecipientnotification}">
</a>
{elseif $item->canreply}
<a title="{str tag=reply section=artefact.multirecipientnotification}" href="{$WWWROOT}artefact/multirecipientnotification/sendmessage.php?{if $item->startnewthread}id={$item->usr}{else}replyto={$item->id}{/if}&returnto=outbox">
<img src="{theme_url filename='images/reply.png'}" alt="{str tag=reply section=artefact.multirecipientnotification}">
</a>
{/if}
</span>
<span class="messagedisplayshort">
<a href="javascript:void(0)" onclick="return false;">
{str tag='replybuttonplaceholder' section='artefact.multirecipientnotification'}
</a>
</span>
{/if}
</td>
<td class="center">
{if $item->table === 'artefact_multirecipient_notification'}
<label class="accessible-hidden" for="delete-{$item->table}-{$item->id}">{str tag='delete' section='mahara'}</label>
......@@ -76,4 +95,4 @@
{/if}
</td>
</tr>
{/foreach}
\ No newline at end of file
{/foreach}
......@@ -19,13 +19,14 @@
<th>{str section='activity' tag='subject'}</th>
<th>{str section='artefact.multirecipientnotification' tag='touser'}</th>
<th>{str section='activity' tag='date'}</th>
<th class="center">{str section='artefact.multirecipientnotification' tag='reply'}</th>
<th class="center">{str section='activity' tag='read'}</th>
<th class="center">{str tag='delete'}</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"></td>
<td colspan="6"></td>
<td class="center">
<a href="" onclick="toggleChecked('tocheckread'); return false;">
{str section='activity' tag='selectall'}
......
......@@ -19,12 +19,13 @@
<th>{str section='activity' tag='subject'}</th>
<th>{str section='artefact.multirecipientnotification' tag='touser'}</th>
<th>{str section='activity' tag='date'}</th>
<th class="center">{str section='artefact.multirecipientnotification' tag='reply'}</th>
<th class="center">{str tag='delete'}</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"></td>
<td colspan="6"></td>
<td class="center">
<a href="" onclick="toggleChecked('tocheckdel'); return false;">
{str section='activity' tag='selectall'}
......
......@@ -16,8 +16,21 @@
<a href="{if $i->url}{$WWWROOT}{$i->url}{else}{$WWWROOT}account/activity/index.php{/if}" class="inbox-showmessage{if !$i->read} unread{/if}">
{if !$i->read}<span class="accessible-hidden">{str tag=unread section=activity}: </span>{/if}{$i->subject|truncate:50}
</a>
<div class="inbox-message hidden messagebody-{$i->type}" id="inbox-message-{$i->msgtable}-{$i->id}">{$i->message|safe}
<div class="inbox-message hidden messagebody-{$i->type}" id="inbox-message-{$i->table}-{$i->id}">{$i->message|safe}
{if $i->url}<br><a href="{$WWWROOT}{$i->url}">{if $i->urltext}{$i->urltext} &raquo;{else}{str tag="more..."}{/if}</a>{/if}
{if $i->canreplyall}
<br>
<a title="{str tag=replyall section=artefact.multirecipientnotification}" href="{$WWWROOT}artefact/multirecipientnotification/sendmessage.php?replyto={$i->id}&returnto=outbox">
{str tag='replyall' section='artefact.multirecipientnotification'}
</a>
{elseif $i->canreply}
<br>
<a title="{str tag=reply section=artefact.multirecipientnotification}" href="{$WWWROOT}a
rtefact/multirecipientnotification/sendmessage.php?id={$i->fromusr}{if !$i->startnewthread}&re
plyto={$i->id}{/if}&returnto=outbox">
{str tag='reply' section='artefact.multirecipientnotification'}
</a>
{/if}
</div>
{elseif $i->url}
<a href="{$WWWROOT}{$i->url}">{$i->subject}</a>
......
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