本文整理汇总了PHP中has_any_capability函数的典型用法代码示例。如果您正苦于以下问题:PHP has_any_capability函数的具体用法?PHP has_any_capability怎么用?PHP has_any_capability使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_any_capability函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_area_backup_course
/**
* Gets a stored file for the backup course filearea directory.
*
* @param int $itemid item ID
* @param string $filepath file path
* @param string $filename file name
* @return file_info|null file_info instance or null if not found or access not allowed
*/
protected function get_area_backup_course($itemid, $filepath, $filename)
{
global $CFG;
if (!isloggedin()) {
return null;
}
if (!has_any_capability(array('moodle/backup:backupcourse', 'moodle/restore:restorecourse'), $this->context)) {
return null;
}
if (is_null($itemid)) {
return $this;
}
$fs = get_file_storage();
$filepath = is_null($filepath) ? '/' : $filepath;
$filename = is_null($filename) ? '.' : $filename;
if (!($storedfile = $fs->get_file($this->context->id, 'backup', 'course', 0, $filepath, $filename))) {
if ($filepath === '/' && $filename === '.') {
$storedfile = new virtual_root_file($this->context->id, 'backup', 'course', 0);
} else {
// Not found.
return null;
}
}
$downloadable = has_capability('moodle/backup:downloadfile', $this->context);
$uploadable = has_capability('moodle/restore:uploadfile', $this->context);
$urlbase = $CFG->wwwroot . '/pluginfile.php';
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('coursebackup', 'repository'), false, $downloadable, $uploadable, false);
}
示例2: get_tabs
/**
* Return array of rows where each row is an array of tab objects
* taking into account permissions of current user
*/
public function get_tabs()
{
$toprow = array();
$context = $this->att->context;
$capabilities = array('mod/attendance:manageattendances', 'mod/attendance:takeattendances', 'mod/attendance:changeattendances');
if (has_any_capability($capabilities, $context)) {
$toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'attendance'));
}
if (has_capability('mod/attendance:manageattendances', $context)) {
$toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), get_string('add', 'attendance'));
}
if (has_capability('mod/attendance:viewreports', $context)) {
$toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'attendance'));
}
if (has_capability('mod/attendance:export', $context)) {
$toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'attendance'));
}
if (has_capability('mod/attendance:changepreferences', $context)) {
$toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'attendance'));
}
if (has_capability('mod/attendance:managetemporaryusers', $context)) {
$toprow[] = new tabobject(self::TAB_TEMPORARYUSERS, $this->att->url_managetemp()->out(), get_string('tempusers', 'attendance'));
}
return array($toprow);
}
示例3: specific_definition
protected function specific_definition($mform)
{
global $CFG, $DB, $USER;
// Fields for editing block contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$mform->addElement('text', 'config_title', get_string('uploadlabel'));
$mform->setType('config_title', PARAM_NOTAGS);
$mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_plus'), array('size' => 5));
$mform->setType('config_shownumentries', PARAM_INTEGER);
$mform->addRule('config_shownumentries', null, 'numeric', null, 'client');
if (!empty($CFG->block_rss_plus_num_entries)) {
$mform->setDefault('config_shownumentries', $CFG->block_rss_plus_num_entries);
} else {
$mform->setDefault('config_shownumentries', 5);
}
$rssfeeds = $DB->get_records_sql_menu('
SELECT id,
CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END
FROM {block_rss_plus}
WHERE userid = ? OR shared = 1
ORDER BY CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END ', array($DB->sql_empty(), $USER->id, $DB->sql_empty()));
if ($rssfeeds) {
$select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_plus'), $rssfeeds);
$select->setMultiple(true);
} else {
$mform->addElement('static', 'config_rssid', get_string('choosefeedlabel', 'block_rss_plus'), get_string('nofeeds', 'block_rss_plus'));
}
if (has_any_capability(array('block/rss_plus:manageanyfeeds', 'block/rss_plus:manageownfeeds'), $this->block->context)) {
$mform->addElement('static', 'nofeedmessage', '', '<div class="rssaddfeedlink"><a class="rssaddfeedlink" href="' . $CFG->wwwroot . '/blocks/rss_plus/managefeeds.php?courseid=' . $this->page->course->id . '">' . get_string('feedsaddedit', 'block_rss_plus') . '</a></div>');
}
}
示例4: export_for_template
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
global $CFG, $DB, $PAGE;
$context = context_course::instance($this->courseid);
$data = new stdClass();
$data->userid = $this->userid;
$data->competencyid = $this->competencyid;
$data->courseid = $this->courseid;
$data->baseurl = $this->baseurl;
$data->groupselector = '';
if (has_any_capability(array('moodle/competency:usercompetencyview', 'moodle/competency:coursecompetencymanage'), $context)) {
$course = $DB->get_record('course', array('id' => $this->courseid));
$currentgroup = groups_get_course_group($course, true);
if ($currentgroup !== false) {
$select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup);
$data->groupselector = $select;
}
// Fetch showactive.
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
$users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.*', null, 0, 0, $showonlyactiveenrol);
$data->users = array();
foreach ($users as $user) {
$exporter = new user_summary_exporter($user);
$user = $exporter->export($output);
if ($user->id == $this->userid) {
$user->selected = true;
}
$data->users[] = $user;
}
$data->hasusers = true;
} else {
$data->users = array();
$data->hasusers = false;
}
$coursecompetencies = \core_competency\api::list_course_competencies($this->courseid);
$data->competencies = array();
$contextcache = array();
foreach ($coursecompetencies as $coursecompetency) {
$frameworkid = $coursecompetency['competency']->get_competencyframeworkid();
if (!isset($contextcache[$frameworkid])) {
$contextcache[$frameworkid] = $coursecompetency['competency']->get_context();
}
$context = $contextcache[$frameworkid];
$coursecompetencycontext = $context;
$exporter = new competency_exporter($coursecompetency['competency'], array('context' => $coursecompetencycontext));
$competency = $exporter->export($output);
if ($competency->id == $this->competencyid) {
$competency->selected = true;
}
$data->competencies[] = $competency;
}
$data->hascompetencies = count($data->competencies);
return $data;
}
示例5: resolve_dependencies
public function resolve_dependencies()
{
parent::resolve_dependencies();
if (!$this->usercanseegrades) {
$this->slotmarks = false;
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$this->checkboxcolumn = has_any_capability(array('mod/quiz:regrade', 'mod/quiz:deleteattempts'), context_module::instance($this->cm->id)) && $this->attempts != quiz_attempts_report::ENROLLED_WITHOUT;
}
示例6: require_any_capability
/**
* Dictates that a user must have one of the given capabilities to view the current page
* @param array $capabilities An array of capability names.
* @param object $context The context to check the capability in.
* @param integer $userid A user id. By default (null) checks the permissions of the current user.
* @param bool $doanything If false, ignore effect of admin role assignment
* @param string $errorstring The error string to to user. Defaults to 'nopermissions'.
* @param string $stringfile The language file to load the error string from. Defaults to 'error'.
* @return void Terminates with an error if the user does not have the given capability.
* @version 2011080401
* @since 2011080401
*/
public static function require_any_capability($capabilities, $context, $userid = null, $doanything = true, $errormessage = 'nopermissions', $stringfile = '')
{
if (!is_array($capabilities)) {
$capabilities = array($capabilities);
}
if (!has_any_capability($capabilities, $context, $userid, $doanything)) {
throw new required_capability_exception($context, $capabilities[0], $errormessage, $stringfile);
}
// Just use the top one
}
示例7: get_content
function get_content()
{
global $USER, $CFG, $SESSION;
$cal_m = optional_param('cal_m', 0, PARAM_INT);
$cal_y = optional_param('cal_y', 0, PARAM_INT);
require_once $CFG->dirroot . '/calendar/lib.php';
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$filtercourse = array();
if (empty($this->instance)) {
// Overrides: use no course at all
$courseshown = false;
$this->content->footer = '';
} else {
$courseshown = $this->page->course->id;
$this->content->footer = '<div class="gotocal"><a href="' . $CFG->wwwroot . '/calendar/view.php?view=upcoming&course=' . $courseshown . '">' . get_string('gotocalendar', 'calendar') . '</a>...</div>';
$context = context_course::instance($courseshown);
if (has_any_capability(array('moodle/calendar:manageentries', 'moodle/calendar:manageownentries'), $context)) {
$this->content->footer .= '<div class="newevent"><a href="' . $CFG->wwwroot . '/calendar/event.php?action=new&course=' . $courseshown . '">' . get_string('newevent', 'calendar') . '</a>...</div>';
}
if ($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = calendar_get_default_courses();
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => $this->page->course);
}
}
list($courses, $group, $user) = calendar_set_filters($filtercourse);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
$defaultlookahead = intval($CFG->calendar_lookahead);
}
$lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
$defaultmaxevents = intval($CFG->calendar_maxevents);
}
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents);
if (!empty($this->instance)) {
$this->content->text = calendar_get_block_upcoming($events, 'view.php?view=day&course=' . $courseshown . '&');
}
if (empty($this->content->text)) {
$this->content->text = '<div class="post">' . get_string('noupcomingevents', 'calendar') . '</div>';
}
return $this->content;
}
示例8: __construct
/**
* @throws coding_exception
*/
public function __construct()
{
global $PAGE, $COURSE;
// Page path blacklist for admin menu.
$adminblockblacklist = ['/user/profile.php'];
if (in_array(local::current_url_path(), $adminblockblacklist)) {
return;
}
// Admin users always see the admin menu with the exception of blacklisted pages.
// The admin menu shows up for other users if they are a teacher in the current course.
if (!is_siteadmin()) {
// We don't want students to see the admin menu ever.
// Editing teachers are identified as people who can manage activities and non editing teachers as those who
// can view the gradebook. As editing teachers are almost certain to also be able to view the gradebook, the
// grader:view capability is checked first.
$caps = ['gradereport/grader:view', 'moodle/course:manageactivities'];
$canmanageacts = has_any_capability($caps, $PAGE->context);
$isstudent = !$canmanageacts && !is_role_switched($COURSE->id);
if ($isstudent) {
return;
}
}
if (!$PAGE->blocks->is_block_present('settings')) {
// Throw error if on front page or course page.
// (There are pages that don't have a settings block so we shouldn't throw an error on those pages).
if (strpos($PAGE->pagetype, 'course-view') === 0 || $PAGE->pagetype === 'site-index') {
debugging('Settings block was not found on this page', DEBUG_DEVELOPER);
}
return;
}
// Core Moodle API appears to be missing a 'get block by name' function.
// Cycle through all regions and block instances until we find settings.
foreach ($PAGE->blocks->get_regions() as $region) {
foreach ($PAGE->blocks->get_blocks_for_region($region) as $block) {
if (isset($block->instance) && $block->instance->blockname == 'settings') {
$this->instanceid = $block->instance->id;
break 2;
}
}
}
if (!has_capability('moodle/block:view', \context_block::instance($this->instanceid))) {
return;
}
$this->output = true;
}
示例9: tool_lp_extend_navigation_course
/**
* This function extends the course navigation
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $course The course to object for the tool
* @param context $coursecontext The context of the course
*/
function tool_lp_extend_navigation_course($navigation, $course, $coursecontext)
{
if (!get_config('core_competency', 'enabled')) {
return;
}
// Check access to the course and competencies page.
$capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage');
$context = context_course::instance($course->id);
if (!has_any_capability($capabilities, $context) || !can_access_course($course)) {
return;
}
// Just a link to course competency.
$title = get_string('competencies', 'core_competency');
$path = new moodle_url("/admin/tool/lp/coursecompetencies.php", array('courseid' => $course->id));
$settingsnode = navigation_node::create($title, $path, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/competencies', ''));
if (isset($settingsnode)) {
$navigation->add_node($settingsnode);
}
}
示例10: specific_definition
protected function specific_definition($mform)
{
global $CFG, $DB, $USER;
// Fields for editing block contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$mform->addElement('selectyesno', 'config_display_description', get_string('displaydescriptionlabel', 'block_rss_client'));
$mform->setDefault('config_display_description', 0);
$mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_client'), array('size' => 5));
$mform->setType('config_shownumentries', PARAM_INT);
$mform->addRule('config_shownumentries', null, 'numeric', null, 'client');
if (!empty($CFG->block_rss_client_num_entries)) {
$mform->setDefault('config_shownumentries', $CFG->block_rss_client_num_entries);
} else {
$mform->setDefault('config_shownumentries', 5);
}
$insql = '';
$params = array('userid' => $USER->id);
$rssconfig = unserialize(base64_decode($this->block->instance->configdata));
if ($rssconfig && !empty($rssconfig->rssid)) {
list($insql, $inparams) = $DB->get_in_or_equal($rssconfig->rssid, SQL_PARAMS_NAMED);
$insql = "OR id {$insql} ";
$params += $inparams;
}
$titlesql = "CASE WHEN preferredtitle = '' THEN {$DB->sql_compare_text('title', 64)} ELSE preferredtitle END";
$rssfeeds = $DB->get_records_sql_menu("\n SELECT id, {$titlesql}\n FROM {block_rss_client}\n WHERE userid = :userid OR shared = 1 {$insql}\n ORDER BY {$titlesql}", $params);
if ($rssfeeds) {
$select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
$select->setMultiple(true);
} else {
$mform->addElement('static', 'config_rssid_no_feeds', get_string('choosefeedlabel', 'block_rss_client'), get_string('nofeeds', 'block_rss_client'));
}
if (has_any_capability(array('block/rss_client:manageanyfeeds', 'block/rss_client:manageownfeeds'), $this->block->context)) {
$mform->addElement('static', 'nofeedmessage', '', '<a href="' . $CFG->wwwroot . '/blocks/rss_client/managefeeds.php?courseid=' . $this->page->course->id . '">' . get_string('feedsaddedit', 'block_rss_client') . '</a>');
}
$mform->addElement('text', 'config_title', get_string('uploadlabel'));
$mform->setType('config_title', PARAM_NOTAGS);
$mform->addElement('selectyesno', 'config_block_rss_client_show_channel_link', get_string('clientshowchannellinklabel', 'block_rss_client'));
$mform->setDefault('config_block_rss_client_show_channel_link', 0);
$mform->addElement('selectyesno', 'config_block_rss_client_show_channel_image', get_string('clientshowimagelabel', 'block_rss_client'));
$mform->setDefault('config_block_rss_client_show_channel_image', 0);
}
示例11: specific_definition
protected function specific_definition($mform)
{
global $CFG, $DB, $USER;
// Fields for editing block contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$mform->addElement('selectyesno', 'config_display_description', get_string('displaydescriptionlabel', 'block_rss_client'));
$mform->setDefault('config_display_description', 0);
$mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_client'), array('size' => 5));
$mform->setType('config_shownumentries', PARAM_INTEGER);
$mform->addRule('config_shownumentries', null, 'numeric', null, 'client');
if (!empty($CFG->block_rss_client_num_entries)) {
$mform->setDefault('config_shownumentries', $CFG->block_rss_client_num_entries);
} else {
$mform->setDefault('config_shownumentries', 5);
}
$rssfeeds = $DB->get_records_sql_menu('
SELECT id, CASE WHEN preferredtitle = ? THEN title ELSE preferredtitle END AS acutaltitle
FROM {block_rss_client}
WHERE userid = ? OR shared = 1
ORDER BY acutaltitle', array($DB->sql_empty(), $USER->id));
if ($rssfeeds) {
$select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
$select->setMultiple(true);
} else {
$mform->addElement('static', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), get_string('nofeeds', 'block_rss_client'));
}
if (has_any_capability(array('block/rss_client:manageanyfeeds', 'block/rss_client:manageownfeeds'), $this->block->context)) {
$mform->addElement('static', 'nofeedmessage', '', '<a href="' . $CFG->wwwroot . '/blocks/rss_client/managefeeds.php?courseid=' . $this->page->course->id . '">' . get_string('feedsaddedit', 'block_rss_client') . '</a>');
}
$mform->addElement('text', 'config_title', get_string('uploadlabel'));
$mform->setType('config_title', PARAM_NOTAGS);
$mform->addElement('selectyesno', 'config_block_rss_client_show_channel_link', get_string('clientshowchannellinklabel', 'block_rss_client'));
$mform->setDefault('config_block_rss_client_show_channel_link', 0);
$mform->addElement('selectyesno', 'config_block_rss_client_show_channel_image', get_string('clientshowimagelabel', 'block_rss_client'));
$mform->setDefault('config_block_rss_client_show_channel_image', 0);
}
示例12: course_get_cm_edit_actions_reduced
/**
* Returns the list of all editing actions that current user can perform on the module
*
* @param cm_info $mod The module to produce editing buttons for
* @param int $indent The current indenting (default -1 means no move left-right actions)
* @param int $sr The section to link back to (used for creating the links)
* @return array array of action_link or pix_icon objects
*/
function course_get_cm_edit_actions_reduced(cm_info $mod, $indent = -1, $sr = null)
{
global $COURSE, $SITE;
static $str;
$coursecontext = context_course::instance($mod->course);
$modcontext = context_module::instance($mod->id);
$editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
$dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
//No permission to edit anything.
if (!has_any_capability($editcaps, $modcontext) and !has_all_capabilities($dupecaps, $coursecontext)) {
return array();
}
$hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
if (!isset($str)) {
$str = get_strings(array('delete', 'move', 'moveright', 'moveleft', 'editsettings', 'duplicate', 'hide', 'show'), 'moodle');
$str->assign = get_string('assignroles', 'role');
$str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
$str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
$str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
}
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
if ($sr !== null) {
$baseurl->param('sr', $sr);
}
$actions = array();
// Duplicate (require both target import caps to be able to duplicate and backup2 support, see modduplicate.php)
// Note that restoring on front page is never allowed.
if ($mod->course != SITEID && has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
$actions['duplicate'] = new action_menu_link_secondary(new moodle_url($baseurl, array('duplicate' => $mod->id)), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->duplicate, array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sr' => $sr));
}
// Delete.
if ($hasmanageactivities) {
$actions['delete'] = new action_menu_link_secondary(new moodle_url($baseurl, array('delete' => $mod->id)), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->delete, array('class' => 'editing_delete', 'data-action' => 'delete'));
}
return $actions;
}
示例13: can_request_review_user
/**
* Can the current user send a user's competency for review?
*
* Note that the status 'review' is not meant to be used for student to self-assess
* themselves, then to ask the teacher to review their assessment. It is more intended
* for a student to provide evidence of prior learning and request their review.
*
* @param int $userid The user ID the competency belongs to.
* @return bool
*/
public static function can_request_review_user($userid)
{
global $USER;
$capabilities = array('moodle/competency:usercompetencyrequestreview');
if ($USER->id == $userid) {
$capabilities[] = 'moodle/competency:usercompetencyrequestreviewown';
}
if (has_any_capability($capabilities, context_user::instance($userid))) {
return true;
}
return false;
}
示例14: load_category_settings
/**
* Loads category specific settings in the navigation
*
* @return navigation_node
*/
protected function load_category_settings()
{
global $CFG;
// We can land here while being in the context of a block, in which case we
// should get the parent context which should be the category one. See self::initialise().
if ($this->context->contextlevel == CONTEXT_BLOCK) {
$catcontext = $this->context->get_parent_context();
} else {
$catcontext = $this->context;
}
// Let's make sure that we always have the right context when getting here.
if ($catcontext->contextlevel != CONTEXT_COURSECAT) {
throw new coding_exception('Unexpected context while loading category settings.');
}
$categorynode = $this->add($catcontext->get_context_name(), null, null, null, 'categorysettings');
$categorynode->nodetype = navigation_node::NODETYPE_BRANCH;
$categorynode->force_open();
if (can_edit_in_category($catcontext->instanceid)) {
$url = new moodle_url('/course/management.php', array('categoryid' => $catcontext->instanceid));
$editstring = get_string('managecategorythis');
$categorynode->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
}
if (has_capability('moodle/category:manage', $catcontext)) {
$editurl = new moodle_url('/course/editcategory.php', array('id' => $catcontext->instanceid));
$categorynode->add(get_string('editcategorythis'), $editurl, self::TYPE_SETTING, null, 'edit', new pix_icon('i/edit', ''));
$addsubcaturl = new moodle_url('/course/editcategory.php', array('parent' => $catcontext->instanceid));
$categorynode->add(get_string('addsubcategory'), $addsubcaturl, self::TYPE_SETTING, null, 'addsubcat', new pix_icon('i/withsubcat', ''));
}
// Assign local roles
$assignableroles = get_assignable_roles($catcontext);
if (!empty($assignableroles)) {
$assignurl = new moodle_url('/' . $CFG->admin . '/roles/assign.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING, null, 'roles', new pix_icon('i/assignroles', ''));
}
// Override roles
if (has_capability('moodle/role:review', $catcontext) or count(get_overridable_roles($catcontext)) > 0) {
$url = new moodle_url('/' . $CFG->admin . '/roles/permissions.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING, null, 'permissions', new pix_icon('i/permissions', ''));
}
// Check role permissions
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:assign'), $catcontext)) {
$url = new moodle_url('/' . $CFG->admin . '/roles/check.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
}
// Cohorts
if (has_any_capability(array('moodle/cohort:view', 'moodle/cohort:manage'), $catcontext)) {
$categorynode->add(get_string('cohorts', 'cohort'), new moodle_url('/cohort/index.php', array('contextid' => $catcontext->id)), self::TYPE_SETTING, null, 'cohort', new pix_icon('i/cohort', ''));
}
// Manage filters
if (has_capability('moodle/filter:manage', $catcontext) && count(filter_get_available_in_context($catcontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, 'filters', new pix_icon('i/filter', ''));
}
// Restore.
if (has_capability('moodle/restore:restorecourse', $catcontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('restorecourse', 'admin'), $url, self::TYPE_SETTING, null, 'restorecourse', new pix_icon('i/restore', ''));
}
// Let plugins hook into category settings navigation.
$pluginsfunction = get_plugins_with_function('extend_navigation_category_settings', 'lib.php');
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($categorynode, $catcontext);
}
}
return $categorynode;
}
示例15: get_marking_workflow_states_for_current_user
/**
* Get the list of marking_workflow states the current user has permission to transition a grade to.
*
* @return array of state => description
*/
public function get_marking_workflow_states_for_current_user()
{
if (!empty($this->markingworkflowstates)) {
return $this->markingworkflowstates;
}
$states = array();
if (has_capability('mod/assign:grade', $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INMARKING] = get_string('markingworkflowstateinmarking', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW] = get_string('markingworkflowstatereadyforreview', 'assign');
}
if (has_any_capability(array('mod/assign:reviewgrades', 'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW] = get_string('markingworkflowstateinreview', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE] = get_string('markingworkflowstatereadyforrelease', 'assign');
}
if (has_any_capability(array('mod/assign:releasegrades', 'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_RELEASED] = get_string('markingworkflowstatereleased', 'assign');
}
$this->markingworkflowstates = $states;
return $this->markingworkflowstates;
}