id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
213,300 | moodle/moodle | repository/s3/S3.php | S3.__parseCloudFrontDistributionConfig | private static function __parseCloudFrontDistributionConfig(&$node)
{
if (isset($node->DistributionConfig))
return self::__parseCloudFrontDistributionConfig($node->DistributionConfig);
$dist = array();
if (isset($node->Id, $node->Status, $node->LastModifiedTime, $node->DomainName))
{
$dist['id'] = (stri... | php | private static function __parseCloudFrontDistributionConfig(&$node)
{
if (isset($node->DistributionConfig))
return self::__parseCloudFrontDistributionConfig($node->DistributionConfig);
$dist = array();
if (isset($node->Id, $node->Status, $node->LastModifiedTime, $node->DomainName))
{
$dist['id'] = (stri... | [
"private",
"static",
"function",
"__parseCloudFrontDistributionConfig",
"(",
"&",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"->",
"DistributionConfig",
")",
")",
"return",
"self",
"::",
"__parseCloudFrontDistributionConfig",
"(",
"$",
"node",
... | Parse a CloudFront distribution config
See http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/index.html?GetDistribution.html
@internal Used to parse the CloudFront DistributionConfig node to an array
@param object &$node DOMNode
@return array | [
"Parse",
"a",
"CloudFront",
"distribution",
"config"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L1730-L1780 |
213,301 | moodle/moodle | repository/s3/S3.php | S3.__getCloudFrontResponse | private static function __getCloudFrontResponse(&$rest)
{
$rest->getResponse();
if ($rest->response->error === false && isset($rest->response->body) &&
is_string($rest->response->body) && substr($rest->response->body, 0, 5) == '<?xml')
{
$rest->response->body = simplexml_load_string($rest->response->body);
... | php | private static function __getCloudFrontResponse(&$rest)
{
$rest->getResponse();
if ($rest->response->error === false && isset($rest->response->body) &&
is_string($rest->response->body) && substr($rest->response->body, 0, 5) == '<?xml')
{
$rest->response->body = simplexml_load_string($rest->response->body);
... | [
"private",
"static",
"function",
"__getCloudFrontResponse",
"(",
"&",
"$",
"rest",
")",
"{",
"$",
"rest",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"rest",
"->",
"response",
"->",
"error",
"===",
"false",
"&&",
"isset",
"(",
"$",
"rest",
"->"... | Grab CloudFront response
@internal Used to parse the CloudFront S3Request::getResponse() output
@param object &$rest S3Request instance
@return object | [
"Grab",
"CloudFront",
"response"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L1790-L1809 |
213,302 | moodle/moodle | repository/s3/S3.php | S3.__getHash | private static function __getHash($string)
{
return base64_encode(extension_loaded('hash') ?
hash_hmac('sha1', $string, self::$__secretKey, true) : pack('H*', sha1(
(str_pad(self::$__secretKey, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) .
pack('H*', sha1((str_pad(self::$__secretKey, 64, chr(0x00)) ^
(str_... | php | private static function __getHash($string)
{
return base64_encode(extension_loaded('hash') ?
hash_hmac('sha1', $string, self::$__secretKey, true) : pack('H*', sha1(
(str_pad(self::$__secretKey, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) .
pack('H*', sha1((str_pad(self::$__secretKey, 64, chr(0x00)) ^
(str_... | [
"private",
"static",
"function",
"__getHash",
"(",
"$",
"string",
")",
"{",
"return",
"base64_encode",
"(",
"extension_loaded",
"(",
"'hash'",
")",
"?",
"hash_hmac",
"(",
"'sha1'",
",",
"$",
"string",
",",
"self",
"::",
"$",
"__secretKey",
",",
"true",
")"... | Creates a HMAC-SHA1 hash
This uses the hash extension if loaded
@internal Used by __getSignature()
@param string $string String to sign
@return string | [
"Creates",
"a",
"HMAC",
"-",
"SHA1",
"hash"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L1900-L1907 |
213,303 | moodle/moodle | repository/s3/S3.php | S3Request.__sortMetaHeadersCmp | private function __sortMetaHeadersCmp($a, $b)
{
$lenA = strpos($a, ':');
$lenB = strpos($b, ':');
$minLen = min($lenA, $lenB);
$ncmp = strncmp($a, $b, $minLen);
if ($lenA == $lenB) return $ncmp;
if (0 == $ncmp) return $lenA < $lenB ? -1 : 1;
return $ncmp;
} | php | private function __sortMetaHeadersCmp($a, $b)
{
$lenA = strpos($a, ':');
$lenB = strpos($b, ':');
$minLen = min($lenA, $lenB);
$ncmp = strncmp($a, $b, $minLen);
if ($lenA == $lenB) return $ncmp;
if (0 == $ncmp) return $lenA < $lenB ? -1 : 1;
return $ncmp;
} | [
"private",
"function",
"__sortMetaHeadersCmp",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"lenA",
"=",
"strpos",
"(",
"$",
"a",
",",
"':'",
")",
";",
"$",
"lenB",
"=",
"strpos",
"(",
"$",
"b",
",",
"':'",
")",
";",
"$",
"minLen",
"=",
"min",
... | Sort compare for meta headers
@internal Used to sort x-amz meta headers
@param string $a String A
@param string $b String B
@return integer | [
"Sort",
"compare",
"for",
"meta",
"headers"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L2285-L2294 |
213,304 | moodle/moodle | repository/s3/S3.php | S3Request.__responseWriteCallback | private function __responseWriteCallback(&$curl, &$data)
{
if (in_array($this->response->code, array(200, 206)) && $this->fp !== false)
return fwrite($this->fp, $data);
else
$this->response->body .= $data;
return strlen($data);
} | php | private function __responseWriteCallback(&$curl, &$data)
{
if (in_array($this->response->code, array(200, 206)) && $this->fp !== false)
return fwrite($this->fp, $data);
else
$this->response->body .= $data;
return strlen($data);
} | [
"private",
"function",
"__responseWriteCallback",
"(",
"&",
"$",
"curl",
",",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"response",
"->",
"code",
",",
"array",
"(",
"200",
",",
"206",
")",
")",
"&&",
"$",
"this",
"-... | CURL write callback
@param resource &$curl CURL resource
@param string &$data Data
@return integer | [
"CURL",
"write",
"callback"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L2303-L2310 |
213,305 | moodle/moodle | repository/s3/S3.php | S3Request.__responseHeaderCallback | private function __responseHeaderCallback($curl, $data)
{
if (($strlen = strlen($data)) <= 2) return $strlen;
if (substr($data, 0, 4) == 'HTTP')
$this->response->code = (int)substr($data, 9, 3);
else
{
$data = trim($data);
if (strpos($data, ': ') === false) return $strlen;
list($header, $value) = e... | php | private function __responseHeaderCallback($curl, $data)
{
if (($strlen = strlen($data)) <= 2) return $strlen;
if (substr($data, 0, 4) == 'HTTP')
$this->response->code = (int)substr($data, 9, 3);
else
{
$data = trim($data);
if (strpos($data, ': ') === false) return $strlen;
list($header, $value) = e... | [
"private",
"function",
"__responseHeaderCallback",
"(",
"$",
"curl",
",",
"$",
"data",
")",
"{",
"if",
"(",
"(",
"$",
"strlen",
"=",
"strlen",
"(",
"$",
"data",
")",
")",
"<=",
"2",
")",
"return",
"$",
"strlen",
";",
"if",
"(",
"substr",
"(",
"$",
... | CURL header callback
@param resource $curl CURL resource
@param string $data Data
@return integer | [
"CURL",
"header",
"callback"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/s3/S3.php#L2338-L2362 |
213,306 | moodle/moodle | customfield/classes/event/field_created.php | field_created.create_from_object | public static function create_from_object(field_controller $field) : field_created {
$eventparams = [
'objectid' => $field->get('id'),
'context' => $field->get_handler()->get_configuration_context(),
'other' => [
'shortname' => $field->get('shortname'),
... | php | public static function create_from_object(field_controller $field) : field_created {
$eventparams = [
'objectid' => $field->get('id'),
'context' => $field->get_handler()->get_configuration_context(),
'other' => [
'shortname' => $field->get('shortname'),
... | [
"public",
"static",
"function",
"create_from_object",
"(",
"field_controller",
"$",
"field",
")",
":",
"field_created",
"{",
"$",
"eventparams",
"=",
"[",
"'objectid'",
"=>",
"$",
"field",
"->",
"get",
"(",
"'id'",
")",
",",
"'context'",
"=>",
"$",
"field",
... | Creates an instance from a field controller object
@param field_controller $field
@return field_created | [
"Creates",
"an",
"instance",
"from",
"a",
"field",
"controller",
"object"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/customfield/classes/event/field_created.php#L56-L68 |
213,307 | moodle/moodle | lib/filestorage/file_system.php | file_system.readfile | public function readfile(stored_file $file) {
if ($this->is_file_readable_locally_by_storedfile($file, false)) {
$path = $this->get_local_path_from_storedfile($file, false);
} else {
$path = $this->get_remote_path_from_storedfile($file);
}
readfile_allow_large($pa... | php | public function readfile(stored_file $file) {
if ($this->is_file_readable_locally_by_storedfile($file, false)) {
$path = $this->get_local_path_from_storedfile($file, false);
} else {
$path = $this->get_remote_path_from_storedfile($file);
}
readfile_allow_large($pa... | [
"public",
"function",
"readfile",
"(",
"stored_file",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_file_readable_locally_by_storedfile",
"(",
"$",
"file",
",",
"false",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_local_path_from_stor... | Output the content of the specified stored file.
Note, this is different to get_content() as it uses the built-in php
readfile function which is more efficient.
@param stored_file $file The file to serve.
@return void | [
"Output",
"the",
"content",
"of",
"the",
"specified",
"stored",
"file",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L60-L67 |
213,308 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_local_path_from_storedfile | protected function get_local_path_from_storedfile(stored_file $file, $fetchifnotfound = false) {
return $this->get_local_path_from_hash($file->get_contenthash(), $fetchifnotfound);
} | php | protected function get_local_path_from_storedfile(stored_file $file, $fetchifnotfound = false) {
return $this->get_local_path_from_hash($file->get_contenthash(), $fetchifnotfound);
} | [
"protected",
"function",
"get_local_path_from_storedfile",
"(",
"stored_file",
"$",
"file",
",",
"$",
"fetchifnotfound",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"get_local_path_from_hash",
"(",
"$",
"file",
"->",
"get_contenthash",
"(",
")",
",",
"$... | Get the full path on disk for the specified stored file.
Note: This must return a consistent path for the file's contenthash
and the path _will_ be in a standard local format.
Streamable paths will not work.
A local copy of the file _will_ be fetched if $fetchifnotfound is tree.
The $fetchifnotfound allows you to det... | [
"Get",
"the",
"full",
"path",
"on",
"disk",
"for",
"the",
"specified",
"stored",
"file",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L83-L85 |
213,309 | moodle/moodle | lib/filestorage/file_system.php | file_system.is_file_readable_remotely_by_storedfile | public function is_file_readable_remotely_by_storedfile(stored_file $file) {
if (!$file->get_filesize()) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
$path = $this->get_remote_path_from_storedfile($f... | php | public function is_file_readable_remotely_by_storedfile(stored_file $file) {
if (!$file->get_filesize()) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
$path = $this->get_remote_path_from_storedfile($f... | [
"public",
"function",
"is_file_readable_remotely_by_storedfile",
"(",
"stored_file",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"file",
"->",
"get_filesize",
"(",
")",
")",
"{",
"// Files with empty size are either directories or empty.",
"// We handle these virtually.",
... | Determine whether the file is present on the local file system somewhere.
@param stored_file $file The file to ensure is available.
@return bool | [
"Determine",
"whether",
"the",
"file",
"is",
"present",
"on",
"the",
"local",
"file",
"system",
"somewhere",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L161-L174 |
213,310 | moodle/moodle | lib/filestorage/file_system.php | file_system.is_file_readable_locally_by_hash | public function is_file_readable_locally_by_hash($contenthash, $fetchifnotfound = false) {
if ($contenthash === file_storage::hash_from_string('')) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
// Thi... | php | public function is_file_readable_locally_by_hash($contenthash, $fetchifnotfound = false) {
if ($contenthash === file_storage::hash_from_string('')) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
// Thi... | [
"public",
"function",
"is_file_readable_locally_by_hash",
"(",
"$",
"contenthash",
",",
"$",
"fetchifnotfound",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"contenthash",
"===",
"file_storage",
"::",
"hash_from_string",
"(",
"''",
")",
")",
"{",
"// Files with empty s... | Determine whether the file is present on the file system somewhere given
the contenthash.
@param string $contenthash The contenthash of the file to check.
@param bool $fetchifnotfound Whether to attempt to fetch from the remote path if not found.
@return bool | [
"Determine",
"whether",
"the",
"file",
"is",
"present",
"on",
"the",
"file",
"system",
"somewhere",
"given",
"the",
"contenthash",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L184-L196 |
213,311 | moodle/moodle | lib/filestorage/file_system.php | file_system.is_file_readable_remotely_by_hash | public function is_file_readable_remotely_by_hash($contenthash) {
if ($contenthash === file_storage::hash_from_string('')) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
$path = $this->get_remote_path_... | php | public function is_file_readable_remotely_by_hash($contenthash) {
if ($contenthash === file_storage::hash_from_string('')) {
// Files with empty size are either directories or empty.
// We handle these virtually.
return true;
}
$path = $this->get_remote_path_... | [
"public",
"function",
"is_file_readable_remotely_by_hash",
"(",
"$",
"contenthash",
")",
"{",
"if",
"(",
"$",
"contenthash",
"===",
"file_storage",
"::",
"hash_from_string",
"(",
"''",
")",
")",
"{",
"// Files with empty size are either directories or empty.",
"// We hand... | Determine whether the file is present locally on the file system somewhere given
the contenthash.
@param string $contenthash The contenthash of the file to check.
@return bool | [
"Determine",
"whether",
"the",
"file",
"is",
"present",
"locally",
"on",
"the",
"file",
"system",
"somewhere",
"given",
"the",
"contenthash",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L205-L216 |
213,312 | moodle/moodle | lib/filestorage/file_system.php | file_system.is_file_removable | protected static function is_file_removable($contenthash) {
global $DB;
if ($contenthash === file_storage::hash_from_string('')) {
// No need to delete files without content.
return false;
}
// Note: This section is critical - in theory file could be reused at t... | php | protected static function is_file_removable($contenthash) {
global $DB;
if ($contenthash === file_storage::hash_from_string('')) {
// No need to delete files without content.
return false;
}
// Note: This section is critical - in theory file could be reused at t... | [
"protected",
"static",
"function",
"is_file_removable",
"(",
"$",
"contenthash",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"contenthash",
"===",
"file_storage",
"::",
"hash_from_string",
"(",
"''",
")",
")",
"{",
"// No need to delete files without conte... | Check whether a file is removable.
This must be called prior to file removal.
@param string $contenthash
@return bool | [
"Check",
"whether",
"a",
"file",
"is",
"removable",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L247-L264 |
213,313 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_content | public function get_content(stored_file $file) {
if (!$file->get_filesize()) {
// Directories are empty. Empty files are not worth fetching.
return '';
}
$source = $this->get_remote_path_from_storedfile($file);
return file_get_contents($source);
} | php | public function get_content(stored_file $file) {
if (!$file->get_filesize()) {
// Directories are empty. Empty files are not worth fetching.
return '';
}
$source = $this->get_remote_path_from_storedfile($file);
return file_get_contents($source);
} | [
"public",
"function",
"get_content",
"(",
"stored_file",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"file",
"->",
"get_filesize",
"(",
")",
")",
"{",
"// Directories are empty. Empty files are not worth fetching.",
"return",
"''",
";",
"}",
"$",
"source",
"=",
... | Get the content of the specified stored file.
Generally you will probably want to use readfile() to serve content,
and where possible you should see if you can use
get_content_file_handle and work with the file stream instead.
@param stored_file $file The file to retrieve
@return string The full file content | [
"Get",
"the",
"content",
"of",
"the",
"specified",
"stored",
"file",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L276-L284 |
213,314 | moodle/moodle | lib/filestorage/file_system.php | file_system.list_files | public function list_files($file, file_packer $packer) {
$archivefile = $this->get_local_path_from_storedfile($file, true);
return $packer->list_files($archivefile);
} | php | public function list_files($file, file_packer $packer) {
$archivefile = $this->get_local_path_from_storedfile($file, true);
return $packer->list_files($archivefile);
} | [
"public",
"function",
"list_files",
"(",
"$",
"file",
",",
"file_packer",
"$",
"packer",
")",
"{",
"$",
"archivefile",
"=",
"$",
"this",
"->",
"get_local_path_from_storedfile",
"(",
"$",
"file",
",",
"true",
")",
";",
"return",
"$",
"packer",
"->",
"list_f... | List contents of archive.
@param stored_file $file The archive to inspect
@param file_packer $packer file packer instance
@return array of file infos | [
"List",
"contents",
"of",
"archive",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L293-L296 |
213,315 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_imageinfo | public function get_imageinfo(stored_file $file) {
if (!$this->is_image_from_storedfile($file)) {
return false;
}
// Whilst get_imageinfo_from_path can use remote paths, it must download the entire file first.
// It is more efficient to use a local file when possible.
... | php | public function get_imageinfo(stored_file $file) {
if (!$this->is_image_from_storedfile($file)) {
return false;
}
// Whilst get_imageinfo_from_path can use remote paths, it must download the entire file first.
// It is more efficient to use a local file when possible.
... | [
"public",
"function",
"get_imageinfo",
"(",
"stored_file",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"is_image_from_storedfile",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Whilst get_imageinfo_from_path can use remote paths, ... | Returns information about image.
Information is determined from the file content
@param stored_file $file The file to inspect
@return mixed array with width, height and mimetype; false if not an image | [
"Returns",
"information",
"about",
"image",
".",
"Information",
"is",
"determined",
"from",
"the",
"file",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L375-L383 |
213,316 | moodle/moodle | lib/filestorage/file_system.php | file_system.is_image_from_storedfile | public function is_image_from_storedfile(stored_file $file) {
if (!$file->get_filesize()) {
// An empty file cannot be an image.
return false;
}
$mimetype = $file->get_mimetype();
if (!preg_match('|^image/|', $mimetype)) {
// The mimetype does not inc... | php | public function is_image_from_storedfile(stored_file $file) {
if (!$file->get_filesize()) {
// An empty file cannot be an image.
return false;
}
$mimetype = $file->get_mimetype();
if (!preg_match('|^image/|', $mimetype)) {
// The mimetype does not inc... | [
"public",
"function",
"is_image_from_storedfile",
"(",
"stored_file",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"file",
"->",
"get_filesize",
"(",
")",
")",
"{",
"// An empty file cannot be an image.",
"return",
"false",
";",
"}",
"$",
"mimetype",
"=",
"$",
... | Attempt to determine whether the specified file is likely to be an
image.
Since this relies upon the mimetype stored in the files table, there
may be times when this information is not 100% accurate.
@param stored_file $file The file to check
@return bool | [
"Attempt",
"to",
"determine",
"whether",
"the",
"specified",
"file",
"is",
"likely",
"to",
"be",
"an",
"image",
".",
"Since",
"this",
"relies",
"upon",
"the",
"mimetype",
"stored",
"in",
"the",
"files",
"table",
"there",
"may",
"be",
"times",
"when",
"this... | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L394-L408 |
213,317 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_imageinfo_from_path | protected function get_imageinfo_from_path($path) {
$imageinfo = getimagesize($path);
$image = array(
'width' => $imageinfo[0],
'height' => $imageinfo[1],
'mimetype' => image_type_to_mime_type($imageinfo[2]),
);
if (empty($imag... | php | protected function get_imageinfo_from_path($path) {
$imageinfo = getimagesize($path);
$image = array(
'width' => $imageinfo[0],
'height' => $imageinfo[1],
'mimetype' => image_type_to_mime_type($imageinfo[2]),
);
if (empty($imag... | [
"protected",
"function",
"get_imageinfo_from_path",
"(",
"$",
"path",
")",
"{",
"$",
"imageinfo",
"=",
"getimagesize",
"(",
"$",
"path",
")",
";",
"$",
"image",
"=",
"array",
"(",
"'width'",
"=>",
"$",
"imageinfo",
"[",
"0",
"]",
",",
"'height'",
"=>",
... | Returns image information relating to the specified path or URL.
@param string $path The path to pass to getimagesize.
@return array Containing width, height, and mimetype. | [
"Returns",
"image",
"information",
"relating",
"to",
"the",
"specified",
"path",
"or",
"URL",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L416-L429 |
213,318 | moodle/moodle | lib/filestorage/file_system.php | file_system.validate_hash_and_file_size | protected function validate_hash_and_file_size($contenthash, $pathname) {
global $CFG;
if (!is_readable($pathname)) {
throw new file_exception('storedfilecannotread', '', $pathname);
}
$filesize = filesize($pathname);
if ($filesize === false) {
throw new... | php | protected function validate_hash_and_file_size($contenthash, $pathname) {
global $CFG;
if (!is_readable($pathname)) {
throw new file_exception('storedfilecannotread', '', $pathname);
}
$filesize = filesize($pathname);
if ($filesize === false) {
throw new... | [
"protected",
"function",
"validate_hash_and_file_size",
"(",
"$",
"contenthash",
",",
"$",
"pathname",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"pathname",
")",
")",
"{",
"throw",
"new",
"file_exception",
"(",
"'storedfil... | Validate that the content hash matches the content hash of the file on disk.
@param string $contenthash The current content hash to validate
@param string $pathname The path to the file on disk
@return array The content hash (it might change) and file size | [
"Validate",
"that",
"the",
"content",
"hash",
"matches",
"the",
"content",
"hash",
"of",
"the",
"file",
"on",
"disk",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L453-L498 |
213,319 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_content_file_handle | public function get_content_file_handle(stored_file $file, $type = stored_file::FILE_HANDLE_FOPEN) {
if ($type === stored_file::FILE_HANDLE_GZOPEN) {
// Local file required for gzopen.
$path = $this->get_local_path_from_storedfile($file, true);
} else {
$path = $this-... | php | public function get_content_file_handle(stored_file $file, $type = stored_file::FILE_HANDLE_FOPEN) {
if ($type === stored_file::FILE_HANDLE_GZOPEN) {
// Local file required for gzopen.
$path = $this->get_local_path_from_storedfile($file, true);
} else {
$path = $this-... | [
"public",
"function",
"get_content_file_handle",
"(",
"stored_file",
"$",
"file",
",",
"$",
"type",
"=",
"stored_file",
"::",
"FILE_HANDLE_FOPEN",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"stored_file",
"::",
"FILE_HANDLE_GZOPEN",
")",
"{",
"// Local file required... | Returns file handle - read only mode, no writing allowed into pool files!
When you want to modify a file, create a new file and delete the old one.
@param stored_file $file The file to retrieve a handle for
@param int $type Type of file handle (FILE_HANDLE_xx constant)
@return resource file handle | [
"Returns",
"file",
"handle",
"-",
"read",
"only",
"mode",
"no",
"writing",
"allowed",
"into",
"pool",
"files!"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L534-L543 |
213,320 | moodle/moodle | lib/filestorage/file_system.php | file_system.get_file_handle_for_path | protected static function get_file_handle_for_path($path, $type = stored_file::FILE_HANDLE_FOPEN) {
switch ($type) {
case stored_file::FILE_HANDLE_FOPEN:
// Binary reading.
return fopen($path, 'rb');
case stored_file::FILE_HANDLE_GZOPEN:
//... | php | protected static function get_file_handle_for_path($path, $type = stored_file::FILE_HANDLE_FOPEN) {
switch ($type) {
case stored_file::FILE_HANDLE_FOPEN:
// Binary reading.
return fopen($path, 'rb');
case stored_file::FILE_HANDLE_GZOPEN:
//... | [
"protected",
"static",
"function",
"get_file_handle_for_path",
"(",
"$",
"path",
",",
"$",
"type",
"=",
"stored_file",
"::",
"FILE_HANDLE_FOPEN",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"stored_file",
"::",
"FILE_HANDLE_FOPEN",
":",
"// Binary re... | Return a file handle for the specified path.
This abstraction should be used when overriding get_content_file_handle in a new file system.
@param string $path The path to the file. This shoudl be any type of path that fopen and gzopen accept.
@param int $type Type of file handle (FILE_HANDLE_xx constant)
@return reso... | [
"Return",
"a",
"file",
"handle",
"for",
"the",
"specified",
"path",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/filestorage/file_system.php#L555-L566 |
213,321 | moodle/moodle | mod/workshop/allocation/manual/renderer.php | workshopallocation_manual_renderer.render_workshopallocation_manual_allocations | protected function render_workshopallocation_manual_allocations(workshopallocation_manual_allocations $data) {
$this->workshop = $data->workshop;
$allocations = $data->allocations; // array prepared array of all allocations data
$userinfo = $data->userinfo; ... | php | protected function render_workshopallocation_manual_allocations(workshopallocation_manual_allocations $data) {
$this->workshop = $data->workshop;
$allocations = $data->allocations; // array prepared array of all allocations data
$userinfo = $data->userinfo; ... | [
"protected",
"function",
"render_workshopallocation_manual_allocations",
"(",
"workshopallocation_manual_allocations",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"workshop",
"=",
"$",
"data",
"->",
"workshop",
";",
"$",
"allocations",
"=",
"$",
"data",
"->",
"allocat... | Display the table of all current allocations and widgets to modify them
@param workshopallocation_manual_allocations $data to be displayed
@return string html code | [
"Display",
"the",
"table",
"of",
"all",
"current",
"allocations",
"and",
"widgets",
"to",
"modify",
"them"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/allocation/manual/renderer.php#L47-L92 |
213,322 | moodle/moodle | mod/workshop/allocation/manual/renderer.php | workshopallocation_manual_renderer.helper_participant | protected function helper_participant(stdclass $allocation, array $userinfo) {
$o = $this->output->user_picture($userinfo[$allocation->userid], array('courseid' => $this->page->course->id));
$o .= fullname($userinfo[$allocation->userid]);
$o .= $this->output->container_start(array('submission')... | php | protected function helper_participant(stdclass $allocation, array $userinfo) {
$o = $this->output->user_picture($userinfo[$allocation->userid], array('courseid' => $this->page->course->id));
$o .= fullname($userinfo[$allocation->userid]);
$o .= $this->output->container_start(array('submission')... | [
"protected",
"function",
"helper_participant",
"(",
"stdclass",
"$",
"allocation",
",",
"array",
"$",
"userinfo",
")",
"{",
"$",
"o",
"=",
"$",
"this",
"->",
"output",
"->",
"user_picture",
"(",
"$",
"userinfo",
"[",
"$",
"allocation",
"->",
"userid",
"]",... | Returns information about the workshop participant
@return string HTML code | [
"Returns",
"information",
"about",
"the",
"workshop",
"participant"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/allocation/manual/renderer.php#L103-L120 |
213,323 | moodle/moodle | mod/workshop/allocation/manual/renderer.php | workshopallocation_manual_renderer.helper_reviewers_of_participant | protected function helper_reviewers_of_participant(stdclass $allocation, array $userinfo, array $reviewers, $selfassessment) {
$o = '';
if (is_null($allocation->submissionid)) {
$o .= $this->output->container(get_string('nothingtoreview', 'workshop'), 'info');
} else {
$e... | php | protected function helper_reviewers_of_participant(stdclass $allocation, array $userinfo, array $reviewers, $selfassessment) {
$o = '';
if (is_null($allocation->submissionid)) {
$o .= $this->output->container(get_string('nothingtoreview', 'workshop'), 'info');
} else {
$e... | [
"protected",
"function",
"helper_reviewers_of_participant",
"(",
"stdclass",
"$",
"allocation",
",",
"array",
"$",
"userinfo",
",",
"array",
"$",
"reviewers",
",",
"$",
"selfassessment",
")",
"{",
"$",
"o",
"=",
"''",
";",
"if",
"(",
"is_null",
"(",
"$",
"... | Returns information about the current reviewers of the given participant and a selector do add new one
@return string html code | [
"Returns",
"information",
"about",
"the",
"current",
"reviewers",
"of",
"the",
"given",
"participant",
"and",
"a",
"selector",
"do",
"add",
"new",
"one"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/allocation/manual/renderer.php#L127-L159 |
213,324 | moodle/moodle | lib/pear/HTML/QuickForm/Renderer/Array.php | HTML_QuickForm_Renderer_Array.renderElement | function renderElement(&$element, $required, $error)
{
$elAry = $this->_elementToArray($element, $required, $error);
if (!empty($error)) {
$this->_ary['errors'][$elAry['name']] = $error;
}
$this->_storeArray($elAry);
} | php | function renderElement(&$element, $required, $error)
{
$elAry = $this->_elementToArray($element, $required, $error);
if (!empty($error)) {
$this->_ary['errors'][$elAry['name']] = $error;
}
$this->_storeArray($elAry);
} | [
"function",
"renderElement",
"(",
"&",
"$",
"element",
",",
"$",
"required",
",",
"$",
"error",
")",
"{",
"$",
"elAry",
"=",
"$",
"this",
"->",
"_elementToArray",
"(",
"$",
"element",
",",
"$",
"required",
",",
"$",
"error",
")",
";",
"if",
"(",
"!... | end func renderHeader | [
"end",
"func",
"renderHeader"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Array.php#L206-L213 |
213,325 | moodle/moodle | lib/pear/HTML/QuickForm/Renderer/Array.php | HTML_QuickForm_Renderer_Array._elementToArray | function _elementToArray(&$element, $required, $error)
{
$ret = array(
'name' => $element->getName(),
'value' => $element->getValue(),
'type' => $element->getType(),
'frozen' => $element->isFrozen(),
'required' => $required,
... | php | function _elementToArray(&$element, $required, $error)
{
$ret = array(
'name' => $element->getName(),
'value' => $element->getValue(),
'type' => $element->getType(),
'frozen' => $element->isFrozen(),
'required' => $required,
... | [
"function",
"_elementToArray",
"(",
"&",
"$",
"element",
",",
"$",
"required",
",",
"$",
"error",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"element",
"->",
"getName",
"(",
")",
",",
"'value'",
"=>",
"$",
"element",
"->",
"getValu... | Creates an array representing an element
@access private
@param object An HTML_QuickForm_element object
@param bool Whether an element is required
@param string Error associated with the element
@return array | [
"Creates",
"an",
"array",
"representing",
"an",
"element"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Array.php#L251-L287 |
213,326 | moodle/moodle | lib/pear/HTML/QuickForm/Renderer/Array.php | HTML_QuickForm_Renderer_Array._storeArray | function _storeArray($elAry)
{
// where should we put this element...
if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) {
$this->_currentGroup['elements'][] = $elAry;
} elseif (isset($this->_currentSection)) {
$this->_ary['sections'][$this->_currentSe... | php | function _storeArray($elAry)
{
// where should we put this element...
if (is_array($this->_currentGroup) && ('group' != $elAry['type'])) {
$this->_currentGroup['elements'][] = $elAry;
} elseif (isset($this->_currentSection)) {
$this->_ary['sections'][$this->_currentSe... | [
"function",
"_storeArray",
"(",
"$",
"elAry",
")",
"{",
"// where should we put this element...",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_currentGroup",
")",
"&&",
"(",
"'group'",
"!=",
"$",
"elAry",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",... | Stores an array representation of an element in the form array
@access private
@param array Array representation of an element
@return void | [
"Stores",
"an",
"array",
"representation",
"of",
"an",
"element",
"in",
"the",
"form",
"array"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Array.php#L297-L307 |
213,327 | moodle/moodle | lib/pear/HTML/QuickForm/Renderer/Array.php | HTML_QuickForm_Renderer_Array.setElementStyle | function setElementStyle($elementName, $styleName = null)
{
if (is_array($elementName)) {
$this->_elementStyles = array_merge($this->_elementStyles, $elementName);
} else {
$this->_elementStyles[$elementName] = $styleName;
}
} | php | function setElementStyle($elementName, $styleName = null)
{
if (is_array($elementName)) {
$this->_elementStyles = array_merge($this->_elementStyles, $elementName);
} else {
$this->_elementStyles[$elementName] = $styleName;
}
} | [
"function",
"setElementStyle",
"(",
"$",
"elementName",
",",
"$",
"styleName",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"elementName",
")",
")",
"{",
"$",
"this",
"->",
"_elementStyles",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_elemen... | Sets a style to use for element rendering
@param mixed element name or array ('element name' => 'style name')
@param string style name if $elementName is not an array
@access public
@return void | [
"Sets",
"a",
"style",
"to",
"use",
"for",
"element",
"rendering"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Array.php#L318-L325 |
213,328 | moodle/moodle | lib/form/grading.php | MoodleQuickForm_grading.get_gradinginstance | public function get_gradinginstance() {
if (is_array($this->gradingattributes) && array_key_exists('gradinginstance', $this->gradingattributes)) {
return $this->gradingattributes['gradinginstance'];
} else {
return null;
}
} | php | public function get_gradinginstance() {
if (is_array($this->gradingattributes) && array_key_exists('gradinginstance', $this->gradingattributes)) {
return $this->gradingattributes['gradinginstance'];
} else {
return null;
}
} | [
"public",
"function",
"get_gradinginstance",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"gradingattributes",
")",
"&&",
"array_key_exists",
"(",
"'gradinginstance'",
",",
"$",
"this",
"->",
"gradingattributes",
")",
")",
"{",
"return",
"$",
... | Helper function to retrieve gradingform_instance passed in element attributes
@return gradingform_instance | [
"Helper",
"function",
"to",
"retrieve",
"gradingform_instance",
"passed",
"in",
"element",
"attributes"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/grading.php#L90-L96 |
213,329 | moodle/moodle | lib/form/grading.php | MoodleQuickForm_grading.onQuickFormEvent | public function onQuickFormEvent($event, $arg, &$caller) {
if ($event == 'createElement') {
$attributes = $arg[2];
if (!is_array($attributes) || !array_key_exists('gradinginstance', $attributes) || !($attributes['gradinginstance'] instanceof gradingform_instance)) {
throw... | php | public function onQuickFormEvent($event, $arg, &$caller) {
if ($event == 'createElement') {
$attributes = $arg[2];
if (!is_array($attributes) || !array_key_exists('gradinginstance', $attributes) || !($attributes['gradinginstance'] instanceof gradingform_instance)) {
throw... | [
"public",
"function",
"onQuickFormEvent",
"(",
"$",
"event",
",",
"$",
"arg",
",",
"&",
"$",
"caller",
")",
"{",
"if",
"(",
"$",
"event",
"==",
"'createElement'",
")",
"{",
"$",
"attributes",
"=",
"$",
"arg",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"... | Called by HTML_QuickForm whenever form event is made on this element.
Adds necessary rules to the element and checks that coorenct instance of gradingform_instance
is passed in attributes
@param string $event Name of event
@param mixed $arg event arguments
@param object $caller calling object
@return bool
@throws mood... | [
"Called",
"by",
"HTML_QuickForm",
"whenever",
"form",
"event",
"is",
"made",
"on",
"this",
"element",
".",
"Adds",
"necessary",
"rules",
"to",
"the",
"element",
"and",
"checks",
"that",
"coorenct",
"instance",
"of",
"gradingform_instance",
"is",
"passed",
"in",
... | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/grading.php#L138-L151 |
213,330 | moodle/moodle | message/classes/api.php | api.search_messages | public static function search_messages($userid, $search, $limitfrom = 0, $limitnum = 0) {
global $DB;
// Get the user fields we want.
$ufields = \user_picture::fields('u', array('lastaccess'), 'userfrom_id', 'userfrom_');
$ufields2 = \user_picture::fields('u2', array('lastaccess'), 'use... | php | public static function search_messages($userid, $search, $limitfrom = 0, $limitnum = 0) {
global $DB;
// Get the user fields we want.
$ufields = \user_picture::fields('u', array('lastaccess'), 'userfrom_id', 'userfrom_');
$ufields2 = \user_picture::fields('u2', array('lastaccess'), 'use... | [
"public",
"static",
"function",
"search_messages",
"(",
"$",
"userid",
",",
"$",
"search",
",",
"$",
"limitfrom",
"=",
"0",
",",
"$",
"limitnum",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"// Get the user fields we want.",
"$",
"ufields",
"=",
"\\",
... | Handles searching for messages in the message area.
@param int $userid The user id doing the searching
@param string $search The string the user is searching
@param int $limitfrom
@param int $limitnum
@return array | [
"Handles",
"searching",
"for",
"messages",
"in",
"the",
"message",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L105-L167 |
213,331 | moodle/moodle | message/classes/api.php | api.search_users_in_course | public static function search_users_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) {
global $DB;
// Get all the users in the course.
list($esql, $params) = get_enrolled_sql(\context_course::instance($courseid), '', 0, true);
$sql = "SELECT u.*, mub.id as isblocked... | php | public static function search_users_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) {
global $DB;
// Get all the users in the course.
list($esql, $params) = get_enrolled_sql(\context_course::instance($courseid), '', 0, true);
$sql = "SELECT u.*, mub.id as isblocked... | [
"public",
"static",
"function",
"search_users_in_course",
"(",
"$",
"userid",
",",
"$",
"courseid",
",",
"$",
"search",
",",
"$",
"limitfrom",
"=",
"0",
",",
"$",
"limitnum",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"// Get all the users in the course."... | Handles searching for user in a particular course in the message area.
TODO: This function should be removed once the related web service goes through final deprecation.
The related web service is data_for_messagearea_search_users_in_course.
Followup: MDL-63261
@param int $userid The user id doing the searching
@para... | [
"Handles",
"searching",
"for",
"user",
"in",
"a",
"particular",
"course",
"in",
"the",
"message",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L183-L212 |
213,332 | moodle/moodle | message/classes/api.php | api.get_linked_conversation_extra_fields | protected static function get_linked_conversation_extra_fields(array $conversations) : array {
global $DB, $PAGE;
$renderer = $PAGE->get_renderer('core');
$linkedconversations = [];
foreach ($conversations as $conversation) {
if (!is_null($conversation->component) && !is_nu... | php | protected static function get_linked_conversation_extra_fields(array $conversations) : array {
global $DB, $PAGE;
$renderer = $PAGE->get_renderer('core');
$linkedconversations = [];
foreach ($conversations as $conversation) {
if (!is_null($conversation->component) && !is_nu... | [
"protected",
"static",
"function",
"get_linked_conversation_extra_fields",
"(",
"array",
"$",
"conversations",
")",
":",
"array",
"{",
"global",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"renderer",
"=",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
";... | Gets extra fields, like image url and subname for any conversations linked to components.
The subname is like a subtitle for the conversation, to compliment it's name.
The imageurl is the location of the image for the conversation, as might be seen on a listing of conversations for a user.
@param array $conversations... | [
"Gets",
"extra",
"fields",
"like",
"image",
"url",
"and",
"subname",
"for",
"any",
"conversations",
"linked",
"to",
"components",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L448-L491 |
213,333 | moodle/moodle | message/classes/api.php | api.get_conversations_between_users | public static function get_conversations_between_users(int $userid1, int $userid2,
int $limitfrom = 0, int $limitnum = 20) : array {
global $DB;
if ($userid1 == $userid2) {
return array();
}
// Get all conversation... | php | public static function get_conversations_between_users(int $userid1, int $userid2,
int $limitfrom = 0, int $limitnum = 20) : array {
global $DB;
if ($userid1 == $userid2) {
return array();
}
// Get all conversation... | [
"public",
"static",
"function",
"get_conversations_between_users",
"(",
"int",
"$",
"userid1",
",",
"int",
"$",
"userid2",
",",
"int",
"$",
"limitfrom",
"=",
"0",
",",
"int",
"$",
"limitnum",
"=",
"20",
")",
":",
"array",
"{",
"global",
"$",
"DB",
";",
... | Returns all conversations between two users
@param int $userid1 One of the user's id
@param int $userid2 The other user's id
@param int $limitfrom
@param int $limitnum
@return array
@throws \dml_exception | [
"Returns",
"all",
"conversations",
"between",
"two",
"users"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L846-L869 |
213,334 | moodle/moodle | message/classes/api.php | api.set_favourite_conversation | public static function set_favourite_conversation(int $conversationid, int $userid) : favourite {
global $DB;
if (!self::is_user_in_conversation($userid, $conversationid)) {
throw new \moodle_exception("Conversation doesn't exist or user is not a member");
}
// Get the conte... | php | public static function set_favourite_conversation(int $conversationid, int $userid) : favourite {
global $DB;
if (!self::is_user_in_conversation($userid, $conversationid)) {
throw new \moodle_exception("Conversation doesn't exist or user is not a member");
}
// Get the conte... | [
"public",
"static",
"function",
"set_favourite_conversation",
"(",
"int",
"$",
"conversationid",
",",
"int",
"$",
"userid",
")",
":",
"favourite",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"!",
"self",
"::",
"is_user_in_conversation",
"(",
"$",
"userid",
","... | Mark a conversation as a favourite for the given user.
@param int $conversationid the id of the conversation to mark as a favourite.
@param int $userid the id of the user to whom the favourite belongs.
@return favourite the favourite object.
@throws \moodle_exception if the user or conversation don't exist. | [
"Mark",
"a",
"conversation",
"as",
"a",
"favourite",
"for",
"the",
"given",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1010-L1034 |
213,335 | moodle/moodle | message/classes/api.php | api.unset_favourite_conversation | public static function unset_favourite_conversation(int $conversationid, int $userid) {
global $DB;
// Get the context for this conversation.
$conversation = $DB->get_record('message_conversations', ['id' => $conversationid]);
$userctx = \context_user::instance($userid);
if (emp... | php | public static function unset_favourite_conversation(int $conversationid, int $userid) {
global $DB;
// Get the context for this conversation.
$conversation = $DB->get_record('message_conversations', ['id' => $conversationid]);
$userctx = \context_user::instance($userid);
if (emp... | [
"public",
"static",
"function",
"unset_favourite_conversation",
"(",
"int",
"$",
"conversationid",
",",
"int",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
";",
"// Get the context for this conversation.",
"$",
"conversation",
"=",
"$",
"DB",
"->",
"get_record",
... | Unset a conversation as a favourite for the given user.
@param int $conversationid the id of the conversation to unset as a favourite.
@param int $userid the id to whom the favourite belongs.
@throws \moodle_exception if the favourite does not exist for the user. | [
"Unset",
"a",
"conversation",
"as",
"a",
"favourite",
"for",
"the",
"given",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1043-L1059 |
213,336 | moodle/moodle | message/classes/api.php | api.get_contacts | public static function get_contacts($userid, $limitfrom = 0, $limitnum = 0) {
global $DB;
$contactids = [];
$sql = "SELECT mc.*
FROM {message_contacts} mc
WHERE mc.userid = ? OR mc.contactid = ?
ORDER BY timecreated DESC";
if ($contacts =... | php | public static function get_contacts($userid, $limitfrom = 0, $limitnum = 0) {
global $DB;
$contactids = [];
$sql = "SELECT mc.*
FROM {message_contacts} mc
WHERE mc.userid = ? OR mc.contactid = ?
ORDER BY timecreated DESC";
if ($contacts =... | [
"public",
"static",
"function",
"get_contacts",
"(",
"$",
"userid",
",",
"$",
"limitfrom",
"=",
"0",
",",
"$",
"limitnum",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"contactids",
"=",
"[",
"]",
";",
"$",
"sql",
"=",
"\"SELECT mc.*\n ... | Returns the contacts to display in the contacts area.
TODO: This function should be removed once the related web service goes through final deprecation.
The related web service is data_for_messagearea_contacts.
Followup: MDL-63261
@param int $userid The user id
@param int $limitfrom
@param int $limitnum
@return array | [
"Returns",
"the",
"contacts",
"to",
"display",
"in",
"the",
"contacts",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1073-L1111 |
213,337 | moodle/moodle | message/classes/api.php | api.get_user_contacts | public static function get_user_contacts(int $userid, int $limitfrom = 0, int $limitnum = 0) {
global $DB;
$sql = "SELECT *
FROM {message_contacts} mc
WHERE mc.userid = ? OR mc.contactid = ?
ORDER BY timecreated DESC, id ASC";
if ($contacts = $DB... | php | public static function get_user_contacts(int $userid, int $limitfrom = 0, int $limitnum = 0) {
global $DB;
$sql = "SELECT *
FROM {message_contacts} mc
WHERE mc.userid = ? OR mc.contactid = ?
ORDER BY timecreated DESC, id ASC";
if ($contacts = $DB... | [
"public",
"static",
"function",
"get_user_contacts",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"limitfrom",
"=",
"0",
",",
"int",
"$",
"limitnum",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT *\n FROM {message_c... | Get the contacts for a given user.
@param int $userid
@param int $limitfrom
@param int $limitnum
@return array An array of contacts | [
"Get",
"the",
"contacts",
"for",
"a",
"given",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1121-L1141 |
213,338 | moodle/moodle | message/classes/api.php | api.count_contacts | public static function count_contacts(int $userid) : int {
global $DB;
$sql = "SELECT COUNT(id)
FROM {message_contacts}
WHERE userid = ? OR contactid = ?";
return $DB->count_records_sql($sql, [$userid, $userid]);
} | php | public static function count_contacts(int $userid) : int {
global $DB;
$sql = "SELECT COUNT(id)
FROM {message_contacts}
WHERE userid = ? OR contactid = ?";
return $DB->count_records_sql($sql, [$userid, $userid]);
} | [
"public",
"static",
"function",
"count_contacts",
"(",
"int",
"$",
"userid",
")",
":",
"int",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT COUNT(id)\n FROM {message_contacts}\n WHERE userid = ? OR contactid = ?\"",
";",
"return"... | Returns the contacts count.
@param int $userid The user id
@return array | [
"Returns",
"the",
"contacts",
"count",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1149-L1156 |
213,339 | moodle/moodle | message/classes/api.php | api.get_non_contacts_with_unread_message_count | public static function get_non_contacts_with_unread_message_count($userid, $limitfrom = 0, $limitnum = 0) {
global $DB;
$userfields = \user_picture::fields('u', array('lastaccess'));
$unreadcountssql = "SELECT $userfields, count(m.id) as messagecount
FROM {user} u
... | php | public static function get_non_contacts_with_unread_message_count($userid, $limitfrom = 0, $limitnum = 0) {
global $DB;
$userfields = \user_picture::fields('u', array('lastaccess'));
$unreadcountssql = "SELECT $userfields, count(m.id) as messagecount
FROM {user} u
... | [
"public",
"static",
"function",
"get_non_contacts_with_unread_message_count",
"(",
"$",
"userid",
",",
"$",
"limitfrom",
"=",
"0",
",",
"$",
"limitnum",
"=",
"0",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"userfields",
"=",
"\\",
"user_picture",
"::",
"fields... | Returns the an array of the users the given user is in a conversation
with who are not a contact and the number of unread messages.
@param int $userid The user id
@param int $limitfrom
@param int $limitnum
@return array | [
"Returns",
"the",
"an",
"array",
"of",
"the",
"users",
"the",
"given",
"user",
"is",
"in",
"a",
"conversation",
"with",
"who",
"are",
"not",
"a",
"contact",
"and",
"the",
"number",
"of",
"unread",
"messages",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1203-L1229 |
213,340 | moodle/moodle | message/classes/api.php | api.get_messages | public static function get_messages($userid, $otheruserid, $limitfrom = 0, $limitnum = 0,
$sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) {
if (!empty($timefrom)) {
// Get the conversation between userid and otheruserid.
$userids = [$userid, $otheruserid];
... | php | public static function get_messages($userid, $otheruserid, $limitfrom = 0, $limitnum = 0,
$sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) {
if (!empty($timefrom)) {
// Get the conversation between userid and otheruserid.
$userids = [$userid, $otheruserid];
... | [
"public",
"static",
"function",
"get_messages",
"(",
"$",
"userid",
",",
"$",
"otheruserid",
",",
"$",
"limitfrom",
"=",
"0",
",",
"$",
"limitnum",
"=",
"0",
",",
"$",
"sort",
"=",
"'timecreated ASC'",
",",
"$",
"timefrom",
"=",
"0",
",",
"$",
"timeto"... | Returns the messages to display in the message area.
TODO: This function should be removed once the related web service goes through final deprecation.
The related web service is data_for_messagearea_messages.
Followup: MDL-63261
@param int $userid the current user
@param int $otheruserid the other user
@param int $l... | [
"Returns",
"the",
"messages",
"to",
"display",
"in",
"the",
"message",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1247-L1278 |
213,341 | moodle/moodle | message/classes/api.php | api.get_conversation_messages | public static function get_conversation_messages(int $userid, int $convid, int $limitfrom = 0, int $limitnum = 0,
string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array {
if (!empty($timefrom)) {
// Check the cache to see if we even need to do a DB query.
... | php | public static function get_conversation_messages(int $userid, int $convid, int $limitfrom = 0, int $limitnum = 0,
string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array {
if (!empty($timefrom)) {
// Check the cache to see if we even need to do a DB query.
... | [
"public",
"static",
"function",
"get_conversation_messages",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"convid",
",",
"int",
"$",
"limitfrom",
"=",
"0",
",",
"int",
"$",
"limitnum",
"=",
"0",
",",
"string",
"$",
"sort",
"=",
"'timecreated ASC'",
",",
"... | Returns the messages for the defined conversation.
@param int $userid The current user.
@param int $convid The conversation where the messages belong. Could be an object or just the id.
@param int $limitfrom Return a subset of records, starting at this point (optional).
@param int $limitnum Return a subset compris... | [
"Returns",
"the",
"messages",
"for",
"the",
"defined",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1292-L1310 |
213,342 | moodle/moodle | message/classes/api.php | api.get_most_recent_message | public static function get_most_recent_message($userid, $otheruserid) {
// We want two messages here so we get an accurate 'blocktime' value.
if ($messages = helper::get_messages($userid, $otheruserid, 0, 0, 2, 'timecreated DESC')) {
// Swap the order so we now have them in historical order.... | php | public static function get_most_recent_message($userid, $otheruserid) {
// We want two messages here so we get an accurate 'blocktime' value.
if ($messages = helper::get_messages($userid, $otheruserid, 0, 0, 2, 'timecreated DESC')) {
// Swap the order so we now have them in historical order.... | [
"public",
"static",
"function",
"get_most_recent_message",
"(",
"$",
"userid",
",",
"$",
"otheruserid",
")",
"{",
"// We want two messages here so we get an accurate 'blocktime' value.",
"if",
"(",
"$",
"messages",
"=",
"helper",
"::",
"get_messages",
"(",
"$",
"userid"... | Returns the most recent message between two users.
TODO: This function should be removed once the related web service goes through final deprecation.
The related web service is data_for_messagearea_get_most_recent_message.
Followup: MDL-63261
@param int $userid the current user
@param int $otheruserid the other user
... | [
"Returns",
"the",
"most",
"recent",
"message",
"between",
"two",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1323-L1333 |
213,343 | moodle/moodle | message/classes/api.php | api.get_most_recent_conversation_message | public static function get_most_recent_conversation_message(int $convid, int $currentuserid = 0) {
global $USER;
if (empty($currentuserid)) {
$currentuserid = $USER->id;
}
if ($messages = helper::get_conversation_messages($currentuserid, $convid, 0, 0, 1, 'timecreated DESC'... | php | public static function get_most_recent_conversation_message(int $convid, int $currentuserid = 0) {
global $USER;
if (empty($currentuserid)) {
$currentuserid = $USER->id;
}
if ($messages = helper::get_conversation_messages($currentuserid, $convid, 0, 0, 1, 'timecreated DESC'... | [
"public",
"static",
"function",
"get_most_recent_conversation_message",
"(",
"int",
"$",
"convid",
",",
"int",
"$",
"currentuserid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"empty",
"(",
"$",
"currentuserid",
")",
")",
"{",
"$",
"current... | Returns the most recent message in a conversation.
@param int $convid The conversation identifier.
@param int $currentuserid The current user identifier.
@return \stdClass|null The most recent message. | [
"Returns",
"the",
"most",
"recent",
"message",
"in",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1342-L1355 |
213,344 | moodle/moodle | message/classes/api.php | api.get_profile | public static function get_profile($userid, $otheruserid) {
global $CFG, $PAGE;
require_once($CFG->dirroot . '/user/lib.php');
$user = \core_user::get_user($otheruserid, '*', MUST_EXIST);
// Create the data we are going to pass to the renderable.
$data = new \stdClass();
... | php | public static function get_profile($userid, $otheruserid) {
global $CFG, $PAGE;
require_once($CFG->dirroot . '/user/lib.php');
$user = \core_user::get_user($otheruserid, '*', MUST_EXIST);
// Create the data we are going to pass to the renderable.
$data = new \stdClass();
... | [
"public",
"static",
"function",
"get_profile",
"(",
"$",
"userid",
",",
"$",
"otheruserid",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"PAGE",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/user/lib.php'",
")",
";",
"$",
"user",
"=",
"\\... | Returns the profile information for a contact for a user.
TODO: This function should be removed once the related web service goes through final deprecation.
The related web service is data_for_messagearea_get_profile.
Followup: MDL-63261
@param int $userid The user id
@param int $otheruserid The id of the user whose ... | [
"Returns",
"the",
"profile",
"information",
"for",
"a",
"contact",
"for",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1368-L1410 |
213,345 | moodle/moodle | message/classes/api.php | api.can_delete_conversation | public static function can_delete_conversation(int $userid, int $conversationid = null) : bool {
global $USER;
if (is_null($conversationid)) {
debugging('\core_message\api::can_delete_conversation() now expects a \'conversationid\' to be passed.',
DEBUG_DEVELOPER);
... | php | public static function can_delete_conversation(int $userid, int $conversationid = null) : bool {
global $USER;
if (is_null($conversationid)) {
debugging('\core_message\api::can_delete_conversation() now expects a \'conversationid\' to be passed.',
DEBUG_DEVELOPER);
... | [
"public",
"static",
"function",
"can_delete_conversation",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
"=",
"null",
")",
":",
"bool",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"is_null",
"(",
"$",
"conversationid",
")",
")",
"{",
"deb... | Checks if a user can delete messages they have either received or sent.
@param int $userid The user id of who we want to delete the messages for (this may be done by the admin
but will still seem as if it was by the user)
@param int $conversationid The id of the conversation
@return bool Returns true if a user can del... | [
"Checks",
"if",
"a",
"user",
"can",
"delete",
"messages",
"they",
"have",
"either",
"received",
"or",
"sent",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1420-L1445 |
213,346 | moodle/moodle | message/classes/api.php | api.delete_conversation_by_id | public static function delete_conversation_by_id(int $userid, int $conversationid) {
global $DB, $USER;
// Get all messages belonging to this conversation that have not already been deleted by this user.
$sql = "SELECT m.*
FROM {messages} m
INNER JOIN {message_conver... | php | public static function delete_conversation_by_id(int $userid, int $conversationid) {
global $DB, $USER;
// Get all messages belonging to this conversation that have not already been deleted by this user.
$sql = "SELECT m.*
FROM {messages} m
INNER JOIN {message_conver... | [
"public",
"static",
"function",
"delete_conversation_by_id",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"// Get all messages belonging to this conversation that have not already been deleted by this us... | Deletes a conversation for a specified user.
This function does not verify any permissions.
@param int $userid The user id of who we want to delete the messages for (this may be done by the admin
but will still seem as if it was by the user)
@param int $conversationid The id of the other user in the conversation | [
"Deletes",
"a",
"conversation",
"for",
"a",
"specified",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1483-L1510 |
213,347 | moodle/moodle | message/classes/api.php | api.can_mark_all_messages_as_read | public static function can_mark_all_messages_as_read(int $userid, int $conversationid) : bool {
global $USER;
$systemcontext = \context_system::instance();
if (has_capability('moodle/site:readallmessages', $systemcontext)) {
return true;
}
if (!self::is_user_in_con... | php | public static function can_mark_all_messages_as_read(int $userid, int $conversationid) : bool {
global $USER;
$systemcontext = \context_system::instance();
if (has_capability('moodle/site:readallmessages', $systemcontext)) {
return true;
}
if (!self::is_user_in_con... | [
"public",
"static",
"function",
"can_mark_all_messages_as_read",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"bool",
"{",
"global",
"$",
"USER",
";",
"$",
"systemcontext",
"=",
"\\",
"context_system",
"::",
"instance",
"(",
")",
"... | Checks if a user can mark all messages as read.
@param int $userid The user id of who we want to mark the messages for
@param int $conversationid The id of the conversation
@return bool true if user is permitted, false otherwise
@since 3.6 | [
"Checks",
"if",
"a",
"user",
"can",
"mark",
"all",
"messages",
"as",
"read",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1551-L1569 |
213,348 | moodle/moodle | message/classes/api.php | api.mark_all_messages_as_read | public static function mark_all_messages_as_read($userid, $conversationid = null) {
global $DB;
$messagesql = "SELECT m.*
FROM {messages} m
INNER JOIN {message_conversations} mc
ON mc.id = m.conversationid
INNER J... | php | public static function mark_all_messages_as_read($userid, $conversationid = null) {
global $DB;
$messagesql = "SELECT m.*
FROM {messages} m
INNER JOIN {message_conversations} mc
ON mc.id = m.conversationid
INNER J... | [
"public",
"static",
"function",
"mark_all_messages_as_read",
"(",
"$",
"userid",
",",
"$",
"conversationid",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"messagesql",
"=",
"\"SELECT m.*\n FROM {messages} m\n INNER JOIN {me... | Marks all messages being sent to a user in a particular conversation.
If $conversationdid is null then it marks all messages as read sent to $userid.
@param int $userid
@param int|null $conversationid The conversation the messages belong to mark as read, if null mark all | [
"Marks",
"all",
"messages",
"being",
"sent",
"to",
"a",
"user",
"in",
"a",
"particular",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1683-L1712 |
213,349 | moodle/moodle | message/classes/api.php | api.mark_all_notifications_as_read | public static function mark_all_notifications_as_read($touserid, $fromuserid = null) {
global $DB;
$notificationsql = "SELECT n.*
FROM {notifications} n
WHERE useridto = ?
AND timeread is NULL";
$notificat... | php | public static function mark_all_notifications_as_read($touserid, $fromuserid = null) {
global $DB;
$notificationsql = "SELECT n.*
FROM {notifications} n
WHERE useridto = ?
AND timeread is NULL";
$notificat... | [
"public",
"static",
"function",
"mark_all_notifications_as_read",
"(",
"$",
"touserid",
",",
"$",
"fromuserid",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"notificationsql",
"=",
"\"SELECT n.*\n FROM {notifications} n\n ... | Marks all notifications being sent from one user to another user as read.
If the from user is null then it marks all notifications as read sent to the to user.
@param int $touserid the id of the message recipient
@param int|null $fromuserid the id of the message sender, null if all messages
@return void | [
"Marks",
"all",
"notifications",
"being",
"sent",
"from",
"one",
"user",
"to",
"another",
"user",
"as",
"read",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1723-L1741 |
213,350 | moodle/moodle | message/classes/api.php | api.get_all_message_preferences | public static function get_all_message_preferences($processors, $providers, $user) {
$preferences = helper::get_providers_preferences($providers, $user->id);
$preferences->userdefaultemail = $user->email; // May be displayed by the email processor.
// For every processors put its options on the... | php | public static function get_all_message_preferences($processors, $providers, $user) {
$preferences = helper::get_providers_preferences($providers, $user->id);
$preferences->userdefaultemail = $user->email; // May be displayed by the email processor.
// For every processors put its options on the... | [
"public",
"static",
"function",
"get_all_message_preferences",
"(",
"$",
"processors",
",",
"$",
"providers",
",",
"$",
"user",
")",
"{",
"$",
"preferences",
"=",
"helper",
"::",
"get_providers_preferences",
"(",
"$",
"providers",
",",
"$",
"user",
"->",
"id",... | Returns message preferences.
@param array $processors
@param array $providers
@param \stdClass $user
@return \stdClass
@since 3.2 | [
"Returns",
"message",
"preferences",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1795-L1810 |
213,351 | moodle/moodle | message/classes/api.php | api.count_blocked_users | public static function count_blocked_users($user = null) {
global $USER, $DB;
if (empty($user)) {
$user = $USER;
}
$sql = "SELECT count(mub.id)
FROM {message_users_blocked} mub
WHERE mub.userid = :userid";
return $DB->count_records... | php | public static function count_blocked_users($user = null) {
global $USER, $DB;
if (empty($user)) {
$user = $USER;
}
$sql = "SELECT count(mub.id)
FROM {message_users_blocked} mub
WHERE mub.userid = :userid";
return $DB->count_records... | [
"public",
"static",
"function",
"count_blocked_users",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"USER",
";",
"}",
"$",
"sql",
... | Count the number of users blocked by a user.
@param \stdClass $user The user object
@return int the number of blocked users | [
"Count",
"the",
"number",
"of",
"users",
"blocked",
"by",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1818-L1829 |
213,352 | moodle/moodle | message/classes/api.php | api.can_post_message | public static function can_post_message($recipient, $sender = null) {
global $USER;
if (is_null($sender)) {
// The message is from the logged in user, unless otherwise specified.
$sender = $USER;
}
$systemcontext = \context_system::instance();
if (!has_c... | php | public static function can_post_message($recipient, $sender = null) {
global $USER;
if (is_null($sender)) {
// The message is from the logged in user, unless otherwise specified.
$sender = $USER;
}
$systemcontext = \context_system::instance();
if (!has_c... | [
"public",
"static",
"function",
"can_post_message",
"(",
"$",
"recipient",
",",
"$",
"sender",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"is_null",
"(",
"$",
"sender",
")",
")",
"{",
"// The message is from the logged in user, unless otherwis... | Determines if a user is permitted to send another user a private message.
If no sender is provided then it defaults to the logged in user.
@param \stdClass $recipient The user object.
@param \stdClass|null $sender The user object.
@return bool true if user is permitted, false otherwise. | [
"Determines",
"if",
"a",
"user",
"is",
"permitted",
"to",
"send",
"another",
"user",
"a",
"private",
"message",
".",
"If",
"no",
"sender",
"is",
"provided",
"then",
"it",
"defaults",
"to",
"the",
"logged",
"in",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1839-L1858 |
213,353 | moodle/moodle | message/classes/api.php | api.can_send_message_to_conversation | public static function can_send_message_to_conversation(int $userid, int $conversationid) : bool {
global $DB;
$systemcontext = \context_system::instance();
if (!has_capability('moodle/site:sendmessage', $systemcontext, $userid)) {
return false;
}
if (!self::is_user... | php | public static function can_send_message_to_conversation(int $userid, int $conversationid) : bool {
global $DB;
$systemcontext = \context_system::instance();
if (!has_capability('moodle/site:sendmessage', $systemcontext, $userid)) {
return false;
}
if (!self::is_user... | [
"public",
"static",
"function",
"can_send_message_to_conversation",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"$",
"systemcontext",
"=",
"\\",
"context_system",
"::",
"instance",
"(",
")",
... | Determines if a user is permitted to send a message to a given conversation.
If no sender is provided then it defaults to the logged in user.
@param int $userid the id of the user on which the checks will be applied.
@param int $conversationid the id of the conversation we wish to check.
@return bool true if the user ... | [
"Determines",
"if",
"a",
"user",
"is",
"permitted",
"to",
"send",
"a",
"message",
"to",
"a",
"given",
"conversation",
".",
"If",
"no",
"sender",
"is",
"provided",
"then",
"it",
"defaults",
"to",
"the",
"logged",
"in",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L1869-L1899 |
213,354 | moodle/moodle | message/classes/api.php | api.is_user_non_contact_blocked | public static function is_user_non_contact_blocked($recipient, $sender = null) {
debugging('\core_message\api::is_user_non_contact_blocked() is deprecated', DEBUG_DEVELOPER);
global $USER, $CFG;
if (is_null($sender)) {
// The message is from the logged in user, unless otherwise spe... | php | public static function is_user_non_contact_blocked($recipient, $sender = null) {
debugging('\core_message\api::is_user_non_contact_blocked() is deprecated', DEBUG_DEVELOPER);
global $USER, $CFG;
if (is_null($sender)) {
// The message is from the logged in user, unless otherwise spe... | [
"public",
"static",
"function",
"is_user_non_contact_blocked",
"(",
"$",
"recipient",
",",
"$",
"sender",
"=",
"null",
")",
"{",
"debugging",
"(",
"'\\core_message\\api::is_user_non_contact_blocked() is deprecated'",
",",
"DEBUG_DEVELOPER",
")",
";",
"global",
"$",
"USE... | Checks if the recipient is allowing messages from users that aren't a
contact. If not then it checks to make sure the sender is in the
recipient's contacts.
@deprecated since 3.6
@param \stdClass $recipient The user object.
@param \stdClass|null $sender The user object.
@return bool true if $sender is blocked, false o... | [
"Checks",
"if",
"the",
"recipient",
"is",
"allowing",
"messages",
"from",
"users",
"that",
"aren",
"t",
"a",
"contact",
".",
"If",
"not",
"then",
"it",
"checks",
"to",
"make",
"sure",
"the",
"sender",
"is",
"in",
"the",
"recipient",
"s",
"contacts",
"."
... | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2035-L2066 |
213,355 | moodle/moodle | message/classes/api.php | api.is_user_blocked | public static function is_user_blocked($recipientid, $senderid = null) {
debugging('\core_message\api::is_user_blocked is deprecated and should not be used.',
DEBUG_DEVELOPER);
global $USER;
if (is_null($senderid)) {
// The message is from the logged in user, unless oth... | php | public static function is_user_blocked($recipientid, $senderid = null) {
debugging('\core_message\api::is_user_blocked is deprecated and should not be used.',
DEBUG_DEVELOPER);
global $USER;
if (is_null($senderid)) {
// The message is from the logged in user, unless oth... | [
"public",
"static",
"function",
"is_user_blocked",
"(",
"$",
"recipientid",
",",
"$",
"senderid",
"=",
"null",
")",
"{",
"debugging",
"(",
"'\\core_message\\api::is_user_blocked is deprecated and should not be used.'",
",",
"DEBUG_DEVELOPER",
")",
";",
"global",
"$",
"U... | Checks if the recipient has specifically blocked the sending user.
Note: This function will always return false if the sender has the
readallmessages capability at the system context level.
@deprecated since 3.6
@param int $recipientid User ID of the recipient.
@param int $senderid User ID of the sender.
@return bool... | [
"Checks",
"if",
"the",
"recipient",
"has",
"specifically",
"blocked",
"the",
"sending",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2079-L2100 |
213,356 | moodle/moodle | message/classes/api.php | api.get_message_processor | public static function get_message_processor($name, $ready = false) {
global $DB, $CFG;
$processor = $DB->get_record('message_processors', array('name' => $name));
if (empty($processor)) {
// Processor not found, return.
return array();
}
$processor = se... | php | public static function get_message_processor($name, $ready = false) {
global $DB, $CFG;
$processor = $DB->get_record('message_processors', array('name' => $name));
if (empty($processor)) {
// Processor not found, return.
return array();
}
$processor = se... | [
"public",
"static",
"function",
"get_message_processor",
"(",
"$",
"name",
",",
"$",
"ready",
"=",
"false",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"$",
"processor",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_processors'",
",",
"arra... | Get specified message processor, validate corresponding plugin existence and
system configuration.
@param string $name Name of the processor.
@param bool $ready only return ready-to-use processors.
@return mixed $processor if processor present else empty array.
@since Moodle 3.2 | [
"Get",
"specified",
"message",
"processor",
"validate",
"corresponding",
"plugin",
"existence",
"and",
"system",
"configuration",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2111-L2130 |
213,357 | moodle/moodle | message/classes/api.php | api.update_processor_status | public static function update_processor_status($processor, $enabled) {
global $DB;
$cache = \cache::make('core', 'message_processors_enabled');
$cache->delete($processor->name);
return $DB->set_field('message_processors', 'enabled', $enabled, array('id' => $processor->id));
} | php | public static function update_processor_status($processor, $enabled) {
global $DB;
$cache = \cache::make('core', 'message_processors_enabled');
$cache->delete($processor->name);
return $DB->set_field('message_processors', 'enabled', $enabled, array('id' => $processor->id));
} | [
"public",
"static",
"function",
"update_processor_status",
"(",
"$",
"processor",
",",
"$",
"enabled",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"cache",
"=",
"\\",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'message_processors_enabled'",
")",
";",
"$",
"c... | Set status of a processor.
@param \stdClass $processor processor record.
@param 0|1 $enabled 0 or 1 to set the processor status.
@return bool
@since Moodle 3.2 | [
"Set",
"status",
"of",
"a",
"processor",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2165-L2170 |
213,358 | moodle/moodle | message/classes/api.php | api.mark_message_as_read | public static function mark_message_as_read($userid, $message, $timeread = null) {
global $DB;
if (is_null($timeread)) {
$timeread = time();
}
$mua = new \stdClass();
$mua->userid = $userid;
$mua->messageid = $message->id;
$mua->action = self::MESSAG... | php | public static function mark_message_as_read($userid, $message, $timeread = null) {
global $DB;
if (is_null($timeread)) {
$timeread = time();
}
$mua = new \stdClass();
$mua->userid = $userid;
$mua->messageid = $message->id;
$mua->action = self::MESSAG... | [
"public",
"static",
"function",
"mark_message_as_read",
"(",
"$",
"userid",
",",
"$",
"message",
",",
"$",
"timeread",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"is_null",
"(",
"$",
"timeread",
")",
")",
"{",
"$",
"timeread",
"=",
"... | Mark a single message as read.
@param int $userid The user id who marked the message as read
@param \stdClass $message The message
@param int|null $timeread The time the message was marked as read, if null will default to time() | [
"Mark",
"a",
"single",
"message",
"as",
"read",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2237-L2269 |
213,359 | moodle/moodle | message/classes/api.php | api.can_delete_message | public static function can_delete_message($userid, $messageid) {
global $DB, $USER;
$systemcontext = \context_system::instance();
$conversationid = $DB->get_field('messages', 'conversationid', ['id' => $messageid], MUST_EXIST);
if (has_capability('moodle/site:deleteanymessage', $syste... | php | public static function can_delete_message($userid, $messageid) {
global $DB, $USER;
$systemcontext = \context_system::instance();
$conversationid = $DB->get_field('messages', 'conversationid', ['id' => $messageid], MUST_EXIST);
if (has_capability('moodle/site:deleteanymessage', $syste... | [
"public",
"static",
"function",
"can_delete_message",
"(",
"$",
"userid",
",",
"$",
"messageid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"systemcontext",
"=",
"\\",
"context_system",
"::",
"instance",
"(",
")",
";",
"$",
"conversationid"... | Checks if a user can delete a message.
@param int $userid the user id of who we want to delete the message for (this may be done by the admin
but will still seem as if it was by the user)
@param int $messageid The message id
@return bool Returns true if a user can delete the message, false otherwise. | [
"Checks",
"if",
"a",
"user",
"can",
"delete",
"a",
"message",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2308-L2329 |
213,360 | moodle/moodle | message/classes/api.php | api.get_conversation_between_users | public static function get_conversation_between_users(array $userids) {
global $DB;
$conversations = self::get_individual_conversations_between_users([$userids]);
$conversation = $conversations[0];
if ($conversation) {
return $conversation->id;
}
return fal... | php | public static function get_conversation_between_users(array $userids) {
global $DB;
$conversations = self::get_individual_conversations_between_users([$userids]);
$conversation = $conversations[0];
if ($conversation) {
return $conversation->id;
}
return fal... | [
"public",
"static",
"function",
"get_conversation_between_users",
"(",
"array",
"$",
"userids",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conversations",
"=",
"self",
"::",
"get_individual_conversations_between_users",
"(",
"[",
"$",
"userids",
"]",
")",
";",
"$... | Returns the conversation between two users.
@param array $userids
@return int|bool The id of the conversation, false if not found | [
"Returns",
"the",
"conversation",
"between",
"two",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2374-L2385 |
213,361 | moodle/moodle | message/classes/api.php | api.get_individual_conversations_between_users | public static function get_individual_conversations_between_users(array $useridsets) : array {
global $DB;
if (empty($useridsets)) {
return [];
}
$hashes = array_map(function($userids) {
return helper::get_conversation_hash($userids);
}, $useridsets);
... | php | public static function get_individual_conversations_between_users(array $useridsets) : array {
global $DB;
if (empty($useridsets)) {
return [];
}
$hashes = array_map(function($userids) {
return helper::get_conversation_hash($userids);
}, $useridsets);
... | [
"public",
"static",
"function",
"get_individual_conversations_between_users",
"(",
"array",
"$",
"useridsets",
")",
":",
"array",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"useridsets",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
... | Returns the conversations between sets of users.
The returned array of results will be in the same order as the requested
arguments, null will be returned if there is no conversation for that user
pair.
For example:
If we have 6 users with ids 1, 2, 3, 4, 5, 6 where only 2 conversations
exist. One between 1 and 2 and... | [
"Returns",
"the",
"conversations",
"between",
"sets",
"of",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2409-L2434 |
213,362 | moodle/moodle | message/classes/api.php | api.get_self_conversation | public static function get_self_conversation(int $userid) {
global $DB;
$conditions = [
'type' => self::MESSAGE_CONVERSATION_TYPE_SELF,
'convhash' => helper::get_conversation_hash([$userid])
];
return $DB->get_record('message_conversations', $conditions);
} | php | public static function get_self_conversation(int $userid) {
global $DB;
$conditions = [
'type' => self::MESSAGE_CONVERSATION_TYPE_SELF,
'convhash' => helper::get_conversation_hash([$userid])
];
return $DB->get_record('message_conversations', $conditions);
} | [
"public",
"static",
"function",
"get_self_conversation",
"(",
"int",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conditions",
"=",
"[",
"'type'",
"=>",
"self",
"::",
"MESSAGE_CONVERSATION_TYPE_SELF",
",",
"'convhash'",
"=>",
"helper",
"::",
"get_c... | Returns the self conversation for a user.
@param int $userid The user id to get the self-conversations
@return \stdClass|false The self-conversation object or false if it doesn't exist
@since Moodle 3.7 | [
"Returns",
"the",
"self",
"conversation",
"for",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2443-L2451 |
213,363 | moodle/moodle | message/classes/api.php | api.create_conversation_between_users | public static function create_conversation_between_users(array $userids) {
debugging('\core_message\api::create_conversation_between_users is deprecated, please use ' .
'\core_message\api::create_conversation instead.', DEBUG_DEVELOPER);
// This method was always used for individual convers... | php | public static function create_conversation_between_users(array $userids) {
debugging('\core_message\api::create_conversation_between_users is deprecated, please use ' .
'\core_message\api::create_conversation instead.', DEBUG_DEVELOPER);
// This method was always used for individual convers... | [
"public",
"static",
"function",
"create_conversation_between_users",
"(",
"array",
"$",
"userids",
")",
"{",
"debugging",
"(",
"'\\core_message\\api::create_conversation_between_users is deprecated, please use '",
".",
"'\\core_message\\api::create_conversation instead.'",
",",
"DEBU... | Creates a conversation between two users.
@deprecated since 3.6
@param array $userids
@return int The id of the conversation | [
"Creates",
"a",
"conversation",
"between",
"two",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2460-L2468 |
213,364 | moodle/moodle | message/classes/api.php | api.create_conversation | public static function create_conversation(int $type, array $userids, string $name = null,
int $enabled = self::MESSAGE_CONVERSATION_ENABLED, string $component = null,
string $itemtype = null, int $itemid = null, int $contextid = null) {
global $DB;
$validtypes = [
... | php | public static function create_conversation(int $type, array $userids, string $name = null,
int $enabled = self::MESSAGE_CONVERSATION_ENABLED, string $component = null,
string $itemtype = null, int $itemid = null, int $contextid = null) {
global $DB;
$validtypes = [
... | [
"public",
"static",
"function",
"create_conversation",
"(",
"int",
"$",
"type",
",",
"array",
"$",
"userids",
",",
"string",
"$",
"name",
"=",
"null",
",",
"int",
"$",
"enabled",
"=",
"self",
"::",
"MESSAGE_CONVERSATION_ENABLED",
",",
"string",
"$",
"compone... | Creates a conversation with selected users and messages.
@param int $type The type of conversation
@param int[] $userids The array of users to add to the conversation
@param string|null $name The name of the conversation
@param int $enabled Determines if the conversation is created enabled or disabled
@param string|nu... | [
"Creates",
"a",
"conversation",
"with",
"selected",
"users",
"and",
"messages",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2483-L2544 |
213,365 | moodle/moodle | message/classes/api.php | api.can_create_group_conversation | public static function can_create_group_conversation(int $userid, \context $context) : bool {
global $CFG;
// If we can't message at all, then we can't create a conversation.
if (empty($CFG->messaging)) {
return false;
}
// We need to check they have the capability ... | php | public static function can_create_group_conversation(int $userid, \context $context) : bool {
global $CFG;
// If we can't message at all, then we can't create a conversation.
if (empty($CFG->messaging)) {
return false;
}
// We need to check they have the capability ... | [
"public",
"static",
"function",
"can_create_group_conversation",
"(",
"int",
"$",
"userid",
",",
"\\",
"context",
"$",
"context",
")",
":",
"bool",
"{",
"global",
"$",
"CFG",
";",
"// If we can't message at all, then we can't create a conversation.",
"if",
"(",
"empty... | Checks if a user can create a group conversation.
@param int $userid The id of the user attempting to create the conversation
@param \context $context The context they are creating the conversation from, most likely course context
@return bool | [
"Checks",
"if",
"a",
"user",
"can",
"create",
"a",
"group",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2553-L2563 |
213,366 | moodle/moodle | message/classes/api.php | api.can_create_contact | public static function can_create_contact(int $userid, int $requesteduserid) : bool {
global $CFG;
// If we can't message at all, then we can't create a contact.
if (empty($CFG->messaging)) {
return false;
}
// If we can message anyone on the site then we can create... | php | public static function can_create_contact(int $userid, int $requesteduserid) : bool {
global $CFG;
// If we can't message at all, then we can't create a contact.
if (empty($CFG->messaging)) {
return false;
}
// If we can message anyone on the site then we can create... | [
"public",
"static",
"function",
"can_create_contact",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
":",
"bool",
"{",
"global",
"$",
"CFG",
";",
"// If we can't message at all, then we can't create a contact.",
"if",
"(",
"empty",
"(",
"$",
"... | Checks if a user can create a contact request.
@param int $userid The id of the user who is creating the contact request
@param int $requesteduserid The id of the user being requested
@return bool | [
"Checks",
"if",
"a",
"user",
"can",
"create",
"a",
"contact",
"request",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2572-L2587 |
213,367 | moodle/moodle | message/classes/api.php | api.create_contact_request | public static function create_contact_request(int $userid, int $requesteduserid) : \stdClass {
global $DB, $PAGE;
$request = new \stdClass();
$request->userid = $userid;
$request->requesteduserid = $requesteduserid;
$request->timecreated = time();
$request->id = $DB->in... | php | public static function create_contact_request(int $userid, int $requesteduserid) : \stdClass {
global $DB, $PAGE;
$request = new \stdClass();
$request->userid = $userid;
$request->requesteduserid = $requesteduserid;
$request->timecreated = time();
$request->id = $DB->in... | [
"public",
"static",
"function",
"create_contact_request",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
":",
"\\",
"stdClass",
"{",
"global",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"request",
"=",
"new",
"\\",
"stdClass",
"(",
")",
... | Handles creating a contact request.
@param int $userid The id of the user who is creating the contact request
@param int $requesteduserid The id of the user being requested
@return \stdClass the request | [
"Handles",
"creating",
"a",
"contact",
"request",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2596-L2641 |
213,368 | moodle/moodle | message/classes/api.php | api.confirm_contact_request | public static function confirm_contact_request(int $userid, int $requesteduserid) {
global $DB;
if ($request = $DB->get_record('message_contact_requests', ['userid' => $userid,
'requesteduserid' => $requesteduserid])) {
self::add_contact($userid, $requesteduserid);
... | php | public static function confirm_contact_request(int $userid, int $requesteduserid) {
global $DB;
if ($request = $DB->get_record('message_contact_requests', ['userid' => $userid,
'requesteduserid' => $requesteduserid])) {
self::add_contact($userid, $requesteduserid);
... | [
"public",
"static",
"function",
"confirm_contact_request",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"request",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_contact_requests'",
",... | Handles confirming a contact request.
@param int $userid The id of the user who created the contact request
@param int $requesteduserid The id of the user confirming the request | [
"Handles",
"confirming",
"a",
"contact",
"request",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2650-L2659 |
213,369 | moodle/moodle | message/classes/api.php | api.decline_contact_request | public static function decline_contact_request(int $userid, int $requesteduserid) {
global $DB;
if ($request = $DB->get_record('message_contact_requests', ['userid' => $userid,
'requesteduserid' => $requesteduserid])) {
$DB->delete_records('message_contact_requests', ['id' =... | php | public static function decline_contact_request(int $userid, int $requesteduserid) {
global $DB;
if ($request = $DB->get_record('message_contact_requests', ['userid' => $userid,
'requesteduserid' => $requesteduserid])) {
$DB->delete_records('message_contact_requests', ['id' =... | [
"public",
"static",
"function",
"decline_contact_request",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"request",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_contact_requests'",
",... | Handles declining a contact request.
@param int $userid The id of the user who created the contact request
@param int $requesteduserid The id of the user declining the request | [
"Handles",
"declining",
"a",
"contact",
"request",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2667-L2674 |
213,370 | moodle/moodle | message/classes/api.php | api.add_contact | public static function add_contact(int $userid, int $contactid) {
global $DB;
$messagecontact = new \stdClass();
$messagecontact->userid = $userid;
$messagecontact->contactid = $contactid;
$messagecontact->timecreated = time();
$messagecontact->id = $DB->insert_record('m... | php | public static function add_contact(int $userid, int $contactid) {
global $DB;
$messagecontact = new \stdClass();
$messagecontact->userid = $userid;
$messagecontact->contactid = $contactid;
$messagecontact->timecreated = time();
$messagecontact->id = $DB->insert_record('m... | [
"public",
"static",
"function",
"add_contact",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"contactid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"messagecontact",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"messagecontact",
"->",
"userid",
"=",
... | Handles adding a contact.
@param int $userid The id of the user who requested to be a contact
@param int $contactid The id of the contact | [
"Handles",
"adding",
"a",
"contact",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2731-L2749 |
213,371 | moodle/moodle | message/classes/api.php | api.remove_contact | public static function remove_contact(int $userid, int $contactid) {
global $DB;
if ($contact = self::get_contact($userid, $contactid)) {
$DB->delete_records('message_contacts', ['id' => $contact->id]);
$event = \core\event\message_contact_removed::create(array(
... | php | public static function remove_contact(int $userid, int $contactid) {
global $DB;
if ($contact = self::get_contact($userid, $contactid)) {
$DB->delete_records('message_contacts', ['id' => $contact->id]);
$event = \core\event\message_contact_removed::create(array(
... | [
"public",
"static",
"function",
"remove_contact",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"contactid",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"contact",
"=",
"self",
"::",
"get_contact",
"(",
"$",
"userid",
",",
"$",
"contactid",
")",
... | Handles removing a contact.
@param int $userid The id of the user who is removing a user as a contact
@param int $contactid The id of the user to be removed as a contact | [
"Handles",
"removing",
"a",
"contact",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2757-L2772 |
213,372 | moodle/moodle | message/classes/api.php | api.block_user | public static function block_user(int $userid, int $usertoblockid) {
global $DB;
$blocked = new \stdClass();
$blocked->userid = $userid;
$blocked->blockeduserid = $usertoblockid;
$blocked->timecreated = time();
$blocked->id = $DB->insert_record('message_users_blocked', $... | php | public static function block_user(int $userid, int $usertoblockid) {
global $DB;
$blocked = new \stdClass();
$blocked->userid = $userid;
$blocked->blockeduserid = $usertoblockid;
$blocked->timecreated = time();
$blocked->id = $DB->insert_record('message_users_blocked', $... | [
"public",
"static",
"function",
"block_user",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"usertoblockid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"blocked",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"blocked",
"->",
"userid",
"=",
"$",
"use... | Handles blocking a user.
@param int $userid The id of the user who is blocking
@param int $usertoblockid The id of the user being blocked | [
"Handles",
"blocking",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2780-L2798 |
213,373 | moodle/moodle | message/classes/api.php | api.unblock_user | public static function unblock_user(int $userid, int $usertounblockid) {
global $DB;
if ($blockeduser = $DB->get_record('message_users_blocked',
['userid' => $userid, 'blockeduserid' => $usertounblockid])) {
$DB->delete_records('message_users_blocked', ['id' => $blockeduser-... | php | public static function unblock_user(int $userid, int $usertounblockid) {
global $DB;
if ($blockeduser = $DB->get_record('message_users_blocked',
['userid' => $userid, 'blockeduserid' => $usertounblockid])) {
$DB->delete_records('message_users_blocked', ['id' => $blockeduser-... | [
"public",
"static",
"function",
"unblock_user",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"usertounblockid",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"blockeduser",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_users_blocked'",
",",
"[",
... | Handles unblocking a user.
@param int $userid The id of the user who is unblocking
@param int $usertounblockid The id of the user being unblocked | [
"Handles",
"unblocking",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2806-L2823 |
213,374 | moodle/moodle | message/classes/api.php | api.is_contact | public static function is_contact(int $userid, int $contactid) : bool {
global $DB;
$sql = "SELECT id
FROM {message_contacts} mc
WHERE (mc.userid = ? AND mc.contactid = ?)
OR (mc.userid = ? AND mc.contactid = ?)";
return $DB->record_exists_... | php | public static function is_contact(int $userid, int $contactid) : bool {
global $DB;
$sql = "SELECT id
FROM {message_contacts} mc
WHERE (mc.userid = ? AND mc.contactid = ?)
OR (mc.userid = ? AND mc.contactid = ?)";
return $DB->record_exists_... | [
"public",
"static",
"function",
"is_contact",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"contactid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT id\n FROM {message_contacts} mc\n WHERE (mc.userid = ? AND... | Checks if users are already contacts.
@param int $userid The id of one of the users
@param int $contactid The id of the other user
@return bool Returns true if they are a contact, false otherwise | [
"Checks",
"if",
"users",
"are",
"already",
"contacts",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2832-L2840 |
213,375 | moodle/moodle | message/classes/api.php | api.get_contact | public static function get_contact(int $userid, int $contactid) {
global $DB;
$sql = "SELECT mc.*
FROM {message_contacts} mc
WHERE (mc.userid = ? AND mc.contactid = ?)
OR (mc.userid = ? AND mc.contactid = ?)";
return $DB->get_record_sql($sq... | php | public static function get_contact(int $userid, int $contactid) {
global $DB;
$sql = "SELECT mc.*
FROM {message_contacts} mc
WHERE (mc.userid = ? AND mc.contactid = ?)
OR (mc.userid = ? AND mc.contactid = ?)";
return $DB->get_record_sql($sq... | [
"public",
"static",
"function",
"get_contact",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"contactid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT mc.*\n FROM {message_contacts} mc\n WHERE (mc.userid = ? AND mc.contactid ... | Returns the row in the database table message_contacts that represents the contact between two people.
@param int $userid The id of one of the users
@param int $contactid The id of the other user
@return mixed A fieldset object containing the record, false otherwise | [
"Returns",
"the",
"row",
"in",
"the",
"database",
"table",
"message_contacts",
"that",
"represents",
"the",
"contact",
"between",
"two",
"people",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2849-L2857 |
213,376 | moodle/moodle | message/classes/api.php | api.is_blocked | public static function is_blocked(int $userid, int $blockeduserid) : bool {
global $DB;
return $DB->record_exists('message_users_blocked', ['userid' => $userid, 'blockeduserid' => $blockeduserid]);
} | php | public static function is_blocked(int $userid, int $blockeduserid) : bool {
global $DB;
return $DB->record_exists('message_users_blocked', ['userid' => $userid, 'blockeduserid' => $blockeduserid]);
} | [
"public",
"static",
"function",
"is_blocked",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"blockeduserid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"return",
"$",
"DB",
"->",
"record_exists",
"(",
"'message_users_blocked'",
",",
"[",
"'userid'",
"=... | Checks if a user is already blocked.
@param int $userid
@param int $blockeduserid
@return bool Returns true if they are a blocked, false otherwise | [
"Checks",
"if",
"a",
"user",
"is",
"already",
"blocked",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2866-L2870 |
213,377 | moodle/moodle | message/classes/api.php | api.get_contact_requests_between_users | public static function get_contact_requests_between_users(int $userid, int $requesteduserid) : array {
global $DB;
$sql = "SELECT *
FROM {message_contact_requests} mcr
WHERE (mcr.userid = ? AND mcr.requesteduserid = ?)
OR (mcr.userid = ? AND mcr.re... | php | public static function get_contact_requests_between_users(int $userid, int $requesteduserid) : array {
global $DB;
$sql = "SELECT *
FROM {message_contact_requests} mcr
WHERE (mcr.userid = ? AND mcr.requesteduserid = ?)
OR (mcr.userid = ? AND mcr.re... | [
"public",
"static",
"function",
"get_contact_requests_between_users",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
":",
"array",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT *\n FROM {message_contact_requests} mcr\n ... | Get contact requests between users.
@param int $userid The id of the user who is creating the contact request
@param int $requesteduserid The id of the user being requested
@return \stdClass[] | [
"Get",
"contact",
"requests",
"between",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2879-L2887 |
213,378 | moodle/moodle | message/classes/api.php | api.does_contact_request_exist | public static function does_contact_request_exist(int $userid, int $requesteduserid) : bool {
global $DB;
$sql = "SELECT id
FROM {message_contact_requests} mcr
WHERE (mcr.userid = ? AND mcr.requesteduserid = ?)
OR (mcr.userid = ? AND mcr.requestedu... | php | public static function does_contact_request_exist(int $userid, int $requesteduserid) : bool {
global $DB;
$sql = "SELECT id
FROM {message_contact_requests} mcr
WHERE (mcr.userid = ? AND mcr.requesteduserid = ?)
OR (mcr.userid = ? AND mcr.requestedu... | [
"public",
"static",
"function",
"does_contact_request_exist",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"requesteduserid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT id\n FROM {message_contact_requests} mcr\n ... | Checks if a contact request already exists between users.
@param int $userid The id of the user who is creating the contact request
@param int $requesteduserid The id of the user being requested
@return bool Returns true if a contact request exists, false otherwise | [
"Checks",
"if",
"a",
"contact",
"request",
"already",
"exists",
"between",
"users",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2896-L2904 |
213,379 | moodle/moodle | message/classes/api.php | api.is_user_in_conversation | public static function is_user_in_conversation(int $userid, int $conversationid) : bool {
global $DB;
return $DB->record_exists('message_conversation_members', ['conversationid' => $conversationid,
'userid' => $userid]);
} | php | public static function is_user_in_conversation(int $userid, int $conversationid) : bool {
global $DB;
return $DB->record_exists('message_conversation_members', ['conversationid' => $conversationid,
'userid' => $userid]);
} | [
"public",
"static",
"function",
"is_user_in_conversation",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"return",
"$",
"DB",
"->",
"record_exists",
"(",
"'message_conversation_members'",
",",
"[... | Checks if a user is already in a conversation.
@param int $userid The id of the user we want to check if they are in a group
@param int $conversationid The id of the conversation
@return bool Returns true if a contact request exists, false otherwise | [
"Checks",
"if",
"a",
"user",
"is",
"already",
"in",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2913-L2918 |
213,380 | moodle/moodle | message/classes/api.php | api.can_contact_user | protected static function can_contact_user(int $recipientid, int $senderid) : bool {
if (has_capability('moodle/site:messageanyuser', \context_system::instance(), $senderid) ||
$recipientid == $senderid) {
// The sender has the ability to contact any user across the entire site or themse... | php | protected static function can_contact_user(int $recipientid, int $senderid) : bool {
if (has_capability('moodle/site:messageanyuser', \context_system::instance(), $senderid) ||
$recipientid == $senderid) {
// The sender has the ability to contact any user across the entire site or themse... | [
"protected",
"static",
"function",
"can_contact_user",
"(",
"int",
"$",
"recipientid",
",",
"int",
"$",
"senderid",
")",
":",
"bool",
"{",
"if",
"(",
"has_capability",
"(",
"'moodle/site:messageanyuser'",
",",
"\\",
"context_system",
"::",
"instance",
"(",
")",
... | Checks if the sender can message the recipient.
@param int $recipientid
@param int $senderid
@return bool true if recipient hasn't blocked sender and sender can contact to recipient, false otherwise. | [
"Checks",
"if",
"the",
"sender",
"can",
"message",
"the",
"recipient",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L2927-L2990 |
213,381 | moodle/moodle | message/classes/api.php | api.add_members_to_conversation | public static function add_members_to_conversation(array $userids, int $convid) {
global $DB;
$conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);
// We can only add members to a group conversation.
if ($conversation->type != self::MESSAGE_CONVE... | php | public static function add_members_to_conversation(array $userids, int $convid) {
global $DB;
$conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);
// We can only add members to a group conversation.
if ($conversation->type != self::MESSAGE_CONVE... | [
"public",
"static",
"function",
"add_members_to_conversation",
"(",
"array",
"$",
"userids",
",",
"int",
"$",
"convid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conversation",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_conversations'",
",",
"[",
"'i... | Add some new members to an existing conversation.
@param array $userids User ids array to add as members.
@param int $convid The conversation id. Must exists.
@throws \dml_missing_record_exception If convid conversation doesn't exist
@throws \dml_exception If there is a database error
@throws \moodle_exception If tryi... | [
"Add",
"some",
"new",
"members",
"to",
"an",
"existing",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3001-L3032 |
213,382 | moodle/moodle | message/classes/api.php | api.remove_members_from_conversation | public static function remove_members_from_conversation(array $userids, int $convid) {
global $DB;
$conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);
if ($conversation->type != self::MESSAGE_CONVERSATION_TYPE_GROUP) {
throw new \moodle_exc... | php | public static function remove_members_from_conversation(array $userids, int $convid) {
global $DB;
$conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);
if ($conversation->type != self::MESSAGE_CONVERSATION_TYPE_GROUP) {
throw new \moodle_exc... | [
"public",
"static",
"function",
"remove_members_from_conversation",
"(",
"array",
"$",
"userids",
",",
"int",
"$",
"convid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conversation",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_conversations'",
",",
"[",
... | Remove some members from an existing conversation.
@param array $userids The user ids to remove from conversation members.
@param int $convid The conversation id. Must exists.
@throws \dml_exception
@throws \moodle_exception If trying to remove a member(s) from a non-group conversation | [
"Remove",
"some",
"members",
"from",
"an",
"existing",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3042-L3056 |
213,383 | moodle/moodle | message/classes/api.php | api.is_conversation_area_enabled | public static function is_conversation_area_enabled(string $component, string $itemtype, int $itemid, int $contextid) : bool {
global $DB;
return $DB->record_exists('message_conversations',
[
'itemid' => $itemid,
'contextid' => $contextid,
'co... | php | public static function is_conversation_area_enabled(string $component, string $itemtype, int $itemid, int $contextid) : bool {
global $DB;
return $DB->record_exists('message_conversations',
[
'itemid' => $itemid,
'contextid' => $contextid,
'co... | [
"public",
"static",
"function",
"is_conversation_area_enabled",
"(",
"string",
"$",
"component",
",",
"string",
"$",
"itemtype",
",",
"int",
"$",
"itemid",
",",
"int",
"$",
"contextid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"return",
"$",
"DB",
... | Checks whether or not a conversation area is enabled.
@param string $component Defines the Moodle component which the area was added to.
@param string $itemtype Defines the type of the component.
@param int $itemid The id of the component.
@param int $contextid The id of the context.
@return bool Returns if a conversa... | [
"Checks",
"whether",
"or",
"not",
"a",
"conversation",
"area",
"is",
"enabled",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3080-L3092 |
213,384 | moodle/moodle | message/classes/api.php | api.get_conversation_by_area | public static function get_conversation_by_area(string $component, string $itemtype, int $itemid, int $contextid) {
global $DB;
return $DB->get_record('message_conversations',
[
'itemid' => $itemid,
'contextid' => $contextid,
'component' => $c... | php | public static function get_conversation_by_area(string $component, string $itemtype, int $itemid, int $contextid) {
global $DB;
return $DB->get_record('message_conversations',
[
'itemid' => $itemid,
'contextid' => $contextid,
'component' => $c... | [
"public",
"static",
"function",
"get_conversation_by_area",
"(",
"string",
"$",
"component",
",",
"string",
"$",
"itemtype",
",",
"int",
"$",
"itemid",
",",
"int",
"$",
"contextid",
")",
"{",
"global",
"$",
"DB",
";",
"return",
"$",
"DB",
"->",
"get_record... | Get conversation by area.
@param string $component Defines the Moodle component which the area was added to.
@param string $itemtype Defines the type of the component.
@param int $itemid The id of the component.
@param int $contextid The id of the context.
@return \stdClass | [
"Get",
"conversation",
"by",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3103-L3114 |
213,385 | moodle/moodle | message/classes/api.php | api.enable_conversation | public static function enable_conversation(int $conversationid) {
global $DB;
$conversation = new \stdClass();
$conversation->id = $conversationid;
$conversation->enabled = self::MESSAGE_CONVERSATION_ENABLED;
$conversation->timemodified = time();
$DB->update_record('mess... | php | public static function enable_conversation(int $conversationid) {
global $DB;
$conversation = new \stdClass();
$conversation->id = $conversationid;
$conversation->enabled = self::MESSAGE_CONVERSATION_ENABLED;
$conversation->timemodified = time();
$DB->update_record('mess... | [
"public",
"static",
"function",
"enable_conversation",
"(",
"int",
"$",
"conversationid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conversation",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"conversation",
"->",
"id",
"=",
"$",
"conversationid",
";"... | Enable a conversation.
@param int $conversationid The id of the conversation.
@return void | [
"Enable",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3122-L3130 |
213,386 | moodle/moodle | message/classes/api.php | api.disable_conversation | public static function disable_conversation(int $conversationid) {
global $DB;
$conversation = new \stdClass();
$conversation->id = $conversationid;
$conversation->enabled = self::MESSAGE_CONVERSATION_DISABLED;
$conversation->timemodified = time();
$DB->update_record('me... | php | public static function disable_conversation(int $conversationid) {
global $DB;
$conversation = new \stdClass();
$conversation->id = $conversationid;
$conversation->enabled = self::MESSAGE_CONVERSATION_DISABLED;
$conversation->timemodified = time();
$DB->update_record('me... | [
"public",
"static",
"function",
"disable_conversation",
"(",
"int",
"$",
"conversationid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"conversation",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"conversation",
"->",
"id",
"=",
"$",
"conversationid",
";... | Disable a conversation.
@param int $conversationid The id of the conversation.
@return void | [
"Disable",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3138-L3146 |
213,387 | moodle/moodle | message/classes/api.php | api.update_conversation_name | public static function update_conversation_name(int $conversationid, string $name) {
global $DB;
if ($conversation = $DB->get_record('message_conversations', array('id' => $conversationid))) {
if ($name <> $conversation->name) {
$conversation->name = $name;
$... | php | public static function update_conversation_name(int $conversationid, string $name) {
global $DB;
if ($conversation = $DB->get_record('message_conversations', array('id' => $conversationid))) {
if ($name <> $conversation->name) {
$conversation->name = $name;
$... | [
"public",
"static",
"function",
"update_conversation_name",
"(",
"int",
"$",
"conversationid",
",",
"string",
"$",
"name",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"conversation",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_conversations'",
... | Update the name of a conversation.
@param int $conversationid The id of a conversation.
@param string $name The main name of the area
@return void | [
"Update",
"the",
"name",
"of",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3155-L3165 |
213,388 | moodle/moodle | message/classes/api.php | api.get_unread_conversation_counts | public static function get_unread_conversation_counts(int $userid) : array {
global $DB;
// Get all conversations the user is in, and check unread.
$unreadcountssql = 'SELECT conv.id, conv.type, indcounts.unreadcount
FROM {message_conversations} conv
... | php | public static function get_unread_conversation_counts(int $userid) : array {
global $DB;
// Get all conversations the user is in, and check unread.
$unreadcountssql = 'SELECT conv.id, conv.type, indcounts.unreadcount
FROM {message_conversations} conv
... | [
"public",
"static",
"function",
"get_unread_conversation_counts",
"(",
"int",
"$",
"userid",
")",
":",
"array",
"{",
"global",
"$",
"DB",
";",
"// Get all conversations the user is in, and check unread.",
"$",
"unreadcountssql",
"=",
"'SELECT conv.id, conv.type, indcounts.unr... | Get the unread counts for all conversations for the user, sorted by type, and including favourites.
@param int $userid the id of the user whose conversations we'll check.
@return array the unread counts for each conversation, indexed by type. | [
"Get",
"the",
"unread",
"counts",
"for",
"all",
"conversations",
"for",
"the",
"user",
"sorted",
"by",
"type",
"and",
"including",
"favourites",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3200-L3247 |
213,389 | moodle/moodle | message/classes/api.php | api.mute_conversation | public static function mute_conversation(int $userid, int $conversationid) : void {
global $DB;
$mutedconversation = new \stdClass();
$mutedconversation->userid = $userid;
$mutedconversation->conversationid = $conversationid;
$mutedconversation->action = self::CONVERSATION_ACTIO... | php | public static function mute_conversation(int $userid, int $conversationid) : void {
global $DB;
$mutedconversation = new \stdClass();
$mutedconversation->userid = $userid;
$mutedconversation->conversationid = $conversationid;
$mutedconversation->action = self::CONVERSATION_ACTIO... | [
"public",
"static",
"function",
"mute_conversation",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"void",
"{",
"global",
"$",
"DB",
";",
"$",
"mutedconversation",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"mutedconversati... | Handles muting a conversation.
@param int $userid The id of the user
@param int $conversationid The id of the conversation | [
"Handles",
"muting",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3255-L3265 |
213,390 | moodle/moodle | message/classes/api.php | api.unmute_conversation | public static function unmute_conversation(int $userid, int $conversationid) : void {
global $DB;
$DB->delete_records('message_conversation_actions',
[
'userid' => $userid,
'conversationid' => $conversationid,
'action' => self::CONVERSATION_AC... | php | public static function unmute_conversation(int $userid, int $conversationid) : void {
global $DB;
$DB->delete_records('message_conversation_actions',
[
'userid' => $userid,
'conversationid' => $conversationid,
'action' => self::CONVERSATION_AC... | [
"public",
"static",
"function",
"unmute_conversation",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"void",
"{",
"global",
"$",
"DB",
";",
"$",
"DB",
"->",
"delete_records",
"(",
"'message_conversation_actions'",
",",
"[",
"'userid'"... | Handles unmuting a conversation.
@param int $userid The id of the user
@param int $conversationid The id of the conversation | [
"Handles",
"unmuting",
"a",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3273-L3283 |
213,391 | moodle/moodle | message/classes/api.php | api.is_conversation_muted | public static function is_conversation_muted(int $userid, int $conversationid) : bool {
global $DB;
return $DB->record_exists('message_conversation_actions',
[
'userid' => $userid,
'conversationid' => $conversationid,
'action' => self::CONVERS... | php | public static function is_conversation_muted(int $userid, int $conversationid) : bool {
global $DB;
return $DB->record_exists('message_conversation_actions',
[
'userid' => $userid,
'conversationid' => $conversationid,
'action' => self::CONVERS... | [
"public",
"static",
"function",
"is_conversation_muted",
"(",
"int",
"$",
"userid",
",",
"int",
"$",
"conversationid",
")",
":",
"bool",
"{",
"global",
"$",
"DB",
";",
"return",
"$",
"DB",
"->",
"record_exists",
"(",
"'message_conversation_actions'",
",",
"[",... | Checks whether a conversation is muted or not.
@param int $userid The id of the user
@param int $conversationid The id of the conversation
@return bool Whether or not the conversation is muted or not | [
"Checks",
"whether",
"a",
"conversation",
"is",
"muted",
"or",
"not",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3292-L3302 |
213,392 | moodle/moodle | message/classes/api.php | api.delete_all_conversation_data | public static function delete_all_conversation_data(int $conversationid) {
global $DB;
$DB->delete_records('message_conversations', ['id' => $conversationid]);
$DB->delete_records('message_conversation_members', ['conversationid' => $conversationid]);
$DB->delete_records('message_conver... | php | public static function delete_all_conversation_data(int $conversationid) {
global $DB;
$DB->delete_records('message_conversations', ['id' => $conversationid]);
$DB->delete_records('message_conversation_members', ['conversationid' => $conversationid]);
$DB->delete_records('message_conver... | [
"public",
"static",
"function",
"delete_all_conversation_data",
"(",
"int",
"$",
"conversationid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"DB",
"->",
"delete_records",
"(",
"'message_conversations'",
",",
"[",
"'id'",
"=>",
"$",
"conversationid",
"]",
")",
"... | Completely removes all related data in the DB for a given conversation.
@param int $conversationid The id of the conversation | [
"Completely",
"removes",
"all",
"related",
"data",
"in",
"the",
"DB",
"for",
"a",
"given",
"conversation",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/classes/api.php#L3309-L3326 |
213,393 | moodle/moodle | admin/tool/monitor/classes/output/managesubs/subs.php | subs.col_unsubscribe | public function col_unsubscribe(\tool_monitor\subscription $sub) {
global $OUTPUT, $CFG;
$deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array('subscriptionid' => $sub->id,
'action' => 'unsubscribe', 'courseid' => $this->courseid, 'sesskey' => sesskey()));
... | php | public function col_unsubscribe(\tool_monitor\subscription $sub) {
global $OUTPUT, $CFG;
$deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array('subscriptionid' => $sub->id,
'action' => 'unsubscribe', 'courseid' => $this->courseid, 'sesskey' => sesskey()));
... | [
"public",
"function",
"col_unsubscribe",
"(",
"\\",
"tool_monitor",
"\\",
"subscription",
"$",
"sub",
")",
"{",
"global",
"$",
"OUTPUT",
",",
"$",
"CFG",
";",
"$",
"deleteurl",
"=",
"new",
"\\",
"moodle_url",
"(",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/adm... | Generate content for unsubscribe column.
@param \tool_monitor\subscription $sub subscription object
@return string html used to display the unsubscribe field. | [
"Generate",
"content",
"for",
"unsubscribe",
"column",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/monitor/classes/output/managesubs/subs.php#L170-L178 |
213,394 | moodle/moodle | lib/lessphp/Exception/Parser.php | Less_Exception_Parser.genMessage | public function genMessage(){
if( $this->currentFile && $this->currentFile['filename'] ){
$this->message .= ' in '.basename($this->currentFile['filename']);
}
if( $this->index !== null ){
$this->getInput();
if( $this->input ){
$line = self::getLineNumber();
$this->message .= ' on line... | php | public function genMessage(){
if( $this->currentFile && $this->currentFile['filename'] ){
$this->message .= ' in '.basename($this->currentFile['filename']);
}
if( $this->index !== null ){
$this->getInput();
if( $this->input ){
$line = self::getLineNumber();
$this->message .= ' on line... | [
"public",
"function",
"genMessage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentFile",
"&&",
"$",
"this",
"->",
"currentFile",
"[",
"'filename'",
"]",
")",
"{",
"$",
"this",
"->",
"message",
".=",
"' in '",
".",
"basename",
"(",
"$",
"this",
... | Converts the exception to string
@return string | [
"Converts",
"the",
"exception",
"to",
"string"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Exception/Parser.php#L69-L93 |
213,395 | moodle/moodle | lib/lessphp/Exception/Parser.php | Less_Exception_Parser.getLineNumber | public function getLineNumber(){
if( $this->index ){
// https://bugs.php.net/bug.php?id=49790
if (ini_get("mbstring.func_overload")) {
return substr_count(substr($this->input, 0, $this->index), "\n") + 1;
} else {
return substr_count($this->input, "\n", 0, $this->index) + 1;
}
}
retur... | php | public function getLineNumber(){
if( $this->index ){
// https://bugs.php.net/bug.php?id=49790
if (ini_get("mbstring.func_overload")) {
return substr_count(substr($this->input, 0, $this->index), "\n") + 1;
} else {
return substr_count($this->input, "\n", 0, $this->index) + 1;
}
}
retur... | [
"public",
"function",
"getLineNumber",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index",
")",
"{",
"// https://bugs.php.net/bug.php?id=49790\r",
"if",
"(",
"ini_get",
"(",
"\"mbstring.func_overload\"",
")",
")",
"{",
"return",
"substr_count",
"(",
"substr",
... | Returns the line number the error was encountered
@return integer | [
"Returns",
"the",
"line",
"number",
"the",
"error",
"was",
"encountered"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Exception/Parser.php#L100-L110 |
213,396 | moodle/moodle | lib/lessphp/Exception/Parser.php | Less_Exception_Parser.getColumn | public function getColumn(){
$part = substr($this->input, 0, $this->index);
$pos = strrpos($part,"\n");
return $this->index - $pos;
} | php | public function getColumn(){
$part = substr($this->input, 0, $this->index);
$pos = strrpos($part,"\n");
return $this->index - $pos;
} | [
"public",
"function",
"getColumn",
"(",
")",
"{",
"$",
"part",
"=",
"substr",
"(",
"$",
"this",
"->",
"input",
",",
"0",
",",
"$",
"this",
"->",
"index",
")",
";",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"part",
",",
"\"\\n\"",
")",
";",
"return",
... | Returns the column the error was encountered
@return integer | [
"Returns",
"the",
"column",
"the",
"error",
"was",
"encountered"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Exception/Parser.php#L118-L123 |
213,397 | moodle/moodle | calendar/classes/local/event/proxies/cm_info_proxy.php | cm_info_proxy.get | public function get($member) {
if ($this->base && property_exists($this->base, $member)) {
return $this->base->{$member};
}
return $this->get_proxied_instance()->{$member};
} | php | public function get($member) {
if ($this->base && property_exists($this->base, $member)) {
return $this->base->{$member};
}
return $this->get_proxied_instance()->{$member};
} | [
"public",
"function",
"get",
"(",
"$",
"member",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"base",
"&&",
"property_exists",
"(",
"$",
"this",
"->",
"base",
",",
"$",
"member",
")",
")",
"{",
"return",
"$",
"this",
"->",
"base",
"->",
"{",
"$",
"mem... | Retrieve a member of the proxied class.
@param string $member The name of the member to retrieve
@return mixed The member. | [
"Retrieve",
"a",
"member",
"of",
"the",
"proxied",
"class",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/calendar/classes/local/event/proxies/cm_info_proxy.php#L64-L70 |
213,398 | moodle/moodle | calendar/classes/local/event/container.php | container.init | private static function init() {
if (empty(self::$eventfactory)) {
self::$actionfactory = new action_factory();
self::$eventmapper = new event_mapper(
// The event mapper we return from here needs to know how to
// make events, so it needs an event factory... | php | private static function init() {
if (empty(self::$eventfactory)) {
self::$actionfactory = new action_factory();
self::$eventmapper = new event_mapper(
// The event mapper we return from here needs to know how to
// make events, so it needs an event factory... | [
"private",
"static",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"eventfactory",
")",
")",
"{",
"self",
"::",
"$",
"actionfactory",
"=",
"new",
"action_factory",
"(",
")",
";",
"self",
"::",
"$",
"eventmapper",
"=",
... | Initialises the dependency graph if it hasn't yet been. | [
"Initialises",
"the",
"dependency",
"graph",
"if",
"it",
"hasn",
"t",
"yet",
"been",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/calendar/classes/local/event/container.php#L92-L197 |
213,399 | moodle/moodle | calendar/classes/local/event/container.php | container.reset_caches | public static function reset_caches() {
self::$requestinguserid = null;
self::$eventfactory = null;
self::$eventmapper = null;
self::$eventvault = null;
self::$actionfactory = null;
self::$eventretrievalstrategy = null;
self::$coursecache = [];
self::$modu... | php | public static function reset_caches() {
self::$requestinguserid = null;
self::$eventfactory = null;
self::$eventmapper = null;
self::$eventvault = null;
self::$actionfactory = null;
self::$eventretrievalstrategy = null;
self::$coursecache = [];
self::$modu... | [
"public",
"static",
"function",
"reset_caches",
"(",
")",
"{",
"self",
"::",
"$",
"requestinguserid",
"=",
"null",
";",
"self",
"::",
"$",
"eventfactory",
"=",
"null",
";",
"self",
"::",
"$",
"eventmapper",
"=",
"null",
";",
"self",
"::",
"$",
"eventvaul... | Reset all static caches, called between tests. | [
"Reset",
"all",
"static",
"caches",
"called",
"between",
"tests",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/calendar/classes/local/event/container.php#L202-L211 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.