/** * Get results for log search with results containing markup/pagination * * @param object Contains: * - userquery string * - functionquery string * - protocol string * - authtype string * - sortby string * - sortdir string * - offset int * - limit int * - onlyerrors string optional * - institution string optional * - institution_requested string optional * * @return array Contains search results markup/pagination */ function build_webservice_log_search_results($search) { global $THEME; $THEME->templatedirs[] = get_config('docroot') . 'auth/webservice/theme/raw/'; $results = get_log_search_results($search); $params = array(); foreach ($search as $k => $v) { if (!empty($v)) { $params[] = $k . '=' . $v; } } $searchurl = get_config('wwwroot') . 'webservice/admin/webservicelogs.php?' . join('&', $params); $pagination = $results['pagination'] = build_pagination(array('id' => 'admin_usersearch_pagination', 'class' => 'center', 'url' => $searchurl, 'count' => $results['count'], 'limit' => $search->limit, 'setlimit' => true, 'jumplinks' => 8, 'numbersincludeprevnext' => 2, 'offset' => $search->offset, 'datatable' => 'searchresults', 'jsonscript' => 'webservice/admin/logsearch.json.php')); $cols = array('username' => array('name' => get_string('userauth', 'auth.webservice'), 'template' => 'auth:webservice:username.tpl', 'class' => 'center', 'sort' => true), 'institution' => array('name' => get_string('institution'), 'sort' => true), 'protocol' => array('name' => get_string('protocol', 'auth.webservice'), 'sort' => true), 'auth' => array('name' => get_string('authtype', 'auth.webservice'), 'sort' => true), 'functionname' => array('name' => get_string('function', 'auth.webservice'), 'sort' => true), 'timetaken' => array('name' => get_string('timetaken', 'auth.webservice'), 'sort' => true), 'timelogged' => array('name' => get_string('timelogged', 'auth.webservice'), 'sort' => true), 'info' => array('name' => get_string('info', 'auth.webservice'), 'class' => 'webservicelogs-info')); $smarty = smarty_core(); $smarty->assign_by_ref('results', $results); $smarty->assign_by_ref('institutions', $institutions); $smarty->assign('searchurl', $searchurl); $smarty->assign('sortby', $search->sortby); $smarty->assign('sortdir', $search->sortdir); $smarty->assign('limitoptions', array(10, 50, 100, 200, 500)); $smarty->assign('pagebaseurl', $searchurl . '&sortby=' . $search->sortby . '&sortdir=' . $search->sortdir); $smarty->assign('cols', $cols); return array($smarty->fetch('searchresulttable.tpl'), $cols, array('url' => $searchurl . '&sortby=' . $search->sortby . '&sortdir=' . $search->sortdir, 'sortby' => $search->sortby, 'sortdir' => $search->sortdir), $pagination); }
/** * This function renders a list of items as html * * @param array items * @param string template * @param array options * @param array pagination */ public function render_items(&$items, $template, $options, $pagination) { $smarty = smarty_core(); $smarty->assign('options', $options); $smarty->assign('items', $items['data']); $items['tablerows'] = $smarty->fetch($template); if ($items['limit'] && $pagination) { $pagination = build_pagination(array('id' => $pagination['id'], 'class' => 'center', 'datatable' => $pagination['datatable'], 'url' => $pagination['baseurl'], 'jsonscript' => $pagination['jsonscript'], 'count' => $items['count'], 'limit' => $items['limit'], 'offset' => $items['offset'], 'numbersincludefirstlast' => false, 'resultcounttextsingular' => $pagination['resultcounttextsingular'] ? $pagination['resultcounttextsingular'] : get_string('result'), 'resultcounttextplural' => $pagination['resultcounttextplural'] ? $pagination['resultcounttextplural'] : get_string('results'))); $items['pagination'] = $pagination['html']; $items['pagination_js'] = $pagination['javascript']; } }
public static function build_myfriends_html(&$friends, $userid, BlockInstance $instance) { $friendarray = array_chunk($friends['data'], 4); // get the friends into a 4x4 array $smarty = smarty_core(); $smarty->assign_by_ref('friends', $friendarray); $friends['tablerows'] = $smarty->fetch('blocktype:myfriends:myfriendrows.tpl'); if ($friends['limit'] === false) { return; } $baseurl = $instance->get_view()->get_url() . '&block=' . $instance->get('id'); $baseurl .= '&user='******'id' => 'userfriendstable_pagination', 'class' => 'center nojs-hidden-block', 'datatable' => 'userfriendstable', 'url' => $baseurl, 'jsonscript' => 'blocktype/myfriends/myfriends.json.php', 'count' => $friends['count'], 'limit' => $friends['limit'], 'offset' => $friends['offset'], 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('friend', 'group'), 'resultcounttextplural' => get_string('friends', 'group'))); $friends['pagination'] = $pagination['html']; $friends['pagination_js'] = $pagination['javascript']; }
function group_get_membersearch_data($results, $group, $query, $membershiptype, $setlimit = false, $sortoption = '') { global $USER; $params = array(); if ($query != '') { $params['query'] = $query; } if (!empty($membershiptype)) { $params['membershiptype'] = $membershiptype; } if (!empty($sortoption)) { $params['sortoption'] = $sortoption; } $searchurl = get_config('wwwroot') . 'group/members.php?id=' . $group . (!empty($params) ? '&' . http_build_query($params) : ''); $smarty = smarty_core(); $role = group_user_access($group); $userid = $USER->get('id'); foreach ($results['data'] as &$r) { if ($role == 'admin' && ($r['id'] != $userid || group_user_can_leave($group, $r['id']))) { $r['removeform'] = group_get_removeuser_form($r['id'], $group); } // NOTE: this is a quick approximation. We should really check whether, // for each role in the group, that the user can change to it (using // group_can_change_role). This only controls whether the 'change // role' link appears though, so it doesn't matter too much. If the // user clicks on this link, changerole.php does the full check and // sends them back here saying that the user has no roles they can // change to anyway. $r['canchangerole'] = !group_is_only_admin($group, $r['id']); } if (!empty($membershiptype)) { if ($membershiptype == 'request') { foreach ($results['data'] as &$r) { $r['addform'] = group_get_adduser_form($r['id'], $group); $r['denyform'] = group_get_denyuser_form($r['id'], $group); // TODO: this will suck when there's quite a few on the page, // would be better to grab all the reasons in one go $r['reason'] = get_field('group_member_request', 'reason', 'group', $group, 'member', $r['id']); } } $smarty->assign('membershiptype', $membershiptype); } $results['cdata'] = array_chunk($results['data'], 2); $results['roles'] = group_get_role_info($group); $smarty->assign_by_ref('results', $results); $smarty->assign('searchurl', $searchurl); $smarty->assign('pagebaseurl', $searchurl); $smarty->assign('caneditroles', group_user_access($group) == 'admin'); $smarty->assign('group', $group); $html = $smarty->fetch('group/membersearchresults.tpl'); $pagination = build_pagination(array('id' => 'member_pagination', 'class' => 'center', 'url' => $searchurl, 'count' => $results['count'], 'setlimit' => $setlimit, 'limit' => $results['limit'], 'offset' => $results['offset'], 'jumplinks' => 8, 'numbersincludeprevnext' => 2, 'datatable' => 'membersearchresults', 'searchresultsheading' => 'searchresultsheading', 'jsonscript' => 'group/membersearchresults.json.php', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('member', 'group'), 'resultcounttextplural' => get_string('members', 'group'))); return array($html, $pagination, $results['count'], $results['offset'], $membershiptype); }
* * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('ADMIN', 1); define('MENUITEM', 'configsite/siteviews'); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'siteviews'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once get_config('libroot') . 'view.php'; require_once 'pieforms/pieform.php'; $limit = param_integer('limit', 5); $offset = param_integer('offset', 0); $title = get_string('siteviews', 'admin'); define('TITLE', $title); $smarty = smarty(); $smarty->assign('heading', $title); $data = View::get_myviews_data($limit, $offset, null, 'mahara'); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'admin/site/views.php', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'))); $smarty->assign('views', $data->data); $smarty->assign('institution', 'mahara'); $smarty->assign('pagination', $pagination['html']); $smarty->assign('createviewform', pieform(create_view_form(null, 'mahara'))); $smarty->assign('createtemplateform', pieform(create_template_form(null, 'mahara'))); $smarty->display('view/index.tpl');
$sortdir = $sort == 'lastchanged' || $sort == 'mtime' ? 'desc' : 'asc'; $share = $queryparams['share'] = $sharedefault = array('user', 'friend', 'group'); $shareoptions = array('user' => get_string('Me', 'view'), 'friend' => get_string('friends', 'view'), 'group' => get_string('mygroups')); if ($USER->get('institutions')) { $shareoptions['institution'] = get_string('myinstitutions', 'group'); } $shareoptions['loggedin'] = get_string('loggedin', 'view'); if (get_config('allowpublicviews')) { $shareoptions['public'] = get_string('public', 'view'); } foreach ($shareoptions as $k => &$v) { $v = array('title' => $v, 'value' => $k, 'defaultvalue' => in_array($k, $sharedefault)); } $searchform = pieform(array('name' => 'search', 'checkdirtychange' => false, 'dieaftersubmit' => false, 'renderer' => 'div', 'class' => 'search', 'elements' => array('query' => array('type' => 'text', 'title' => get_string('Query') . ': ', 'class' => 'inline', 'defaultvalue' => $searchdefault), 'search' => array('type' => 'submit', 'class' => 'inline', 'value' => get_string('go')), 'advanced' => array('type' => 'fieldset', 'legend' => get_string('moreoptions', 'view'), 'class' => 'advanced', 'collapsible' => true, 'collapsed' => true, 'elements' => array('type' => array('type' => 'select', 'title' => get_string('searchwithin') . ': ', 'options' => $searchoptions, 'defaultvalue' => $searchtype), 'sort' => array('type' => 'select', 'title' => get_string('sortresultsby') . ' ', 'options' => $sortoptions, 'defaultvalue' => $sort), 'share' => array('type' => 'checkboxes', 'title' => get_string('sharedwith', 'view') . ': ', 'elements' => $shareoptions, 'labelwidth' => 0)))))); $data = View::shared_to_user($query, $tag, $limit, $offset, $sort, $sortdir, $share); $pagination = build_pagination(array('id' => 'sharedviews_pagination', 'url' => get_config('wwwroot') . 'view/sharedviews.php' . (empty($queryparams) ? '' : '?' . http_build_query($queryparams)), 'jsonscript' => '/json/sharedviews.php', 'datatable' => 'sharedviewlist', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset)); // GC OVERWRITE 2 - add create pages form for continuity $createviewform = pieform(create_view_form()); // END GC OVERWRITE 2 $smarty = smarty(array('paginator')); $smarty->assign('views', $data->data); $smarty->assign('searchform', $searchform); $smarty->assign('pagination', $pagination['html']); // GC OVERWRITE 3 - send createviewform to template $smarty->assign('createviewform', $createviewform); // END GC OVERWRITE 3 $smarty->assign('INLINEJAVASCRIPT', 'addLoadEvent(function() {' . $pagination['javascript'] . '});'); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('view/sharedviews.tpl'); exit; function search_submit(Pieform $form, $values)
public function render_profile_element() { $data = self::get_social_profiles(); // Build pagination for 'socialprofile' artefacts table $baseurl = get_config('wwwroot') . 'artefact/internal/index.php' . '?' . http_build_query(array('fs' => 'social')); $count = count($data); $limit = 500; $offset = 0; $pagination = build_pagination(array('id' => 'socialprofiles_pagination', 'url' => $baseurl, 'datatable' => 'socialprofilelist', 'count' => $count, 'limit' => $limit, 'offset' => $offset)); // User may delete social profile if: // - there is more than 1 social profile and 'socialprofile' is a mandatory field. // - 'socialprofile' is not mandatory. $candelete = true; $mandatory_fields = ArtefactTypeProfile::get_mandatory_fields(); if (isset($mandatory_fields['socialprofile']) && count($data) <= 1) { $candelete = false; } $smarty = smarty_core(); $smarty->assign('controls', true); $smarty->assign('rows', $data); $smarty->assign('candelete', $candelete); $smarty->assign('pagination', $pagination); return array('type' => 'html', 'value' => $smarty->fetch('artefact:internal:socialprofiles.tpl')); }
/** * Returns the search results for the archived submissions * * @param array $search The parameters we want to search against * @param int $offset What result to start showing paginated results from * @param int $limit How many results to show * * @return array A data structure containing results (see top of file). */ function build_admin_archived_submissions_results($search, $offset, $limit) { global $USER; $wantedparams = array('query', 'sortby', 'sortdir', 'institution'); $params = array(); foreach ($search as $k => $v) { if (!in_array($k, $wantedparams)) { continue; } if (!empty($v)) { $params[] = $k . '=' . $v; } } $searchurl = get_config('wwwroot') . 'admin/groups/archives.php?' . join('&', $params) . '&limit=' . $limit; // Use get_admin_user_search_results() as it hooks into the same // funky stuff the user search box query does on user/search.php page. $search->archivedsubmissions = true; $results = get_admin_user_search_results($search, $offset, $limit); // Now that we have the users we need to do some last minute alterations if (!empty($results['count'])) { foreach ($results['data'] as $key => $data) { // alter the archivectime to be human readable $results['data'][$key]['archivectime'] = format_date($data['archivectime']); // make sure the archive file is still on server at the path 'filepath' (not moved or deleted by server admin) $results['data'][$key]['filemissing'] = !file_exists($data['filepath'] . $data['filename']) ? true : false; // make the deleted group name more human readable $results['data'][$key]['groupdeleted'] = false; if (preg_match('/^(.*?)(\\.deleted\\.)(.*)$/', $data['submittedto'], $matches)) { $results['data'][$key]['groupdeleted'] = true; $results['data'][$key]['submittedto'] = $matches[1] . ' (' . get_string('deleted') . ' ' . format_date($matches[3]) . ')'; } } } $pagination = build_pagination(array('id' => 'admin_exportqueue_pagination', 'class' => 'center', 'url' => $searchurl, 'count' => $results['count'], 'setlimit' => true, 'limit' => $limit, 'jumplinks' => 8, 'numbersincludeprevnext' => 2, 'offset' => $offset, 'datatable' => 'searchresults', 'searchresultsheading' => 'resultsheading', 'jsonscript' => 'admin/groups/archives.json.php')); $cols = array('submittedto' => array('name' => get_string('submittedto', 'admin'), 'sort' => true, 'template' => 'admin/groups/submittedtocontentcolumn.tpl'), 'specialid' => array('name' => get_string('ID', 'admin'), 'sort' => true), 'icon' => array('template' => 'admin/users/searchiconcolumn.tpl', 'class' => 'center', 'accessible' => get_string('profileicon')), 'firstname' => array('name' => get_string('firstname'), 'sort' => true, 'template' => 'admin/users/searchfirstnamecolumn.tpl'), 'lastname' => array('name' => get_string('lastname'), 'sort' => true, 'template' => 'admin/users/searchlastnamecolumn.tpl'), 'preferredname' => array('name' => get_string('displayname'), 'sort' => true), 'username' => array('name' => get_string('username'), 'sort' => true, 'template' => 'admin/users/searchusernamecolumn.tpl'), 'filetitle' => array('name' => get_string('filenameleap', 'admin'), 'sort' => true, 'template' => 'admin/groups/leap2acontentcolumn.tpl'), 'archivectime' => array('name' => get_string('archivedon', 'admin'), 'sort' => true)); $smarty = smarty_core(); $smarty->assign_by_ref('results', $results); $smarty->assign('USER', $USER); $smarty->assign('limit', $limit); $smarty->assign('limitoptions', array(10, 50, 100, 200, 500)); $smarty->assign('cols', $cols); $smarty->assign('ncols', count($cols)); $html = $smarty->fetch('searchresulttable.tpl'); return array($html, $cols, $pagination, array('url' => $searchurl, 'sortby' => $search->sortby, 'sortdir' => $search->sortdir)); }
public static function build_html(&$data, $onview) { global $USER, $THEME; $candelete = $data->canedit || $USER->get('admin'); $deletedmessage = array(); foreach (ArtefactTypeAnnotationfeedback::deleted_by_types_description() as $k => $v) { $deletedmessage[$k] = get_string($v, 'artefact.annotation'); } $authors = array(); $lastcomment = self::last_public_annotation_feedback($data->annotation, $data->view, $data->artefact); $editableafter = time() - 60 * get_config_plugin('artefact', 'annotation', 'commenteditabletime'); foreach ($data->data as &$item) { $isadminfeedback = $item->admin == 1 || $item->staff == 1 || $item->feedbackinstitutionadmin == 1 || $item->feedbackinstitutionstaff == 1; $item->ts = strtotime($item->ctime); $item->date = format_date($item->ts, 'strftimedatetime'); if ($item->ts < strtotime($item->lastcontentupdate)) { $item->updated = format_date(strtotime($item->lastcontentupdate), 'strftimedatetime'); } $item->isauthor = $item->author && $item->author == $USER->get('id'); if ($item->private) { $item->pubmessage = get_string('annotationfeedbackisprivate', 'artefact.annotation'); } if (isset($data->showcomment) && $data->showcomment == $item->id) { $item->highlight = 1; } $is_export_preview = param_integer('export', 0); if ($item->deletedby) { $item->deletedmessage = $deletedmessage[$item->deletedby]; } else { if (($candelete || $item->isauthor) && !$is_export_preview && !$isadminfeedback) { // If the auther was admin/staff and not the owner of the annotation, // the feedback can't be deleted. $item->deleteform = pieform(self::delete_annotation_feedback_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id)); } } // Comment authors can edit recent comments if they're private or if no one has replied yet. if (!$item->deletedby && $item->isauthor && !$is_export_preview && ($item->private || $item->id == $lastcomment->id) && $item->ts > $editableafter) { $item->canedit = 1; } // Form to make private comment public, or request that a // private comment be made public. if (!$item->deletedby && $item->private && $item->author && $data->owner && ($item->isauthor || $data->isowner)) { if (empty($item->requestpublic) && $data->isowner || $item->isauthor && $item->requestpublic == 'owner' || $data->isowner && $item->requestpublic == 'author') { if (!$is_export_preview) { $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id)); } } else { if ($item->isauthor && $item->requestpublic == 'author' || $data->isowner && $item->requestpublic == 'owner') { $item->makepublicrequested = 1; } } } else { if (!$item->deletedby && $item->private && !$item->author && $data->owner && $data->isowner && $item->requestpublic == 'author' && !$is_export_preview) { $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id)); } else { if (!$item->deletedby && $item->private && !$data->owner && $item->group && $item->requestpublic == 'author') { // no owner as comment is on a group view / artefact if ($item->isauthor) { $item->makepublicrequested = 1; } else { if ($data->artefact && $data->canedit || $data->view && $data->canedit && !$is_export_preview) { $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id)); } else { $item->makepublicrequested = 1; } } } } } if ($item->author) { if (isset($authors[$item->author])) { $item->author = $authors[$item->author]; } else { $item->author = $authors[$item->author] = (object) array('id' => $item->author, 'username' => $item->username, 'firstname' => $item->firstname, 'lastname' => $item->lastname, 'preferredname' => $item->preferredname, 'email' => $item->email, 'staff' => $item->staff, 'admin' => $item->admin, 'deleted' => $item->deleted, 'profileicon' => $item->profileicon, 'profileurl' => profile_url($item->author)); } } } $extradata = array('annotation' => $data->annotation, 'view' => $data->view, 'artefact' => !empty($data->artefact) ? $data->artefact : '', 'blockid' => $data->block); $data->jsonscript = 'artefact/annotation/annotations.json.php'; $data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?' . 'artefact=' . $data->annotation . '&view=' . $data->view . (isset($data->block) ? '&block=' . $data->block : ''); $smarty = smarty_core(); $smarty->assign_by_ref('data', $data->data); $smarty->assign('canedit', $data->canedit); $smarty->assign('viewid', $data->view); $smarty->assign('position', $data->position); $smarty->assign('baseurl', $data->baseurl); $data->tablerows = $smarty->fetch('artefact:annotation:annotationlist.tpl'); $pagination = build_pagination(array('id' => 'annotationfeedback_pagination_' . $data->block, 'class' => 'center', 'url' => $data->baseurl, 'jsonscript' => $data->jsonscript, 'datatable' => 'annotationfeedbacktable_' . $data->block, 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'forceoffset' => isset($data->forceoffset) ? $data->forceoffset : null, 'resultcounttextsingular' => get_string('annotation', 'artefact.annotation'), 'resultcounttextplural' => get_string('annotations', 'artefact.annotation'), 'extradata' => $extradata)); $data->pagination = $pagination['html']; $data->pagination_js = $pagination['javascript']; }
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz * */ define('INTERNAL', 1); define('MENUITEM', 'myportfolio/collection'); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'collection'); define('SECTION_PAGE', 'index'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; require_once 'collection.php'; define('TITLE', get_string('mycollections', 'collection')); // offset and limit for pagination $offset = param_integer('offset', 0); $limit = param_integer('limit', 5); $data = Collection::get_mycollections_data($offset, $limit); foreach ($data->data as $value) { $collection = new Collection($value->id); $views = $collection->get('views'); if (!empty($views)) { $value->views = $views['views']; } } $pagination = build_pagination(array('id' => 'collectionslist_pagination', 'class' => 'center', 'url' => get_config('wwwroot') . 'collection/index.php', 'jsonscript' => 'collection/collections.json.php', 'datatable' => 'collectionslist', 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('collection', 'collection'), 'resultcounttextplural' => get_string('collections', 'collection'))); $smarty = smarty(array('paginator')); $smarty->assign('collections', $data->data); $smarty->assign('pagination', $pagination['html']); $smarty->assign('strnocollectionsaddone', get_string('nocollectionsaddone', 'collection', '<a href="' . get_config('wwwroot') . 'collection/edit.php?new=1">', '</a>')); $smarty->assign('PAGEHEADING', hsc(get_string('mycollections', 'collection'))); $smarty->display('collection/index.tpl');
/** * Builds the "results" table seen on the universal search results page * @param unknown_type $data */ public static function build_results_html(&$data) { $smarty = smarty_core(); $smarty->assign('data', isset($data['data']) ? $data['data'] : null); $params = array(); if (isset($data['query'])) { $params['query'] = $data['query']; } if (isset($data['selected'])) { $params['mainfacetterm'] = $data['selected']; } if (isset($data['content-filter-selected'])) { $params['secfacetterm'] = $data['content-filter-selected']; } if (isset($data['owner-filter-selected'])) { $params['owner'] = $data['owner-filter-selected']; } if (isset($data['tagsonly'])) { $params['tagsonly'] = $data['tagsonly']; } if (isset($data['sort'])) { $params['sort'] = $data['sort']; } if (isset($data['license'])) { $params['license'] = $data['license']; } if (!isset($data['count'])) { $data['count'] = 0; } if (!isset($data['limit'])) { $data['limit'] = 0; } if (!isset($data['offset'])) { $data['offset'] = 0; } $smarty->assign('offset', $data['offset']); $resultcounttextsingular = get_string('record', 'search.elasticsearch'); $resultcounttextplural = get_string('records', 'search.elasticsearch'); if (isset($data['facets'])) { $smarty->assign('facets', $data['facets']); } if (isset($data['content-filter'])) { $smarty->assign('contentfilter', $data['content-filter']); } if (isset($data['content-filter-selected'])) { $smarty->assign('contentfilterselected', $data['content-filter-selected']); } if (isset($data['owner-filter'])) { $smarty->assign('ownerfilter', $data['owner-filter']); } if (isset($data['owner-filter-selected'])) { $smarty->assign('owner', $data['owner-filter-selected']); } if (isset($data['tagsonly'])) { $smarty->assign('tagsonly', $data['tagsonly']); } if (isset($data['selected'])) { $smarty->assign('selected', $data['selected']); } if (isset($data['sort'])) { $smarty->assign('sort', $data['sort']); } if (isset($data['limit'])) { $smarty->assign('limit', $data['limit']); } if (isset($data['offset'])) { $smarty->assign('offset', $data['offset']); } if (isset($data['license'])) { $smarty->assign('license', $data['license']); } if (isset($data['totalresults'])) { $smarty->assign('totalresults', $data['totalresults']); } // Only show licence if Text or Media tab is selected and license metadata site config is set if (isset($data['license_on']) && isset($data['license_options']) && isset($data['selected']) && ($data['selected'] == 'Media' || $data['selected'] == 'Text')) { $smarty->assign('license_on', $data['license_on']); $smarty->assign('license_options', $data['license_options']); } if (isset($data['type'])) { $smarty->assign('type', $data['type']); } $smarty->assign('query', $params['query']); $data['tablerows'] = $smarty->fetch('Search:elasticsearch:searchresults.tpl'); $pagination = build_pagination(array('id' => 'elasticsearch_pagination', 'url' => get_config('wwwroot') . 'search/elasticsearch/index.php?' . http_build_query($params), 'jsonscript' => 'search/elasticsearch/json/elasticsearch.php', 'datatable' => 'universalsearchresult', 'count' => $data['count'], 'setlimit' => $data['limit'], 'limit' => $data['limit'], 'offset' => $data['offset'], 'jumplinks' => 6, 'numbersincludeprevnext' => 2, 'resultcounttextsingular' => $resultcounttextsingular, 'resultcounttextplural' => $resultcounttextplural, 'extradata' => array('page' => 'index'))); $data['pagination'] = $pagination['html']; $data['pagination_js'] = $pagination['javascript']; }
public static function get_templatesearch_data(&$search) { require_once get_config('libroot') . 'pieforms/pieform.php'; $results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true); foreach ($results->data as &$r) { $r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id'])); } $params = array(); if (!empty($search->query)) { $params[] = 'viewquery=' . $search->query; } if (!empty($search->ownerquery)) { $params[] = 'ownerquery=' . $search->query; } if (!empty($search->group)) { $params[] = 'group=' . $search->group; } if (!empty($search->institution)) { $params[] = 'institution=' . $search->institution; } $params[] = 'viewlimit=' . $search->limit; $smarty = smarty_core(); $smarty->assign_by_ref('results', $results->data); $search->html = $smarty->fetch('view/templatesearchresults.tpl'); $search->count = $results->count; $search->pagination = build_pagination(array('id' => 'templatesearch_pagination', 'class' => 'center', 'url' => get_config('wwwroot') . 'view/choosetemplate.php?' . join('&', $params), 'count' => $results->count, 'limit' => $search->limit, 'offset' => $search->offset, 'offsetname' => 'viewoffset', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'))); }
require dirname(dirname(__FILE__)) . '/init.php'; require_once 'skin.php'; require_once 'pieforms/pieform.php'; define('TITLE', get_string('myskins', 'skin')); if (!can_use_skins()) { throw new FeatureNotEnabledException(); } $filter = param_alpha('filter', 'all'); $limit = param_integer('limit', 6); // For 2x3 grid, showing thumbnails of view skins (2 rows with 3 thumbs each). $offset = param_integer('offset', 0); $metadata = param_integer('metadata', null); $id = param_integer('id', null); $data = Skin::get_myskins_data($limit, $offset, $filter); $form = pieform(array('name' => 'filter', 'method' => 'post', 'renderer' => 'div', 'class' => 'form-inline with-heading', 'elements' => array('inputgroup' => array('type' => 'fieldset', 'title' => get_string('filter'), 'class' => 'input-group', 'elements' => array('options' => array('type' => 'select', 'defaultvalue' => $filter, 'options' => array('all' => get_string('allskins', 'skin'), 'site' => get_string('siteskins', 'skin'), 'user' => get_string('userskins', 'skin'), 'public' => get_string('publicskins', 'skin'))), 'submit' => array('type' => 'button', 'usebuttontag' => true, 'class' => 'btn-primary input-group-btn', 'value' => '<span class="icon icon-filter prs"></span>' . get_string('filter'))))))); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'skin/index.php?filter=' . $filter, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('skin', 'skin'), 'resultcounttextplural' => get_string('skins', 'skin'))); $css = array('<link rel="stylesheet" type="text/css" href="' . $THEME->get_url('style/skin.css') . '">'); $smarty = smarty(array(), $css); $smarty->assign('skins', $data->data); $smarty->assign('user', $USER->get('id')); $smarty->assign('form', $form); $smarty->assign('id', $id); $smarty->assign('metadata', $metadata); $smarty->assign('filter', $filter); $smarty->assign('pagination', $pagination['html']); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('skin/index.tpl'); function filter_submit(Pieform $form, $values) { redirect('/skin/index.php?filter=' . $values['options']); }
$groupids[] = $group->id; } $groups['data'] = get_records_sql_assoc("SELECT g1.id, g1.name, g1.description, g1.jointype, g1.membershiptype, g1.membercount, COUNT(gmr.member) AS requests\n FROM (\n SELECT g.id, g.name, g.description, g.jointype, t.membershiptype, COUNT(gm.member) AS membercount\n FROM {group} g\n LEFT JOIN {group_member} gm ON (gm.group = g.id)\n LEFT JOIN (\n SELECT g.id, 'admin' AS membershiptype\n FROM {group} g\n INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ? AND gm.role = 'admin')\n UNION\n SELECT g.id, 'member' AS membershiptype\n FROM {group} g\n INNER JOIN {group_member} gm ON (g.id = gm.group AND gm.member = ? AND gm.role != 'admin')\n UNION\n SELECT g.id, 'invite' AS membershiptype\n FROM {group} g\n INNER JOIN {group_member_invite} gmi ON (gmi.group = g.id AND gmi.member = ?)\n UNION\n SELECT g.id, 'request' AS membershiptype\n FROM {group} g\n INNER JOIN {group_member_request} gmr ON (gmr.group = g.id AND gmr.member = ?)\n ) t ON t.id = g.id\n WHERE g.id IN (" . implode($groupids, ',') . ') GROUP BY g.id, g.name, g.description, g.jointype, t.membershiptype ORDER BY g.name ) g1 LEFT JOIN {group_member_request} gmr ON (gmr.group = g1.id) GROUP BY g1.id, g1.name, g1.description, g1.jointype, g1.membershiptype, g1.membercount', array($USER->get('id'), $USER->get('id'), $USER->get('id'), $USER->get('id'))); if ($groups['data']) { // Get 3 members from each group in a separate query -- mysql doesn't like including them as subqueries with limit 1 in the above query $members = get_records_sql_array("\n SELECT m1.group, m1.member, u.* FROM {group_member} m1\n INNER JOIN {usr} u ON (m1.member = u.id AND u.deleted = 0)\n WHERE 3 > (\n SELECT COUNT(m2.member)\n FROM {group_member} m2\n WHERE m1.group = m2.group AND m2.member < m1.member\n )\n AND m1.group IN (" . implode($groupids, ',') . ')', array()); if ($members) { foreach ($members as $m) { $groups['data'][$m->group]->members[] = (object) array('id' => $m->id, 'name' => display_name($m)); } } } $groups['data'] = array_values($groups['data']); } group_prepare_usergroups_for_display($groups['data'], 'find'); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'group/find.php?filter=' . $filter . '&query=' . $query, 'count' => $groups['count'], 'limit' => $groupsperpage, 'offset' => $offset, 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group'))); function search_submit(Pieform $form, $values) { redirect('/group/find.php?filter=' . $values['filter'] . (isset($values['query']) ? '&query=' . urlencode($values['query']) : '')); } $smarty = smarty(); $smarty->assign('heading', TITLE); $smarty->assign('form', $searchform); $smarty->assign('groups', $groups['data']); $smarty->assign('pagination', $pagination['html']); $smarty->display('group/find.tpl');
define('TITLE', get_string('Collections', 'collection')); } } $baseurl = get_config('wwwroot') . 'collection/index.php'; if ($urlparams) { $baseurl .= '?' . http_build_query($urlparams); } $data = Collection::get_mycollections_data($offset, $limit, $owner, $groupid, $institutionname); foreach ($data->data as $value) { $collection = new Collection($value->id); $views = $collection->get('views'); if (!empty($views)) { $value->views = $views['views']; } } $pagination = build_pagination(array('id' => 'collectionslist_pagination', 'class' => 'center', 'url' => $baseurl, 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('collection', 'collection'), 'resultcounttextplural' => get_string('collections', 'collection'))); $smarty = smarty(array('paginator'), array(), array(), array('PAGEICON' => $pageIcon)); $urlparamsstr = ''; if ($urlparams) { $urlparamsstr = '&' . http_build_query($urlparams); } if ($canedit) { $smarty->assign('addonelink', get_config('wwwroot') . 'collection/edit.php?new=1' . $urlparamsstr); } if (!empty($institutionname) && $institutionname != 'mahara') { $smarty->assign('institution', $institutionname); $smarty->assign('institutionselector', $s['institutionselector']); $smarty->assign('INLINEJAVASCRIPT', $s['institutionselectorjs']); } if ($subsectionheading) { $smarty->assign('subsectionheading', $subsectionheading);
/** * Create logins by institution table for the site statistics page * * @param int $limit Limit results * @param int $offset Starting offset * @param string $sort DB Column to sort by * @param string/int $sortdesc The direction to sort the $sort column by * @param string $start The start date to filter results by - format 'YYYY-MM-DD HH:MM:SS' * @param string $end The end date to filter results by - format 'YYYY-MM-DD HH:MM:SS' * * @results array Results containing the html / pagination data */ function institution_logins_stats_table($limit, $offset, $sort, $sortdesc, $start, $end) { global $USER; $rawdata = users_active_data(null, null, $sort, $sortdesc, $start, $end); $count = $rawdata ? count($rawdata) : 0; $pagination = build_pagination(array('id' => 'stats_pagination', 'url' => get_config('wwwroot') . 'admin/statistics.php?type=logins&start=' . date('Y-m-d', strtotime($start)) . '&end=' . date('Y-m-d', strtotime($end)), 'jsonscript' => 'admin/statistics.json.php', 'datatable' => 'statistics_table', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'setlimit' => true)); $result = array('count' => $count, 'tablerows' => '', 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript']); if ($count < 1) { return $result; } $csvfields = array('name', 'displayname', 'count_logins', 'count_active'); $USER->set_download_file(generate_csv($rawdata, $csvfields), 'userloginstatistics.csv', 'text/csv'); $result['csv'] = true; $data = array_slice($rawdata, $offset, $limit); $smarty = smarty_core(); $smarty->assign('data', $data); $result['tablerows'] = $smarty->fetch('admin/userloginsummary.tpl'); return $result; }
public static function build_courselist_html($data, $page, $eschool_param = 0, $category_param = 0) { $params = ''; $resultcounttextsingular = get_string('course', 'artefact.courses'); $resultcounttextplural = get_string('courses', 'artefact.courses'); $smarty = smarty_core(); $smarty->assign('data', isset($data['data']) ? $data['data'] : null); $smarty->assign('page', $page); if (isset($data['query'])) { $smarty->assign('query', $data['query']); $params = '?query=' . $data['query']; } elseif (isset($data['filter'])) { $smarty->assign('filter', $data['filter']); $params = '?filter=' . $data['filter']; } if (isset($eschool_param)) { $params .= '&eschool=' . $eschool_param; } if (isset($category_param)) { $params .= '&category=' . $category_param; } $data['tablerows'] = $smarty->fetch('artefact:courses:courseresults.tpl'); $pagination = build_pagination(array('id' => 'courselist_pagination', 'url' => get_config('wwwroot') . 'artefact/courses/' . $page . '.php' . $params, 'jsonscript' => 'artefact/courses/courses.json.php', 'datatable' => 'courselist', 'count' => $data['count'], 'limit' => $data['limit'], 'offset' => $data['offset'], 'resultcounttextsingular' => $resultcounttextsingular, 'resultcounttextplural' => $resultcounttextplural, 'extradata' => array('page' => $page))); $data['pagination'] = $pagination['html']; $data['pagination_js'] = $pagination['javascript']; return $data; }
function build_portfolio_search_html(&$data) { global $THEME; $artefacttypes = get_records_assoc('artefact_installed_type'); require_once 'view.php'; require_once 'collection.php'; foreach ($data->data as &$item) { $item->ctime = format_date($item->ctime); if ($item->type == 'view') { $item->typestr = get_string('view'); $item->icon = $THEME->get_image_url('page'); $v = new View(0, (array) $item); $v->set('dirty', false); $item->url = $v->get_url(); } else { if ($item->type == 'collection') { $item->typestr = get_string('Collection', 'collection'); $item->icon = $THEME->get_image_url('collection'); $c = new Collection(0, (array) $item); $item->url = $c->get_url(); } else { // artefact safe_require('artefact', $artefacttypes[$item->artefacttype]->plugin); $links = call_static_method(generate_artefact_class_name($item->artefacttype), 'get_links', $item->id); $item->url = $links['_default']; $item->icon = call_static_method(generate_artefact_class_name($item->artefacttype), 'get_icon', array('id' => $item->id)); if ($item->artefacttype == 'task') { $item->typestr = get_string('Task', 'artefact.plans'); } else { $item->typestr = get_string($item->artefacttype, 'artefact.' . $artefacttypes[$item->artefacttype]->plugin); } } } } $data->baseurl = get_config('wwwroot') . 'tags.php' . (is_null($data->tag) ? '' : '?tag=' . urlencode($data->tag)); $data->sortcols = array('name', 'date'); $data->filtercols = array('all' => get_string('tagfilter_all'), 'file' => get_string('tagfilter_file'), 'image' => get_string('tagfilter_image'), 'text' => get_string('tagfilter_text'), 'view' => get_string('tagfilter_view'), 'collection' => get_string('tagfilter_collection')); $smarty = smarty_core(); $smarty->assign_by_ref('data', $data->data); $smarty->assign('owner', $data->owner->id); $data->tablerows = $smarty->fetch('portfoliosearchresults.tpl'); $pagination = build_pagination(array('id' => 'results_pagination', 'class' => 'center', 'url' => $data->baseurl . ($data->sort == 'name' ? '' : '&sort=' . $data->sort) . ($data->filter == 'all' ? '' : '&type=' . $data->filter), 'jsonscript' => 'json/tagsearch.php', 'datatable' => 'results', 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2, 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('result'), 'resultcounttextplural' => get_string('results'))); $data->pagination = $pagination['html']; $data->pagination_js = $pagination['javascript']; }
if (!empty($tag)) { $queryparams['tag'] = $tag; $query = null; } else { if ($query != '') { $queryparams['query'] = $query; } } $sortoptions = array('lastchanged', 'mtime', 'ownername', 'title'); if (!in_array($sort = param_alpha('sort', 'lastchanged'), $sortoptions)) { $sort = 'lastchanged'; } if ($sort !== 'lastchanged') { $queryparams['sort'] = $sort; } $sortdir = $sort == 'lastchanged' || $sort == 'mtime' ? 'desc' : 'asc'; $shareoptions = array('user', 'friend', 'group', 'institution', 'loggedin', 'public'); $share = param_variable('share', array()); if (is_array($share)) { $share = $queryparams['share'] = array_intersect($share, $shareoptions); } else { $share = null; } $data = View::shared_to_user($query, $tag, $limit, $offset, $sort, $sortdir, $share); $pagination = build_pagination(array('id' => 'sharedviews_pagination', 'url' => get_config('wwwroot') . 'view/sharedviews.php' . (empty($queryparams) ? '' : '?' . http_build_query($queryparams)), 'jsonscript' => '/json/sharedviews.php', 'datatable' => 'sharedviewlist', 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'setlimit' => true, 'jumplinks' => 8, 'numbersincludeprevnext' => 2)); $smarty = smarty_core(); $smarty->assign_by_ref('views', $data->data); $data->tablerows = $smarty->fetch('view/sharedviewrows.tpl'); $data->pagination = $pagination['html']; $data->pagination_js = $pagination['javascript']; json_reply(false, array('data' => $data));
public static function get_templatesearch_data(&$search) { require_once get_config('libroot') . 'pieforms/pieform.php'; $search->sort = isset($search->sort) ? $search->sort : null; // for backwards compatibility $results = self::view_search($search->query, $search->ownerquery, null, $search->copyableby, $search->limit, $search->offset, true, $search->sort, null, true); $oldcollid = null; foreach ($results->data as &$r) { if (!empty($search->sort)) { $collid = $r['collid'] == $oldcollid ? null : $r['collid']; } else { $collid = $r['collid']; } $r['form'] = pieform(create_view_form($search->copyableby->group, $search->copyableby->institution, $r['id'], $collid)); $oldcollid = $r['collid']; } $params = array(); if (isset($search->query) && $search->query != '') { $params['viewquery'] = $search->query; } if (isset($search->ownerquery) && $search->ownerquery != '') { $params['ownerquery'] = $search->ownerquery; } if (!empty($search->group)) { $params['group'] = $search->group; } if (!empty($search->institution)) { $params['institution'] = $search->institution; } if (!empty($search->collection)) { $params['searchcollection'] = $search->collection; } $params['viewlimit'] = $search->limit; $smarty = smarty_core(); $smarty->assign_by_ref('results', $results->data); $search->html = $smarty->fetch('view/templatesearchresults.tpl'); $search->count = $results->count; $search->pagination = build_pagination(array('id' => 'templatesearch_pagination', 'class' => 'center', 'url' => get_config('wwwroot') . 'view/choosetemplate.php' . (!empty($params) ? '?' . http_build_query($params) : ''), 'count' => $results->count, 'limit' => $search->limit, 'offset' => $search->offset, 'jumplinks' => 6, 'numbersincludeprevnext' => 2, 'offsetname' => 'viewoffset', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'))); }
public static function build_html(&$data) { global $USER, $THEME; $candelete = $data->canedit || $USER->get('admin'); $deletedmessage = array(); foreach (self::deleted_messages() as $k => $v) { $deletedmessage[$k] = get_string($v, 'artefact.comment'); } $authors = array(); $lastcomment = self::last_public_comment($data->view, $data->artefact); $editableafter = time() - 60 * get_config_plugin('artefact', 'comment', 'commenteditabletime'); foreach ($data->data as &$item) { $item->ts = strtotime($item->ctime); $item->date = format_date($item->ts, 'strftimedatetime'); if ($item->ts < strtotime($item->lastcontentupdate)) { $item->updated = format_date(strtotime($item->lastcontentupdate), 'strftimedatetime'); } $item->isauthor = $item->author && $item->author == $USER->get('id'); if (!empty($item->attachments)) { if ($data->isowner) { $item->attachmessage = get_string('feedbackattachmessage', 'artefact.comment', get_string('feedbackattachdirname', 'artefact.comment')); } foreach ($item->attachments as &$a) { $a->attachid = $a->attachment; $a->attachtitle = $a->title; $a->attachsize = display_size($a->size); } } if ($item->private) { $item->pubmessage = get_string('thiscommentisprivate', 'artefact.comment'); } if (isset($data->showcomment) && $data->showcomment == $item->id) { $item->highlight = 1; } $is_export_preview = param_integer('export', 0); if ($item->deletedby) { $item->deletedmessage = $deletedmessage[$item->deletedby]; } else { if (($candelete || $item->isauthor) && !$is_export_preview) { $item->deleteform = pieform(self::delete_comment_form($item->id)); } } // Comment authors can edit recent comments if they're private or if no one has replied yet. if (!$item->deletedby && $item->isauthor && !$is_export_preview && ($item->private || $item->id == $lastcomment->id) && $item->ts > $editableafter) { $item->canedit = 1; } // Form to make private comment public, or request that a // private comment be made public if (!$item->deletedby && $item->private && $item->author && $data->owner && ($item->isauthor || $data->isowner)) { if (empty($item->requestpublic) && $data->isowner || $item->isauthor && $item->requestpublic == 'owner' || $data->isowner && $item->requestpublic == 'author') { if (!$is_export_preview) { $item->makepublicform = pieform(self::make_public_form($item->id)); } } else { if ($item->isauthor && $item->requestpublic == 'author' || $data->isowner && $item->requestpublic == 'owner') { $item->makepublicrequested = 1; } } } else { if (!$item->deletedby && $item->private && !$item->author && $data->owner && $data->isowner && $item->requestpublic == 'author' && !$is_export_preview) { $item->makepublicform = pieform(self::make_public_form($item->id)); } else { if (!$item->deletedby && $item->private && !$data->owner && $item->group && $item->requestpublic == 'author') { // no owner as comment is on a group view / artefact if ($item->isauthor) { $item->makepublicrequested = 1; } else { if ($data->artefact && $data->canedit || $data->view && $data->canedit && !$is_export_preview) { $item->makepublicform = pieform(self::make_public_form($item->id)); } else { $item->makepublicrequested = 1; } } } } } if ($item->author) { if (isset($authors[$item->author])) { $item->author = $authors[$item->author]; } else { $item->author = $authors[$item->author] = (object) array('id' => $item->author, 'username' => $item->username, 'firstname' => $item->firstname, 'lastname' => $item->lastname, 'preferredname' => $item->preferredname, 'email' => $item->email, 'staff' => $item->staff, 'admin' => $item->admin, 'deleted' => $item->deleted, 'profileicon' => $item->profileicon, 'profileurl' => profile_url($item->author)); } } if (get_config_plugin('artefact', 'comment', 'commentratings') and $item->rating) { $item->ratingdata = (object) array('value' => valid_rating($item->rating), 'min_rating' => MIN_RATING, 'max_rating' => MAX_RATING, 'export' => $data->export); } } $extradata = array('view' => $data->view); $data->jsonscript = 'artefact/comment/comments.json.php'; if (!empty($data->artefact)) { $data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $data->view . '&artefact=' . $data->artefact; $extradata['artefact'] = $data->artefact; } else { $data->baseurl = get_config('wwwroot') . 'view/view.php?id=' . $data->view; } $smarty = smarty_core(); $smarty->assign_by_ref('data', $data->data); $smarty->assign('canedit', $data->canedit); $smarty->assign('viewid', $data->view); $smarty->assign('position', $data->position); $smarty->assign('baseurl', $data->baseurl); $data->tablerows = $smarty->fetch('artefact:comment:commentlist.tpl'); $pagination = build_pagination(array('id' => 'feedback_pagination', 'class' => 'center', 'url' => $data->baseurl, 'jsonscript' => $data->jsonscript, 'datatable' => 'feedbacktable', 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'forceoffset' => isset($data->forceoffset) ? $data->forceoffset : null, 'resultcounttextsingular' => get_string('comment', 'artefact.comment'), 'resultcounttextplural' => get_string('comments', 'artefact.comment'), 'extradata' => $extradata)); $data->pagination = $pagination['html']; $data->pagination_js = $pagination['javascript']; }
public static function render_activities(&$activities, $template, $options, $pagination) { $smarty = smarty_core(); $smarty->assign_by_ref('activities', $activities); $smarty->assign_by_ref('options', $options); $activities['tablerows'] = $smarty->fetch($template); if ($activities['limit'] && $pagination) { $pagination = build_pagination(array('id' => $pagination['id'], 'class' => 'center', 'datatable' => $pagination['datatable'], 'url' => $pagination['baseurl'], 'jsonscript' => $pagination['jsonscript'], 'count' => $activities['count'], 'limit' => $activities['limit'], 'offset' => $activities['offset'], 'numbersincludefirstlast' => false, 'resultcounttextsingular' => get_string('activity', 'artefact.cpds'), 'resultcounttextplural' => get_string('activities', 'artefact.cpds'))); $activities['pagination'] = $pagination['html']; $activities['pagination_js'] = $pagination['javascript']; } }
/** * 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); $pagination = build_pagination(array('id' => 'activitylist_pagination', 'url' => get_config('wwwroot') . 'account/activity/index.php?type=' . $type, '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; }
function build_institutions_html($filter, $showdefault, $query, $limit, $offset, &$count = null) { global $USER; $institutions = Institution::count_members($filter, $showdefault, $query, $limit, $offset, $count); $smarty = smarty_core(); $smarty->assign('institutions', $institutions); $smarty->assign('siteadmin', $USER->get('admin')); $data['tablerows'] = $smarty->fetch('admin/users/institutionsresults.tpl'); $pagination = build_pagination(array('id' => 'adminstitutionslist_pagination', 'datatable' => 'adminstitutionslist', 'url' => get_config('wwwroot') . 'admin/users/institutions.php' . (!empty($query) ? '?query=' . urlencode($query) : ''), 'jsonscript' => 'admin/users/institutions.json.php', 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('institution', 'admin'), 'resultcounttextplural' => get_string('institutions', 'admin'))); $data['pagination'] = $pagination['html']; $data['pagination_js'] = $pagination['javascript']; return $data; }
$offset = param_integer('offset', 0); define('GROUP', param_integer('group')); $group = group_current_group(); if (!is_logged_in() && !$group->public) { throw new AccessDeniedException(); } define('TITLE', $group->name . ' - ' . get_string('groupviews', 'view')); $member = group_user_access($group->id); $shared = param_boolean('shared', 0) && $member; $can_edit = group_user_can_edit_views($group->id); $smarty = smarty(); $smarty->assign('heading', $group->name); if ($can_edit) { $data = View::get_myviews_data($limit, $offset, $group->id); } else { $data = View::view_search(null, null, (object) array('group' => $group->id), null, $limit, $offset); } $userid = $USER->get('id'); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'view/groupviews.php?group=' . $group->id, 'count' => $data->count, 'limit' => $limit, 'offset' => $offset, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view'))); $smarty->assign('groupviews', 1); $smarty->assign('member', $member); $smarty->assign('views', $data->data); $smarty->assign('pagination', $pagination['html']); $smarty->assign('createviewform', pieform(create_view_form($group->id))); $smarty->assign('createtemplateform', pieform(create_template_form($group->id))); if ($can_edit) { // && !$shared) { $smarty->display('view/index.tpl'); } else { $smarty->display('view/sharedviews.tpl'); }
// If the user has internal notifications for this topic, mark them // all as read. Obviously there's no guarantee the user will actually // read all the posts on this page, but better than letting the unread // notifications grow too fast. Unfortunately the only way to find // notifications on this topic is to look for the url of this page. execute_sql(' UPDATE {notification_internal_activity} SET "read" = 1 WHERE "read" = 0 AND usr = ? AND url LIKE ? || \'%\' AND type = ( SELECT id FROM {activity_type} WHERE name = ? )', array($USER->get('id'), get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid . '&post=', 'newpost')); // renders a page of posts $posts = buildpostlist($posts, $indentmode, $maxindentdepth); // adds posts pagination $postcount = count_records_sql('SELECT COUNT(id) FROM {interaction_forum_post} WHERE topic = ?', array($topicid)); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topicid, 'count' => $postcount, 'limit' => $limit, 'offset' => $offset)); $headers = array(); if ($publicgroup) { $headers[] = '<link rel="alternate" type="application/atom+xml" href="' . $feedlink . '">'; } $smarty = smarty(array(), $headers); $smarty->assign('topic', $topic); $smarty->assign('membership', $membership); $smarty->assign('moderator', $moderator); $smarty->assign('lastpostid', $lastpostid); $smarty->assign('posts', $posts); $smarty->assign('pagination', $pagination['html']); $smarty->display('interaction:forum:topic.tpl'); /* * Render a page of posts *
function build_userlist_html(&$data, $page, $admingroups) { if ($data['data']) { $userlist = join(',', array_map(create_function('$u', 'return (int)$u[\'id\'];'), $data['data'])); $userdata = get_users_data($userlist, $page == 'myfriends'); } $smarty = smarty_core(); $smarty->assign('data', isset($userdata) ? $userdata : null); $smarty->assign('page', $page); if (isset($data['query'])) { $smarty->assign('query', $data['query']); $params = '?query=' . $data['query']; $resultcounttextsingular = get_string('user', 'group'); $resultcounttextplural = get_string('users', 'group'); } elseif (isset($data['filter'])) { $smarty->assign('filter', $data['filter']); $params = '?filter=' . $data['filter']; $resultcounttextsingular = get_string('friend', 'group'); $resultcounttextplural = get_string('friends', 'group'); } $smarty->assign('admingroups', $admingroups); $data['tablerows'] = $smarty->fetch('user/userresults.tpl'); $pagination = build_pagination(array('id' => 'friendslist_pagination', 'url' => get_config('wwwroot') . 'user/' . $page . '.php' . $params, 'jsonscript' => 'json/friendsearch.php', 'datatable' => 'friendslist', 'count' => $data['count'], 'limit' => $data['limit'], 'offset' => $data['offset'], 'resultcounttextsingular' => $resultcounttextsingular, 'resultcounttextplural' => $resultcounttextplural, 'extradata' => array('page' => $page))); $data['pagination'] = $pagination['html']; $data['pagination_js'] = $pagination['javascript']; }
function build_onlinelist_html(&$data, $page) { if ($data['data']) { $userdata = get_users_data($data['data'], false); } $smarty = smarty_core(); $smarty->assign('data', isset($userdata) ? $userdata : null); $smarty->assign('page', $page); $resultcounttextsingular = get_string('user', 'group'); $resultcounttextplural = get_string('users', 'group'); $data['tablerows'] = $smarty->fetch('user/onlineuserresults.tpl'); $pagination = build_pagination(array('id' => 'onlinelist_pagination', 'url' => get_config('wwwroot') . 'user/' . $page . '.php', 'datatable' => 'onlinelist', 'count' => $data['count'], 'limit' => $data['limit'], 'offset' => $data['offset'], 'resultcounttextsingular' => $resultcounttextsingular, 'resultcounttextplural' => $resultcounttextplural, 'extradata' => array('page' => $page))); $data['pagination'] = $pagination['html']; $data['pagination_js'] = $pagination['javascript']; }
LEFT JOIN {interaction_forum_topic} t2 ON (p4.topic = t2.id) LEFT JOIN ( SELECT m.forum, m.user FROM {interaction_forum_moderator} m INNER JOIN {usr} u ON (m.user = u.id AND u.deleted = 0) ) m2 ON (p4.poster = m2.user AND t2.forum = m2.forum) WHERE t.forum = ? AND t.sticky = ? AND t.deleted != 1 GROUP BY 1, 2, 3, 4, 5, 6, 8, 9, 10, p4.ctime, p4.poster, p4.id, m2.user ORDER BY p4.ctime DESC, p4.id DESC'; $stickytopics = get_records_sql_array($sql, array($userid, $forumid, 1)); $regulartopics = get_records_sql_array($sql, array($userid, $forumid, 0), $offset, $topicsperpage); setup_topics($stickytopics); setup_topics($regulartopics); $pagination = build_pagination(array('url' => get_config('wwwroot') . 'interaction/forum/view.php?id=' . $forumid, 'count' => $forum->topiccount, 'limit' => $topicsperpage, 'offset' => $offset, 'resultcounttextsingular' => get_string('topiclower', 'interaction.forum'), 'resultcounttextplural' => get_string('topicslower', 'interaction.forum'))); $inlinejavascript = <<<EOF addLoadEvent(function() { forEach(getElementsByTagAndClassName('input', 'topic-checkbox'), function(checkbox) { var tr = getFirstParentByTagAndClassName(checkbox, 'tr', null); var origColour = tr.style.backgroundColor; connect(checkbox, 'onclick', function(e) { if (tr.style.backgroundColor == origColour) { tr.style.backgroundColor = '#ffc'; } else { tr.style.backgroundColor = origColour; } }); }); });
} $files = ArtefactType::attachments_from_id_list($noteids); if ($files) { safe_require('artefact', 'file'); foreach ($files as $file) { $file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment)); $data[$file->artefact]->files[] = $file; } } // Add Attachments count for each Note if ($data) { foreach ($data as $item) { $item->count = isset($item->files) ? count($item->files) : 0; } } $pagination = build_pagination(array('id' => 'notes_pagination', 'url' => $baseurl, 'datatable' => 'notes', 'count' => $count, 'limit' => $limit, 'offset' => $offset)); $js = ' jQuery(function($) { $("a.notetitle").click(function(e) { e.preventDefault(); $("#" + this.id + "_desc").toggleClass("hidden"); }); });'; $smarty = smarty(); $smarty->assign('PAGEHEADING', $pageheading); $smarty->assign('INLINEJAVASCRIPT', $js); $smarty->assign_by_ref('data', $data); $smarty->assign('pagination', $pagination); $smarty->display('artefact:internal:notes.tpl'); function deletenote_form($id, $notedata) {