[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/course/ -> recent_form.php (source)

   1  <?php //$$
   2  
   3  require_once($CFG->libdir.'/formslib.php');
   4  
   5  class recent_form extends moodleform {
   6      function definition() {
   7          global $CFG, $COURSE, $USER;
   8  
   9          $mform =& $this->_form;
  10          $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
  11          $modinfo = get_fast_modinfo($COURSE);
  12  
  13          $mform->addElement('header', 'filters', get_string('managefilters')); //TODO: add better string
  14  
  15          if ($COURSE->id == SITEID) {
  16              $viewparticipants = has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM));
  17          } else {
  18              $viewparticipants = has_capability('moodle/course:viewparticipants', $context);
  19          }
  20  
  21          $viewfullnames = has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $COURSE->id));
  22  
  23          if ($viewparticipants) {
  24              $options = array();
  25              $options[0] = get_string('allparticipants');
  26              if ($guest = get_guest()) {
  27                  $options[$guest->id] = fullname($guest);
  28              }
  29  
  30              if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS) {
  31                  $groups = groups_get_user_groups($COURSE->id);
  32                  $groups = $groups[0];
  33              } else {
  34                  $groups = '';
  35              }
  36              
  37              if ($courseusers = get_users_by_capability($context, 'moodle/course:view', 'u.id, u.firstname, u.lastname', 'lastname ASC, firstname DESC', '', '', $groups)) {
  38                  foreach ($courseusers as $courseuser) {
  39                      $options[$courseuser->id] = fullname($courseuser, $viewfullnames);
  40                  }
  41              }
  42              $mform->addElement('select', 'user', get_string('participants'), $options);
  43              $mform->setAdvanced('user');
  44          }
  45  
  46          switch ($COURSE->format) {
  47              case 'weeks':  $sectiontitle = get_string('week'); break;
  48              case 'topics': $sectiontitle = get_string('topic'); break;
  49              default: $sectiontitle = get_string('section'); break;
  50          }
  51  
  52          $options = array(''=>get_string('allactivities'));
  53          $modsused = array();
  54  
  55          foreach($modinfo->cms as $cm) {
  56              if (!$cm->uservisible) {
  57                  continue;
  58              }
  59              $modsused[$cm->modname] = true;
  60          }
  61  
  62          foreach ($modsused as $modname=>$unused) {
  63              $libfile = "$CFG->dirroot/mod/$modname/lib.php";
  64              if (!file_exists($libfile)) {
  65                  unset($modsused[$modname]);
  66                  continue;
  67              }
  68              include_once($libfile);
  69              $libfunction = $modname."_get_recent_mod_activity";
  70              if (!function_exists($libfunction)) {
  71                  unset($modsused[$modname]);
  72                  continue;
  73              }
  74              $options["mod/$modname"] = get_string('allmods', '', get_string('modulenameplural', $modname));
  75          }
  76  
  77          foreach ($modinfo->sections as $section=>$cmids) {
  78              $options["section/$section"] = "-- $sectiontitle $section --";
  79              foreach ($cmids as $cmid) {
  80                  $cm = $modinfo->cms[$cmid];
  81                  if (empty($modsused[$cm->modname]) or !$cm->uservisible) {
  82                      continue;
  83                  }
  84                  $options[$cm->id] = format_string($cm->name);
  85              }
  86          }
  87          $mform->addElement('select', 'modid', get_string('activities'), $options);
  88          $mform->setAdvanced('modid');
  89  
  90  
  91          if (has_capability('moodle/site:accessallgroups', $context)) {
  92              if ($groups = groups_get_all_groups($COURSE->id)) {
  93                  $options = array('0'=>get_string('allgroups'));
  94                  foreach($groups as $group) {
  95                      $options[$group->id] = format_string($group->name);
  96                  }
  97                  $mform->addElement('select', 'group', get_string('groups'), $options);
  98                  $mform->setAdvanced('group');
  99              }
 100          } else {
 101              $mform->addElement('hidden','group');
 102              $mform->setConstants(array('group'=>0));
 103          }
 104  
 105          $options = array('default'  => get_string('bycourseorder'),
 106                           'dateasc'  => get_string('datemostrecentlast'),
 107                           'datedesc' => get_string('datemostrecentfirst'));
 108          $mform->addElement('select', 'sortby', get_string('sortby'), $options);
 109          $mform->setAdvanced('sortby');
 110  
 111          $mform->addElement('date_time_selector', 'date', get_string('since'), array('optional'=>true));
 112  
 113          $mform->addElement('hidden','id');
 114          $mform->setType('courseid', PARAM_INT);
 115  
 116          $this->add_action_buttons(false, get_string('showrecent'));
 117      }
 118  }


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7