本文整理汇总了PHP中filter_get_available_in_context函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_get_available_in_context函数的具体用法?PHP filter_get_available_in_context怎么用?PHP filter_get_available_in_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_get_available_in_context函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: load_front_page_settings
/**
* This function loads all of the front page settings into the settings navigation.
* This function is called when the user is on the front page, or $COURSE==$SITE
* @param bool $forceopen (optional)
* @return navigation_node
*/
protected function load_front_page_settings($forceopen = false)
{
global $SITE, $CFG;
$course = clone $SITE;
$coursecontext = context_course::instance($course->id);
// Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$frontpage->force_open();
}
$frontpage->id = 'frontpagesettings';
if ($this->page->user_allowed_editing()) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');
} else {
$url->param('edit', 'on');
$editstring = get_string('turneditingon');
}
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
}
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the course settings link
$url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
}
// add enrol nodes
enrol_add_course_navigation($frontpage, $course);
// Manage filters
if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
}
// View course reports.
if (has_capability('moodle/site:viewreports', $coursecontext)) {
// Basic capability for listing of reports.
$frontpagenav = $frontpage->add(get_string('reports'), null, self::TYPE_CONTAINER, null, 'frontpagereports', new pix_icon('i/stats', ''));
$coursereports = core_component::get_plugin_list('coursereport');
foreach ($coursereports as $report => $dir) {
$libfile = $CFG->dirroot . '/course/report/' . $report . '/lib.php';
if (file_exists($libfile)) {
require_once $libfile;
$reportfunction = $report . '_report_extend_navigation';
if (function_exists($report . '_report_extend_navigation')) {
$reportfunction($frontpagenav, $course, $coursecontext);
}
}
}
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
foreach ($reports as $reportfunction) {
$reportfunction($frontpagenav, $course, $coursecontext);
}
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
}
// Questions
require_once $CFG->libdir . '/questionlib.php';
question_extend_settings_navigation($frontpage, $coursecontext)->trim_if_empty();
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
//hiden in new installs
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/folder', ''));
}
// Let plugins hook into frontpage navigation.
$pluginsfunction = get_plugins_with_function('extend_navigation_frontpage', 'lib.php');
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($frontpage, $course, $coursecontext);
}
}
return $frontpage;
}
开发者ID:evltuma,项目名称:moodle,代码行数:89,代码来源:navigationlib.php
示例2: load_front_page_settings
/**
* This function loads all of the front page settings into the settings navigation.
* This function is called when the user is on the front page, or $COURSE==$SITE
* @param bool $forceopen (optional)
* @return navigation_node
*/
protected function load_front_page_settings($forceopen = false)
{
global $SITE, $CFG;
$course = clone $SITE;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$frontpage->force_open();
}
$frontpage->id = 'frontpagesettings';
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');
} else {
$url->param('edit', 'on');
$editstring = get_string('turneditingon');
}
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
// Add the course settings link
$url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
}
// add enrol nodes
enrol_add_course_navigation($frontpage, $course);
// Manage filters
if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
}
// Questions
require_once $CFG->libdir . '/questionlib.php';
question_extend_settings_navigation($frontpage, $coursecontext)->trim_if_empty();
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
//hiden in new installs
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id, 'itemid' => 0, 'component' => 'course', 'filearea' => 'legacy'));
$frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/files', ''));
}
return $frontpage;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:60,代码来源:navigationlib.php
示例3: require_login
} else {
if ($context->contextlevel == CONTEXT_MODULE) {
// Must be module context.
$heading = $PAGE->activityrecord->name;
} else {
$heading = '';
}
}
}
/// Check login and permissions.
require_login($course, false, $cm);
require_capability('moodle/filter:manage', $context);
$PAGE->set_context($context);
$PAGE->set_heading($heading);
/// Get the list of available filters.
$availablefilters = filter_get_available_in_context($context);
if (!$isfrontpage && empty($availablefilters)) {
print_error('nofiltersenabled', 'error');
}
// If we are handling local settings for a particular filter, start processing.
if ($forfilter) {
if (!filter_has_local_settings($forfilter)) {
print_error('filterdoesnothavelocalconfig', 'error', $forfilter);
}
require_once $CFG->dirroot . '/filter/local_settings_form.php';
require_once $CFG->dirroot . '/' . $forfilter . '/filterlocalsettings.php';
$formname = basename($forfilter) . '_filter_local_settings_form';
$settingsform = new $formname($CFG->wwwroot . '/filter/manage.php', $forfilter, $context);
if ($settingsform->is_cancelled()) {
redirect($baseurl);
} else {
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:manage.php
示例4: can_review_filters
/**
* Returns true if the current user can review filter settings for this category.
* @return bool
*/
public function can_review_filters()
{
return has_capability('moodle/filter:manage', $this->get_context()) && count(filter_get_available_in_context($this->get_context())) > 0;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:8,代码来源:coursecatlib.php
示例5: course_get_user_administration_options
/**
* Return an object with the list of administration options in a course that are available or not for the current user.
* This function also handles the frontpage settings.
*
* @param stdClass $course course object (for frontpage it should be a clone of $SITE)
* @param stdClass $context context object (course context)
* @return stdClass the administration options in a course and their availability status
* @since Moodle 3.2
*/
function course_get_user_administration_options($course, $context)
{
global $CFG;
$isfrontpage = $course->id == SITEID;
$options = new stdClass();
$options->update = has_capability('moodle/course:update', $context);
$options->filters = has_capability('moodle/filter:manage', $context) && count(filter_get_available_in_context($context)) > 0;
$options->reports = has_capability('moodle/site:viewreports', $context);
$options->backup = has_capability('moodle/backup:backupcourse', $context);
$options->restore = has_capability('moodle/restore:restorecourse', $context);
$options->files = $course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $context);
if (!$isfrontpage) {
$options->tags = has_capability('moodle/course:tag', $context);
$options->gradebook = has_capability('moodle/grade:manage', $context);
$options->outcomes = !empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $context);
$options->badges = !empty($CFG->enablebadges);
$options->import = has_capability('moodle/restore:restoretargetimport', $context);
$options->publish = has_capability('moodle/course:publish', $context);
$options->reset = has_capability('moodle/course:reset', $context);
$options->roles = has_capability('moodle/role:switchroles', $context);
// Add view grade report is permitted.
$grades = false;
if (has_capability('moodle/grade:viewall', $context)) {
$grades = true;
} else {
if (!empty($course->showgrades)) {
$reports = core_component::get_plugin_list('gradereport');
if (is_array($reports) && count($reports) > 0) {
// Get all installed reports.
arsort($reports);
// User is last, we want to test it first.
foreach ($reports as $plugin => $plugindir) {
if (has_capability('gradereport/' . $plugin . ':view', $context)) {
// Stop when the first visible plugin is found.
$grades = true;
break;
}
}
}
}
}
$options->grades = $grades;
} else {
// Set default options to false.
$listofoptions = array('tags', 'gradebook', 'outcomes', 'badges', 'import', 'publish', 'reset', 'roles', 'grades');
foreach ($listofoptions as $option) {
$options->{$option} = false;
}
}
return $options;
}
开发者ID:janeklb,项目名称:moodle,代码行数:60,代码来源:lib.php
示例6: test_available_in_context_exception_with_syscontext
public function test_available_in_context_exception_with_syscontext()
{
// Set expectation.
$this->expectException();
// Exercise SUT.
filter_get_available_in_context($this->syscontext);
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:7,代码来源:testfilterconfig.php
示例7: 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;
}
开发者ID:janeklb,项目名称:moodle,代码行数:72,代码来源:navigationlib.php
示例8: test_available_in_context_exception_with_syscontext
/**
* @expectedException coding_exception
*/
public function test_available_in_context_exception_with_syscontext()
{
$this->setup_available_in_context_tests();
// Exercise SUT.
filter_get_available_in_context($this->syscontext);
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:9,代码来源:filterlib_test.php
示例9: test_available_in_context_exception_with_syscontext
/**
* @expectedException coding_exception
* @return void
*/
public function test_available_in_context_exception_with_syscontext() {
// Exercise SUT.
filter_get_available_in_context(self::$syscontext);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:8,代码来源:filter_test.php
示例10: course_get_user_administration_options
/**
* Return an object with the list of administration options in a course that are available or not for the current user.
* This function also handles the frontpage settings.
*
* @param stdClass $course course object (for frontpage it should be a clone of $SITE)
* @param stdClass $context context object (course context)
* @return stdClass the administration options in a course and their availability status
* @since Moodle 3.2
*/
function course_get_user_administration_options($course, $context)
{
global $CFG;
$isfrontpage = $course->id == SITEID;
$options = new stdClass();
$options->update = has_capability('moodle/course:update', $context);
$options->filters = has_capability('moodle/filter:manage', $context) && count(filter_get_available_in_context($context)) > 0;
$options->reports = has_capability('moodle/site:viewreports', $context);
$options->backup = has_capability('moodle/backup:backupcourse', $context);
$options->restore = has_capability('moodle/restore:restorecourse', $context);
$options->files = $course->legacyfiles == 2 && has_capability('moodle/course:managefiles', $context);
if (!$isfrontpage) {
$options->tags = has_capability('moodle/course:tag', $context);
$options->gradebook = has_capability('moodle/grade:manage', $context);
$options->outcomes = !empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $context);
$options->badges = !empty($CFG->enablebadges);
$options->import = has_capability('moodle/restore:restoretargetimport', $context);
$options->publish = has_capability('moodle/course:publish', $context);
$options->reset = has_capability('moodle/course:reset', $context);
$options->roles = has_capability('moodle/role:switchroles', $context);
} else {
// Set default options to false.
$listofoptions = array('tags', 'gradebook', 'outcomes', 'badges', 'import', 'publish', 'reset', 'roles', 'grades');
foreach ($listofoptions as $option) {
$options->{$option} = false;
}
}
return $options;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:38,代码来源:lib.php
示例11: taskchain_navigation_accesscontrol_form
//.........这里部分代码省略.........
continue;
}
$conditionfield[] = (object) array('type' => 'profile', 'sf' => $name, 'op' => empty($conditionfieldoperator[$i]) ? '' : $conditionfieldoperator[$i], 'v' => empty($conditionfieldvalue[$i]) ? '' : $conditionfieldvalue[$i]);
}
$conditiongroup = array();
foreach ($conditiongroupid as $i => $id) {
if ($id == 0) {
continue;
}
$conditiongroup[] = (object) array('type' => 'group', 'id' => $id);
}
$conditiongrouping = array();
foreach ($conditiongroupingid as $i => $id) {
if ($id == 0) {
continue;
}
$conditiongrouping[] = (object) array('type' => 'grouping', 'id' => $id);
}
$conditioncm = array();
foreach ($conditioncmid as $i => $id) {
if ($id == 0) {
continue;
}
$conditioncm[] = (object) array('type' => 'completion', 'cm' => $id, 'e' => isset($conditioncmcompletion[$i]) ? $conditioncmcompletion[$i] : 1, 'ungraded' => empty($conditioncmungraded[$i]) ? 0 : 1, 'resources' => empty($conditioncmresources[$i]) ? 0 : 1, 'labels' => empty($conditioncmlabels[$i]) ? 0 : 1);
}
if ($completionday && $completionmonth && $completionyear) {
$completiondate = make_timestamp($completionyear, $completionmonth, $completionday, 0, 0, 0, 99, false);
} else {
$completiondate = 0;
}
// add standard settings
$settings = array('availablefrom', 'availableuntil', 'availablecutoff', 'rating', 'maxgrade', 'gradepass', 'gradecat', 'gradeitemhidden', 'extracredit', 'regrade', 'groupmode', 'groupingid', 'groupmembersonly', 'visible', 'indent', 'section', 'uploadlimit');
// add switches to enable/disable filters
$filters = filter_get_available_in_context($course->context);
foreach (array_keys($filters) as $filter) {
$setting = 'filter' . $filter;
echo $setting;
$settings[] = $setting;
${$setting} = optional_param($setting, null, PARAM_INT);
}
// add "availability" settings, if enabled
if (empty($CFG->enableavailability)) {
$enableavailability = false;
} else {
$enableavailability = true;
}
if ($enableavailability) {
array_push($settings, 'removeconditions', 'conditiondate', 'conditiongrade', 'conditionfield', 'conditiongroup', 'conditiongrouping', 'conditioncm', 'conditionaction');
}
// add "completion" settings, if enabled
if (empty($CFG->enablecompletion) || empty($course->enablecompletion)) {
$enablecompletion = false;
} else {
$enablecompletion = true;
}
if ($enablecompletion) {
array_push($settings, 'removecompletion', 'erasecompletion', 'completiontracking', 'completiondate');
}
// are we using competencies
// (available in Moodle >= 3.1)
if (get_config('core_competency', 'enabled')) {
$enablecompetency = true;
} else {
$enablecompetency = false;
}
if ($enablecompetency) {
开发者ID:gbateson,项目名称:moodle-block_taskchain_navigation,代码行数:67,代码来源:accesscontrol.php
注:本文中的filter_get_available_in_context函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论