Commit 7e0d8030 authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge "Add read message icon to block and inbox for user messages (bug #852956)"

parents 735e9d95 cd4db50a
......@@ -76,6 +76,7 @@ require_once('activity.php');
$activitylist = activitylist_html($type);
$star = json_encode($THEME->get_url('images/star.png'));
$readicon = json_encode($THEME->get_url('images/readusermessage.gif'));
$strread = json_encode(get_string('read', 'activity'));
$javascript = <<<JAVASCRIPT
......@@ -123,10 +124,16 @@ function showHideMessage(id) {
var unread = getFirstElementByTagAndClassName(
'input', 'tocheckread', message.parentNode.parentNode
);
var unreadicon = getFirstElementByTagAndClassName(
'img', 'unreadmessage', message.parentNode.parentNode
);
if (unread) {
var pd = {'readone':id};
sendjsonrequest('index.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);
});
}
......
......@@ -46,7 +46,7 @@ class PluginBlocktypeInbox extends SystemBlocktype {
}
public static function render_instance(BlockInstance $instance, $editing=false) {
global $USER;
global $USER, $THEME;
$configdata = $instance->get('configdata');
$desiredtypes = array();
......@@ -88,6 +88,8 @@ class PluginBlocktypeInbox extends SystemBlocktype {
if ($records) {
require_once('activity.php');
foreach ($records as &$r) {
$section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
$r->strtype = get_string('type' . $r->type, $section);
$r->message = format_notification_whitespace($r->message, $r->type);
}
}
......@@ -98,6 +100,8 @@ class PluginBlocktypeInbox extends SystemBlocktype {
}
$smarty->assign('blockid', 'blockinstance_' . $instance->get('id'));
$smarty->assign('items', $records);
$smarty->assign('readicon', $THEME->get_url('images/readusermessage.gif'));
return $smarty->fetch('blocktype:inbox:inbox.tpl');
}
......
......@@ -5,7 +5,13 @@
{foreach from=$items item=i}
<tr class="{cycle values='r0,r1'}">
<td class="icon-container">
<img src="{theme_url filename=cat('images/' $i->type '.gif')}" />
{if $i->read && $i->type == 'usermessage'}
<img src="{theme_url filename=cat('images/read' $i->type '.gif')}" alt="{$i->strtype}" />
{elseif $i->type == 'usermessage'}
<img src="{theme_url filename=cat('images/' $i->type '.gif')}" class="unreadmessage" />
{else}
<img src="{theme_url filename=cat('images/' $i->type '.gif')}" alt="{$i->strtype}" />
{/if}
</td>
<td>
{if $i->message}
......@@ -37,12 +43,16 @@ addLoadEvent(function() {
connect(element, 'onclick', function(e) {
e.stop();
var message = getFirstElementByTagAndClassName('div', 'inbox-message', element.parentNode);
var unreadicon = getFirstElementByTagAndClassName('img', 'unreadmessage', message.parentNode.parentNode);
toggleElementClass('hidden', message);
if (hasElementClass(element, 'unread')) {
var id = getNodeAttribute(message, 'id').replace(/inbox-message-(\d+)$/, '$1');
var pd = {'readone':id};
sendjsonrequest(config.wwwroot + 'account/activity/index.json.php', pd, 'GET', function(data) {
removeElementClass(element, 'unread');
if (unreadicon) {
swapDOM(unreadicon, IMG({'src' : {/literal}'{$readicon}'{literal}, 'alt' : getNodeAttribute(unreadicon, 'alt') + ' - ' + {/literal}'{str tag='read' section='activity'}'{literal} }));
};
updateUnreadCount(data);
});
}
......@@ -51,4 +61,4 @@ addLoadEvent(function() {
});
{/literal}
</script>
{/if}
\ No newline at end of file
{/if}
{foreach from=$data item=item}
<tr class="{cycle values='r0,r1'}">
<td>
{if $item->read && $item->type == 'usermessage'}
<img src="{theme_url filename=cat('images/read' $item->type '.gif')}" alt="{$item->strtype} - {str tag='read' section='activity'}" />
{elseif $item->type == 'usermessage'}
<img src="{theme_url filename=cat('images/' $item->type '.gif')}" alt="{$item->strtype}" class="unreadmessage" />
{else}
<img src="{theme_url filename=cat('images/' $item->type '.gif')}" alt="{$item->strtype}" />
{/if}
</td>
<td>
{if $item->message}
......
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