. /** * Library code used by the roles administration interfaces. * * @package core_role * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/user/selector/lib.php'); /** * Base class to avoid duplicating code. */ abstract class core_role_assign_user_selector_base extends user_selector_base { protected $roleid; protected $context; /** * @param string $name control name * @param array $options should have two elements with keys groupid and courseid. */ public function __construct($name, $options) { global $CFG; if (isset($options['context'])) { $this->context = $options['context']; } else { $this->context = context::instance_by_id($options['contextid']); } $options['accesscontext'] = $this->context; parent::__construct($name, $options); $this->roleid = $options['roleid']; require_once($CFG->dirroot . '/group/lib.php'); } protected function get_options() { global $CFG; $options = parent::get_options(); $options['file'] = $CFG->admin . '/roles/lib.php'; $options['roleid'] = $this->roleid; $options['contextid'] = $this->context->id; return $options; } }