Esempio n. 1
0
 /**
  * Generate content for select column.
  *
  * @param \tool_monitor\rule $rule rule object
  * @return string html used to display the select field.
  */
 public function col_select(\tool_monitor\rule $rule)
 {
     global $OUTPUT;
     $options = $rule->get_subscribe_options($this->courseid);
     $text = get_string('subscribeto', 'tool_monitor', $rule->get_name($this->context));
     if ($options instanceof \single_select) {
         $options->set_label($text, array('class' => 'accesshide'));
         return $OUTPUT->render($options);
     } else {
         if ($options instanceof \moodle_url) {
             // A \moodle_url to subscribe.
             $icon = $OUTPUT->pix_icon('t/add', $text);
             $link = new \action_link($options, $icon);
             return $OUTPUT->render($link);
         } else {
             return $options;
         }
     }
 }
Esempio n. 2
0
 /**
  * Generate content for manage column.
  *
  * @param \tool_monitor\rule $rule rule object
  *
  * @return string html used to display the manage column field.
  */
 public function col_manage(\tool_monitor\rule $rule)
 {
     global $OUTPUT, $CFG;
     $manage = '';
     // We don't need to check for capability at course level since, user is never shown this page,
     // if he doesn't have the capability.
     if ($this->hassystemcap || $rule->courseid != 0) {
         // There might be site rules which the user can not manage.
         $editurl = new \moodle_url($CFG->wwwroot . '/admin/tool/monitor/edit.php', array('ruleid' => $rule->id, 'courseid' => $rule->courseid, 'sesskey' => sesskey()));
         $copyurl = new \moodle_url($CFG->wwwroot . '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'copy', 'courseid' => $this->courseid, 'sesskey' => sesskey()));
         $deleteurl = new \moodle_url($CFG->wwwroot . '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'delete', 'courseid' => $rule->courseid, 'sesskey' => sesskey()));
         $icon = $OUTPUT->render(new \pix_icon('t/edit', get_string('editrule', 'tool_monitor')));
         $manage .= \html_writer::link($editurl, $icon, array('class' => 'action-icon'));
         $icon = $OUTPUT->render(new \pix_icon('t/copy', get_string('duplicaterule', 'tool_monitor')));
         $manage .= \html_writer::link($copyurl, $icon, array('class' => 'action-icon'));
         $a = $rule->get_name($this->context);
         $action = new \component_action('click', 'M.util.show_confirm_dialog', array('message' => get_string('ruleareyousure', 'tool_monitor', $a)));
         $icon = $OUTPUT->action_link($deleteurl, new \pix_icon('t/delete', get_string('deleterule', 'tool_monitor')), $action);
         $manage .= $icon;
     } else {
         $manage = get_string('nopermission', 'tool_monitor');
     }
     return $manage;
 }
Esempio n. 3
0
 /**
  * Generate content for filters column.
  *
  * @param \tool_monitor\rule $rule rule object
  * @return string html used to display the filters column field.
  */
 public function col_filters(\tool_monitor\rule $rule)
 {
     return $rule->get_filters_description();
 }
Esempio n. 4
0
 /**
  * Generate content for plugin column.
  *
  * @param \tool_monitor\rule $rule rule object
  *
  * @return string html used to display the column field.
  */
 public function col_select(\tool_monitor\rule $rule)
 {
     global $OUTPUT;
     $select = $rule->get_module_select($this->courseid);
     return is_object($select) ? $OUTPUT->render($select) : $select;
 }