id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
212,100
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.startSheet
protected function startSheet() { $this->sheetFilePointer = fopen($this->worksheetFilePath, 'w'); $this->throwIfSheetFilePointerIsNotAvailable(); fwrite($this->sheetFilePointer, self::SHEET_XML_FILE_HEADER); fwrite($this->sheetFilePointer, '<sheetData>'); }
php
protected function startSheet() { $this->sheetFilePointer = fopen($this->worksheetFilePath, 'w'); $this->throwIfSheetFilePointerIsNotAvailable(); fwrite($this->sheetFilePointer, self::SHEET_XML_FILE_HEADER); fwrite($this->sheetFilePointer, '<sheetData>'); }
[ "protected", "function", "startSheet", "(", ")", "{", "$", "this", "->", "sheetFilePointer", "=", "fopen", "(", "$", "this", "->", "worksheetFilePath", ",", "'w'", ")", ";", "$", "this", "->", "throwIfSheetFilePointerIsNotAvailable", "(", ")", ";", "fwrite", "(", "$", "this", "->", "sheetFilePointer", ",", "self", "::", "SHEET_XML_FILE_HEADER", ")", ";", "fwrite", "(", "$", "this", "->", "sheetFilePointer", ",", "'<sheetData>'", ")", ";", "}" ]
Prepares the worksheet to accept data @return void @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing
[ "Prepares", "the", "worksheet", "to", "accept", "data" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L89-L96
212,101
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.isEmptyRow
protected function isEmptyRow($dataRow) { $numCells = count($dataRow); // using "reset()" instead of "$dataRow[0]" because $dataRow can be an associative array return ($numCells === 1 && CellHelper::isEmpty(reset($dataRow))); }
php
protected function isEmptyRow($dataRow) { $numCells = count($dataRow); // using "reset()" instead of "$dataRow[0]" because $dataRow can be an associative array return ($numCells === 1 && CellHelper::isEmpty(reset($dataRow))); }
[ "protected", "function", "isEmptyRow", "(", "$", "dataRow", ")", "{", "$", "numCells", "=", "count", "(", "$", "dataRow", ")", ";", "// using \"reset()\" instead of \"$dataRow[0]\" because $dataRow can be an associative array", "return", "(", "$", "numCells", "===", "1", "&&", "CellHelper", "::", "isEmpty", "(", "reset", "(", "$", "dataRow", ")", ")", ")", ";", "}" ]
Returns whether the given row is empty @param array $dataRow Array containing data to be written. Cannot be empty. Example $dataRow = ['data1', 1234, null, '', 'data5']; @return bool Whether the given row is empty
[ "Returns", "whether", "the", "given", "row", "is", "empty" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L162-L167
212,102
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.addNonEmptyRow
protected function addNonEmptyRow($dataRow, $style) { $cellNumber = 0; $rowIndex = $this->lastWrittenRowIndex + 1; $numCells = count($dataRow); $rowXML = '<row r="' . $rowIndex . '" spans="1:' . $numCells . '">'; foreach($dataRow as $cellValue) { $rowXML .= $this->getCellXML($rowIndex, $cellNumber, $cellValue, $style->getId()); $cellNumber++; } $rowXML .= '</row>'; $wasWriteSuccessful = fwrite($this->sheetFilePointer, $rowXML); if ($wasWriteSuccessful === false) { throw new IOException("Unable to write data in {$this->worksheetFilePath}"); } }
php
protected function addNonEmptyRow($dataRow, $style) { $cellNumber = 0; $rowIndex = $this->lastWrittenRowIndex + 1; $numCells = count($dataRow); $rowXML = '<row r="' . $rowIndex . '" spans="1:' . $numCells . '">'; foreach($dataRow as $cellValue) { $rowXML .= $this->getCellXML($rowIndex, $cellNumber, $cellValue, $style->getId()); $cellNumber++; } $rowXML .= '</row>'; $wasWriteSuccessful = fwrite($this->sheetFilePointer, $rowXML); if ($wasWriteSuccessful === false) { throw new IOException("Unable to write data in {$this->worksheetFilePath}"); } }
[ "protected", "function", "addNonEmptyRow", "(", "$", "dataRow", ",", "$", "style", ")", "{", "$", "cellNumber", "=", "0", ";", "$", "rowIndex", "=", "$", "this", "->", "lastWrittenRowIndex", "+", "1", ";", "$", "numCells", "=", "count", "(", "$", "dataRow", ")", ";", "$", "rowXML", "=", "'<row r=\"'", ".", "$", "rowIndex", ".", "'\" spans=\"1:'", ".", "$", "numCells", ".", "'\">'", ";", "foreach", "(", "$", "dataRow", "as", "$", "cellValue", ")", "{", "$", "rowXML", ".=", "$", "this", "->", "getCellXML", "(", "$", "rowIndex", ",", "$", "cellNumber", ",", "$", "cellValue", ",", "$", "style", "->", "getId", "(", ")", ")", ";", "$", "cellNumber", "++", ";", "}", "$", "rowXML", ".=", "'</row>'", ";", "$", "wasWriteSuccessful", "=", "fwrite", "(", "$", "this", "->", "sheetFilePointer", ",", "$", "rowXML", ")", ";", "if", "(", "$", "wasWriteSuccessful", "===", "false", ")", "{", "throw", "new", "IOException", "(", "\"Unable to write data in {$this->worksheetFilePath}\"", ")", ";", "}", "}" ]
Adds non empty row to the worksheet. @param array $dataRow Array containing data to be written. Cannot be empty. Example $dataRow = ['data1', 1234, null, '', 'data5']; @param \Box\Spout\Writer\Style\Style $style Style to be applied to the row. NULL means use default style. @return void @throws \Box\Spout\Common\Exception\IOException If the data cannot be written @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported
[ "Adds", "non", "empty", "row", "to", "the", "worksheet", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L179-L198
212,103
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.getCellXML
protected function getCellXML($rowIndex, $cellNumber, $cellValue, $styleId) { $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber); $cellXML = '<c r="' . $columnIndex . $rowIndex . '"'; $cellXML .= ' s="' . $styleId . '"'; if (CellHelper::isNonEmptyString($cellValue)) { $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cellValue); } else if (CellHelper::isBoolean($cellValue)) { $cellXML .= ' t="b"><v>' . intval($cellValue) . '</v></c>'; } else if (CellHelper::isNumeric($cellValue)) { $cellXML .= '><v>' . $cellValue . '</v></c>'; } else if (empty($cellValue)) { if ($this->styleHelper->shouldApplyStyleOnEmptyCell($styleId)) { $cellXML .= '/>'; } else { // don't write empty cells that do no need styling // NOTE: not appending to $cellXML is the right behavior!! $cellXML = ''; } } else { throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } return $cellXML; }
php
protected function getCellXML($rowIndex, $cellNumber, $cellValue, $styleId) { $columnIndex = CellHelper::getCellIndexFromColumnIndex($cellNumber); $cellXML = '<c r="' . $columnIndex . $rowIndex . '"'; $cellXML .= ' s="' . $styleId . '"'; if (CellHelper::isNonEmptyString($cellValue)) { $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cellValue); } else if (CellHelper::isBoolean($cellValue)) { $cellXML .= ' t="b"><v>' . intval($cellValue) . '</v></c>'; } else if (CellHelper::isNumeric($cellValue)) { $cellXML .= '><v>' . $cellValue . '</v></c>'; } else if (empty($cellValue)) { if ($this->styleHelper->shouldApplyStyleOnEmptyCell($styleId)) { $cellXML .= '/>'; } else { // don't write empty cells that do no need styling // NOTE: not appending to $cellXML is the right behavior!! $cellXML = ''; } } else { throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cellValue)); } return $cellXML; }
[ "protected", "function", "getCellXML", "(", "$", "rowIndex", ",", "$", "cellNumber", ",", "$", "cellValue", ",", "$", "styleId", ")", "{", "$", "columnIndex", "=", "CellHelper", "::", "getCellIndexFromColumnIndex", "(", "$", "cellNumber", ")", ";", "$", "cellXML", "=", "'<c r=\"'", ".", "$", "columnIndex", ".", "$", "rowIndex", ".", "'\"'", ";", "$", "cellXML", ".=", "' s=\"'", ".", "$", "styleId", ".", "'\"'", ";", "if", "(", "CellHelper", "::", "isNonEmptyString", "(", "$", "cellValue", ")", ")", "{", "$", "cellXML", ".=", "$", "this", "->", "getCellXMLFragmentForNonEmptyString", "(", "$", "cellValue", ")", ";", "}", "else", "if", "(", "CellHelper", "::", "isBoolean", "(", "$", "cellValue", ")", ")", "{", "$", "cellXML", ".=", "' t=\"b\"><v>'", ".", "intval", "(", "$", "cellValue", ")", ".", "'</v></c>'", ";", "}", "else", "if", "(", "CellHelper", "::", "isNumeric", "(", "$", "cellValue", ")", ")", "{", "$", "cellXML", ".=", "'><v>'", ".", "$", "cellValue", ".", "'</v></c>'", ";", "}", "else", "if", "(", "empty", "(", "$", "cellValue", ")", ")", "{", "if", "(", "$", "this", "->", "styleHelper", "->", "shouldApplyStyleOnEmptyCell", "(", "$", "styleId", ")", ")", "{", "$", "cellXML", ".=", "'/>'", ";", "}", "else", "{", "// don't write empty cells that do no need styling", "// NOTE: not appending to $cellXML is the right behavior!!", "$", "cellXML", "=", "''", ";", "}", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Trying to add a value with an unsupported type: '", ".", "gettype", "(", "$", "cellValue", ")", ")", ";", "}", "return", "$", "cellXML", ";", "}" ]
Build and return xml for a single cell. @param int $rowIndex @param int $cellNumber @param mixed $cellValue @param int $styleId @return string @throws InvalidArgumentException If the given value cannot be processed
[ "Build", "and", "return", "xml", "for", "a", "single", "cell", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L210-L235
212,104
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.getCellXMLFragmentForNonEmptyString
protected function getCellXMLFragmentForNonEmptyString($cellValue) { if ($this->stringHelper->getStringLength($cellValue) > self::MAX_CHARACTERS_PER_CELL) { throw new InvalidArgumentException('Trying to add a value that exceeds the maximum number of characters allowed in a cell (32,767)'); } if ($this->shouldUseInlineStrings) { $cellXMLFragment = ' t="inlineStr"><is><t>' . $this->stringsEscaper->escape($cellValue) . '</t></is></c>'; } else { $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); $cellXMLFragment = ' t="s"><v>' . $sharedStringId . '</v></c>'; } return $cellXMLFragment; }
php
protected function getCellXMLFragmentForNonEmptyString($cellValue) { if ($this->stringHelper->getStringLength($cellValue) > self::MAX_CHARACTERS_PER_CELL) { throw new InvalidArgumentException('Trying to add a value that exceeds the maximum number of characters allowed in a cell (32,767)'); } if ($this->shouldUseInlineStrings) { $cellXMLFragment = ' t="inlineStr"><is><t>' . $this->stringsEscaper->escape($cellValue) . '</t></is></c>'; } else { $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); $cellXMLFragment = ' t="s"><v>' . $sharedStringId . '</v></c>'; } return $cellXMLFragment; }
[ "protected", "function", "getCellXMLFragmentForNonEmptyString", "(", "$", "cellValue", ")", "{", "if", "(", "$", "this", "->", "stringHelper", "->", "getStringLength", "(", "$", "cellValue", ")", ">", "self", "::", "MAX_CHARACTERS_PER_CELL", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Trying to add a value that exceeds the maximum number of characters allowed in a cell (32,767)'", ")", ";", "}", "if", "(", "$", "this", "->", "shouldUseInlineStrings", ")", "{", "$", "cellXMLFragment", "=", "' t=\"inlineStr\"><is><t>'", ".", "$", "this", "->", "stringsEscaper", "->", "escape", "(", "$", "cellValue", ")", ".", "'</t></is></c>'", ";", "}", "else", "{", "$", "sharedStringId", "=", "$", "this", "->", "sharedStringsHelper", "->", "writeString", "(", "$", "cellValue", ")", ";", "$", "cellXMLFragment", "=", "' t=\"s\"><v>'", ".", "$", "sharedStringId", ".", "'</v></c>'", ";", "}", "return", "$", "cellXMLFragment", ";", "}" ]
Returns the XML fragment for a cell containing a non empty string @param string $cellValue The cell value @return string The XML fragment representing the cell @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell
[ "Returns", "the", "XML", "fragment", "for", "a", "cell", "containing", "a", "non", "empty", "string" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L244-L258
212,105
moodle/moodle
lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php
Worksheet.close
public function close() { if (!is_resource($this->sheetFilePointer)) { return; } fwrite($this->sheetFilePointer, '</sheetData>'); fwrite($this->sheetFilePointer, '</worksheet>'); fclose($this->sheetFilePointer); }
php
public function close() { if (!is_resource($this->sheetFilePointer)) { return; } fwrite($this->sheetFilePointer, '</sheetData>'); fwrite($this->sheetFilePointer, '</worksheet>'); fclose($this->sheetFilePointer); }
[ "public", "function", "close", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "sheetFilePointer", ")", ")", "{", "return", ";", "}", "fwrite", "(", "$", "this", "->", "sheetFilePointer", ",", "'</sheetData>'", ")", ";", "fwrite", "(", "$", "this", "->", "sheetFilePointer", ",", "'</worksheet>'", ")", ";", "fclose", "(", "$", "this", "->", "sheetFilePointer", ")", ";", "}" ]
Closes the worksheet @return void
[ "Closes", "the", "worksheet" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/XLSX/Internal/Worksheet.php#L265-L274
212,106
moodle/moodle
lib/classes/event/user_deleted.php
user_deleted.get_legacy_eventdata
protected function get_legacy_eventdata() { $user = $this->get_record_snapshot('user', $this->objectid); $user->deleted = 0; $user->username = $this->other['username']; $user->email = $this->other['email']; $user->idnumber = $this->other['idnumber']; $user->picture = $this->other['picture']; return $user; }
php
protected function get_legacy_eventdata() { $user = $this->get_record_snapshot('user', $this->objectid); $user->deleted = 0; $user->username = $this->other['username']; $user->email = $this->other['email']; $user->idnumber = $this->other['idnumber']; $user->picture = $this->other['picture']; return $user; }
[ "protected", "function", "get_legacy_eventdata", "(", ")", "{", "$", "user", "=", "$", "this", "->", "get_record_snapshot", "(", "'user'", ",", "$", "this", "->", "objectid", ")", ";", "$", "user", "->", "deleted", "=", "0", ";", "$", "user", "->", "username", "=", "$", "this", "->", "other", "[", "'username'", "]", ";", "$", "user", "->", "email", "=", "$", "this", "->", "other", "[", "'email'", "]", ";", "$", "user", "->", "idnumber", "=", "$", "this", "->", "other", "[", "'idnumber'", "]", ";", "$", "user", "->", "picture", "=", "$", "this", "->", "other", "[", "'picture'", "]", ";", "return", "$", "user", ";", "}" ]
Return user_deleted legacy event data. @return \stdClass user data.
[ "Return", "user_deleted", "legacy", "event", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/user_deleted.php#L89-L98
212,107
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.command
public function command($command, array $options = []) { if ( ! isset($options['readPreference'])) { $options['readPreference'] = $this->readPreference; } if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $operation = new DatabaseCommand($this->databaseName, $command, $options); $server = $this->manager->selectServer($options['readPreference']); return $operation->execute($server); }
php
public function command($command, array $options = []) { if ( ! isset($options['readPreference'])) { $options['readPreference'] = $this->readPreference; } if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $operation = new DatabaseCommand($this->databaseName, $command, $options); $server = $this->manager->selectServer($options['readPreference']); return $operation->execute($server); }
[ "public", "function", "command", "(", "$", "command", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'readPreference'", "]", ")", ")", "{", "$", "options", "[", "'readPreference'", "]", "=", "$", "this", "->", "readPreference", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'typeMap'", "]", ")", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "$", "this", "->", "typeMap", ";", "}", "$", "operation", "=", "new", "DatabaseCommand", "(", "$", "this", "->", "databaseName", ",", "$", "command", ",", "$", "options", ")", ";", "$", "server", "=", "$", "this", "->", "manager", "->", "selectServer", "(", "$", "options", "[", "'readPreference'", "]", ")", ";", "return", "$", "operation", "->", "execute", "(", "$", "server", ")", ";", "}" ]
Execute a command on this database. @see DatabaseCommand::__construct() for supported options @param array|object $command Command document @param array $options Options for command execution @return Cursor @throws InvalidArgumentException for parameter/option parsing errors @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "Execute", "a", "command", "on", "this", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L168-L182
212,108
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.createCollection
public function createCollection($collectionName, array $options = []) { if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) { $options['writeConcern'] = $this->writeConcern; } $operation = new CreateCollection($this->databaseName, $collectionName, $options); return $operation->execute($server); }
php
public function createCollection($collectionName, array $options = []) { if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) { $options['writeConcern'] = $this->writeConcern; } $operation = new CreateCollection($this->databaseName, $collectionName, $options); return $operation->execute($server); }
[ "public", "function", "createCollection", "(", "$", "collectionName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'typeMap'", "]", ")", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "$", "this", "->", "typeMap", ";", "}", "$", "server", "=", "$", "this", "->", "manager", "->", "selectServer", "(", "new", "ReadPreference", "(", "ReadPreference", "::", "RP_PRIMARY", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'writeConcern'", "]", ")", "&&", "\\", "MongoDB", "\\", "server_supports_feature", "(", "$", "server", ",", "self", "::", "$", "wireVersionForWritableCommandWriteConcern", ")", ")", "{", "$", "options", "[", "'writeConcern'", "]", "=", "$", "this", "->", "writeConcern", ";", "}", "$", "operation", "=", "new", "CreateCollection", "(", "$", "this", "->", "databaseName", ",", "$", "collectionName", ",", "$", "options", ")", ";", "return", "$", "operation", "->", "execute", "(", "$", "server", ")", ";", "}" ]
Create a new collection explicitly. @see CreateCollection::__construct() for supported options @param string $collectionName @param array $options @return array|object Command result document @throws UnsupportedException if options are not supported by the selected server @throws InvalidArgumentException for parameter/option parsing errors @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "Create", "a", "new", "collection", "explicitly", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L195-L210
212,109
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.listCollections
public function listCollections(array $options = []) { $operation = new ListCollections($this->databaseName, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }
php
public function listCollections(array $options = []) { $operation = new ListCollections($this->databaseName, $options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }
[ "public", "function", "listCollections", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "operation", "=", "new", "ListCollections", "(", "$", "this", "->", "databaseName", ",", "$", "options", ")", ";", "$", "server", "=", "$", "this", "->", "manager", "->", "selectServer", "(", "new", "ReadPreference", "(", "ReadPreference", "::", "RP_PRIMARY", ")", ")", ";", "return", "$", "operation", "->", "execute", "(", "$", "server", ")", ";", "}" ]
Returns information for all collections in this database. @see ListCollections::__construct() for supported options @param array $options @return CollectionInfoIterator @throws InvalidArgumentException for parameter/option parsing errors @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "Returns", "information", "for", "all", "collections", "in", "this", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L338-L344
212,110
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.modifyCollection
public function modifyCollection($collectionName, array $collectionOptions, array $options = []) { if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) { $options['writeConcern'] = $this->writeConcern; } $operation = new ModifyCollection($this->databaseName, $collectionName, $collectionOptions, $options); return $operation->execute($server); }
php
public function modifyCollection($collectionName, array $collectionOptions, array $options = []) { if ( ! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; } $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForWritableCommandWriteConcern)) { $options['writeConcern'] = $this->writeConcern; } $operation = new ModifyCollection($this->databaseName, $collectionName, $collectionOptions, $options); return $operation->execute($server); }
[ "public", "function", "modifyCollection", "(", "$", "collectionName", ",", "array", "$", "collectionOptions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'typeMap'", "]", ")", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "$", "this", "->", "typeMap", ";", "}", "$", "server", "=", "$", "this", "->", "manager", "->", "selectServer", "(", "new", "ReadPreference", "(", "ReadPreference", "::", "RP_PRIMARY", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'writeConcern'", "]", ")", "&&", "\\", "MongoDB", "\\", "server_supports_feature", "(", "$", "server", ",", "self", "::", "$", "wireVersionForWritableCommandWriteConcern", ")", ")", "{", "$", "options", "[", "'writeConcern'", "]", "=", "$", "this", "->", "writeConcern", ";", "}", "$", "operation", "=", "new", "ModifyCollection", "(", "$", "this", "->", "databaseName", ",", "$", "collectionName", ",", "$", "collectionOptions", ",", "$", "options", ")", ";", "return", "$", "operation", "->", "execute", "(", "$", "server", ")", ";", "}" ]
Modifies a collection or view. @see ModifyCollection::__construct() for supported options @param string $collectionName Collection or view to modify @param array $collectionOptions Collection or view options to assign @param array $options Command options @throws InvalidArgumentException for parameter/option parsing errors @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "Modifies", "a", "collection", "or", "view", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L356-L371
212,111
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.selectGridFSBucket
public function selectGridFSBucket(array $options = []) { $options += [ 'readConcern' => $this->readConcern, 'readPreference' => $this->readPreference, 'typeMap' => $this->typeMap, 'writeConcern' => $this->writeConcern, ]; return new Bucket($this->manager, $this->databaseName, $options); }
php
public function selectGridFSBucket(array $options = []) { $options += [ 'readConcern' => $this->readConcern, 'readPreference' => $this->readPreference, 'typeMap' => $this->typeMap, 'writeConcern' => $this->writeConcern, ]; return new Bucket($this->manager, $this->databaseName, $options); }
[ "public", "function", "selectGridFSBucket", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'readConcern'", "=>", "$", "this", "->", "readConcern", ",", "'readPreference'", "=>", "$", "this", "->", "readPreference", ",", "'typeMap'", "=>", "$", "this", "->", "typeMap", ",", "'writeConcern'", "=>", "$", "this", "->", "writeConcern", ",", "]", ";", "return", "new", "Bucket", "(", "$", "this", "->", "manager", ",", "$", "this", "->", "databaseName", ",", "$", "options", ")", ";", "}" ]
Select a GridFS bucket within this database. @see Bucket::__construct() for supported options @param array $options Bucket constructor options @return Bucket @throws InvalidArgumentException for parameter/option parsing errors
[ "Select", "a", "GridFS", "bucket", "within", "this", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L402-L412
212,112
moodle/moodle
cache/stores/mongodb/MongoDB/Database.php
Database.withOptions
public function withOptions(array $options = []) { $options += [ 'readConcern' => $this->readConcern, 'readPreference' => $this->readPreference, 'typeMap' => $this->typeMap, 'writeConcern' => $this->writeConcern, ]; return new Database($this->manager, $this->databaseName, $options); }
php
public function withOptions(array $options = []) { $options += [ 'readConcern' => $this->readConcern, 'readPreference' => $this->readPreference, 'typeMap' => $this->typeMap, 'writeConcern' => $this->writeConcern, ]; return new Database($this->manager, $this->databaseName, $options); }
[ "public", "function", "withOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'readConcern'", "=>", "$", "this", "->", "readConcern", ",", "'readPreference'", "=>", "$", "this", "->", "readPreference", ",", "'typeMap'", "=>", "$", "this", "->", "typeMap", ",", "'writeConcern'", "=>", "$", "this", "->", "writeConcern", ",", "]", ";", "return", "new", "Database", "(", "$", "this", "->", "manager", ",", "$", "this", "->", "databaseName", ",", "$", "options", ")", ";", "}" ]
Get a clone of this database with different options. @see Database::__construct() for supported options @param array $options Database constructor options @return Database @throws InvalidArgumentException for parameter/option parsing errors
[ "Get", "a", "clone", "of", "this", "database", "with", "different", "options", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Database.php#L452-L462
212,113
moodle/moodle
lib/phpexcel/PHPExcel/Exception.php
PHPExcel_Exception.errorHandlerCallback
public static function errorHandlerCallback($code, $string, $file, $line, $context) { $e = new self($string, $code); $e->line = $line; $e->file = $file; throw $e; }
php
public static function errorHandlerCallback($code, $string, $file, $line, $context) { $e = new self($string, $code); $e->line = $line; $e->file = $file; throw $e; }
[ "public", "static", "function", "errorHandlerCallback", "(", "$", "code", ",", "$", "string", ",", "$", "file", ",", "$", "line", ",", "$", "context", ")", "{", "$", "e", "=", "new", "self", "(", "$", "string", ",", "$", "code", ")", ";", "$", "e", "->", "line", "=", "$", "line", ";", "$", "e", "->", "file", "=", "$", "file", ";", "throw", "$", "e", ";", "}" ]
Error handler callback @param mixed $code @param mixed $string @param mixed $file @param mixed $line @param mixed $context
[ "Error", "handler", "callback" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Exception.php#L47-L53
212,114
moodle/moodle
backup/util/settings/base_setting.class.php
base_setting.get_my_dependency_properties
public function get_my_dependency_properties($settingname=null) { if ($settingname == null) { $settingname = $this->get_ui_name(); } $dependencies = array(); foreach ($this->dependenton as $dependenton) { $properties = $dependenton->get_moodleform_properties(); $properties['setting'] = $settingname; $dependencies[$properties['setting'].'-'.$properties['dependenton']] = $properties; $dependencies = array_merge($dependencies, $dependenton->get_setting()->get_my_dependency_properties($settingname)); } return $dependencies; }
php
public function get_my_dependency_properties($settingname=null) { if ($settingname == null) { $settingname = $this->get_ui_name(); } $dependencies = array(); foreach ($this->dependenton as $dependenton) { $properties = $dependenton->get_moodleform_properties(); $properties['setting'] = $settingname; $dependencies[$properties['setting'].'-'.$properties['dependenton']] = $properties; $dependencies = array_merge($dependencies, $dependenton->get_setting()->get_my_dependency_properties($settingname)); } return $dependencies; }
[ "public", "function", "get_my_dependency_properties", "(", "$", "settingname", "=", "null", ")", "{", "if", "(", "$", "settingname", "==", "null", ")", "{", "$", "settingname", "=", "$", "this", "->", "get_ui_name", "(", ")", ";", "}", "$", "dependencies", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "dependenton", "as", "$", "dependenton", ")", "{", "$", "properties", "=", "$", "dependenton", "->", "get_moodleform_properties", "(", ")", ";", "$", "properties", "[", "'setting'", "]", "=", "$", "settingname", ";", "$", "dependencies", "[", "$", "properties", "[", "'setting'", "]", ".", "'-'", ".", "$", "properties", "[", "'dependenton'", "]", "]", "=", "$", "properties", ";", "$", "dependencies", "=", "array_merge", "(", "$", "dependencies", ",", "$", "dependenton", "->", "get_setting", "(", ")", "->", "get_my_dependency_properties", "(", "$", "settingname", ")", ")", ";", "}", "return", "$", "dependencies", ";", "}" ]
Gets an array of properties for all of the dependencies that will affect this setting. This method returns an array rather than the dependencies in order to minimise the memory footprint of for the potentially huge recursive dependency structure that we may be dealing with. This method also ensures that all dependencies are transmuted to affect the setting in question and that we don't provide any duplicates. @param string|null $settingname @return array
[ "Gets", "an", "array", "of", "properties", "for", "all", "of", "the", "dependencies", "that", "will", "affect", "this", "setting", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/settings/base_setting.class.php#L252-L264
212,115
moodle/moodle
backup/util/settings/base_setting.class.php
base_setting.register_dependency
public function register_dependency(setting_dependency $dependency) { if ($this->is_circular_reference($dependency->get_dependent_setting())) { $a = new stdclass(); $a->alreadydependent = $this->name; $a->main = $dependency->get_dependent_setting()->get_name(); throw new base_setting_exception('setting_circular_reference', $a); } $this->dependencies[$dependency->get_dependent_setting()->get_name()] = $dependency; $dependency->get_dependent_setting()->register_dependent_dependency($dependency); }
php
public function register_dependency(setting_dependency $dependency) { if ($this->is_circular_reference($dependency->get_dependent_setting())) { $a = new stdclass(); $a->alreadydependent = $this->name; $a->main = $dependency->get_dependent_setting()->get_name(); throw new base_setting_exception('setting_circular_reference', $a); } $this->dependencies[$dependency->get_dependent_setting()->get_name()] = $dependency; $dependency->get_dependent_setting()->register_dependent_dependency($dependency); }
[ "public", "function", "register_dependency", "(", "setting_dependency", "$", "dependency", ")", "{", "if", "(", "$", "this", "->", "is_circular_reference", "(", "$", "dependency", "->", "get_dependent_setting", "(", ")", ")", ")", "{", "$", "a", "=", "new", "stdclass", "(", ")", ";", "$", "a", "->", "alreadydependent", "=", "$", "this", "->", "name", ";", "$", "a", "->", "main", "=", "$", "dependency", "->", "get_dependent_setting", "(", ")", "->", "get_name", "(", ")", ";", "throw", "new", "base_setting_exception", "(", "'setting_circular_reference'", ",", "$", "a", ")", ";", "}", "$", "this", "->", "dependencies", "[", "$", "dependency", "->", "get_dependent_setting", "(", ")", "->", "get_name", "(", ")", "]", "=", "$", "dependency", ";", "$", "dependency", "->", "get_dependent_setting", "(", ")", "->", "register_dependent_dependency", "(", "$", "dependency", ")", ";", "}" ]
Adds a dependency where another setting depends on this setting. @param setting_dependency $dependency
[ "Adds", "a", "dependency", "where", "another", "setting", "depends", "on", "this", "setting", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/settings/base_setting.class.php#L316-L325
212,116
moodle/moodle
backup/util/settings/base_setting.class.php
base_setting.add_dependency
public function add_dependency(base_setting $dependentsetting, $type=null, $options=array()) { if ($this->is_circular_reference($dependentsetting)) { $a = new stdclass(); $a->alreadydependent = $this->name; $a->main = $dependentsetting->get_name(); throw new base_setting_exception('setting_circular_reference', $a); } // Check the settings hasn't been already added if (array_key_exists($dependentsetting->get_name(), $this->dependencies)) { throw new base_setting_exception('setting_already_added'); } $options = (array)$options; if (!array_key_exists('defaultvalue', $options)) { $options['defaultvalue'] = false; } if ($type == null) { switch ($this->vtype) { case self::IS_BOOLEAN : if ($this->get_ui_type() == self::UI_HTML_CHECKBOX) { if ($this->value) { $type = setting_dependency::DISABLED_NOT_CHECKED; } else { $type = setting_dependency::DISABLED_CHECKED; } } else { if ($this->value) { $type = setting_dependency::DISABLED_FALSE; } else { $type = setting_dependency::DISABLED_TRUE; } } break; case self::IS_FILENAME : case self::IS_PATH : case self::IS_INTEGER : default : $type = setting_dependency::DISABLED_VALUE; break; } } switch ($type) { case setting_dependency::DISABLED_VALUE : if (!array_key_exists('value', $options)) { throw new base_setting_exception('dependency_needs_value'); } $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, $options['value'], $options['defaultvalue']); break; case setting_dependency::DISABLED_TRUE : $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, true, $options['defaultvalue']); break; case setting_dependency::DISABLED_FALSE : $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, false, $options['defaultvalue']); break; case setting_dependency::DISABLED_CHECKED : $dependency = new setting_dependency_disabledif_checked($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_NOT_CHECKED : $dependency = new setting_dependency_disabledif_not_checked($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_EMPTY : $dependency = new setting_dependency_disabledif_empty($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_NOT_EMPTY : $dependency = new setting_dependency_disabledif_not_empty($this, $dependentsetting, $options['defaultvalue']); break; } $this->dependencies[$dependentsetting->get_name()] = $dependency; $dependency->get_dependent_setting()->register_dependent_dependency($dependency); }
php
public function add_dependency(base_setting $dependentsetting, $type=null, $options=array()) { if ($this->is_circular_reference($dependentsetting)) { $a = new stdclass(); $a->alreadydependent = $this->name; $a->main = $dependentsetting->get_name(); throw new base_setting_exception('setting_circular_reference', $a); } // Check the settings hasn't been already added if (array_key_exists($dependentsetting->get_name(), $this->dependencies)) { throw new base_setting_exception('setting_already_added'); } $options = (array)$options; if (!array_key_exists('defaultvalue', $options)) { $options['defaultvalue'] = false; } if ($type == null) { switch ($this->vtype) { case self::IS_BOOLEAN : if ($this->get_ui_type() == self::UI_HTML_CHECKBOX) { if ($this->value) { $type = setting_dependency::DISABLED_NOT_CHECKED; } else { $type = setting_dependency::DISABLED_CHECKED; } } else { if ($this->value) { $type = setting_dependency::DISABLED_FALSE; } else { $type = setting_dependency::DISABLED_TRUE; } } break; case self::IS_FILENAME : case self::IS_PATH : case self::IS_INTEGER : default : $type = setting_dependency::DISABLED_VALUE; break; } } switch ($type) { case setting_dependency::DISABLED_VALUE : if (!array_key_exists('value', $options)) { throw new base_setting_exception('dependency_needs_value'); } $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, $options['value'], $options['defaultvalue']); break; case setting_dependency::DISABLED_TRUE : $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, true, $options['defaultvalue']); break; case setting_dependency::DISABLED_FALSE : $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, false, $options['defaultvalue']); break; case setting_dependency::DISABLED_CHECKED : $dependency = new setting_dependency_disabledif_checked($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_NOT_CHECKED : $dependency = new setting_dependency_disabledif_not_checked($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_EMPTY : $dependency = new setting_dependency_disabledif_empty($this, $dependentsetting, $options['defaultvalue']); break; case setting_dependency::DISABLED_NOT_EMPTY : $dependency = new setting_dependency_disabledif_not_empty($this, $dependentsetting, $options['defaultvalue']); break; } $this->dependencies[$dependentsetting->get_name()] = $dependency; $dependency->get_dependent_setting()->register_dependent_dependency($dependency); }
[ "public", "function", "add_dependency", "(", "base_setting", "$", "dependentsetting", ",", "$", "type", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "is_circular_reference", "(", "$", "dependentsetting", ")", ")", "{", "$", "a", "=", "new", "stdclass", "(", ")", ";", "$", "a", "->", "alreadydependent", "=", "$", "this", "->", "name", ";", "$", "a", "->", "main", "=", "$", "dependentsetting", "->", "get_name", "(", ")", ";", "throw", "new", "base_setting_exception", "(", "'setting_circular_reference'", ",", "$", "a", ")", ";", "}", "// Check the settings hasn't been already added", "if", "(", "array_key_exists", "(", "$", "dependentsetting", "->", "get_name", "(", ")", ",", "$", "this", "->", "dependencies", ")", ")", "{", "throw", "new", "base_setting_exception", "(", "'setting_already_added'", ")", ";", "}", "$", "options", "=", "(", "array", ")", "$", "options", ";", "if", "(", "!", "array_key_exists", "(", "'defaultvalue'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'defaultvalue'", "]", "=", "false", ";", "}", "if", "(", "$", "type", "==", "null", ")", "{", "switch", "(", "$", "this", "->", "vtype", ")", "{", "case", "self", "::", "IS_BOOLEAN", ":", "if", "(", "$", "this", "->", "get_ui_type", "(", ")", "==", "self", "::", "UI_HTML_CHECKBOX", ")", "{", "if", "(", "$", "this", "->", "value", ")", "{", "$", "type", "=", "setting_dependency", "::", "DISABLED_NOT_CHECKED", ";", "}", "else", "{", "$", "type", "=", "setting_dependency", "::", "DISABLED_CHECKED", ";", "}", "}", "else", "{", "if", "(", "$", "this", "->", "value", ")", "{", "$", "type", "=", "setting_dependency", "::", "DISABLED_FALSE", ";", "}", "else", "{", "$", "type", "=", "setting_dependency", "::", "DISABLED_TRUE", ";", "}", "}", "break", ";", "case", "self", "::", "IS_FILENAME", ":", "case", "self", "::", "IS_PATH", ":", "case", "self", "::", "IS_INTEGER", ":", "default", ":", "$", "type", "=", "setting_dependency", "::", "DISABLED_VALUE", ";", "break", ";", "}", "}", "switch", "(", "$", "type", ")", "{", "case", "setting_dependency", "::", "DISABLED_VALUE", ":", "if", "(", "!", "array_key_exists", "(", "'value'", ",", "$", "options", ")", ")", "{", "throw", "new", "base_setting_exception", "(", "'dependency_needs_value'", ")", ";", "}", "$", "dependency", "=", "new", "setting_dependency_disabledif_equals", "(", "$", "this", ",", "$", "dependentsetting", ",", "$", "options", "[", "'value'", "]", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_TRUE", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_equals", "(", "$", "this", ",", "$", "dependentsetting", ",", "true", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_FALSE", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_equals", "(", "$", "this", ",", "$", "dependentsetting", ",", "false", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_CHECKED", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_checked", "(", "$", "this", ",", "$", "dependentsetting", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_NOT_CHECKED", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_not_checked", "(", "$", "this", ",", "$", "dependentsetting", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_EMPTY", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_empty", "(", "$", "this", ",", "$", "dependentsetting", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "case", "setting_dependency", "::", "DISABLED_NOT_EMPTY", ":", "$", "dependency", "=", "new", "setting_dependency_disabledif_not_empty", "(", "$", "this", ",", "$", "dependentsetting", ",", "$", "options", "[", "'defaultvalue'", "]", ")", ";", "break", ";", "}", "$", "this", "->", "dependencies", "[", "$", "dependentsetting", "->", "get_name", "(", ")", "]", "=", "$", "dependency", ";", "$", "dependency", "->", "get_dependent_setting", "(", ")", "->", "register_dependent_dependency", "(", "$", "dependency", ")", ";", "}" ]
Quick method to add a dependency to this setting. The dependency created is done so by inspecting this setting and the setting that is passed in as the dependent setting. @param base_setting $dependentsetting @param int $type One of setting_dependency::* @param array $options
[ "Quick", "method", "to", "add", "a", "dependency", "to", "this", "setting", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/settings/base_setting.class.php#L347-L419
212,117
moodle/moodle
backup/util/settings/base_setting.class.php
base_setting.get_param_validation
public function get_param_validation() { switch ($this->vtype) { case self::IS_BOOLEAN: return PARAM_BOOL; case self::IS_INTEGER: return PARAM_INT; case self::IS_FILENAME: return PARAM_FILE; case self::IS_PATH: return PARAM_PATH; case self::IS_TEXT: return PARAM_TEXT; } return null; }
php
public function get_param_validation() { switch ($this->vtype) { case self::IS_BOOLEAN: return PARAM_BOOL; case self::IS_INTEGER: return PARAM_INT; case self::IS_FILENAME: return PARAM_FILE; case self::IS_PATH: return PARAM_PATH; case self::IS_TEXT: return PARAM_TEXT; } return null; }
[ "public", "function", "get_param_validation", "(", ")", "{", "switch", "(", "$", "this", "->", "vtype", ")", "{", "case", "self", "::", "IS_BOOLEAN", ":", "return", "PARAM_BOOL", ";", "case", "self", "::", "IS_INTEGER", ":", "return", "PARAM_INT", ";", "case", "self", "::", "IS_FILENAME", ":", "return", "PARAM_FILE", ";", "case", "self", "::", "IS_PATH", ":", "return", "PARAM_PATH", ";", "case", "self", "::", "IS_TEXT", ":", "return", "PARAM_TEXT", ";", "}", "return", "null", ";", "}" ]
Get the PARAM_XXXX validation to be applied to the setting @return string The PARAM_XXXX constant of null if the setting type is not defined
[ "Get", "the", "PARAM_XXXX", "validation", "to", "be", "applied", "to", "the", "setting" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/settings/base_setting.class.php#L426-L440
212,118
moodle/moodle
question/type/gapselect/questiontypebase.php
qtype_gapselect_base.get_correct_answers
protected function get_correct_answers($question) { $arrayofchoices = $this->get_array_of_choices($question); $arrayofplaceholdeers = $this->get_array_of_placeholders($question); $correctplayers = array(); foreach ($arrayofplaceholdeers as $ph) { foreach ($arrayofchoices as $key => $choice) { if ($key + 1 == $ph) { $correctplayers[] = $choice; } } } return $correctplayers; }
php
protected function get_correct_answers($question) { $arrayofchoices = $this->get_array_of_choices($question); $arrayofplaceholdeers = $this->get_array_of_placeholders($question); $correctplayers = array(); foreach ($arrayofplaceholdeers as $ph) { foreach ($arrayofchoices as $key => $choice) { if ($key + 1 == $ph) { $correctplayers[] = $choice; } } } return $correctplayers; }
[ "protected", "function", "get_correct_answers", "(", "$", "question", ")", "{", "$", "arrayofchoices", "=", "$", "this", "->", "get_array_of_choices", "(", "$", "question", ")", ";", "$", "arrayofplaceholdeers", "=", "$", "this", "->", "get_array_of_placeholders", "(", "$", "question", ")", ";", "$", "correctplayers", "=", "array", "(", ")", ";", "foreach", "(", "$", "arrayofplaceholdeers", "as", "$", "ph", ")", "{", "foreach", "(", "$", "arrayofchoices", "as", "$", "key", "=>", "$", "choice", ")", "{", "if", "(", "$", "key", "+", "1", "==", "$", "ph", ")", "{", "$", "correctplayers", "[", "]", "=", "$", "choice", ";", "}", "}", "}", "return", "$", "correctplayers", ";", "}" ]
This method gets the correct answers in a 2 dimentional array. @param object $question @return array of groups
[ "This", "method", "gets", "the", "correct", "answers", "in", "a", "2", "dimentional", "array", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/gapselect/questiontypebase.php#L238-L251
212,119
moodle/moodle
question/type/gapselect/questiontypebase.php
qtype_gapselect_base.get_array_of_placeholders
protected function get_array_of_placeholders($question) { $qtext = $question->questiontext; $error = '<b> ERROR</b>: Please check the form for this question. '; if (!$qtext) { echo $error . 'The question text is empty!'; return false; } // Get the slots. $slots = $this->getEmbeddedTextArray($question); if (!$slots) { echo $error . 'The question text is not in the correct format!'; return false; } $output = array(); foreach ($slots as $slot) { $output[] = substr($slot, 2, strlen($slot) - 4); // 2 is for '[[' and 4 is for '[[]]'. } return $output; }
php
protected function get_array_of_placeholders($question) { $qtext = $question->questiontext; $error = '<b> ERROR</b>: Please check the form for this question. '; if (!$qtext) { echo $error . 'The question text is empty!'; return false; } // Get the slots. $slots = $this->getEmbeddedTextArray($question); if (!$slots) { echo $error . 'The question text is not in the correct format!'; return false; } $output = array(); foreach ($slots as $slot) { $output[] = substr($slot, 2, strlen($slot) - 4); // 2 is for '[[' and 4 is for '[[]]'. } return $output; }
[ "protected", "function", "get_array_of_placeholders", "(", "$", "question", ")", "{", "$", "qtext", "=", "$", "question", "->", "questiontext", ";", "$", "error", "=", "'<b> ERROR</b>: Please check the form for this question. '", ";", "if", "(", "!", "$", "qtext", ")", "{", "echo", "$", "error", ".", "'The question text is empty!'", ";", "return", "false", ";", "}", "// Get the slots.", "$", "slots", "=", "$", "this", "->", "getEmbeddedTextArray", "(", "$", "question", ")", ";", "if", "(", "!", "$", "slots", ")", "{", "echo", "$", "error", ".", "'The question text is not in the correct format!'", ";", "return", "false", ";", "}", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "slots", "as", "$", "slot", ")", "{", "$", "output", "[", "]", "=", "substr", "(", "$", "slot", ",", "2", ",", "strlen", "(", "$", "slot", ")", "-", "4", ")", ";", "// 2 is for '[[' and 4 is for '[[]]'.", "}", "return", "$", "output", ";", "}" ]
Return the list of groups used in a question. @param stdClass $question the question data. @return array the groups used, or false if an error occurs.
[ "Return", "the", "list", "of", "groups", "used", "in", "a", "question", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/gapselect/questiontypebase.php#L258-L279
212,120
moodle/moodle
lib/completionlib.php
completion_info.is_enabled
public function is_enabled($cm = null) { global $CFG, $DB; // First check global completion if (!isset($CFG->enablecompletion) || $CFG->enablecompletion == COMPLETION_DISABLED) { return COMPLETION_DISABLED; } // Load data if we do not have enough if (!isset($this->course->enablecompletion)) { $this->course = get_course($this->course_id); } // Check course completion if ($this->course->enablecompletion == COMPLETION_DISABLED) { return COMPLETION_DISABLED; } // If there was no $cm and we got this far, then it's enabled if (!$cm) { return COMPLETION_ENABLED; } // Return course-module completion value return $cm->completion; }
php
public function is_enabled($cm = null) { global $CFG, $DB; // First check global completion if (!isset($CFG->enablecompletion) || $CFG->enablecompletion == COMPLETION_DISABLED) { return COMPLETION_DISABLED; } // Load data if we do not have enough if (!isset($this->course->enablecompletion)) { $this->course = get_course($this->course_id); } // Check course completion if ($this->course->enablecompletion == COMPLETION_DISABLED) { return COMPLETION_DISABLED; } // If there was no $cm and we got this far, then it's enabled if (!$cm) { return COMPLETION_ENABLED; } // Return course-module completion value return $cm->completion; }
[ "public", "function", "is_enabled", "(", "$", "cm", "=", "null", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "// First check global completion", "if", "(", "!", "isset", "(", "$", "CFG", "->", "enablecompletion", ")", "||", "$", "CFG", "->", "enablecompletion", "==", "COMPLETION_DISABLED", ")", "{", "return", "COMPLETION_DISABLED", ";", "}", "// Load data if we do not have enough", "if", "(", "!", "isset", "(", "$", "this", "->", "course", "->", "enablecompletion", ")", ")", "{", "$", "this", "->", "course", "=", "get_course", "(", "$", "this", "->", "course_id", ")", ";", "}", "// Check course completion", "if", "(", "$", "this", "->", "course", "->", "enablecompletion", "==", "COMPLETION_DISABLED", ")", "{", "return", "COMPLETION_DISABLED", ";", "}", "// If there was no $cm and we got this far, then it's enabled", "if", "(", "!", "$", "cm", ")", "{", "return", "COMPLETION_ENABLED", ";", "}", "// Return course-module completion value", "return", "$", "cm", "->", "completion", ";", "}" ]
Checks whether completion is enabled in a particular course and possibly activity. @param stdClass|cm_info $cm Course-module object. If not specified, returns the course completion enable state. @return mixed COMPLETION_ENABLED or COMPLETION_DISABLED (==0) in the case of site and course; COMPLETION_TRACKING_MANUAL, _AUTOMATIC or _NONE (==0) for a course-module.
[ "Checks", "whether", "completion", "is", "enabled", "in", "a", "particular", "course", "and", "possibly", "activity", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L279-L304
212,121
moodle/moodle
lib/completionlib.php
completion_info.display_help_icon
public function display_help_icon() { global $PAGE, $OUTPUT, $USER; $result = ''; if ($this->is_enabled() && !$PAGE->user_is_editing() && $this->is_tracked_user($USER->id) && isloggedin() && !isguestuser()) { $result .= html_writer::tag('div', get_string('yourprogress','completion') . $OUTPUT->help_icon('completionicons', 'completion'), array('id' => 'completionprogressid', 'class' => 'completionprogress')); } return $result; }
php
public function display_help_icon() { global $PAGE, $OUTPUT, $USER; $result = ''; if ($this->is_enabled() && !$PAGE->user_is_editing() && $this->is_tracked_user($USER->id) && isloggedin() && !isguestuser()) { $result .= html_writer::tag('div', get_string('yourprogress','completion') . $OUTPUT->help_icon('completionicons', 'completion'), array('id' => 'completionprogressid', 'class' => 'completionprogress')); } return $result; }
[ "public", "function", "display_help_icon", "(", ")", "{", "global", "$", "PAGE", ",", "$", "OUTPUT", ",", "$", "USER", ";", "$", "result", "=", "''", ";", "if", "(", "$", "this", "->", "is_enabled", "(", ")", "&&", "!", "$", "PAGE", "->", "user_is_editing", "(", ")", "&&", "$", "this", "->", "is_tracked_user", "(", "$", "USER", "->", "id", ")", "&&", "isloggedin", "(", ")", "&&", "!", "isguestuser", "(", ")", ")", "{", "$", "result", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "get_string", "(", "'yourprogress'", ",", "'completion'", ")", ".", "$", "OUTPUT", "->", "help_icon", "(", "'completionicons'", ",", "'completion'", ")", ",", "array", "(", "'id'", "=>", "'completionprogressid'", ",", "'class'", "=>", "'completionprogress'", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the 'Your progress' help icon, if completion tracking is enabled. @return string HTML code for help icon, or blank if not needed
[ "Returns", "the", "Your", "progress", "help", "icon", "if", "completion", "tracking", "is", "enabled", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L321-L331
212,122
moodle/moodle
lib/completionlib.php
completion_info.get_completion
public function get_completion($user_id, $criteriatype) { $completions = $this->get_completions($user_id, $criteriatype); if (empty($completions)) { return false; } elseif (count($completions) > 1) { print_error('multipleselfcompletioncriteria', 'completion'); } return $completions[0]; }
php
public function get_completion($user_id, $criteriatype) { $completions = $this->get_completions($user_id, $criteriatype); if (empty($completions)) { return false; } elseif (count($completions) > 1) { print_error('multipleselfcompletioncriteria', 'completion'); } return $completions[0]; }
[ "public", "function", "get_completion", "(", "$", "user_id", ",", "$", "criteriatype", ")", "{", "$", "completions", "=", "$", "this", "->", "get_completions", "(", "$", "user_id", ",", "$", "criteriatype", ")", ";", "if", "(", "empty", "(", "$", "completions", ")", ")", "{", "return", "false", ";", "}", "elseif", "(", "count", "(", "$", "completions", ")", ">", "1", ")", "{", "print_error", "(", "'multipleselfcompletioncriteria'", ",", "'completion'", ")", ";", "}", "return", "$", "completions", "[", "0", "]", ";", "}" ]
Get a course completion for a user @param int $user_id User id @param int $criteriatype Specific criteria type to return @return bool|completion_criteria_completion returns false on fail
[ "Get", "a", "course", "completion", "for", "a", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L340-L350
212,123
moodle/moodle
lib/completionlib.php
completion_info.get_completions
public function get_completions($user_id, $criteriatype = null) { $criteria = $this->get_criteria($criteriatype); $completions = array(); foreach ($criteria as $criterion) { $params = array( 'course' => $this->course_id, 'userid' => $user_id, 'criteriaid' => $criterion->id ); $completion = new completion_criteria_completion($params); $completion->attach_criteria($criterion); $completions[] = $completion; } return $completions; }
php
public function get_completions($user_id, $criteriatype = null) { $criteria = $this->get_criteria($criteriatype); $completions = array(); foreach ($criteria as $criterion) { $params = array( 'course' => $this->course_id, 'userid' => $user_id, 'criteriaid' => $criterion->id ); $completion = new completion_criteria_completion($params); $completion->attach_criteria($criterion); $completions[] = $completion; } return $completions; }
[ "public", "function", "get_completions", "(", "$", "user_id", ",", "$", "criteriatype", "=", "null", ")", "{", "$", "criteria", "=", "$", "this", "->", "get_criteria", "(", "$", "criteriatype", ")", ";", "$", "completions", "=", "array", "(", ")", ";", "foreach", "(", "$", "criteria", "as", "$", "criterion", ")", "{", "$", "params", "=", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ",", "'userid'", "=>", "$", "user_id", ",", "'criteriaid'", "=>", "$", "criterion", "->", "id", ")", ";", "$", "completion", "=", "new", "completion_criteria_completion", "(", "$", "params", ")", ";", "$", "completion", "->", "attach_criteria", "(", "$", "criterion", ")", ";", "$", "completions", "[", "]", "=", "$", "completion", ";", "}", "return", "$", "completions", ";", "}" ]
Get all course criteria's completion objects for a user @param int $user_id User id @param int $criteriatype Specific criteria type to return (optional) @return array
[ "Get", "all", "course", "criteria", "s", "completion", "objects", "for", "a", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L359-L378
212,124
moodle/moodle
lib/completionlib.php
completion_info.get_user_completion
public function get_user_completion($user_id, $criteria) { $params = array( 'course' => $this->course_id, 'userid' => $user_id, 'criteriaid' => $criteria->id, ); $completion = new completion_criteria_completion($params); return $completion; }
php
public function get_user_completion($user_id, $criteria) { $params = array( 'course' => $this->course_id, 'userid' => $user_id, 'criteriaid' => $criteria->id, ); $completion = new completion_criteria_completion($params); return $completion; }
[ "public", "function", "get_user_completion", "(", "$", "user_id", ",", "$", "criteria", ")", "{", "$", "params", "=", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ",", "'userid'", "=>", "$", "user_id", ",", "'criteriaid'", "=>", "$", "criteria", "->", "id", ",", ")", ";", "$", "completion", "=", "new", "completion_criteria_completion", "(", "$", "params", ")", ";", "return", "$", "completion", ";", "}" ]
Get completion object for a user and a criteria @param int $user_id User id @param completion_criteria $criteria Criteria object @return completion_criteria_completion
[ "Get", "completion", "object", "for", "a", "user", "and", "a", "criteria" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L387-L396
212,125
moodle/moodle
lib/completionlib.php
completion_info.get_criteria
public function get_criteria($criteriatype = null) { // Fill cache if empty if (!is_array($this->criteria)) { global $DB; $params = array( 'course' => $this->course->id ); // Load criteria from database $records = (array)$DB->get_records('course_completion_criteria', $params); // Order records so activities are in the same order as they appear on the course view page. if ($records) { $activitiesorder = array_keys(get_fast_modinfo($this->course)->get_cms()); usort($records, function ($a, $b) use ($activitiesorder) { $aidx = ($a->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ? array_search($a->moduleinstance, $activitiesorder) : false; $bidx = ($b->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ? array_search($b->moduleinstance, $activitiesorder) : false; if ($aidx === false || $bidx === false || $aidx == $bidx) { return 0; } return ($aidx < $bidx) ? -1 : 1; }); } // Build array of criteria objects $this->criteria = array(); foreach ($records as $record) { $this->criteria[$record->id] = completion_criteria::factory((array)$record); } } // If after all criteria if ($criteriatype === null) { return $this->criteria; } // If we are only after a specific criteria type $criteria = array(); foreach ($this->criteria as $criterion) { if ($criterion->criteriatype != $criteriatype) { continue; } $criteria[$criterion->id] = $criterion; } return $criteria; }
php
public function get_criteria($criteriatype = null) { // Fill cache if empty if (!is_array($this->criteria)) { global $DB; $params = array( 'course' => $this->course->id ); // Load criteria from database $records = (array)$DB->get_records('course_completion_criteria', $params); // Order records so activities are in the same order as they appear on the course view page. if ($records) { $activitiesorder = array_keys(get_fast_modinfo($this->course)->get_cms()); usort($records, function ($a, $b) use ($activitiesorder) { $aidx = ($a->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ? array_search($a->moduleinstance, $activitiesorder) : false; $bidx = ($b->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) ? array_search($b->moduleinstance, $activitiesorder) : false; if ($aidx === false || $bidx === false || $aidx == $bidx) { return 0; } return ($aidx < $bidx) ? -1 : 1; }); } // Build array of criteria objects $this->criteria = array(); foreach ($records as $record) { $this->criteria[$record->id] = completion_criteria::factory((array)$record); } } // If after all criteria if ($criteriatype === null) { return $this->criteria; } // If we are only after a specific criteria type $criteria = array(); foreach ($this->criteria as $criterion) { if ($criterion->criteriatype != $criteriatype) { continue; } $criteria[$criterion->id] = $criterion; } return $criteria; }
[ "public", "function", "get_criteria", "(", "$", "criteriatype", "=", "null", ")", "{", "// Fill cache if empty", "if", "(", "!", "is_array", "(", "$", "this", "->", "criteria", ")", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "array", "(", "'course'", "=>", "$", "this", "->", "course", "->", "id", ")", ";", "// Load criteria from database", "$", "records", "=", "(", "array", ")", "$", "DB", "->", "get_records", "(", "'course_completion_criteria'", ",", "$", "params", ")", ";", "// Order records so activities are in the same order as they appear on the course view page.", "if", "(", "$", "records", ")", "{", "$", "activitiesorder", "=", "array_keys", "(", "get_fast_modinfo", "(", "$", "this", "->", "course", ")", "->", "get_cms", "(", ")", ")", ";", "usort", "(", "$", "records", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "activitiesorder", ")", "{", "$", "aidx", "=", "(", "$", "a", "->", "criteriatype", "==", "COMPLETION_CRITERIA_TYPE_ACTIVITY", ")", "?", "array_search", "(", "$", "a", "->", "moduleinstance", ",", "$", "activitiesorder", ")", ":", "false", ";", "$", "bidx", "=", "(", "$", "b", "->", "criteriatype", "==", "COMPLETION_CRITERIA_TYPE_ACTIVITY", ")", "?", "array_search", "(", "$", "b", "->", "moduleinstance", ",", "$", "activitiesorder", ")", ":", "false", ";", "if", "(", "$", "aidx", "===", "false", "||", "$", "bidx", "===", "false", "||", "$", "aidx", "==", "$", "bidx", ")", "{", "return", "0", ";", "}", "return", "(", "$", "aidx", "<", "$", "bidx", ")", "?", "-", "1", ":", "1", ";", "}", ")", ";", "}", "// Build array of criteria objects", "$", "this", "->", "criteria", "=", "array", "(", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "this", "->", "criteria", "[", "$", "record", "->", "id", "]", "=", "completion_criteria", "::", "factory", "(", "(", "array", ")", "$", "record", ")", ";", "}", "}", "// If after all criteria", "if", "(", "$", "criteriatype", "===", "null", ")", "{", "return", "$", "this", "->", "criteria", ";", "}", "// If we are only after a specific criteria type", "$", "criteria", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "criteria", "as", "$", "criterion", ")", "{", "if", "(", "$", "criterion", "->", "criteriatype", "!=", "$", "criteriatype", ")", "{", "continue", ";", "}", "$", "criteria", "[", "$", "criterion", "->", "id", "]", "=", "$", "criterion", ";", "}", "return", "$", "criteria", ";", "}" ]
Get course completion criteria @param int $criteriatype Specific criteria type to return (optional)
[ "Get", "course", "completion", "criteria" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L414-L466
212,126
moodle/moodle
lib/completionlib.php
completion_info.get_aggregation_method
public function get_aggregation_method($criteriatype = null) { $params = array( 'course' => $this->course_id, 'criteriatype' => $criteriatype ); $aggregation = new completion_aggregation($params); if (!$aggregation->id) { $aggregation->method = COMPLETION_AGGREGATION_ALL; } return $aggregation->method; }
php
public function get_aggregation_method($criteriatype = null) { $params = array( 'course' => $this->course_id, 'criteriatype' => $criteriatype ); $aggregation = new completion_aggregation($params); if (!$aggregation->id) { $aggregation->method = COMPLETION_AGGREGATION_ALL; } return $aggregation->method; }
[ "public", "function", "get_aggregation_method", "(", "$", "criteriatype", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ",", "'criteriatype'", "=>", "$", "criteriatype", ")", ";", "$", "aggregation", "=", "new", "completion_aggregation", "(", "$", "params", ")", ";", "if", "(", "!", "$", "aggregation", "->", "id", ")", "{", "$", "aggregation", "->", "method", "=", "COMPLETION_AGGREGATION_ALL", ";", "}", "return", "$", "aggregation", "->", "method", ";", "}" ]
Get aggregation method @param int $criteriatype If none supplied, get overall aggregation method (optional) @return int One of COMPLETION_AGGREGATION_ALL or COMPLETION_AGGREGATION_ANY
[ "Get", "aggregation", "method" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L474-L487
212,127
moodle/moodle
lib/completionlib.php
completion_info.clear_criteria
public function clear_criteria() { global $DB; $DB->delete_records('course_completion_criteria', array('course' => $this->course_id)); $DB->delete_records('course_completion_aggr_methd', array('course' => $this->course_id)); $this->delete_course_completion_data(); }
php
public function clear_criteria() { global $DB; $DB->delete_records('course_completion_criteria', array('course' => $this->course_id)); $DB->delete_records('course_completion_aggr_methd', array('course' => $this->course_id)); $this->delete_course_completion_data(); }
[ "public", "function", "clear_criteria", "(", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records", "(", "'course_completion_criteria'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "'course_completion_aggr_methd'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ")", ")", ";", "$", "this", "->", "delete_course_completion_data", "(", ")", ";", "}" ]
Clear old course completion criteria
[ "Clear", "old", "course", "completion", "criteria" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L499-L505
212,128
moodle/moodle
lib/completionlib.php
completion_info.is_course_complete
public function is_course_complete($user_id) { $params = array( 'userid' => $user_id, 'course' => $this->course_id ); $ccompletion = new completion_completion($params); return $ccompletion->is_complete(); }
php
public function is_course_complete($user_id) { $params = array( 'userid' => $user_id, 'course' => $this->course_id ); $ccompletion = new completion_completion($params); return $ccompletion->is_complete(); }
[ "public", "function", "is_course_complete", "(", "$", "user_id", ")", "{", "$", "params", "=", "array", "(", "'userid'", "=>", "$", "user_id", ",", "'course'", "=>", "$", "this", "->", "course_id", ")", ";", "$", "ccompletion", "=", "new", "completion_completion", "(", "$", "params", ")", ";", "return", "$", "ccompletion", "->", "is_complete", "(", ")", ";", "}" ]
Has the supplied user completed this course @param int $user_id User's id @return boolean
[ "Has", "the", "supplied", "user", "completed", "this", "course" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L513-L521
212,129
moodle/moodle
lib/completionlib.php
completion_info.internal_get_state
public function internal_get_state($cm, $userid, $current) { global $USER, $DB, $CFG; // Get user ID if (!$userid) { $userid = $USER->id; } // Check viewed if ($cm->completionview == COMPLETION_VIEW_REQUIRED && $current->viewed == COMPLETION_NOT_VIEWED) { return COMPLETION_INCOMPLETE; } // Modname hopefully is provided in $cm but just in case it isn't, let's grab it if (!isset($cm->modname)) { $cm->modname = $DB->get_field('modules', 'name', array('id'=>$cm->module)); } $newstate = COMPLETION_COMPLETE; // Check grade if (!is_null($cm->completiongradeitemnumber)) { require_once($CFG->libdir.'/gradelib.php'); $item = grade_item::fetch(array('courseid'=>$cm->course, 'itemtype'=>'mod', 'itemmodule'=>$cm->modname, 'iteminstance'=>$cm->instance, 'itemnumber'=>$cm->completiongradeitemnumber)); if ($item) { // Fetch 'grades' (will be one or none) $grades = grade_grade::fetch_users_grades($item, array($userid), false); if (empty($grades)) { // No grade for user return COMPLETION_INCOMPLETE; } if (count($grades) > 1) { $this->internal_systemerror("Unexpected result: multiple grades for item '{$item->id}', user '{$userid}'"); } $newstate = self::internal_get_grade_state($item, reset($grades)); if ($newstate == COMPLETION_INCOMPLETE) { return COMPLETION_INCOMPLETE; } } else { $this->internal_systemerror("Cannot find grade item for '{$cm->modname}' cm '{$cm->id}' matching number '{$cm->completiongradeitemnumber}'"); } } if (plugin_supports('mod', $cm->modname, FEATURE_COMPLETION_HAS_RULES)) { $function = $cm->modname.'_get_completion_state'; if (!function_exists($function)) { $this->internal_systemerror("Module {$cm->modname} claims to support FEATURE_COMPLETION_HAS_RULES but does not have required {$cm->modname}_get_completion_state function"); } if (!$function($this->course, $cm, $userid, COMPLETION_AND)) { return COMPLETION_INCOMPLETE; } } return $newstate; }
php
public function internal_get_state($cm, $userid, $current) { global $USER, $DB, $CFG; // Get user ID if (!$userid) { $userid = $USER->id; } // Check viewed if ($cm->completionview == COMPLETION_VIEW_REQUIRED && $current->viewed == COMPLETION_NOT_VIEWED) { return COMPLETION_INCOMPLETE; } // Modname hopefully is provided in $cm but just in case it isn't, let's grab it if (!isset($cm->modname)) { $cm->modname = $DB->get_field('modules', 'name', array('id'=>$cm->module)); } $newstate = COMPLETION_COMPLETE; // Check grade if (!is_null($cm->completiongradeitemnumber)) { require_once($CFG->libdir.'/gradelib.php'); $item = grade_item::fetch(array('courseid'=>$cm->course, 'itemtype'=>'mod', 'itemmodule'=>$cm->modname, 'iteminstance'=>$cm->instance, 'itemnumber'=>$cm->completiongradeitemnumber)); if ($item) { // Fetch 'grades' (will be one or none) $grades = grade_grade::fetch_users_grades($item, array($userid), false); if (empty($grades)) { // No grade for user return COMPLETION_INCOMPLETE; } if (count($grades) > 1) { $this->internal_systemerror("Unexpected result: multiple grades for item '{$item->id}', user '{$userid}'"); } $newstate = self::internal_get_grade_state($item, reset($grades)); if ($newstate == COMPLETION_INCOMPLETE) { return COMPLETION_INCOMPLETE; } } else { $this->internal_systemerror("Cannot find grade item for '{$cm->modname}' cm '{$cm->id}' matching number '{$cm->completiongradeitemnumber}'"); } } if (plugin_supports('mod', $cm->modname, FEATURE_COMPLETION_HAS_RULES)) { $function = $cm->modname.'_get_completion_state'; if (!function_exists($function)) { $this->internal_systemerror("Module {$cm->modname} claims to support FEATURE_COMPLETION_HAS_RULES but does not have required {$cm->modname}_get_completion_state function"); } if (!$function($this->course, $cm, $userid, COMPLETION_AND)) { return COMPLETION_INCOMPLETE; } } return $newstate; }
[ "public", "function", "internal_get_state", "(", "$", "cm", ",", "$", "userid", ",", "$", "current", ")", "{", "global", "$", "USER", ",", "$", "DB", ",", "$", "CFG", ";", "// Get user ID", "if", "(", "!", "$", "userid", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "// Check viewed", "if", "(", "$", "cm", "->", "completionview", "==", "COMPLETION_VIEW_REQUIRED", "&&", "$", "current", "->", "viewed", "==", "COMPLETION_NOT_VIEWED", ")", "{", "return", "COMPLETION_INCOMPLETE", ";", "}", "// Modname hopefully is provided in $cm but just in case it isn't, let's grab it", "if", "(", "!", "isset", "(", "$", "cm", "->", "modname", ")", ")", "{", "$", "cm", "->", "modname", "=", "$", "DB", "->", "get_field", "(", "'modules'", ",", "'name'", ",", "array", "(", "'id'", "=>", "$", "cm", "->", "module", ")", ")", ";", "}", "$", "newstate", "=", "COMPLETION_COMPLETE", ";", "// Check grade", "if", "(", "!", "is_null", "(", "$", "cm", "->", "completiongradeitemnumber", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/gradelib.php'", ")", ";", "$", "item", "=", "grade_item", "::", "fetch", "(", "array", "(", "'courseid'", "=>", "$", "cm", "->", "course", ",", "'itemtype'", "=>", "'mod'", ",", "'itemmodule'", "=>", "$", "cm", "->", "modname", ",", "'iteminstance'", "=>", "$", "cm", "->", "instance", ",", "'itemnumber'", "=>", "$", "cm", "->", "completiongradeitemnumber", ")", ")", ";", "if", "(", "$", "item", ")", "{", "// Fetch 'grades' (will be one or none)", "$", "grades", "=", "grade_grade", "::", "fetch_users_grades", "(", "$", "item", ",", "array", "(", "$", "userid", ")", ",", "false", ")", ";", "if", "(", "empty", "(", "$", "grades", ")", ")", "{", "// No grade for user", "return", "COMPLETION_INCOMPLETE", ";", "}", "if", "(", "count", "(", "$", "grades", ")", ">", "1", ")", "{", "$", "this", "->", "internal_systemerror", "(", "\"Unexpected result: multiple grades for\n item '{$item->id}', user '{$userid}'\"", ")", ";", "}", "$", "newstate", "=", "self", "::", "internal_get_grade_state", "(", "$", "item", ",", "reset", "(", "$", "grades", ")", ")", ";", "if", "(", "$", "newstate", "==", "COMPLETION_INCOMPLETE", ")", "{", "return", "COMPLETION_INCOMPLETE", ";", "}", "}", "else", "{", "$", "this", "->", "internal_systemerror", "(", "\"Cannot find grade item for '{$cm->modname}'\n cm '{$cm->id}' matching number '{$cm->completiongradeitemnumber}'\"", ")", ";", "}", "}", "if", "(", "plugin_supports", "(", "'mod'", ",", "$", "cm", "->", "modname", ",", "FEATURE_COMPLETION_HAS_RULES", ")", ")", "{", "$", "function", "=", "$", "cm", "->", "modname", ".", "'_get_completion_state'", ";", "if", "(", "!", "function_exists", "(", "$", "function", ")", ")", "{", "$", "this", "->", "internal_systemerror", "(", "\"Module {$cm->modname} claims to support\n FEATURE_COMPLETION_HAS_RULES but does not have required\n {$cm->modname}_get_completion_state function\"", ")", ";", "}", "if", "(", "!", "$", "function", "(", "$", "this", "->", "course", ",", "$", "cm", ",", "$", "userid", ",", "COMPLETION_AND", ")", ")", "{", "return", "COMPLETION_INCOMPLETE", ";", "}", "}", "return", "$", "newstate", ";", "}" ]
Calculates the completion state for an activity and user. Internal function. Not private, so we can unit-test it. @param stdClass|cm_info $cm Activity @param int $userid ID of user @param stdClass $current Previous completion information from database @return mixed
[ "Calculates", "the", "completion", "state", "for", "an", "activity", "and", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L636-L700
212,130
moodle/moodle
lib/completionlib.php
completion_info.set_module_viewed
public function set_module_viewed($cm, $userid=0) { global $PAGE; if ($PAGE->headerprinted) { debugging('set_module_viewed must be called before header is printed', DEBUG_DEVELOPER); } // Don't do anything if view condition is not turned on if ($cm->completionview == COMPLETION_VIEW_NOT_REQUIRED || !$this->is_enabled($cm)) { return; } // Get current completion state $data = $this->get_data($cm, false, $userid); // If we already viewed it, don't do anything unless the completion status is overridden. // If the completion status is overridden, then we need to allow this 'view' to trigger automatic completion again. if ($data->viewed == COMPLETION_VIEWED && empty($data->overrideby)) { return; } // OK, change state, save it, and update completion $data->viewed = COMPLETION_VIEWED; $this->internal_set_data($cm, $data); $this->update_state($cm, COMPLETION_COMPLETE, $userid); }
php
public function set_module_viewed($cm, $userid=0) { global $PAGE; if ($PAGE->headerprinted) { debugging('set_module_viewed must be called before header is printed', DEBUG_DEVELOPER); } // Don't do anything if view condition is not turned on if ($cm->completionview == COMPLETION_VIEW_NOT_REQUIRED || !$this->is_enabled($cm)) { return; } // Get current completion state $data = $this->get_data($cm, false, $userid); // If we already viewed it, don't do anything unless the completion status is overridden. // If the completion status is overridden, then we need to allow this 'view' to trigger automatic completion again. if ($data->viewed == COMPLETION_VIEWED && empty($data->overrideby)) { return; } // OK, change state, save it, and update completion $data->viewed = COMPLETION_VIEWED; $this->internal_set_data($cm, $data); $this->update_state($cm, COMPLETION_COMPLETE, $userid); }
[ "public", "function", "set_module_viewed", "(", "$", "cm", ",", "$", "userid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "if", "(", "$", "PAGE", "->", "headerprinted", ")", "{", "debugging", "(", "'set_module_viewed must be called before header is printed'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "// Don't do anything if view condition is not turned on", "if", "(", "$", "cm", "->", "completionview", "==", "COMPLETION_VIEW_NOT_REQUIRED", "||", "!", "$", "this", "->", "is_enabled", "(", "$", "cm", ")", ")", "{", "return", ";", "}", "// Get current completion state", "$", "data", "=", "$", "this", "->", "get_data", "(", "$", "cm", ",", "false", ",", "$", "userid", ")", ";", "// If we already viewed it, don't do anything unless the completion status is overridden.", "// If the completion status is overridden, then we need to allow this 'view' to trigger automatic completion again.", "if", "(", "$", "data", "->", "viewed", "==", "COMPLETION_VIEWED", "&&", "empty", "(", "$", "data", "->", "overrideby", ")", ")", "{", "return", ";", "}", "// OK, change state, save it, and update completion", "$", "data", "->", "viewed", "=", "COMPLETION_VIEWED", ";", "$", "this", "->", "internal_set_data", "(", "$", "cm", ",", "$", "data", ")", ";", "$", "this", "->", "update_state", "(", "$", "cm", ",", "COMPLETION_COMPLETE", ",", "$", "userid", ")", ";", "}" ]
Marks a module as viewed. Should be called whenever a module is 'viewed' (it is up to the module how to determine that). Has no effect if viewing is not set as a completion condition. Note that this function must be called before you print the page header because it is possible that the navigation block may depend on it. If you call it after printing the header, it shows a developer debug warning. @param stdClass|cm_info $cm Activity @param int $userid User ID or 0 (default) for current user @return void
[ "Marks", "a", "module", "as", "viewed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L716-L741
212,131
moodle/moodle
lib/completionlib.php
completion_info.count_course_user_data
public function count_course_user_data($user_id = null) { global $DB; $sql = ' SELECT COUNT(1) FROM {course_completion_crit_compl} WHERE course = ? '; $params = array($this->course_id); // Limit data to a single user if an ID is supplied if ($user_id) { $sql .= ' AND userid = ?'; $params[] = $user_id; } return $DB->get_field_sql($sql, $params); }
php
public function count_course_user_data($user_id = null) { global $DB; $sql = ' SELECT COUNT(1) FROM {course_completion_crit_compl} WHERE course = ? '; $params = array($this->course_id); // Limit data to a single user if an ID is supplied if ($user_id) { $sql .= ' AND userid = ?'; $params[] = $user_id; } return $DB->get_field_sql($sql, $params); }
[ "public", "function", "count_course_user_data", "(", "$", "user_id", "=", "null", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "'\n SELECT\n COUNT(1)\n FROM\n {course_completion_crit_compl}\n WHERE\n course = ?\n '", ";", "$", "params", "=", "array", "(", "$", "this", "->", "course_id", ")", ";", "// Limit data to a single user if an ID is supplied", "if", "(", "$", "user_id", ")", "{", "$", "sql", ".=", "' AND userid = ?'", ";", "$", "params", "[", "]", "=", "$", "user_id", ";", "}", "return", "$", "DB", "->", "get_field_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Determines how much course completion data exists for a course. This is used when deciding whether completion information should be 'locked' in the completion settings form and activity completion settings. @param int $user_id Optionally only get course completion data for a single user @return int The number of users who have completion data stored for this course, 0 if none
[ "Determines", "how", "much", "course", "completion", "data", "exists", "for", "a", "course", ".", "This", "is", "used", "when", "deciding", "whether", "completion", "information", "should", "be", "locked", "in", "the", "completion", "settings", "form", "and", "activity", "completion", "settings", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L773-L794
212,132
moodle/moodle
lib/completionlib.php
completion_info.delete_course_completion_data
public function delete_course_completion_data() { global $DB; $DB->delete_records('course_completions', array('course' => $this->course_id)); $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id)); // Difficult to find affected users, just purge all completion cache. cache::make('core', 'completion')->purge(); cache::make('core', 'coursecompletion')->purge(); }
php
public function delete_course_completion_data() { global $DB; $DB->delete_records('course_completions', array('course' => $this->course_id)); $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id)); // Difficult to find affected users, just purge all completion cache. cache::make('core', 'completion')->purge(); cache::make('core', 'coursecompletion')->purge(); }
[ "public", "function", "delete_course_completion_data", "(", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records", "(", "'course_completions'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "'course_completion_crit_compl'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ")", ")", ";", "// Difficult to find affected users, just purge all completion cache.", "cache", "::", "make", "(", "'core'", ",", "'completion'", ")", "->", "purge", "(", ")", ";", "cache", "::", "make", "(", "'core'", ",", "'coursecompletion'", ")", "->", "purge", "(", ")", ";", "}" ]
Deletes all course completion completion data. Intended to be used when unlocking completion criteria settings.
[ "Deletes", "all", "course", "completion", "completion", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L810-L819
212,133
moodle/moodle
lib/completionlib.php
completion_info.delete_all_state
public function delete_all_state($cm) { global $DB; // Delete from database $DB->delete_records('course_modules_completion', array('coursemoduleid'=>$cm->id)); // Check if there is an associated course completion criteria $criteria = $this->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY); $acriteria = false; foreach ($criteria as $criterion) { if ($criterion->moduleinstance == $cm->id) { $acriteria = $criterion; break; } } if ($acriteria) { // Delete all criteria completions relating to this activity $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id, 'criteriaid' => $acriteria->id)); $DB->delete_records('course_completions', array('course' => $this->course_id)); } // Difficult to find affected users, just purge all completion cache. cache::make('core', 'completion')->purge(); cache::make('core', 'coursecompletion')->purge(); }
php
public function delete_all_state($cm) { global $DB; // Delete from database $DB->delete_records('course_modules_completion', array('coursemoduleid'=>$cm->id)); // Check if there is an associated course completion criteria $criteria = $this->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY); $acriteria = false; foreach ($criteria as $criterion) { if ($criterion->moduleinstance == $cm->id) { $acriteria = $criterion; break; } } if ($acriteria) { // Delete all criteria completions relating to this activity $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id, 'criteriaid' => $acriteria->id)); $DB->delete_records('course_completions', array('course' => $this->course_id)); } // Difficult to find affected users, just purge all completion cache. cache::make('core', 'completion')->purge(); cache::make('core', 'coursecompletion')->purge(); }
[ "public", "function", "delete_all_state", "(", "$", "cm", ")", "{", "global", "$", "DB", ";", "// Delete from database", "$", "DB", "->", "delete_records", "(", "'course_modules_completion'", ",", "array", "(", "'coursemoduleid'", "=>", "$", "cm", "->", "id", ")", ")", ";", "// Check if there is an associated course completion criteria", "$", "criteria", "=", "$", "this", "->", "get_criteria", "(", "COMPLETION_CRITERIA_TYPE_ACTIVITY", ")", ";", "$", "acriteria", "=", "false", ";", "foreach", "(", "$", "criteria", "as", "$", "criterion", ")", "{", "if", "(", "$", "criterion", "->", "moduleinstance", "==", "$", "cm", "->", "id", ")", "{", "$", "acriteria", "=", "$", "criterion", ";", "break", ";", "}", "}", "if", "(", "$", "acriteria", ")", "{", "// Delete all criteria completions relating to this activity", "$", "DB", "->", "delete_records", "(", "'course_completion_crit_compl'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ",", "'criteriaid'", "=>", "$", "acriteria", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "'course_completions'", ",", "array", "(", "'course'", "=>", "$", "this", "->", "course_id", ")", ")", ";", "}", "// Difficult to find affected users, just purge all completion cache.", "cache", "::", "make", "(", "'core'", ",", "'completion'", ")", "->", "purge", "(", ")", ";", "cache", "::", "make", "(", "'core'", ",", "'coursecompletion'", ")", "->", "purge", "(", ")", ";", "}" ]
Deletes completion state related to an activity for all users. Intended for use only when the activity itself is deleted. @param stdClass|cm_info $cm Activity
[ "Deletes", "completion", "state", "related", "to", "an", "activity", "for", "all", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L846-L871
212,134
moodle/moodle
lib/completionlib.php
completion_info.reset_all_state
public function reset_all_state($cm) { global $DB; if ($cm->completion == COMPLETION_TRACKING_MANUAL) { $this->delete_all_state($cm); return; } // Get current list of users with completion state $rs = $DB->get_recordset('course_modules_completion', array('coursemoduleid'=>$cm->id), '', 'userid'); $keepusers = array(); foreach ($rs as $rec) { $keepusers[] = $rec->userid; } $rs->close(); // Delete all existing state. $this->delete_all_state($cm); // Merge this with list of planned users (according to roles) $trackedusers = $this->get_tracked_users(); foreach ($trackedusers as $trackeduser) { $keepusers[] = $trackeduser->id; } $keepusers = array_unique($keepusers); // Recalculate state for each kept user foreach ($keepusers as $keepuser) { $this->update_state($cm, COMPLETION_UNKNOWN, $keepuser); } }
php
public function reset_all_state($cm) { global $DB; if ($cm->completion == COMPLETION_TRACKING_MANUAL) { $this->delete_all_state($cm); return; } // Get current list of users with completion state $rs = $DB->get_recordset('course_modules_completion', array('coursemoduleid'=>$cm->id), '', 'userid'); $keepusers = array(); foreach ($rs as $rec) { $keepusers[] = $rec->userid; } $rs->close(); // Delete all existing state. $this->delete_all_state($cm); // Merge this with list of planned users (according to roles) $trackedusers = $this->get_tracked_users(); foreach ($trackedusers as $trackeduser) { $keepusers[] = $trackeduser->id; } $keepusers = array_unique($keepusers); // Recalculate state for each kept user foreach ($keepusers as $keepuser) { $this->update_state($cm, COMPLETION_UNKNOWN, $keepuser); } }
[ "public", "function", "reset_all_state", "(", "$", "cm", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "cm", "->", "completion", "==", "COMPLETION_TRACKING_MANUAL", ")", "{", "$", "this", "->", "delete_all_state", "(", "$", "cm", ")", ";", "return", ";", "}", "// Get current list of users with completion state", "$", "rs", "=", "$", "DB", "->", "get_recordset", "(", "'course_modules_completion'", ",", "array", "(", "'coursemoduleid'", "=>", "$", "cm", "->", "id", ")", ",", "''", ",", "'userid'", ")", ";", "$", "keepusers", "=", "array", "(", ")", ";", "foreach", "(", "$", "rs", "as", "$", "rec", ")", "{", "$", "keepusers", "[", "]", "=", "$", "rec", "->", "userid", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "// Delete all existing state.", "$", "this", "->", "delete_all_state", "(", "$", "cm", ")", ";", "// Merge this with list of planned users (according to roles)", "$", "trackedusers", "=", "$", "this", "->", "get_tracked_users", "(", ")", ";", "foreach", "(", "$", "trackedusers", "as", "$", "trackeduser", ")", "{", "$", "keepusers", "[", "]", "=", "$", "trackeduser", "->", "id", ";", "}", "$", "keepusers", "=", "array_unique", "(", "$", "keepusers", ")", ";", "// Recalculate state for each kept user", "foreach", "(", "$", "keepusers", "as", "$", "keepuser", ")", "{", "$", "this", "->", "update_state", "(", "$", "cm", ",", "COMPLETION_UNKNOWN", ",", "$", "keepuser", ")", ";", "}", "}" ]
Recalculates completion state related to an activity for all users. Intended for use if completion conditions change. (This should be avoided as it may cause some things to become incomplete when they were previously complete, with the effect - for example - of hiding a later activity that was previously available.) Resetting state of manual tickbox has same result as deleting state for it. @param stcClass|cm_info $cm Activity
[ "Recalculates", "completion", "state", "related", "to", "an", "activity", "for", "all", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L886-L915
212,135
moodle/moodle
lib/completionlib.php
completion_info.has_activities
public function has_activities() { $modinfo = get_fast_modinfo($this->course); foreach ($modinfo->get_cms() as $cm) { if ($cm->completion != COMPLETION_TRACKING_NONE) { return true; } } return false; }
php
public function has_activities() { $modinfo = get_fast_modinfo($this->course); foreach ($modinfo->get_cms() as $cm) { if ($cm->completion != COMPLETION_TRACKING_NONE) { return true; } } return false; }
[ "public", "function", "has_activities", "(", ")", "{", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "this", "->", "course", ")", ";", "foreach", "(", "$", "modinfo", "->", "get_cms", "(", ")", "as", "$", "cm", ")", "{", "if", "(", "$", "cm", "->", "completion", "!=", "COMPLETION_TRACKING_NONE", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return whether or not the course has activities with completion enabled. @return boolean true when there is at least one activity with completion enabled.
[ "Return", "whether", "or", "not", "the", "course", "has", "activities", "with", "completion", "enabled", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1097-L1105
212,136
moodle/moodle
lib/completionlib.php
completion_info.get_activities
public function get_activities() { $modinfo = get_fast_modinfo($this->course); $result = array(); foreach ($modinfo->get_cms() as $cm) { if ($cm->completion != COMPLETION_TRACKING_NONE && !$cm->deletioninprogress) { $result[$cm->id] = $cm; } } return $result; }
php
public function get_activities() { $modinfo = get_fast_modinfo($this->course); $result = array(); foreach ($modinfo->get_cms() as $cm) { if ($cm->completion != COMPLETION_TRACKING_NONE && !$cm->deletioninprogress) { $result[$cm->id] = $cm; } } return $result; }
[ "public", "function", "get_activities", "(", ")", "{", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "this", "->", "course", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "modinfo", "->", "get_cms", "(", ")", "as", "$", "cm", ")", "{", "if", "(", "$", "cm", "->", "completion", "!=", "COMPLETION_TRACKING_NONE", "&&", "!", "$", "cm", "->", "deletioninprogress", ")", "{", "$", "result", "[", "$", "cm", "->", "id", "]", "=", "$", "cm", ";", "}", "}", "return", "$", "result", ";", "}" ]
Obtains a list of activities for which completion is enabled on the course. The list is ordered by the section order of those activities. @return cm_info[] Array from $cmid => $cm of all activities with completion enabled, empty array if none
[ "Obtains", "a", "list", "of", "activities", "for", "which", "completion", "is", "enabled", "on", "the", "course", ".", "The", "list", "is", "ordered", "by", "the", "section", "order", "of", "those", "activities", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1114-L1123
212,137
moodle/moodle
lib/completionlib.php
completion_info.is_tracked_user
public function is_tracked_user($userid) { return is_enrolled(context_course::instance($this->course->id), $userid, 'moodle/course:isincompletionreports', true); }
php
public function is_tracked_user($userid) { return is_enrolled(context_course::instance($this->course->id), $userid, 'moodle/course:isincompletionreports', true); }
[ "public", "function", "is_tracked_user", "(", "$", "userid", ")", "{", "return", "is_enrolled", "(", "context_course", "::", "instance", "(", "$", "this", "->", "course", "->", "id", ")", ",", "$", "userid", ",", "'moodle/course:isincompletionreports'", ",", "true", ")", ";", "}" ]
Checks to see if the userid supplied has a tracked role in this course @param int $userid User id @return bool
[ "Checks", "to", "see", "if", "the", "userid", "supplied", "has", "a", "tracked", "role", "in", "this", "course" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1132-L1134
212,138
moodle/moodle
lib/completionlib.php
completion_info.get_num_tracked_users
public function get_num_tracked_users($where = '', $whereparams = array(), $groupid = 0) { global $DB; list($enrolledsql, $enrolledparams) = get_enrolled_sql( context_course::instance($this->course->id), 'moodle/course:isincompletionreports', $groupid, true); $sql = 'SELECT COUNT(eu.id) FROM (' . $enrolledsql . ') eu JOIN {user} u ON u.id = eu.id'; if ($where) { $sql .= " WHERE $where"; } $params = array_merge($enrolledparams, $whereparams); return $DB->count_records_sql($sql, $params); }
php
public function get_num_tracked_users($where = '', $whereparams = array(), $groupid = 0) { global $DB; list($enrolledsql, $enrolledparams) = get_enrolled_sql( context_course::instance($this->course->id), 'moodle/course:isincompletionreports', $groupid, true); $sql = 'SELECT COUNT(eu.id) FROM (' . $enrolledsql . ') eu JOIN {user} u ON u.id = eu.id'; if ($where) { $sql .= " WHERE $where"; } $params = array_merge($enrolledparams, $whereparams); return $DB->count_records_sql($sql, $params); }
[ "public", "function", "get_num_tracked_users", "(", "$", "where", "=", "''", ",", "$", "whereparams", "=", "array", "(", ")", ",", "$", "groupid", "=", "0", ")", "{", "global", "$", "DB", ";", "list", "(", "$", "enrolledsql", ",", "$", "enrolledparams", ")", "=", "get_enrolled_sql", "(", "context_course", "::", "instance", "(", "$", "this", "->", "course", "->", "id", ")", ",", "'moodle/course:isincompletionreports'", ",", "$", "groupid", ",", "true", ")", ";", "$", "sql", "=", "'SELECT COUNT(eu.id) FROM ('", ".", "$", "enrolledsql", ".", "') eu JOIN {user} u ON u.id = eu.id'", ";", "if", "(", "$", "where", ")", "{", "$", "sql", ".=", "\" WHERE $where\"", ";", "}", "$", "params", "=", "array_merge", "(", "$", "enrolledparams", ",", "$", "whereparams", ")", ";", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Returns the number of users whose progress is tracked in this course. Optionally supply a search's where clause, or a group id. @param string $where Where clause sql (use 'u.whatever' for user table fields) @param array $whereparams Where clause params @param int $groupid Group id @return int Number of tracked users
[ "Returns", "the", "number", "of", "users", "whose", "progress", "is", "tracked", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1146-L1158
212,139
moodle/moodle
lib/completionlib.php
completion_info.get_tracked_users
public function get_tracked_users($where = '', $whereparams = array(), $groupid = 0, $sort = '', $limitfrom = '', $limitnum = '', context $extracontext = null) { global $DB; list($enrolledsql, $params) = get_enrolled_sql( context_course::instance($this->course->id), 'moodle/course:isincompletionreports', $groupid, true); $allusernames = get_all_user_name_fields(true, 'u'); $sql = 'SELECT u.id, u.idnumber, ' . $allusernames; if ($extracontext) { $sql .= get_extra_user_fields_sql($extracontext, 'u', '', array('idnumber')); } $sql .= ' FROM (' . $enrolledsql . ') eu JOIN {user} u ON u.id = eu.id'; if ($where) { $sql .= " AND $where"; $params = array_merge($params, $whereparams); } if ($sort) { $sql .= " ORDER BY $sort"; } return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); }
php
public function get_tracked_users($where = '', $whereparams = array(), $groupid = 0, $sort = '', $limitfrom = '', $limitnum = '', context $extracontext = null) { global $DB; list($enrolledsql, $params) = get_enrolled_sql( context_course::instance($this->course->id), 'moodle/course:isincompletionreports', $groupid, true); $allusernames = get_all_user_name_fields(true, 'u'); $sql = 'SELECT u.id, u.idnumber, ' . $allusernames; if ($extracontext) { $sql .= get_extra_user_fields_sql($extracontext, 'u', '', array('idnumber')); } $sql .= ' FROM (' . $enrolledsql . ') eu JOIN {user} u ON u.id = eu.id'; if ($where) { $sql .= " AND $where"; $params = array_merge($params, $whereparams); } if ($sort) { $sql .= " ORDER BY $sort"; } return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); }
[ "public", "function", "get_tracked_users", "(", "$", "where", "=", "''", ",", "$", "whereparams", "=", "array", "(", ")", ",", "$", "groupid", "=", "0", ",", "$", "sort", "=", "''", ",", "$", "limitfrom", "=", "''", ",", "$", "limitnum", "=", "''", ",", "context", "$", "extracontext", "=", "null", ")", "{", "global", "$", "DB", ";", "list", "(", "$", "enrolledsql", ",", "$", "params", ")", "=", "get_enrolled_sql", "(", "context_course", "::", "instance", "(", "$", "this", "->", "course", "->", "id", ")", ",", "'moodle/course:isincompletionreports'", ",", "$", "groupid", ",", "true", ")", ";", "$", "allusernames", "=", "get_all_user_name_fields", "(", "true", ",", "'u'", ")", ";", "$", "sql", "=", "'SELECT u.id, u.idnumber, '", ".", "$", "allusernames", ";", "if", "(", "$", "extracontext", ")", "{", "$", "sql", ".=", "get_extra_user_fields_sql", "(", "$", "extracontext", ",", "'u'", ",", "''", ",", "array", "(", "'idnumber'", ")", ")", ";", "}", "$", "sql", ".=", "' FROM ('", ".", "$", "enrolledsql", ".", "') eu JOIN {user} u ON u.id = eu.id'", ";", "if", "(", "$", "where", ")", "{", "$", "sql", ".=", "\" AND $where\"", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "whereparams", ")", ";", "}", "if", "(", "$", "sort", ")", "{", "$", "sql", ".=", "\" ORDER BY $sort\"", ";", "}", "return", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ",", "$", "limitfrom", ",", "$", "limitnum", ")", ";", "}" ]
Return array of users whose progress is tracked in this course. Optionally supply a search's where clause, group id, sorting, paging. @param string $where Where clause sql, referring to 'u.' fields (optional) @param array $whereparams Where clause params (optional) @param int $groupid Group ID to restrict to (optional) @param string $sort Order by clause (optional) @param int $limitfrom Result start (optional) @param int $limitnum Result max size (optional) @param context $extracontext If set, includes extra user information fields as appropriate to display for current user in this context @return array Array of user objects with standard user fields
[ "Return", "array", "of", "users", "whose", "progress", "is", "tracked", "in", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1175-L1201
212,140
moodle/moodle
lib/completionlib.php
completion_info.get_progress_all
public function get_progress_all($where = '', $where_params = array(), $groupid = 0, $sort = '', $pagesize = '', $start = '', context $extracontext = null) { global $CFG, $DB; // Get list of applicable users $users = $this->get_tracked_users($where, $where_params, $groupid, $sort, $start, $pagesize, $extracontext); // Get progress information for these users in groups of 1, 000 (if needed) // to avoid making the SQL IN too long $results = array(); $userids = array(); foreach ($users as $user) { $userids[] = $user->id; $results[$user->id] = $user; $results[$user->id]->progress = array(); } for($i=0; $i<count($userids); $i+=1000) { $blocksize = count($userids)-$i < 1000 ? count($userids)-$i : 1000; list($insql, $params) = $DB->get_in_or_equal(array_slice($userids, $i, $blocksize)); array_splice($params, 0, 0, array($this->course->id)); $rs = $DB->get_recordset_sql(" SELECT cmc.* FROM {course_modules} cm INNER JOIN {course_modules_completion} cmc ON cm.id=cmc.coursemoduleid WHERE cm.course=? AND cmc.userid $insql", $params); foreach ($rs as $progress) { $progress = (object)$progress; $results[$progress->userid]->progress[$progress->coursemoduleid] = $progress; } $rs->close(); } return $results; }
php
public function get_progress_all($where = '', $where_params = array(), $groupid = 0, $sort = '', $pagesize = '', $start = '', context $extracontext = null) { global $CFG, $DB; // Get list of applicable users $users = $this->get_tracked_users($where, $where_params, $groupid, $sort, $start, $pagesize, $extracontext); // Get progress information for these users in groups of 1, 000 (if needed) // to avoid making the SQL IN too long $results = array(); $userids = array(); foreach ($users as $user) { $userids[] = $user->id; $results[$user->id] = $user; $results[$user->id]->progress = array(); } for($i=0; $i<count($userids); $i+=1000) { $blocksize = count($userids)-$i < 1000 ? count($userids)-$i : 1000; list($insql, $params) = $DB->get_in_or_equal(array_slice($userids, $i, $blocksize)); array_splice($params, 0, 0, array($this->course->id)); $rs = $DB->get_recordset_sql(" SELECT cmc.* FROM {course_modules} cm INNER JOIN {course_modules_completion} cmc ON cm.id=cmc.coursemoduleid WHERE cm.course=? AND cmc.userid $insql", $params); foreach ($rs as $progress) { $progress = (object)$progress; $results[$progress->userid]->progress[$progress->coursemoduleid] = $progress; } $rs->close(); } return $results; }
[ "public", "function", "get_progress_all", "(", "$", "where", "=", "''", ",", "$", "where_params", "=", "array", "(", ")", ",", "$", "groupid", "=", "0", ",", "$", "sort", "=", "''", ",", "$", "pagesize", "=", "''", ",", "$", "start", "=", "''", ",", "context", "$", "extracontext", "=", "null", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "// Get list of applicable users", "$", "users", "=", "$", "this", "->", "get_tracked_users", "(", "$", "where", ",", "$", "where_params", ",", "$", "groupid", ",", "$", "sort", ",", "$", "start", ",", "$", "pagesize", ",", "$", "extracontext", ")", ";", "// Get progress information for these users in groups of 1, 000 (if needed)", "// to avoid making the SQL IN too long", "$", "results", "=", "array", "(", ")", ";", "$", "userids", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "userids", "[", "]", "=", "$", "user", "->", "id", ";", "$", "results", "[", "$", "user", "->", "id", "]", "=", "$", "user", ";", "$", "results", "[", "$", "user", "->", "id", "]", "->", "progress", "=", "array", "(", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "userids", ")", ";", "$", "i", "+=", "1000", ")", "{", "$", "blocksize", "=", "count", "(", "$", "userids", ")", "-", "$", "i", "<", "1000", "?", "count", "(", "$", "userids", ")", "-", "$", "i", ":", "1000", ";", "list", "(", "$", "insql", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_slice", "(", "$", "userids", ",", "$", "i", ",", "$", "blocksize", ")", ")", ";", "array_splice", "(", "$", "params", ",", "0", ",", "0", ",", "array", "(", "$", "this", "->", "course", "->", "id", ")", ")", ";", "$", "rs", "=", "$", "DB", "->", "get_recordset_sql", "(", "\"\n SELECT\n cmc.*\n FROM\n {course_modules} cm\n INNER JOIN {course_modules_completion} cmc ON cm.id=cmc.coursemoduleid\n WHERE\n cm.course=? AND cmc.userid $insql\"", ",", "$", "params", ")", ";", "foreach", "(", "$", "rs", "as", "$", "progress", ")", "{", "$", "progress", "=", "(", "object", ")", "$", "progress", ";", "$", "results", "[", "$", "progress", "->", "userid", "]", "->", "progress", "[", "$", "progress", "->", "coursemoduleid", "]", "=", "$", "progress", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "}", "return", "$", "results", ";", "}" ]
Obtains progress information across a course for all users on that course, or for all users in a specific group. Intended for use when displaying progress. This includes only users who, in course context, have one of the roles for which progress is tracked (the gradebookroles admin option) and are enrolled in course. Users are included (in the first array) even if they do not have completion progress for any course-module. @param bool $sortfirstname If true, sort by first name, otherwise sort by last name @param string $where Where clause sql (optional) @param array $where_params Where clause params (optional) @param int $groupid Group ID or 0 (default)/false for all groups @param int $pagesize Number of users to actually return (optional) @param int $start User to start at if paging (optional) @param context $extracontext If set, includes extra user information fields as appropriate to display for current user in this context @return stdClass with ->total and ->start (same as $start) and ->users; an array of user objects (like mdl_user id, firstname, lastname) containing an additional ->progress array of coursemoduleid => completionstate
[ "Obtains", "progress", "information", "across", "a", "course", "for", "all", "users", "on", "that", "course", "or", "for", "all", "users", "in", "a", "specific", "group", ".", "Intended", "for", "use", "when", "displaying", "progress", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1226-L1265
212,141
moodle/moodle
lib/completionlib.php
completion_info.inform_grade_changed
public function inform_grade_changed($cm, $item, $grade, $deleted) { // Bail out now if completion is not enabled for course-module, it is enabled // but is set to manual, grade is not used to compute completion, or this // is a different numbered grade if (!$this->is_enabled($cm) || $cm->completion == COMPLETION_TRACKING_MANUAL || is_null($cm->completiongradeitemnumber) || $item->itemnumber != $cm->completiongradeitemnumber) { return; } // What is the expected result based on this grade? if ($deleted) { // Grade being deleted, so only change could be to make it incomplete $possibleresult = COMPLETION_INCOMPLETE; } else { $possibleresult = self::internal_get_grade_state($item, $grade); } // OK, let's update state based on this $this->update_state($cm, $possibleresult, $grade->userid); }
php
public function inform_grade_changed($cm, $item, $grade, $deleted) { // Bail out now if completion is not enabled for course-module, it is enabled // but is set to manual, grade is not used to compute completion, or this // is a different numbered grade if (!$this->is_enabled($cm) || $cm->completion == COMPLETION_TRACKING_MANUAL || is_null($cm->completiongradeitemnumber) || $item->itemnumber != $cm->completiongradeitemnumber) { return; } // What is the expected result based on this grade? if ($deleted) { // Grade being deleted, so only change could be to make it incomplete $possibleresult = COMPLETION_INCOMPLETE; } else { $possibleresult = self::internal_get_grade_state($item, $grade); } // OK, let's update state based on this $this->update_state($cm, $possibleresult, $grade->userid); }
[ "public", "function", "inform_grade_changed", "(", "$", "cm", ",", "$", "item", ",", "$", "grade", ",", "$", "deleted", ")", "{", "// Bail out now if completion is not enabled for course-module, it is enabled", "// but is set to manual, grade is not used to compute completion, or this", "// is a different numbered grade", "if", "(", "!", "$", "this", "->", "is_enabled", "(", "$", "cm", ")", "||", "$", "cm", "->", "completion", "==", "COMPLETION_TRACKING_MANUAL", "||", "is_null", "(", "$", "cm", "->", "completiongradeitemnumber", ")", "||", "$", "item", "->", "itemnumber", "!=", "$", "cm", "->", "completiongradeitemnumber", ")", "{", "return", ";", "}", "// What is the expected result based on this grade?", "if", "(", "$", "deleted", ")", "{", "// Grade being deleted, so only change could be to make it incomplete", "$", "possibleresult", "=", "COMPLETION_INCOMPLETE", ";", "}", "else", "{", "$", "possibleresult", "=", "self", "::", "internal_get_grade_state", "(", "$", "item", ",", "$", "grade", ")", ";", "}", "// OK, let's update state based on this", "$", "this", "->", "update_state", "(", "$", "cm", ",", "$", "possibleresult", ",", "$", "grade", "->", "userid", ")", ";", "}" ]
Called by grade code to inform the completion system when a grade has been changed. If the changed grade is used to determine completion for the course-module, then the completion status will be updated. @param stdClass|cm_info $cm Course-module for item that owns grade @param grade_item $item Grade item @param stdClass $grade @param bool $deleted
[ "Called", "by", "grade", "code", "to", "inform", "the", "completion", "system", "when", "a", "grade", "has", "been", "changed", ".", "If", "the", "changed", "grade", "is", "used", "to", "determine", "completion", "for", "the", "course", "-", "module", "then", "the", "completion", "status", "will", "be", "updated", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/completionlib.php#L1277-L1298
212,142
moodle/moodle
enrol/cohort/locallib.php
enrol_cohort_handler.member_added
public static function member_added(\core\event\cohort_member_added $event) { global $DB, $CFG; require_once("$CFG->dirroot/group/lib.php"); if (!enrol_is_enabled('cohort')) { return true; } // Does any enabled cohort instance want to sync with this cohort? $sql = "SELECT e.*, r.id as roleexists FROM {enrol} e LEFT JOIN {role} r ON (r.id = e.roleid) WHERE e.customint1 = :cohortid AND e.enrol = 'cohort' AND e.status = :enrolstatus ORDER BY e.id ASC"; $params['cohortid'] = $event->objectid; $params['enrolstatus'] = ENROL_INSTANCE_ENABLED; if (!$instances = $DB->get_records_sql($sql, $params)) { return true; } $plugin = enrol_get_plugin('cohort'); foreach ($instances as $instance) { if ($instance->status != ENROL_INSTANCE_ENABLED ) { // No roles for disabled instances. $instance->roleid = 0; } else if ($instance->roleid and !$instance->roleexists) { // Invalid role - let's just enrol, they will have to create new sync and delete this one. $instance->roleid = 0; } unset($instance->roleexists); // No problem if already enrolled. $plugin->enrol_user($instance, $event->relateduserid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE); // Sync groups. if ($instance->customint2) { if (!groups_is_member($instance->customint2, $event->relateduserid)) { if ($group = $DB->get_record('groups', array('id'=>$instance->customint2, 'courseid'=>$instance->courseid))) { groups_add_member($group->id, $event->relateduserid, 'enrol_cohort', $instance->id); } } } } return true; }
php
public static function member_added(\core\event\cohort_member_added $event) { global $DB, $CFG; require_once("$CFG->dirroot/group/lib.php"); if (!enrol_is_enabled('cohort')) { return true; } // Does any enabled cohort instance want to sync with this cohort? $sql = "SELECT e.*, r.id as roleexists FROM {enrol} e LEFT JOIN {role} r ON (r.id = e.roleid) WHERE e.customint1 = :cohortid AND e.enrol = 'cohort' AND e.status = :enrolstatus ORDER BY e.id ASC"; $params['cohortid'] = $event->objectid; $params['enrolstatus'] = ENROL_INSTANCE_ENABLED; if (!$instances = $DB->get_records_sql($sql, $params)) { return true; } $plugin = enrol_get_plugin('cohort'); foreach ($instances as $instance) { if ($instance->status != ENROL_INSTANCE_ENABLED ) { // No roles for disabled instances. $instance->roleid = 0; } else if ($instance->roleid and !$instance->roleexists) { // Invalid role - let's just enrol, they will have to create new sync and delete this one. $instance->roleid = 0; } unset($instance->roleexists); // No problem if already enrolled. $plugin->enrol_user($instance, $event->relateduserid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE); // Sync groups. if ($instance->customint2) { if (!groups_is_member($instance->customint2, $event->relateduserid)) { if ($group = $DB->get_record('groups', array('id'=>$instance->customint2, 'courseid'=>$instance->courseid))) { groups_add_member($group->id, $event->relateduserid, 'enrol_cohort', $instance->id); } } } } return true; }
[ "public", "static", "function", "member_added", "(", "\\", "core", "\\", "event", "\\", "cohort_member_added", "$", "event", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "require_once", "(", "\"$CFG->dirroot/group/lib.php\"", ")", ";", "if", "(", "!", "enrol_is_enabled", "(", "'cohort'", ")", ")", "{", "return", "true", ";", "}", "// Does any enabled cohort instance want to sync with this cohort?", "$", "sql", "=", "\"SELECT e.*, r.id as roleexists\n FROM {enrol} e\n LEFT JOIN {role} r ON (r.id = e.roleid)\n WHERE e.customint1 = :cohortid AND e.enrol = 'cohort' AND e.status = :enrolstatus\n ORDER BY e.id ASC\"", ";", "$", "params", "[", "'cohortid'", "]", "=", "$", "event", "->", "objectid", ";", "$", "params", "[", "'enrolstatus'", "]", "=", "ENROL_INSTANCE_ENABLED", ";", "if", "(", "!", "$", "instances", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ")", ")", "{", "return", "true", ";", "}", "$", "plugin", "=", "enrol_get_plugin", "(", "'cohort'", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instance", ")", "{", "if", "(", "$", "instance", "->", "status", "!=", "ENROL_INSTANCE_ENABLED", ")", "{", "// No roles for disabled instances.", "$", "instance", "->", "roleid", "=", "0", ";", "}", "else", "if", "(", "$", "instance", "->", "roleid", "and", "!", "$", "instance", "->", "roleexists", ")", "{", "// Invalid role - let's just enrol, they will have to create new sync and delete this one.", "$", "instance", "->", "roleid", "=", "0", ";", "}", "unset", "(", "$", "instance", "->", "roleexists", ")", ";", "// No problem if already enrolled.", "$", "plugin", "->", "enrol_user", "(", "$", "instance", ",", "$", "event", "->", "relateduserid", ",", "$", "instance", "->", "roleid", ",", "0", ",", "0", ",", "ENROL_USER_ACTIVE", ")", ";", "// Sync groups.", "if", "(", "$", "instance", "->", "customint2", ")", "{", "if", "(", "!", "groups_is_member", "(", "$", "instance", "->", "customint2", ",", "$", "event", "->", "relateduserid", ")", ")", "{", "if", "(", "$", "group", "=", "$", "DB", "->", "get_record", "(", "'groups'", ",", "array", "(", "'id'", "=>", "$", "instance", "->", "customint2", ",", "'courseid'", "=>", "$", "instance", "->", "courseid", ")", ")", ")", "{", "groups_add_member", "(", "$", "group", "->", "id", ",", "$", "event", "->", "relateduserid", ",", "'enrol_cohort'", ",", "$", "instance", "->", "id", ")", ";", "}", "}", "}", "}", "return", "true", ";", "}" ]
Event processor - cohort member added. @param \core\event\cohort_member_added $event @return bool
[ "Event", "processor", "-", "cohort", "member", "added", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/enrol/cohort/locallib.php#L43-L87
212,143
moodle/moodle
enrol/cohort/locallib.php
enrol_cohort_handler.member_removed
public static function member_removed(\core\event\cohort_member_removed $event) { global $DB; // Does anything want to sync with this cohort? if (!$instances = $DB->get_records('enrol', array('customint1'=>$event->objectid, 'enrol'=>'cohort'), 'id ASC')) { return true; } $plugin = enrol_get_plugin('cohort'); $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL); foreach ($instances as $instance) { if (!$ue = $DB->get_record('user_enrolments', array('enrolid'=>$instance->id, 'userid'=>$event->relateduserid))) { continue; } if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) { $plugin->unenrol_user($instance, $event->relateduserid); } else { if ($ue->status != ENROL_USER_SUSPENDED) { $plugin->update_user_enrol($instance, $ue->userid, ENROL_USER_SUSPENDED); $context = context_course::instance($instance->courseid); role_unassign_all(array('userid'=>$ue->userid, 'contextid'=>$context->id, 'component'=>'enrol_cohort', 'itemid'=>$instance->id)); } } } return true; }
php
public static function member_removed(\core\event\cohort_member_removed $event) { global $DB; // Does anything want to sync with this cohort? if (!$instances = $DB->get_records('enrol', array('customint1'=>$event->objectid, 'enrol'=>'cohort'), 'id ASC')) { return true; } $plugin = enrol_get_plugin('cohort'); $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL); foreach ($instances as $instance) { if (!$ue = $DB->get_record('user_enrolments', array('enrolid'=>$instance->id, 'userid'=>$event->relateduserid))) { continue; } if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) { $plugin->unenrol_user($instance, $event->relateduserid); } else { if ($ue->status != ENROL_USER_SUSPENDED) { $plugin->update_user_enrol($instance, $ue->userid, ENROL_USER_SUSPENDED); $context = context_course::instance($instance->courseid); role_unassign_all(array('userid'=>$ue->userid, 'contextid'=>$context->id, 'component'=>'enrol_cohort', 'itemid'=>$instance->id)); } } } return true; }
[ "public", "static", "function", "member_removed", "(", "\\", "core", "\\", "event", "\\", "cohort_member_removed", "$", "event", ")", "{", "global", "$", "DB", ";", "// Does anything want to sync with this cohort?", "if", "(", "!", "$", "instances", "=", "$", "DB", "->", "get_records", "(", "'enrol'", ",", "array", "(", "'customint1'", "=>", "$", "event", "->", "objectid", ",", "'enrol'", "=>", "'cohort'", ")", ",", "'id ASC'", ")", ")", "{", "return", "true", ";", "}", "$", "plugin", "=", "enrol_get_plugin", "(", "'cohort'", ")", ";", "$", "unenrolaction", "=", "$", "plugin", "->", "get_config", "(", "'unenrolaction'", ",", "ENROL_EXT_REMOVED_UNENROL", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instance", ")", "{", "if", "(", "!", "$", "ue", "=", "$", "DB", "->", "get_record", "(", "'user_enrolments'", ",", "array", "(", "'enrolid'", "=>", "$", "instance", "->", "id", ",", "'userid'", "=>", "$", "event", "->", "relateduserid", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "unenrolaction", "==", "ENROL_EXT_REMOVED_UNENROL", ")", "{", "$", "plugin", "->", "unenrol_user", "(", "$", "instance", ",", "$", "event", "->", "relateduserid", ")", ";", "}", "else", "{", "if", "(", "$", "ue", "->", "status", "!=", "ENROL_USER_SUSPENDED", ")", "{", "$", "plugin", "->", "update_user_enrol", "(", "$", "instance", ",", "$", "ue", "->", "userid", ",", "ENROL_USER_SUSPENDED", ")", ";", "$", "context", "=", "context_course", "::", "instance", "(", "$", "instance", "->", "courseid", ")", ";", "role_unassign_all", "(", "array", "(", "'userid'", "=>", "$", "ue", "->", "userid", ",", "'contextid'", "=>", "$", "context", "->", "id", ",", "'component'", "=>", "'enrol_cohort'", ",", "'itemid'", "=>", "$", "instance", "->", "id", ")", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Event processor - cohort member removed. @param \core\event\cohort_member_removed $event @return bool
[ "Event", "processor", "-", "cohort", "member", "removed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/enrol/cohort/locallib.php#L94-L122
212,144
moodle/moodle
enrol/cohort/locallib.php
enrol_cohort_handler.deleted
public static function deleted(\core\event\cohort_deleted $event) { global $DB; // Does anything want to sync with this cohort? if (!$instances = $DB->get_records('enrol', array('customint1'=>$event->objectid, 'enrol'=>'cohort'), 'id ASC')) { return true; } $plugin = enrol_get_plugin('cohort'); $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL); foreach ($instances as $instance) { if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) { $context = context_course::instance($instance->courseid); role_unassign_all(array('contextid'=>$context->id, 'component'=>'enrol_cohort', 'itemid'=>$instance->id)); $plugin->update_status($instance, ENROL_INSTANCE_DISABLED); } else { $plugin->delete_instance($instance); } } return true; }
php
public static function deleted(\core\event\cohort_deleted $event) { global $DB; // Does anything want to sync with this cohort? if (!$instances = $DB->get_records('enrol', array('customint1'=>$event->objectid, 'enrol'=>'cohort'), 'id ASC')) { return true; } $plugin = enrol_get_plugin('cohort'); $unenrolaction = $plugin->get_config('unenrolaction', ENROL_EXT_REMOVED_UNENROL); foreach ($instances as $instance) { if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) { $context = context_course::instance($instance->courseid); role_unassign_all(array('contextid'=>$context->id, 'component'=>'enrol_cohort', 'itemid'=>$instance->id)); $plugin->update_status($instance, ENROL_INSTANCE_DISABLED); } else { $plugin->delete_instance($instance); } } return true; }
[ "public", "static", "function", "deleted", "(", "\\", "core", "\\", "event", "\\", "cohort_deleted", "$", "event", ")", "{", "global", "$", "DB", ";", "// Does anything want to sync with this cohort?", "if", "(", "!", "$", "instances", "=", "$", "DB", "->", "get_records", "(", "'enrol'", ",", "array", "(", "'customint1'", "=>", "$", "event", "->", "objectid", ",", "'enrol'", "=>", "'cohort'", ")", ",", "'id ASC'", ")", ")", "{", "return", "true", ";", "}", "$", "plugin", "=", "enrol_get_plugin", "(", "'cohort'", ")", ";", "$", "unenrolaction", "=", "$", "plugin", "->", "get_config", "(", "'unenrolaction'", ",", "ENROL_EXT_REMOVED_UNENROL", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instance", ")", "{", "if", "(", "$", "unenrolaction", "==", "ENROL_EXT_REMOVED_SUSPENDNOROLES", ")", "{", "$", "context", "=", "context_course", "::", "instance", "(", "$", "instance", "->", "courseid", ")", ";", "role_unassign_all", "(", "array", "(", "'contextid'", "=>", "$", "context", "->", "id", ",", "'component'", "=>", "'enrol_cohort'", ",", "'itemid'", "=>", "$", "instance", "->", "id", ")", ")", ";", "$", "plugin", "->", "update_status", "(", "$", "instance", ",", "ENROL_INSTANCE_DISABLED", ")", ";", "}", "else", "{", "$", "plugin", "->", "delete_instance", "(", "$", "instance", ")", ";", "}", "}", "return", "true", ";", "}" ]
Event processor - cohort deleted. @param \core\event\cohort_deleted $event @return bool
[ "Event", "processor", "-", "cohort", "deleted", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/enrol/cohort/locallib.php#L129-L151
212,145
moodle/moodle
mod/workshop/eval/best/backup/moodle2/backup_workshopeval_best_subplugin.class.php
backup_workshopeval_best_subplugin.define_workshop_subplugin_structure
protected function define_workshop_subplugin_structure() { // create XML elements $subplugin = $this->get_subplugin_element(); // virtual optigroup element $subplugin_wrapper = new backup_nested_element($this->get_recommended_name()); $subplugin_table_settings = new backup_nested_element('workshopeval_best_settings', null, array('comparison')); // connect XML elements into the tree $subplugin->add_child($subplugin_wrapper); $subplugin_wrapper->add_child($subplugin_table_settings); // set source to populate the data $subplugin_table_settings->set_source_table('workshopeval_best_settings', array('workshopid' => backup::VAR_ACTIVITYID)); return $subplugin; }
php
protected function define_workshop_subplugin_structure() { // create XML elements $subplugin = $this->get_subplugin_element(); // virtual optigroup element $subplugin_wrapper = new backup_nested_element($this->get_recommended_name()); $subplugin_table_settings = new backup_nested_element('workshopeval_best_settings', null, array('comparison')); // connect XML elements into the tree $subplugin->add_child($subplugin_wrapper); $subplugin_wrapper->add_child($subplugin_table_settings); // set source to populate the data $subplugin_table_settings->set_source_table('workshopeval_best_settings', array('workshopid' => backup::VAR_ACTIVITYID)); return $subplugin; }
[ "protected", "function", "define_workshop_subplugin_structure", "(", ")", "{", "// create XML elements", "$", "subplugin", "=", "$", "this", "->", "get_subplugin_element", "(", ")", ";", "// virtual optigroup element", "$", "subplugin_wrapper", "=", "new", "backup_nested_element", "(", "$", "this", "->", "get_recommended_name", "(", ")", ")", ";", "$", "subplugin_table_settings", "=", "new", "backup_nested_element", "(", "'workshopeval_best_settings'", ",", "null", ",", "array", "(", "'comparison'", ")", ")", ";", "// connect XML elements into the tree", "$", "subplugin", "->", "add_child", "(", "$", "subplugin_wrapper", ")", ";", "$", "subplugin_wrapper", "->", "add_child", "(", "$", "subplugin_table_settings", ")", ";", "// set source to populate the data", "$", "subplugin_table_settings", "->", "set_source_table", "(", "'workshopeval_best_settings'", ",", "array", "(", "'workshopid'", "=>", "backup", "::", "VAR_ACTIVITYID", ")", ")", ";", "return", "$", "subplugin", ";", "}" ]
Returns the subplugin information to attach to workshop element
[ "Returns", "the", "subplugin", "information", "to", "attach", "to", "workshop", "element" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/eval/best/backup/moodle2/backup_workshopeval_best_subplugin.class.php#L37-L52
212,146
moodle/moodle
lib/classes/output/mustache_user_date_helper.php
mustache_user_date_helper.transform
public function transform($args, Mustache_LambdaHelper $helper) { // Split the text into an array of variables. list($timestamp, $format) = explode(',', $args, 2); $timestamp = trim($timestamp); $format = trim($format); $timestamp = $helper->render($timestamp); $format = $helper->render($format); return userdate($timestamp, $format); }
php
public function transform($args, Mustache_LambdaHelper $helper) { // Split the text into an array of variables. list($timestamp, $format) = explode(',', $args, 2); $timestamp = trim($timestamp); $format = trim($format); $timestamp = $helper->render($timestamp); $format = $helper->render($format); return userdate($timestamp, $format); }
[ "public", "function", "transform", "(", "$", "args", ",", "Mustache_LambdaHelper", "$", "helper", ")", "{", "// Split the text into an array of variables.", "list", "(", "$", "timestamp", ",", "$", "format", ")", "=", "explode", "(", "','", ",", "$", "args", ",", "2", ")", ";", "$", "timestamp", "=", "trim", "(", "$", "timestamp", ")", ";", "$", "format", "=", "trim", "(", "$", "format", ")", ";", "$", "timestamp", "=", "$", "helper", "->", "render", "(", "$", "timestamp", ")", ";", "$", "format", "=", "$", "helper", "->", "render", "(", "$", "format", ")", ";", "return", "userdate", "(", "$", "timestamp", ",", "$", "format", ")", ";", "}" ]
Read a timestamp and format from the string. {{#userdate}}1487655635, %Y %m %d{{/userdate}} There is a list of formats in lang/en/langconfig.php that can be used as the date format. Both args are required. The timestamp must come first. @param string $args The text to parse for arguments. @param Mustache_LambdaHelper $helper Used to render nested mustache variables. @return string
[ "Read", "a", "timestamp", "and", "format", "from", "the", "string", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/output/mustache_user_date_helper.php#L53-L63
212,147
moodle/moodle
cache/stores/mongodb/MongoDB/GridFS/Exception/FileNotFoundException.php
FileNotFoundException.byId
public static function byId($id, $namespace) { $json = \MongoDB\BSON\toJSON(\MongoDB\BSON\fromPHP(['_id' => $id])); return new static(sprintf('File "%s" not found in "%s"', $json, $namespace)); }
php
public static function byId($id, $namespace) { $json = \MongoDB\BSON\toJSON(\MongoDB\BSON\fromPHP(['_id' => $id])); return new static(sprintf('File "%s" not found in "%s"', $json, $namespace)); }
[ "public", "static", "function", "byId", "(", "$", "id", ",", "$", "namespace", ")", "{", "$", "json", "=", "\\", "MongoDB", "\\", "BSON", "\\", "toJSON", "(", "\\", "MongoDB", "\\", "BSON", "\\", "fromPHP", "(", "[", "'_id'", "=>", "$", "id", "]", ")", ")", ";", "return", "new", "static", "(", "sprintf", "(", "'File \"%s\" not found in \"%s\"'", ",", "$", "json", ",", "$", "namespace", ")", ")", ";", "}" ]
Thrown when a file cannot be found by its ID. @param mixed $id File ID @param string $namespace Namespace for the files collection @return self
[ "Thrown", "when", "a", "file", "cannot", "be", "found", "by", "its", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/GridFS/Exception/FileNotFoundException.php#L44-L49
212,148
moodle/moodle
admin/tool/monitor/classes/output/managerules/renderable.php
renderable.col_manage
public function col_manage(\tool_monitor\rule $rule) { global $OUTPUT, $CFG; $manage = ''; // Do not allow the user to edit the rule unless they have the system capability, or we are viewing the rules // for a course, and not the site. Note - we don't need to check for the capability at a course level since // the user is never shown this page otherwise. if ($this->hassystemcap || ($rule->courseid != 0)) { $editurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('ruleid' => $rule->id, 'courseid' => $rule->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/edit', get_string('editrule', 'tool_monitor'))); $manage .= \html_writer::link($editurl, $icon, array('class' => 'action-icon')); } // The user should always be able to copy the rule if they are able to view the page. $copyurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'copy', 'courseid' => $this->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/copy', get_string('duplicaterule', 'tool_monitor'))); $manage .= \html_writer::link($copyurl, $icon, array('class' => 'action-icon')); if ($this->hassystemcap || ($rule->courseid != 0)) { $deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'delete', 'courseid' => $rule->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/delete', get_string('deleterule', 'tool_monitor'))); $manage .= \html_writer::link($deleteurl, $icon, array('class' => 'action-icon')); } return $manage; }
php
public function col_manage(\tool_monitor\rule $rule) { global $OUTPUT, $CFG; $manage = ''; // Do not allow the user to edit the rule unless they have the system capability, or we are viewing the rules // for a course, and not the site. Note - we don't need to check for the capability at a course level since // the user is never shown this page otherwise. if ($this->hassystemcap || ($rule->courseid != 0)) { $editurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('ruleid' => $rule->id, 'courseid' => $rule->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/edit', get_string('editrule', 'tool_monitor'))); $manage .= \html_writer::link($editurl, $icon, array('class' => 'action-icon')); } // The user should always be able to copy the rule if they are able to view the page. $copyurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'copy', 'courseid' => $this->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/copy', get_string('duplicaterule', 'tool_monitor'))); $manage .= \html_writer::link($copyurl, $icon, array('class' => 'action-icon')); if ($this->hassystemcap || ($rule->courseid != 0)) { $deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id, 'action' => 'delete', 'courseid' => $rule->courseid, 'sesskey' => sesskey())); $icon = $OUTPUT->render(new \pix_icon('t/delete', get_string('deleterule', 'tool_monitor'))); $manage .= \html_writer::link($deleteurl, $icon, array('class' => 'action-icon')); } return $manage; }
[ "public", "function", "col_manage", "(", "\\", "tool_monitor", "\\", "rule", "$", "rule", ")", "{", "global", "$", "OUTPUT", ",", "$", "CFG", ";", "$", "manage", "=", "''", ";", "// Do not allow the user to edit the rule unless they have the system capability, or we are viewing the rules", "// for a course, and not the site. Note - we don't need to check for the capability at a course level since", "// the user is never shown this page otherwise.", "if", "(", "$", "this", "->", "hassystemcap", "||", "(", "$", "rule", "->", "courseid", "!=", "0", ")", ")", "{", "$", "editurl", "=", "new", "\\", "moodle_url", "(", "$", "CFG", "->", "wwwroot", ".", "'/admin/tool/monitor/edit.php'", ",", "array", "(", "'ruleid'", "=>", "$", "rule", "->", "id", ",", "'courseid'", "=>", "$", "rule", "->", "courseid", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "icon", "=", "$", "OUTPUT", "->", "render", "(", "new", "\\", "pix_icon", "(", "'t/edit'", ",", "get_string", "(", "'editrule'", ",", "'tool_monitor'", ")", ")", ")", ";", "$", "manage", ".=", "\\", "html_writer", "::", "link", "(", "$", "editurl", ",", "$", "icon", ",", "array", "(", "'class'", "=>", "'action-icon'", ")", ")", ";", "}", "// The user should always be able to copy the rule if they are able to view the page.", "$", "copyurl", "=", "new", "\\", "moodle_url", "(", "$", "CFG", "->", "wwwroot", ".", "'/admin/tool/monitor/managerules.php'", ",", "array", "(", "'ruleid'", "=>", "$", "rule", "->", "id", ",", "'action'", "=>", "'copy'", ",", "'courseid'", "=>", "$", "this", "->", "courseid", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "icon", "=", "$", "OUTPUT", "->", "render", "(", "new", "\\", "pix_icon", "(", "'t/copy'", ",", "get_string", "(", "'duplicaterule'", ",", "'tool_monitor'", ")", ")", ")", ";", "$", "manage", ".=", "\\", "html_writer", "::", "link", "(", "$", "copyurl", ",", "$", "icon", ",", "array", "(", "'class'", "=>", "'action-icon'", ")", ")", ";", "if", "(", "$", "this", "->", "hassystemcap", "||", "(", "$", "rule", "->", "courseid", "!=", "0", ")", ")", "{", "$", "deleteurl", "=", "new", "\\", "moodle_url", "(", "$", "CFG", "->", "wwwroot", ".", "'/admin/tool/monitor/managerules.php'", ",", "array", "(", "'ruleid'", "=>", "$", "rule", "->", "id", ",", "'action'", "=>", "'delete'", ",", "'courseid'", "=>", "$", "rule", "->", "courseid", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "icon", "=", "$", "OUTPUT", "->", "render", "(", "new", "\\", "pix_icon", "(", "'t/delete'", ",", "get_string", "(", "'deleterule'", ",", "'tool_monitor'", ")", ")", ")", ";", "$", "manage", ".=", "\\", "html_writer", "::", "link", "(", "$", "deleteurl", ",", "$", "icon", ",", "array", "(", "'class'", "=>", "'action-icon'", ")", ")", ";", "}", "return", "$", "manage", ";", "}" ]
Generate content for manage column. @param \tool_monitor\rule $rule rule object @return string html used to display the manage column field.
[ "Generate", "content", "for", "manage", "column", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/monitor/classes/output/managerules/renderable.php#L165-L194
212,149
moodle/moodle
mnet/peer.php
mnet_peer.set_wwwroot
function set_wwwroot($wwwroot) { global $CFG, $DB; $hostinfo = $DB->get_record('mnet_host', array('wwwroot'=>$wwwroot)); if ($hostinfo != false) { $this->populate($hostinfo); return true; } return false; }
php
function set_wwwroot($wwwroot) { global $CFG, $DB; $hostinfo = $DB->get_record('mnet_host', array('wwwroot'=>$wwwroot)); if ($hostinfo != false) { $this->populate($hostinfo); return true; } return false; }
[ "function", "set_wwwroot", "(", "$", "wwwroot", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "$", "hostinfo", "=", "$", "DB", "->", "get_record", "(", "'mnet_host'", ",", "array", "(", "'wwwroot'", "=>", "$", "wwwroot", ")", ")", ";", "if", "(", "$", "hostinfo", "!=", "false", ")", "{", "$", "this", "->", "populate", "(", "$", "hostinfo", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Load information from db about an mnet peer into this object's properties @param string $wwwroot - address of peer whose details we want to load @return bool - indication of success or failure
[ "Load", "information", "from", "db", "about", "an", "mnet", "peer", "into", "this", "object", "s", "properties" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/peer.php#L241-L251
212,150
moodle/moodle
mnet/peer.php
mnet_peer.populate
function populate($hostinfo) { global $DB; $this->id = $hostinfo->id; $this->wwwroot = $hostinfo->wwwroot; $this->ip_address = $hostinfo->ip_address; $this->name = $hostinfo->name; $this->deleted = $hostinfo->deleted; $this->public_key = $hostinfo->public_key; $this->public_key_expires = $hostinfo->public_key_expires; $this->last_connect_time = $hostinfo->last_connect_time; $this->last_log_id = $hostinfo->last_log_id; $this->force_theme = $hostinfo->force_theme; $this->theme = $hostinfo->theme; $this->applicationid = $hostinfo->applicationid; $this->sslverification = $hostinfo->sslverification; $this->application = $DB->get_record('mnet_application', array('id'=>$this->applicationid)); $this->bootstrapped = true; }
php
function populate($hostinfo) { global $DB; $this->id = $hostinfo->id; $this->wwwroot = $hostinfo->wwwroot; $this->ip_address = $hostinfo->ip_address; $this->name = $hostinfo->name; $this->deleted = $hostinfo->deleted; $this->public_key = $hostinfo->public_key; $this->public_key_expires = $hostinfo->public_key_expires; $this->last_connect_time = $hostinfo->last_connect_time; $this->last_log_id = $hostinfo->last_log_id; $this->force_theme = $hostinfo->force_theme; $this->theme = $hostinfo->theme; $this->applicationid = $hostinfo->applicationid; $this->sslverification = $hostinfo->sslverification; $this->application = $DB->get_record('mnet_application', array('id'=>$this->applicationid)); $this->bootstrapped = true; }
[ "function", "populate", "(", "$", "hostinfo", ")", "{", "global", "$", "DB", ";", "$", "this", "->", "id", "=", "$", "hostinfo", "->", "id", ";", "$", "this", "->", "wwwroot", "=", "$", "hostinfo", "->", "wwwroot", ";", "$", "this", "->", "ip_address", "=", "$", "hostinfo", "->", "ip_address", ";", "$", "this", "->", "name", "=", "$", "hostinfo", "->", "name", ";", "$", "this", "->", "deleted", "=", "$", "hostinfo", "->", "deleted", ";", "$", "this", "->", "public_key", "=", "$", "hostinfo", "->", "public_key", ";", "$", "this", "->", "public_key_expires", "=", "$", "hostinfo", "->", "public_key_expires", ";", "$", "this", "->", "last_connect_time", "=", "$", "hostinfo", "->", "last_connect_time", ";", "$", "this", "->", "last_log_id", "=", "$", "hostinfo", "->", "last_log_id", ";", "$", "this", "->", "force_theme", "=", "$", "hostinfo", "->", "force_theme", ";", "$", "this", "->", "theme", "=", "$", "hostinfo", "->", "theme", ";", "$", "this", "->", "applicationid", "=", "$", "hostinfo", "->", "applicationid", ";", "$", "this", "->", "sslverification", "=", "$", "hostinfo", "->", "sslverification", ";", "$", "this", "->", "application", "=", "$", "DB", "->", "get_record", "(", "'mnet_application'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "applicationid", ")", ")", ";", "$", "this", "->", "bootstrapped", "=", "true", ";", "}" ]
Several methods can be used to get an 'mnet_host' record. They all then send it to this private method to populate this object's attributes. @param object $hostinfo A database record from the mnet_host table @return void
[ "Several", "methods", "can", "be", "used", "to", "get", "an", "mnet_host", "record", ".", "They", "all", "then", "send", "it", "to", "this", "private", "method", "to", "populate", "this", "object", "s", "attributes", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mnet/peer.php#L284-L301
212,151
moodle/moodle
mod/lesson/backup/moodle2/restore_lesson_activity_task.class.php
restore_lesson_activity_task.define_decode_rules
static public function define_decode_rules() { $rules = array(); $rules[] = new restore_decode_rule('LESSONEDIT', '/mod/lesson/edit.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONESAY', '/mod/lesson/essay.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONREPORT', '/mod/lesson/report.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONMEDIAFILE', '/mod/lesson/mediafile.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONVIEWBYID', '/mod/lesson/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONINDEX', '/mod/lesson/index.php?id=$1', 'course'); $rules[] = new restore_decode_rule('LESSONVIEWPAGE', '/mod/lesson/view.php?id=$1&pageid=$2', array('course_module', 'lesson_page')); $rules[] = new restore_decode_rule('LESSONEDITPAGE', '/mod/lesson/edit.php?id=$1&pageid=$2', array('course_module', 'lesson_page')); return $rules; }
php
static public function define_decode_rules() { $rules = array(); $rules[] = new restore_decode_rule('LESSONEDIT', '/mod/lesson/edit.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONESAY', '/mod/lesson/essay.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONREPORT', '/mod/lesson/report.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONMEDIAFILE', '/mod/lesson/mediafile.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONVIEWBYID', '/mod/lesson/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('LESSONINDEX', '/mod/lesson/index.php?id=$1', 'course'); $rules[] = new restore_decode_rule('LESSONVIEWPAGE', '/mod/lesson/view.php?id=$1&pageid=$2', array('course_module', 'lesson_page')); $rules[] = new restore_decode_rule('LESSONEDITPAGE', '/mod/lesson/edit.php?id=$1&pageid=$2', array('course_module', 'lesson_page')); return $rules; }
[ "static", "public", "function", "define_decode_rules", "(", ")", "{", "$", "rules", "=", "array", "(", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONEDIT'", ",", "'/mod/lesson/edit.php?id=$1'", ",", "'course_module'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONESAY'", ",", "'/mod/lesson/essay.php?id=$1'", ",", "'course_module'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONREPORT'", ",", "'/mod/lesson/report.php?id=$1'", ",", "'course_module'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONMEDIAFILE'", ",", "'/mod/lesson/mediafile.php?id=$1'", ",", "'course_module'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONVIEWBYID'", ",", "'/mod/lesson/view.php?id=$1'", ",", "'course_module'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONINDEX'", ",", "'/mod/lesson/index.php?id=$1'", ",", "'course'", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONVIEWPAGE'", ",", "'/mod/lesson/view.php?id=$1&pageid=$2'", ",", "array", "(", "'course_module'", ",", "'lesson_page'", ")", ")", ";", "$", "rules", "[", "]", "=", "new", "restore_decode_rule", "(", "'LESSONEDITPAGE'", ",", "'/mod/lesson/edit.php?id=$1&pageid=$2'", ",", "array", "(", "'course_module'", ",", "'lesson_page'", ")", ")", ";", "return", "$", "rules", ";", "}" ]
Define the decoding rules for links belonging to the activity to be executed by the link decoder
[ "Define", "the", "decoding", "rules", "for", "links", "belonging", "to", "the", "activity", "to", "be", "executed", "by", "the", "link", "decoder" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/backup/moodle2/restore_lesson_activity_task.class.php#L68-L82
212,152
moodle/moodle
lib/classes/analytics/analyser/student_enrolments.php
student_enrolments.get_all_samples
public function get_all_samples(\core_analytics\analysable $course) { $enrolments = enrol_get_course_users($course->get_id()); // We fetch all enrolments, but we are only interested in students. $studentids = $course->get_students(); $samplesdata = array(); foreach ($enrolments as $userenrolmentid => $user) { if (empty($studentids[$user->id])) { // Not a student. continue; } $sampleid = $userenrolmentid; $samplesdata[$sampleid]['user_enrolments'] = (object)array( 'id' => $user->ueid, 'status' => $user->uestatus, 'enrolid' => $user->ueenrolid, 'userid' => $user->id, 'timestart' => $user->uetimestart, 'timeend' => $user->uetimeend, 'modifierid' => $user->uemodifierid, 'timecreated' => $user->uetimecreated, 'timemodified' => $user->uetimemodified ); unset($user->ueid); unset($user->uestatus); unset($user->ueenrolid); unset($user->uetimestart); unset($user->uetimeend); unset($user->uemodifierid); unset($user->uetimecreated); unset($user->uetimemodified); $samplesdata[$sampleid]['course'] = $course->get_course_data(); $samplesdata[$sampleid]['context'] = $course->get_context(); $samplesdata[$sampleid]['user'] = $user; // Fill the cache. $this->samplecourses[$sampleid] = $course->get_id(); } $enrolids = array_keys($samplesdata); return array(array_combine($enrolids, $enrolids), $samplesdata); }
php
public function get_all_samples(\core_analytics\analysable $course) { $enrolments = enrol_get_course_users($course->get_id()); // We fetch all enrolments, but we are only interested in students. $studentids = $course->get_students(); $samplesdata = array(); foreach ($enrolments as $userenrolmentid => $user) { if (empty($studentids[$user->id])) { // Not a student. continue; } $sampleid = $userenrolmentid; $samplesdata[$sampleid]['user_enrolments'] = (object)array( 'id' => $user->ueid, 'status' => $user->uestatus, 'enrolid' => $user->ueenrolid, 'userid' => $user->id, 'timestart' => $user->uetimestart, 'timeend' => $user->uetimeend, 'modifierid' => $user->uemodifierid, 'timecreated' => $user->uetimecreated, 'timemodified' => $user->uetimemodified ); unset($user->ueid); unset($user->uestatus); unset($user->ueenrolid); unset($user->uetimestart); unset($user->uetimeend); unset($user->uemodifierid); unset($user->uetimecreated); unset($user->uetimemodified); $samplesdata[$sampleid]['course'] = $course->get_course_data(); $samplesdata[$sampleid]['context'] = $course->get_context(); $samplesdata[$sampleid]['user'] = $user; // Fill the cache. $this->samplecourses[$sampleid] = $course->get_id(); } $enrolids = array_keys($samplesdata); return array(array_combine($enrolids, $enrolids), $samplesdata); }
[ "public", "function", "get_all_samples", "(", "\\", "core_analytics", "\\", "analysable", "$", "course", ")", "{", "$", "enrolments", "=", "enrol_get_course_users", "(", "$", "course", "->", "get_id", "(", ")", ")", ";", "// We fetch all enrolments, but we are only interested in students.", "$", "studentids", "=", "$", "course", "->", "get_students", "(", ")", ";", "$", "samplesdata", "=", "array", "(", ")", ";", "foreach", "(", "$", "enrolments", "as", "$", "userenrolmentid", "=>", "$", "user", ")", "{", "if", "(", "empty", "(", "$", "studentids", "[", "$", "user", "->", "id", "]", ")", ")", "{", "// Not a student.", "continue", ";", "}", "$", "sampleid", "=", "$", "userenrolmentid", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'user_enrolments'", "]", "=", "(", "object", ")", "array", "(", "'id'", "=>", "$", "user", "->", "ueid", ",", "'status'", "=>", "$", "user", "->", "uestatus", ",", "'enrolid'", "=>", "$", "user", "->", "ueenrolid", ",", "'userid'", "=>", "$", "user", "->", "id", ",", "'timestart'", "=>", "$", "user", "->", "uetimestart", ",", "'timeend'", "=>", "$", "user", "->", "uetimeend", ",", "'modifierid'", "=>", "$", "user", "->", "uemodifierid", ",", "'timecreated'", "=>", "$", "user", "->", "uetimecreated", ",", "'timemodified'", "=>", "$", "user", "->", "uetimemodified", ")", ";", "unset", "(", "$", "user", "->", "ueid", ")", ";", "unset", "(", "$", "user", "->", "uestatus", ")", ";", "unset", "(", "$", "user", "->", "ueenrolid", ")", ";", "unset", "(", "$", "user", "->", "uetimestart", ")", ";", "unset", "(", "$", "user", "->", "uetimeend", ")", ";", "unset", "(", "$", "user", "->", "uemodifierid", ")", ";", "unset", "(", "$", "user", "->", "uetimecreated", ")", ";", "unset", "(", "$", "user", "->", "uetimemodified", ")", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'course'", "]", "=", "$", "course", "->", "get_course_data", "(", ")", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'context'", "]", "=", "$", "course", "->", "get_context", "(", ")", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'user'", "]", "=", "$", "user", ";", "// Fill the cache.", "$", "this", "->", "samplecourses", "[", "$", "sampleid", "]", "=", "$", "course", "->", "get_id", "(", ")", ";", "}", "$", "enrolids", "=", "array_keys", "(", "$", "samplesdata", ")", ";", "return", "array", "(", "array_combine", "(", "$", "enrolids", ",", "$", "enrolids", ")", ",", "$", "samplesdata", ")", ";", "}" ]
All course student enrolments. It does return all student enrolments including the suspended ones. @param \core_analytics\analysable $course @return array
[ "All", "course", "student", "enrolments", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/student_enrolments.php#L114-L160
212,153
moodle/moodle
lib/classes/analytics/analyser/student_enrolments.php
student_enrolments.get_samples
public function get_samples($sampleids) { global $DB; $enrolments = enrol_get_course_users(false, false, array(), $sampleids); // Some course enrolments. list($enrolsql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED); $samplesdata = array(); foreach ($enrolments as $userenrolmentid => $user) { $sampleid = $userenrolmentid; $samplesdata[$sampleid]['user_enrolments'] = (object)array( 'id' => $user->ueid, 'status' => $user->uestatus, 'enrolid' => $user->ueenrolid, 'userid' => $user->id, 'timestart' => $user->uetimestart, 'timeend' => $user->uetimeend, 'modifierid' => $user->uemodifierid, 'timecreated' => $user->uetimecreated, 'timemodified' => $user->uetimemodified ); unset($user->ueid); unset($user->uestatus); unset($user->ueenrolid); unset($user->uetimestart); unset($user->uetimeend); unset($user->uemodifierid); unset($user->uetimecreated); unset($user->uetimemodified); // Enrolment samples are grouped by the course they belong to, so all $sampleids belong to the same // course, $courseid and $coursemodinfo will only query the DB once and cache the course data in memory. $courseid = $this->get_sample_courseid($sampleid); $coursemodinfo = get_fast_modinfo($courseid); $coursecontext = \context_course::instance($courseid); $samplesdata[$sampleid]['course'] = $coursemodinfo->get_course(); $samplesdata[$sampleid]['context'] = $coursecontext; $samplesdata[$sampleid]['user'] = $user; // Fill the cache. $this->samplecourses[$sampleid] = $coursemodinfo->get_course()->id; } $enrolids = array_keys($samplesdata); return array(array_combine($enrolids, $enrolids), $samplesdata); }
php
public function get_samples($sampleids) { global $DB; $enrolments = enrol_get_course_users(false, false, array(), $sampleids); // Some course enrolments. list($enrolsql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED); $samplesdata = array(); foreach ($enrolments as $userenrolmentid => $user) { $sampleid = $userenrolmentid; $samplesdata[$sampleid]['user_enrolments'] = (object)array( 'id' => $user->ueid, 'status' => $user->uestatus, 'enrolid' => $user->ueenrolid, 'userid' => $user->id, 'timestart' => $user->uetimestart, 'timeend' => $user->uetimeend, 'modifierid' => $user->uemodifierid, 'timecreated' => $user->uetimecreated, 'timemodified' => $user->uetimemodified ); unset($user->ueid); unset($user->uestatus); unset($user->ueenrolid); unset($user->uetimestart); unset($user->uetimeend); unset($user->uemodifierid); unset($user->uetimecreated); unset($user->uetimemodified); // Enrolment samples are grouped by the course they belong to, so all $sampleids belong to the same // course, $courseid and $coursemodinfo will only query the DB once and cache the course data in memory. $courseid = $this->get_sample_courseid($sampleid); $coursemodinfo = get_fast_modinfo($courseid); $coursecontext = \context_course::instance($courseid); $samplesdata[$sampleid]['course'] = $coursemodinfo->get_course(); $samplesdata[$sampleid]['context'] = $coursecontext; $samplesdata[$sampleid]['user'] = $user; // Fill the cache. $this->samplecourses[$sampleid] = $coursemodinfo->get_course()->id; } $enrolids = array_keys($samplesdata); return array(array_combine($enrolids, $enrolids), $samplesdata); }
[ "public", "function", "get_samples", "(", "$", "sampleids", ")", "{", "global", "$", "DB", ";", "$", "enrolments", "=", "enrol_get_course_users", "(", "false", ",", "false", ",", "array", "(", ")", ",", "$", "sampleids", ")", ";", "// Some course enrolments.", "list", "(", "$", "enrolsql", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "sampleids", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "samplesdata", "=", "array", "(", ")", ";", "foreach", "(", "$", "enrolments", "as", "$", "userenrolmentid", "=>", "$", "user", ")", "{", "$", "sampleid", "=", "$", "userenrolmentid", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'user_enrolments'", "]", "=", "(", "object", ")", "array", "(", "'id'", "=>", "$", "user", "->", "ueid", ",", "'status'", "=>", "$", "user", "->", "uestatus", ",", "'enrolid'", "=>", "$", "user", "->", "ueenrolid", ",", "'userid'", "=>", "$", "user", "->", "id", ",", "'timestart'", "=>", "$", "user", "->", "uetimestart", ",", "'timeend'", "=>", "$", "user", "->", "uetimeend", ",", "'modifierid'", "=>", "$", "user", "->", "uemodifierid", ",", "'timecreated'", "=>", "$", "user", "->", "uetimecreated", ",", "'timemodified'", "=>", "$", "user", "->", "uetimemodified", ")", ";", "unset", "(", "$", "user", "->", "ueid", ")", ";", "unset", "(", "$", "user", "->", "uestatus", ")", ";", "unset", "(", "$", "user", "->", "ueenrolid", ")", ";", "unset", "(", "$", "user", "->", "uetimestart", ")", ";", "unset", "(", "$", "user", "->", "uetimeend", ")", ";", "unset", "(", "$", "user", "->", "uemodifierid", ")", ";", "unset", "(", "$", "user", "->", "uetimecreated", ")", ";", "unset", "(", "$", "user", "->", "uetimemodified", ")", ";", "// Enrolment samples are grouped by the course they belong to, so all $sampleids belong to the same", "// course, $courseid and $coursemodinfo will only query the DB once and cache the course data in memory.", "$", "courseid", "=", "$", "this", "->", "get_sample_courseid", "(", "$", "sampleid", ")", ";", "$", "coursemodinfo", "=", "get_fast_modinfo", "(", "$", "courseid", ")", ";", "$", "coursecontext", "=", "\\", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'course'", "]", "=", "$", "coursemodinfo", "->", "get_course", "(", ")", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'context'", "]", "=", "$", "coursecontext", ";", "$", "samplesdata", "[", "$", "sampleid", "]", "[", "'user'", "]", "=", "$", "user", ";", "// Fill the cache.", "$", "this", "->", "samplecourses", "[", "$", "sampleid", "]", "=", "$", "coursemodinfo", "->", "get_course", "(", ")", "->", "id", ";", "}", "$", "enrolids", "=", "array_keys", "(", "$", "samplesdata", ")", ";", "return", "array", "(", "array_combine", "(", "$", "enrolids", ",", "$", "enrolids", ")", ",", "$", "samplesdata", ")", ";", "}" ]
Returns all samples from the samples ids. @param int[] $sampleids @return array
[ "Returns", "all", "samples", "from", "the", "samples", "ids", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/student_enrolments.php#L168-L216
212,154
moodle/moodle
lib/classes/analytics/analyser/student_enrolments.php
student_enrolments.get_sample_courseid
protected function get_sample_courseid($sampleid) { global $DB; if (empty($this->samplecourses[$sampleid])) { $course = enrol_get_course_by_user_enrolment_id($sampleid); $this->samplecourses[$sampleid] = $course->id; } return $this->samplecourses[$sampleid]; }
php
protected function get_sample_courseid($sampleid) { global $DB; if (empty($this->samplecourses[$sampleid])) { $course = enrol_get_course_by_user_enrolment_id($sampleid); $this->samplecourses[$sampleid] = $course->id; } return $this->samplecourses[$sampleid]; }
[ "protected", "function", "get_sample_courseid", "(", "$", "sampleid", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "this", "->", "samplecourses", "[", "$", "sampleid", "]", ")", ")", "{", "$", "course", "=", "enrol_get_course_by_user_enrolment_id", "(", "$", "sampleid", ")", ";", "$", "this", "->", "samplecourses", "[", "$", "sampleid", "]", "=", "$", "course", "->", "id", ";", "}", "return", "$", "this", "->", "samplecourses", "[", "$", "sampleid", "]", ";", "}" ]
Returns the student enrolment course id. @param int $sampleid @return int
[ "Returns", "the", "student", "enrolment", "course", "id", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/student_enrolments.php#L224-L233
212,155
moodle/moodle
lib/google/src/Google/Service/MapsEngine.php
Google_Service_MapsEngine_LayersPermissions_Resource.batchUpdate
public function batchUpdate($id, Google_Service_MapsEngine_PermissionsBatchUpdateRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchUpdate', array($params), "Google_Service_MapsEngine_PermissionsBatchUpdateResponse"); }
php
public function batchUpdate($id, Google_Service_MapsEngine_PermissionsBatchUpdateRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchUpdate', array($params), "Google_Service_MapsEngine_PermissionsBatchUpdateResponse"); }
[ "public", "function", "batchUpdate", "(", "$", "id", ",", "Google_Service_MapsEngine_PermissionsBatchUpdateRequest", "$", "postBody", ",", "$", "optParams", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'postBody'", "=>", "$", "postBody", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "optParams", ")", ";", "return", "$", "this", "->", "call", "(", "'batchUpdate'", ",", "array", "(", "$", "params", ")", ",", "\"Google_Service_MapsEngine_PermissionsBatchUpdateResponse\"", ")", ";", "}" ]
Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic. (permissions.batchUpdate) @param string $id The ID of the asset to which permissions will be added. @param Google_PermissionsBatchUpdateRequest $postBody @param array $optParams Optional parameters. @return Google_Service_MapsEngine_PermissionsBatchUpdateResponse
[ "Add", "or", "update", "permission", "entries", "to", "an", "already", "existing", "asset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Service/MapsEngine.php#L1943-L1948
212,156
moodle/moodle
lib/google/src/Google/Service/MapsEngine.php
Google_Service_MapsEngine_TablesFeatures_Resource.batchInsert
public function batchInsert($id, Google_Service_MapsEngine_FeaturesBatchInsertRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchInsert', array($params)); }
php
public function batchInsert($id, Google_Service_MapsEngine_FeaturesBatchInsertRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchInsert', array($params)); }
[ "public", "function", "batchInsert", "(", "$", "id", ",", "Google_Service_MapsEngine_FeaturesBatchInsertRequest", "$", "postBody", ",", "$", "optParams", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'postBody'", "=>", "$", "postBody", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "optParams", ")", ";", "return", "$", "this", "->", "call", "(", "'batchInsert'", ",", "array", "(", "$", "params", ")", ")", ";", "}" ]
Append features to an existing table. A single batchInsert request can create: - Up to 50 features. - A combined total of 10 000 vertices. Feature limits are documented in the Supported data formats and limits article of the Google Maps Engine help center. Note that free and paid accounts have different limits. For more information about inserting features, read Creating features in the Google Maps Engine developer's guide. (features.batchInsert) @param string $id The ID of the table to append the features to. @param Google_FeaturesBatchInsertRequest $postBody @param array $optParams Optional parameters.
[ "Append", "features", "to", "an", "existing", "table", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Service/MapsEngine.php#L3080-L3085
212,157
moodle/moodle
lib/google/src/Google/Service/MapsEngine.php
Google_Service_MapsEngine_TablesFeatures_Resource.batchPatch
public function batchPatch($id, Google_Service_MapsEngine_FeaturesBatchPatchRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchPatch', array($params)); }
php
public function batchPatch($id, Google_Service_MapsEngine_FeaturesBatchPatchRequest $postBody, $optParams = array()) { $params = array('id' => $id, 'postBody' => $postBody); $params = array_merge($params, $optParams); return $this->call('batchPatch', array($params)); }
[ "public", "function", "batchPatch", "(", "$", "id", ",", "Google_Service_MapsEngine_FeaturesBatchPatchRequest", "$", "postBody", ",", "$", "optParams", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "id", ",", "'postBody'", "=>", "$", "postBody", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "optParams", ")", ";", "return", "$", "this", "->", "call", "(", "'batchPatch'", ",", "array", "(", "$", "params", ")", ")", ";", "}" ]
Update the supplied features. A single batchPatch request can update: - Up to 50 features. - A combined total of 10 000 vertices. Feature limits are documented in the Supported data formats and limits article of the Google Maps Engine help center. Note that free and paid accounts have different limits. Feature updates use HTTP PATCH semantics: - A supplied value replaces an existing value (if any) in that field. - Omitted fields remain unchanged. - Complex values in geometries and properties must be replaced as atomic units. For example, providing just the coordinates of a geometry is not allowed; the complete geometry, including type, must be supplied. - Setting a property's value to null deletes that property. For more information about updating features, read Updating features in the Google Maps Engine developer's guide. (features.batchPatch) @param string $id The ID of the table containing the features to be patched. @param Google_FeaturesBatchPatchRequest $postBody @param array $optParams Optional parameters.
[ "Update", "the", "supplied", "features", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/google/src/Google/Service/MapsEngine.php#L3111-L3116
212,158
moodle/moodle
lib/classes/event/tag_added.php
tag_added.create_from_tag_instance
public static function create_from_tag_instance($taginstance, $tagname, $tagrawname, $addsnapshot = false) { $event = self::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( 'tagid' => $taginstance->tagid, 'tagname' => $tagname, 'tagrawname' => $tagrawname, 'itemid' => $taginstance->itemid, 'itemtype' => $taginstance->itemtype ) )); if ($addsnapshot) { $event->add_record_snapshot('tag_instance', $taginstance); } return $event; }
php
public static function create_from_tag_instance($taginstance, $tagname, $tagrawname, $addsnapshot = false) { $event = self::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( 'tagid' => $taginstance->tagid, 'tagname' => $tagname, 'tagrawname' => $tagrawname, 'itemid' => $taginstance->itemid, 'itemtype' => $taginstance->itemtype ) )); if ($addsnapshot) { $event->add_record_snapshot('tag_instance', $taginstance); } return $event; }
[ "public", "static", "function", "create_from_tag_instance", "(", "$", "taginstance", ",", "$", "tagname", ",", "$", "tagrawname", ",", "$", "addsnapshot", "=", "false", ")", "{", "$", "event", "=", "self", "::", "create", "(", "array", "(", "'objectid'", "=>", "$", "taginstance", "->", "id", ",", "'contextid'", "=>", "$", "taginstance", "->", "contextid", ",", "'other'", "=>", "array", "(", "'tagid'", "=>", "$", "taginstance", "->", "tagid", ",", "'tagname'", "=>", "$", "tagname", ",", "'tagrawname'", "=>", "$", "tagrawname", ",", "'itemid'", "=>", "$", "taginstance", "->", "itemid", ",", "'itemtype'", "=>", "$", "taginstance", "->", "itemtype", ")", ")", ")", ";", "if", "(", "$", "addsnapshot", ")", "{", "$", "event", "->", "add_record_snapshot", "(", "'tag_instance'", ",", "$", "taginstance", ")", ";", "}", "return", "$", "event", ";", "}" ]
Creates an event from taginstance object @since Moodle 3.1 @param stdClass $taginstance @param string $tagname @param string $tagrawname @param bool $addsnapshot trust that $taginstance has all necessary fields and add it as a record snapshot @return tag_added
[ "Creates", "an", "event", "from", "taginstance", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/tag_added.php#L87-L103
212,159
moodle/moodle
admin/tool/dataprivacy/classes/output/crud_element.php
crud_element.action_menu
protected final function action_menu($elementname, $exported, $persistent) { // Just in case, we are doing funny stuff below. $elementname = clean_param($elementname, PARAM_ALPHA); // Actions. $actionmenu = new \action_menu(); $actionmenu->set_menu_trigger(get_string('actions')); $actionmenu->set_owner_selector($elementname . '-' . $exported->id . '-actions'); $actionmenu->set_alignment(\action_menu::TL, \action_menu::BL); $url = new \moodle_url('/admin/tool/dataprivacy/edit' . $elementname . '.php', ['id' => $exported->id]); $link = new \action_menu_link_secondary($url, new \pix_icon('t/edit', get_string('edit')), get_string('edit')); $actionmenu->add($link); if (!$persistent->is_used()) { $url = new \moodle_url('#'); $attrs = ['data-id' => $exported->id, 'data-action' => 'delete' . $elementname, 'data-name' => $exported->name]; $link = new \action_menu_link_secondary($url, new \pix_icon('t/delete', get_string('delete')), get_string('delete'), $attrs); $actionmenu->add($link); } return $actionmenu; }
php
protected final function action_menu($elementname, $exported, $persistent) { // Just in case, we are doing funny stuff below. $elementname = clean_param($elementname, PARAM_ALPHA); // Actions. $actionmenu = new \action_menu(); $actionmenu->set_menu_trigger(get_string('actions')); $actionmenu->set_owner_selector($elementname . '-' . $exported->id . '-actions'); $actionmenu->set_alignment(\action_menu::TL, \action_menu::BL); $url = new \moodle_url('/admin/tool/dataprivacy/edit' . $elementname . '.php', ['id' => $exported->id]); $link = new \action_menu_link_secondary($url, new \pix_icon('t/edit', get_string('edit')), get_string('edit')); $actionmenu->add($link); if (!$persistent->is_used()) { $url = new \moodle_url('#'); $attrs = ['data-id' => $exported->id, 'data-action' => 'delete' . $elementname, 'data-name' => $exported->name]; $link = new \action_menu_link_secondary($url, new \pix_icon('t/delete', get_string('delete')), get_string('delete'), $attrs); $actionmenu->add($link); } return $actionmenu; }
[ "protected", "final", "function", "action_menu", "(", "$", "elementname", ",", "$", "exported", ",", "$", "persistent", ")", "{", "// Just in case, we are doing funny stuff below.", "$", "elementname", "=", "clean_param", "(", "$", "elementname", ",", "PARAM_ALPHA", ")", ";", "// Actions.", "$", "actionmenu", "=", "new", "\\", "action_menu", "(", ")", ";", "$", "actionmenu", "->", "set_menu_trigger", "(", "get_string", "(", "'actions'", ")", ")", ";", "$", "actionmenu", "->", "set_owner_selector", "(", "$", "elementname", ".", "'-'", ".", "$", "exported", "->", "id", ".", "'-actions'", ")", ";", "$", "actionmenu", "->", "set_alignment", "(", "\\", "action_menu", "::", "TL", ",", "\\", "action_menu", "::", "BL", ")", ";", "$", "url", "=", "new", "\\", "moodle_url", "(", "'/admin/tool/dataprivacy/edit'", ".", "$", "elementname", ".", "'.php'", ",", "[", "'id'", "=>", "$", "exported", "->", "id", "]", ")", ";", "$", "link", "=", "new", "\\", "action_menu_link_secondary", "(", "$", "url", ",", "new", "\\", "pix_icon", "(", "'t/edit'", ",", "get_string", "(", "'edit'", ")", ")", ",", "get_string", "(", "'edit'", ")", ")", ";", "$", "actionmenu", "->", "add", "(", "$", "link", ")", ";", "if", "(", "!", "$", "persistent", "->", "is_used", "(", ")", ")", "{", "$", "url", "=", "new", "\\", "moodle_url", "(", "'#'", ")", ";", "$", "attrs", "=", "[", "'data-id'", "=>", "$", "exported", "->", "id", ",", "'data-action'", "=>", "'delete'", ".", "$", "elementname", ",", "'data-name'", "=>", "$", "exported", "->", "name", "]", ";", "$", "link", "=", "new", "\\", "action_menu_link_secondary", "(", "$", "url", ",", "new", "\\", "pix_icon", "(", "'t/delete'", ",", "get_string", "(", "'delete'", ")", ")", ",", "get_string", "(", "'delete'", ")", ",", "$", "attrs", ")", ";", "$", "actionmenu", "->", "add", "(", "$", "link", ")", ";", "}", "return", "$", "actionmenu", ";", "}" ]
Adds an action menu for the provided element @param string $elementname 'purpose' or 'category'. @param \stdClass $exported @param \core\persistent $persistent @return \action_menu
[ "Adds", "an", "action", "menu", "for", "the", "provided", "element" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/dataprivacy/classes/output/crud_element.php#L65-L91
212,160
moodle/moodle
message/classes/helper.php
helper.get_messages
public static function get_messages($userid, $otheruserid, $timedeleted = 0, $limitfrom = 0, $limitnum = 0, $sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) { global $DB; $hash = self::get_conversation_hash([$userid, $otheruserid]); $sql = "SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml, m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated, mc.contextid, muaread.timecreated AS timeread FROM {message_conversations} mc INNER JOIN {messages} m ON m.conversationid = mc.id LEFT JOIN {message_user_actions} muaread ON (muaread.messageid = m.id AND muaread.userid = :userid1 AND muaread.action = :readaction)"; $params = ['userid1' => $userid, 'readaction' => api::MESSAGE_ACTION_READ, 'convhash' => $hash]; if (empty($timedeleted)) { $sql .= " LEFT JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated is NOT NULL)"; } else { $sql .= " INNER JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated = :timedeleted)"; $params['timedeleted'] = $timedeleted; } $params['userid2'] = $userid; $params['deleteaction'] = api::MESSAGE_ACTION_DELETED; $sql .= " WHERE mc.convhash = :convhash"; if (!empty($timefrom)) { $sql .= " AND m.timecreated >= :timefrom"; $params['timefrom'] = $timefrom; } if (!empty($timeto)) { $sql .= " AND m.timecreated <= :timeto"; $params['timeto'] = $timeto; } if (empty($timedeleted)) { $sql .= " AND mua.id is NULL"; } $sql .= " ORDER BY m.$sort"; $messages = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); foreach ($messages as &$message) { $message->useridto = ($message->useridfrom == $userid) ? $otheruserid : $userid; } return $messages; }
php
public static function get_messages($userid, $otheruserid, $timedeleted = 0, $limitfrom = 0, $limitnum = 0, $sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) { global $DB; $hash = self::get_conversation_hash([$userid, $otheruserid]); $sql = "SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml, m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated, mc.contextid, muaread.timecreated AS timeread FROM {message_conversations} mc INNER JOIN {messages} m ON m.conversationid = mc.id LEFT JOIN {message_user_actions} muaread ON (muaread.messageid = m.id AND muaread.userid = :userid1 AND muaread.action = :readaction)"; $params = ['userid1' => $userid, 'readaction' => api::MESSAGE_ACTION_READ, 'convhash' => $hash]; if (empty($timedeleted)) { $sql .= " LEFT JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated is NOT NULL)"; } else { $sql .= " INNER JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated = :timedeleted)"; $params['timedeleted'] = $timedeleted; } $params['userid2'] = $userid; $params['deleteaction'] = api::MESSAGE_ACTION_DELETED; $sql .= " WHERE mc.convhash = :convhash"; if (!empty($timefrom)) { $sql .= " AND m.timecreated >= :timefrom"; $params['timefrom'] = $timefrom; } if (!empty($timeto)) { $sql .= " AND m.timecreated <= :timeto"; $params['timeto'] = $timeto; } if (empty($timedeleted)) { $sql .= " AND mua.id is NULL"; } $sql .= " ORDER BY m.$sort"; $messages = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); foreach ($messages as &$message) { $message->useridto = ($message->useridfrom == $userid) ? $otheruserid : $userid; } return $messages; }
[ "public", "static", "function", "get_messages", "(", "$", "userid", ",", "$", "otheruserid", ",", "$", "timedeleted", "=", "0", ",", "$", "limitfrom", "=", "0", ",", "$", "limitnum", "=", "0", ",", "$", "sort", "=", "'timecreated ASC'", ",", "$", "timefrom", "=", "0", ",", "$", "timeto", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "hash", "=", "self", "::", "get_conversation_hash", "(", "[", "$", "userid", ",", "$", "otheruserid", "]", ")", ";", "$", "sql", "=", "\"SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml,\n m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated,\n mc.contextid, muaread.timecreated AS timeread\n FROM {message_conversations} mc\n INNER JOIN {messages} m\n ON m.conversationid = mc.id\n LEFT JOIN {message_user_actions} muaread\n ON (muaread.messageid = m.id\n AND muaread.userid = :userid1\n AND muaread.action = :readaction)\"", ";", "$", "params", "=", "[", "'userid1'", "=>", "$", "userid", ",", "'readaction'", "=>", "api", "::", "MESSAGE_ACTION_READ", ",", "'convhash'", "=>", "$", "hash", "]", ";", "if", "(", "empty", "(", "$", "timedeleted", ")", ")", "{", "$", "sql", ".=", "\" LEFT JOIN {message_user_actions} mua\n ON (mua.messageid = m.id\n AND mua.userid = :userid2\n AND mua.action = :deleteaction\n AND mua.timecreated is NOT NULL)\"", ";", "}", "else", "{", "$", "sql", ".=", "\" INNER JOIN {message_user_actions} mua\n ON (mua.messageid = m.id\n AND mua.userid = :userid2\n AND mua.action = :deleteaction\n AND mua.timecreated = :timedeleted)\"", ";", "$", "params", "[", "'timedeleted'", "]", "=", "$", "timedeleted", ";", "}", "$", "params", "[", "'userid2'", "]", "=", "$", "userid", ";", "$", "params", "[", "'deleteaction'", "]", "=", "api", "::", "MESSAGE_ACTION_DELETED", ";", "$", "sql", ".=", "\" WHERE mc.convhash = :convhash\"", ";", "if", "(", "!", "empty", "(", "$", "timefrom", ")", ")", "{", "$", "sql", ".=", "\" AND m.timecreated >= :timefrom\"", ";", "$", "params", "[", "'timefrom'", "]", "=", "$", "timefrom", ";", "}", "if", "(", "!", "empty", "(", "$", "timeto", ")", ")", "{", "$", "sql", ".=", "\" AND m.timecreated <= :timeto\"", ";", "$", "params", "[", "'timeto'", "]", "=", "$", "timeto", ";", "}", "if", "(", "empty", "(", "$", "timedeleted", ")", ")", "{", "$", "sql", ".=", "\" AND mua.id is NULL\"", ";", "}", "$", "sql", ".=", "\" ORDER BY m.$sort\"", ";", "$", "messages", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ",", "$", "limitfrom", ",", "$", "limitnum", ")", ";", "foreach", "(", "$", "messages", "as", "&", "$", "message", ")", "{", "$", "message", "->", "useridto", "=", "(", "$", "message", "->", "useridfrom", "==", "$", "userid", ")", "?", "$", "otheruserid", ":", "$", "userid", ";", "}", "return", "$", "messages", ";", "}" ]
Helper function to retrieve the messages between two users TODO: This function should be removed once the related web services go through final deprecation. The related web services are data_for_messagearea_messages AND data_for_messagearea_get_most_recent_message. Followup: MDL-63261 @param int $userid the current user @param int $otheruserid the other user @param int $timedeleted the time the message was deleted @param int $limitfrom @param int $limitnum @param string $sort @param int $timefrom the time from the message being sent @param int $timeto the time up until the message being sent @return array of messages
[ "Helper", "function", "to", "retrieve", "the", "messages", "between", "two", "users" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L54-L114
212,161
moodle/moodle
message/classes/helper.php
helper.get_conversation_messages
public static function get_conversation_messages(int $userid, int $convid, int $timedeleted = 0, int $limitfrom = 0, int $limitnum = 0, string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array { global $DB; $sql = "SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml, m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated, mc.contextid, muaread.timecreated AS timeread FROM {message_conversations} mc INNER JOIN {messages} m ON m.conversationid = mc.id LEFT JOIN {message_user_actions} muaread ON (muaread.messageid = m.id AND muaread.userid = :userid1 AND muaread.action = :readaction)"; $params = ['userid1' => $userid, 'readaction' => api::MESSAGE_ACTION_READ, 'convid' => $convid]; if (empty($timedeleted)) { $sql .= " LEFT JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated is NOT NULL)"; } else { $sql .= " INNER JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated = :timedeleted)"; $params['timedeleted'] = $timedeleted; } $params['userid2'] = $userid; $params['deleteaction'] = api::MESSAGE_ACTION_DELETED; $sql .= " WHERE mc.id = :convid"; if (!empty($timefrom)) { $sql .= " AND m.timecreated >= :timefrom"; $params['timefrom'] = $timefrom; } if (!empty($timeto)) { $sql .= " AND m.timecreated <= :timeto"; $params['timeto'] = $timeto; } if (empty($timedeleted)) { $sql .= " AND mua.id is NULL"; } $sql .= " ORDER BY m.$sort"; $messages = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); return $messages; }
php
public static function get_conversation_messages(int $userid, int $convid, int $timedeleted = 0, int $limitfrom = 0, int $limitnum = 0, string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array { global $DB; $sql = "SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml, m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated, mc.contextid, muaread.timecreated AS timeread FROM {message_conversations} mc INNER JOIN {messages} m ON m.conversationid = mc.id LEFT JOIN {message_user_actions} muaread ON (muaread.messageid = m.id AND muaread.userid = :userid1 AND muaread.action = :readaction)"; $params = ['userid1' => $userid, 'readaction' => api::MESSAGE_ACTION_READ, 'convid' => $convid]; if (empty($timedeleted)) { $sql .= " LEFT JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated is NOT NULL)"; } else { $sql .= " INNER JOIN {message_user_actions} mua ON (mua.messageid = m.id AND mua.userid = :userid2 AND mua.action = :deleteaction AND mua.timecreated = :timedeleted)"; $params['timedeleted'] = $timedeleted; } $params['userid2'] = $userid; $params['deleteaction'] = api::MESSAGE_ACTION_DELETED; $sql .= " WHERE mc.id = :convid"; if (!empty($timefrom)) { $sql .= " AND m.timecreated >= :timefrom"; $params['timefrom'] = $timefrom; } if (!empty($timeto)) { $sql .= " AND m.timecreated <= :timeto"; $params['timeto'] = $timeto; } if (empty($timedeleted)) { $sql .= " AND mua.id is NULL"; } $sql .= " ORDER BY m.$sort"; $messages = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum); return $messages; }
[ "public", "static", "function", "get_conversation_messages", "(", "int", "$", "userid", ",", "int", "$", "convid", ",", "int", "$", "timedeleted", "=", "0", ",", "int", "$", "limitfrom", "=", "0", ",", "int", "$", "limitnum", "=", "0", ",", "string", "$", "sort", "=", "'timecreated ASC'", ",", "int", "$", "timefrom", "=", "0", ",", "int", "$", "timeto", "=", "0", ")", ":", "array", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT m.id, m.useridfrom, m.subject, m.fullmessage, m.fullmessagehtml,\n m.fullmessageformat, m.fullmessagetrust, m.smallmessage, m.timecreated,\n mc.contextid, muaread.timecreated AS timeread\n FROM {message_conversations} mc\n INNER JOIN {messages} m\n ON m.conversationid = mc.id\n LEFT JOIN {message_user_actions} muaread\n ON (muaread.messageid = m.id\n AND muaread.userid = :userid1\n AND muaread.action = :readaction)\"", ";", "$", "params", "=", "[", "'userid1'", "=>", "$", "userid", ",", "'readaction'", "=>", "api", "::", "MESSAGE_ACTION_READ", ",", "'convid'", "=>", "$", "convid", "]", ";", "if", "(", "empty", "(", "$", "timedeleted", ")", ")", "{", "$", "sql", ".=", "\" LEFT JOIN {message_user_actions} mua\n ON (mua.messageid = m.id\n AND mua.userid = :userid2\n AND mua.action = :deleteaction\n AND mua.timecreated is NOT NULL)\"", ";", "}", "else", "{", "$", "sql", ".=", "\" INNER JOIN {message_user_actions} mua\n ON (mua.messageid = m.id\n AND mua.userid = :userid2\n AND mua.action = :deleteaction\n AND mua.timecreated = :timedeleted)\"", ";", "$", "params", "[", "'timedeleted'", "]", "=", "$", "timedeleted", ";", "}", "$", "params", "[", "'userid2'", "]", "=", "$", "userid", ";", "$", "params", "[", "'deleteaction'", "]", "=", "api", "::", "MESSAGE_ACTION_DELETED", ";", "$", "sql", ".=", "\" WHERE mc.id = :convid\"", ";", "if", "(", "!", "empty", "(", "$", "timefrom", ")", ")", "{", "$", "sql", ".=", "\" AND m.timecreated >= :timefrom\"", ";", "$", "params", "[", "'timefrom'", "]", "=", "$", "timefrom", ";", "}", "if", "(", "!", "empty", "(", "$", "timeto", ")", ")", "{", "$", "sql", ".=", "\" AND m.timecreated <= :timeto\"", ";", "$", "params", "[", "'timeto'", "]", "=", "$", "timeto", ";", "}", "if", "(", "empty", "(", "$", "timedeleted", ")", ")", "{", "$", "sql", ".=", "\" AND mua.id is NULL\"", ";", "}", "$", "sql", ".=", "\" ORDER BY m.$sort\"", ";", "$", "messages", "=", "$", "DB", "->", "get_records_sql", "(", "$", "sql", ",", "$", "params", ",", "$", "limitfrom", ",", "$", "limitnum", ")", ";", "return", "$", "messages", ";", "}" ]
Helper function to retrieve conversation messages. @param int $userid The current user. @param int $convid The conversation identifier. @param int $timedeleted The time the message was deleted @param int $limitfrom Return a subset of records, starting at this point (optional). @param int $limitnum Return a subset comprising this many records in total (optional, required if $limitfrom is set). @param string $sort The column name to order by including optionally direction. @param int $timefrom The time from the message being sent. @param int $timeto The time up until the message being sent. @return array of messages
[ "Helper", "function", "to", "retrieve", "conversation", "messages", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L129-L185
212,162
moodle/moodle
message/classes/helper.php
helper.create_messages
public static function create_messages($userid, $messages) { // Store the messages. $arrmessages = array(); // We always view messages from oldest to newest, ensure we have it in that order. $lastmessage = end($messages); $firstmessage = reset($messages); if ($lastmessage->timecreated < $firstmessage->timecreated) { $messages = array_reverse($messages); } // Keeps track of the last day, month and year combo we were viewing. $day = ''; $month = ''; $year = ''; foreach ($messages as $message) { // Check if we are now viewing a different block period. $displayblocktime = false; $date = usergetdate($message->timecreated); if ($day != $date['mday'] || $month != $date['month'] || $year != $date['year']) { $day = $date['mday']; $month = $date['month']; $year = $date['year']; $displayblocktime = true; } // Store the message to pass to the renderable. $msg = new \stdClass(); $msg->id = $message->id; $msg->text = message_format_message_text($message); $msg->currentuserid = $userid; $msg->useridfrom = $message->useridfrom; $msg->useridto = $message->useridto; $msg->displayblocktime = $displayblocktime; $msg->timecreated = $message->timecreated; $msg->timeread = $message->timeread; $arrmessages[] = $msg; } return $arrmessages; }
php
public static function create_messages($userid, $messages) { // Store the messages. $arrmessages = array(); // We always view messages from oldest to newest, ensure we have it in that order. $lastmessage = end($messages); $firstmessage = reset($messages); if ($lastmessage->timecreated < $firstmessage->timecreated) { $messages = array_reverse($messages); } // Keeps track of the last day, month and year combo we were viewing. $day = ''; $month = ''; $year = ''; foreach ($messages as $message) { // Check if we are now viewing a different block period. $displayblocktime = false; $date = usergetdate($message->timecreated); if ($day != $date['mday'] || $month != $date['month'] || $year != $date['year']) { $day = $date['mday']; $month = $date['month']; $year = $date['year']; $displayblocktime = true; } // Store the message to pass to the renderable. $msg = new \stdClass(); $msg->id = $message->id; $msg->text = message_format_message_text($message); $msg->currentuserid = $userid; $msg->useridfrom = $message->useridfrom; $msg->useridto = $message->useridto; $msg->displayblocktime = $displayblocktime; $msg->timecreated = $message->timecreated; $msg->timeread = $message->timeread; $arrmessages[] = $msg; } return $arrmessages; }
[ "public", "static", "function", "create_messages", "(", "$", "userid", ",", "$", "messages", ")", "{", "// Store the messages.", "$", "arrmessages", "=", "array", "(", ")", ";", "// We always view messages from oldest to newest, ensure we have it in that order.", "$", "lastmessage", "=", "end", "(", "$", "messages", ")", ";", "$", "firstmessage", "=", "reset", "(", "$", "messages", ")", ";", "if", "(", "$", "lastmessage", "->", "timecreated", "<", "$", "firstmessage", "->", "timecreated", ")", "{", "$", "messages", "=", "array_reverse", "(", "$", "messages", ")", ";", "}", "// Keeps track of the last day, month and year combo we were viewing.", "$", "day", "=", "''", ";", "$", "month", "=", "''", ";", "$", "year", "=", "''", ";", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "// Check if we are now viewing a different block period.", "$", "displayblocktime", "=", "false", ";", "$", "date", "=", "usergetdate", "(", "$", "message", "->", "timecreated", ")", ";", "if", "(", "$", "day", "!=", "$", "date", "[", "'mday'", "]", "||", "$", "month", "!=", "$", "date", "[", "'month'", "]", "||", "$", "year", "!=", "$", "date", "[", "'year'", "]", ")", "{", "$", "day", "=", "$", "date", "[", "'mday'", "]", ";", "$", "month", "=", "$", "date", "[", "'month'", "]", ";", "$", "year", "=", "$", "date", "[", "'year'", "]", ";", "$", "displayblocktime", "=", "true", ";", "}", "// Store the message to pass to the renderable.", "$", "msg", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "msg", "->", "id", "=", "$", "message", "->", "id", ";", "$", "msg", "->", "text", "=", "message_format_message_text", "(", "$", "message", ")", ";", "$", "msg", "->", "currentuserid", "=", "$", "userid", ";", "$", "msg", "->", "useridfrom", "=", "$", "message", "->", "useridfrom", ";", "$", "msg", "->", "useridto", "=", "$", "message", "->", "useridto", ";", "$", "msg", "->", "displayblocktime", "=", "$", "displayblocktime", ";", "$", "msg", "->", "timecreated", "=", "$", "message", "->", "timecreated", ";", "$", "msg", "->", "timeread", "=", "$", "message", "->", "timeread", ";", "$", "arrmessages", "[", "]", "=", "$", "msg", ";", "}", "return", "$", "arrmessages", ";", "}" ]
Helper function to return an array of messages. TODO: This function should be removed once the related web services go through final deprecation. The related web services are data_for_messagearea_messages AND data_for_messagearea_get_most_recent_message. Followup: MDL-63261 @param int $userid @param array $messages @return array
[ "Helper", "function", "to", "return", "an", "array", "of", "messages", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L245-L284
212,163
moodle/moodle
message/classes/helper.php
helper.create_contact
public static function create_contact($contact, $prefix = '') { global $PAGE; // Create the data we are going to pass to the renderable. $userfields = \user_picture::unalias($contact, array('lastaccess'), $prefix . 'id', $prefix); $data = new \stdClass(); $data->userid = $userfields->id; $data->useridfrom = null; $data->fullname = fullname($userfields); // Get the user picture data. $userpicture = new \user_picture($userfields); $userpicture->size = 1; // Size f1. $data->profileimageurl = $userpicture->get_url($PAGE)->out(false); $userpicture->size = 0; // Size f2. $data->profileimageurlsmall = $userpicture->get_url($PAGE)->out(false); // Store the message if we have it. $data->ismessaging = false; $data->lastmessage = null; $data->lastmessagedate = null; $data->messageid = null; if (isset($contact->smallmessage)) { $data->ismessaging = true; // Strip the HTML tags from the message for displaying in the contact area. $data->lastmessage = clean_param($contact->smallmessage, PARAM_NOTAGS); $data->lastmessagedate = $contact->timecreated; $data->useridfrom = $contact->useridfrom; if (isset($contact->messageid)) { $data->messageid = $contact->messageid; } } $data->isonline = null; $user = \core_user::get_user($data->userid); if (self::show_online_status($user)) { $data->isonline = self::is_online($userfields->lastaccess); } $data->isblocked = isset($contact->blocked) ? (bool) $contact->blocked : false; $data->isread = isset($contact->isread) ? (bool) $contact->isread : false; $data->unreadcount = isset($contact->unreadcount) ? $contact->unreadcount : null; $data->conversationid = $contact->conversationid ?? null; return $data; }
php
public static function create_contact($contact, $prefix = '') { global $PAGE; // Create the data we are going to pass to the renderable. $userfields = \user_picture::unalias($contact, array('lastaccess'), $prefix . 'id', $prefix); $data = new \stdClass(); $data->userid = $userfields->id; $data->useridfrom = null; $data->fullname = fullname($userfields); // Get the user picture data. $userpicture = new \user_picture($userfields); $userpicture->size = 1; // Size f1. $data->profileimageurl = $userpicture->get_url($PAGE)->out(false); $userpicture->size = 0; // Size f2. $data->profileimageurlsmall = $userpicture->get_url($PAGE)->out(false); // Store the message if we have it. $data->ismessaging = false; $data->lastmessage = null; $data->lastmessagedate = null; $data->messageid = null; if (isset($contact->smallmessage)) { $data->ismessaging = true; // Strip the HTML tags from the message for displaying in the contact area. $data->lastmessage = clean_param($contact->smallmessage, PARAM_NOTAGS); $data->lastmessagedate = $contact->timecreated; $data->useridfrom = $contact->useridfrom; if (isset($contact->messageid)) { $data->messageid = $contact->messageid; } } $data->isonline = null; $user = \core_user::get_user($data->userid); if (self::show_online_status($user)) { $data->isonline = self::is_online($userfields->lastaccess); } $data->isblocked = isset($contact->blocked) ? (bool) $contact->blocked : false; $data->isread = isset($contact->isread) ? (bool) $contact->isread : false; $data->unreadcount = isset($contact->unreadcount) ? $contact->unreadcount : null; $data->conversationid = $contact->conversationid ?? null; return $data; }
[ "public", "static", "function", "create_contact", "(", "$", "contact", ",", "$", "prefix", "=", "''", ")", "{", "global", "$", "PAGE", ";", "// Create the data we are going to pass to the renderable.", "$", "userfields", "=", "\\", "user_picture", "::", "unalias", "(", "$", "contact", ",", "array", "(", "'lastaccess'", ")", ",", "$", "prefix", ".", "'id'", ",", "$", "prefix", ")", ";", "$", "data", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "data", "->", "userid", "=", "$", "userfields", "->", "id", ";", "$", "data", "->", "useridfrom", "=", "null", ";", "$", "data", "->", "fullname", "=", "fullname", "(", "$", "userfields", ")", ";", "// Get the user picture data.", "$", "userpicture", "=", "new", "\\", "user_picture", "(", "$", "userfields", ")", ";", "$", "userpicture", "->", "size", "=", "1", ";", "// Size f1.", "$", "data", "->", "profileimageurl", "=", "$", "userpicture", "->", "get_url", "(", "$", "PAGE", ")", "->", "out", "(", "false", ")", ";", "$", "userpicture", "->", "size", "=", "0", ";", "// Size f2.", "$", "data", "->", "profileimageurlsmall", "=", "$", "userpicture", "->", "get_url", "(", "$", "PAGE", ")", "->", "out", "(", "false", ")", ";", "// Store the message if we have it.", "$", "data", "->", "ismessaging", "=", "false", ";", "$", "data", "->", "lastmessage", "=", "null", ";", "$", "data", "->", "lastmessagedate", "=", "null", ";", "$", "data", "->", "messageid", "=", "null", ";", "if", "(", "isset", "(", "$", "contact", "->", "smallmessage", ")", ")", "{", "$", "data", "->", "ismessaging", "=", "true", ";", "// Strip the HTML tags from the message for displaying in the contact area.", "$", "data", "->", "lastmessage", "=", "clean_param", "(", "$", "contact", "->", "smallmessage", ",", "PARAM_NOTAGS", ")", ";", "$", "data", "->", "lastmessagedate", "=", "$", "contact", "->", "timecreated", ";", "$", "data", "->", "useridfrom", "=", "$", "contact", "->", "useridfrom", ";", "if", "(", "isset", "(", "$", "contact", "->", "messageid", ")", ")", "{", "$", "data", "->", "messageid", "=", "$", "contact", "->", "messageid", ";", "}", "}", "$", "data", "->", "isonline", "=", "null", ";", "$", "user", "=", "\\", "core_user", "::", "get_user", "(", "$", "data", "->", "userid", ")", ";", "if", "(", "self", "::", "show_online_status", "(", "$", "user", ")", ")", "{", "$", "data", "->", "isonline", "=", "self", "::", "is_online", "(", "$", "userfields", "->", "lastaccess", ")", ";", "}", "$", "data", "->", "isblocked", "=", "isset", "(", "$", "contact", "->", "blocked", ")", "?", "(", "bool", ")", "$", "contact", "->", "blocked", ":", "false", ";", "$", "data", "->", "isread", "=", "isset", "(", "$", "contact", "->", "isread", ")", "?", "(", "bool", ")", "$", "contact", "->", "isread", ":", "false", ";", "$", "data", "->", "unreadcount", "=", "isset", "(", "$", "contact", "->", "unreadcount", ")", "?", "$", "contact", "->", "unreadcount", ":", "null", ";", "$", "data", "->", "conversationid", "=", "$", "contact", "->", "conversationid", "??", "null", ";", "return", "$", "data", ";", "}" ]
Helper function for creating a contact object. @param \stdClass $contact @param string $prefix @return \stdClass
[ "Helper", "function", "for", "creating", "a", "contact", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L293-L334
212,164
moodle/moodle
message/classes/helper.php
helper.show_online_status
public static function show_online_status($user) { global $CFG; require_once($CFG->dirroot . '/user/lib.php'); if ($lastaccess = user_get_user_details($user, null, array('lastaccess'))) { if (isset($lastaccess['lastaccess'])) { return true; } } return false; }
php
public static function show_online_status($user) { global $CFG; require_once($CFG->dirroot . '/user/lib.php'); if ($lastaccess = user_get_user_details($user, null, array('lastaccess'))) { if (isset($lastaccess['lastaccess'])) { return true; } } return false; }
[ "public", "static", "function", "show_online_status", "(", "$", "user", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/user/lib.php'", ")", ";", "if", "(", "$", "lastaccess", "=", "user_get_user_details", "(", "$", "user", ",", "null", ",", "array", "(", "'lastaccess'", ")", ")", ")", "{", "if", "(", "isset", "(", "$", "lastaccess", "[", "'lastaccess'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper function for checking if we should show the user's online status. @param \stdClass $user @return boolean
[ "Helper", "function", "for", "checking", "if", "we", "should", "show", "the", "user", "s", "online", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L342-L354
212,165
moodle/moodle
message/classes/helper.php
helper.is_online
public static function is_online($lastaccess) { global $CFG; // Variable to check if we consider this user online or not. $timetoshowusers = 300; // Seconds default. if (isset($CFG->block_online_users_timetosee)) { $timetoshowusers = $CFG->block_online_users_timetosee * 60; } $time = time() - $timetoshowusers; return $lastaccess >= $time; }
php
public static function is_online($lastaccess) { global $CFG; // Variable to check if we consider this user online or not. $timetoshowusers = 300; // Seconds default. if (isset($CFG->block_online_users_timetosee)) { $timetoshowusers = $CFG->block_online_users_timetosee * 60; } $time = time() - $timetoshowusers; return $lastaccess >= $time; }
[ "public", "static", "function", "is_online", "(", "$", "lastaccess", ")", "{", "global", "$", "CFG", ";", "// Variable to check if we consider this user online or not.", "$", "timetoshowusers", "=", "300", ";", "// Seconds default.", "if", "(", "isset", "(", "$", "CFG", "->", "block_online_users_timetosee", ")", ")", "{", "$", "timetoshowusers", "=", "$", "CFG", "->", "block_online_users_timetosee", "*", "60", ";", "}", "$", "time", "=", "time", "(", ")", "-", "$", "timetoshowusers", ";", "return", "$", "lastaccess", ">=", "$", "time", ";", "}" ]
Helper function for checking the time meets the 'online' condition. @param int $lastaccess @return boolean
[ "Helper", "function", "for", "checking", "the", "time", "meets", "the", "online", "condition", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L362-L373
212,166
moodle/moodle
message/classes/helper.php
helper.get_providers_preferences
public static function get_providers_preferences($providers, $userid) { $preferences = new \stdClass(); // Get providers preferences. foreach ($providers as $provider) { foreach (array('loggedin', 'loggedoff') as $state) { $linepref = get_user_preferences('message_provider_' . $provider->component . '_' . $provider->name . '_' . $state, '', $userid); if ($linepref == '') { continue; } $lineprefarray = explode(',', $linepref); $preferences->{$provider->component.'_'.$provider->name.'_'.$state} = array(); foreach ($lineprefarray as $pref) { $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$pref] = 1; } } } return $preferences; }
php
public static function get_providers_preferences($providers, $userid) { $preferences = new \stdClass(); // Get providers preferences. foreach ($providers as $provider) { foreach (array('loggedin', 'loggedoff') as $state) { $linepref = get_user_preferences('message_provider_' . $provider->component . '_' . $provider->name . '_' . $state, '', $userid); if ($linepref == '') { continue; } $lineprefarray = explode(',', $linepref); $preferences->{$provider->component.'_'.$provider->name.'_'.$state} = array(); foreach ($lineprefarray as $pref) { $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$pref] = 1; } } } return $preferences; }
[ "public", "static", "function", "get_providers_preferences", "(", "$", "providers", ",", "$", "userid", ")", "{", "$", "preferences", "=", "new", "\\", "stdClass", "(", ")", ";", "// Get providers preferences.", "foreach", "(", "$", "providers", "as", "$", "provider", ")", "{", "foreach", "(", "array", "(", "'loggedin'", ",", "'loggedoff'", ")", "as", "$", "state", ")", "{", "$", "linepref", "=", "get_user_preferences", "(", "'message_provider_'", ".", "$", "provider", "->", "component", ".", "'_'", ".", "$", "provider", "->", "name", ".", "'_'", ".", "$", "state", ",", "''", ",", "$", "userid", ")", ";", "if", "(", "$", "linepref", "==", "''", ")", "{", "continue", ";", "}", "$", "lineprefarray", "=", "explode", "(", "','", ",", "$", "linepref", ")", ";", "$", "preferences", "->", "{", "$", "provider", "->", "component", ".", "'_'", ".", "$", "provider", "->", "name", ".", "'_'", ".", "$", "state", "}", "=", "array", "(", ")", ";", "foreach", "(", "$", "lineprefarray", "as", "$", "pref", ")", "{", "$", "preferences", "->", "{", "$", "provider", "->", "component", ".", "'_'", ".", "$", "provider", "->", "name", ".", "'_'", ".", "$", "state", "}", "[", "$", "pref", "]", "=", "1", ";", "}", "}", "}", "return", "$", "preferences", ";", "}" ]
Get providers preferences. @param array $providers @param int $userid @return \stdClass
[ "Get", "providers", "preferences", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L382-L402
212,167
moodle/moodle
message/classes/helper.php
helper.togglecontact_requirejs
public static function togglecontact_requirejs() { global $PAGE; static $done = false; if ($done) { return; } $PAGE->requires->js_call_amd('core_message/toggle_contact_button', 'enhance', array('#toggle-contact-button')); $done = true; }
php
public static function togglecontact_requirejs() { global $PAGE; static $done = false; if ($done) { return; } $PAGE->requires->js_call_amd('core_message/toggle_contact_button', 'enhance', array('#toggle-contact-button')); $done = true; }
[ "public", "static", "function", "togglecontact_requirejs", "(", ")", "{", "global", "$", "PAGE", ";", "static", "$", "done", "=", "false", ";", "if", "(", "$", "done", ")", "{", "return", ";", "}", "$", "PAGE", "->", "requires", "->", "js_call_amd", "(", "'core_message/toggle_contact_button'", ",", "'enhance'", ",", "array", "(", "'#toggle-contact-button'", ")", ")", ";", "$", "done", "=", "true", ";", "}" ]
Requires the JS libraries for the toggle contact button. @return void
[ "Requires", "the", "JS", "libraries", "for", "the", "toggle", "contact", "button", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L409-L419
212,168
moodle/moodle
message/classes/helper.php
helper.messageuser_requirejs
public static function messageuser_requirejs() { global $PAGE; static $done = false; if ($done) { return; } $PAGE->requires->js_call_amd('core_message/message_user_button', 'send', array('#message-user-button')); $done = true; }
php
public static function messageuser_requirejs() { global $PAGE; static $done = false; if ($done) { return; } $PAGE->requires->js_call_amd('core_message/message_user_button', 'send', array('#message-user-button')); $done = true; }
[ "public", "static", "function", "messageuser_requirejs", "(", ")", "{", "global", "$", "PAGE", ";", "static", "$", "done", "=", "false", ";", "if", "(", "$", "done", ")", "{", "return", ";", "}", "$", "PAGE", "->", "requires", "->", "js_call_amd", "(", "'core_message/message_user_button'", ",", "'send'", ",", "array", "(", "'#message-user-button'", ")", ")", ";", "$", "done", "=", "true", ";", "}" ]
Requires the JS libraries for the message user button. @return void
[ "Requires", "the", "JS", "libraries", "for", "the", "message", "user", "button", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L445-L455
212,169
moodle/moodle
message/classes/helper.php
helper.messageuser_link_params
public static function messageuser_link_params(int $useridto) : array { global $USER; return [ 'id' => 'message-user-button', 'role' => 'button', 'data-conversationid' => api::get_conversation_between_users([$USER->id, $useridto]), 'data-userid' => $useridto, ]; }
php
public static function messageuser_link_params(int $useridto) : array { global $USER; return [ 'id' => 'message-user-button', 'role' => 'button', 'data-conversationid' => api::get_conversation_between_users([$USER->id, $useridto]), 'data-userid' => $useridto, ]; }
[ "public", "static", "function", "messageuser_link_params", "(", "int", "$", "useridto", ")", ":", "array", "{", "global", "$", "USER", ";", "return", "[", "'id'", "=>", "'message-user-button'", ",", "'role'", "=>", "'button'", ",", "'data-conversationid'", "=>", "api", "::", "get_conversation_between_users", "(", "[", "$", "USER", "->", "id", ",", "$", "useridto", "]", ")", ",", "'data-userid'", "=>", "$", "useridto", ",", "]", ";", "}" ]
Returns the attributes to place on the message user button. @param int $useridto @return array
[ "Returns", "the", "attributes", "to", "place", "on", "the", "message", "user", "button", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L463-L472
212,170
moodle/moodle
message/classes/helper.php
helper.legacy_messages_exist
public static function legacy_messages_exist($userid) { global $DB; $sql = "SELECT id FROM {message} m WHERE useridfrom = ? OR useridto = ?"; $messageexists = $DB->record_exists_sql($sql, [$userid, $userid]); $sql = "SELECT id FROM {message_read} m WHERE useridfrom = ? OR useridto = ?"; $messagereadexists = $DB->record_exists_sql($sql, [$userid, $userid]); return $messageexists || $messagereadexists; }
php
public static function legacy_messages_exist($userid) { global $DB; $sql = "SELECT id FROM {message} m WHERE useridfrom = ? OR useridto = ?"; $messageexists = $DB->record_exists_sql($sql, [$userid, $userid]); $sql = "SELECT id FROM {message_read} m WHERE useridfrom = ? OR useridto = ?"; $messagereadexists = $DB->record_exists_sql($sql, [$userid, $userid]); return $messageexists || $messagereadexists; }
[ "public", "static", "function", "legacy_messages_exist", "(", "$", "userid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT id\n FROM {message} m\n WHERE useridfrom = ?\n OR useridto = ?\"", ";", "$", "messageexists", "=", "$", "DB", "->", "record_exists_sql", "(", "$", "sql", ",", "[", "$", "userid", ",", "$", "userid", "]", ")", ";", "$", "sql", "=", "\"SELECT id\n FROM {message_read} m\n WHERE useridfrom = ?\n OR useridto = ?\"", ";", "$", "messagereadexists", "=", "$", "DB", "->", "record_exists_sql", "(", "$", "sql", ",", "[", "$", "userid", ",", "$", "userid", "]", ")", ";", "return", "$", "messageexists", "||", "$", "messagereadexists", ";", "}" ]
Checks if legacy messages exist for a given user. @param int $userid @return bool
[ "Checks", "if", "legacy", "messages", "exist", "for", "a", "given", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L502-L518
212,171
moodle/moodle
message/classes/helper.php
helper.render_messaging_widget
public static function render_messaging_widget(bool $isdrawer, int $sendtouser = null, int $conversationid = null) { global $USER, $CFG, $PAGE; // Early bail out conditions. if (empty($CFG->messaging) || !isloggedin() || isguestuser() || user_not_fully_set_up($USER) || get_user_preferences('auth_forcepasswordchange') || (!$USER->policyagreed && !is_siteadmin() && ($manager = new \core_privacy\local\sitepolicy\manager()) && $manager->is_defined())) { return ''; } $renderer = $PAGE->get_renderer('core'); $requestcount = \core_message\api::get_received_contact_requests_count($USER->id); $contactscount = \core_message\api::count_contacts($USER->id); $choices = []; $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_ONLYCONTACTS, 'text' => get_string('contactableprivacy_onlycontacts', 'message') ]; $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_COURSEMEMBER, 'text' => get_string('contactableprivacy_coursemember', 'message') ]; if (!empty($CFG->messagingallusers)) { // Add the MESSAGE_PRIVACY_SITE option when site-wide messaging between users is enabled. $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_SITE, 'text' => get_string('contactableprivacy_site', 'message') ]; } // Enter to send. $entertosend = get_user_preferences('message_entertosend', $CFG->messagingdefaultpressenter, $USER); $notification = ''; if (!get_user_preferences('core_message_migrate_data', false)) { $notification = get_string('messagingdatahasnotbeenmigrated', 'message'); } if ($isdrawer) { $template = 'core_message/message_drawer'; $messageurl = new \moodle_url('/message/index.php'); } else { $template = 'core_message/message_index'; $messageurl = null; } $templatecontext = [ 'contactrequestcount' => $requestcount, 'loggedinuser' => [ 'id' => $USER->id, 'midnight' => usergetmidnight(time()) ], 'contacts' => [ 'sectioncontacts' => [ 'placeholders' => array_fill(0, $contactscount > 50 ? 50 : $contactscount, true) ], 'sectionrequests' => [ 'placeholders' => array_fill(0, $requestcount > 50 ? 50 : $requestcount, true) ], ], 'settings' => [ 'privacy' => $choices, 'entertosend' => $entertosend ], 'overview' => [ 'messageurl' => $messageurl, 'notification' => $notification ], 'sendtouser' => false, 'conversationid' => false, 'isdrawer' => $isdrawer ]; if ($sendtouser) { $templatecontext['sendtouser'] = $sendtouser; } if ($conversationid) { $templatecontext['conversationid'] = $conversationid; } return $renderer->render_from_template($template, $templatecontext); }
php
public static function render_messaging_widget(bool $isdrawer, int $sendtouser = null, int $conversationid = null) { global $USER, $CFG, $PAGE; // Early bail out conditions. if (empty($CFG->messaging) || !isloggedin() || isguestuser() || user_not_fully_set_up($USER) || get_user_preferences('auth_forcepasswordchange') || (!$USER->policyagreed && !is_siteadmin() && ($manager = new \core_privacy\local\sitepolicy\manager()) && $manager->is_defined())) { return ''; } $renderer = $PAGE->get_renderer('core'); $requestcount = \core_message\api::get_received_contact_requests_count($USER->id); $contactscount = \core_message\api::count_contacts($USER->id); $choices = []; $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_ONLYCONTACTS, 'text' => get_string('contactableprivacy_onlycontacts', 'message') ]; $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_COURSEMEMBER, 'text' => get_string('contactableprivacy_coursemember', 'message') ]; if (!empty($CFG->messagingallusers)) { // Add the MESSAGE_PRIVACY_SITE option when site-wide messaging between users is enabled. $choices[] = [ 'value' => \core_message\api::MESSAGE_PRIVACY_SITE, 'text' => get_string('contactableprivacy_site', 'message') ]; } // Enter to send. $entertosend = get_user_preferences('message_entertosend', $CFG->messagingdefaultpressenter, $USER); $notification = ''; if (!get_user_preferences('core_message_migrate_data', false)) { $notification = get_string('messagingdatahasnotbeenmigrated', 'message'); } if ($isdrawer) { $template = 'core_message/message_drawer'; $messageurl = new \moodle_url('/message/index.php'); } else { $template = 'core_message/message_index'; $messageurl = null; } $templatecontext = [ 'contactrequestcount' => $requestcount, 'loggedinuser' => [ 'id' => $USER->id, 'midnight' => usergetmidnight(time()) ], 'contacts' => [ 'sectioncontacts' => [ 'placeholders' => array_fill(0, $contactscount > 50 ? 50 : $contactscount, true) ], 'sectionrequests' => [ 'placeholders' => array_fill(0, $requestcount > 50 ? 50 : $requestcount, true) ], ], 'settings' => [ 'privacy' => $choices, 'entertosend' => $entertosend ], 'overview' => [ 'messageurl' => $messageurl, 'notification' => $notification ], 'sendtouser' => false, 'conversationid' => false, 'isdrawer' => $isdrawer ]; if ($sendtouser) { $templatecontext['sendtouser'] = $sendtouser; } if ($conversationid) { $templatecontext['conversationid'] = $conversationid; } return $renderer->render_from_template($template, $templatecontext); }
[ "public", "static", "function", "render_messaging_widget", "(", "bool", "$", "isdrawer", ",", "int", "$", "sendtouser", "=", "null", ",", "int", "$", "conversationid", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "CFG", ",", "$", "PAGE", ";", "// Early bail out conditions.", "if", "(", "empty", "(", "$", "CFG", "->", "messaging", ")", "||", "!", "isloggedin", "(", ")", "||", "isguestuser", "(", ")", "||", "user_not_fully_set_up", "(", "$", "USER", ")", "||", "get_user_preferences", "(", "'auth_forcepasswordchange'", ")", "||", "(", "!", "$", "USER", "->", "policyagreed", "&&", "!", "is_siteadmin", "(", ")", "&&", "(", "$", "manager", "=", "new", "\\", "core_privacy", "\\", "local", "\\", "sitepolicy", "\\", "manager", "(", ")", ")", "&&", "$", "manager", "->", "is_defined", "(", ")", ")", ")", "{", "return", "''", ";", "}", "$", "renderer", "=", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ";", "$", "requestcount", "=", "\\", "core_message", "\\", "api", "::", "get_received_contact_requests_count", "(", "$", "USER", "->", "id", ")", ";", "$", "contactscount", "=", "\\", "core_message", "\\", "api", "::", "count_contacts", "(", "$", "USER", "->", "id", ")", ";", "$", "choices", "=", "[", "]", ";", "$", "choices", "[", "]", "=", "[", "'value'", "=>", "\\", "core_message", "\\", "api", "::", "MESSAGE_PRIVACY_ONLYCONTACTS", ",", "'text'", "=>", "get_string", "(", "'contactableprivacy_onlycontacts'", ",", "'message'", ")", "]", ";", "$", "choices", "[", "]", "=", "[", "'value'", "=>", "\\", "core_message", "\\", "api", "::", "MESSAGE_PRIVACY_COURSEMEMBER", ",", "'text'", "=>", "get_string", "(", "'contactableprivacy_coursemember'", ",", "'message'", ")", "]", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "messagingallusers", ")", ")", "{", "// Add the MESSAGE_PRIVACY_SITE option when site-wide messaging between users is enabled.", "$", "choices", "[", "]", "=", "[", "'value'", "=>", "\\", "core_message", "\\", "api", "::", "MESSAGE_PRIVACY_SITE", ",", "'text'", "=>", "get_string", "(", "'contactableprivacy_site'", ",", "'message'", ")", "]", ";", "}", "// Enter to send.", "$", "entertosend", "=", "get_user_preferences", "(", "'message_entertosend'", ",", "$", "CFG", "->", "messagingdefaultpressenter", ",", "$", "USER", ")", ";", "$", "notification", "=", "''", ";", "if", "(", "!", "get_user_preferences", "(", "'core_message_migrate_data'", ",", "false", ")", ")", "{", "$", "notification", "=", "get_string", "(", "'messagingdatahasnotbeenmigrated'", ",", "'message'", ")", ";", "}", "if", "(", "$", "isdrawer", ")", "{", "$", "template", "=", "'core_message/message_drawer'", ";", "$", "messageurl", "=", "new", "\\", "moodle_url", "(", "'/message/index.php'", ")", ";", "}", "else", "{", "$", "template", "=", "'core_message/message_index'", ";", "$", "messageurl", "=", "null", ";", "}", "$", "templatecontext", "=", "[", "'contactrequestcount'", "=>", "$", "requestcount", ",", "'loggedinuser'", "=>", "[", "'id'", "=>", "$", "USER", "->", "id", ",", "'midnight'", "=>", "usergetmidnight", "(", "time", "(", ")", ")", "]", ",", "'contacts'", "=>", "[", "'sectioncontacts'", "=>", "[", "'placeholders'", "=>", "array_fill", "(", "0", ",", "$", "contactscount", ">", "50", "?", "50", ":", "$", "contactscount", ",", "true", ")", "]", ",", "'sectionrequests'", "=>", "[", "'placeholders'", "=>", "array_fill", "(", "0", ",", "$", "requestcount", ">", "50", "?", "50", ":", "$", "requestcount", ",", "true", ")", "]", ",", "]", ",", "'settings'", "=>", "[", "'privacy'", "=>", "$", "choices", ",", "'entertosend'", "=>", "$", "entertosend", "]", ",", "'overview'", "=>", "[", "'messageurl'", "=>", "$", "messageurl", ",", "'notification'", "=>", "$", "notification", "]", ",", "'sendtouser'", "=>", "false", ",", "'conversationid'", "=>", "false", ",", "'isdrawer'", "=>", "$", "isdrawer", "]", ";", "if", "(", "$", "sendtouser", ")", "{", "$", "templatecontext", "[", "'sendtouser'", "]", "=", "$", "sendtouser", ";", "}", "if", "(", "$", "conversationid", ")", "{", "$", "templatecontext", "[", "'conversationid'", "]", "=", "$", "conversationid", ";", "}", "return", "$", "renderer", "->", "render_from_template", "(", "$", "template", ",", "$", "templatecontext", ")", ";", "}" ]
Renders the messaging widget. @param bool $isdrawer Are we are rendering the drawer or is this on a full page? @param int|null $sendtouser The ID of the user we want to send a message to @param int|null $conversationid The ID of the conversation we want to load @return string The HTML.
[ "Renders", "the", "messaging", "widget", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L690-L774
212,172
moodle/moodle
message/classes/helper.php
helper.search_get_user_details
public static function search_get_user_details(\stdClass $user) : array { global $CFG, $USER; require_once($CFG->dirroot . '/user/lib.php'); if ($CFG->messagingallusers || $user->id == $USER->id) { return \user_get_user_details_courses($user) ?? []; // This checks visibility of site and course profiles. } else { // Messaging specific: user must share a course with the searching user AND have a visible profile there. $sharedcourses = enrol_get_shared_courses($USER, $user); foreach ($sharedcourses as $course) { if (user_can_view_profile($user, $course)) { $userdetails = user_get_user_details($user, $course); if (!is_null($userdetails)) { return $userdetails; } } } } return []; }
php
public static function search_get_user_details(\stdClass $user) : array { global $CFG, $USER; require_once($CFG->dirroot . '/user/lib.php'); if ($CFG->messagingallusers || $user->id == $USER->id) { return \user_get_user_details_courses($user) ?? []; // This checks visibility of site and course profiles. } else { // Messaging specific: user must share a course with the searching user AND have a visible profile there. $sharedcourses = enrol_get_shared_courses($USER, $user); foreach ($sharedcourses as $course) { if (user_can_view_profile($user, $course)) { $userdetails = user_get_user_details($user, $course); if (!is_null($userdetails)) { return $userdetails; } } } } return []; }
[ "public", "static", "function", "search_get_user_details", "(", "\\", "stdClass", "$", "user", ")", ":", "array", "{", "global", "$", "CFG", ",", "$", "USER", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/user/lib.php'", ")", ";", "if", "(", "$", "CFG", "->", "messagingallusers", "||", "$", "user", "->", "id", "==", "$", "USER", "->", "id", ")", "{", "return", "\\", "user_get_user_details_courses", "(", "$", "user", ")", "??", "[", "]", ";", "// This checks visibility of site and course profiles.", "}", "else", "{", "// Messaging specific: user must share a course with the searching user AND have a visible profile there.", "$", "sharedcourses", "=", "enrol_get_shared_courses", "(", "$", "USER", ",", "$", "user", ")", ";", "foreach", "(", "$", "sharedcourses", "as", "$", "course", ")", "{", "if", "(", "user_can_view_profile", "(", "$", "user", ",", "$", "course", ")", ")", "{", "$", "userdetails", "=", "user_get_user_details", "(", "$", "user", ",", "$", "course", ")", ";", "if", "(", "!", "is_null", "(", "$", "userdetails", ")", ")", "{", "return", "$", "userdetails", ";", "}", "}", "}", "}", "return", "[", "]", ";", "}" ]
Returns user details for a user, if they are visible to the current user in the message search. This method checks the visibility of a user specifically for the purpose of inclusion in the message search results. Visibility depends on the site-wide messaging setting 'messagingallusers': If enabled, visibility depends only on the core notion of visibility; a visible site or course profile. If disabled, visibility requires that the user be sharing a course with the searching user, and have a visible profile there. The current user is always returned. @param \stdClass $user @return array the array of userdetails, if visible, or an empty array otherwise.
[ "Returns", "user", "details", "for", "a", "user", "if", "they", "are", "visible", "to", "the", "current", "user", "in", "the", "message", "search", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/helper.php#L788-L807
212,173
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.set_attributes
public function set_attributes($type, $fields, $reftable=null, $reffields=null) { $this->type = $type; $this->fields = $fields; $this->reftable = $reftable; $this->reffields = empty($reffields) ? array() : $reffields; }
php
public function set_attributes($type, $fields, $reftable=null, $reffields=null) { $this->type = $type; $this->fields = $fields; $this->reftable = $reftable; $this->reffields = empty($reffields) ? array() : $reffields; }
[ "public", "function", "set_attributes", "(", "$", "type", ",", "$", "fields", ",", "$", "reftable", "=", "null", ",", "$", "reffields", "=", "null", ")", "{", "$", "this", "->", "type", "=", "$", "type", ";", "$", "this", "->", "fields", "=", "$", "fields", ";", "$", "this", "->", "reftable", "=", "$", "reftable", ";", "$", "this", "->", "reffields", "=", "empty", "(", "$", "reffields", ")", "?", "array", "(", ")", ":", "$", "reffields", ";", "}" ]
Set all the attributes of one xmldb_key @param string $type XMLDB_KEY_[PRIMARY|UNIQUE|FOREIGN|FOREIGN_UNIQUE] @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
[ "Set", "all", "the", "attributes", "of", "one", "xmldb_key" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L68-L73
212,174
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.getXMLDBKeyType
public function getXMLDBKeyType($type) { $result = XMLDB_KEY_INCORRECT; switch (strtolower($type)) { case 'primary': $result = XMLDB_KEY_PRIMARY; break; case 'unique': $result = XMLDB_KEY_UNIQUE; break; case 'foreign': $result = XMLDB_KEY_FOREIGN; break; case 'foreign-unique': $result = XMLDB_KEY_FOREIGN_UNIQUE; break; // case 'check': //Not supported // $result = XMLDB_KEY_CHECK; // break; } // Return the normalized XMLDB_KEY return $result; }
php
public function getXMLDBKeyType($type) { $result = XMLDB_KEY_INCORRECT; switch (strtolower($type)) { case 'primary': $result = XMLDB_KEY_PRIMARY; break; case 'unique': $result = XMLDB_KEY_UNIQUE; break; case 'foreign': $result = XMLDB_KEY_FOREIGN; break; case 'foreign-unique': $result = XMLDB_KEY_FOREIGN_UNIQUE; break; // case 'check': //Not supported // $result = XMLDB_KEY_CHECK; // break; } // Return the normalized XMLDB_KEY return $result; }
[ "public", "function", "getXMLDBKeyType", "(", "$", "type", ")", "{", "$", "result", "=", "XMLDB_KEY_INCORRECT", ";", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "case", "'primary'", ":", "$", "result", "=", "XMLDB_KEY_PRIMARY", ";", "break", ";", "case", "'unique'", ":", "$", "result", "=", "XMLDB_KEY_UNIQUE", ";", "break", ";", "case", "'foreign'", ":", "$", "result", "=", "XMLDB_KEY_FOREIGN", ";", "break", ";", "case", "'foreign-unique'", ":", "$", "result", "=", "XMLDB_KEY_FOREIGN_UNIQUE", ";", "break", ";", "// case 'check': //Not supported", "// $result = XMLDB_KEY_CHECK;", "// break;", "}", "// Return the normalized XMLDB_KEY", "return", "$", "result", ";", "}" ]
This function returns the correct XMLDB_KEY_XXX value for the string passed as argument @param string $type @return int
[ "This", "function", "returns", "the", "correct", "XMLDB_KEY_XXX", "value", "for", "the", "string", "passed", "as", "argument" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L288-L311
212,175
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.getXMLDBKeyName
public function getXMLDBKeyName($type) { $result = ''; switch ($type) { case XMLDB_KEY_PRIMARY: $result = 'primary'; break; case XMLDB_KEY_UNIQUE: $result = 'unique'; break; case XMLDB_KEY_FOREIGN: $result = 'foreign'; break; case XMLDB_KEY_FOREIGN_UNIQUE: $result = 'foreign-unique'; break; // case XMLDB_KEY_CHECK: //Not supported // $result = 'check'; // break; } // Return the normalized name return $result; }
php
public function getXMLDBKeyName($type) { $result = ''; switch ($type) { case XMLDB_KEY_PRIMARY: $result = 'primary'; break; case XMLDB_KEY_UNIQUE: $result = 'unique'; break; case XMLDB_KEY_FOREIGN: $result = 'foreign'; break; case XMLDB_KEY_FOREIGN_UNIQUE: $result = 'foreign-unique'; break; // case XMLDB_KEY_CHECK: //Not supported // $result = 'check'; // break; } // Return the normalized name return $result; }
[ "public", "function", "getXMLDBKeyName", "(", "$", "type", ")", "{", "$", "result", "=", "''", ";", "switch", "(", "$", "type", ")", "{", "case", "XMLDB_KEY_PRIMARY", ":", "$", "result", "=", "'primary'", ";", "break", ";", "case", "XMLDB_KEY_UNIQUE", ":", "$", "result", "=", "'unique'", ";", "break", ";", "case", "XMLDB_KEY_FOREIGN", ":", "$", "result", "=", "'foreign'", ";", "break", ";", "case", "XMLDB_KEY_FOREIGN_UNIQUE", ":", "$", "result", "=", "'foreign-unique'", ";", "break", ";", "// case XMLDB_KEY_CHECK: //Not supported", "// $result = 'check';", "// break;", "}", "// Return the normalized name", "return", "$", "result", ";", "}" ]
This function returns the correct name value for the XMLDB_KEY_XXX passed as argument @param int $type @return string
[ "This", "function", "returns", "the", "correct", "name", "value", "for", "the", "XMLDB_KEY_XXX", "passed", "as", "argument" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L319-L342
212,176
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.calculateHash
public function calculateHash($recursive = false) { if (!$this->loaded) { $this->hash = null; } else { $key = $this->type . implode(', ', $this->fields); if ($this->type == XMLDB_KEY_FOREIGN || $this->type == XMLDB_KEY_FOREIGN_UNIQUE) { $key .= $this->reftable . implode(', ', $this->reffields); } ; $this->hash = md5($key); } }
php
public function calculateHash($recursive = false) { if (!$this->loaded) { $this->hash = null; } else { $key = $this->type . implode(', ', $this->fields); if ($this->type == XMLDB_KEY_FOREIGN || $this->type == XMLDB_KEY_FOREIGN_UNIQUE) { $key .= $this->reftable . implode(', ', $this->reffields); } ; $this->hash = md5($key); } }
[ "public", "function", "calculateHash", "(", "$", "recursive", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "loaded", ")", "{", "$", "this", "->", "hash", "=", "null", ";", "}", "else", "{", "$", "key", "=", "$", "this", "->", "type", ".", "implode", "(", "', '", ",", "$", "this", "->", "fields", ")", ";", "if", "(", "$", "this", "->", "type", "==", "XMLDB_KEY_FOREIGN", "||", "$", "this", "->", "type", "==", "XMLDB_KEY_FOREIGN_UNIQUE", ")", "{", "$", "key", ".=", "$", "this", "->", "reftable", ".", "implode", "(", "', '", ",", "$", "this", "->", "reffields", ")", ";", "}", ";", "$", "this", "->", "hash", "=", "md5", "(", "$", "key", ")", ";", "}", "}" ]
This function calculate and set the hash of one xmldb_key @param bool $recursive
[ "This", "function", "calculate", "and", "set", "the", "hash", "of", "one", "xmldb_key" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L348-L360
212,177
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.xmlOutput
public function xmlOutput() { $o = ''; $o.= ' <KEY NAME="' . $this->name . '"'; $o.= ' TYPE="' . $this->getXMLDBKeyName($this->type) . '"'; $o.= ' FIELDS="' . implode(', ', $this->fields) . '"'; if ($this->type == XMLDB_KEY_FOREIGN || $this->type == XMLDB_KEY_FOREIGN_UNIQUE) { $o.= ' REFTABLE="' . $this->reftable . '"'; $o.= ' REFFIELDS="' . implode(', ', $this->reffields) . '"'; } if ($this->comment) { $o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"'; } $o.= '/>' . "\n"; return $o; }
php
public function xmlOutput() { $o = ''; $o.= ' <KEY NAME="' . $this->name . '"'; $o.= ' TYPE="' . $this->getXMLDBKeyName($this->type) . '"'; $o.= ' FIELDS="' . implode(', ', $this->fields) . '"'; if ($this->type == XMLDB_KEY_FOREIGN || $this->type == XMLDB_KEY_FOREIGN_UNIQUE) { $o.= ' REFTABLE="' . $this->reftable . '"'; $o.= ' REFFIELDS="' . implode(', ', $this->reffields) . '"'; } if ($this->comment) { $o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"'; } $o.= '/>' . "\n"; return $o; }
[ "public", "function", "xmlOutput", "(", ")", "{", "$", "o", "=", "''", ";", "$", "o", ".=", "' <KEY NAME=\"'", ".", "$", "this", "->", "name", ".", "'\"'", ";", "$", "o", ".=", "' TYPE=\"'", ".", "$", "this", "->", "getXMLDBKeyName", "(", "$", "this", "->", "type", ")", ".", "'\"'", ";", "$", "o", ".=", "' FIELDS=\"'", ".", "implode", "(", "', '", ",", "$", "this", "->", "fields", ")", ".", "'\"'", ";", "if", "(", "$", "this", "->", "type", "==", "XMLDB_KEY_FOREIGN", "||", "$", "this", "->", "type", "==", "XMLDB_KEY_FOREIGN_UNIQUE", ")", "{", "$", "o", ".=", "' REFTABLE=\"'", ".", "$", "this", "->", "reftable", ".", "'\"'", ";", "$", "o", ".=", "' REFFIELDS=\"'", ".", "implode", "(", "', '", ",", "$", "this", "->", "reffields", ")", ".", "'\"'", ";", "}", "if", "(", "$", "this", "->", "comment", ")", "{", "$", "o", ".=", "' COMMENT=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "comment", ")", ".", "'\"'", ";", "}", "$", "o", ".=", "'/>'", ".", "\"\\n\"", ";", "return", "$", "o", ";", "}" ]
This function will output the XML text for one key @return string
[ "This", "function", "will", "output", "the", "XML", "text", "for", "one", "key" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L366-L382
212,178
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.setFromADOKey
public function setFromADOKey($adokey) { // Calculate the XMLDB_KEY switch (strtolower($adokey['name'])) { case 'primary': $this->type = XMLDB_KEY_PRIMARY; break; default: $this->type = XMLDB_KEY_UNIQUE; } // Set the fields, converting all them to lowercase $fields = array_flip(array_change_key_case(array_flip($adokey['columns']))); $this->fields = $fields; // Some more fields $this->loaded = true; $this->changed = true; }
php
public function setFromADOKey($adokey) { // Calculate the XMLDB_KEY switch (strtolower($adokey['name'])) { case 'primary': $this->type = XMLDB_KEY_PRIMARY; break; default: $this->type = XMLDB_KEY_UNIQUE; } // Set the fields, converting all them to lowercase $fields = array_flip(array_change_key_case(array_flip($adokey['columns']))); $this->fields = $fields; // Some more fields $this->loaded = true; $this->changed = true; }
[ "public", "function", "setFromADOKey", "(", "$", "adokey", ")", "{", "// Calculate the XMLDB_KEY", "switch", "(", "strtolower", "(", "$", "adokey", "[", "'name'", "]", ")", ")", "{", "case", "'primary'", ":", "$", "this", "->", "type", "=", "XMLDB_KEY_PRIMARY", ";", "break", ";", "default", ":", "$", "this", "->", "type", "=", "XMLDB_KEY_UNIQUE", ";", "}", "// Set the fields, converting all them to lowercase", "$", "fields", "=", "array_flip", "(", "array_change_key_case", "(", "array_flip", "(", "$", "adokey", "[", "'columns'", "]", ")", ")", ")", ";", "$", "this", "->", "fields", "=", "$", "fields", ";", "// Some more fields", "$", "this", "->", "loaded", "=", "true", ";", "$", "this", "->", "changed", "=", "true", ";", "}" ]
This function will set all the attributes of the xmldb_key object based on information passed in one ADOkey @oaram array $adokey
[ "This", "function", "will", "set", "all", "the", "attributes", "of", "the", "xmldb_key", "object", "based", "on", "information", "passed", "in", "one", "ADOkey" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L389-L405
212,179
moodle/moodle
lib/xmldb/xmldb_key.php
xmldb_key.getPHP
public function getPHP() { $result = ''; // The type switch ($this->getType()) { case XMLDB_KEY_PRIMARY: $result .= 'XMLDB_KEY_PRIMARY' . ', '; break; case XMLDB_KEY_UNIQUE: $result .= 'XMLDB_KEY_UNIQUE' . ', '; break; case XMLDB_KEY_FOREIGN: $result .= 'XMLDB_KEY_FOREIGN' . ', '; break; case XMLDB_KEY_FOREIGN_UNIQUE: $result .= 'XMLDB_KEY_FOREIGN_UNIQUE' . ', '; break; } // The fields $keyfields = $this->getFields(); if (!empty($keyfields)) { $result .= "['". implode("', '", $keyfields) . "']"; } else { $result .= 'null'; } // The FKs attributes if ($this->getType() == XMLDB_KEY_FOREIGN || $this->getType() == XMLDB_KEY_FOREIGN_UNIQUE) { // The reftable $reftable = $this->getRefTable(); if (!empty($reftable)) { $result .= ", '" . $reftable . "', "; } else { $result .= 'null, '; } // The reffields $reffields = $this->getRefFields(); if (!empty($reffields)) { $result .= "['". implode("', '", $reffields) . "']"; } else { $result .= 'null'; } } // Return result return $result; }
php
public function getPHP() { $result = ''; // The type switch ($this->getType()) { case XMLDB_KEY_PRIMARY: $result .= 'XMLDB_KEY_PRIMARY' . ', '; break; case XMLDB_KEY_UNIQUE: $result .= 'XMLDB_KEY_UNIQUE' . ', '; break; case XMLDB_KEY_FOREIGN: $result .= 'XMLDB_KEY_FOREIGN' . ', '; break; case XMLDB_KEY_FOREIGN_UNIQUE: $result .= 'XMLDB_KEY_FOREIGN_UNIQUE' . ', '; break; } // The fields $keyfields = $this->getFields(); if (!empty($keyfields)) { $result .= "['". implode("', '", $keyfields) . "']"; } else { $result .= 'null'; } // The FKs attributes if ($this->getType() == XMLDB_KEY_FOREIGN || $this->getType() == XMLDB_KEY_FOREIGN_UNIQUE) { // The reftable $reftable = $this->getRefTable(); if (!empty($reftable)) { $result .= ", '" . $reftable . "', "; } else { $result .= 'null, '; } // The reffields $reffields = $this->getRefFields(); if (!empty($reffields)) { $result .= "['". implode("', '", $reffields) . "']"; } else { $result .= 'null'; } } // Return result return $result; }
[ "public", "function", "getPHP", "(", ")", "{", "$", "result", "=", "''", ";", "// The type", "switch", "(", "$", "this", "->", "getType", "(", ")", ")", "{", "case", "XMLDB_KEY_PRIMARY", ":", "$", "result", ".=", "'XMLDB_KEY_PRIMARY'", ".", "', '", ";", "break", ";", "case", "XMLDB_KEY_UNIQUE", ":", "$", "result", ".=", "'XMLDB_KEY_UNIQUE'", ".", "', '", ";", "break", ";", "case", "XMLDB_KEY_FOREIGN", ":", "$", "result", ".=", "'XMLDB_KEY_FOREIGN'", ".", "', '", ";", "break", ";", "case", "XMLDB_KEY_FOREIGN_UNIQUE", ":", "$", "result", ".=", "'XMLDB_KEY_FOREIGN_UNIQUE'", ".", "', '", ";", "break", ";", "}", "// The fields", "$", "keyfields", "=", "$", "this", "->", "getFields", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "keyfields", ")", ")", "{", "$", "result", ".=", "\"['\"", ".", "implode", "(", "\"', '\"", ",", "$", "keyfields", ")", ".", "\"']\"", ";", "}", "else", "{", "$", "result", ".=", "'null'", ";", "}", "// The FKs attributes", "if", "(", "$", "this", "->", "getType", "(", ")", "==", "XMLDB_KEY_FOREIGN", "||", "$", "this", "->", "getType", "(", ")", "==", "XMLDB_KEY_FOREIGN_UNIQUE", ")", "{", "// The reftable", "$", "reftable", "=", "$", "this", "->", "getRefTable", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "reftable", ")", ")", "{", "$", "result", ".=", "\", '\"", ".", "$", "reftable", ".", "\"', \"", ";", "}", "else", "{", "$", "result", ".=", "'null, '", ";", "}", "// The reffields", "$", "reffields", "=", "$", "this", "->", "getRefFields", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "reffields", ")", ")", "{", "$", "result", ".=", "\"['\"", ".", "implode", "(", "\"', '\"", ",", "$", "reffields", ")", ".", "\"']\"", ";", "}", "else", "{", "$", "result", ".=", "'null'", ";", "}", "}", "// Return result", "return", "$", "result", ";", "}" ]
Returns the PHP code needed to define one xmldb_key @return string
[ "Returns", "the", "PHP", "code", "needed", "to", "define", "one", "xmldb_key" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/xmldb/xmldb_key.php#L411-L457
212,180
moodle/moodle
lib/horde/framework/Horde/Support/CaseInsensitiveArray.php
Horde_Support_CaseInsensitiveArray._getRealOffset
protected function _getRealOffset($offset) { /* Optimize: check for base $offset in array first. */ if (parent::offsetExists($offset)) { return $offset; } foreach (array_keys($this->getArrayCopy()) as $key) { if (strcasecmp($key, $offset) === 0) { return $key; } } return null; }
php
protected function _getRealOffset($offset) { /* Optimize: check for base $offset in array first. */ if (parent::offsetExists($offset)) { return $offset; } foreach (array_keys($this->getArrayCopy()) as $key) { if (strcasecmp($key, $offset) === 0) { return $key; } } return null; }
[ "protected", "function", "_getRealOffset", "(", "$", "offset", ")", "{", "/* Optimize: check for base $offset in array first. */", "if", "(", "parent", "::", "offsetExists", "(", "$", "offset", ")", ")", "{", "return", "$", "offset", ";", "}", "foreach", "(", "array_keys", "(", "$", "this", "->", "getArrayCopy", "(", ")", ")", "as", "$", "key", ")", "{", "if", "(", "strcasecmp", "(", "$", "key", ",", "$", "offset", ")", "===", "0", ")", "{", "return", "$", "key", ";", "}", "}", "return", "null", ";", "}" ]
Determines the actual array offset given the input offset. @param string $offset Input offset. @return string Real offset or null.
[ "Determines", "the", "actual", "array", "offset", "given", "the", "input", "offset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Support/CaseInsensitiveArray.php#L68-L82
212,181
moodle/moodle
mod/lesson/backup/moodle2/backup_lesson_activity_task.class.php
backup_lesson_activity_task.encode_content_links
static public function encode_content_links($content) { global $CFG; $base = preg_quote($CFG->wwwroot.'/mod/lesson','#'); // Provides the interface for overall authoring of lessons $pattern = '#'.$base.'/edit\.php\?id=([0-9]+)#'; $replacement = '$@LESSONEDIT*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Action for adding a question page. Prints an HTML form. $pattern = '#'.$base.'/editpage\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; $replacement = '$@LESSONEDITPAGE*$1*$3@$'; $content = preg_replace($pattern, $replacement, $content); // Provides the interface for grading essay questions $pattern = '#'.$base.'/essay\.php\?id=([0-9]+)#'; $replacement = '$@LESSONESSAY*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Provides the interface for viewing the report $pattern = '#'.$base.'/report\.php\?id=([0-9]+)#'; $replacement = '$@LESSONREPORT*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This file plays the mediafile set in lesson settings. $pattern = '#'.$base.'/mediafile\.php\?id=([0-9]+)#'; $replacement = '$@LESSONMEDIAFILE*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This page lists all the instances of lesson in a particular course $pattern = '#'.$base.'/index\.php\?id=([0-9]+)#'; $replacement = '$@LESSONINDEX*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This page prints a particular page of lesson $pattern = '#'.$base.'/view\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; $replacement = '$@LESSONVIEWPAGE*$1*$3@$'; $content = preg_replace($pattern, $replacement, $content); // Link to one lesson by cmid $pattern = '#'.$base.'/view\.php\?id=([0-9]+)#'; $replacement = '$@LESSONVIEWBYID*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Return the now encoded content return $content; }
php
static public function encode_content_links($content) { global $CFG; $base = preg_quote($CFG->wwwroot.'/mod/lesson','#'); // Provides the interface for overall authoring of lessons $pattern = '#'.$base.'/edit\.php\?id=([0-9]+)#'; $replacement = '$@LESSONEDIT*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Action for adding a question page. Prints an HTML form. $pattern = '#'.$base.'/editpage\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; $replacement = '$@LESSONEDITPAGE*$1*$3@$'; $content = preg_replace($pattern, $replacement, $content); // Provides the interface for grading essay questions $pattern = '#'.$base.'/essay\.php\?id=([0-9]+)#'; $replacement = '$@LESSONESSAY*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Provides the interface for viewing the report $pattern = '#'.$base.'/report\.php\?id=([0-9]+)#'; $replacement = '$@LESSONREPORT*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This file plays the mediafile set in lesson settings. $pattern = '#'.$base.'/mediafile\.php\?id=([0-9]+)#'; $replacement = '$@LESSONMEDIAFILE*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This page lists all the instances of lesson in a particular course $pattern = '#'.$base.'/index\.php\?id=([0-9]+)#'; $replacement = '$@LESSONINDEX*$1@$'; $content = preg_replace($pattern, $replacement, $content); // This page prints a particular page of lesson $pattern = '#'.$base.'/view\.php\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'; $replacement = '$@LESSONVIEWPAGE*$1*$3@$'; $content = preg_replace($pattern, $replacement, $content); // Link to one lesson by cmid $pattern = '#'.$base.'/view\.php\?id=([0-9]+)#'; $replacement = '$@LESSONVIEWBYID*$1@$'; $content = preg_replace($pattern, $replacement, $content); // Return the now encoded content return $content; }
[ "static", "public", "function", "encode_content_links", "(", "$", "content", ")", "{", "global", "$", "CFG", ";", "$", "base", "=", "preg_quote", "(", "$", "CFG", "->", "wwwroot", ".", "'/mod/lesson'", ",", "'#'", ")", ";", "// Provides the interface for overall authoring of lessons", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/edit\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONEDIT*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// Action for adding a question page. Prints an HTML form.", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/editpage\\.php\\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONEDITPAGE*$1*$3@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// Provides the interface for grading essay questions", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/essay\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONESSAY*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// Provides the interface for viewing the report", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/report\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONREPORT*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// This file plays the mediafile set in lesson settings.", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/mediafile\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONMEDIAFILE*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// This page lists all the instances of lesson in a particular course", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/index\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONINDEX*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// This page prints a particular page of lesson", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/view\\.php\\?id=([0-9]+)&(amp;)?pageid=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONVIEWPAGE*$1*$3@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// Link to one lesson by cmid", "$", "pattern", "=", "'#'", ".", "$", "base", ".", "'/view\\.php\\?id=([0-9]+)#'", ";", "$", "replacement", "=", "'$@LESSONVIEWBYID*$1@$'", ";", "$", "content", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replacement", ",", "$", "content", ")", ";", "// Return the now encoded content", "return", "$", "content", ";", "}" ]
Encodes URLs to various Lesson scripts @param string $content some HTML text that eventually contains URLs to the activity instance scripts @return string the content with the URLs encoded
[ "Encodes", "URLs", "to", "various", "Lesson", "scripts" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/backup/moodle2/backup_lesson_activity_task.class.php#L58-L105
212,182
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_user
private function get_user() { $userid = $this->backuprec->userid; $user = core_user::get_user($userid, '*', MUST_EXIST); return $user; }
php
private function get_user() { $userid = $this->backuprec->userid; $user = core_user::get_user($userid, '*', MUST_EXIST); return $user; }
[ "private", "function", "get_user", "(", ")", "{", "$", "userid", "=", "$", "this", "->", "backuprec", "->", "userid", ";", "$", "user", "=", "core_user", "::", "get_user", "(", "$", "userid", ",", "'*'", ",", "MUST_EXIST", ")", ";", "return", "$", "user", ";", "}" ]
Given a user id return a user object. @return object $user The limited user record.
[ "Given", "a", "user", "id", "return", "a", "user", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L92-L97
212,183
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.lookup_message_variables
private function lookup_message_variables($matches) { $options = array( 'operation' => $this->type, 'backupid' => $this->backupid, 'user_username' => $this->user->username, 'user_email' => $this->user->email, 'user_firstname' => $this->user->firstname, 'user_lastname' => $this->user->lastname, 'link' => $this->get_resource_link(), ); $match = $options[$matches[1]] ?? $matches[1]; return $match; }
php
private function lookup_message_variables($matches) { $options = array( 'operation' => $this->type, 'backupid' => $this->backupid, 'user_username' => $this->user->username, 'user_email' => $this->user->email, 'user_firstname' => $this->user->firstname, 'user_lastname' => $this->user->lastname, 'link' => $this->get_resource_link(), ); $match = $options[$matches[1]] ?? $matches[1]; return $match; }
[ "private", "function", "lookup_message_variables", "(", "$", "matches", ")", "{", "$", "options", "=", "array", "(", "'operation'", "=>", "$", "this", "->", "type", ",", "'backupid'", "=>", "$", "this", "->", "backupid", ",", "'user_username'", "=>", "$", "this", "->", "user", "->", "username", ",", "'user_email'", "=>", "$", "this", "->", "user", "->", "email", ",", "'user_firstname'", "=>", "$", "this", "->", "user", "->", "firstname", ",", "'user_lastname'", "=>", "$", "this", "->", "user", "->", "lastname", ",", "'link'", "=>", "$", "this", "->", "get_resource_link", "(", ")", ",", ")", ";", "$", "match", "=", "$", "options", "[", "$", "matches", "[", "1", "]", "]", "??", "$", "matches", "[", "1", "]", ";", "return", "$", "match", ";", "}" ]
Callback for preg_replace_callback. Replaces message placeholders with real values. @param array $matches The match array from from preg_replace_callback. @return string $match The replaced string.
[ "Callback", "for", "preg_replace_callback", ".", "Replaces", "message", "placeholders", "with", "real", "values", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L106-L120
212,184
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_resource_link
private function get_resource_link() { // Get activity context only for backups. if ($this->backuprec->type == 'activity' && $this->type == 'backup') { $context = context_module::instance($this->backuprec->itemid); } else { // Course or Section which have the same context getter. $context = context_course::instance($this->backuprec->itemid); } // Generate link based on operation type. if ($this->type == 'backup') { // For backups simply generate link to restore file area UI. $url = new moodle_url('/backup/restorefile.php', array('contextid' => $context->id)); } else { // For restore generate link to the item itself. $url = $context->get_url(); } return $url; }
php
private function get_resource_link() { // Get activity context only for backups. if ($this->backuprec->type == 'activity' && $this->type == 'backup') { $context = context_module::instance($this->backuprec->itemid); } else { // Course or Section which have the same context getter. $context = context_course::instance($this->backuprec->itemid); } // Generate link based on operation type. if ($this->type == 'backup') { // For backups simply generate link to restore file area UI. $url = new moodle_url('/backup/restorefile.php', array('contextid' => $context->id)); } else { // For restore generate link to the item itself. $url = $context->get_url(); } return $url; }
[ "private", "function", "get_resource_link", "(", ")", "{", "// Get activity context only for backups.", "if", "(", "$", "this", "->", "backuprec", "->", "type", "==", "'activity'", "&&", "$", "this", "->", "type", "==", "'backup'", ")", "{", "$", "context", "=", "context_module", "::", "instance", "(", "$", "this", "->", "backuprec", "->", "itemid", ")", ";", "}", "else", "{", "// Course or Section which have the same context getter.", "$", "context", "=", "context_course", "::", "instance", "(", "$", "this", "->", "backuprec", "->", "itemid", ")", ";", "}", "// Generate link based on operation type.", "if", "(", "$", "this", "->", "type", "==", "'backup'", ")", "{", "// For backups simply generate link to restore file area UI.", "$", "url", "=", "new", "moodle_url", "(", "'/backup/restorefile.php'", ",", "array", "(", "'contextid'", "=>", "$", "context", "->", "id", ")", ")", ";", "}", "else", "{", "// For restore generate link to the item itself.", "$", "url", "=", "$", "context", "->", "get_url", "(", ")", ";", "}", "return", "$", "url", ";", "}" ]
Get the link to the resource that is being backuped or restored. @return moodle_url $url The link to the resource.
[ "Get", "the", "link", "to", "the", "resource", "that", "is", "being", "backuped", "or", "restored", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L127-L145
212,185
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.send_message
public function send_message() { global $USER; $subjectraw = get_config('backup', 'backup_async_message_subject'); $subjecttext = preg_replace_callback( '/\{([-_A-Za-z0-9]+)\}/u', array('async_helper', 'lookup_message_variables'), $subjectraw); $messageraw = get_config('backup', 'backup_async_message'); $messagehtml = preg_replace_callback( '/\{([-_A-Za-z0-9]+)\}/u', array('async_helper', 'lookup_message_variables'), $messageraw); $messagetext = html_to_text($messagehtml); $message = new \core\message\message(); $message->component = 'moodle'; $message->name = 'asyncbackupnotification'; $message->userfrom = $USER; $message->userto = $this->user; $message->subject = $subjecttext; $message->fullmessage = $messagetext; $message->fullmessageformat = FORMAT_HTML; $message->fullmessagehtml = $messagehtml; $message->smallmessage = ''; $message->notification = '1'; $messageid = message_send($message); return $messageid; }
php
public function send_message() { global $USER; $subjectraw = get_config('backup', 'backup_async_message_subject'); $subjecttext = preg_replace_callback( '/\{([-_A-Za-z0-9]+)\}/u', array('async_helper', 'lookup_message_variables'), $subjectraw); $messageraw = get_config('backup', 'backup_async_message'); $messagehtml = preg_replace_callback( '/\{([-_A-Za-z0-9]+)\}/u', array('async_helper', 'lookup_message_variables'), $messageraw); $messagetext = html_to_text($messagehtml); $message = new \core\message\message(); $message->component = 'moodle'; $message->name = 'asyncbackupnotification'; $message->userfrom = $USER; $message->userto = $this->user; $message->subject = $subjecttext; $message->fullmessage = $messagetext; $message->fullmessageformat = FORMAT_HTML; $message->fullmessagehtml = $messagehtml; $message->smallmessage = ''; $message->notification = '1'; $messageid = message_send($message); return $messageid; }
[ "public", "function", "send_message", "(", ")", "{", "global", "$", "USER", ";", "$", "subjectraw", "=", "get_config", "(", "'backup'", ",", "'backup_async_message_subject'", ")", ";", "$", "subjecttext", "=", "preg_replace_callback", "(", "'/\\{([-_A-Za-z0-9]+)\\}/u'", ",", "array", "(", "'async_helper'", ",", "'lookup_message_variables'", ")", ",", "$", "subjectraw", ")", ";", "$", "messageraw", "=", "get_config", "(", "'backup'", ",", "'backup_async_message'", ")", ";", "$", "messagehtml", "=", "preg_replace_callback", "(", "'/\\{([-_A-Za-z0-9]+)\\}/u'", ",", "array", "(", "'async_helper'", ",", "'lookup_message_variables'", ")", ",", "$", "messageraw", ")", ";", "$", "messagetext", "=", "html_to_text", "(", "$", "messagehtml", ")", ";", "$", "message", "=", "new", "\\", "core", "\\", "message", "\\", "message", "(", ")", ";", "$", "message", "->", "component", "=", "'moodle'", ";", "$", "message", "->", "name", "=", "'asyncbackupnotification'", ";", "$", "message", "->", "userfrom", "=", "$", "USER", ";", "$", "message", "->", "userto", "=", "$", "this", "->", "user", ";", "$", "message", "->", "subject", "=", "$", "subjecttext", ";", "$", "message", "->", "fullmessage", "=", "$", "messagetext", ";", "$", "message", "->", "fullmessageformat", "=", "FORMAT_HTML", ";", "$", "message", "->", "fullmessagehtml", "=", "$", "messagehtml", ";", "$", "message", "->", "smallmessage", "=", "''", ";", "$", "message", "->", "notification", "=", "'1'", ";", "$", "messageid", "=", "message_send", "(", "$", "message", ")", ";", "return", "$", "messageid", ";", "}" ]
Sends a confirmation message for an aynchronous process. @return int $messageid The id of the sent message.
[ "Sends", "a", "confirmation", "message", "for", "an", "aynchronous", "process", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L152-L183
212,186
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.is_async_enabled
static public function is_async_enabled() { global $CFG; $async = false; if (!empty($CFG->enableasyncbackup)) { $async = true; } return $async; }
php
static public function is_async_enabled() { global $CFG; $async = false; if (!empty($CFG->enableasyncbackup)) { $async = true; } return $async; }
[ "static", "public", "function", "is_async_enabled", "(", ")", "{", "global", "$", "CFG", ";", "$", "async", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "enableasyncbackup", ")", ")", "{", "$", "async", "=", "true", ";", "}", "return", "$", "async", ";", "}" ]
Check if asynchronous backup and restore mode is enabled at system level. @return bool $async True if async mode enabled false otherwise.
[ "Check", "if", "asynchronous", "backup", "and", "restore", "mode", "is", "enabled", "at", "system", "level", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L191-L200
212,187
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.is_async_pending
public static function is_async_pending($id, $type, $operation) { global $DB, $USER, $CFG; $asyncpending = false; // Only check for pending async operations if async mode is enabled. require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php'); require_once($CFG->dirroot . '/backup/backup.class.php'); if (self::is_async_enabled()) { $select = 'userid = ? AND itemid = ? AND type = ? AND operation = ? AND execution = ? AND status < ? AND status > ?'; $params = array( $USER->id, $id, $type, $operation, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK ); $asyncpending = $DB->record_exists_select('backup_controllers', $select, $params); } return $asyncpending; }
php
public static function is_async_pending($id, $type, $operation) { global $DB, $USER, $CFG; $asyncpending = false; // Only check for pending async operations if async mode is enabled. require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php'); require_once($CFG->dirroot . '/backup/backup.class.php'); if (self::is_async_enabled()) { $select = 'userid = ? AND itemid = ? AND type = ? AND operation = ? AND execution = ? AND status < ? AND status > ?'; $params = array( $USER->id, $id, $type, $operation, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK ); $asyncpending = $DB->record_exists_select('backup_controllers', $select, $params); } return $asyncpending; }
[ "public", "static", "function", "is_async_pending", "(", "$", "id", ",", "$", "type", ",", "$", "operation", ")", "{", "global", "$", "DB", ",", "$", "USER", ",", "$", "CFG", ";", "$", "asyncpending", "=", "false", ";", "// Only check for pending async operations if async mode is enabled.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/backup/util/interfaces/checksumable.class.php'", ")", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/backup/backup.class.php'", ")", ";", "if", "(", "self", "::", "is_async_enabled", "(", ")", ")", "{", "$", "select", "=", "'userid = ? AND itemid = ? AND type = ? AND operation = ? AND execution = ? AND status < ? AND status > ?'", ";", "$", "params", "=", "array", "(", "$", "USER", "->", "id", ",", "$", "id", ",", "$", "type", ",", "$", "operation", ",", "backup", "::", "EXECUTION_DELAYED", ",", "backup", "::", "STATUS_FINISHED_ERR", ",", "backup", "::", "STATUS_NEED_PRECHECK", ")", ";", "$", "asyncpending", "=", "$", "DB", "->", "record_exists_select", "(", "'backup_controllers'", ",", "$", "select", ",", "$", "params", ")", ";", "}", "return", "$", "asyncpending", ";", "}" ]
Check if there is a pending async operation for given details. @param int $id The item id to check in the backup record. @param string $type The type of operation: course, activity or section. @param string $operation Operation backup or restore. @return boolean $asyncpedning Is there a pending async operation.
[ "Check", "if", "there", "is", "a", "pending", "async", "operation", "for", "given", "details", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L210-L232
212,188
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_backup_file_info
public static function get_backup_file_info($filename, $filearea, $contextid) { $fs = get_file_storage(); $file = $fs->get_file($contextid, 'backup', $filearea, 0, '/', $filename); $filesize = display_size ($file->get_filesize()); $fileurl = moodle_url::make_pluginfile_url( $file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename(), true ); $params = array(); $params['action'] = 'choosebackupfile'; $params['filename'] = $file->get_filename(); $params['filepath'] = $file->get_filepath(); $params['component'] = $file->get_component(); $params['filearea'] = $file->get_filearea(); $params['filecontextid'] = $file->get_contextid(); $params['contextid'] = $contextid; $params['itemid'] = $file->get_itemid(); $restoreurl = new moodle_url('/backup/restorefile.php', $params); $filesize = display_size ($file->get_filesize()); $results = array( 'filesize' => $filesize, 'fileurl' => $fileurl->out(false), 'restoreurl' => $restoreurl->out(false)); return $results; }
php
public static function get_backup_file_info($filename, $filearea, $contextid) { $fs = get_file_storage(); $file = $fs->get_file($contextid, 'backup', $filearea, 0, '/', $filename); $filesize = display_size ($file->get_filesize()); $fileurl = moodle_url::make_pluginfile_url( $file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename(), true ); $params = array(); $params['action'] = 'choosebackupfile'; $params['filename'] = $file->get_filename(); $params['filepath'] = $file->get_filepath(); $params['component'] = $file->get_component(); $params['filearea'] = $file->get_filearea(); $params['filecontextid'] = $file->get_contextid(); $params['contextid'] = $contextid; $params['itemid'] = $file->get_itemid(); $restoreurl = new moodle_url('/backup/restorefile.php', $params); $filesize = display_size ($file->get_filesize()); $results = array( 'filesize' => $filesize, 'fileurl' => $fileurl->out(false), 'restoreurl' => $restoreurl->out(false)); return $results; }
[ "public", "static", "function", "get_backup_file_info", "(", "$", "filename", ",", "$", "filearea", ",", "$", "contextid", ")", "{", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "file", "=", "$", "fs", "->", "get_file", "(", "$", "contextid", ",", "'backup'", ",", "$", "filearea", ",", "0", ",", "'/'", ",", "$", "filename", ")", ";", "$", "filesize", "=", "display_size", "(", "$", "file", "->", "get_filesize", "(", ")", ")", ";", "$", "fileurl", "=", "moodle_url", "::", "make_pluginfile_url", "(", "$", "file", "->", "get_contextid", "(", ")", ",", "$", "file", "->", "get_component", "(", ")", ",", "$", "file", "->", "get_filearea", "(", ")", ",", "null", ",", "$", "file", "->", "get_filepath", "(", ")", ",", "$", "file", "->", "get_filename", "(", ")", ",", "true", ")", ";", "$", "params", "=", "array", "(", ")", ";", "$", "params", "[", "'action'", "]", "=", "'choosebackupfile'", ";", "$", "params", "[", "'filename'", "]", "=", "$", "file", "->", "get_filename", "(", ")", ";", "$", "params", "[", "'filepath'", "]", "=", "$", "file", "->", "get_filepath", "(", ")", ";", "$", "params", "[", "'component'", "]", "=", "$", "file", "->", "get_component", "(", ")", ";", "$", "params", "[", "'filearea'", "]", "=", "$", "file", "->", "get_filearea", "(", ")", ";", "$", "params", "[", "'filecontextid'", "]", "=", "$", "file", "->", "get_contextid", "(", ")", ";", "$", "params", "[", "'contextid'", "]", "=", "$", "contextid", ";", "$", "params", "[", "'itemid'", "]", "=", "$", "file", "->", "get_itemid", "(", ")", ";", "$", "restoreurl", "=", "new", "moodle_url", "(", "'/backup/restorefile.php'", ",", "$", "params", ")", ";", "$", "filesize", "=", "display_size", "(", "$", "file", "->", "get_filesize", "(", ")", ")", ";", "$", "results", "=", "array", "(", "'filesize'", "=>", "$", "filesize", ",", "'fileurl'", "=>", "$", "fileurl", "->", "out", "(", "false", ")", ",", "'restoreurl'", "=>", "$", "restoreurl", "->", "out", "(", "false", ")", ")", ";", "return", "$", "results", ";", "}" ]
Get the size, url and restore url for a backup file. @param string $filename The name of the file to get info for. @param string $filearea The file area for the file. @param int $contextid The context ID of the file. @return array $results The result array containing the size, url and restore url of the file.
[ "Get", "the", "size", "url", "and", "restore", "url", "for", "a", "backup", "file", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L242-L274
212,189
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_restore_url
public static function get_restore_url($backupid) { global $DB; $backupitemid = $DB->get_field('backup_controllers', 'itemid', array('backupid' => $backupid), MUST_EXIST); $newcontext = context_course::instance($backupitemid); $restoreurl = $newcontext->get_url()->out(); $urlarray = array('restoreurl' => $restoreurl); return $urlarray; }
php
public static function get_restore_url($backupid) { global $DB; $backupitemid = $DB->get_field('backup_controllers', 'itemid', array('backupid' => $backupid), MUST_EXIST); $newcontext = context_course::instance($backupitemid); $restoreurl = $newcontext->get_url()->out(); $urlarray = array('restoreurl' => $restoreurl); return $urlarray; }
[ "public", "static", "function", "get_restore_url", "(", "$", "backupid", ")", "{", "global", "$", "DB", ";", "$", "backupitemid", "=", "$", "DB", "->", "get_field", "(", "'backup_controllers'", ",", "'itemid'", ",", "array", "(", "'backupid'", "=>", "$", "backupid", ")", ",", "MUST_EXIST", ")", ";", "$", "newcontext", "=", "context_course", "::", "instance", "(", "$", "backupitemid", ")", ";", "$", "restoreurl", "=", "$", "newcontext", "->", "get_url", "(", ")", "->", "out", "(", ")", ";", "$", "urlarray", "=", "array", "(", "'restoreurl'", "=>", "$", "restoreurl", ")", ";", "return", "$", "urlarray", ";", "}" ]
Get the url of a restored backup item based on the backup ID. @param string $backupid The backup ID to get the restore location url. @return array $urlarray The restored item URL as an array.
[ "Get", "the", "url", "of", "a", "restored", "backup", "item", "based", "on", "the", "backup", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L282-L292
212,190
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_async_backups
public static function get_async_backups($renderer, $instanceid) { global $DB; $tabledata = array(); // Get relevant backup ids based on context instance id. $select = 'itemid = ? AND execution = ? AND status < ? AND status > ?'; $params = array($instanceid, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK); $backups = $DB->get_records_select('backup_controllers', $select, $params, 'timecreated DESC', 'id, backupid, timecreated'); foreach ($backups as $backup) { $bc = \backup_controller::load_controller($backup->backupid); // Get the backup controller. $filename = $bc->get_plan()->get_setting('filename')->get_value(); $timecreated = $backup->timecreated; $status = $renderer->get_status_display($bc->get_status(), $bc->get_backupid()); $tablerow = array($filename, userdate($timecreated), '-', '-', '-', $status); $tabledata[] = $tablerow; } return $tabledata; }
php
public static function get_async_backups($renderer, $instanceid) { global $DB; $tabledata = array(); // Get relevant backup ids based on context instance id. $select = 'itemid = ? AND execution = ? AND status < ? AND status > ?'; $params = array($instanceid, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK); $backups = $DB->get_records_select('backup_controllers', $select, $params, 'timecreated DESC', 'id, backupid, timecreated'); foreach ($backups as $backup) { $bc = \backup_controller::load_controller($backup->backupid); // Get the backup controller. $filename = $bc->get_plan()->get_setting('filename')->get_value(); $timecreated = $backup->timecreated; $status = $renderer->get_status_display($bc->get_status(), $bc->get_backupid()); $tablerow = array($filename, userdate($timecreated), '-', '-', '-', $status); $tabledata[] = $tablerow; } return $tabledata; }
[ "public", "static", "function", "get_async_backups", "(", "$", "renderer", ",", "$", "instanceid", ")", "{", "global", "$", "DB", ";", "$", "tabledata", "=", "array", "(", ")", ";", "// Get relevant backup ids based on context instance id.", "$", "select", "=", "'itemid = ? AND execution = ? AND status < ? AND status > ?'", ";", "$", "params", "=", "array", "(", "$", "instanceid", ",", "backup", "::", "EXECUTION_DELAYED", ",", "backup", "::", "STATUS_FINISHED_ERR", ",", "backup", "::", "STATUS_NEED_PRECHECK", ")", ";", "$", "backups", "=", "$", "DB", "->", "get_records_select", "(", "'backup_controllers'", ",", "$", "select", ",", "$", "params", ",", "'timecreated DESC'", ",", "'id, backupid, timecreated'", ")", ";", "foreach", "(", "$", "backups", "as", "$", "backup", ")", "{", "$", "bc", "=", "\\", "backup_controller", "::", "load_controller", "(", "$", "backup", "->", "backupid", ")", ";", "// Get the backup controller.", "$", "filename", "=", "$", "bc", "->", "get_plan", "(", ")", "->", "get_setting", "(", "'filename'", ")", "->", "get_value", "(", ")", ";", "$", "timecreated", "=", "$", "backup", "->", "timecreated", ";", "$", "status", "=", "$", "renderer", "->", "get_status_display", "(", "$", "bc", "->", "get_status", "(", ")", ",", "$", "bc", "->", "get_backupid", "(", ")", ")", ";", "$", "tablerow", "=", "array", "(", "$", "filename", ",", "userdate", "(", "$", "timecreated", ")", ",", "'-'", ",", "'-'", ",", "'-'", ",", "$", "status", ")", ";", "$", "tabledata", "[", "]", "=", "$", "tablerow", ";", "}", "return", "$", "tabledata", ";", "}" ]
Get markup for in progress async backups, to use in backup table UI. @param \core_backup_renderer $renderer The backup renderer object. @param integer $instanceid The context id to get backup data for. @return array $tabledata the rows of table data.
[ "Get", "markup", "for", "in", "progress", "async", "backups", "to", "use", "in", "backup", "table", "UI", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L302-L323
212,191
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_restore_name
public static function get_restore_name(\context $context) { global $DB; $instanceid = $context->instanceid; if ($context->contextlevel == CONTEXT_MODULE) { // For modules get the course name and module name. $cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST); $coursename = $DB->get_field('course', 'fullname', array('id' => $cm->course)); $itemname = $coursename . ' - ' . $cm->name; } else { $itemname = $DB->get_field('course', 'fullname', array('id' => $context->instanceid)); } return $itemname; }
php
public static function get_restore_name(\context $context) { global $DB; $instanceid = $context->instanceid; if ($context->contextlevel == CONTEXT_MODULE) { // For modules get the course name and module name. $cm = get_coursemodule_from_id('', $context->instanceid, 0, false, MUST_EXIST); $coursename = $DB->get_field('course', 'fullname', array('id' => $cm->course)); $itemname = $coursename . ' - ' . $cm->name; } else { $itemname = $DB->get_field('course', 'fullname', array('id' => $context->instanceid)); } return $itemname; }
[ "public", "static", "function", "get_restore_name", "(", "\\", "context", "$", "context", ")", "{", "global", "$", "DB", ";", "$", "instanceid", "=", "$", "context", "->", "instanceid", ";", "if", "(", "$", "context", "->", "contextlevel", "==", "CONTEXT_MODULE", ")", "{", "// For modules get the course name and module name.", "$", "cm", "=", "get_coursemodule_from_id", "(", "''", ",", "$", "context", "->", "instanceid", ",", "0", ",", "false", ",", "MUST_EXIST", ")", ";", "$", "coursename", "=", "$", "DB", "->", "get_field", "(", "'course'", ",", "'fullname'", ",", "array", "(", "'id'", "=>", "$", "cm", "->", "course", ")", ")", ";", "$", "itemname", "=", "$", "coursename", ".", "' - '", ".", "$", "cm", "->", "name", ";", "}", "else", "{", "$", "itemname", "=", "$", "DB", "->", "get_field", "(", "'course'", ",", "'fullname'", ",", "array", "(", "'id'", "=>", "$", "context", "->", "instanceid", ")", ")", ";", "}", "return", "$", "itemname", ";", "}" ]
Get the course name of the resource being restored. @param \context $context The Moodle context for the restores. @return string $coursename The full name of the course.
[ "Get", "the", "course", "name", "of", "the", "resource", "being", "restored", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L331-L346
212,192
moodle/moodle
backup/util/helper/async_helper.class.php
async_helper.get_async_restores
public static function get_async_restores($userid) { global $DB; $select = 'userid = ? AND execution = ? AND status < ? AND status > ? AND operation = ?'; $params = array($userid, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK, 'restore'); $restores = $DB->get_records_select( 'backup_controllers', $select, $params, 'timecreated DESC', 'id, backupid, status, itemid, timecreated'); return $restores; }
php
public static function get_async_restores($userid) { global $DB; $select = 'userid = ? AND execution = ? AND status < ? AND status > ? AND operation = ?'; $params = array($userid, backup::EXECUTION_DELAYED, backup::STATUS_FINISHED_ERR, backup::STATUS_NEED_PRECHECK, 'restore'); $restores = $DB->get_records_select( 'backup_controllers', $select, $params, 'timecreated DESC', 'id, backupid, status, itemid, timecreated'); return $restores; }
[ "public", "static", "function", "get_async_restores", "(", "$", "userid", ")", "{", "global", "$", "DB", ";", "$", "select", "=", "'userid = ? AND execution = ? AND status < ? AND status > ? AND operation = ?'", ";", "$", "params", "=", "array", "(", "$", "userid", ",", "backup", "::", "EXECUTION_DELAYED", ",", "backup", "::", "STATUS_FINISHED_ERR", ",", "backup", "::", "STATUS_NEED_PRECHECK", ",", "'restore'", ")", ";", "$", "restores", "=", "$", "DB", "->", "get_records_select", "(", "'backup_controllers'", ",", "$", "select", ",", "$", "params", ",", "'timecreated DESC'", ",", "'id, backupid, status, itemid, timecreated'", ")", ";", "return", "$", "restores", ";", "}" ]
Get all the current in progress async restores for a user. @param int $userid Moodle user id. @return array $restores List of current restores in progress.
[ "Get", "all", "the", "current", "in", "progress", "async", "restores", "for", "a", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/helper/async_helper.class.php#L354-L367
212,193
moodle/moodle
lib/phpexcel/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php
EigenvalueDecomposition.cdiv
private function cdiv($xr, $xi, $yr, $yi) { if (abs($yr) > abs($yi)) { $r = $yi / $yr; $d = $yr + $r * $yi; $this->cdivr = ($xr + $r * $xi) / $d; $this->cdivi = ($xi - $r * $xr) / $d; } else { $r = $yr / $yi; $d = $yi + $r * $yr; $this->cdivr = ($r * $xr + $xi) / $d; $this->cdivi = ($r * $xi - $xr) / $d; } }
php
private function cdiv($xr, $xi, $yr, $yi) { if (abs($yr) > abs($yi)) { $r = $yi / $yr; $d = $yr + $r * $yi; $this->cdivr = ($xr + $r * $xi) / $d; $this->cdivi = ($xi - $r * $xr) / $d; } else { $r = $yr / $yi; $d = $yi + $r * $yr; $this->cdivr = ($r * $xr + $xi) / $d; $this->cdivi = ($r * $xi - $xr) / $d; } }
[ "private", "function", "cdiv", "(", "$", "xr", ",", "$", "xi", ",", "$", "yr", ",", "$", "yi", ")", "{", "if", "(", "abs", "(", "$", "yr", ")", ">", "abs", "(", "$", "yi", ")", ")", "{", "$", "r", "=", "$", "yi", "/", "$", "yr", ";", "$", "d", "=", "$", "yr", "+", "$", "r", "*", "$", "yi", ";", "$", "this", "->", "cdivr", "=", "(", "$", "xr", "+", "$", "r", "*", "$", "xi", ")", "/", "$", "d", ";", "$", "this", "->", "cdivi", "=", "(", "$", "xi", "-", "$", "r", "*", "$", "xr", ")", "/", "$", "d", ";", "}", "else", "{", "$", "r", "=", "$", "yr", "/", "$", "yi", ";", "$", "d", "=", "$", "yi", "+", "$", "r", "*", "$", "yr", ";", "$", "this", "->", "cdivr", "=", "(", "$", "r", "*", "$", "xr", "+", "$", "xi", ")", "/", "$", "d", ";", "$", "this", "->", "cdivi", "=", "(", "$", "r", "*", "$", "xi", "-", "$", "xr", ")", "/", "$", "d", ";", "}", "}" ]
Performs complex division. @access private
[ "Performs", "complex", "division", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php#L375-L388
212,194
moodle/moodle
filter/classes/external.php
external.get_available_in_context
public static function get_available_in_context($contexts) { $params = self::validate_parameters(self::get_available_in_context_parameters(), array('contexts' => $contexts)); $filters = $warnings = array(); foreach ($params['contexts'] as $contextinfo) { try { $context = self::get_context_from_params($contextinfo); self::validate_context($context); $contextinfo['contextid'] = $context->id; } catch (Exception $e) { $warnings[] = array( 'item' => 'context', 'itemid' => $context['instanceid'], 'warningcode' => $e->getCode(), 'message' => $e->getMessage(), ); continue; } $contextfilters = filter_get_available_in_context($context); foreach ($contextfilters as $filter) { $filters[] = array_merge($contextinfo, (array) $filter); } } return array( 'filters' => $filters, 'warnings' => $warnings, ); }
php
public static function get_available_in_context($contexts) { $params = self::validate_parameters(self::get_available_in_context_parameters(), array('contexts' => $contexts)); $filters = $warnings = array(); foreach ($params['contexts'] as $contextinfo) { try { $context = self::get_context_from_params($contextinfo); self::validate_context($context); $contextinfo['contextid'] = $context->id; } catch (Exception $e) { $warnings[] = array( 'item' => 'context', 'itemid' => $context['instanceid'], 'warningcode' => $e->getCode(), 'message' => $e->getMessage(), ); continue; } $contextfilters = filter_get_available_in_context($context); foreach ($contextfilters as $filter) { $filters[] = array_merge($contextinfo, (array) $filter); } } return array( 'filters' => $filters, 'warnings' => $warnings, ); }
[ "public", "static", "function", "get_available_in_context", "(", "$", "contexts", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_available_in_context_parameters", "(", ")", ",", "array", "(", "'contexts'", "=>", "$", "contexts", ")", ")", ";", "$", "filters", "=", "$", "warnings", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "[", "'contexts'", "]", "as", "$", "contextinfo", ")", "{", "try", "{", "$", "context", "=", "self", "::", "get_context_from_params", "(", "$", "contextinfo", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "contextinfo", "[", "'contextid'", "]", "=", "$", "context", "->", "id", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "warnings", "[", "]", "=", "array", "(", "'item'", "=>", "'context'", ",", "'itemid'", "=>", "$", "context", "[", "'instanceid'", "]", ",", "'warningcode'", "=>", "$", "e", "->", "getCode", "(", ")", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", ")", ";", "continue", ";", "}", "$", "contextfilters", "=", "filter_get_available_in_context", "(", "$", "context", ")", ";", "foreach", "(", "$", "contextfilters", "as", "$", "filter", ")", "{", "$", "filters", "[", "]", "=", "array_merge", "(", "$", "contextinfo", ",", "(", "array", ")", "$", "filter", ")", ";", "}", "}", "return", "array", "(", "'filters'", "=>", "$", "filters", ",", "'warnings'", "=>", "$", "warnings", ",", ")", ";", "}" ]
Returns the filters available in the given contexts. @param array $contexts the list of contexts to check @return array with the filters information and warnings @since Moodle 3.4
[ "Returns", "the", "filters", "available", "in", "the", "given", "contexts", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/filter/classes/external.php#L76-L105
212,195
moodle/moodle
admin/tool/installaddon/renderer.php
tool_installaddon_renderer.set_installer_instance
public function set_installer_instance(tool_installaddon_installer $installer) { if (is_null($this->installer)) { $this->installer = $installer; } else { throw new coding_exception('Attempting to reset the installer instance.'); } }
php
public function set_installer_instance(tool_installaddon_installer $installer) { if (is_null($this->installer)) { $this->installer = $installer; } else { throw new coding_exception('Attempting to reset the installer instance.'); } }
[ "public", "function", "set_installer_instance", "(", "tool_installaddon_installer", "$", "installer", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "installer", ")", ")", "{", "$", "this", "->", "installer", "=", "$", "installer", ";", "}", "else", "{", "throw", "new", "coding_exception", "(", "'Attempting to reset the installer instance.'", ")", ";", "}", "}" ]
Sets the tool_installaddon_installer instance being used. @throws coding_exception if the installer has been already set @param tool_installaddon_installer $installer
[ "Sets", "the", "tool_installaddon_installer", "instance", "being", "used", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/installaddon/renderer.php#L46-L52
212,196
moodle/moodle
admin/tool/installaddon/renderer.php
tool_installaddon_renderer.index_page
public function index_page() { if (is_null($this->installer)) { throw new coding_exception('Installer instance has not been set.'); } $permcheckurl = new moodle_url('/admin/tool/installaddon/permcheck.php'); $this->page->requires->yui_module('moodle-tool_installaddon-permcheck', 'M.tool_installaddon.permcheck.init', array(array('permcheckurl' => $permcheckurl->out()))); $this->page->requires->strings_for_js( array('permcheckprogress', 'permcheckresultno', 'permcheckresultyes', 'permcheckerror', 'permcheckrepeat'), 'tool_installaddon'); $out = $this->output->header(); $out .= $this->index_page_heading(); $out .= $this->index_page_repository(); $out .= $this->index_page_upload(); $out .= $this->output->footer(); return $out; }
php
public function index_page() { if (is_null($this->installer)) { throw new coding_exception('Installer instance has not been set.'); } $permcheckurl = new moodle_url('/admin/tool/installaddon/permcheck.php'); $this->page->requires->yui_module('moodle-tool_installaddon-permcheck', 'M.tool_installaddon.permcheck.init', array(array('permcheckurl' => $permcheckurl->out()))); $this->page->requires->strings_for_js( array('permcheckprogress', 'permcheckresultno', 'permcheckresultyes', 'permcheckerror', 'permcheckrepeat'), 'tool_installaddon'); $out = $this->output->header(); $out .= $this->index_page_heading(); $out .= $this->index_page_repository(); $out .= $this->index_page_upload(); $out .= $this->output->footer(); return $out; }
[ "public", "function", "index_page", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "installer", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Installer instance has not been set.'", ")", ";", "}", "$", "permcheckurl", "=", "new", "moodle_url", "(", "'/admin/tool/installaddon/permcheck.php'", ")", ";", "$", "this", "->", "page", "->", "requires", "->", "yui_module", "(", "'moodle-tool_installaddon-permcheck'", ",", "'M.tool_installaddon.permcheck.init'", ",", "array", "(", "array", "(", "'permcheckurl'", "=>", "$", "permcheckurl", "->", "out", "(", ")", ")", ")", ")", ";", "$", "this", "->", "page", "->", "requires", "->", "strings_for_js", "(", "array", "(", "'permcheckprogress'", ",", "'permcheckresultno'", ",", "'permcheckresultyes'", ",", "'permcheckerror'", ",", "'permcheckrepeat'", ")", ",", "'tool_installaddon'", ")", ";", "$", "out", "=", "$", "this", "->", "output", "->", "header", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "index_page_heading", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "index_page_repository", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "index_page_upload", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "footer", "(", ")", ";", "return", "$", "out", ";", "}" ]
Defines the index page layout @return string
[ "Defines", "the", "index", "page", "layout" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/installaddon/renderer.php#L59-L79
212,197
moodle/moodle
admin/tool/installaddon/renderer.php
tool_installaddon_renderer.remote_request_invalid_page
public function remote_request_invalid_page(moodle_url $continueurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->box(get_string('remoterequestinvalid', 'tool_installaddon'), 'generalbox', 'notice'); $out .= $this->output->continue_button($continueurl, 'get'); $out .= $this->output->footer(); return $out; }
php
public function remote_request_invalid_page(moodle_url $continueurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->box(get_string('remoterequestinvalid', 'tool_installaddon'), 'generalbox', 'notice'); $out .= $this->output->continue_button($continueurl, 'get'); $out .= $this->output->footer(); return $out; }
[ "public", "function", "remote_request_invalid_page", "(", "moodle_url", "$", "continueurl", ")", "{", "$", "out", "=", "$", "this", "->", "output", "->", "header", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'installfromrepo'", ",", "'tool_installaddon'", ")", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "box", "(", "get_string", "(", "'remoterequestinvalid'", ",", "'tool_installaddon'", ")", ",", "'generalbox'", ",", "'notice'", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "continue_button", "(", "$", "continueurl", ",", "'get'", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "footer", "(", ")", ";", "return", "$", "out", ";", "}" ]
Inform the user about invalid remote installation request. @param moodle_url $continueurl @return string
[ "Inform", "the", "user", "about", "invalid", "remote", "installation", "request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/installaddon/renderer.php#L104-L113
212,198
moodle/moodle
admin/tool/installaddon/renderer.php
tool_installaddon_renderer.remote_request_alreadyinstalled_page
public function remote_request_alreadyinstalled_page(stdClass $data, moodle_url $continueurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->box(get_string('remoterequestalreadyinstalled', 'tool_installaddon', $data), 'generalbox', 'notice'); $out .= $this->output->continue_button($continueurl, 'get'); $out .= $this->output->footer(); return $out; }
php
public function remote_request_alreadyinstalled_page(stdClass $data, moodle_url $continueurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->box(get_string('remoterequestalreadyinstalled', 'tool_installaddon', $data), 'generalbox', 'notice'); $out .= $this->output->continue_button($continueurl, 'get'); $out .= $this->output->footer(); return $out; }
[ "public", "function", "remote_request_alreadyinstalled_page", "(", "stdClass", "$", "data", ",", "moodle_url", "$", "continueurl", ")", "{", "$", "out", "=", "$", "this", "->", "output", "->", "header", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'installfromrepo'", ",", "'tool_installaddon'", ")", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "box", "(", "get_string", "(", "'remoterequestalreadyinstalled'", ",", "'tool_installaddon'", ",", "$", "data", ")", ",", "'generalbox'", ",", "'notice'", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "continue_button", "(", "$", "continueurl", ",", "'get'", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "footer", "(", ")", ";", "return", "$", "out", ";", "}" ]
Inform the user that such plugin is already installed @param stdClass $data decoded request data @param moodle_url $continueurl @return string
[ "Inform", "the", "user", "that", "such", "plugin", "is", "already", "installed" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/installaddon/renderer.php#L122-L131
212,199
moodle/moodle
admin/tool/installaddon/renderer.php
tool_installaddon_renderer.remote_request_confirm_page
public function remote_request_confirm_page(stdClass $data, moodle_url $continueurl, moodle_url $cancelurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->confirm(get_string('remoterequestconfirm', 'tool_installaddon', $data), $continueurl, $cancelurl); $out .= $this->output->footer(); return $out; }
php
public function remote_request_confirm_page(stdClass $data, moodle_url $continueurl, moodle_url $cancelurl) { $out = $this->output->header(); $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon')); $out .= $this->output->confirm(get_string('remoterequestconfirm', 'tool_installaddon', $data), $continueurl, $cancelurl); $out .= $this->output->footer(); return $out; }
[ "public", "function", "remote_request_confirm_page", "(", "stdClass", "$", "data", ",", "moodle_url", "$", "continueurl", ",", "moodle_url", "$", "cancelurl", ")", "{", "$", "out", "=", "$", "this", "->", "output", "->", "header", "(", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'installfromrepo'", ",", "'tool_installaddon'", ")", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "confirm", "(", "get_string", "(", "'remoterequestconfirm'", ",", "'tool_installaddon'", ",", "$", "data", ")", ",", "$", "continueurl", ",", "$", "cancelurl", ")", ";", "$", "out", ".=", "$", "this", "->", "output", "->", "footer", "(", ")", ";", "return", "$", "out", ";", "}" ]
Let the user confirm the remote installation request. @param stdClass $data decoded request data @param moodle_url $continueurl @param moodle_url $cancelurl @return string
[ "Let", "the", "user", "confirm", "the", "remote", "installation", "request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/installaddon/renderer.php#L141-L149