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,500 | moodle/moodle | lib/minify/matthiasmullie-minify/src/JS.php | JS.restoreExtractedData | protected function restoreExtractedData($content)
{
// restore regular extracted stuff
$content = parent::restoreExtractedData($content);
// restore nested stuff from within regex extraction
$content = strtr($content, $this->nestedExtracted);
return $content;
} | php | protected function restoreExtractedData($content)
{
// restore regular extracted stuff
$content = parent::restoreExtractedData($content);
// restore nested stuff from within regex extraction
$content = strtr($content, $this->nestedExtracted);
return $content;
} | [
"protected",
"function",
"restoreExtractedData",
"(",
"$",
"content",
")",
"{",
"// restore regular extracted stuff",
"$",
"content",
"=",
"parent",
"::",
"restoreExtractedData",
"(",
"$",
"content",
")",
";",
"// restore nested stuff from within regex extraction",
"$",
"content",
"=",
"strtr",
"(",
"$",
"content",
",",
"$",
"this",
"->",
"nestedExtracted",
")",
";",
"return",
"$",
"content",
";",
"}"
] | In addition to the regular restore routine, we also need to restore a few
more things that have been extracted as part of the regex extraction...
{@inheritdoc} | [
"In",
"addition",
"to",
"the",
"regular",
"restore",
"routine",
"we",
"also",
"need",
"to",
"restore",
"a",
"few",
"more",
"things",
"that",
"have",
"been",
"extracted",
"as",
"part",
"of",
"the",
"regex",
"extraction",
"..."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/JS.php#L310-L319 |
213,501 | moodle/moodle | lib/minify/matthiasmullie-minify/src/JS.php | JS.getOperatorsForRegex | protected function getOperatorsForRegex(array $operators, $delimiter = '/')
{
// escape operators for use in regex
$delimiters = array_fill(0, count($operators), $delimiter);
$escaped = array_map('preg_quote', $operators, $delimiters);
$operators = array_combine($operators, $escaped);
// ignore + & - for now, they'll get special treatment
unset($operators['+'], $operators['-']);
// dot can not just immediately follow a number; it can be confused for
// decimal point, or calling a method on it, e.g. 42 .toString()
$operators['.'] = '(?<![0-9]\s)\.';
// don't confuse = with other assignment shortcuts (e.g. +=)
$chars = preg_quote('+-*\=<>%&|', $delimiter);
$operators['='] = '(?<!['.$chars.'])\=';
return $operators;
} | php | protected function getOperatorsForRegex(array $operators, $delimiter = '/')
{
// escape operators for use in regex
$delimiters = array_fill(0, count($operators), $delimiter);
$escaped = array_map('preg_quote', $operators, $delimiters);
$operators = array_combine($operators, $escaped);
// ignore + & - for now, they'll get special treatment
unset($operators['+'], $operators['-']);
// dot can not just immediately follow a number; it can be confused for
// decimal point, or calling a method on it, e.g. 42 .toString()
$operators['.'] = '(?<![0-9]\s)\.';
// don't confuse = with other assignment shortcuts (e.g. +=)
$chars = preg_quote('+-*\=<>%&|', $delimiter);
$operators['='] = '(?<!['.$chars.'])\=';
return $operators;
} | [
"protected",
"function",
"getOperatorsForRegex",
"(",
"array",
"$",
"operators",
",",
"$",
"delimiter",
"=",
"'/'",
")",
"{",
"// escape operators for use in regex",
"$",
"delimiters",
"=",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"operators",
")",
",",
"$",
"delimiter",
")",
";",
"$",
"escaped",
"=",
"array_map",
"(",
"'preg_quote'",
",",
"$",
"operators",
",",
"$",
"delimiters",
")",
";",
"$",
"operators",
"=",
"array_combine",
"(",
"$",
"operators",
",",
"$",
"escaped",
")",
";",
"// ignore + & - for now, they'll get special treatment",
"unset",
"(",
"$",
"operators",
"[",
"'+'",
"]",
",",
"$",
"operators",
"[",
"'-'",
"]",
")",
";",
"// dot can not just immediately follow a number; it can be confused for",
"// decimal point, or calling a method on it, e.g. 42 .toString()",
"$",
"operators",
"[",
"'.'",
"]",
"=",
"'(?<![0-9]\\s)\\.'",
";",
"// don't confuse = with other assignment shortcuts (e.g. +=)",
"$",
"chars",
"=",
"preg_quote",
"(",
"'+-*\\=<>%&|'",
",",
"$",
"delimiter",
")",
";",
"$",
"operators",
"[",
"'='",
"]",
"=",
"'(?<!['",
".",
"$",
"chars",
".",
"'])\\='",
";",
"return",
"$",
"operators",
";",
"}"
] | We'll strip whitespace around certain operators with regular expressions.
This will prepare the given array by escaping all characters.
@param string[] $operators
@param string $delimiter
@return string[] | [
"We",
"ll",
"strip",
"whitespace",
"around",
"certain",
"operators",
"with",
"regular",
"expressions",
".",
"This",
"will",
"prepare",
"the",
"given",
"array",
"by",
"escaping",
"all",
"characters",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/JS.php#L446-L466 |
213,502 | moodle/moodle | lib/minify/matthiasmullie-minify/src/JS.php | JS.getKeywordsForRegex | protected function getKeywordsForRegex(array $keywords, $delimiter = '/')
{
// escape keywords for use in regex
$delimiter = array_fill(0, count($keywords), $delimiter);
$escaped = array_map('preg_quote', $keywords, $delimiter);
// add word boundaries
array_walk($keywords, function ($value) {
return '\b'.$value.'\b';
});
$keywords = array_combine($keywords, $escaped);
return $keywords;
} | php | protected function getKeywordsForRegex(array $keywords, $delimiter = '/')
{
// escape keywords for use in regex
$delimiter = array_fill(0, count($keywords), $delimiter);
$escaped = array_map('preg_quote', $keywords, $delimiter);
// add word boundaries
array_walk($keywords, function ($value) {
return '\b'.$value.'\b';
});
$keywords = array_combine($keywords, $escaped);
return $keywords;
} | [
"protected",
"function",
"getKeywordsForRegex",
"(",
"array",
"$",
"keywords",
",",
"$",
"delimiter",
"=",
"'/'",
")",
"{",
"// escape keywords for use in regex",
"$",
"delimiter",
"=",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"keywords",
")",
",",
"$",
"delimiter",
")",
";",
"$",
"escaped",
"=",
"array_map",
"(",
"'preg_quote'",
",",
"$",
"keywords",
",",
"$",
"delimiter",
")",
";",
"// add word boundaries",
"array_walk",
"(",
"$",
"keywords",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"'\\b'",
".",
"$",
"value",
".",
"'\\b'",
";",
"}",
")",
";",
"$",
"keywords",
"=",
"array_combine",
"(",
"$",
"keywords",
",",
"$",
"escaped",
")",
";",
"return",
"$",
"keywords",
";",
"}"
] | We'll strip whitespace around certain keywords with regular expressions.
This will prepare the given array by escaping all characters.
@param string[] $keywords
@param string $delimiter
@return string[] | [
"We",
"ll",
"strip",
"whitespace",
"around",
"certain",
"keywords",
"with",
"regular",
"expressions",
".",
"This",
"will",
"prepare",
"the",
"given",
"array",
"by",
"escaping",
"all",
"characters",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/JS.php#L477-L491 |
213,503 | moodle/moodle | lib/minify/matthiasmullie-minify/src/JS.php | JS.shortenBools | protected function shortenBools($content)
{
/*
* 'true' or 'false' could be used as property names (which may be
* followed by whitespace) - we must not replace those!
* Since PHP doesn't allow variable-length (to account for the
* whitespace) lookbehind assertions, I need to capture the leading
* character and check if it's a `.`
*/
$callback = function ($match) {
if (trim($match[1]) === '.') {
return $match[0];
}
return $match[1].($match[2] === 'true' ? '!0' : '!1');
};
$content = preg_replace_callback('/(^|.\s*)\b(true|false)\b(?!:)/', $callback, $content);
// for(;;) is exactly the same as while(true), but shorter :)
$content = preg_replace('/\bwhile\(!0\){/', 'for(;;){', $content);
// now make sure we didn't turn any do ... while(true) into do ... for(;;)
preg_match_all('/\bdo\b/', $content, $dos, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
// go backward to make sure positional offsets aren't altered when $content changes
$dos = array_reverse($dos);
foreach ($dos as $do) {
$offsetDo = $do[0][1];
// find all `while` (now `for`) following `do`: one of those must be
// associated with the `do` and be turned back into `while`
preg_match_all('/\bfor\(;;\)/', $content, $whiles, PREG_OFFSET_CAPTURE | PREG_SET_ORDER, $offsetDo);
foreach ($whiles as $while) {
$offsetWhile = $while[0][1];
$open = substr_count($content, '{', $offsetDo, $offsetWhile - $offsetDo);
$close = substr_count($content, '}', $offsetDo, $offsetWhile - $offsetDo);
if ($open === $close) {
// only restore `while` if amount of `{` and `}` are the same;
// otherwise, that `for` isn't associated with this `do`
$content = substr_replace($content, 'while(!0)', $offsetWhile, strlen('for(;;)'));
break;
}
}
}
return $content;
} | php | protected function shortenBools($content)
{
/*
* 'true' or 'false' could be used as property names (which may be
* followed by whitespace) - we must not replace those!
* Since PHP doesn't allow variable-length (to account for the
* whitespace) lookbehind assertions, I need to capture the leading
* character and check if it's a `.`
*/
$callback = function ($match) {
if (trim($match[1]) === '.') {
return $match[0];
}
return $match[1].($match[2] === 'true' ? '!0' : '!1');
};
$content = preg_replace_callback('/(^|.\s*)\b(true|false)\b(?!:)/', $callback, $content);
// for(;;) is exactly the same as while(true), but shorter :)
$content = preg_replace('/\bwhile\(!0\){/', 'for(;;){', $content);
// now make sure we didn't turn any do ... while(true) into do ... for(;;)
preg_match_all('/\bdo\b/', $content, $dos, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
// go backward to make sure positional offsets aren't altered when $content changes
$dos = array_reverse($dos);
foreach ($dos as $do) {
$offsetDo = $do[0][1];
// find all `while` (now `for`) following `do`: one of those must be
// associated with the `do` and be turned back into `while`
preg_match_all('/\bfor\(;;\)/', $content, $whiles, PREG_OFFSET_CAPTURE | PREG_SET_ORDER, $offsetDo);
foreach ($whiles as $while) {
$offsetWhile = $while[0][1];
$open = substr_count($content, '{', $offsetDo, $offsetWhile - $offsetDo);
$close = substr_count($content, '}', $offsetDo, $offsetWhile - $offsetDo);
if ($open === $close) {
// only restore `while` if amount of `{` and `}` are the same;
// otherwise, that `for` isn't associated with this `do`
$content = substr_replace($content, 'while(!0)', $offsetWhile, strlen('for(;;)'));
break;
}
}
}
return $content;
} | [
"protected",
"function",
"shortenBools",
"(",
"$",
"content",
")",
"{",
"/*\n * 'true' or 'false' could be used as property names (which may be\n * followed by whitespace) - we must not replace those!\n * Since PHP doesn't allow variable-length (to account for the\n * whitespace) lookbehind assertions, I need to capture the leading\n * character and check if it's a `.`\n */",
"$",
"callback",
"=",
"function",
"(",
"$",
"match",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"===",
"'.'",
")",
"{",
"return",
"$",
"match",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"match",
"[",
"1",
"]",
".",
"(",
"$",
"match",
"[",
"2",
"]",
"===",
"'true'",
"?",
"'!0'",
":",
"'!1'",
")",
";",
"}",
";",
"$",
"content",
"=",
"preg_replace_callback",
"(",
"'/(^|.\\s*)\\b(true|false)\\b(?!:)/'",
",",
"$",
"callback",
",",
"$",
"content",
")",
";",
"// for(;;) is exactly the same as while(true), but shorter :)",
"$",
"content",
"=",
"preg_replace",
"(",
"'/\\bwhile\\(!0\\){/'",
",",
"'for(;;){'",
",",
"$",
"content",
")",
";",
"// now make sure we didn't turn any do ... while(true) into do ... for(;;)",
"preg_match_all",
"(",
"'/\\bdo\\b/'",
",",
"$",
"content",
",",
"$",
"dos",
",",
"PREG_OFFSET_CAPTURE",
"|",
"PREG_SET_ORDER",
")",
";",
"// go backward to make sure positional offsets aren't altered when $content changes",
"$",
"dos",
"=",
"array_reverse",
"(",
"$",
"dos",
")",
";",
"foreach",
"(",
"$",
"dos",
"as",
"$",
"do",
")",
"{",
"$",
"offsetDo",
"=",
"$",
"do",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"// find all `while` (now `for`) following `do`: one of those must be",
"// associated with the `do` and be turned back into `while`",
"preg_match_all",
"(",
"'/\\bfor\\(;;\\)/'",
",",
"$",
"content",
",",
"$",
"whiles",
",",
"PREG_OFFSET_CAPTURE",
"|",
"PREG_SET_ORDER",
",",
"$",
"offsetDo",
")",
";",
"foreach",
"(",
"$",
"whiles",
"as",
"$",
"while",
")",
"{",
"$",
"offsetWhile",
"=",
"$",
"while",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"open",
"=",
"substr_count",
"(",
"$",
"content",
",",
"'{'",
",",
"$",
"offsetDo",
",",
"$",
"offsetWhile",
"-",
"$",
"offsetDo",
")",
";",
"$",
"close",
"=",
"substr_count",
"(",
"$",
"content",
",",
"'}'",
",",
"$",
"offsetDo",
",",
"$",
"offsetWhile",
"-",
"$",
"offsetDo",
")",
";",
"if",
"(",
"$",
"open",
"===",
"$",
"close",
")",
"{",
"// only restore `while` if amount of `{` and `}` are the same;",
"// otherwise, that `for` isn't associated with this `do`",
"$",
"content",
"=",
"substr_replace",
"(",
"$",
"content",
",",
"'while(!0)'",
",",
"$",
"offsetWhile",
",",
"strlen",
"(",
"'for(;;)'",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"content",
";",
"}"
] | Replaces true & false by !0 and !1.
@param string $content
@return string | [
"Replaces",
"true",
"&",
"false",
"by",
"!0",
"and",
"!1",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-minify/src/JS.php#L559-L606 |
213,504 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.set_attributes | public function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = $type;
/// Try to split the precision into length and decimals and apply
/// each one as needed
$precisionarr = explode(',', $precision);
if (isset($precisionarr[0])) {
$this->length = trim($precisionarr[0]);
}
if (isset($precisionarr[1])) {
$this->decimals = trim($precisionarr[1]);
}
$this->precision = $type;
$this->notnull = !empty($notnull) ? true : false;
$this->sequence = !empty($sequence) ? true : false;
$this->setDefault($default);
if ($this->type == XMLDB_TYPE_BINARY || $this->type == XMLDB_TYPE_TEXT) {
$this->length = null;
$this->decimals = null;
}
$this->previous = $previous;
} | php | public function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$this->type = $type;
/// Try to split the precision into length and decimals and apply
/// each one as needed
$precisionarr = explode(',', $precision);
if (isset($precisionarr[0])) {
$this->length = trim($precisionarr[0]);
}
if (isset($precisionarr[1])) {
$this->decimals = trim($precisionarr[1]);
}
$this->precision = $type;
$this->notnull = !empty($notnull) ? true : false;
$this->sequence = !empty($sequence) ? true : false;
$this->setDefault($default);
if ($this->type == XMLDB_TYPE_BINARY || $this->type == XMLDB_TYPE_TEXT) {
$this->length = null;
$this->decimals = null;
}
$this->previous = $previous;
} | [
"public",
"function",
"set_attributes",
"(",
"$",
"type",
",",
"$",
"precision",
"=",
"null",
",",
"$",
"unsigned",
"=",
"null",
",",
"$",
"notnull",
"=",
"null",
",",
"$",
"sequence",
"=",
"null",
",",
"$",
"default",
"=",
"null",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"/// Try to split the precision into length and decimals and apply",
"/// each one as needed",
"$",
"precisionarr",
"=",
"explode",
"(",
"','",
",",
"$",
"precision",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"precisionarr",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"trim",
"(",
"$",
"precisionarr",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"precisionarr",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"decimals",
"=",
"trim",
"(",
"$",
"precisionarr",
"[",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"precision",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"notnull",
"=",
"!",
"empty",
"(",
"$",
"notnull",
")",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"sequence",
"=",
"!",
"empty",
"(",
"$",
"sequence",
")",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"setDefault",
"(",
"$",
"default",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_BINARY",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_TEXT",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"null",
";",
"$",
"this",
"->",
"decimals",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"previous",
"=",
"$",
"previous",
";",
"}"
] | Set all the attributes of one xmldb_field
@param int $type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
@param string $precision length for integers and chars, two-comma separated numbers for numbers
@param bool $unsigned XMLDB_UNSIGNED or null (or false)
@param bool $notnull XMLDB_NOTNULL or null (or false)
@param bool $sequence XMLDB_SEQUENCE or null (or false)
@param mixed $default meaningful default o null (or false)
@param xmldb_object $previous | [
"Set",
"all",
"the",
"attributes",
"of",
"one",
"xmldb_field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L117-L139 |
213,505 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.setDefault | public function setDefault($default) {
// Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them
// to NULL so XMLDB will apply the proper default
if ($this->type == XMLDB_TYPE_CHAR && $this->notnull && $default === '') {
$this->errormsg = 'XMLDB has detected one CHAR NOT NULL column (' . $this->name . ") with '' (empty string) as DEFAULT value. This type of columns must have one meaningful DEFAULT declared or none (NULL). XMLDB have fixed it automatically changing it to none (NULL). The process will continue ok and proper defaults will be created accordingly with each DB requirements. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
$this->debug($this->errormsg);
$default = null;
}
// Check, warn and autofix TEXT|BINARY columns having a default clause (only null is allowed)
if (($this->type == XMLDB_TYPE_TEXT || $this->type == XMLDB_TYPE_BINARY) && $default !== null) {
$this->errormsg = 'XMLDB has detected one TEXT/BINARY column (' . $this->name . ") with some DEFAULT defined. This type of columns cannot have any default value. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
$this->debug($this->errormsg);
$default = null;
}
$this->default = $default;
} | php | public function setDefault($default) {
// Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them
// to NULL so XMLDB will apply the proper default
if ($this->type == XMLDB_TYPE_CHAR && $this->notnull && $default === '') {
$this->errormsg = 'XMLDB has detected one CHAR NOT NULL column (' . $this->name . ") with '' (empty string) as DEFAULT value. This type of columns must have one meaningful DEFAULT declared or none (NULL). XMLDB have fixed it automatically changing it to none (NULL). The process will continue ok and proper defaults will be created accordingly with each DB requirements. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
$this->debug($this->errormsg);
$default = null;
}
// Check, warn and autofix TEXT|BINARY columns having a default clause (only null is allowed)
if (($this->type == XMLDB_TYPE_TEXT || $this->type == XMLDB_TYPE_BINARY) && $default !== null) {
$this->errormsg = 'XMLDB has detected one TEXT/BINARY column (' . $this->name . ") with some DEFAULT defined. This type of columns cannot have any default value. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.";
$this->debug($this->errormsg);
$default = null;
}
$this->default = $default;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"default",
")",
"{",
"// Check, warn and auto-fix '' (empty) defaults for CHAR NOT NULL columns, changing them",
"// to NULL so XMLDB will apply the proper default",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_CHAR",
"&&",
"$",
"this",
"->",
"notnull",
"&&",
"$",
"default",
"===",
"''",
")",
"{",
"$",
"this",
"->",
"errormsg",
"=",
"'XMLDB has detected one CHAR NOT NULL column ('",
".",
"$",
"this",
"->",
"name",
".",
"\") with '' (empty string) as DEFAULT value. This type of columns must have one meaningful DEFAULT declared or none (NULL). XMLDB have fixed it automatically changing it to none (NULL). The process will continue ok and proper defaults will be created accordingly with each DB requirements. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errormsg",
")",
";",
"$",
"default",
"=",
"null",
";",
"}",
"// Check, warn and autofix TEXT|BINARY columns having a default clause (only null is allowed)",
"if",
"(",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_TEXT",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_BINARY",
")",
"&&",
"$",
"default",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"errormsg",
"=",
"'XMLDB has detected one TEXT/BINARY column ('",
".",
"$",
"this",
"->",
"name",
".",
"\") with some DEFAULT defined. This type of columns cannot have any default value. Please fix it in source (XML and/or upgrade script) to avoid this message to be displayed.\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errormsg",
")",
";",
"$",
"default",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"default",
"=",
"$",
"default",
";",
"}"
] | Set the field default
@param mixed $default | [
"Set",
"the",
"field",
"default"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L250-L265 |
213,506 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.getXMLDBFieldType | public function getXMLDBFieldType($type) {
$result = XMLDB_TYPE_INCORRECT;
switch (strtolower($type)) {
case 'int':
$result = XMLDB_TYPE_INTEGER;
break;
case 'number':
$result = XMLDB_TYPE_NUMBER;
break;
case 'float':
$result = XMLDB_TYPE_FLOAT;
break;
case 'char':
$result = XMLDB_TYPE_CHAR;
break;
case 'text':
$result = XMLDB_TYPE_TEXT;
break;
case 'binary':
$result = XMLDB_TYPE_BINARY;
break;
case 'datetime':
$result = XMLDB_TYPE_DATETIME;
break;
}
// Return the normalized XMLDB_TYPE
return $result;
} | php | public function getXMLDBFieldType($type) {
$result = XMLDB_TYPE_INCORRECT;
switch (strtolower($type)) {
case 'int':
$result = XMLDB_TYPE_INTEGER;
break;
case 'number':
$result = XMLDB_TYPE_NUMBER;
break;
case 'float':
$result = XMLDB_TYPE_FLOAT;
break;
case 'char':
$result = XMLDB_TYPE_CHAR;
break;
case 'text':
$result = XMLDB_TYPE_TEXT;
break;
case 'binary':
$result = XMLDB_TYPE_BINARY;
break;
case 'datetime':
$result = XMLDB_TYPE_DATETIME;
break;
}
// Return the normalized XMLDB_TYPE
return $result;
} | [
"public",
"function",
"getXMLDBFieldType",
"(",
"$",
"type",
")",
"{",
"$",
"result",
"=",
"XMLDB_TYPE_INCORRECT",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'int'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_INTEGER",
";",
"break",
";",
"case",
"'number'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_NUMBER",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_FLOAT",
";",
"break",
";",
"case",
"'char'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_CHAR",
";",
"break",
";",
"case",
"'text'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_TEXT",
";",
"break",
";",
"case",
"'binary'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_BINARY",
";",
"break",
";",
"case",
"'datetime'",
":",
"$",
"result",
"=",
"XMLDB_TYPE_DATETIME",
";",
"break",
";",
"}",
"// Return the normalized XMLDB_TYPE",
"return",
"$",
"result",
";",
"}"
] | This function returns the correct XMLDB_TYPE_XXX value for the
string passed as argument
@param string $type
@return int | [
"This",
"function",
"returns",
"the",
"correct",
"XMLDB_TYPE_XXX",
"value",
"for",
"the",
"string",
"passed",
"as",
"argument"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L411-L440 |
213,507 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.getXMLDBTypeName | public function getXMLDBTypeName($type) {
$result = "";
switch (strtolower($type)) {
case XMLDB_TYPE_INTEGER:
$result = 'int';
break;
case XMLDB_TYPE_NUMBER:
$result = 'number';
break;
case XMLDB_TYPE_FLOAT:
$result = 'float';
break;
case XMLDB_TYPE_CHAR:
$result = 'char';
break;
case XMLDB_TYPE_TEXT:
$result = 'text';
break;
case XMLDB_TYPE_BINARY:
$result = 'binary';
break;
case XMLDB_TYPE_DATETIME:
$result = 'datetime';
break;
}
// Return the normalized name
return $result;
} | php | public function getXMLDBTypeName($type) {
$result = "";
switch (strtolower($type)) {
case XMLDB_TYPE_INTEGER:
$result = 'int';
break;
case XMLDB_TYPE_NUMBER:
$result = 'number';
break;
case XMLDB_TYPE_FLOAT:
$result = 'float';
break;
case XMLDB_TYPE_CHAR:
$result = 'char';
break;
case XMLDB_TYPE_TEXT:
$result = 'text';
break;
case XMLDB_TYPE_BINARY:
$result = 'binary';
break;
case XMLDB_TYPE_DATETIME:
$result = 'datetime';
break;
}
// Return the normalized name
return $result;
} | [
"public",
"function",
"getXMLDBTypeName",
"(",
"$",
"type",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"XMLDB_TYPE_INTEGER",
":",
"$",
"result",
"=",
"'int'",
";",
"break",
";",
"case",
"XMLDB_TYPE_NUMBER",
":",
"$",
"result",
"=",
"'number'",
";",
"break",
";",
"case",
"XMLDB_TYPE_FLOAT",
":",
"$",
"result",
"=",
"'float'",
";",
"break",
";",
"case",
"XMLDB_TYPE_CHAR",
":",
"$",
"result",
"=",
"'char'",
";",
"break",
";",
"case",
"XMLDB_TYPE_TEXT",
":",
"$",
"result",
"=",
"'text'",
";",
"break",
";",
"case",
"XMLDB_TYPE_BINARY",
":",
"$",
"result",
"=",
"'binary'",
";",
"break",
";",
"case",
"XMLDB_TYPE_DATETIME",
":",
"$",
"result",
"=",
"'datetime'",
";",
"break",
";",
"}",
"// Return the normalized name",
"return",
"$",
"result",
";",
"}"
] | This function returns the correct name value for the
XMLDB_TYPE_XXX passed as argument
@param int $type
@return string | [
"This",
"function",
"returns",
"the",
"correct",
"name",
"value",
"for",
"the",
"XMLDB_TYPE_XXX",
"passed",
"as",
"argument"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L448-L477 |
213,508 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.calculateHash | public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = null;
} else {
$defaulthash = is_null($this->default) ? '' : sha1($this->default);
$key = $this->name . $this->type . $this->length .
$this->notnull . $this->sequence .
$this->decimals . $this->comment . $defaulthash;
$this->hash = md5($key);
}
} | php | public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = null;
} else {
$defaulthash = is_null($this->default) ? '' : sha1($this->default);
$key = $this->name . $this->type . $this->length .
$this->notnull . $this->sequence .
$this->decimals . $this->comment . $defaulthash;
$this->hash = md5($key);
}
} | [
"public",
"function",
"calculateHash",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loaded",
")",
"{",
"$",
"this",
"->",
"hash",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"defaulthash",
"=",
"is_null",
"(",
"$",
"this",
"->",
"default",
")",
"?",
"''",
":",
"sha1",
"(",
"$",
"this",
"->",
"default",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"name",
".",
"$",
"this",
"->",
"type",
".",
"$",
"this",
"->",
"length",
".",
"$",
"this",
"->",
"notnull",
".",
"$",
"this",
"->",
"sequence",
".",
"$",
"this",
"->",
"decimals",
".",
"$",
"this",
"->",
"comment",
".",
"$",
"defaulthash",
";",
"$",
"this",
"->",
"hash",
"=",
"md5",
"(",
"$",
"key",
")",
";",
"}",
"}"
] | This function calculate and set the hash of one xmldb_field
@param bool $recursive
@return void, modifies $this->hash | [
"This",
"function",
"calculate",
"and",
"set",
"the",
"hash",
"of",
"one",
"xmldb_field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L484-L494 |
213,509 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.xmlOutput | public function xmlOutput() {
$o = '';
$o.= ' <FIELD NAME="' . $this->name . '"';
$o.= ' TYPE="' . $this->getXMLDBTypeName($this->type) . '"';
if ($this->length) {
$o.= ' LENGTH="' . $this->length . '"';
}
if ($this->notnull) {
$notnull = 'true';
} else {
$notnull = 'false';
}
$o.= ' NOTNULL="' . $notnull . '"';
if (!$this->sequence && $this->default !== null) {
$o.= ' DEFAULT="' . $this->default . '"';
}
if ($this->sequence) {
$sequence = 'true';
} else {
$sequence = 'false';
}
$o.= ' SEQUENCE="' . $sequence . '"';
if ($this->decimals !== null) {
$o.= ' DECIMALS="' . $this->decimals . '"';
}
if ($this->comment) {
$o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
}
$o.= '/>' . "\n";
return $o;
} | php | public function xmlOutput() {
$o = '';
$o.= ' <FIELD NAME="' . $this->name . '"';
$o.= ' TYPE="' . $this->getXMLDBTypeName($this->type) . '"';
if ($this->length) {
$o.= ' LENGTH="' . $this->length . '"';
}
if ($this->notnull) {
$notnull = 'true';
} else {
$notnull = 'false';
}
$o.= ' NOTNULL="' . $notnull . '"';
if (!$this->sequence && $this->default !== null) {
$o.= ' DEFAULT="' . $this->default . '"';
}
if ($this->sequence) {
$sequence = 'true';
} else {
$sequence = 'false';
}
$o.= ' SEQUENCE="' . $sequence . '"';
if ($this->decimals !== null) {
$o.= ' DECIMALS="' . $this->decimals . '"';
}
if ($this->comment) {
$o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
}
$o.= '/>' . "\n";
return $o;
} | [
"public",
"function",
"xmlOutput",
"(",
")",
"{",
"$",
"o",
"=",
"''",
";",
"$",
"o",
".=",
"' <FIELD NAME=\"'",
".",
"$",
"this",
"->",
"name",
".",
"'\"'",
";",
"$",
"o",
".=",
"' TYPE=\"'",
".",
"$",
"this",
"->",
"getXMLDBTypeName",
"(",
"$",
"this",
"->",
"type",
")",
".",
"'\"'",
";",
"if",
"(",
"$",
"this",
"->",
"length",
")",
"{",
"$",
"o",
".=",
"' LENGTH=\"'",
".",
"$",
"this",
"->",
"length",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"notnull",
")",
"{",
"$",
"notnull",
"=",
"'true'",
";",
"}",
"else",
"{",
"$",
"notnull",
"=",
"'false'",
";",
"}",
"$",
"o",
".=",
"' NOTNULL=\"'",
".",
"$",
"notnull",
".",
"'\"'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"sequence",
"&&",
"$",
"this",
"->",
"default",
"!==",
"null",
")",
"{",
"$",
"o",
".=",
"' DEFAULT=\"'",
".",
"$",
"this",
"->",
"default",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"sequence",
")",
"{",
"$",
"sequence",
"=",
"'true'",
";",
"}",
"else",
"{",
"$",
"sequence",
"=",
"'false'",
";",
"}",
"$",
"o",
".=",
"' SEQUENCE=\"'",
".",
"$",
"sequence",
".",
"'\"'",
";",
"if",
"(",
"$",
"this",
"->",
"decimals",
"!==",
"null",
")",
"{",
"$",
"o",
".=",
"' DECIMALS=\"'",
".",
"$",
"this",
"->",
"decimals",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"comment",
")",
"{",
"$",
"o",
".=",
"' COMMENT=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"comment",
")",
".",
"'\"'",
";",
"}",
"$",
"o",
".=",
"'/>'",
".",
"\"\\n\"",
";",
"return",
"$",
"o",
";",
"}"
] | This function will output the XML text for one field
@return string | [
"This",
"function",
"will",
"output",
"the",
"XML",
"text",
"for",
"one",
"field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L500-L531 |
213,510 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.setFromADOField | public function setFromADOField($adofield) {
// Calculate the XMLDB_TYPE
switch (strtolower($adofield->type)) {
case 'int':
case 'tinyint':
case 'smallint':
case 'bigint':
case 'integer':
$this->type = XMLDB_TYPE_INTEGER;
break;
case 'number':
case 'decimal':
case 'dec':
case 'numeric':
$this->type = XMLDB_TYPE_NUMBER;
break;
case 'float':
case 'double':
$this->type = XMLDB_TYPE_FLOAT;
break;
case 'char':
case 'varchar':
case 'enum':
$this->type = XMLDB_TYPE_CHAR;
break;
case 'text':
case 'tinytext':
case 'mediumtext':
case 'longtext':
$this->type = XMLDB_TYPE_TEXT;
break;
case 'blob':
case 'tinyblob':
case 'mediumblob':
case 'longblob':
$this->type = XMLDB_TYPE_BINARY;
break;
case 'datetime':
case 'timestamp':
$this->type = XMLDB_TYPE_DATETIME;
break;
default:
$this->type = XMLDB_TYPE_TEXT;
}
// Calculate the length of the field
if ($adofield->max_length > 0 &&
($this->type == XMLDB_TYPE_INTEGER ||
$this->type == XMLDB_TYPE_NUMBER ||
$this->type == XMLDB_TYPE_FLOAT ||
$this->type == XMLDB_TYPE_CHAR)) {
$this->length = $adofield->max_length;
}
if ($this->type == XMLDB_TYPE_TEXT) {
$this->length = null;
}
if ($this->type == XMLDB_TYPE_BINARY) {
$this->length = null;
}
// Calculate the decimals of the field
if ($adofield->max_length > 0 &&
$adofield->scale &&
($this->type == XMLDB_TYPE_NUMBER ||
$this->type == XMLDB_TYPE_FLOAT)) {
$this->decimals = $adofield->scale;
}
// Calculate the notnull field
if ($adofield->not_null) {
$this->notnull = true;
}
// Calculate the default field
if ($adofield->has_default) {
$this->default = $adofield->default_value;
}
// Calculate the sequence field
if ($adofield->auto_increment) {
$this->sequence = true;
}
// Some more fields
$this->loaded = true;
$this->changed = true;
} | php | public function setFromADOField($adofield) {
// Calculate the XMLDB_TYPE
switch (strtolower($adofield->type)) {
case 'int':
case 'tinyint':
case 'smallint':
case 'bigint':
case 'integer':
$this->type = XMLDB_TYPE_INTEGER;
break;
case 'number':
case 'decimal':
case 'dec':
case 'numeric':
$this->type = XMLDB_TYPE_NUMBER;
break;
case 'float':
case 'double':
$this->type = XMLDB_TYPE_FLOAT;
break;
case 'char':
case 'varchar':
case 'enum':
$this->type = XMLDB_TYPE_CHAR;
break;
case 'text':
case 'tinytext':
case 'mediumtext':
case 'longtext':
$this->type = XMLDB_TYPE_TEXT;
break;
case 'blob':
case 'tinyblob':
case 'mediumblob':
case 'longblob':
$this->type = XMLDB_TYPE_BINARY;
break;
case 'datetime':
case 'timestamp':
$this->type = XMLDB_TYPE_DATETIME;
break;
default:
$this->type = XMLDB_TYPE_TEXT;
}
// Calculate the length of the field
if ($adofield->max_length > 0 &&
($this->type == XMLDB_TYPE_INTEGER ||
$this->type == XMLDB_TYPE_NUMBER ||
$this->type == XMLDB_TYPE_FLOAT ||
$this->type == XMLDB_TYPE_CHAR)) {
$this->length = $adofield->max_length;
}
if ($this->type == XMLDB_TYPE_TEXT) {
$this->length = null;
}
if ($this->type == XMLDB_TYPE_BINARY) {
$this->length = null;
}
// Calculate the decimals of the field
if ($adofield->max_length > 0 &&
$adofield->scale &&
($this->type == XMLDB_TYPE_NUMBER ||
$this->type == XMLDB_TYPE_FLOAT)) {
$this->decimals = $adofield->scale;
}
// Calculate the notnull field
if ($adofield->not_null) {
$this->notnull = true;
}
// Calculate the default field
if ($adofield->has_default) {
$this->default = $adofield->default_value;
}
// Calculate the sequence field
if ($adofield->auto_increment) {
$this->sequence = true;
}
// Some more fields
$this->loaded = true;
$this->changed = true;
} | [
"public",
"function",
"setFromADOField",
"(",
"$",
"adofield",
")",
"{",
"// Calculate the XMLDB_TYPE",
"switch",
"(",
"strtolower",
"(",
"$",
"adofield",
"->",
"type",
")",
")",
"{",
"case",
"'int'",
":",
"case",
"'tinyint'",
":",
"case",
"'smallint'",
":",
"case",
"'bigint'",
":",
"case",
"'integer'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_INTEGER",
";",
"break",
";",
"case",
"'number'",
":",
"case",
"'decimal'",
":",
"case",
"'dec'",
":",
"case",
"'numeric'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_NUMBER",
";",
"break",
";",
"case",
"'float'",
":",
"case",
"'double'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_FLOAT",
";",
"break",
";",
"case",
"'char'",
":",
"case",
"'varchar'",
":",
"case",
"'enum'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_CHAR",
";",
"break",
";",
"case",
"'text'",
":",
"case",
"'tinytext'",
":",
"case",
"'mediumtext'",
":",
"case",
"'longtext'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_TEXT",
";",
"break",
";",
"case",
"'blob'",
":",
"case",
"'tinyblob'",
":",
"case",
"'mediumblob'",
":",
"case",
"'longblob'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_BINARY",
";",
"break",
";",
"case",
"'datetime'",
":",
"case",
"'timestamp'",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_DATETIME",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"type",
"=",
"XMLDB_TYPE_TEXT",
";",
"}",
"// Calculate the length of the field",
"if",
"(",
"$",
"adofield",
"->",
"max_length",
">",
"0",
"&&",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_INTEGER",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_NUMBER",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_FLOAT",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_CHAR",
")",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"$",
"adofield",
"->",
"max_length",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_TEXT",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_BINARY",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"null",
";",
"}",
"// Calculate the decimals of the field",
"if",
"(",
"$",
"adofield",
"->",
"max_length",
">",
"0",
"&&",
"$",
"adofield",
"->",
"scale",
"&&",
"(",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_NUMBER",
"||",
"$",
"this",
"->",
"type",
"==",
"XMLDB_TYPE_FLOAT",
")",
")",
"{",
"$",
"this",
"->",
"decimals",
"=",
"$",
"adofield",
"->",
"scale",
";",
"}",
"// Calculate the notnull field",
"if",
"(",
"$",
"adofield",
"->",
"not_null",
")",
"{",
"$",
"this",
"->",
"notnull",
"=",
"true",
";",
"}",
"// Calculate the default field",
"if",
"(",
"$",
"adofield",
"->",
"has_default",
")",
"{",
"$",
"this",
"->",
"default",
"=",
"$",
"adofield",
"->",
"default_value",
";",
"}",
"// Calculate the sequence field",
"if",
"(",
"$",
"adofield",
"->",
"auto_increment",
")",
"{",
"$",
"this",
"->",
"sequence",
"=",
"true",
";",
"}",
"// Some more fields",
"$",
"this",
"->",
"loaded",
"=",
"true",
";",
"$",
"this",
"->",
"changed",
"=",
"true",
";",
"}"
] | This function will set all the attributes of the xmldb_field object
based on information passed in one ADOField
@param string $adofield
@return void, sets $this->type | [
"This",
"function",
"will",
"set",
"all",
"the",
"attributes",
"of",
"the",
"xmldb_field",
"object",
"based",
"on",
"information",
"passed",
"in",
"one",
"ADOField"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L539-L620 |
213,511 | moodle/moodle | lib/xmldb/xmldb_field.php | xmldb_field.getPHP | public function getPHP($includeprevious=true) {
$result = '';
// The XMLDBTYPE
switch ($this->getType()) {
case XMLDB_TYPE_INTEGER:
$result .= 'XMLDB_TYPE_INTEGER' . ', ';
break;
case XMLDB_TYPE_NUMBER:
$result .= 'XMLDB_TYPE_NUMBER' . ', ';
break;
case XMLDB_TYPE_FLOAT:
$result .= 'XMLDB_TYPE_FLOAT' . ', ';
break;
case XMLDB_TYPE_CHAR:
$result .= 'XMLDB_TYPE_CHAR' . ', ';
break;
case XMLDB_TYPE_TEXT:
$result .= 'XMLDB_TYPE_TEXT' . ', ';
break;
case XMLDB_TYPE_BINARY:
$result .= 'XMLDB_TYPE_BINARY' . ', ';
break;
case XMLDB_TYPE_DATETIME:
$result .= 'XMLDB_TYPE_DATETIME' . ', ';
break;
case XMLDB_TYPE_TIMESTAMP:
$result .= 'XMLDB_TYPE_TIMESTAMP' . ', ';
break;
}
// The length
$length = $this->getLength();
$decimals = $this->getDecimals();
if (!empty($length)) {
$result .= "'" . $length;
if (!empty($decimals)) {
$result .= ', ' . $decimals;
}
$result .= "', ";
} else {
$result .= 'null, ';
}
// Unsigned is not used any more since Moodle 2.3
$result .= 'null, ';
// Not Null
$notnull = $this->getNotnull();
if (!empty($notnull)) {
$result .= 'XMLDB_NOTNULL' . ', ';
} else {
$result .= 'null, ';
}
// Sequence
$sequence = $this->getSequence();
if (!empty($sequence)) {
$result .= 'XMLDB_SEQUENCE' . ', ';
} else {
$result .= 'null, ';
}
// Default
$default = $this->getDefault();
if ($default !== null && !$this->getSequence()) {
$result .= "'" . $default . "'";
} else {
$result .= 'null';
}
// Previous (decided by parameter)
if ($includeprevious) {
$previous = $this->getPrevious();
if (!empty($previous)) {
$result .= ", '" . $previous . "'";
} else {
$result .= ', null';
}
}
// Return result
return $result;
} | php | public function getPHP($includeprevious=true) {
$result = '';
// The XMLDBTYPE
switch ($this->getType()) {
case XMLDB_TYPE_INTEGER:
$result .= 'XMLDB_TYPE_INTEGER' . ', ';
break;
case XMLDB_TYPE_NUMBER:
$result .= 'XMLDB_TYPE_NUMBER' . ', ';
break;
case XMLDB_TYPE_FLOAT:
$result .= 'XMLDB_TYPE_FLOAT' . ', ';
break;
case XMLDB_TYPE_CHAR:
$result .= 'XMLDB_TYPE_CHAR' . ', ';
break;
case XMLDB_TYPE_TEXT:
$result .= 'XMLDB_TYPE_TEXT' . ', ';
break;
case XMLDB_TYPE_BINARY:
$result .= 'XMLDB_TYPE_BINARY' . ', ';
break;
case XMLDB_TYPE_DATETIME:
$result .= 'XMLDB_TYPE_DATETIME' . ', ';
break;
case XMLDB_TYPE_TIMESTAMP:
$result .= 'XMLDB_TYPE_TIMESTAMP' . ', ';
break;
}
// The length
$length = $this->getLength();
$decimals = $this->getDecimals();
if (!empty($length)) {
$result .= "'" . $length;
if (!empty($decimals)) {
$result .= ', ' . $decimals;
}
$result .= "', ";
} else {
$result .= 'null, ';
}
// Unsigned is not used any more since Moodle 2.3
$result .= 'null, ';
// Not Null
$notnull = $this->getNotnull();
if (!empty($notnull)) {
$result .= 'XMLDB_NOTNULL' . ', ';
} else {
$result .= 'null, ';
}
// Sequence
$sequence = $this->getSequence();
if (!empty($sequence)) {
$result .= 'XMLDB_SEQUENCE' . ', ';
} else {
$result .= 'null, ';
}
// Default
$default = $this->getDefault();
if ($default !== null && !$this->getSequence()) {
$result .= "'" . $default . "'";
} else {
$result .= 'null';
}
// Previous (decided by parameter)
if ($includeprevious) {
$previous = $this->getPrevious();
if (!empty($previous)) {
$result .= ", '" . $previous . "'";
} else {
$result .= ', null';
}
}
// Return result
return $result;
} | [
"public",
"function",
"getPHP",
"(",
"$",
"includeprevious",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"''",
";",
"// The XMLDBTYPE",
"switch",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"XMLDB_TYPE_INTEGER",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_INTEGER'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_NUMBER",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_NUMBER'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_FLOAT",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_FLOAT'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_CHAR",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_CHAR'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_TEXT",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_TEXT'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_BINARY",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_BINARY'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_DATETIME",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_DATETIME'",
".",
"', '",
";",
"break",
";",
"case",
"XMLDB_TYPE_TIMESTAMP",
":",
"$",
"result",
".=",
"'XMLDB_TYPE_TIMESTAMP'",
".",
"', '",
";",
"break",
";",
"}",
"// The length",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"$",
"decimals",
"=",
"$",
"this",
"->",
"getDecimals",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"length",
")",
")",
"{",
"$",
"result",
".=",
"\"'\"",
".",
"$",
"length",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"decimals",
")",
")",
"{",
"$",
"result",
".=",
"', '",
".",
"$",
"decimals",
";",
"}",
"$",
"result",
".=",
"\"', \"",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'null, '",
";",
"}",
"// Unsigned is not used any more since Moodle 2.3",
"$",
"result",
".=",
"'null, '",
";",
"// Not Null",
"$",
"notnull",
"=",
"$",
"this",
"->",
"getNotnull",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"notnull",
")",
")",
"{",
"$",
"result",
".=",
"'XMLDB_NOTNULL'",
".",
"', '",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'null, '",
";",
"}",
"// Sequence",
"$",
"sequence",
"=",
"$",
"this",
"->",
"getSequence",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sequence",
")",
")",
"{",
"$",
"result",
".=",
"'XMLDB_SEQUENCE'",
".",
"', '",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'null, '",
";",
"}",
"// Default",
"$",
"default",
"=",
"$",
"this",
"->",
"getDefault",
"(",
")",
";",
"if",
"(",
"$",
"default",
"!==",
"null",
"&&",
"!",
"$",
"this",
"->",
"getSequence",
"(",
")",
")",
"{",
"$",
"result",
".=",
"\"'\"",
".",
"$",
"default",
".",
"\"'\"",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"'null'",
";",
"}",
"// Previous (decided by parameter)",
"if",
"(",
"$",
"includeprevious",
")",
"{",
"$",
"previous",
"=",
"$",
"this",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"previous",
")",
")",
"{",
"$",
"result",
".=",
"\", '\"",
".",
"$",
"previous",
".",
"\"'\"",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"', null'",
";",
"}",
"}",
"// Return result",
"return",
"$",
"result",
";",
"}"
] | Returns the PHP code needed to define one xmldb_field
@param bool $includeprevious
@return string | [
"Returns",
"the",
"PHP",
"code",
"needed",
"to",
"define",
"one",
"xmldb_field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_field.php#L627-L704 |
213,512 | moodle/moodle | lib/mustache/src/Mustache/Autoloader.php | Mustache_Autoloader.register | public static function register($baseDir = null)
{
$key = $baseDir ? $baseDir : 0;
if (!isset(self::$instances[$key])) {
self::$instances[$key] = new self($baseDir);
}
$loader = self::$instances[$key];
spl_autoload_register(array($loader, 'autoload'));
return $loader;
} | php | public static function register($baseDir = null)
{
$key = $baseDir ? $baseDir : 0;
if (!isset(self::$instances[$key])) {
self::$instances[$key] = new self($baseDir);
}
$loader = self::$instances[$key];
spl_autoload_register(array($loader, 'autoload'));
return $loader;
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"baseDir",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"baseDir",
"?",
"$",
"baseDir",
":",
"0",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
"=",
"new",
"self",
"(",
"$",
"baseDir",
")",
";",
"}",
"$",
"loader",
"=",
"self",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
";",
"spl_autoload_register",
"(",
"array",
"(",
"$",
"loader",
",",
"'autoload'",
")",
")",
";",
"return",
"$",
"loader",
";",
"}"
] | Register a new instance as an SPL autoloader.
@param string $baseDir Mustache library base directory (default: dirname(__FILE__).'/..')
@return Mustache_Autoloader Registered Autoloader instance | [
"Register",
"a",
"new",
"instance",
"as",
"an",
"SPL",
"autoloader",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Autoloader.php#L54-L66 |
213,513 | moodle/moodle | lib/horde/framework/Horde/Mail/Rfc822/Address.php | Horde_Mail_Rfc822_Address.matchDomain | public function matchDomain($domain)
{
$host = $this->host;
if (is_null($host)) {
return false;
}
$match_domain = explode('.', $domain);
$match_host = array_slice(explode('.', $host), count($match_domain) * -1);
return (strcasecmp($domain, implode('.', $match_host)) === 0);
} | php | public function matchDomain($domain)
{
$host = $this->host;
if (is_null($host)) {
return false;
}
$match_domain = explode('.', $domain);
$match_host = array_slice(explode('.', $host), count($match_domain) * -1);
return (strcasecmp($domain, implode('.', $match_host)) === 0);
} | [
"public",
"function",
"matchDomain",
"(",
"$",
"domain",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"host",
";",
"if",
"(",
"is_null",
"(",
"$",
"host",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"match_domain",
"=",
"explode",
"(",
"'.'",
",",
"$",
"domain",
")",
";",
"$",
"match_host",
"=",
"array_slice",
"(",
"explode",
"(",
"'.'",
",",
"$",
"host",
")",
",",
"count",
"(",
"$",
"match_domain",
")",
"*",
"-",
"1",
")",
";",
"return",
"(",
"strcasecmp",
"(",
"$",
"domain",
",",
"implode",
"(",
"'.'",
",",
"$",
"match_host",
")",
")",
"===",
"0",
")",
";",
"}"
] | Do a case-insensitive match on the address for a given domain.
Matches as many parts of the subdomain in the address as is given in
the input.
@param string $domain Domain to match.
@return boolean True if the address matches the given domain. | [
"Do",
"a",
"case",
"-",
"insensitive",
"match",
"on",
"the",
"address",
"for",
"a",
"given",
"domain",
".",
"Matches",
"as",
"many",
"parts",
"of",
"the",
"subdomain",
"in",
"the",
"address",
"as",
"is",
"given",
"in",
"the",
"input",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/Address.php#L229-L240 |
213,514 | moodle/moodle | lib/ltiprovider/src/ToolProvider/DataConnector/DataConnector.php | DataConnector.loadToolProxy | public function loadToolProxy($toolProxy)
{
$now = time();
$toolProxy->created = $now;
$toolProxy->updated = $now;
return true;
} | php | public function loadToolProxy($toolProxy)
{
$now = time();
$toolProxy->created = $now;
$toolProxy->updated = $now;
return true;
} | [
"public",
"function",
"loadToolProxy",
"(",
"$",
"toolProxy",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"$",
"toolProxy",
"->",
"created",
"=",
"$",
"now",
";",
"$",
"toolProxy",
"->",
"updated",
"=",
"$",
"now",
";",
"return",
"true",
";",
"}"
] | Load tool proxy object.
@param ToolProxy $toolProxy ToolProxy object
@return boolean True if the tool proxy object was successfully loaded | [
"Load",
"tool",
"proxy",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/DataConnector/DataConnector.php#L176-L185 |
213,515 | moodle/moodle | lib/ltiprovider/src/ToolProvider/DataConnector/DataConnector.php | DataConnector.getConsumerKey | protected static function getConsumerKey($key)
{
$len = strlen($key);
if ($len > 255) {
$key = 'sha512:' . hash('sha512', $key);
}
return $key;
} | php | protected static function getConsumerKey($key)
{
$len = strlen($key);
if ($len > 255) {
$key = 'sha512:' . hash('sha512', $key);
}
return $key;
} | [
"protected",
"static",
"function",
"getConsumerKey",
"(",
"$",
"key",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"len",
">",
"255",
")",
"{",
"$",
"key",
"=",
"'sha512:'",
".",
"hash",
"(",
"'sha512'",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"key",
";",
"}"
] | Return a hash of a consumer key for values longer than 255 characters.
@param string $key
@return string | [
"Return",
"a",
"hash",
"of",
"a",
"consumer",
"key",
"for",
"values",
"longer",
"than",
"255",
"characters",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/DataConnector/DataConnector.php#L501-L511 |
213,516 | moodle/moodle | lib/google/src/Google/Auth/OAuth2.php | Google_Auth_OAuth2.refreshToken | public function refreshToken($refreshToken)
{
$this->refreshTokenRequest(
array(
'client_id' => $this->client->getClassConfig($this, 'client_id'),
'client_secret' => $this->client->getClassConfig($this, 'client_secret'),
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token'
)
);
} | php | public function refreshToken($refreshToken)
{
$this->refreshTokenRequest(
array(
'client_id' => $this->client->getClassConfig($this, 'client_id'),
'client_secret' => $this->client->getClassConfig($this, 'client_secret'),
'refresh_token' => $refreshToken,
'grant_type' => 'refresh_token'
)
);
} | [
"public",
"function",
"refreshToken",
"(",
"$",
"refreshToken",
")",
"{",
"$",
"this",
"->",
"refreshTokenRequest",
"(",
"array",
"(",
"'client_id'",
"=>",
"$",
"this",
"->",
"client",
"->",
"getClassConfig",
"(",
"$",
"this",
",",
"'client_id'",
")",
",",
"'client_secret'",
"=>",
"$",
"this",
"->",
"client",
"->",
"getClassConfig",
"(",
"$",
"this",
",",
"'client_secret'",
")",
",",
"'refresh_token'",
"=>",
"$",
"refreshToken",
",",
"'grant_type'",
"=>",
"'refresh_token'",
")",
")",
";",
"}"
] | Fetches a fresh access token with the given refresh token.
@param string $refreshToken
@return void | [
"Fetches",
"a",
"fresh",
"access",
"token",
"with",
"the",
"given",
"refresh",
"token",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Auth/OAuth2.php#L270-L280 |
213,517 | moodle/moodle | lib/google/src/Google/Auth/OAuth2.php | Google_Auth_OAuth2.maybeAddParam | private function maybeAddParam($params, $name)
{
$param = $this->client->getClassConfig($this, $name);
if ($param != '') {
$params[$name] = $param;
}
return $params;
} | php | private function maybeAddParam($params, $name)
{
$param = $this->client->getClassConfig($this, $name);
if ($param != '') {
$params[$name] = $param;
}
return $params;
} | [
"private",
"function",
"maybeAddParam",
"(",
"$",
"params",
",",
"$",
"name",
")",
"{",
"$",
"param",
"=",
"$",
"this",
"->",
"client",
"->",
"getClassConfig",
"(",
"$",
"this",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"param",
"!=",
"''",
")",
"{",
"$",
"params",
"[",
"$",
"name",
"]",
"=",
"$",
"param",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Add a parameter to the auth params if not empty string. | [
"Add",
"a",
"parameter",
"to",
"the",
"auth",
"params",
"if",
"not",
"empty",
"string",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Auth/OAuth2.php#L638-L645 |
213,518 | moodle/moodle | competency/classes/evidence.php | evidence.set_url | protected function set_url($url) {
if ($url instanceof \moodle_url) {
$url = $url->out(false);
}
$this->raw_set('url', $url);
} | php | protected function set_url($url) {
if ($url instanceof \moodle_url) {
$url = $url->out(false);
}
$this->raw_set('url', $url);
} | [
"protected",
"function",
"set_url",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"url",
"instanceof",
"\\",
"moodle_url",
")",
"{",
"$",
"url",
"=",
"$",
"url",
"->",
"out",
"(",
"false",
")",
";",
"}",
"$",
"this",
"->",
"raw_set",
"(",
"'url'",
",",
"$",
"url",
")",
";",
"}"
] | Convenience method handling moodle_urls.
@param null|string|moodle_url $url The URL. | [
"Convenience",
"method",
"handling",
"moodle_urls",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/evidence.php#L165-L170 |
213,519 | moodle/moodle | competency/classes/evidence.php | evidence.validate_descidentifier | protected function validate_descidentifier($value) {
if (!$this->get('id') && !get_string_manager()->string_exists($value, $this->get('desccomponent'))) {
return new lang_string('invalidevidencedesc', 'core_competency');
}
return true;
} | php | protected function validate_descidentifier($value) {
if (!$this->get('id') && !get_string_manager()->string_exists($value, $this->get('desccomponent'))) {
return new lang_string('invalidevidencedesc', 'core_competency');
}
return true;
} | [
"protected",
"function",
"validate_descidentifier",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"get",
"(",
"'id'",
")",
"&&",
"!",
"get_string_manager",
"(",
")",
"->",
"string_exists",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"get",
"(",
"'desccomponent'",
")",
")",
")",
"{",
"return",
"new",
"lang_string",
"(",
"'invalidevidencedesc'",
",",
"'core_competency'",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Validate the description identifier.
Only validate string existence during create. If the string is removed later on we should
not prevent this model from being updated. Alternatively we could check if the string has
changed before performing the check but this overhead is not required for now.
An evidence should usually never be updated anyway.
@param string $value
@return true|lang_string | [
"Validate",
"the",
"description",
"identifier",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/evidence.php#L231-L237 |
213,520 | moodle/moodle | competency/classes/evidence.php | evidence.get_records_for_usercompetency | public static function get_records_for_usercompetency($usercompetencyid,
\context $context,
$sort = '',
$order = 'ASC',
$skip = 0,
$limit = 0) {
global $DB;
$params = array(
'usercompid' => $usercompetencyid,
'path' => $context->path . '/%',
'contextid' => $context->id
);
if (!empty($sort)) {
$sort = ' ORDER BY e.' . $sort . ' ' . $order . ', e.id ASC';
} else {
$sort = ' ORDER BY e.id ASC';
}
$sql = 'SELECT e.*
FROM {' . static::TABLE . '} e
JOIN {context} c ON c.id = e.contextid
WHERE (c.path LIKE :path OR c.id = :contextid)
AND e.usercompetencyid = :usercompid
' . $sort;
$records = $DB->get_records_sql($sql, $params, $skip, $limit);
$instances = array();
foreach ($records as $record) {
$newrecord = new static(0, $record);
array_push($instances, $newrecord);
}
return $instances;
} | php | public static function get_records_for_usercompetency($usercompetencyid,
\context $context,
$sort = '',
$order = 'ASC',
$skip = 0,
$limit = 0) {
global $DB;
$params = array(
'usercompid' => $usercompetencyid,
'path' => $context->path . '/%',
'contextid' => $context->id
);
if (!empty($sort)) {
$sort = ' ORDER BY e.' . $sort . ' ' . $order . ', e.id ASC';
} else {
$sort = ' ORDER BY e.id ASC';
}
$sql = 'SELECT e.*
FROM {' . static::TABLE . '} e
JOIN {context} c ON c.id = e.contextid
WHERE (c.path LIKE :path OR c.id = :contextid)
AND e.usercompetencyid = :usercompid
' . $sort;
$records = $DB->get_records_sql($sql, $params, $skip, $limit);
$instances = array();
foreach ($records as $record) {
$newrecord = new static(0, $record);
array_push($instances, $newrecord);
}
return $instances;
} | [
"public",
"static",
"function",
"get_records_for_usercompetency",
"(",
"$",
"usercompetencyid",
",",
"\\",
"context",
"$",
"context",
",",
"$",
"sort",
"=",
"''",
",",
"$",
"order",
"=",
"'ASC'",
",",
"$",
"skip",
"=",
"0",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"array",
"(",
"'usercompid'",
"=>",
"$",
"usercompetencyid",
",",
"'path'",
"=>",
"$",
"context",
"->",
"path",
".",
"'/%'",
",",
"'contextid'",
"=>",
"$",
"context",
"->",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sort",
")",
")",
"{",
"$",
"sort",
"=",
"' ORDER BY e.'",
".",
"$",
"sort",
".",
"' '",
".",
"$",
"order",
".",
"', e.id ASC'",
";",
"}",
"else",
"{",
"$",
"sort",
"=",
"' ORDER BY e.id ASC'",
";",
"}",
"$",
"sql",
"=",
"'SELECT e.*\n FROM {'",
".",
"static",
"::",
"TABLE",
".",
"'} e\n JOIN {context} c ON c.id = e.contextid\n WHERE (c.path LIKE :path OR c.id = :contextid)\n AND e.usercompetencyid = :usercompid\n '",
".",
"$",
"sort",
";",
"$",
"records",
"=",
"$",
"DB",
"->",
"get_records_sql",
"(",
"$",
"sql",
",",
"$",
"params",
",",
"$",
"skip",
",",
"$",
"limit",
")",
";",
"$",
"instances",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"newrecord",
"=",
"new",
"static",
"(",
"0",
",",
"$",
"record",
")",
";",
"array_push",
"(",
"$",
"instances",
",",
"$",
"newrecord",
")",
";",
"}",
"return",
"$",
"instances",
";",
"}"
] | Load a list of records in a context for a user competency.
@param int $usercompetencyid The id of the user competency.
@param context $context Context to filter the evidence list.
@param string $sort The field from the evidence table to sort on.
@param string $order The sort direction
@param int $skip Limitstart.
@param int $limit Number of rows to return.
@return \core_competency\persistent[] | [
"Load",
"a",
"list",
"of",
"records",
"in",
"a",
"context",
"for",
"a",
"user",
"competency",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/evidence.php#L308-L342 |
213,521 | moodle/moodle | lib/classes/event/base.php | base.get_name | public static function get_name() {
// Override in subclass with real lang string.
$parts = explode('\\', get_called_class());
if (count($parts) !== 3) {
return get_string('unknownevent', 'error');
}
return $parts[0].': '.str_replace('_', ' ', $parts[2]);
} | php | public static function get_name() {
// Override in subclass with real lang string.
$parts = explode('\\', get_called_class());
if (count($parts) !== 3) {
return get_string('unknownevent', 'error');
}
return $parts[0].': '.str_replace('_', ' ', $parts[2]);
} | [
"public",
"static",
"function",
"get_name",
"(",
")",
"{",
"// Override in subclass with real lang string.",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_called_class",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!==",
"3",
")",
"{",
"return",
"get_string",
"(",
"'unknownevent'",
",",
"'error'",
")",
";",
"}",
"return",
"$",
"parts",
"[",
"0",
"]",
".",
"': '",
".",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"parts",
"[",
"2",
"]",
")",
";",
"}"
] | Returns localised general event name.
Override in subclass, we can not make it static and abstract at the same time.
@return string | [
"Returns",
"localised",
"general",
"event",
"name",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L309-L316 |
213,522 | moodle/moodle | lib/classes/event/base.php | base.restore | public static final function restore(array $data, array $logextra) {
$classname = $data['eventname'];
$component = $data['component'];
$action = $data['action'];
$target = $data['target'];
// Security: make 100% sure this really is an event class.
if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
return false;
}
if (!class_exists($classname)) {
return self::restore_unknown($data, $logextra);
}
$event = new $classname();
if (!($event instanceof \core\event\base)) {
return false;
}
$event->init(); // Init method of events could be setting custom properties.
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->logextra = $logextra;
foreach (self::$fields as $key) {
if (!array_key_exists($key, $data)) {
debugging("Event restore data must contain key $key");
$data[$key] = null;
}
}
if (count($data) != count(self::$fields)) {
foreach ($data as $key => $value) {
if (!in_array($key, self::$fields)) {
debugging("Event restore data cannot contain key $key");
unset($data[$key]);
}
}
}
$event->data = $data;
return $event;
} | php | public static final function restore(array $data, array $logextra) {
$classname = $data['eventname'];
$component = $data['component'];
$action = $data['action'];
$target = $data['target'];
// Security: make 100% sure this really is an event class.
if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
return false;
}
if (!class_exists($classname)) {
return self::restore_unknown($data, $logextra);
}
$event = new $classname();
if (!($event instanceof \core\event\base)) {
return false;
}
$event->init(); // Init method of events could be setting custom properties.
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->logextra = $logextra;
foreach (self::$fields as $key) {
if (!array_key_exists($key, $data)) {
debugging("Event restore data must contain key $key");
$data[$key] = null;
}
}
if (count($data) != count(self::$fields)) {
foreach ($data as $key => $value) {
if (!in_array($key, self::$fields)) {
debugging("Event restore data cannot contain key $key");
unset($data[$key]);
}
}
}
$event->data = $data;
return $event;
} | [
"public",
"static",
"final",
"function",
"restore",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"logextra",
")",
"{",
"$",
"classname",
"=",
"$",
"data",
"[",
"'eventname'",
"]",
";",
"$",
"component",
"=",
"$",
"data",
"[",
"'component'",
"]",
";",
"$",
"action",
"=",
"$",
"data",
"[",
"'action'",
"]",
";",
"$",
"target",
"=",
"$",
"data",
"[",
"'target'",
"]",
";",
"// Security: make 100% sure this really is an event class.",
"if",
"(",
"$",
"classname",
"!==",
"\"\\\\{$component}\\\\event\\\\{$target}_{$action}\"",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"self",
"::",
"restore_unknown",
"(",
"$",
"data",
",",
"$",
"logextra",
")",
";",
"}",
"$",
"event",
"=",
"new",
"$",
"classname",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"event",
"instanceof",
"\\",
"core",
"\\",
"event",
"\\",
"base",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"event",
"->",
"init",
"(",
")",
";",
"// Init method of events could be setting custom properties.",
"$",
"event",
"->",
"restored",
"=",
"true",
";",
"$",
"event",
"->",
"triggered",
"=",
"true",
";",
"$",
"event",
"->",
"dispatched",
"=",
"true",
";",
"$",
"event",
"->",
"logextra",
"=",
"$",
"logextra",
";",
"foreach",
"(",
"self",
"::",
"$",
"fields",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"data",
")",
")",
"{",
"debugging",
"(",
"\"Event restore data must contain key $key\"",
")",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"!=",
"count",
"(",
"self",
"::",
"$",
"fields",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"fields",
")",
")",
"{",
"debugging",
"(",
"\"Event restore data cannot contain key $key\"",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"$",
"event",
"->",
"data",
"=",
"$",
"data",
";",
"return",
"$",
"event",
";",
"}"
] | Restore event from existing historic data.
@param array $data
@param array $logextra the format is standardised by logging API
@return bool|\core\event\base | [
"Restore",
"event",
"from",
"existing",
"historic",
"data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L370-L412 |
213,523 | moodle/moodle | lib/classes/event/base.php | base.restore_unknown | protected static final function restore_unknown(array $data, array $logextra) {
$classname = '\core\event\unknown_logged';
/** @var unknown_logged $event */
$event = new $classname();
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->data = $data;
$event->logextra = $logextra;
return $event;
} | php | protected static final function restore_unknown(array $data, array $logextra) {
$classname = '\core\event\unknown_logged';
/** @var unknown_logged $event */
$event = new $classname();
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->data = $data;
$event->logextra = $logextra;
return $event;
} | [
"protected",
"static",
"final",
"function",
"restore_unknown",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"logextra",
")",
"{",
"$",
"classname",
"=",
"'\\core\\event\\unknown_logged'",
";",
"/** @var unknown_logged $event */",
"$",
"event",
"=",
"new",
"$",
"classname",
"(",
")",
";",
"$",
"event",
"->",
"restored",
"=",
"true",
";",
"$",
"event",
"->",
"triggered",
"=",
"true",
";",
"$",
"event",
"->",
"dispatched",
"=",
"true",
";",
"$",
"event",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"event",
"->",
"logextra",
"=",
"$",
"logextra",
";",
"return",
"$",
"event",
";",
"}"
] | Restore unknown event.
@param array $data
@param array $logextra
@return unknown_logged | [
"Restore",
"unknown",
"event",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L421-L433 |
213,524 | moodle/moodle | lib/classes/event/base.php | base.get_static_info | public static final function get_static_info() {
/** Var \core\event\base $event. */
$event = new static();
// Set static event data specific for child class.
$event->init();
return array(
'eventname' => $event->data['eventname'],
'component' => $event->data['component'],
'target' => $event->data['target'],
'action' => $event->data['action'],
'crud' => $event->data['crud'],
'edulevel' => $event->data['edulevel'],
'objecttable' => $event->data['objecttable'],
);
} | php | public static final function get_static_info() {
/** Var \core\event\base $event. */
$event = new static();
// Set static event data specific for child class.
$event->init();
return array(
'eventname' => $event->data['eventname'],
'component' => $event->data['component'],
'target' => $event->data['target'],
'action' => $event->data['action'],
'crud' => $event->data['crud'],
'edulevel' => $event->data['edulevel'],
'objecttable' => $event->data['objecttable'],
);
} | [
"public",
"static",
"final",
"function",
"get_static_info",
"(",
")",
"{",
"/** Var \\core\\event\\base $event. */",
"$",
"event",
"=",
"new",
"static",
"(",
")",
";",
"// Set static event data specific for child class.",
"$",
"event",
"->",
"init",
"(",
")",
";",
"return",
"array",
"(",
"'eventname'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'eventname'",
"]",
",",
"'component'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'component'",
"]",
",",
"'target'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'target'",
"]",
",",
"'action'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'action'",
"]",
",",
"'crud'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'crud'",
"]",
",",
"'edulevel'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'edulevel'",
"]",
",",
"'objecttable'",
"=>",
"$",
"event",
"->",
"data",
"[",
"'objecttable'",
"]",
",",
")",
";",
"}"
] | Get static information about an event.
This is used in reports and is not for general use.
@return array Static information about the event. | [
"Get",
"static",
"information",
"about",
"an",
"event",
".",
"This",
"is",
"used",
"in",
"reports",
"and",
"is",
"not",
"for",
"general",
"use",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L600-L614 |
213,525 | moodle/moodle | lib/classes/event/base.php | base.get_context | public function get_context() {
if (isset($this->context)) {
return $this->context;
}
$this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
return $this->context;
} | php | public function get_context() {
if (isset($this->context)) {
return $this->context;
}
$this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
return $this->context;
} | [
"public",
"function",
"get_context",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"context",
")",
")",
"{",
"return",
"$",
"this",
"->",
"context",
";",
"}",
"$",
"this",
"->",
"context",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"this",
"->",
"data",
"[",
"'contextid'",
"]",
",",
"IGNORE_MISSING",
")",
";",
"return",
"$",
"this",
"->",
"context",
";",
"}"
] | Returns event context.
@return \context | [
"Returns",
"event",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L661-L667 |
213,526 | moodle/moodle | lib/classes/event/base.php | base.add_record_snapshot | public final function add_record_snapshot($tablename, $record) {
global $DB, $CFG;
if ($this->triggered) {
throw new \coding_exception('It is not possible to add snapshots after triggering of events');
}
// Special case for course module, allow instance of cm_info to be passed instead of stdClass.
if ($tablename === 'course_modules' && $record instanceof \cm_info) {
$record = $record->get_course_module_record();
}
// NOTE: this might use some kind of MUC cache,
// hopefully we will not run out of memory here...
if ($CFG->debugdeveloper) {
if (!($record instanceof \stdClass)) {
debugging('Argument $record must be an instance of stdClass.', DEBUG_DEVELOPER);
}
if (!$DB->get_manager()->table_exists($tablename)) {
debugging("Invalid table name '$tablename' specified, database table does not exist.", DEBUG_DEVELOPER);
} else {
$columns = $DB->get_columns($tablename);
$missingfields = array_diff(array_keys($columns), array_keys((array)$record));
if (!empty($missingfields)) {
debugging("Fields list in snapshot record does not match fields list in '$tablename'. Record is missing fields: ".
join(', ', $missingfields), DEBUG_DEVELOPER);
}
}
}
$this->recordsnapshots[$tablename][$record->id] = $record;
} | php | public final function add_record_snapshot($tablename, $record) {
global $DB, $CFG;
if ($this->triggered) {
throw new \coding_exception('It is not possible to add snapshots after triggering of events');
}
// Special case for course module, allow instance of cm_info to be passed instead of stdClass.
if ($tablename === 'course_modules' && $record instanceof \cm_info) {
$record = $record->get_course_module_record();
}
// NOTE: this might use some kind of MUC cache,
// hopefully we will not run out of memory here...
if ($CFG->debugdeveloper) {
if (!($record instanceof \stdClass)) {
debugging('Argument $record must be an instance of stdClass.', DEBUG_DEVELOPER);
}
if (!$DB->get_manager()->table_exists($tablename)) {
debugging("Invalid table name '$tablename' specified, database table does not exist.", DEBUG_DEVELOPER);
} else {
$columns = $DB->get_columns($tablename);
$missingfields = array_diff(array_keys($columns), array_keys((array)$record));
if (!empty($missingfields)) {
debugging("Fields list in snapshot record does not match fields list in '$tablename'. Record is missing fields: ".
join(', ', $missingfields), DEBUG_DEVELOPER);
}
}
}
$this->recordsnapshots[$tablename][$record->id] = $record;
} | [
"public",
"final",
"function",
"add_record_snapshot",
"(",
"$",
"tablename",
",",
"$",
"record",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"if",
"(",
"$",
"this",
"->",
"triggered",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'It is not possible to add snapshots after triggering of events'",
")",
";",
"}",
"// Special case for course module, allow instance of cm_info to be passed instead of stdClass.",
"if",
"(",
"$",
"tablename",
"===",
"'course_modules'",
"&&",
"$",
"record",
"instanceof",
"\\",
"cm_info",
")",
"{",
"$",
"record",
"=",
"$",
"record",
"->",
"get_course_module_record",
"(",
")",
";",
"}",
"// NOTE: this might use some kind of MUC cache,",
"// hopefully we will not run out of memory here...",
"if",
"(",
"$",
"CFG",
"->",
"debugdeveloper",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"record",
"instanceof",
"\\",
"stdClass",
")",
")",
"{",
"debugging",
"(",
"'Argument $record must be an instance of stdClass.'",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"if",
"(",
"!",
"$",
"DB",
"->",
"get_manager",
"(",
")",
"->",
"table_exists",
"(",
"$",
"tablename",
")",
")",
"{",
"debugging",
"(",
"\"Invalid table name '$tablename' specified, database table does not exist.\"",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"else",
"{",
"$",
"columns",
"=",
"$",
"DB",
"->",
"get_columns",
"(",
"$",
"tablename",
")",
";",
"$",
"missingfields",
"=",
"array_diff",
"(",
"array_keys",
"(",
"$",
"columns",
")",
",",
"array_keys",
"(",
"(",
"array",
")",
"$",
"record",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"missingfields",
")",
")",
"{",
"debugging",
"(",
"\"Fields list in snapshot record does not match fields list in '$tablename'. Record is missing fields: \"",
".",
"join",
"(",
"', '",
",",
"$",
"missingfields",
")",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"recordsnapshots",
"[",
"$",
"tablename",
"]",
"[",
"$",
"record",
"->",
"id",
"]",
"=",
"$",
"record",
";",
"}"
] | Add cached data that will be most probably used in event observers.
This is used to improve performance, but it is required for data
that was just deleted.
@param string $tablename
@param \stdClass $record
@throws \coding_exception if used after ::trigger() | [
"Add",
"cached",
"data",
"that",
"will",
"be",
"most",
"probably",
"used",
"in",
"event",
"observers",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L877-L907 |
213,527 | moodle/moodle | lib/classes/event/base.php | base.get_record_snapshot | public final function get_record_snapshot($tablename, $id) {
global $DB;
if ($this->restored) {
throw new \coding_exception('It is not possible to get snapshots from restored events');
}
if (isset($this->recordsnapshots[$tablename][$id])) {
return clone($this->recordsnapshots[$tablename][$id]);
}
$record = $DB->get_record($tablename, array('id'=>$id));
$this->recordsnapshots[$tablename][$id] = $record;
return $record;
} | php | public final function get_record_snapshot($tablename, $id) {
global $DB;
if ($this->restored) {
throw new \coding_exception('It is not possible to get snapshots from restored events');
}
if (isset($this->recordsnapshots[$tablename][$id])) {
return clone($this->recordsnapshots[$tablename][$id]);
}
$record = $DB->get_record($tablename, array('id'=>$id));
$this->recordsnapshots[$tablename][$id] = $record;
return $record;
} | [
"public",
"final",
"function",
"get_record_snapshot",
"(",
"$",
"tablename",
",",
"$",
"id",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"this",
"->",
"restored",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'It is not possible to get snapshots from restored events'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"recordsnapshots",
"[",
"$",
"tablename",
"]",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"clone",
"(",
"$",
"this",
"->",
"recordsnapshots",
"[",
"$",
"tablename",
"]",
"[",
"$",
"id",
"]",
")",
";",
"}",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"$",
"tablename",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"$",
"this",
"->",
"recordsnapshots",
"[",
"$",
"tablename",
"]",
"[",
"$",
"id",
"]",
"=",
"$",
"record",
";",
"return",
"$",
"record",
";",
"}"
] | Returns cached record or fetches data from database if not cached.
@param string $tablename
@param int $id
@return \stdClass
@throws \coding_exception if used after ::restore() | [
"Returns",
"cached",
"record",
"or",
"fetches",
"data",
"from",
"database",
"if",
"not",
"cached",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L918-L933 |
213,528 | moodle/moodle | lib/classes/event/base.php | base.__isset | public function __isset($name) {
if ($name === 'level') {
debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
return isset($this->data['edulevel']);
}
return isset($this->data[$name]);
} | php | public function __isset($name) {
if ($name === 'level') {
debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
return isset($this->data['edulevel']);
}
return isset($this->data[$name]);
} | [
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'level'",
")",
"{",
"debugging",
"(",
"'level property is deprecated, use edulevel property instead'",
",",
"DEBUG_DEVELOPER",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'edulevel'",
"]",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Is data property set?
@param string $name
@return bool | [
"Is",
"data",
"property",
"set?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/base.php#L974-L980 |
213,529 | moodle/moodle | lib/spout/src/Spout/Reader/ODS/Reader.php | Reader.openReader | protected function openReader($filePath)
{
$this->zip = new \ZipArchive();
if ($this->zip->open($filePath) === true) {
$this->sheetIterator = new SheetIterator($filePath, $this->getOptions());
} else {
throw new IOException("Could not open $filePath for reading.");
}
} | php | protected function openReader($filePath)
{
$this->zip = new \ZipArchive();
if ($this->zip->open($filePath) === true) {
$this->sheetIterator = new SheetIterator($filePath, $this->getOptions());
} else {
throw new IOException("Could not open $filePath for reading.");
}
} | [
"protected",
"function",
"openReader",
"(",
"$",
"filePath",
")",
"{",
"$",
"this",
"->",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"zip",
"->",
"open",
"(",
"$",
"filePath",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"sheetIterator",
"=",
"new",
"SheetIterator",
"(",
"$",
"filePath",
",",
"$",
"this",
"->",
"getOptions",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not open $filePath for reading.\"",
")",
";",
"}",
"}"
] | Opens the file at the given file path to make it ready to be read.
@param string $filePath Path of the file to be read
@return void
@throws \Box\Spout\Common\Exception\IOException If the file at the given path or its content cannot be read
@throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file | [
"Opens",
"the",
"file",
"at",
"the",
"given",
"file",
"path",
"to",
"make",
"it",
"ready",
"to",
"be",
"read",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Reader/ODS/Reader.php#L53-L62 |
213,530 | moodle/moodle | lib/pear/PEAR.php | PEAR.registerShutdownFunc | function registerShutdownFunc($func, $args = array())
{
// if we are called statically, there is a potential
// that no shutdown func is registered. Bug #6445
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
register_shutdown_function("_PEAR_call_destructors");
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
}
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
} | php | function registerShutdownFunc($func, $args = array())
{
// if we are called statically, there is a potential
// that no shutdown func is registered. Bug #6445
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
register_shutdown_function("_PEAR_call_destructors");
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
}
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
} | [
"function",
"registerShutdownFunc",
"(",
"$",
"func",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"// if we are called statically, there is a potential",
"// that no shutdown func is registered. Bug #6445",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'_PEAR_SHUTDOWN_REGISTERED'",
"]",
")",
")",
"{",
"register_shutdown_function",
"(",
"\"_PEAR_call_destructors\"",
")",
";",
"$",
"GLOBALS",
"[",
"'_PEAR_SHUTDOWN_REGISTERED'",
"]",
"=",
"true",
";",
"}",
"$",
"GLOBALS",
"[",
"'_PEAR_shutdown_funcs'",
"]",
"[",
"]",
"=",
"array",
"(",
"$",
"func",
",",
"$",
"args",
")",
";",
"}"
] | Use this function to register a shutdown method for static
classes.
@access public
@param mixed $func The function name (or array of class/method) to call
@param mixed $args The arguments to pass to the function
@return void | [
"Use",
"this",
"function",
"to",
"register",
"a",
"shutdown",
"method",
"for",
"static",
"classes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L240-L249 |
213,531 | moodle/moodle | lib/pear/PEAR.php | PEAR.isError | function isError($data, $code = null)
{
if (!is_a($data, 'PEAR_Error')) {
return false;
}
if (is_null($code)) {
return true;
} elseif (is_string($code)) {
return $data->getMessage() == $code;
}
return $data->getCode() == $code;
} | php | function isError($data, $code = null)
{
if (!is_a($data, 'PEAR_Error')) {
return false;
}
if (is_null($code)) {
return true;
} elseif (is_string($code)) {
return $data->getMessage() == $code;
}
return $data->getCode() == $code;
} | [
"function",
"isError",
"(",
"$",
"data",
",",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"data",
",",
"'PEAR_Error'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"code",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"code",
")",
")",
"{",
"return",
"$",
"data",
"->",
"getMessage",
"(",
")",
"==",
"$",
"code",
";",
"}",
"return",
"$",
"data",
"->",
"getCode",
"(",
")",
"==",
"$",
"code",
";",
"}"
] | Tell whether a value is a PEAR error.
@param mixed $data the value to test
@param int $code if $data is an error object, return true
only if $code is a string and
$obj->getMessage() == $code or
$code is an integer and $obj->getCode() == $code
@access public
@return bool true if parameter is an error | [
"Tell",
"whether",
"a",
"value",
"is",
"a",
"PEAR",
"error",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L262-L275 |
213,532 | moodle/moodle | lib/pear/PEAR.php | PEAR.setErrorHandling | function setErrorHandling($mode = null, $options = null)
{
if (isset($this) && is_a($this, 'PEAR')) {
$setmode = &$this->_default_error_mode;
$setoptions = &$this->_default_error_options;
} else {
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
}
switch ($mode) {
case PEAR_ERROR_EXCEPTION:
case PEAR_ERROR_RETURN:
case PEAR_ERROR_PRINT:
case PEAR_ERROR_TRIGGER:
case PEAR_ERROR_DIE:
case null:
$setmode = $mode;
$setoptions = $options;
break;
case PEAR_ERROR_CALLBACK:
$setmode = $mode;
// class/object method callback
if (is_callable($options)) {
$setoptions = $options;
} else {
trigger_error("invalid error callback", E_USER_WARNING);
}
break;
default:
trigger_error("invalid error mode", E_USER_WARNING);
break;
}
} | php | function setErrorHandling($mode = null, $options = null)
{
if (isset($this) && is_a($this, 'PEAR')) {
$setmode = &$this->_default_error_mode;
$setoptions = &$this->_default_error_options;
} else {
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
}
switch ($mode) {
case PEAR_ERROR_EXCEPTION:
case PEAR_ERROR_RETURN:
case PEAR_ERROR_PRINT:
case PEAR_ERROR_TRIGGER:
case PEAR_ERROR_DIE:
case null:
$setmode = $mode;
$setoptions = $options;
break;
case PEAR_ERROR_CALLBACK:
$setmode = $mode;
// class/object method callback
if (is_callable($options)) {
$setoptions = $options;
} else {
trigger_error("invalid error callback", E_USER_WARNING);
}
break;
default:
trigger_error("invalid error mode", E_USER_WARNING);
break;
}
} | [
"function",
"setErrorHandling",
"(",
"$",
"mode",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
")",
"&&",
"is_a",
"(",
"$",
"this",
",",
"'PEAR'",
")",
")",
"{",
"$",
"setmode",
"=",
"&",
"$",
"this",
"->",
"_default_error_mode",
";",
"$",
"setoptions",
"=",
"&",
"$",
"this",
"->",
"_default_error_options",
";",
"}",
"else",
"{",
"$",
"setmode",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_default_error_mode'",
"]",
";",
"$",
"setoptions",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_default_error_options'",
"]",
";",
"}",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"PEAR_ERROR_EXCEPTION",
":",
"case",
"PEAR_ERROR_RETURN",
":",
"case",
"PEAR_ERROR_PRINT",
":",
"case",
"PEAR_ERROR_TRIGGER",
":",
"case",
"PEAR_ERROR_DIE",
":",
"case",
"null",
":",
"$",
"setmode",
"=",
"$",
"mode",
";",
"$",
"setoptions",
"=",
"$",
"options",
";",
"break",
";",
"case",
"PEAR_ERROR_CALLBACK",
":",
"$",
"setmode",
"=",
"$",
"mode",
";",
"// class/object method callback",
"if",
"(",
"is_callable",
"(",
"$",
"options",
")",
")",
"{",
"$",
"setoptions",
"=",
"$",
"options",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"\"invalid error callback\"",
",",
"E_USER_WARNING",
")",
";",
"}",
"break",
";",
"default",
":",
"trigger_error",
"(",
"\"invalid error mode\"",
",",
"E_USER_WARNING",
")",
";",
"break",
";",
"}",
"}"
] | Sets how errors generated by this object should be handled.
Can be invoked both in objects and statically. If called
statically, setErrorHandling sets the default behaviour for all
PEAR objects. If called in an object, setErrorHandling sets
the default behaviour for that object.
@param int $mode
One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
@param mixed $options
When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
to be the callback function or method. A callback
function is a string with the name of the function, a
callback method is an array of two elements: the element
at index 0 is the object, and the element at index 1 is
the name of the method to call in the object.
When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
a printf format string used when printing the error
message.
@access public
@return void
@see PEAR_ERROR_RETURN
@see PEAR_ERROR_PRINT
@see PEAR_ERROR_TRIGGER
@see PEAR_ERROR_DIE
@see PEAR_ERROR_CALLBACK
@see PEAR_ERROR_EXCEPTION
@since PHP 4.0.5 | [
"Sets",
"how",
"errors",
"generated",
"by",
"this",
"object",
"should",
"be",
"handled",
".",
"Can",
"be",
"invoked",
"both",
"in",
"objects",
"and",
"statically",
".",
"If",
"called",
"statically",
"setErrorHandling",
"sets",
"the",
"default",
"behaviour",
"for",
"all",
"PEAR",
"objects",
".",
"If",
"called",
"in",
"an",
"object",
"setErrorHandling",
"sets",
"the",
"default",
"behaviour",
"for",
"that",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L315-L350 |
213,533 | moodle/moodle | lib/pear/PEAR.php | PEAR._checkDelExpect | function _checkDelExpect($error_code)
{
$deleted = false;
foreach ($this->_expected_errors as $key => $error_array) {
if (in_array($error_code, $error_array)) {
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
$deleted = true;
}
// clean up empty arrays
if (0 == count($this->_expected_errors[$key])) {
unset($this->_expected_errors[$key]);
}
}
return $deleted;
} | php | function _checkDelExpect($error_code)
{
$deleted = false;
foreach ($this->_expected_errors as $key => $error_array) {
if (in_array($error_code, $error_array)) {
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
$deleted = true;
}
// clean up empty arrays
if (0 == count($this->_expected_errors[$key])) {
unset($this->_expected_errors[$key]);
}
}
return $deleted;
} | [
"function",
"_checkDelExpect",
"(",
"$",
"error_code",
")",
"{",
"$",
"deleted",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"_expected_errors",
"as",
"$",
"key",
"=>",
"$",
"error_array",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"error_code",
",",
"$",
"error_array",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_expected_errors",
"[",
"$",
"key",
"]",
"[",
"array_search",
"(",
"$",
"error_code",
",",
"$",
"error_array",
")",
"]",
")",
";",
"$",
"deleted",
"=",
"true",
";",
"}",
"// clean up empty arrays",
"if",
"(",
"0",
"==",
"count",
"(",
"$",
"this",
"->",
"_expected_errors",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_expected_errors",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"deleted",
";",
"}"
] | This method checks unsets an error code if available
@param mixed error code
@return bool true if the error code was unset, false otherwise
@access private
@since PHP 4.3.0 | [
"This",
"method",
"checks",
"unsets",
"an",
"error",
"code",
"if",
"available"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L396-L412 |
213,534 | moodle/moodle | lib/pear/PEAR.php | PEAR.delExpect | function delExpect($error_code)
{
$deleted = false;
if ((is_array($error_code) && (0 != count($error_code)))) {
// $error_code is a non-empty array here; we walk through it trying
// to unset all values
foreach ($error_code as $key => $error) {
$deleted = $this->_checkDelExpect($error) ? true : false;
}
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
} elseif (!empty($error_code)) {
// $error_code comes alone, trying to unset it
if ($this->_checkDelExpect($error_code)) {
return true;
}
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
}
// $error_code is empty
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
} | php | function delExpect($error_code)
{
$deleted = false;
if ((is_array($error_code) && (0 != count($error_code)))) {
// $error_code is a non-empty array here; we walk through it trying
// to unset all values
foreach ($error_code as $key => $error) {
$deleted = $this->_checkDelExpect($error) ? true : false;
}
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
} elseif (!empty($error_code)) {
// $error_code comes alone, trying to unset it
if ($this->_checkDelExpect($error_code)) {
return true;
}
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
}
// $error_code is empty
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
} | [
"function",
"delExpect",
"(",
"$",
"error_code",
")",
"{",
"$",
"deleted",
"=",
"false",
";",
"if",
"(",
"(",
"is_array",
"(",
"$",
"error_code",
")",
"&&",
"(",
"0",
"!=",
"count",
"(",
"$",
"error_code",
")",
")",
")",
")",
"{",
"// $error_code is a non-empty array here; we walk through it trying",
"// to unset all values",
"foreach",
"(",
"$",
"error_code",
"as",
"$",
"key",
"=>",
"$",
"error",
")",
"{",
"$",
"deleted",
"=",
"$",
"this",
"->",
"_checkDelExpect",
"(",
"$",
"error",
")",
"?",
"true",
":",
"false",
";",
"}",
"return",
"$",
"deleted",
"?",
"true",
":",
"PEAR",
"::",
"raiseError",
"(",
"\"The expected error you submitted does not exist\"",
")",
";",
"// IMPROVE ME",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"error_code",
")",
")",
"{",
"// $error_code comes alone, trying to unset it",
"if",
"(",
"$",
"this",
"->",
"_checkDelExpect",
"(",
"$",
"error_code",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"PEAR",
"::",
"raiseError",
"(",
"\"The expected error you submitted does not exist\"",
")",
";",
"// IMPROVE ME",
"}",
"// $error_code is empty",
"return",
"PEAR",
"::",
"raiseError",
"(",
"\"The expected error you submitted is empty\"",
")",
";",
"// IMPROVE ME",
"}"
] | This method deletes all occurences of the specified element from
the expected error codes stack.
@param mixed $error_code error code that should be deleted
@return mixed list of error codes that were deleted or error
@access public
@since PHP 4.3.0 | [
"This",
"method",
"deletes",
"all",
"occurences",
"of",
"the",
"specified",
"element",
"from",
"the",
"expected",
"error",
"codes",
"stack",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L423-L445 |
213,535 | moodle/moodle | lib/pear/PEAR.php | PEAR.& | function &throwError($message = null, $code = null, $userinfo = null)
{
if (isset($this) && is_a($this, 'PEAR')) {
$a = &$this->raiseError($message, $code, null, null, $userinfo);
return $a;
}
$a = &PEAR::raiseError($message, $code, null, null, $userinfo);
return $a;
} | php | function &throwError($message = null, $code = null, $userinfo = null)
{
if (isset($this) && is_a($this, 'PEAR')) {
$a = &$this->raiseError($message, $code, null, null, $userinfo);
return $a;
}
$a = &PEAR::raiseError($message, $code, null, null, $userinfo);
return $a;
} | [
"function",
"&",
"throwError",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"code",
"=",
"null",
",",
"$",
"userinfo",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
")",
"&&",
"is_a",
"(",
"$",
"this",
",",
"'PEAR'",
")",
")",
"{",
"$",
"a",
"=",
"&",
"$",
"this",
"->",
"raiseError",
"(",
"$",
"message",
",",
"$",
"code",
",",
"null",
",",
"null",
",",
"$",
"userinfo",
")",
";",
"return",
"$",
"a",
";",
"}",
"$",
"a",
"=",
"&",
"PEAR",
"::",
"raiseError",
"(",
"$",
"message",
",",
"$",
"code",
",",
"null",
",",
"null",
",",
"$",
"userinfo",
")",
";",
"return",
"$",
"a",
";",
"}"
] | Simpler form of raiseError with fewer options. In most cases
message, code and userinfo are enough.
@param mixed $message a text error message or a PEAR error object
@param int $code a numeric error code (it is up to your class
to define these if you want to use codes)
@param string $userinfo If you need to pass along for example debug
information, this parameter is meant for that.
@access public
@return object a PEAR error object
@see PEAR::raiseError | [
"Simpler",
"form",
"of",
"raiseError",
"with",
"fewer",
"options",
".",
"In",
"most",
"cases",
"message",
"code",
"and",
"userinfo",
"are",
"enough",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L567-L576 |
213,536 | moodle/moodle | lib/pear/PEAR.php | PEAR.pushErrorHandling | function pushErrorHandling($mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
if (isset($this) && is_a($this, 'PEAR')) {
$def_mode = &$this->_default_error_mode;
$def_options = &$this->_default_error_options;
} else {
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
$def_options = &$GLOBALS['_PEAR_default_error_options'];
}
$stack[] = array($def_mode, $def_options);
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
$stack[] = array($mode, $options);
return true;
} | php | function pushErrorHandling($mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
if (isset($this) && is_a($this, 'PEAR')) {
$def_mode = &$this->_default_error_mode;
$def_options = &$this->_default_error_options;
} else {
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
$def_options = &$GLOBALS['_PEAR_default_error_options'];
}
$stack[] = array($def_mode, $def_options);
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
$stack[] = array($mode, $options);
return true;
} | [
"function",
"pushErrorHandling",
"(",
"$",
"mode",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"stack",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_error_handler_stack'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
")",
"&&",
"is_a",
"(",
"$",
"this",
",",
"'PEAR'",
")",
")",
"{",
"$",
"def_mode",
"=",
"&",
"$",
"this",
"->",
"_default_error_mode",
";",
"$",
"def_options",
"=",
"&",
"$",
"this",
"->",
"_default_error_options",
";",
"}",
"else",
"{",
"$",
"def_mode",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_default_error_mode'",
"]",
";",
"$",
"def_options",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_default_error_options'",
"]",
";",
"}",
"$",
"stack",
"[",
"]",
"=",
"array",
"(",
"$",
"def_mode",
",",
"$",
"def_options",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
")",
"&&",
"is_a",
"(",
"$",
"this",
",",
"'PEAR'",
")",
")",
"{",
"$",
"this",
"->",
"setErrorHandling",
"(",
"$",
"mode",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"PEAR",
"::",
"setErrorHandling",
"(",
"$",
"mode",
",",
"$",
"options",
")",
";",
"}",
"$",
"stack",
"[",
"]",
"=",
"array",
"(",
"$",
"mode",
",",
"$",
"options",
")",
";",
"return",
"true",
";",
"}"
] | Push a new error handler on top of the error handler options stack. With this
you can easily override the actual error handler for some code and restore
it later with popErrorHandling.
@param mixed $mode (same as setErrorHandling)
@param mixed $options (same as setErrorHandling)
@return bool Always true
@see PEAR::setErrorHandling | [
"Push",
"a",
"new",
"error",
"handler",
"on",
"top",
"of",
"the",
"error",
"handler",
"options",
"stack",
".",
"With",
"this",
"you",
"can",
"easily",
"override",
"the",
"actual",
"error",
"handler",
"for",
"some",
"code",
"and",
"restore",
"it",
"later",
"with",
"popErrorHandling",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L661-L680 |
213,537 | moodle/moodle | lib/pear/PEAR.php | PEAR.popErrorHandling | function popErrorHandling()
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
array_pop($stack);
list($mode, $options) = $stack[sizeof($stack) - 1];
array_pop($stack);
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
return true;
} | php | function popErrorHandling()
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
array_pop($stack);
list($mode, $options) = $stack[sizeof($stack) - 1];
array_pop($stack);
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
return true;
} | [
"function",
"popErrorHandling",
"(",
")",
"{",
"$",
"stack",
"=",
"&",
"$",
"GLOBALS",
"[",
"'_PEAR_error_handler_stack'",
"]",
";",
"array_pop",
"(",
"$",
"stack",
")",
";",
"list",
"(",
"$",
"mode",
",",
"$",
"options",
")",
"=",
"$",
"stack",
"[",
"sizeof",
"(",
"$",
"stack",
")",
"-",
"1",
"]",
";",
"array_pop",
"(",
"$",
"stack",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
")",
"&&",
"is_a",
"(",
"$",
"this",
",",
"'PEAR'",
")",
")",
"{",
"$",
"this",
"->",
"setErrorHandling",
"(",
"$",
"mode",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"PEAR",
"::",
"setErrorHandling",
"(",
"$",
"mode",
",",
"$",
"options",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Pop the last error handler used
@return bool Always true
@see PEAR::pushErrorHandling | [
"Pop",
"the",
"last",
"error",
"handler",
"used"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L689-L701 |
213,538 | moodle/moodle | lib/pear/PEAR.php | PEAR.loadExtension | function loadExtension($ext)
{
if (extension_loaded($ext)) {
return true;
}
// if either returns true dl() will produce a FATAL error, stop that
if (
function_exists('dl') === false ||
ini_get('enable_dl') != 1 ||
ini_get('safe_mode') == 1
) {
return false;
}
if (OS_WINDOWS) {
$suffix = '.dll';
} elseif (PHP_OS == 'HP-UX') {
$suffix = '.sl';
} elseif (PHP_OS == 'AIX') {
$suffix = '.a';
} elseif (PHP_OS == 'OSX') {
$suffix = '.bundle';
} else {
$suffix = '.so';
}
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
} | php | function loadExtension($ext)
{
if (extension_loaded($ext)) {
return true;
}
// if either returns true dl() will produce a FATAL error, stop that
if (
function_exists('dl') === false ||
ini_get('enable_dl') != 1 ||
ini_get('safe_mode') == 1
) {
return false;
}
if (OS_WINDOWS) {
$suffix = '.dll';
} elseif (PHP_OS == 'HP-UX') {
$suffix = '.sl';
} elseif (PHP_OS == 'AIX') {
$suffix = '.a';
} elseif (PHP_OS == 'OSX') {
$suffix = '.bundle';
} else {
$suffix = '.so';
}
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
} | [
"function",
"loadExtension",
"(",
"$",
"ext",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"$",
"ext",
")",
")",
"{",
"return",
"true",
";",
"}",
"// if either returns true dl() will produce a FATAL error, stop that",
"if",
"(",
"function_exists",
"(",
"'dl'",
")",
"===",
"false",
"||",
"ini_get",
"(",
"'enable_dl'",
")",
"!=",
"1",
"||",
"ini_get",
"(",
"'safe_mode'",
")",
"==",
"1",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"OS_WINDOWS",
")",
"{",
"$",
"suffix",
"=",
"'.dll'",
";",
"}",
"elseif",
"(",
"PHP_OS",
"==",
"'HP-UX'",
")",
"{",
"$",
"suffix",
"=",
"'.sl'",
";",
"}",
"elseif",
"(",
"PHP_OS",
"==",
"'AIX'",
")",
"{",
"$",
"suffix",
"=",
"'.a'",
";",
"}",
"elseif",
"(",
"PHP_OS",
"==",
"'OSX'",
")",
"{",
"$",
"suffix",
"=",
"'.bundle'",
";",
"}",
"else",
"{",
"$",
"suffix",
"=",
"'.so'",
";",
"}",
"return",
"@",
"dl",
"(",
"'php_'",
".",
"$",
"ext",
".",
"$",
"suffix",
")",
"||",
"@",
"dl",
"(",
"$",
"ext",
".",
"$",
"suffix",
")",
";",
"}"
] | OS independant PHP extension load. Remember to take care
on the correct extension name for case sensitive OSes.
@param string $ext The extension name
@return bool Success or not on the dl() call | [
"OS",
"independant",
"PHP",
"extension",
"load",
".",
"Remember",
"to",
"take",
"care",
"on",
"the",
"correct",
"extension",
"name",
"for",
"case",
"sensitive",
"OSes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L710-L738 |
213,539 | moodle/moodle | lib/pear/PEAR.php | PEAR_Error.PEAR_Error | public function PEAR_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null) {
self::__construct($message, $code, $mode, $options, $userinfo);
} | php | public function PEAR_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null) {
self::__construct($message, $code, $mode, $options, $userinfo);
} | [
"public",
"function",
"PEAR_Error",
"(",
"$",
"message",
"=",
"'unknown error'",
",",
"$",
"code",
"=",
"null",
",",
"$",
"mode",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"userinfo",
"=",
"null",
")",
"{",
"self",
"::",
"__construct",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"mode",
",",
"$",
"options",
",",
"$",
"userinfo",
")",
";",
"}"
] | Old syntax of class constructor for backward compatibility. | [
"Old",
"syntax",
"of",
"class",
"constructor",
"for",
"backward",
"compatibility",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L914-L917 |
213,540 | moodle/moodle | lib/pear/PEAR.php | PEAR_Error.getBacktrace | function getBacktrace($frame = null)
{
if (defined('PEAR_IGNORE_BACKTRACE')) {
return null;
}
if ($frame === null) {
return $this->backtrace;
}
return $this->backtrace[$frame];
} | php | function getBacktrace($frame = null)
{
if (defined('PEAR_IGNORE_BACKTRACE')) {
return null;
}
if ($frame === null) {
return $this->backtrace;
}
return $this->backtrace[$frame];
} | [
"function",
"getBacktrace",
"(",
"$",
"frame",
"=",
"null",
")",
"{",
"if",
"(",
"defined",
"(",
"'PEAR_IGNORE_BACKTRACE'",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"frame",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"backtrace",
";",
"}",
"return",
"$",
"this",
"->",
"backtrace",
"[",
"$",
"frame",
"]",
";",
"}"
] | Get the call backtrace from where the error was generated.
Supported with PHP 4.3.0 or newer.
@param int $frame (optional) what frame to fetch
@return array Backtrace, or NULL if not available.
@access public | [
"Get",
"the",
"call",
"backtrace",
"from",
"where",
"the",
"error",
"was",
"generated",
".",
"Supported",
"with",
"PHP",
"4",
".",
"3",
".",
"0",
"or",
"newer",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L1004-L1013 |
213,541 | moodle/moodle | lib/pear/PEAR.php | PEAR_Error.toString | function toString()
{
$modes = array();
$levels = array(E_USER_NOTICE => 'notice',
E_USER_WARNING => 'warning',
E_USER_ERROR => 'error');
if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_array($this->callback)) {
$callback = (is_object($this->callback[0]) ?
strtolower(get_class($this->callback[0])) :
$this->callback[0]) . '::' .
$this->callback[1];
} else {
$callback = $this->callback;
}
return sprintf('[%s: message="%s" code=%d mode=callback '.
'callback=%s prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code,
$callback, $this->error_message_prefix,
$this->userinfo);
}
if ($this->mode & PEAR_ERROR_PRINT) {
$modes[] = 'print';
}
if ($this->mode & PEAR_ERROR_TRIGGER) {
$modes[] = 'trigger';
}
if ($this->mode & PEAR_ERROR_DIE) {
$modes[] = 'die';
}
if ($this->mode & PEAR_ERROR_RETURN) {
$modes[] = 'return';
}
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
'prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code,
implode("|", $modes), $levels[$this->level],
$this->error_message_prefix,
$this->userinfo);
} | php | function toString()
{
$modes = array();
$levels = array(E_USER_NOTICE => 'notice',
E_USER_WARNING => 'warning',
E_USER_ERROR => 'error');
if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_array($this->callback)) {
$callback = (is_object($this->callback[0]) ?
strtolower(get_class($this->callback[0])) :
$this->callback[0]) . '::' .
$this->callback[1];
} else {
$callback = $this->callback;
}
return sprintf('[%s: message="%s" code=%d mode=callback '.
'callback=%s prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code,
$callback, $this->error_message_prefix,
$this->userinfo);
}
if ($this->mode & PEAR_ERROR_PRINT) {
$modes[] = 'print';
}
if ($this->mode & PEAR_ERROR_TRIGGER) {
$modes[] = 'trigger';
}
if ($this->mode & PEAR_ERROR_DIE) {
$modes[] = 'die';
}
if ($this->mode & PEAR_ERROR_RETURN) {
$modes[] = 'return';
}
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
'prefix="%s" info="%s"]',
strtolower(get_class($this)), $this->message, $this->code,
implode("|", $modes), $levels[$this->level],
$this->error_message_prefix,
$this->userinfo);
} | [
"function",
"toString",
"(",
")",
"{",
"$",
"modes",
"=",
"array",
"(",
")",
";",
"$",
"levels",
"=",
"array",
"(",
"E_USER_NOTICE",
"=>",
"'notice'",
",",
"E_USER_WARNING",
"=>",
"'warning'",
",",
"E_USER_ERROR",
"=>",
"'error'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"mode",
"&",
"PEAR_ERROR_CALLBACK",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"callback",
")",
")",
"{",
"$",
"callback",
"=",
"(",
"is_object",
"(",
"$",
"this",
"->",
"callback",
"[",
"0",
"]",
")",
"?",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
"->",
"callback",
"[",
"0",
"]",
")",
")",
":",
"$",
"this",
"->",
"callback",
"[",
"0",
"]",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"callback",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"callback",
";",
"}",
"return",
"sprintf",
"(",
"'[%s: message=\"%s\" code=%d mode=callback '",
".",
"'callback=%s prefix=\"%s\" info=\"%s\"]'",
",",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
",",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"code",
",",
"$",
"callback",
",",
"$",
"this",
"->",
"error_message_prefix",
",",
"$",
"this",
"->",
"userinfo",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"&",
"PEAR_ERROR_PRINT",
")",
"{",
"$",
"modes",
"[",
"]",
"=",
"'print'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"&",
"PEAR_ERROR_TRIGGER",
")",
"{",
"$",
"modes",
"[",
"]",
"=",
"'trigger'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"&",
"PEAR_ERROR_DIE",
")",
"{",
"$",
"modes",
"[",
"]",
"=",
"'die'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mode",
"&",
"PEAR_ERROR_RETURN",
")",
"{",
"$",
"modes",
"[",
"]",
"=",
"'return'",
";",
"}",
"return",
"sprintf",
"(",
"'[%s: message=\"%s\" code=%d mode=%s level=%s '",
".",
"'prefix=\"%s\" info=\"%s\"]'",
",",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
",",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"code",
",",
"implode",
"(",
"\"|\"",
",",
"$",
"modes",
")",
",",
"$",
"levels",
"[",
"$",
"this",
"->",
"level",
"]",
",",
"$",
"this",
"->",
"error_message_prefix",
",",
"$",
"this",
"->",
"userinfo",
")",
";",
"}"
] | Make a string representation of this object.
@return string a string with an object summary
@access public | [
"Make",
"a",
"string",
"representation",
"of",
"this",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/PEAR.php#L1035-L1074 |
213,542 | moodle/moodle | lib/classes/output/mustache_quote_helper.php | mustache_quote_helper.quote | public function quote($text, \Mustache_LambdaHelper $helper) {
// Split the text into an array of variables.
$content = trim($text);
$content = $helper->render($content);
// Escape the {{ and the ".
$content = str_replace('"', '\\"', $content);
$content = preg_replace('([{}]{2,3})', '{{=<% %>=}}${0}<%={{ }}=%>', $content);
return '"' . $content . '"';
} | php | public function quote($text, \Mustache_LambdaHelper $helper) {
// Split the text into an array of variables.
$content = trim($text);
$content = $helper->render($content);
// Escape the {{ and the ".
$content = str_replace('"', '\\"', $content);
$content = preg_replace('([{}]{2,3})', '{{=<% %>=}}${0}<%={{ }}=%>', $content);
return '"' . $content . '"';
} | [
"public",
"function",
"quote",
"(",
"$",
"text",
",",
"\\",
"Mustache_LambdaHelper",
"$",
"helper",
")",
"{",
"// Split the text into an array of variables.",
"$",
"content",
"=",
"trim",
"(",
"$",
"text",
")",
";",
"$",
"content",
"=",
"$",
"helper",
"->",
"render",
"(",
"$",
"content",
")",
";",
"// Escape the {{ and the \".",
"$",
"content",
"=",
"str_replace",
"(",
"'\"'",
",",
"'\\\\\"'",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"'([{}]{2,3})'",
",",
"'{{=<% %>=}}${0}<%={{ }}=%>'",
",",
"$",
"content",
")",
";",
"return",
"'\"'",
".",
"$",
"content",
".",
"'\"'",
";",
"}"
] | Wrap content in quotes, and escape all quotes used.
Note: This helper is only compatible with the standard {{ }} delimeters.
@param string $text The text to parse for arguments.
@param Mustache_LambdaHelper $helper Used to render nested mustache variables.
@return string | [
"Wrap",
"content",
"in",
"quotes",
"and",
"escape",
"all",
"quotes",
"used",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/output/mustache_quote_helper.php#L45-L54 |
213,543 | moodle/moodle | lib/classes/event/blog_entry_deleted.php | blog_entry_deleted.init | protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'post';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
} | php | protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'post';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"context",
"=",
"\\",
"context_system",
"::",
"instance",
"(",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'objecttable'",
"]",
"=",
"'post'",
";",
"$",
"this",
"->",
"data",
"[",
"'crud'",
"]",
"=",
"'d'",
";",
"$",
"this",
"->",
"data",
"[",
"'edulevel'",
"]",
"=",
"self",
"::",
"LEVEL_PARTICIPATING",
";",
"}"
] | Set basic event properties. | [
"Set",
"basic",
"event",
"properties",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/blog_entry_deleted.php#L46-L51 |
213,544 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.addField | public function addField($field, $after=null) {
// Detect duplicates first
if ($this->getField($field->getName())) {
throw new coding_exception('Duplicate field '.$field->getName().' specified in table '.$this->getName());
}
// Calculate the previous and next fields
$prevfield = null;
$nextfield = null;
if (!$after) {
$allfields = $this->getFields();
if (!empty($allfields)) {
end($allfields);
$prevfield = $allfields[key($allfields)];
}
} else {
$prevfield = $this->getField($after);
}
if ($prevfield && $prevfield->getNext()) {
$nextfield = $this->getField($prevfield->getNext());
}
// Set current field previous and next attributes
if ($prevfield) {
$field->setPrevious($prevfield->getName());
$prevfield->setNext($field->getName());
}
if ($nextfield) {
$field->setNext($nextfield->getName());
$nextfield->setPrevious($field->getName());
}
// Some more attributes
$field->setLoaded(true);
$field->setChanged(true);
// Add the new field
$this->fields[] = $field;
// Reorder the field
$this->orderFields($this->fields);
// Recalculate the hash
$this->calculateHash(true);
// We have one new field, so the table has changed
$this->setChanged(true);
return $field;
} | php | public function addField($field, $after=null) {
// Detect duplicates first
if ($this->getField($field->getName())) {
throw new coding_exception('Duplicate field '.$field->getName().' specified in table '.$this->getName());
}
// Calculate the previous and next fields
$prevfield = null;
$nextfield = null;
if (!$after) {
$allfields = $this->getFields();
if (!empty($allfields)) {
end($allfields);
$prevfield = $allfields[key($allfields)];
}
} else {
$prevfield = $this->getField($after);
}
if ($prevfield && $prevfield->getNext()) {
$nextfield = $this->getField($prevfield->getNext());
}
// Set current field previous and next attributes
if ($prevfield) {
$field->setPrevious($prevfield->getName());
$prevfield->setNext($field->getName());
}
if ($nextfield) {
$field->setNext($nextfield->getName());
$nextfield->setPrevious($field->getName());
}
// Some more attributes
$field->setLoaded(true);
$field->setChanged(true);
// Add the new field
$this->fields[] = $field;
// Reorder the field
$this->orderFields($this->fields);
// Recalculate the hash
$this->calculateHash(true);
// We have one new field, so the table has changed
$this->setChanged(true);
return $field;
} | [
"public",
"function",
"addField",
"(",
"$",
"field",
",",
"$",
"after",
"=",
"null",
")",
"{",
"// Detect duplicates first",
"if",
"(",
"$",
"this",
"->",
"getField",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Duplicate field '",
".",
"$",
"field",
"->",
"getName",
"(",
")",
".",
"' specified in table '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Calculate the previous and next fields",
"$",
"prevfield",
"=",
"null",
";",
"$",
"nextfield",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"after",
")",
"{",
"$",
"allfields",
"=",
"$",
"this",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"allfields",
")",
")",
"{",
"end",
"(",
"$",
"allfields",
")",
";",
"$",
"prevfield",
"=",
"$",
"allfields",
"[",
"key",
"(",
"$",
"allfields",
")",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"prevfield",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"after",
")",
";",
"}",
"if",
"(",
"$",
"prevfield",
"&&",
"$",
"prevfield",
"->",
"getNext",
"(",
")",
")",
"{",
"$",
"nextfield",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"prevfield",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"// Set current field previous and next attributes",
"if",
"(",
"$",
"prevfield",
")",
"{",
"$",
"field",
"->",
"setPrevious",
"(",
"$",
"prevfield",
"->",
"getName",
"(",
")",
")",
";",
"$",
"prevfield",
"->",
"setNext",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextfield",
")",
"{",
"$",
"field",
"->",
"setNext",
"(",
"$",
"nextfield",
"->",
"getName",
"(",
")",
")",
";",
"$",
"nextfield",
"->",
"setPrevious",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Some more attributes",
"$",
"field",
"->",
"setLoaded",
"(",
"true",
")",
";",
"$",
"field",
"->",
"setChanged",
"(",
"true",
")",
";",
"// Add the new field",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"// Reorder the field",
"$",
"this",
"->",
"orderFields",
"(",
"$",
"this",
"->",
"fields",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one new field, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"return",
"$",
"field",
";",
"}"
] | Add one field to the table, allowing to specify the desired order
If it's not specified, then the field is added at the end
@param xmldb_field $field
@param xmldb_object $after
@return xmldb_field | [
"Add",
"one",
"field",
"to",
"the",
"table",
"allowing",
"to",
"specify",
"the",
"desired",
"order",
"If",
"it",
"s",
"not",
"specified",
"then",
"the",
"field",
"is",
"added",
"at",
"the",
"end"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L67-L113 |
213,545 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.addKey | public function addKey($key, $after=null) {
// Detect duplicates first
if ($this->getKey($key->getName())) {
throw new coding_exception('Duplicate key '.$key->getName().' specified in table '.$this->getName());
}
// Make sure there are no indexes with the key column specs because they would collide.
$newfields = $key->getFields();
$allindexes = $this->getIndexes();
foreach ($allindexes as $index) {
$fields = $index->getFields();
if ($fields === $newfields) {
throw new coding_exception('Index '.$index->getName().' collides with key'.$key->getName().' specified in table '.$this->getName());
}
}
// Calculate the previous and next keys
$prevkey = null;
$nextkey = null;
if (!$after) {
$allkeys = $this->getKeys();
if (!empty($allkeys)) {
end($allkeys);
$prevkey = $allkeys[key($allkeys)];
}
} else {
$prevkey = $this->getKey($after);
}
if ($prevkey && $prevkey->getNext()) {
$nextkey = $this->getKey($prevkey->getNext());
}
// Set current key previous and next attributes
if ($prevkey) {
$key->setPrevious($prevkey->getName());
$prevkey->setNext($key->getName());
}
if ($nextkey) {
$key->setNext($nextkey->getName());
$nextkey->setPrevious($key->getName());
}
// Some more attributes
$key->setLoaded(true);
$key->setChanged(true);
// Add the new key
$this->keys[] = $key;
// Reorder the keys
$this->orderKeys($this->keys);
// Recalculate the hash
$this->calculateHash(true);
// We have one new field, so the table has changed
$this->setChanged(true);
} | php | public function addKey($key, $after=null) {
// Detect duplicates first
if ($this->getKey($key->getName())) {
throw new coding_exception('Duplicate key '.$key->getName().' specified in table '.$this->getName());
}
// Make sure there are no indexes with the key column specs because they would collide.
$newfields = $key->getFields();
$allindexes = $this->getIndexes();
foreach ($allindexes as $index) {
$fields = $index->getFields();
if ($fields === $newfields) {
throw new coding_exception('Index '.$index->getName().' collides with key'.$key->getName().' specified in table '.$this->getName());
}
}
// Calculate the previous and next keys
$prevkey = null;
$nextkey = null;
if (!$after) {
$allkeys = $this->getKeys();
if (!empty($allkeys)) {
end($allkeys);
$prevkey = $allkeys[key($allkeys)];
}
} else {
$prevkey = $this->getKey($after);
}
if ($prevkey && $prevkey->getNext()) {
$nextkey = $this->getKey($prevkey->getNext());
}
// Set current key previous and next attributes
if ($prevkey) {
$key->setPrevious($prevkey->getName());
$prevkey->setNext($key->getName());
}
if ($nextkey) {
$key->setNext($nextkey->getName());
$nextkey->setPrevious($key->getName());
}
// Some more attributes
$key->setLoaded(true);
$key->setChanged(true);
// Add the new key
$this->keys[] = $key;
// Reorder the keys
$this->orderKeys($this->keys);
// Recalculate the hash
$this->calculateHash(true);
// We have one new field, so the table has changed
$this->setChanged(true);
} | [
"public",
"function",
"addKey",
"(",
"$",
"key",
",",
"$",
"after",
"=",
"null",
")",
"{",
"// Detect duplicates first",
"if",
"(",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
"->",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Duplicate key '",
".",
"$",
"key",
"->",
"getName",
"(",
")",
".",
"' specified in table '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Make sure there are no indexes with the key column specs because they would collide.",
"$",
"newfields",
"=",
"$",
"key",
"->",
"getFields",
"(",
")",
";",
"$",
"allindexes",
"=",
"$",
"this",
"->",
"getIndexes",
"(",
")",
";",
"foreach",
"(",
"$",
"allindexes",
"as",
"$",
"index",
")",
"{",
"$",
"fields",
"=",
"$",
"index",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"$",
"fields",
"===",
"$",
"newfields",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Index '",
".",
"$",
"index",
"->",
"getName",
"(",
")",
".",
"' collides with key'",
".",
"$",
"key",
"->",
"getName",
"(",
")",
".",
"' specified in table '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"// Calculate the previous and next keys",
"$",
"prevkey",
"=",
"null",
";",
"$",
"nextkey",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"after",
")",
"{",
"$",
"allkeys",
"=",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"allkeys",
")",
")",
"{",
"end",
"(",
"$",
"allkeys",
")",
";",
"$",
"prevkey",
"=",
"$",
"allkeys",
"[",
"key",
"(",
"$",
"allkeys",
")",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"prevkey",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"after",
")",
";",
"}",
"if",
"(",
"$",
"prevkey",
"&&",
"$",
"prevkey",
"->",
"getNext",
"(",
")",
")",
"{",
"$",
"nextkey",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"prevkey",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"// Set current key previous and next attributes",
"if",
"(",
"$",
"prevkey",
")",
"{",
"$",
"key",
"->",
"setPrevious",
"(",
"$",
"prevkey",
"->",
"getName",
"(",
")",
")",
";",
"$",
"prevkey",
"->",
"setNext",
"(",
"$",
"key",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextkey",
")",
"{",
"$",
"key",
"->",
"setNext",
"(",
"$",
"nextkey",
"->",
"getName",
"(",
")",
")",
";",
"$",
"nextkey",
"->",
"setPrevious",
"(",
"$",
"key",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Some more attributes",
"$",
"key",
"->",
"setLoaded",
"(",
"true",
")",
";",
"$",
"key",
"->",
"setChanged",
"(",
"true",
")",
";",
"// Add the new key",
"$",
"this",
"->",
"keys",
"[",
"]",
"=",
"$",
"key",
";",
"// Reorder the keys",
"$",
"this",
"->",
"orderKeys",
"(",
"$",
"this",
"->",
"keys",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one new field, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"}"
] | Add one key to the table, allowing to specify the desired order
If it's not specified, then the key is added at the end
@param xmldb_key $key
@param xmldb_object $after | [
"Add",
"one",
"key",
"to",
"the",
"table",
"allowing",
"to",
"specify",
"the",
"desired",
"order",
"If",
"it",
"s",
"not",
"specified",
"then",
"the",
"key",
"is",
"added",
"at",
"the",
"end"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L121-L175 |
213,546 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.addIndex | public function addIndex($index, $after=null) {
// Detect duplicates first
if ($this->getIndex($index->getName())) {
throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
}
// Make sure there are no keys with the index column specs because they would collide.
$newfields = $index->getFields();
$allkeys = $this->getKeys();
foreach ($allkeys as $key) {
$fields = $key->getFields();
if ($fields === $newfields) {
throw new coding_exception('Key '.$key->getName().' collides with index'.$index->getName().' specified in table '.$this->getName());
}
}
// Calculate the previous and next indexes
$previndex = null;
$nextindex = null;
if (!$after) {
$allindexes = $this->getIndexes();
if (!empty($allindexes)) {
end($allindexes);
$previndex = $allindexes[key($allindexes)];
}
} else {
$previndex = $this->getIndex($after);
}
if ($previndex && $previndex->getNext()) {
$nextindex = $this->getIndex($previndex->getNext());
}
// Set current index previous and next attributes
if ($previndex) {
$index->setPrevious($previndex->getName());
$previndex->setNext($index->getName());
}
if ($nextindex) {
$index->setNext($nextindex->getName());
$nextindex->setPrevious($index->getName());
}
// Some more attributes
$index->setLoaded(true);
$index->setChanged(true);
// Add the new index
$this->indexes[] = $index;
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one new index, so the table has changed
$this->setChanged(true);
} | php | public function addIndex($index, $after=null) {
// Detect duplicates first
if ($this->getIndex($index->getName())) {
throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
}
// Make sure there are no keys with the index column specs because they would collide.
$newfields = $index->getFields();
$allkeys = $this->getKeys();
foreach ($allkeys as $key) {
$fields = $key->getFields();
if ($fields === $newfields) {
throw new coding_exception('Key '.$key->getName().' collides with index'.$index->getName().' specified in table '.$this->getName());
}
}
// Calculate the previous and next indexes
$previndex = null;
$nextindex = null;
if (!$after) {
$allindexes = $this->getIndexes();
if (!empty($allindexes)) {
end($allindexes);
$previndex = $allindexes[key($allindexes)];
}
} else {
$previndex = $this->getIndex($after);
}
if ($previndex && $previndex->getNext()) {
$nextindex = $this->getIndex($previndex->getNext());
}
// Set current index previous and next attributes
if ($previndex) {
$index->setPrevious($previndex->getName());
$previndex->setNext($index->getName());
}
if ($nextindex) {
$index->setNext($nextindex->getName());
$nextindex->setPrevious($index->getName());
}
// Some more attributes
$index->setLoaded(true);
$index->setChanged(true);
// Add the new index
$this->indexes[] = $index;
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one new index, so the table has changed
$this->setChanged(true);
} | [
"public",
"function",
"addIndex",
"(",
"$",
"index",
",",
"$",
"after",
"=",
"null",
")",
"{",
"// Detect duplicates first",
"if",
"(",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Duplicate index '",
".",
"$",
"index",
"->",
"getName",
"(",
")",
".",
"' specified in table '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Make sure there are no keys with the index column specs because they would collide.",
"$",
"newfields",
"=",
"$",
"index",
"->",
"getFields",
"(",
")",
";",
"$",
"allkeys",
"=",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"foreach",
"(",
"$",
"allkeys",
"as",
"$",
"key",
")",
"{",
"$",
"fields",
"=",
"$",
"key",
"->",
"getFields",
"(",
")",
";",
"if",
"(",
"$",
"fields",
"===",
"$",
"newfields",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Key '",
".",
"$",
"key",
"->",
"getName",
"(",
")",
".",
"' collides with index'",
".",
"$",
"index",
"->",
"getName",
"(",
")",
".",
"' specified in table '",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"// Calculate the previous and next indexes",
"$",
"previndex",
"=",
"null",
";",
"$",
"nextindex",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"after",
")",
"{",
"$",
"allindexes",
"=",
"$",
"this",
"->",
"getIndexes",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"allindexes",
")",
")",
"{",
"end",
"(",
"$",
"allindexes",
")",
";",
"$",
"previndex",
"=",
"$",
"allindexes",
"[",
"key",
"(",
"$",
"allindexes",
")",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"previndex",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"after",
")",
";",
"}",
"if",
"(",
"$",
"previndex",
"&&",
"$",
"previndex",
"->",
"getNext",
"(",
")",
")",
"{",
"$",
"nextindex",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"previndex",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"// Set current index previous and next attributes",
"if",
"(",
"$",
"previndex",
")",
"{",
"$",
"index",
"->",
"setPrevious",
"(",
"$",
"previndex",
"->",
"getName",
"(",
")",
")",
";",
"$",
"previndex",
"->",
"setNext",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextindex",
")",
"{",
"$",
"index",
"->",
"setNext",
"(",
"$",
"nextindex",
"->",
"getName",
"(",
")",
")",
";",
"$",
"nextindex",
"->",
"setPrevious",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Some more attributes",
"$",
"index",
"->",
"setLoaded",
"(",
"true",
")",
";",
"$",
"index",
"->",
"setChanged",
"(",
"true",
")",
";",
"// Add the new index",
"$",
"this",
"->",
"indexes",
"[",
"]",
"=",
"$",
"index",
";",
"// Reorder the indexes",
"$",
"this",
"->",
"orderIndexes",
"(",
"$",
"this",
"->",
"indexes",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one new index, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"}"
] | Add one index to the table, allowing to specify the desired order
If it's not specified, then the index is added at the end
@param xmldb_index $index
@param xmldb_object $after | [
"Add",
"one",
"index",
"to",
"the",
"table",
"allowing",
"to",
"specify",
"the",
"desired",
"order",
"If",
"it",
"s",
"not",
"specified",
"then",
"the",
"index",
"is",
"added",
"at",
"the",
"end"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L183-L238 |
213,547 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.getField | public function getField($fieldname) {
$i = $this->findFieldInArray($fieldname);
if ($i !== null) {
return $this->fields[$i];
}
return null;
} | php | public function getField($fieldname) {
$i = $this->findFieldInArray($fieldname);
if ($i !== null) {
return $this->fields[$i];
}
return null;
} | [
"public",
"function",
"getField",
"(",
"$",
"fieldname",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findFieldInArray",
"(",
"$",
"fieldname",
")",
";",
"if",
"(",
"$",
"i",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"fields",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns one xmldb_field
@param string $fieldname
@return xmldb_field|null | [
"Returns",
"one",
"xmldb_field"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L269-L275 |
213,548 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.findFieldInArray | public function findFieldInArray($fieldname) {
foreach ($this->fields as $i => $field) {
if ($fieldname == $field->getName()) {
return $i;
}
}
return null;
} | php | public function findFieldInArray($fieldname) {
foreach ($this->fields as $i => $field) {
if ($fieldname == $field->getName()) {
return $i;
}
}
return null;
} | [
"public",
"function",
"findFieldInArray",
"(",
"$",
"fieldname",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"i",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"fieldname",
"==",
"$",
"field",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the position of one field in the array.
@param string $fieldname
@return int|null index of the field, or null if not found. | [
"Returns",
"the",
"position",
"of",
"one",
"field",
"in",
"the",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L282-L289 |
213,549 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.orderFields | public function orderFields() {
$result = $this->orderElements($this->fields);
if ($result) {
$this->setFields($result);
return true;
} else {
return false;
}
} | php | public function orderFields() {
$result = $this->orderElements($this->fields);
if ($result) {
$this->setFields($result);
return true;
} else {
return false;
}
} | [
"public",
"function",
"orderFields",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"orderElements",
"(",
"$",
"this",
"->",
"fields",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"setFields",
"(",
"$",
"result",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | This function will reorder the array of fields
@return bool whether the reordering succeeded. | [
"This",
"function",
"will",
"reorder",
"the",
"array",
"of",
"fields"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L295-L303 |
213,550 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.getKey | public function getKey($keyname) {
$i = $this->findKeyInArray($keyname);
if ($i !== null) {
return $this->keys[$i];
}
return null;
} | php | public function getKey($keyname) {
$i = $this->findKeyInArray($keyname);
if ($i !== null) {
return $this->keys[$i];
}
return null;
} | [
"public",
"function",
"getKey",
"(",
"$",
"keyname",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findKeyInArray",
"(",
"$",
"keyname",
")",
";",
"if",
"(",
"$",
"i",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"keys",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns one xmldb_key
@param string $keyname
@return xmldb_key|null | [
"Returns",
"one",
"xmldb_key"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L310-L316 |
213,551 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.findKeyInArray | public function findKeyInArray($keyname) {
foreach ($this->keys as $i => $key) {
if ($keyname == $key->getName()) {
return $i;
}
}
return null;
} | php | public function findKeyInArray($keyname) {
foreach ($this->keys as $i => $key) {
if ($keyname == $key->getName()) {
return $i;
}
}
return null;
} | [
"public",
"function",
"findKeyInArray",
"(",
"$",
"keyname",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"as",
"$",
"i",
"=>",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"keyname",
"==",
"$",
"key",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the position of one key in the array.
@param string $keyname
@return int|null index of the key, or null if not found. | [
"Returns",
"the",
"position",
"of",
"one",
"key",
"in",
"the",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L323-L330 |
213,552 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.orderKeys | public function orderKeys() {
$result = $this->orderElements($this->keys);
if ($result) {
$this->setKeys($result);
return true;
} else {
return false;
}
} | php | public function orderKeys() {
$result = $this->orderElements($this->keys);
if ($result) {
$this->setKeys($result);
return true;
} else {
return false;
}
} | [
"public",
"function",
"orderKeys",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"orderElements",
"(",
"$",
"this",
"->",
"keys",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"setKeys",
"(",
"$",
"result",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | This function will reorder the array of keys
@return bool whether the reordering succeeded. | [
"This",
"function",
"will",
"reorder",
"the",
"array",
"of",
"keys"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L336-L344 |
213,553 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.getIndex | public function getIndex($indexname) {
$i = $this->findIndexInArray($indexname);
if ($i !== null) {
return $this->indexes[$i];
}
return null;
} | php | public function getIndex($indexname) {
$i = $this->findIndexInArray($indexname);
if ($i !== null) {
return $this->indexes[$i];
}
return null;
} | [
"public",
"function",
"getIndex",
"(",
"$",
"indexname",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findIndexInArray",
"(",
"$",
"indexname",
")",
";",
"if",
"(",
"$",
"i",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"indexes",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns one xmldb_index
@param string $indexname
@return xmldb_index|null | [
"Returns",
"one",
"xmldb_index"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L351-L357 |
213,554 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.findIndexInArray | public function findIndexInArray($indexname) {
foreach ($this->indexes as $i => $index) {
if ($indexname == $index->getName()) {
return $i;
}
}
return null;
} | php | public function findIndexInArray($indexname) {
foreach ($this->indexes as $i => $index) {
if ($indexname == $index->getName()) {
return $i;
}
}
return null;
} | [
"public",
"function",
"findIndexInArray",
"(",
"$",
"indexname",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"as",
"$",
"i",
"=>",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"indexname",
"==",
"$",
"index",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the position of one index in the array.
@param string $indexname
@return int|null index of the index, or null if not found. | [
"Returns",
"the",
"position",
"of",
"one",
"index",
"in",
"the",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L364-L371 |
213,555 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.orderIndexes | public function orderIndexes() {
$result = $this->orderElements($this->indexes);
if ($result) {
$this->setIndexes($result);
return true;
} else {
return false;
}
} | php | public function orderIndexes() {
$result = $this->orderElements($this->indexes);
if ($result) {
$this->setIndexes($result);
return true;
} else {
return false;
}
} | [
"public",
"function",
"orderIndexes",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"orderElements",
"(",
"$",
"this",
"->",
"indexes",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"setIndexes",
"(",
"$",
"result",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | This function will reorder the array of indexes
@return bool whether the reordering succeeded. | [
"This",
"function",
"will",
"reorder",
"the",
"array",
"of",
"indexes"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L377-L385 |
213,556 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.deleteField | public function deleteField($fieldname) {
$field = $this->getField($fieldname);
if ($field) {
$i = $this->findFieldInArray($fieldname);
// Look for prev and next field
$prevfield = $this->getField($field->getPrevious());
$nextfield = $this->getField($field->getNext());
// Change their previous and next attributes
if ($prevfield) {
$prevfield->setNext($field->getNext());
}
if ($nextfield) {
$nextfield->setPrevious($field->getPrevious());
}
// Delete the field
unset($this->fields[$i]);
// Reorder the whole structure
$this->orderFields($this->fields);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted field, so the table has changed
$this->setChanged(true);
}
} | php | public function deleteField($fieldname) {
$field = $this->getField($fieldname);
if ($field) {
$i = $this->findFieldInArray($fieldname);
// Look for prev and next field
$prevfield = $this->getField($field->getPrevious());
$nextfield = $this->getField($field->getNext());
// Change their previous and next attributes
if ($prevfield) {
$prevfield->setNext($field->getNext());
}
if ($nextfield) {
$nextfield->setPrevious($field->getPrevious());
}
// Delete the field
unset($this->fields[$i]);
// Reorder the whole structure
$this->orderFields($this->fields);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted field, so the table has changed
$this->setChanged(true);
}
} | [
"public",
"function",
"deleteField",
"(",
"$",
"fieldname",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"fieldname",
")",
";",
"if",
"(",
"$",
"field",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findFieldInArray",
"(",
"$",
"fieldname",
")",
";",
"// Look for prev and next field",
"$",
"prevfield",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"field",
"->",
"getPrevious",
"(",
")",
")",
";",
"$",
"nextfield",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"field",
"->",
"getNext",
"(",
")",
")",
";",
"// Change their previous and next attributes",
"if",
"(",
"$",
"prevfield",
")",
"{",
"$",
"prevfield",
"->",
"setNext",
"(",
"$",
"field",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextfield",
")",
"{",
"$",
"nextfield",
"->",
"setPrevious",
"(",
"$",
"field",
"->",
"getPrevious",
"(",
")",
")",
";",
"}",
"// Delete the field",
"unset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"i",
"]",
")",
";",
"// Reorder the whole structure",
"$",
"this",
"->",
"orderFields",
"(",
"$",
"this",
"->",
"fields",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one deleted field, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"}",
"}"
] | Delete one field from the table
@param string $fieldname | [
"Delete",
"one",
"field",
"from",
"the",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L415-L439 |
213,557 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.deleteKey | public function deleteKey($keyname) {
$key = $this->getKey($keyname);
if ($key) {
$i = $this->findKeyInArray($keyname);
// Look for prev and next key
$prevkey = $this->getKey($key->getPrevious());
$nextkey = $this->getKey($key->getNext());
// Change their previous and next attributes
if ($prevkey) {
$prevkey->setNext($key->getNext());
}
if ($nextkey) {
$nextkey->setPrevious($key->getPrevious());
}
// Delete the key
unset($this->keys[$i]);
// Reorder the Keys
$this->orderKeys($this->keys);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted key, so the table has changed
$this->setChanged(true);
}
} | php | public function deleteKey($keyname) {
$key = $this->getKey($keyname);
if ($key) {
$i = $this->findKeyInArray($keyname);
// Look for prev and next key
$prevkey = $this->getKey($key->getPrevious());
$nextkey = $this->getKey($key->getNext());
// Change their previous and next attributes
if ($prevkey) {
$prevkey->setNext($key->getNext());
}
if ($nextkey) {
$nextkey->setPrevious($key->getPrevious());
}
// Delete the key
unset($this->keys[$i]);
// Reorder the Keys
$this->orderKeys($this->keys);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted key, so the table has changed
$this->setChanged(true);
}
} | [
"public",
"function",
"deleteKey",
"(",
"$",
"keyname",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"keyname",
")",
";",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findKeyInArray",
"(",
"$",
"keyname",
")",
";",
"// Look for prev and next key",
"$",
"prevkey",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
"->",
"getPrevious",
"(",
")",
")",
";",
"$",
"nextkey",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
"->",
"getNext",
"(",
")",
")",
";",
"// Change their previous and next attributes",
"if",
"(",
"$",
"prevkey",
")",
"{",
"$",
"prevkey",
"->",
"setNext",
"(",
"$",
"key",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextkey",
")",
"{",
"$",
"nextkey",
"->",
"setPrevious",
"(",
"$",
"key",
"->",
"getPrevious",
"(",
")",
")",
";",
"}",
"// Delete the key",
"unset",
"(",
"$",
"this",
"->",
"keys",
"[",
"$",
"i",
"]",
")",
";",
"// Reorder the Keys",
"$",
"this",
"->",
"orderKeys",
"(",
"$",
"this",
"->",
"keys",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one deleted key, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"}",
"}"
] | Delete one key from the table
@param string $keyname | [
"Delete",
"one",
"key",
"from",
"the",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L445-L469 |
213,558 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.deleteIndex | public function deleteIndex($indexname) {
$index = $this->getIndex($indexname);
if ($index) {
$i = $this->findIndexInArray($indexname);
// Look for prev and next index
$previndex = $this->getIndex($index->getPrevious());
$nextindex = $this->getIndex($index->getNext());
// Change their previous and next attributes
if ($previndex) {
$previndex->setNext($index->getNext());
}
if ($nextindex) {
$nextindex->setPrevious($index->getPrevious());
}
// Delete the index
unset($this->indexes[$i]);
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted index, so the table has changed
$this->setChanged(true);
}
} | php | public function deleteIndex($indexname) {
$index = $this->getIndex($indexname);
if ($index) {
$i = $this->findIndexInArray($indexname);
// Look for prev and next index
$previndex = $this->getIndex($index->getPrevious());
$nextindex = $this->getIndex($index->getNext());
// Change their previous and next attributes
if ($previndex) {
$previndex->setNext($index->getNext());
}
if ($nextindex) {
$nextindex->setPrevious($index->getPrevious());
}
// Delete the index
unset($this->indexes[$i]);
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one deleted index, so the table has changed
$this->setChanged(true);
}
} | [
"public",
"function",
"deleteIndex",
"(",
"$",
"indexname",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"indexname",
")",
";",
"if",
"(",
"$",
"index",
")",
"{",
"$",
"i",
"=",
"$",
"this",
"->",
"findIndexInArray",
"(",
"$",
"indexname",
")",
";",
"// Look for prev and next index",
"$",
"previndex",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"index",
"->",
"getPrevious",
"(",
")",
")",
";",
"$",
"nextindex",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"index",
"->",
"getNext",
"(",
")",
")",
";",
"// Change their previous and next attributes",
"if",
"(",
"$",
"previndex",
")",
"{",
"$",
"previndex",
"->",
"setNext",
"(",
"$",
"index",
"->",
"getNext",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"nextindex",
")",
"{",
"$",
"nextindex",
"->",
"setPrevious",
"(",
"$",
"index",
"->",
"getPrevious",
"(",
")",
")",
";",
"}",
"// Delete the index",
"unset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"i",
"]",
")",
";",
"// Reorder the indexes",
"$",
"this",
"->",
"orderIndexes",
"(",
"$",
"this",
"->",
"indexes",
")",
";",
"// Recalculate the hash",
"$",
"this",
"->",
"calculateHash",
"(",
"true",
")",
";",
"// We have one deleted index, so the table has changed",
"$",
"this",
"->",
"setChanged",
"(",
"true",
")",
";",
"}",
"}"
] | Delete one index from the table
@param string $indexname | [
"Delete",
"one",
"index",
"from",
"the",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L475-L499 |
213,559 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.calculateHash | public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = null;
} else {
$key = $this->name . $this->comment;
if ($this->fields) {
foreach ($this->fields as $fie) {
$field = $this->getField($fie->getName());
if ($recursive) {
$field->calculateHash($recursive);
}
$key .= $field->getHash();
}
}
if ($this->keys) {
foreach ($this->keys as $ke) {
$k = $this->getKey($ke->getName());
if ($recursive) {
$k->calculateHash($recursive);
}
$key .= $k->getHash();
}
}
if ($this->indexes) {
foreach ($this->indexes as $in) {
$index = $this->getIndex($in->getName());
if ($recursive) {
$index->calculateHash($recursive);
}
$key .= $index->getHash();
}
}
$this->hash = md5($key);
}
} | php | public function calculateHash($recursive = false) {
if (!$this->loaded) {
$this->hash = null;
} else {
$key = $this->name . $this->comment;
if ($this->fields) {
foreach ($this->fields as $fie) {
$field = $this->getField($fie->getName());
if ($recursive) {
$field->calculateHash($recursive);
}
$key .= $field->getHash();
}
}
if ($this->keys) {
foreach ($this->keys as $ke) {
$k = $this->getKey($ke->getName());
if ($recursive) {
$k->calculateHash($recursive);
}
$key .= $k->getHash();
}
}
if ($this->indexes) {
foreach ($this->indexes as $in) {
$index = $this->getIndex($in->getName());
if ($recursive) {
$index->calculateHash($recursive);
}
$key .= $index->getHash();
}
}
$this->hash = md5($key);
}
} | [
"public",
"function",
"calculateHash",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loaded",
")",
"{",
"$",
"this",
"->",
"hash",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"name",
".",
"$",
"this",
"->",
"comment",
";",
"if",
"(",
"$",
"this",
"->",
"fields",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"fie",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"getField",
"(",
"$",
"fie",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"$",
"field",
"->",
"calculateHash",
"(",
"$",
"recursive",
")",
";",
"}",
"$",
"key",
".=",
"$",
"field",
"->",
"getHash",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"keys",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"as",
"$",
"ke",
")",
"{",
"$",
"k",
"=",
"$",
"this",
"->",
"getKey",
"(",
"$",
"ke",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"$",
"k",
"->",
"calculateHash",
"(",
"$",
"recursive",
")",
";",
"}",
"$",
"key",
".=",
"$",
"k",
"->",
"getHash",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"indexes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"as",
"$",
"in",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"in",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"$",
"index",
"->",
"calculateHash",
"(",
"$",
"recursive",
")",
";",
"}",
"$",
"key",
".=",
"$",
"index",
"->",
"getHash",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"hash",
"=",
"md5",
"(",
"$",
"key",
")",
";",
"}",
"}"
] | This function calculate and set the hash of one xmldb_table
@param bool $recursive | [
"This",
"function",
"calculate",
"and",
"set",
"the",
"hash",
"of",
"one",
"xmldb_table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L668-L702 |
213,560 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.xmlOutput | public function xmlOutput() {
$o = '';
$o.= ' <TABLE NAME="' . $this->name . '"';
if ($this->comment) {
$o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
}
$o.= '>' . "\n";
// Now the fields
if ($this->fields) {
$o.= ' <FIELDS>' . "\n";
foreach ($this->fields as $field) {
$o.= $field->xmlOutput();
}
$o.= ' </FIELDS>' . "\n";
}
// Now the keys
if ($this->keys) {
$o.= ' <KEYS>' . "\n";
foreach ($this->keys as $key) {
$o.= $key->xmlOutput();
}
$o.= ' </KEYS>' . "\n";
}
// Now the indexes
if ($this->indexes) {
$o.= ' <INDEXES>' . "\n";
foreach ($this->indexes as $index) {
$o.= $index->xmlOutput();
}
$o.= ' </INDEXES>' . "\n";
}
$o.= ' </TABLE>' . "\n";
return $o;
} | php | public function xmlOutput() {
$o = '';
$o.= ' <TABLE NAME="' . $this->name . '"';
if ($this->comment) {
$o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
}
$o.= '>' . "\n";
// Now the fields
if ($this->fields) {
$o.= ' <FIELDS>' . "\n";
foreach ($this->fields as $field) {
$o.= $field->xmlOutput();
}
$o.= ' </FIELDS>' . "\n";
}
// Now the keys
if ($this->keys) {
$o.= ' <KEYS>' . "\n";
foreach ($this->keys as $key) {
$o.= $key->xmlOutput();
}
$o.= ' </KEYS>' . "\n";
}
// Now the indexes
if ($this->indexes) {
$o.= ' <INDEXES>' . "\n";
foreach ($this->indexes as $index) {
$o.= $index->xmlOutput();
}
$o.= ' </INDEXES>' . "\n";
}
$o.= ' </TABLE>' . "\n";
return $o;
} | [
"public",
"function",
"xmlOutput",
"(",
")",
"{",
"$",
"o",
"=",
"''",
";",
"$",
"o",
".=",
"' <TABLE NAME=\"'",
".",
"$",
"this",
"->",
"name",
".",
"'\"'",
";",
"if",
"(",
"$",
"this",
"->",
"comment",
")",
"{",
"$",
"o",
".=",
"' COMMENT=\"'",
".",
"htmlspecialchars",
"(",
"$",
"this",
"->",
"comment",
")",
".",
"'\"'",
";",
"}",
"$",
"o",
".=",
"'>'",
".",
"\"\\n\"",
";",
"// Now the fields",
"if",
"(",
"$",
"this",
"->",
"fields",
")",
"{",
"$",
"o",
".=",
"' <FIELDS>'",
".",
"\"\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"o",
".=",
"$",
"field",
"->",
"xmlOutput",
"(",
")",
";",
"}",
"$",
"o",
".=",
"' </FIELDS>'",
".",
"\"\\n\"",
";",
"}",
"// Now the keys",
"if",
"(",
"$",
"this",
"->",
"keys",
")",
"{",
"$",
"o",
".=",
"' <KEYS>'",
".",
"\"\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"o",
".=",
"$",
"key",
"->",
"xmlOutput",
"(",
")",
";",
"}",
"$",
"o",
".=",
"' </KEYS>'",
".",
"\"\\n\"",
";",
"}",
"// Now the indexes",
"if",
"(",
"$",
"this",
"->",
"indexes",
")",
"{",
"$",
"o",
".=",
"' <INDEXES>'",
".",
"\"\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"as",
"$",
"index",
")",
"{",
"$",
"o",
".=",
"$",
"index",
"->",
"xmlOutput",
"(",
")",
";",
"}",
"$",
"o",
".=",
"' </INDEXES>'",
".",
"\"\\n\"",
";",
"}",
"$",
"o",
".=",
"' </TABLE>'",
".",
"\"\\n\"",
";",
"return",
"$",
"o",
";",
"}"
] | This function will output the XML text for one table
@return string | [
"This",
"function",
"will",
"output",
"the",
"XML",
"text",
"for",
"one",
"table"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L730-L764 |
213,561 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.add_field | public function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $default);
$this->addField($field, $previous);
return $field;
} | php | public function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
$field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $default);
$this->addField($field, $previous);
return $field;
} | [
"public",
"function",
"add_field",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"precision",
"=",
"null",
",",
"$",
"unsigned",
"=",
"null",
",",
"$",
"notnull",
"=",
"null",
",",
"$",
"sequence",
"=",
"null",
",",
"$",
"default",
"=",
"null",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"field",
"=",
"new",
"xmldb_field",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"precision",
",",
"$",
"unsigned",
",",
"$",
"notnull",
",",
"$",
"sequence",
",",
"$",
"default",
")",
";",
"$",
"this",
"->",
"addField",
"(",
"$",
"field",
",",
"$",
"previous",
")",
";",
"return",
"$",
"field",
";",
"}"
] | This function will add one new field to the table with all
its attributes defined
@param string $name name of the field
@param int $type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
@param string $precision length for integers and chars, two-comma separated numbers for numbers
@param bool $unsigned XMLDB_UNSIGNED or null (or false)
@param bool $notnull XMLDB_NOTNULL or null (or false)
@param bool $sequence XMLDB_SEQUENCE or null (or false)
@param mixed $default meaningful default o null (or false)
@param xmldb_object $previous name of the previous field in the table or null (or false)
@return xmlddb_field | [
"This",
"function",
"will",
"add",
"one",
"new",
"field",
"to",
"the",
"table",
"with",
"all",
"its",
"attributes",
"defined"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L780-L785 |
213,562 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.add_key | public function add_key($name, $type, $fields, $reftable=null, $reffields=null) {
$key = new xmldb_key($name, $type, $fields, $reftable, $reffields);
$this->addKey($key);
} | php | public function add_key($name, $type, $fields, $reftable=null, $reffields=null) {
$key = new xmldb_key($name, $type, $fields, $reftable, $reffields);
$this->addKey($key);
} | [
"public",
"function",
"add_key",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"fields",
",",
"$",
"reftable",
"=",
"null",
",",
"$",
"reffields",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"new",
"xmldb_key",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"fields",
",",
"$",
"reftable",
",",
"$",
"reffields",
")",
";",
"$",
"this",
"->",
"addKey",
"(",
"$",
"key",
")",
";",
"}"
] | This function will add one new key to the table with all
its attributes defined
@param string $name name of the key
@param int $type XMLDB_KEY_PRIMARY, XMLDB_KEY_UNIQUE, XMLDB_KEY_FOREIGN
@param array $fields an array of fieldnames to build the key over
@param string $reftable name of the table the FK points to or null
@param array $reffields an array of fieldnames in the FK table or null | [
"This",
"function",
"will",
"add",
"one",
"new",
"key",
"to",
"the",
"table",
"with",
"all",
"its",
"attributes",
"defined"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L797-L800 |
213,563 | moodle/moodle | lib/xmldb/xmldb_table.php | xmldb_table.add_index | public function add_index($name, $type, $fields, $hints = array()) {
$index = new xmldb_index($name, $type, $fields, $hints);
$this->addIndex($index);
} | php | public function add_index($name, $type, $fields, $hints = array()) {
$index = new xmldb_index($name, $type, $fields, $hints);
$this->addIndex($index);
} | [
"public",
"function",
"add_index",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"fields",
",",
"$",
"hints",
"=",
"array",
"(",
")",
")",
"{",
"$",
"index",
"=",
"new",
"xmldb_index",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"fields",
",",
"$",
"hints",
")",
";",
"$",
"this",
"->",
"addIndex",
"(",
"$",
"index",
")",
";",
"}"
] | This function will add one new index to the table with all
its attributes defined
@param string $name name of the index
@param int $type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
@param array $fields an array of fieldnames to build the index over
@param array $hints optional index type hints | [
"This",
"function",
"will",
"add",
"one",
"new",
"index",
"to",
"the",
"table",
"with",
"all",
"its",
"attributes",
"defined"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_table.php#L811-L814 |
213,564 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_common | public function process_common($quest) {
$question = $this->defaultquestion();
$text = $quest->QUESTION_BLOCK->text;
$questiontext = $this->cleaned_text_field($text);
$question->questiontext = $questiontext['text'];
$question->questiontextformat = $questiontext['format']; // Needed because add_blank_combined_feedback uses it.
if (isset($questiontext['itemid'])) {
$question->questiontextitemid = $questiontext['itemid'];
}
$question->name = $this->create_default_question_name($question->questiontext,
get_string('defaultname', 'qformat_blackboard_six' , $quest->id));
$question->generalfeedback = '';
$question->generalfeedbackformat = FORMAT_HTML;
$question->generalfeedbackfiles = array();
return $question;
} | php | public function process_common($quest) {
$question = $this->defaultquestion();
$text = $quest->QUESTION_BLOCK->text;
$questiontext = $this->cleaned_text_field($text);
$question->questiontext = $questiontext['text'];
$question->questiontextformat = $questiontext['format']; // Needed because add_blank_combined_feedback uses it.
if (isset($questiontext['itemid'])) {
$question->questiontextitemid = $questiontext['itemid'];
}
$question->name = $this->create_default_question_name($question->questiontext,
get_string('defaultname', 'qformat_blackboard_six' , $quest->id));
$question->generalfeedback = '';
$question->generalfeedbackformat = FORMAT_HTML;
$question->generalfeedbackfiles = array();
return $question;
} | [
"public",
"function",
"process_common",
"(",
"$",
"quest",
")",
"{",
"$",
"question",
"=",
"$",
"this",
"->",
"defaultquestion",
"(",
")",
";",
"$",
"text",
"=",
"$",
"quest",
"->",
"QUESTION_BLOCK",
"->",
"text",
";",
"$",
"questiontext",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"text",
")",
";",
"$",
"question",
"->",
"questiontext",
"=",
"$",
"questiontext",
"[",
"'text'",
"]",
";",
"$",
"question",
"->",
"questiontextformat",
"=",
"$",
"questiontext",
"[",
"'format'",
"]",
";",
"// Needed because add_blank_combined_feedback uses it.",
"if",
"(",
"isset",
"(",
"$",
"questiontext",
"[",
"'itemid'",
"]",
")",
")",
"{",
"$",
"question",
"->",
"questiontextitemid",
"=",
"$",
"questiontext",
"[",
"'itemid'",
"]",
";",
"}",
"$",
"question",
"->",
"name",
"=",
"$",
"this",
"->",
"create_default_question_name",
"(",
"$",
"question",
"->",
"questiontext",
",",
"get_string",
"(",
"'defaultname'",
",",
"'qformat_blackboard_six'",
",",
"$",
"quest",
"->",
"id",
")",
")",
";",
"$",
"question",
"->",
"generalfeedback",
"=",
"''",
";",
"$",
"question",
"->",
"generalfeedbackformat",
"=",
"FORMAT_HTML",
";",
"$",
"question",
"->",
"generalfeedbackfiles",
"=",
"array",
"(",
")",
";",
"return",
"$",
"question",
";",
"}"
] | Create common parts of question
@param object $quest rawquestion
@return object Moodle question. | [
"Create",
"common",
"parts",
"of",
"question"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L509-L525 |
213,565 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_fblank | protected function process_fblank($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'shortanswer';
$question->usecase = 0; // Ignore case.
$answers = array();
$fractions = array();
$feedbacks = array();
// Extract the feedback.
$feedback = array();
foreach ($quest->feedback as $fback) {
if (isset($fback->ident)) {
if ($fback->ident == 'correct' || $fback->ident == 'incorrect') {
$feedback[$fback->ident] = $fback->text;
}
}
}
foreach ($quest->responses as $response) {
if (isset($response->title)) {
if ($this->getpath($response->ident[0],
array('varequal', 0, '#'), false, false)) {
// For BB Fill in the Blank, only interested in correct answers.
if ($response->feedback = 'correct') {
$answers[] = $this->getpath($response->ident[0],
array('varequal', 0, '#'), '', true);
$fractions[] = 1;
if (isset($feedback['correct'])) {
$feedbacks[] = $this->cleaned_text_field($feedback['correct']);
} else {
$feedbacks[] = $this->text_field('');
}
}
}
}
}
// Adding catchall to so that students can see feedback for incorrect answers when they enter something,
// the instructor did not enter.
$answers[] = '*';
$fractions[] = 0;
if (isset($feedback['incorrect'])) {
$feedbacks[] = $this->cleaned_text_field($feedback['incorrect']);
} else {
$feedbacks[] = $this->text_field('');
}
$question->answer = $answers;
$question->fraction = $fractions;
$question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of.
if (!empty($question)) {
$questions[] = $question;
}
} | php | protected function process_fblank($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'shortanswer';
$question->usecase = 0; // Ignore case.
$answers = array();
$fractions = array();
$feedbacks = array();
// Extract the feedback.
$feedback = array();
foreach ($quest->feedback as $fback) {
if (isset($fback->ident)) {
if ($fback->ident == 'correct' || $fback->ident == 'incorrect') {
$feedback[$fback->ident] = $fback->text;
}
}
}
foreach ($quest->responses as $response) {
if (isset($response->title)) {
if ($this->getpath($response->ident[0],
array('varequal', 0, '#'), false, false)) {
// For BB Fill in the Blank, only interested in correct answers.
if ($response->feedback = 'correct') {
$answers[] = $this->getpath($response->ident[0],
array('varequal', 0, '#'), '', true);
$fractions[] = 1;
if (isset($feedback['correct'])) {
$feedbacks[] = $this->cleaned_text_field($feedback['correct']);
} else {
$feedbacks[] = $this->text_field('');
}
}
}
}
}
// Adding catchall to so that students can see feedback for incorrect answers when they enter something,
// the instructor did not enter.
$answers[] = '*';
$fractions[] = 0;
if (isset($feedback['incorrect'])) {
$feedbacks[] = $this->cleaned_text_field($feedback['incorrect']);
} else {
$feedbacks[] = $this->text_field('');
}
$question->answer = $answers;
$question->fraction = $fractions;
$question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of.
if (!empty($question)) {
$questions[] = $question;
}
} | [
"protected",
"function",
"process_fblank",
"(",
"$",
"quest",
",",
"&",
"$",
"questions",
")",
"{",
"$",
"question",
"=",
"$",
"this",
"->",
"process_common",
"(",
"$",
"quest",
")",
";",
"$",
"question",
"->",
"qtype",
"=",
"'shortanswer'",
";",
"$",
"question",
"->",
"usecase",
"=",
"0",
";",
"// Ignore case.",
"$",
"answers",
"=",
"array",
"(",
")",
";",
"$",
"fractions",
"=",
"array",
"(",
")",
";",
"$",
"feedbacks",
"=",
"array",
"(",
")",
";",
"// Extract the feedback.",
"$",
"feedback",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"quest",
"->",
"feedback",
"as",
"$",
"fback",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"fback",
"->",
"ident",
")",
")",
"{",
"if",
"(",
"$",
"fback",
"->",
"ident",
"==",
"'correct'",
"||",
"$",
"fback",
"->",
"ident",
"==",
"'incorrect'",
")",
"{",
"$",
"feedback",
"[",
"$",
"fback",
"->",
"ident",
"]",
"=",
"$",
"fback",
"->",
"text",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"quest",
"->",
"responses",
"as",
"$",
"response",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"title",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getpath",
"(",
"$",
"response",
"->",
"ident",
"[",
"0",
"]",
",",
"array",
"(",
"'varequal'",
",",
"0",
",",
"'#'",
")",
",",
"false",
",",
"false",
")",
")",
"{",
"// For BB Fill in the Blank, only interested in correct answers.",
"if",
"(",
"$",
"response",
"->",
"feedback",
"=",
"'correct'",
")",
"{",
"$",
"answers",
"[",
"]",
"=",
"$",
"this",
"->",
"getpath",
"(",
"$",
"response",
"->",
"ident",
"[",
"0",
"]",
",",
"array",
"(",
"'varequal'",
",",
"0",
",",
"'#'",
")",
",",
"''",
",",
"true",
")",
";",
"$",
"fractions",
"[",
"]",
"=",
"1",
";",
"if",
"(",
"isset",
"(",
"$",
"feedback",
"[",
"'correct'",
"]",
")",
")",
"{",
"$",
"feedbacks",
"[",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"feedback",
"[",
"'correct'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"feedbacks",
"[",
"]",
"=",
"$",
"this",
"->",
"text_field",
"(",
"''",
")",
";",
"}",
"}",
"}",
"}",
"}",
"// Adding catchall to so that students can see feedback for incorrect answers when they enter something,",
"// the instructor did not enter.",
"$",
"answers",
"[",
"]",
"=",
"'*'",
";",
"$",
"fractions",
"[",
"]",
"=",
"0",
";",
"if",
"(",
"isset",
"(",
"$",
"feedback",
"[",
"'incorrect'",
"]",
")",
")",
"{",
"$",
"feedbacks",
"[",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"feedback",
"[",
"'incorrect'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"feedbacks",
"[",
"]",
"=",
"$",
"this",
"->",
"text_field",
"(",
"''",
")",
";",
"}",
"$",
"question",
"->",
"answer",
"=",
"$",
"answers",
";",
"$",
"question",
"->",
"fraction",
"=",
"$",
"fractions",
";",
"$",
"question",
"->",
"feedback",
"=",
"$",
"feedbacks",
";",
"// Changed to assign $feedbacks to $question->feedback instead of.",
"if",
"(",
"!",
"empty",
"(",
"$",
"question",
")",
")",
"{",
"$",
"questions",
"[",
"]",
"=",
"$",
"question",
";",
"}",
"}"
] | Process Fill in the Blank Questions
Parse a fillintheblank rawquestion and add the result
to the array of questions already parsed.
@param object $quest rawquestion
@param array $questions array of Moodle questions already done. | [
"Process",
"Fill",
"in",
"the",
"Blank",
"Questions",
"Parse",
"a",
"fillintheblank",
"rawquestion",
"and",
"add",
"the",
"result",
"to",
"the",
"array",
"of",
"questions",
"already",
"parsed",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L575-L632 |
213,566 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_ma | public function process_ma($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'multichoice';
$question = $this->add_blank_combined_feedback($question);
$question->single = 0; // More than one answer allowed.
$answers = $quest->responses;
$correctanswers = array();
foreach ($answers as $answer) {
if ($answer->title == 'correct') {
$answerset = $this->getpath($answer->ident[0],
array('and', 0, '#', 'varequal'), array(), false);
foreach ($answerset as $ans) {
$correctanswers[] = $ans['#'];
}
}
}
$feedback = new stdClass();
foreach ($quest->feedback as $fb) {
$feedback->{$fb->ident} = trim($fb->text);
}
$correctanswercount = count($correctanswers);
$fraction = 1 / $correctanswercount;
$choiceset = $quest->RESPONSE_BLOCK->choices;
$i = 0;
foreach ($choiceset as $choice) {
$question->answer[$i] = $this->cleaned_text_field(trim($choice->text));
if (in_array($choice->ident, $correctanswers)) {
// Correct answer.
$question->fraction[$i] = $fraction;
$question->feedback[$i] = $this->cleaned_text_field($feedback->correct);
} else {
// Wrong answer.
$question->fraction[$i] = 0;
$question->feedback[$i] = $this->cleaned_text_field($feedback->incorrect);
}
$i++;
}
$questions[] = $question;
} | php | public function process_ma($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'multichoice';
$question = $this->add_blank_combined_feedback($question);
$question->single = 0; // More than one answer allowed.
$answers = $quest->responses;
$correctanswers = array();
foreach ($answers as $answer) {
if ($answer->title == 'correct') {
$answerset = $this->getpath($answer->ident[0],
array('and', 0, '#', 'varequal'), array(), false);
foreach ($answerset as $ans) {
$correctanswers[] = $ans['#'];
}
}
}
$feedback = new stdClass();
foreach ($quest->feedback as $fb) {
$feedback->{$fb->ident} = trim($fb->text);
}
$correctanswercount = count($correctanswers);
$fraction = 1 / $correctanswercount;
$choiceset = $quest->RESPONSE_BLOCK->choices;
$i = 0;
foreach ($choiceset as $choice) {
$question->answer[$i] = $this->cleaned_text_field(trim($choice->text));
if (in_array($choice->ident, $correctanswers)) {
// Correct answer.
$question->fraction[$i] = $fraction;
$question->feedback[$i] = $this->cleaned_text_field($feedback->correct);
} else {
// Wrong answer.
$question->fraction[$i] = 0;
$question->feedback[$i] = $this->cleaned_text_field($feedback->incorrect);
}
$i++;
}
$questions[] = $question;
} | [
"public",
"function",
"process_ma",
"(",
"$",
"quest",
",",
"&",
"$",
"questions",
")",
"{",
"$",
"question",
"=",
"$",
"this",
"->",
"process_common",
"(",
"$",
"quest",
")",
";",
"$",
"question",
"->",
"qtype",
"=",
"'multichoice'",
";",
"$",
"question",
"=",
"$",
"this",
"->",
"add_blank_combined_feedback",
"(",
"$",
"question",
")",
";",
"$",
"question",
"->",
"single",
"=",
"0",
";",
"// More than one answer allowed.",
"$",
"answers",
"=",
"$",
"quest",
"->",
"responses",
";",
"$",
"correctanswers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"answers",
"as",
"$",
"answer",
")",
"{",
"if",
"(",
"$",
"answer",
"->",
"title",
"==",
"'correct'",
")",
"{",
"$",
"answerset",
"=",
"$",
"this",
"->",
"getpath",
"(",
"$",
"answer",
"->",
"ident",
"[",
"0",
"]",
",",
"array",
"(",
"'and'",
",",
"0",
",",
"'#'",
",",
"'varequal'",
")",
",",
"array",
"(",
")",
",",
"false",
")",
";",
"foreach",
"(",
"$",
"answerset",
"as",
"$",
"ans",
")",
"{",
"$",
"correctanswers",
"[",
"]",
"=",
"$",
"ans",
"[",
"'#'",
"]",
";",
"}",
"}",
"}",
"$",
"feedback",
"=",
"new",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"$",
"quest",
"->",
"feedback",
"as",
"$",
"fb",
")",
"{",
"$",
"feedback",
"->",
"{",
"$",
"fb",
"->",
"ident",
"}",
"=",
"trim",
"(",
"$",
"fb",
"->",
"text",
")",
";",
"}",
"$",
"correctanswercount",
"=",
"count",
"(",
"$",
"correctanswers",
")",
";",
"$",
"fraction",
"=",
"1",
"/",
"$",
"correctanswercount",
";",
"$",
"choiceset",
"=",
"$",
"quest",
"->",
"RESPONSE_BLOCK",
"->",
"choices",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"choiceset",
"as",
"$",
"choice",
")",
"{",
"$",
"question",
"->",
"answer",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"trim",
"(",
"$",
"choice",
"->",
"text",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"choice",
"->",
"ident",
",",
"$",
"correctanswers",
")",
")",
"{",
"// Correct answer.",
"$",
"question",
"->",
"fraction",
"[",
"$",
"i",
"]",
"=",
"$",
"fraction",
";",
"$",
"question",
"->",
"feedback",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"feedback",
"->",
"correct",
")",
";",
"}",
"else",
"{",
"// Wrong answer.",
"$",
"question",
"->",
"fraction",
"[",
"$",
"i",
"]",
"=",
"0",
";",
"$",
"question",
"->",
"feedback",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"feedback",
"->",
"incorrect",
")",
";",
"}",
"$",
"i",
"++",
";",
"}",
"$",
"questions",
"[",
"]",
"=",
"$",
"question",
";",
"}"
] | Process Multiple Choice Questions With Multiple Answers.
Parse a multichoice multianswer rawquestion and add the result
to the array of questions already parsed.
@param object $quest rawquestion
@param array $questions array of Moodle questions already done. | [
"Process",
"Multiple",
"Choice",
"Questions",
"With",
"Multiple",
"Answers",
".",
"Parse",
"a",
"multichoice",
"multianswer",
"rawquestion",
"and",
"add",
"the",
"result",
"to",
"the",
"array",
"of",
"questions",
"already",
"parsed",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L712-L753 |
213,567 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_essay | public function process_essay($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'essay';
$question->feedback = array();
// Not sure where to get the correct answer from?
foreach ($quest->feedback as $feedback) {
// Added this code to put the possible solution that the
// instructor gives as the Moodle answer for an essay question.
if ($feedback->ident == 'solution') {
$question->graderinfo = $this->cleaned_text_field($feedback->text);
}
}
// Added because essay/questiontype.php:save_question_option is expecting a
// fraction property - CT 8/10/06.
$question->fraction[] = 1;
$question->defaultmark = 1;
$question->responseformat = 'editor';
$question->responserequired = 1;
$question->responsefieldlines = 15;
$question->attachments = 0;
$question->attachmentsrequired = 0;
$question->responsetemplate = $this->text_field('');
$questions[] = $question;
} | php | public function process_essay($quest, &$questions) {
$question = $this->process_common($quest);
$question->qtype = 'essay';
$question->feedback = array();
// Not sure where to get the correct answer from?
foreach ($quest->feedback as $feedback) {
// Added this code to put the possible solution that the
// instructor gives as the Moodle answer for an essay question.
if ($feedback->ident == 'solution') {
$question->graderinfo = $this->cleaned_text_field($feedback->text);
}
}
// Added because essay/questiontype.php:save_question_option is expecting a
// fraction property - CT 8/10/06.
$question->fraction[] = 1;
$question->defaultmark = 1;
$question->responseformat = 'editor';
$question->responserequired = 1;
$question->responsefieldlines = 15;
$question->attachments = 0;
$question->attachmentsrequired = 0;
$question->responsetemplate = $this->text_field('');
$questions[] = $question;
} | [
"public",
"function",
"process_essay",
"(",
"$",
"quest",
",",
"&",
"$",
"questions",
")",
"{",
"$",
"question",
"=",
"$",
"this",
"->",
"process_common",
"(",
"$",
"quest",
")",
";",
"$",
"question",
"->",
"qtype",
"=",
"'essay'",
";",
"$",
"question",
"->",
"feedback",
"=",
"array",
"(",
")",
";",
"// Not sure where to get the correct answer from?",
"foreach",
"(",
"$",
"quest",
"->",
"feedback",
"as",
"$",
"feedback",
")",
"{",
"// Added this code to put the possible solution that the",
"// instructor gives as the Moodle answer for an essay question.",
"if",
"(",
"$",
"feedback",
"->",
"ident",
"==",
"'solution'",
")",
"{",
"$",
"question",
"->",
"graderinfo",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"feedback",
"->",
"text",
")",
";",
"}",
"}",
"// Added because essay/questiontype.php:save_question_option is expecting a",
"// fraction property - CT 8/10/06.",
"$",
"question",
"->",
"fraction",
"[",
"]",
"=",
"1",
";",
"$",
"question",
"->",
"defaultmark",
"=",
"1",
";",
"$",
"question",
"->",
"responseformat",
"=",
"'editor'",
";",
"$",
"question",
"->",
"responserequired",
"=",
"1",
";",
"$",
"question",
"->",
"responsefieldlines",
"=",
"15",
";",
"$",
"question",
"->",
"attachments",
"=",
"0",
";",
"$",
"question",
"->",
"attachmentsrequired",
"=",
"0",
";",
"$",
"question",
"->",
"responsetemplate",
"=",
"$",
"this",
"->",
"text_field",
"(",
"''",
")",
";",
"$",
"questions",
"[",
"]",
"=",
"$",
"question",
";",
"}"
] | Process Essay Questions
Parse an essay rawquestion and add the result
to the array of questions already parsed.
@param object $quest rawquestion
@param array $questions array of Moodle questions already done. | [
"Process",
"Essay",
"Questions",
"Parse",
"an",
"essay",
"rawquestion",
"and",
"add",
"the",
"result",
"to",
"the",
"array",
"of",
"questions",
"already",
"parsed",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L762-L788 |
213,568 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_matching | public function process_matching($quest, &$questions) {
// Blackboard matching questions can't be imported in core Moodle without a loss in data,
// as core match question don't allow HTML in subanswers. The contributed ddmatch
// question type support HTML in subanswers.
// The ddmatch question type is not part of core, so we need to check if it is defined.
$ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
$question = $this->process_common($quest);
$question = $this->add_blank_combined_feedback($question);
$question->valid = true;
if ($ddmatchisinstalled) {
$question->qtype = 'ddmatch';
} else {
$question->qtype = 'match';
}
// Construction of the array holding mappings between subanswers and subquestions.
foreach ($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) {
foreach ($quest->responses as $rid => $resp) {
if (isset($resp->ident) && $resp->ident == $subq->ident) {
$correct = $resp->correct;
}
}
foreach ($subq->choices as $cid => $choice) {
if ($choice == $correct) {
$mappings[$subq->ident] = $cid;
}
}
}
foreach ($subq->choices as $choiceid => $choice) {
$subanswertext = $quest->RIGHT_MATCH_BLOCK->matchinganswerset[$choiceid]->text;
if ($ddmatchisinstalled) {
$subanswer = $this->cleaned_text_field($subanswertext);
} else {
$subanswertext = html_to_text($this->cleaninput($subanswertext), 0);
$subanswer = $subanswertext;
}
if ($subanswertext != '') { // Only import non empty subanswers.
$subquestion = '';
$fiber = array_keys ($mappings, $choiceid);
foreach ($fiber as $correctanswerid) {
// We have found a correspondance for this subanswer so we need to take the associated subquestion.
foreach ($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) {
$currentsubqid = $subq->ident;
if (strcmp ($currentsubqid, $correctanswerid) == 0) {
$subquestion = $subq->text;
break;
}
}
$question->subquestions[] = $this->cleaned_text_field($subquestion);
$question->subanswers[] = $subanswer;
}
if ($subquestion == '') { // Then in this case, $choice is a distractor.
$question->subquestions[] = $this->text_field('');
$question->subanswers[] = $subanswer;
}
}
}
// Verify that this matching question has enough subquestions and subanswers.
$subquestioncount = 0;
$subanswercount = 0;
$subanswers = $question->subanswers;
foreach ($question->subquestions as $key => $subquestion) {
$subquestion = $subquestion['text'];
$subanswer = $subanswers[$key];
if ($subquestion != '') {
$subquestioncount++;
}
$subanswercount++;
}
if ($subquestioncount < 2 || $subanswercount < 3) {
$this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext));
} else {
$questions[] = $question;
}
} | php | public function process_matching($quest, &$questions) {
// Blackboard matching questions can't be imported in core Moodle without a loss in data,
// as core match question don't allow HTML in subanswers. The contributed ddmatch
// question type support HTML in subanswers.
// The ddmatch question type is not part of core, so we need to check if it is defined.
$ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
$question = $this->process_common($quest);
$question = $this->add_blank_combined_feedback($question);
$question->valid = true;
if ($ddmatchisinstalled) {
$question->qtype = 'ddmatch';
} else {
$question->qtype = 'match';
}
// Construction of the array holding mappings between subanswers and subquestions.
foreach ($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) {
foreach ($quest->responses as $rid => $resp) {
if (isset($resp->ident) && $resp->ident == $subq->ident) {
$correct = $resp->correct;
}
}
foreach ($subq->choices as $cid => $choice) {
if ($choice == $correct) {
$mappings[$subq->ident] = $cid;
}
}
}
foreach ($subq->choices as $choiceid => $choice) {
$subanswertext = $quest->RIGHT_MATCH_BLOCK->matchinganswerset[$choiceid]->text;
if ($ddmatchisinstalled) {
$subanswer = $this->cleaned_text_field($subanswertext);
} else {
$subanswertext = html_to_text($this->cleaninput($subanswertext), 0);
$subanswer = $subanswertext;
}
if ($subanswertext != '') { // Only import non empty subanswers.
$subquestion = '';
$fiber = array_keys ($mappings, $choiceid);
foreach ($fiber as $correctanswerid) {
// We have found a correspondance for this subanswer so we need to take the associated subquestion.
foreach ($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) {
$currentsubqid = $subq->ident;
if (strcmp ($currentsubqid, $correctanswerid) == 0) {
$subquestion = $subq->text;
break;
}
}
$question->subquestions[] = $this->cleaned_text_field($subquestion);
$question->subanswers[] = $subanswer;
}
if ($subquestion == '') { // Then in this case, $choice is a distractor.
$question->subquestions[] = $this->text_field('');
$question->subanswers[] = $subanswer;
}
}
}
// Verify that this matching question has enough subquestions and subanswers.
$subquestioncount = 0;
$subanswercount = 0;
$subanswers = $question->subanswers;
foreach ($question->subquestions as $key => $subquestion) {
$subquestion = $subquestion['text'];
$subanswer = $subanswers[$key];
if ($subquestion != '') {
$subquestioncount++;
}
$subanswercount++;
}
if ($subquestioncount < 2 || $subanswercount < 3) {
$this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext));
} else {
$questions[] = $question;
}
} | [
"public",
"function",
"process_matching",
"(",
"$",
"quest",
",",
"&",
"$",
"questions",
")",
"{",
"// Blackboard matching questions can't be imported in core Moodle without a loss in data,",
"// as core match question don't allow HTML in subanswers. The contributed ddmatch",
"// question type support HTML in subanswers.",
"// The ddmatch question type is not part of core, so we need to check if it is defined.",
"$",
"ddmatchisinstalled",
"=",
"question_bank",
"::",
"is_qtype_installed",
"(",
"'ddmatch'",
")",
";",
"$",
"question",
"=",
"$",
"this",
"->",
"process_common",
"(",
"$",
"quest",
")",
";",
"$",
"question",
"=",
"$",
"this",
"->",
"add_blank_combined_feedback",
"(",
"$",
"question",
")",
";",
"$",
"question",
"->",
"valid",
"=",
"true",
";",
"if",
"(",
"$",
"ddmatchisinstalled",
")",
"{",
"$",
"question",
"->",
"qtype",
"=",
"'ddmatch'",
";",
"}",
"else",
"{",
"$",
"question",
"->",
"qtype",
"=",
"'match'",
";",
"}",
"// Construction of the array holding mappings between subanswers and subquestions.",
"foreach",
"(",
"$",
"quest",
"->",
"RESPONSE_BLOCK",
"->",
"subquestions",
"as",
"$",
"qid",
"=>",
"$",
"subq",
")",
"{",
"foreach",
"(",
"$",
"quest",
"->",
"responses",
"as",
"$",
"rid",
"=>",
"$",
"resp",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"resp",
"->",
"ident",
")",
"&&",
"$",
"resp",
"->",
"ident",
"==",
"$",
"subq",
"->",
"ident",
")",
"{",
"$",
"correct",
"=",
"$",
"resp",
"->",
"correct",
";",
"}",
"}",
"foreach",
"(",
"$",
"subq",
"->",
"choices",
"as",
"$",
"cid",
"=>",
"$",
"choice",
")",
"{",
"if",
"(",
"$",
"choice",
"==",
"$",
"correct",
")",
"{",
"$",
"mappings",
"[",
"$",
"subq",
"->",
"ident",
"]",
"=",
"$",
"cid",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"subq",
"->",
"choices",
"as",
"$",
"choiceid",
"=>",
"$",
"choice",
")",
"{",
"$",
"subanswertext",
"=",
"$",
"quest",
"->",
"RIGHT_MATCH_BLOCK",
"->",
"matchinganswerset",
"[",
"$",
"choiceid",
"]",
"->",
"text",
";",
"if",
"(",
"$",
"ddmatchisinstalled",
")",
"{",
"$",
"subanswer",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"subanswertext",
")",
";",
"}",
"else",
"{",
"$",
"subanswertext",
"=",
"html_to_text",
"(",
"$",
"this",
"->",
"cleaninput",
"(",
"$",
"subanswertext",
")",
",",
"0",
")",
";",
"$",
"subanswer",
"=",
"$",
"subanswertext",
";",
"}",
"if",
"(",
"$",
"subanswertext",
"!=",
"''",
")",
"{",
"// Only import non empty subanswers.",
"$",
"subquestion",
"=",
"''",
";",
"$",
"fiber",
"=",
"array_keys",
"(",
"$",
"mappings",
",",
"$",
"choiceid",
")",
";",
"foreach",
"(",
"$",
"fiber",
"as",
"$",
"correctanswerid",
")",
"{",
"// We have found a correspondance for this subanswer so we need to take the associated subquestion.",
"foreach",
"(",
"$",
"quest",
"->",
"RESPONSE_BLOCK",
"->",
"subquestions",
"as",
"$",
"qid",
"=>",
"$",
"subq",
")",
"{",
"$",
"currentsubqid",
"=",
"$",
"subq",
"->",
"ident",
";",
"if",
"(",
"strcmp",
"(",
"$",
"currentsubqid",
",",
"$",
"correctanswerid",
")",
"==",
"0",
")",
"{",
"$",
"subquestion",
"=",
"$",
"subq",
"->",
"text",
";",
"break",
";",
"}",
"}",
"$",
"question",
"->",
"subquestions",
"[",
"]",
"=",
"$",
"this",
"->",
"cleaned_text_field",
"(",
"$",
"subquestion",
")",
";",
"$",
"question",
"->",
"subanswers",
"[",
"]",
"=",
"$",
"subanswer",
";",
"}",
"if",
"(",
"$",
"subquestion",
"==",
"''",
")",
"{",
"// Then in this case, $choice is a distractor.",
"$",
"question",
"->",
"subquestions",
"[",
"]",
"=",
"$",
"this",
"->",
"text_field",
"(",
"''",
")",
";",
"$",
"question",
"->",
"subanswers",
"[",
"]",
"=",
"$",
"subanswer",
";",
"}",
"}",
"}",
"// Verify that this matching question has enough subquestions and subanswers.",
"$",
"subquestioncount",
"=",
"0",
";",
"$",
"subanswercount",
"=",
"0",
";",
"$",
"subanswers",
"=",
"$",
"question",
"->",
"subanswers",
";",
"foreach",
"(",
"$",
"question",
"->",
"subquestions",
"as",
"$",
"key",
"=>",
"$",
"subquestion",
")",
"{",
"$",
"subquestion",
"=",
"$",
"subquestion",
"[",
"'text'",
"]",
";",
"$",
"subanswer",
"=",
"$",
"subanswers",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"$",
"subquestion",
"!=",
"''",
")",
"{",
"$",
"subquestioncount",
"++",
";",
"}",
"$",
"subanswercount",
"++",
";",
"}",
"if",
"(",
"$",
"subquestioncount",
"<",
"2",
"||",
"$",
"subanswercount",
"<",
"3",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"get_string",
"(",
"'notenoughtsubans'",
",",
"'qformat_blackboard_six'",
",",
"$",
"question",
"->",
"questiontext",
")",
")",
";",
"}",
"else",
"{",
"$",
"questions",
"[",
"]",
"=",
"$",
"question",
";",
"}",
"}"
] | Process Matching Questions
Parse a matching rawquestion and add the result
to the array of questions already parsed.
@param object $quest rawquestion
@param array $questions array of Moodle questions already done. | [
"Process",
"Matching",
"Questions",
"Parse",
"a",
"matching",
"rawquestion",
"and",
"add",
"the",
"result",
"to",
"the",
"array",
"of",
"questions",
"already",
"parsed",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L797-L878 |
213,569 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.process_category | public function process_category($xml, &$questions) {
$title = $this->getpath($xml, array('questestinterop', '#', 'assessment', 0, '@', 'title'), '', true);
$dummyquestion = new stdClass();
$dummyquestion->qtype = 'category';
$dummyquestion->category = $this->cleaninput($this->clean_question_name($title));
$questions[] = $dummyquestion;
} | php | public function process_category($xml, &$questions) {
$title = $this->getpath($xml, array('questestinterop', '#', 'assessment', 0, '@', 'title'), '', true);
$dummyquestion = new stdClass();
$dummyquestion->qtype = 'category';
$dummyquestion->category = $this->cleaninput($this->clean_question_name($title));
$questions[] = $dummyquestion;
} | [
"public",
"function",
"process_category",
"(",
"$",
"xml",
",",
"&",
"$",
"questions",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"getpath",
"(",
"$",
"xml",
",",
"array",
"(",
"'questestinterop'",
",",
"'#'",
",",
"'assessment'",
",",
"0",
",",
"'@'",
",",
"'title'",
")",
",",
"''",
",",
"true",
")",
";",
"$",
"dummyquestion",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"dummyquestion",
"->",
"qtype",
"=",
"'category'",
";",
"$",
"dummyquestion",
"->",
"category",
"=",
"$",
"this",
"->",
"cleaninput",
"(",
"$",
"this",
"->",
"clean_question_name",
"(",
"$",
"title",
")",
")",
";",
"$",
"questions",
"[",
"]",
"=",
"$",
"dummyquestion",
";",
"}"
] | Add a category question entry based on the assessment title
@param array $xml the xml tree
@param array $questions the questions already parsed | [
"Add",
"a",
"category",
"question",
"entry",
"based",
"on",
"the",
"assessment",
"title"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L885-L893 |
213,570 | moodle/moodle | question/format/blackboard_six/formatqti.php | qformat_blackboard_six_qti.strip_applet_tags_get_mathml | public function strip_applet_tags_get_mathml($string) {
if (stristr($string, '</APPLET>') === false) {
return $string;
} else {
// Strip all applet tags keeping stuff before/after and inbetween (if mathml) them.
while (stristr($string, '</APPLET>') !== false) {
preg_match("/(.*)\<applet.*value=\"(\<math\>.*\<\/math\>)\".*\<\/applet\>(.*)/i", $string, $mathmls);
$string = $mathmls[1].$mathmls[2].$mathmls[3];
}
return $string;
}
} | php | public function strip_applet_tags_get_mathml($string) {
if (stristr($string, '</APPLET>') === false) {
return $string;
} else {
// Strip all applet tags keeping stuff before/after and inbetween (if mathml) them.
while (stristr($string, '</APPLET>') !== false) {
preg_match("/(.*)\<applet.*value=\"(\<math\>.*\<\/math\>)\".*\<\/applet\>(.*)/i", $string, $mathmls);
$string = $mathmls[1].$mathmls[2].$mathmls[3];
}
return $string;
}
} | [
"public",
"function",
"strip_applet_tags_get_mathml",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"stristr",
"(",
"$",
"string",
",",
"'</APPLET>'",
")",
"===",
"false",
")",
"{",
"return",
"$",
"string",
";",
"}",
"else",
"{",
"// Strip all applet tags keeping stuff before/after and inbetween (if mathml) them.",
"while",
"(",
"stristr",
"(",
"$",
"string",
",",
"'</APPLET>'",
")",
"!==",
"false",
")",
"{",
"preg_match",
"(",
"\"/(.*)\\<applet.*value=\\\"(\\<math\\>.*\\<\\/math\\>)\\\".*\\<\\/applet\\>(.*)/i\"",
",",
"$",
"string",
",",
"$",
"mathmls",
")",
";",
"$",
"string",
"=",
"$",
"mathmls",
"[",
"1",
"]",
".",
"$",
"mathmls",
"[",
"2",
"]",
".",
"$",
"mathmls",
"[",
"3",
"]",
";",
"}",
"return",
"$",
"string",
";",
"}",
"}"
] | Strip the applet tag used by Blackboard to render mathml formulas,
keeping the mathml tag.
@param string $string
@return string | [
"Strip",
"the",
"applet",
"tag",
"used",
"by",
"Blackboard",
"to",
"render",
"mathml",
"formulas",
"keeping",
"the",
"mathml",
"tag",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/format/blackboard_six/formatqti.php#L901-L912 |
213,571 | moodle/moodle | mod/assign/classes/event/base.php | base.set_assign | public function set_assign(\assign $assign) {
if ($this->is_triggered()) {
throw new \coding_exception('set_assign() must be done before triggerring of event');
}
if ($assign->get_context()->id != $this->get_context()->id) {
throw new \coding_exception('Invalid assign isntance supplied!');
}
if ($assign->is_blind_marking()) {
$this->data['anonymous'] = 1;
}
$this->assign = $assign;
} | php | public function set_assign(\assign $assign) {
if ($this->is_triggered()) {
throw new \coding_exception('set_assign() must be done before triggerring of event');
}
if ($assign->get_context()->id != $this->get_context()->id) {
throw new \coding_exception('Invalid assign isntance supplied!');
}
if ($assign->is_blind_marking()) {
$this->data['anonymous'] = 1;
}
$this->assign = $assign;
} | [
"public",
"function",
"set_assign",
"(",
"\\",
"assign",
"$",
"assign",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_triggered",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'set_assign() must be done before triggerring of event'",
")",
";",
"}",
"if",
"(",
"$",
"assign",
"->",
"get_context",
"(",
")",
"->",
"id",
"!=",
"$",
"this",
"->",
"get_context",
"(",
")",
"->",
"id",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'Invalid assign isntance supplied!'",
")",
";",
"}",
"if",
"(",
"$",
"assign",
"->",
"is_blind_marking",
"(",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'anonymous'",
"]",
"=",
"1",
";",
"}",
"$",
"this",
"->",
"assign",
"=",
"$",
"assign",
";",
"}"
] | Set assign instance for this event.
@param \assign $assign
@throws \coding_exception | [
"Set",
"assign",
"instance",
"for",
"this",
"event",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/classes/event/base.php#L56-L67 |
213,572 | moodle/moodle | mod/assign/classes/event/base.php | base.get_assign | public function get_assign() {
if ($this->is_restored()) {
throw new \coding_exception('get_assign() is intended for event observers only');
}
if (!isset($this->assign)) {
debugging('assign property should be initialised in each event', DEBUG_DEVELOPER);
global $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$cm = get_coursemodule_from_id('assign', $this->contextinstanceid, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$this->assign = new \assign($this->get_context(), $cm, $course);
}
return $this->assign;
} | php | public function get_assign() {
if ($this->is_restored()) {
throw new \coding_exception('get_assign() is intended for event observers only');
}
if (!isset($this->assign)) {
debugging('assign property should be initialised in each event', DEBUG_DEVELOPER);
global $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$cm = get_coursemodule_from_id('assign', $this->contextinstanceid, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$this->assign = new \assign($this->get_context(), $cm, $course);
}
return $this->assign;
} | [
"public",
"function",
"get_assign",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_restored",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'get_assign() is intended for event observers only'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"assign",
")",
")",
"{",
"debugging",
"(",
"'assign property should be initialised in each event'",
",",
"DEBUG_DEVELOPER",
")",
";",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/locallib.php'",
")",
";",
"$",
"cm",
"=",
"get_coursemodule_from_id",
"(",
"'assign'",
",",
"$",
"this",
"->",
"contextinstanceid",
",",
"0",
",",
"false",
",",
"MUST_EXIST",
")",
";",
"$",
"course",
"=",
"get_course",
"(",
"$",
"cm",
"->",
"course",
")",
";",
"$",
"this",
"->",
"assign",
"=",
"new",
"\\",
"assign",
"(",
"$",
"this",
"->",
"get_context",
"(",
")",
",",
"$",
"cm",
",",
"$",
"course",
")",
";",
"}",
"return",
"$",
"this",
"->",
"assign",
";",
"}"
] | Get assign instance.
NOTE: to be used from observers only.
@throws \coding_exception
@return \assign | [
"Get",
"assign",
"instance",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/classes/event/base.php#L77-L90 |
213,573 | moodle/moodle | mod/assign/classes/event/base.php | base.set_legacy_logdata | public function set_legacy_logdata($action = '', $info = '', $url = '') {
$fullurl = 'view.php?id=' . $this->contextinstanceid;
if ($url != '') {
$fullurl .= '&' . $url;
}
$this->legacylogdata = array($this->courseid, 'assign', $action, $fullurl, $info, $this->contextinstanceid);
} | php | public function set_legacy_logdata($action = '', $info = '', $url = '') {
$fullurl = 'view.php?id=' . $this->contextinstanceid;
if ($url != '') {
$fullurl .= '&' . $url;
}
$this->legacylogdata = array($this->courseid, 'assign', $action, $fullurl, $info, $this->contextinstanceid);
} | [
"public",
"function",
"set_legacy_logdata",
"(",
"$",
"action",
"=",
"''",
",",
"$",
"info",
"=",
"''",
",",
"$",
"url",
"=",
"''",
")",
"{",
"$",
"fullurl",
"=",
"'view.php?id='",
".",
"$",
"this",
"->",
"contextinstanceid",
";",
"if",
"(",
"$",
"url",
"!=",
"''",
")",
"{",
"$",
"fullurl",
".=",
"'&'",
".",
"$",
"url",
";",
"}",
"$",
"this",
"->",
"legacylogdata",
"=",
"array",
"(",
"$",
"this",
"->",
"courseid",
",",
"'assign'",
",",
"$",
"action",
",",
"$",
"fullurl",
",",
"$",
"info",
",",
"$",
"this",
"->",
"contextinstanceid",
")",
";",
"}"
] | Sets the legacy event log data.
@param string $action The current action
@param string $info A detailed description of the change. But no more than 255 characters.
@param string $url The url to the assign module instance. | [
"Sets",
"the",
"legacy",
"event",
"log",
"data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/classes/event/base.php#L109-L116 |
213,574 | moodle/moodle | question/classes/external.php | core_question_external.update_flag | public static function update_flag($qubaid, $questionid, $qaid, $slot, $checksum, $newstate) {
global $CFG, $DB;
$params = self::validate_parameters(self::update_flag_parameters(),
array(
'qubaid' => $qubaid,
'questionid' => $questionid,
'qaid' => $qaid,
'slot' => $slot,
'checksum' => $checksum,
'newstate' => $newstate
)
);
$warnings = array();
self::validate_context(context_system::instance());
// The checksum will be checked to provide security flagging other users questions.
question_flags::update_flag($params['qubaid'], $params['questionid'], $params['qaid'], $params['slot'], $params['checksum'],
$params['newstate']);
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
} | php | public static function update_flag($qubaid, $questionid, $qaid, $slot, $checksum, $newstate) {
global $CFG, $DB;
$params = self::validate_parameters(self::update_flag_parameters(),
array(
'qubaid' => $qubaid,
'questionid' => $questionid,
'qaid' => $qaid,
'slot' => $slot,
'checksum' => $checksum,
'newstate' => $newstate
)
);
$warnings = array();
self::validate_context(context_system::instance());
// The checksum will be checked to provide security flagging other users questions.
question_flags::update_flag($params['qubaid'], $params['questionid'], $params['qaid'], $params['slot'], $params['checksum'],
$params['newstate']);
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
} | [
"public",
"static",
"function",
"update_flag",
"(",
"$",
"qubaid",
",",
"$",
"questionid",
",",
"$",
"qaid",
",",
"$",
"slot",
",",
"$",
"checksum",
",",
"$",
"newstate",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"update_flag_parameters",
"(",
")",
",",
"array",
"(",
"'qubaid'",
"=>",
"$",
"qubaid",
",",
"'questionid'",
"=>",
"$",
"questionid",
",",
"'qaid'",
"=>",
"$",
"qaid",
",",
"'slot'",
"=>",
"$",
"slot",
",",
"'checksum'",
"=>",
"$",
"checksum",
",",
"'newstate'",
"=>",
"$",
"newstate",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"self",
"::",
"validate_context",
"(",
"context_system",
"::",
"instance",
"(",
")",
")",
";",
"// The checksum will be checked to provide security flagging other users questions.",
"question_flags",
"::",
"update_flag",
"(",
"$",
"params",
"[",
"'qubaid'",
"]",
",",
"$",
"params",
"[",
"'questionid'",
"]",
",",
"$",
"params",
"[",
"'qaid'",
"]",
",",
"$",
"params",
"[",
"'slot'",
"]",
",",
"$",
"params",
"[",
"'checksum'",
"]",
",",
"$",
"params",
"[",
"'newstate'",
"]",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"'warnings'",
"]",
"=",
"$",
"warnings",
";",
"return",
"$",
"result",
";",
"}"
] | Update the flag state of a question attempt.
@param int $qubaid the question usage id.
@param int $questionid the question id.
@param int $qaid the question_attempt id.
@param int $slot the slot number within the usage.
@param string $checksum checksum, as computed by {@link get_toggle_checksum()}
corresponding to the last three arguments and the users username.
@param bool $newstate the new state of the flag. true = flagged.
@return array (success infos and fail infos)
@since Moodle 3.1 | [
"Update",
"the",
"flag",
"state",
"of",
"a",
"question",
"attempt",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/external.php#L78-L103 |
213,575 | moodle/moodle | question/classes/external.php | core_question_external.submit_tags_form | public static function submit_tags_form($questionid, $contextid, $formdata) {
global $DB, $CFG;
$data = [];
$result = ['status' => false];
// Parameter validation.
$params = self::validate_parameters(self::submit_tags_form_parameters(), [
'questionid' => $questionid,
'contextid' => $contextid,
'formdata' => $formdata
]);
$editingcontext = \context::instance_by_id($contextid);
self::validate_context($editingcontext);
parse_str($params['formdata'], $data);
if (!$question = $DB->get_record_sql('
SELECT q.*, qc.contextid
FROM {question} q
JOIN {question_categories} qc ON qc.id = q.category
WHERE q.id = ?', [$questionid])) {
print_error('questiondoesnotexist', 'question');
}
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/question/type/tags_form.php');
$cantag = question_has_capability_on($question, 'tag');
$questioncontext = \context::instance_by_id($question->contextid);
$contexts = new \question_edit_contexts($editingcontext);
$formoptions = [
'editingcontext' => $editingcontext,
'questioncontext' => $questioncontext,
'contexts' => $contexts->all()
];
$mform = new \core_question\form\tags(null, $formoptions, 'post', '', null, $cantag, $data);
if ($validateddata = $mform->get_data()) {
if ($cantag) {
if (isset($validateddata->tags)) {
// Due to a mform bug, if there's no tags set on the tag element, it submits the name as the value.
// The only way to discover is checking if the tag element is an array.
$tags = is_array($validateddata->tags) ? $validateddata->tags : [];
core_tag_tag::set_item_tags('core_question', 'question', $validateddata->id,
$questioncontext, $tags);
$result['status'] = true;
}
if (isset($validateddata->coursetags)) {
$coursetags = is_array($validateddata->coursetags) ? $validateddata->coursetags : [];
core_tag_tag::set_item_tags('core_question', 'question', $validateddata->id,
$editingcontext->get_course_context(false), $coursetags);
$result['status'] = true;
}
}
}
return $result;
} | php | public static function submit_tags_form($questionid, $contextid, $formdata) {
global $DB, $CFG;
$data = [];
$result = ['status' => false];
// Parameter validation.
$params = self::validate_parameters(self::submit_tags_form_parameters(), [
'questionid' => $questionid,
'contextid' => $contextid,
'formdata' => $formdata
]);
$editingcontext = \context::instance_by_id($contextid);
self::validate_context($editingcontext);
parse_str($params['formdata'], $data);
if (!$question = $DB->get_record_sql('
SELECT q.*, qc.contextid
FROM {question} q
JOIN {question_categories} qc ON qc.id = q.category
WHERE q.id = ?', [$questionid])) {
print_error('questiondoesnotexist', 'question');
}
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/question/type/tags_form.php');
$cantag = question_has_capability_on($question, 'tag');
$questioncontext = \context::instance_by_id($question->contextid);
$contexts = new \question_edit_contexts($editingcontext);
$formoptions = [
'editingcontext' => $editingcontext,
'questioncontext' => $questioncontext,
'contexts' => $contexts->all()
];
$mform = new \core_question\form\tags(null, $formoptions, 'post', '', null, $cantag, $data);
if ($validateddata = $mform->get_data()) {
if ($cantag) {
if (isset($validateddata->tags)) {
// Due to a mform bug, if there's no tags set on the tag element, it submits the name as the value.
// The only way to discover is checking if the tag element is an array.
$tags = is_array($validateddata->tags) ? $validateddata->tags : [];
core_tag_tag::set_item_tags('core_question', 'question', $validateddata->id,
$questioncontext, $tags);
$result['status'] = true;
}
if (isset($validateddata->coursetags)) {
$coursetags = is_array($validateddata->coursetags) ? $validateddata->coursetags : [];
core_tag_tag::set_item_tags('core_question', 'question', $validateddata->id,
$editingcontext->get_course_context(false), $coursetags);
$result['status'] = true;
}
}
}
return $result;
} | [
"public",
"static",
"function",
"submit_tags_form",
"(",
"$",
"questionid",
",",
"$",
"contextid",
",",
"$",
"formdata",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"[",
"'status'",
"=>",
"false",
"]",
";",
"// Parameter validation.",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"submit_tags_form_parameters",
"(",
")",
",",
"[",
"'questionid'",
"=>",
"$",
"questionid",
",",
"'contextid'",
"=>",
"$",
"contextid",
",",
"'formdata'",
"=>",
"$",
"formdata",
"]",
")",
";",
"$",
"editingcontext",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"contextid",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"editingcontext",
")",
";",
"parse_str",
"(",
"$",
"params",
"[",
"'formdata'",
"]",
",",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"question",
"=",
"$",
"DB",
"->",
"get_record_sql",
"(",
"'\n SELECT q.*, qc.contextid\n FROM {question} q\n JOIN {question_categories} qc ON qc.id = q.category\n WHERE q.id = ?'",
",",
"[",
"$",
"questionid",
"]",
")",
")",
"{",
"print_error",
"(",
"'questiondoesnotexist'",
",",
"'question'",
")",
";",
"}",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/questionlib.php'",
")",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/question/type/tags_form.php'",
")",
";",
"$",
"cantag",
"=",
"question_has_capability_on",
"(",
"$",
"question",
",",
"'tag'",
")",
";",
"$",
"questioncontext",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"question",
"->",
"contextid",
")",
";",
"$",
"contexts",
"=",
"new",
"\\",
"question_edit_contexts",
"(",
"$",
"editingcontext",
")",
";",
"$",
"formoptions",
"=",
"[",
"'editingcontext'",
"=>",
"$",
"editingcontext",
",",
"'questioncontext'",
"=>",
"$",
"questioncontext",
",",
"'contexts'",
"=>",
"$",
"contexts",
"->",
"all",
"(",
")",
"]",
";",
"$",
"mform",
"=",
"new",
"\\",
"core_question",
"\\",
"form",
"\\",
"tags",
"(",
"null",
",",
"$",
"formoptions",
",",
"'post'",
",",
"''",
",",
"null",
",",
"$",
"cantag",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"validateddata",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
")",
"{",
"if",
"(",
"$",
"cantag",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"validateddata",
"->",
"tags",
")",
")",
"{",
"// Due to a mform bug, if there's no tags set on the tag element, it submits the name as the value.",
"// The only way to discover is checking if the tag element is an array.",
"$",
"tags",
"=",
"is_array",
"(",
"$",
"validateddata",
"->",
"tags",
")",
"?",
"$",
"validateddata",
"->",
"tags",
":",
"[",
"]",
";",
"core_tag_tag",
"::",
"set_item_tags",
"(",
"'core_question'",
",",
"'question'",
",",
"$",
"validateddata",
"->",
"id",
",",
"$",
"questioncontext",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"validateddata",
"->",
"coursetags",
")",
")",
"{",
"$",
"coursetags",
"=",
"is_array",
"(",
"$",
"validateddata",
"->",
"coursetags",
")",
"?",
"$",
"validateddata",
"->",
"coursetags",
":",
"[",
"]",
";",
"core_tag_tag",
"::",
"set_item_tags",
"(",
"'core_question'",
",",
"'question'",
",",
"$",
"validateddata",
"->",
"id",
",",
"$",
"editingcontext",
"->",
"get_course_context",
"(",
"false",
")",
",",
"$",
"coursetags",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Handles the tags form submission.
@param int $questionid The question id.
@param int $contextid The editing context id.
@param string $formdata The question tag form data in a URI encoded param string
@return array The created or modified question tag | [
"Handles",
"the",
"tags",
"form",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/external.php#L141-L205 |
213,576 | moodle/moodle | question/classes/external.php | core_question_external.get_random_question_summaries | public static function get_random_question_summaries(
$categoryid,
$includesubcategories,
$tagids,
$contextid,
$limit = 0,
$offset = 0
) {
global $DB, $PAGE;
// Parameter validation.
$params = self::validate_parameters(
self::get_random_question_summaries_parameters(),
[
'categoryid' => $categoryid,
'includesubcategories' => $includesubcategories,
'tagids' => $tagids,
'contextid' => $contextid,
'limit' => $limit,
'offset' => $offset
]
);
$categoryid = $params['categoryid'];
$includesubcategories = $params['includesubcategories'];
$tagids = $params['tagids'];
$contextid = $params['contextid'];
$limit = $params['limit'];
$offset = $params['offset'];
$context = \context::instance_by_id($contextid);
self::validate_context($context);
$categorycontextid = $DB->get_field('question_categories', 'contextid', ['id' => $categoryid], MUST_EXIST);
$categorycontext = \context::instance_by_id($categorycontextid);
$editcontexts = new \question_edit_contexts($categorycontext);
// The user must be able to view all questions in the category that they are requesting.
$editcontexts->require_cap('moodle/question:viewall');
$loader = new \core_question\bank\random_question_loader(new qubaid_list([]));
// Only load the properties we require from the DB.
$properties = \core_question\external\question_summary_exporter::get_mandatory_properties();
$questions = $loader->get_questions($categoryid, $includesubcategories, $tagids, $limit, $offset, $properties);
$totalcount = $loader->count_questions($categoryid, $includesubcategories, $tagids);
$renderer = $PAGE->get_renderer('core');
$formattedquestions = array_map(function($question) use ($context, $renderer) {
$exporter = new \core_question\external\question_summary_exporter($question, ['context' => $context]);
return $exporter->export($renderer);
}, $questions);
return [
'totalcount' => $totalcount,
'questions' => $formattedquestions
];
} | php | public static function get_random_question_summaries(
$categoryid,
$includesubcategories,
$tagids,
$contextid,
$limit = 0,
$offset = 0
) {
global $DB, $PAGE;
// Parameter validation.
$params = self::validate_parameters(
self::get_random_question_summaries_parameters(),
[
'categoryid' => $categoryid,
'includesubcategories' => $includesubcategories,
'tagids' => $tagids,
'contextid' => $contextid,
'limit' => $limit,
'offset' => $offset
]
);
$categoryid = $params['categoryid'];
$includesubcategories = $params['includesubcategories'];
$tagids = $params['tagids'];
$contextid = $params['contextid'];
$limit = $params['limit'];
$offset = $params['offset'];
$context = \context::instance_by_id($contextid);
self::validate_context($context);
$categorycontextid = $DB->get_field('question_categories', 'contextid', ['id' => $categoryid], MUST_EXIST);
$categorycontext = \context::instance_by_id($categorycontextid);
$editcontexts = new \question_edit_contexts($categorycontext);
// The user must be able to view all questions in the category that they are requesting.
$editcontexts->require_cap('moodle/question:viewall');
$loader = new \core_question\bank\random_question_loader(new qubaid_list([]));
// Only load the properties we require from the DB.
$properties = \core_question\external\question_summary_exporter::get_mandatory_properties();
$questions = $loader->get_questions($categoryid, $includesubcategories, $tagids, $limit, $offset, $properties);
$totalcount = $loader->count_questions($categoryid, $includesubcategories, $tagids);
$renderer = $PAGE->get_renderer('core');
$formattedquestions = array_map(function($question) use ($context, $renderer) {
$exporter = new \core_question\external\question_summary_exporter($question, ['context' => $context]);
return $exporter->export($renderer);
}, $questions);
return [
'totalcount' => $totalcount,
'questions' => $formattedquestions
];
} | [
"public",
"static",
"function",
"get_random_question_summaries",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
",",
"$",
"contextid",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"PAGE",
";",
"// Parameter validation.",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_random_question_summaries_parameters",
"(",
")",
",",
"[",
"'categoryid'",
"=>",
"$",
"categoryid",
",",
"'includesubcategories'",
"=>",
"$",
"includesubcategories",
",",
"'tagids'",
"=>",
"$",
"tagids",
",",
"'contextid'",
"=>",
"$",
"contextid",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"'offset'",
"=>",
"$",
"offset",
"]",
")",
";",
"$",
"categoryid",
"=",
"$",
"params",
"[",
"'categoryid'",
"]",
";",
"$",
"includesubcategories",
"=",
"$",
"params",
"[",
"'includesubcategories'",
"]",
";",
"$",
"tagids",
"=",
"$",
"params",
"[",
"'tagids'",
"]",
";",
"$",
"contextid",
"=",
"$",
"params",
"[",
"'contextid'",
"]",
";",
"$",
"limit",
"=",
"$",
"params",
"[",
"'limit'",
"]",
";",
"$",
"offset",
"=",
"$",
"params",
"[",
"'offset'",
"]",
";",
"$",
"context",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"contextid",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"$",
"categorycontextid",
"=",
"$",
"DB",
"->",
"get_field",
"(",
"'question_categories'",
",",
"'contextid'",
",",
"[",
"'id'",
"=>",
"$",
"categoryid",
"]",
",",
"MUST_EXIST",
")",
";",
"$",
"categorycontext",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"categorycontextid",
")",
";",
"$",
"editcontexts",
"=",
"new",
"\\",
"question_edit_contexts",
"(",
"$",
"categorycontext",
")",
";",
"// The user must be able to view all questions in the category that they are requesting.",
"$",
"editcontexts",
"->",
"require_cap",
"(",
"'moodle/question:viewall'",
")",
";",
"$",
"loader",
"=",
"new",
"\\",
"core_question",
"\\",
"bank",
"\\",
"random_question_loader",
"(",
"new",
"qubaid_list",
"(",
"[",
"]",
")",
")",
";",
"// Only load the properties we require from the DB.",
"$",
"properties",
"=",
"\\",
"core_question",
"\\",
"external",
"\\",
"question_summary_exporter",
"::",
"get_mandatory_properties",
"(",
")",
";",
"$",
"questions",
"=",
"$",
"loader",
"->",
"get_questions",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"properties",
")",
";",
"$",
"totalcount",
"=",
"$",
"loader",
"->",
"count_questions",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"$",
"renderer",
"=",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
";",
"$",
"formattedquestions",
"=",
"array_map",
"(",
"function",
"(",
"$",
"question",
")",
"use",
"(",
"$",
"context",
",",
"$",
"renderer",
")",
"{",
"$",
"exporter",
"=",
"new",
"\\",
"core_question",
"\\",
"external",
"\\",
"question_summary_exporter",
"(",
"$",
"question",
",",
"[",
"'context'",
"=>",
"$",
"context",
"]",
")",
";",
"return",
"$",
"exporter",
"->",
"export",
"(",
"$",
"renderer",
")",
";",
"}",
",",
"$",
"questions",
")",
";",
"return",
"[",
"'totalcount'",
"=>",
"$",
"totalcount",
",",
"'questions'",
"=>",
"$",
"formattedquestions",
"]",
";",
"}"
] | Gets the list of random questions for the given criteria. The questions
will be exported in a summaries format and won't include all of the
question data.
@param int $categoryid Category id to find random questions
@param bool $includesubcategories Include the subcategories in the search
@param int[] $tagids Only include questions with these tags
@param int $contextid The context id where the questions will be rendered
@param int $limit Maximum number of results to return
@param int $offset Number of items to skip from the beginning of the result set.
@return array The list of questions and total question count. | [
"Gets",
"the",
"list",
"of",
"random",
"questions",
"for",
"the",
"given",
"criteria",
".",
"The",
"questions",
"will",
"be",
"exported",
"in",
"a",
"summaries",
"format",
"and",
"won",
"t",
"include",
"all",
"of",
"the",
"question",
"data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/external.php#L250-L304 |
213,577 | moodle/moodle | lib/horde/framework/Horde/Mime/Headers/Addresses.php | Horde_Mime_Headers_Addresses.doSendEncode | public static function doSendEncode($alist, array $opts = array())
{
$out = array();
foreach ($alist as $ob) {
if (!empty($opts['defserver'])) {
foreach ($ob->raw_addresses as $ob2) {
if (is_null($ob2->host)) {
$ob2->host = $opts['defserver'];
}
}
}
$out[] = $ob->writeAddress(array(
'encode' => empty($opts['charset']) ? null : $opts['charset'],
'idn' => true
));
}
return $out;
} | php | public static function doSendEncode($alist, array $opts = array())
{
$out = array();
foreach ($alist as $ob) {
if (!empty($opts['defserver'])) {
foreach ($ob->raw_addresses as $ob2) {
if (is_null($ob2->host)) {
$ob2->host = $opts['defserver'];
}
}
}
$out[] = $ob->writeAddress(array(
'encode' => empty($opts['charset']) ? null : $opts['charset'],
'idn' => true
));
}
return $out;
} | [
"public",
"static",
"function",
"doSendEncode",
"(",
"$",
"alist",
",",
"array",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"alist",
"as",
"$",
"ob",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'defserver'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"ob",
"->",
"raw_addresses",
"as",
"$",
"ob2",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ob2",
"->",
"host",
")",
")",
"{",
"$",
"ob2",
"->",
"host",
"=",
"$",
"opts",
"[",
"'defserver'",
"]",
";",
"}",
"}",
"}",
"$",
"out",
"[",
"]",
"=",
"$",
"ob",
"->",
"writeAddress",
"(",
"array",
"(",
"'encode'",
"=>",
"empty",
"(",
"$",
"opts",
"[",
"'charset'",
"]",
")",
"?",
"null",
":",
"$",
"opts",
"[",
"'charset'",
"]",
",",
"'idn'",
"=>",
"true",
")",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Do send encoding for addresses.
Needed as a static function because it is used by both single and
multiple address headers.
@todo Implement with traits.
@param array $alist An array of Horde_Mail_Rfc822_List objects.
@param array $opts Additional options:
- charset: (string) Encodes the headers using this charset.
DEFAULT: UTF-8
- defserver: (string) The default domain to append to mailboxes.
DEFAULT: No default name. | [
"Do",
"send",
"encoding",
"for",
"addresses",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mime/Headers/Addresses.php#L152-L172 |
213,578 | moodle/moodle | lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php | ZipHelper.createOrGetZip | protected function createOrGetZip()
{
if (!isset($this->zip)) {
$this->zip = new \ZipArchive();
$zipFilePath = $this->getZipFilePath();
$this->zip->open($zipFilePath, \ZipArchive::CREATE|\ZipArchive::OVERWRITE);
}
return $this->zip;
} | php | protected function createOrGetZip()
{
if (!isset($this->zip)) {
$this->zip = new \ZipArchive();
$zipFilePath = $this->getZipFilePath();
$this->zip->open($zipFilePath, \ZipArchive::CREATE|\ZipArchive::OVERWRITE);
}
return $this->zip;
} | [
"protected",
"function",
"createOrGetZip",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"zip",
")",
")",
"{",
"$",
"this",
"->",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"zipFilePath",
"=",
"$",
"this",
"->",
"getZipFilePath",
"(",
")",
";",
"$",
"this",
"->",
"zip",
"->",
"open",
"(",
"$",
"zipFilePath",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
"|",
"\\",
"ZipArchive",
"::",
"OVERWRITE",
")",
";",
"}",
"return",
"$",
"this",
"->",
"zip",
";",
"}"
] | Returns the already created ZipArchive instance or
creates one if none exists.
@return \ZipArchive | [
"Returns",
"the",
"already",
"created",
"ZipArchive",
"instance",
"or",
"creates",
"one",
"if",
"none",
"exists",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php#L39-L49 |
213,579 | moodle/moodle | lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php | ZipHelper.addFileToArchive | public function addFileToArchive($rootFolderPath, $localFilePath, $existingFileMode = self::EXISTING_FILES_OVERWRITE)
{
$this->addFileToArchiveWithCompressionMethod(
$rootFolderPath,
$localFilePath,
$existingFileMode,
\ZipArchive::CM_DEFAULT
);
} | php | public function addFileToArchive($rootFolderPath, $localFilePath, $existingFileMode = self::EXISTING_FILES_OVERWRITE)
{
$this->addFileToArchiveWithCompressionMethod(
$rootFolderPath,
$localFilePath,
$existingFileMode,
\ZipArchive::CM_DEFAULT
);
} | [
"public",
"function",
"addFileToArchive",
"(",
"$",
"rootFolderPath",
",",
"$",
"localFilePath",
",",
"$",
"existingFileMode",
"=",
"self",
"::",
"EXISTING_FILES_OVERWRITE",
")",
"{",
"$",
"this",
"->",
"addFileToArchiveWithCompressionMethod",
"(",
"$",
"rootFolderPath",
",",
"$",
"localFilePath",
",",
"$",
"existingFileMode",
",",
"\\",
"ZipArchive",
"::",
"CM_DEFAULT",
")",
";",
"}"
] | Adds the given file, located under the given root folder to the archive.
The file will be compressed.
Example of use:
addFileToArchive('/tmp/xlsx/foo', 'bar/baz.xml');
=> will add the file located at '/tmp/xlsx/foo/bar/baz.xml' in the archive, but only as 'bar/baz.xml'
@param string $rootFolderPath Path of the root folder that will be ignored in the archive tree.
@param string $localFilePath Path of the file to be added, under the root folder
@param string|void $existingFileMode Controls what to do when trying to add an existing file
@return void | [
"Adds",
"the",
"given",
"file",
"located",
"under",
"the",
"given",
"root",
"folder",
"to",
"the",
"archive",
".",
"The",
"file",
"will",
"be",
"compressed",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php#L72-L80 |
213,580 | moodle/moodle | lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php | ZipHelper.closeArchiveAndCopyToStream | public function closeArchiveAndCopyToStream($streamPointer)
{
$zip = $this->createOrGetZip();
$zip->close();
unset($this->zip);
$this->copyZipToStream($streamPointer);
} | php | public function closeArchiveAndCopyToStream($streamPointer)
{
$zip = $this->createOrGetZip();
$zip->close();
unset($this->zip);
$this->copyZipToStream($streamPointer);
} | [
"public",
"function",
"closeArchiveAndCopyToStream",
"(",
"$",
"streamPointer",
")",
"{",
"$",
"zip",
"=",
"$",
"this",
"->",
"createOrGetZip",
"(",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"zip",
")",
";",
"$",
"this",
"->",
"copyZipToStream",
"(",
"$",
"streamPointer",
")",
";",
"}"
] | Closes the archive and copies it into the given stream
@param resource $streamPointer Pointer to the stream to copy the zip
@return void | [
"Closes",
"the",
"archive",
"and",
"copies",
"it",
"into",
"the",
"given",
"stream"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php#L196-L203 |
213,581 | moodle/moodle | lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php | ZipHelper.copyZipToStream | protected function copyZipToStream($pointer)
{
$zipFilePointer = fopen($this->getZipFilePath(), 'r');
stream_copy_to_stream($zipFilePointer, $pointer);
fclose($zipFilePointer);
} | php | protected function copyZipToStream($pointer)
{
$zipFilePointer = fopen($this->getZipFilePath(), 'r');
stream_copy_to_stream($zipFilePointer, $pointer);
fclose($zipFilePointer);
} | [
"protected",
"function",
"copyZipToStream",
"(",
"$",
"pointer",
")",
"{",
"$",
"zipFilePointer",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getZipFilePath",
"(",
")",
",",
"'r'",
")",
";",
"stream_copy_to_stream",
"(",
"$",
"zipFilePointer",
",",
"$",
"pointer",
")",
";",
"fclose",
"(",
"$",
"zipFilePointer",
")",
";",
"}"
] | Streams the contents of the zip file into the given stream
@param resource $pointer Pointer to the stream to copy the zip
@return void | [
"Streams",
"the",
"contents",
"of",
"the",
"zip",
"file",
"into",
"the",
"given",
"stream"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Common/Helper/ZipHelper.php#L211-L216 |
213,582 | moodle/moodle | enrol/meta/lib.php | enrol_meta_plugin.get_course_options | protected function get_course_options($instance, $coursecontext) {
global $DB;
if ($instance->id) {
$where = 'WHERE c.id = :courseid';
$params = array('courseid' => $instance->customint1);
$existing = array();
} else {
$where = '';
$params = array();
$instanceparams = array('enrol' => 'meta', 'courseid' => $instance->courseid);
$existing = $DB->get_records('enrol', $instanceparams, '', 'customint1, id');
}
// TODO: this has to be done via ajax or else it will fail very badly on large sites!
$courses = array();
$select = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
$sortorder = 'c.' . $this->get_config('coursesort', 'sortorder') . ' ASC';
$sql = "SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join $where ORDER BY $sortorder";
$rs = $DB->get_recordset_sql($sql, array('contextlevel' => CONTEXT_COURSE) + $params);
foreach ($rs as $c) {
if ($c->id == SITEID or $c->id == $instance->courseid or isset($existing[$c->id])) {
continue;
}
context_helper::preload_from_record($c);
$coursecontext = context_course::instance($c->id);
if (!$c->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
continue;
}
if (!has_capability('enrol/meta:selectaslinked', $coursecontext)) {
continue;
}
$courses[$c->id] = $coursecontext->get_context_name(false);
}
$rs->close();
return $courses;
} | php | protected function get_course_options($instance, $coursecontext) {
global $DB;
if ($instance->id) {
$where = 'WHERE c.id = :courseid';
$params = array('courseid' => $instance->customint1);
$existing = array();
} else {
$where = '';
$params = array();
$instanceparams = array('enrol' => 'meta', 'courseid' => $instance->courseid);
$existing = $DB->get_records('enrol', $instanceparams, '', 'customint1, id');
}
// TODO: this has to be done via ajax or else it will fail very badly on large sites!
$courses = array();
$select = ', ' . context_helper::get_preload_record_columns_sql('ctx');
$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
$sortorder = 'c.' . $this->get_config('coursesort', 'sortorder') . ' ASC';
$sql = "SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join $where ORDER BY $sortorder";
$rs = $DB->get_recordset_sql($sql, array('contextlevel' => CONTEXT_COURSE) + $params);
foreach ($rs as $c) {
if ($c->id == SITEID or $c->id == $instance->courseid or isset($existing[$c->id])) {
continue;
}
context_helper::preload_from_record($c);
$coursecontext = context_course::instance($c->id);
if (!$c->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
continue;
}
if (!has_capability('enrol/meta:selectaslinked', $coursecontext)) {
continue;
}
$courses[$c->id] = $coursecontext->get_context_name(false);
}
$rs->close();
return $courses;
} | [
"protected",
"function",
"get_course_options",
"(",
"$",
"instance",
",",
"$",
"coursecontext",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"instance",
"->",
"id",
")",
"{",
"$",
"where",
"=",
"'WHERE c.id = :courseid'",
";",
"$",
"params",
"=",
"array",
"(",
"'courseid'",
"=>",
"$",
"instance",
"->",
"customint1",
")",
";",
"$",
"existing",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"where",
"=",
"''",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"instanceparams",
"=",
"array",
"(",
"'enrol'",
"=>",
"'meta'",
",",
"'courseid'",
"=>",
"$",
"instance",
"->",
"courseid",
")",
";",
"$",
"existing",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'enrol'",
",",
"$",
"instanceparams",
",",
"''",
",",
"'customint1, id'",
")",
";",
"}",
"// TODO: this has to be done via ajax or else it will fail very badly on large sites!",
"$",
"courses",
"=",
"array",
"(",
")",
";",
"$",
"select",
"=",
"', '",
".",
"context_helper",
"::",
"get_preload_record_columns_sql",
"(",
"'ctx'",
")",
";",
"$",
"join",
"=",
"\"LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)\"",
";",
"$",
"sortorder",
"=",
"'c.'",
".",
"$",
"this",
"->",
"get_config",
"(",
"'coursesort'",
",",
"'sortorder'",
")",
".",
"' ASC'",
";",
"$",
"sql",
"=",
"\"SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join $where ORDER BY $sortorder\"",
";",
"$",
"rs",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"$",
"sql",
",",
"array",
"(",
"'contextlevel'",
"=>",
"CONTEXT_COURSE",
")",
"+",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"rs",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"c",
"->",
"id",
"==",
"SITEID",
"or",
"$",
"c",
"->",
"id",
"==",
"$",
"instance",
"->",
"courseid",
"or",
"isset",
"(",
"$",
"existing",
"[",
"$",
"c",
"->",
"id",
"]",
")",
")",
"{",
"continue",
";",
"}",
"context_helper",
"::",
"preload_from_record",
"(",
"$",
"c",
")",
";",
"$",
"coursecontext",
"=",
"context_course",
"::",
"instance",
"(",
"$",
"c",
"->",
"id",
")",
";",
"if",
"(",
"!",
"$",
"c",
"->",
"visible",
"and",
"!",
"has_capability",
"(",
"'moodle/course:viewhiddencourses'",
",",
"$",
"coursecontext",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"has_capability",
"(",
"'enrol/meta:selectaslinked'",
",",
"$",
"coursecontext",
")",
")",
"{",
"continue",
";",
"}",
"$",
"courses",
"[",
"$",
"c",
"->",
"id",
"]",
"=",
"$",
"coursecontext",
"->",
"get_context_name",
"(",
"false",
")",
";",
"}",
"$",
"rs",
"->",
"close",
"(",
")",
";",
"return",
"$",
"courses",
";",
"}"
] | Return an array of valid options for the courses.
@param stdClass $instance
@param context $coursecontext
@return array | [
"Return",
"an",
"array",
"of",
"valid",
"options",
"for",
"the",
"courses",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/enrol/meta/lib.php#L224-L263 |
213,583 | moodle/moodle | admin/tool/dataprivacy/classes/external/data_request_exporter.php | data_request_exporter.define_other_properties | protected static function define_other_properties() {
return [
'foruser' => [
'type' => user_summary_exporter::read_properties_definition(),
],
'requestedbyuser' => [
'type' => user_summary_exporter::read_properties_definition(),
'optional' => true
],
'dpouser' => [
'type' => user_summary_exporter::read_properties_definition(),
'optional' => true
],
'messagehtml' => [
'type' => PARAM_RAW,
'optional' => true
],
'typename' => [
'type' => PARAM_TEXT,
],
'typenameshort' => [
'type' => PARAM_TEXT,
],
'statuslabel' => [
'type' => PARAM_TEXT,
],
'statuslabelclass' => [
'type' => PARAM_TEXT,
],
'canreview' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
'approvedeny' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
'canmarkcomplete' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
];
} | php | protected static function define_other_properties() {
return [
'foruser' => [
'type' => user_summary_exporter::read_properties_definition(),
],
'requestedbyuser' => [
'type' => user_summary_exporter::read_properties_definition(),
'optional' => true
],
'dpouser' => [
'type' => user_summary_exporter::read_properties_definition(),
'optional' => true
],
'messagehtml' => [
'type' => PARAM_RAW,
'optional' => true
],
'typename' => [
'type' => PARAM_TEXT,
],
'typenameshort' => [
'type' => PARAM_TEXT,
],
'statuslabel' => [
'type' => PARAM_TEXT,
],
'statuslabelclass' => [
'type' => PARAM_TEXT,
],
'canreview' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
'approvedeny' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
'canmarkcomplete' => [
'type' => PARAM_BOOL,
'optional' => true,
'default' => false
],
];
} | [
"protected",
"static",
"function",
"define_other_properties",
"(",
")",
"{",
"return",
"[",
"'foruser'",
"=>",
"[",
"'type'",
"=>",
"user_summary_exporter",
"::",
"read_properties_definition",
"(",
")",
",",
"]",
",",
"'requestedbyuser'",
"=>",
"[",
"'type'",
"=>",
"user_summary_exporter",
"::",
"read_properties_definition",
"(",
")",
",",
"'optional'",
"=>",
"true",
"]",
",",
"'dpouser'",
"=>",
"[",
"'type'",
"=>",
"user_summary_exporter",
"::",
"read_properties_definition",
"(",
")",
",",
"'optional'",
"=>",
"true",
"]",
",",
"'messagehtml'",
"=>",
"[",
"'type'",
"=>",
"PARAM_RAW",
",",
"'optional'",
"=>",
"true",
"]",
",",
"'typename'",
"=>",
"[",
"'type'",
"=>",
"PARAM_TEXT",
",",
"]",
",",
"'typenameshort'",
"=>",
"[",
"'type'",
"=>",
"PARAM_TEXT",
",",
"]",
",",
"'statuslabel'",
"=>",
"[",
"'type'",
"=>",
"PARAM_TEXT",
",",
"]",
",",
"'statuslabelclass'",
"=>",
"[",
"'type'",
"=>",
"PARAM_TEXT",
",",
"]",
",",
"'canreview'",
"=>",
"[",
"'type'",
"=>",
"PARAM_BOOL",
",",
"'optional'",
"=>",
"true",
",",
"'default'",
"=>",
"false",
"]",
",",
"'approvedeny'",
"=>",
"[",
"'type'",
"=>",
"PARAM_BOOL",
",",
"'optional'",
"=>",
"true",
",",
"'default'",
"=>",
"false",
"]",
",",
"'canmarkcomplete'",
"=>",
"[",
"'type'",
"=>",
"PARAM_BOOL",
",",
"'optional'",
"=>",
"true",
",",
"'default'",
"=>",
"false",
"]",
",",
"]",
";",
"}"
] | Other properties definition.
@return array | [
"Other",
"properties",
"definition",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/external/data_request_exporter.php#L71-L116 |
213,584 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setAxisOptionsProperties | public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
{
$this->axisOptions['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
($horizontal_crosses !== null) ? $this->axisOptions['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== null) ? $this->axisOptions['orientation'] = (string) $axis_orientation : null;
($major_tmt !== null) ? $this->axisOptions['major_tick_mark'] = (string) $major_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minimum !== null) ? $this->axisOptions['minimum'] = (string) $minimum : null;
($maximum !== null) ? $this->axisOptions['maximum'] = (string) $maximum : null;
($major_unit !== null) ? $this->axisOptions['major_unit'] = (string) $major_unit : null;
($minor_unit !== null) ? $this->axisOptions['minor_unit'] = (string) $minor_unit : null;
} | php | public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
{
$this->axisOptions['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
($horizontal_crosses !== null) ? $this->axisOptions['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== null) ? $this->axisOptions['orientation'] = (string) $axis_orientation : null;
($major_tmt !== null) ? $this->axisOptions['major_tick_mark'] = (string) $major_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minor_tmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minor_tmt : null;
($minimum !== null) ? $this->axisOptions['minimum'] = (string) $minimum : null;
($maximum !== null) ? $this->axisOptions['maximum'] = (string) $maximum : null;
($major_unit !== null) ? $this->axisOptions['major_unit'] = (string) $major_unit : null;
($minor_unit !== null) ? $this->axisOptions['minor_unit'] = (string) $minor_unit : null;
} | [
"public",
"function",
"setAxisOptionsProperties",
"(",
"$",
"axis_labels",
",",
"$",
"horizontal_crosses_value",
"=",
"null",
",",
"$",
"horizontal_crosses",
"=",
"null",
",",
"$",
"axis_orientation",
"=",
"null",
",",
"$",
"major_tmt",
"=",
"null",
",",
"$",
"minor_tmt",
"=",
"null",
",",
"$",
"minimum",
"=",
"null",
",",
"$",
"maximum",
"=",
"null",
",",
"$",
"major_unit",
"=",
"null",
",",
"$",
"minor_unit",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"axisOptions",
"[",
"'axis_labels'",
"]",
"=",
"(",
"string",
")",
"$",
"axis_labels",
";",
"(",
"$",
"horizontal_crosses_value",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'horizontal_crosses_value'",
"]",
"=",
"(",
"string",
")",
"$",
"horizontal_crosses_value",
":",
"null",
";",
"(",
"$",
"horizontal_crosses",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'horizontal_crosses'",
"]",
"=",
"(",
"string",
")",
"$",
"horizontal_crosses",
":",
"null",
";",
"(",
"$",
"axis_orientation",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'orientation'",
"]",
"=",
"(",
"string",
")",
"$",
"axis_orientation",
":",
"null",
";",
"(",
"$",
"major_tmt",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'major_tick_mark'",
"]",
"=",
"(",
"string",
")",
"$",
"major_tmt",
":",
"null",
";",
"(",
"$",
"minor_tmt",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'minor_tick_mark'",
"]",
"=",
"(",
"string",
")",
"$",
"minor_tmt",
":",
"null",
";",
"(",
"$",
"minor_tmt",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'minor_tick_mark'",
"]",
"=",
"(",
"string",
")",
"$",
"minor_tmt",
":",
"null",
";",
"(",
"$",
"minimum",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'minimum'",
"]",
"=",
"(",
"string",
")",
"$",
"minimum",
":",
"null",
";",
"(",
"$",
"maximum",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'maximum'",
"]",
"=",
"(",
"string",
")",
"$",
"maximum",
":",
"null",
";",
"(",
"$",
"major_unit",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'major_unit'",
"]",
"=",
"(",
"string",
")",
"$",
"major_unit",
":",
"null",
";",
"(",
"$",
"minor_unit",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"axisOptions",
"[",
"'minor_unit'",
"]",
"=",
"(",
"string",
")",
"$",
"minor_unit",
":",
"null",
";",
"}"
] | Set Axis Options Properties
@param string $axis_labels
@param string $horizontal_crosses_value
@param string $horizontal_crosses
@param string $axis_orientation
@param string $major_tmt
@param string $minor_tmt
@param string $minimum
@param string $maximum
@param string $major_unit
@param string $minor_unit | [
"Set",
"Axis",
"Options",
"Properties"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L179-L192 |
213,585 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setFillParameters | public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->fillProperties = $this->setColorProperties($color, $alpha, $type);
} | php | public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->fillProperties = $this->setColorProperties($color, $alpha, $type);
} | [
"public",
"function",
"setFillParameters",
"(",
"$",
"color",
",",
"$",
"alpha",
"=",
"0",
",",
"$",
"type",
"=",
"self",
"::",
"EXCEL_COLOR_TYPE_ARGB",
")",
"{",
"$",
"this",
"->",
"fillProperties",
"=",
"$",
"this",
"->",
"setColorProperties",
"(",
"$",
"color",
",",
"$",
"alpha",
",",
"$",
"type",
")",
";",
"}"
] | Set Fill Property
@param string $color
@param int $alpha
@param string $type | [
"Set",
"Fill",
"Property"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L225-L228 |
213,586 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setLineParameters | public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->lineProperties = $this->setColorProperties($color, $alpha, $type);
} | php | public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB)
{
$this->lineProperties = $this->setColorProperties($color, $alpha, $type);
} | [
"public",
"function",
"setLineParameters",
"(",
"$",
"color",
",",
"$",
"alpha",
"=",
"0",
",",
"$",
"type",
"=",
"self",
"::",
"EXCEL_COLOR_TYPE_ARGB",
")",
"{",
"$",
"this",
"->",
"lineProperties",
"=",
"$",
"this",
"->",
"setColorProperties",
"(",
"$",
"color",
",",
"$",
"alpha",
",",
"$",
"type",
")",
";",
"}"
] | Set Line Property
@param string $color
@param int $alpha
@param string $type | [
"Set",
"Line",
"Property"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L238-L241 |
213,587 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setShadowProperiesMapValues | private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
{
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
} | php | private function setShadowProperiesMapValues(array $properties_map, &$reference = null)
{
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->shadowProperties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === null) {
$this->shadowProperties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
} | [
"private",
"function",
"setShadowProperiesMapValues",
"(",
"array",
"$",
"properties_map",
",",
"&",
"$",
"reference",
"=",
"null",
")",
"{",
"$",
"base_reference",
"=",
"$",
"reference",
";",
"foreach",
"(",
"$",
"properties_map",
"as",
"$",
"property_key",
"=>",
"$",
"property_val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"property_val",
")",
")",
"{",
"if",
"(",
"$",
"reference",
"===",
"null",
")",
"{",
"$",
"reference",
"=",
"&",
"$",
"this",
"->",
"shadowProperties",
"[",
"$",
"property_key",
"]",
";",
"}",
"else",
"{",
"$",
"reference",
"=",
"&",
"$",
"reference",
"[",
"$",
"property_key",
"]",
";",
"}",
"$",
"this",
"->",
"setShadowProperiesMapValues",
"(",
"$",
"property_val",
",",
"$",
"reference",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"base_reference",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"shadowProperties",
"[",
"$",
"property_key",
"]",
"=",
"$",
"property_val",
";",
"}",
"else",
"{",
"$",
"reference",
"[",
"$",
"property_key",
"]",
"=",
"$",
"property_val",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Shadow Properties from Maped Values
@param array $properties_map
@param * $reference
@return PHPExcel_Chart_Axis | [
"Set",
"Shadow",
"Properties",
"from",
"Maped",
"Values"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L378-L399 |
213,588 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setShadowBlur | private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
} | php | private function setShadowBlur($blur)
{
if ($blur !== null) {
$this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
} | [
"private",
"function",
"setShadowBlur",
"(",
"$",
"blur",
")",
"{",
"if",
"(",
"$",
"blur",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"shadowProperties",
"[",
"'blur'",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getExcelPointsWidth",
"(",
"$",
"blur",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Shadow Blur
@param float $blur
@return PHPExcel_Chart_Axis | [
"Set",
"Shadow",
"Blur"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L424-L431 |
213,589 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setShadowAngle | private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
} | php | private function setShadowAngle($angle)
{
if ($angle !== null) {
$this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
} | [
"private",
"function",
"setShadowAngle",
"(",
"$",
"angle",
")",
"{",
"if",
"(",
"$",
"angle",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"shadowProperties",
"[",
"'direction'",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getExcelPointsAngle",
"(",
"$",
"angle",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Shadow Angle
@param int $angle
@return PHPExcel_Chart_Axis | [
"Set",
"Shadow",
"Angle"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L440-L447 |
213,590 | moodle/moodle | lib/phpexcel/PHPExcel/Chart/Axis.php | PHPExcel_Chart_Axis.setShadowDistance | private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
} | php | private function setShadowDistance($distance)
{
if ($distance !== null) {
$this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
} | [
"private",
"function",
"setShadowDistance",
"(",
"$",
"distance",
")",
"{",
"if",
"(",
"$",
"distance",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"shadowProperties",
"[",
"'distance'",
"]",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getExcelPointsWidth",
"(",
"$",
"distance",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Shadow Distance
@param float $distance
@return PHPExcel_Chart_Axis | [
"Set",
"Shadow",
"Distance"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Chart/Axis.php#L456-L463 |
213,591 | moodle/moodle | analytics/classes/local/analysis/result_file.php | result_file.add_analysable_results | public function add_analysable_results(array $results): bool {
$any = false;
// Process all provided time splitting methods.
foreach ($results as $timesplittingid => $result) {
if (!empty($result->result)) {
$this->filesbytimesplitting[$timesplittingid][] = $result->result;
$any = true;
}
}
if (empty($any)) {
return false;
}
return true;
} | php | public function add_analysable_results(array $results): bool {
$any = false;
// Process all provided time splitting methods.
foreach ($results as $timesplittingid => $result) {
if (!empty($result->result)) {
$this->filesbytimesplitting[$timesplittingid][] = $result->result;
$any = true;
}
}
if (empty($any)) {
return false;
}
return true;
} | [
"public",
"function",
"add_analysable_results",
"(",
"array",
"$",
"results",
")",
":",
"bool",
"{",
"$",
"any",
"=",
"false",
";",
"// Process all provided time splitting methods.",
"foreach",
"(",
"$",
"results",
"as",
"$",
"timesplittingid",
"=>",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
"->",
"result",
")",
")",
"{",
"$",
"this",
"->",
"filesbytimesplitting",
"[",
"$",
"timesplittingid",
"]",
"[",
"]",
"=",
"$",
"result",
"->",
"result",
";",
"$",
"any",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"any",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Stores the analysis results.
@param array $results
@return bool True if anything was successfully analysed | [
"Stores",
"the",
"analysis",
"results",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/local/analysis/result_file.php#L49-L65 |
213,592 | moodle/moodle | analytics/classes/local/analysis/result_file.php | result_file.add_model_metadata | private function add_model_metadata(array &$data, \core_analytics\local\time_splitting\base $timesplitting,
\core_analytics\local\target\base $target) {
global $CFG;
// If no target the first column is the sampleid, if target the last column is the target.
// This will need to be updated when we support unsupervised learning models.
$metadata = array(
'timesplitting' => $timesplitting->get_id(),
'nfeatures' => count(current($data)) - 1,
'moodleversion' => $CFG->version,
'targetcolumn' => $target->get_id()
);
if ($target->is_linear()) {
$metadata['targettype'] = 'linear';
$metadata['targetmin'] = $target::get_min_value();
$metadata['targetmax'] = $target::get_max_value();
} else {
$metadata['targettype'] = 'discrete';
$metadata['targetclasses'] = json_encode($target::get_classes());
}
// The first 2 samples will be used to store metadata about the dataset.
$metadatacolumns = [];
$metadatavalues = [];
foreach ($metadata as $key => $value) {
$metadatacolumns[] = $key;
$metadatavalues[] = $value;
}
// This will also reset samples' dataset keys.
array_unshift($data, $metadatacolumns, $metadatavalues);
} | php | private function add_model_metadata(array &$data, \core_analytics\local\time_splitting\base $timesplitting,
\core_analytics\local\target\base $target) {
global $CFG;
// If no target the first column is the sampleid, if target the last column is the target.
// This will need to be updated when we support unsupervised learning models.
$metadata = array(
'timesplitting' => $timesplitting->get_id(),
'nfeatures' => count(current($data)) - 1,
'moodleversion' => $CFG->version,
'targetcolumn' => $target->get_id()
);
if ($target->is_linear()) {
$metadata['targettype'] = 'linear';
$metadata['targetmin'] = $target::get_min_value();
$metadata['targetmax'] = $target::get_max_value();
} else {
$metadata['targettype'] = 'discrete';
$metadata['targetclasses'] = json_encode($target::get_classes());
}
// The first 2 samples will be used to store metadata about the dataset.
$metadatacolumns = [];
$metadatavalues = [];
foreach ($metadata as $key => $value) {
$metadatacolumns[] = $key;
$metadatavalues[] = $value;
}
// This will also reset samples' dataset keys.
array_unshift($data, $metadatacolumns, $metadatavalues);
} | [
"private",
"function",
"add_model_metadata",
"(",
"array",
"&",
"$",
"data",
",",
"\\",
"core_analytics",
"\\",
"local",
"\\",
"time_splitting",
"\\",
"base",
"$",
"timesplitting",
",",
"\\",
"core_analytics",
"\\",
"local",
"\\",
"target",
"\\",
"base",
"$",
"target",
")",
"{",
"global",
"$",
"CFG",
";",
"// If no target the first column is the sampleid, if target the last column is the target.",
"// This will need to be updated when we support unsupervised learning models.",
"$",
"metadata",
"=",
"array",
"(",
"'timesplitting'",
"=>",
"$",
"timesplitting",
"->",
"get_id",
"(",
")",
",",
"'nfeatures'",
"=>",
"count",
"(",
"current",
"(",
"$",
"data",
")",
")",
"-",
"1",
",",
"'moodleversion'",
"=>",
"$",
"CFG",
"->",
"version",
",",
"'targetcolumn'",
"=>",
"$",
"target",
"->",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"$",
"target",
"->",
"is_linear",
"(",
")",
")",
"{",
"$",
"metadata",
"[",
"'targettype'",
"]",
"=",
"'linear'",
";",
"$",
"metadata",
"[",
"'targetmin'",
"]",
"=",
"$",
"target",
"::",
"get_min_value",
"(",
")",
";",
"$",
"metadata",
"[",
"'targetmax'",
"]",
"=",
"$",
"target",
"::",
"get_max_value",
"(",
")",
";",
"}",
"else",
"{",
"$",
"metadata",
"[",
"'targettype'",
"]",
"=",
"'discrete'",
";",
"$",
"metadata",
"[",
"'targetclasses'",
"]",
"=",
"json_encode",
"(",
"$",
"target",
"::",
"get_classes",
"(",
")",
")",
";",
"}",
"// The first 2 samples will be used to store metadata about the dataset.",
"$",
"metadatacolumns",
"=",
"[",
"]",
";",
"$",
"metadatavalues",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"metadata",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"metadatacolumns",
"[",
"]",
"=",
"$",
"key",
";",
"$",
"metadatavalues",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"// This will also reset samples' dataset keys.",
"array_unshift",
"(",
"$",
"data",
",",
"$",
"metadatacolumns",
",",
"$",
"metadatavalues",
")",
";",
"}"
] | Adds target metadata to the dataset.
The final dataset document will look like this:
----------------------------------------------------
metadata1,metadata2,metadata3,.....
value1, value2, value3,.....
header1,header2,header3,header4,.....
stud1value1,stud1value2,stud1value3,stud1value4,.....
stud2value1,stud2value2,stud2value3,stud2value4,.....
.....
----------------------------------------------------
@param array $data
@param \core_analytics\local\time_splitting\base $timesplitting
@param \core_analytics\local\target\base $target
@return null | [
"Adds",
"target",
"metadata",
"to",
"the",
"dataset",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/local/analysis/result_file.php#L196-L227 |
213,593 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Data/BaseSubject.php | Horde_Imap_Client_Data_BaseSubject._removeSubjLeader | protected function _removeSubjLeader(&$str, $keepblob = false)
{
$ret = false;
if (!strlen($str)) {
return $ret;
}
if ($len = strspn($str, " \t")) {
$str = substr($str, $len);
$ret = true;
}
$i = 0;
if (!$keepblob) {
while (isset($str[$i]) && ($str[$i] === '[')) {
if (($i = $this->_removeBlob($str, $i)) === false) {
return $ret;
}
}
}
if (stripos($str, 're', $i) === 0) {
$i += 2;
} elseif (stripos($str, 'fw', $i) === 0) {
$i += (stripos($str, 'fwd', $i) === 0) ? 3 : 2;
} else {
return $ret;
}
$i += strspn($str, " \t", $i);
if (!$keepblob) {
while (isset($str[$i]) && ($str[$i] === '[')) {
if (($i = $this->_removeBlob($str, $i)) === false) {
return $ret;
}
}
}
if (!isset($str[$i]) || ($str[$i] !== ':')) {
return $ret;
}
$str = substr($str, ++$i);
return true;
} | php | protected function _removeSubjLeader(&$str, $keepblob = false)
{
$ret = false;
if (!strlen($str)) {
return $ret;
}
if ($len = strspn($str, " \t")) {
$str = substr($str, $len);
$ret = true;
}
$i = 0;
if (!$keepblob) {
while (isset($str[$i]) && ($str[$i] === '[')) {
if (($i = $this->_removeBlob($str, $i)) === false) {
return $ret;
}
}
}
if (stripos($str, 're', $i) === 0) {
$i += 2;
} elseif (stripos($str, 'fw', $i) === 0) {
$i += (stripos($str, 'fwd', $i) === 0) ? 3 : 2;
} else {
return $ret;
}
$i += strspn($str, " \t", $i);
if (!$keepblob) {
while (isset($str[$i]) && ($str[$i] === '[')) {
if (($i = $this->_removeBlob($str, $i)) === false) {
return $ret;
}
}
}
if (!isset($str[$i]) || ($str[$i] !== ':')) {
return $ret;
}
$str = substr($str, ++$i);
return true;
} | [
"protected",
"function",
"_removeSubjLeader",
"(",
"&",
"$",
"str",
",",
"$",
"keepblob",
"=",
"false",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"str",
")",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"if",
"(",
"$",
"len",
"=",
"strspn",
"(",
"$",
"str",
",",
"\" \\t\"",
")",
")",
"{",
"$",
"str",
"=",
"substr",
"(",
"$",
"str",
",",
"$",
"len",
")",
";",
"$",
"ret",
"=",
"true",
";",
"}",
"$",
"i",
"=",
"0",
";",
"if",
"(",
"!",
"$",
"keepblob",
")",
"{",
"while",
"(",
"isset",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
")",
"&&",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
"===",
"'['",
")",
")",
"{",
"if",
"(",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"_removeBlob",
"(",
"$",
"str",
",",
"$",
"i",
")",
")",
"===",
"false",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"}",
"}",
"if",
"(",
"stripos",
"(",
"$",
"str",
",",
"'re'",
",",
"$",
"i",
")",
"===",
"0",
")",
"{",
"$",
"i",
"+=",
"2",
";",
"}",
"elseif",
"(",
"stripos",
"(",
"$",
"str",
",",
"'fw'",
",",
"$",
"i",
")",
"===",
"0",
")",
"{",
"$",
"i",
"+=",
"(",
"stripos",
"(",
"$",
"str",
",",
"'fwd'",
",",
"$",
"i",
")",
"===",
"0",
")",
"?",
"3",
":",
"2",
";",
"}",
"else",
"{",
"return",
"$",
"ret",
";",
"}",
"$",
"i",
"+=",
"strspn",
"(",
"$",
"str",
",",
"\" \\t\"",
",",
"$",
"i",
")",
";",
"if",
"(",
"!",
"$",
"keepblob",
")",
"{",
"while",
"(",
"isset",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
")",
"&&",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
"===",
"'['",
")",
")",
"{",
"if",
"(",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"_removeBlob",
"(",
"$",
"str",
",",
"$",
"i",
")",
")",
"===",
"false",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
")",
"||",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
"!==",
"':'",
")",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"$",
"str",
"=",
"substr",
"(",
"$",
"str",
",",
"++",
"$",
"i",
")",
";",
"return",
"true",
";",
"}"
] | Remove all prefix text of the subject that matches the subj-leader
ABNF.
@param string &$str The subject string.
@param boolean $keepblob Remove blob information?
@return boolean True if string was altered. | [
"Remove",
"all",
"prefix",
"text",
"of",
"the",
"subject",
"that",
"matches",
"the",
"subj",
"-",
"leader",
"ABNF",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/BaseSubject.php#L103-L151 |
213,594 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.get_comments | public static function get_comments($gradeid, $pageno, $draft) {
global $DB;
$comments = array();
$params = array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1);
if (!$draft) {
$params['draft'] = 0;
}
// Fetch comments ordered by position on the page.
$records = $DB->get_records('assignfeedback_editpdf_cmnt', $params, 'y, x');
foreach ($records as $record) {
array_push($comments, new comment($record));
}
return $comments;
} | php | public static function get_comments($gradeid, $pageno, $draft) {
global $DB;
$comments = array();
$params = array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1);
if (!$draft) {
$params['draft'] = 0;
}
// Fetch comments ordered by position on the page.
$records = $DB->get_records('assignfeedback_editpdf_cmnt', $params, 'y, x');
foreach ($records as $record) {
array_push($comments, new comment($record));
}
return $comments;
} | [
"public",
"static",
"function",
"get_comments",
"(",
"$",
"gradeid",
",",
"$",
"pageno",
",",
"$",
"draft",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"comments",
"=",
"array",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'gradeid'",
"=>",
"$",
"gradeid",
",",
"'pageno'",
"=>",
"$",
"pageno",
",",
"'draft'",
"=>",
"1",
")",
";",
"if",
"(",
"!",
"$",
"draft",
")",
"{",
"$",
"params",
"[",
"'draft'",
"]",
"=",
"0",
";",
"}",
"// Fetch comments ordered by position on the page.",
"$",
"records",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'assignfeedback_editpdf_cmnt'",
",",
"$",
"params",
",",
"'y, x'",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"array_push",
"(",
"$",
"comments",
",",
"new",
"comment",
"(",
"$",
"record",
")",
")",
";",
"}",
"return",
"$",
"comments",
";",
"}"
] | Get all comments for a page.
@param int $gradeid
@param int $pageno
@param bool $draft
@return comment[] | [
"Get",
"all",
"comments",
"for",
"a",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L45-L60 |
213,595 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.set_comments | public static function set_comments($gradeid, $pageno, $comments) {
global $DB;
$DB->delete_records('assignfeedback_editpdf_cmnt', array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1));
$added = 0;
foreach ($comments as $record) {
// Force these.
if (!($record instanceof comment)) {
$comment = new comment($record);
} else {
$comment = $record;
}
if (trim($comment->rawtext) === '') {
continue;
}
$comment->gradeid = $gradeid;
$comment->pageno = $pageno;
$comment->draft = 1;
if (self::add_comment($comment)) {
$added++;
}
}
return $added;
} | php | public static function set_comments($gradeid, $pageno, $comments) {
global $DB;
$DB->delete_records('assignfeedback_editpdf_cmnt', array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1));
$added = 0;
foreach ($comments as $record) {
// Force these.
if (!($record instanceof comment)) {
$comment = new comment($record);
} else {
$comment = $record;
}
if (trim($comment->rawtext) === '') {
continue;
}
$comment->gradeid = $gradeid;
$comment->pageno = $pageno;
$comment->draft = 1;
if (self::add_comment($comment)) {
$added++;
}
}
return $added;
} | [
"public",
"static",
"function",
"set_comments",
"(",
"$",
"gradeid",
",",
"$",
"pageno",
",",
"$",
"comments",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"DB",
"->",
"delete_records",
"(",
"'assignfeedback_editpdf_cmnt'",
",",
"array",
"(",
"'gradeid'",
"=>",
"$",
"gradeid",
",",
"'pageno'",
"=>",
"$",
"pageno",
",",
"'draft'",
"=>",
"1",
")",
")",
";",
"$",
"added",
"=",
"0",
";",
"foreach",
"(",
"$",
"comments",
"as",
"$",
"record",
")",
"{",
"// Force these.",
"if",
"(",
"!",
"(",
"$",
"record",
"instanceof",
"comment",
")",
")",
"{",
"$",
"comment",
"=",
"new",
"comment",
"(",
"$",
"record",
")",
";",
"}",
"else",
"{",
"$",
"comment",
"=",
"$",
"record",
";",
"}",
"if",
"(",
"trim",
"(",
"$",
"comment",
"->",
"rawtext",
")",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"$",
"comment",
"->",
"gradeid",
"=",
"$",
"gradeid",
";",
"$",
"comment",
"->",
"pageno",
"=",
"$",
"pageno",
";",
"$",
"comment",
"->",
"draft",
"=",
"1",
";",
"if",
"(",
"self",
"::",
"add_comment",
"(",
"$",
"comment",
")",
")",
"{",
"$",
"added",
"++",
";",
"}",
"}",
"return",
"$",
"added",
";",
"}"
] | Set all comments for a page.
@param int $gradeid
@param int $pageno
@param comment[] $comments
@return int - the number of comments. | [
"Set",
"all",
"comments",
"for",
"a",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L69-L94 |
213,596 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.get_comment | public static function get_comment($commentid) {
$record = $DB->get_record('assignfeedback_editpdf_cmnt', array('id'=>$commentid), '*', IGNORE_MISSING);
if ($record) {
return new comment($record);
}
return false;
} | php | public static function get_comment($commentid) {
$record = $DB->get_record('assignfeedback_editpdf_cmnt', array('id'=>$commentid), '*', IGNORE_MISSING);
if ($record) {
return new comment($record);
}
return false;
} | [
"public",
"static",
"function",
"get_comment",
"(",
"$",
"commentid",
")",
"{",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assignfeedback_editpdf_cmnt'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"commentid",
")",
",",
"'*'",
",",
"IGNORE_MISSING",
")",
";",
"if",
"(",
"$",
"record",
")",
"{",
"return",
"new",
"comment",
"(",
"$",
"record",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Get a single comment by id.
@param int $commentid
@return comment or false | [
"Get",
"a",
"single",
"comment",
"by",
"id",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L101-L107 |
213,597 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.add_comment | public static function add_comment(comment $comment) {
global $DB;
$comment->id = null;
return $DB->insert_record('assignfeedback_editpdf_cmnt', $comment);
} | php | public static function add_comment(comment $comment) {
global $DB;
$comment->id = null;
return $DB->insert_record('assignfeedback_editpdf_cmnt', $comment);
} | [
"public",
"static",
"function",
"add_comment",
"(",
"comment",
"$",
"comment",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"comment",
"->",
"id",
"=",
"null",
";",
"return",
"$",
"DB",
"->",
"insert_record",
"(",
"'assignfeedback_editpdf_cmnt'",
",",
"$",
"comment",
")",
";",
"}"
] | Add a comment to a page.
@param comment $comment
@return bool | [
"Add",
"a",
"comment",
"to",
"a",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L114-L118 |
213,598 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.get_annotations | public static function get_annotations($gradeid, $pageno, $draft) {
global $DB;
$params = array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1);
if (!$draft) {
$params['draft'] = 0;
}
$annotations = array();
$records = $DB->get_records('assignfeedback_editpdf_annot', $params);
foreach ($records as $record) {
array_push($annotations, new annotation($record));
}
return $annotations;
} | php | public static function get_annotations($gradeid, $pageno, $draft) {
global $DB;
$params = array('gradeid'=>$gradeid, 'pageno'=>$pageno, 'draft'=>1);
if (!$draft) {
$params['draft'] = 0;
}
$annotations = array();
$records = $DB->get_records('assignfeedback_editpdf_annot', $params);
foreach ($records as $record) {
array_push($annotations, new annotation($record));
}
return $annotations;
} | [
"public",
"static",
"function",
"get_annotations",
"(",
"$",
"gradeid",
",",
"$",
"pageno",
",",
"$",
"draft",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"array",
"(",
"'gradeid'",
"=>",
"$",
"gradeid",
",",
"'pageno'",
"=>",
"$",
"pageno",
",",
"'draft'",
"=>",
"1",
")",
";",
"if",
"(",
"!",
"$",
"draft",
")",
"{",
"$",
"params",
"[",
"'draft'",
"]",
"=",
"0",
";",
"}",
"$",
"annotations",
"=",
"array",
"(",
")",
";",
"$",
"records",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'assignfeedback_editpdf_annot'",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"array_push",
"(",
"$",
"annotations",
",",
"new",
"annotation",
"(",
"$",
"record",
")",
")",
";",
"}",
"return",
"$",
"annotations",
";",
"}"
] | Get all annotations for a page.
@param int $gradeid
@param int $pageno
@param bool $draft
@return annotation[] | [
"Get",
"all",
"annotations",
"for",
"a",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L137-L151 |
213,599 | moodle/moodle | mod/assign/feedback/editpdf/classes/page_editor.php | page_editor.set_annotations | public static function set_annotations($gradeid, $pageno, $annotations) {
global $DB;
$DB->delete_records('assignfeedback_editpdf_annot', array('gradeid' => $gradeid, 'pageno' => $pageno, 'draft' => 1));
$added = 0;
foreach ($annotations as $record) {
// Force these.
if (!($record instanceof annotation)) {
$annotation = new annotation($record);
} else {
$annotation = $record;
}
$annotation->gradeid = $gradeid;
$annotation->pageno = $pageno;
$annotation->draft = 1;
if (self::add_annotation($annotation)) {
$added++;
}
}
return $added;
} | php | public static function set_annotations($gradeid, $pageno, $annotations) {
global $DB;
$DB->delete_records('assignfeedback_editpdf_annot', array('gradeid' => $gradeid, 'pageno' => $pageno, 'draft' => 1));
$added = 0;
foreach ($annotations as $record) {
// Force these.
if (!($record instanceof annotation)) {
$annotation = new annotation($record);
} else {
$annotation = $record;
}
$annotation->gradeid = $gradeid;
$annotation->pageno = $pageno;
$annotation->draft = 1;
if (self::add_annotation($annotation)) {
$added++;
}
}
return $added;
} | [
"public",
"static",
"function",
"set_annotations",
"(",
"$",
"gradeid",
",",
"$",
"pageno",
",",
"$",
"annotations",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"DB",
"->",
"delete_records",
"(",
"'assignfeedback_editpdf_annot'",
",",
"array",
"(",
"'gradeid'",
"=>",
"$",
"gradeid",
",",
"'pageno'",
"=>",
"$",
"pageno",
",",
"'draft'",
"=>",
"1",
")",
")",
";",
"$",
"added",
"=",
"0",
";",
"foreach",
"(",
"$",
"annotations",
"as",
"$",
"record",
")",
"{",
"// Force these.",
"if",
"(",
"!",
"(",
"$",
"record",
"instanceof",
"annotation",
")",
")",
"{",
"$",
"annotation",
"=",
"new",
"annotation",
"(",
"$",
"record",
")",
";",
"}",
"else",
"{",
"$",
"annotation",
"=",
"$",
"record",
";",
"}",
"$",
"annotation",
"->",
"gradeid",
"=",
"$",
"gradeid",
";",
"$",
"annotation",
"->",
"pageno",
"=",
"$",
"pageno",
";",
"$",
"annotation",
"->",
"draft",
"=",
"1",
";",
"if",
"(",
"self",
"::",
"add_annotation",
"(",
"$",
"annotation",
")",
")",
"{",
"$",
"added",
"++",
";",
"}",
"}",
"return",
"$",
"added",
";",
"}"
] | Set all annotations for a page.
@param int $gradeid
@param int $pageno
@param annotation[] $annotations
@return int - the number of annotations. | [
"Set",
"all",
"annotations",
"for",
"a",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/editpdf/classes/page_editor.php#L160-L181 |
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.