public function load_choices() { if (is_array($this->choices)) { return true; } $this->choices = array('mathjax' => get_string('settingmathsdisplay_mathjax', 'qtype_stack')); // Remove this if statement once we no longer need to support Moodle 2.5.x. if (class_exists('core_component') && method_exists('core_component', 'get_plugin_list_with_file')) { $filters = core_component::get_plugin_list_with_file('filter', 'filter.php'); } else { $filters = get_plugin_list_with_file('filter', 'filter.php'); } if (array_key_exists('tex', $filters)) { $this->choices['tex'] = get_string('settingmathsdisplay_tex', 'qtype_stack'); } if (array_key_exists('maths', $filters)) { $this->choices['maths'] = get_string('settingmathsdisplay_maths', 'qtype_stack'); } return true; }
/** * Initialises the navigation object. * * This causes the navigation object to look at the current state of the page * that it is associated with and then load the appropriate content. * * This should only occur the first time that the navigation structure is utilised * which will normally be either when the navbar is called to be displayed or * when a block makes use of it. * * @return bool */ public function initialise() { global $CFG, $SITE, $USER, $DB; // Check if it has alread been initialised if ($this->initialised || during_initial_install()) { return true; } $this->initialised = true; // Set up the five base root nodes. These are nodes where we will put our // content and are as follows: // site: Navigation for the front page. // myprofile: User profile information goes here. // mycourses: The users courses get added here. // courses: Additional courses are added here. // users: Other users information loaded here. $this->rootnodes = array(); if (get_home_page() == HOMEPAGE_SITE) { // The home element should be my moodle because the root element is the site if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in $this->rootnodes['home'] = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_SETTING, null, 'home'); } } else { // The home element should be the site because the root node is my moodle $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home'); if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY) { // We need to stop automatic redirection $this->rootnodes['home']->action->param('redirect', '0'); } } $this->rootnodes['site'] = $this->add_course($SITE); $this->rootnodes['myprofile'] = $this->add(get_string('myprofile'), null, self::TYPE_USER, null, 'myprofile'); $this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), null, self::TYPE_ROOTNODE, null, 'mycourses'); $this->rootnodes['courses'] = $this->add(get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_ROOTNODE, null, 'courses'); $this->rootnodes['users'] = $this->add(get_string('users'), null, self::TYPE_ROOTNODE, null, 'users'); // We always load the frontpage course to ensure it is available without // JavaScript enabled. $this->add_front_page_course_essentials($this->rootnodes['site'], $SITE); $this->load_course_sections($SITE, $this->rootnodes['site']); // Fetch all of the users courses. $mycourses = enrol_get_my_courses(); // We need to show categories if we can show categories and the user isn't enrolled in any courses or we're not showing all courses $showcategories = $this->show_categories() && (count($mycourses) == 0 || !empty($CFG->navshowallcourses)); // $issite gets set to true if the current pages course is the sites frontpage course $issite = $this->page->course->id == $SITE->id; // $ismycourse gets set to true if the user is enrolled in the current pages course. $ismycourse = !$issite && array_key_exists($this->page->course->id, $mycourses); // Check if any courses were returned. if (count($mycourses) > 0) { // Check if categories should be displayed within the my courses branch if (!empty($CFG->navshowmycoursecategories)) { // Find the category of each mycourse $categories = array(); foreach ($mycourses as $course) { $categories[] = $course->category; } // Do a single DB query to get the categories immediately associated with // courses the user is enrolled in. $categories = $DB->get_records_list('course_categories', 'id', array_unique($categories), 'depth ASC, sortorder ASC'); // Work out the parent categories that we need to load that we havn't // already got. $categoryids = array(); foreach ($categories as $category) { $categoryids = array_merge($categoryids, explode('/', trim($category->path, '/'))); } $categoryids = array_unique($categoryids); $categoryids = array_diff($categoryids, array_keys($categories)); if (count($categoryids)) { // Fetch any other categories we need. $allcategories = $DB->get_records_list('course_categories', 'id', $categoryids, 'depth ASC, sortorder ASC'); if (is_array($allcategories) && count($allcategories) > 0) { $categories = array_merge($categories, $allcategories); } } // We ONLY want the categories, we need to get rid of the keys $categories = array_values($categories); $addedcategories = array(); while (($category = array_shift($categories)) !== null) { if ($category->parent == '0') { $categoryparent = $this->rootnodes['mycourses']; } else { if (array_key_exists($category->parent, $addedcategories)) { $categoryparent = $addedcategories[$category->parent]; } else { // Prepare to count iterations. We don't want to loop forever // accidentally if for some reason a category can't be placed. if (!isset($category->loopcount)) { $category->loopcount = 0; } $category->loopcount++; if ($category->loopcount > 5) { // This is a pretty serious problem and this should never happen. // If it does then for some reason a category has been loaded but // its parents have now. It could be data corruption. debugging('Category ' . $category->id . ' could not be placed within the navigation', DEBUG_DEVELOPER); } else { // Add it back to the end of the categories array array_push($categories, $category); } continue; } } $url = new moodle_url('/course/category.php', array('id' => $category->id)); $addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id); if (!$category->visible) { // Let's decide the context where viewhidden cap checks will happen. if ($category->parent == '0') { $contexttocheck = context_system::instance(); } else { $contexttocheck = context_coursecat::instance($category->parent); } if (!has_capability('moodle/category:viewhiddencategories', $contexttocheck)) { $addedcategories[$category->id]->display = false; } else { $addedcategories[$category->id]->hidden = true; } } } } // Add all of the users courses to the navigation. // First up we need to add to the mycourses section. foreach ($mycourses as $course) { $course->coursenode = $this->add_course($course, false, true); } if (!empty($CFG->navshowallcourses)) { // Load all courses $this->load_all_courses(); } // Next if nasvshowallcourses is enabled then we need to add courses // to the courses branch as well. if (!empty($CFG->navshowallcourses)) { foreach ($mycourses as $course) { if (!empty($course->category) && !$this->can_add_more_courses_to_category($course->category)) { continue; } $genericcoursenode = $this->add_course($course, true); if ($genericcoursenode->isactive) { // We don't want this node to be active because we want the // node in the mycourses branch to be active. $genericcoursenode->make_inactive(); $genericcoursenode->collapse = true; if ($genericcoursenode->parent && $genericcoursenode->parent->type == self::TYPE_CATEGORY) { $parent = $genericcoursenode->parent; while ($parent && $parent->type == self::TYPE_CATEGORY) { $parent->collapse = true; $parent = $parent->parent; } } } } } } else { if (!empty($CFG->navshowallcourses) || !$this->show_categories()) { // Load all courses $this->load_all_courses(); } } $canviewcourseprofile = true; // Next load context specific content into the navigation switch ($this->page->context->contextlevel) { case CONTEXT_SYSTEM: // This has already been loaded we just need to map the variable if ($showcategories) { $this->load_all_categories(self::LOAD_ROOT_CATEGORIES, true); } break; case CONTEXT_COURSECAT: // This has already been loaded we just need to map the variable if ($this->show_categories()) { $this->load_all_categories($this->page->context->instanceid, true); } break; case CONTEXT_BLOCK: case CONTEXT_COURSE: if ($issite) { // If it is the front page course, or a block on it then // all we need to do is load the root categories if required if ($showcategories) { $this->load_all_categories(self::LOAD_ROOT_CATEGORIES, true); } break; } // Load the course associated with the page into the navigation $course = $this->page->course; if ($this->show_categories() && !$ismycourse) { // The user isn't enrolled in the course and we need to show categories in which case we need // to load the category relating to the course and depending up $showcategories all of the root categories as well. $this->load_all_categories($course->category, $showcategories); } $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. // Not enrolled, can't view, and hasn't switched roles if (!can_access_course($course)) { // TODO: very ugly hack - do not force "parents" to enrol into course their child is enrolled in, // this hack has been propagated from user/view.php to display the navigation node. (MDL-25805) $isparent = false; if ($this->useridtouseforparentchecks) { if ($this->useridtouseforparentchecks != $USER->id) { $usercontext = get_context_instance(CONTEXT_USER, $this->useridtouseforparentchecks, MUST_EXIST); if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id)) and has_capability('moodle/user:viewdetails', $usercontext)) { $isparent = true; } } } if (!$isparent) { $coursenode->make_active(); $canviewcourseprofile = false; break; } } // Add the essentials such as reports etc... $this->add_course_essentials($coursenode, $course); if ($this->format_display_course_content($course->format)) { // Load the course sections $sections = $this->load_course_sections($course, $coursenode); } if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) { $coursenode->make_active(); } break; case CONTEXT_MODULE: if ($issite) { // If this is the site course then most information will have // already been loaded. // However we need to check if there is more content that can // yet be loaded for the specific module instance. $activitynode = $this->rootnodes['site']->get($this->page->cm->id, navigation_node::TYPE_ACTIVITY); if ($activitynode) { $this->load_activity($this->page->cm, $this->page->course, $activitynode); } break; } $course = $this->page->course; $cm = $this->page->cm; if ($this->show_categories() && !$ismycourse) { $this->load_all_categories($course->category, $showcategories); } // Load the course associated with the page into the navigation $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. if (!can_access_course($course)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); // Get section number from $cm (if provided) - we need this // before loading sections in order to tell it to load this section // even if it would not normally display (=> it contains only // a label, which we are now editing) $sectionnum = isset($cm->sectionnum) ? $cm->sectionnum : 0; if ($sectionnum) { // This value has to be stored in a member variable because // otherwise we would have to pass it through a public API // to course formats and they would need to change their // functions to pass it along again... $this->includesectionnum = $sectionnum; } else { $this->includesectionnum = false; } // Load the course sections into the page $sections = $this->load_course_sections($course, $coursenode); if ($course->id != $SITE->id) { // Find the section for the $CM associated with the page and collect // its section number. if ($sectionnum) { $cm->sectionnumber = $sectionnum; } else { foreach ($sections as $section) { if ($section->id == $cm->section) { $cm->sectionnumber = $section->section; break; } } } // Load all of the section activities for the section the cm belongs to. if (isset($cm->sectionnumber) and !empty($sections[$cm->sectionnumber])) { list($sectionarray, $activityarray) = $this->generate_sections_and_activities($course); $activities = $this->load_section_activities($sections[$cm->sectionnumber]->sectionnode, $cm->sectionnumber, $activityarray); } else { $activities = array(); if ($activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course))) { // "stealth" activity from unavailable section $activities[$cm->id] = $activity; } } } else { $activities = array(); $activities[$cm->id] = $coursenode->get($cm->id, navigation_node::TYPE_ACTIVITY); } if (!empty($activities[$cm->id])) { // Finally load the cm specific navigaton information $this->load_activity($cm, $course, $activities[$cm->id]); // Check if we have an active ndoe if (!$activities[$cm->id]->contains_active_node() && !$activities[$cm->id]->search_for_active_node()) { // And make the activity node active. $activities[$cm->id]->make_active(); } } else { //TODO: something is wrong, what to do? (Skodak) } break; case CONTEXT_USER: if ($issite) { // The users profile information etc is already loaded // for the front page. break; } $course = $this->page->course; if ($this->show_categories() && !$ismycourse) { $this->load_all_categories($course->category, $showcategories); } // Load the course associated with the user into the navigation $coursenode = $this->load_course($course); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. if (!can_access_course($course)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); $sections = $this->load_course_sections($course, $coursenode); break; } // Look for all categories which have been loaded if ($showcategories) { $categories = $this->find_all_of_type(self::TYPE_CATEGORY); if (count($categories) !== 0) { $categoryids = array(); foreach ($categories as $category) { $categoryids[] = $category->key; } list($categoriessql, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED); $params['limit'] = !empty($CFG->navcourselimit) ? $CFG->navcourselimit : 20; $sql = "SELECT cc.id, COUNT(c.id) AS coursecount\n FROM {course_categories} cc\n JOIN {course} c ON c.category = cc.id\n WHERE cc.id {$categoriessql}\n GROUP BY cc.id\n HAVING COUNT(c.id) > :limit"; $excessivecategories = $DB->get_records_sql($sql, $params); foreach ($categories as &$category) { if (array_key_exists($category->key, $excessivecategories) && !$this->can_add_more_courses_to_category($category)) { $url = new moodle_url('/course/category.php', array('id' => $category->key)); $category->add(get_string('viewallcourses'), $url, self::TYPE_SETTING); } } } } else { if ((!empty($CFG->navshowallcourses) || empty($mycourses)) && !$this->can_add_more_courses_to_category($this->rootnodes['courses'])) { $this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING); } } // Load for the current user $this->load_for_user(); if ($this->page->context->contextlevel >= CONTEXT_COURSE && $this->page->context->instanceid != $SITE->id && $canviewcourseprofile) { $this->load_for_user(null, true); } // Load each extending user into the navigation. foreach ($this->extendforuser as $user) { if ($user->id != $USER->id) { $this->load_for_user($user); } } // Give the local plugins a chance to include some navigation if they want. foreach (get_plugin_list_with_file('local', 'lib.php', true) as $plugin => $file) { $function = "local_{$plugin}_extends_navigation"; $oldfunction = "{$plugin}_extends_navigation"; if (function_exists($function)) { // This is the preferred function name as there is less chance of conflicts $function($this); } else { if (function_exists($oldfunction)) { // We continue to support the old function name to ensure backwards compatability $oldfunction($this); } } } // Remove any empty root nodes foreach ($this->rootnodes as $node) { // Dont remove the home node if ($node->key !== 'home' && !$node->has_children()) { $node->remove(); } } if (!$this->contains_active_node()) { $this->search_for_active_node(); } // If the user is not logged in modify the navigation structure as detailed // in {@link http://docs.moodle.org/dev/Navigation_2.0_structure} if (!isloggedin()) { $activities = clone $this->rootnodes['site']->children; $this->rootnodes['site']->remove(); $children = clone $this->children; $this->children = new navigation_node_collection(); foreach ($activities as $child) { $this->children->add($child); } foreach ($children as $child) { $this->children->add($child); } } return true; }
require_once($CFG->dirroot . '/mod/quiz/lib.php'); require_once($CFG->dirroot . '/mod/quiz/settingslib.php'); // First get a list of quiz reports with there own settings pages. If there none, // we use a simpler overall menu structure. $reports = get_plugin_list_with_file('quiz', 'settings.php', false); $reportsbyname = array(); foreach ($reports as $report => $reportdir) { $strreportname = get_string($report . 'report', 'quiz_'.$report); $reportsbyname[$strreportname] = $report; } collatorlib::ksort($reportsbyname); // First get a list of quiz reports with there own settings pages. If there none, // we use a simpler overall menu structure. $rules = get_plugin_list_with_file('quizaccess', 'settings.php', false); $rulesbyname = array(); foreach ($rules as $rule => $ruledir) { $strrulename = get_string('pluginname', 'quizaccess_' . $rule); $rulesbyname[$strrulename] = $rule; } collatorlib::ksort($rulesbyname); // Create the quiz settings page. if (empty($reportsbyname) && empty($rulesbyname)) { $pagetitle = get_string('modulename', 'quiz'); } else { $pagetitle = get_string('generalsettings', 'admin'); } $quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config');
/** * Get a list of all the plugins of a given type that define a certain class * in a certain file. The plugin component names and class names are returned. * * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'. * @param string $class the part of the name of the class after the * frankenstyle prefix. e.g 'thing' if you are looking for classes with * names like report_courselist_thing. If you are looking for classes with * the same name as the plugin name (e.g. qtype_multichoice) then pass ''. * @param string $file the name of file within the plugin that defines the class. * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum') * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice'). */ function get_plugin_list_with_class($plugintype, $class, $file) { if ($class) { $suffix = '_' . $class; } else { $suffix = ''; } $pluginclasses = array(); foreach (get_plugin_list_with_file($plugintype, $file, true) as $plugin => $notused) { $classname = $plugintype . '_' . $plugin . $suffix; if (class_exists($classname)) { $pluginclasses[$plugintype . '_' . $plugin] = $classname; } } return $pluginclasses; }
/** * Returns the list of available grading evaluation methods * * @return array of (string)name => (string)localized title */ public static function available_evaluators_list() { $evals = array(); foreach (get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) { $evals[$eval] = get_string('pluginname', 'workshopeval_' . $eval); } return $evals; }
/** * Initialises the navigation object. * * This causes the navigation object to look at the current state of the page * that it is associated with and then load the appropriate content. * * This should only occur the first time that the navigation structure is utilised * which will normally be either when the navbar is called to be displayed or * when a block makes use of it. * * @return bool */ public function initialise() { global $CFG, $SITE, $USER; // Check if it has already been initialised if ($this->initialised || during_initial_install()) { return true; } $this->initialised = true; // Set up the five base root nodes. These are nodes where we will put our // content and are as follows: // site: Navigation for the front page. // myprofile: User profile information goes here. // currentcourse: The course being currently viewed. // mycourses: The users courses get added here. // courses: Additional courses are added here. // users: Other users information loaded here. $this->rootnodes = array(); if (get_home_page() == HOMEPAGE_SITE) { // The home element should be my moodle because the root element is the site if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in $this->rootnodes['home'] = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_SETTING, null, 'home'); } } else { // The home element should be the site because the root node is my moodle $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home'); if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY) { // We need to stop automatic redirection $this->rootnodes['home']->action->param('redirect', '0'); } } $this->rootnodes['site'] = $this->add_course($SITE); $this->rootnodes['myprofile'] = $this->add(get_string('myprofile'), null, self::TYPE_USER, null, 'myprofile'); $this->rootnodes['currentcourse'] = $this->add(get_string('currentcourse'), null, self::TYPE_ROOTNODE, null, 'currentcourse'); $this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), new moodle_url('/my/'), self::TYPE_ROOTNODE, null, 'mycourses'); $this->rootnodes['courses'] = $this->add(get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_ROOTNODE, null, 'courses'); $this->rootnodes['users'] = $this->add(get_string('users'), null, self::TYPE_ROOTNODE, null, 'users'); // We always load the frontpage course to ensure it is available without // JavaScript enabled. $this->add_front_page_course_essentials($this->rootnodes['site'], $SITE); $this->load_course_sections($SITE, $this->rootnodes['site']); $course = $this->page->course; // $issite gets set to true if the current pages course is the sites frontpage course $issite = $this->page->course->id == $SITE->id; // Determine if the user is enrolled in any course. $enrolledinanycourse = enrol_user_sees_own_courses(); $this->rootnodes['currentcourse']->mainnavonly = true; if ($enrolledinanycourse) { $this->rootnodes['mycourses']->isexpandable = true; if ($CFG->navshowallcourses) { // When we show all courses we need to show both the my courses and the regular courses branch. $this->rootnodes['courses']->isexpandable = true; } } else { $this->rootnodes['courses']->isexpandable = true; } if ($this->rootnodes['mycourses']->isactive) { $this->load_courses_enrolled(); } $canviewcourseprofile = true; // Next load context specific content into the navigation switch ($this->page->context->contextlevel) { case CONTEXT_SYSTEM: // Nothing left to do here I feel. break; case CONTEXT_COURSECAT: // This is essential, we must load categories. $this->load_all_categories($this->page->context->instanceid, true); break; case CONTEXT_BLOCK: case CONTEXT_COURSE: if ($issite) { // Nothing left to do here. break; } // Load the course associated with the current page into the navigation. $coursenode = $this->add_course($course, false, self::COURSE_CURRENT); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. // Not enrolled, can't view, and hasn't switched roles if (!can_access_course($course)) { // Very ugly hack - do not force "parents" to enrol into course their child is enrolled in, // this hack has been propagated from user/view.php to display the navigation node. (MDL-25805) if (!$this->current_user_is_parent_role()) { $coursenode->make_active(); $canviewcourseprofile = false; break; } } // Add the essentials such as reports etc... $this->add_course_essentials($coursenode, $course); // Extend course navigation with it's sections/activities $this->load_course_sections($course, $coursenode); if (!$coursenode->contains_active_node() && !$coursenode->search_for_active_node()) { $coursenode->make_active(); } break; case CONTEXT_MODULE: if ($issite) { // If this is the site course then most information will have // already been loaded. // However we need to check if there is more content that can // yet be loaded for the specific module instance. $activitynode = $this->rootnodes['site']->find($this->page->cm->id, navigation_node::TYPE_ACTIVITY); if ($activitynode) { $this->load_activity($this->page->cm, $this->page->course, $activitynode); } break; } $course = $this->page->course; $cm = $this->page->cm; // Load the course associated with the page into the navigation $coursenode = $this->add_course($course, false, self::COURSE_CURRENT); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. if (!can_access_course($course)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); // Load the course sections into the page $this->load_course_sections($course, $coursenode, null, $cm); $activity = $coursenode->find($cm->id, navigation_node::TYPE_ACTIVITY); // Finally load the cm specific navigaton information $this->load_activity($cm, $course, $activity); // Check if we have an active ndoe if (!$activity->contains_active_node() && !$activity->search_for_active_node()) { // And make the activity node active. $activity->make_active(); } break; case CONTEXT_USER: if ($issite) { // The users profile information etc is already loaded // for the front page. break; } $course = $this->page->course; // Load the course associated with the user into the navigation $coursenode = $this->add_course($course, false, self::COURSE_CURRENT); // If the course wasn't added then don't try going any further. if (!$coursenode) { $canviewcourseprofile = false; break; } // If the user is not enrolled then we only want to show the // course node and not populate it. if (!can_access_course($course)) { $coursenode->make_active(); $canviewcourseprofile = false; break; } $this->add_course_essentials($coursenode, $course); $this->load_course_sections($course, $coursenode); break; } // Load for the current user $this->load_for_user(); if ($this->page->context->contextlevel >= CONTEXT_COURSE && $this->page->context->instanceid != $SITE->id && $canviewcourseprofile) { $this->load_for_user(null, true); } // Load each extending user into the navigation. foreach ($this->extendforuser as $user) { if ($user->id != $USER->id) { $this->load_for_user($user); } } // Give the local plugins a chance to include some navigation if they want. foreach (get_plugin_list_with_file('local', 'lib.php', true) as $plugin => $file) { $function = "local_{$plugin}_extends_navigation"; $oldfunction = "{$plugin}_extends_navigation"; if (function_exists($function)) { // This is the preferred function name as there is less chance of conflicts $function($this); } else { if (function_exists($oldfunction)) { // We continue to support the old function name to ensure backwards compatibility debugging("Deprecated local plugin navigation callback: Please rename '{$oldfunction}' to '{$function}'. Support for the old callback will be dropped after the release of 2.4", DEBUG_DEVELOPER); $oldfunction($this); } } } // Remove any empty root nodes foreach ($this->rootnodes as $node) { // Dont remove the home node if ($node->key !== 'home' && !$node->has_children()) { $node->remove(); } } if (!$this->contains_active_node()) { $this->search_for_active_node(); } // If the user is not logged in modify the navigation structure as detailed // in {@link http://docs.moodle.org/dev/Navigation_2.0_structure} if (!isloggedin()) { $activities = clone $this->rootnodes['site']->children; $this->rootnodes['site']->remove(); $children = clone $this->children; $this->children = new navigation_node_collection(); foreach ($activities as $child) { $this->children->add($child); } foreach ($children as $child) { $this->children->add($child); } } return true; }
/** * Returns an array of information about plugins, everything a renderer needs. * @return array */ public static function get_store_plugin_summaries() { $return = array(); $plugins = get_plugin_list_with_file('cachestore', 'lib.php', true); foreach ($plugins as $plugin => $path) { $class = 'cachestore_' . $plugin; $return[$plugin] = array('name' => get_string('pluginname', 'cachestore_' . $plugin), 'requirementsmet' => $class::are_requirements_met(), 'instances' => 0, 'modes' => array(cache_store::MODE_APPLICATION => $class::get_supported_modes() & cache_store::MODE_APPLICATION, cache_store::MODE_SESSION => $class::get_supported_modes() & cache_store::MODE_SESSION, cache_store::MODE_REQUEST => $class::get_supported_modes() & cache_store::MODE_REQUEST), 'supports' => array('multipleidentifiers' => $class::get_supported_features() & cache_store::SUPPORTS_MULTIPLE_IDENTIFIERS, 'dataguarantee' => $class::get_supported_features() & cache_store::SUPPORTS_DATA_GUARANTEE, 'nativettl' => $class::get_supported_features() & cache_store::SUPPORTS_NATIVE_TTL, 'nativelocking' => in_array('cache_is_lockable', class_implements($class)), 'keyawareness' => array_key_exists('cache_is_key_aware', class_implements($class))), 'canaddinstance' => $class::can_add_instance() && $class::are_requirements_met()); } $instance = cache_config::instance(); $stores = $instance->get_all_stores(); foreach ($stores as $store) { $plugin = $store['plugin']; if (array_key_exists($plugin, $return)) { $return[$plugin]['instances']++; } } return $return; }
/** * This function adds plugin pages to the navigation menu * * @static * @param string $subtype - The type of plugin (submission or feedback) * @param part_of_admin_tree $admin - The handle to the admin menu * @param admin_settingpage $settings - The handle to current node in the navigation tree * @param stdClass $module - The handle to the current module * @return None */ static function add_admin_assign_plugin_settings($subtype, part_of_admin_tree $admin, admin_settingpage $settings, stdClass $module) { global $CFG; $plugins = get_plugin_list_with_file($subtype, 'settings.php', false); $pluginsbyname = array(); foreach ($plugins as $plugin => $plugindir) { $pluginname = get_string('pluginname', $subtype . '_'.$plugin); $pluginsbyname[$pluginname] = $plugin; } ksort($pluginsbyname); foreach ($pluginsbyname as $pluginname => $plugin) { $settings = new admin_settingpage($subtype . '_'.$plugin, $pluginname, 'moodle/site:config', !$module->visible); if ($admin->fulltree) { $shortsubtype = substr($subtype, strlen('assign')); include($CFG->dirroot . "/mod/assign/$shortsubtype/$plugin/settings.php"); } $admin->add($subtype . 'plugins', $settings); } }
* * @package mod * @subpackage quiz * @copyright 2010 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/mod/quiz/lib.php'); require_once($CFG->dirroot . '/mod/quiz/settingslib.php'); // First get a list of quiz reports with there own settings pages. If there none, // we use a simpler overall menu structure. $reports = get_plugin_list_with_file('quiz', 'settings.php', false); $reportsbyname = array(); foreach ($reports as $report => $reportdir) { $strreportname = get_string($report . 'report', 'quiz_'.$report); $reportsbyname[$strreportname] = $report; } ksort($reportsbyname); // Create the quiz settings page. if (empty($reportsbyname)) { $pagetitle = get_string('modulename', 'quiz'); } else { $pagetitle = get_string('generalsettings', 'admin'); } $quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config');
$count = max($count, 0); admin_externalpage_setup('cachetestperformance'); $applicationtable = new html_table(); $applicationtable->head = array(get_string('plugin', 'cache'), get_string('result', 'cache'), get_string('set', 'cache'), get_string('gethit', 'cache'), get_string('getmiss', 'cache'), get_string('delete', 'cache')); $applicationtable->data = array(); $sessiontable = clone $applicationtable; $requesttable = clone $applicationtable; $application = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cache', 'applicationtest'); $session = cache_definition::load_adhoc(cache_store::MODE_SESSION, 'cache', 'sessiontest'); $request = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cache', 'requesttest'); $strinvalidplugin = new lang_string('invalidplugin', 'cache'); $strunsupportedmode = new lang_string('unsupportedmode', 'cache'); $struntestable = new lang_string('untestable', 'cache'); $strtested = new lang_string('tested', 'cache'); $strnotready = new lang_string('storenotready', 'cache'); foreach (get_plugin_list_with_file('cachestore', 'lib.php', true) as $plugin => $path) { $class = 'cachestore_' . $plugin; $plugin = get_string('pluginname', 'cachestore_' . $plugin); if (!class_exists($class) || !method_exists($class, 'initialise_test_instance') || !$class::are_requirements_met()) { $applicationtable->data[] = array($plugin, $strinvalidplugin, '-', '-', '-', '-'); $sessiontable->data[] = array($plugin, $strinvalidplugin, '-', '-', '-', '-'); $requesttable->data[] = array($plugin, $strinvalidplugin, '-', '-', '-', '-'); continue; } if (!$class::is_supported_mode(cache_store::MODE_APPLICATION)) { $applicationtable->data[] = array($plugin, $strunsupportedmode, '-', '-', '-', '-'); } else { $store = $class::initialise_test_instance($application); if ($store === false) { $applicationtable->data[] = array($plugin, $struntestable, '-', '-', '-', '-'); } else {