id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
219,000
moodle/moodle
admin/tool/dataprivacy/classes/purpose.php
purpose.after_update
protected function after_update($result) { $cache = \cache::make('tool_dataprivacy', 'purpose'); $cache->set($this->get('id'), $this->to_record()); }
php
protected function after_update($result) { $cache = \cache::make('tool_dataprivacy', 'purpose'); $cache->set($this->get('id'), $this->to_record()); }
[ "protected", "function", "after_update", "(", "$", "result", ")", "{", "$", "cache", "=", "\\", "cache", "::", "make", "(", "'tool_dataprivacy'", ",", "'purpose'", ")", ";", "$", "cache", "->", "set", "(", "$", "this", "->", "get", "(", "'id'", ")", ",", "$", "this", "->", "to_record", "(", ")", ")", ";", "}" ]
Updates the cache record. @param bool $result @return null
[ "Updates", "the", "cache", "record", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/purpose.php#L144-L147
219,001
moodle/moodle
mod/workshop/form/numerrors/backup/moodle1/lib.php
moodle1_workshopform_numerrors_handler.on_elements_end
public function on_elements_end() { foreach ($this->mappings as $mapping) { $this->write_xml('workshopform_numerrors_map', $mapping, array('/workshopform_numerrors_map/id')); } foreach ($this->dimensions as $dimension) { $this->write_xml('workshopform_numerrors_dimension', $dimension, array('/workshopform_numerrors_dimension/id')); } }
php
public function on_elements_end() { foreach ($this->mappings as $mapping) { $this->write_xml('workshopform_numerrors_map', $mapping, array('/workshopform_numerrors_map/id')); } foreach ($this->dimensions as $dimension) { $this->write_xml('workshopform_numerrors_dimension', $dimension, array('/workshopform_numerrors_dimension/id')); } }
[ "public", "function", "on_elements_end", "(", ")", "{", "foreach", "(", "$", "this", "->", "mappings", "as", "$", "mapping", ")", "{", "$", "this", "->", "write_xml", "(", "'workshopform_numerrors_map'", ",", "$", "mapping", ",", "array", "(", "'/workshopform_numerrors_map/id'", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "dimensions", "as", "$", "dimension", ")", "{", "$", "this", "->", "write_xml", "(", "'workshopform_numerrors_dimension'", ",", "$", "dimension", ",", "array", "(", "'/workshopform_numerrors_dimension/id'", ")", ")", ";", "}", "}" ]
Writes gathered mappings and dimensions
[ "Writes", "gathered", "mappings", "and", "dimensions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/form/numerrors/backup/moodle1/lib.php#L89-L98
219,002
moodle/moodle
lib/mustache/src/Mustache/HelperCollection.php
Mustache_HelperCollection.get
public function get($name) { if (!$this->has($name)) { throw new Mustache_Exception_UnknownHelperException($name); } return $this->helpers[$name]; }
php
public function get($name) { if (!$this->has($name)) { throw new Mustache_Exception_UnknownHelperException($name); } return $this->helpers[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "Mustache_Exception_UnknownHelperException", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "helpers", "[", "$", "name", "]", ";", "}" ]
Get a helper by name. @throws Mustache_Exception_UnknownHelperException If helper does not exist @param string $name @return mixed Helper
[ "Get", "a", "helper", "by", "name", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/HelperCollection.php#L90-L97
219,003
moodle/moodle
lib/mustache/src/Mustache/HelperCollection.php
Mustache_HelperCollection.remove
public function remove($name) { if (!$this->has($name)) { throw new Mustache_Exception_UnknownHelperException($name); } unset($this->helpers[$name]); }
php
public function remove($name) { if (!$this->has($name)) { throw new Mustache_Exception_UnknownHelperException($name); } unset($this->helpers[$name]); }
[ "public", "function", "remove", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "Mustache_Exception_UnknownHelperException", "(", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "helpers", "[", "$", "name", "]", ")", ";", "}" ]
Check whether a given helper is present in the collection. @throws Mustache_Exception_UnknownHelperException if the requested helper is not present @param string $name
[ "Check", "whether", "a", "given", "helper", "is", "present", "in", "the", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/HelperCollection.php#L144-L151
219,004
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Socket/ClientSort.php
Horde_Imap_Client_Socket_ClientSort._sortString
protected function _sortString(&$sorted) { if (empty($this->_collator)) { asort($sorted, SORT_LOCALE_STRING); } else { $this->_collator->asort($sorted, Collator::SORT_STRING); } }
php
protected function _sortString(&$sorted) { if (empty($this->_collator)) { asort($sorted, SORT_LOCALE_STRING); } else { $this->_collator->asort($sorted, Collator::SORT_STRING); } }
[ "protected", "function", "_sortString", "(", "&", "$", "sorted", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_collator", ")", ")", "{", "asort", "(", "$", "sorted", ",", "SORT_LOCALE_STRING", ")", ";", "}", "else", "{", "$", "this", "->", "_collator", "->", "asort", "(", "$", "sorted", ",", "Collator", "::", "SORT_STRING", ")", ";", "}", "}" ]
Sort an array of strings based on current locale. @param array &$sorted Array of strings.
[ "Sort", "an", "array", "of", "strings", "based", "on", "current", "locale", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Socket/ClientSort.php#L364-L371
219,005
moodle/moodle
lib/mustache/src/Mustache/Context.php
Mustache_Context.findDot
public function findDot($id) { $chunks = explode('.', $id); $first = array_shift($chunks); $value = $this->findVariableInStack($first, $this->stack); foreach ($chunks as $chunk) { if ($value === '') { return $value; } $value = $this->findVariableInStack($chunk, array($value)); } return $value; }
php
public function findDot($id) { $chunks = explode('.', $id); $first = array_shift($chunks); $value = $this->findVariableInStack($first, $this->stack); foreach ($chunks as $chunk) { if ($value === '') { return $value; } $value = $this->findVariableInStack($chunk, array($value)); } return $value; }
[ "public", "function", "findDot", "(", "$", "id", ")", "{", "$", "chunks", "=", "explode", "(", "'.'", ",", "$", "id", ")", ";", "$", "first", "=", "array_shift", "(", "$", "chunks", ")", ";", "$", "value", "=", "$", "this", "->", "findVariableInStack", "(", "$", "first", ",", "$", "this", "->", "stack", ")", ";", "foreach", "(", "$", "chunks", "as", "$", "chunk", ")", "{", "if", "(", "$", "value", "===", "''", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "$", "this", "->", "findVariableInStack", "(", "$", "chunk", ",", "array", "(", "$", "value", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Find a 'dot notation' variable in the Context stack. Note that dot notation traversal bubbles through scope differently than the regular find method. After finding the initial chunk of the dotted name, each subsequent chunk is searched for only within the value of the previous result. For example, given the following context stack: $data = array( 'name' => 'Fred', 'child' => array( 'name' => 'Bob' ), ); ... and the Mustache following template: {{ child.name }} ... the `name` value is only searched for within the `child` value of the global Context, not within parent Context frames. @param string $id Dotted variable selector @return mixed Variable value, or '' if not found
[ "Find", "a", "dot", "notation", "variable", "in", "the", "Context", "stack", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Context.php#L127-L142
219,006
moodle/moodle
lib/mustache/src/Mustache/Context.php
Mustache_Context.findAnchoredDot
public function findAnchoredDot($id) { $chunks = explode('.', $id); $first = array_shift($chunks); if ($first !== '') { throw new Mustache_Exception_InvalidArgumentException(sprintf('Unexpected id for findAnchoredDot: %s', $id)); } $value = $this->last(); foreach ($chunks as $chunk) { if ($value === '') { return $value; } $value = $this->findVariableInStack($chunk, array($value)); } return $value; }
php
public function findAnchoredDot($id) { $chunks = explode('.', $id); $first = array_shift($chunks); if ($first !== '') { throw new Mustache_Exception_InvalidArgumentException(sprintf('Unexpected id for findAnchoredDot: %s', $id)); } $value = $this->last(); foreach ($chunks as $chunk) { if ($value === '') { return $value; } $value = $this->findVariableInStack($chunk, array($value)); } return $value; }
[ "public", "function", "findAnchoredDot", "(", "$", "id", ")", "{", "$", "chunks", "=", "explode", "(", "'.'", ",", "$", "id", ")", ";", "$", "first", "=", "array_shift", "(", "$", "chunks", ")", ";", "if", "(", "$", "first", "!==", "''", ")", "{", "throw", "new", "Mustache_Exception_InvalidArgumentException", "(", "sprintf", "(", "'Unexpected id for findAnchoredDot: %s'", ",", "$", "id", ")", ")", ";", "}", "$", "value", "=", "$", "this", "->", "last", "(", ")", ";", "foreach", "(", "$", "chunks", "as", "$", "chunk", ")", "{", "if", "(", "$", "value", "===", "''", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "$", "this", "->", "findVariableInStack", "(", "$", "chunk", ",", "array", "(", "$", "value", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Find an 'anchored dot notation' variable in the Context stack. This is the same as findDot(), except it looks in the top of the context stack for the first value, rather than searching the whole context stack and starting from there. @see Mustache_Context::findDot @throws Mustache_Exception_InvalidArgumentException if given an invalid anchored dot $id @param string $id Dotted variable selector @return mixed Variable value, or '' if not found
[ "Find", "an", "anchored", "dot", "notation", "variable", "in", "the", "Context", "stack", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Context.php#L159-L178
219,007
moodle/moodle
lib/mustache/src/Mustache/Context.php
Mustache_Context.findInBlock
public function findInBlock($id) { foreach ($this->blockStack as $context) { if (array_key_exists($id, $context)) { return $context[$id]; } } return ''; }
php
public function findInBlock($id) { foreach ($this->blockStack as $context) { if (array_key_exists($id, $context)) { return $context[$id]; } } return ''; }
[ "public", "function", "findInBlock", "(", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "blockStack", "as", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "context", ")", ")", "{", "return", "$", "context", "[", "$", "id", "]", ";", "}", "}", "return", "''", ";", "}" ]
Find an argument in the block context stack. @param string $id @return mixed Variable value, or '' if not found
[ "Find", "an", "argument", "in", "the", "block", "context", "stack", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Context.php#L187-L196
219,008
moodle/moodle
lib/mustache/src/Mustache/Context.php
Mustache_Context.findVariableInStack
private function findVariableInStack($id, array $stack) { for ($i = count($stack) - 1; $i >= 0; $i--) { $frame = &$stack[$i]; switch (gettype($frame)) { case 'object': if (!($frame instanceof Closure)) { // Note that is_callable() *will not work here* // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods if (method_exists($frame, $id)) { return $frame->$id(); } if (isset($frame->$id)) { return $frame->$id; } if ($frame instanceof ArrayAccess && isset($frame[$id])) { return $frame[$id]; } } break; case 'array': if (array_key_exists($id, $frame)) { return $frame[$id]; } break; } } return ''; }
php
private function findVariableInStack($id, array $stack) { for ($i = count($stack) - 1; $i >= 0; $i--) { $frame = &$stack[$i]; switch (gettype($frame)) { case 'object': if (!($frame instanceof Closure)) { // Note that is_callable() *will not work here* // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods if (method_exists($frame, $id)) { return $frame->$id(); } if (isset($frame->$id)) { return $frame->$id; } if ($frame instanceof ArrayAccess && isset($frame[$id])) { return $frame[$id]; } } break; case 'array': if (array_key_exists($id, $frame)) { return $frame[$id]; } break; } } return ''; }
[ "private", "function", "findVariableInStack", "(", "$", "id", ",", "array", "$", "stack", ")", "{", "for", "(", "$", "i", "=", "count", "(", "$", "stack", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "frame", "=", "&", "$", "stack", "[", "$", "i", "]", ";", "switch", "(", "gettype", "(", "$", "frame", ")", ")", "{", "case", "'object'", ":", "if", "(", "!", "(", "$", "frame", "instanceof", "Closure", ")", ")", "{", "// Note that is_callable() *will not work here*", "// See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods", "if", "(", "method_exists", "(", "$", "frame", ",", "$", "id", ")", ")", "{", "return", "$", "frame", "->", "$", "id", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "frame", "->", "$", "id", ")", ")", "{", "return", "$", "frame", "->", "$", "id", ";", "}", "if", "(", "$", "frame", "instanceof", "ArrayAccess", "&&", "isset", "(", "$", "frame", "[", "$", "id", "]", ")", ")", "{", "return", "$", "frame", "[", "$", "id", "]", ";", "}", "}", "break", ";", "case", "'array'", ":", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "frame", ")", ")", "{", "return", "$", "frame", "[", "$", "id", "]", ";", "}", "break", ";", "}", "}", "return", "''", ";", "}" ]
Helper function to find a variable in the Context stack. @see Mustache_Context::find @param string $id Variable name @param array $stack Context stack @return mixed Variable value, or '' if not found
[ "Helper", "function", "to", "find", "a", "variable", "in", "the", "Context", "stack", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Context.php#L208-L241
219,009
moodle/moodle
lib/adodb/drivers/adodb-netezza.inc.php
ADORecordSet_netezza._initrs
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1; $this->_numOfFields = @pg_num_fields($this->_queryID); }
php
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1; $this->_numOfFields = @pg_num_fields($this->_queryID); }
[ "function", "_initrs", "(", ")", "{", "global", "$", "ADODB_COUNTRECS", ";", "$", "this", "->", "_numOfRows", "=", "(", "$", "ADODB_COUNTRECS", ")", "?", "@", "pg_num_rows", "(", "$", "this", "->", "_queryID", ")", ":", "-", "1", ";", "$", "this", "->", "_numOfFields", "=", "@", "pg_num_fields", "(", "$", "this", "->", "_queryID", ")", ";", "}" ]
_initrs modified to disable blob handling
[ "_initrs", "modified", "to", "disable", "blob", "handling" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-netezza.inc.php#L150-L155
219,010
moodle/moodle
lib/phpexcel/PHPExcel/Writer/OpenDocument/Settings.php
PHPExcel_Writer_OpenDocument_Settings.write
public function write(PHPExcel $pPHPExcel = null) { if (!$pPHPExcel) { $pPHPExcel = $this->getParentWriter()->getPHPExcel(); } $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Settings $objWriter->startElement('office:document-settings'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->startElement('office:settings'); $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:view-settings'); $objWriter->startElement('config:config-item-map-indexed'); $objWriter->writeAttribute('config:name', 'Views'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:configuration-settings'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); return $objWriter->getData(); }
php
public function write(PHPExcel $pPHPExcel = null) { if (!$pPHPExcel) { $pPHPExcel = $this->getParentWriter()->getPHPExcel(); } $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Settings $objWriter->startElement('office:document-settings'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->startElement('office:settings'); $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:view-settings'); $objWriter->startElement('config:config-item-map-indexed'); $objWriter->writeAttribute('config:name', 'Views'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:configuration-settings'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); return $objWriter->getData(); }
[ "public", "function", "write", "(", "PHPExcel", "$", "pPHPExcel", "=", "null", ")", "{", "if", "(", "!", "$", "pPHPExcel", ")", "{", "$", "pPHPExcel", "=", "$", "this", "->", "getParentWriter", "(", ")", "->", "getPHPExcel", "(", ")", ";", "}", "$", "objWriter", "=", "null", ";", "if", "(", "$", "this", "->", "getParentWriter", "(", ")", "->", "getUseDiskCaching", "(", ")", ")", "{", "$", "objWriter", "=", "new", "PHPExcel_Shared_XMLWriter", "(", "PHPExcel_Shared_XMLWriter", "::", "STORAGE_DISK", ",", "$", "this", "->", "getParentWriter", "(", ")", "->", "getDiskCachingDirectory", "(", ")", ")", ";", "}", "else", "{", "$", "objWriter", "=", "new", "PHPExcel_Shared_XMLWriter", "(", "PHPExcel_Shared_XMLWriter", "::", "STORAGE_MEMORY", ")", ";", "}", "// XML header", "$", "objWriter", "->", "startDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "// Settings", "$", "objWriter", "->", "startElement", "(", "'office:document-settings'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns:office'", ",", "'urn:oasis:names:tc:opendocument:xmlns:office:1.0'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns:xlink'", ",", "'http://www.w3.org/1999/xlink'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns:config'", ",", "'urn:oasis:names:tc:opendocument:xmlns:config:1.0'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns:ooo'", ",", "'http://openoffice.org/2004/office'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'office:version'", ",", "'1.2'", ")", ";", "$", "objWriter", "->", "startElement", "(", "'office:settings'", ")", ";", "$", "objWriter", "->", "startElement", "(", "'config:config-item-set'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'config:name'", ",", "'ooo:view-settings'", ")", ";", "$", "objWriter", "->", "startElement", "(", "'config:config-item-map-indexed'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'config:name'", ",", "'Views'", ")", ";", "$", "objWriter", "->", "endElement", "(", ")", ";", "$", "objWriter", "->", "endElement", "(", ")", ";", "$", "objWriter", "->", "startElement", "(", "'config:config-item-set'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'config:name'", ",", "'ooo:configuration-settings'", ")", ";", "$", "objWriter", "->", "endElement", "(", ")", ";", "$", "objWriter", "->", "endElement", "(", ")", ";", "$", "objWriter", "->", "endElement", "(", ")", ";", "return", "$", "objWriter", "->", "getData", "(", ")", ";", "}" ]
Write settings.xml to XML format @param PHPExcel $pPHPExcel @return string XML Output @throws PHPExcel_Writer_Exception
[ "Write", "settings", ".", "xml", "to", "XML", "format" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Writer/OpenDocument/Settings.php#L37-L75
219,011
moodle/moodle
lib/classes/task/logging_trait.php
logging_trait.get_trace
protected function get_trace() { if (null === $this->trace) { $this->trace = new \text_progress_trace(); $this->tracestats = new \stdClass(); } return $this->trace; }
php
protected function get_trace() { if (null === $this->trace) { $this->trace = new \text_progress_trace(); $this->tracestats = new \stdClass(); } return $this->trace; }
[ "protected", "function", "get_trace", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "trace", ")", "{", "$", "this", "->", "trace", "=", "new", "\\", "text_progress_trace", "(", ")", ";", "$", "this", "->", "tracestats", "=", "new", "\\", "stdClass", "(", ")", ";", "}", "return", "$", "this", "->", "trace", ";", "}" ]
Get the progress_trace. @return \progress_trace
[ "Get", "the", "progress_trace", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logging_trait.php#L53-L60
219,012
moodle/moodle
lib/classes/task/logging_trait.php
logging_trait.log_start
protected function log_start($message, $depth = 0) { $this->log($message, $depth); if (defined('MDL_PERFTOLOG') && MDL_PERFTOLOG) { $this->tracestats->$depth = [ 'mem' => memory_get_usage(), 'time' => microtime(), ]; } }
php
protected function log_start($message, $depth = 0) { $this->log($message, $depth); if (defined('MDL_PERFTOLOG') && MDL_PERFTOLOG) { $this->tracestats->$depth = [ 'mem' => memory_get_usage(), 'time' => microtime(), ]; } }
[ "protected", "function", "log_start", "(", "$", "message", ",", "$", "depth", "=", "0", ")", "{", "$", "this", "->", "log", "(", "$", "message", ",", "$", "depth", ")", ";", "if", "(", "defined", "(", "'MDL_PERFTOLOG'", ")", "&&", "MDL_PERFTOLOG", ")", "{", "$", "this", "->", "tracestats", "->", "$", "depth", "=", "[", "'mem'", "=>", "memory_get_usage", "(", ")", ",", "'time'", "=>", "microtime", "(", ")", ",", "]", ";", "}", "}" ]
Log a start message to the progress tracer. @param string $message @param int $depth
[ "Log", "a", "start", "message", "to", "the", "progress", "tracer", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logging_trait.php#L79-L88
219,013
moodle/moodle
lib/classes/task/logging_trait.php
logging_trait.log_finish
protected function log_finish($message, $depth = 0) { $this->log($message, $depth); if (isset($this->tracestats->$depth)) { $startstats = $this->tracestats->$depth; $this->log( sprintf("Time taken %s, memory total: %s, Memory growth: %s, Memory peak: %s", microtime_diff($startstats['time'], microtime()), display_size(memory_get_usage()), display_size(memory_get_usage() - $startstats['mem']), display_size(memory_get_peak_usage()) ), $depth + 1 ); } }
php
protected function log_finish($message, $depth = 0) { $this->log($message, $depth); if (isset($this->tracestats->$depth)) { $startstats = $this->tracestats->$depth; $this->log( sprintf("Time taken %s, memory total: %s, Memory growth: %s, Memory peak: %s", microtime_diff($startstats['time'], microtime()), display_size(memory_get_usage()), display_size(memory_get_usage() - $startstats['mem']), display_size(memory_get_peak_usage()) ), $depth + 1 ); } }
[ "protected", "function", "log_finish", "(", "$", "message", ",", "$", "depth", "=", "0", ")", "{", "$", "this", "->", "log", "(", "$", "message", ",", "$", "depth", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "tracestats", "->", "$", "depth", ")", ")", "{", "$", "startstats", "=", "$", "this", "->", "tracestats", "->", "$", "depth", ";", "$", "this", "->", "log", "(", "sprintf", "(", "\"Time taken %s, memory total: %s, Memory growth: %s, Memory peak: %s\"", ",", "microtime_diff", "(", "$", "startstats", "[", "'time'", "]", ",", "microtime", "(", ")", ")", ",", "display_size", "(", "memory_get_usage", "(", ")", ")", ",", "display_size", "(", "memory_get_usage", "(", ")", "-", "$", "startstats", "[", "'mem'", "]", ")", ",", "display_size", "(", "memory_get_peak_usage", "(", ")", ")", ")", ",", "$", "depth", "+", "1", ")", ";", "}", "}" ]
Log an end message to the progress tracer. @param string $message @param int $depth
[ "Log", "an", "end", "message", "to", "the", "progress", "tracer", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logging_trait.php#L96-L111
219,014
moodle/moodle
badges/criteria/award_criteria_activity.php
award_criteria_activity.get_mod_instance
private function get_mod_instance($cmid) { global $DB; $rec = $DB->get_record_sql("SELECT md.name FROM {course_modules} cm, {modules} md WHERE cm.id = ? AND md.id = cm.module", array($cmid)); if ($rec) { return get_coursemodule_from_id($rec->name, $cmid); } else { return null; } }
php
private function get_mod_instance($cmid) { global $DB; $rec = $DB->get_record_sql("SELECT md.name FROM {course_modules} cm, {modules} md WHERE cm.id = ? AND md.id = cm.module", array($cmid)); if ($rec) { return get_coursemodule_from_id($rec->name, $cmid); } else { return null; } }
[ "private", "function", "get_mod_instance", "(", "$", "cmid", ")", "{", "global", "$", "DB", ";", "$", "rec", "=", "$", "DB", "->", "get_record_sql", "(", "\"SELECT md.name\n FROM {course_modules} cm,\n {modules} md\n WHERE cm.id = ? AND\n md.id = cm.module\"", ",", "array", "(", "$", "cmid", ")", ")", ";", "if", "(", "$", "rec", ")", "{", "return", "get_coursemodule_from_id", "(", "$", "rec", "->", "name", ",", "$", "cmid", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets the module instance from the database and returns it. If no module instance exists this function returns false. @return stdClass|bool
[ "Gets", "the", "module", "instance", "from", "the", "database", "and", "returns", "it", ".", "If", "no", "module", "instance", "exists", "this", "function", "returns", "false", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/criteria/award_criteria_activity.php#L66-L79
219,015
moodle/moodle
badges/criteria/award_criteria_activity.php
award_criteria_activity.get_details
public function get_details($short = '') { global $DB, $OUTPUT; $output = array(); foreach ($this->params as $p) { $mod = self::get_mod_instance($p['module']); if (!$mod) { $str = $OUTPUT->error_text(get_string('error:nosuchmod', 'badges')); } else { $str = html_writer::tag('b', '"' . get_string('modulename', $mod->modname) . ' - ' . $mod->name . '"'); if (isset($p['bydate'])) { $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig'))); } } $output[] = $str; } if ($short) { return implode(', ', $output); } else { return html_writer::alist($output, array(), 'ul'); } }
php
public function get_details($short = '') { global $DB, $OUTPUT; $output = array(); foreach ($this->params as $p) { $mod = self::get_mod_instance($p['module']); if (!$mod) { $str = $OUTPUT->error_text(get_string('error:nosuchmod', 'badges')); } else { $str = html_writer::tag('b', '"' . get_string('modulename', $mod->modname) . ' - ' . $mod->name . '"'); if (isset($p['bydate'])) { $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig'))); } } $output[] = $str; } if ($short) { return implode(', ', $output); } else { return html_writer::alist($output, array(), 'ul'); } }
[ "public", "function", "get_details", "(", "$", "short", "=", "''", ")", "{", "global", "$", "DB", ",", "$", "OUTPUT", ";", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "params", "as", "$", "p", ")", "{", "$", "mod", "=", "self", "::", "get_mod_instance", "(", "$", "p", "[", "'module'", "]", ")", ";", "if", "(", "!", "$", "mod", ")", "{", "$", "str", "=", "$", "OUTPUT", "->", "error_text", "(", "get_string", "(", "'error:nosuchmod'", ",", "'badges'", ")", ")", ";", "}", "else", "{", "$", "str", "=", "html_writer", "::", "tag", "(", "'b'", ",", "'\"'", ".", "get_string", "(", "'modulename'", ",", "$", "mod", "->", "modname", ")", ".", "' - '", ".", "$", "mod", "->", "name", ".", "'\"'", ")", ";", "if", "(", "isset", "(", "$", "p", "[", "'bydate'", "]", ")", ")", "{", "$", "str", ".=", "get_string", "(", "'criteria_descr_bydate'", ",", "'badges'", ",", "userdate", "(", "$", "p", "[", "'bydate'", "]", ",", "get_string", "(", "'strftimedate'", ",", "'core_langconfig'", ")", ")", ")", ";", "}", "}", "$", "output", "[", "]", "=", "$", "str", ";", "}", "if", "(", "$", "short", ")", "{", "return", "implode", "(", "', '", ",", "$", "output", ")", ";", "}", "else", "{", "return", "html_writer", "::", "alist", "(", "$", "output", ",", "array", "(", ")", ",", "'ul'", ")", ";", "}", "}" ]
Get criteria description for displaying to users @return string
[ "Get", "criteria", "description", "for", "displaying", "to", "users" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/criteria/award_criteria_activity.php#L86-L107
219,016
moodle/moodle
admin/tool/analytics/classes/clihelper.php
clihelper.list_models
public static function list_models() { cli_heading("List of models"); echo str_pad(get_string('modelid', 'tool_analytics'), 15, ' ') . ' ' . str_pad(get_string('name'), 50, ' ') . ' ' . str_pad(get_string('status'), 15, ' ') . "\n"; $models = \core_analytics\manager::get_all_models(); foreach ($models as $model) { $modelid = $model->get_id(); $isenabled = $model->is_enabled() ? get_string('enabled', 'tool_analytics') : get_string('disabled', 'tool_analytics'); $name = $model->get_name(); echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n"; } }
php
public static function list_models() { cli_heading("List of models"); echo str_pad(get_string('modelid', 'tool_analytics'), 15, ' ') . ' ' . str_pad(get_string('name'), 50, ' ') . ' ' . str_pad(get_string('status'), 15, ' ') . "\n"; $models = \core_analytics\manager::get_all_models(); foreach ($models as $model) { $modelid = $model->get_id(); $isenabled = $model->is_enabled() ? get_string('enabled', 'tool_analytics') : get_string('disabled', 'tool_analytics'); $name = $model->get_name(); echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n"; } }
[ "public", "static", "function", "list_models", "(", ")", "{", "cli_heading", "(", "\"List of models\"", ")", ";", "echo", "str_pad", "(", "get_string", "(", "'modelid'", ",", "'tool_analytics'", ")", ",", "15", ",", "' '", ")", ".", "' '", ".", "str_pad", "(", "get_string", "(", "'name'", ")", ",", "50", ",", "' '", ")", ".", "' '", ".", "str_pad", "(", "get_string", "(", "'status'", ")", ",", "15", ",", "' '", ")", ".", "\"\\n\"", ";", "$", "models", "=", "\\", "core_analytics", "\\", "manager", "::", "get_all_models", "(", ")", ";", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "$", "modelid", "=", "$", "model", "->", "get_id", "(", ")", ";", "$", "isenabled", "=", "$", "model", "->", "is_enabled", "(", ")", "?", "get_string", "(", "'enabled'", ",", "'tool_analytics'", ")", ":", "get_string", "(", "'disabled'", ",", "'tool_analytics'", ")", ";", "$", "name", "=", "$", "model", "->", "get_name", "(", ")", ";", "echo", "str_pad", "(", "$", "modelid", ",", "15", ",", "' '", ")", ".", "' '", ".", "str_pad", "(", "$", "name", ",", "50", ",", "' '", ")", ".", "' '", ".", "str_pad", "(", "$", "isenabled", ",", "15", ",", "' '", ")", ".", "\"\\n\"", ";", "}", "}" ]
List all models in the system. To be used from cli scripts. @return void
[ "List", "all", "models", "in", "the", "system", ".", "To", "be", "used", "from", "cli", "scripts", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/analytics/classes/clihelper.php#L43-L54
219,017
moodle/moodle
competency/classes/course_competency.php
course_competency.get_courses_with_competency_and_user
public static function get_courses_with_competency_and_user($competencyid, $userid) { global $CFG, $DB; if (!$plugins = explode(',', $CFG->enrol_plugins_enabled)) { return array(); } $ctxfields = \context_helper::get_preload_record_columns_sql('ctx'); list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee'); $params['competencyid'] = $competencyid; $params['userid'] = $userid; $params['enabled'] = ENROL_INSTANCE_ENABLED; $params['active'] = ENROL_USER_ACTIVE; $params['contextlevel'] = CONTEXT_COURSE; // Heavily based on enrol_get_shared_courses(). $sql = "SELECT c.*, $ctxfields FROM {course} c JOIN {" . static::TABLE . "} cc ON cc.courseid = c.id AND cc.competencyid = :competencyid JOIN ( SELECT DISTINCT c.id FROM {enrol} e JOIN {user_enrolments} ue ON ue.enrolid = e.id AND ue.status = :active AND ue.userid = :userid JOIN {course} c ON c.id = e.courseid WHERE e.status = :enabled AND e.enrol $plugins ) ec ON ec.id = c.id LEFT JOIN {context} ctx ON ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel ORDER BY c.id"; $courses = $DB->get_records_sql($sql, $params); array_map('context_helper::preload_from_record', $courses); return $courses; }
php
public static function get_courses_with_competency_and_user($competencyid, $userid) { global $CFG, $DB; if (!$plugins = explode(',', $CFG->enrol_plugins_enabled)) { return array(); } $ctxfields = \context_helper::get_preload_record_columns_sql('ctx'); list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee'); $params['competencyid'] = $competencyid; $params['userid'] = $userid; $params['enabled'] = ENROL_INSTANCE_ENABLED; $params['active'] = ENROL_USER_ACTIVE; $params['contextlevel'] = CONTEXT_COURSE; // Heavily based on enrol_get_shared_courses(). $sql = "SELECT c.*, $ctxfields FROM {course} c JOIN {" . static::TABLE . "} cc ON cc.courseid = c.id AND cc.competencyid = :competencyid JOIN ( SELECT DISTINCT c.id FROM {enrol} e JOIN {user_enrolments} ue ON ue.enrolid = e.id AND ue.status = :active AND ue.userid = :userid JOIN {course} c ON c.id = e.courseid WHERE e.status = :enabled AND e.enrol $plugins ) ec ON ec.id = c.id LEFT JOIN {context} ctx ON ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel ORDER BY c.id"; $courses = $DB->get_records_sql($sql, $params); array_map('context_helper::preload_from_record', $courses); return $courses; }
[ "public", "static", "function", "get_courses_with_competency_and_user", "(", "$", "competencyid", ",", "$", "userid", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "if", "(", "!", "$", "plugins", "=", "explode", "(", "','", ",", "$", "CFG", "->", "enrol_plugins_enabled", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "ctxfields", "=", "\\", "context_helper", "::", "get_preload_record_columns_sql", "(", "'ctx'", ")", ";", "list", "(", "$", "plugins", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "plugins", ",", "SQL_PARAMS_NAMED", ",", "'ee'", ")", ";", "$", "params", "[", "'competencyid'", "]", "=", "$", "competencyid", ";", "$", "params", "[", "'userid'", "]", "=", "$", "userid", ";", "$", "params", "[", "'enabled'", "]", "=", "ENROL_INSTANCE_ENABLED", ";", "$", "params", "[", "'active'", "]", "=", "ENROL_USER_ACTIVE", ";", "$", "params", "[", "'contextlevel'", "]", "=", "CONTEXT_COURSE", ";", "// Heavily based on enrol_get_shared_courses().", "$", "sql", "=", "\"SELECT c.*, $ctxfields\n FROM {course} c\n JOIN {\"", ".", "static", "::", "TABLE", ".", "\"} cc\n ON cc.courseid = c.id\n AND cc.competencyid = :competencyid\n JOIN (\n SELECT DISTINCT c.id\n FROM {enrol} e\n JOIN {user_enrolments} ue\n ON ue.enrolid = e.id\n AND ue.status = :active\n AND ue.userid = :userid\n JOIN {course} c\n ON c.id = e.courseid\n WHERE e.status = :enabled\n AND e.enrol $plugins\n ) ec ON ec.id = c.id\n LEFT JOIN {context} ctx\n ON ctx.instanceid = c.id\n AND ctx.contextlevel = :contextlevel\n ORDER BY c.id\"", ";", "$", "courses", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "array_map", "(", "'context_helper::preload_from_record'", ",", "$", "courses", ")", ";", "return", "$", "courses", ";", "}" ]
Return the courses where both competency and user are. A user is considered being in a course when they are enrolled, the enrolment is valid, the enrolment instance is enabled, and the enrolment plugin is enabled.. @param int $competencyid The competency ID. @param int $userid The user ID. @return array Indexed by course ID.
[ "Return", "the", "courses", "where", "both", "competency", "and", "user", "are", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L99-L140
219,018
moodle/moodle
competency/classes/course_competency.php
course_competency.get_ruleoutcome_list
public static function get_ruleoutcome_list() { static $list = null; if ($list === null) { $list = array( self::OUTCOME_NONE => self::get_ruleoutcome_name(self::OUTCOME_NONE), self::OUTCOME_EVIDENCE => self::get_ruleoutcome_name(self::OUTCOME_EVIDENCE), self::OUTCOME_RECOMMEND => self::get_ruleoutcome_name(self::OUTCOME_RECOMMEND), self::OUTCOME_COMPLETE => self::get_ruleoutcome_name(self::OUTCOME_COMPLETE)); } return $list; }
php
public static function get_ruleoutcome_list() { static $list = null; if ($list === null) { $list = array( self::OUTCOME_NONE => self::get_ruleoutcome_name(self::OUTCOME_NONE), self::OUTCOME_EVIDENCE => self::get_ruleoutcome_name(self::OUTCOME_EVIDENCE), self::OUTCOME_RECOMMEND => self::get_ruleoutcome_name(self::OUTCOME_RECOMMEND), self::OUTCOME_COMPLETE => self::get_ruleoutcome_name(self::OUTCOME_COMPLETE)); } return $list; }
[ "public", "static", "function", "get_ruleoutcome_list", "(", ")", "{", "static", "$", "list", "=", "null", ";", "if", "(", "$", "list", "===", "null", ")", "{", "$", "list", "=", "array", "(", "self", "::", "OUTCOME_NONE", "=>", "self", "::", "get_ruleoutcome_name", "(", "self", "::", "OUTCOME_NONE", ")", ",", "self", "::", "OUTCOME_EVIDENCE", "=>", "self", "::", "get_ruleoutcome_name", "(", "self", "::", "OUTCOME_EVIDENCE", ")", ",", "self", "::", "OUTCOME_RECOMMEND", "=>", "self", "::", "get_ruleoutcome_name", "(", "self", "::", "OUTCOME_RECOMMEND", ")", ",", "self", "::", "OUTCOME_COMPLETE", "=>", "self", "::", "get_ruleoutcome_name", "(", "self", "::", "OUTCOME_COMPLETE", ")", ")", ";", "}", "return", "$", "list", ";", "}" ]
Return a list of rules. @return array Indexed by outcome value.
[ "Return", "a", "list", "of", "rules", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L147-L159
219,019
moodle/moodle
competency/classes/course_competency.php
course_competency.list_courses_min
public static function list_courses_min($competencyid) { global $DB; $results = $DB->get_records_sql('SELECT course.id as id, course.visible as visible FROM {' . self::TABLE . '} coursecomp JOIN {course} course ON coursecomp.courseid = course.id WHERE coursecomp.competencyid = ? ', array($competencyid)); return $results; }
php
public static function list_courses_min($competencyid) { global $DB; $results = $DB->get_records_sql('SELECT course.id as id, course.visible as visible FROM {' . self::TABLE . '} coursecomp JOIN {course} course ON coursecomp.courseid = course.id WHERE coursecomp.competencyid = ? ', array($competencyid)); return $results; }
[ "public", "static", "function", "list_courses_min", "(", "$", "competencyid", ")", "{", "global", "$", "DB", ";", "$", "results", "=", "$", "DB", "->", "get_records_sql", "(", "'SELECT course.id as id, course.visible as visible\n FROM {'", ".", "self", "::", "TABLE", ".", "'} coursecomp\n JOIN {course} course\n ON coursecomp.courseid = course.id\n WHERE coursecomp.competencyid = ? '", ",", "array", "(", "$", "competencyid", ")", ")", ";", "return", "$", "results", ";", "}" ]
Return the course IDs and visible flags that include this competency. Only the ids and visible flag are returned, for the full records use list_courses. @param int $competencyid The competency id @return array containing courseid and visible.
[ "Return", "the", "course", "IDs", "and", "visible", "flags", "that", "include", "this", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L225-L235
219,020
moodle/moodle
competency/classes/course_competency.php
course_competency.list_courses
public static function list_courses($competencyid) { global $DB; $results = $DB->get_records_sql('SELECT course.id, course.visible, course.shortname, course.idnumber, course.fullname, course.summary, course.summaryformat, course.startdate, course.enddate, course.category FROM {course} course JOIN {' . self::TABLE . '} coursecomp ON coursecomp.courseid = course.id WHERE coursecomp.competencyid = ? ', array($competencyid)); return $results; }
php
public static function list_courses($competencyid) { global $DB; $results = $DB->get_records_sql('SELECT course.id, course.visible, course.shortname, course.idnumber, course.fullname, course.summary, course.summaryformat, course.startdate, course.enddate, course.category FROM {course} course JOIN {' . self::TABLE . '} coursecomp ON coursecomp.courseid = course.id WHERE coursecomp.competencyid = ? ', array($competencyid)); return $results; }
[ "public", "static", "function", "list_courses", "(", "$", "competencyid", ")", "{", "global", "$", "DB", ";", "$", "results", "=", "$", "DB", "->", "get_records_sql", "(", "'SELECT course.id, course.visible, course.shortname, course.idnumber,\n course.fullname, course.summary, course.summaryformat, course.startdate,\n course.enddate, course.category\n FROM {course} course\n JOIN {'", ".", "self", "::", "TABLE", ".", "'} coursecomp\n ON coursecomp.courseid = course.id\n WHERE coursecomp.competencyid = ? '", ",", "array", "(", "$", "competencyid", ")", ")", ";", "return", "$", "results", ";", "}" ]
Return partial course records foreach course that contains this competency. @param int $competencyid The competency id @return array[stdClass] Array of course records containg id, visible, shortname, idnumber, fullname
[ "Return", "partial", "course", "records", "foreach", "course", "that", "contains", "this", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L243-L255
219,021
moodle/moodle
competency/classes/course_competency.php
course_competency.count_competencies
public static function count_competencies($courseid) { global $DB; $sql = 'SELECT COUNT(comp.id) FROM {' . self::TABLE . '} coursecomp JOIN {' . competency::TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ? '; $params = array($courseid); $results = $DB->count_records_sql($sql, $params); return $results; }
php
public static function count_competencies($courseid) { global $DB; $sql = 'SELECT COUNT(comp.id) FROM {' . self::TABLE . '} coursecomp JOIN {' . competency::TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ? '; $params = array($courseid); $results = $DB->count_records_sql($sql, $params); return $results; }
[ "public", "static", "function", "count_competencies", "(", "$", "courseid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "'SELECT COUNT(comp.id)\n FROM {'", ".", "self", "::", "TABLE", ".", "'} coursecomp\n JOIN {'", ".", "competency", "::", "TABLE", ".", "'} comp\n ON coursecomp.competencyid = comp.id\n WHERE coursecomp.courseid = ? '", ";", "$", "params", "=", "array", "(", "$", "courseid", ")", ";", "$", "results", "=", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "return", "$", "results", ";", "}" ]
Count the competencies in this course. @param int $courseid The course id @return int
[ "Count", "the", "competencies", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L263-L276
219,022
moodle/moodle
competency/classes/course_competency.php
course_competency.list_competencies
public static function list_competencies($courseid) { global $DB; $sql = 'SELECT comp.* FROM {' . competency::TABLE . '} comp JOIN {' . self::TABLE . '} coursecomp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ?'; $params = array($courseid); $sql .= ' ORDER BY coursecomp.sortorder ASC'; $results = $DB->get_recordset_sql($sql, $params); $instances = array(); foreach ($results as $result) { $comp = new competency(0, $result); $instances[$comp->get('id')] = $comp; } $results->close(); return $instances; }
php
public static function list_competencies($courseid) { global $DB; $sql = 'SELECT comp.* FROM {' . competency::TABLE . '} comp JOIN {' . self::TABLE . '} coursecomp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ?'; $params = array($courseid); $sql .= ' ORDER BY coursecomp.sortorder ASC'; $results = $DB->get_recordset_sql($sql, $params); $instances = array(); foreach ($results as $result) { $comp = new competency(0, $result); $instances[$comp->get('id')] = $comp; } $results->close(); return $instances; }
[ "public", "static", "function", "list_competencies", "(", "$", "courseid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "'SELECT comp.*\n FROM {'", ".", "competency", "::", "TABLE", ".", "'} comp\n JOIN {'", ".", "self", "::", "TABLE", ".", "'} coursecomp\n ON coursecomp.competencyid = comp.id\n WHERE coursecomp.courseid = ?'", ";", "$", "params", "=", "array", "(", "$", "courseid", ")", ";", "$", "sql", ".=", "' ORDER BY coursecomp.sortorder ASC'", ";", "$", "results", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "instances", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "comp", "=", "new", "competency", "(", "0", ",", "$", "result", ")", ";", "$", "instances", "[", "$", "comp", "->", "get", "(", "'id'", ")", "]", "=", "$", "comp", ";", "}", "$", "results", "->", "close", "(", ")", ";", "return", "$", "instances", ";", "}" ]
List the competencies in this course. @param int $courseid The course id @return competency[] Indexed by competency ID.
[ "List", "the", "competencies", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L284-L304
219,023
moodle/moodle
competency/classes/course_competency.php
course_competency.get_course_competency
public static function get_course_competency($courseid, $competencyid) { global $DB; $sql = 'SELECT crscomp.* FROM {' . self::TABLE . '} crscomp WHERE crscomp.courseid = ? AND crscomp.competencyid = ?'; $params = array($courseid, $competencyid); $result = $DB->get_record_sql($sql, $params); if (!$result) { throw new coding_exception('The competency does not belong to this course: ' . $competencyid . ', ' . $courseid); } return new course_competency(0, $result); }
php
public static function get_course_competency($courseid, $competencyid) { global $DB; $sql = 'SELECT crscomp.* FROM {' . self::TABLE . '} crscomp WHERE crscomp.courseid = ? AND crscomp.competencyid = ?'; $params = array($courseid, $competencyid); $result = $DB->get_record_sql($sql, $params); if (!$result) { throw new coding_exception('The competency does not belong to this course: ' . $competencyid . ', ' . $courseid); } return new course_competency(0, $result); }
[ "public", "static", "function", "get_course_competency", "(", "$", "courseid", ",", "$", "competencyid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "'SELECT crscomp.*\n FROM {'", ".", "self", "::", "TABLE", ".", "'} crscomp\n WHERE crscomp.courseid = ? AND crscomp.competencyid = ?'", ";", "$", "params", "=", "array", "(", "$", "courseid", ",", "$", "competencyid", ")", ";", "$", "result", "=", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "coding_exception", "(", "'The competency does not belong to this course: '", ".", "$", "competencyid", ".", "', '", ".", "$", "courseid", ")", ";", "}", "return", "new", "course_competency", "(", "0", ",", "$", "result", ")", ";", "}" ]
Get the specified course_competency in this course. @param int $courseid The course id @param int $competencyid The competency id @return course_competency
[ "Get", "the", "specified", "course_competency", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L355-L369
219,024
moodle/moodle
competency/classes/course_competency.php
course_competency.list_course_competencies
public static function list_course_competencies($courseid) { global $DB; $sql = 'SELECT coursecomp.* FROM {' . self::TABLE . '} coursecomp JOIN {' . competency::TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ?'; $params = array($courseid); $sql .= ' ORDER BY coursecomp.sortorder ASC'; $results = $DB->get_recordset_sql($sql, $params); $instances = array(); foreach ($results as $result) { array_push($instances, new course_competency(0, $result)); } $results->close(); return $instances; }
php
public static function list_course_competencies($courseid) { global $DB; $sql = 'SELECT coursecomp.* FROM {' . self::TABLE . '} coursecomp JOIN {' . competency::TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ?'; $params = array($courseid); $sql .= ' ORDER BY coursecomp.sortorder ASC'; $results = $DB->get_recordset_sql($sql, $params); $instances = array(); foreach ($results as $result) { array_push($instances, new course_competency(0, $result)); } $results->close(); return $instances; }
[ "public", "static", "function", "list_course_competencies", "(", "$", "courseid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "'SELECT coursecomp.*\n FROM {'", ".", "self", "::", "TABLE", ".", "'} coursecomp\n JOIN {'", ".", "competency", "::", "TABLE", ".", "'} comp\n ON coursecomp.competencyid = comp.id\n WHERE coursecomp.courseid = ?'", ";", "$", "params", "=", "array", "(", "$", "courseid", ")", ";", "$", "sql", ".=", "' ORDER BY coursecomp.sortorder ASC'", ";", "$", "results", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "instances", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "array_push", "(", "$", "instances", ",", "new", "course_competency", "(", "0", ",", "$", "result", ")", ")", ";", "}", "$", "results", "->", "close", "(", ")", ";", "return", "$", "instances", ";", "}" ]
List the course_competencies in this course. @param int $courseid The course id @return course_competency[]
[ "List", "the", "course_competencies", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/course_competency.php#L377-L396
219,025
moodle/moodle
backup/util/plan/backup_structure_step.class.php
backup_structure_step.add_plugin_structure
protected function add_plugin_structure($plugintype, $element, $multiple) { global $CFG; // Check the requested plugintype is a valid one if (!array_key_exists($plugintype, core_component::get_plugin_types($plugintype))) { throw new backup_step_exception('incorrect_plugin_type', $plugintype); } // Arrived here, plugin is correct, let's create the optigroup $optigroupname = $plugintype . '_' . $element->get_name() . '_plugin'; $optigroup = new backup_optigroup($optigroupname, null, $multiple); $element->add_child($optigroup); // Add optigroup to stay connected since beginning // Get all the optigroup_elements, looking across all the plugin dirs $pluginsdirs = core_component::get_plugin_list($plugintype); foreach ($pluginsdirs as $name => $plugindir) { $classname = 'backup_' . $plugintype . '_' . $name . '_plugin'; $backupfile = $plugindir . '/backup/moodle2/' . $classname . '.class.php'; if (file_exists($backupfile)) { require_once($backupfile); $backupplugin = new $classname($plugintype, $name, $optigroup, $this); // Add plugin returned structure to optigroup $backupplugin->define_plugin_structure($element->get_name()); } } }
php
protected function add_plugin_structure($plugintype, $element, $multiple) { global $CFG; // Check the requested plugintype is a valid one if (!array_key_exists($plugintype, core_component::get_plugin_types($plugintype))) { throw new backup_step_exception('incorrect_plugin_type', $plugintype); } // Arrived here, plugin is correct, let's create the optigroup $optigroupname = $plugintype . '_' . $element->get_name() . '_plugin'; $optigroup = new backup_optigroup($optigroupname, null, $multiple); $element->add_child($optigroup); // Add optigroup to stay connected since beginning // Get all the optigroup_elements, looking across all the plugin dirs $pluginsdirs = core_component::get_plugin_list($plugintype); foreach ($pluginsdirs as $name => $plugindir) { $classname = 'backup_' . $plugintype . '_' . $name . '_plugin'; $backupfile = $plugindir . '/backup/moodle2/' . $classname . '.class.php'; if (file_exists($backupfile)) { require_once($backupfile); $backupplugin = new $classname($plugintype, $name, $optigroup, $this); // Add plugin returned structure to optigroup $backupplugin->define_plugin_structure($element->get_name()); } } }
[ "protected", "function", "add_plugin_structure", "(", "$", "plugintype", ",", "$", "element", ",", "$", "multiple", ")", "{", "global", "$", "CFG", ";", "// Check the requested plugintype is a valid one", "if", "(", "!", "array_key_exists", "(", "$", "plugintype", ",", "core_component", "::", "get_plugin_types", "(", "$", "plugintype", ")", ")", ")", "{", "throw", "new", "backup_step_exception", "(", "'incorrect_plugin_type'", ",", "$", "plugintype", ")", ";", "}", "// Arrived here, plugin is correct, let's create the optigroup", "$", "optigroupname", "=", "$", "plugintype", ".", "'_'", ".", "$", "element", "->", "get_name", "(", ")", ".", "'_plugin'", ";", "$", "optigroup", "=", "new", "backup_optigroup", "(", "$", "optigroupname", ",", "null", ",", "$", "multiple", ")", ";", "$", "element", "->", "add_child", "(", "$", "optigroup", ")", ";", "// Add optigroup to stay connected since beginning", "// Get all the optigroup_elements, looking across all the plugin dirs", "$", "pluginsdirs", "=", "core_component", "::", "get_plugin_list", "(", "$", "plugintype", ")", ";", "foreach", "(", "$", "pluginsdirs", "as", "$", "name", "=>", "$", "plugindir", ")", "{", "$", "classname", "=", "'backup_'", ".", "$", "plugintype", ".", "'_'", ".", "$", "name", ".", "'_plugin'", ";", "$", "backupfile", "=", "$", "plugindir", ".", "'/backup/moodle2/'", ".", "$", "classname", ".", "'.class.php'", ";", "if", "(", "file_exists", "(", "$", "backupfile", ")", ")", "{", "require_once", "(", "$", "backupfile", ")", ";", "$", "backupplugin", "=", "new", "$", "classname", "(", "$", "plugintype", ",", "$", "name", ",", "$", "optigroup", ",", "$", "this", ")", ";", "// Add plugin returned structure to optigroup", "$", "backupplugin", "->", "define_plugin_structure", "(", "$", "element", "->", "get_name", "(", ")", ")", ";", "}", "}", "}" ]
Add plugin structure to any element in the structure backup tree @param string $plugintype type of plugin as defined by core_component::get_plugin_types() @param backup_nested_element $element element in the structure backup tree that we are going to add plugin information to @param bool $multiple to define if multiple plugins can produce information for each instance of $element (true) or no (false)
[ "Add", "plugin", "structure", "to", "any", "element", "in", "the", "structure", "backup", "tree" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/plan/backup_structure_step.class.php#L137-L163
219,026
moodle/moodle
backup/util/plan/backup_structure_step.class.php
backup_structure_step.add_subplugin_structure
protected function add_subplugin_structure($subplugintype, $element, $multiple, $plugintype = null, $pluginname = null) { global $CFG; // This global declaration is required, because where we do require_once($backupfile); // That file may in turn try to do require_once($CFG->dirroot ...). // That worked in the past, we should keep it working. // Verify if this is a BC call for an activity backup. See NOTE above for this special case. if ($plugintype === null and $pluginname === null) { $plugintype = 'mod'; $pluginname = $this->task->get_modulename(); // TODO: Once all the calls have been changed to add both not null plugintype and pluginname, add a debugging here. } // Check the requested plugintype is a valid one. if (!array_key_exists($plugintype, core_component::get_plugin_types())) { throw new backup_step_exception('incorrect_plugin_type', $plugintype); } // Check the requested pluginname, for the specified plugintype, is a valid one. if (!array_key_exists($pluginname, core_component::get_plugin_list($plugintype))) { throw new backup_step_exception('incorrect_plugin_name', array($plugintype, $pluginname)); } // Check the requested subplugintype is a valid one. $subpluginsfile = core_component::get_component_directory($plugintype . '_' . $pluginname) . '/db/subplugins.php'; if (!file_exists($subpluginsfile)) { throw new backup_step_exception('plugin_missing_subplugins_php_file', array($plugintype, $pluginname)); } include($subpluginsfile); if (!array_key_exists($subplugintype, $subplugins)) { throw new backup_step_exception('incorrect_subplugin_type', $subplugintype); } // Arrived here, subplugin is correct, let's create the optigroup. $optigroupname = $subplugintype . '_' . $element->get_name() . '_subplugin'; $optigroup = new backup_optigroup($optigroupname, null, $multiple); $element->add_child($optigroup); // Add optigroup to stay connected since beginning. // Every subplugin optionally can have a common/parent subplugin // class for shared stuff. $parentclass = 'backup_' . $plugintype . '_' . $pluginname . '_' . $subplugintype . '_subplugin'; $parentfile = core_component::get_component_directory($plugintype . '_' . $pluginname) . '/backup/moodle2/' . $parentclass . '.class.php'; if (file_exists($parentfile)) { require_once($parentfile); } // Get all the optigroup_elements, looking over all the subplugin dirs. $subpluginsdirs = core_component::get_plugin_list($subplugintype); foreach ($subpluginsdirs as $name => $subpluginsdir) { $classname = 'backup_' . $subplugintype . '_' . $name . '_subplugin'; $backupfile = $subpluginsdir . '/backup/moodle2/' . $classname . '.class.php'; if (file_exists($backupfile)) { require_once($backupfile); $backupsubplugin = new $classname($subplugintype, $name, $optigroup, $this); // Add subplugin returned structure to optigroup. $backupsubplugin->define_subplugin_structure($element->get_name()); } } }
php
protected function add_subplugin_structure($subplugintype, $element, $multiple, $plugintype = null, $pluginname = null) { global $CFG; // This global declaration is required, because where we do require_once($backupfile); // That file may in turn try to do require_once($CFG->dirroot ...). // That worked in the past, we should keep it working. // Verify if this is a BC call for an activity backup. See NOTE above for this special case. if ($plugintype === null and $pluginname === null) { $plugintype = 'mod'; $pluginname = $this->task->get_modulename(); // TODO: Once all the calls have been changed to add both not null plugintype and pluginname, add a debugging here. } // Check the requested plugintype is a valid one. if (!array_key_exists($plugintype, core_component::get_plugin_types())) { throw new backup_step_exception('incorrect_plugin_type', $plugintype); } // Check the requested pluginname, for the specified plugintype, is a valid one. if (!array_key_exists($pluginname, core_component::get_plugin_list($plugintype))) { throw new backup_step_exception('incorrect_plugin_name', array($plugintype, $pluginname)); } // Check the requested subplugintype is a valid one. $subpluginsfile = core_component::get_component_directory($plugintype . '_' . $pluginname) . '/db/subplugins.php'; if (!file_exists($subpluginsfile)) { throw new backup_step_exception('plugin_missing_subplugins_php_file', array($plugintype, $pluginname)); } include($subpluginsfile); if (!array_key_exists($subplugintype, $subplugins)) { throw new backup_step_exception('incorrect_subplugin_type', $subplugintype); } // Arrived here, subplugin is correct, let's create the optigroup. $optigroupname = $subplugintype . '_' . $element->get_name() . '_subplugin'; $optigroup = new backup_optigroup($optigroupname, null, $multiple); $element->add_child($optigroup); // Add optigroup to stay connected since beginning. // Every subplugin optionally can have a common/parent subplugin // class for shared stuff. $parentclass = 'backup_' . $plugintype . '_' . $pluginname . '_' . $subplugintype . '_subplugin'; $parentfile = core_component::get_component_directory($plugintype . '_' . $pluginname) . '/backup/moodle2/' . $parentclass . '.class.php'; if (file_exists($parentfile)) { require_once($parentfile); } // Get all the optigroup_elements, looking over all the subplugin dirs. $subpluginsdirs = core_component::get_plugin_list($subplugintype); foreach ($subpluginsdirs as $name => $subpluginsdir) { $classname = 'backup_' . $subplugintype . '_' . $name . '_subplugin'; $backupfile = $subpluginsdir . '/backup/moodle2/' . $classname . '.class.php'; if (file_exists($backupfile)) { require_once($backupfile); $backupsubplugin = new $classname($subplugintype, $name, $optigroup, $this); // Add subplugin returned structure to optigroup. $backupsubplugin->define_subplugin_structure($element->get_name()); } } }
[ "protected", "function", "add_subplugin_structure", "(", "$", "subplugintype", ",", "$", "element", ",", "$", "multiple", ",", "$", "plugintype", "=", "null", ",", "$", "pluginname", "=", "null", ")", "{", "global", "$", "CFG", ";", "// This global declaration is required, because where we do require_once($backupfile);", "// That file may in turn try to do require_once($CFG->dirroot ...).", "// That worked in the past, we should keep it working.", "// Verify if this is a BC call for an activity backup. See NOTE above for this special case.", "if", "(", "$", "plugintype", "===", "null", "and", "$", "pluginname", "===", "null", ")", "{", "$", "plugintype", "=", "'mod'", ";", "$", "pluginname", "=", "$", "this", "->", "task", "->", "get_modulename", "(", ")", ";", "// TODO: Once all the calls have been changed to add both not null plugintype and pluginname, add a debugging here.", "}", "// Check the requested plugintype is a valid one.", "if", "(", "!", "array_key_exists", "(", "$", "plugintype", ",", "core_component", "::", "get_plugin_types", "(", ")", ")", ")", "{", "throw", "new", "backup_step_exception", "(", "'incorrect_plugin_type'", ",", "$", "plugintype", ")", ";", "}", "// Check the requested pluginname, for the specified plugintype, is a valid one.", "if", "(", "!", "array_key_exists", "(", "$", "pluginname", ",", "core_component", "::", "get_plugin_list", "(", "$", "plugintype", ")", ")", ")", "{", "throw", "new", "backup_step_exception", "(", "'incorrect_plugin_name'", ",", "array", "(", "$", "plugintype", ",", "$", "pluginname", ")", ")", ";", "}", "// Check the requested subplugintype is a valid one.", "$", "subpluginsfile", "=", "core_component", "::", "get_component_directory", "(", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ")", ".", "'/db/subplugins.php'", ";", "if", "(", "!", "file_exists", "(", "$", "subpluginsfile", ")", ")", "{", "throw", "new", "backup_step_exception", "(", "'plugin_missing_subplugins_php_file'", ",", "array", "(", "$", "plugintype", ",", "$", "pluginname", ")", ")", ";", "}", "include", "(", "$", "subpluginsfile", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "subplugintype", ",", "$", "subplugins", ")", ")", "{", "throw", "new", "backup_step_exception", "(", "'incorrect_subplugin_type'", ",", "$", "subplugintype", ")", ";", "}", "// Arrived here, subplugin is correct, let's create the optigroup.", "$", "optigroupname", "=", "$", "subplugintype", ".", "'_'", ".", "$", "element", "->", "get_name", "(", ")", ".", "'_subplugin'", ";", "$", "optigroup", "=", "new", "backup_optigroup", "(", "$", "optigroupname", ",", "null", ",", "$", "multiple", ")", ";", "$", "element", "->", "add_child", "(", "$", "optigroup", ")", ";", "// Add optigroup to stay connected since beginning.", "// Every subplugin optionally can have a common/parent subplugin", "// class for shared stuff.", "$", "parentclass", "=", "'backup_'", ".", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ".", "'_'", ".", "$", "subplugintype", ".", "'_subplugin'", ";", "$", "parentfile", "=", "core_component", "::", "get_component_directory", "(", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ")", ".", "'/backup/moodle2/'", ".", "$", "parentclass", ".", "'.class.php'", ";", "if", "(", "file_exists", "(", "$", "parentfile", ")", ")", "{", "require_once", "(", "$", "parentfile", ")", ";", "}", "// Get all the optigroup_elements, looking over all the subplugin dirs.", "$", "subpluginsdirs", "=", "core_component", "::", "get_plugin_list", "(", "$", "subplugintype", ")", ";", "foreach", "(", "$", "subpluginsdirs", "as", "$", "name", "=>", "$", "subpluginsdir", ")", "{", "$", "classname", "=", "'backup_'", ".", "$", "subplugintype", ".", "'_'", ".", "$", "name", ".", "'_subplugin'", ";", "$", "backupfile", "=", "$", "subpluginsdir", ".", "'/backup/moodle2/'", ".", "$", "classname", ".", "'.class.php'", ";", "if", "(", "file_exists", "(", "$", "backupfile", ")", ")", "{", "require_once", "(", "$", "backupfile", ")", ";", "$", "backupsubplugin", "=", "new", "$", "classname", "(", "$", "subplugintype", ",", "$", "name", ",", "$", "optigroup", ",", "$", "this", ")", ";", "// Add subplugin returned structure to optigroup.", "$", "backupsubplugin", "->", "define_subplugin_structure", "(", "$", "element", "->", "get_name", "(", ")", ")", ";", "}", "}", "}" ]
Add subplugin structure for a given plugin to any element in the structure backup tree. This method allows the injection of subplugins (of a specified plugin) data to any element in any backup structure. NOTE: Initially subplugins were only available for activities (mod), so only the {@link backup_activity_structure_step} class had support for them, always looking for /mod/modulenanme subplugins. This new method is a generalization of the existing one for activities, supporting all subplugins injecting information everywhere. @param string $subplugintype type of subplugin as defined in plugin's db/subplugins.php. @param backup_nested_element $element element in the backup tree (anywhere) that we are going to add subplugin information to. @param bool $multiple to define if multiple subplugins can produce information for each instance of $element (true) or no (false). @param string $plugintype type of the plugin. @param string $pluginname name of the plugin. @return void
[ "Add", "subplugin", "structure", "for", "a", "given", "plugin", "to", "any", "element", "in", "the", "structure", "backup", "tree", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/plan/backup_structure_step.class.php#L185-L244
219,027
moodle/moodle
analytics/classes/local/time_splitting/periodic.php
periodic.get_training_ranges
public function get_training_ranges() { // Cloning the array. $trainingranges = $this->ranges; foreach ($trainingranges as $rangeindex => $range) { if (!$this->ready_to_train($range)) { unset($trainingranges[$rangeindex]); } } return $trainingranges; }
php
public function get_training_ranges() { // Cloning the array. $trainingranges = $this->ranges; foreach ($trainingranges as $rangeindex => $range) { if (!$this->ready_to_train($range)) { unset($trainingranges[$rangeindex]); } } return $trainingranges; }
[ "public", "function", "get_training_ranges", "(", ")", "{", "// Cloning the array.", "$", "trainingranges", "=", "$", "this", "->", "ranges", ";", "foreach", "(", "$", "trainingranges", "as", "$", "rangeindex", "=>", "$", "range", ")", "{", "if", "(", "!", "$", "this", "->", "ready_to_train", "(", "$", "range", ")", ")", "{", "unset", "(", "$", "trainingranges", "[", "$", "rangeindex", "]", ")", ";", "}", "}", "return", "$", "trainingranges", ";", "}" ]
Overwritting as the last range may be for prediction. @return array
[ "Overwritting", "as", "the", "last", "range", "may", "be", "for", "prediction", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/local/time_splitting/periodic.php#L108-L119
219,028
moodle/moodle
analytics/classes/local/time_splitting/periodic.php
periodic.get_next_range
protected function get_next_range(\DateTimeImmutable $next) { $end = $next->getTimestamp(); $start = $next->sub($this->periodicity())->getTimestamp(); if ($start < $this->analysable->get_start()) { // We skip the first range generated as its start is prior to the analysable start. return false; } return [ 'start' => $start, 'end' => $end, 'time' => $end ]; }
php
protected function get_next_range(\DateTimeImmutable $next) { $end = $next->getTimestamp(); $start = $next->sub($this->periodicity())->getTimestamp(); if ($start < $this->analysable->get_start()) { // We skip the first range generated as its start is prior to the analysable start. return false; } return [ 'start' => $start, 'end' => $end, 'time' => $end ]; }
[ "protected", "function", "get_next_range", "(", "\\", "DateTimeImmutable", "$", "next", ")", "{", "$", "end", "=", "$", "next", "->", "getTimestamp", "(", ")", ";", "$", "start", "=", "$", "next", "->", "sub", "(", "$", "this", "->", "periodicity", "(", ")", ")", "->", "getTimestamp", "(", ")", ";", "if", "(", "$", "start", "<", "$", "this", "->", "analysable", "->", "get_start", "(", ")", ")", "{", "// We skip the first range generated as its start is prior to the analysable start.", "return", "false", ";", "}", "return", "[", "'start'", "=>", "$", "start", ",", "'end'", "=>", "$", "end", ",", "'time'", "=>", "$", "end", "]", ";", "}" ]
The next range is based on the past period. @param \DateTimeImmutable $next @return array
[ "The", "next", "range", "is", "based", "on", "the", "past", "period", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/local/time_splitting/periodic.php#L127-L142
219,029
moodle/moodle
cache/stores/mongodb/MongoDB/Operation/Watch.php
Watch.createAggregate
private function createAggregate() { $pipeline = $this->pipeline; array_unshift($pipeline, ['$changeStream' => (object) $this->changeStreamOptions]); return new Aggregate($this->databaseName, $this->collectionName, $pipeline, $this->aggregateOptions); }
php
private function createAggregate() { $pipeline = $this->pipeline; array_unshift($pipeline, ['$changeStream' => (object) $this->changeStreamOptions]); return new Aggregate($this->databaseName, $this->collectionName, $pipeline, $this->aggregateOptions); }
[ "private", "function", "createAggregate", "(", ")", "{", "$", "pipeline", "=", "$", "this", "->", "pipeline", ";", "array_unshift", "(", "$", "pipeline", ",", "[", "'$changeStream'", "=>", "(", "object", ")", "$", "this", "->", "changeStreamOptions", "]", ")", ";", "return", "new", "Aggregate", "(", "$", "this", "->", "databaseName", ",", "$", "this", "->", "collectionName", ",", "$", "pipeline", ",", "$", "this", "->", "aggregateOptions", ")", ";", "}" ]
Create the aggregate command for creating a change stream. This method is also used to recreate the aggregate command when resuming. @return Aggregate
[ "Create", "the", "aggregate", "command", "for", "creating", "a", "change", "stream", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Operation/Watch.php#L226-L232
219,030
moodle/moodle
cache/stores/mongodb/MongoDB/Operation/Watch.php
Watch.executeAggregate
private function executeAggregate(Server $server) { /* If we've already captured an operation time or the server does not * support returning an operation time (e.g. MongoDB 3.6), execute the * aggregation directly and return its cursor. */ if ($this->operationTime !== null || ! \MongoDB\server_supports_feature($server, self::$wireVersionForOperationTime)) { return $this->aggregate->execute($server); } /* Otherwise, execute the aggregation using command monitoring so that * we can capture its operation time with commandSucceeded(). */ \MongoDB\Driver\Monitoring\addSubscriber($this); try { return $this->aggregate->execute($server); } finally { \MongoDB\Driver\Monitoring\removeSubscriber($this); } }
php
private function executeAggregate(Server $server) { /* If we've already captured an operation time or the server does not * support returning an operation time (e.g. MongoDB 3.6), execute the * aggregation directly and return its cursor. */ if ($this->operationTime !== null || ! \MongoDB\server_supports_feature($server, self::$wireVersionForOperationTime)) { return $this->aggregate->execute($server); } /* Otherwise, execute the aggregation using command monitoring so that * we can capture its operation time with commandSucceeded(). */ \MongoDB\Driver\Monitoring\addSubscriber($this); try { return $this->aggregate->execute($server); } finally { \MongoDB\Driver\Monitoring\removeSubscriber($this); } }
[ "private", "function", "executeAggregate", "(", "Server", "$", "server", ")", "{", "/* If we've already captured an operation time or the server does not\n * support returning an operation time (e.g. MongoDB 3.6), execute the\n * aggregation directly and return its cursor. */", "if", "(", "$", "this", "->", "operationTime", "!==", "null", "||", "!", "\\", "MongoDB", "\\", "server_supports_feature", "(", "$", "server", ",", "self", "::", "$", "wireVersionForOperationTime", ")", ")", "{", "return", "$", "this", "->", "aggregate", "->", "execute", "(", "$", "server", ")", ";", "}", "/* Otherwise, execute the aggregation using command monitoring so that\n * we can capture its operation time with commandSucceeded(). */", "\\", "MongoDB", "\\", "Driver", "\\", "Monitoring", "\\", "addSubscriber", "(", "$", "this", ")", ";", "try", "{", "return", "$", "this", "->", "aggregate", "->", "execute", "(", "$", "server", ")", ";", "}", "finally", "{", "\\", "MongoDB", "\\", "Driver", "\\", "Monitoring", "\\", "removeSubscriber", "(", "$", "this", ")", ";", "}", "}" ]
Execute the aggregate command and optionally capture its operation time. @param Server $server @return Cursor
[ "Execute", "the", "aggregate", "command", "and", "optionally", "capture", "its", "operation", "time", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Operation/Watch.php#L267-L285
219,031
moodle/moodle
blocks/rss_client/editfeed.php
feed_edit_form.autodiscover_feed_url
public static function autodiscover_feed_url($url){ $rss = new moodle_simplepie(); $rss->set_feed_url($url); $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL); // When autodiscovering an RSS feed, simplepie will try lots of // rss links on a page, so set the timeout high $rss->set_timeout(20); $rss->init(); if($rss->error()){ return $url; } // return URL without quoting.. $discoveredurl = new moodle_url($rss->subscribe_url()); return $discoveredurl->out(false); }
php
public static function autodiscover_feed_url($url){ $rss = new moodle_simplepie(); $rss->set_feed_url($url); $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL); // When autodiscovering an RSS feed, simplepie will try lots of // rss links on a page, so set the timeout high $rss->set_timeout(20); $rss->init(); if($rss->error()){ return $url; } // return URL without quoting.. $discoveredurl = new moodle_url($rss->subscribe_url()); return $discoveredurl->out(false); }
[ "public", "static", "function", "autodiscover_feed_url", "(", "$", "url", ")", "{", "$", "rss", "=", "new", "moodle_simplepie", "(", ")", ";", "$", "rss", "->", "set_feed_url", "(", "$", "url", ")", ";", "$", "rss", "->", "set_autodiscovery_level", "(", "SIMPLEPIE_LOCATOR_ALL", ")", ";", "// When autodiscovering an RSS feed, simplepie will try lots of", "// rss links on a page, so set the timeout high", "$", "rss", "->", "set_timeout", "(", "20", ")", ";", "$", "rss", "->", "init", "(", ")", ";", "if", "(", "$", "rss", "->", "error", "(", ")", ")", "{", "return", "$", "url", ";", "}", "// return URL without quoting..", "$", "discoveredurl", "=", "new", "moodle_url", "(", "$", "rss", "->", "subscribe_url", "(", ")", ")", ";", "return", "$", "discoveredurl", "->", "out", "(", "false", ")", ";", "}" ]
Autodiscovers a feed url from a given url, to be used by the formslibs filter function Uses simplepie with autodiscovery set to maximum level to try and find a feed to subscribe to. See: http://simplepie.org/wiki/reference/simplepie/set_autodiscovery_level @param string URL to autodiscover a url @return string URL of feed or original url if none found
[ "Autodiscovers", "a", "feed", "url", "from", "a", "given", "url", "to", "be", "used", "by", "the", "formslibs", "filter", "function" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/rss_client/editfeed.php#L129-L145
219,032
moodle/moodle
mod/url/classes/external.php
mod_url_external.get_urls_by_courses
public static function get_urls_by_courses($courseids = array()) { $warnings = array(); $returnedurls = array(); $params = array( 'courseids' => $courseids, ); $params = self::validate_parameters(self::get_urls_by_courses_parameters(), $params); $mycourses = array(); if (empty($params['courseids'])) { $mycourses = enrol_get_my_courses(); $params['courseids'] = array_keys($mycourses); } // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses); // Get the urls in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $urls = get_all_instances_in_courses("url", $courses); foreach ($urls as $url) { $context = context_module::instance($url->coursemodule); // Entry to return. $url->name = external_format_string($url->name, $context->id); list($url->intro, $url->introformat) = external_format_text($url->intro, $url->introformat, $context->id, 'mod_url', 'intro', null); $url->introfiles = external_util::get_area_files($context->id, 'mod_url', 'intro', false, false); $returnedurls[] = $url; } } $result = array( 'urls' => $returnedurls, 'warnings' => $warnings ); return $result; }
php
public static function get_urls_by_courses($courseids = array()) { $warnings = array(); $returnedurls = array(); $params = array( 'courseids' => $courseids, ); $params = self::validate_parameters(self::get_urls_by_courses_parameters(), $params); $mycourses = array(); if (empty($params['courseids'])) { $mycourses = enrol_get_my_courses(); $params['courseids'] = array_keys($mycourses); } // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses); // Get the urls in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $urls = get_all_instances_in_courses("url", $courses); foreach ($urls as $url) { $context = context_module::instance($url->coursemodule); // Entry to return. $url->name = external_format_string($url->name, $context->id); list($url->intro, $url->introformat) = external_format_text($url->intro, $url->introformat, $context->id, 'mod_url', 'intro', null); $url->introfiles = external_util::get_area_files($context->id, 'mod_url', 'intro', false, false); $returnedurls[] = $url; } } $result = array( 'urls' => $returnedurls, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_urls_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "$", "warnings", "=", "array", "(", ")", ";", "$", "returnedurls", "=", "array", "(", ")", ";", "$", "params", "=", "array", "(", "'courseids'", "=>", "$", "courseids", ",", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_urls_by_courses_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "mycourses", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "$", "mycourses", "=", "enrol_get_my_courses", "(", ")", ";", "$", "params", "[", "'courseids'", "]", "=", "array_keys", "(", "$", "mycourses", ")", ";", "}", "// Ensure there are courseids to loop through.", "if", "(", "!", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "$", "mycourses", ")", ";", "// Get the urls in this course, this function checks users visibility permissions.", "// We can avoid then additional validate_context calls.", "$", "urls", "=", "get_all_instances_in_courses", "(", "\"url\"", ",", "$", "courses", ")", ";", "foreach", "(", "$", "urls", "as", "$", "url", ")", "{", "$", "context", "=", "context_module", "::", "instance", "(", "$", "url", "->", "coursemodule", ")", ";", "// Entry to return.", "$", "url", "->", "name", "=", "external_format_string", "(", "$", "url", "->", "name", ",", "$", "context", "->", "id", ")", ";", "list", "(", "$", "url", "->", "intro", ",", "$", "url", "->", "introformat", ")", "=", "external_format_text", "(", "$", "url", "->", "intro", ",", "$", "url", "->", "introformat", ",", "$", "context", "->", "id", ",", "'mod_url'", ",", "'intro'", ",", "null", ")", ";", "$", "url", "->", "introfiles", "=", "external_util", "::", "get_area_files", "(", "$", "context", "->", "id", ",", "'mod_url'", ",", "'intro'", ",", "false", ",", "false", ")", ";", "$", "returnedurls", "[", "]", "=", "$", "url", ";", "}", "}", "$", "result", "=", "array", "(", "'urls'", "=>", "$", "returnedurls", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Returns a list of urls in a provided list of courses. If no list is provided all urls that the user can view will be returned. @param array $courseids course ids @return array of warnings and urls @since Moodle 3.3
[ "Returns", "a", "list", "of", "urls", "in", "a", "provided", "list", "of", "courses", ".", "If", "no", "list", "is", "provided", "all", "urls", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/url/classes/external.php#L131-L173
219,033
moodle/moodle
mod/url/classes/external.php
mod_url_external.get_urls_by_courses_returns
public static function get_urls_by_courses_returns() { return new external_single_structure( array( 'urls' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Module id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'URL name'), 'intro' => new external_value(PARAM_RAW, 'Summary'), 'introformat' => new external_format_value('intro', 'Summary format'), 'introfiles' => new external_files('Files in the introduction text'), 'externalurl' => new external_value(PARAM_RAW_TRIMMED, 'External URL'), 'display' => new external_value(PARAM_INT, 'How to display the url'), 'displayoptions' => new external_value(PARAM_RAW, 'Display options (width, height)'), 'parameters' => new external_value(PARAM_RAW, 'Parameters to append to the URL'), 'timemodified' => new external_value(PARAM_INT, 'Last time the url was modified'), 'section' => new external_value(PARAM_INT, 'Course section id'), 'visible' => new external_value(PARAM_INT, 'Module visibility'), 'groupmode' => new external_value(PARAM_INT, 'Group mode'), 'groupingid' => new external_value(PARAM_INT, 'Grouping id'), ) ) ), 'warnings' => new external_warnings(), ) ); }
php
public static function get_urls_by_courses_returns() { return new external_single_structure( array( 'urls' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Module id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'URL name'), 'intro' => new external_value(PARAM_RAW, 'Summary'), 'introformat' => new external_format_value('intro', 'Summary format'), 'introfiles' => new external_files('Files in the introduction text'), 'externalurl' => new external_value(PARAM_RAW_TRIMMED, 'External URL'), 'display' => new external_value(PARAM_INT, 'How to display the url'), 'displayoptions' => new external_value(PARAM_RAW, 'Display options (width, height)'), 'parameters' => new external_value(PARAM_RAW, 'Parameters to append to the URL'), 'timemodified' => new external_value(PARAM_INT, 'Last time the url was modified'), 'section' => new external_value(PARAM_INT, 'Course section id'), 'visible' => new external_value(PARAM_INT, 'Module visibility'), 'groupmode' => new external_value(PARAM_INT, 'Group mode'), 'groupingid' => new external_value(PARAM_INT, 'Grouping id'), ) ) ), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_urls_by_courses_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'urls'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Module id'", ")", ",", "'coursemodule'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course module id'", ")", ",", "'course'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'URL name'", ")", ",", "'intro'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Summary'", ")", ",", "'introformat'", "=>", "new", "external_format_value", "(", "'intro'", ",", "'Summary format'", ")", ",", "'introfiles'", "=>", "new", "external_files", "(", "'Files in the introduction text'", ")", ",", "'externalurl'", "=>", "new", "external_value", "(", "PARAM_RAW_TRIMMED", ",", "'External URL'", ")", ",", "'display'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'How to display the url'", ")", ",", "'displayoptions'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Display options (width, height)'", ")", ",", "'parameters'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Parameters to append to the URL'", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Last time the url was modified'", ")", ",", "'section'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course section id'", ")", ",", "'visible'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Module visibility'", ")", ",", "'groupmode'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Group mode'", ")", ",", "'groupingid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Grouping id'", ")", ",", ")", ")", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_urls_by_courses return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_urls_by_courses", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/url/classes/external.php#L181-L209
219,034
moodle/moodle
backup/util/dbops/restore_controller_dbops.class.php
restore_controller_dbops.save_controller
public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false) { global $DB; // Check we are going to save one backup_controller if (! $controller instanceof restore_controller) { throw new backup_controller_exception('restore_controller_expected'); } // Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-). if ($includeobj and !$controller->is_checksum_correct($checksum)) { throw new restore_dbops_exception('restore_controller_dbops_saving_checksum_mismatch'); } // Cannot request to $includeobj and $cleanobj at the same time. if ($includeobj and $cleanobj) { throw new restore_dbops_exception('restore_controller_dbops_saving_cannot_include_and_delete'); } // Get all the columns $rec = new stdclass(); $rec->backupid = $controller->get_restoreid(); $rec->operation = $controller->get_operation(); $rec->type = $controller->get_type(); $rec->itemid = $controller->get_courseid(); $rec->format = $controller->get_format(); $rec->interactive = $controller->get_interactive(); $rec->purpose = $controller->get_mode(); $rec->userid = $controller->get_userid(); $rec->status = $controller->get_status(); $rec->execution = $controller->get_execution(); $rec->executiontime= $controller->get_executiontime(); $rec->checksum = $checksum; // Serialize information if ($includeobj) { $rec->controller = base64_encode(serialize($controller)); } else if ($cleanobj) { $rec->controller = ''; } // Send it to DB if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) { $rec->id = $recexists->id; $rec->timemodified = time(); $DB->update_record('backup_controllers', $rec); } else { $rec->timecreated = time(); $rec->timemodified = 0; $rec->id = $DB->insert_record('backup_controllers', $rec); } return $rec->id; }
php
public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false) { global $DB; // Check we are going to save one backup_controller if (! $controller instanceof restore_controller) { throw new backup_controller_exception('restore_controller_expected'); } // Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-). if ($includeobj and !$controller->is_checksum_correct($checksum)) { throw new restore_dbops_exception('restore_controller_dbops_saving_checksum_mismatch'); } // Cannot request to $includeobj and $cleanobj at the same time. if ($includeobj and $cleanobj) { throw new restore_dbops_exception('restore_controller_dbops_saving_cannot_include_and_delete'); } // Get all the columns $rec = new stdclass(); $rec->backupid = $controller->get_restoreid(); $rec->operation = $controller->get_operation(); $rec->type = $controller->get_type(); $rec->itemid = $controller->get_courseid(); $rec->format = $controller->get_format(); $rec->interactive = $controller->get_interactive(); $rec->purpose = $controller->get_mode(); $rec->userid = $controller->get_userid(); $rec->status = $controller->get_status(); $rec->execution = $controller->get_execution(); $rec->executiontime= $controller->get_executiontime(); $rec->checksum = $checksum; // Serialize information if ($includeobj) { $rec->controller = base64_encode(serialize($controller)); } else if ($cleanobj) { $rec->controller = ''; } // Send it to DB if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) { $rec->id = $recexists->id; $rec->timemodified = time(); $DB->update_record('backup_controllers', $rec); } else { $rec->timecreated = time(); $rec->timemodified = 0; $rec->id = $DB->insert_record('backup_controllers', $rec); } return $rec->id; }
[ "public", "static", "function", "save_controller", "(", "$", "controller", ",", "$", "checksum", ",", "$", "includeobj", "=", "true", ",", "$", "cleanobj", "=", "false", ")", "{", "global", "$", "DB", ";", "// Check we are going to save one backup_controller", "if", "(", "!", "$", "controller", "instanceof", "restore_controller", ")", "{", "throw", "new", "backup_controller_exception", "(", "'restore_controller_expected'", ")", ";", "}", "// Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-).", "if", "(", "$", "includeobj", "and", "!", "$", "controller", "->", "is_checksum_correct", "(", "$", "checksum", ")", ")", "{", "throw", "new", "restore_dbops_exception", "(", "'restore_controller_dbops_saving_checksum_mismatch'", ")", ";", "}", "// Cannot request to $includeobj and $cleanobj at the same time.", "if", "(", "$", "includeobj", "and", "$", "cleanobj", ")", "{", "throw", "new", "restore_dbops_exception", "(", "'restore_controller_dbops_saving_cannot_include_and_delete'", ")", ";", "}", "// Get all the columns", "$", "rec", "=", "new", "stdclass", "(", ")", ";", "$", "rec", "->", "backupid", "=", "$", "controller", "->", "get_restoreid", "(", ")", ";", "$", "rec", "->", "operation", "=", "$", "controller", "->", "get_operation", "(", ")", ";", "$", "rec", "->", "type", "=", "$", "controller", "->", "get_type", "(", ")", ";", "$", "rec", "->", "itemid", "=", "$", "controller", "->", "get_courseid", "(", ")", ";", "$", "rec", "->", "format", "=", "$", "controller", "->", "get_format", "(", ")", ";", "$", "rec", "->", "interactive", "=", "$", "controller", "->", "get_interactive", "(", ")", ";", "$", "rec", "->", "purpose", "=", "$", "controller", "->", "get_mode", "(", ")", ";", "$", "rec", "->", "userid", "=", "$", "controller", "->", "get_userid", "(", ")", ";", "$", "rec", "->", "status", "=", "$", "controller", "->", "get_status", "(", ")", ";", "$", "rec", "->", "execution", "=", "$", "controller", "->", "get_execution", "(", ")", ";", "$", "rec", "->", "executiontime", "=", "$", "controller", "->", "get_executiontime", "(", ")", ";", "$", "rec", "->", "checksum", "=", "$", "checksum", ";", "// Serialize information", "if", "(", "$", "includeobj", ")", "{", "$", "rec", "->", "controller", "=", "base64_encode", "(", "serialize", "(", "$", "controller", ")", ")", ";", "}", "else", "if", "(", "$", "cleanobj", ")", "{", "$", "rec", "->", "controller", "=", "''", ";", "}", "// Send it to DB", "if", "(", "$", "recexists", "=", "$", "DB", "->", "get_record", "(", "'backup_controllers'", ",", "array", "(", "'backupid'", "=>", "$", "rec", "->", "backupid", ")", ")", ")", "{", "$", "rec", "->", "id", "=", "$", "recexists", "->", "id", ";", "$", "rec", "->", "timemodified", "=", "time", "(", ")", ";", "$", "DB", "->", "update_record", "(", "'backup_controllers'", ",", "$", "rec", ")", ";", "}", "else", "{", "$", "rec", "->", "timecreated", "=", "time", "(", ")", ";", "$", "rec", "->", "timemodified", "=", "0", ";", "$", "rec", "->", "id", "=", "$", "DB", "->", "insert_record", "(", "'backup_controllers'", ",", "$", "rec", ")", ";", "}", "return", "$", "rec", "->", "id", ";", "}" ]
Send one restore controller to DB @param restore_controller $controller controller to send to DB @param string $checksum hash of the controller to be checked @param bool $includeobj to decide if the object itself must be updated (true) or no (false) @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false) @return int id of the controller record in the DB @throws backup_controller_exception|restore_dbops_exception
[ "Send", "one", "restore", "controller", "to", "DB" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/dbops/restore_controller_dbops.class.php#L45-L90
219,035
moodle/moodle
backup/util/dbops/restore_controller_dbops.class.php
restore_controller_dbops.apply_config_defaults
public static function apply_config_defaults(restore_controller $controller) { $settings = array( 'restore_general_users' => 'users', 'restore_general_enrolments' => 'enrolments', 'restore_general_role_assignments' => 'role_assignments', 'restore_general_activities' => 'activities', 'restore_general_blocks' => 'blocks', 'restore_general_filters' => 'filters', 'restore_general_comments' => 'comments', 'restore_general_badges' => 'badges', 'restore_general_calendarevents' => 'calendarevents', 'restore_general_userscompletion' => 'userscompletion', 'restore_general_logs' => 'logs', 'restore_general_histories' => 'grade_histories', 'restore_general_questionbank' => 'questionbank', 'restore_general_groups' => 'groups', 'restore_general_competencies' => 'competencies' ); self::apply_admin_config_defaults($controller, $settings, true); $target = $controller->get_target(); if ($target == backup::TARGET_EXISTING_ADDING || $target == backup::TARGET_CURRENT_ADDING) { $settings = array( 'restore_merge_overwrite_conf' => 'overwrite_conf', 'restore_merge_course_fullname' => 'course_fullname', 'restore_merge_course_shortname' => 'course_shortname', 'restore_merge_course_startdate' => 'course_startdate', ); self::apply_admin_config_defaults($controller, $settings, true); } if ($target == backup::TARGET_EXISTING_DELETING || $target == backup::TARGET_CURRENT_DELETING) { $settings = array( 'restore_replace_overwrite_conf' => 'overwrite_conf', 'restore_replace_course_fullname' => 'course_fullname', 'restore_replace_course_shortname' => 'course_shortname', 'restore_replace_course_startdate' => 'course_startdate', 'restore_replace_keep_roles_and_enrolments' => 'keep_roles_and_enrolments', 'restore_replace_keep_groups_and_groupings' => 'keep_groups_and_groupings', ); self::apply_admin_config_defaults($controller, $settings, true); } if ($controller->get_mode() == backup::MODE_IMPORT && (!$controller->get_interactive()) && $controller->get_type() == backup::TYPE_1ACTIVITY) { // This is duplicate - there is no concept of defaults - these settings must be on. $settings = array( 'activities', 'blocks', 'filters', 'questionbank' ); self::force_enable_settings($controller, $settings); }; // Add some dependencies. $plan = $controller->get_plan(); if ($plan->setting_exists('overwrite_conf')) { /** @var restore_course_overwrite_conf_setting $overwriteconf */ $overwriteconf = $plan->get_setting('overwrite_conf'); if ($overwriteconf->get_visibility()) { foreach (['course_fullname', 'course_shortname', 'course_startdate'] as $settingname) { if ($plan->setting_exists($settingname)) { $setting = $plan->get_setting($settingname); $overwriteconf->add_dependency($setting, setting_dependency::DISABLED_FALSE, array('defaultvalue' => $setting->get_value())); } } } } }
php
public static function apply_config_defaults(restore_controller $controller) { $settings = array( 'restore_general_users' => 'users', 'restore_general_enrolments' => 'enrolments', 'restore_general_role_assignments' => 'role_assignments', 'restore_general_activities' => 'activities', 'restore_general_blocks' => 'blocks', 'restore_general_filters' => 'filters', 'restore_general_comments' => 'comments', 'restore_general_badges' => 'badges', 'restore_general_calendarevents' => 'calendarevents', 'restore_general_userscompletion' => 'userscompletion', 'restore_general_logs' => 'logs', 'restore_general_histories' => 'grade_histories', 'restore_general_questionbank' => 'questionbank', 'restore_general_groups' => 'groups', 'restore_general_competencies' => 'competencies' ); self::apply_admin_config_defaults($controller, $settings, true); $target = $controller->get_target(); if ($target == backup::TARGET_EXISTING_ADDING || $target == backup::TARGET_CURRENT_ADDING) { $settings = array( 'restore_merge_overwrite_conf' => 'overwrite_conf', 'restore_merge_course_fullname' => 'course_fullname', 'restore_merge_course_shortname' => 'course_shortname', 'restore_merge_course_startdate' => 'course_startdate', ); self::apply_admin_config_defaults($controller, $settings, true); } if ($target == backup::TARGET_EXISTING_DELETING || $target == backup::TARGET_CURRENT_DELETING) { $settings = array( 'restore_replace_overwrite_conf' => 'overwrite_conf', 'restore_replace_course_fullname' => 'course_fullname', 'restore_replace_course_shortname' => 'course_shortname', 'restore_replace_course_startdate' => 'course_startdate', 'restore_replace_keep_roles_and_enrolments' => 'keep_roles_and_enrolments', 'restore_replace_keep_groups_and_groupings' => 'keep_groups_and_groupings', ); self::apply_admin_config_defaults($controller, $settings, true); } if ($controller->get_mode() == backup::MODE_IMPORT && (!$controller->get_interactive()) && $controller->get_type() == backup::TYPE_1ACTIVITY) { // This is duplicate - there is no concept of defaults - these settings must be on. $settings = array( 'activities', 'blocks', 'filters', 'questionbank' ); self::force_enable_settings($controller, $settings); }; // Add some dependencies. $plan = $controller->get_plan(); if ($plan->setting_exists('overwrite_conf')) { /** @var restore_course_overwrite_conf_setting $overwriteconf */ $overwriteconf = $plan->get_setting('overwrite_conf'); if ($overwriteconf->get_visibility()) { foreach (['course_fullname', 'course_shortname', 'course_startdate'] as $settingname) { if ($plan->setting_exists($settingname)) { $setting = $plan->get_setting($settingname); $overwriteconf->add_dependency($setting, setting_dependency::DISABLED_FALSE, array('defaultvalue' => $setting->get_value())); } } } } }
[ "public", "static", "function", "apply_config_defaults", "(", "restore_controller", "$", "controller", ")", "{", "$", "settings", "=", "array", "(", "'restore_general_users'", "=>", "'users'", ",", "'restore_general_enrolments'", "=>", "'enrolments'", ",", "'restore_general_role_assignments'", "=>", "'role_assignments'", ",", "'restore_general_activities'", "=>", "'activities'", ",", "'restore_general_blocks'", "=>", "'blocks'", ",", "'restore_general_filters'", "=>", "'filters'", ",", "'restore_general_comments'", "=>", "'comments'", ",", "'restore_general_badges'", "=>", "'badges'", ",", "'restore_general_calendarevents'", "=>", "'calendarevents'", ",", "'restore_general_userscompletion'", "=>", "'userscompletion'", ",", "'restore_general_logs'", "=>", "'logs'", ",", "'restore_general_histories'", "=>", "'grade_histories'", ",", "'restore_general_questionbank'", "=>", "'questionbank'", ",", "'restore_general_groups'", "=>", "'groups'", ",", "'restore_general_competencies'", "=>", "'competencies'", ")", ";", "self", "::", "apply_admin_config_defaults", "(", "$", "controller", ",", "$", "settings", ",", "true", ")", ";", "$", "target", "=", "$", "controller", "->", "get_target", "(", ")", ";", "if", "(", "$", "target", "==", "backup", "::", "TARGET_EXISTING_ADDING", "||", "$", "target", "==", "backup", "::", "TARGET_CURRENT_ADDING", ")", "{", "$", "settings", "=", "array", "(", "'restore_merge_overwrite_conf'", "=>", "'overwrite_conf'", ",", "'restore_merge_course_fullname'", "=>", "'course_fullname'", ",", "'restore_merge_course_shortname'", "=>", "'course_shortname'", ",", "'restore_merge_course_startdate'", "=>", "'course_startdate'", ",", ")", ";", "self", "::", "apply_admin_config_defaults", "(", "$", "controller", ",", "$", "settings", ",", "true", ")", ";", "}", "if", "(", "$", "target", "==", "backup", "::", "TARGET_EXISTING_DELETING", "||", "$", "target", "==", "backup", "::", "TARGET_CURRENT_DELETING", ")", "{", "$", "settings", "=", "array", "(", "'restore_replace_overwrite_conf'", "=>", "'overwrite_conf'", ",", "'restore_replace_course_fullname'", "=>", "'course_fullname'", ",", "'restore_replace_course_shortname'", "=>", "'course_shortname'", ",", "'restore_replace_course_startdate'", "=>", "'course_startdate'", ",", "'restore_replace_keep_roles_and_enrolments'", "=>", "'keep_roles_and_enrolments'", ",", "'restore_replace_keep_groups_and_groupings'", "=>", "'keep_groups_and_groupings'", ",", ")", ";", "self", "::", "apply_admin_config_defaults", "(", "$", "controller", ",", "$", "settings", ",", "true", ")", ";", "}", "if", "(", "$", "controller", "->", "get_mode", "(", ")", "==", "backup", "::", "MODE_IMPORT", "&&", "(", "!", "$", "controller", "->", "get_interactive", "(", ")", ")", "&&", "$", "controller", "->", "get_type", "(", ")", "==", "backup", "::", "TYPE_1ACTIVITY", ")", "{", "// This is duplicate - there is no concept of defaults - these settings must be on.", "$", "settings", "=", "array", "(", "'activities'", ",", "'blocks'", ",", "'filters'", ",", "'questionbank'", ")", ";", "self", "::", "force_enable_settings", "(", "$", "controller", ",", "$", "settings", ")", ";", "}", ";", "// Add some dependencies.", "$", "plan", "=", "$", "controller", "->", "get_plan", "(", ")", ";", "if", "(", "$", "plan", "->", "setting_exists", "(", "'overwrite_conf'", ")", ")", "{", "/** @var restore_course_overwrite_conf_setting $overwriteconf */", "$", "overwriteconf", "=", "$", "plan", "->", "get_setting", "(", "'overwrite_conf'", ")", ";", "if", "(", "$", "overwriteconf", "->", "get_visibility", "(", ")", ")", "{", "foreach", "(", "[", "'course_fullname'", ",", "'course_shortname'", ",", "'course_startdate'", "]", "as", "$", "settingname", ")", "{", "if", "(", "$", "plan", "->", "setting_exists", "(", "$", "settingname", ")", ")", "{", "$", "setting", "=", "$", "plan", "->", "get_setting", "(", "$", "settingname", ")", ";", "$", "overwriteconf", "->", "add_dependency", "(", "$", "setting", ",", "setting_dependency", "::", "DISABLED_FALSE", ",", "array", "(", "'defaultvalue'", "=>", "$", "setting", "->", "get_value", "(", ")", ")", ")", ";", "}", "}", "}", "}", "}" ]
Sets the default values for the settings in a restore operation @param restore_controller $controller
[ "Sets", "the", "default", "values", "for", "the", "settings", "in", "a", "restore", "operation" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/dbops/restore_controller_dbops.class.php#L143-L214
219,036
moodle/moodle
backup/util/dbops/restore_controller_dbops.class.php
restore_controller_dbops.get_setting_default
private static function get_setting_default($config, $setting) { $value = get_config('restore', $config); if (in_array($setting->get_name(), ['course_fullname', 'course_shortname', 'course_startdate']) && $setting->get_ui() instanceof backup_setting_ui_defaultcustom) { // Special case - admin config settings course_fullname, etc. are boolean and the restore settings are strings. $value = (bool)$value; if ($value) { $attributes = $setting->get_ui()->get_attributes(); $value = $attributes['customvalue']; } } if ($setting->get_ui() instanceof backup_setting_ui_select) { // Make sure the value is a valid option in the select element, otherwise just pick the first from the options list. // Example: enrolments dropdown may not have the "enrol_withusers" option because users info can not be restored. $options = array_keys($setting->get_ui()->get_values()); if (!in_array($value, $options)) { $value = reset($options); } } return $value; }
php
private static function get_setting_default($config, $setting) { $value = get_config('restore', $config); if (in_array($setting->get_name(), ['course_fullname', 'course_shortname', 'course_startdate']) && $setting->get_ui() instanceof backup_setting_ui_defaultcustom) { // Special case - admin config settings course_fullname, etc. are boolean and the restore settings are strings. $value = (bool)$value; if ($value) { $attributes = $setting->get_ui()->get_attributes(); $value = $attributes['customvalue']; } } if ($setting->get_ui() instanceof backup_setting_ui_select) { // Make sure the value is a valid option in the select element, otherwise just pick the first from the options list. // Example: enrolments dropdown may not have the "enrol_withusers" option because users info can not be restored. $options = array_keys($setting->get_ui()->get_values()); if (!in_array($value, $options)) { $value = reset($options); } } return $value; }
[ "private", "static", "function", "get_setting_default", "(", "$", "config", ",", "$", "setting", ")", "{", "$", "value", "=", "get_config", "(", "'restore'", ",", "$", "config", ")", ";", "if", "(", "in_array", "(", "$", "setting", "->", "get_name", "(", ")", ",", "[", "'course_fullname'", ",", "'course_shortname'", ",", "'course_startdate'", "]", ")", "&&", "$", "setting", "->", "get_ui", "(", ")", "instanceof", "backup_setting_ui_defaultcustom", ")", "{", "// Special case - admin config settings course_fullname, etc. are boolean and the restore settings are strings.", "$", "value", "=", "(", "bool", ")", "$", "value", ";", "if", "(", "$", "value", ")", "{", "$", "attributes", "=", "$", "setting", "->", "get_ui", "(", ")", "->", "get_attributes", "(", ")", ";", "$", "value", "=", "$", "attributes", "[", "'customvalue'", "]", ";", "}", "}", "if", "(", "$", "setting", "->", "get_ui", "(", ")", "instanceof", "backup_setting_ui_select", ")", "{", "// Make sure the value is a valid option in the select element, otherwise just pick the first from the options list.", "// Example: enrolments dropdown may not have the \"enrol_withusers\" option because users info can not be restored.", "$", "options", "=", "array_keys", "(", "$", "setting", "->", "get_ui", "(", ")", "->", "get_values", "(", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "value", ",", "$", "options", ")", ")", "{", "$", "value", "=", "reset", "(", "$", "options", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Returns the default value to be used for a setting from the admin restore config @param string $config @param backup_setting $setting @return mixed
[ "Returns", "the", "default", "value", "to", "be", "used", "for", "a", "setting", "from", "the", "admin", "restore", "config" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/dbops/restore_controller_dbops.class.php#L223-L246
219,037
moodle/moodle
backup/util/dbops/restore_controller_dbops.class.php
restore_controller_dbops.force_enable_settings
private static function force_enable_settings(restore_controller $controller, array $settings) { $plan = $controller->get_plan(); foreach ($settings as $config => $settingname) { $value = true; if ($plan->setting_exists($settingname)) { $setting = $plan->get_setting($settingname); // We do not allow this setting to be locked for a duplicate function. if ($setting->get_status() !== base_setting::NOT_LOCKED) { $setting->set_status(base_setting::NOT_LOCKED); } $setting->set_value($value); $setting->set_status(base_setting::LOCKED_BY_CONFIG); } else { $controller->log('Unknown setting: ' . $settingname, BACKUP::LOG_DEBUG); } } }
php
private static function force_enable_settings(restore_controller $controller, array $settings) { $plan = $controller->get_plan(); foreach ($settings as $config => $settingname) { $value = true; if ($plan->setting_exists($settingname)) { $setting = $plan->get_setting($settingname); // We do not allow this setting to be locked for a duplicate function. if ($setting->get_status() !== base_setting::NOT_LOCKED) { $setting->set_status(base_setting::NOT_LOCKED); } $setting->set_value($value); $setting->set_status(base_setting::LOCKED_BY_CONFIG); } else { $controller->log('Unknown setting: ' . $settingname, BACKUP::LOG_DEBUG); } } }
[ "private", "static", "function", "force_enable_settings", "(", "restore_controller", "$", "controller", ",", "array", "$", "settings", ")", "{", "$", "plan", "=", "$", "controller", "->", "get_plan", "(", ")", ";", "foreach", "(", "$", "settings", "as", "$", "config", "=>", "$", "settingname", ")", "{", "$", "value", "=", "true", ";", "if", "(", "$", "plan", "->", "setting_exists", "(", "$", "settingname", ")", ")", "{", "$", "setting", "=", "$", "plan", "->", "get_setting", "(", "$", "settingname", ")", ";", "// We do not allow this setting to be locked for a duplicate function.", "if", "(", "$", "setting", "->", "get_status", "(", ")", "!==", "base_setting", "::", "NOT_LOCKED", ")", "{", "$", "setting", "->", "set_status", "(", "base_setting", "::", "NOT_LOCKED", ")", ";", "}", "$", "setting", "->", "set_value", "(", "$", "value", ")", ";", "$", "setting", "->", "set_status", "(", "base_setting", "::", "LOCKED_BY_CONFIG", ")", ";", "}", "else", "{", "$", "controller", "->", "log", "(", "'Unknown setting: '", ".", "$", "settingname", ",", "BACKUP", "::", "LOG_DEBUG", ")", ";", "}", "}", "}" ]
Turn these settings on. No defaults from admin settings. @param restore_controller $controller @param array $settings a map from admin config names to setting names (Config name => Setting name)
[ "Turn", "these", "settings", "on", ".", "No", "defaults", "from", "admin", "settings", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/dbops/restore_controller_dbops.class.php#L254-L270
219,038
moodle/moodle
admin/tool/usertours/classes/step.php
step.load_from_record
public static function load_from_record($record, $clean = false) { $step = new self(); return $step->reload_from_record($record, $clean); }
php
public static function load_from_record($record, $clean = false) { $step = new self(); return $step->reload_from_record($record, $clean); }
[ "public", "static", "function", "load_from_record", "(", "$", "record", ",", "$", "clean", "=", "false", ")", "{", "$", "step", "=", "new", "self", "(", ")", ";", "return", "$", "step", "->", "reload_from_record", "(", "$", "record", ",", "$", "clean", ")", ";", "}" ]
Load the step instance. @param stdClass $record The step record to be loaded. @param boolean $clean Clean the values. @return step
[ "Load", "the", "step", "instance", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L105-L108
219,039
moodle/moodle
admin/tool/usertours/classes/step.php
step.reload_from_record
protected function reload_from_record($record, $clean = false) { $this->id = $record->id; $this->tourid = $record->tourid; if ($clean) { $this->title = clean_param($record->title, PARAM_TEXT); $this->content = clean_text($record->content); } else { $this->title = $record->title; $this->content = $record->content; } $this->targettype = $record->targettype; $this->targetvalue = $record->targetvalue; $this->sortorder = $record->sortorder; $this->config = json_decode($record->configdata); $this->dirty = false; return $this; }
php
protected function reload_from_record($record, $clean = false) { $this->id = $record->id; $this->tourid = $record->tourid; if ($clean) { $this->title = clean_param($record->title, PARAM_TEXT); $this->content = clean_text($record->content); } else { $this->title = $record->title; $this->content = $record->content; } $this->targettype = $record->targettype; $this->targetvalue = $record->targetvalue; $this->sortorder = $record->sortorder; $this->config = json_decode($record->configdata); $this->dirty = false; return $this; }
[ "protected", "function", "reload_from_record", "(", "$", "record", ",", "$", "clean", "=", "false", ")", "{", "$", "this", "->", "id", "=", "$", "record", "->", "id", ";", "$", "this", "->", "tourid", "=", "$", "record", "->", "tourid", ";", "if", "(", "$", "clean", ")", "{", "$", "this", "->", "title", "=", "clean_param", "(", "$", "record", "->", "title", ",", "PARAM_TEXT", ")", ";", "$", "this", "->", "content", "=", "clean_text", "(", "$", "record", "->", "content", ")", ";", "}", "else", "{", "$", "this", "->", "title", "=", "$", "record", "->", "title", ";", "$", "this", "->", "content", "=", "$", "record", "->", "content", ";", "}", "$", "this", "->", "targettype", "=", "$", "record", "->", "targettype", ";", "$", "this", "->", "targetvalue", "=", "$", "record", "->", "targetvalue", ";", "$", "this", "->", "sortorder", "=", "$", "record", "->", "sortorder", ";", "$", "this", "->", "config", "=", "json_decode", "(", "$", "record", "->", "configdata", ")", ";", "$", "this", "->", "dirty", "=", "false", ";", "return", "$", "this", ";", "}" ]
Reload the current step from the supplied record. @param stdClass $record The step record to be loaded. @param boolean $clean Clean the values. @return step
[ "Reload", "the", "current", "step", "from", "the", "supplied", "record", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L140-L157
219,040
moodle/moodle
admin/tool/usertours/classes/step.php
step.get_tour
public function get_tour() { if ($this->tour === null) { $this->tour = tour::instance($this->tourid); } return $this->tour; }
php
public function get_tour() { if ($this->tour === null) { $this->tour = tour::instance($this->tourid); } return $this->tour; }
[ "public", "function", "get_tour", "(", ")", "{", "if", "(", "$", "this", "->", "tour", "===", "null", ")", "{", "$", "this", "->", "tour", "=", "tour", "::", "instance", "(", "$", "this", "->", "tourid", ")", ";", "}", "return", "$", "this", "->", "tour", ";", "}" ]
Get the Tour instance that this step belongs to. @return tour
[ "Get", "the", "Tour", "instance", "that", "this", "step", "belongs", "to", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L182-L187
219,041
moodle/moodle
admin/tool/usertours/classes/step.php
step.set_tourid
public function set_tourid($value) { $this->tourid = $value; $this->tour = null; $this->dirty = true; return $this; }
php
public function set_tourid($value) { $this->tourid = $value; $this->tour = null; $this->dirty = true; return $this; }
[ "public", "function", "set_tourid", "(", "$", "value", ")", "{", "$", "this", "->", "tourid", "=", "$", "value", ";", "$", "this", "->", "tour", "=", "null", ";", "$", "this", "->", "dirty", "=", "true", ";", "return", "$", "this", ";", "}" ]
Set the id of the tour. @param int $value The id of the tour. @return self
[ "Set", "the", "id", "of", "the", "tour", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L195-L201
219,042
moodle/moodle
admin/tool/usertours/classes/step.php
step.set_title
public function set_title($value) { $this->title = clean_text($value); $this->dirty = true; return $this; }
php
public function set_title($value) { $this->title = clean_text($value); $this->dirty = true; return $this; }
[ "public", "function", "set_title", "(", "$", "value", ")", "{", "$", "this", "->", "title", "=", "clean_text", "(", "$", "value", ")", ";", "$", "this", "->", "dirty", "=", "true", ";", "return", "$", "this", ";", "}" ]
Set the title for this step. @param string $value The new title to use. @return $this
[ "Set", "the", "title", "for", "this", "step", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L218-L223
219,043
moodle/moodle
admin/tool/usertours/classes/step.php
step.set_content
public function set_content($value) { $this->content = clean_text($value); $this->dirty = true; return $this; }
php
public function set_content($value) { $this->content = clean_text($value); $this->dirty = true; return $this; }
[ "public", "function", "set_content", "(", "$", "value", ")", "{", "$", "this", "->", "content", "=", "clean_text", "(", "$", "value", ")", ";", "$", "this", "->", "dirty", "=", "true", ";", "return", "$", "this", ";", "}" ]
Set the content value for this step. @param string $value The new content to use. @return $this
[ "Set", "the", "content", "value", "for", "this", "step", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L240-L245
219,044
moodle/moodle
admin/tool/usertours/classes/step.php
step.to_record
public function to_record() { return (object) array( 'id' => $this->id, 'tourid' => $this->tourid, 'title' => $this->title, 'content' => $this->content, 'targettype' => $this->targettype, 'targetvalue' => $this->targetvalue, 'sortorder' => $this->sortorder, 'configdata' => json_encode($this->config), ); }
php
public function to_record() { return (object) array( 'id' => $this->id, 'tourid' => $this->tourid, 'title' => $this->title, 'content' => $this->content, 'targettype' => $this->targettype, 'targetvalue' => $this->targetvalue, 'sortorder' => $this->sortorder, 'configdata' => json_encode($this->config), ); }
[ "public", "function", "to_record", "(", ")", "{", "return", "(", "object", ")", "array", "(", "'id'", "=>", "$", "this", "->", "id", ",", "'tourid'", "=>", "$", "this", "->", "tourid", ",", "'title'", "=>", "$", "this", "->", "title", ",", "'content'", "=>", "$", "this", "->", "content", ",", "'targettype'", "=>", "$", "this", "->", "targettype", ",", "'targetvalue'", "=>", "$", "this", "->", "targetvalue", ",", "'sortorder'", "=>", "$", "this", "->", "sortorder", ",", "'configdata'", "=>", "json_encode", "(", "$", "this", "->", "config", ")", ",", ")", ";", "}" ]
Prepare this step for saving to the database. @return object
[ "Prepare", "this", "step", "for", "saving", "to", "the", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L440-L451
219,045
moodle/moodle
admin/tool/usertours/classes/step.php
step.handle_form_submission
public function handle_form_submission(local\forms\editstep &$mform, \stdClass $data) { $this->set_title($data->title); $this->set_content($data->content); $this->set_targettype($data->targettype); $this->set_targetvalue($this->get_target()->get_value_from_form($data)); foreach (self::get_config_keys() as $key) { if (!$this->get_target()->is_setting_forced($key)) { if (isset($data->$key)) { $value = $data->$key; } else { $value = configuration::TOURDEFAULT; } if ($value === configuration::TOURDEFAULT) { $this->set_config($key, null); } else { $this->set_config($key, $value); } } } $this->persist(); return $this; }
php
public function handle_form_submission(local\forms\editstep &$mform, \stdClass $data) { $this->set_title($data->title); $this->set_content($data->content); $this->set_targettype($data->targettype); $this->set_targetvalue($this->get_target()->get_value_from_form($data)); foreach (self::get_config_keys() as $key) { if (!$this->get_target()->is_setting_forced($key)) { if (isset($data->$key)) { $value = $data->$key; } else { $value = configuration::TOURDEFAULT; } if ($value === configuration::TOURDEFAULT) { $this->set_config($key, null); } else { $this->set_config($key, $value); } } } $this->persist(); return $this; }
[ "public", "function", "handle_form_submission", "(", "local", "\\", "forms", "\\", "editstep", "&", "$", "mform", ",", "\\", "stdClass", "$", "data", ")", "{", "$", "this", "->", "set_title", "(", "$", "data", "->", "title", ")", ";", "$", "this", "->", "set_content", "(", "$", "data", "->", "content", ")", ";", "$", "this", "->", "set_targettype", "(", "$", "data", "->", "targettype", ")", ";", "$", "this", "->", "set_targetvalue", "(", "$", "this", "->", "get_target", "(", ")", "->", "get_value_from_form", "(", "$", "data", ")", ")", ";", "foreach", "(", "self", "::", "get_config_keys", "(", ")", "as", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "get_target", "(", ")", "->", "is_setting_forced", "(", "$", "key", ")", ")", "{", "if", "(", "isset", "(", "$", "data", "->", "$", "key", ")", ")", "{", "$", "value", "=", "$", "data", "->", "$", "key", ";", "}", "else", "{", "$", "value", "=", "configuration", "::", "TOURDEFAULT", ";", "}", "if", "(", "$", "value", "===", "configuration", "::", "TOURDEFAULT", ")", "{", "$", "this", "->", "set_config", "(", "$", "key", ",", "null", ")", ";", "}", "else", "{", "$", "this", "->", "set_config", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}", "$", "this", "->", "persist", "(", ")", ";", "return", "$", "this", ";", "}" ]
Handle submission of the step editing form. @param local\forms\editstep $mform The sumitted form. @param stdClass $data The submitted data. @return $this
[ "Handle", "submission", "of", "the", "step", "editing", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L626-L651
219,046
moodle/moodle
admin/tool/usertours/classes/step.php
step.get_string_from_input
public static function get_string_from_input($string) { $string = trim($string); if (preg_match('|^([a-zA-Z][a-zA-Z0-9\.:/_-]*),([a-zA-Z][a-zA-Z0-9\.:/_-]*)$|', $string, $matches)) { if ($matches[2] === 'moodle') { $matches[2] = 'core'; } if (get_string_manager()->string_exists($matches[1], $matches[2])) { $string = get_string($matches[1], $matches[2]); } } return $string; }
php
public static function get_string_from_input($string) { $string = trim($string); if (preg_match('|^([a-zA-Z][a-zA-Z0-9\.:/_-]*),([a-zA-Z][a-zA-Z0-9\.:/_-]*)$|', $string, $matches)) { if ($matches[2] === 'moodle') { $matches[2] = 'core'; } if (get_string_manager()->string_exists($matches[1], $matches[2])) { $string = get_string($matches[1], $matches[2]); } } return $string; }
[ "public", "static", "function", "get_string_from_input", "(", "$", "string", ")", "{", "$", "string", "=", "trim", "(", "$", "string", ")", ";", "if", "(", "preg_match", "(", "'|^([a-zA-Z][a-zA-Z0-9\\.:/_-]*),([a-zA-Z][a-zA-Z0-9\\.:/_-]*)$|'", ",", "$", "string", ",", "$", "matches", ")", ")", "{", "if", "(", "$", "matches", "[", "2", "]", "===", "'moodle'", ")", "{", "$", "matches", "[", "2", "]", "=", "'core'", ";", "}", "if", "(", "get_string_manager", "(", ")", "->", "string_exists", "(", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "string", "=", "get_string", "(", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ")", ";", "}", "}", "return", "$", "string", ";", "}" ]
Attempt to fetch any matching langstring if the string is in the format identifier,component. @param string $string @return string
[ "Attempt", "to", "fetch", "any", "matching", "langstring", "if", "the", "string", "is", "in", "the", "format", "identifier", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/usertours/classes/step.php#L660-L674
219,047
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.setValue
function setValue($value) { $this->_createElementsIfNotExist(); foreach (array_keys($this->_elements) as $key) { if (!$this->_appendName) { $v = $this->_elements[$key]->_findValue($value); if (null !== $v) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $v, $this); } } else { $elementName = $this->_elements[$key]->getName(); $index = strlen($elementName) ? $elementName : $key; if (is_array($value)) { if (isset($value[$index])) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this); } } elseif (isset($value)) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value, $this); } } } }
php
function setValue($value) { $this->_createElementsIfNotExist(); foreach (array_keys($this->_elements) as $key) { if (!$this->_appendName) { $v = $this->_elements[$key]->_findValue($value); if (null !== $v) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $v, $this); } } else { $elementName = $this->_elements[$key]->getName(); $index = strlen($elementName) ? $elementName : $key; if (is_array($value)) { if (isset($value[$index])) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this); } } elseif (isset($value)) { $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value, $this); } } } }
[ "function", "setValue", "(", "$", "value", ")", "{", "$", "this", "->", "_createElementsIfNotExist", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "_elements", ")", "as", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "_appendName", ")", "{", "$", "v", "=", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "_findValue", "(", "$", "value", ")", ";", "if", "(", "null", "!==", "$", "v", ")", "{", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "onQuickFormEvent", "(", "'setGroupValue'", ",", "$", "v", ",", "$", "this", ")", ";", "}", "}", "else", "{", "$", "elementName", "=", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "getName", "(", ")", ";", "$", "index", "=", "strlen", "(", "$", "elementName", ")", "?", "$", "elementName", ":", "$", "key", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "$", "index", "]", ")", ")", "{", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "onQuickFormEvent", "(", "'setGroupValue'", ",", "$", "value", "[", "$", "index", "]", ",", "$", "this", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "value", ")", ")", "{", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "onQuickFormEvent", "(", "'setGroupValue'", ",", "$", "value", ",", "$", "this", ")", ";", "}", "}", "}", "}" ]
Sets values for group's elements @param mixed Values for group's elements @since 1.0 @access public @return void
[ "Sets", "values", "for", "group", "s", "elements" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L161-L183
219,048
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.getValue
function getValue() { $value = null; foreach (array_keys($this->_elements) as $key) { $element =& $this->_elements[$key]; switch ($element->getType()) { case 'radio': $v = $element->getChecked()? $element->getValue(): null; break; case 'checkbox': $v = $element->getChecked()? true: null; break; default: $v = $element->getValue(); } if (null !== $v) { $elementName = $element->getName(); if (is_null($elementName)) { $value = $v; } else { if (!is_array($value)) { $value = is_null($value)? array(): array($value); } if ('' === $elementName) { $value[] = $v; } else { $value[$elementName] = $v; } } } } return $value; }
php
function getValue() { $value = null; foreach (array_keys($this->_elements) as $key) { $element =& $this->_elements[$key]; switch ($element->getType()) { case 'radio': $v = $element->getChecked()? $element->getValue(): null; break; case 'checkbox': $v = $element->getChecked()? true: null; break; default: $v = $element->getValue(); } if (null !== $v) { $elementName = $element->getName(); if (is_null($elementName)) { $value = $v; } else { if (!is_array($value)) { $value = is_null($value)? array(): array($value); } if ('' === $elementName) { $value[] = $v; } else { $value[$elementName] = $v; } } } } return $value; }
[ "function", "getValue", "(", ")", "{", "$", "value", "=", "null", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "_elements", ")", "as", "$", "key", ")", "{", "$", "element", "=", "&", "$", "this", "->", "_elements", "[", "$", "key", "]", ";", "switch", "(", "$", "element", "->", "getType", "(", ")", ")", "{", "case", "'radio'", ":", "$", "v", "=", "$", "element", "->", "getChecked", "(", ")", "?", "$", "element", "->", "getValue", "(", ")", ":", "null", ";", "break", ";", "case", "'checkbox'", ":", "$", "v", "=", "$", "element", "->", "getChecked", "(", ")", "?", "true", ":", "null", ";", "break", ";", "default", ":", "$", "v", "=", "$", "element", "->", "getValue", "(", ")", ";", "}", "if", "(", "null", "!==", "$", "v", ")", "{", "$", "elementName", "=", "$", "element", "->", "getName", "(", ")", ";", "if", "(", "is_null", "(", "$", "elementName", ")", ")", "{", "$", "value", "=", "$", "v", ";", "}", "else", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "is_null", "(", "$", "value", ")", "?", "array", "(", ")", ":", "array", "(", "$", "value", ")", ";", "}", "if", "(", "''", "===", "$", "elementName", ")", "{", "$", "value", "[", "]", "=", "$", "v", ";", "}", "else", "{", "$", "value", "[", "$", "elementName", "]", "=", "$", "v", ";", "}", "}", "}", "}", "return", "$", "value", ";", "}" ]
Returns the value of the group @since 1.0 @access public @return mixed
[ "Returns", "the", "value", "of", "the", "group" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L195-L227
219,049
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.setElements
function setElements($elements) { $this->_elements = array_values($elements); if ($this->_flagFrozen) { $this->freeze(); } }
php
function setElements($elements) { $this->_elements = array_values($elements); if ($this->_flagFrozen) { $this->freeze(); } }
[ "function", "setElements", "(", "$", "elements", ")", "{", "$", "this", "->", "_elements", "=", "array_values", "(", "$", "elements", ")", ";", "if", "(", "$", "this", "->", "_flagFrozen", ")", "{", "$", "this", "->", "freeze", "(", ")", ";", "}", "}" ]
Sets the grouped elements @param array $elements Array of elements @since 1.1 @access public @return void
[ "Sets", "the", "grouped", "elements" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L240-L246
219,050
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.getGroupType
function getGroupType() { $this->_createElementsIfNotExist(); $prevType = ''; foreach (array_keys($this->_elements) as $key) { $type = $this->_elements[$key]->getType(); if ($type != $prevType && $prevType != '') { return 'mixed'; } $prevType = $type; } return $type; }
php
function getGroupType() { $this->_createElementsIfNotExist(); $prevType = ''; foreach (array_keys($this->_elements) as $key) { $type = $this->_elements[$key]->getType(); if ($type != $prevType && $prevType != '') { return 'mixed'; } $prevType = $type; } return $type; }
[ "function", "getGroupType", "(", ")", "{", "$", "this", "->", "_createElementsIfNotExist", "(", ")", ";", "$", "prevType", "=", "''", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "_elements", ")", "as", "$", "key", ")", "{", "$", "type", "=", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "getType", "(", ")", ";", "if", "(", "$", "type", "!=", "$", "prevType", "&&", "$", "prevType", "!=", "''", ")", "{", "return", "'mixed'", ";", "}", "$", "prevType", "=", "$", "type", ";", "}", "return", "$", "type", ";", "}" ]
Gets the group type based on its elements Will return 'mixed' if elements contained in the group are of different types. @access public @return string group elements type
[ "Gets", "the", "group", "type", "based", "on", "its", "elements", "Will", "return", "mixed", "if", "elements", "contained", "in", "the", "group", "are", "of", "different", "types", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L275-L287
219,051
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.toHtml
function toHtml() { include_once('HTML/QuickForm/Renderer/Default.php'); $renderer = new HTML_QuickForm_Renderer_Default(); $renderer->setElementTemplate('{element}'); $this->accept($renderer); return $renderer->toHtml(); }
php
function toHtml() { include_once('HTML/QuickForm/Renderer/Default.php'); $renderer = new HTML_QuickForm_Renderer_Default(); $renderer->setElementTemplate('{element}'); $this->accept($renderer); return $renderer->toHtml(); }
[ "function", "toHtml", "(", ")", "{", "include_once", "(", "'HTML/QuickForm/Renderer/Default.php'", ")", ";", "$", "renderer", "=", "new", "HTML_QuickForm_Renderer_Default", "(", ")", ";", "$", "renderer", "->", "setElementTemplate", "(", "'{element}'", ")", ";", "$", "this", "->", "accept", "(", "$", "renderer", ")", ";", "return", "$", "renderer", "->", "toHtml", "(", ")", ";", "}" ]
Returns Html for the group @since 1.0 @access public @return string
[ "Returns", "Html", "for", "the", "group" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L299-L306
219,052
moodle/moodle
lib/pear/HTML/QuickForm/group.php
HTML_QuickForm_group.getElementName
function getElementName($index) { $this->_createElementsIfNotExist(); $elementName = false; if (is_int($index) && isset($this->_elements[$index])) { $elementName = $this->_elements[$index]->getName(); if (isset($elementName) && $elementName == '') { $elementName = $index; } if ($this->_appendName) { if (is_null($elementName)) { $elementName = $this->getName(); } else { $elementName = $this->getName().'['.$elementName.']'; } } } elseif (is_string($index)) { foreach (array_keys($this->_elements) as $key) { $elementName = $this->_elements[$key]->getName(); if ($index == $elementName) { if ($this->_appendName) { $elementName = $this->getName().'['.$elementName.']'; } break; } elseif ($this->_appendName && $this->getName().'['.$elementName.']' == $index) { break; } } } return $elementName; }
php
function getElementName($index) { $this->_createElementsIfNotExist(); $elementName = false; if (is_int($index) && isset($this->_elements[$index])) { $elementName = $this->_elements[$index]->getName(); if (isset($elementName) && $elementName == '') { $elementName = $index; } if ($this->_appendName) { if (is_null($elementName)) { $elementName = $this->getName(); } else { $elementName = $this->getName().'['.$elementName.']'; } } } elseif (is_string($index)) { foreach (array_keys($this->_elements) as $key) { $elementName = $this->_elements[$key]->getName(); if ($index == $elementName) { if ($this->_appendName) { $elementName = $this->getName().'['.$elementName.']'; } break; } elseif ($this->_appendName && $this->getName().'['.$elementName.']' == $index) { break; } } } return $elementName; }
[ "function", "getElementName", "(", "$", "index", ")", "{", "$", "this", "->", "_createElementsIfNotExist", "(", ")", ";", "$", "elementName", "=", "false", ";", "if", "(", "is_int", "(", "$", "index", ")", "&&", "isset", "(", "$", "this", "->", "_elements", "[", "$", "index", "]", ")", ")", "{", "$", "elementName", "=", "$", "this", "->", "_elements", "[", "$", "index", "]", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "elementName", ")", "&&", "$", "elementName", "==", "''", ")", "{", "$", "elementName", "=", "$", "index", ";", "}", "if", "(", "$", "this", "->", "_appendName", ")", "{", "if", "(", "is_null", "(", "$", "elementName", ")", ")", "{", "$", "elementName", "=", "$", "this", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "elementName", "=", "$", "this", "->", "getName", "(", ")", ".", "'['", ".", "$", "elementName", ".", "']'", ";", "}", "}", "}", "elseif", "(", "is_string", "(", "$", "index", ")", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "_elements", ")", "as", "$", "key", ")", "{", "$", "elementName", "=", "$", "this", "->", "_elements", "[", "$", "key", "]", "->", "getName", "(", ")", ";", "if", "(", "$", "index", "==", "$", "elementName", ")", "{", "if", "(", "$", "this", "->", "_appendName", ")", "{", "$", "elementName", "=", "$", "this", "->", "getName", "(", ")", ".", "'['", ".", "$", "elementName", ".", "']'", ";", "}", "break", ";", "}", "elseif", "(", "$", "this", "->", "_appendName", "&&", "$", "this", "->", "getName", "(", ")", ".", "'['", ".", "$", "elementName", ".", "']'", "==", "$", "index", ")", "{", "break", ";", "}", "}", "}", "return", "$", "elementName", ";", "}" ]
Returns the element name inside the group such as found in the html form @param mixed $index Element name or element index in the group @since 3.0 @access public @return mixed string with element name, false if not found
[ "Returns", "the", "element", "name", "inside", "the", "group", "such", "as", "found", "in", "the", "html", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/group.php#L319-L350
219,053
moodle/moodle
admin/tool/dataprivacy/classes/context_instance.php
context_instance.get_record_by_contextid
public static function get_record_by_contextid($contextid, $exception = true) { global $DB; if (!$record = $DB->get_record(self::TABLE, array('contextid' => $contextid))) { if (!$exception) { return false; } else { throw new \dml_missing_record_exception(self::TABLE); } } return new static(0, $record); }
php
public static function get_record_by_contextid($contextid, $exception = true) { global $DB; if (!$record = $DB->get_record(self::TABLE, array('contextid' => $contextid))) { if (!$exception) { return false; } else { throw new \dml_missing_record_exception(self::TABLE); } } return new static(0, $record); }
[ "public", "static", "function", "get_record_by_contextid", "(", "$", "contextid", ",", "$", "exception", "=", "true", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "record", "=", "$", "DB", "->", "get_record", "(", "self", "::", "TABLE", ",", "array", "(", "'contextid'", "=>", "$", "contextid", ")", ")", ")", "{", "if", "(", "!", "$", "exception", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "new", "\\", "dml_missing_record_exception", "(", "self", "::", "TABLE", ")", ";", "}", "}", "return", "new", "static", "(", "0", ",", "$", "record", ")", ";", "}" ]
Returns an instance by contextid. @param mixed $contextid @param mixed $exception @return null
[ "Returns", "an", "instance", "by", "contextid", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/context_instance.php#L81-L93
219,054
moodle/moodle
admin/tool/uploadcourse/classes/step2_form.php
tool_uploadcourse_step2_form.add_action_buttons
public function add_action_buttons($cancel = true, $submitlabel = null) { $mform =& $this->_form; $buttonarray = array(); $buttonarray[] = &$mform->createElement('submit', 'showpreview', get_string('preview', 'tool_uploadcourse')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); $buttonarray[] = &$mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
php
public function add_action_buttons($cancel = true, $submitlabel = null) { $mform =& $this->_form; $buttonarray = array(); $buttonarray[] = &$mform->createElement('submit', 'showpreview', get_string('preview', 'tool_uploadcourse')); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); $buttonarray[] = &$mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
[ "public", "function", "add_action_buttons", "(", "$", "cancel", "=", "true", ",", "$", "submitlabel", "=", "null", ")", "{", "$", "mform", "=", "&", "$", "this", "->", "_form", ";", "$", "buttonarray", "=", "array", "(", ")", ";", "$", "buttonarray", "[", "]", "=", "&", "$", "mform", "->", "createElement", "(", "'submit'", ",", "'showpreview'", ",", "get_string", "(", "'preview'", ",", "'tool_uploadcourse'", ")", ")", ";", "$", "buttonarray", "[", "]", "=", "&", "$", "mform", "->", "createElement", "(", "'submit'", ",", "'submitbutton'", ",", "$", "submitlabel", ")", ";", "$", "buttonarray", "[", "]", "=", "&", "$", "mform", "->", "createElement", "(", "'cancel'", ")", ";", "$", "mform", "->", "addGroup", "(", "$", "buttonarray", ",", "'buttonar'", ",", "''", ",", "array", "(", "' '", ")", ",", "false", ")", ";", "$", "mform", "->", "closeHeaderBefore", "(", "'buttonar'", ")", ";", "}" ]
Add actopm buttons. @param bool $cancel whether to show cancel button, default true @param string $submitlabel label for submit button, defaults to get_string('savechanges') @return void
[ "Add", "actopm", "buttons", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/step2_form.php#L195-L203
219,055
moodle/moodle
admin/tool/uploadcourse/classes/step2_form.php
tool_uploadcourse_step2_form.definition_after_data
public function definition_after_data() { $mform = $this->_form; // The default end date depends on the course format. $format = course_get_format((object)array('format' => get_config('moodlecourse', 'format'))); // Check if course end date form field should be enabled by default. // If a default date is provided to the form element, it is magically enabled by default in the // MoodleQuickForm_date_time_selector class, otherwise it's disabled by default. if (get_config('moodlecourse', 'courseenddateenabled')) { $enddate = $format->get_default_course_enddate($mform, array('startdate' => 'defaults[startdate]')); $mform->setDefault('defaults[enddate]', $enddate); } }
php
public function definition_after_data() { $mform = $this->_form; // The default end date depends on the course format. $format = course_get_format((object)array('format' => get_config('moodlecourse', 'format'))); // Check if course end date form field should be enabled by default. // If a default date is provided to the form element, it is magically enabled by default in the // MoodleQuickForm_date_time_selector class, otherwise it's disabled by default. if (get_config('moodlecourse', 'courseenddateenabled')) { $enddate = $format->get_default_course_enddate($mform, array('startdate' => 'defaults[startdate]')); $mform->setDefault('defaults[enddate]', $enddate); } }
[ "public", "function", "definition_after_data", "(", ")", "{", "$", "mform", "=", "$", "this", "->", "_form", ";", "// The default end date depends on the course format.", "$", "format", "=", "course_get_format", "(", "(", "object", ")", "array", "(", "'format'", "=>", "get_config", "(", "'moodlecourse'", ",", "'format'", ")", ")", ")", ";", "// Check if course end date form field should be enabled by default.", "// If a default date is provided to the form element, it is magically enabled by default in the", "// MoodleQuickForm_date_time_selector class, otherwise it's disabled by default.", "if", "(", "get_config", "(", "'moodlecourse'", ",", "'courseenddateenabled'", ")", ")", "{", "$", "enddate", "=", "$", "format", "->", "get_default_course_enddate", "(", "$", "mform", ",", "array", "(", "'startdate'", "=>", "'defaults[startdate]'", ")", ")", ";", "$", "mform", "->", "setDefault", "(", "'defaults[enddate]'", ",", "$", "enddate", ")", ";", "}", "}" ]
Sets the enddate default after set_data is called.
[ "Sets", "the", "enddate", "default", "after", "set_data", "is", "called", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/step2_form.php#L208-L222
219,056
moodle/moodle
course/externallib.php
core_course_external.delete_modules
public static function delete_modules($cmids) { global $CFG, $DB; // Require course file containing the course delete module function. require_once($CFG->dirroot . "/course/lib.php"); // Clean the parameters. $params = self::validate_parameters(self::delete_modules_parameters(), array('cmids' => $cmids)); // Keep track of the course ids we have performed a capability check on to avoid repeating. $arrcourseschecked = array(); foreach ($params['cmids'] as $cmid) { // Get the course module. $cm = $DB->get_record('course_modules', array('id' => $cmid), '*', MUST_EXIST); // Check if we have not yet confirmed they have permission in this course. if (!in_array($cm->course, $arrcourseschecked)) { // Ensure the current user has required permission in this course. $context = context_course::instance($cm->course); self::validate_context($context); // Add to the array. $arrcourseschecked[] = $cm->course; } // Ensure they can delete this module. $modcontext = context_module::instance($cm->id); require_capability('moodle/course:manageactivities', $modcontext); // Delete the module. course_delete_module($cm->id); } }
php
public static function delete_modules($cmids) { global $CFG, $DB; // Require course file containing the course delete module function. require_once($CFG->dirroot . "/course/lib.php"); // Clean the parameters. $params = self::validate_parameters(self::delete_modules_parameters(), array('cmids' => $cmids)); // Keep track of the course ids we have performed a capability check on to avoid repeating. $arrcourseschecked = array(); foreach ($params['cmids'] as $cmid) { // Get the course module. $cm = $DB->get_record('course_modules', array('id' => $cmid), '*', MUST_EXIST); // Check if we have not yet confirmed they have permission in this course. if (!in_array($cm->course, $arrcourseschecked)) { // Ensure the current user has required permission in this course. $context = context_course::instance($cm->course); self::validate_context($context); // Add to the array. $arrcourseschecked[] = $cm->course; } // Ensure they can delete this module. $modcontext = context_module::instance($cm->id); require_capability('moodle/course:manageactivities', $modcontext); // Delete the module. course_delete_module($cm->id); } }
[ "public", "static", "function", "delete_modules", "(", "$", "cmids", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "// Require course file containing the course delete module function.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "\"/course/lib.php\"", ")", ";", "// Clean the parameters.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "delete_modules_parameters", "(", ")", ",", "array", "(", "'cmids'", "=>", "$", "cmids", ")", ")", ";", "// Keep track of the course ids we have performed a capability check on to avoid repeating.", "$", "arrcourseschecked", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "[", "'cmids'", "]", "as", "$", "cmid", ")", "{", "// Get the course module.", "$", "cm", "=", "$", "DB", "->", "get_record", "(", "'course_modules'", ",", "array", "(", "'id'", "=>", "$", "cmid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "// Check if we have not yet confirmed they have permission in this course.", "if", "(", "!", "in_array", "(", "$", "cm", "->", "course", ",", "$", "arrcourseschecked", ")", ")", "{", "// Ensure the current user has required permission in this course.", "$", "context", "=", "context_course", "::", "instance", "(", "$", "cm", "->", "course", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "// Add to the array.", "$", "arrcourseschecked", "[", "]", "=", "$", "cm", "->", "course", ";", "}", "// Ensure they can delete this module.", "$", "modcontext", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "require_capability", "(", "'moodle/course:manageactivities'", ",", "$", "modcontext", ")", ";", "// Delete the module.", "course_delete_module", "(", "$", "cm", "->", "id", ")", ";", "}", "}" ]
Deletes a list of provided module instances. @param array $cmids the course module ids @since Moodle 2.5
[ "Deletes", "a", "list", "of", "provided", "module", "instances", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L2242-L2274
219,057
moodle/moodle
course/externallib.php
core_course_external.view_course
public static function view_course($courseid, $sectionnumber = 0) { global $CFG; require_once($CFG->dirroot . "/course/lib.php"); $params = self::validate_parameters(self::view_course_parameters(), array( 'courseid' => $courseid, 'sectionnumber' => $sectionnumber )); $warnings = array(); $course = get_course($params['courseid']); $context = context_course::instance($course->id); self::validate_context($context); if (!empty($params['sectionnumber'])) { // Get section details and check it exists. $modinfo = get_fast_modinfo($course); $coursesection = $modinfo->get_section_info($params['sectionnumber'], MUST_EXIST); // Check user is allowed to see it. if (!$coursesection->uservisible) { require_capability('moodle/course:viewhiddensections', $context); } } course_view($context, $params['sectionnumber']); $result = array(); $result['status'] = true; $result['warnings'] = $warnings; return $result; }
php
public static function view_course($courseid, $sectionnumber = 0) { global $CFG; require_once($CFG->dirroot . "/course/lib.php"); $params = self::validate_parameters(self::view_course_parameters(), array( 'courseid' => $courseid, 'sectionnumber' => $sectionnumber )); $warnings = array(); $course = get_course($params['courseid']); $context = context_course::instance($course->id); self::validate_context($context); if (!empty($params['sectionnumber'])) { // Get section details and check it exists. $modinfo = get_fast_modinfo($course); $coursesection = $modinfo->get_section_info($params['sectionnumber'], MUST_EXIST); // Check user is allowed to see it. if (!$coursesection->uservisible) { require_capability('moodle/course:viewhiddensections', $context); } } course_view($context, $params['sectionnumber']); $result = array(); $result['status'] = true; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "view_course", "(", "$", "courseid", ",", "$", "sectionnumber", "=", "0", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "\"/course/lib.php\"", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "view_course_parameters", "(", ")", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'sectionnumber'", "=>", "$", "sectionnumber", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "course", "=", "get_course", "(", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'sectionnumber'", "]", ")", ")", "{", "// Get section details and check it exists.", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "$", "coursesection", "=", "$", "modinfo", "->", "get_section_info", "(", "$", "params", "[", "'sectionnumber'", "]", ",", "MUST_EXIST", ")", ";", "// Check user is allowed to see it.", "if", "(", "!", "$", "coursesection", "->", "uservisible", ")", "{", "require_capability", "(", "'moodle/course:viewhiddensections'", ",", "$", "context", ")", ";", "}", "}", "course_view", "(", "$", "context", ",", "$", "params", "[", "'sectionnumber'", "]", ")", ";", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'status'", "]", "=", "true", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Trigger the course viewed event. @param int $courseid id of course @param int $sectionnumber sectionnumber (0, 1, 2...) @return array of warnings and status result @since Moodle 2.9 @throws moodle_exception
[ "Trigger", "the", "course", "viewed", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L2310-L2344
219,058
moodle/moodle
course/externallib.php
core_course_external.get_activities_overview
public static function get_activities_overview($courseids) { global $USER; // Parameter validation. $params = self::validate_parameters(self::get_activities_overview_parameters(), array('courseids' => $courseids)); $courseoverviews = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids']); if (!empty($courses)) { // Add lastaccess to each course (required by print_overview function). // We need the complete user data, the ws server does not load a complete one. $user = get_complete_user_data('id', $USER->id); foreach ($courses as $course) { if (isset($user->lastcourseaccess[$course->id])) { $course->lastaccess = $user->lastcourseaccess[$course->id]; } else { $course->lastaccess = 0; } } $overviews = array(); if ($modules = get_plugin_list_with_function('mod', 'print_overview')) { foreach ($modules as $fname) { $fname($courses, $overviews); } } // Format output. foreach ($overviews as $courseid => $modules) { $courseoverviews[$courseid]['id'] = $courseid; $courseoverviews[$courseid]['overviews'] = array(); foreach ($modules as $modname => $overviewtext) { $courseoverviews[$courseid]['overviews'][] = array( 'module' => $modname, 'overviewtext' => $overviewtext // This text doesn't need formatting. ); } } } $result = array( 'courses' => $courseoverviews, 'warnings' => $warnings ); return $result; }
php
public static function get_activities_overview($courseids) { global $USER; // Parameter validation. $params = self::validate_parameters(self::get_activities_overview_parameters(), array('courseids' => $courseids)); $courseoverviews = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids']); if (!empty($courses)) { // Add lastaccess to each course (required by print_overview function). // We need the complete user data, the ws server does not load a complete one. $user = get_complete_user_data('id', $USER->id); foreach ($courses as $course) { if (isset($user->lastcourseaccess[$course->id])) { $course->lastaccess = $user->lastcourseaccess[$course->id]; } else { $course->lastaccess = 0; } } $overviews = array(); if ($modules = get_plugin_list_with_function('mod', 'print_overview')) { foreach ($modules as $fname) { $fname($courses, $overviews); } } // Format output. foreach ($overviews as $courseid => $modules) { $courseoverviews[$courseid]['id'] = $courseid; $courseoverviews[$courseid]['overviews'] = array(); foreach ($modules as $modname => $overviewtext) { $courseoverviews[$courseid]['overviews'][] = array( 'module' => $modname, 'overviewtext' => $overviewtext // This text doesn't need formatting. ); } } } $result = array( 'courses' => $courseoverviews, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_activities_overview", "(", "$", "courseids", ")", "{", "global", "$", "USER", ";", "// Parameter validation.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_activities_overview_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "courseoverviews", "=", "array", "(", ")", ";", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "courses", ")", ")", "{", "// Add lastaccess to each course (required by print_overview function).", "// We need the complete user data, the ws server does not load a complete one.", "$", "user", "=", "get_complete_user_data", "(", "'id'", ",", "$", "USER", "->", "id", ")", ";", "foreach", "(", "$", "courses", "as", "$", "course", ")", "{", "if", "(", "isset", "(", "$", "user", "->", "lastcourseaccess", "[", "$", "course", "->", "id", "]", ")", ")", "{", "$", "course", "->", "lastaccess", "=", "$", "user", "->", "lastcourseaccess", "[", "$", "course", "->", "id", "]", ";", "}", "else", "{", "$", "course", "->", "lastaccess", "=", "0", ";", "}", "}", "$", "overviews", "=", "array", "(", ")", ";", "if", "(", "$", "modules", "=", "get_plugin_list_with_function", "(", "'mod'", ",", "'print_overview'", ")", ")", "{", "foreach", "(", "$", "modules", "as", "$", "fname", ")", "{", "$", "fname", "(", "$", "courses", ",", "$", "overviews", ")", ";", "}", "}", "// Format output.", "foreach", "(", "$", "overviews", "as", "$", "courseid", "=>", "$", "modules", ")", "{", "$", "courseoverviews", "[", "$", "courseid", "]", "[", "'id'", "]", "=", "$", "courseid", ";", "$", "courseoverviews", "[", "$", "courseid", "]", "[", "'overviews'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "modname", "=>", "$", "overviewtext", ")", "{", "$", "courseoverviews", "[", "$", "courseid", "]", "[", "'overviews'", "]", "[", "]", "=", "array", "(", "'module'", "=>", "$", "modname", ",", "'overviewtext'", "=>", "$", "overviewtext", "// This text doesn't need formatting.", ")", ";", "}", "}", "}", "$", "result", "=", "array", "(", "'courses'", "=>", "$", "courseoverviews", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Return activities overview for the given courses. @deprecated since 3.3 @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487. @param array $courseids a list of course ids @return array of warnings and the activities overview @since Moodle 3.2 @throws moodle_exception
[ "Return", "activities", "overview", "for", "the", "given", "courses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L2935-L2982
219,059
moodle/moodle
course/externallib.php
core_course_external.get_user_navigation_options
public static function get_user_navigation_options($courseids) { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); // Parameter validation. $params = self::validate_parameters(self::get_user_navigation_options_parameters(), array('courseids' => $courseids)); $courseoptions = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids'], array(), true); if (!empty($courses)) { foreach ($courses as $course) { // Fix the context for the frontpage. if ($course->id == SITEID) { $course->context = context_system::instance(); } $navoptions = course_get_user_navigation_options($course->context, $course); $options = array(); foreach ($navoptions as $name => $available) { $options[] = array( 'name' => $name, 'available' => $available, ); } $courseoptions[] = array( 'id' => $course->id, 'options' => $options ); } } $result = array( 'courses' => $courseoptions, 'warnings' => $warnings ); return $result; }
php
public static function get_user_navigation_options($courseids) { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); // Parameter validation. $params = self::validate_parameters(self::get_user_navigation_options_parameters(), array('courseids' => $courseids)); $courseoptions = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids'], array(), true); if (!empty($courses)) { foreach ($courses as $course) { // Fix the context for the frontpage. if ($course->id == SITEID) { $course->context = context_system::instance(); } $navoptions = course_get_user_navigation_options($course->context, $course); $options = array(); foreach ($navoptions as $name => $available) { $options[] = array( 'name' => $name, 'available' => $available, ); } $courseoptions[] = array( 'id' => $course->id, 'options' => $options ); } } $result = array( 'courses' => $courseoptions, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_user_navigation_options", "(", "$", "courseids", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "// Parameter validation.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_user_navigation_options_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "courseoptions", "=", "array", "(", ")", ";", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "array", "(", ")", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "courses", ")", ")", "{", "foreach", "(", "$", "courses", "as", "$", "course", ")", "{", "// Fix the context for the frontpage.", "if", "(", "$", "course", "->", "id", "==", "SITEID", ")", "{", "$", "course", "->", "context", "=", "context_system", "::", "instance", "(", ")", ";", "}", "$", "navoptions", "=", "course_get_user_navigation_options", "(", "$", "course", "->", "context", ",", "$", "course", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "navoptions", "as", "$", "name", "=>", "$", "available", ")", "{", "$", "options", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'available'", "=>", "$", "available", ",", ")", ";", "}", "$", "courseoptions", "[", "]", "=", "array", "(", "'id'", "=>", "$", "course", "->", "id", ",", "'options'", "=>", "$", "options", ")", ";", "}", "}", "$", "result", "=", "array", "(", "'courses'", "=>", "$", "courseoptions", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Return a list of navigation options in a set of courses that are avaialable or not for the current user. @param array $courseids a list of course ids @return array of warnings and the options availability @since Moodle 3.2 @throws moodle_exception
[ "Return", "a", "list", "of", "navigation", "options", "in", "a", "set", "of", "courses", "that", "are", "avaialable", "or", "not", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3046-L3083
219,060
moodle/moodle
course/externallib.php
core_course_external.get_user_administration_options
public static function get_user_administration_options($courseids) { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); // Parameter validation. $params = self::validate_parameters(self::get_user_administration_options_parameters(), array('courseids' => $courseids)); $courseoptions = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids'], array(), true); if (!empty($courses)) { foreach ($courses as $course) { $adminoptions = course_get_user_administration_options($course, $course->context); $options = array(); foreach ($adminoptions as $name => $available) { $options[] = array( 'name' => $name, 'available' => $available, ); } $courseoptions[] = array( 'id' => $course->id, 'options' => $options ); } } $result = array( 'courses' => $courseoptions, 'warnings' => $warnings ); return $result; }
php
public static function get_user_administration_options($courseids) { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); // Parameter validation. $params = self::validate_parameters(self::get_user_administration_options_parameters(), array('courseids' => $courseids)); $courseoptions = array(); list($courses, $warnings) = external_util::validate_courses($params['courseids'], array(), true); if (!empty($courses)) { foreach ($courses as $course) { $adminoptions = course_get_user_administration_options($course, $course->context); $options = array(); foreach ($adminoptions as $name => $available) { $options[] = array( 'name' => $name, 'available' => $available, ); } $courseoptions[] = array( 'id' => $course->id, 'options' => $options ); } } $result = array( 'courses' => $courseoptions, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_user_administration_options", "(", "$", "courseids", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/course/lib.php'", ")", ";", "// Parameter validation.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_user_administration_options_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "courseoptions", "=", "array", "(", ")", ";", "list", "(", "$", "courses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "array", "(", ")", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "courses", ")", ")", "{", "foreach", "(", "$", "courses", "as", "$", "course", ")", "{", "$", "adminoptions", "=", "course_get_user_administration_options", "(", "$", "course", ",", "$", "course", "->", "context", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "adminoptions", "as", "$", "name", "=>", "$", "available", ")", "{", "$", "options", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'available'", "=>", "$", "available", ",", ")", ";", "}", "$", "courseoptions", "[", "]", "=", "array", "(", "'id'", "=>", "$", "course", "->", "id", ",", "'options'", "=>", "$", "options", ")", ";", "}", "}", "$", "result", "=", "array", "(", "'courses'", "=>", "$", "courseoptions", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Return a list of administration options in a set of courses that are available or not for the current user. @param array $courseids a list of course ids @return array of warnings and the options availability @since Moodle 3.2 @throws moodle_exception
[ "Return", "a", "list", "of", "administration", "options", "in", "a", "set", "of", "courses", "that", "are", "available", "or", "not", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3136-L3169
219,061
moodle/moodle
course/externallib.php
core_course_external.check_updates
public static function check_updates($courseid, $tocheck, $filter = array()) { global $CFG, $DB; require_once($CFG->dirroot . "/course/lib.php"); $params = self::validate_parameters( self::check_updates_parameters(), array( 'courseid' => $courseid, 'tocheck' => $tocheck, 'filter' => $filter, ) ); $course = get_course($params['courseid']); $context = context_course::instance($course->id); self::validate_context($context); list($instances, $warnings) = course_check_updates($course, $params['tocheck'], $filter); $instancesformatted = array(); foreach ($instances as $instance) { $updates = array(); foreach ($instance['updates'] as $name => $data) { if (empty($data->updated)) { continue; } $updatedata = array( 'name' => $name, ); if (!empty($data->timeupdated)) { $updatedata['timeupdated'] = $data->timeupdated; } if (!empty($data->itemids)) { $updatedata['itemids'] = $data->itemids; } $updates[] = $updatedata; } if (!empty($updates)) { $instancesformatted[] = array( 'contextlevel' => $instance['contextlevel'], 'id' => $instance['id'], 'updates' => $updates ); } } return array( 'instances' => $instancesformatted, 'warnings' => $warnings ); }
php
public static function check_updates($courseid, $tocheck, $filter = array()) { global $CFG, $DB; require_once($CFG->dirroot . "/course/lib.php"); $params = self::validate_parameters( self::check_updates_parameters(), array( 'courseid' => $courseid, 'tocheck' => $tocheck, 'filter' => $filter, ) ); $course = get_course($params['courseid']); $context = context_course::instance($course->id); self::validate_context($context); list($instances, $warnings) = course_check_updates($course, $params['tocheck'], $filter); $instancesformatted = array(); foreach ($instances as $instance) { $updates = array(); foreach ($instance['updates'] as $name => $data) { if (empty($data->updated)) { continue; } $updatedata = array( 'name' => $name, ); if (!empty($data->timeupdated)) { $updatedata['timeupdated'] = $data->timeupdated; } if (!empty($data->itemids)) { $updatedata['itemids'] = $data->itemids; } $updates[] = $updatedata; } if (!empty($updates)) { $instancesformatted[] = array( 'contextlevel' => $instance['contextlevel'], 'id' => $instance['id'], 'updates' => $updates ); } } return array( 'instances' => $instancesformatted, 'warnings' => $warnings ); }
[ "public", "static", "function", "check_updates", "(", "$", "courseid", ",", "$", "tocheck", ",", "$", "filter", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "\"/course/lib.php\"", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "check_updates_parameters", "(", ")", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'tocheck'", "=>", "$", "tocheck", ",", "'filter'", "=>", "$", "filter", ",", ")", ")", ";", "$", "course", "=", "get_course", "(", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "list", "(", "$", "instances", ",", "$", "warnings", ")", "=", "course_check_updates", "(", "$", "course", ",", "$", "params", "[", "'tocheck'", "]", ",", "$", "filter", ")", ";", "$", "instancesformatted", "=", "array", "(", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instance", ")", "{", "$", "updates", "=", "array", "(", ")", ";", "foreach", "(", "$", "instance", "[", "'updates'", "]", "as", "$", "name", "=>", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", "->", "updated", ")", ")", "{", "continue", ";", "}", "$", "updatedata", "=", "array", "(", "'name'", "=>", "$", "name", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "timeupdated", ")", ")", "{", "$", "updatedata", "[", "'timeupdated'", "]", "=", "$", "data", "->", "timeupdated", ";", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "itemids", ")", ")", "{", "$", "updatedata", "[", "'itemids'", "]", "=", "$", "data", "->", "itemids", ";", "}", "$", "updates", "[", "]", "=", "$", "updatedata", ";", "}", "if", "(", "!", "empty", "(", "$", "updates", ")", ")", "{", "$", "instancesformatted", "[", "]", "=", "array", "(", "'contextlevel'", "=>", "$", "instance", "[", "'contextlevel'", "]", ",", "'id'", "=>", "$", "instance", "[", "'id'", "]", ",", "'updates'", "=>", "$", "updates", ")", ";", "}", "}", "return", "array", "(", "'instances'", "=>", "$", "instancesformatted", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "}" ]
Check if there is updates affecting the user for the given course and contexts. Right now only modules are supported. This WS calls mod_check_updates_since for each module to check if there is any update the user should we aware of. @param int $courseid the list of modules to check @param array $tocheck the list of modules to check @param array $filter check only for updates in these areas @return array list of updates and warnings @throws moodle_exception @since Moodle 3.2
[ "Check", "if", "there", "is", "updates", "affecting", "the", "user", "for", "the", "given", "course", "and", "contexts", ".", "Right", "now", "only", "modules", "are", "supported", ".", "This", "WS", "calls", "mod_check_updates_since", "for", "each", "module", "to", "check", "if", "there", "is", "any", "update", "the", "user", "should", "we", "aware", "of", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3378-L3428
219,062
moodle/moodle
course/externallib.php
core_course_external.get_updates_since
public static function get_updates_since($courseid, $since, $filter = array()) { global $CFG, $DB; $params = self::validate_parameters( self::get_updates_since_parameters(), array( 'courseid' => $courseid, 'since' => $since, 'filter' => $filter, ) ); $course = get_course($params['courseid']); $modinfo = get_fast_modinfo($course); $tocheck = array(); // Retrieve all the visible course modules for the current user. $cms = $modinfo->get_cms(); foreach ($cms as $cm) { if (!$cm->uservisible) { continue; } $tocheck[] = array( 'id' => $cm->id, 'contextlevel' => 'module', 'since' => $params['since'], ); } return self::check_updates($course->id, $tocheck, $params['filter']); }
php
public static function get_updates_since($courseid, $since, $filter = array()) { global $CFG, $DB; $params = self::validate_parameters( self::get_updates_since_parameters(), array( 'courseid' => $courseid, 'since' => $since, 'filter' => $filter, ) ); $course = get_course($params['courseid']); $modinfo = get_fast_modinfo($course); $tocheck = array(); // Retrieve all the visible course modules for the current user. $cms = $modinfo->get_cms(); foreach ($cms as $cm) { if (!$cm->uservisible) { continue; } $tocheck[] = array( 'id' => $cm->id, 'contextlevel' => 'module', 'since' => $params['since'], ); } return self::check_updates($course->id, $tocheck, $params['filter']); }
[ "public", "static", "function", "get_updates_since", "(", "$", "courseid", ",", "$", "since", ",", "$", "filter", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_updates_since_parameters", "(", ")", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'since'", "=>", "$", "since", ",", "'filter'", "=>", "$", "filter", ",", ")", ")", ";", "$", "course", "=", "get_course", "(", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "course", ")", ";", "$", "tocheck", "=", "array", "(", ")", ";", "// Retrieve all the visible course modules for the current user.", "$", "cms", "=", "$", "modinfo", "->", "get_cms", "(", ")", ";", "foreach", "(", "$", "cms", "as", "$", "cm", ")", "{", "if", "(", "!", "$", "cm", "->", "uservisible", ")", "{", "continue", ";", "}", "$", "tocheck", "[", "]", "=", "array", "(", "'id'", "=>", "$", "cm", "->", "id", ",", "'contextlevel'", "=>", "'module'", ",", "'since'", "=>", "$", "params", "[", "'since'", "]", ",", ")", ";", "}", "return", "self", "::", "check_updates", "(", "$", "course", "->", "id", ",", "$", "tocheck", ",", "$", "params", "[", "'filter'", "]", ")", ";", "}" ]
Check if there are updates affecting the user for the given course since the given time stamp. This function is a wrapper of self::check_updates for retrieving all the updates since a given time for all the activities. @param int $courseid the list of modules to check @param int $since check updates since this time stamp @param array $filter check only for updates in these areas @return array list of updates and warnings @throws moodle_exception @since Moodle 3.3
[ "Check", "if", "there", "are", "updates", "affecting", "the", "user", "for", "the", "given", "course", "since", "the", "given", "time", "stamp", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3497-L3527
219,063
moodle/moodle
course/externallib.php
core_course_external.get_module
public static function get_module($id, $sectionreturn = null) { global $PAGE; // Validate and normalize parameters. $params = self::validate_parameters(self::get_module_parameters(), array('id' => $id, 'sectionreturn' => $sectionreturn)); $id = $params['id']; $sectionreturn = $params['sectionreturn']; // Set of permissions an editing user may have. $contextarray = [ 'moodle/course:update', 'moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/course:sectionvisibility', 'moodle/course:movesections', 'moodle/course:setcurrentsection', ]; $PAGE->set_other_editing_capability($contextarray); // Validate access to the course (note, this is html for the course view page, we don't validate access to the module). list($course, $cm) = get_course_and_cm_from_cmid($id); self::validate_context(context_course::instance($course->id)); $courserenderer = $PAGE->get_renderer('core', 'course'); $completioninfo = new completion_info($course); return $courserenderer->course_section_cm_list_item($course, $completioninfo, $cm, $sectionreturn); }
php
public static function get_module($id, $sectionreturn = null) { global $PAGE; // Validate and normalize parameters. $params = self::validate_parameters(self::get_module_parameters(), array('id' => $id, 'sectionreturn' => $sectionreturn)); $id = $params['id']; $sectionreturn = $params['sectionreturn']; // Set of permissions an editing user may have. $contextarray = [ 'moodle/course:update', 'moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/course:sectionvisibility', 'moodle/course:movesections', 'moodle/course:setcurrentsection', ]; $PAGE->set_other_editing_capability($contextarray); // Validate access to the course (note, this is html for the course view page, we don't validate access to the module). list($course, $cm) = get_course_and_cm_from_cmid($id); self::validate_context(context_course::instance($course->id)); $courserenderer = $PAGE->get_renderer('core', 'course'); $completioninfo = new completion_info($course); return $courserenderer->course_section_cm_list_item($course, $completioninfo, $cm, $sectionreturn); }
[ "public", "static", "function", "get_module", "(", "$", "id", ",", "$", "sectionreturn", "=", "null", ")", "{", "global", "$", "PAGE", ";", "// Validate and normalize parameters.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_module_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", "'sectionreturn'", "=>", "$", "sectionreturn", ")", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "sectionreturn", "=", "$", "params", "[", "'sectionreturn'", "]", ";", "// Set of permissions an editing user may have.", "$", "contextarray", "=", "[", "'moodle/course:update'", ",", "'moodle/course:manageactivities'", ",", "'moodle/course:activityvisibility'", ",", "'moodle/course:sectionvisibility'", ",", "'moodle/course:movesections'", ",", "'moodle/course:setcurrentsection'", ",", "]", ";", "$", "PAGE", "->", "set_other_editing_capability", "(", "$", "contextarray", ")", ";", "// Validate access to the course (note, this is html for the course view page, we don't validate access to the module).", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_cmid", "(", "$", "id", ")", ";", "self", "::", "validate_context", "(", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ")", ";", "$", "courserenderer", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ",", "'course'", ")", ";", "$", "completioninfo", "=", "new", "completion_info", "(", "$", "course", ")", ";", "return", "$", "courserenderer", "->", "course_section_cm_list_item", "(", "$", "course", ",", "$", "completioninfo", ",", "$", "cm", ",", "$", "sectionreturn", ")", ";", "}" ]
Returns html for displaying one activity module on course page @since Moodle 3.3 @param int $id @param null|int $sectionreturn @return string
[ "Returns", "html", "for", "displaying", "one", "activity", "module", "on", "course", "page" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3690-L3716
219,064
moodle/moodle
course/externallib.php
core_course_external.edit_section
public static function edit_section($action, $id, $sectionreturn) { global $DB; // Validate and normalize parameters. $params = self::validate_parameters(self::edit_section_parameters(), array('action' => $action, 'id' => $id, 'sectionreturn' => $sectionreturn)); $action = $params['action']; $id = $params['id']; $sr = $params['sectionreturn']; $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST); $coursecontext = context_course::instance($section->course); self::validate_context($coursecontext); $rv = course_get_format($section->course)->section_action($section, $action, $sectionreturn); if ($rv) { return json_encode($rv); } else { return null; } }
php
public static function edit_section($action, $id, $sectionreturn) { global $DB; // Validate and normalize parameters. $params = self::validate_parameters(self::edit_section_parameters(), array('action' => $action, 'id' => $id, 'sectionreturn' => $sectionreturn)); $action = $params['action']; $id = $params['id']; $sr = $params['sectionreturn']; $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST); $coursecontext = context_course::instance($section->course); self::validate_context($coursecontext); $rv = course_get_format($section->course)->section_action($section, $action, $sectionreturn); if ($rv) { return json_encode($rv); } else { return null; } }
[ "public", "static", "function", "edit_section", "(", "$", "action", ",", "$", "id", ",", "$", "sectionreturn", ")", "{", "global", "$", "DB", ";", "// Validate and normalize parameters.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "edit_section_parameters", "(", ")", ",", "array", "(", "'action'", "=>", "$", "action", ",", "'id'", "=>", "$", "id", ",", "'sectionreturn'", "=>", "$", "sectionreturn", ")", ")", ";", "$", "action", "=", "$", "params", "[", "'action'", "]", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "sr", "=", "$", "params", "[", "'sectionreturn'", "]", ";", "$", "section", "=", "$", "DB", "->", "get_record", "(", "'course_sections'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "$", "coursecontext", "=", "context_course", "::", "instance", "(", "$", "section", "->", "course", ")", ";", "self", "::", "validate_context", "(", "$", "coursecontext", ")", ";", "$", "rv", "=", "course_get_format", "(", "$", "section", "->", "course", ")", "->", "section_action", "(", "$", "section", ",", "$", "action", ",", "$", "sectionreturn", ")", ";", "if", "(", "$", "rv", ")", "{", "return", "json_encode", "(", "$", "rv", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Performs one of the edit section actions @since Moodle 3.3 @param string $action @param int $id section id @param int $sectionreturn section to return to @return string
[ "Performs", "one", "of", "the", "edit", "section", "actions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3752-L3771
219,065
moodle/moodle
course/externallib.php
core_course_external.set_favourite_courses
public static function set_favourite_courses( array $courses ) { global $USER; $params = self::validate_parameters(self::set_favourite_courses_parameters(), array( 'courses' => $courses ) ); $warnings = []; $ufservice = \core_favourites\service_factory::get_service_for_user_context(\context_user::instance($USER->id)); foreach ($params['courses'] as $course) { $warning = []; $favouriteexists = $ufservice->favourite_exists('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); if ($course['favourite']) { if (!$favouriteexists) { try { $ufservice->create_favourite('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); } catch (Exception $e) { $warning['courseid'] = $course['id']; if ($e instanceof moodle_exception) { $warning['warningcode'] = $e->errorcode; } else { $warning['warningcode'] = $e->getCode(); } $warning['message'] = $e->getMessage(); $warnings[] = $warning; $warnings[] = $warning; } } else { $warning['courseid'] = $course['id']; $warning['warningcode'] = 'coursealreadyfavourited'; $warning['message'] = 'Course already favourited'; $warnings[] = $warning; } } else { if ($favouriteexists) { try { $ufservice->delete_favourite('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); } catch (Exception $e) { $warning['courseid'] = $course['id']; if ($e instanceof moodle_exception) { $warning['warningcode'] = $e->errorcode; } else { $warning['warningcode'] = $e->getCode(); } $warning['message'] = $e->getMessage(); $warnings[] = $warning; $warnings[] = $warning; } } else { $warning['courseid'] = $course['id']; $warning['warningcode'] = 'cannotdeletefavourite'; $warning['message'] = 'Could not delete favourite status for course'; $warnings[] = $warning; } } } return [ 'warnings' => $warnings ]; }
php
public static function set_favourite_courses( array $courses ) { global $USER; $params = self::validate_parameters(self::set_favourite_courses_parameters(), array( 'courses' => $courses ) ); $warnings = []; $ufservice = \core_favourites\service_factory::get_service_for_user_context(\context_user::instance($USER->id)); foreach ($params['courses'] as $course) { $warning = []; $favouriteexists = $ufservice->favourite_exists('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); if ($course['favourite']) { if (!$favouriteexists) { try { $ufservice->create_favourite('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); } catch (Exception $e) { $warning['courseid'] = $course['id']; if ($e instanceof moodle_exception) { $warning['warningcode'] = $e->errorcode; } else { $warning['warningcode'] = $e->getCode(); } $warning['message'] = $e->getMessage(); $warnings[] = $warning; $warnings[] = $warning; } } else { $warning['courseid'] = $course['id']; $warning['warningcode'] = 'coursealreadyfavourited'; $warning['message'] = 'Course already favourited'; $warnings[] = $warning; } } else { if ($favouriteexists) { try { $ufservice->delete_favourite('core_course', 'courses', $course['id'], \context_course::instance($course['id'])); } catch (Exception $e) { $warning['courseid'] = $course['id']; if ($e instanceof moodle_exception) { $warning['warningcode'] = $e->errorcode; } else { $warning['warningcode'] = $e->getCode(); } $warning['message'] = $e->getMessage(); $warnings[] = $warning; $warnings[] = $warning; } } else { $warning['courseid'] = $course['id']; $warning['warningcode'] = 'cannotdeletefavourite'; $warning['message'] = 'Could not delete favourite status for course'; $warnings[] = $warning; } } } return [ 'warnings' => $warnings ]; }
[ "public", "static", "function", "set_favourite_courses", "(", "array", "$", "courses", ")", "{", "global", "$", "USER", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "set_favourite_courses_parameters", "(", ")", ",", "array", "(", "'courses'", "=>", "$", "courses", ")", ")", ";", "$", "warnings", "=", "[", "]", ";", "$", "ufservice", "=", "\\", "core_favourites", "\\", "service_factory", "::", "get_service_for_user_context", "(", "\\", "context_user", "::", "instance", "(", "$", "USER", "->", "id", ")", ")", ";", "foreach", "(", "$", "params", "[", "'courses'", "]", "as", "$", "course", ")", "{", "$", "warning", "=", "[", "]", ";", "$", "favouriteexists", "=", "$", "ufservice", "->", "favourite_exists", "(", "'core_course'", ",", "'courses'", ",", "$", "course", "[", "'id'", "]", ",", "\\", "context_course", "::", "instance", "(", "$", "course", "[", "'id'", "]", ")", ")", ";", "if", "(", "$", "course", "[", "'favourite'", "]", ")", "{", "if", "(", "!", "$", "favouriteexists", ")", "{", "try", "{", "$", "ufservice", "->", "create_favourite", "(", "'core_course'", ",", "'courses'", ",", "$", "course", "[", "'id'", "]", ",", "\\", "context_course", "::", "instance", "(", "$", "course", "[", "'id'", "]", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "warning", "[", "'courseid'", "]", "=", "$", "course", "[", "'id'", "]", ";", "if", "(", "$", "e", "instanceof", "moodle_exception", ")", "{", "$", "warning", "[", "'warningcode'", "]", "=", "$", "e", "->", "errorcode", ";", "}", "else", "{", "$", "warning", "[", "'warningcode'", "]", "=", "$", "e", "->", "getCode", "(", ")", ";", "}", "$", "warning", "[", "'message'", "]", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "}", "}", "else", "{", "$", "warning", "[", "'courseid'", "]", "=", "$", "course", "[", "'id'", "]", ";", "$", "warning", "[", "'warningcode'", "]", "=", "'coursealreadyfavourited'", ";", "$", "warning", "[", "'message'", "]", "=", "'Course already favourited'", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "}", "}", "else", "{", "if", "(", "$", "favouriteexists", ")", "{", "try", "{", "$", "ufservice", "->", "delete_favourite", "(", "'core_course'", ",", "'courses'", ",", "$", "course", "[", "'id'", "]", ",", "\\", "context_course", "::", "instance", "(", "$", "course", "[", "'id'", "]", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "warning", "[", "'courseid'", "]", "=", "$", "course", "[", "'id'", "]", ";", "if", "(", "$", "e", "instanceof", "moodle_exception", ")", "{", "$", "warning", "[", "'warningcode'", "]", "=", "$", "e", "->", "errorcode", ";", "}", "else", "{", "$", "warning", "[", "'warningcode'", "]", "=", "$", "e", "->", "getCode", "(", ")", ";", "}", "$", "warning", "[", "'message'", "]", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "}", "}", "else", "{", "$", "warning", "[", "'courseid'", "]", "=", "$", "course", "[", "'id'", "]", ";", "$", "warning", "[", "'warningcode'", "]", "=", "'cannotdeletefavourite'", ";", "$", "warning", "[", "'message'", "]", "=", "'Could not delete favourite status for course'", ";", "$", "warnings", "[", "]", "=", "$", "warning", ";", "}", "}", "}", "return", "[", "'warnings'", "=>", "$", "warnings", "]", ";", "}" ]
Set the course favourite status for an array of courses. @param array $courses List with course id's and favourite status. @return array Array with an array of favourite courses.
[ "Set", "the", "course", "favourite", "status", "for", "an", "array", "of", "courses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L3959-L4031
219,066
moodle/moodle
course/externallib.php
core_course_external.get_recent_courses
public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, string $sort = null) { global $USER, $PAGE; if (empty($userid)) { $userid = $USER->id; } $params = self::validate_parameters(self::get_recent_courses_parameters(), array( 'userid' => $userid, 'limit' => $limit, 'offset' => $offset, 'sort' => $sort ) ); $userid = $params['userid']; $limit = $params['limit']; $offset = $params['offset']; $sort = $params['sort']; $usercontext = context_user::instance($userid); self::validate_context($usercontext); if ($userid != $USER->id and !has_capability('moodle/user:viewdetails', $usercontext)) { return array(); } $courses = course_get_recent_courses($userid, $limit, $offset, $sort); $renderer = $PAGE->get_renderer('core'); $recentcourses = array_map(function($course) use ($renderer) { context_helper::preload_from_record($course); $context = context_course::instance($course->id); $isfavourite = !empty($course->component); $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => $isfavourite]); return $exporter->export($renderer); }, $courses); return $recentcourses; }
php
public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, string $sort = null) { global $USER, $PAGE; if (empty($userid)) { $userid = $USER->id; } $params = self::validate_parameters(self::get_recent_courses_parameters(), array( 'userid' => $userid, 'limit' => $limit, 'offset' => $offset, 'sort' => $sort ) ); $userid = $params['userid']; $limit = $params['limit']; $offset = $params['offset']; $sort = $params['sort']; $usercontext = context_user::instance($userid); self::validate_context($usercontext); if ($userid != $USER->id and !has_capability('moodle/user:viewdetails', $usercontext)) { return array(); } $courses = course_get_recent_courses($userid, $limit, $offset, $sort); $renderer = $PAGE->get_renderer('core'); $recentcourses = array_map(function($course) use ($renderer) { context_helper::preload_from_record($course); $context = context_course::instance($course->id); $isfavourite = !empty($course->component); $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => $isfavourite]); return $exporter->export($renderer); }, $courses); return $recentcourses; }
[ "public", "static", "function", "get_recent_courses", "(", "int", "$", "userid", "=", "0", ",", "int", "$", "limit", "=", "0", ",", "int", "$", "offset", "=", "0", ",", "string", "$", "sort", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ";", "if", "(", "empty", "(", "$", "userid", ")", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_recent_courses_parameters", "(", ")", ",", "array", "(", "'userid'", "=>", "$", "userid", ",", "'limit'", "=>", "$", "limit", ",", "'offset'", "=>", "$", "offset", ",", "'sort'", "=>", "$", "sort", ")", ")", ";", "$", "userid", "=", "$", "params", "[", "'userid'", "]", ";", "$", "limit", "=", "$", "params", "[", "'limit'", "]", ";", "$", "offset", "=", "$", "params", "[", "'offset'", "]", ";", "$", "sort", "=", "$", "params", "[", "'sort'", "]", ";", "$", "usercontext", "=", "context_user", "::", "instance", "(", "$", "userid", ")", ";", "self", "::", "validate_context", "(", "$", "usercontext", ")", ";", "if", "(", "$", "userid", "!=", "$", "USER", "->", "id", "and", "!", "has_capability", "(", "'moodle/user:viewdetails'", ",", "$", "usercontext", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "courses", "=", "course_get_recent_courses", "(", "$", "userid", ",", "$", "limit", ",", "$", "offset", ",", "$", "sort", ")", ";", "$", "renderer", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "recentcourses", "=", "array_map", "(", "function", "(", "$", "course", ")", "use", "(", "$", "renderer", ")", "{", "context_helper", "::", "preload_from_record", "(", "$", "course", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "$", "isfavourite", "=", "!", "empty", "(", "$", "course", "->", "component", ")", ";", "$", "exporter", "=", "new", "course_summary_exporter", "(", "$", "course", ",", "[", "'context'", "=>", "$", "context", ",", "'isfavourite'", "=>", "$", "isfavourite", "]", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "renderer", ")", ";", "}", ",", "$", "courses", ")", ";", "return", "$", "recentcourses", ";", "}" ]
Get last accessed courses adding additional course information like images. @param int $userid User id from which the courses will be obtained @param int $limit Restrict result set to this amount @param int $offset Skip this number of records from the start of the result set @param string|null $sort SQL string for sorting @return array List of courses @throws invalid_parameter_exception
[ "Get", "last", "accessed", "courses", "adding", "additional", "course", "information", "like", "images", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/externallib.php#L4073-L4115
219,067
moodle/moodle
question/type/truefalse/backup/moodle2/restore_qtype_truefalse_plugin.class.php
restore_qtype_truefalse_plugin.recode_legacy_state_answer
public function recode_legacy_state_answer($state) { $answer = $state->answer; $result = ''; if ($answer) { $result = $this->get_mappingid('question_answer', $answer); } return $result; }
php
public function recode_legacy_state_answer($state) { $answer = $state->answer; $result = ''; if ($answer) { $result = $this->get_mappingid('question_answer', $answer); } return $result; }
[ "public", "function", "recode_legacy_state_answer", "(", "$", "state", ")", "{", "$", "answer", "=", "$", "state", "->", "answer", ";", "$", "result", "=", "''", ";", "if", "(", "$", "answer", ")", "{", "$", "result", "=", "$", "this", "->", "get_mappingid", "(", "'question_answer'", ",", "$", "answer", ")", ";", "}", "return", "$", "result", ";", "}" ]
Given one question_states record, return the answer recoded pointing to all the restored stuff for truefalse questions if not empty, answer is one question_answers->id
[ "Given", "one", "question_states", "record", "return", "the", "answer", "recoded", "pointing", "to", "all", "the", "restored", "stuff", "for", "truefalse", "questions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/truefalse/backup/moodle2/restore_qtype_truefalse_plugin.class.php#L88-L95
219,068
moodle/moodle
lib/classes/grading_external.php
core_grading_external.get_definitions_parameters
public static function get_definitions_parameters() { return new external_function_parameters( array( 'cmids' => new external_multiple_structure( new external_value(PARAM_INT, 'course module id'), '1 or more course module ids'), 'areaname' => new external_value(PARAM_AREA, 'area name'), 'activeonly' => new external_value(PARAM_BOOL, 'Only the active method', VALUE_DEFAULT, 0) ) ); }
php
public static function get_definitions_parameters() { return new external_function_parameters( array( 'cmids' => new external_multiple_structure( new external_value(PARAM_INT, 'course module id'), '1 or more course module ids'), 'areaname' => new external_value(PARAM_AREA, 'area name'), 'activeonly' => new external_value(PARAM_BOOL, 'Only the active method', VALUE_DEFAULT, 0) ) ); }
[ "public", "static", "function", "get_definitions_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'cmids'", "=>", "new", "external_multiple_structure", "(", "new", "external_value", "(", "PARAM_INT", ",", "'course module id'", ")", ",", "'1 or more course module ids'", ")", ",", "'areaname'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "'area name'", ")", ",", "'activeonly'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Only the active method'", ",", "VALUE_DEFAULT", ",", "0", ")", ")", ")", ";", "}" ]
Describes the parameters for get_definitions @return external_function_parameters @since Moodle 2.5
[ "Describes", "the", "parameters", "for", "get_definitions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L41-L50
219,069
moodle/moodle
lib/classes/grading_external.php
core_grading_external.grading_area
private static function grading_area() { return new external_single_structure( array ( 'cmid' => new external_value(PARAM_INT, 'course module id'), 'contextid' => new external_value(PARAM_INT, 'context id'), 'component' => new external_value(PARAM_TEXT, 'component name'), 'areaname' => new external_value(PARAM_TEXT, 'area name'), 'activemethod' => new external_value(PARAM_TEXT, 'active method', VALUE_OPTIONAL), 'definitions' => new external_multiple_structure(self::definition(), 'definitions') ) ); }
php
private static function grading_area() { return new external_single_structure( array ( 'cmid' => new external_value(PARAM_INT, 'course module id'), 'contextid' => new external_value(PARAM_INT, 'context id'), 'component' => new external_value(PARAM_TEXT, 'component name'), 'areaname' => new external_value(PARAM_TEXT, 'area name'), 'activemethod' => new external_value(PARAM_TEXT, 'active method', VALUE_OPTIONAL), 'definitions' => new external_multiple_structure(self::definition(), 'definitions') ) ); }
[ "private", "static", "function", "grading_area", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'cmid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'course module id'", ")", ",", "'contextid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'context id'", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'component name'", ")", ",", "'areaname'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'area name'", ")", ",", "'activemethod'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'active method'", ",", "VALUE_OPTIONAL", ")", ",", "'definitions'", "=>", "new", "external_multiple_structure", "(", "self", "::", "definition", "(", ")", ",", "'definitions'", ")", ")", ")", ";", "}" ]
Creates a grading area @return external_single_structure @since Moodle 2.5
[ "Creates", "a", "grading", "area" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L224-L235
219,070
moodle/moodle
lib/classes/grading_external.php
core_grading_external.definition
private static function definition() { global $CFG; $definition = array(); $definition['id'] = new external_value(PARAM_INT, 'definition id', VALUE_OPTIONAL); $definition['method'] = new external_value(PARAM_TEXT, 'method'); $definition['name'] = new external_value(PARAM_TEXT, 'name'); $definition['description'] = new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL); $definition['descriptionformat'] = new external_format_value('description', VALUE_OPTIONAL); $definition['status'] = new external_value(PARAM_INT, 'status'); $definition['copiedfromid'] = new external_value(PARAM_INT, 'copied from id', VALUE_OPTIONAL); $definition['timecreated'] = new external_value(PARAM_INT, 'creation time'); $definition['usercreated'] = new external_value(PARAM_INT, 'user who created definition'); $definition['timemodified'] = new external_value(PARAM_INT, 'last modified time'); $definition['usermodified'] = new external_value(PARAM_INT, 'user who modified definition'); $definition['timecopied'] = new external_value(PARAM_INT, 'time copied', VALUE_OPTIONAL); foreach (self::get_grading_methods() as $method) { require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details'); if ($details != null) { $items = array(); foreach ($details as $key => $value) { $details[$key]->required = VALUE_OPTIONAL; $items[$key] = $value; } $definition[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL); } } return new external_single_structure($definition); }
php
private static function definition() { global $CFG; $definition = array(); $definition['id'] = new external_value(PARAM_INT, 'definition id', VALUE_OPTIONAL); $definition['method'] = new external_value(PARAM_TEXT, 'method'); $definition['name'] = new external_value(PARAM_TEXT, 'name'); $definition['description'] = new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL); $definition['descriptionformat'] = new external_format_value('description', VALUE_OPTIONAL); $definition['status'] = new external_value(PARAM_INT, 'status'); $definition['copiedfromid'] = new external_value(PARAM_INT, 'copied from id', VALUE_OPTIONAL); $definition['timecreated'] = new external_value(PARAM_INT, 'creation time'); $definition['usercreated'] = new external_value(PARAM_INT, 'user who created definition'); $definition['timemodified'] = new external_value(PARAM_INT, 'last modified time'); $definition['usermodified'] = new external_value(PARAM_INT, 'user who modified definition'); $definition['timecopied'] = new external_value(PARAM_INT, 'time copied', VALUE_OPTIONAL); foreach (self::get_grading_methods() as $method) { require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details'); if ($details != null) { $items = array(); foreach ($details as $key => $value) { $details[$key]->required = VALUE_OPTIONAL; $items[$key] = $value; } $definition[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL); } } return new external_single_structure($definition); }
[ "private", "static", "function", "definition", "(", ")", "{", "global", "$", "CFG", ";", "$", "definition", "=", "array", "(", ")", ";", "$", "definition", "[", "'id'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'definition id'", ",", "VALUE_OPTIONAL", ")", ";", "$", "definition", "[", "'method'", "]", "=", "new", "external_value", "(", "PARAM_TEXT", ",", "'method'", ")", ";", "$", "definition", "[", "'name'", "]", "=", "new", "external_value", "(", "PARAM_TEXT", ",", "'name'", ")", ";", "$", "definition", "[", "'description'", "]", "=", "new", "external_value", "(", "PARAM_RAW", ",", "'description'", ",", "VALUE_OPTIONAL", ")", ";", "$", "definition", "[", "'descriptionformat'", "]", "=", "new", "external_format_value", "(", "'description'", ",", "VALUE_OPTIONAL", ")", ";", "$", "definition", "[", "'status'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'status'", ")", ";", "$", "definition", "[", "'copiedfromid'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'copied from id'", ",", "VALUE_OPTIONAL", ")", ";", "$", "definition", "[", "'timecreated'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'creation time'", ")", ";", "$", "definition", "[", "'usercreated'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'user who created definition'", ")", ";", "$", "definition", "[", "'timemodified'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'last modified time'", ")", ";", "$", "definition", "[", "'usermodified'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'user who modified definition'", ")", ";", "$", "definition", "[", "'timecopied'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'time copied'", ",", "VALUE_OPTIONAL", ")", ";", "foreach", "(", "self", "::", "get_grading_methods", "(", ")", "as", "$", "method", ")", "{", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/grade/grading/form/'", ".", "$", "method", ".", "'/lib.php'", ")", ";", "$", "details", "=", "call_user_func", "(", "'gradingform_'", ".", "$", "method", ".", "'_controller::get_external_definition_details'", ")", ";", "if", "(", "$", "details", "!=", "null", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "details", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "details", "[", "$", "key", "]", "->", "required", "=", "VALUE_OPTIONAL", ";", "$", "items", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "definition", "[", "$", "method", "]", "=", "new", "external_single_structure", "(", "$", "items", ",", "'items'", ",", "VALUE_OPTIONAL", ")", ";", "}", "}", "return", "new", "external_single_structure", "(", "$", "definition", ")", ";", "}" ]
creates a grading form definition @return external_single_structure @since Moodle 2.5
[ "creates", "a", "grading", "form", "definition" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L242-L270
219,071
moodle/moodle
lib/classes/grading_external.php
core_grading_external.grading_instance
private static function grading_instance() { global $CFG; $instance = array(); $instance['id'] = new external_value(PARAM_INT, 'instance id'); $instance['raterid'] = new external_value(PARAM_INT, 'rater id'); $instance['itemid'] = new external_value(PARAM_INT, 'item id'); $instance['rawgrade'] = new external_value(PARAM_TEXT, 'raw grade', VALUE_OPTIONAL); $instance['status'] = new external_value(PARAM_INT, 'status'); $instance['feedback'] = new external_value(PARAM_RAW, 'feedback', VALUE_OPTIONAL); $instance['feedbackformat'] = new external_format_value('feedback', VALUE_OPTIONAL); $instance['timemodified'] = new external_value(PARAM_INT, 'modified time'); foreach (self::get_grading_methods() as $method) { require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_instance_filling_details'); if ($details != null) { $items = array(); foreach ($details as $key => $value) { $details[$key]->required = VALUE_OPTIONAL; $items[$key] = $value; } $instance[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL); } } return new external_single_structure($instance); }
php
private static function grading_instance() { global $CFG; $instance = array(); $instance['id'] = new external_value(PARAM_INT, 'instance id'); $instance['raterid'] = new external_value(PARAM_INT, 'rater id'); $instance['itemid'] = new external_value(PARAM_INT, 'item id'); $instance['rawgrade'] = new external_value(PARAM_TEXT, 'raw grade', VALUE_OPTIONAL); $instance['status'] = new external_value(PARAM_INT, 'status'); $instance['feedback'] = new external_value(PARAM_RAW, 'feedback', VALUE_OPTIONAL); $instance['feedbackformat'] = new external_format_value('feedback', VALUE_OPTIONAL); $instance['timemodified'] = new external_value(PARAM_INT, 'modified time'); foreach (self::get_grading_methods() as $method) { require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_instance_filling_details'); if ($details != null) { $items = array(); foreach ($details as $key => $value) { $details[$key]->required = VALUE_OPTIONAL; $items[$key] = $value; } $instance[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL); } } return new external_single_structure($instance); }
[ "private", "static", "function", "grading_instance", "(", ")", "{", "global", "$", "CFG", ";", "$", "instance", "=", "array", "(", ")", ";", "$", "instance", "[", "'id'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'instance id'", ")", ";", "$", "instance", "[", "'raterid'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'rater id'", ")", ";", "$", "instance", "[", "'itemid'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'item id'", ")", ";", "$", "instance", "[", "'rawgrade'", "]", "=", "new", "external_value", "(", "PARAM_TEXT", ",", "'raw grade'", ",", "VALUE_OPTIONAL", ")", ";", "$", "instance", "[", "'status'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'status'", ")", ";", "$", "instance", "[", "'feedback'", "]", "=", "new", "external_value", "(", "PARAM_RAW", ",", "'feedback'", ",", "VALUE_OPTIONAL", ")", ";", "$", "instance", "[", "'feedbackformat'", "]", "=", "new", "external_format_value", "(", "'feedback'", ",", "VALUE_OPTIONAL", ")", ";", "$", "instance", "[", "'timemodified'", "]", "=", "new", "external_value", "(", "PARAM_INT", ",", "'modified time'", ")", ";", "foreach", "(", "self", "::", "get_grading_methods", "(", ")", "as", "$", "method", ")", "{", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/grade/grading/form/'", ".", "$", "method", ".", "'/lib.php'", ")", ";", "$", "details", "=", "call_user_func", "(", "'gradingform_'", ".", "$", "method", ".", "'_controller::get_external_instance_filling_details'", ")", ";", "if", "(", "$", "details", "!=", "null", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "details", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "details", "[", "$", "key", "]", "->", "required", "=", "VALUE_OPTIONAL", ";", "$", "items", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "instance", "[", "$", "method", "]", "=", "new", "external_single_structure", "(", "$", "items", ",", "'items'", ",", "VALUE_OPTIONAL", ")", ";", "}", "}", "return", "new", "external_single_structure", "(", "$", "instance", ")", ";", "}" ]
Creates a grading instance @return external_single_structure @since Moodle 2.6
[ "Creates", "a", "grading", "instance" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L406-L430
219,072
moodle/moodle
lib/classes/grading_external.php
core_grading_external.save_definitions
public static function save_definitions($areas) { $params = self::validate_parameters(self::save_definitions_parameters(), array('areas' => $areas)); foreach ($params['areas'] as $area) { $context = context::instance_by_id($area['contextid']); require_capability('moodle/grade:managegradingforms', $context); $gradingmanager = get_grading_manager($context, $area['component'], $area['areaname']); $gradingmanager->set_active_method($area['activemethod']); $availablemethods = $gradingmanager->get_available_methods(); foreach ($area['definitions'] as $definition) { if (array_key_exists($definition['method'], $availablemethods)) { $controller = $gradingmanager->get_controller($definition['method']); $controller->update_definition(self::create_definition_object($definition)); } else { throw new invalid_parameter_exception('Unknown Grading method: '. $definition['method']); } } } }
php
public static function save_definitions($areas) { $params = self::validate_parameters(self::save_definitions_parameters(), array('areas' => $areas)); foreach ($params['areas'] as $area) { $context = context::instance_by_id($area['contextid']); require_capability('moodle/grade:managegradingforms', $context); $gradingmanager = get_grading_manager($context, $area['component'], $area['areaname']); $gradingmanager->set_active_method($area['activemethod']); $availablemethods = $gradingmanager->get_available_methods(); foreach ($area['definitions'] as $definition) { if (array_key_exists($definition['method'], $availablemethods)) { $controller = $gradingmanager->get_controller($definition['method']); $controller->update_definition(self::create_definition_object($definition)); } else { throw new invalid_parameter_exception('Unknown Grading method: '. $definition['method']); } } } }
[ "public", "static", "function", "save_definitions", "(", "$", "areas", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "save_definitions_parameters", "(", ")", ",", "array", "(", "'areas'", "=>", "$", "areas", ")", ")", ";", "foreach", "(", "$", "params", "[", "'areas'", "]", "as", "$", "area", ")", "{", "$", "context", "=", "context", "::", "instance_by_id", "(", "$", "area", "[", "'contextid'", "]", ")", ";", "require_capability", "(", "'moodle/grade:managegradingforms'", ",", "$", "context", ")", ";", "$", "gradingmanager", "=", "get_grading_manager", "(", "$", "context", ",", "$", "area", "[", "'component'", "]", ",", "$", "area", "[", "'areaname'", "]", ")", ";", "$", "gradingmanager", "->", "set_active_method", "(", "$", "area", "[", "'activemethod'", "]", ")", ";", "$", "availablemethods", "=", "$", "gradingmanager", "->", "get_available_methods", "(", ")", ";", "foreach", "(", "$", "area", "[", "'definitions'", "]", "as", "$", "definition", ")", "{", "if", "(", "array_key_exists", "(", "$", "definition", "[", "'method'", "]", ",", "$", "availablemethods", ")", ")", "{", "$", "controller", "=", "$", "gradingmanager", "->", "get_controller", "(", "$", "definition", "[", "'method'", "]", ")", ";", "$", "controller", "->", "update_definition", "(", "self", "::", "create_definition_object", "(", "$", "definition", ")", ")", ";", "}", "else", "{", "throw", "new", "invalid_parameter_exception", "(", "'Unknown Grading method: '", ".", "$", "definition", "[", "'method'", "]", ")", ";", "}", "}", "}", "}" ]
Saves the areas and definitions @param array $areas array of areas containing definitions to be saved @return null @throws invalid_parameter_exception @since Moodle 2.8
[ "Saves", "the", "areas", "and", "definitions" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L468-L489
219,073
moodle/moodle
lib/classes/grading_external.php
core_grading_external.create_definition_object
private static function create_definition_object($definition) { global $CFG; $method = $definition['method']; $definitionobject = new stdClass(); foreach ($definition as $key => $value) { if (!is_array($value)) { $definitionobject->$key = $value; } } $text = ''; $format = FORMAT_MOODLE; if (isset($definition['description'])) { $text = $definition['description']; if (isset($definition['descriptionformat'])) { $format = $definition['descriptionformat']; } } $definitionobject->description_editor = array('text' => $text, 'format' => $format); require_once("$CFG->libdir/filelib.php"); require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details'); $methodarray = array(); foreach (array_keys($details) as $definitionkey) { $items = array(); $idnumber = 1; foreach ($definition[$method][$definitionkey] as $item) { $processeditem = self::set_new_ids($item, $idnumber); $items[$processeditem['id']] = $processeditem; $idnumber++; } $definitionobjectkey = substr($definitionkey, strlen($method.'_')); $methodarray[$definitionobjectkey] = $items; $definitionobject->$method = $methodarray; } return $definitionobject; }
php
private static function create_definition_object($definition) { global $CFG; $method = $definition['method']; $definitionobject = new stdClass(); foreach ($definition as $key => $value) { if (!is_array($value)) { $definitionobject->$key = $value; } } $text = ''; $format = FORMAT_MOODLE; if (isset($definition['description'])) { $text = $definition['description']; if (isset($definition['descriptionformat'])) { $format = $definition['descriptionformat']; } } $definitionobject->description_editor = array('text' => $text, 'format' => $format); require_once("$CFG->libdir/filelib.php"); require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); $details = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details'); $methodarray = array(); foreach (array_keys($details) as $definitionkey) { $items = array(); $idnumber = 1; foreach ($definition[$method][$definitionkey] as $item) { $processeditem = self::set_new_ids($item, $idnumber); $items[$processeditem['id']] = $processeditem; $idnumber++; } $definitionobjectkey = substr($definitionkey, strlen($method.'_')); $methodarray[$definitionobjectkey] = $items; $definitionobject->$method = $methodarray; } return $definitionobject; }
[ "private", "static", "function", "create_definition_object", "(", "$", "definition", ")", "{", "global", "$", "CFG", ";", "$", "method", "=", "$", "definition", "[", "'method'", "]", ";", "$", "definitionobject", "=", "new", "stdClass", "(", ")", ";", "foreach", "(", "$", "definition", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "definitionobject", "->", "$", "key", "=", "$", "value", ";", "}", "}", "$", "text", "=", "''", ";", "$", "format", "=", "FORMAT_MOODLE", ";", "if", "(", "isset", "(", "$", "definition", "[", "'description'", "]", ")", ")", "{", "$", "text", "=", "$", "definition", "[", "'description'", "]", ";", "if", "(", "isset", "(", "$", "definition", "[", "'descriptionformat'", "]", ")", ")", "{", "$", "format", "=", "$", "definition", "[", "'descriptionformat'", "]", ";", "}", "}", "$", "definitionobject", "->", "description_editor", "=", "array", "(", "'text'", "=>", "$", "text", ",", "'format'", "=>", "$", "format", ")", ";", "require_once", "(", "\"$CFG->libdir/filelib.php\"", ")", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/grade/grading/form/'", ".", "$", "method", ".", "'/lib.php'", ")", ";", "$", "details", "=", "call_user_func", "(", "'gradingform_'", ".", "$", "method", ".", "'_controller::get_external_definition_details'", ")", ";", "$", "methodarray", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "details", ")", "as", "$", "definitionkey", ")", "{", "$", "items", "=", "array", "(", ")", ";", "$", "idnumber", "=", "1", ";", "foreach", "(", "$", "definition", "[", "$", "method", "]", "[", "$", "definitionkey", "]", "as", "$", "item", ")", "{", "$", "processeditem", "=", "self", "::", "set_new_ids", "(", "$", "item", ",", "$", "idnumber", ")", ";", "$", "items", "[", "$", "processeditem", "[", "'id'", "]", "]", "=", "$", "processeditem", ";", "$", "idnumber", "++", ";", "}", "$", "definitionobjectkey", "=", "substr", "(", "$", "definitionkey", ",", "strlen", "(", "$", "method", ".", "'_'", ")", ")", ";", "$", "methodarray", "[", "$", "definitionobjectkey", "]", "=", "$", "items", ";", "$", "definitionobject", "->", "$", "method", "=", "$", "methodarray", ";", "}", "return", "$", "definitionobject", ";", "}" ]
Creates a definition stdClass object using the values from the definition array that is passed in as a parameter @param array $definition @return stdClass definition object @since Moodle 2.8
[ "Creates", "a", "definition", "stdClass", "object", "using", "the", "values", "from", "the", "definition", "array", "that", "is", "passed", "in", "as", "a", "parameter" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/grading_external.php#L509-L547
219,074
moodle/moodle
lib/google/src/Google/Http/Request.php
Google_Http_Request.enableGzip
public function enableGzip() { $this->setRequestHeaders(array("Accept-Encoding" => "gzip")); $this->canGzip = true; $this->setUserAgent($this->userAgent); }
php
public function enableGzip() { $this->setRequestHeaders(array("Accept-Encoding" => "gzip")); $this->canGzip = true; $this->setUserAgent($this->userAgent); }
[ "public", "function", "enableGzip", "(", ")", "{", "$", "this", "->", "setRequestHeaders", "(", "array", "(", "\"Accept-Encoding\"", "=>", "\"gzip\"", ")", ")", ";", "$", "this", "->", "canGzip", "=", "true", ";", "$", "this", "->", "setUserAgent", "(", "$", "this", "->", "userAgent", ")", ";", "}" ]
Enable support for gzipped responses with this request.
[ "Enable", "support", "for", "gzipped", "responses", "with", "this", "request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Http/Request.php#L92-L97
219,075
moodle/moodle
lib/google/src/Google/Http/Request.php
Google_Http_Request.disableGzip
public function disableGzip() { if ( isset($this->requestHeaders['accept-encoding']) && $this->requestHeaders['accept-encoding'] == "gzip" ) { unset($this->requestHeaders['accept-encoding']); } $this->canGzip = false; $this->userAgent = str_replace(self::GZIP_UA, "", $this->userAgent); }
php
public function disableGzip() { if ( isset($this->requestHeaders['accept-encoding']) && $this->requestHeaders['accept-encoding'] == "gzip" ) { unset($this->requestHeaders['accept-encoding']); } $this->canGzip = false; $this->userAgent = str_replace(self::GZIP_UA, "", $this->userAgent); }
[ "public", "function", "disableGzip", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "requestHeaders", "[", "'accept-encoding'", "]", ")", "&&", "$", "this", "->", "requestHeaders", "[", "'accept-encoding'", "]", "==", "\"gzip\"", ")", "{", "unset", "(", "$", "this", "->", "requestHeaders", "[", "'accept-encoding'", "]", ")", ";", "}", "$", "this", "->", "canGzip", "=", "false", ";", "$", "this", "->", "userAgent", "=", "str_replace", "(", "self", "::", "GZIP_UA", ",", "\"\"", ",", "$", "this", "->", "userAgent", ")", ";", "}" ]
Disable support for gzip responses with this request.
[ "Disable", "support", "for", "gzip", "responses", "with", "this", "request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Http/Request.php#L102-L112
219,076
moodle/moodle
lib/google/src/Google/Http/Request.php
Google_Http_Request.setUserAgent
public function setUserAgent($userAgent) { $this->userAgent = $userAgent; if ($this->canGzip) { $this->userAgent = $userAgent . self::GZIP_UA; } }
php
public function setUserAgent($userAgent) { $this->userAgent = $userAgent; if ($this->canGzip) { $this->userAgent = $userAgent . self::GZIP_UA; } }
[ "public", "function", "setUserAgent", "(", "$", "userAgent", ")", "{", "$", "this", "->", "userAgent", "=", "$", "userAgent", ";", "if", "(", "$", "this", "->", "canGzip", ")", "{", "$", "this", "->", "userAgent", "=", "$", "userAgent", ".", "self", "::", "GZIP_UA", ";", "}", "}" ]
Set the User-Agent Header. @param string $userAgent The User-Agent.
[ "Set", "the", "User", "-", "Agent", "Header", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Http/Request.php#L362-L368
219,077
moodle/moodle
lib/google/src/Google/Http/Request.php
Google_Http_Request.getCacheKey
public function getCacheKey() { $key = $this->getUrl(); if (isset($this->accessKey)) { $key .= $this->accessKey; } if (isset($this->requestHeaders['authorization'])) { $key .= $this->requestHeaders['authorization']; } return md5($key); }
php
public function getCacheKey() { $key = $this->getUrl(); if (isset($this->accessKey)) { $key .= $this->accessKey; } if (isset($this->requestHeaders['authorization'])) { $key .= $this->requestHeaders['authorization']; } return md5($key); }
[ "public", "function", "getCacheKey", "(", ")", "{", "$", "key", "=", "$", "this", "->", "getUrl", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "accessKey", ")", ")", "{", "$", "key", ".=", "$", "this", "->", "accessKey", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "requestHeaders", "[", "'authorization'", "]", ")", ")", "{", "$", "key", ".=", "$", "this", "->", "requestHeaders", "[", "'authorization'", "]", ";", "}", "return", "md5", "(", "$", "key", ")", ";", "}" ]
Returns a cache key depending on if this was an OAuth signed request in which case it will use the non-signed url and access key to make this cache key unique per authenticated user, else use the plain request url @return string The md5 hash of the request cache key.
[ "Returns", "a", "cache", "key", "depending", "on", "if", "this", "was", "an", "OAuth", "signed", "request", "in", "which", "case", "it", "will", "use", "the", "non", "-", "signed", "url", "and", "access", "key", "to", "make", "this", "cache", "key", "unique", "per", "authenticated", "user", "else", "use", "the", "plain", "request", "url" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Http/Request.php#L384-L397
219,078
moodle/moodle
lib/google/src/Google/Http/Request.php
Google_Http_Request.maybeMoveParametersToBody
public function maybeMoveParametersToBody() { if ($this->getRequestMethod() == "POST" && empty($this->postBody)) { $this->setRequestHeaders( array( "content-type" => "application/x-www-form-urlencoded; charset=UTF-8" ) ); $this->setPostBody($this->buildQuery($this->queryParams)); $this->queryParams = array(); } }
php
public function maybeMoveParametersToBody() { if ($this->getRequestMethod() == "POST" && empty($this->postBody)) { $this->setRequestHeaders( array( "content-type" => "application/x-www-form-urlencoded; charset=UTF-8" ) ); $this->setPostBody($this->buildQuery($this->queryParams)); $this->queryParams = array(); } }
[ "public", "function", "maybeMoveParametersToBody", "(", ")", "{", "if", "(", "$", "this", "->", "getRequestMethod", "(", ")", "==", "\"POST\"", "&&", "empty", "(", "$", "this", "->", "postBody", ")", ")", "{", "$", "this", "->", "setRequestHeaders", "(", "array", "(", "\"content-type\"", "=>", "\"application/x-www-form-urlencoded; charset=UTF-8\"", ")", ")", ";", "$", "this", "->", "setPostBody", "(", "$", "this", "->", "buildQuery", "(", "$", "this", "->", "queryParams", ")", ")", ";", "$", "this", "->", "queryParams", "=", "array", "(", ")", ";", "}", "}" ]
If we're POSTing and have no body to send, we can send the query parameters in there, which avoids length issues with longer query params.
[ "If", "we", "re", "POSTing", "and", "have", "no", "body", "to", "send", "we", "can", "send", "the", "query", "parameters", "in", "there", "which", "avoids", "length", "issues", "with", "longer", "query", "params", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Http/Request.php#L491-L503
219,079
moodle/moodle
mod/wiki/parser/markups/nwiki.php
nwiki_parser.italic_tag_rule
protected function italic_tag_rule($match) { $text = $match[1]; if(strlen($match[2]) == 5) { $text .= "''"; } $this->rules($text, array('only' => array('bold'))); if(strpos($text, "''") !== false) { $text = str_replace("''", $this->protect("''"), $text); } return array($text, array()); }
php
protected function italic_tag_rule($match) { $text = $match[1]; if(strlen($match[2]) == 5) { $text .= "''"; } $this->rules($text, array('only' => array('bold'))); if(strpos($text, "''") !== false) { $text = str_replace("''", $this->protect("''"), $text); } return array($text, array()); }
[ "protected", "function", "italic_tag_rule", "(", "$", "match", ")", "{", "$", "text", "=", "$", "match", "[", "1", "]", ";", "if", "(", "strlen", "(", "$", "match", "[", "2", "]", ")", "==", "5", ")", "{", "$", "text", ".=", "\"''\"", ";", "}", "$", "this", "->", "rules", "(", "$", "text", ",", "array", "(", "'only'", "=>", "array", "(", "'bold'", ")", ")", ")", ";", "if", "(", "strpos", "(", "$", "text", ",", "\"''\"", ")", "!==", "false", ")", "{", "$", "text", "=", "str_replace", "(", "\"''\"", ",", "$", "this", "->", "protect", "(", "\"''\"", ")", ",", "$", "text", ")", ";", "}", "return", "array", "(", "$", "text", ",", "array", "(", ")", ")", ";", "}" ]
Bold and italic similar to creole...
[ "Bold", "and", "italic", "similar", "to", "creole", "..." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/parser/markups/nwiki.php#L191-L203
219,080
moodle/moodle
user/filters/profilefield.php
user_filter_profilefield.get_profile_fields
public function get_profile_fields() { global $DB; if (!$fields = $DB->get_records('user_info_field', null, 'shortname', 'id,shortname')) { return null; } $res = array(0 => get_string('anyfield', 'filters')); foreach ($fields as $k => $v) { $res[$k] = $v->shortname; } return $res; }
php
public function get_profile_fields() { global $DB; if (!$fields = $DB->get_records('user_info_field', null, 'shortname', 'id,shortname')) { return null; } $res = array(0 => get_string('anyfield', 'filters')); foreach ($fields as $k => $v) { $res[$k] = $v->shortname; } return $res; }
[ "public", "function", "get_profile_fields", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "fields", "=", "$", "DB", "->", "get_records", "(", "'user_info_field'", ",", "null", ",", "'shortname'", ",", "'id,shortname'", ")", ")", "{", "return", "null", ";", "}", "$", "res", "=", "array", "(", "0", "=>", "get_string", "(", "'anyfield'", ",", "'filters'", ")", ")", ";", "foreach", "(", "$", "fields", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "res", "[", "$", "k", "]", "=", "$", "v", "->", "shortname", ";", "}", "return", "$", "res", ";", "}" ]
Returns an array of custom profile fields @return array of profile fields
[ "Returns", "an", "array", "of", "custom", "profile", "fields" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/filters/profilefield.php#L75-L85
219,081
moodle/moodle
mod/quiz/report/overview/overview_table.php
quiz_overview_table.compute_average_row
public function compute_average_row($label, \core\dml\sql_join $usersjoins) { global $DB; list($fields, $from, $where, $params) = $this->base_sql($usersjoins); $record = $DB->get_record_sql(" SELECT AVG(quizaouter.sumgrades) AS grade, COUNT(quizaouter.sumgrades) AS numaveraged FROM {quiz_attempts} quizaouter JOIN ( SELECT DISTINCT quiza.id FROM $from WHERE $where ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id ", $params); $record->grade = quiz_rescale_grade($record->grade, $this->quiz, false); if ($this->is_downloading()) { $namekey = 'lastname'; } else { $namekey = 'fullname'; } $averagerow = array( $namekey => $label, 'sumgrades' => $this->format_average($record), 'feedbacktext' => strip_tags(quiz_report_feedback_for_grade( $record->grade, $this->quiz->id, $this->context)) ); if ($this->options->slotmarks) { $dm = new question_engine_data_mapper(); $qubaids = new qubaid_join("{quiz_attempts} quizaouter JOIN ( SELECT DISTINCT quiza.id FROM $from WHERE $where ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id", 'quizaouter.uniqueid', '1 = 1', $params); $avggradebyq = $dm->load_average_marks($qubaids, array_keys($this->questions)); $averagerow += $this->format_average_grade_for_questions($avggradebyq); } return $averagerow; }
php
public function compute_average_row($label, \core\dml\sql_join $usersjoins) { global $DB; list($fields, $from, $where, $params) = $this->base_sql($usersjoins); $record = $DB->get_record_sql(" SELECT AVG(quizaouter.sumgrades) AS grade, COUNT(quizaouter.sumgrades) AS numaveraged FROM {quiz_attempts} quizaouter JOIN ( SELECT DISTINCT quiza.id FROM $from WHERE $where ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id ", $params); $record->grade = quiz_rescale_grade($record->grade, $this->quiz, false); if ($this->is_downloading()) { $namekey = 'lastname'; } else { $namekey = 'fullname'; } $averagerow = array( $namekey => $label, 'sumgrades' => $this->format_average($record), 'feedbacktext' => strip_tags(quiz_report_feedback_for_grade( $record->grade, $this->quiz->id, $this->context)) ); if ($this->options->slotmarks) { $dm = new question_engine_data_mapper(); $qubaids = new qubaid_join("{quiz_attempts} quizaouter JOIN ( SELECT DISTINCT quiza.id FROM $from WHERE $where ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id", 'quizaouter.uniqueid', '1 = 1', $params); $avggradebyq = $dm->load_average_marks($qubaids, array_keys($this->questions)); $averagerow += $this->format_average_grade_for_questions($avggradebyq); } return $averagerow; }
[ "public", "function", "compute_average_row", "(", "$", "label", ",", "\\", "core", "\\", "dml", "\\", "sql_join", "$", "usersjoins", ")", "{", "global", "$", "DB", ";", "list", "(", "$", "fields", ",", "$", "from", ",", "$", "where", ",", "$", "params", ")", "=", "$", "this", "->", "base_sql", "(", "$", "usersjoins", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record_sql", "(", "\"\n SELECT AVG(quizaouter.sumgrades) AS grade, COUNT(quizaouter.sumgrades) AS numaveraged\n FROM {quiz_attempts} quizaouter\n JOIN (\n SELECT DISTINCT quiza.id\n FROM $from\n WHERE $where\n ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id\n \"", ",", "$", "params", ")", ";", "$", "record", "->", "grade", "=", "quiz_rescale_grade", "(", "$", "record", "->", "grade", ",", "$", "this", "->", "quiz", ",", "false", ")", ";", "if", "(", "$", "this", "->", "is_downloading", "(", ")", ")", "{", "$", "namekey", "=", "'lastname'", ";", "}", "else", "{", "$", "namekey", "=", "'fullname'", ";", "}", "$", "averagerow", "=", "array", "(", "$", "namekey", "=>", "$", "label", ",", "'sumgrades'", "=>", "$", "this", "->", "format_average", "(", "$", "record", ")", ",", "'feedbacktext'", "=>", "strip_tags", "(", "quiz_report_feedback_for_grade", "(", "$", "record", "->", "grade", ",", "$", "this", "->", "quiz", "->", "id", ",", "$", "this", "->", "context", ")", ")", ")", ";", "if", "(", "$", "this", "->", "options", "->", "slotmarks", ")", "{", "$", "dm", "=", "new", "question_engine_data_mapper", "(", ")", ";", "$", "qubaids", "=", "new", "qubaid_join", "(", "\"{quiz_attempts} quizaouter\n JOIN (\n SELECT DISTINCT quiza.id\n FROM $from\n WHERE $where\n ) relevant_attempt_ids ON quizaouter.id = relevant_attempt_ids.id\"", ",", "'quizaouter.uniqueid'", ",", "'1 = 1'", ",", "$", "params", ")", ";", "$", "avggradebyq", "=", "$", "dm", "->", "load_average_marks", "(", "$", "qubaids", ",", "array_keys", "(", "$", "this", "->", "questions", ")", ")", ";", "$", "averagerow", "+=", "$", "this", "->", "format_average_grade_for_questions", "(", "$", "avggradebyq", ")", ";", "}", "return", "$", "averagerow", ";", "}" ]
Calculate the average overall and question scores for a set of attempts at the quiz. @param string $label the title ot use for this row. @param \core\dml\sql_join $usersjoins to indicate a set of users. @return array of table cells that make up the average row.
[ "Calculate", "the", "average", "overall", "and", "question", "scores", "for", "a", "set", "of", "attempts", "at", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/overview_table.php#L102-L143
219,082
moodle/moodle
mod/quiz/report/overview/overview_table.php
quiz_overview_table.add_average_row
protected function add_average_row($label, \core\dml\sql_join $usersjoins) { $averagerow = $this->compute_average_row($label, $usersjoins); $this->add_data_keyed($averagerow); }
php
protected function add_average_row($label, \core\dml\sql_join $usersjoins) { $averagerow = $this->compute_average_row($label, $usersjoins); $this->add_data_keyed($averagerow); }
[ "protected", "function", "add_average_row", "(", "$", "label", ",", "\\", "core", "\\", "dml", "\\", "sql_join", "$", "usersjoins", ")", "{", "$", "averagerow", "=", "$", "this", "->", "compute_average_row", "(", "$", "label", ",", "$", "usersjoins", ")", ";", "$", "this", "->", "add_data_keyed", "(", "$", "averagerow", ")", ";", "}" ]
Add an average grade row for a set of users. @param string $label the title ot use for this row. @param \core\dml\sql_join $usersjoins (joins, wheres, params) for the users to average over.
[ "Add", "an", "average", "grade", "row", "for", "a", "set", "of", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/overview_table.php#L151-L154
219,083
moodle/moodle
mod/quiz/report/overview/overview_table.php
quiz_overview_table.format_average
protected function format_average($record, $question = false) { if (is_null($record->grade)) { $average = '-'; } else if ($question) { $average = quiz_format_question_grade($this->quiz, $record->grade); } else { $average = quiz_format_grade($this->quiz, $record->grade); } if ($this->download) { return $average; } else if (is_null($record->numaveraged) || $record->numaveraged == 0) { return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')), array('class' => 'avgcell')); } else { return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')) . ' ' . html_writer::tag('span', '(' . $record->numaveraged . ')', array('class' => 'count')), array('class' => 'avgcell')); } }
php
protected function format_average($record, $question = false) { if (is_null($record->grade)) { $average = '-'; } else if ($question) { $average = quiz_format_question_grade($this->quiz, $record->grade); } else { $average = quiz_format_grade($this->quiz, $record->grade); } if ($this->download) { return $average; } else if (is_null($record->numaveraged) || $record->numaveraged == 0) { return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')), array('class' => 'avgcell')); } else { return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')) . ' ' . html_writer::tag('span', '(' . $record->numaveraged . ')', array('class' => 'count')), array('class' => 'avgcell')); } }
[ "protected", "function", "format_average", "(", "$", "record", ",", "$", "question", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "record", "->", "grade", ")", ")", "{", "$", "average", "=", "'-'", ";", "}", "else", "if", "(", "$", "question", ")", "{", "$", "average", "=", "quiz_format_question_grade", "(", "$", "this", "->", "quiz", ",", "$", "record", "->", "grade", ")", ";", "}", "else", "{", "$", "average", "=", "quiz_format_grade", "(", "$", "this", "->", "quiz", ",", "$", "record", "->", "grade", ")", ";", "}", "if", "(", "$", "this", "->", "download", ")", "{", "return", "$", "average", ";", "}", "else", "if", "(", "is_null", "(", "$", "record", "->", "numaveraged", ")", "||", "$", "record", "->", "numaveraged", "==", "0", ")", "{", "return", "html_writer", "::", "tag", "(", "'span'", ",", "html_writer", "::", "tag", "(", "'span'", ",", "$", "average", ",", "array", "(", "'class'", "=>", "'average'", ")", ")", ",", "array", "(", "'class'", "=>", "'avgcell'", ")", ")", ";", "}", "else", "{", "return", "html_writer", "::", "tag", "(", "'span'", ",", "html_writer", "::", "tag", "(", "'span'", ",", "$", "average", ",", "array", "(", "'class'", "=>", "'average'", ")", ")", ".", "' '", ".", "html_writer", "::", "tag", "(", "'span'", ",", "'('", ".", "$", "record", "->", "numaveraged", ".", "')'", ",", "array", "(", "'class'", "=>", "'count'", ")", ")", ",", "array", "(", "'class'", "=>", "'avgcell'", ")", ")", ";", "}", "}" ]
Format an entry in an average row. @param object $record with fields grade and numaveraged. @param bool $question true if this is a question score, false if it is an overall score. @return string HTML fragment for an average score (with number of things included in the average).
[ "Format", "an", "entry", "in", "an", "average", "row", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/overview_table.php#L192-L212
219,084
moodle/moodle
mod/quiz/report/overview/overview_table.php
quiz_overview_table.get_regraded_questions
protected function get_regraded_questions() { global $DB; $qubaids = $this->get_qubaids_condition(); $regradedqs = $DB->get_records_select('quiz_overview_regrades', 'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params()); return quiz_report_index_by_keys($regradedqs, array('questionusageid', 'slot')); }
php
protected function get_regraded_questions() { global $DB; $qubaids = $this->get_qubaids_condition(); $regradedqs = $DB->get_records_select('quiz_overview_regrades', 'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params()); return quiz_report_index_by_keys($regradedqs, array('questionusageid', 'slot')); }
[ "protected", "function", "get_regraded_questions", "(", ")", "{", "global", "$", "DB", ";", "$", "qubaids", "=", "$", "this", "->", "get_qubaids_condition", "(", ")", ";", "$", "regradedqs", "=", "$", "DB", "->", "get_records_select", "(", "'quiz_overview_regrades'", ",", "'questionusageid '", ".", "$", "qubaids", "->", "usage_id_in", "(", ")", ",", "$", "qubaids", "->", "usage_id_in_params", "(", ")", ")", ";", "return", "quiz_report_index_by_keys", "(", "$", "regradedqs", ",", "array", "(", "'questionusageid'", ",", "'slot'", ")", ")", ";", "}" ]
Get all the questions in all the attempts being displayed that need regrading. @return array A two dimensional array $questionusageid => $slot => $regradeinfo.
[ "Get", "all", "the", "questions", "in", "all", "the", "attempts", "being", "displayed", "that", "need", "regrading", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/overview_table.php#L365-L372
219,085
moodle/moodle
lib/classes/output/icon_system_fontawesome.php
icon_system_fontawesome.get_icon_name_map
public function get_icon_name_map() { if ($this->map === []) { $cache = \cache::make('core', 'fontawesomeiconmapping'); $this->map = $cache->get('mapping'); if (empty($this->map)) { $this->map = $this->get_core_icon_map(); $callback = 'get_fontawesome_icon_map'; if ($pluginsfunction = get_plugins_with_function($callback)) { foreach ($pluginsfunction as $plugintype => $plugins) { foreach ($plugins as $pluginfunction) { $pluginmap = $pluginfunction(); $this->map += $pluginmap; } } } $cache->set('mapping', $this->map); } } return $this->map; }
php
public function get_icon_name_map() { if ($this->map === []) { $cache = \cache::make('core', 'fontawesomeiconmapping'); $this->map = $cache->get('mapping'); if (empty($this->map)) { $this->map = $this->get_core_icon_map(); $callback = 'get_fontawesome_icon_map'; if ($pluginsfunction = get_plugins_with_function($callback)) { foreach ($pluginsfunction as $plugintype => $plugins) { foreach ($plugins as $pluginfunction) { $pluginmap = $pluginfunction(); $this->map += $pluginmap; } } } $cache->set('mapping', $this->map); } } return $this->map; }
[ "public", "function", "get_icon_name_map", "(", ")", "{", "if", "(", "$", "this", "->", "map", "===", "[", "]", ")", "{", "$", "cache", "=", "\\", "cache", "::", "make", "(", "'core'", ",", "'fontawesomeiconmapping'", ")", ";", "$", "this", "->", "map", "=", "$", "cache", "->", "get", "(", "'mapping'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "map", ")", ")", "{", "$", "this", "->", "map", "=", "$", "this", "->", "get_core_icon_map", "(", ")", ";", "$", "callback", "=", "'get_fontawesome_icon_map'", ";", "if", "(", "$", "pluginsfunction", "=", "get_plugins_with_function", "(", "$", "callback", ")", ")", "{", "foreach", "(", "$", "pluginsfunction", "as", "$", "plugintype", "=>", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "pluginfunction", ")", "{", "$", "pluginmap", "=", "$", "pluginfunction", "(", ")", ";", "$", "this", "->", "map", "+=", "$", "pluginmap", ";", "}", "}", "}", "$", "cache", "->", "set", "(", "'mapping'", ",", "$", "this", "->", "map", ")", ";", "}", "}", "return", "$", "this", "->", "map", ";", "}" ]
Overridable function to get a mapping of all icons. Default is to do no mapping.
[ "Overridable", "function", "to", "get", "a", "mapping", "of", "all", "icons", ".", "Default", "is", "to", "do", "no", "mapping", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/output/icon_system_fontawesome.php#L416-L439
219,086
moodle/moodle
lib/spout/src/Spout/Reader/Wrapper/XMLReader.php
XMLReader.openFileInZip
public function openFileInZip($zipFilePath, $fileInsideZipPath) { $wasOpenSuccessful = false; $realPathURI = $this->getRealPathURIForFileInZip($zipFilePath, $fileInsideZipPath); // We need to check first that the file we are trying to read really exist because: // - PHP emits a warning when trying to open a file that does not exist. // - HHVM does not check if file exists within zip file (@link https://github.com/facebook/hhvm/issues/5779) if ($this->fileExistsWithinZip($realPathURI)) { $wasOpenSuccessful = $this->open($realPathURI, null, LIBXML_NONET); } return $wasOpenSuccessful; }
php
public function openFileInZip($zipFilePath, $fileInsideZipPath) { $wasOpenSuccessful = false; $realPathURI = $this->getRealPathURIForFileInZip($zipFilePath, $fileInsideZipPath); // We need to check first that the file we are trying to read really exist because: // - PHP emits a warning when trying to open a file that does not exist. // - HHVM does not check if file exists within zip file (@link https://github.com/facebook/hhvm/issues/5779) if ($this->fileExistsWithinZip($realPathURI)) { $wasOpenSuccessful = $this->open($realPathURI, null, LIBXML_NONET); } return $wasOpenSuccessful; }
[ "public", "function", "openFileInZip", "(", "$", "zipFilePath", ",", "$", "fileInsideZipPath", ")", "{", "$", "wasOpenSuccessful", "=", "false", ";", "$", "realPathURI", "=", "$", "this", "->", "getRealPathURIForFileInZip", "(", "$", "zipFilePath", ",", "$", "fileInsideZipPath", ")", ";", "// We need to check first that the file we are trying to read really exist because:", "// - PHP emits a warning when trying to open a file that does not exist.", "// - HHVM does not check if file exists within zip file (@link https://github.com/facebook/hhvm/issues/5779)", "if", "(", "$", "this", "->", "fileExistsWithinZip", "(", "$", "realPathURI", ")", ")", "{", "$", "wasOpenSuccessful", "=", "$", "this", "->", "open", "(", "$", "realPathURI", ",", "null", ",", "LIBXML_NONET", ")", ";", "}", "return", "$", "wasOpenSuccessful", ";", "}" ]
Opens the XML Reader to read a file located inside a ZIP file. @param string $zipFilePath Path to the ZIP file @param string $fileInsideZipPath Relative or absolute path of the file inside the zip @return bool TRUE on success or FALSE on failure
[ "Opens", "the", "XML", "Reader", "to", "read", "a", "file", "located", "inside", "a", "ZIP", "file", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Reader/Wrapper/XMLReader.php#L27-L40
219,087
moodle/moodle
lib/spout/src/Spout/Reader/Wrapper/XMLReader.php
XMLReader.fileExistsWithinZip
protected function fileExistsWithinZip($zipStreamURI) { $doesFileExists = false; $pattern = '/zip:\/\/([^#]+)#(.*)/'; if (preg_match($pattern, $zipStreamURI, $matches)) { $zipFilePath = $matches[1]; $innerFilePath = $matches[2]; $zip = new \ZipArchive(); if ($zip->open($zipFilePath) === true) { $doesFileExists = ($zip->locateName($innerFilePath) !== false); $zip->close(); } } return $doesFileExists; }
php
protected function fileExistsWithinZip($zipStreamURI) { $doesFileExists = false; $pattern = '/zip:\/\/([^#]+)#(.*)/'; if (preg_match($pattern, $zipStreamURI, $matches)) { $zipFilePath = $matches[1]; $innerFilePath = $matches[2]; $zip = new \ZipArchive(); if ($zip->open($zipFilePath) === true) { $doesFileExists = ($zip->locateName($innerFilePath) !== false); $zip->close(); } } return $doesFileExists; }
[ "protected", "function", "fileExistsWithinZip", "(", "$", "zipStreamURI", ")", "{", "$", "doesFileExists", "=", "false", ";", "$", "pattern", "=", "'/zip:\\/\\/([^#]+)#(.*)/'", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "zipStreamURI", ",", "$", "matches", ")", ")", "{", "$", "zipFilePath", "=", "$", "matches", "[", "1", "]", ";", "$", "innerFilePath", "=", "$", "matches", "[", "2", "]", ";", "$", "zip", "=", "new", "\\", "ZipArchive", "(", ")", ";", "if", "(", "$", "zip", "->", "open", "(", "$", "zipFilePath", ")", "===", "true", ")", "{", "$", "doesFileExists", "=", "(", "$", "zip", "->", "locateName", "(", "$", "innerFilePath", ")", "!==", "false", ")", ";", "$", "zip", "->", "close", "(", ")", ";", "}", "}", "return", "$", "doesFileExists", ";", "}" ]
Returns whether the file at the given location exists @param string $zipStreamURI URI of a zip stream, e.g. "zip://file.zip#path/inside.xml" @return bool TRUE if the file exists, FALSE otherwise
[ "Returns", "whether", "the", "file", "at", "the", "given", "location", "exists" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Reader/Wrapper/XMLReader.php#L61-L78
219,088
moodle/moodle
lib/spout/src/Spout/Reader/Wrapper/XMLReader.php
XMLReader.readUntilNodeFound
public function readUntilNodeFound($nodeName) { do { $wasReadSuccessful = $this->read(); $isNotPositionedOnStartingNode = !$this->isPositionedOnStartingNode($nodeName); } while ($wasReadSuccessful && $isNotPositionedOnStartingNode); return $wasReadSuccessful; }
php
public function readUntilNodeFound($nodeName) { do { $wasReadSuccessful = $this->read(); $isNotPositionedOnStartingNode = !$this->isPositionedOnStartingNode($nodeName); } while ($wasReadSuccessful && $isNotPositionedOnStartingNode); return $wasReadSuccessful; }
[ "public", "function", "readUntilNodeFound", "(", "$", "nodeName", ")", "{", "do", "{", "$", "wasReadSuccessful", "=", "$", "this", "->", "read", "(", ")", ";", "$", "isNotPositionedOnStartingNode", "=", "!", "$", "this", "->", "isPositionedOnStartingNode", "(", "$", "nodeName", ")", ";", "}", "while", "(", "$", "wasReadSuccessful", "&&", "$", "isNotPositionedOnStartingNode", ")", ";", "return", "$", "wasReadSuccessful", ";", "}" ]
Read until the element with the given name is found, or the end of the file. @param string $nodeName Name of the node to find @return bool TRUE on success or FALSE on failure @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
[ "Read", "until", "the", "element", "with", "the", "given", "name", "is", "found", "or", "the", "end", "of", "the", "file", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Reader/Wrapper/XMLReader.php#L105-L113
219,089
moodle/moodle
lib/horde/framework/Horde/Crypt/Blowfish/Base.php
Horde_Crypt_Blowfish_Base._pad
protected function _pad($text, $ignore = false) { $blocksize = Horde_Crypt_Blowfish::BLOCKSIZE; $padding = $blocksize - (strlen($text) % $blocksize); return ($ignore && ($padding == $blocksize)) ? $text : $text . str_repeat(chr($padding), $padding); }
php
protected function _pad($text, $ignore = false) { $blocksize = Horde_Crypt_Blowfish::BLOCKSIZE; $padding = $blocksize - (strlen($text) % $blocksize); return ($ignore && ($padding == $blocksize)) ? $text : $text . str_repeat(chr($padding), $padding); }
[ "protected", "function", "_pad", "(", "$", "text", ",", "$", "ignore", "=", "false", ")", "{", "$", "blocksize", "=", "Horde_Crypt_Blowfish", "::", "BLOCKSIZE", ";", "$", "padding", "=", "$", "blocksize", "-", "(", "strlen", "(", "$", "text", ")", "%", "$", "blocksize", ")", ";", "return", "(", "$", "ignore", "&&", "(", "$", "padding", "==", "$", "blocksize", ")", ")", "?", "$", "text", ":", "$", "text", ".", "str_repeat", "(", "chr", "(", "$", "padding", ")", ",", "$", "padding", ")", ";", "}" ]
Pad text to match blocksize length. @param string $text Unpadded text. @param boolean $ignore Don't pad if already at blocksize length. @return string Padded text.
[ "Pad", "text", "to", "match", "blocksize", "length", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Crypt/Blowfish/Base.php#L106-L114
219,090
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php
StyleHelper.registerStyle
public function registerStyle($style) { $registeredStyle = parent::registerStyle($style); $this->registerFill($registeredStyle); $this->registerBorder($registeredStyle); return $registeredStyle; }
php
public function registerStyle($style) { $registeredStyle = parent::registerStyle($style); $this->registerFill($registeredStyle); $this->registerBorder($registeredStyle); return $registeredStyle; }
[ "public", "function", "registerStyle", "(", "$", "style", ")", "{", "$", "registeredStyle", "=", "parent", "::", "registerStyle", "(", "$", "style", ")", ";", "$", "this", "->", "registerFill", "(", "$", "registeredStyle", ")", ";", "$", "this", "->", "registerBorder", "(", "$", "registeredStyle", ")", ";", "return", "$", "registeredStyle", ";", "}" ]
XLSX specific operations on the registered styles @param \Box\Spout\Writer\Style\Style $style @return \Box\Spout\Writer\Style\Style
[ "XLSX", "specific", "operations", "on", "the", "registered", "styles" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php#L51-L57
219,091
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php
StyleHelper.registerFill
protected function registerFill($style) { $styleId = $style->getId(); // Currently - only solid backgrounds are supported // so $backgroundColor is a scalar value (RGB Color) $backgroundColor = $style->getBackgroundColor(); if ($backgroundColor) { $isBackgroundColorRegistered = isset($this->registeredFills[$backgroundColor]); // We need to track the already registered background definitions if ($isBackgroundColorRegistered) { $registeredStyleId = $this->registeredFills[$backgroundColor]; $registeredFillId = $this->styleIdToFillMappingTable[$registeredStyleId]; $this->styleIdToFillMappingTable[$styleId] = $registeredFillId; } else { $this->registeredFills[$backgroundColor] = $styleId; $this->styleIdToFillMappingTable[$styleId] = $this->fillIndex++; } } else { // The fillId maps a style to a fill declaration // When there is no background color definition - we default to 0 $this->styleIdToFillMappingTable[$styleId] = 0; } }
php
protected function registerFill($style) { $styleId = $style->getId(); // Currently - only solid backgrounds are supported // so $backgroundColor is a scalar value (RGB Color) $backgroundColor = $style->getBackgroundColor(); if ($backgroundColor) { $isBackgroundColorRegistered = isset($this->registeredFills[$backgroundColor]); // We need to track the already registered background definitions if ($isBackgroundColorRegistered) { $registeredStyleId = $this->registeredFills[$backgroundColor]; $registeredFillId = $this->styleIdToFillMappingTable[$registeredStyleId]; $this->styleIdToFillMappingTable[$styleId] = $registeredFillId; } else { $this->registeredFills[$backgroundColor] = $styleId; $this->styleIdToFillMappingTable[$styleId] = $this->fillIndex++; } } else { // The fillId maps a style to a fill declaration // When there is no background color definition - we default to 0 $this->styleIdToFillMappingTable[$styleId] = 0; } }
[ "protected", "function", "registerFill", "(", "$", "style", ")", "{", "$", "styleId", "=", "$", "style", "->", "getId", "(", ")", ";", "// Currently - only solid backgrounds are supported", "// so $backgroundColor is a scalar value (RGB Color)", "$", "backgroundColor", "=", "$", "style", "->", "getBackgroundColor", "(", ")", ";", "if", "(", "$", "backgroundColor", ")", "{", "$", "isBackgroundColorRegistered", "=", "isset", "(", "$", "this", "->", "registeredFills", "[", "$", "backgroundColor", "]", ")", ";", "// We need to track the already registered background definitions", "if", "(", "$", "isBackgroundColorRegistered", ")", "{", "$", "registeredStyleId", "=", "$", "this", "->", "registeredFills", "[", "$", "backgroundColor", "]", ";", "$", "registeredFillId", "=", "$", "this", "->", "styleIdToFillMappingTable", "[", "$", "registeredStyleId", "]", ";", "$", "this", "->", "styleIdToFillMappingTable", "[", "$", "styleId", "]", "=", "$", "registeredFillId", ";", "}", "else", "{", "$", "this", "->", "registeredFills", "[", "$", "backgroundColor", "]", "=", "$", "styleId", ";", "$", "this", "->", "styleIdToFillMappingTable", "[", "$", "styleId", "]", "=", "$", "this", "->", "fillIndex", "++", ";", "}", "}", "else", "{", "// The fillId maps a style to a fill declaration", "// When there is no background color definition - we default to 0", "$", "this", "->", "styleIdToFillMappingTable", "[", "$", "styleId", "]", "=", "0", ";", "}", "}" ]
Register a fill definition @param \Box\Spout\Writer\Style\Style $style
[ "Register", "a", "fill", "definition" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php#L64-L90
219,092
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php
StyleHelper.registerBorder
protected function registerBorder($style) { $styleId = $style->getId(); if ($style->shouldApplyBorder()) { $border = $style->getBorder(); $serializedBorder = serialize($border); $isBorderAlreadyRegistered = isset($this->registeredBorders[$serializedBorder]); if ($isBorderAlreadyRegistered) { $registeredStyleId = $this->registeredBorders[$serializedBorder]; $registeredBorderId = $this->styleIdToBorderMappingTable[$registeredStyleId]; $this->styleIdToBorderMappingTable[$styleId] = $registeredBorderId; } else { $this->registeredBorders[$serializedBorder] = $styleId; $this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders); } } else { // If no border should be applied - the mapping is the default border: 0 $this->styleIdToBorderMappingTable[$styleId] = 0; } }
php
protected function registerBorder($style) { $styleId = $style->getId(); if ($style->shouldApplyBorder()) { $border = $style->getBorder(); $serializedBorder = serialize($border); $isBorderAlreadyRegistered = isset($this->registeredBorders[$serializedBorder]); if ($isBorderAlreadyRegistered) { $registeredStyleId = $this->registeredBorders[$serializedBorder]; $registeredBorderId = $this->styleIdToBorderMappingTable[$registeredStyleId]; $this->styleIdToBorderMappingTable[$styleId] = $registeredBorderId; } else { $this->registeredBorders[$serializedBorder] = $styleId; $this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders); } } else { // If no border should be applied - the mapping is the default border: 0 $this->styleIdToBorderMappingTable[$styleId] = 0; } }
[ "protected", "function", "registerBorder", "(", "$", "style", ")", "{", "$", "styleId", "=", "$", "style", "->", "getId", "(", ")", ";", "if", "(", "$", "style", "->", "shouldApplyBorder", "(", ")", ")", "{", "$", "border", "=", "$", "style", "->", "getBorder", "(", ")", ";", "$", "serializedBorder", "=", "serialize", "(", "$", "border", ")", ";", "$", "isBorderAlreadyRegistered", "=", "isset", "(", "$", "this", "->", "registeredBorders", "[", "$", "serializedBorder", "]", ")", ";", "if", "(", "$", "isBorderAlreadyRegistered", ")", "{", "$", "registeredStyleId", "=", "$", "this", "->", "registeredBorders", "[", "$", "serializedBorder", "]", ";", "$", "registeredBorderId", "=", "$", "this", "->", "styleIdToBorderMappingTable", "[", "$", "registeredStyleId", "]", ";", "$", "this", "->", "styleIdToBorderMappingTable", "[", "$", "styleId", "]", "=", "$", "registeredBorderId", ";", "}", "else", "{", "$", "this", "->", "registeredBorders", "[", "$", "serializedBorder", "]", "=", "$", "styleId", ";", "$", "this", "->", "styleIdToBorderMappingTable", "[", "$", "styleId", "]", "=", "count", "(", "$", "this", "->", "registeredBorders", ")", ";", "}", "}", "else", "{", "// If no border should be applied - the mapping is the default border: 0", "$", "this", "->", "styleIdToBorderMappingTable", "[", "$", "styleId", "]", "=", "0", ";", "}", "}" ]
Register a border definition @param \Box\Spout\Writer\Style\Style $style
[ "Register", "a", "border", "definition" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Helper/StyleHelper.php#L97-L120
219,093
moodle/moodle
admin/renderer.php
core_admin_renderer.install_licence_page
public function install_licence_page() { global $CFG; $output = ''; $copyrightnotice = text_to_html(get_string('gpl3')); $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack $continue = new single_button(new moodle_url($this->page->url, array( 'lang' => $CFG->lang, 'agreelicense' => 1)), get_string('continue'), 'get'); $output .= $this->header(); $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment'); $output .= $this->heading(get_string('copyrightnotice')); $output .= $this->box($copyrightnotice, 'copyrightnotice'); $output .= html_writer::empty_tag('br'); $output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License"); $output .= $this->footer(); return $output; }
php
public function install_licence_page() { global $CFG; $output = ''; $copyrightnotice = text_to_html(get_string('gpl3')); $copyrightnotice = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $copyrightnotice); // extremely ugly validation hack $continue = new single_button(new moodle_url($this->page->url, array( 'lang' => $CFG->lang, 'agreelicense' => 1)), get_string('continue'), 'get'); $output .= $this->header(); $output .= $this->heading('<a href="http://moodle.org">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment'); $output .= $this->heading(get_string('copyrightnotice')); $output .= $this->box($copyrightnotice, 'copyrightnotice'); $output .= html_writer::empty_tag('br'); $output .= $this->confirm(get_string('doyouagree'), $continue, "http://docs.moodle.org/dev/License"); $output .= $this->footer(); return $output; }
[ "public", "function", "install_licence_page", "(", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "''", ";", "$", "copyrightnotice", "=", "text_to_html", "(", "get_string", "(", "'gpl3'", ")", ")", ";", "$", "copyrightnotice", "=", "str_replace", "(", "'target=\"_blank\"'", ",", "'onclick=\"this.target=\\'_blank\\'\"'", ",", "$", "copyrightnotice", ")", ";", "// extremely ugly validation hack", "$", "continue", "=", "new", "single_button", "(", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'lang'", "=>", "$", "CFG", "->", "lang", ",", "'agreelicense'", "=>", "1", ")", ")", ",", "get_string", "(", "'continue'", ")", ",", "'get'", ")", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "'<a href=\"http://moodle.org\">Moodle</a> - Modular Object-Oriented Dynamic Learning Environment'", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'copyrightnotice'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "box", "(", "$", "copyrightnotice", ",", "'copyrightnotice'", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'br'", ")", ";", "$", "output", ".=", "$", "this", "->", "confirm", "(", "get_string", "(", "'doyouagree'", ")", ",", "$", "continue", ",", "\"http://docs.moodle.org/dev/License\"", ")", ";", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display the 'Do you acknowledge the terms of the GPL' page. The first page during install. @return string HTML to output.
[ "Display", "the", "Do", "you", "acknowledge", "the", "terms", "of", "the", "GPL", "page", ".", "The", "first", "page", "during", "install", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L39-L58
219,094
moodle/moodle
admin/renderer.php
core_admin_renderer.upgrade_stale_php_files_page
public function upgrade_stale_php_files_page() { $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('upgradestalefiles', 'admin')); $output .= $this->box_start('generalbox', 'notice'); $output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN); $output .= html_writer::empty_tag('br'); $output .= html_writer::tag('div', $this->single_button($this->page->url, get_string('reload'), 'get'), array('class' => 'buttons')); $output .= $this->box_end(); $output .= $this->footer(); return $output; }
php
public function upgrade_stale_php_files_page() { $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('upgradestalefiles', 'admin')); $output .= $this->box_start('generalbox', 'notice'); $output .= format_text(get_string('upgradestalefilesinfo', 'admin', get_docs_url('Upgrading')), FORMAT_MARKDOWN); $output .= html_writer::empty_tag('br'); $output .= html_writer::tag('div', $this->single_button($this->page->url, get_string('reload'), 'get'), array('class' => 'buttons')); $output .= $this->box_end(); $output .= $this->footer(); return $output; }
[ "public", "function", "upgrade_stale_php_files_page", "(", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'upgradestalefiles'", ",", "'admin'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "box_start", "(", "'generalbox'", ",", "'notice'", ")", ";", "$", "output", ".=", "format_text", "(", "get_string", "(", "'upgradestalefilesinfo'", ",", "'admin'", ",", "get_docs_url", "(", "'Upgrading'", ")", ")", ",", "FORMAT_MARKDOWN", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'br'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "$", "this", "->", "single_button", "(", "$", "this", "->", "page", "->", "url", ",", "get_string", "(", "'reload'", ")", ",", "'get'", ")", ",", "array", "(", "'class'", "=>", "'buttons'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "box_end", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display page explaining proper upgrade process, there can not be any PHP file leftovers... @return string HTML to output.
[ "Display", "page", "explaining", "proper", "upgrade", "process", "there", "can", "not", "be", "any", "PHP", "file", "leftovers", "..." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L66-L78
219,095
moodle/moodle
admin/renderer.php
core_admin_renderer.install_environment_page
public function install_environment_page($maturity, $envstatus, $environment_results, $release) { global $CFG; $output = ''; $output .= $this->header(); $output .= $this->maturity_warning($maturity); $output .= $this->heading("Moodle $release"); $output .= $this->release_notes_link(); $output .= $this->environment_check_table($envstatus, $environment_results); if (!$envstatus) { $output .= $this->upgrade_reload(new moodle_url($this->page->url, array('agreelicense' => 1, 'lang' => $CFG->lang))); } else { $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess'); $output .= $this->continue_button(new moodle_url($this->page->url, array( 'agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang))); } $output .= $this->footer(); return $output; }
php
public function install_environment_page($maturity, $envstatus, $environment_results, $release) { global $CFG; $output = ''; $output .= $this->header(); $output .= $this->maturity_warning($maturity); $output .= $this->heading("Moodle $release"); $output .= $this->release_notes_link(); $output .= $this->environment_check_table($envstatus, $environment_results); if (!$envstatus) { $output .= $this->upgrade_reload(new moodle_url($this->page->url, array('agreelicense' => 1, 'lang' => $CFG->lang))); } else { $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess'); $output .= $this->continue_button(new moodle_url($this->page->url, array( 'agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang))); } $output .= $this->footer(); return $output; }
[ "public", "function", "install_environment_page", "(", "$", "maturity", ",", "$", "envstatus", ",", "$", "environment_results", ",", "$", "release", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "maturity_warning", "(", "$", "maturity", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "\"Moodle $release\"", ")", ";", "$", "output", ".=", "$", "this", "->", "release_notes_link", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "environment_check_table", "(", "$", "envstatus", ",", "$", "environment_results", ")", ";", "if", "(", "!", "$", "envstatus", ")", "{", "$", "output", ".=", "$", "this", "->", "upgrade_reload", "(", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'agreelicense'", "=>", "1", ",", "'lang'", "=>", "$", "CFG", "->", "lang", ")", ")", ")", ";", "}", "else", "{", "$", "output", ".=", "$", "this", "->", "notification", "(", "get_string", "(", "'environmentok'", ",", "'admin'", ")", ",", "'notifysuccess'", ")", ";", "$", "output", ".=", "$", "this", "->", "continue_button", "(", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'agreelicense'", "=>", "1", ",", "'confirmrelease'", "=>", "1", ",", "'lang'", "=>", "$", "CFG", "->", "lang", ")", ")", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display the 'environment check' page that is displayed during install. @param int $maturity @param boolean $envstatus final result of the check (true/false) @param array $environment_results array of results gathered @param string $release moodle release @return string HTML to output.
[ "Display", "the", "environment", "check", "page", "that", "is", "displayed", "during", "install", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L88-L109
219,096
moodle/moodle
admin/renderer.php
core_admin_renderer.unsatisfied_dependencies_page
public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) { $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('pluginscheck', 'admin')); $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed))))); $output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true)); $output .= $this->warning(get_string('pluginschecktodo', 'admin')); $output .= $this->continue_button($reloadurl); $output .= $this->footer(); return $output; }
php
public function unsatisfied_dependencies_page($version, array $failed, moodle_url $reloadurl) { $output = ''; $output .= $this->header(); $output .= $this->heading(get_string('pluginscheck', 'admin')); $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed))))); $output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true)); $output .= $this->warning(get_string('pluginschecktodo', 'admin')); $output .= $this->continue_button($reloadurl); $output .= $this->footer(); return $output; }
[ "public", "function", "unsatisfied_dependencies_page", "(", "$", "version", ",", "array", "$", "failed", ",", "moodle_url", "$", "reloadurl", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'pluginscheck'", ",", "'admin'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "warning", "(", "get_string", "(", "'pluginscheckfailed'", ",", "'admin'", ",", "array", "(", "'pluginslist'", "=>", "implode", "(", "', '", ",", "array_unique", "(", "$", "failed", ")", ")", ")", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "plugins_check_table", "(", "core_plugin_manager", "::", "instance", "(", ")", ",", "$", "version", ",", "array", "(", "'xdep'", "=>", "true", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "warning", "(", "get_string", "(", "'pluginschecktodo'", ",", "'admin'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "continue_button", "(", "$", "reloadurl", ")", ";", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Displays the list of plugins with unsatisfied dependencies @param double|string|int $version Moodle on-disk version @param array $failed list of plugins with unsatisfied dependecies @param moodle_url $reloadurl URL of the page to recheck the dependencies @return string HTML
[ "Displays", "the", "list", "of", "plugins", "with", "unsatisfied", "dependencies" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L119-L132
219,097
moodle/moodle
admin/renderer.php
core_admin_renderer.upgrade_confirm_page
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) { $output = ''; $continueurl = new moodle_url($this->page->url, array('confirmupgrade' => 1, 'cache' => 0)); $continue = new single_button($continueurl, get_string('continue'), 'get'); $cancelurl = new moodle_url('/admin/index.php'); $output .= $this->header(); $output .= $this->maturity_warning($maturity); $output .= $this->test_site_warning($testsite); $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl); $output .= $this->footer(); return $output; }
php
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) { $output = ''; $continueurl = new moodle_url($this->page->url, array('confirmupgrade' => 1, 'cache' => 0)); $continue = new single_button($continueurl, get_string('continue'), 'get'); $cancelurl = new moodle_url('/admin/index.php'); $output .= $this->header(); $output .= $this->maturity_warning($maturity); $output .= $this->test_site_warning($testsite); $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl); $output .= $this->footer(); return $output; }
[ "public", "function", "upgrade_confirm_page", "(", "$", "strnewversion", ",", "$", "maturity", ",", "$", "testsite", ")", "{", "$", "output", "=", "''", ";", "$", "continueurl", "=", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'confirmupgrade'", "=>", "1", ",", "'cache'", "=>", "0", ")", ")", ";", "$", "continue", "=", "new", "single_button", "(", "$", "continueurl", ",", "get_string", "(", "'continue'", ")", ",", "'get'", ")", ";", "$", "cancelurl", "=", "new", "moodle_url", "(", "'/admin/index.php'", ")", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "maturity_warning", "(", "$", "maturity", ")", ";", "$", "output", ".=", "$", "this", "->", "test_site_warning", "(", "$", "testsite", ")", ";", "$", "output", ".=", "$", "this", "->", "confirm", "(", "get_string", "(", "'upgradesure'", ",", "'admin'", ",", "$", "strnewversion", ")", ",", "$", "continue", ",", "$", "cancelurl", ")", ";", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display the 'You are about to upgrade Moodle' page. The first page during upgrade. @param string $strnewversion @param int $maturity @param string $testsite @return string HTML to output.
[ "Display", "the", "You", "are", "about", "to", "upgrade", "Moodle", "page", ".", "The", "first", "page", "during", "upgrade", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L142-L156
219,098
moodle/moodle
admin/renderer.php
core_admin_renderer.upgrade_environment_page
public function upgrade_environment_page($release, $envstatus, $environment_results) { global $CFG; $output = ''; $output .= $this->header(); $output .= $this->heading("Moodle $release"); $output .= $this->release_notes_link(); $output .= $this->environment_check_table($envstatus, $environment_results); if (!$envstatus) { $output .= $this->upgrade_reload(new moodle_url($this->page->url, array('confirmupgrade' => 1, 'cache' => 0))); } else { $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess'); if (empty($CFG->skiplangupgrade) and current_language() !== 'en') { $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice'); } $output .= $this->continue_button(new moodle_url($this->page->url, array( 'confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0))); } $output .= $this->footer(); return $output; }
php
public function upgrade_environment_page($release, $envstatus, $environment_results) { global $CFG; $output = ''; $output .= $this->header(); $output .= $this->heading("Moodle $release"); $output .= $this->release_notes_link(); $output .= $this->environment_check_table($envstatus, $environment_results); if (!$envstatus) { $output .= $this->upgrade_reload(new moodle_url($this->page->url, array('confirmupgrade' => 1, 'cache' => 0))); } else { $output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess'); if (empty($CFG->skiplangupgrade) and current_language() !== 'en') { $output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice'); } $output .= $this->continue_button(new moodle_url($this->page->url, array( 'confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0))); } $output .= $this->footer(); return $output; }
[ "public", "function", "upgrade_environment_page", "(", "$", "release", ",", "$", "envstatus", ",", "$", "environment_results", ")", "{", "global", "$", "CFG", ";", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "\"Moodle $release\"", ")", ";", "$", "output", ".=", "$", "this", "->", "release_notes_link", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "environment_check_table", "(", "$", "envstatus", ",", "$", "environment_results", ")", ";", "if", "(", "!", "$", "envstatus", ")", "{", "$", "output", ".=", "$", "this", "->", "upgrade_reload", "(", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'confirmupgrade'", "=>", "1", ",", "'cache'", "=>", "0", ")", ")", ")", ";", "}", "else", "{", "$", "output", ".=", "$", "this", "->", "notification", "(", "get_string", "(", "'environmentok'", ",", "'admin'", ")", ",", "'notifysuccess'", ")", ";", "if", "(", "empty", "(", "$", "CFG", "->", "skiplangupgrade", ")", "and", "current_language", "(", ")", "!==", "'en'", ")", "{", "$", "output", ".=", "$", "this", "->", "box", "(", "get_string", "(", "'langpackwillbeupdated'", ",", "'admin'", ")", ",", "'generalbox'", ",", "'notice'", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "continue_button", "(", "new", "moodle_url", "(", "$", "this", "->", "page", "->", "url", ",", "array", "(", "'confirmupgrade'", "=>", "1", ",", "'confirmrelease'", "=>", "1", ",", "'cache'", "=>", "0", ")", ")", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display the environment page during the upgrade process. @param string $release @param boolean $envstatus final result of env check (true/false) @param array $environment_results array of results gathered @return string HTML to output.
[ "Display", "the", "environment", "page", "during", "the", "upgrade", "process", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L165-L191
219,099
moodle/moodle
admin/renderer.php
core_admin_renderer.upgrade_plugin_check_page
public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker, $version, $showallplugins, $reloadurl, $continueurl) { $output = ''; $output .= $this->header(); $output .= $this->box_start('generalbox', 'plugins-check-page'); $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'), array('class' => 'page-description')); $output .= $this->check_for_updates_button($checker, $reloadurl); $output .= $this->missing_dependencies($pluginman); $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins)); $output .= $this->box_end(); $output .= $this->upgrade_reload($reloadurl); if ($pluginman->some_plugins_updatable()) { $output .= $this->container_start('upgradepluginsinfo'); $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin')); $output .= $this->container_end(); } $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get'); $button->class = 'continuebutton'; $output .= $this->render($button); $output .= $this->footer(); return $output; }
php
public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker, $version, $showallplugins, $reloadurl, $continueurl) { $output = ''; $output .= $this->header(); $output .= $this->box_start('generalbox', 'plugins-check-page'); $output .= html_writer::tag('p', get_string('pluginchecknotice', 'core_plugin'), array('class' => 'page-description')); $output .= $this->check_for_updates_button($checker, $reloadurl); $output .= $this->missing_dependencies($pluginman); $output .= $this->plugins_check_table($pluginman, $version, array('full' => $showallplugins)); $output .= $this->box_end(); $output .= $this->upgrade_reload($reloadurl); if ($pluginman->some_plugins_updatable()) { $output .= $this->container_start('upgradepluginsinfo'); $output .= $this->help_icon('upgradepluginsinfo', 'core_admin', get_string('upgradepluginsfirst', 'core_admin')); $output .= $this->container_end(); } $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get'); $button->class = 'continuebutton'; $output .= $this->render($button); $output .= $this->footer(); return $output; }
[ "public", "function", "upgrade_plugin_check_page", "(", "core_plugin_manager", "$", "pluginman", ",", "\\", "core", "\\", "update", "\\", "checker", "$", "checker", ",", "$", "version", ",", "$", "showallplugins", ",", "$", "reloadurl", ",", "$", "continueurl", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "box_start", "(", "'generalbox'", ",", "'plugins-check-page'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'p'", ",", "get_string", "(", "'pluginchecknotice'", ",", "'core_plugin'", ")", ",", "array", "(", "'class'", "=>", "'page-description'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "check_for_updates_button", "(", "$", "checker", ",", "$", "reloadurl", ")", ";", "$", "output", ".=", "$", "this", "->", "missing_dependencies", "(", "$", "pluginman", ")", ";", "$", "output", ".=", "$", "this", "->", "plugins_check_table", "(", "$", "pluginman", ",", "$", "version", ",", "array", "(", "'full'", "=>", "$", "showallplugins", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "box_end", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "upgrade_reload", "(", "$", "reloadurl", ")", ";", "if", "(", "$", "pluginman", "->", "some_plugins_updatable", "(", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "container_start", "(", "'upgradepluginsinfo'", ")", ";", "$", "output", ".=", "$", "this", "->", "help_icon", "(", "'upgradepluginsinfo'", ",", "'core_admin'", ",", "get_string", "(", "'upgradepluginsfirst'", ",", "'core_admin'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "container_end", "(", ")", ";", "}", "$", "button", "=", "new", "single_button", "(", "$", "continueurl", ",", "get_string", "(", "'upgradestart'", ",", "'admin'", ")", ",", "'get'", ")", ";", "$", "button", "->", "class", "=", "'continuebutton'", ";", "$", "output", ".=", "$", "this", "->", "render", "(", "$", "button", ")", ";", "$", "output", ".=", "$", "this", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Display the upgrade page that lists all the plugins that require attention. @param core_plugin_manager $pluginman provides information about the plugins. @param \core\update\checker $checker provides information about available updates. @param int $version the version of the Moodle code from version.php. @param bool $showallplugins @param moodle_url $reloadurl @param moodle_url $continueurl @return string HTML to output.
[ "Display", "the", "upgrade", "page", "that", "lists", "all", "the", "plugins", "that", "require", "attention", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/renderer.php#L203-L229