public static function get_link(BlockInstance $instance) { safe_require('module', 'multirecipientnotification'); if (PluginModuleMultirecipientnotification::is_active()) { $data = get_config('wwwroot') . 'module/multirecipientnotification/inbox.php'; } else { $data = get_config('wwwroot') . 'account/activity/index.php'; } return sanitize_url($data); }
/** * API-Function get the provided Menus. It is possible to overwrite existing menuentries * by redefining them with the same path, title and weight. * * @return array fully descripted new menuitems with menupath, title, url, etc. */ public static function right_nav_menu_items() { global $USER; global $THEME; safe_require('notification', 'internal'); $unread = $USER->get('unread'); $menuExtensions = array('inbox' => array('path' => 'inbox', 'url' => 'module/multirecipientnotification/inbox.php', 'alt' => get_string('inbox'), 'title' => get_string('inbox'), 'count' => $unread, 'countclass' => 'unreadmessagecount', 'linkid' => 'mail', 'weight' => 20, 'iconclass' => 'envelope')); // Templates if (PluginModuleMultirecipientnotification::is_active()) { // search for path $searchFor = '/user\\/sendmessage.php/'; if (preg_match($searchFor, $_SERVER['REQUEST_URI']) == 1) { // set new path $redirTarget = get_config('wwwroot') . 'module/multirecipientnotification/sendmessage.php'; if (!empty($_SERVER['QUERY_STRING'])) { // change path $redirTarget .= '?' . $_SERVER['QUERY_STRING']; } redirect($redirTarget); exit; } } return $menuExtensions; }
function delete_all_notifications_submit() { global $USER, $SESSION; $userid = $USER->get('id'); $type = param_variable('type', 'all'); $typesql = ''; if ($type != 'all') { // Treat as comma-separated list of activity type names $types = explode(',', preg_replace('/[^a-z,]+/', '', $type)); if ($types) { $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')'; if (in_array('adminmessages', $types)) { $typesql = '(' . $typesql . ' OR at.admin = 1)'; } $typesql = ' AND ' . $typesql; } } $from = "\n FROM {notification_internal_activity} a\n JOIN {activity_type} at ON a.type = at.id\n WHERE a.usr = ? {$typesql}"; $values = array($userid); db_begin(); $count = 0; $records = get_records_sql_array('SELECT a.id ' . $from, $values); if ($records) { $count = sizeof($records); $ids = array(); foreach ($records as $row) { $ids[] = $row->id; } // Remove parent pointers to messages we're about to delete execute_sql(' UPDATE {notification_internal_activity} SET parent = NULL WHERE parent IN ( ' . join(',', array_map('db_quote', $ids)) . ' )'); // delete execute_sql(' DELETE FROM {notification_internal_activity} WHERE id IN ( ' . join(',', array_map('db_quote', $ids)) . ' )'); // The update_unread_delete db trigger on notification_internal_activity // will update the unread column on the usr table. } db_commit(); $SESSION->add_ok_msg(get_string('deletednotifications1', 'activity', $count)); safe_require('module', 'multirecipientnotification'); if (PluginModuleMultirecipientnotification::is_active()) { redirect(get_config('wwwroot') . 'module/multirecipientnotification/inbox.php?type=' . $type); } else { redirect(get_config('wwwroot') . 'account/activity/index.php?type=' . $type); } }
/** * Build the html for a list of staff information * * @param object $data * @param string $page * @param string $listtype * @param string $institution */ function build_stafflist_html(&$data, $page, $listtype, $inst = 'mahara') { global $USER; if ($data) { $data = get_users_data($data, false); } $smarty = smarty_core(); $smarty->assign('page', $page); $smarty->assign('listtype', $listtype); $smarty->assign('inst', $inst); $smarty->assign('USER', $USER); if (count($data) > 5) { $split = ceil(count($data) / 2); $columns = array_chunk($data, $split); } if (isset($columns) && count($columns) == 2) { $smarty->assign('columnleft', $columns[0]); $smarty->assign('columnright', $columns[1]); } else { $smarty->assign('data', isset($data) ? $data : null); } safe_require('module', 'multirecipientnotification'); $smarty->assign('mrmoduleactive', PluginModuleMultirecipientnotification::is_active()); $data['tablerows'] = $smarty->fetch('institution/stafflist.tpl'); }
/** * Get one page of notifications and return html */ function activitylist_html($type = 'all', $limit = 10, $offset = 0) { global $USER; $userid = $USER->get('id'); $typesql = ''; if ($type != 'all') { // Treat as comma-separated list of activity type names $types = explode(',', preg_replace('/[^a-z,]+/', '', $type)); if ($types) { $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')'; if (in_array('adminmessages', $types)) { $typesql = '(' . $typesql . ' OR at.admin = 1)'; } $typesql = ' AND ' . $typesql; } } $from = "\n FROM {notification_internal_activity} a\n JOIN {activity_type} at ON a.type = at.id\n WHERE a.usr = ? {$typesql}"; $values = array($userid); $count = count_records_sql('SELECT COUNT(*)' . $from, $values); safe_require('module', 'multirecipientnotification'); if (PluginModuleMultirecipientnotification::is_active()) { $paginationurl = get_config('wwwroot') . 'module/multirecipientnotification/inbox.php?type=' . $type; } else { $paginationurl = get_config('wwwroot') . 'account/activity/index.php?type=' . $type; } $pagination = build_pagination(array('id' => 'activitylist_pagination', 'url' => $paginationurl, 'jsonscript' => 'account/activity/index.json.php', 'datatable' => 'activitylist', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2)); $result = array('count' => $count, 'limit' => $limit, 'offset' => $offset, 'type' => $type, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']); if ($count < 1) { return $result; } $records = get_records_sql_array(' SELECT a.*, at.name AS type, at.plugintype, at.pluginname' . $from . ' ORDER BY a.ctime DESC', $values, $offset, $limit); if ($records) { foreach ($records as &$r) { $r->date = format_date(strtotime($r->ctime), 'strfdaymonthyearshort'); $section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}"; $r->strtype = get_string('type' . $r->type, $section); $r->message = format_notification_whitespace($r->message); } } $smarty = smarty_core(); $smarty->assign('data', $records); $result['tablerows'] = $smarty->fetch('account/activity/activitylist.tpl'); return $result; }
if ($loggedinid && $loggedinid == $userid) { $smarty->assign('ownprofile', true); } $smarty->assign('pageheadinghtml', $view->display_title(false)); if ($skin) { if ($skindata['header_logo_image'] == 'light' || $skindata['header_logo_image'] == 'dark') { // override the default $smarty->assign('sitelogo') that happens // in the initial call to smarty() $smarty->assign('sitelogo', $THEME->header_logo($skindata['header_logo_image'])); } } if (!$restrictedview) { $smarty->assign('viewcontent', $viewcontent); } safe_require('module', 'multirecipientnotification'); $smarty->assign('mrmoduleactive', PluginModuleMultirecipientnotification::is_active()); $smarty->display('user/view.tpl'); mahara_log('views', "{$viewid}"); // Log view visits // Send an invitation to the user to join a group function invite_submit(Pieform $form, $values) { global $userid; redirect('/group/invite.php?id=' . $values['group'] . '&user='******'group', 'id', $values['group']); $ctitle = $group->name;
* @author David Ballhausen, Tobias Zeuch * @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. * */ define('INTERNAL', 1); define('MENUITEM', 'inbox'); define('SECTION_PLUGINTYPE', 'module'); define('SECTION_PLUGINNAME', 'multirecipientnotification'); define('SECTION_PAGE', 'inbox'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; safe_require('module', 'multirecipientnotification'); global $USER; global $THEME; if (!PluginModuleMultirecipientnotification::is_active()) { $redirTarget = get_config('wwwroot') . 'account/activity/inbox.php'; if (!empty($_SERVER['QUERY_STRING'])) { // change path $redirTarget .= '?' . $_SERVER['QUERY_STRING']; } redirect($redirTarget); exit; } // Add new title define('TITLE', get_string('notification', 'module.multirecipientnotification')); // Make sure the unread message count is up to date whenever the // user hits this page. $USER->reload_background_fields(); $installedtypes = get_records_assoc('activity_type', '', '', 'plugintype,pluginname,name', 'name,admin,plugintype,pluginname'); $options = array();