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
219,200
moodle/moodle
lib/classes/task/manager.php
manager.adhoc_task_from_record
public static function adhoc_task_from_record($record) { $classname = self::get_canonical_class_name($record->classname); if (!class_exists($classname)) { debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER); return false; } $task = new $classname; if (isset($record->nextruntime)) { $task->set_next_run_time($record->nextruntime); } if (isset($record->id)) { $task->set_id($record->id); } if (isset($record->component)) { $task->set_component($record->component); } $task->set_blocking(!empty($record->blocking)); if (isset($record->faildelay)) { $task->set_fail_delay($record->faildelay); } if (isset($record->customdata)) { $task->set_custom_data_as_string($record->customdata); } if (isset($record->userid)) { $task->set_userid($record->userid); } return $task; }
php
public static function adhoc_task_from_record($record) { $classname = self::get_canonical_class_name($record->classname); if (!class_exists($classname)) { debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER); return false; } $task = new $classname; if (isset($record->nextruntime)) { $task->set_next_run_time($record->nextruntime); } if (isset($record->id)) { $task->set_id($record->id); } if (isset($record->component)) { $task->set_component($record->component); } $task->set_blocking(!empty($record->blocking)); if (isset($record->faildelay)) { $task->set_fail_delay($record->faildelay); } if (isset($record->customdata)) { $task->set_custom_data_as_string($record->customdata); } if (isset($record->userid)) { $task->set_userid($record->userid); } return $task; }
[ "public", "static", "function", "adhoc_task_from_record", "(", "$", "record", ")", "{", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "record", "->", "classname", ")", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "debugging", "(", "\"Failed to load task: \"", ".", "$", "classname", ",", "DEBUG_DEVELOPER", ")", ";", "return", "false", ";", "}", "$", "task", "=", "new", "$", "classname", ";", "if", "(", "isset", "(", "$", "record", "->", "nextruntime", ")", ")", "{", "$", "task", "->", "set_next_run_time", "(", "$", "record", "->", "nextruntime", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "id", ")", ")", "{", "$", "task", "->", "set_id", "(", "$", "record", "->", "id", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "component", ")", ")", "{", "$", "task", "->", "set_component", "(", "$", "record", "->", "component", ")", ";", "}", "$", "task", "->", "set_blocking", "(", "!", "empty", "(", "$", "record", "->", "blocking", ")", ")", ";", "if", "(", "isset", "(", "$", "record", "->", "faildelay", ")", ")", "{", "$", "task", "->", "set_fail_delay", "(", "$", "record", "->", "faildelay", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "customdata", ")", ")", "{", "$", "task", "->", "set_custom_data_as_string", "(", "$", "record", "->", "customdata", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "userid", ")", ")", "{", "$", "task", "->", "set_userid", "(", "$", "record", "->", "userid", ")", ";", "}", "return", "$", "task", ";", "}" ]
Utility method to create an adhoc task from a DB record. @param \stdClass $record @return \core\task\adhoc_task
[ "Utility", "method", "to", "create", "an", "adhoc", "task", "from", "a", "DB", "record", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L286-L315
219,201
moodle/moodle
lib/classes/task/manager.php
manager.scheduled_task_from_record
public static function scheduled_task_from_record($record) { $classname = self::get_canonical_class_name($record->classname); if (!class_exists($classname)) { debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER); return false; } /** @var \core\task\scheduled_task $task */ $task = new $classname; if (isset($record->lastruntime)) { $task->set_last_run_time($record->lastruntime); } if (isset($record->nextruntime)) { $task->set_next_run_time($record->nextruntime); } if (isset($record->customised)) { $task->set_customised($record->customised); } if (isset($record->component)) { $task->set_component($record->component); } $task->set_blocking(!empty($record->blocking)); if (isset($record->minute)) { $task->set_minute($record->minute); } if (isset($record->hour)) { $task->set_hour($record->hour); } if (isset($record->day)) { $task->set_day($record->day); } if (isset($record->month)) { $task->set_month($record->month); } if (isset($record->dayofweek)) { $task->set_day_of_week($record->dayofweek); } if (isset($record->faildelay)) { $task->set_fail_delay($record->faildelay); } if (isset($record->disabled)) { $task->set_disabled($record->disabled); } return $task; }
php
public static function scheduled_task_from_record($record) { $classname = self::get_canonical_class_name($record->classname); if (!class_exists($classname)) { debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER); return false; } /** @var \core\task\scheduled_task $task */ $task = new $classname; if (isset($record->lastruntime)) { $task->set_last_run_time($record->lastruntime); } if (isset($record->nextruntime)) { $task->set_next_run_time($record->nextruntime); } if (isset($record->customised)) { $task->set_customised($record->customised); } if (isset($record->component)) { $task->set_component($record->component); } $task->set_blocking(!empty($record->blocking)); if (isset($record->minute)) { $task->set_minute($record->minute); } if (isset($record->hour)) { $task->set_hour($record->hour); } if (isset($record->day)) { $task->set_day($record->day); } if (isset($record->month)) { $task->set_month($record->month); } if (isset($record->dayofweek)) { $task->set_day_of_week($record->dayofweek); } if (isset($record->faildelay)) { $task->set_fail_delay($record->faildelay); } if (isset($record->disabled)) { $task->set_disabled($record->disabled); } return $task; }
[ "public", "static", "function", "scheduled_task_from_record", "(", "$", "record", ")", "{", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "record", "->", "classname", ")", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "debugging", "(", "\"Failed to load task: \"", ".", "$", "classname", ",", "DEBUG_DEVELOPER", ")", ";", "return", "false", ";", "}", "/** @var \\core\\task\\scheduled_task $task */", "$", "task", "=", "new", "$", "classname", ";", "if", "(", "isset", "(", "$", "record", "->", "lastruntime", ")", ")", "{", "$", "task", "->", "set_last_run_time", "(", "$", "record", "->", "lastruntime", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "nextruntime", ")", ")", "{", "$", "task", "->", "set_next_run_time", "(", "$", "record", "->", "nextruntime", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "customised", ")", ")", "{", "$", "task", "->", "set_customised", "(", "$", "record", "->", "customised", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "component", ")", ")", "{", "$", "task", "->", "set_component", "(", "$", "record", "->", "component", ")", ";", "}", "$", "task", "->", "set_blocking", "(", "!", "empty", "(", "$", "record", "->", "blocking", ")", ")", ";", "if", "(", "isset", "(", "$", "record", "->", "minute", ")", ")", "{", "$", "task", "->", "set_minute", "(", "$", "record", "->", "minute", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "hour", ")", ")", "{", "$", "task", "->", "set_hour", "(", "$", "record", "->", "hour", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "day", ")", ")", "{", "$", "task", "->", "set_day", "(", "$", "record", "->", "day", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "month", ")", ")", "{", "$", "task", "->", "set_month", "(", "$", "record", "->", "month", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "dayofweek", ")", ")", "{", "$", "task", "->", "set_day_of_week", "(", "$", "record", "->", "dayofweek", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "faildelay", ")", ")", "{", "$", "task", "->", "set_fail_delay", "(", "$", "record", "->", "faildelay", ")", ";", "}", "if", "(", "isset", "(", "$", "record", "->", "disabled", ")", ")", "{", "$", "task", "->", "set_disabled", "(", "$", "record", "->", "disabled", ")", ";", "}", "return", "$", "task", ";", "}" ]
Utility method to create a task from a DB record. @param \stdClass $record @return \core\task\scheduled_task
[ "Utility", "method", "to", "create", "a", "task", "from", "a", "DB", "record", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L323-L367
219,202
moodle/moodle
lib/classes/task/manager.php
manager.load_scheduled_tasks_for_component
public static function load_scheduled_tasks_for_component($componentname) { global $DB; $tasks = array(); // We are just reading - so no locks required. $records = $DB->get_records('task_scheduled', array('component' => $componentname), 'classname', '*', IGNORE_MISSING); foreach ($records as $record) { $task = self::scheduled_task_from_record($record); // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). if ($task) { $tasks[] = $task; } } return $tasks; }
php
public static function load_scheduled_tasks_for_component($componentname) { global $DB; $tasks = array(); // We are just reading - so no locks required. $records = $DB->get_records('task_scheduled', array('component' => $componentname), 'classname', '*', IGNORE_MISSING); foreach ($records as $record) { $task = self::scheduled_task_from_record($record); // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). if ($task) { $tasks[] = $task; } } return $tasks; }
[ "public", "static", "function", "load_scheduled_tasks_for_component", "(", "$", "componentname", ")", "{", "global", "$", "DB", ";", "$", "tasks", "=", "array", "(", ")", ";", "// We are just reading - so no locks required.", "$", "records", "=", "$", "DB", "->", "get_records", "(", "'task_scheduled'", ",", "array", "(", "'component'", "=>", "$", "componentname", ")", ",", "'classname'", ",", "'*'", ",", "IGNORE_MISSING", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "task", "=", "self", "::", "scheduled_task_from_record", "(", "$", "record", ")", ";", "// Safety check in case the task in the DB does not match a real class (maybe something was uninstalled).", "if", "(", "$", "task", ")", "{", "$", "tasks", "[", "]", "=", "$", "task", ";", "}", "}", "return", "$", "tasks", ";", "}" ]
Given a component name, will load the list of tasks from the scheduled_tasks table for that component. Do not execute tasks loaded from this function - they have not been locked. @param string $componentname - The name of the component to load the tasks for. @return \core\task\scheduled_task[]
[ "Given", "a", "component", "name", "will", "load", "the", "list", "of", "tasks", "from", "the", "scheduled_tasks", "table", "for", "that", "component", ".", "Do", "not", "execute", "tasks", "loaded", "from", "this", "function", "-", "they", "have", "not", "been", "locked", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L375-L390
219,203
moodle/moodle
lib/classes/task/manager.php
manager.get_scheduled_task
public static function get_scheduled_task($classname) { global $DB; $classname = self::get_canonical_class_name($classname); // We are just reading - so no locks required. $record = $DB->get_record('task_scheduled', array('classname'=>$classname), '*', IGNORE_MISSING); if (!$record) { return false; } return self::scheduled_task_from_record($record); }
php
public static function get_scheduled_task($classname) { global $DB; $classname = self::get_canonical_class_name($classname); // We are just reading - so no locks required. $record = $DB->get_record('task_scheduled', array('classname'=>$classname), '*', IGNORE_MISSING); if (!$record) { return false; } return self::scheduled_task_from_record($record); }
[ "public", "static", "function", "get_scheduled_task", "(", "$", "classname", ")", "{", "global", "$", "DB", ";", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "classname", ")", ";", "// We are just reading - so no locks required.", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'task_scheduled'", ",", "array", "(", "'classname'", "=>", "$", "classname", ")", ",", "'*'", ",", "IGNORE_MISSING", ")", ";", "if", "(", "!", "$", "record", ")", "{", "return", "false", ";", "}", "return", "self", "::", "scheduled_task_from_record", "(", "$", "record", ")", ";", "}" ]
This function load the scheduled task details for a given classname. @param string $classname @return \core\task\scheduled_task or false
[ "This", "function", "load", "the", "scheduled", "task", "details", "for", "a", "given", "classname", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L398-L408
219,204
moodle/moodle
lib/classes/task/manager.php
manager.get_adhoc_tasks
public static function get_adhoc_tasks($classname) { global $DB; $classname = self::get_canonical_class_name($classname); // We are just reading - so no locks required. $records = $DB->get_records('task_adhoc', array('classname' => $classname)); return array_map(function($record) { return self::adhoc_task_from_record($record); }, $records); }
php
public static function get_adhoc_tasks($classname) { global $DB; $classname = self::get_canonical_class_name($classname); // We are just reading - so no locks required. $records = $DB->get_records('task_adhoc', array('classname' => $classname)); return array_map(function($record) { return self::adhoc_task_from_record($record); }, $records); }
[ "public", "static", "function", "get_adhoc_tasks", "(", "$", "classname", ")", "{", "global", "$", "DB", ";", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "classname", ")", ";", "// We are just reading - so no locks required.", "$", "records", "=", "$", "DB", "->", "get_records", "(", "'task_adhoc'", ",", "array", "(", "'classname'", "=>", "$", "classname", ")", ")", ";", "return", "array_map", "(", "function", "(", "$", "record", ")", "{", "return", "self", "::", "adhoc_task_from_record", "(", "$", "record", ")", ";", "}", ",", "$", "records", ")", ";", "}" ]
This function load the adhoc tasks for a given classname. @param string $classname @return \core\task\adhoc_task[]
[ "This", "function", "load", "the", "adhoc", "tasks", "for", "a", "given", "classname", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L416-L426
219,205
moodle/moodle
lib/classes/task/manager.php
manager.get_default_scheduled_task
public static function get_default_scheduled_task($classname) { $task = self::get_scheduled_task($classname); $componenttasks = array(); // Safety check in case no task was found for the given classname. if ($task) { $componenttasks = self::load_default_scheduled_tasks_for_component($task->get_component()); } foreach ($componenttasks as $componenttask) { if (get_class($componenttask) == get_class($task)) { return $componenttask; } } return false; }
php
public static function get_default_scheduled_task($classname) { $task = self::get_scheduled_task($classname); $componenttasks = array(); // Safety check in case no task was found for the given classname. if ($task) { $componenttasks = self::load_default_scheduled_tasks_for_component($task->get_component()); } foreach ($componenttasks as $componenttask) { if (get_class($componenttask) == get_class($task)) { return $componenttask; } } return false; }
[ "public", "static", "function", "get_default_scheduled_task", "(", "$", "classname", ")", "{", "$", "task", "=", "self", "::", "get_scheduled_task", "(", "$", "classname", ")", ";", "$", "componenttasks", "=", "array", "(", ")", ";", "// Safety check in case no task was found for the given classname.", "if", "(", "$", "task", ")", "{", "$", "componenttasks", "=", "self", "::", "load_default_scheduled_tasks_for_component", "(", "$", "task", "->", "get_component", "(", ")", ")", ";", "}", "foreach", "(", "$", "componenttasks", "as", "$", "componenttask", ")", "{", "if", "(", "get_class", "(", "$", "componenttask", ")", "==", "get_class", "(", "$", "task", ")", ")", "{", "return", "$", "componenttask", ";", "}", "}", "return", "false", ";", "}" ]
This function load the default scheduled task details for a given classname. @param string $classname @return \core\task\scheduled_task or false
[ "This", "function", "load", "the", "default", "scheduled", "task", "details", "for", "a", "given", "classname", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L434-L450
219,206
moodle/moodle
lib/classes/task/manager.php
manager.get_all_scheduled_tasks
public static function get_all_scheduled_tasks() { global $DB; $records = $DB->get_records('task_scheduled', null, 'component, classname', '*', IGNORE_MISSING); $tasks = array(); foreach ($records as $record) { $task = self::scheduled_task_from_record($record); // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). if ($task) { $tasks[] = $task; } } return $tasks; }
php
public static function get_all_scheduled_tasks() { global $DB; $records = $DB->get_records('task_scheduled', null, 'component, classname', '*', IGNORE_MISSING); $tasks = array(); foreach ($records as $record) { $task = self::scheduled_task_from_record($record); // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled). if ($task) { $tasks[] = $task; } } return $tasks; }
[ "public", "static", "function", "get_all_scheduled_tasks", "(", ")", "{", "global", "$", "DB", ";", "$", "records", "=", "$", "DB", "->", "get_records", "(", "'task_scheduled'", ",", "null", ",", "'component, classname'", ",", "'*'", ",", "IGNORE_MISSING", ")", ";", "$", "tasks", "=", "array", "(", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "task", "=", "self", "::", "scheduled_task_from_record", "(", "$", "record", ")", ";", "// Safety check in case the task in the DB does not match a real class (maybe something was uninstalled).", "if", "(", "$", "task", ")", "{", "$", "tasks", "[", "]", "=", "$", "task", ";", "}", "}", "return", "$", "tasks", ";", "}" ]
This function will return a list of all the scheduled tasks that exist in the database. @return \core\task\scheduled_task[]
[ "This", "function", "will", "return", "a", "list", "of", "all", "the", "scheduled", "tasks", "that", "exist", "in", "the", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L457-L472
219,207
moodle/moodle
lib/classes/task/manager.php
manager.adhoc_task_failed
public static function adhoc_task_failed(adhoc_task $task) { global $DB; $delay = $task->get_fail_delay(); // Reschedule task with exponential fall off for failing tasks. if (empty($delay)) { $delay = 60; } else { $delay *= 2; } // Max of 24 hour delay. if ($delay > 86400) { $delay = 86400; } $classname = self::get_canonical_class_name($task); $task->set_next_run_time(time() + $delay); $task->set_fail_delay($delay); $record = self::record_from_adhoc_task($task); $DB->update_record('task_adhoc', $record); if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); // Finalise the log output. logmanager::finalise_log(true); }
php
public static function adhoc_task_failed(adhoc_task $task) { global $DB; $delay = $task->get_fail_delay(); // Reschedule task with exponential fall off for failing tasks. if (empty($delay)) { $delay = 60; } else { $delay *= 2; } // Max of 24 hour delay. if ($delay > 86400) { $delay = 86400; } $classname = self::get_canonical_class_name($task); $task->set_next_run_time(time() + $delay); $task->set_fail_delay($delay); $record = self::record_from_adhoc_task($task); $DB->update_record('task_adhoc', $record); if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); // Finalise the log output. logmanager::finalise_log(true); }
[ "public", "static", "function", "adhoc_task_failed", "(", "adhoc_task", "$", "task", ")", "{", "global", "$", "DB", ";", "$", "delay", "=", "$", "task", "->", "get_fail_delay", "(", ")", ";", "// Reschedule task with exponential fall off for failing tasks.", "if", "(", "empty", "(", "$", "delay", ")", ")", "{", "$", "delay", "=", "60", ";", "}", "else", "{", "$", "delay", "*=", "2", ";", "}", "// Max of 24 hour delay.", "if", "(", "$", "delay", ">", "86400", ")", "{", "$", "delay", "=", "86400", ";", "}", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "task", ")", ";", "$", "task", "->", "set_next_run_time", "(", "time", "(", ")", "+", "$", "delay", ")", ";", "$", "task", "->", "set_fail_delay", "(", "$", "delay", ")", ";", "$", "record", "=", "self", "::", "record_from_adhoc_task", "(", "$", "task", ")", ";", "$", "DB", "->", "update_record", "(", "'task_adhoc'", ",", "$", "record", ")", ";", "if", "(", "$", "task", "->", "is_blocking", "(", ")", ")", "{", "$", "task", "->", "get_cron_lock", "(", ")", "->", "release", "(", ")", ";", "}", "$", "task", "->", "get_lock", "(", ")", "->", "release", "(", ")", ";", "// Finalise the log output.", "logmanager", "::", "finalise_log", "(", "true", ")", ";", "}" ]
This function indicates that an adhoc task was not completed successfully and should be retried. @param \core\task\adhoc_task $task
[ "This", "function", "indicates", "that", "an", "adhoc", "task", "was", "not", "completed", "successfully", "and", "should", "be", "retried", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L601-L631
219,208
moodle/moodle
lib/classes/task/manager.php
manager.adhoc_task_complete
public static function adhoc_task_complete(adhoc_task $task) { global $DB; // Finalise the log output. logmanager::finalise_log(); // Delete the adhoc task record - it is finished. $DB->delete_records('task_adhoc', array('id' => $task->get_id())); // Reschedule and then release the locks. if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); }
php
public static function adhoc_task_complete(adhoc_task $task) { global $DB; // Finalise the log output. logmanager::finalise_log(); // Delete the adhoc task record - it is finished. $DB->delete_records('task_adhoc', array('id' => $task->get_id())); // Reschedule and then release the locks. if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); }
[ "public", "static", "function", "adhoc_task_complete", "(", "adhoc_task", "$", "task", ")", "{", "global", "$", "DB", ";", "// Finalise the log output.", "logmanager", "::", "finalise_log", "(", ")", ";", "// Delete the adhoc task record - it is finished.", "$", "DB", "->", "delete_records", "(", "'task_adhoc'", ",", "array", "(", "'id'", "=>", "$", "task", "->", "get_id", "(", ")", ")", ")", ";", "// Reschedule and then release the locks.", "if", "(", "$", "task", "->", "is_blocking", "(", ")", ")", "{", "$", "task", "->", "get_cron_lock", "(", ")", "->", "release", "(", ")", ";", "}", "$", "task", "->", "get_lock", "(", ")", "->", "release", "(", ")", ";", "}" ]
This function indicates that an adhoc task was completed successfully. @param \core\task\adhoc_task $task
[ "This", "function", "indicates", "that", "an", "adhoc", "task", "was", "completed", "successfully", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L638-L652
219,209
moodle/moodle
lib/classes/task/manager.php
manager.scheduled_task_failed
public static function scheduled_task_failed(scheduled_task $task) { global $DB; $delay = $task->get_fail_delay(); // Reschedule task with exponential fall off for failing tasks. if (empty($delay)) { $delay = 60; } else { $delay *= 2; } // Max of 24 hour delay. if ($delay > 86400) { $delay = 86400; } $classname = self::get_canonical_class_name($task); $record = $DB->get_record('task_scheduled', array('classname' => $classname)); $record->nextruntime = time() + $delay; $record->faildelay = $delay; $DB->update_record('task_scheduled', $record); if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); // Finalise the log output. logmanager::finalise_log(true); }
php
public static function scheduled_task_failed(scheduled_task $task) { global $DB; $delay = $task->get_fail_delay(); // Reschedule task with exponential fall off for failing tasks. if (empty($delay)) { $delay = 60; } else { $delay *= 2; } // Max of 24 hour delay. if ($delay > 86400) { $delay = 86400; } $classname = self::get_canonical_class_name($task); $record = $DB->get_record('task_scheduled', array('classname' => $classname)); $record->nextruntime = time() + $delay; $record->faildelay = $delay; $DB->update_record('task_scheduled', $record); if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); // Finalise the log output. logmanager::finalise_log(true); }
[ "public", "static", "function", "scheduled_task_failed", "(", "scheduled_task", "$", "task", ")", "{", "global", "$", "DB", ";", "$", "delay", "=", "$", "task", "->", "get_fail_delay", "(", ")", ";", "// Reschedule task with exponential fall off for failing tasks.", "if", "(", "empty", "(", "$", "delay", ")", ")", "{", "$", "delay", "=", "60", ";", "}", "else", "{", "$", "delay", "*=", "2", ";", "}", "// Max of 24 hour delay.", "if", "(", "$", "delay", ">", "86400", ")", "{", "$", "delay", "=", "86400", ";", "}", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "task", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'task_scheduled'", ",", "array", "(", "'classname'", "=>", "$", "classname", ")", ")", ";", "$", "record", "->", "nextruntime", "=", "time", "(", ")", "+", "$", "delay", ";", "$", "record", "->", "faildelay", "=", "$", "delay", ";", "$", "DB", "->", "update_record", "(", "'task_scheduled'", ",", "$", "record", ")", ";", "if", "(", "$", "task", "->", "is_blocking", "(", ")", ")", "{", "$", "task", "->", "get_cron_lock", "(", ")", "->", "release", "(", ")", ";", "}", "$", "task", "->", "get_lock", "(", ")", "->", "release", "(", ")", ";", "// Finalise the log output.", "logmanager", "::", "finalise_log", "(", "true", ")", ";", "}" ]
This function indicates that a scheduled task was not completed successfully and should be retried. @param \core\task\scheduled_task $task
[ "This", "function", "indicates", "that", "a", "scheduled", "task", "was", "not", "completed", "successfully", "and", "should", "be", "retried", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L659-L690
219,210
moodle/moodle
lib/classes/task/manager.php
manager.clear_fail_delay
public static function clear_fail_delay(scheduled_task $task) { global $DB; $record = new \stdClass(); $record->id = $DB->get_field('task_scheduled', 'id', ['classname' => self::get_canonical_class_name($task)]); $record->nextruntime = $task->get_next_scheduled_time(); $record->faildelay = 0; $DB->update_record('task_scheduled', $record); }
php
public static function clear_fail_delay(scheduled_task $task) { global $DB; $record = new \stdClass(); $record->id = $DB->get_field('task_scheduled', 'id', ['classname' => self::get_canonical_class_name($task)]); $record->nextruntime = $task->get_next_scheduled_time(); $record->faildelay = 0; $DB->update_record('task_scheduled', $record); }
[ "public", "static", "function", "clear_fail_delay", "(", "scheduled_task", "$", "task", ")", "{", "global", "$", "DB", ";", "$", "record", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "record", "->", "id", "=", "$", "DB", "->", "get_field", "(", "'task_scheduled'", ",", "'id'", ",", "[", "'classname'", "=>", "self", "::", "get_canonical_class_name", "(", "$", "task", ")", "]", ")", ";", "$", "record", "->", "nextruntime", "=", "$", "task", "->", "get_next_scheduled_time", "(", ")", ";", "$", "record", "->", "faildelay", "=", "0", ";", "$", "DB", "->", "update_record", "(", "'task_scheduled'", ",", "$", "record", ")", ";", "}" ]
Clears the fail delay for the given task and updates its next run time based on the schedule. @param scheduled_task $task Task to reset @throws \dml_exception If there is a database error
[ "Clears", "the", "fail", "delay", "for", "the", "given", "task", "and", "updates", "its", "next", "run", "time", "based", "on", "the", "schedule", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L698-L707
219,211
moodle/moodle
lib/classes/task/manager.php
manager.scheduled_task_complete
public static function scheduled_task_complete(scheduled_task $task) { global $DB; // Finalise the log output. logmanager::finalise_log(); $classname = self::get_canonical_class_name($task); $record = $DB->get_record('task_scheduled', array('classname' => $classname)); if ($record) { $record->lastruntime = time(); $record->faildelay = 0; $record->nextruntime = $task->get_next_scheduled_time(); $DB->update_record('task_scheduled', $record); } // Reschedule and then release the locks. if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); }
php
public static function scheduled_task_complete(scheduled_task $task) { global $DB; // Finalise the log output. logmanager::finalise_log(); $classname = self::get_canonical_class_name($task); $record = $DB->get_record('task_scheduled', array('classname' => $classname)); if ($record) { $record->lastruntime = time(); $record->faildelay = 0; $record->nextruntime = $task->get_next_scheduled_time(); $DB->update_record('task_scheduled', $record); } // Reschedule and then release the locks. if ($task->is_blocking()) { $task->get_cron_lock()->release(); } $task->get_lock()->release(); }
[ "public", "static", "function", "scheduled_task_complete", "(", "scheduled_task", "$", "task", ")", "{", "global", "$", "DB", ";", "// Finalise the log output.", "logmanager", "::", "finalise_log", "(", ")", ";", "$", "classname", "=", "self", "::", "get_canonical_class_name", "(", "$", "task", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'task_scheduled'", ",", "array", "(", "'classname'", "=>", "$", "classname", ")", ")", ";", "if", "(", "$", "record", ")", "{", "$", "record", "->", "lastruntime", "=", "time", "(", ")", ";", "$", "record", "->", "faildelay", "=", "0", ";", "$", "record", "->", "nextruntime", "=", "$", "task", "->", "get_next_scheduled_time", "(", ")", ";", "$", "DB", "->", "update_record", "(", "'task_scheduled'", ",", "$", "record", ")", ";", "}", "// Reschedule and then release the locks.", "if", "(", "$", "task", "->", "is_blocking", "(", ")", ")", "{", "$", "task", "->", "get_cron_lock", "(", ")", "->", "release", "(", ")", ";", "}", "$", "task", "->", "get_lock", "(", ")", "->", "release", "(", ")", ";", "}" ]
This function indicates that a scheduled task was completed successfully and should be rescheduled. @param \core\task\scheduled_task $task
[ "This", "function", "indicates", "that", "a", "scheduled", "task", "was", "completed", "successfully", "and", "should", "be", "rescheduled", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L714-L735
219,212
moodle/moodle
lib/classes/task/manager.php
manager.get_canonical_class_name
protected static function get_canonical_class_name($taskorstring) { if (is_string($taskorstring)) { $classname = $taskorstring; } else { $classname = get_class($taskorstring); } if (strpos($classname, '\\') !== 0) { $classname = '\\' . $classname; } return $classname; }
php
protected static function get_canonical_class_name($taskorstring) { if (is_string($taskorstring)) { $classname = $taskorstring; } else { $classname = get_class($taskorstring); } if (strpos($classname, '\\') !== 0) { $classname = '\\' . $classname; } return $classname; }
[ "protected", "static", "function", "get_canonical_class_name", "(", "$", "taskorstring", ")", "{", "if", "(", "is_string", "(", "$", "taskorstring", ")", ")", "{", "$", "classname", "=", "$", "taskorstring", ";", "}", "else", "{", "$", "classname", "=", "get_class", "(", "$", "taskorstring", ")", ";", "}", "if", "(", "strpos", "(", "$", "classname", ",", "'\\\\'", ")", "!==", "0", ")", "{", "$", "classname", "=", "'\\\\'", ".", "$", "classname", ";", "}", "return", "$", "classname", ";", "}" ]
Gets class name for use in database table. Always begins with a \. @param string|task_base $taskorstring Task object or a string
[ "Gets", "class", "name", "for", "use", "in", "database", "table", ".", "Always", "begins", "with", "a", "\\", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/manager.php#L773-L783
219,213
moodle/moodle
lib/grade/grade_object.php
grade_object.fetch_all_helper
public static function fetch_all_helper($table, $classname, $params) { global $DB; // Need to introspect DB here. $instance = new $classname(); $classvars = (array)$instance; $params = (array)$params; $wheresql = array(); $newparams = array(); $columns = $DB->get_columns($table); // Cached, no worries. foreach ($params as $var=>$value) { if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) { continue; } if (!array_key_exists($var, $columns)) { continue; } if (is_null($value)) { $wheresql[] = " $var IS NULL "; } else { if ($columns[$var]->meta_type === 'X') { // We have a text/clob column, use the cross-db method for its comparison. $wheresql[] = ' ' . $DB->sql_compare_text($var) . ' = ' . $DB->sql_compare_text('?') . ' '; } else { // Other columns (varchar, integers...). $wheresql[] = " $var = ? "; } $newparams[] = $value; } } if (empty($wheresql)) { $wheresql = ''; } else { $wheresql = implode("AND", $wheresql); } global $DB; $rs = $DB->get_recordset_select($table, $wheresql, $newparams); //returning false rather than empty array if nothing found if (!$rs->valid()) { $rs->close(); return false; } $result = array(); foreach($rs as $data) { $instance = new $classname(); grade_object::set_properties($instance, $data); $result[$instance->id] = $instance; } $rs->close(); return $result; }
php
public static function fetch_all_helper($table, $classname, $params) { global $DB; // Need to introspect DB here. $instance = new $classname(); $classvars = (array)$instance; $params = (array)$params; $wheresql = array(); $newparams = array(); $columns = $DB->get_columns($table); // Cached, no worries. foreach ($params as $var=>$value) { if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) { continue; } if (!array_key_exists($var, $columns)) { continue; } if (is_null($value)) { $wheresql[] = " $var IS NULL "; } else { if ($columns[$var]->meta_type === 'X') { // We have a text/clob column, use the cross-db method for its comparison. $wheresql[] = ' ' . $DB->sql_compare_text($var) . ' = ' . $DB->sql_compare_text('?') . ' '; } else { // Other columns (varchar, integers...). $wheresql[] = " $var = ? "; } $newparams[] = $value; } } if (empty($wheresql)) { $wheresql = ''; } else { $wheresql = implode("AND", $wheresql); } global $DB; $rs = $DB->get_recordset_select($table, $wheresql, $newparams); //returning false rather than empty array if nothing found if (!$rs->valid()) { $rs->close(); return false; } $result = array(); foreach($rs as $data) { $instance = new $classname(); grade_object::set_properties($instance, $data); $result[$instance->id] = $instance; } $rs->close(); return $result; }
[ "public", "static", "function", "fetch_all_helper", "(", "$", "table", ",", "$", "classname", ",", "$", "params", ")", "{", "global", "$", "DB", ";", "// Need to introspect DB here.", "$", "instance", "=", "new", "$", "classname", "(", ")", ";", "$", "classvars", "=", "(", "array", ")", "$", "instance", ";", "$", "params", "=", "(", "array", ")", "$", "params", ";", "$", "wheresql", "=", "array", "(", ")", ";", "$", "newparams", "=", "array", "(", ")", ";", "$", "columns", "=", "$", "DB", "->", "get_columns", "(", "$", "table", ")", ";", "// Cached, no worries.", "foreach", "(", "$", "params", "as", "$", "var", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "var", ",", "$", "instance", "->", "required_fields", ")", "and", "!", "array_key_exists", "(", "$", "var", ",", "$", "instance", "->", "optional_fields", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "var", ",", "$", "columns", ")", ")", "{", "continue", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "wheresql", "[", "]", "=", "\" $var IS NULL \"", ";", "}", "else", "{", "if", "(", "$", "columns", "[", "$", "var", "]", "->", "meta_type", "===", "'X'", ")", "{", "// We have a text/clob column, use the cross-db method for its comparison.", "$", "wheresql", "[", "]", "=", "' '", ".", "$", "DB", "->", "sql_compare_text", "(", "$", "var", ")", ".", "' = '", ".", "$", "DB", "->", "sql_compare_text", "(", "'?'", ")", ".", "' '", ";", "}", "else", "{", "// Other columns (varchar, integers...).", "$", "wheresql", "[", "]", "=", "\" $var = ? \"", ";", "}", "$", "newparams", "[", "]", "=", "$", "value", ";", "}", "}", "if", "(", "empty", "(", "$", "wheresql", ")", ")", "{", "$", "wheresql", "=", "''", ";", "}", "else", "{", "$", "wheresql", "=", "implode", "(", "\"AND\"", ",", "$", "wheresql", ")", ";", "}", "global", "$", "DB", ";", "$", "rs", "=", "$", "DB", "->", "get_recordset_select", "(", "$", "table", ",", "$", "wheresql", ",", "$", "newparams", ")", ";", "//returning false rather than empty array if nothing found", "if", "(", "!", "$", "rs", "->", "valid", "(", ")", ")", "{", "$", "rs", "->", "close", "(", ")", ";", "return", "false", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "rs", "as", "$", "data", ")", "{", "$", "instance", "=", "new", "$", "classname", "(", ")", ";", "grade_object", "::", "set_properties", "(", "$", "instance", ",", "$", "data", ")", ";", "$", "result", "[", "$", "instance", "->", "id", "]", "=", "$", "instance", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "return", "$", "result", ";", "}" ]
Factory method which uses the parameters to retrieve all matching instances from the database @param string $table The table to retrieve from @param string $classname The name of the class to instantiate @param array $params An array of conditions like $fieldname => $fieldvalue @return array|bool Array of object instances or false if not found
[ "Factory", "method", "which", "uses", "the", "parameters", "to", "retrieve", "all", "matching", "instances", "from", "the", "database" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_object.php#L179-L235
219,214
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.fetch_and_start_tour
public static function fetch_and_start_tour($tourid, $context, $pageurl) { global $PAGE; $params = self::validate_parameters(self::fetch_and_start_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); if (!$tour->should_show_for_user()) { return []; } $touroutput = new \tool_usertours\output\tour($tour); \tool_usertours\event\tour_started::create([ 'contextid' => $context->id, 'objectid' => $tourid, 'other' => [ 'pageurl' => $pageurl, ], ])->trigger(); return [ 'tourconfig' => $touroutput->export_for_template($PAGE->get_renderer('core')), ]; }
php
public static function fetch_and_start_tour($tourid, $context, $pageurl) { global $PAGE; $params = self::validate_parameters(self::fetch_and_start_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); if (!$tour->should_show_for_user()) { return []; } $touroutput = new \tool_usertours\output\tour($tour); \tool_usertours\event\tour_started::create([ 'contextid' => $context->id, 'objectid' => $tourid, 'other' => [ 'pageurl' => $pageurl, ], ])->trigger(); return [ 'tourconfig' => $touroutput->export_for_template($PAGE->get_renderer('core')), ]; }
[ "public", "static", "function", "fetch_and_start_tour", "(", "$", "tourid", ",", "$", "context", ",", "$", "pageurl", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "fetch_and_start_tour_parameters", "(", ")", ",", "[", "'tourid'", "=>", "$", "tourid", ",", "'context'", "=>", "$", "context", ",", "'pageurl'", "=>", "$", "pageurl", ",", "]", ")", ";", "$", "context", "=", "\\", "context_helper", "::", "instance_by_id", "(", "$", "params", "[", "'context'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "tour", "=", "tourinstance", "::", "instance", "(", "$", "params", "[", "'tourid'", "]", ")", ";", "if", "(", "!", "$", "tour", "->", "should_show_for_user", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "touroutput", "=", "new", "\\", "tool_usertours", "\\", "output", "\\", "tour", "(", "$", "tour", ")", ";", "\\", "tool_usertours", "\\", "event", "\\", "tour_started", "::", "create", "(", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'objectid'", "=>", "$", "tourid", ",", "'other'", "=>", "[", "'pageurl'", "=>", "$", "pageurl", ",", "]", ",", "]", ")", "->", "trigger", "(", ")", ";", "return", "[", "'tourconfig'", "=>", "$", "touroutput", "->", "export_for_template", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ",", "]", ";", "}" ]
Fetch the tour configuration for the specified tour. @param int $tourid The ID of the tour to fetch. @param int $context The Context ID of the current page. @param string $pageurl The path of the current page. @return array As described in fetch_and_start_tour_returns
[ "Fetch", "the", "tour", "configuration", "for", "the", "specified", "tour", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L52-L82
219,215
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.reset_tour
public static function reset_tour($tourid, $context, $pageurl) { $params = self::validate_parameters(self::reset_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); $tour->request_user_reset(); $result = []; if ($tourinstance = \tool_usertours\manager::get_matching_tours(new \moodle_url($params['pageurl']))) { if ($tour->get_id() === $tourinstance->get_id()) { $result['startTour'] = $tour->get_id(); \tool_usertours\event\tour_reset::create([ 'contextid' => $context->id, 'objectid' => $params['tourid'], 'other' => [ 'pageurl' => $params['pageurl'], ], ])->trigger(); } } return $result; }
php
public static function reset_tour($tourid, $context, $pageurl) { $params = self::validate_parameters(self::reset_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); $tour->request_user_reset(); $result = []; if ($tourinstance = \tool_usertours\manager::get_matching_tours(new \moodle_url($params['pageurl']))) { if ($tour->get_id() === $tourinstance->get_id()) { $result['startTour'] = $tour->get_id(); \tool_usertours\event\tour_reset::create([ 'contextid' => $context->id, 'objectid' => $params['tourid'], 'other' => [ 'pageurl' => $params['pageurl'], ], ])->trigger(); } } return $result; }
[ "public", "static", "function", "reset_tour", "(", "$", "tourid", ",", "$", "context", ",", "$", "pageurl", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "reset_tour_parameters", "(", ")", ",", "[", "'tourid'", "=>", "$", "tourid", ",", "'context'", "=>", "$", "context", ",", "'pageurl'", "=>", "$", "pageurl", ",", "]", ")", ";", "$", "context", "=", "\\", "context_helper", "::", "instance_by_id", "(", "$", "params", "[", "'context'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "tour", "=", "tourinstance", "::", "instance", "(", "$", "params", "[", "'tourid'", "]", ")", ";", "$", "tour", "->", "request_user_reset", "(", ")", ";", "$", "result", "=", "[", "]", ";", "if", "(", "$", "tourinstance", "=", "\\", "tool_usertours", "\\", "manager", "::", "get_matching_tours", "(", "new", "\\", "moodle_url", "(", "$", "params", "[", "'pageurl'", "]", ")", ")", ")", "{", "if", "(", "$", "tour", "->", "get_id", "(", ")", "===", "$", "tourinstance", "->", "get_id", "(", ")", ")", "{", "$", "result", "[", "'startTour'", "]", "=", "$", "tour", "->", "get_id", "(", ")", ";", "\\", "tool_usertours", "\\", "event", "\\", "tour_reset", "::", "create", "(", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'objectid'", "=>", "$", "params", "[", "'tourid'", "]", ",", "'other'", "=>", "[", "'pageurl'", "=>", "$", "params", "[", "'pageurl'", "]", ",", "]", ",", "]", ")", "->", "trigger", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Reset the specified tour for the current user. @param int $tourid The ID of the tour. @param int $context The Context ID of the current page. @param string $pageurl The path of the current page requesting the reset. @return array As described in reset_tour_returns
[ "Reset", "the", "specified", "tour", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L119-L150
219,216
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.complete_tour
public static function complete_tour($tourid, $context, $pageurl, $stepid, $stepindex) { $params = self::validate_parameters(self::complete_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, 'stepid' => $stepid, 'stepindex' => $stepindex, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); $tour->mark_user_completed(); \tool_usertours\event\tour_ended::create([ 'contextid' => $context->id, 'objectid' => $params['tourid'], 'other' => [ 'pageurl' => $params['pageurl'], 'stepid' => $params['stepid'], 'stepindex' => $params['stepindex'], ], ])->trigger(); return []; }
php
public static function complete_tour($tourid, $context, $pageurl, $stepid, $stepindex) { $params = self::validate_parameters(self::complete_tour_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, 'stepid' => $stepid, 'stepindex' => $stepindex, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $tour = tourinstance::instance($params['tourid']); $tour->mark_user_completed(); \tool_usertours\event\tour_ended::create([ 'contextid' => $context->id, 'objectid' => $params['tourid'], 'other' => [ 'pageurl' => $params['pageurl'], 'stepid' => $params['stepid'], 'stepindex' => $params['stepindex'], ], ])->trigger(); return []; }
[ "public", "static", "function", "complete_tour", "(", "$", "tourid", ",", "$", "context", ",", "$", "pageurl", ",", "$", "stepid", ",", "$", "stepindex", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "complete_tour_parameters", "(", ")", ",", "[", "'tourid'", "=>", "$", "tourid", ",", "'context'", "=>", "$", "context", ",", "'pageurl'", "=>", "$", "pageurl", ",", "'stepid'", "=>", "$", "stepid", ",", "'stepindex'", "=>", "$", "stepindex", ",", "]", ")", ";", "$", "context", "=", "\\", "context_helper", "::", "instance_by_id", "(", "$", "params", "[", "'context'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "tour", "=", "tourinstance", "::", "instance", "(", "$", "params", "[", "'tourid'", "]", ")", ";", "$", "tour", "->", "mark_user_completed", "(", ")", ";", "\\", "tool_usertours", "\\", "event", "\\", "tour_ended", "::", "create", "(", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'objectid'", "=>", "$", "params", "[", "'tourid'", "]", ",", "'other'", "=>", "[", "'pageurl'", "=>", "$", "params", "[", "'pageurl'", "]", ",", "'stepid'", "=>", "$", "params", "[", "'stepid'", "]", ",", "'stepindex'", "=>", "$", "params", "[", "'stepindex'", "]", ",", "]", ",", "]", ")", "->", "trigger", "(", ")", ";", "return", "[", "]", ";", "}" ]
Mark the specified tour as completed for the current user. @param int $tourid The ID of the tour. @param int $context The Context ID of the current page. @param string $pageurl The path of the current page. @param int $stepid The step id @param int $stepindex The step index @return array As described in complete_tour_returns
[ "Mark", "the", "specified", "tour", "as", "completed", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L186-L212
219,217
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.complete_tour_parameters
public static function complete_tour_parameters() { return new external_function_parameters([ 'tourid' => new external_value(PARAM_INT, 'Tour ID'), 'context' => new external_value(PARAM_INT, 'Context ID'), 'pageurl' => new external_value(PARAM_LOCALURL, 'Page URL'), 'stepid' => new external_value(PARAM_INT, 'Step ID'), 'stepindex' => new external_value(PARAM_INT, 'Step Number'), ]); }
php
public static function complete_tour_parameters() { return new external_function_parameters([ 'tourid' => new external_value(PARAM_INT, 'Tour ID'), 'context' => new external_value(PARAM_INT, 'Context ID'), 'pageurl' => new external_value(PARAM_LOCALURL, 'Page URL'), 'stepid' => new external_value(PARAM_INT, 'Step ID'), 'stepindex' => new external_value(PARAM_INT, 'Step Number'), ]); }
[ "public", "static", "function", "complete_tour_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "[", "'tourid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tour ID'", ")", ",", "'context'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Context ID'", ")", ",", "'pageurl'", "=>", "new", "external_value", "(", "PARAM_LOCALURL", ",", "'Page URL'", ")", ",", "'stepid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Step ID'", ")", ",", "'stepindex'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Step Number'", ")", ",", "]", ")", ";", "}" ]
The parameters for complete_tour. @return external_function_parameters
[ "The", "parameters", "for", "complete_tour", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L219-L227
219,218
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.step_shown
public static function step_shown($tourid, $context, $pageurl, $stepid, $stepindex) { $params = self::validate_parameters(self::step_shown_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, 'stepid' => $stepid, 'stepindex' => $stepindex, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $step = step::instance($params['stepid']); if ($step->get_tourid() != $params['tourid']) { throw new \moodle_exception('Incorrect tour specified.'); } \tool_usertours\event\step_shown::create([ 'contextid' => $context->id, 'objectid' => $params['stepid'], 'other' => [ 'pageurl' => $params['pageurl'], 'tourid' => $params['tourid'], 'stepindex' => $params['stepindex'], ], ])->trigger(); return []; }
php
public static function step_shown($tourid, $context, $pageurl, $stepid, $stepindex) { $params = self::validate_parameters(self::step_shown_parameters(), [ 'tourid' => $tourid, 'context' => $context, 'pageurl' => $pageurl, 'stepid' => $stepid, 'stepindex' => $stepindex, ]); $context = \context_helper::instance_by_id($params['context']); self::validate_context($context); $step = step::instance($params['stepid']); if ($step->get_tourid() != $params['tourid']) { throw new \moodle_exception('Incorrect tour specified.'); } \tool_usertours\event\step_shown::create([ 'contextid' => $context->id, 'objectid' => $params['stepid'], 'other' => [ 'pageurl' => $params['pageurl'], 'tourid' => $params['tourid'], 'stepindex' => $params['stepindex'], ], ])->trigger(); return []; }
[ "public", "static", "function", "step_shown", "(", "$", "tourid", ",", "$", "context", ",", "$", "pageurl", ",", "$", "stepid", ",", "$", "stepindex", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "step_shown_parameters", "(", ")", ",", "[", "'tourid'", "=>", "$", "tourid", ",", "'context'", "=>", "$", "context", ",", "'pageurl'", "=>", "$", "pageurl", ",", "'stepid'", "=>", "$", "stepid", ",", "'stepindex'", "=>", "$", "stepindex", ",", "]", ")", ";", "$", "context", "=", "\\", "context_helper", "::", "instance_by_id", "(", "$", "params", "[", "'context'", "]", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "step", "=", "step", "::", "instance", "(", "$", "params", "[", "'stepid'", "]", ")", ";", "if", "(", "$", "step", "->", "get_tourid", "(", ")", "!=", "$", "params", "[", "'tourid'", "]", ")", "{", "throw", "new", "\\", "moodle_exception", "(", "'Incorrect tour specified.'", ")", ";", "}", "\\", "tool_usertours", "\\", "event", "\\", "step_shown", "::", "create", "(", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'objectid'", "=>", "$", "params", "[", "'stepid'", "]", ",", "'other'", "=>", "[", "'pageurl'", "=>", "$", "params", "[", "'pageurl'", "]", ",", "'tourid'", "=>", "$", "params", "[", "'tourid'", "]", ",", "'stepindex'", "=>", "$", "params", "[", "'stepindex'", "]", ",", "]", ",", "]", ")", "->", "trigger", "(", ")", ";", "return", "[", "]", ";", "}" ]
Mark the specified toru step as shown for the current user. @param int $tourid The ID of the tour. @param int $context The Context ID of the current page. @param string $pageurl The path of the current page. @param int $stepid The step id @param int $stepindex The step index @return array As described in complete_tour_returns
[ "Mark", "the", "specified", "toru", "step", "as", "shown", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L248-L277
219,219
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.step_shown_parameters
public static function step_shown_parameters() { return new external_function_parameters([ 'tourid' => new external_value(PARAM_INT, 'Tour ID'), 'context' => new external_value(PARAM_INT, 'Context ID'), 'pageurl' => new external_value(PARAM_URL, 'Page URL'), 'stepid' => new external_value(PARAM_INT, 'Step ID'), 'stepindex' => new external_value(PARAM_INT, 'Step Number'), ]); }
php
public static function step_shown_parameters() { return new external_function_parameters([ 'tourid' => new external_value(PARAM_INT, 'Tour ID'), 'context' => new external_value(PARAM_INT, 'Context ID'), 'pageurl' => new external_value(PARAM_URL, 'Page URL'), 'stepid' => new external_value(PARAM_INT, 'Step ID'), 'stepindex' => new external_value(PARAM_INT, 'Step Number'), ]); }
[ "public", "static", "function", "step_shown_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "[", "'tourid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tour ID'", ")", ",", "'context'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Context ID'", ")", ",", "'pageurl'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Page URL'", ")", ",", "'stepid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Step ID'", ")", ",", "'stepindex'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Step Number'", ")", ",", "]", ")", ";", "}" ]
The parameters for step_shown. @return external_function_parameters
[ "The", "parameters", "for", "step_shown", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L284-L292
219,220
moodle/moodle
admin/tool/usertours/classes/external/tour.php
tour.step_structure_returns
public static function step_structure_returns() { return new external_single_structure([ 'title' => new external_value(PARAM_RAW, 'Step Title'), 'content' => new external_value(PARAM_RAW, 'Step Content'), 'element' => new external_value(PARAM_TEXT, 'Step Target'), 'placement' => new external_value(PARAM_TEXT, 'Step Placement'), 'delay' => new external_value(PARAM_INT, 'Delay before showing the step (ms)', VALUE_OPTIONAL), 'backdrop' => new external_value(PARAM_BOOL, 'Whether a backdrop should be used', VALUE_OPTIONAL), 'reflex' => new external_value(PARAM_BOOL, 'Whether to move to the next step when the target element is clicked', VALUE_OPTIONAL), 'orphan' => new external_value(PARAM_BOOL, 'Whether to display the step even if it could not be found', VALUE_OPTIONAL), 'stepid' => new external_value(PARAM_INT, 'The actual ID of the step', VALUE_OPTIONAL), ]); }
php
public static function step_structure_returns() { return new external_single_structure([ 'title' => new external_value(PARAM_RAW, 'Step Title'), 'content' => new external_value(PARAM_RAW, 'Step Content'), 'element' => new external_value(PARAM_TEXT, 'Step Target'), 'placement' => new external_value(PARAM_TEXT, 'Step Placement'), 'delay' => new external_value(PARAM_INT, 'Delay before showing the step (ms)', VALUE_OPTIONAL), 'backdrop' => new external_value(PARAM_BOOL, 'Whether a backdrop should be used', VALUE_OPTIONAL), 'reflex' => new external_value(PARAM_BOOL, 'Whether to move to the next step when the target element is clicked', VALUE_OPTIONAL), 'orphan' => new external_value(PARAM_BOOL, 'Whether to display the step even if it could not be found', VALUE_OPTIONAL), 'stepid' => new external_value(PARAM_INT, 'The actual ID of the step', VALUE_OPTIONAL), ]); }
[ "public", "static", "function", "step_structure_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "[", "'title'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Step Title'", ")", ",", "'content'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Step Content'", ")", ",", "'element'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Step Target'", ")", ",", "'placement'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Step Placement'", ")", ",", "'delay'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Delay before showing the step (ms)'", ",", "VALUE_OPTIONAL", ")", ",", "'backdrop'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether a backdrop should be used'", ",", "VALUE_OPTIONAL", ")", ",", "'reflex'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether to move to the next step when the target element is clicked'", ",", "VALUE_OPTIONAL", ")", ",", "'orphan'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether to display the step even if it could not be found'", ",", "VALUE_OPTIONAL", ")", ",", "'stepid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The actual ID of the step'", ",", "VALUE_OPTIONAL", ")", ",", "]", ")", ";", "}" ]
The standard return structure for a step. @return external_multiple_structure
[ "The", "standard", "return", "structure", "for", "a", "step", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/external/tour.php#L308-L329
219,221
moodle/moodle
mod/quiz/classes/form/randomquestion_form.php
randomquestion_form.definition
public function definition() { $mform = $this->_form; $contexts = $this->_customdata['contexts']; $usablecontexts = $contexts->having_cap('moodle/question:useall'); // Standard fields at the start of the form. $mform->addElement('header', 'generalheader', get_string("general", 'form')); $mform->addElement('questioncategory', 'category', get_string('category', 'question'), array('contexts' => $usablecontexts, 'top' => true)); $mform->addElement('advcheckbox', 'includesubcategories', get_string('recurse', 'quiz'), null, null, array(0, 1)); $tops = question_get_top_categories_for_contexts(array_column($contexts->all(), 'id')); $mform->hideIf('includesubcategories', 'category', 'in', $tops); $tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $usablecontexts); $tagstrings = array(); foreach ($tags as $tag) { $tagstrings["{$tag->id},{$tag->name}"] = $tag->name; } $options = array( 'multiple' => true, 'noselectionstring' => get_string('anytags', 'quiz'), ); $mform->addElement('autocomplete', 'fromtags', get_string('randomquestiontags', 'mod_quiz'), $tagstrings, $options); $mform->addHelpButton('fromtags', 'randomquestiontags', 'mod_quiz'); $mform->addElement('hidden', 'slotid'); $mform->setType('slotid', PARAM_INT); $mform->addElement('hidden', 'returnurl'); $mform->setType('returnurl', PARAM_LOCALURL); $buttonarray = array(); $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
php
public function definition() { $mform = $this->_form; $contexts = $this->_customdata['contexts']; $usablecontexts = $contexts->having_cap('moodle/question:useall'); // Standard fields at the start of the form. $mform->addElement('header', 'generalheader', get_string("general", 'form')); $mform->addElement('questioncategory', 'category', get_string('category', 'question'), array('contexts' => $usablecontexts, 'top' => true)); $mform->addElement('advcheckbox', 'includesubcategories', get_string('recurse', 'quiz'), null, null, array(0, 1)); $tops = question_get_top_categories_for_contexts(array_column($contexts->all(), 'id')); $mform->hideIf('includesubcategories', 'category', 'in', $tops); $tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $usablecontexts); $tagstrings = array(); foreach ($tags as $tag) { $tagstrings["{$tag->id},{$tag->name}"] = $tag->name; } $options = array( 'multiple' => true, 'noselectionstring' => get_string('anytags', 'quiz'), ); $mform->addElement('autocomplete', 'fromtags', get_string('randomquestiontags', 'mod_quiz'), $tagstrings, $options); $mform->addHelpButton('fromtags', 'randomquestiontags', 'mod_quiz'); $mform->addElement('hidden', 'slotid'); $mform->setType('slotid', PARAM_INT); $mform->addElement('hidden', 'returnurl'); $mform->setType('returnurl', PARAM_LOCALURL); $buttonarray = array(); $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] = $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
[ "public", "function", "definition", "(", ")", "{", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "contexts", "=", "$", "this", "->", "_customdata", "[", "'contexts'", "]", ";", "$", "usablecontexts", "=", "$", "contexts", "->", "having_cap", "(", "'moodle/question:useall'", ")", ";", "// Standard fields at the start of the form.", "$", "mform", "->", "addElement", "(", "'header'", ",", "'generalheader'", ",", "get_string", "(", "\"general\"", ",", "'form'", ")", ")", ";", "$", "mform", "->", "addElement", "(", "'questioncategory'", ",", "'category'", ",", "get_string", "(", "'category'", ",", "'question'", ")", ",", "array", "(", "'contexts'", "=>", "$", "usablecontexts", ",", "'top'", "=>", "true", ")", ")", ";", "$", "mform", "->", "addElement", "(", "'advcheckbox'", ",", "'includesubcategories'", ",", "get_string", "(", "'recurse'", ",", "'quiz'", ")", ",", "null", ",", "null", ",", "array", "(", "0", ",", "1", ")", ")", ";", "$", "tops", "=", "question_get_top_categories_for_contexts", "(", "array_column", "(", "$", "contexts", "->", "all", "(", ")", ",", "'id'", ")", ")", ";", "$", "mform", "->", "hideIf", "(", "'includesubcategories'", ",", "'category'", ",", "'in'", ",", "$", "tops", ")", ";", "$", "tags", "=", "\\", "core_tag_tag", "::", "get_tags_by_area_in_contexts", "(", "'core_question'", ",", "'question'", ",", "$", "usablecontexts", ")", ";", "$", "tagstrings", "=", "array", "(", ")", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "tagstrings", "[", "\"{$tag->id},{$tag->name}\"", "]", "=", "$", "tag", "->", "name", ";", "}", "$", "options", "=", "array", "(", "'multiple'", "=>", "true", ",", "'noselectionstring'", "=>", "get_string", "(", "'anytags'", ",", "'quiz'", ")", ",", ")", ";", "$", "mform", "->", "addElement", "(", "'autocomplete'", ",", "'fromtags'", ",", "get_string", "(", "'randomquestiontags'", ",", "'mod_quiz'", ")", ",", "$", "tagstrings", ",", "$", "options", ")", ";", "$", "mform", "->", "addHelpButton", "(", "'fromtags'", ",", "'randomquestiontags'", ",", "'mod_quiz'", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'slotid'", ")", ";", "$", "mform", "->", "setType", "(", "'slotid'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'returnurl'", ")", ";", "$", "mform", "->", "setType", "(", "'returnurl'", ",", "PARAM_LOCALURL", ")", ";", "$", "buttonarray", "=", "array", "(", ")", ";", "$", "buttonarray", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'submit'", ",", "'submitbutton'", ",", "get_string", "(", "'savechanges'", ")", ")", ";", "$", "buttonarray", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'cancel'", ")", ";", "$", "mform", "->", "addGroup", "(", "$", "buttonarray", ",", "'buttonar'", ",", "''", ",", "array", "(", "' '", ")", ",", "false", ")", ";", "$", "mform", "->", "closeHeaderBefore", "(", "'buttonar'", ")", ";", "}" ]
Form definiton.
[ "Form", "definiton", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/form/randomquestion_form.php#L43-L83
219,222
moodle/moodle
lib/classes/hub/registration.php
registration.get_registration
protected static function get_registration($confirmed = true) { global $DB; if (self::$registration === null) { self::$registration = $DB->get_record('registration_hubs', ['huburl' => HUB_MOODLEORGHUBURL]); } if (self::$registration && (bool)self::$registration->confirmed == (bool)$confirmed) { return self::$registration; } return null; }
php
protected static function get_registration($confirmed = true) { global $DB; if (self::$registration === null) { self::$registration = $DB->get_record('registration_hubs', ['huburl' => HUB_MOODLEORGHUBURL]); } if (self::$registration && (bool)self::$registration->confirmed == (bool)$confirmed) { return self::$registration; } return null; }
[ "protected", "static", "function", "get_registration", "(", "$", "confirmed", "=", "true", ")", "{", "global", "$", "DB", ";", "if", "(", "self", "::", "$", "registration", "===", "null", ")", "{", "self", "::", "$", "registration", "=", "$", "DB", "->", "get_record", "(", "'registration_hubs'", ",", "[", "'huburl'", "=>", "HUB_MOODLEORGHUBURL", "]", ")", ";", "}", "if", "(", "self", "::", "$", "registration", "&&", "(", "bool", ")", "self", "::", "$", "registration", "->", "confirmed", "==", "(", "bool", ")", "$", "confirmed", ")", "{", "return", "self", "::", "$", "registration", ";", "}", "return", "null", ";", "}" ]
Get site registration @param bool $confirmed @return stdClass|null
[ "Get", "site", "registration" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L81-L93
219,223
moodle/moodle
lib/classes/hub/registration.php
registration.require_registration
public static function require_registration() { if ($registration = self::get_registration()) { return $registration; } if (has_capability('moodle/site:config', context_system::instance())) { throw new moodle_exception('registrationwarning', 'admin', new moodle_url('/admin/registration/index.php')); } else { throw new moodle_exception('registrationwarningcontactadmin', 'admin'); } }
php
public static function require_registration() { if ($registration = self::get_registration()) { return $registration; } if (has_capability('moodle/site:config', context_system::instance())) { throw new moodle_exception('registrationwarning', 'admin', new moodle_url('/admin/registration/index.php')); } else { throw new moodle_exception('registrationwarningcontactadmin', 'admin'); } }
[ "public", "static", "function", "require_registration", "(", ")", "{", "if", "(", "$", "registration", "=", "self", "::", "get_registration", "(", ")", ")", "{", "return", "$", "registration", ";", "}", "if", "(", "has_capability", "(", "'moodle/site:config'", ",", "context_system", "::", "instance", "(", ")", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'registrationwarning'", ",", "'admin'", ",", "new", "moodle_url", "(", "'/admin/registration/index.php'", ")", ")", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'registrationwarningcontactadmin'", ",", "'admin'", ")", ";", "}", "}" ]
Same as get_registration except it throws exception if site not registered @return stdClass @throws \moodle_exception
[ "Same", "as", "get_registration", "except", "it", "throws", "exception", "if", "site", "not", "registered" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L101-L110
219,224
moodle/moodle
lib/classes/hub/registration.php
registration.get_token
public static function get_token($strictness = IGNORE_MISSING) { if ($strictness == MUST_EXIST) { $registration = self::require_registration(); } else if (!$registration = self::get_registration()) { return null; } return $registration->token; }
php
public static function get_token($strictness = IGNORE_MISSING) { if ($strictness == MUST_EXIST) { $registration = self::require_registration(); } else if (!$registration = self::get_registration()) { return null; } return $registration->token; }
[ "public", "static", "function", "get_token", "(", "$", "strictness", "=", "IGNORE_MISSING", ")", "{", "if", "(", "$", "strictness", "==", "MUST_EXIST", ")", "{", "$", "registration", "=", "self", "::", "require_registration", "(", ")", ";", "}", "else", "if", "(", "!", "$", "registration", "=", "self", "::", "get_registration", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "registration", "->", "token", ";", "}" ]
Returns registration token @param int $strictness if set to MUST_EXIST and site is not registered will throw an exception @return null @throws moodle_exception
[ "Returns", "registration", "token" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L128-L135
219,225
moodle/moodle
lib/classes/hub/registration.php
registration.get_site_info
public static function get_site_info($defaults = []) { global $CFG, $DB; require_once($CFG->libdir . '/badgeslib.php'); require_once($CFG->dirroot . "/course/lib.php"); $siteinfo = array(); $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); foreach (self::FORM_FIELDS as $field) { $siteinfo[$field] = get_config('hub', 'site_'.$field.'_' . $cleanhuburl); if ($siteinfo[$field] === false) { $siteinfo[$field] = array_key_exists($field, $defaults) ? $defaults[$field] : null; } } // Statistical data. $siteinfo['courses'] = $DB->count_records('course') - 1; $siteinfo['users'] = $DB->count_records('user', array('deleted' => 0)); $siteinfo['enrolments'] = $DB->count_records('role_assignments'); $siteinfo['posts'] = $DB->count_records('forum_posts'); $siteinfo['questions'] = $DB->count_records('question'); $siteinfo['resources'] = $DB->count_records('resource'); $siteinfo['badges'] = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED); $siteinfo['issuedbadges'] = $DB->count_records('badge_issued'); $siteinfo['participantnumberaverage'] = average_number_of_participants(); $siteinfo['modulenumberaverage'] = average_number_of_courses_modules(); // Version and url. $siteinfo['moodlerelease'] = $CFG->release; $siteinfo['url'] = $CFG->wwwroot; // Mobile related information. $siteinfo['mobileservicesenabled'] = 0; $siteinfo['mobilenotificationsenabled'] = 0; $siteinfo['registereduserdevices'] = 0; $siteinfo['registeredactiveuserdevices'] = 0; if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) { $siteinfo['mobileservicesenabled'] = 1; $siteinfo['registereduserdevices'] = $DB->count_records('user_devices'); $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php'; if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin. require_once($airnotifierextpath); $siteinfo['mobilenotificationsenabled'] = \message_airnotifier_external::is_system_configured(); $siteinfo['registeredactiveuserdevices'] = $DB->count_records('message_airnotifier_devices', array('enable' => 1)); } } // Analytics related data follow. $siteinfo['analyticsenabledmodels'] = \core_analytics\stats::enabled_models(); $siteinfo['analyticspredictions'] = \core_analytics\stats::predictions(); $siteinfo['analyticsactions'] = \core_analytics\stats::actions(); $siteinfo['analyticsactionsnotuseful'] = \core_analytics\stats::actions_not_useful(); // IMPORTANT: any new fields in siteinfo have to be added to the constant CONFIRM_NEW_FIELDS. return $siteinfo; }
php
public static function get_site_info($defaults = []) { global $CFG, $DB; require_once($CFG->libdir . '/badgeslib.php'); require_once($CFG->dirroot . "/course/lib.php"); $siteinfo = array(); $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); foreach (self::FORM_FIELDS as $field) { $siteinfo[$field] = get_config('hub', 'site_'.$field.'_' . $cleanhuburl); if ($siteinfo[$field] === false) { $siteinfo[$field] = array_key_exists($field, $defaults) ? $defaults[$field] : null; } } // Statistical data. $siteinfo['courses'] = $DB->count_records('course') - 1; $siteinfo['users'] = $DB->count_records('user', array('deleted' => 0)); $siteinfo['enrolments'] = $DB->count_records('role_assignments'); $siteinfo['posts'] = $DB->count_records('forum_posts'); $siteinfo['questions'] = $DB->count_records('question'); $siteinfo['resources'] = $DB->count_records('resource'); $siteinfo['badges'] = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED); $siteinfo['issuedbadges'] = $DB->count_records('badge_issued'); $siteinfo['participantnumberaverage'] = average_number_of_participants(); $siteinfo['modulenumberaverage'] = average_number_of_courses_modules(); // Version and url. $siteinfo['moodlerelease'] = $CFG->release; $siteinfo['url'] = $CFG->wwwroot; // Mobile related information. $siteinfo['mobileservicesenabled'] = 0; $siteinfo['mobilenotificationsenabled'] = 0; $siteinfo['registereduserdevices'] = 0; $siteinfo['registeredactiveuserdevices'] = 0; if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) { $siteinfo['mobileservicesenabled'] = 1; $siteinfo['registereduserdevices'] = $DB->count_records('user_devices'); $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php'; if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin. require_once($airnotifierextpath); $siteinfo['mobilenotificationsenabled'] = \message_airnotifier_external::is_system_configured(); $siteinfo['registeredactiveuserdevices'] = $DB->count_records('message_airnotifier_devices', array('enable' => 1)); } } // Analytics related data follow. $siteinfo['analyticsenabledmodels'] = \core_analytics\stats::enabled_models(); $siteinfo['analyticspredictions'] = \core_analytics\stats::predictions(); $siteinfo['analyticsactions'] = \core_analytics\stats::actions(); $siteinfo['analyticsactionsnotuseful'] = \core_analytics\stats::actions_not_useful(); // IMPORTANT: any new fields in siteinfo have to be added to the constant CONFIRM_NEW_FIELDS. return $siteinfo; }
[ "public", "static", "function", "get_site_info", "(", "$", "defaults", "=", "[", "]", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/badgeslib.php'", ")", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "\"/course/lib.php\"", ")", ";", "$", "siteinfo", "=", "array", "(", ")", ";", "$", "cleanhuburl", "=", "clean_param", "(", "HUB_MOODLEORGHUBURL", ",", "PARAM_ALPHANUMEXT", ")", ";", "foreach", "(", "self", "::", "FORM_FIELDS", "as", "$", "field", ")", "{", "$", "siteinfo", "[", "$", "field", "]", "=", "get_config", "(", "'hub'", ",", "'site_'", ".", "$", "field", ".", "'_'", ".", "$", "cleanhuburl", ")", ";", "if", "(", "$", "siteinfo", "[", "$", "field", "]", "===", "false", ")", "{", "$", "siteinfo", "[", "$", "field", "]", "=", "array_key_exists", "(", "$", "field", ",", "$", "defaults", ")", "?", "$", "defaults", "[", "$", "field", "]", ":", "null", ";", "}", "}", "// Statistical data.", "$", "siteinfo", "[", "'courses'", "]", "=", "$", "DB", "->", "count_records", "(", "'course'", ")", "-", "1", ";", "$", "siteinfo", "[", "'users'", "]", "=", "$", "DB", "->", "count_records", "(", "'user'", ",", "array", "(", "'deleted'", "=>", "0", ")", ")", ";", "$", "siteinfo", "[", "'enrolments'", "]", "=", "$", "DB", "->", "count_records", "(", "'role_assignments'", ")", ";", "$", "siteinfo", "[", "'posts'", "]", "=", "$", "DB", "->", "count_records", "(", "'forum_posts'", ")", ";", "$", "siteinfo", "[", "'questions'", "]", "=", "$", "DB", "->", "count_records", "(", "'question'", ")", ";", "$", "siteinfo", "[", "'resources'", "]", "=", "$", "DB", "->", "count_records", "(", "'resource'", ")", ";", "$", "siteinfo", "[", "'badges'", "]", "=", "$", "DB", "->", "count_records_select", "(", "'badge'", ",", "'status <> '", ".", "BADGE_STATUS_ARCHIVED", ")", ";", "$", "siteinfo", "[", "'issuedbadges'", "]", "=", "$", "DB", "->", "count_records", "(", "'badge_issued'", ")", ";", "$", "siteinfo", "[", "'participantnumberaverage'", "]", "=", "average_number_of_participants", "(", ")", ";", "$", "siteinfo", "[", "'modulenumberaverage'", "]", "=", "average_number_of_courses_modules", "(", ")", ";", "// Version and url.", "$", "siteinfo", "[", "'moodlerelease'", "]", "=", "$", "CFG", "->", "release", ";", "$", "siteinfo", "[", "'url'", "]", "=", "$", "CFG", "->", "wwwroot", ";", "// Mobile related information.", "$", "siteinfo", "[", "'mobileservicesenabled'", "]", "=", "0", ";", "$", "siteinfo", "[", "'mobilenotificationsenabled'", "]", "=", "0", ";", "$", "siteinfo", "[", "'registereduserdevices'", "]", "=", "0", ";", "$", "siteinfo", "[", "'registeredactiveuserdevices'", "]", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "enablewebservices", ")", "&&", "!", "empty", "(", "$", "CFG", "->", "enablemobilewebservice", ")", ")", "{", "$", "siteinfo", "[", "'mobileservicesenabled'", "]", "=", "1", ";", "$", "siteinfo", "[", "'registereduserdevices'", "]", "=", "$", "DB", "->", "count_records", "(", "'user_devices'", ")", ";", "$", "airnotifierextpath", "=", "$", "CFG", "->", "dirroot", ".", "'/message/output/airnotifier/externallib.php'", ";", "if", "(", "file_exists", "(", "$", "airnotifierextpath", ")", ")", "{", "// Maybe some one uninstalled the plugin.", "require_once", "(", "$", "airnotifierextpath", ")", ";", "$", "siteinfo", "[", "'mobilenotificationsenabled'", "]", "=", "\\", "message_airnotifier_external", "::", "is_system_configured", "(", ")", ";", "$", "siteinfo", "[", "'registeredactiveuserdevices'", "]", "=", "$", "DB", "->", "count_records", "(", "'message_airnotifier_devices'", ",", "array", "(", "'enable'", "=>", "1", ")", ")", ";", "}", "}", "// Analytics related data follow.", "$", "siteinfo", "[", "'analyticsenabledmodels'", "]", "=", "\\", "core_analytics", "\\", "stats", "::", "enabled_models", "(", ")", ";", "$", "siteinfo", "[", "'analyticspredictions'", "]", "=", "\\", "core_analytics", "\\", "stats", "::", "predictions", "(", ")", ";", "$", "siteinfo", "[", "'analyticsactions'", "]", "=", "\\", "core_analytics", "\\", "stats", "::", "actions", "(", ")", ";", "$", "siteinfo", "[", "'analyticsactionsnotuseful'", "]", "=", "\\", "core_analytics", "\\", "stats", "::", "actions_not_useful", "(", ")", ";", "// IMPORTANT: any new fields in siteinfo have to be added to the constant CONFIRM_NEW_FIELDS.", "return", "$", "siteinfo", ";", "}" ]
Calculates and prepares site information to send to moodle.net as part of registration or update @param array $defaults default values for inputs in the registration form (if site was never registered before) @return array site info
[ "Calculates", "and", "prepares", "site", "information", "to", "send", "to", "moodle", ".", "net", "as", "part", "of", "registration", "or", "update" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L155-L210
219,226
moodle/moodle
lib/classes/hub/registration.php
registration.get_stats_summary
public static function get_stats_summary($siteinfo) { $fieldsneedconfirm = self::get_new_registration_fields(); $summary = html_writer::tag('p', get_string('sendfollowinginfo_help', 'hub')) . html_writer::start_tag('ul'); $mobileservicesenabled = $siteinfo['mobileservicesenabled'] ? get_string('yes') : get_string('no'); $mobilenotificationsenabled = $siteinfo['mobilenotificationsenabled'] ? get_string('yes') : get_string('no'); $moodlerelease = $siteinfo['moodlerelease']; if (preg_match('/^(\d+\.\d.*?)[\. ]/', $moodlerelease, $matches)) { $moodlerelease = $matches[1]; } $senddata = [ 'moodlerelease' => get_string('sitereleasenum', 'hub', $moodlerelease), 'courses' => get_string('coursesnumber', 'hub', $siteinfo['courses']), 'users' => get_string('usersnumber', 'hub', $siteinfo['users']), 'enrolments' => get_string('roleassignmentsnumber', 'hub', $siteinfo['enrolments']), 'posts' => get_string('postsnumber', 'hub', $siteinfo['posts']), 'questions' => get_string('questionsnumber', 'hub', $siteinfo['questions']), 'resources' => get_string('resourcesnumber', 'hub', $siteinfo['resources']), 'badges' => get_string('badgesnumber', 'hub', $siteinfo['badges']), 'issuedbadges' => get_string('issuedbadgesnumber', 'hub', $siteinfo['issuedbadges']), 'participantnumberaverage' => get_string('participantnumberaverage', 'hub', format_float($siteinfo['participantnumberaverage'], 2)), 'modulenumberaverage' => get_string('modulenumberaverage', 'hub', format_float($siteinfo['modulenumberaverage'], 2)), 'mobileservicesenabled' => get_string('mobileservicesenabled', 'hub', $mobileservicesenabled), 'mobilenotificationsenabled' => get_string('mobilenotificationsenabled', 'hub', $mobilenotificationsenabled), 'registereduserdevices' => get_string('registereduserdevices', 'hub', $siteinfo['registereduserdevices']), 'registeredactiveuserdevices' => get_string('registeredactiveuserdevices', 'hub', $siteinfo['registeredactiveuserdevices']), 'analyticsenabledmodels' => get_string('analyticsenabledmodels', 'hub', $siteinfo['analyticsenabledmodels']), 'analyticspredictions' => get_string('analyticspredictions', 'hub', $siteinfo['analyticspredictions']), 'analyticsactions' => get_string('analyticsactions', 'hub', $siteinfo['analyticsactions']), 'analyticsactionsnotuseful' => get_string('analyticsactionsnotuseful', 'hub', $siteinfo['analyticsactionsnotuseful']), ]; foreach ($senddata as $key => $str) { $class = in_array($key, $fieldsneedconfirm) ? ' needsconfirmation mark' : ''; $summary .= html_writer::tag('li', $str, ['class' => 'site' . $key . $class]); } $summary .= html_writer::end_tag('ul'); return $summary; }
php
public static function get_stats_summary($siteinfo) { $fieldsneedconfirm = self::get_new_registration_fields(); $summary = html_writer::tag('p', get_string('sendfollowinginfo_help', 'hub')) . html_writer::start_tag('ul'); $mobileservicesenabled = $siteinfo['mobileservicesenabled'] ? get_string('yes') : get_string('no'); $mobilenotificationsenabled = $siteinfo['mobilenotificationsenabled'] ? get_string('yes') : get_string('no'); $moodlerelease = $siteinfo['moodlerelease']; if (preg_match('/^(\d+\.\d.*?)[\. ]/', $moodlerelease, $matches)) { $moodlerelease = $matches[1]; } $senddata = [ 'moodlerelease' => get_string('sitereleasenum', 'hub', $moodlerelease), 'courses' => get_string('coursesnumber', 'hub', $siteinfo['courses']), 'users' => get_string('usersnumber', 'hub', $siteinfo['users']), 'enrolments' => get_string('roleassignmentsnumber', 'hub', $siteinfo['enrolments']), 'posts' => get_string('postsnumber', 'hub', $siteinfo['posts']), 'questions' => get_string('questionsnumber', 'hub', $siteinfo['questions']), 'resources' => get_string('resourcesnumber', 'hub', $siteinfo['resources']), 'badges' => get_string('badgesnumber', 'hub', $siteinfo['badges']), 'issuedbadges' => get_string('issuedbadgesnumber', 'hub', $siteinfo['issuedbadges']), 'participantnumberaverage' => get_string('participantnumberaverage', 'hub', format_float($siteinfo['participantnumberaverage'], 2)), 'modulenumberaverage' => get_string('modulenumberaverage', 'hub', format_float($siteinfo['modulenumberaverage'], 2)), 'mobileservicesenabled' => get_string('mobileservicesenabled', 'hub', $mobileservicesenabled), 'mobilenotificationsenabled' => get_string('mobilenotificationsenabled', 'hub', $mobilenotificationsenabled), 'registereduserdevices' => get_string('registereduserdevices', 'hub', $siteinfo['registereduserdevices']), 'registeredactiveuserdevices' => get_string('registeredactiveuserdevices', 'hub', $siteinfo['registeredactiveuserdevices']), 'analyticsenabledmodels' => get_string('analyticsenabledmodels', 'hub', $siteinfo['analyticsenabledmodels']), 'analyticspredictions' => get_string('analyticspredictions', 'hub', $siteinfo['analyticspredictions']), 'analyticsactions' => get_string('analyticsactions', 'hub', $siteinfo['analyticsactions']), 'analyticsactionsnotuseful' => get_string('analyticsactionsnotuseful', 'hub', $siteinfo['analyticsactionsnotuseful']), ]; foreach ($senddata as $key => $str) { $class = in_array($key, $fieldsneedconfirm) ? ' needsconfirmation mark' : ''; $summary .= html_writer::tag('li', $str, ['class' => 'site' . $key . $class]); } $summary .= html_writer::end_tag('ul'); return $summary; }
[ "public", "static", "function", "get_stats_summary", "(", "$", "siteinfo", ")", "{", "$", "fieldsneedconfirm", "=", "self", "::", "get_new_registration_fields", "(", ")", ";", "$", "summary", "=", "html_writer", "::", "tag", "(", "'p'", ",", "get_string", "(", "'sendfollowinginfo_help'", ",", "'hub'", ")", ")", ".", "html_writer", "::", "start_tag", "(", "'ul'", ")", ";", "$", "mobileservicesenabled", "=", "$", "siteinfo", "[", "'mobileservicesenabled'", "]", "?", "get_string", "(", "'yes'", ")", ":", "get_string", "(", "'no'", ")", ";", "$", "mobilenotificationsenabled", "=", "$", "siteinfo", "[", "'mobilenotificationsenabled'", "]", "?", "get_string", "(", "'yes'", ")", ":", "get_string", "(", "'no'", ")", ";", "$", "moodlerelease", "=", "$", "siteinfo", "[", "'moodlerelease'", "]", ";", "if", "(", "preg_match", "(", "'/^(\\d+\\.\\d.*?)[\\. ]/'", ",", "$", "moodlerelease", ",", "$", "matches", ")", ")", "{", "$", "moodlerelease", "=", "$", "matches", "[", "1", "]", ";", "}", "$", "senddata", "=", "[", "'moodlerelease'", "=>", "get_string", "(", "'sitereleasenum'", ",", "'hub'", ",", "$", "moodlerelease", ")", ",", "'courses'", "=>", "get_string", "(", "'coursesnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'courses'", "]", ")", ",", "'users'", "=>", "get_string", "(", "'usersnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'users'", "]", ")", ",", "'enrolments'", "=>", "get_string", "(", "'roleassignmentsnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'enrolments'", "]", ")", ",", "'posts'", "=>", "get_string", "(", "'postsnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'posts'", "]", ")", ",", "'questions'", "=>", "get_string", "(", "'questionsnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'questions'", "]", ")", ",", "'resources'", "=>", "get_string", "(", "'resourcesnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'resources'", "]", ")", ",", "'badges'", "=>", "get_string", "(", "'badgesnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'badges'", "]", ")", ",", "'issuedbadges'", "=>", "get_string", "(", "'issuedbadgesnumber'", ",", "'hub'", ",", "$", "siteinfo", "[", "'issuedbadges'", "]", ")", ",", "'participantnumberaverage'", "=>", "get_string", "(", "'participantnumberaverage'", ",", "'hub'", ",", "format_float", "(", "$", "siteinfo", "[", "'participantnumberaverage'", "]", ",", "2", ")", ")", ",", "'modulenumberaverage'", "=>", "get_string", "(", "'modulenumberaverage'", ",", "'hub'", ",", "format_float", "(", "$", "siteinfo", "[", "'modulenumberaverage'", "]", ",", "2", ")", ")", ",", "'mobileservicesenabled'", "=>", "get_string", "(", "'mobileservicesenabled'", ",", "'hub'", ",", "$", "mobileservicesenabled", ")", ",", "'mobilenotificationsenabled'", "=>", "get_string", "(", "'mobilenotificationsenabled'", ",", "'hub'", ",", "$", "mobilenotificationsenabled", ")", ",", "'registereduserdevices'", "=>", "get_string", "(", "'registereduserdevices'", ",", "'hub'", ",", "$", "siteinfo", "[", "'registereduserdevices'", "]", ")", ",", "'registeredactiveuserdevices'", "=>", "get_string", "(", "'registeredactiveuserdevices'", ",", "'hub'", ",", "$", "siteinfo", "[", "'registeredactiveuserdevices'", "]", ")", ",", "'analyticsenabledmodels'", "=>", "get_string", "(", "'analyticsenabledmodels'", ",", "'hub'", ",", "$", "siteinfo", "[", "'analyticsenabledmodels'", "]", ")", ",", "'analyticspredictions'", "=>", "get_string", "(", "'analyticspredictions'", ",", "'hub'", ",", "$", "siteinfo", "[", "'analyticspredictions'", "]", ")", ",", "'analyticsactions'", "=>", "get_string", "(", "'analyticsactions'", ",", "'hub'", ",", "$", "siteinfo", "[", "'analyticsactions'", "]", ")", ",", "'analyticsactionsnotuseful'", "=>", "get_string", "(", "'analyticsactionsnotuseful'", ",", "'hub'", ",", "$", "siteinfo", "[", "'analyticsactionsnotuseful'", "]", ")", ",", "]", ";", "foreach", "(", "$", "senddata", "as", "$", "key", "=>", "$", "str", ")", "{", "$", "class", "=", "in_array", "(", "$", "key", ",", "$", "fieldsneedconfirm", ")", "?", "' needsconfirmation mark'", ":", "''", ";", "$", "summary", ".=", "html_writer", "::", "tag", "(", "'li'", ",", "$", "str", ",", "[", "'class'", "=>", "'site'", ".", "$", "key", ".", "$", "class", "]", ")", ";", "}", "$", "summary", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "return", "$", "summary", ";", "}" ]
Human-readable summary of data that will be sent to moodle.net @param array $siteinfo result of get_site_info() @return string
[ "Human", "-", "readable", "summary", "of", "data", "that", "will", "be", "sent", "to", "moodle", ".", "net" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L218-L259
219,227
moodle/moodle
lib/classes/hub/registration.php
registration.save_site_info
public static function save_site_info($formdata) { $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); foreach (self::FORM_FIELDS as $field) { set_config('site_' . $field . '_' . $cleanhuburl, $formdata->$field, 'hub'); } // Even if the the connection with moodle.net fails, admin has manually submitted the form which means they don't need // to be redirected to the site registration page any more. set_config('site_regupdateversion_' . $cleanhuburl, max(array_keys(self::CONFIRM_NEW_FIELDS)), 'hub'); }
php
public static function save_site_info($formdata) { $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); foreach (self::FORM_FIELDS as $field) { set_config('site_' . $field . '_' . $cleanhuburl, $formdata->$field, 'hub'); } // Even if the the connection with moodle.net fails, admin has manually submitted the form which means they don't need // to be redirected to the site registration page any more. set_config('site_regupdateversion_' . $cleanhuburl, max(array_keys(self::CONFIRM_NEW_FIELDS)), 'hub'); }
[ "public", "static", "function", "save_site_info", "(", "$", "formdata", ")", "{", "$", "cleanhuburl", "=", "clean_param", "(", "HUB_MOODLEORGHUBURL", ",", "PARAM_ALPHANUMEXT", ")", ";", "foreach", "(", "self", "::", "FORM_FIELDS", "as", "$", "field", ")", "{", "set_config", "(", "'site_'", ".", "$", "field", ".", "'_'", ".", "$", "cleanhuburl", ",", "$", "formdata", "->", "$", "field", ",", "'hub'", ")", ";", "}", "// Even if the the connection with moodle.net fails, admin has manually submitted the form which means they don't need", "// to be redirected to the site registration page any more.", "set_config", "(", "'site_regupdateversion_'", ".", "$", "cleanhuburl", ",", "max", "(", "array_keys", "(", "self", "::", "CONFIRM_NEW_FIELDS", ")", ")", ",", "'hub'", ")", ";", "}" ]
Save registration info locally so it can be retrieved when registration needs to be updated @param stdClass $formdata data from {@link site_registration_form}
[ "Save", "registration", "info", "locally", "so", "it", "can", "be", "retrieved", "when", "registration", "needs", "to", "be", "updated" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L266-L274
219,228
moodle/moodle
lib/classes/hub/registration.php
registration.update_manual
public static function update_manual() { global $DB; if (!$registration = self::get_registration()) { return false; } $siteinfo = self::get_site_info(); try { api::update_registration($siteinfo); } catch (moodle_exception $e) { if (!self::is_registered()) { // Token was rejected during registration update and site and locally stored token was reset, // proceed to site registration. This method will redirect away. self::register(''); } \core\notification::add(get_string('errorregistrationupdate', 'hub', $e->getMessage()), \core\output\notification::NOTIFY_ERROR); return false; } $DB->update_record('registration_hubs', ['id' => $registration->id, 'timemodified' => time()]); \core\notification::add(get_string('siteregistrationupdated', 'hub'), \core\output\notification::NOTIFY_SUCCESS); self::$registration = null; return true; }
php
public static function update_manual() { global $DB; if (!$registration = self::get_registration()) { return false; } $siteinfo = self::get_site_info(); try { api::update_registration($siteinfo); } catch (moodle_exception $e) { if (!self::is_registered()) { // Token was rejected during registration update and site and locally stored token was reset, // proceed to site registration. This method will redirect away. self::register(''); } \core\notification::add(get_string('errorregistrationupdate', 'hub', $e->getMessage()), \core\output\notification::NOTIFY_ERROR); return false; } $DB->update_record('registration_hubs', ['id' => $registration->id, 'timemodified' => time()]); \core\notification::add(get_string('siteregistrationupdated', 'hub'), \core\output\notification::NOTIFY_SUCCESS); self::$registration = null; return true; }
[ "public", "static", "function", "update_manual", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "registration", "=", "self", "::", "get_registration", "(", ")", ")", "{", "return", "false", ";", "}", "$", "siteinfo", "=", "self", "::", "get_site_info", "(", ")", ";", "try", "{", "api", "::", "update_registration", "(", "$", "siteinfo", ")", ";", "}", "catch", "(", "moodle_exception", "$", "e", ")", "{", "if", "(", "!", "self", "::", "is_registered", "(", ")", ")", "{", "// Token was rejected during registration update and site and locally stored token was reset,", "// proceed to site registration. This method will redirect away.", "self", "::", "register", "(", "''", ")", ";", "}", "\\", "core", "\\", "notification", "::", "add", "(", "get_string", "(", "'errorregistrationupdate'", ",", "'hub'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_ERROR", ")", ";", "return", "false", ";", "}", "$", "DB", "->", "update_record", "(", "'registration_hubs'", ",", "[", "'id'", "=>", "$", "registration", "->", "id", ",", "'timemodified'", "=>", "time", "(", ")", "]", ")", ";", "\\", "core", "\\", "notification", "::", "add", "(", "get_string", "(", "'siteregistrationupdated'", ",", "'hub'", ")", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_SUCCESS", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "return", "true", ";", "}" ]
Updates site registration when "Update reigstration" button is clicked by admin
[ "Updates", "site", "registration", "when", "Update", "reigstration", "button", "is", "clicked", "by", "admin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L279-L304
219,229
moodle/moodle
lib/classes/hub/registration.php
registration.update_cron
public static function update_cron() { global $DB; if (!$registration = self::get_registration()) { mtrace(get_string('registrationwarning', 'admin')); return; } if (self::get_new_registration_fields()) { mtrace(get_string('pleaserefreshregistrationnewdata', 'admin')); return; } $siteinfo = self::get_site_info(); api::update_registration($siteinfo); $DB->update_record('registration_hubs', ['id' => $registration->id, 'timemodified' => time()]); mtrace(get_string('siteregistrationupdated', 'hub')); self::$registration = null; }
php
public static function update_cron() { global $DB; if (!$registration = self::get_registration()) { mtrace(get_string('registrationwarning', 'admin')); return; } if (self::get_new_registration_fields()) { mtrace(get_string('pleaserefreshregistrationnewdata', 'admin')); return; } $siteinfo = self::get_site_info(); api::update_registration($siteinfo); $DB->update_record('registration_hubs', ['id' => $registration->id, 'timemodified' => time()]); mtrace(get_string('siteregistrationupdated', 'hub')); self::$registration = null; }
[ "public", "static", "function", "update_cron", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "registration", "=", "self", "::", "get_registration", "(", ")", ")", "{", "mtrace", "(", "get_string", "(", "'registrationwarning'", ",", "'admin'", ")", ")", ";", "return", ";", "}", "if", "(", "self", "::", "get_new_registration_fields", "(", ")", ")", "{", "mtrace", "(", "get_string", "(", "'pleaserefreshregistrationnewdata'", ",", "'admin'", ")", ")", ";", "return", ";", "}", "$", "siteinfo", "=", "self", "::", "get_site_info", "(", ")", ";", "api", "::", "update_registration", "(", "$", "siteinfo", ")", ";", "$", "DB", "->", "update_record", "(", "'registration_hubs'", ",", "[", "'id'", "=>", "$", "registration", "->", "id", ",", "'timemodified'", "=>", "time", "(", ")", "]", ")", ";", "mtrace", "(", "get_string", "(", "'siteregistrationupdated'", ",", "'hub'", ")", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "}" ]
Updates site registration via cron @throws moodle_exception
[ "Updates", "site", "registration", "via", "cron" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L311-L329
219,230
moodle/moodle
lib/classes/hub/registration.php
registration.confirm_registration
public static function confirm_registration($token, $newtoken, $hubname) { global $DB; $registration = self::get_registration(false); if (!$registration || $registration->token !== $token) { throw new moodle_exception('wrongtoken', 'hub', new moodle_url('/admin/registration/index.php')); } $record = ['id' => $registration->id]; $record['token'] = $newtoken; $record['confirmed'] = 1; $record['hubname'] = $hubname; $record['timemodified'] = time(); $DB->update_record('registration_hubs', $record); self::$registration = null; }
php
public static function confirm_registration($token, $newtoken, $hubname) { global $DB; $registration = self::get_registration(false); if (!$registration || $registration->token !== $token) { throw new moodle_exception('wrongtoken', 'hub', new moodle_url('/admin/registration/index.php')); } $record = ['id' => $registration->id]; $record['token'] = $newtoken; $record['confirmed'] = 1; $record['hubname'] = $hubname; $record['timemodified'] = time(); $DB->update_record('registration_hubs', $record); self::$registration = null; }
[ "public", "static", "function", "confirm_registration", "(", "$", "token", ",", "$", "newtoken", ",", "$", "hubname", ")", "{", "global", "$", "DB", ";", "$", "registration", "=", "self", "::", "get_registration", "(", "false", ")", ";", "if", "(", "!", "$", "registration", "||", "$", "registration", "->", "token", "!==", "$", "token", ")", "{", "throw", "new", "moodle_exception", "(", "'wrongtoken'", ",", "'hub'", ",", "new", "moodle_url", "(", "'/admin/registration/index.php'", ")", ")", ";", "}", "$", "record", "=", "[", "'id'", "=>", "$", "registration", "->", "id", "]", ";", "$", "record", "[", "'token'", "]", "=", "$", "newtoken", ";", "$", "record", "[", "'confirmed'", "]", "=", "1", ";", "$", "record", "[", "'hubname'", "]", "=", "$", "hubname", ";", "$", "record", "[", "'timemodified'", "]", "=", "time", "(", ")", ";", "$", "DB", "->", "update_record", "(", "'registration_hubs'", ",", "$", "record", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "}" ]
Confirms registration by moodle.net @param string $token @param string $newtoken @param string $hubname @throws moodle_exception
[ "Confirms", "registration", "by", "moodle", ".", "net" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L339-L353
219,231
moodle/moodle
lib/classes/hub/registration.php
registration.site_privacy_options
public static function site_privacy_options() { return [ self::HUB_SITENOTPUBLISHED => get_string('siteprivacynotpublished', 'hub'), self::HUB_SITENAMEPUBLISHED => get_string('siteprivacypublished', 'hub'), self::HUB_SITELINKPUBLISHED => get_string('siteprivacylinked', 'hub') ]; }
php
public static function site_privacy_options() { return [ self::HUB_SITENOTPUBLISHED => get_string('siteprivacynotpublished', 'hub'), self::HUB_SITENAMEPUBLISHED => get_string('siteprivacypublished', 'hub'), self::HUB_SITELINKPUBLISHED => get_string('siteprivacylinked', 'hub') ]; }
[ "public", "static", "function", "site_privacy_options", "(", ")", "{", "return", "[", "self", "::", "HUB_SITENOTPUBLISHED", "=>", "get_string", "(", "'siteprivacynotpublished'", ",", "'hub'", ")", ",", "self", "::", "HUB_SITENAMEPUBLISHED", "=>", "get_string", "(", "'siteprivacypublished'", ",", "'hub'", ")", ",", "self", "::", "HUB_SITELINKPUBLISHED", "=>", "get_string", "(", "'siteprivacylinked'", ",", "'hub'", ")", "]", ";", "}" ]
Retrieve the options for site privacy form element to use in registration form @return array
[ "Retrieve", "the", "options", "for", "site", "privacy", "form", "element", "to", "use", "in", "registration", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L359-L365
219,232
moodle/moodle
lib/classes/hub/registration.php
registration.register
public static function register($returnurl) { global $DB, $SESSION; if (self::is_registered()) { // Caller of this method must make sure that site is not registered. throw new \coding_exception('Site already registered'); } $hub = self::get_registration(false); if (empty($hub)) { // Create a new record in 'registration_hubs'. $hub = new stdClass(); $hub->token = get_site_identifier(); $hub->secret = $hub->token; $hub->huburl = HUB_MOODLEORGHUBURL; $hub->hubname = 'Moodle.net'; $hub->confirmed = 0; $hub->timemodified = time(); $hub->id = $DB->insert_record('registration_hubs', $hub); self::$registration = null; } $params = self::get_site_info(); $params['token'] = $hub->token; $SESSION->registrationredirect = $returnurl; redirect(new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php', $params)); }
php
public static function register($returnurl) { global $DB, $SESSION; if (self::is_registered()) { // Caller of this method must make sure that site is not registered. throw new \coding_exception('Site already registered'); } $hub = self::get_registration(false); if (empty($hub)) { // Create a new record in 'registration_hubs'. $hub = new stdClass(); $hub->token = get_site_identifier(); $hub->secret = $hub->token; $hub->huburl = HUB_MOODLEORGHUBURL; $hub->hubname = 'Moodle.net'; $hub->confirmed = 0; $hub->timemodified = time(); $hub->id = $DB->insert_record('registration_hubs', $hub); self::$registration = null; } $params = self::get_site_info(); $params['token'] = $hub->token; $SESSION->registrationredirect = $returnurl; redirect(new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php', $params)); }
[ "public", "static", "function", "register", "(", "$", "returnurl", ")", "{", "global", "$", "DB", ",", "$", "SESSION", ";", "if", "(", "self", "::", "is_registered", "(", ")", ")", "{", "// Caller of this method must make sure that site is not registered.", "throw", "new", "\\", "coding_exception", "(", "'Site already registered'", ")", ";", "}", "$", "hub", "=", "self", "::", "get_registration", "(", "false", ")", ";", "if", "(", "empty", "(", "$", "hub", ")", ")", "{", "// Create a new record in 'registration_hubs'.", "$", "hub", "=", "new", "stdClass", "(", ")", ";", "$", "hub", "->", "token", "=", "get_site_identifier", "(", ")", ";", "$", "hub", "->", "secret", "=", "$", "hub", "->", "token", ";", "$", "hub", "->", "huburl", "=", "HUB_MOODLEORGHUBURL", ";", "$", "hub", "->", "hubname", "=", "'Moodle.net'", ";", "$", "hub", "->", "confirmed", "=", "0", ";", "$", "hub", "->", "timemodified", "=", "time", "(", ")", ";", "$", "hub", "->", "id", "=", "$", "DB", "->", "insert_record", "(", "'registration_hubs'", ",", "$", "hub", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "}", "$", "params", "=", "self", "::", "get_site_info", "(", ")", ";", "$", "params", "[", "'token'", "]", "=", "$", "hub", "->", "token", ";", "$", "SESSION", "->", "registrationredirect", "=", "$", "returnurl", ";", "redirect", "(", "new", "moodle_url", "(", "HUB_MOODLEORGHUBURL", ".", "'/local/hub/siteregistration.php'", ",", "$", "params", ")", ")", ";", "}" ]
Registers a site This method will make sure that unconfirmed registration record is created and then redirect to registration script on https://moodle.net Moodle.net will check that the site is accessible, register it and redirect back to /admin/registration/confirmregistration.php @param string $returnurl @throws \coding_exception
[ "Registers", "a", "site" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L378-L405
219,233
moodle/moodle
lib/classes/hub/registration.php
registration.reset_token
public static function reset_token() { global $DB; if (!$hub = self::get_registration()) { return true; } $DB->delete_records('registration_hubs', array('id' => $hub->id)); self::$registration = null; }
php
public static function reset_token() { global $DB; if (!$hub = self::get_registration()) { return true; } $DB->delete_records('registration_hubs', array('id' => $hub->id)); self::$registration = null; }
[ "public", "static", "function", "reset_token", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "hub", "=", "self", "::", "get_registration", "(", ")", ")", "{", "return", "true", ";", "}", "$", "DB", "->", "delete_records", "(", "'registration_hubs'", ",", "array", "(", "'id'", "=>", "$", "hub", "->", "id", ")", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "}" ]
Resets the registration token without changing site identifier so site can be re-registered @return bool
[ "Resets", "the", "registration", "token", "without", "changing", "site", "identifier", "so", "site", "can", "be", "re", "-", "registered" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L453-L460
219,234
moodle/moodle
lib/classes/hub/registration.php
registration.reset_site_identifier
public static function reset_site_identifier($token) { global $DB, $CFG; $registration = self::get_registration(false); if (!$registration || $registration->token != $token) { throw new moodle_exception('wrongtoken', 'hub', new moodle_url('/admin/registration/index.php')); } $DB->delete_records('registration_hubs', array('id' => $registration->id)); self::$registration = null; $CFG->siteidentifier = null; get_site_identifier(); }
php
public static function reset_site_identifier($token) { global $DB, $CFG; $registration = self::get_registration(false); if (!$registration || $registration->token != $token) { throw new moodle_exception('wrongtoken', 'hub', new moodle_url('/admin/registration/index.php')); } $DB->delete_records('registration_hubs', array('id' => $registration->id)); self::$registration = null; $CFG->siteidentifier = null; get_site_identifier(); }
[ "public", "static", "function", "reset_site_identifier", "(", "$", "token", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "$", "registration", "=", "self", "::", "get_registration", "(", "false", ")", ";", "if", "(", "!", "$", "registration", "||", "$", "registration", "->", "token", "!=", "$", "token", ")", "{", "throw", "new", "moodle_exception", "(", "'wrongtoken'", ",", "'hub'", ",", "new", "moodle_url", "(", "'/admin/registration/index.php'", ")", ")", ";", "}", "$", "DB", "->", "delete_records", "(", "'registration_hubs'", ",", "array", "(", "'id'", "=>", "$", "registration", "->", "id", ")", ")", ";", "self", "::", "$", "registration", "=", "null", ";", "$", "CFG", "->", "siteidentifier", "=", "null", ";", "get_site_identifier", "(", ")", ";", "}" ]
Generate a new token for the site that is not registered @param string $token @throws moodle_exception
[ "Generate", "a", "new", "token", "for", "the", "site", "that", "is", "not", "registered" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L468-L482
219,235
moodle/moodle
lib/classes/hub/registration.php
registration.show_after_install
public static function show_after_install($markasviewed = null) { global $CFG; if (self::is_registered()) { $showregistration = false; $markasviewed = true; } else { $showregistration = !empty($CFG->registrationpending); if ($showregistration && !site_is_public()) { // If it's not a public site, don't redirect to registration, it won't work anyway. $showregistration = false; $markasviewed = true; } } if ($markasviewed !== null) { set_config('registrationpending', !$markasviewed); } return $showregistration; }
php
public static function show_after_install($markasviewed = null) { global $CFG; if (self::is_registered()) { $showregistration = false; $markasviewed = true; } else { $showregistration = !empty($CFG->registrationpending); if ($showregistration && !site_is_public()) { // If it's not a public site, don't redirect to registration, it won't work anyway. $showregistration = false; $markasviewed = true; } } if ($markasviewed !== null) { set_config('registrationpending', !$markasviewed); } return $showregistration; }
[ "public", "static", "function", "show_after_install", "(", "$", "markasviewed", "=", "null", ")", "{", "global", "$", "CFG", ";", "if", "(", "self", "::", "is_registered", "(", ")", ")", "{", "$", "showregistration", "=", "false", ";", "$", "markasviewed", "=", "true", ";", "}", "else", "{", "$", "showregistration", "=", "!", "empty", "(", "$", "CFG", "->", "registrationpending", ")", ";", "if", "(", "$", "showregistration", "&&", "!", "site_is_public", "(", ")", ")", "{", "// If it's not a public site, don't redirect to registration, it won't work anyway.", "$", "showregistration", "=", "false", ";", "$", "markasviewed", "=", "true", ";", "}", "}", "if", "(", "$", "markasviewed", "!==", "null", ")", "{", "set_config", "(", "'registrationpending'", ",", "!", "$", "markasviewed", ")", ";", "}", "return", "$", "showregistration", ";", "}" ]
Does admin need to be redirected to the registration page after install? @param bool|null $markasviewed if set to true will mark the registration form as viewed and admin will not be redirected to the registration form again (regardless of whether the site was registered or not). @return bool
[ "Does", "admin", "need", "to", "be", "redirected", "to", "the", "registration", "page", "after", "install?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L520-L537
219,236
moodle/moodle
lib/classes/hub/registration.php
registration.get_new_registration_fields
public static function get_new_registration_fields() { $fieldsneedconfirm = []; if (!self::is_registered()) { // Nothing to update if site is not registered. return $fieldsneedconfirm; } $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); $lastupdated = (int)get_config('hub', 'site_regupdateversion_' . $cleanhuburl); foreach (self::CONFIRM_NEW_FIELDS as $version => $fields) { if ($version > $lastupdated) { $fieldsneedconfirm = array_merge($fieldsneedconfirm, $fields); } } return $fieldsneedconfirm; }
php
public static function get_new_registration_fields() { $fieldsneedconfirm = []; if (!self::is_registered()) { // Nothing to update if site is not registered. return $fieldsneedconfirm; } $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT); $lastupdated = (int)get_config('hub', 'site_regupdateversion_' . $cleanhuburl); foreach (self::CONFIRM_NEW_FIELDS as $version => $fields) { if ($version > $lastupdated) { $fieldsneedconfirm = array_merge($fieldsneedconfirm, $fields); } } return $fieldsneedconfirm; }
[ "public", "static", "function", "get_new_registration_fields", "(", ")", "{", "$", "fieldsneedconfirm", "=", "[", "]", ";", "if", "(", "!", "self", "::", "is_registered", "(", ")", ")", "{", "// Nothing to update if site is not registered.", "return", "$", "fieldsneedconfirm", ";", "}", "$", "cleanhuburl", "=", "clean_param", "(", "HUB_MOODLEORGHUBURL", ",", "PARAM_ALPHANUMEXT", ")", ";", "$", "lastupdated", "=", "(", "int", ")", "get_config", "(", "'hub'", ",", "'site_regupdateversion_'", ".", "$", "cleanhuburl", ")", ";", "foreach", "(", "self", "::", "CONFIRM_NEW_FIELDS", "as", "$", "version", "=>", "$", "fields", ")", "{", "if", "(", "$", "version", ">", "$", "lastupdated", ")", "{", "$", "fieldsneedconfirm", "=", "array_merge", "(", "$", "fieldsneedconfirm", ",", "$", "fields", ")", ";", "}", "}", "return", "$", "fieldsneedconfirm", ";", "}" ]
Returns the list of the fields in the registration form that were added since registration or last manual update If this list is not empty the scheduled task will be paused and admin will be reminded to update registration manually. @return array
[ "Returns", "the", "list", "of", "the", "fields", "in", "the", "registration", "form", "that", "were", "added", "since", "registration", "or", "last", "manual", "update" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L546-L561
219,237
moodle/moodle
lib/classes/hub/registration.php
registration.registration_reminder
public static function registration_reminder($url) { if (defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING) { // No redirection during behat runs. return; } if (!has_capability('moodle/site:config', context_system::instance())) { return; } if (self::show_after_install() || self::get_new_registration_fields()) { $returnurl = new moodle_url($url); redirect(new moodle_url('/admin/registration/index.php', ['returnurl' => $returnurl->out_as_local_url(false)])); } }
php
public static function registration_reminder($url) { if (defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING) { // No redirection during behat runs. return; } if (!has_capability('moodle/site:config', context_system::instance())) { return; } if (self::show_after_install() || self::get_new_registration_fields()) { $returnurl = new moodle_url($url); redirect(new moodle_url('/admin/registration/index.php', ['returnurl' => $returnurl->out_as_local_url(false)])); } }
[ "public", "static", "function", "registration_reminder", "(", "$", "url", ")", "{", "if", "(", "defined", "(", "'BEHAT_SITE_RUNNING'", ")", "&&", "BEHAT_SITE_RUNNING", ")", "{", "// No redirection during behat runs.", "return", ";", "}", "if", "(", "!", "has_capability", "(", "'moodle/site:config'", ",", "context_system", "::", "instance", "(", ")", ")", ")", "{", "return", ";", "}", "if", "(", "self", "::", "show_after_install", "(", ")", "||", "self", "::", "get_new_registration_fields", "(", ")", ")", "{", "$", "returnurl", "=", "new", "moodle_url", "(", "$", "url", ")", ";", "redirect", "(", "new", "moodle_url", "(", "'/admin/registration/index.php'", ",", "[", "'returnurl'", "=>", "$", "returnurl", "->", "out_as_local_url", "(", "false", ")", "]", ")", ")", ";", "}", "}" ]
Redirect to the site registration form if it's a new install or registration needs updating @param string|moodle_url $url
[ "Redirect", "to", "the", "site", "registration", "form", "if", "it", "s", "a", "new", "install", "or", "registration", "needs", "updating" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/hub/registration.php#L568-L580
219,238
moodle/moodle
lib/pear/HTML/QuickForm/radio.php
HTML_QuickForm_radio.exportValue
function exportValue(&$submitValues, $assoc = false) { $value = $this->_findValue($submitValues); if (null === $value) { $value = $this->getChecked()? $this->getValue(): null; } elseif ($value != $this->getValue()) { $value = null; } return $this->_prepareValue($value, $assoc); }
php
function exportValue(&$submitValues, $assoc = false) { $value = $this->_findValue($submitValues); if (null === $value) { $value = $this->getChecked()? $this->getValue(): null; } elseif ($value != $this->getValue()) { $value = null; } return $this->_prepareValue($value, $assoc); }
[ "function", "exportValue", "(", "&", "$", "submitValues", ",", "$", "assoc", "=", "false", ")", "{", "$", "value", "=", "$", "this", "->", "_findValue", "(", "$", "submitValues", ")", ";", "if", "(", "null", "===", "$", "value", ")", "{", "$", "value", "=", "$", "this", "->", "getChecked", "(", ")", "?", "$", "this", "->", "getValue", "(", ")", ":", "null", ";", "}", "elseif", "(", "$", "value", "!=", "$", "this", "->", "getValue", "(", ")", ")", "{", "$", "value", "=", "null", ";", "}", "return", "$", "this", "->", "_prepareValue", "(", "$", "value", ",", "$", "assoc", ")", ";", "}" ]
Returns the value attribute if the radio is checked, null if it is not
[ "Returns", "the", "value", "attribute", "if", "the", "radio", "is", "checked", "null", "if", "it", "is", "not" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/radio.php#L255-L264
219,239
moodle/moodle
mod/lti/edit_form.php
mod_lti_edit_types_form.get_data
public function get_data() { $data = parent::get_data(); if ($data && !empty($this->_customdata->istool)) { // Content item checkbox is disabled in tool settings, so this cannot be edited. Just unset it. unset($data->lti_contentitem); } return $data; }
php
public function get_data() { $data = parent::get_data(); if ($data && !empty($this->_customdata->istool)) { // Content item checkbox is disabled in tool settings, so this cannot be edited. Just unset it. unset($data->lti_contentitem); } return $data; }
[ "public", "function", "get_data", "(", ")", "{", "$", "data", "=", "parent", "::", "get_data", "(", ")", ";", "if", "(", "$", "data", "&&", "!", "empty", "(", "$", "this", "->", "_customdata", "->", "istool", ")", ")", "{", "// Content item checkbox is disabled in tool settings, so this cannot be edited. Just unset it.", "unset", "(", "$", "data", "->", "lti_contentitem", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retrieves the data of the submitted form. @return stdClass
[ "Retrieves", "the", "data", "of", "the", "submitted", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/edit_form.php#L277-L284
219,240
moodle/moodle
mod/lti/edit_form.php
mod_lti_edit_types_form.get_lti_advantage_services
public function get_lti_advantage_services(&$mform) { // For each service add the label and get the array of configuration. $services = lti_get_services(); $mform->addElement('header', 'services', get_string('services', 'lti')); foreach ($services as $service) { /** @var \mod_lti\local\ltiservice\service_base $service */ $service->get_configuration_options($mform); } }
php
public function get_lti_advantage_services(&$mform) { // For each service add the label and get the array of configuration. $services = lti_get_services(); $mform->addElement('header', 'services', get_string('services', 'lti')); foreach ($services as $service) { /** @var \mod_lti\local\ltiservice\service_base $service */ $service->get_configuration_options($mform); } }
[ "public", "function", "get_lti_advantage_services", "(", "&", "$", "mform", ")", "{", "// For each service add the label and get the array of configuration.", "$", "services", "=", "lti_get_services", "(", ")", ";", "$", "mform", "->", "addElement", "(", "'header'", ",", "'services'", ",", "get_string", "(", "'services'", ",", "'lti'", ")", ")", ";", "foreach", "(", "$", "services", "as", "$", "service", ")", "{", "/** @var \\mod_lti\\local\\ltiservice\\service_base $service */", "$", "service", "->", "get_configuration_options", "(", "$", "mform", ")", ";", "}", "}" ]
Generates the lti advantage extra configuration adding it to the mform @param MoodleQuickForm $mform
[ "Generates", "the", "lti", "advantage", "extra", "configuration", "adding", "it", "to", "the", "mform" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/edit_form.php#L291-L299
219,241
moodle/moodle
search/classes/external.php
external.get_relevant_users
public static function get_relevant_users($query, $courseid) { global $CFG, $PAGE; // Validate parameter. self::validate_parameters(self::get_relevant_users_parameters(), ['query' => $query, 'courseid' => $courseid]); // Validate the context (search page is always system context). $systemcontext = \context_system::instance(); self::validate_context($systemcontext); // Get course object too. if ($courseid) { $coursecontext = \context_course::instance($courseid); } else { $coursecontext = null; } // If not logged in, can't see anyone when forceloginforprofiles is on. if (!empty($CFG->forceloginforprofiles)) { if (!isloggedin() || isguestuser()) { return []; } } $users = \core_user::search($query, $coursecontext); $result = []; foreach ($users as $user) { // Get a standard exported user object. $fulldetails = (new user_summary_exporter($user))->export($PAGE->get_renderer('core')); // To avoid leaking private data to students, only include the specific information we // are going to display (and not the email, idnumber, etc). $result[] = (object)['id' => $fulldetails->id, 'fullname' => $fulldetails->fullname, 'profileimageurlsmall' => $fulldetails->profileimageurlsmall]; } return $result; }
php
public static function get_relevant_users($query, $courseid) { global $CFG, $PAGE; // Validate parameter. self::validate_parameters(self::get_relevant_users_parameters(), ['query' => $query, 'courseid' => $courseid]); // Validate the context (search page is always system context). $systemcontext = \context_system::instance(); self::validate_context($systemcontext); // Get course object too. if ($courseid) { $coursecontext = \context_course::instance($courseid); } else { $coursecontext = null; } // If not logged in, can't see anyone when forceloginforprofiles is on. if (!empty($CFG->forceloginforprofiles)) { if (!isloggedin() || isguestuser()) { return []; } } $users = \core_user::search($query, $coursecontext); $result = []; foreach ($users as $user) { // Get a standard exported user object. $fulldetails = (new user_summary_exporter($user))->export($PAGE->get_renderer('core')); // To avoid leaking private data to students, only include the specific information we // are going to display (and not the email, idnumber, etc). $result[] = (object)['id' => $fulldetails->id, 'fullname' => $fulldetails->fullname, 'profileimageurlsmall' => $fulldetails->profileimageurlsmall]; } return $result; }
[ "public", "static", "function", "get_relevant_users", "(", "$", "query", ",", "$", "courseid", ")", "{", "global", "$", "CFG", ",", "$", "PAGE", ";", "// Validate parameter.", "self", "::", "validate_parameters", "(", "self", "::", "get_relevant_users_parameters", "(", ")", ",", "[", "'query'", "=>", "$", "query", ",", "'courseid'", "=>", "$", "courseid", "]", ")", ";", "// Validate the context (search page is always system context).", "$", "systemcontext", "=", "\\", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "systemcontext", ")", ";", "// Get course object too.", "if", "(", "$", "courseid", ")", "{", "$", "coursecontext", "=", "\\", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "}", "else", "{", "$", "coursecontext", "=", "null", ";", "}", "// If not logged in, can't see anyone when forceloginforprofiles is on.", "if", "(", "!", "empty", "(", "$", "CFG", "->", "forceloginforprofiles", ")", ")", "{", "if", "(", "!", "isloggedin", "(", ")", "||", "isguestuser", "(", ")", ")", "{", "return", "[", "]", ";", "}", "}", "$", "users", "=", "\\", "core_user", "::", "search", "(", "$", "query", ",", "$", "coursecontext", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "// Get a standard exported user object.", "$", "fulldetails", "=", "(", "new", "user_summary_exporter", "(", "$", "user", ")", ")", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "// To avoid leaking private data to students, only include the specific information we", "// are going to display (and not the email, idnumber, etc).", "$", "result", "[", "]", "=", "(", "object", ")", "[", "'id'", "=>", "$", "fulldetails", "->", "id", ",", "'fullname'", "=>", "$", "fulldetails", "->", "fullname", ",", "'profileimageurlsmall'", "=>", "$", "fulldetails", "->", "profileimageurlsmall", "]", ";", "}", "return", "$", "result", ";", "}" ]
Searches for users given a query, taking into account the current user's permissions and possibly a course to check within. @param string $query Query text @param int $courseid Course id or 0 if no restriction @return array Defined return structure
[ "Searches", "for", "users", "given", "a", "query", "taking", "into", "account", "the", "current", "user", "s", "permissions", "and", "possibly", "a", "course", "to", "check", "within", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/search/classes/external.php#L80-L118
219,242
moodle/moodle
analytics/classes/prediction.php
prediction.action_executed
public function action_executed($actionname, \core_analytics\local\target\base $target) { global $USER, $DB; $context = \context::instance_by_id($this->get_prediction_data()->contextid, IGNORE_MISSING); if (!$context) { throw new \moodle_exception('errorpredictioncontextnotavailable', 'analytics'); } // Check that the provided action exists. $actions = $target->prediction_actions($this, true); foreach ($actions as $action) { if ($action->get_action_name() === $actionname) { $found = true; } } if (empty($found)) { throw new \moodle_exception('errorunknownaction', 'analytics'); } $predictionid = $this->get_prediction_data()->id; $action = new \stdClass(); $action->predictionid = $predictionid; $action->userid = $USER->id; $action->actionname = $actionname; $action->timecreated = time(); $DB->insert_record('analytics_prediction_actions', $action); $eventdata = array ( 'context' => $context, 'objectid' => $predictionid, 'other' => array('actionname' => $actionname) ); \core\event\prediction_action_started::create($eventdata)->trigger(); }
php
public function action_executed($actionname, \core_analytics\local\target\base $target) { global $USER, $DB; $context = \context::instance_by_id($this->get_prediction_data()->contextid, IGNORE_MISSING); if (!$context) { throw new \moodle_exception('errorpredictioncontextnotavailable', 'analytics'); } // Check that the provided action exists. $actions = $target->prediction_actions($this, true); foreach ($actions as $action) { if ($action->get_action_name() === $actionname) { $found = true; } } if (empty($found)) { throw new \moodle_exception('errorunknownaction', 'analytics'); } $predictionid = $this->get_prediction_data()->id; $action = new \stdClass(); $action->predictionid = $predictionid; $action->userid = $USER->id; $action->actionname = $actionname; $action->timecreated = time(); $DB->insert_record('analytics_prediction_actions', $action); $eventdata = array ( 'context' => $context, 'objectid' => $predictionid, 'other' => array('actionname' => $actionname) ); \core\event\prediction_action_started::create($eventdata)->trigger(); }
[ "public", "function", "action_executed", "(", "$", "actionname", ",", "\\", "core_analytics", "\\", "local", "\\", "target", "\\", "base", "$", "target", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "context", "=", "\\", "context", "::", "instance_by_id", "(", "$", "this", "->", "get_prediction_data", "(", ")", "->", "contextid", ",", "IGNORE_MISSING", ")", ";", "if", "(", "!", "$", "context", ")", "{", "throw", "new", "\\", "moodle_exception", "(", "'errorpredictioncontextnotavailable'", ",", "'analytics'", ")", ";", "}", "// Check that the provided action exists.", "$", "actions", "=", "$", "target", "->", "prediction_actions", "(", "$", "this", ",", "true", ")", ";", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if", "(", "$", "action", "->", "get_action_name", "(", ")", "===", "$", "actionname", ")", "{", "$", "found", "=", "true", ";", "}", "}", "if", "(", "empty", "(", "$", "found", ")", ")", "{", "throw", "new", "\\", "moodle_exception", "(", "'errorunknownaction'", ",", "'analytics'", ")", ";", "}", "$", "predictionid", "=", "$", "this", "->", "get_prediction_data", "(", ")", "->", "id", ";", "$", "action", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "action", "->", "predictionid", "=", "$", "predictionid", ";", "$", "action", "->", "userid", "=", "$", "USER", "->", "id", ";", "$", "action", "->", "actionname", "=", "$", "actionname", ";", "$", "action", "->", "timecreated", "=", "time", "(", ")", ";", "$", "DB", "->", "insert_record", "(", "'analytics_prediction_actions'", ",", "$", "action", ")", ";", "$", "eventdata", "=", "array", "(", "'context'", "=>", "$", "context", ",", "'objectid'", "=>", "$", "predictionid", ",", "'other'", "=>", "array", "(", "'actionname'", "=>", "$", "actionname", ")", ")", ";", "\\", "core", "\\", "event", "\\", "prediction_action_started", "::", "create", "(", "$", "eventdata", ")", "->", "trigger", "(", ")", ";", "}" ]
Stores the executed action. Prediction instances should be retrieved using \core_analytics\manager::get_prediction, It is the caller responsability to check that the user can see the prediction. @param string $actionname @param \core_analytics\local\target\base $target
[ "Stores", "the", "executed", "action", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/prediction.php#L124-L158
219,243
moodle/moodle
user/selector/lib.php
user_selector_base.get_selected_users
public function get_selected_users() { // Do a lazy load. if (is_null($this->selected)) { $this->selected = $this->load_selected_users(); } return $this->selected; }
php
public function get_selected_users() { // Do a lazy load. if (is_null($this->selected)) { $this->selected = $this->load_selected_users(); } return $this->selected; }
[ "public", "function", "get_selected_users", "(", ")", "{", "// Do a lazy load.", "if", "(", "is_null", "(", "$", "this", "->", "selected", ")", ")", "{", "$", "this", "->", "selected", "=", "$", "this", "->", "load_selected_users", "(", ")", ";", "}", "return", "$", "this", "->", "selected", ";", "}" ]
The users that were selected. This is a more sophisticated version of optional_param($this->name, array(), PARAM_INT) that validates the returned list of ids against the rules for this user selector. @return array of user objects.
[ "The", "users", "that", "were", "selected", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L171-L177
219,244
moodle/moodle
user/selector/lib.php
user_selector_base.display
public function display($return = false) { global $PAGE; // Get the list of requested users. $search = optional_param($this->name . '_searchtext', '', PARAM_RAW); if (optional_param($this->name . '_clearbutton', false, PARAM_BOOL)) { $search = ''; } $groupedusers = $this->find_users($search); // Output the select. $name = $this->name; $multiselect = ''; if ($this->multiselect) { $name .= '[]'; $multiselect = 'multiple="multiple" '; } $output = '<div class="userselector" id="' . $this->name . '_wrapper">' . "\n" . '<select name="' . $name . '" id="' . $this->name . '" ' . $multiselect . 'size="' . $this->rows . '" class="form-control no-overflow">' . "\n"; // Populate the select. $output .= $this->output_options($groupedusers, $search); // Output the search controls. $output .= "</select>\n<div class=\"form-inline\">\n"; $output .= '<input type="text" name="' . $this->name . '_searchtext" id="' . $this->name . '_searchtext" size="15" value="' . s($search) . '" class="form-control"/>'; $output .= '<input type="submit" name="' . $this->name . '_searchbutton" id="' . $this->name . '_searchbutton" value="' . $this->search_button_caption() . '" class="btn btn-secondary"/>'; $output .= '<input type="submit" name="' . $this->name . '_clearbutton" id="' . $this->name . '_clearbutton" value="' . get_string('clear') . '" class="btn btn-secondary"/>'; // And the search options. $optionsoutput = false; if (!user_selector_base::$searchoptionsoutput) { $output .= print_collapsible_region_start('', 'userselector_options', get_string('searchoptions'), 'userselector_optionscollapsed', true, true); $output .= $this->option_checkbox('preserveselected', $this->preserveselected, get_string('userselectorpreserveselected')); $output .= $this->option_checkbox('autoselectunique', $this->autoselectunique, get_string('userselectorautoselectunique')); $output .= $this->option_checkbox('searchanywhere', $this->searchanywhere, get_string('userselectorsearchanywhere')); $output .= print_collapsible_region_end(true); $PAGE->requires->js_init_call('M.core_user.init_user_selector_options_tracker', array(), false, self::$jsmodule); user_selector_base::$searchoptionsoutput = true; } $output .= "</div>\n</div>\n\n"; // Initialise the ajax functionality. $output .= $this->initialise_javascript($search); // Return or output it. if ($return) { return $output; } else { echo $output; } }
php
public function display($return = false) { global $PAGE; // Get the list of requested users. $search = optional_param($this->name . '_searchtext', '', PARAM_RAW); if (optional_param($this->name . '_clearbutton', false, PARAM_BOOL)) { $search = ''; } $groupedusers = $this->find_users($search); // Output the select. $name = $this->name; $multiselect = ''; if ($this->multiselect) { $name .= '[]'; $multiselect = 'multiple="multiple" '; } $output = '<div class="userselector" id="' . $this->name . '_wrapper">' . "\n" . '<select name="' . $name . '" id="' . $this->name . '" ' . $multiselect . 'size="' . $this->rows . '" class="form-control no-overflow">' . "\n"; // Populate the select. $output .= $this->output_options($groupedusers, $search); // Output the search controls. $output .= "</select>\n<div class=\"form-inline\">\n"; $output .= '<input type="text" name="' . $this->name . '_searchtext" id="' . $this->name . '_searchtext" size="15" value="' . s($search) . '" class="form-control"/>'; $output .= '<input type="submit" name="' . $this->name . '_searchbutton" id="' . $this->name . '_searchbutton" value="' . $this->search_button_caption() . '" class="btn btn-secondary"/>'; $output .= '<input type="submit" name="' . $this->name . '_clearbutton" id="' . $this->name . '_clearbutton" value="' . get_string('clear') . '" class="btn btn-secondary"/>'; // And the search options. $optionsoutput = false; if (!user_selector_base::$searchoptionsoutput) { $output .= print_collapsible_region_start('', 'userselector_options', get_string('searchoptions'), 'userselector_optionscollapsed', true, true); $output .= $this->option_checkbox('preserveselected', $this->preserveselected, get_string('userselectorpreserveselected')); $output .= $this->option_checkbox('autoselectunique', $this->autoselectunique, get_string('userselectorautoselectunique')); $output .= $this->option_checkbox('searchanywhere', $this->searchanywhere, get_string('userselectorsearchanywhere')); $output .= print_collapsible_region_end(true); $PAGE->requires->js_init_call('M.core_user.init_user_selector_options_tracker', array(), false, self::$jsmodule); user_selector_base::$searchoptionsoutput = true; } $output .= "</div>\n</div>\n\n"; // Initialise the ajax functionality. $output .= $this->initialise_javascript($search); // Return or output it. if ($return) { return $output; } else { echo $output; } }
[ "public", "function", "display", "(", "$", "return", "=", "false", ")", "{", "global", "$", "PAGE", ";", "// Get the list of requested users.", "$", "search", "=", "optional_param", "(", "$", "this", "->", "name", ".", "'_searchtext'", ",", "''", ",", "PARAM_RAW", ")", ";", "if", "(", "optional_param", "(", "$", "this", "->", "name", ".", "'_clearbutton'", ",", "false", ",", "PARAM_BOOL", ")", ")", "{", "$", "search", "=", "''", ";", "}", "$", "groupedusers", "=", "$", "this", "->", "find_users", "(", "$", "search", ")", ";", "// Output the select.", "$", "name", "=", "$", "this", "->", "name", ";", "$", "multiselect", "=", "''", ";", "if", "(", "$", "this", "->", "multiselect", ")", "{", "$", "name", ".=", "'[]'", ";", "$", "multiselect", "=", "'multiple=\"multiple\" '", ";", "}", "$", "output", "=", "'<div class=\"userselector\" id=\"'", ".", "$", "this", "->", "name", ".", "'_wrapper\">'", ".", "\"\\n\"", ".", "'<select name=\"'", ".", "$", "name", ".", "'\" id=\"'", ".", "$", "this", "->", "name", ".", "'\" '", ".", "$", "multiselect", ".", "'size=\"'", ".", "$", "this", "->", "rows", ".", "'\" class=\"form-control no-overflow\">'", ".", "\"\\n\"", ";", "// Populate the select.", "$", "output", ".=", "$", "this", "->", "output_options", "(", "$", "groupedusers", ",", "$", "search", ")", ";", "// Output the search controls.", "$", "output", ".=", "\"</select>\\n<div class=\\\"form-inline\\\">\\n\"", ";", "$", "output", ".=", "'<input type=\"text\" name=\"'", ".", "$", "this", "->", "name", ".", "'_searchtext\" id=\"'", ".", "$", "this", "->", "name", ".", "'_searchtext\" size=\"15\" value=\"'", ".", "s", "(", "$", "search", ")", ".", "'\" class=\"form-control\"/>'", ";", "$", "output", ".=", "'<input type=\"submit\" name=\"'", ".", "$", "this", "->", "name", ".", "'_searchbutton\" id=\"'", ".", "$", "this", "->", "name", ".", "'_searchbutton\" value=\"'", ".", "$", "this", "->", "search_button_caption", "(", ")", ".", "'\" class=\"btn btn-secondary\"/>'", ";", "$", "output", ".=", "'<input type=\"submit\" name=\"'", ".", "$", "this", "->", "name", ".", "'_clearbutton\" id=\"'", ".", "$", "this", "->", "name", ".", "'_clearbutton\" value=\"'", ".", "get_string", "(", "'clear'", ")", ".", "'\" class=\"btn btn-secondary\"/>'", ";", "// And the search options.", "$", "optionsoutput", "=", "false", ";", "if", "(", "!", "user_selector_base", "::", "$", "searchoptionsoutput", ")", "{", "$", "output", ".=", "print_collapsible_region_start", "(", "''", ",", "'userselector_options'", ",", "get_string", "(", "'searchoptions'", ")", ",", "'userselector_optionscollapsed'", ",", "true", ",", "true", ")", ";", "$", "output", ".=", "$", "this", "->", "option_checkbox", "(", "'preserveselected'", ",", "$", "this", "->", "preserveselected", ",", "get_string", "(", "'userselectorpreserveselected'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "option_checkbox", "(", "'autoselectunique'", ",", "$", "this", "->", "autoselectunique", ",", "get_string", "(", "'userselectorautoselectunique'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "option_checkbox", "(", "'searchanywhere'", ",", "$", "this", "->", "searchanywhere", ",", "get_string", "(", "'userselectorsearchanywhere'", ")", ")", ";", "$", "output", ".=", "print_collapsible_region_end", "(", "true", ")", ";", "$", "PAGE", "->", "requires", "->", "js_init_call", "(", "'M.core_user.init_user_selector_options_tracker'", ",", "array", "(", ")", ",", "false", ",", "self", "::", "$", "jsmodule", ")", ";", "user_selector_base", "::", "$", "searchoptionsoutput", "=", "true", ";", "}", "$", "output", ".=", "\"</div>\\n</div>\\n\\n\"", ";", "// Initialise the ajax functionality.", "$", "output", ".=", "$", "this", "->", "initialise_javascript", "(", "$", "search", ")", ";", "// Return or output it.", "if", "(", "$", "return", ")", "{", "return", "$", "output", ";", "}", "else", "{", "echo", "$", "output", ";", "}", "}" ]
Output this user_selector as HTML. @param boolean $return if true, return the HTML as a string instead of outputting it. @return mixed if $return is true, returns the HTML as a string, otherwise returns nothing.
[ "Output", "this", "user_selector", "as", "HTML", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L217-L277
219,245
moodle/moodle
user/selector/lib.php
user_selector_base.load_selected_users
protected function load_selected_users() { // See if we got anything. if ($this->multiselect) { $userids = optional_param_array($this->name, array(), PARAM_INT); } else if ($userid = optional_param($this->name, 0, PARAM_INT)) { $userids = array($userid); } // If there are no users there is nobody to load. if (empty($userids)) { return array(); } // If we did, use the find_users method to validate the ids. $this->validatinguserids = $userids; $groupedusers = $this->find_users(''); $this->validatinguserids = null; // Aggregate the resulting list back into a single one. $users = array(); foreach ($groupedusers as $group) { foreach ($group as $user) { if (!isset($users[$user->id]) && empty($user->disabled) && in_array($user->id, $userids)) { $users[$user->id] = $user; } } } // If we are only supposed to be selecting a single user, make sure we do. if (!$this->multiselect && count($users) > 1) { $users = array_slice($users, 0, 1); } return $users; }
php
protected function load_selected_users() { // See if we got anything. if ($this->multiselect) { $userids = optional_param_array($this->name, array(), PARAM_INT); } else if ($userid = optional_param($this->name, 0, PARAM_INT)) { $userids = array($userid); } // If there are no users there is nobody to load. if (empty($userids)) { return array(); } // If we did, use the find_users method to validate the ids. $this->validatinguserids = $userids; $groupedusers = $this->find_users(''); $this->validatinguserids = null; // Aggregate the resulting list back into a single one. $users = array(); foreach ($groupedusers as $group) { foreach ($group as $user) { if (!isset($users[$user->id]) && empty($user->disabled) && in_array($user->id, $userids)) { $users[$user->id] = $user; } } } // If we are only supposed to be selecting a single user, make sure we do. if (!$this->multiselect && count($users) > 1) { $users = array_slice($users, 0, 1); } return $users; }
[ "protected", "function", "load_selected_users", "(", ")", "{", "// See if we got anything.", "if", "(", "$", "this", "->", "multiselect", ")", "{", "$", "userids", "=", "optional_param_array", "(", "$", "this", "->", "name", ",", "array", "(", ")", ",", "PARAM_INT", ")", ";", "}", "else", "if", "(", "$", "userid", "=", "optional_param", "(", "$", "this", "->", "name", ",", "0", ",", "PARAM_INT", ")", ")", "{", "$", "userids", "=", "array", "(", "$", "userid", ")", ";", "}", "// If there are no users there is nobody to load.", "if", "(", "empty", "(", "$", "userids", ")", ")", "{", "return", "array", "(", ")", ";", "}", "// If we did, use the find_users method to validate the ids.", "$", "this", "->", "validatinguserids", "=", "$", "userids", ";", "$", "groupedusers", "=", "$", "this", "->", "find_users", "(", "''", ")", ";", "$", "this", "->", "validatinguserids", "=", "null", ";", "// Aggregate the resulting list back into a single one.", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "groupedusers", "as", "$", "group", ")", "{", "foreach", "(", "$", "group", "as", "$", "user", ")", "{", "if", "(", "!", "isset", "(", "$", "users", "[", "$", "user", "->", "id", "]", ")", "&&", "empty", "(", "$", "user", "->", "disabled", ")", "&&", "in_array", "(", "$", "user", "->", "id", ",", "$", "userids", ")", ")", "{", "$", "users", "[", "$", "user", "->", "id", "]", "=", "$", "user", ";", "}", "}", "}", "// If we are only supposed to be selecting a single user, make sure we do.", "if", "(", "!", "$", "this", "->", "multiselect", "&&", "count", "(", "$", "users", ")", ">", "1", ")", "{", "$", "users", "=", "array_slice", "(", "$", "users", ",", "0", ",", "1", ")", ";", "}", "return", "$", "users", ";", "}" ]
Get the list of users that were selected by doing optional_param then validating the result. @return array of user objects.
[ "Get", "the", "list", "of", "users", "that", "were", "selected", "by", "doing", "optional_param", "then", "validating", "the", "result", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L394-L427
219,246
moodle/moodle
user/selector/lib.php
user_selector_base.required_fields_sql
protected function required_fields_sql($u) { // Raw list of fields. $fields = array('id'); // Add additional name fields. $fields = array_merge($fields, get_all_user_name_fields(), $this->extrafields); // Prepend the table alias. if ($u) { foreach ($fields as &$field) { $field = $u . '.' . $field; } } return implode(',', $fields); }
php
protected function required_fields_sql($u) { // Raw list of fields. $fields = array('id'); // Add additional name fields. $fields = array_merge($fields, get_all_user_name_fields(), $this->extrafields); // Prepend the table alias. if ($u) { foreach ($fields as &$field) { $field = $u . '.' . $field; } } return implode(',', $fields); }
[ "protected", "function", "required_fields_sql", "(", "$", "u", ")", "{", "// Raw list of fields.", "$", "fields", "=", "array", "(", "'id'", ")", ";", "// Add additional name fields.", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "get_all_user_name_fields", "(", ")", ",", "$", "this", "->", "extrafields", ")", ";", "// Prepend the table alias.", "if", "(", "$", "u", ")", "{", "foreach", "(", "$", "fields", "as", "&", "$", "field", ")", "{", "$", "field", "=", "$", "u", ".", "'.'", ".", "$", "field", ";", "}", "}", "return", "implode", "(", "','", ",", "$", "fields", ")", ";", "}" ]
Returns SQL to select required fields. @param string $u the table alias for the user table in the query being built. May be ''. @return string fragment of SQL to go in the select list of the query.
[ "Returns", "SQL", "to", "select", "required", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L436-L449
219,247
moodle/moodle
user/selector/lib.php
user_selector_base.search_sql
protected function search_sql($search, $u) { return users_search_sql($search, $u, $this->searchanywhere, $this->extrafields, $this->exclude, $this->validatinguserids); }
php
protected function search_sql($search, $u) { return users_search_sql($search, $u, $this->searchanywhere, $this->extrafields, $this->exclude, $this->validatinguserids); }
[ "protected", "function", "search_sql", "(", "$", "search", ",", "$", "u", ")", "{", "return", "users_search_sql", "(", "$", "search", ",", "$", "u", ",", "$", "this", "->", "searchanywhere", ",", "$", "this", "->", "extrafields", ",", "$", "this", "->", "exclude", ",", "$", "this", "->", "validatinguserids", ")", ";", "}" ]
Returns an array with SQL to perform a search and the params that go into it. @param string $search the text to search for. @param string $u the table alias for the user table in the query being built. May be ''. @return array an array with two elements, a fragment of SQL to go in the where clause the query, and an array containing any required parameters. this uses ? style placeholders.
[ "Returns", "an", "array", "with", "SQL", "to", "perform", "a", "search", "and", "the", "params", "that", "go", "into", "it", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L461-L464
219,248
moodle/moodle
user/selector/lib.php
user_selector_base.too_many_results
protected function too_many_results($search, $count) { if ($search) { $a = new stdClass; $a->count = $count; $a->search = $search; return array(get_string('toomanyusersmatchsearch', '', $a) => array(), get_string('pleasesearchmore') => array()); } else { return array(get_string('toomanyuserstoshow', '', $count) => array(), get_string('pleaseusesearch') => array()); } }
php
protected function too_many_results($search, $count) { if ($search) { $a = new stdClass; $a->count = $count; $a->search = $search; return array(get_string('toomanyusersmatchsearch', '', $a) => array(), get_string('pleasesearchmore') => array()); } else { return array(get_string('toomanyuserstoshow', '', $count) => array(), get_string('pleaseusesearch') => array()); } }
[ "protected", "function", "too_many_results", "(", "$", "search", ",", "$", "count", ")", "{", "if", "(", "$", "search", ")", "{", "$", "a", "=", "new", "stdClass", ";", "$", "a", "->", "count", "=", "$", "count", ";", "$", "a", "->", "search", "=", "$", "search", ";", "return", "array", "(", "get_string", "(", "'toomanyusersmatchsearch'", ",", "''", ",", "$", "a", ")", "=>", "array", "(", ")", ",", "get_string", "(", "'pleasesearchmore'", ")", "=>", "array", "(", ")", ")", ";", "}", "else", "{", "return", "array", "(", "get_string", "(", "'toomanyuserstoshow'", ",", "''", ",", "$", "count", ")", "=>", "array", "(", ")", ",", "get_string", "(", "'pleaseusesearch'", ")", "=>", "array", "(", ")", ")", ";", "}", "}" ]
Used to generate a nice message when there are too many users to show. The message includes the number of users that currently match, and the text of the message depends on whether the search term is non-blank. @param string $search the search term, as passed in to the find users method. @param int $count the number of users that currently match. @return array in the right format to return from the find_users method.
[ "Used", "to", "generate", "a", "nice", "message", "when", "there", "are", "too", "many", "users", "to", "show", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L476-L487
219,249
moodle/moodle
user/selector/lib.php
user_selector_base.output_optgroup
protected function output_optgroup($groupname, $users, $select) { if (!empty($users)) { $output = ' <optgroup label="' . htmlspecialchars($groupname) . ' (' . count($users) . ')">' . "\n"; foreach ($users as $user) { $attributes = ''; if (!empty($user->disabled)) { $attributes .= ' disabled="disabled"'; } else if ($select || isset($this->selected[$user->id])) { $attributes .= ' selected="selected"'; } unset($this->selected[$user->id]); $output .= ' <option' . $attributes . ' value="' . $user->id . '">' . $this->output_user($user) . "</option>\n"; if (!empty($user->infobelow)) { // Poor man's indent here is because CSS styles do not work in select options, except in Firefox. $output .= ' <option disabled="disabled" class="userselector-infobelow">' . '&nbsp;&nbsp;&nbsp;&nbsp;' . s($user->infobelow) . '</option>'; } } } else { $output = ' <optgroup label="' . htmlspecialchars($groupname) . '">' . "\n"; $output .= ' <option disabled="disabled">&nbsp;</option>' . "\n"; } $output .= " </optgroup>\n"; return $output; }
php
protected function output_optgroup($groupname, $users, $select) { if (!empty($users)) { $output = ' <optgroup label="' . htmlspecialchars($groupname) . ' (' . count($users) . ')">' . "\n"; foreach ($users as $user) { $attributes = ''; if (!empty($user->disabled)) { $attributes .= ' disabled="disabled"'; } else if ($select || isset($this->selected[$user->id])) { $attributes .= ' selected="selected"'; } unset($this->selected[$user->id]); $output .= ' <option' . $attributes . ' value="' . $user->id . '">' . $this->output_user($user) . "</option>\n"; if (!empty($user->infobelow)) { // Poor man's indent here is because CSS styles do not work in select options, except in Firefox. $output .= ' <option disabled="disabled" class="userselector-infobelow">' . '&nbsp;&nbsp;&nbsp;&nbsp;' . s($user->infobelow) . '</option>'; } } } else { $output = ' <optgroup label="' . htmlspecialchars($groupname) . '">' . "\n"; $output .= ' <option disabled="disabled">&nbsp;</option>' . "\n"; } $output .= " </optgroup>\n"; return $output; }
[ "protected", "function", "output_optgroup", "(", "$", "groupname", ",", "$", "users", ",", "$", "select", ")", "{", "if", "(", "!", "empty", "(", "$", "users", ")", ")", "{", "$", "output", "=", "' <optgroup label=\"'", ".", "htmlspecialchars", "(", "$", "groupname", ")", ".", "' ('", ".", "count", "(", "$", "users", ")", ".", "')\">'", ".", "\"\\n\"", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "attributes", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "user", "->", "disabled", ")", ")", "{", "$", "attributes", ".=", "' disabled=\"disabled\"'", ";", "}", "else", "if", "(", "$", "select", "||", "isset", "(", "$", "this", "->", "selected", "[", "$", "user", "->", "id", "]", ")", ")", "{", "$", "attributes", ".=", "' selected=\"selected\"'", ";", "}", "unset", "(", "$", "this", "->", "selected", "[", "$", "user", "->", "id", "]", ")", ";", "$", "output", ".=", "' <option'", ".", "$", "attributes", ".", "' value=\"'", ".", "$", "user", "->", "id", ".", "'\">'", ".", "$", "this", "->", "output_user", "(", "$", "user", ")", ".", "\"</option>\\n\"", ";", "if", "(", "!", "empty", "(", "$", "user", "->", "infobelow", ")", ")", "{", "// Poor man's indent here is because CSS styles do not work in select options, except in Firefox.", "$", "output", ".=", "' <option disabled=\"disabled\" class=\"userselector-infobelow\">'", ".", "'&nbsp;&nbsp;&nbsp;&nbsp;'", ".", "s", "(", "$", "user", "->", "infobelow", ")", ".", "'</option>'", ";", "}", "}", "}", "else", "{", "$", "output", "=", "' <optgroup label=\"'", ".", "htmlspecialchars", "(", "$", "groupname", ")", ".", "'\">'", ".", "\"\\n\"", ";", "$", "output", ".=", "' <option disabled=\"disabled\">&nbsp;</option>'", ".", "\"\\n\"", ";", "}", "$", "output", ".=", "\" </optgroup>\\n\"", ";", "return", "$", "output", ";", "}" ]
Output one particular optgroup. Used by the preceding function output_options. @param string $groupname the label for this optgroup. @param array $users the users to put in this optgroup. @param boolean $select if true, select the users in this group. @return string HTML code.
[ "Output", "one", "particular", "optgroup", ".", "Used", "by", "the", "preceding", "function", "output_options", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L546-L571
219,250
moodle/moodle
user/selector/lib.php
user_selector_base.output_user
public function output_user($user) { $out = fullname($user, $this->viewfullnames); if ($this->extrafields) { $displayfields = array(); foreach ($this->extrafields as $field) { $displayfields[] = $user->{$field}; } $out .= ' (' . implode(', ', $displayfields) . ')'; } return $out; }
php
public function output_user($user) { $out = fullname($user, $this->viewfullnames); if ($this->extrafields) { $displayfields = array(); foreach ($this->extrafields as $field) { $displayfields[] = $user->{$field}; } $out .= ' (' . implode(', ', $displayfields) . ')'; } return $out; }
[ "public", "function", "output_user", "(", "$", "user", ")", "{", "$", "out", "=", "fullname", "(", "$", "user", ",", "$", "this", "->", "viewfullnames", ")", ";", "if", "(", "$", "this", "->", "extrafields", ")", "{", "$", "displayfields", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "extrafields", "as", "$", "field", ")", "{", "$", "displayfields", "[", "]", "=", "$", "user", "->", "{", "$", "field", "}", ";", "}", "$", "out", ".=", "' ('", ".", "implode", "(", "', '", ",", "$", "displayfields", ")", ".", "')'", ";", "}", "return", "$", "out", ";", "}" ]
Convert a user object to a string suitable for displaying as an option in the list box. @param object $user the user to display. @return string a string representation of the user.
[ "Convert", "a", "user", "object", "to", "a", "string", "suitable", "for", "displaying", "as", "an", "option", "in", "the", "list", "box", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L579-L589
219,251
moodle/moodle
user/selector/lib.php
user_selector_base.initialise_option
private function initialise_option($name, $default) { $param = optional_param($name, null, PARAM_BOOL); if (is_null($param)) { return get_user_preferences($name, $default); } else { set_user_preference($name, $param); return $param; } }
php
private function initialise_option($name, $default) { $param = optional_param($name, null, PARAM_BOOL); if (is_null($param)) { return get_user_preferences($name, $default); } else { set_user_preference($name, $param); return $param; } }
[ "private", "function", "initialise_option", "(", "$", "name", ",", "$", "default", ")", "{", "$", "param", "=", "optional_param", "(", "$", "name", ",", "null", ",", "PARAM_BOOL", ")", ";", "if", "(", "is_null", "(", "$", "param", ")", ")", "{", "return", "get_user_preferences", "(", "$", "name", ",", "$", "default", ")", ";", "}", "else", "{", "set_user_preference", "(", "$", "name", ",", "$", "param", ")", ";", "return", "$", "param", ";", "}", "}" ]
Initialise one of the option checkboxes, either from the request, or failing that from the user_preferences table, or finally from the given default. @param string $name @param mixed $default @return mixed|null|string
[ "Initialise", "one", "of", "the", "option", "checkboxes", "either", "from", "the", "request", "or", "failing", "that", "from", "the", "user_preferences", "table", "or", "finally", "from", "the", "given", "default", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L608-L616
219,252
moodle/moodle
user/selector/lib.php
user_selector_base.option_checkbox
private function option_checkbox($name, $on, $label) { if ($on) { $checked = ' checked="checked"'; } else { $checked = ''; } $name = 'userselector_' . $name; // For the benefit of brain-dead IE, the id must be different from the name of the hidden form field above. // It seems that document.getElementById('frog') in IE will return and element with name="frog". $output = '<div class="form-check"><input type="hidden" name="' . $name . '" value="0" />' . '<label class="form-check-label" for="' . $name . 'id">' . '<input class="form-check-input" type="checkbox" id="' . $name . 'id" name="' . $name . '" value="1"' . $checked . ' /> ' . $label . "</label> </div>\n"; user_preference_allow_ajax_update($name, PARAM_BOOL); return $output; }
php
private function option_checkbox($name, $on, $label) { if ($on) { $checked = ' checked="checked"'; } else { $checked = ''; } $name = 'userselector_' . $name; // For the benefit of brain-dead IE, the id must be different from the name of the hidden form field above. // It seems that document.getElementById('frog') in IE will return and element with name="frog". $output = '<div class="form-check"><input type="hidden" name="' . $name . '" value="0" />' . '<label class="form-check-label" for="' . $name . 'id">' . '<input class="form-check-input" type="checkbox" id="' . $name . 'id" name="' . $name . '" value="1"' . $checked . ' /> ' . $label . "</label> </div>\n"; user_preference_allow_ajax_update($name, PARAM_BOOL); return $output; }
[ "private", "function", "option_checkbox", "(", "$", "name", ",", "$", "on", ",", "$", "label", ")", "{", "if", "(", "$", "on", ")", "{", "$", "checked", "=", "' checked=\"checked\"'", ";", "}", "else", "{", "$", "checked", "=", "''", ";", "}", "$", "name", "=", "'userselector_'", ".", "$", "name", ";", "// For the benefit of brain-dead IE, the id must be different from the name of the hidden form field above.", "// It seems that document.getElementById('frog') in IE will return and element with name=\"frog\".", "$", "output", "=", "'<div class=\"form-check\"><input type=\"hidden\" name=\"'", ".", "$", "name", ".", "'\" value=\"0\" />'", ".", "'<label class=\"form-check-label\" for=\"'", ".", "$", "name", ".", "'id\">'", ".", "'<input class=\"form-check-input\" type=\"checkbox\" id=\"'", ".", "$", "name", ".", "'id\" name=\"'", ".", "$", "name", ".", "'\" value=\"1\"'", ".", "$", "checked", ".", "' /> '", ".", "$", "label", ".", "\"</label>\n </div>\\n\"", ";", "user_preference_allow_ajax_update", "(", "$", "name", ",", "PARAM_BOOL", ")", ";", "return", "$", "output", ";", "}" ]
Output one of the options checkboxes. @param string $name @param string $on @param string $label @return string
[ "Output", "one", "of", "the", "options", "checkboxes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L626-L643
219,253
moodle/moodle
user/selector/lib.php
user_selector_base.initialise_javascript
protected function initialise_javascript($search) { global $USER, $PAGE, $OUTPUT; $output = ''; // Put the options into the session, to allow search.php to respond to the ajax requests. $options = $this->get_options(); $hash = md5(serialize($options)); $USER->userselectors[$hash] = $options; // Initialise the selector. $PAGE->requires->js_init_call( 'M.core_user.init_user_selector', array($this->name, $hash, $this->extrafields, $search), false, self::$jsmodule ); return $output; }
php
protected function initialise_javascript($search) { global $USER, $PAGE, $OUTPUT; $output = ''; // Put the options into the session, to allow search.php to respond to the ajax requests. $options = $this->get_options(); $hash = md5(serialize($options)); $USER->userselectors[$hash] = $options; // Initialise the selector. $PAGE->requires->js_init_call( 'M.core_user.init_user_selector', array($this->name, $hash, $this->extrafields, $search), false, self::$jsmodule ); return $output; }
[ "protected", "function", "initialise_javascript", "(", "$", "search", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ",", "$", "OUTPUT", ";", "$", "output", "=", "''", ";", "// Put the options into the session, to allow search.php to respond to the ajax requests.", "$", "options", "=", "$", "this", "->", "get_options", "(", ")", ";", "$", "hash", "=", "md5", "(", "serialize", "(", "$", "options", ")", ")", ";", "$", "USER", "->", "userselectors", "[", "$", "hash", "]", "=", "$", "options", ";", "// Initialise the selector.", "$", "PAGE", "->", "requires", "->", "js_init_call", "(", "'M.core_user.init_user_selector'", ",", "array", "(", "$", "this", "->", "name", ",", "$", "hash", ",", "$", "this", "->", "extrafields", ",", "$", "search", ")", ",", "false", ",", "self", "::", "$", "jsmodule", ")", ";", "return", "$", "output", ";", "}" ]
Initialises JS for this control. @param string $search @return string any HTML needed here.
[ "Initialises", "JS", "for", "this", "control", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L651-L668
219,254
moodle/moodle
user/selector/lib.php
groups_user_selector_base.get_options
protected function get_options() { $options = parent::get_options(); $options['groupid'] = $this->groupid; $options['courseid'] = $this->courseid; return $options; }
php
protected function get_options() { $options = parent::get_options(); $options['groupid'] = $this->groupid; $options['courseid'] = $this->courseid; return $options; }
[ "protected", "function", "get_options", "(", ")", "{", "$", "options", "=", "parent", "::", "get_options", "(", ")", ";", "$", "options", "[", "'groupid'", "]", "=", "$", "this", "->", "groupid", ";", "$", "options", "[", "'courseid'", "]", "=", "$", "this", "->", "courseid", ";", "return", "$", "options", ";", "}" ]
Returns options for this selector. @return array
[ "Returns", "options", "for", "this", "selector", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L702-L707
219,255
moodle/moodle
user/selector/lib.php
groups_user_selector_base.convert_array_format
protected function convert_array_format($roles, $search) { if (empty($roles)) { $roles = array(); } $groupedusers = array(); foreach ($roles as $role) { if ($search) { $a = new stdClass; $a->role = $role->name; $a->search = $search; $groupname = get_string('matchingsearchandrole', '', $a); } else { $groupname = $role->name; } $groupedusers[$groupname] = $role->users; foreach ($groupedusers[$groupname] as &$user) { unset($user->roles); $user->fullname = fullname($user); if (!empty($user->component)) { $user->infobelow = get_string('addedby', 'group', get_string('pluginname', $user->component)); } } } return $groupedusers; }
php
protected function convert_array_format($roles, $search) { if (empty($roles)) { $roles = array(); } $groupedusers = array(); foreach ($roles as $role) { if ($search) { $a = new stdClass; $a->role = $role->name; $a->search = $search; $groupname = get_string('matchingsearchandrole', '', $a); } else { $groupname = $role->name; } $groupedusers[$groupname] = $role->users; foreach ($groupedusers[$groupname] as &$user) { unset($user->roles); $user->fullname = fullname($user); if (!empty($user->component)) { $user->infobelow = get_string('addedby', 'group', get_string('pluginname', $user->component)); } } } return $groupedusers; }
[ "protected", "function", "convert_array_format", "(", "$", "roles", ",", "$", "search", ")", "{", "if", "(", "empty", "(", "$", "roles", ")", ")", "{", "$", "roles", "=", "array", "(", ")", ";", "}", "$", "groupedusers", "=", "array", "(", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "if", "(", "$", "search", ")", "{", "$", "a", "=", "new", "stdClass", ";", "$", "a", "->", "role", "=", "$", "role", "->", "name", ";", "$", "a", "->", "search", "=", "$", "search", ";", "$", "groupname", "=", "get_string", "(", "'matchingsearchandrole'", ",", "''", ",", "$", "a", ")", ";", "}", "else", "{", "$", "groupname", "=", "$", "role", "->", "name", ";", "}", "$", "groupedusers", "[", "$", "groupname", "]", "=", "$", "role", "->", "users", ";", "foreach", "(", "$", "groupedusers", "[", "$", "groupname", "]", "as", "&", "$", "user", ")", "{", "unset", "(", "$", "user", "->", "roles", ")", ";", "$", "user", "->", "fullname", "=", "fullname", "(", "$", "user", ")", ";", "if", "(", "!", "empty", "(", "$", "user", "->", "component", ")", ")", "{", "$", "user", "->", "infobelow", "=", "get_string", "(", "'addedby'", ",", "'group'", ",", "get_string", "(", "'pluginname'", ",", "$", "user", "->", "component", ")", ")", ";", "}", "}", "}", "return", "$", "groupedusers", ";", "}" ]
Creates an organised array from given data. @param array $roles array in the format returned by groups_calculate_role_people. @param string $search @return array array in the format find_users is supposed to return.
[ "Creates", "an", "organised", "array", "from", "given", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L716-L741
219,256
moodle/moodle
user/selector/lib.php
group_non_members_selector.get_user_summaries
public function get_user_summaries($courseid) { global $DB; $usersummaries = array(); // Get other groups user already belongs to. $usergroups = array(); $potentialmembersids = $this->potentialmembersids; if (empty($potentialmembersids) == false) { list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm'); $sql = "SELECT u.id AS userid, g.* FROM {user} u JOIN {groups_members} gm ON u.id = gm.userid JOIN {groups} g ON gm.groupid = g.id WHERE u.id $membersidsclause AND g.courseid = :courseid "; $params['courseid'] = $courseid; $rs = $DB->get_recordset_sql($sql, $params); foreach ($rs as $usergroup) { $usergroups[$usergroup->userid][$usergroup->id] = $usergroup; } $rs->close(); foreach ($potentialmembersids as $userid) { if (isset($usergroups[$userid])) { $usergrouplist = html_writer::start_tag('ul'); foreach ($usergroups[$userid] as $groupitem) { $usergrouplist .= html_writer::tag('li', format_string($groupitem->name)); } $usergrouplist .= html_writer::end_tag('ul'); } else { $usergrouplist = ''; } $usersummaries[] = $usergrouplist; } } return $usersummaries; }
php
public function get_user_summaries($courseid) { global $DB; $usersummaries = array(); // Get other groups user already belongs to. $usergroups = array(); $potentialmembersids = $this->potentialmembersids; if (empty($potentialmembersids) == false) { list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm'); $sql = "SELECT u.id AS userid, g.* FROM {user} u JOIN {groups_members} gm ON u.id = gm.userid JOIN {groups} g ON gm.groupid = g.id WHERE u.id $membersidsclause AND g.courseid = :courseid "; $params['courseid'] = $courseid; $rs = $DB->get_recordset_sql($sql, $params); foreach ($rs as $usergroup) { $usergroups[$usergroup->userid][$usergroup->id] = $usergroup; } $rs->close(); foreach ($potentialmembersids as $userid) { if (isset($usergroups[$userid])) { $usergrouplist = html_writer::start_tag('ul'); foreach ($usergroups[$userid] as $groupitem) { $usergrouplist .= html_writer::tag('li', format_string($groupitem->name)); } $usergrouplist .= html_writer::end_tag('ul'); } else { $usergrouplist = ''; } $usersummaries[] = $usergrouplist; } } return $usersummaries; }
[ "public", "function", "get_user_summaries", "(", "$", "courseid", ")", "{", "global", "$", "DB", ";", "$", "usersummaries", "=", "array", "(", ")", ";", "// Get other groups user already belongs to.", "$", "usergroups", "=", "array", "(", ")", ";", "$", "potentialmembersids", "=", "$", "this", "->", "potentialmembersids", ";", "if", "(", "empty", "(", "$", "potentialmembersids", ")", "==", "false", ")", "{", "list", "(", "$", "membersidsclause", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "potentialmembersids", ",", "SQL_PARAMS_NAMED", ",", "'pm'", ")", ";", "$", "sql", "=", "\"SELECT u.id AS userid, g.*\n FROM {user} u\n JOIN {groups_members} gm ON u.id = gm.userid\n JOIN {groups} g ON gm.groupid = g.id\n WHERE u.id $membersidsclause AND g.courseid = :courseid \"", ";", "$", "params", "[", "'courseid'", "]", "=", "$", "courseid", ";", "$", "rs", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "foreach", "(", "$", "rs", "as", "$", "usergroup", ")", "{", "$", "usergroups", "[", "$", "usergroup", "->", "userid", "]", "[", "$", "usergroup", "->", "id", "]", "=", "$", "usergroup", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "foreach", "(", "$", "potentialmembersids", "as", "$", "userid", ")", "{", "if", "(", "isset", "(", "$", "usergroups", "[", "$", "userid", "]", ")", ")", "{", "$", "usergrouplist", "=", "html_writer", "::", "start_tag", "(", "'ul'", ")", ";", "foreach", "(", "$", "usergroups", "[", "$", "userid", "]", "as", "$", "groupitem", ")", "{", "$", "usergrouplist", ".=", "html_writer", "::", "tag", "(", "'li'", ",", "format_string", "(", "$", "groupitem", "->", "name", ")", ")", ";", "}", "$", "usergrouplist", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "}", "else", "{", "$", "usergrouplist", "=", "''", ";", "}", "$", "usersummaries", "[", "]", "=", "$", "usergrouplist", ";", "}", "}", "return", "$", "usersummaries", ";", "}" ]
Construct HTML lists of group-memberships of the current set of users. Used in user/selector/search.php to repopulate the userSummaries JS global that is created in self::print_user_summaries() above. @param int $courseid The course @return string[] Array of HTML lists of groups.
[ "Construct", "HTML", "lists", "of", "group", "-", "memberships", "of", "the", "current", "set", "of", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/selector/lib.php#L829-L865
219,257
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.deleteFileAndChunksById
public function deleteFileAndChunksById($id) { $this->filesCollection->deleteOne(['_id' => $id]); $this->chunksCollection->deleteMany(['files_id' => $id]); }
php
public function deleteFileAndChunksById($id) { $this->filesCollection->deleteOne(['_id' => $id]); $this->chunksCollection->deleteMany(['files_id' => $id]); }
[ "public", "function", "deleteFileAndChunksById", "(", "$", "id", ")", "{", "$", "this", "->", "filesCollection", "->", "deleteOne", "(", "[", "'_id'", "=>", "$", "id", "]", ")", ";", "$", "this", "->", "chunksCollection", "->", "deleteMany", "(", "[", "'files_id'", "=>", "$", "id", "]", ")", ";", "}" ]
Deletes a GridFS file and related chunks by ID. @param mixed $id
[ "Deletes", "a", "GridFS", "file", "and", "related", "chunks", "by", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L74-L78
219,258
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.findFileByFilenameAndRevision
public function findFileByFilenameAndRevision($filename, $revision) { $filename = (string) $filename; $revision = (integer) $revision; if ($revision < 0) { $skip = abs($revision) - 1; $sortOrder = -1; } else { $skip = $revision; $sortOrder = 1; } return $this->filesCollection->findOne( ['filename' => $filename], [ 'skip' => $skip, 'sort' => ['uploadDate' => $sortOrder], 'typeMap' => ['root' => 'stdClass'], ] ); }
php
public function findFileByFilenameAndRevision($filename, $revision) { $filename = (string) $filename; $revision = (integer) $revision; if ($revision < 0) { $skip = abs($revision) - 1; $sortOrder = -1; } else { $skip = $revision; $sortOrder = 1; } return $this->filesCollection->findOne( ['filename' => $filename], [ 'skip' => $skip, 'sort' => ['uploadDate' => $sortOrder], 'typeMap' => ['root' => 'stdClass'], ] ); }
[ "public", "function", "findFileByFilenameAndRevision", "(", "$", "filename", ",", "$", "revision", ")", "{", "$", "filename", "=", "(", "string", ")", "$", "filename", ";", "$", "revision", "=", "(", "integer", ")", "$", "revision", ";", "if", "(", "$", "revision", "<", "0", ")", "{", "$", "skip", "=", "abs", "(", "$", "revision", ")", "-", "1", ";", "$", "sortOrder", "=", "-", "1", ";", "}", "else", "{", "$", "skip", "=", "$", "revision", ";", "$", "sortOrder", "=", "1", ";", "}", "return", "$", "this", "->", "filesCollection", "->", "findOne", "(", "[", "'filename'", "=>", "$", "filename", "]", ",", "[", "'skip'", "=>", "$", "skip", ",", "'sort'", "=>", "[", "'uploadDate'", "=>", "$", "sortOrder", "]", ",", "'typeMap'", "=>", "[", "'root'", "=>", "'stdClass'", "]", ",", "]", ")", ";", "}" ]
Finds a GridFS file document for a given filename and revision. Revision numbers are defined as follows: * 0 = the original stored file * 1 = the first revision * 2 = the second revision * etc… * -2 = the second most recent revision * -1 = the most recent revision @see Bucket::downloadToStreamByName() @see Bucket::openDownloadStreamByName() @param string $filename @param integer $revision @return stdClass|null
[ "Finds", "a", "GridFS", "file", "document", "for", "a", "given", "filename", "and", "revision", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L128-L149
219,259
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.insertChunk
public function insertChunk($chunk) { if ( ! $this->checkedIndexes) { $this->ensureIndexes(); } $this->chunksCollection->insertOne($chunk); }
php
public function insertChunk($chunk) { if ( ! $this->checkedIndexes) { $this->ensureIndexes(); } $this->chunksCollection->insertOne($chunk); }
[ "public", "function", "insertChunk", "(", "$", "chunk", ")", "{", "if", "(", "!", "$", "this", "->", "checkedIndexes", ")", "{", "$", "this", "->", "ensureIndexes", "(", ")", ";", "}", "$", "this", "->", "chunksCollection", "->", "insertOne", "(", "$", "chunk", ")", ";", "}" ]
Inserts a document into the chunks collection. @param array|object $chunk Chunk document
[ "Inserts", "a", "document", "into", "the", "chunks", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L235-L242
219,260
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.insertFile
public function insertFile($file) { if ( ! $this->checkedIndexes) { $this->ensureIndexes(); } $this->filesCollection->insertOne($file); }
php
public function insertFile($file) { if ( ! $this->checkedIndexes) { $this->ensureIndexes(); } $this->filesCollection->insertOne($file); }
[ "public", "function", "insertFile", "(", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "checkedIndexes", ")", "{", "$", "this", "->", "ensureIndexes", "(", ")", ";", "}", "$", "this", "->", "filesCollection", "->", "insertOne", "(", "$", "file", ")", ";", "}" ]
Inserts a document into the files collection. The file document should be inserted after all chunks have been inserted. @param array|object $file File document
[ "Inserts", "a", "document", "into", "the", "files", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L251-L258
219,261
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.ensureChunksIndex
private function ensureChunksIndex() { foreach ($this->chunksCollection->listIndexes() as $index) { if ($index->isUnique() && $index->getKey() === ['files_id' => 1, 'n' => 1]) { return; } } $this->chunksCollection->createIndex(['files_id' => 1, 'n' => 1], ['unique' => true]); }
php
private function ensureChunksIndex() { foreach ($this->chunksCollection->listIndexes() as $index) { if ($index->isUnique() && $index->getKey() === ['files_id' => 1, 'n' => 1]) { return; } } $this->chunksCollection->createIndex(['files_id' => 1, 'n' => 1], ['unique' => true]); }
[ "private", "function", "ensureChunksIndex", "(", ")", "{", "foreach", "(", "$", "this", "->", "chunksCollection", "->", "listIndexes", "(", ")", "as", "$", "index", ")", "{", "if", "(", "$", "index", "->", "isUnique", "(", ")", "&&", "$", "index", "->", "getKey", "(", ")", "===", "[", "'files_id'", "=>", "1", ",", "'n'", "=>", "1", "]", ")", "{", "return", ";", "}", "}", "$", "this", "->", "chunksCollection", "->", "createIndex", "(", "[", "'files_id'", "=>", "1", ",", "'n'", "=>", "1", "]", ",", "[", "'unique'", "=>", "true", "]", ")", ";", "}" ]
Create an index on the chunks collection if it does not already exist.
[ "Create", "an", "index", "on", "the", "chunks", "collection", "if", "it", "does", "not", "already", "exist", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L278-L287
219,262
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.ensureFilesIndex
private function ensureFilesIndex() { foreach ($this->filesCollection->listIndexes() as $index) { if ($index->getKey() === ['filename' => 1, 'uploadDate' => 1]) { return; } } $this->filesCollection->createIndex(['filename' => 1, 'uploadDate' => 1]); }
php
private function ensureFilesIndex() { foreach ($this->filesCollection->listIndexes() as $index) { if ($index->getKey() === ['filename' => 1, 'uploadDate' => 1]) { return; } } $this->filesCollection->createIndex(['filename' => 1, 'uploadDate' => 1]); }
[ "private", "function", "ensureFilesIndex", "(", ")", "{", "foreach", "(", "$", "this", "->", "filesCollection", "->", "listIndexes", "(", ")", "as", "$", "index", ")", "{", "if", "(", "$", "index", "->", "getKey", "(", ")", "===", "[", "'filename'", "=>", "1", ",", "'uploadDate'", "=>", "1", "]", ")", "{", "return", ";", "}", "}", "$", "this", "->", "filesCollection", "->", "createIndex", "(", "[", "'filename'", "=>", "1", ",", "'uploadDate'", "=>", "1", "]", ")", ";", "}" ]
Create an index on the files collection if it does not already exist.
[ "Create", "an", "index", "on", "the", "files", "collection", "if", "it", "does", "not", "already", "exist", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L292-L301
219,263
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php
CollectionWrapper.ensureIndexes
private function ensureIndexes() { if ($this->checkedIndexes) { return; } $this->checkedIndexes = true; if ( ! $this->isFilesCollectionEmpty()) { return; } $this->ensureFilesIndex(); $this->ensureChunksIndex(); }
php
private function ensureIndexes() { if ($this->checkedIndexes) { return; } $this->checkedIndexes = true; if ( ! $this->isFilesCollectionEmpty()) { return; } $this->ensureFilesIndex(); $this->ensureChunksIndex(); }
[ "private", "function", "ensureIndexes", "(", ")", "{", "if", "(", "$", "this", "->", "checkedIndexes", ")", "{", "return", ";", "}", "$", "this", "->", "checkedIndexes", "=", "true", ";", "if", "(", "!", "$", "this", "->", "isFilesCollectionEmpty", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "ensureFilesIndex", "(", ")", ";", "$", "this", "->", "ensureChunksIndex", "(", ")", ";", "}" ]
Ensure indexes on the files and chunks collections exist. This method is called once before the first write operation on a GridFS bucket. Indexes are only be created if the files collection is empty.
[ "Ensure", "indexes", "on", "the", "files", "and", "chunks", "collections", "exist", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/CollectionWrapper.php#L309-L323
219,264
moodle/moodle
badges/related_form.php
edit_relatedbadge_form.get_badges_option
public function get_badges_option($badge) { global $DB; $sql = "SELECT b.id, b.name, b.version, b.language, b.type FROM {badge} b WHERE b.id <> :badgeid AND b.id NOT IN ( SELECT DISTINCT b.id FROM {badge_related} br JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id) WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)"; $params = ['badgeid' => $badge->id, 'badgeid2' => $badge->id, 'badgeid3' => $badge->id, 'badgeid4' => $badge->id]; if ($badge->type == BADGE_TYPE_COURSE) { $sql .= " AND (b.courseid = :courseid OR b.type = :badgetype)"; $params['courseid'] = $badge->courseid; $params['badgetype'] = BADGE_TYPE_SITE; } $records = $DB->get_records_sql($sql, $params); $languages = get_string_manager()->get_list_of_languages(); $options = array(); foreach ($records as $record) { $language = isset($languages[$record->language]) ? $languages[$record->language] : ''; $options[$record->id] = $record->name . ' (version: ' . $record->version . ', language: ' . $language . ', ' . ($record->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')) . ')'; } return $options; }
php
public function get_badges_option($badge) { global $DB; $sql = "SELECT b.id, b.name, b.version, b.language, b.type FROM {badge} b WHERE b.id <> :badgeid AND b.id NOT IN ( SELECT DISTINCT b.id FROM {badge_related} br JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id) WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)"; $params = ['badgeid' => $badge->id, 'badgeid2' => $badge->id, 'badgeid3' => $badge->id, 'badgeid4' => $badge->id]; if ($badge->type == BADGE_TYPE_COURSE) { $sql .= " AND (b.courseid = :courseid OR b.type = :badgetype)"; $params['courseid'] = $badge->courseid; $params['badgetype'] = BADGE_TYPE_SITE; } $records = $DB->get_records_sql($sql, $params); $languages = get_string_manager()->get_list_of_languages(); $options = array(); foreach ($records as $record) { $language = isset($languages[$record->language]) ? $languages[$record->language] : ''; $options[$record->id] = $record->name . ' (version: ' . $record->version . ', language: ' . $language . ', ' . ($record->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')) . ')'; } return $options; }
[ "public", "function", "get_badges_option", "(", "$", "badge", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT b.id, b.name, b.version, b.language, b.type\n FROM {badge} b\n WHERE b.id <> :badgeid\n AND b.id NOT IN (\n SELECT DISTINCT b.id\n FROM {badge_related} br\n JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)\n WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)\"", ";", "$", "params", "=", "[", "'badgeid'", "=>", "$", "badge", "->", "id", ",", "'badgeid2'", "=>", "$", "badge", "->", "id", ",", "'badgeid3'", "=>", "$", "badge", "->", "id", ",", "'badgeid4'", "=>", "$", "badge", "->", "id", "]", ";", "if", "(", "$", "badge", "->", "type", "==", "BADGE_TYPE_COURSE", ")", "{", "$", "sql", ".=", "\" AND (b.courseid = :courseid OR b.type = :badgetype)\"", ";", "$", "params", "[", "'courseid'", "]", "=", "$", "badge", "->", "courseid", ";", "$", "params", "[", "'badgetype'", "]", "=", "BADGE_TYPE_SITE", ";", "}", "$", "records", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "languages", "=", "get_string_manager", "(", ")", "->", "get_list_of_languages", "(", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "language", "=", "isset", "(", "$", "languages", "[", "$", "record", "->", "language", "]", ")", "?", "$", "languages", "[", "$", "record", "->", "language", "]", ":", "''", ";", "$", "options", "[", "$", "record", "->", "id", "]", "=", "$", "record", "->", "name", ".", "' (version: '", ".", "$", "record", "->", "version", ".", "', language: '", ".", "$", "language", ".", "', '", ".", "(", "$", "record", "->", "type", "==", "BADGE_TYPE_COURSE", "?", "get_string", "(", "'badgesview'", ",", "'badges'", ")", ":", "get_string", "(", "'sitebadges'", ",", "'badges'", ")", ")", ".", "')'", ";", "}", "return", "$", "options", ";", "}" ]
Return list badge of a course or list badge site. @param object $badge Badge object. @return array $options An array the badges.
[ "Return", "list", "badge", "of", "a", "course", "or", "list", "badge", "site", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/related_form.php#L80-L108
219,265
moodle/moodle
lib/form/modgrade.php
MoodleQuickForm_modgrade.exportValue
public function exportValue(&$submitvalues, $notused = false) { global $COURSE; // Get the values from all the child elements. $vals = array(); foreach ($this->_elements as $element) { $thisexport = $element->exportValue($submitvalues[$this->getName()], true); if (!is_null($thisexport)) { $vals += $thisexport; } } $type = (isset($vals['modgrade_type'])) ? $vals['modgrade_type'] : 'none'; $point = (isset($vals['modgrade_point'])) ? $vals['modgrade_point'] : null; $scale = (isset($vals['modgrade_scale'])) ? $vals['modgrade_scale'] : null; $rescalegrades = (isset($vals['modgrade_rescalegrades'])) ? $vals['modgrade_rescalegrades'] : null; $return = $this->process_value($type, $scale, $point, $rescalegrades); return array($this->getName() => $return, $this->getName() . '_rescalegrades' => $rescalegrades); }
php
public function exportValue(&$submitvalues, $notused = false) { global $COURSE; // Get the values from all the child elements. $vals = array(); foreach ($this->_elements as $element) { $thisexport = $element->exportValue($submitvalues[$this->getName()], true); if (!is_null($thisexport)) { $vals += $thisexport; } } $type = (isset($vals['modgrade_type'])) ? $vals['modgrade_type'] : 'none'; $point = (isset($vals['modgrade_point'])) ? $vals['modgrade_point'] : null; $scale = (isset($vals['modgrade_scale'])) ? $vals['modgrade_scale'] : null; $rescalegrades = (isset($vals['modgrade_rescalegrades'])) ? $vals['modgrade_rescalegrades'] : null; $return = $this->process_value($type, $scale, $point, $rescalegrades); return array($this->getName() => $return, $this->getName() . '_rescalegrades' => $rescalegrades); }
[ "public", "function", "exportValue", "(", "&", "$", "submitvalues", ",", "$", "notused", "=", "false", ")", "{", "global", "$", "COURSE", ";", "// Get the values from all the child elements.", "$", "vals", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_elements", "as", "$", "element", ")", "{", "$", "thisexport", "=", "$", "element", "->", "exportValue", "(", "$", "submitvalues", "[", "$", "this", "->", "getName", "(", ")", "]", ",", "true", ")", ";", "if", "(", "!", "is_null", "(", "$", "thisexport", ")", ")", "{", "$", "vals", "+=", "$", "thisexport", ";", "}", "}", "$", "type", "=", "(", "isset", "(", "$", "vals", "[", "'modgrade_type'", "]", ")", ")", "?", "$", "vals", "[", "'modgrade_type'", "]", ":", "'none'", ";", "$", "point", "=", "(", "isset", "(", "$", "vals", "[", "'modgrade_point'", "]", ")", ")", "?", "$", "vals", "[", "'modgrade_point'", "]", ":", "null", ";", "$", "scale", "=", "(", "isset", "(", "$", "vals", "[", "'modgrade_scale'", "]", ")", ")", "?", "$", "vals", "[", "'modgrade_scale'", "]", ":", "null", ";", "$", "rescalegrades", "=", "(", "isset", "(", "$", "vals", "[", "'modgrade_rescalegrades'", "]", ")", ")", "?", "$", "vals", "[", "'modgrade_rescalegrades'", "]", ":", "null", ";", "$", "return", "=", "$", "this", "->", "process_value", "(", "$", "type", ",", "$", "scale", ",", "$", "point", ",", "$", "rescalegrades", ")", ";", "return", "array", "(", "$", "this", "->", "getName", "(", ")", "=>", "$", "return", ",", "$", "this", "->", "getName", "(", ")", ".", "'_rescalegrades'", "=>", "$", "rescalegrades", ")", ";", "}" ]
Calculate the output value for the element as a whole. @param array $submitvalues The incoming values from the form. @param bool $notused Not used. @return array Return value for the element, formatted like field name => value.
[ "Calculate", "the", "output", "value", "for", "the", "element", "as", "a", "whole", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/modgrade.php#L255-L274
219,266
moodle/moodle
lib/form/modgrade.php
MoodleQuickForm_modgrade.process_value
protected function process_value($type='none', $scale=null, $point=null, $rescalegrades=null) { global $COURSE; $val = 0; if ($this->isupdate && $this->hasgrades && $this->canrescale && $this->currentgradetype == 'point' && empty($rescalegrades)) { // If the maxgrade field is disabled with javascript, no value is sent with the form and mform assumes the default. // If the user was forced to choose a rescale option - and they haven't - prevent any changes to the max grade. return (string)unformat_float($this->currentgrade); } switch ($type) { case 'point': if ($this->validate_point($point) === true) { $val = (int)$point; } break; case 'scale': if ($this->validate_scale($scale)) { $val = (int)(-$scale); } break; } return $val; }
php
protected function process_value($type='none', $scale=null, $point=null, $rescalegrades=null) { global $COURSE; $val = 0; if ($this->isupdate && $this->hasgrades && $this->canrescale && $this->currentgradetype == 'point' && empty($rescalegrades)) { // If the maxgrade field is disabled with javascript, no value is sent with the form and mform assumes the default. // If the user was forced to choose a rescale option - and they haven't - prevent any changes to the max grade. return (string)unformat_float($this->currentgrade); } switch ($type) { case 'point': if ($this->validate_point($point) === true) { $val = (int)$point; } break; case 'scale': if ($this->validate_scale($scale)) { $val = (int)(-$scale); } break; } return $val; }
[ "protected", "function", "process_value", "(", "$", "type", "=", "'none'", ",", "$", "scale", "=", "null", ",", "$", "point", "=", "null", ",", "$", "rescalegrades", "=", "null", ")", "{", "global", "$", "COURSE", ";", "$", "val", "=", "0", ";", "if", "(", "$", "this", "->", "isupdate", "&&", "$", "this", "->", "hasgrades", "&&", "$", "this", "->", "canrescale", "&&", "$", "this", "->", "currentgradetype", "==", "'point'", "&&", "empty", "(", "$", "rescalegrades", ")", ")", "{", "// If the maxgrade field is disabled with javascript, no value is sent with the form and mform assumes the default.", "// If the user was forced to choose a rescale option - and they haven't - prevent any changes to the max grade.", "return", "(", "string", ")", "unformat_float", "(", "$", "this", "->", "currentgrade", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'point'", ":", "if", "(", "$", "this", "->", "validate_point", "(", "$", "point", ")", "===", "true", ")", "{", "$", "val", "=", "(", "int", ")", "$", "point", ";", "}", "break", ";", "case", "'scale'", ":", "if", "(", "$", "this", "->", "validate_scale", "(", "$", "scale", ")", ")", "{", "$", "val", "=", "(", "int", ")", "(", "-", "$", "scale", ")", ";", "}", "break", ";", "}", "return", "$", "val", ";", "}" ]
Process the value for the group based on the selected grade type, and the input for the scale and point elements. @param string $type The value of the grade type select box. Can be 'none', 'scale', or 'point' @param string|int $scale The value of the scale select box. @param string|int $point The value of the point grade textbox. @param string $rescalegrades The value of the rescalegrades select. @return int The resulting value
[ "Process", "the", "value", "for", "the", "group", "based", "on", "the", "selected", "grade", "type", "and", "the", "input", "for", "the", "scale", "and", "point", "elements", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/modgrade.php#L285-L307
219,267
moodle/moodle
lib/form/modgrade.php
MoodleQuickForm_modgrade.validate_scale
protected function validate_scale($val) { global $COURSE; $scales = get_scales_menu($COURSE->id); return (!empty($val) && isset($scales[(int)$val])) ? true : false; }
php
protected function validate_scale($val) { global $COURSE; $scales = get_scales_menu($COURSE->id); return (!empty($val) && isset($scales[(int)$val])) ? true : false; }
[ "protected", "function", "validate_scale", "(", "$", "val", ")", "{", "global", "$", "COURSE", ";", "$", "scales", "=", "get_scales_menu", "(", "$", "COURSE", "->", "id", ")", ";", "return", "(", "!", "empty", "(", "$", "val", ")", "&&", "isset", "(", "$", "scales", "[", "(", "int", ")", "$", "val", "]", ")", ")", "?", "true", ":", "false", ";", "}" ]
Determines whether a given value is a valid scale selection. @param string|int $val The value to test. @return bool Valid or invalid
[ "Determines", "whether", "a", "given", "value", "is", "a", "valid", "scale", "selection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/modgrade.php#L315-L319
219,268
moodle/moodle
lib/form/modgrade.php
MoodleQuickForm_modgrade.validate_point
protected function validate_point($val) { if (empty($val)) { return false; } $maxgrade = (int)get_config('core', 'gradepointmax'); $isintlike = ((string)(int)$val === $val) ? true : false; return ($isintlike === true && $val > 0 && $val <= $maxgrade) ? true : false; }
php
protected function validate_point($val) { if (empty($val)) { return false; } $maxgrade = (int)get_config('core', 'gradepointmax'); $isintlike = ((string)(int)$val === $val) ? true : false; return ($isintlike === true && $val > 0 && $val <= $maxgrade) ? true : false; }
[ "protected", "function", "validate_point", "(", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "val", ")", ")", "{", "return", "false", ";", "}", "$", "maxgrade", "=", "(", "int", ")", "get_config", "(", "'core'", ",", "'gradepointmax'", ")", ";", "$", "isintlike", "=", "(", "(", "string", ")", "(", "int", ")", "$", "val", "===", "$", "val", ")", "?", "true", ":", "false", ";", "return", "(", "$", "isintlike", "===", "true", "&&", "$", "val", ">", "0", "&&", "$", "val", "<=", "$", "maxgrade", ")", "?", "true", ":", "false", ";", "}" ]
Determines whether a given value is a valid point selection. @param string|int $val The value to test. @return bool Valid or invalid
[ "Determines", "whether", "a", "given", "value", "is", "a", "valid", "point", "selection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/modgrade.php#L327-L334
219,269
moodle/moodle
lib/form/modgrade.php
MoodleQuickForm_modgrade.generate_modgrade_subelement_id
protected function generate_modgrade_subelement_id($subname) { $gid = str_replace(array('[', ']'), array('_', ''), $this->getName()); return clean_param('id_'.$gid.'_'.$subname, PARAM_ALPHANUMEXT); }
php
protected function generate_modgrade_subelement_id($subname) { $gid = str_replace(array('[', ']'), array('_', ''), $this->getName()); return clean_param('id_'.$gid.'_'.$subname, PARAM_ALPHANUMEXT); }
[ "protected", "function", "generate_modgrade_subelement_id", "(", "$", "subname", ")", "{", "$", "gid", "=", "str_replace", "(", "array", "(", "'['", ",", "']'", ")", ",", "array", "(", "'_'", ",", "''", ")", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "return", "clean_param", "(", "'id_'", ".", "$", "gid", ".", "'_'", ".", "$", "subname", ",", "PARAM_ALPHANUMEXT", ")", ";", "}" ]
Generates the id attribute for the subelement of the modgrade group. Uses algorithm similar to what {@link HTML_QuickForm_element::_generateId()} does but takes the name of the wrapping modgrade group into account. @param string $subname the name of the HTML_QuickForm_element in this modgrade group @return string
[ "Generates", "the", "id", "attribute", "for", "the", "subelement", "of", "the", "modgrade", "group", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/modgrade.php#L532-L535
219,270
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.management_heading
public function management_heading($heading, $viewmode = null, $categoryid = null) { $html = html_writer::start_div('coursecat-management-header clearfix'); if (!empty($heading)) { $html .= $this->heading($heading); } if ($viewmode !== null) { $html .= html_writer::start_div(); $html .= $this->view_mode_selector(\core_course\management\helper::get_management_viewmodes(), $viewmode); if ($viewmode === 'courses') { $categories = core_course_category::make_categories_list(array('moodle/category:manage', 'moodle/course:create')); $nothing = false; if ($categoryid === null) { $nothing = array('' => get_string('selectacategory')); $categoryid = ''; } $select = new single_select($this->page->url, 'categoryid', $categories, $categoryid, $nothing); $html .= $this->render($select); } $html .= html_writer::end_div(); } $html .= html_writer::end_div(); return $html; }
php
public function management_heading($heading, $viewmode = null, $categoryid = null) { $html = html_writer::start_div('coursecat-management-header clearfix'); if (!empty($heading)) { $html .= $this->heading($heading); } if ($viewmode !== null) { $html .= html_writer::start_div(); $html .= $this->view_mode_selector(\core_course\management\helper::get_management_viewmodes(), $viewmode); if ($viewmode === 'courses') { $categories = core_course_category::make_categories_list(array('moodle/category:manage', 'moodle/course:create')); $nothing = false; if ($categoryid === null) { $nothing = array('' => get_string('selectacategory')); $categoryid = ''; } $select = new single_select($this->page->url, 'categoryid', $categories, $categoryid, $nothing); $html .= $this->render($select); } $html .= html_writer::end_div(); } $html .= html_writer::end_div(); return $html; }
[ "public", "function", "management_heading", "(", "$", "heading", ",", "$", "viewmode", "=", "null", ",", "$", "categoryid", "=", "null", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'coursecat-management-header clearfix'", ")", ";", "if", "(", "!", "empty", "(", "$", "heading", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "heading", "(", "$", "heading", ")", ";", "}", "if", "(", "$", "viewmode", "!==", "null", ")", "{", "$", "html", ".=", "html_writer", "::", "start_div", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "view_mode_selector", "(", "\\", "core_course", "\\", "management", "\\", "helper", "::", "get_management_viewmodes", "(", ")", ",", "$", "viewmode", ")", ";", "if", "(", "$", "viewmode", "===", "'courses'", ")", "{", "$", "categories", "=", "core_course_category", "::", "make_categories_list", "(", "array", "(", "'moodle/category:manage'", ",", "'moodle/course:create'", ")", ")", ";", "$", "nothing", "=", "false", ";", "if", "(", "$", "categoryid", "===", "null", ")", "{", "$", "nothing", "=", "array", "(", "''", "=>", "get_string", "(", "'selectacategory'", ")", ")", ";", "$", "categoryid", "=", "''", ";", "}", "$", "select", "=", "new", "single_select", "(", "$", "this", "->", "page", "->", "url", ",", "'categoryid'", ",", "$", "categories", ",", "$", "categoryid", ",", "$", "nothing", ")", ";", "$", "html", ".=", "$", "this", "->", "render", "(", "$", "select", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Displays a heading for the management pages. @param string $heading The heading to display @param string|null $viewmode The current view mode if there are options. @param int|null $categoryid The currently selected category if there is one. @return string
[ "Displays", "a", "heading", "for", "the", "management", "pages", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L72-L94
219,271
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.management_form_start
public function management_form_start() { $form = array('action' => $this->page->url->out(), 'method' => 'POST', 'id' => 'coursecat-management'); $html = html_writer::start_tag('form', $form); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'bulkaction')); return $html; }
php
public function management_form_start() { $form = array('action' => $this->page->url->out(), 'method' => 'POST', 'id' => 'coursecat-management'); $html = html_writer::start_tag('form', $form); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'bulkaction')); return $html; }
[ "public", "function", "management_form_start", "(", ")", "{", "$", "form", "=", "array", "(", "'action'", "=>", "$", "this", "->", "page", "->", "url", "->", "out", "(", ")", ",", "'method'", "=>", "'POST'", ",", "'id'", "=>", "'coursecat-management'", ")", ";", "$", "html", "=", "html_writer", "::", "start_tag", "(", "'form'", ",", "$", "form", ")", ";", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'sesskey'", ",", "'value'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'action'", ",", "'value'", "=>", "'bulkaction'", ")", ")", ";", "return", "$", "html", ";", "}" ]
Prepares the form element for the course category listing bulk actions. @return string
[ "Prepares", "the", "form", "element", "for", "the", "course", "category", "listing", "bulk", "actions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L101-L108
219,272
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.category_listing
public function category_listing(core_course_category $category = null) { if ($category === null) { $selectedparents = array(); $selectedcategory = null; } else { $selectedparents = $category->get_parents(); $selectedparents[] = $category->id; $selectedcategory = $category->id; } $catatlevel = \core_course\management\helper::get_expanded_categories(''); $catatlevel[] = array_shift($selectedparents); $catatlevel = array_unique($catatlevel); $listing = core_course_category::top()->get_children(); $attributes = array( 'class' => 'ml-1 list-unstyled', 'role' => 'tree', 'aria-labelledby' => 'category-listing-title' ); $html = html_writer::start_div('category-listing card w-100'); $html .= html_writer::tag('h3', get_string('categories'), array('class' => 'card-header', 'id' => 'category-listing-title')); $html .= html_writer::start_div('card-body'); $html .= $this->category_listing_actions($category); $html .= html_writer::start_tag('ul', $attributes); foreach ($listing as $listitem) { // Render each category in the listing. $subcategories = array(); if (in_array($listitem->id, $catatlevel)) { $subcategories = $listitem->get_children(); } $html .= $this->category_listitem( $listitem, $subcategories, $listitem->get_children_count(), $selectedcategory, $selectedparents ); } $html .= html_writer::end_tag('ul'); $html .= $this->category_bulk_actions($category); $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
php
public function category_listing(core_course_category $category = null) { if ($category === null) { $selectedparents = array(); $selectedcategory = null; } else { $selectedparents = $category->get_parents(); $selectedparents[] = $category->id; $selectedcategory = $category->id; } $catatlevel = \core_course\management\helper::get_expanded_categories(''); $catatlevel[] = array_shift($selectedparents); $catatlevel = array_unique($catatlevel); $listing = core_course_category::top()->get_children(); $attributes = array( 'class' => 'ml-1 list-unstyled', 'role' => 'tree', 'aria-labelledby' => 'category-listing-title' ); $html = html_writer::start_div('category-listing card w-100'); $html .= html_writer::tag('h3', get_string('categories'), array('class' => 'card-header', 'id' => 'category-listing-title')); $html .= html_writer::start_div('card-body'); $html .= $this->category_listing_actions($category); $html .= html_writer::start_tag('ul', $attributes); foreach ($listing as $listitem) { // Render each category in the listing. $subcategories = array(); if (in_array($listitem->id, $catatlevel)) { $subcategories = $listitem->get_children(); } $html .= $this->category_listitem( $listitem, $subcategories, $listitem->get_children_count(), $selectedcategory, $selectedparents ); } $html .= html_writer::end_tag('ul'); $html .= $this->category_bulk_actions($category); $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "category_listing", "(", "core_course_category", "$", "category", "=", "null", ")", "{", "if", "(", "$", "category", "===", "null", ")", "{", "$", "selectedparents", "=", "array", "(", ")", ";", "$", "selectedcategory", "=", "null", ";", "}", "else", "{", "$", "selectedparents", "=", "$", "category", "->", "get_parents", "(", ")", ";", "$", "selectedparents", "[", "]", "=", "$", "category", "->", "id", ";", "$", "selectedcategory", "=", "$", "category", "->", "id", ";", "}", "$", "catatlevel", "=", "\\", "core_course", "\\", "management", "\\", "helper", "::", "get_expanded_categories", "(", "''", ")", ";", "$", "catatlevel", "[", "]", "=", "array_shift", "(", "$", "selectedparents", ")", ";", "$", "catatlevel", "=", "array_unique", "(", "$", "catatlevel", ")", ";", "$", "listing", "=", "core_course_category", "::", "top", "(", ")", "->", "get_children", "(", ")", ";", "$", "attributes", "=", "array", "(", "'class'", "=>", "'ml-1 list-unstyled'", ",", "'role'", "=>", "'tree'", ",", "'aria-labelledby'", "=>", "'category-listing-title'", ")", ";", "$", "html", "=", "html_writer", "::", "start_div", "(", "'category-listing card w-100'", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'h3'", ",", "get_string", "(", "'categories'", ")", ",", "array", "(", "'class'", "=>", "'card-header'", ",", "'id'", "=>", "'category-listing-title'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'card-body'", ")", ";", "$", "html", ".=", "$", "this", "->", "category_listing_actions", "(", "$", "category", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'ul'", ",", "$", "attributes", ")", ";", "foreach", "(", "$", "listing", "as", "$", "listitem", ")", "{", "// Render each category in the listing.", "$", "subcategories", "=", "array", "(", ")", ";", "if", "(", "in_array", "(", "$", "listitem", "->", "id", ",", "$", "catatlevel", ")", ")", "{", "$", "subcategories", "=", "$", "listitem", "->", "get_children", "(", ")", ";", "}", "$", "html", ".=", "$", "this", "->", "category_listitem", "(", "$", "listitem", ",", "$", "subcategories", ",", "$", "listitem", "->", "get_children_count", "(", ")", ",", "$", "selectedcategory", ",", "$", "selectedparents", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "$", "html", ".=", "$", "this", "->", "category_bulk_actions", "(", "$", "category", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Presents a course category listing. @param core_course_category $category The currently selected category. Also the category to highlight in the listing. @return string
[ "Presents", "a", "course", "category", "listing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L125-L172
219,273
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.category_listing_actions
public function category_listing_actions(core_course_category $category = null) { $actions = array(); $cancreatecategory = $category && $category->can_create_subcategory(); $cancreatecategory = $cancreatecategory || core_course_category::can_create_top_level_category(); if ($category === null) { $category = core_course_category::top(); } if ($cancreatecategory) { $url = new moodle_url('/course/editcategory.php', array('parent' => $category->id)); $actions[] = html_writer::link($url, get_string('createnewcategory'), array('class' => 'btn btn-secondary')); } if (core_course_category::can_approve_course_requests()) { $actions[] = html_writer::link(new moodle_url('/course/pending.php'), get_string('coursespending')); } if (count($actions) === 0) { return ''; } return html_writer::div(join(' ', $actions), 'listing-actions category-listing-actions mb-3'); }
php
public function category_listing_actions(core_course_category $category = null) { $actions = array(); $cancreatecategory = $category && $category->can_create_subcategory(); $cancreatecategory = $cancreatecategory || core_course_category::can_create_top_level_category(); if ($category === null) { $category = core_course_category::top(); } if ($cancreatecategory) { $url = new moodle_url('/course/editcategory.php', array('parent' => $category->id)); $actions[] = html_writer::link($url, get_string('createnewcategory'), array('class' => 'btn btn-secondary')); } if (core_course_category::can_approve_course_requests()) { $actions[] = html_writer::link(new moodle_url('/course/pending.php'), get_string('coursespending')); } if (count($actions) === 0) { return ''; } return html_writer::div(join(' ', $actions), 'listing-actions category-listing-actions mb-3'); }
[ "public", "function", "category_listing_actions", "(", "core_course_category", "$", "category", "=", "null", ")", "{", "$", "actions", "=", "array", "(", ")", ";", "$", "cancreatecategory", "=", "$", "category", "&&", "$", "category", "->", "can_create_subcategory", "(", ")", ";", "$", "cancreatecategory", "=", "$", "cancreatecategory", "||", "core_course_category", "::", "can_create_top_level_category", "(", ")", ";", "if", "(", "$", "category", "===", "null", ")", "{", "$", "category", "=", "core_course_category", "::", "top", "(", ")", ";", "}", "if", "(", "$", "cancreatecategory", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "'/course/editcategory.php'", ",", "array", "(", "'parent'", "=>", "$", "category", "->", "id", ")", ")", ";", "$", "actions", "[", "]", "=", "html_writer", "::", "link", "(", "$", "url", ",", "get_string", "(", "'createnewcategory'", ")", ",", "array", "(", "'class'", "=>", "'btn btn-secondary'", ")", ")", ";", "}", "if", "(", "core_course_category", "::", "can_approve_course_requests", "(", ")", ")", "{", "$", "actions", "[", "]", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "'/course/pending.php'", ")", ",", "get_string", "(", "'coursespending'", ")", ")", ";", "}", "if", "(", "count", "(", "$", "actions", ")", "===", "0", ")", "{", "return", "''", ";", "}", "return", "html_writer", "::", "div", "(", "join", "(", "' '", ",", "$", "actions", ")", ",", "'listing-actions category-listing-actions mb-3'", ")", ";", "}" ]
Renderers the actions that are possible for the course category listing. These are not the actions associated with an individual category listing. That happens through category_listitem_actions. @param core_course_category $category @return string
[ "Renderers", "the", "actions", "that", "are", "possible", "for", "the", "course", "category", "listing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L324-L344
219,274
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.category_listitem_actions
public function category_listitem_actions(core_course_category $category, array $actions = null) { if ($actions === null) { $actions = \core_course\management\helper::get_category_listitem_actions($category); } $menu = new action_menu(); $menu->attributes['class'] .= ' category-item-actions item-actions'; $hasitems = false; foreach ($actions as $key => $action) { $hasitems = true; $menu->add(new action_menu_link( $action['url'], $action['icon'], $action['string'], in_array($key, array('show', 'hide', 'moveup', 'movedown')), array('data-action' => $key, 'class' => 'action-'.$key) )); } if (!$hasitems) { return ''; } return $this->render($menu); }
php
public function category_listitem_actions(core_course_category $category, array $actions = null) { if ($actions === null) { $actions = \core_course\management\helper::get_category_listitem_actions($category); } $menu = new action_menu(); $menu->attributes['class'] .= ' category-item-actions item-actions'; $hasitems = false; foreach ($actions as $key => $action) { $hasitems = true; $menu->add(new action_menu_link( $action['url'], $action['icon'], $action['string'], in_array($key, array('show', 'hide', 'moveup', 'movedown')), array('data-action' => $key, 'class' => 'action-'.$key) )); } if (!$hasitems) { return ''; } return $this->render($menu); }
[ "public", "function", "category_listitem_actions", "(", "core_course_category", "$", "category", ",", "array", "$", "actions", "=", "null", ")", "{", "if", "(", "$", "actions", "===", "null", ")", "{", "$", "actions", "=", "\\", "core_course", "\\", "management", "\\", "helper", "::", "get_category_listitem_actions", "(", "$", "category", ")", ";", "}", "$", "menu", "=", "new", "action_menu", "(", ")", ";", "$", "menu", "->", "attributes", "[", "'class'", "]", ".=", "' category-item-actions item-actions'", ";", "$", "hasitems", "=", "false", ";", "foreach", "(", "$", "actions", "as", "$", "key", "=>", "$", "action", ")", "{", "$", "hasitems", "=", "true", ";", "$", "menu", "->", "add", "(", "new", "action_menu_link", "(", "$", "action", "[", "'url'", "]", ",", "$", "action", "[", "'icon'", "]", ",", "$", "action", "[", "'string'", "]", ",", "in_array", "(", "$", "key", ",", "array", "(", "'show'", ",", "'hide'", ",", "'moveup'", ",", "'movedown'", ")", ")", ",", "array", "(", "'data-action'", "=>", "$", "key", ",", "'class'", "=>", "'action-'", ".", "$", "key", ")", ")", ")", ";", "}", "if", "(", "!", "$", "hasitems", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "render", "(", "$", "menu", ")", ";", "}" ]
Renderers the actions for individual category list items. @param core_course_category $category @param array $actions @return string
[ "Renderers", "the", "actions", "for", "individual", "category", "list", "items", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L353-L374
219,275
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_listing
public function course_listing(core_course_category $category = null, core_course_list_element $course = null, $page = 0, $perpage = 20, $viewmode = 'default') { if ($category === null) { $html = html_writer::start_div('select-a-category'); $html .= html_writer::tag('h3', get_string('courses'), array('id' => 'course-listing-title', 'tabindex' => '0')); $html .= $this->output->notification(get_string('selectacategory'), 'notifymessage'); $html .= html_writer::end_div(); return $html; } $page = max($page, 0); $perpage = max($perpage, 2); $totalcourses = $category->coursecount; $totalpages = ceil($totalcourses / $perpage); if ($page > $totalpages - 1) { $page = $totalpages - 1; } $options = array( 'offset' => $page * $perpage, 'limit' => $perpage ); $courseid = isset($course) ? $course->id : null; $class = ''; if ($page === 0) { $class .= ' firstpage'; } if ($page + 1 === (int)$totalpages) { $class .= ' lastpage'; } $html = html_writer::start_div('card course-listing w-100'.$class, array( 'data-category' => $category->id, 'data-page' => $page, 'data-totalpages' => $totalpages, 'data-totalcourses' => $totalcourses, 'data-canmoveoutof' => $category->can_move_courses_out_of() && $category->can_move_courses_into() )); $html .= html_writer::tag('h3', $category->get_formatted_name(), array('id' => 'course-listing-title', 'tabindex' => '0', 'class' => 'card-header')); $html .= html_writer::start_div('card-body'); $html .= $this->course_listing_actions($category, $course, $perpage); $html .= $this->listing_pagination($category, $page, $perpage, false, $viewmode); $html .= html_writer::start_tag('ul', array('class' => 'ml course-list', 'role' => 'group')); foreach ($category->get_courses($options) as $listitem) { $html .= $this->course_listitem($category, $listitem, $courseid); } $html .= html_writer::end_tag('ul'); $html .= $this->listing_pagination($category, $page, $perpage, true, $viewmode); $html .= $this->course_bulk_actions($category); $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
php
public function course_listing(core_course_category $category = null, core_course_list_element $course = null, $page = 0, $perpage = 20, $viewmode = 'default') { if ($category === null) { $html = html_writer::start_div('select-a-category'); $html .= html_writer::tag('h3', get_string('courses'), array('id' => 'course-listing-title', 'tabindex' => '0')); $html .= $this->output->notification(get_string('selectacategory'), 'notifymessage'); $html .= html_writer::end_div(); return $html; } $page = max($page, 0); $perpage = max($perpage, 2); $totalcourses = $category->coursecount; $totalpages = ceil($totalcourses / $perpage); if ($page > $totalpages - 1) { $page = $totalpages - 1; } $options = array( 'offset' => $page * $perpage, 'limit' => $perpage ); $courseid = isset($course) ? $course->id : null; $class = ''; if ($page === 0) { $class .= ' firstpage'; } if ($page + 1 === (int)$totalpages) { $class .= ' lastpage'; } $html = html_writer::start_div('card course-listing w-100'.$class, array( 'data-category' => $category->id, 'data-page' => $page, 'data-totalpages' => $totalpages, 'data-totalcourses' => $totalcourses, 'data-canmoveoutof' => $category->can_move_courses_out_of() && $category->can_move_courses_into() )); $html .= html_writer::tag('h3', $category->get_formatted_name(), array('id' => 'course-listing-title', 'tabindex' => '0', 'class' => 'card-header')); $html .= html_writer::start_div('card-body'); $html .= $this->course_listing_actions($category, $course, $perpage); $html .= $this->listing_pagination($category, $page, $perpage, false, $viewmode); $html .= html_writer::start_tag('ul', array('class' => 'ml course-list', 'role' => 'group')); foreach ($category->get_courses($options) as $listitem) { $html .= $this->course_listitem($category, $listitem, $courseid); } $html .= html_writer::end_tag('ul'); $html .= $this->listing_pagination($category, $page, $perpage, true, $viewmode); $html .= $this->course_bulk_actions($category); $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "course_listing", "(", "core_course_category", "$", "category", "=", "null", ",", "core_course_list_element", "$", "course", "=", "null", ",", "$", "page", "=", "0", ",", "$", "perpage", "=", "20", ",", "$", "viewmode", "=", "'default'", ")", "{", "if", "(", "$", "category", "===", "null", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'select-a-category'", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'h3'", ",", "get_string", "(", "'courses'", ")", ",", "array", "(", "'id'", "=>", "'course-listing-title'", ",", "'tabindex'", "=>", "'0'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "notification", "(", "get_string", "(", "'selectacategory'", ")", ",", "'notifymessage'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}", "$", "page", "=", "max", "(", "$", "page", ",", "0", ")", ";", "$", "perpage", "=", "max", "(", "$", "perpage", ",", "2", ")", ";", "$", "totalcourses", "=", "$", "category", "->", "coursecount", ";", "$", "totalpages", "=", "ceil", "(", "$", "totalcourses", "/", "$", "perpage", ")", ";", "if", "(", "$", "page", ">", "$", "totalpages", "-", "1", ")", "{", "$", "page", "=", "$", "totalpages", "-", "1", ";", "}", "$", "options", "=", "array", "(", "'offset'", "=>", "$", "page", "*", "$", "perpage", ",", "'limit'", "=>", "$", "perpage", ")", ";", "$", "courseid", "=", "isset", "(", "$", "course", ")", "?", "$", "course", "->", "id", ":", "null", ";", "$", "class", "=", "''", ";", "if", "(", "$", "page", "===", "0", ")", "{", "$", "class", ".=", "' firstpage'", ";", "}", "if", "(", "$", "page", "+", "1", "===", "(", "int", ")", "$", "totalpages", ")", "{", "$", "class", ".=", "' lastpage'", ";", "}", "$", "html", "=", "html_writer", "::", "start_div", "(", "'card course-listing w-100'", ".", "$", "class", ",", "array", "(", "'data-category'", "=>", "$", "category", "->", "id", ",", "'data-page'", "=>", "$", "page", ",", "'data-totalpages'", "=>", "$", "totalpages", ",", "'data-totalcourses'", "=>", "$", "totalcourses", ",", "'data-canmoveoutof'", "=>", "$", "category", "->", "can_move_courses_out_of", "(", ")", "&&", "$", "category", "->", "can_move_courses_into", "(", ")", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'h3'", ",", "$", "category", "->", "get_formatted_name", "(", ")", ",", "array", "(", "'id'", "=>", "'course-listing-title'", ",", "'tabindex'", "=>", "'0'", ",", "'class'", "=>", "'card-header'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'card-body'", ")", ";", "$", "html", ".=", "$", "this", "->", "course_listing_actions", "(", "$", "category", ",", "$", "course", ",", "$", "perpage", ")", ";", "$", "html", ".=", "$", "this", "->", "listing_pagination", "(", "$", "category", ",", "$", "page", ",", "$", "perpage", ",", "false", ",", "$", "viewmode", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "'ml course-list'", ",", "'role'", "=>", "'group'", ")", ")", ";", "foreach", "(", "$", "category", "->", "get_courses", "(", "$", "options", ")", "as", "$", "listitem", ")", "{", "$", "html", ".=", "$", "this", "->", "course_listitem", "(", "$", "category", ",", "$", "listitem", ",", "$", "courseid", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "$", "html", ".=", "$", "this", "->", "listing_pagination", "(", "$", "category", ",", "$", "page", ",", "$", "perpage", ",", "true", ",", "$", "viewmode", ")", ";", "$", "html", ".=", "$", "this", "->", "course_bulk_actions", "(", "$", "category", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Renders a course listing. @param core_course_category $category The currently selected category. This is what the listing is focused on. @param core_course_list_element $course The currently selected course. @param int $page The page being displayed. @param int $perpage The number of courses to display per page. @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'. @return string
[ "Renders", "a", "course", "listing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L494-L548
219,276
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.listing_pagination
protected function listing_pagination(core_course_category $category, $page, $perpage, $showtotals = false, $viewmode = 'default') { $html = ''; $totalcourses = $category->get_courses_count(); $totalpages = ceil($totalcourses / $perpage); if ($showtotals) { if ($totalpages == 0) { $str = get_string('nocoursesyet'); } else if ($totalpages == 1) { $str = get_string('showingacourses', 'moodle', $totalcourses); } else { $a = new stdClass; $a->start = ($page * $perpage) + 1; $a->end = min((($page + 1) * $perpage), $totalcourses); $a->total = $totalcourses; $str = get_string('showingxofycourses', 'moodle', $a); } $html .= html_writer::div($str, 'listing-pagination-totals dimmed'); } if ($viewmode !== 'default') { $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id, 'view' => $viewmode)); } else { $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id)); } $html .= $this->output->paging_bar($totalcourses, $page, $perpage, $baseurl); return $html; }
php
protected function listing_pagination(core_course_category $category, $page, $perpage, $showtotals = false, $viewmode = 'default') { $html = ''; $totalcourses = $category->get_courses_count(); $totalpages = ceil($totalcourses / $perpage); if ($showtotals) { if ($totalpages == 0) { $str = get_string('nocoursesyet'); } else if ($totalpages == 1) { $str = get_string('showingacourses', 'moodle', $totalcourses); } else { $a = new stdClass; $a->start = ($page * $perpage) + 1; $a->end = min((($page + 1) * $perpage), $totalcourses); $a->total = $totalcourses; $str = get_string('showingxofycourses', 'moodle', $a); } $html .= html_writer::div($str, 'listing-pagination-totals dimmed'); } if ($viewmode !== 'default') { $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id, 'view' => $viewmode)); } else { $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id)); } $html .= $this->output->paging_bar($totalcourses, $page, $perpage, $baseurl); return $html; }
[ "protected", "function", "listing_pagination", "(", "core_course_category", "$", "category", ",", "$", "page", ",", "$", "perpage", ",", "$", "showtotals", "=", "false", ",", "$", "viewmode", "=", "'default'", ")", "{", "$", "html", "=", "''", ";", "$", "totalcourses", "=", "$", "category", "->", "get_courses_count", "(", ")", ";", "$", "totalpages", "=", "ceil", "(", "$", "totalcourses", "/", "$", "perpage", ")", ";", "if", "(", "$", "showtotals", ")", "{", "if", "(", "$", "totalpages", "==", "0", ")", "{", "$", "str", "=", "get_string", "(", "'nocoursesyet'", ")", ";", "}", "else", "if", "(", "$", "totalpages", "==", "1", ")", "{", "$", "str", "=", "get_string", "(", "'showingacourses'", ",", "'moodle'", ",", "$", "totalcourses", ")", ";", "}", "else", "{", "$", "a", "=", "new", "stdClass", ";", "$", "a", "->", "start", "=", "(", "$", "page", "*", "$", "perpage", ")", "+", "1", ";", "$", "a", "->", "end", "=", "min", "(", "(", "(", "$", "page", "+", "1", ")", "*", "$", "perpage", ")", ",", "$", "totalcourses", ")", ";", "$", "a", "->", "total", "=", "$", "totalcourses", ";", "$", "str", "=", "get_string", "(", "'showingxofycourses'", ",", "'moodle'", ",", "$", "a", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "div", "(", "$", "str", ",", "'listing-pagination-totals dimmed'", ")", ";", "}", "if", "(", "$", "viewmode", "!==", "'default'", ")", "{", "$", "baseurl", "=", "new", "moodle_url", "(", "'/course/management.php'", ",", "array", "(", "'categoryid'", "=>", "$", "category", "->", "id", ",", "'view'", "=>", "$", "viewmode", ")", ")", ";", "}", "else", "{", "$", "baseurl", "=", "new", "moodle_url", "(", "'/course/management.php'", ",", "array", "(", "'categoryid'", "=>", "$", "category", "->", "id", ")", ")", ";", "}", "$", "html", ".=", "$", "this", "->", "output", "->", "paging_bar", "(", "$", "totalcourses", ",", "$", "page", ",", "$", "perpage", ",", "$", "baseurl", ")", ";", "return", "$", "html", ";", "}" ]
Renders pagination for a course listing. @param core_course_category $category The category to produce pagination for. @param int $page The current page. @param int $perpage The number of courses to display per page. @param bool $showtotals Set to true to show the total number of courses and what is being displayed. @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'. @return string
[ "Renders", "pagination", "for", "a", "course", "listing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L560-L589
219,277
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_listitem
public function course_listitem(core_course_category $category, core_course_list_element $course, $selectedcourse) { $text = $course->get_formatted_name(); $attributes = array( 'class' => 'listitem listitem-course list-group-item list-group-item-action', 'data-id' => $course->id, 'data-selected' => ($selectedcourse == $course->id) ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0' ); $bulkcourseinput = array( 'type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox', 'aria-label' => get_string('bulkactionselect', 'moodle', $text), 'data-action' => 'select' ); if (!$category->has_manage_capability()) { // Very very hardcoded here. $bulkcourseinput['style'] = 'visibility:hidden'; } $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id)); $html = html_writer::start_tag('li', $attributes); $html .= html_writer::start_div('clearfix'); if ($category->can_resort_courses()) { // In order for dnd to be available the user must be able to resort the category children.. $html .= html_writer::div($this->output->pix_icon('i/move_2d', get_string('dndcourse')), 'float-left drag-handle'); } $html .= html_writer::start_div('ba-checkbox float-left'); $html .= html_writer::empty_tag('input', $bulkcourseinput).'&nbsp;'; $html .= html_writer::end_div(); $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename')); $html .= html_writer::start_div('float-right'); if ($course->idnumber) { $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber')); } $html .= $this->course_listitem_actions($category, $course); $html .= html_writer::end_div(); $html .= html_writer::end_div(); $html .= html_writer::end_tag('li'); return $html; }
php
public function course_listitem(core_course_category $category, core_course_list_element $course, $selectedcourse) { $text = $course->get_formatted_name(); $attributes = array( 'class' => 'listitem listitem-course list-group-item list-group-item-action', 'data-id' => $course->id, 'data-selected' => ($selectedcourse == $course->id) ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0' ); $bulkcourseinput = array( 'type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox', 'aria-label' => get_string('bulkactionselect', 'moodle', $text), 'data-action' => 'select' ); if (!$category->has_manage_capability()) { // Very very hardcoded here. $bulkcourseinput['style'] = 'visibility:hidden'; } $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id)); $html = html_writer::start_tag('li', $attributes); $html .= html_writer::start_div('clearfix'); if ($category->can_resort_courses()) { // In order for dnd to be available the user must be able to resort the category children.. $html .= html_writer::div($this->output->pix_icon('i/move_2d', get_string('dndcourse')), 'float-left drag-handle'); } $html .= html_writer::start_div('ba-checkbox float-left'); $html .= html_writer::empty_tag('input', $bulkcourseinput).'&nbsp;'; $html .= html_writer::end_div(); $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename')); $html .= html_writer::start_div('float-right'); if ($course->idnumber) { $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber')); } $html .= $this->course_listitem_actions($category, $course); $html .= html_writer::end_div(); $html .= html_writer::end_div(); $html .= html_writer::end_tag('li'); return $html; }
[ "public", "function", "course_listitem", "(", "core_course_category", "$", "category", ",", "core_course_list_element", "$", "course", ",", "$", "selectedcourse", ")", "{", "$", "text", "=", "$", "course", "->", "get_formatted_name", "(", ")", ";", "$", "attributes", "=", "array", "(", "'class'", "=>", "'listitem listitem-course list-group-item list-group-item-action'", ",", "'data-id'", "=>", "$", "course", "->", "id", ",", "'data-selected'", "=>", "(", "$", "selectedcourse", "==", "$", "course", "->", "id", ")", "?", "'1'", ":", "'0'", ",", "'data-visible'", "=>", "$", "course", "->", "visible", "?", "'1'", ":", "'0'", ")", ";", "$", "bulkcourseinput", "=", "array", "(", "'type'", "=>", "'checkbox'", ",", "'name'", "=>", "'bc[]'", ",", "'value'", "=>", "$", "course", "->", "id", ",", "'class'", "=>", "'bulk-action-checkbox'", ",", "'aria-label'", "=>", "get_string", "(", "'bulkactionselect'", ",", "'moodle'", ",", "$", "text", ")", ",", "'data-action'", "=>", "'select'", ")", ";", "if", "(", "!", "$", "category", "->", "has_manage_capability", "(", ")", ")", "{", "// Very very hardcoded here.", "$", "bulkcourseinput", "[", "'style'", "]", "=", "'visibility:hidden'", ";", "}", "$", "viewcourseurl", "=", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ";", "$", "html", "=", "html_writer", "::", "start_tag", "(", "'li'", ",", "$", "attributes", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'clearfix'", ")", ";", "if", "(", "$", "category", "->", "can_resort_courses", "(", ")", ")", "{", "// In order for dnd to be available the user must be able to resort the category children..", "$", "html", ".=", "html_writer", "::", "div", "(", "$", "this", "->", "output", "->", "pix_icon", "(", "'i/move_2d'", ",", "get_string", "(", "'dndcourse'", ")", ")", ",", "'float-left drag-handle'", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'ba-checkbox float-left'", ")", ";", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "bulkcourseinput", ")", ".", "'&nbsp;'", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "viewcourseurl", ",", "$", "text", ",", "array", "(", "'class'", "=>", "'float-left coursename'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'float-right'", ")", ";", "if", "(", "$", "course", "->", "idnumber", ")", "{", "$", "html", ".=", "html_writer", "::", "tag", "(", "'span'", ",", "s", "(", "$", "course", "->", "idnumber", ")", ",", "array", "(", "'class'", "=>", "'dimmed idnumber'", ")", ")", ";", "}", "$", "html", ".=", "$", "this", "->", "course_listitem_actions", "(", "$", "category", ",", "$", "course", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'li'", ")", ";", "return", "$", "html", ";", "}" ]
Renderers a course list item. This function will be called for every course being displayed by course_listing. @param core_course_category $category The currently selected category and the category the course belongs to. @param core_course_list_element $course The course to produce HTML for. @param int $selectedcourse The id of the currently selected course. @return string
[ "Renderers", "a", "course", "list", "item", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L601-L647
219,278
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_bulk_actions
public function course_bulk_actions(core_course_category $category) { $html = html_writer::start_div('course-bulk-actions bulk-actions'); if ($category->can_move_courses_out_of()) { $html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0')); $options = core_course_category::make_categories_list('moodle/category:manage'); $select = html_writer::select( $options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto', 'class' => 'mr-1') ); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'), 'class' => 'btn btn-secondary'); $html .= $this->detail_pair( html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit) ); } $html .= html_writer::end_div(); return $html; }
php
public function course_bulk_actions(core_course_category $category) { $html = html_writer::start_div('course-bulk-actions bulk-actions'); if ($category->can_move_courses_out_of()) { $html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0')); $options = core_course_category::make_categories_list('moodle/category:manage'); $select = html_writer::select( $options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto', 'class' => 'mr-1') ); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'), 'class' => 'btn btn-secondary'); $html .= $this->detail_pair( html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit) ); } $html .= html_writer::end_div(); return $html; }
[ "public", "function", "course_bulk_actions", "(", "core_course_category", "$", "category", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'course-bulk-actions bulk-actions'", ")", ";", "if", "(", "$", "category", "->", "can_move_courses_out_of", "(", ")", ")", "{", "$", "html", ".=", "html_writer", "::", "div", "(", "get_string", "(", "'coursebulkaction'", ")", ",", "'accesshide'", ",", "array", "(", "'tabindex'", "=>", "'0'", ")", ")", ";", "$", "options", "=", "core_course_category", "::", "make_categories_list", "(", "'moodle/category:manage'", ")", ";", "$", "select", "=", "html_writer", "::", "select", "(", "$", "options", ",", "'movecoursesto'", ",", "''", ",", "array", "(", "''", "=>", "'choosedots'", ")", ",", "array", "(", "'aria-labelledby'", "=>", "'moveselectedcoursesto'", ",", "'class'", "=>", "'mr-1'", ")", ")", ";", "$", "submit", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'bulkmovecourses'", ",", "'value'", "=>", "get_string", "(", "'move'", ")", ",", "'class'", "=>", "'btn btn-secondary'", ")", ";", "$", "html", ".=", "$", "this", "->", "detail_pair", "(", "html_writer", "::", "span", "(", "get_string", "(", "'moveselectedcoursesto'", ")", ",", "''", ",", "array", "(", "'id'", "=>", "'moveselectedcoursesto'", ")", ")", ",", "$", "select", ".", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "submit", ")", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Renderers bulk actions that can be performed on courses. @param core_course_category $category The currently selected category and the category in which courses that are selectable belong. @return string
[ "Renderers", "bulk", "actions", "that", "can", "be", "performed", "on", "courses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L757-L778
219,279
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_search_bulk_actions
public function course_search_bulk_actions() { $html = html_writer::start_div('course-bulk-actions bulk-actions'); $html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0')); $options = core_course_category::make_categories_list('moodle/category:manage'); $select = html_writer::select( $options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto') ); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'), 'class' => 'btn btn-secondary'); $html .= $this->detail_pair( html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit) ); $html .= html_writer::end_div(); return $html; }
php
public function course_search_bulk_actions() { $html = html_writer::start_div('course-bulk-actions bulk-actions'); $html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0')); $options = core_course_category::make_categories_list('moodle/category:manage'); $select = html_writer::select( $options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto') ); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move'), 'class' => 'btn btn-secondary'); $html .= $this->detail_pair( html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit) ); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "course_search_bulk_actions", "(", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'course-bulk-actions bulk-actions'", ")", ";", "$", "html", ".=", "html_writer", "::", "div", "(", "get_string", "(", "'coursebulkaction'", ")", ",", "'accesshide'", ",", "array", "(", "'tabindex'", "=>", "'0'", ")", ")", ";", "$", "options", "=", "core_course_category", "::", "make_categories_list", "(", "'moodle/category:manage'", ")", ";", "$", "select", "=", "html_writer", "::", "select", "(", "$", "options", ",", "'movecoursesto'", ",", "''", ",", "array", "(", "''", "=>", "'choosedots'", ")", ",", "array", "(", "'aria-labelledby'", "=>", "'moveselectedcoursesto'", ")", ")", ";", "$", "submit", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'bulkmovecourses'", ",", "'value'", "=>", "get_string", "(", "'move'", ")", ",", "'class'", "=>", "'btn btn-secondary'", ")", ";", "$", "html", ".=", "$", "this", "->", "detail_pair", "(", "html_writer", "::", "span", "(", "get_string", "(", "'moveselectedcoursesto'", ")", ",", "''", ",", "array", "(", "'id'", "=>", "'moveselectedcoursesto'", ")", ")", ",", "$", "select", ".", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "submit", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Renderers bulk actions that can be performed on courses in search returns @return string
[ "Renderers", "bulk", "actions", "that", "can", "be", "performed", "on", "courses", "in", "search", "returns" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L785-L804
219,280
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_detail
public function course_detail(core_course_list_element $course) { $details = \core_course\management\helper::get_course_detail_array($course); $fullname = $details['fullname']['value']; $html = html_writer::start_div('course-detail card'); $html .= html_writer::start_div('card-header'); $html .= html_writer::tag('h3', $fullname, array('id' => 'course-detail-title', 'class' => 'card-title', 'tabindex' => '0')); $html .= html_writer::end_div(); $html .= html_writer::start_div('card-body'); $html .= $this->course_detail_actions($course); foreach ($details as $class => $data) { $html .= $this->detail_pair($data['key'], $data['value'], $class); } $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
php
public function course_detail(core_course_list_element $course) { $details = \core_course\management\helper::get_course_detail_array($course); $fullname = $details['fullname']['value']; $html = html_writer::start_div('course-detail card'); $html .= html_writer::start_div('card-header'); $html .= html_writer::tag('h3', $fullname, array('id' => 'course-detail-title', 'class' => 'card-title', 'tabindex' => '0')); $html .= html_writer::end_div(); $html .= html_writer::start_div('card-body'); $html .= $this->course_detail_actions($course); foreach ($details as $class => $data) { $html .= $this->detail_pair($data['key'], $data['value'], $class); } $html .= html_writer::end_div(); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "course_detail", "(", "core_course_list_element", "$", "course", ")", "{", "$", "details", "=", "\\", "core_course", "\\", "management", "\\", "helper", "::", "get_course_detail_array", "(", "$", "course", ")", ";", "$", "fullname", "=", "$", "details", "[", "'fullname'", "]", "[", "'value'", "]", ";", "$", "html", "=", "html_writer", "::", "start_div", "(", "'course-detail card'", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'card-header'", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'h3'", ",", "$", "fullname", ",", "array", "(", "'id'", "=>", "'course-detail-title'", ",", "'class'", "=>", "'card-title'", ",", "'tabindex'", "=>", "'0'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'card-body'", ")", ";", "$", "html", ".=", "$", "this", "->", "course_detail_actions", "(", "$", "course", ")", ";", "foreach", "(", "$", "details", "as", "$", "class", "=>", "$", "data", ")", "{", "$", "html", ".=", "$", "this", "->", "detail_pair", "(", "$", "data", "[", "'key'", "]", ",", "$", "data", "[", "'value'", "]", ",", "$", "class", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Renderers detailed course information. @param core_course_list_element $course The course to display details for. @return string
[ "Renderers", "detailed", "course", "information", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L812-L829
219,281
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.detail_pair
protected function detail_pair($key, $value, $class ='') { $html = html_writer::start_div('detail-pair row yui3-g '.preg_replace('#[^a-zA-Z0-9_\-]#', '-', $class)); $html .= html_writer::div(html_writer::span($key), 'pair-key col-md-3 yui3-u-1-4 font-weight-bold'); $html .= html_writer::div(html_writer::span($value), 'pair-value col-md-8 yui3-u-3-4'); $html .= html_writer::end_div(); return $html; }
php
protected function detail_pair($key, $value, $class ='') { $html = html_writer::start_div('detail-pair row yui3-g '.preg_replace('#[^a-zA-Z0-9_\-]#', '-', $class)); $html .= html_writer::div(html_writer::span($key), 'pair-key col-md-3 yui3-u-1-4 font-weight-bold'); $html .= html_writer::div(html_writer::span($value), 'pair-value col-md-8 yui3-u-3-4'); $html .= html_writer::end_div(); return $html; }
[ "protected", "function", "detail_pair", "(", "$", "key", ",", "$", "value", ",", "$", "class", "=", "''", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'detail-pair row yui3-g '", ".", "preg_replace", "(", "'#[^a-zA-Z0-9_\\-]#'", ",", "'-'", ",", "$", "class", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "div", "(", "html_writer", "::", "span", "(", "$", "key", ")", ",", "'pair-key col-md-3 yui3-u-1-4 font-weight-bold'", ")", ";", "$", "html", ".=", "html_writer", "::", "div", "(", "html_writer", "::", "span", "(", "$", "value", ")", ",", "'pair-value col-md-8 yui3-u-3-4'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Renderers a key value pair of information for display. @param string $key @param string $value @param string $class @return string
[ "Renderers", "a", "key", "value", "pair", "of", "information", "for", "display", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L839-L845
219,282
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_detail_actions
public function course_detail_actions(core_course_list_element $course) { $actions = \core_course\management\helper::get_course_detail_actions($course); if (empty($actions)) { return ''; } $options = array(); foreach ($actions as $action) { $options[] = $this->action_link($action['url'], $action['string'], null, array('class' => 'btn btn-sm btn-secondary mr-1 mb-3')); } return html_writer::div(join('', $options), 'listing-actions course-detail-listing-actions'); }
php
public function course_detail_actions(core_course_list_element $course) { $actions = \core_course\management\helper::get_course_detail_actions($course); if (empty($actions)) { return ''; } $options = array(); foreach ($actions as $action) { $options[] = $this->action_link($action['url'], $action['string'], null, array('class' => 'btn btn-sm btn-secondary mr-1 mb-3')); } return html_writer::div(join('', $options), 'listing-actions course-detail-listing-actions'); }
[ "public", "function", "course_detail_actions", "(", "core_course_list_element", "$", "course", ")", "{", "$", "actions", "=", "\\", "core_course", "\\", "management", "\\", "helper", "::", "get_course_detail_actions", "(", "$", "course", ")", ";", "if", "(", "empty", "(", "$", "actions", ")", ")", "{", "return", "''", ";", "}", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "$", "options", "[", "]", "=", "$", "this", "->", "action_link", "(", "$", "action", "[", "'url'", "]", ",", "$", "action", "[", "'string'", "]", ",", "null", ",", "array", "(", "'class'", "=>", "'btn btn-sm btn-secondary mr-1 mb-3'", ")", ")", ";", "}", "return", "html_writer", "::", "div", "(", "join", "(", "''", ",", "$", "options", ")", ",", "'listing-actions course-detail-listing-actions'", ")", ";", "}" ]
A collection of actions for a course. @param core_course_list_element $course The course to display actions for. @return string
[ "A", "collection", "of", "actions", "for", "a", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L853-L864
219,283
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.grid_start
public function grid_start($id = null, $class = null) { $gridclass = 'grid-start grid-row-r d-flex flex-wrap row'; if (is_null($class)) { $class = $gridclass; } else { $class .= ' ' . $gridclass; } $attributes = array(); if (!is_null($id)) { $attributes['id'] = $id; } return html_writer::start_div($class, $attributes); }
php
public function grid_start($id = null, $class = null) { $gridclass = 'grid-start grid-row-r d-flex flex-wrap row'; if (is_null($class)) { $class = $gridclass; } else { $class .= ' ' . $gridclass; } $attributes = array(); if (!is_null($id)) { $attributes['id'] = $id; } return html_writer::start_div($class, $attributes); }
[ "public", "function", "grid_start", "(", "$", "id", "=", "null", ",", "$", "class", "=", "null", ")", "{", "$", "gridclass", "=", "'grid-start grid-row-r d-flex flex-wrap row'", ";", "if", "(", "is_null", "(", "$", "class", ")", ")", "{", "$", "class", "=", "$", "gridclass", ";", "}", "else", "{", "$", "class", ".=", "' '", ".", "$", "gridclass", ";", "}", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "id", ";", "}", "return", "html_writer", "::", "start_div", "(", "$", "class", ",", "$", "attributes", ")", ";", "}" ]
Opens a grid. Call {@link core_course_management_renderer::grid_column_start()} to create columns. @param string $id An id to give this grid. @param string $class A class to give this grid. @return string
[ "Opens", "a", "grid", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L907-L919
219,284
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.grid_column_start
public function grid_column_start($size, $id = null, $class = null) { if ($id == 'course-detail') { $size = 12; $bootstrapclass = 'col-md-'.$size; } else { $bootstrapclass = 'd-flex flex-wrap px-3 mb-3'; } $yuigridclass = "col-sm"; if (is_null($class)) { $class = $yuigridclass . ' ' . $bootstrapclass; } else { $class .= ' ' . $yuigridclass . ' ' . $bootstrapclass; } $attributes = array(); if (!is_null($id)) { $attributes['id'] = $id; } return html_writer::start_div($class . " grid_column_start", $attributes); }
php
public function grid_column_start($size, $id = null, $class = null) { if ($id == 'course-detail') { $size = 12; $bootstrapclass = 'col-md-'.$size; } else { $bootstrapclass = 'd-flex flex-wrap px-3 mb-3'; } $yuigridclass = "col-sm"; if (is_null($class)) { $class = $yuigridclass . ' ' . $bootstrapclass; } else { $class .= ' ' . $yuigridclass . ' ' . $bootstrapclass; } $attributes = array(); if (!is_null($id)) { $attributes['id'] = $id; } return html_writer::start_div($class . " grid_column_start", $attributes); }
[ "public", "function", "grid_column_start", "(", "$", "size", ",", "$", "id", "=", "null", ",", "$", "class", "=", "null", ")", "{", "if", "(", "$", "id", "==", "'course-detail'", ")", "{", "$", "size", "=", "12", ";", "$", "bootstrapclass", "=", "'col-md-'", ".", "$", "size", ";", "}", "else", "{", "$", "bootstrapclass", "=", "'d-flex flex-wrap px-3 mb-3'", ";", "}", "$", "yuigridclass", "=", "\"col-sm\"", ";", "if", "(", "is_null", "(", "$", "class", ")", ")", "{", "$", "class", "=", "$", "yuigridclass", ".", "' '", ".", "$", "bootstrapclass", ";", "}", "else", "{", "$", "class", ".=", "' '", ".", "$", "yuigridclass", ".", "' '", ".", "$", "bootstrapclass", ";", "}", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "id", ";", "}", "return", "html_writer", "::", "start_div", "(", "$", "class", ".", "\" grid_column_start\"", ",", "$", "attributes", ")", ";", "}" ]
Opens a grid column @param int $size The number of segments this column should span. @param string $id An id to give the column. @param string $class A class to give the column. @return string
[ "Opens", "a", "grid", "column" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L938-L959
219,285
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.action_icon
public function action_icon($url, pix_icon $pixicon, component_action $action = null, array $attributes = null, $linktext = false) { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } $attributes = (array)$attributes; if (empty($attributes['class'])) { // Let devs override the class via $attributes. $attributes['class'] = 'action-icon'; } $icon = $this->render($pixicon); if ($linktext) { $text = $pixicon->attributes['alt']; } else { $text = ''; } return $this->action_link($url, $icon.$text, $action, $attributes); }
php
public function action_icon($url, pix_icon $pixicon, component_action $action = null, array $attributes = null, $linktext = false) { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } $attributes = (array)$attributes; if (empty($attributes['class'])) { // Let devs override the class via $attributes. $attributes['class'] = 'action-icon'; } $icon = $this->render($pixicon); if ($linktext) { $text = $pixicon->attributes['alt']; } else { $text = ''; } return $this->action_link($url, $icon.$text, $action, $attributes); }
[ "public", "function", "action_icon", "(", "$", "url", ",", "pix_icon", "$", "pixicon", ",", "component_action", "$", "action", "=", "null", ",", "array", "$", "attributes", "=", "null", ",", "$", "linktext", "=", "false", ")", "{", "if", "(", "!", "(", "$", "url", "instanceof", "moodle_url", ")", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "$", "url", ")", ";", "}", "$", "attributes", "=", "(", "array", ")", "$", "attributes", ";", "if", "(", "empty", "(", "$", "attributes", "[", "'class'", "]", ")", ")", "{", "// Let devs override the class via $attributes.", "$", "attributes", "[", "'class'", "]", "=", "'action-icon'", ";", "}", "$", "icon", "=", "$", "this", "->", "render", "(", "$", "pixicon", ")", ";", "if", "(", "$", "linktext", ")", "{", "$", "text", "=", "$", "pixicon", "->", "attributes", "[", "'alt'", "]", ";", "}", "else", "{", "$", "text", "=", "''", ";", "}", "return", "$", "this", "->", "action_link", "(", "$", "url", ",", "$", "icon", ".", "$", "text", ",", "$", "action", ",", "$", "attributes", ")", ";", "}" ]
Renders an action_icon. This function uses the {@link core_renderer::action_link()} method for the most part. What it does different is prepare the icon as HTML and use it as the link text. @param string|moodle_url $url A string URL or moodel_url @param pix_icon $pixicon @param component_action $action @param array $attributes associative array of html link attributes + disabled @param bool $linktext show title next to image in link @return string HTML fragment
[ "Renders", "an", "action_icon", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L984-L1005
219,286
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.view_mode_selector
public function view_mode_selector(array $modes, $currentmode, moodle_url $url = null, $param = 'view') { if ($url === null) { $url = $this->page->url; } $menu = new action_menu; $menu->attributes['class'] .= ' view-mode-selector vms ml-1'; $selected = null; foreach ($modes as $mode => $modestr) { $attributes = array( 'class' => 'vms-mode', 'data-mode' => $mode ); if ($currentmode === $mode) { $attributes['class'] .= ' currentmode'; $selected = $modestr; } if ($selected === null) { $selected = $modestr; } $modeurl = new moodle_url($url, array($param => $mode)); if ($mode === 'default') { $modeurl->remove_params($param); } $menu->add(new action_menu_link_secondary($modeurl, null, $modestr, $attributes)); } $menu->set_menu_trigger($selected); $html = html_writer::start_div('view-mode-selector vms d-flex'); $html .= get_string('viewing').' '.$this->render($menu); $html .= html_writer::end_div(); return $html; }
php
public function view_mode_selector(array $modes, $currentmode, moodle_url $url = null, $param = 'view') { if ($url === null) { $url = $this->page->url; } $menu = new action_menu; $menu->attributes['class'] .= ' view-mode-selector vms ml-1'; $selected = null; foreach ($modes as $mode => $modestr) { $attributes = array( 'class' => 'vms-mode', 'data-mode' => $mode ); if ($currentmode === $mode) { $attributes['class'] .= ' currentmode'; $selected = $modestr; } if ($selected === null) { $selected = $modestr; } $modeurl = new moodle_url($url, array($param => $mode)); if ($mode === 'default') { $modeurl->remove_params($param); } $menu->add(new action_menu_link_secondary($modeurl, null, $modestr, $attributes)); } $menu->set_menu_trigger($selected); $html = html_writer::start_div('view-mode-selector vms d-flex'); $html .= get_string('viewing').' '.$this->render($menu); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "view_mode_selector", "(", "array", "$", "modes", ",", "$", "currentmode", ",", "moodle_url", "$", "url", "=", "null", ",", "$", "param", "=", "'view'", ")", "{", "if", "(", "$", "url", "===", "null", ")", "{", "$", "url", "=", "$", "this", "->", "page", "->", "url", ";", "}", "$", "menu", "=", "new", "action_menu", ";", "$", "menu", "->", "attributes", "[", "'class'", "]", ".=", "' view-mode-selector vms ml-1'", ";", "$", "selected", "=", "null", ";", "foreach", "(", "$", "modes", "as", "$", "mode", "=>", "$", "modestr", ")", "{", "$", "attributes", "=", "array", "(", "'class'", "=>", "'vms-mode'", ",", "'data-mode'", "=>", "$", "mode", ")", ";", "if", "(", "$", "currentmode", "===", "$", "mode", ")", "{", "$", "attributes", "[", "'class'", "]", ".=", "' currentmode'", ";", "$", "selected", "=", "$", "modestr", ";", "}", "if", "(", "$", "selected", "===", "null", ")", "{", "$", "selected", "=", "$", "modestr", ";", "}", "$", "modeurl", "=", "new", "moodle_url", "(", "$", "url", ",", "array", "(", "$", "param", "=>", "$", "mode", ")", ")", ";", "if", "(", "$", "mode", "===", "'default'", ")", "{", "$", "modeurl", "->", "remove_params", "(", "$", "param", ")", ";", "}", "$", "menu", "->", "add", "(", "new", "action_menu_link_secondary", "(", "$", "modeurl", ",", "null", ",", "$", "modestr", ",", "$", "attributes", ")", ")", ";", "}", "$", "menu", "->", "set_menu_trigger", "(", "$", "selected", ")", ";", "$", "html", "=", "html_writer", "::", "start_div", "(", "'view-mode-selector vms d-flex'", ")", ";", "$", "html", ".=", "get_string", "(", "'viewing'", ")", ".", "' '", ".", "$", "this", "->", "render", "(", "$", "menu", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Displays a view mode selector. @param array $modes An array of view modes. @param string $currentmode The current view mode. @param moodle_url $url The URL to use when changing actions. Defaults to the page URL. @param string $param The param name. @return string
[ "Displays", "a", "view", "mode", "selector", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L1016-L1051
219,287
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.search_listing
public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20, $search = '') { $page = max($page, 0); $perpage = max($perpage, 2); $totalpages = ceil($totalcourses / $perpage); if ($page > $totalpages - 1) { $page = $totalpages - 1; } $courseid = isset($course) ? $course->id : null; $first = true; $last = false; $i = $page * $perpage; $html = html_writer::start_div('course-listing w-100', array( 'data-category' => 'search', 'data-page' => $page, 'data-totalpages' => $totalpages, 'data-totalcourses' => $totalcourses )); $html .= html_writer::tag('h3', get_string('courses')); $html .= $this->search_pagination($totalcourses, $page, $perpage); $html .= html_writer::start_tag('ul', array('class' => 'ml')); foreach ($courses as $listitem) { $i++; if ($i == $totalcourses) { $last = true; } $html .= $this->search_listitem($listitem, $courseid, $first, $last); $first = false; } $html .= html_writer::end_tag('ul'); $html .= $this->search_pagination($totalcourses, $page, $perpage, true, $search); $html .= $this->course_search_bulk_actions(); $html .= html_writer::end_div(); return $html; }
php
public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20, $search = '') { $page = max($page, 0); $perpage = max($perpage, 2); $totalpages = ceil($totalcourses / $perpage); if ($page > $totalpages - 1) { $page = $totalpages - 1; } $courseid = isset($course) ? $course->id : null; $first = true; $last = false; $i = $page * $perpage; $html = html_writer::start_div('course-listing w-100', array( 'data-category' => 'search', 'data-page' => $page, 'data-totalpages' => $totalpages, 'data-totalcourses' => $totalcourses )); $html .= html_writer::tag('h3', get_string('courses')); $html .= $this->search_pagination($totalcourses, $page, $perpage); $html .= html_writer::start_tag('ul', array('class' => 'ml')); foreach ($courses as $listitem) { $i++; if ($i == $totalcourses) { $last = true; } $html .= $this->search_listitem($listitem, $courseid, $first, $last); $first = false; } $html .= html_writer::end_tag('ul'); $html .= $this->search_pagination($totalcourses, $page, $perpage, true, $search); $html .= $this->course_search_bulk_actions(); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "search_listing", "(", "array", "$", "courses", ",", "$", "totalcourses", ",", "core_course_list_element", "$", "course", "=", "null", ",", "$", "page", "=", "0", ",", "$", "perpage", "=", "20", ",", "$", "search", "=", "''", ")", "{", "$", "page", "=", "max", "(", "$", "page", ",", "0", ")", ";", "$", "perpage", "=", "max", "(", "$", "perpage", ",", "2", ")", ";", "$", "totalpages", "=", "ceil", "(", "$", "totalcourses", "/", "$", "perpage", ")", ";", "if", "(", "$", "page", ">", "$", "totalpages", "-", "1", ")", "{", "$", "page", "=", "$", "totalpages", "-", "1", ";", "}", "$", "courseid", "=", "isset", "(", "$", "course", ")", "?", "$", "course", "->", "id", ":", "null", ";", "$", "first", "=", "true", ";", "$", "last", "=", "false", ";", "$", "i", "=", "$", "page", "*", "$", "perpage", ";", "$", "html", "=", "html_writer", "::", "start_div", "(", "'course-listing w-100'", ",", "array", "(", "'data-category'", "=>", "'search'", ",", "'data-page'", "=>", "$", "page", ",", "'data-totalpages'", "=>", "$", "totalpages", ",", "'data-totalcourses'", "=>", "$", "totalcourses", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'h3'", ",", "get_string", "(", "'courses'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "search_pagination", "(", "$", "totalcourses", ",", "$", "page", ",", "$", "perpage", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "'ml'", ")", ")", ";", "foreach", "(", "$", "courses", "as", "$", "listitem", ")", "{", "$", "i", "++", ";", "if", "(", "$", "i", "==", "$", "totalcourses", ")", "{", "$", "last", "=", "true", ";", "}", "$", "html", ".=", "$", "this", "->", "search_listitem", "(", "$", "listitem", ",", "$", "courseid", ",", "$", "first", ",", "$", "last", ")", ";", "$", "first", "=", "false", ";", "}", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "$", "html", ".=", "$", "this", "->", "search_pagination", "(", "$", "totalcourses", ",", "$", "page", ",", "$", "perpage", ",", "true", ",", "$", "search", ")", ";", "$", "html", ".=", "$", "this", "->", "course_search_bulk_actions", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Displays a search result listing. @param array $courses The courses to display. @param int $totalcourses The total number of courses to display. @param core_course_list_element $course The currently selected course if there is one. @param int $page The current page, starting at 0. @param int $perpage The number of courses to display per page. @param string $search The string we are searching for. @return string
[ "Displays", "a", "search", "result", "listing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L1064-L1099
219,288
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.search_listitem
public function search_listitem(core_course_list_element $course, $selectedcourse) { $text = $course->get_formatted_name(); $attributes = array( 'class' => 'listitem listitem-course list-group-item list-group-item-action', 'data-id' => $course->id, 'data-selected' => ($selectedcourse == $course->id) ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0' ); $bulkcourseinput = ''; if (core_course_category::get($course->category)->can_move_courses_out_of()) { $bulkcourseinput = array( 'type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox', 'aria-label' => get_string('bulkactionselect', 'moodle', $text), 'data-action' => 'select' ); } $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id)); $categoryname = core_course_category::get($course->category)->get_formatted_name(); $html = html_writer::start_tag('li', $attributes); $html .= html_writer::start_div('clearfix'); $html .= html_writer::start_div('float-left'); if ($bulkcourseinput) { $html .= html_writer::empty_tag('input', $bulkcourseinput).'&nbsp;'; } $html .= html_writer::end_div(); $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename')); $html .= html_writer::tag('span', $categoryname, array('class' => 'float-left categoryname')); $html .= html_writer::start_div('float-right'); $html .= $this->search_listitem_actions($course); $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber')); $html .= html_writer::end_div(); $html .= html_writer::end_div(); $html .= html_writer::end_tag('li'); return $html; }
php
public function search_listitem(core_course_list_element $course, $selectedcourse) { $text = $course->get_formatted_name(); $attributes = array( 'class' => 'listitem listitem-course list-group-item list-group-item-action', 'data-id' => $course->id, 'data-selected' => ($selectedcourse == $course->id) ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0' ); $bulkcourseinput = ''; if (core_course_category::get($course->category)->can_move_courses_out_of()) { $bulkcourseinput = array( 'type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox', 'aria-label' => get_string('bulkactionselect', 'moodle', $text), 'data-action' => 'select' ); } $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id)); $categoryname = core_course_category::get($course->category)->get_formatted_name(); $html = html_writer::start_tag('li', $attributes); $html .= html_writer::start_div('clearfix'); $html .= html_writer::start_div('float-left'); if ($bulkcourseinput) { $html .= html_writer::empty_tag('input', $bulkcourseinput).'&nbsp;'; } $html .= html_writer::end_div(); $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename')); $html .= html_writer::tag('span', $categoryname, array('class' => 'float-left categoryname')); $html .= html_writer::start_div('float-right'); $html .= $this->search_listitem_actions($course); $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber')); $html .= html_writer::end_div(); $html .= html_writer::end_div(); $html .= html_writer::end_tag('li'); return $html; }
[ "public", "function", "search_listitem", "(", "core_course_list_element", "$", "course", ",", "$", "selectedcourse", ")", "{", "$", "text", "=", "$", "course", "->", "get_formatted_name", "(", ")", ";", "$", "attributes", "=", "array", "(", "'class'", "=>", "'listitem listitem-course list-group-item list-group-item-action'", ",", "'data-id'", "=>", "$", "course", "->", "id", ",", "'data-selected'", "=>", "(", "$", "selectedcourse", "==", "$", "course", "->", "id", ")", "?", "'1'", ":", "'0'", ",", "'data-visible'", "=>", "$", "course", "->", "visible", "?", "'1'", ":", "'0'", ")", ";", "$", "bulkcourseinput", "=", "''", ";", "if", "(", "core_course_category", "::", "get", "(", "$", "course", "->", "category", ")", "->", "can_move_courses_out_of", "(", ")", ")", "{", "$", "bulkcourseinput", "=", "array", "(", "'type'", "=>", "'checkbox'", ",", "'name'", "=>", "'bc[]'", ",", "'value'", "=>", "$", "course", "->", "id", ",", "'class'", "=>", "'bulk-action-checkbox'", ",", "'aria-label'", "=>", "get_string", "(", "'bulkactionselect'", ",", "'moodle'", ",", "$", "text", ")", ",", "'data-action'", "=>", "'select'", ")", ";", "}", "$", "viewcourseurl", "=", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ";", "$", "categoryname", "=", "core_course_category", "::", "get", "(", "$", "course", "->", "category", ")", "->", "get_formatted_name", "(", ")", ";", "$", "html", "=", "html_writer", "::", "start_tag", "(", "'li'", ",", "$", "attributes", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'clearfix'", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'float-left'", ")", ";", "if", "(", "$", "bulkcourseinput", ")", "{", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "bulkcourseinput", ")", ".", "'&nbsp;'", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "viewcourseurl", ",", "$", "text", ",", "array", "(", "'class'", "=>", "'float-left coursename'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "categoryname", ",", "array", "(", "'class'", "=>", "'float-left categoryname'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_div", "(", "'float-right'", ")", ";", "$", "html", ".=", "$", "this", "->", "search_listitem_actions", "(", "$", "course", ")", ";", "$", "html", ".=", "html_writer", "::", "tag", "(", "'span'", ",", "s", "(", "$", "course", "->", "idnumber", ")", ",", "array", "(", "'class'", "=>", "'dimmed idnumber'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'li'", ")", ";", "return", "$", "html", ";", "}" ]
Renderers a search result course list item. This function will be called for every course being displayed by course_listing. @param core_course_list_element $course The course to produce HTML for. @param int $selectedcourse The id of the currently selected course. @return string
[ "Renderers", "a", "search", "result", "course", "list", "item", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L1176-L1215
219,289
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.course_search_form
public function course_search_form($value = '', $format = 'plain') { static $count = 0; $formid = 'coursesearch'; if ((++$count) > 1) { $formid .= $count; } switch ($format) { case 'navbar' : $formid = 'coursesearchnavbar'; $inputid = 'navsearchbox'; $inputsize = 20; break; case 'short' : $inputid = 'shortsearchbox'; $inputsize = 12; break; default : $inputid = 'coursesearchbox'; $inputsize = 30; } $strsearchcourses = get_string("searchcourses"); $searchurl = new moodle_url('/course/management.php'); $output = html_writer::start_div('row'); $output .= html_writer::start_div('col-md-12'); $output .= html_writer::start_tag('form', array('class' => 'card', 'id' => $formid, 'action' => $searchurl, 'method' => 'get')); $output .= html_writer::start_tag('fieldset', array('class' => 'coursesearchbox invisiblefieldset')); $output .= html_writer::tag('div', $this->output->heading($strsearchcourses.': ', 2, 'm-0'), array('class' => 'card-header')); $output .= html_writer::start_div('card-body'); $output .= html_writer::start_div('input-group col-sm-6 col-lg-4 m-auto'); $output .= html_writer::empty_tag('input', array('class' => 'form-control', 'type' => 'text', 'id' => $inputid, 'size' => $inputsize, 'name' => 'search', 'value' => s($value))); $output .= html_writer::start_tag('span', array('class' => 'input-group-btn')); $output .= html_writer::tag('button', get_string('go'), array('class' => 'btn btn-primary', 'type' => 'submit')); $output .= html_writer::end_tag('span'); $output .= html_writer::end_div(); $output .= html_writer::end_div(); $output .= html_writer::end_tag('fieldset'); $output .= html_writer::end_tag('form'); $output .= html_writer::end_div(); $output .= html_writer::end_div(); return $output; }
php
public function course_search_form($value = '', $format = 'plain') { static $count = 0; $formid = 'coursesearch'; if ((++$count) > 1) { $formid .= $count; } switch ($format) { case 'navbar' : $formid = 'coursesearchnavbar'; $inputid = 'navsearchbox'; $inputsize = 20; break; case 'short' : $inputid = 'shortsearchbox'; $inputsize = 12; break; default : $inputid = 'coursesearchbox'; $inputsize = 30; } $strsearchcourses = get_string("searchcourses"); $searchurl = new moodle_url('/course/management.php'); $output = html_writer::start_div('row'); $output .= html_writer::start_div('col-md-12'); $output .= html_writer::start_tag('form', array('class' => 'card', 'id' => $formid, 'action' => $searchurl, 'method' => 'get')); $output .= html_writer::start_tag('fieldset', array('class' => 'coursesearchbox invisiblefieldset')); $output .= html_writer::tag('div', $this->output->heading($strsearchcourses.': ', 2, 'm-0'), array('class' => 'card-header')); $output .= html_writer::start_div('card-body'); $output .= html_writer::start_div('input-group col-sm-6 col-lg-4 m-auto'); $output .= html_writer::empty_tag('input', array('class' => 'form-control', 'type' => 'text', 'id' => $inputid, 'size' => $inputsize, 'name' => 'search', 'value' => s($value))); $output .= html_writer::start_tag('span', array('class' => 'input-group-btn')); $output .= html_writer::tag('button', get_string('go'), array('class' => 'btn btn-primary', 'type' => 'submit')); $output .= html_writer::end_tag('span'); $output .= html_writer::end_div(); $output .= html_writer::end_div(); $output .= html_writer::end_tag('fieldset'); $output .= html_writer::end_tag('form'); $output .= html_writer::end_div(); $output .= html_writer::end_div(); return $output; }
[ "public", "function", "course_search_form", "(", "$", "value", "=", "''", ",", "$", "format", "=", "'plain'", ")", "{", "static", "$", "count", "=", "0", ";", "$", "formid", "=", "'coursesearch'", ";", "if", "(", "(", "++", "$", "count", ")", ">", "1", ")", "{", "$", "formid", ".=", "$", "count", ";", "}", "switch", "(", "$", "format", ")", "{", "case", "'navbar'", ":", "$", "formid", "=", "'coursesearchnavbar'", ";", "$", "inputid", "=", "'navsearchbox'", ";", "$", "inputsize", "=", "20", ";", "break", ";", "case", "'short'", ":", "$", "inputid", "=", "'shortsearchbox'", ";", "$", "inputsize", "=", "12", ";", "break", ";", "default", ":", "$", "inputid", "=", "'coursesearchbox'", ";", "$", "inputsize", "=", "30", ";", "}", "$", "strsearchcourses", "=", "get_string", "(", "\"searchcourses\"", ")", ";", "$", "searchurl", "=", "new", "moodle_url", "(", "'/course/management.php'", ")", ";", "$", "output", "=", "html_writer", "::", "start_div", "(", "'row'", ")", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'col-md-12'", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'form'", ",", "array", "(", "'class'", "=>", "'card'", ",", "'id'", "=>", "$", "formid", ",", "'action'", "=>", "$", "searchurl", ",", "'method'", "=>", "'get'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'fieldset'", ",", "array", "(", "'class'", "=>", "'coursesearchbox invisiblefieldset'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "$", "this", "->", "output", "->", "heading", "(", "$", "strsearchcourses", ".", "': '", ",", "2", ",", "'m-0'", ")", ",", "array", "(", "'class'", "=>", "'card-header'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'card-body'", ")", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'input-group col-sm-6 col-lg-4 m-auto'", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'class'", "=>", "'form-control'", ",", "'type'", "=>", "'text'", ",", "'id'", "=>", "$", "inputid", ",", "'size'", "=>", "$", "inputsize", ",", "'name'", "=>", "'search'", ",", "'value'", "=>", "s", "(", "$", "value", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'span'", ",", "array", "(", "'class'", "=>", "'input-group-btn'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'button'", ",", "get_string", "(", "'go'", ")", ",", "array", "(", "'class'", "=>", "'btn btn-primary'", ",", "'type'", "=>", "'submit'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'span'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "output", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'fieldset'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'form'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_div", "(", ")", ";", "$", "output", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "output", ";", "}" ]
Renders html to display a course search form @param string $value default value to populate the search field @param string $format display format - 'plain' (default), 'short' or 'navbar' @return string
[ "Renders", "html", "to", "display", "a", "course", "search", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L1277-L1324
219,290
moodle/moodle
course/classes/management_renderer.php
core_course_management_renderer.accessible_skipto_links
public function accessible_skipto_links($displaycategorylisting, $displaycourselisting, $displaycoursedetail) { $html = html_writer::start_div('skiplinks accesshide'); $url = new moodle_url($this->page->url); if ($displaycategorylisting) { $url->set_anchor('category-listing'); $html .= html_writer::link($url, get_string('skiptocategorylisting'), array('class' => 'skip')); } if ($displaycourselisting) { $url->set_anchor('course-listing'); $html .= html_writer::link($url, get_string('skiptocourselisting'), array('class' => 'skip')); } if ($displaycoursedetail) { $url->set_anchor('course-detail'); $html .= html_writer::link($url, get_string('skiptocoursedetails'), array('class' => 'skip')); } $html .= html_writer::end_div(); return $html; }
php
public function accessible_skipto_links($displaycategorylisting, $displaycourselisting, $displaycoursedetail) { $html = html_writer::start_div('skiplinks accesshide'); $url = new moodle_url($this->page->url); if ($displaycategorylisting) { $url->set_anchor('category-listing'); $html .= html_writer::link($url, get_string('skiptocategorylisting'), array('class' => 'skip')); } if ($displaycourselisting) { $url->set_anchor('course-listing'); $html .= html_writer::link($url, get_string('skiptocourselisting'), array('class' => 'skip')); } if ($displaycoursedetail) { $url->set_anchor('course-detail'); $html .= html_writer::link($url, get_string('skiptocoursedetails'), array('class' => 'skip')); } $html .= html_writer::end_div(); return $html; }
[ "public", "function", "accessible_skipto_links", "(", "$", "displaycategorylisting", ",", "$", "displaycourselisting", ",", "$", "displaycoursedetail", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'skiplinks accesshide'", ")", ";", "$", "url", "=", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ")", ";", "if", "(", "$", "displaycategorylisting", ")", "{", "$", "url", "->", "set_anchor", "(", "'category-listing'", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "url", ",", "get_string", "(", "'skiptocategorylisting'", ")", ",", "array", "(", "'class'", "=>", "'skip'", ")", ")", ";", "}", "if", "(", "$", "displaycourselisting", ")", "{", "$", "url", "->", "set_anchor", "(", "'course-listing'", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "url", ",", "get_string", "(", "'skiptocourselisting'", ")", ",", "array", "(", "'class'", "=>", "'skip'", ")", ")", ";", "}", "if", "(", "$", "displaycoursedetail", ")", "{", "$", "url", "->", "set_anchor", "(", "'course-detail'", ")", ";", "$", "html", ".=", "html_writer", "::", "link", "(", "$", "url", ",", "get_string", "(", "'skiptocoursedetails'", ")", ",", "array", "(", "'class'", "=>", "'skip'", ")", ")", ";", "}", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Creates access hidden skip to links for the displayed sections. @param bool $displaycategorylisting @param bool $displaycourselisting @param bool $displaycoursedetail @return string
[ "Creates", "access", "hidden", "skip", "to", "links", "for", "the", "displayed", "sections", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/management_renderer.php#L1334-L1351
219,291
moodle/moodle
lib/spout/src/Spout/Writer/ODS/Internal/Worksheet.php
Worksheet.getTableElementStartAsString
public function getTableElementStartAsString() { $escapedSheetName = $this->stringsEscaper->escape($this->externalSheet->getName()); $tableStyleName = 'ta' . ($this->externalSheet->getIndex() + 1); $tableElement = '<table:table table:style-name="' . $tableStyleName . '" table:name="' . $escapedSheetName . '">'; $tableElement .= '<table:table-column table:default-cell-style-name="ce1" table:style-name="co1" table:number-columns-repeated="' . $this->maxNumColumns . '"/>'; return $tableElement; }
php
public function getTableElementStartAsString() { $escapedSheetName = $this->stringsEscaper->escape($this->externalSheet->getName()); $tableStyleName = 'ta' . ($this->externalSheet->getIndex() + 1); $tableElement = '<table:table table:style-name="' . $tableStyleName . '" table:name="' . $escapedSheetName . '">'; $tableElement .= '<table:table-column table:default-cell-style-name="ce1" table:style-name="co1" table:number-columns-repeated="' . $this->maxNumColumns . '"/>'; return $tableElement; }
[ "public", "function", "getTableElementStartAsString", "(", ")", "{", "$", "escapedSheetName", "=", "$", "this", "->", "stringsEscaper", "->", "escape", "(", "$", "this", "->", "externalSheet", "->", "getName", "(", ")", ")", ";", "$", "tableStyleName", "=", "'ta'", ".", "(", "$", "this", "->", "externalSheet", "->", "getIndex", "(", ")", "+", "1", ")", ";", "$", "tableElement", "=", "'<table:table table:style-name=\"'", ".", "$", "tableStyleName", ".", "'\" table:name=\"'", ".", "$", "escapedSheetName", ".", "'\">'", ";", "$", "tableElement", ".=", "'<table:table-column table:default-cell-style-name=\"ce1\" table:style-name=\"co1\" table:number-columns-repeated=\"'", ".", "$", "this", "->", "maxNumColumns", ".", "'\"/>'", ";", "return", "$", "tableElement", ";", "}" ]
Returns the table XML root node as string. @return string <table> node as string
[ "Returns", "the", "table", "XML", "root", "node", "as", "string", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/ODS/Internal/Worksheet.php#L98-L107
219,292
moodle/moodle
lib/spout/src/Spout/Writer/ODS/Internal/Worksheet.php
Worksheet.getCellXML
protected function getCellXML($cellValue, $styleIndex, $numTimesValueRepeated) { $data = '<table:table-cell table:style-name="ce' . $styleIndex . '"'; if ($numTimesValueRepeated !== 1) { $data .= ' table:number-columns-repeated="' . $numTimesValueRepeated . '"'; } if (CellHelper::isNonEmptyString($cellValue)) { $data .= ' office:value-type="string" calcext:value-type="string">'; $cellValueLines = explode("\n", $cellValue); foreach ($cellValueLines as $cellValueLine) { $data .= '<text:p>' . $this->stringsEscaper->escape($cellValueLine) . '</text:p>'; } $data .= '</table:table-cell>'; } else if (CellHelper::isBoolean($cellValue)) { $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $cellValue . '">'; $data .= '<text:p>' . $cellValue . '</text:p>'; $data .= '</table:table-cell>'; } else if (CellHelper::isNumeric($cellValue)) { $data .= ' office:value-type="float" calcext:value-type="float" office:value="' . $cellValue . '">'; $data .= '<text:p>' . $cellValue . '</text:p>'; $data .= '</table:table-cell>'; } else if (empty($cellValue)) { $data .= '/>'; } else { throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } return $data; }
php
protected function getCellXML($cellValue, $styleIndex, $numTimesValueRepeated) { $data = '<table:table-cell table:style-name="ce' . $styleIndex . '"'; if ($numTimesValueRepeated !== 1) { $data .= ' table:number-columns-repeated="' . $numTimesValueRepeated . '"'; } if (CellHelper::isNonEmptyString($cellValue)) { $data .= ' office:value-type="string" calcext:value-type="string">'; $cellValueLines = explode("\n", $cellValue); foreach ($cellValueLines as $cellValueLine) { $data .= '<text:p>' . $this->stringsEscaper->escape($cellValueLine) . '</text:p>'; } $data .= '</table:table-cell>'; } else if (CellHelper::isBoolean($cellValue)) { $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $cellValue . '">'; $data .= '<text:p>' . $cellValue . '</text:p>'; $data .= '</table:table-cell>'; } else if (CellHelper::isNumeric($cellValue)) { $data .= ' office:value-type="float" calcext:value-type="float" office:value="' . $cellValue . '">'; $data .= '<text:p>' . $cellValue . '</text:p>'; $data .= '</table:table-cell>'; } else if (empty($cellValue)) { $data .= '/>'; } else { throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } return $data; }
[ "protected", "function", "getCellXML", "(", "$", "cellValue", ",", "$", "styleIndex", ",", "$", "numTimesValueRepeated", ")", "{", "$", "data", "=", "'<table:table-cell table:style-name=\"ce'", ".", "$", "styleIndex", ".", "'\"'", ";", "if", "(", "$", "numTimesValueRepeated", "!==", "1", ")", "{", "$", "data", ".=", "' table:number-columns-repeated=\"'", ".", "$", "numTimesValueRepeated", ".", "'\"'", ";", "}", "if", "(", "CellHelper", "::", "isNonEmptyString", "(", "$", "cellValue", ")", ")", "{", "$", "data", ".=", "' office:value-type=\"string\" calcext:value-type=\"string\">'", ";", "$", "cellValueLines", "=", "explode", "(", "\"\\n\"", ",", "$", "cellValue", ")", ";", "foreach", "(", "$", "cellValueLines", "as", "$", "cellValueLine", ")", "{", "$", "data", ".=", "'<text:p>'", ".", "$", "this", "->", "stringsEscaper", "->", "escape", "(", "$", "cellValueLine", ")", ".", "'</text:p>'", ";", "}", "$", "data", ".=", "'</table:table-cell>'", ";", "}", "else", "if", "(", "CellHelper", "::", "isBoolean", "(", "$", "cellValue", ")", ")", "{", "$", "data", ".=", "' office:value-type=\"boolean\" calcext:value-type=\"boolean\" office:boolean-value=\"'", ".", "$", "cellValue", ".", "'\">'", ";", "$", "data", ".=", "'<text:p>'", ".", "$", "cellValue", ".", "'</text:p>'", ";", "$", "data", ".=", "'</table:table-cell>'", ";", "}", "else", "if", "(", "CellHelper", "::", "isNumeric", "(", "$", "cellValue", ")", ")", "{", "$", "data", ".=", "' office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"'", ".", "$", "cellValue", ".", "'\">'", ";", "$", "data", ".=", "'<text:p>'", ".", "$", "cellValue", ".", "'</text:p>'", ";", "$", "data", ".=", "'</table:table-cell>'", ";", "}", "else", "if", "(", "empty", "(", "$", "cellValue", ")", ")", "{", "$", "data", ".=", "'/>'", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Trying to add a value with an unsupported type: '", ".", "gettype", "(", "$", "cellValue", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Returns the cell XML content, given its value. @param mixed $cellValue The value to be written @param int $styleIndex Index of the used style @param int $numTimesValueRepeated Number of times the value is consecutively repeated @return string The cell XML content @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported
[ "Returns", "the", "cell", "XML", "content", "given", "its", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/ODS/Internal/Worksheet.php#L186-L218
219,293
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_my_data_requests_page
public function render_my_data_requests_page(my_data_requests_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/my_data_requests', $data); }
php
public function render_my_data_requests_page(my_data_requests_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/my_data_requests', $data); }
[ "public", "function", "render_my_data_requests_page", "(", "my_data_requests_page", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/my_data_requests'", ",", "$", "data", ")", ";", "}" ]
Render the user's data requests page. @param my_data_requests_page $page @return string html for the page @throws moodle_exception
[ "Render", "the", "user", "s", "data", "requests", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L50-L53
219,294
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_data_requests_page
public function render_data_requests_page(data_requests_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_requests', $data); }
php
public function render_data_requests_page(data_requests_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_requests', $data); }
[ "public", "function", "render_data_requests_page", "(", "data_requests_page", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/data_requests'", ",", "$", "data", ")", ";", "}" ]
Render the data requests page for the DPO. @param data_requests_page $page @return string html for the page @throws moodle_exception
[ "Render", "the", "data", "requests", "page", "for", "the", "DPO", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L78-L81
219,295
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_data_registry_page
public function render_data_registry_page(data_registry_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_registry', $data); }
php
public function render_data_registry_page(data_registry_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_registry', $data); }
[ "public", "function", "render_data_registry_page", "(", "data_registry_page", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/data_registry'", ",", "$", "data", ")", ";", "}" ]
Render the data registry. @param data_registry_page $page @return string html for the page @throws moodle_exception
[ "Render", "the", "data", "registry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L90-L93
219,296
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_data_registry_compliance_page
public function render_data_registry_compliance_page(data_registry_compliance_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_registry_compliance', $data); }
php
public function render_data_registry_compliance_page(data_registry_compliance_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_registry_compliance', $data); }
[ "public", "function", "render_data_registry_compliance_page", "(", "data_registry_compliance_page", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/data_registry_compliance'", ",", "$", "data", ")", ";", "}" ]
Render the data compliance registry. @param data_registry_compliance_page $page @return string html for the page @throws moodle_exception
[ "Render", "the", "data", "compliance", "registry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L102-L105
219,297
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_purposes
public function render_purposes(purposes $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/purposes', $data); }
php
public function render_purposes(purposes $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/purposes', $data); }
[ "public", "function", "render_purposes", "(", "purposes", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/purposes'", ",", "$", "data", ")", ";", "}" ]
Render the purposes management page. @param purposes $page @return string html for the page @throws moodle_exception
[ "Render", "the", "purposes", "management", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L114-L117
219,298
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_categories
public function render_categories(categories $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/categories', $data); }
php
public function render_categories(categories $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/categories', $data); }
[ "public", "function", "render_categories", "(", "categories", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/categories'", ",", "$", "data", ")", ";", "}" ]
Render the categories management page. @param categories $page @return string html for the page @throws moodle_exception
[ "Render", "the", "categories", "management", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L126-L129
219,299
moodle/moodle
admin/tool/dataprivacy/classes/output/renderer.php
renderer.render_data_deletion_page
public function render_data_deletion_page(data_deletion_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_deletion', $data); }
php
public function render_data_deletion_page(data_deletion_page $page) { $data = $page->export_for_template($this); return parent::render_from_template('tool_dataprivacy/data_deletion', $data); }
[ "public", "function", "render_data_deletion_page", "(", "data_deletion_page", "$", "page", ")", "{", "$", "data", "=", "$", "page", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'tool_dataprivacy/data_deletion'", ",", "$", "data", ")", ";", "}" ]
Render the review page for the deletion of expired contexts. @param data_deletion_page $page @return string html for the page @throws moodle_exception
[ "Render", "the", "review", "page", "for", "the", "deletion", "of", "expired", "contexts", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/renderer.php#L138-L141