[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Display all recent activity in a flexible way 20 * 21 * @copyright 1999 Martin Dougiamas http://dougiamas.com 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @package course 24 */ 25 26 if (!defined('MOODLE_INTERNAL')) { 27 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page 28 } 29 30 require_once($CFG->libdir.'/formslib.php'); 31 32 class recent_form extends moodleform { 33 function definition() { 34 global $CFG, $COURSE, $USER; 35 36 $mform =& $this->_form; 37 $context = context_course::instance($COURSE->id); 38 $modinfo = get_fast_modinfo($COURSE); 39 40 $mform->addElement('header', 'filters', get_string('managefilters')); //TODO: add better string 41 42 $groupoptions = array(); 43 if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { 44 // limited group access 45 $groups = groups_get_user_groups($COURSE->id); 46 $allgroups = groups_get_all_groups($COURSE->id); 47 if (!empty($groups[$COURSE->defaultgroupingid])) { 48 foreach ($groups[$COURSE->defaultgroupingid] AS $groupid) { 49 $groupoptions[$groupid] = format_string($allgroups[$groupid]->name, true, array('context'=>$context)); 50 } 51 } 52 } else { 53 $groupoptions = array('0'=>get_string('allgroups')); 54 if (has_capability('moodle/site:accessallgroups', $context)) { 55 // user can see all groups 56 $allgroups = groups_get_all_groups($COURSE->id); 57 } else { 58 // user can see course level groups 59 $allgroups = groups_get_all_groups($COURSE->id, 0, $COURSE->defaultgroupingid); 60 } 61 foreach($allgroups as $group) { 62 $groupoptions[$group->id] = format_string($group->name, true, array('context'=>$context)); 63 } 64 } 65 66 if ($COURSE->id == SITEID) { 67 $viewparticipants = has_capability('moodle/site:viewparticipants', context_system::instance()); 68 } else { 69 $viewparticipants = has_capability('moodle/course:viewparticipants', $context); 70 } 71 72 if ($viewparticipants) { 73 $viewfullnames = has_capability('moodle/site:viewfullnames', context_course::instance($COURSE->id)); 74 75 $options = array(); 76 $options[0] = get_string('allparticipants'); 77 $options[$CFG->siteguest] = get_string('guestuser'); 78 79 if (isset($groupoptions[0])) { 80 // can see all enrolled users 81 if ($enrolled = get_enrolled_users($context, null, 0, user_picture::fields('u'))) { 82 foreach ($enrolled as $euser) { 83 $options[$euser->id] = fullname($euser, $viewfullnames); 84 } 85 } 86 } else { 87 // can see users from some groups only 88 foreach ($groupoptions as $groupid=>$unused) { 89 if ($enrolled = get_enrolled_users($context, null, $groupid, user_picture::fields('u'))) { 90 foreach ($enrolled as $euser) { 91 if (!array_key_exists($euser->id, $options)) { 92 $options[$euser->id] = fullname($euser, $viewfullnames); 93 } 94 } 95 } 96 } 97 } 98 99 $mform->addElement('select', 'user', get_string('participants'), $options); 100 $mform->setAdvanced('user'); 101 } else { 102 // Default to no user. 103 $mform->addElement('hidden', 'user', 0); 104 $mform->setType('user', PARAM_INT); 105 $mform->setConstant('user', 0); 106 } 107 108 $options = array(''=>get_string('allactivities')); 109 $modsused = array(); 110 111 foreach($modinfo->cms as $cm) { 112 if (!$cm->uservisible) { 113 continue; 114 } 115 $modsused[$cm->modname] = true; 116 } 117 118 foreach ($modsused as $modname=>$unused) { 119 $libfile = "$CFG->dirroot/mod/$modname/lib.php"; 120 if (!file_exists($libfile)) { 121 unset($modsused[$modname]); 122 continue; 123 } 124 include_once($libfile); 125 $libfunction = $modname."_get_recent_mod_activity"; 126 if (!function_exists($libfunction)) { 127 unset($modsused[$modname]); 128 continue; 129 } 130 $options["mod/$modname"] = get_string('allmods', '', get_string('modulenameplural', $modname)); 131 } 132 133 foreach ($modinfo->sections as $section=>$cmids) { 134 $options["section/$section"] = "-- ".get_section_name($COURSE, $section)." --"; 135 foreach ($cmids as $cmid) { 136 $cm = $modinfo->cms[$cmid]; 137 if (empty($modsused[$cm->modname]) or !$cm->uservisible) { 138 continue; 139 } 140 $options[$cm->id] = format_string($cm->name); 141 } 142 } 143 $mform->addElement('select', 'modid', get_string('activities'), $options); 144 $mform->setAdvanced('modid'); 145 146 147 if ($groupoptions) { 148 $mform->addElement('select', 'group', get_string('groups'), $groupoptions); 149 $mform->setAdvanced('group'); 150 } else { 151 // no access to groups in separate mode 152 $mform->addElement('hidden','group'); 153 $mform->setType('group', PARAM_INT); 154 $mform->setConstants(array('group'=>-1)); 155 } 156 157 $options = array('default' => get_string('bycourseorder'), 158 'dateasc' => get_string('datemostrecentlast'), 159 'datedesc' => get_string('datemostrecentfirst')); 160 $mform->addElement('select', 'sortby', get_string('sortby'), $options); 161 $mform->setAdvanced('sortby'); 162 163 $mform->addElement('date_time_selector', 'date', get_string('since'), array('optional'=>true)); 164 165 $mform->addElement('hidden','id'); 166 $mform->setType('id', PARAM_INT); 167 $mform->setType('courseid', PARAM_INT); 168 169 $this->add_action_buttons(false, get_string('showrecent')); 170 } 171 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |