Beispiel #1
0
 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');
         }
         $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->archetype = '';
         $this->contextlevels = array();
     }
     parent::load_current_permissions();
 }
Beispiel #2
0
 protected function load_current_permissions()
 {
     if ($this->roleid) {
         if (!($this->role = get_record('role', 'id', $this->roleid))) {
             print_error('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();
 }