Commit b9a75deb authored by Pat Kira's avatar Pat Kira Committed by Aaron Wells
Browse files

Notifications (bootstrap)

Bug 1465107: Use Bootstrap CSS Framework
Notifications (bootstrap)
Send message styling (work in progress)
Style inbox and outbox (work in progress)
Style inbox and outbox notification (Done)
Add class control-buttons to a tablecell that has 2 or more buttons
Notifications (bootstrap)
Amend inbox & outbox styles
Notificatiosn

Change-Id: I3216395b1b1a100ae38ee7687b255f099b90513d
parent cb93a0c4
...@@ -75,8 +75,6 @@ require_once(get_config('docroot') . 'lib/activity.php'); ...@@ -75,8 +75,6 @@ require_once(get_config('docroot') . 'lib/activity.php');
// use the new function to show from - and to user // use the new function to show from - and to user
$activitylist = activitylistin_html($type); $activitylist = activitylistin_html($type);
$star = json_encode($THEME->get_image_url('star'));
$readicon = json_encode($THEME->get_image_url('readusermessage'));
$strread = json_encode(get_string('read', 'activity')); $strread = json_encode(get_string('read', 'activity'));
$strnodelete = json_encode(get_string('nodelete', 'activity')); $strnodelete = json_encode(get_string('nodelete', 'activity'));
$javascript = <<<JAVASCRIPT $javascript = <<<JAVASCRIPT
......
...@@ -19,15 +19,15 @@ global $USER; ...@@ -19,15 +19,15 @@ global $USER;
global $THEME; global $THEME;
$readone = param_integer('readone', 0); $readone = param_integer('readone', 0);
$table = param_alphanumext('table', 'notification_internal_activity'); $list = param_alphanumext('div', 'notification_internal_activity');
$markasread = param_integer('markasread', 0); $markasread = param_integer('markasread', 0);
$delete = param_integer('delete', 0); $delete = param_integer('delete', 0);
if ($readone) { if ($readone) {
if ('notification_internal_activity' === $table) { if ('notification_internal_activity' === $list) {
set_field($table, 'read', 1, 'id', $readone, 'usr', $USER->get('id')); set_field($list, 'read', 1, 'id', $readone, 'usr', $USER->get('id'));
} }
else if ('artefact_multirecipient_notification' === $table) { else if ('artefact_multirecipient_notification' === $list) {
mark_as_read_mr(array($readone), $USER->get('id')); mark_as_read_mr(array($readone), $USER->get('id'));
} }
$unread = $USER->add_unread(-1); $unread = $USER->add_unread(-1);
...@@ -51,25 +51,25 @@ if ($markasread) { ...@@ -51,25 +51,25 @@ if ($markasread) {
$m = array(); $m = array();
foreach ($_GET as $k => $v) { foreach ($_GET as $k => $v) {
if (preg_match('/^unread\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) { if (preg_match('/^unread\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
$table = $m[1]; $list = $m[1];
$ids[$table][] = $m[2]; $ids[$list][] = $m[2];
} }
} }
foreach ($ids as $table => $idspertable) { foreach ($ids as $list => $idsperlist) {
if ($idspertable) { if ($idsperlist) {
if ('artefact_multirecipient_notification' === $table) { if ('artefact_multirecipient_notification' === $list) {
$table = 'artefact_multirecipient_userrelation'; $list = 'artefact_multirecipient_userrelation';
$column = 'notification'; $column = 'notification';
} }
else { else {
$column = 'id'; $column = 'id';
} }
set_field_select( set_field_select(
$table, 'read', '1', $list, 'read', '1',
$column . ' IN (' . join(',', array_map('db_quote', $idspertable)) . ') AND usr = ?', $column . ' IN (' . join(',', array_map('db_quote', $idsperlist)) . ') AND usr = ?',
array($USER->get('id')) array($USER->get('id'))
); );
$newunread = $USER->add_unread(-count($idspertable)); $newunread = $USER->add_unread(-count($idsperlist));
} }
} }
$message = get_string('markedasread', 'activity'); $message = get_string('markedasread', 'activity');
...@@ -79,20 +79,22 @@ else if ($delete) { ...@@ -79,20 +79,22 @@ else if ($delete) {
$deleteunread = 0; // Remember the number of unread messages being deleted $deleteunread = 0; // Remember the number of unread messages being deleted
foreach ($_GET as $k => $v) { foreach ($_GET as $k => $v) {
if (preg_match('/^delete\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) { if (preg_match('/^delete\-([a-zA-Z_]+)\-(\d+)$/',$k,$m)) {
$table = $m[1]; $list = $m[1];
$rawids[$table][] = $m[2]; $ids[$list][] = $m[2];
if (isset($_GET['unread-' . $table . '-' . $m[2]])) { if (isset($_GET['unread-' . $list . '-' . $m[2]])) {
$deleteunread++; $deleteunread++;
} }
} }
} }
db_begin(); db_begin();
$countdeleted = 0; $countdeleted = 0;
foreach ($rawids as $table => $idspertable) { foreach ($ids as $list => $idsperlist) {
if ('artefact_multirecipient_notification' === $table) { if ('artefact_multirecipient_notification' === $list) {
delete_messages_mr($idspertable, $USER->get('id')); delete_messages_mr($idsperlist, $USER->get('id'));
} }
else if ('notification_internal_activity' === $table) { else if ('notification_internal_activity' === $list) {
$strids = join(',', array_map('db_quote', $idsperlist));
$userid = $USER->get('id'); $userid = $USER->get('id');
// Ignore message ids that do not belong to the current user to stop // Ignore message ids that do not belong to the current user to stop
// hacking of the form allowing the deletion of messages owned by other users. // hacking of the form allowing the deletion of messages owned by other users.
......
...@@ -223,6 +223,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) { ...@@ -223,6 +223,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
} }
else { else {
$tousrarray = array( $tousrarray = array(
'username' => display_username(get_user_for_display($record->userids[$i])),
'display' => display_name($record->userids[$i]), 'display' => display_name($record->userids[$i]),
'link' => profile_url($record->userids[$i]), 'link' => profile_url($record->userids[$i]),
); );
...@@ -234,6 +235,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) { ...@@ -234,6 +235,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
} }
if ($deletedcount > 0) { if ($deletedcount > 0) {
$record->tousr[] = array( $record->tousr[] = array(
'username' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'),
'display' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'), 'display' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'),
'link' => null, 'link' => null,
); );
...@@ -526,6 +528,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -526,6 +528,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
// read out sender name // read out sender name
if (isset($record->from)) { if (isset($record->from)) {
$record->fromusr = $record->from; $record->fromusr = $record->from;
// $record->fromusr = $record->from;
} }
else { else {
// we're in the outbox, so basically, this should hold for all messages // we're in the outbox, so basically, this should hold for all messages
...@@ -563,6 +566,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -563,6 +566,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
} }
else { else {
$record->tousr[] = array( $record->tousr[] = array(
'username' => display_username(get_user_for_display($record->userids[$i])),
'display' => display_name($record->userids[$i]), 'display' => display_name($record->userids[$i]),
'link' => profile_url($record->userids[$i]), 'link' => profile_url($record->userids[$i]),
); );
...@@ -570,6 +574,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -570,6 +574,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
} }
if ($deletedcount > 0) { if ($deletedcount > 0) {
$record->tousr[] = array( $record->tousr[] = array(
'username' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'),
'display' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'), 'display' => $deletedcount . ' ' . get_string('deleteduser', 'artefact.multirecipientnotification'),
'link' => null, 'link' => null,
); );
......
...@@ -68,7 +68,7 @@ class PluginArtefactResume extends PluginArtefact { ...@@ -68,7 +68,7 @@ class PluginArtefactResume extends PluginArtefact {
'workskill' => array('text'), 'workskill' => array('text'),
); );
} }
public static function submenu_items() { public static function submenu_items() {
$tabs = array( $tabs = array(
'index' => array( 'index' => array(
...@@ -1087,8 +1087,8 @@ EOF; ...@@ -1087,8 +1087,8 @@ EOF;
var buttons = []; var buttons = [];
if (r._rownumber > 1) { if (r._rownumber > 1) {
var up = var up =
A({'href': '', 'class': 'btn btn-default btn-xs'}, A({'href': '', 'class': 'moveup'},
SPAN({'class': 'fa fa-caret-up'}), SPAN({'class': 'fa fa-long-arrow-up'}),
SPAN({'class': 'sr-only'}, '{$upstr}')); SPAN({'class': 'sr-only'}, '{$upstr}'));
connect(up, 'onclick', function (e) { connect(up, 'onclick', function (e) {
e.stop(); e.stop();
...@@ -1098,8 +1098,8 @@ EOF; ...@@ -1098,8 +1098,8 @@ EOF;
} }
if (!r._last) { if (!r._last) {
var down = var down =
A({'href': '', 'class':'btn btn-default btn-xs movedown'}, A({'href': '', 'class':'movedown'},
SPAN({'class': 'fa fa-caret-down'}), SPAN({'class': 'fa fa-long-arrow-down'}),
SPAN({'class': 'sr-only'}, '{$downstr}')); SPAN({'class': 'sr-only'}, '{$downstr}'));
connect(down, 'onclick', function (e) { connect(down, 'onclick', function (e) {
e.stop(); e.stop();
...@@ -1128,7 +1128,7 @@ EOF; ...@@ -1128,7 +1128,7 @@ EOF;
e.stop(); e.stop();
return deleteComposite(d.type, r.id, r.artefact); return deleteComposite(d.type, r.id, r.artefact);
}); });
return TD({'class':'btns2'}, null, editlink, ' ', dellink); return TD({'class':'control-buttons'}, null, editlink, ' ', dellink);
} }
] ]
); );
......
...@@ -168,6 +168,7 @@ class PluginBlocktypeWall extends SystemBlocktype { ...@@ -168,6 +168,7 @@ class PluginBlocktypeWall extends SystemBlocktype {
), ),
'submit' => array( 'submit' => array(
'type' => 'submit', 'type' => 'submit',
'class' => 'btn btn-success',
'value' => get_string('Post', 'blocktype.wall'), 'value' => get_string('Post', 'blocktype.wall'),
), ),
), ),
......
...@@ -100,6 +100,7 @@ else { ...@@ -100,6 +100,7 @@ else {
} }
$elements['submit'] = array( $elements['submit'] = array(
'type' => $type, 'type' => $type,
'class' => 'btn btn-success',
'value' => $submitstr, 'value' => $submitstr,
'confirm' => $confirm, 'confirm' => $confirm,
); );
......
...@@ -720,19 +720,24 @@ function setCookie( name, value, expires, path, domain, secure ) ...@@ -720,19 +720,24 @@ function setCookie( name, value, expires, path, domain, secure )
// End cookie related functions // End cookie related functions
function toggleChecked(c) { function toggleChecked(c) {
var e = getElementsByTagAndClassName(null, c); var elements = getElementsByTagAndClassName(null, c),
if (e) { trigger = document.querySelectorAll('data-'+c),
for (cb in e) { i;
if (e[cb].checked == true) {
e[cb].checked = ''; if(trigger) {
} trigger.checked = true;
else { }
e[cb].checked = 'checked'; if (elements) {
for (i = 0; i < elements.length; i = i + 1) {
if (elements[i].checked == true) {
elements[i].checked = '';
} else {
elements[i].checked = 'checked';
} }
} }
} }
return false; return;
} }
function expandDownToViewport(element, width) { function expandDownToViewport(element, width) {
......
...@@ -86,13 +86,9 @@ function PieformTextarea(element, fullwidth) {//{{{ ...@@ -86,13 +86,9 @@ function PieformTextarea(element, fullwidth) {//{{{
this.grippie.dimensions = this.actual(this.grippie); this.grippie.dimensions = this.actual(this.grippie);
// Set wrapper and textarea dimensions // Set wrapper and textarea dimensions
setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1});
if (!fullwidth) {
jQuery(this.wrapper).css("max-width", this.dimensions.w + "px");
}
setStyle(this.element, { setStyle(this.element, {
'margin-bottom': '0', 'margin-bottom': '0'
'width': '100%' // 'width': '100%'
}); });
// Wrap textarea // Wrap textarea
......
...@@ -1017,7 +1017,7 @@ function check_imap_for_bounces() { ...@@ -1017,7 +1017,7 @@ function check_imap_for_bounces() {
* Both parameters should be objects containing id, preferredname, firstname, * Both parameters should be objects containing id, preferredname, firstname,
* lastname, admin * lastname, admin
* *
* @param object $user the user that you're trying to format to a string * @param Int $user the user that you're trying to format to a string
* @param object $userto the user that is looking at the string representation (if left * @param object $userto the user that is looking at the string representation (if left
* blank, will default to the currently logged in user). * blank, will default to the currently logged in user).
* @param boolean $nameonly do not append the user's username even if $userto can see it. * @param boolean $nameonly do not append the user's username even if $userto can see it.
...@@ -1027,6 +1027,7 @@ function check_imap_for_bounces() { ...@@ -1027,6 +1027,7 @@ function check_imap_for_bounces() {
* @returns string name to display * @returns string name to display
*/ */
function display_name($user, $userto=null, $nameonly=false, $realname=false, $username=false) { function display_name($user, $userto=null, $nameonly=false, $realname=false, $username=false) {
global $USER; global $USER;
static $tutorcache = array(); static $tutorcache = array();
...@@ -1191,6 +1192,8 @@ function get_user_for_display($user=null) { ...@@ -1191,6 +1192,8 @@ function get_user_for_display($user=null) {
* the global $USER object is used * the global $USER object is used
*/ */
function display_username($user=null) { function display_username($user=null) {
global $USER; global $USER;
if ($user === null) { if ($user === null) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="fr nowrap"> <div class="fr nowrap">
<span class="entries"><a href="{$WWWROOT}artefact/blog/view/index.php?id={$blog->id}">{str tag=nposts section=artefact.blog arg1=$blog->postcount}</a></span> <span class="entries"><a href="{$WWWROOT}artefact/blog/view/index.php?id={$blog->id}">{str tag=nposts section=artefact.blog arg1=$blog->postcount}</a></span>
<span class="newentry"><a href="{$WWWROOT}artefact/blog/post.php?blog={$blog->id}" class="btn">{str tag=addpost section=artefact.blog}</a></span> <span class="newentry"><a href="{$WWWROOT}artefact/blog/post.php?blog={$blog->id}" class="btn">{str tag=addpost section=artefact.blog}</a></span>
<span class="btns2"> <span class="control-buttons">
{if $blog->locked} {if $blog->locked}
<span class="s dull">{str tag=submittedforassessment section=view}</span> <span class="s dull">{str tag=submittedforassessment section=view}</span>
{else} {else}
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</span> </span>
<a class="attach-files" data-toggle="collapse" href="#attach_{$post->id}" aria-expanded="false"> <a class="attach-files" data-toggle="collapse" href="#attach_{$post->id}" aria-expanded="false">
{str tag=attachedfiles section=artefact.blog} {str tag=attachedfiles section=artefact.blog}
<span class="fa fa-chevron-down"></span> <span class="fa fa-chevron-up"></span>
</a> </a>
</div> </div>
<div class="collapse files" id="attach_{$post->id}"> <div class="collapse files" id="attach_{$post->id}">
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</td> </td>
{/if} {/if}
<!-- Ensure space for 3 buttons (in the case of a really long single line string in a user input field --> <!-- Ensure space for 3 buttons (in the case of a really long single line string in a user input field -->
<td class="text-right"> <td class="text-right control-buttons">
{if $editable && !$file->isparent} {if $editable && !$file->isparent}
{if $file->locked} {if $file->locked}
<span class="dull">{str tag=Submitted section=view}</span> <span class="dull">{str tag=Submitted section=view}</span>
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
{/foreach} {/foreach}
</td> </td>
<td class="note-attachment"><label class="hidden">{str tag=Attachments section=artefact.resume}: </label> {$n->count}</td> <td class="note-attachment"><label class="hidden">{str tag=Attachments section=artefact.resume}: </label> {$n->count}</td>
<td class="right buttonscell btns2"> <td class="right buttonscell control-buttons">
{if $n->locked} {if $n->locked}
<span class="s dull">{str tag=Submitted section=view}</span> <span class="s dull">{str tag=Submitted section=view}</span>
{else} {else}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<th class="icons"></th> <th class="icons"></th>
<th>{str tag='service' section='artefact.internal'}</th> <th>{str tag='service' section='artefact.internal'}</th>
<th>{str tag='profileurl' section='artefact.internal'}</th> <th>{str tag='profileurl' section='artefact.internal'}</th>
{if $controls}<th class="btns2"> {if $controls}<th class="control-buttons">
<span class="accessible-hidden sr-only">{str tag=edit}</span> <span class="accessible-hidden sr-only">{str tag=edit}</span>
</th>{/if} </th>{/if}
</tr> </tr>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<td class="center"><img src="{$row->icon}" alt="{$row->description}"></td> <td class="center"><img src="{$row->icon}" alt="{$row->description}"></td>
<td><span>{$row->description}</span></td> <td><span>{$row->description}</span></td>
<td>{if $row->link}<a href="{$row->link}" title="{$row->link}" target="_blank" class="socialprofile">{/if}{$row->title}{if $row->link}</a>{/if}</td> <td>{if $row->link}<a href="{$row->link}" title="{$row->link}" target="_blank" class="socialprofile">{/if}{$row->title}{if $row->link}</a>{/if}</td>
{if $controls}<td class="right buttonscell btns2"> {if $controls}<td class="buttonscell control-buttons">
<a href="{$WWWROOT}artefact/internal/socialprofile.php?id={$row->id}" title="{str tag='edit'}" class="btn btn-default btn-xs"> <a href="{$WWWROOT}artefact/internal/socialprofile.php?id={$row->id}" title="{str tag='edit'}" class="btn btn-default btn-xs">
<span class="fa fa-pencil"></span> <span class="fa fa-pencil"></span>
<span class="sr-only">{str tag='edit'}</span> <span class="sr-only">{str tag='edit'}</span>
......
{foreach from=$data item=item} {foreach from=$data item=item}
<script language="JavaScript" type="text/javascript" src="js/toggle_recipient.js"> </script> <div class="notification-item panel {if !$item->read}unread panel-warning {else} panel-default{/if}">
<tr class="{cycle values='r0,r1'}{if !$item->read} unread{/if}"> <div class="notification-header panel-heading clearfix" data-toggle="collapse" data-target="#notification-{$item->id}" aria-expanded="false" aria-controls="#notification-{$item->id}">
<td class="inboxicon"> <div class="notification-icon pull-left">
{if $item->read && $item->type == 'usermessage'} {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'}" /> <span class="fa fa-envelope"></span><span class="sr-only">{$item->strtype} - {str tag='read' section='activity'}</span>
{elseif $item->strtype == 'usermessage'} {elseif $item->strtype == 'usermessage'}
<img src="{theme_url filename=cat('images/' $item->type '.png')}" alt="{$item->strtype}" class="unreadmessage" /> <span class="fa fa-envelope"></span><span class="sr-only">{$item->strtype}</span>
{else} {else}
<img src="{theme_url filename=cat('images/' $item->type '.png')}" alt="{$item->strtype}" /> <span class="fa fa-wrench"></span>
{/if} <span class="sr-only">{$item->strtype}</span>
</td> {/if}
<td> </div>
{if ($item->fromusr != 0)} <h3 class="notification-subject">
{if ($item->fromusrlink)}<a href="{$item->fromusrlink}">{/if} <span class="sr-only">{str section='activity' tag='subject'}</span>
{$item->fromusr|display_name|truncate:$maxnamestrlength} {if !$item->read}
{if ($item->fromusrlink)}</a>{/if} <span class="accessible-hidden sr-only">
{else} {str tag='unread' section='activity'}:
{str tag="system"} </span>
{/if} {/if}
</td> {$item->subject|truncate:40}
<td> </h3>
{if $item->message} <div class="notification-metadata">
<a href="" onclick="showHideMessage({$item->id}, '{$item->table}'); return false;"> <span class="sr-only">
{if !$item->read} <span class="accessible-hidden sr-only">{str tag='unread' section='activity'}: </span> {/if} {str section='artefact.multirecipientnotification 'tag='fromuser'}:
{$item->subject|truncate:60} </span>
<span class="accessible-hidden sr-only">{str tag='clickformore' section='artefact.multirecipientnotification'}</span> {if ($item->fromusr != 0)}
</a> {if ($item->fromusrlink)}
<span class="username">
<div id="message-{$item->table}-{$item->id}" class="hidden">{$item->message|safe} {/if}
{if $item->url} - {$item->fromusr|display_name|truncate:$maxnamestrlength}
<br /> {if ($item->fromusrlink)}
<a href="{$WWWROOT}{$item->url}"> </span>
{if $item->urltext} {/if}
{$item->urltext}
{else} {else}
{str tag="more..."} <span class="username">
- {str tag="system"}
</span>
{/if} {/if}
{str tag='linkindicator' section="artefact.multirecipientnotification"} <span class="sentdate">
, {$item->date}
</span>
</div>
<div class="notification-control">
<div class="control">
{if !$item->read}
<div class="control-wrapper prm">
<input type="checkbox" class="tocheckread" name="unread-{$item->table}-{$item->id}" id="unread-{$item->table}-{$item->id}">
<label class="marked read" for="unread-{$item->table}-{$item->id}">{str tag='markasread' section='activity'}</label>
</div>
{/if}
<div class="control-wrapper prl">
<input type="checkbox" class="tocheckdel" name="delete-{$item->table}-{$item->id}" id="delete-{$item->table}-{$item->id}">
<label class="marked delete" for="delete-{$item->table}-{$item->id}">{str tag='delete' section='mahara'}</label>
</div>
</div>