/**
  * Return array of rows where each row is an array of tab objects
  * taking into account permissions of current user
  */
 public function get_tabs()
 {
     $toprow = array();
     $context = $this->att->context;
     $capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances');
     if (has_any_capability($capabilities, $context)) {
         $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'attendance'));
     }
     if (has_capability('mod/attendance:manageattendances', $context)) {
         $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), get_string('add', 'attendance'));
     }
     if (has_capability('mod/attendance:viewreports', $context)) {
         $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'attendance'));
     }
     if (has_capability('mod/attendance:export', $context)) {
         $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'attendance'));
     }
     if (has_capability('mod/attendance:changepreferences', $context)) {
         $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'attendance'));
     }
     if (has_capability('mod/attendance:managetemporaryusers', $context)) {
         $toprow[] = new tabobject(self::TAB_TEMPORARYUSERS, $this->att->url_managetemp()->out(), get_string('tempusers', 'attendance'));
     }
     return array($toprow);
 }
示例#2
0
    /**
     * Return array of rows where each row is an array of tab objects
     * taking into account permissions of current user
     */
    public function get_tabs() {
        $toprow = array();
        if ($this->att->perm->can_manage() or
                $this->att->perm->can_take() or
                $this->att->perm->can_change()) {
            $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'local_attendance'));
        }

        if ($this->att->perm->can_manage()) {
            $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => local_att_sessions_page_params::ACTION_ADD)), get_string('add', 'local_attendance'));
        }

        if ($this->att->perm->can_view_reports()) {
            $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'local_attendance'));
        }

        if ($this->att->perm->can_export()) {
            $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'local_attendance'));
        }

        if ($this->att->perm->can_change_preferences()) {
            $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'local_attendance'));
        }

        return array($toprow);
    }
$pageparams->statusid = optional_param('statusid', null, PARAM_INT);
$pageparams->statusset = optional_param('statusset', 0, PARAM_INT);
// Set of statuses to view.
$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/attendance:changepreferences', $context);
// Make sure the statusset is valid.
$maxstatusset = attendance_get_max_statusset($att->id);
if ($pageparams->statusset > $maxstatusset + 1) {
    $pageparams->statusset = $maxstatusset + 1;
}
$att = new attendance($att, $cm, $course, $context, $pageparams);
$PAGE->set_url($att->url_preferences());
$PAGE->set_title($course->shortname . ": " . $att->name . ' - ' . get_string('settings', 'attendance'));
$PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance'));
$PAGE->navbar->add(get_string('settings', 'attendance'));
$errors = array();
// Check sesskey if we are performing an action.
if (!empty($att->pageparams->action)) {
    require_sesskey();
}
switch ($att->pageparams->action) {
    case att_preferences_page_params::ACTION_ADD:
        $newacronym = optional_param('newacronym', null, PARAM_TEXT);
        $newdescription = optional_param('newdescription', null, PARAM_TEXT);
        $newgrade = optional_param('newgrade', 0, PARAM_RAW);