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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
213,700 | moodle/moodle | mod/lesson/pagetypes/essay.php | lesson_page_type_essay.format_answer | public function format_answer($answer, $context, $answerformat, $options = []) {
$answer = file_rewrite_pluginfile_urls($answer, 'pluginfile.php', $context->id,
'mod_lesson', 'essay_answers', $options->attemptid);
return parent::format_answer($answer, $context, $answerformat, $options);
} | php | public function format_answer($answer, $context, $answerformat, $options = []) {
$answer = file_rewrite_pluginfile_urls($answer, 'pluginfile.php', $context->id,
'mod_lesson', 'essay_answers', $options->attemptid);
return parent::format_answer($answer, $context, $answerformat, $options);
} | [
"public",
"function",
"format_answer",
"(",
"$",
"answer",
",",
"$",
"context",
",",
"$",
"answerformat",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"answer",
"=",
"file_rewrite_pluginfile_urls",
"(",
"$",
"answer",
",",
"'pluginfile.php'",
",",
"$",
"context",
"->",
"id",
",",
"'mod_lesson'",
",",
"'essay_answers'",
",",
"$",
"options",
"->",
"attemptid",
")",
";",
"return",
"parent",
"::",
"format_answer",
"(",
"$",
"answer",
",",
"$",
"context",
",",
"$",
"answerformat",
",",
"$",
"options",
")",
";",
"}"
] | Custom formats the answer to display
@param string $answer
@param context $context
@param int $answerformat
@param array $options Optional param for additional options.
@return string Returns formatted string | [
"Custom",
"formats",
"the",
"answer",
"to",
"display"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/pagetypes/essay.php#L175-L179 |
213,701 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.addHeaders | public function addHeaders($headers = array())
{
foreach ($headers as $header => $value) {
$this->addHeader($header, $value);
}
} | php | public function addHeaders($headers = array())
{
foreach ($headers as $header => $value) {
$this->addHeader($header, $value);
}
} | [
"public",
"function",
"addHeaders",
"(",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Adds several message headers at once.
@param array $header Hash with header names as keys and header
contents as values.
@throws Horde_Mime_Exception | [
"Adds",
"several",
"message",
"headers",
"at",
"once",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L143-L148 |
213,702 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.addHeader | public function addHeader($header, $value, $overwrite = null)
{
$lc_header = Horde_String::lower($header);
if (is_null($overwrite) &&
in_array($lc_header, $this->_headers->singleFields(true))) {
$overwrite = true;
}
if ($overwrite) {
$this->_headers->removeHeader($header);
}
if ($lc_header === 'bcc') {
$this->_bcc = $value;
} else {
$this->_headers->addHeader($header, $value);
}
} | php | public function addHeader($header, $value, $overwrite = null)
{
$lc_header = Horde_String::lower($header);
if (is_null($overwrite) &&
in_array($lc_header, $this->_headers->singleFields(true))) {
$overwrite = true;
}
if ($overwrite) {
$this->_headers->removeHeader($header);
}
if ($lc_header === 'bcc') {
$this->_bcc = $value;
} else {
$this->_headers->addHeader($header, $value);
}
} | [
"public",
"function",
"addHeader",
"(",
"$",
"header",
",",
"$",
"value",
",",
"$",
"overwrite",
"=",
"null",
")",
"{",
"$",
"lc_header",
"=",
"Horde_String",
"::",
"lower",
"(",
"$",
"header",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"overwrite",
")",
"&&",
"in_array",
"(",
"$",
"lc_header",
",",
"$",
"this",
"->",
"_headers",
"->",
"singleFields",
"(",
"true",
")",
")",
")",
"{",
"$",
"overwrite",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"overwrite",
")",
"{",
"$",
"this",
"->",
"_headers",
"->",
"removeHeader",
"(",
"$",
"header",
")",
";",
"}",
"if",
"(",
"$",
"lc_header",
"===",
"'bcc'",
")",
"{",
"$",
"this",
"->",
"_bcc",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_headers",
"->",
"addHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Adds a message header.
@param string $header The header name.
@param string $value The header value.
@param boolean $overwrite If true, an existing header of the same name
is being overwritten; if false, multiple
headers are added; if null, the correct
behaviour is automatically chosen depending
on the header name.
@throws Horde_Mime_Exception | [
"Adds",
"a",
"message",
"header",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L163-L181 |
213,703 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.removeHeader | public function removeHeader($header)
{
if (Horde_String::lower($header) === 'bcc') {
unset($this->_bcc);
} else {
$this->_headers->removeHeader($header);
}
} | php | public function removeHeader($header)
{
if (Horde_String::lower($header) === 'bcc') {
unset($this->_bcc);
} else {
$this->_headers->removeHeader($header);
}
} | [
"public",
"function",
"removeHeader",
"(",
"$",
"header",
")",
"{",
"if",
"(",
"Horde_String",
"::",
"lower",
"(",
"$",
"header",
")",
"===",
"'bcc'",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_bcc",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_headers",
"->",
"removeHeader",
"(",
"$",
"header",
")",
";",
"}",
"}"
] | Removes a message header.
@param string $header The header name. | [
"Removes",
"a",
"message",
"header",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L202-L209 |
213,704 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.setBody | public function setBody($body, $charset = null, $wrap = false)
{
if (!$charset) {
$charset = $this->_charset;
}
$body = Horde_String::convertCharset($body, 'UTF-8', $charset);
if ($wrap) {
$body = Horde_String::wrap($body, $wrap === true ? 76 : $wrap);
}
$this->_body = new Horde_Mime_Part();
$this->_body->setType('text/plain');
$this->_body->setCharset($charset);
$this->_body->setContents($body);
$this->_base = null;
} | php | public function setBody($body, $charset = null, $wrap = false)
{
if (!$charset) {
$charset = $this->_charset;
}
$body = Horde_String::convertCharset($body, 'UTF-8', $charset);
if ($wrap) {
$body = Horde_String::wrap($body, $wrap === true ? 76 : $wrap);
}
$this->_body = new Horde_Mime_Part();
$this->_body->setType('text/plain');
$this->_body->setCharset($charset);
$this->_body->setContents($body);
$this->_base = null;
} | [
"public",
"function",
"setBody",
"(",
"$",
"body",
",",
"$",
"charset",
"=",
"null",
",",
"$",
"wrap",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"charset",
")",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"_charset",
";",
"}",
"$",
"body",
"=",
"Horde_String",
"::",
"convertCharset",
"(",
"$",
"body",
",",
"'UTF-8'",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"wrap",
")",
"{",
"$",
"body",
"=",
"Horde_String",
"::",
"wrap",
"(",
"$",
"body",
",",
"$",
"wrap",
"===",
"true",
"?",
"76",
":",
"$",
"wrap",
")",
";",
"}",
"$",
"this",
"->",
"_body",
"=",
"new",
"Horde_Mime_Part",
"(",
")",
";",
"$",
"this",
"->",
"_body",
"->",
"setType",
"(",
"'text/plain'",
")",
";",
"$",
"this",
"->",
"_body",
"->",
"setCharset",
"(",
"$",
"charset",
")",
";",
"$",
"this",
"->",
"_body",
"->",
"setContents",
"(",
"$",
"body",
")",
";",
"$",
"this",
"->",
"_base",
"=",
"null",
";",
"}"
] | Sets the message body text.
@param string $body The message content.
@param string $charset The character set of the message.
@param boolean|integer $wrap If true, wrap the message at column 76;
If an integer wrap the message at that
column. Don't use wrapping if sending
flowed messages. | [
"Sets",
"the",
"message",
"body",
"text",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L221-L235 |
213,705 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.setHtmlBody | public function setHtmlBody($body, $charset = null, $alternative = true)
{
if (!$charset) {
$charset = $this->_charset;
}
$this->_htmlBody = new Horde_Mime_Part();
$this->_htmlBody->setType('text/html');
$this->_htmlBody->setCharset($charset);
$this->_htmlBody->setContents($body);
if ($alternative) {
$this->setBody(Horde_Text_Filter::filter($body, 'Html2text', array('charset' => $charset, 'wrap' => false)), $charset);
}
$this->_base = null;
} | php | public function setHtmlBody($body, $charset = null, $alternative = true)
{
if (!$charset) {
$charset = $this->_charset;
}
$this->_htmlBody = new Horde_Mime_Part();
$this->_htmlBody->setType('text/html');
$this->_htmlBody->setCharset($charset);
$this->_htmlBody->setContents($body);
if ($alternative) {
$this->setBody(Horde_Text_Filter::filter($body, 'Html2text', array('charset' => $charset, 'wrap' => false)), $charset);
}
$this->_base = null;
} | [
"public",
"function",
"setHtmlBody",
"(",
"$",
"body",
",",
"$",
"charset",
"=",
"null",
",",
"$",
"alternative",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"charset",
")",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"_charset",
";",
"}",
"$",
"this",
"->",
"_htmlBody",
"=",
"new",
"Horde_Mime_Part",
"(",
")",
";",
"$",
"this",
"->",
"_htmlBody",
"->",
"setType",
"(",
"'text/html'",
")",
";",
"$",
"this",
"->",
"_htmlBody",
"->",
"setCharset",
"(",
"$",
"charset",
")",
";",
"$",
"this",
"->",
"_htmlBody",
"->",
"setContents",
"(",
"$",
"body",
")",
";",
"if",
"(",
"$",
"alternative",
")",
"{",
"$",
"this",
"->",
"setBody",
"(",
"Horde_Text_Filter",
"::",
"filter",
"(",
"$",
"body",
",",
"'Html2text'",
",",
"array",
"(",
"'charset'",
"=>",
"$",
"charset",
",",
"'wrap'",
"=>",
"false",
")",
")",
",",
"$",
"charset",
")",
";",
"}",
"$",
"this",
"->",
"_base",
"=",
"null",
";",
"}"
] | Sets the HTML message body text.
@param string $body The message content.
@param string $charset The character set of the message.
@param boolean $alternative If true, a multipart/alternative message is
created and the text/plain part is
generated automatically. If false, a
text/html message is generated. | [
"Sets",
"the",
"HTML",
"message",
"body",
"text",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L247-L260 |
213,706 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.addPart | public function addPart($mime_type, $content, $charset = 'us-ascii',
$disposition = null)
{
$part = new Horde_Mime_Part();
$part->setType($mime_type);
$part->setCharset($charset);
$part->setDisposition($disposition);
$part->setContents($content);
return $this->addMimePart($part);
} | php | public function addPart($mime_type, $content, $charset = 'us-ascii',
$disposition = null)
{
$part = new Horde_Mime_Part();
$part->setType($mime_type);
$part->setCharset($charset);
$part->setDisposition($disposition);
$part->setContents($content);
return $this->addMimePart($part);
} | [
"public",
"function",
"addPart",
"(",
"$",
"mime_type",
",",
"$",
"content",
",",
"$",
"charset",
"=",
"'us-ascii'",
",",
"$",
"disposition",
"=",
"null",
")",
"{",
"$",
"part",
"=",
"new",
"Horde_Mime_Part",
"(",
")",
";",
"$",
"part",
"->",
"setType",
"(",
"$",
"mime_type",
")",
";",
"$",
"part",
"->",
"setCharset",
"(",
"$",
"charset",
")",
";",
"$",
"part",
"->",
"setDisposition",
"(",
"$",
"disposition",
")",
";",
"$",
"part",
"->",
"setContents",
"(",
"$",
"content",
")",
";",
"return",
"$",
"this",
"->",
"addMimePart",
"(",
"$",
"part",
")",
";",
"}"
] | Adds a message part.
@param string $mime_type The content type of the part.
@param string $content The content of the part.
@param string $charset The character set of the part.
@param string $disposition The content disposition of the part.
@return integer The part number. | [
"Adds",
"a",
"message",
"part",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L272-L281 |
213,707 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.addAttachment | public function addAttachment($file, $name = null, $type = null,
$charset = 'us-ascii')
{
if (empty($name)) {
$name = basename($file);
}
if (empty($type)) {
$type = Horde_Mime_Magic::filenameToMime($file, false);
}
$num = $this->addPart($type, file_get_contents($file), $charset, 'attachment');
$this->_parts[$num]->setName($name);
return $num;
} | php | public function addAttachment($file, $name = null, $type = null,
$charset = 'us-ascii')
{
if (empty($name)) {
$name = basename($file);
}
if (empty($type)) {
$type = Horde_Mime_Magic::filenameToMime($file, false);
}
$num = $this->addPart($type, file_get_contents($file), $charset, 'attachment');
$this->_parts[$num]->setName($name);
return $num;
} | [
"public",
"function",
"addAttachment",
"(",
"$",
"file",
",",
"$",
"name",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"charset",
"=",
"'us-ascii'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"basename",
"(",
"$",
"file",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"Horde_Mime_Magic",
"::",
"filenameToMime",
"(",
"$",
"file",
",",
"false",
")",
";",
"}",
"$",
"num",
"=",
"$",
"this",
"->",
"addPart",
"(",
"$",
"type",
",",
"file_get_contents",
"(",
"$",
"file",
")",
",",
"$",
"charset",
",",
"'attachment'",
")",
";",
"$",
"this",
"->",
"_parts",
"[",
"$",
"num",
"]",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"return",
"$",
"num",
";",
"}"
] | Adds an attachment.
@param string $file The path to the file.
@param string $name The file name to use for the attachment.
@param string $type The content type of the file.
@param string $charset The character set of the part (only relevant for
text parts.
@return integer The part number. | [
"Adds",
"an",
"attachment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L320-L334 |
213,708 | moodle/moodle | lib/horde/framework/Horde/Mime/Mail.php | Horde_Mime_Mail.getRaw | public function getRaw($stream = true)
{
if ($stream) {
$hdr = new Horde_Stream();
$hdr->add($this->_headers->toString(), true);
return Horde_Stream_Wrapper_Combine::getStream(
array($hdr->stream,
$this->getBasePart()->toString(
array('stream' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY))
)
);
}
return $this->_headers->toString() . $this->getBasePart()->toString();
} | php | public function getRaw($stream = true)
{
if ($stream) {
$hdr = new Horde_Stream();
$hdr->add($this->_headers->toString(), true);
return Horde_Stream_Wrapper_Combine::getStream(
array($hdr->stream,
$this->getBasePart()->toString(
array('stream' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT | Horde_Mime_Part::ENCODE_8BIT | Horde_Mime_Part::ENCODE_BINARY))
)
);
}
return $this->_headers->toString() . $this->getBasePart()->toString();
} | [
"public",
"function",
"getRaw",
"(",
"$",
"stream",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"stream",
")",
"{",
"$",
"hdr",
"=",
"new",
"Horde_Stream",
"(",
")",
";",
"$",
"hdr",
"->",
"add",
"(",
"$",
"this",
"->",
"_headers",
"->",
"toString",
"(",
")",
",",
"true",
")",
";",
"return",
"Horde_Stream_Wrapper_Combine",
"::",
"getStream",
"(",
"array",
"(",
"$",
"hdr",
"->",
"stream",
",",
"$",
"this",
"->",
"getBasePart",
"(",
")",
"->",
"toString",
"(",
"array",
"(",
"'stream'",
"=>",
"true",
",",
"'encode'",
"=>",
"Horde_Mime_Part",
"::",
"ENCODE_7BIT",
"|",
"Horde_Mime_Part",
"::",
"ENCODE_8BIT",
"|",
"Horde_Mime_Part",
"::",
"ENCODE_BINARY",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_headers",
"->",
"toString",
"(",
")",
".",
"$",
"this",
"->",
"getBasePart",
"(",
")",
"->",
"toString",
"(",
")",
";",
"}"
] | Get the raw email data sent by this object.
@param boolean $stream If true, return a stream resource, otherwise
a string is returned.
@return stream|string The raw email data.
@since 2.4.0 | [
"Get",
"the",
"raw",
"email",
"data",
"sent",
"by",
"this",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Mail.php#L494-L508 |
213,709 | moodle/moodle | admin/tool/lp/classes/output/template_cohorts_table.php | template_cohorts_table.col_actions | protected function col_actions($row) {
global $OUTPUT;
$action = new \confirm_action(get_string('areyousure'));
$url = new moodle_url($this->baseurl);
$url->params(array('removecohort' => $row->id, 'sesskey' => sesskey()));
$actionlink = $OUTPUT->action_link($url, '', $action, null, new \pix_icon('t/delete',
get_string('stopsyncingcohort', 'tool_lp')));
return $actionlink;
} | php | protected function col_actions($row) {
global $OUTPUT;
$action = new \confirm_action(get_string('areyousure'));
$url = new moodle_url($this->baseurl);
$url->params(array('removecohort' => $row->id, 'sesskey' => sesskey()));
$actionlink = $OUTPUT->action_link($url, '', $action, null, new \pix_icon('t/delete',
get_string('stopsyncingcohort', 'tool_lp')));
return $actionlink;
} | [
"protected",
"function",
"col_actions",
"(",
"$",
"row",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"action",
"=",
"new",
"\\",
"confirm_action",
"(",
"get_string",
"(",
"'areyousure'",
")",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"this",
"->",
"baseurl",
")",
";",
"$",
"url",
"->",
"params",
"(",
"array",
"(",
"'removecohort'",
"=>",
"$",
"row",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"actionlink",
"=",
"$",
"OUTPUT",
"->",
"action_link",
"(",
"$",
"url",
",",
"''",
",",
"$",
"action",
",",
"null",
",",
"new",
"\\",
"pix_icon",
"(",
"'t/delete'",
",",
"get_string",
"(",
"'stopsyncingcohort'",
",",
"'tool_lp'",
")",
")",
")",
";",
"return",
"$",
"actionlink",
";",
"}"
] | Column actions.
@param object $row
@return string | [
"Column",
"actions",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/lp/classes/output/template_cohorts_table.php#L85-L96 |
213,710 | moodle/moodle | admin/tool/lp/classes/output/template_cohorts_table.php | template_cohorts_table.define_table_columns | protected function define_table_columns() {
// Define headers and columns.
$cols = array(
'name' => get_string('name', 'cohort'),
'idnumber' => get_string('idnumber', 'cohort'),
);
if ($this->template->can_manage()) {
$cols['actions'] = get_string('actions');
}
$this->define_columns(array_keys($cols));
$this->define_headers(array_values($cols));
} | php | protected function define_table_columns() {
// Define headers and columns.
$cols = array(
'name' => get_string('name', 'cohort'),
'idnumber' => get_string('idnumber', 'cohort'),
);
if ($this->template->can_manage()) {
$cols['actions'] = get_string('actions');
}
$this->define_columns(array_keys($cols));
$this->define_headers(array_values($cols));
} | [
"protected",
"function",
"define_table_columns",
"(",
")",
"{",
"// Define headers and columns.",
"$",
"cols",
"=",
"array",
"(",
"'name'",
"=>",
"get_string",
"(",
"'name'",
",",
"'cohort'",
")",
",",
"'idnumber'",
"=>",
"get_string",
"(",
"'idnumber'",
",",
"'cohort'",
")",
",",
")",
";",
"if",
"(",
"$",
"this",
"->",
"template",
"->",
"can_manage",
"(",
")",
")",
"{",
"$",
"cols",
"[",
"'actions'",
"]",
"=",
"get_string",
"(",
"'actions'",
")",
";",
"}",
"$",
"this",
"->",
"define_columns",
"(",
"array_keys",
"(",
"$",
"cols",
")",
")",
";",
"$",
"this",
"->",
"define_headers",
"(",
"array_values",
"(",
"$",
"cols",
")",
")",
";",
"}"
] | Setup the headers for the table. | [
"Setup",
"the",
"headers",
"for",
"the",
"table",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/lp/classes/output/template_cohorts_table.php#L101-L114 |
213,711 | moodle/moodle | admin/tool/lp/classes/output/template_cohorts_table.php | template_cohorts_table.query_db | public function query_db($pagesize, $useinitialsbar = true) {
global $DB;
list($countsql, $countparams) = $this->get_sql_and_params(true);
list($sql, $params) = $this->get_sql_and_params();
$total = $DB->count_records_sql($countsql, $countparams);
$this->pagesize($pagesize, $total);
$this->rawdata = $DB->get_records_sql($sql, $params, $this->get_page_start(), $this->get_page_size());
// Set initial bars.
if ($useinitialsbar) {
$this->initialbars($total > $pagesize);
}
} | php | public function query_db($pagesize, $useinitialsbar = true) {
global $DB;
list($countsql, $countparams) = $this->get_sql_and_params(true);
list($sql, $params) = $this->get_sql_and_params();
$total = $DB->count_records_sql($countsql, $countparams);
$this->pagesize($pagesize, $total);
$this->rawdata = $DB->get_records_sql($sql, $params, $this->get_page_start(), $this->get_page_size());
// Set initial bars.
if ($useinitialsbar) {
$this->initialbars($total > $pagesize);
}
} | [
"public",
"function",
"query_db",
"(",
"$",
"pagesize",
",",
"$",
"useinitialsbar",
"=",
"true",
")",
"{",
"global",
"$",
"DB",
";",
"list",
"(",
"$",
"countsql",
",",
"$",
"countparams",
")",
"=",
"$",
"this",
"->",
"get_sql_and_params",
"(",
"true",
")",
";",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"get_sql_and_params",
"(",
")",
";",
"$",
"total",
"=",
"$",
"DB",
"->",
"count_records_sql",
"(",
"$",
"countsql",
",",
"$",
"countparams",
")",
";",
"$",
"this",
"->",
"pagesize",
"(",
"$",
"pagesize",
",",
"$",
"total",
")",
";",
"$",
"this",
"->",
"rawdata",
"=",
"$",
"DB",
"->",
"get_records_sql",
"(",
"$",
"sql",
",",
"$",
"params",
",",
"$",
"this",
"->",
"get_page_start",
"(",
")",
",",
"$",
"this",
"->",
"get_page_size",
"(",
")",
")",
";",
"// Set initial bars.",
"if",
"(",
"$",
"useinitialsbar",
")",
"{",
"$",
"this",
"->",
"initialbars",
"(",
"$",
"total",
">",
"$",
"pagesize",
")",
";",
"}",
"}"
] | Query the DB.
@param int $pagesize size of page for paginated displayed table.
@param bool $useinitialsbar do you want to use the initials bar. | [
"Query",
"the",
"DB",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/lp/classes/output/template_cohorts_table.php#L171-L184 |
213,712 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Base/Debug.php | Horde_Imap_Client_Base_Debug._write | protected function _write($msg, $pre = null)
{
if (!$this->debug || !$this->_stream) {
return;
}
if (!is_null($pre)) {
$new_time = microtime(true);
if (is_null($this->_time)) {
fwrite(
$this->_stream,
str_repeat('-', 30) . "\n" . '>> ' . date('r') . "\n"
);
} elseif (($diff = ($new_time - $this->_time)) > self::SLOW_CMD) {
fwrite(
$this->_stream,
'>> Slow Command: ' . round($diff, 3) . " seconds\n"
);
}
$this->_time = $new_time;
}
fwrite($this->_stream, $pre . $msg);
} | php | protected function _write($msg, $pre = null)
{
if (!$this->debug || !$this->_stream) {
return;
}
if (!is_null($pre)) {
$new_time = microtime(true);
if (is_null($this->_time)) {
fwrite(
$this->_stream,
str_repeat('-', 30) . "\n" . '>> ' . date('r') . "\n"
);
} elseif (($diff = ($new_time - $this->_time)) > self::SLOW_CMD) {
fwrite(
$this->_stream,
'>> Slow Command: ' . round($diff, 3) . " seconds\n"
);
}
$this->_time = $new_time;
}
fwrite($this->_stream, $pre . $msg);
} | [
"protected",
"function",
"_write",
"(",
"$",
"msg",
",",
"$",
"pre",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"debug",
"||",
"!",
"$",
"this",
"->",
"_stream",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pre",
")",
")",
"{",
"$",
"new_time",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_time",
")",
")",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"_stream",
",",
"str_repeat",
"(",
"'-'",
",",
"30",
")",
".",
"\"\\n\"",
".",
"'>> '",
".",
"date",
"(",
"'r'",
")",
".",
"\"\\n\"",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"diff",
"=",
"(",
"$",
"new_time",
"-",
"$",
"this",
"->",
"_time",
")",
")",
">",
"self",
"::",
"SLOW_CMD",
")",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"_stream",
",",
"'>> Slow Command: '",
".",
"round",
"(",
"$",
"diff",
",",
"3",
")",
".",
"\" seconds\\n\"",
")",
";",
"}",
"$",
"this",
"->",
"_time",
"=",
"$",
"new_time",
";",
"}",
"fwrite",
"(",
"$",
"this",
"->",
"_stream",
",",
"$",
"pre",
".",
"$",
"msg",
")",
";",
"}"
] | Write debug information to the output stream.
@param string $msg Debug data. | [
"Write",
"debug",
"information",
"to",
"the",
"output",
"stream",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Base/Debug.php#L125-L150 |
213,713 | moodle/moodle | repository/skydrive/lib.php | repository_skydrive.print_login | public function print_login() {
$url = $this->skydrive->get_login_url();
if ($this->options['ajax']) {
$popup = new stdClass();
$popup->type = 'popup';
$popup->url = $url->out(false);
return array('login' => array($popup));
} else {
echo '<a target="_blank" href="'.$url->out(false).'">'.get_string('login', 'repository').'</a>';
}
} | php | public function print_login() {
$url = $this->skydrive->get_login_url();
if ($this->options['ajax']) {
$popup = new stdClass();
$popup->type = 'popup';
$popup->url = $url->out(false);
return array('login' => array($popup));
} else {
echo '<a target="_blank" href="'.$url->out(false).'">'.get_string('login', 'repository').'</a>';
}
} | [
"public",
"function",
"print_login",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"skydrive",
"->",
"get_login_url",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'ajax'",
"]",
")",
"{",
"$",
"popup",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"popup",
"->",
"type",
"=",
"'popup'",
";",
"$",
"popup",
"->",
"url",
"=",
"$",
"url",
"->",
"out",
"(",
"false",
")",
";",
"return",
"array",
"(",
"'login'",
"=>",
"array",
"(",
"$",
"popup",
")",
")",
";",
"}",
"else",
"{",
"echo",
"'<a target=\"_blank\" href=\"'",
".",
"$",
"url",
"->",
"out",
"(",
"false",
")",
".",
"'\">'",
".",
"get_string",
"(",
"'login'",
",",
"'repository'",
")",
".",
"'</a>'",
";",
"}",
"}"
] | Print the login form, if required
@return array of login options | [
"Print",
"the",
"login",
"form",
"if",
"required"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/skydrive/lib.php#L77-L88 |
213,714 | moodle/moodle | repository/skydrive/lib.php | repository_skydrive.get_listing | public function get_listing($path='', $page = '') {
$ret = array();
$ret['dynload'] = true;
$ret['nosearch'] = true;
$ret['manage'] = 'https://skydrive.live.com/';
$fileslist = $this->skydrive->get_file_list($path);
// Filter list for accepted types. Hopefully this will be done by core some day.
$fileslist = array_filter($fileslist, array($this, 'filter'));
$ret['list'] = $fileslist;
// Generate path bar, always start with the plugin name.
$ret['path'] = array();
$ret['path'][] = array('name'=> $this->name, 'path'=>'');
// Now add each level folder.
$trail = '';
if (!empty($path)) {
$parts = explode('/', $path);
foreach ($parts as $folderid) {
if (!empty($folderid)) {
$trail .= ('/'.$folderid);
$ret['path'][] = array('name' => $this->skydrive->get_folder_name($folderid),
'path' => $trail);
}
}
}
return $ret;
} | php | public function get_listing($path='', $page = '') {
$ret = array();
$ret['dynload'] = true;
$ret['nosearch'] = true;
$ret['manage'] = 'https://skydrive.live.com/';
$fileslist = $this->skydrive->get_file_list($path);
// Filter list for accepted types. Hopefully this will be done by core some day.
$fileslist = array_filter($fileslist, array($this, 'filter'));
$ret['list'] = $fileslist;
// Generate path bar, always start with the plugin name.
$ret['path'] = array();
$ret['path'][] = array('name'=> $this->name, 'path'=>'');
// Now add each level folder.
$trail = '';
if (!empty($path)) {
$parts = explode('/', $path);
foreach ($parts as $folderid) {
if (!empty($folderid)) {
$trail .= ('/'.$folderid);
$ret['path'][] = array('name' => $this->skydrive->get_folder_name($folderid),
'path' => $trail);
}
}
}
return $ret;
} | [
"public",
"function",
"get_listing",
"(",
"$",
"path",
"=",
"''",
",",
"$",
"page",
"=",
"''",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"ret",
"[",
"'dynload'",
"]",
"=",
"true",
";",
"$",
"ret",
"[",
"'nosearch'",
"]",
"=",
"true",
";",
"$",
"ret",
"[",
"'manage'",
"]",
"=",
"'https://skydrive.live.com/'",
";",
"$",
"fileslist",
"=",
"$",
"this",
"->",
"skydrive",
"->",
"get_file_list",
"(",
"$",
"path",
")",
";",
"// Filter list for accepted types. Hopefully this will be done by core some day.",
"$",
"fileslist",
"=",
"array_filter",
"(",
"$",
"fileslist",
",",
"array",
"(",
"$",
"this",
",",
"'filter'",
")",
")",
";",
"$",
"ret",
"[",
"'list'",
"]",
"=",
"$",
"fileslist",
";",
"// Generate path bar, always start with the plugin name.",
"$",
"ret",
"[",
"'path'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"ret",
"[",
"'path'",
"]",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'path'",
"=>",
"''",
")",
";",
"// Now add each level folder.",
"$",
"trail",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"folderid",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"folderid",
")",
")",
"{",
"$",
"trail",
".=",
"(",
"'/'",
".",
"$",
"folderid",
")",
";",
"$",
"ret",
"[",
"'path'",
"]",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"skydrive",
"->",
"get_folder_name",
"(",
"$",
"folderid",
")",
",",
"'path'",
"=>",
"$",
"trail",
")",
";",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Given a path, and perhaps a search, get a list of files.
See details on {@link http://docs.moodle.org/dev/Repository_plugins}
@param string $path identifier for current path
@param string $page the page number of file list
@return array list of files including meta information as specified by parent. | [
"Given",
"a",
"path",
"and",
"perhaps",
"a",
"search",
"get",
"a",
"list",
"of",
"files",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/skydrive/lib.php#L99-L128 |
213,715 | moodle/moodle | repository/skydrive/lib.php | repository_skydrive.type_config_form | public static function type_config_form($mform, $classname = 'repository') {
global $OUTPUT;
$a = new stdClass;
$a->callbackurl = microsoft_skydrive::callback_url()->out(false);
$mform->addElement('static', null, '', get_string('oauthinfo', 'repository_skydrive', $a));
$mform->addElement('static', null, '', $OUTPUT->notification(get_string('deprecatedwarning', 'repository_skydrive', $a)));
parent::type_config_form($mform);
$strrequired = get_string('required');
$mform->addElement('text', 'clientid', get_string('clientid', 'repository_skydrive'));
$mform->addElement('text', 'secret', get_string('secret', 'repository_skydrive'));
$mform->addRule('clientid', $strrequired, 'required', null, 'client');
$mform->addRule('secret', $strrequired, 'required', null, 'client');
$mform->setType('clientid', PARAM_RAW_TRIMMED);
$mform->setType('secret', PARAM_RAW_TRIMMED);
} | php | public static function type_config_form($mform, $classname = 'repository') {
global $OUTPUT;
$a = new stdClass;
$a->callbackurl = microsoft_skydrive::callback_url()->out(false);
$mform->addElement('static', null, '', get_string('oauthinfo', 'repository_skydrive', $a));
$mform->addElement('static', null, '', $OUTPUT->notification(get_string('deprecatedwarning', 'repository_skydrive', $a)));
parent::type_config_form($mform);
$strrequired = get_string('required');
$mform->addElement('text', 'clientid', get_string('clientid', 'repository_skydrive'));
$mform->addElement('text', 'secret', get_string('secret', 'repository_skydrive'));
$mform->addRule('clientid', $strrequired, 'required', null, 'client');
$mform->addRule('secret', $strrequired, 'required', null, 'client');
$mform->setType('clientid', PARAM_RAW_TRIMMED);
$mform->setType('secret', PARAM_RAW_TRIMMED);
} | [
"public",
"static",
"function",
"type_config_form",
"(",
"$",
"mform",
",",
"$",
"classname",
"=",
"'repository'",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"a",
"=",
"new",
"stdClass",
";",
"$",
"a",
"->",
"callbackurl",
"=",
"microsoft_skydrive",
"::",
"callback_url",
"(",
")",
"->",
"out",
"(",
"false",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'static'",
",",
"null",
",",
"''",
",",
"get_string",
"(",
"'oauthinfo'",
",",
"'repository_skydrive'",
",",
"$",
"a",
")",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'static'",
",",
"null",
",",
"''",
",",
"$",
"OUTPUT",
"->",
"notification",
"(",
"get_string",
"(",
"'deprecatedwarning'",
",",
"'repository_skydrive'",
",",
"$",
"a",
")",
")",
")",
";",
"parent",
"::",
"type_config_form",
"(",
"$",
"mform",
")",
";",
"$",
"strrequired",
"=",
"get_string",
"(",
"'required'",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'text'",
",",
"'clientid'",
",",
"get_string",
"(",
"'clientid'",
",",
"'repository_skydrive'",
")",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'text'",
",",
"'secret'",
",",
"get_string",
"(",
"'secret'",
",",
"'repository_skydrive'",
")",
")",
";",
"$",
"mform",
"->",
"addRule",
"(",
"'clientid'",
",",
"$",
"strrequired",
",",
"'required'",
",",
"null",
",",
"'client'",
")",
";",
"$",
"mform",
"->",
"addRule",
"(",
"'secret'",
",",
"$",
"strrequired",
",",
"'required'",
",",
"null",
",",
"'client'",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"'clientid'",
",",
"PARAM_RAW_TRIMMED",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"'secret'",
",",
"PARAM_RAW_TRIMMED",
")",
";",
"}"
] | Setup repistory form.
@param moodleform $mform Moodle form (passed by reference)
@param string $classname repository class name | [
"Setup",
"repistory",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/skydrive/lib.php#L159-L176 |
213,716 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_badge_table_actions | public function print_badge_table_actions($badge, $context) {
$actions = "";
if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
// Activate/deactivate badge.
if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
// "Activate" will go to another page and ask for confirmation.
$url = new moodle_url('/badges/action.php');
$url->param('id', $badge->id);
$url->param('activate', true);
$url->param('sesskey', sesskey());
$return = new moodle_url(qualified_me());
$url->param('return', $return->out_as_local_url(false));
$actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " ";
} else {
$url = new moodle_url(qualified_me());
$url->param('lock', $badge->id);
$url->param('sesskey', sesskey());
$actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " ";
}
}
// Award badge manually.
if ($badge->has_manual_award_criteria() &&
has_capability('moodle/badges:awardbadge', $context) &&
$badge->is_active()) {
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
$actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " ";
}
// Edit badge.
if (has_capability('moodle/badges:configuredetails', $context)) {
$url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'details'));
$actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " ";
}
// Duplicate badge.
if (has_capability('moodle/badges:createbadge', $context)) {
$url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
$actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " ";
}
// Delete badge.
if (has_capability('moodle/badges:deletebadge', $context)) {
$url = new moodle_url(qualified_me());
$url->param('delete', $badge->id);
$actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " ";
}
return $actions;
} | php | public function print_badge_table_actions($badge, $context) {
$actions = "";
if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
// Activate/deactivate badge.
if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
// "Activate" will go to another page and ask for confirmation.
$url = new moodle_url('/badges/action.php');
$url->param('id', $badge->id);
$url->param('activate', true);
$url->param('sesskey', sesskey());
$return = new moodle_url(qualified_me());
$url->param('return', $return->out_as_local_url(false));
$actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " ";
} else {
$url = new moodle_url(qualified_me());
$url->param('lock', $badge->id);
$url->param('sesskey', sesskey());
$actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " ";
}
}
// Award badge manually.
if ($badge->has_manual_award_criteria() &&
has_capability('moodle/badges:awardbadge', $context) &&
$badge->is_active()) {
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
$actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " ";
}
// Edit badge.
if (has_capability('moodle/badges:configuredetails', $context)) {
$url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'details'));
$actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " ";
}
// Duplicate badge.
if (has_capability('moodle/badges:createbadge', $context)) {
$url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
$actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " ";
}
// Delete badge.
if (has_capability('moodle/badges:deletebadge', $context)) {
$url = new moodle_url(qualified_me());
$url->param('delete', $badge->id);
$actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " ";
}
return $actions;
} | [
"public",
"function",
"print_badge_table_actions",
"(",
"$",
"badge",
",",
"$",
"context",
")",
"{",
"$",
"actions",
"=",
"\"\"",
";",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:configuredetails'",
",",
"$",
"context",
")",
"&&",
"$",
"badge",
"->",
"has_criteria",
"(",
")",
")",
"{",
"// Activate/deactivate badge.",
"if",
"(",
"$",
"badge",
"->",
"status",
"==",
"BADGE_STATUS_INACTIVE",
"||",
"$",
"badge",
"->",
"status",
"==",
"BADGE_STATUS_INACTIVE_LOCKED",
")",
"{",
"// \"Activate\" will go to another page and ask for confirmation.",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/badges/action.php'",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'id'",
",",
"$",
"badge",
"->",
"id",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'activate'",
",",
"true",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'sesskey'",
",",
"sesskey",
"(",
")",
")",
";",
"$",
"return",
"=",
"new",
"moodle_url",
"(",
"qualified_me",
"(",
")",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'return'",
",",
"$",
"return",
"->",
"out_as_local_url",
"(",
"false",
")",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/show'",
",",
"get_string",
"(",
"'activate'",
",",
"'badges'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"qualified_me",
"(",
")",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'lock'",
",",
"$",
"badge",
"->",
"id",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'sesskey'",
",",
"sesskey",
"(",
")",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/hide'",
",",
"get_string",
"(",
"'deactivate'",
",",
"'badges'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"}",
"// Award badge manually.",
"if",
"(",
"$",
"badge",
"->",
"has_manual_award_criteria",
"(",
")",
"&&",
"has_capability",
"(",
"'moodle/badges:awardbadge'",
",",
"$",
"context",
")",
"&&",
"$",
"badge",
"->",
"is_active",
"(",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/badges/award.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
")",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/award'",
",",
"get_string",
"(",
"'award'",
",",
"'badges'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"// Edit badge.",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:configuredetails'",
",",
"$",
"context",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/badges/edit.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'action'",
"=>",
"'details'",
")",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/edit'",
",",
"get_string",
"(",
"'edit'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"// Duplicate badge.",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:createbadge'",
",",
"$",
"context",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/badges/action.php'",
",",
"array",
"(",
"'copy'",
"=>",
"'1'",
",",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/copy'",
",",
"get_string",
"(",
"'copy'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"// Delete badge.",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:deletebadge'",
",",
"$",
"context",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"qualified_me",
"(",
")",
")",
";",
"$",
"url",
"->",
"param",
"(",
"'delete'",
",",
"$",
"badge",
"->",
"id",
")",
";",
"$",
"actions",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/delete'",
",",
"get_string",
"(",
"'delete'",
")",
")",
")",
".",
"\" \"",
";",
"}",
"return",
"$",
"actions",
";",
"}"
] | Prints action icons for the badge. | [
"Prints",
"action",
"icons",
"for",
"the",
"badge",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L231-L281 |
213,717 | moodle/moodle | badges/renderer.php | core_badges_renderer.render_badge_collection | protected function render_badge_collection(badge_collection $badges) {
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'collection';
$sortbyname = $this->helper_sortable_heading(get_string('name'),
'name', $badges->sort, $badges->dir);
$sortbyawarded = $this->helper_sortable_heading(get_string('awardedtoyou', 'badges'),
'dateissued', $badges->sort, $badges->dir);
$table->head = array(
get_string('badgeimage', 'badges'),
$sortbyname,
get_string('description', 'badges'),
get_string('bcriteria', 'badges'),
$sortbyawarded
);
$table->colclasses = array('badgeimage', 'name', 'description', 'criteria', 'awards');
foreach ($badges->badges as $badge) {
$badgeimage = print_badge_image($badge, $this->page->context, 'large');
$name = $badge->name;
$description = $badge->description;
$criteria = self::print_badge_criteria($badge);
if ($badge->dateissued) {
$icon = new pix_icon('i/valid',
get_string('dateearned', 'badges',
userdate($badge->dateissued, get_string('strftimedatefullshort', 'core_langconfig'))));
$badgeurl = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
$awarded = $this->output->action_icon($badgeurl, $icon, null, null, true);
} else {
$awarded = "";
}
$row = array($badgeimage, $name, $description, $criteria, $awarded);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | php | protected function render_badge_collection(badge_collection $badges) {
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'collection';
$sortbyname = $this->helper_sortable_heading(get_string('name'),
'name', $badges->sort, $badges->dir);
$sortbyawarded = $this->helper_sortable_heading(get_string('awardedtoyou', 'badges'),
'dateissued', $badges->sort, $badges->dir);
$table->head = array(
get_string('badgeimage', 'badges'),
$sortbyname,
get_string('description', 'badges'),
get_string('bcriteria', 'badges'),
$sortbyawarded
);
$table->colclasses = array('badgeimage', 'name', 'description', 'criteria', 'awards');
foreach ($badges->badges as $badge) {
$badgeimage = print_badge_image($badge, $this->page->context, 'large');
$name = $badge->name;
$description = $badge->description;
$criteria = self::print_badge_criteria($badge);
if ($badge->dateissued) {
$icon = new pix_icon('i/valid',
get_string('dateearned', 'badges',
userdate($badge->dateissued, get_string('strftimedatefullshort', 'core_langconfig'))));
$badgeurl = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
$awarded = $this->output->action_icon($badgeurl, $icon, null, null, true);
} else {
$awarded = "";
}
$row = array($badgeimage, $name, $description, $criteria, $awarded);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | [
"protected",
"function",
"render_badge_collection",
"(",
"badge_collection",
"$",
"badges",
")",
"{",
"$",
"paging",
"=",
"new",
"paging_bar",
"(",
"$",
"badges",
"->",
"totalcount",
",",
"$",
"badges",
"->",
"page",
",",
"$",
"badges",
"->",
"perpage",
",",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'page'",
")",
";",
"$",
"htmlpagingbar",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"paging",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'collection'",
";",
"$",
"sortbyname",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'name'",
")",
",",
"'name'",
",",
"$",
"badges",
"->",
"sort",
",",
"$",
"badges",
"->",
"dir",
")",
";",
"$",
"sortbyawarded",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'awardedtoyou'",
",",
"'badges'",
")",
",",
"'dateissued'",
",",
"$",
"badges",
"->",
"sort",
",",
"$",
"badges",
"->",
"dir",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'badgeimage'",
",",
"'badges'",
")",
",",
"$",
"sortbyname",
",",
"get_string",
"(",
"'description'",
",",
"'badges'",
")",
",",
"get_string",
"(",
"'bcriteria'",
",",
"'badges'",
")",
",",
"$",
"sortbyawarded",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'badgeimage'",
",",
"'name'",
",",
"'description'",
",",
"'criteria'",
",",
"'awards'",
")",
";",
"foreach",
"(",
"$",
"badges",
"->",
"badges",
"as",
"$",
"badge",
")",
"{",
"$",
"badgeimage",
"=",
"print_badge_image",
"(",
"$",
"badge",
",",
"$",
"this",
"->",
"page",
"->",
"context",
",",
"'large'",
")",
";",
"$",
"name",
"=",
"$",
"badge",
"->",
"name",
";",
"$",
"description",
"=",
"$",
"badge",
"->",
"description",
";",
"$",
"criteria",
"=",
"self",
"::",
"print_badge_criteria",
"(",
"$",
"badge",
")",
";",
"if",
"(",
"$",
"badge",
"->",
"dateissued",
")",
"{",
"$",
"icon",
"=",
"new",
"pix_icon",
"(",
"'i/valid'",
",",
"get_string",
"(",
"'dateearned'",
",",
"'badges'",
",",
"userdate",
"(",
"$",
"badge",
"->",
"dateissued",
",",
"get_string",
"(",
"'strftimedatefullshort'",
",",
"'core_langconfig'",
")",
")",
")",
")",
";",
"$",
"badgeurl",
"=",
"new",
"moodle_url",
"(",
"'/badges/badge.php'",
",",
"array",
"(",
"'hash'",
"=>",
"$",
"badge",
"->",
"uniquehash",
")",
")",
";",
"$",
"awarded",
"=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"badgeurl",
",",
"$",
"icon",
",",
"null",
",",
"null",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"awarded",
"=",
"\"\"",
";",
"}",
"$",
"row",
"=",
"array",
"(",
"$",
"badgeimage",
",",
"$",
"name",
",",
"$",
"description",
",",
"$",
"criteria",
",",
"$",
"awarded",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"htmltable",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"htmlpagingbar",
".",
"$",
"htmltable",
".",
"$",
"htmlpagingbar",
";",
"}"
] | Displays the available badges. | [
"Displays",
"the",
"available",
"badges",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L594-L634 |
213,718 | moodle/moodle | badges/renderer.php | core_badges_renderer.render_badge_management | protected function render_badge_management(badge_management $badges) {
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
// New badge button.
$htmlnew = '';
if (has_capability('moodle/badges:createbadge', $this->page->context)) {
$n['type'] = $this->page->url->get_param('type');
$n['id'] = $this->page->url->get_param('id');
$htmlnew = $this->output->single_button(new moodle_url('newbadge.php', $n), get_string('newbadge', 'badges'));
}
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'collection';
$sortbyname = $this->helper_sortable_heading(get_string('name'),
'name', $badges->sort, $badges->dir);
$sortbystatus = $this->helper_sortable_heading(get_string('status', 'badges'),
'status', $badges->sort, $badges->dir);
$table->head = array(
$sortbyname,
$sortbystatus,
get_string('bcriteria', 'badges'),
get_string('awards', 'badges'),
get_string('actions')
);
$table->colclasses = array('name', 'status', 'criteria', 'awards', 'actions');
foreach ($badges->badges as $b) {
$style = !$b->is_active() ? array('class' => 'dimmed') : array();
$forlink = print_badge_image($b, $this->page->context) . ' ' .
html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink, $style);
$status = $b->statstring;
$criteria = self::print_badge_criteria($b, 'short');
if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
$awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
} else {
$awards = $b->awards;
}
$actions = self::print_badge_table_actions($b, $this->page->context);
$row = array($name, $status, $criteria, $awards, $actions);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlnew . $htmlpagingbar . $htmltable . $htmlpagingbar;
} | php | protected function render_badge_management(badge_management $badges) {
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
// New badge button.
$htmlnew = '';
if (has_capability('moodle/badges:createbadge', $this->page->context)) {
$n['type'] = $this->page->url->get_param('type');
$n['id'] = $this->page->url->get_param('id');
$htmlnew = $this->output->single_button(new moodle_url('newbadge.php', $n), get_string('newbadge', 'badges'));
}
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'collection';
$sortbyname = $this->helper_sortable_heading(get_string('name'),
'name', $badges->sort, $badges->dir);
$sortbystatus = $this->helper_sortable_heading(get_string('status', 'badges'),
'status', $badges->sort, $badges->dir);
$table->head = array(
$sortbyname,
$sortbystatus,
get_string('bcriteria', 'badges'),
get_string('awards', 'badges'),
get_string('actions')
);
$table->colclasses = array('name', 'status', 'criteria', 'awards', 'actions');
foreach ($badges->badges as $b) {
$style = !$b->is_active() ? array('class' => 'dimmed') : array();
$forlink = print_badge_image($b, $this->page->context) . ' ' .
html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink, $style);
$status = $b->statstring;
$criteria = self::print_badge_criteria($b, 'short');
if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
$awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
} else {
$awards = $b->awards;
}
$actions = self::print_badge_table_actions($b, $this->page->context);
$row = array($name, $status, $criteria, $awards, $actions);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlnew . $htmlpagingbar . $htmltable . $htmlpagingbar;
} | [
"protected",
"function",
"render_badge_management",
"(",
"badge_management",
"$",
"badges",
")",
"{",
"$",
"paging",
"=",
"new",
"paging_bar",
"(",
"$",
"badges",
"->",
"totalcount",
",",
"$",
"badges",
"->",
"page",
",",
"$",
"badges",
"->",
"perpage",
",",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'page'",
")",
";",
"// New badge button.",
"$",
"htmlnew",
"=",
"''",
";",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:createbadge'",
",",
"$",
"this",
"->",
"page",
"->",
"context",
")",
")",
"{",
"$",
"n",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"page",
"->",
"url",
"->",
"get_param",
"(",
"'type'",
")",
";",
"$",
"n",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"page",
"->",
"url",
"->",
"get_param",
"(",
"'id'",
")",
";",
"$",
"htmlnew",
"=",
"$",
"this",
"->",
"output",
"->",
"single_button",
"(",
"new",
"moodle_url",
"(",
"'newbadge.php'",
",",
"$",
"n",
")",
",",
"get_string",
"(",
"'newbadge'",
",",
"'badges'",
")",
")",
";",
"}",
"$",
"htmlpagingbar",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"paging",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'collection'",
";",
"$",
"sortbyname",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'name'",
")",
",",
"'name'",
",",
"$",
"badges",
"->",
"sort",
",",
"$",
"badges",
"->",
"dir",
")",
";",
"$",
"sortbystatus",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'status'",
",",
"'badges'",
")",
",",
"'status'",
",",
"$",
"badges",
"->",
"sort",
",",
"$",
"badges",
"->",
"dir",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"$",
"sortbyname",
",",
"$",
"sortbystatus",
",",
"get_string",
"(",
"'bcriteria'",
",",
"'badges'",
")",
",",
"get_string",
"(",
"'awards'",
",",
"'badges'",
")",
",",
"get_string",
"(",
"'actions'",
")",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'name'",
",",
"'status'",
",",
"'criteria'",
",",
"'awards'",
",",
"'actions'",
")",
";",
"foreach",
"(",
"$",
"badges",
"->",
"badges",
"as",
"$",
"b",
")",
"{",
"$",
"style",
"=",
"!",
"$",
"b",
"->",
"is_active",
"(",
")",
"?",
"array",
"(",
"'class'",
"=>",
"'dimmed'",
")",
":",
"array",
"(",
")",
";",
"$",
"forlink",
"=",
"print_badge_image",
"(",
"$",
"b",
",",
"$",
"this",
"->",
"page",
"->",
"context",
")",
".",
"' '",
".",
"html_writer",
"::",
"start_tag",
"(",
"'span'",
")",
".",
"$",
"b",
"->",
"name",
".",
"html_writer",
"::",
"end_tag",
"(",
"'span'",
")",
";",
"$",
"name",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/badges/overview.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"b",
"->",
"id",
")",
")",
",",
"$",
"forlink",
",",
"$",
"style",
")",
";",
"$",
"status",
"=",
"$",
"b",
"->",
"statstring",
";",
"$",
"criteria",
"=",
"self",
"::",
"print_badge_criteria",
"(",
"$",
"b",
",",
"'short'",
")",
";",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:viewawarded'",
",",
"$",
"this",
"->",
"page",
"->",
"context",
")",
")",
"{",
"$",
"awards",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/badges/recipients.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"b",
"->",
"id",
")",
")",
",",
"$",
"b",
"->",
"awards",
")",
";",
"}",
"else",
"{",
"$",
"awards",
"=",
"$",
"b",
"->",
"awards",
";",
"}",
"$",
"actions",
"=",
"self",
"::",
"print_badge_table_actions",
"(",
"$",
"b",
",",
"$",
"this",
"->",
"page",
"->",
"context",
")",
";",
"$",
"row",
"=",
"array",
"(",
"$",
"name",
",",
"$",
"status",
",",
"$",
"criteria",
",",
"$",
"awards",
",",
"$",
"actions",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"htmltable",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"htmlnew",
".",
"$",
"htmlpagingbar",
".",
"$",
"htmltable",
".",
"$",
"htmlpagingbar",
";",
"}"
] | Outputs table of badges with actions available. | [
"Outputs",
"table",
"of",
"badges",
"with",
"actions",
"available",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L637-L687 |
213,719 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_badge_status_box | public function print_badge_status_box(badge $badge) {
if (has_capability('moodle/badges:configurecriteria', $badge->get_context())) {
if (!$badge->has_criteria()) {
$criteriaurl = new moodle_url('/badges/criteria.php', array('id' => $badge->id));
$status = get_string('nocriteria', 'badges');
if ($this->page->url != $criteriaurl) {
$action = $this->output->single_button(
$criteriaurl,
get_string('addcriteria', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = '';
}
$message = $status . $action;
} else {
$status = get_string('statusmessage_' . $badge->status, 'badges');
if ($badge->is_active()) {
$action = $this->output->single_button(new moodle_url('/badges/action.php',
array('id' => $badge->id, 'lock' => 1, 'sesskey' => sesskey(),
'return' => $this->page->url->out_as_local_url(false))),
get_string('deactivate', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = $this->output->single_button(new moodle_url('/badges/action.php',
array('id' => $badge->id, 'activate' => 1, 'sesskey' => sesskey(),
'return' => $this->page->url->out_as_local_url(false))),
get_string('activate', 'badges'), 'POST', array('class' => 'activatebadge'));
}
$message = $status . $this->output->help_icon('status', 'badges') . $action;
}
$style = $badge->is_active() ? 'generalbox statusbox active' : 'generalbox statusbox inactive';
return $this->output->box($message, $style);
}
return null;
} | php | public function print_badge_status_box(badge $badge) {
if (has_capability('moodle/badges:configurecriteria', $badge->get_context())) {
if (!$badge->has_criteria()) {
$criteriaurl = new moodle_url('/badges/criteria.php', array('id' => $badge->id));
$status = get_string('nocriteria', 'badges');
if ($this->page->url != $criteriaurl) {
$action = $this->output->single_button(
$criteriaurl,
get_string('addcriteria', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = '';
}
$message = $status . $action;
} else {
$status = get_string('statusmessage_' . $badge->status, 'badges');
if ($badge->is_active()) {
$action = $this->output->single_button(new moodle_url('/badges/action.php',
array('id' => $badge->id, 'lock' => 1, 'sesskey' => sesskey(),
'return' => $this->page->url->out_as_local_url(false))),
get_string('deactivate', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = $this->output->single_button(new moodle_url('/badges/action.php',
array('id' => $badge->id, 'activate' => 1, 'sesskey' => sesskey(),
'return' => $this->page->url->out_as_local_url(false))),
get_string('activate', 'badges'), 'POST', array('class' => 'activatebadge'));
}
$message = $status . $this->output->help_icon('status', 'badges') . $action;
}
$style = $badge->is_active() ? 'generalbox statusbox active' : 'generalbox statusbox inactive';
return $this->output->box($message, $style);
}
return null;
} | [
"public",
"function",
"print_badge_status_box",
"(",
"badge",
"$",
"badge",
")",
"{",
"if",
"(",
"has_capability",
"(",
"'moodle/badges:configurecriteria'",
",",
"$",
"badge",
"->",
"get_context",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"badge",
"->",
"has_criteria",
"(",
")",
")",
"{",
"$",
"criteriaurl",
"=",
"new",
"moodle_url",
"(",
"'/badges/criteria.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
")",
")",
";",
"$",
"status",
"=",
"get_string",
"(",
"'nocriteria'",
",",
"'badges'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"url",
"!=",
"$",
"criteriaurl",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"output",
"->",
"single_button",
"(",
"$",
"criteriaurl",
",",
"get_string",
"(",
"'addcriteria'",
",",
"'badges'",
")",
",",
"'POST'",
",",
"array",
"(",
"'class'",
"=>",
"'activatebadge'",
")",
")",
";",
"}",
"else",
"{",
"$",
"action",
"=",
"''",
";",
"}",
"$",
"message",
"=",
"$",
"status",
".",
"$",
"action",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"get_string",
"(",
"'statusmessage_'",
".",
"$",
"badge",
"->",
"status",
",",
"'badges'",
")",
";",
"if",
"(",
"$",
"badge",
"->",
"is_active",
"(",
")",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"output",
"->",
"single_button",
"(",
"new",
"moodle_url",
"(",
"'/badges/action.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'lock'",
"=>",
"1",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'return'",
"=>",
"$",
"this",
"->",
"page",
"->",
"url",
"->",
"out_as_local_url",
"(",
"false",
")",
")",
")",
",",
"get_string",
"(",
"'deactivate'",
",",
"'badges'",
")",
",",
"'POST'",
",",
"array",
"(",
"'class'",
"=>",
"'activatebadge'",
")",
")",
";",
"}",
"else",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"output",
"->",
"single_button",
"(",
"new",
"moodle_url",
"(",
"'/badges/action.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'activate'",
"=>",
"1",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'return'",
"=>",
"$",
"this",
"->",
"page",
"->",
"url",
"->",
"out_as_local_url",
"(",
"false",
")",
")",
")",
",",
"get_string",
"(",
"'activate'",
",",
"'badges'",
")",
",",
"'POST'",
",",
"array",
"(",
"'class'",
"=>",
"'activatebadge'",
")",
")",
";",
"}",
"$",
"message",
"=",
"$",
"status",
".",
"$",
"this",
"->",
"output",
"->",
"help_icon",
"(",
"'status'",
",",
"'badges'",
")",
".",
"$",
"action",
";",
"}",
"$",
"style",
"=",
"$",
"badge",
"->",
"is_active",
"(",
")",
"?",
"'generalbox statusbox active'",
":",
"'generalbox statusbox inactive'",
";",
"return",
"$",
"this",
"->",
"output",
"->",
"box",
"(",
"$",
"message",
",",
"$",
"style",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Prints badge status box.
@return Either the status box html as a string or null | [
"Prints",
"badge",
"status",
"box",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L766-L804 |
213,720 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_criteria_actions | public function print_criteria_actions(badge $badge) {
$output = '';
if (!$badge->is_active() && !$badge->is_locked()) {
$accepted = $badge->get_accepted_criteria();
$potential = array_diff($accepted, array_keys($badge->criteria));
if (!empty($potential)) {
foreach ($potential as $p) {
if ($p != 0) {
$select[$p] = get_string('criteria_' . $p, 'badges');
}
}
$output .= $this->output->single_select(
new moodle_url('/badges/criteria_settings.php', array('badgeid' => $badge->id, 'add' => true)),
'type',
$select,
'',
array('' => 'choosedots'),
null,
array('label' => get_string('addbadgecriteria', 'badges'))
);
} else {
$output .= $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
}
}
return $output;
} | php | public function print_criteria_actions(badge $badge) {
$output = '';
if (!$badge->is_active() && !$badge->is_locked()) {
$accepted = $badge->get_accepted_criteria();
$potential = array_diff($accepted, array_keys($badge->criteria));
if (!empty($potential)) {
foreach ($potential as $p) {
if ($p != 0) {
$select[$p] = get_string('criteria_' . $p, 'badges');
}
}
$output .= $this->output->single_select(
new moodle_url('/badges/criteria_settings.php', array('badgeid' => $badge->id, 'add' => true)),
'type',
$select,
'',
array('' => 'choosedots'),
null,
array('label' => get_string('addbadgecriteria', 'badges'))
);
} else {
$output .= $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
}
}
return $output;
} | [
"public",
"function",
"print_criteria_actions",
"(",
"badge",
"$",
"badge",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"badge",
"->",
"is_active",
"(",
")",
"&&",
"!",
"$",
"badge",
"->",
"is_locked",
"(",
")",
")",
"{",
"$",
"accepted",
"=",
"$",
"badge",
"->",
"get_accepted_criteria",
"(",
")",
";",
"$",
"potential",
"=",
"array_diff",
"(",
"$",
"accepted",
",",
"array_keys",
"(",
"$",
"badge",
"->",
"criteria",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"potential",
")",
")",
"{",
"foreach",
"(",
"$",
"potential",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"$",
"p",
"!=",
"0",
")",
"{",
"$",
"select",
"[",
"$",
"p",
"]",
"=",
"get_string",
"(",
"'criteria_'",
".",
"$",
"p",
",",
"'badges'",
")",
";",
"}",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"output",
"->",
"single_select",
"(",
"new",
"moodle_url",
"(",
"'/badges/criteria_settings.php'",
",",
"array",
"(",
"'badgeid'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'add'",
"=>",
"true",
")",
")",
",",
"'type'",
",",
"$",
"select",
",",
"''",
",",
"array",
"(",
"''",
"=>",
"'choosedots'",
")",
",",
"null",
",",
"array",
"(",
"'label'",
"=>",
"get_string",
"(",
"'addbadgecriteria'",
",",
"'badges'",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"output",
"->",
"box",
"(",
"get_string",
"(",
"'nothingtoadd'",
",",
"'badges'",
")",
",",
"'clearfix'",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Prints criteria actions for badge editing. | [
"Prints",
"criteria",
"actions",
"for",
"badge",
"editing",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L884-L911 |
213,721 | moodle/moodle | badges/renderer.php | core_badges_renderer.render_badge_recipients | protected function render_badge_recipients(badge_recipients $recipients) {
$paging = new paging_bar($recipients->totalcount, $recipients->page, $recipients->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'),
'firstname', $recipients->sort, $recipients->dir);
$sortbylastname = $this->helper_sortable_heading(get_string('lastname'),
'lastname', $recipients->sort, $recipients->dir);
if ($this->helper_fullname_format() == 'lf') {
$sortbyname = $sortbylastname . ' / ' . $sortbyfirstname;
} else {
$sortbyname = $sortbyfirstname . ' / ' . $sortbylastname;
}
$sortbydate = $this->helper_sortable_heading(get_string('dateawarded', 'badges'),
'dateissued', $recipients->sort, $recipients->dir);
$table->head = array($sortbyname, $sortbydate, '');
foreach ($recipients->userids as $holder) {
$fullname = fullname($holder);
$fullname = html_writer::link(
new moodle_url('/user/profile.php', array('id' => $holder->userid)),
$fullname
);
$awarded = userdate($holder->dateissued);
$badgeurl = html_writer::link(
new moodle_url('/badges/badge.php', array('hash' => $holder->uniquehash)),
get_string('viewbadge', 'badges')
);
$row = array($fullname, $awarded, $badgeurl);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | php | protected function render_badge_recipients(badge_recipients $recipients) {
$paging = new paging_bar($recipients->totalcount, $recipients->page, $recipients->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'),
'firstname', $recipients->sort, $recipients->dir);
$sortbylastname = $this->helper_sortable_heading(get_string('lastname'),
'lastname', $recipients->sort, $recipients->dir);
if ($this->helper_fullname_format() == 'lf') {
$sortbyname = $sortbylastname . ' / ' . $sortbyfirstname;
} else {
$sortbyname = $sortbyfirstname . ' / ' . $sortbylastname;
}
$sortbydate = $this->helper_sortable_heading(get_string('dateawarded', 'badges'),
'dateissued', $recipients->sort, $recipients->dir);
$table->head = array($sortbyname, $sortbydate, '');
foreach ($recipients->userids as $holder) {
$fullname = fullname($holder);
$fullname = html_writer::link(
new moodle_url('/user/profile.php', array('id' => $holder->userid)),
$fullname
);
$awarded = userdate($holder->dateissued);
$badgeurl = html_writer::link(
new moodle_url('/badges/badge.php', array('hash' => $holder->uniquehash)),
get_string('viewbadge', 'badges')
);
$row = array($fullname, $awarded, $badgeurl);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | [
"protected",
"function",
"render_badge_recipients",
"(",
"badge_recipients",
"$",
"recipients",
")",
"{",
"$",
"paging",
"=",
"new",
"paging_bar",
"(",
"$",
"recipients",
"->",
"totalcount",
",",
"$",
"recipients",
"->",
"page",
",",
"$",
"recipients",
"->",
"perpage",
",",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'page'",
")",
";",
"$",
"htmlpagingbar",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"paging",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generaltable boxaligncenter boxwidthwide'",
";",
"$",
"sortbyfirstname",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'firstname'",
")",
",",
"'firstname'",
",",
"$",
"recipients",
"->",
"sort",
",",
"$",
"recipients",
"->",
"dir",
")",
";",
"$",
"sortbylastname",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'lastname'",
")",
",",
"'lastname'",
",",
"$",
"recipients",
"->",
"sort",
",",
"$",
"recipients",
"->",
"dir",
")",
";",
"if",
"(",
"$",
"this",
"->",
"helper_fullname_format",
"(",
")",
"==",
"'lf'",
")",
"{",
"$",
"sortbyname",
"=",
"$",
"sortbylastname",
".",
"' / '",
".",
"$",
"sortbyfirstname",
";",
"}",
"else",
"{",
"$",
"sortbyname",
"=",
"$",
"sortbyfirstname",
".",
"' / '",
".",
"$",
"sortbylastname",
";",
"}",
"$",
"sortbydate",
"=",
"$",
"this",
"->",
"helper_sortable_heading",
"(",
"get_string",
"(",
"'dateawarded'",
",",
"'badges'",
")",
",",
"'dateissued'",
",",
"$",
"recipients",
"->",
"sort",
",",
"$",
"recipients",
"->",
"dir",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"$",
"sortbyname",
",",
"$",
"sortbydate",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"recipients",
"->",
"userids",
"as",
"$",
"holder",
")",
"{",
"$",
"fullname",
"=",
"fullname",
"(",
"$",
"holder",
")",
";",
"$",
"fullname",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/user/profile.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"holder",
"->",
"userid",
")",
")",
",",
"$",
"fullname",
")",
";",
"$",
"awarded",
"=",
"userdate",
"(",
"$",
"holder",
"->",
"dateissued",
")",
";",
"$",
"badgeurl",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/badges/badge.php'",
",",
"array",
"(",
"'hash'",
"=>",
"$",
"holder",
"->",
"uniquehash",
")",
")",
",",
"get_string",
"(",
"'viewbadge'",
",",
"'badges'",
")",
")",
";",
"$",
"row",
"=",
"array",
"(",
"$",
"fullname",
",",
"$",
"awarded",
",",
"$",
"badgeurl",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"htmltable",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"htmlpagingbar",
".",
"$",
"htmltable",
".",
"$",
"htmlpagingbar",
";",
"}"
] | Based on stamps collection plugin. | [
"Based",
"on",
"stamps",
"collection",
"plugin",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L915-L955 |
213,722 | moodle/moodle | badges/renderer.php | core_badges_renderer.helper_sortable_heading | protected function helper_sortable_heading($text, $sortid = null, $sortby = null, $sorthow = null) {
$out = html_writer::tag('span', $text, array('class' => 'text'));
if (!is_null($sortid)) {
if ($sortby !== $sortid || $sorthow !== 'ASC') {
$url = new moodle_url($this->page->url);
$url->params(array('sort' => $sortid, 'dir' => 'ASC'));
$out .= $this->output->action_icon($url,
new pix_icon('t/sort_asc', get_string('sortbyx', 'core', s($text)), null, array('class' => 'iconsort')));
}
if ($sortby !== $sortid || $sorthow !== 'DESC') {
$url = new moodle_url($this->page->url);
$url->params(array('sort' => $sortid, 'dir' => 'DESC'));
$out .= $this->output->action_icon($url,
new pix_icon('t/sort_desc', get_string('sortbyxreverse', 'core', s($text)), null, array('class' => 'iconsort')));
}
}
return $out;
} | php | protected function helper_sortable_heading($text, $sortid = null, $sortby = null, $sorthow = null) {
$out = html_writer::tag('span', $text, array('class' => 'text'));
if (!is_null($sortid)) {
if ($sortby !== $sortid || $sorthow !== 'ASC') {
$url = new moodle_url($this->page->url);
$url->params(array('sort' => $sortid, 'dir' => 'ASC'));
$out .= $this->output->action_icon($url,
new pix_icon('t/sort_asc', get_string('sortbyx', 'core', s($text)), null, array('class' => 'iconsort')));
}
if ($sortby !== $sortid || $sorthow !== 'DESC') {
$url = new moodle_url($this->page->url);
$url->params(array('sort' => $sortid, 'dir' => 'DESC'));
$out .= $this->output->action_icon($url,
new pix_icon('t/sort_desc', get_string('sortbyxreverse', 'core', s($text)), null, array('class' => 'iconsort')));
}
}
return $out;
} | [
"protected",
"function",
"helper_sortable_heading",
"(",
"$",
"text",
",",
"$",
"sortid",
"=",
"null",
",",
"$",
"sortby",
"=",
"null",
",",
"$",
"sorthow",
"=",
"null",
")",
"{",
"$",
"out",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"text",
",",
"array",
"(",
"'class'",
"=>",
"'text'",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"sortid",
")",
")",
"{",
"if",
"(",
"$",
"sortby",
"!==",
"$",
"sortid",
"||",
"$",
"sorthow",
"!==",
"'ASC'",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"this",
"->",
"page",
"->",
"url",
")",
";",
"$",
"url",
"->",
"params",
"(",
"array",
"(",
"'sort'",
"=>",
"$",
"sortid",
",",
"'dir'",
"=>",
"'ASC'",
")",
")",
";",
"$",
"out",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/sort_asc'",
",",
"get_string",
"(",
"'sortbyx'",
",",
"'core'",
",",
"s",
"(",
"$",
"text",
")",
")",
",",
"null",
",",
"array",
"(",
"'class'",
"=>",
"'iconsort'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"sortby",
"!==",
"$",
"sortid",
"||",
"$",
"sorthow",
"!==",
"'DESC'",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"this",
"->",
"page",
"->",
"url",
")",
";",
"$",
"url",
"->",
"params",
"(",
"array",
"(",
"'sort'",
"=>",
"$",
"sortid",
",",
"'dir'",
"=>",
"'DESC'",
")",
")",
";",
"$",
"out",
".=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/sort_desc'",
",",
"get_string",
"(",
"'sortbyxreverse'",
",",
"'core'",
",",
"s",
"(",
"$",
"text",
")",
")",
",",
"null",
",",
"array",
"(",
"'class'",
"=>",
"'iconsort'",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Renders a text with icons to sort by the given column
This is intended for table headings.
@param string $text The heading text
@param string $sortid The column id used for sorting
@param string $sortby Currently sorted by (column id)
@param string $sorthow Currently sorted how (ASC|DESC)
@return string | [
"Renders",
"a",
"text",
"with",
"icons",
"to",
"sort",
"by",
"the",
"given",
"column"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L974-L992 |
213,723 | moodle/moodle | badges/renderer.php | core_badges_renderer.helper_search_form | protected function helper_search_form($search) {
global $CFG;
require_once($CFG->libdir . '/formslib.php');
$mform = new MoodleQuickForm('searchform', 'POST', $this->page->url);
$mform->addElement('hidden', 'sesskey', sesskey());
$el[] = $mform->createElement('text', 'search', get_string('search'), array('size' => 20));
$mform->setDefault('search', $search);
$el[] = $mform->createElement('submit', 'submitsearch', get_string('search'));
$el[] = $mform->createElement('submit', 'clearsearch', get_string('clear'));
$mform->addGroup($el, 'searchgroup', get_string('searchname', 'badges'), ' ', false);
ob_start();
$mform->display();
$out = ob_get_clean();
return $out;
} | php | protected function helper_search_form($search) {
global $CFG;
require_once($CFG->libdir . '/formslib.php');
$mform = new MoodleQuickForm('searchform', 'POST', $this->page->url);
$mform->addElement('hidden', 'sesskey', sesskey());
$el[] = $mform->createElement('text', 'search', get_string('search'), array('size' => 20));
$mform->setDefault('search', $search);
$el[] = $mform->createElement('submit', 'submitsearch', get_string('search'));
$el[] = $mform->createElement('submit', 'clearsearch', get_string('clear'));
$mform->addGroup($el, 'searchgroup', get_string('searchname', 'badges'), ' ', false);
ob_start();
$mform->display();
$out = ob_get_clean();
return $out;
} | [
"protected",
"function",
"helper_search_form",
"(",
"$",
"search",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/formslib.php'",
")",
";",
"$",
"mform",
"=",
"new",
"MoodleQuickForm",
"(",
"'searchform'",
",",
"'POST'",
",",
"$",
"this",
"->",
"page",
"->",
"url",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'hidden'",
",",
"'sesskey'",
",",
"sesskey",
"(",
")",
")",
";",
"$",
"el",
"[",
"]",
"=",
"$",
"mform",
"->",
"createElement",
"(",
"'text'",
",",
"'search'",
",",
"get_string",
"(",
"'search'",
")",
",",
"array",
"(",
"'size'",
"=>",
"20",
")",
")",
";",
"$",
"mform",
"->",
"setDefault",
"(",
"'search'",
",",
"$",
"search",
")",
";",
"$",
"el",
"[",
"]",
"=",
"$",
"mform",
"->",
"createElement",
"(",
"'submit'",
",",
"'submitsearch'",
",",
"get_string",
"(",
"'search'",
")",
")",
";",
"$",
"el",
"[",
"]",
"=",
"$",
"mform",
"->",
"createElement",
"(",
"'submit'",
",",
"'clearsearch'",
",",
"get_string",
"(",
"'clear'",
")",
")",
";",
"$",
"mform",
"->",
"addGroup",
"(",
"$",
"el",
",",
"'searchgroup'",
",",
"get_string",
"(",
"'searchname'",
",",
"'badges'",
")",
",",
"' '",
",",
"false",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"mform",
"->",
"display",
"(",
")",
";",
"$",
"out",
"=",
"ob_get_clean",
"(",
")",
";",
"return",
"$",
"out",
";",
"}"
] | Renders a search form
@param string $search Search string
@return string HTML | [
"Renders",
"a",
"search",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1015-L1034 |
213,724 | moodle/moodle | badges/renderer.php | core_badges_renderer.definition_list | protected function definition_list(array $items, array $attributes = array()) {
$output = html_writer::start_tag('dl', $attributes);
foreach ($items as $label => $value) {
$output .= html_writer::tag('dt', $label);
$output .= html_writer::tag('dd', $value);
}
$output .= html_writer::end_tag('dl');
return $output;
} | php | protected function definition_list(array $items, array $attributes = array()) {
$output = html_writer::start_tag('dl', $attributes);
foreach ($items as $label => $value) {
$output .= html_writer::tag('dt', $label);
$output .= html_writer::tag('dd', $value);
}
$output .= html_writer::end_tag('dl');
return $output;
} | [
"protected",
"function",
"definition_list",
"(",
"array",
"$",
"items",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"output",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'dl'",
",",
"$",
"attributes",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"label",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'dt'",
",",
"$",
"label",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'dd'",
",",
"$",
"value",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'dl'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Renders a definition list
@param array $items the list of items to define
@param array | [
"Renders",
"a",
"definition",
"list"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1042-L1050 |
213,725 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_badge_endorsement | protected function print_badge_endorsement(badge $badge) {
$output = '';
$endorsement = $badge->get_endorsement();
$dl = array();
$output .= $this->heading(get_string('endorsement', 'badges'), 3);
if (!empty($endorsement)) {
$dl[get_string('issuername', 'badges')] = $endorsement->issuername;
$dl[get_string('issueremail', 'badges')] =
html_writer::tag('a', $endorsement->issueremail, array('href' => 'mailto:' . $endorsement->issueremail));
$dl[get_string('issuerurl', 'badges')] = html_writer::link($endorsement->issuerurl, $endorsement->issuerurl,
array('target' => '_blank'));
$dl[get_string('dateawarded', 'badges')] = userdate($endorsement->dateissued);
$dl[get_string('claimid', 'badges')] = html_writer::link($endorsement->claimid, $endorsement->claimid,
array('target' => '_blank'));
$dl[get_string('claimcomment', 'badges')] = $endorsement->claimcomment;
$output .= $this->definition_list($dl);
} else {
$output .= get_string('noendorsement', 'badges');
}
return $output;
} | php | protected function print_badge_endorsement(badge $badge) {
$output = '';
$endorsement = $badge->get_endorsement();
$dl = array();
$output .= $this->heading(get_string('endorsement', 'badges'), 3);
if (!empty($endorsement)) {
$dl[get_string('issuername', 'badges')] = $endorsement->issuername;
$dl[get_string('issueremail', 'badges')] =
html_writer::tag('a', $endorsement->issueremail, array('href' => 'mailto:' . $endorsement->issueremail));
$dl[get_string('issuerurl', 'badges')] = html_writer::link($endorsement->issuerurl, $endorsement->issuerurl,
array('target' => '_blank'));
$dl[get_string('dateawarded', 'badges')] = userdate($endorsement->dateissued);
$dl[get_string('claimid', 'badges')] = html_writer::link($endorsement->claimid, $endorsement->claimid,
array('target' => '_blank'));
$dl[get_string('claimcomment', 'badges')] = $endorsement->claimcomment;
$output .= $this->definition_list($dl);
} else {
$output .= get_string('noendorsement', 'badges');
}
return $output;
} | [
"protected",
"function",
"print_badge_endorsement",
"(",
"badge",
"$",
"badge",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"endorsement",
"=",
"$",
"badge",
"->",
"get_endorsement",
"(",
")",
";",
"$",
"dl",
"=",
"array",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'endorsement'",
",",
"'badges'",
")",
",",
"3",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"endorsement",
")",
")",
"{",
"$",
"dl",
"[",
"get_string",
"(",
"'issuername'",
",",
"'badges'",
")",
"]",
"=",
"$",
"endorsement",
"->",
"issuername",
";",
"$",
"dl",
"[",
"get_string",
"(",
"'issueremail'",
",",
"'badges'",
")",
"]",
"=",
"html_writer",
"::",
"tag",
"(",
"'a'",
",",
"$",
"endorsement",
"->",
"issueremail",
",",
"array",
"(",
"'href'",
"=>",
"'mailto:'",
".",
"$",
"endorsement",
"->",
"issueremail",
")",
")",
";",
"$",
"dl",
"[",
"get_string",
"(",
"'issuerurl'",
",",
"'badges'",
")",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"endorsement",
"->",
"issuerurl",
",",
"$",
"endorsement",
"->",
"issuerurl",
",",
"array",
"(",
"'target'",
"=>",
"'_blank'",
")",
")",
";",
"$",
"dl",
"[",
"get_string",
"(",
"'dateawarded'",
",",
"'badges'",
")",
"]",
"=",
"userdate",
"(",
"$",
"endorsement",
"->",
"dateissued",
")",
";",
"$",
"dl",
"[",
"get_string",
"(",
"'claimid'",
",",
"'badges'",
")",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"endorsement",
"->",
"claimid",
",",
"$",
"endorsement",
"->",
"claimid",
",",
"array",
"(",
"'target'",
"=>",
"'_blank'",
")",
")",
";",
"$",
"dl",
"[",
"get_string",
"(",
"'claimcomment'",
",",
"'badges'",
")",
"]",
"=",
"$",
"endorsement",
"->",
"claimcomment",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"definition_list",
"(",
"$",
"dl",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"get_string",
"(",
"'noendorsement'",
",",
"'badges'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Outputs list en badges.
@param badge $badge Badge object.
@return string $output content endorsement to output. | [
"Outputs",
"list",
"en",
"badges",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1058-L1078 |
213,726 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_badge_related | protected function print_badge_related(badge $badge) {
$output = '';
$relatedbadges = $badge->get_related_badges();
$output .= $this->heading(get_string('relatedbages', 'badges'), 3);
if (!empty($relatedbadges)) {
$items = array();
foreach ($relatedbadges as $related) {
$relatedurl = new moodle_url('/badges/overview.php', array('id' => $related->id));
$items[] = html_writer::link($relatedurl->out(), $related->name, array('target' => '_blank'));
}
$output .= html_writer::alist($items, array(), 'ul');
} else {
$output .= get_string('norelated', 'badges');
}
return $output;
} | php | protected function print_badge_related(badge $badge) {
$output = '';
$relatedbadges = $badge->get_related_badges();
$output .= $this->heading(get_string('relatedbages', 'badges'), 3);
if (!empty($relatedbadges)) {
$items = array();
foreach ($relatedbadges as $related) {
$relatedurl = new moodle_url('/badges/overview.php', array('id' => $related->id));
$items[] = html_writer::link($relatedurl->out(), $related->name, array('target' => '_blank'));
}
$output .= html_writer::alist($items, array(), 'ul');
} else {
$output .= get_string('norelated', 'badges');
}
return $output;
} | [
"protected",
"function",
"print_badge_related",
"(",
"badge",
"$",
"badge",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"relatedbadges",
"=",
"$",
"badge",
"->",
"get_related_badges",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'relatedbages'",
",",
"'badges'",
")",
",",
"3",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"relatedbadges",
")",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"relatedbadges",
"as",
"$",
"related",
")",
"{",
"$",
"relatedurl",
"=",
"new",
"moodle_url",
"(",
"'/badges/overview.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"related",
"->",
"id",
")",
")",
";",
"$",
"items",
"[",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"relatedurl",
"->",
"out",
"(",
")",
",",
"$",
"related",
"->",
"name",
",",
"array",
"(",
"'target'",
"=>",
"'_blank'",
")",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"alist",
"(",
"$",
"items",
",",
"array",
"(",
")",
",",
"'ul'",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"get_string",
"(",
"'norelated'",
",",
"'badges'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Print list badges related.
@param badge $badge Badge objects.
@return string $output List related badges to output. | [
"Print",
"list",
"badges",
"related",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1086-L1101 |
213,727 | moodle/moodle | badges/renderer.php | core_badges_renderer.print_badge_alignments | protected function print_badge_alignments(badge $badge) {
$output = '';
$output .= $this->heading(get_string('alignment', 'badges'), 3);
$alignments = $badge->get_alignments();
if (!empty($alignments)) {
$items = array();
foreach ($alignments as $alignment) {
$urlaligment = new moodle_url('alignment.php',
array('id' => $badge->id, 'alignmentid' => $alignment->id)
);
$items[] = html_writer::link($urlaligment, $alignment->targetname, array('target' => '_blank'));
}
$output .= html_writer::alist($items, array(), 'ul');
} else {
$output .= get_string('noalignment', 'badges');
}
return $output;
} | php | protected function print_badge_alignments(badge $badge) {
$output = '';
$output .= $this->heading(get_string('alignment', 'badges'), 3);
$alignments = $badge->get_alignments();
if (!empty($alignments)) {
$items = array();
foreach ($alignments as $alignment) {
$urlaligment = new moodle_url('alignment.php',
array('id' => $badge->id, 'alignmentid' => $alignment->id)
);
$items[] = html_writer::link($urlaligment, $alignment->targetname, array('target' => '_blank'));
}
$output .= html_writer::alist($items, array(), 'ul');
} else {
$output .= get_string('noalignment', 'badges');
}
return $output;
} | [
"protected",
"function",
"print_badge_alignments",
"(",
"badge",
"$",
"badge",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'alignment'",
",",
"'badges'",
")",
",",
"3",
")",
";",
"$",
"alignments",
"=",
"$",
"badge",
"->",
"get_alignments",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"alignments",
")",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"alignments",
"as",
"$",
"alignment",
")",
"{",
"$",
"urlaligment",
"=",
"new",
"moodle_url",
"(",
"'alignment.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'alignmentid'",
"=>",
"$",
"alignment",
"->",
"id",
")",
")",
";",
"$",
"items",
"[",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"urlaligment",
",",
"$",
"alignment",
"->",
"targetname",
",",
"array",
"(",
"'target'",
"=>",
"'_blank'",
")",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"alist",
"(",
"$",
"items",
",",
"array",
"(",
")",
",",
"'ul'",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"get_string",
"(",
"'noalignment'",
",",
"'badges'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Print list badge alignments.
@param badge $badge Badge objects.
@return string $output List alignments to output. | [
"Print",
"list",
"badge",
"alignments",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1109-L1126 |
213,728 | moodle/moodle | badges/renderer.php | core_badges_renderer.render_badge_related | protected function render_badge_related(badge_related $related) {
$currentbadge = new badge($related->currentbadgeid);
$languages = get_string_manager()->get_list_of_languages();
$paging = new paging_bar($related->totalcount, $related->page, $related->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$table->head = array(
get_string('name'),
get_string('version', 'badges'),
get_string('language', 'badges'),
get_string('type', 'badges')
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
array_push($table->head, '');
}
foreach ($related->badges as $badge) {
$badgeobject = new badge($badge->id);
$style = array('title' => $badgeobject->name);
if (!$badgeobject->is_active()) {
$style['class'] = 'dimmed';
}
$context = ($badgeobject->type == BADGE_TYPE_SITE) ?
context_system::instance() : context_course::instance($badgeobject->courseid);
$forlink = print_badge_image($badgeobject, $context) . ' ' .
html_writer::start_tag('span') . $badgeobject->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $badgeobject->id)), $forlink, $style);
$row = array(
$name,
$badge->version,
$badge->language ? $languages[$badge->language] : '',
$badge->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
$action = $this->output->action_icon(
new moodle_url('related_action.php',
array(
'badgeid' => $related->currentbadgeid,
'relatedid' => $badge->id,
'action' => 'remove'
)
), new pix_icon('t/delete', get_string('delete')));
$actions = html_writer::tag('div', $action, array('class' => 'badge-actions'));
array_push($row, $actions);
}
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | php | protected function render_badge_related(badge_related $related) {
$currentbadge = new badge($related->currentbadgeid);
$languages = get_string_manager()->get_list_of_languages();
$paging = new paging_bar($related->totalcount, $related->page, $related->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$table->head = array(
get_string('name'),
get_string('version', 'badges'),
get_string('language', 'badges'),
get_string('type', 'badges')
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
array_push($table->head, '');
}
foreach ($related->badges as $badge) {
$badgeobject = new badge($badge->id);
$style = array('title' => $badgeobject->name);
if (!$badgeobject->is_active()) {
$style['class'] = 'dimmed';
}
$context = ($badgeobject->type == BADGE_TYPE_SITE) ?
context_system::instance() : context_course::instance($badgeobject->courseid);
$forlink = print_badge_image($badgeobject, $context) . ' ' .
html_writer::start_tag('span') . $badgeobject->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $badgeobject->id)), $forlink, $style);
$row = array(
$name,
$badge->version,
$badge->language ? $languages[$badge->language] : '',
$badge->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
$action = $this->output->action_icon(
new moodle_url('related_action.php',
array(
'badgeid' => $related->currentbadgeid,
'relatedid' => $badge->id,
'action' => 'remove'
)
), new pix_icon('t/delete', get_string('delete')));
$actions = html_writer::tag('div', $action, array('class' => 'badge-actions'));
array_push($row, $actions);
}
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | [
"protected",
"function",
"render_badge_related",
"(",
"badge_related",
"$",
"related",
")",
"{",
"$",
"currentbadge",
"=",
"new",
"badge",
"(",
"$",
"related",
"->",
"currentbadgeid",
")",
";",
"$",
"languages",
"=",
"get_string_manager",
"(",
")",
"->",
"get_list_of_languages",
"(",
")",
";",
"$",
"paging",
"=",
"new",
"paging_bar",
"(",
"$",
"related",
"->",
"totalcount",
",",
"$",
"related",
"->",
"page",
",",
"$",
"related",
"->",
"perpage",
",",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'page'",
")",
";",
"$",
"htmlpagingbar",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"paging",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generaltable boxaligncenter boxwidthwide'",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'name'",
")",
",",
"get_string",
"(",
"'version'",
",",
"'badges'",
")",
",",
"get_string",
"(",
"'language'",
",",
"'badges'",
")",
",",
"get_string",
"(",
"'type'",
",",
"'badges'",
")",
")",
";",
"if",
"(",
"!",
"$",
"currentbadge",
"->",
"is_active",
"(",
")",
"&&",
"!",
"$",
"currentbadge",
"->",
"is_locked",
"(",
")",
")",
"{",
"array_push",
"(",
"$",
"table",
"->",
"head",
",",
"''",
")",
";",
"}",
"foreach",
"(",
"$",
"related",
"->",
"badges",
"as",
"$",
"badge",
")",
"{",
"$",
"badgeobject",
"=",
"new",
"badge",
"(",
"$",
"badge",
"->",
"id",
")",
";",
"$",
"style",
"=",
"array",
"(",
"'title'",
"=>",
"$",
"badgeobject",
"->",
"name",
")",
";",
"if",
"(",
"!",
"$",
"badgeobject",
"->",
"is_active",
"(",
")",
")",
"{",
"$",
"style",
"[",
"'class'",
"]",
"=",
"'dimmed'",
";",
"}",
"$",
"context",
"=",
"(",
"$",
"badgeobject",
"->",
"type",
"==",
"BADGE_TYPE_SITE",
")",
"?",
"context_system",
"::",
"instance",
"(",
")",
":",
"context_course",
"::",
"instance",
"(",
"$",
"badgeobject",
"->",
"courseid",
")",
";",
"$",
"forlink",
"=",
"print_badge_image",
"(",
"$",
"badgeobject",
",",
"$",
"context",
")",
".",
"' '",
".",
"html_writer",
"::",
"start_tag",
"(",
"'span'",
")",
".",
"$",
"badgeobject",
"->",
"name",
".",
"html_writer",
"::",
"end_tag",
"(",
"'span'",
")",
";",
"$",
"name",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/badges/overview.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"badgeobject",
"->",
"id",
")",
")",
",",
"$",
"forlink",
",",
"$",
"style",
")",
";",
"$",
"row",
"=",
"array",
"(",
"$",
"name",
",",
"$",
"badge",
"->",
"version",
",",
"$",
"badge",
"->",
"language",
"?",
"$",
"languages",
"[",
"$",
"badge",
"->",
"language",
"]",
":",
"''",
",",
"$",
"badge",
"->",
"type",
"==",
"BADGE_TYPE_COURSE",
"?",
"get_string",
"(",
"'badgesview'",
",",
"'badges'",
")",
":",
"get_string",
"(",
"'sitebadges'",
",",
"'badges'",
")",
")",
";",
"if",
"(",
"!",
"$",
"currentbadge",
"->",
"is_active",
"(",
")",
"&&",
"!",
"$",
"currentbadge",
"->",
"is_locked",
"(",
")",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"new",
"moodle_url",
"(",
"'related_action.php'",
",",
"array",
"(",
"'badgeid'",
"=>",
"$",
"related",
"->",
"currentbadgeid",
",",
"'relatedid'",
"=>",
"$",
"badge",
"->",
"id",
",",
"'action'",
"=>",
"'remove'",
")",
")",
",",
"new",
"pix_icon",
"(",
"'t/delete'",
",",
"get_string",
"(",
"'delete'",
")",
")",
")",
";",
"$",
"actions",
"=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"action",
",",
"array",
"(",
"'class'",
"=>",
"'badge-actions'",
")",
")",
";",
"array_push",
"(",
"$",
"row",
",",
"$",
"actions",
")",
";",
"}",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"htmltable",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"htmlpagingbar",
".",
"$",
"htmltable",
".",
"$",
"htmlpagingbar",
";",
"}"
] | Renders a table for related badges.
@param badge_related $related list related badges.
@return string list related badges to output. | [
"Renders",
"a",
"table",
"for",
"related",
"badges",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1134-L1186 |
213,729 | moodle/moodle | badges/renderer.php | core_badges_renderer.render_badge_alignments | protected function render_badge_alignments(badge_alignments $alignments) {
$currentbadge = new badge($alignments->currentbadgeid);
$paging = new paging_bar($alignments->totalcount, $alignments->page, $alignments->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$table->head = array('Name', 'URL', '');
foreach ($alignments->alignments as $item) {
$urlaligment = new moodle_url('alignment.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
)
);
$row = array(
html_writer::link($urlaligment, $item->targetname),
html_writer::link($item->targeturl, $item->targeturl, array('target' => '_blank'))
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
$delete = $this->output->action_icon(
new moodle_url('alignment_action.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'action' => 'remove'
)
), new pix_icon('t/delete', get_string('delete')));
$edit = $this->output->action_icon(
new moodle_url('alignment.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'action' => 'edit'
)
), new pix_icon('t/edit', get_string('edit')));
$actions = html_writer::tag('div', $edit . $delete, array('class' => 'badge-actions'));
array_push($row, $actions);
}
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | php | protected function render_badge_alignments(badge_alignments $alignments) {
$currentbadge = new badge($alignments->currentbadgeid);
$paging = new paging_bar($alignments->totalcount, $alignments->page, $alignments->perpage, $this->page->url, 'page');
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'generaltable boxaligncenter boxwidthwide';
$table->head = array('Name', 'URL', '');
foreach ($alignments->alignments as $item) {
$urlaligment = new moodle_url('alignment.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
)
);
$row = array(
html_writer::link($urlaligment, $item->targetname),
html_writer::link($item->targeturl, $item->targeturl, array('target' => '_blank'))
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
$delete = $this->output->action_icon(
new moodle_url('alignment_action.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'action' => 'remove'
)
), new pix_icon('t/delete', get_string('delete')));
$edit = $this->output->action_icon(
new moodle_url('alignment.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'action' => 'edit'
)
), new pix_icon('t/edit', get_string('edit')));
$actions = html_writer::tag('div', $edit . $delete, array('class' => 'badge-actions'));
array_push($row, $actions);
}
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlpagingbar . $htmltable . $htmlpagingbar;
} | [
"protected",
"function",
"render_badge_alignments",
"(",
"badge_alignments",
"$",
"alignments",
")",
"{",
"$",
"currentbadge",
"=",
"new",
"badge",
"(",
"$",
"alignments",
"->",
"currentbadgeid",
")",
";",
"$",
"paging",
"=",
"new",
"paging_bar",
"(",
"$",
"alignments",
"->",
"totalcount",
",",
"$",
"alignments",
"->",
"page",
",",
"$",
"alignments",
"->",
"perpage",
",",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'page'",
")",
";",
"$",
"htmlpagingbar",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"paging",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generaltable boxaligncenter boxwidthwide'",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"'Name'",
",",
"'URL'",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"alignments",
"->",
"alignments",
"as",
"$",
"item",
")",
"{",
"$",
"urlaligment",
"=",
"new",
"moodle_url",
"(",
"'alignment.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"currentbadge",
"->",
"id",
",",
"'alignmentid'",
"=>",
"$",
"item",
"->",
"id",
",",
")",
")",
";",
"$",
"row",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"urlaligment",
",",
"$",
"item",
"->",
"targetname",
")",
",",
"html_writer",
"::",
"link",
"(",
"$",
"item",
"->",
"targeturl",
",",
"$",
"item",
"->",
"targeturl",
",",
"array",
"(",
"'target'",
"=>",
"'_blank'",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"currentbadge",
"->",
"is_active",
"(",
")",
"&&",
"!",
"$",
"currentbadge",
"->",
"is_locked",
"(",
")",
")",
"{",
"$",
"delete",
"=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"new",
"moodle_url",
"(",
"'alignment_action.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"currentbadge",
"->",
"id",
",",
"'alignmentid'",
"=>",
"$",
"item",
"->",
"id",
",",
"'action'",
"=>",
"'remove'",
")",
")",
",",
"new",
"pix_icon",
"(",
"'t/delete'",
",",
"get_string",
"(",
"'delete'",
")",
")",
")",
";",
"$",
"edit",
"=",
"$",
"this",
"->",
"output",
"->",
"action_icon",
"(",
"new",
"moodle_url",
"(",
"'alignment.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"currentbadge",
"->",
"id",
",",
"'alignmentid'",
"=>",
"$",
"item",
"->",
"id",
",",
"'action'",
"=>",
"'edit'",
")",
")",
",",
"new",
"pix_icon",
"(",
"'t/edit'",
",",
"get_string",
"(",
"'edit'",
")",
")",
")",
";",
"$",
"actions",
"=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"edit",
".",
"$",
"delete",
",",
"array",
"(",
"'class'",
"=>",
"'badge-actions'",
")",
")",
";",
"array_push",
"(",
"$",
"row",
",",
"$",
"actions",
")",
";",
"}",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"htmltable",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"htmlpagingbar",
".",
"$",
"htmltable",
".",
"$",
"htmlpagingbar",
";",
"}"
] | Renders a table with alignment.
@param badge_alignments $alignments List alignments.
@return string List alignment to output. | [
"Renders",
"a",
"table",
"with",
"alignment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/badges/renderer.php#L1194-L1238 |
213,730 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.get_quickgrading_html | public function get_quickgrading_html($userid, $grade) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
$pluginname = get_string('pluginname', 'assignfeedback_comments');
$labeloptions = array('for'=>'quickgrade_comments_' . $userid,
'class'=>'accesshide');
$textareaoptions = array('name'=>'quickgrade_comments_' . $userid,
'id'=>'quickgrade_comments_' . $userid,
'class'=>'quickgrade');
return html_writer::tag('label', $pluginname, $labeloptions) .
html_writer::tag('textarea', $commenttext, $textareaoptions);
} | php | public function get_quickgrading_html($userid, $grade) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
$pluginname = get_string('pluginname', 'assignfeedback_comments');
$labeloptions = array('for'=>'quickgrade_comments_' . $userid,
'class'=>'accesshide');
$textareaoptions = array('name'=>'quickgrade_comments_' . $userid,
'id'=>'quickgrade_comments_' . $userid,
'class'=>'quickgrade');
return html_writer::tag('label', $pluginname, $labeloptions) .
html_writer::tag('textarea', $commenttext, $textareaoptions);
} | [
"public",
"function",
"get_quickgrading_html",
"(",
"$",
"userid",
",",
"$",
"grade",
")",
"{",
"$",
"commenttext",
"=",
"''",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomments",
")",
"{",
"$",
"commenttext",
"=",
"$",
"feedbackcomments",
"->",
"commenttext",
";",
"}",
"}",
"$",
"pluginname",
"=",
"get_string",
"(",
"'pluginname'",
",",
"'assignfeedback_comments'",
")",
";",
"$",
"labeloptions",
"=",
"array",
"(",
"'for'",
"=>",
"'quickgrade_comments_'",
".",
"$",
"userid",
",",
"'class'",
"=>",
"'accesshide'",
")",
";",
"$",
"textareaoptions",
"=",
"array",
"(",
"'name'",
"=>",
"'quickgrade_comments_'",
".",
"$",
"userid",
",",
"'id'",
"=>",
"'quickgrade_comments_'",
".",
"$",
"userid",
",",
"'class'",
"=>",
"'quickgrade'",
")",
";",
"return",
"html_writer",
"::",
"tag",
"(",
"'label'",
",",
"$",
"pluginname",
",",
"$",
"labeloptions",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'textarea'",
",",
"$",
"commenttext",
",",
"$",
"textareaoptions",
")",
";",
"}"
] | Get quickgrading form elements as html.
@param int $userid The user id in the table this quickgrading element relates to
@param mixed $grade - The grade data - may be null if there are no grades for this user (yet)
@return mixed - A html string containing the html form elements required for quickgrading | [
"Get",
"quickgrading",
"form",
"elements",
"as",
"html",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L69-L86 |
213,731 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.is_quickgrading_modified | public function is_quickgrading_modified($userid, $grade) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
// Note that this handles the difference between empty and not in the quickgrading
// form at all (hidden column).
$newvalue = optional_param('quickgrade_comments_' . $userid, false, PARAM_RAW);
return ($newvalue !== false) && ($newvalue != $commenttext);
} | php | public function is_quickgrading_modified($userid, $grade) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
// Note that this handles the difference between empty and not in the quickgrading
// form at all (hidden column).
$newvalue = optional_param('quickgrade_comments_' . $userid, false, PARAM_RAW);
return ($newvalue !== false) && ($newvalue != $commenttext);
} | [
"public",
"function",
"is_quickgrading_modified",
"(",
"$",
"userid",
",",
"$",
"grade",
")",
"{",
"$",
"commenttext",
"=",
"''",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomments",
")",
"{",
"$",
"commenttext",
"=",
"$",
"feedbackcomments",
"->",
"commenttext",
";",
"}",
"}",
"// Note that this handles the difference between empty and not in the quickgrading",
"// form at all (hidden column).",
"$",
"newvalue",
"=",
"optional_param",
"(",
"'quickgrade_comments_'",
".",
"$",
"userid",
",",
"false",
",",
"PARAM_RAW",
")",
";",
"return",
"(",
"$",
"newvalue",
"!==",
"false",
")",
"&&",
"(",
"$",
"newvalue",
"!=",
"$",
"commenttext",
")",
";",
"}"
] | Has the plugin quickgrading form element been modified in the current form submission?
@param int $userid The user id in the table this quickgrading element relates to
@param stdClass $grade The grade
@return boolean - true if the quickgrading form element has been modified | [
"Has",
"the",
"plugin",
"quickgrading",
"form",
"element",
"been",
"modified",
"in",
"the",
"current",
"form",
"submission?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L95-L107 |
213,732 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.is_feedback_modified | public function is_feedback_modified(stdClass $grade, stdClass $data) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
$formtext = $data->assignfeedbackcomments_editor['text'];
// Need to convert the form text to use @@PLUGINFILE@@ and format it so we can compare it with what is stored in the DB.
if (isset($data->assignfeedbackcomments_editor['itemid'])) {
$formtext = file_rewrite_urls_to_pluginfile($formtext, $data->assignfeedbackcomments_editor['itemid']);
$formtext = format_text($formtext, FORMAT_HTML);
}
if ($commenttext == $formtext) {
return false;
} else {
return true;
}
} | php | public function is_feedback_modified(stdClass $grade, stdClass $data) {
$commenttext = '';
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
$commenttext = $feedbackcomments->commenttext;
}
}
$formtext = $data->assignfeedbackcomments_editor['text'];
// Need to convert the form text to use @@PLUGINFILE@@ and format it so we can compare it with what is stored in the DB.
if (isset($data->assignfeedbackcomments_editor['itemid'])) {
$formtext = file_rewrite_urls_to_pluginfile($formtext, $data->assignfeedbackcomments_editor['itemid']);
$formtext = format_text($formtext, FORMAT_HTML);
}
if ($commenttext == $formtext) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"is_feedback_modified",
"(",
"stdClass",
"$",
"grade",
",",
"stdClass",
"$",
"data",
")",
"{",
"$",
"commenttext",
"=",
"''",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomments",
")",
"{",
"$",
"commenttext",
"=",
"$",
"feedbackcomments",
"->",
"commenttext",
";",
"}",
"}",
"$",
"formtext",
"=",
"$",
"data",
"->",
"assignfeedbackcomments_editor",
"[",
"'text'",
"]",
";",
"// Need to convert the form text to use @@PLUGINFILE@@ and format it so we can compare it with what is stored in the DB.",
"if",
"(",
"isset",
"(",
"$",
"data",
"->",
"assignfeedbackcomments_editor",
"[",
"'itemid'",
"]",
")",
")",
"{",
"$",
"formtext",
"=",
"file_rewrite_urls_to_pluginfile",
"(",
"$",
"formtext",
",",
"$",
"data",
"->",
"assignfeedbackcomments_editor",
"[",
"'itemid'",
"]",
")",
";",
"$",
"formtext",
"=",
"format_text",
"(",
"$",
"formtext",
",",
"FORMAT_HTML",
")",
";",
"}",
"if",
"(",
"$",
"commenttext",
"==",
"$",
"formtext",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Has the comment feedback been modified?
@param stdClass $grade The grade object.
@param stdClass $data Data from the form submission.
@return boolean True if the comment feedback has been modified, else false. | [
"Has",
"the",
"comment",
"feedback",
"been",
"modified?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L116-L138 |
213,733 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.save_quickgrading_changes | public function save_quickgrading_changes($userid, $grade) {
global $DB;
$feedbackcomment = $this->get_feedback_comments($grade->id);
$quickgradecomments = optional_param('quickgrade_comments_' . $userid, null, PARAM_RAW);
if (!$quickgradecomments && $quickgradecomments !== '') {
return true;
}
if ($feedbackcomment) {
$feedbackcomment->commenttext = $quickgradecomments;
return $DB->update_record('assignfeedback_comments', $feedbackcomment);
} else {
$feedbackcomment = new stdClass();
$feedbackcomment->commenttext = $quickgradecomments;
$feedbackcomment->commentformat = FORMAT_HTML;
$feedbackcomment->grade = $grade->id;
$feedbackcomment->assignment = $this->assignment->get_instance()->id;
return $DB->insert_record('assignfeedback_comments', $feedbackcomment) > 0;
}
} | php | public function save_quickgrading_changes($userid, $grade) {
global $DB;
$feedbackcomment = $this->get_feedback_comments($grade->id);
$quickgradecomments = optional_param('quickgrade_comments_' . $userid, null, PARAM_RAW);
if (!$quickgradecomments && $quickgradecomments !== '') {
return true;
}
if ($feedbackcomment) {
$feedbackcomment->commenttext = $quickgradecomments;
return $DB->update_record('assignfeedback_comments', $feedbackcomment);
} else {
$feedbackcomment = new stdClass();
$feedbackcomment->commenttext = $quickgradecomments;
$feedbackcomment->commentformat = FORMAT_HTML;
$feedbackcomment->grade = $grade->id;
$feedbackcomment->assignment = $this->assignment->get_instance()->id;
return $DB->insert_record('assignfeedback_comments', $feedbackcomment) > 0;
}
} | [
"public",
"function",
"save_quickgrading_changes",
"(",
"$",
"userid",
",",
"$",
"grade",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"feedbackcomment",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"$",
"quickgradecomments",
"=",
"optional_param",
"(",
"'quickgrade_comments_'",
".",
"$",
"userid",
",",
"null",
",",
"PARAM_RAW",
")",
";",
"if",
"(",
"!",
"$",
"quickgradecomments",
"&&",
"$",
"quickgradecomments",
"!==",
"''",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"feedbackcomment",
")",
"{",
"$",
"feedbackcomment",
"->",
"commenttext",
"=",
"$",
"quickgradecomments",
";",
"return",
"$",
"DB",
"->",
"update_record",
"(",
"'assignfeedback_comments'",
",",
"$",
"feedbackcomment",
")",
";",
"}",
"else",
"{",
"$",
"feedbackcomment",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"feedbackcomment",
"->",
"commenttext",
"=",
"$",
"quickgradecomments",
";",
"$",
"feedbackcomment",
"->",
"commentformat",
"=",
"FORMAT_HTML",
";",
"$",
"feedbackcomment",
"->",
"grade",
"=",
"$",
"grade",
"->",
"id",
";",
"$",
"feedbackcomment",
"->",
"assignment",
"=",
"$",
"this",
"->",
"assignment",
"->",
"get_instance",
"(",
")",
"->",
"id",
";",
"return",
"$",
"DB",
"->",
"insert_record",
"(",
"'assignfeedback_comments'",
",",
"$",
"feedbackcomment",
")",
">",
"0",
";",
"}",
"}"
] | Save quickgrading changes.
@param int $userid The user id in the table this quickgrading element relates to
@param stdClass $grade The grade
@return boolean - true if the grade changes were saved correctly | [
"Save",
"quickgrading",
"changes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L213-L231 |
213,734 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.get_settings | public function get_settings(MoodleQuickForm $mform) {
$default = $this->get_config('commentinline');
if ($default === false) {
// Apply the admin default if we don't have a value yet.
$default = get_config('assignfeedback_comments', 'inline');
}
$mform->addElement('selectyesno',
'assignfeedback_comments_commentinline',
get_string('commentinline', 'assignfeedback_comments'));
$mform->addHelpButton('assignfeedback_comments_commentinline', 'commentinline', 'assignfeedback_comments');
$mform->setDefault('assignfeedback_comments_commentinline', $default);
// Disable comment online if comment feedback plugin is disabled.
$mform->hideIf('assignfeedback_comments_commentinline', 'assignfeedback_comments_enabled', 'notchecked');
} | php | public function get_settings(MoodleQuickForm $mform) {
$default = $this->get_config('commentinline');
if ($default === false) {
// Apply the admin default if we don't have a value yet.
$default = get_config('assignfeedback_comments', 'inline');
}
$mform->addElement('selectyesno',
'assignfeedback_comments_commentinline',
get_string('commentinline', 'assignfeedback_comments'));
$mform->addHelpButton('assignfeedback_comments_commentinline', 'commentinline', 'assignfeedback_comments');
$mform->setDefault('assignfeedback_comments_commentinline', $default);
// Disable comment online if comment feedback plugin is disabled.
$mform->hideIf('assignfeedback_comments_commentinline', 'assignfeedback_comments_enabled', 'notchecked');
} | [
"public",
"function",
"get_settings",
"(",
"MoodleQuickForm",
"$",
"mform",
")",
"{",
"$",
"default",
"=",
"$",
"this",
"->",
"get_config",
"(",
"'commentinline'",
")",
";",
"if",
"(",
"$",
"default",
"===",
"false",
")",
"{",
"// Apply the admin default if we don't have a value yet.",
"$",
"default",
"=",
"get_config",
"(",
"'assignfeedback_comments'",
",",
"'inline'",
")",
";",
"}",
"$",
"mform",
"->",
"addElement",
"(",
"'selectyesno'",
",",
"'assignfeedback_comments_commentinline'",
",",
"get_string",
"(",
"'commentinline'",
",",
"'assignfeedback_comments'",
")",
")",
";",
"$",
"mform",
"->",
"addHelpButton",
"(",
"'assignfeedback_comments_commentinline'",
",",
"'commentinline'",
",",
"'assignfeedback_comments'",
")",
";",
"$",
"mform",
"->",
"setDefault",
"(",
"'assignfeedback_comments_commentinline'",
",",
"$",
"default",
")",
";",
"// Disable comment online if comment feedback plugin is disabled.",
"$",
"mform",
"->",
"hideIf",
"(",
"'assignfeedback_comments_commentinline'",
",",
"'assignfeedback_comments_enabled'",
",",
"'notchecked'",
")",
";",
"}"
] | Get the default setting for feedback comments plugin
@param MoodleQuickForm $mform The form to add elements to
@return void | [
"Get",
"the",
"default",
"setting",
"for",
"feedback",
"comments",
"plugin"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L250-L263 |
213,735 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.convert_submission_text_to_feedback | protected function convert_submission_text_to_feedback($submission, $data, $grade) {
global $DB;
$format = false;
$text = '';
foreach ($this->assignment->get_submission_plugins() as $plugin) {
$fields = $plugin->get_editor_fields();
if ($plugin->is_enabled() && $plugin->is_visible() && !$plugin->is_empty($submission) && !empty($fields)) {
$user = $DB->get_record('user', ['id' => $submission->userid]);
// Copy the files to the feedback area.
if ($files = $plugin->get_files($submission, $user)) {
$fs = get_file_storage();
$component = 'assignfeedback_comments';
$filearea = ASSIGNFEEDBACK_COMMENTS_FILEAREA;
$itemid = $grade->id;
$fieldupdates = [
'component' => $component,
'filearea' => $filearea,
'itemid' => $itemid
];
foreach ($files as $file) {
if ($file instanceof stored_file) {
// Before we create it, check that it doesn't already exist.
if (!$fs->file_exists(
$file->get_contextid(),
$component,
$filearea,
$itemid,
$file->get_filepath(),
$file->get_filename())) {
$fs->create_file_from_storedfile($fieldupdates, $file);
}
}
}
}
foreach ($fields as $key => $description) {
$rawtext = clean_text($plugin->get_editor_text($key, $submission->id));
$newformat = $plugin->get_editor_format($key, $submission->id);
if ($format !== false && $newformat != $format) {
// There are 2 or more editor fields using different formats, set to plain as a fallback.
$format = FORMAT_PLAIN;
} else {
$format = $newformat;
}
$text .= $rawtext;
}
}
}
if ($format === false) {
$format = FORMAT_HTML;
}
$data->assignfeedbackcomments = $text;
$data->assignfeedbackcommentsformat = $format;
return true;
} | php | protected function convert_submission_text_to_feedback($submission, $data, $grade) {
global $DB;
$format = false;
$text = '';
foreach ($this->assignment->get_submission_plugins() as $plugin) {
$fields = $plugin->get_editor_fields();
if ($plugin->is_enabled() && $plugin->is_visible() && !$plugin->is_empty($submission) && !empty($fields)) {
$user = $DB->get_record('user', ['id' => $submission->userid]);
// Copy the files to the feedback area.
if ($files = $plugin->get_files($submission, $user)) {
$fs = get_file_storage();
$component = 'assignfeedback_comments';
$filearea = ASSIGNFEEDBACK_COMMENTS_FILEAREA;
$itemid = $grade->id;
$fieldupdates = [
'component' => $component,
'filearea' => $filearea,
'itemid' => $itemid
];
foreach ($files as $file) {
if ($file instanceof stored_file) {
// Before we create it, check that it doesn't already exist.
if (!$fs->file_exists(
$file->get_contextid(),
$component,
$filearea,
$itemid,
$file->get_filepath(),
$file->get_filename())) {
$fs->create_file_from_storedfile($fieldupdates, $file);
}
}
}
}
foreach ($fields as $key => $description) {
$rawtext = clean_text($plugin->get_editor_text($key, $submission->id));
$newformat = $plugin->get_editor_format($key, $submission->id);
if ($format !== false && $newformat != $format) {
// There are 2 or more editor fields using different formats, set to plain as a fallback.
$format = FORMAT_PLAIN;
} else {
$format = $newformat;
}
$text .= $rawtext;
}
}
}
if ($format === false) {
$format = FORMAT_HTML;
}
$data->assignfeedbackcomments = $text;
$data->assignfeedbackcommentsformat = $format;
return true;
} | [
"protected",
"function",
"convert_submission_text_to_feedback",
"(",
"$",
"submission",
",",
"$",
"data",
",",
"$",
"grade",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"format",
"=",
"false",
";",
"$",
"text",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"assignment",
"->",
"get_submission_plugins",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"$",
"fields",
"=",
"$",
"plugin",
"->",
"get_editor_fields",
"(",
")",
";",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
"&&",
"!",
"$",
"plugin",
"->",
"is_empty",
"(",
"$",
"submission",
")",
"&&",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"[",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
"]",
")",
";",
"// Copy the files to the feedback area.",
"if",
"(",
"$",
"files",
"=",
"$",
"plugin",
"->",
"get_files",
"(",
"$",
"submission",
",",
"$",
"user",
")",
")",
"{",
"$",
"fs",
"=",
"get_file_storage",
"(",
")",
";",
"$",
"component",
"=",
"'assignfeedback_comments'",
";",
"$",
"filearea",
"=",
"ASSIGNFEEDBACK_COMMENTS_FILEAREA",
";",
"$",
"itemid",
"=",
"$",
"grade",
"->",
"id",
";",
"$",
"fieldupdates",
"=",
"[",
"'component'",
"=>",
"$",
"component",
",",
"'filearea'",
"=>",
"$",
"filearea",
",",
"'itemid'",
"=>",
"$",
"itemid",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"instanceof",
"stored_file",
")",
"{",
"// Before we create it, check that it doesn't already exist.",
"if",
"(",
"!",
"$",
"fs",
"->",
"file_exists",
"(",
"$",
"file",
"->",
"get_contextid",
"(",
")",
",",
"$",
"component",
",",
"$",
"filearea",
",",
"$",
"itemid",
",",
"$",
"file",
"->",
"get_filepath",
"(",
")",
",",
"$",
"file",
"->",
"get_filename",
"(",
")",
")",
")",
"{",
"$",
"fs",
"->",
"create_file_from_storedfile",
"(",
"$",
"fieldupdates",
",",
"$",
"file",
")",
";",
"}",
"}",
"}",
"}",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"description",
")",
"{",
"$",
"rawtext",
"=",
"clean_text",
"(",
"$",
"plugin",
"->",
"get_editor_text",
"(",
"$",
"key",
",",
"$",
"submission",
"->",
"id",
")",
")",
";",
"$",
"newformat",
"=",
"$",
"plugin",
"->",
"get_editor_format",
"(",
"$",
"key",
",",
"$",
"submission",
"->",
"id",
")",
";",
"if",
"(",
"$",
"format",
"!==",
"false",
"&&",
"$",
"newformat",
"!=",
"$",
"format",
")",
"{",
"// There are 2 or more editor fields using different formats, set to plain as a fallback.",
"$",
"format",
"=",
"FORMAT_PLAIN",
";",
"}",
"else",
"{",
"$",
"format",
"=",
"$",
"newformat",
";",
"}",
"$",
"text",
".=",
"$",
"rawtext",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"format",
"===",
"false",
")",
"{",
"$",
"format",
"=",
"FORMAT_HTML",
";",
"}",
"$",
"data",
"->",
"assignfeedbackcomments",
"=",
"$",
"text",
";",
"$",
"data",
"->",
"assignfeedbackcommentsformat",
"=",
"$",
"format",
";",
"return",
"true",
";",
"}"
] | Convert the text from any submission plugin that has an editor field to
a format suitable for inserting in the feedback text field.
@param stdClass $submission
@param stdClass $data - Form data to be filled with the converted submission text and format.
@param stdClass|null $grade
@return boolean - True if feedback text was set. | [
"Convert",
"the",
"text",
"from",
"any",
"submission",
"plugin",
"that",
"has",
"an",
"editor",
"field",
"to",
"a",
"format",
"suitable",
"for",
"inserting",
"in",
"the",
"feedback",
"text",
"field",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L274-L332 |
213,736 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.get_form_elements_for_user | public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) {
$commentinlinenabled = $this->get_config('commentinline');
$submission = $this->assignment->get_user_submission($userid, false);
$feedbackcomments = false;
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
}
if ($feedbackcomments && !empty($feedbackcomments->commenttext)) {
$data->assignfeedbackcomments = $feedbackcomments->commenttext;
$data->assignfeedbackcommentsformat = $feedbackcomments->commentformat;
} else {
// No feedback given yet - maybe we need to copy the text from the submission?
if (!empty($commentinlinenabled) && $submission) {
$this->convert_submission_text_to_feedback($submission, $data, $grade);
} else { // Set it to empty.
$data->assignfeedbackcomments = '';
$data->assignfeedbackcommentsformat = FORMAT_HTML;
}
}
file_prepare_standard_editor(
$data,
'assignfeedbackcomments',
$this->get_editor_options(),
$this->assignment->get_context(),
ASSIGNFEEDBACK_COMMENTS_COMPONENT,
ASSIGNFEEDBACK_COMMENTS_FILEAREA,
$grade->id
);
$mform->addElement('editor', 'assignfeedbackcomments_editor', $this->get_name(), null, $this->get_editor_options());
return true;
} | php | public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) {
$commentinlinenabled = $this->get_config('commentinline');
$submission = $this->assignment->get_user_submission($userid, false);
$feedbackcomments = false;
if ($grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
}
if ($feedbackcomments && !empty($feedbackcomments->commenttext)) {
$data->assignfeedbackcomments = $feedbackcomments->commenttext;
$data->assignfeedbackcommentsformat = $feedbackcomments->commentformat;
} else {
// No feedback given yet - maybe we need to copy the text from the submission?
if (!empty($commentinlinenabled) && $submission) {
$this->convert_submission_text_to_feedback($submission, $data, $grade);
} else { // Set it to empty.
$data->assignfeedbackcomments = '';
$data->assignfeedbackcommentsformat = FORMAT_HTML;
}
}
file_prepare_standard_editor(
$data,
'assignfeedbackcomments',
$this->get_editor_options(),
$this->assignment->get_context(),
ASSIGNFEEDBACK_COMMENTS_COMPONENT,
ASSIGNFEEDBACK_COMMENTS_FILEAREA,
$grade->id
);
$mform->addElement('editor', 'assignfeedbackcomments_editor', $this->get_name(), null, $this->get_editor_options());
return true;
} | [
"public",
"function",
"get_form_elements_for_user",
"(",
"$",
"grade",
",",
"MoodleQuickForm",
"$",
"mform",
",",
"stdClass",
"$",
"data",
",",
"$",
"userid",
")",
"{",
"$",
"commentinlinenabled",
"=",
"$",
"this",
"->",
"get_config",
"(",
"'commentinline'",
")",
";",
"$",
"submission",
"=",
"$",
"this",
"->",
"assignment",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"$",
"feedbackcomments",
"=",
"false",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"}",
"if",
"(",
"$",
"feedbackcomments",
"&&",
"!",
"empty",
"(",
"$",
"feedbackcomments",
"->",
"commenttext",
")",
")",
"{",
"$",
"data",
"->",
"assignfeedbackcomments",
"=",
"$",
"feedbackcomments",
"->",
"commenttext",
";",
"$",
"data",
"->",
"assignfeedbackcommentsformat",
"=",
"$",
"feedbackcomments",
"->",
"commentformat",
";",
"}",
"else",
"{",
"// No feedback given yet - maybe we need to copy the text from the submission?",
"if",
"(",
"!",
"empty",
"(",
"$",
"commentinlinenabled",
")",
"&&",
"$",
"submission",
")",
"{",
"$",
"this",
"->",
"convert_submission_text_to_feedback",
"(",
"$",
"submission",
",",
"$",
"data",
",",
"$",
"grade",
")",
";",
"}",
"else",
"{",
"// Set it to empty.",
"$",
"data",
"->",
"assignfeedbackcomments",
"=",
"''",
";",
"$",
"data",
"->",
"assignfeedbackcommentsformat",
"=",
"FORMAT_HTML",
";",
"}",
"}",
"file_prepare_standard_editor",
"(",
"$",
"data",
",",
"'assignfeedbackcomments'",
",",
"$",
"this",
"->",
"get_editor_options",
"(",
")",
",",
"$",
"this",
"->",
"assignment",
"->",
"get_context",
"(",
")",
",",
"ASSIGNFEEDBACK_COMMENTS_COMPONENT",
",",
"ASSIGNFEEDBACK_COMMENTS_FILEAREA",
",",
"$",
"grade",
"->",
"id",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'editor'",
",",
"'assignfeedbackcomments_editor'",
",",
"$",
"this",
"->",
"get_name",
"(",
")",
",",
"null",
",",
"$",
"this",
"->",
"get_editor_options",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] | Get form elements for the grading page
@param stdClass|null $grade
@param MoodleQuickForm $mform
@param stdClass $data
@return bool true if elements were added to the form | [
"Get",
"form",
"elements",
"for",
"the",
"grading",
"page"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L342-L377 |
213,737 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.save | public function save(stdClass $grade, stdClass $data) {
global $DB;
// Save the files.
$data = file_postupdate_standard_editor(
$data,
'assignfeedbackcomments',
$this->get_editor_options(),
$this->assignment->get_context(),
ASSIGNFEEDBACK_COMMENTS_COMPONENT,
ASSIGNFEEDBACK_COMMENTS_FILEAREA,
$grade->id
);
$feedbackcomment = $this->get_feedback_comments($grade->id);
if ($feedbackcomment) {
$feedbackcomment->commenttext = $data->assignfeedbackcomments;
$feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
return $DB->update_record('assignfeedback_comments', $feedbackcomment);
} else {
$feedbackcomment = new stdClass();
$feedbackcomment->commenttext = $data->assignfeedbackcomments;
$feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
$feedbackcomment->grade = $grade->id;
$feedbackcomment->assignment = $this->assignment->get_instance()->id;
return $DB->insert_record('assignfeedback_comments', $feedbackcomment) > 0;
}
} | php | public function save(stdClass $grade, stdClass $data) {
global $DB;
// Save the files.
$data = file_postupdate_standard_editor(
$data,
'assignfeedbackcomments',
$this->get_editor_options(),
$this->assignment->get_context(),
ASSIGNFEEDBACK_COMMENTS_COMPONENT,
ASSIGNFEEDBACK_COMMENTS_FILEAREA,
$grade->id
);
$feedbackcomment = $this->get_feedback_comments($grade->id);
if ($feedbackcomment) {
$feedbackcomment->commenttext = $data->assignfeedbackcomments;
$feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
return $DB->update_record('assignfeedback_comments', $feedbackcomment);
} else {
$feedbackcomment = new stdClass();
$feedbackcomment->commenttext = $data->assignfeedbackcomments;
$feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
$feedbackcomment->grade = $grade->id;
$feedbackcomment->assignment = $this->assignment->get_instance()->id;
return $DB->insert_record('assignfeedback_comments', $feedbackcomment) > 0;
}
} | [
"public",
"function",
"save",
"(",
"stdClass",
"$",
"grade",
",",
"stdClass",
"$",
"data",
")",
"{",
"global",
"$",
"DB",
";",
"// Save the files.",
"$",
"data",
"=",
"file_postupdate_standard_editor",
"(",
"$",
"data",
",",
"'assignfeedbackcomments'",
",",
"$",
"this",
"->",
"get_editor_options",
"(",
")",
",",
"$",
"this",
"->",
"assignment",
"->",
"get_context",
"(",
")",
",",
"ASSIGNFEEDBACK_COMMENTS_COMPONENT",
",",
"ASSIGNFEEDBACK_COMMENTS_FILEAREA",
",",
"$",
"grade",
"->",
"id",
")",
";",
"$",
"feedbackcomment",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomment",
")",
"{",
"$",
"feedbackcomment",
"->",
"commenttext",
"=",
"$",
"data",
"->",
"assignfeedbackcomments",
";",
"$",
"feedbackcomment",
"->",
"commentformat",
"=",
"$",
"data",
"->",
"assignfeedbackcommentsformat",
";",
"return",
"$",
"DB",
"->",
"update_record",
"(",
"'assignfeedback_comments'",
",",
"$",
"feedbackcomment",
")",
";",
"}",
"else",
"{",
"$",
"feedbackcomment",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"feedbackcomment",
"->",
"commenttext",
"=",
"$",
"data",
"->",
"assignfeedbackcomments",
";",
"$",
"feedbackcomment",
"->",
"commentformat",
"=",
"$",
"data",
"->",
"assignfeedbackcommentsformat",
";",
"$",
"feedbackcomment",
"->",
"grade",
"=",
"$",
"grade",
"->",
"id",
";",
"$",
"feedbackcomment",
"->",
"assignment",
"=",
"$",
"this",
"->",
"assignment",
"->",
"get_instance",
"(",
")",
"->",
"id",
";",
"return",
"$",
"DB",
"->",
"insert_record",
"(",
"'assignfeedback_comments'",
",",
"$",
"feedbackcomment",
")",
">",
"0",
";",
"}",
"}"
] | Saving the comment content into database.
@param stdClass $grade
@param stdClass $data
@return bool | [
"Saving",
"the",
"comment",
"content",
"into",
"database",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L386-L413 |
213,738 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.upgrade | public function upgrade(context $oldcontext,
stdClass $oldassignment,
stdClass $oldsubmission,
stdClass $grade,
& $log) {
global $DB;
$feedbackcomments = new stdClass();
$feedbackcomments->commenttext = $oldsubmission->submissioncomment;
$feedbackcomments->commentformat = FORMAT_HTML;
$feedbackcomments->grade = $grade->id;
$feedbackcomments->assignment = $this->assignment->get_instance()->id;
if (!$DB->insert_record('assignfeedback_comments', $feedbackcomments) > 0) {
$log .= get_string('couldnotconvertgrade', 'mod_assign', $grade->userid);
return false;
}
return true;
} | php | public function upgrade(context $oldcontext,
stdClass $oldassignment,
stdClass $oldsubmission,
stdClass $grade,
& $log) {
global $DB;
$feedbackcomments = new stdClass();
$feedbackcomments->commenttext = $oldsubmission->submissioncomment;
$feedbackcomments->commentformat = FORMAT_HTML;
$feedbackcomments->grade = $grade->id;
$feedbackcomments->assignment = $this->assignment->get_instance()->id;
if (!$DB->insert_record('assignfeedback_comments', $feedbackcomments) > 0) {
$log .= get_string('couldnotconvertgrade', 'mod_assign', $grade->userid);
return false;
}
return true;
} | [
"public",
"function",
"upgrade",
"(",
"context",
"$",
"oldcontext",
",",
"stdClass",
"$",
"oldassignment",
",",
"stdClass",
"$",
"oldsubmission",
",",
"stdClass",
"$",
"grade",
",",
"&",
"$",
"log",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"feedbackcomments",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"feedbackcomments",
"->",
"commenttext",
"=",
"$",
"oldsubmission",
"->",
"submissioncomment",
";",
"$",
"feedbackcomments",
"->",
"commentformat",
"=",
"FORMAT_HTML",
";",
"$",
"feedbackcomments",
"->",
"grade",
"=",
"$",
"grade",
"->",
"id",
";",
"$",
"feedbackcomments",
"->",
"assignment",
"=",
"$",
"this",
"->",
"assignment",
"->",
"get_instance",
"(",
")",
"->",
"id",
";",
"if",
"(",
"!",
"$",
"DB",
"->",
"insert_record",
"(",
"'assignfeedback_comments'",
",",
"$",
"feedbackcomments",
")",
">",
"0",
")",
"{",
"$",
"log",
".=",
"get_string",
"(",
"'couldnotconvertgrade'",
",",
"'mod_assign'",
",",
"$",
"grade",
"->",
"userid",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Upgrade the feedback from the old assignment to the new one
@param context $oldcontext - the database for the old assignment context
@param stdClass $oldassignment The data record for the old assignment
@param stdClass $oldsubmission The data record for the old submission
@param stdClass $grade The data record for the new grade
@param string $log Record upgrade messages in the log
@return bool true or false - false will trigger a rollback | [
"Upgrade",
"the",
"feedback",
"from",
"the",
"old",
"assignment",
"to",
"the",
"new",
"one"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L508-L527 |
213,739 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.format_for_gradebook | public function format_for_gradebook(stdClass $grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
return $feedbackcomments->commentformat;
}
return FORMAT_MOODLE;
} | php | public function format_for_gradebook(stdClass $grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
return $feedbackcomments->commentformat;
}
return FORMAT_MOODLE;
} | [
"public",
"function",
"format_for_gradebook",
"(",
"stdClass",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomments",
")",
"{",
"return",
"$",
"feedbackcomments",
"->",
"commentformat",
";",
"}",
"return",
"FORMAT_MOODLE",
";",
"}"
] | If this plugin adds to the gradebook comments field, it must specify the format of the text
of the comment
Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment
settings page.
@param stdClass $grade The grade
@return int | [
"If",
"this",
"plugin",
"adds",
"to",
"the",
"gradebook",
"comments",
"field",
"it",
"must",
"specify",
"the",
"format",
"of",
"the",
"text",
"of",
"the",
"comment"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L539-L545 |
213,740 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.text_for_gradebook | public function text_for_gradebook(stdClass $grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
return $feedbackcomments->commenttext;
}
return '';
} | php | public function text_for_gradebook(stdClass $grade) {
$feedbackcomments = $this->get_feedback_comments($grade->id);
if ($feedbackcomments) {
return $feedbackcomments->commenttext;
}
return '';
} | [
"public",
"function",
"text_for_gradebook",
"(",
"stdClass",
"$",
"grade",
")",
"{",
"$",
"feedbackcomments",
"=",
"$",
"this",
"->",
"get_feedback_comments",
"(",
"$",
"grade",
"->",
"id",
")",
";",
"if",
"(",
"$",
"feedbackcomments",
")",
"{",
"return",
"$",
"feedbackcomments",
"->",
"commenttext",
";",
"}",
"return",
"''",
";",
"}"
] | If this plugin adds to the gradebook comments field, it must format the text
of the comment
Only one feedback plugin can push comments to the gradebook and that is chosen by the assignment
settings page.
@param stdClass $grade The grade
@return string | [
"If",
"this",
"plugin",
"adds",
"to",
"the",
"gradebook",
"comments",
"field",
"it",
"must",
"format",
"the",
"text",
"of",
"the",
"comment"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L557-L563 |
213,741 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.files_for_gradebook | public function files_for_gradebook(stdClass $grade) : array {
return [
'contextid' => $this->assignment->get_context()->id,
'component' => ASSIGNFEEDBACK_COMMENTS_COMPONENT,
'filearea' => ASSIGNFEEDBACK_COMMENTS_FILEAREA,
'itemid' => $grade->id
];
} | php | public function files_for_gradebook(stdClass $grade) : array {
return [
'contextid' => $this->assignment->get_context()->id,
'component' => ASSIGNFEEDBACK_COMMENTS_COMPONENT,
'filearea' => ASSIGNFEEDBACK_COMMENTS_FILEAREA,
'itemid' => $grade->id
];
} | [
"public",
"function",
"files_for_gradebook",
"(",
"stdClass",
"$",
"grade",
")",
":",
"array",
"{",
"return",
"[",
"'contextid'",
"=>",
"$",
"this",
"->",
"assignment",
"->",
"get_context",
"(",
")",
"->",
"id",
",",
"'component'",
"=>",
"ASSIGNFEEDBACK_COMMENTS_COMPONENT",
",",
"'filearea'",
"=>",
"ASSIGNFEEDBACK_COMMENTS_FILEAREA",
",",
"'itemid'",
"=>",
"$",
"grade",
"->",
"id",
"]",
";",
"}"
] | Return any files this plugin wishes to save to the gradebook.
@param stdClass $grade The assign_grades object from the db
@return array | [
"Return",
"any",
"files",
"this",
"plugin",
"wishes",
"to",
"save",
"to",
"the",
"gradebook",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L571-L578 |
213,742 | moodle/moodle | mod/assign/feedback/comments/locallib.php | assign_feedback_comments.get_external_parameters | public function get_external_parameters() {
$editorparams = array('text' => new external_value(PARAM_RAW, 'The text for this feedback.'),
'format' => new external_value(PARAM_INT, 'The format for this feedback'));
$editorstructure = new external_single_structure($editorparams, 'Editor structure', VALUE_OPTIONAL);
return array('assignfeedbackcomments_editor' => $editorstructure);
} | php | public function get_external_parameters() {
$editorparams = array('text' => new external_value(PARAM_RAW, 'The text for this feedback.'),
'format' => new external_value(PARAM_INT, 'The format for this feedback'));
$editorstructure = new external_single_structure($editorparams, 'Editor structure', VALUE_OPTIONAL);
return array('assignfeedbackcomments_editor' => $editorstructure);
} | [
"public",
"function",
"get_external_parameters",
"(",
")",
"{",
"$",
"editorparams",
"=",
"array",
"(",
"'text'",
"=>",
"new",
"external_value",
"(",
"PARAM_RAW",
",",
"'The text for this feedback.'",
")",
",",
"'format'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'The format for this feedback'",
")",
")",
";",
"$",
"editorstructure",
"=",
"new",
"external_single_structure",
"(",
"$",
"editorparams",
",",
"'Editor structure'",
",",
"VALUE_OPTIONAL",
")",
";",
"return",
"array",
"(",
"'assignfeedbackcomments_editor'",
"=>",
"$",
"editorstructure",
")",
";",
"}"
] | Return a description of external params suitable for uploading an feedback comment from a webservice.
@return external_description|null | [
"Return",
"a",
"description",
"of",
"external",
"params",
"suitable",
"for",
"uploading",
"an",
"feedback",
"comment",
"from",
"a",
"webservice",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/comments/locallib.php#L616-L621 |
213,743 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.get_default_tree_structure | private function get_default_tree_structure() {
$frontpage = \context_course::instance(SITEID);
$categorybranches = $this->get_all_category_branches();
$elements = [
'text' => get_string('contextlevelname' . CONTEXT_SYSTEM, 'tool_dataprivacy'),
'contextlevel' => CONTEXT_SYSTEM,
'branches' => [
[
'text' => get_string('user'),
'contextlevel' => CONTEXT_USER,
], [
'text' => get_string('categories'),
'branches' => $categorybranches,
'expandelement' => 'category',
], [
'text' => get_string('frontpagecourse', 'tool_dataprivacy'),
'contextid' => $frontpage->id,
'branches' => [
[
'text' => get_string('activitiesandresources', 'tool_dataprivacy'),
'expandcontextid' => $frontpage->id,
'expandelement' => 'module',
'expanded' => 0,
], [
'text' => get_string('blocks'),
'expandcontextid' => $frontpage->id,
'expandelement' => 'block',
'expanded' => 0,
],
]
]
]
];
// Returned as an array to follow a common array format.
return [self::complete($elements, $this->defaultcontextlevel, $this->defaultcontextid)];
} | php | private function get_default_tree_structure() {
$frontpage = \context_course::instance(SITEID);
$categorybranches = $this->get_all_category_branches();
$elements = [
'text' => get_string('contextlevelname' . CONTEXT_SYSTEM, 'tool_dataprivacy'),
'contextlevel' => CONTEXT_SYSTEM,
'branches' => [
[
'text' => get_string('user'),
'contextlevel' => CONTEXT_USER,
], [
'text' => get_string('categories'),
'branches' => $categorybranches,
'expandelement' => 'category',
], [
'text' => get_string('frontpagecourse', 'tool_dataprivacy'),
'contextid' => $frontpage->id,
'branches' => [
[
'text' => get_string('activitiesandresources', 'tool_dataprivacy'),
'expandcontextid' => $frontpage->id,
'expandelement' => 'module',
'expanded' => 0,
], [
'text' => get_string('blocks'),
'expandcontextid' => $frontpage->id,
'expandelement' => 'block',
'expanded' => 0,
],
]
]
]
];
// Returned as an array to follow a common array format.
return [self::complete($elements, $this->defaultcontextlevel, $this->defaultcontextid)];
} | [
"private",
"function",
"get_default_tree_structure",
"(",
")",
"{",
"$",
"frontpage",
"=",
"\\",
"context_course",
"::",
"instance",
"(",
"SITEID",
")",
";",
"$",
"categorybranches",
"=",
"$",
"this",
"->",
"get_all_category_branches",
"(",
")",
";",
"$",
"elements",
"=",
"[",
"'text'",
"=>",
"get_string",
"(",
"'contextlevelname'",
".",
"CONTEXT_SYSTEM",
",",
"'tool_dataprivacy'",
")",
",",
"'contextlevel'",
"=>",
"CONTEXT_SYSTEM",
",",
"'branches'",
"=>",
"[",
"[",
"'text'",
"=>",
"get_string",
"(",
"'user'",
")",
",",
"'contextlevel'",
"=>",
"CONTEXT_USER",
",",
"]",
",",
"[",
"'text'",
"=>",
"get_string",
"(",
"'categories'",
")",
",",
"'branches'",
"=>",
"$",
"categorybranches",
",",
"'expandelement'",
"=>",
"'category'",
",",
"]",
",",
"[",
"'text'",
"=>",
"get_string",
"(",
"'frontpagecourse'",
",",
"'tool_dataprivacy'",
")",
",",
"'contextid'",
"=>",
"$",
"frontpage",
"->",
"id",
",",
"'branches'",
"=>",
"[",
"[",
"'text'",
"=>",
"get_string",
"(",
"'activitiesandresources'",
",",
"'tool_dataprivacy'",
")",
",",
"'expandcontextid'",
"=>",
"$",
"frontpage",
"->",
"id",
",",
"'expandelement'",
"=>",
"'module'",
",",
"'expanded'",
"=>",
"0",
",",
"]",
",",
"[",
"'text'",
"=>",
"get_string",
"(",
"'blocks'",
")",
",",
"'expandcontextid'",
"=>",
"$",
"frontpage",
"->",
"id",
",",
"'expandelement'",
"=>",
"'block'",
",",
"'expanded'",
"=>",
"0",
",",
"]",
",",
"]",
"]",
"]",
"]",
";",
"// Returned as an array to follow a common array format.",
"return",
"[",
"self",
"::",
"complete",
"(",
"$",
"elements",
",",
"$",
"this",
"->",
"defaultcontextlevel",
",",
"$",
"this",
"->",
"defaultcontextid",
")",
"]",
";",
"}"
] | Returns the tree default structure.
@return array | [
"Returns",
"the",
"tree",
"default",
"structure",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L123-L162 |
213,744 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.get_all_category_branches | private function get_all_category_branches() {
$categories = data_registry::get_site_categories();
$categoriesbranch = [];
while (count($categories) > 0) {
foreach ($categories as $key => $category) {
$context = \context_coursecat::instance($category->id);
$newnode = [
'text' => shorten_text(format_string($category->name, true, ['context' => $context])),
'categoryid' => $category->id,
'contextid' => $context->id,
];
if ($category->coursecount > 0) {
$newnode['branches'] = [
[
'text' => get_string('courses'),
'expandcontextid' => $context->id,
'expandelement' => 'course',
'expanded' => 0,
]
];
}
$added = false;
if ($category->parent == 0) {
// New categories root-level node.
$categoriesbranch[] = $newnode;
$added = true;
} else {
// Add the new node under the appropriate parent.
if ($this->add_to_parent_category_branch($category, $newnode, $categoriesbranch)) {
$added = true;
}
}
if ($added) {
unset($categories[$key]);
}
}
}
return $categoriesbranch;
} | php | private function get_all_category_branches() {
$categories = data_registry::get_site_categories();
$categoriesbranch = [];
while (count($categories) > 0) {
foreach ($categories as $key => $category) {
$context = \context_coursecat::instance($category->id);
$newnode = [
'text' => shorten_text(format_string($category->name, true, ['context' => $context])),
'categoryid' => $category->id,
'contextid' => $context->id,
];
if ($category->coursecount > 0) {
$newnode['branches'] = [
[
'text' => get_string('courses'),
'expandcontextid' => $context->id,
'expandelement' => 'course',
'expanded' => 0,
]
];
}
$added = false;
if ($category->parent == 0) {
// New categories root-level node.
$categoriesbranch[] = $newnode;
$added = true;
} else {
// Add the new node under the appropriate parent.
if ($this->add_to_parent_category_branch($category, $newnode, $categoriesbranch)) {
$added = true;
}
}
if ($added) {
unset($categories[$key]);
}
}
}
return $categoriesbranch;
} | [
"private",
"function",
"get_all_category_branches",
"(",
")",
"{",
"$",
"categories",
"=",
"data_registry",
"::",
"get_site_categories",
"(",
")",
";",
"$",
"categoriesbranch",
"=",
"[",
"]",
";",
"while",
"(",
"count",
"(",
"$",
"categories",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"key",
"=>",
"$",
"category",
")",
"{",
"$",
"context",
"=",
"\\",
"context_coursecat",
"::",
"instance",
"(",
"$",
"category",
"->",
"id",
")",
";",
"$",
"newnode",
"=",
"[",
"'text'",
"=>",
"shorten_text",
"(",
"format_string",
"(",
"$",
"category",
"->",
"name",
",",
"true",
",",
"[",
"'context'",
"=>",
"$",
"context",
"]",
")",
")",
",",
"'categoryid'",
"=>",
"$",
"category",
"->",
"id",
",",
"'contextid'",
"=>",
"$",
"context",
"->",
"id",
",",
"]",
";",
"if",
"(",
"$",
"category",
"->",
"coursecount",
">",
"0",
")",
"{",
"$",
"newnode",
"[",
"'branches'",
"]",
"=",
"[",
"[",
"'text'",
"=>",
"get_string",
"(",
"'courses'",
")",
",",
"'expandcontextid'",
"=>",
"$",
"context",
"->",
"id",
",",
"'expandelement'",
"=>",
"'course'",
",",
"'expanded'",
"=>",
"0",
",",
"]",
"]",
";",
"}",
"$",
"added",
"=",
"false",
";",
"if",
"(",
"$",
"category",
"->",
"parent",
"==",
"0",
")",
"{",
"// New categories root-level node.",
"$",
"categoriesbranch",
"[",
"]",
"=",
"$",
"newnode",
";",
"$",
"added",
"=",
"true",
";",
"}",
"else",
"{",
"// Add the new node under the appropriate parent.",
"if",
"(",
"$",
"this",
"->",
"add_to_parent_category_branch",
"(",
"$",
"category",
",",
"$",
"newnode",
",",
"$",
"categoriesbranch",
")",
")",
"{",
"$",
"added",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"added",
")",
"{",
"unset",
"(",
"$",
"categories",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"categoriesbranch",
";",
"}"
] | Returns the hierarchy of system course categories.
@return array | [
"Returns",
"the",
"hierarchy",
"of",
"system",
"course",
"categories",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L169-L214 |
213,745 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.get_courses_branch | public static function get_courses_branch(\context $catcontext) {
if ($catcontext->contextlevel !== CONTEXT_COURSECAT) {
throw new \coding_exception('A course category context should be provided');
}
$coursecat = \core_course_category::get($catcontext->instanceid);
$courses = $coursecat->get_courses();
$branches = [];
foreach ($courses as $course) {
$coursecontext = \context_course::instance($course->id);
$coursenode = [
'text' => shorten_text(format_string($course->shortname, true, ['context' => $coursecontext])),
'contextid' => $coursecontext->id,
'branches' => [
[
'text' => get_string('activitiesandresources', 'tool_dataprivacy'),
'expandcontextid' => $coursecontext->id,
'expandelement' => 'module',
'expanded' => 0,
], [
'text' => get_string('blocks'),
'expandcontextid' => $coursecontext->id,
'expandelement' => 'block',
'expanded' => 0,
],
]
];
$branches[] = self::complete($coursenode);
}
return $branches;
} | php | public static function get_courses_branch(\context $catcontext) {
if ($catcontext->contextlevel !== CONTEXT_COURSECAT) {
throw new \coding_exception('A course category context should be provided');
}
$coursecat = \core_course_category::get($catcontext->instanceid);
$courses = $coursecat->get_courses();
$branches = [];
foreach ($courses as $course) {
$coursecontext = \context_course::instance($course->id);
$coursenode = [
'text' => shorten_text(format_string($course->shortname, true, ['context' => $coursecontext])),
'contextid' => $coursecontext->id,
'branches' => [
[
'text' => get_string('activitiesandresources', 'tool_dataprivacy'),
'expandcontextid' => $coursecontext->id,
'expandelement' => 'module',
'expanded' => 0,
], [
'text' => get_string('blocks'),
'expandcontextid' => $coursecontext->id,
'expandelement' => 'block',
'expanded' => 0,
],
]
];
$branches[] = self::complete($coursenode);
}
return $branches;
} | [
"public",
"static",
"function",
"get_courses_branch",
"(",
"\\",
"context",
"$",
"catcontext",
")",
"{",
"if",
"(",
"$",
"catcontext",
"->",
"contextlevel",
"!==",
"CONTEXT_COURSECAT",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'A course category context should be provided'",
")",
";",
"}",
"$",
"coursecat",
"=",
"\\",
"core_course_category",
"::",
"get",
"(",
"$",
"catcontext",
"->",
"instanceid",
")",
";",
"$",
"courses",
"=",
"$",
"coursecat",
"->",
"get_courses",
"(",
")",
";",
"$",
"branches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"courses",
"as",
"$",
"course",
")",
"{",
"$",
"coursecontext",
"=",
"\\",
"context_course",
"::",
"instance",
"(",
"$",
"course",
"->",
"id",
")",
";",
"$",
"coursenode",
"=",
"[",
"'text'",
"=>",
"shorten_text",
"(",
"format_string",
"(",
"$",
"course",
"->",
"shortname",
",",
"true",
",",
"[",
"'context'",
"=>",
"$",
"coursecontext",
"]",
")",
")",
",",
"'contextid'",
"=>",
"$",
"coursecontext",
"->",
"id",
",",
"'branches'",
"=>",
"[",
"[",
"'text'",
"=>",
"get_string",
"(",
"'activitiesandresources'",
",",
"'tool_dataprivacy'",
")",
",",
"'expandcontextid'",
"=>",
"$",
"coursecontext",
"->",
"id",
",",
"'expandelement'",
"=>",
"'module'",
",",
"'expanded'",
"=>",
"0",
",",
"]",
",",
"[",
"'text'",
"=>",
"get_string",
"(",
"'blocks'",
")",
",",
"'expandcontextid'",
"=>",
"$",
"coursecontext",
"->",
"id",
",",
"'expandelement'",
"=>",
"'block'",
",",
"'expanded'",
"=>",
"0",
",",
"]",
",",
"]",
"]",
";",
"$",
"branches",
"[",
"]",
"=",
"self",
"::",
"complete",
"(",
"$",
"coursenode",
")",
";",
"}",
"return",
"$",
"branches",
";",
"}"
] | Gets the courses branch for the provided category.
@param \context $catcontext
@return array | [
"Gets",
"the",
"courses",
"branch",
"for",
"the",
"provided",
"category",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L222-L258 |
213,746 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.get_modules_branch | public static function get_modules_branch(\context $coursecontext) {
if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
throw new \coding_exception('A course context should be provided');
}
$branches = [];
// Using the current user.
$modinfo = get_fast_modinfo($coursecontext->instanceid);
foreach ($modinfo->get_instances() as $moduletype => $instances) {
foreach ($instances as $cm) {
if (!$cm->uservisible) {
continue;
}
$a = (object)[
'instancename' => shorten_text($cm->get_formatted_name()),
'modulename' => get_string('pluginname', 'mod_' . $moduletype),
];
$text = get_string('moduleinstancename', 'tool_dataprivacy', $a);
$branches[] = self::complete([
'text' => $text,
'contextid' => $cm->context->id,
]);
}
}
return $branches;
} | php | public static function get_modules_branch(\context $coursecontext) {
if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
throw new \coding_exception('A course context should be provided');
}
$branches = [];
// Using the current user.
$modinfo = get_fast_modinfo($coursecontext->instanceid);
foreach ($modinfo->get_instances() as $moduletype => $instances) {
foreach ($instances as $cm) {
if (!$cm->uservisible) {
continue;
}
$a = (object)[
'instancename' => shorten_text($cm->get_formatted_name()),
'modulename' => get_string('pluginname', 'mod_' . $moduletype),
];
$text = get_string('moduleinstancename', 'tool_dataprivacy', $a);
$branches[] = self::complete([
'text' => $text,
'contextid' => $cm->context->id,
]);
}
}
return $branches;
} | [
"public",
"static",
"function",
"get_modules_branch",
"(",
"\\",
"context",
"$",
"coursecontext",
")",
"{",
"if",
"(",
"$",
"coursecontext",
"->",
"contextlevel",
"!==",
"CONTEXT_COURSE",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'A course context should be provided'",
")",
";",
"}",
"$",
"branches",
"=",
"[",
"]",
";",
"// Using the current user.",
"$",
"modinfo",
"=",
"get_fast_modinfo",
"(",
"$",
"coursecontext",
"->",
"instanceid",
")",
";",
"foreach",
"(",
"$",
"modinfo",
"->",
"get_instances",
"(",
")",
"as",
"$",
"moduletype",
"=>",
"$",
"instances",
")",
"{",
"foreach",
"(",
"$",
"instances",
"as",
"$",
"cm",
")",
"{",
"if",
"(",
"!",
"$",
"cm",
"->",
"uservisible",
")",
"{",
"continue",
";",
"}",
"$",
"a",
"=",
"(",
"object",
")",
"[",
"'instancename'",
"=>",
"shorten_text",
"(",
"$",
"cm",
"->",
"get_formatted_name",
"(",
")",
")",
",",
"'modulename'",
"=>",
"get_string",
"(",
"'pluginname'",
",",
"'mod_'",
".",
"$",
"moduletype",
")",
",",
"]",
";",
"$",
"text",
"=",
"get_string",
"(",
"'moduleinstancename'",
",",
"'tool_dataprivacy'",
",",
"$",
"a",
")",
";",
"$",
"branches",
"[",
"]",
"=",
"self",
"::",
"complete",
"(",
"[",
"'text'",
"=>",
"$",
"text",
",",
"'contextid'",
"=>",
"$",
"cm",
"->",
"context",
"->",
"id",
",",
"]",
")",
";",
"}",
"}",
"return",
"$",
"branches",
";",
"}"
] | Gets the modules branch for the provided course.
@param \context $coursecontext
@return array | [
"Gets",
"the",
"modules",
"branch",
"for",
"the",
"provided",
"course",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L266-L297 |
213,747 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.get_blocks_branch | public static function get_blocks_branch(\context $coursecontext) {
global $DB;
if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
throw new \coding_exception('A course context should be provided');
}
$branches = [];
$children = $coursecontext->get_child_contexts();
foreach ($children as $childcontext) {
if ($childcontext->contextlevel !== CONTEXT_BLOCK) {
continue;
}
$blockinstance = block_instance_by_id($childcontext->instanceid);
$displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $childcontext]));
$branches[] = self::complete([
'text' => $displayname,
'contextid' => $childcontext->id,
]);
}
return $branches;
} | php | public static function get_blocks_branch(\context $coursecontext) {
global $DB;
if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
throw new \coding_exception('A course context should be provided');
}
$branches = [];
$children = $coursecontext->get_child_contexts();
foreach ($children as $childcontext) {
if ($childcontext->contextlevel !== CONTEXT_BLOCK) {
continue;
}
$blockinstance = block_instance_by_id($childcontext->instanceid);
$displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $childcontext]));
$branches[] = self::complete([
'text' => $displayname,
'contextid' => $childcontext->id,
]);
}
return $branches;
} | [
"public",
"static",
"function",
"get_blocks_branch",
"(",
"\\",
"context",
"$",
"coursecontext",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"coursecontext",
"->",
"contextlevel",
"!==",
"CONTEXT_COURSE",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'A course context should be provided'",
")",
";",
"}",
"$",
"branches",
"=",
"[",
"]",
";",
"$",
"children",
"=",
"$",
"coursecontext",
"->",
"get_child_contexts",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"childcontext",
")",
"{",
"if",
"(",
"$",
"childcontext",
"->",
"contextlevel",
"!==",
"CONTEXT_BLOCK",
")",
"{",
"continue",
";",
"}",
"$",
"blockinstance",
"=",
"block_instance_by_id",
"(",
"$",
"childcontext",
"->",
"instanceid",
")",
";",
"$",
"displayname",
"=",
"shorten_text",
"(",
"format_string",
"(",
"$",
"blockinstance",
"->",
"get_title",
"(",
")",
",",
"true",
",",
"[",
"'context'",
"=>",
"$",
"childcontext",
"]",
")",
")",
";",
"$",
"branches",
"[",
"]",
"=",
"self",
"::",
"complete",
"(",
"[",
"'text'",
"=>",
"$",
"displayname",
",",
"'contextid'",
"=>",
"$",
"childcontext",
"->",
"id",
",",
"]",
")",
";",
"}",
"return",
"$",
"branches",
";",
"}"
] | Gets the blocks branch for the provided course.
@param \context $coursecontext
@return null | [
"Gets",
"the",
"blocks",
"branch",
"for",
"the",
"provided",
"course",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L305-L331 |
213,748 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.add_to_parent_category_branch | private function add_to_parent_category_branch($category, $newnode, &$categoriesbranch) {
foreach ($categoriesbranch as $key => $branch) {
if (!empty($branch['categoryid']) && $branch['categoryid'] == $category->parent) {
// It may be empty (if it does not contain courses and this is the first child cat).
if (!isset($categoriesbranch[$key]['branches'])) {
$categoriesbranch[$key]['branches'] = [];
}
$categoriesbranch[$key]['branches'][] = $newnode;
return true;
}
if (!empty($branch['branches'])) {
$parent = $this->add_to_parent_category_branch($category, $newnode, $categoriesbranch[$key]['branches']);
if ($parent) {
return true;
}
}
}
return false;
} | php | private function add_to_parent_category_branch($category, $newnode, &$categoriesbranch) {
foreach ($categoriesbranch as $key => $branch) {
if (!empty($branch['categoryid']) && $branch['categoryid'] == $category->parent) {
// It may be empty (if it does not contain courses and this is the first child cat).
if (!isset($categoriesbranch[$key]['branches'])) {
$categoriesbranch[$key]['branches'] = [];
}
$categoriesbranch[$key]['branches'][] = $newnode;
return true;
}
if (!empty($branch['branches'])) {
$parent = $this->add_to_parent_category_branch($category, $newnode, $categoriesbranch[$key]['branches']);
if ($parent) {
return true;
}
}
}
return false;
} | [
"private",
"function",
"add_to_parent_category_branch",
"(",
"$",
"category",
",",
"$",
"newnode",
",",
"&",
"$",
"categoriesbranch",
")",
"{",
"foreach",
"(",
"$",
"categoriesbranch",
"as",
"$",
"key",
"=>",
"$",
"branch",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"branch",
"[",
"'categoryid'",
"]",
")",
"&&",
"$",
"branch",
"[",
"'categoryid'",
"]",
"==",
"$",
"category",
"->",
"parent",
")",
"{",
"// It may be empty (if it does not contain courses and this is the first child cat).",
"if",
"(",
"!",
"isset",
"(",
"$",
"categoriesbranch",
"[",
"$",
"key",
"]",
"[",
"'branches'",
"]",
")",
")",
"{",
"$",
"categoriesbranch",
"[",
"$",
"key",
"]",
"[",
"'branches'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"categoriesbranch",
"[",
"$",
"key",
"]",
"[",
"'branches'",
"]",
"[",
"]",
"=",
"$",
"newnode",
";",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"branch",
"[",
"'branches'",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"add_to_parent_category_branch",
"(",
"$",
"category",
",",
"$",
"newnode",
",",
"$",
"categoriesbranch",
"[",
"$",
"key",
"]",
"[",
"'branches'",
"]",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Adds the provided category to the categories branch.
@param stdClass $category
@param array $newnode
@param array $categoriesbranch
@return bool | [
"Adds",
"the",
"provided",
"category",
"to",
"the",
"categories",
"branch",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L341-L361 |
213,749 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.complete | private static function complete($node, $currentcontextlevel = false, $currentcontextid = false) {
if (!isset($node['active'])) {
if ($currentcontextlevel && !empty($node['contextlevel']) &&
$currentcontextlevel == $node['contextlevel'] &&
empty($currentcontextid)) {
// This is the active context level, we also checked that there
// is no default contextid set.
$node['active'] = true;
} else if ($currentcontextid && !empty($node['contextid']) &&
$currentcontextid == $node['contextid']) {
$node['active'] = true;
} else {
$node['active'] = null;
}
}
if (!isset($node['branches'])) {
$node['branches'] = [];
} else {
foreach ($node['branches'] as $key => $childnode) {
$node['branches'][$key] = self::complete($childnode, $currentcontextlevel, $currentcontextid);
}
}
if (!isset($node['expandelement'])) {
$node['expandelement'] = null;
}
if (!isset($node['expandcontextid'])) {
$node['expandcontextid'] = null;
}
if (!isset($node['contextid'])) {
$node['contextid'] = null;
}
if (!isset($node['contextlevel'])) {
$node['contextlevel'] = null;
}
if (!isset($node['expanded'])) {
if (!empty($node['branches'])) {
$node['expanded'] = 1;
} else {
$node['expanded'] = 0;
}
}
return $node;
} | php | private static function complete($node, $currentcontextlevel = false, $currentcontextid = false) {
if (!isset($node['active'])) {
if ($currentcontextlevel && !empty($node['contextlevel']) &&
$currentcontextlevel == $node['contextlevel'] &&
empty($currentcontextid)) {
// This is the active context level, we also checked that there
// is no default contextid set.
$node['active'] = true;
} else if ($currentcontextid && !empty($node['contextid']) &&
$currentcontextid == $node['contextid']) {
$node['active'] = true;
} else {
$node['active'] = null;
}
}
if (!isset($node['branches'])) {
$node['branches'] = [];
} else {
foreach ($node['branches'] as $key => $childnode) {
$node['branches'][$key] = self::complete($childnode, $currentcontextlevel, $currentcontextid);
}
}
if (!isset($node['expandelement'])) {
$node['expandelement'] = null;
}
if (!isset($node['expandcontextid'])) {
$node['expandcontextid'] = null;
}
if (!isset($node['contextid'])) {
$node['contextid'] = null;
}
if (!isset($node['contextlevel'])) {
$node['contextlevel'] = null;
}
if (!isset($node['expanded'])) {
if (!empty($node['branches'])) {
$node['expanded'] = 1;
} else {
$node['expanded'] = 0;
}
}
return $node;
} | [
"private",
"static",
"function",
"complete",
"(",
"$",
"node",
",",
"$",
"currentcontextlevel",
"=",
"false",
",",
"$",
"currentcontextid",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'active'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"currentcontextlevel",
"&&",
"!",
"empty",
"(",
"$",
"node",
"[",
"'contextlevel'",
"]",
")",
"&&",
"$",
"currentcontextlevel",
"==",
"$",
"node",
"[",
"'contextlevel'",
"]",
"&&",
"empty",
"(",
"$",
"currentcontextid",
")",
")",
"{",
"// This is the active context level, we also checked that there",
"// is no default contextid set.",
"$",
"node",
"[",
"'active'",
"]",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"$",
"currentcontextid",
"&&",
"!",
"empty",
"(",
"$",
"node",
"[",
"'contextid'",
"]",
")",
"&&",
"$",
"currentcontextid",
"==",
"$",
"node",
"[",
"'contextid'",
"]",
")",
"{",
"$",
"node",
"[",
"'active'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"node",
"[",
"'active'",
"]",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'branches'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'branches'",
"]",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"node",
"[",
"'branches'",
"]",
"as",
"$",
"key",
"=>",
"$",
"childnode",
")",
"{",
"$",
"node",
"[",
"'branches'",
"]",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"complete",
"(",
"$",
"childnode",
",",
"$",
"currentcontextlevel",
",",
"$",
"currentcontextid",
")",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'expandelement'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'expandelement'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'expandcontextid'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'expandcontextid'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'contextid'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'contextid'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'contextlevel'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'contextlevel'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"'expanded'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"[",
"'branches'",
"]",
")",
")",
"{",
"$",
"node",
"[",
"'expanded'",
"]",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"node",
"[",
"'expanded'",
"]",
"=",
"0",
";",
"}",
"}",
"return",
"$",
"node",
";",
"}"
] | Completes tree nodes with default values.
@param array $node
@param int|false $currentcontextlevel
@param int|false $currentcontextid
@return array | [
"Completes",
"tree",
"nodes",
"with",
"default",
"values",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L371-L419 |
213,750 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.purpose_options | public static function purpose_options($purposes, $includenotset = true, $includeinherit = true) {
$options = self::base_options($includenotset, $includeinherit);
foreach ($purposes as $purpose) {
$options[$purpose->get('id')] = $purpose->get('name');
}
return $options;
} | php | public static function purpose_options($purposes, $includenotset = true, $includeinherit = true) {
$options = self::base_options($includenotset, $includeinherit);
foreach ($purposes as $purpose) {
$options[$purpose->get('id')] = $purpose->get('name');
}
return $options;
} | [
"public",
"static",
"function",
"purpose_options",
"(",
"$",
"purposes",
",",
"$",
"includenotset",
"=",
"true",
",",
"$",
"includeinherit",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"self",
"::",
"base_options",
"(",
"$",
"includenotset",
",",
"$",
"includeinherit",
")",
";",
"foreach",
"(",
"$",
"purposes",
"as",
"$",
"purpose",
")",
"{",
"$",
"options",
"[",
"$",
"purpose",
"->",
"get",
"(",
"'id'",
")",
"]",
"=",
"$",
"purpose",
"->",
"get",
"(",
"'name'",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | From a list of purpose persistents to a list of id => name purposes.
@param \tool_dataprivacy\purpose[] $purposes
@param bool $includenotset
@param bool $includeinherit
@return string[] | [
"From",
"a",
"list",
"of",
"purpose",
"persistents",
"to",
"a",
"list",
"of",
"id",
"=",
">",
"name",
"purposes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L429-L436 |
213,751 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.category_options | public static function category_options($categories, $includenotset = true, $includeinherit = true) {
$options = self::base_options($includenotset, $includeinherit);
foreach ($categories as $category) {
$options[$category->get('id')] = $category->get('name');
}
return $options;
} | php | public static function category_options($categories, $includenotset = true, $includeinherit = true) {
$options = self::base_options($includenotset, $includeinherit);
foreach ($categories as $category) {
$options[$category->get('id')] = $category->get('name');
}
return $options;
} | [
"public",
"static",
"function",
"category_options",
"(",
"$",
"categories",
",",
"$",
"includenotset",
"=",
"true",
",",
"$",
"includeinherit",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"self",
"::",
"base_options",
"(",
"$",
"includenotset",
",",
"$",
"includeinherit",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"options",
"[",
"$",
"category",
"->",
"get",
"(",
"'id'",
")",
"]",
"=",
"$",
"category",
"->",
"get",
"(",
"'name'",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | From a list of category persistents to a list of id => name categories.
@param \tool_dataprivacy\category[] $categories
@param bool $includenotset
@param bool $includeinherit
@return string[] | [
"From",
"a",
"list",
"of",
"category",
"persistents",
"to",
"a",
"list",
"of",
"id",
"=",
">",
"name",
"categories",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L446-L453 |
213,752 | moodle/moodle | admin/tool/dataprivacy/classes/output/data_registry_page.php | data_registry_page.base_options | private static function base_options($includenotset = true, $includeinherit = true) {
$options = [];
if ($includenotset) {
$options[\tool_dataprivacy\context_instance::NOTSET] = get_string('notset', 'tool_dataprivacy');
}
if ($includeinherit) {
$options[\tool_dataprivacy\context_instance::INHERIT] = get_string('inherit', 'tool_dataprivacy');
}
return $options;
} | php | private static function base_options($includenotset = true, $includeinherit = true) {
$options = [];
if ($includenotset) {
$options[\tool_dataprivacy\context_instance::NOTSET] = get_string('notset', 'tool_dataprivacy');
}
if ($includeinherit) {
$options[\tool_dataprivacy\context_instance::INHERIT] = get_string('inherit', 'tool_dataprivacy');
}
return $options;
} | [
"private",
"static",
"function",
"base_options",
"(",
"$",
"includenotset",
"=",
"true",
",",
"$",
"includeinherit",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"includenotset",
")",
"{",
"$",
"options",
"[",
"\\",
"tool_dataprivacy",
"\\",
"context_instance",
"::",
"NOTSET",
"]",
"=",
"get_string",
"(",
"'notset'",
",",
"'tool_dataprivacy'",
")",
";",
"}",
"if",
"(",
"$",
"includeinherit",
")",
"{",
"$",
"options",
"[",
"\\",
"tool_dataprivacy",
"\\",
"context_instance",
"::",
"INHERIT",
"]",
"=",
"get_string",
"(",
"'inherit'",
",",
"'tool_dataprivacy'",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | Base not set and inherit options.
@param bool $includenotset
@param bool $includeinherit
@return array | [
"Base",
"not",
"set",
"and",
"inherit",
"options",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/data_registry_page.php#L462-L475 |
213,753 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.reset_database | public static function reset_database() {
global $DB;
if (!is_null(self::$lastdbwrites) and self::$lastdbwrites == $DB->perf_get_writes()) {
return false;
}
if (!parent::reset_database()) {
return false;
}
self::$lastdbwrites = $DB->perf_get_writes();
return true;
} | php | public static function reset_database() {
global $DB;
if (!is_null(self::$lastdbwrites) and self::$lastdbwrites == $DB->perf_get_writes()) {
return false;
}
if (!parent::reset_database()) {
return false;
}
self::$lastdbwrites = $DB->perf_get_writes();
return true;
} | [
"public",
"static",
"function",
"reset_database",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"lastdbwrites",
")",
"and",
"self",
"::",
"$",
"lastdbwrites",
"==",
"$",
"DB",
"->",
"perf_get_writes",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"parent",
"::",
"reset_database",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"$",
"lastdbwrites",
"=",
"$",
"DB",
"->",
"perf_get_writes",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Reset all database tables to default values.
@static
@return bool true if reset done, false if skipped | [
"Reset",
"all",
"database",
"tables",
"to",
"default",
"values",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L302-L316 |
213,754 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.bootstrap_init | public static function bootstrap_init() {
global $CFG, $SITE, $DB, $FULLME;
// backup the globals
self::$globals['_SERVER'] = $_SERVER;
self::$globals['CFG'] = clone($CFG);
self::$globals['SITE'] = clone($SITE);
self::$globals['DB'] = $DB;
self::$globals['FULLME'] = $FULLME;
// refresh data in all tables, clear caches, etc.
self::reset_all_data();
} | php | public static function bootstrap_init() {
global $CFG, $SITE, $DB, $FULLME;
// backup the globals
self::$globals['_SERVER'] = $_SERVER;
self::$globals['CFG'] = clone($CFG);
self::$globals['SITE'] = clone($SITE);
self::$globals['DB'] = $DB;
self::$globals['FULLME'] = $FULLME;
// refresh data in all tables, clear caches, etc.
self::reset_all_data();
} | [
"public",
"static",
"function",
"bootstrap_init",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"SITE",
",",
"$",
"DB",
",",
"$",
"FULLME",
";",
"// backup the globals",
"self",
"::",
"$",
"globals",
"[",
"'_SERVER'",
"]",
"=",
"$",
"_SERVER",
";",
"self",
"::",
"$",
"globals",
"[",
"'CFG'",
"]",
"=",
"clone",
"(",
"$",
"CFG",
")",
";",
"self",
"::",
"$",
"globals",
"[",
"'SITE'",
"]",
"=",
"clone",
"(",
"$",
"SITE",
")",
";",
"self",
"::",
"$",
"globals",
"[",
"'DB'",
"]",
"=",
"$",
"DB",
";",
"self",
"::",
"$",
"globals",
"[",
"'FULLME'",
"]",
"=",
"$",
"FULLME",
";",
"// refresh data in all tables, clear caches, etc.",
"self",
"::",
"reset_all_data",
"(",
")",
";",
"}"
] | Called during bootstrap only!
@internal
@static
@return void | [
"Called",
"during",
"bootstrap",
"only!"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L324-L336 |
213,755 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.get_global_backup | public static function get_global_backup($name) {
if ($name === 'DB') {
// no cloning of database object,
// we just need the original reference, not original state
return self::$globals['DB'];
}
if (isset(self::$globals[$name])) {
if (is_object(self::$globals[$name])) {
$return = clone(self::$globals[$name]);
return $return;
} else {
return self::$globals[$name];
}
}
return null;
} | php | public static function get_global_backup($name) {
if ($name === 'DB') {
// no cloning of database object,
// we just need the original reference, not original state
return self::$globals['DB'];
}
if (isset(self::$globals[$name])) {
if (is_object(self::$globals[$name])) {
$return = clone(self::$globals[$name]);
return $return;
} else {
return self::$globals[$name];
}
}
return null;
} | [
"public",
"static",
"function",
"get_global_backup",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'DB'",
")",
"{",
"// no cloning of database object,",
"// we just need the original reference, not original state",
"return",
"self",
"::",
"$",
"globals",
"[",
"'DB'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"globals",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"self",
"::",
"$",
"globals",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"return",
"=",
"clone",
"(",
"self",
"::",
"$",
"globals",
"[",
"$",
"name",
"]",
")",
";",
"return",
"$",
"return",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"globals",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns original state of global variable.
@static
@param string $name
@return mixed | [
"Returns",
"original",
"state",
"of",
"global",
"variable",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L354-L369 |
213,756 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.drop_site | public static function drop_site($displayprogress = false) {
global $DB, $CFG;
if (!self::is_test_site()) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not drop non-test site!!');
}
// Purge dataroot
if ($displayprogress) {
echo "Purging dataroot:\n";
}
self::reset_dataroot();
testing_initdataroot($CFG->dataroot, 'phpunit');
// Drop all tables.
self::drop_database($displayprogress);
// Drop dataroot.
self::drop_dataroot();
} | php | public static function drop_site($displayprogress = false) {
global $DB, $CFG;
if (!self::is_test_site()) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not drop non-test site!!');
}
// Purge dataroot
if ($displayprogress) {
echo "Purging dataroot:\n";
}
self::reset_dataroot();
testing_initdataroot($CFG->dataroot, 'phpunit');
// Drop all tables.
self::drop_database($displayprogress);
// Drop dataroot.
self::drop_dataroot();
} | [
"public",
"static",
"function",
"drop_site",
"(",
"$",
"displayprogress",
"=",
"false",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"if",
"(",
"!",
"self",
"::",
"is_test_site",
"(",
")",
")",
"{",
"phpunit_bootstrap_error",
"(",
"PHPUNIT_EXITCODE_CONFIGERROR",
",",
"'Can not drop non-test site!!'",
")",
";",
"}",
"// Purge dataroot",
"if",
"(",
"$",
"displayprogress",
")",
"{",
"echo",
"\"Purging dataroot:\\n\"",
";",
"}",
"self",
"::",
"reset_dataroot",
"(",
")",
";",
"testing_initdataroot",
"(",
"$",
"CFG",
"->",
"dataroot",
",",
"'phpunit'",
")",
";",
"// Drop all tables.",
"self",
"::",
"drop_database",
"(",
"$",
"displayprogress",
")",
";",
"// Drop dataroot.",
"self",
"::",
"drop_dataroot",
"(",
")",
";",
"}"
] | Drop all test site data.
Note: To be used from CLI scripts only.
@static
@param bool $displayprogress if true, this method will echo progress information.
@return void may terminate execution with exit code | [
"Drop",
"all",
"test",
"site",
"data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L411-L431 |
213,757 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.install_site | public static function install_site() {
global $DB, $CFG;
if (!self::is_test_site()) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not install on non-test site!!');
}
if ($DB->get_tables()) {
list($errorcode, $message) = self::testing_ready_problem();
if ($errorcode) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_REINSTALL, 'Database tables already present, Moodle PHPUnit test environment can not be initialised');
} else {
phpunit_bootstrap_error(0, 'Moodle PHPUnit test environment is already initialised');
}
}
$options = array();
$options['adminpass'] = 'admin';
$options['shortname'] = 'phpunit';
$options['fullname'] = 'PHPUnit test site';
install_cli_database($options, false);
// Set the admin email address.
$DB->set_field('user', 'email', 'admin@example.com', array('username' => 'admin'));
// Disable all logging for performance and sanity reasons.
set_config('enabled_stores', '', 'tool_log');
// We need to keep the installed dataroot filedir files.
// So each time we reset the dataroot before running a test, the default files are still installed.
self::save_original_data_files();
// Store version hash in the database and in a file.
self::store_versions_hash();
// Store database data and structure.
self::store_database_state();
} | php | public static function install_site() {
global $DB, $CFG;
if (!self::is_test_site()) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGERROR, 'Can not install on non-test site!!');
}
if ($DB->get_tables()) {
list($errorcode, $message) = self::testing_ready_problem();
if ($errorcode) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_REINSTALL, 'Database tables already present, Moodle PHPUnit test environment can not be initialised');
} else {
phpunit_bootstrap_error(0, 'Moodle PHPUnit test environment is already initialised');
}
}
$options = array();
$options['adminpass'] = 'admin';
$options['shortname'] = 'phpunit';
$options['fullname'] = 'PHPUnit test site';
install_cli_database($options, false);
// Set the admin email address.
$DB->set_field('user', 'email', 'admin@example.com', array('username' => 'admin'));
// Disable all logging for performance and sanity reasons.
set_config('enabled_stores', '', 'tool_log');
// We need to keep the installed dataroot filedir files.
// So each time we reset the dataroot before running a test, the default files are still installed.
self::save_original_data_files();
// Store version hash in the database and in a file.
self::store_versions_hash();
// Store database data and structure.
self::store_database_state();
} | [
"public",
"static",
"function",
"install_site",
"(",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"if",
"(",
"!",
"self",
"::",
"is_test_site",
"(",
")",
")",
"{",
"phpunit_bootstrap_error",
"(",
"PHPUNIT_EXITCODE_CONFIGERROR",
",",
"'Can not install on non-test site!!'",
")",
";",
"}",
"if",
"(",
"$",
"DB",
"->",
"get_tables",
"(",
")",
")",
"{",
"list",
"(",
"$",
"errorcode",
",",
"$",
"message",
")",
"=",
"self",
"::",
"testing_ready_problem",
"(",
")",
";",
"if",
"(",
"$",
"errorcode",
")",
"{",
"phpunit_bootstrap_error",
"(",
"PHPUNIT_EXITCODE_REINSTALL",
",",
"'Database tables already present, Moodle PHPUnit test environment can not be initialised'",
")",
";",
"}",
"else",
"{",
"phpunit_bootstrap_error",
"(",
"0",
",",
"'Moodle PHPUnit test environment is already initialised'",
")",
";",
"}",
"}",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"options",
"[",
"'adminpass'",
"]",
"=",
"'admin'",
";",
"$",
"options",
"[",
"'shortname'",
"]",
"=",
"'phpunit'",
";",
"$",
"options",
"[",
"'fullname'",
"]",
"=",
"'PHPUnit test site'",
";",
"install_cli_database",
"(",
"$",
"options",
",",
"false",
")",
";",
"// Set the admin email address.",
"$",
"DB",
"->",
"set_field",
"(",
"'user'",
",",
"'email'",
",",
"'admin@example.com'",
",",
"array",
"(",
"'username'",
"=>",
"'admin'",
")",
")",
";",
"// Disable all logging for performance and sanity reasons.",
"set_config",
"(",
"'enabled_stores'",
",",
"''",
",",
"'tool_log'",
")",
";",
"// We need to keep the installed dataroot filedir files.",
"// So each time we reset the dataroot before running a test, the default files are still installed.",
"self",
"::",
"save_original_data_files",
"(",
")",
";",
"// Store version hash in the database and in a file.",
"self",
"::",
"store_versions_hash",
"(",
")",
";",
"// Store database data and structure.",
"self",
"::",
"store_database_state",
"(",
")",
";",
"}"
] | Perform a fresh test site installation
Note: To be used from CLI scripts only.
@static
@return void may terminate execution with exit code | [
"Perform",
"a",
"fresh",
"test",
"site",
"installation"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L441-L479 |
213,758 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.display_debugging_messages | public static function display_debugging_messages($return = false) {
if (empty(self::$debuggings)) {
return false;
}
$debugstring = '';
foreach(self::$debuggings as $debug) {
$debugstring .= 'Debugging: ' . $debug->message . "\n" . trim($debug->from) . "\n";
}
if ($return) {
return $debugstring;
}
echo $debugstring;
return true;
} | php | public static function display_debugging_messages($return = false) {
if (empty(self::$debuggings)) {
return false;
}
$debugstring = '';
foreach(self::$debuggings as $debug) {
$debugstring .= 'Debugging: ' . $debug->message . "\n" . trim($debug->from) . "\n";
}
if ($return) {
return $debugstring;
}
echo $debugstring;
return true;
} | [
"public",
"static",
"function",
"display_debugging_messages",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"debuggings",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"debugstring",
"=",
"''",
";",
"foreach",
"(",
"self",
"::",
"$",
"debuggings",
"as",
"$",
"debug",
")",
"{",
"$",
"debugstring",
".=",
"'Debugging: '",
".",
"$",
"debug",
"->",
"message",
".",
"\"\\n\"",
".",
"trim",
"(",
"$",
"debug",
"->",
"from",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"debugstring",
";",
"}",
"echo",
"$",
"debugstring",
";",
"return",
"true",
";",
"}"
] | Prints out any debug messages accumulated during test execution.
@param bool $return true to return the messages or false to print them directly. Default false.
@return bool|string false if no debug messages, true if debug triggered or string of messages | [
"Prints",
"out",
"any",
"debug",
"messages",
"accumulated",
"during",
"test",
"execution",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L705-L720 |
213,759 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.start_message_redirection | public static function start_message_redirection() {
if (self::$messagesink) {
self::stop_message_redirection();
}
self::$messagesink = new phpunit_message_sink();
return self::$messagesink;
} | php | public static function start_message_redirection() {
if (self::$messagesink) {
self::stop_message_redirection();
}
self::$messagesink = new phpunit_message_sink();
return self::$messagesink;
} | [
"public",
"static",
"function",
"start_message_redirection",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"messagesink",
")",
"{",
"self",
"::",
"stop_message_redirection",
"(",
")",
";",
"}",
"self",
"::",
"$",
"messagesink",
"=",
"new",
"phpunit_message_sink",
"(",
")",
";",
"return",
"self",
"::",
"$",
"messagesink",
";",
"}"
] | Start message redirection.
Note: Do not call directly from tests,
use $sink = $this->redirectMessages() instead.
@return phpunit_message_sink | [
"Start",
"message",
"redirection",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L730-L736 |
213,760 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.start_phpmailer_redirection | public static function start_phpmailer_redirection() {
if (self::$phpmailersink) {
// If an existing mailer sink is active, just clear it.
self::$phpmailersink->clear();
} else {
self::$phpmailersink = new phpunit_phpmailer_sink();
}
return self::$phpmailersink;
} | php | public static function start_phpmailer_redirection() {
if (self::$phpmailersink) {
// If an existing mailer sink is active, just clear it.
self::$phpmailersink->clear();
} else {
self::$phpmailersink = new phpunit_phpmailer_sink();
}
return self::$phpmailersink;
} | [
"public",
"static",
"function",
"start_phpmailer_redirection",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"phpmailersink",
")",
"{",
"// If an existing mailer sink is active, just clear it.",
"self",
"::",
"$",
"phpmailersink",
"->",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"phpmailersink",
"=",
"new",
"phpunit_phpmailer_sink",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"phpmailersink",
";",
"}"
] | Start phpmailer redirection.
Note: Do not call directly from tests,
use $sink = $this->redirectEmails() instead.
@return phpunit_phpmailer_sink | [
"Start",
"phpmailer",
"redirection",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L779-L787 |
213,761 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.start_event_redirection | public static function start_event_redirection() {
if (self::$eventsink) {
self::stop_event_redirection();
}
self::$eventsink = new phpunit_event_sink();
return self::$eventsink;
} | php | public static function start_event_redirection() {
if (self::$eventsink) {
self::stop_event_redirection();
}
self::$eventsink = new phpunit_event_sink();
return self::$eventsink;
} | [
"public",
"static",
"function",
"start_event_redirection",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"eventsink",
")",
"{",
"self",
"::",
"stop_event_redirection",
"(",
")",
";",
"}",
"self",
"::",
"$",
"eventsink",
"=",
"new",
"phpunit_event_sink",
"(",
")",
";",
"return",
"self",
"::",
"$",
"eventsink",
";",
"}"
] | Start event redirection.
@private
Note: Do not call directly from tests,
use $sink = $this->redirectEvents() instead.
@return phpunit_event_sink | [
"Start",
"event",
"redirection",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L831-L837 |
213,762 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.event_triggered | public static function event_triggered(\core\event\base $event) {
if (self::$eventsink) {
self::$eventsink->add_event($event);
}
} | php | public static function event_triggered(\core\event\base $event) {
if (self::$eventsink) {
self::$eventsink->add_event($event);
}
} | [
"public",
"static",
"function",
"event_triggered",
"(",
"\\",
"core",
"\\",
"event",
"\\",
"base",
"$",
"event",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"eventsink",
")",
"{",
"self",
"::",
"$",
"eventsink",
"->",
"add_event",
"(",
"$",
"event",
")",
";",
"}",
"}"
] | To be called from \core\event\base only!
@private
@param \core\event\base $event record from event_read table
@return bool true means send event, false means event "sent" to sink. | [
"To",
"be",
"called",
"from",
"\\",
"core",
"\\",
"event",
"\\",
"base",
"only!"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L869-L873 |
213,763 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.run_all_adhoc_tasks | public static function run_all_adhoc_tasks() {
$now = time();
while (($task = \core\task\manager::get_next_adhoc_task($now)) !== null) {
try {
$task->execute();
\core\task\manager::adhoc_task_complete($task);
} catch (Exception $e) {
\core\task\manager::adhoc_task_failed($task);
}
}
} | php | public static function run_all_adhoc_tasks() {
$now = time();
while (($task = \core\task\manager::get_next_adhoc_task($now)) !== null) {
try {
$task->execute();
\core\task\manager::adhoc_task_complete($task);
} catch (Exception $e) {
\core\task\manager::adhoc_task_failed($task);
}
}
} | [
"public",
"static",
"function",
"run_all_adhoc_tasks",
"(",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"while",
"(",
"(",
"$",
"task",
"=",
"\\",
"core",
"\\",
"task",
"\\",
"manager",
"::",
"get_next_adhoc_task",
"(",
"$",
"now",
")",
")",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"task",
"->",
"execute",
"(",
")",
";",
"\\",
"core",
"\\",
"task",
"\\",
"manager",
"::",
"adhoc_task_complete",
"(",
"$",
"task",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"\\",
"core",
"\\",
"task",
"\\",
"manager",
"::",
"adhoc_task_failed",
"(",
"$",
"task",
")",
";",
"}",
"}",
"}"
] | Executes all adhoc tasks in the queue. Useful for testing asynchronous behaviour.
@return void | [
"Executes",
"all",
"adhoc",
"tasks",
"in",
"the",
"queue",
".",
"Useful",
"for",
"testing",
"asynchronous",
"behaviour",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L895-L905 |
213,764 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.get_filter_config | protected static function get_filter_config(array $whitelists, array $excludelists) : string {
$filters = '';
if (!empty($whitelists)) {
$filters .= self::pad("<whitelist>", 2);
foreach ($whitelists as $line) {
$filters .= self::pad($line, 3);
}
if (!empty($excludelists)) {
$filters .= self::pad("<exclude>", 3);
foreach ($excludelists as $line) {
$filters .= self::pad($line, 4);
}
$filters .= self::pad("</exclude>", 3);
}
$filters .= self::pad("</whitelist>", 2);
}
return $filters;
} | php | protected static function get_filter_config(array $whitelists, array $excludelists) : string {
$filters = '';
if (!empty($whitelists)) {
$filters .= self::pad("<whitelist>", 2);
foreach ($whitelists as $line) {
$filters .= self::pad($line, 3);
}
if (!empty($excludelists)) {
$filters .= self::pad("<exclude>", 3);
foreach ($excludelists as $line) {
$filters .= self::pad($line, 4);
}
$filters .= self::pad("</exclude>", 3);
}
$filters .= self::pad("</whitelist>", 2);
}
return $filters;
} | [
"protected",
"static",
"function",
"get_filter_config",
"(",
"array",
"$",
"whitelists",
",",
"array",
"$",
"excludelists",
")",
":",
"string",
"{",
"$",
"filters",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"whitelists",
")",
")",
"{",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"\"<whitelist>\"",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"whitelists",
"as",
"$",
"line",
")",
"{",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"$",
"line",
",",
"3",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludelists",
")",
")",
"{",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"\"<exclude>\"",
",",
"3",
")",
";",
"foreach",
"(",
"$",
"excludelists",
"as",
"$",
"line",
")",
"{",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"$",
"line",
",",
"4",
")",
";",
"}",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"\"</exclude>\"",
",",
"3",
")",
";",
"}",
"$",
"filters",
".=",
"self",
"::",
"pad",
"(",
"\"</whitelist>\"",
",",
"2",
")",
";",
"}",
"return",
"$",
"filters",
";",
"}"
] | Get the filter config for the supplied whitelist and excludelist configuration.
@param array[] $whitelists The list of files/folders in the whitelist.
@param array[] $excludelists The list of files/folders in the excludelist.
@return string | [
"Get",
"the",
"filter",
"config",
"for",
"the",
"supplied",
"whitelist",
"and",
"excludelist",
"configuration",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L948-L966 |
213,765 | moodle/moodle | lib/phpunit/classes/util.php | phpunit_util.get_coverage_info | protected static function get_coverage_info(string $fulldir): ?phpunit_coverage_info {
$coverageconfig = "{$fulldir}/tests/coverage.php";
if (file_exists($coverageconfig)) {
$coverageinfo = require($coverageconfig);
if (!$coverageinfo instanceof phpunit_coverage_info) {
throw new \coding_exception("{$coverageconfig} does not return a phpunit_coverage_info");
}
return $coverageinfo;
}
return null;
} | php | protected static function get_coverage_info(string $fulldir): ?phpunit_coverage_info {
$coverageconfig = "{$fulldir}/tests/coverage.php";
if (file_exists($coverageconfig)) {
$coverageinfo = require($coverageconfig);
if (!$coverageinfo instanceof phpunit_coverage_info) {
throw new \coding_exception("{$coverageconfig} does not return a phpunit_coverage_info");
}
return $coverageinfo;
}
return null;
} | [
"protected",
"static",
"function",
"get_coverage_info",
"(",
"string",
"$",
"fulldir",
")",
":",
"?",
"phpunit_coverage_info",
"{",
"$",
"coverageconfig",
"=",
"\"{$fulldir}/tests/coverage.php\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"coverageconfig",
")",
")",
"{",
"$",
"coverageinfo",
"=",
"require",
"(",
"$",
"coverageconfig",
")",
";",
"if",
"(",
"!",
"$",
"coverageinfo",
"instanceof",
"phpunit_coverage_info",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"\"{$coverageconfig} does not return a phpunit_coverage_info\"",
")",
";",
"}",
"return",
"$",
"coverageinfo",
";",
"}",
"return",
"null",
";",
"}"
] | Get the phpunit_coverage_info for the specified plugin or subsystem directory.
@param string $fulldir The directory to find the coverage info file in.
@return phpunit_coverage_info | [
"Get",
"the",
"phpunit_coverage_info",
"for",
"the",
"specified",
"plugin",
"or",
"subsystem",
"directory",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpunit/classes/util.php#L974-L986 |
213,766 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query.charset | public function charset($charset, $convert = true)
{
$oldcharset = $this->_charset;
$this->_charset = Horde_String::upper($charset);
if (!$convert || ($oldcharset == $this->_charset)) {
return;
}
foreach (array('and', 'or') as $item) {
if (isset($this->_search[$item])) {
foreach ($this->_search[$item] as &$val) {
$val->charset($charset, $convert);
}
}
}
foreach (array('header', 'text') as $item) {
if (isset($this->_search[$item])) {
foreach ($this->_search[$item] as $key => $val) {
$new_val = Horde_String::convertCharset($val['text'], $oldcharset, $this->_charset);
if (Horde_String::convertCharset($new_val, $this->_charset, $oldcharset) != $val['text']) {
throw new Horde_Imap_Client_Exception_SearchCharset($this->_charset);
}
$this->_search[$item][$key]['text'] = $new_val;
}
}
}
} | php | public function charset($charset, $convert = true)
{
$oldcharset = $this->_charset;
$this->_charset = Horde_String::upper($charset);
if (!$convert || ($oldcharset == $this->_charset)) {
return;
}
foreach (array('and', 'or') as $item) {
if (isset($this->_search[$item])) {
foreach ($this->_search[$item] as &$val) {
$val->charset($charset, $convert);
}
}
}
foreach (array('header', 'text') as $item) {
if (isset($this->_search[$item])) {
foreach ($this->_search[$item] as $key => $val) {
$new_val = Horde_String::convertCharset($val['text'], $oldcharset, $this->_charset);
if (Horde_String::convertCharset($new_val, $this->_charset, $oldcharset) != $val['text']) {
throw new Horde_Imap_Client_Exception_SearchCharset($this->_charset);
}
$this->_search[$item][$key]['text'] = $new_val;
}
}
}
} | [
"public",
"function",
"charset",
"(",
"$",
"charset",
",",
"$",
"convert",
"=",
"true",
")",
"{",
"$",
"oldcharset",
"=",
"$",
"this",
"->",
"_charset",
";",
"$",
"this",
"->",
"_charset",
"=",
"Horde_String",
"::",
"upper",
"(",
"$",
"charset",
")",
";",
"if",
"(",
"!",
"$",
"convert",
"||",
"(",
"$",
"oldcharset",
"==",
"$",
"this",
"->",
"_charset",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"array",
"(",
"'and'",
",",
"'or'",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_search",
"[",
"$",
"item",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_search",
"[",
"$",
"item",
"]",
"as",
"&",
"$",
"val",
")",
"{",
"$",
"val",
"->",
"charset",
"(",
"$",
"charset",
",",
"$",
"convert",
")",
";",
"}",
"}",
"}",
"foreach",
"(",
"array",
"(",
"'header'",
",",
"'text'",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_search",
"[",
"$",
"item",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_search",
"[",
"$",
"item",
"]",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"new_val",
"=",
"Horde_String",
"::",
"convertCharset",
"(",
"$",
"val",
"[",
"'text'",
"]",
",",
"$",
"oldcharset",
",",
"$",
"this",
"->",
"_charset",
")",
";",
"if",
"(",
"Horde_String",
"::",
"convertCharset",
"(",
"$",
"new_val",
",",
"$",
"this",
"->",
"_charset",
",",
"$",
"oldcharset",
")",
"!=",
"$",
"val",
"[",
"'text'",
"]",
")",
"{",
"throw",
"new",
"Horde_Imap_Client_Exception_SearchCharset",
"(",
"$",
"this",
"->",
"_charset",
")",
";",
"}",
"$",
"this",
"->",
"_search",
"[",
"$",
"item",
"]",
"[",
"$",
"key",
"]",
"[",
"'text'",
"]",
"=",
"$",
"new_val",
";",
"}",
"}",
"}",
"}"
] | Sets the charset of the search text.
@param string $charset The charset to use for the search.
@param boolean $convert Convert existing text values?
@throws Horde_Imap_Client_Exception_SearchCharset | [
"Sets",
"the",
"charset",
"of",
"the",
"search",
"text",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L81-L109 |
213,767 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query._addFuzzy | protected function _addFuzzy($add, &$temp)
{
if ($add) {
if (!$temp['exts']->query('SEARCH', 'FUZZY')) {
throw new Horde_Imap_Client_Exception_NoSupportExtension('SEARCH=FUZZY');
}
$temp['cmds']->add('FUZZY');
$temp['exts_used'][] = 'SEARCH=FUZZY';
}
} | php | protected function _addFuzzy($add, &$temp)
{
if ($add) {
if (!$temp['exts']->query('SEARCH', 'FUZZY')) {
throw new Horde_Imap_Client_Exception_NoSupportExtension('SEARCH=FUZZY');
}
$temp['cmds']->add('FUZZY');
$temp['exts_used'][] = 'SEARCH=FUZZY';
}
} | [
"protected",
"function",
"_addFuzzy",
"(",
"$",
"add",
",",
"&",
"$",
"temp",
")",
"{",
"if",
"(",
"$",
"add",
")",
"{",
"if",
"(",
"!",
"$",
"temp",
"[",
"'exts'",
"]",
"->",
"query",
"(",
"'SEARCH'",
",",
"'FUZZY'",
")",
")",
"{",
"throw",
"new",
"Horde_Imap_Client_Exception_NoSupportExtension",
"(",
"'SEARCH=FUZZY'",
")",
";",
"}",
"$",
"temp",
"[",
"'cmds'",
"]",
"->",
"add",
"(",
"'FUZZY'",
")",
";",
"$",
"temp",
"[",
"'exts_used'",
"]",
"[",
"]",
"=",
"'SEARCH=FUZZY'",
";",
"}",
"}"
] | Adds fuzzy modifier to search keys.
@param boolean $add Add the fuzzy modifier?
@param array $temp Temporary build data.
@throws Horde_Imap_Client_Exception_NoSupport_Extension | [
"Adds",
"fuzzy",
"modifier",
"to",
"search",
"keys",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L495-L504 |
213,768 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query.headerText | public function headerText($header, $text, $not = false,
array $opts = array())
{
if (!isset($this->_search['header'])) {
$this->_search['header'] = array();
}
$this->_search['header'][] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'header' => Horde_String::upper($header),
'text' => $text,
'not' => $not
));
} | php | public function headerText($header, $text, $not = false,
array $opts = array())
{
if (!isset($this->_search['header'])) {
$this->_search['header'] = array();
}
$this->_search['header'][] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'header' => Horde_String::upper($header),
'text' => $text,
'not' => $not
));
} | [
"public",
"function",
"headerText",
"(",
"$",
"header",
",",
"$",
"text",
",",
"$",
"not",
"=",
"false",
",",
"array",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_search",
"[",
"'header'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_search",
"[",
"'header'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_search",
"[",
"'header'",
"]",
"[",
"]",
"=",
"array_filter",
"(",
"array",
"(",
"'fuzzy'",
"=>",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'fuzzy'",
"]",
")",
",",
"'header'",
"=>",
"Horde_String",
"::",
"upper",
"(",
"$",
"header",
")",
",",
"'text'",
"=>",
"$",
"text",
",",
"'not'",
"=>",
"$",
"not",
")",
")",
";",
"}"
] | Search for text in the header of a message.
@param string $header The header field.
@param string $text The search text.
@param boolean $not If true, do a 'NOT' search of $text.
@param array $opts Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203. | [
"Search",
"for",
"text",
"in",
"the",
"header",
"of",
"a",
"message",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L577-L589 |
213,769 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query.text | public function text($text, $bodyonly = true, $not = false,
array $opts = array())
{
if (!isset($this->_search['text'])) {
$this->_search['text'] = array();
}
$this->_search['text'][] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'not' => $not,
'text' => $text,
'type' => $bodyonly ? 'BODY' : 'TEXT'
));
} | php | public function text($text, $bodyonly = true, $not = false,
array $opts = array())
{
if (!isset($this->_search['text'])) {
$this->_search['text'] = array();
}
$this->_search['text'][] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'not' => $not,
'text' => $text,
'type' => $bodyonly ? 'BODY' : 'TEXT'
));
} | [
"public",
"function",
"text",
"(",
"$",
"text",
",",
"$",
"bodyonly",
"=",
"true",
",",
"$",
"not",
"=",
"false",
",",
"array",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_search",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_search",
"[",
"'text'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_search",
"[",
"'text'",
"]",
"[",
"]",
"=",
"array_filter",
"(",
"array",
"(",
"'fuzzy'",
"=>",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'fuzzy'",
"]",
")",
",",
"'not'",
"=>",
"$",
"not",
",",
"'text'",
"=>",
"$",
"text",
",",
"'type'",
"=>",
"$",
"bodyonly",
"?",
"'BODY'",
":",
"'TEXT'",
")",
")",
";",
"}"
] | Search for text in either the entire message, or just the body.
@param string $text The search text.
@param string $bodyonly If true, only search in the body of the
message. If false, also search in the headers.
@param boolean $not If true, do a 'NOT' search of $text.
@param array $opts Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203. | [
"Search",
"for",
"text",
"in",
"either",
"the",
"entire",
"message",
"or",
"just",
"the",
"body",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L602-L615 |
213,770 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query.ids | public function ids(Horde_Imap_Client_Ids $ids, $not = false,
array $opts = array())
{
$this->_search['ids'] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'ids' => $ids,
'not' => $not
));
} | php | public function ids(Horde_Imap_Client_Ids $ids, $not = false,
array $opts = array())
{
$this->_search['ids'] = array_filter(array(
'fuzzy' => !empty($opts['fuzzy']),
'ids' => $ids,
'not' => $not
));
} | [
"public",
"function",
"ids",
"(",
"Horde_Imap_Client_Ids",
"$",
"ids",
",",
"$",
"not",
"=",
"false",
",",
"array",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_search",
"[",
"'ids'",
"]",
"=",
"array_filter",
"(",
"array",
"(",
"'fuzzy'",
"=>",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'fuzzy'",
"]",
")",
",",
"'ids'",
"=>",
"$",
"ids",
",",
"'not'",
"=>",
"$",
"not",
")",
")",
";",
"}"
] | Search for messages within a given UID range. Only one message range
can be specified per query.
@param Horde_Imap_Client_Ids $ids The list of UIDs to search.
@param boolean $not If true, do a 'NOT' search of the
UIDs.
@param array $opts Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203. | [
"Search",
"for",
"messages",
"within",
"a",
"given",
"UID",
"range",
".",
"Only",
"one",
"message",
"range",
"can",
"be",
"specified",
"per",
"query",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L653-L661 |
213,771 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Search/Query.php | Horde_Imap_Client_Search_Query.dateSearch | public function dateSearch($date, $range, $header = true, $not = false,
array $opts = array())
{
if (!isset($this->_search['date'])) {
$this->_search['date'] = array();
}
// We should really be storing the raw DateTime object as data,
// but all versions of the query object have converted at this stage.
$ob = new Horde_Imap_Client_Data_Format_Date($date);
$this->_search['date'][] = array_filter(array(
'date' => $ob->escape(),
'fuzzy' => !empty($opts['fuzzy']),
'header' => $header,
'range' => $range,
'not' => $not
));
} | php | public function dateSearch($date, $range, $header = true, $not = false,
array $opts = array())
{
if (!isset($this->_search['date'])) {
$this->_search['date'] = array();
}
// We should really be storing the raw DateTime object as data,
// but all versions of the query object have converted at this stage.
$ob = new Horde_Imap_Client_Data_Format_Date($date);
$this->_search['date'][] = array_filter(array(
'date' => $ob->escape(),
'fuzzy' => !empty($opts['fuzzy']),
'header' => $header,
'range' => $range,
'not' => $not
));
} | [
"public",
"function",
"dateSearch",
"(",
"$",
"date",
",",
"$",
"range",
",",
"$",
"header",
"=",
"true",
",",
"$",
"not",
"=",
"false",
",",
"array",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_search",
"[",
"'date'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_search",
"[",
"'date'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"// We should really be storing the raw DateTime object as data,",
"// but all versions of the query object have converted at this stage.",
"$",
"ob",
"=",
"new",
"Horde_Imap_Client_Data_Format_Date",
"(",
"$",
"date",
")",
";",
"$",
"this",
"->",
"_search",
"[",
"'date'",
"]",
"[",
"]",
"=",
"array_filter",
"(",
"array",
"(",
"'date'",
"=>",
"$",
"ob",
"->",
"escape",
"(",
")",
",",
"'fuzzy'",
"=>",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'fuzzy'",
"]",
")",
",",
"'header'",
"=>",
"$",
"header",
",",
"'range'",
"=>",
"$",
"range",
",",
"'not'",
"=>",
"$",
"not",
")",
")",
";",
"}"
] | Search for messages within a date range.
@param mixed $date DateTime or Horde_Date object.
@param string $range Either:
- Horde_Imap_Client_Search_Query::DATE_BEFORE
- Horde_Imap_Client_Search_Query::DATE_ON
- Horde_Imap_Client_Search_Query::DATE_SINCE
@param boolean $header If true, search using the date in the message
headers. If false, search using the internal
IMAP date (usually arrival time).
@param boolean $not If true, do a 'NOT' search of the range.
@param array $opts Additional options:
- fuzzy: (boolean) If true, perform a fuzzy search. The IMAP server
MUST support RFC 6203. | [
"Search",
"for",
"messages",
"within",
"a",
"date",
"range",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Search/Query.php#L679-L697 |
213,772 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.start_logging | public static function start_logging(task_base $task) {
global $DB;
if (!self::should_log()) {
return;
}
// We register a shutdown handler to ensure that logs causing any failures are correctly disposed of.
// Note: This must happen before the per-request directory is requested because the shutdown handler deletes the logfile.
if (!self::$tasklogregistered) {
\core_shutdown_manager::register_function(function() {
// These will only actually do anything if capturing is current active when the thread ended, which
// constitutes a failure.
\core\task\logmanager::finalise_log(true);
});
// Create a brand new per-request directory basedir.
get_request_storage_directory(true, true);
self::$tasklogregistered = true;
}
if (self::is_current_output_buffer()) {
// We cannot capture when we are already capturing.
throw new \coding_exception('Logging is already in progress for task "' . get_class(self::$task) . '". ' .
'Nested logging is not supported.');
}
// Store the initial data about the task and current state.
self::$task = $task;
self::$taskloginfo = (object) [
'dbread' => $DB->perf_get_reads(),
'dbwrite' => $DB->perf_get_writes(),
'timestart' => microtime(true),
];
// For simplicity's sake we always store logs on disk and flush at the end.
self::$logpath = make_request_directory() . DIRECTORY_SEPARATOR . "task.log";
self::$fh = fopen(self::$logpath, 'w+');
// Note the level of the current output buffer.
// Note: You cannot use ob_get_level() as it will return `1` when the default output buffer is enabled.
if ($obstatus = ob_get_status()) {
self::$oblevel = $obstatus['level'];
} else {
self::$oblevel = null;
}
// Start capturing output.
ob_start([\core\task\logmanager::class, 'add_line'], self::CHUNKSIZE);
} | php | public static function start_logging(task_base $task) {
global $DB;
if (!self::should_log()) {
return;
}
// We register a shutdown handler to ensure that logs causing any failures are correctly disposed of.
// Note: This must happen before the per-request directory is requested because the shutdown handler deletes the logfile.
if (!self::$tasklogregistered) {
\core_shutdown_manager::register_function(function() {
// These will only actually do anything if capturing is current active when the thread ended, which
// constitutes a failure.
\core\task\logmanager::finalise_log(true);
});
// Create a brand new per-request directory basedir.
get_request_storage_directory(true, true);
self::$tasklogregistered = true;
}
if (self::is_current_output_buffer()) {
// We cannot capture when we are already capturing.
throw new \coding_exception('Logging is already in progress for task "' . get_class(self::$task) . '". ' .
'Nested logging is not supported.');
}
// Store the initial data about the task and current state.
self::$task = $task;
self::$taskloginfo = (object) [
'dbread' => $DB->perf_get_reads(),
'dbwrite' => $DB->perf_get_writes(),
'timestart' => microtime(true),
];
// For simplicity's sake we always store logs on disk and flush at the end.
self::$logpath = make_request_directory() . DIRECTORY_SEPARATOR . "task.log";
self::$fh = fopen(self::$logpath, 'w+');
// Note the level of the current output buffer.
// Note: You cannot use ob_get_level() as it will return `1` when the default output buffer is enabled.
if ($obstatus = ob_get_status()) {
self::$oblevel = $obstatus['level'];
} else {
self::$oblevel = null;
}
// Start capturing output.
ob_start([\core\task\logmanager::class, 'add_line'], self::CHUNKSIZE);
} | [
"public",
"static",
"function",
"start_logging",
"(",
"task_base",
"$",
"task",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"self",
"::",
"should_log",
"(",
")",
")",
"{",
"return",
";",
"}",
"// We register a shutdown handler to ensure that logs causing any failures are correctly disposed of.",
"// Note: This must happen before the per-request directory is requested because the shutdown handler deletes the logfile.",
"if",
"(",
"!",
"self",
"::",
"$",
"tasklogregistered",
")",
"{",
"\\",
"core_shutdown_manager",
"::",
"register_function",
"(",
"function",
"(",
")",
"{",
"// These will only actually do anything if capturing is current active when the thread ended, which",
"// constitutes a failure.",
"\\",
"core",
"\\",
"task",
"\\",
"logmanager",
"::",
"finalise_log",
"(",
"true",
")",
";",
"}",
")",
";",
"// Create a brand new per-request directory basedir.",
"get_request_storage_directory",
"(",
"true",
",",
"true",
")",
";",
"self",
"::",
"$",
"tasklogregistered",
"=",
"true",
";",
"}",
"if",
"(",
"self",
"::",
"is_current_output_buffer",
"(",
")",
")",
"{",
"// We cannot capture when we are already capturing.",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'Logging is already in progress for task \"'",
".",
"get_class",
"(",
"self",
"::",
"$",
"task",
")",
".",
"'\". '",
".",
"'Nested logging is not supported.'",
")",
";",
"}",
"// Store the initial data about the task and current state.",
"self",
"::",
"$",
"task",
"=",
"$",
"task",
";",
"self",
"::",
"$",
"taskloginfo",
"=",
"(",
"object",
")",
"[",
"'dbread'",
"=>",
"$",
"DB",
"->",
"perf_get_reads",
"(",
")",
",",
"'dbwrite'",
"=>",
"$",
"DB",
"->",
"perf_get_writes",
"(",
")",
",",
"'timestart'",
"=>",
"microtime",
"(",
"true",
")",
",",
"]",
";",
"// For simplicity's sake we always store logs on disk and flush at the end.",
"self",
"::",
"$",
"logpath",
"=",
"make_request_directory",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"\"task.log\"",
";",
"self",
"::",
"$",
"fh",
"=",
"fopen",
"(",
"self",
"::",
"$",
"logpath",
",",
"'w+'",
")",
";",
"// Note the level of the current output buffer.",
"// Note: You cannot use ob_get_level() as it will return `1` when the default output buffer is enabled.",
"if",
"(",
"$",
"obstatus",
"=",
"ob_get_status",
"(",
")",
")",
"{",
"self",
"::",
"$",
"oblevel",
"=",
"$",
"obstatus",
"[",
"'level'",
"]",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"oblevel",
"=",
"null",
";",
"}",
"// Start capturing output.",
"ob_start",
"(",
"[",
"\\",
"core",
"\\",
"task",
"\\",
"logmanager",
"::",
"class",
",",
"'add_line'",
"]",
",",
"self",
"::",
"CHUNKSIZE",
")",
";",
"}"
] | Create a new task logger for the specified task, and prepare for logging.
@param \core\task\task_base $task The task being run | [
"Create",
"a",
"new",
"task",
"logger",
"for",
"the",
"specified",
"task",
"and",
"prepare",
"for",
"logging",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L84-L134 |
213,773 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.should_log | protected static function should_log() : bool {
global $CFG;
// Respect the config setting.
if (isset($CFG->task_logmode) && empty($CFG->task_logmode)) {
return false;
}
$loggerclass = self::get_logger_classname();
if (empty($loggerclass)) {
return false;
}
return $loggerclass::is_configured();
} | php | protected static function should_log() : bool {
global $CFG;
// Respect the config setting.
if (isset($CFG->task_logmode) && empty($CFG->task_logmode)) {
return false;
}
$loggerclass = self::get_logger_classname();
if (empty($loggerclass)) {
return false;
}
return $loggerclass::is_configured();
} | [
"protected",
"static",
"function",
"should_log",
"(",
")",
":",
"bool",
"{",
"global",
"$",
"CFG",
";",
"// Respect the config setting.",
"if",
"(",
"isset",
"(",
"$",
"CFG",
"->",
"task_logmode",
")",
"&&",
"empty",
"(",
"$",
"CFG",
"->",
"task_logmode",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"loggerclass",
"=",
"self",
"::",
"get_logger_classname",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"loggerclass",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"loggerclass",
"::",
"is_configured",
"(",
")",
";",
"}"
] | Whether logging is possible and should be happening.
@return bool | [
"Whether",
"logging",
"is",
"possible",
"and",
"should",
"be",
"happening",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L141-L155 |
213,774 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.uses_standard_settings | public static function uses_standard_settings() : bool {
$classname = self::get_logger_classname();
if (!class_exists($classname)) {
return false;
}
if (is_a($classname, database_logger::class, true)) {
return true;
}
return false;
} | php | public static function uses_standard_settings() : bool {
$classname = self::get_logger_classname();
if (!class_exists($classname)) {
return false;
}
if (is_a($classname, database_logger::class, true)) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"uses_standard_settings",
"(",
")",
":",
"bool",
"{",
"$",
"classname",
"=",
"self",
"::",
"get_logger_classname",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_a",
"(",
"$",
"classname",
",",
"database_logger",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Whether to use the standard settings form. | [
"Whether",
"to",
"use",
"the",
"standard",
"settings",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L188-L199 |
213,775 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.get_url_for_task_class | public static function get_url_for_task_class(string $classname) : \moodle_url {
$loggerclass = self::get_logger_classname();
return $loggerclass::get_url_for_task_class($classname);
} | php | public static function get_url_for_task_class(string $classname) : \moodle_url {
$loggerclass = self::get_logger_classname();
return $loggerclass::get_url_for_task_class($classname);
} | [
"public",
"static",
"function",
"get_url_for_task_class",
"(",
"string",
"$",
"classname",
")",
":",
"\\",
"moodle_url",
"{",
"$",
"loggerclass",
"=",
"self",
"::",
"get_logger_classname",
"(",
")",
";",
"return",
"$",
"loggerclass",
"::",
"get_url_for_task_class",
"(",
"$",
"classname",
")",
";",
"}"
] | Get any URL available for viewing relevant task log reports.
@param string $classname The task class to fetch for
@return \moodle_url | [
"Get",
"any",
"URL",
"available",
"for",
"viewing",
"relevant",
"task",
"log",
"reports",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L207-L211 |
213,776 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.is_current_output_buffer | protected static function is_current_output_buffer() : bool {
if (empty(self::$taskloginfo)) {
return false;
}
if ($ob = ob_get_status()) {
return 'core\\task\\logmanager::add_line' == $ob['name'];
}
return false;
} | php | protected static function is_current_output_buffer() : bool {
if (empty(self::$taskloginfo)) {
return false;
}
if ($ob = ob_get_status()) {
return 'core\\task\\logmanager::add_line' == $ob['name'];
}
return false;
} | [
"protected",
"static",
"function",
"is_current_output_buffer",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"taskloginfo",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"ob",
"=",
"ob_get_status",
"(",
")",
")",
"{",
"return",
"'core\\\\task\\\\logmanager::add_line'",
"==",
"$",
"ob",
"[",
"'name'",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | Whether we are the current log collector.
@return bool | [
"Whether",
"we",
"are",
"the",
"current",
"log",
"collector",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L218-L228 |
213,777 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.is_capturing | protected static function is_capturing() : bool {
$buffers = ob_get_status(true);
foreach ($buffers as $ob) {
if ('core\\task\\logmanager::add_line' == $ob['name']) {
return true;
}
}
return false;
} | php | protected static function is_capturing() : bool {
$buffers = ob_get_status(true);
foreach ($buffers as $ob) {
if ('core\\task\\logmanager::add_line' == $ob['name']) {
return true;
}
}
return false;
} | [
"protected",
"static",
"function",
"is_capturing",
"(",
")",
":",
"bool",
"{",
"$",
"buffers",
"=",
"ob_get_status",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"buffers",
"as",
"$",
"ob",
")",
"{",
"if",
"(",
"'core\\\\task\\\\logmanager::add_line'",
"==",
"$",
"ob",
"[",
"'name'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Whether we are capturing at all.
@return bool | [
"Whether",
"we",
"are",
"capturing",
"at",
"all",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L235-L244 |
213,778 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.finalise_log | public static function finalise_log(bool $failed = false) {
global $CFG, $DB, $PERF;
if (!self::should_log()) {
return;
}
if (!self::is_capturing()) {
// Not capturing anything.
return;
}
// Ensure that all logs are closed.
$buffers = ob_get_status(true);
foreach (array_reverse($buffers) as $ob) {
if (null !== self::$oblevel) {
if ($ob['level'] <= self::$oblevel) {
// Only close as far as the initial output buffer level.
break;
}
}
// End and flush this buffer.
ob_end_flush();
if ('core\\task\\logmanager::add_line' == $ob['name']) {
break;
}
}
self::$oblevel = null;
// Flush any remaining buffer.
self::flush();
// Close and unset the FH.
fclose(self::$fh);
self::$fh = null;
if ($failed || empty($CFG->task_logmode) || self::MODE_ALL == $CFG->task_logmode) {
// Finalise the log.
$loggerclass = self::get_logger_classname();
$loggerclass::store_log_for_task(
self::$task,
self::$logpath,
$failed,
$DB->perf_get_reads() - self::$taskloginfo->dbread,
$DB->perf_get_writes() - self::$taskloginfo->dbwrite - $PERF->logwrites,
self::$taskloginfo->timestart,
microtime(true)
);
}
// Tidy up.
self::$logpath = null;
self::$taskloginfo = null;
} | php | public static function finalise_log(bool $failed = false) {
global $CFG, $DB, $PERF;
if (!self::should_log()) {
return;
}
if (!self::is_capturing()) {
// Not capturing anything.
return;
}
// Ensure that all logs are closed.
$buffers = ob_get_status(true);
foreach (array_reverse($buffers) as $ob) {
if (null !== self::$oblevel) {
if ($ob['level'] <= self::$oblevel) {
// Only close as far as the initial output buffer level.
break;
}
}
// End and flush this buffer.
ob_end_flush();
if ('core\\task\\logmanager::add_line' == $ob['name']) {
break;
}
}
self::$oblevel = null;
// Flush any remaining buffer.
self::flush();
// Close and unset the FH.
fclose(self::$fh);
self::$fh = null;
if ($failed || empty($CFG->task_logmode) || self::MODE_ALL == $CFG->task_logmode) {
// Finalise the log.
$loggerclass = self::get_logger_classname();
$loggerclass::store_log_for_task(
self::$task,
self::$logpath,
$failed,
$DB->perf_get_reads() - self::$taskloginfo->dbread,
$DB->perf_get_writes() - self::$taskloginfo->dbwrite - $PERF->logwrites,
self::$taskloginfo->timestart,
microtime(true)
);
}
// Tidy up.
self::$logpath = null;
self::$taskloginfo = null;
} | [
"public",
"static",
"function",
"finalise_log",
"(",
"bool",
"$",
"failed",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
",",
"$",
"PERF",
";",
"if",
"(",
"!",
"self",
"::",
"should_log",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"is_capturing",
"(",
")",
")",
"{",
"// Not capturing anything.",
"return",
";",
"}",
"// Ensure that all logs are closed.",
"$",
"buffers",
"=",
"ob_get_status",
"(",
"true",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"buffers",
")",
"as",
"$",
"ob",
")",
"{",
"if",
"(",
"null",
"!==",
"self",
"::",
"$",
"oblevel",
")",
"{",
"if",
"(",
"$",
"ob",
"[",
"'level'",
"]",
"<=",
"self",
"::",
"$",
"oblevel",
")",
"{",
"// Only close as far as the initial output buffer level.",
"break",
";",
"}",
"}",
"// End and flush this buffer.",
"ob_end_flush",
"(",
")",
";",
"if",
"(",
"'core\\\\task\\\\logmanager::add_line'",
"==",
"$",
"ob",
"[",
"'name'",
"]",
")",
"{",
"break",
";",
"}",
"}",
"self",
"::",
"$",
"oblevel",
"=",
"null",
";",
"// Flush any remaining buffer.",
"self",
"::",
"flush",
"(",
")",
";",
"// Close and unset the FH.",
"fclose",
"(",
"self",
"::",
"$",
"fh",
")",
";",
"self",
"::",
"$",
"fh",
"=",
"null",
";",
"if",
"(",
"$",
"failed",
"||",
"empty",
"(",
"$",
"CFG",
"->",
"task_logmode",
")",
"||",
"self",
"::",
"MODE_ALL",
"==",
"$",
"CFG",
"->",
"task_logmode",
")",
"{",
"// Finalise the log.",
"$",
"loggerclass",
"=",
"self",
"::",
"get_logger_classname",
"(",
")",
";",
"$",
"loggerclass",
"::",
"store_log_for_task",
"(",
"self",
"::",
"$",
"task",
",",
"self",
"::",
"$",
"logpath",
",",
"$",
"failed",
",",
"$",
"DB",
"->",
"perf_get_reads",
"(",
")",
"-",
"self",
"::",
"$",
"taskloginfo",
"->",
"dbread",
",",
"$",
"DB",
"->",
"perf_get_writes",
"(",
")",
"-",
"self",
"::",
"$",
"taskloginfo",
"->",
"dbwrite",
"-",
"$",
"PERF",
"->",
"logwrites",
",",
"self",
"::",
"$",
"taskloginfo",
"->",
"timestart",
",",
"microtime",
"(",
"true",
")",
")",
";",
"}",
"// Tidy up.",
"self",
"::",
"$",
"logpath",
"=",
"null",
";",
"self",
"::",
"$",
"taskloginfo",
"=",
"null",
";",
"}"
] | Finish writing for the current task.
@param bool $failed | [
"Finish",
"writing",
"for",
"the",
"current",
"task",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L251-L306 |
213,779 | moodle/moodle | lib/classes/task/logmanager.php | logmanager.add_line | public static function add_line(string $log) : string {
if (empty(self::$taskloginfo)) {
return $log;
}
if (empty(self::$fh)) {
return $log;
}
if (self::is_current_output_buffer()) {
fwrite(self::$fh, $log);
}
return $log;
} | php | public static function add_line(string $log) : string {
if (empty(self::$taskloginfo)) {
return $log;
}
if (empty(self::$fh)) {
return $log;
}
if (self::is_current_output_buffer()) {
fwrite(self::$fh, $log);
}
return $log;
} | [
"public",
"static",
"function",
"add_line",
"(",
"string",
"$",
"log",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"taskloginfo",
")",
")",
"{",
"return",
"$",
"log",
";",
"}",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"fh",
")",
")",
"{",
"return",
"$",
"log",
";",
"}",
"if",
"(",
"self",
"::",
"is_current_output_buffer",
"(",
")",
")",
"{",
"fwrite",
"(",
"self",
"::",
"$",
"fh",
",",
"$",
"log",
")",
";",
"}",
"return",
"$",
"log",
";",
"}"
] | Add a log record to the task log.
@param string $log
@return string | [
"Add",
"a",
"log",
"record",
"to",
"the",
"task",
"log",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/task/logmanager.php#L326-L340 |
213,780 | moodle/moodle | lib/htmlpurifier/HTMLPurifier/ContentSets.php | HTMLPurifier_ContentSets.generateChildDef | public function generateChildDef(&$def, $module)
{
if (!empty($def->child)) { // already done!
return;
}
$content_model = $def->content_model;
if (is_string($content_model)) {
// Assume that $this->keys is alphanumeric
$def->content_model = preg_replace_callback(
'/\b(' . implode('|', $this->keys) . ')\b/',
array($this, 'generateChildDefCallback'),
$content_model
);
//$def->content_model = str_replace(
// $this->keys, $this->values, $content_model);
}
$def->child = $this->getChildDef($def, $module);
} | php | public function generateChildDef(&$def, $module)
{
if (!empty($def->child)) { // already done!
return;
}
$content_model = $def->content_model;
if (is_string($content_model)) {
// Assume that $this->keys is alphanumeric
$def->content_model = preg_replace_callback(
'/\b(' . implode('|', $this->keys) . ')\b/',
array($this, 'generateChildDefCallback'),
$content_model
);
//$def->content_model = str_replace(
// $this->keys, $this->values, $content_model);
}
$def->child = $this->getChildDef($def, $module);
} | [
"public",
"function",
"generateChildDef",
"(",
"&",
"$",
"def",
",",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"def",
"->",
"child",
")",
")",
"{",
"// already done!",
"return",
";",
"}",
"$",
"content_model",
"=",
"$",
"def",
"->",
"content_model",
";",
"if",
"(",
"is_string",
"(",
"$",
"content_model",
")",
")",
"{",
"// Assume that $this->keys is alphanumeric",
"$",
"def",
"->",
"content_model",
"=",
"preg_replace_callback",
"(",
"'/\\b('",
".",
"implode",
"(",
"'|'",
",",
"$",
"this",
"->",
"keys",
")",
".",
"')\\b/'",
",",
"array",
"(",
"$",
"this",
",",
"'generateChildDefCallback'",
")",
",",
"$",
"content_model",
")",
";",
"//$def->content_model = str_replace(",
"// $this->keys, $this->values, $content_model);",
"}",
"$",
"def",
"->",
"child",
"=",
"$",
"this",
"->",
"getChildDef",
"(",
"$",
"def",
",",
"$",
"module",
")",
";",
"}"
] | Accepts a definition; generates and assigns a ChildDef for it
@param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef reference
@param HTMLPurifier_HTMLModule $module Module that defined the ElementDef | [
"Accepts",
"a",
"definition",
";",
"generates",
"and",
"assigns",
"a",
"ChildDef",
"for",
"it"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/ContentSets.php#L83-L100 |
213,781 | moodle/moodle | cache/stores/mongodb/MongoDB/Operation/Update.php | Update.createUpdateOptions | private function createUpdateOptions()
{
$updateOptions = [
'multi' => $this->options['multi'],
'upsert' => $this->options['upsert'],
];
if (isset($this->options['arrayFilters'])) {
$updateOptions['arrayFilters'] = $this->options['arrayFilters'];
}
if (isset($this->options['collation'])) {
$updateOptions['collation'] = (object) $this->options['collation'];
}
return $updateOptions;
} | php | private function createUpdateOptions()
{
$updateOptions = [
'multi' => $this->options['multi'],
'upsert' => $this->options['upsert'],
];
if (isset($this->options['arrayFilters'])) {
$updateOptions['arrayFilters'] = $this->options['arrayFilters'];
}
if (isset($this->options['collation'])) {
$updateOptions['collation'] = (object) $this->options['collation'];
}
return $updateOptions;
} | [
"private",
"function",
"createUpdateOptions",
"(",
")",
"{",
"$",
"updateOptions",
"=",
"[",
"'multi'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'multi'",
"]",
",",
"'upsert'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'upsert'",
"]",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'arrayFilters'",
"]",
")",
")",
"{",
"$",
"updateOptions",
"[",
"'arrayFilters'",
"]",
"=",
"$",
"this",
"->",
"options",
"[",
"'arrayFilters'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'collation'",
"]",
")",
")",
"{",
"$",
"updateOptions",
"[",
"'collation'",
"]",
"=",
"(",
"object",
")",
"$",
"this",
"->",
"options",
"[",
"'collation'",
"]",
";",
"}",
"return",
"$",
"updateOptions",
";",
"}"
] | Create options for the update command.
Note that these options are different from the bulk write options, which
are created in createExecuteOptions().
@return array | [
"Create",
"options",
"for",
"the",
"update",
"command",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Operation/Update.php#L228-L244 |
213,782 | moodle/moodle | lib/ddl/mysql_sql_generator.php | mysql_sql_generator.guess_antelope_row_size | public function guess_antelope_row_size(array $columns) {
if (empty($columns)) {
return 0;
}
$size = 0;
$first = reset($columns);
if (count($columns) > 1) {
// Do not start with zero because we need to cover changes of field types and
// this calculation is most probably not be accurate.
$size += 1000;
}
if ($first instanceof xmldb_field) {
foreach ($columns as $field) {
switch ($field->getType()) {
case XMLDB_TYPE_TEXT:
$size += 768;
break;
case XMLDB_TYPE_BINARY:
$size += 768;
break;
case XMLDB_TYPE_CHAR:
$bytes = $field->getLength() * 3;
if ($bytes > 768) {
$bytes = 768;
}
$size += $bytes;
break;
default:
// Anything else is usually maximum 8 bytes.
$size += 8;
}
}
} else if ($first instanceof database_column_info) {
foreach ($columns as $column) {
switch ($column->meta_type) {
case 'X':
$size += 768;
break;
case 'B':
$size += 768;
break;
case 'C':
$bytes = $column->max_length * 3;
if ($bytes > 768) {
$bytes = 768;
}
$size += $bytes;
break;
default:
// Anything else is usually maximum 8 bytes.
$size += 8;
}
}
}
return $size;
} | php | public function guess_antelope_row_size(array $columns) {
if (empty($columns)) {
return 0;
}
$size = 0;
$first = reset($columns);
if (count($columns) > 1) {
// Do not start with zero because we need to cover changes of field types and
// this calculation is most probably not be accurate.
$size += 1000;
}
if ($first instanceof xmldb_field) {
foreach ($columns as $field) {
switch ($field->getType()) {
case XMLDB_TYPE_TEXT:
$size += 768;
break;
case XMLDB_TYPE_BINARY:
$size += 768;
break;
case XMLDB_TYPE_CHAR:
$bytes = $field->getLength() * 3;
if ($bytes > 768) {
$bytes = 768;
}
$size += $bytes;
break;
default:
// Anything else is usually maximum 8 bytes.
$size += 8;
}
}
} else if ($first instanceof database_column_info) {
foreach ($columns as $column) {
switch ($column->meta_type) {
case 'X':
$size += 768;
break;
case 'B':
$size += 768;
break;
case 'C':
$bytes = $column->max_length * 3;
if ($bytes > 768) {
$bytes = 768;
}
$size += $bytes;
break;
default:
// Anything else is usually maximum 8 bytes.
$size += 8;
}
}
}
return $size;
} | [
"public",
"function",
"guess_antelope_row_size",
"(",
"array",
"$",
"columns",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"size",
"=",
"0",
";",
"$",
"first",
"=",
"reset",
"(",
"$",
"columns",
")",
";",
"if",
"(",
"count",
"(",
"$",
"columns",
")",
">",
"1",
")",
"{",
"// Do not start with zero because we need to cover changes of field types and",
"// this calculation is most probably not be accurate.",
"$",
"size",
"+=",
"1000",
";",
"}",
"if",
"(",
"$",
"first",
"instanceof",
"xmldb_field",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"field",
")",
"{",
"switch",
"(",
"$",
"field",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"XMLDB_TYPE_TEXT",
":",
"$",
"size",
"+=",
"768",
";",
"break",
";",
"case",
"XMLDB_TYPE_BINARY",
":",
"$",
"size",
"+=",
"768",
";",
"break",
";",
"case",
"XMLDB_TYPE_CHAR",
":",
"$",
"bytes",
"=",
"$",
"field",
"->",
"getLength",
"(",
")",
"*",
"3",
";",
"if",
"(",
"$",
"bytes",
">",
"768",
")",
"{",
"$",
"bytes",
"=",
"768",
";",
"}",
"$",
"size",
"+=",
"$",
"bytes",
";",
"break",
";",
"default",
":",
"// Anything else is usually maximum 8 bytes.",
"$",
"size",
"+=",
"8",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"first",
"instanceof",
"database_column_info",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"switch",
"(",
"$",
"column",
"->",
"meta_type",
")",
"{",
"case",
"'X'",
":",
"$",
"size",
"+=",
"768",
";",
"break",
";",
"case",
"'B'",
":",
"$",
"size",
"+=",
"768",
";",
"break",
";",
"case",
"'C'",
":",
"$",
"bytes",
"=",
"$",
"column",
"->",
"max_length",
"*",
"3",
";",
"if",
"(",
"$",
"bytes",
">",
"768",
")",
"{",
"$",
"bytes",
"=",
"768",
";",
"}",
"$",
"size",
"+=",
"$",
"bytes",
";",
"break",
";",
"default",
":",
"// Anything else is usually maximum 8 bytes.",
"$",
"size",
"+=",
"8",
";",
"}",
"}",
"}",
"return",
"$",
"size",
";",
"}"
] | Calculate proximate row size when using InnoDB tables in Antelope row format.
Note: the returned value is a bit higher to compensate for errors and changes of column data types.
@param xmldb_field[]|database_column_info[] $columns
@return int approximate row size in bytes | [
"Calculate",
"proximate",
"row",
"size",
"when",
"using",
"InnoDB",
"tables",
"in",
"Antelope",
"row",
"format",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/mysql_sql_generator.php#L135-L196 |
213,783 | moodle/moodle | backup/util/structure/base_optigroup.class.php | base_optigroup.set_parent | protected function set_parent($element) {
parent::set_parent($element);
// Force condition param calculation in all children
foreach ($this->get_children() as $child) {
$child->set_condition($child->get_condition_param(), $child->get_condition_value());
}
} | php | protected function set_parent($element) {
parent::set_parent($element);
// Force condition param calculation in all children
foreach ($this->get_children() as $child) {
$child->set_condition($child->get_condition_param(), $child->get_condition_value());
}
} | [
"protected",
"function",
"set_parent",
"(",
"$",
"element",
")",
"{",
"parent",
"::",
"set_parent",
"(",
"$",
"element",
")",
";",
"// Force condition param calculation in all children",
"foreach",
"(",
"$",
"this",
"->",
"get_children",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"set_condition",
"(",
"$",
"child",
"->",
"get_condition_param",
"(",
")",
",",
"$",
"child",
"->",
"get_condition_value",
"(",
")",
")",
";",
"}",
"}"
] | Set the parent of the optigroup and, at the same time, process all the
condition params in all the childs | [
"Set",
"the",
"parent",
"of",
"the",
"optigroup",
"and",
"at",
"the",
"same",
"time",
"process",
"all",
"the",
"condition",
"params",
"in",
"all",
"the",
"childs"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/structure/base_optigroup.class.php#L122-L128 |
213,784 | moodle/moodle | backup/util/structure/base_optigroup.class.php | base_optigroup.add_used | protected function add_used($element) {
$newused = array();
// Iterate over all the element useds, filling $newused and
// observing the multiple setting
foreach ($element->get_used() as $used) {
if (!in_array($used, $this->get_used())) { // it's a new one, add to $newused array
$newused[] = $used;
$this->set_used(array_merge($this->get_used(), array($used))); // add to the optigroup used array
} else { // it's an existing one, exception on multiple optigroups
if ($this->multiple) {
throw new base_optigroup_exception('multiple_optigroup_duplicate_element', $used);
}
}
}
// Finally, inform about newused to the next grand(parent/optigroupelement)
if ($newused && $this->get_parent()) {
$element->set_used($newused); // Only about the newused
$grandparent = $this->get_grandoptigroupelement_or_grandparent();
$grandparent->check_and_set_used($element);
}
} | php | protected function add_used($element) {
$newused = array();
// Iterate over all the element useds, filling $newused and
// observing the multiple setting
foreach ($element->get_used() as $used) {
if (!in_array($used, $this->get_used())) { // it's a new one, add to $newused array
$newused[] = $used;
$this->set_used(array_merge($this->get_used(), array($used))); // add to the optigroup used array
} else { // it's an existing one, exception on multiple optigroups
if ($this->multiple) {
throw new base_optigroup_exception('multiple_optigroup_duplicate_element', $used);
}
}
}
// Finally, inform about newused to the next grand(parent/optigroupelement)
if ($newused && $this->get_parent()) {
$element->set_used($newused); // Only about the newused
$grandparent = $this->get_grandoptigroupelement_or_grandparent();
$grandparent->check_and_set_used($element);
}
} | [
"protected",
"function",
"add_used",
"(",
"$",
"element",
")",
"{",
"$",
"newused",
"=",
"array",
"(",
")",
";",
"// Iterate over all the element useds, filling $newused and",
"// observing the multiple setting",
"foreach",
"(",
"$",
"element",
"->",
"get_used",
"(",
")",
"as",
"$",
"used",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"used",
",",
"$",
"this",
"->",
"get_used",
"(",
")",
")",
")",
"{",
"// it's a new one, add to $newused array",
"$",
"newused",
"[",
"]",
"=",
"$",
"used",
";",
"$",
"this",
"->",
"set_used",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"get_used",
"(",
")",
",",
"array",
"(",
"$",
"used",
")",
")",
")",
";",
"// add to the optigroup used array",
"}",
"else",
"{",
"// it's an existing one, exception on multiple optigroups",
"if",
"(",
"$",
"this",
"->",
"multiple",
")",
"{",
"throw",
"new",
"base_optigroup_exception",
"(",
"'multiple_optigroup_duplicate_element'",
",",
"$",
"used",
")",
";",
"}",
"}",
"}",
"// Finally, inform about newused to the next grand(parent/optigroupelement)",
"if",
"(",
"$",
"newused",
"&&",
"$",
"this",
"->",
"get_parent",
"(",
")",
")",
"{",
"$",
"element",
"->",
"set_used",
"(",
"$",
"newused",
")",
";",
"// Only about the newused",
"$",
"grandparent",
"=",
"$",
"this",
"->",
"get_grandoptigroupelement_or_grandparent",
"(",
")",
";",
"$",
"grandparent",
"->",
"check_and_set_used",
"(",
"$",
"element",
")",
";",
"}",
"}"
] | Recalculate all the used elements in the optigroup, observing
restrictions and passing the new used to outer level | [
"Recalculate",
"all",
"the",
"used",
"elements",
"in",
"the",
"optigroup",
"observing",
"restrictions",
"and",
"passing",
"the",
"new",
"used",
"to",
"outer",
"level"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/structure/base_optigroup.class.php#L134-L154 |
213,785 | moodle/moodle | completion/criteria/completion_criteria_date.php | completion_criteria_date.update_date | public static function update_date($courseid, $timeshift) {
if ($criteria = self::fetch(array('course' => $courseid))) {
$criteria->timeend = $criteria->timeend + $timeshift;
$criteria->update();
}
} | php | public static function update_date($courseid, $timeshift) {
if ($criteria = self::fetch(array('course' => $courseid))) {
$criteria->timeend = $criteria->timeend + $timeshift;
$criteria->update();
}
} | [
"public",
"static",
"function",
"update_date",
"(",
"$",
"courseid",
",",
"$",
"timeshift",
")",
"{",
"if",
"(",
"$",
"criteria",
"=",
"self",
"::",
"fetch",
"(",
"array",
"(",
"'course'",
"=>",
"$",
"courseid",
")",
")",
")",
"{",
"$",
"criteria",
"->",
"timeend",
"=",
"$",
"criteria",
"->",
"timeend",
"+",
"$",
"timeshift",
";",
"$",
"criteria",
"->",
"update",
"(",
")",
";",
"}",
"}"
] | Shift the date when resetting course.
@param int $courseid the course id
@param int $timeshift number of seconds to shift date
@return boolean was the operation successful? | [
"Shift",
"the",
"date",
"when",
"resetting",
"course",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/criteria/completion_criteria_date.php#L224-L229 |
213,786 | moodle/moodle | lib/ltiprovider/src/ToolProvider/Context.php | Context.initialize | public function initialize()
{
$this->title = '';
$this->settings = array();
$this->created = null;
$this->updated = null;
} | php | public function initialize()
{
$this->title = '';
$this->settings = array();
$this->created = null;
$this->updated = null;
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"''",
";",
"$",
"this",
"->",
"settings",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"created",
"=",
"null",
";",
"$",
"this",
"->",
"updated",
"=",
"null",
";",
"}"
] | Initialise the context. | [
"Initialise",
"the",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/Context.php#L101-L109 |
213,787 | moodle/moodle | lib/ltiprovider/src/ToolProvider/Context.php | Context.save | public function save()
{
$ok = $this->getDataConnector()->saveContext($this);
if ($ok) {
$this->settingsChanged = false;
}
return $ok;
} | php | public function save()
{
$ok = $this->getDataConnector()->saveContext($this);
if ($ok) {
$this->settingsChanged = false;
}
return $ok;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"ok",
"=",
"$",
"this",
"->",
"getDataConnector",
"(",
")",
"->",
"saveContext",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"ok",
")",
"{",
"$",
"this",
"->",
"settingsChanged",
"=",
"false",
";",
"}",
"return",
"$",
"ok",
";",
"}"
] | Save the context to the database.
@return boolean True if the context was successfully saved. | [
"Save",
"the",
"context",
"to",
"the",
"database",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/Context.php#L128-L138 |
213,788 | moodle/moodle | lib/ltiprovider/src/ToolProvider/Context.php | Context.getSetting | public function getSetting($name, $default = '')
{
if (array_key_exists($name, $this->settings)) {
$value = $this->settings[$name];
} else {
$value = $default;
}
return $value;
} | php | public function getSetting($name, $default = '')
{
if (array_key_exists($name, $this->settings)) {
$value = $this->settings[$name];
} else {
$value = $default;
}
return $value;
} | [
"public",
"function",
"getSetting",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"''",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"settings",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"settings",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Get a setting value.
@param string $name Name of setting
@param string $default Value to return if the setting does not exist (optional, default is an empty string)
@return string Setting value | [
"Get",
"a",
"setting",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/Context.php#L248-L259 |
213,789 | moodle/moodle | lib/ltiprovider/src/ToolProvider/Context.php | Context.getToolSettings | public function getToolSettings($mode = Service\ToolSettings::MODE_CURRENT_LEVEL, $simple = true)
{
$url = $this->getSetting('custom_context_setting_url');
$service = new Service\ToolSettings($this, $url, $simple);
$response = $service->get($mode);
return $response;
} | php | public function getToolSettings($mode = Service\ToolSettings::MODE_CURRENT_LEVEL, $simple = true)
{
$url = $this->getSetting('custom_context_setting_url');
$service = new Service\ToolSettings($this, $url, $simple);
$response = $service->get($mode);
return $response;
} | [
"public",
"function",
"getToolSettings",
"(",
"$",
"mode",
"=",
"Service",
"\\",
"ToolSettings",
"::",
"MODE_CURRENT_LEVEL",
",",
"$",
"simple",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getSetting",
"(",
"'custom_context_setting_url'",
")",
";",
"$",
"service",
"=",
"new",
"Service",
"\\",
"ToolSettings",
"(",
"$",
"this",
",",
"$",
"url",
",",
"$",
"simple",
")",
";",
"$",
"response",
"=",
"$",
"service",
"->",
"get",
"(",
"$",
"mode",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Get Tool Settings.
@param int $mode Mode for request (optional, default is current level only)
@param boolean $simple True if all the simple media type is to be used (optional, default is true)
@return mixed The array of settings if successful, otherwise false | [
"Get",
"Tool",
"Settings",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/Context.php#L346-L355 |
213,790 | moodle/moodle | privacy/classes/local/request/approved_userlist.php | approved_userlist.create_from_userlist | public static function create_from_userlist(userlist $userlist) : approved_userlist {
$newlist = new static($userlist->get_context(), $userlist->get_component(), $userlist->get_userids());
return $newlist;
} | php | public static function create_from_userlist(userlist $userlist) : approved_userlist {
$newlist = new static($userlist->get_context(), $userlist->get_component(), $userlist->get_userids());
return $newlist;
} | [
"public",
"static",
"function",
"create_from_userlist",
"(",
"userlist",
"$",
"userlist",
")",
":",
"approved_userlist",
"{",
"$",
"newlist",
"=",
"new",
"static",
"(",
"$",
"userlist",
"->",
"get_context",
"(",
")",
",",
"$",
"userlist",
"->",
"get_component",
"(",
")",
",",
"$",
"userlist",
"->",
"get_userids",
"(",
")",
")",
";",
"return",
"$",
"newlist",
";",
"}"
] | Create an approved userlist from a userlist.
@param userlist $userlist The source list
@return approved_userlist The newly created approved userlist. | [
"Create",
"an",
"approved",
"userlist",
"from",
"a",
"userlist",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/approved_userlist.php#L56-L60 |
213,791 | moodle/moodle | filter/glossary/filter.php | filter_glossary.get_all_concepts | protected function get_all_concepts() {
global $USER;
if ($this->cache === null) {
$this->cache = cache::make_from_params(cache_store::MODE_REQUEST, 'filter', 'glossary');
}
// Try to get current course.
$coursectx = $this->context->get_course_context(false);
if (!$coursectx) {
// Only global glossaries will be linked.
$courseid = 0;
} else {
$courseid = $coursectx->instanceid;
}
$cached = $this->cache->get('concepts');
if ($cached !== false && ($cached->cachecourseid != $courseid || $cached->cacheuserid != $USER->id)) {
// Invalidate the page cache.
$cached = false;
}
if ($cached !== false && is_array($cached->cacheconceptlist)) {
return $cached->cacheconceptlist;
}
list($glossaries, $allconcepts) = \mod_glossary\local\concept_cache::get_concepts($courseid);
if (!$allconcepts) {
$tocache = new stdClass();
$tocache->cacheuserid = $USER->id;
$tocache->cachecourseid = $courseid;
$tocache->cacheconceptlist = [];
$this->cache->set('concepts', $tocache);
return [];
}
$conceptlist = array();
foreach ($allconcepts as $concepts) {
foreach ($concepts as $concept) {
$conceptlist[] = new filterobject($concept->concept, null, null,
$concept->casesensitive, $concept->fullmatch, null,
[$this, 'filterobject_prepare_replacement_callback'], [$concept, $glossaries]);
}
}
// We sort longest first, so that when we replace the terms,
// the longest ones are replaced first. This does the right thing
// when you have two terms like 'Moodle' and 'Moodle 3.5'. You want the longest match.
usort($conceptlist, [$this, 'sort_entries_by_length']);
$conceptlist = filter_prepare_phrases_for_filtering($conceptlist);
$tocache = new stdClass();
$tocache->cacheuserid = $USER->id;
$tocache->cachecourseid = $courseid;
$tocache->cacheconceptlist = $conceptlist;
$this->cache->set('concepts', $tocache);
return $conceptlist;
} | php | protected function get_all_concepts() {
global $USER;
if ($this->cache === null) {
$this->cache = cache::make_from_params(cache_store::MODE_REQUEST, 'filter', 'glossary');
}
// Try to get current course.
$coursectx = $this->context->get_course_context(false);
if (!$coursectx) {
// Only global glossaries will be linked.
$courseid = 0;
} else {
$courseid = $coursectx->instanceid;
}
$cached = $this->cache->get('concepts');
if ($cached !== false && ($cached->cachecourseid != $courseid || $cached->cacheuserid != $USER->id)) {
// Invalidate the page cache.
$cached = false;
}
if ($cached !== false && is_array($cached->cacheconceptlist)) {
return $cached->cacheconceptlist;
}
list($glossaries, $allconcepts) = \mod_glossary\local\concept_cache::get_concepts($courseid);
if (!$allconcepts) {
$tocache = new stdClass();
$tocache->cacheuserid = $USER->id;
$tocache->cachecourseid = $courseid;
$tocache->cacheconceptlist = [];
$this->cache->set('concepts', $tocache);
return [];
}
$conceptlist = array();
foreach ($allconcepts as $concepts) {
foreach ($concepts as $concept) {
$conceptlist[] = new filterobject($concept->concept, null, null,
$concept->casesensitive, $concept->fullmatch, null,
[$this, 'filterobject_prepare_replacement_callback'], [$concept, $glossaries]);
}
}
// We sort longest first, so that when we replace the terms,
// the longest ones are replaced first. This does the right thing
// when you have two terms like 'Moodle' and 'Moodle 3.5'. You want the longest match.
usort($conceptlist, [$this, 'sort_entries_by_length']);
$conceptlist = filter_prepare_phrases_for_filtering($conceptlist);
$tocache = new stdClass();
$tocache->cacheuserid = $USER->id;
$tocache->cachecourseid = $courseid;
$tocache->cacheconceptlist = $conceptlist;
$this->cache->set('concepts', $tocache);
return $conceptlist;
} | [
"protected",
"function",
"get_all_concepts",
"(",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"cache",
"::",
"make_from_params",
"(",
"cache_store",
"::",
"MODE_REQUEST",
",",
"'filter'",
",",
"'glossary'",
")",
";",
"}",
"// Try to get current course.",
"$",
"coursectx",
"=",
"$",
"this",
"->",
"context",
"->",
"get_course_context",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"coursectx",
")",
"{",
"// Only global glossaries will be linked.",
"$",
"courseid",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"courseid",
"=",
"$",
"coursectx",
"->",
"instanceid",
";",
"}",
"$",
"cached",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"'concepts'",
")",
";",
"if",
"(",
"$",
"cached",
"!==",
"false",
"&&",
"(",
"$",
"cached",
"->",
"cachecourseid",
"!=",
"$",
"courseid",
"||",
"$",
"cached",
"->",
"cacheuserid",
"!=",
"$",
"USER",
"->",
"id",
")",
")",
"{",
"// Invalidate the page cache.",
"$",
"cached",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"cached",
"!==",
"false",
"&&",
"is_array",
"(",
"$",
"cached",
"->",
"cacheconceptlist",
")",
")",
"{",
"return",
"$",
"cached",
"->",
"cacheconceptlist",
";",
"}",
"list",
"(",
"$",
"glossaries",
",",
"$",
"allconcepts",
")",
"=",
"\\",
"mod_glossary",
"\\",
"local",
"\\",
"concept_cache",
"::",
"get_concepts",
"(",
"$",
"courseid",
")",
";",
"if",
"(",
"!",
"$",
"allconcepts",
")",
"{",
"$",
"tocache",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"tocache",
"->",
"cacheuserid",
"=",
"$",
"USER",
"->",
"id",
";",
"$",
"tocache",
"->",
"cachecourseid",
"=",
"$",
"courseid",
";",
"$",
"tocache",
"->",
"cacheconceptlist",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'concepts'",
",",
"$",
"tocache",
")",
";",
"return",
"[",
"]",
";",
"}",
"$",
"conceptlist",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"allconcepts",
"as",
"$",
"concepts",
")",
"{",
"foreach",
"(",
"$",
"concepts",
"as",
"$",
"concept",
")",
"{",
"$",
"conceptlist",
"[",
"]",
"=",
"new",
"filterobject",
"(",
"$",
"concept",
"->",
"concept",
",",
"null",
",",
"null",
",",
"$",
"concept",
"->",
"casesensitive",
",",
"$",
"concept",
"->",
"fullmatch",
",",
"null",
",",
"[",
"$",
"this",
",",
"'filterobject_prepare_replacement_callback'",
"]",
",",
"[",
"$",
"concept",
",",
"$",
"glossaries",
"]",
")",
";",
"}",
"}",
"// We sort longest first, so that when we replace the terms,",
"// the longest ones are replaced first. This does the right thing",
"// when you have two terms like 'Moodle' and 'Moodle 3.5'. You want the longest match.",
"usort",
"(",
"$",
"conceptlist",
",",
"[",
"$",
"this",
",",
"'sort_entries_by_length'",
"]",
")",
";",
"$",
"conceptlist",
"=",
"filter_prepare_phrases_for_filtering",
"(",
"$",
"conceptlist",
")",
";",
"$",
"tocache",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"tocache",
"->",
"cacheuserid",
"=",
"$",
"USER",
"->",
"id",
";",
"$",
"tocache",
"->",
"cachecourseid",
"=",
"$",
"courseid",
";",
"$",
"tocache",
"->",
"cacheconceptlist",
"=",
"$",
"conceptlist",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'concepts'",
",",
"$",
"tocache",
")",
";",
"return",
"$",
"conceptlist",
";",
"}"
] | Get all the concepts for this context.
@return filterobject[] the concepts, and filterobjects. | [
"Get",
"all",
"the",
"concepts",
"for",
"this",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/filter/glossary/filter.php#L53-L114 |
213,792 | moodle/moodle | lib/mustache/src/Mustache/Cache/NoopCache.php | Mustache_Cache_NoopCache.cache | public function cache($key, $value)
{
$this->log(
Mustache_Logger::WARNING,
'Template cache disabled, evaluating "{className}" class at runtime',
array('className' => $key)
);
eval('?>' . $value);
} | php | public function cache($key, $value)
{
$this->log(
Mustache_Logger::WARNING,
'Template cache disabled, evaluating "{className}" class at runtime',
array('className' => $key)
);
eval('?>' . $value);
} | [
"public",
"function",
"cache",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"Mustache_Logger",
"::",
"WARNING",
",",
"'Template cache disabled, evaluating \"{className}\" class at runtime'",
",",
"array",
"(",
"'className'",
"=>",
"$",
"key",
")",
")",
";",
"eval",
"(",
"'?>'",
".",
"$",
"value",
")",
";",
"}"
] | Loads the compiled Mustache Template class without caching.
@param string $key
@param string $value | [
"Loads",
"the",
"compiled",
"Mustache",
"Template",
"class",
"without",
"caching",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Cache/NoopCache.php#L38-L46 |
213,793 | moodle/moodle | admin/tool/dataprivacy/classes/expiry_info.php | expiry_info.is_any_expired | public function is_any_expired() : bool {
if ($this->is_fully_expired()) {
return true;
}
if (!empty($this->get_expired_roles())) {
return true;
}
if ($this->is_default_expired()) {
return true;
}
return false;
} | php | public function is_any_expired() : bool {
if ($this->is_fully_expired()) {
return true;
}
if (!empty($this->get_expired_roles())) {
return true;
}
if ($this->is_default_expired()) {
return true;
}
return false;
} | [
"public",
"function",
"is_any_expired",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"is_fully_expired",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"get_expired_roles",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"is_default_expired",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Whether any part of this context has expired.
@return bool | [
"Whether",
"any",
"part",
"of",
"this",
"context",
"has",
"expired",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/expiry_info.php#L88-L102 |
213,794 | moodle/moodle | admin/tool/dataprivacy/classes/expiry_info.php | expiry_info.get_unprotected_overridden_roles | public function get_unprotected_overridden_roles() : array {
$allroles = array_merge($this->expired, $this->unexpired);
return array_diff($allroles, $this->protectedroles);
} | php | public function get_unprotected_overridden_roles() : array {
$allroles = array_merge($this->expired, $this->unexpired);
return array_diff($allroles, $this->protectedroles);
} | [
"public",
"function",
"get_unprotected_overridden_roles",
"(",
")",
":",
"array",
"{",
"$",
"allroles",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"expired",
",",
"$",
"this",
"->",
"unexpired",
")",
";",
"return",
"array_diff",
"(",
"$",
"allroles",
",",
"$",
"this",
"->",
"protectedroles",
")",
";",
"}"
] | Get a list of all overridden roles which are unprotected.
@return int[] | [
"Get",
"a",
"list",
"of",
"all",
"overridden",
"roles",
"which",
"are",
"unprotected",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/expiry_info.php#L168-L172 |
213,795 | moodle/moodle | admin/tool/dataprivacy/classes/expiry_info.php | expiry_info.merge_with_child | public function merge_with_child(expiry_info $child) : expiry_info {
if ($child->is_fully_expired()) {
return $this;
}
// If the child is not fully expired, then none of the parents can be either.
$this->fullyexpired = false;
// Remove any role in this node which is not expired in the child.
foreach ($this->expired as $key => $roleid) {
if (!$child->is_role_expired($roleid)) {
unset($this->expired[$key]);
}
}
array_merge($this->unexpired, $child->get_unexpired_roles());
if (!$child->is_default_expired()) {
$this->defaultexpiryreached = false;
}
return $this;
} | php | public function merge_with_child(expiry_info $child) : expiry_info {
if ($child->is_fully_expired()) {
return $this;
}
// If the child is not fully expired, then none of the parents can be either.
$this->fullyexpired = false;
// Remove any role in this node which is not expired in the child.
foreach ($this->expired as $key => $roleid) {
if (!$child->is_role_expired($roleid)) {
unset($this->expired[$key]);
}
}
array_merge($this->unexpired, $child->get_unexpired_roles());
if (!$child->is_default_expired()) {
$this->defaultexpiryreached = false;
}
return $this;
} | [
"public",
"function",
"merge_with_child",
"(",
"expiry_info",
"$",
"child",
")",
":",
"expiry_info",
"{",
"if",
"(",
"$",
"child",
"->",
"is_fully_expired",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// If the child is not fully expired, then none of the parents can be either.",
"$",
"this",
"->",
"fullyexpired",
"=",
"false",
";",
"// Remove any role in this node which is not expired in the child.",
"foreach",
"(",
"$",
"this",
"->",
"expired",
"as",
"$",
"key",
"=>",
"$",
"roleid",
")",
"{",
"if",
"(",
"!",
"$",
"child",
"->",
"is_role_expired",
"(",
"$",
"roleid",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"expired",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"array_merge",
"(",
"$",
"this",
"->",
"unexpired",
",",
"$",
"child",
"->",
"get_unexpired_roles",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"child",
"->",
"is_default_expired",
"(",
")",
")",
"{",
"$",
"this",
"->",
"defaultexpiryreached",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Merge this expiry_info object with another belonging to a child context in order to set the 'safest' heritage.
It is not possible to delete any part of a context that is not deleted by a parent.
So if a course's retention policy has been reached, then only parts where the children have also expired can be
deleted.
@param expiry_info $child The child record to merge with.
@return $this | [
"Merge",
"this",
"expiry_info",
"object",
"with",
"another",
"belonging",
"to",
"a",
"child",
"context",
"in",
"order",
"to",
"set",
"the",
"safest",
"heritage",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/expiry_info.php#L184-L206 |
213,796 | moodle/moodle | lib/mlbackend/php/phpml/src/Phpml/Math/LinearAlgebra/LUDecomposition.php | LUDecomposition.getL | public function getL()
{
$L = [];
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i > $j) {
$L[$i][$j] = $this->LU[$i][$j];
} elseif ($i == $j) {
$L[$i][$j] = 1.0;
} else {
$L[$i][$j] = 0.0;
}
}
}
return new Matrix($L);
} | php | public function getL()
{
$L = [];
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i > $j) {
$L[$i][$j] = $this->LU[$i][$j];
} elseif ($i == $j) {
$L[$i][$j] = 1.0;
} else {
$L[$i][$j] = 0.0;
}
}
}
return new Matrix($L);
} | [
"public",
"function",
"getL",
"(",
")",
"{",
"$",
"L",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"m",
";",
"++",
"$",
"i",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"this",
"->",
"n",
";",
"++",
"$",
"j",
")",
"{",
"if",
"(",
"$",
"i",
">",
"$",
"j",
")",
"{",
"$",
"L",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"$",
"this",
"->",
"LU",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
";",
"}",
"elseif",
"(",
"$",
"i",
"==",
"$",
"j",
")",
"{",
"$",
"L",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"1.0",
";",
"}",
"else",
"{",
"$",
"L",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"0.0",
";",
"}",
"}",
"}",
"return",
"new",
"Matrix",
"(",
"$",
"L",
")",
";",
"}"
] | Get lower triangular factor.
@return Matrix Lower triangular factor | [
"Get",
"lower",
"triangular",
"factor",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mlbackend/php/phpml/src/Phpml/Math/LinearAlgebra/LUDecomposition.php#L139-L154 |
213,797 | moodle/moodle | question/classes/bank/search/tag_condition.php | tag_condition.display_options | public function display_options() {
global $OUTPUT;
$tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $this->contexts);
$tagoptions = array_map(function($tag) {
return [
'id' => $tag->id,
'name' => $tag->name,
'selected' => in_array($tag->id, $this->selectedtagids)
];
}, array_values($tags));
$context = [
'tagoptions' => $tagoptions
];
echo $OUTPUT->render_from_template('core_question/tag_condition', $context);
} | php | public function display_options() {
global $OUTPUT;
$tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $this->contexts);
$tagoptions = array_map(function($tag) {
return [
'id' => $tag->id,
'name' => $tag->name,
'selected' => in_array($tag->id, $this->selectedtagids)
];
}, array_values($tags));
$context = [
'tagoptions' => $tagoptions
];
echo $OUTPUT->render_from_template('core_question/tag_condition', $context);
} | [
"public",
"function",
"display_options",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"tags",
"=",
"\\",
"core_tag_tag",
"::",
"get_tags_by_area_in_contexts",
"(",
"'core_question'",
",",
"'question'",
",",
"$",
"this",
"->",
"contexts",
")",
";",
"$",
"tagoptions",
"=",
"array_map",
"(",
"function",
"(",
"$",
"tag",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"tag",
"->",
"id",
",",
"'name'",
"=>",
"$",
"tag",
"->",
"name",
",",
"'selected'",
"=>",
"in_array",
"(",
"$",
"tag",
"->",
"id",
",",
"$",
"this",
"->",
"selectedtagids",
")",
"]",
";",
"}",
",",
"array_values",
"(",
"$",
"tags",
")",
")",
";",
"$",
"context",
"=",
"[",
"'tagoptions'",
"=>",
"$",
"tagoptions",
"]",
";",
"echo",
"$",
"OUTPUT",
"->",
"render_from_template",
"(",
"'core_question/tag_condition'",
",",
"$",
"context",
")",
";",
"}"
] | Print HTML to display the list of tags to filter by. | [
"Print",
"HTML",
"to",
"display",
"the",
"list",
"of",
"tags",
"to",
"filter",
"by",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/tag_condition.php#L106-L122 |
213,798 | moodle/moodle | lib/dml/oci_native_moodle_database.php | oci_native_moodle_database.parse_query | protected function parse_query($sql) {
$stmt = oci_parse($this->oci, $sql);
if ($stmt == false) {
throw new dml_connection_exception('Can not parse sql query'); //TODO: maybe add better info
}
return $stmt;
} | php | protected function parse_query($sql) {
$stmt = oci_parse($this->oci, $sql);
if ($stmt == false) {
throw new dml_connection_exception('Can not parse sql query'); //TODO: maybe add better info
}
return $stmt;
} | [
"protected",
"function",
"parse_query",
"(",
"$",
"sql",
")",
"{",
"$",
"stmt",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"oci",
",",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"stmt",
"==",
"false",
")",
"{",
"throw",
"new",
"dml_connection_exception",
"(",
"'Can not parse sql query'",
")",
";",
"//TODO: maybe add better info",
"}",
"return",
"$",
"stmt",
";",
"}"
] | Prepare the statement for execution
@throws dml_connection_exception
@param string $sql
@return resource | [
"Prepare",
"the",
"statement",
"for",
"execution"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/oci_native_moodle_database.php#L352-L358 |
213,799 | moodle/moodle | lib/dml/oci_native_moodle_database.php | oci_native_moodle_database.tweak_param_names | protected function tweak_param_names($sql, array $params) {
if (empty($params)) {
return array($sql, $params);
}
$newparams = array();
$searcharr = array(); // search => replace pairs
foreach ($params as $name => $value) {
// Keep the name within the 30 chars limit always (prefixing/replacing)
if (strlen($name) <= 28) {
$newname = 'o_' . $name;
} else {
$newname = 'o_' . substr($name, 2);
}
$newparams[$newname] = $value;
$searcharr[':' . $name] = ':' . $newname;
}
// sort by length desc to avoid potential str_replace() overlap
uksort($searcharr, array('oci_native_moodle_database', 'compare_by_length_desc'));
$sql = str_replace(array_keys($searcharr), $searcharr, $sql);
return array($sql, $newparams);
} | php | protected function tweak_param_names($sql, array $params) {
if (empty($params)) {
return array($sql, $params);
}
$newparams = array();
$searcharr = array(); // search => replace pairs
foreach ($params as $name => $value) {
// Keep the name within the 30 chars limit always (prefixing/replacing)
if (strlen($name) <= 28) {
$newname = 'o_' . $name;
} else {
$newname = 'o_' . substr($name, 2);
}
$newparams[$newname] = $value;
$searcharr[':' . $name] = ':' . $newname;
}
// sort by length desc to avoid potential str_replace() overlap
uksort($searcharr, array('oci_native_moodle_database', 'compare_by_length_desc'));
$sql = str_replace(array_keys($searcharr), $searcharr, $sql);
return array($sql, $newparams);
} | [
"protected",
"function",
"tweak_param_names",
"(",
"$",
"sql",
",",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"return",
"array",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"}",
"$",
"newparams",
"=",
"array",
"(",
")",
";",
"$",
"searcharr",
"=",
"array",
"(",
")",
";",
"// search => replace pairs",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"// Keep the name within the 30 chars limit always (prefixing/replacing)",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"<=",
"28",
")",
"{",
"$",
"newname",
"=",
"'o_'",
".",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"newname",
"=",
"'o_'",
".",
"substr",
"(",
"$",
"name",
",",
"2",
")",
";",
"}",
"$",
"newparams",
"[",
"$",
"newname",
"]",
"=",
"$",
"value",
";",
"$",
"searcharr",
"[",
"':'",
".",
"$",
"name",
"]",
"=",
"':'",
".",
"$",
"newname",
";",
"}",
"// sort by length desc to avoid potential str_replace() overlap",
"uksort",
"(",
"$",
"searcharr",
",",
"array",
"(",
"'oci_native_moodle_database'",
",",
"'compare_by_length_desc'",
")",
")",
";",
"$",
"sql",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"searcharr",
")",
",",
"$",
"searcharr",
",",
"$",
"sql",
")",
";",
"return",
"array",
"(",
"$",
"sql",
",",
"$",
"newparams",
")",
";",
"}"
] | Make sure there are no reserved words in param names...
@param string $sql
@param array $params
@return array ($sql, $params) updated query and parameters | [
"Make",
"sure",
"there",
"are",
"no",
"reserved",
"words",
"in",
"param",
"names",
"..."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/oci_native_moodle_database.php#L366-L388 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.