public function execute()
{
global $CFG, $DB;
require_once $CFG->libdir . '/accesslib.php';
//some variables you may want to use
//$this->cwd - the directory where moosh command was executed
//$this->mooshDir - moosh installation directory
//$this->expandedOptions - commandline provided options, merged with defaults
//$this->topDir - top Moodle directory
//$this->arguments[0] - first argument passed
//$this->pluginInfo - array with information about the current plugin (based on cwd), keys:'type','name','dir'
$options = $this->expandedOptions;
$contextid = $this->arguments[0];
//$contextpath = $this->arguments[0];
// Get all contexts under given one
$context = \context::instance_by_id($contextid, MUST_EXIST);
var_dump($context);
echo $context->get_context_name();
return;
$sql = "SELECT * FROM {context} WHERE path LIKE '{$contextpath}/%'";
$contexts = $DB->get_records_sql($sql);
foreach ($contexts as $context) {
/** @var \context $context */
echo $this->context_info($context->id) . "\n";
// What is in mdl_role_capabilities for this context
$capabilities = $DB->get_records('role_capabilities', array('contextid' => $context->id));
foreach ($capabilities as $cap) {
echo $cap->roleid . ' ' . $cap->capability . ' ' . $cap->permission . " | ";
}
echo "\n";
}
}