switch ($action) { case 'add': print_heading_with_help(get_string('addrole', 'role'), 'roles'); break; case 'view': print_heading_with_help(get_string('viewrole', 'role'), 'roles'); break; case 'edit': print_heading_with_help(get_string('editrole', 'role'), 'roles'); break; } echo '<div class="selector">'; if ($action == 'view') { popup_form('manage.php?action=view&roleid=', $roleoptions, 'switchrole', $roleid, '', '', '', false, 'self', get_string('selectrole', 'role')); echo '<div class="buttons">'; $legacytype = get_legacy_type($roleid); $options = array(); $options['roleid'] = $roleid; $options['action'] = 'edit'; print_single_button('manage.php', $options, get_string('edit')); $options['action'] = 'reset'; if (empty($legacytype)) { print_single_button('manage.php', $options, get_string('resetrolenolegacy', 'role')); } else { print_single_button('manage.php', $options, get_string('resetrole', 'role')); } $options['action'] = 'duplicate'; print_single_button('manage.php', $options, get_string('duplicaterole', 'role')); print_single_button('manage.php', null, get_string('listallroles', 'role')); echo '</div>'; }
protected function load_current_permissions() { global $DB; if ($this->roleid) { if (!($this->role = $DB->get_record('role', array('id' => $this->roleid)))) { throw new moodle_exception('invalidroleid'); } $this->role->legacytype = get_legacy_type($this->roleid); $contextlevels = get_role_contextlevels($this->roleid); // Put the contextlevels in the array keys, as well as the values. if (!empty($contextlevels)) { $this->contextlevels = array_combine($contextlevels, $contextlevels); } else { $this->contextlevels = array(); } } else { $this->role = new stdClass(); $this->role->name = ''; $this->role->shortname = ''; $this->role->description = ''; $this->role->legacytype = ''; $this->contextlevels = array(); } parent::load_current_permissions(); }