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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
217,000
|
moodle/moodle
|
lib/jabber/XMPP/XMLStream.php
|
XMPPHP_XMLStream.processTime
|
public function processTime($timeout=NULL) {
if (is_null($timeout)) {
return $this->__process(NULL);
} else {
return $this->__process($timeout * 1000000);
}
}
|
php
|
public function processTime($timeout=NULL) {
if (is_null($timeout)) {
return $this->__process(NULL);
} else {
return $this->__process($timeout * 1000000);
}
}
|
[
"public",
"function",
"processTime",
"(",
"$",
"timeout",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"timeout",
")",
")",
"{",
"return",
"$",
"this",
"->",
"__process",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"__process",
"(",
"$",
"timeout",
"*",
"1000000",
")",
";",
"}",
"}"
] |
Process until a timeout occurs
@param integer $timeout
@return string
|
[
"Process",
"until",
"a",
"timeout",
"occurs"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/jabber/XMPP/XMLStream.php#L446-L452
|
217,001
|
moodle/moodle
|
lib/jabber/XMPP/XMLStream.php
|
XMPPHP_XMLStream.processUntil
|
public function processUntil($event, $timeout=-1) {
$start = time();
if(!is_array($event)) $event = array($event);
$this->until[] = $event;
end($this->until);
$event_key = key($this->until);
reset($this->until);
$this->until_count[$event_key] = 0;
$updated = '';
while(!$this->disconnected and $this->until_count[$event_key] < 1 and (time() - $start < $timeout or $timeout == -1)) {
$this->__process();
}
if(array_key_exists($event_key, $this->until_payload)) {
$payload = $this->until_payload[$event_key];
unset($this->until_payload[$event_key]);
unset($this->until_count[$event_key]);
unset($this->until[$event_key]);
} else {
$payload = array();
}
return $payload;
}
|
php
|
public function processUntil($event, $timeout=-1) {
$start = time();
if(!is_array($event)) $event = array($event);
$this->until[] = $event;
end($this->until);
$event_key = key($this->until);
reset($this->until);
$this->until_count[$event_key] = 0;
$updated = '';
while(!$this->disconnected and $this->until_count[$event_key] < 1 and (time() - $start < $timeout or $timeout == -1)) {
$this->__process();
}
if(array_key_exists($event_key, $this->until_payload)) {
$payload = $this->until_payload[$event_key];
unset($this->until_payload[$event_key]);
unset($this->until_count[$event_key]);
unset($this->until[$event_key]);
} else {
$payload = array();
}
return $payload;
}
|
[
"public",
"function",
"processUntil",
"(",
"$",
"event",
",",
"$",
"timeout",
"=",
"-",
"1",
")",
"{",
"$",
"start",
"=",
"time",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"event",
")",
")",
"$",
"event",
"=",
"array",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"until",
"[",
"]",
"=",
"$",
"event",
";",
"end",
"(",
"$",
"this",
"->",
"until",
")",
";",
"$",
"event_key",
"=",
"key",
"(",
"$",
"this",
"->",
"until",
")",
";",
"reset",
"(",
"$",
"this",
"->",
"until",
")",
";",
"$",
"this",
"->",
"until_count",
"[",
"$",
"event_key",
"]",
"=",
"0",
";",
"$",
"updated",
"=",
"''",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"disconnected",
"and",
"$",
"this",
"->",
"until_count",
"[",
"$",
"event_key",
"]",
"<",
"1",
"and",
"(",
"time",
"(",
")",
"-",
"$",
"start",
"<",
"$",
"timeout",
"or",
"$",
"timeout",
"==",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"__process",
"(",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"event_key",
",",
"$",
"this",
"->",
"until_payload",
")",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"until_payload",
"[",
"$",
"event_key",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"until_payload",
"[",
"$",
"event_key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"until_count",
"[",
"$",
"event_key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"until",
"[",
"$",
"event_key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"payload",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"payload",
";",
"}"
] |
Process until a specified event or a timeout occurs
@param string|array $event
@param integer $timeout
@return string
|
[
"Process",
"until",
"a",
"specified",
"event",
"or",
"a",
"timeout",
"occurs"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/jabber/XMPP/XMLStream.php#L461-L482
|
217,002
|
moodle/moodle
|
lib/jabber/XMPP/XMLStream.php
|
XMPPHP_XMLStream.setupParser
|
public function setupParser() {
$this->parser = xml_parser_create('UTF-8');
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'startXML', 'endXML');
xml_set_character_data_handler($this->parser, 'charXML');
}
|
php
|
public function setupParser() {
$this->parser = xml_parser_create('UTF-8');
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'startXML', 'endXML');
xml_set_character_data_handler($this->parser, 'charXML');
}
|
[
"public",
"function",
"setupParser",
"(",
")",
"{",
"$",
"this",
"->",
"parser",
"=",
"xml_parser_create",
"(",
"'UTF-8'",
")",
";",
"xml_parser_set_option",
"(",
"$",
"this",
"->",
"parser",
",",
"XML_OPTION_SKIP_WHITE",
",",
"1",
")",
";",
"xml_parser_set_option",
"(",
"$",
"this",
"->",
"parser",
",",
"XML_OPTION_TARGET_ENCODING",
",",
"'UTF-8'",
")",
";",
"xml_set_object",
"(",
"$",
"this",
"->",
"parser",
",",
"$",
"this",
")",
";",
"xml_set_element_handler",
"(",
"$",
"this",
"->",
"parser",
",",
"'startXML'",
",",
"'endXML'",
")",
";",
"xml_set_character_data_handler",
"(",
"$",
"this",
"->",
"parser",
",",
"'charXML'",
")",
";",
"}"
] |
Setup the XML parser
|
[
"Setup",
"the",
"XML",
"parser"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/jabber/XMPP/XMLStream.php#L747-L754
|
217,003
|
moodle/moodle
|
message/output/airnotifier/classes/manager.php
|
message_airnotifier_manager.include_device_ajax
|
public function include_device_ajax() {
global $PAGE, $CFG;
$config = new stdClass();
$config->resturl = '/message/output/airnotifier/rest.php';
$config->pageparams = array();
// Include toolboxes.
$PAGE->requires->yui_module('moodle-message_airnotifier-toolboxes', 'M.message.init_device_toolbox', array(array(
'ajaxurl' => $config->resturl,
'config' => $config,
))
);
// Required strings for the javascript.
$PAGE->requires->strings_for_js(array('deletecheckdevicename'), 'message_airnotifier');
$PAGE->requires->strings_for_js(array('show', 'hide'), 'moodle');
return true;
}
|
php
|
public function include_device_ajax() {
global $PAGE, $CFG;
$config = new stdClass();
$config->resturl = '/message/output/airnotifier/rest.php';
$config->pageparams = array();
// Include toolboxes.
$PAGE->requires->yui_module('moodle-message_airnotifier-toolboxes', 'M.message.init_device_toolbox', array(array(
'ajaxurl' => $config->resturl,
'config' => $config,
))
);
// Required strings for the javascript.
$PAGE->requires->strings_for_js(array('deletecheckdevicename'), 'message_airnotifier');
$PAGE->requires->strings_for_js(array('show', 'hide'), 'moodle');
return true;
}
|
[
"public",
"function",
"include_device_ajax",
"(",
")",
"{",
"global",
"$",
"PAGE",
",",
"$",
"CFG",
";",
"$",
"config",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"config",
"->",
"resturl",
"=",
"'/message/output/airnotifier/rest.php'",
";",
"$",
"config",
"->",
"pageparams",
"=",
"array",
"(",
")",
";",
"// Include toolboxes.",
"$",
"PAGE",
"->",
"requires",
"->",
"yui_module",
"(",
"'moodle-message_airnotifier-toolboxes'",
",",
"'M.message.init_device_toolbox'",
",",
"array",
"(",
"array",
"(",
"'ajaxurl'",
"=>",
"$",
"config",
"->",
"resturl",
",",
"'config'",
"=>",
"$",
"config",
",",
")",
")",
")",
";",
"// Required strings for the javascript.",
"$",
"PAGE",
"->",
"requires",
"->",
"strings_for_js",
"(",
"array",
"(",
"'deletecheckdevicename'",
")",
",",
"'message_airnotifier'",
")",
";",
"$",
"PAGE",
"->",
"requires",
"->",
"strings_for_js",
"(",
"array",
"(",
"'show'",
",",
"'hide'",
")",
",",
"'moodle'",
")",
";",
"return",
"true",
";",
"}"
] |
Include the relevant javascript and language strings for the device
toolbox YUI module
@return bool
|
[
"Include",
"the",
"relevant",
"javascript",
"and",
"language",
"strings",
"for",
"the",
"device",
"toolbox",
"YUI",
"module"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/output/airnotifier/classes/manager.php#L43-L62
|
217,004
|
moodle/moodle
|
message/output/airnotifier/classes/manager.php
|
message_airnotifier_manager.get_user_devices
|
public function get_user_devices($appname, $userid = null) {
global $USER, $DB;
if (empty($userid)) {
$userid = $USER->id;
}
$devices = array();
$params = array('appid' => $appname, 'userid' => $userid);
// First, we look all the devices registered for this user in the Moodle core.
// We are going to allow only ios devices (since these are the ones that supports PUSH notifications).
$userdevices = $DB->get_records('user_devices', $params);
foreach ($userdevices as $device) {
if (core_text::strtolower($device->platform)) {
// Check if the device is known by airnotifier.
if (!$airnotifierdev = $DB->get_record('message_airnotifier_devices',
array('userdeviceid' => $device->id))) {
// We have to create the device token in airnotifier.
if (! $this->create_token($device->pushid)) {
continue;
}
$airnotifierdev = new stdClass;
$airnotifierdev->userdeviceid = $device->id;
$airnotifierdev->enable = 1;
$airnotifierdev->id = $DB->insert_record('message_airnotifier_devices', $airnotifierdev);
}
$device->id = $airnotifierdev->id;
$device->enable = $airnotifierdev->enable;
$devices[] = $device;
}
}
return $devices;
}
|
php
|
public function get_user_devices($appname, $userid = null) {
global $USER, $DB;
if (empty($userid)) {
$userid = $USER->id;
}
$devices = array();
$params = array('appid' => $appname, 'userid' => $userid);
// First, we look all the devices registered for this user in the Moodle core.
// We are going to allow only ios devices (since these are the ones that supports PUSH notifications).
$userdevices = $DB->get_records('user_devices', $params);
foreach ($userdevices as $device) {
if (core_text::strtolower($device->platform)) {
// Check if the device is known by airnotifier.
if (!$airnotifierdev = $DB->get_record('message_airnotifier_devices',
array('userdeviceid' => $device->id))) {
// We have to create the device token in airnotifier.
if (! $this->create_token($device->pushid)) {
continue;
}
$airnotifierdev = new stdClass;
$airnotifierdev->userdeviceid = $device->id;
$airnotifierdev->enable = 1;
$airnotifierdev->id = $DB->insert_record('message_airnotifier_devices', $airnotifierdev);
}
$device->id = $airnotifierdev->id;
$device->enable = $airnotifierdev->enable;
$devices[] = $device;
}
}
return $devices;
}
|
[
"public",
"function",
"get_user_devices",
"(",
"$",
"appname",
",",
"$",
"userid",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"userid",
")",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"$",
"devices",
"=",
"array",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'appid'",
"=>",
"$",
"appname",
",",
"'userid'",
"=>",
"$",
"userid",
")",
";",
"// First, we look all the devices registered for this user in the Moodle core.",
"// We are going to allow only ios devices (since these are the ones that supports PUSH notifications).",
"$",
"userdevices",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'user_devices'",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"userdevices",
"as",
"$",
"device",
")",
"{",
"if",
"(",
"core_text",
"::",
"strtolower",
"(",
"$",
"device",
"->",
"platform",
")",
")",
"{",
"// Check if the device is known by airnotifier.",
"if",
"(",
"!",
"$",
"airnotifierdev",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'message_airnotifier_devices'",
",",
"array",
"(",
"'userdeviceid'",
"=>",
"$",
"device",
"->",
"id",
")",
")",
")",
"{",
"// We have to create the device token in airnotifier.",
"if",
"(",
"!",
"$",
"this",
"->",
"create_token",
"(",
"$",
"device",
"->",
"pushid",
")",
")",
"{",
"continue",
";",
"}",
"$",
"airnotifierdev",
"=",
"new",
"stdClass",
";",
"$",
"airnotifierdev",
"->",
"userdeviceid",
"=",
"$",
"device",
"->",
"id",
";",
"$",
"airnotifierdev",
"->",
"enable",
"=",
"1",
";",
"$",
"airnotifierdev",
"->",
"id",
"=",
"$",
"DB",
"->",
"insert_record",
"(",
"'message_airnotifier_devices'",
",",
"$",
"airnotifierdev",
")",
";",
"}",
"$",
"device",
"->",
"id",
"=",
"$",
"airnotifierdev",
"->",
"id",
";",
"$",
"device",
"->",
"enable",
"=",
"$",
"airnotifierdev",
"->",
"enable",
";",
"$",
"devices",
"[",
"]",
"=",
"$",
"device",
";",
"}",
"}",
"return",
"$",
"devices",
";",
"}"
] |
Return the user devices for a specific app.
@param string $appname the app name .
@param int $userid if empty take the current user.
@return array all the devices
|
[
"Return",
"the",
"user",
"devices",
"for",
"a",
"specific",
"app",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/output/airnotifier/classes/manager.php#L71-L108
|
217,005
|
moodle/moodle
|
message/output/airnotifier/classes/manager.php
|
message_airnotifier_manager.request_accesskey
|
public function request_accesskey() {
global $CFG, $USER;
require_once($CFG->libdir . '/filelib.php');
// Sending the request access key request to Airnotifier.
$serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/accesskeys/';
// We use an APP Key "none", it can be anything.
$header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
'X-AN-APP-KEY: none');
$curl = new curl();
$curl->setHeader($header);
// Site ids are stored as secrets in md5 in the Moodle public hub.
$params = array(
'url' => $CFG->wwwroot,
'siteid' => md5($CFG->siteidentifier),
'contact' => $USER->email,
'description' => $CFG->wwwroot
);
$resp = $curl->post($serverurl, $params);
if ($key = json_decode($resp, true)) {
if (!empty($key['accesskey'])) {
return $key['accesskey'];
}
}
debugging("Unexpected response from the Airnotifier server: $resp");
return false;
}
|
php
|
public function request_accesskey() {
global $CFG, $USER;
require_once($CFG->libdir . '/filelib.php');
// Sending the request access key request to Airnotifier.
$serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/accesskeys/';
// We use an APP Key "none", it can be anything.
$header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
'X-AN-APP-KEY: none');
$curl = new curl();
$curl->setHeader($header);
// Site ids are stored as secrets in md5 in the Moodle public hub.
$params = array(
'url' => $CFG->wwwroot,
'siteid' => md5($CFG->siteidentifier),
'contact' => $USER->email,
'description' => $CFG->wwwroot
);
$resp = $curl->post($serverurl, $params);
if ($key = json_decode($resp, true)) {
if (!empty($key['accesskey'])) {
return $key['accesskey'];
}
}
debugging("Unexpected response from the Airnotifier server: $resp");
return false;
}
|
[
"public",
"function",
"request_accesskey",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/filelib.php'",
")",
";",
"// Sending the request access key request to Airnotifier.",
"$",
"serverurl",
"=",
"$",
"CFG",
"->",
"airnotifierurl",
".",
"':'",
".",
"$",
"CFG",
"->",
"airnotifierport",
".",
"'/accesskeys/'",
";",
"// We use an APP Key \"none\", it can be anything.",
"$",
"header",
"=",
"array",
"(",
"'Accept: application/json'",
",",
"'X-AN-APP-NAME: '",
".",
"$",
"CFG",
"->",
"airnotifierappname",
",",
"'X-AN-APP-KEY: none'",
")",
";",
"$",
"curl",
"=",
"new",
"curl",
"(",
")",
";",
"$",
"curl",
"->",
"setHeader",
"(",
"$",
"header",
")",
";",
"// Site ids are stored as secrets in md5 in the Moodle public hub.",
"$",
"params",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"CFG",
"->",
"wwwroot",
",",
"'siteid'",
"=>",
"md5",
"(",
"$",
"CFG",
"->",
"siteidentifier",
")",
",",
"'contact'",
"=>",
"$",
"USER",
"->",
"email",
",",
"'description'",
"=>",
"$",
"CFG",
"->",
"wwwroot",
")",
";",
"$",
"resp",
"=",
"$",
"curl",
"->",
"post",
"(",
"$",
"serverurl",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"key",
"=",
"json_decode",
"(",
"$",
"resp",
",",
"true",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"key",
"[",
"'accesskey'",
"]",
")",
")",
"{",
"return",
"$",
"key",
"[",
"'accesskey'",
"]",
";",
"}",
"}",
"debugging",
"(",
"\"Unexpected response from the Airnotifier server: $resp\"",
")",
";",
"return",
"false",
";",
"}"
] |
Request and access key to Airnotifier
@return mixed The access key or false in case of error
|
[
"Request",
"and",
"access",
"key",
"to",
"Airnotifier"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/output/airnotifier/classes/manager.php#L115-L144
|
217,006
|
moodle/moodle
|
message/output/airnotifier/classes/manager.php
|
message_airnotifier_manager.create_token
|
private function create_token($token) {
global $CFG;
if (!$this->is_system_configured()) {
return false;
}
require_once($CFG->libdir . '/filelib.php');
$serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/tokens/' . $token;
$header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
$curl = new curl;
$curl->setHeader($header);
$params = array();
$resp = $curl->post($serverurl, $params);
if ($token = json_decode($resp, true)) {
if (!empty($token['status'])) {
return $token['status'] == 'ok' || $token['status'] == 'token exists';
}
}
debugging("Unexpected response from the Airnotifier server: $resp");
return false;
}
|
php
|
private function create_token($token) {
global $CFG;
if (!$this->is_system_configured()) {
return false;
}
require_once($CFG->libdir . '/filelib.php');
$serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/tokens/' . $token;
$header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname,
'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
$curl = new curl;
$curl->setHeader($header);
$params = array();
$resp = $curl->post($serverurl, $params);
if ($token = json_decode($resp, true)) {
if (!empty($token['status'])) {
return $token['status'] == 'ok' || $token['status'] == 'token exists';
}
}
debugging("Unexpected response from the Airnotifier server: $resp");
return false;
}
|
[
"private",
"function",
"create_token",
"(",
"$",
"token",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"is_system_configured",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/filelib.php'",
")",
";",
"$",
"serverurl",
"=",
"$",
"CFG",
"->",
"airnotifierurl",
".",
"':'",
".",
"$",
"CFG",
"->",
"airnotifierport",
".",
"'/tokens/'",
".",
"$",
"token",
";",
"$",
"header",
"=",
"array",
"(",
"'Accept: application/json'",
",",
"'X-AN-APP-NAME: '",
".",
"$",
"CFG",
"->",
"airnotifierappname",
",",
"'X-AN-APP-KEY: '",
".",
"$",
"CFG",
"->",
"airnotifieraccesskey",
")",
";",
"$",
"curl",
"=",
"new",
"curl",
";",
"$",
"curl",
"->",
"setHeader",
"(",
"$",
"header",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"resp",
"=",
"$",
"curl",
"->",
"post",
"(",
"$",
"serverurl",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"token",
"=",
"json_decode",
"(",
"$",
"resp",
",",
"true",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"token",
"[",
"'status'",
"]",
")",
")",
"{",
"return",
"$",
"token",
"[",
"'status'",
"]",
"==",
"'ok'",
"||",
"$",
"token",
"[",
"'status'",
"]",
"==",
"'token exists'",
";",
"}",
"}",
"debugging",
"(",
"\"Unexpected response from the Airnotifier server: $resp\"",
")",
";",
"return",
"false",
";",
"}"
] |
Create a device token in the Airnotifier instance
@param string $token The token to be created
@return bool True if all was right
|
[
"Create",
"a",
"device",
"token",
"in",
"the",
"Airnotifier",
"instance"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/message/output/airnotifier/classes/manager.php#L151-L175
|
217,007
|
moodle/moodle
|
backup/util/ui/backup_moodleform.class.php
|
backup_confirmation_form.definition_after_data
|
public function definition_after_data() {
parent::definition_after_data();
$this->_form->addRule('setting_root_filename', get_string('errorfilenamerequired', 'backup'), 'required');
$this->_form->setType('setting_root_filename', PARAM_FILE);
}
|
php
|
public function definition_after_data() {
parent::definition_after_data();
$this->_form->addRule('setting_root_filename', get_string('errorfilenamerequired', 'backup'), 'required');
$this->_form->setType('setting_root_filename', PARAM_FILE);
}
|
[
"public",
"function",
"definition_after_data",
"(",
")",
"{",
"parent",
"::",
"definition_after_data",
"(",
")",
";",
"$",
"this",
"->",
"_form",
"->",
"addRule",
"(",
"'setting_root_filename'",
",",
"get_string",
"(",
"'errorfilenamerequired'",
",",
"'backup'",
")",
",",
"'required'",
")",
";",
"$",
"this",
"->",
"_form",
"->",
"setType",
"(",
"'setting_root_filename'",
",",
"PARAM_FILE",
")",
";",
"}"
] |
Adds the last elements, rules, settings etc to the form after data has been set.
We override this to add a rule and type to the filename setting.
@throws coding_exception
|
[
"Adds",
"the",
"last",
"elements",
"rules",
"settings",
"etc",
"to",
"the",
"form",
"after",
"data",
"has",
"been",
"set",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/backup_moodleform.class.php#L103-L107
|
217,008
|
moodle/moodle
|
backup/util/ui/backup_moodleform.class.php
|
backup_confirmation_form.validation
|
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if (!array_key_exists('setting_root_filename', $errors)) {
if (trim($data['setting_root_filename']) == '') {
$errors['setting_root_filename'] = get_string('errorfilenamerequired', 'backup');
} else if (strlen(trim($data['setting_root_filename'])) > 255) {
$errors['setting_root_filename'] = get_string('errorfilenametoolong', 'backup');
} else if (!preg_match('#\.mbz$#i', $data['setting_root_filename'])) {
$errors['setting_root_filename'] = get_string('errorfilenamemustbezip', 'backup');
}
}
return $errors;
}
|
php
|
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if (!array_key_exists('setting_root_filename', $errors)) {
if (trim($data['setting_root_filename']) == '') {
$errors['setting_root_filename'] = get_string('errorfilenamerequired', 'backup');
} else if (strlen(trim($data['setting_root_filename'])) > 255) {
$errors['setting_root_filename'] = get_string('errorfilenametoolong', 'backup');
} else if (!preg_match('#\.mbz$#i', $data['setting_root_filename'])) {
$errors['setting_root_filename'] = get_string('errorfilenamemustbezip', 'backup');
}
}
return $errors;
}
|
[
"public",
"function",
"validation",
"(",
"$",
"data",
",",
"$",
"files",
")",
"{",
"$",
"errors",
"=",
"parent",
"::",
"validation",
"(",
"$",
"data",
",",
"$",
"files",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'setting_root_filename'",
",",
"$",
"errors",
")",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"data",
"[",
"'setting_root_filename'",
"]",
")",
"==",
"''",
")",
"{",
"$",
"errors",
"[",
"'setting_root_filename'",
"]",
"=",
"get_string",
"(",
"'errorfilenamerequired'",
",",
"'backup'",
")",
";",
"}",
"else",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"data",
"[",
"'setting_root_filename'",
"]",
")",
")",
">",
"255",
")",
"{",
"$",
"errors",
"[",
"'setting_root_filename'",
"]",
"=",
"get_string",
"(",
"'errorfilenametoolong'",
",",
"'backup'",
")",
";",
"}",
"else",
"if",
"(",
"!",
"preg_match",
"(",
"'#\\.mbz$#i'",
",",
"$",
"data",
"[",
"'setting_root_filename'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"'setting_root_filename'",
"]",
"=",
"get_string",
"(",
"'errorfilenamemustbezip'",
",",
"'backup'",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Validates the form.
Relies on the parent::validation for the bulk of the work.
@param array $data
@param array $files
@return array
@throws coding_exception
|
[
"Validates",
"the",
"form",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/backup_moodleform.class.php#L119-L133
|
217,009
|
moodle/moodle
|
question/classes/bank/search/category_condition.php
|
category_condition.display_options
|
public function display_options() {
$this->display_category_form($this->contexts, $this->baseurl, $this->cat);
$this->print_category_info($this->category);
}
|
php
|
public function display_options() {
$this->display_category_form($this->contexts, $this->baseurl, $this->cat);
$this->print_category_info($this->category);
}
|
[
"public",
"function",
"display_options",
"(",
")",
"{",
"$",
"this",
"->",
"display_category_form",
"(",
"$",
"this",
"->",
"contexts",
",",
"$",
"this",
"->",
"baseurl",
",",
"$",
"this",
"->",
"cat",
")",
";",
"$",
"this",
"->",
"print_category_info",
"(",
"$",
"this",
"->",
"category",
")",
";",
"}"
] |
Called by question_bank_view to display the GUI for selecting a category
|
[
"Called",
"by",
"question_bank_view",
"to",
"display",
"the",
"GUI",
"for",
"selecting",
"a",
"category"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/category_condition.php#L107-L110
|
217,010
|
moodle/moodle
|
question/classes/bank/search/category_condition.php
|
category_condition.display_options_adv
|
public function display_options_adv() {
echo \html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'recurse',
'value' => 0, 'id' => 'recurse_off'));
echo \html_writer::checkbox('recurse', '1', $this->recurse, get_string('includesubcategories', 'question'),
array('id' => 'recurse_on', 'class' => 'searchoptions'));
echo \html_writer::end_div() . "\n";
}
|
php
|
public function display_options_adv() {
echo \html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'recurse',
'value' => 0, 'id' => 'recurse_off'));
echo \html_writer::checkbox('recurse', '1', $this->recurse, get_string('includesubcategories', 'question'),
array('id' => 'recurse_on', 'class' => 'searchoptions'));
echo \html_writer::end_div() . "\n";
}
|
[
"public",
"function",
"display_options_adv",
"(",
")",
"{",
"echo",
"\\",
"html_writer",
"::",
"start_div",
"(",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'recurse'",
",",
"'value'",
"=>",
"0",
",",
"'id'",
"=>",
"'recurse_off'",
")",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"checkbox",
"(",
"'recurse'",
",",
"'1'",
",",
"$",
"this",
"->",
"recurse",
",",
"get_string",
"(",
"'includesubcategories'",
",",
"'question'",
")",
",",
"array",
"(",
"'id'",
"=>",
"'recurse_on'",
",",
"'class'",
"=>",
"'searchoptions'",
")",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"end_div",
"(",
")",
".",
"\"\\n\"",
";",
"}"
] |
Displays the recursion checkbox GUI.
question_bank_view places this within the section that is hidden by default
|
[
"Displays",
"the",
"recursion",
"checkbox",
"GUI",
".",
"question_bank_view",
"places",
"this",
"within",
"the",
"section",
"that",
"is",
"hidden",
"by",
"default"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/category_condition.php#L116-L123
|
217,011
|
moodle/moodle
|
question/classes/bank/search/category_condition.php
|
category_condition.display_category_form
|
protected function display_category_form($contexts, $pageurl, $current) {
echo \html_writer::start_div('choosecategory');
$catmenu = question_category_options($contexts, true, 0, true);
echo \html_writer::label(get_string('selectacategory', 'question'), 'id_selectacategory');
echo \html_writer::select($catmenu, 'category', $current, array(),
array('class' => 'searchoptions custom-select', 'id' => 'id_selectacategory'));
echo \html_writer::end_div() . "\n";
}
|
php
|
protected function display_category_form($contexts, $pageurl, $current) {
echo \html_writer::start_div('choosecategory');
$catmenu = question_category_options($contexts, true, 0, true);
echo \html_writer::label(get_string('selectacategory', 'question'), 'id_selectacategory');
echo \html_writer::select($catmenu, 'category', $current, array(),
array('class' => 'searchoptions custom-select', 'id' => 'id_selectacategory'));
echo \html_writer::end_div() . "\n";
}
|
[
"protected",
"function",
"display_category_form",
"(",
"$",
"contexts",
",",
"$",
"pageurl",
",",
"$",
"current",
")",
"{",
"echo",
"\\",
"html_writer",
"::",
"start_div",
"(",
"'choosecategory'",
")",
";",
"$",
"catmenu",
"=",
"question_category_options",
"(",
"$",
"contexts",
",",
"true",
",",
"0",
",",
"true",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"label",
"(",
"get_string",
"(",
"'selectacategory'",
",",
"'question'",
")",
",",
"'id_selectacategory'",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"select",
"(",
"$",
"catmenu",
",",
"'category'",
",",
"$",
"current",
",",
"array",
"(",
")",
",",
"array",
"(",
"'class'",
"=>",
"'searchoptions custom-select'",
",",
"'id'",
"=>",
"'id_selectacategory'",
")",
")",
";",
"echo",
"\\",
"html_writer",
"::",
"end_div",
"(",
")",
".",
"\"\\n\"",
";",
"}"
] |
Display the drop down to select the category.
@param array $contexts of contexts that can be accessed from here.
@param \moodle_url $pageurl the URL of this page.
@param string $current 'categoryID,contextID'.
|
[
"Display",
"the",
"drop",
"down",
"to",
"select",
"the",
"category",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/category_condition.php#L132-L139
|
217,012
|
moodle/moodle
|
question/classes/bank/search/category_condition.php
|
category_condition.get_current_category
|
protected function get_current_category($categoryandcontext) {
global $DB, $OUTPUT;
list($categoryid, $contextid) = explode(',', $categoryandcontext);
if (!$categoryid) {
$this->print_choose_category_message($categoryandcontext);
return false;
}
if (!$category = $DB->get_record('question_categories',
array('id' => $categoryid, 'contextid' => $contextid))) {
echo $OUTPUT->box_start('generalbox questionbank');
echo $OUTPUT->notification('Category not found!');
echo $OUTPUT->box_end();
return false;
}
return $category;
}
|
php
|
protected function get_current_category($categoryandcontext) {
global $DB, $OUTPUT;
list($categoryid, $contextid) = explode(',', $categoryandcontext);
if (!$categoryid) {
$this->print_choose_category_message($categoryandcontext);
return false;
}
if (!$category = $DB->get_record('question_categories',
array('id' => $categoryid, 'contextid' => $contextid))) {
echo $OUTPUT->box_start('generalbox questionbank');
echo $OUTPUT->notification('Category not found!');
echo $OUTPUT->box_end();
return false;
}
return $category;
}
|
[
"protected",
"function",
"get_current_category",
"(",
"$",
"categoryandcontext",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"OUTPUT",
";",
"list",
"(",
"$",
"categoryid",
",",
"$",
"contextid",
")",
"=",
"explode",
"(",
"','",
",",
"$",
"categoryandcontext",
")",
";",
"if",
"(",
"!",
"$",
"categoryid",
")",
"{",
"$",
"this",
"->",
"print_choose_category_message",
"(",
"$",
"categoryandcontext",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"category",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'question_categories'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"categoryid",
",",
"'contextid'",
"=>",
"$",
"contextid",
")",
")",
")",
"{",
"echo",
"$",
"OUTPUT",
"->",
"box_start",
"(",
"'generalbox questionbank'",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"notification",
"(",
"'Category not found!'",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"box_end",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"category",
";",
"}"
] |
Look up the category record based on cateogry ID and context
@param string $categoryandcontext categoryID,contextID as used with question_bank_view->display()
@return \stdClass The category record
|
[
"Look",
"up",
"the",
"category",
"record",
"based",
"on",
"cateogry",
"ID",
"and",
"context"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/category_condition.php#L146-L163
|
217,013
|
moodle/moodle
|
question/classes/bank/search/category_condition.php
|
category_condition.print_category_info
|
protected function print_category_info($category) {
$formatoptions = new \stdClass();
$formatoptions->noclean = true;
$formatoptions->overflowdiv = true;
echo \html_writer::start_div('boxaligncenter categoryinfo');
if (isset($this->maxinfolength)) {
echo shorten_text(format_text($category->info, $category->infoformat, $formatoptions, $this->course->id),
$this->maxinfolength);
} else {
echo format_text($category->info, $category->infoformat, $formatoptions, $this->course->id);
}
echo \html_writer::end_div() . "\n";
}
|
php
|
protected function print_category_info($category) {
$formatoptions = new \stdClass();
$formatoptions->noclean = true;
$formatoptions->overflowdiv = true;
echo \html_writer::start_div('boxaligncenter categoryinfo');
if (isset($this->maxinfolength)) {
echo shorten_text(format_text($category->info, $category->infoformat, $formatoptions, $this->course->id),
$this->maxinfolength);
} else {
echo format_text($category->info, $category->infoformat, $formatoptions, $this->course->id);
}
echo \html_writer::end_div() . "\n";
}
|
[
"protected",
"function",
"print_category_info",
"(",
"$",
"category",
")",
"{",
"$",
"formatoptions",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"formatoptions",
"->",
"noclean",
"=",
"true",
";",
"$",
"formatoptions",
"->",
"overflowdiv",
"=",
"true",
";",
"echo",
"\\",
"html_writer",
"::",
"start_div",
"(",
"'boxaligncenter categoryinfo'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"maxinfolength",
")",
")",
"{",
"echo",
"shorten_text",
"(",
"format_text",
"(",
"$",
"category",
"->",
"info",
",",
"$",
"category",
"->",
"infoformat",
",",
"$",
"formatoptions",
",",
"$",
"this",
"->",
"course",
"->",
"id",
")",
",",
"$",
"this",
"->",
"maxinfolength",
")",
";",
"}",
"else",
"{",
"echo",
"format_text",
"(",
"$",
"category",
"->",
"info",
",",
"$",
"category",
"->",
"infoformat",
",",
"$",
"formatoptions",
",",
"$",
"this",
"->",
"course",
"->",
"id",
")",
";",
"}",
"echo",
"\\",
"html_writer",
"::",
"end_div",
"(",
")",
".",
"\"\\n\"",
";",
"}"
] |
Print the category description
@param stdClass $category the category information form the database.
|
[
"Print",
"the",
"category",
"description"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/search/category_condition.php#L169-L181
|
217,014
|
moodle/moodle
|
mod/feedback/classes/templates_table.php
|
mod_feedback_templates_table.display
|
public function display($templates) {
global $OUTPUT;
if (empty($templates)) {
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'),
'generalbox boxaligncenter');
return;
}
$this->setup();
$strdeletefeedback = get_string('delete_template', 'feedback');
foreach ($templates as $template) {
$data = array();
$data[] = format_string($template->name);
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id, 'sesskey' => sesskey()));
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$data[] = $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdeletefeedback), $deleteaction);
$this->add_data($data);
}
$this->finish_output();
}
|
php
|
public function display($templates) {
global $OUTPUT;
if (empty($templates)) {
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'),
'generalbox boxaligncenter');
return;
}
$this->setup();
$strdeletefeedback = get_string('delete_template', 'feedback');
foreach ($templates as $template) {
$data = array();
$data[] = format_string($template->name);
$url = new moodle_url($this->baseurl, array('deletetempl' => $template->id, 'sesskey' => sesskey()));
$deleteaction = new confirm_action(get_string('confirmdeletetemplate', 'feedback'));
$data[] = $OUTPUT->action_icon($url, new pix_icon('t/delete', $strdeletefeedback), $deleteaction);
$this->add_data($data);
}
$this->finish_output();
}
|
[
"public",
"function",
"display",
"(",
"$",
"templates",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"if",
"(",
"empty",
"(",
"$",
"templates",
")",
")",
"{",
"echo",
"$",
"OUTPUT",
"->",
"box",
"(",
"get_string",
"(",
"'no_templates_available_yet'",
",",
"'feedback'",
")",
",",
"'generalbox boxaligncenter'",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"setup",
"(",
")",
";",
"$",
"strdeletefeedback",
"=",
"get_string",
"(",
"'delete_template'",
",",
"'feedback'",
")",
";",
"foreach",
"(",
"$",
"templates",
"as",
"$",
"template",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"]",
"=",
"format_string",
"(",
"$",
"template",
"->",
"name",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"this",
"->",
"baseurl",
",",
"array",
"(",
"'deletetempl'",
"=>",
"$",
"template",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"deleteaction",
"=",
"new",
"confirm_action",
"(",
"get_string",
"(",
"'confirmdeletetemplate'",
",",
"'feedback'",
")",
")",
";",
"$",
"data",
"[",
"]",
"=",
"$",
"OUTPUT",
"->",
"action_icon",
"(",
"$",
"url",
",",
"new",
"pix_icon",
"(",
"'t/delete'",
",",
"$",
"strdeletefeedback",
")",
",",
"$",
"deleteaction",
")",
";",
"$",
"this",
"->",
"add_data",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"finish_output",
"(",
")",
";",
"}"
] |
Displays the table with the given set of templates
@param array $templates
|
[
"Displays",
"the",
"table",
"with",
"the",
"given",
"set",
"of",
"templates"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/templates_table.php#L66-L87
|
217,015
|
moodle/moodle
|
lib/classes/minify.php
|
core_minify.js
|
public static function js($content) {
try {
$minifier = new MatthiasMullie\Minify\JS($content);
return $minifier->minify();
} catch (Exception $e) {
ob_end_clean();
$error = $e->getMessage();
}
$return = <<<EOD
try {console.log('Error: Minimisation of JavaScript failed!');} catch (e) {}
// Error: $error
// Problem detected during JavaScript minimisation, please review the following code
// =================================================================================
EOD;
return $return.$content;
}
|
php
|
public static function js($content) {
try {
$minifier = new MatthiasMullie\Minify\JS($content);
return $minifier->minify();
} catch (Exception $e) {
ob_end_clean();
$error = $e->getMessage();
}
$return = <<<EOD
try {console.log('Error: Minimisation of JavaScript failed!');} catch (e) {}
// Error: $error
// Problem detected during JavaScript minimisation, please review the following code
// =================================================================================
EOD;
return $return.$content;
}
|
[
"public",
"static",
"function",
"js",
"(",
"$",
"content",
")",
"{",
"try",
"{",
"$",
"minifier",
"=",
"new",
"MatthiasMullie",
"\\",
"Minify",
"\\",
"JS",
"(",
"$",
"content",
")",
";",
"return",
"$",
"minifier",
"->",
"minify",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"ob_end_clean",
"(",
")",
";",
"$",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"$",
"return",
"=",
" <<<EOD\n\ntry {console.log('Error: Minimisation of JavaScript failed!');} catch (e) {}\n\n// Error: $error\n// Problem detected during JavaScript minimisation, please review the following code\n// =================================================================================\n\n\nEOD",
";",
"return",
"$",
"return",
".",
"$",
"content",
";",
"}"
] |
Minify JS code.
@param string $content
@return string minified JS code
|
[
"Minify",
"JS",
"code",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/minify.php#L37-L58
|
217,016
|
moodle/moodle
|
lib/classes/minify.php
|
core_minify.js_files
|
public static function js_files(array $files) {
if (empty($files)) {
return '';
}
$compressed = array();
foreach ($files as $file) {
$content = file_get_contents($file);
if ($content === false) {
$compressed[] = "\n\n// Cannot read JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
continue;
}
$compressed[] = self::js($content);
}
return implode(";\n", $compressed);
}
|
php
|
public static function js_files(array $files) {
if (empty($files)) {
return '';
}
$compressed = array();
foreach ($files as $file) {
$content = file_get_contents($file);
if ($content === false) {
$compressed[] = "\n\n// Cannot read JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
continue;
}
$compressed[] = self::js($content);
}
return implode(";\n", $compressed);
}
|
[
"public",
"static",
"function",
"js_files",
"(",
"array",
"$",
"files",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"compressed",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"content",
"===",
"false",
")",
"{",
"$",
"compressed",
"[",
"]",
"=",
"\"\\n\\n// Cannot read JS file \"",
".",
"basename",
"(",
"dirname",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
".",
"'/'",
".",
"basename",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
".",
"'/'",
".",
"basename",
"(",
"$",
"file",
")",
".",
"\"\\n\\n\"",
";",
"continue",
";",
"}",
"$",
"compressed",
"[",
"]",
"=",
"self",
"::",
"js",
"(",
"$",
"content",
")",
";",
"}",
"return",
"implode",
"(",
"\";\\n\"",
",",
"$",
"compressed",
")",
";",
"}"
] |
Minify JS files.
@param array $files
@return string minified JS code
|
[
"Minify",
"JS",
"files",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/minify.php#L66-L82
|
217,017
|
moodle/moodle
|
lib/classes/minify.php
|
core_minify.css
|
public static function css($content) {
$error = 'unknown';
try {
$minifier = new MatthiasMullie\Minify\CSS($content);
return $minifier->minify();
} catch (Exception $e) {
$error = $e->getMessage();
}
$return = <<<EOD
/* Error: $error */
/* Problem detected during CSS minimisation, please review the following code */
/* ========================================================================== */
EOD;
return $return.$content;
}
|
php
|
public static function css($content) {
$error = 'unknown';
try {
$minifier = new MatthiasMullie\Minify\CSS($content);
return $minifier->minify();
} catch (Exception $e) {
$error = $e->getMessage();
}
$return = <<<EOD
/* Error: $error */
/* Problem detected during CSS minimisation, please review the following code */
/* ========================================================================== */
EOD;
return $return.$content;
}
|
[
"public",
"static",
"function",
"css",
"(",
"$",
"content",
")",
"{",
"$",
"error",
"=",
"'unknown'",
";",
"try",
"{",
"$",
"minifier",
"=",
"new",
"MatthiasMullie",
"\\",
"Minify",
"\\",
"CSS",
"(",
"$",
"content",
")",
";",
"return",
"$",
"minifier",
"->",
"minify",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"$",
"return",
"=",
" <<<EOD\n\n/* Error: $error */\n/* Problem detected during CSS minimisation, please review the following code */\n/* ========================================================================== */\n\n\nEOD",
";",
"return",
"$",
"return",
".",
"$",
"content",
";",
"}"
] |
Minify CSS code.
@param string $content
@return string minified CSS
|
[
"Minify",
"CSS",
"code",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/minify.php#L90-L109
|
217,018
|
moodle/moodle
|
lib/classes/minify.php
|
core_minify.css_files
|
public static function css_files(array $files) {
if (empty($files)) {
return '';
}
$compressed = array();
foreach ($files as $file) {
$content = file_get_contents($file);
if ($content === false) {
$compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
continue;
}
$compressed[] = self::css($content);
}
return implode("\n", $compressed);
}
|
php
|
public static function css_files(array $files) {
if (empty($files)) {
return '';
}
$compressed = array();
foreach ($files as $file) {
$content = file_get_contents($file);
if ($content === false) {
$compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
continue;
}
$compressed[] = self::css($content);
}
return implode("\n", $compressed);
}
|
[
"public",
"static",
"function",
"css_files",
"(",
"array",
"$",
"files",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"compressed",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"content",
"===",
"false",
")",
"{",
"$",
"compressed",
"[",
"]",
"=",
"\"\\n\\n/* Cannot read CSS file \"",
".",
"basename",
"(",
"dirname",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
".",
"'/'",
".",
"basename",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
".",
"'/'",
".",
"basename",
"(",
"$",
"file",
")",
".",
"\"*/\\n\\n\"",
";",
"continue",
";",
"}",
"$",
"compressed",
"[",
"]",
"=",
"self",
"::",
"css",
"(",
"$",
"content",
")",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"compressed",
")",
";",
"}"
] |
Minify CSS files.
@param array $files
@return string minified CSS code
|
[
"Minify",
"CSS",
"files",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/minify.php#L117-L133
|
217,019
|
moodle/moodle
|
user/profile/field/text/field.class.php
|
profile_field_text.display_data
|
public function display_data() {
// Default formatting.
$data = parent::display_data();
// Are we creating a link?
if (!empty($this->field->param4) and !empty($data)) {
// Define the target.
if (! empty($this->field->param5)) {
$target = 'target="'.$this->field->param5.'"';
} else {
$target = '';
}
// Create the link.
$data = '<a href="'.str_replace('$$', urlencode($data), $this->field->param4).'" '.$target.'>'.htmlspecialchars($data).'</a>';
}
return $data;
}
|
php
|
public function display_data() {
// Default formatting.
$data = parent::display_data();
// Are we creating a link?
if (!empty($this->field->param4) and !empty($data)) {
// Define the target.
if (! empty($this->field->param5)) {
$target = 'target="'.$this->field->param5.'"';
} else {
$target = '';
}
// Create the link.
$data = '<a href="'.str_replace('$$', urlencode($data), $this->field->param4).'" '.$target.'>'.htmlspecialchars($data).'</a>';
}
return $data;
}
|
[
"public",
"function",
"display_data",
"(",
")",
"{",
"// Default formatting.",
"$",
"data",
"=",
"parent",
"::",
"display_data",
"(",
")",
";",
"// Are we creating a link?",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"field",
"->",
"param4",
")",
"and",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"// Define the target.",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"field",
"->",
"param5",
")",
")",
"{",
"$",
"target",
"=",
"'target=\"'",
".",
"$",
"this",
"->",
"field",
"->",
"param5",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"target",
"=",
"''",
";",
"}",
"// Create the link.",
"$",
"data",
"=",
"'<a href=\"'",
".",
"str_replace",
"(",
"'$$'",
",",
"urlencode",
"(",
"$",
"data",
")",
",",
"$",
"this",
"->",
"field",
"->",
"param4",
")",
".",
"'\" '",
".",
"$",
"target",
".",
"'>'",
".",
"htmlspecialchars",
"(",
"$",
"data",
")",
".",
"'</a>'",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Overwrite the base class to display the data for this field
|
[
"Overwrite",
"the",
"base",
"class",
"to",
"display",
"the",
"data",
"for",
"this",
"field"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/text/field.class.php#L36-L55
|
217,020
|
moodle/moodle
|
user/profile/field/text/field.class.php
|
profile_field_text.edit_field_add
|
public function edit_field_add($mform) {
$size = $this->field->param1;
$maxlength = $this->field->param2;
$fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');
// Create the form field.
$mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
$mform->setType($this->inputname, PARAM_TEXT);
}
|
php
|
public function edit_field_add($mform) {
$size = $this->field->param1;
$maxlength = $this->field->param2;
$fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');
// Create the form field.
$mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
$mform->setType($this->inputname, PARAM_TEXT);
}
|
[
"public",
"function",
"edit_field_add",
"(",
"$",
"mform",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"field",
"->",
"param1",
";",
"$",
"maxlength",
"=",
"$",
"this",
"->",
"field",
"->",
"param2",
";",
"$",
"fieldtype",
"=",
"(",
"$",
"this",
"->",
"field",
"->",
"param3",
"==",
"1",
"?",
"'password'",
":",
"'text'",
")",
";",
"// Create the form field.",
"$",
"mform",
"->",
"addElement",
"(",
"$",
"fieldtype",
",",
"$",
"this",
"->",
"inputname",
",",
"format_string",
"(",
"$",
"this",
"->",
"field",
"->",
"name",
")",
",",
"'maxlength=\"'",
".",
"$",
"maxlength",
".",
"'\" size=\"'",
".",
"$",
"size",
".",
"'\" '",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"$",
"this",
"->",
"inputname",
",",
"PARAM_TEXT",
")",
";",
"}"
] |
Add fields for editing a text profile field.
@param moodleform $mform
|
[
"Add",
"fields",
"for",
"editing",
"a",
"text",
"profile",
"field",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/text/field.class.php#L61-L69
|
217,021
|
moodle/moodle
|
lib/horde/framework/Horde/Variables.php
|
Horde_Variables.sanitize
|
public function sanitize()
{
if (!$this->_sanitized) {
foreach (array_keys($this->_vars) as $key) {
$this->$key = $this->filter($key);
}
$this->_sanitized = true;
}
}
|
php
|
public function sanitize()
{
if (!$this->_sanitized) {
foreach (array_keys($this->_vars) as $key) {
$this->$key = $this->filter($key);
}
$this->_sanitized = true;
}
}
|
[
"public",
"function",
"sanitize",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_sanitized",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_vars",
")",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"filter",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"_sanitized",
"=",
"true",
";",
"}",
"}"
] |
Sanitize the form input.
|
[
"Sanitize",
"the",
"form",
"input",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Variables.php#L98-L106
|
217,022
|
moodle/moodle
|
lib/horde/framework/Horde/Variables.php
|
Horde_Variables.get
|
public function get($varname, $default = null)
{
return $this->_getExists($this->_vars, $varname, $value)
? $value
: $default;
}
|
php
|
public function get($varname, $default = null)
{
return $this->_getExists($this->_vars, $varname, $value)
? $value
: $default;
}
|
[
"public",
"function",
"get",
"(",
"$",
"varname",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_getExists",
"(",
"$",
"this",
"->",
"_vars",
",",
"$",
"varname",
",",
"$",
"value",
")",
"?",
"$",
"value",
":",
"$",
"default",
";",
"}"
] |
Returns the value of a given form variable.
@param string $varname The form variable name.
@param string $default The default form variable value.
@return mixed The form variable, or $default if it doesn't exist.
|
[
"Returns",
"the",
"value",
"of",
"a",
"given",
"form",
"variable",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Variables.php#L150-L155
|
217,023
|
moodle/moodle
|
lib/horde/framework/Horde/Variables.php
|
Horde_Variables.getExists
|
public function getExists($varname, &$exists)
{
$exists = $this->_getExists($this->_vars, $varname, $value);
return $value;
}
|
php
|
public function getExists($varname, &$exists)
{
$exists = $this->_getExists($this->_vars, $varname, $value);
return $value;
}
|
[
"public",
"function",
"getExists",
"(",
"$",
"varname",
",",
"&",
"$",
"exists",
")",
"{",
"$",
"exists",
"=",
"$",
"this",
"->",
"_getExists",
"(",
"$",
"this",
"->",
"_vars",
",",
"$",
"varname",
",",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}"
] |
Given a variable name, returns the value and sets a variable indicating
whether the value exists in the form data.
@param string $varname The form variable name.
@param boolean &$exists Reference to variable that will indicate
whether $varname existed in form data.
@return mixed The form variable, or null if it doesn't exist.
|
[
"Given",
"a",
"variable",
"name",
"returns",
"the",
"value",
"and",
"sets",
"a",
"variable",
"indicating",
"whether",
"the",
"value",
"exists",
"in",
"the",
"form",
"data",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Variables.php#L190-L194
|
217,024
|
moodle/moodle
|
lib/horde/framework/Horde/Variables.php
|
Horde_Variables.filter
|
public function filter($varname)
{
$val = $this->$varname;
if (is_null($val) || $this->_sanitized) {
return $val;
}
return is_array($val)
? filter_var_array($val, FILTER_SANITIZE_STRING)
: filter_var($val, FILTER_SANITIZE_STRING);
}
|
php
|
public function filter($varname)
{
$val = $this->$varname;
if (is_null($val) || $this->_sanitized) {
return $val;
}
return is_array($val)
? filter_var_array($val, FILTER_SANITIZE_STRING)
: filter_var($val, FILTER_SANITIZE_STRING);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"varname",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"$",
"varname",
";",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
"||",
"$",
"this",
"->",
"_sanitized",
")",
"{",
"return",
"$",
"val",
";",
"}",
"return",
"is_array",
"(",
"$",
"val",
")",
"?",
"filter_var_array",
"(",
"$",
"val",
",",
"FILTER_SANITIZE_STRING",
")",
":",
"filter_var",
"(",
"$",
"val",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"}"
] |
Filters a form value so that it can be used in HTML output.
@param string $varname The form variable name.
@return mixed The filtered variable, or null if it doesn't exist.
|
[
"Filters",
"a",
"form",
"value",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"HTML",
"output",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Variables.php#L329-L340
|
217,025
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.execute
|
public function execute() {
global $CFG, $DB;
$timenow = time();
// Delete any really old posts in the digest queue.
$weekago = $timenow - (7 * 24 * 3600);
$this->log_start("Removing old digest records from 7 days ago.");
$DB->delete_records_select('forum_queue', "timemodified < ?", array($weekago));
$this->log_finish("Removed all old digest records.");
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - (2 * DAYSECS);
$this->log_start("Fetching unmailed posts.");
if (!$posts = $this->get_unmailed_posts($starttime, $endtime, $timenow)) {
$this->log_finish("No posts found.", 1);
return false;
}
$this->log_finish("Done");
// Process post data and turn into adhoc tasks.
$this->process_post_data($posts);
// Mark posts as read.
list($in, $params) = $DB->get_in_or_equal(array_keys($posts));
$DB->set_field_select('forum_posts', 'mailed', 1, "id {$in}", $params);
}
|
php
|
public function execute() {
global $CFG, $DB;
$timenow = time();
// Delete any really old posts in the digest queue.
$weekago = $timenow - (7 * 24 * 3600);
$this->log_start("Removing old digest records from 7 days ago.");
$DB->delete_records_select('forum_queue', "timemodified < ?", array($weekago));
$this->log_finish("Removed all old digest records.");
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - (2 * DAYSECS);
$this->log_start("Fetching unmailed posts.");
if (!$posts = $this->get_unmailed_posts($starttime, $endtime, $timenow)) {
$this->log_finish("No posts found.", 1);
return false;
}
$this->log_finish("Done");
// Process post data and turn into adhoc tasks.
$this->process_post_data($posts);
// Mark posts as read.
list($in, $params) = $DB->get_in_or_equal(array_keys($posts));
$DB->set_field_select('forum_posts', 'mailed', 1, "id {$in}", $params);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"$",
"timenow",
"=",
"time",
"(",
")",
";",
"// Delete any really old posts in the digest queue.",
"$",
"weekago",
"=",
"$",
"timenow",
"-",
"(",
"7",
"*",
"24",
"*",
"3600",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Removing old digest records from 7 days ago.\"",
")",
";",
"$",
"DB",
"->",
"delete_records_select",
"(",
"'forum_queue'",
",",
"\"timemodified < ?\"",
",",
"array",
"(",
"$",
"weekago",
")",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Removed all old digest records.\"",
")",
";",
"$",
"endtime",
"=",
"$",
"timenow",
"-",
"$",
"CFG",
"->",
"maxeditingtime",
";",
"$",
"starttime",
"=",
"$",
"endtime",
"-",
"(",
"2",
"*",
"DAYSECS",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Fetching unmailed posts.\"",
")",
";",
"if",
"(",
"!",
"$",
"posts",
"=",
"$",
"this",
"->",
"get_unmailed_posts",
"(",
"$",
"starttime",
",",
"$",
"endtime",
",",
"$",
"timenow",
")",
")",
"{",
"$",
"this",
"->",
"log_finish",
"(",
"\"No posts found.\"",
",",
"1",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
")",
";",
"// Process post data and turn into adhoc tasks.",
"$",
"this",
"->",
"process_post_data",
"(",
"$",
"posts",
")",
";",
"// Mark posts as read.",
"list",
"(",
"$",
"in",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"array_keys",
"(",
"$",
"posts",
")",
")",
";",
"$",
"DB",
"->",
"set_field_select",
"(",
"'forum_posts'",
",",
"'mailed'",
",",
"1",
",",
"\"id {$in}\"",
",",
"$",
"params",
")",
";",
"}"
] |
Execute the scheduled task.
|
[
"Execute",
"the",
"scheduled",
"task",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L94-L120
|
217,026
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.process_post_data
|
protected function process_post_data($posts) {
$discussionids = [];
$forumids = [];
$courseids = [];
$this->log_start("Processing post information");
$start = microtime(true);
foreach ($posts as $id => $post) {
$discussionids[$post->discussion] = true;
$forumids[$post->forum] = true;
$courseids[$post->course] = true;
$this->add_data_for_post($post);
$this->posts[$id] = $post;
}
$this->log_finish(sprintf("Processed %s posts", count($this->posts)));
if (empty($this->posts)) {
$this->log("No posts found. Returning early.");
return;
}
// Please note, this order is intentional.
// The forum cache makes use of the course.
$this->log_start("Filling caches");
$start = microtime(true);
$this->log_start("Filling course cache", 1);
$this->fill_course_cache(array_keys($courseids));
$this->log_finish("Done", 1);
$this->log_start("Filling forum cache", 1);
$this->fill_forum_cache(array_keys($forumids));
$this->log_finish("Done", 1);
$this->log_start("Filling discussion cache", 1);
$this->fill_discussion_cache(array_keys($discussionids));
$this->log_finish("Done", 1);
$this->log_start("Filling user subscription cache", 1);
$this->fill_user_subscription_cache();
$this->log_finish("Done", 1);
$this->log_start("Filling digest cache", 1);
$this->fill_digest_cache();
$this->log_finish("Done", 1);
$this->log_finish("All caches filled");
$this->log_start("Queueing user tasks.");
$this->queue_user_tasks();
$this->log_finish("All tasks queued.");
}
|
php
|
protected function process_post_data($posts) {
$discussionids = [];
$forumids = [];
$courseids = [];
$this->log_start("Processing post information");
$start = microtime(true);
foreach ($posts as $id => $post) {
$discussionids[$post->discussion] = true;
$forumids[$post->forum] = true;
$courseids[$post->course] = true;
$this->add_data_for_post($post);
$this->posts[$id] = $post;
}
$this->log_finish(sprintf("Processed %s posts", count($this->posts)));
if (empty($this->posts)) {
$this->log("No posts found. Returning early.");
return;
}
// Please note, this order is intentional.
// The forum cache makes use of the course.
$this->log_start("Filling caches");
$start = microtime(true);
$this->log_start("Filling course cache", 1);
$this->fill_course_cache(array_keys($courseids));
$this->log_finish("Done", 1);
$this->log_start("Filling forum cache", 1);
$this->fill_forum_cache(array_keys($forumids));
$this->log_finish("Done", 1);
$this->log_start("Filling discussion cache", 1);
$this->fill_discussion_cache(array_keys($discussionids));
$this->log_finish("Done", 1);
$this->log_start("Filling user subscription cache", 1);
$this->fill_user_subscription_cache();
$this->log_finish("Done", 1);
$this->log_start("Filling digest cache", 1);
$this->fill_digest_cache();
$this->log_finish("Done", 1);
$this->log_finish("All caches filled");
$this->log_start("Queueing user tasks.");
$this->queue_user_tasks();
$this->log_finish("All tasks queued.");
}
|
[
"protected",
"function",
"process_post_data",
"(",
"$",
"posts",
")",
"{",
"$",
"discussionids",
"=",
"[",
"]",
";",
"$",
"forumids",
"=",
"[",
"]",
";",
"$",
"courseids",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Processing post information\"",
")",
";",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"posts",
"as",
"$",
"id",
"=>",
"$",
"post",
")",
"{",
"$",
"discussionids",
"[",
"$",
"post",
"->",
"discussion",
"]",
"=",
"true",
";",
"$",
"forumids",
"[",
"$",
"post",
"->",
"forum",
"]",
"=",
"true",
";",
"$",
"courseids",
"[",
"$",
"post",
"->",
"course",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"add_data_for_post",
"(",
"$",
"post",
")",
";",
"$",
"this",
"->",
"posts",
"[",
"$",
"id",
"]",
"=",
"$",
"post",
";",
"}",
"$",
"this",
"->",
"log_finish",
"(",
"sprintf",
"(",
"\"Processed %s posts\"",
",",
"count",
"(",
"$",
"this",
"->",
"posts",
")",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"posts",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"No posts found. Returning early.\"",
")",
";",
"return",
";",
"}",
"// Please note, this order is intentional.",
"// The forum cache makes use of the course.",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling caches\"",
")",
";",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling course cache\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"fill_course_cache",
"(",
"array_keys",
"(",
"$",
"courseids",
")",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling forum cache\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"fill_forum_cache",
"(",
"array_keys",
"(",
"$",
"forumids",
")",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling discussion cache\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"fill_discussion_cache",
"(",
"array_keys",
"(",
"$",
"discussionids",
")",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling user subscription cache\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"fill_user_subscription_cache",
"(",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Filling digest cache\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"fill_digest_cache",
"(",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"Done\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"All caches filled\"",
")",
";",
"$",
"this",
"->",
"log_start",
"(",
"\"Queueing user tasks.\"",
")",
";",
"$",
"this",
"->",
"queue_user_tasks",
"(",
")",
";",
"$",
"this",
"->",
"log_finish",
"(",
"\"All tasks queued.\"",
")",
";",
"}"
] |
Process all posts and convert to appropriated hoc tasks.
@param \stdClass[] $posts
|
[
"Process",
"all",
"posts",
"and",
"convert",
"to",
"appropriated",
"hoc",
"tasks",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L127-L179
|
217,027
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.fill_course_cache
|
protected function fill_course_cache($courseids) {
global $DB;
list($in, $params) = $DB->get_in_or_equal($courseids);
$this->courses = $DB->get_records_select('course', "id $in", $params);
}
|
php
|
protected function fill_course_cache($courseids) {
global $DB;
list($in, $params) = $DB->get_in_or_equal($courseids);
$this->courses = $DB->get_records_select('course', "id $in", $params);
}
|
[
"protected",
"function",
"fill_course_cache",
"(",
"$",
"courseids",
")",
"{",
"global",
"$",
"DB",
";",
"list",
"(",
"$",
"in",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"courseids",
")",
";",
"$",
"this",
"->",
"courses",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'course'",
",",
"\"id $in\"",
",",
"$",
"params",
")",
";",
"}"
] |
Fill the course cache.
@param int[] $courseids
|
[
"Fill",
"the",
"course",
"cache",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L186-L191
|
217,028
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.fill_forum_cache
|
protected function fill_forum_cache($forumids) {
global $DB;
$requiredfields = [
'id',
'course',
'forcesubscribe',
'type',
];
list($in, $params) = $DB->get_in_or_equal($forumids);
$this->forums = $DB->get_records_select('forum', "id $in", $params, '', implode(', ', $requiredfields));
foreach ($this->forums as $id => $forum) {
\mod_forum\subscriptions::fill_subscription_cache($id);
\mod_forum\subscriptions::fill_discussion_subscription_cache($id);
}
}
|
php
|
protected function fill_forum_cache($forumids) {
global $DB;
$requiredfields = [
'id',
'course',
'forcesubscribe',
'type',
];
list($in, $params) = $DB->get_in_or_equal($forumids);
$this->forums = $DB->get_records_select('forum', "id $in", $params, '', implode(', ', $requiredfields));
foreach ($this->forums as $id => $forum) {
\mod_forum\subscriptions::fill_subscription_cache($id);
\mod_forum\subscriptions::fill_discussion_subscription_cache($id);
}
}
|
[
"protected",
"function",
"fill_forum_cache",
"(",
"$",
"forumids",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"requiredfields",
"=",
"[",
"'id'",
",",
"'course'",
",",
"'forcesubscribe'",
",",
"'type'",
",",
"]",
";",
"list",
"(",
"$",
"in",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"forumids",
")",
";",
"$",
"this",
"->",
"forums",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'forum'",
",",
"\"id $in\"",
",",
"$",
"params",
",",
"''",
",",
"implode",
"(",
"', '",
",",
"$",
"requiredfields",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"forums",
"as",
"$",
"id",
"=>",
"$",
"forum",
")",
"{",
"\\",
"mod_forum",
"\\",
"subscriptions",
"::",
"fill_subscription_cache",
"(",
"$",
"id",
")",
";",
"\\",
"mod_forum",
"\\",
"subscriptions",
"::",
"fill_discussion_subscription_cache",
"(",
"$",
"id",
")",
";",
"}",
"}"
] |
Fill the forum cache.
@param int[] $forumids
|
[
"Fill",
"the",
"forum",
"cache",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L198-L213
|
217,029
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.fill_discussion_cache
|
protected function fill_discussion_cache($discussionids) {
global $DB;
if (empty($discussionids)) {
$this->discussion = [];
} else {
$requiredfields = [
'id',
'groupid',
'firstpost',
'timestart',
'timeend',
];
list($in, $params) = $DB->get_in_or_equal($discussionids);
$this->discussions = $DB->get_records_select(
'forum_discussions', "id $in", $params, '', implode(', ', $requiredfields));
}
}
|
php
|
protected function fill_discussion_cache($discussionids) {
global $DB;
if (empty($discussionids)) {
$this->discussion = [];
} else {
$requiredfields = [
'id',
'groupid',
'firstpost',
'timestart',
'timeend',
];
list($in, $params) = $DB->get_in_or_equal($discussionids);
$this->discussions = $DB->get_records_select(
'forum_discussions', "id $in", $params, '', implode(', ', $requiredfields));
}
}
|
[
"protected",
"function",
"fill_discussion_cache",
"(",
"$",
"discussionids",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"discussionids",
")",
")",
"{",
"$",
"this",
"->",
"discussion",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"requiredfields",
"=",
"[",
"'id'",
",",
"'groupid'",
",",
"'firstpost'",
",",
"'timestart'",
",",
"'timeend'",
",",
"]",
";",
"list",
"(",
"$",
"in",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"discussionids",
")",
";",
"$",
"this",
"->",
"discussions",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'forum_discussions'",
",",
"\"id $in\"",
",",
"$",
"params",
",",
"''",
",",
"implode",
"(",
"', '",
",",
"$",
"requiredfields",
")",
")",
";",
"}",
"}"
] |
Fill the discussion cache.
@param int[] $discussionids
|
[
"Fill",
"the",
"discussion",
"cache",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L220-L239
|
217,030
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.fill_digest_cache
|
protected function fill_digest_cache() {
global $DB;
if (empty($this->users)) {
return;
}
// Get the list of forum subscriptions for per-user per-forum maildigest settings.
list($in, $params) = $DB->get_in_or_equal(array_keys($this->users));
$digestspreferences = $DB->get_recordset_select(
'forum_digests', "userid $in", $params, '', 'id, userid, forum, maildigest');
foreach ($digestspreferences as $digestpreference) {
if (!isset($this->digestusers[$digestpreference->forum])) {
$this->digestusers[$digestpreference->forum] = [];
}
$this->digestusers[$digestpreference->forum][$digestpreference->userid] = $digestpreference->maildigest;
}
$digestspreferences->close();
}
|
php
|
protected function fill_digest_cache() {
global $DB;
if (empty($this->users)) {
return;
}
// Get the list of forum subscriptions for per-user per-forum maildigest settings.
list($in, $params) = $DB->get_in_or_equal(array_keys($this->users));
$digestspreferences = $DB->get_recordset_select(
'forum_digests', "userid $in", $params, '', 'id, userid, forum, maildigest');
foreach ($digestspreferences as $digestpreference) {
if (!isset($this->digestusers[$digestpreference->forum])) {
$this->digestusers[$digestpreference->forum] = [];
}
$this->digestusers[$digestpreference->forum][$digestpreference->userid] = $digestpreference->maildigest;
}
$digestspreferences->close();
}
|
[
"protected",
"function",
"fill_digest_cache",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"users",
")",
")",
"{",
"return",
";",
"}",
"// Get the list of forum subscriptions for per-user per-forum maildigest settings.",
"list",
"(",
"$",
"in",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"users",
")",
")",
";",
"$",
"digestspreferences",
"=",
"$",
"DB",
"->",
"get_recordset_select",
"(",
"'forum_digests'",
",",
"\"userid $in\"",
",",
"$",
"params",
",",
"''",
",",
"'id, userid, forum, maildigest'",
")",
";",
"foreach",
"(",
"$",
"digestspreferences",
"as",
"$",
"digestpreference",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"digestusers",
"[",
"$",
"digestpreference",
"->",
"forum",
"]",
")",
")",
"{",
"$",
"this",
"->",
"digestusers",
"[",
"$",
"digestpreference",
"->",
"forum",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"digestusers",
"[",
"$",
"digestpreference",
"->",
"forum",
"]",
"[",
"$",
"digestpreference",
"->",
"userid",
"]",
"=",
"$",
"digestpreference",
"->",
"maildigest",
";",
"}",
"$",
"digestspreferences",
"->",
"close",
"(",
")",
";",
"}"
] |
Fill the cache of user digest preferences.
|
[
"Fill",
"the",
"cache",
"of",
"user",
"digest",
"preferences",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L244-L261
|
217,031
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.add_data_for_post
|
protected function add_data_for_post($post) {
if (!isset($this->adhocdata[$post->course])) {
$this->adhocdata[$post->course] = [];
}
if (!isset($this->adhocdata[$post->course][$post->forum])) {
$this->adhocdata[$post->course][$post->forum] = [];
}
if (!isset($this->adhocdata[$post->course][$post->forum][$post->discussion])) {
$this->adhocdata[$post->course][$post->forum][$post->discussion] = [];
}
$this->adhocdata[$post->course][$post->forum][$post->discussion][$post->id] = $post->id;
}
|
php
|
protected function add_data_for_post($post) {
if (!isset($this->adhocdata[$post->course])) {
$this->adhocdata[$post->course] = [];
}
if (!isset($this->adhocdata[$post->course][$post->forum])) {
$this->adhocdata[$post->course][$post->forum] = [];
}
if (!isset($this->adhocdata[$post->course][$post->forum][$post->discussion])) {
$this->adhocdata[$post->course][$post->forum][$post->discussion] = [];
}
$this->adhocdata[$post->course][$post->forum][$post->discussion][$post->id] = $post->id;
}
|
[
"protected",
"function",
"add_data_for_post",
"(",
"$",
"post",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
")",
")",
"{",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"[",
"$",
"post",
"->",
"forum",
"]",
")",
")",
"{",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"[",
"$",
"post",
"->",
"forum",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"[",
"$",
"post",
"->",
"forum",
"]",
"[",
"$",
"post",
"->",
"discussion",
"]",
")",
")",
"{",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"[",
"$",
"post",
"->",
"forum",
"]",
"[",
"$",
"post",
"->",
"discussion",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"adhocdata",
"[",
"$",
"post",
"->",
"course",
"]",
"[",
"$",
"post",
"->",
"forum",
"]",
"[",
"$",
"post",
"->",
"discussion",
"]",
"[",
"$",
"post",
"->",
"id",
"]",
"=",
"$",
"post",
"->",
"id",
";",
"}"
] |
Add dsta for the current forum post to the structure of adhoc data.
@param \stdClass $post
|
[
"Add",
"dsta",
"for",
"the",
"current",
"forum",
"post",
"to",
"the",
"structure",
"of",
"adhoc",
"data",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L268-L282
|
217,032
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.fill_user_subscription_cache
|
protected function fill_user_subscription_cache() {
foreach ($this->forums as $forum) {
$cm = get_fast_modinfo($this->courses[$forum->course])->instances['forum'][$forum->id];
$modcontext = \context_module::instance($cm->id);
$this->subscribedusers[$forum->id] = [];
if ($users = \mod_forum\subscriptions::fetch_subscribed_users($forum, 0, $modcontext, 'u.id, u.maildigest', true)) {
foreach ($users as $user) {
// This user is subscribed to this forum.
$this->subscribedusers[$forum->id][$user->id] = $user->id;
if (!isset($this->users[$user->id])) {
// Store minimal user info.
$this->users[$user->id] = $user;
}
}
// Release memory.
unset($users);
}
}
}
|
php
|
protected function fill_user_subscription_cache() {
foreach ($this->forums as $forum) {
$cm = get_fast_modinfo($this->courses[$forum->course])->instances['forum'][$forum->id];
$modcontext = \context_module::instance($cm->id);
$this->subscribedusers[$forum->id] = [];
if ($users = \mod_forum\subscriptions::fetch_subscribed_users($forum, 0, $modcontext, 'u.id, u.maildigest', true)) {
foreach ($users as $user) {
// This user is subscribed to this forum.
$this->subscribedusers[$forum->id][$user->id] = $user->id;
if (!isset($this->users[$user->id])) {
// Store minimal user info.
$this->users[$user->id] = $user;
}
}
// Release memory.
unset($users);
}
}
}
|
[
"protected",
"function",
"fill_user_subscription_cache",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"forums",
"as",
"$",
"forum",
")",
"{",
"$",
"cm",
"=",
"get_fast_modinfo",
"(",
"$",
"this",
"->",
"courses",
"[",
"$",
"forum",
"->",
"course",
"]",
")",
"->",
"instances",
"[",
"'forum'",
"]",
"[",
"$",
"forum",
"->",
"id",
"]",
";",
"$",
"modcontext",
"=",
"\\",
"context_module",
"::",
"instance",
"(",
"$",
"cm",
"->",
"id",
")",
";",
"$",
"this",
"->",
"subscribedusers",
"[",
"$",
"forum",
"->",
"id",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"users",
"=",
"\\",
"mod_forum",
"\\",
"subscriptions",
"::",
"fetch_subscribed_users",
"(",
"$",
"forum",
",",
"0",
",",
"$",
"modcontext",
",",
"'u.id, u.maildigest'",
",",
"true",
")",
")",
"{",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"// This user is subscribed to this forum.",
"$",
"this",
"->",
"subscribedusers",
"[",
"$",
"forum",
"->",
"id",
"]",
"[",
"$",
"user",
"->",
"id",
"]",
"=",
"$",
"user",
"->",
"id",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"->",
"id",
"]",
")",
")",
"{",
"// Store minimal user info.",
"$",
"this",
"->",
"users",
"[",
"$",
"user",
"->",
"id",
"]",
"=",
"$",
"user",
";",
"}",
"}",
"// Release memory.",
"unset",
"(",
"$",
"users",
")",
";",
"}",
"}",
"}"
] |
Fill the cache of user subscriptions.
|
[
"Fill",
"the",
"cache",
"of",
"user",
"subscriptions",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L287-L306
|
217,033
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.queue_user_tasks
|
protected function queue_user_tasks() {
global $CFG, $DB;
$timenow = time();
$sitetimezone = \core_date::get_server_timezone();
$counts = [
'digests' => 0,
'individuals' => 0,
'users' => 0,
'ignored' => 0,
'messages' => 0,
];
$this->log("Processing " . count($this->users) . " users", 1);
foreach ($this->users as $user) {
$usercounts = [
'digests' => 0,
'messages' => 0,
];
$send = false;
// Setup this user so that the capabilities are cached, and environment matches receiving user.
cron_setup_user($user);
list($individualpostdata, $digestpostdata) = $this->fetch_posts_for_user($user);
if (!empty($digestpostdata)) {
// Insert all of the records for the digest.
$DB->insert_records('forum_queue', $digestpostdata);
$digesttime = usergetmidnight($timenow, $sitetimezone) + ($CFG->digestmailtime * 3600);
$task = new \mod_forum\task\send_user_digests();
$task->set_userid($user->id);
$task->set_component('mod_forum');
$task->set_next_run_time($digesttime);
\core\task\manager::reschedule_or_queue_adhoc_task($task);
$usercounts['digests']++;
$send = true;
}
if (!empty($individualpostdata)) {
$usercounts['messages'] += count($individualpostdata);
$task = new \mod_forum\task\send_user_notifications();
$task->set_userid($user->id);
$task->set_custom_data($individualpostdata);
$task->set_component('mod_forum');
\core\task\manager::queue_adhoc_task($task);
$counts['individuals']++;
$send = true;
}
if ($send) {
$counts['users']++;
$counts['messages'] += $usercounts['messages'];
$counts['digests'] += $usercounts['digests'];
} else {
$counts['ignored']++;
}
$this->log(sprintf("Queued %d digests and %d messages for %s",
$usercounts['digests'],
$usercounts['messages'],
$user->id
), 2);
}
$this->log(
sprintf(
"Queued %d digests, and %d individual tasks for %d post mails. " .
"Unique users: %d (%d ignored)",
$counts['digests'],
$counts['individuals'],
$counts['messages'],
$counts['users'],
$counts['ignored']
), 1);
}
|
php
|
protected function queue_user_tasks() {
global $CFG, $DB;
$timenow = time();
$sitetimezone = \core_date::get_server_timezone();
$counts = [
'digests' => 0,
'individuals' => 0,
'users' => 0,
'ignored' => 0,
'messages' => 0,
];
$this->log("Processing " . count($this->users) . " users", 1);
foreach ($this->users as $user) {
$usercounts = [
'digests' => 0,
'messages' => 0,
];
$send = false;
// Setup this user so that the capabilities are cached, and environment matches receiving user.
cron_setup_user($user);
list($individualpostdata, $digestpostdata) = $this->fetch_posts_for_user($user);
if (!empty($digestpostdata)) {
// Insert all of the records for the digest.
$DB->insert_records('forum_queue', $digestpostdata);
$digesttime = usergetmidnight($timenow, $sitetimezone) + ($CFG->digestmailtime * 3600);
$task = new \mod_forum\task\send_user_digests();
$task->set_userid($user->id);
$task->set_component('mod_forum');
$task->set_next_run_time($digesttime);
\core\task\manager::reschedule_or_queue_adhoc_task($task);
$usercounts['digests']++;
$send = true;
}
if (!empty($individualpostdata)) {
$usercounts['messages'] += count($individualpostdata);
$task = new \mod_forum\task\send_user_notifications();
$task->set_userid($user->id);
$task->set_custom_data($individualpostdata);
$task->set_component('mod_forum');
\core\task\manager::queue_adhoc_task($task);
$counts['individuals']++;
$send = true;
}
if ($send) {
$counts['users']++;
$counts['messages'] += $usercounts['messages'];
$counts['digests'] += $usercounts['digests'];
} else {
$counts['ignored']++;
}
$this->log(sprintf("Queued %d digests and %d messages for %s",
$usercounts['digests'],
$usercounts['messages'],
$user->id
), 2);
}
$this->log(
sprintf(
"Queued %d digests, and %d individual tasks for %d post mails. " .
"Unique users: %d (%d ignored)",
$counts['digests'],
$counts['individuals'],
$counts['messages'],
$counts['users'],
$counts['ignored']
), 1);
}
|
[
"protected",
"function",
"queue_user_tasks",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"$",
"timenow",
"=",
"time",
"(",
")",
";",
"$",
"sitetimezone",
"=",
"\\",
"core_date",
"::",
"get_server_timezone",
"(",
")",
";",
"$",
"counts",
"=",
"[",
"'digests'",
"=>",
"0",
",",
"'individuals'",
"=>",
"0",
",",
"'users'",
"=>",
"0",
",",
"'ignored'",
"=>",
"0",
",",
"'messages'",
"=>",
"0",
",",
"]",
";",
"$",
"this",
"->",
"log",
"(",
"\"Processing \"",
".",
"count",
"(",
"$",
"this",
"->",
"users",
")",
".",
"\" users\"",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"usercounts",
"=",
"[",
"'digests'",
"=>",
"0",
",",
"'messages'",
"=>",
"0",
",",
"]",
";",
"$",
"send",
"=",
"false",
";",
"// Setup this user so that the capabilities are cached, and environment matches receiving user.",
"cron_setup_user",
"(",
"$",
"user",
")",
";",
"list",
"(",
"$",
"individualpostdata",
",",
"$",
"digestpostdata",
")",
"=",
"$",
"this",
"->",
"fetch_posts_for_user",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"digestpostdata",
")",
")",
"{",
"// Insert all of the records for the digest.",
"$",
"DB",
"->",
"insert_records",
"(",
"'forum_queue'",
",",
"$",
"digestpostdata",
")",
";",
"$",
"digesttime",
"=",
"usergetmidnight",
"(",
"$",
"timenow",
",",
"$",
"sitetimezone",
")",
"+",
"(",
"$",
"CFG",
"->",
"digestmailtime",
"*",
"3600",
")",
";",
"$",
"task",
"=",
"new",
"\\",
"mod_forum",
"\\",
"task",
"\\",
"send_user_digests",
"(",
")",
";",
"$",
"task",
"->",
"set_userid",
"(",
"$",
"user",
"->",
"id",
")",
";",
"$",
"task",
"->",
"set_component",
"(",
"'mod_forum'",
")",
";",
"$",
"task",
"->",
"set_next_run_time",
"(",
"$",
"digesttime",
")",
";",
"\\",
"core",
"\\",
"task",
"\\",
"manager",
"::",
"reschedule_or_queue_adhoc_task",
"(",
"$",
"task",
")",
";",
"$",
"usercounts",
"[",
"'digests'",
"]",
"++",
";",
"$",
"send",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"individualpostdata",
")",
")",
"{",
"$",
"usercounts",
"[",
"'messages'",
"]",
"+=",
"count",
"(",
"$",
"individualpostdata",
")",
";",
"$",
"task",
"=",
"new",
"\\",
"mod_forum",
"\\",
"task",
"\\",
"send_user_notifications",
"(",
")",
";",
"$",
"task",
"->",
"set_userid",
"(",
"$",
"user",
"->",
"id",
")",
";",
"$",
"task",
"->",
"set_custom_data",
"(",
"$",
"individualpostdata",
")",
";",
"$",
"task",
"->",
"set_component",
"(",
"'mod_forum'",
")",
";",
"\\",
"core",
"\\",
"task",
"\\",
"manager",
"::",
"queue_adhoc_task",
"(",
"$",
"task",
")",
";",
"$",
"counts",
"[",
"'individuals'",
"]",
"++",
";",
"$",
"send",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"send",
")",
"{",
"$",
"counts",
"[",
"'users'",
"]",
"++",
";",
"$",
"counts",
"[",
"'messages'",
"]",
"+=",
"$",
"usercounts",
"[",
"'messages'",
"]",
";",
"$",
"counts",
"[",
"'digests'",
"]",
"+=",
"$",
"usercounts",
"[",
"'digests'",
"]",
";",
"}",
"else",
"{",
"$",
"counts",
"[",
"'ignored'",
"]",
"++",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"\"Queued %d digests and %d messages for %s\"",
",",
"$",
"usercounts",
"[",
"'digests'",
"]",
",",
"$",
"usercounts",
"[",
"'messages'",
"]",
",",
"$",
"user",
"->",
"id",
")",
",",
"2",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"\"Queued %d digests, and %d individual tasks for %d post mails. \"",
".",
"\"Unique users: %d (%d ignored)\"",
",",
"$",
"counts",
"[",
"'digests'",
"]",
",",
"$",
"counts",
"[",
"'individuals'",
"]",
",",
"$",
"counts",
"[",
"'messages'",
"]",
",",
"$",
"counts",
"[",
"'users'",
"]",
",",
"$",
"counts",
"[",
"'ignored'",
"]",
")",
",",
"1",
")",
";",
"}"
] |
Queue the user tasks.
|
[
"Queue",
"the",
"user",
"tasks",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L311-L386
|
217,034
|
moodle/moodle
|
mod/forum/classes/task/cron_task.php
|
cron_task.get_unmailed_posts
|
protected function get_unmailed_posts($starttime, $endtime, $now = null) {
global $CFG, $DB;
$params = array();
$params['mailed'] = FORUM_MAILED_PENDING;
$params['ptimestart'] = $starttime;
$params['ptimeend'] = $endtime;
$params['mailnow'] = 1;
if (!empty($CFG->forum_enabletimedposts)) {
if (empty($now)) {
$now = time();
}
$selectsql = "AND (p.created >= :ptimestart OR d.timestart >= :pptimestart)";
$params['pptimestart'] = $starttime;
$timedsql = "AND (d.timestart < :dtimestart AND (d.timeend = 0 OR d.timeend > :dtimeend))";
$params['dtimestart'] = $now;
$params['dtimeend'] = $now;
} else {
$timedsql = "";
$selectsql = "AND p.created >= :ptimestart";
}
return $DB->get_records_sql(
"SELECT
p.id,
p.discussion,
d.forum,
d.course,
p.created,
p.parent,
p.userid
FROM {forum_posts} p
JOIN {forum_discussions} d ON d.id = p.discussion
WHERE p.mailed = :mailed
$selectsql
AND (p.created < :ptimeend OR p.mailnow = :mailnow)
$timedsql
ORDER BY p.modified ASC",
$params);
}
|
php
|
protected function get_unmailed_posts($starttime, $endtime, $now = null) {
global $CFG, $DB;
$params = array();
$params['mailed'] = FORUM_MAILED_PENDING;
$params['ptimestart'] = $starttime;
$params['ptimeend'] = $endtime;
$params['mailnow'] = 1;
if (!empty($CFG->forum_enabletimedposts)) {
if (empty($now)) {
$now = time();
}
$selectsql = "AND (p.created >= :ptimestart OR d.timestart >= :pptimestart)";
$params['pptimestart'] = $starttime;
$timedsql = "AND (d.timestart < :dtimestart AND (d.timeend = 0 OR d.timeend > :dtimeend))";
$params['dtimestart'] = $now;
$params['dtimeend'] = $now;
} else {
$timedsql = "";
$selectsql = "AND p.created >= :ptimestart";
}
return $DB->get_records_sql(
"SELECT
p.id,
p.discussion,
d.forum,
d.course,
p.created,
p.parent,
p.userid
FROM {forum_posts} p
JOIN {forum_discussions} d ON d.id = p.discussion
WHERE p.mailed = :mailed
$selectsql
AND (p.created < :ptimeend OR p.mailnow = :mailnow)
$timedsql
ORDER BY p.modified ASC",
$params);
}
|
[
"protected",
"function",
"get_unmailed_posts",
"(",
"$",
"starttime",
",",
"$",
"endtime",
",",
"$",
"now",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"params",
"[",
"'mailed'",
"]",
"=",
"FORUM_MAILED_PENDING",
";",
"$",
"params",
"[",
"'ptimestart'",
"]",
"=",
"$",
"starttime",
";",
"$",
"params",
"[",
"'ptimeend'",
"]",
"=",
"$",
"endtime",
";",
"$",
"params",
"[",
"'mailnow'",
"]",
"=",
"1",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"forum_enabletimedposts",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"now",
")",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"}",
"$",
"selectsql",
"=",
"\"AND (p.created >= :ptimestart OR d.timestart >= :pptimestart)\"",
";",
"$",
"params",
"[",
"'pptimestart'",
"]",
"=",
"$",
"starttime",
";",
"$",
"timedsql",
"=",
"\"AND (d.timestart < :dtimestart AND (d.timeend = 0 OR d.timeend > :dtimeend))\"",
";",
"$",
"params",
"[",
"'dtimestart'",
"]",
"=",
"$",
"now",
";",
"$",
"params",
"[",
"'dtimeend'",
"]",
"=",
"$",
"now",
";",
"}",
"else",
"{",
"$",
"timedsql",
"=",
"\"\"",
";",
"$",
"selectsql",
"=",
"\"AND p.created >= :ptimestart\"",
";",
"}",
"return",
"$",
"DB",
"->",
"get_records_sql",
"(",
"\"SELECT\n p.id,\n p.discussion,\n d.forum,\n d.course,\n p.created,\n p.parent,\n p.userid\n FROM {forum_posts} p\n JOIN {forum_discussions} d ON d.id = p.discussion\n WHERE p.mailed = :mailed\n $selectsql\n AND (p.created < :ptimeend OR p.mailnow = :mailnow)\n $timedsql\n ORDER BY p.modified ASC\"",
",",
"$",
"params",
")",
";",
"}"
] |
Returns a list of all new posts that have not been mailed yet
@param int $starttime posts created after this time
@param int $endtime posts created before this
@param int $now used for timed discussions only
@return array
|
[
"Returns",
"a",
"list",
"of",
"all",
"new",
"posts",
"that",
"have",
"not",
"been",
"mailed",
"yet"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/task/cron_task.php#L497-L537
|
217,035
|
moodle/moodle
|
mod/data/backup/moodle2/restore_data_stepslib.php
|
restore_data_activity_structure_step.process_data_record_tag
|
protected function process_data_record_tag($data) {
$data = (object)$data;
if (!core_tag_tag::is_enabled('mod_data', 'data_records')) { // Tags disabled in server, nothing to process.
return;
}
if (!$itemid = $this->get_mappingid('data_record', $data->itemid)) {
// Some orphaned tag, we could not find the data record for it - ignore.
return;
}
$tag = $data->rawname;
$context = context_module::instance($this->task->get_moduleid());
core_tag_tag::add_item_tag('mod_data', 'data_records', $itemid, $context, $tag);
}
|
php
|
protected function process_data_record_tag($data) {
$data = (object)$data;
if (!core_tag_tag::is_enabled('mod_data', 'data_records')) { // Tags disabled in server, nothing to process.
return;
}
if (!$itemid = $this->get_mappingid('data_record', $data->itemid)) {
// Some orphaned tag, we could not find the data record for it - ignore.
return;
}
$tag = $data->rawname;
$context = context_module::instance($this->task->get_moduleid());
core_tag_tag::add_item_tag('mod_data', 'data_records', $itemid, $context, $tag);
}
|
[
"protected",
"function",
"process_data_record_tag",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"(",
"object",
")",
"$",
"data",
";",
"if",
"(",
"!",
"core_tag_tag",
"::",
"is_enabled",
"(",
"'mod_data'",
",",
"'data_records'",
")",
")",
"{",
"// Tags disabled in server, nothing to process.",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"itemid",
"=",
"$",
"this",
"->",
"get_mappingid",
"(",
"'data_record'",
",",
"$",
"data",
"->",
"itemid",
")",
")",
"{",
"// Some orphaned tag, we could not find the data record for it - ignore.",
"return",
";",
"}",
"$",
"tag",
"=",
"$",
"data",
"->",
"rawname",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"this",
"->",
"task",
"->",
"get_moduleid",
"(",
")",
")",
";",
"core_tag_tag",
"::",
"add_item_tag",
"(",
"'mod_data'",
",",
"'data_records'",
",",
"$",
"itemid",
",",
"$",
"context",
",",
"$",
"tag",
")",
";",
"}"
] |
Add tags to restored records.
@param stdClass $data Tag
|
[
"Add",
"tags",
"to",
"restored",
"records",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/backup/moodle2/restore_data_stepslib.php#L130-L145
|
217,036
|
moodle/moodle
|
lib/dml/moodle_temptables.php
|
moodle_temptables.dispose
|
public function dispose() {
// We shouldn't have any temp table registered at the end of the script.
// So we error_log that and, at the same time, drop all the pending temptables
if ($temptables = $this->get_temptables()) {
error_log('Potential coding error - existing temptables found when disposing database. Must be dropped!');
foreach ($temptables as $temptable) {
$this->mdb->get_manager()->drop_table(new xmldb_table($temptable));
}
}
$this->mdb = null;
}
|
php
|
public function dispose() {
// We shouldn't have any temp table registered at the end of the script.
// So we error_log that and, at the same time, drop all the pending temptables
if ($temptables = $this->get_temptables()) {
error_log('Potential coding error - existing temptables found when disposing database. Must be dropped!');
foreach ($temptables as $temptable) {
$this->mdb->get_manager()->drop_table(new xmldb_table($temptable));
}
}
$this->mdb = null;
}
|
[
"public",
"function",
"dispose",
"(",
")",
"{",
"// We shouldn't have any temp table registered at the end of the script.",
"// So we error_log that and, at the same time, drop all the pending temptables",
"if",
"(",
"$",
"temptables",
"=",
"$",
"this",
"->",
"get_temptables",
"(",
")",
")",
"{",
"error_log",
"(",
"'Potential coding error - existing temptables found when disposing database. Must be dropped!'",
")",
";",
"foreach",
"(",
"$",
"temptables",
"as",
"$",
"temptable",
")",
"{",
"$",
"this",
"->",
"mdb",
"->",
"get_manager",
"(",
")",
"->",
"drop_table",
"(",
"new",
"xmldb_table",
"(",
"$",
"temptable",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"mdb",
"=",
"null",
";",
"}"
] |
Dispose the temptables stuff, checking for wrong situations, informing and recovering from them
|
[
"Dispose",
"the",
"temptables",
"stuff",
"checking",
"for",
"wrong",
"situations",
"informing",
"and",
"recovering",
"from",
"them"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_temptables.php#L134-L144
|
217,037
|
moodle/moodle
|
lib/classes/analytics/analyser/users.php
|
users.get_analysables_iterator
|
public function get_analysables_iterator(?string $action = null) {
global $DB, $CFG;
$siteadmins = explode(',', $CFG->siteadmins);
list($sql, $params) = $this->get_iterator_sql('user', CONTEXT_USER, $action, 'u');
$sql .= " AND u.deleted = :deleted AND u.confirmed = :confirmed AND u.suspended = :suspended";
$params = $params + ['deleted' => 0, 'confirmed' => 1, 'suspended' => 0];
$ordersql = $this->order_sql('timecreated', 'ASC', 'u');
$recordset = $DB->get_recordset_sql($sql, $params);
if (!$recordset->valid()) {
$this->add_log(get_string('nousersfound'));
return new \ArrayIterator([]);
}
return new \core\dml\recordset_walk($recordset, function($record) use ($siteadmins) {
if (in_array($record->id, $siteadmins) || isguestuser($record->id)) {
// Skip admins and the guest user.
return false;
}
$context = \context_helper::preload_from_record($record);
return \core_analytics\user::instance($record, $context);
});
}
|
php
|
public function get_analysables_iterator(?string $action = null) {
global $DB, $CFG;
$siteadmins = explode(',', $CFG->siteadmins);
list($sql, $params) = $this->get_iterator_sql('user', CONTEXT_USER, $action, 'u');
$sql .= " AND u.deleted = :deleted AND u.confirmed = :confirmed AND u.suspended = :suspended";
$params = $params + ['deleted' => 0, 'confirmed' => 1, 'suspended' => 0];
$ordersql = $this->order_sql('timecreated', 'ASC', 'u');
$recordset = $DB->get_recordset_sql($sql, $params);
if (!$recordset->valid()) {
$this->add_log(get_string('nousersfound'));
return new \ArrayIterator([]);
}
return new \core\dml\recordset_walk($recordset, function($record) use ($siteadmins) {
if (in_array($record->id, $siteadmins) || isguestuser($record->id)) {
// Skip admins and the guest user.
return false;
}
$context = \context_helper::preload_from_record($record);
return \core_analytics\user::instance($record, $context);
});
}
|
[
"public",
"function",
"get_analysables_iterator",
"(",
"?",
"string",
"$",
"action",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"$",
"siteadmins",
"=",
"explode",
"(",
"','",
",",
"$",
"CFG",
"->",
"siteadmins",
")",
";",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"get_iterator_sql",
"(",
"'user'",
",",
"CONTEXT_USER",
",",
"$",
"action",
",",
"'u'",
")",
";",
"$",
"sql",
".=",
"\" AND u.deleted = :deleted AND u.confirmed = :confirmed AND u.suspended = :suspended\"",
";",
"$",
"params",
"=",
"$",
"params",
"+",
"[",
"'deleted'",
"=>",
"0",
",",
"'confirmed'",
"=>",
"1",
",",
"'suspended'",
"=>",
"0",
"]",
";",
"$",
"ordersql",
"=",
"$",
"this",
"->",
"order_sql",
"(",
"'timecreated'",
",",
"'ASC'",
",",
"'u'",
")",
";",
"$",
"recordset",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"recordset",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"add_log",
"(",
"get_string",
"(",
"'nousersfound'",
")",
")",
";",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"[",
"]",
")",
";",
"}",
"return",
"new",
"\\",
"core",
"\\",
"dml",
"\\",
"recordset_walk",
"(",
"$",
"recordset",
",",
"function",
"(",
"$",
"record",
")",
"use",
"(",
"$",
"siteadmins",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"record",
"->",
"id",
",",
"$",
"siteadmins",
")",
"||",
"isguestuser",
"(",
"$",
"record",
"->",
"id",
")",
")",
"{",
"// Skip admins and the guest user.",
"return",
"false",
";",
"}",
"$",
"context",
"=",
"\\",
"context_helper",
"::",
"preload_from_record",
"(",
"$",
"record",
")",
";",
"return",
"\\",
"core_analytics",
"\\",
"user",
"::",
"instance",
"(",
"$",
"record",
",",
"$",
"context",
")",
";",
"}",
")",
";",
"}"
] |
The site users are the analysable elements returned by this analyser.
@param string|null $action 'prediction', 'training' or null if no specific action needed.
@return \Iterator
|
[
"The",
"site",
"users",
"are",
"the",
"analysable",
"elements",
"returned",
"by",
"this",
"analyser",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/users.php#L44-L71
|
217,038
|
moodle/moodle
|
lib/classes/analytics/analyser/users.php
|
users.get_all_samples
|
public function get_all_samples(\core_analytics\analysable $user) {
$context = \context_user::instance($user->get_id());
// Just 1 sample per analysable.
return [
[$user->get_id() => $user->get_id()],
[$user->get_id() => ['user' => $user->get_user_data(), 'context' => $context]]
];
}
|
php
|
public function get_all_samples(\core_analytics\analysable $user) {
$context = \context_user::instance($user->get_id());
// Just 1 sample per analysable.
return [
[$user->get_id() => $user->get_id()],
[$user->get_id() => ['user' => $user->get_user_data(), 'context' => $context]]
];
}
|
[
"public",
"function",
"get_all_samples",
"(",
"\\",
"core_analytics",
"\\",
"analysable",
"$",
"user",
")",
"{",
"$",
"context",
"=",
"\\",
"context_user",
"::",
"instance",
"(",
"$",
"user",
"->",
"get_id",
"(",
")",
")",
";",
"// Just 1 sample per analysable.",
"return",
"[",
"[",
"$",
"user",
"->",
"get_id",
"(",
")",
"=>",
"$",
"user",
"->",
"get_id",
"(",
")",
"]",
",",
"[",
"$",
"user",
"->",
"get_id",
"(",
")",
"=>",
"[",
"'user'",
"=>",
"$",
"user",
"->",
"get_user_data",
"(",
")",
",",
"'context'",
"=>",
"$",
"context",
"]",
"]",
"]",
";",
"}"
] |
This will return just one user as we analyse users separately.
@param \core_analytics\analysable $user
@return array
|
[
"This",
"will",
"return",
"just",
"one",
"user",
"as",
"we",
"analyse",
"users",
"separately",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/users.php#L126-L135
|
217,039
|
moodle/moodle
|
lib/classes/analytics/analyser/users.php
|
users.get_samples
|
public function get_samples($sampleids) {
global $DB;
list($sql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED);
$users = $DB->get_records_select('user', "id $sql", $params);
$userids = array_keys($users);
$sampleids = array_combine($userids, $userids);
$users = array_map(function($user) {
return ['user' => $user, 'context' => \context_user::instance($user->id)];
}, $users);
// No related data attached.
return [$sampleids, $users];
}
|
php
|
public function get_samples($sampleids) {
global $DB;
list($sql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED);
$users = $DB->get_records_select('user', "id $sql", $params);
$userids = array_keys($users);
$sampleids = array_combine($userids, $userids);
$users = array_map(function($user) {
return ['user' => $user, 'context' => \context_user::instance($user->id)];
}, $users);
// No related data attached.
return [$sampleids, $users];
}
|
[
"public",
"function",
"get_samples",
"(",
"$",
"sampleids",
")",
"{",
"global",
"$",
"DB",
";",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"sampleids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"users",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'user'",
",",
"\"id $sql\"",
",",
"$",
"params",
")",
";",
"$",
"userids",
"=",
"array_keys",
"(",
"$",
"users",
")",
";",
"$",
"sampleids",
"=",
"array_combine",
"(",
"$",
"userids",
",",
"$",
"userids",
")",
";",
"$",
"users",
"=",
"array_map",
"(",
"function",
"(",
"$",
"user",
")",
"{",
"return",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'context'",
"=>",
"\\",
"context_user",
"::",
"instance",
"(",
"$",
"user",
"->",
"id",
")",
"]",
";",
"}",
",",
"$",
"users",
")",
";",
"// No related data attached.",
"return",
"[",
"$",
"sampleids",
",",
"$",
"users",
"]",
";",
"}"
] |
Returns samples data from sample ids.
@param int[] $sampleids
@return array
|
[
"Returns",
"samples",
"data",
"from",
"sample",
"ids",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/analytics/analyser/users.php#L143-L158
|
217,040
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Data/Capability.php
|
Horde_Imap_Client_Data_Capability.remove
|
public function remove($capability, $params = null)
{
$capability = Horde_String::upper($capability);
if (is_null($params)) {
unset($this->_data[$capability]);
} elseif (isset($this->_data[$capability])) {
if (!is_array($params)) {
$params = array($params);
}
$params = array_map('Horde_String::upper', $params);
$this->_data[$capability] = is_array($this->_data[$capability])
? array_diff($this->_data[$capability], $params)
: array();
if (empty($this->_data[$capability])) {
unset($this->_data[$capability]);
}
}
$this->notify();
}
|
php
|
public function remove($capability, $params = null)
{
$capability = Horde_String::upper($capability);
if (is_null($params)) {
unset($this->_data[$capability]);
} elseif (isset($this->_data[$capability])) {
if (!is_array($params)) {
$params = array($params);
}
$params = array_map('Horde_String::upper', $params);
$this->_data[$capability] = is_array($this->_data[$capability])
? array_diff($this->_data[$capability], $params)
: array();
if (empty($this->_data[$capability])) {
unset($this->_data[$capability]);
}
}
$this->notify();
}
|
[
"public",
"function",
"remove",
"(",
"$",
"capability",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"capability",
"=",
"Horde_String",
"::",
"upper",
"(",
"$",
"capability",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"params",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"params",
")",
";",
"}",
"$",
"params",
"=",
"array_map",
"(",
"'Horde_String::upper'",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
"=",
"is_array",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
"?",
"array_diff",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
",",
"$",
"params",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"notify",
"(",
")",
";",
"}"
] |
Remove a capability.
@param string $capability The capability to remove.
@param string $params A parameter (or array of parameters) to
remove from the capability.
|
[
"Remove",
"a",
"capability",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Capability.php#L79-L101
|
217,041
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Data/Capability.php
|
Horde_Imap_Client_Data_Capability.query
|
public function query($capability, $parameter = null)
{
$capability = Horde_String::upper($capability);
if (!isset($this->_data[$capability])) {
return false;
}
return is_null($parameter) ?:
(is_array($this->_data[$capability]) &&
in_array(Horde_String::upper($parameter), $this->_data[$capability]));
}
|
php
|
public function query($capability, $parameter = null)
{
$capability = Horde_String::upper($capability);
if (!isset($this->_data[$capability])) {
return false;
}
return is_null($parameter) ?:
(is_array($this->_data[$capability]) &&
in_array(Horde_String::upper($parameter), $this->_data[$capability]));
}
|
[
"public",
"function",
"query",
"(",
"$",
"capability",
",",
"$",
"parameter",
"=",
"null",
")",
"{",
"$",
"capability",
"=",
"Horde_String",
"::",
"upper",
"(",
"$",
"capability",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"is_null",
"(",
"$",
"parameter",
")",
"?",
":",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
"&&",
"in_array",
"(",
"Horde_String",
"::",
"upper",
"(",
"$",
"parameter",
")",
",",
"$",
"this",
"->",
"_data",
"[",
"$",
"capability",
"]",
")",
")",
";",
"}"
] |
Returns whether the server supports the given capability.
@param string $capability The capability string to query.
@param string $parameter If set, require the parameter to exist.
@return boolean True if the capability (and parameter) exist.
|
[
"Returns",
"whether",
"the",
"server",
"supports",
"the",
"given",
"capability",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Capability.php#L111-L122
|
217,042
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Data/Capability.php
|
Horde_Imap_Client_Data_Capability.getParams
|
public function getParams($capability)
{
return ($this->query($capability) && is_array($out = $this->_data[Horde_String::upper($capability)]))
? $out
: array();
}
|
php
|
public function getParams($capability)
{
return ($this->query($capability) && is_array($out = $this->_data[Horde_String::upper($capability)]))
? $out
: array();
}
|
[
"public",
"function",
"getParams",
"(",
"$",
"capability",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"query",
"(",
"$",
"capability",
")",
"&&",
"is_array",
"(",
"$",
"out",
"=",
"$",
"this",
"->",
"_data",
"[",
"Horde_String",
"::",
"upper",
"(",
"$",
"capability",
")",
"]",
")",
")",
"?",
"$",
"out",
":",
"array",
"(",
")",
";",
"}"
] |
Return the list of parameters for an extension.
@param string $capability The capability string to query.
@return array An array of parameters if the extension exists and
supports parameters. Otherwise, an empty array.
|
[
"Return",
"the",
"list",
"of",
"parameters",
"for",
"an",
"extension",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/Capability.php#L132-L137
|
217,043
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.add
|
public function add($data, $reset = false)
{
if ($reset) {
$pos = $this->pos();
}
if (is_resource($data)) {
$dpos = ftell($data);
while (!feof($data)) {
$this->add(fread($data, 8192));
}
fseek($data, $dpos);
} elseif ($data instanceof Horde_Stream) {
$dpos = $data->pos();
while (!$data->eof()) {
$this->add($data->substring(0, 65536));
}
$data->seek($dpos, false);
} else {
fwrite($this->stream, $data);
}
if ($reset) {
$this->seek($pos, false);
}
}
|
php
|
public function add($data, $reset = false)
{
if ($reset) {
$pos = $this->pos();
}
if (is_resource($data)) {
$dpos = ftell($data);
while (!feof($data)) {
$this->add(fread($data, 8192));
}
fseek($data, $dpos);
} elseif ($data instanceof Horde_Stream) {
$dpos = $data->pos();
while (!$data->eof()) {
$this->add($data->substring(0, 65536));
}
$data->seek($dpos, false);
} else {
fwrite($this->stream, $data);
}
if ($reset) {
$this->seek($pos, false);
}
}
|
[
"public",
"function",
"add",
"(",
"$",
"data",
",",
"$",
"reset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"}",
"if",
"(",
"is_resource",
"(",
"$",
"data",
")",
")",
"{",
"$",
"dpos",
"=",
"ftell",
"(",
"$",
"data",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"fread",
"(",
"$",
"data",
",",
"8192",
")",
")",
";",
"}",
"fseek",
"(",
"$",
"data",
",",
"$",
"dpos",
")",
";",
"}",
"elseif",
"(",
"$",
"data",
"instanceof",
"Horde_Stream",
")",
"{",
"$",
"dpos",
"=",
"$",
"data",
"->",
"pos",
"(",
")",
";",
"while",
"(",
"!",
"$",
"data",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"data",
"->",
"substring",
"(",
"0",
",",
"65536",
")",
")",
";",
"}",
"$",
"data",
"->",
"seek",
"(",
"$",
"dpos",
",",
"false",
")",
";",
"}",
"else",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"data",
")",
";",
"}",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"seek",
"(",
"$",
"pos",
",",
"false",
")",
";",
"}",
"}"
] |
Adds data to the stream.
@param mixed $data Data to add to the stream. Can be a resource,
Horde_Stream object, or a string(-ish) value.
@param boolean $reset Reset stream pointer to initial position after
adding?
|
[
"Adds",
"data",
"to",
"the",
"stream",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L124-L149
|
217,044
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.length
|
public function length($utf8 = false)
{
$pos = $this->pos();
if ($utf8 && $this->_utf8_char) {
$this->rewind();
$len = 0;
while ($this->getChar() !== false) {
++$len;
}
} elseif (!$this->end()) {
throw new Horde_Stream_Exception('ERROR');
} else {
$len = $this->pos();
}
if (!$this->seek($pos, false)) {
throw new Horde_Stream_Exception('ERROR');
}
return $len;
}
|
php
|
public function length($utf8 = false)
{
$pos = $this->pos();
if ($utf8 && $this->_utf8_char) {
$this->rewind();
$len = 0;
while ($this->getChar() !== false) {
++$len;
}
} elseif (!$this->end()) {
throw new Horde_Stream_Exception('ERROR');
} else {
$len = $this->pos();
}
if (!$this->seek($pos, false)) {
throw new Horde_Stream_Exception('ERROR');
}
return $len;
}
|
[
"public",
"function",
"length",
"(",
"$",
"utf8",
"=",
"false",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"if",
"(",
"$",
"utf8",
"&&",
"$",
"this",
"->",
"_utf8_char",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"len",
"=",
"0",
";",
"while",
"(",
"$",
"this",
"->",
"getChar",
"(",
")",
"!==",
"false",
")",
"{",
"++",
"$",
"len",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"end",
"(",
")",
")",
"{",
"throw",
"new",
"Horde_Stream_Exception",
"(",
"'ERROR'",
")",
";",
"}",
"else",
"{",
"$",
"len",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"seek",
"(",
"$",
"pos",
",",
"false",
")",
")",
"{",
"throw",
"new",
"Horde_Stream_Exception",
"(",
"'ERROR'",
")",
";",
"}",
"return",
"$",
"len",
";",
"}"
] |
Returns the length of the data. Does not change the stream position.
@param boolean $utf8 If true, determines the UTF-8 length of the
stream (as of 1.4.0). If false, determines the
byte length of the stream.
@return integer Stream size.
@throws Horde_Stream_Exception
|
[
"Returns",
"the",
"length",
"of",
"the",
"data",
".",
"Does",
"not",
"change",
"the",
"stream",
"position",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L162-L183
|
217,045
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.substring
|
public function substring($start = 0, $length = null, $char = false)
{
if ($start !== 0) {
$this->seek($start, true, $char);
}
$out = '';
$to_end = is_null($length);
/* If length is greater than remaining stream, use more efficient
* algorithm below. Also, if doing a negative length, deal with that
* below also. */
if ($char &&
$this->_utf8_char &&
!$to_end &&
($length >= 0) &&
($length < ($this->length() - $this->pos()))) {
while ($length-- && (($char = $this->getChar()) !== false)) {
$out .= $char;
}
return $out;
}
if (!$to_end && ($length < 0)) {
$pos = $this->pos();
$this->end();
$this->seek($length, true, $char);
$length = $this->pos() - $pos;
$this->seek($pos, false);
if ($length < 0) {
return '';
}
}
while (!feof($this->stream) && ($to_end || $length)) {
$read = fread($this->stream, $to_end ? 16384 : $length);
$out .= $read;
if (!$to_end) {
$length -= strlen($read);
}
}
return $out;
}
|
php
|
public function substring($start = 0, $length = null, $char = false)
{
if ($start !== 0) {
$this->seek($start, true, $char);
}
$out = '';
$to_end = is_null($length);
/* If length is greater than remaining stream, use more efficient
* algorithm below. Also, if doing a negative length, deal with that
* below also. */
if ($char &&
$this->_utf8_char &&
!$to_end &&
($length >= 0) &&
($length < ($this->length() - $this->pos()))) {
while ($length-- && (($char = $this->getChar()) !== false)) {
$out .= $char;
}
return $out;
}
if (!$to_end && ($length < 0)) {
$pos = $this->pos();
$this->end();
$this->seek($length, true, $char);
$length = $this->pos() - $pos;
$this->seek($pos, false);
if ($length < 0) {
return '';
}
}
while (!feof($this->stream) && ($to_end || $length)) {
$read = fread($this->stream, $to_end ? 16384 : $length);
$out .= $read;
if (!$to_end) {
$length -= strlen($read);
}
}
return $out;
}
|
[
"public",
"function",
"substring",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"length",
"=",
"null",
",",
"$",
"char",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"start",
"!==",
"0",
")",
"{",
"$",
"this",
"->",
"seek",
"(",
"$",
"start",
",",
"true",
",",
"$",
"char",
")",
";",
"}",
"$",
"out",
"=",
"''",
";",
"$",
"to_end",
"=",
"is_null",
"(",
"$",
"length",
")",
";",
"/* If length is greater than remaining stream, use more efficient\n * algorithm below. Also, if doing a negative length, deal with that\n * below also. */",
"if",
"(",
"$",
"char",
"&&",
"$",
"this",
"->",
"_utf8_char",
"&&",
"!",
"$",
"to_end",
"&&",
"(",
"$",
"length",
">=",
"0",
")",
"&&",
"(",
"$",
"length",
"<",
"(",
"$",
"this",
"->",
"length",
"(",
")",
"-",
"$",
"this",
"->",
"pos",
"(",
")",
")",
")",
")",
"{",
"while",
"(",
"$",
"length",
"--",
"&&",
"(",
"(",
"$",
"char",
"=",
"$",
"this",
"->",
"getChar",
"(",
")",
")",
"!==",
"false",
")",
")",
"{",
"$",
"out",
".=",
"$",
"char",
";",
"}",
"return",
"$",
"out",
";",
"}",
"if",
"(",
"!",
"$",
"to_end",
"&&",
"(",
"$",
"length",
"<",
"0",
")",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"$",
"this",
"->",
"end",
"(",
")",
";",
"$",
"this",
"->",
"seek",
"(",
"$",
"length",
",",
"true",
",",
"$",
"char",
")",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
"-",
"$",
"pos",
";",
"$",
"this",
"->",
"seek",
"(",
"$",
"pos",
",",
"false",
")",
";",
"if",
"(",
"$",
"length",
"<",
"0",
")",
"{",
"return",
"''",
";",
"}",
"}",
"while",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"stream",
")",
"&&",
"(",
"$",
"to_end",
"||",
"$",
"length",
")",
")",
"{",
"$",
"read",
"=",
"fread",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"to_end",
"?",
"16384",
":",
"$",
"length",
")",
";",
"$",
"out",
".=",
"$",
"read",
";",
"if",
"(",
"!",
"$",
"to_end",
")",
"{",
"$",
"length",
"-=",
"strlen",
"(",
"$",
"read",
")",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
Return part of the stream as a string.
@since 1.4.0
@param integer $start Start, as an offset from the current postion.
@param integer $length Length of string to return. If null, returns
rest of the stream. If negative, this many
characters will be omitted from the end of the
stream.
@param boolean $char If true, $start/$length is the length in
characters. If false, $start/$length is the
length in bytes.
@return string The substring.
|
[
"Return",
"part",
"of",
"the",
"stream",
"as",
"a",
"string",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L367-L410
|
217,046
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.getEOL
|
public function getEOL()
{
$pos = $this->pos();
$this->rewind();
$pos2 = $this->search("\n", false, false);
if ($pos2) {
$this->seek(-1);
$eol = ($this->getChar() == "\r")
? "\r\n"
: "\n";
} else {
$eol = is_null($pos2)
? null
: "\n";
}
$this->seek($pos, false);
return $eol;
}
|
php
|
public function getEOL()
{
$pos = $this->pos();
$this->rewind();
$pos2 = $this->search("\n", false, false);
if ($pos2) {
$this->seek(-1);
$eol = ($this->getChar() == "\r")
? "\r\n"
: "\n";
} else {
$eol = is_null($pos2)
? null
: "\n";
}
$this->seek($pos, false);
return $eol;
}
|
[
"public",
"function",
"getEOL",
"(",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"pos2",
"=",
"$",
"this",
"->",
"search",
"(",
"\"\\n\"",
",",
"false",
",",
"false",
")",
";",
"if",
"(",
"$",
"pos2",
")",
"{",
"$",
"this",
"->",
"seek",
"(",
"-",
"1",
")",
";",
"$",
"eol",
"=",
"(",
"$",
"this",
"->",
"getChar",
"(",
")",
"==",
"\"\\r\"",
")",
"?",
"\"\\r\\n\"",
":",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"eol",
"=",
"is_null",
"(",
"$",
"pos2",
")",
"?",
"null",
":",
"\"\\n\"",
";",
"}",
"$",
"this",
"->",
"seek",
"(",
"$",
"pos",
",",
"false",
")",
";",
"return",
"$",
"eol",
";",
"}"
] |
Auto-determine the EOL string.
@since 1.3.0
@return string The EOL string, or null if no EOL found.
|
[
"Auto",
"-",
"determine",
"the",
"EOL",
"string",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L419-L439
|
217,047
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.getChar
|
public function getChar()
{
$char = fgetc($this->stream);
if (!$this->_utf8_char) {
return $char;
}
$c = ord($char);
if ($c < 0x80) {
return $char;
}
if ($c < 0xe0) {
$n = 1;
} elseif ($c < 0xf0) {
$n = 2;
} elseif ($c < 0xf8) {
$n = 3;
} else {
throw new Horde_Stream_Exception('ERROR');
}
for ($i = 0; $i < $n; ++$i) {
if (($c = fgetc($this->stream)) === false) {
throw new Horde_Stream_Exception('ERROR');
}
$char .= $c;
}
return $char;
}
|
php
|
public function getChar()
{
$char = fgetc($this->stream);
if (!$this->_utf8_char) {
return $char;
}
$c = ord($char);
if ($c < 0x80) {
return $char;
}
if ($c < 0xe0) {
$n = 1;
} elseif ($c < 0xf0) {
$n = 2;
} elseif ($c < 0xf8) {
$n = 3;
} else {
throw new Horde_Stream_Exception('ERROR');
}
for ($i = 0; $i < $n; ++$i) {
if (($c = fgetc($this->stream)) === false) {
throw new Horde_Stream_Exception('ERROR');
}
$char .= $c;
}
return $char;
}
|
[
"public",
"function",
"getChar",
"(",
")",
"{",
"$",
"char",
"=",
"fgetc",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_utf8_char",
")",
"{",
"return",
"$",
"char",
";",
"}",
"$",
"c",
"=",
"ord",
"(",
"$",
"char",
")",
";",
"if",
"(",
"$",
"c",
"<",
"0x80",
")",
"{",
"return",
"$",
"char",
";",
"}",
"if",
"(",
"$",
"c",
"<",
"0xe0",
")",
"{",
"$",
"n",
"=",
"1",
";",
"}",
"elseif",
"(",
"$",
"c",
"<",
"0xf0",
")",
"{",
"$",
"n",
"=",
"2",
";",
"}",
"elseif",
"(",
"$",
"c",
"<",
"0xf8",
")",
"{",
"$",
"n",
"=",
"3",
";",
"}",
"else",
"{",
"throw",
"new",
"Horde_Stream_Exception",
"(",
"'ERROR'",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"n",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"(",
"$",
"c",
"=",
"fgetc",
"(",
"$",
"this",
"->",
"stream",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Horde_Stream_Exception",
"(",
"'ERROR'",
")",
";",
"}",
"$",
"char",
".=",
"$",
"c",
";",
"}",
"return",
"$",
"char",
";",
"}"
] |
Return a character from the string.
@since 1.4.0
@return string Character (single byte, or UTF-8 character if
$utf8_char is true).
|
[
"Return",
"a",
"character",
"from",
"the",
"string",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L449-L479
|
217,048
|
moodle/moodle
|
lib/horde/framework/Horde/Stream.php
|
Horde_Stream.seek
|
public function seek($offset = 0, $curr = true, $char = false)
{
if (!$offset) {
return (bool)$curr ?: $this->rewind();
}
if ($offset < 0) {
if (!$curr) {
return true;
} elseif (abs($offset) > $this->pos()) {
return $this->rewind();
}
}
if ($char && $this->_utf8_char) {
if ($offset > 0) {
if (!$curr) {
$this->rewind();
}
do {
$this->getChar();
} while (--$offset);
} else {
$pos = $this->pos();
$offset = abs($offset);
while ($pos-- && $offset) {
fseek($this->stream, -1, SEEK_CUR);
if ((ord($this->peek()) & 0xC0) != 0x80) {
--$offset;
}
}
}
return true;
}
return (fseek($this->stream, $offset, $curr ? SEEK_CUR : SEEK_SET) === 0);
}
|
php
|
public function seek($offset = 0, $curr = true, $char = false)
{
if (!$offset) {
return (bool)$curr ?: $this->rewind();
}
if ($offset < 0) {
if (!$curr) {
return true;
} elseif (abs($offset) > $this->pos()) {
return $this->rewind();
}
}
if ($char && $this->_utf8_char) {
if ($offset > 0) {
if (!$curr) {
$this->rewind();
}
do {
$this->getChar();
} while (--$offset);
} else {
$pos = $this->pos();
$offset = abs($offset);
while ($pos-- && $offset) {
fseek($this->stream, -1, SEEK_CUR);
if ((ord($this->peek()) & 0xC0) != 0x80) {
--$offset;
}
}
}
return true;
}
return (fseek($this->stream, $offset, $curr ? SEEK_CUR : SEEK_SET) === 0);
}
|
[
"public",
"function",
"seek",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"curr",
"=",
"true",
",",
"$",
"char",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"offset",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"curr",
"?",
":",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"if",
"(",
"$",
"offset",
"<",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"curr",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"abs",
"(",
"$",
"offset",
")",
">",
"$",
"this",
"->",
"pos",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"char",
"&&",
"$",
"this",
"->",
"_utf8_char",
")",
"{",
"if",
"(",
"$",
"offset",
">",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"curr",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"do",
"{",
"$",
"this",
"->",
"getChar",
"(",
")",
";",
"}",
"while",
"(",
"--",
"$",
"offset",
")",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"pos",
"(",
")",
";",
"$",
"offset",
"=",
"abs",
"(",
"$",
"offset",
")",
";",
"while",
"(",
"$",
"pos",
"--",
"&&",
"$",
"offset",
")",
"{",
"fseek",
"(",
"$",
"this",
"->",
"stream",
",",
"-",
"1",
",",
"SEEK_CUR",
")",
";",
"if",
"(",
"(",
"ord",
"(",
"$",
"this",
"->",
"peek",
"(",
")",
")",
"&",
"0xC0",
")",
"!=",
"0x80",
")",
"{",
"--",
"$",
"offset",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"(",
"fseek",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"offset",
",",
"$",
"curr",
"?",
"SEEK_CUR",
":",
"SEEK_SET",
")",
"===",
"0",
")",
";",
"}"
] |
Move internal pointer.
@since 1.4.0
@param integer $offset The offset.
@param boolean $curr If true, offset is from current position. If
false, offset is from beginning of stream.
@param boolean $char If true, $offset is the length in characters.
If false, $offset is the length in bytes.
@return boolean True if successful.
|
[
"Move",
"internal",
"pointer",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Stream.php#L518-L557
|
217,049
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.get_next_question_id
|
public function get_next_question_id($categoryid, $includesubcategories, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
if (empty($this->availablequestionscache[$categorykey])) {
return null;
}
reset($this->availablequestionscache[$categorykey]);
$lowestcount = key($this->availablequestionscache[$categorykey]);
reset($this->availablequestionscache[$categorykey][$lowestcount]);
$questionid = key($this->availablequestionscache[$categorykey][$lowestcount]);
$this->use_question($questionid);
return $questionid;
}
|
php
|
public function get_next_question_id($categoryid, $includesubcategories, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
if (empty($this->availablequestionscache[$categorykey])) {
return null;
}
reset($this->availablequestionscache[$categorykey]);
$lowestcount = key($this->availablequestionscache[$categorykey]);
reset($this->availablequestionscache[$categorykey][$lowestcount]);
$questionid = key($this->availablequestionscache[$categorykey][$lowestcount]);
$this->use_question($questionid);
return $questionid;
}
|
[
"public",
"function",
"get_next_question_id",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensure_questions_for_category_loaded",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"$",
"categorykey",
"=",
"$",
"this",
"->",
"get_category_key",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"reset",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
")",
";",
"$",
"lowestcount",
"=",
"key",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
")",
";",
"reset",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"[",
"$",
"lowestcount",
"]",
")",
";",
"$",
"questionid",
"=",
"key",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"[",
"$",
"lowestcount",
"]",
")",
";",
"$",
"this",
"->",
"use_question",
"(",
"$",
"questionid",
")",
";",
"return",
"$",
"questionid",
";",
"}"
] |
Pick a question at random from the given category, from among those with the fewest uses.
If an array of tag ids are specified, then only the questions that are tagged with ALL those tags will be selected.
It is up the the caller to verify that the cateogry exists. An unknown category
behaves like an empty one.
@param int $categoryid the id of a category in the question bank.
@param bool $includesubcategories wether to pick a question from exactly
that category, or that category and subcategories.
@param array $tagids An array of tag ids. A question has to be tagged with all the provided tagids (if any)
in order to be eligible for being picked.
@return int|null the id of the question picked, or null if there aren't any.
|
[
"Pick",
"a",
"question",
"at",
"random",
"from",
"the",
"given",
"category",
"from",
"among",
"those",
"with",
"the",
"fewest",
"uses",
".",
"If",
"an",
"array",
"of",
"tag",
"ids",
"are",
"specified",
"then",
"only",
"the",
"questions",
"that",
"are",
"tagged",
"with",
"ALL",
"those",
"tags",
"will",
"be",
"selected",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L92-L106
|
217,050
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.use_question
|
protected function use_question($questionid) {
if (isset($this->recentlyusedquestions[$questionid])) {
$this->recentlyusedquestions[$questionid] += 1;
} else {
$this->recentlyusedquestions[$questionid] = 1;
}
foreach ($this->availablequestionscache as $categorykey => $questionsforcategory) {
foreach ($questionsforcategory as $numuses => $questionids) {
if (!isset($questionids[$questionid])) {
continue;
}
unset($this->availablequestionscache[$categorykey][$numuses][$questionid]);
if (empty($this->availablequestionscache[$categorykey][$numuses])) {
unset($this->availablequestionscache[$categorykey][$numuses]);
}
}
}
}
|
php
|
protected function use_question($questionid) {
if (isset($this->recentlyusedquestions[$questionid])) {
$this->recentlyusedquestions[$questionid] += 1;
} else {
$this->recentlyusedquestions[$questionid] = 1;
}
foreach ($this->availablequestionscache as $categorykey => $questionsforcategory) {
foreach ($questionsforcategory as $numuses => $questionids) {
if (!isset($questionids[$questionid])) {
continue;
}
unset($this->availablequestionscache[$categorykey][$numuses][$questionid]);
if (empty($this->availablequestionscache[$categorykey][$numuses])) {
unset($this->availablequestionscache[$categorykey][$numuses]);
}
}
}
}
|
[
"protected",
"function",
"use_question",
"(",
"$",
"questionid",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"recentlyusedquestions",
"[",
"$",
"questionid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"recentlyusedquestions",
"[",
"$",
"questionid",
"]",
"+=",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"recentlyusedquestions",
"[",
"$",
"questionid",
"]",
"=",
"1",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"availablequestionscache",
"as",
"$",
"categorykey",
"=>",
"$",
"questionsforcategory",
")",
"{",
"foreach",
"(",
"$",
"questionsforcategory",
"as",
"$",
"numuses",
"=>",
"$",
"questionids",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"questionids",
"[",
"$",
"questionid",
"]",
")",
")",
"{",
"continue",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"[",
"$",
"numuses",
"]",
"[",
"$",
"questionid",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"[",
"$",
"numuses",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"[",
"$",
"numuses",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
Update the internal data structures to indicate that a given question has
been used one more time.
@param int $questionid the question that is being used.
|
[
"Update",
"the",
"internal",
"data",
"structures",
"to",
"indicate",
"that",
"a",
"given",
"question",
"has",
"been",
"used",
"one",
"more",
"time",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L193-L211
|
217,051
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.get_question_ids
|
protected function get_question_ids($categoryid, $includesubcategories, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
$cachedvalues = $this->availablequestionscache[$categorykey];
$questionids = [];
foreach ($cachedvalues as $usecount => $ids) {
$questionids = array_merge($questionids, array_keys($ids));
}
return $questionids;
}
|
php
|
protected function get_question_ids($categoryid, $includesubcategories, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
$cachedvalues = $this->availablequestionscache[$categorykey];
$questionids = [];
foreach ($cachedvalues as $usecount => $ids) {
$questionids = array_merge($questionids, array_keys($ids));
}
return $questionids;
}
|
[
"protected",
"function",
"get_question_ids",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensure_questions_for_category_loaded",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"$",
"categorykey",
"=",
"$",
"this",
"->",
"get_category_key",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"$",
"cachedvalues",
"=",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
";",
"$",
"questionids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cachedvalues",
"as",
"$",
"usecount",
"=>",
"$",
"ids",
")",
"{",
"$",
"questionids",
"=",
"array_merge",
"(",
"$",
"questionids",
",",
"array_keys",
"(",
"$",
"ids",
")",
")",
";",
"}",
"return",
"$",
"questionids",
";",
"}"
] |
Get the list of available question ids for the given criteria.
@param int $categoryid The id of a category in the question bank.
@param bool $includesubcategories Whether to pick a question from exactly
that category, or that category and subcategories.
@param array $tagids An array of tag ids. If an array is provided, then
only the questions that are tagged with ALL the provided tagids will be loaded.
@return int[] The list of question ids
|
[
"Get",
"the",
"list",
"of",
"available",
"question",
"ids",
"for",
"the",
"given",
"criteria",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L223-L234
|
217,052
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.is_question_available
|
public function is_question_available($categoryid, $includesubcategories, $questionid, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
foreach ($this->availablequestionscache[$categorykey] as $questionids) {
if (isset($questionids[$questionid])) {
$this->use_question($questionid);
return true;
}
}
return false;
}
|
php
|
public function is_question_available($categoryid, $includesubcategories, $questionid, $tagids = []) {
$this->ensure_questions_for_category_loaded($categoryid, $includesubcategories, $tagids);
$categorykey = $this->get_category_key($categoryid, $includesubcategories, $tagids);
foreach ($this->availablequestionscache[$categorykey] as $questionids) {
if (isset($questionids[$questionid])) {
$this->use_question($questionid);
return true;
}
}
return false;
}
|
[
"public",
"function",
"is_question_available",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"questionid",
",",
"$",
"tagids",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensure_questions_for_category_loaded",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"$",
"categorykey",
"=",
"$",
"this",
"->",
"get_category_key",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"availablequestionscache",
"[",
"$",
"categorykey",
"]",
"as",
"$",
"questionids",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"questionids",
"[",
"$",
"questionid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"use_question",
"(",
"$",
"questionid",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check whether a given question is available in a given category. If so, mark it used.
If an optional list of tag ids are provided, then the question must be tagged with
ALL of the provided tags to be considered as available.
@param int $categoryid the id of a category in the question bank.
@param bool $includesubcategories wether to pick a question from exactly
that category, or that category and subcategories.
@param int $questionid the question that is being used.
@param array $tagids An array of tag ids. Only the questions that are tagged with all the provided tagids can be available.
@return bool whether the question is available in the requested category.
|
[
"Check",
"whether",
"a",
"given",
"question",
"is",
"available",
"in",
"a",
"given",
"category",
".",
"If",
"so",
"mark",
"it",
"used",
".",
"If",
"an",
"optional",
"list",
"of",
"tag",
"ids",
"are",
"provided",
"then",
"the",
"question",
"must",
"be",
"tagged",
"with",
"ALL",
"of",
"the",
"provided",
"tags",
"to",
"be",
"considered",
"as",
"available",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L248-L260
|
217,053
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.get_questions
|
public function get_questions(
$categoryid,
$includesubcategories,
$tagids = [],
$limit = 100,
$offset = 0,
$fields = []
) {
global $DB;
$questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
if (empty($questionids)) {
return [];
}
if (empty($fields)) {
// Return all fields.
$fieldsstring = '*';
} else {
$fieldsstring = implode(',', $fields);
}
return $DB->get_records_list(
'question',
'id',
$questionids,
'id',
$fieldsstring,
$offset,
$limit
);
}
|
php
|
public function get_questions(
$categoryid,
$includesubcategories,
$tagids = [],
$limit = 100,
$offset = 0,
$fields = []
) {
global $DB;
$questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
if (empty($questionids)) {
return [];
}
if (empty($fields)) {
// Return all fields.
$fieldsstring = '*';
} else {
$fieldsstring = implode(',', $fields);
}
return $DB->get_records_list(
'question',
'id',
$questionids,
'id',
$fieldsstring,
$offset,
$limit
);
}
|
[
"public",
"function",
"get_questions",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
"=",
"[",
"]",
",",
"$",
"limit",
"=",
"100",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"questionids",
"=",
"$",
"this",
"->",
"get_question_ids",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"questionids",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"// Return all fields.",
"$",
"fieldsstring",
"=",
"'*'",
";",
"}",
"else",
"{",
"$",
"fieldsstring",
"=",
"implode",
"(",
"','",
",",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"DB",
"->",
"get_records_list",
"(",
"'question'",
",",
"'id'",
",",
"$",
"questionids",
",",
"'id'",
",",
"$",
"fieldsstring",
",",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"}"
] |
Get the list of available questions for the given criteria.
@param int $categoryid The id of a category in the question bank.
@param bool $includesubcategories Whether to pick a question from exactly
that category, or that category and subcategories.
@param array $tagids An array of tag ids. If an array is provided, then
only the questions that are tagged with ALL the provided tagids will be loaded.
@param int $limit Maximum number of results to return.
@param int $offset Number of items to skip from the begging of the result set.
@param string[] $fields The fields to return for each question.
@return \stdClass[] The list of question records
|
[
"Get",
"the",
"list",
"of",
"available",
"questions",
"for",
"the",
"given",
"criteria",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L275-L306
|
217,054
|
moodle/moodle
|
question/classes/bank/random_question_loader.php
|
random_question_loader.count_questions
|
public function count_questions($categoryid, $includesubcategories, $tagids = []) {
$questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
return count($questionids);
}
|
php
|
public function count_questions($categoryid, $includesubcategories, $tagids = []) {
$questionids = $this->get_question_ids($categoryid, $includesubcategories, $tagids);
return count($questionids);
}
|
[
"public",
"function",
"count_questions",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
"=",
"[",
"]",
")",
"{",
"$",
"questionids",
"=",
"$",
"this",
"->",
"get_question_ids",
"(",
"$",
"categoryid",
",",
"$",
"includesubcategories",
",",
"$",
"tagids",
")",
";",
"return",
"count",
"(",
"$",
"questionids",
")",
";",
"}"
] |
Count the number of available questions for the given criteria.
@param int $categoryid The id of a category in the question bank.
@param bool $includesubcategories Whether to pick a question from exactly
that category, or that category and subcategories.
@param array $tagids An array of tag ids. If an array is provided, then
only the questions that are tagged with ALL the provided tagids will be loaded.
@return int The number of questions matching the criteria.
|
[
"Count",
"the",
"number",
"of",
"available",
"questions",
"for",
"the",
"given",
"criteria",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/random_question_loader.php#L318-L321
|
217,055
|
moodle/moodle
|
auth/cas/CAS/CAS/ProxyChain/AllowedList.php
|
CAS_ProxyChain_AllowedList.isProxyListAllowed
|
public function isProxyListAllowed(array $proxies)
{
phpCAS::traceBegin();
if (empty($proxies)) {
phpCAS::trace("No proxies were found in the response");
phpCAS::traceEnd(true);
return true;
} elseif (!$this->isProxyingAllowed()) {
phpCAS::trace("Proxies are not allowed");
phpCAS::traceEnd(false);
return false;
} else {
$res = $this->contains($proxies);
phpCAS::traceEnd($res);
return $res;
}
}
|
php
|
public function isProxyListAllowed(array $proxies)
{
phpCAS::traceBegin();
if (empty($proxies)) {
phpCAS::trace("No proxies were found in the response");
phpCAS::traceEnd(true);
return true;
} elseif (!$this->isProxyingAllowed()) {
phpCAS::trace("Proxies are not allowed");
phpCAS::traceEnd(false);
return false;
} else {
$res = $this->contains($proxies);
phpCAS::traceEnd($res);
return $res;
}
}
|
[
"public",
"function",
"isProxyListAllowed",
"(",
"array",
"$",
"proxies",
")",
"{",
"phpCAS",
"::",
"traceBegin",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"proxies",
")",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"No proxies were found in the response\"",
")",
";",
"phpCAS",
"::",
"traceEnd",
"(",
"true",
")",
";",
"return",
"true",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"isProxyingAllowed",
"(",
")",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Proxies are not allowed\"",
")",
";",
"phpCAS",
"::",
"traceEnd",
"(",
"false",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"contains",
"(",
"$",
"proxies",
")",
";",
"phpCAS",
"::",
"traceEnd",
"(",
"$",
"res",
")",
";",
"return",
"$",
"res",
";",
"}",
"}"
] |
Check if the proxies found in the response match the allowed proxies
@param array $proxies list of proxies to check
@return bool whether the proxies match the allowed proxies
|
[
"Check",
"if",
"the",
"proxies",
"found",
"in",
"the",
"response",
"match",
"the",
"allowed",
"proxies"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/ProxyChain/AllowedList.php#L77-L93
|
217,056
|
moodle/moodle
|
auth/cas/CAS/CAS/ProxyChain/AllowedList.php
|
CAS_ProxyChain_AllowedList.contains
|
public function contains(array $list)
{
phpCAS::traceBegin();
$count = 0;
foreach ($this->_chains as $chain) {
phpCAS::trace("Checking chain ". $count++);
if ($chain->matches($list)) {
phpCAS::traceEnd(true);
return true;
}
}
phpCAS::trace("No proxy chain matches.");
phpCAS::traceEnd(false);
return false;
}
|
php
|
public function contains(array $list)
{
phpCAS::traceBegin();
$count = 0;
foreach ($this->_chains as $chain) {
phpCAS::trace("Checking chain ". $count++);
if ($chain->matches($list)) {
phpCAS::traceEnd(true);
return true;
}
}
phpCAS::trace("No proxy chain matches.");
phpCAS::traceEnd(false);
return false;
}
|
[
"public",
"function",
"contains",
"(",
"array",
"$",
"list",
")",
"{",
"phpCAS",
"::",
"traceBegin",
"(",
")",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"_chains",
"as",
"$",
"chain",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Checking chain \"",
".",
"$",
"count",
"++",
")",
";",
"if",
"(",
"$",
"chain",
"->",
"matches",
"(",
"$",
"list",
")",
")",
"{",
"phpCAS",
"::",
"traceEnd",
"(",
"true",
")",
";",
"return",
"true",
";",
"}",
"}",
"phpCAS",
"::",
"trace",
"(",
"\"No proxy chain matches.\"",
")",
";",
"phpCAS",
"::",
"traceEnd",
"(",
"false",
")",
";",
"return",
"false",
";",
"}"
] |
Validate the proxies from the proxy ticket validation against the
chains that were definded.
@param array $list List of proxies from the proxy ticket validation.
@return if any chain fully matches the supplied list
|
[
"Validate",
"the",
"proxies",
"from",
"the",
"proxy",
"ticket",
"validation",
"against",
"the",
"chains",
"that",
"were",
"definded",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/ProxyChain/AllowedList.php#L103-L117
|
217,057
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.get_columns
|
public function get_columns() {
if (isset($this->_columns)) {
return $this->_columns;
}
global $USER, $CFG;
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
$fp = fopen($filename, "r");
$line = fgetcsv($fp);
fclose($fp);
if ($line === false) {
return false;
}
$this->_columns = $line;
return $this->_columns;
}
|
php
|
public function get_columns() {
if (isset($this->_columns)) {
return $this->_columns;
}
global $USER, $CFG;
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
$fp = fopen($filename, "r");
$line = fgetcsv($fp);
fclose($fp);
if ($line === false) {
return false;
}
$this->_columns = $line;
return $this->_columns;
}
|
[
"public",
"function",
"get_columns",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_columns",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_columns",
";",
"}",
"global",
"$",
"USER",
",",
"$",
"CFG",
";",
"$",
"filename",
"=",
"$",
"CFG",
"->",
"tempdir",
".",
"'/csvimport/'",
".",
"$",
"this",
"->",
"_type",
".",
"'/'",
".",
"$",
"USER",
"->",
"id",
".",
"'/'",
".",
"$",
"this",
"->",
"_iid",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"r\"",
")",
";",
"$",
"line",
"=",
"fgetcsv",
"(",
"$",
"fp",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"if",
"(",
"$",
"line",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_columns",
"=",
"$",
"line",
";",
"return",
"$",
"this",
"->",
"_columns",
";",
"}"
] |
Returns list of columns
@return array
|
[
"Returns",
"list",
"of",
"columns"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L195-L214
|
217,058
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.init
|
public function init() {
global $CFG, $USER;
if (!empty($this->_fp)) {
$this->close();
}
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
if (!$this->_fp = fopen($filename, "r")) {
return false;
}
//skip header
return (fgetcsv($this->_fp) !== false);
}
|
php
|
public function init() {
global $CFG, $USER;
if (!empty($this->_fp)) {
$this->close();
}
$filename = $CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid;
if (!file_exists($filename)) {
return false;
}
if (!$this->_fp = fopen($filename, "r")) {
return false;
}
//skip header
return (fgetcsv($this->_fp) !== false);
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"CFG",
"->",
"tempdir",
".",
"'/csvimport/'",
".",
"$",
"this",
"->",
"_type",
".",
"'/'",
".",
"$",
"USER",
"->",
"id",
".",
"'/'",
".",
"$",
"this",
"->",
"_iid",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_fp",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"r\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"//skip header",
"return",
"(",
"fgetcsv",
"(",
"$",
"this",
"->",
"_fp",
")",
"!==",
"false",
")",
";",
"}"
] |
Init iterator.
@global object
@global object
@return bool Success
|
[
"Init",
"iterator",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L223-L238
|
217,059
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.next
|
public function next() {
if (empty($this->_fp) or feof($this->_fp)) {
return false;
}
if ($ser = fgetcsv($this->_fp)) {
return $ser;
} else {
return false;
}
}
|
php
|
public function next() {
if (empty($this->_fp) or feof($this->_fp)) {
return false;
}
if ($ser = fgetcsv($this->_fp)) {
return $ser;
} else {
return false;
}
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_fp",
")",
"or",
"feof",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"ser",
"=",
"fgetcsv",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"return",
"$",
"ser",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Get next line
@return mixed false, or an array of values
|
[
"Get",
"next",
"line"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L245-L254
|
217,060
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.close
|
public function close() {
if (!empty($this->_fp)) {
fclose($this->_fp);
$this->_fp = null;
}
}
|
php
|
public function close() {
if (!empty($this->_fp)) {
fclose($this->_fp);
$this->_fp = null;
}
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_fp",
")",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"_fp",
")",
";",
"$",
"this",
"->",
"_fp",
"=",
"null",
";",
"}",
"}"
] |
Release iteration related resources
@return void
|
[
"Release",
"iteration",
"related",
"resources"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L261-L266
|
217,061
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.cleanup
|
public function cleanup($full=false) {
global $USER, $CFG;
if ($full) {
@remove_dir($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id);
} else {
@unlink($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid);
}
}
|
php
|
public function cleanup($full=false) {
global $USER, $CFG;
if ($full) {
@remove_dir($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id);
} else {
@unlink($CFG->tempdir.'/csvimport/'.$this->_type.'/'.$USER->id.'/'.$this->_iid);
}
}
|
[
"public",
"function",
"cleanup",
"(",
"$",
"full",
"=",
"false",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"CFG",
";",
"if",
"(",
"$",
"full",
")",
"{",
"@",
"remove_dir",
"(",
"$",
"CFG",
"->",
"tempdir",
".",
"'/csvimport/'",
".",
"$",
"this",
"->",
"_type",
".",
"'/'",
".",
"$",
"USER",
"->",
"id",
")",
";",
"}",
"else",
"{",
"@",
"unlink",
"(",
"$",
"CFG",
"->",
"tempdir",
".",
"'/csvimport/'",
".",
"$",
"this",
"->",
"_type",
".",
"'/'",
".",
"$",
"USER",
"->",
"id",
".",
"'/'",
".",
"$",
"this",
"->",
"_iid",
")",
";",
"}",
"}"
] |
Cleanup temporary data
@global object
@global object
@param boolean $full true means do a full cleanup - all sessions for current user, false only the active iid
|
[
"Cleanup",
"temporary",
"data"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L284-L292
|
217,062
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.get_delimiter_list
|
public static function get_delimiter_list() {
global $CFG;
$delimiters = array('comma'=>',', 'semicolon'=>';', 'colon'=>':', 'tab'=>'\\t');
if (isset($CFG->CSV_DELIMITER) and strlen($CFG->CSV_DELIMITER) === 1 and !in_array($CFG->CSV_DELIMITER, $delimiters)) {
$delimiters['cfg'] = $CFG->CSV_DELIMITER;
}
return $delimiters;
}
|
php
|
public static function get_delimiter_list() {
global $CFG;
$delimiters = array('comma'=>',', 'semicolon'=>';', 'colon'=>':', 'tab'=>'\\t');
if (isset($CFG->CSV_DELIMITER) and strlen($CFG->CSV_DELIMITER) === 1 and !in_array($CFG->CSV_DELIMITER, $delimiters)) {
$delimiters['cfg'] = $CFG->CSV_DELIMITER;
}
return $delimiters;
}
|
[
"public",
"static",
"function",
"get_delimiter_list",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"delimiters",
"=",
"array",
"(",
"'comma'",
"=>",
"','",
",",
"'semicolon'",
"=>",
"';'",
",",
"'colon'",
"=>",
"':'",
",",
"'tab'",
"=>",
"'\\\\t'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"CFG",
"->",
"CSV_DELIMITER",
")",
"and",
"strlen",
"(",
"$",
"CFG",
"->",
"CSV_DELIMITER",
")",
"===",
"1",
"and",
"!",
"in_array",
"(",
"$",
"CFG",
"->",
"CSV_DELIMITER",
",",
"$",
"delimiters",
")",
")",
"{",
"$",
"delimiters",
"[",
"'cfg'",
"]",
"=",
"$",
"CFG",
"->",
"CSV_DELIMITER",
";",
"}",
"return",
"$",
"delimiters",
";",
"}"
] |
Get list of cvs delimiters
@return array suitable for selection box
|
[
"Get",
"list",
"of",
"cvs",
"delimiters"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L299-L306
|
217,063
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.get_encoded_delimiter
|
public static function get_encoded_delimiter($delimiter_name) {
global $CFG;
if ($delimiter_name == 'cfg' and isset($CFG->CSV_ENCODE)) {
return $CFG->CSV_ENCODE;
}
$delimiter = csv_import_reader::get_delimiter($delimiter_name);
return '&#'.ord($delimiter);
}
|
php
|
public static function get_encoded_delimiter($delimiter_name) {
global $CFG;
if ($delimiter_name == 'cfg' and isset($CFG->CSV_ENCODE)) {
return $CFG->CSV_ENCODE;
}
$delimiter = csv_import_reader::get_delimiter($delimiter_name);
return '&#'.ord($delimiter);
}
|
[
"public",
"static",
"function",
"get_encoded_delimiter",
"(",
"$",
"delimiter_name",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"$",
"delimiter_name",
"==",
"'cfg'",
"and",
"isset",
"(",
"$",
"CFG",
"->",
"CSV_ENCODE",
")",
")",
"{",
"return",
"$",
"CFG",
"->",
"CSV_ENCODE",
";",
"}",
"$",
"delimiter",
"=",
"csv_import_reader",
"::",
"get_delimiter",
"(",
"$",
"delimiter_name",
")",
";",
"return",
"'&#'",
".",
"ord",
"(",
"$",
"delimiter",
")",
";",
"}"
] |
Get encoded delimiter character
@global object
@param string separator name
@return string encoded delimiter char
|
[
"Get",
"encoded",
"delimiter",
"character"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L333-L340
|
217,064
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_import_reader.get_new_iid
|
public static function get_new_iid($type) {
global $USER;
$filename = make_temp_directory('csvimport/'.$type.'/'.$USER->id);
// use current (non-conflicting) time stamp
$iiid = time();
while (file_exists($filename.'/'.$iiid)) {
$iiid--;
}
return $iiid;
}
|
php
|
public static function get_new_iid($type) {
global $USER;
$filename = make_temp_directory('csvimport/'.$type.'/'.$USER->id);
// use current (non-conflicting) time stamp
$iiid = time();
while (file_exists($filename.'/'.$iiid)) {
$iiid--;
}
return $iiid;
}
|
[
"public",
"static",
"function",
"get_new_iid",
"(",
"$",
"type",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"filename",
"=",
"make_temp_directory",
"(",
"'csvimport/'",
".",
"$",
"type",
".",
"'/'",
".",
"$",
"USER",
"->",
"id",
")",
";",
"// use current (non-conflicting) time stamp",
"$",
"iiid",
"=",
"time",
"(",
")",
";",
"while",
"(",
"file_exists",
"(",
"$",
"filename",
".",
"'/'",
".",
"$",
"iiid",
")",
")",
"{",
"$",
"iiid",
"--",
";",
"}",
"return",
"$",
"iiid",
";",
"}"
] |
Create new import id
@global object
@param string who imports?
@return int iid
|
[
"Create",
"new",
"import",
"id"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L349-L361
|
217,065
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.set_temp_file_path
|
protected function set_temp_file_path() {
global $USER, $CFG;
make_temp_directory('csvimport/' . $USER->id);
$path = $CFG->tempdir . '/csvimport/' . $USER->id. '/' . $this->filename;
// Check to see if the file exists, if so delete it.
if (file_exists($path)) {
unlink($path);
}
$this->path = $path;
}
|
php
|
protected function set_temp_file_path() {
global $USER, $CFG;
make_temp_directory('csvimport/' . $USER->id);
$path = $CFG->tempdir . '/csvimport/' . $USER->id. '/' . $this->filename;
// Check to see if the file exists, if so delete it.
if (file_exists($path)) {
unlink($path);
}
$this->path = $path;
}
|
[
"protected",
"function",
"set_temp_file_path",
"(",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"CFG",
";",
"make_temp_directory",
"(",
"'csvimport/'",
".",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"path",
"=",
"$",
"CFG",
"->",
"tempdir",
".",
"'/csvimport/'",
".",
"$",
"USER",
"->",
"id",
".",
"'/'",
".",
"$",
"this",
"->",
"filename",
";",
"// Check to see if the file exists, if so delete it.",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"unlink",
"(",
"$",
"path",
")",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"$",
"path",
";",
"}"
] |
Set the file path to the temporary file.
|
[
"Set",
"the",
"file",
"path",
"to",
"the",
"temporary",
"file",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L420-L429
|
217,066
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.add_data
|
public function add_data($row) {
if(!isset($this->path)) {
$this->set_temp_file_path();
$this->fp = fopen($this->path, 'w+');
}
$delimiter = csv_import_reader::get_delimiter($this->delimiter);
fputcsv($this->fp, $row, $delimiter, $this->csvenclosure);
}
|
php
|
public function add_data($row) {
if(!isset($this->path)) {
$this->set_temp_file_path();
$this->fp = fopen($this->path, 'w+');
}
$delimiter = csv_import_reader::get_delimiter($this->delimiter);
fputcsv($this->fp, $row, $delimiter, $this->csvenclosure);
}
|
[
"public",
"function",
"add_data",
"(",
"$",
"row",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"$",
"this",
"->",
"set_temp_file_path",
"(",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"path",
",",
"'w+'",
")",
";",
"}",
"$",
"delimiter",
"=",
"csv_import_reader",
"::",
"get_delimiter",
"(",
"$",
"this",
"->",
"delimiter",
")",
";",
"fputcsv",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"row",
",",
"$",
"delimiter",
",",
"$",
"this",
"->",
"csvenclosure",
")",
";",
"}"
] |
Add data to the temporary file in csv format
@param array $row An array of values.
|
[
"Add",
"data",
"to",
"the",
"temporary",
"file",
"in",
"csv",
"format"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L436-L443
|
217,067
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.print_csv_data
|
public function print_csv_data($return = false) {
fseek($this->fp, 0);
$returnstring = '';
while (($content = fgets($this->fp)) !== false) {
if (!$return){
echo $content;
} else {
$returnstring .= $content;
}
}
if ($return) {
return $returnstring;
}
}
|
php
|
public function print_csv_data($return = false) {
fseek($this->fp, 0);
$returnstring = '';
while (($content = fgets($this->fp)) !== false) {
if (!$return){
echo $content;
} else {
$returnstring .= $content;
}
}
if ($return) {
return $returnstring;
}
}
|
[
"public",
"function",
"print_csv_data",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"fseek",
"(",
"$",
"this",
"->",
"fp",
",",
"0",
")",
";",
"$",
"returnstring",
"=",
"''",
";",
"while",
"(",
"(",
"$",
"content",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"return",
")",
"{",
"echo",
"$",
"content",
";",
"}",
"else",
"{",
"$",
"returnstring",
".=",
"$",
"content",
";",
"}",
"}",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"returnstring",
";",
"}",
"}"
] |
Echos or returns a csv data line by line for displaying.
@param bool $return Set to true to return a string with the csv data.
@return string csv data.
|
[
"Echos",
"or",
"returns",
"a",
"csv",
"data",
"line",
"by",
"line",
"for",
"displaying",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L451-L464
|
217,068
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.set_filename
|
public function set_filename($dataname, $extension = '.csv') {
$filename = clean_filename($dataname);
$filename .= clean_filename('-' . gmdate("Ymd_Hi"));
$filename .= clean_filename("-{$this->delimiter}_separated");
$filename .= $extension;
$this->filename = $filename;
}
|
php
|
public function set_filename($dataname, $extension = '.csv') {
$filename = clean_filename($dataname);
$filename .= clean_filename('-' . gmdate("Ymd_Hi"));
$filename .= clean_filename("-{$this->delimiter}_separated");
$filename .= $extension;
$this->filename = $filename;
}
|
[
"public",
"function",
"set_filename",
"(",
"$",
"dataname",
",",
"$",
"extension",
"=",
"'.csv'",
")",
"{",
"$",
"filename",
"=",
"clean_filename",
"(",
"$",
"dataname",
")",
";",
"$",
"filename",
".=",
"clean_filename",
"(",
"'-'",
".",
"gmdate",
"(",
"\"Ymd_Hi\"",
")",
")",
";",
"$",
"filename",
".=",
"clean_filename",
"(",
"\"-{$this->delimiter}_separated\"",
")",
";",
"$",
"filename",
".=",
"$",
"extension",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"filename",
";",
"}"
] |
Set the filename for the uploaded csv file
@param string $dataname The name of the module.
@param string $extenstion File extension for the file.
|
[
"Set",
"the",
"filename",
"for",
"the",
"uploaded",
"csv",
"file"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L472-L478
|
217,069
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.download_array
|
public static function download_array($filename, array &$records, $delimiter = 'comma', $enclosure='"') {
$csvdata = new csv_export_writer($delimiter, $enclosure);
$csvdata->set_filename($filename);
foreach ($records as $row) {
$csvdata->add_data($row);
}
$csvdata->download_file();
}
|
php
|
public static function download_array($filename, array &$records, $delimiter = 'comma', $enclosure='"') {
$csvdata = new csv_export_writer($delimiter, $enclosure);
$csvdata->set_filename($filename);
foreach ($records as $row) {
$csvdata->add_data($row);
}
$csvdata->download_file();
}
|
[
"public",
"static",
"function",
"download_array",
"(",
"$",
"filename",
",",
"array",
"&",
"$",
"records",
",",
"$",
"delimiter",
"=",
"'comma'",
",",
"$",
"enclosure",
"=",
"'\"'",
")",
"{",
"$",
"csvdata",
"=",
"new",
"csv_export_writer",
"(",
"$",
"delimiter",
",",
"$",
"enclosure",
")",
";",
"$",
"csvdata",
"->",
"set_filename",
"(",
"$",
"filename",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"row",
")",
"{",
"$",
"csvdata",
"->",
"add_data",
"(",
"$",
"row",
")",
";",
"}",
"$",
"csvdata",
"->",
"download_file",
"(",
")",
";",
"}"
] |
Creates a file for downloading an array into a deliminated format.
This function is useful if you are happy with the defaults and all of your
information is in one array.
@param string $filename The filename of the file being created.
@param array $records An array of information to be converted.
@param string $delimiter The name of the delimiter. Supported types(comma, tab, semicolon, colon, cfg)
@param string $enclosure How speical fields are enclosed.
|
[
"Creates",
"a",
"file",
"for",
"downloading",
"an",
"array",
"into",
"a",
"deliminated",
"format",
".",
"This",
"function",
"is",
"useful",
"if",
"you",
"are",
"happy",
"with",
"the",
"defaults",
"and",
"all",
"of",
"your",
"information",
"is",
"in",
"one",
"array",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L521-L528
|
217,070
|
moodle/moodle
|
lib/csvlib.class.php
|
csv_export_writer.print_array
|
public static function print_array(array &$records, $delimiter = 'comma', $enclosure = '"', $return = false) {
$csvdata = new csv_export_writer($delimiter, $enclosure);
foreach ($records as $row) {
$csvdata->add_data($row);
}
$data = $csvdata->print_csv_data($return);
if ($return) {
return $data;
}
}
|
php
|
public static function print_array(array &$records, $delimiter = 'comma', $enclosure = '"', $return = false) {
$csvdata = new csv_export_writer($delimiter, $enclosure);
foreach ($records as $row) {
$csvdata->add_data($row);
}
$data = $csvdata->print_csv_data($return);
if ($return) {
return $data;
}
}
|
[
"public",
"static",
"function",
"print_array",
"(",
"array",
"&",
"$",
"records",
",",
"$",
"delimiter",
"=",
"'comma'",
",",
"$",
"enclosure",
"=",
"'\"'",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"csvdata",
"=",
"new",
"csv_export_writer",
"(",
"$",
"delimiter",
",",
"$",
"enclosure",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"row",
")",
"{",
"$",
"csvdata",
"->",
"add_data",
"(",
"$",
"row",
")",
";",
"}",
"$",
"data",
"=",
"$",
"csvdata",
"->",
"print_csv_data",
"(",
"$",
"return",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"data",
";",
"}",
"}"
] |
This will convert an array of values into a deliminated string.
Like the above function, this is for convenience.
@param array $records An array of information to be converted.
@param string $delimiter The name of the delimiter. Supported types(comma, tab, semicolon, colon, cfg)
@param string $enclosure How speical fields are enclosed.
@param bool $return If true will return a string with the csv data.
@return string csv data.
|
[
"This",
"will",
"convert",
"an",
"array",
"of",
"values",
"into",
"a",
"deliminated",
"string",
".",
"Like",
"the",
"above",
"function",
"this",
"is",
"for",
"convenience",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/csvlib.class.php#L540-L549
|
217,071
|
moodle/moodle
|
question/classes/statistics/responses/analyser.php
|
analyser.calculate
|
public function calculate($qubaids, $whichtries = \question_attempt::LAST_TRY) {
// Load data.
$dm = new \question_engine_data_mapper();
$questionattempts = $dm->load_attempts_at_question($this->questiondata->id, $qubaids);
// Analyse it.
foreach ($questionattempts as $qa) {
$responseparts = $qa->classify_response($whichtries);
if ($this->breakdownbyvariant) {
$this->analysis->count_response_parts($qa->get_variant(), $responseparts);
} else {
$this->analysis->count_response_parts(1, $responseparts);
}
}
$this->analysis->cache($qubaids, $whichtries, $this->questiondata->id);
return $this->analysis;
}
|
php
|
public function calculate($qubaids, $whichtries = \question_attempt::LAST_TRY) {
// Load data.
$dm = new \question_engine_data_mapper();
$questionattempts = $dm->load_attempts_at_question($this->questiondata->id, $qubaids);
// Analyse it.
foreach ($questionattempts as $qa) {
$responseparts = $qa->classify_response($whichtries);
if ($this->breakdownbyvariant) {
$this->analysis->count_response_parts($qa->get_variant(), $responseparts);
} else {
$this->analysis->count_response_parts(1, $responseparts);
}
}
$this->analysis->cache($qubaids, $whichtries, $this->questiondata->id);
return $this->analysis;
}
|
[
"public",
"function",
"calculate",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
"=",
"\\",
"question_attempt",
"::",
"LAST_TRY",
")",
"{",
"// Load data.",
"$",
"dm",
"=",
"new",
"\\",
"question_engine_data_mapper",
"(",
")",
";",
"$",
"questionattempts",
"=",
"$",
"dm",
"->",
"load_attempts_at_question",
"(",
"$",
"this",
"->",
"questiondata",
"->",
"id",
",",
"$",
"qubaids",
")",
";",
"// Analyse it.",
"foreach",
"(",
"$",
"questionattempts",
"as",
"$",
"qa",
")",
"{",
"$",
"responseparts",
"=",
"$",
"qa",
"->",
"classify_response",
"(",
"$",
"whichtries",
")",
";",
"if",
"(",
"$",
"this",
"->",
"breakdownbyvariant",
")",
"{",
"$",
"this",
"->",
"analysis",
"->",
"count_response_parts",
"(",
"$",
"qa",
"->",
"get_variant",
"(",
")",
",",
"$",
"responseparts",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"analysis",
"->",
"count_response_parts",
"(",
"1",
",",
"$",
"responseparts",
")",
";",
"}",
"}",
"$",
"this",
"->",
"analysis",
"->",
"cache",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
",",
"$",
"this",
"->",
"questiondata",
"->",
"id",
")",
";",
"return",
"$",
"this",
"->",
"analysis",
";",
"}"
] |
Analyse all the response data for for all the specified attempts at this question.
@param \qubaid_condition $qubaids which attempts to consider.
@param string $whichtries which tries to analyse. Will be one of
\question_attempt::FIRST_TRY, LAST_TRY or ALL_TRIES.
@return analysis_for_question
|
[
"Analyse",
"all",
"the",
"response",
"data",
"for",
"for",
"all",
"the",
"specified",
"attempts",
"at",
"this",
"question",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analyser.php#L119-L136
|
217,072
|
moodle/moodle
|
question/classes/statistics/responses/analyser.php
|
analyser.load_cached
|
public function load_cached($qubaids, $whichtries) {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
// Variable name 'analyses' is the plural of 'analysis'.
$responseanalyses = $DB->get_records_select('question_response_analysis',
'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?',
array($qubaids->get_hash_code(), $whichtries, $this->questiondata->id, $timemodified));
if (!$responseanalyses) {
return false;
}
$analysisids = array();
foreach ($responseanalyses as $responseanalysis) {
$analysisforsubpart = $this->analysis->get_analysis_for_subpart($responseanalysis->variant, $responseanalysis->subqid);
$class = $analysisforsubpart->get_response_class($responseanalysis->aid);
$class->add_response($responseanalysis->response, $responseanalysis->credit);
$analysisids[] = $responseanalysis->id;
}
list($sql, $params) = $DB->get_in_or_equal($analysisids);
$counts = $DB->get_records_select('question_response_count', "analysisid {$sql}", $params);
foreach ($counts as $count) {
$responseanalysis = $responseanalyses[$count->analysisid];
$analysisforsubpart = $this->analysis->get_analysis_for_subpart($responseanalysis->variant, $responseanalysis->subqid);
$class = $analysisforsubpart->get_response_class($responseanalysis->aid);
$class->set_response_count($responseanalysis->response, $count->try, $count->rcount);
}
return $this->analysis;
}
|
php
|
public function load_cached($qubaids, $whichtries) {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
// Variable name 'analyses' is the plural of 'analysis'.
$responseanalyses = $DB->get_records_select('question_response_analysis',
'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?',
array($qubaids->get_hash_code(), $whichtries, $this->questiondata->id, $timemodified));
if (!$responseanalyses) {
return false;
}
$analysisids = array();
foreach ($responseanalyses as $responseanalysis) {
$analysisforsubpart = $this->analysis->get_analysis_for_subpart($responseanalysis->variant, $responseanalysis->subqid);
$class = $analysisforsubpart->get_response_class($responseanalysis->aid);
$class->add_response($responseanalysis->response, $responseanalysis->credit);
$analysisids[] = $responseanalysis->id;
}
list($sql, $params) = $DB->get_in_or_equal($analysisids);
$counts = $DB->get_records_select('question_response_count', "analysisid {$sql}", $params);
foreach ($counts as $count) {
$responseanalysis = $responseanalyses[$count->analysisid];
$analysisforsubpart = $this->analysis->get_analysis_for_subpart($responseanalysis->variant, $responseanalysis->subqid);
$class = $analysisforsubpart->get_response_class($responseanalysis->aid);
$class->set_response_count($responseanalysis->response, $count->try, $count->rcount);
}
return $this->analysis;
}
|
[
"public",
"function",
"load_cached",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"timemodified",
"=",
"time",
"(",
")",
"-",
"self",
"::",
"TIME_TO_CACHE",
";",
"// Variable name 'analyses' is the plural of 'analysis'.",
"$",
"responseanalyses",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'question_response_analysis'",
",",
"'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?'",
",",
"array",
"(",
"$",
"qubaids",
"->",
"get_hash_code",
"(",
")",
",",
"$",
"whichtries",
",",
"$",
"this",
"->",
"questiondata",
"->",
"id",
",",
"$",
"timemodified",
")",
")",
";",
"if",
"(",
"!",
"$",
"responseanalyses",
")",
"{",
"return",
"false",
";",
"}",
"$",
"analysisids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"responseanalyses",
"as",
"$",
"responseanalysis",
")",
"{",
"$",
"analysisforsubpart",
"=",
"$",
"this",
"->",
"analysis",
"->",
"get_analysis_for_subpart",
"(",
"$",
"responseanalysis",
"->",
"variant",
",",
"$",
"responseanalysis",
"->",
"subqid",
")",
";",
"$",
"class",
"=",
"$",
"analysisforsubpart",
"->",
"get_response_class",
"(",
"$",
"responseanalysis",
"->",
"aid",
")",
";",
"$",
"class",
"->",
"add_response",
"(",
"$",
"responseanalysis",
"->",
"response",
",",
"$",
"responseanalysis",
"->",
"credit",
")",
";",
"$",
"analysisids",
"[",
"]",
"=",
"$",
"responseanalysis",
"->",
"id",
";",
"}",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"analysisids",
")",
";",
"$",
"counts",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'question_response_count'",
",",
"\"analysisid {$sql}\"",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"counts",
"as",
"$",
"count",
")",
"{",
"$",
"responseanalysis",
"=",
"$",
"responseanalyses",
"[",
"$",
"count",
"->",
"analysisid",
"]",
";",
"$",
"analysisforsubpart",
"=",
"$",
"this",
"->",
"analysis",
"->",
"get_analysis_for_subpart",
"(",
"$",
"responseanalysis",
"->",
"variant",
",",
"$",
"responseanalysis",
"->",
"subqid",
")",
";",
"$",
"class",
"=",
"$",
"analysisforsubpart",
"->",
"get_response_class",
"(",
"$",
"responseanalysis",
"->",
"aid",
")",
";",
"$",
"class",
"->",
"set_response_count",
"(",
"$",
"responseanalysis",
"->",
"response",
",",
"$",
"count",
"->",
"try",
",",
"$",
"count",
"->",
"rcount",
")",
";",
"}",
"return",
"$",
"this",
"->",
"analysis",
";",
"}"
] |
Retrieve the computed response analysis from the question_response_analysis table.
@param \qubaid_condition $qubaids load the analysis of which question usages?
@param string $whichtries load the analysis of which tries?
@return analysis_for_question|boolean analysis or false if no cached analysis found.
|
[
"Retrieve",
"the",
"computed",
"response",
"analysis",
"from",
"the",
"question_response_analysis",
"table",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analyser.php#L145-L174
|
217,073
|
moodle/moodle
|
question/classes/statistics/responses/analyser.php
|
analyser.get_last_analysed_time
|
public function get_last_analysed_time($qubaids, $whichtries) {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
return $DB->get_field_select('question_response_analysis', 'timemodified',
'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?',
array($qubaids->get_hash_code(), $whichtries, $this->questiondata->id, $timemodified),
IGNORE_MULTIPLE);
}
|
php
|
public function get_last_analysed_time($qubaids, $whichtries) {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
return $DB->get_field_select('question_response_analysis', 'timemodified',
'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?',
array($qubaids->get_hash_code(), $whichtries, $this->questiondata->id, $timemodified),
IGNORE_MULTIPLE);
}
|
[
"public",
"function",
"get_last_analysed_time",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"timemodified",
"=",
"time",
"(",
")",
"-",
"self",
"::",
"TIME_TO_CACHE",
";",
"return",
"$",
"DB",
"->",
"get_field_select",
"(",
"'question_response_analysis'",
",",
"'timemodified'",
",",
"'hashcode = ? AND whichtries = ? AND questionid = ? AND timemodified > ?'",
",",
"array",
"(",
"$",
"qubaids",
"->",
"get_hash_code",
"(",
")",
",",
"$",
"whichtries",
",",
"$",
"this",
"->",
"questiondata",
"->",
"id",
",",
"$",
"timemodified",
")",
",",
"IGNORE_MULTIPLE",
")",
";",
"}"
] |
Find time of non-expired analysis in the database.
@param \qubaid_condition $qubaids check for the analysis of which question usages?
@param string $whichtries check for the analysis of which tries?
@return integer|boolean Time of cached record that matches this qubaid_condition or false if none found.
|
[
"Find",
"time",
"of",
"non",
"-",
"expired",
"analysis",
"in",
"the",
"database",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analyser.php#L184-L192
|
217,074
|
moodle/moodle
|
lib/simplepie/library/SimplePie/Category.php
|
SimplePie_Category.get_label
|
public function get_label($strict = false)
{
if ($this->label === null && $strict !== true)
{
return $this->get_term();
}
return $this->label;
}
|
php
|
public function get_label($strict = false)
{
if ($this->label === null && $strict !== true)
{
return $this->get_term();
}
return $this->label;
}
|
[
"public",
"function",
"get_label",
"(",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"label",
"===",
"null",
"&&",
"$",
"strict",
"!==",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"get_term",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"label",
";",
"}"
] |
Get the human readable label
@param bool $strict
@return string|null
|
[
"Get",
"the",
"human",
"readable",
"label"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie/Category.php#L144-L151
|
217,075
|
moodle/moodle
|
lib/htmlpurifier/HTMLPurifier/URIScheme.php
|
HTMLPurifier_URIScheme.validate
|
public function validate(&$uri, $config, $context)
{
if ($this->default_port == $uri->port) {
$uri->port = null;
}
// kludge: browsers do funny things when the scheme but not the
// authority is set
if (!$this->may_omit_host &&
// if the scheme is present, a missing host is always in error
(!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) ||
// if the scheme is not present, a *blank* host is in error,
// since this translates into '///path' which most browsers
// interpret as being 'http://path'.
(is_null($uri->scheme) && $uri->host === '')
) {
do {
if (is_null($uri->scheme)) {
if (substr($uri->path, 0, 2) != '//') {
$uri->host = null;
break;
}
// URI is '////path', so we cannot nullify the
// host to preserve semantics. Try expanding the
// hostname instead (fall through)
}
// first see if we can manually insert a hostname
$host = $config->get('URI.Host');
if (!is_null($host)) {
$uri->host = $host;
} else {
// we can't do anything sensible, reject the URL.
return false;
}
} while (false);
}
return $this->doValidate($uri, $config, $context);
}
|
php
|
public function validate(&$uri, $config, $context)
{
if ($this->default_port == $uri->port) {
$uri->port = null;
}
// kludge: browsers do funny things when the scheme but not the
// authority is set
if (!$this->may_omit_host &&
// if the scheme is present, a missing host is always in error
(!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) ||
// if the scheme is not present, a *blank* host is in error,
// since this translates into '///path' which most browsers
// interpret as being 'http://path'.
(is_null($uri->scheme) && $uri->host === '')
) {
do {
if (is_null($uri->scheme)) {
if (substr($uri->path, 0, 2) != '//') {
$uri->host = null;
break;
}
// URI is '////path', so we cannot nullify the
// host to preserve semantics. Try expanding the
// hostname instead (fall through)
}
// first see if we can manually insert a hostname
$host = $config->get('URI.Host');
if (!is_null($host)) {
$uri->host = $host;
} else {
// we can't do anything sensible, reject the URL.
return false;
}
} while (false);
}
return $this->doValidate($uri, $config, $context);
}
|
[
"public",
"function",
"validate",
"(",
"&",
"$",
"uri",
",",
"$",
"config",
",",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"default_port",
"==",
"$",
"uri",
"->",
"port",
")",
"{",
"$",
"uri",
"->",
"port",
"=",
"null",
";",
"}",
"// kludge: browsers do funny things when the scheme but not the",
"// authority is set",
"if",
"(",
"!",
"$",
"this",
"->",
"may_omit_host",
"&&",
"// if the scheme is present, a missing host is always in error",
"(",
"!",
"is_null",
"(",
"$",
"uri",
"->",
"scheme",
")",
"&&",
"(",
"$",
"uri",
"->",
"host",
"===",
"''",
"||",
"is_null",
"(",
"$",
"uri",
"->",
"host",
")",
")",
")",
"||",
"// if the scheme is not present, a *blank* host is in error,",
"// since this translates into '///path' which most browsers",
"// interpret as being 'http://path'.",
"(",
"is_null",
"(",
"$",
"uri",
"->",
"scheme",
")",
"&&",
"$",
"uri",
"->",
"host",
"===",
"''",
")",
")",
"{",
"do",
"{",
"if",
"(",
"is_null",
"(",
"$",
"uri",
"->",
"scheme",
")",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"uri",
"->",
"path",
",",
"0",
",",
"2",
")",
"!=",
"'//'",
")",
"{",
"$",
"uri",
"->",
"host",
"=",
"null",
";",
"break",
";",
"}",
"// URI is '////path', so we cannot nullify the",
"// host to preserve semantics. Try expanding the",
"// hostname instead (fall through)",
"}",
"// first see if we can manually insert a hostname",
"$",
"host",
"=",
"$",
"config",
"->",
"get",
"(",
"'URI.Host'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"host",
")",
")",
"{",
"$",
"uri",
"->",
"host",
"=",
"$",
"host",
";",
"}",
"else",
"{",
"// we can't do anything sensible, reject the URL.",
"return",
"false",
";",
"}",
"}",
"while",
"(",
"false",
")",
";",
"}",
"return",
"$",
"this",
"->",
"doValidate",
"(",
"$",
"uri",
",",
"$",
"config",
",",
"$",
"context",
")",
";",
"}"
] |
Public interface for validating components of a URI. Performs a
bunch of default actions. Don't overload this method.
@param HTMLPurifier_URI $uri Reference to a HTMLPurifier_URI object
@param HTMLPurifier_Config $config
@param HTMLPurifier_Context $context
@return bool success or failure
|
[
"Public",
"interface",
"for",
"validating",
"components",
"of",
"a",
"URI",
".",
"Performs",
"a",
"bunch",
"of",
"default",
"actions",
".",
"Don",
"t",
"overload",
"this",
"method",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/URIScheme.php#L63-L99
|
217,076
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.delete_orphan_historical_grades
|
protected static function delete_orphan_historical_grades($userid) {
global $DB;
$sql = "
SELECT ggh.id
FROM {grade_grades_history} ggh
LEFT JOIN {grade_items} gi
ON ggh.itemid = gi.id
WHERE gi.id IS NULL
AND ggh.userid = :userid";
$ids = $DB->get_fieldset_sql($sql, ['userid' => $userid]);
if (empty($ids)) {
return;
}
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED);
// First, let's delete their files.
$sql = "
SELECT gi.id
FROM {grade_grades_history} ggh
JOIN {grade_items} gi
ON gi.id = ggh.itemid
WHERE ggh.userid = :userid";
$params = ['userid' => $userid];
$gradeitems = $DB->get_records_sql($sql, $params);
if ($gradeitems) {
$itemids = array_keys($gradeitems);
self::delete_files($itemids, true, [$userid]);
}
$DB->delete_records_select('grade_grades_history', "id $insql", $inparams);
}
|
php
|
protected static function delete_orphan_historical_grades($userid) {
global $DB;
$sql = "
SELECT ggh.id
FROM {grade_grades_history} ggh
LEFT JOIN {grade_items} gi
ON ggh.itemid = gi.id
WHERE gi.id IS NULL
AND ggh.userid = :userid";
$ids = $DB->get_fieldset_sql($sql, ['userid' => $userid]);
if (empty($ids)) {
return;
}
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED);
// First, let's delete their files.
$sql = "
SELECT gi.id
FROM {grade_grades_history} ggh
JOIN {grade_items} gi
ON gi.id = ggh.itemid
WHERE ggh.userid = :userid";
$params = ['userid' => $userid];
$gradeitems = $DB->get_records_sql($sql, $params);
if ($gradeitems) {
$itemids = array_keys($gradeitems);
self::delete_files($itemids, true, [$userid]);
}
$DB->delete_records_select('grade_grades_history', "id $insql", $inparams);
}
|
[
"protected",
"static",
"function",
"delete_orphan_historical_grades",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"\n SELECT ggh.id\n FROM {grade_grades_history} ggh\n LEFT JOIN {grade_items} gi\n ON ggh.itemid = gi.id\n WHERE gi.id IS NULL\n AND ggh.userid = :userid\"",
";",
"$",
"ids",
"=",
"$",
"DB",
"->",
"get_fieldset_sql",
"(",
"$",
"sql",
",",
"[",
"'userid'",
"=>",
"$",
"userid",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"return",
";",
"}",
"list",
"(",
"$",
"insql",
",",
"$",
"inparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"ids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"// First, let's delete their files.",
"$",
"sql",
"=",
"\"\n SELECT gi.id\n FROM {grade_grades_history} ggh\n JOIN {grade_items} gi\n ON gi.id = ggh.itemid\n WHERE ggh.userid = :userid\"",
";",
"$",
"params",
"=",
"[",
"'userid'",
"=>",
"$",
"userid",
"]",
";",
"$",
"gradeitems",
"=",
"$",
"DB",
"->",
"get_records_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"gradeitems",
")",
"{",
"$",
"itemids",
"=",
"array_keys",
"(",
"$",
"gradeitems",
")",
";",
"self",
"::",
"delete_files",
"(",
"$",
"itemids",
",",
"true",
",",
"[",
"$",
"userid",
"]",
")",
";",
"}",
"$",
"DB",
"->",
"delete_records_select",
"(",
"'grade_grades_history'",
",",
"\"id $insql\"",
",",
"$",
"inparams",
")",
";",
"}"
] |
Delete orphan historical grades.
@param int $userid The user ID.
@return void
|
[
"Delete",
"orphan",
"historical",
"grades",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L809-L839
|
217,077
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.extract_grade_grade_from_record
|
protected static function extract_grade_grade_from_record(stdClass $record, $ishistory = false) {
$prefix = $ishistory ? 'ggh_' : 'gg_';
$ggrecord = static::extract_record($record, $prefix);
if ($ishistory) {
// The grade history is not a real grade_grade so we remove the ID.
$historyid = $ggrecord->id;
unset($ggrecord->id);
}
$gg = new grade_grade($ggrecord, false);
// There is a grade item in the record.
if (!empty($record->gi_id)) {
$gi = new grade_item(static::extract_record($record, 'gi_'), false);
$gg->grade_item = $gi; // This is a common hack throughout the grades API.
}
// Load the scale, when it still exists.
if (!empty($gi->scaleid) && !empty($record->sc_id)) {
$scalerec = static::extract_record($record, 'sc_');
$gi->scale = new grade_scale($scalerec, false);
$gi->scale->load_items();
}
if ($ishistory) {
$gg->historyid = $historyid;
}
return $gg;
}
|
php
|
protected static function extract_grade_grade_from_record(stdClass $record, $ishistory = false) {
$prefix = $ishistory ? 'ggh_' : 'gg_';
$ggrecord = static::extract_record($record, $prefix);
if ($ishistory) {
// The grade history is not a real grade_grade so we remove the ID.
$historyid = $ggrecord->id;
unset($ggrecord->id);
}
$gg = new grade_grade($ggrecord, false);
// There is a grade item in the record.
if (!empty($record->gi_id)) {
$gi = new grade_item(static::extract_record($record, 'gi_'), false);
$gg->grade_item = $gi; // This is a common hack throughout the grades API.
}
// Load the scale, when it still exists.
if (!empty($gi->scaleid) && !empty($record->sc_id)) {
$scalerec = static::extract_record($record, 'sc_');
$gi->scale = new grade_scale($scalerec, false);
$gi->scale->load_items();
}
if ($ishistory) {
$gg->historyid = $historyid;
}
return $gg;
}
|
[
"protected",
"static",
"function",
"extract_grade_grade_from_record",
"(",
"stdClass",
"$",
"record",
",",
"$",
"ishistory",
"=",
"false",
")",
"{",
"$",
"prefix",
"=",
"$",
"ishistory",
"?",
"'ggh_'",
":",
"'gg_'",
";",
"$",
"ggrecord",
"=",
"static",
"::",
"extract_record",
"(",
"$",
"record",
",",
"$",
"prefix",
")",
";",
"if",
"(",
"$",
"ishistory",
")",
"{",
"// The grade history is not a real grade_grade so we remove the ID.",
"$",
"historyid",
"=",
"$",
"ggrecord",
"->",
"id",
";",
"unset",
"(",
"$",
"ggrecord",
"->",
"id",
")",
";",
"}",
"$",
"gg",
"=",
"new",
"grade_grade",
"(",
"$",
"ggrecord",
",",
"false",
")",
";",
"// There is a grade item in the record.",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
"->",
"gi_id",
")",
")",
"{",
"$",
"gi",
"=",
"new",
"grade_item",
"(",
"static",
"::",
"extract_record",
"(",
"$",
"record",
",",
"'gi_'",
")",
",",
"false",
")",
";",
"$",
"gg",
"->",
"grade_item",
"=",
"$",
"gi",
";",
"// This is a common hack throughout the grades API.",
"}",
"// Load the scale, when it still exists.",
"if",
"(",
"!",
"empty",
"(",
"$",
"gi",
"->",
"scaleid",
")",
"&&",
"!",
"empty",
"(",
"$",
"record",
"->",
"sc_id",
")",
")",
"{",
"$",
"scalerec",
"=",
"static",
"::",
"extract_record",
"(",
"$",
"record",
",",
"'sc_'",
")",
";",
"$",
"gi",
"->",
"scale",
"=",
"new",
"grade_scale",
"(",
"$",
"scalerec",
",",
"false",
")",
";",
"$",
"gi",
"->",
"scale",
"->",
"load_items",
"(",
")",
";",
"}",
"if",
"(",
"$",
"ishistory",
")",
"{",
"$",
"gg",
"->",
"historyid",
"=",
"$",
"historyid",
";",
"}",
"return",
"$",
"gg",
";",
"}"
] |
Extract grade_grade from a record.
@param stdClass $record The record.
@param bool $ishistory Whether we're extracting a historical grade.
@return grade_grade
|
[
"Extract",
"grade_grade",
"from",
"a",
"record",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1036-L1064
|
217,078
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.extract_record
|
protected static function extract_record($record, $prefix) {
$result = [];
$prefixlength = strlen($prefix);
foreach ($record as $key => $value) {
if (strpos($key, $prefix) === 0) {
$result[substr($key, $prefixlength)] = $value;
}
}
return (object) $result;
}
|
php
|
protected static function extract_record($record, $prefix) {
$result = [];
$prefixlength = strlen($prefix);
foreach ($record as $key => $value) {
if (strpos($key, $prefix) === 0) {
$result[substr($key, $prefixlength)] = $value;
}
}
return (object) $result;
}
|
[
"protected",
"static",
"function",
"extract_record",
"(",
"$",
"record",
",",
"$",
"prefix",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"prefixlength",
"=",
"strlen",
"(",
"$",
"prefix",
")",
";",
"foreach",
"(",
"$",
"record",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"prefix",
")",
"===",
"0",
")",
"{",
"$",
"result",
"[",
"substr",
"(",
"$",
"key",
",",
"$",
"prefixlength",
")",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"(",
"object",
")",
"$",
"result",
";",
"}"
] |
Extract a record from another one.
@param object $record The record to extract from.
@param string $prefix The prefix used.
@return object
|
[
"Extract",
"a",
"record",
"from",
"another",
"one",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1073-L1082
|
217,079
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.get_fields_sql
|
protected static function get_fields_sql($target, $alias, $prefix) {
switch ($target) {
case 'grade_category':
case 'grade_grade':
case 'grade_item':
case 'grade_outcome':
case 'grade_scale':
$obj = new $target([], false);
$fields = array_merge(array_keys($obj->optional_fields), $obj->required_fields);
break;
case 'grade_grades_history':
$fields = ['id', 'action', 'oldid', 'source', 'timemodified', 'loggeduser', 'itemid', 'userid', 'rawgrade',
'rawgrademax', 'rawgrademin', 'rawscaleid', 'usermodified', 'finalgrade', 'hidden', 'locked', 'locktime',
'exported', 'overridden', 'excluded', 'feedback', 'feedbackformat', 'information', 'informationformat'];
break;
default:
throw new \coding_exception('Unrecognised target: ' . $target);
break;
}
return implode(', ', array_map(function($field) use ($alias, $prefix) {
return "{$alias}.{$field} AS {$prefix}{$field}";
}, $fields));
}
|
php
|
protected static function get_fields_sql($target, $alias, $prefix) {
switch ($target) {
case 'grade_category':
case 'grade_grade':
case 'grade_item':
case 'grade_outcome':
case 'grade_scale':
$obj = new $target([], false);
$fields = array_merge(array_keys($obj->optional_fields), $obj->required_fields);
break;
case 'grade_grades_history':
$fields = ['id', 'action', 'oldid', 'source', 'timemodified', 'loggeduser', 'itemid', 'userid', 'rawgrade',
'rawgrademax', 'rawgrademin', 'rawscaleid', 'usermodified', 'finalgrade', 'hidden', 'locked', 'locktime',
'exported', 'overridden', 'excluded', 'feedback', 'feedbackformat', 'information', 'informationformat'];
break;
default:
throw new \coding_exception('Unrecognised target: ' . $target);
break;
}
return implode(', ', array_map(function($field) use ($alias, $prefix) {
return "{$alias}.{$field} AS {$prefix}{$field}";
}, $fields));
}
|
[
"protected",
"static",
"function",
"get_fields_sql",
"(",
"$",
"target",
",",
"$",
"alias",
",",
"$",
"prefix",
")",
"{",
"switch",
"(",
"$",
"target",
")",
"{",
"case",
"'grade_category'",
":",
"case",
"'grade_grade'",
":",
"case",
"'grade_item'",
":",
"case",
"'grade_outcome'",
":",
"case",
"'grade_scale'",
":",
"$",
"obj",
"=",
"new",
"$",
"target",
"(",
"[",
"]",
",",
"false",
")",
";",
"$",
"fields",
"=",
"array_merge",
"(",
"array_keys",
"(",
"$",
"obj",
"->",
"optional_fields",
")",
",",
"$",
"obj",
"->",
"required_fields",
")",
";",
"break",
";",
"case",
"'grade_grades_history'",
":",
"$",
"fields",
"=",
"[",
"'id'",
",",
"'action'",
",",
"'oldid'",
",",
"'source'",
",",
"'timemodified'",
",",
"'loggeduser'",
",",
"'itemid'",
",",
"'userid'",
",",
"'rawgrade'",
",",
"'rawgrademax'",
",",
"'rawgrademin'",
",",
"'rawscaleid'",
",",
"'usermodified'",
",",
"'finalgrade'",
",",
"'hidden'",
",",
"'locked'",
",",
"'locktime'",
",",
"'exported'",
",",
"'overridden'",
",",
"'excluded'",
",",
"'feedback'",
",",
"'feedbackformat'",
",",
"'information'",
",",
"'informationformat'",
"]",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'Unrecognised target: '",
".",
"$",
"target",
")",
";",
"break",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"function",
"(",
"$",
"field",
")",
"use",
"(",
"$",
"alias",
",",
"$",
"prefix",
")",
"{",
"return",
"\"{$alias}.{$field} AS {$prefix}{$field}\"",
";",
"}",
",",
"$",
"fields",
")",
")",
";",
"}"
] |
Get fields SQL for a grade related object.
@param string $target The related object.
@param string $alias The table alias.
@param string $prefix A prefix.
@return string
|
[
"Get",
"fields",
"SQL",
"for",
"a",
"grade",
"related",
"object",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1092-L1117
|
217,080
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.get_item_ids_from_course_ids
|
protected static function get_item_ids_from_course_ids($courseids) {
global $DB;
if (empty($courseids)) {
return [];
}
list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
return $DB->get_fieldset_select('grade_items', 'id', "courseid $insql", $inparams);
}
|
php
|
protected static function get_item_ids_from_course_ids($courseids) {
global $DB;
if (empty($courseids)) {
return [];
}
list($insql, $inparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);
return $DB->get_fieldset_select('grade_items', 'id', "courseid $insql", $inparams);
}
|
[
"protected",
"static",
"function",
"get_item_ids_from_course_ids",
"(",
"$",
"courseids",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"courseids",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"list",
"(",
"$",
"insql",
",",
"$",
"inparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"courseids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"return",
"$",
"DB",
"->",
"get_fieldset_select",
"(",
"'grade_items'",
",",
"'id'",
",",
"\"courseid $insql\"",
",",
"$",
"inparams",
")",
";",
"}"
] |
Get all the items IDs from course IDs.
@param array $courseids The course IDs.
@return array
|
[
"Get",
"all",
"the",
"items",
"IDs",
"from",
"course",
"IDs",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1125-L1132
|
217,081
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.transform_grade
|
protected static function transform_grade(grade_grade $gg, context $context, bool $ishistory) {
$gi = $gg->load_grade_item();
$timemodified = $gg->timemodified ? transform::datetime($gg->timemodified) : null;
$timecreated = $gg->timecreated ? transform::datetime($gg->timecreated) : $timemodified; // When null we use timemodified.
$filearea = $ishistory ? GRADE_HISTORY_FEEDBACK_FILEAREA : GRADE_FEEDBACK_FILEAREA;
$itemid = $ishistory ? $gg->historyid : $gg->id;
$subpath = $ishistory ? get_string('feedbackhistoryfiles', 'core_grades') : get_string('feedbackfiles', 'core_grades');
$pathtofiles = [
get_string('grades', 'core_grades'),
$subpath
];
$gg->feedback = writer::with_context($gg->get_context())->rewrite_pluginfile_urls(
$pathtofiles,
GRADE_FILE_COMPONENT,
$filearea,
$itemid,
$gg->feedback
);
return [
'gradeobject' => $gg,
'item' => $gi->get_name(),
'grade' => $gg->finalgrade,
'grade_formatted' => grade_format_gradevalue($gg->finalgrade, $gi),
'feedback' => format_text($gg->feedback, $gg->feedbackformat, ['context' => $context]),
'information' => format_text($gg->information, $gg->informationformat, ['context' => $context]),
'timecreated' => $timecreated,
'timemodified' => $timemodified,
];
}
|
php
|
protected static function transform_grade(grade_grade $gg, context $context, bool $ishistory) {
$gi = $gg->load_grade_item();
$timemodified = $gg->timemodified ? transform::datetime($gg->timemodified) : null;
$timecreated = $gg->timecreated ? transform::datetime($gg->timecreated) : $timemodified; // When null we use timemodified.
$filearea = $ishistory ? GRADE_HISTORY_FEEDBACK_FILEAREA : GRADE_FEEDBACK_FILEAREA;
$itemid = $ishistory ? $gg->historyid : $gg->id;
$subpath = $ishistory ? get_string('feedbackhistoryfiles', 'core_grades') : get_string('feedbackfiles', 'core_grades');
$pathtofiles = [
get_string('grades', 'core_grades'),
$subpath
];
$gg->feedback = writer::with_context($gg->get_context())->rewrite_pluginfile_urls(
$pathtofiles,
GRADE_FILE_COMPONENT,
$filearea,
$itemid,
$gg->feedback
);
return [
'gradeobject' => $gg,
'item' => $gi->get_name(),
'grade' => $gg->finalgrade,
'grade_formatted' => grade_format_gradevalue($gg->finalgrade, $gi),
'feedback' => format_text($gg->feedback, $gg->feedbackformat, ['context' => $context]),
'information' => format_text($gg->information, $gg->informationformat, ['context' => $context]),
'timecreated' => $timecreated,
'timemodified' => $timemodified,
];
}
|
[
"protected",
"static",
"function",
"transform_grade",
"(",
"grade_grade",
"$",
"gg",
",",
"context",
"$",
"context",
",",
"bool",
"$",
"ishistory",
")",
"{",
"$",
"gi",
"=",
"$",
"gg",
"->",
"load_grade_item",
"(",
")",
";",
"$",
"timemodified",
"=",
"$",
"gg",
"->",
"timemodified",
"?",
"transform",
"::",
"datetime",
"(",
"$",
"gg",
"->",
"timemodified",
")",
":",
"null",
";",
"$",
"timecreated",
"=",
"$",
"gg",
"->",
"timecreated",
"?",
"transform",
"::",
"datetime",
"(",
"$",
"gg",
"->",
"timecreated",
")",
":",
"$",
"timemodified",
";",
"// When null we use timemodified.",
"$",
"filearea",
"=",
"$",
"ishistory",
"?",
"GRADE_HISTORY_FEEDBACK_FILEAREA",
":",
"GRADE_FEEDBACK_FILEAREA",
";",
"$",
"itemid",
"=",
"$",
"ishistory",
"?",
"$",
"gg",
"->",
"historyid",
":",
"$",
"gg",
"->",
"id",
";",
"$",
"subpath",
"=",
"$",
"ishistory",
"?",
"get_string",
"(",
"'feedbackhistoryfiles'",
",",
"'core_grades'",
")",
":",
"get_string",
"(",
"'feedbackfiles'",
",",
"'core_grades'",
")",
";",
"$",
"pathtofiles",
"=",
"[",
"get_string",
"(",
"'grades'",
",",
"'core_grades'",
")",
",",
"$",
"subpath",
"]",
";",
"$",
"gg",
"->",
"feedback",
"=",
"writer",
"::",
"with_context",
"(",
"$",
"gg",
"->",
"get_context",
"(",
")",
")",
"->",
"rewrite_pluginfile_urls",
"(",
"$",
"pathtofiles",
",",
"GRADE_FILE_COMPONENT",
",",
"$",
"filearea",
",",
"$",
"itemid",
",",
"$",
"gg",
"->",
"feedback",
")",
";",
"return",
"[",
"'gradeobject'",
"=>",
"$",
"gg",
",",
"'item'",
"=>",
"$",
"gi",
"->",
"get_name",
"(",
")",
",",
"'grade'",
"=>",
"$",
"gg",
"->",
"finalgrade",
",",
"'grade_formatted'",
"=>",
"grade_format_gradevalue",
"(",
"$",
"gg",
"->",
"finalgrade",
",",
"$",
"gi",
")",
",",
"'feedback'",
"=>",
"format_text",
"(",
"$",
"gg",
"->",
"feedback",
",",
"$",
"gg",
"->",
"feedbackformat",
",",
"[",
"'context'",
"=>",
"$",
"context",
"]",
")",
",",
"'information'",
"=>",
"format_text",
"(",
"$",
"gg",
"->",
"information",
",",
"$",
"gg",
"->",
"informationformat",
",",
"[",
"'context'",
"=>",
"$",
"context",
"]",
")",
",",
"'timecreated'",
"=>",
"$",
"timecreated",
",",
"'timemodified'",
"=>",
"$",
"timemodified",
",",
"]",
";",
"}"
] |
Transform a grade.
@param grade_grade $gg The grade object.
@param context $context The context.
@param bool $ishistory Whether we're extracting a historical grade.
@return array
|
[
"Transform",
"a",
"grade",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1195-L1226
|
217,082
|
moodle/moodle
|
grade/classes/privacy/provider.php
|
provider.delete_files
|
protected static function delete_files(array $itemids, bool $ishistory, array $userids = null) {
global $DB;
list($iteminnsql, $params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED);
if (!is_null($userids)) {
list($userinnsql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$params = array_merge($params, $userparams);
}
if ($ishistory) {
$gradefields = static::get_fields_sql('grade_grades_history', 'ggh', 'ggh_');
$gradetable = 'grade_grades_history';
$tableprefix = 'ggh';
$filearea = GRADE_HISTORY_FEEDBACK_FILEAREA;
} else {
$gradefields = static::get_fields_sql('grade_grade', 'gg', 'gg_');
$gradetable = 'grade_grades';
$tableprefix = 'gg';
$filearea = GRADE_FEEDBACK_FILEAREA;
}
$gifields = static::get_fields_sql('grade_item', 'gi', 'gi_');
$fs = new \file_storage();
$sql = "SELECT $gradefields, $gifields
FROM {{$gradetable}} $tableprefix
JOIN {grade_items} gi
ON gi.id = {$tableprefix}.itemid
WHERE gi.id $iteminnsql ";
if (!is_null($userids)) {
$sql .= "AND {$tableprefix}.userid $userinnsql";
}
$grades = $DB->get_recordset_sql($sql, $params);
foreach ($grades as $grade) {
$gg = static::extract_grade_grade_from_record($grade, $ishistory);
$fileitemid = ($ishistory) ? $gg->historyid : $gg->id;
$fs->delete_area_files($gg->get_context()->id, GRADE_FILE_COMPONENT, $filearea, $fileitemid);
}
$grades->close();
}
|
php
|
protected static function delete_files(array $itemids, bool $ishistory, array $userids = null) {
global $DB;
list($iteminnsql, $params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED);
if (!is_null($userids)) {
list($userinnsql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$params = array_merge($params, $userparams);
}
if ($ishistory) {
$gradefields = static::get_fields_sql('grade_grades_history', 'ggh', 'ggh_');
$gradetable = 'grade_grades_history';
$tableprefix = 'ggh';
$filearea = GRADE_HISTORY_FEEDBACK_FILEAREA;
} else {
$gradefields = static::get_fields_sql('grade_grade', 'gg', 'gg_');
$gradetable = 'grade_grades';
$tableprefix = 'gg';
$filearea = GRADE_FEEDBACK_FILEAREA;
}
$gifields = static::get_fields_sql('grade_item', 'gi', 'gi_');
$fs = new \file_storage();
$sql = "SELECT $gradefields, $gifields
FROM {{$gradetable}} $tableprefix
JOIN {grade_items} gi
ON gi.id = {$tableprefix}.itemid
WHERE gi.id $iteminnsql ";
if (!is_null($userids)) {
$sql .= "AND {$tableprefix}.userid $userinnsql";
}
$grades = $DB->get_recordset_sql($sql, $params);
foreach ($grades as $grade) {
$gg = static::extract_grade_grade_from_record($grade, $ishistory);
$fileitemid = ($ishistory) ? $gg->historyid : $gg->id;
$fs->delete_area_files($gg->get_context()->id, GRADE_FILE_COMPONENT, $filearea, $fileitemid);
}
$grades->close();
}
|
[
"protected",
"static",
"function",
"delete_files",
"(",
"array",
"$",
"itemids",
",",
"bool",
"$",
"ishistory",
",",
"array",
"$",
"userids",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"list",
"(",
"$",
"iteminnsql",
",",
"$",
"params",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"itemids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"userids",
")",
")",
"{",
"list",
"(",
"$",
"userinnsql",
",",
"$",
"userparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"userids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"params",
",",
"$",
"userparams",
")",
";",
"}",
"if",
"(",
"$",
"ishistory",
")",
"{",
"$",
"gradefields",
"=",
"static",
"::",
"get_fields_sql",
"(",
"'grade_grades_history'",
",",
"'ggh'",
",",
"'ggh_'",
")",
";",
"$",
"gradetable",
"=",
"'grade_grades_history'",
";",
"$",
"tableprefix",
"=",
"'ggh'",
";",
"$",
"filearea",
"=",
"GRADE_HISTORY_FEEDBACK_FILEAREA",
";",
"}",
"else",
"{",
"$",
"gradefields",
"=",
"static",
"::",
"get_fields_sql",
"(",
"'grade_grade'",
",",
"'gg'",
",",
"'gg_'",
")",
";",
"$",
"gradetable",
"=",
"'grade_grades'",
";",
"$",
"tableprefix",
"=",
"'gg'",
";",
"$",
"filearea",
"=",
"GRADE_FEEDBACK_FILEAREA",
";",
"}",
"$",
"gifields",
"=",
"static",
"::",
"get_fields_sql",
"(",
"'grade_item'",
",",
"'gi'",
",",
"'gi_'",
")",
";",
"$",
"fs",
"=",
"new",
"\\",
"file_storage",
"(",
")",
";",
"$",
"sql",
"=",
"\"SELECT $gradefields, $gifields\n FROM {{$gradetable}} $tableprefix\n JOIN {grade_items} gi\n ON gi.id = {$tableprefix}.itemid\n WHERE gi.id $iteminnsql \"",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"userids",
")",
")",
"{",
"$",
"sql",
".=",
"\"AND {$tableprefix}.userid $userinnsql\"",
";",
"}",
"$",
"grades",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"grades",
"as",
"$",
"grade",
")",
"{",
"$",
"gg",
"=",
"static",
"::",
"extract_grade_grade_from_record",
"(",
"$",
"grade",
",",
"$",
"ishistory",
")",
";",
"$",
"fileitemid",
"=",
"(",
"$",
"ishistory",
")",
"?",
"$",
"gg",
"->",
"historyid",
":",
"$",
"gg",
"->",
"id",
";",
"$",
"fs",
"->",
"delete_area_files",
"(",
"$",
"gg",
"->",
"get_context",
"(",
")",
"->",
"id",
",",
"GRADE_FILE_COMPONENT",
",",
"$",
"filearea",
",",
"$",
"fileitemid",
")",
";",
"}",
"$",
"grades",
"->",
"close",
"(",
")",
";",
"}"
] |
Handles deleting files for a given list of grade items.
If an array of userids if given then it handles deleting files for those users.
@param array $itemids
@param bool $ishistory
@param array|null $userids
@throws \coding_exception
@throws \dml_exception
|
[
"Handles",
"deleting",
"files",
"for",
"a",
"given",
"list",
"of",
"grade",
"items",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/classes/privacy/provider.php#L1239-L1279
|
217,083
|
moodle/moodle
|
backup/moodle2/restore_plugin.class.php
|
restore_plugin.launch_after_restore_methods
|
public function launch_after_restore_methods() {
// Check if the after_restore method exists and launch it
$afterrestore = 'after_restore_' . basename($this->connectionpoint->get_path());
if (method_exists($this, $afterrestore)) {
$this->$afterrestore();
}
}
|
php
|
public function launch_after_restore_methods() {
// Check if the after_restore method exists and launch it
$afterrestore = 'after_restore_' . basename($this->connectionpoint->get_path());
if (method_exists($this, $afterrestore)) {
$this->$afterrestore();
}
}
|
[
"public",
"function",
"launch_after_restore_methods",
"(",
")",
"{",
"// Check if the after_restore method exists and launch it",
"$",
"afterrestore",
"=",
"'after_restore_'",
".",
"basename",
"(",
"$",
"this",
"->",
"connectionpoint",
"->",
"get_path",
"(",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"afterrestore",
")",
")",
"{",
"$",
"this",
"->",
"$",
"afterrestore",
"(",
")",
";",
"}",
"}"
] |
after_restore dispatcher for any restore_plugin class
This method will dispatch execution to the corresponding
after_restore_xxx() method when available, with xxx
being the connection point of the instance, so plugin
classes with multiple connection points will support
multiple after_restore methods, one for each connection point
|
[
"after_restore",
"dispatcher",
"for",
"any",
"restore_plugin",
"class"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/moodle2/restore_plugin.class.php#L97-L103
|
217,084
|
moodle/moodle
|
backup/moodle2/restore_plugin.class.php
|
restore_plugin.get_restore_decode_contents
|
static public function get_restore_decode_contents($plugintype) {
$decodecontents = array();
// Check the requested plugintype is a valid one
if (!array_key_exists($plugintype, core_component::get_plugin_types($plugintype))) {
throw new backup_step_exception('incorrect_plugin_type', $plugintype);
}
// Check the base plugin class exists
$classname = 'restore_' . $plugintype . '_plugin';
if (!class_exists($classname)) {
throw new backup_step_exception('plugin_class_not_found', $classname);
}
// First, call to the define_plugin_decode_contents in the base plugin class
// (must exist by design in all the plugin base classes)
if (method_exists($classname, 'define_plugin_decode_contents')) {
$decodecontents = array_merge($decodecontents, call_user_func(array($classname, 'define_plugin_decode_contents')));
}
// Now, iterate over all the possible plugins available
// (only the needed ones have been loaded, so they will
// be the ones being asked here). Fetch their restore contents
// by calling (if exists) to their define_decode_contents() method
$plugins = core_component::get_plugin_list($plugintype);
foreach ($plugins as $plugin => $plugindir) {
$classname = 'restore_' . $plugintype . '_' . $plugin . '_plugin';
if (class_exists($classname)) {
if (method_exists($classname, 'define_decode_contents')) {
$decodecontents = array_merge($decodecontents, call_user_func(array($classname, 'define_decode_contents')));
}
}
}
return $decodecontents;
}
|
php
|
static public function get_restore_decode_contents($plugintype) {
$decodecontents = array();
// Check the requested plugintype is a valid one
if (!array_key_exists($plugintype, core_component::get_plugin_types($plugintype))) {
throw new backup_step_exception('incorrect_plugin_type', $plugintype);
}
// Check the base plugin class exists
$classname = 'restore_' . $plugintype . '_plugin';
if (!class_exists($classname)) {
throw new backup_step_exception('plugin_class_not_found', $classname);
}
// First, call to the define_plugin_decode_contents in the base plugin class
// (must exist by design in all the plugin base classes)
if (method_exists($classname, 'define_plugin_decode_contents')) {
$decodecontents = array_merge($decodecontents, call_user_func(array($classname, 'define_plugin_decode_contents')));
}
// Now, iterate over all the possible plugins available
// (only the needed ones have been loaded, so they will
// be the ones being asked here). Fetch their restore contents
// by calling (if exists) to their define_decode_contents() method
$plugins = core_component::get_plugin_list($plugintype);
foreach ($plugins as $plugin => $plugindir) {
$classname = 'restore_' . $plugintype . '_' . $plugin . '_plugin';
if (class_exists($classname)) {
if (method_exists($classname, 'define_decode_contents')) {
$decodecontents = array_merge($decodecontents, call_user_func(array($classname, 'define_decode_contents')));
}
}
}
return $decodecontents;
}
|
[
"static",
"public",
"function",
"get_restore_decode_contents",
"(",
"$",
"plugintype",
")",
"{",
"$",
"decodecontents",
"=",
"array",
"(",
")",
";",
"// Check the requested plugintype is a valid one",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"plugintype",
",",
"core_component",
"::",
"get_plugin_types",
"(",
"$",
"plugintype",
")",
")",
")",
"{",
"throw",
"new",
"backup_step_exception",
"(",
"'incorrect_plugin_type'",
",",
"$",
"plugintype",
")",
";",
"}",
"// Check the base plugin class exists",
"$",
"classname",
"=",
"'restore_'",
".",
"$",
"plugintype",
".",
"'_plugin'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"throw",
"new",
"backup_step_exception",
"(",
"'plugin_class_not_found'",
",",
"$",
"classname",
")",
";",
"}",
"// First, call to the define_plugin_decode_contents in the base plugin class",
"// (must exist by design in all the plugin base classes)",
"if",
"(",
"method_exists",
"(",
"$",
"classname",
",",
"'define_plugin_decode_contents'",
")",
")",
"{",
"$",
"decodecontents",
"=",
"array_merge",
"(",
"$",
"decodecontents",
",",
"call_user_func",
"(",
"array",
"(",
"$",
"classname",
",",
"'define_plugin_decode_contents'",
")",
")",
")",
";",
"}",
"// Now, iterate over all the possible plugins available",
"// (only the needed ones have been loaded, so they will",
"// be the ones being asked here). Fetch their restore contents",
"// by calling (if exists) to their define_decode_contents() method",
"$",
"plugins",
"=",
"core_component",
"::",
"get_plugin_list",
"(",
"$",
"plugintype",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
"=>",
"$",
"plugindir",
")",
"{",
"$",
"classname",
"=",
"'restore_'",
".",
"$",
"plugintype",
".",
"'_'",
".",
"$",
"plugin",
".",
"'_plugin'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"classname",
",",
"'define_decode_contents'",
")",
")",
"{",
"$",
"decodecontents",
"=",
"array_merge",
"(",
"$",
"decodecontents",
",",
"call_user_func",
"(",
"array",
"(",
"$",
"classname",
",",
"'define_decode_contents'",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"decodecontents",
";",
"}"
] |
Returns one array with all the decode contents
to be processed by the links decoder
This method, given one plugin type, returns one
array of {@link restore_decode_content} objects
that will be added to the restore decoder in order
to perform modifications under the plugin contents.
The objects are retrieved by calling to the {@link define_decode_contents}
method (when available), first in the main restore_xxxx_plugin class
and later on each of the available subclasses
|
[
"Returns",
"one",
"array",
"with",
"all",
"the",
"decode",
"contents",
"to",
"be",
"processed",
"by",
"the",
"links",
"decoder"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/moodle2/restore_plugin.class.php#L118-L148
|
217,085
|
moodle/moodle
|
lib/mlbackend/php/phpml/src/Phpml/Helper/Optimizer/StochasticGD.php
|
StochasticGD.earlyStop
|
protected function earlyStop($oldTheta)
{
// Check for early stop: No change larger than threshold (default 1e-5)
$diff = array_map(
function ($w1, $w2) {
return abs($w1 - $w2) > $this->threshold ? 1 : 0;
},
$oldTheta, $this->theta);
if (array_sum($diff) == 0) {
return true;
}
// Check if the last two cost values are almost the same
$costs = array_slice($this->costValues, -2);
if (count($costs) == 2 && abs($costs[1] - $costs[0]) < $this->threshold) {
return true;
}
return false;
}
|
php
|
protected function earlyStop($oldTheta)
{
// Check for early stop: No change larger than threshold (default 1e-5)
$diff = array_map(
function ($w1, $w2) {
return abs($w1 - $w2) > $this->threshold ? 1 : 0;
},
$oldTheta, $this->theta);
if (array_sum($diff) == 0) {
return true;
}
// Check if the last two cost values are almost the same
$costs = array_slice($this->costValues, -2);
if (count($costs) == 2 && abs($costs[1] - $costs[0]) < $this->threshold) {
return true;
}
return false;
}
|
[
"protected",
"function",
"earlyStop",
"(",
"$",
"oldTheta",
")",
"{",
"// Check for early stop: No change larger than threshold (default 1e-5)",
"$",
"diff",
"=",
"array_map",
"(",
"function",
"(",
"$",
"w1",
",",
"$",
"w2",
")",
"{",
"return",
"abs",
"(",
"$",
"w1",
"-",
"$",
"w2",
")",
">",
"$",
"this",
"->",
"threshold",
"?",
"1",
":",
"0",
";",
"}",
",",
"$",
"oldTheta",
",",
"$",
"this",
"->",
"theta",
")",
";",
"if",
"(",
"array_sum",
"(",
"$",
"diff",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"// Check if the last two cost values are almost the same",
"$",
"costs",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"costValues",
",",
"-",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"costs",
")",
"==",
"2",
"&&",
"abs",
"(",
"$",
"costs",
"[",
"1",
"]",
"-",
"$",
"costs",
"[",
"0",
"]",
")",
"<",
"$",
"this",
"->",
"threshold",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the optimization is not effective enough and can be stopped
in case large enough changes in the solution do not happen
@param array $oldTheta
@return boolean
|
[
"Checks",
"if",
"the",
"optimization",
"is",
"not",
"effective",
"enough",
"and",
"can",
"be",
"stopped",
"in",
"case",
"large",
"enough",
"changes",
"in",
"the",
"solution",
"do",
"not",
"happen"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mlbackend/php/phpml/src/Phpml/Helper/Optimizer/StochasticGD.php#L239-L259
|
217,086
|
moodle/moodle
|
lib/form/select.php
|
MoodleQuickForm_select.removeOption
|
function removeOption($value)
{
$key=array_search($value, $this->_values);
if ($key!==FALSE and $key!==null) {
unset($this->_values[$key]);
}
foreach ($this->_options as $key=>$option){
if ($option['attr']['value']==$value){
unset($this->_options[$key]);
// we must reindex the options because the ugly code in quickforms' select.php expects that keys are 0,1,2,3... !?!?
$this->_options = array_merge($this->_options);
return;
}
}
}
|
php
|
function removeOption($value)
{
$key=array_search($value, $this->_values);
if ($key!==FALSE and $key!==null) {
unset($this->_values[$key]);
}
foreach ($this->_options as $key=>$option){
if ($option['attr']['value']==$value){
unset($this->_options[$key]);
// we must reindex the options because the ugly code in quickforms' select.php expects that keys are 0,1,2,3... !?!?
$this->_options = array_merge($this->_options);
return;
}
}
}
|
[
"function",
"removeOption",
"(",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"_values",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"FALSE",
"and",
"$",
"key",
"!==",
"null",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_options",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"[",
"'attr'",
"]",
"[",
"'value'",
"]",
"==",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_options",
"[",
"$",
"key",
"]",
")",
";",
"// we must reindex the options because the ugly code in quickforms' select.php expects that keys are 0,1,2,3... !?!?",
"$",
"this",
"->",
"_options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_options",
")",
";",
"return",
";",
"}",
"}",
"}"
] |
Removes an OPTION from the SELECT
@param string $value Value for the OPTION to remove
@return void
|
[
"Removes",
"an",
"OPTION",
"from",
"the",
"SELECT"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/select.php#L120-L134
|
217,087
|
moodle/moodle
|
question/type/match/backup/moodle1/lib.php
|
moodle1_qtype_match_handler.process_question
|
public function process_question(array $data, array $raw) {
global $CFG;
// Populate the list of matches first to get their ids.
// Note that the field is re-populated on restore anyway but let us
// do our best to produce valid backup files.
$matchids = array();
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
$matchids[] = $match['id'];
}
}
// Convert match options.
if (isset($data['matchoptions'])) {
$matchoptions = $data['matchoptions'][0];
} else {
$matchoptions = array('shuffleanswers' => 1);
}
$matchoptions['id'] = $this->converter->get_nextid();
$matchoptions['subquestions'] = implode(',', $matchids);
$this->write_xml('matchoptions', $matchoptions, array('/matchoptions/id'));
// Convert matches.
$this->xmlwriter->begin_tag('matches');
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
// Replay the upgrade step 2009072100.
$match['questiontextformat'] = 0;
if ($CFG->texteditors !== 'textarea' and $data['oldquestiontextformat'] == FORMAT_MOODLE) {
$match['questiontext'] = text_to_html($match['questiontext'], false, false, true);
$match['questiontextformat'] = FORMAT_HTML;
} else {
$match['questiontextformat'] = $data['oldquestiontextformat'];
}
$match['questiontext'] = $this->migrate_files(
$match['questiontext'], 'qtype_match', 'subquestion', $match['id']);
$this->write_xml('match', $match, array('/match/id'));
}
}
$this->xmlwriter->end_tag('matches');
}
|
php
|
public function process_question(array $data, array $raw) {
global $CFG;
// Populate the list of matches first to get their ids.
// Note that the field is re-populated on restore anyway but let us
// do our best to produce valid backup files.
$matchids = array();
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
$matchids[] = $match['id'];
}
}
// Convert match options.
if (isset($data['matchoptions'])) {
$matchoptions = $data['matchoptions'][0];
} else {
$matchoptions = array('shuffleanswers' => 1);
}
$matchoptions['id'] = $this->converter->get_nextid();
$matchoptions['subquestions'] = implode(',', $matchids);
$this->write_xml('matchoptions', $matchoptions, array('/matchoptions/id'));
// Convert matches.
$this->xmlwriter->begin_tag('matches');
if (isset($data['matchs']['match'])) {
foreach ($data['matchs']['match'] as $match) {
// Replay the upgrade step 2009072100.
$match['questiontextformat'] = 0;
if ($CFG->texteditors !== 'textarea' and $data['oldquestiontextformat'] == FORMAT_MOODLE) {
$match['questiontext'] = text_to_html($match['questiontext'], false, false, true);
$match['questiontextformat'] = FORMAT_HTML;
} else {
$match['questiontextformat'] = $data['oldquestiontextformat'];
}
$match['questiontext'] = $this->migrate_files(
$match['questiontext'], 'qtype_match', 'subquestion', $match['id']);
$this->write_xml('match', $match, array('/match/id'));
}
}
$this->xmlwriter->end_tag('matches');
}
|
[
"public",
"function",
"process_question",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"raw",
")",
"{",
"global",
"$",
"CFG",
";",
"// Populate the list of matches first to get their ids.",
"// Note that the field is re-populated on restore anyway but let us",
"// do our best to produce valid backup files.",
"$",
"matchids",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'matchs'",
"]",
"[",
"'match'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'matchs'",
"]",
"[",
"'match'",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"matchids",
"[",
"]",
"=",
"$",
"match",
"[",
"'id'",
"]",
";",
"}",
"}",
"// Convert match options.",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'matchoptions'",
"]",
")",
")",
"{",
"$",
"matchoptions",
"=",
"$",
"data",
"[",
"'matchoptions'",
"]",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"matchoptions",
"=",
"array",
"(",
"'shuffleanswers'",
"=>",
"1",
")",
";",
"}",
"$",
"matchoptions",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"converter",
"->",
"get_nextid",
"(",
")",
";",
"$",
"matchoptions",
"[",
"'subquestions'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"matchids",
")",
";",
"$",
"this",
"->",
"write_xml",
"(",
"'matchoptions'",
",",
"$",
"matchoptions",
",",
"array",
"(",
"'/matchoptions/id'",
")",
")",
";",
"// Convert matches.",
"$",
"this",
"->",
"xmlwriter",
"->",
"begin_tag",
"(",
"'matches'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'matchs'",
"]",
"[",
"'match'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'matchs'",
"]",
"[",
"'match'",
"]",
"as",
"$",
"match",
")",
"{",
"// Replay the upgrade step 2009072100.",
"$",
"match",
"[",
"'questiontextformat'",
"]",
"=",
"0",
";",
"if",
"(",
"$",
"CFG",
"->",
"texteditors",
"!==",
"'textarea'",
"and",
"$",
"data",
"[",
"'oldquestiontextformat'",
"]",
"==",
"FORMAT_MOODLE",
")",
"{",
"$",
"match",
"[",
"'questiontext'",
"]",
"=",
"text_to_html",
"(",
"$",
"match",
"[",
"'questiontext'",
"]",
",",
"false",
",",
"false",
",",
"true",
")",
";",
"$",
"match",
"[",
"'questiontextformat'",
"]",
"=",
"FORMAT_HTML",
";",
"}",
"else",
"{",
"$",
"match",
"[",
"'questiontextformat'",
"]",
"=",
"$",
"data",
"[",
"'oldquestiontextformat'",
"]",
";",
"}",
"$",
"match",
"[",
"'questiontext'",
"]",
"=",
"$",
"this",
"->",
"migrate_files",
"(",
"$",
"match",
"[",
"'questiontext'",
"]",
",",
"'qtype_match'",
",",
"'subquestion'",
",",
"$",
"match",
"[",
"'id'",
"]",
")",
";",
"$",
"this",
"->",
"write_xml",
"(",
"'match'",
",",
"$",
"match",
",",
"array",
"(",
"'/match/id'",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"xmlwriter",
"->",
"end_tag",
"(",
"'matches'",
")",
";",
"}"
] |
Appends the match specific information to the question.
|
[
"Appends",
"the",
"match",
"specific",
"information",
"to",
"the",
"question",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/match/backup/moodle1/lib.php#L43-L85
|
217,088
|
moodle/moodle
|
completion/completion_aggregation.php
|
completion_aggregation.setMethod
|
public function setMethod($method) {
$methods = array(
COMPLETION_AGGREGATION_ALL,
COMPLETION_AGGREGATION_ANY,
);
if (in_array($method, $methods)) {
$this->method = $method;
} else {
$this->method = COMPLETION_AGGREGATION_ALL;
}
}
|
php
|
public function setMethod($method) {
$methods = array(
COMPLETION_AGGREGATION_ALL,
COMPLETION_AGGREGATION_ANY,
);
if (in_array($method, $methods)) {
$this->method = $method;
} else {
$this->method = COMPLETION_AGGREGATION_ALL;
}
}
|
[
"public",
"function",
"setMethod",
"(",
"$",
"method",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
"COMPLETION_AGGREGATION_ALL",
",",
"COMPLETION_AGGREGATION_ANY",
",",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"method",
",",
"$",
"methods",
")",
")",
"{",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"method",
"=",
"COMPLETION_AGGREGATION_ALL",
";",
"}",
"}"
] |
Set the aggregation method
@param int $method One of COMPLETION_AGGREGATION_ALL or COMPLETION_AGGREGATION_ANY
|
[
"Set",
"the",
"aggregation",
"method"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/completion_aggregation.php#L92-L103
|
217,089
|
moodle/moodle
|
lib/classes/progress/display_if_slow.php
|
display_if_slow.start_html
|
public function start_html() {
global $OUTPUT;
$this->id = 'core_progress_display_if_slow' . self::$nextid;
self::$nextid++;
// Containing div includes a CSS class so that it can be themed if required,
// and an id so it can be automatically hidden at end.
echo \html_writer::start_div('core_progress_display_if_slow',
array('id' => $this->id));
// Display optional heading.
if ($this->heading !== '') {
echo $OUTPUT->heading($this->heading, 3);
}
// Use base class to display progress bar.
parent::start_html();
}
|
php
|
public function start_html() {
global $OUTPUT;
$this->id = 'core_progress_display_if_slow' . self::$nextid;
self::$nextid++;
// Containing div includes a CSS class so that it can be themed if required,
// and an id so it can be automatically hidden at end.
echo \html_writer::start_div('core_progress_display_if_slow',
array('id' => $this->id));
// Display optional heading.
if ($this->heading !== '') {
echo $OUTPUT->heading($this->heading, 3);
}
// Use base class to display progress bar.
parent::start_html();
}
|
[
"public",
"function",
"start_html",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"this",
"->",
"id",
"=",
"'core_progress_display_if_slow'",
".",
"self",
"::",
"$",
"nextid",
";",
"self",
"::",
"$",
"nextid",
"++",
";",
"// Containing div includes a CSS class so that it can be themed if required,",
"// and an id so it can be automatically hidden at end.",
"echo",
"\\",
"html_writer",
"::",
"start_div",
"(",
"'core_progress_display_if_slow'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"id",
")",
")",
";",
"// Display optional heading.",
"if",
"(",
"$",
"this",
"->",
"heading",
"!==",
"''",
")",
"{",
"echo",
"$",
"OUTPUT",
"->",
"heading",
"(",
"$",
"this",
"->",
"heading",
",",
"3",
")",
";",
"}",
"// Use base class to display progress bar.",
"parent",
"::",
"start_html",
"(",
")",
";",
"}"
] |
Starts displaying the progress bar, with optional heading and a special
div so it can be hidden later.
@see \core\progress\display::start_html()
|
[
"Starts",
"displaying",
"the",
"progress",
"bar",
"with",
"optional",
"heading",
"and",
"a",
"special",
"div",
"so",
"it",
"can",
"be",
"hidden",
"later",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/progress/display_if_slow.php#L80-L97
|
217,090
|
moodle/moodle
|
lib/classes/progress/display_if_slow.php
|
display_if_slow.update_progress
|
public function update_progress() {
// If we haven't started yet, consider starting.
if ($this->starttime) {
if (time() > $this->starttime) {
$this->starttime = 0;
} else {
// Do nothing until start time.
return;
}
}
// We have started, so handle as default.
parent::update_progress();
}
|
php
|
public function update_progress() {
// If we haven't started yet, consider starting.
if ($this->starttime) {
if (time() > $this->starttime) {
$this->starttime = 0;
} else {
// Do nothing until start time.
return;
}
}
// We have started, so handle as default.
parent::update_progress();
}
|
[
"public",
"function",
"update_progress",
"(",
")",
"{",
"// If we haven't started yet, consider starting.",
"if",
"(",
"$",
"this",
"->",
"starttime",
")",
"{",
"if",
"(",
"time",
"(",
")",
">",
"$",
"this",
"->",
"starttime",
")",
"{",
"$",
"this",
"->",
"starttime",
"=",
"0",
";",
"}",
"else",
"{",
"// Do nothing until start time.",
"return",
";",
"}",
"}",
"// We have started, so handle as default.",
"parent",
"::",
"update_progress",
"(",
")",
";",
"}"
] |
When progress is updated, after a certain time, starts actually displaying
the progress bar.
@see \core\progress\base::update_progress()
|
[
"When",
"progress",
"is",
"updated",
"after",
"a",
"certain",
"time",
"starts",
"actually",
"displaying",
"the",
"progress",
"bar",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/progress/display_if_slow.php#L105-L118
|
217,091
|
moodle/moodle
|
completion/classes/api.php
|
api.update_completion_date_event
|
public static function update_completion_date_event($cmid, $modulename, $instanceorid, $completionexpectedtime) {
global $CFG, $DB;
// Required for calendar constant CALENDAR_EVENT_TYPE_ACTION.
require_once($CFG->dirroot . '/calendar/lib.php');
$instance = null;
if (is_object($instanceorid)) {
$instance = $instanceorid;
} else {
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', IGNORE_MISSING);
}
if (!$instance) {
return false;
}
$course = get_course($instance->course);
$completion = new \completion_info($course);
// Can not create/update an event if completion is disabled.
if (!$completion->is_enabled() && $completionexpectedtime !== null) {
return true;
}
// Create the \stdClass we will be using for our language strings.
$lang = new \stdClass();
$lang->modulename = get_string('pluginname', $modulename);
$lang->instancename = $instance->name;
// Create the calendar event.
$event = new \stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->eventtype = self::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => $modulename,
'instance' => $instance->id, 'eventtype' => $event->eventtype))) {
if ($completionexpectedtime !== null) {
// Calendar event exists so update it.
$event->name = get_string('completionexpectedfor', 'completion', $lang);
$event->description = format_module_intro($modulename, $instance, $cmid);
$event->timestart = $completionexpectedtime;
$event->timesort = $completionexpectedtime;
$event->visible = instance_is_visible($modulename, $instance);
$event->timeduration = 0;
$calendarevent = \calendar_event::load($event->id);
$calendarevent->update($event, false);
} else {
// Calendar event is no longer needed.
$calendarevent = \calendar_event::load($event->id);
$calendarevent->delete();
}
} else {
// Event doesn't exist so create one.
if ($completionexpectedtime !== null) {
$event->name = get_string('completionexpectedfor', 'completion', $lang);
$event->description = format_module_intro($modulename, $instance, $cmid);
$event->courseid = $instance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = $modulename;
$event->instance = $instance->id;
$event->timestart = $completionexpectedtime;
$event->timesort = $completionexpectedtime;
$event->visible = instance_is_visible($modulename, $instance);
$event->timeduration = 0;
\calendar_event::create($event, false);
}
}
return true;
}
|
php
|
public static function update_completion_date_event($cmid, $modulename, $instanceorid, $completionexpectedtime) {
global $CFG, $DB;
// Required for calendar constant CALENDAR_EVENT_TYPE_ACTION.
require_once($CFG->dirroot . '/calendar/lib.php');
$instance = null;
if (is_object($instanceorid)) {
$instance = $instanceorid;
} else {
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', IGNORE_MISSING);
}
if (!$instance) {
return false;
}
$course = get_course($instance->course);
$completion = new \completion_info($course);
// Can not create/update an event if completion is disabled.
if (!$completion->is_enabled() && $completionexpectedtime !== null) {
return true;
}
// Create the \stdClass we will be using for our language strings.
$lang = new \stdClass();
$lang->modulename = get_string('pluginname', $modulename);
$lang->instancename = $instance->name;
// Create the calendar event.
$event = new \stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->eventtype = self::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED;
if ($event->id = $DB->get_field('event', 'id', array('modulename' => $modulename,
'instance' => $instance->id, 'eventtype' => $event->eventtype))) {
if ($completionexpectedtime !== null) {
// Calendar event exists so update it.
$event->name = get_string('completionexpectedfor', 'completion', $lang);
$event->description = format_module_intro($modulename, $instance, $cmid);
$event->timestart = $completionexpectedtime;
$event->timesort = $completionexpectedtime;
$event->visible = instance_is_visible($modulename, $instance);
$event->timeduration = 0;
$calendarevent = \calendar_event::load($event->id);
$calendarevent->update($event, false);
} else {
// Calendar event is no longer needed.
$calendarevent = \calendar_event::load($event->id);
$calendarevent->delete();
}
} else {
// Event doesn't exist so create one.
if ($completionexpectedtime !== null) {
$event->name = get_string('completionexpectedfor', 'completion', $lang);
$event->description = format_module_intro($modulename, $instance, $cmid);
$event->courseid = $instance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = $modulename;
$event->instance = $instance->id;
$event->timestart = $completionexpectedtime;
$event->timesort = $completionexpectedtime;
$event->visible = instance_is_visible($modulename, $instance);
$event->timeduration = 0;
\calendar_event::create($event, false);
}
}
return true;
}
|
[
"public",
"static",
"function",
"update_completion_date_event",
"(",
"$",
"cmid",
",",
"$",
"modulename",
",",
"$",
"instanceorid",
",",
"$",
"completionexpectedtime",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"// Required for calendar constant CALENDAR_EVENT_TYPE_ACTION.",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/calendar/lib.php'",
")",
";",
"$",
"instance",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"instanceorid",
")",
")",
"{",
"$",
"instance",
"=",
"$",
"instanceorid",
";",
"}",
"else",
"{",
"$",
"instance",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"$",
"modulename",
",",
"array",
"(",
"'id'",
"=>",
"$",
"instanceorid",
")",
",",
"'*'",
",",
"IGNORE_MISSING",
")",
";",
"}",
"if",
"(",
"!",
"$",
"instance",
")",
"{",
"return",
"false",
";",
"}",
"$",
"course",
"=",
"get_course",
"(",
"$",
"instance",
"->",
"course",
")",
";",
"$",
"completion",
"=",
"new",
"\\",
"completion_info",
"(",
"$",
"course",
")",
";",
"// Can not create/update an event if completion is disabled.",
"if",
"(",
"!",
"$",
"completion",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"completionexpectedtime",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"// Create the \\stdClass we will be using for our language strings.",
"$",
"lang",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"lang",
"->",
"modulename",
"=",
"get_string",
"(",
"'pluginname'",
",",
"$",
"modulename",
")",
";",
"$",
"lang",
"->",
"instancename",
"=",
"$",
"instance",
"->",
"name",
";",
"// Create the calendar event.",
"$",
"event",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"event",
"->",
"type",
"=",
"CALENDAR_EVENT_TYPE_ACTION",
";",
"$",
"event",
"->",
"eventtype",
"=",
"self",
"::",
"COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED",
";",
"if",
"(",
"$",
"event",
"->",
"id",
"=",
"$",
"DB",
"->",
"get_field",
"(",
"'event'",
",",
"'id'",
",",
"array",
"(",
"'modulename'",
"=>",
"$",
"modulename",
",",
"'instance'",
"=>",
"$",
"instance",
"->",
"id",
",",
"'eventtype'",
"=>",
"$",
"event",
"->",
"eventtype",
")",
")",
")",
"{",
"if",
"(",
"$",
"completionexpectedtime",
"!==",
"null",
")",
"{",
"// Calendar event exists so update it.",
"$",
"event",
"->",
"name",
"=",
"get_string",
"(",
"'completionexpectedfor'",
",",
"'completion'",
",",
"$",
"lang",
")",
";",
"$",
"event",
"->",
"description",
"=",
"format_module_intro",
"(",
"$",
"modulename",
",",
"$",
"instance",
",",
"$",
"cmid",
")",
";",
"$",
"event",
"->",
"timestart",
"=",
"$",
"completionexpectedtime",
";",
"$",
"event",
"->",
"timesort",
"=",
"$",
"completionexpectedtime",
";",
"$",
"event",
"->",
"visible",
"=",
"instance_is_visible",
"(",
"$",
"modulename",
",",
"$",
"instance",
")",
";",
"$",
"event",
"->",
"timeduration",
"=",
"0",
";",
"$",
"calendarevent",
"=",
"\\",
"calendar_event",
"::",
"load",
"(",
"$",
"event",
"->",
"id",
")",
";",
"$",
"calendarevent",
"->",
"update",
"(",
"$",
"event",
",",
"false",
")",
";",
"}",
"else",
"{",
"// Calendar event is no longer needed.",
"$",
"calendarevent",
"=",
"\\",
"calendar_event",
"::",
"load",
"(",
"$",
"event",
"->",
"id",
")",
";",
"$",
"calendarevent",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// Event doesn't exist so create one.",
"if",
"(",
"$",
"completionexpectedtime",
"!==",
"null",
")",
"{",
"$",
"event",
"->",
"name",
"=",
"get_string",
"(",
"'completionexpectedfor'",
",",
"'completion'",
",",
"$",
"lang",
")",
";",
"$",
"event",
"->",
"description",
"=",
"format_module_intro",
"(",
"$",
"modulename",
",",
"$",
"instance",
",",
"$",
"cmid",
")",
";",
"$",
"event",
"->",
"courseid",
"=",
"$",
"instance",
"->",
"course",
";",
"$",
"event",
"->",
"groupid",
"=",
"0",
";",
"$",
"event",
"->",
"userid",
"=",
"0",
";",
"$",
"event",
"->",
"modulename",
"=",
"$",
"modulename",
";",
"$",
"event",
"->",
"instance",
"=",
"$",
"instance",
"->",
"id",
";",
"$",
"event",
"->",
"timestart",
"=",
"$",
"completionexpectedtime",
";",
"$",
"event",
"->",
"timesort",
"=",
"$",
"completionexpectedtime",
";",
"$",
"event",
"->",
"visible",
"=",
"instance_is_visible",
"(",
"$",
"modulename",
",",
"$",
"instance",
")",
";",
"$",
"event",
"->",
"timeduration",
"=",
"0",
";",
"\\",
"calendar_event",
"::",
"create",
"(",
"$",
"event",
",",
"false",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Creates, updates or deletes an event for the expected completion date.
@param int $cmid The course module id
@param string $modulename The name of the module (eg. assign, quiz)
@param \stdClass|int $instanceorid The instance object or ID.
@param int|null $completionexpectedtime The time completion is expected, null if not set
@return bool
|
[
"Creates",
"updates",
"or",
"deletes",
"an",
"event",
"for",
"the",
"expected",
"completion",
"date",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/api.php#L52-L123
|
217,092
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.renderer_prefixes
|
public function renderer_prefixes() {
global $CFG; // just in case the included files need it
$prefixes = array('theme_'.$this->name);
foreach ($this->parent_configs as $parent) {
$prefixes[] = 'theme_'.$parent->name;
}
return $prefixes;
}
|
php
|
public function renderer_prefixes() {
global $CFG; // just in case the included files need it
$prefixes = array('theme_'.$this->name);
foreach ($this->parent_configs as $parent) {
$prefixes[] = 'theme_'.$parent->name;
}
return $prefixes;
}
|
[
"public",
"function",
"renderer_prefixes",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"// just in case the included files need it",
"$",
"prefixes",
"=",
"array",
"(",
"'theme_'",
".",
"$",
"this",
"->",
"name",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parent_configs",
"as",
"$",
"parent",
")",
"{",
"$",
"prefixes",
"[",
"]",
"=",
"'theme_'",
".",
"$",
"parent",
"->",
"name",
";",
"}",
"return",
"$",
"prefixes",
";",
"}"
] |
Returns output renderer prefixes, these are used when looking
for the overridden renderers in themes.
@return array
|
[
"Returns",
"output",
"renderer",
"prefixes",
"these",
"are",
"used",
"when",
"looking",
"for",
"the",
"overridden",
"renderers",
"in",
"themes",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L888-L898
|
217,093
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.editor_css_url
|
public function editor_css_url($encoded=true) {
global $CFG;
$rev = theme_get_revision();
if ($rev > -1) {
$themesubrevision = theme_get_sub_revision_for_theme($this->name);
// Provide the sub revision to allow us to invalidate cached theme CSS
// on a per theme basis, rather than globally.
if ($themesubrevision && $themesubrevision > 0) {
$rev .= "_{$themesubrevision}";
}
$url = new moodle_url("/theme/styles.php");
if (!empty($CFG->slasharguments)) {
$url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
} else {
$url->params(array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor'));
}
} else {
$params = array('theme'=>$this->name, 'type'=>'editor');
$url = new moodle_url('/theme/styles_debug.php', $params);
}
return $url;
}
|
php
|
public function editor_css_url($encoded=true) {
global $CFG;
$rev = theme_get_revision();
if ($rev > -1) {
$themesubrevision = theme_get_sub_revision_for_theme($this->name);
// Provide the sub revision to allow us to invalidate cached theme CSS
// on a per theme basis, rather than globally.
if ($themesubrevision && $themesubrevision > 0) {
$rev .= "_{$themesubrevision}";
}
$url = new moodle_url("/theme/styles.php");
if (!empty($CFG->slasharguments)) {
$url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
} else {
$url->params(array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor'));
}
} else {
$params = array('theme'=>$this->name, 'type'=>'editor');
$url = new moodle_url('/theme/styles_debug.php', $params);
}
return $url;
}
|
[
"public",
"function",
"editor_css_url",
"(",
"$",
"encoded",
"=",
"true",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"rev",
"=",
"theme_get_revision",
"(",
")",
";",
"if",
"(",
"$",
"rev",
">",
"-",
"1",
")",
"{",
"$",
"themesubrevision",
"=",
"theme_get_sub_revision_for_theme",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// Provide the sub revision to allow us to invalidate cached theme CSS",
"// on a per theme basis, rather than globally.",
"if",
"(",
"$",
"themesubrevision",
"&&",
"$",
"themesubrevision",
">",
"0",
")",
"{",
"$",
"rev",
".=",
"\"_{$themesubrevision}\"",
";",
"}",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"\"/theme/styles.php\"",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"slasharguments",
")",
")",
"{",
"$",
"url",
"->",
"set_slashargument",
"(",
"'/'",
".",
"$",
"this",
"->",
"name",
".",
"'/'",
".",
"$",
"rev",
".",
"'/editor'",
",",
"'noparam'",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"url",
"->",
"params",
"(",
"array",
"(",
"'theme'",
"=>",
"$",
"this",
"->",
"name",
",",
"'rev'",
"=>",
"$",
"rev",
",",
"'type'",
"=>",
"'editor'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"params",
"=",
"array",
"(",
"'theme'",
"=>",
"$",
"this",
"->",
"name",
",",
"'type'",
"=>",
"'editor'",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/theme/styles_debug.php'",
",",
"$",
"params",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Returns the stylesheet URL of this editor content
@param bool $encoded false means use & and true use & in URLs
@return moodle_url
|
[
"Returns",
"the",
"stylesheet",
"URL",
"of",
"this",
"editor",
"content"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L906-L929
|
217,094
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.editor_css_files
|
public function editor_css_files() {
$files = array();
// First editor plugins.
$plugins = core_component::get_plugin_list('editor');
foreach ($plugins as $plugin=>$fulldir) {
$sheetfile = "$fulldir/editor_styles.css";
if (is_readable($sheetfile)) {
$files['plugin_'.$plugin] = $sheetfile;
}
}
// Then parent themes - base first, the immediate parent last.
foreach (array_reverse($this->parent_configs) as $parent_config) {
if (empty($parent_config->editor_sheets)) {
continue;
}
foreach ($parent_config->editor_sheets as $sheet) {
$sheetfile = "$parent_config->dir/style/$sheet.css";
if (is_readable($sheetfile)) {
$files['parent_'.$parent_config->name.'_'.$sheet] = $sheetfile;
}
}
}
// Finally this theme.
if (!empty($this->editor_sheets)) {
foreach ($this->editor_sheets as $sheet) {
$sheetfile = "$this->dir/style/$sheet.css";
if (is_readable($sheetfile)) {
$files['theme_'.$sheet] = $sheetfile;
}
}
}
return $files;
}
|
php
|
public function editor_css_files() {
$files = array();
// First editor plugins.
$plugins = core_component::get_plugin_list('editor');
foreach ($plugins as $plugin=>$fulldir) {
$sheetfile = "$fulldir/editor_styles.css";
if (is_readable($sheetfile)) {
$files['plugin_'.$plugin] = $sheetfile;
}
}
// Then parent themes - base first, the immediate parent last.
foreach (array_reverse($this->parent_configs) as $parent_config) {
if (empty($parent_config->editor_sheets)) {
continue;
}
foreach ($parent_config->editor_sheets as $sheet) {
$sheetfile = "$parent_config->dir/style/$sheet.css";
if (is_readable($sheetfile)) {
$files['parent_'.$parent_config->name.'_'.$sheet] = $sheetfile;
}
}
}
// Finally this theme.
if (!empty($this->editor_sheets)) {
foreach ($this->editor_sheets as $sheet) {
$sheetfile = "$this->dir/style/$sheet.css";
if (is_readable($sheetfile)) {
$files['theme_'.$sheet] = $sheetfile;
}
}
}
return $files;
}
|
[
"public",
"function",
"editor_css_files",
"(",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"// First editor plugins.",
"$",
"plugins",
"=",
"core_component",
"::",
"get_plugin_list",
"(",
"'editor'",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
"=>",
"$",
"fulldir",
")",
"{",
"$",
"sheetfile",
"=",
"\"$fulldir/editor_styles.css\"",
";",
"if",
"(",
"is_readable",
"(",
"$",
"sheetfile",
")",
")",
"{",
"$",
"files",
"[",
"'plugin_'",
".",
"$",
"plugin",
"]",
"=",
"$",
"sheetfile",
";",
"}",
"}",
"// Then parent themes - base first, the immediate parent last.",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"parent_configs",
")",
"as",
"$",
"parent_config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parent_config",
"->",
"editor_sheets",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"parent_config",
"->",
"editor_sheets",
"as",
"$",
"sheet",
")",
"{",
"$",
"sheetfile",
"=",
"\"$parent_config->dir/style/$sheet.css\"",
";",
"if",
"(",
"is_readable",
"(",
"$",
"sheetfile",
")",
")",
"{",
"$",
"files",
"[",
"'parent_'",
".",
"$",
"parent_config",
"->",
"name",
".",
"'_'",
".",
"$",
"sheet",
"]",
"=",
"$",
"sheetfile",
";",
"}",
"}",
"}",
"// Finally this theme.",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"editor_sheets",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"editor_sheets",
"as",
"$",
"sheet",
")",
"{",
"$",
"sheetfile",
"=",
"\"$this->dir/style/$sheet.css\"",
";",
"if",
"(",
"is_readable",
"(",
"$",
"sheetfile",
")",
")",
"{",
"$",
"files",
"[",
"'theme_'",
".",
"$",
"sheet",
"]",
"=",
"$",
"sheetfile",
";",
"}",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Returns the content of the CSS to be used in editor content
@return array
|
[
"Returns",
"the",
"content",
"of",
"the",
"CSS",
"to",
"be",
"used",
"in",
"editor",
"content"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L936-L970
|
217,095
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.editor_scss_to_css
|
public function editor_scss_to_css() {
$css = '';
if (!empty($this->editor_scss)) {
$compiler = new core_scss();
foreach ($this->editor_scss as $filename) {
$compiler->set_file("{$this->dir}/scss/{$filename}.scss");
try {
$css .= $compiler->to_css();
} catch (\Exception $e) {
debugging('Error while compiling editor SCSS: ' . $e->getMessage(), DEBUG_DEVELOPER);
}
}
}
return $css;
}
|
php
|
public function editor_scss_to_css() {
$css = '';
if (!empty($this->editor_scss)) {
$compiler = new core_scss();
foreach ($this->editor_scss as $filename) {
$compiler->set_file("{$this->dir}/scss/{$filename}.scss");
try {
$css .= $compiler->to_css();
} catch (\Exception $e) {
debugging('Error while compiling editor SCSS: ' . $e->getMessage(), DEBUG_DEVELOPER);
}
}
}
return $css;
}
|
[
"public",
"function",
"editor_scss_to_css",
"(",
")",
"{",
"$",
"css",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"editor_scss",
")",
")",
"{",
"$",
"compiler",
"=",
"new",
"core_scss",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"editor_scss",
"as",
"$",
"filename",
")",
"{",
"$",
"compiler",
"->",
"set_file",
"(",
"\"{$this->dir}/scss/{$filename}.scss\"",
")",
";",
"try",
"{",
"$",
"css",
".=",
"$",
"compiler",
"->",
"to_css",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"debugging",
"(",
"'Error while compiling editor SCSS: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"}",
"}",
"return",
"$",
"css",
";",
"}"
] |
Compiles and returns the content of the SCSS to be used in editor content
@return string Compiled CSS from the editor SCSS
|
[
"Compiles",
"and",
"returns",
"the",
"content",
"of",
"the",
"SCSS",
"to",
"be",
"used",
"in",
"editor",
"content"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L977-L995
|
217,096
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.get_css_content
|
public function get_css_content() {
$csscontent = '';
foreach ($this->get_css_files(false) as $type => $value) {
foreach ($value as $identifier => $val) {
if (is_array($val)) {
foreach ($val as $v) {
$csscontent .= file_get_contents($v) . "\n";
}
} else {
if ($type === 'theme' && $identifier === self::SCSS_KEY) {
// We need the content from SCSS because this is the SCSS file from the theme.
if ($compiled = $this->get_css_content_from_scss(false)) {
$csscontent .= $compiled;
} else {
// The compiler failed so default back to any precompiled css that might
// exist.
$csscontent .= $this->get_precompiled_css_content();
}
} else if ($type === 'theme' && $identifier === $this->lessfile) {
// We need the content from LESS because this is the LESS file from the theme.
$csscontent .= $this->get_css_content_from_less(false);
} else {
$csscontent .= file_get_contents($val) . "\n";
}
}
}
}
$csscontent = $this->post_process($csscontent);
$csscontent = core_minify::css($csscontent);
return $csscontent;
}
|
php
|
public function get_css_content() {
$csscontent = '';
foreach ($this->get_css_files(false) as $type => $value) {
foreach ($value as $identifier => $val) {
if (is_array($val)) {
foreach ($val as $v) {
$csscontent .= file_get_contents($v) . "\n";
}
} else {
if ($type === 'theme' && $identifier === self::SCSS_KEY) {
// We need the content from SCSS because this is the SCSS file from the theme.
if ($compiled = $this->get_css_content_from_scss(false)) {
$csscontent .= $compiled;
} else {
// The compiler failed so default back to any precompiled css that might
// exist.
$csscontent .= $this->get_precompiled_css_content();
}
} else if ($type === 'theme' && $identifier === $this->lessfile) {
// We need the content from LESS because this is the LESS file from the theme.
$csscontent .= $this->get_css_content_from_less(false);
} else {
$csscontent .= file_get_contents($val) . "\n";
}
}
}
}
$csscontent = $this->post_process($csscontent);
$csscontent = core_minify::css($csscontent);
return $csscontent;
}
|
[
"public",
"function",
"get_css_content",
"(",
")",
"{",
"$",
"csscontent",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"get_css_files",
"(",
"false",
")",
"as",
"$",
"type",
"=>",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"identifier",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"foreach",
"(",
"$",
"val",
"as",
"$",
"v",
")",
"{",
"$",
"csscontent",
".=",
"file_get_contents",
"(",
"$",
"v",
")",
".",
"\"\\n\"",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"type",
"===",
"'theme'",
"&&",
"$",
"identifier",
"===",
"self",
"::",
"SCSS_KEY",
")",
"{",
"// We need the content from SCSS because this is the SCSS file from the theme.",
"if",
"(",
"$",
"compiled",
"=",
"$",
"this",
"->",
"get_css_content_from_scss",
"(",
"false",
")",
")",
"{",
"$",
"csscontent",
".=",
"$",
"compiled",
";",
"}",
"else",
"{",
"// The compiler failed so default back to any precompiled css that might",
"// exist.",
"$",
"csscontent",
".=",
"$",
"this",
"->",
"get_precompiled_css_content",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"type",
"===",
"'theme'",
"&&",
"$",
"identifier",
"===",
"$",
"this",
"->",
"lessfile",
")",
"{",
"// We need the content from LESS because this is the LESS file from the theme.",
"$",
"csscontent",
".=",
"$",
"this",
"->",
"get_css_content_from_less",
"(",
"false",
")",
";",
"}",
"else",
"{",
"$",
"csscontent",
".=",
"file_get_contents",
"(",
"$",
"val",
")",
".",
"\"\\n\"",
";",
"}",
"}",
"}",
"}",
"$",
"csscontent",
"=",
"$",
"this",
"->",
"post_process",
"(",
"$",
"csscontent",
")",
";",
"$",
"csscontent",
"=",
"core_minify",
"::",
"css",
"(",
"$",
"csscontent",
")",
";",
"return",
"$",
"csscontent",
";",
"}"
] |
Get the whole css stylesheet for production mode.
NOTE: this method is not expected to be used from any addons.
@return string CSS markup compressed
|
[
"Get",
"the",
"whole",
"css",
"stylesheet",
"for",
"production",
"mode",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L1116-L1148
|
217,097
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.set_css_content_cache
|
public function set_css_content_cache($csscontent) {
$cache = cache::make('core', 'postprocessedcss');
$key = $this->get_css_cache_key();
return $cache->set($key, $csscontent);
}
|
php
|
public function set_css_content_cache($csscontent) {
$cache = cache::make('core', 'postprocessedcss');
$key = $this->get_css_cache_key();
return $cache->set($key, $csscontent);
}
|
[
"public",
"function",
"set_css_content_cache",
"(",
"$",
"csscontent",
")",
"{",
"$",
"cache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'postprocessedcss'",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"get_css_cache_key",
"(",
")",
";",
"return",
"$",
"cache",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"csscontent",
")",
";",
"}"
] |
Set post processed CSS content cache.
@param string $csscontent The post processed CSS content.
@return bool True if the content was successfully cached.
|
[
"Set",
"post",
"processed",
"CSS",
"content",
"cache",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L1155-L1161
|
217,098
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.has_css_cached_content
|
public function has_css_cached_content() {
$key = $this->get_css_cache_key();
$cache = cache::make('core', 'postprocessedcss');
return $cache->has($key);
}
|
php
|
public function has_css_cached_content() {
$key = $this->get_css_cache_key();
$cache = cache::make('core', 'postprocessedcss');
return $cache->has($key);
}
|
[
"public",
"function",
"has_css_cached_content",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"get_css_cache_key",
"(",
")",
";",
"$",
"cache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'postprocessedcss'",
")",
";",
"return",
"$",
"cache",
"->",
"has",
"(",
"$",
"key",
")",
";",
"}"
] |
Return whether the post processed CSS content has been cached.
@return bool Whether the post-processed CSS is available in the cache.
|
[
"Return",
"whether",
"the",
"post",
"processed",
"CSS",
"content",
"has",
"been",
"cached",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L1168-L1174
|
217,099
|
moodle/moodle
|
lib/outputlib.php
|
theme_config.get_css_cached_content
|
public function get_css_cached_content() {
$key = $this->get_css_cache_key();
$cache = cache::make('core', 'postprocessedcss');
return $cache->get($key);
}
|
php
|
public function get_css_cached_content() {
$key = $this->get_css_cache_key();
$cache = cache::make('core', 'postprocessedcss');
return $cache->get($key);
}
|
[
"public",
"function",
"get_css_cached_content",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"get_css_cache_key",
"(",
")",
";",
"$",
"cache",
"=",
"cache",
"::",
"make",
"(",
"'core'",
",",
"'postprocessedcss'",
")",
";",
"return",
"$",
"cache",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}"
] |
Return cached post processed CSS content.
@return bool|string The cached css content or false if not found.
|
[
"Return",
"cached",
"post",
"processed",
"CSS",
"content",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputlib.php#L1181-L1187
|
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.