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
212,900
moodle/moodle
lib/outputrenderers.php
core_renderer.render_login_signup_form
public function render_login_signup_form($form) { global $SITE; $context = $form->export_for_template($this); $url = $this->get_logo_url(); if ($url) { $url = $url->out(false); } $context['logourl'] = $url; $context['sitename'] = format_string($SITE->fullname, true, ['context' => context_course::instance(SITEID), "escape" => false]); return $this->render_from_template('core/signup_form_layout', $context); }
php
public function render_login_signup_form($form) { global $SITE; $context = $form->export_for_template($this); $url = $this->get_logo_url(); if ($url) { $url = $url->out(false); } $context['logourl'] = $url; $context['sitename'] = format_string($SITE->fullname, true, ['context' => context_course::instance(SITEID), "escape" => false]); return $this->render_from_template('core/signup_form_layout', $context); }
[ "public", "function", "render_login_signup_form", "(", "$", "form", ")", "{", "global", "$", "SITE", ";", "$", "context", "=", "$", "form", "->", "export_for_template", "(", "$", "this", ")", ";", "$", "url", "=", "$", "this", "->", "get_logo_url", "(", ")", ";", "if", "(", "$", "url", ")", "{", "$", "url", "=", "$", "url", "->", "out", "(", "false", ")", ";", "}", "$", "context", "[", "'logourl'", "]", "=", "$", "url", ";", "$", "context", "[", "'sitename'", "]", "=", "format_string", "(", "$", "SITE", "->", "fullname", ",", "true", ",", "[", "'context'", "=>", "context_course", "::", "instance", "(", "SITEID", ")", ",", "\"escape\"", "=>", "false", "]", ")", ";", "return", "$", "this", "->", "render_from_template", "(", "'core/signup_form_layout'", ",", "$", "context", ")", ";", "}" ]
Render the login signup form into a nice template for the theme. @param mform $form @return string
[ "Render", "the", "login", "signup", "form", "into", "a", "nice", "template", "for", "the", "theme", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4627-L4640
212,901
moodle/moodle
lib/outputrenderers.php
core_renderer.render_progress_bar
public function render_progress_bar(progress_bar $bar) { global $PAGE; $data = $bar->export_for_template($this); return $this->render_from_template('core/progress_bar', $data); }
php
public function render_progress_bar(progress_bar $bar) { global $PAGE; $data = $bar->export_for_template($this); return $this->render_from_template('core/progress_bar', $data); }
[ "public", "function", "render_progress_bar", "(", "progress_bar", "$", "bar", ")", "{", "global", "$", "PAGE", ";", "$", "data", "=", "$", "bar", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "$", "this", "->", "render_from_template", "(", "'core/progress_bar'", ",", "$", "data", ")", ";", "}" ]
Renders a progress bar. Do not use $OUTPUT->render($bar), instead use progress_bar::create(). @param progress_bar $bar The bar. @return string HTML fragment
[ "Renders", "a", "progress", "bar", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4674-L4678
212,902
moodle/moodle
lib/outputrenderers.php
core_renderer_cli.heading
public function heading($text, $level = 2, $classes = 'main', $id = null) { $text .= "\n"; switch ($level) { case 1: return '=>' . $text; case 2: return '-->' . $text; default: return $text; } }
php
public function heading($text, $level = 2, $classes = 'main', $id = null) { $text .= "\n"; switch ($level) { case 1: return '=>' . $text; case 2: return '-->' . $text; default: return $text; } }
[ "public", "function", "heading", "(", "$", "text", ",", "$", "level", "=", "2", ",", "$", "classes", "=", "'main'", ",", "$", "id", "=", "null", ")", "{", "$", "text", ".=", "\"\\n\"", ";", "switch", "(", "$", "level", ")", "{", "case", "1", ":", "return", "'=>'", ".", "$", "text", ";", "case", "2", ":", "return", "'-->'", ".", "$", "text", ";", "default", ":", "return", "$", "text", ";", "}", "}" ]
Returns a template fragment representing a Heading. @param string $text The text of the heading @param int $level The level of importance of the heading @param string $classes A space-separated list of CSS classes @param string $id An optional ID @return string A template fragment for a heading
[ "Returns", "a", "template", "fragment", "representing", "a", "Heading", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4712-L4722
212,903
moodle/moodle
lib/outputrenderers.php
core_renderer_ajax.header
public function header() { // unfortunately YUI iframe upload does not support application/json if (!empty($_FILES)) { @header('Content-type: text/plain; charset=utf-8'); if (!core_useragent::supports_json_contenttype()) { @header('X-Content-Type-Options: nosniff'); } } else if (!core_useragent::supports_json_contenttype()) { @header('Content-type: text/plain; charset=utf-8'); @header('X-Content-Type-Options: nosniff'); } else { @header('Content-type: application/json; charset=utf-8'); } // Headers to make it not cacheable and json @header('Cache-Control: no-store, no-cache, must-revalidate'); @header('Cache-Control: post-check=0, pre-check=0', false); @header('Pragma: no-cache'); @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); @header('Accept-Ranges: none'); }
php
public function header() { // unfortunately YUI iframe upload does not support application/json if (!empty($_FILES)) { @header('Content-type: text/plain; charset=utf-8'); if (!core_useragent::supports_json_contenttype()) { @header('X-Content-Type-Options: nosniff'); } } else if (!core_useragent::supports_json_contenttype()) { @header('Content-type: text/plain; charset=utf-8'); @header('X-Content-Type-Options: nosniff'); } else { @header('Content-type: application/json; charset=utf-8'); } // Headers to make it not cacheable and json @header('Cache-Control: no-store, no-cache, must-revalidate'); @header('Cache-Control: post-check=0, pre-check=0', false); @header('Pragma: no-cache'); @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); @header('Accept-Ranges: none'); }
[ "public", "function", "header", "(", ")", "{", "// unfortunately YUI iframe upload does not support application/json", "if", "(", "!", "empty", "(", "$", "_FILES", ")", ")", "{", "@", "header", "(", "'Content-type: text/plain; charset=utf-8'", ")", ";", "if", "(", "!", "core_useragent", "::", "supports_json_contenttype", "(", ")", ")", "{", "@", "header", "(", "'X-Content-Type-Options: nosniff'", ")", ";", "}", "}", "else", "if", "(", "!", "core_useragent", "::", "supports_json_contenttype", "(", ")", ")", "{", "@", "header", "(", "'Content-type: text/plain; charset=utf-8'", ")", ";", "@", "header", "(", "'X-Content-Type-Options: nosniff'", ")", ";", "}", "else", "{", "@", "header", "(", "'Content-type: application/json; charset=utf-8'", ")", ";", "}", "// Headers to make it not cacheable and json", "@", "header", "(", "'Cache-Control: no-store, no-cache, must-revalidate'", ")", ";", "@", "header", "(", "'Cache-Control: post-check=0, pre-check=0'", ",", "false", ")", ";", "@", "header", "(", "'Pragma: no-cache'", ")", ";", "@", "header", "(", "'Expires: Mon, 20 Aug 1969 09:23:00 GMT'", ")", ";", "@", "header", "(", "'Last-Modified: '", ".", "gmdate", "(", "'D, d M Y H:i:s'", ")", ".", "' GMT'", ")", ";", "@", "header", "(", "'Accept-Ranges: none'", ")", ";", "}" ]
Prepares the start of an AJAX output.
[ "Prepares", "the", "start", "of", "an", "AJAX", "output", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4863-L4884
212,904
moodle/moodle
lib/outputrenderers.php
core_renderer_maintenance.confirm
public function confirm($message, $continue, $cancel) { // We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be // from any previous version of Moodle). if ($continue instanceof single_button) { $continue->primary = true; } else if (is_string($continue)) { $continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true); } else if ($continue instanceof moodle_url) { $continue = new single_button($continue, get_string('continue'), 'post', true); } else { throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL' . ' (string/moodle_url) or a single_button instance.'); } if ($cancel instanceof single_button) { $output = ''; } else if (is_string($cancel)) { $cancel = new single_button(new moodle_url($cancel), get_string('cancel'), 'get'); } else if ($cancel instanceof moodle_url) { $cancel = new single_button($cancel, get_string('cancel'), 'get'); } else { throw new coding_exception('The cancel param to $OUTPUT->confirm() must be either a URL' . ' (string/moodle_url) or a single_button instance.'); } $output = $this->box_start('generalbox', 'notice'); $output .= html_writer::tag('h4', get_string('confirm')); $output .= html_writer::tag('p', $message); $output .= html_writer::tag('div', $this->render($continue) . $this->render($cancel), array('class' => 'buttons')); $output .= $this->box_end(); return $output; }
php
public function confirm($message, $continue, $cancel) { // We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be // from any previous version of Moodle). if ($continue instanceof single_button) { $continue->primary = true; } else if (is_string($continue)) { $continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true); } else if ($continue instanceof moodle_url) { $continue = new single_button($continue, get_string('continue'), 'post', true); } else { throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL' . ' (string/moodle_url) or a single_button instance.'); } if ($cancel instanceof single_button) { $output = ''; } else if (is_string($cancel)) { $cancel = new single_button(new moodle_url($cancel), get_string('cancel'), 'get'); } else if ($cancel instanceof moodle_url) { $cancel = new single_button($cancel, get_string('cancel'), 'get'); } else { throw new coding_exception('The cancel param to $OUTPUT->confirm() must be either a URL' . ' (string/moodle_url) or a single_button instance.'); } $output = $this->box_start('generalbox', 'notice'); $output .= html_writer::tag('h4', get_string('confirm')); $output .= html_writer::tag('p', $message); $output .= html_writer::tag('div', $this->render($continue) . $this->render($cancel), array('class' => 'buttons')); $output .= $this->box_end(); return $output; }
[ "public", "function", "confirm", "(", "$", "message", ",", "$", "continue", ",", "$", "cancel", ")", "{", "// We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be", "// from any previous version of Moodle).", "if", "(", "$", "continue", "instanceof", "single_button", ")", "{", "$", "continue", "->", "primary", "=", "true", ";", "}", "else", "if", "(", "is_string", "(", "$", "continue", ")", ")", "{", "$", "continue", "=", "new", "single_button", "(", "new", "moodle_url", "(", "$", "continue", ")", ",", "get_string", "(", "'continue'", ")", ",", "'post'", ",", "true", ")", ";", "}", "else", "if", "(", "$", "continue", "instanceof", "moodle_url", ")", "{", "$", "continue", "=", "new", "single_button", "(", "$", "continue", ",", "get_string", "(", "'continue'", ")", ",", "'post'", ",", "true", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'The continue param to $OUTPUT->confirm() must be either a URL'", ".", "' (string/moodle_url) or a single_button instance.'", ")", ";", "}", "if", "(", "$", "cancel", "instanceof", "single_button", ")", "{", "$", "output", "=", "''", ";", "}", "else", "if", "(", "is_string", "(", "$", "cancel", ")", ")", "{", "$", "cancel", "=", "new", "single_button", "(", "new", "moodle_url", "(", "$", "cancel", ")", ",", "get_string", "(", "'cancel'", ")", ",", "'get'", ")", ";", "}", "else", "if", "(", "$", "cancel", "instanceof", "moodle_url", ")", "{", "$", "cancel", "=", "new", "single_button", "(", "$", "cancel", ",", "get_string", "(", "'cancel'", ")", ",", "'get'", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'The cancel param to $OUTPUT->confirm() must be either a URL'", ".", "' (string/moodle_url) or a single_button instance.'", ")", ";", "}", "$", "output", "=", "$", "this", "->", "box_start", "(", "'generalbox'", ",", "'notice'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'h4'", ",", "get_string", "(", "'confirm'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'p'", ",", "$", "message", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "$", "this", "->", "render", "(", "$", "continue", ")", ".", "$", "this", "->", "render", "(", "$", "cancel", ")", ",", "array", "(", "'class'", "=>", "'buttons'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "box_end", "(", ")", ";", "return", "$", "output", ";", "}" ]
Overridden confirm message for upgrades. @param string $message The question to ask the user @param single_button|moodle_url|string $continue The single_button component representing the Continue answer. @param single_button|moodle_url|string $cancel The single_button component representing the Cancel answer. @return string HTML fragment
[ "Overridden", "confirm", "message", "for", "upgrades", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L5043-L5074
212,905
moodle/moodle
lib/lessphp/Tree/Mixin/Call.php
Less_Tree_Mixin_Call.Format
private function Format($args){ $message = array(); if( $args ){ foreach($args as $a){ $argValue = ''; if( $a['name'] ){ $argValue .= $a['name'] . ':'; } if( is_object($a['value']) ){ $argValue .= $a['value']->toCSS(); }else{ $argValue .= '???'; } $message[] = $argValue; } } return implode(', ',$message); }
php
private function Format($args){ $message = array(); if( $args ){ foreach($args as $a){ $argValue = ''; if( $a['name'] ){ $argValue .= $a['name'] . ':'; } if( is_object($a['value']) ){ $argValue .= $a['value']->toCSS(); }else{ $argValue .= '???'; } $message[] = $argValue; } } return implode(', ',$message); }
[ "private", "function", "Format", "(", "$", "args", ")", "{", "$", "message", "=", "array", "(", ")", ";", "if", "(", "$", "args", ")", "{", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "$", "argValue", "=", "''", ";", "if", "(", "$", "a", "[", "'name'", "]", ")", "{", "$", "argValue", ".=", "$", "a", "[", "'name'", "]", ".", "':'", ";", "}", "if", "(", "is_object", "(", "$", "a", "[", "'value'", "]", ")", ")", "{", "$", "argValue", ".=", "$", "a", "[", "'value'", "]", "->", "toCSS", "(", ")", ";", "}", "else", "{", "$", "argValue", ".=", "'???'", ";", "}", "$", "message", "[", "]", "=", "$", "argValue", ";", "}", "}", "return", "implode", "(", "', '", ",", "$", "message", ")", ";", "}" ]
Format the args for use in exception messages
[ "Format", "the", "args", "for", "use", "in", "exception", "messages" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Tree/Mixin/Call.php#L157-L174
212,906
moodle/moodle
lib/lessphp/Tree/Mixin/Call.php
Less_Tree_Mixin_Call.IsRecursive
private function IsRecursive( $env, $mixin ){ foreach($env->frames as $recur_frame){ if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ if( $mixin === $recur_frame ){ return true; } if( isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset ){ return true; } } } return false; }
php
private function IsRecursive( $env, $mixin ){ foreach($env->frames as $recur_frame){ if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ if( $mixin === $recur_frame ){ return true; } if( isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset ){ return true; } } } return false; }
[ "private", "function", "IsRecursive", "(", "$", "env", ",", "$", "mixin", ")", "{", "foreach", "(", "$", "env", "->", "frames", "as", "$", "recur_frame", ")", "{", "if", "(", "!", "(", "$", "mixin", "instanceof", "Less_Tree_Mixin_Definition", ")", ")", "{", "if", "(", "$", "mixin", "===", "$", "recur_frame", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "recur_frame", "->", "originalRuleset", ")", "&&", "$", "mixin", "->", "ruleset_id", "===", "$", "recur_frame", "->", "originalRuleset", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Are we in a recursive mixin call? @return bool
[ "Are", "we", "in", "a", "recursive", "mixin", "call?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Tree/Mixin/Call.php#L182-L198
212,907
moodle/moodle
privacy/classes/local/request/contextlist_collection.php
contextlist_collection.add_contextlist
public function add_contextlist(contextlist_base $contextlist) { $component = $contextlist->get_component(); if (empty($component)) { throw new \moodle_exception("The contextlist must have a component set"); } if (isset($this->contextlists[$component])) { throw new \moodle_exception("A contextlist has already been added for the '{$component}' component"); } $this->contextlists[$component] = $contextlist; return $this; }
php
public function add_contextlist(contextlist_base $contextlist) { $component = $contextlist->get_component(); if (empty($component)) { throw new \moodle_exception("The contextlist must have a component set"); } if (isset($this->contextlists[$component])) { throw new \moodle_exception("A contextlist has already been added for the '{$component}' component"); } $this->contextlists[$component] = $contextlist; return $this; }
[ "public", "function", "add_contextlist", "(", "contextlist_base", "$", "contextlist", ")", "{", "$", "component", "=", "$", "contextlist", "->", "get_component", "(", ")", ";", "if", "(", "empty", "(", "$", "component", ")", ")", "{", "throw", "new", "\\", "moodle_exception", "(", "\"The contextlist must have a component set\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "contextlists", "[", "$", "component", "]", ")", ")", "{", "throw", "new", "\\", "moodle_exception", "(", "\"A contextlist has already been added for the '{$component}' component\"", ")", ";", "}", "$", "this", "->", "contextlists", "[", "$", "component", "]", "=", "$", "contextlist", ";", "return", "$", "this", ";", "}" ]
Add a contextlist to this collection. @param contextlist_base $contextlist the contextlist to export. @return $this
[ "Add", "a", "contextlist", "to", "this", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/contextlist_collection.php#L77-L89
212,908
moodle/moodle
privacy/classes/local/request/contextlist_collection.php
contextlist_collection.get_contextlist_for_component
public function get_contextlist_for_component(string $component) { if (isset($this->contextlists[$component])) { return $this->contextlists[$component]; } return null; }
php
public function get_contextlist_for_component(string $component) { if (isset($this->contextlists[$component])) { return $this->contextlists[$component]; } return null; }
[ "public", "function", "get_contextlist_for_component", "(", "string", "$", "component", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "contextlists", "[", "$", "component", "]", ")", ")", "{", "return", "$", "this", "->", "contextlists", "[", "$", "component", "]", ";", "}", "return", "null", ";", "}" ]
Get the contextlist for the specified component. @param string $component the frankenstyle name of the component to fetch for. @return contextlist_base|null
[ "Get", "the", "contextlist", "for", "the", "specified", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/contextlist_collection.php#L107-L113
212,909
moodle/moodle
lib/phpexcel/PHPExcel/Writer/Excel2007/Rels.php
PHPExcel_Writer_Excel2007_Rels.writeRelationships
public function writeRelationships(PHPExcel $pPHPExcel = null) { // Create XML writer $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', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); if (!empty($customPropertyList)) { // Relationship docProps/app.xml $this->writeRelationship( $objWriter, 4, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', 'docProps/custom.xml' ); } // Relationship docProps/app.xml $this->writeRelationship( $objWriter, 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', 'docProps/app.xml' ); // Relationship docProps/core.xml $this->writeRelationship( $objWriter, 2, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', 'docProps/core.xml' ); // Relationship xl/workbook.xml $this->writeRelationship( $objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'xl/workbook.xml' ); // a custom UI in workbook ? if ($pPHPExcel->hasRibbon()) { $this->_writeRelationShip( $objWriter, 5, 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility', $pPHPExcel->getRibbonXMLData('target') ); } $objWriter->endElement(); return $objWriter->getData(); }
php
public function writeRelationships(PHPExcel $pPHPExcel = null) { // Create XML writer $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', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); if (!empty($customPropertyList)) { // Relationship docProps/app.xml $this->writeRelationship( $objWriter, 4, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', 'docProps/custom.xml' ); } // Relationship docProps/app.xml $this->writeRelationship( $objWriter, 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', 'docProps/app.xml' ); // Relationship docProps/core.xml $this->writeRelationship( $objWriter, 2, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', 'docProps/core.xml' ); // Relationship xl/workbook.xml $this->writeRelationship( $objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'xl/workbook.xml' ); // a custom UI in workbook ? if ($pPHPExcel->hasRibbon()) { $this->_writeRelationShip( $objWriter, 5, 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility', $pPHPExcel->getRibbonXMLData('target') ); } $objWriter->endElement(); return $objWriter->getData(); }
[ "public", "function", "writeRelationships", "(", "PHPExcel", "$", "pPHPExcel", "=", "null", ")", "{", "// Create XML writer", "$", "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'", ",", "'yes'", ")", ";", "// Relationships", "$", "objWriter", "->", "startElement", "(", "'Relationships'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns'", ",", "'http://schemas.openxmlformats.org/package/2006/relationships'", ")", ";", "$", "customPropertyList", "=", "$", "pPHPExcel", "->", "getProperties", "(", ")", "->", "getCustomProperties", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "customPropertyList", ")", ")", "{", "// Relationship docProps/app.xml", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "4", ",", "'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties'", ",", "'docProps/custom.xml'", ")", ";", "}", "// Relationship docProps/app.xml", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "3", ",", "'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties'", ",", "'docProps/app.xml'", ")", ";", "// Relationship docProps/core.xml", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "2", ",", "'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties'", ",", "'docProps/core.xml'", ")", ";", "// Relationship xl/workbook.xml", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "1", ",", "'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'", ",", "'xl/workbook.xml'", ")", ";", "// a custom UI in workbook ?", "if", "(", "$", "pPHPExcel", "->", "hasRibbon", "(", ")", ")", "{", "$", "this", "->", "_writeRelationShip", "(", "$", "objWriter", ",", "5", ",", "'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility'", ",", "$", "pPHPExcel", "->", "getRibbonXMLData", "(", "'target'", ")", ")", ";", "}", "$", "objWriter", "->", "endElement", "(", ")", ";", "return", "$", "objWriter", "->", "getData", "(", ")", ";", "}" ]
Write relationships to XML format @param PHPExcel $pPHPExcel @return string XML Output @throws PHPExcel_Writer_Exception
[ "Write", "relationships", "to", "XML", "format" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Writer/Excel2007/Rels.php#L37-L102
212,910
moodle/moodle
lib/phpexcel/PHPExcel/Writer/Excel2007/Rels.php
PHPExcel_Writer_Excel2007_Rels.writeDrawingRelationships
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = false) { // Create XML writer $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', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Loop through images and write relationships $i = 1; $iterator = $pWorksheet->getDrawingCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing || $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) { // Write relationship for image drawing $this->writeRelationship( $objWriter, $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename()) ); } $iterator->next(); ++$i; } if ($includeCharts) { // Loop through charts and write relationships $chartCount = $pWorksheet->getChartCount(); if ($chartCount > 0) { for ($c = 0; $c < $chartCount; ++$c) { $this->writeRelationship( $objWriter, $i++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/chart' . ++$chartRef . '.xml' ); } } } $objWriter->endElement(); return $objWriter->getData(); }
php
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = false) { // Create XML writer $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', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Loop through images and write relationships $i = 1; $iterator = $pWorksheet->getDrawingCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing || $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) { // Write relationship for image drawing $this->writeRelationship( $objWriter, $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename()) ); } $iterator->next(); ++$i; } if ($includeCharts) { // Loop through charts and write relationships $chartCount = $pWorksheet->getChartCount(); if ($chartCount > 0) { for ($c = 0; $c < $chartCount; ++$c) { $this->writeRelationship( $objWriter, $i++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/chart' . ++$chartRef . '.xml' ); } } } $objWriter->endElement(); return $objWriter->getData(); }
[ "public", "function", "writeDrawingRelationships", "(", "PHPExcel_Worksheet", "$", "pWorksheet", "=", "null", ",", "&", "$", "chartRef", ",", "$", "includeCharts", "=", "false", ")", "{", "// Create XML writer", "$", "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'", ",", "'yes'", ")", ";", "// Relationships", "$", "objWriter", "->", "startElement", "(", "'Relationships'", ")", ";", "$", "objWriter", "->", "writeAttribute", "(", "'xmlns'", ",", "'http://schemas.openxmlformats.org/package/2006/relationships'", ")", ";", "// Loop through images and write relationships", "$", "i", "=", "1", ";", "$", "iterator", "=", "$", "pWorksheet", "->", "getDrawingCollection", "(", ")", "->", "getIterator", "(", ")", ";", "while", "(", "$", "iterator", "->", "valid", "(", ")", ")", "{", "if", "(", "$", "iterator", "->", "current", "(", ")", "instanceof", "PHPExcel_Worksheet_Drawing", "||", "$", "iterator", "->", "current", "(", ")", "instanceof", "PHPExcel_Worksheet_MemoryDrawing", ")", "{", "// Write relationship for image drawing", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "$", "i", ",", "'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'", ",", "'../media/'", ".", "str_replace", "(", "' '", ",", "''", ",", "$", "iterator", "->", "current", "(", ")", "->", "getIndexedFilename", "(", ")", ")", ")", ";", "}", "$", "iterator", "->", "next", "(", ")", ";", "++", "$", "i", ";", "}", "if", "(", "$", "includeCharts", ")", "{", "// Loop through charts and write relationships", "$", "chartCount", "=", "$", "pWorksheet", "->", "getChartCount", "(", ")", ";", "if", "(", "$", "chartCount", ">", "0", ")", "{", "for", "(", "$", "c", "=", "0", ";", "$", "c", "<", "$", "chartCount", ";", "++", "$", "c", ")", "{", "$", "this", "->", "writeRelationship", "(", "$", "objWriter", ",", "$", "i", "++", ",", "'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart'", ",", "'../charts/chart'", ".", "++", "$", "chartRef", ".", "'.xml'", ")", ";", "}", "}", "}", "$", "objWriter", "->", "endElement", "(", ")", ";", "return", "$", "objWriter", "->", "getData", "(", ")", ";", "}" ]
Write drawing relationships to XML format @param PHPExcel_Worksheet $pWorksheet @param int &$chartRef Chart ID @param boolean $includeCharts Flag indicating if we should write charts @return string XML Output @throws PHPExcel_Writer_Exception
[ "Write", "drawing", "relationships", "to", "XML", "format" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Writer/Excel2007/Rels.php#L300-L354
212,911
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.add_field
protected function add_field(\stdClass $data) { foreach ($data->fields as $field) { $this->_form->addElement($field); } if (!empty($data->helps)) { foreach ($data->helps as $fieldname => $helpdata) { $help = array_merge([$fieldname], $helpdata); call_user_func_array([$this->_form, 'addHelpButton'], $help); } } if (!empty($data->types)) { foreach ($data->types as $fieldname => $type) { $this->_form->setType($fieldname, $type); } } if (!empty($data->rules)) { foreach ($data->rules as $fieldname => $ruledata) { $rule = array_merge([$fieldname], $ruledata); call_user_func_array([$this->_form, 'addRule'], $rule); } } if (!empty($data->defaults)) { foreach ($data->defaults as $fieldname => $default) { $this->_form($fieldname, $default); } } }
php
protected function add_field(\stdClass $data) { foreach ($data->fields as $field) { $this->_form->addElement($field); } if (!empty($data->helps)) { foreach ($data->helps as $fieldname => $helpdata) { $help = array_merge([$fieldname], $helpdata); call_user_func_array([$this->_form, 'addHelpButton'], $help); } } if (!empty($data->types)) { foreach ($data->types as $fieldname => $type) { $this->_form->setType($fieldname, $type); } } if (!empty($data->rules)) { foreach ($data->rules as $fieldname => $ruledata) { $rule = array_merge([$fieldname], $ruledata); call_user_func_array([$this->_form, 'addRule'], $rule); } } if (!empty($data->defaults)) { foreach ($data->defaults as $fieldname => $default) { $this->_form($fieldname, $default); } } }
[ "protected", "function", "add_field", "(", "\\", "stdClass", "$", "data", ")", "{", "foreach", "(", "$", "data", "->", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "_form", "->", "addElement", "(", "$", "field", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "helps", ")", ")", "{", "foreach", "(", "$", "data", "->", "helps", "as", "$", "fieldname", "=>", "$", "helpdata", ")", "{", "$", "help", "=", "array_merge", "(", "[", "$", "fieldname", "]", ",", "$", "helpdata", ")", ";", "call_user_func_array", "(", "[", "$", "this", "->", "_form", ",", "'addHelpButton'", "]", ",", "$", "help", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "types", ")", ")", "{", "foreach", "(", "$", "data", "->", "types", "as", "$", "fieldname", "=>", "$", "type", ")", "{", "$", "this", "->", "_form", "->", "setType", "(", "$", "fieldname", ",", "$", "type", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "rules", ")", ")", "{", "foreach", "(", "$", "data", "->", "rules", "as", "$", "fieldname", "=>", "$", "ruledata", ")", "{", "$", "rule", "=", "array_merge", "(", "[", "$", "fieldname", "]", ",", "$", "ruledata", ")", ";", "call_user_func_array", "(", "[", "$", "this", "->", "_form", ",", "'addRule'", "]", ",", "$", "rule", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "defaults", ")", ")", "{", "foreach", "(", "$", "data", "->", "defaults", "as", "$", "fieldname", "=>", "$", "default", ")", "{", "$", "this", "->", "_form", "(", "$", "fieldname", ",", "$", "default", ")", ";", "}", "}", "}" ]
Add a fieldset to the current form. @param \stdClass $data
[ "Add", "a", "fieldset", "to", "the", "current", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L90-L120
212,912
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.filter_data_for_persistent
public function filter_data_for_persistent($data) { $data = parent::filter_data_for_persistent($data); $classname = static::$persistentclass; $properties = $classname::properties_definition(); $data = (object) array_filter((array) $data, function($value, $key) use ($properties) { return isset($properties[$key]); }, ARRAY_FILTER_USE_BOTH); return $data; }
php
public function filter_data_for_persistent($data) { $data = parent::filter_data_for_persistent($data); $classname = static::$persistentclass; $properties = $classname::properties_definition(); $data = (object) array_filter((array) $data, function($value, $key) use ($properties) { return isset($properties[$key]); }, ARRAY_FILTER_USE_BOTH); return $data; }
[ "public", "function", "filter_data_for_persistent", "(", "$", "data", ")", "{", "$", "data", "=", "parent", "::", "filter_data_for_persistent", "(", "$", "data", ")", ";", "$", "classname", "=", "static", "::", "$", "persistentclass", ";", "$", "properties", "=", "$", "classname", "::", "properties_definition", "(", ")", ";", "$", "data", "=", "(", "object", ")", "array_filter", "(", "(", "array", ")", "$", "data", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "properties", ")", "{", "return", "isset", "(", "$", "properties", "[", "$", "key", "]", ")", ";", "}", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "return", "$", "data", ";", "}" ]
Converts fields. @param \stdClass $data @return \stdClass
[ "Converts", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L229-L240
212,913
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.get_lawful_base_field
protected function get_lawful_base_field(string $prefix = '') : \stdClass { $fieldname = "{$prefix}lawfulbases"; $data = (object) [ 'fields' => [], ]; $bases = []; foreach (\tool_dataprivacy\purpose::GDPR_ART_6_1_ITEMS as $article) { $key = 'gdpr_art_6_1_' . $article; $bases[$key] = get_string("{$key}_name", 'tool_dataprivacy'); } $data->fields[] = $this->_form->createElement('autocomplete', $fieldname, get_string('lawfulbases', 'tool_dataprivacy'), $bases, [ 'multiple' => true, ] ); $data->helps = [ $fieldname => ['lawfulbases', 'tool_dataprivacy'], ]; $data->advanceds = [ $fieldname => true, ]; return $data; }
php
protected function get_lawful_base_field(string $prefix = '') : \stdClass { $fieldname = "{$prefix}lawfulbases"; $data = (object) [ 'fields' => [], ]; $bases = []; foreach (\tool_dataprivacy\purpose::GDPR_ART_6_1_ITEMS as $article) { $key = 'gdpr_art_6_1_' . $article; $bases[$key] = get_string("{$key}_name", 'tool_dataprivacy'); } $data->fields[] = $this->_form->createElement('autocomplete', $fieldname, get_string('lawfulbases', 'tool_dataprivacy'), $bases, [ 'multiple' => true, ] ); $data->helps = [ $fieldname => ['lawfulbases', 'tool_dataprivacy'], ]; $data->advanceds = [ $fieldname => true, ]; return $data; }
[ "protected", "function", "get_lawful_base_field", "(", "string", "$", "prefix", "=", "''", ")", ":", "\\", "stdClass", "{", "$", "fieldname", "=", "\"{$prefix}lawfulbases\"", ";", "$", "data", "=", "(", "object", ")", "[", "'fields'", "=>", "[", "]", ",", "]", ";", "$", "bases", "=", "[", "]", ";", "foreach", "(", "\\", "tool_dataprivacy", "\\", "purpose", "::", "GDPR_ART_6_1_ITEMS", "as", "$", "article", ")", "{", "$", "key", "=", "'gdpr_art_6_1_'", ".", "$", "article", ";", "$", "bases", "[", "$", "key", "]", "=", "get_string", "(", "\"{$key}_name\"", ",", "'tool_dataprivacy'", ")", ";", "}", "$", "data", "->", "fields", "[", "]", "=", "$", "this", "->", "_form", "->", "createElement", "(", "'autocomplete'", ",", "$", "fieldname", ",", "get_string", "(", "'lawfulbases'", ",", "'tool_dataprivacy'", ")", ",", "$", "bases", ",", "[", "'multiple'", "=>", "true", ",", "]", ")", ";", "$", "data", "->", "helps", "=", "[", "$", "fieldname", "=>", "[", "'lawfulbases'", ",", "'tool_dataprivacy'", "]", ",", "]", ";", "$", "data", "->", "advanceds", "=", "[", "$", "fieldname", "=>", "true", ",", "]", ";", "return", "$", "data", ";", "}" ]
Get the mform field for lawful bases. @param string $prefix The prefix to apply to the field @return \stdClass
[ "Get", "the", "mform", "field", "for", "lawful", "bases", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L300-L329
212,914
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.get_retention_period_fields
protected function get_retention_period_fields(string $prefix = '') : \stdClass { $prefix = "{$prefix}retentionperiod"; $data = (object) [ 'fields' => [], 'types' => [], ]; $number = $this->_form->createElement('text', "{$prefix}number", null, ['size' => 8]); $data->types["{$prefix}number"] = PARAM_INT; $unitoptions = [ 'Y' => get_string('years'), 'M' => strtolower(get_string('months')), 'D' => strtolower(get_string('days')) ]; $unit = $this->_form->createElement('select', "{$prefix}unit", '', $unitoptions); $data->fields[] = $this->_form->createElement( 'group', $prefix, get_string('retentionperiod', 'tool_dataprivacy'), [ 'number' => $number, 'unit' => $unit, ], null, false ); return $data; }
php
protected function get_retention_period_fields(string $prefix = '') : \stdClass { $prefix = "{$prefix}retentionperiod"; $data = (object) [ 'fields' => [], 'types' => [], ]; $number = $this->_form->createElement('text', "{$prefix}number", null, ['size' => 8]); $data->types["{$prefix}number"] = PARAM_INT; $unitoptions = [ 'Y' => get_string('years'), 'M' => strtolower(get_string('months')), 'D' => strtolower(get_string('days')) ]; $unit = $this->_form->createElement('select', "{$prefix}unit", '', $unitoptions); $data->fields[] = $this->_form->createElement( 'group', $prefix, get_string('retentionperiod', 'tool_dataprivacy'), [ 'number' => $number, 'unit' => $unit, ], null, false ); return $data; }
[ "protected", "function", "get_retention_period_fields", "(", "string", "$", "prefix", "=", "''", ")", ":", "\\", "stdClass", "{", "$", "prefix", "=", "\"{$prefix}retentionperiod\"", ";", "$", "data", "=", "(", "object", ")", "[", "'fields'", "=>", "[", "]", ",", "'types'", "=>", "[", "]", ",", "]", ";", "$", "number", "=", "$", "this", "->", "_form", "->", "createElement", "(", "'text'", ",", "\"{$prefix}number\"", ",", "null", ",", "[", "'size'", "=>", "8", "]", ")", ";", "$", "data", "->", "types", "[", "\"{$prefix}number\"", "]", "=", "PARAM_INT", ";", "$", "unitoptions", "=", "[", "'Y'", "=>", "get_string", "(", "'years'", ")", ",", "'M'", "=>", "strtolower", "(", "get_string", "(", "'months'", ")", ")", ",", "'D'", "=>", "strtolower", "(", "get_string", "(", "'days'", ")", ")", "]", ";", "$", "unit", "=", "$", "this", "->", "_form", "->", "createElement", "(", "'select'", ",", "\"{$prefix}unit\"", ",", "''", ",", "$", "unitoptions", ")", ";", "$", "data", "->", "fields", "[", "]", "=", "$", "this", "->", "_form", "->", "createElement", "(", "'group'", ",", "$", "prefix", ",", "get_string", "(", "'retentionperiod'", ",", "'tool_dataprivacy'", ")", ",", "[", "'number'", "=>", "$", "number", ",", "'unit'", "=>", "$", "unit", ",", "]", ",", "null", ",", "false", ")", ";", "return", "$", "data", ";", "}" ]
Get the retention period fields. @param string $prefix The name of the main field, and prefix for the subfields. @return \stdClass
[ "Get", "the", "retention", "period", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L376-L406
212,915
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.get_protected_field
protected function get_protected_field(string $prefix = '') : \stdClass { $fieldname = "{$prefix}protected"; return (object) [ 'fields' => [ $this->_form->createElement( 'advcheckbox', $fieldname, get_string('protected', 'tool_dataprivacy'), get_string('protectedlabel', 'tool_dataprivacy') ), ], ]; }
php
protected function get_protected_field(string $prefix = '') : \stdClass { $fieldname = "{$prefix}protected"; return (object) [ 'fields' => [ $this->_form->createElement( 'advcheckbox', $fieldname, get_string('protected', 'tool_dataprivacy'), get_string('protectedlabel', 'tool_dataprivacy') ), ], ]; }
[ "protected", "function", "get_protected_field", "(", "string", "$", "prefix", "=", "''", ")", ":", "\\", "stdClass", "{", "$", "fieldname", "=", "\"{$prefix}protected\"", ";", "return", "(", "object", ")", "[", "'fields'", "=>", "[", "$", "this", "->", "_form", "->", "createElement", "(", "'advcheckbox'", ",", "$", "fieldname", ",", "get_string", "(", "'protected'", ",", "'tool_dataprivacy'", ")", ",", "get_string", "(", "'protectedlabel'", ",", "'tool_dataprivacy'", ")", ")", ",", "]", ",", "]", ";", "}" ]
Get the mform field for the protected flag. @param string $prefix The prefix to apply to the field @return \stdClass
[ "Get", "the", "mform", "field", "for", "the", "protected", "flag", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L414-L427
212,916
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.convert_fields
protected static function convert_fields(\stdClass $data) { $data = parent::convert_fields($data); if (!empty($data->lawfulbases) && is_array($data->lawfulbases)) { $data->lawfulbases = implode(',', $data->lawfulbases); } if (!empty($data->sensitivedatareasons) && is_array($data->sensitivedatareasons)) { $data->sensitivedatareasons = implode(',', $data->sensitivedatareasons); } // A single value. $data->retentionperiod = 'P' . $data->retentionperiodnumber . $data->retentionperiodunit; unset($data->retentionperiodnumber); unset($data->retentionperiodunit); return $data; }
php
protected static function convert_fields(\stdClass $data) { $data = parent::convert_fields($data); if (!empty($data->lawfulbases) && is_array($data->lawfulbases)) { $data->lawfulbases = implode(',', $data->lawfulbases); } if (!empty($data->sensitivedatareasons) && is_array($data->sensitivedatareasons)) { $data->sensitivedatareasons = implode(',', $data->sensitivedatareasons); } // A single value. $data->retentionperiod = 'P' . $data->retentionperiodnumber . $data->retentionperiodunit; unset($data->retentionperiodnumber); unset($data->retentionperiodunit); return $data; }
[ "protected", "static", "function", "convert_fields", "(", "\\", "stdClass", "$", "data", ")", "{", "$", "data", "=", "parent", "::", "convert_fields", "(", "$", "data", ")", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "lawfulbases", ")", "&&", "is_array", "(", "$", "data", "->", "lawfulbases", ")", ")", "{", "$", "data", "->", "lawfulbases", "=", "implode", "(", "','", ",", "$", "data", "->", "lawfulbases", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "sensitivedatareasons", ")", "&&", "is_array", "(", "$", "data", "->", "sensitivedatareasons", ")", ")", "{", "$", "data", "->", "sensitivedatareasons", "=", "implode", "(", "','", ",", "$", "data", "->", "sensitivedatareasons", ")", ";", "}", "// A single value.", "$", "data", "->", "retentionperiod", "=", "'P'", ".", "$", "data", "->", "retentionperiodnumber", ".", "$", "data", "->", "retentionperiodunit", ";", "unset", "(", "$", "data", "->", "retentionperiodnumber", ")", ";", "unset", "(", "$", "data", "->", "retentionperiodunit", ")", ";", "return", "$", "data", ";", "}" ]
Converts data to data suitable for storage. @param \stdClass $data @return \stdClass
[ "Converts", "data", "to", "data", "suitable", "for", "storage", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L435-L451
212,917
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.convert_existing_data_to_values
protected function convert_existing_data_to_values(\stdClass $data) : \stdClass { $data->lawfulbases = explode(',', $data->lawfulbases); if (!empty($data->sensitivedatareasons)) { $data->sensitivedatareasons = explode(',', $data->sensitivedatareasons); } // Convert the single properties into number and unit. $strlen = strlen($data->retentionperiod); $data->retentionperiodnumber = substr($data->retentionperiod, 1, $strlen - 2); $data->retentionperiodunit = substr($data->retentionperiod, $strlen - 1); unset($data->retentionperiod); return $data; }
php
protected function convert_existing_data_to_values(\stdClass $data) : \stdClass { $data->lawfulbases = explode(',', $data->lawfulbases); if (!empty($data->sensitivedatareasons)) { $data->sensitivedatareasons = explode(',', $data->sensitivedatareasons); } // Convert the single properties into number and unit. $strlen = strlen($data->retentionperiod); $data->retentionperiodnumber = substr($data->retentionperiod, 1, $strlen - 2); $data->retentionperiodunit = substr($data->retentionperiod, $strlen - 1); unset($data->retentionperiod); return $data; }
[ "protected", "function", "convert_existing_data_to_values", "(", "\\", "stdClass", "$", "data", ")", ":", "\\", "stdClass", "{", "$", "data", "->", "lawfulbases", "=", "explode", "(", "','", ",", "$", "data", "->", "lawfulbases", ")", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "sensitivedatareasons", ")", ")", "{", "$", "data", "->", "sensitivedatareasons", "=", "explode", "(", "','", ",", "$", "data", "->", "sensitivedatareasons", ")", ";", "}", "// Convert the single properties into number and unit.", "$", "strlen", "=", "strlen", "(", "$", "data", "->", "retentionperiod", ")", ";", "$", "data", "->", "retentionperiodnumber", "=", "substr", "(", "$", "data", "->", "retentionperiod", ",", "1", ",", "$", "strlen", "-", "2", ")", ";", "$", "data", "->", "retentionperiodunit", "=", "substr", "(", "$", "data", "->", "retentionperiod", ",", "$", "strlen", "-", "1", ")", ";", "unset", "(", "$", "data", "->", "retentionperiod", ")", ";", "return", "$", "data", ";", "}" ]
Normalise any values stored in existing data. @param \stdClass $data @return \stdClass
[ "Normalise", "any", "values", "stored", "in", "existing", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L470-L483
212,918
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.get_role_overrides_from_data
public function get_role_overrides_from_data(\stdClass $data) { $overrides = []; if (!empty($data->overrides)) { $searchkey = 'roleoverride_'; for ($i = 0; $i < $data->overrides; $i++) { $overridedata = (object) []; foreach ((array) $data as $fieldname => $value) { if (strpos($fieldname, $searchkey) !== 0) { continue; } $overridefieldname = substr($fieldname, strlen($searchkey)); $overridedata->$overridefieldname = $value[$i]; } if (empty($overridedata->roleid) || empty($overridedata->retentionperiodnumber)) { // Skip this one. // There is no value and it will be delete. continue; } $override = static::convert_fields($overridedata); $overrides[$i] = $override; } } return $overrides; }
php
public function get_role_overrides_from_data(\stdClass $data) { $overrides = []; if (!empty($data->overrides)) { $searchkey = 'roleoverride_'; for ($i = 0; $i < $data->overrides; $i++) { $overridedata = (object) []; foreach ((array) $data as $fieldname => $value) { if (strpos($fieldname, $searchkey) !== 0) { continue; } $overridefieldname = substr($fieldname, strlen($searchkey)); $overridedata->$overridefieldname = $value[$i]; } if (empty($overridedata->roleid) || empty($overridedata->retentionperiodnumber)) { // Skip this one. // There is no value and it will be delete. continue; } $override = static::convert_fields($overridedata); $overrides[$i] = $override; } } return $overrides; }
[ "public", "function", "get_role_overrides_from_data", "(", "\\", "stdClass", "$", "data", ")", "{", "$", "overrides", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "overrides", ")", ")", "{", "$", "searchkey", "=", "'roleoverride_'", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "data", "->", "overrides", ";", "$", "i", "++", ")", "{", "$", "overridedata", "=", "(", "object", ")", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "data", "as", "$", "fieldname", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "fieldname", ",", "$", "searchkey", ")", "!==", "0", ")", "{", "continue", ";", "}", "$", "overridefieldname", "=", "substr", "(", "$", "fieldname", ",", "strlen", "(", "$", "searchkey", ")", ")", ";", "$", "overridedata", "->", "$", "overridefieldname", "=", "$", "value", "[", "$", "i", "]", ";", "}", "if", "(", "empty", "(", "$", "overridedata", "->", "roleid", ")", "||", "empty", "(", "$", "overridedata", "->", "retentionperiodnumber", ")", ")", "{", "// Skip this one.", "// There is no value and it will be delete.", "continue", ";", "}", "$", "override", "=", "static", "::", "convert_fields", "(", "$", "overridedata", ")", ";", "$", "overrides", "[", "$", "i", "]", "=", "$", "override", ";", "}", "}", "return", "$", "overrides", ";", "}" ]
Fetch the role override data from the list of submitted data. @param \stdClass $data The complete set of processed data @return \stdClass[] The list of overrides
[ "Fetch", "the", "role", "override", "data", "from", "the", "list", "of", "submitted", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L491-L520
212,919
moodle/moodle
admin/tool/dataprivacy/classes/form/purpose.php
purpose.extra_validation
protected function extra_validation($data, $files, array &$errors) { $overrides = $this->get_role_overrides_from_data($data); // Check role overrides to ensure that: // - roles are unique; and // - specifeid retention periods are numeric. $seenroleids = []; foreach ($overrides as $id => $override) { $override->purposeid = 0; $persistent = new \tool_dataprivacy\purpose_override($override->id, $override); if (isset($seenroleids[$persistent->get('roleid')])) { $errors["roleoverride_roleid[{$id}]"] = get_string('duplicaterole'); } $seenroleids[$persistent->get('roleid')] = true; $errors = array_merge($errors, $persistent->get_errors()); } return $errors; }
php
protected function extra_validation($data, $files, array &$errors) { $overrides = $this->get_role_overrides_from_data($data); // Check role overrides to ensure that: // - roles are unique; and // - specifeid retention periods are numeric. $seenroleids = []; foreach ($overrides as $id => $override) { $override->purposeid = 0; $persistent = new \tool_dataprivacy\purpose_override($override->id, $override); if (isset($seenroleids[$persistent->get('roleid')])) { $errors["roleoverride_roleid[{$id}]"] = get_string('duplicaterole'); } $seenroleids[$persistent->get('roleid')] = true; $errors = array_merge($errors, $persistent->get_errors()); } return $errors; }
[ "protected", "function", "extra_validation", "(", "$", "data", ",", "$", "files", ",", "array", "&", "$", "errors", ")", "{", "$", "overrides", "=", "$", "this", "->", "get_role_overrides_from_data", "(", "$", "data", ")", ";", "// Check role overrides to ensure that:", "// - roles are unique; and", "// - specifeid retention periods are numeric.", "$", "seenroleids", "=", "[", "]", ";", "foreach", "(", "$", "overrides", "as", "$", "id", "=>", "$", "override", ")", "{", "$", "override", "->", "purposeid", "=", "0", ";", "$", "persistent", "=", "new", "\\", "tool_dataprivacy", "\\", "purpose_override", "(", "$", "override", "->", "id", ",", "$", "override", ")", ";", "if", "(", "isset", "(", "$", "seenroleids", "[", "$", "persistent", "->", "get", "(", "'roleid'", ")", "]", ")", ")", "{", "$", "errors", "[", "\"roleoverride_roleid[{$id}]\"", "]", "=", "get_string", "(", "'duplicaterole'", ")", ";", "}", "$", "seenroleids", "[", "$", "persistent", "->", "get", "(", "'roleid'", ")", "]", "=", "true", ";", "$", "errors", "=", "array_merge", "(", "$", "errors", ",", "$", "persistent", "->", "get_errors", "(", ")", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Define extra validation mechanims. @param stdClass $data Data to validate. @param array $files Array of files. @param array $errors Currently reported errors. @return array of additional errors, or overridden errors.
[ "Define", "extra", "validation", "mechanims", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/form/purpose.php#L530-L550
212,920
moodle/moodle
report/insights/classes/output/renderer.php
renderer.render_insights_list
protected function render_insights_list(renderable $renderable) { $data = $renderable->export_for_template($this); return parent::render_from_template('report_insights/insights_list', $data); }
php
protected function render_insights_list(renderable $renderable) { $data = $renderable->export_for_template($this); return parent::render_from_template('report_insights/insights_list', $data); }
[ "protected", "function", "render_insights_list", "(", "renderable", "$", "renderable", ")", "{", "$", "data", "=", "$", "renderable", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'report_insights/insights_list'", ",", "$", "data", ")", ";", "}" ]
Renders the list of insights @param renderable $renderable @return string HTML
[ "Renders", "the", "list", "of", "insights" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/output/renderer.php#L48-L51
212,921
moodle/moodle
report/insights/classes/output/renderer.php
renderer.render_insight
protected function render_insight(renderable $renderable) { $data = $renderable->export_for_template($this); return parent::render_from_template('report_insights/insight_details', $data); }
php
protected function render_insight(renderable $renderable) { $data = $renderable->export_for_template($this); return parent::render_from_template('report_insights/insight_details', $data); }
[ "protected", "function", "render_insight", "(", "renderable", "$", "renderable", ")", "{", "$", "data", "=", "$", "renderable", "->", "export_for_template", "(", "$", "this", ")", ";", "return", "parent", "::", "render_from_template", "(", "'report_insights/insight_details'", ",", "$", "data", ")", ";", "}" ]
Renders an insight @param renderable $renderable @return string HTML
[ "Renders", "an", "insight" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/output/renderer.php#L59-L62
212,922
moodle/moodle
report/insights/classes/output/renderer.php
renderer.render_model_disabled
public function render_model_disabled($insightinfo) { global $OUTPUT, $PAGE; // We don't want to disclose the name of the model if it has not been enabled. $PAGE->set_title($insightinfo->contextname); $PAGE->set_heading($insightinfo->contextname); $output = $OUTPUT->header(); $output .= $OUTPUT->notification(get_string('disabledmodel', 'report_insights'), \core\output\notification::NOTIFY_INFO); $output .= $OUTPUT->footer(); return $output; }
php
public function render_model_disabled($insightinfo) { global $OUTPUT, $PAGE; // We don't want to disclose the name of the model if it has not been enabled. $PAGE->set_title($insightinfo->contextname); $PAGE->set_heading($insightinfo->contextname); $output = $OUTPUT->header(); $output .= $OUTPUT->notification(get_string('disabledmodel', 'report_insights'), \core\output\notification::NOTIFY_INFO); $output .= $OUTPUT->footer(); return $output; }
[ "public", "function", "render_model_disabled", "(", "$", "insightinfo", ")", "{", "global", "$", "OUTPUT", ",", "$", "PAGE", ";", "// We don't want to disclose the name of the model if it has not been enabled.", "$", "PAGE", "->", "set_title", "(", "$", "insightinfo", "->", "contextname", ")", ";", "$", "PAGE", "->", "set_heading", "(", "$", "insightinfo", "->", "contextname", ")", ";", "$", "output", "=", "$", "OUTPUT", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "OUTPUT", "->", "notification", "(", "get_string", "(", "'disabledmodel'", ",", "'report_insights'", ")", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_INFO", ")", ";", "$", "output", ".=", "$", "OUTPUT", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Model disabled info. @param \stdClass $insightinfo @return string HTML
[ "Model", "disabled", "info", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/output/renderer.php#L70-L82
212,923
moodle/moodle
report/insights/classes/output/renderer.php
renderer.render_no_insights
public function render_no_insights(\context $context) { global $OUTPUT, $PAGE; // We don't want to disclose the name of the model if it has not been enabled. $PAGE->set_title($context->get_context_name()); $PAGE->set_heading($context->get_context_name()); $output = $OUTPUT->header(); $output .= $OUTPUT->notification(get_string('noinsights', 'analytics'), \core\output\notification::NOTIFY_INFO); $output .= $OUTPUT->footer(); return $output; }
php
public function render_no_insights(\context $context) { global $OUTPUT, $PAGE; // We don't want to disclose the name of the model if it has not been enabled. $PAGE->set_title($context->get_context_name()); $PAGE->set_heading($context->get_context_name()); $output = $OUTPUT->header(); $output .= $OUTPUT->notification(get_string('noinsights', 'analytics'), \core\output\notification::NOTIFY_INFO); $output .= $OUTPUT->footer(); return $output; }
[ "public", "function", "render_no_insights", "(", "\\", "context", "$", "context", ")", "{", "global", "$", "OUTPUT", ",", "$", "PAGE", ";", "// We don't want to disclose the name of the model if it has not been enabled.", "$", "PAGE", "->", "set_title", "(", "$", "context", "->", "get_context_name", "(", ")", ")", ";", "$", "PAGE", "->", "set_heading", "(", "$", "context", "->", "get_context_name", "(", ")", ")", ";", "$", "output", "=", "$", "OUTPUT", "->", "header", "(", ")", ";", "$", "output", ".=", "$", "OUTPUT", "->", "notification", "(", "get_string", "(", "'noinsights'", ",", "'analytics'", ")", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_INFO", ")", ";", "$", "output", ".=", "$", "OUTPUT", "->", "footer", "(", ")", ";", "return", "$", "output", ";", "}" ]
Model without insights info. @param \context $context @return string HTML
[ "Model", "without", "insights", "info", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/output/renderer.php#L90-L102
212,924
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.load_component_strings
public function load_component_strings($component, $lang, $disablecache = false, $disablelocal = false) { global $CFG; list($plugintype, $pluginname) = core_component::normalize_component($component); if ($plugintype === 'core' and is_null($pluginname)) { $component = 'core'; } else { $component = $plugintype . '_' . $pluginname; } $cachekey = $lang.'_'.$component.'_'.$this->get_key_suffix(); $cachedstring = $this->cache->get($cachekey); if (!$disablecache and !$disablelocal) { if ($cachedstring !== false) { return $cachedstring; } } // No cache found - let us merge all possible sources of the strings. if ($plugintype === 'core') { $file = $pluginname; if ($file === null) { $file = 'moodle'; } $string = array(); // First load english pack. if (!file_exists("$CFG->dirroot/lang/en/$file.php")) { return array(); } include("$CFG->dirroot/lang/en/$file.php"); $enstring = $string; // And then corresponding local if present and allowed. if (!$disablelocal and file_exists("$this->localroot/en_local/$file.php")) { include("$this->localroot/en_local/$file.php"); } // Now loop through all langs in correct order. $deps = $this->get_language_dependencies($lang); foreach ($deps as $dep) { // The main lang string location. if (file_exists("$this->otherroot/$dep/$file.php")) { include("$this->otherroot/$dep/$file.php"); } if (!$disablelocal and file_exists("$this->localroot/{$dep}_local/$file.php")) { include("$this->localroot/{$dep}_local/$file.php"); } } } else { if (!$location = core_component::get_plugin_directory($plugintype, $pluginname) or !is_dir($location)) { return array(); } if ($plugintype === 'mod') { // Bloody mod hack. $file = $pluginname; } else { $file = $plugintype . '_' . $pluginname; } $string = array(); // First load English pack. if (!file_exists("$location/lang/en/$file.php")) { // English pack does not exist, so do not try to load anything else. return array(); } include("$location/lang/en/$file.php"); $enstring = $string; // And then corresponding local english if present. if (!$disablelocal and file_exists("$this->localroot/en_local/$file.php")) { include("$this->localroot/en_local/$file.php"); } // Now loop through all langs in correct order. $deps = $this->get_language_dependencies($lang); foreach ($deps as $dep) { // Legacy location - used by contrib only. if (file_exists("$location/lang/$dep/$file.php")) { include("$location/lang/$dep/$file.php"); } // The main lang string location. if (file_exists("$this->otherroot/$dep/$file.php")) { include("$this->otherroot/$dep/$file.php"); } // Local customisations. if (!$disablelocal and file_exists("$this->localroot/{$dep}_local/$file.php")) { include("$this->localroot/{$dep}_local/$file.php"); } } } // We do not want any extra strings from other languages - everything must be in en lang pack. $string = array_intersect_key($string, $enstring); if (!$disablelocal) { // Now we have a list of strings from all possible sources, // cache it in MUC cache if not already there. if ($cachedstring === false) { $this->cache->set($cachekey, $string); } } return $string; }
php
public function load_component_strings($component, $lang, $disablecache = false, $disablelocal = false) { global $CFG; list($plugintype, $pluginname) = core_component::normalize_component($component); if ($plugintype === 'core' and is_null($pluginname)) { $component = 'core'; } else { $component = $plugintype . '_' . $pluginname; } $cachekey = $lang.'_'.$component.'_'.$this->get_key_suffix(); $cachedstring = $this->cache->get($cachekey); if (!$disablecache and !$disablelocal) { if ($cachedstring !== false) { return $cachedstring; } } // No cache found - let us merge all possible sources of the strings. if ($plugintype === 'core') { $file = $pluginname; if ($file === null) { $file = 'moodle'; } $string = array(); // First load english pack. if (!file_exists("$CFG->dirroot/lang/en/$file.php")) { return array(); } include("$CFG->dirroot/lang/en/$file.php"); $enstring = $string; // And then corresponding local if present and allowed. if (!$disablelocal and file_exists("$this->localroot/en_local/$file.php")) { include("$this->localroot/en_local/$file.php"); } // Now loop through all langs in correct order. $deps = $this->get_language_dependencies($lang); foreach ($deps as $dep) { // The main lang string location. if (file_exists("$this->otherroot/$dep/$file.php")) { include("$this->otherroot/$dep/$file.php"); } if (!$disablelocal and file_exists("$this->localroot/{$dep}_local/$file.php")) { include("$this->localroot/{$dep}_local/$file.php"); } } } else { if (!$location = core_component::get_plugin_directory($plugintype, $pluginname) or !is_dir($location)) { return array(); } if ($plugintype === 'mod') { // Bloody mod hack. $file = $pluginname; } else { $file = $plugintype . '_' . $pluginname; } $string = array(); // First load English pack. if (!file_exists("$location/lang/en/$file.php")) { // English pack does not exist, so do not try to load anything else. return array(); } include("$location/lang/en/$file.php"); $enstring = $string; // And then corresponding local english if present. if (!$disablelocal and file_exists("$this->localroot/en_local/$file.php")) { include("$this->localroot/en_local/$file.php"); } // Now loop through all langs in correct order. $deps = $this->get_language_dependencies($lang); foreach ($deps as $dep) { // Legacy location - used by contrib only. if (file_exists("$location/lang/$dep/$file.php")) { include("$location/lang/$dep/$file.php"); } // The main lang string location. if (file_exists("$this->otherroot/$dep/$file.php")) { include("$this->otherroot/$dep/$file.php"); } // Local customisations. if (!$disablelocal and file_exists("$this->localroot/{$dep}_local/$file.php")) { include("$this->localroot/{$dep}_local/$file.php"); } } } // We do not want any extra strings from other languages - everything must be in en lang pack. $string = array_intersect_key($string, $enstring); if (!$disablelocal) { // Now we have a list of strings from all possible sources, // cache it in MUC cache if not already there. if ($cachedstring === false) { $this->cache->set($cachekey, $string); } } return $string; }
[ "public", "function", "load_component_strings", "(", "$", "component", ",", "$", "lang", ",", "$", "disablecache", "=", "false", ",", "$", "disablelocal", "=", "false", ")", "{", "global", "$", "CFG", ";", "list", "(", "$", "plugintype", ",", "$", "pluginname", ")", "=", "core_component", "::", "normalize_component", "(", "$", "component", ")", ";", "if", "(", "$", "plugintype", "===", "'core'", "and", "is_null", "(", "$", "pluginname", ")", ")", "{", "$", "component", "=", "'core'", ";", "}", "else", "{", "$", "component", "=", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ";", "}", "$", "cachekey", "=", "$", "lang", ".", "'_'", ".", "$", "component", ".", "'_'", ".", "$", "this", "->", "get_key_suffix", "(", ")", ";", "$", "cachedstring", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "cachekey", ")", ";", "if", "(", "!", "$", "disablecache", "and", "!", "$", "disablelocal", ")", "{", "if", "(", "$", "cachedstring", "!==", "false", ")", "{", "return", "$", "cachedstring", ";", "}", "}", "// No cache found - let us merge all possible sources of the strings.", "if", "(", "$", "plugintype", "===", "'core'", ")", "{", "$", "file", "=", "$", "pluginname", ";", "if", "(", "$", "file", "===", "null", ")", "{", "$", "file", "=", "'moodle'", ";", "}", "$", "string", "=", "array", "(", ")", ";", "// First load english pack.", "if", "(", "!", "file_exists", "(", "\"$CFG->dirroot/lang/en/$file.php\"", ")", ")", "{", "return", "array", "(", ")", ";", "}", "include", "(", "\"$CFG->dirroot/lang/en/$file.php\"", ")", ";", "$", "enstring", "=", "$", "string", ";", "// And then corresponding local if present and allowed.", "if", "(", "!", "$", "disablelocal", "and", "file_exists", "(", "\"$this->localroot/en_local/$file.php\"", ")", ")", "{", "include", "(", "\"$this->localroot/en_local/$file.php\"", ")", ";", "}", "// Now loop through all langs in correct order.", "$", "deps", "=", "$", "this", "->", "get_language_dependencies", "(", "$", "lang", ")", ";", "foreach", "(", "$", "deps", "as", "$", "dep", ")", "{", "// The main lang string location.", "if", "(", "file_exists", "(", "\"$this->otherroot/$dep/$file.php\"", ")", ")", "{", "include", "(", "\"$this->otherroot/$dep/$file.php\"", ")", ";", "}", "if", "(", "!", "$", "disablelocal", "and", "file_exists", "(", "\"$this->localroot/{$dep}_local/$file.php\"", ")", ")", "{", "include", "(", "\"$this->localroot/{$dep}_local/$file.php\"", ")", ";", "}", "}", "}", "else", "{", "if", "(", "!", "$", "location", "=", "core_component", "::", "get_plugin_directory", "(", "$", "plugintype", ",", "$", "pluginname", ")", "or", "!", "is_dir", "(", "$", "location", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "plugintype", "===", "'mod'", ")", "{", "// Bloody mod hack.", "$", "file", "=", "$", "pluginname", ";", "}", "else", "{", "$", "file", "=", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ";", "}", "$", "string", "=", "array", "(", ")", ";", "// First load English pack.", "if", "(", "!", "file_exists", "(", "\"$location/lang/en/$file.php\"", ")", ")", "{", "// English pack does not exist, so do not try to load anything else.", "return", "array", "(", ")", ";", "}", "include", "(", "\"$location/lang/en/$file.php\"", ")", ";", "$", "enstring", "=", "$", "string", ";", "// And then corresponding local english if present.", "if", "(", "!", "$", "disablelocal", "and", "file_exists", "(", "\"$this->localroot/en_local/$file.php\"", ")", ")", "{", "include", "(", "\"$this->localroot/en_local/$file.php\"", ")", ";", "}", "// Now loop through all langs in correct order.", "$", "deps", "=", "$", "this", "->", "get_language_dependencies", "(", "$", "lang", ")", ";", "foreach", "(", "$", "deps", "as", "$", "dep", ")", "{", "// Legacy location - used by contrib only.", "if", "(", "file_exists", "(", "\"$location/lang/$dep/$file.php\"", ")", ")", "{", "include", "(", "\"$location/lang/$dep/$file.php\"", ")", ";", "}", "// The main lang string location.", "if", "(", "file_exists", "(", "\"$this->otherroot/$dep/$file.php\"", ")", ")", "{", "include", "(", "\"$this->otherroot/$dep/$file.php\"", ")", ";", "}", "// Local customisations.", "if", "(", "!", "$", "disablelocal", "and", "file_exists", "(", "\"$this->localroot/{$dep}_local/$file.php\"", ")", ")", "{", "include", "(", "\"$this->localroot/{$dep}_local/$file.php\"", ")", ";", "}", "}", "}", "// We do not want any extra strings from other languages - everything must be in en lang pack.", "$", "string", "=", "array_intersect_key", "(", "$", "string", ",", "$", "enstring", ")", ";", "if", "(", "!", "$", "disablelocal", ")", "{", "// Now we have a list of strings from all possible sources,", "// cache it in MUC cache if not already there.", "if", "(", "$", "cachedstring", "===", "false", ")", "{", "$", "this", "->", "cache", "->", "set", "(", "$", "cachekey", ",", "$", "string", ")", ";", "}", "}", "return", "$", "string", ";", "}" ]
Load all strings for one component @param string $component The module the string is associated with @param string $lang @param bool $disablecache Do not use caches, force fetching the strings from sources @param bool $disablelocal Do not use customized strings in xx_local language packs @return array of all string for given component and lang
[ "Load", "all", "strings", "for", "one", "component" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L112-L213
212,925
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.load_deprecated_strings
protected function load_deprecated_strings() { global $CFG; if ($this->cacheddeprecated !== null) { return $this->cacheddeprecated; } $this->cacheddeprecated = array(); $content = ''; $filename = $CFG->dirroot . '/lang/en/deprecated.txt'; if (file_exists($filename)) { $content .= file_get_contents($filename); } foreach (core_component::get_plugin_types() as $plugintype => $plugintypedir) { foreach (core_component::get_plugin_list($plugintype) as $pluginname => $plugindir) { $filename = $plugindir.'/lang/en/deprecated.txt'; if (file_exists($filename)) { $content .= "\n". file_get_contents($filename); } } } $strings = preg_split('/\s*\n\s*/', $content, -1, PREG_SPLIT_NO_EMPTY); $this->cacheddeprecated = array_flip($strings); return $this->cacheddeprecated; }
php
protected function load_deprecated_strings() { global $CFG; if ($this->cacheddeprecated !== null) { return $this->cacheddeprecated; } $this->cacheddeprecated = array(); $content = ''; $filename = $CFG->dirroot . '/lang/en/deprecated.txt'; if (file_exists($filename)) { $content .= file_get_contents($filename); } foreach (core_component::get_plugin_types() as $plugintype => $plugintypedir) { foreach (core_component::get_plugin_list($plugintype) as $pluginname => $plugindir) { $filename = $plugindir.'/lang/en/deprecated.txt'; if (file_exists($filename)) { $content .= "\n". file_get_contents($filename); } } } $strings = preg_split('/\s*\n\s*/', $content, -1, PREG_SPLIT_NO_EMPTY); $this->cacheddeprecated = array_flip($strings); return $this->cacheddeprecated; }
[ "protected", "function", "load_deprecated_strings", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "this", "->", "cacheddeprecated", "!==", "null", ")", "{", "return", "$", "this", "->", "cacheddeprecated", ";", "}", "$", "this", "->", "cacheddeprecated", "=", "array", "(", ")", ";", "$", "content", "=", "''", ";", "$", "filename", "=", "$", "CFG", "->", "dirroot", ".", "'/lang/en/deprecated.txt'", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "content", ".=", "file_get_contents", "(", "$", "filename", ")", ";", "}", "foreach", "(", "core_component", "::", "get_plugin_types", "(", ")", "as", "$", "plugintype", "=>", "$", "plugintypedir", ")", "{", "foreach", "(", "core_component", "::", "get_plugin_list", "(", "$", "plugintype", ")", "as", "$", "pluginname", "=>", "$", "plugindir", ")", "{", "$", "filename", "=", "$", "plugindir", ".", "'/lang/en/deprecated.txt'", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "content", ".=", "\"\\n\"", ".", "file_get_contents", "(", "$", "filename", ")", ";", "}", "}", "}", "$", "strings", "=", "preg_split", "(", "'/\\s*\\n\\s*/'", ",", "$", "content", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "this", "->", "cacheddeprecated", "=", "array_flip", "(", "$", "strings", ")", ";", "return", "$", "this", "->", "cacheddeprecated", ";", "}" ]
Parses all deprecated.txt in all plugins lang locations and returns the list of deprecated strings. Static variable is used for caching, this function is only called in dev environment. @return array of deprecated strings in the same format they appear in deprecated.txt files: "identifier,component" where component is a normalised component (i.e. "core_moodle", "mod_assign", etc.)
[ "Parses", "all", "deprecated", ".", "txt", "in", "all", "plugins", "lang", "locations", "and", "returns", "the", "list", "of", "deprecated", "strings", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L223-L249
212,926
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.string_deprecated
public function string_deprecated($identifier, $component) { $deprecated = $this->load_deprecated_strings(); list($plugintype, $pluginname) = core_component::normalize_component($component); $normcomponent = $pluginname ? ($plugintype . '_' . $pluginname) : $plugintype; return isset($deprecated[$identifier . ',' . $normcomponent]); }
php
public function string_deprecated($identifier, $component) { $deprecated = $this->load_deprecated_strings(); list($plugintype, $pluginname) = core_component::normalize_component($component); $normcomponent = $pluginname ? ($plugintype . '_' . $pluginname) : $plugintype; return isset($deprecated[$identifier . ',' . $normcomponent]); }
[ "public", "function", "string_deprecated", "(", "$", "identifier", ",", "$", "component", ")", "{", "$", "deprecated", "=", "$", "this", "->", "load_deprecated_strings", "(", ")", ";", "list", "(", "$", "plugintype", ",", "$", "pluginname", ")", "=", "core_component", "::", "normalize_component", "(", "$", "component", ")", ";", "$", "normcomponent", "=", "$", "pluginname", "?", "(", "$", "plugintype", ".", "'_'", ".", "$", "pluginname", ")", ":", "$", "plugintype", ";", "return", "isset", "(", "$", "deprecated", "[", "$", "identifier", ".", "','", ".", "$", "normcomponent", "]", ")", ";", "}" ]
Has string been deprecated? Usually checked only inside get_string() to display debug warnings. @param string $identifier The identifier of the string to search for @param string $component The module the string is associated with @return bool true if deprecated
[ "Has", "string", "been", "deprecated?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L260-L265
212,927
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.get_list_of_countries
public function get_list_of_countries($returnall = false, $lang = null) { global $CFG; if ($lang === null) { $lang = current_language(); } $countries = $this->load_component_strings('core_countries', $lang); core_collator::asort($countries); if (!$returnall and !empty($CFG->allcountrycodes)) { $enabled = explode(',', $CFG->allcountrycodes); $return = array(); foreach ($enabled as $c) { if (isset($countries[$c])) { $return[$c] = $countries[$c]; } } return $return; } return $countries; }
php
public function get_list_of_countries($returnall = false, $lang = null) { global $CFG; if ($lang === null) { $lang = current_language(); } $countries = $this->load_component_strings('core_countries', $lang); core_collator::asort($countries); if (!$returnall and !empty($CFG->allcountrycodes)) { $enabled = explode(',', $CFG->allcountrycodes); $return = array(); foreach ($enabled as $c) { if (isset($countries[$c])) { $return[$c] = $countries[$c]; } } return $return; } return $countries; }
[ "public", "function", "get_list_of_countries", "(", "$", "returnall", "=", "false", ",", "$", "lang", "=", "null", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "lang", "===", "null", ")", "{", "$", "lang", "=", "current_language", "(", ")", ";", "}", "$", "countries", "=", "$", "this", "->", "load_component_strings", "(", "'core_countries'", ",", "$", "lang", ")", ";", "core_collator", "::", "asort", "(", "$", "countries", ")", ";", "if", "(", "!", "$", "returnall", "and", "!", "empty", "(", "$", "CFG", "->", "allcountrycodes", ")", ")", "{", "$", "enabled", "=", "explode", "(", "','", ",", "$", "CFG", "->", "allcountrycodes", ")", ";", "$", "return", "=", "array", "(", ")", ";", "foreach", "(", "$", "enabled", "as", "$", "c", ")", "{", "if", "(", "isset", "(", "$", "countries", "[", "$", "c", "]", ")", ")", "{", "$", "return", "[", "$", "c", "]", "=", "$", "countries", "[", "$", "c", "]", ";", "}", "}", "return", "$", "return", ";", "}", "return", "$", "countries", ";", "}" ]
Returns a localised list of all country names, sorted by localised name. @param bool $returnall return all or just enabled @param string $lang moodle translation language, null means use current @return array two-letter country code => translated name.
[ "Returns", "a", "localised", "list", "of", "all", "country", "names", "sorted", "by", "localised", "name", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L421-L442
212,928
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.translation_exists
public function translation_exists($lang, $includeall = true) { $translations = $this->get_list_of_translations($includeall); return isset($translations[$lang]); }
php
public function translation_exists($lang, $includeall = true) { $translations = $this->get_list_of_translations($includeall); return isset($translations[$lang]); }
[ "public", "function", "translation_exists", "(", "$", "lang", ",", "$", "includeall", "=", "true", ")", "{", "$", "translations", "=", "$", "this", "->", "get_list_of_translations", "(", "$", "includeall", ")", ";", "return", "isset", "(", "$", "translations", "[", "$", "lang", "]", ")", ";", "}" ]
Checks if the translation exists for the language @param string $lang moodle translation language code @param bool $includeall include also disabled translations @return bool true if exists
[ "Checks", "if", "the", "translation", "exists", "for", "the", "language" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L503-L506
212,929
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.get_list_of_currencies
public function get_list_of_currencies($lang = null) { if ($lang === null) { $lang = current_language(); } $currencies = $this->load_component_strings('core_currencies', $lang); asort($currencies); return $currencies; }
php
public function get_list_of_currencies($lang = null) { if ($lang === null) { $lang = current_language(); } $currencies = $this->load_component_strings('core_currencies', $lang); asort($currencies); return $currencies; }
[ "public", "function", "get_list_of_currencies", "(", "$", "lang", "=", "null", ")", "{", "if", "(", "$", "lang", "===", "null", ")", "{", "$", "lang", "=", "current_language", "(", ")", ";", "}", "$", "currencies", "=", "$", "this", "->", "load_component_strings", "(", "'core_currencies'", ",", "$", "lang", ")", ";", "asort", "(", "$", "currencies", ")", ";", "return", "$", "currencies", ";", "}" ]
Returns localised list of currencies. @param string $lang moodle translation language, null means use current @return array currency code => localised currency name
[ "Returns", "localised", "list", "of", "currencies", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L592-L601
212,930
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.reset_caches
public function reset_caches($phpunitreset = false) { // Clear the on-disk disk with aggregated string files. $this->cache->purge(); $this->menucache->purge(); if (!$phpunitreset) { // Increment the revision counter. $langrev = get_config('core', 'langrev'); $next = time(); if ($langrev !== false and $next <= $langrev and $langrev - $next < 60*60) { // This resolves problems when reset is requested repeatedly within 1s, // the < 1h condition prevents accidental switching to future dates // because we might not recover from it. $next = $langrev+1; } set_config('langrev', $next); } // Lang packs use PHP files in dataroot, it is better to invalidate opcode caches. if (function_exists('opcache_reset')) { opcache_reset(); } }
php
public function reset_caches($phpunitreset = false) { // Clear the on-disk disk with aggregated string files. $this->cache->purge(); $this->menucache->purge(); if (!$phpunitreset) { // Increment the revision counter. $langrev = get_config('core', 'langrev'); $next = time(); if ($langrev !== false and $next <= $langrev and $langrev - $next < 60*60) { // This resolves problems when reset is requested repeatedly within 1s, // the < 1h condition prevents accidental switching to future dates // because we might not recover from it. $next = $langrev+1; } set_config('langrev', $next); } // Lang packs use PHP files in dataroot, it is better to invalidate opcode caches. if (function_exists('opcache_reset')) { opcache_reset(); } }
[ "public", "function", "reset_caches", "(", "$", "phpunitreset", "=", "false", ")", "{", "// Clear the on-disk disk with aggregated string files.", "$", "this", "->", "cache", "->", "purge", "(", ")", ";", "$", "this", "->", "menucache", "->", "purge", "(", ")", ";", "if", "(", "!", "$", "phpunitreset", ")", "{", "// Increment the revision counter.", "$", "langrev", "=", "get_config", "(", "'core'", ",", "'langrev'", ")", ";", "$", "next", "=", "time", "(", ")", ";", "if", "(", "$", "langrev", "!==", "false", "and", "$", "next", "<=", "$", "langrev", "and", "$", "langrev", "-", "$", "next", "<", "60", "*", "60", ")", "{", "// This resolves problems when reset is requested repeatedly within 1s,", "// the < 1h condition prevents accidental switching to future dates", "// because we might not recover from it.", "$", "next", "=", "$", "langrev", "+", "1", ";", "}", "set_config", "(", "'langrev'", ",", "$", "next", ")", ";", "}", "// Lang packs use PHP files in dataroot, it is better to invalidate opcode caches.", "if", "(", "function_exists", "(", "'opcache_reset'", ")", ")", "{", "opcache_reset", "(", ")", ";", "}", "}" ]
Clears both in-memory and on-disk caches @param bool $phpunitreset true means called from our PHPUnit integration test reset
[ "Clears", "both", "in", "-", "memory", "and", "on", "-", "disk", "caches" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L607-L629
212,931
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.get_revision
public function get_revision() { global $CFG; if (empty($CFG->langstringcache)) { return -1; } if (isset($CFG->langrev)) { return (int)$CFG->langrev; } else { return -1; } }
php
public function get_revision() { global $CFG; if (empty($CFG->langstringcache)) { return -1; } if (isset($CFG->langrev)) { return (int)$CFG->langrev; } else { return -1; } }
[ "public", "function", "get_revision", "(", ")", "{", "global", "$", "CFG", ";", "if", "(", "empty", "(", "$", "CFG", "->", "langstringcache", ")", ")", "{", "return", "-", "1", ";", "}", "if", "(", "isset", "(", "$", "CFG", "->", "langrev", ")", ")", "{", "return", "(", "int", ")", "$", "CFG", "->", "langrev", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}" ]
Returns string revision counter, this is incremented after any string cache reset. @return int lang string revision counter, -1 if unknown
[ "Returns", "string", "revision", "counter", "this", "is", "incremented", "after", "any", "string", "cache", "reset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L651-L661
212,932
moodle/moodle
lib/classes/string_manager_standard.php
core_string_manager_standard.populate_parent_languages
protected function populate_parent_languages($lang, array $stack = array()) { // English does not have a parent language. if ($lang === 'en') { return $stack; } // Prevent circular dependency (and thence the infinitive recursion loop). if (in_array($lang, $stack)) { return $stack; } // Load language configuration and look for the explicit parent language. if (!file_exists("$this->otherroot/$lang/langconfig.php")) { return $stack; } $string = array(); include("$this->otherroot/$lang/langconfig.php"); if (empty($string['parentlanguage']) or $string['parentlanguage'] === 'en') { return array_merge(array($lang), $stack); } $parentlang = $string['parentlanguage']; return $this->populate_parent_languages($parentlang, array_merge(array($lang), $stack)); }
php
protected function populate_parent_languages($lang, array $stack = array()) { // English does not have a parent language. if ($lang === 'en') { return $stack; } // Prevent circular dependency (and thence the infinitive recursion loop). if (in_array($lang, $stack)) { return $stack; } // Load language configuration and look for the explicit parent language. if (!file_exists("$this->otherroot/$lang/langconfig.php")) { return $stack; } $string = array(); include("$this->otherroot/$lang/langconfig.php"); if (empty($string['parentlanguage']) or $string['parentlanguage'] === 'en') { return array_merge(array($lang), $stack); } $parentlang = $string['parentlanguage']; return $this->populate_parent_languages($parentlang, array_merge(array($lang), $stack)); }
[ "protected", "function", "populate_parent_languages", "(", "$", "lang", ",", "array", "$", "stack", "=", "array", "(", ")", ")", "{", "// English does not have a parent language.", "if", "(", "$", "lang", "===", "'en'", ")", "{", "return", "$", "stack", ";", "}", "// Prevent circular dependency (and thence the infinitive recursion loop).", "if", "(", "in_array", "(", "$", "lang", ",", "$", "stack", ")", ")", "{", "return", "$", "stack", ";", "}", "// Load language configuration and look for the explicit parent language.", "if", "(", "!", "file_exists", "(", "\"$this->otherroot/$lang/langconfig.php\"", ")", ")", "{", "return", "$", "stack", ";", "}", "$", "string", "=", "array", "(", ")", ";", "include", "(", "\"$this->otherroot/$lang/langconfig.php\"", ")", ";", "if", "(", "empty", "(", "$", "string", "[", "'parentlanguage'", "]", ")", "or", "$", "string", "[", "'parentlanguage'", "]", "===", "'en'", ")", "{", "return", "array_merge", "(", "array", "(", "$", "lang", ")", ",", "$", "stack", ")", ";", "}", "$", "parentlang", "=", "$", "string", "[", "'parentlanguage'", "]", ";", "return", "$", "this", "->", "populate_parent_languages", "(", "$", "parentlang", ",", "array_merge", "(", "array", "(", "$", "lang", ")", ",", "$", "stack", ")", ")", ";", "}" ]
Helper method that recursively loads all parents of the given language. @see self::get_language_dependencies() @param string $lang language code @param array $stack list of parent languages already populated in previous recursive calls @return array list of all parents of the given language with the $lang itself added as the last element
[ "Helper", "method", "that", "recursively", "loads", "all", "parents", "of", "the", "given", "language", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/string_manager_standard.php#L671-L697
212,933
moodle/moodle
lib/horde/framework/Horde/Mime/Related.php
Horde_Mime_Related.cidReplace
public function cidReplace($text, $callback, $charset = 'UTF-8') { $dom = ($text instanceof Horde_Domhtml) ? $text : new Horde_Domhtml($text, $charset); foreach ($dom as $node) { if ($node instanceof DOMElement) { switch (Horde_String::lower($node->tagName)) { case 'body': case 'td': $this->_cidReplace($node, 'background', $callback); break; case 'img': $this->_cidReplace($node, 'src', $callback); break; } } } return $dom; }
php
public function cidReplace($text, $callback, $charset = 'UTF-8') { $dom = ($text instanceof Horde_Domhtml) ? $text : new Horde_Domhtml($text, $charset); foreach ($dom as $node) { if ($node instanceof DOMElement) { switch (Horde_String::lower($node->tagName)) { case 'body': case 'td': $this->_cidReplace($node, 'background', $callback); break; case 'img': $this->_cidReplace($node, 'src', $callback); break; } } } return $dom; }
[ "public", "function", "cidReplace", "(", "$", "text", ",", "$", "callback", ",", "$", "charset", "=", "'UTF-8'", ")", "{", "$", "dom", "=", "(", "$", "text", "instanceof", "Horde_Domhtml", ")", "?", "$", "text", ":", "new", "Horde_Domhtml", "(", "$", "text", ",", "$", "charset", ")", ";", "foreach", "(", "$", "dom", "as", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "DOMElement", ")", "{", "switch", "(", "Horde_String", "::", "lower", "(", "$", "node", "->", "tagName", ")", ")", "{", "case", "'body'", ":", "case", "'td'", ":", "$", "this", "->", "_cidReplace", "(", "$", "node", ",", "'background'", ",", "$", "callback", ")", ";", "break", ";", "case", "'img'", ":", "$", "this", "->", "_cidReplace", "(", "$", "node", ",", "'src'", ",", "$", "callback", ")", ";", "break", ";", "}", "}", "}", "return", "$", "dom", ";", "}" ]
Scan for CID strings in HTML data and replace with data returned from a callback method. @param mixed $text The HTML text (can be Horde_Domhtml object). @param callback $callback Callback method. Receives three arguments: MIME ID, the attribute name containing the content ID, and the node object. Expects return value of URL to display the data. @param string $charset HTML data charset. @return Horde_Domhtml A Horde_Domhtml object.
[ "Scan", "for", "CID", "strings", "in", "HTML", "data", "and", "replace", "with", "data", "returned", "from", "a", "callback", "method", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Related.php#L117-L139
212,934
moodle/moodle
cohort/edit_form.php
cohort_edit_form.definition
public function definition() { global $CFG; $mform = $this->_form; $editoroptions = $this->_customdata['editoroptions']; $cohort = $this->_customdata['data']; $mform->addElement('text', 'name', get_string('name', 'cohort'), 'maxlength="254" size="50"'); $mform->addRule('name', get_string('required'), 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); $options = $this->get_category_options($cohort->contextid); $mform->addElement('select', 'contextid', get_string('context', 'role'), $options); $mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"'); $mform->setType('idnumber', PARAM_RAW); // Idnumbers are plain text, must not be changed. $mform->addElement('advcheckbox', 'visible', get_string('visible', 'cohort')); $mform->setDefault('visible', 1); $mform->addHelpButton('visible', 'visible', 'cohort'); $mform->addElement('editor', 'description_editor', get_string('description', 'cohort'), null, $editoroptions); $mform->setType('description_editor', PARAM_RAW); if (!empty($CFG->allowcohortthemes)) { $themes = array_merge(array('' => get_string('forceno')), cohort_get_list_of_themes()); $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); if (isset($this->_customdata['returnurl'])) { $mform->addElement('hidden', 'returnurl', $this->_customdata['returnurl']->out_as_local_url()); $mform->setType('returnurl', PARAM_LOCALURL); } $this->add_action_buttons(); $this->set_data($cohort); }
php
public function definition() { global $CFG; $mform = $this->_form; $editoroptions = $this->_customdata['editoroptions']; $cohort = $this->_customdata['data']; $mform->addElement('text', 'name', get_string('name', 'cohort'), 'maxlength="254" size="50"'); $mform->addRule('name', get_string('required'), 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); $options = $this->get_category_options($cohort->contextid); $mform->addElement('select', 'contextid', get_string('context', 'role'), $options); $mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"'); $mform->setType('idnumber', PARAM_RAW); // Idnumbers are plain text, must not be changed. $mform->addElement('advcheckbox', 'visible', get_string('visible', 'cohort')); $mform->setDefault('visible', 1); $mform->addHelpButton('visible', 'visible', 'cohort'); $mform->addElement('editor', 'description_editor', get_string('description', 'cohort'), null, $editoroptions); $mform->setType('description_editor', PARAM_RAW); if (!empty($CFG->allowcohortthemes)) { $themes = array_merge(array('' => get_string('forceno')), cohort_get_list_of_themes()); $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); if (isset($this->_customdata['returnurl'])) { $mform->addElement('hidden', 'returnurl', $this->_customdata['returnurl']->out_as_local_url()); $mform->setType('returnurl', PARAM_LOCALURL); } $this->add_action_buttons(); $this->set_data($cohort); }
[ "public", "function", "definition", "(", ")", "{", "global", "$", "CFG", ";", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "editoroptions", "=", "$", "this", "->", "_customdata", "[", "'editoroptions'", "]", ";", "$", "cohort", "=", "$", "this", "->", "_customdata", "[", "'data'", "]", ";", "$", "mform", "->", "addElement", "(", "'text'", ",", "'name'", ",", "get_string", "(", "'name'", ",", "'cohort'", ")", ",", "'maxlength=\"254\" size=\"50\"'", ")", ";", "$", "mform", "->", "addRule", "(", "'name'", ",", "get_string", "(", "'required'", ")", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "$", "mform", "->", "setType", "(", "'name'", ",", "PARAM_TEXT", ")", ";", "$", "options", "=", "$", "this", "->", "get_category_options", "(", "$", "cohort", "->", "contextid", ")", ";", "$", "mform", "->", "addElement", "(", "'select'", ",", "'contextid'", ",", "get_string", "(", "'context'", ",", "'role'", ")", ",", "$", "options", ")", ";", "$", "mform", "->", "addElement", "(", "'text'", ",", "'idnumber'", ",", "get_string", "(", "'idnumber'", ",", "'cohort'", ")", ",", "'maxlength=\"254\" size=\"50\"'", ")", ";", "$", "mform", "->", "setType", "(", "'idnumber'", ",", "PARAM_RAW", ")", ";", "// Idnumbers are plain text, must not be changed.", "$", "mform", "->", "addElement", "(", "'advcheckbox'", ",", "'visible'", ",", "get_string", "(", "'visible'", ",", "'cohort'", ")", ")", ";", "$", "mform", "->", "setDefault", "(", "'visible'", ",", "1", ")", ";", "$", "mform", "->", "addHelpButton", "(", "'visible'", ",", "'visible'", ",", "'cohort'", ")", ";", "$", "mform", "->", "addElement", "(", "'editor'", ",", "'description_editor'", ",", "get_string", "(", "'description'", ",", "'cohort'", ")", ",", "null", ",", "$", "editoroptions", ")", ";", "$", "mform", "->", "setType", "(", "'description_editor'", ",", "PARAM_RAW", ")", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "allowcohortthemes", ")", ")", "{", "$", "themes", "=", "array_merge", "(", "array", "(", "''", "=>", "get_string", "(", "'forceno'", ")", ")", ",", "cohort_get_list_of_themes", "(", ")", ")", ";", "$", "mform", "->", "addElement", "(", "'select'", ",", "'theme'", ",", "get_string", "(", "'forcetheme'", ")", ",", "$", "themes", ")", ";", "}", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'id'", ")", ";", "$", "mform", "->", "setType", "(", "'id'", ",", "PARAM_INT", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_customdata", "[", "'returnurl'", "]", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'returnurl'", ",", "$", "this", "->", "_customdata", "[", "'returnurl'", "]", "->", "out_as_local_url", "(", ")", ")", ";", "$", "mform", "->", "setType", "(", "'returnurl'", ",", "PARAM_LOCALURL", ")", ";", "}", "$", "this", "->", "add_action_buttons", "(", ")", ";", "$", "this", "->", "set_data", "(", "$", "cohort", ")", ";", "}" ]
Define the cohort edit form
[ "Define", "the", "cohort", "edit", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cohort/edit_form.php#L34-L74
212,935
moodle/moodle
mnet/xmlrpc/client.php
mnet_xmlrpc_client.set_timeout
function set_timeout($timeout) { if (!is_integer($timeout)) { if (is_numeric($timeout)) { $this->timeout = (integer)$timeout; return true; } return false; } $this->timeout = $timeout; return true; }
php
function set_timeout($timeout) { if (!is_integer($timeout)) { if (is_numeric($timeout)) { $this->timeout = (integer)$timeout; return true; } return false; } $this->timeout = $timeout; return true; }
[ "function", "set_timeout", "(", "$", "timeout", ")", "{", "if", "(", "!", "is_integer", "(", "$", "timeout", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "timeout", ")", ")", "{", "$", "this", "->", "timeout", "=", "(", "integer", ")", "$", "timeout", ";", "return", "true", ";", "}", "return", "false", ";", "}", "$", "this", "->", "timeout", "=", "$", "timeout", ";", "return", "true", ";", "}" ]
Allow users to override the default timeout @param int $timeout Request timeout in seconds $return bool True if param is an integer or integer string
[ "Allow", "users", "to", "override", "the", "default", "timeout" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/xmlrpc/client.php#L48-L58
212,936
moodle/moodle
mnet/xmlrpc/client.php
mnet_xmlrpc_client.add_param
function add_param($argument, $type = 'string') { $allowed_types = array('none', 'empty', 'base64', 'boolean', 'datetime', 'double', 'int', 'i4', 'string', 'array', 'struct'); if (!in_array($type, $allowed_types)) { return false; } if ($type != 'datetime' && $type != 'base64') { $this->params[] = $argument; return true; } // Note weirdness - The type of $argument gets changed to an object with // value and type properties. // bool xmlrpc_set_type ( string &value, string type ) xmlrpc_set_type($argument, $type); $this->params[] = $argument; return true; }
php
function add_param($argument, $type = 'string') { $allowed_types = array('none', 'empty', 'base64', 'boolean', 'datetime', 'double', 'int', 'i4', 'string', 'array', 'struct'); if (!in_array($type, $allowed_types)) { return false; } if ($type != 'datetime' && $type != 'base64') { $this->params[] = $argument; return true; } // Note weirdness - The type of $argument gets changed to an object with // value and type properties. // bool xmlrpc_set_type ( string &value, string type ) xmlrpc_set_type($argument, $type); $this->params[] = $argument; return true; }
[ "function", "add_param", "(", "$", "argument", ",", "$", "type", "=", "'string'", ")", "{", "$", "allowed_types", "=", "array", "(", "'none'", ",", "'empty'", ",", "'base64'", ",", "'boolean'", ",", "'datetime'", ",", "'double'", ",", "'int'", ",", "'i4'", ",", "'string'", ",", "'array'", ",", "'struct'", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "allowed_types", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "type", "!=", "'datetime'", "&&", "$", "type", "!=", "'base64'", ")", "{", "$", "this", "->", "params", "[", "]", "=", "$", "argument", ";", "return", "true", ";", "}", "// Note weirdness - The type of $argument gets changed to an object with", "// value and type properties.", "// bool xmlrpc_set_type ( string &value, string type )", "xmlrpc_set_type", "(", "$", "argument", ",", "$", "type", ")", ";", "$", "this", "->", "params", "[", "]", "=", "$", "argument", ";", "return", "true", ";", "}" ]
Add a parameter to the array of parameters. @param string $argument A transport ID, as defined in lib.php @param string $type The argument type, can be one of: none empty base64 boolean datetime double int string array struct In its weakly-typed wisdom, PHP will (currently) ignore everything except datetime and base64 @return bool True on success
[ "Add", "a", "parameter", "to", "the", "array", "of", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/xmlrpc/client.php#L98-L126
212,937
moodle/moodle
mnet/xmlrpc/client.php
mnet_xmlrpc_client.permission_to_call
function permission_to_call($mnet_peer) { global $DB, $CFG, $USER; // Executing any system method is permitted. $system_methods = array('system/listMethods', 'system/methodSignature', 'system/methodHelp', 'system/listServices'); if (in_array($this->method, $system_methods) ) { return true; } $hostids = array($mnet_peer->id); if (!empty($CFG->mnet_all_hosts_id)) { $hostids[] = $CFG->mnet_all_hosts_id; } // At this point, we don't care if the remote host implements the // method we're trying to call. We just want to know that: // 1. The method belongs to some service, as far as OUR host knows // 2. We are allowed to subscribe to that service on this mnet_peer list($hostidsql, $hostidparams) = $DB->get_in_or_equal($hostids); $sql = "SELECT r.id FROM {mnet_remote_rpc} r INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid WHERE r.xmlrpcpath = ? AND h2s.subscribe = ? AND h2s.hostid $hostidsql"; $params = array($this->method, 1); $params = array_merge($params, $hostidparams); if ($DB->record_exists_sql($sql, $params)) { return true; } $this->error[] = '7:User with ID '. $USER->id . ' attempted to call unauthorised method '. $this->method.' on host '. $mnet_peer->wwwroot; return false; }
php
function permission_to_call($mnet_peer) { global $DB, $CFG, $USER; // Executing any system method is permitted. $system_methods = array('system/listMethods', 'system/methodSignature', 'system/methodHelp', 'system/listServices'); if (in_array($this->method, $system_methods) ) { return true; } $hostids = array($mnet_peer->id); if (!empty($CFG->mnet_all_hosts_id)) { $hostids[] = $CFG->mnet_all_hosts_id; } // At this point, we don't care if the remote host implements the // method we're trying to call. We just want to know that: // 1. The method belongs to some service, as far as OUR host knows // 2. We are allowed to subscribe to that service on this mnet_peer list($hostidsql, $hostidparams) = $DB->get_in_or_equal($hostids); $sql = "SELECT r.id FROM {mnet_remote_rpc} r INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid WHERE r.xmlrpcpath = ? AND h2s.subscribe = ? AND h2s.hostid $hostidsql"; $params = array($this->method, 1); $params = array_merge($params, $hostidparams); if ($DB->record_exists_sql($sql, $params)) { return true; } $this->error[] = '7:User with ID '. $USER->id . ' attempted to call unauthorised method '. $this->method.' on host '. $mnet_peer->wwwroot; return false; }
[ "function", "permission_to_call", "(", "$", "mnet_peer", ")", "{", "global", "$", "DB", ",", "$", "CFG", ",", "$", "USER", ";", "// Executing any system method is permitted.", "$", "system_methods", "=", "array", "(", "'system/listMethods'", ",", "'system/methodSignature'", ",", "'system/methodHelp'", ",", "'system/listServices'", ")", ";", "if", "(", "in_array", "(", "$", "this", "->", "method", ",", "$", "system_methods", ")", ")", "{", "return", "true", ";", "}", "$", "hostids", "=", "array", "(", "$", "mnet_peer", "->", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "mnet_all_hosts_id", ")", ")", "{", "$", "hostids", "[", "]", "=", "$", "CFG", "->", "mnet_all_hosts_id", ";", "}", "// At this point, we don't care if the remote host implements the", "// method we're trying to call. We just want to know that:", "// 1. The method belongs to some service, as far as OUR host knows", "// 2. We are allowed to subscribe to that service on this mnet_peer", "list", "(", "$", "hostidsql", ",", "$", "hostidparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "hostids", ")", ";", "$", "sql", "=", "\"SELECT r.id\n FROM {mnet_remote_rpc} r\n INNER JOIN {mnet_remote_service2rpc} s2r ON s2r.rpcid = r.id\n INNER JOIN {mnet_host2service} h2s ON h2s.serviceid = s2r.serviceid\n WHERE r.xmlrpcpath = ?\n AND h2s.subscribe = ?\n AND h2s.hostid $hostidsql\"", ";", "$", "params", "=", "array", "(", "$", "this", "->", "method", ",", "1", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "hostidparams", ")", ";", "if", "(", "$", "DB", "->", "record_exists_sql", "(", "$", "sql", ",", "$", "params", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "[", "]", "=", "'7:User with ID '", ".", "$", "USER", "->", "id", ".", "' attempted to call unauthorised method '", ".", "$", "this", "->", "method", ".", "' on host '", ".", "$", "mnet_peer", "->", "wwwroot", ";", "return", "false", ";", "}" ]
Check that we are permitted to call method on specified peer @param object $mnet_peer A mnet_peer object with details of the remote host we're connecting to @return bool True if we permit calls to method on specified peer, False otherwise.
[ "Check", "that", "we", "are", "permitted", "to", "call", "method", "on", "specified", "peer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/xmlrpc/client.php#L322-L362
212,938
moodle/moodle
mnet/xmlrpc/client.php
mnet_xmlrpc_client.prepare_http_request
function prepare_http_request ($mnet_peer) { $this->uri = $mnet_peer->wwwroot . $mnet_peer->application->xmlrpc_server_url; // Initialize request the target URL $httprequest = curl_init($this->uri); curl_setopt($httprequest, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($httprequest, CURLOPT_RETURNTRANSFER, true); curl_setopt($httprequest, CURLOPT_POST, true); curl_setopt($httprequest, CURLOPT_USERAGENT, 'Moodle'); curl_setopt($httprequest, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8")); $verifyhost = 0; $verifypeer = false; if ($mnet_peer->sslverification == mnet_peer::SSL_HOST_AND_PEER) { $verifyhost = 2; $verifypeer = true; } else if ($mnet_peer->sslverification == mnet_peer::SSL_HOST) { $verifyhost = 2; } curl_setopt($httprequest, CURLOPT_SSL_VERIFYHOST, $verifyhost); curl_setopt($httprequest, CURLOPT_SSL_VERIFYPEER, $verifypeer); return $httprequest; }
php
function prepare_http_request ($mnet_peer) { $this->uri = $mnet_peer->wwwroot . $mnet_peer->application->xmlrpc_server_url; // Initialize request the target URL $httprequest = curl_init($this->uri); curl_setopt($httprequest, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($httprequest, CURLOPT_RETURNTRANSFER, true); curl_setopt($httprequest, CURLOPT_POST, true); curl_setopt($httprequest, CURLOPT_USERAGENT, 'Moodle'); curl_setopt($httprequest, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8")); $verifyhost = 0; $verifypeer = false; if ($mnet_peer->sslverification == mnet_peer::SSL_HOST_AND_PEER) { $verifyhost = 2; $verifypeer = true; } else if ($mnet_peer->sslverification == mnet_peer::SSL_HOST) { $verifyhost = 2; } curl_setopt($httprequest, CURLOPT_SSL_VERIFYHOST, $verifyhost); curl_setopt($httprequest, CURLOPT_SSL_VERIFYPEER, $verifypeer); return $httprequest; }
[ "function", "prepare_http_request", "(", "$", "mnet_peer", ")", "{", "$", "this", "->", "uri", "=", "$", "mnet_peer", "->", "wwwroot", ".", "$", "mnet_peer", "->", "application", "->", "xmlrpc_server_url", ";", "// Initialize request the target URL", "$", "httprequest", "=", "curl_init", "(", "$", "this", "->", "uri", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_TIMEOUT", ",", "$", "this", "->", "timeout", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_USERAGENT", ",", "'Moodle'", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "\"Content-Type: text/xml charset=UTF-8\"", ")", ")", ";", "$", "verifyhost", "=", "0", ";", "$", "verifypeer", "=", "false", ";", "if", "(", "$", "mnet_peer", "->", "sslverification", "==", "mnet_peer", "::", "SSL_HOST_AND_PEER", ")", "{", "$", "verifyhost", "=", "2", ";", "$", "verifypeer", "=", "true", ";", "}", "else", "if", "(", "$", "mnet_peer", "->", "sslverification", "==", "mnet_peer", "::", "SSL_HOST", ")", "{", "$", "verifyhost", "=", "2", ";", "}", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_SSL_VERIFYHOST", ",", "$", "verifyhost", ")", ";", "curl_setopt", "(", "$", "httprequest", ",", "CURLOPT_SSL_VERIFYPEER", ",", "$", "verifypeer", ")", ";", "return", "$", "httprequest", ";", "}" ]
Generate a curl handle and prepare it for sending to an mnet host @param object $mnet_peer A mnet_peer object with details of the remote host the request will be sent to @return cURL handle - the almost-ready-to-send http request
[ "Generate", "a", "curl", "handle", "and", "prepare", "it", "for", "sending", "to", "an", "mnet", "host" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/xmlrpc/client.php#L370-L392
212,939
moodle/moodle
lib/classes/output/mustache_javascript_helper.php
mustache_javascript_helper.help
public function help($text, \Mustache_LambdaHelper $helper) { $this->page->requires->js_amd_inline($helper->render($text)); }
php
public function help($text, \Mustache_LambdaHelper $helper) { $this->page->requires->js_amd_inline($helper->render($text)); }
[ "public", "function", "help", "(", "$", "text", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "this", "->", "page", "->", "requires", "->", "js_amd_inline", "(", "$", "helper", "->", "render", "(", "$", "text", ")", ")", ";", "}" ]
Add the block of text to the page requires so it is appended in the footer. The content of the block can contain further mustache tags which will be resolved. @param string $text The script content of the section. @param \Mustache_LambdaHelper $helper Used to render the content of this block.
[ "Add", "the", "block", "of", "text", "to", "the", "page", "requires", "so", "it", "is", "appended", "in", "the", "footer", ".", "The", "content", "of", "the", "block", "can", "contain", "further", "mustache", "tags", "which", "will", "be", "resolved", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/output/mustache_javascript_helper.php#L56-L58
212,940
moodle/moodle
admin/tool/analytics/classes/task/train_models.php
train_models.execute
public function execute() { global $OUTPUT, $PAGE; $models = \core_analytics\manager::get_all_models(true); if (!$models) { mtrace(get_string('errornoenabledmodels', 'tool_analytics')); return; } foreach ($models as $model) { if ($model->is_static()) { // Skip models based on assumptions. continue; } if (!$model->get_time_splitting()) { // Can not train if there is no time splitting method selected. continue; } $result = $model->train(); // Reset the page as some indicators may call external functions that overwrite the page context. \tool_analytics\output\helper::reset_page(); if ($result) { echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name())); $renderer = $PAGE->get_renderer('tool_analytics'); echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs()); } } }
php
public function execute() { global $OUTPUT, $PAGE; $models = \core_analytics\manager::get_all_models(true); if (!$models) { mtrace(get_string('errornoenabledmodels', 'tool_analytics')); return; } foreach ($models as $model) { if ($model->is_static()) { // Skip models based on assumptions. continue; } if (!$model->get_time_splitting()) { // Can not train if there is no time splitting method selected. continue; } $result = $model->train(); // Reset the page as some indicators may call external functions that overwrite the page context. \tool_analytics\output\helper::reset_page(); if ($result) { echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name())); $renderer = $PAGE->get_renderer('tool_analytics'); echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs()); } } }
[ "public", "function", "execute", "(", ")", "{", "global", "$", "OUTPUT", ",", "$", "PAGE", ";", "$", "models", "=", "\\", "core_analytics", "\\", "manager", "::", "get_all_models", "(", "true", ")", ";", "if", "(", "!", "$", "models", ")", "{", "mtrace", "(", "get_string", "(", "'errornoenabledmodels'", ",", "'tool_analytics'", ")", ")", ";", "return", ";", "}", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "if", "(", "$", "model", "->", "is_static", "(", ")", ")", "{", "// Skip models based on assumptions.", "continue", ";", "}", "if", "(", "!", "$", "model", "->", "get_time_splitting", "(", ")", ")", "{", "// Can not train if there is no time splitting method selected.", "continue", ";", "}", "$", "result", "=", "$", "model", "->", "train", "(", ")", ";", "// Reset the page as some indicators may call external functions that overwrite the page context.", "\\", "tool_analytics", "\\", "output", "\\", "helper", "::", "reset_page", "(", ")", ";", "if", "(", "$", "result", ")", "{", "echo", "$", "OUTPUT", "->", "heading", "(", "get_string", "(", "'modelresults'", ",", "'tool_analytics'", ",", "$", "model", "->", "get_name", "(", ")", ")", ")", ";", "$", "renderer", "=", "$", "PAGE", "->", "get_renderer", "(", "'tool_analytics'", ")", ";", "echo", "$", "renderer", "->", "render_get_predictions_results", "(", "$", "result", ",", "$", "model", "->", "get_analyser", "(", ")", "->", "get_logs", "(", ")", ")", ";", "}", "}", "}" ]
Executes the prediction task. @return void
[ "Executes", "the", "prediction", "task", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/analytics/classes/task/train_models.php#L52-L85
212,941
moodle/moodle
blocks/starredcourses/classes/external.php
block_starredcourses_external.get_starred_courses
public static function get_starred_courses($limit, $offset) { global $USER, $PAGE; $params = self::validate_parameters(self::get_starred_courses_parameters(), [ 'limit' => $limit, 'offset' => $offset ]); $limit = $params['limit']; $offset = $params['offset']; $usercontext = context_user::instance($USER->id); self::validate_context($usercontext); $PAGE->set_context($usercontext); $renderer = $PAGE->get_renderer('core'); // Get the user favourites service, scoped to a single user (their favourites only). $userservice = \core_favourites\service_factory::get_service_for_user_context($usercontext); // Get the favourites, by type, for the user. $favourites = $userservice->find_favourites_by_type('core_course', 'courses', $offset, $limit); // Sort the favourites getting last added first. usort($favourites, function($a, $b) { if ($a->timemodified == $b->timemodified) return 0; return ($a->timemodified > $b->timemodified) ? -1 : 1; }); $formattedcourses = array_map(function($favourite) use ($renderer) { $course = get_course($favourite->itemid); $context = \context_course::instance($favourite->itemid); $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => true]); return $exporter->export($renderer); }, $favourites); return $formattedcourses; }
php
public static function get_starred_courses($limit, $offset) { global $USER, $PAGE; $params = self::validate_parameters(self::get_starred_courses_parameters(), [ 'limit' => $limit, 'offset' => $offset ]); $limit = $params['limit']; $offset = $params['offset']; $usercontext = context_user::instance($USER->id); self::validate_context($usercontext); $PAGE->set_context($usercontext); $renderer = $PAGE->get_renderer('core'); // Get the user favourites service, scoped to a single user (their favourites only). $userservice = \core_favourites\service_factory::get_service_for_user_context($usercontext); // Get the favourites, by type, for the user. $favourites = $userservice->find_favourites_by_type('core_course', 'courses', $offset, $limit); // Sort the favourites getting last added first. usort($favourites, function($a, $b) { if ($a->timemodified == $b->timemodified) return 0; return ($a->timemodified > $b->timemodified) ? -1 : 1; }); $formattedcourses = array_map(function($favourite) use ($renderer) { $course = get_course($favourite->itemid); $context = \context_course::instance($favourite->itemid); $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => true]); return $exporter->export($renderer); }, $favourites); return $formattedcourses; }
[ "public", "static", "function", "get_starred_courses", "(", "$", "limit", ",", "$", "offset", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_starred_courses_parameters", "(", ")", ",", "[", "'limit'", "=>", "$", "limit", ",", "'offset'", "=>", "$", "offset", "]", ")", ";", "$", "limit", "=", "$", "params", "[", "'limit'", "]", ";", "$", "offset", "=", "$", "params", "[", "'offset'", "]", ";", "$", "usercontext", "=", "context_user", "::", "instance", "(", "$", "USER", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "usercontext", ")", ";", "$", "PAGE", "->", "set_context", "(", "$", "usercontext", ")", ";", "$", "renderer", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "// Get the user favourites service, scoped to a single user (their favourites only).", "$", "userservice", "=", "\\", "core_favourites", "\\", "service_factory", "::", "get_service_for_user_context", "(", "$", "usercontext", ")", ";", "// Get the favourites, by type, for the user.", "$", "favourites", "=", "$", "userservice", "->", "find_favourites_by_type", "(", "'core_course'", ",", "'courses'", ",", "$", "offset", ",", "$", "limit", ")", ";", "// Sort the favourites getting last added first.", "usort", "(", "$", "favourites", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "$", "a", "->", "timemodified", "==", "$", "b", "->", "timemodified", ")", "return", "0", ";", "return", "(", "$", "a", "->", "timemodified", ">", "$", "b", "->", "timemodified", ")", "?", "-", "1", ":", "1", ";", "}", ")", ";", "$", "formattedcourses", "=", "array_map", "(", "function", "(", "$", "favourite", ")", "use", "(", "$", "renderer", ")", "{", "$", "course", "=", "get_course", "(", "$", "favourite", "->", "itemid", ")", ";", "$", "context", "=", "\\", "context_course", "::", "instance", "(", "$", "favourite", "->", "itemid", ")", ";", "$", "exporter", "=", "new", "course_summary_exporter", "(", "$", "course", ",", "[", "'context'", "=>", "$", "context", ",", "'isfavourite'", "=>", "true", "]", ")", ";", "return", "$", "exporter", "->", "export", "(", "$", "renderer", ")", ";", "}", ",", "$", "favourites", ")", ";", "return", "$", "formattedcourses", ";", "}" ]
Get users starred courses. @param int $limit Limit @param int $offset Offset @return array list of courses and warnings
[ "Get", "users", "starred", "courses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/starredcourses/classes/external.php#L62-L100
212,942
moodle/moodle
mod/wiki/diff/diff_nwiki.php
WikiDiff.reverse
function reverse () { $rev = $this; $rev->edits = array(); foreach ($this->edits as $edit) { $rev->edits[] = $edit->reverse(); } return $rev; }
php
function reverse () { $rev = $this; $rev->edits = array(); foreach ($this->edits as $edit) { $rev->edits[] = $edit->reverse(); } return $rev; }
[ "function", "reverse", "(", ")", "{", "$", "rev", "=", "$", "this", ";", "$", "rev", "->", "edits", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "edits", "as", "$", "edit", ")", "{", "$", "rev", "->", "edits", "[", "]", "=", "$", "edit", "->", "reverse", "(", ")", ";", "}", "return", "$", "rev", ";", "}" ]
Compute reversed WikiDiff. SYNOPSIS: $diff = new WikiDiff($lines1, $lines2); $rev = $diff->reverse(); @return object A WikiDiff object representing the inverse of the original diff.
[ "Compute", "reversed", "WikiDiff", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/diff/diff_nwiki.php#L529-L536
212,943
moodle/moodle
mod/wiki/diff/diff_nwiki.php
WikiDiff.orig
function orig() { $lines = array(); foreach ($this->edits as $edit) { if ($edit->orig) array_splice($lines, sizeof($lines), 0, $edit->orig); } return $lines; }
php
function orig() { $lines = array(); foreach ($this->edits as $edit) { if ($edit->orig) array_splice($lines, sizeof($lines), 0, $edit->orig); } return $lines; }
[ "function", "orig", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "edits", "as", "$", "edit", ")", "{", "if", "(", "$", "edit", "->", "orig", ")", "array_splice", "(", "$", "lines", ",", "sizeof", "(", "$", "lines", ")", ",", "0", ",", "$", "edit", "->", "orig", ")", ";", "}", "return", "$", "lines", ";", "}" ]
Get the original set of lines. This reconstructs the $from_lines parameter passed to the constructor. @return array The original sequence of strings.
[ "Get", "the", "original", "set", "of", "lines", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/diff/diff_nwiki.php#L575-L583
212,944
moodle/moodle
mod/wiki/diff/diff_nwiki.php
WikiDiff.closing
function closing() { $lines = array(); foreach ($this->edits as $edit) { if ($edit->closing) array_splice($lines, sizeof($lines), 0, $edit->closing); } return $lines; }
php
function closing() { $lines = array(); foreach ($this->edits as $edit) { if ($edit->closing) array_splice($lines, sizeof($lines), 0, $edit->closing); } return $lines; }
[ "function", "closing", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "edits", "as", "$", "edit", ")", "{", "if", "(", "$", "edit", "->", "closing", ")", "array_splice", "(", "$", "lines", ",", "sizeof", "(", "$", "lines", ")", ",", "0", ",", "$", "edit", "->", "closing", ")", ";", "}", "return", "$", "lines", ";", "}" ]
Get the closing set of lines. This reconstructs the $to_lines parameter passed to the constructor. @return array The sequence of strings.
[ "Get", "the", "closing", "set", "of", "lines", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/diff/diff_nwiki.php#L593-L601
212,945
moodle/moodle
mod/wiki/diff/diff_nwiki.php
WikiDiff._check
function _check ($from_lines, $to_lines) { if (serialize($from_lines) != serialize($this->orig())) trigger_error("Reconstructed original doesn't match", E_USER_ERROR); if (serialize($to_lines) != serialize($this->closing())) trigger_error("Reconstructed closing doesn't match", E_USER_ERROR); $rev = $this->reverse(); if (serialize($to_lines) != serialize($rev->orig())) trigger_error("Reversed original doesn't match", E_USER_ERROR); if (serialize($from_lines) != serialize($rev->closing())) trigger_error("Reversed closing doesn't match", E_USER_ERROR); $prevtype = 'none'; foreach ($this->edits as $edit) { if ( $prevtype == $edit->type ) trigger_error("Edit sequence is non-optimal", E_USER_ERROR); $prevtype = $edit->type; } $lcs = $this->lcs(); trigger_error("WikiDiff okay: LCS = $lcs", E_USER_NOTICE); }
php
function _check ($from_lines, $to_lines) { if (serialize($from_lines) != serialize($this->orig())) trigger_error("Reconstructed original doesn't match", E_USER_ERROR); if (serialize($to_lines) != serialize($this->closing())) trigger_error("Reconstructed closing doesn't match", E_USER_ERROR); $rev = $this->reverse(); if (serialize($to_lines) != serialize($rev->orig())) trigger_error("Reversed original doesn't match", E_USER_ERROR); if (serialize($from_lines) != serialize($rev->closing())) trigger_error("Reversed closing doesn't match", E_USER_ERROR); $prevtype = 'none'; foreach ($this->edits as $edit) { if ( $prevtype == $edit->type ) trigger_error("Edit sequence is non-optimal", E_USER_ERROR); $prevtype = $edit->type; } $lcs = $this->lcs(); trigger_error("WikiDiff okay: LCS = $lcs", E_USER_NOTICE); }
[ "function", "_check", "(", "$", "from_lines", ",", "$", "to_lines", ")", "{", "if", "(", "serialize", "(", "$", "from_lines", ")", "!=", "serialize", "(", "$", "this", "->", "orig", "(", ")", ")", ")", "trigger_error", "(", "\"Reconstructed original doesn't match\"", ",", "E_USER_ERROR", ")", ";", "if", "(", "serialize", "(", "$", "to_lines", ")", "!=", "serialize", "(", "$", "this", "->", "closing", "(", ")", ")", ")", "trigger_error", "(", "\"Reconstructed closing doesn't match\"", ",", "E_USER_ERROR", ")", ";", "$", "rev", "=", "$", "this", "->", "reverse", "(", ")", ";", "if", "(", "serialize", "(", "$", "to_lines", ")", "!=", "serialize", "(", "$", "rev", "->", "orig", "(", ")", ")", ")", "trigger_error", "(", "\"Reversed original doesn't match\"", ",", "E_USER_ERROR", ")", ";", "if", "(", "serialize", "(", "$", "from_lines", ")", "!=", "serialize", "(", "$", "rev", "->", "closing", "(", ")", ")", ")", "trigger_error", "(", "\"Reversed closing doesn't match\"", ",", "E_USER_ERROR", ")", ";", "$", "prevtype", "=", "'none'", ";", "foreach", "(", "$", "this", "->", "edits", "as", "$", "edit", ")", "{", "if", "(", "$", "prevtype", "==", "$", "edit", "->", "type", ")", "trigger_error", "(", "\"Edit sequence is non-optimal\"", ",", "E_USER_ERROR", ")", ";", "$", "prevtype", "=", "$", "edit", "->", "type", ";", "}", "$", "lcs", "=", "$", "this", "->", "lcs", "(", ")", ";", "trigger_error", "(", "\"WikiDiff okay: LCS = $lcs\"", ",", "E_USER_NOTICE", ")", ";", "}" ]
Check a WikiDiff for validity. This is here only for debugging purposes.
[ "Check", "a", "WikiDiff", "for", "validity", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/diff/diff_nwiki.php#L608-L630
212,946
moodle/moodle
mod/workshop/form/rubric/lib.php
workshop_rubric_strategy.delete_instance
public static function delete_instance($workshopid) { global $DB; $dimensions = $DB->get_records('workshopform_rubric', array('workshopid' => $workshopid), '', 'id'); $DB->delete_records_list('workshopform_rubric_levels', 'dimensionid', array_keys($dimensions)); $DB->delete_records('workshopform_rubric', array('workshopid' => $workshopid)); $DB->delete_records('workshopform_rubric_config', array('workshopid' => $workshopid)); }
php
public static function delete_instance($workshopid) { global $DB; $dimensions = $DB->get_records('workshopform_rubric', array('workshopid' => $workshopid), '', 'id'); $DB->delete_records_list('workshopform_rubric_levels', 'dimensionid', array_keys($dimensions)); $DB->delete_records('workshopform_rubric', array('workshopid' => $workshopid)); $DB->delete_records('workshopform_rubric_config', array('workshopid' => $workshopid)); }
[ "public", "static", "function", "delete_instance", "(", "$", "workshopid", ")", "{", "global", "$", "DB", ";", "$", "dimensions", "=", "$", "DB", "->", "get_records", "(", "'workshopform_rubric'", ",", "array", "(", "'workshopid'", "=>", "$", "workshopid", ")", ",", "''", ",", "'id'", ")", ";", "$", "DB", "->", "delete_records_list", "(", "'workshopform_rubric_levels'", ",", "'dimensionid'", ",", "array_keys", "(", "$", "dimensions", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "'workshopform_rubric'", ",", "array", "(", "'workshopid'", "=>", "$", "workshopid", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "'workshopform_rubric_config'", ",", "array", "(", "'workshopid'", "=>", "$", "workshopid", ")", ")", ";", "}" ]
Delete all data related to a given workshop module instance @see workshop_delete_instance() @param int $workshopid id of the workshop module instance being deleted @return void
[ "Delete", "all", "data", "related", "to", "a", "given", "workshop", "module", "instance" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/form/rubric/lib.php#L412-L419
212,947
moodle/moodle
mod/workshop/form/rubric/lib.php
workshop_rubric_strategy.load_config
protected function load_config() { global $DB; if (!$config = $DB->get_record('workshopform_rubric_config', array('workshopid' => $this->workshop->id), 'layout')) { $config = (object)array('layout' => 'list'); } return $config; }
php
protected function load_config() { global $DB; if (!$config = $DB->get_record('workshopform_rubric_config', array('workshopid' => $this->workshop->id), 'layout')) { $config = (object)array('layout' => 'list'); } return $config; }
[ "protected", "function", "load_config", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "config", "=", "$", "DB", "->", "get_record", "(", "'workshopform_rubric_config'", ",", "array", "(", "'workshopid'", "=>", "$", "this", "->", "workshop", "->", "id", ")", ",", "'layout'", ")", ")", "{", "$", "config", "=", "(", "object", ")", "array", "(", "'layout'", "=>", "'list'", ")", ";", "}", "return", "$", "config", ";", "}" ]
Get the configuration for the current rubric strategy @return object
[ "Get", "the", "configuration", "for", "the", "current", "rubric", "strategy" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/form/rubric/lib.php#L470-L477
212,948
moodle/moodle
mod/workshop/form/rubric/lib.php
workshop_rubric_strategy.get_current_assessment_data
protected function get_current_assessment_data(stdclass $assessment) { global $DB; if (empty($this->dimensions)) { return array(); } list($dimsql, $dimparams) = $DB->get_in_or_equal(array_keys($this->dimensions), SQL_PARAMS_NAMED); // beware! the caller may rely on the returned array is indexed by dimensionid $sql = "SELECT dimensionid, wg.* FROM {workshop_grades} wg WHERE assessmentid = :assessmentid AND strategy= :strategy AND dimensionid $dimsql"; $params = array('assessmentid' => $assessment->id, 'strategy' => 'rubric'); $params = array_merge($params, $dimparams); return $DB->get_records_sql($sql, $params); }
php
protected function get_current_assessment_data(stdclass $assessment) { global $DB; if (empty($this->dimensions)) { return array(); } list($dimsql, $dimparams) = $DB->get_in_or_equal(array_keys($this->dimensions), SQL_PARAMS_NAMED); // beware! the caller may rely on the returned array is indexed by dimensionid $sql = "SELECT dimensionid, wg.* FROM {workshop_grades} wg WHERE assessmentid = :assessmentid AND strategy= :strategy AND dimensionid $dimsql"; $params = array('assessmentid' => $assessment->id, 'strategy' => 'rubric'); $params = array_merge($params, $dimparams); return $DB->get_records_sql($sql, $params); }
[ "protected", "function", "get_current_assessment_data", "(", "stdclass", "$", "assessment", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "this", "->", "dimensions", ")", ")", "{", "return", "array", "(", ")", ";", "}", "list", "(", "$", "dimsql", ",", "$", "dimparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_keys", "(", "$", "this", "->", "dimensions", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "// beware! the caller may rely on the returned array is indexed by dimensionid", "$", "sql", "=", "\"SELECT dimensionid, wg.*\n FROM {workshop_grades} wg\n WHERE assessmentid = :assessmentid AND strategy= :strategy AND dimensionid $dimsql\"", ";", "$", "params", "=", "array", "(", "'assessmentid'", "=>", "$", "assessment", "->", "id", ",", "'strategy'", "=>", "'rubric'", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "dimparams", ")", ";", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Returns the list of current grades filled by the reviewer indexed by dimensionid @param stdClass $assessment Assessment record @return array [int dimensionid] => stdclass workshop_grades record
[ "Returns", "the", "list", "of", "current", "grades", "filled", "by", "the", "reviewer", "indexed", "by", "dimensionid" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/form/rubric/lib.php#L571-L586
212,949
moodle/moodle
mod/forum/classes/observer.php
mod_forum_observer.user_enrolment_deleted
public static function user_enrolment_deleted(\core\event\user_enrolment_deleted $event) { global $DB; // NOTE: this has to be as fast as possible. // Get user enrolment info from event. $cp = (object)$event->other['userenrolment']; if ($cp->lastenrol) { if (!$forums = $DB->get_records('forum', array('course' => $cp->courseid), '', 'id')) { return; } list($forumselect, $params) = $DB->get_in_or_equal(array_keys($forums), SQL_PARAMS_NAMED); $params['userid'] = $cp->userid; $DB->delete_records_select('forum_digests', 'userid = :userid AND forum '.$forumselect, $params); $DB->delete_records_select('forum_subscriptions', 'userid = :userid AND forum '.$forumselect, $params); $DB->delete_records_select('forum_track_prefs', 'userid = :userid AND forumid '.$forumselect, $params); $DB->delete_records_select('forum_read', 'userid = :userid AND forumid '.$forumselect, $params); } }
php
public static function user_enrolment_deleted(\core\event\user_enrolment_deleted $event) { global $DB; // NOTE: this has to be as fast as possible. // Get user enrolment info from event. $cp = (object)$event->other['userenrolment']; if ($cp->lastenrol) { if (!$forums = $DB->get_records('forum', array('course' => $cp->courseid), '', 'id')) { return; } list($forumselect, $params) = $DB->get_in_or_equal(array_keys($forums), SQL_PARAMS_NAMED); $params['userid'] = $cp->userid; $DB->delete_records_select('forum_digests', 'userid = :userid AND forum '.$forumselect, $params); $DB->delete_records_select('forum_subscriptions', 'userid = :userid AND forum '.$forumselect, $params); $DB->delete_records_select('forum_track_prefs', 'userid = :userid AND forumid '.$forumselect, $params); $DB->delete_records_select('forum_read', 'userid = :userid AND forumid '.$forumselect, $params); } }
[ "public", "static", "function", "user_enrolment_deleted", "(", "\\", "core", "\\", "event", "\\", "user_enrolment_deleted", "$", "event", ")", "{", "global", "$", "DB", ";", "// NOTE: this has to be as fast as possible.", "// Get user enrolment info from event.", "$", "cp", "=", "(", "object", ")", "$", "event", "->", "other", "[", "'userenrolment'", "]", ";", "if", "(", "$", "cp", "->", "lastenrol", ")", "{", "if", "(", "!", "$", "forums", "=", "$", "DB", "->", "get_records", "(", "'forum'", ",", "array", "(", "'course'", "=>", "$", "cp", "->", "courseid", ")", ",", "''", ",", "'id'", ")", ")", "{", "return", ";", "}", "list", "(", "$", "forumselect", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_keys", "(", "$", "forums", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "params", "[", "'userid'", "]", "=", "$", "cp", "->", "userid", ";", "$", "DB", "->", "delete_records_select", "(", "'forum_digests'", ",", "'userid = :userid AND forum '", ".", "$", "forumselect", ",", "$", "params", ")", ";", "$", "DB", "->", "delete_records_select", "(", "'forum_subscriptions'", ",", "'userid = :userid AND forum '", ".", "$", "forumselect", ",", "$", "params", ")", ";", "$", "DB", "->", "delete_records_select", "(", "'forum_track_prefs'", ",", "'userid = :userid AND forumid '", ".", "$", "forumselect", ",", "$", "params", ")", ";", "$", "DB", "->", "delete_records_select", "(", "'forum_read'", ",", "'userid = :userid AND forumid '", ".", "$", "forumselect", ",", "$", "params", ")", ";", "}", "}" ]
Triggered via user_enrolment_deleted event. @param \core\event\user_enrolment_deleted $event
[ "Triggered", "via", "user_enrolment_deleted", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/observer.php#L37-L55
212,950
moodle/moodle
mod/forum/classes/observer.php
mod_forum_observer.role_assigned
public static function role_assigned(\core\event\role_assigned $event) { global $CFG, $DB; $context = context::instance_by_id($event->contextid, MUST_EXIST); // If contextlevel is course then only subscribe user. Role assignment // at course level means user is enroled in course and can subscribe to forum. if ($context->contextlevel != CONTEXT_COURSE) { return; } // Forum lib required for the constant used below. require_once($CFG->dirroot . '/mod/forum/lib.php'); $userid = $event->relateduserid; $sql = "SELECT f.id, f.course as course, cm.id AS cmid, f.forcesubscribe FROM {forum} f JOIN {course_modules} cm ON (cm.instance = f.id) JOIN {modules} m ON (m.id = cm.module) LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = :userid) WHERE f.course = :courseid AND f.forcesubscribe = :initial AND m.name = 'forum' AND fs.id IS NULL"; $params = array('courseid' => $context->instanceid, 'userid' => $userid, 'initial' => FORUM_INITIALSUBSCRIBE); $forums = $DB->get_records_sql($sql, $params); foreach ($forums as $forum) { // If user doesn't have allowforcesubscribe capability then don't subscribe. $modcontext = context_module::instance($forum->cmid); if (has_capability('mod/forum:allowforcesubscribe', $modcontext, $userid)) { \mod_forum\subscriptions::subscribe_user($userid, $forum, $modcontext); } } }
php
public static function role_assigned(\core\event\role_assigned $event) { global $CFG, $DB; $context = context::instance_by_id($event->contextid, MUST_EXIST); // If contextlevel is course then only subscribe user. Role assignment // at course level means user is enroled in course and can subscribe to forum. if ($context->contextlevel != CONTEXT_COURSE) { return; } // Forum lib required for the constant used below. require_once($CFG->dirroot . '/mod/forum/lib.php'); $userid = $event->relateduserid; $sql = "SELECT f.id, f.course as course, cm.id AS cmid, f.forcesubscribe FROM {forum} f JOIN {course_modules} cm ON (cm.instance = f.id) JOIN {modules} m ON (m.id = cm.module) LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = :userid) WHERE f.course = :courseid AND f.forcesubscribe = :initial AND m.name = 'forum' AND fs.id IS NULL"; $params = array('courseid' => $context->instanceid, 'userid' => $userid, 'initial' => FORUM_INITIALSUBSCRIBE); $forums = $DB->get_records_sql($sql, $params); foreach ($forums as $forum) { // If user doesn't have allowforcesubscribe capability then don't subscribe. $modcontext = context_module::instance($forum->cmid); if (has_capability('mod/forum:allowforcesubscribe', $modcontext, $userid)) { \mod_forum\subscriptions::subscribe_user($userid, $forum, $modcontext); } } }
[ "public", "static", "function", "role_assigned", "(", "\\", "core", "\\", "event", "\\", "role_assigned", "$", "event", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "$", "context", "=", "context", "::", "instance_by_id", "(", "$", "event", "->", "contextid", ",", "MUST_EXIST", ")", ";", "// If contextlevel is course then only subscribe user. Role assignment", "// at course level means user is enroled in course and can subscribe to forum.", "if", "(", "$", "context", "->", "contextlevel", "!=", "CONTEXT_COURSE", ")", "{", "return", ";", "}", "// Forum lib required for the constant used below.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/forum/lib.php'", ")", ";", "$", "userid", "=", "$", "event", "->", "relateduserid", ";", "$", "sql", "=", "\"SELECT f.id, f.course as course, cm.id AS cmid, f.forcesubscribe\n FROM {forum} f\n JOIN {course_modules} cm ON (cm.instance = f.id)\n JOIN {modules} m ON (m.id = cm.module)\n LEFT JOIN {forum_subscriptions} fs ON (fs.forum = f.id AND fs.userid = :userid)\n WHERE f.course = :courseid\n AND f.forcesubscribe = :initial\n AND m.name = 'forum'\n AND fs.id IS NULL\"", ";", "$", "params", "=", "array", "(", "'courseid'", "=>", "$", "context", "->", "instanceid", ",", "'userid'", "=>", "$", "userid", ",", "'initial'", "=>", "FORUM_INITIALSUBSCRIBE", ")", ";", "$", "forums", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "foreach", "(", "$", "forums", "as", "$", "forum", ")", "{", "// If user doesn't have allowforcesubscribe capability then don't subscribe.", "$", "modcontext", "=", "context_module", "::", "instance", "(", "$", "forum", "->", "cmid", ")", ";", "if", "(", "has_capability", "(", "'mod/forum:allowforcesubscribe'", ",", "$", "modcontext", ",", "$", "userid", ")", ")", "{", "\\", "mod_forum", "\\", "subscriptions", "::", "subscribe_user", "(", "$", "userid", ",", "$", "forum", ",", "$", "modcontext", ")", ";", "}", "}", "}" ]
Observer for role_assigned event. @param \core\event\role_assigned $event @return void
[ "Observer", "for", "role_assigned", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/observer.php#L63-L97
212,951
moodle/moodle
mod/forum/classes/observer.php
mod_forum_observer.course_module_created
public static function course_module_created(\core\event\course_module_created $event) { global $CFG; if ($event->other['modulename'] === 'forum') { // Include the forum library to make use of the forum_instance_created function. require_once($CFG->dirroot . '/mod/forum/lib.php'); $forum = $event->get_record_snapshot('forum', $event->other['instanceid']); forum_instance_created($event->get_context(), $forum); } }
php
public static function course_module_created(\core\event\course_module_created $event) { global $CFG; if ($event->other['modulename'] === 'forum') { // Include the forum library to make use of the forum_instance_created function. require_once($CFG->dirroot . '/mod/forum/lib.php'); $forum = $event->get_record_snapshot('forum', $event->other['instanceid']); forum_instance_created($event->get_context(), $forum); } }
[ "public", "static", "function", "course_module_created", "(", "\\", "core", "\\", "event", "\\", "course_module_created", "$", "event", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "event", "->", "other", "[", "'modulename'", "]", "===", "'forum'", ")", "{", "// Include the forum library to make use of the forum_instance_created function.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/forum/lib.php'", ")", ";", "$", "forum", "=", "$", "event", "->", "get_record_snapshot", "(", "'forum'", ",", "$", "event", "->", "other", "[", "'instanceid'", "]", ")", ";", "forum_instance_created", "(", "$", "event", "->", "get_context", "(", ")", ",", "$", "forum", ")", ";", "}", "}" ]
Observer for \core\event\course_module_created event. @param \core\event\course_module_created $event @return void
[ "Observer", "for", "\\", "core", "\\", "event", "\\", "course_module_created", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/observer.php#L105-L115
212,952
moodle/moodle
mod/forum/classes/observer.php
mod_forum_observer.course_created
public static function course_created(\core\event\course_created $event) { global $CFG; $course = $event->get_record_snapshot('course', $event->objectid); $format = course_get_format($course); if ($format->supports_news() && !empty($course->newsitems)) { require_once($CFG->dirroot . '/mod/forum/lib.php'); // Auto create the announcements forum. forum_get_course_forum($event->objectid, 'news'); } }
php
public static function course_created(\core\event\course_created $event) { global $CFG; $course = $event->get_record_snapshot('course', $event->objectid); $format = course_get_format($course); if ($format->supports_news() && !empty($course->newsitems)) { require_once($CFG->dirroot . '/mod/forum/lib.php'); // Auto create the announcements forum. forum_get_course_forum($event->objectid, 'news'); } }
[ "public", "static", "function", "course_created", "(", "\\", "core", "\\", "event", "\\", "course_created", "$", "event", ")", "{", "global", "$", "CFG", ";", "$", "course", "=", "$", "event", "->", "get_record_snapshot", "(", "'course'", ",", "$", "event", "->", "objectid", ")", ";", "$", "format", "=", "course_get_format", "(", "$", "course", ")", ";", "if", "(", "$", "format", "->", "supports_news", "(", ")", "&&", "!", "empty", "(", "$", "course", "->", "newsitems", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/forum/lib.php'", ")", ";", "// Auto create the announcements forum.", "forum_get_course_forum", "(", "$", "event", "->", "objectid", ",", "'news'", ")", ";", "}", "}" ]
Observer for \core\event\course_created event. @param \core\event\course_created $event @return void
[ "Observer", "for", "\\", "core", "\\", "event", "\\", "course_created", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/observer.php#L123-L133
212,953
moodle/moodle
blocks/html/backup/moodle2/restore_html_block_task.class.php
restore_html_block_decode_content.get_iterator
protected function get_iterator() { global $DB; // Build the SQL dynamically here $fieldslist = 't.' . implode(', t.', $this->fields); $sql = "SELECT t.id, $fieldslist FROM {" . $this->tablename . "} t JOIN {backup_ids_temp} b ON b.newitemid = t.id WHERE b.backupid = ? AND b.itemname = ? AND t.blockname = 'html'"; $params = array($this->restoreid, $this->mapping); return ($DB->get_recordset_sql($sql, $params)); }
php
protected function get_iterator() { global $DB; // Build the SQL dynamically here $fieldslist = 't.' . implode(', t.', $this->fields); $sql = "SELECT t.id, $fieldslist FROM {" . $this->tablename . "} t JOIN {backup_ids_temp} b ON b.newitemid = t.id WHERE b.backupid = ? AND b.itemname = ? AND t.blockname = 'html'"; $params = array($this->restoreid, $this->mapping); return ($DB->get_recordset_sql($sql, $params)); }
[ "protected", "function", "get_iterator", "(", ")", "{", "global", "$", "DB", ";", "// Build the SQL dynamically here", "$", "fieldslist", "=", "'t.'", ".", "implode", "(", "', t.'", ",", "$", "this", "->", "fields", ")", ";", "$", "sql", "=", "\"SELECT t.id, $fieldslist\n FROM {\"", ".", "$", "this", "->", "tablename", ".", "\"} t\n JOIN {backup_ids_temp} b ON b.newitemid = t.id\n WHERE b.backupid = ?\n AND b.itemname = ?\n AND t.blockname = 'html'\"", ";", "$", "params", "=", "array", "(", "$", "this", "->", "restoreid", ",", "$", "this", "->", "mapping", ")", ";", "return", "(", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ")", ";", "}" ]
Temp storage for unserialized configdata
[ "Temp", "storage", "for", "unserialized", "configdata" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/html/backup/moodle2/restore_html_block_task.class.php#L69-L82
212,954
moodle/moodle
lib/authlib.php
auth_plugin_base.get_custom_user_profile_fields
public function get_custom_user_profile_fields() { global $DB; // If already retrieved then return. if (!is_null($this->customfields)) { return $this->customfields; } $this->customfields = array(); if ($proffields = $DB->get_records('user_info_field')) { foreach ($proffields as $proffield) { $this->customfields[] = 'profile_field_'.$proffield->shortname; } } unset($proffields); return $this->customfields; }
php
public function get_custom_user_profile_fields() { global $DB; // If already retrieved then return. if (!is_null($this->customfields)) { return $this->customfields; } $this->customfields = array(); if ($proffields = $DB->get_records('user_info_field')) { foreach ($proffields as $proffield) { $this->customfields[] = 'profile_field_'.$proffield->shortname; } } unset($proffields); return $this->customfields; }
[ "public", "function", "get_custom_user_profile_fields", "(", ")", "{", "global", "$", "DB", ";", "// If already retrieved then return.", "if", "(", "!", "is_null", "(", "$", "this", "->", "customfields", ")", ")", "{", "return", "$", "this", "->", "customfields", ";", "}", "$", "this", "->", "customfields", "=", "array", "(", ")", ";", "if", "(", "$", "proffields", "=", "$", "DB", "->", "get_records", "(", "'user_info_field'", ")", ")", "{", "foreach", "(", "$", "proffields", "as", "$", "proffield", ")", "{", "$", "this", "->", "customfields", "[", "]", "=", "'profile_field_'", ".", "$", "proffield", "->", "shortname", ";", "}", "}", "unset", "(", "$", "proffields", ")", ";", "return", "$", "this", "->", "customfields", ";", "}" ]
Return custom user profile fields. @return array list of custom fields.
[ "Return", "custom", "user", "profile", "fields", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/authlib.php#L600-L616
212,955
moodle/moodle
lib/authlib.php
auth_plugin_base.get_identity_providers
public static function get_identity_providers($authsequence) { global $SESSION; $identityproviders = []; foreach ($authsequence as $authname) { $authplugin = get_auth_plugin($authname); $wantsurl = (isset($SESSION->wantsurl)) ? $SESSION->wantsurl : ''; $identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($wantsurl)); } return $identityproviders; }
php
public static function get_identity_providers($authsequence) { global $SESSION; $identityproviders = []; foreach ($authsequence as $authname) { $authplugin = get_auth_plugin($authname); $wantsurl = (isset($SESSION->wantsurl)) ? $SESSION->wantsurl : ''; $identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($wantsurl)); } return $identityproviders; }
[ "public", "static", "function", "get_identity_providers", "(", "$", "authsequence", ")", "{", "global", "$", "SESSION", ";", "$", "identityproviders", "=", "[", "]", ";", "foreach", "(", "$", "authsequence", "as", "$", "authname", ")", "{", "$", "authplugin", "=", "get_auth_plugin", "(", "$", "authname", ")", ";", "$", "wantsurl", "=", "(", "isset", "(", "$", "SESSION", "->", "wantsurl", ")", ")", "?", "$", "SESSION", "->", "wantsurl", ":", "''", ";", "$", "identityproviders", "=", "array_merge", "(", "$", "identityproviders", ",", "$", "authplugin", "->", "loginpage_idp_list", "(", "$", "wantsurl", ")", ")", ";", "}", "return", "$", "identityproviders", ";", "}" ]
Return the list of enabled identity providers. Each identity provider data contains the keys url, name and iconurl (or icon). See the documentation of {@link auth_plugin_base::loginpage_idp_list()} for detailed description of the returned structure. @param array $authsequence site's auth sequence (list of auth plugins ordered) @return array List of arrays describing the identity providers
[ "Return", "the", "list", "of", "enabled", "identity", "providers", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/authlib.php#L724-L734
212,956
moodle/moodle
lib/authlib.php
auth_plugin_base.prepare_identity_providers_for_output
public static function prepare_identity_providers_for_output($identityproviders, renderer_base $output) { $data = []; foreach ($identityproviders as $idp) { if (!empty($idp['icon'])) { // Pre-3.3 auth plugins provide icon as a pix_icon instance. New auth plugins (since 3.3) provide iconurl. $idp['iconurl'] = $output->image_url($idp['icon']->pix, $idp['icon']->component); } if ($idp['iconurl'] instanceof moodle_url) { $idp['iconurl'] = $idp['iconurl']->out(false); } unset($idp['icon']); if ($idp['url'] instanceof moodle_url) { $idp['url'] = $idp['url']->out(false); } $data[] = $idp; } return $data; }
php
public static function prepare_identity_providers_for_output($identityproviders, renderer_base $output) { $data = []; foreach ($identityproviders as $idp) { if (!empty($idp['icon'])) { // Pre-3.3 auth plugins provide icon as a pix_icon instance. New auth plugins (since 3.3) provide iconurl. $idp['iconurl'] = $output->image_url($idp['icon']->pix, $idp['icon']->component); } if ($idp['iconurl'] instanceof moodle_url) { $idp['iconurl'] = $idp['iconurl']->out(false); } unset($idp['icon']); if ($idp['url'] instanceof moodle_url) { $idp['url'] = $idp['url']->out(false); } $data[] = $idp; } return $data; }
[ "public", "static", "function", "prepare_identity_providers_for_output", "(", "$", "identityproviders", ",", "renderer_base", "$", "output", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "identityproviders", "as", "$", "idp", ")", "{", "if", "(", "!", "empty", "(", "$", "idp", "[", "'icon'", "]", ")", ")", "{", "// Pre-3.3 auth plugins provide icon as a pix_icon instance. New auth plugins (since 3.3) provide iconurl.", "$", "idp", "[", "'iconurl'", "]", "=", "$", "output", "->", "image_url", "(", "$", "idp", "[", "'icon'", "]", "->", "pix", ",", "$", "idp", "[", "'icon'", "]", "->", "component", ")", ";", "}", "if", "(", "$", "idp", "[", "'iconurl'", "]", "instanceof", "moodle_url", ")", "{", "$", "idp", "[", "'iconurl'", "]", "=", "$", "idp", "[", "'iconurl'", "]", "->", "out", "(", "false", ")", ";", "}", "unset", "(", "$", "idp", "[", "'icon'", "]", ")", ";", "if", "(", "$", "idp", "[", "'url'", "]", "instanceof", "moodle_url", ")", "{", "$", "idp", "[", "'url'", "]", "=", "$", "idp", "[", "'url'", "]", "->", "out", "(", "false", ")", ";", "}", "$", "data", "[", "]", "=", "$", "idp", ";", "}", "return", "$", "data", ";", "}" ]
Prepare a list of identity providers for output. @param array $identityproviders as returned by {@link self::get_identity_providers()} @param renderer_base $output @return array the identity providers ready for output
[ "Prepare", "a", "list", "of", "identity", "providers", "for", "output", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/authlib.php#L743-L760
212,957
moodle/moodle
lib/authlib.php
auth_plugin_base.get_password_change_info
public function get_password_change_info(stdClass $user) : array { $site = get_site(); $systemcontext = context_system::instance(); $data = new stdClass(); $data->firstname = $user->firstname; $data->lastname = $user->lastname; $data->username = $user->username; $data->sitename = format_string($site->fullname); $data->admin = generate_email_signoff(); if ($this->can_change_password() and $this->change_password_url()) { // We have some external url for password changing. $data->link = $this->change_password_url(); } else { // No way to change password, sorry. $data->link = ''; } if (!empty($data->link) and has_capability('moodle/user:changeownpassword', $systemcontext, $user->id)) { $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname)); $message = get_string('emailpasswordchangeinfo', '', $data); } else { $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname)); $message = get_string('emailpasswordchangeinfofail', '', $data); } return [ 'subject' => $subject, 'message' => $message ]; }
php
public function get_password_change_info(stdClass $user) : array { $site = get_site(); $systemcontext = context_system::instance(); $data = new stdClass(); $data->firstname = $user->firstname; $data->lastname = $user->lastname; $data->username = $user->username; $data->sitename = format_string($site->fullname); $data->admin = generate_email_signoff(); if ($this->can_change_password() and $this->change_password_url()) { // We have some external url for password changing. $data->link = $this->change_password_url(); } else { // No way to change password, sorry. $data->link = ''; } if (!empty($data->link) and has_capability('moodle/user:changeownpassword', $systemcontext, $user->id)) { $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname)); $message = get_string('emailpasswordchangeinfo', '', $data); } else { $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname)); $message = get_string('emailpasswordchangeinfofail', '', $data); } return [ 'subject' => $subject, 'message' => $message ]; }
[ "public", "function", "get_password_change_info", "(", "stdClass", "$", "user", ")", ":", "array", "{", "$", "site", "=", "get_site", "(", ")", ";", "$", "systemcontext", "=", "context_system", "::", "instance", "(", ")", ";", "$", "data", "=", "new", "stdClass", "(", ")", ";", "$", "data", "->", "firstname", "=", "$", "user", "->", "firstname", ";", "$", "data", "->", "lastname", "=", "$", "user", "->", "lastname", ";", "$", "data", "->", "username", "=", "$", "user", "->", "username", ";", "$", "data", "->", "sitename", "=", "format_string", "(", "$", "site", "->", "fullname", ")", ";", "$", "data", "->", "admin", "=", "generate_email_signoff", "(", ")", ";", "if", "(", "$", "this", "->", "can_change_password", "(", ")", "and", "$", "this", "->", "change_password_url", "(", ")", ")", "{", "// We have some external url for password changing.", "$", "data", "->", "link", "=", "$", "this", "->", "change_password_url", "(", ")", ";", "}", "else", "{", "// No way to change password, sorry.", "$", "data", "->", "link", "=", "''", ";", "}", "if", "(", "!", "empty", "(", "$", "data", "->", "link", ")", "and", "has_capability", "(", "'moodle/user:changeownpassword'", ",", "$", "systemcontext", ",", "$", "user", "->", "id", ")", ")", "{", "$", "subject", "=", "get_string", "(", "'emailpasswordchangeinfosubject'", ",", "''", ",", "format_string", "(", "$", "site", "->", "fullname", ")", ")", ";", "$", "message", "=", "get_string", "(", "'emailpasswordchangeinfo'", ",", "''", ",", "$", "data", ")", ";", "}", "else", "{", "$", "subject", "=", "get_string", "(", "'emailpasswordchangeinfosubject'", ",", "''", ",", "format_string", "(", "$", "site", "->", "fullname", ")", ")", ";", "$", "message", "=", "get_string", "(", "'emailpasswordchangeinfofail'", ",", "''", ",", "$", "data", ")", ";", "}", "return", "[", "'subject'", "=>", "$", "subject", ",", "'message'", "=>", "$", "message", "]", ";", "}" ]
Returns information on how the specified user can change their password. @param stdClass $user A user object @return string[] An array of strings with keys subject and message
[ "Returns", "information", "on", "how", "the", "specified", "user", "can", "change", "their", "password", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/authlib.php#L768-L799
212,958
moodle/moodle
competency/classes/competency_rule_points.php
competency_rule_points.migrate_config
public static function migrate_config($config, $mappings) { $ruleconfig = json_decode($config, true); if (is_array($ruleconfig)) { foreach ($ruleconfig['competencies'] as $key => $rulecomp) { $rulecmpid = $rulecomp['id']; if (array_key_exists($rulecmpid, $mappings)) { $ruleconfig['competencies'][$key]['id'] = $mappings[$rulecmpid]->get('id'); } else { throw new coding_exception("The competency id is not found in the matchids."); } } } else { throw new coding_exception("Invalid JSON config rule."); } return json_encode($ruleconfig); }
php
public static function migrate_config($config, $mappings) { $ruleconfig = json_decode($config, true); if (is_array($ruleconfig)) { foreach ($ruleconfig['competencies'] as $key => $rulecomp) { $rulecmpid = $rulecomp['id']; if (array_key_exists($rulecmpid, $mappings)) { $ruleconfig['competencies'][$key]['id'] = $mappings[$rulecmpid]->get('id'); } else { throw new coding_exception("The competency id is not found in the matchids."); } } } else { throw new coding_exception("Invalid JSON config rule."); } return json_encode($ruleconfig); }
[ "public", "static", "function", "migrate_config", "(", "$", "config", ",", "$", "mappings", ")", "{", "$", "ruleconfig", "=", "json_decode", "(", "$", "config", ",", "true", ")", ";", "if", "(", "is_array", "(", "$", "ruleconfig", ")", ")", "{", "foreach", "(", "$", "ruleconfig", "[", "'competencies'", "]", "as", "$", "key", "=>", "$", "rulecomp", ")", "{", "$", "rulecmpid", "=", "$", "rulecomp", "[", "'id'", "]", ";", "if", "(", "array_key_exists", "(", "$", "rulecmpid", ",", "$", "mappings", ")", ")", "{", "$", "ruleconfig", "[", "'competencies'", "]", "[", "$", "key", "]", "[", "'id'", "]", "=", "$", "mappings", "[", "$", "rulecmpid", "]", "->", "get", "(", "'id'", ")", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "\"The competency id is not found in the matchids.\"", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "coding_exception", "(", "\"Invalid JSON config rule.\"", ")", ";", "}", "return", "json_encode", "(", "$", "ruleconfig", ")", ";", "}" ]
Migrate rule config when duplicate competency based on mapping competencies ids. @param string $config the config rule of a competency @param array $mappings array that match the old competency ids with the new competencies @return string
[ "Migrate", "rule", "config", "when", "duplicate", "competency", "based", "on", "mapping", "competencies", "ids", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/competency_rule_points.php#L201-L217
212,959
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getFullMsg
public function getFullMsg($stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_FULLMSG]) ? $this->_data[Horde_Imap_Client::FETCH_FULLMSG] : null ); }
php
public function getFullMsg($stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_FULLMSG]) ? $this->_data[Horde_Imap_Client::FETCH_FULLMSG] : null ); }
[ "public", "function", "getFullMsg", "(", "$", "stream", "=", "false", ")", "{", "return", "$", "this", "->", "_msgText", "(", "$", "stream", ",", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_FULLMSG", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_FULLMSG", "]", ":", "null", ")", ";", "}" ]
Returns the full message. @param boolean $stream Return as a stream? @return mixed The full text of the entire message.
[ "Returns", "the", "full", "message", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L62-L70
212,960
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getStructure
public function getStructure() { return isset($this->_data[Horde_Imap_Client::FETCH_STRUCTURE]) ? clone $this->_data[Horde_Imap_Client::FETCH_STRUCTURE] : new Horde_Mime_Part(); }
php
public function getStructure() { return isset($this->_data[Horde_Imap_Client::FETCH_STRUCTURE]) ? clone $this->_data[Horde_Imap_Client::FETCH_STRUCTURE] : new Horde_Mime_Part(); }
[ "public", "function", "getStructure", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_STRUCTURE", "]", ")", "?", "clone", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_STRUCTURE", "]", ":", "new", "Horde_Mime_Part", "(", ")", ";", "}" ]
Get the message structure. @return Horde_Mime_Part $structure The base MIME part of the message.
[ "Get", "the", "message", "structure", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L87-L92
212,961
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setHeaders
public function setHeaders($label, $data) { if ($data instanceof Horde_Stream) { $data = $data->stream; } $this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = $data; }
php
public function setHeaders($label, $data) { if ($data instanceof Horde_Stream) { $data = $data->stream; } $this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = $data; }
[ "public", "function", "setHeaders", "(", "$", "label", ",", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "Horde_Stream", ")", "{", "$", "data", "=", "$", "data", "->", "stream", ";", "}", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_HEADERS", "]", "[", "$", "label", "]", "=", "$", "data", ";", "}" ]
Set a header entry. @param string $label The search label. @param mixed $data Either a Horde_Mime_Headers object or the raw header text.
[ "Set", "a", "header", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L101-L107
212,962
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setHeaderText
public function setHeaderText($id, $text) { $this->_data[Horde_Imap_Client::FETCH_HEADERTEXT][$id] = $this->_setMixed($text); }
php
public function setHeaderText($id, $text) { $this->_data[Horde_Imap_Client::FETCH_HEADERTEXT][$id] = $this->_setMixed($text); }
[ "public", "function", "setHeaderText", "(", "$", "id", ",", "$", "text", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_HEADERTEXT", "]", "[", "$", "id", "]", "=", "$", "this", "->", "_setMixed", "(", "$", "text", ")", ";", "}" ]
Set a header text entry. @param string $id The MIME ID. @param mixed $text The header text, as either a string or stream resource.
[ "Set", "a", "header", "text", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L136-L139
212,963
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setMimeHeader
public function setMimeHeader($id, $text) { $this->_data[Horde_Imap_Client::FETCH_MIMEHEADER][$id] = $this->_setMixed($text); }
php
public function setMimeHeader($id, $text) { $this->_data[Horde_Imap_Client::FETCH_MIMEHEADER][$id] = $this->_setMixed($text); }
[ "public", "function", "setMimeHeader", "(", "$", "id", ",", "$", "text", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_MIMEHEADER", "]", "[", "$", "id", "]", "=", "$", "this", "->", "_setMixed", "(", "$", "text", ")", ";", "}" ]
Set a MIME header entry. @param string $id The MIME ID. @param mixed $text The header text, as either a string or stream resource.
[ "Set", "a", "MIME", "header", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L168-L171
212,964
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setBodyPart
public function setBodyPart($id, $text, $decode = null) { $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id] = array( 'd' => $decode, 't' => $this->_setMixed($text) ); }
php
public function setBodyPart($id, $text, $decode = null) { $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id] = array( 'd' => $decode, 't' => $this->_setMixed($text) ); }
[ "public", "function", "setBodyPart", "(", "$", "id", ",", "$", "text", ",", "$", "decode", "=", "null", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPART", "]", "[", "$", "id", "]", "=", "array", "(", "'d'", "=>", "$", "decode", ",", "'t'", "=>", "$", "this", "->", "_setMixed", "(", "$", "text", ")", ")", ";", "}" ]
Set a body part entry. @param string $id The MIME ID. @param mixed $text The body part text, as either a string or stream resource. @param string $decode Either '8bit', 'binary', or null.
[ "Set", "a", "body", "part", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L201-L207
212,965
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getBodyPart
public function getBodyPart($id, $stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]['t'] : null ); }
php
public function getBodyPart($id, $stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]['t'] : null ); }
[ "public", "function", "getBodyPart", "(", "$", "id", ",", "$", "stream", "=", "false", ")", "{", "return", "$", "this", "->", "_msgText", "(", "$", "stream", ",", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPART", "]", "[", "$", "id", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPART", "]", "[", "$", "id", "]", "[", "'t'", "]", ":", "null", ")", ";", "}" ]
Get a body part entry. @param string $id The MIME ID. @param boolean $stream Return as a stream? @return mixed The full text of the body part.
[ "Get", "a", "body", "part", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L217-L225
212,966
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setBodyPartSize
public function setBodyPartSize($id, $size) { $this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] = intval($size); }
php
public function setBodyPartSize($id, $size) { $this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] = intval($size); }
[ "public", "function", "setBodyPartSize", "(", "$", "id", ",", "$", "size", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPARTSIZE", "]", "[", "$", "id", "]", "=", "intval", "(", "$", "size", ")", ";", "}" ]
Set the body part size for a body part. @param string $id The MIME ID. @param integer $size The size (in bytes).
[ "Set", "the", "body", "part", "size", "for", "a", "body", "part", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L247-L250
212,967
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getBodyPartSize
public function getBodyPartSize($id) { return isset($this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] : null; }
php
public function getBodyPartSize($id) { return isset($this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] : null; }
[ "public", "function", "getBodyPartSize", "(", "$", "id", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPARTSIZE", "]", "[", "$", "id", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYPARTSIZE", "]", "[", "$", "id", "]", ":", "null", ";", "}" ]
Returns the body part size, if returned by the server. @param string $id The MIME ID. @return integer The body part size, in bytes.
[ "Returns", "the", "body", "part", "size", "if", "returned", "by", "the", "server", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L259-L264
212,968
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setBodyText
public function setBodyText($id, $text) { $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] = $this->_setMixed($text); }
php
public function setBodyText($id, $text) { $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] = $this->_setMixed($text); }
[ "public", "function", "setBodyText", "(", "$", "id", ",", "$", "text", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYTEXT", "]", "[", "$", "id", "]", "=", "$", "this", "->", "_setMixed", "(", "$", "text", ")", ";", "}" ]
Set a body text entry. @param string $id The MIME ID. @param mixed $text The body part text, as either a string or stream resource.
[ "Set", "a", "body", "text", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L273-L276
212,969
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getBodyText
public function getBodyText($id = 0, $stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] : null ); }
php
public function getBodyText($id = 0, $stream = false) { return $this->_msgText( $stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] : null ); }
[ "public", "function", "getBodyText", "(", "$", "id", "=", "0", ",", "$", "stream", "=", "false", ")", "{", "return", "$", "this", "->", "_msgText", "(", "$", "stream", ",", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYTEXT", "]", "[", "$", "id", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_BODYTEXT", "]", "[", "$", "id", "]", ":", "null", ")", ";", "}" ]
Get a body text entry. @param string $id The MIME ID. @param boolean $stream Return as a stream? @return mixed The full text of the body text.
[ "Get", "a", "body", "text", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L286-L294
212,970
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setEnvelope
public function setEnvelope($data) { $this->_data[Horde_Imap_Client::FETCH_ENVELOPE] = is_array($data) ? new Horde_Imap_Client_Data_Envelope($data) : $data; }
php
public function setEnvelope($data) { $this->_data[Horde_Imap_Client::FETCH_ENVELOPE] = is_array($data) ? new Horde_Imap_Client_Data_Envelope($data) : $data; }
[ "public", "function", "setEnvelope", "(", "$", "data", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_ENVELOPE", "]", "=", "is_array", "(", "$", "data", ")", "?", "new", "Horde_Imap_Client_Data_Envelope", "(", "$", "data", ")", ":", "$", "data", ";", "}" ]
Set envelope data. @param array $data The envelope data to pass to the Envelope object constructor, or an Envelope object.
[ "Set", "envelope", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L302-L307
212,971
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getEnvelope
public function getEnvelope() { return isset($this->_data[Horde_Imap_Client::FETCH_ENVELOPE]) ? clone $this->_data[Horde_Imap_Client::FETCH_ENVELOPE] : new Horde_Imap_Client_Data_Envelope(); }
php
public function getEnvelope() { return isset($this->_data[Horde_Imap_Client::FETCH_ENVELOPE]) ? clone $this->_data[Horde_Imap_Client::FETCH_ENVELOPE] : new Horde_Imap_Client_Data_Envelope(); }
[ "public", "function", "getEnvelope", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_ENVELOPE", "]", ")", "?", "clone", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_ENVELOPE", "]", ":", "new", "Horde_Imap_Client_Data_Envelope", "(", ")", ";", "}" ]
Get envelope data. @return Horde_Imap_Client_Data_Envelope An envelope object.
[ "Get", "envelope", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L314-L319
212,972
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getFlags
public function getFlags() { return isset($this->_data[Horde_Imap_Client::FETCH_FLAGS]) ? $this->_data[Horde_Imap_Client::FETCH_FLAGS] : array(); }
php
public function getFlags() { return isset($this->_data[Horde_Imap_Client::FETCH_FLAGS]) ? $this->_data[Horde_Imap_Client::FETCH_FLAGS] : array(); }
[ "public", "function", "getFlags", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_FLAGS", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_FLAGS", "]", ":", "array", "(", ")", ";", "}" ]
Get IMAP flags. @return array An array of IMAP flags (all flags in lowercase).
[ "Get", "IMAP", "flags", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L339-L344
212,973
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setImapDate
public function setImapDate($date) { $this->_data[Horde_Imap_Client::FETCH_IMAPDATE] = is_object($date) ? $date : new Horde_Imap_Client_DateTime($date); }
php
public function setImapDate($date) { $this->_data[Horde_Imap_Client::FETCH_IMAPDATE] = is_object($date) ? $date : new Horde_Imap_Client_DateTime($date); }
[ "public", "function", "setImapDate", "(", "$", "date", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_IMAPDATE", "]", "=", "is_object", "(", "$", "date", ")", "?", "$", "date", ":", "new", "Horde_Imap_Client_DateTime", "(", "$", "date", ")", ";", "}" ]
Set IMAP internal date. @param mixed $date Either a Horde_Imap_Client_DateTime object or a date string.
[ "Set", "IMAP", "internal", "date", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L352-L357
212,974
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getImapDate
public function getImapDate() { return isset($this->_data[Horde_Imap_Client::FETCH_IMAPDATE]) ? clone $this->_data[Horde_Imap_Client::FETCH_IMAPDATE] : new Horde_Imap_Client_DateTime(); }
php
public function getImapDate() { return isset($this->_data[Horde_Imap_Client::FETCH_IMAPDATE]) ? clone $this->_data[Horde_Imap_Client::FETCH_IMAPDATE] : new Horde_Imap_Client_DateTime(); }
[ "public", "function", "getImapDate", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_IMAPDATE", "]", ")", "?", "clone", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_IMAPDATE", "]", ":", "new", "Horde_Imap_Client_DateTime", "(", ")", ";", "}" ]
Get internal IMAP date. @return Horde_Imap_Client_DateTime A date object.
[ "Get", "internal", "IMAP", "date", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L364-L369
212,975
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getSize
public function getSize() { return isset($this->_data[Horde_Imap_Client::FETCH_SIZE]) ? $this->_data[Horde_Imap_Client::FETCH_SIZE] : 0; }
php
public function getSize() { return isset($this->_data[Horde_Imap_Client::FETCH_SIZE]) ? $this->_data[Horde_Imap_Client::FETCH_SIZE] : 0; }
[ "public", "function", "getSize", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_SIZE", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_SIZE", "]", ":", "0", ";", "}" ]
Get message size. @return integer The size of the message, in bytes.
[ "Get", "message", "size", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L386-L391
212,976
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getUid
public function getUid() { return isset($this->_data[Horde_Imap_Client::FETCH_UID]) ? $this->_data[Horde_Imap_Client::FETCH_UID] : null; }
php
public function getUid() { return isset($this->_data[Horde_Imap_Client::FETCH_UID]) ? $this->_data[Horde_Imap_Client::FETCH_UID] : null; }
[ "public", "function", "getUid", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_UID", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_UID", "]", ":", "null", ";", "}" ]
Get UID. @return integer The message UID.
[ "Get", "UID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L408-L413
212,977
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getSeq
public function getSeq() { return isset($this->_data[Horde_Imap_Client::FETCH_SEQ]) ? $this->_data[Horde_Imap_Client::FETCH_SEQ] : null; }
php
public function getSeq() { return isset($this->_data[Horde_Imap_Client::FETCH_SEQ]) ? $this->_data[Horde_Imap_Client::FETCH_SEQ] : null; }
[ "public", "function", "getSeq", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_SEQ", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_SEQ", "]", ":", "null", ";", "}" ]
Get message sequence number. @return integer The message sequence number.
[ "Get", "message", "sequence", "number", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L430-L435
212,978
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.getModSeq
public function getModSeq() { return isset($this->_data[Horde_Imap_Client::FETCH_MODSEQ]) ? $this->_data[Horde_Imap_Client::FETCH_MODSEQ] : null; }
php
public function getModSeq() { return isset($this->_data[Horde_Imap_Client::FETCH_MODSEQ]) ? $this->_data[Horde_Imap_Client::FETCH_MODSEQ] : null; }
[ "public", "function", "getModSeq", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_MODSEQ", "]", ")", "?", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_MODSEQ", "]", ":", "null", ";", "}" ]
Get the modified sequence value for the message. @return integer The modseq value.
[ "Get", "the", "modified", "sequence", "value", "for", "the", "message", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L452-L457
212,979
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.setDowngraded
public function setDowngraded($downgraded) { if ($downgraded) { $this->_data[Horde_Imap_Client::FETCH_DOWNGRADED] = true; } else { unset($this->_data[Horde_Imap_Client::FETCH_DOWNGRADED]); } }
php
public function setDowngraded($downgraded) { if ($downgraded) { $this->_data[Horde_Imap_Client::FETCH_DOWNGRADED] = true; } else { unset($this->_data[Horde_Imap_Client::FETCH_DOWNGRADED]); } }
[ "public", "function", "setDowngraded", "(", "$", "downgraded", ")", "{", "if", "(", "$", "downgraded", ")", "{", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_DOWNGRADED", "]", "=", "true", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "_data", "[", "Horde_Imap_Client", "::", "FETCH_DOWNGRADED", "]", ")", ";", "}", "}" ]
Set the internationalized downgraded status for the message. @since 2.11.0 @param boolean $downgraded True if at least one message component has been downgraded.
[ "Set", "the", "internationalized", "downgraded", "status", "for", "the", "message", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L467-L474
212,980
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch.merge
public function merge(Horde_Imap_Client_Data_Fetch $data) { $this->_data = array_replace_recursive( $this->_data, $data->getRawData() ); }
php
public function merge(Horde_Imap_Client_Data_Fetch $data) { $this->_data = array_replace_recursive( $this->_data, $data->getRawData() ); }
[ "public", "function", "merge", "(", "Horde_Imap_Client_Data_Fetch", "$", "data", ")", "{", "$", "this", "->", "_data", "=", "array_replace_recursive", "(", "$", "this", "->", "_data", ",", "$", "data", "->", "getRawData", "(", ")", ")", ";", "}" ]
Merge a fetch object into this one. @param Horde_Imap_Client_Data_Fetch $data A fetch object.
[ "Merge", "a", "fetch", "object", "into", "this", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L505-L511
212,981
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch._msgText
protected function _msgText($stream, $data) { if ($data instanceof Horde_Stream) { if ($stream) { $data->rewind(); return $data->stream; } return strval($data); } if (is_resource($data)) { rewind($data); return $stream ? $data : stream_get_contents($data); } if (!$stream) { return strval($data); } $tmp = fopen('php://temp', 'w+'); if (!is_null($data)) { fwrite($tmp, $data); rewind($tmp); } return $tmp; }
php
protected function _msgText($stream, $data) { if ($data instanceof Horde_Stream) { if ($stream) { $data->rewind(); return $data->stream; } return strval($data); } if (is_resource($data)) { rewind($data); return $stream ? $data : stream_get_contents($data); } if (!$stream) { return strval($data); } $tmp = fopen('php://temp', 'w+'); if (!is_null($data)) { fwrite($tmp, $data); rewind($tmp); } return $tmp; }
[ "protected", "function", "_msgText", "(", "$", "stream", ",", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "Horde_Stream", ")", "{", "if", "(", "$", "stream", ")", "{", "$", "data", "->", "rewind", "(", ")", ";", "return", "$", "data", "->", "stream", ";", "}", "return", "strval", "(", "$", "data", ")", ";", "}", "if", "(", "is_resource", "(", "$", "data", ")", ")", "{", "rewind", "(", "$", "data", ")", ";", "return", "$", "stream", "?", "$", "data", ":", "stream_get_contents", "(", "$", "data", ")", ";", "}", "if", "(", "!", "$", "stream", ")", "{", "return", "strval", "(", "$", "data", ")", ";", "}", "$", "tmp", "=", "fopen", "(", "'php://temp'", ",", "'w+'", ")", ";", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "fwrite", "(", "$", "tmp", ",", "$", "data", ")", ";", "rewind", "(", "$", "tmp", ")", ";", "}", "return", "$", "tmp", ";", "}" ]
Return text representation of a field. @param boolean $stream Return as a stream? @param mixed $data The field data (string or resource) or null if field does not exist. @return mixed Requested text representation.
[ "Return", "text", "representation", "of", "a", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L544-L573
212,982
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/Fetch.php
Horde_Imap_Client_Data_Fetch._getHeaders
protected function _getHeaders($id, $format, $key) { switch ($format) { case self::HEADER_STREAM: if (!isset($this->_data[$key][$id])) { $data = null; } elseif (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: $data = $this->_getHeaders($id, 0, $key); break; case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: $data = $this->_data[$key][$id]; break; } } else { $data = $this->_data[$key][$id]; } return $this->_msgText(true, $data); case self::HEADER_PARSE: if (!isset($this->_data[$key][$id])) { return new Horde_Mime_Headers(); } elseif (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: return clone $this->_data[$key][$id]; case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: $hdrs = $this->_data[$key][$id]; break; } } else { $hdrs = $this->_getHeaders($id, self::HEADER_STREAM, $key); } return Horde_Mime_Headers::parseHeaders($hdrs); } if (!isset($this->_data[$key][$id])) { return ''; } if (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: return $this->_data[$key][$id]->toString( array('nowrap' => true) ); case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: return strval($this->_data[$key][$id]); } } return $this->_msgText(false, $this->_data[$key][$id]); }
php
protected function _getHeaders($id, $format, $key) { switch ($format) { case self::HEADER_STREAM: if (!isset($this->_data[$key][$id])) { $data = null; } elseif (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: $data = $this->_getHeaders($id, 0, $key); break; case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: $data = $this->_data[$key][$id]; break; } } else { $data = $this->_data[$key][$id]; } return $this->_msgText(true, $data); case self::HEADER_PARSE: if (!isset($this->_data[$key][$id])) { return new Horde_Mime_Headers(); } elseif (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: return clone $this->_data[$key][$id]; case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: $hdrs = $this->_data[$key][$id]; break; } } else { $hdrs = $this->_getHeaders($id, self::HEADER_STREAM, $key); } return Horde_Mime_Headers::parseHeaders($hdrs); } if (!isset($this->_data[$key][$id])) { return ''; } if (is_object($this->_data[$key][$id])) { switch ($key) { case Horde_Imap_Client::FETCH_HEADERS: return $this->_data[$key][$id]->toString( array('nowrap' => true) ); case Horde_Imap_Client::FETCH_HEADERTEXT: case Horde_Imap_Client::FETCH_MIMEHEADER: return strval($this->_data[$key][$id]); } } return $this->_msgText(false, $this->_data[$key][$id]); }
[ "protected", "function", "_getHeaders", "(", "$", "id", ",", "$", "format", ",", "$", "key", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "self", "::", "HEADER_STREAM", ":", "if", "(", "!", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "$", "data", "=", "null", ";", "}", "elseif", "(", "is_object", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "Horde_Imap_Client", "::", "FETCH_HEADERS", ":", "$", "data", "=", "$", "this", "->", "_getHeaders", "(", "$", "id", ",", "0", ",", "$", "key", ")", ";", "break", ";", "case", "Horde_Imap_Client", "::", "FETCH_HEADERTEXT", ":", "case", "Horde_Imap_Client", "::", "FETCH_MIMEHEADER", ":", "$", "data", "=", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ";", "break", ";", "}", "}", "else", "{", "$", "data", "=", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ";", "}", "return", "$", "this", "->", "_msgText", "(", "true", ",", "$", "data", ")", ";", "case", "self", "::", "HEADER_PARSE", ":", "if", "(", "!", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "return", "new", "Horde_Mime_Headers", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "Horde_Imap_Client", "::", "FETCH_HEADERS", ":", "return", "clone", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ";", "case", "Horde_Imap_Client", "::", "FETCH_HEADERTEXT", ":", "case", "Horde_Imap_Client", "::", "FETCH_MIMEHEADER", ":", "$", "hdrs", "=", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ";", "break", ";", "}", "}", "else", "{", "$", "hdrs", "=", "$", "this", "->", "_getHeaders", "(", "$", "id", ",", "self", "::", "HEADER_STREAM", ",", "$", "key", ")", ";", "}", "return", "Horde_Mime_Headers", "::", "parseHeaders", "(", "$", "hdrs", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "return", "''", ";", "}", "if", "(", "is_object", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "Horde_Imap_Client", "::", "FETCH_HEADERS", ":", "return", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", "->", "toString", "(", "array", "(", "'nowrap'", "=>", "true", ")", ")", ";", "case", "Horde_Imap_Client", "::", "FETCH_HEADERTEXT", ":", "case", "Horde_Imap_Client", "::", "FETCH_MIMEHEADER", ":", "return", "strval", "(", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ";", "}", "}", "return", "$", "this", "->", "_msgText", "(", "false", ",", "$", "this", "->", "_data", "[", "$", "key", "]", "[", "$", "id", "]", ")", ";", "}" ]
Return representation of a header field. @param string $id The header id. @param integer $format The return format. If self::HEADER_PARSE, returns a Horde_Mime_Headers object. If self::HEADER_STREAM, returns a stream. Otherwise, returns header text. @param integer $key The array key where the data is stored in the internal array. @return mixed The data in the format specified by $format.
[ "Return", "representation", "of", "a", "header", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Fetch.php#L588-L649
212,983
moodle/moodle
lib/editor/tinymce/plugins/pdw/lib.php
tinymce_pdw.update_init_params
protected function update_init_params(array &$params, context $context, array $options = null) { $rowsnumber = $this->count_button_rows($params); if ($rowsnumber > 1) { $this->add_button_before($params, 1, 'pdw_toggle', ''); $params['pdw_toggle_on'] = 1; $params['pdw_toggle_toolbars'] = join(',', range(2, $rowsnumber)); // Add JS file, which uses default name. $this->add_js_plugin($params); } }
php
protected function update_init_params(array &$params, context $context, array $options = null) { $rowsnumber = $this->count_button_rows($params); if ($rowsnumber > 1) { $this->add_button_before($params, 1, 'pdw_toggle', ''); $params['pdw_toggle_on'] = 1; $params['pdw_toggle_toolbars'] = join(',', range(2, $rowsnumber)); // Add JS file, which uses default name. $this->add_js_plugin($params); } }
[ "protected", "function", "update_init_params", "(", "array", "&", "$", "params", ",", "context", "$", "context", ",", "array", "$", "options", "=", "null", ")", "{", "$", "rowsnumber", "=", "$", "this", "->", "count_button_rows", "(", "$", "params", ")", ";", "if", "(", "$", "rowsnumber", ">", "1", ")", "{", "$", "this", "->", "add_button_before", "(", "$", "params", ",", "1", ",", "'pdw_toggle'", ",", "''", ")", ";", "$", "params", "[", "'pdw_toggle_on'", "]", "=", "1", ";", "$", "params", "[", "'pdw_toggle_toolbars'", "]", "=", "join", "(", "','", ",", "range", "(", "2", ",", "$", "rowsnumber", ")", ")", ";", "// Add JS file, which uses default name.", "$", "this", "->", "add_js_plugin", "(", "$", "params", ")", ";", "}", "}" ]
Adds pdw toggle button if there are more than one row of buttons in TinyMCE @param array $params TinyMCE init parameters array @param context $context Context where editor is being shown @param array $options Options for this editor
[ "Adds", "pdw", "toggle", "button", "if", "there", "are", "more", "than", "one", "row", "of", "buttons", "in", "TinyMCE" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/editor/tinymce/plugins/pdw/lib.php#L34-L46
212,984
moodle/moodle
lib/odslib.class.php
MoodleODSWorkbook.add_worksheet
public function add_worksheet($name = '') { $ws = new MoodleODSWorksheet($name, $this->worksheets); $this->worksheets[] = $ws; return $ws; }
php
public function add_worksheet($name = '') { $ws = new MoodleODSWorksheet($name, $this->worksheets); $this->worksheets[] = $ws; return $ws; }
[ "public", "function", "add_worksheet", "(", "$", "name", "=", "''", ")", "{", "$", "ws", "=", "new", "MoodleODSWorksheet", "(", "$", "name", ",", "$", "this", "->", "worksheets", ")", ";", "$", "this", "->", "worksheets", "[", "]", "=", "$", "ws", ";", "return", "$", "ws", ";", "}" ]
Create one Moodle Worksheet. @param string $name Name of the sheet @return MoodleODSWorksheet
[ "Create", "one", "Moodle", "Worksheet", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L52-L56
212,985
moodle/moodle
lib/odslib.class.php
MoodleODSWorkbook.close
public function close() { global $CFG; require_once($CFG->libdir . '/filelib.php'); $writer = new MoodleODSWriter($this->worksheets); $contents = $writer->get_file_content(); send_file($contents, $this->filename, 0, 0, true, true, $writer->get_ods_mimetype()); }
php
public function close() { global $CFG; require_once($CFG->libdir . '/filelib.php'); $writer = new MoodleODSWriter($this->worksheets); $contents = $writer->get_file_content(); send_file($contents, $this->filename, 0, 0, true, true, $writer->get_ods_mimetype()); }
[ "public", "function", "close", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/filelib.php'", ")", ";", "$", "writer", "=", "new", "MoodleODSWriter", "(", "$", "this", "->", "worksheets", ")", ";", "$", "contents", "=", "$", "writer", "->", "get_file_content", "(", ")", ";", "send_file", "(", "$", "contents", ",", "$", "this", "->", "filename", ",", "0", ",", "0", ",", "true", ",", "true", ",", "$", "writer", "->", "get_ods_mimetype", "(", ")", ")", ";", "}" ]
Close the Moodle Workbook.
[ "Close", "the", "Moodle", "Workbook", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L74-L82
212,986
moodle/moodle
lib/odslib.class.php
MoodleODSWorksheet.write
public function write($row, $col, $token, $format = null) { // Analyse what are we trying to send. if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) { // Match number return $this->write_number($row, $col, $token, $format); } elseif (preg_match("/^[fh]tt?p:\/\//", $token)) { // Match http or ftp URL return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^mailto:/", $token)) { // Match mailto: return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^(?:in|ex)ternal:/", $token)) { // Match internal or external sheet link return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^=/", $token)) { // Match formula return $this->write_formula($row, $col, $token, $format); } elseif (preg_match("/^@/", $token)) { // Match formula return $this->write_formula($row, $col, $token, $format); } elseif ($token == '') { // Match blank return $this->write_blank($row, $col, $format); } else { // Default: match string return $this->write_string($row, $col, $token, $format); } }
php
public function write($row, $col, $token, $format = null) { // Analyse what are we trying to send. if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) { // Match number return $this->write_number($row, $col, $token, $format); } elseif (preg_match("/^[fh]tt?p:\/\//", $token)) { // Match http or ftp URL return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^mailto:/", $token)) { // Match mailto: return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^(?:in|ex)ternal:/", $token)) { // Match internal or external sheet link return $this->write_url($row, $col, $token, '', $format); } elseif (preg_match("/^=/", $token)) { // Match formula return $this->write_formula($row, $col, $token, $format); } elseif (preg_match("/^@/", $token)) { // Match formula return $this->write_formula($row, $col, $token, $format); } elseif ($token == '') { // Match blank return $this->write_blank($row, $col, $format); } else { // Default: match string return $this->write_string($row, $col, $token, $format); } }
[ "public", "function", "write", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "$", "format", "=", "null", ")", "{", "// Analyse what are we trying to send.", "if", "(", "preg_match", "(", "\"/^([+-]?)(?=\\d|\\.\\d)\\d*(\\.\\d*)?([Ee]([+-]?\\d+))?$/\"", ",", "$", "token", ")", ")", "{", "// Match number", "return", "$", "this", "->", "write_number", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "$", "format", ")", ";", "}", "elseif", "(", "preg_match", "(", "\"/^[fh]tt?p:\\/\\//\"", ",", "$", "token", ")", ")", "{", "// Match http or ftp URL", "return", "$", "this", "->", "write_url", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "''", ",", "$", "format", ")", ";", "}", "elseif", "(", "preg_match", "(", "\"/^mailto:/\"", ",", "$", "token", ")", ")", "{", "// Match mailto:", "return", "$", "this", "->", "write_url", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "''", ",", "$", "format", ")", ";", "}", "elseif", "(", "preg_match", "(", "\"/^(?:in|ex)ternal:/\"", ",", "$", "token", ")", ")", "{", "// Match internal or external sheet link", "return", "$", "this", "->", "write_url", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "''", ",", "$", "format", ")", ";", "}", "elseif", "(", "preg_match", "(", "\"/^=/\"", ",", "$", "token", ")", ")", "{", "// Match formula", "return", "$", "this", "->", "write_formula", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "$", "format", ")", ";", "}", "elseif", "(", "preg_match", "(", "\"/^@/\"", ",", "$", "token", ")", ")", "{", "// Match formula", "return", "$", "this", "->", "write_formula", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "$", "format", ")", ";", "}", "elseif", "(", "$", "token", "==", "''", ")", "{", "// Match blank", "return", "$", "this", "->", "write_blank", "(", "$", "row", ",", "$", "col", ",", "$", "format", ")", ";", "}", "else", "{", "// Default: match string", "return", "$", "this", "->", "write_string", "(", "$", "row", ",", "$", "col", ",", "$", "token", ",", "$", "format", ")", ";", "}", "}" ]
Write anything somewhere in the worksheet, type will be automatically detected. @param integer $row Zero indexed row @param integer $col Zero indexed column @param mixed $token What we are writing @param mixed $format The XF format for the cell
[ "Write", "anything", "somewhere", "in", "the", "worksheet", "type", "will", "be", "automatically", "detected", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L270-L297
212,987
moodle/moodle
lib/odslib.class.php
MoodleODSFormat.set_align
public function set_align($location) { if (in_array($location, array('left', 'centre', 'center', 'right', 'fill', 'merge', 'justify', 'equal_space'))) { $this->set_h_align($location); } else if (in_array($location, array('top', 'vcentre', 'vcenter', 'bottom', 'vjustify', 'vequal_space'))) { $this->set_v_align($location); } }
php
public function set_align($location) { if (in_array($location, array('left', 'centre', 'center', 'right', 'fill', 'merge', 'justify', 'equal_space'))) { $this->set_h_align($location); } else if (in_array($location, array('top', 'vcentre', 'vcenter', 'bottom', 'vjustify', 'vequal_space'))) { $this->set_v_align($location); } }
[ "public", "function", "set_align", "(", "$", "location", ")", "{", "if", "(", "in_array", "(", "$", "location", ",", "array", "(", "'left'", ",", "'centre'", ",", "'center'", ",", "'right'", ",", "'fill'", ",", "'merge'", ",", "'justify'", ",", "'equal_space'", ")", ")", ")", "{", "$", "this", "->", "set_h_align", "(", "$", "location", ")", ";", "}", "else", "if", "(", "in_array", "(", "$", "location", ",", "array", "(", "'top'", ",", "'vcentre'", ",", "'vcenter'", ",", "'bottom'", ",", "'vjustify'", ",", "'vequal_space'", ")", ")", ")", "{", "$", "this", "->", "set_v_align", "(", "$", "location", ")", ";", "}", "}" ]
Set the cell alignment of the format. @param string $location alignment for the cell ('left', 'right', 'justify', etc...)
[ "Set", "the", "cell", "alignment", "of", "the", "format", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L585-L592
212,988
moodle/moodle
lib/odslib.class.php
MoodleODSFormat.parse_color
protected function parse_color($color) { if (strpos($color, '#') === 0) { // No conversion should be needed. return $color; } if ($color > 7 and $color < 53) { $numbers = array( 8 => 'black', 12 => 'blue', 16 => 'brown', 15 => 'cyan', 23 => 'gray', 17 => 'green', 11 => 'lime', 14 => 'magenta', 18 => 'navy', 53 => 'orange', 33 => 'pink', 20 => 'purple', 10 => 'red', 22 => 'silver', 9 => 'white', 13 => 'yellow', ); if (isset($numbers[$color])) { $color = $numbers[$color]; } else { $color = 'black'; } } $colors = array( 'aqua' => '00FFFF', 'black' => '000000', 'blue' => '0000FF', 'brown' => 'A52A2A', 'cyan' => '00FFFF', 'fuchsia' => 'FF00FF', 'gray' => '808080', 'grey' => '808080', 'green' => '00FF00', 'lime' => '00FF00', 'magenta' => 'FF00FF', 'maroon' => '800000', 'navy' => '000080', 'orange' => 'FFA500', 'olive' => '808000', 'pink' => 'FAAFBE', 'purple' => '800080', 'red' => 'FF0000', 'silver' => 'C0C0C0', 'teal' => '008080', 'white' => 'FFFFFF', 'yellow' => 'FFFF00', ); if (isset($colors[$color])) { return('#'.$colors[$color]); } return('#'.$colors['black']); }
php
protected function parse_color($color) { if (strpos($color, '#') === 0) { // No conversion should be needed. return $color; } if ($color > 7 and $color < 53) { $numbers = array( 8 => 'black', 12 => 'blue', 16 => 'brown', 15 => 'cyan', 23 => 'gray', 17 => 'green', 11 => 'lime', 14 => 'magenta', 18 => 'navy', 53 => 'orange', 33 => 'pink', 20 => 'purple', 10 => 'red', 22 => 'silver', 9 => 'white', 13 => 'yellow', ); if (isset($numbers[$color])) { $color = $numbers[$color]; } else { $color = 'black'; } } $colors = array( 'aqua' => '00FFFF', 'black' => '000000', 'blue' => '0000FF', 'brown' => 'A52A2A', 'cyan' => '00FFFF', 'fuchsia' => 'FF00FF', 'gray' => '808080', 'grey' => '808080', 'green' => '00FF00', 'lime' => '00FF00', 'magenta' => 'FF00FF', 'maroon' => '800000', 'navy' => '000080', 'orange' => 'FFA500', 'olive' => '808000', 'pink' => 'FAAFBE', 'purple' => '800080', 'red' => 'FF0000', 'silver' => 'C0C0C0', 'teal' => '008080', 'white' => 'FFFFFF', 'yellow' => 'FFFF00', ); if (isset($colors[$color])) { return('#'.$colors[$color]); } return('#'.$colors['black']); }
[ "protected", "function", "parse_color", "(", "$", "color", ")", "{", "if", "(", "strpos", "(", "$", "color", ",", "'#'", ")", "===", "0", ")", "{", "// No conversion should be needed.", "return", "$", "color", ";", "}", "if", "(", "$", "color", ">", "7", "and", "$", "color", "<", "53", ")", "{", "$", "numbers", "=", "array", "(", "8", "=>", "'black'", ",", "12", "=>", "'blue'", ",", "16", "=>", "'brown'", ",", "15", "=>", "'cyan'", ",", "23", "=>", "'gray'", ",", "17", "=>", "'green'", ",", "11", "=>", "'lime'", ",", "14", "=>", "'magenta'", ",", "18", "=>", "'navy'", ",", "53", "=>", "'orange'", ",", "33", "=>", "'pink'", ",", "20", "=>", "'purple'", ",", "10", "=>", "'red'", ",", "22", "=>", "'silver'", ",", "9", "=>", "'white'", ",", "13", "=>", "'yellow'", ",", ")", ";", "if", "(", "isset", "(", "$", "numbers", "[", "$", "color", "]", ")", ")", "{", "$", "color", "=", "$", "numbers", "[", "$", "color", "]", ";", "}", "else", "{", "$", "color", "=", "'black'", ";", "}", "}", "$", "colors", "=", "array", "(", "'aqua'", "=>", "'00FFFF'", ",", "'black'", "=>", "'000000'", ",", "'blue'", "=>", "'0000FF'", ",", "'brown'", "=>", "'A52A2A'", ",", "'cyan'", "=>", "'00FFFF'", ",", "'fuchsia'", "=>", "'FF00FF'", ",", "'gray'", "=>", "'808080'", ",", "'grey'", "=>", "'808080'", ",", "'green'", "=>", "'00FF00'", ",", "'lime'", "=>", "'00FF00'", ",", "'magenta'", "=>", "'FF00FF'", ",", "'maroon'", "=>", "'800000'", ",", "'navy'", "=>", "'000080'", ",", "'orange'", "=>", "'FFA500'", ",", "'olive'", "=>", "'808000'", ",", "'pink'", "=>", "'FAAFBE'", ",", "'purple'", "=>", "'800080'", ",", "'red'", "=>", "'FF0000'", ",", "'silver'", "=>", "'C0C0C0'", ",", "'teal'", "=>", "'008080'", ",", "'white'", "=>", "'FFFFFF'", ",", "'yellow'", "=>", "'FFFF00'", ",", ")", ";", "if", "(", "isset", "(", "$", "colors", "[", "$", "color", "]", ")", ")", "{", "return", "(", "'#'", ".", "$", "colors", "[", "$", "color", "]", ")", ";", "}", "return", "(", "'#'", ".", "$", "colors", "[", "'black'", "]", ")", ";", "}" ]
Standardise colour name. @param mixed $color name of the color (i.e.: 'blue', 'red', etc..), or an integer (range is [8...63]). @return string the RGB color value
[ "Standardise", "colour", "name", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L751-L813
212,989
moodle/moodle
lib/odslib.class.php
MoodleODSWriter.get_file_content
public function get_file_content() { $dir = make_request_directory(); $filename = $dir . '/result.ods'; $files = [ 'mimetype' => [$this->get_ods_mimetype()], 'content.xml' => [$this->get_ods_content($this->worksheets)], 'meta.xml' => [$this->get_ods_meta()], 'styles.xml' => [$this->get_ods_styles()], 'settings.xml' => [$this->get_ods_settings()], 'META-INF/manifest.xml' => [$this->get_ods_manifest()], ]; $packer = get_file_packer('application/zip'); $packer->archive_to_pathname($files, $filename); $contents = file_get_contents($filename); remove_dir($dir); return $contents; }
php
public function get_file_content() { $dir = make_request_directory(); $filename = $dir . '/result.ods'; $files = [ 'mimetype' => [$this->get_ods_mimetype()], 'content.xml' => [$this->get_ods_content($this->worksheets)], 'meta.xml' => [$this->get_ods_meta()], 'styles.xml' => [$this->get_ods_styles()], 'settings.xml' => [$this->get_ods_settings()], 'META-INF/manifest.xml' => [$this->get_ods_manifest()], ]; $packer = get_file_packer('application/zip'); $packer->archive_to_pathname($files, $filename); $contents = file_get_contents($filename); remove_dir($dir); return $contents; }
[ "public", "function", "get_file_content", "(", ")", "{", "$", "dir", "=", "make_request_directory", "(", ")", ";", "$", "filename", "=", "$", "dir", ".", "'/result.ods'", ";", "$", "files", "=", "[", "'mimetype'", "=>", "[", "$", "this", "->", "get_ods_mimetype", "(", ")", "]", ",", "'content.xml'", "=>", "[", "$", "this", "->", "get_ods_content", "(", "$", "this", "->", "worksheets", ")", "]", ",", "'meta.xml'", "=>", "[", "$", "this", "->", "get_ods_meta", "(", ")", "]", ",", "'styles.xml'", "=>", "[", "$", "this", "->", "get_ods_styles", "(", ")", "]", ",", "'settings.xml'", "=>", "[", "$", "this", "->", "get_ods_settings", "(", ")", "]", ",", "'META-INF/manifest.xml'", "=>", "[", "$", "this", "->", "get_ods_manifest", "(", ")", "]", ",", "]", ";", "$", "packer", "=", "get_file_packer", "(", "'application/zip'", ")", ";", "$", "packer", "->", "archive_to_pathname", "(", "$", "files", ",", "$", "filename", ")", ";", "$", "contents", "=", "file_get_contents", "(", "$", "filename", ")", ";", "remove_dir", "(", "$", "dir", ")", ";", "return", "$", "contents", ";", "}" ]
Fetch the file ocntnet for the ODS. @return string
[ "Fetch", "the", "file", "ocntnet", "for", "the", "ODS", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/odslib.class.php#L836-L856
212,990
moodle/moodle
cache/stores/mongodb/MongoDB/Exception/InvalidArgumentException.php
InvalidArgumentException.invalidType
public static function invalidType($name, $value, $expectedType) { return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value))); }
php
public static function invalidType($name, $value, $expectedType) { return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value))); }
[ "public", "static", "function", "invalidType", "(", "$", "name", ",", "$", "value", ",", "$", "expectedType", ")", "{", "return", "new", "static", "(", "sprintf", "(", "'Expected %s to have type \"%s\" but found \"%s\"'", ",", "$", "name", ",", "$", "expectedType", ",", "is_object", "(", "$", "value", ")", "?", "get_class", "(", "$", "value", ")", ":", "gettype", "(", "$", "value", ")", ")", ")", ";", "}" ]
Thrown when an argument or option has an invalid type. @param string $name Name of the argument or option @param mixed $value Actual value (used to derive the type) @param string $expectedType Expected type @return self
[ "Thrown", "when", "an", "argument", "or", "option", "has", "an", "invalid", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Exception/InvalidArgumentException.php#L30-L33
212,991
moodle/moodle
mod/lesson/backup/moodle2/restore_lesson_stepslib.php
restore_lesson_activity_structure_step.process_lesson_override
protected function process_lesson_override($data) { global $DB; $data = (object)$data; $oldid = $data->id; // Based on userinfo, we'll restore user overides or no. $userinfo = $this->get_setting_value('userinfo'); // Skip user overrides if we are not restoring userinfo. if (!$userinfo && !is_null($data->userid)) { return; } $data->lessonid = $this->get_new_parentid('lesson'); if (!is_null($data->userid)) { $data->userid = $this->get_mappingid('user', $data->userid); } if (!is_null($data->groupid)) { $data->groupid = $this->get_mappingid('group', $data->groupid); } $data->available = $this->apply_date_offset($data->available); $data->deadline = $this->apply_date_offset($data->deadline); $newitemid = $DB->insert_record('lesson_overrides', $data); // Add mapping, restore of logs needs it. $this->set_mapping('lesson_override', $oldid, $newitemid); }
php
protected function process_lesson_override($data) { global $DB; $data = (object)$data; $oldid = $data->id; // Based on userinfo, we'll restore user overides or no. $userinfo = $this->get_setting_value('userinfo'); // Skip user overrides if we are not restoring userinfo. if (!$userinfo && !is_null($data->userid)) { return; } $data->lessonid = $this->get_new_parentid('lesson'); if (!is_null($data->userid)) { $data->userid = $this->get_mappingid('user', $data->userid); } if (!is_null($data->groupid)) { $data->groupid = $this->get_mappingid('group', $data->groupid); } $data->available = $this->apply_date_offset($data->available); $data->deadline = $this->apply_date_offset($data->deadline); $newitemid = $DB->insert_record('lesson_overrides', $data); // Add mapping, restore of logs needs it. $this->set_mapping('lesson_override', $oldid, $newitemid); }
[ "protected", "function", "process_lesson_override", "(", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "data", "=", "(", "object", ")", "$", "data", ";", "$", "oldid", "=", "$", "data", "->", "id", ";", "// Based on userinfo, we'll restore user overides or no.", "$", "userinfo", "=", "$", "this", "->", "get_setting_value", "(", "'userinfo'", ")", ";", "// Skip user overrides if we are not restoring userinfo.", "if", "(", "!", "$", "userinfo", "&&", "!", "is_null", "(", "$", "data", "->", "userid", ")", ")", "{", "return", ";", "}", "$", "data", "->", "lessonid", "=", "$", "this", "->", "get_new_parentid", "(", "'lesson'", ")", ";", "if", "(", "!", "is_null", "(", "$", "data", "->", "userid", ")", ")", "{", "$", "data", "->", "userid", "=", "$", "this", "->", "get_mappingid", "(", "'user'", ",", "$", "data", "->", "userid", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "data", "->", "groupid", ")", ")", "{", "$", "data", "->", "groupid", "=", "$", "this", "->", "get_mappingid", "(", "'group'", ",", "$", "data", "->", "groupid", ")", ";", "}", "$", "data", "->", "available", "=", "$", "this", "->", "apply_date_offset", "(", "$", "data", "->", "available", ")", ";", "$", "data", "->", "deadline", "=", "$", "this", "->", "apply_date_offset", "(", "$", "data", "->", "deadline", ")", ";", "$", "newitemid", "=", "$", "DB", "->", "insert_record", "(", "'lesson_overrides'", ",", "$", "data", ")", ";", "// Add mapping, restore of logs needs it.", "$", "this", "->", "set_mapping", "(", "'lesson_override'", ",", "$", "oldid", ",", "$", "newitemid", ")", ";", "}" ]
Process a lesson override restore @param object $data The data in object form @return void
[ "Process", "a", "lesson", "override", "restore" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/backup/moodle2/restore_lesson_stepslib.php#L200-L230
212,992
moodle/moodle
lib/dml/moodle_database.php
moodle_database.get_driver_instance
public static function get_driver_instance($type, $library, $external = false) { global $CFG; $classname = $type.'_'.$library.'_moodle_database'; $libfile = "$CFG->libdir/dml/$classname.php"; if (!file_exists($libfile)) { return null; } require_once($libfile); return new $classname($external); }
php
public static function get_driver_instance($type, $library, $external = false) { global $CFG; $classname = $type.'_'.$library.'_moodle_database'; $libfile = "$CFG->libdir/dml/$classname.php"; if (!file_exists($libfile)) { return null; } require_once($libfile); return new $classname($external); }
[ "public", "static", "function", "get_driver_instance", "(", "$", "type", ",", "$", "library", ",", "$", "external", "=", "false", ")", "{", "global", "$", "CFG", ";", "$", "classname", "=", "$", "type", ".", "'_'", ".", "$", "library", ".", "'_moodle_database'", ";", "$", "libfile", "=", "\"$CFG->libdir/dml/$classname.php\"", ";", "if", "(", "!", "file_exists", "(", "$", "libfile", ")", ")", "{", "return", "null", ";", "}", "require_once", "(", "$", "libfile", ")", ";", "return", "new", "$", "classname", "(", "$", "external", ")", ";", "}" ]
Loads and returns a database instance with the specified type and library. The loaded class is within lib/dml directory and of the form: $type.'_'.$library.'_moodle_database' @param string $type Database driver's type. (eg: mysqli, pgsql, mssql, sqldrv, oci, etc.) @param string $library Database driver's library (native, pdo, etc.) @param bool $external True if this is an external database. @return moodle_database driver object or null if error, for example of driver object see {@link mysqli_native_moodle_database}
[ "Loads", "and", "returns", "a", "database", "instance", "with", "the", "specified", "type", "and", "library", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L189-L201
212,993
moodle/moodle
lib/dml/moodle_database.php
moodle_database.export_dbconfig
public function export_dbconfig() { $cfg = new stdClass(); $cfg->dbtype = $this->get_dbtype(); $cfg->dblibrary = $this->get_dblibrary(); $cfg->dbhost = $this->dbhost; $cfg->dbname = $this->dbname; $cfg->dbuser = $this->dbuser; $cfg->dbpass = $this->dbpass; $cfg->prefix = $this->prefix; if ($this->dboptions) { $cfg->dboptions = $this->dboptions; } return $cfg; }
php
public function export_dbconfig() { $cfg = new stdClass(); $cfg->dbtype = $this->get_dbtype(); $cfg->dblibrary = $this->get_dblibrary(); $cfg->dbhost = $this->dbhost; $cfg->dbname = $this->dbname; $cfg->dbuser = $this->dbuser; $cfg->dbpass = $this->dbpass; $cfg->prefix = $this->prefix; if ($this->dboptions) { $cfg->dboptions = $this->dboptions; } return $cfg; }
[ "public", "function", "export_dbconfig", "(", ")", "{", "$", "cfg", "=", "new", "stdClass", "(", ")", ";", "$", "cfg", "->", "dbtype", "=", "$", "this", "->", "get_dbtype", "(", ")", ";", "$", "cfg", "->", "dblibrary", "=", "$", "this", "->", "get_dblibrary", "(", ")", ";", "$", "cfg", "->", "dbhost", "=", "$", "this", "->", "dbhost", ";", "$", "cfg", "->", "dbname", "=", "$", "this", "->", "dbname", ";", "$", "cfg", "->", "dbuser", "=", "$", "this", "->", "dbuser", ";", "$", "cfg", "->", "dbpass", "=", "$", "this", "->", "dbpass", ";", "$", "cfg", "->", "prefix", "=", "$", "this", "->", "prefix", ";", "if", "(", "$", "this", "->", "dboptions", ")", "{", "$", "cfg", "->", "dboptions", "=", "$", "this", "->", "dboptions", ";", "}", "return", "$", "cfg", ";", "}" ]
Returns the db related part of config.php @return stdClass
[ "Returns", "the", "db", "related", "part", "of", "config", ".", "php" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L262-L276
212,994
moodle/moodle
lib/dml/moodle_database.php
moodle_database.store_settings
protected function store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; $this->dbname = $dbname; $this->prefix = $prefix; $this->dboptions = (array)$dboptions; }
php
protected function store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; $this->dbname = $dbname; $this->prefix = $prefix; $this->dboptions = (array)$dboptions; }
[ "protected", "function", "store_settings", "(", "$", "dbhost", ",", "$", "dbuser", ",", "$", "dbpass", ",", "$", "dbname", ",", "$", "prefix", ",", "array", "$", "dboptions", "=", "null", ")", "{", "$", "this", "->", "dbhost", "=", "$", "dbhost", ";", "$", "this", "->", "dbuser", "=", "$", "dbuser", ";", "$", "this", "->", "dbpass", "=", "$", "dbpass", ";", "$", "this", "->", "dbname", "=", "$", "dbname", ";", "$", "this", "->", "prefix", "=", "$", "prefix", ";", "$", "this", "->", "dboptions", "=", "(", "array", ")", "$", "dboptions", ";", "}" ]
Store various database settings @param string $dbhost The database host. @param string $dbuser The database user to connect as. @param string $dbpass The password to use when connecting to the database. @param string $dbname The name of the database being connected to. @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used @param array $dboptions driver specific options @return void
[ "Store", "various", "database", "settings" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L312-L319
212,995
moodle/moodle
lib/dml/moodle_database.php
moodle_database.get_settings_hash
protected function get_settings_hash() { if (empty($this->settingshash)) { $this->settingshash = md5($this->dbhost . $this->dbuser . $this->dbname . $this->prefix); } return $this->settingshash; }
php
protected function get_settings_hash() { if (empty($this->settingshash)) { $this->settingshash = md5($this->dbhost . $this->dbuser . $this->dbname . $this->prefix); } return $this->settingshash; }
[ "protected", "function", "get_settings_hash", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "settingshash", ")", ")", "{", "$", "this", "->", "settingshash", "=", "md5", "(", "$", "this", "->", "dbhost", ".", "$", "this", "->", "dbuser", ".", "$", "this", "->", "dbname", ".", "$", "this", "->", "prefix", ")", ";", "}", "return", "$", "this", "->", "settingshash", ";", "}" ]
Returns a hash for the settings used during connection. If not already requested it is generated and stored in a private property. @return string
[ "Returns", "a", "hash", "for", "the", "settings", "used", "during", "connection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L328-L333
212,996
moodle/moodle
lib/dml/moodle_database.php
moodle_database.get_metacache
protected function get_metacache() { if (!isset($this->metacache)) { $properties = array('dbfamily' => $this->get_dbfamily(), 'settings' => $this->get_settings_hash()); $this->metacache = cache::make('core', 'databasemeta', $properties); } return $this->metacache; }
php
protected function get_metacache() { if (!isset($this->metacache)) { $properties = array('dbfamily' => $this->get_dbfamily(), 'settings' => $this->get_settings_hash()); $this->metacache = cache::make('core', 'databasemeta', $properties); } return $this->metacache; }
[ "protected", "function", "get_metacache", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "metacache", ")", ")", "{", "$", "properties", "=", "array", "(", "'dbfamily'", "=>", "$", "this", "->", "get_dbfamily", "(", ")", ",", "'settings'", "=>", "$", "this", "->", "get_settings_hash", "(", ")", ")", ";", "$", "this", "->", "metacache", "=", "cache", "::", "make", "(", "'core'", ",", "'databasemeta'", ",", "$", "properties", ")", ";", "}", "return", "$", "this", "->", "metacache", ";", "}" ]
Handle the creation and caching of the databasemeta information for all databases. @return cache_application The databasemeta cachestore to complete operations on.
[ "Handle", "the", "creation", "and", "caching", "of", "the", "databasemeta", "information", "for", "all", "databases", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L340-L346
212,997
moodle/moodle
lib/dml/moodle_database.php
moodle_database.get_temp_tables_cache
protected function get_temp_tables_cache() { if (!isset($this->metacachetemp)) { // Using connection data to prevent collisions when using the same temp table name with different db connections. $properties = array('dbfamily' => $this->get_dbfamily(), 'settings' => $this->get_settings_hash()); $this->metacachetemp = cache::make('core', 'temp_tables', $properties); } return $this->metacachetemp; }
php
protected function get_temp_tables_cache() { if (!isset($this->metacachetemp)) { // Using connection data to prevent collisions when using the same temp table name with different db connections. $properties = array('dbfamily' => $this->get_dbfamily(), 'settings' => $this->get_settings_hash()); $this->metacachetemp = cache::make('core', 'temp_tables', $properties); } return $this->metacachetemp; }
[ "protected", "function", "get_temp_tables_cache", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "metacachetemp", ")", ")", "{", "// Using connection data to prevent collisions when using the same temp table name with different db connections.", "$", "properties", "=", "array", "(", "'dbfamily'", "=>", "$", "this", "->", "get_dbfamily", "(", ")", ",", "'settings'", "=>", "$", "this", "->", "get_settings_hash", "(", ")", ")", ";", "$", "this", "->", "metacachetemp", "=", "cache", "::", "make", "(", "'core'", ",", "'temp_tables'", ",", "$", "properties", ")", ";", "}", "return", "$", "this", "->", "metacachetemp", ";", "}" ]
Handle the creation and caching of the temporary tables. @return cache_application The temp_tables cachestore to complete operations on.
[ "Handle", "the", "creation", "and", "caching", "of", "the", "temporary", "tables", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L353-L360
212,998
moodle/moodle
lib/dml/moodle_database.php
moodle_database.get_transaction_start_backtrace
public function get_transaction_start_backtrace() { if (!$this->transactions) { return null; } $lowesttransaction = end($this->transactions); return $lowesttransaction->get_backtrace(); }
php
public function get_transaction_start_backtrace() { if (!$this->transactions) { return null; } $lowesttransaction = end($this->transactions); return $lowesttransaction->get_backtrace(); }
[ "public", "function", "get_transaction_start_backtrace", "(", ")", "{", "if", "(", "!", "$", "this", "->", "transactions", ")", "{", "return", "null", ";", "}", "$", "lowesttransaction", "=", "end", "(", "$", "this", "->", "transactions", ")", ";", "return", "$", "lowesttransaction", "->", "get_backtrace", "(", ")", ";", "}" ]
Returns transaction trace for debugging purposes. @private to be used by core only @return array or null if not in transaction.
[ "Returns", "transaction", "trace", "for", "debugging", "purposes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L381-L387
212,999
moodle/moodle
lib/dml/moodle_database.php
moodle_database.query_start
protected function query_start($sql, array $params=null, $type, $extrainfo=null) { if ($this->loggingquery) { return; } $this->last_sql = $sql; $this->last_params = $params; $this->last_type = $type; $this->last_extrainfo = $extrainfo; $this->last_time = microtime(true); switch ($type) { case SQL_QUERY_SELECT: case SQL_QUERY_AUX: $this->reads++; break; case SQL_QUERY_INSERT: case SQL_QUERY_UPDATE: case SQL_QUERY_STRUCTURE: $this->writes++; default: if ((PHPUNIT_TEST) || (defined('BEHAT_TEST') && BEHAT_TEST) || defined('BEHAT_SITE_RUNNING')) { // Set list of tables that are updated. require_once(__DIR__.'/../testing/classes/util.php'); testing_util::set_table_modified_by_sql($sql); } } $this->print_debug($sql, $params); }
php
protected function query_start($sql, array $params=null, $type, $extrainfo=null) { if ($this->loggingquery) { return; } $this->last_sql = $sql; $this->last_params = $params; $this->last_type = $type; $this->last_extrainfo = $extrainfo; $this->last_time = microtime(true); switch ($type) { case SQL_QUERY_SELECT: case SQL_QUERY_AUX: $this->reads++; break; case SQL_QUERY_INSERT: case SQL_QUERY_UPDATE: case SQL_QUERY_STRUCTURE: $this->writes++; default: if ((PHPUNIT_TEST) || (defined('BEHAT_TEST') && BEHAT_TEST) || defined('BEHAT_SITE_RUNNING')) { // Set list of tables that are updated. require_once(__DIR__.'/../testing/classes/util.php'); testing_util::set_table_modified_by_sql($sql); } } $this->print_debug($sql, $params); }
[ "protected", "function", "query_start", "(", "$", "sql", ",", "array", "$", "params", "=", "null", ",", "$", "type", ",", "$", "extrainfo", "=", "null", ")", "{", "if", "(", "$", "this", "->", "loggingquery", ")", "{", "return", ";", "}", "$", "this", "->", "last_sql", "=", "$", "sql", ";", "$", "this", "->", "last_params", "=", "$", "params", ";", "$", "this", "->", "last_type", "=", "$", "type", ";", "$", "this", "->", "last_extrainfo", "=", "$", "extrainfo", ";", "$", "this", "->", "last_time", "=", "microtime", "(", "true", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "SQL_QUERY_SELECT", ":", "case", "SQL_QUERY_AUX", ":", "$", "this", "->", "reads", "++", ";", "break", ";", "case", "SQL_QUERY_INSERT", ":", "case", "SQL_QUERY_UPDATE", ":", "case", "SQL_QUERY_STRUCTURE", ":", "$", "this", "->", "writes", "++", ";", "default", ":", "if", "(", "(", "PHPUNIT_TEST", ")", "||", "(", "defined", "(", "'BEHAT_TEST'", ")", "&&", "BEHAT_TEST", ")", "||", "defined", "(", "'BEHAT_SITE_RUNNING'", ")", ")", "{", "// Set list of tables that are updated.", "require_once", "(", "__DIR__", ".", "'/../testing/classes/util.php'", ")", ";", "testing_util", "::", "set_table_modified_by_sql", "(", "$", "sql", ")", ";", "}", "}", "$", "this", "->", "print_debug", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
This should be called before each db query. @param string $sql The query string. @param array $params An array of parameters. @param int $type The type of query. ( SQL_QUERY_SELECT | SQL_QUERY_AUX | SQL_QUERY_INSERT | SQL_QUERY_UPDATE | SQL_QUERY_STRUCTURE ) @param mixed $extrainfo This is here for any driver specific extra information. @return void
[ "This", "should", "be", "called", "before", "each", "db", "query", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_database.php#L423-L453