function action_default() { global $CURMAN; $roleid = $this->optional_param('role', '', PARAM_INT); $context = $this->get_context(); if ($roleid) { if (!user_can_assign($context, $roleid)) { print_error('nopermissions', 'error'); } return parent::action_default(); } else { $decorators = array('name' => new role_name_decorator(clone $this)); $assignableroles = get_assignable_roles($context, 'name', ROLENAME_BOTH); $roles = array(); foreach ($assignableroles as $roleid => $rolename) { $rec = new stdClass(); $rec->id = $roleid; $rec->name = $rolename; $rec->description = format_string(get_field('role', 'description', 'id', $roleid)); $rec->count = count_role_users($roleid, $context); $roles[$roleid] = $rec; } $table = new nosort_table($roles, array('name' => get_string('name'), 'description' => get_string('description'), 'count' => get_string('users')), $this->get_moodle_url(), $decorators); $table->print_table(); } }