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
217,400
moodle/moodle
lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.listifyObjectList
protected function listifyObjectList($array) { ksort($array); $list = array(); foreach ($array as $obj) { $list[] = $this->getClass($obj, 'AttrTransform_'); } return $this->listify($list); }
php
protected function listifyObjectList($array) { ksort($array); $list = array(); foreach ($array as $obj) { $list[] = $this->getClass($obj, 'AttrTransform_'); } return $this->listify($list); }
[ "protected", "function", "listifyObjectList", "(", "$", "array", ")", "{", "ksort", "(", "$", "array", ")", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "obj", ")", "{", "$", "list", "[", "]", "=", "$", "this", "->", "getClass", "(", "$", "obj", ",", "'AttrTransform_'", ")", ";", "}", "return", "$", "this", "->", "listify", "(", "$", "list", ")", ";", "}" ]
Listifies a list of objects by retrieving class names and internal state @param array $array List of objects @return string @todo Also add information about internal state
[ "Listifies", "a", "list", "of", "objects", "by", "retrieving", "class", "names", "and", "internal", "state" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php#L280-L288
217,401
moodle/moodle
lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.heavyHeader
protected function heavyHeader($text, $num = 1) { $ret = ''; $ret .= $this->start('tr'); $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); $ret .= $this->end('tr'); return $ret; }
php
protected function heavyHeader($text, $num = 1) { $ret = ''; $ret .= $this->start('tr'); $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); $ret .= $this->end('tr'); return $ret; }
[ "protected", "function", "heavyHeader", "(", "$", "text", ",", "$", "num", "=", "1", ")", "{", "$", "ret", "=", "''", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "$", "text", ",", "array", "(", "'colspan'", "=>", "$", "num", ",", "'class'", "=>", "'heavy'", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "return", "$", "ret", ";", "}" ]
Creates a heavy header row @param string $text @param int $num @return string
[ "Creates", "a", "heavy", "header", "row" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php#L314-L321
217,402
moodle/moodle
lib/pear/HTML/QuickForm/Rule/Range.php
HTML_QuickForm_Rule_Range.validate
function validate($value, $options = null) { $length = core_text::strlen($value); switch ($this->name) { case 'minlength': return ($length >= $options); case 'maxlength': return ($length <= $options); default: return ($length >= $options[0] && $length <= $options[1]); } }
php
function validate($value, $options = null) { $length = core_text::strlen($value); switch ($this->name) { case 'minlength': return ($length >= $options); case 'maxlength': return ($length <= $options); default: return ($length >= $options[0] && $length <= $options[1]); } }
[ "function", "validate", "(", "$", "value", ",", "$", "options", "=", "null", ")", "{", "$", "length", "=", "core_text", "::", "strlen", "(", "$", "value", ")", ";", "switch", "(", "$", "this", "->", "name", ")", "{", "case", "'minlength'", ":", "return", "(", "$", "length", ">=", "$", "options", ")", ";", "case", "'maxlength'", ":", "return", "(", "$", "length", "<=", "$", "options", ")", ";", "default", ":", "return", "(", "$", "length", ">=", "$", "options", "[", "0", "]", "&&", "$", "length", "<=", "$", "options", "[", "1", "]", ")", ";", "}", "}" ]
Validates a value using a range comparison @param string $value Value to be checked @param mixed $options Int for length, array for range @access public @return boolean true if value is valid
[ "Validates", "a", "value", "using", "a", "range", "comparison" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Rule/Range.php#L37-L45
217,403
moodle/moodle
lib/pear/HTML/QuickForm/Rule/Range.php
HTML_QuickForm_Rule_Range.getValidationScript
function getValidationScript($options = null) { switch ($this->name) { case 'minlength': $test = '{jsVar}.length < '.$options; break; case 'maxlength': $test = '{jsVar}.length > '.$options; break; default: $test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')'; } return array('', "{jsVar} != '' && {$test}"); }
php
function getValidationScript($options = null) { switch ($this->name) { case 'minlength': $test = '{jsVar}.length < '.$options; break; case 'maxlength': $test = '{jsVar}.length > '.$options; break; default: $test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')'; } return array('', "{jsVar} != '' && {$test}"); }
[ "function", "getValidationScript", "(", "$", "options", "=", "null", ")", "{", "switch", "(", "$", "this", "->", "name", ")", "{", "case", "'minlength'", ":", "$", "test", "=", "'{jsVar}.length < '", ".", "$", "options", ";", "break", ";", "case", "'maxlength'", ":", "$", "test", "=", "'{jsVar}.length > '", ".", "$", "options", ";", "break", ";", "default", ":", "$", "test", "=", "'({jsVar}.length < '", ".", "$", "options", "[", "0", "]", ".", "' || {jsVar}.length > '", ".", "$", "options", "[", "1", "]", ".", "')'", ";", "}", "return", "array", "(", "''", ",", "\"{jsVar} != '' && {$test}\"", ")", ";", "}" ]
end func validate
[ "end", "func", "validate" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Rule/Range.php#L48-L61
217,404
moodle/moodle
portfolio/mahara/lib.php
portfolio_plugin_mahara.send_intent
public function send_intent() { global $CFG, $DB; require_once($CFG->dirroot . '/mnet/xmlrpc/client.php'); $client = new mnet_xmlrpc_client(); $client->set_method('portfolio/mahara/lib.php/send_content_intent'); $client->add_param($this->get('user')->username); $this->ensure_mnethost(); if (!$client->send($this->mnethost)) { foreach ($client->error as $errormessage) { list($code, $message) = array_map('trim',explode(':', $errormessage, 2)); $message .= "ERROR $code:<br/>$errormessage<br/>"; } throw new portfolio_export_exception($this->get('exporter'), 'failedtoping', 'portfolio_mahara', '', $message); } // we should get back... the send type and a shared token $response = (object)$client->response; if (empty($response->sendtype) || empty($response->token)) { throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara'); } switch ($response->sendtype) { case 'immediate': $this->sendtype = PORTFOLIO_MAHARA_IMMEDIATE; break; case 'queue': $this->sendtype = PORTFOLIO_MAHARA_QUEUE; break; case 'none': default: throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara'); } $this->token = $response->token; $this->get('exporter')->save(); // put the entry in the mahara queue table now too $q = new stdClass; $q->token = $this->token; $q->transferid = $this->get('exporter')->get('id'); $DB->insert_record('portfolio_mahara_queue', $q); }
php
public function send_intent() { global $CFG, $DB; require_once($CFG->dirroot . '/mnet/xmlrpc/client.php'); $client = new mnet_xmlrpc_client(); $client->set_method('portfolio/mahara/lib.php/send_content_intent'); $client->add_param($this->get('user')->username); $this->ensure_mnethost(); if (!$client->send($this->mnethost)) { foreach ($client->error as $errormessage) { list($code, $message) = array_map('trim',explode(':', $errormessage, 2)); $message .= "ERROR $code:<br/>$errormessage<br/>"; } throw new portfolio_export_exception($this->get('exporter'), 'failedtoping', 'portfolio_mahara', '', $message); } // we should get back... the send type and a shared token $response = (object)$client->response; if (empty($response->sendtype) || empty($response->token)) { throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara'); } switch ($response->sendtype) { case 'immediate': $this->sendtype = PORTFOLIO_MAHARA_IMMEDIATE; break; case 'queue': $this->sendtype = PORTFOLIO_MAHARA_QUEUE; break; case 'none': default: throw new portfolio_export_exception($this->get('exporter'), 'senddisallowed', 'portfolio_mahara'); } $this->token = $response->token; $this->get('exporter')->save(); // put the entry in the mahara queue table now too $q = new stdClass; $q->token = $this->token; $q->transferid = $this->get('exporter')->get('id'); $DB->insert_record('portfolio_mahara_queue', $q); }
[ "public", "function", "send_intent", "(", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mnet/xmlrpc/client.php'", ")", ";", "$", "client", "=", "new", "mnet_xmlrpc_client", "(", ")", ";", "$", "client", "->", "set_method", "(", "'portfolio/mahara/lib.php/send_content_intent'", ")", ";", "$", "client", "->", "add_param", "(", "$", "this", "->", "get", "(", "'user'", ")", "->", "username", ")", ";", "$", "this", "->", "ensure_mnethost", "(", ")", ";", "if", "(", "!", "$", "client", "->", "send", "(", "$", "this", "->", "mnethost", ")", ")", "{", "foreach", "(", "$", "client", "->", "error", "as", "$", "errormessage", ")", "{", "list", "(", "$", "code", ",", "$", "message", ")", "=", "array_map", "(", "'trim'", ",", "explode", "(", "':'", ",", "$", "errormessage", ",", "2", ")", ")", ";", "$", "message", ".=", "\"ERROR $code:<br/>$errormessage<br/>\"", ";", "}", "throw", "new", "portfolio_export_exception", "(", "$", "this", "->", "get", "(", "'exporter'", ")", ",", "'failedtoping'", ",", "'portfolio_mahara'", ",", "''", ",", "$", "message", ")", ";", "}", "// we should get back... the send type and a shared token", "$", "response", "=", "(", "object", ")", "$", "client", "->", "response", ";", "if", "(", "empty", "(", "$", "response", "->", "sendtype", ")", "||", "empty", "(", "$", "response", "->", "token", ")", ")", "{", "throw", "new", "portfolio_export_exception", "(", "$", "this", "->", "get", "(", "'exporter'", ")", ",", "'senddisallowed'", ",", "'portfolio_mahara'", ")", ";", "}", "switch", "(", "$", "response", "->", "sendtype", ")", "{", "case", "'immediate'", ":", "$", "this", "->", "sendtype", "=", "PORTFOLIO_MAHARA_IMMEDIATE", ";", "break", ";", "case", "'queue'", ":", "$", "this", "->", "sendtype", "=", "PORTFOLIO_MAHARA_QUEUE", ";", "break", ";", "case", "'none'", ":", "default", ":", "throw", "new", "portfolio_export_exception", "(", "$", "this", "->", "get", "(", "'exporter'", ")", ",", "'senddisallowed'", ",", "'portfolio_mahara'", ")", ";", "}", "$", "this", "->", "token", "=", "$", "response", "->", "token", ";", "$", "this", "->", "get", "(", "'exporter'", ")", "->", "save", "(", ")", ";", "// put the entry in the mahara queue table now too", "$", "q", "=", "new", "stdClass", ";", "$", "q", "->", "token", "=", "$", "this", "->", "token", ";", "$", "q", "->", "transferid", "=", "$", "this", "->", "get", "(", "'exporter'", ")", "->", "get", "(", "'id'", ")", ";", "$", "DB", "->", "insert_record", "(", "'portfolio_mahara_queue'", ",", "$", "q", ")", ";", "}" ]
sends the 'content_intent' ping to mahara if all goes well, this will set the 'token' and 'sendtype' member variables.
[ "sends", "the", "content_intent", "ping", "to", "mahara", "if", "all", "goes", "well", "this", "will", "set", "the", "token", "and", "sendtype", "member", "variables", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/portfolio/mahara/lib.php#L270-L307
217,405
moodle/moodle
search/classes/area_category.php
area_category.set_areas
public function set_areas(array $areas) { foreach ($areas as $area) { if ($area instanceof base && !key_exists($area->get_area_id(), $this->areas)) { $this->areas[$area->get_area_id()] = $area; } } }
php
public function set_areas(array $areas) { foreach ($areas as $area) { if ($area instanceof base && !key_exists($area->get_area_id(), $this->areas)) { $this->areas[$area->get_area_id()] = $area; } } }
[ "public", "function", "set_areas", "(", "array", "$", "areas", ")", "{", "foreach", "(", "$", "areas", "as", "$", "area", ")", "{", "if", "(", "$", "area", "instanceof", "base", "&&", "!", "key_exists", "(", "$", "area", "->", "get_area_id", "(", ")", ",", "$", "this", "->", "areas", ")", ")", "{", "$", "this", "->", "areas", "[", "$", "area", "->", "get_area_id", "(", ")", "]", "=", "$", "area", ";", "}", "}", "}" ]
Set list of search areas for this category, @param \core_search\base[] $areas
[ "Set", "list", "of", "search", "areas", "for", "this", "category" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/search/classes/area_category.php#L118-L124
217,406
moodle/moodle
backup/util/structure/backup_nested_element.class.php
backup_nested_element.process
public function process($processor) { if (!$processor instanceof base_processor) { // No correct processor, throw exception throw new base_element_struct_exception('incorrect_processor'); } $iterator = $this->get_iterator($processor); // Get the iterator over backup-able data foreach ($iterator as $key => $values) { // Process each "ocurrrence" of the nested element (recordset or array) // Fill the values of the attributes and final elements with the $values from the iterator $this->fill_values($values); // Perform pre-process tasks for the nested_element $processor->pre_process_nested_element($this); // Delegate the process of each attribute foreach ($this->get_attributes() as $attribute) { $attribute->process($processor); } // Main process tasks for the nested element, once its attributes have been processed $processor->process_nested_element($this); // Delegate the process of each final_element foreach ($this->get_final_elements() as $final_element) { $final_element->process($processor); } // Delegate the process to the optigroup if ($this->get_optigroup()) { $this->get_optigroup()->process($processor); } // Delegate the process to each child nested_element foreach ($this->get_children() as $child) { $child->process($processor); } // Perform post-process tasks for the nested element $processor->post_process_nested_element($this); // Everything processed, clean values before next iteration $this->clean_values(); // Increment counter for this element $this->counter++; // For root element, check we only have 1 element if ($this->get_parent() === null && $this->counter > 1) { throw new base_element_struct_exception('root_only_one_ocurrence', $this->get_name()); } } // Close the iterator (DB recordset / array iterator) $iterator->close(); }
php
public function process($processor) { if (!$processor instanceof base_processor) { // No correct processor, throw exception throw new base_element_struct_exception('incorrect_processor'); } $iterator = $this->get_iterator($processor); // Get the iterator over backup-able data foreach ($iterator as $key => $values) { // Process each "ocurrrence" of the nested element (recordset or array) // Fill the values of the attributes and final elements with the $values from the iterator $this->fill_values($values); // Perform pre-process tasks for the nested_element $processor->pre_process_nested_element($this); // Delegate the process of each attribute foreach ($this->get_attributes() as $attribute) { $attribute->process($processor); } // Main process tasks for the nested element, once its attributes have been processed $processor->process_nested_element($this); // Delegate the process of each final_element foreach ($this->get_final_elements() as $final_element) { $final_element->process($processor); } // Delegate the process to the optigroup if ($this->get_optigroup()) { $this->get_optigroup()->process($processor); } // Delegate the process to each child nested_element foreach ($this->get_children() as $child) { $child->process($processor); } // Perform post-process tasks for the nested element $processor->post_process_nested_element($this); // Everything processed, clean values before next iteration $this->clean_values(); // Increment counter for this element $this->counter++; // For root element, check we only have 1 element if ($this->get_parent() === null && $this->counter > 1) { throw new base_element_struct_exception('root_only_one_ocurrence', $this->get_name()); } } // Close the iterator (DB recordset / array iterator) $iterator->close(); }
[ "public", "function", "process", "(", "$", "processor", ")", "{", "if", "(", "!", "$", "processor", "instanceof", "base_processor", ")", "{", "// No correct processor, throw exception", "throw", "new", "base_element_struct_exception", "(", "'incorrect_processor'", ")", ";", "}", "$", "iterator", "=", "$", "this", "->", "get_iterator", "(", "$", "processor", ")", ";", "// Get the iterator over backup-able data", "foreach", "(", "$", "iterator", "as", "$", "key", "=>", "$", "values", ")", "{", "// Process each \"ocurrrence\" of the nested element (recordset or array)", "// Fill the values of the attributes and final elements with the $values from the iterator", "$", "this", "->", "fill_values", "(", "$", "values", ")", ";", "// Perform pre-process tasks for the nested_element", "$", "processor", "->", "pre_process_nested_element", "(", "$", "this", ")", ";", "// Delegate the process of each attribute", "foreach", "(", "$", "this", "->", "get_attributes", "(", ")", "as", "$", "attribute", ")", "{", "$", "attribute", "->", "process", "(", "$", "processor", ")", ";", "}", "// Main process tasks for the nested element, once its attributes have been processed", "$", "processor", "->", "process_nested_element", "(", "$", "this", ")", ";", "// Delegate the process of each final_element", "foreach", "(", "$", "this", "->", "get_final_elements", "(", ")", "as", "$", "final_element", ")", "{", "$", "final_element", "->", "process", "(", "$", "processor", ")", ";", "}", "// Delegate the process to the optigroup", "if", "(", "$", "this", "->", "get_optigroup", "(", ")", ")", "{", "$", "this", "->", "get_optigroup", "(", ")", "->", "process", "(", "$", "processor", ")", ";", "}", "// Delegate the process to each child nested_element", "foreach", "(", "$", "this", "->", "get_children", "(", ")", "as", "$", "child", ")", "{", "$", "child", "->", "process", "(", "$", "processor", ")", ";", "}", "// Perform post-process tasks for the nested element", "$", "processor", "->", "post_process_nested_element", "(", "$", "this", ")", ";", "// Everything processed, clean values before next iteration", "$", "this", "->", "clean_values", "(", ")", ";", "// Increment counter for this element", "$", "this", "->", "counter", "++", ";", "// For root element, check we only have 1 element", "if", "(", "$", "this", "->", "get_parent", "(", ")", "===", "null", "&&", "$", "this", "->", "counter", ">", "1", ")", "{", "throw", "new", "base_element_struct_exception", "(", "'root_only_one_ocurrence'", ",", "$", "this", "->", "get_name", "(", ")", ")", ";", "}", "}", "// Close the iterator (DB recordset / array iterator)", "$", "iterator", "->", "close", "(", ")", ";", "}" ]
Process the nested element @param object $processor the processor @return void
[ "Process", "the", "nested", "element" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/structure/backup_nested_element.class.php#L72-L126
217,407
moodle/moodle
backup/util/structure/backup_nested_element.class.php
backup_nested_element.add_log
protected function add_log($message, $level, $a = null, $depth = null, $display = false) { // Adding the result to the oldest parent. if ($this->get_parent()) { $parent = $this->get_grandparent(); $parent->add_log($message, $level, $a, $depth, $display); } else { $log = new stdClass(); $log->message = $message; $log->level = $level; $log->a = $a; $log->depth = $depth; $log->display = $display; $this->logs[] = $log; } }
php
protected function add_log($message, $level, $a = null, $depth = null, $display = false) { // Adding the result to the oldest parent. if ($this->get_parent()) { $parent = $this->get_grandparent(); $parent->add_log($message, $level, $a, $depth, $display); } else { $log = new stdClass(); $log->message = $message; $log->level = $level; $log->a = $a; $log->depth = $depth; $log->display = $display; $this->logs[] = $log; } }
[ "protected", "function", "add_log", "(", "$", "message", ",", "$", "level", ",", "$", "a", "=", "null", ",", "$", "depth", "=", "null", ",", "$", "display", "=", "false", ")", "{", "// Adding the result to the oldest parent.", "if", "(", "$", "this", "->", "get_parent", "(", ")", ")", "{", "$", "parent", "=", "$", "this", "->", "get_grandparent", "(", ")", ";", "$", "parent", "->", "add_log", "(", "$", "message", ",", "$", "level", ",", "$", "a", ",", "$", "depth", ",", "$", "display", ")", ";", "}", "else", "{", "$", "log", "=", "new", "stdClass", "(", ")", ";", "$", "log", "->", "message", "=", "$", "message", ";", "$", "log", "->", "level", "=", "$", "level", ";", "$", "log", "->", "a", "=", "$", "a", ";", "$", "log", "->", "depth", "=", "$", "depth", ";", "$", "log", "->", "display", "=", "$", "display", ";", "$", "this", "->", "logs", "[", "]", "=", "$", "log", ";", "}", "}" ]
Saves a log message to an array @see backup_helper::log() @param string $message to add to the logs @param int $level level of importance {@link backup::LOG_DEBUG} and other constants @param mixed $a to be included in $message @param int $depth of the message @param display $bool supporting translation via get_string() if true @return void
[ "Saves", "a", "log", "message", "to", "an", "array" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/structure/backup_nested_element.class.php#L139-L153
217,408
moodle/moodle
backup/util/structure/backup_nested_element.class.php
backup_nested_element.add_result
protected function add_result($result) { if (is_array($result)) { // Adding the result to the oldest parent. if ($this->get_parent()) { $parent = $this->get_grandparent(); $parent->add_result($result); } else { $this->results = array_merge($this->results, $result); } } }
php
protected function add_result($result) { if (is_array($result)) { // Adding the result to the oldest parent. if ($this->get_parent()) { $parent = $this->get_grandparent(); $parent->add_result($result); } else { $this->results = array_merge($this->results, $result); } } }
[ "protected", "function", "add_result", "(", "$", "result", ")", "{", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "// Adding the result to the oldest parent.", "if", "(", "$", "this", "->", "get_parent", "(", ")", ")", "{", "$", "parent", "=", "$", "this", "->", "get_grandparent", "(", ")", ";", "$", "parent", "->", "add_result", "(", "$", "result", ")", ";", "}", "else", "{", "$", "this", "->", "results", "=", "array_merge", "(", "$", "this", "->", "results", ",", "$", "result", ")", ";", "}", "}", "}" ]
Saves the results to an array @param array $result associative array @return void
[ "Saves", "the", "results", "to", "an", "array" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/structure/backup_nested_element.class.php#L161-L171
217,409
moodle/moodle
grade/report/history/classes/helper.php
helper.get_users
public static function get_users($context, $search = '', $page = 0, $perpage = 25) { global $DB; list($sql, $params) = self::get_users_sql_and_params($context, $search); $limitfrom = $page * $perpage; $limitto = $limitfrom + $perpage; $users = $DB->get_records_sql($sql, $params, $limitfrom, $limitto); return $users; }
php
public static function get_users($context, $search = '', $page = 0, $perpage = 25) { global $DB; list($sql, $params) = self::get_users_sql_and_params($context, $search); $limitfrom = $page * $perpage; $limitto = $limitfrom + $perpage; $users = $DB->get_records_sql($sql, $params, $limitfrom, $limitto); return $users; }
[ "public", "static", "function", "get_users", "(", "$", "context", ",", "$", "search", "=", "''", ",", "$", "page", "=", "0", ",", "$", "perpage", "=", "25", ")", "{", "global", "$", "DB", ";", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "self", "::", "get_users_sql_and_params", "(", "$", "context", ",", "$", "search", ")", ";", "$", "limitfrom", "=", "$", "page", "*", "$", "perpage", ";", "$", "limitto", "=", "$", "limitfrom", "+", "$", "perpage", ";", "$", "users", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ",", "$", "limitfrom", ",", "$", "limitto", ")", ";", "return", "$", "users", ";", "}" ]
Retrieve a list of users. We're interested in anyone that had a grade history in this course. This api returns a list of such users based on various criteria passed. @param \context $context Context of the page where the results would be shown. @param string $search the text to search for (empty string = find all). @param int $page page number, defaults to 0. @param int $perpage Number of entries to display per page, defaults to 0. @return array list of users.
[ "Retrieve", "a", "list", "of", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/helper.php#L95-L103
217,410
moodle/moodle
grade/report/history/classes/helper.php
helper.get_users_count
public static function get_users_count($context, $search = '') { global $DB; list($sql, $params) = self::get_users_sql_and_params($context, $search, true); return $DB->count_records_sql($sql, $params); }
php
public static function get_users_count($context, $search = '') { global $DB; list($sql, $params) = self::get_users_sql_and_params($context, $search, true); return $DB->count_records_sql($sql, $params); }
[ "public", "static", "function", "get_users_count", "(", "$", "context", ",", "$", "search", "=", "''", ")", "{", "global", "$", "DB", ";", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "self", "::", "get_users_sql_and_params", "(", "$", "context", ",", "$", "search", ",", "true", ")", ";", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Get total number of users present for the given search criteria. @param \context $context Context of the page where the results would be shown. @param string $search the text to search for (empty string = find all). @return int number of users found.
[ "Get", "total", "number", "of", "users", "present", "for", "the", "given", "search", "criteria", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/helper.php#L113-L119
217,411
moodle/moodle
grade/report/history/classes/helper.php
helper.get_users_sql_and_params
protected static function get_users_sql_and_params($context, $search = '', $count = false) { // Fields we need from the user table. $extrafields = get_extra_user_fields($context); $params = array(); if (!empty($search)) { list($filtersql, $params) = users_search_sql($search, 'u', true, $extrafields); $filtersql .= ' AND '; } else { $filtersql = ''; } $ufields = \user_picture::fields('u', $extrafields).',u.username'; if ($count) { $select = "SELECT COUNT(DISTINCT u.id) "; $orderby = ""; } else { $select = "SELECT DISTINCT $ufields "; $orderby = " ORDER BY u.lastname ASC, u.firstname ASC"; } $sql = "$select FROM {user} u JOIN {grade_grades_history} ggh ON u.id = ggh.userid JOIN {grade_items} gi ON gi.id = ggh.itemid WHERE $filtersql gi.courseid = :courseid"; $sql .= $orderby; $params['courseid'] = $context->instanceid; return array($sql, $params); }
php
protected static function get_users_sql_and_params($context, $search = '', $count = false) { // Fields we need from the user table. $extrafields = get_extra_user_fields($context); $params = array(); if (!empty($search)) { list($filtersql, $params) = users_search_sql($search, 'u', true, $extrafields); $filtersql .= ' AND '; } else { $filtersql = ''; } $ufields = \user_picture::fields('u', $extrafields).',u.username'; if ($count) { $select = "SELECT COUNT(DISTINCT u.id) "; $orderby = ""; } else { $select = "SELECT DISTINCT $ufields "; $orderby = " ORDER BY u.lastname ASC, u.firstname ASC"; } $sql = "$select FROM {user} u JOIN {grade_grades_history} ggh ON u.id = ggh.userid JOIN {grade_items} gi ON gi.id = ggh.itemid WHERE $filtersql gi.courseid = :courseid"; $sql .= $orderby; $params['courseid'] = $context->instanceid; return array($sql, $params); }
[ "protected", "static", "function", "get_users_sql_and_params", "(", "$", "context", ",", "$", "search", "=", "''", ",", "$", "count", "=", "false", ")", "{", "// Fields we need from the user table.", "$", "extrafields", "=", "get_extra_user_fields", "(", "$", "context", ")", ";", "$", "params", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "search", ")", ")", "{", "list", "(", "$", "filtersql", ",", "$", "params", ")", "=", "users_search_sql", "(", "$", "search", ",", "'u'", ",", "true", ",", "$", "extrafields", ")", ";", "$", "filtersql", ".=", "' AND '", ";", "}", "else", "{", "$", "filtersql", "=", "''", ";", "}", "$", "ufields", "=", "\\", "user_picture", "::", "fields", "(", "'u'", ",", "$", "extrafields", ")", ".", "',u.username'", ";", "if", "(", "$", "count", ")", "{", "$", "select", "=", "\"SELECT COUNT(DISTINCT u.id) \"", ";", "$", "orderby", "=", "\"\"", ";", "}", "else", "{", "$", "select", "=", "\"SELECT DISTINCT $ufields \"", ";", "$", "orderby", "=", "\" ORDER BY u.lastname ASC, u.firstname ASC\"", ";", "}", "$", "sql", "=", "\"$select\n FROM {user} u\n JOIN {grade_grades_history} ggh ON u.id = ggh.userid\n JOIN {grade_items} gi ON gi.id = ggh.itemid\n WHERE $filtersql gi.courseid = :courseid\"", ";", "$", "sql", ".=", "$", "orderby", ";", "$", "params", "[", "'courseid'", "]", "=", "$", "context", "->", "instanceid", ";", "return", "array", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Get sql and params to use to get list of users. @param \context $context Context of the page where the results would be shown. @param string $search the text to search for (empty string = find all). @param bool $count setting this to true, returns an sql to get count only instead of the complete data records. @return array sql and params list
[ "Get", "sql", "and", "params", "to", "use", "to", "get", "list", "of", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/helper.php#L130-L159
217,412
moodle/moodle
grade/report/history/classes/helper.php
helper.get_graders
public static function get_graders($courseid) { global $DB; $ufields = get_all_user_name_fields(true, 'u'); $sql = "SELECT u.id, $ufields FROM {user} u JOIN {grade_grades_history} ggh ON ggh.usermodified = u.id JOIN {grade_items} gi ON gi.id = ggh.itemid WHERE gi.courseid = :courseid GROUP BY u.id, $ufields ORDER BY u.lastname ASC, u.firstname ASC"; $graders = $DB->get_records_sql($sql, array('courseid' => $courseid)); $return = array(0 => get_string('allgraders', 'gradereport_history')); foreach ($graders as $grader) { $return[$grader->id] = fullname($grader); } return $return; }
php
public static function get_graders($courseid) { global $DB; $ufields = get_all_user_name_fields(true, 'u'); $sql = "SELECT u.id, $ufields FROM {user} u JOIN {grade_grades_history} ggh ON ggh.usermodified = u.id JOIN {grade_items} gi ON gi.id = ggh.itemid WHERE gi.courseid = :courseid GROUP BY u.id, $ufields ORDER BY u.lastname ASC, u.firstname ASC"; $graders = $DB->get_records_sql($sql, array('courseid' => $courseid)); $return = array(0 => get_string('allgraders', 'gradereport_history')); foreach ($graders as $grader) { $return[$grader->id] = fullname($grader); } return $return; }
[ "public", "static", "function", "get_graders", "(", "$", "courseid", ")", "{", "global", "$", "DB", ";", "$", "ufields", "=", "get_all_user_name_fields", "(", "true", ",", "'u'", ")", ";", "$", "sql", "=", "\"SELECT u.id, $ufields\n FROM {user} u\n JOIN {grade_grades_history} ggh ON ggh.usermodified = u.id\n JOIN {grade_items} gi ON gi.id = ggh.itemid\n WHERE gi.courseid = :courseid\n GROUP BY u.id, $ufields\n ORDER BY u.lastname ASC, u.firstname ASC\"", ";", "$", "graders", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ")", ")", ";", "$", "return", "=", "array", "(", "0", "=>", "get_string", "(", "'allgraders'", ",", "'gradereport_history'", ")", ")", ";", "foreach", "(", "$", "graders", "as", "$", "grader", ")", "{", "$", "return", "[", "$", "grader", "->", "id", "]", "=", "fullname", "(", "$", "grader", ")", ";", "}", "return", "$", "return", ";", "}" ]
Get a list of graders. @param int $courseid Id of course for which we need to fetch graders. @return array list of graders.
[ "Get", "a", "list", "of", "graders", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/helper.php#L168-L186
217,413
moodle/moodle
grade/grading/form/rubric/backup/moodle2/backup_gradingform_rubric_plugin.class.php
backup_gradingform_rubric_plugin.define_definition_plugin_structure
protected function define_definition_plugin_structure() { // Append data only if the grand-parent element has 'method' set to 'rubric' $plugin = $this->get_plugin_element(null, '../../method', 'rubric'); // Create a visible container for our data $pluginwrapper = new backup_nested_element($this->get_recommended_name()); // Connect our visible container to the parent $plugin->add_child($pluginwrapper); // Define our elements $criteria = new backup_nested_element('criteria'); $criterion = new backup_nested_element('criterion', array('id'), array( 'sortorder', 'description', 'descriptionformat')); $levels = new backup_nested_element('levels'); $level = new backup_nested_element('level', array('id'), array( 'score', 'definition', 'definitionformat')); // Build elements hierarchy $pluginwrapper->add_child($criteria); $criteria->add_child($criterion); $criterion->add_child($levels); $levels->add_child($level); // Set sources to populate the data $criterion->set_source_table('gradingform_rubric_criteria', array('definitionid' => backup::VAR_PARENTID)); $level->set_source_table('gradingform_rubric_levels', array('criterionid' => backup::VAR_PARENTID)); // no need to annotate ids or files yet (one day when criterion definition supports // embedded files, they must be annotated here) return $plugin; }
php
protected function define_definition_plugin_structure() { // Append data only if the grand-parent element has 'method' set to 'rubric' $plugin = $this->get_plugin_element(null, '../../method', 'rubric'); // Create a visible container for our data $pluginwrapper = new backup_nested_element($this->get_recommended_name()); // Connect our visible container to the parent $plugin->add_child($pluginwrapper); // Define our elements $criteria = new backup_nested_element('criteria'); $criterion = new backup_nested_element('criterion', array('id'), array( 'sortorder', 'description', 'descriptionformat')); $levels = new backup_nested_element('levels'); $level = new backup_nested_element('level', array('id'), array( 'score', 'definition', 'definitionformat')); // Build elements hierarchy $pluginwrapper->add_child($criteria); $criteria->add_child($criterion); $criterion->add_child($levels); $levels->add_child($level); // Set sources to populate the data $criterion->set_source_table('gradingform_rubric_criteria', array('definitionid' => backup::VAR_PARENTID)); $level->set_source_table('gradingform_rubric_levels', array('criterionid' => backup::VAR_PARENTID)); // no need to annotate ids or files yet (one day when criterion definition supports // embedded files, they must be annotated here) return $plugin; }
[ "protected", "function", "define_definition_plugin_structure", "(", ")", "{", "// Append data only if the grand-parent element has 'method' set to 'rubric'", "$", "plugin", "=", "$", "this", "->", "get_plugin_element", "(", "null", ",", "'../../method'", ",", "'rubric'", ")", ";", "// Create a visible container for our data", "$", "pluginwrapper", "=", "new", "backup_nested_element", "(", "$", "this", "->", "get_recommended_name", "(", ")", ")", ";", "// Connect our visible container to the parent", "$", "plugin", "->", "add_child", "(", "$", "pluginwrapper", ")", ";", "// Define our elements", "$", "criteria", "=", "new", "backup_nested_element", "(", "'criteria'", ")", ";", "$", "criterion", "=", "new", "backup_nested_element", "(", "'criterion'", ",", "array", "(", "'id'", ")", ",", "array", "(", "'sortorder'", ",", "'description'", ",", "'descriptionformat'", ")", ")", ";", "$", "levels", "=", "new", "backup_nested_element", "(", "'levels'", ")", ";", "$", "level", "=", "new", "backup_nested_element", "(", "'level'", ",", "array", "(", "'id'", ")", ",", "array", "(", "'score'", ",", "'definition'", ",", "'definitionformat'", ")", ")", ";", "// Build elements hierarchy", "$", "pluginwrapper", "->", "add_child", "(", "$", "criteria", ")", ";", "$", "criteria", "->", "add_child", "(", "$", "criterion", ")", ";", "$", "criterion", "->", "add_child", "(", "$", "levels", ")", ";", "$", "levels", "->", "add_child", "(", "$", "level", ")", ";", "// Set sources to populate the data", "$", "criterion", "->", "set_source_table", "(", "'gradingform_rubric_criteria'", ",", "array", "(", "'definitionid'", "=>", "backup", "::", "VAR_PARENTID", ")", ")", ";", "$", "level", "->", "set_source_table", "(", "'gradingform_rubric_levels'", ",", "array", "(", "'criterionid'", "=>", "backup", "::", "VAR_PARENTID", ")", ")", ";", "// no need to annotate ids or files yet (one day when criterion definition supports", "// embedded files, they must be annotated here)", "return", "$", "plugin", ";", "}" ]
Declares rubric structures to append to the grading form definition
[ "Declares", "rubric", "structures", "to", "append", "to", "the", "grading", "form", "definition" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/grading/form/rubric/backup/moodle2/backup_gradingform_rubric_plugin.class.php#L39-L81
217,414
moodle/moodle
login/set_password_form.php
login_set_password_form.definition
public function definition() { global $CFG; $mform = $this->_form; $mform->setDisableShortforms(true); $mform->addElement('header', 'setpassword', get_string('setpassword'), ''); // Include the username in the form so browsers will recognise that a password is being set. $mform->addElement('text', 'username', '', 'style="display: none;"'); $mform->setType('username', PARAM_RAW); // Token gives authority to change password. $mform->addElement('hidden', 'token', ''); $mform->setType('token', PARAM_ALPHANUM); // Visible elements. $mform->addElement('static', 'username2', get_string('username')); $policies = array(); if (!empty($CFG->passwordpolicy)) { $policies[] = print_password_policy(); } if (!empty($CFG->passwordreuselimit) and $CFG->passwordreuselimit > 0) { $policies[] = get_string('informminpasswordreuselimit', 'auth', $CFG->passwordreuselimit); } if ($policies) { $mform->addElement('static', 'passwordpolicyinfo', '', implode('<br />', $policies)); } $mform->addElement('password', 'password', get_string('newpassword')); $mform->addRule('password', get_string('required'), 'required', null, 'client'); $mform->setType('password', PARAM_RAW); $strpasswordagain = get_string('newpassword') . ' (' . get_string('again') . ')'; $mform->addElement('password', 'password2', $strpasswordagain); $mform->addRule('password2', get_string('required'), 'required', null, 'client'); $mform->setType('password2', PARAM_RAW); $this->add_action_buttons(true); }
php
public function definition() { global $CFG; $mform = $this->_form; $mform->setDisableShortforms(true); $mform->addElement('header', 'setpassword', get_string('setpassword'), ''); // Include the username in the form so browsers will recognise that a password is being set. $mform->addElement('text', 'username', '', 'style="display: none;"'); $mform->setType('username', PARAM_RAW); // Token gives authority to change password. $mform->addElement('hidden', 'token', ''); $mform->setType('token', PARAM_ALPHANUM); // Visible elements. $mform->addElement('static', 'username2', get_string('username')); $policies = array(); if (!empty($CFG->passwordpolicy)) { $policies[] = print_password_policy(); } if (!empty($CFG->passwordreuselimit) and $CFG->passwordreuselimit > 0) { $policies[] = get_string('informminpasswordreuselimit', 'auth', $CFG->passwordreuselimit); } if ($policies) { $mform->addElement('static', 'passwordpolicyinfo', '', implode('<br />', $policies)); } $mform->addElement('password', 'password', get_string('newpassword')); $mform->addRule('password', get_string('required'), 'required', null, 'client'); $mform->setType('password', PARAM_RAW); $strpasswordagain = get_string('newpassword') . ' (' . get_string('again') . ')'; $mform->addElement('password', 'password2', $strpasswordagain); $mform->addRule('password2', get_string('required'), 'required', null, 'client'); $mform->setType('password2', PARAM_RAW); $this->add_action_buttons(true); }
[ "public", "function", "definition", "(", ")", "{", "global", "$", "CFG", ";", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "mform", "->", "setDisableShortforms", "(", "true", ")", ";", "$", "mform", "->", "addElement", "(", "'header'", ",", "'setpassword'", ",", "get_string", "(", "'setpassword'", ")", ",", "''", ")", ";", "// Include the username in the form so browsers will recognise that a password is being set.", "$", "mform", "->", "addElement", "(", "'text'", ",", "'username'", ",", "''", ",", "'style=\"display: none;\"'", ")", ";", "$", "mform", "->", "setType", "(", "'username'", ",", "PARAM_RAW", ")", ";", "// Token gives authority to change password.", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'token'", ",", "''", ")", ";", "$", "mform", "->", "setType", "(", "'token'", ",", "PARAM_ALPHANUM", ")", ";", "// Visible elements.", "$", "mform", "->", "addElement", "(", "'static'", ",", "'username2'", ",", "get_string", "(", "'username'", ")", ")", ";", "$", "policies", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "passwordpolicy", ")", ")", "{", "$", "policies", "[", "]", "=", "print_password_policy", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "CFG", "->", "passwordreuselimit", ")", "and", "$", "CFG", "->", "passwordreuselimit", ">", "0", ")", "{", "$", "policies", "[", "]", "=", "get_string", "(", "'informminpasswordreuselimit'", ",", "'auth'", ",", "$", "CFG", "->", "passwordreuselimit", ")", ";", "}", "if", "(", "$", "policies", ")", "{", "$", "mform", "->", "addElement", "(", "'static'", ",", "'passwordpolicyinfo'", ",", "''", ",", "implode", "(", "'<br />'", ",", "$", "policies", ")", ")", ";", "}", "$", "mform", "->", "addElement", "(", "'password'", ",", "'password'", ",", "get_string", "(", "'newpassword'", ")", ")", ";", "$", "mform", "->", "addRule", "(", "'password'", ",", "get_string", "(", "'required'", ")", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "$", "mform", "->", "setType", "(", "'password'", ",", "PARAM_RAW", ")", ";", "$", "strpasswordagain", "=", "get_string", "(", "'newpassword'", ")", ".", "' ('", ".", "get_string", "(", "'again'", ")", ".", "')'", ";", "$", "mform", "->", "addElement", "(", "'password'", ",", "'password2'", ",", "$", "strpasswordagain", ")", ";", "$", "mform", "->", "addRule", "(", "'password2'", ",", "get_string", "(", "'required'", ")", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "$", "mform", "->", "setType", "(", "'password2'", ",", "PARAM_RAW", ")", ";", "$", "this", "->", "add_action_buttons", "(", "true", ")", ";", "}" ]
Define the set password form.
[ "Define", "the", "set", "password", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/login/set_password_form.php#L45-L82
217,415
moodle/moodle
login/set_password_form.php
login_set_password_form.validation
public function validation($data, $files) { $user = $this->_customdata; $errors = parent::validation($data, $files); // Ignore submitted username. if ($data['password'] !== $data['password2']) { $errors['password'] = get_string('passwordsdiffer'); $errors['password2'] = get_string('passwordsdiffer'); return $errors; } $errmsg = ''; // Prevents eclipse warnings. if (!check_password_policy($data['password'], $errmsg)) { $errors['password'] = $errmsg; $errors['password2'] = $errmsg; return $errors; } if (user_is_previously_used_password($user->id, $data['password'])) { $errors['password'] = get_string('errorpasswordreused', 'core_auth'); $errors['password2'] = get_string('errorpasswordreused', 'core_auth'); } return $errors; }
php
public function validation($data, $files) { $user = $this->_customdata; $errors = parent::validation($data, $files); // Ignore submitted username. if ($data['password'] !== $data['password2']) { $errors['password'] = get_string('passwordsdiffer'); $errors['password2'] = get_string('passwordsdiffer'); return $errors; } $errmsg = ''; // Prevents eclipse warnings. if (!check_password_policy($data['password'], $errmsg)) { $errors['password'] = $errmsg; $errors['password2'] = $errmsg; return $errors; } if (user_is_previously_used_password($user->id, $data['password'])) { $errors['password'] = get_string('errorpasswordreused', 'core_auth'); $errors['password2'] = get_string('errorpasswordreused', 'core_auth'); } return $errors; }
[ "public", "function", "validation", "(", "$", "data", ",", "$", "files", ")", "{", "$", "user", "=", "$", "this", "->", "_customdata", ";", "$", "errors", "=", "parent", "::", "validation", "(", "$", "data", ",", "$", "files", ")", ";", "// Ignore submitted username.", "if", "(", "$", "data", "[", "'password'", "]", "!==", "$", "data", "[", "'password2'", "]", ")", "{", "$", "errors", "[", "'password'", "]", "=", "get_string", "(", "'passwordsdiffer'", ")", ";", "$", "errors", "[", "'password2'", "]", "=", "get_string", "(", "'passwordsdiffer'", ")", ";", "return", "$", "errors", ";", "}", "$", "errmsg", "=", "''", ";", "// Prevents eclipse warnings.", "if", "(", "!", "check_password_policy", "(", "$", "data", "[", "'password'", "]", ",", "$", "errmsg", ")", ")", "{", "$", "errors", "[", "'password'", "]", "=", "$", "errmsg", ";", "$", "errors", "[", "'password2'", "]", "=", "$", "errmsg", ";", "return", "$", "errors", ";", "}", "if", "(", "user_is_previously_used_password", "(", "$", "user", "->", "id", ",", "$", "data", "[", "'password'", "]", ")", ")", "{", "$", "errors", "[", "'password'", "]", "=", "get_string", "(", "'errorpasswordreused'", ",", "'core_auth'", ")", ";", "$", "errors", "[", "'password2'", "]", "=", "get_string", "(", "'errorpasswordreused'", ",", "'core_auth'", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Perform extra password change validation. @param array $data submitted form fields. @param array $files submitted with the form. @return array errors occuring during validation.
[ "Perform", "extra", "password", "change", "validation", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/login/set_password_form.php#L90-L115
217,416
moodle/moodle
course/classes/analytics/target/no_teaching.php
no_teaching.is_valid_sample
public function is_valid_sample($sampleid, \core_analytics\analysable $analysable, $fortraining = true) { $course = $this->retrieve('course', $sampleid); $now = time(); // No courses without start date, no finished courses, no predictions before start - 1 week nor // predictions for courses that started more than 1 week ago. if (!$course->startdate || (!empty($course->enddate) && $course->enddate < $now) || $course->startdate - WEEKSECS > $now || $course->startdate + WEEKSECS < $now) { return false; } return true; }
php
public function is_valid_sample($sampleid, \core_analytics\analysable $analysable, $fortraining = true) { $course = $this->retrieve('course', $sampleid); $now = time(); // No courses without start date, no finished courses, no predictions before start - 1 week nor // predictions for courses that started more than 1 week ago. if (!$course->startdate || (!empty($course->enddate) && $course->enddate < $now) || $course->startdate - WEEKSECS > $now || $course->startdate + WEEKSECS < $now) { return false; } return true; }
[ "public", "function", "is_valid_sample", "(", "$", "sampleid", ",", "\\", "core_analytics", "\\", "analysable", "$", "analysable", ",", "$", "fortraining", "=", "true", ")", "{", "$", "course", "=", "$", "this", "->", "retrieve", "(", "'course'", ",", "$", "sampleid", ")", ";", "$", "now", "=", "time", "(", ")", ";", "// No courses without start date, no finished courses, no predictions before start - 1 week nor", "// predictions for courses that started more than 1 week ago.", "if", "(", "!", "$", "course", "->", "startdate", "||", "(", "!", "empty", "(", "$", "course", "->", "enddate", ")", "&&", "$", "course", "->", "enddate", "<", "$", "now", ")", "||", "$", "course", "->", "startdate", "-", "WEEKSECS", ">", "$", "now", "||", "$", "course", "->", "startdate", "+", "WEEKSECS", "<", "$", "now", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Only process samples which start date is getting close. @param int $sampleid @param \core_analytics\analysable $analysable @param bool $fortraining @return bool
[ "Only", "process", "samples", "which", "start", "date", "is", "getting", "close", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/analytics/target/no_teaching.php#L148-L161
217,417
moodle/moodle
lib/minify/matthiasmullie-minify/src/Minify.php
Minify.add
public function add($data /* $data = null, ... */) { // bogus "usage" of parameter $data: scrutinizer warns this variable is // not used (we're using func_get_args instead to support overloading), // but it still needs to be defined because it makes no sense to have // this function without argument :) $args = array($data) + func_get_args(); // this method can be overloaded foreach ($args as $data) { if (is_array($data)) { call_user_func_array(array($this, 'add'), $data); continue; } // redefine var $data = (string) $data; // load data $value = $this->load($data); $key = ($data != $value) ? $data : count($this->data); // replace CR linefeeds etc. // @see https://github.com/matthiasmullie/minify/pull/139 $value = str_replace(array("\r\n", "\r"), "\n", $value); // store data $this->data[$key] = $value; } return $this; }
php
public function add($data /* $data = null, ... */) { // bogus "usage" of parameter $data: scrutinizer warns this variable is // not used (we're using func_get_args instead to support overloading), // but it still needs to be defined because it makes no sense to have // this function without argument :) $args = array($data) + func_get_args(); // this method can be overloaded foreach ($args as $data) { if (is_array($data)) { call_user_func_array(array($this, 'add'), $data); continue; } // redefine var $data = (string) $data; // load data $value = $this->load($data); $key = ($data != $value) ? $data : count($this->data); // replace CR linefeeds etc. // @see https://github.com/matthiasmullie/minify/pull/139 $value = str_replace(array("\r\n", "\r"), "\n", $value); // store data $this->data[$key] = $value; } return $this; }
[ "public", "function", "add", "(", "$", "data", "/* $data = null, ... */", ")", "{", "// bogus \"usage\" of parameter $data: scrutinizer warns this variable is", "// not used (we're using func_get_args instead to support overloading),", "// but it still needs to be defined because it makes no sense to have", "// this function without argument :)", "$", "args", "=", "array", "(", "$", "data", ")", "+", "func_get_args", "(", ")", ";", "// this method can be overloaded", "foreach", "(", "$", "args", "as", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'add'", ")", ",", "$", "data", ")", ";", "continue", ";", "}", "// redefine var", "$", "data", "=", "(", "string", ")", "$", "data", ";", "// load data", "$", "value", "=", "$", "this", "->", "load", "(", "$", "data", ")", ";", "$", "key", "=", "(", "$", "data", "!=", "$", "value", ")", "?", "$", "data", ":", "count", "(", "$", "this", "->", "data", ")", ";", "// replace CR linefeeds etc.", "// @see https://github.com/matthiasmullie/minify/pull/139", "$", "value", "=", "str_replace", "(", "array", "(", "\"\\r\\n\"", ",", "\"\\r\"", ")", ",", "\"\\n\"", ",", "$", "value", ")", ";", "// store data", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Add a file or straight-up code to be minified. @param string|string[] $data @return static
[ "Add", "a", "file", "or", "straight", "-", "up", "code", "to", "be", "minified", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/Minify.php#L60-L91
217,418
moodle/moodle
lib/minify/matthiasmullie-minify/src/Minify.php
Minify.cache
public function cache(CacheItemInterface $item) { $content = $this->execute(); $item->set($content); return $item; }
php
public function cache(CacheItemInterface $item) { $content = $this->execute(); $item->set($content); return $item; }
[ "public", "function", "cache", "(", "CacheItemInterface", "$", "item", ")", "{", "$", "content", "=", "$", "this", "->", "execute", "(", ")", ";", "$", "item", "->", "set", "(", "$", "content", ")", ";", "return", "$", "item", ";", "}" ]
Minify the data & write it to a CacheItemInterface object. @param CacheItemInterface $item Cache item to write the data to @return CacheItemInterface Cache item with the minifier data
[ "Minify", "the", "data", "&", "write", "it", "to", "a", "CacheItemInterface", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/Minify.php#L140-L146
217,419
moodle/moodle
lib/minify/matthiasmullie-minify/src/Minify.php
Minify.save
protected function save($content, $path) { $handler = $this->openFileForWriting($path); $this->writeToFile($handler, $content); @fclose($handler); }
php
protected function save($content, $path) { $handler = $this->openFileForWriting($path); $this->writeToFile($handler, $content); @fclose($handler); }
[ "protected", "function", "save", "(", "$", "content", ",", "$", "path", ")", "{", "$", "handler", "=", "$", "this", "->", "openFileForWriting", "(", "$", "path", ")", ";", "$", "this", "->", "writeToFile", "(", "$", "handler", ",", "$", "content", ")", ";", "@", "fclose", "(", "$", "handler", ")", ";", "}" ]
Save to file. @param string $content The minified data @param string $path The path to save the minified data to @throws IOException
[ "Save", "to", "file", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/Minify.php#L187-L194
217,420
moodle/moodle
lib/minify/matthiasmullie-minify/src/Minify.php
Minify.extractStrings
protected function extractStrings($chars = '\'"', $placeholderPrefix = '') { // PHP only supports $this inside anonymous functions since 5.4 $minifier = $this; $callback = function ($match) use ($minifier, $placeholderPrefix) { // check the second index here, because the first always contains a quote if ($match[2] === '') { /* * Empty strings need no placeholder; they can't be confused for * anything else anyway. * But we still needed to match them, for the extraction routine * to skip over this particular string. */ return $match[0]; } $count = count($minifier->extracted); $placeholder = $match[1].$placeholderPrefix.$count.$match[1]; $minifier->extracted[$placeholder] = $match[1].$match[2].$match[1]; return $placeholder; }; /* * The \\ messiness explained: * * Don't count ' or " as end-of-string if it's escaped (has backslash * in front of it) * * Unless... that backslash itself is escaped (another leading slash), * in which case it's no longer escaping the ' or " * * So there can be either no backslash, or an even number * * multiply all of that times 4, to account for the escaping that has * to be done to pass the backslash into the PHP string without it being * considered as escape-char (times 2) and to get it in the regex, * escaped (times 2) */ $this->registerPattern('/(['.$chars.'])(.*?(?<!\\\\)(\\\\\\\\)*+)\\1/s', $callback); }
php
protected function extractStrings($chars = '\'"', $placeholderPrefix = '') { // PHP only supports $this inside anonymous functions since 5.4 $minifier = $this; $callback = function ($match) use ($minifier, $placeholderPrefix) { // check the second index here, because the first always contains a quote if ($match[2] === '') { /* * Empty strings need no placeholder; they can't be confused for * anything else anyway. * But we still needed to match them, for the extraction routine * to skip over this particular string. */ return $match[0]; } $count = count($minifier->extracted); $placeholder = $match[1].$placeholderPrefix.$count.$match[1]; $minifier->extracted[$placeholder] = $match[1].$match[2].$match[1]; return $placeholder; }; /* * The \\ messiness explained: * * Don't count ' or " as end-of-string if it's escaped (has backslash * in front of it) * * Unless... that backslash itself is escaped (another leading slash), * in which case it's no longer escaping the ' or " * * So there can be either no backslash, or an even number * * multiply all of that times 4, to account for the escaping that has * to be done to pass the backslash into the PHP string without it being * considered as escape-char (times 2) and to get it in the regex, * escaped (times 2) */ $this->registerPattern('/(['.$chars.'])(.*?(?<!\\\\)(\\\\\\\\)*+)\\1/s', $callback); }
[ "protected", "function", "extractStrings", "(", "$", "chars", "=", "'\\'\"'", ",", "$", "placeholderPrefix", "=", "''", ")", "{", "// PHP only supports $this inside anonymous functions since 5.4", "$", "minifier", "=", "$", "this", ";", "$", "callback", "=", "function", "(", "$", "match", ")", "use", "(", "$", "minifier", ",", "$", "placeholderPrefix", ")", "{", "// check the second index here, because the first always contains a quote", "if", "(", "$", "match", "[", "2", "]", "===", "''", ")", "{", "/*\n * Empty strings need no placeholder; they can't be confused for\n * anything else anyway.\n * But we still needed to match them, for the extraction routine\n * to skip over this particular string.\n */", "return", "$", "match", "[", "0", "]", ";", "}", "$", "count", "=", "count", "(", "$", "minifier", "->", "extracted", ")", ";", "$", "placeholder", "=", "$", "match", "[", "1", "]", ".", "$", "placeholderPrefix", ".", "$", "count", ".", "$", "match", "[", "1", "]", ";", "$", "minifier", "->", "extracted", "[", "$", "placeholder", "]", "=", "$", "match", "[", "1", "]", ".", "$", "match", "[", "2", "]", ".", "$", "match", "[", "1", "]", ";", "return", "$", "placeholder", ";", "}", ";", "/*\n * The \\\\ messiness explained:\n * * Don't count ' or \" as end-of-string if it's escaped (has backslash\n * in front of it)\n * * Unless... that backslash itself is escaped (another leading slash),\n * in which case it's no longer escaping the ' or \"\n * * So there can be either no backslash, or an even number\n * * multiply all of that times 4, to account for the escaping that has\n * to be done to pass the backslash into the PHP string without it being\n * considered as escape-char (times 2) and to get it in the regex,\n * escaped (times 2)\n */", "$", "this", "->", "registerPattern", "(", "'/(['", ".", "$", "chars", ".", "'])(.*?(?<!\\\\\\\\)(\\\\\\\\\\\\\\\\)*+)\\\\1/s'", ",", "$", "callback", ")", ";", "}" ]
Strings are a pattern we need to match, in order to ignore potential code-like content inside them, but we just want all of the string content to remain untouched. This method will replace all string content with simple STRING# placeholder text, so we've rid all strings from characters that may be misinterpreted. Original string content will be saved in $this->extracted and after doing all other minifying, we can restore the original content via restoreStrings(). @param string[optional] $chars @param string[optional] $placeholderPrefix
[ "Strings", "are", "a", "pattern", "we", "need", "to", "match", "in", "order", "to", "ignore", "potential", "code", "-", "like", "content", "inside", "them", "but", "we", "just", "want", "all", "of", "the", "string", "content", "to", "remain", "untouched", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/Minify.php#L329-L365
217,421
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.login_user
public static function login_user($chatid, $groupid = 0) { global $DB; $params = self::validate_parameters(self::login_user_parameters(), array( 'chatid' => $chatid, 'groupid' => $groupid )); $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } // Get the unique chat session id. // Since we are going to use the chat via Web Service requests we set the ajax version (since it's the most similar). if (!$chatsid = chat_login_user($chat->id, 'ajax', $groupid, $course)) { throw new moodle_exception('cantlogin', 'chat'); } $result = array(); $result['chatsid'] = $chatsid; $result['warnings'] = $warnings; return $result; }
php
public static function login_user($chatid, $groupid = 0) { global $DB; $params = self::validate_parameters(self::login_user_parameters(), array( 'chatid' => $chatid, 'groupid' => $groupid )); $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } // Get the unique chat session id. // Since we are going to use the chat via Web Service requests we set the ajax version (since it's the most similar). if (!$chatsid = chat_login_user($chat->id, 'ajax', $groupid, $course)) { throw new moodle_exception('cantlogin', 'chat'); } $result = array(); $result['chatsid'] = $chatsid; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "login_user", "(", "$", "chatid", ",", "$", "groupid", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "login_user_parameters", "(", ")", ",", "array", "(", "'chatid'", "=>", "$", "chatid", ",", "'groupid'", "=>", "$", "groupid", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "$", "chat", "=", "$", "DB", "->", "get_record", "(", "'chat'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'chatid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "chat", ",", "'chat'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'mod/chat:chat'", ",", "$", "context", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "if", "(", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "// Determine is the group is visible to user (this is particullary for the group 0).", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "// Get the unique chat session id.", "// Since we are going to use the chat via Web Service requests we set the ajax version (since it's the most similar).", "if", "(", "!", "$", "chatsid", "=", "chat_login_user", "(", "$", "chat", "->", "id", ",", "'ajax'", ",", "$", "groupid", ",", "$", "course", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'cantlogin'", ",", "'chat'", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'chatsid'", "]", "=", "$", "chatsid", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Log the current user into a chat room in the given chat. @param int $chatid the chat instance id @param int $groupid the user group id @return array of warnings and the chat unique session id @since Moodle 3.0 @throws moodle_exception
[ "Log", "the", "current", "user", "into", "a", "chat", "room", "in", "the", "given", "chat", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L70-L118
217,422
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.get_chat_users
public static function get_chat_users($chatsid) { global $DB, $PAGE; $params = self::validate_parameters(self::get_chat_users_parameters(), array( 'chatsid' => $chatsid )); $warnings = array(); // Request and permission validation. if (!$chatuser = $DB->get_record('chat_users', array('sid' => $params['chatsid']))) { throw new moodle_exception('notlogged', 'chat'); } $chat = $DB->get_record('chat', array('id' => $chatuser->chatid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); // First, delete old users from the chats. chat_delete_old_users(); $users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid); $returnedusers = array(); foreach ($users as $user) { $userpicture = new user_picture($user); $userpicture->size = 1; // Size f1. $profileimageurl = $userpicture->get_url($PAGE)->out(false); $returnedusers[] = array( 'id' => $user->id, 'fullname' => fullname($user), 'profileimageurl' => $profileimageurl ); } $result = array(); $result['users'] = $returnedusers; $result['warnings'] = $warnings; return $result; }
php
public static function get_chat_users($chatsid) { global $DB, $PAGE; $params = self::validate_parameters(self::get_chat_users_parameters(), array( 'chatsid' => $chatsid )); $warnings = array(); // Request and permission validation. if (!$chatuser = $DB->get_record('chat_users', array('sid' => $params['chatsid']))) { throw new moodle_exception('notlogged', 'chat'); } $chat = $DB->get_record('chat', array('id' => $chatuser->chatid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); // First, delete old users from the chats. chat_delete_old_users(); $users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid); $returnedusers = array(); foreach ($users as $user) { $userpicture = new user_picture($user); $userpicture->size = 1; // Size f1. $profileimageurl = $userpicture->get_url($PAGE)->out(false); $returnedusers[] = array( 'id' => $user->id, 'fullname' => fullname($user), 'profileimageurl' => $profileimageurl ); } $result = array(); $result['users'] = $returnedusers; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_chat_users", "(", "$", "chatsid", ")", "{", "global", "$", "DB", ",", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_chat_users_parameters", "(", ")", ",", "array", "(", "'chatsid'", "=>", "$", "chatsid", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "if", "(", "!", "$", "chatuser", "=", "$", "DB", "->", "get_record", "(", "'chat_users'", ",", "array", "(", "'sid'", "=>", "$", "params", "[", "'chatsid'", "]", ")", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notlogged'", ",", "'chat'", ")", ";", "}", "$", "chat", "=", "$", "DB", "->", "get_record", "(", "'chat'", ",", "array", "(", "'id'", "=>", "$", "chatuser", "->", "chatid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "chat", ",", "'chat'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'mod/chat:chat'", ",", "$", "context", ")", ";", "// First, delete old users from the chats.", "chat_delete_old_users", "(", ")", ";", "$", "users", "=", "chat_get_users", "(", "$", "chatuser", "->", "chatid", ",", "$", "chatuser", "->", "groupid", ",", "$", "cm", "->", "groupingid", ")", ";", "$", "returnedusers", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "userpicture", "=", "new", "user_picture", "(", "$", "user", ")", ";", "$", "userpicture", "->", "size", "=", "1", ";", "// Size f1.", "$", "profileimageurl", "=", "$", "userpicture", "->", "get_url", "(", "$", "PAGE", ")", "->", "out", "(", "false", ")", ";", "$", "returnedusers", "[", "]", "=", "array", "(", "'id'", "=>", "$", "user", "->", "id", ",", "'fullname'", "=>", "fullname", "(", "$", "user", ")", ",", "'profileimageurl'", "=>", "$", "profileimageurl", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'users'", "]", "=", "$", "returnedusers", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Get the list of users in the given chat session. @param int $chatsid the chat session id @return array of warnings and the user lists @since Moodle 3.0 @throws moodle_exception
[ "Get", "the", "list", "of", "users", "in", "the", "given", "chat", "session", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L157-L201
217,423
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.send_chat_message
public static function send_chat_message($chatsid, $messagetext, $beepid = '') { global $DB; $params = self::validate_parameters(self::send_chat_message_parameters(), array( 'chatsid' => $chatsid, 'messagetext' => $messagetext, 'beepid' => $beepid )); $warnings = array(); // Request and permission validation. if (!$chatuser = $DB->get_record('chat_users', array('sid' => $params['chatsid']))) { throw new moodle_exception('notlogged', 'chat'); } $chat = $DB->get_record('chat', array('id' => $chatuser->chatid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); $chatmessage = clean_text($params['messagetext'], FORMAT_MOODLE); if (!empty($params['beepid'])) { $chatmessage = 'beep ' . $params['beepid']; } if (!empty($chatmessage)) { // Send the message. $messageid = chat_send_chatmessage($chatuser, $chatmessage, 0, $cm); // Update ping time. $chatuser->lastmessageping = time() - 2; $DB->update_record('chat_users', $chatuser); } else { $messageid = 0; } $result = array(); $result['messageid'] = $messageid; $result['warnings'] = $warnings; return $result; }
php
public static function send_chat_message($chatsid, $messagetext, $beepid = '') { global $DB; $params = self::validate_parameters(self::send_chat_message_parameters(), array( 'chatsid' => $chatsid, 'messagetext' => $messagetext, 'beepid' => $beepid )); $warnings = array(); // Request and permission validation. if (!$chatuser = $DB->get_record('chat_users', array('sid' => $params['chatsid']))) { throw new moodle_exception('notlogged', 'chat'); } $chat = $DB->get_record('chat', array('id' => $chatuser->chatid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/chat:chat', $context); $chatmessage = clean_text($params['messagetext'], FORMAT_MOODLE); if (!empty($params['beepid'])) { $chatmessage = 'beep ' . $params['beepid']; } if (!empty($chatmessage)) { // Send the message. $messageid = chat_send_chatmessage($chatuser, $chatmessage, 0, $cm); // Update ping time. $chatuser->lastmessageping = time() - 2; $DB->update_record('chat_users', $chatuser); } else { $messageid = 0; } $result = array(); $result['messageid'] = $messageid; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "send_chat_message", "(", "$", "chatsid", ",", "$", "messagetext", ",", "$", "beepid", "=", "''", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "send_chat_message_parameters", "(", ")", ",", "array", "(", "'chatsid'", "=>", "$", "chatsid", ",", "'messagetext'", "=>", "$", "messagetext", ",", "'beepid'", "=>", "$", "beepid", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "if", "(", "!", "$", "chatuser", "=", "$", "DB", "->", "get_record", "(", "'chat_users'", ",", "array", "(", "'sid'", "=>", "$", "params", "[", "'chatsid'", "]", ")", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notlogged'", ",", "'chat'", ")", ";", "}", "$", "chat", "=", "$", "DB", "->", "get_record", "(", "'chat'", ",", "array", "(", "'id'", "=>", "$", "chatuser", "->", "chatid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "chat", ",", "'chat'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'mod/chat:chat'", ",", "$", "context", ")", ";", "$", "chatmessage", "=", "clean_text", "(", "$", "params", "[", "'messagetext'", "]", ",", "FORMAT_MOODLE", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'beepid'", "]", ")", ")", "{", "$", "chatmessage", "=", "'beep '", ".", "$", "params", "[", "'beepid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "chatmessage", ")", ")", "{", "// Send the message.", "$", "messageid", "=", "chat_send_chatmessage", "(", "$", "chatuser", ",", "$", "chatmessage", ",", "0", ",", "$", "cm", ")", ";", "// Update ping time.", "$", "chatuser", "->", "lastmessageping", "=", "time", "(", ")", "-", "2", ";", "$", "DB", "->", "update_record", "(", "'chat_users'", ",", "$", "chatuser", ")", ";", "}", "else", "{", "$", "messageid", "=", "0", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'messageid'", "]", "=", "$", "messageid", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Send a message on the given chat session. @param int $chatsid the chat session id @param string $messagetext the message text @param string $beepid the beep message id @return array of warnings and the new message id (0 if the message was empty) @since Moodle 3.0 @throws moodle_exception
[ "Send", "a", "message", "on", "the", "given", "chat", "session", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L254-L297
217,424
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.get_chats_by_courses
public static function get_chats_by_courses($courseids = array()) { global $CFG; $returnedchats = array(); $warnings = array(); $params = self::validate_parameters(self::get_chats_by_courses_parameters(), array('courseids' => $courseids)); $courses = array(); if (empty($params['courseids'])) { $courses = enrol_get_my_courses(); $params['courseids'] = array_keys($courses); } // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses); // Get the chats in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $chats = get_all_instances_in_courses("chat", $courses); foreach ($chats as $chat) { $chatcontext = context_module::instance($chat->coursemodule); // Entry to return. $chatdetails = array(); // First, we return information that any user can see in the web interface. $chatdetails['id'] = $chat->id; $chatdetails['coursemodule'] = $chat->coursemodule; $chatdetails['course'] = $chat->course; $chatdetails['name'] = external_format_string($chat->name, $chatcontext->id); // Format intro. list($chatdetails['intro'], $chatdetails['introformat']) = external_format_text($chat->intro, $chat->introformat, $chatcontext->id, 'mod_chat', 'intro', null); $chatdetails['introfiles'] = external_util::get_area_files($chatcontext->id, 'mod_chat', 'intro', false, false); if (has_capability('mod/chat:chat', $chatcontext)) { $chatdetails['chatmethod'] = $CFG->chat_method; $chatdetails['keepdays'] = $chat->keepdays; $chatdetails['studentlogs'] = $chat->studentlogs; $chatdetails['chattime'] = $chat->chattime; $chatdetails['schedule'] = $chat->schedule; } if (has_capability('moodle/course:manageactivities', $chatcontext)) { $chatdetails['timemodified'] = $chat->timemodified; $chatdetails['section'] = $chat->section; $chatdetails['visible'] = $chat->visible; $chatdetails['groupmode'] = $chat->groupmode; $chatdetails['groupingid'] = $chat->groupingid; } $returnedchats[] = $chatdetails; } } $result = array(); $result['chats'] = $returnedchats; $result['warnings'] = $warnings; return $result; }
php
public static function get_chats_by_courses($courseids = array()) { global $CFG; $returnedchats = array(); $warnings = array(); $params = self::validate_parameters(self::get_chats_by_courses_parameters(), array('courseids' => $courseids)); $courses = array(); if (empty($params['courseids'])) { $courses = enrol_get_my_courses(); $params['courseids'] = array_keys($courses); } // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses); // Get the chats in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $chats = get_all_instances_in_courses("chat", $courses); foreach ($chats as $chat) { $chatcontext = context_module::instance($chat->coursemodule); // Entry to return. $chatdetails = array(); // First, we return information that any user can see in the web interface. $chatdetails['id'] = $chat->id; $chatdetails['coursemodule'] = $chat->coursemodule; $chatdetails['course'] = $chat->course; $chatdetails['name'] = external_format_string($chat->name, $chatcontext->id); // Format intro. list($chatdetails['intro'], $chatdetails['introformat']) = external_format_text($chat->intro, $chat->introformat, $chatcontext->id, 'mod_chat', 'intro', null); $chatdetails['introfiles'] = external_util::get_area_files($chatcontext->id, 'mod_chat', 'intro', false, false); if (has_capability('mod/chat:chat', $chatcontext)) { $chatdetails['chatmethod'] = $CFG->chat_method; $chatdetails['keepdays'] = $chat->keepdays; $chatdetails['studentlogs'] = $chat->studentlogs; $chatdetails['chattime'] = $chat->chattime; $chatdetails['schedule'] = $chat->schedule; } if (has_capability('moodle/course:manageactivities', $chatcontext)) { $chatdetails['timemodified'] = $chat->timemodified; $chatdetails['section'] = $chat->section; $chatdetails['visible'] = $chat->visible; $chatdetails['groupmode'] = $chat->groupmode; $chatdetails['groupingid'] = $chat->groupingid; } $returnedchats[] = $chatdetails; } } $result = array(); $result['chats'] = $returnedchats; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_chats_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ";", "$", "returnedchats", "=", "array", "(", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_chats_by_courses_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "courses", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "$", "courses", "=", "enrol_get_my_courses", "(", ")", ";", "$", "params", "[", "'courseids'", "]", "=", "array_keys", "(", "$", "courses", ")", ";", "}", "// Ensure there are courseids to loop through.", "if", "(", "!", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "$", "courses", ")", ";", "// Get the chats in this course, this function checks users visibility permissions.", "// We can avoid then additional validate_context calls.", "$", "chats", "=", "get_all_instances_in_courses", "(", "\"chat\"", ",", "$", "courses", ")", ";", "foreach", "(", "$", "chats", "as", "$", "chat", ")", "{", "$", "chatcontext", "=", "context_module", "::", "instance", "(", "$", "chat", "->", "coursemodule", ")", ";", "// Entry to return.", "$", "chatdetails", "=", "array", "(", ")", ";", "// First, we return information that any user can see in the web interface.", "$", "chatdetails", "[", "'id'", "]", "=", "$", "chat", "->", "id", ";", "$", "chatdetails", "[", "'coursemodule'", "]", "=", "$", "chat", "->", "coursemodule", ";", "$", "chatdetails", "[", "'course'", "]", "=", "$", "chat", "->", "course", ";", "$", "chatdetails", "[", "'name'", "]", "=", "external_format_string", "(", "$", "chat", "->", "name", ",", "$", "chatcontext", "->", "id", ")", ";", "// Format intro.", "list", "(", "$", "chatdetails", "[", "'intro'", "]", ",", "$", "chatdetails", "[", "'introformat'", "]", ")", "=", "external_format_text", "(", "$", "chat", "->", "intro", ",", "$", "chat", "->", "introformat", ",", "$", "chatcontext", "->", "id", ",", "'mod_chat'", ",", "'intro'", ",", "null", ")", ";", "$", "chatdetails", "[", "'introfiles'", "]", "=", "external_util", "::", "get_area_files", "(", "$", "chatcontext", "->", "id", ",", "'mod_chat'", ",", "'intro'", ",", "false", ",", "false", ")", ";", "if", "(", "has_capability", "(", "'mod/chat:chat'", ",", "$", "chatcontext", ")", ")", "{", "$", "chatdetails", "[", "'chatmethod'", "]", "=", "$", "CFG", "->", "chat_method", ";", "$", "chatdetails", "[", "'keepdays'", "]", "=", "$", "chat", "->", "keepdays", ";", "$", "chatdetails", "[", "'studentlogs'", "]", "=", "$", "chat", "->", "studentlogs", ";", "$", "chatdetails", "[", "'chattime'", "]", "=", "$", "chat", "->", "chattime", ";", "$", "chatdetails", "[", "'schedule'", "]", "=", "$", "chat", "->", "schedule", ";", "}", "if", "(", "has_capability", "(", "'moodle/course:manageactivities'", ",", "$", "chatcontext", ")", ")", "{", "$", "chatdetails", "[", "'timemodified'", "]", "=", "$", "chat", "->", "timemodified", ";", "$", "chatdetails", "[", "'section'", "]", "=", "$", "chat", "->", "section", ";", "$", "chatdetails", "[", "'visible'", "]", "=", "$", "chat", "->", "visible", ";", "$", "chatdetails", "[", "'groupmode'", "]", "=", "$", "chat", "->", "groupmode", ";", "$", "chatdetails", "[", "'groupingid'", "]", "=", "$", "chat", "->", "groupingid", ";", "}", "$", "returnedchats", "[", "]", "=", "$", "chatdetails", ";", "}", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'chats'", "]", "=", "$", "returnedchats", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Returns a list of chats in a provided list of courses, if no list is provided all chats that the user can view will be returned. @param array $courseids the course ids @return array of chats details @since Moodle 3.0
[ "Returns", "a", "list", "of", "chats", "in", "a", "provided", "list", "of", "courses", "if", "no", "list", "is", "provided", "all", "chats", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L520-L578
217,425
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.get_chats_by_courses_returns
public static function get_chats_by_courses_returns() { return new external_single_structure( array( 'chats' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Chat id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'Chat name'), 'intro' => new external_value(PARAM_RAW, 'The Chat intro'), 'introformat' => new external_format_value('intro'), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'chatmethod' => new external_value(PARAM_PLUGIN, 'chat method (sockets, ajax, header_js)', VALUE_OPTIONAL), 'keepdays' => new external_value(PARAM_INT, 'keep days', VALUE_OPTIONAL), 'studentlogs' => new external_value(PARAM_INT, 'student logs visible to everyone', VALUE_OPTIONAL), 'chattime' => new external_value(PARAM_INT, 'chat time', VALUE_OPTIONAL), 'schedule' => new external_value(PARAM_INT, 'schedule type', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'time of last modification', VALUE_OPTIONAL), 'section' => new external_value(PARAM_INT, 'course section id', VALUE_OPTIONAL), 'visible' => new external_value(PARAM_BOOL, 'visible', VALUE_OPTIONAL), 'groupmode' => new external_value(PARAM_INT, 'group mode', VALUE_OPTIONAL), 'groupingid' => new external_value(PARAM_INT, 'group id', VALUE_OPTIONAL), ), 'Chats' ) ), 'warnings' => new external_warnings(), ) ); }
php
public static function get_chats_by_courses_returns() { return new external_single_structure( array( 'chats' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Chat id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'Chat name'), 'intro' => new external_value(PARAM_RAW, 'The Chat intro'), 'introformat' => new external_format_value('intro'), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'chatmethod' => new external_value(PARAM_PLUGIN, 'chat method (sockets, ajax, header_js)', VALUE_OPTIONAL), 'keepdays' => new external_value(PARAM_INT, 'keep days', VALUE_OPTIONAL), 'studentlogs' => new external_value(PARAM_INT, 'student logs visible to everyone', VALUE_OPTIONAL), 'chattime' => new external_value(PARAM_INT, 'chat time', VALUE_OPTIONAL), 'schedule' => new external_value(PARAM_INT, 'schedule type', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'time of last modification', VALUE_OPTIONAL), 'section' => new external_value(PARAM_INT, 'course section id', VALUE_OPTIONAL), 'visible' => new external_value(PARAM_BOOL, 'visible', VALUE_OPTIONAL), 'groupmode' => new external_value(PARAM_INT, 'group mode', VALUE_OPTIONAL), 'groupingid' => new external_value(PARAM_INT, 'group id', VALUE_OPTIONAL), ), 'Chats' ) ), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_chats_by_courses_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'chats'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Chat id'", ")", ",", "'coursemodule'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course module id'", ")", ",", "'course'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Chat name'", ")", ",", "'intro'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'The Chat intro'", ")", ",", "'introformat'", "=>", "new", "external_format_value", "(", "'intro'", ")", ",", "'introfiles'", "=>", "new", "external_files", "(", "'Files in the introduction text'", ",", "VALUE_OPTIONAL", ")", ",", "'chatmethod'", "=>", "new", "external_value", "(", "PARAM_PLUGIN", ",", "'chat method (sockets, ajax, header_js)'", ",", "VALUE_OPTIONAL", ")", ",", "'keepdays'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'keep days'", ",", "VALUE_OPTIONAL", ")", ",", "'studentlogs'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'student logs visible to everyone'", ",", "VALUE_OPTIONAL", ")", ",", "'chattime'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'chat time'", ",", "VALUE_OPTIONAL", ")", ",", "'schedule'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'schedule type'", ",", "VALUE_OPTIONAL", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'time of last modification'", ",", "VALUE_OPTIONAL", ")", ",", "'section'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'course section id'", ",", "VALUE_OPTIONAL", ")", ",", "'visible'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'visible'", ",", "VALUE_OPTIONAL", ")", ",", "'groupmode'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'group mode'", ",", "VALUE_OPTIONAL", ")", ",", "'groupingid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'group id'", ",", "VALUE_OPTIONAL", ")", ",", ")", ",", "'Chats'", ")", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_chats_by_courses return value. @return external_single_structure @since Moodle 3.0
[ "Describes", "the", "get_chats_by_courses", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L586-L616
217,426
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.get_sessions
public static function get_sessions($chatid, $groupid = 0, $showall = false) { global $DB; $params = self::validate_parameters(self::get_sessions_parameters(), array( 'chatid' => $chatid, 'groupid' => $groupid, 'showall' => $showall, )); $sessions = $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) { throw new moodle_exception('nopermissiontoseethechatlog', 'chat'); } if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $messages = chat_get_session_messages($chat->id, $groupid, 0, 0, 'timestamp DESC'); if ($messages) { $chatsessions = chat_get_sessions($messages, $params['showall']); // Format sessions for external. foreach ($chatsessions as $session) { $sessionusers = array(); foreach ($session->sessionusers as $sessionuser => $usermessagecount) { $sessionusers[] = array( 'userid' => $sessionuser, 'messagecount' => $usermessagecount ); } $session->sessionusers = $sessionusers; $sessions[] = $session; } } $result = array(); $result['sessions'] = $sessions; $result['warnings'] = $warnings; return $result; }
php
public static function get_sessions($chatid, $groupid = 0, $showall = false) { global $DB; $params = self::validate_parameters(self::get_sessions_parameters(), array( 'chatid' => $chatid, 'groupid' => $groupid, 'showall' => $showall, )); $sessions = $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) { throw new moodle_exception('nopermissiontoseethechatlog', 'chat'); } if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $messages = chat_get_session_messages($chat->id, $groupid, 0, 0, 'timestamp DESC'); if ($messages) { $chatsessions = chat_get_sessions($messages, $params['showall']); // Format sessions for external. foreach ($chatsessions as $session) { $sessionusers = array(); foreach ($session->sessionusers as $sessionuser => $usermessagecount) { $sessionusers[] = array( 'userid' => $sessionuser, 'messagecount' => $usermessagecount ); } $session->sessionusers = $sessionusers; $sessions[] = $session; } } $result = array(); $result['sessions'] = $sessions; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_sessions", "(", "$", "chatid", ",", "$", "groupid", "=", "0", ",", "$", "showall", "=", "false", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_sessions_parameters", "(", ")", ",", "array", "(", "'chatid'", "=>", "$", "chatid", ",", "'groupid'", "=>", "$", "groupid", ",", "'showall'", "=>", "$", "showall", ",", ")", ")", ";", "$", "sessions", "=", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "$", "chat", "=", "$", "DB", "->", "get_record", "(", "'chat'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'chatid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "chat", ",", "'chat'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "if", "(", "empty", "(", "$", "chat", "->", "studentlogs", ")", "&&", "!", "has_capability", "(", "'mod/chat:readlog'", ",", "$", "context", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'nopermissiontoseethechatlog'", ",", "'chat'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "if", "(", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "// Determine is the group is visible to user (this is particullary for the group 0).", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "$", "messages", "=", "chat_get_session_messages", "(", "$", "chat", "->", "id", ",", "$", "groupid", ",", "0", ",", "0", ",", "'timestamp DESC'", ")", ";", "if", "(", "$", "messages", ")", "{", "$", "chatsessions", "=", "chat_get_sessions", "(", "$", "messages", ",", "$", "params", "[", "'showall'", "]", ")", ";", "// Format sessions for external.", "foreach", "(", "$", "chatsessions", "as", "$", "session", ")", "{", "$", "sessionusers", "=", "array", "(", ")", ";", "foreach", "(", "$", "session", "->", "sessionusers", "as", "$", "sessionuser", "=>", "$", "usermessagecount", ")", "{", "$", "sessionusers", "[", "]", "=", "array", "(", "'userid'", "=>", "$", "sessionuser", ",", "'messagecount'", "=>", "$", "usermessagecount", ")", ";", "}", "$", "session", "->", "sessionusers", "=", "$", "sessionusers", ";", "$", "sessions", "[", "]", "=", "$", "session", ";", "}", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'sessions'", "]", "=", "$", "sessions", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Retrieves chat sessions for a given chat. @param int $chatid the chat instance id @param int $groupid filter messages by this group. 0 to determine the group. @param bool $showall whether to include incomplete sessions or not @return array of warnings and the sessions @since Moodle 3.4 @throws moodle_exception
[ "Retrieves", "chat", "sessions", "for", "a", "given", "chat", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L645-L707
217,427
moodle/moodle
mod/chat/classes/external.php
mod_chat_external.get_session_messages
public static function get_session_messages($chatid, $sessionstart, $sessionend, $groupid = 0) { global $DB, $PAGE; $params = self::validate_parameters(self::get_session_messages_parameters(), array( 'chatid' => $chatid, 'sessionstart' => $sessionstart, 'sessionend' => $sessionend, 'groupid' => $groupid, )); $messages = $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) { throw new moodle_exception('nopermissiontoseethechatlog', 'chat'); } if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $messages = chat_get_session_messages($chat->id, $groupid, $params['sessionstart'], $params['sessionend'], 'timestamp ASC'); if ($messages) { foreach ($messages as $message) { $exporter = new chat_message_exporter($message, array('context' => $context)); $returneditems[] = $exporter->export($PAGE->get_renderer('core')); } } $result = array( 'messages' => $messages, 'warnings' => $warnings, ); return $result; }
php
public static function get_session_messages($chatid, $sessionstart, $sessionend, $groupid = 0) { global $DB, $PAGE; $params = self::validate_parameters(self::get_session_messages_parameters(), array( 'chatid' => $chatid, 'sessionstart' => $sessionstart, 'sessionend' => $sessionend, 'groupid' => $groupid, )); $messages = $warnings = array(); // Request and permission validation. $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat'); $context = context_module::instance($cm->id); self::validate_context($context); if (empty($chat->studentlogs) && !has_capability('mod/chat:readlog', $context)) { throw new moodle_exception('nopermissiontoseethechatlog', 'chat'); } if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $messages = chat_get_session_messages($chat->id, $groupid, $params['sessionstart'], $params['sessionend'], 'timestamp ASC'); if ($messages) { foreach ($messages as $message) { $exporter = new chat_message_exporter($message, array('context' => $context)); $returneditems[] = $exporter->export($PAGE->get_renderer('core')); } } $result = array( 'messages' => $messages, 'warnings' => $warnings, ); return $result; }
[ "public", "static", "function", "get_session_messages", "(", "$", "chatid", ",", "$", "sessionstart", ",", "$", "sessionend", ",", "$", "groupid", "=", "0", ")", "{", "global", "$", "DB", ",", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_session_messages_parameters", "(", ")", ",", "array", "(", "'chatid'", "=>", "$", "chatid", ",", "'sessionstart'", "=>", "$", "sessionstart", ",", "'sessionend'", "=>", "$", "sessionend", ",", "'groupid'", "=>", "$", "groupid", ",", ")", ")", ";", "$", "messages", "=", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "$", "chat", "=", "$", "DB", "->", "get_record", "(", "'chat'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'chatid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "chat", ",", "'chat'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "if", "(", "empty", "(", "$", "chat", "->", "studentlogs", ")", "&&", "!", "has_capability", "(", "'mod/chat:readlog'", ",", "$", "context", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'nopermissiontoseethechatlog'", ",", "'chat'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "if", "(", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "// Determine is the group is visible to user (this is particullary for the group 0).", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "$", "messages", "=", "chat_get_session_messages", "(", "$", "chat", "->", "id", ",", "$", "groupid", ",", "$", "params", "[", "'sessionstart'", "]", ",", "$", "params", "[", "'sessionend'", "]", ",", "'timestamp ASC'", ")", ";", "if", "(", "$", "messages", ")", "{", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "$", "exporter", "=", "new", "chat_message_exporter", "(", "$", "message", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "returneditems", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "}", "$", "result", "=", "array", "(", "'messages'", "=>", "$", "messages", ",", "'warnings'", "=>", "$", "warnings", ",", ")", ";", "return", "$", "result", ";", "}" ]
Retrieves messages of the given chat session. @param int $chatid the chat instance id @param int $sessionstart the session start time (timestamp) @param int $sessionend the session end time (timestamp) @param int $groupid filter messages by this group. 0 to determine the group. @return array of warnings and the messages @since Moodle 3.4 @throws moodle_exception
[ "Retrieves", "messages", "of", "the", "given", "chat", "session", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/chat/classes/external.php#L770-L826
217,428
moodle/moodle
lib/grade/grade_grade.php
grade_grade.fetch_users_grades
public static function fetch_users_grades($grade_item, $userids, $include_missing=true) { global $DB; // hmm, there might be a problem with length of sql query // if there are too many users requested - we might run out of memory anyway $limit = 2000; $count = count($userids); if ($count > $limit) { $half = (int)($count/2); $first = array_slice($userids, 0, $half); $second = array_slice($userids, $half); return grade_grade::fetch_users_grades($grade_item, $first, $include_missing) + grade_grade::fetch_users_grades($grade_item, $second, $include_missing); } list($user_ids_cvs, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'uid0'); $params['giid'] = $grade_item->id; $result = array(); if ($grade_records = $DB->get_records_select('grade_grades', "itemid=:giid AND userid $user_ids_cvs", $params)) { foreach ($grade_records as $record) { $result[$record->userid] = new grade_grade($record, false); } } if ($include_missing) { foreach ($userids as $userid) { if (!array_key_exists($userid, $result)) { $grade_grade = new grade_grade(); $grade_grade->userid = $userid; $grade_grade->itemid = $grade_item->id; $result[$userid] = $grade_grade; } } } return $result; }
php
public static function fetch_users_grades($grade_item, $userids, $include_missing=true) { global $DB; // hmm, there might be a problem with length of sql query // if there are too many users requested - we might run out of memory anyway $limit = 2000; $count = count($userids); if ($count > $limit) { $half = (int)($count/2); $first = array_slice($userids, 0, $half); $second = array_slice($userids, $half); return grade_grade::fetch_users_grades($grade_item, $first, $include_missing) + grade_grade::fetch_users_grades($grade_item, $second, $include_missing); } list($user_ids_cvs, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'uid0'); $params['giid'] = $grade_item->id; $result = array(); if ($grade_records = $DB->get_records_select('grade_grades', "itemid=:giid AND userid $user_ids_cvs", $params)) { foreach ($grade_records as $record) { $result[$record->userid] = new grade_grade($record, false); } } if ($include_missing) { foreach ($userids as $userid) { if (!array_key_exists($userid, $result)) { $grade_grade = new grade_grade(); $grade_grade->userid = $userid; $grade_grade->itemid = $grade_item->id; $result[$userid] = $grade_grade; } } } return $result; }
[ "public", "static", "function", "fetch_users_grades", "(", "$", "grade_item", ",", "$", "userids", ",", "$", "include_missing", "=", "true", ")", "{", "global", "$", "DB", ";", "// hmm, there might be a problem with length of sql query", "// if there are too many users requested - we might run out of memory anyway", "$", "limit", "=", "2000", ";", "$", "count", "=", "count", "(", "$", "userids", ")", ";", "if", "(", "$", "count", ">", "$", "limit", ")", "{", "$", "half", "=", "(", "int", ")", "(", "$", "count", "/", "2", ")", ";", "$", "first", "=", "array_slice", "(", "$", "userids", ",", "0", ",", "$", "half", ")", ";", "$", "second", "=", "array_slice", "(", "$", "userids", ",", "$", "half", ")", ";", "return", "grade_grade", "::", "fetch_users_grades", "(", "$", "grade_item", ",", "$", "first", ",", "$", "include_missing", ")", "+", "grade_grade", "::", "fetch_users_grades", "(", "$", "grade_item", ",", "$", "second", ",", "$", "include_missing", ")", ";", "}", "list", "(", "$", "user_ids_cvs", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "userids", ",", "SQL_PARAMS_NAMED", ",", "'uid0'", ")", ";", "$", "params", "[", "'giid'", "]", "=", "$", "grade_item", "->", "id", ";", "$", "result", "=", "array", "(", ")", ";", "if", "(", "$", "grade_records", "=", "$", "DB", "->", "get_records_select", "(", "'grade_grades'", ",", "\"itemid=:giid AND userid $user_ids_cvs\"", ",", "$", "params", ")", ")", "{", "foreach", "(", "$", "grade_records", "as", "$", "record", ")", "{", "$", "result", "[", "$", "record", "->", "userid", "]", "=", "new", "grade_grade", "(", "$", "record", ",", "false", ")", ";", "}", "}", "if", "(", "$", "include_missing", ")", "{", "foreach", "(", "$", "userids", "as", "$", "userid", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "userid", ",", "$", "result", ")", ")", "{", "$", "grade_grade", "=", "new", "grade_grade", "(", ")", ";", "$", "grade_grade", "->", "userid", "=", "$", "userid", ";", "$", "grade_grade", "->", "itemid", "=", "$", "grade_item", "->", "id", ";", "$", "result", "[", "$", "userid", "]", "=", "$", "grade_grade", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Returns array of grades for given grade_item+users @param grade_item $grade_item @param array $userids @param bool $include_missing include grades that do not exist yet @return array userid=>grade_grade array
[ "Returns", "array", "of", "grades", "for", "given", "grade_item", "+", "users" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L199-L233
217,429
moodle/moodle
lib/grade/grade_grade.php
grade_grade.is_editable
public function is_editable() { if ($this->is_locked()) { return false; } $grade_item = $this->load_grade_item(); if ($grade_item->gradetype == GRADE_TYPE_NONE) { return false; } if ($grade_item->is_course_item() or $grade_item->is_category_item()) { return (bool)get_config('moodle', 'grade_overridecat'); } return true; }
php
public function is_editable() { if ($this->is_locked()) { return false; } $grade_item = $this->load_grade_item(); if ($grade_item->gradetype == GRADE_TYPE_NONE) { return false; } if ($grade_item->is_course_item() or $grade_item->is_category_item()) { return (bool)get_config('moodle', 'grade_overridecat'); } return true; }
[ "public", "function", "is_editable", "(", ")", "{", "if", "(", "$", "this", "->", "is_locked", "(", ")", ")", "{", "return", "false", ";", "}", "$", "grade_item", "=", "$", "this", "->", "load_grade_item", "(", ")", ";", "if", "(", "$", "grade_item", "->", "gradetype", "==", "GRADE_TYPE_NONE", ")", "{", "return", "false", ";", "}", "if", "(", "$", "grade_item", "->", "is_course_item", "(", ")", "or", "$", "grade_item", "->", "is_category_item", "(", ")", ")", "{", "return", "(", "bool", ")", "get_config", "(", "'moodle'", ",", "'grade_overridecat'", ")", ";", "}", "return", "true", ";", "}" ]
Is grading object editable? @return bool
[ "Is", "grading", "object", "editable?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L263-L279
217,430
moodle/moodle
lib/grade/grade_grade.php
grade_grade.get_grade_min_and_max
protected function get_grade_min_and_max() { global $CFG; $this->load_grade_item(); // When the following setting is turned on we use the grade_grade raw min and max values. $minmaxtouse = grade_get_setting($this->grade_item->courseid, 'minmaxtouse', $CFG->grade_minmaxtouse); // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they // wish to update the grades. $gradebookcalculationsfreeze = 'gradebook_calculations_freeze_' . $this->grade_item->courseid; // Gradebook is frozen, run through old code. if (isset($CFG->$gradebookcalculationsfreeze) && (int)$CFG->$gradebookcalculationsfreeze <= 20150627) { // Only aggregate items use separate min grades. if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE || $this->grade_item->is_aggregate_item()) { return array($this->rawgrademin, $this->rawgrademax); } else { return array($this->grade_item->grademin, $this->grade_item->grademax); } } else { // Only aggregate items use separate min grades, unless they are calculated grade items. if (($this->grade_item->is_aggregate_item() && !$this->grade_item->is_calculated()) || $minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE) { return array($this->rawgrademin, $this->rawgrademax); } else { return array($this->grade_item->grademin, $this->grade_item->grademax); } } }
php
protected function get_grade_min_and_max() { global $CFG; $this->load_grade_item(); // When the following setting is turned on we use the grade_grade raw min and max values. $minmaxtouse = grade_get_setting($this->grade_item->courseid, 'minmaxtouse', $CFG->grade_minmaxtouse); // Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they // wish to update the grades. $gradebookcalculationsfreeze = 'gradebook_calculations_freeze_' . $this->grade_item->courseid; // Gradebook is frozen, run through old code. if (isset($CFG->$gradebookcalculationsfreeze) && (int)$CFG->$gradebookcalculationsfreeze <= 20150627) { // Only aggregate items use separate min grades. if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE || $this->grade_item->is_aggregate_item()) { return array($this->rawgrademin, $this->rawgrademax); } else { return array($this->grade_item->grademin, $this->grade_item->grademax); } } else { // Only aggregate items use separate min grades, unless they are calculated grade items. if (($this->grade_item->is_aggregate_item() && !$this->grade_item->is_calculated()) || $minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE) { return array($this->rawgrademin, $this->rawgrademax); } else { return array($this->grade_item->grademin, $this->grade_item->grademax); } } }
[ "protected", "function", "get_grade_min_and_max", "(", ")", "{", "global", "$", "CFG", ";", "$", "this", "->", "load_grade_item", "(", ")", ";", "// When the following setting is turned on we use the grade_grade raw min and max values.", "$", "minmaxtouse", "=", "grade_get_setting", "(", "$", "this", "->", "grade_item", "->", "courseid", ",", "'minmaxtouse'", ",", "$", "CFG", "->", "grade_minmaxtouse", ")", ";", "// Check to see if the gradebook is frozen. This allows grades to not be altered at all until a user verifies that they", "// wish to update the grades.", "$", "gradebookcalculationsfreeze", "=", "'gradebook_calculations_freeze_'", ".", "$", "this", "->", "grade_item", "->", "courseid", ";", "// Gradebook is frozen, run through old code.", "if", "(", "isset", "(", "$", "CFG", "->", "$", "gradebookcalculationsfreeze", ")", "&&", "(", "int", ")", "$", "CFG", "->", "$", "gradebookcalculationsfreeze", "<=", "20150627", ")", "{", "// Only aggregate items use separate min grades.", "if", "(", "$", "minmaxtouse", "==", "GRADE_MIN_MAX_FROM_GRADE_GRADE", "||", "$", "this", "->", "grade_item", "->", "is_aggregate_item", "(", ")", ")", "{", "return", "array", "(", "$", "this", "->", "rawgrademin", ",", "$", "this", "->", "rawgrademax", ")", ";", "}", "else", "{", "return", "array", "(", "$", "this", "->", "grade_item", "->", "grademin", ",", "$", "this", "->", "grade_item", "->", "grademax", ")", ";", "}", "}", "else", "{", "// Only aggregate items use separate min grades, unless they are calculated grade items.", "if", "(", "(", "$", "this", "->", "grade_item", "->", "is_aggregate_item", "(", ")", "&&", "!", "$", "this", "->", "grade_item", "->", "is_calculated", "(", ")", ")", "||", "$", "minmaxtouse", "==", "GRADE_MIN_MAX_FROM_GRADE_GRADE", ")", "{", "return", "array", "(", "$", "this", "->", "rawgrademin", ",", "$", "this", "->", "rawgrademax", ")", ";", "}", "else", "{", "return", "array", "(", "$", "this", "->", "grade_item", "->", "grademin", ",", "$", "this", "->", "grade_item", "->", "grademax", ")", ";", "}", "}", "}" ]
Returns the minimum and maximum number of points this grade is graded with respect to. @since Moodle 2.8.7, 2.9.1 @return array A list containing, in order, the minimum and maximum number of points.
[ "Returns", "the", "minimum", "and", "maximum", "number", "of", "points", "this", "grade", "is", "graded", "with", "respect", "to", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L362-L389
217,431
moodle/moodle
lib/grade/grade_grade.php
grade_grade.get_dategraded
public function get_dategraded() { //TODO: HACK - create new fields (MDL-31379) if (is_null($this->finalgrade) and is_null($this->feedback)) { return null; // no grade == no date } else if ($this->overridden) { return $this->overridden; } else { return $this->timemodified; } }
php
public function get_dategraded() { //TODO: HACK - create new fields (MDL-31379) if (is_null($this->finalgrade) and is_null($this->feedback)) { return null; // no grade == no date } else if ($this->overridden) { return $this->overridden; } else { return $this->timemodified; } }
[ "public", "function", "get_dategraded", "(", ")", "{", "//TODO: HACK - create new fields (MDL-31379)", "if", "(", "is_null", "(", "$", "this", "->", "finalgrade", ")", "and", "is_null", "(", "$", "this", "->", "feedback", ")", ")", "{", "return", "null", ";", "// no grade == no date", "}", "else", "if", "(", "$", "this", "->", "overridden", ")", "{", "return", "$", "this", "->", "overridden", ";", "}", "else", "{", "return", "$", "this", "->", "timemodified", ";", "}", "}" ]
Returns timestamp when last graded, null if no grade present @return int
[ "Returns", "timestamp", "when", "last", "graded", "null", "if", "no", "grade", "present" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L420-L429
217,432
moodle/moodle
lib/grade/grade_grade.php
grade_grade.set_overridden
public function set_overridden($state, $refresh = true) { if (empty($this->overridden) and $state) { $this->overridden = time(); $this->update(); return true; } else if (!empty($this->overridden) and !$state) { $this->overridden = 0; $this->update(); if ($refresh) { //refresh when unlocking $this->grade_item->refresh_grades($this->userid); } return true; } return false; }
php
public function set_overridden($state, $refresh = true) { if (empty($this->overridden) and $state) { $this->overridden = time(); $this->update(); return true; } else if (!empty($this->overridden) and !$state) { $this->overridden = 0; $this->update(); if ($refresh) { //refresh when unlocking $this->grade_item->refresh_grades($this->userid); } return true; } return false; }
[ "public", "function", "set_overridden", "(", "$", "state", ",", "$", "refresh", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "overridden", ")", "and", "$", "state", ")", "{", "$", "this", "->", "overridden", "=", "time", "(", ")", ";", "$", "this", "->", "update", "(", ")", ";", "return", "true", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "this", "->", "overridden", ")", "and", "!", "$", "state", ")", "{", "$", "this", "->", "overridden", "=", "0", ";", "$", "this", "->", "update", "(", ")", ";", "if", "(", "$", "refresh", ")", "{", "//refresh when unlocking", "$", "this", "->", "grade_item", "->", "refresh_grades", "(", "$", "this", "->", "userid", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Set the overridden status of grade @param bool $state requested overridden state @param bool $refresh refresh grades from external activities if needed @return bool true is db state changed
[ "Set", "the", "overridden", "status", "of", "grade" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L438-L456
217,433
moodle/moodle
lib/grade/grade_grade.php
grade_grade.set_excluded
public function set_excluded($state) { if (empty($this->excluded) and $state) { $this->excluded = time(); $this->update(); return true; } else if (!empty($this->excluded) and !$state) { $this->excluded = 0; $this->update(); return true; } return false; }
php
public function set_excluded($state) { if (empty($this->excluded) and $state) { $this->excluded = time(); $this->update(); return true; } else if (!empty($this->excluded) and !$state) { $this->excluded = 0; $this->update(); return true; } return false; }
[ "public", "function", "set_excluded", "(", "$", "state", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "excluded", ")", "and", "$", "state", ")", "{", "$", "this", "->", "excluded", "=", "time", "(", ")", ";", "$", "this", "->", "update", "(", ")", ";", "return", "true", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "this", "->", "excluded", ")", "and", "!", "$", "state", ")", "{", "$", "this", "->", "excluded", "=", "0", ";", "$", "this", "->", "update", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Set the excluded status of grade @param bool $state requested excluded state @return bool True is database state changed
[ "Set", "the", "excluded", "status", "of", "grade" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L473-L485
217,434
moodle/moodle
lib/grade/grade_grade.php
grade_grade.get_locktime
public function get_locktime() { $this->load_grade_item(); $item_locktime = $this->grade_item->get_locktime(); if (empty($this->locktime) or ($item_locktime and $item_locktime < $this->locktime)) { return $item_locktime; } else { return $this->locktime; } }
php
public function get_locktime() { $this->load_grade_item(); $item_locktime = $this->grade_item->get_locktime(); if (empty($this->locktime) or ($item_locktime and $item_locktime < $this->locktime)) { return $item_locktime; } else { return $this->locktime; } }
[ "public", "function", "get_locktime", "(", ")", "{", "$", "this", "->", "load_grade_item", "(", ")", ";", "$", "item_locktime", "=", "$", "this", "->", "grade_item", "->", "get_locktime", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "locktime", ")", "or", "(", "$", "item_locktime", "and", "$", "item_locktime", "<", "$", "this", "->", "locktime", ")", ")", "{", "return", "$", "item_locktime", ";", "}", "else", "{", "return", "$", "this", "->", "locktime", ";", "}", "}" ]
Get the locktime for this grade. @return int $locktime timestamp for lock to activate
[ "Get", "the", "locktime", "for", "this", "grade", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L565-L576
217,435
moodle/moodle
lib/grade/grade_grade.php
grade_grade.is_passed
public function is_passed($grade_item = null) { if (empty($grade_item)) { if (!isset($this->grade_item)) { $this->load_grade_item(); } } else { $this->grade_item = $grade_item; $this->itemid = $grade_item->id; } // Return null if finalgrade is null if (is_null($this->finalgrade)) { return null; } // Return null if gradepass == grademin, gradepass is null, or grade item is a scale and gradepass is 0. if (is_null($this->grade_item->gradepass)) { return null; } else if ($this->grade_item->gradepass == $this->grade_item->grademin) { return null; } else if ($this->grade_item->gradetype == GRADE_TYPE_SCALE && !grade_floats_different($this->grade_item->gradepass, 0.0)) { return null; } return $this->finalgrade >= $this->grade_item->gradepass; }
php
public function is_passed($grade_item = null) { if (empty($grade_item)) { if (!isset($this->grade_item)) { $this->load_grade_item(); } } else { $this->grade_item = $grade_item; $this->itemid = $grade_item->id; } // Return null if finalgrade is null if (is_null($this->finalgrade)) { return null; } // Return null if gradepass == grademin, gradepass is null, or grade item is a scale and gradepass is 0. if (is_null($this->grade_item->gradepass)) { return null; } else if ($this->grade_item->gradepass == $this->grade_item->grademin) { return null; } else if ($this->grade_item->gradetype == GRADE_TYPE_SCALE && !grade_floats_different($this->grade_item->gradepass, 0.0)) { return null; } return $this->finalgrade >= $this->grade_item->gradepass; }
[ "public", "function", "is_passed", "(", "$", "grade_item", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "grade_item", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "grade_item", ")", ")", "{", "$", "this", "->", "load_grade_item", "(", ")", ";", "}", "}", "else", "{", "$", "this", "->", "grade_item", "=", "$", "grade_item", ";", "$", "this", "->", "itemid", "=", "$", "grade_item", "->", "id", ";", "}", "// Return null if finalgrade is null", "if", "(", "is_null", "(", "$", "this", "->", "finalgrade", ")", ")", "{", "return", "null", ";", "}", "// Return null if gradepass == grademin, gradepass is null, or grade item is a scale and gradepass is 0.", "if", "(", "is_null", "(", "$", "this", "->", "grade_item", "->", "gradepass", ")", ")", "{", "return", "null", ";", "}", "else", "if", "(", "$", "this", "->", "grade_item", "->", "gradepass", "==", "$", "this", "->", "grade_item", "->", "grademin", ")", "{", "return", "null", ";", "}", "else", "if", "(", "$", "this", "->", "grade_item", "->", "gradetype", "==", "GRADE_TYPE_SCALE", "&&", "!", "grade_floats_different", "(", "$", "this", "->", "grade_item", "->", "gradepass", ",", "0.0", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "finalgrade", ">=", "$", "this", "->", "grade_item", "->", "gradepass", ";", "}" ]
Returns true if the grade's value is superior or equal to the grade item's gradepass value, false otherwise. @param grade_item $grade_item An optional grade_item of which gradepass value we can use, saves having to load the grade_grade's grade_item @return bool
[ "Returns", "true", "if", "the", "grade", "s", "value", "is", "superior", "or", "equal", "to", "the", "grade", "item", "s", "gradepass", "value", "false", "otherwise", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L989-L1014
217,436
moodle/moodle
lib/grade/grade_grade.php
grade_grade.add_feedback_files
protected function add_feedback_files(int $historyid = null) { global $CFG; // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $this->copy_feedback_files($context, GRADE_FEEDBACK_FILEAREA, $this->id); if (empty($CFG->disablegradehistory) && $historyid) { $this->copy_feedback_files($context, GRADE_HISTORY_FEEDBACK_FILEAREA, $historyid); } } return $this->id; }
php
protected function add_feedback_files(int $historyid = null) { global $CFG; // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $this->copy_feedback_files($context, GRADE_FEEDBACK_FILEAREA, $this->id); if (empty($CFG->disablegradehistory) && $historyid) { $this->copy_feedback_files($context, GRADE_HISTORY_FEEDBACK_FILEAREA, $historyid); } } return $this->id; }
[ "protected", "function", "add_feedback_files", "(", "int", "$", "historyid", "=", "null", ")", "{", "global", "$", "CFG", ";", "// We only support feedback files for modules atm.", "if", "(", "$", "this", "->", "grade_item", "&&", "$", "this", "->", "grade_item", "->", "is_external_item", "(", ")", ")", "{", "$", "context", "=", "$", "this", "->", "get_context", "(", ")", ";", "$", "this", "->", "copy_feedback_files", "(", "$", "context", ",", "GRADE_FEEDBACK_FILEAREA", ",", "$", "this", "->", "id", ")", ";", "if", "(", "empty", "(", "$", "CFG", "->", "disablegradehistory", ")", "&&", "$", "historyid", ")", "{", "$", "this", "->", "copy_feedback_files", "(", "$", "context", ",", "GRADE_HISTORY_FEEDBACK_FILEAREA", ",", "$", "historyid", ")", ";", "}", "}", "return", "$", "this", "->", "id", ";", "}" ]
Handles adding feedback files in the gradebook. @param int|null $historyid
[ "Handles", "adding", "feedback", "files", "in", "the", "gradebook", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L1049-L1063
217,437
moodle/moodle
lib/grade/grade_grade.php
grade_grade.update_feedback_files
protected function update_feedback_files(int $historyid = null) { global $CFG; // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $fs = new file_storage(); $fs->delete_area_files($context->id, GRADE_FILE_COMPONENT, GRADE_FEEDBACK_FILEAREA, $this->id); $this->copy_feedback_files($context, GRADE_FEEDBACK_FILEAREA, $this->id); if (empty($CFG->disablegradehistory) && $historyid) { $this->copy_feedback_files($context, GRADE_HISTORY_FEEDBACK_FILEAREA, $historyid); } } return true; }
php
protected function update_feedback_files(int $historyid = null) { global $CFG; // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $fs = new file_storage(); $fs->delete_area_files($context->id, GRADE_FILE_COMPONENT, GRADE_FEEDBACK_FILEAREA, $this->id); $this->copy_feedback_files($context, GRADE_FEEDBACK_FILEAREA, $this->id); if (empty($CFG->disablegradehistory) && $historyid) { $this->copy_feedback_files($context, GRADE_HISTORY_FEEDBACK_FILEAREA, $historyid); } } return true; }
[ "protected", "function", "update_feedback_files", "(", "int", "$", "historyid", "=", "null", ")", "{", "global", "$", "CFG", ";", "// We only support feedback files for modules atm.", "if", "(", "$", "this", "->", "grade_item", "&&", "$", "this", "->", "grade_item", "->", "is_external_item", "(", ")", ")", "{", "$", "context", "=", "$", "this", "->", "get_context", "(", ")", ";", "$", "fs", "=", "new", "file_storage", "(", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "context", "->", "id", ",", "GRADE_FILE_COMPONENT", ",", "GRADE_FEEDBACK_FILEAREA", ",", "$", "this", "->", "id", ")", ";", "$", "this", "->", "copy_feedback_files", "(", "$", "context", ",", "GRADE_FEEDBACK_FILEAREA", ",", "$", "this", "->", "id", ")", ";", "if", "(", "empty", "(", "$", "CFG", "->", "disablegradehistory", ")", "&&", "$", "historyid", ")", "{", "$", "this", "->", "copy_feedback_files", "(", "$", "context", ",", "GRADE_HISTORY_FEEDBACK_FILEAREA", ",", "$", "historyid", ")", ";", "}", "}", "return", "true", ";", "}" ]
Handles updating feedback files in the gradebook. @param int|null $historyid
[ "Handles", "updating", "feedback", "files", "in", "the", "gradebook", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L1070-L1088
217,438
moodle/moodle
lib/grade/grade_grade.php
grade_grade.delete_feedback_files
protected function delete_feedback_files() { // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $fs = new file_storage(); $fs->delete_area_files($context->id, GRADE_FILE_COMPONENT, GRADE_FEEDBACK_FILEAREA, $this->id); // Grade history only gets deleted when we delete the whole grade item. } return true; }
php
protected function delete_feedback_files() { // We only support feedback files for modules atm. if ($this->grade_item && $this->grade_item->is_external_item()) { $context = $this->get_context(); $fs = new file_storage(); $fs->delete_area_files($context->id, GRADE_FILE_COMPONENT, GRADE_FEEDBACK_FILEAREA, $this->id); // Grade history only gets deleted when we delete the whole grade item. } return true; }
[ "protected", "function", "delete_feedback_files", "(", ")", "{", "// We only support feedback files for modules atm.", "if", "(", "$", "this", "->", "grade_item", "&&", "$", "this", "->", "grade_item", "->", "is_external_item", "(", ")", ")", "{", "$", "context", "=", "$", "this", "->", "get_context", "(", ")", ";", "$", "fs", "=", "new", "file_storage", "(", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "context", "->", "id", ",", "GRADE_FILE_COMPONENT", ",", "GRADE_FEEDBACK_FILEAREA", ",", "$", "this", "->", "id", ")", ";", "// Grade history only gets deleted when we delete the whole grade item.", "}", "return", "true", ";", "}" ]
Handles deleting feedback files in the gradebook.
[ "Handles", "deleting", "feedback", "files", "in", "the", "gradebook", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L1093-L1105
217,439
moodle/moodle
lib/grade/grade_grade.php
grade_grade.delete
public function delete($source = null) { $success = parent::delete($source); // If the grade was deleted successfully trigger a grade_deleted event. if ($success) { $this->load_grade_item(); \core\event\grade_deleted::create_from_grade($this)->trigger(); } return $success; }
php
public function delete($source = null) { $success = parent::delete($source); // If the grade was deleted successfully trigger a grade_deleted event. if ($success) { $this->load_grade_item(); \core\event\grade_deleted::create_from_grade($this)->trigger(); } return $success; }
[ "public", "function", "delete", "(", "$", "source", "=", "null", ")", "{", "$", "success", "=", "parent", "::", "delete", "(", "$", "source", ")", ";", "// If the grade was deleted successfully trigger a grade_deleted event.", "if", "(", "$", "success", ")", "{", "$", "this", "->", "load_grade_item", "(", ")", ";", "\\", "core", "\\", "event", "\\", "grade_deleted", "::", "create_from_grade", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "}", "return", "$", "success", ";", "}" ]
Deletes the grade_grade instance from the database. @param string $source The location the deletion occurred (mod/forum, manual, etc.). @return bool Returns true if the deletion was successful, false otherwise.
[ "Deletes", "the", "grade_grade", "instance", "from", "the", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L1113-L1123
217,440
moodle/moodle
lib/grade/grade_grade.php
grade_grade.copy_feedback_files
private function copy_feedback_files(context $context, string $filearea, int $itemid) { if ($this->feedbackfiles) { $filestocopycontextid = $this->feedbackfiles['contextid']; $filestocopycomponent = $this->feedbackfiles['component']; $filestocopyfilearea = $this->feedbackfiles['filearea']; $filestocopyitemid = $this->feedbackfiles['itemid']; $fs = new file_storage(); if ($filestocopy = $fs->get_area_files($filestocopycontextid, $filestocopycomponent, $filestocopyfilearea, $filestocopyitemid)) { foreach ($filestocopy as $filetocopy) { $destination = [ 'contextid' => $context->id, 'component' => GRADE_FILE_COMPONENT, 'filearea' => $filearea, 'itemid' => $itemid ]; $fs->create_file_from_storedfile($destination, $filetocopy); } } } }
php
private function copy_feedback_files(context $context, string $filearea, int $itemid) { if ($this->feedbackfiles) { $filestocopycontextid = $this->feedbackfiles['contextid']; $filestocopycomponent = $this->feedbackfiles['component']; $filestocopyfilearea = $this->feedbackfiles['filearea']; $filestocopyitemid = $this->feedbackfiles['itemid']; $fs = new file_storage(); if ($filestocopy = $fs->get_area_files($filestocopycontextid, $filestocopycomponent, $filestocopyfilearea, $filestocopyitemid)) { foreach ($filestocopy as $filetocopy) { $destination = [ 'contextid' => $context->id, 'component' => GRADE_FILE_COMPONENT, 'filearea' => $filearea, 'itemid' => $itemid ]; $fs->create_file_from_storedfile($destination, $filetocopy); } } } }
[ "private", "function", "copy_feedback_files", "(", "context", "$", "context", ",", "string", "$", "filearea", ",", "int", "$", "itemid", ")", "{", "if", "(", "$", "this", "->", "feedbackfiles", ")", "{", "$", "filestocopycontextid", "=", "$", "this", "->", "feedbackfiles", "[", "'contextid'", "]", ";", "$", "filestocopycomponent", "=", "$", "this", "->", "feedbackfiles", "[", "'component'", "]", ";", "$", "filestocopyfilearea", "=", "$", "this", "->", "feedbackfiles", "[", "'filearea'", "]", ";", "$", "filestocopyitemid", "=", "$", "this", "->", "feedbackfiles", "[", "'itemid'", "]", ";", "$", "fs", "=", "new", "file_storage", "(", ")", ";", "if", "(", "$", "filestocopy", "=", "$", "fs", "->", "get_area_files", "(", "$", "filestocopycontextid", ",", "$", "filestocopycomponent", ",", "$", "filestocopyfilearea", ",", "$", "filestocopyitemid", ")", ")", "{", "foreach", "(", "$", "filestocopy", "as", "$", "filetocopy", ")", "{", "$", "destination", "=", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'component'", "=>", "GRADE_FILE_COMPONENT", ",", "'filearea'", "=>", "$", "filearea", ",", "'itemid'", "=>", "$", "itemid", "]", ";", "$", "fs", "->", "create_file_from_storedfile", "(", "$", "destination", ",", "$", "filetocopy", ")", ";", "}", "}", "}", "}" ]
Handles copying feedback files to a specified gradebook file area. @param context $context @param string $filearea @param int $itemid
[ "Handles", "copying", "feedback", "files", "to", "a", "specified", "gradebook", "file", "area", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/grade/grade_grade.php#L1212-L1233
217,441
moodle/moodle
lib/pear/PEAR/Exception.php
PEAR_Exception.getCauseMessage
public function getCauseMessage(&$causes) { $trace = $this->getTraceSafe(); $cause = array('class' => get_class($this), 'message' => $this->message, 'file' => 'unknown', 'line' => 'unknown'); if (isset($trace[0])) { if (isset($trace[0]['file'])) { $cause['file'] = $trace[0]['file']; $cause['line'] = $trace[0]['line']; } } $causes[] = $cause; if ($this->cause instanceof PEAR_Exception) { $this->cause->getCauseMessage($causes); } elseif ($this->cause instanceof Exception) { $causes[] = array('class' => get_class($this->cause), 'message' => $this->cause->getMessage(), 'file' => $this->cause->getFile(), 'line' => $this->cause->getLine()); } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { $causes[] = array('class' => get_class($this->cause), 'message' => $this->cause->getMessage(), 'file' => 'unknown', 'line' => 'unknown'); } elseif (is_array($this->cause)) { foreach ($this->cause as $cause) { if ($cause instanceof PEAR_Exception) { $cause->getCauseMessage($causes); } elseif ($cause instanceof Exception) { $causes[] = array('class' => get_class($cause), 'message' => $cause->getMessage(), 'file' => $cause->getFile(), 'line' => $cause->getLine()); } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { $causes[] = array('class' => get_class($cause), 'message' => $cause->getMessage(), 'file' => 'unknown', 'line' => 'unknown'); } elseif (is_array($cause) && isset($cause['message'])) { // PEAR_ErrorStack warning $causes[] = array( 'class' => $cause['package'], 'message' => $cause['message'], 'file' => isset($cause['context']['file']) ? $cause['context']['file'] : 'unknown', 'line' => isset($cause['context']['line']) ? $cause['context']['line'] : 'unknown', ); } } } }
php
public function getCauseMessage(&$causes) { $trace = $this->getTraceSafe(); $cause = array('class' => get_class($this), 'message' => $this->message, 'file' => 'unknown', 'line' => 'unknown'); if (isset($trace[0])) { if (isset($trace[0]['file'])) { $cause['file'] = $trace[0]['file']; $cause['line'] = $trace[0]['line']; } } $causes[] = $cause; if ($this->cause instanceof PEAR_Exception) { $this->cause->getCauseMessage($causes); } elseif ($this->cause instanceof Exception) { $causes[] = array('class' => get_class($this->cause), 'message' => $this->cause->getMessage(), 'file' => $this->cause->getFile(), 'line' => $this->cause->getLine()); } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { $causes[] = array('class' => get_class($this->cause), 'message' => $this->cause->getMessage(), 'file' => 'unknown', 'line' => 'unknown'); } elseif (is_array($this->cause)) { foreach ($this->cause as $cause) { if ($cause instanceof PEAR_Exception) { $cause->getCauseMessage($causes); } elseif ($cause instanceof Exception) { $causes[] = array('class' => get_class($cause), 'message' => $cause->getMessage(), 'file' => $cause->getFile(), 'line' => $cause->getLine()); } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { $causes[] = array('class' => get_class($cause), 'message' => $cause->getMessage(), 'file' => 'unknown', 'line' => 'unknown'); } elseif (is_array($cause) && isset($cause['message'])) { // PEAR_ErrorStack warning $causes[] = array( 'class' => $cause['package'], 'message' => $cause['message'], 'file' => isset($cause['context']['file']) ? $cause['context']['file'] : 'unknown', 'line' => isset($cause['context']['line']) ? $cause['context']['line'] : 'unknown', ); } } } }
[ "public", "function", "getCauseMessage", "(", "&", "$", "causes", ")", "{", "$", "trace", "=", "$", "this", "->", "getTraceSafe", "(", ")", ";", "$", "cause", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "this", ")", ",", "'message'", "=>", "$", "this", "->", "message", ",", "'file'", "=>", "'unknown'", ",", "'line'", "=>", "'unknown'", ")", ";", "if", "(", "isset", "(", "$", "trace", "[", "0", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "trace", "[", "0", "]", "[", "'file'", "]", ")", ")", "{", "$", "cause", "[", "'file'", "]", "=", "$", "trace", "[", "0", "]", "[", "'file'", "]", ";", "$", "cause", "[", "'line'", "]", "=", "$", "trace", "[", "0", "]", "[", "'line'", "]", ";", "}", "}", "$", "causes", "[", "]", "=", "$", "cause", ";", "if", "(", "$", "this", "->", "cause", "instanceof", "PEAR_Exception", ")", "{", "$", "this", "->", "cause", "->", "getCauseMessage", "(", "$", "causes", ")", ";", "}", "elseif", "(", "$", "this", "->", "cause", "instanceof", "Exception", ")", "{", "$", "causes", "[", "]", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "this", "->", "cause", ")", ",", "'message'", "=>", "$", "this", "->", "cause", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "this", "->", "cause", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "this", "->", "cause", "->", "getLine", "(", ")", ")", ";", "}", "elseif", "(", "class_exists", "(", "'PEAR_Error'", ")", "&&", "$", "this", "->", "cause", "instanceof", "PEAR_Error", ")", "{", "$", "causes", "[", "]", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "this", "->", "cause", ")", ",", "'message'", "=>", "$", "this", "->", "cause", "->", "getMessage", "(", ")", ",", "'file'", "=>", "'unknown'", ",", "'line'", "=>", "'unknown'", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "this", "->", "cause", ")", ")", "{", "foreach", "(", "$", "this", "->", "cause", "as", "$", "cause", ")", "{", "if", "(", "$", "cause", "instanceof", "PEAR_Exception", ")", "{", "$", "cause", "->", "getCauseMessage", "(", "$", "causes", ")", ";", "}", "elseif", "(", "$", "cause", "instanceof", "Exception", ")", "{", "$", "causes", "[", "]", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "cause", ")", ",", "'message'", "=>", "$", "cause", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "cause", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "cause", "->", "getLine", "(", ")", ")", ";", "}", "elseif", "(", "class_exists", "(", "'PEAR_Error'", ")", "&&", "$", "cause", "instanceof", "PEAR_Error", ")", "{", "$", "causes", "[", "]", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "cause", ")", ",", "'message'", "=>", "$", "cause", "->", "getMessage", "(", ")", ",", "'file'", "=>", "'unknown'", ",", "'line'", "=>", "'unknown'", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "cause", ")", "&&", "isset", "(", "$", "cause", "[", "'message'", "]", ")", ")", "{", "// PEAR_ErrorStack warning", "$", "causes", "[", "]", "=", "array", "(", "'class'", "=>", "$", "cause", "[", "'package'", "]", ",", "'message'", "=>", "$", "cause", "[", "'message'", "]", ",", "'file'", "=>", "isset", "(", "$", "cause", "[", "'context'", "]", "[", "'file'", "]", ")", "?", "$", "cause", "[", "'context'", "]", "[", "'file'", "]", ":", "'unknown'", ",", "'line'", "=>", "isset", "(", "$", "cause", "[", "'context'", "]", "[", "'line'", "]", ")", "?", "$", "cause", "[", "'context'", "]", "[", "'line'", "]", ":", "'unknown'", ",", ")", ";", "}", "}", "}", "}" ]
Function must be public to call on caused exceptions @param array
[ "Function", "must", "be", "public", "to", "call", "on", "caused", "exceptions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR/Exception.php#L234-L289
217,442
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.is_first
public final function is_first() { $order = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder'); if ($order == 0) { return true; } return false; }
php
public final function is_first() { $order = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder'); if ($order == 0) { return true; } return false; }
[ "public", "final", "function", "is_first", "(", ")", "{", "$", "order", "=", "get_config", "(", "$", "this", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "this", "->", "get_type", "(", ")", ",", "'sortorder'", ")", ";", "if", "(", "$", "order", "==", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is this the first plugin in the list? @return bool
[ "Is", "this", "the", "first", "plugin", "in", "the", "list?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L66-L73
217,443
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.is_last
public final function is_last() { $lastindex = count(core_component::get_plugin_list($this->get_subtype()))-1; $currentindex = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder'); if ($lastindex == $currentindex) { return true; } return false; }
php
public final function is_last() { $lastindex = count(core_component::get_plugin_list($this->get_subtype()))-1; $currentindex = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder'); if ($lastindex == $currentindex) { return true; } return false; }
[ "public", "final", "function", "is_last", "(", ")", "{", "$", "lastindex", "=", "count", "(", "core_component", "::", "get_plugin_list", "(", "$", "this", "->", "get_subtype", "(", ")", ")", ")", "-", "1", ";", "$", "currentindex", "=", "get_config", "(", "$", "this", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "this", "->", "get_type", "(", ")", ",", "'sortorder'", ")", ";", "if", "(", "$", "lastindex", "==", "$", "currentindex", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is this the last plugin in the list? @return bool
[ "Is", "this", "the", "last", "plugin", "in", "the", "list?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L80-L88
217,444
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.is_visible
public final function is_visible() { if ($this->visiblecache === null) { $disabled = get_config($this->get_subtype() . '_' . $this->get_type(), 'disabled'); $this->visiblecache = !$disabled; } return $this->visiblecache; }
php
public final function is_visible() { if ($this->visiblecache === null) { $disabled = get_config($this->get_subtype() . '_' . $this->get_type(), 'disabled'); $this->visiblecache = !$disabled; } return $this->visiblecache; }
[ "public", "final", "function", "is_visible", "(", ")", "{", "if", "(", "$", "this", "->", "visiblecache", "===", "null", ")", "{", "$", "disabled", "=", "get_config", "(", "$", "this", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "this", "->", "get_type", "(", ")", ",", "'disabled'", ")", ";", "$", "this", "->", "visiblecache", "=", "!", "$", "disabled", ";", "}", "return", "$", "this", "->", "visiblecache", ";", "}" ]
Is this plugin enaled? @return bool
[ "Is", "this", "plugin", "enaled?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L292-L298
217,445
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.has_admin_settings
public final function has_admin_settings() { global $CFG; $pluginroot = $CFG->dirroot . '/mod/assign/' . substr($this->get_subtype(), strlen('assign')) . '/' . $this->get_type(); $settingsfile = $pluginroot . '/settings.php'; return file_exists($settingsfile); }
php
public final function has_admin_settings() { global $CFG; $pluginroot = $CFG->dirroot . '/mod/assign/' . substr($this->get_subtype(), strlen('assign')) . '/' . $this->get_type(); $settingsfile = $pluginroot . '/settings.php'; return file_exists($settingsfile); }
[ "public", "final", "function", "has_admin_settings", "(", ")", "{", "global", "$", "CFG", ";", "$", "pluginroot", "=", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/'", ".", "substr", "(", "$", "this", "->", "get_subtype", "(", ")", ",", "strlen", "(", "'assign'", ")", ")", ".", "'/'", ".", "$", "this", "->", "get_type", "(", ")", ";", "$", "settingsfile", "=", "$", "pluginroot", ".", "'/settings.php'", ";", "return", "file_exists", "(", "$", "settingsfile", ")", ";", "}" ]
Has this plugin got a custom settings.php file? @return bool
[ "Has", "this", "plugin", "got", "a", "custom", "settings", ".", "php", "file?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L306-L312
217,446
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.set_config
public final function set_config($name, $value) { global $DB; $dbparams = array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$name); $current = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING); if ($current) { $current->value = $value; return $DB->update_record('assign_plugin_config', $current); } else { $setting = new stdClass(); $setting->assignment = $this->assignment->get_instance()->id; $setting->subtype = $this->get_subtype(); $setting->plugin = $this->get_type(); $setting->name = $name; $setting->value = $value; return $DB->insert_record('assign_plugin_config', $setting) > 0; } }
php
public final function set_config($name, $value) { global $DB; $dbparams = array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$name); $current = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING); if ($current) { $current->value = $value; return $DB->update_record('assign_plugin_config', $current); } else { $setting = new stdClass(); $setting->assignment = $this->assignment->get_instance()->id; $setting->subtype = $this->get_subtype(); $setting->plugin = $this->get_type(); $setting->name = $name; $setting->value = $value; return $DB->insert_record('assign_plugin_config', $setting) > 0; } }
[ "public", "final", "function", "set_config", "(", "$", "name", ",", "$", "value", ")", "{", "global", "$", "DB", ";", "$", "dbparams", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "assignment", "->", "get_instance", "(", ")", "->", "id", ",", "'subtype'", "=>", "$", "this", "->", "get_subtype", "(", ")", ",", "'plugin'", "=>", "$", "this", "->", "get_type", "(", ")", ",", "'name'", "=>", "$", "name", ")", ";", "$", "current", "=", "$", "DB", "->", "get_record", "(", "'assign_plugin_config'", ",", "$", "dbparams", ",", "'*'", ",", "IGNORE_MISSING", ")", ";", "if", "(", "$", "current", ")", "{", "$", "current", "->", "value", "=", "$", "value", ";", "return", "$", "DB", "->", "update_record", "(", "'assign_plugin_config'", ",", "$", "current", ")", ";", "}", "else", "{", "$", "setting", "=", "new", "stdClass", "(", ")", ";", "$", "setting", "->", "assignment", "=", "$", "this", "->", "assignment", "->", "get_instance", "(", ")", "->", "id", ";", "$", "setting", "->", "subtype", "=", "$", "this", "->", "get_subtype", "(", ")", ";", "$", "setting", "->", "plugin", "=", "$", "this", "->", "get_type", "(", ")", ";", "$", "setting", "->", "name", "=", "$", "name", ";", "$", "setting", "->", "value", "=", "$", "value", ";", "return", "$", "DB", "->", "insert_record", "(", "'assign_plugin_config'", ",", "$", "setting", ")", ">", "0", ";", "}", "}" ]
Set a configuration value for this plugin @param string $name The config key @param string $value The config value @return bool
[ "Set", "a", "configuration", "value", "for", "this", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L321-L343
217,447
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.get_config
public final function get_config($setting = null) { global $DB; if ($setting) { if (!$this->assignment->has_instance()) { return false; } $assignment = $this->assignment->get_instance(); if ($assignment) { $dbparams = array('assignment'=>$assignment->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$setting); $result = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING); if ($result) { return $result->value; } } return false; } $dbparams = array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type()); $results = $DB->get_records('assign_plugin_config', $dbparams); $config = new stdClass(); if (is_array($results)) { foreach ($results as $setting) { $name = $setting->name; $config->$name = $setting->value; } } return $config; }
php
public final function get_config($setting = null) { global $DB; if ($setting) { if (!$this->assignment->has_instance()) { return false; } $assignment = $this->assignment->get_instance(); if ($assignment) { $dbparams = array('assignment'=>$assignment->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type(), 'name'=>$setting); $result = $DB->get_record('assign_plugin_config', $dbparams, '*', IGNORE_MISSING); if ($result) { return $result->value; } } return false; } $dbparams = array('assignment'=>$this->assignment->get_instance()->id, 'subtype'=>$this->get_subtype(), 'plugin'=>$this->get_type()); $results = $DB->get_records('assign_plugin_config', $dbparams); $config = new stdClass(); if (is_array($results)) { foreach ($results as $setting) { $name = $setting->name; $config->$name = $setting->value; } } return $config; }
[ "public", "final", "function", "get_config", "(", "$", "setting", "=", "null", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "setting", ")", "{", "if", "(", "!", "$", "this", "->", "assignment", "->", "has_instance", "(", ")", ")", "{", "return", "false", ";", "}", "$", "assignment", "=", "$", "this", "->", "assignment", "->", "get_instance", "(", ")", ";", "if", "(", "$", "assignment", ")", "{", "$", "dbparams", "=", "array", "(", "'assignment'", "=>", "$", "assignment", "->", "id", ",", "'subtype'", "=>", "$", "this", "->", "get_subtype", "(", ")", ",", "'plugin'", "=>", "$", "this", "->", "get_type", "(", ")", ",", "'name'", "=>", "$", "setting", ")", ";", "$", "result", "=", "$", "DB", "->", "get_record", "(", "'assign_plugin_config'", ",", "$", "dbparams", ",", "'*'", ",", "IGNORE_MISSING", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "result", "->", "value", ";", "}", "}", "return", "false", ";", "}", "$", "dbparams", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "assignment", "->", "get_instance", "(", ")", "->", "id", ",", "'subtype'", "=>", "$", "this", "->", "get_subtype", "(", ")", ",", "'plugin'", "=>", "$", "this", "->", "get_type", "(", ")", ")", ";", "$", "results", "=", "$", "DB", "->", "get_records", "(", "'assign_plugin_config'", ",", "$", "dbparams", ")", ";", "$", "config", "=", "new", "stdClass", "(", ")", ";", "if", "(", "is_array", "(", "$", "results", ")", ")", "{", "foreach", "(", "$", "results", "as", "$", "setting", ")", "{", "$", "name", "=", "$", "setting", "->", "name", ";", "$", "config", "->", "$", "name", "=", "$", "setting", "->", "value", ";", "}", "}", "return", "$", "config", ";", "}" ]
Get a configuration value for this plugin @param mixed $setting The config key (string) or null @return mixed string | false
[ "Get", "a", "configuration", "value", "for", "this", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L351-L384
217,448
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.upgrade_settings
public function upgrade_settings(context $oldcontext, stdClass $oldassignment, & $log) { $params = array('type'=>$this->type, 'subtype'=>$this->get_subtype()); $log .= ' ' . get_string('upgradenotimplemented', 'mod_assign', $params); return false; }
php
public function upgrade_settings(context $oldcontext, stdClass $oldassignment, & $log) { $params = array('type'=>$this->type, 'subtype'=>$this->get_subtype()); $log .= ' ' . get_string('upgradenotimplemented', 'mod_assign', $params); return false; }
[ "public", "function", "upgrade_settings", "(", "context", "$", "oldcontext", ",", "stdClass", "$", "oldassignment", ",", "&", "$", "log", ")", "{", "$", "params", "=", "array", "(", "'type'", "=>", "$", "this", "->", "type", ",", "'subtype'", "=>", "$", "this", "->", "get_subtype", "(", ")", ")", ";", "$", "log", ".=", "' '", ".", "get_string", "(", "'upgradenotimplemented'", ",", "'mod_assign'", ",", "$", "params", ")", ";", "return", "false", ";", "}" ]
Upgrade the settings from the old assignment to the new one @param context $oldcontext The context for the old assignment module @param stdClass $oldassignment The data record for the old assignment @param string $log Record upgrade messages in the log @return bool true or false - false will trigger a rollback
[ "Upgrade", "the", "settings", "from", "the", "old", "assignment", "to", "the", "new", "one" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L498-L502
217,449
moodle/moodle
mod/assign/assignmentplugin.php
assign_plugin.get_file_info
public function get_file_info($browser, $filearea, $itemid, $filepath, $filename) { global $CFG, $DB, $USER; $urlbase = $CFG->wwwroot.'/pluginfile.php'; $writeaccess = false; // Permission check on the itemid. $assignment = $this->assignment; if ($this->get_subtype() == 'assignsubmission') { if ($itemid) { $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid,groupid', IGNORE_MISSING); if (!$record) { return null; } if (!empty($record->userid)) { if (!$assignment->can_view_submission($record->userid)) { return null; } // We only report write access for teachers. $writeaccess = $assignment->can_grade() && $assignment->can_edit_submission($record->userid); } else { // Must be a team submission with a group. if (!$assignment->can_view_group_submission($record->groupid)) { return null; } // We only report write access for teachers. $writeaccess = $assignment->can_grade() && $assignment->can_edit_group_submission($record->groupid); } } } else { // Not supported for feedback plugins. return null; } $fs = get_file_storage(); $filepath = is_null($filepath) ? '/' : $filepath; $filename = is_null($filename) ? '.' : $filename; if (!($storedfile = $fs->get_file($assignment->get_context()->id, $this->get_subtype() . '_' . $this->get_type(), $filearea, $itemid, $filepath, $filename))) { return null; } return new file_info_stored($browser, $assignment->get_context(), $storedfile, $urlbase, $filearea, $itemid, true, $writeaccess, false); }
php
public function get_file_info($browser, $filearea, $itemid, $filepath, $filename) { global $CFG, $DB, $USER; $urlbase = $CFG->wwwroot.'/pluginfile.php'; $writeaccess = false; // Permission check on the itemid. $assignment = $this->assignment; if ($this->get_subtype() == 'assignsubmission') { if ($itemid) { $record = $DB->get_record('assign_submission', array('id' => $itemid), 'userid,groupid', IGNORE_MISSING); if (!$record) { return null; } if (!empty($record->userid)) { if (!$assignment->can_view_submission($record->userid)) { return null; } // We only report write access for teachers. $writeaccess = $assignment->can_grade() && $assignment->can_edit_submission($record->userid); } else { // Must be a team submission with a group. if (!$assignment->can_view_group_submission($record->groupid)) { return null; } // We only report write access for teachers. $writeaccess = $assignment->can_grade() && $assignment->can_edit_group_submission($record->groupid); } } } else { // Not supported for feedback plugins. return null; } $fs = get_file_storage(); $filepath = is_null($filepath) ? '/' : $filepath; $filename = is_null($filename) ? '.' : $filename; if (!($storedfile = $fs->get_file($assignment->get_context()->id, $this->get_subtype() . '_' . $this->get_type(), $filearea, $itemid, $filepath, $filename))) { return null; } return new file_info_stored($browser, $assignment->get_context(), $storedfile, $urlbase, $filearea, $itemid, true, $writeaccess, false); }
[ "public", "function", "get_file_info", "(", "$", "browser", ",", "$", "filearea", ",", "$", "itemid", ",", "$", "filepath", ",", "$", "filename", ")", "{", "global", "$", "CFG", ",", "$", "DB", ",", "$", "USER", ";", "$", "urlbase", "=", "$", "CFG", "->", "wwwroot", ".", "'/pluginfile.php'", ";", "$", "writeaccess", "=", "false", ";", "// Permission check on the itemid.", "$", "assignment", "=", "$", "this", "->", "assignment", ";", "if", "(", "$", "this", "->", "get_subtype", "(", ")", "==", "'assignsubmission'", ")", "{", "if", "(", "$", "itemid", ")", "{", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'assign_submission'", ",", "array", "(", "'id'", "=>", "$", "itemid", ")", ",", "'userid,groupid'", ",", "IGNORE_MISSING", ")", ";", "if", "(", "!", "$", "record", ")", "{", "return", "null", ";", "}", "if", "(", "!", "empty", "(", "$", "record", "->", "userid", ")", ")", "{", "if", "(", "!", "$", "assignment", "->", "can_view_submission", "(", "$", "record", "->", "userid", ")", ")", "{", "return", "null", ";", "}", "// We only report write access for teachers.", "$", "writeaccess", "=", "$", "assignment", "->", "can_grade", "(", ")", "&&", "$", "assignment", "->", "can_edit_submission", "(", "$", "record", "->", "userid", ")", ";", "}", "else", "{", "// Must be a team submission with a group.", "if", "(", "!", "$", "assignment", "->", "can_view_group_submission", "(", "$", "record", "->", "groupid", ")", ")", "{", "return", "null", ";", "}", "// We only report write access for teachers.", "$", "writeaccess", "=", "$", "assignment", "->", "can_grade", "(", ")", "&&", "$", "assignment", "->", "can_edit_group_submission", "(", "$", "record", "->", "groupid", ")", ";", "}", "}", "}", "else", "{", "// Not supported for feedback plugins.", "return", "null", ";", "}", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "filepath", "=", "is_null", "(", "$", "filepath", ")", "?", "'/'", ":", "$", "filepath", ";", "$", "filename", "=", "is_null", "(", "$", "filename", ")", "?", "'.'", ":", "$", "filename", ";", "if", "(", "!", "(", "$", "storedfile", "=", "$", "fs", "->", "get_file", "(", "$", "assignment", "->", "get_context", "(", ")", "->", "id", ",", "$", "this", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "this", "->", "get_type", "(", ")", ",", "$", "filearea", ",", "$", "itemid", ",", "$", "filepath", ",", "$", "filename", ")", ")", ")", "{", "return", "null", ";", "}", "return", "new", "file_info_stored", "(", "$", "browser", ",", "$", "assignment", "->", "get_context", "(", ")", ",", "$", "storedfile", ",", "$", "urlbase", ",", "$", "filearea", ",", "$", "itemid", ",", "true", ",", "$", "writeaccess", ",", "false", ")", ";", "}" ]
Default implementation of file_get_info for plugins. This is used by the filebrowser to browse a plugins file areas. This implementation should work for most plugins but can be overridden if required. @param file_browser $browser @param string $filearea @param int $itemid @param string $filepath @param string $filename @return file_info_stored
[ "Default", "implementation", "of", "file_get_info", "for", "plugins", ".", "This", "is", "used", "by", "the", "filebrowser", "to", "browse", "a", "plugins", "file", "areas", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/assignmentplugin.php#L580-L635
217,450
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.reset_caches
public static function reset_caches($phpunitreset = false) { if ($phpunitreset) { static::$singletoninstance = null; } else { if (static::$singletoninstance) { static::$singletoninstance->pluginsinfo = null; static::$singletoninstance->subpluginsinfo = null; static::$singletoninstance->remotepluginsinfoatleast = null; static::$singletoninstance->remotepluginsinfoexact = null; static::$singletoninstance->installedplugins = null; static::$singletoninstance->enabledplugins = null; static::$singletoninstance->presentplugins = null; static::$singletoninstance->plugintypes = null; static::$singletoninstance->codemanager = null; static::$singletoninstance->updateapiclient = null; } } $cache = cache::make('core', 'plugin_manager'); $cache->purge(); }
php
public static function reset_caches($phpunitreset = false) { if ($phpunitreset) { static::$singletoninstance = null; } else { if (static::$singletoninstance) { static::$singletoninstance->pluginsinfo = null; static::$singletoninstance->subpluginsinfo = null; static::$singletoninstance->remotepluginsinfoatleast = null; static::$singletoninstance->remotepluginsinfoexact = null; static::$singletoninstance->installedplugins = null; static::$singletoninstance->enabledplugins = null; static::$singletoninstance->presentplugins = null; static::$singletoninstance->plugintypes = null; static::$singletoninstance->codemanager = null; static::$singletoninstance->updateapiclient = null; } } $cache = cache::make('core', 'plugin_manager'); $cache->purge(); }
[ "public", "static", "function", "reset_caches", "(", "$", "phpunitreset", "=", "false", ")", "{", "if", "(", "$", "phpunitreset", ")", "{", "static", "::", "$", "singletoninstance", "=", "null", ";", "}", "else", "{", "if", "(", "static", "::", "$", "singletoninstance", ")", "{", "static", "::", "$", "singletoninstance", "->", "pluginsinfo", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "subpluginsinfo", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "remotepluginsinfoatleast", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "remotepluginsinfoexact", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "installedplugins", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "enabledplugins", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "presentplugins", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "plugintypes", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "codemanager", "=", "null", ";", "static", "::", "$", "singletoninstance", "->", "updateapiclient", "=", "null", ";", "}", "}", "$", "cache", "=", "cache", "::", "make", "(", "'core'", ",", "'plugin_manager'", ")", ";", "$", "cache", "->", "purge", "(", ")", ";", "}" ]
Reset all caches. @param bool $phpunitreset
[ "Reset", "all", "caches", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L119-L138
217,451
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_installed_plugins
public function get_installed_plugins($type) { $this->load_installed_plugins(); if (isset($this->installedplugins[$type])) { return $this->installedplugins[$type]; } return array(); }
php
public function get_installed_plugins($type) { $this->load_installed_plugins(); if (isset($this->installedplugins[$type])) { return $this->installedplugins[$type]; } return array(); }
[ "public", "function", "get_installed_plugins", "(", "$", "type", ")", "{", "$", "this", "->", "load_installed_plugins", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "installedplugins", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "installedplugins", "[", "$", "type", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
Return list of installed plugins of given type. @param string $type @return array $name=>$version
[ "Return", "list", "of", "installed", "plugins", "of", "given", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L212-L218
217,452
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_enabled_plugins
public function get_enabled_plugins($type) { $this->load_enabled_plugins(); if (isset($this->enabledplugins[$type])) { return $this->enabledplugins[$type]; } return null; }
php
public function get_enabled_plugins($type) { $this->load_enabled_plugins(); if (isset($this->enabledplugins[$type])) { return $this->enabledplugins[$type]; } return null; }
[ "public", "function", "get_enabled_plugins", "(", "$", "type", ")", "{", "$", "this", "->", "load_enabled_plugins", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "enabledplugins", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "enabledplugins", "[", "$", "type", "]", ";", "}", "return", "null", ";", "}" ]
Get list of enabled plugins of given type, the result may contain missing plugins. @param string $type @return array|null list of enabled plugins of this type, null if unknown
[ "Get", "list", "of", "enabled", "plugins", "of", "given", "type", "the", "result", "may", "contain", "missing", "plugins", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L272-L278
217,453
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_present_plugins
public function get_present_plugins($type) { $this->load_present_plugins(); if (isset($this->presentplugins[$type])) { return $this->presentplugins[$type]; } return null; }
php
public function get_present_plugins($type) { $this->load_present_plugins(); if (isset($this->presentplugins[$type])) { return $this->presentplugins[$type]; } return null; }
[ "public", "function", "get_present_plugins", "(", "$", "type", ")", "{", "$", "this", "->", "load_present_plugins", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "presentplugins", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "presentplugins", "[", "$", "type", "]", ";", "}", "return", "null", ";", "}" ]
Get list of present plugins of given type. @param string $type @return array|null list of presnet plugins $name=>$diskversion, null if unknown
[ "Get", "list", "of", "present", "plugins", "of", "given", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L334-L340
217,454
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_plugins
public function get_plugins() { $this->init_pluginsinfo_property(); // Make sure all types are initialised. foreach ($this->pluginsinfo as $plugintype => $list) { if ($list === null) { $this->get_plugins_of_type($plugintype); } } return $this->pluginsinfo; }
php
public function get_plugins() { $this->init_pluginsinfo_property(); // Make sure all types are initialised. foreach ($this->pluginsinfo as $plugintype => $list) { if ($list === null) { $this->get_plugins_of_type($plugintype); } } return $this->pluginsinfo; }
[ "public", "function", "get_plugins", "(", ")", "{", "$", "this", "->", "init_pluginsinfo_property", "(", ")", ";", "// Make sure all types are initialised.", "foreach", "(", "$", "this", "->", "pluginsinfo", "as", "$", "plugintype", "=>", "$", "list", ")", "{", "if", "(", "$", "list", "===", "null", ")", "{", "$", "this", "->", "get_plugins_of_type", "(", "$", "plugintype", ")", ";", "}", "}", "return", "$", "this", "->", "pluginsinfo", ";", "}" ]
Returns a tree of known plugins and information about them @return array 2D array. The first keys are plugin type names (e.g. qtype); the second keys are the plugin local name (e.g. multichoice); and the values are the corresponding objects extending {@link \core\plugininfo\base}
[ "Returns", "a", "tree", "of", "known", "plugins", "and", "information", "about", "them" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L349-L360
217,455
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_plugins_of_type
public function get_plugins_of_type($type) { global $CFG; $this->init_pluginsinfo_property(); if (!array_key_exists($type, $this->pluginsinfo)) { return array(); } if (is_array($this->pluginsinfo[$type])) { return $this->pluginsinfo[$type]; } $types = core_component::get_plugin_types(); if (!isset($types[$type])) { // Orphaned subplugins! $plugintypeclass = static::resolve_plugininfo_class($type); $this->pluginsinfo[$type] = $plugintypeclass::get_plugins($type, null, $plugintypeclass, $this); return $this->pluginsinfo[$type]; } /** @var \core\plugininfo\base $plugintypeclass */ $plugintypeclass = static::resolve_plugininfo_class($type); $plugins = $plugintypeclass::get_plugins($type, $types[$type], $plugintypeclass, $this); $this->pluginsinfo[$type] = $plugins; return $this->pluginsinfo[$type]; }
php
public function get_plugins_of_type($type) { global $CFG; $this->init_pluginsinfo_property(); if (!array_key_exists($type, $this->pluginsinfo)) { return array(); } if (is_array($this->pluginsinfo[$type])) { return $this->pluginsinfo[$type]; } $types = core_component::get_plugin_types(); if (!isset($types[$type])) { // Orphaned subplugins! $plugintypeclass = static::resolve_plugininfo_class($type); $this->pluginsinfo[$type] = $plugintypeclass::get_plugins($type, null, $plugintypeclass, $this); return $this->pluginsinfo[$type]; } /** @var \core\plugininfo\base $plugintypeclass */ $plugintypeclass = static::resolve_plugininfo_class($type); $plugins = $plugintypeclass::get_plugins($type, $types[$type], $plugintypeclass, $this); $this->pluginsinfo[$type] = $plugins; return $this->pluginsinfo[$type]; }
[ "public", "function", "get_plugins_of_type", "(", "$", "type", ")", "{", "global", "$", "CFG", ";", "$", "this", "->", "init_pluginsinfo_property", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "pluginsinfo", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", ";", "}", "$", "types", "=", "core_component", "::", "get_plugin_types", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "types", "[", "$", "type", "]", ")", ")", "{", "// Orphaned subplugins!", "$", "plugintypeclass", "=", "static", "::", "resolve_plugininfo_class", "(", "$", "type", ")", ";", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", "=", "$", "plugintypeclass", "::", "get_plugins", "(", "$", "type", ",", "null", ",", "$", "plugintypeclass", ",", "$", "this", ")", ";", "return", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", ";", "}", "/** @var \\core\\plugininfo\\base $plugintypeclass */", "$", "plugintypeclass", "=", "static", "::", "resolve_plugininfo_class", "(", "$", "type", ")", ";", "$", "plugins", "=", "$", "plugintypeclass", "::", "get_plugins", "(", "$", "type", ",", "$", "types", "[", "$", "type", "]", ",", "$", "plugintypeclass", ",", "$", "this", ")", ";", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", "=", "$", "plugins", ";", "return", "$", "this", "->", "pluginsinfo", "[", "$", "type", "]", ";", "}" ]
Returns list of known plugins of the given type. This method returns the subset of the tree returned by {@link self::get_plugins()}. If the given type is not known, empty array is returned. @param string $type plugin type, e.g. 'mod' or 'workshopallocation' @return \core\plugininfo\base[] (string)plugin name (e.g. 'workshop') => corresponding subclass of {@link \core\plugininfo\base}
[ "Returns", "list", "of", "known", "plugins", "of", "the", "given", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L371-L399
217,456
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.init_pluginsinfo_property
protected function init_pluginsinfo_property() { if (is_array($this->pluginsinfo)) { return; } $this->pluginsinfo = array(); $plugintypes = $this->get_plugin_types(); foreach ($plugintypes as $plugintype => $plugintyperootdir) { $this->pluginsinfo[$plugintype] = null; } // Add orphaned subplugin types. $this->load_installed_plugins(); foreach ($this->installedplugins as $plugintype => $unused) { if (!isset($plugintypes[$plugintype])) { $this->pluginsinfo[$plugintype] = null; } } }
php
protected function init_pluginsinfo_property() { if (is_array($this->pluginsinfo)) { return; } $this->pluginsinfo = array(); $plugintypes = $this->get_plugin_types(); foreach ($plugintypes as $plugintype => $plugintyperootdir) { $this->pluginsinfo[$plugintype] = null; } // Add orphaned subplugin types. $this->load_installed_plugins(); foreach ($this->installedplugins as $plugintype => $unused) { if (!isset($plugintypes[$plugintype])) { $this->pluginsinfo[$plugintype] = null; } } }
[ "protected", "function", "init_pluginsinfo_property", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "pluginsinfo", ")", ")", "{", "return", ";", "}", "$", "this", "->", "pluginsinfo", "=", "array", "(", ")", ";", "$", "plugintypes", "=", "$", "this", "->", "get_plugin_types", "(", ")", ";", "foreach", "(", "$", "plugintypes", "as", "$", "plugintype", "=>", "$", "plugintyperootdir", ")", "{", "$", "this", "->", "pluginsinfo", "[", "$", "plugintype", "]", "=", "null", ";", "}", "// Add orphaned subplugin types.", "$", "this", "->", "load_installed_plugins", "(", ")", ";", "foreach", "(", "$", "this", "->", "installedplugins", "as", "$", "plugintype", "=>", "$", "unused", ")", "{", "if", "(", "!", "isset", "(", "$", "plugintypes", "[", "$", "plugintype", "]", ")", ")", "{", "$", "this", "->", "pluginsinfo", "[", "$", "plugintype", "]", "=", "null", ";", "}", "}", "}" ]
Init placeholder array for plugin infos.
[ "Init", "placeholder", "array", "for", "plugin", "infos", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L404-L423
217,457
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.resolve_plugininfo_class
public static function resolve_plugininfo_class($type) { $plugintypes = core_component::get_plugin_types(); if (!isset($plugintypes[$type])) { return '\core\plugininfo\orphaned'; } $parent = core_component::get_subtype_parent($type); if ($parent) { $class = '\\'.$parent.'\plugininfo\\' . $type; if (class_exists($class)) { $plugintypeclass = $class; } else { if ($dir = core_component::get_component_directory($parent)) { // BC only - use namespace instead! if (file_exists("$dir/adminlib.php")) { global $CFG; include_once("$dir/adminlib.php"); } if (class_exists('plugininfo_' . $type)) { $plugintypeclass = 'plugininfo_' . $type; debugging('Class "'.$plugintypeclass.'" is deprecated, migrate to "'.$class.'"', DEBUG_DEVELOPER); } else { debugging('Subplugin type "'.$type.'" should define class "'.$class.'"', DEBUG_DEVELOPER); $plugintypeclass = '\core\plugininfo\general'; } } else { $plugintypeclass = '\core\plugininfo\general'; } } } else { $class = '\core\plugininfo\\' . $type; if (class_exists($class)) { $plugintypeclass = $class; } else { debugging('All standard types including "'.$type.'" should have plugininfo class!', DEBUG_DEVELOPER); $plugintypeclass = '\core\plugininfo\general'; } } if (!in_array('core\plugininfo\base', class_parents($plugintypeclass))) { throw new coding_exception('Class ' . $plugintypeclass . ' must extend \core\plugininfo\base'); } return $plugintypeclass; }
php
public static function resolve_plugininfo_class($type) { $plugintypes = core_component::get_plugin_types(); if (!isset($plugintypes[$type])) { return '\core\plugininfo\orphaned'; } $parent = core_component::get_subtype_parent($type); if ($parent) { $class = '\\'.$parent.'\plugininfo\\' . $type; if (class_exists($class)) { $plugintypeclass = $class; } else { if ($dir = core_component::get_component_directory($parent)) { // BC only - use namespace instead! if (file_exists("$dir/adminlib.php")) { global $CFG; include_once("$dir/adminlib.php"); } if (class_exists('plugininfo_' . $type)) { $plugintypeclass = 'plugininfo_' . $type; debugging('Class "'.$plugintypeclass.'" is deprecated, migrate to "'.$class.'"', DEBUG_DEVELOPER); } else { debugging('Subplugin type "'.$type.'" should define class "'.$class.'"', DEBUG_DEVELOPER); $plugintypeclass = '\core\plugininfo\general'; } } else { $plugintypeclass = '\core\plugininfo\general'; } } } else { $class = '\core\plugininfo\\' . $type; if (class_exists($class)) { $plugintypeclass = $class; } else { debugging('All standard types including "'.$type.'" should have plugininfo class!', DEBUG_DEVELOPER); $plugintypeclass = '\core\plugininfo\general'; } } if (!in_array('core\plugininfo\base', class_parents($plugintypeclass))) { throw new coding_exception('Class ' . $plugintypeclass . ' must extend \core\plugininfo\base'); } return $plugintypeclass; }
[ "public", "static", "function", "resolve_plugininfo_class", "(", "$", "type", ")", "{", "$", "plugintypes", "=", "core_component", "::", "get_plugin_types", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "plugintypes", "[", "$", "type", "]", ")", ")", "{", "return", "'\\core\\plugininfo\\orphaned'", ";", "}", "$", "parent", "=", "core_component", "::", "get_subtype_parent", "(", "$", "type", ")", ";", "if", "(", "$", "parent", ")", "{", "$", "class", "=", "'\\\\'", ".", "$", "parent", ".", "'\\plugininfo\\\\'", ".", "$", "type", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "plugintypeclass", "=", "$", "class", ";", "}", "else", "{", "if", "(", "$", "dir", "=", "core_component", "::", "get_component_directory", "(", "$", "parent", ")", ")", "{", "// BC only - use namespace instead!", "if", "(", "file_exists", "(", "\"$dir/adminlib.php\"", ")", ")", "{", "global", "$", "CFG", ";", "include_once", "(", "\"$dir/adminlib.php\"", ")", ";", "}", "if", "(", "class_exists", "(", "'plugininfo_'", ".", "$", "type", ")", ")", "{", "$", "plugintypeclass", "=", "'plugininfo_'", ".", "$", "type", ";", "debugging", "(", "'Class \"'", ".", "$", "plugintypeclass", ".", "'\" is deprecated, migrate to \"'", ".", "$", "class", ".", "'\"'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "else", "{", "debugging", "(", "'Subplugin type \"'", ".", "$", "type", ".", "'\" should define class \"'", ".", "$", "class", ".", "'\"'", ",", "DEBUG_DEVELOPER", ")", ";", "$", "plugintypeclass", "=", "'\\core\\plugininfo\\general'", ";", "}", "}", "else", "{", "$", "plugintypeclass", "=", "'\\core\\plugininfo\\general'", ";", "}", "}", "}", "else", "{", "$", "class", "=", "'\\core\\plugininfo\\\\'", ".", "$", "type", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "plugintypeclass", "=", "$", "class", ";", "}", "else", "{", "debugging", "(", "'All standard types including \"'", ".", "$", "type", ".", "'\" should have plugininfo class!'", ",", "DEBUG_DEVELOPER", ")", ";", "$", "plugintypeclass", "=", "'\\core\\plugininfo\\general'", ";", "}", "}", "if", "(", "!", "in_array", "(", "'core\\plugininfo\\base'", ",", "class_parents", "(", "$", "plugintypeclass", ")", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Class '", ".", "$", "plugintypeclass", ".", "' must extend \\core\\plugininfo\\base'", ")", ";", "}", "return", "$", "plugintypeclass", ";", "}" ]
Find the plugin info class for given type. @param string $type @return string name of pluginfo class for give plugin type
[ "Find", "the", "plugin", "info", "class", "for", "given", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L431-L476
217,458
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_subplugins_of_plugin
public function get_subplugins_of_plugin($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return array(); } $subplugins = $this->get_subplugins(); if (!isset($subplugins[$pluginfo->component])) { return array(); } $list = array(); foreach ($subplugins[$pluginfo->component] as $subdata) { foreach ($this->get_plugins_of_type($subdata->type) as $subpluginfo) { $list[$subpluginfo->component] = $subpluginfo; } } return $list; }
php
public function get_subplugins_of_plugin($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return array(); } $subplugins = $this->get_subplugins(); if (!isset($subplugins[$pluginfo->component])) { return array(); } $list = array(); foreach ($subplugins[$pluginfo->component] as $subdata) { foreach ($this->get_plugins_of_type($subdata->type) as $subpluginfo) { $list[$subpluginfo->component] = $subpluginfo; } } return $list; }
[ "public", "function", "get_subplugins_of_plugin", "(", "$", "component", ")", "{", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "subplugins", "=", "$", "this", "->", "get_subplugins", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "subplugins", "[", "$", "pluginfo", "->", "component", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "subplugins", "[", "$", "pluginfo", "->", "component", "]", "as", "$", "subdata", ")", "{", "foreach", "(", "$", "this", "->", "get_plugins_of_type", "(", "$", "subdata", "->", "type", ")", "as", "$", "subpluginfo", ")", "{", "$", "list", "[", "$", "subpluginfo", "->", "component", "]", "=", "$", "subpluginfo", ";", "}", "}", "return", "$", "list", ";", "}" ]
Returns list of all known subplugins of the given plugin. For plugins that do not provide subplugins (i.e. there is no support for it), empty array is returned. @param string $component full component name, e.g. 'mod_workshop' @return array (string) component name (e.g. 'workshopallocation_random') => subclass of {@link \core\plugininfo\base}
[ "Returns", "list", "of", "all", "known", "subplugins", "of", "the", "given", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L487-L510
217,459
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.plugin_name
public function plugin_name($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { throw new moodle_exception('err_unknown_plugin', 'core_plugin', '', array('plugin' => $component)); } return $pluginfo->displayname; }
php
public function plugin_name($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { throw new moodle_exception('err_unknown_plugin', 'core_plugin', '', array('plugin' => $component)); } return $pluginfo->displayname; }
[ "public", "function", "plugin_name", "(", "$", "component", ")", "{", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'err_unknown_plugin'", ",", "'core_plugin'", ",", "''", ",", "array", "(", "'plugin'", "=>", "$", "component", ")", ")", ";", "}", "return", "$", "pluginfo", "->", "displayname", ";", "}" ]
Returns a localized name of a given plugin @param string $component name of the plugin, eg mod_workshop or auth_ldap @return string
[ "Returns", "a", "localized", "name", "of", "a", "given", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L569-L578
217,460
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.plugintype_name
public function plugintype_name($type) { if (get_string_manager()->string_exists('type_' . $type, 'core_plugin')) { // For most plugin types, their names are defined in core_plugin lang file. return get_string('type_' . $type, 'core_plugin'); } else if ($parent = $this->get_parent_of_subplugin($type)) { // If this is a subplugin, try to ask the parent plugin for the name. if (get_string_manager()->string_exists('subplugintype_' . $type, $parent)) { return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type, $parent); } else { return $this->plugin_name($parent) . ' / ' . $type; } } else { return $type; } }
php
public function plugintype_name($type) { if (get_string_manager()->string_exists('type_' . $type, 'core_plugin')) { // For most plugin types, their names are defined in core_plugin lang file. return get_string('type_' . $type, 'core_plugin'); } else if ($parent = $this->get_parent_of_subplugin($type)) { // If this is a subplugin, try to ask the parent plugin for the name. if (get_string_manager()->string_exists('subplugintype_' . $type, $parent)) { return $this->plugin_name($parent) . ' / ' . get_string('subplugintype_' . $type, $parent); } else { return $this->plugin_name($parent) . ' / ' . $type; } } else { return $type; } }
[ "public", "function", "plugintype_name", "(", "$", "type", ")", "{", "if", "(", "get_string_manager", "(", ")", "->", "string_exists", "(", "'type_'", ".", "$", "type", ",", "'core_plugin'", ")", ")", "{", "// For most plugin types, their names are defined in core_plugin lang file.", "return", "get_string", "(", "'type_'", ".", "$", "type", ",", "'core_plugin'", ")", ";", "}", "else", "if", "(", "$", "parent", "=", "$", "this", "->", "get_parent_of_subplugin", "(", "$", "type", ")", ")", "{", "// If this is a subplugin, try to ask the parent plugin for the name.", "if", "(", "get_string_manager", "(", ")", "->", "string_exists", "(", "'subplugintype_'", ".", "$", "type", ",", "$", "parent", ")", ")", "{", "return", "$", "this", "->", "plugin_name", "(", "$", "parent", ")", ".", "' / '", ".", "get_string", "(", "'subplugintype_'", ".", "$", "type", ",", "$", "parent", ")", ";", "}", "else", "{", "return", "$", "this", "->", "plugin_name", "(", "$", "parent", ")", ".", "' / '", ".", "$", "type", ";", "}", "}", "else", "{", "return", "$", "type", ";", "}", "}" ]
Returns a localized name of a plugin typed in singular form Most plugin types define their names in core_plugin lang file. In case of subplugins, we try to ask the parent plugin for the name. In the worst case, we will return the value of the passed $type parameter. @param string $type the type of the plugin, e.g. mod or workshopform @return string
[ "Returns", "a", "localized", "name", "of", "a", "plugin", "typed", "in", "singular", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L590-L607
217,461
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_plugin_info
public function get_plugin_info($component) { list($type, $name) = core_component::normalize_component($component); $plugins = $this->get_plugins_of_type($type); if (isset($plugins[$name])) { return $plugins[$name]; } else { return null; } }
php
public function get_plugin_info($component) { list($type, $name) = core_component::normalize_component($component); $plugins = $this->get_plugins_of_type($type); if (isset($plugins[$name])) { return $plugins[$name]; } else { return null; } }
[ "public", "function", "get_plugin_info", "(", "$", "component", ")", "{", "list", "(", "$", "type", ",", "$", "name", ")", "=", "core_component", "::", "normalize_component", "(", "$", "component", ")", ";", "$", "plugins", "=", "$", "this", "->", "get_plugins_of_type", "(", "$", "type", ")", ";", "if", "(", "isset", "(", "$", "plugins", "[", "$", "name", "]", ")", ")", "{", "return", "$", "plugins", "[", "$", "name", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns information about the known plugin, or null @param string $component frankenstyle component name. @return \core\plugininfo\base|null the corresponding plugin information.
[ "Returns", "information", "about", "the", "known", "plugin", "or", "null" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L644-L652
217,462
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.plugin_external_source
public function plugin_external_source($component) { $plugininfo = $this->get_plugin_info($component); if (is_null($plugininfo)) { return false; } $pluginroot = $plugininfo->rootdir; if (is_dir($pluginroot.'/.git')) { return 'git'; } if (is_file($pluginroot.'/.git')) { return 'git-submodule'; } if (is_dir($pluginroot.'/CVS')) { return 'cvs'; } if (is_dir($pluginroot.'/.svn')) { return 'svn'; } if (is_dir($pluginroot.'/.hg')) { return 'mercurial'; } return false; }
php
public function plugin_external_source($component) { $plugininfo = $this->get_plugin_info($component); if (is_null($plugininfo)) { return false; } $pluginroot = $plugininfo->rootdir; if (is_dir($pluginroot.'/.git')) { return 'git'; } if (is_file($pluginroot.'/.git')) { return 'git-submodule'; } if (is_dir($pluginroot.'/CVS')) { return 'cvs'; } if (is_dir($pluginroot.'/.svn')) { return 'svn'; } if (is_dir($pluginroot.'/.hg')) { return 'mercurial'; } return false; }
[ "public", "function", "plugin_external_source", "(", "$", "component", ")", "{", "$", "plugininfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "plugininfo", ")", ")", "{", "return", "false", ";", "}", "$", "pluginroot", "=", "$", "plugininfo", "->", "rootdir", ";", "if", "(", "is_dir", "(", "$", "pluginroot", ".", "'/.git'", ")", ")", "{", "return", "'git'", ";", "}", "if", "(", "is_file", "(", "$", "pluginroot", ".", "'/.git'", ")", ")", "{", "return", "'git-submodule'", ";", "}", "if", "(", "is_dir", "(", "$", "pluginroot", ".", "'/CVS'", ")", ")", "{", "return", "'cvs'", ";", "}", "if", "(", "is_dir", "(", "$", "pluginroot", ".", "'/.svn'", ")", ")", "{", "return", "'svn'", ";", "}", "if", "(", "is_dir", "(", "$", "pluginroot", ".", "'/.hg'", ")", ")", "{", "return", "'mercurial'", ";", "}", "return", "false", ";", "}" ]
Check to see if the current version of the plugin seems to be a checkout of an external repository. @param string $component frankenstyle component name @return false|string
[ "Check", "to", "see", "if", "the", "current", "version", "of", "the", "plugin", "seems", "to", "be", "a", "checkout", "of", "an", "external", "repository", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L660-L691
217,463
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.other_plugins_that_require
public function other_plugins_that_require($component) { $others = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { $required = $plugin->get_other_required_plugins(); if (isset($required[$component])) { $others[] = $plugin->component; } } } return $others; }
php
public function other_plugins_that_require($component) { $others = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { $required = $plugin->get_other_required_plugins(); if (isset($required[$component])) { $others[] = $plugin->component; } } } return $others; }
[ "public", "function", "other_plugins_that_require", "(", "$", "component", ")", "{", "$", "others", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "$", "required", "=", "$", "plugin", "->", "get_other_required_plugins", "(", ")", ";", "if", "(", "isset", "(", "$", "required", "[", "$", "component", "]", ")", ")", "{", "$", "others", "[", "]", "=", "$", "plugin", "->", "component", ";", "}", "}", "}", "return", "$", "others", ";", "}" ]
Get a list of any other plugins that require this one. @param string $component frankenstyle component name. @return array of frankensyle component names that require this one.
[ "Get", "a", "list", "of", "any", "other", "plugins", "that", "require", "this", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L698-L709
217,464
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.are_dependencies_satisfied
public function are_dependencies_satisfied($dependencies) { foreach ($dependencies as $component => $requiredversion) { $otherplugin = $this->get_plugin_info($component); if (is_null($otherplugin)) { return false; } if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { return false; } } return true; }
php
public function are_dependencies_satisfied($dependencies) { foreach ($dependencies as $component => $requiredversion) { $otherplugin = $this->get_plugin_info($component); if (is_null($otherplugin)) { return false; } if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { return false; } } return true; }
[ "public", "function", "are_dependencies_satisfied", "(", "$", "dependencies", ")", "{", "foreach", "(", "$", "dependencies", "as", "$", "component", "=>", "$", "requiredversion", ")", "{", "$", "otherplugin", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "otherplugin", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "requiredversion", "!=", "ANY_VERSION", "and", "$", "otherplugin", "->", "versiondisk", "<", "$", "requiredversion", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check a dependencies list against the list of installed plugins. @param array $dependencies compenent name to required version or ANY_VERSION. @return bool true if all the dependencies are satisfied.
[ "Check", "a", "dependencies", "list", "against", "the", "list", "of", "installed", "plugins", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L716-L729
217,465
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.all_plugins_ok
public function all_plugins_ok($moodleversion, &$failedplugins = array()) { $return = true; foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if (!$plugin->is_core_dependency_satisfied($moodleversion)) { $return = false; $failedplugins[] = $plugin->component; } if (!$this->are_dependencies_satisfied($plugin->get_other_required_plugins())) { $return = false; $failedplugins[] = $plugin->component; } } } return $return; }
php
public function all_plugins_ok($moodleversion, &$failedplugins = array()) { $return = true; foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if (!$plugin->is_core_dependency_satisfied($moodleversion)) { $return = false; $failedplugins[] = $plugin->component; } if (!$this->are_dependencies_satisfied($plugin->get_other_required_plugins())) { $return = false; $failedplugins[] = $plugin->component; } } } return $return; }
[ "public", "function", "all_plugins_ok", "(", "$", "moodleversion", ",", "&", "$", "failedplugins", "=", "array", "(", ")", ")", "{", "$", "return", "=", "true", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "!", "$", "plugin", "->", "is_core_dependency_satisfied", "(", "$", "moodleversion", ")", ")", "{", "$", "return", "=", "false", ";", "$", "failedplugins", "[", "]", "=", "$", "plugin", "->", "component", ";", "}", "if", "(", "!", "$", "this", "->", "are_dependencies_satisfied", "(", "$", "plugin", "->", "get_other_required_plugins", "(", ")", ")", ")", "{", "$", "return", "=", "false", ";", "$", "failedplugins", "[", "]", "=", "$", "plugin", "->", "component", ";", "}", "}", "}", "return", "$", "return", ";", "}" ]
Checks all dependencies for all installed plugins This is used by install and upgrade. The array passed by reference as the second argument is populated with the list of plugins that have failed dependencies (note that a single plugin can appear multiple times in the $failedplugins). @param int $moodleversion the version from version.php. @param array $failedplugins to return the list of plugins with non-satisfied dependencies @return bool true if all the dependencies are satisfied for all plugins.
[ "Checks", "all", "dependencies", "for", "all", "installed", "plugins" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L742-L761
217,466
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.resolve_requirements
public function resolve_requirements(\core\plugininfo\base $plugin, $moodleversion=null, $moodlebranch=null) { global $CFG; if ($plugin->versiondisk === null) { // Missing from disk, we have no version.php to read from. return array(); } if ($moodleversion === null) { $moodleversion = $CFG->version; } if ($moodlebranch === null) { $moodlebranch = $CFG->branch; } $reqs = array(); $reqcore = $this->resolve_core_requirements($plugin, $moodleversion); if (!empty($reqcore)) { $reqs['core'] = $reqcore; } foreach ($plugin->get_other_required_plugins() as $reqplug => $reqver) { $reqs[$reqplug] = $this->resolve_dependency_requirements($plugin, $reqplug, $reqver, $moodlebranch); } return $reqs; }
php
public function resolve_requirements(\core\plugininfo\base $plugin, $moodleversion=null, $moodlebranch=null) { global $CFG; if ($plugin->versiondisk === null) { // Missing from disk, we have no version.php to read from. return array(); } if ($moodleversion === null) { $moodleversion = $CFG->version; } if ($moodlebranch === null) { $moodlebranch = $CFG->branch; } $reqs = array(); $reqcore = $this->resolve_core_requirements($plugin, $moodleversion); if (!empty($reqcore)) { $reqs['core'] = $reqcore; } foreach ($plugin->get_other_required_plugins() as $reqplug => $reqver) { $reqs[$reqplug] = $this->resolve_dependency_requirements($plugin, $reqplug, $reqver, $moodlebranch); } return $reqs; }
[ "public", "function", "resolve_requirements", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ",", "$", "moodleversion", "=", "null", ",", "$", "moodlebranch", "=", "null", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "plugin", "->", "versiondisk", "===", "null", ")", "{", "// Missing from disk, we have no version.php to read from.", "return", "array", "(", ")", ";", "}", "if", "(", "$", "moodleversion", "===", "null", ")", "{", "$", "moodleversion", "=", "$", "CFG", "->", "version", ";", "}", "if", "(", "$", "moodlebranch", "===", "null", ")", "{", "$", "moodlebranch", "=", "$", "CFG", "->", "branch", ";", "}", "$", "reqs", "=", "array", "(", ")", ";", "$", "reqcore", "=", "$", "this", "->", "resolve_core_requirements", "(", "$", "plugin", ",", "$", "moodleversion", ")", ";", "if", "(", "!", "empty", "(", "$", "reqcore", ")", ")", "{", "$", "reqs", "[", "'core'", "]", "=", "$", "reqcore", ";", "}", "foreach", "(", "$", "plugin", "->", "get_other_required_plugins", "(", ")", "as", "$", "reqplug", "=>", "$", "reqver", ")", "{", "$", "reqs", "[", "$", "reqplug", "]", "=", "$", "this", "->", "resolve_dependency_requirements", "(", "$", "plugin", ",", "$", "reqplug", ",", "$", "reqver", ",", "$", "moodlebranch", ")", ";", "}", "return", "$", "reqs", ";", "}" ]
Resolve requirements and dependencies of a plugin. Returns an array of objects describing the requirement/dependency, indexed by the frankenstyle name of the component. The returned array can be empty. The objects in the array have following properties: ->(numeric)hasver ->(numeric)reqver ->(string)status ->(string)availability @param \core\plugininfo\base $plugin the plugin we are checking @param null|string|int|double $moodleversion explicit moodle core version to check against, defaults to $CFG->version @param null|string|int $moodlebranch explicit moodle core branch to check against, defaults to $CFG->branch @return array of objects
[ "Resolve", "requirements", "and", "dependencies", "of", "a", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L780-L808
217,467
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.resolve_core_requirements
protected function resolve_core_requirements(\core\plugininfo\base $plugin, $moodleversion) { $reqs = (object)array( 'hasver' => null, 'reqver' => null, 'status' => null, 'availability' => null, ); $reqs->hasver = $moodleversion; if (empty($plugin->versionrequires)) { $reqs->reqver = ANY_VERSION; } else { $reqs->reqver = $plugin->versionrequires; } if ($plugin->is_core_dependency_satisfied($moodleversion)) { $reqs->status = self::REQUIREMENT_STATUS_OK; } else { $reqs->status = self::REQUIREMENT_STATUS_OUTDATED; } return $reqs; }
php
protected function resolve_core_requirements(\core\plugininfo\base $plugin, $moodleversion) { $reqs = (object)array( 'hasver' => null, 'reqver' => null, 'status' => null, 'availability' => null, ); $reqs->hasver = $moodleversion; if (empty($plugin->versionrequires)) { $reqs->reqver = ANY_VERSION; } else { $reqs->reqver = $plugin->versionrequires; } if ($plugin->is_core_dependency_satisfied($moodleversion)) { $reqs->status = self::REQUIREMENT_STATUS_OK; } else { $reqs->status = self::REQUIREMENT_STATUS_OUTDATED; } return $reqs; }
[ "protected", "function", "resolve_core_requirements", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ",", "$", "moodleversion", ")", "{", "$", "reqs", "=", "(", "object", ")", "array", "(", "'hasver'", "=>", "null", ",", "'reqver'", "=>", "null", ",", "'status'", "=>", "null", ",", "'availability'", "=>", "null", ",", ")", ";", "$", "reqs", "->", "hasver", "=", "$", "moodleversion", ";", "if", "(", "empty", "(", "$", "plugin", "->", "versionrequires", ")", ")", "{", "$", "reqs", "->", "reqver", "=", "ANY_VERSION", ";", "}", "else", "{", "$", "reqs", "->", "reqver", "=", "$", "plugin", "->", "versionrequires", ";", "}", "if", "(", "$", "plugin", "->", "is_core_dependency_satisfied", "(", "$", "moodleversion", ")", ")", "{", "$", "reqs", "->", "status", "=", "self", "::", "REQUIREMENT_STATUS_OK", ";", "}", "else", "{", "$", "reqs", "->", "status", "=", "self", "::", "REQUIREMENT_STATUS_OUTDATED", ";", "}", "return", "$", "reqs", ";", "}" ]
Helper method to resolve plugin's requirements on the moodle core. @param \core\plugininfo\base $plugin the plugin we are checking @param string|int|double $moodleversion moodle core branch to check against @return stdObject
[ "Helper", "method", "to", "resolve", "plugin", "s", "requirements", "on", "the", "moodle", "core", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L817-L841
217,468
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.resolve_dependency_requirements
protected function resolve_dependency_requirements(\core\plugininfo\base $plugin, $otherpluginname, $requiredversion, $moodlebranch) { $reqs = (object)array( 'hasver' => null, 'reqver' => null, 'status' => null, 'availability' => null, ); $otherplugin = $this->get_plugin_info($otherpluginname); if ($otherplugin !== null) { // The required plugin is installed. $reqs->hasver = $otherplugin->versiondisk; $reqs->reqver = $requiredversion; // Check it has sufficient version. if ($requiredversion == ANY_VERSION or $otherplugin->versiondisk >= $requiredversion) { $reqs->status = self::REQUIREMENT_STATUS_OK; } else { $reqs->status = self::REQUIREMENT_STATUS_OUTDATED; } } else { // The required plugin is not installed. $reqs->hasver = null; $reqs->reqver = $requiredversion; $reqs->status = self::REQUIREMENT_STATUS_MISSING; } if ($reqs->status !== self::REQUIREMENT_STATUS_OK) { if ($this->is_remote_plugin_available($otherpluginname, $requiredversion, false)) { $reqs->availability = self::REQUIREMENT_AVAILABLE; } else { $reqs->availability = self::REQUIREMENT_UNAVAILABLE; } } return $reqs; }
php
protected function resolve_dependency_requirements(\core\plugininfo\base $plugin, $otherpluginname, $requiredversion, $moodlebranch) { $reqs = (object)array( 'hasver' => null, 'reqver' => null, 'status' => null, 'availability' => null, ); $otherplugin = $this->get_plugin_info($otherpluginname); if ($otherplugin !== null) { // The required plugin is installed. $reqs->hasver = $otherplugin->versiondisk; $reqs->reqver = $requiredversion; // Check it has sufficient version. if ($requiredversion == ANY_VERSION or $otherplugin->versiondisk >= $requiredversion) { $reqs->status = self::REQUIREMENT_STATUS_OK; } else { $reqs->status = self::REQUIREMENT_STATUS_OUTDATED; } } else { // The required plugin is not installed. $reqs->hasver = null; $reqs->reqver = $requiredversion; $reqs->status = self::REQUIREMENT_STATUS_MISSING; } if ($reqs->status !== self::REQUIREMENT_STATUS_OK) { if ($this->is_remote_plugin_available($otherpluginname, $requiredversion, false)) { $reqs->availability = self::REQUIREMENT_AVAILABLE; } else { $reqs->availability = self::REQUIREMENT_UNAVAILABLE; } } return $reqs; }
[ "protected", "function", "resolve_dependency_requirements", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ",", "$", "otherpluginname", ",", "$", "requiredversion", ",", "$", "moodlebranch", ")", "{", "$", "reqs", "=", "(", "object", ")", "array", "(", "'hasver'", "=>", "null", ",", "'reqver'", "=>", "null", ",", "'status'", "=>", "null", ",", "'availability'", "=>", "null", ",", ")", ";", "$", "otherplugin", "=", "$", "this", "->", "get_plugin_info", "(", "$", "otherpluginname", ")", ";", "if", "(", "$", "otherplugin", "!==", "null", ")", "{", "// The required plugin is installed.", "$", "reqs", "->", "hasver", "=", "$", "otherplugin", "->", "versiondisk", ";", "$", "reqs", "->", "reqver", "=", "$", "requiredversion", ";", "// Check it has sufficient version.", "if", "(", "$", "requiredversion", "==", "ANY_VERSION", "or", "$", "otherplugin", "->", "versiondisk", ">=", "$", "requiredversion", ")", "{", "$", "reqs", "->", "status", "=", "self", "::", "REQUIREMENT_STATUS_OK", ";", "}", "else", "{", "$", "reqs", "->", "status", "=", "self", "::", "REQUIREMENT_STATUS_OUTDATED", ";", "}", "}", "else", "{", "// The required plugin is not installed.", "$", "reqs", "->", "hasver", "=", "null", ";", "$", "reqs", "->", "reqver", "=", "$", "requiredversion", ";", "$", "reqs", "->", "status", "=", "self", "::", "REQUIREMENT_STATUS_MISSING", ";", "}", "if", "(", "$", "reqs", "->", "status", "!==", "self", "::", "REQUIREMENT_STATUS_OK", ")", "{", "if", "(", "$", "this", "->", "is_remote_plugin_available", "(", "$", "otherpluginname", ",", "$", "requiredversion", ",", "false", ")", ")", "{", "$", "reqs", "->", "availability", "=", "self", "::", "REQUIREMENT_AVAILABLE", ";", "}", "else", "{", "$", "reqs", "->", "availability", "=", "self", "::", "REQUIREMENT_UNAVAILABLE", ";", "}", "}", "return", "$", "reqs", ";", "}" ]
Helper method to resolve plugin's dependecies on other plugins. @param \core\plugininfo\base $plugin the plugin we are checking @param string $otherpluginname @param string|int $requiredversion @param string|int $moodlebranch explicit moodle core branch to check against, defaults to $CFG->branch @return stdClass
[ "Helper", "method", "to", "resolve", "plugin", "s", "dependecies", "on", "other", "plugins", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L852-L891
217,469
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_remote_plugin_available
public function is_remote_plugin_available($component, $version, $exactmatch) { $info = $this->get_remote_plugin_info($component, $version, $exactmatch); if (empty($info)) { // There is no available plugin of that name. return false; } if (empty($info->version)) { // Plugin is known, but no suitable version was found. return false; } return true; }
php
public function is_remote_plugin_available($component, $version, $exactmatch) { $info = $this->get_remote_plugin_info($component, $version, $exactmatch); if (empty($info)) { // There is no available plugin of that name. return false; } if (empty($info->version)) { // Plugin is known, but no suitable version was found. return false; } return true; }
[ "public", "function", "is_remote_plugin_available", "(", "$", "component", ",", "$", "version", ",", "$", "exactmatch", ")", "{", "$", "info", "=", "$", "this", "->", "get_remote_plugin_info", "(", "$", "component", ",", "$", "version", ",", "$", "exactmatch", ")", ";", "if", "(", "empty", "(", "$", "info", ")", ")", "{", "// There is no available plugin of that name.", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "info", "->", "version", ")", ")", "{", "// Plugin is known, but no suitable version was found.", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is the given plugin version available in the plugins directory? See {@link self::get_remote_plugin_info()} for the full explanation of how the $version parameter is interpretted. @param string $component plugin frankenstyle name @param string|int $version ANY_VERSION or the version number @param bool $exactmatch false if "given version or higher" is requested @return boolean
[ "Is", "the", "given", "plugin", "version", "available", "in", "the", "plugins", "directory?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L904-L919
217,470
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_remote_plugin_installable
public function is_remote_plugin_installable($component, $version, &$reason=null) { global $CFG; // Make sure the feature is not disabled. if (!empty($CFG->disableupdateautodeploy)) { $reason = 'disabled'; return false; } // Make sure the version is available. if (!$this->is_remote_plugin_available($component, $version, true)) { $reason = 'remoteunavailable'; return false; } // Make sure the plugin type root directory is writable. list($plugintype, $pluginname) = core_component::normalize_component($component); if (!$this->is_plugintype_writable($plugintype)) { $reason = 'notwritableplugintype'; return false; } $remoteinfo = $this->get_remote_plugin_info($component, $version, true); $localinfo = $this->get_plugin_info($component); if ($localinfo) { // If the plugin is already present, prevent downgrade. if ($localinfo->versiondb > $remoteinfo->version->version) { $reason = 'cannotdowngrade'; return false; } // Make sure we have write access to all the existing code. if (is_dir($localinfo->rootdir)) { if (!$this->is_plugin_folder_removable($component)) { $reason = 'notwritableplugin'; return false; } } } // Looks like it could work. return true; }
php
public function is_remote_plugin_installable($component, $version, &$reason=null) { global $CFG; // Make sure the feature is not disabled. if (!empty($CFG->disableupdateautodeploy)) { $reason = 'disabled'; return false; } // Make sure the version is available. if (!$this->is_remote_plugin_available($component, $version, true)) { $reason = 'remoteunavailable'; return false; } // Make sure the plugin type root directory is writable. list($plugintype, $pluginname) = core_component::normalize_component($component); if (!$this->is_plugintype_writable($plugintype)) { $reason = 'notwritableplugintype'; return false; } $remoteinfo = $this->get_remote_plugin_info($component, $version, true); $localinfo = $this->get_plugin_info($component); if ($localinfo) { // If the plugin is already present, prevent downgrade. if ($localinfo->versiondb > $remoteinfo->version->version) { $reason = 'cannotdowngrade'; return false; } // Make sure we have write access to all the existing code. if (is_dir($localinfo->rootdir)) { if (!$this->is_plugin_folder_removable($component)) { $reason = 'notwritableplugin'; return false; } } } // Looks like it could work. return true; }
[ "public", "function", "is_remote_plugin_installable", "(", "$", "component", ",", "$", "version", ",", "&", "$", "reason", "=", "null", ")", "{", "global", "$", "CFG", ";", "// Make sure the feature is not disabled.", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "$", "reason", "=", "'disabled'", ";", "return", "false", ";", "}", "// Make sure the version is available.", "if", "(", "!", "$", "this", "->", "is_remote_plugin_available", "(", "$", "component", ",", "$", "version", ",", "true", ")", ")", "{", "$", "reason", "=", "'remoteunavailable'", ";", "return", "false", ";", "}", "// Make sure the plugin type root directory is writable.", "list", "(", "$", "plugintype", ",", "$", "pluginname", ")", "=", "core_component", "::", "normalize_component", "(", "$", "component", ")", ";", "if", "(", "!", "$", "this", "->", "is_plugintype_writable", "(", "$", "plugintype", ")", ")", "{", "$", "reason", "=", "'notwritableplugintype'", ";", "return", "false", ";", "}", "$", "remoteinfo", "=", "$", "this", "->", "get_remote_plugin_info", "(", "$", "component", ",", "$", "version", ",", "true", ")", ";", "$", "localinfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "$", "localinfo", ")", "{", "// If the plugin is already present, prevent downgrade.", "if", "(", "$", "localinfo", "->", "versiondb", ">", "$", "remoteinfo", "->", "version", "->", "version", ")", "{", "$", "reason", "=", "'cannotdowngrade'", ";", "return", "false", ";", "}", "// Make sure we have write access to all the existing code.", "if", "(", "is_dir", "(", "$", "localinfo", "->", "rootdir", ")", ")", "{", "if", "(", "!", "$", "this", "->", "is_plugin_folder_removable", "(", "$", "component", ")", ")", "{", "$", "reason", "=", "'notwritableplugin'", ";", "return", "false", ";", "}", "}", "}", "// Looks like it could work.", "return", "true", ";", "}" ]
Can the given plugin version be installed via the admin UI? This check should be used whenever attempting to install a plugin from the plugins directory (new install, available update, missing dependency). @param string $component @param int $version version number @param string $reason returned code of the reason why it is not @return boolean
[ "Can", "the", "given", "plugin", "version", "be", "installed", "via", "the", "admin", "UI?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L932-L975
217,471
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.filter_installable
public function filter_installable($remoteinfos) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return array(); } if (empty($remoteinfos)) { return array(); } $installable = array(); foreach ($remoteinfos as $index => $remoteinfo) { if ($this->is_remote_plugin_installable($remoteinfo->component, $remoteinfo->version->version)) { $installable[$index] = $remoteinfo; } } return $installable; }
php
public function filter_installable($remoteinfos) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return array(); } if (empty($remoteinfos)) { return array(); } $installable = array(); foreach ($remoteinfos as $index => $remoteinfo) { if ($this->is_remote_plugin_installable($remoteinfo->component, $remoteinfo->version->version)) { $installable[$index] = $remoteinfo; } } return $installable; }
[ "public", "function", "filter_installable", "(", "$", "remoteinfos", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "remoteinfos", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "installable", "=", "array", "(", ")", ";", "foreach", "(", "$", "remoteinfos", "as", "$", "index", "=>", "$", "remoteinfo", ")", "{", "if", "(", "$", "this", "->", "is_remote_plugin_installable", "(", "$", "remoteinfo", "->", "component", ",", "$", "remoteinfo", "->", "version", "->", "version", ")", ")", "{", "$", "installable", "[", "$", "index", "]", "=", "$", "remoteinfo", ";", "}", "}", "return", "$", "installable", ";", "}" ]
Given the list of remote plugin infos, return just those installable. This is typically used on lists returned by {@link self::available_updates()} or {@link self::missing_dependencies()} to perform bulk installation of remote plugins. @param array $remoteinfos list of {@link \core\update\remote_info} @return array
[ "Given", "the", "list", "of", "remote", "plugin", "infos", "return", "just", "those", "installable", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L987-L1003
217,472
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_remote_plugin_info
public function get_remote_plugin_info($component, $version, $exactmatch) { if ($exactmatch and $version == ANY_VERSION) { throw new coding_exception('Invalid request for exactly any version, it does not make sense.'); } $client = $this->get_update_api_client(); if ($exactmatch) { // Use client's get_plugin_info() method. if (!isset($this->remotepluginsinfoexact[$component][$version])) { $this->remotepluginsinfoexact[$component][$version] = $client->get_plugin_info($component, $version); } return $this->remotepluginsinfoexact[$component][$version]; } else { // Use client's find_plugin() method. if (!isset($this->remotepluginsinfoatleast[$component][$version])) { $this->remotepluginsinfoatleast[$component][$version] = $client->find_plugin($component, $version); } return $this->remotepluginsinfoatleast[$component][$version]; } }
php
public function get_remote_plugin_info($component, $version, $exactmatch) { if ($exactmatch and $version == ANY_VERSION) { throw new coding_exception('Invalid request for exactly any version, it does not make sense.'); } $client = $this->get_update_api_client(); if ($exactmatch) { // Use client's get_plugin_info() method. if (!isset($this->remotepluginsinfoexact[$component][$version])) { $this->remotepluginsinfoexact[$component][$version] = $client->get_plugin_info($component, $version); } return $this->remotepluginsinfoexact[$component][$version]; } else { // Use client's find_plugin() method. if (!isset($this->remotepluginsinfoatleast[$component][$version])) { $this->remotepluginsinfoatleast[$component][$version] = $client->find_plugin($component, $version); } return $this->remotepluginsinfoatleast[$component][$version]; } }
[ "public", "function", "get_remote_plugin_info", "(", "$", "component", ",", "$", "version", ",", "$", "exactmatch", ")", "{", "if", "(", "$", "exactmatch", "and", "$", "version", "==", "ANY_VERSION", ")", "{", "throw", "new", "coding_exception", "(", "'Invalid request for exactly any version, it does not make sense.'", ")", ";", "}", "$", "client", "=", "$", "this", "->", "get_update_api_client", "(", ")", ";", "if", "(", "$", "exactmatch", ")", "{", "// Use client's get_plugin_info() method.", "if", "(", "!", "isset", "(", "$", "this", "->", "remotepluginsinfoexact", "[", "$", "component", "]", "[", "$", "version", "]", ")", ")", "{", "$", "this", "->", "remotepluginsinfoexact", "[", "$", "component", "]", "[", "$", "version", "]", "=", "$", "client", "->", "get_plugin_info", "(", "$", "component", ",", "$", "version", ")", ";", "}", "return", "$", "this", "->", "remotepluginsinfoexact", "[", "$", "component", "]", "[", "$", "version", "]", ";", "}", "else", "{", "// Use client's find_plugin() method.", "if", "(", "!", "isset", "(", "$", "this", "->", "remotepluginsinfoatleast", "[", "$", "component", "]", "[", "$", "version", "]", ")", ")", "{", "$", "this", "->", "remotepluginsinfoatleast", "[", "$", "component", "]", "[", "$", "version", "]", "=", "$", "client", "->", "find_plugin", "(", "$", "component", ",", "$", "version", ")", ";", "}", "return", "$", "this", "->", "remotepluginsinfoatleast", "[", "$", "component", "]", "[", "$", "version", "]", ";", "}", "}" ]
Returns information about a plugin in the plugins directory. This is typically used when checking for available dependencies (in which case the $version represents minimal version we need), or when installing an available update or a new plugin from the plugins directory (in which case the $version is exact version we are interested in). The interpretation of the $version is controlled by the $exactmatch argument. If a plugin with the given component name is found, data about the plugin are returned as an object. The ->version property of the object contains the information about the particular plugin version that matches best the given critera. The ->version property is false if no suitable version of the plugin was found (yet the plugin itself is known). See {@link \core\update\api::validate_pluginfo_format()} for the returned data structure. @param string $component plugin frankenstyle name @param string|int $version ANY_VERSION or the version number @param bool $exactmatch false if "given version or higher" is requested @return \core\update\remote_info|bool
[ "Returns", "information", "about", "a", "plugin", "in", "the", "plugins", "directory", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1030-L1052
217,473
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.missing_dependencies
public function missing_dependencies($availableonly=false) { $dependencies = array(); foreach ($this->get_plugins() as $plugintype => $pluginfos) { foreach ($pluginfos as $pluginname => $pluginfo) { foreach ($this->resolve_requirements($pluginfo) as $reqname => $reqinfo) { if ($reqname === 'core') { continue; } if ($reqinfo->status != self::REQUIREMENT_STATUS_OK) { if ($reqinfo->availability == self::REQUIREMENT_AVAILABLE) { $remoteinfo = $this->get_remote_plugin_info($reqname, $reqinfo->reqver, false); if (empty($dependencies[$reqname])) { $dependencies[$reqname] = $remoteinfo; } else { // If resolving requirements has led to two different versions of the same // remote plugin, pick the higher version. This can happen in cases like one // plugin requiring ANY_VERSION and another plugin requiring specific higher // version with lower maturity of a remote plugin. if ($remoteinfo->version->version > $dependencies[$reqname]->version->version) { $dependencies[$reqname] = $remoteinfo; } } } else { if (!isset($dependencies[$reqname])) { // Unable to find a plugin fulfilling the requirements. $dependencies[$reqname] = false; } } } } } } if ($availableonly) { foreach ($dependencies as $component => $info) { if (empty($info) or empty($info->version)) { unset($dependencies[$component]); } } } return $dependencies; }
php
public function missing_dependencies($availableonly=false) { $dependencies = array(); foreach ($this->get_plugins() as $plugintype => $pluginfos) { foreach ($pluginfos as $pluginname => $pluginfo) { foreach ($this->resolve_requirements($pluginfo) as $reqname => $reqinfo) { if ($reqname === 'core') { continue; } if ($reqinfo->status != self::REQUIREMENT_STATUS_OK) { if ($reqinfo->availability == self::REQUIREMENT_AVAILABLE) { $remoteinfo = $this->get_remote_plugin_info($reqname, $reqinfo->reqver, false); if (empty($dependencies[$reqname])) { $dependencies[$reqname] = $remoteinfo; } else { // If resolving requirements has led to two different versions of the same // remote plugin, pick the higher version. This can happen in cases like one // plugin requiring ANY_VERSION and another plugin requiring specific higher // version with lower maturity of a remote plugin. if ($remoteinfo->version->version > $dependencies[$reqname]->version->version) { $dependencies[$reqname] = $remoteinfo; } } } else { if (!isset($dependencies[$reqname])) { // Unable to find a plugin fulfilling the requirements. $dependencies[$reqname] = false; } } } } } } if ($availableonly) { foreach ($dependencies as $component => $info) { if (empty($info) or empty($info->version)) { unset($dependencies[$component]); } } } return $dependencies; }
[ "public", "function", "missing_dependencies", "(", "$", "availableonly", "=", "false", ")", "{", "$", "dependencies", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "plugintype", "=>", "$", "pluginfos", ")", "{", "foreach", "(", "$", "pluginfos", "as", "$", "pluginname", "=>", "$", "pluginfo", ")", "{", "foreach", "(", "$", "this", "->", "resolve_requirements", "(", "$", "pluginfo", ")", "as", "$", "reqname", "=>", "$", "reqinfo", ")", "{", "if", "(", "$", "reqname", "===", "'core'", ")", "{", "continue", ";", "}", "if", "(", "$", "reqinfo", "->", "status", "!=", "self", "::", "REQUIREMENT_STATUS_OK", ")", "{", "if", "(", "$", "reqinfo", "->", "availability", "==", "self", "::", "REQUIREMENT_AVAILABLE", ")", "{", "$", "remoteinfo", "=", "$", "this", "->", "get_remote_plugin_info", "(", "$", "reqname", ",", "$", "reqinfo", "->", "reqver", ",", "false", ")", ";", "if", "(", "empty", "(", "$", "dependencies", "[", "$", "reqname", "]", ")", ")", "{", "$", "dependencies", "[", "$", "reqname", "]", "=", "$", "remoteinfo", ";", "}", "else", "{", "// If resolving requirements has led to two different versions of the same", "// remote plugin, pick the higher version. This can happen in cases like one", "// plugin requiring ANY_VERSION and another plugin requiring specific higher", "// version with lower maturity of a remote plugin.", "if", "(", "$", "remoteinfo", "->", "version", "->", "version", ">", "$", "dependencies", "[", "$", "reqname", "]", "->", "version", "->", "version", ")", "{", "$", "dependencies", "[", "$", "reqname", "]", "=", "$", "remoteinfo", ";", "}", "}", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "dependencies", "[", "$", "reqname", "]", ")", ")", "{", "// Unable to find a plugin fulfilling the requirements.", "$", "dependencies", "[", "$", "reqname", "]", "=", "false", ";", "}", "}", "}", "}", "}", "}", "if", "(", "$", "availableonly", ")", "{", "foreach", "(", "$", "dependencies", "as", "$", "component", "=>", "$", "info", ")", "{", "if", "(", "empty", "(", "$", "info", ")", "or", "empty", "(", "$", "info", "->", "version", ")", ")", "{", "unset", "(", "$", "dependencies", "[", "$", "component", "]", ")", ";", "}", "}", "}", "return", "$", "dependencies", ";", "}" ]
Return a list of missing dependencies. This should provide the full list of plugins that should be installed to fulfill the requirements of all plugins, if possible. @param bool $availableonly return only available missing dependencies @return array of \core\update\remote_info|bool indexed by the component name
[ "Return", "a", "list", "of", "missing", "dependencies", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1114-L1160
217,474
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.can_uninstall_plugin
public function can_uninstall_plugin($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } if (!$this->common_uninstall_check($pluginfo)) { return false; } // Verify only if something else requires the subplugins, do not verify their common_uninstall_check()! $subplugins = $this->get_subplugins_of_plugin($pluginfo->component); foreach ($subplugins as $subpluginfo) { // Check if there are some other plugins requiring this subplugin // (but the parent and siblings). foreach ($this->other_plugins_that_require($subpluginfo->component) as $requiresme) { $ismyparent = ($pluginfo->component === $requiresme); $ismysibling = in_array($requiresme, array_keys($subplugins)); if (!$ismyparent and !$ismysibling) { return false; } } } // Check if there are some other plugins requiring this plugin // (but its subplugins). foreach ($this->other_plugins_that_require($pluginfo->component) as $requiresme) { $ismysubplugin = in_array($requiresme, array_keys($subplugins)); if (!$ismysubplugin) { return false; } } return true; }
php
public function can_uninstall_plugin($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } if (!$this->common_uninstall_check($pluginfo)) { return false; } // Verify only if something else requires the subplugins, do not verify their common_uninstall_check()! $subplugins = $this->get_subplugins_of_plugin($pluginfo->component); foreach ($subplugins as $subpluginfo) { // Check if there are some other plugins requiring this subplugin // (but the parent and siblings). foreach ($this->other_plugins_that_require($subpluginfo->component) as $requiresme) { $ismyparent = ($pluginfo->component === $requiresme); $ismysibling = in_array($requiresme, array_keys($subplugins)); if (!$ismyparent and !$ismysibling) { return false; } } } // Check if there are some other plugins requiring this plugin // (but its subplugins). foreach ($this->other_plugins_that_require($pluginfo->component) as $requiresme) { $ismysubplugin = in_array($requiresme, array_keys($subplugins)); if (!$ismysubplugin) { return false; } } return true; }
[ "public", "function", "can_uninstall_plugin", "(", "$", "component", ")", "{", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "common_uninstall_check", "(", "$", "pluginfo", ")", ")", "{", "return", "false", ";", "}", "// Verify only if something else requires the subplugins, do not verify their common_uninstall_check()!", "$", "subplugins", "=", "$", "this", "->", "get_subplugins_of_plugin", "(", "$", "pluginfo", "->", "component", ")", ";", "foreach", "(", "$", "subplugins", "as", "$", "subpluginfo", ")", "{", "// Check if there are some other plugins requiring this subplugin", "// (but the parent and siblings).", "foreach", "(", "$", "this", "->", "other_plugins_that_require", "(", "$", "subpluginfo", "->", "component", ")", "as", "$", "requiresme", ")", "{", "$", "ismyparent", "=", "(", "$", "pluginfo", "->", "component", "===", "$", "requiresme", ")", ";", "$", "ismysibling", "=", "in_array", "(", "$", "requiresme", ",", "array_keys", "(", "$", "subplugins", ")", ")", ";", "if", "(", "!", "$", "ismyparent", "and", "!", "$", "ismysibling", ")", "{", "return", "false", ";", "}", "}", "}", "// Check if there are some other plugins requiring this plugin", "// (but its subplugins).", "foreach", "(", "$", "this", "->", "other_plugins_that_require", "(", "$", "pluginfo", "->", "component", ")", "as", "$", "requiresme", ")", "{", "$", "ismysubplugin", "=", "in_array", "(", "$", "requiresme", ",", "array_keys", "(", "$", "subplugins", ")", ")", ";", "if", "(", "!", "$", "ismysubplugin", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Is it possible to uninstall the given plugin? False is returned if the plugininfo subclass declares the uninstall should not be allowed via {@link \core\plugininfo\base::is_uninstall_allowed()} or if the core vetoes it (e.g. becase the plugin or some of its subplugins is required by some other installed plugin). @param string $component full frankenstyle name, e.g. mod_foobar @return bool
[ "Is", "it", "possible", "to", "uninstall", "the", "given", "plugin?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1173-L1209
217,475
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_uninstall_url
public function get_uninstall_url($component, $return = 'overview') { if (!$this->can_uninstall_plugin($component)) { return null; } $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return null; } if (method_exists($pluginfo, 'get_uninstall_url')) { debugging('plugininfo method get_uninstall_url() is deprecated, all plugins should be uninstalled via standard URL only.'); return $pluginfo->get_uninstall_url($return); } return $pluginfo->get_default_uninstall_url($return); }
php
public function get_uninstall_url($component, $return = 'overview') { if (!$this->can_uninstall_plugin($component)) { return null; } $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return null; } if (method_exists($pluginfo, 'get_uninstall_url')) { debugging('plugininfo method get_uninstall_url() is deprecated, all plugins should be uninstalled via standard URL only.'); return $pluginfo->get_uninstall_url($return); } return $pluginfo->get_default_uninstall_url($return); }
[ "public", "function", "get_uninstall_url", "(", "$", "component", ",", "$", "return", "=", "'overview'", ")", "{", "if", "(", "!", "$", "this", "->", "can_uninstall_plugin", "(", "$", "component", ")", ")", "{", "return", "null", ";", "}", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "return", "null", ";", "}", "if", "(", "method_exists", "(", "$", "pluginfo", ",", "'get_uninstall_url'", ")", ")", "{", "debugging", "(", "'plugininfo method get_uninstall_url() is deprecated, all plugins should be uninstalled via standard URL only.'", ")", ";", "return", "$", "pluginfo", "->", "get_uninstall_url", "(", "$", "return", ")", ";", "}", "return", "$", "pluginfo", "->", "get_default_uninstall_url", "(", "$", "return", ")", ";", "}" ]
Returns uninstall URL if exists. @param string $component @param string $return either 'overview' or 'manage' @return moodle_url uninstall URL, null if uninstall not supported
[ "Returns", "uninstall", "URL", "if", "exists", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1391-L1408
217,476
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.uninstall_plugin
public function uninstall_plugin($component, progress_trace $progress) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } // Give the pluginfo class a chance to execute some steps. $result = $pluginfo->uninstall($progress); if (!$result) { return false; } // Call the legacy core function to uninstall the plugin. ob_start(); uninstall_plugin($pluginfo->type, $pluginfo->name); $progress->output(ob_get_clean()); return true; }
php
public function uninstall_plugin($component, progress_trace $progress) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } // Give the pluginfo class a chance to execute some steps. $result = $pluginfo->uninstall($progress); if (!$result) { return false; } // Call the legacy core function to uninstall the plugin. ob_start(); uninstall_plugin($pluginfo->type, $pluginfo->name); $progress->output(ob_get_clean()); return true; }
[ "public", "function", "uninstall_plugin", "(", "$", "component", ",", "progress_trace", "$", "progress", ")", "{", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "return", "false", ";", "}", "// Give the pluginfo class a chance to execute some steps.", "$", "result", "=", "$", "pluginfo", "->", "uninstall", "(", "$", "progress", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "false", ";", "}", "// Call the legacy core function to uninstall the plugin.", "ob_start", "(", ")", ";", "uninstall_plugin", "(", "$", "pluginfo", "->", "type", ",", "$", "pluginfo", "->", "name", ")", ";", "$", "progress", "->", "output", "(", "ob_get_clean", "(", ")", ")", ";", "return", "true", ";", "}" ]
Uninstall the given plugin. Automatically cleans-up all remaining configuration data, log records, events, files from the file pool etc. In the future, the functionality of {@link uninstall_plugin()} function may be moved into this method and all the code should be refactored to use it. At the moment, we mimic this future behaviour by wrapping that function call. @param string $component @param progress_trace $progress traces the process @return bool true on success, false on errors/problems
[ "Uninstall", "the", "given", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1424-L1444
217,477
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.some_plugins_updatable
public function some_plugins_updatable() { foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($plugin->available_updates()) { return true; } } } return false; }
php
public function some_plugins_updatable() { foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($plugin->available_updates()) { return true; } } } return false; }
[ "public", "function", "some_plugins_updatable", "(", ")", "{", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "->", "available_updates", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if there are some plugins with a known available update @return bool true if there is at least one available update
[ "Checks", "if", "there", "are", "some", "plugins", "with", "a", "known", "available", "update" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1451-L1461
217,478
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.load_available_updates_for_plugin
public function load_available_updates_for_plugin($component) { global $CFG; $provider = \core\update\checker::instance(); if (!$provider->enabled() or during_initial_install()) { return null; } if (isset($CFG->updateminmaturity)) { $minmaturity = $CFG->updateminmaturity; } else { // This can happen during the very first upgrade to 2.3. $minmaturity = MATURITY_STABLE; } return $provider->get_update_info($component, array('minmaturity' => $minmaturity)); }
php
public function load_available_updates_for_plugin($component) { global $CFG; $provider = \core\update\checker::instance(); if (!$provider->enabled() or during_initial_install()) { return null; } if (isset($CFG->updateminmaturity)) { $minmaturity = $CFG->updateminmaturity; } else { // This can happen during the very first upgrade to 2.3. $minmaturity = MATURITY_STABLE; } return $provider->get_update_info($component, array('minmaturity' => $minmaturity)); }
[ "public", "function", "load_available_updates_for_plugin", "(", "$", "component", ")", "{", "global", "$", "CFG", ";", "$", "provider", "=", "\\", "core", "\\", "update", "\\", "checker", "::", "instance", "(", ")", ";", "if", "(", "!", "$", "provider", "->", "enabled", "(", ")", "or", "during_initial_install", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isset", "(", "$", "CFG", "->", "updateminmaturity", ")", ")", "{", "$", "minmaturity", "=", "$", "CFG", "->", "updateminmaturity", ";", "}", "else", "{", "// This can happen during the very first upgrade to 2.3.", "$", "minmaturity", "=", "MATURITY_STABLE", ";", "}", "return", "$", "provider", "->", "get_update_info", "(", "$", "component", ",", "array", "(", "'minmaturity'", "=>", "$", "minmaturity", ")", ")", ";", "}" ]
Returns list of available updates for the given component. This method should be considered as internal API and is supposed to be called by {@link \core\plugininfo\base::available_updates()} only to lazy load the data once they are first requested. @param string $component frankenstyle name of the plugin @return null|array array of \core\update\info objects or null
[ "Returns", "list", "of", "available", "updates", "for", "the", "given", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1473-L1490
217,479
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.available_updates
public function available_updates() { $updates = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { $availableupdates = $plugin->available_updates(); if (empty($availableupdates)) { continue; } foreach ($availableupdates as $update) { if (empty($updates[$plugin->component])) { $updates[$plugin->component] = $update; continue; } $maturitycurrent = $updates[$plugin->component]->maturity; if (empty($maturitycurrent)) { $maturitycurrent = MATURITY_STABLE - 25; } $maturityremote = $update->maturity; if (empty($maturityremote)) { $maturityremote = MATURITY_STABLE - 25; } if ($maturityremote < $maturitycurrent) { continue; } if ($maturityremote > $maturitycurrent) { $updates[$plugin->component] = $update; continue; } if ($update->version > $updates[$plugin->component]->version) { $updates[$plugin->component] = $update; continue; } } } } foreach ($updates as $component => $update) { $remoteinfo = $this->get_remote_plugin_info($component, $update->version, true); if (empty($remoteinfo) or empty($remoteinfo->version)) { unset($updates[$component]); } else { $updates[$component] = $remoteinfo; } } return $updates; }
php
public function available_updates() { $updates = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { $availableupdates = $plugin->available_updates(); if (empty($availableupdates)) { continue; } foreach ($availableupdates as $update) { if (empty($updates[$plugin->component])) { $updates[$plugin->component] = $update; continue; } $maturitycurrent = $updates[$plugin->component]->maturity; if (empty($maturitycurrent)) { $maturitycurrent = MATURITY_STABLE - 25; } $maturityremote = $update->maturity; if (empty($maturityremote)) { $maturityremote = MATURITY_STABLE - 25; } if ($maturityremote < $maturitycurrent) { continue; } if ($maturityremote > $maturitycurrent) { $updates[$plugin->component] = $update; continue; } if ($update->version > $updates[$plugin->component]->version) { $updates[$plugin->component] = $update; continue; } } } } foreach ($updates as $component => $update) { $remoteinfo = $this->get_remote_plugin_info($component, $update->version, true); if (empty($remoteinfo) or empty($remoteinfo->version)) { unset($updates[$component]); } else { $updates[$component] = $remoteinfo; } } return $updates; }
[ "public", "function", "available_updates", "(", ")", "{", "$", "updates", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "$", "availableupdates", "=", "$", "plugin", "->", "available_updates", "(", ")", ";", "if", "(", "empty", "(", "$", "availableupdates", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "availableupdates", "as", "$", "update", ")", "{", "if", "(", "empty", "(", "$", "updates", "[", "$", "plugin", "->", "component", "]", ")", ")", "{", "$", "updates", "[", "$", "plugin", "->", "component", "]", "=", "$", "update", ";", "continue", ";", "}", "$", "maturitycurrent", "=", "$", "updates", "[", "$", "plugin", "->", "component", "]", "->", "maturity", ";", "if", "(", "empty", "(", "$", "maturitycurrent", ")", ")", "{", "$", "maturitycurrent", "=", "MATURITY_STABLE", "-", "25", ";", "}", "$", "maturityremote", "=", "$", "update", "->", "maturity", ";", "if", "(", "empty", "(", "$", "maturityremote", ")", ")", "{", "$", "maturityremote", "=", "MATURITY_STABLE", "-", "25", ";", "}", "if", "(", "$", "maturityremote", "<", "$", "maturitycurrent", ")", "{", "continue", ";", "}", "if", "(", "$", "maturityremote", ">", "$", "maturitycurrent", ")", "{", "$", "updates", "[", "$", "plugin", "->", "component", "]", "=", "$", "update", ";", "continue", ";", "}", "if", "(", "$", "update", "->", "version", ">", "$", "updates", "[", "$", "plugin", "->", "component", "]", "->", "version", ")", "{", "$", "updates", "[", "$", "plugin", "->", "component", "]", "=", "$", "update", ";", "continue", ";", "}", "}", "}", "}", "foreach", "(", "$", "updates", "as", "$", "component", "=>", "$", "update", ")", "{", "$", "remoteinfo", "=", "$", "this", "->", "get_remote_plugin_info", "(", "$", "component", ",", "$", "update", "->", "version", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "remoteinfo", ")", "or", "empty", "(", "$", "remoteinfo", "->", "version", ")", ")", "{", "unset", "(", "$", "updates", "[", "$", "component", "]", ")", ";", "}", "else", "{", "$", "updates", "[", "$", "component", "]", "=", "$", "remoteinfo", ";", "}", "}", "return", "$", "updates", ";", "}" ]
Returns a list of all available updates to be installed. This is used when "update all plugins" action is performed at the administration UI screen. Returns array of remote info objects indexed by the plugin component. If there are multiple updates available (typically a mix of stable and non-stable ones), we pick the most mature most recent one. Plugins without explicit maturity are considered more mature than release candidates but less mature than explicit stable (this should be pretty rare case). @return array (string)component => (\core\update\remote_info)remoteinfo
[ "Returns", "a", "list", "of", "all", "available", "updates", "to", "be", "installed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1508-L1556
217,480
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_plugin_folder_removable
public function is_plugin_folder_removable($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } // To be able to remove the plugin folder, its parent must be writable, too. if (!is_writable(dirname($pluginfo->rootdir))) { return false; } // Check that the folder and all its content is writable (thence removable). return $this->is_directory_removable($pluginfo->rootdir); }
php
public function is_plugin_folder_removable($component) { $pluginfo = $this->get_plugin_info($component); if (is_null($pluginfo)) { return false; } // To be able to remove the plugin folder, its parent must be writable, too. if (!is_writable(dirname($pluginfo->rootdir))) { return false; } // Check that the folder and all its content is writable (thence removable). return $this->is_directory_removable($pluginfo->rootdir); }
[ "public", "function", "is_plugin_folder_removable", "(", "$", "component", ")", "{", "$", "pluginfo", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "is_null", "(", "$", "pluginfo", ")", ")", "{", "return", "false", ";", "}", "// To be able to remove the plugin folder, its parent must be writable, too.", "if", "(", "!", "is_writable", "(", "dirname", "(", "$", "pluginfo", "->", "rootdir", ")", ")", ")", "{", "return", "false", ";", "}", "// Check that the folder and all its content is writable (thence removable).", "return", "$", "this", "->", "is_directory_removable", "(", "$", "pluginfo", "->", "rootdir", ")", ";", "}" ]
Check to see if the given plugin folder can be removed by the web server process. @param string $component full frankenstyle component @return bool
[ "Check", "to", "see", "if", "the", "given", "plugin", "folder", "can", "be", "removed", "by", "the", "web", "server", "process", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1564-L1579
217,481
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_plugintype_writable
public function is_plugintype_writable($plugintype) { $plugintypepath = $this->get_plugintype_root($plugintype); if (is_null($plugintypepath)) { throw new coding_exception('Unknown plugin type: '.$plugintype); } if ($plugintypepath === false) { throw new coding_exception('Plugin type location does not exist: '.$plugintype); } return is_writable($plugintypepath); }
php
public function is_plugintype_writable($plugintype) { $plugintypepath = $this->get_plugintype_root($plugintype); if (is_null($plugintypepath)) { throw new coding_exception('Unknown plugin type: '.$plugintype); } if ($plugintypepath === false) { throw new coding_exception('Plugin type location does not exist: '.$plugintype); } return is_writable($plugintypepath); }
[ "public", "function", "is_plugintype_writable", "(", "$", "plugintype", ")", "{", "$", "plugintypepath", "=", "$", "this", "->", "get_plugintype_root", "(", "$", "plugintype", ")", ";", "if", "(", "is_null", "(", "$", "plugintypepath", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Unknown plugin type: '", ".", "$", "plugintype", ")", ";", "}", "if", "(", "$", "plugintypepath", "===", "false", ")", "{", "throw", "new", "coding_exception", "(", "'Plugin type location does not exist: '", ".", "$", "plugintype", ")", ";", "}", "return", "is_writable", "(", "$", "plugintypepath", ")", ";", "}" ]
Is it possible to create a new plugin directory for the given plugin type? @throws coding_exception for invalid plugin types or non-existing plugin type locations @param string $plugintype @return boolean
[ "Is", "it", "possible", "to", "create", "a", "new", "plugin", "directory", "for", "the", "given", "plugin", "type?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1588-L1601
217,482
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_plugintype_root
public function get_plugintype_root($plugintype) { $plugintypepath = null; foreach (core_component::get_plugin_types() as $type => $fullpath) { if ($type === $plugintype) { $plugintypepath = $fullpath; break; } } if (is_null($plugintypepath)) { return null; } if (!is_dir($plugintypepath)) { return false; } return $plugintypepath; }
php
public function get_plugintype_root($plugintype) { $plugintypepath = null; foreach (core_component::get_plugin_types() as $type => $fullpath) { if ($type === $plugintype) { $plugintypepath = $fullpath; break; } } if (is_null($plugintypepath)) { return null; } if (!is_dir($plugintypepath)) { return false; } return $plugintypepath; }
[ "public", "function", "get_plugintype_root", "(", "$", "plugintype", ")", "{", "$", "plugintypepath", "=", "null", ";", "foreach", "(", "core_component", "::", "get_plugin_types", "(", ")", "as", "$", "type", "=>", "$", "fullpath", ")", "{", "if", "(", "$", "type", "===", "$", "plugintype", ")", "{", "$", "plugintypepath", "=", "$", "fullpath", ";", "break", ";", "}", "}", "if", "(", "is_null", "(", "$", "plugintypepath", ")", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_dir", "(", "$", "plugintypepath", ")", ")", "{", "return", "false", ";", "}", "return", "$", "plugintypepath", ";", "}" ]
Returns the full path of the root of the given plugin type Null is returned if the plugin type is not known. False is returned if the plugin type root is expected but not found. Otherwise, string is returned. @param string $plugintype @return string|bool|null
[ "Returns", "the", "full", "path", "of", "the", "root", "of", "the", "given", "plugin", "type" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1613-L1630
217,483
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_deleted_standard_plugin
public static function is_deleted_standard_plugin($type, $name) { // Do not include plugins that were removed during upgrades to versions that are // not supported as source versions for upgrade any more. For example, at MOODLE_23_STABLE // branch, listed should be no plugins that were removed at 1.9.x - 2.1.x versions as // Moodle 2.3 supports upgrades from 2.2.x only. $plugins = array( 'qformat' => array('blackboard', 'learnwise'), 'auth' => array('radius', 'fc', 'nntp', 'pam', 'pop3', 'imap'), 'block' => array('course_overview', 'messages'), 'cachestore' => array('memcache'), 'enrol' => array('authorize'), 'report' => array('search'), 'repository' => array('alfresco'), 'tinymce' => array('dragmath'), 'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport', 'assignmentupgrade'), 'theme' => array('bootstrapbase', 'clean', 'more', 'afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'boxxie', 'brick', 'canvas', 'formal_white', 'formfactor', 'fusion', 'leatherbound', 'magazine', 'mymobile', 'nimble', 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash', 'standard', 'standardold'), 'webservice' => array('amf'), ); if (!isset($plugins[$type])) { return false; } return in_array($name, $plugins[$type]); }
php
public static function is_deleted_standard_plugin($type, $name) { // Do not include plugins that were removed during upgrades to versions that are // not supported as source versions for upgrade any more. For example, at MOODLE_23_STABLE // branch, listed should be no plugins that were removed at 1.9.x - 2.1.x versions as // Moodle 2.3 supports upgrades from 2.2.x only. $plugins = array( 'qformat' => array('blackboard', 'learnwise'), 'auth' => array('radius', 'fc', 'nntp', 'pam', 'pop3', 'imap'), 'block' => array('course_overview', 'messages'), 'cachestore' => array('memcache'), 'enrol' => array('authorize'), 'report' => array('search'), 'repository' => array('alfresco'), 'tinymce' => array('dragmath'), 'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport', 'assignmentupgrade'), 'theme' => array('bootstrapbase', 'clean', 'more', 'afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'boxxie', 'brick', 'canvas', 'formal_white', 'formfactor', 'fusion', 'leatherbound', 'magazine', 'mymobile', 'nimble', 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash', 'standard', 'standardold'), 'webservice' => array('amf'), ); if (!isset($plugins[$type])) { return false; } return in_array($name, $plugins[$type]); }
[ "public", "static", "function", "is_deleted_standard_plugin", "(", "$", "type", ",", "$", "name", ")", "{", "// Do not include plugins that were removed during upgrades to versions that are", "// not supported as source versions for upgrade any more. For example, at MOODLE_23_STABLE", "// branch, listed should be no plugins that were removed at 1.9.x - 2.1.x versions as", "// Moodle 2.3 supports upgrades from 2.2.x only.", "$", "plugins", "=", "array", "(", "'qformat'", "=>", "array", "(", "'blackboard'", ",", "'learnwise'", ")", ",", "'auth'", "=>", "array", "(", "'radius'", ",", "'fc'", ",", "'nntp'", ",", "'pam'", ",", "'pop3'", ",", "'imap'", ")", ",", "'block'", "=>", "array", "(", "'course_overview'", ",", "'messages'", ")", ",", "'cachestore'", "=>", "array", "(", "'memcache'", ")", ",", "'enrol'", "=>", "array", "(", "'authorize'", ")", ",", "'report'", "=>", "array", "(", "'search'", ")", ",", "'repository'", "=>", "array", "(", "'alfresco'", ")", ",", "'tinymce'", "=>", "array", "(", "'dragmath'", ")", ",", "'tool'", "=>", "array", "(", "'bloglevelupgrade'", ",", "'qeupgradehelper'", ",", "'timezoneimport'", ",", "'assignmentupgrade'", ")", ",", "'theme'", "=>", "array", "(", "'bootstrapbase'", ",", "'clean'", ",", "'more'", ",", "'afterburner'", ",", "'anomaly'", ",", "'arialist'", ",", "'base'", ",", "'binarius'", ",", "'boxxie'", ",", "'brick'", ",", "'canvas'", ",", "'formal_white'", ",", "'formfactor'", ",", "'fusion'", ",", "'leatherbound'", ",", "'magazine'", ",", "'mymobile'", ",", "'nimble'", ",", "'nonzero'", ",", "'overlay'", ",", "'serenity'", ",", "'sky_high'", ",", "'splash'", ",", "'standard'", ",", "'standardold'", ")", ",", "'webservice'", "=>", "array", "(", "'amf'", ")", ",", ")", ";", "if", "(", "!", "isset", "(", "$", "plugins", "[", "$", "type", "]", ")", ")", "{", "return", "false", ";", "}", "return", "in_array", "(", "$", "name", ",", "$", "plugins", "[", "$", "type", "]", ")", ";", "}" ]
Defines a list of all plugins that were originally shipped in the standard Moodle distribution, but are not anymore and are deleted during upgrades. The main purpose of this list is to hide missing plugins during upgrade. @param string $type plugin type @param string $name plugin name @return bool
[ "Defines", "a", "list", "of", "all", "plugins", "that", "were", "originally", "shipped", "in", "the", "standard", "Moodle", "distribution", "but", "are", "not", "anymore", "and", "are", "deleted", "during", "upgrades", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1642-L1668
217,484
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.remove_plugin_folder
public function remove_plugin_folder(\core\plugininfo\base $plugin) { if (!$this->is_plugin_folder_removable($plugin->component)) { throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '', array('plugin' => $plugin->component, 'rootdir' => $plugin->rootdir), 'plugin root folder is not removable as expected'); } if ($plugin->get_status() === self::PLUGIN_STATUS_UPTODATE or $plugin->get_status() === self::PLUGIN_STATUS_NEW) { $this->archive_plugin_version($plugin); } remove_dir($plugin->rootdir); clearstatcache(); if (function_exists('opcache_reset')) { opcache_reset(); } }
php
public function remove_plugin_folder(\core\plugininfo\base $plugin) { if (!$this->is_plugin_folder_removable($plugin->component)) { throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '', array('plugin' => $plugin->component, 'rootdir' => $plugin->rootdir), 'plugin root folder is not removable as expected'); } if ($plugin->get_status() === self::PLUGIN_STATUS_UPTODATE or $plugin->get_status() === self::PLUGIN_STATUS_NEW) { $this->archive_plugin_version($plugin); } remove_dir($plugin->rootdir); clearstatcache(); if (function_exists('opcache_reset')) { opcache_reset(); } }
[ "public", "function", "remove_plugin_folder", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ")", "{", "if", "(", "!", "$", "this", "->", "is_plugin_folder_removable", "(", "$", "plugin", "->", "component", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'err_removing_unremovable_folder'", ",", "'core_plugin'", ",", "''", ",", "array", "(", "'plugin'", "=>", "$", "plugin", "->", "component", ",", "'rootdir'", "=>", "$", "plugin", "->", "rootdir", ")", ",", "'plugin root folder is not removable as expected'", ")", ";", "}", "if", "(", "$", "plugin", "->", "get_status", "(", ")", "===", "self", "::", "PLUGIN_STATUS_UPTODATE", "or", "$", "plugin", "->", "get_status", "(", ")", "===", "self", "::", "PLUGIN_STATUS_NEW", ")", "{", "$", "this", "->", "archive_plugin_version", "(", "$", "plugin", ")", ";", "}", "remove_dir", "(", "$", "plugin", "->", "rootdir", ")", ";", "clearstatcache", "(", ")", ";", "if", "(", "function_exists", "(", "'opcache_reset'", ")", ")", "{", "opcache_reset", "(", ")", ";", "}", "}" ]
Remove the current plugin code from the dirroot. If removing the currently installed version (which happens during updates), we archive the code so that the upgrade can be cancelled. To prevent accidental data-loss, we also archive the existing plugin code if cancelling installation of it, so that the developer does not loose the only version of their work-in-progress. @param \core\plugininfo\base $plugin
[ "Remove", "the", "current", "plugin", "code", "from", "the", "dirroot", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1956-L1973
217,485
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.can_cancel_plugin_installation
public function can_cancel_plugin_installation(\core\plugininfo\base $plugin) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin() or !$this->is_plugin_folder_removable($plugin->component)) { return false; } if ($plugin->get_status() === self::PLUGIN_STATUS_NEW) { return true; } return false; }
php
public function can_cancel_plugin_installation(\core\plugininfo\base $plugin) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin() or !$this->is_plugin_folder_removable($plugin->component)) { return false; } if ($plugin->get_status() === self::PLUGIN_STATUS_NEW) { return true; } return false; }
[ "public", "function", "can_cancel_plugin_installation", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "plugin", ")", "or", "$", "plugin", "->", "is_standard", "(", ")", "or", "$", "plugin", "->", "is_subplugin", "(", ")", "or", "!", "$", "this", "->", "is_plugin_folder_removable", "(", "$", "plugin", "->", "component", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "plugin", "->", "get_status", "(", ")", "===", "self", "::", "PLUGIN_STATUS_NEW", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Can the installation of the new plugin be cancelled? Subplugins can be cancelled only via their parent plugin, not separately (they are considered as implicit requirements if distributed together with the main package). @param \core\plugininfo\base $plugin @return bool
[ "Can", "the", "installation", "of", "the", "new", "plugin", "be", "cancelled?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L1985-L2002
217,486
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.can_cancel_plugin_upgrade
public function can_cancel_plugin_upgrade(\core\plugininfo\base $plugin) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { // Cancelling the plugin upgrade is actually installation of the // previously archived version. return false; } if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin() or !$this->is_plugin_folder_removable($plugin->component)) { return false; } if ($plugin->get_status() === self::PLUGIN_STATUS_UPGRADE) { if ($this->get_code_manager()->get_archived_plugin_version($plugin->component, $plugin->versiondb)) { return true; } } return false; }
php
public function can_cancel_plugin_upgrade(\core\plugininfo\base $plugin) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { // Cancelling the plugin upgrade is actually installation of the // previously archived version. return false; } if (empty($plugin) or $plugin->is_standard() or $plugin->is_subplugin() or !$this->is_plugin_folder_removable($plugin->component)) { return false; } if ($plugin->get_status() === self::PLUGIN_STATUS_UPGRADE) { if ($this->get_code_manager()->get_archived_plugin_version($plugin->component, $plugin->versiondb)) { return true; } } return false; }
[ "public", "function", "can_cancel_plugin_upgrade", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "// Cancelling the plugin upgrade is actually installation of the", "// previously archived version.", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "plugin", ")", "or", "$", "plugin", "->", "is_standard", "(", ")", "or", "$", "plugin", "->", "is_subplugin", "(", ")", "or", "!", "$", "this", "->", "is_plugin_folder_removable", "(", "$", "plugin", "->", "component", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "plugin", "->", "get_status", "(", ")", "===", "self", "::", "PLUGIN_STATUS_UPGRADE", ")", "{", "if", "(", "$", "this", "->", "get_code_manager", "(", ")", "->", "get_archived_plugin_version", "(", "$", "plugin", "->", "component", ",", "$", "plugin", "->", "versiondb", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Can the upgrade of the existing plugin be cancelled? Subplugins can be cancelled only via their parent plugin, not separately (they are considered as implicit requirements if distributed together with the main package). @param \core\plugininfo\base $plugin @return bool
[ "Can", "the", "upgrade", "of", "the", "existing", "plugin", "be", "cancelled?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2014-L2035
217,487
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.cancel_plugin_installation
public function cancel_plugin_installation($component) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } $plugin = $this->get_plugin_info($component); if ($this->can_cancel_plugin_installation($plugin)) { $this->remove_plugin_folder($plugin); } return false; }
php
public function cancel_plugin_installation($component) { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } $plugin = $this->get_plugin_info($component); if ($this->can_cancel_plugin_installation($plugin)) { $this->remove_plugin_folder($plugin); } return false; }
[ "public", "function", "cancel_plugin_installation", "(", "$", "component", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "return", "false", ";", "}", "$", "plugin", "=", "$", "this", "->", "get_plugin_info", "(", "$", "component", ")", ";", "if", "(", "$", "this", "->", "can_cancel_plugin_installation", "(", "$", "plugin", ")", ")", "{", "$", "this", "->", "remove_plugin_folder", "(", "$", "plugin", ")", ";", "}", "return", "false", ";", "}" ]
Removes the plugin code directory if it is not installed yet. This is intended for the plugins check screen to give the admin a chance to cancel the installation of just unzipped plugin before the database upgrade happens. @param string $component
[ "Removes", "the", "plugin", "code", "directory", "if", "it", "is", "not", "installed", "yet", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2046-L2060
217,488
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.list_cancellable_installations
public function list_cancellable_installations() { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return array(); } $cancellable = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($this->can_cancel_plugin_installation($plugin)) { $cancellable[$plugin->component] = $plugin; } } } return $cancellable; }
php
public function list_cancellable_installations() { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return array(); } $cancellable = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($this->can_cancel_plugin_installation($plugin)) { $cancellable[$plugin->component] = $plugin; } } } return $cancellable; }
[ "public", "function", "list_cancellable_installations", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "cancellable", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "this", "->", "can_cancel_plugin_installation", "(", "$", "plugin", ")", ")", "{", "$", "cancellable", "[", "$", "plugin", "->", "component", "]", "=", "$", "plugin", ";", "}", "}", "}", "return", "$", "cancellable", ";", "}" ]
Returns plugins, the installation of which can be cancelled. @return array [(string)component] => (\core\plugininfo\base)plugin
[ "Returns", "plugins", "the", "installation", "of", "which", "can", "be", "cancelled", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2067-L2084
217,489
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.archive_plugin_version
public function archive_plugin_version(\core\plugininfo\base $plugin) { return $this->get_code_manager()->archive_plugin_version($plugin->rootdir, $plugin->component, $plugin->versiondisk); }
php
public function archive_plugin_version(\core\plugininfo\base $plugin) { return $this->get_code_manager()->archive_plugin_version($plugin->rootdir, $plugin->component, $plugin->versiondisk); }
[ "public", "function", "archive_plugin_version", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "plugin", ")", "{", "return", "$", "this", "->", "get_code_manager", "(", ")", "->", "archive_plugin_version", "(", "$", "plugin", "->", "rootdir", ",", "$", "plugin", "->", "component", ",", "$", "plugin", "->", "versiondisk", ")", ";", "}" ]
Archive the current on-disk plugin code. @param \core\plugiinfo\base $plugin @return bool
[ "Archive", "the", "current", "on", "-", "disk", "plugin", "code", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2092-L2094
217,490
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.list_restorable_archives
public function list_restorable_archives() { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } $codeman = $this->get_code_manager(); $restorable = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($this->can_cancel_plugin_upgrade($plugin)) { $restorable[$plugin->component] = (object)array( 'component' => $plugin->component, 'zipfilepath' => $codeman->get_archived_plugin_version($plugin->component, $plugin->versiondb) ); } } } return $restorable; }
php
public function list_restorable_archives() { global $CFG; if (!empty($CFG->disableupdateautodeploy)) { return false; } $codeman = $this->get_code_manager(); $restorable = array(); foreach ($this->get_plugins() as $type => $plugins) { foreach ($plugins as $plugin) { if ($this->can_cancel_plugin_upgrade($plugin)) { $restorable[$plugin->component] = (object)array( 'component' => $plugin->component, 'zipfilepath' => $codeman->get_archived_plugin_version($plugin->component, $plugin->versiondb) ); } } } return $restorable; }
[ "public", "function", "list_restorable_archives", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "disableupdateautodeploy", ")", ")", "{", "return", "false", ";", "}", "$", "codeman", "=", "$", "this", "->", "get_code_manager", "(", ")", ";", "$", "restorable", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "get_plugins", "(", ")", "as", "$", "type", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "this", "->", "can_cancel_plugin_upgrade", "(", "$", "plugin", ")", ")", "{", "$", "restorable", "[", "$", "plugin", "->", "component", "]", "=", "(", "object", ")", "array", "(", "'component'", "=>", "$", "plugin", "->", "component", ",", "'zipfilepath'", "=>", "$", "codeman", "->", "get_archived_plugin_version", "(", "$", "plugin", "->", "component", ",", "$", "plugin", "->", "versiondb", ")", ")", ";", "}", "}", "}", "return", "$", "restorable", ";", "}" ]
Returns list of all archives that can be installed to cancel the plugin upgrade. @return array [(string)component] => {(string)->component, (string)->zipfilepath}
[ "Returns", "list", "of", "all", "archives", "that", "can", "be", "installed", "to", "cancel", "the", "plugin", "upgrade", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2101-L2122
217,491
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.reorder_plugin_types
protected function reorder_plugin_types(array $types) { $fix = array('mod' => $types['mod']); foreach (core_component::get_plugin_list('mod') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('mod_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } $fix['mod'] = $types['mod']; $fix['block'] = $types['block']; $fix['qtype'] = $types['qtype']; $fix['qbehaviour'] = $types['qbehaviour']; $fix['qformat'] = $types['qformat']; $fix['filter'] = $types['filter']; $fix['editor'] = $types['editor']; foreach (core_component::get_plugin_list('editor') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('editor_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } $fix['enrol'] = $types['enrol']; $fix['auth'] = $types['auth']; $fix['tool'] = $types['tool']; foreach (core_component::get_plugin_list('tool') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('tool_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } foreach ($types as $type => $path) { if (!isset($fix[$type])) { $fix[$type] = $path; } } return $fix; }
php
protected function reorder_plugin_types(array $types) { $fix = array('mod' => $types['mod']); foreach (core_component::get_plugin_list('mod') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('mod_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } $fix['mod'] = $types['mod']; $fix['block'] = $types['block']; $fix['qtype'] = $types['qtype']; $fix['qbehaviour'] = $types['qbehaviour']; $fix['qformat'] = $types['qformat']; $fix['filter'] = $types['filter']; $fix['editor'] = $types['editor']; foreach (core_component::get_plugin_list('editor') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('editor_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } $fix['enrol'] = $types['enrol']; $fix['auth'] = $types['auth']; $fix['tool'] = $types['tool']; foreach (core_component::get_plugin_list('tool') as $plugin => $fulldir) { if (!$subtypes = core_component::get_subplugins('tool_'.$plugin)) { continue; } foreach ($subtypes as $subtype => $ignored) { $fix[$subtype] = $types[$subtype]; } } foreach ($types as $type => $path) { if (!isset($fix[$type])) { $fix[$type] = $path; } } return $fix; }
[ "protected", "function", "reorder_plugin_types", "(", "array", "$", "types", ")", "{", "$", "fix", "=", "array", "(", "'mod'", "=>", "$", "types", "[", "'mod'", "]", ")", ";", "foreach", "(", "core_component", "::", "get_plugin_list", "(", "'mod'", ")", "as", "$", "plugin", "=>", "$", "fulldir", ")", "{", "if", "(", "!", "$", "subtypes", "=", "core_component", "::", "get_subplugins", "(", "'mod_'", ".", "$", "plugin", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "subtypes", "as", "$", "subtype", "=>", "$", "ignored", ")", "{", "$", "fix", "[", "$", "subtype", "]", "=", "$", "types", "[", "$", "subtype", "]", ";", "}", "}", "$", "fix", "[", "'mod'", "]", "=", "$", "types", "[", "'mod'", "]", ";", "$", "fix", "[", "'block'", "]", "=", "$", "types", "[", "'block'", "]", ";", "$", "fix", "[", "'qtype'", "]", "=", "$", "types", "[", "'qtype'", "]", ";", "$", "fix", "[", "'qbehaviour'", "]", "=", "$", "types", "[", "'qbehaviour'", "]", ";", "$", "fix", "[", "'qformat'", "]", "=", "$", "types", "[", "'qformat'", "]", ";", "$", "fix", "[", "'filter'", "]", "=", "$", "types", "[", "'filter'", "]", ";", "$", "fix", "[", "'editor'", "]", "=", "$", "types", "[", "'editor'", "]", ";", "foreach", "(", "core_component", "::", "get_plugin_list", "(", "'editor'", ")", "as", "$", "plugin", "=>", "$", "fulldir", ")", "{", "if", "(", "!", "$", "subtypes", "=", "core_component", "::", "get_subplugins", "(", "'editor_'", ".", "$", "plugin", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "subtypes", "as", "$", "subtype", "=>", "$", "ignored", ")", "{", "$", "fix", "[", "$", "subtype", "]", "=", "$", "types", "[", "$", "subtype", "]", ";", "}", "}", "$", "fix", "[", "'enrol'", "]", "=", "$", "types", "[", "'enrol'", "]", ";", "$", "fix", "[", "'auth'", "]", "=", "$", "types", "[", "'auth'", "]", ";", "$", "fix", "[", "'tool'", "]", "=", "$", "types", "[", "'tool'", "]", ";", "foreach", "(", "core_component", "::", "get_plugin_list", "(", "'tool'", ")", "as", "$", "plugin", "=>", "$", "fulldir", ")", "{", "if", "(", "!", "$", "subtypes", "=", "core_component", "::", "get_subplugins", "(", "'tool_'", ".", "$", "plugin", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "subtypes", "as", "$", "subtype", "=>", "$", "ignored", ")", "{", "$", "fix", "[", "$", "subtype", "]", "=", "$", "types", "[", "$", "subtype", "]", ";", "}", "}", "foreach", "(", "$", "types", "as", "$", "type", "=>", "$", "path", ")", "{", "if", "(", "!", "isset", "(", "$", "fix", "[", "$", "type", "]", ")", ")", "{", "$", "fix", "[", "$", "type", "]", "=", "$", "path", ";", "}", "}", "return", "$", "fix", ";", "}" ]
Reorders plugin types into a sequence to be displayed For technical reasons, plugin types returned by {@link core_component::get_plugin_types()} are in a certain order that does not need to fit the expected order for the display. Particularly, activity modules should be displayed first as they represent the real heart of Moodle. They should be followed by other plugin types that are used to build the courses (as that is what one expects from LMS). After that, other supportive plugin types follow. @param array $types associative array @return array same array with altered order of items
[ "Reorders", "plugin", "types", "into", "a", "sequence", "to", "be", "displayed" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2137-L2183
217,492
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.is_directory_removable
public function is_directory_removable($fullpath) { if (!is_writable($fullpath)) { return false; } if (is_dir($fullpath)) { $handle = opendir($fullpath); } else { return false; } $result = true; while ($filename = readdir($handle)) { if ($filename === '.' or $filename === '..') { continue; } $subfilepath = $fullpath.'/'.$filename; if (is_dir($subfilepath)) { $result = $result && $this->is_directory_removable($subfilepath); } else { $result = $result && is_writable($subfilepath); } } closedir($handle); return $result; }
php
public function is_directory_removable($fullpath) { if (!is_writable($fullpath)) { return false; } if (is_dir($fullpath)) { $handle = opendir($fullpath); } else { return false; } $result = true; while ($filename = readdir($handle)) { if ($filename === '.' or $filename === '..') { continue; } $subfilepath = $fullpath.'/'.$filename; if (is_dir($subfilepath)) { $result = $result && $this->is_directory_removable($subfilepath); } else { $result = $result && is_writable($subfilepath); } } closedir($handle); return $result; }
[ "public", "function", "is_directory_removable", "(", "$", "fullpath", ")", "{", "if", "(", "!", "is_writable", "(", "$", "fullpath", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_dir", "(", "$", "fullpath", ")", ")", "{", "$", "handle", "=", "opendir", "(", "$", "fullpath", ")", ";", "}", "else", "{", "return", "false", ";", "}", "$", "result", "=", "true", ";", "while", "(", "$", "filename", "=", "readdir", "(", "$", "handle", ")", ")", "{", "if", "(", "$", "filename", "===", "'.'", "or", "$", "filename", "===", "'..'", ")", "{", "continue", ";", "}", "$", "subfilepath", "=", "$", "fullpath", ".", "'/'", ".", "$", "filename", ";", "if", "(", "is_dir", "(", "$", "subfilepath", ")", ")", "{", "$", "result", "=", "$", "result", "&&", "$", "this", "->", "is_directory_removable", "(", "$", "subfilepath", ")", ";", "}", "else", "{", "$", "result", "=", "$", "result", "&&", "is_writable", "(", "$", "subfilepath", ")", ";", "}", "}", "closedir", "(", "$", "handle", ")", ";", "return", "$", "result", ";", "}" ]
Check if the given directory can be removed by the web server process. This recursively checks that the given directory and all its contents it writable. @param string $fullpath @return boolean
[ "Check", "if", "the", "given", "directory", "can", "be", "removed", "by", "the", "web", "server", "process", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2194-L2227
217,493
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.common_uninstall_check
protected function common_uninstall_check(\core\plugininfo\base $pluginfo) { if (!$pluginfo->is_uninstall_allowed()) { // The plugin's plugininfo class declares it should not be uninstalled. return false; } if ($pluginfo->get_status() === static::PLUGIN_STATUS_NEW) { // The plugin is not installed. It should be either installed or removed from the disk. // Relying on this temporary state may be tricky. return false; } if (method_exists($pluginfo, 'get_uninstall_url') and is_null($pluginfo->get_uninstall_url())) { // Backwards compatibility. debugging('\core\plugininfo\base subclasses should use is_uninstall_allowed() instead of returning null in get_uninstall_url()', DEBUG_DEVELOPER); return false; } return true; }
php
protected function common_uninstall_check(\core\plugininfo\base $pluginfo) { if (!$pluginfo->is_uninstall_allowed()) { // The plugin's plugininfo class declares it should not be uninstalled. return false; } if ($pluginfo->get_status() === static::PLUGIN_STATUS_NEW) { // The plugin is not installed. It should be either installed or removed from the disk. // Relying on this temporary state may be tricky. return false; } if (method_exists($pluginfo, 'get_uninstall_url') and is_null($pluginfo->get_uninstall_url())) { // Backwards compatibility. debugging('\core\plugininfo\base subclasses should use is_uninstall_allowed() instead of returning null in get_uninstall_url()', DEBUG_DEVELOPER); return false; } return true; }
[ "protected", "function", "common_uninstall_check", "(", "\\", "core", "\\", "plugininfo", "\\", "base", "$", "pluginfo", ")", "{", "if", "(", "!", "$", "pluginfo", "->", "is_uninstall_allowed", "(", ")", ")", "{", "// The plugin's plugininfo class declares it should not be uninstalled.", "return", "false", ";", "}", "if", "(", "$", "pluginfo", "->", "get_status", "(", ")", "===", "static", "::", "PLUGIN_STATUS_NEW", ")", "{", "// The plugin is not installed. It should be either installed or removed from the disk.", "// Relying on this temporary state may be tricky.", "return", "false", ";", "}", "if", "(", "method_exists", "(", "$", "pluginfo", ",", "'get_uninstall_url'", ")", "and", "is_null", "(", "$", "pluginfo", "->", "get_uninstall_url", "(", ")", ")", ")", "{", "// Backwards compatibility.", "debugging", "(", "'\\core\\plugininfo\\base subclasses should use is_uninstall_allowed() instead of returning null in get_uninstall_url()'", ",", "DEBUG_DEVELOPER", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Helper method that implements common uninstall prerequisites @param \core\plugininfo\base $pluginfo @return bool
[ "Helper", "method", "that", "implements", "common", "uninstall", "prerequisites" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2235-L2256
217,494
moodle/moodle
lib/classes/plugin_manager.php
core_plugin_manager.get_code_manager
protected function get_code_manager() { if ($this->codemanager === null) { $this->codemanager = new \core\update\code_manager(); } return $this->codemanager; }
php
protected function get_code_manager() { if ($this->codemanager === null) { $this->codemanager = new \core\update\code_manager(); } return $this->codemanager; }
[ "protected", "function", "get_code_manager", "(", ")", "{", "if", "(", "$", "this", "->", "codemanager", "===", "null", ")", "{", "$", "this", "->", "codemanager", "=", "new", "\\", "core", "\\", "update", "\\", "code_manager", "(", ")", ";", "}", "return", "$", "this", "->", "codemanager", ";", "}" ]
Returns a code_manager instance to be used for the plugins code operations. @return \core\update\code_manager
[ "Returns", "a", "code_manager", "instance", "to", "be", "used", "for", "the", "plugins", "code", "operations", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/plugin_manager.php#L2263-L2270
217,495
moodle/moodle
lib/spout/src/Spout/Writer/Style/Color.php
Color.rgb
public static function rgb($red, $green, $blue) { self::throwIfInvalidColorComponentValue($red); self::throwIfInvalidColorComponentValue($green); self::throwIfInvalidColorComponentValue($blue); return strtoupper( self::convertColorComponentToHex($red) . self::convertColorComponentToHex($green) . self::convertColorComponentToHex($blue) ); }
php
public static function rgb($red, $green, $blue) { self::throwIfInvalidColorComponentValue($red); self::throwIfInvalidColorComponentValue($green); self::throwIfInvalidColorComponentValue($blue); return strtoupper( self::convertColorComponentToHex($red) . self::convertColorComponentToHex($green) . self::convertColorComponentToHex($blue) ); }
[ "public", "static", "function", "rgb", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "self", "::", "throwIfInvalidColorComponentValue", "(", "$", "red", ")", ";", "self", "::", "throwIfInvalidColorComponentValue", "(", "$", "green", ")", ";", "self", "::", "throwIfInvalidColorComponentValue", "(", "$", "blue", ")", ";", "return", "strtoupper", "(", "self", "::", "convertColorComponentToHex", "(", "$", "red", ")", ".", "self", "::", "convertColorComponentToHex", "(", "$", "green", ")", ".", "self", "::", "convertColorComponentToHex", "(", "$", "blue", ")", ")", ";", "}" ]
Returns an RGB color from R, G and B values @api @param int $red Red component, 0 - 255 @param int $green Green component, 0 - 255 @param int $blue Blue component, 0 - 255 @return string RGB color
[ "Returns", "an", "RGB", "color", "from", "R", "G", "and", "B", "values" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Style/Color.php#L38-L49
217,496
moodle/moodle
privacy/classes/local/sitepolicy/manager.php
manager.get_handler_classname
public function get_handler_classname() { global $CFG; if (!empty($CFG->sitepolicyhandler)) { $sitepolicyhandlers = $this->get_all_handlers(); if (!isset($sitepolicyhandlers[$CFG->sitepolicyhandler])) { return default_handler::class; } else { return $sitepolicyhandlers[$CFG->sitepolicyhandler]; } } else { return default_handler::class; } }
php
public function get_handler_classname() { global $CFG; if (!empty($CFG->sitepolicyhandler)) { $sitepolicyhandlers = $this->get_all_handlers(); if (!isset($sitepolicyhandlers[$CFG->sitepolicyhandler])) { return default_handler::class; } else { return $sitepolicyhandlers[$CFG->sitepolicyhandler]; } } else { return default_handler::class; } }
[ "public", "function", "get_handler_classname", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "sitepolicyhandler", ")", ")", "{", "$", "sitepolicyhandlers", "=", "$", "this", "->", "get_all_handlers", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "sitepolicyhandlers", "[", "$", "CFG", "->", "sitepolicyhandler", "]", ")", ")", "{", "return", "default_handler", "::", "class", ";", "}", "else", "{", "return", "$", "sitepolicyhandlers", "[", "$", "CFG", "->", "sitepolicyhandler", "]", ";", "}", "}", "else", "{", "return", "default_handler", "::", "class", ";", "}", "}" ]
Returns the current site policy handler @return handler
[ "Returns", "the", "current", "site", "policy", "handler" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/sitepolicy/manager.php#L62-L78
217,497
moodle/moodle
lib/classes/event/content_viewed.php
content_viewed.init
protected function init() { global $PAGE; $this->data['crud'] = 'r'; $this->data['edulevel'] = self::LEVEL_OTHER; $this->context = $PAGE->context; }
php
protected function init() { global $PAGE; $this->data['crud'] = 'r'; $this->data['edulevel'] = self::LEVEL_OTHER; $this->context = $PAGE->context; }
[ "protected", "function", "init", "(", ")", "{", "global", "$", "PAGE", ";", "$", "this", "->", "data", "[", "'crud'", "]", "=", "'r'", ";", "$", "this", "->", "data", "[", "'edulevel'", "]", "=", "self", "::", "LEVEL_OTHER", ";", "$", "this", "->", "context", "=", "$", "PAGE", "->", "context", ";", "}" ]
Set basic properties of the event.
[ "Set", "basic", "properties", "of", "the", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/content_viewed.php#L59-L65
217,498
moodle/moodle
lib/classes/event/content_viewed.php
content_viewed.set_page_detail
public function set_page_detail() { global $PAGE; if (!isset($this->data['other'])) { $this->data['other'] = array(); } $this->data['other'] = array_merge(array('url' => $PAGE->url->out_as_local_url(false), 'heading' => $PAGE->heading, 'title' => $PAGE->title), $this->data['other']); }
php
public function set_page_detail() { global $PAGE; if (!isset($this->data['other'])) { $this->data['other'] = array(); } $this->data['other'] = array_merge(array('url' => $PAGE->url->out_as_local_url(false), 'heading' => $PAGE->heading, 'title' => $PAGE->title), $this->data['other']); }
[ "public", "function", "set_page_detail", "(", ")", "{", "global", "$", "PAGE", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'other'", "]", ")", ")", "{", "$", "this", "->", "data", "[", "'other'", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "data", "[", "'other'", "]", "=", "array_merge", "(", "array", "(", "'url'", "=>", "$", "PAGE", "->", "url", "->", "out_as_local_url", "(", "false", ")", ",", "'heading'", "=>", "$", "PAGE", "->", "heading", ",", "'title'", "=>", "$", "PAGE", "->", "title", ")", ",", "$", "this", "->", "data", "[", "'other'", "]", ")", ";", "}" ]
Set basic page properties.
[ "Set", "basic", "page", "properties", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/content_viewed.php#L70-L78
217,499
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Interaction/Pipeline.php
Horde_Imap_Client_Interaction_Pipeline.add
public function add(Horde_Imap_Client_Interaction_Command $cmd, $top = false) { if ($top) { // This won't re-index keys, which may be numerical. $this->_commands = array($cmd->tag => $cmd) + $this->_commands; } else { $this->_commands[$cmd->tag] = $cmd; } $this->_todo[$cmd->tag] = true; }
php
public function add(Horde_Imap_Client_Interaction_Command $cmd, $top = false) { if ($top) { // This won't re-index keys, which may be numerical. $this->_commands = array($cmd->tag => $cmd) + $this->_commands; } else { $this->_commands[$cmd->tag] = $cmd; } $this->_todo[$cmd->tag] = true; }
[ "public", "function", "add", "(", "Horde_Imap_Client_Interaction_Command", "$", "cmd", ",", "$", "top", "=", "false", ")", "{", "if", "(", "$", "top", ")", "{", "// This won't re-index keys, which may be numerical.", "$", "this", "->", "_commands", "=", "array", "(", "$", "cmd", "->", "tag", "=>", "$", "cmd", ")", "+", "$", "this", "->", "_commands", ";", "}", "else", "{", "$", "this", "->", "_commands", "[", "$", "cmd", "->", "tag", "]", "=", "$", "cmd", ";", "}", "$", "this", "->", "_todo", "[", "$", "cmd", "->", "tag", "]", "=", "true", ";", "}" ]
Add a command to the pipeline. @param Horde_Imap_Client_Interaction_Command $cmd Command object. @param boolean $top Add command to top of queue?
[ "Add", "a", "command", "to", "the", "pipeline", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Interaction/Pipeline.php#L87-L97