define('GROUP', param_integer('group')); $wwwroot = get_config('wwwroot'); $needsubdomain = get_config('cleanurlusersubdomains'); $limit = param_integer('limit', 0); $userlimit = get_account_preference($USER->get('id'), 'viewsperpage'); if ($limit > 0 && $limit != $userlimit) { $USER->set_account_preference('viewsperpage', $limit); } else { $limit = $userlimit; } $offset = param_integer('offset', 0); $sort = param_variable('sort', 'title'); $direction = param_variable('direction', 'asc'); $group = group_current_group(); $role = group_user_access($group->id); if (!group_role_can_access_report($group, $role)) { throw new AccessDeniedException(); } $sharedviews = View::get_participation_sharedviews_data($group->id, $sort, $direction, $limit, $offset); $pagination = array('baseurl' => $wwwroot . 'group/report.php?group=' . $group->id . '&sort=' . $sort . '&direction=' . $direction, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewsreport', 'jsonscript' => 'group/participationsharedviews.json.php', 'setlimit' => true, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); View::render_participation_views($sharedviews, 'group/participationsharedviews.tpl', $pagination); $groupviews = View::get_participation_groupviews_data($group->id, $sort, $direction, $limit, $offset); $pagination = array('baseurl' => $wwwroot . 'group/report.php?group=' . $group->id . '&sort=' . $sort . '&direction=' . $direction, 'id' => 'groupviews_pagination', 'datatable' => 'groupviewsreport', 'jsonscript' => 'group/participationgroupviews.json.php', 'setlimit' => true, 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); View::render_participation_views($groupviews, 'group/participationgroupviews.tpl', $pagination); $smarty = smarty(array('paginator')); $smarty->assign('baseurl', get_config('wwwroot') . 'group/report.php?group=' . $group->id); $smarty->assign('heading', $group->name); $smarty->assign('sharedviews', $sharedviews); $smarty->assign('groupviews', $groupviews); $smarty->assign('sort', $sort); $smarty->assign('direction', $direction);
/** * Returns a datastructure describing the tabs that appear on a group page * * @param object $group Database record of group to get tabs for * @return array */ function group_get_menu_tabs() { static $menu; $group = group_current_group(); if (!$group) { return null; } $role = group_user_access($group->id); $menu = array('info' => array('path' => 'groups/info', 'url' => group_homepage_url($group, false), 'title' => get_string('About', 'group'), 'weight' => 20)); if (group_can_list_members($group, $role)) { $menu['members'] = array('path' => 'groups/members', 'url' => 'group/members.php?id=' . $group->id, 'title' => get_string('Members', 'group'), 'weight' => 30); } if ($interactionplugins = plugins_installed('interaction')) { foreach ($interactionplugins as $plugin) { safe_require('interaction', $plugin->name); $plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'group_menu_items', $group); $menu = array_merge($menu, $plugin_menu); } } $menu['views'] = array('path' => 'groups/views', 'url' => 'view/groupviews.php?group=' . $group->id, 'title' => get_string('Views', 'group'), 'weight' => 50); $menu['collections'] = array('path' => 'groups/collections', 'url' => 'collection/index.php?group=' . $group->id, 'title' => get_string('Collections', 'group'), 'weight' => 60); if (group_role_can_edit_views($group, $role)) { $menu['share'] = array('path' => 'groups/share', 'url' => 'group/shareviews.php?group=' . $group->id, 'title' => get_string('share', 'view'), 'weight' => 70); } if ($role) { safe_require('grouptype', $group->grouptype); $artefactplugins = call_static_method('GroupType' . $group->grouptype, 'get_group_artefact_plugins'); if ($plugins = plugins_installed('artefact')) { foreach ($plugins as &$plugin) { if (!in_array($plugin->name, $artefactplugins)) { continue; } safe_require('artefact', $plugin->name); $plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'group_tabs', $group->id); $menu = array_merge($menu, $plugin_menu); } } } if (group_role_can_access_report($group, $role)) { $menu['report'] = array('path' => 'groups/report', 'url' => 'group/report.php?group=' . $group->id, 'title' => get_string('report', 'group'), 'weight' => 70); } if (defined('MENUITEM')) { $key = substr(MENUITEM, strlen('groups/')); if ($key && isset($menu[$key])) { $menu[$key]['selected'] = true; } } return $menu; }
/** * Returns a datastructure describing the tabs that appear on a group page * * @param object $group Database record of group to get tabs for * @return array */ function group_get_menu_tabs() { static $menu; $group = group_current_group(); if (!$group) { return null; } $role = group_user_access($group->id); $menu = array('info' => array('path' => 'groups/info', 'url' => group_homepage_url($group, false), 'title' => get_string('About', 'group'), 'weight' => 20)); if (group_can_list_members($group, $role)) { $menu['members'] = array('path' => 'groups/members', 'url' => 'group/members.php?id=' . $group->id, 'title' => get_string('Members', 'group'), 'weight' => 30); } if ($interactionplugins = plugins_installed('interaction')) { foreach ($interactionplugins as $plugin) { safe_require('interaction', $plugin->name); $plugin_menu = call_static_method(generate_class_name('interaction', $plugin->name), 'group_menu_items', $group); $menu = array_merge($menu, $plugin_menu); } } $menu['subnav'] = array('class' => 'group'); $menu['views'] = array('path' => 'groups/views', 'url' => 'view/groupviews.php?group=' . $group->id, 'title' => get_string('Views', 'group'), 'weight' => 50); $menu['collections'] = array('path' => 'groups/collections', 'url' => 'collection/index.php?group=' . $group->id, 'title' => get_string('Collections', 'group'), 'weight' => 60); if (group_role_can_edit_views($group, $role)) { $menu['share'] = array('path' => 'groups/share', 'url' => 'group/shareviews.php?group=' . $group->id, 'title' => get_string('share', 'view'), 'weight' => 70); } if ($role) { safe_require('grouptype', $group->grouptype); $artefactplugins = call_static_method('GroupType' . $group->grouptype, 'get_group_artefact_plugins'); if ($plugins = plugins_installed('artefact')) { foreach ($plugins as &$plugin) { if (!in_array($plugin->name, $artefactplugins)) { continue; } safe_require('artefact', $plugin->name); $plugin_menu = call_static_method(generate_class_name('artefact', $plugin->name), 'group_tabs', $group->id); $menu = array_merge($menu, $plugin_menu); } } } if (group_role_can_access_report($group, $role)) { $menu['report'] = array('path' => 'groups/report', 'url' => 'group/report.php?group=' . $group->id, 'title' => get_string('report', 'group'), 'weight' => 70); } if (defined('MENUITEM')) { $key = substr(MENUITEM, strlen('groups/')); if ($key && isset($menu[$key])) { $menu[$key]['selected'] = true; } } // Sort the menu items by weight uasort($menu, function ($a, $b) { // Only items with a "weight" component need to get sorted. Ones without weight can go first. if (!array_key_exists('weight', $a)) { return -1; } if (!array_key_exists('weight', $b)) { return 1; } $aweight = $a['weight']; $bweight = $b['weight']; if ($aweight == $bweight) { return 0; } return $aweight < $bweight ? -1 : 1; }); return $menu; }