Пример #1
0
 /**
  * Query the reader. Store results in the object for use by build_table.
  *
  * @param int $pagesize size of page for paginated displayed table.
  * @param bool $useinitialsbar do you want to use the initials bar.
  */
 public function query_db($pagesize, $useinitialsbar = true)
 {
     $total = \tool_monitor\subscription_manager::count_user_subscriptions();
     $this->pagesize($pagesize, $total);
     $subs = \tool_monitor\subscription_manager::get_user_subscriptions($this->get_page_start(), $this->get_page_size());
     $this->rawdata = $subs;
     // Set initial bars.
     if ($useinitialsbar) {
         $this->initialbars($total > $pagesize);
     }
 }
Пример #2
0
} else {
    echo $OUTPUT->header();
}
$renderer = $PAGE->get_renderer('tool_monitor', 'managesubs');
// Render the course selector.
$totalrules = \tool_monitor\rule_manager::count_rules_by_courseid($courseid);
$rules = new \tool_monitor\output\managesubs\rules('toolmonitorrules', $indexurl, $courseid);
$usercourses = $rules->get_user_courses_select();
if (!empty($usercourses)) {
    echo $renderer->render($usercourses);
} else {
    // Nothing to show at all. Show a notification.
    echo $OUTPUT->notification(get_string('rulenopermission', 'tool_monitor'), 'notifyproblem');
}
// Render the current subscriptions list.
$totalsubs = \tool_monitor\subscription_manager::count_user_subscriptions();
if (!empty($totalsubs)) {
    // Show the subscriptions section only if there are subscriptions.
    $subs = new \tool_monitor\output\managesubs\subs('toolmonitorsubs', $indexurl, $courseid);
    echo $OUTPUT->heading(get_string('currentsubscriptions', 'tool_monitor'), 3);
    echo $renderer->render($subs);
}
// Render the potential rules list.
// Check the capability here before displaying any rules to subscribe to.
if (has_capability('tool/monitor:subscribe', $coursecontext)) {
    echo $OUTPUT->heading(get_string('rulescansubscribe', 'tool_monitor'), 3);
    echo $renderer->render($rules);
}
// Check if the user can manage the course rules we are viewing.
$canmanagerules = has_capability('tool/monitor:managerules', $coursecontext);
if (empty($totalrules)) {