id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
215,800
moodle/moodle
lib/adminlib.php
admin_page_managemessageoutputs.search
public function search($query) { global $CFG, $DB; if ($result = parent::search($query)) { return $result; } $found = false; if ($processors = get_message_processors()) { foreach ($processors as $processor) { if (!$processor->available) { continue; } if (strpos($processor->name, $query) !== false) { $found = true; break; } $strprocessorname = get_string('pluginname', 'message_'.$processor->name); if (strpos(core_text::strtolower($strprocessorname), $query) !== false) { $found = true; break; } } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
php
public function search($query) { global $CFG, $DB; if ($result = parent::search($query)) { return $result; } $found = false; if ($processors = get_message_processors()) { foreach ($processors as $processor) { if (!$processor->available) { continue; } if (strpos($processor->name, $query) !== false) { $found = true; break; } $strprocessorname = get_string('pluginname', 'message_'.$processor->name); if (strpos(core_text::strtolower($strprocessorname), $query) !== false) { $found = true; break; } } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
[ "public", "function", "search", "(", "$", "query", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "if", "(", "$", "result", "=", "parent", "::", "search", "(", "$", "query", ")", ")", "{", "return", "$", "result", ";", "}", "$", "found", "=", "false", ";", "if", "(", "$", "processors", "=", "get_message_processors", "(", ")", ")", "{", "foreach", "(", "$", "processors", "as", "$", "processor", ")", "{", "if", "(", "!", "$", "processor", "->", "available", ")", "{", "continue", ";", "}", "if", "(", "strpos", "(", "$", "processor", "->", "name", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "$", "strprocessorname", "=", "get_string", "(", "'pluginname'", ",", "'message_'", ".", "$", "processor", "->", "name", ")", ";", "if", "(", "strpos", "(", "core_text", "::", "strtolower", "(", "$", "strprocessorname", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "$", "found", ")", "{", "$", "result", "=", "new", "stdClass", "(", ")", ";", "$", "result", "->", "page", "=", "$", "this", ";", "$", "result", "->", "settings", "=", "array", "(", ")", ";", "return", "array", "(", "$", "this", "->", "name", "=>", "$", "result", ")", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Search for a specific message processor @param string $query The string to search for @return array
[ "Search", "for", "a", "specific", "message", "processor" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L6354-L6385
215,801
moodle/moodle
lib/adminlib.php
admin_page_manageqbehaviours.search
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; require_once($CFG->dirroot . '/question/engine/lib.php'); foreach (core_component::get_plugin_list('qbehaviour') as $behaviour => $notused) { if (strpos(core_text::strtolower(question_engine::get_behaviour_name($behaviour)), $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
php
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; require_once($CFG->dirroot . '/question/engine/lib.php'); foreach (core_component::get_plugin_list('qbehaviour') as $behaviour => $notused) { if (strpos(core_text::strtolower(question_engine::get_behaviour_name($behaviour)), $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
[ "public", "function", "search", "(", "$", "query", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "result", "=", "parent", "::", "search", "(", "$", "query", ")", ")", "{", "return", "$", "result", ";", "}", "$", "found", "=", "false", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/question/engine/lib.php'", ")", ";", "foreach", "(", "core_component", "::", "get_plugin_list", "(", "'qbehaviour'", ")", "as", "$", "behaviour", "=>", "$", "notused", ")", "{", "if", "(", "strpos", "(", "core_text", "::", "strtolower", "(", "question_engine", "::", "get_behaviour_name", "(", "$", "behaviour", ")", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "found", ")", "{", "$", "result", "=", "new", "stdClass", "(", ")", ";", "$", "result", "->", "page", "=", "$", "this", ";", "$", "result", "->", "settings", "=", "array", "(", ")", ";", "return", "array", "(", "$", "this", "->", "name", "=>", "$", "result", ")", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Search question behaviours for the specified string @param string $query The string to search for in question behaviours @return array
[ "Search", "question", "behaviours", "for", "the", "specified", "string" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L6436-L6459
215,802
moodle/moodle
lib/adminlib.php
admin_page_manageqtypes.search
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; require_once($CFG->dirroot . '/question/engine/bank.php'); foreach (question_bank::get_all_qtypes() as $qtype) { if (strpos(core_text::strtolower($qtype->local_name()), $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
php
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; require_once($CFG->dirroot . '/question/engine/bank.php'); foreach (question_bank::get_all_qtypes() as $qtype) { if (strpos(core_text::strtolower($qtype->local_name()), $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass(); $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
[ "public", "function", "search", "(", "$", "query", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "result", "=", "parent", "::", "search", "(", "$", "query", ")", ")", "{", "return", "$", "result", ";", "}", "$", "found", "=", "false", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/question/engine/bank.php'", ")", ";", "foreach", "(", "question_bank", "::", "get_all_qtypes", "(", ")", "as", "$", "qtype", ")", "{", "if", "(", "strpos", "(", "core_text", "::", "strtolower", "(", "$", "qtype", "->", "local_name", "(", ")", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "found", ")", "{", "$", "result", "=", "new", "stdClass", "(", ")", ";", "$", "result", "->", "page", "=", "$", "this", ";", "$", "result", "->", "settings", "=", "array", "(", ")", ";", "return", "array", "(", "$", "this", "->", "name", "=>", "$", "result", ")", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Search question types for the specified string @param string $query The string to search for in question types @return array
[ "Search", "question", "types", "for", "the", "specified", "string" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L6484-L6506
215,803
moodle/moodle
lib/adminlib.php
admin_setting_manageauths.is_related
public function is_related($query) { if (parent::is_related($query)) { return true; } $authsavailable = core_component::get_plugin_list('auth'); foreach ($authsavailable as $auth => $dir) { if (strpos($auth, $query) !== false) { return true; } $authplugin = get_auth_plugin($auth); $authtitle = $authplugin->get_title(); if (strpos(core_text::strtolower($authtitle), $query) !== false) { return true; } } return false; }
php
public function is_related($query) { if (parent::is_related($query)) { return true; } $authsavailable = core_component::get_plugin_list('auth'); foreach ($authsavailable as $auth => $dir) { if (strpos($auth, $query) !== false) { return true; } $authplugin = get_auth_plugin($auth); $authtitle = $authplugin->get_title(); if (strpos(core_text::strtolower($authtitle), $query) !== false) { return true; } } return false; }
[ "public", "function", "is_related", "(", "$", "query", ")", "{", "if", "(", "parent", "::", "is_related", "(", "$", "query", ")", ")", "{", "return", "true", ";", "}", "$", "authsavailable", "=", "core_component", "::", "get_plugin_list", "(", "'auth'", ")", ";", "foreach", "(", "$", "authsavailable", "as", "$", "auth", "=>", "$", "dir", ")", "{", "if", "(", "strpos", "(", "$", "auth", ",", "$", "query", ")", "!==", "false", ")", "{", "return", "true", ";", "}", "$", "authplugin", "=", "get_auth_plugin", "(", "$", "auth", ")", ";", "$", "authtitle", "=", "$", "authplugin", "->", "get_title", "(", ")", ";", "if", "(", "strpos", "(", "core_text", "::", "strtolower", "(", "$", "authtitle", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Search to find if Query is related to auth plugin @param string $query The string to search for @return bool true for related false for not
[ "Search", "to", "find", "if", "Query", "is", "related", "to", "auth", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L6660-L6677
215,804
moodle/moodle
lib/adminlib.php
admin_setting_manageformats.is_related
public function is_related($query) { if (parent::is_related($query)) { return true; } $formats = core_plugin_manager::instance()->get_plugins_of_type('format'); foreach ($formats as $format) { if (strpos($format->component, $query) !== false || strpos(core_text::strtolower($format->displayname), $query) !== false) { return true; } } return false; }
php
public function is_related($query) { if (parent::is_related($query)) { return true; } $formats = core_plugin_manager::instance()->get_plugins_of_type('format'); foreach ($formats as $format) { if (strpos($format->component, $query) !== false || strpos(core_text::strtolower($format->displayname), $query) !== false) { return true; } } return false; }
[ "public", "function", "is_related", "(", "$", "query", ")", "{", "if", "(", "parent", "::", "is_related", "(", "$", "query", ")", ")", "{", "return", "true", ";", "}", "$", "formats", "=", "core_plugin_manager", "::", "instance", "(", ")", "->", "get_plugins_of_type", "(", "'format'", ")", ";", "foreach", "(", "$", "formats", "as", "$", "format", ")", "{", "if", "(", "strpos", "(", "$", "format", "->", "component", ",", "$", "query", ")", "!==", "false", "||", "strpos", "(", "core_text", "::", "strtolower", "(", "$", "format", "->", "displayname", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Search to find if Query is related to format plugin @param string $query The string to search for @return bool true for related false for not
[ "Search", "to", "find", "if", "Query", "is", "related", "to", "format", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L7340-L7352
215,805
moodle/moodle
lib/adminlib.php
admin_page_managefilters.search
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; $filternames = filter_get_all_installed(); foreach ($filternames as $path => $strfiltername) { if (strpos(core_text::strtolower($strfiltername), $query) !== false) { $found = true; break; } if (strpos($path, $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass; $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
php
public function search($query) { global $CFG; if ($result = parent::search($query)) { return $result; } $found = false; $filternames = filter_get_all_installed(); foreach ($filternames as $path => $strfiltername) { if (strpos(core_text::strtolower($strfiltername), $query) !== false) { $found = true; break; } if (strpos($path, $query) !== false) { $found = true; break; } } if ($found) { $result = new stdClass; $result->page = $this; $result->settings = array(); return array($this->name => $result); } else { return array(); } }
[ "public", "function", "search", "(", "$", "query", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "result", "=", "parent", "::", "search", "(", "$", "query", ")", ")", "{", "return", "$", "result", ";", "}", "$", "found", "=", "false", ";", "$", "filternames", "=", "filter_get_all_installed", "(", ")", ";", "foreach", "(", "$", "filternames", "as", "$", "path", "=>", "$", "strfiltername", ")", "{", "if", "(", "strpos", "(", "core_text", "::", "strtolower", "(", "$", "strfiltername", ")", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "if", "(", "strpos", "(", "$", "path", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "found", ")", "{", "$", "result", "=", "new", "stdClass", ";", "$", "result", "->", "page", "=", "$", "this", ";", "$", "result", "->", "settings", "=", "array", "(", ")", ";", "return", "array", "(", "$", "this", "->", "name", "=>", "$", "result", ")", ";", "}", "else", "{", "return", "array", "(", ")", ";", "}", "}" ]
Searches all installed filters for specified filter @param string $query The filter(string) to search for @param string $query
[ "Searches", "all", "installed", "filters", "for", "specified", "filter" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L7740-L7767
215,806
moodle/moodle
lib/adminlib.php
admin_setting_manage_plugins.output_html
public function output_html($data, $query = '') { global $CFG, $OUTPUT, $DB, $PAGE; $context = (object) [ 'manageurl' => new moodle_url($this->get_manage_url(), [ 'type' => $this->get_plugin_type(), 'sesskey' => sesskey(), ]), 'infocolumnname' => $this->get_info_column_name(), 'plugins' => [], ]; $pluginmanager = core_plugin_manager::instance(); $allplugins = $pluginmanager->get_plugins_of_type($this->get_plugin_type()); $enabled = $pluginmanager->get_enabled_plugins($this->get_plugin_type()); $plugins = array_merge($enabled, $allplugins); foreach ($plugins as $key => $plugin) { $pluginlink = new moodle_url($context->manageurl, ['plugin' => $key]); $pluginkey = (object) [ 'plugin' => $plugin->displayname, 'enabled' => $plugin->is_enabled(), 'togglelink' => '', 'moveuplink' => '', 'movedownlink' => '', 'settingslink' => $plugin->get_settings_url(), 'uninstalllink' => '', 'info' => '', ]; // Enable/Disable link. $togglelink = new moodle_url($pluginlink); if ($plugin->is_enabled()) { $toggletarget = false; $togglelink->param('action', 'disable'); if (count($context->plugins)) { // This is not the first plugin. $pluginkey->moveuplink = new moodle_url($pluginlink, ['action' => 'up']); } if (count($enabled) > count($context->plugins) + 1) { // This is not the last plugin. $pluginkey->movedownlink = new moodle_url($pluginlink, ['action' => 'down']); } $pluginkey->info = $this->get_info_column($plugin); } else { $toggletarget = true; $togglelink->param('action', 'enable'); } $pluginkey->toggletarget = $toggletarget; $pluginkey->togglelink = $togglelink; $frankenstyle = $plugin->type . '_' . $plugin->name; if ($uninstalllink = core_plugin_manager::instance()->get_uninstall_url($frankenstyle, 'manage')) { // This plugin supports uninstallation. $pluginkey->uninstalllink = $uninstalllink; } if (!empty($this->get_info_column_name())) { // This plugintype has an info column. $pluginkey->info = $this->get_info_column($plugin); } $context->plugins[] = $pluginkey; } $str = $OUTPUT->render_from_template('core_admin/setting_manage_plugins', $context); return highlight($query, $str); }
php
public function output_html($data, $query = '') { global $CFG, $OUTPUT, $DB, $PAGE; $context = (object) [ 'manageurl' => new moodle_url($this->get_manage_url(), [ 'type' => $this->get_plugin_type(), 'sesskey' => sesskey(), ]), 'infocolumnname' => $this->get_info_column_name(), 'plugins' => [], ]; $pluginmanager = core_plugin_manager::instance(); $allplugins = $pluginmanager->get_plugins_of_type($this->get_plugin_type()); $enabled = $pluginmanager->get_enabled_plugins($this->get_plugin_type()); $plugins = array_merge($enabled, $allplugins); foreach ($plugins as $key => $plugin) { $pluginlink = new moodle_url($context->manageurl, ['plugin' => $key]); $pluginkey = (object) [ 'plugin' => $plugin->displayname, 'enabled' => $plugin->is_enabled(), 'togglelink' => '', 'moveuplink' => '', 'movedownlink' => '', 'settingslink' => $plugin->get_settings_url(), 'uninstalllink' => '', 'info' => '', ]; // Enable/Disable link. $togglelink = new moodle_url($pluginlink); if ($plugin->is_enabled()) { $toggletarget = false; $togglelink->param('action', 'disable'); if (count($context->plugins)) { // This is not the first plugin. $pluginkey->moveuplink = new moodle_url($pluginlink, ['action' => 'up']); } if (count($enabled) > count($context->plugins) + 1) { // This is not the last plugin. $pluginkey->movedownlink = new moodle_url($pluginlink, ['action' => 'down']); } $pluginkey->info = $this->get_info_column($plugin); } else { $toggletarget = true; $togglelink->param('action', 'enable'); } $pluginkey->toggletarget = $toggletarget; $pluginkey->togglelink = $togglelink; $frankenstyle = $plugin->type . '_' . $plugin->name; if ($uninstalllink = core_plugin_manager::instance()->get_uninstall_url($frankenstyle, 'manage')) { // This plugin supports uninstallation. $pluginkey->uninstalllink = $uninstalllink; } if (!empty($this->get_info_column_name())) { // This plugintype has an info column. $pluginkey->info = $this->get_info_column($plugin); } $context->plugins[] = $pluginkey; } $str = $OUTPUT->render_from_template('core_admin/setting_manage_plugins', $context); return highlight($query, $str); }
[ "public", "function", "output_html", "(", "$", "data", ",", "$", "query", "=", "''", ")", "{", "global", "$", "CFG", ",", "$", "OUTPUT", ",", "$", "DB", ",", "$", "PAGE", ";", "$", "context", "=", "(", "object", ")", "[", "'manageurl'", "=>", "new", "moodle_url", "(", "$", "this", "->", "get_manage_url", "(", ")", ",", "[", "'type'", "=>", "$", "this", "->", "get_plugin_type", "(", ")", ",", "'sesskey'", "=>", "sesskey", "(", ")", ",", "]", ")", ",", "'infocolumnname'", "=>", "$", "this", "->", "get_info_column_name", "(", ")", ",", "'plugins'", "=>", "[", "]", ",", "]", ";", "$", "pluginmanager", "=", "core_plugin_manager", "::", "instance", "(", ")", ";", "$", "allplugins", "=", "$", "pluginmanager", "->", "get_plugins_of_type", "(", "$", "this", "->", "get_plugin_type", "(", ")", ")", ";", "$", "enabled", "=", "$", "pluginmanager", "->", "get_enabled_plugins", "(", "$", "this", "->", "get_plugin_type", "(", ")", ")", ";", "$", "plugins", "=", "array_merge", "(", "$", "enabled", ",", "$", "allplugins", ")", ";", "foreach", "(", "$", "plugins", "as", "$", "key", "=>", "$", "plugin", ")", "{", "$", "pluginlink", "=", "new", "moodle_url", "(", "$", "context", "->", "manageurl", ",", "[", "'plugin'", "=>", "$", "key", "]", ")", ";", "$", "pluginkey", "=", "(", "object", ")", "[", "'plugin'", "=>", "$", "plugin", "->", "displayname", ",", "'enabled'", "=>", "$", "plugin", "->", "is_enabled", "(", ")", ",", "'togglelink'", "=>", "''", ",", "'moveuplink'", "=>", "''", ",", "'movedownlink'", "=>", "''", ",", "'settingslink'", "=>", "$", "plugin", "->", "get_settings_url", "(", ")", ",", "'uninstalllink'", "=>", "''", ",", "'info'", "=>", "''", ",", "]", ";", "// Enable/Disable link.", "$", "togglelink", "=", "new", "moodle_url", "(", "$", "pluginlink", ")", ";", "if", "(", "$", "plugin", "->", "is_enabled", "(", ")", ")", "{", "$", "toggletarget", "=", "false", ";", "$", "togglelink", "->", "param", "(", "'action'", ",", "'disable'", ")", ";", "if", "(", "count", "(", "$", "context", "->", "plugins", ")", ")", "{", "// This is not the first plugin.", "$", "pluginkey", "->", "moveuplink", "=", "new", "moodle_url", "(", "$", "pluginlink", ",", "[", "'action'", "=>", "'up'", "]", ")", ";", "}", "if", "(", "count", "(", "$", "enabled", ")", ">", "count", "(", "$", "context", "->", "plugins", ")", "+", "1", ")", "{", "// This is not the last plugin.", "$", "pluginkey", "->", "movedownlink", "=", "new", "moodle_url", "(", "$", "pluginlink", ",", "[", "'action'", "=>", "'down'", "]", ")", ";", "}", "$", "pluginkey", "->", "info", "=", "$", "this", "->", "get_info_column", "(", "$", "plugin", ")", ";", "}", "else", "{", "$", "toggletarget", "=", "true", ";", "$", "togglelink", "->", "param", "(", "'action'", ",", "'enable'", ")", ";", "}", "$", "pluginkey", "->", "toggletarget", "=", "$", "toggletarget", ";", "$", "pluginkey", "->", "togglelink", "=", "$", "togglelink", ";", "$", "frankenstyle", "=", "$", "plugin", "->", "type", ".", "'_'", ".", "$", "plugin", "->", "name", ";", "if", "(", "$", "uninstalllink", "=", "core_plugin_manager", "::", "instance", "(", ")", "->", "get_uninstall_url", "(", "$", "frankenstyle", ",", "'manage'", ")", ")", "{", "// This plugin supports uninstallation.", "$", "pluginkey", "->", "uninstalllink", "=", "$", "uninstalllink", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "get_info_column_name", "(", ")", ")", ")", "{", "// This plugintype has an info column.", "$", "pluginkey", "->", "info", "=", "$", "this", "->", "get_info_column", "(", "$", "plugin", ")", ";", "}", "$", "context", "->", "plugins", "[", "]", "=", "$", "pluginkey", ";", "}", "$", "str", "=", "$", "OUTPUT", "->", "render_from_template", "(", "'core_admin/setting_manage_plugins'", ",", "$", "context", ")", ";", "return", "highlight", "(", "$", "query", ",", "$", "str", ")", ";", "}" ]
Builds the HTML to display the control. @param string $data Unused @param string $query @return string
[ "Builds", "the", "HTML", "to", "display", "the", "control", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L7897-L7968
215,807
moodle/moodle
lib/adminlib.php
admin_setting_managemediaplayers.get_sorted_plugins
protected function get_sorted_plugins() { $pluginmanager = core_plugin_manager::instance(); $plugins = $pluginmanager->get_plugins_of_type('media'); $enabledplugins = $pluginmanager->get_enabled_plugins('media'); // Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank. \core_collator::asort_objects_by_method($plugins, 'get_rank', \core_collator::SORT_NUMERIC); $order = array_values($enabledplugins); $order = array_merge($order, array_diff(array_reverse(array_keys($plugins)), $order)); $sortedplugins = array(); foreach ($order as $name) { $sortedplugins[$name] = $plugins[$name]; } return $sortedplugins; }
php
protected function get_sorted_plugins() { $pluginmanager = core_plugin_manager::instance(); $plugins = $pluginmanager->get_plugins_of_type('media'); $enabledplugins = $pluginmanager->get_enabled_plugins('media'); // Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank. \core_collator::asort_objects_by_method($plugins, 'get_rank', \core_collator::SORT_NUMERIC); $order = array_values($enabledplugins); $order = array_merge($order, array_diff(array_reverse(array_keys($plugins)), $order)); $sortedplugins = array(); foreach ($order as $name) { $sortedplugins[$name] = $plugins[$name]; } return $sortedplugins; }
[ "protected", "function", "get_sorted_plugins", "(", ")", "{", "$", "pluginmanager", "=", "core_plugin_manager", "::", "instance", "(", ")", ";", "$", "plugins", "=", "$", "pluginmanager", "->", "get_plugins_of_type", "(", "'media'", ")", ";", "$", "enabledplugins", "=", "$", "pluginmanager", "->", "get_enabled_plugins", "(", "'media'", ")", ";", "// Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank.", "\\", "core_collator", "::", "asort_objects_by_method", "(", "$", "plugins", ",", "'get_rank'", ",", "\\", "core_collator", "::", "SORT_NUMERIC", ")", ";", "$", "order", "=", "array_values", "(", "$", "enabledplugins", ")", ";", "$", "order", "=", "array_merge", "(", "$", "order", ",", "array_diff", "(", "array_reverse", "(", "array_keys", "(", "$", "plugins", ")", ")", ",", "$", "order", ")", ")", ";", "$", "sortedplugins", "=", "array", "(", ")", ";", "foreach", "(", "$", "order", "as", "$", "name", ")", "{", "$", "sortedplugins", "[", "$", "name", "]", "=", "$", "plugins", "[", "$", "name", "]", ";", "}", "return", "$", "sortedplugins", ";", "}" ]
Sort plugins so enabled plugins are displayed first and all others are displayed in the end sorted by rank. @return \core\plugininfo\media[]
[ "Sort", "plugins", "so", "enabled", "plugins", "are", "displayed", "first", "and", "all", "others", "are", "displayed", "in", "the", "end", "sorted", "by", "rank", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L8069-L8087
215,808
moodle/moodle
lib/adminlib.php
admin_setting_enablemobileservice.output_html
public function output_html($data, $query='') { global $OUTPUT; $html = parent::output_html($data, $query); if ((string)$data === $this->yes) { $notifications = tool_mobile\api::get_potential_config_issues(); // Safe to call, plugin available if we reach here. foreach ($notifications as $notification) { $message = get_string($notification[0], $notification[1]); $html .= $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING); } } return $html; }
php
public function output_html($data, $query='') { global $OUTPUT; $html = parent::output_html($data, $query); if ((string)$data === $this->yes) { $notifications = tool_mobile\api::get_potential_config_issues(); // Safe to call, plugin available if we reach here. foreach ($notifications as $notification) { $message = get_string($notification[0], $notification[1]); $html .= $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING); } } return $html; }
[ "public", "function", "output_html", "(", "$", "data", ",", "$", "query", "=", "''", ")", "{", "global", "$", "OUTPUT", ";", "$", "html", "=", "parent", "::", "output_html", "(", "$", "data", ",", "$", "query", ")", ";", "if", "(", "(", "string", ")", "$", "data", "===", "$", "this", "->", "yes", ")", "{", "$", "notifications", "=", "tool_mobile", "\\", "api", "::", "get_potential_config_issues", "(", ")", ";", "// Safe to call, plugin available if we reach here.", "foreach", "(", "$", "notifications", "as", "$", "notification", ")", "{", "$", "message", "=", "get_string", "(", "$", "notification", "[", "0", "]", ",", "$", "notification", "[", "1", "]", ")", ";", "$", "html", ".=", "$", "OUTPUT", "->", "notification", "(", "$", "message", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_WARNING", ")", ";", "}", "}", "return", "$", "html", ";", "}" ]
Builds XHTML to display the control. The main purpose of this overloading is to display a warning when https is not supported by the server @param string $data Unused @param string $query @return string XHTML
[ "Builds", "XHTML", "to", "display", "the", "control", ".", "The", "main", "purpose", "of", "this", "overloading", "is", "to", "display", "a", "warning", "when", "https", "is", "not", "supported", "by", "the", "server" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L9146-L9159
215,809
moodle/moodle
lib/adminlib.php
admin_setting_enablemobileservice.get_setting
public function get_setting() { global $CFG; // First check if is not set. $result = $this->config_read($this->name); if (is_null($result)) { return null; } // For install cli script, $CFG->defaultuserroleid is not set so return 0 // Or if web services aren't enabled this can't be, if (empty($CFG->defaultuserroleid) || empty($CFG->enablewebservices)) { return 0; } require_once($CFG->dirroot . '/webservice/lib.php'); $webservicemanager = new webservice(); $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE); if ($mobileservice->enabled and $this->is_protocol_cap_allowed()) { return $result; } else { return 0; } }
php
public function get_setting() { global $CFG; // First check if is not set. $result = $this->config_read($this->name); if (is_null($result)) { return null; } // For install cli script, $CFG->defaultuserroleid is not set so return 0 // Or if web services aren't enabled this can't be, if (empty($CFG->defaultuserroleid) || empty($CFG->enablewebservices)) { return 0; } require_once($CFG->dirroot . '/webservice/lib.php'); $webservicemanager = new webservice(); $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE); if ($mobileservice->enabled and $this->is_protocol_cap_allowed()) { return $result; } else { return 0; } }
[ "public", "function", "get_setting", "(", ")", "{", "global", "$", "CFG", ";", "// First check if is not set.", "$", "result", "=", "$", "this", "->", "config_read", "(", "$", "this", "->", "name", ")", ";", "if", "(", "is_null", "(", "$", "result", ")", ")", "{", "return", "null", ";", "}", "// For install cli script, $CFG->defaultuserroleid is not set so return 0", "// Or if web services aren't enabled this can't be,", "if", "(", "empty", "(", "$", "CFG", "->", "defaultuserroleid", ")", "||", "empty", "(", "$", "CFG", "->", "enablewebservices", ")", ")", "{", "return", "0", ";", "}", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/webservice/lib.php'", ")", ";", "$", "webservicemanager", "=", "new", "webservice", "(", ")", ";", "$", "mobileservice", "=", "$", "webservicemanager", "->", "get_external_service_by_shortname", "(", "MOODLE_OFFICIAL_MOBILE_SERVICE", ")", ";", "if", "(", "$", "mobileservice", "->", "enabled", "and", "$", "this", "->", "is_protocol_cap_allowed", "(", ")", ")", "{", "return", "$", "result", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
Retrieves the current setting using the objects name @return string
[ "Retrieves", "the", "current", "setting", "using", "the", "objects", "name" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L9166-L9189
215,810
moodle/moodle
lib/adminlib.php
admin_setting_configcolourpicker.write_setting
public function write_setting($data) { $data = $this->validate($data); if ($data === false) { return get_string('validateerror', 'admin'); } return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin')); }
php
public function write_setting($data) { $data = $this->validate($data); if ($data === false) { return get_string('validateerror', 'admin'); } return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin')); }
[ "public", "function", "write_setting", "(", "$", "data", ")", "{", "$", "data", "=", "$", "this", "->", "validate", "(", "$", "data", ")", ";", "if", "(", "$", "data", "===", "false", ")", "{", "return", "get_string", "(", "'validateerror'", ",", "'admin'", ")", ";", "}", "return", "(", "$", "this", "->", "config_write", "(", "$", "this", "->", "name", ",", "$", "data", ")", "?", "''", ":", "get_string", "(", "'errorsetting'", ",", "'admin'", ")", ")", ";", "}" ]
Saves the setting @param string $data @return bool
[ "Saves", "the", "setting" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10006-L10012
215,811
moodle/moodle
lib/adminlib.php
admin_setting_configcolourpicker.output_html
public function output_html($data, $query = '') { global $PAGE, $OUTPUT; $icon = new pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', ['class' => 'loadingicon']); $context = (object) [ 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => $data, 'icon' => $icon->export_for_template($OUTPUT), 'haspreviewconfig' => !empty($this->previewconfig), 'forceltr' => $this->get_force_ltr() ]; $element = $OUTPUT->render_from_template('core_admin/setting_configcolourpicker', $context); $PAGE->requires->js_init_call('M.util.init_colour_picker', array($this->get_id(), $this->previewconfig)); return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $this->get_defaultsetting(), $query); }
php
public function output_html($data, $query = '') { global $PAGE, $OUTPUT; $icon = new pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', ['class' => 'loadingicon']); $context = (object) [ 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => $data, 'icon' => $icon->export_for_template($OUTPUT), 'haspreviewconfig' => !empty($this->previewconfig), 'forceltr' => $this->get_force_ltr() ]; $element = $OUTPUT->render_from_template('core_admin/setting_configcolourpicker', $context); $PAGE->requires->js_init_call('M.util.init_colour_picker', array($this->get_id(), $this->previewconfig)); return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $this->get_defaultsetting(), $query); }
[ "public", "function", "output_html", "(", "$", "data", ",", "$", "query", "=", "''", ")", "{", "global", "$", "PAGE", ",", "$", "OUTPUT", ";", "$", "icon", "=", "new", "pix_icon", "(", "'i/loading'", ",", "get_string", "(", "'loading'", ",", "'admin'", ")", ",", "'moodle'", ",", "[", "'class'", "=>", "'loadingicon'", "]", ")", ";", "$", "context", "=", "(", "object", ")", "[", "'id'", "=>", "$", "this", "->", "get_id", "(", ")", ",", "'name'", "=>", "$", "this", "->", "get_full_name", "(", ")", ",", "'value'", "=>", "$", "data", ",", "'icon'", "=>", "$", "icon", "->", "export_for_template", "(", "$", "OUTPUT", ")", ",", "'haspreviewconfig'", "=>", "!", "empty", "(", "$", "this", "->", "previewconfig", ")", ",", "'forceltr'", "=>", "$", "this", "->", "get_force_ltr", "(", ")", "]", ";", "$", "element", "=", "$", "OUTPUT", "->", "render_from_template", "(", "'core_admin/setting_configcolourpicker'", ",", "$", "context", ")", ";", "$", "PAGE", "->", "requires", "->", "js_init_call", "(", "'M.util.init_colour_picker'", ",", "array", "(", "$", "this", "->", "get_id", "(", ")", ",", "$", "this", "->", "previewconfig", ")", ")", ";", "return", "format_admin_setting", "(", "$", "this", ",", "$", "this", "->", "visiblename", ",", "$", "element", ",", "$", "this", "->", "description", ",", "true", ",", "''", ",", "$", "this", "->", "get_defaultsetting", "(", ")", ",", "$", "query", ")", ";", "}" ]
Generates the HTML for the setting @global moodle_page $PAGE @global core_renderer $OUTPUT @param string $data @param string $query
[ "Generates", "the", "HTML", "for", "the", "setting" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10096-L10114
215,812
moodle/moodle
lib/adminlib.php
admin_setting_configstoredfile.get_options
protected function get_options() { global $CFG; require_once("$CFG->libdir/filelib.php"); require_once("$CFG->dirroot/repository/lib.php"); $defaults = array( 'mainfile' => '', 'subdirs' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'areamaxbytes' => FILE_AREA_MAX_BYTES_UNLIMITED, 'context' => context_system::instance()); foreach($this->options as $k => $v) { $defaults[$k] = $v; } return $defaults; }
php
protected function get_options() { global $CFG; require_once("$CFG->libdir/filelib.php"); require_once("$CFG->dirroot/repository/lib.php"); $defaults = array( 'mainfile' => '', 'subdirs' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'areamaxbytes' => FILE_AREA_MAX_BYTES_UNLIMITED, 'context' => context_system::instance()); foreach($this->options as $k => $v) { $defaults[$k] = $v; } return $defaults; }
[ "protected", "function", "get_options", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "\"$CFG->libdir/filelib.php\"", ")", ";", "require_once", "(", "\"$CFG->dirroot/repository/lib.php\"", ")", ";", "$", "defaults", "=", "array", "(", "'mainfile'", "=>", "''", ",", "'subdirs'", "=>", "0", ",", "'maxbytes'", "=>", "-", "1", ",", "'maxfiles'", "=>", "1", ",", "'accepted_types'", "=>", "'*'", ",", "'return_types'", "=>", "FILE_INTERNAL", ",", "'areamaxbytes'", "=>", "FILE_AREA_MAX_BYTES_UNLIMITED", ",", "'context'", "=>", "context_system", "::", "instance", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "defaults", "[", "$", "k", "]", "=", "$", "v", ";", "}", "return", "$", "defaults", ";", "}" ]
Applies defaults and returns all options. @return array
[ "Applies", "defaults", "and", "returns", "all", "options", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10160-L10174
215,813
moodle/moodle
lib/adminlib.php
admin_setting_devicedetectregex.prepare_form_data
protected function prepare_form_data($regexes) { $regexes = json_decode($regexes); $form = array(); $i = 0; foreach ($regexes as $value => $regex) { $expressionname = 'expression'.$i; $valuename = 'value'.$i; $form[$expressionname] = $regex; $form[$valuename] = $value; $i++; } return $form; }
php
protected function prepare_form_data($regexes) { $regexes = json_decode($regexes); $form = array(); $i = 0; foreach ($regexes as $value => $regex) { $expressionname = 'expression'.$i; $valuename = 'value'.$i; $form[$expressionname] = $regex; $form[$valuename] = $value; $i++; } return $form; }
[ "protected", "function", "prepare_form_data", "(", "$", "regexes", ")", "{", "$", "regexes", "=", "json_decode", "(", "$", "regexes", ")", ";", "$", "form", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "regexes", "as", "$", "value", "=>", "$", "regex", ")", "{", "$", "expressionname", "=", "'expression'", ".", "$", "i", ";", "$", "valuename", "=", "'value'", ".", "$", "i", ";", "$", "form", "[", "$", "expressionname", "]", "=", "$", "regex", ";", "$", "form", "[", "$", "valuename", "]", "=", "$", "value", ";", "$", "i", "++", ";", "}", "return", "$", "form", ";", "}" ]
Converts the string of regexes @see self::process_form_data() @param $regexes string of regexes @return array of form fields and their values
[ "Converts", "the", "string", "of", "regexes" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10408-L10426
215,814
moodle/moodle
lib/adminlib.php
admin_setting_devicedetectregex.process_form_data
protected function process_form_data(array $form) { $count = count($form); // number of form field values if ($count % 2) { // we must get five fields per expression return false; } $regexes = array(); for ($i = 0; $i < $count / 2; $i++) { $expressionname = "expression".$i; $valuename = "value".$i; $expression = trim($form['expression'.$i]); $value = trim($form['value'.$i]); if (empty($expression)){ continue; } $regexes[$value] = $expression; } $regexes = json_encode($regexes); return $regexes; }
php
protected function process_form_data(array $form) { $count = count($form); // number of form field values if ($count % 2) { // we must get five fields per expression return false; } $regexes = array(); for ($i = 0; $i < $count / 2; $i++) { $expressionname = "expression".$i; $valuename = "value".$i; $expression = trim($form['expression'.$i]); $value = trim($form['value'.$i]); if (empty($expression)){ continue; } $regexes[$value] = $expression; } $regexes = json_encode($regexes); return $regexes; }
[ "protected", "function", "process_form_data", "(", "array", "$", "form", ")", "{", "$", "count", "=", "count", "(", "$", "form", ")", ";", "// number of form field values", "if", "(", "$", "count", "%", "2", ")", "{", "// we must get five fields per expression", "return", "false", ";", "}", "$", "regexes", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", "/", "2", ";", "$", "i", "++", ")", "{", "$", "expressionname", "=", "\"expression\"", ".", "$", "i", ";", "$", "valuename", "=", "\"value\"", ".", "$", "i", ";", "$", "expression", "=", "trim", "(", "$", "form", "[", "'expression'", ".", "$", "i", "]", ")", ";", "$", "value", "=", "trim", "(", "$", "form", "[", "'value'", ".", "$", "i", "]", ")", ";", "if", "(", "empty", "(", "$", "expression", ")", ")", "{", "continue", ";", "}", "$", "regexes", "[", "$", "value", "]", "=", "$", "expression", ";", "}", "$", "regexes", "=", "json_encode", "(", "$", "regexes", ")", ";", "return", "$", "regexes", ";", "}" ]
Converts the data from admin settings form into a string of regexes @see self::prepare_form_data() @param array $data array of admin form fields and values @return false|string of regexes
[ "Converts", "the", "data", "from", "admin", "settings", "form", "into", "a", "string", "of", "regexes" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10435-L10462
215,815
moodle/moodle
lib/adminlib.php
admin_setting_configmultiselect_modules.load_choices
public function load_choices() { if (is_array($this->choices)) { return true; } $this->choices = array(); global $CFG, $DB; $records = $DB->get_records('modules', array('visible'=>1), 'name'); foreach ($records as $record) { // Exclude modules if the code doesn't exist if (file_exists("$CFG->dirroot/mod/$record->name/lib.php")) { // Also exclude system modules (if specified) if (!($this->excludesystem && plugin_supports('mod', $record->name, FEATURE_MOD_ARCHETYPE) === MOD_ARCHETYPE_SYSTEM)) { $this->choices[$record->id] = $record->name; } } } return true; }
php
public function load_choices() { if (is_array($this->choices)) { return true; } $this->choices = array(); global $CFG, $DB; $records = $DB->get_records('modules', array('visible'=>1), 'name'); foreach ($records as $record) { // Exclude modules if the code doesn't exist if (file_exists("$CFG->dirroot/mod/$record->name/lib.php")) { // Also exclude system modules (if specified) if (!($this->excludesystem && plugin_supports('mod', $record->name, FEATURE_MOD_ARCHETYPE) === MOD_ARCHETYPE_SYSTEM)) { $this->choices[$record->id] = $record->name; } } } return true; }
[ "public", "function", "load_choices", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "choices", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "choices", "=", "array", "(", ")", ";", "global", "$", "CFG", ",", "$", "DB", ";", "$", "records", "=", "$", "DB", "->", "get_records", "(", "'modules'", ",", "array", "(", "'visible'", "=>", "1", ")", ",", "'name'", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "// Exclude modules if the code doesn't exist", "if", "(", "file_exists", "(", "\"$CFG->dirroot/mod/$record->name/lib.php\"", ")", ")", "{", "// Also exclude system modules (if specified)", "if", "(", "!", "(", "$", "this", "->", "excludesystem", "&&", "plugin_supports", "(", "'mod'", ",", "$", "record", "->", "name", ",", "FEATURE_MOD_ARCHETYPE", ")", "===", "MOD_ARCHETYPE_SYSTEM", ")", ")", "{", "$", "this", "->", "choices", "[", "$", "record", "->", "id", "]", "=", "$", "record", "->", "name", ";", "}", "}", "}", "return", "true", ";", "}" ]
Loads an array of current module choices @return bool always return true
[ "Loads", "an", "array", "of", "current", "module", "choices" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10494-L10514
215,816
moodle/moodle
lib/adminlib.php
admin_setting_php_extension_enabled.output_html
public function output_html($data, $query='') { global $OUTPUT; $o = ''; if (!extension_loaded($this->extension)) { $warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description; $o .= format_admin_setting($this, $this->visiblename, $warning); } return $o; }
php
public function output_html($data, $query='') { global $OUTPUT; $o = ''; if (!extension_loaded($this->extension)) { $warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description; $o .= format_admin_setting($this, $this->visiblename, $warning); } return $o; }
[ "public", "function", "output_html", "(", "$", "data", ",", "$", "query", "=", "''", ")", "{", "global", "$", "OUTPUT", ";", "$", "o", "=", "''", ";", "if", "(", "!", "extension_loaded", "(", "$", "this", "->", "extension", ")", ")", "{", "$", "warning", "=", "$", "OUTPUT", "->", "pix_icon", "(", "'i/warning'", ",", "''", ",", "''", ",", "array", "(", "'role'", "=>", "'presentation'", ")", ")", ".", "' '", ".", "$", "this", "->", "description", ";", "$", "o", ".=", "format_admin_setting", "(", "$", "this", ",", "$", "this", "->", "visiblename", ",", "$", "warning", ")", ";", "}", "return", "$", "o", ";", "}" ]
Outputs the html for this setting. @return string Returns an XHTML string
[ "Outputs", "the", "html", "for", "this", "setting", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10569-L10579
215,817
moodle/moodle
lib/adminlib.php
admin_setting_scsscode.validate
public function validate($data) { if (empty($data)) { return true; } $scss = new core_scss(); try { $scss->compile($data); } catch (Leafo\ScssPhp\Exception\ParserException $e) { return get_string('scssinvalid', 'admin', $e->getMessage()); } catch (Leafo\ScssPhp\Exception\CompilerException $e) { // Silently ignore this - it could be a scss variable defined from somewhere // else which we are not examining here. return true; } return true; }
php
public function validate($data) { if (empty($data)) { return true; } $scss = new core_scss(); try { $scss->compile($data); } catch (Leafo\ScssPhp\Exception\ParserException $e) { return get_string('scssinvalid', 'admin', $e->getMessage()); } catch (Leafo\ScssPhp\Exception\CompilerException $e) { // Silently ignore this - it could be a scss variable defined from somewhere // else which we are not examining here. return true; } return true; }
[ "public", "function", "validate", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "true", ";", "}", "$", "scss", "=", "new", "core_scss", "(", ")", ";", "try", "{", "$", "scss", "->", "compile", "(", "$", "data", ")", ";", "}", "catch", "(", "Leafo", "\\", "ScssPhp", "\\", "Exception", "\\", "ParserException", "$", "e", ")", "{", "return", "get_string", "(", "'scssinvalid'", ",", "'admin'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "Leafo", "\\", "ScssPhp", "\\", "Exception", "\\", "CompilerException", "$", "e", ")", "{", "// Silently ignore this - it could be a scss variable defined from somewhere", "// else which we are not examining here.", "return", "true", ";", "}", "return", "true", ";", "}" ]
Validate the contents of the SCSS to ensure its parsable. Does not attempt to detect undefined scss variables. @param string $data The scss code from text field. @return mixed bool true for success or string:error on failure.
[ "Validate", "the", "contents", "of", "the", "SCSS", "to", "ensure", "its", "parsable", ".", "Does", "not", "attempt", "to", "detect", "undefined", "scss", "variables", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10847-L10864
215,818
moodle/moodle
lib/adminlib.php
admin_setting_filetypes.output_html
public function output_html($data, $query='') { global $OUTPUT, $PAGE; $default = $this->get_defaultsetting(); $context = (object) [ 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => $data, 'descriptions' => $this->util->describe_file_types($data), ]; $element = $OUTPUT->render_from_template('core_admin/setting_filetypes', $context); $PAGE->requires->js_call_amd('core_form/filetypes', 'init', [ $this->get_id(), $this->visiblename->out(), $this->onlytypes, $this->allowall, ]); return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $default, $query); }
php
public function output_html($data, $query='') { global $OUTPUT, $PAGE; $default = $this->get_defaultsetting(); $context = (object) [ 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => $data, 'descriptions' => $this->util->describe_file_types($data), ]; $element = $OUTPUT->render_from_template('core_admin/setting_filetypes', $context); $PAGE->requires->js_call_amd('core_form/filetypes', 'init', [ $this->get_id(), $this->visiblename->out(), $this->onlytypes, $this->allowall, ]); return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $default, $query); }
[ "public", "function", "output_html", "(", "$", "data", ",", "$", "query", "=", "''", ")", "{", "global", "$", "OUTPUT", ",", "$", "PAGE", ";", "$", "default", "=", "$", "this", "->", "get_defaultsetting", "(", ")", ";", "$", "context", "=", "(", "object", ")", "[", "'id'", "=>", "$", "this", "->", "get_id", "(", ")", ",", "'name'", "=>", "$", "this", "->", "get_full_name", "(", ")", ",", "'value'", "=>", "$", "data", ",", "'descriptions'", "=>", "$", "this", "->", "util", "->", "describe_file_types", "(", "$", "data", ")", ",", "]", ";", "$", "element", "=", "$", "OUTPUT", "->", "render_from_template", "(", "'core_admin/setting_filetypes'", ",", "$", "context", ")", ";", "$", "PAGE", "->", "requires", "->", "js_call_amd", "(", "'core_form/filetypes'", ",", "'init'", ",", "[", "$", "this", "->", "get_id", "(", ")", ",", "$", "this", "->", "visiblename", "->", "out", "(", ")", ",", "$", "this", "->", "onlytypes", ",", "$", "this", "->", "allowall", ",", "]", ")", ";", "return", "format_admin_setting", "(", "$", "this", ",", "$", "this", "->", "visiblename", ",", "$", "element", ",", "$", "this", "->", "description", ",", "true", ",", "''", ",", "$", "default", ",", "$", "query", ")", ";", "}" ]
Return an HTML string for the setting element. @param string $data The current setting value @param string $query Admin search query to be highlighted @return string HTML to be displayed
[ "Return", "an", "HTML", "string", "for", "the", "setting", "element", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L10951-L10971
215,819
moodle/moodle
lib/adminlib.php
admin_setting_agedigitalconsentmap.validate
public function validate($data) { if (empty($data)) { return true; } try { \core_auth\digital_consent::parse_age_digital_consent_map($data); } catch (\moodle_exception $e) { return get_string('invalidagedigitalconsent', 'admin', $e->getMessage()); } return true; }
php
public function validate($data) { if (empty($data)) { return true; } try { \core_auth\digital_consent::parse_age_digital_consent_map($data); } catch (\moodle_exception $e) { return get_string('invalidagedigitalconsent', 'admin', $e->getMessage()); } return true; }
[ "public", "function", "validate", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "true", ";", "}", "try", "{", "\\", "core_auth", "\\", "digital_consent", "::", "parse_age_digital_consent_map", "(", "$", "data", ")", ";", "}", "catch", "(", "\\", "moodle_exception", "$", "e", ")", "{", "return", "get_string", "(", "'invalidagedigitalconsent'", ",", "'admin'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "true", ";", "}" ]
Validate the content and format of the age of digital consent map to ensure it is parsable. @param string $data The age of digital consent map from text field. @return mixed bool true for success or string:error on failure.
[ "Validate", "the", "content", "and", "format", "of", "the", "age", "of", "digital", "consent", "map", "to", "ensure", "it", "is", "parsable", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adminlib.php#L11017-L11029
215,820
moodle/moodle
lib/adodb/drivers/adodb-pdo_mysql.inc.php
ADODB_pdo_mysql.OffsetDate
function OffsetDate($dayFraction, $date=false) { if (!$date) { $date = $this->sysDate; } $fraction = $dayFraction * 24 * 3600; return $date . ' + INTERVAL ' . $fraction . ' SECOND'; // return "from_unixtime(unix_timestamp($date)+$fraction)"; }
php
function OffsetDate($dayFraction, $date=false) { if (!$date) { $date = $this->sysDate; } $fraction = $dayFraction * 24 * 3600; return $date . ' + INTERVAL ' . $fraction . ' SECOND'; // return "from_unixtime(unix_timestamp($date)+$fraction)"; }
[ "function", "OffsetDate", "(", "$", "dayFraction", ",", "$", "date", "=", "false", ")", "{", "if", "(", "!", "$", "date", ")", "{", "$", "date", "=", "$", "this", "->", "sysDate", ";", "}", "$", "fraction", "=", "$", "dayFraction", "*", "24", "*", "3600", ";", "return", "$", "date", ".", "' + INTERVAL '", ".", "$", "fraction", ".", "' SECOND'", ";", "//\t\treturn \"from_unixtime(unix_timestamp($date)+$fraction)\";", "}" ]
dayFraction is a day in floating point
[ "dayFraction", "is", "a", "day", "in", "floating", "point" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-pdo_mysql.inc.php#L38-L47
215,821
moodle/moodle
lib/adodb/drivers/adodb-pdo_mysql.inc.php
ADODB_pdo_mysql.SelectLimit
function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs=0) { $offsetStr =($offset>=0) ? "$offset," : ''; // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 if ($nrows < 0) { $nrows = '18446744073709551615'; } if ($secs) { $rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows", $inputarr); } else { $rs = $this->Execute($sql . " LIMIT $offsetStr$nrows", $inputarr); } return $rs; }
php
function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs=0) { $offsetStr =($offset>=0) ? "$offset," : ''; // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 if ($nrows < 0) { $nrows = '18446744073709551615'; } if ($secs) { $rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows", $inputarr); } else { $rs = $this->Execute($sql . " LIMIT $offsetStr$nrows", $inputarr); } return $rs; }
[ "function", "SelectLimit", "(", "$", "sql", ",", "$", "nrows", "=", "-", "1", ",", "$", "offset", "=", "-", "1", ",", "$", "inputarr", "=", "false", ",", "$", "secs", "=", "0", ")", "{", "$", "offsetStr", "=", "(", "$", "offset", ">=", "0", ")", "?", "\"$offset,\"", ":", "''", ";", "// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220", "if", "(", "$", "nrows", "<", "0", ")", "{", "$", "nrows", "=", "'18446744073709551615'", ";", "}", "if", "(", "$", "secs", ")", "{", "$", "rs", "=", "$", "this", "->", "CacheExecute", "(", "$", "secs", ",", "$", "sql", ".", "\" LIMIT $offsetStr$nrows\"", ",", "$", "inputarr", ")", ";", "}", "else", "{", "$", "rs", "=", "$", "this", "->", "Execute", "(", "$", "sql", ".", "\" LIMIT $offsetStr$nrows\"", ",", "$", "inputarr", ")", ";", "}", "return", "$", "rs", ";", "}" ]
parameters use PostgreSQL convention, not MySQL
[ "parameters", "use", "PostgreSQL", "convention", "not", "MySQL" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-pdo_mysql.inc.php#L193-L207
215,822
moodle/moodle
lib/adodb/drivers/adodb-sqlitepo.inc.php
ADORecordset_sqlitepo._fetch
function _fetch($ignore_fields=false) { $this->fields = array(); $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); if(is_array($fields)) foreach($fields as $n => $v) { if(($p = strpos($n, ".")) !== false) $n = substr($n, $p+1); $this->fields[$n] = $v; } return !empty($this->fields); }
php
function _fetch($ignore_fields=false) { $this->fields = array(); $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); if(is_array($fields)) foreach($fields as $n => $v) { if(($p = strpos($n, ".")) !== false) $n = substr($n, $p+1); $this->fields[$n] = $v; } return !empty($this->fields); }
[ "function", "_fetch", "(", "$", "ignore_fields", "=", "false", ")", "{", "$", "this", "->", "fields", "=", "array", "(", ")", ";", "$", "fields", "=", "@", "sqlite_fetch_array", "(", "$", "this", "->", "_queryID", ",", "$", "this", "->", "fetchMode", ")", ";", "if", "(", "is_array", "(", "$", "fields", ")", ")", "foreach", "(", "$", "fields", "as", "$", "n", "=>", "$", "v", ")", "{", "if", "(", "(", "$", "p", "=", "strpos", "(", "$", "n", ",", "\".\"", ")", ")", "!==", "false", ")", "$", "n", "=", "substr", "(", "$", "n", ",", "$", "p", "+", "1", ")", ";", "$", "this", "->", "fields", "[", "$", "n", "]", "=", "$", "v", ";", "}", "return", "!", "empty", "(", "$", "this", "->", "fields", ")", ";", "}" ]
Modified to strip table names from returned fields
[ "Modified", "to", "strip", "table", "names", "from", "returned", "fields" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-sqlitepo.inc.php#L44-L57
215,823
moodle/moodle
lib/navigationlib.php
navigation_node.check_if_active
public function check_if_active($strength=URL_MATCH_EXACT) { global $FULLME, $PAGE; // Set fullmeurl if it hasn't already been set if (self::$fullmeurl == null) { if ($PAGE->has_set_url()) { self::override_active_url(new moodle_url($PAGE->url)); } else { self::override_active_url(new moodle_url($FULLME)); } } // Compare the action of this node against the fullmeurl if ($this->action instanceof moodle_url && $this->action->compare(self::$fullmeurl, $strength)) { $this->make_active(); return true; } return false; }
php
public function check_if_active($strength=URL_MATCH_EXACT) { global $FULLME, $PAGE; // Set fullmeurl if it hasn't already been set if (self::$fullmeurl == null) { if ($PAGE->has_set_url()) { self::override_active_url(new moodle_url($PAGE->url)); } else { self::override_active_url(new moodle_url($FULLME)); } } // Compare the action of this node against the fullmeurl if ($this->action instanceof moodle_url && $this->action->compare(self::$fullmeurl, $strength)) { $this->make_active(); return true; } return false; }
[ "public", "function", "check_if_active", "(", "$", "strength", "=", "URL_MATCH_EXACT", ")", "{", "global", "$", "FULLME", ",", "$", "PAGE", ";", "// Set fullmeurl if it hasn't already been set", "if", "(", "self", "::", "$", "fullmeurl", "==", "null", ")", "{", "if", "(", "$", "PAGE", "->", "has_set_url", "(", ")", ")", "{", "self", "::", "override_active_url", "(", "new", "moodle_url", "(", "$", "PAGE", "->", "url", ")", ")", ";", "}", "else", "{", "self", "::", "override_active_url", "(", "new", "moodle_url", "(", "$", "FULLME", ")", ")", ";", "}", "}", "// Compare the action of this node against the fullmeurl", "if", "(", "$", "this", "->", "action", "instanceof", "moodle_url", "&&", "$", "this", "->", "action", "->", "compare", "(", "self", "::", "$", "fullmeurl", ",", "$", "strength", ")", ")", "{", "$", "this", "->", "make_active", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if this node is the active node. This is determined by comparing the action for the node against the defined URL for the page. A match will see this node marked as active. @param int $strength One of URL_MATCH_EXACT, URL_MATCH_PARAMS, or URL_MATCH_BASE @return bool
[ "Checks", "if", "this", "node", "is", "the", "active", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L226-L243
215,824
moodle/moodle
lib/navigationlib.php
navigation_node.has_siblings
public function has_siblings() { if (empty($this->parent) || empty($this->parent->children)) { return false; } if ($this->parent->children instanceof navigation_node_collection) { $count = $this->parent->children->count(); } else { $count = count($this->parent->children); } return ($count > 1); }
php
public function has_siblings() { if (empty($this->parent) || empty($this->parent->children)) { return false; } if ($this->parent->children instanceof navigation_node_collection) { $count = $this->parent->children->count(); } else { $count = count($this->parent->children); } return ($count > 1); }
[ "public", "function", "has_siblings", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "parent", ")", "||", "empty", "(", "$", "this", "->", "parent", "->", "children", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "parent", "->", "children", "instanceof", "navigation_node_collection", ")", "{", "$", "count", "=", "$", "this", "->", "parent", "->", "children", "->", "count", "(", ")", ";", "}", "else", "{", "$", "count", "=", "count", "(", "$", "this", "->", "parent", "->", "children", ")", ";", "}", "return", "(", "$", "count", ">", "1", ")", ";", "}" ]
True if this nav node has siblings in the tree. @return bool
[ "True", "if", "this", "nav", "node", "has", "siblings", "in", "the", "tree", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L250-L260
215,825
moodle/moodle
lib/navigationlib.php
navigation_node.get_siblings
public function get_siblings() { // Returns a list of the siblings of the current node for display in a flat navigation element. Either // the in-page links or the breadcrumb links. $siblings = false; if ($this->has_siblings()) { $siblings = []; foreach ($this->parent->children as $child) { if ($child->display) { $siblings[] = $child; } } } return $siblings; }
php
public function get_siblings() { // Returns a list of the siblings of the current node for display in a flat navigation element. Either // the in-page links or the breadcrumb links. $siblings = false; if ($this->has_siblings()) { $siblings = []; foreach ($this->parent->children as $child) { if ($child->display) { $siblings[] = $child; } } } return $siblings; }
[ "public", "function", "get_siblings", "(", ")", "{", "// Returns a list of the siblings of the current node for display in a flat navigation element. Either", "// the in-page links or the breadcrumb links.", "$", "siblings", "=", "false", ";", "if", "(", "$", "this", "->", "has_siblings", "(", ")", ")", "{", "$", "siblings", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "parent", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "display", ")", "{", "$", "siblings", "[", "]", "=", "$", "child", ";", "}", "}", "}", "return", "$", "siblings", ";", "}" ]
Get a list of sibling navigation nodes at the same level as this one. @return bool|array of navigation_node
[ "Get", "a", "list", "of", "sibling", "navigation", "nodes", "at", "the", "same", "level", "as", "this", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L267-L281
215,826
moodle/moodle
lib/navigationlib.php
navigation_node.override_active_url
public static function override_active_url(moodle_url $url, $loadadmintree = false) { // Clone the URL, in case the calling script changes their URL later. self::$fullmeurl = new moodle_url($url); // True means we do not want AJAX loaded admin tree, required for all admin pages. if ($loadadmintree) { // Do not change back to false if already set. self::$loadadmintree = true; } }
php
public static function override_active_url(moodle_url $url, $loadadmintree = false) { // Clone the URL, in case the calling script changes their URL later. self::$fullmeurl = new moodle_url($url); // True means we do not want AJAX loaded admin tree, required for all admin pages. if ($loadadmintree) { // Do not change back to false if already set. self::$loadadmintree = true; } }
[ "public", "static", "function", "override_active_url", "(", "moodle_url", "$", "url", ",", "$", "loadadmintree", "=", "false", ")", "{", "// Clone the URL, in case the calling script changes their URL later.", "self", "::", "$", "fullmeurl", "=", "new", "moodle_url", "(", "$", "url", ")", ";", "// True means we do not want AJAX loaded admin tree, required for all admin pages.", "if", "(", "$", "loadadmintree", ")", "{", "// Do not change back to false if already set.", "self", "::", "$", "loadadmintree", "=", "true", ";", "}", "}" ]
This sets the URL that the URL of new nodes get compared to when locating the active node. The active node is the node that matches the URL set here. By default this is either $PAGE->url or if that hasn't been set $FULLME. @param moodle_url $url The url to use for the fullmeurl. @param bool $loadadmintree use true if the URL point to administration tree
[ "This", "sets", "the", "URL", "that", "the", "URL", "of", "new", "nodes", "get", "compared", "to", "when", "locating", "the", "active", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L293-L301
215,827
moodle/moodle
lib/navigationlib.php
navigation_node.add
public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) { // Create child node $childnode = self::create($text, $action, $type, $shorttext, $key, $icon); // Add the child to end and return return $this->add_node($childnode); }
php
public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) { // Create child node $childnode = self::create($text, $action, $type, $shorttext, $key, $icon); // Add the child to end and return return $this->add_node($childnode); }
[ "public", "function", "add", "(", "$", "text", ",", "$", "action", "=", "null", ",", "$", "type", "=", "self", "::", "TYPE_CUSTOM", ",", "$", "shorttext", "=", "null", ",", "$", "key", "=", "null", ",", "pix_icon", "$", "icon", "=", "null", ")", "{", "// Create child node", "$", "childnode", "=", "self", "::", "create", "(", "$", "text", ",", "$", "action", ",", "$", "type", ",", "$", "shorttext", ",", "$", "key", ",", "$", "icon", ")", ";", "// Add the child to end and return", "return", "$", "this", "->", "add_node", "(", "$", "childnode", ")", ";", "}" ]
Adds a navigation node as a child of this node. @param string $text @param moodle_url|action_link $action @param int $type @param string $shorttext @param string|int $key @param pix_icon $icon @return navigation_node
[ "Adds", "a", "navigation", "node", "as", "a", "child", "of", "this", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L359-L365
215,828
moodle/moodle
lib/navigationlib.php
navigation_node.build_flat_navigation_list
public function build_flat_navigation_list(flat_navigation $nodes, $showdivider = false, $label = '') { if ($this->showinflatnavigation) { $indent = 0; if ($this->type == self::TYPE_COURSE || $this->key === self::COURSE_INDEX_PAGE) { $indent = 1; } $flat = new flat_navigation_node($this, $indent); $flat->set_showdivider($showdivider, $label); $nodes->add($flat); } foreach ($this->children as $child) { $child->build_flat_navigation_list($nodes, false); } }
php
public function build_flat_navigation_list(flat_navigation $nodes, $showdivider = false, $label = '') { if ($this->showinflatnavigation) { $indent = 0; if ($this->type == self::TYPE_COURSE || $this->key === self::COURSE_INDEX_PAGE) { $indent = 1; } $flat = new flat_navigation_node($this, $indent); $flat->set_showdivider($showdivider, $label); $nodes->add($flat); } foreach ($this->children as $child) { $child->build_flat_navigation_list($nodes, false); } }
[ "public", "function", "build_flat_navigation_list", "(", "flat_navigation", "$", "nodes", ",", "$", "showdivider", "=", "false", ",", "$", "label", "=", "''", ")", "{", "if", "(", "$", "this", "->", "showinflatnavigation", ")", "{", "$", "indent", "=", "0", ";", "if", "(", "$", "this", "->", "type", "==", "self", "::", "TYPE_COURSE", "||", "$", "this", "->", "key", "===", "self", "::", "COURSE_INDEX_PAGE", ")", "{", "$", "indent", "=", "1", ";", "}", "$", "flat", "=", "new", "flat_navigation_node", "(", "$", "this", ",", "$", "indent", ")", ";", "$", "flat", "->", "set_showdivider", "(", "$", "showdivider", ",", "$", "label", ")", ";", "$", "nodes", "->", "add", "(", "$", "flat", ")", ";", "}", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "child", "->", "build_flat_navigation_list", "(", "$", "nodes", ",", "false", ")", ";", "}", "}" ]
Walk the tree building up a list of all the flat navigation nodes. @param flat_navigation $nodes List of the found flat navigation nodes. @param boolean $showdivider Show a divider before the first node. @param string $label A label for the collection of navigation links.
[ "Walk", "the", "tree", "building", "up", "a", "list", "of", "all", "the", "flat", "navigation", "nodes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L435-L448
215,829
moodle/moodle
lib/navigationlib.php
navigation_node.has_children
public function has_children() { return ($this->nodetype === navigation_node::NODETYPE_BRANCH || $this->children->count()>0 || $this->isexpandable); }
php
public function has_children() { return ($this->nodetype === navigation_node::NODETYPE_BRANCH || $this->children->count()>0 || $this->isexpandable); }
[ "public", "function", "has_children", "(", ")", "{", "return", "(", "$", "this", "->", "nodetype", "===", "navigation_node", "::", "NODETYPE_BRANCH", "||", "$", "this", "->", "children", "->", "count", "(", ")", ">", "0", "||", "$", "this", "->", "isexpandable", ")", ";", "}" ]
Checks if this node has or could have any children @return bool Returns true if it has children or could have (by AJAX expansion)
[ "Checks", "if", "this", "node", "has", "or", "could", "have", "any", "children" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L478-L480
215,830
moodle/moodle
lib/navigationlib.php
navigation_node.make_active
public function make_active() { $this->isactive = true; $this->add_class('active_tree_node'); $this->force_open(); if ($this->parent !== null) { $this->parent->make_inactive(); } }
php
public function make_active() { $this->isactive = true; $this->add_class('active_tree_node'); $this->force_open(); if ($this->parent !== null) { $this->parent->make_inactive(); } }
[ "public", "function", "make_active", "(", ")", "{", "$", "this", "->", "isactive", "=", "true", ";", "$", "this", "->", "add_class", "(", "'active_tree_node'", ")", ";", "$", "this", "->", "force_open", "(", ")", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->", "make_inactive", "(", ")", ";", "}", "}" ]
Marks this node as active and forces it open. Important: If you are here because you need to mark a node active to get the navigation to do what you want have you looked at {@link navigation_node::override_active_url()}? You can use it to specify a different URL to match the active navigation node on rather than having to locate and manually mark a node active.
[ "Marks", "this", "node", "as", "active", "and", "forces", "it", "open", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L490-L497
215,831
moodle/moodle
lib/navigationlib.php
navigation_node.make_inactive
public function make_inactive() { $this->isactive = false; $this->remove_class('active_tree_node'); if ($this->parent !== null) { $this->parent->make_inactive(); } }
php
public function make_inactive() { $this->isactive = false; $this->remove_class('active_tree_node'); if ($this->parent !== null) { $this->parent->make_inactive(); } }
[ "public", "function", "make_inactive", "(", ")", "{", "$", "this", "->", "isactive", "=", "false", ";", "$", "this", "->", "remove_class", "(", "'active_tree_node'", ")", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->", "make_inactive", "(", ")", ";", "}", "}" ]
Marks a node as inactive and recusised back to the base of the tree doing the same to all parents.
[ "Marks", "a", "node", "as", "inactive", "and", "recusised", "back", "to", "the", "base", "of", "the", "tree", "doing", "the", "same", "to", "all", "parents", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L503-L509
215,832
moodle/moodle
lib/navigationlib.php
navigation_node.force_open
public function force_open() { $this->forceopen = true; if ($this->parent !== null) { $this->parent->force_open(); } }
php
public function force_open() { $this->forceopen = true; if ($this->parent !== null) { $this->parent->force_open(); } }
[ "public", "function", "force_open", "(", ")", "{", "$", "this", "->", "forceopen", "=", "true", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "$", "this", "->", "parent", "->", "force_open", "(", ")", ";", "}", "}" ]
Forces this node to be open and at the same time forces open all parents until the root node. Recursive.
[ "Forces", "this", "node", "to", "be", "open", "and", "at", "the", "same", "time", "forces", "open", "all", "parents", "until", "the", "root", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L517-L522
215,833
moodle/moodle
lib/navigationlib.php
navigation_node.remove_class
public function remove_class($class) { if (in_array($class, $this->classes)) { $key = array_search($class,$this->classes); if ($key!==false) { unset($this->classes[$key]); return true; } } return false; }
php
public function remove_class($class) { if (in_array($class, $this->classes)) { $key = array_search($class,$this->classes); if ($key!==false) { unset($this->classes[$key]); return true; } } return false; }
[ "public", "function", "remove_class", "(", "$", "class", ")", "{", "if", "(", "in_array", "(", "$", "class", ",", "$", "this", "->", "classes", ")", ")", "{", "$", "key", "=", "array_search", "(", "$", "class", ",", "$", "this", "->", "classes", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "classes", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Removes a CSS class from this node. @param string $class @return bool True if the class was successfully removed.
[ "Removes", "a", "CSS", "class", "from", "this", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L543-L552
215,834
moodle/moodle
lib/navigationlib.php
navigation_node.contains_active_node
public function contains_active_node() { if ($this->isactive) { return true; } else { foreach ($this->children as $child) { if ($child->isactive || $child->contains_active_node()) { return true; } } } return false; }
php
public function contains_active_node() { if ($this->isactive) { return true; } else { foreach ($this->children as $child) { if ($child->isactive || $child->contains_active_node()) { return true; } } } return false; }
[ "public", "function", "contains_active_node", "(", ")", "{", "if", "(", "$", "this", "->", "isactive", ")", "{", "return", "true", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "isactive", "||", "$", "child", "->", "contains_active_node", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if this node or any of its children contain the active node. Recursive. @return bool
[ "Checks", "if", "this", "node", "or", "any", "of", "its", "children", "contain", "the", "active", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L579-L590
215,835
moodle/moodle
lib/navigationlib.php
navigation_node.is_short_branch
public function is_short_branch() { $limit = 8; if ($this->children->count() >= $limit) { return false; } foreach ($this->children as $child) { if ($child->has_children()) { return false; } } return true; }
php
public function is_short_branch() { $limit = 8; if ($this->children->count() >= $limit) { return false; } foreach ($this->children as $child) { if ($child->has_children()) { return false; } } return true; }
[ "public", "function", "is_short_branch", "(", ")", "{", "$", "limit", "=", "8", ";", "if", "(", "$", "this", "->", "children", "->", "count", "(", ")", ">=", "$", "limit", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "has_children", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
To better balance the admin tree, we want to group all the short top branches together. This means < 8 nodes and no subtrees. @return bool
[ "To", "better", "balance", "the", "admin", "tree", "we", "want", "to", "group", "all", "the", "short", "top", "branches", "together", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L599-L610
215,836
moodle/moodle
lib/navigationlib.php
navigation_node.find_active_node
public function find_active_node() { if ($this->isactive) { return $this; } else { foreach ($this->children as &$child) { $outcome = $child->find_active_node(); if ($outcome !== false) { return $outcome; } } } return false; }
php
public function find_active_node() { if ($this->isactive) { return $this; } else { foreach ($this->children as &$child) { $outcome = $child->find_active_node(); if ($outcome !== false) { return $outcome; } } } return false; }
[ "public", "function", "find_active_node", "(", ")", "{", "if", "(", "$", "this", "->", "isactive", ")", "{", "return", "$", "this", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "children", "as", "&", "$", "child", ")", "{", "$", "outcome", "=", "$", "child", "->", "find_active_node", "(", ")", ";", "if", "(", "$", "outcome", "!==", "false", ")", "{", "return", "$", "outcome", ";", "}", "}", "}", "return", "false", ";", "}" ]
Finds the active node. Searches this nodes children plus all of the children for the active node and returns it if found. Recursive. @return navigation_node|false
[ "Finds", "the", "active", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L622-L634
215,837
moodle/moodle
lib/navigationlib.php
navigation_node.search_for_active_node
public function search_for_active_node() { if ($this->check_if_active(URL_MATCH_BASE)) { return $this; } else { foreach ($this->children as &$child) { $outcome = $child->search_for_active_node(); if ($outcome !== false) { return $outcome; } } } return false; }
php
public function search_for_active_node() { if ($this->check_if_active(URL_MATCH_BASE)) { return $this; } else { foreach ($this->children as &$child) { $outcome = $child->search_for_active_node(); if ($outcome !== false) { return $outcome; } } } return false; }
[ "public", "function", "search_for_active_node", "(", ")", "{", "if", "(", "$", "this", "->", "check_if_active", "(", "URL_MATCH_BASE", ")", ")", "{", "return", "$", "this", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "children", "as", "&", "$", "child", ")", "{", "$", "outcome", "=", "$", "child", "->", "search_for_active_node", "(", ")", ";", "if", "(", "$", "outcome", "!==", "false", ")", "{", "return", "$", "outcome", ";", "}", "}", "}", "return", "false", ";", "}" ]
Searches all children for the best matching active node @return navigation_node|false
[ "Searches", "all", "children", "for", "the", "best", "matching", "active", "node" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L640-L652
215,838
moodle/moodle
lib/navigationlib.php
navigation_node.get_content
public function get_content($shorttext=false) { if ($shorttext && $this->shorttext!==null) { return format_string($this->shorttext); } else { return format_string($this->text); } }
php
public function get_content($shorttext=false) { if ($shorttext && $this->shorttext!==null) { return format_string($this->shorttext); } else { return format_string($this->text); } }
[ "public", "function", "get_content", "(", "$", "shorttext", "=", "false", ")", "{", "if", "(", "$", "shorttext", "&&", "$", "this", "->", "shorttext", "!==", "null", ")", "{", "return", "format_string", "(", "$", "this", "->", "shorttext", ")", ";", "}", "else", "{", "return", "format_string", "(", "$", "this", "->", "text", ")", ";", "}", "}" ]
Gets the content for this node. @param bool $shorttext If true shorttext is used rather than the normal text @return string
[ "Gets", "the", "content", "for", "this", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L660-L666
215,839
moodle/moodle
lib/navigationlib.php
navigation_node.get_css_type
public function get_css_type() { if (array_key_exists($this->type, $this->namedtypes)) { return 'type_'.$this->namedtypes[$this->type]; } return 'type_unknown'; }
php
public function get_css_type() { if (array_key_exists($this->type, $this->namedtypes)) { return 'type_'.$this->namedtypes[$this->type]; } return 'type_unknown'; }
[ "public", "function", "get_css_type", "(", ")", "{", "if", "(", "array_key_exists", "(", "$", "this", "->", "type", ",", "$", "this", "->", "namedtypes", ")", ")", "{", "return", "'type_'", ".", "$", "this", "->", "namedtypes", "[", "$", "this", "->", "type", "]", ";", "}", "return", "'type_unknown'", ";", "}" ]
Gets the CSS class to add to this node to describe its type @return string
[ "Gets", "the", "CSS", "class", "to", "add", "to", "this", "node", "to", "describe", "its", "type" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L704-L709
215,840
moodle/moodle
lib/navigationlib.php
navigation_node.find_expandable
public function find_expandable(array &$expandable) { foreach ($this->children as &$child) { if ($child->display && $child->has_children() && $child->children->count() == 0) { $child->id = 'expandable_branch_'.$child->type.'_'.clean_param($child->key, PARAM_ALPHANUMEXT); $this->add_class('canexpand'); $child->requiresajaxloading = true; $expandable[] = array('id' => $child->id, 'key' => $child->key, 'type' => $child->type); } $child->find_expandable($expandable); } }
php
public function find_expandable(array &$expandable) { foreach ($this->children as &$child) { if ($child->display && $child->has_children() && $child->children->count() == 0) { $child->id = 'expandable_branch_'.$child->type.'_'.clean_param($child->key, PARAM_ALPHANUMEXT); $this->add_class('canexpand'); $child->requiresajaxloading = true; $expandable[] = array('id' => $child->id, 'key' => $child->key, 'type' => $child->type); } $child->find_expandable($expandable); } }
[ "public", "function", "find_expandable", "(", "array", "&", "$", "expandable", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "&", "$", "child", ")", "{", "if", "(", "$", "child", "->", "display", "&&", "$", "child", "->", "has_children", "(", ")", "&&", "$", "child", "->", "children", "->", "count", "(", ")", "==", "0", ")", "{", "$", "child", "->", "id", "=", "'expandable_branch_'", ".", "$", "child", "->", "type", ".", "'_'", ".", "clean_param", "(", "$", "child", "->", "key", ",", "PARAM_ALPHANUMEXT", ")", ";", "$", "this", "->", "add_class", "(", "'canexpand'", ")", ";", "$", "child", "->", "requiresajaxloading", "=", "true", ";", "$", "expandable", "[", "]", "=", "array", "(", "'id'", "=>", "$", "child", "->", "id", ",", "'key'", "=>", "$", "child", "->", "key", ",", "'type'", "=>", "$", "child", "->", "type", ")", ";", "}", "$", "child", "->", "find_expandable", "(", "$", "expandable", ")", ";", "}", "}" ]
Finds all nodes that are expandable by AJAX @param array $expandable An array by reference to populate with expandable nodes.
[ "Finds", "all", "nodes", "that", "are", "expandable", "by", "AJAX" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L716-L726
215,841
moodle/moodle
lib/navigationlib.php
navigation_node.get_tabs_array
public function get_tabs_array(array $inactive=array(), $return=false) { $tabs = array(); $rows = array(); $selected = null; $activated = array(); foreach ($this->children as $node) { $tabs[] = new tabobject($node->key, $node->action, $node->get_content(), $node->get_title()); if ($node->contains_active_node()) { if ($node->children->count() > 0) { $activated[] = $node->key; foreach ($node->children as $child) { if ($child->contains_active_node()) { $selected = $child->key; } $rows[] = new tabobject($child->key, $child->action, $child->get_content(), $child->get_title()); } } else { $selected = $node->key; } } } return array(array($tabs, $rows), $selected, $inactive, $activated, $return); }
php
public function get_tabs_array(array $inactive=array(), $return=false) { $tabs = array(); $rows = array(); $selected = null; $activated = array(); foreach ($this->children as $node) { $tabs[] = new tabobject($node->key, $node->action, $node->get_content(), $node->get_title()); if ($node->contains_active_node()) { if ($node->children->count() > 0) { $activated[] = $node->key; foreach ($node->children as $child) { if ($child->contains_active_node()) { $selected = $child->key; } $rows[] = new tabobject($child->key, $child->action, $child->get_content(), $child->get_title()); } } else { $selected = $node->key; } } } return array(array($tabs, $rows), $selected, $inactive, $activated, $return); }
[ "public", "function", "get_tabs_array", "(", "array", "$", "inactive", "=", "array", "(", ")", ",", "$", "return", "=", "false", ")", "{", "$", "tabs", "=", "array", "(", ")", ";", "$", "rows", "=", "array", "(", ")", ";", "$", "selected", "=", "null", ";", "$", "activated", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "node", ")", "{", "$", "tabs", "[", "]", "=", "new", "tabobject", "(", "$", "node", "->", "key", ",", "$", "node", "->", "action", ",", "$", "node", "->", "get_content", "(", ")", ",", "$", "node", "->", "get_title", "(", ")", ")", ";", "if", "(", "$", "node", "->", "contains_active_node", "(", ")", ")", "{", "if", "(", "$", "node", "->", "children", "->", "count", "(", ")", ">", "0", ")", "{", "$", "activated", "[", "]", "=", "$", "node", "->", "key", ";", "foreach", "(", "$", "node", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "contains_active_node", "(", ")", ")", "{", "$", "selected", "=", "$", "child", "->", "key", ";", "}", "$", "rows", "[", "]", "=", "new", "tabobject", "(", "$", "child", "->", "key", ",", "$", "child", "->", "action", ",", "$", "child", "->", "get_content", "(", ")", ",", "$", "child", "->", "get_title", "(", ")", ")", ";", "}", "}", "else", "{", "$", "selected", "=", "$", "node", "->", "key", ";", "}", "}", "}", "return", "array", "(", "array", "(", "$", "tabs", ",", "$", "rows", ")", ",", "$", "selected", ",", "$", "inactive", ",", "$", "activated", ",", "$", "return", ")", ";", "}" ]
Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page. call_user_func_array('print_tabs', $node->get_tabs_array()); @param array $inactive @param bool $return @return array Array (tabs, selected, inactive, activated, return)
[ "Creates", "a", "tab", "representation", "of", "this", "nodes", "children", "that", "can", "be", "used", "with", "print_tabs", "to", "produce", "the", "tabs", "on", "a", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L762-L784
215,842
moodle/moodle
lib/navigationlib.php
navigation_node.set_parent
public function set_parent(navigation_node $parent) { // Set the parent (thats the easy part) $this->parent = $parent; // Check if this node is active (this is checked during construction) if ($this->isactive) { // Force all of the parent nodes open so you can see this node $this->parent->force_open(); // Make all parents inactive so that its clear where we are. $this->parent->make_inactive(); } }
php
public function set_parent(navigation_node $parent) { // Set the parent (thats the easy part) $this->parent = $parent; // Check if this node is active (this is checked during construction) if ($this->isactive) { // Force all of the parent nodes open so you can see this node $this->parent->force_open(); // Make all parents inactive so that its clear where we are. $this->parent->make_inactive(); } }
[ "public", "function", "set_parent", "(", "navigation_node", "$", "parent", ")", "{", "// Set the parent (thats the easy part)", "$", "this", "->", "parent", "=", "$", "parent", ";", "// Check if this node is active (this is checked during construction)", "if", "(", "$", "this", "->", "isactive", ")", "{", "// Force all of the parent nodes open so you can see this node", "$", "this", "->", "parent", "->", "force_open", "(", ")", ";", "// Make all parents inactive so that its clear where we are.", "$", "this", "->", "parent", "->", "make_inactive", "(", ")", ";", "}", "}" ]
Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well. @param navigation_node $parent
[ "Sets", "the", "parent", "for", "this", "node", "and", "if", "this", "node", "is", "active", "ensures", "that", "the", "tree", "is", "properly", "adjusted", "as", "well", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L792-L802
215,843
moodle/moodle
lib/navigationlib.php
navigation_node.hide
public function hide(array $typestohide = null) { if ($typestohide === null || in_array($this->type, $typestohide)) { $this->display = false; if ($this->has_children()) { foreach ($this->children as $child) { $child->hide($typestohide); } } } }
php
public function hide(array $typestohide = null) { if ($typestohide === null || in_array($this->type, $typestohide)) { $this->display = false; if ($this->has_children()) { foreach ($this->children as $child) { $child->hide($typestohide); } } } }
[ "public", "function", "hide", "(", "array", "$", "typestohide", "=", "null", ")", "{", "if", "(", "$", "typestohide", "===", "null", "||", "in_array", "(", "$", "this", "->", "type", ",", "$", "typestohide", ")", ")", "{", "$", "this", "->", "display", "=", "false", ";", "if", "(", "$", "this", "->", "has_children", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "child", "->", "hide", "(", "$", "typestohide", ")", ";", "}", "}", "}", "}" ]
Hides the node and any children it has. @since Moodle 2.5 @param array $typestohide Optional. An array of node types that should be hidden. If null all nodes will be hidden. If an array is given then nodes will only be hidden if their type mtatches an element in the array. e.g. array(navigation_node::TYPE_COURSE) would hide only course nodes.
[ "Hides", "the", "node", "and", "any", "children", "it", "has", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L813-L822
215,844
moodle/moodle
lib/navigationlib.php
navigation_node.action
public function action() { if ($this->action instanceof moodle_url) { return $this->action; } else if ($this->action instanceof action_link) { return $this->action->url; } return $this->action; }
php
public function action() { if ($this->action instanceof moodle_url) { return $this->action; } else if ($this->action instanceof action_link) { return $this->action->url; } return $this->action; }
[ "public", "function", "action", "(", ")", "{", "if", "(", "$", "this", "->", "action", "instanceof", "moodle_url", ")", "{", "return", "$", "this", "->", "action", ";", "}", "else", "if", "(", "$", "this", "->", "action", "instanceof", "action_link", ")", "{", "return", "$", "this", "->", "action", "->", "url", ";", "}", "return", "$", "this", "->", "action", ";", "}" ]
Get the action url for this navigation node. Called from templates. @since Moodle 3.2
[ "Get", "the", "action", "url", "for", "this", "navigation", "node", ".", "Called", "from", "templates", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L830-L837
215,845
moodle/moodle
lib/navigationlib.php
navigation_node.add_context_locking_node
protected function add_context_locking_node(\navigation_node $node, \context $context) { global $CFG; // Manage context locking. if (!empty($CFG->contextlocking) && has_capability('moodle/site:managecontextlocks', $context)) { $parentcontext = $context->get_parent_context(); if (empty($parentcontext) || !$parentcontext->locked) { if ($context->locked) { $lockicon = 'i/unlock'; $lockstring = get_string('managecontextunlock', 'admin'); } else { $lockicon = 'i/lock'; $lockstring = get_string('managecontextlock', 'admin'); } $node->add( $lockstring, new moodle_url( '/admin/lock.php', [ 'id' => $context->id, ] ), self::TYPE_SETTING, null, 'contextlocking', new pix_icon($lockicon, '') ); } } }
php
protected function add_context_locking_node(\navigation_node $node, \context $context) { global $CFG; // Manage context locking. if (!empty($CFG->contextlocking) && has_capability('moodle/site:managecontextlocks', $context)) { $parentcontext = $context->get_parent_context(); if (empty($parentcontext) || !$parentcontext->locked) { if ($context->locked) { $lockicon = 'i/unlock'; $lockstring = get_string('managecontextunlock', 'admin'); } else { $lockicon = 'i/lock'; $lockstring = get_string('managecontextlock', 'admin'); } $node->add( $lockstring, new moodle_url( '/admin/lock.php', [ 'id' => $context->id, ] ), self::TYPE_SETTING, null, 'contextlocking', new pix_icon($lockicon, '') ); } } }
[ "protected", "function", "add_context_locking_node", "(", "\\", "navigation_node", "$", "node", ",", "\\", "context", "$", "context", ")", "{", "global", "$", "CFG", ";", "// Manage context locking.", "if", "(", "!", "empty", "(", "$", "CFG", "->", "contextlocking", ")", "&&", "has_capability", "(", "'moodle/site:managecontextlocks'", ",", "$", "context", ")", ")", "{", "$", "parentcontext", "=", "$", "context", "->", "get_parent_context", "(", ")", ";", "if", "(", "empty", "(", "$", "parentcontext", ")", "||", "!", "$", "parentcontext", "->", "locked", ")", "{", "if", "(", "$", "context", "->", "locked", ")", "{", "$", "lockicon", "=", "'i/unlock'", ";", "$", "lockstring", "=", "get_string", "(", "'managecontextunlock'", ",", "'admin'", ")", ";", "}", "else", "{", "$", "lockicon", "=", "'i/lock'", ";", "$", "lockstring", "=", "get_string", "(", "'managecontextlock'", ",", "'admin'", ")", ";", "}", "$", "node", "->", "add", "(", "$", "lockstring", ",", "new", "moodle_url", "(", "'/admin/lock.php'", ",", "[", "'id'", "=>", "$", "context", "->", "id", ",", "]", ")", ",", "self", "::", "TYPE_SETTING", ",", "null", ",", "'contextlocking'", ",", "new", "pix_icon", "(", "$", "lockicon", ",", "''", ")", ")", ";", "}", "}", "}" ]
Add the menu item to handle locking and unlocking of a conext. @param \navigation_node $node Node to add @param \context $context The context to be locked
[ "Add", "the", "menu", "item", "to", "handle", "locking", "and", "unlocking", "of", "a", "conext", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L845-L874
215,846
moodle/moodle
lib/navigationlib.php
navigation_node_collection.add
public function add(navigation_node $node, $beforekey=null) { global $CFG; $key = $node->key; $type = $node->type; // First check we have a 2nd dimension for this type if (!array_key_exists($type, $this->orderedcollection)) { $this->orderedcollection[$type] = array(); } // Check for a collision and report if debugging is turned on if ($CFG->debug && array_key_exists($key, $this->orderedcollection[$type])) { debugging('Navigation node intersect: Adding a node that already exists '.$key, DEBUG_DEVELOPER); } // Find the key to add before $newindex = $this->count; $last = true; if ($beforekey !== null) { foreach ($this->collection as $index => $othernode) { if ($othernode->key === $beforekey) { $newindex = $index; $last = false; break; } } if ($newindex === $this->count) { debugging('Navigation node add_before: Reference node not found ' . $beforekey . ', options: ' . implode(' ', $this->get_key_list()), DEBUG_DEVELOPER); } } // Add the node to the appropriate place in the by-type structure (which // is not ordered, despite the variable name) $this->orderedcollection[$type][$key] = $node; if (!$last) { // Update existing references in the ordered collection (which is the // one that isn't called 'ordered') to shuffle them along if required for ($oldindex = $this->count; $oldindex > $newindex; $oldindex--) { $this->collection[$oldindex] = $this->collection[$oldindex - 1]; } } // Add a reference to the node to the progressive collection. $this->collection[$newindex] = $this->orderedcollection[$type][$key]; // Update the last property to a reference to this new node. $this->last = $this->orderedcollection[$type][$key]; // Reorder the array by index if needed if (!$last) { ksort($this->collection); } $this->count++; // Return the reference to the now added node return $node; }
php
public function add(navigation_node $node, $beforekey=null) { global $CFG; $key = $node->key; $type = $node->type; // First check we have a 2nd dimension for this type if (!array_key_exists($type, $this->orderedcollection)) { $this->orderedcollection[$type] = array(); } // Check for a collision and report if debugging is turned on if ($CFG->debug && array_key_exists($key, $this->orderedcollection[$type])) { debugging('Navigation node intersect: Adding a node that already exists '.$key, DEBUG_DEVELOPER); } // Find the key to add before $newindex = $this->count; $last = true; if ($beforekey !== null) { foreach ($this->collection as $index => $othernode) { if ($othernode->key === $beforekey) { $newindex = $index; $last = false; break; } } if ($newindex === $this->count) { debugging('Navigation node add_before: Reference node not found ' . $beforekey . ', options: ' . implode(' ', $this->get_key_list()), DEBUG_DEVELOPER); } } // Add the node to the appropriate place in the by-type structure (which // is not ordered, despite the variable name) $this->orderedcollection[$type][$key] = $node; if (!$last) { // Update existing references in the ordered collection (which is the // one that isn't called 'ordered') to shuffle them along if required for ($oldindex = $this->count; $oldindex > $newindex; $oldindex--) { $this->collection[$oldindex] = $this->collection[$oldindex - 1]; } } // Add a reference to the node to the progressive collection. $this->collection[$newindex] = $this->orderedcollection[$type][$key]; // Update the last property to a reference to this new node. $this->last = $this->orderedcollection[$type][$key]; // Reorder the array by index if needed if (!$last) { ksort($this->collection); } $this->count++; // Return the reference to the now added node return $node; }
[ "public", "function", "add", "(", "navigation_node", "$", "node", ",", "$", "beforekey", "=", "null", ")", "{", "global", "$", "CFG", ";", "$", "key", "=", "$", "node", "->", "key", ";", "$", "type", "=", "$", "node", "->", "type", ";", "// First check we have a 2nd dimension for this type", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "orderedcollection", ")", ")", "{", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "// Check for a collision and report if debugging is turned on", "if", "(", "$", "CFG", "->", "debug", "&&", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", ")", ")", "{", "debugging", "(", "'Navigation node intersect: Adding a node that already exists '", ".", "$", "key", ",", "DEBUG_DEVELOPER", ")", ";", "}", "// Find the key to add before", "$", "newindex", "=", "$", "this", "->", "count", ";", "$", "last", "=", "true", ";", "if", "(", "$", "beforekey", "!==", "null", ")", "{", "foreach", "(", "$", "this", "->", "collection", "as", "$", "index", "=>", "$", "othernode", ")", "{", "if", "(", "$", "othernode", "->", "key", "===", "$", "beforekey", ")", "{", "$", "newindex", "=", "$", "index", ";", "$", "last", "=", "false", ";", "break", ";", "}", "}", "if", "(", "$", "newindex", "===", "$", "this", "->", "count", ")", "{", "debugging", "(", "'Navigation node add_before: Reference node not found '", ".", "$", "beforekey", ".", "', options: '", ".", "implode", "(", "' '", ",", "$", "this", "->", "get_key_list", "(", ")", ")", ",", "DEBUG_DEVELOPER", ")", ";", "}", "}", "// Add the node to the appropriate place in the by-type structure (which", "// is not ordered, despite the variable name)", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", "=", "$", "node", ";", "if", "(", "!", "$", "last", ")", "{", "// Update existing references in the ordered collection (which is the", "// one that isn't called 'ordered') to shuffle them along if required", "for", "(", "$", "oldindex", "=", "$", "this", "->", "count", ";", "$", "oldindex", ">", "$", "newindex", ";", "$", "oldindex", "--", ")", "{", "$", "this", "->", "collection", "[", "$", "oldindex", "]", "=", "$", "this", "->", "collection", "[", "$", "oldindex", "-", "1", "]", ";", "}", "}", "// Add a reference to the node to the progressive collection.", "$", "this", "->", "collection", "[", "$", "newindex", "]", "=", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", ";", "// Update the last property to a reference to this new node.", "$", "this", "->", "last", "=", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", ";", "// Reorder the array by index if needed", "if", "(", "!", "$", "last", ")", "{", "ksort", "(", "$", "this", "->", "collection", ")", ";", "}", "$", "this", "->", "count", "++", ";", "// Return the reference to the now added node", "return", "$", "node", ";", "}" ]
Adds a navigation node to the collection @param navigation_node $node Node to add @param string $beforekey If specified, adds before a node with this key, otherwise adds at end @return navigation_node Added node
[ "Adds", "a", "navigation", "node", "to", "the", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L931-L984
215,847
moodle/moodle
lib/navigationlib.php
navigation_node_collection.get_key_list
public function get_key_list() { $keys = array(); foreach ($this->collection as $node) { $keys[] = $node->key; } return $keys; }
php
public function get_key_list() { $keys = array(); foreach ($this->collection as $node) { $keys[] = $node->key; } return $keys; }
[ "public", "function", "get_key_list", "(", ")", "{", "$", "keys", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "collection", "as", "$", "node", ")", "{", "$", "keys", "[", "]", "=", "$", "node", "->", "key", ";", "}", "return", "$", "keys", ";", "}" ]
Return a list of all the keys of all the nodes. @return array the keys.
[ "Return", "a", "list", "of", "all", "the", "keys", "of", "all", "the", "nodes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L990-L996
215,848
moodle/moodle
lib/navigationlib.php
navigation_node_collection.get
public function get($key, $type=null) { if ($type !== null) { // If the type is known then we can simply check and fetch if (!empty($this->orderedcollection[$type][$key])) { return $this->orderedcollection[$type][$key]; } } else { // Because we don't know the type we look in the progressive array foreach ($this->collection as $node) { if ($node->key === $key) { return $node; } } } return false; }
php
public function get($key, $type=null) { if ($type !== null) { // If the type is known then we can simply check and fetch if (!empty($this->orderedcollection[$type][$key])) { return $this->orderedcollection[$type][$key]; } } else { // Because we don't know the type we look in the progressive array foreach ($this->collection as $node) { if ($node->key === $key) { return $node; } } } return false; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "!==", "null", ")", "{", "// If the type is known then we can simply check and fetch", "if", "(", "!", "empty", "(", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", ";", "}", "}", "else", "{", "// Because we don't know the type we look in the progressive array", "foreach", "(", "$", "this", "->", "collection", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "key", "===", "$", "key", ")", "{", "return", "$", "node", ";", "}", "}", "}", "return", "false", ";", "}" ]
Fetches a node from this collection. @param string|int $key The key of the node we want to find. @param int $type One of navigation_node::TYPE_*. @return navigation_node|null
[ "Fetches", "a", "node", "from", "this", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1023-L1038
215,849
moodle/moodle
lib/navigationlib.php
navigation_node_collection.find
public function find($key, $type=null) { if ($type !== null && array_key_exists($type, $this->orderedcollection) && array_key_exists($key, $this->orderedcollection[$type])) { return $this->orderedcollection[$type][$key]; } else { $nodes = $this->getIterator(); // Search immediate children first foreach ($nodes as &$node) { if ($node->key === $key && ($type === null || $type === $node->type)) { return $node; } } // Now search each childs children foreach ($nodes as &$node) { $result = $node->children->find($key, $type); if ($result !== false) { return $result; } } } return false; }
php
public function find($key, $type=null) { if ($type !== null && array_key_exists($type, $this->orderedcollection) && array_key_exists($key, $this->orderedcollection[$type])) { return $this->orderedcollection[$type][$key]; } else { $nodes = $this->getIterator(); // Search immediate children first foreach ($nodes as &$node) { if ($node->key === $key && ($type === null || $type === $node->type)) { return $node; } } // Now search each childs children foreach ($nodes as &$node) { $result = $node->children->find($key, $type); if ($result !== false) { return $result; } } } return false; }
[ "public", "function", "find", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "!==", "null", "&&", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "orderedcollection", ")", "&&", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "[", "$", "key", "]", ";", "}", "else", "{", "$", "nodes", "=", "$", "this", "->", "getIterator", "(", ")", ";", "// Search immediate children first", "foreach", "(", "$", "nodes", "as", "&", "$", "node", ")", "{", "if", "(", "$", "node", "->", "key", "===", "$", "key", "&&", "(", "$", "type", "===", "null", "||", "$", "type", "===", "$", "node", "->", "type", ")", ")", "{", "return", "$", "node", ";", "}", "}", "// Now search each childs children", "foreach", "(", "$", "nodes", "as", "&", "$", "node", ")", "{", "$", "result", "=", "$", "node", "->", "children", "->", "find", "(", "$", "key", ",", "$", "type", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "}", "}", "return", "false", ";", "}" ]
Searches for a node with matching key and type. This function searches both the nodes in this collection and all of the nodes in each collection belonging to the nodes in this collection. Recursive. @param string|int $key The key of the node we want to find. @param int $type One of navigation_node::TYPE_*. @return navigation_node|null
[ "Searches", "for", "a", "node", "with", "matching", "key", "and", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1052-L1072
215,850
moodle/moodle
lib/navigationlib.php
navigation_node_collection.type
public function type($type) { if (!array_key_exists($type, $this->orderedcollection)) { $this->orderedcollection[$type] = array(); } return $this->orderedcollection[$type]; }
php
public function type($type) { if (!array_key_exists($type, $this->orderedcollection)) { $this->orderedcollection[$type] = array(); } return $this->orderedcollection[$type]; }
[ "public", "function", "type", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "orderedcollection", ")", ")", "{", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "return", "$", "this", "->", "orderedcollection", "[", "$", "type", "]", ";", "}" ]
Fetches all nodes of a given type from this collection @param string|int $type node type being searched for. @return array ordered collection
[ "Fetches", "all", "nodes", "of", "a", "given", "type", "from", "this", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1089-L1094
215,851
moodle/moodle
lib/navigationlib.php
navigation_node_collection.remove
public function remove($key, $type=null) { $child = $this->get($key, $type); if ($child !== false) { foreach ($this->collection as $colkey => $node) { if ($node->key === $key && (is_null($type) || $node->type == $type)) { unset($this->collection[$colkey]); $this->collection = array_values($this->collection); break; } } unset($this->orderedcollection[$child->type][$child->key]); $this->count--; return true; } return false; }
php
public function remove($key, $type=null) { $child = $this->get($key, $type); if ($child !== false) { foreach ($this->collection as $colkey => $node) { if ($node->key === $key && (is_null($type) || $node->type == $type)) { unset($this->collection[$colkey]); $this->collection = array_values($this->collection); break; } } unset($this->orderedcollection[$child->type][$child->key]); $this->count--; return true; } return false; }
[ "public", "function", "remove", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "$", "child", "=", "$", "this", "->", "get", "(", "$", "key", ",", "$", "type", ")", ";", "if", "(", "$", "child", "!==", "false", ")", "{", "foreach", "(", "$", "this", "->", "collection", "as", "$", "colkey", "=>", "$", "node", ")", "{", "if", "(", "$", "node", "->", "key", "===", "$", "key", "&&", "(", "is_null", "(", "$", "type", ")", "||", "$", "node", "->", "type", "==", "$", "type", ")", ")", "{", "unset", "(", "$", "this", "->", "collection", "[", "$", "colkey", "]", ")", ";", "$", "this", "->", "collection", "=", "array_values", "(", "$", "this", "->", "collection", ")", ";", "break", ";", "}", "}", "unset", "(", "$", "this", "->", "orderedcollection", "[", "$", "child", "->", "type", "]", "[", "$", "child", "->", "key", "]", ")", ";", "$", "this", "->", "count", "--", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Removes the node with the given key and type from the collection @param string|int $key The key of the node we want to find. @param int $type @return bool
[ "Removes", "the", "node", "with", "the", "given", "key", "and", "type", "from", "the", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1102-L1117
215,852
moodle/moodle
lib/navigationlib.php
global_navigation.current_user_is_parent_role
protected function current_user_is_parent_role() { global $USER, $DB; if ($this->useridtouseforparentchecks && $this->useridtouseforparentchecks != $USER->id) { $usercontext = context_user::instance($this->useridtouseforparentchecks, MUST_EXIST); if (!has_capability('moodle/user:viewdetails', $usercontext)) { return false; } if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))) { return true; } } return false; }
php
protected function current_user_is_parent_role() { global $USER, $DB; if ($this->useridtouseforparentchecks && $this->useridtouseforparentchecks != $USER->id) { $usercontext = context_user::instance($this->useridtouseforparentchecks, MUST_EXIST); if (!has_capability('moodle/user:viewdetails', $usercontext)) { return false; } if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))) { return true; } } return false; }
[ "protected", "function", "current_user_is_parent_role", "(", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "if", "(", "$", "this", "->", "useridtouseforparentchecks", "&&", "$", "this", "->", "useridtouseforparentchecks", "!=", "$", "USER", "->", "id", ")", "{", "$", "usercontext", "=", "context_user", "::", "instance", "(", "$", "this", "->", "useridtouseforparentchecks", ",", "MUST_EXIST", ")", ";", "if", "(", "!", "has_capability", "(", "'moodle/user:viewdetails'", ",", "$", "usercontext", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "DB", "->", "record_exists", "(", "'role_assignments'", ",", "array", "(", "'userid'", "=>", "$", "USER", "->", "id", ",", "'contextid'", "=>", "$", "usercontext", "->", "id", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the current user is a parent of the user being currently viewed. If the current user is not viewing another user, or if the current user does not hold any parent roles over the other user being viewed this function returns false. In order to set the user for whom we are checking against you must call {@link set_userid_for_parent_checks()} @since Moodle 2.4 @return bool
[ "Returns", "true", "if", "the", "current", "user", "is", "a", "parent", "of", "the", "user", "being", "currently", "viewed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1530-L1542
215,853
moodle/moodle
lib/navigationlib.php
global_navigation.show_categories
protected function show_categories($ismycourse = false) { global $CFG, $DB; if ($ismycourse) { return $this->show_my_categories(); } if ($this->showcategories === null) { $show = false; if ($this->page->context->contextlevel == CONTEXT_COURSECAT) { $show = true; } else if (!empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1) { $show = true; } $this->showcategories = $show; } return $this->showcategories; }
php
protected function show_categories($ismycourse = false) { global $CFG, $DB; if ($ismycourse) { return $this->show_my_categories(); } if ($this->showcategories === null) { $show = false; if ($this->page->context->contextlevel == CONTEXT_COURSECAT) { $show = true; } else if (!empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1) { $show = true; } $this->showcategories = $show; } return $this->showcategories; }
[ "protected", "function", "show_categories", "(", "$", "ismycourse", "=", "false", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "if", "(", "$", "ismycourse", ")", "{", "return", "$", "this", "->", "show_my_categories", "(", ")", ";", "}", "if", "(", "$", "this", "->", "showcategories", "===", "null", ")", "{", "$", "show", "=", "false", ";", "if", "(", "$", "this", "->", "page", "->", "context", "->", "contextlevel", "==", "CONTEXT_COURSECAT", ")", "{", "$", "show", "=", "true", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "CFG", "->", "navshowcategories", ")", "&&", "$", "DB", "->", "count_records", "(", "'course_categories'", ")", ">", "1", ")", "{", "$", "show", "=", "true", ";", "}", "$", "this", "->", "showcategories", "=", "$", "show", ";", "}", "return", "$", "this", "->", "showcategories", ";", "}" ]
Returns true if courses should be shown within categories on the navigation. @param bool $ismycourse Set to true if you are calculating this for a course. @return bool
[ "Returns", "true", "if", "courses", "should", "be", "shown", "within", "categories", "on", "the", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1550-L1565
215,854
moodle/moodle
lib/navigationlib.php
global_navigation.show_my_categories
protected function show_my_categories() { global $CFG; if ($this->showmycategories === null) { $this->showmycategories = !empty($CFG->navshowmycoursecategories) && !core_course_category::is_simple_site(); } return $this->showmycategories; }
php
protected function show_my_categories() { global $CFG; if ($this->showmycategories === null) { $this->showmycategories = !empty($CFG->navshowmycoursecategories) && !core_course_category::is_simple_site(); } return $this->showmycategories; }
[ "protected", "function", "show_my_categories", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "this", "->", "showmycategories", "===", "null", ")", "{", "$", "this", "->", "showmycategories", "=", "!", "empty", "(", "$", "CFG", "->", "navshowmycoursecategories", ")", "&&", "!", "core_course_category", "::", "is_simple_site", "(", ")", ";", "}", "return", "$", "this", "->", "showmycategories", ";", "}" ]
Returns true if we should show categories in the My Courses branch. @return bool
[ "Returns", "true", "if", "we", "should", "show", "categories", "in", "the", "My", "Courses", "branch", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1571-L1577
215,855
moodle/moodle
lib/navigationlib.php
global_navigation.can_add_more_courses_to_category
protected function can_add_more_courses_to_category($category) { global $CFG; $limit = 20; if (!empty($CFG->navcourselimit)) { $limit = (int)$CFG->navcourselimit; } if (is_numeric($category)) { if (!array_key_exists($category, $this->addedcategories)) { return true; } $coursecount = count($this->addedcategories[$category]->children->type(self::TYPE_COURSE)); } else if ($category instanceof navigation_node) { if (($category->type != self::TYPE_CATEGORY) || ($category->type != self::TYPE_MY_CATEGORY)) { return false; } $coursecount = count($category->children->type(self::TYPE_COURSE)); } else if (is_object($category) && property_exists($category,'id')) { $coursecount = count($this->addedcategories[$category->id]->children->type(self::TYPE_COURSE)); } return ($coursecount <= $limit); }
php
protected function can_add_more_courses_to_category($category) { global $CFG; $limit = 20; if (!empty($CFG->navcourselimit)) { $limit = (int)$CFG->navcourselimit; } if (is_numeric($category)) { if (!array_key_exists($category, $this->addedcategories)) { return true; } $coursecount = count($this->addedcategories[$category]->children->type(self::TYPE_COURSE)); } else if ($category instanceof navigation_node) { if (($category->type != self::TYPE_CATEGORY) || ($category->type != self::TYPE_MY_CATEGORY)) { return false; } $coursecount = count($category->children->type(self::TYPE_COURSE)); } else if (is_object($category) && property_exists($category,'id')) { $coursecount = count($this->addedcategories[$category->id]->children->type(self::TYPE_COURSE)); } return ($coursecount <= $limit); }
[ "protected", "function", "can_add_more_courses_to_category", "(", "$", "category", ")", "{", "global", "$", "CFG", ";", "$", "limit", "=", "20", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "navcourselimit", ")", ")", "{", "$", "limit", "=", "(", "int", ")", "$", "CFG", "->", "navcourselimit", ";", "}", "if", "(", "is_numeric", "(", "$", "category", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "category", ",", "$", "this", "->", "addedcategories", ")", ")", "{", "return", "true", ";", "}", "$", "coursecount", "=", "count", "(", "$", "this", "->", "addedcategories", "[", "$", "category", "]", "->", "children", "->", "type", "(", "self", "::", "TYPE_COURSE", ")", ")", ";", "}", "else", "if", "(", "$", "category", "instanceof", "navigation_node", ")", "{", "if", "(", "(", "$", "category", "->", "type", "!=", "self", "::", "TYPE_CATEGORY", ")", "||", "(", "$", "category", "->", "type", "!=", "self", "::", "TYPE_MY_CATEGORY", ")", ")", "{", "return", "false", ";", "}", "$", "coursecount", "=", "count", "(", "$", "category", "->", "children", "->", "type", "(", "self", "::", "TYPE_COURSE", ")", ")", ";", "}", "else", "if", "(", "is_object", "(", "$", "category", ")", "&&", "property_exists", "(", "$", "category", ",", "'id'", ")", ")", "{", "$", "coursecount", "=", "count", "(", "$", "this", "->", "addedcategories", "[", "$", "category", "->", "id", "]", "->", "children", "->", "type", "(", "self", "::", "TYPE_COURSE", ")", ")", ";", "}", "return", "(", "$", "coursecount", "<=", "$", "limit", ")", ";", "}" ]
Returns true if more courses can be added to the provided category. @param int|navigation_node|stdClass $category @return bool
[ "Returns", "true", "if", "more", "courses", "can", "be", "added", "to", "the", "provided", "category", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1763-L1783
215,856
moodle/moodle
lib/navigationlib.php
global_navigation.load_course
protected function load_course(stdClass $course) { global $SITE; if ($course->id == $SITE->id) { // This is always loaded during initialisation return $this->rootnodes['site']; } else if (array_key_exists($course->id, $this->addedcourses)) { // The course has already been loaded so return a reference return $this->addedcourses[$course->id]; } else { // Add the course return $this->add_course($course); } }
php
protected function load_course(stdClass $course) { global $SITE; if ($course->id == $SITE->id) { // This is always loaded during initialisation return $this->rootnodes['site']; } else if (array_key_exists($course->id, $this->addedcourses)) { // The course has already been loaded so return a reference return $this->addedcourses[$course->id]; } else { // Add the course return $this->add_course($course); } }
[ "protected", "function", "load_course", "(", "stdClass", "$", "course", ")", "{", "global", "$", "SITE", ";", "if", "(", "$", "course", "->", "id", "==", "$", "SITE", "->", "id", ")", "{", "// This is always loaded during initialisation", "return", "$", "this", "->", "rootnodes", "[", "'site'", "]", ";", "}", "else", "if", "(", "array_key_exists", "(", "$", "course", "->", "id", ",", "$", "this", "->", "addedcourses", ")", ")", "{", "// The course has already been loaded so return a reference", "return", "$", "this", "->", "addedcourses", "[", "$", "course", "->", "id", "]", ";", "}", "else", "{", "// Add the course", "return", "$", "this", "->", "add_course", "(", "$", "course", ")", ";", "}", "}" ]
Loads the given course into the navigation @param stdClass $course @return navigation_node
[ "Loads", "the", "given", "course", "into", "the", "navigation" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L1979-L1991
215,857
moodle/moodle
lib/navigationlib.php
global_navigation.load_course_sections
protected function load_course_sections(stdClass $course, navigation_node $coursenode, $sectionnum = null, $cm = null) { global $CFG, $SITE; require_once($CFG->dirroot.'/course/lib.php'); if (isset($cm->sectionnum)) { $sectionnum = $cm->sectionnum; } if ($sectionnum !== null) { $this->includesectionnum = $sectionnum; } course_get_format($course)->extend_course_navigation($this, $coursenode, $sectionnum, $cm); if (isset($cm->id)) { $activity = $coursenode->find($cm->id, self::TYPE_ACTIVITY); if (empty($activity)) { $activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course)); } } }
php
protected function load_course_sections(stdClass $course, navigation_node $coursenode, $sectionnum = null, $cm = null) { global $CFG, $SITE; require_once($CFG->dirroot.'/course/lib.php'); if (isset($cm->sectionnum)) { $sectionnum = $cm->sectionnum; } if ($sectionnum !== null) { $this->includesectionnum = $sectionnum; } course_get_format($course)->extend_course_navigation($this, $coursenode, $sectionnum, $cm); if (isset($cm->id)) { $activity = $coursenode->find($cm->id, self::TYPE_ACTIVITY); if (empty($activity)) { $activity = $this->load_stealth_activity($coursenode, get_fast_modinfo($course)); } } }
[ "protected", "function", "load_course_sections", "(", "stdClass", "$", "course", ",", "navigation_node", "$", "coursenode", ",", "$", "sectionnum", "=", "null", ",", "$", "cm", "=", "null", ")", "{", "global", "$", "CFG", ",", "$", "SITE", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "if", "(", "isset", "(", "$", "cm", "->", "sectionnum", ")", ")", "{", "$", "sectionnum", "=", "$", "cm", "->", "sectionnum", ";", "}", "if", "(", "$", "sectionnum", "!==", "null", ")", "{", "$", "this", "->", "includesectionnum", "=", "$", "sectionnum", ";", "}", "course_get_format", "(", "$", "course", ")", "->", "extend_course_navigation", "(", "$", "this", ",", "$", "coursenode", ",", "$", "sectionnum", ",", "$", "cm", ")", ";", "if", "(", "isset", "(", "$", "cm", "->", "id", ")", ")", "{", "$", "activity", "=", "$", "coursenode", "->", "find", "(", "$", "cm", "->", "id", ",", "self", "::", "TYPE_ACTIVITY", ")", ";", "if", "(", "empty", "(", "$", "activity", ")", ")", "{", "$", "activity", "=", "$", "this", "->", "load_stealth_activity", "(", "$", "coursenode", ",", "get_fast_modinfo", "(", "$", "course", ")", ")", ";", "}", "}", "}" ]
Loads all of the courses section into the navigation. This function calls method from current course format, see {@link format_base::extend_course_navigation()} If course module ($cm) is specified but course format failed to create the node, the activity node is created anyway. By default course formats call the method {@link global_navigation::load_generic_course_sections()} @param stdClass $course Database record for the course @param navigation_node $coursenode The course node within the navigation @param null|int $sectionnum If specified load the contents of section with this relative number @param null|cm_info $cm If specified make sure that activity node is created (either in containg section or by calling load_stealth_activity() )
[ "Loads", "all", "of", "the", "courses", "section", "into", "the", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2009-L2025
215,858
moodle/moodle
lib/navigationlib.php
global_navigation.generate_sections_and_activities
protected function generate_sections_and_activities(stdClass $course) { global $CFG; require_once($CFG->dirroot.'/course/lib.php'); $modinfo = get_fast_modinfo($course); $sections = $modinfo->get_section_info_all(); // For course formats using 'numsections' trim the sections list $courseformatoptions = course_get_format($course)->get_format_options(); if (isset($courseformatoptions['numsections'])) { $sections = array_slice($sections, 0, $courseformatoptions['numsections']+1, true); } $activities = array(); foreach ($sections as $key => $section) { // Clone and unset summary to prevent $SESSION bloat (MDL-31802). $sections[$key] = clone($section); unset($sections[$key]->summary); $sections[$key]->hasactivites = false; if (!array_key_exists($section->section, $modinfo->sections)) { continue; } foreach ($modinfo->sections[$section->section] as $cmid) { $cm = $modinfo->cms[$cmid]; $activity = new stdClass; $activity->id = $cm->id; $activity->course = $course->id; $activity->section = $section->section; $activity->name = $cm->name; $activity->icon = $cm->icon; $activity->iconcomponent = $cm->iconcomponent; $activity->hidden = (!$cm->visible); $activity->modname = $cm->modname; $activity->nodetype = navigation_node::NODETYPE_LEAF; $activity->onclick = $cm->onclick; $url = $cm->url; if (!$url) { $activity->url = null; $activity->display = false; } else { $activity->url = $url->out(); $activity->display = $cm->is_visible_on_course_page() ? true : false; if (self::module_extends_navigation($cm->modname)) { $activity->nodetype = navigation_node::NODETYPE_BRANCH; } } $activities[$cmid] = $activity; if ($activity->display) { $sections[$key]->hasactivites = true; } } } return array($sections, $activities); }
php
protected function generate_sections_and_activities(stdClass $course) { global $CFG; require_once($CFG->dirroot.'/course/lib.php'); $modinfo = get_fast_modinfo($course); $sections = $modinfo->get_section_info_all(); // For course formats using 'numsections' trim the sections list $courseformatoptions = course_get_format($course)->get_format_options(); if (isset($courseformatoptions['numsections'])) { $sections = array_slice($sections, 0, $courseformatoptions['numsections']+1, true); } $activities = array(); foreach ($sections as $key => $section) { // Clone and unset summary to prevent $SESSION bloat (MDL-31802). $sections[$key] = clone($section); unset($sections[$key]->summary); $sections[$key]->hasactivites = false; if (!array_key_exists($section->section, $modinfo->sections)) { continue; } foreach ($modinfo->sections[$section->section] as $cmid) { $cm = $modinfo->cms[$cmid]; $activity = new stdClass; $activity->id = $cm->id; $activity->course = $course->id; $activity->section = $section->section; $activity->name = $cm->name; $activity->icon = $cm->icon; $activity->iconcomponent = $cm->iconcomponent; $activity->hidden = (!$cm->visible); $activity->modname = $cm->modname; $activity->nodetype = navigation_node::NODETYPE_LEAF; $activity->onclick = $cm->onclick; $url = $cm->url; if (!$url) { $activity->url = null; $activity->display = false; } else { $activity->url = $url->out(); $activity->display = $cm->is_visible_on_course_page() ? true : false; if (self::module_extends_navigation($cm->modname)) { $activity->nodetype = navigation_node::NODETYPE_BRANCH; } } $activities[$cmid] = $activity; if ($activity->display) { $sections[$key]->hasactivites = true; } } } return array($sections, $activities); }
[ "protected", "function", "generate_sections_and_activities", "(", "stdClass", "$", "course", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "$", "sections", "=", "$", "modinfo", "->", "get_section_info_all", "(", ")", ";", "// For course formats using 'numsections' trim the sections list", "$", "courseformatoptions", "=", "course_get_format", "(", "$", "course", ")", "->", "get_format_options", "(", ")", ";", "if", "(", "isset", "(", "$", "courseformatoptions", "[", "'numsections'", "]", ")", ")", "{", "$", "sections", "=", "array_slice", "(", "$", "sections", ",", "0", ",", "$", "courseformatoptions", "[", "'numsections'", "]", "+", "1", ",", "true", ")", ";", "}", "$", "activities", "=", "array", "(", ")", ";", "foreach", "(", "$", "sections", "as", "$", "key", "=>", "$", "section", ")", "{", "// Clone and unset summary to prevent $SESSION bloat (MDL-31802).", "$", "sections", "[", "$", "key", "]", "=", "clone", "(", "$", "section", ")", ";", "unset", "(", "$", "sections", "[", "$", "key", "]", "->", "summary", ")", ";", "$", "sections", "[", "$", "key", "]", "->", "hasactivites", "=", "false", ";", "if", "(", "!", "array_key_exists", "(", "$", "section", "->", "section", ",", "$", "modinfo", "->", "sections", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "modinfo", "->", "sections", "[", "$", "section", "->", "section", "]", "as", "$", "cmid", ")", "{", "$", "cm", "=", "$", "modinfo", "->", "cms", "[", "$", "cmid", "]", ";", "$", "activity", "=", "new", "stdClass", ";", "$", "activity", "->", "id", "=", "$", "cm", "->", "id", ";", "$", "activity", "->", "course", "=", "$", "course", "->", "id", ";", "$", "activity", "->", "section", "=", "$", "section", "->", "section", ";", "$", "activity", "->", "name", "=", "$", "cm", "->", "name", ";", "$", "activity", "->", "icon", "=", "$", "cm", "->", "icon", ";", "$", "activity", "->", "iconcomponent", "=", "$", "cm", "->", "iconcomponent", ";", "$", "activity", "->", "hidden", "=", "(", "!", "$", "cm", "->", "visible", ")", ";", "$", "activity", "->", "modname", "=", "$", "cm", "->", "modname", ";", "$", "activity", "->", "nodetype", "=", "navigation_node", "::", "NODETYPE_LEAF", ";", "$", "activity", "->", "onclick", "=", "$", "cm", "->", "onclick", ";", "$", "url", "=", "$", "cm", "->", "url", ";", "if", "(", "!", "$", "url", ")", "{", "$", "activity", "->", "url", "=", "null", ";", "$", "activity", "->", "display", "=", "false", ";", "}", "else", "{", "$", "activity", "->", "url", "=", "$", "url", "->", "out", "(", ")", ";", "$", "activity", "->", "display", "=", "$", "cm", "->", "is_visible_on_course_page", "(", ")", "?", "true", ":", "false", ";", "if", "(", "self", "::", "module_extends_navigation", "(", "$", "cm", "->", "modname", ")", ")", "{", "$", "activity", "->", "nodetype", "=", "navigation_node", "::", "NODETYPE_BRANCH", ";", "}", "}", "$", "activities", "[", "$", "cmid", "]", "=", "$", "activity", ";", "if", "(", "$", "activity", "->", "display", ")", "{", "$", "sections", "[", "$", "key", "]", "->", "hasactivites", "=", "true", ";", "}", "}", "}", "return", "array", "(", "$", "sections", ",", "$", "activities", ")", ";", "}" ]
Generates an array of sections and an array of activities for the given course. This method uses the cache to improve performance and avoid the get_fast_modinfo call @param stdClass $course @return array Array($sections, $activities)
[ "Generates", "an", "array", "of", "sections", "and", "an", "array", "of", "activities", "for", "the", "given", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2035-L2090
215,859
moodle/moodle
lib/navigationlib.php
global_navigation.load_generic_course_sections
public function load_generic_course_sections(stdClass $course, navigation_node $coursenode) { global $CFG, $DB, $USER, $SITE; require_once($CFG->dirroot.'/course/lib.php'); list($sections, $activities) = $this->generate_sections_and_activities($course); $navigationsections = array(); foreach ($sections as $sectionid => $section) { $section = clone($section); if ($course->id == $SITE->id) { $this->load_section_activities($coursenode, $section->section, $activities); } else { if (!$section->uservisible || (!$this->showemptysections && !$section->hasactivites && $this->includesectionnum !== $section->section)) { continue; } $sectionname = get_section_name($course, $section); $url = course_get_url($course, $section->section, array('navigation' => true)); $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id, new pix_icon('i/section', '')); $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH; $sectionnode->hidden = (!$section->visible || !$section->available); if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) { $this->load_section_activities($sectionnode, $section->section, $activities); } $section->sectionnode = $sectionnode; $navigationsections[$sectionid] = $section; } } return $navigationsections; }
php
public function load_generic_course_sections(stdClass $course, navigation_node $coursenode) { global $CFG, $DB, $USER, $SITE; require_once($CFG->dirroot.'/course/lib.php'); list($sections, $activities) = $this->generate_sections_and_activities($course); $navigationsections = array(); foreach ($sections as $sectionid => $section) { $section = clone($section); if ($course->id == $SITE->id) { $this->load_section_activities($coursenode, $section->section, $activities); } else { if (!$section->uservisible || (!$this->showemptysections && !$section->hasactivites && $this->includesectionnum !== $section->section)) { continue; } $sectionname = get_section_name($course, $section); $url = course_get_url($course, $section->section, array('navigation' => true)); $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id, new pix_icon('i/section', '')); $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH; $sectionnode->hidden = (!$section->visible || !$section->available); if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) { $this->load_section_activities($sectionnode, $section->section, $activities); } $section->sectionnode = $sectionnode; $navigationsections[$sectionid] = $section; } } return $navigationsections; }
[ "public", "function", "load_generic_course_sections", "(", "stdClass", "$", "course", ",", "navigation_node", "$", "coursenode", ")", "{", "global", "$", "CFG", ",", "$", "DB", ",", "$", "USER", ",", "$", "SITE", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "list", "(", "$", "sections", ",", "$", "activities", ")", "=", "$", "this", "->", "generate_sections_and_activities", "(", "$", "course", ")", ";", "$", "navigationsections", "=", "array", "(", ")", ";", "foreach", "(", "$", "sections", "as", "$", "sectionid", "=>", "$", "section", ")", "{", "$", "section", "=", "clone", "(", "$", "section", ")", ";", "if", "(", "$", "course", "->", "id", "==", "$", "SITE", "->", "id", ")", "{", "$", "this", "->", "load_section_activities", "(", "$", "coursenode", ",", "$", "section", "->", "section", ",", "$", "activities", ")", ";", "}", "else", "{", "if", "(", "!", "$", "section", "->", "uservisible", "||", "(", "!", "$", "this", "->", "showemptysections", "&&", "!", "$", "section", "->", "hasactivites", "&&", "$", "this", "->", "includesectionnum", "!==", "$", "section", "->", "section", ")", ")", "{", "continue", ";", "}", "$", "sectionname", "=", "get_section_name", "(", "$", "course", ",", "$", "section", ")", ";", "$", "url", "=", "course_get_url", "(", "$", "course", ",", "$", "section", "->", "section", ",", "array", "(", "'navigation'", "=>", "true", ")", ")", ";", "$", "sectionnode", "=", "$", "coursenode", "->", "add", "(", "$", "sectionname", ",", "$", "url", ",", "navigation_node", "::", "TYPE_SECTION", ",", "null", ",", "$", "section", "->", "id", ",", "new", "pix_icon", "(", "'i/section'", ",", "''", ")", ")", ";", "$", "sectionnode", "->", "nodetype", "=", "navigation_node", "::", "NODETYPE_BRANCH", ";", "$", "sectionnode", "->", "hidden", "=", "(", "!", "$", "section", "->", "visible", "||", "!", "$", "section", "->", "available", ")", ";", "if", "(", "$", "this", "->", "includesectionnum", "!==", "false", "&&", "$", "this", "->", "includesectionnum", "==", "$", "section", "->", "section", ")", "{", "$", "this", "->", "load_section_activities", "(", "$", "sectionnode", ",", "$", "section", "->", "section", ",", "$", "activities", ")", ";", "}", "$", "section", "->", "sectionnode", "=", "$", "sectionnode", ";", "$", "navigationsections", "[", "$", "sectionid", "]", "=", "$", "section", ";", "}", "}", "return", "$", "navigationsections", ";", "}" ]
Generically loads the course sections into the course's navigation. @param stdClass $course @param navigation_node $coursenode @return array An array of course section nodes
[ "Generically", "loads", "the", "course", "sections", "into", "the", "course", "s", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2099-L2131
215,860
moodle/moodle
lib/navigationlib.php
global_navigation.load_section_activities
protected function load_section_activities(navigation_node $sectionnode, $sectionnumber, array $activities, $course = null) { global $CFG, $SITE; // A static counter for JS function naming static $legacyonclickcounter = 0; $activitynodes = array(); if (empty($activities)) { return $activitynodes; } if (!is_object($course)) { $activity = reset($activities); $courseid = $activity->course; } else { $courseid = $course->id; } $showactivities = ($courseid != $SITE->id || !empty($CFG->navshowfrontpagemods)); foreach ($activities as $activity) { if ($activity->section != $sectionnumber) { continue; } if ($activity->icon) { $icon = new pix_icon($activity->icon, get_string('modulename', $activity->modname), $activity->iconcomponent); } else { $icon = new pix_icon('icon', get_string('modulename', $activity->modname), $activity->modname); } // Prepare the default name and url for the node $activityname = format_string($activity->name, true, array('context' => context_module::instance($activity->id))); $action = new moodle_url($activity->url); // Check if the onclick property is set (puke!) if (!empty($activity->onclick)) { // Increment the counter so that we have a unique number. $legacyonclickcounter++; // Generate the function name we will use $functionname = 'legacy_activity_onclick_handler_'.$legacyonclickcounter; $propogrationhandler = ''; // Check if we need to cancel propogation. Remember inline onclick // events would return false if they wanted to prevent propogation and the // default action. if (strpos($activity->onclick, 'return false')) { $propogrationhandler = 'e.halt();'; } // Decode the onclick - it has already been encoded for display (puke) $onclick = htmlspecialchars_decode($activity->onclick, ENT_QUOTES); // Build the JS function the click event will call $jscode = "function {$functionname}(e) { $propogrationhandler $onclick }"; $this->page->requires->js_amd_inline($jscode); // Override the default url with the new action link $action = new action_link($action, $activityname, new component_action('click', $functionname)); } $activitynode = $sectionnode->add($activityname, $action, navigation_node::TYPE_ACTIVITY, null, $activity->id, $icon); $activitynode->title(get_string('modulename', $activity->modname)); $activitynode->hidden = $activity->hidden; $activitynode->display = $showactivities && $activity->display; $activitynode->nodetype = $activity->nodetype; $activitynodes[$activity->id] = $activitynode; } return $activitynodes; }
php
protected function load_section_activities(navigation_node $sectionnode, $sectionnumber, array $activities, $course = null) { global $CFG, $SITE; // A static counter for JS function naming static $legacyonclickcounter = 0; $activitynodes = array(); if (empty($activities)) { return $activitynodes; } if (!is_object($course)) { $activity = reset($activities); $courseid = $activity->course; } else { $courseid = $course->id; } $showactivities = ($courseid != $SITE->id || !empty($CFG->navshowfrontpagemods)); foreach ($activities as $activity) { if ($activity->section != $sectionnumber) { continue; } if ($activity->icon) { $icon = new pix_icon($activity->icon, get_string('modulename', $activity->modname), $activity->iconcomponent); } else { $icon = new pix_icon('icon', get_string('modulename', $activity->modname), $activity->modname); } // Prepare the default name and url for the node $activityname = format_string($activity->name, true, array('context' => context_module::instance($activity->id))); $action = new moodle_url($activity->url); // Check if the onclick property is set (puke!) if (!empty($activity->onclick)) { // Increment the counter so that we have a unique number. $legacyonclickcounter++; // Generate the function name we will use $functionname = 'legacy_activity_onclick_handler_'.$legacyonclickcounter; $propogrationhandler = ''; // Check if we need to cancel propogation. Remember inline onclick // events would return false if they wanted to prevent propogation and the // default action. if (strpos($activity->onclick, 'return false')) { $propogrationhandler = 'e.halt();'; } // Decode the onclick - it has already been encoded for display (puke) $onclick = htmlspecialchars_decode($activity->onclick, ENT_QUOTES); // Build the JS function the click event will call $jscode = "function {$functionname}(e) { $propogrationhandler $onclick }"; $this->page->requires->js_amd_inline($jscode); // Override the default url with the new action link $action = new action_link($action, $activityname, new component_action('click', $functionname)); } $activitynode = $sectionnode->add($activityname, $action, navigation_node::TYPE_ACTIVITY, null, $activity->id, $icon); $activitynode->title(get_string('modulename', $activity->modname)); $activitynode->hidden = $activity->hidden; $activitynode->display = $showactivities && $activity->display; $activitynode->nodetype = $activity->nodetype; $activitynodes[$activity->id] = $activitynode; } return $activitynodes; }
[ "protected", "function", "load_section_activities", "(", "navigation_node", "$", "sectionnode", ",", "$", "sectionnumber", ",", "array", "$", "activities", ",", "$", "course", "=", "null", ")", "{", "global", "$", "CFG", ",", "$", "SITE", ";", "// A static counter for JS function naming", "static", "$", "legacyonclickcounter", "=", "0", ";", "$", "activitynodes", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "activities", ")", ")", "{", "return", "$", "activitynodes", ";", "}", "if", "(", "!", "is_object", "(", "$", "course", ")", ")", "{", "$", "activity", "=", "reset", "(", "$", "activities", ")", ";", "$", "courseid", "=", "$", "activity", "->", "course", ";", "}", "else", "{", "$", "courseid", "=", "$", "course", "->", "id", ";", "}", "$", "showactivities", "=", "(", "$", "courseid", "!=", "$", "SITE", "->", "id", "||", "!", "empty", "(", "$", "CFG", "->", "navshowfrontpagemods", ")", ")", ";", "foreach", "(", "$", "activities", "as", "$", "activity", ")", "{", "if", "(", "$", "activity", "->", "section", "!=", "$", "sectionnumber", ")", "{", "continue", ";", "}", "if", "(", "$", "activity", "->", "icon", ")", "{", "$", "icon", "=", "new", "pix_icon", "(", "$", "activity", "->", "icon", ",", "get_string", "(", "'modulename'", ",", "$", "activity", "->", "modname", ")", ",", "$", "activity", "->", "iconcomponent", ")", ";", "}", "else", "{", "$", "icon", "=", "new", "pix_icon", "(", "'icon'", ",", "get_string", "(", "'modulename'", ",", "$", "activity", "->", "modname", ")", ",", "$", "activity", "->", "modname", ")", ";", "}", "// Prepare the default name and url for the node", "$", "activityname", "=", "format_string", "(", "$", "activity", "->", "name", ",", "true", ",", "array", "(", "'context'", "=>", "context_module", "::", "instance", "(", "$", "activity", "->", "id", ")", ")", ")", ";", "$", "action", "=", "new", "moodle_url", "(", "$", "activity", "->", "url", ")", ";", "// Check if the onclick property is set (puke!)", "if", "(", "!", "empty", "(", "$", "activity", "->", "onclick", ")", ")", "{", "// Increment the counter so that we have a unique number.", "$", "legacyonclickcounter", "++", ";", "// Generate the function name we will use", "$", "functionname", "=", "'legacy_activity_onclick_handler_'", ".", "$", "legacyonclickcounter", ";", "$", "propogrationhandler", "=", "''", ";", "// Check if we need to cancel propogation. Remember inline onclick", "// events would return false if they wanted to prevent propogation and the", "// default action.", "if", "(", "strpos", "(", "$", "activity", "->", "onclick", ",", "'return false'", ")", ")", "{", "$", "propogrationhandler", "=", "'e.halt();'", ";", "}", "// Decode the onclick - it has already been encoded for display (puke)", "$", "onclick", "=", "htmlspecialchars_decode", "(", "$", "activity", "->", "onclick", ",", "ENT_QUOTES", ")", ";", "// Build the JS function the click event will call", "$", "jscode", "=", "\"function {$functionname}(e) { $propogrationhandler $onclick }\"", ";", "$", "this", "->", "page", "->", "requires", "->", "js_amd_inline", "(", "$", "jscode", ")", ";", "// Override the default url with the new action link", "$", "action", "=", "new", "action_link", "(", "$", "action", ",", "$", "activityname", ",", "new", "component_action", "(", "'click'", ",", "$", "functionname", ")", ")", ";", "}", "$", "activitynode", "=", "$", "sectionnode", "->", "add", "(", "$", "activityname", ",", "$", "action", ",", "navigation_node", "::", "TYPE_ACTIVITY", ",", "null", ",", "$", "activity", "->", "id", ",", "$", "icon", ")", ";", "$", "activitynode", "->", "title", "(", "get_string", "(", "'modulename'", ",", "$", "activity", "->", "modname", ")", ")", ";", "$", "activitynode", "->", "hidden", "=", "$", "activity", "->", "hidden", ";", "$", "activitynode", "->", "display", "=", "$", "showactivities", "&&", "$", "activity", "->", "display", ";", "$", "activitynode", "->", "nodetype", "=", "$", "activity", "->", "nodetype", ";", "$", "activitynodes", "[", "$", "activity", "->", "id", "]", "=", "$", "activitynode", ";", "}", "return", "$", "activitynodes", ";", "}" ]
Loads all of the activities for a section into the navigation structure. @param navigation_node $sectionnode @param int $sectionnumber @param array $activities An array of activites as returned by {@link global_navigation::generate_sections_and_activities()} @param stdClass $course The course object the section and activities relate to. @return array Array of activity nodes
[ "Loads", "all", "of", "the", "activities", "for", "a", "section", "into", "the", "navigation", "structure", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2142-L2205
215,861
moodle/moodle
lib/navigationlib.php
global_navigation.load_stealth_activity
protected function load_stealth_activity(navigation_node $coursenode, $modinfo) { if (empty($modinfo->cms[$this->page->cm->id])) { return null; } $cm = $modinfo->cms[$this->page->cm->id]; if ($cm->icon) { $icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent); } else { $icon = new pix_icon('icon', get_string('modulename', $cm->modname), $cm->modname); } $url = $cm->url; $activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon); $activitynode->title(get_string('modulename', $cm->modname)); $activitynode->hidden = (!$cm->visible); if (!$cm->is_visible_on_course_page()) { // Do not show any error here, let the page handle exception that activity is not visible for the current user. // Also there may be no exception at all in case when teacher is logged in as student. $activitynode->display = false; } else if (!$url) { // Don't show activities that don't have links! $activitynode->display = false; } else if (self::module_extends_navigation($cm->modname)) { $activitynode->nodetype = navigation_node::NODETYPE_BRANCH; } return $activitynode; }
php
protected function load_stealth_activity(navigation_node $coursenode, $modinfo) { if (empty($modinfo->cms[$this->page->cm->id])) { return null; } $cm = $modinfo->cms[$this->page->cm->id]; if ($cm->icon) { $icon = new pix_icon($cm->icon, get_string('modulename', $cm->modname), $cm->iconcomponent); } else { $icon = new pix_icon('icon', get_string('modulename', $cm->modname), $cm->modname); } $url = $cm->url; $activitynode = $coursenode->add(format_string($cm->name), $url, navigation_node::TYPE_ACTIVITY, null, $cm->id, $icon); $activitynode->title(get_string('modulename', $cm->modname)); $activitynode->hidden = (!$cm->visible); if (!$cm->is_visible_on_course_page()) { // Do not show any error here, let the page handle exception that activity is not visible for the current user. // Also there may be no exception at all in case when teacher is logged in as student. $activitynode->display = false; } else if (!$url) { // Don't show activities that don't have links! $activitynode->display = false; } else if (self::module_extends_navigation($cm->modname)) { $activitynode->nodetype = navigation_node::NODETYPE_BRANCH; } return $activitynode; }
[ "protected", "function", "load_stealth_activity", "(", "navigation_node", "$", "coursenode", ",", "$", "modinfo", ")", "{", "if", "(", "empty", "(", "$", "modinfo", "->", "cms", "[", "$", "this", "->", "page", "->", "cm", "->", "id", "]", ")", ")", "{", "return", "null", ";", "}", "$", "cm", "=", "$", "modinfo", "->", "cms", "[", "$", "this", "->", "page", "->", "cm", "->", "id", "]", ";", "if", "(", "$", "cm", "->", "icon", ")", "{", "$", "icon", "=", "new", "pix_icon", "(", "$", "cm", "->", "icon", ",", "get_string", "(", "'modulename'", ",", "$", "cm", "->", "modname", ")", ",", "$", "cm", "->", "iconcomponent", ")", ";", "}", "else", "{", "$", "icon", "=", "new", "pix_icon", "(", "'icon'", ",", "get_string", "(", "'modulename'", ",", "$", "cm", "->", "modname", ")", ",", "$", "cm", "->", "modname", ")", ";", "}", "$", "url", "=", "$", "cm", "->", "url", ";", "$", "activitynode", "=", "$", "coursenode", "->", "add", "(", "format_string", "(", "$", "cm", "->", "name", ")", ",", "$", "url", ",", "navigation_node", "::", "TYPE_ACTIVITY", ",", "null", ",", "$", "cm", "->", "id", ",", "$", "icon", ")", ";", "$", "activitynode", "->", "title", "(", "get_string", "(", "'modulename'", ",", "$", "cm", "->", "modname", ")", ")", ";", "$", "activitynode", "->", "hidden", "=", "(", "!", "$", "cm", "->", "visible", ")", ";", "if", "(", "!", "$", "cm", "->", "is_visible_on_course_page", "(", ")", ")", "{", "// Do not show any error here, let the page handle exception that activity is not visible for the current user.", "// Also there may be no exception at all in case when teacher is logged in as student.", "$", "activitynode", "->", "display", "=", "false", ";", "}", "else", "if", "(", "!", "$", "url", ")", "{", "// Don't show activities that don't have links!", "$", "activitynode", "->", "display", "=", "false", ";", "}", "else", "if", "(", "self", "::", "module_extends_navigation", "(", "$", "cm", "->", "modname", ")", ")", "{", "$", "activitynode", "->", "nodetype", "=", "navigation_node", "::", "NODETYPE_BRANCH", ";", "}", "return", "$", "activitynode", ";", "}" ]
Loads a stealth module from unavailable section @param navigation_node $coursenode @param stdClass $modinfo @return navigation_node or null if not accessible
[ "Loads", "a", "stealth", "module", "from", "unavailable", "section" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2212-L2237
215,862
moodle/moodle
lib/navigationlib.php
global_navigation.load_activity
protected function load_activity($cm, stdClass $course, navigation_node $activity) { global $CFG, $DB; // make sure we have a $cm from get_fast_modinfo as this contains activity access details if (!($cm instanceof cm_info)) { $modinfo = get_fast_modinfo($course); $cm = $modinfo->get_cm($cm->id); } $activity->nodetype = navigation_node::NODETYPE_LEAF; $activity->make_active(); $file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php'; $function = $cm->modname.'_extend_navigation'; if (file_exists($file)) { require_once($file); if (function_exists($function)) { $activtyrecord = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST); $function($activity, $course, $activtyrecord, $cm); } } // Allow the active advanced grading method plugin to append module navigation $featuresfunc = $cm->modname.'_supports'; if (function_exists($featuresfunc) && $featuresfunc(FEATURE_ADVANCED_GRADING)) { require_once($CFG->dirroot.'/grade/grading/lib.php'); $gradingman = get_grading_manager($cm->context, 'mod_'.$cm->modname); $gradingman->extend_navigation($this, $activity); } return $activity->has_children(); }
php
protected function load_activity($cm, stdClass $course, navigation_node $activity) { global $CFG, $DB; // make sure we have a $cm from get_fast_modinfo as this contains activity access details if (!($cm instanceof cm_info)) { $modinfo = get_fast_modinfo($course); $cm = $modinfo->get_cm($cm->id); } $activity->nodetype = navigation_node::NODETYPE_LEAF; $activity->make_active(); $file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php'; $function = $cm->modname.'_extend_navigation'; if (file_exists($file)) { require_once($file); if (function_exists($function)) { $activtyrecord = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST); $function($activity, $course, $activtyrecord, $cm); } } // Allow the active advanced grading method plugin to append module navigation $featuresfunc = $cm->modname.'_supports'; if (function_exists($featuresfunc) && $featuresfunc(FEATURE_ADVANCED_GRADING)) { require_once($CFG->dirroot.'/grade/grading/lib.php'); $gradingman = get_grading_manager($cm->context, 'mod_'.$cm->modname); $gradingman->extend_navigation($this, $activity); } return $activity->has_children(); }
[ "protected", "function", "load_activity", "(", "$", "cm", ",", "stdClass", "$", "course", ",", "navigation_node", "$", "activity", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "// make sure we have a $cm from get_fast_modinfo as this contains activity access details", "if", "(", "!", "(", "$", "cm", "instanceof", "cm_info", ")", ")", "{", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "$", "cm", "=", "$", "modinfo", "->", "get_cm", "(", "$", "cm", "->", "id", ")", ";", "}", "$", "activity", "->", "nodetype", "=", "navigation_node", "::", "NODETYPE_LEAF", ";", "$", "activity", "->", "make_active", "(", ")", ";", "$", "file", "=", "$", "CFG", "->", "dirroot", ".", "'/mod/'", ".", "$", "cm", "->", "modname", ".", "'/lib.php'", ";", "$", "function", "=", "$", "cm", "->", "modname", ".", "'_extend_navigation'", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "require_once", "(", "$", "file", ")", ";", "if", "(", "function_exists", "(", "$", "function", ")", ")", "{", "$", "activtyrecord", "=", "$", "DB", "->", "get_record", "(", "$", "cm", "->", "modname", ",", "array", "(", "'id'", "=>", "$", "cm", "->", "instance", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "$", "function", "(", "$", "activity", ",", "$", "course", ",", "$", "activtyrecord", ",", "$", "cm", ")", ";", "}", "}", "// Allow the active advanced grading method plugin to append module navigation", "$", "featuresfunc", "=", "$", "cm", "->", "modname", ".", "'_supports'", ";", "if", "(", "function_exists", "(", "$", "featuresfunc", ")", "&&", "$", "featuresfunc", "(", "FEATURE_ADVANCED_GRADING", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/grade/grading/lib.php'", ")", ";", "$", "gradingman", "=", "get_grading_manager", "(", "$", "cm", "->", "context", ",", "'mod_'", ".", "$", "cm", "->", "modname", ")", ";", "$", "gradingman", "->", "extend_navigation", "(", "$", "this", ",", "$", "activity", ")", ";", "}", "return", "$", "activity", "->", "has_children", "(", ")", ";", "}" ]
Loads the navigation structure for the given activity into the activities node. This method utilises a callback within the modules lib.php file to load the content specific to activity given. The callback is a method: {modulename}_extend_navigation() Examples: * {@link forum_extend_navigation()} * {@link workshop_extend_navigation()} @param cm_info|stdClass $cm @param stdClass $course @param navigation_node $activity @return bool
[ "Loads", "the", "navigation", "structure", "for", "the", "given", "activity", "into", "the", "activities", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2254-L2284
215,863
moodle/moodle
lib/navigationlib.php
global_navigation.module_extends_navigation
public static function module_extends_navigation($modname) { global $CFG; static $extendingmodules = array(); if (!array_key_exists($modname, $extendingmodules)) { $extendingmodules[$modname] = false; $file = $CFG->dirroot.'/mod/'.$modname.'/lib.php'; if (file_exists($file)) { $function = $modname.'_extend_navigation'; require_once($file); $extendingmodules[$modname] = (function_exists($function)); } } return $extendingmodules[$modname]; }
php
public static function module_extends_navigation($modname) { global $CFG; static $extendingmodules = array(); if (!array_key_exists($modname, $extendingmodules)) { $extendingmodules[$modname] = false; $file = $CFG->dirroot.'/mod/'.$modname.'/lib.php'; if (file_exists($file)) { $function = $modname.'_extend_navigation'; require_once($file); $extendingmodules[$modname] = (function_exists($function)); } } return $extendingmodules[$modname]; }
[ "public", "static", "function", "module_extends_navigation", "(", "$", "modname", ")", "{", "global", "$", "CFG", ";", "static", "$", "extendingmodules", "=", "array", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "modname", ",", "$", "extendingmodules", ")", ")", "{", "$", "extendingmodules", "[", "$", "modname", "]", "=", "false", ";", "$", "file", "=", "$", "CFG", "->", "dirroot", ".", "'/mod/'", ".", "$", "modname", ".", "'/lib.php'", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "function", "=", "$", "modname", ".", "'_extend_navigation'", ";", "require_once", "(", "$", "file", ")", ";", "$", "extendingmodules", "[", "$", "modname", "]", "=", "(", "function_exists", "(", "$", "function", ")", ")", ";", "}", "}", "return", "$", "extendingmodules", "[", "$", "modname", "]", ";", "}" ]
This method simply checks to see if a given module can extend the navigation. @todo (MDL-25290) A shared caching solution should be used to save details on what extends navigation. @param string $modname @return bool
[ "This", "method", "simply", "checks", "to", "see", "if", "a", "given", "module", "can", "extend", "the", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2565-L2578
215,864
moodle/moodle
lib/navigationlib.php
global_navigation.get_expand_course_cache
protected function get_expand_course_cache() { if ($this->cacheexpandcourse === null) { $this->cacheexpandcourse = cache::make('core', 'navigation_expandcourse'); } return $this->cacheexpandcourse; }
php
protected function get_expand_course_cache() { if ($this->cacheexpandcourse === null) { $this->cacheexpandcourse = cache::make('core', 'navigation_expandcourse'); } return $this->cacheexpandcourse; }
[ "protected", "function", "get_expand_course_cache", "(", ")", "{", "if", "(", "$", "this", "->", "cacheexpandcourse", "===", "null", ")", "{", "$", "this", "->", "cacheexpandcourse", "=", "cache", "::", "make", "(", "'core'", ",", "'navigation_expandcourse'", ")", ";", "}", "return", "$", "this", "->", "cacheexpandcourse", ";", "}" ]
Returns a cache instance to use for the expand course cache. @return cache_session
[ "Returns", "a", "cache", "instance", "to", "use", "for", "the", "expand", "course", "cache", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2699-L2704
215,865
moodle/moodle
lib/navigationlib.php
global_navigation.can_expand_course
protected function can_expand_course($course) { $cache = $this->get_expand_course_cache(); $canexpand = $cache->get($course->id); if ($canexpand === false) { $canexpand = isloggedin() && can_access_course($course, null, '', true); $canexpand = (int)$canexpand; $cache->set($course->id, $canexpand); } return ($canexpand === 1); }
php
protected function can_expand_course($course) { $cache = $this->get_expand_course_cache(); $canexpand = $cache->get($course->id); if ($canexpand === false) { $canexpand = isloggedin() && can_access_course($course, null, '', true); $canexpand = (int)$canexpand; $cache->set($course->id, $canexpand); } return ($canexpand === 1); }
[ "protected", "function", "can_expand_course", "(", "$", "course", ")", "{", "$", "cache", "=", "$", "this", "->", "get_expand_course_cache", "(", ")", ";", "$", "canexpand", "=", "$", "cache", "->", "get", "(", "$", "course", "->", "id", ")", ";", "if", "(", "$", "canexpand", "===", "false", ")", "{", "$", "canexpand", "=", "isloggedin", "(", ")", "&&", "can_access_course", "(", "$", "course", ",", "null", ",", "''", ",", "true", ")", ";", "$", "canexpand", "=", "(", "int", ")", "$", "canexpand", ";", "$", "cache", "->", "set", "(", "$", "course", "->", "id", ",", "$", "canexpand", ")", ";", "}", "return", "(", "$", "canexpand", "===", "1", ")", ";", "}" ]
Checks if a user can expand a course in the navigation. We use a cache here because in order to be accurate we need to call can_access_course which is a costly function. Because this functionality is basic + non-essential and because we lack good event triggering this cache permits stale data. In the situation the user is granted access to a course after we've initialised this session cache the cache will be stale. It is brought up to date in only one of two ways. 1. The user logs out and in again. 2. The user browses to the course they've just being given access to. Really all this controls is whether the node is shown as expandable or not. It is uber un-important. @param stdClass $course @return bool
[ "Checks", "if", "a", "user", "can", "expand", "a", "course", "in", "the", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2723-L2732
215,866
moodle/moodle
lib/navigationlib.php
global_navigation.is_category_fully_loaded
protected function is_category_fully_loaded($categoryid) { return (array_key_exists($categoryid, $this->addedcategories) && ($this->allcategoriesloaded || $this->addedcategories[$categoryid]->children->count() > 0)); }
php
protected function is_category_fully_loaded($categoryid) { return (array_key_exists($categoryid, $this->addedcategories) && ($this->allcategoriesloaded || $this->addedcategories[$categoryid]->children->count() > 0)); }
[ "protected", "function", "is_category_fully_loaded", "(", "$", "categoryid", ")", "{", "return", "(", "array_key_exists", "(", "$", "categoryid", ",", "$", "this", "->", "addedcategories", ")", "&&", "(", "$", "this", "->", "allcategoriesloaded", "||", "$", "this", "->", "addedcategories", "[", "$", "categoryid", "]", "->", "children", "->", "count", "(", ")", ">", "0", ")", ")", ";", "}" ]
Returns true if the category has already been loaded as have any child categories @param int $categoryid @return bool
[ "Returns", "true", "if", "the", "category", "has", "already", "been", "loaded", "as", "have", "any", "child", "categories" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2740-L2742
215,867
moodle/moodle
lib/navigationlib.php
global_navigation.set_expansion_limit
public function set_expansion_limit($type) { global $SITE; $nodes = $this->find_all_of_type($type); // We only want to hide specific types of nodes. // Only nodes that represent "structure" in the navigation tree should be hidden. // If we hide all nodes then we risk hiding vital information. $typestohide = array( self::TYPE_CATEGORY, self::TYPE_COURSE, self::TYPE_SECTION, self::TYPE_ACTIVITY ); foreach ($nodes as $node) { // We need to generate the full site node if ($type == self::TYPE_COURSE && $node->key == $SITE->id) { continue; } foreach ($node->children as $child) { $child->hide($typestohide); } } return true; }
php
public function set_expansion_limit($type) { global $SITE; $nodes = $this->find_all_of_type($type); // We only want to hide specific types of nodes. // Only nodes that represent "structure" in the navigation tree should be hidden. // If we hide all nodes then we risk hiding vital information. $typestohide = array( self::TYPE_CATEGORY, self::TYPE_COURSE, self::TYPE_SECTION, self::TYPE_ACTIVITY ); foreach ($nodes as $node) { // We need to generate the full site node if ($type == self::TYPE_COURSE && $node->key == $SITE->id) { continue; } foreach ($node->children as $child) { $child->hide($typestohide); } } return true; }
[ "public", "function", "set_expansion_limit", "(", "$", "type", ")", "{", "global", "$", "SITE", ";", "$", "nodes", "=", "$", "this", "->", "find_all_of_type", "(", "$", "type", ")", ";", "// We only want to hide specific types of nodes.", "// Only nodes that represent \"structure\" in the navigation tree should be hidden.", "// If we hide all nodes then we risk hiding vital information.", "$", "typestohide", "=", "array", "(", "self", "::", "TYPE_CATEGORY", ",", "self", "::", "TYPE_COURSE", ",", "self", "::", "TYPE_SECTION", ",", "self", "::", "TYPE_ACTIVITY", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "// We need to generate the full site node", "if", "(", "$", "type", "==", "self", "::", "TYPE_COURSE", "&&", "$", "node", "->", "key", "==", "$", "SITE", "->", "id", ")", "{", "continue", ";", "}", "foreach", "(", "$", "node", "->", "children", "as", "$", "child", ")", "{", "$", "child", "->", "hide", "(", "$", "typestohide", ")", ";", "}", "}", "return", "true", ";", "}" ]
Sets an expansion limit for the navigation The expansion limit is used to prevent the display of content that has a type greater than the provided $type. Can be used to ensure things such as activities or activity content don't get shown on the navigation. They are still generated in order to ensure the navbar still makes sense. @param int $type One of navigation_node::TYPE_* @return bool true when complete.
[ "Sets", "an", "expansion", "limit", "for", "the", "navigation" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2929-L2953
215,868
moodle/moodle
lib/navigationlib.php
global_navigation.get
public function get($key, $type = null) { if (!$this->initialised) { $this->initialise(); } return parent::get($key, $type); }
php
public function get($key, $type = null) { if (!$this->initialised) { $this->initialise(); } return parent::get($key, $type); }
[ "public", "function", "get", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "initialised", ")", "{", "$", "this", "->", "initialise", "(", ")", ";", "}", "return", "parent", "::", "get", "(", "$", "key", ",", "$", "type", ")", ";", "}" ]
Attempts to get the navigation with the given key from this nodes children. This function only looks at this nodes children, it does NOT look recursivily. If the node can't be found then false is returned. If you need to search recursivily then use the {@link global_navigation::find()} method. Note: If you are trying to set the active node {@link navigation_node::override_active_url()} may be of more use to you. @param string|int $key The key of the node you wish to receive. @param int $type One of navigation_node::TYPE_* @return navigation_node|false
[ "Attempts", "to", "get", "the", "navigation", "with", "the", "given", "key", "from", "this", "nodes", "children", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2969-L2974
215,869
moodle/moodle
lib/navigationlib.php
global_navigation.find
public function find($key, $type) { if (!$this->initialised) { $this->initialise(); } if ($type == self::TYPE_ROOTNODE && array_key_exists($key, $this->rootnodes)) { return $this->rootnodes[$key]; } return parent::find($key, $type); }
php
public function find($key, $type) { if (!$this->initialised) { $this->initialise(); } if ($type == self::TYPE_ROOTNODE && array_key_exists($key, $this->rootnodes)) { return $this->rootnodes[$key]; } return parent::find($key, $type); }
[ "public", "function", "find", "(", "$", "key", ",", "$", "type", ")", "{", "if", "(", "!", "$", "this", "->", "initialised", ")", "{", "$", "this", "->", "initialise", "(", ")", ";", "}", "if", "(", "$", "type", "==", "self", "::", "TYPE_ROOTNODE", "&&", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "rootnodes", ")", ")", "{", "return", "$", "this", "->", "rootnodes", "[", "$", "key", "]", ";", "}", "return", "parent", "::", "find", "(", "$", "key", ",", "$", "type", ")", ";", "}" ]
Searches this nodes children and their children to find a navigation node with the matching key and type. This method is recursive and searches children so until either a node is found or there are no more nodes to search. If you know that the node being searched for is a child of this node then use the {@link global_navigation::get()} method instead. Note: If you are trying to set the active node {@link navigation_node::override_active_url()} may be of more use to you. @param string|int $key The key of the node you wish to receive. @param int $type One of navigation_node::TYPE_* @return navigation_node|false
[ "Searches", "this", "nodes", "children", "and", "their", "children", "to", "find", "a", "navigation", "node", "with", "the", "matching", "key", "and", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L2993-L3001
215,870
moodle/moodle
lib/navigationlib.php
navbar.has_items
public function has_items() { if ($this->duringinstall) { return false; } else if ($this->hasitems !== false) { return true; } if (count($this->children) > 0 || count($this->prependchildren) > 0) { // There have been manually added items - there are definitely items. $outcome = true; } else if (!$this->ignoreactive) { // We will need to initialise the navigation structure to check if there are active items. $this->page->navigation->initialise($this->page); $outcome = ($this->page->navigation->contains_active_node() || $this->page->settingsnav->contains_active_node()); } $this->hasitems = $outcome; return $outcome; }
php
public function has_items() { if ($this->duringinstall) { return false; } else if ($this->hasitems !== false) { return true; } if (count($this->children) > 0 || count($this->prependchildren) > 0) { // There have been manually added items - there are definitely items. $outcome = true; } else if (!$this->ignoreactive) { // We will need to initialise the navigation structure to check if there are active items. $this->page->navigation->initialise($this->page); $outcome = ($this->page->navigation->contains_active_node() || $this->page->settingsnav->contains_active_node()); } $this->hasitems = $outcome; return $outcome; }
[ "public", "function", "has_items", "(", ")", "{", "if", "(", "$", "this", "->", "duringinstall", ")", "{", "return", "false", ";", "}", "else", "if", "(", "$", "this", "->", "hasitems", "!==", "false", ")", "{", "return", "true", ";", "}", "if", "(", "count", "(", "$", "this", "->", "children", ")", ">", "0", "||", "count", "(", "$", "this", "->", "prependchildren", ")", ">", "0", ")", "{", "// There have been manually added items - there are definitely items.", "$", "outcome", "=", "true", ";", "}", "else", "if", "(", "!", "$", "this", "->", "ignoreactive", ")", "{", "// We will need to initialise the navigation structure to check if there are active items.", "$", "this", "->", "page", "->", "navigation", "->", "initialise", "(", "$", "this", "->", "page", ")", ";", "$", "outcome", "=", "(", "$", "this", "->", "page", "->", "navigation", "->", "contains_active_node", "(", ")", "||", "$", "this", "->", "page", "->", "settingsnav", "->", "contains_active_node", "(", ")", ")", ";", "}", "$", "this", "->", "hasitems", "=", "$", "outcome", ";", "return", "$", "outcome", ";", "}" ]
Quick check to see if the navbar will have items in. @return bool Returns true if the navbar will have items, false otherwise
[ "Quick", "check", "to", "see", "if", "the", "navbar", "will", "have", "items", "in", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3447-L3463
215,871
moodle/moodle
lib/navigationlib.php
navbar.get
public function get($key, $type = null) { foreach ($this->children as &$child) { if ($child->key === $key && ($type == null || $type == $child->type)) { return $child; } } foreach ($this->prependchildren as &$child) { if ($child->key === $key && ($type == null || $type == $child->type)) { return $child; } } return false; }
php
public function get($key, $type = null) { foreach ($this->children as &$child) { if ($child->key === $key && ($type == null || $type == $child->type)) { return $child; } } foreach ($this->prependchildren as &$child) { if ($child->key === $key && ($type == null || $type == $child->type)) { return $child; } } return false; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "type", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "&", "$", "child", ")", "{", "if", "(", "$", "child", "->", "key", "===", "$", "key", "&&", "(", "$", "type", "==", "null", "||", "$", "type", "==", "$", "child", "->", "type", ")", ")", "{", "return", "$", "child", ";", "}", "}", "foreach", "(", "$", "this", "->", "prependchildren", "as", "&", "$", "child", ")", "{", "if", "(", "$", "child", "->", "key", "===", "$", "key", "&&", "(", "$", "type", "==", "null", "||", "$", "type", "==", "$", "child", "->", "type", ")", ")", "{", "return", "$", "child", ";", "}", "}", "return", "false", ";", "}" ]
Gets a navigation node @param string|int $key for referencing the navbar nodes @param int $type breadcrumb_navigation_node::TYPE_* @return breadcrumb_navigation_node|bool
[ "Gets", "a", "navigation", "node" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3481-L3493
215,872
moodle/moodle
lib/navigationlib.php
navbar.get_course_categories
private function get_course_categories() { global $CFG; require_once($CFG->dirroot.'/course/lib.php'); $categories = array(); $cap = 'moodle/category:viewhiddencategories'; $showcategories = !core_course_category::is_simple_site(); if ($showcategories) { foreach ($this->page->categories as $category) { $context = context_coursecat::instance($category->id); if (!core_course_category::can_view_category($category)) { continue; } $url = new moodle_url('/course/index.php', array('categoryid' => $category->id)); $name = format_string($category->name, true, array('context' => $context)); $categorynode = breadcrumb_navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id); if (!$category->visible) { $categorynode->hidden = true; } $categories[] = $categorynode; } } // Don't show the 'course' node if enrolled in this course. if (!is_enrolled(context_course::instance($this->page->course->id, null, '', true))) { $courses = $this->page->navigation->get('courses'); if (!$courses) { // Courses node may not be present. $courses = breadcrumb_navigation_node::create( get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_CONTAINER ); } $categories[] = $courses; } return $categories; }
php
private function get_course_categories() { global $CFG; require_once($CFG->dirroot.'/course/lib.php'); $categories = array(); $cap = 'moodle/category:viewhiddencategories'; $showcategories = !core_course_category::is_simple_site(); if ($showcategories) { foreach ($this->page->categories as $category) { $context = context_coursecat::instance($category->id); if (!core_course_category::can_view_category($category)) { continue; } $url = new moodle_url('/course/index.php', array('categoryid' => $category->id)); $name = format_string($category->name, true, array('context' => $context)); $categorynode = breadcrumb_navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id); if (!$category->visible) { $categorynode->hidden = true; } $categories[] = $categorynode; } } // Don't show the 'course' node if enrolled in this course. if (!is_enrolled(context_course::instance($this->page->course->id, null, '', true))) { $courses = $this->page->navigation->get('courses'); if (!$courses) { // Courses node may not be present. $courses = breadcrumb_navigation_node::create( get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_CONTAINER ); } $categories[] = $courses; } return $categories; }
[ "private", "function", "get_course_categories", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "$", "categories", "=", "array", "(", ")", ";", "$", "cap", "=", "'moodle/category:viewhiddencategories'", ";", "$", "showcategories", "=", "!", "core_course_category", "::", "is_simple_site", "(", ")", ";", "if", "(", "$", "showcategories", ")", "{", "foreach", "(", "$", "this", "->", "page", "->", "categories", "as", "$", "category", ")", "{", "$", "context", "=", "context_coursecat", "::", "instance", "(", "$", "category", "->", "id", ")", ";", "if", "(", "!", "core_course_category", "::", "can_view_category", "(", "$", "category", ")", ")", "{", "continue", ";", "}", "$", "url", "=", "new", "moodle_url", "(", "'/course/index.php'", ",", "array", "(", "'categoryid'", "=>", "$", "category", "->", "id", ")", ")", ";", "$", "name", "=", "format_string", "(", "$", "category", "->", "name", ",", "true", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "categorynode", "=", "breadcrumb_navigation_node", "::", "create", "(", "$", "name", ",", "$", "url", ",", "self", "::", "TYPE_CATEGORY", ",", "null", ",", "$", "category", "->", "id", ")", ";", "if", "(", "!", "$", "category", "->", "visible", ")", "{", "$", "categorynode", "->", "hidden", "=", "true", ";", "}", "$", "categories", "[", "]", "=", "$", "categorynode", ";", "}", "}", "// Don't show the 'course' node if enrolled in this course.", "if", "(", "!", "is_enrolled", "(", "context_course", "::", "instance", "(", "$", "this", "->", "page", "->", "course", "->", "id", ",", "null", ",", "''", ",", "true", ")", ")", ")", "{", "$", "courses", "=", "$", "this", "->", "page", "->", "navigation", "->", "get", "(", "'courses'", ")", ";", "if", "(", "!", "$", "courses", ")", "{", "// Courses node may not be present.", "$", "courses", "=", "breadcrumb_navigation_node", "::", "create", "(", "get_string", "(", "'courses'", ")", ",", "new", "moodle_url", "(", "'/course/index.php'", ")", ",", "self", "::", "TYPE_CONTAINER", ")", ";", "}", "$", "categories", "[", "]", "=", "$", "courses", ";", "}", "return", "$", "categories", ";", "}" ]
Get the list of categories leading to this course. This function is used by {@link navbar::get_items()} to add back the "courses" node and category chain leading to the current course. Note that this is only ever called for the current course, so we don't need to bother taking in any parameters. @return array
[ "Get", "the", "list", "of", "categories", "leading", "to", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3603-L3642
215,873
moodle/moodle
lib/navigationlib.php
flat_navigation_node.get_collectionlabel
public function get_collectionlabel() { if (!empty($this->collectionlabel)) { return $this->collectionlabel; } if ($this->parent && ($this->parent instanceof flat_navigation_node || $this->parent instanceof flat_navigation)) { return $this->parent->get_collectionlabel(); } debugging('Navigation region requires a label', DEBUG_DEVELOPER); return ''; }
php
public function get_collectionlabel() { if (!empty($this->collectionlabel)) { return $this->collectionlabel; } if ($this->parent && ($this->parent instanceof flat_navigation_node || $this->parent instanceof flat_navigation)) { return $this->parent->get_collectionlabel(); } debugging('Navigation region requires a label', DEBUG_DEVELOPER); return ''; }
[ "public", "function", "get_collectionlabel", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "collectionlabel", ")", ")", "{", "return", "$", "this", "->", "collectionlabel", ";", "}", "if", "(", "$", "this", "->", "parent", "&&", "(", "$", "this", "->", "parent", "instanceof", "flat_navigation_node", "||", "$", "this", "->", "parent", "instanceof", "flat_navigation", ")", ")", "{", "return", "$", "this", "->", "parent", "->", "get_collectionlabel", "(", ")", ";", "}", "debugging", "(", "'Navigation region requires a label'", ",", "DEBUG_DEVELOPER", ")", ";", "return", "''", ";", "}" ]
Getter, get the label for this flat_navigation node, or it's parent if it doesn't have one. @return string
[ "Getter", "get", "the", "label", "for", "this", "flat_navigation", "node", "or", "it", "s", "parent", "if", "it", "doesn", "t", "have", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3846-L3855
215,874
moodle/moodle
lib/navigationlib.php
flat_navigation_node.isactive
public function isactive() { global $PAGE; if ($this->is_section()) { $active = $PAGE->navigation->find_active_node(); while ($active = $active->parent) { if ($active->key == $this->key && $active->type == $this->type) { return true; } } } return $this->isactive; }
php
public function isactive() { global $PAGE; if ($this->is_section()) { $active = $PAGE->navigation->find_active_node(); while ($active = $active->parent) { if ($active->key == $this->key && $active->type == $this->type) { return true; } } } return $this->isactive; }
[ "public", "function", "isactive", "(", ")", "{", "global", "$", "PAGE", ";", "if", "(", "$", "this", "->", "is_section", "(", ")", ")", "{", "$", "active", "=", "$", "PAGE", "->", "navigation", "->", "find_active_node", "(", ")", ";", "while", "(", "$", "active", "=", "$", "active", "->", "parent", ")", "{", "if", "(", "$", "active", "->", "key", "==", "$", "this", "->", "key", "&&", "$", "active", "->", "type", "==", "$", "this", "->", "type", ")", "{", "return", "true", ";", "}", "}", "}", "return", "$", "this", "->", "isactive", ";", "}" ]
In flat navigation - sections are active if we are looking at activities in the section. @return boolean
[ "In", "flat", "navigation", "-", "sections", "are", "active", "if", "we", "are", "looking", "at", "activities", "in", "the", "section", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3869-L3881
215,875
moodle/moodle
lib/navigationlib.php
flat_navigation_node.set_showdivider
public function set_showdivider($val, $label = '') { $this->showdivider = $val; if ($this->showdivider && empty($label)) { debugging('Navigation region requires a label', DEBUG_DEVELOPER); } else { $this->set_collectionlabel($label); } }
php
public function set_showdivider($val, $label = '') { $this->showdivider = $val; if ($this->showdivider && empty($label)) { debugging('Navigation region requires a label', DEBUG_DEVELOPER); } else { $this->set_collectionlabel($label); } }
[ "public", "function", "set_showdivider", "(", "$", "val", ",", "$", "label", "=", "''", ")", "{", "$", "this", "->", "showdivider", "=", "$", "val", ";", "if", "(", "$", "this", "->", "showdivider", "&&", "empty", "(", "$", "label", ")", ")", "{", "debugging", "(", "'Navigation region requires a label'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "else", "{", "$", "this", "->", "set_collectionlabel", "(", "$", "label", ")", ";", "}", "}" ]
Setter for "showdivider" @param $val boolean @param $label string Label for the group of nodes
[ "Setter", "for", "showdivider" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L3896-L3903
215,876
moodle/moodle
lib/navigationlib.php
flat_navigation.add
public function add(navigation_node $node, $beforekey=null) { $result = parent::add($node, $beforekey); // Extend the parent to get a name for the collection of nodes if required. if (empty($this->collectionlabel)) { if ($node instanceof flat_navigation_node) { $this->set_collectionlabel($node->get_collectionlabel()); } } return $result; }
php
public function add(navigation_node $node, $beforekey=null) { $result = parent::add($node, $beforekey); // Extend the parent to get a name for the collection of nodes if required. if (empty($this->collectionlabel)) { if ($node instanceof flat_navigation_node) { $this->set_collectionlabel($node->get_collectionlabel()); } } return $result; }
[ "public", "function", "add", "(", "navigation_node", "$", "node", ",", "$", "beforekey", "=", "null", ")", "{", "$", "result", "=", "parent", "::", "add", "(", "$", "node", ",", "$", "beforekey", ")", ";", "// Extend the parent to get a name for the collection of nodes if required.", "if", "(", "empty", "(", "$", "this", "->", "collectionlabel", ")", ")", "{", "if", "(", "$", "node", "instanceof", "flat_navigation_node", ")", "{", "$", "this", "->", "set_collectionlabel", "(", "$", "node", "->", "get_collectionlabel", "(", ")", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Override the parent so we can set a label for this collection if it has not been set yet. @param navigation_node $node Node to add @param string $beforekey If specified, adds before a node with this key, otherwise adds at end @return navigation_node Added node
[ "Override", "the", "parent", "so", "we", "can", "set", "a", "label", "for", "this", "collection", "if", "it", "has", "not", "been", "set", "yet", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4050-L4060
215,877
moodle/moodle
lib/navigationlib.php
settings_navigation.add
public function add($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { $node = parent::add($text, $url, $type, $shorttext, $key, $icon); $node->add_class('root_node'); return $node; }
php
public function add($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { $node = parent::add($text, $url, $type, $shorttext, $key, $icon); $node->add_class('root_node'); return $node; }
[ "public", "function", "add", "(", "$", "text", ",", "$", "url", "=", "null", ",", "$", "type", "=", "null", ",", "$", "shorttext", "=", "null", ",", "$", "key", "=", "null", ",", "pix_icon", "$", "icon", "=", "null", ")", "{", "$", "node", "=", "parent", "::", "add", "(", "$", "text", ",", "$", "url", ",", "$", "type", ",", "$", "shorttext", ",", "$", "key", ",", "$", "icon", ")", ";", "$", "node", "->", "add_class", "(", "'root_node'", ")", ";", "return", "$", "node", ";", "}" ]
Override the parent function so that we can add preceeding hr's and set a root node class against all first level element It does this by first calling the parent's add method {@link navigation_node::add()} and then proceeds to use the key to set class and hr @param string $text text to be used for the link. @param string|moodle_url $url url for the new node @param int $type the type of node navigation_node::TYPE_* @param string $shorttext @param string|int $key a key to access the node by. @param pix_icon $icon An icon that appears next to the node. @return navigation_node with the new node added to it.
[ "Override", "the", "parent", "function", "so", "that", "we", "can", "add", "preceeding", "hr", "s", "and", "set", "a", "root", "node", "class", "against", "all", "first", "level", "element" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4233-L4237
215,878
moodle/moodle
lib/navigationlib.php
settings_navigation.prepend
public function prepend($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { $children = $this->children; $childrenclass = get_class($children); $this->children = new $childrenclass; $node = $this->add($text, $url, $type, $shorttext, $key, $icon); foreach ($children as $child) { $this->children->add($child); } return $node; }
php
public function prepend($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { $children = $this->children; $childrenclass = get_class($children); $this->children = new $childrenclass; $node = $this->add($text, $url, $type, $shorttext, $key, $icon); foreach ($children as $child) { $this->children->add($child); } return $node; }
[ "public", "function", "prepend", "(", "$", "text", ",", "$", "url", "=", "null", ",", "$", "type", "=", "null", ",", "$", "shorttext", "=", "null", ",", "$", "key", "=", "null", ",", "pix_icon", "$", "icon", "=", "null", ")", "{", "$", "children", "=", "$", "this", "->", "children", ";", "$", "childrenclass", "=", "get_class", "(", "$", "children", ")", ";", "$", "this", "->", "children", "=", "new", "$", "childrenclass", ";", "$", "node", "=", "$", "this", "->", "add", "(", "$", "text", ",", "$", "url", ",", "$", "type", ",", "$", "shorttext", ",", "$", "key", ",", "$", "icon", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "children", "->", "add", "(", "$", "child", ")", ";", "}", "return", "$", "node", ";", "}" ]
This function allows the user to add something to the start of the settings navigation, which means it will be at the top of the settings navigation block @param string $text text to be used for the link. @param string|moodle_url $url url for the new node @param int $type the type of node navigation_node::TYPE_* @param string $shorttext @param string|int $key a key to access the node by. @param pix_icon $icon An icon that appears next to the node. @return navigation_node $node with the new node added to it.
[ "This", "function", "allows", "the", "user", "to", "add", "something", "to", "the", "start", "of", "the", "settings", "navigation", "which", "means", "it", "will", "be", "at", "the", "top", "of", "the", "settings", "navigation", "block" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4251-L4260
215,879
moodle/moodle
lib/navigationlib.php
settings_navigation.is_admin_tree_needed
protected function is_admin_tree_needed() { if (self::$loadadmintree) { // Usually external admin page or settings page. return true; } if ($this->page->pagelayout === 'admin' or strpos($this->page->pagetype, 'admin-') === 0) { // Admin settings tree is intended for system level settings and management only, use navigation for the rest! if ($this->page->context->contextlevel != CONTEXT_SYSTEM) { return false; } return true; } return false; }
php
protected function is_admin_tree_needed() { if (self::$loadadmintree) { // Usually external admin page or settings page. return true; } if ($this->page->pagelayout === 'admin' or strpos($this->page->pagetype, 'admin-') === 0) { // Admin settings tree is intended for system level settings and management only, use navigation for the rest! if ($this->page->context->contextlevel != CONTEXT_SYSTEM) { return false; } return true; } return false; }
[ "protected", "function", "is_admin_tree_needed", "(", ")", "{", "if", "(", "self", "::", "$", "loadadmintree", ")", "{", "// Usually external admin page or settings page.", "return", "true", ";", "}", "if", "(", "$", "this", "->", "page", "->", "pagelayout", "===", "'admin'", "or", "strpos", "(", "$", "this", "->", "page", "->", "pagetype", ",", "'admin-'", ")", "===", "0", ")", "{", "// Admin settings tree is intended for system level settings and management only, use navigation for the rest!", "if", "(", "$", "this", "->", "page", "->", "context", "->", "contextlevel", "!=", "CONTEXT_SYSTEM", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Does this page require loading of full admin tree or is it enough rely on AJAX? @return bool
[ "Does", "this", "page", "require", "loading", "of", "full", "admin", "tree", "or", "is", "it", "enough", "rely", "on", "AJAX?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4268-L4283
215,880
moodle/moodle
lib/navigationlib.php
settings_navigation.scan_for_active_node
protected function scan_for_active_node(navigation_node $node) { if (!$node->check_if_active() && $node->children->count()>0) { foreach ($node->children as &$child) { $this->scan_for_active_node($child); } } }
php
protected function scan_for_active_node(navigation_node $node) { if (!$node->check_if_active() && $node->children->count()>0) { foreach ($node->children as &$child) { $this->scan_for_active_node($child); } } }
[ "protected", "function", "scan_for_active_node", "(", "navigation_node", "$", "node", ")", "{", "if", "(", "!", "$", "node", "->", "check_if_active", "(", ")", "&&", "$", "node", "->", "children", "->", "count", "(", ")", ">", "0", ")", "{", "foreach", "(", "$", "node", "->", "children", "as", "&", "$", "child", ")", "{", "$", "this", "->", "scan_for_active_node", "(", "$", "child", ")", ";", "}", "}", "}" ]
This function recursivily scans nodes until it finds the active node or there are no more nodes. @param navigation_node $node
[ "This", "function", "recursivily", "scans", "nodes", "until", "it", "finds", "the", "active", "node", "or", "there", "are", "no", "more", "nodes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4376-L4382
215,881
moodle/moodle
lib/navigationlib.php
settings_navigation.get_by_path
protected function get_by_path(array $path) { $node = $this->get(array_shift($path)); foreach ($path as $key) { $node->get($key); } return $node; }
php
protected function get_by_path(array $path) { $node = $this->get(array_shift($path)); foreach ($path as $key) { $node->get($key); } return $node; }
[ "protected", "function", "get_by_path", "(", "array", "$", "path", ")", "{", "$", "node", "=", "$", "this", "->", "get", "(", "array_shift", "(", "$", "path", ")", ")", ";", "foreach", "(", "$", "path", "as", "$", "key", ")", "{", "$", "node", "->", "get", "(", "$", "key", ")", ";", "}", "return", "$", "node", ";", "}" ]
Gets a navigation node given an array of keys that represent the path to the desired node. @param array $path @return navigation_node|false
[ "Gets", "a", "navigation", "node", "given", "an", "array", "of", "keys", "that", "represent", "the", "path", "to", "the", "desired", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4391-L4397
215,882
moodle/moodle
lib/navigationlib.php
settings_navigation.load_user_settings
protected function load_user_settings($courseid = SITEID) { global $USER, $CFG; if (isguestuser() || !isloggedin()) { return false; } $navusers = $this->page->navigation->get_extending_users(); if (count($this->userstoextendfor) > 0 || count($navusers) > 0) { $usernode = null; foreach ($this->userstoextendfor as $userid) { if ($userid == $USER->id) { continue; } $node = $this->generate_user_settings($courseid, $userid, 'userviewingsettings'); if (is_null($usernode)) { $usernode = $node; } } foreach ($navusers as $user) { if ($user->id == $USER->id) { continue; } $node = $this->generate_user_settings($courseid, $user->id, 'userviewingsettings'); if (is_null($usernode)) { $usernode = $node; } } $this->generate_user_settings($courseid, $USER->id); } else { $usernode = $this->generate_user_settings($courseid, $USER->id); } return $usernode; }
php
protected function load_user_settings($courseid = SITEID) { global $USER, $CFG; if (isguestuser() || !isloggedin()) { return false; } $navusers = $this->page->navigation->get_extending_users(); if (count($this->userstoextendfor) > 0 || count($navusers) > 0) { $usernode = null; foreach ($this->userstoextendfor as $userid) { if ($userid == $USER->id) { continue; } $node = $this->generate_user_settings($courseid, $userid, 'userviewingsettings'); if (is_null($usernode)) { $usernode = $node; } } foreach ($navusers as $user) { if ($user->id == $USER->id) { continue; } $node = $this->generate_user_settings($courseid, $user->id, 'userviewingsettings'); if (is_null($usernode)) { $usernode = $node; } } $this->generate_user_settings($courseid, $USER->id); } else { $usernode = $this->generate_user_settings($courseid, $USER->id); } return $usernode; }
[ "protected", "function", "load_user_settings", "(", "$", "courseid", "=", "SITEID", ")", "{", "global", "$", "USER", ",", "$", "CFG", ";", "if", "(", "isguestuser", "(", ")", "||", "!", "isloggedin", "(", ")", ")", "{", "return", "false", ";", "}", "$", "navusers", "=", "$", "this", "->", "page", "->", "navigation", "->", "get_extending_users", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "userstoextendfor", ")", ">", "0", "||", "count", "(", "$", "navusers", ")", ">", "0", ")", "{", "$", "usernode", "=", "null", ";", "foreach", "(", "$", "this", "->", "userstoextendfor", "as", "$", "userid", ")", "{", "if", "(", "$", "userid", "==", "$", "USER", "->", "id", ")", "{", "continue", ";", "}", "$", "node", "=", "$", "this", "->", "generate_user_settings", "(", "$", "courseid", ",", "$", "userid", ",", "'userviewingsettings'", ")", ";", "if", "(", "is_null", "(", "$", "usernode", ")", ")", "{", "$", "usernode", "=", "$", "node", ";", "}", "}", "foreach", "(", "$", "navusers", "as", "$", "user", ")", "{", "if", "(", "$", "user", "->", "id", "==", "$", "USER", "->", "id", ")", "{", "continue", ";", "}", "$", "node", "=", "$", "this", "->", "generate_user_settings", "(", "$", "courseid", ",", "$", "user", "->", "id", ",", "'userviewingsettings'", ")", ";", "if", "(", "is_null", "(", "$", "usernode", ")", ")", "{", "$", "usernode", "=", "$", "node", ";", "}", "}", "$", "this", "->", "generate_user_settings", "(", "$", "courseid", ",", "$", "USER", "->", "id", ")", ";", "}", "else", "{", "$", "usernode", "=", "$", "this", "->", "generate_user_settings", "(", "$", "courseid", ",", "$", "USER", "->", "id", ")", ";", "}", "return", "$", "usernode", ";", "}" ]
Loads the user settings block of the settings nav This function is simply works out the userid and whether we need to load just the current users profile settings, or the current user and the user the current user is viewing. This function has some very ugly code to work out the user, if anyone has any bright ideas please feel free to intervene. @param int $courseid The course id of the current course @return navigation_node|false
[ "Loads", "the", "user", "settings", "block", "of", "the", "settings", "nav" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4701-L4735
215,883
moodle/moodle
lib/navigationlib.php
settings_navigation.extend_for_user
public function extend_for_user($userid) { global $CFG; if (!in_array($userid, $this->userstoextendfor)) { $this->userstoextendfor[] = $userid; if ($this->initialised) { $this->generate_user_settings($this->page->course->id, $userid, 'userviewingsettings'); $children = array(); foreach ($this->children as $child) { $children[] = $child; } array_unshift($children, array_pop($children)); $this->children = new navigation_node_collection(); foreach ($children as $child) { $this->children->add($child); } } } }
php
public function extend_for_user($userid) { global $CFG; if (!in_array($userid, $this->userstoextendfor)) { $this->userstoextendfor[] = $userid; if ($this->initialised) { $this->generate_user_settings($this->page->course->id, $userid, 'userviewingsettings'); $children = array(); foreach ($this->children as $child) { $children[] = $child; } array_unshift($children, array_pop($children)); $this->children = new navigation_node_collection(); foreach ($children as $child) { $this->children->add($child); } } } }
[ "public", "function", "extend_for_user", "(", "$", "userid", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "in_array", "(", "$", "userid", ",", "$", "this", "->", "userstoextendfor", ")", ")", "{", "$", "this", "->", "userstoextendfor", "[", "]", "=", "$", "userid", ";", "if", "(", "$", "this", "->", "initialised", ")", "{", "$", "this", "->", "generate_user_settings", "(", "$", "this", "->", "page", "->", "course", "->", "id", ",", "$", "userid", ",", "'userviewingsettings'", ")", ";", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "children", "[", "]", "=", "$", "child", ";", "}", "array_unshift", "(", "$", "children", ",", "array_pop", "(", "$", "children", ")", ")", ";", "$", "this", "->", "children", "=", "new", "navigation_node_collection", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "children", "->", "add", "(", "$", "child", ")", ";", "}", "}", "}", "}" ]
Extends the settings navigation for the given user. Note: This method gets called automatically if you call $PAGE->navigation->extend_for_user($userid) @param int $userid
[ "Extends", "the", "settings", "navigation", "for", "the", "given", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L4745-L4763
215,884
moodle/moodle
lib/navigationlib.php
settings_navigation.load_block_settings
protected function load_block_settings() { global $CFG; $blocknode = $this->add($this->context->get_context_name(), null, self::TYPE_SETTING, null, 'blocksettings'); $blocknode->force_open(); // Assign local roles if (get_assignable_roles($this->context, ROLENAME_ORIGINAL)) { $assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $this->context->id)); $blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING, null, 'roles', new pix_icon('i/assignroles', '')); } // Override roles if (has_capability('moodle/role:review', $this->context) or count(get_overridable_roles($this->context))>0) { $url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->context->id)); $blocknode->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'), $this->context)) { $url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->context->id)); $blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', '')); } // Add the context locking node. $this->add_context_locking_node($blocknode, $this->context); return $blocknode; }
php
protected function load_block_settings() { global $CFG; $blocknode = $this->add($this->context->get_context_name(), null, self::TYPE_SETTING, null, 'blocksettings'); $blocknode->force_open(); // Assign local roles if (get_assignable_roles($this->context, ROLENAME_ORIGINAL)) { $assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $this->context->id)); $blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING, null, 'roles', new pix_icon('i/assignroles', '')); } // Override roles if (has_capability('moodle/role:review', $this->context) or count(get_overridable_roles($this->context))>0) { $url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->context->id)); $blocknode->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'), $this->context)) { $url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->context->id)); $blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', '')); } // Add the context locking node. $this->add_context_locking_node($blocknode, $this->context); return $blocknode; }
[ "protected", "function", "load_block_settings", "(", ")", "{", "global", "$", "CFG", ";", "$", "blocknode", "=", "$", "this", "->", "add", "(", "$", "this", "->", "context", "->", "get_context_name", "(", ")", ",", "null", ",", "self", "::", "TYPE_SETTING", ",", "null", ",", "'blocksettings'", ")", ";", "$", "blocknode", "->", "force_open", "(", ")", ";", "// Assign local roles", "if", "(", "get_assignable_roles", "(", "$", "this", "->", "context", ",", "ROLENAME_ORIGINAL", ")", ")", "{", "$", "assignurl", "=", "new", "moodle_url", "(", "'/'", ".", "$", "CFG", "->", "admin", ".", "'/roles/assign.php'", ",", "array", "(", "'contextid'", "=>", "$", "this", "->", "context", "->", "id", ")", ")", ";", "$", "blocknode", "->", "add", "(", "get_string", "(", "'assignroles'", ",", "'role'", ")", ",", "$", "assignurl", ",", "self", "::", "TYPE_SETTING", ",", "null", ",", "'roles'", ",", "new", "pix_icon", "(", "'i/assignroles'", ",", "''", ")", ")", ";", "}", "// Override roles", "if", "(", "has_capability", "(", "'moodle/role:review'", ",", "$", "this", "->", "context", ")", "or", "count", "(", "get_overridable_roles", "(", "$", "this", "->", "context", ")", ")", ">", "0", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "'/'", ".", "$", "CFG", "->", "admin", ".", "'/roles/permissions.php'", ",", "array", "(", "'contextid'", "=>", "$", "this", "->", "context", "->", "id", ")", ")", ";", "$", "blocknode", "->", "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'", ")", ",", "$", "this", "->", "context", ")", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "'/'", ".", "$", "CFG", "->", "admin", ".", "'/roles/check.php'", ",", "array", "(", "'contextid'", "=>", "$", "this", "->", "context", "->", "id", ")", ")", ";", "$", "blocknode", "->", "add", "(", "get_string", "(", "'checkpermissions'", ",", "'role'", ")", ",", "$", "url", ",", "self", "::", "TYPE_SETTING", ",", "null", ",", "'checkpermissions'", ",", "new", "pix_icon", "(", "'i/checkpermissions'", ",", "''", ")", ")", ";", "}", "// Add the context locking node.", "$", "this", "->", "add_context_locking_node", "(", "$", "blocknode", ",", "$", "this", "->", "context", ")", ";", "return", "$", "blocknode", ";", "}" ]
Loads block specific settings in the navigation @return navigation_node
[ "Loads", "block", "specific", "settings", "in", "the", "navigation" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5197-L5227
215,885
moodle/moodle
lib/navigationlib.php
settings_navigation.can_view_user_preferences
public function can_view_user_preferences($userid) { if (is_siteadmin()) { return true; } // See if any nodes are present in the preferences section for this user. $preferencenode = $this->find('userviewingsettings' . $userid, null); if ($preferencenode && $preferencenode->has_children()) { // Run through each child node. foreach ($preferencenode->children as $childnode) { // If the child node has children then this user has access to a link in the preferences page. if ($childnode->has_children()) { return true; } } } // No links found for the user to access on the preferences page. return false; }
php
public function can_view_user_preferences($userid) { if (is_siteadmin()) { return true; } // See if any nodes are present in the preferences section for this user. $preferencenode = $this->find('userviewingsettings' . $userid, null); if ($preferencenode && $preferencenode->has_children()) { // Run through each child node. foreach ($preferencenode->children as $childnode) { // If the child node has children then this user has access to a link in the preferences page. if ($childnode->has_children()) { return true; } } } // No links found for the user to access on the preferences page. return false; }
[ "public", "function", "can_view_user_preferences", "(", "$", "userid", ")", "{", "if", "(", "is_siteadmin", "(", ")", ")", "{", "return", "true", ";", "}", "// See if any nodes are present in the preferences section for this user.", "$", "preferencenode", "=", "$", "this", "->", "find", "(", "'userviewingsettings'", ".", "$", "userid", ",", "null", ")", ";", "if", "(", "$", "preferencenode", "&&", "$", "preferencenode", "->", "has_children", "(", ")", ")", "{", "// Run through each child node.", "foreach", "(", "$", "preferencenode", "->", "children", "as", "$", "childnode", ")", "{", "// If the child node has children then this user has access to a link in the preferences page.", "if", "(", "$", "childnode", "->", "has_children", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "// No links found for the user to access on the preferences page.", "return", "false", ";", "}" ]
Checks to see if there are child nodes available in the specific user's preference node. If so, then they have the appropriate permissions view this user's preferences. @since Moodle 2.9.3 @param int $userid The user's ID. @return bool True if child nodes exist to view, otherwise false.
[ "Checks", "to", "see", "if", "there", "are", "child", "nodes", "available", "in", "the", "specific", "user", "s", "preference", "node", ".", "If", "so", "then", "they", "have", "the", "appropriate", "permissions", "view", "this", "user", "s", "preferences", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5475-L5492
215,886
moodle/moodle
lib/navigationlib.php
settings_navigation_ajax.initialise
public function initialise() { if ($this->initialised || during_initial_install()) { return false; } $this->context = $this->page->context; $this->load_administration_settings(); // Check if local plugins is adding node to site admin. $this->load_local_plugin_settings(); $this->initialised = true; }
php
public function initialise() { if ($this->initialised || during_initial_install()) { return false; } $this->context = $this->page->context; $this->load_administration_settings(); // Check if local plugins is adding node to site admin. $this->load_local_plugin_settings(); $this->initialised = true; }
[ "public", "function", "initialise", "(", ")", "{", "if", "(", "$", "this", "->", "initialised", "||", "during_initial_install", "(", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "context", "=", "$", "this", "->", "page", "->", "context", ";", "$", "this", "->", "load_administration_settings", "(", ")", ";", "// Check if local plugins is adding node to site admin.", "$", "this", "->", "load_local_plugin_settings", "(", ")", ";", "$", "this", "->", "initialised", "=", "true", ";", "}" ]
Initialise the site admin navigation. @return array An array of the expandable nodes
[ "Initialise", "the", "site", "admin", "navigation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5521-L5532
215,887
moodle/moodle
lib/navigationlib.php
navigation_json.set_expandable
public function set_expandable($expandable) { foreach ($expandable as $node) { $this->expandable[$node['key'].':'.$node['type']] = $node; } }
php
public function set_expandable($expandable) { foreach ($expandable as $node) { $this->expandable[$node['key'].':'.$node['type']] = $node; } }
[ "public", "function", "set_expandable", "(", "$", "expandable", ")", "{", "foreach", "(", "$", "expandable", "as", "$", "node", ")", "{", "$", "this", "->", "expandable", "[", "$", "node", "[", "'key'", "]", ".", "':'", ".", "$", "node", "[", "'type'", "]", "]", "=", "$", "node", ";", "}", "}" ]
Set the expandable items in the array so that we have enough information to attach AJAX events @param array $expandable
[ "Set", "the", "expandable", "items", "in", "the", "array", "so", "that", "we", "have", "enough", "information", "to", "attach", "AJAX", "events" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5563-L5567
215,888
moodle/moodle
lib/navigationlib.php
navigation_cache.ensure_session_cache_initialised
protected function ensure_session_cache_initialised() { global $SESSION; if (empty($this->session)) { if (!isset($SESSION->navcache)) { $SESSION->navcache = new stdClass; } if (!isset($SESSION->navcache->{$this->area})) { $SESSION->navcache->{$this->area} = array(); } $this->session = &$SESSION->navcache->{$this->area}; // pointer to array, =& is correct here } }
php
protected function ensure_session_cache_initialised() { global $SESSION; if (empty($this->session)) { if (!isset($SESSION->navcache)) { $SESSION->navcache = new stdClass; } if (!isset($SESSION->navcache->{$this->area})) { $SESSION->navcache->{$this->area} = array(); } $this->session = &$SESSION->navcache->{$this->area}; // pointer to array, =& is correct here } }
[ "protected", "function", "ensure_session_cache_initialised", "(", ")", "{", "global", "$", "SESSION", ";", "if", "(", "empty", "(", "$", "this", "->", "session", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "SESSION", "->", "navcache", ")", ")", "{", "$", "SESSION", "->", "navcache", "=", "new", "stdClass", ";", "}", "if", "(", "!", "isset", "(", "$", "SESSION", "->", "navcache", "->", "{", "$", "this", "->", "area", "}", ")", ")", "{", "$", "SESSION", "->", "navcache", "->", "{", "$", "this", "->", "area", "}", "=", "array", "(", ")", ";", "}", "$", "this", "->", "session", "=", "&", "$", "SESSION", "->", "navcache", "->", "{", "$", "this", "->", "area", "}", ";", "// pointer to array, =& is correct here", "}", "}" ]
Used to set up the cache within the SESSION. This is called for each access and ensure that we don't put anything into the session before it is required.
[ "Used", "to", "set", "up", "the", "cache", "within", "the", "SESSION", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5710-L5721
215,889
moodle/moodle
lib/navigationlib.php
navigation_cache.cached
public function cached($key) { global $USER; $this->ensure_session_cache_initialised(); if (!array_key_exists($key, $this->session) || !is_array($this->session[$key]) || $this->session[$key][self::CACHEUSERID]!=$USER->id || $this->session[$key][self::CACHETIME] < $this->timeout) { return false; } return true; }
php
public function cached($key) { global $USER; $this->ensure_session_cache_initialised(); if (!array_key_exists($key, $this->session) || !is_array($this->session[$key]) || $this->session[$key][self::CACHEUSERID]!=$USER->id || $this->session[$key][self::CACHETIME] < $this->timeout) { return false; } return true; }
[ "public", "function", "cached", "(", "$", "key", ")", "{", "global", "$", "USER", ";", "$", "this", "->", "ensure_session_cache_initialised", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "session", ")", "||", "!", "is_array", "(", "$", "this", "->", "session", "[", "$", "key", "]", ")", "||", "$", "this", "->", "session", "[", "$", "key", "]", "[", "self", "::", "CACHEUSERID", "]", "!=", "$", "USER", "->", "id", "||", "$", "this", "->", "session", "[", "$", "key", "]", "[", "self", "::", "CACHETIME", "]", "<", "$", "this", "->", "timeout", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check the existence of the identifier in the cache @param string|int $key @return bool
[ "Check", "the", "existence", "of", "the", "identifier", "in", "the", "cache" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5765-L5772
215,890
moodle/moodle
lib/navigationlib.php
navigation_cache.compare
public function compare($key, $value, $serialise = true) { if ($this->cached($key)) { if ($serialise) { $value = serialize($value); } if ($this->session[$key][self::CACHEVALUE] === $value) { return true; } } return false; }
php
public function compare($key, $value, $serialise = true) { if ($this->cached($key)) { if ($serialise) { $value = serialize($value); } if ($this->session[$key][self::CACHEVALUE] === $value) { return true; } } return false; }
[ "public", "function", "compare", "(", "$", "key", ",", "$", "value", ",", "$", "serialise", "=", "true", ")", "{", "if", "(", "$", "this", "->", "cached", "(", "$", "key", ")", ")", "{", "if", "(", "$", "serialise", ")", "{", "$", "value", "=", "serialize", "(", "$", "value", ")", ";", "}", "if", "(", "$", "this", "->", "session", "[", "$", "key", "]", "[", "self", "::", "CACHEVALUE", "]", "===", "$", "value", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Compare something to it's equivilant in the cache @param string $key @param mixed $value @param bool $serialise Whether to serialise the value before comparison this should only be set to false if the value is already serialised @return bool If the value is the same false if it is not set or doesn't match
[ "Compare", "something", "to", "it", "s", "equivilant", "in", "the", "cache" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5783-L5793
215,891
moodle/moodle
lib/navigationlib.php
navigation_cache.garbage_collection
protected function garbage_collection() { if (empty($this->session)) { return true; } foreach ($this->session as $key=>$cachedinfo) { if (is_array($cachedinfo) && $cachedinfo[self::CACHETIME]<$this->timeout) { unset($this->session[$key]); } } }
php
protected function garbage_collection() { if (empty($this->session)) { return true; } foreach ($this->session as $key=>$cachedinfo) { if (is_array($cachedinfo) && $cachedinfo[self::CACHETIME]<$this->timeout) { unset($this->session[$key]); } } }
[ "protected", "function", "garbage_collection", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "session", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "session", "as", "$", "key", "=>", "$", "cachedinfo", ")", "{", "if", "(", "is_array", "(", "$", "cachedinfo", ")", "&&", "$", "cachedinfo", "[", "self", "::", "CACHETIME", "]", "<", "$", "this", "->", "timeout", ")", "{", "unset", "(", "$", "this", "->", "session", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Checks all cache entries and removes any that have expired, good ole cleanup
[ "Checks", "all", "cache", "entries", "and", "removes", "any", "that", "have", "expired", "good", "ole", "cleanup" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5805-L5814
215,892
moodle/moodle
lib/navigationlib.php
navigation_cache.destroy_volatile_caches
public static function destroy_volatile_caches() { global $SESSION; if (is_array(self::$volatilecaches) && count(self::$volatilecaches)>0) { foreach (self::$volatilecaches as $area) { $SESSION->navcache->{$area} = array(); } } else { $SESSION->navcache = new stdClass; } }
php
public static function destroy_volatile_caches() { global $SESSION; if (is_array(self::$volatilecaches) && count(self::$volatilecaches)>0) { foreach (self::$volatilecaches as $area) { $SESSION->navcache->{$area} = array(); } } else { $SESSION->navcache = new stdClass; } }
[ "public", "static", "function", "destroy_volatile_caches", "(", ")", "{", "global", "$", "SESSION", ";", "if", "(", "is_array", "(", "self", "::", "$", "volatilecaches", ")", "&&", "count", "(", "self", "::", "$", "volatilecaches", ")", ">", "0", ")", "{", "foreach", "(", "self", "::", "$", "volatilecaches", "as", "$", "area", ")", "{", "$", "SESSION", "->", "navcache", "->", "{", "$", "area", "}", "=", "array", "(", ")", ";", "}", "}", "else", "{", "$", "SESSION", "->", "navcache", "=", "new", "stdClass", ";", "}", "}" ]
Destroys all caches marked as volatile This function is static and works in conjunction with the static volatilecaches property of navigation cache. Because this function is static it manually resets the cached areas back to an empty array.
[ "Destroys", "all", "caches", "marked", "as", "volatile" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/navigationlib.php#L5846-L5855
215,893
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_forums_by_courses
public static function get_forums_by_courses($courseids = array()) { global $CFG; require_once($CFG->dirroot . "/mod/forum/lib.php"); $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids)); $courses = array(); if (empty($params['courseids'])) { $courses = enrol_get_my_courses(); $params['courseids'] = array_keys($courses); } // Array to store the forums to return. $arrforums = array(); $warnings = array(); // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses); // Get the forums in this course. This function checks users visibility permissions. $forums = get_all_instances_in_courses("forum", $courses); foreach ($forums as $forum) { $course = $courses[$forum->course]; $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id); $context = context_module::instance($cm->id); // Skip forums we are not allowed to see discussions. if (!has_capability('mod/forum:viewdiscussion', $context)) { continue; } $forum->name = external_format_string($forum->name, $context->id); // Format the intro before being returning using the format setting. list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', null); $forum->introfiles = external_util::get_area_files($context->id, 'mod_forum', 'intro', false, false); // Discussions count. This function does static request cache. $forum->numdiscussions = forum_count_discussions($forum, $cm, $course); $forum->cmid = $forum->coursemodule; $forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context); $forum->istracked = forum_tp_is_tracked($forum); if ($forum->istracked) { $forum->unreadpostscount = forum_tp_count_forum_unread_posts($cm, $course); } // Add the forum to the array to return. $arrforums[$forum->id] = $forum; } } return $arrforums; }
php
public static function get_forums_by_courses($courseids = array()) { global $CFG; require_once($CFG->dirroot . "/mod/forum/lib.php"); $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids)); $courses = array(); if (empty($params['courseids'])) { $courses = enrol_get_my_courses(); $params['courseids'] = array_keys($courses); } // Array to store the forums to return. $arrforums = array(); $warnings = array(); // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses); // Get the forums in this course. This function checks users visibility permissions. $forums = get_all_instances_in_courses("forum", $courses); foreach ($forums as $forum) { $course = $courses[$forum->course]; $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id); $context = context_module::instance($cm->id); // Skip forums we are not allowed to see discussions. if (!has_capability('mod/forum:viewdiscussion', $context)) { continue; } $forum->name = external_format_string($forum->name, $context->id); // Format the intro before being returning using the format setting. list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', null); $forum->introfiles = external_util::get_area_files($context->id, 'mod_forum', 'intro', false, false); // Discussions count. This function does static request cache. $forum->numdiscussions = forum_count_discussions($forum, $cm, $course); $forum->cmid = $forum->coursemodule; $forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context); $forum->istracked = forum_tp_is_tracked($forum); if ($forum->istracked) { $forum->unreadpostscount = forum_tp_count_forum_unread_posts($cm, $course); } // Add the forum to the array to return. $arrforums[$forum->id] = $forum; } } return $arrforums; }
[ "public", "static", "function", "get_forums_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "\"/mod/forum/lib.php\"", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_forums_by_courses_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "courses", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "$", "courses", "=", "enrol_get_my_courses", "(", ")", ";", "$", "params", "[", "'courseids'", "]", "=", "array_keys", "(", "$", "courses", ")", ";", "}", "// Array to store the forums to return.", "$", "arrforums", "=", "array", "(", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "// Ensure there are courseids to loop through.", "if", "(", "!", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "$", "courses", ")", ";", "// Get the forums in this course. This function checks users visibility permissions.", "$", "forums", "=", "get_all_instances_in_courses", "(", "\"forum\"", ",", "$", "courses", ")", ";", "foreach", "(", "$", "forums", "as", "$", "forum", ")", "{", "$", "course", "=", "$", "courses", "[", "$", "forum", "->", "course", "]", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'forum'", ",", "$", "forum", "->", "id", ",", "$", "course", "->", "id", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "// Skip forums we are not allowed to see discussions.", "if", "(", "!", "has_capability", "(", "'mod/forum:viewdiscussion'", ",", "$", "context", ")", ")", "{", "continue", ";", "}", "$", "forum", "->", "name", "=", "external_format_string", "(", "$", "forum", "->", "name", ",", "$", "context", "->", "id", ")", ";", "// Format the intro before being returning using the format setting.", "list", "(", "$", "forum", "->", "intro", ",", "$", "forum", "->", "introformat", ")", "=", "external_format_text", "(", "$", "forum", "->", "intro", ",", "$", "forum", "->", "introformat", ",", "$", "context", "->", "id", ",", "'mod_forum'", ",", "'intro'", ",", "null", ")", ";", "$", "forum", "->", "introfiles", "=", "external_util", "::", "get_area_files", "(", "$", "context", "->", "id", ",", "'mod_forum'", ",", "'intro'", ",", "false", ",", "false", ")", ";", "// Discussions count. This function does static request cache.", "$", "forum", "->", "numdiscussions", "=", "forum_count_discussions", "(", "$", "forum", ",", "$", "cm", ",", "$", "course", ")", ";", "$", "forum", "->", "cmid", "=", "$", "forum", "->", "coursemodule", ";", "$", "forum", "->", "cancreatediscussions", "=", "forum_user_can_post_discussion", "(", "$", "forum", ",", "null", ",", "-", "1", ",", "$", "cm", ",", "$", "context", ")", ";", "$", "forum", "->", "istracked", "=", "forum_tp_is_tracked", "(", "$", "forum", ")", ";", "if", "(", "$", "forum", "->", "istracked", ")", "{", "$", "forum", "->", "unreadpostscount", "=", "forum_tp_count_forum_unread_posts", "(", "$", "cm", ",", "$", "course", ")", ";", "}", "// Add the forum to the array to return.", "$", "arrforums", "[", "$", "forum", "->", "id", "]", "=", "$", "forum", ";", "}", "}", "return", "$", "arrforums", ";", "}" ]
Returns a list of forums in a provided list of courses, if no list is provided all forums that the user can view will be returned. @param array $courseids the course ids @return array the forum details @since Moodle 2.5
[ "Returns", "a", "list", "of", "forums", "in", "a", "provided", "list", "of", "courses", "if", "no", "list", "is", "provided", "all", "forums", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L59-L114
215,894
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_forums_by_courses_returns
public static function get_forums_by_courses_returns() { return new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Forum id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'type' => new external_value(PARAM_TEXT, 'The forum type'), 'name' => new external_value(PARAM_RAW, 'Forum name'), 'intro' => new external_value(PARAM_RAW, 'The forum intro'), 'introformat' => new external_format_value('intro'), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'duedate' => new external_value(PARAM_INT, 'duedate for the user', VALUE_OPTIONAL), 'cutoffdate' => new external_value(PARAM_INT, 'cutoffdate for the user', VALUE_OPTIONAL), 'assessed' => new external_value(PARAM_INT, 'Aggregate type'), 'assesstimestart' => new external_value(PARAM_INT, 'Assess start time'), 'assesstimefinish' => new external_value(PARAM_INT, 'Assess finish time'), 'scale' => new external_value(PARAM_INT, 'Scale'), 'maxbytes' => new external_value(PARAM_INT, 'Maximum attachment size'), 'maxattachments' => new external_value(PARAM_INT, 'Maximum number of attachments'), 'forcesubscribe' => new external_value(PARAM_INT, 'Force users to subscribe'), 'trackingtype' => new external_value(PARAM_INT, 'Subscription mode'), 'rsstype' => new external_value(PARAM_INT, 'RSS feed for this activity'), 'rssarticles' => new external_value(PARAM_INT, 'Number of RSS recent articles'), 'timemodified' => new external_value(PARAM_INT, 'Time modified'), 'warnafter' => new external_value(PARAM_INT, 'Post threshold for warning'), 'blockafter' => new external_value(PARAM_INT, 'Post threshold for blocking'), 'blockperiod' => new external_value(PARAM_INT, 'Time period for blocking'), 'completiondiscussions' => new external_value(PARAM_INT, 'Student must create discussions'), 'completionreplies' => new external_value(PARAM_INT, 'Student must post replies'), 'completionposts' => new external_value(PARAM_INT, 'Student must post discussions or replies'), 'cmid' => new external_value(PARAM_INT, 'Course module id'), 'numdiscussions' => new external_value(PARAM_INT, 'Number of discussions in the forum', VALUE_OPTIONAL), 'cancreatediscussions' => new external_value(PARAM_BOOL, 'If the user can create discussions', VALUE_OPTIONAL), 'lockdiscussionafter' => new external_value(PARAM_INT, 'After what period a discussion is locked', VALUE_OPTIONAL), 'istracked' => new external_value(PARAM_BOOL, 'If the user is tracking the forum', VALUE_OPTIONAL), 'unreadpostscount' => new external_value(PARAM_INT, 'The number of unread posts for tracked forums', VALUE_OPTIONAL), ), 'forum' ) ); }
php
public static function get_forums_by_courses_returns() { return new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Forum id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'type' => new external_value(PARAM_TEXT, 'The forum type'), 'name' => new external_value(PARAM_RAW, 'Forum name'), 'intro' => new external_value(PARAM_RAW, 'The forum intro'), 'introformat' => new external_format_value('intro'), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'duedate' => new external_value(PARAM_INT, 'duedate for the user', VALUE_OPTIONAL), 'cutoffdate' => new external_value(PARAM_INT, 'cutoffdate for the user', VALUE_OPTIONAL), 'assessed' => new external_value(PARAM_INT, 'Aggregate type'), 'assesstimestart' => new external_value(PARAM_INT, 'Assess start time'), 'assesstimefinish' => new external_value(PARAM_INT, 'Assess finish time'), 'scale' => new external_value(PARAM_INT, 'Scale'), 'maxbytes' => new external_value(PARAM_INT, 'Maximum attachment size'), 'maxattachments' => new external_value(PARAM_INT, 'Maximum number of attachments'), 'forcesubscribe' => new external_value(PARAM_INT, 'Force users to subscribe'), 'trackingtype' => new external_value(PARAM_INT, 'Subscription mode'), 'rsstype' => new external_value(PARAM_INT, 'RSS feed for this activity'), 'rssarticles' => new external_value(PARAM_INT, 'Number of RSS recent articles'), 'timemodified' => new external_value(PARAM_INT, 'Time modified'), 'warnafter' => new external_value(PARAM_INT, 'Post threshold for warning'), 'blockafter' => new external_value(PARAM_INT, 'Post threshold for blocking'), 'blockperiod' => new external_value(PARAM_INT, 'Time period for blocking'), 'completiondiscussions' => new external_value(PARAM_INT, 'Student must create discussions'), 'completionreplies' => new external_value(PARAM_INT, 'Student must post replies'), 'completionposts' => new external_value(PARAM_INT, 'Student must post discussions or replies'), 'cmid' => new external_value(PARAM_INT, 'Course module id'), 'numdiscussions' => new external_value(PARAM_INT, 'Number of discussions in the forum', VALUE_OPTIONAL), 'cancreatediscussions' => new external_value(PARAM_BOOL, 'If the user can create discussions', VALUE_OPTIONAL), 'lockdiscussionafter' => new external_value(PARAM_INT, 'After what period a discussion is locked', VALUE_OPTIONAL), 'istracked' => new external_value(PARAM_BOOL, 'If the user is tracking the forum', VALUE_OPTIONAL), 'unreadpostscount' => new external_value(PARAM_INT, 'The number of unread posts for tracked forums', VALUE_OPTIONAL), ), 'forum' ) ); }
[ "public", "static", "function", "get_forums_by_courses_returns", "(", ")", "{", "return", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Forum id'", ")", ",", "'course'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'type'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'The forum type'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Forum name'", ")", ",", "'intro'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'The forum intro'", ")", ",", "'introformat'", "=>", "new", "external_format_value", "(", "'intro'", ")", ",", "'introfiles'", "=>", "new", "external_files", "(", "'Files in the introduction text'", ",", "VALUE_OPTIONAL", ")", ",", "'duedate'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'duedate for the user'", ",", "VALUE_OPTIONAL", ")", ",", "'cutoffdate'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'cutoffdate for the user'", ",", "VALUE_OPTIONAL", ")", ",", "'assessed'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Aggregate type'", ")", ",", "'assesstimestart'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Assess start time'", ")", ",", "'assesstimefinish'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Assess finish time'", ")", ",", "'scale'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Scale'", ")", ",", "'maxbytes'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Maximum attachment size'", ")", ",", "'maxattachments'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Maximum number of attachments'", ")", ",", "'forcesubscribe'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Force users to subscribe'", ")", ",", "'trackingtype'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Subscription mode'", ")", ",", "'rsstype'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'RSS feed for this activity'", ")", ",", "'rssarticles'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Number of RSS recent articles'", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time modified'", ")", ",", "'warnafter'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Post threshold for warning'", ")", ",", "'blockafter'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Post threshold for blocking'", ")", ",", "'blockperiod'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time period for blocking'", ")", ",", "'completiondiscussions'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Student must create discussions'", ")", ",", "'completionreplies'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Student must post replies'", ")", ",", "'completionposts'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Student must post discussions or replies'", ")", ",", "'cmid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course module id'", ")", ",", "'numdiscussions'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Number of discussions in the forum'", ",", "VALUE_OPTIONAL", ")", ",", "'cancreatediscussions'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'If the user can create discussions'", ",", "VALUE_OPTIONAL", ")", ",", "'lockdiscussionafter'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'After what period a discussion is locked'", ",", "VALUE_OPTIONAL", ")", ",", "'istracked'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'If the user is tracking the forum'", ",", "VALUE_OPTIONAL", ")", ",", "'unreadpostscount'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The number of unread posts for tracked forums'", ",", "VALUE_OPTIONAL", ")", ",", ")", ",", "'forum'", ")", ")", ";", "}" ]
Describes the get_forum return value. @return external_single_structure @since Moodle 2.5
[ "Describes", "the", "get_forum", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L122-L162
215,895
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_discussion_posts
public static function get_discussion_posts(int $discussionid, ?string $sortby, ?string $sortdirection) { global $USER; // Validate the parameter. $params = self::validate_parameters(self::get_discussion_posts_parameters(), [ 'discussionid' => $discussionid, 'sortby' => $sortby, 'sortdirection' => $sortdirection, ]); $warnings = []; $vaultfactory = mod_forum\local\container::get_vault_factory(); $discussionvault = $vaultfactory->get_discussion_vault(); $discussion = $discussionvault->get_from_id($params['discussionid']); $forumvault = $vaultfactory->get_forum_vault(); $forum = $forumvault->get_from_id($discussion->get_forum_id()); $sortby = $params['sortby']; $sortdirection = $params['sortdirection']; $sortallowedvalues = ['id', 'created', 'modified']; $directionallowedvalues = ['ASC', 'DESC']; if (!in_array(strtolower($sortby), $sortallowedvalues)) { throw new invalid_parameter_exception('Invalid value for sortby parameter (value: ' . $sortby . '),' . 'allowed values are: ' . implode(', ', $sortallowedvalues)); } $sortdirection = strtoupper($sortdirection); if (!in_array($sortdirection, $directionallowedvalues)) { throw new invalid_parameter_exception('Invalid value for sortdirection parameter (value: ' . $sortdirection . '),' . 'allowed values are: ' . implode(',', $directionallowedvalues)); } $managerfactory = mod_forum\local\container::get_manager_factory(); $capabilitymanager = $managerfactory->get_capability_manager($forum); $postvault = $vaultfactory->get_post_vault(); $posts = $postvault->get_from_discussion_id( $USER, $discussion->get_id(), $capabilitymanager->can_view_any_private_reply($USER), "{$sortby} {$sortdirection}" ); $builderfactory = mod_forum\local\container::get_builder_factory(); $postbuilder = $builderfactory->get_exported_posts_builder(); $legacydatamapper = mod_forum\local\container::get_legacy_data_mapper_factory(); return [ 'posts' => $postbuilder->build($USER, [$forum], [$discussion], $posts), 'ratinginfo' => \core_rating\external\util::get_rating_info( $legacydatamapper->get_forum_data_mapper()->to_legacy_object($forum), $forum->get_context(), 'mod_forum', 'post', $legacydatamapper->get_post_data_mapper()->to_legacy_objects($posts) ), 'warnings' => $warnings, ]; }
php
public static function get_discussion_posts(int $discussionid, ?string $sortby, ?string $sortdirection) { global $USER; // Validate the parameter. $params = self::validate_parameters(self::get_discussion_posts_parameters(), [ 'discussionid' => $discussionid, 'sortby' => $sortby, 'sortdirection' => $sortdirection, ]); $warnings = []; $vaultfactory = mod_forum\local\container::get_vault_factory(); $discussionvault = $vaultfactory->get_discussion_vault(); $discussion = $discussionvault->get_from_id($params['discussionid']); $forumvault = $vaultfactory->get_forum_vault(); $forum = $forumvault->get_from_id($discussion->get_forum_id()); $sortby = $params['sortby']; $sortdirection = $params['sortdirection']; $sortallowedvalues = ['id', 'created', 'modified']; $directionallowedvalues = ['ASC', 'DESC']; if (!in_array(strtolower($sortby), $sortallowedvalues)) { throw new invalid_parameter_exception('Invalid value for sortby parameter (value: ' . $sortby . '),' . 'allowed values are: ' . implode(', ', $sortallowedvalues)); } $sortdirection = strtoupper($sortdirection); if (!in_array($sortdirection, $directionallowedvalues)) { throw new invalid_parameter_exception('Invalid value for sortdirection parameter (value: ' . $sortdirection . '),' . 'allowed values are: ' . implode(',', $directionallowedvalues)); } $managerfactory = mod_forum\local\container::get_manager_factory(); $capabilitymanager = $managerfactory->get_capability_manager($forum); $postvault = $vaultfactory->get_post_vault(); $posts = $postvault->get_from_discussion_id( $USER, $discussion->get_id(), $capabilitymanager->can_view_any_private_reply($USER), "{$sortby} {$sortdirection}" ); $builderfactory = mod_forum\local\container::get_builder_factory(); $postbuilder = $builderfactory->get_exported_posts_builder(); $legacydatamapper = mod_forum\local\container::get_legacy_data_mapper_factory(); return [ 'posts' => $postbuilder->build($USER, [$forum], [$discussion], $posts), 'ratinginfo' => \core_rating\external\util::get_rating_info( $legacydatamapper->get_forum_data_mapper()->to_legacy_object($forum), $forum->get_context(), 'mod_forum', 'post', $legacydatamapper->get_post_data_mapper()->to_legacy_objects($posts) ), 'warnings' => $warnings, ]; }
[ "public", "static", "function", "get_discussion_posts", "(", "int", "$", "discussionid", ",", "?", "string", "$", "sortby", ",", "?", "string", "$", "sortdirection", ")", "{", "global", "$", "USER", ";", "// Validate the parameter.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_discussion_posts_parameters", "(", ")", ",", "[", "'discussionid'", "=>", "$", "discussionid", ",", "'sortby'", "=>", "$", "sortby", ",", "'sortdirection'", "=>", "$", "sortdirection", ",", "]", ")", ";", "$", "warnings", "=", "[", "]", ";", "$", "vaultfactory", "=", "mod_forum", "\\", "local", "\\", "container", "::", "get_vault_factory", "(", ")", ";", "$", "discussionvault", "=", "$", "vaultfactory", "->", "get_discussion_vault", "(", ")", ";", "$", "discussion", "=", "$", "discussionvault", "->", "get_from_id", "(", "$", "params", "[", "'discussionid'", "]", ")", ";", "$", "forumvault", "=", "$", "vaultfactory", "->", "get_forum_vault", "(", ")", ";", "$", "forum", "=", "$", "forumvault", "->", "get_from_id", "(", "$", "discussion", "->", "get_forum_id", "(", ")", ")", ";", "$", "sortby", "=", "$", "params", "[", "'sortby'", "]", ";", "$", "sortdirection", "=", "$", "params", "[", "'sortdirection'", "]", ";", "$", "sortallowedvalues", "=", "[", "'id'", ",", "'created'", ",", "'modified'", "]", ";", "$", "directionallowedvalues", "=", "[", "'ASC'", ",", "'DESC'", "]", ";", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "sortby", ")", ",", "$", "sortallowedvalues", ")", ")", "{", "throw", "new", "invalid_parameter_exception", "(", "'Invalid value for sortby parameter (value: '", ".", "$", "sortby", ".", "'),'", ".", "'allowed values are: '", ".", "implode", "(", "', '", ",", "$", "sortallowedvalues", ")", ")", ";", "}", "$", "sortdirection", "=", "strtoupper", "(", "$", "sortdirection", ")", ";", "if", "(", "!", "in_array", "(", "$", "sortdirection", ",", "$", "directionallowedvalues", ")", ")", "{", "throw", "new", "invalid_parameter_exception", "(", "'Invalid value for sortdirection parameter (value: '", ".", "$", "sortdirection", ".", "'),'", ".", "'allowed values are: '", ".", "implode", "(", "','", ",", "$", "directionallowedvalues", ")", ")", ";", "}", "$", "managerfactory", "=", "mod_forum", "\\", "local", "\\", "container", "::", "get_manager_factory", "(", ")", ";", "$", "capabilitymanager", "=", "$", "managerfactory", "->", "get_capability_manager", "(", "$", "forum", ")", ";", "$", "postvault", "=", "$", "vaultfactory", "->", "get_post_vault", "(", ")", ";", "$", "posts", "=", "$", "postvault", "->", "get_from_discussion_id", "(", "$", "USER", ",", "$", "discussion", "->", "get_id", "(", ")", ",", "$", "capabilitymanager", "->", "can_view_any_private_reply", "(", "$", "USER", ")", ",", "\"{$sortby} {$sortdirection}\"", ")", ";", "$", "builderfactory", "=", "mod_forum", "\\", "local", "\\", "container", "::", "get_builder_factory", "(", ")", ";", "$", "postbuilder", "=", "$", "builderfactory", "->", "get_exported_posts_builder", "(", ")", ";", "$", "legacydatamapper", "=", "mod_forum", "\\", "local", "\\", "container", "::", "get_legacy_data_mapper_factory", "(", ")", ";", "return", "[", "'posts'", "=>", "$", "postbuilder", "->", "build", "(", "$", "USER", ",", "[", "$", "forum", "]", ",", "[", "$", "discussion", "]", ",", "$", "posts", ")", ",", "'ratinginfo'", "=>", "\\", "core_rating", "\\", "external", "\\", "util", "::", "get_rating_info", "(", "$", "legacydatamapper", "->", "get_forum_data_mapper", "(", ")", "->", "to_legacy_object", "(", "$", "forum", ")", ",", "$", "forum", "->", "get_context", "(", ")", ",", "'mod_forum'", ",", "'post'", ",", "$", "legacydatamapper", "->", "get_post_data_mapper", "(", ")", "->", "to_legacy_objects", "(", "$", "posts", ")", ")", ",", "'warnings'", "=>", "$", "warnings", ",", "]", ";", "}" ]
Get the forum posts in the specified discussion. @param int $discussionid @param string $sortby @param string $sortdirection @return array
[ "Get", "the", "forum", "posts", "in", "the", "specified", "discussion", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L172-L233
215,896
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_discussion_posts_parameters
public static function get_discussion_posts_parameters() { return new external_function_parameters ([ 'discussionid' => new external_value(PARAM_INT, 'The ID of the discussion from which to fetch posts.', VALUE_REQUIRED), 'sortby' => new external_value(PARAM_ALPHA, 'Sort by this element: id, created or modified', VALUE_DEFAULT, 'created'), 'sortdirection' => new external_value(PARAM_ALPHA, 'Sort direction: ASC or DESC', VALUE_DEFAULT, 'DESC') ]); }
php
public static function get_discussion_posts_parameters() { return new external_function_parameters ([ 'discussionid' => new external_value(PARAM_INT, 'The ID of the discussion from which to fetch posts.', VALUE_REQUIRED), 'sortby' => new external_value(PARAM_ALPHA, 'Sort by this element: id, created or modified', VALUE_DEFAULT, 'created'), 'sortdirection' => new external_value(PARAM_ALPHA, 'Sort direction: ASC or DESC', VALUE_DEFAULT, 'DESC') ]); }
[ "public", "static", "function", "get_discussion_posts_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "[", "'discussionid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The ID of the discussion from which to fetch posts.'", ",", "VALUE_REQUIRED", ")", ",", "'sortby'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'Sort by this element: id, created or modified'", ",", "VALUE_DEFAULT", ",", "'created'", ")", ",", "'sortdirection'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'Sort direction: ASC or DESC'", ",", "VALUE_DEFAULT", ",", "'DESC'", ")", "]", ")", ";", "}" ]
Describe the post parameters. @return external_function_parameters
[ "Describe", "the", "post", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L240-L246
215,897
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_discussion_posts_returns
public static function get_discussion_posts_returns() { return new external_single_structure([ 'posts' => new external_multiple_structure(\mod_forum\local\exporters\post::get_read_structure()), 'ratinginfo' => \core_rating\external\util::external_ratings_structure(), 'warnings' => new external_warnings() ]); }
php
public static function get_discussion_posts_returns() { return new external_single_structure([ 'posts' => new external_multiple_structure(\mod_forum\local\exporters\post::get_read_structure()), 'ratinginfo' => \core_rating\external\util::external_ratings_structure(), 'warnings' => new external_warnings() ]); }
[ "public", "static", "function", "get_discussion_posts_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "[", "'posts'", "=>", "new", "external_multiple_structure", "(", "\\", "mod_forum", "\\", "local", "\\", "exporters", "\\", "post", "::", "get_read_structure", "(", ")", ")", ",", "'ratinginfo'", "=>", "\\", "core_rating", "\\", "external", "\\", "util", "::", "external_ratings_structure", "(", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", "]", ")", ";", "}" ]
Describe the post return format. @return external_single_structure
[ "Describe", "the", "post", "return", "format", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L253-L259
215,898
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_forum_discussion_posts_parameters
public static function get_forum_discussion_posts_parameters() { return new external_function_parameters ( array( 'discussionid' => new external_value(PARAM_INT, 'discussion ID', VALUE_REQUIRED), 'sortby' => new external_value(PARAM_ALPHA, 'sort by this element: id, created or modified', VALUE_DEFAULT, 'created'), 'sortdirection' => new external_value(PARAM_ALPHA, 'sort direction: ASC or DESC', VALUE_DEFAULT, 'DESC') ) ); }
php
public static function get_forum_discussion_posts_parameters() { return new external_function_parameters ( array( 'discussionid' => new external_value(PARAM_INT, 'discussion ID', VALUE_REQUIRED), 'sortby' => new external_value(PARAM_ALPHA, 'sort by this element: id, created or modified', VALUE_DEFAULT, 'created'), 'sortdirection' => new external_value(PARAM_ALPHA, 'sort direction: ASC or DESC', VALUE_DEFAULT, 'DESC') ) ); }
[ "public", "static", "function", "get_forum_discussion_posts_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'discussionid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'discussion ID'", ",", "VALUE_REQUIRED", ")", ",", "'sortby'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'sort by this element: id, created or modified'", ",", "VALUE_DEFAULT", ",", "'created'", ")", ",", "'sortdirection'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'sort direction: ASC or DESC'", ",", "VALUE_DEFAULT", ",", "'DESC'", ")", ")", ")", ";", "}" ]
Describes the parameters for get_forum_discussion_posts. @return external_function_parameters @since Moodle 2.7
[ "Describes", "the", "parameters", "for", "get_forum_discussion_posts", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L267-L276
215,899
moodle/moodle
mod/forum/externallib.php
mod_forum_external.get_forum_discussion_posts_returns
public static function get_forum_discussion_posts_returns() { return new external_single_structure( array( 'posts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Post id'), 'discussion' => new external_value(PARAM_INT, 'Discussion id'), 'parent' => new external_value(PARAM_INT, 'Parent id'), 'userid' => new external_value(PARAM_INT, 'User id'), 'created' => new external_value(PARAM_INT, 'Creation time'), 'modified' => new external_value(PARAM_INT, 'Time modified'), 'mailed' => new external_value(PARAM_INT, 'Mailed?'), 'subject' => new external_value(PARAM_TEXT, 'The post subject'), 'message' => new external_value(PARAM_RAW, 'The post message'), 'messageformat' => new external_format_value('message'), 'messagetrust' => new external_value(PARAM_INT, 'Can we trust?'), 'messageinlinefiles' => new external_files('post message inline files', VALUE_OPTIONAL), 'attachment' => new external_value(PARAM_RAW, 'Has attachments?'), 'attachments' => new external_files('attachments', VALUE_OPTIONAL), 'totalscore' => new external_value(PARAM_INT, 'The post message total score'), 'mailnow' => new external_value(PARAM_INT, 'Mail now?'), 'children' => new external_multiple_structure(new external_value(PARAM_INT, 'children post id')), 'canreply' => new external_value(PARAM_BOOL, 'The user can reply to posts?'), 'postread' => new external_value(PARAM_BOOL, 'The post was read'), 'userfullname' => new external_value(PARAM_TEXT, 'Post author full name'), 'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL), 'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.'), 'isprivatereply' => new external_value(PARAM_BOOL, 'The post is a private reply'), 'tags' => new external_multiple_structure( \core_tag\external\tag_item_exporter::get_read_structure(), 'Tags', VALUE_OPTIONAL ), ), 'post' ) ), 'ratinginfo' => \core_rating\external\util::external_ratings_structure(), 'warnings' => new external_warnings() ) ); }
php
public static function get_forum_discussion_posts_returns() { return new external_single_structure( array( 'posts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Post id'), 'discussion' => new external_value(PARAM_INT, 'Discussion id'), 'parent' => new external_value(PARAM_INT, 'Parent id'), 'userid' => new external_value(PARAM_INT, 'User id'), 'created' => new external_value(PARAM_INT, 'Creation time'), 'modified' => new external_value(PARAM_INT, 'Time modified'), 'mailed' => new external_value(PARAM_INT, 'Mailed?'), 'subject' => new external_value(PARAM_TEXT, 'The post subject'), 'message' => new external_value(PARAM_RAW, 'The post message'), 'messageformat' => new external_format_value('message'), 'messagetrust' => new external_value(PARAM_INT, 'Can we trust?'), 'messageinlinefiles' => new external_files('post message inline files', VALUE_OPTIONAL), 'attachment' => new external_value(PARAM_RAW, 'Has attachments?'), 'attachments' => new external_files('attachments', VALUE_OPTIONAL), 'totalscore' => new external_value(PARAM_INT, 'The post message total score'), 'mailnow' => new external_value(PARAM_INT, 'Mail now?'), 'children' => new external_multiple_structure(new external_value(PARAM_INT, 'children post id')), 'canreply' => new external_value(PARAM_BOOL, 'The user can reply to posts?'), 'postread' => new external_value(PARAM_BOOL, 'The post was read'), 'userfullname' => new external_value(PARAM_TEXT, 'Post author full name'), 'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL), 'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.'), 'isprivatereply' => new external_value(PARAM_BOOL, 'The post is a private reply'), 'tags' => new external_multiple_structure( \core_tag\external\tag_item_exporter::get_read_structure(), 'Tags', VALUE_OPTIONAL ), ), 'post' ) ), 'ratinginfo' => \core_rating\external\util::external_ratings_structure(), 'warnings' => new external_warnings() ) ); }
[ "public", "static", "function", "get_forum_discussion_posts_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'posts'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Post id'", ")", ",", "'discussion'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Discussion id'", ")", ",", "'parent'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Parent id'", ")", ",", "'userid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'User id'", ")", ",", "'created'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Creation time'", ")", ",", "'modified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time modified'", ")", ",", "'mailed'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Mailed?'", ")", ",", "'subject'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'The post subject'", ")", ",", "'message'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'The post message'", ")", ",", "'messageformat'", "=>", "new", "external_format_value", "(", "'message'", ")", ",", "'messagetrust'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Can we trust?'", ")", ",", "'messageinlinefiles'", "=>", "new", "external_files", "(", "'post message inline files'", ",", "VALUE_OPTIONAL", ")", ",", "'attachment'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Has attachments?'", ")", ",", "'attachments'", "=>", "new", "external_files", "(", "'attachments'", ",", "VALUE_OPTIONAL", ")", ",", "'totalscore'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The post message total score'", ")", ",", "'mailnow'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Mail now?'", ")", ",", "'children'", "=>", "new", "external_multiple_structure", "(", "new", "external_value", "(", "PARAM_INT", ",", "'children post id'", ")", ")", ",", "'canreply'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'The user can reply to posts?'", ")", ",", "'postread'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'The post was read'", ")", ",", "'userfullname'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Post author full name'", ")", ",", "'userpictureurl'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Post author picture.'", ",", "VALUE_OPTIONAL", ")", ",", "'deleted'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'This post has been removed.'", ")", ",", "'isprivatereply'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'The post is a private reply'", ")", ",", "'tags'", "=>", "new", "external_multiple_structure", "(", "\\", "core_tag", "\\", "external", "\\", "tag_item_exporter", "::", "get_read_structure", "(", ")", ",", "'Tags'", ",", "VALUE_OPTIONAL", ")", ",", ")", ",", "'post'", ")", ")", ",", "'ratinginfo'", "=>", "\\", "core_rating", "\\", "external", "\\", "util", "::", "external_ratings_structure", "(", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ")", ")", ";", "}" ]
Describes the get_forum_discussion_posts return value. @return external_single_structure @since Moodle 2.7
[ "Describes", "the", "get_forum_discussion_posts", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/externallib.php#L446-L485