id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
212,500
moodle/moodle
lib/webdavlib.php
webdav_client.copy_file
function copy_file($src_path, $dst_path, $overwrite) { $this->_path = $this->translate_uri($src_path); $this->header_unset(); $this->create_basic_request('COPY'); $this->header_add(sprintf('Destination: http://%s%s', $this->_server, $this->translate_uri($dst_path))); if ($overwrite) { $this->header_add('Overwrite: T'); } else { $this->header_add('Overwrite: F'); } $this->header_add(''); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed just return what server gave us (as defined in rfc 2518) : 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource. 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource. 403 (Forbidden) - The source and destination URIs are the same. 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created. 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element or the Overwrite header is "F" and the state of the destination resource is non-null. 423 (Locked) - The destination resource was locked. 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource. 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the execution of this method. */ return $response['status']['status-code']; } return false; }
php
function copy_file($src_path, $dst_path, $overwrite) { $this->_path = $this->translate_uri($src_path); $this->header_unset(); $this->create_basic_request('COPY'); $this->header_add(sprintf('Destination: http://%s%s', $this->_server, $this->translate_uri($dst_path))); if ($overwrite) { $this->header_add('Overwrite: T'); } else { $this->header_add('Overwrite: F'); } $this->header_add(''); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed just return what server gave us (as defined in rfc 2518) : 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource. 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource. 403 (Forbidden) - The source and destination URIs are the same. 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created. 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element or the Overwrite header is "F" and the state of the destination resource is non-null. 423 (Locked) - The destination resource was locked. 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource. 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the execution of this method. */ return $response['status']['status-code']; } return false; }
[ "function", "copy_file", "(", "$", "src_path", ",", "$", "dst_path", ",", "$", "overwrite", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "src_path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'COPY'", ")", ";", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Destination: http://%s%s'", ",", "$", "this", "->", "_server", ",", "$", "this", "->", "translate_uri", "(", "$", "dst_path", ")", ")", ")", ";", "if", "(", "$", "overwrite", ")", "{", "$", "this", "->", "header_add", "(", "'Overwrite: T'", ")", ";", "}", "else", "{", "$", "this", "->", "header_add", "(", "'Overwrite: F'", ")", ";", "}", "$", "this", "->", "header_add", "(", "''", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "// validate the response ...", "// check http-version", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "/* seems to be http ... proceed\n just return what server gave us (as defined in rfc 2518) :\n 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource.\n 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource.\n 403 (Forbidden) - The source and destination URIs are the same.\n 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created.\n 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element\n or the Overwrite header is \"F\" and the state of the destination resource is non-null.\n 423 (Locked) - The destination resource was locked.\n 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource.\n 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the\n execution of this method.\n */", "return", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "}", "return", "false", ";", "}" ]
Public method copy_file Copies a file on a webdav server Duplicates a file on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten. @param string src_path, string dest_path, bool overwrite @return int status code (look at rfc 2518). false on error.
[ "Public", "method", "copy_file" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L447-L481
212,501
moodle/moodle
lib/webdavlib.php
webdav_client.copy_coll
function copy_coll($src_path, $dst_path, $overwrite) { $this->_path = $this->translate_uri($src_path); $this->header_unset(); $this->create_basic_request('COPY'); $this->header_add(sprintf('Destination: http://%s%s', $this->_server, $this->translate_uri($dst_path))); $this->header_add('Depth: Infinity'); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"; $xml .= "<d:propertybehavior xmlns:d=\"DAV:\">\r\n"; $xml .= " <d:keepalive>*</d:keepalive>\r\n"; $xml .= "</d:propertybehavior>\r\n"; $this->header_add('Content-length: ' . strlen($xml)); $this->header_add('Content-type: application/xml'); $this->send_request(); // send also xml fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed just return what server gave us (as defined in rfc 2518) : 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource. 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource. 403 (Forbidden) - The source and destination URIs are the same. 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created. 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element or the Overwrite header is "F" and the state of the destination resource is non-null. 423 (Locked) - The destination resource was locked. 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource. 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the execution of this method. */ return $response['status']['status-code']; } return false; }
php
function copy_coll($src_path, $dst_path, $overwrite) { $this->_path = $this->translate_uri($src_path); $this->header_unset(); $this->create_basic_request('COPY'); $this->header_add(sprintf('Destination: http://%s%s', $this->_server, $this->translate_uri($dst_path))); $this->header_add('Depth: Infinity'); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"; $xml .= "<d:propertybehavior xmlns:d=\"DAV:\">\r\n"; $xml .= " <d:keepalive>*</d:keepalive>\r\n"; $xml .= "</d:propertybehavior>\r\n"; $this->header_add('Content-length: ' . strlen($xml)); $this->header_add('Content-type: application/xml'); $this->send_request(); // send also xml fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed just return what server gave us (as defined in rfc 2518) : 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource. 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource. 403 (Forbidden) - The source and destination URIs are the same. 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created. 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element or the Overwrite header is "F" and the state of the destination resource is non-null. 423 (Locked) - The destination resource was locked. 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource. 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the execution of this method. */ return $response['status']['status-code']; } return false; }
[ "function", "copy_coll", "(", "$", "src_path", ",", "$", "dst_path", ",", "$", "overwrite", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "src_path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'COPY'", ")", ";", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Destination: http://%s%s'", ",", "$", "this", "->", "_server", ",", "$", "this", "->", "translate_uri", "(", "$", "dst_path", ")", ")", ")", ";", "$", "this", "->", "header_add", "(", "'Depth: Infinity'", ")", ";", "$", "xml", "=", "\"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?>\\r\\n\"", ";", "$", "xml", ".=", "\"<d:propertybehavior xmlns:d=\\\"DAV:\\\">\\r\\n\"", ";", "$", "xml", ".=", "\" <d:keepalive>*</d:keepalive>\\r\\n\"", ";", "$", "xml", ".=", "\"</d:propertybehavior>\\r\\n\"", ";", "$", "this", "->", "header_add", "(", "'Content-length: '", ".", "strlen", "(", "$", "xml", ")", ")", ";", "$", "this", "->", "header_add", "(", "'Content-type: application/xml'", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "// send also xml", "fputs", "(", "$", "this", "->", "sock", ",", "$", "xml", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "// validate the response ...", "// check http-version", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "/* seems to be http ... proceed\n just return what server gave us (as defined in rfc 2518) :\n 201 (Created) - The source resource was successfully copied. The copy operation resulted in the creation of a new resource.\n 204 (No Content) - The source resource was successfully copied to a pre-existing destination resource.\n 403 (Forbidden) - The source and destination URIs are the same.\n 409 (Conflict) - A resource cannot be created at the destination until one or more intermediate collections have been created.\n 412 (Precondition Failed) - The server was unable to maintain the liveness of the properties listed in the propertybehavior XML element\n or the Overwrite header is \"F\" and the state of the destination resource is non-null.\n 423 (Locked) - The destination resource was locked.\n 502 (Bad Gateway) - This may occur when the destination is on another server and the destination server refuses to accept the resource.\n 507 (Insufficient Storage) - The destination resource does not have sufficient space to record the state of the resource after the\n execution of this method.\n */", "return", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "}", "return", "false", ";", "}" ]
Public method copy_coll Copies a collection on a webdav server Duplicates a collection on the webdav server (serverside). All work is done on the webdav server. If you set param overwrite as true, the target will be overwritten. @param string src_path, string dest_path, bool overwrite @return int status code (look at rfc 2518). false on error.
[ "Public", "method", "copy_coll" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L495-L534
212,502
moodle/moodle
lib/webdavlib.php
webdav_client.lock
function lock($path) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('LOCK'); $this->header_add('Timeout: Infinite'); $this->header_add('Content-type: text/xml'); // create the xml request ... $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"; $xml .= "<D:lockinfo xmlns:D='DAV:'\r\n>"; $xml .= " <D:lockscope><D:exclusive/></D:lockscope>\r\n"; $xml .= " <D:locktype><D:write/></D:locktype>\r\n"; $xml .= " <D:owner>\r\n"; $xml .= " <D:href>".($this->_user)."</D:href>\r\n"; $xml .= " </D:owner>\r\n"; $xml .= "</D:lockinfo>\r\n"; $this->header_add('Content-length: ' . strlen($xml)); $this->send_request(); // send also xml fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... (only basic validation) // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed rfc 2518 says: 200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body. 412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the request in the lockinfo XML element. 423 (Locked) - The resource is locked, so the method has been rejected. */ switch($response['status']['status-code']) { case 200: // collection was successfully locked... see xml response to get lock token... if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns(); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_lock[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_lock_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_lock_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } // Free resources xml_parser_free($this->_parser); // add status code to array $this->_lock[$this->_parserid]['status'] = 200; return $this->_lock[$this->_parserid]; } else { print 'Missing Content-Type: text/xml header in response.<br>'; } return false; default: // hmm. not what we expected. Just return what we got from webdav server // someone else has to handle it. $this->_lock['status'] = $response['status']['status-code']; return $this->_lock; } } }
php
function lock($path) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('LOCK'); $this->header_add('Timeout: Infinite'); $this->header_add('Content-type: text/xml'); // create the xml request ... $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"; $xml .= "<D:lockinfo xmlns:D='DAV:'\r\n>"; $xml .= " <D:lockscope><D:exclusive/></D:lockscope>\r\n"; $xml .= " <D:locktype><D:write/></D:locktype>\r\n"; $xml .= " <D:owner>\r\n"; $xml .= " <D:href>".($this->_user)."</D:href>\r\n"; $xml .= " </D:owner>\r\n"; $xml .= "</D:lockinfo>\r\n"; $this->header_add('Content-length: ' . strlen($xml)); $this->send_request(); // send also xml fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... (only basic validation) // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed rfc 2518 says: 200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body. 412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the request in the lockinfo XML element. 423 (Locked) - The resource is locked, so the method has been rejected. */ switch($response['status']['status-code']) { case 200: // collection was successfully locked... see xml response to get lock token... if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns(); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_lock[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_lock_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_lock_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } // Free resources xml_parser_free($this->_parser); // add status code to array $this->_lock[$this->_parserid]['status'] = 200; return $this->_lock[$this->_parserid]; } else { print 'Missing Content-Type: text/xml header in response.<br>'; } return false; default: // hmm. not what we expected. Just return what we got from webdav server // someone else has to handle it. $this->_lock['status'] = $response['status']['status-code']; return $this->_lock; } } }
[ "function", "lock", "(", "$", "path", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'LOCK'", ")", ";", "$", "this", "->", "header_add", "(", "'Timeout: Infinite'", ")", ";", "$", "this", "->", "header_add", "(", "'Content-type: text/xml'", ")", ";", "// create the xml request ...", "$", "xml", "=", "\"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?>\\r\\n\"", ";", "$", "xml", ".=", "\"<D:lockinfo xmlns:D='DAV:'\\r\\n>\"", ";", "$", "xml", ".=", "\" <D:lockscope><D:exclusive/></D:lockscope>\\r\\n\"", ";", "$", "xml", ".=", "\" <D:locktype><D:write/></D:locktype>\\r\\n\"", ";", "$", "xml", ".=", "\" <D:owner>\\r\\n\"", ";", "$", "xml", ".=", "\" <D:href>\"", ".", "(", "$", "this", "->", "_user", ")", ".", "\"</D:href>\\r\\n\"", ";", "$", "xml", ".=", "\" </D:owner>\\r\\n\"", ";", "$", "xml", ".=", "\"</D:lockinfo>\\r\\n\"", ";", "$", "this", "->", "header_add", "(", "'Content-length: '", ".", "strlen", "(", "$", "xml", ")", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "// send also xml", "fputs", "(", "$", "this", "->", "sock", ",", "$", "xml", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "// validate the response ... (only basic validation)", "// check http-version", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "/* seems to be http ... proceed\n rfc 2518 says:\n 200 (OK) - The lock request succeeded and the value of the lockdiscovery property is included in the body.\n 412 (Precondition Failed) - The included lock token was not enforceable on this resource or the server could not satisfy the\n request in the lockinfo XML element.\n 423 (Locked) - The resource is locked, so the method has been rejected.\n */", "switch", "(", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ")", "{", "case", "200", ":", "// collection was successfully locked... see xml response to get lock token...", "if", "(", "strcmp", "(", "$", "response", "[", "'header'", "]", "[", "'Content-Type'", "]", ",", "'text/xml; charset=\"utf-8\"'", ")", "==", "0", ")", "{", "// ok let's get the content of the xml stuff", "$", "this", "->", "_parser", "=", "xml_parser_create_ns", "(", ")", ";", "$", "this", "->", "_parserid", "=", "(", "int", ")", "$", "this", "->", "_parser", ";", "// forget old data...", "unset", "(", "$", "this", "->", "_lock", "[", "$", "this", "->", "_parserid", "]", ")", ";", "unset", "(", "$", "this", "->", "_xmltree", "[", "$", "this", "->", "_parserid", "]", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_SKIP_WHITE", ",", "0", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_CASE_FOLDING", ",", "0", ")", ";", "xml_set_object", "(", "$", "this", "->", "_parser", ",", "$", "this", ")", ";", "xml_set_element_handler", "(", "$", "this", "->", "_parser", ",", "\"_lock_startElement\"", ",", "\"_endElement\"", ")", ";", "xml_set_character_data_handler", "(", "$", "this", "->", "_parser", ",", "\"_lock_cdata\"", ")", ";", "if", "(", "!", "xml_parse", "(", "$", "this", "->", "_parser", ",", "$", "response", "[", "'body'", "]", ")", ")", "{", "die", "(", "sprintf", "(", "\"XML error: %s at line %d\"", ",", "xml_error_string", "(", "xml_get_error_code", "(", "$", "this", "->", "_parser", ")", ")", ",", "xml_get_current_line_number", "(", "$", "this", "->", "_parser", ")", ")", ")", ";", "}", "// Free resources", "xml_parser_free", "(", "$", "this", "->", "_parser", ")", ";", "// add status code to array", "$", "this", "->", "_lock", "[", "$", "this", "->", "_parserid", "]", "[", "'status'", "]", "=", "200", ";", "return", "$", "this", "->", "_lock", "[", "$", "this", "->", "_parserid", "]", ";", "}", "else", "{", "print", "'Missing Content-Type: text/xml header in response.<br>'", ";", "}", "return", "false", ";", "default", ":", "// hmm. not what we expected. Just return what we got from webdav server", "// someone else has to handle it.", "$", "this", "->", "_lock", "[", "'status'", "]", "=", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "return", "$", "this", "->", "_lock", ";", "}", "}", "}" ]
Public method lock Locks a file or collection. Lock uses this->_user as lock owner. @param string path @return int status code (look at rfc 2518). false on error.
[ "Public", "method", "lock" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L604-L679
212,503
moodle/moodle
lib/webdavlib.php
webdav_client.unlock
function unlock($path, $locktoken) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('UNLOCK'); $this->header_add(sprintf('Lock-Token: <%s>', $locktoken)); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed rfc 2518 says: 204 (OK) - The 204 (No Content) status code is used instead of 200 (OK) because there is no response entity body. */ return $response['status']['status-code']; } return false; }
php
function unlock($path, $locktoken) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('UNLOCK'); $this->header_add(sprintf('Lock-Token: <%s>', $locktoken)); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { /* seems to be http ... proceed rfc 2518 says: 204 (OK) - The 204 (No Content) status code is used instead of 200 (OK) because there is no response entity body. */ return $response['status']['status-code']; } return false; }
[ "function", "unlock", "(", "$", "path", ",", "$", "locktoken", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'UNLOCK'", ")", ";", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Lock-Token: <%s>'", ",", "$", "locktoken", ")", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "/* seems to be http ... proceed\n rfc 2518 says:\n 204 (OK) - The 204 (No Content) status code is used instead of 200 (OK) because there is no response entity body.\n */", "return", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "}", "return", "false", ";", "}" ]
Public method unlock Unlocks a file or collection. @param string path, string locktoken @return int status code (look at rfc 2518). false on error.
[ "Public", "method", "unlock" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L690-L707
212,504
moodle/moodle
lib/webdavlib.php
webdav_client.delete
function delete($path) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('DELETE'); /* $this->header_add('Content-Length: 0'); */ $this->header_add(''); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { // seems to be http ... proceed // We expect a 207 Multi-Status status code // print 'http ok<br>'; switch ($response['status']['status-code']) { case 207: // collection was NOT deleted... see xml response for reason... // next there should be a Content-Type: text/xml; charset="utf-8" header line if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns(); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_delete[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_delete_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_delete_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } print "<br>"; // Free resources xml_parser_free($this->_parser); $this->_delete[$this->_parserid]['status'] = $response['status']['status-code']; return $this->_delete[$this->_parserid]; } else { print 'Missing Content-Type: text/xml header in response.<br>'; } return false; default: // collection or file was successfully deleted $this->_delete['status'] = $response['status']['status-code']; return $this->_delete; } } }
php
function delete($path) { $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('DELETE'); /* $this->header_add('Content-Length: 0'); */ $this->header_add(''); $this->send_request(); $this->get_respond(); $response = $this->process_respond(); // validate the response ... // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { // seems to be http ... proceed // We expect a 207 Multi-Status status code // print 'http ok<br>'; switch ($response['status']['status-code']) { case 207: // collection was NOT deleted... see xml response for reason... // next there should be a Content-Type: text/xml; charset="utf-8" header line if (strcmp($response['header']['Content-Type'], 'text/xml; charset="utf-8"') == 0) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns(); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_delete[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_delete_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_delete_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } print "<br>"; // Free resources xml_parser_free($this->_parser); $this->_delete[$this->_parserid]['status'] = $response['status']['status-code']; return $this->_delete[$this->_parserid]; } else { print 'Missing Content-Type: text/xml header in response.<br>'; } return false; default: // collection or file was successfully deleted $this->_delete['status'] = $response['status']['status-code']; return $this->_delete; } } }
[ "function", "delete", "(", "$", "path", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'DELETE'", ")", ";", "/* $this->header_add('Content-Length: 0'); */", "$", "this", "->", "header_add", "(", "''", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "// validate the response ...", "// check http-version", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "// seems to be http ... proceed", "// We expect a 207 Multi-Status status code", "// print 'http ok<br>';", "switch", "(", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ")", "{", "case", "207", ":", "// collection was NOT deleted... see xml response for reason...", "// next there should be a Content-Type: text/xml; charset=\"utf-8\" header line", "if", "(", "strcmp", "(", "$", "response", "[", "'header'", "]", "[", "'Content-Type'", "]", ",", "'text/xml; charset=\"utf-8\"'", ")", "==", "0", ")", "{", "// ok let's get the content of the xml stuff", "$", "this", "->", "_parser", "=", "xml_parser_create_ns", "(", ")", ";", "$", "this", "->", "_parserid", "=", "(", "int", ")", "$", "this", "->", "_parser", ";", "// forget old data...", "unset", "(", "$", "this", "->", "_delete", "[", "$", "this", "->", "_parserid", "]", ")", ";", "unset", "(", "$", "this", "->", "_xmltree", "[", "$", "this", "->", "_parserid", "]", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_SKIP_WHITE", ",", "0", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_CASE_FOLDING", ",", "0", ")", ";", "xml_set_object", "(", "$", "this", "->", "_parser", ",", "$", "this", ")", ";", "xml_set_element_handler", "(", "$", "this", "->", "_parser", ",", "\"_delete_startElement\"", ",", "\"_endElement\"", ")", ";", "xml_set_character_data_handler", "(", "$", "this", "->", "_parser", ",", "\"_delete_cdata\"", ")", ";", "if", "(", "!", "xml_parse", "(", "$", "this", "->", "_parser", ",", "$", "response", "[", "'body'", "]", ")", ")", "{", "die", "(", "sprintf", "(", "\"XML error: %s at line %d\"", ",", "xml_error_string", "(", "xml_get_error_code", "(", "$", "this", "->", "_parser", ")", ")", ",", "xml_get_current_line_number", "(", "$", "this", "->", "_parser", ")", ")", ")", ";", "}", "print", "\"<br>\"", ";", "// Free resources", "xml_parser_free", "(", "$", "this", "->", "_parser", ")", ";", "$", "this", "->", "_delete", "[", "$", "this", "->", "_parserid", "]", "[", "'status'", "]", "=", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "return", "$", "this", "->", "_delete", "[", "$", "this", "->", "_parserid", "]", ";", "}", "else", "{", "print", "'Missing Content-Type: text/xml header in response.<br>'", ";", "}", "return", "false", ";", "default", ":", "// collection or file was successfully deleted", "$", "this", "->", "_delete", "[", "'status'", "]", "=", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "return", "$", "this", "->", "_delete", ";", "}", "}", "}" ]
Public method delete deletes a collection/directory on a webdav server @param string path @return int status code (look at rfc 2518). false on error.
[ "Public", "method", "delete" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L716-L778
212,505
moodle/moodle
lib/webdavlib.php
webdav_client.ls
function ls($path) { if (trim($path) == '') { $this->_error_log('Missing a path in method ls'); return false; } $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('PROPFIND'); $this->header_add('Depth: 1'); $this->header_add('Content-type: application/xml'); // create profind xml request... $xml = <<<EOD <?xml version="1.0" encoding="utf-8"?> <propfind xmlns="DAV:"><prop> <getcontentlength xmlns="DAV:"/> <getlastmodified xmlns="DAV:"/> <executable xmlns="http://apache.org/dav/props/"/> <resourcetype xmlns="DAV:"/> <checked-in xmlns="DAV:"/> <checked-out xmlns="DAV:"/> </prop></propfind> EOD; $this->header_add('Content-length: ' . strlen($xml)); $this->send_request(); $this->_error_log($xml); fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... (only basic validation) // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { // seems to be http ... proceed // We expect a 207 Multi-Status status code // print 'http ok<br>'; if (strcmp($response['status']['status-code'],'207') == 0 ) { // ok so far // next there should be a Content-Type: text/xml; charset="utf-8" header line if (preg_match('#(application|text)/xml;\s?charset=[\'\"]?utf-8[\'\"]?#i', $response['header']['Content-Type'])) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns('UTF-8'); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_ls[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); // xml_parser_set_option($this->_parser,XML_OPTION_TARGET_ENCODING,'UTF-8'); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_propfind_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_propfind_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } // Free resources xml_parser_free($this->_parser); $arr = $this->_ls[$this->_parserid]; return $arr; } else { $this->_error_log('Missing Content-Type: text/xml header in response!!'); return false; } } else { // return status code ... return $response['status']['status-code']; } } // response was not http $this->_error_log('Ups in method ls: error in response from server'); return false; }
php
function ls($path) { if (trim($path) == '') { $this->_error_log('Missing a path in method ls'); return false; } $this->_path = $this->translate_uri($path); $this->header_unset(); $this->create_basic_request('PROPFIND'); $this->header_add('Depth: 1'); $this->header_add('Content-type: application/xml'); // create profind xml request... $xml = <<<EOD <?xml version="1.0" encoding="utf-8"?> <propfind xmlns="DAV:"><prop> <getcontentlength xmlns="DAV:"/> <getlastmodified xmlns="DAV:"/> <executable xmlns="http://apache.org/dav/props/"/> <resourcetype xmlns="DAV:"/> <checked-in xmlns="DAV:"/> <checked-out xmlns="DAV:"/> </prop></propfind> EOD; $this->header_add('Content-length: ' . strlen($xml)); $this->send_request(); $this->_error_log($xml); fputs($this->sock, $xml); $this->get_respond(); $response = $this->process_respond(); // validate the response ... (only basic validation) // check http-version if ($response['status']['http-version'] == 'HTTP/1.1' || $response['status']['http-version'] == 'HTTP/1.0') { // seems to be http ... proceed // We expect a 207 Multi-Status status code // print 'http ok<br>'; if (strcmp($response['status']['status-code'],'207') == 0 ) { // ok so far // next there should be a Content-Type: text/xml; charset="utf-8" header line if (preg_match('#(application|text)/xml;\s?charset=[\'\"]?utf-8[\'\"]?#i', $response['header']['Content-Type'])) { // ok let's get the content of the xml stuff $this->_parser = xml_parser_create_ns('UTF-8'); $this->_parserid = (int) $this->_parser; // forget old data... unset($this->_ls[$this->_parserid]); unset($this->_xmltree[$this->_parserid]); xml_parser_set_option($this->_parser,XML_OPTION_SKIP_WHITE,0); xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,0); // xml_parser_set_option($this->_parser,XML_OPTION_TARGET_ENCODING,'UTF-8'); xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, "_propfind_startElement", "_endElement"); xml_set_character_data_handler($this->_parser, "_propfind_cdata"); if (!xml_parse($this->_parser, $response['body'])) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser))); } // Free resources xml_parser_free($this->_parser); $arr = $this->_ls[$this->_parserid]; return $arr; } else { $this->_error_log('Missing Content-Type: text/xml header in response!!'); return false; } } else { // return status code ... return $response['status']['status-code']; } } // response was not http $this->_error_log('Ups in method ls: error in response from server'); return false; }
[ "function", "ls", "(", "$", "path", ")", "{", "if", "(", "trim", "(", "$", "path", ")", "==", "''", ")", "{", "$", "this", "->", "_error_log", "(", "'Missing a path in method ls'", ")", ";", "return", "false", ";", "}", "$", "this", "->", "_path", "=", "$", "this", "->", "translate_uri", "(", "$", "path", ")", ";", "$", "this", "->", "header_unset", "(", ")", ";", "$", "this", "->", "create_basic_request", "(", "'PROPFIND'", ")", ";", "$", "this", "->", "header_add", "(", "'Depth: 1'", ")", ";", "$", "this", "->", "header_add", "(", "'Content-type: application/xml'", ")", ";", "// create profind xml request...", "$", "xml", "=", " <<<EOD\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<propfind xmlns=\"DAV:\"><prop>\n<getcontentlength xmlns=\"DAV:\"/>\n<getlastmodified xmlns=\"DAV:\"/>\n<executable xmlns=\"http://apache.org/dav/props/\"/>\n<resourcetype xmlns=\"DAV:\"/>\n<checked-in xmlns=\"DAV:\"/>\n<checked-out xmlns=\"DAV:\"/>\n</prop></propfind>\nEOD", ";", "$", "this", "->", "header_add", "(", "'Content-length: '", ".", "strlen", "(", "$", "xml", ")", ")", ";", "$", "this", "->", "send_request", "(", ")", ";", "$", "this", "->", "_error_log", "(", "$", "xml", ")", ";", "fputs", "(", "$", "this", "->", "sock", ",", "$", "xml", ")", ";", "$", "this", "->", "get_respond", "(", ")", ";", "$", "response", "=", "$", "this", "->", "process_respond", "(", ")", ";", "// validate the response ... (only basic validation)", "// check http-version", "if", "(", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.1'", "||", "$", "response", "[", "'status'", "]", "[", "'http-version'", "]", "==", "'HTTP/1.0'", ")", "{", "// seems to be http ... proceed", "// We expect a 207 Multi-Status status code", "// print 'http ok<br>';", "if", "(", "strcmp", "(", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ",", "'207'", ")", "==", "0", ")", "{", "// ok so far", "// next there should be a Content-Type: text/xml; charset=\"utf-8\" header line", "if", "(", "preg_match", "(", "'#(application|text)/xml;\\s?charset=[\\'\\\"]?utf-8[\\'\\\"]?#i'", ",", "$", "response", "[", "'header'", "]", "[", "'Content-Type'", "]", ")", ")", "{", "// ok let's get the content of the xml stuff", "$", "this", "->", "_parser", "=", "xml_parser_create_ns", "(", "'UTF-8'", ")", ";", "$", "this", "->", "_parserid", "=", "(", "int", ")", "$", "this", "->", "_parser", ";", "// forget old data...", "unset", "(", "$", "this", "->", "_ls", "[", "$", "this", "->", "_parserid", "]", ")", ";", "unset", "(", "$", "this", "->", "_xmltree", "[", "$", "this", "->", "_parserid", "]", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_SKIP_WHITE", ",", "0", ")", ";", "xml_parser_set_option", "(", "$", "this", "->", "_parser", ",", "XML_OPTION_CASE_FOLDING", ",", "0", ")", ";", "// xml_parser_set_option($this->_parser,XML_OPTION_TARGET_ENCODING,'UTF-8');", "xml_set_object", "(", "$", "this", "->", "_parser", ",", "$", "this", ")", ";", "xml_set_element_handler", "(", "$", "this", "->", "_parser", ",", "\"_propfind_startElement\"", ",", "\"_endElement\"", ")", ";", "xml_set_character_data_handler", "(", "$", "this", "->", "_parser", ",", "\"_propfind_cdata\"", ")", ";", "if", "(", "!", "xml_parse", "(", "$", "this", "->", "_parser", ",", "$", "response", "[", "'body'", "]", ")", ")", "{", "die", "(", "sprintf", "(", "\"XML error: %s at line %d\"", ",", "xml_error_string", "(", "xml_get_error_code", "(", "$", "this", "->", "_parser", ")", ")", ",", "xml_get_current_line_number", "(", "$", "this", "->", "_parser", ")", ")", ")", ";", "}", "// Free resources", "xml_parser_free", "(", "$", "this", "->", "_parser", ")", ";", "$", "arr", "=", "$", "this", "->", "_ls", "[", "$", "this", "->", "_parserid", "]", ";", "return", "$", "arr", ";", "}", "else", "{", "$", "this", "->", "_error_log", "(", "'Missing Content-Type: text/xml header in response!!'", ")", ";", "return", "false", ";", "}", "}", "else", "{", "// return status code ...", "return", "$", "response", "[", "'status'", "]", "[", "'status-code'", "]", ";", "}", "}", "// response was not http", "$", "this", "->", "_error_log", "(", "'Ups in method ls: error in response from server'", ")", ";", "return", "false", ";", "}" ]
Public method ls Get's directory information from webdav server into flat a array using PROPFIND All filenames are UTF-8 encoded. Have a look at _propfind_startElement what keys are used in array returned. @param string path @return array dirinfo, false on error
[ "Public", "method", "ls" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L790-L868
212,506
moodle/moodle
lib/webdavlib.php
webdav_client.gpi
function gpi($path) { // split path by last "/" $path = rtrim($path, "/"); $item = basename($path); $dir = dirname($path); $list = $this->ls($dir); // be sure it is an array if (is_array($list)) { foreach($list as $e) { $fullpath = urldecode($e['href']); $filename = basename($fullpath); if ($filename == $item && $filename != "" and $fullpath != $dir."/") { return $e; } } } return false; }
php
function gpi($path) { // split path by last "/" $path = rtrim($path, "/"); $item = basename($path); $dir = dirname($path); $list = $this->ls($dir); // be sure it is an array if (is_array($list)) { foreach($list as $e) { $fullpath = urldecode($e['href']); $filename = basename($fullpath); if ($filename == $item && $filename != "" and $fullpath != $dir."/") { return $e; } } } return false; }
[ "function", "gpi", "(", "$", "path", ")", "{", "// split path by last \"/\"", "$", "path", "=", "rtrim", "(", "$", "path", ",", "\"/\"", ")", ";", "$", "item", "=", "basename", "(", "$", "path", ")", ";", "$", "dir", "=", "dirname", "(", "$", "path", ")", ";", "$", "list", "=", "$", "this", "->", "ls", "(", "$", "dir", ")", ";", "// be sure it is an array", "if", "(", "is_array", "(", "$", "list", ")", ")", "{", "foreach", "(", "$", "list", "as", "$", "e", ")", "{", "$", "fullpath", "=", "urldecode", "(", "$", "e", "[", "'href'", "]", ")", ";", "$", "filename", "=", "basename", "(", "$", "fullpath", ")", ";", "if", "(", "$", "filename", "==", "$", "item", "&&", "$", "filename", "!=", "\"\"", "and", "$", "fullpath", "!=", "$", "dir", ".", "\"/\"", ")", "{", "return", "$", "e", ";", "}", "}", "}", "return", "false", ";", "}" ]
Public method gpi Get's path information from webdav server for one element. @param string path @return array dirinfo. false on error
[ "Public", "method", "gpi" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L879-L901
212,507
moodle/moodle
lib/webdavlib.php
webdav_client.is_file
function is_file($path) { $item = $this->gpi($path); if ($item === false) { return false; } else { return ($item['resourcetype'] != 'collection'); } }
php
function is_file($path) { $item = $this->gpi($path); if ($item === false) { return false; } else { return ($item['resourcetype'] != 'collection'); } }
[ "function", "is_file", "(", "$", "path", ")", "{", "$", "item", "=", "$", "this", "->", "gpi", "(", "$", "path", ")", ";", "if", "(", "$", "item", "===", "false", ")", "{", "return", "false", ";", "}", "else", "{", "return", "(", "$", "item", "[", "'resourcetype'", "]", "!=", "'collection'", ")", ";", "}", "}" ]
Public method is_file Gathers whether a path points to a file or not. @param string path @return bool true or false
[ "Public", "method", "is_file" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L911-L920
212,508
moodle/moodle
lib/webdavlib.php
webdav_client.is_dir
function is_dir($path) { // be sure path is utf-8 $item = $this->gpi($path); if ($item === false) { return false; } else { return ($item['resourcetype'] == 'collection'); } }
php
function is_dir($path) { // be sure path is utf-8 $item = $this->gpi($path); if ($item === false) { return false; } else { return ($item['resourcetype'] == 'collection'); } }
[ "function", "is_dir", "(", "$", "path", ")", "{", "// be sure path is utf-8", "$", "item", "=", "$", "this", "->", "gpi", "(", "$", "path", ")", ";", "if", "(", "$", "item", "===", "false", ")", "{", "return", "false", ";", "}", "else", "{", "return", "(", "$", "item", "[", "'resourcetype'", "]", "==", "'collection'", ")", ";", "}", "}" ]
Public method is_dir Gather whether a path points to a directory @param string path return bool true or false
[ "Public", "method", "is_dir" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L929-L939
212,509
moodle/moodle
lib/webdavlib.php
webdav_client.mput
function mput($filelist) { $result = true; foreach ($filelist as $localpath => $destpath) { $localpath = rtrim($localpath, "/"); $destpath = rtrim($destpath, "/"); // attempt to create target path if (is_dir($localpath)) { $pathparts = explode("/", $destpath."/ "); // add one level, last level will be created as dir } else { $pathparts = explode("/", $destpath); } $checkpath = ""; for ($i=1; $i<sizeof($pathparts)-1; $i++) { $checkpath .= "/" . $pathparts[$i]; if (!($this->is_dir($checkpath))) { $result &= ($this->mkcol($checkpath) == 201 ); } } if ($result) { // recurse directories if (is_dir($localpath)) { if (!$dp = opendir($localpath)) { $this->_error_log("Could not open localpath for reading"); return false; } $fl = array(); while($filename = readdir($dp)) { if ((is_file($localpath."/".$filename) || is_dir($localpath."/".$filename)) && $filename!="." && $filename != "..") { $fl[$localpath."/".$filename] = $destpath."/".$filename; } } $result &= $this->mput($fl); } else { $result &= ($this->put_file($destpath, $localpath) == 201); } } } return $result; }
php
function mput($filelist) { $result = true; foreach ($filelist as $localpath => $destpath) { $localpath = rtrim($localpath, "/"); $destpath = rtrim($destpath, "/"); // attempt to create target path if (is_dir($localpath)) { $pathparts = explode("/", $destpath."/ "); // add one level, last level will be created as dir } else { $pathparts = explode("/", $destpath); } $checkpath = ""; for ($i=1; $i<sizeof($pathparts)-1; $i++) { $checkpath .= "/" . $pathparts[$i]; if (!($this->is_dir($checkpath))) { $result &= ($this->mkcol($checkpath) == 201 ); } } if ($result) { // recurse directories if (is_dir($localpath)) { if (!$dp = opendir($localpath)) { $this->_error_log("Could not open localpath for reading"); return false; } $fl = array(); while($filename = readdir($dp)) { if ((is_file($localpath."/".$filename) || is_dir($localpath."/".$filename)) && $filename!="." && $filename != "..") { $fl[$localpath."/".$filename] = $destpath."/".$filename; } } $result &= $this->mput($fl); } else { $result &= ($this->put_file($destpath, $localpath) == 201); } } } return $result; }
[ "function", "mput", "(", "$", "filelist", ")", "{", "$", "result", "=", "true", ";", "foreach", "(", "$", "filelist", "as", "$", "localpath", "=>", "$", "destpath", ")", "{", "$", "localpath", "=", "rtrim", "(", "$", "localpath", ",", "\"/\"", ")", ";", "$", "destpath", "=", "rtrim", "(", "$", "destpath", ",", "\"/\"", ")", ";", "// attempt to create target path", "if", "(", "is_dir", "(", "$", "localpath", ")", ")", "{", "$", "pathparts", "=", "explode", "(", "\"/\"", ",", "$", "destpath", ".", "\"/ \"", ")", ";", "// add one level, last level will be created as dir", "}", "else", "{", "$", "pathparts", "=", "explode", "(", "\"/\"", ",", "$", "destpath", ")", ";", "}", "$", "checkpath", "=", "\"\"", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "sizeof", "(", "$", "pathparts", ")", "-", "1", ";", "$", "i", "++", ")", "{", "$", "checkpath", ".=", "\"/\"", ".", "$", "pathparts", "[", "$", "i", "]", ";", "if", "(", "!", "(", "$", "this", "->", "is_dir", "(", "$", "checkpath", ")", ")", ")", "{", "$", "result", "&=", "(", "$", "this", "->", "mkcol", "(", "$", "checkpath", ")", "==", "201", ")", ";", "}", "}", "if", "(", "$", "result", ")", "{", "// recurse directories", "if", "(", "is_dir", "(", "$", "localpath", ")", ")", "{", "if", "(", "!", "$", "dp", "=", "opendir", "(", "$", "localpath", ")", ")", "{", "$", "this", "->", "_error_log", "(", "\"Could not open localpath for reading\"", ")", ";", "return", "false", ";", "}", "$", "fl", "=", "array", "(", ")", ";", "while", "(", "$", "filename", "=", "readdir", "(", "$", "dp", ")", ")", "{", "if", "(", "(", "is_file", "(", "$", "localpath", ".", "\"/\"", ".", "$", "filename", ")", "||", "is_dir", "(", "$", "localpath", ".", "\"/\"", ".", "$", "filename", ")", ")", "&&", "$", "filename", "!=", "\".\"", "&&", "$", "filename", "!=", "\"..\"", ")", "{", "$", "fl", "[", "$", "localpath", ".", "\"/\"", ".", "$", "filename", "]", "=", "$", "destpath", ".", "\"/\"", ".", "$", "filename", ";", "}", "}", "$", "result", "&=", "$", "this", "->", "mput", "(", "$", "fl", ")", ";", "}", "else", "{", "$", "result", "&=", "(", "$", "this", "->", "put_file", "(", "$", "destpath", ",", "$", "localpath", ")", "==", "201", ")", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Public method mput Puts multiple files and/or directories onto a webdav server. Filenames should be allready UTF-8 encoded. Param fileList must be in format array("localpath" => "destpath"). @param array filelist @return bool true on success. otherwise int status code on error
[ "Public", "method", "mput" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L953-L997
212,510
moodle/moodle
lib/webdavlib.php
webdav_client.mget
function mget($filelist) { $result = true; foreach ($filelist as $remotepath => $localpath) { $localpath = rtrim($localpath, "/"); $remotepath = rtrim($remotepath, "/"); // attempt to create local path if ($this->is_dir($remotepath)) { $pathparts = explode("/", $localpath."/ "); // add one level, last level will be created as dir } else { $pathparts = explode("/", $localpath); } $checkpath = ""; for ($i=1; $i<sizeof($pathparts)-1; $i++) { $checkpath .= "/" . $pathparts[$i]; if (!is_dir($checkpath)) { $result &= mkdir($checkpath); } } if ($result) { // recurse directories if ($this->is_dir($remotepath)) { $list = $this->ls($remotepath); $fl = array(); foreach($list as $e) { $fullpath = urldecode($e['href']); $filename = basename($fullpath); if ($filename != '' and $fullpath != $remotepath . '/') { $fl[$remotepath."/".$filename] = $localpath."/".$filename; } } $result &= $this->mget($fl); } else { $result &= ($this->get_file($remotepath, $localpath)); } } } return $result; }
php
function mget($filelist) { $result = true; foreach ($filelist as $remotepath => $localpath) { $localpath = rtrim($localpath, "/"); $remotepath = rtrim($remotepath, "/"); // attempt to create local path if ($this->is_dir($remotepath)) { $pathparts = explode("/", $localpath."/ "); // add one level, last level will be created as dir } else { $pathparts = explode("/", $localpath); } $checkpath = ""; for ($i=1; $i<sizeof($pathparts)-1; $i++) { $checkpath .= "/" . $pathparts[$i]; if (!is_dir($checkpath)) { $result &= mkdir($checkpath); } } if ($result) { // recurse directories if ($this->is_dir($remotepath)) { $list = $this->ls($remotepath); $fl = array(); foreach($list as $e) { $fullpath = urldecode($e['href']); $filename = basename($fullpath); if ($filename != '' and $fullpath != $remotepath . '/') { $fl[$remotepath."/".$filename] = $localpath."/".$filename; } } $result &= $this->mget($fl); } else { $result &= ($this->get_file($remotepath, $localpath)); } } } return $result; }
[ "function", "mget", "(", "$", "filelist", ")", "{", "$", "result", "=", "true", ";", "foreach", "(", "$", "filelist", "as", "$", "remotepath", "=>", "$", "localpath", ")", "{", "$", "localpath", "=", "rtrim", "(", "$", "localpath", ",", "\"/\"", ")", ";", "$", "remotepath", "=", "rtrim", "(", "$", "remotepath", ",", "\"/\"", ")", ";", "// attempt to create local path", "if", "(", "$", "this", "->", "is_dir", "(", "$", "remotepath", ")", ")", "{", "$", "pathparts", "=", "explode", "(", "\"/\"", ",", "$", "localpath", ".", "\"/ \"", ")", ";", "// add one level, last level will be created as dir", "}", "else", "{", "$", "pathparts", "=", "explode", "(", "\"/\"", ",", "$", "localpath", ")", ";", "}", "$", "checkpath", "=", "\"\"", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "sizeof", "(", "$", "pathparts", ")", "-", "1", ";", "$", "i", "++", ")", "{", "$", "checkpath", ".=", "\"/\"", ".", "$", "pathparts", "[", "$", "i", "]", ";", "if", "(", "!", "is_dir", "(", "$", "checkpath", ")", ")", "{", "$", "result", "&=", "mkdir", "(", "$", "checkpath", ")", ";", "}", "}", "if", "(", "$", "result", ")", "{", "// recurse directories", "if", "(", "$", "this", "->", "is_dir", "(", "$", "remotepath", ")", ")", "{", "$", "list", "=", "$", "this", "->", "ls", "(", "$", "remotepath", ")", ";", "$", "fl", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "e", ")", "{", "$", "fullpath", "=", "urldecode", "(", "$", "e", "[", "'href'", "]", ")", ";", "$", "filename", "=", "basename", "(", "$", "fullpath", ")", ";", "if", "(", "$", "filename", "!=", "''", "and", "$", "fullpath", "!=", "$", "remotepath", ".", "'/'", ")", "{", "$", "fl", "[", "$", "remotepath", ".", "\"/\"", ".", "$", "filename", "]", "=", "$", "localpath", ".", "\"/\"", ".", "$", "filename", ";", "}", "}", "$", "result", "&=", "$", "this", "->", "mget", "(", "$", "fl", ")", ";", "}", "else", "{", "$", "result", "&=", "(", "$", "this", "->", "get_file", "(", "$", "remotepath", ",", "$", "localpath", ")", ")", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Public method mget Gets multiple files and directories. FileList must be in format array("remotepath" => "localpath"). Filenames are UTF-8 encoded. @param array filelist @return bool true on succes, other int status code on error
[ "Public", "method", "mget" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1010-L1054
212,511
moodle/moodle
lib/webdavlib.php
webdav_client._endElement
private function _endElement($parser, $name) { // end tag was found... $parserid = (int) $parser; $this->_xmltree[$parserid] = substr($this->_xmltree[$parserid],0, strlen($this->_xmltree[$parserid]) - (strlen($name) + 1)); }
php
private function _endElement($parser, $name) { // end tag was found... $parserid = (int) $parser; $this->_xmltree[$parserid] = substr($this->_xmltree[$parserid],0, strlen($this->_xmltree[$parserid]) - (strlen($name) + 1)); }
[ "private", "function", "_endElement", "(", "$", "parser", ",", "$", "name", ")", "{", "// end tag was found...", "$", "parserid", "=", "(", "int", ")", "$", "parser", ";", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", "=", "substr", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ",", "0", ",", "strlen", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ")", "-", "(", "strlen", "(", "$", "name", ")", "+", "1", ")", ")", ";", "}" ]
Private method _endelement a generic endElement method (used for all xml callbacks). @param resource parser, string name @access private
[ "Private", "method", "_endelement" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1070-L1074
212,512
moodle/moodle
lib/webdavlib.php
webdav_client._propfind_startElement
private function _propfind_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); if (!empty($this->_xmltree[$parserid])) { $this->_xmltree[$parserid] .= $propname . '_'; } else { $this->_xmltree[$parserid] = $propname . '_'; } // translate xml tree to a flat array ... switch($this->_xmltree[$parserid]) { case 'dav::multistatus_dav::response_': // new element in mu $this->_ls_ref =& $this->_ls[$parserid][]; break; case 'dav::multistatus_dav::response_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['href']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::creationdate_': $this->_ls_ref_cdata = &$this->_ls_ref['creationdate']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getlastmodified_': $this->_ls_ref_cdata = &$this->_ls_ref['lastmodified']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontenttype_': $this->_ls_ref_cdata = &$this->_ls_ref['getcontenttype']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontentlength_': $this->_ls_ref_cdata = &$this->_ls_ref['getcontentlength']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_depth']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_owner']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_owner']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_timeout']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_token']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_type']; $this->_ls_ref_cdata = 'write'; $this->_ls_ref_cdata = &$this->_null; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::resourcetype_dav::collection_': $this->_ls_ref_cdata = &$this->_ls_ref['resourcetype']; $this->_ls_ref_cdata = 'collection'; $this->_ls_ref_cdata = &$this->_null; break; case 'dav::multistatus_dav::response_dav::propstat_dav::status_': $this->_ls_ref_cdata = &$this->_ls_ref['status']; break; default: // handle unknown xml elements... $this->_ls_ref_cdata = &$this->_ls_ref[$this->_xmltree[$parserid]]; } }
php
private function _propfind_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); if (!empty($this->_xmltree[$parserid])) { $this->_xmltree[$parserid] .= $propname . '_'; } else { $this->_xmltree[$parserid] = $propname . '_'; } // translate xml tree to a flat array ... switch($this->_xmltree[$parserid]) { case 'dav::multistatus_dav::response_': // new element in mu $this->_ls_ref =& $this->_ls[$parserid][]; break; case 'dav::multistatus_dav::response_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['href']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::creationdate_': $this->_ls_ref_cdata = &$this->_ls_ref['creationdate']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getlastmodified_': $this->_ls_ref_cdata = &$this->_ls_ref['lastmodified']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontenttype_': $this->_ls_ref_cdata = &$this->_ls_ref['getcontenttype']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontentlength_': $this->_ls_ref_cdata = &$this->_ls_ref['getcontentlength']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_depth']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_owner']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_owner']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_timeout']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_token']; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_': $this->_ls_ref_cdata = &$this->_ls_ref['activelock_type']; $this->_ls_ref_cdata = 'write'; $this->_ls_ref_cdata = &$this->_null; break; case 'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::resourcetype_dav::collection_': $this->_ls_ref_cdata = &$this->_ls_ref['resourcetype']; $this->_ls_ref_cdata = 'collection'; $this->_ls_ref_cdata = &$this->_null; break; case 'dav::multistatus_dav::response_dav::propstat_dav::status_': $this->_ls_ref_cdata = &$this->_ls_ref['status']; break; default: // handle unknown xml elements... $this->_ls_ref_cdata = &$this->_ls_ref[$this->_xmltree[$parserid]]; } }
[ "private", "function", "_propfind_startElement", "(", "$", "parser", ",", "$", "name", ",", "$", "attrs", ")", "{", "// lower XML Names... maybe break a RFC, don't know ...", "$", "parserid", "=", "(", "int", ")", "$", "parser", ";", "$", "propname", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ")", ")", "{", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ".=", "$", "propname", ".", "'_'", ";", "}", "else", "{", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", "=", "$", "propname", ".", "'_'", ";", "}", "// translate xml tree to a flat array ...", "switch", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ")", "{", "case", "'dav::multistatus_dav::response_'", ":", "// new element in mu", "$", "this", "->", "_ls_ref", "=", "&", "$", "this", "->", "_ls", "[", "$", "parserid", "]", "[", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::href_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'href'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::creationdate_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'creationdate'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getlastmodified_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'lastmodified'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontenttype_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'getcontenttype'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::getcontentlength_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'getcontentlength'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_depth'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_owner'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_owner'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_timeout'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_token'", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'activelock_type'", "]", ";", "$", "this", "->", "_ls_ref_cdata", "=", "'write'", ";", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_null", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::prop_dav::resourcetype_dav::collection_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'resourcetype'", "]", ";", "$", "this", "->", "_ls_ref_cdata", "=", "'collection'", ";", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_null", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::propstat_dav::status_'", ":", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'status'", "]", ";", "break", ";", "default", ":", "// handle unknown xml elements...", "$", "this", "->", "_ls_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", "]", ";", "}", "}" ]
Private method _propfind_startElement Is needed by public method ls. Generic method will called by php xml_parse when a xml start element tag has been detected. The xml tree will translated into a flat php array for easier access. @param resource parser, string name, string attrs @access private
[ "Private", "method", "_propfind_startElement" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1086-L1151
212,513
moodle/moodle
lib/webdavlib.php
webdav_client._delete_startElement
private function _delete_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); $this->_xmltree[$parserid] .= $propname . '_'; // translate xml tree to a flat array ... switch($this->_xmltree[$parserid]) { case 'dav::multistatus_dav::response_': // new element in mu $this->_delete_ref =& $this->_delete[$parserid][]; break; case 'dav::multistatus_dav::response_dav::href_': $this->_delete_ref_cdata = &$this->_ls_ref['href']; break; default: // handle unknown xml elements... $this->_delete_cdata = &$this->_delete_ref[$this->_xmltree[$parserid]]; } }
php
private function _delete_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); $this->_xmltree[$parserid] .= $propname . '_'; // translate xml tree to a flat array ... switch($this->_xmltree[$parserid]) { case 'dav::multistatus_dav::response_': // new element in mu $this->_delete_ref =& $this->_delete[$parserid][]; break; case 'dav::multistatus_dav::response_dav::href_': $this->_delete_ref_cdata = &$this->_ls_ref['href']; break; default: // handle unknown xml elements... $this->_delete_cdata = &$this->_delete_ref[$this->_xmltree[$parserid]]; } }
[ "private", "function", "_delete_startElement", "(", "$", "parser", ",", "$", "name", ",", "$", "attrs", ")", "{", "// lower XML Names... maybe break a RFC, don't know ...", "$", "parserid", "=", "(", "int", ")", "$", "parser", ";", "$", "propname", "=", "strtolower", "(", "$", "name", ")", ";", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ".=", "$", "propname", ".", "'_'", ";", "// translate xml tree to a flat array ...", "switch", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ")", "{", "case", "'dav::multistatus_dav::response_'", ":", "// new element in mu", "$", "this", "->", "_delete_ref", "=", "&", "$", "this", "->", "_delete", "[", "$", "parserid", "]", "[", "]", ";", "break", ";", "case", "'dav::multistatus_dav::response_dav::href_'", ":", "$", "this", "->", "_delete_ref_cdata", "=", "&", "$", "this", "->", "_ls_ref", "[", "'href'", "]", ";", "break", ";", "default", ":", "// handle unknown xml elements...", "$", "this", "->", "_delete_cdata", "=", "&", "$", "this", "->", "_delete_ref", "[", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", "]", ";", "}", "}" ]
Private method _delete_startElement Is used by public method delete. Will be called by php xml_parse. @param resource parser, string name, string attrs) @access private
[ "Private", "method", "_delete_startElement" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1182-L1202
212,514
moodle/moodle
lib/webdavlib.php
webdav_client._lock_startElement
private function _lock_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); $this->_xmltree[$parserid] .= $propname . '_'; // translate xml tree to a flat array ... /* dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_= dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_= dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_= dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_= */ switch($this->_xmltree[$parserid]) { case 'dav::prop_dav::lockdiscovery_dav::activelock_': // new element $this->_lock_ref =& $this->_lock[$parserid][]; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_': $this->_lock_ref_cdata = &$this->_lock_ref['locktype']; $this->_lock_cdata = 'write'; $this->_lock_cdata = &$this->_null; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::lockscope_dav::exclusive_': $this->_lock_ref_cdata = &$this->_lock_ref['lockscope']; $this->_lock_ref_cdata = 'exclusive'; $this->_lock_ref_cdata = &$this->_null; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_': $this->_lock_ref_cdata = &$this->_lock_ref['depth']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_': $this->_lock_ref_cdata = &$this->_lock_ref['owner']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_': $this->_lock_ref_cdata = &$this->_lock_ref['timeout']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_': $this->_lock_ref_cdata = &$this->_lock_ref['locktoken']; break; default: // handle unknown xml elements... $this->_lock_cdata = &$this->_lock_ref[$this->_xmltree[$parserid]]; } }
php
private function _lock_startElement($parser, $name, $attrs) { // lower XML Names... maybe break a RFC, don't know ... $parserid = (int) $parser; $propname = strtolower($name); $this->_xmltree[$parserid] .= $propname . '_'; // translate xml tree to a flat array ... /* dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_= dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_= dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_= dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_= */ switch($this->_xmltree[$parserid]) { case 'dav::prop_dav::lockdiscovery_dav::activelock_': // new element $this->_lock_ref =& $this->_lock[$parserid][]; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_': $this->_lock_ref_cdata = &$this->_lock_ref['locktype']; $this->_lock_cdata = 'write'; $this->_lock_cdata = &$this->_null; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::lockscope_dav::exclusive_': $this->_lock_ref_cdata = &$this->_lock_ref['lockscope']; $this->_lock_ref_cdata = 'exclusive'; $this->_lock_ref_cdata = &$this->_null; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_': $this->_lock_ref_cdata = &$this->_lock_ref['depth']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_': $this->_lock_ref_cdata = &$this->_lock_ref['owner']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_': $this->_lock_ref_cdata = &$this->_lock_ref['timeout']; break; case 'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_': $this->_lock_ref_cdata = &$this->_lock_ref['locktoken']; break; default: // handle unknown xml elements... $this->_lock_cdata = &$this->_lock_ref[$this->_xmltree[$parserid]]; } }
[ "private", "function", "_lock_startElement", "(", "$", "parser", ",", "$", "name", ",", "$", "attrs", ")", "{", "// lower XML Names... maybe break a RFC, don't know ...", "$", "parserid", "=", "(", "int", ")", "$", "parser", ";", "$", "propname", "=", "strtolower", "(", "$", "name", ")", ";", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ".=", "$", "propname", ".", "'_'", ";", "// translate xml tree to a flat array ...", "/*\n dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_=\n dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_=\n dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_=\n dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_=\n */", "switch", "(", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", ")", "{", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_'", ":", "// new element", "$", "this", "->", "_lock_ref", "=", "&", "$", "this", "->", "_lock", "[", "$", "parserid", "]", "[", "]", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktype_dav::write_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'locktype'", "]", ";", "$", "this", "->", "_lock_cdata", "=", "'write'", ";", "$", "this", "->", "_lock_cdata", "=", "&", "$", "this", "->", "_null", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::lockscope_dav::exclusive_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'lockscope'", "]", ";", "$", "this", "->", "_lock_ref_cdata", "=", "'exclusive'", ";", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_null", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::depth_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'depth'", "]", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::owner_dav::href_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'owner'", "]", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::timeout_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'timeout'", "]", ";", "break", ";", "case", "'dav::prop_dav::lockdiscovery_dav::activelock_dav::locktoken_dav::href_'", ":", "$", "this", "->", "_lock_ref_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "'locktoken'", "]", ";", "break", ";", "default", ":", "// handle unknown xml elements...", "$", "this", "->", "_lock_cdata", "=", "&", "$", "this", "->", "_lock_ref", "[", "$", "this", "->", "_xmltree", "[", "$", "parserid", "]", "]", ";", "}", "}" ]
Private method _lock_startElement Is needed by public method lock. Mmethod will called by php xml_parse when a xml start element tag has been detected. The xml tree will translated into a flat php array for easier access. @param resource parser, string name, string attrs @access private
[ "Private", "method", "_lock_startElement" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1234-L1279
212,515
moodle/moodle
lib/webdavlib.php
webdav_client._lock_cData
private function _lock_cData($parser, $cdata) { $parserid = (int) $parser; if (trim($cdata) <> '') { // $this->_error_log(($this->_xmltree[$parserid]) . '='. htmlentities($cdata)); $this->_lock_ref_cdata .= $cdata; } else { // do nothing } }
php
private function _lock_cData($parser, $cdata) { $parserid = (int) $parser; if (trim($cdata) <> '') { // $this->_error_log(($this->_xmltree[$parserid]) . '='. htmlentities($cdata)); $this->_lock_ref_cdata .= $cdata; } else { // do nothing } }
[ "private", "function", "_lock_cData", "(", "$", "parser", ",", "$", "cdata", ")", "{", "$", "parserid", "=", "(", "int", ")", "$", "parser", ";", "if", "(", "trim", "(", "$", "cdata", ")", "<>", "''", ")", "{", "// $this->_error_log(($this->_xmltree[$parserid]) . '='. htmlentities($cdata));", "$", "this", "->", "_lock_ref_cdata", ".=", "$", "cdata", ";", "}", "else", "{", "// do nothing", "}", "}" ]
Private method _lock_cData Is used by public method lock. Will be called by php xml_set_character_data_handler() when xml data has to be handled. Stores data found into class var _lock_ref_cdata @param resource parser, string cdata @access private
[ "Private", "method", "_lock_cData" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1291-L1299
212,516
moodle/moodle
lib/webdavlib.php
webdav_client.create_basic_request
private function create_basic_request($method) { $this->header_add(sprintf('%s %s %s', $method, $this->_path, $this->_protocol)); $this->header_add(sprintf('Host: %s:%s', $this->_server, $this->_port)); //$request .= sprintf('Connection: Keep-Alive'); $this->header_add(sprintf('User-Agent: %s', $this->_user_agent)); $this->header_add('Connection: TE'); $this->header_add('TE: Trailers'); if ($this->_auth == 'basic') { $this->header_add(sprintf('Authorization: Basic %s', base64_encode("$this->_user:$this->_pass"))); } else if ($this->_auth == 'digest') { if ($signature = $this->digest_signature($method)){ $this->header_add($signature); } } else if ($this->_auth == 'bearer') { $this->header_add(sprintf('Authorization: Bearer %s', $this->oauthtoken)); } }
php
private function create_basic_request($method) { $this->header_add(sprintf('%s %s %s', $method, $this->_path, $this->_protocol)); $this->header_add(sprintf('Host: %s:%s', $this->_server, $this->_port)); //$request .= sprintf('Connection: Keep-Alive'); $this->header_add(sprintf('User-Agent: %s', $this->_user_agent)); $this->header_add('Connection: TE'); $this->header_add('TE: Trailers'); if ($this->_auth == 'basic') { $this->header_add(sprintf('Authorization: Basic %s', base64_encode("$this->_user:$this->_pass"))); } else if ($this->_auth == 'digest') { if ($signature = $this->digest_signature($method)){ $this->header_add($signature); } } else if ($this->_auth == 'bearer') { $this->header_add(sprintf('Authorization: Bearer %s', $this->oauthtoken)); } }
[ "private", "function", "create_basic_request", "(", "$", "method", ")", "{", "$", "this", "->", "header_add", "(", "sprintf", "(", "'%s %s %s'", ",", "$", "method", ",", "$", "this", "->", "_path", ",", "$", "this", "->", "_protocol", ")", ")", ";", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Host: %s:%s'", ",", "$", "this", "->", "_server", ",", "$", "this", "->", "_port", ")", ")", ";", "//$request .= sprintf('Connection: Keep-Alive');", "$", "this", "->", "header_add", "(", "sprintf", "(", "'User-Agent: %s'", ",", "$", "this", "->", "_user_agent", ")", ")", ";", "$", "this", "->", "header_add", "(", "'Connection: TE'", ")", ";", "$", "this", "->", "header_add", "(", "'TE: Trailers'", ")", ";", "if", "(", "$", "this", "->", "_auth", "==", "'basic'", ")", "{", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Authorization: Basic %s'", ",", "base64_encode", "(", "\"$this->_user:$this->_pass\"", ")", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "_auth", "==", "'digest'", ")", "{", "if", "(", "$", "signature", "=", "$", "this", "->", "digest_signature", "(", "$", "method", ")", ")", "{", "$", "this", "->", "header_add", "(", "$", "signature", ")", ";", "}", "}", "else", "if", "(", "$", "this", "->", "_auth", "==", "'bearer'", ")", "{", "$", "this", "->", "header_add", "(", "sprintf", "(", "'Authorization: Bearer %s'", ",", "$", "this", "->", "oauthtoken", ")", ")", ";", "}", "}" ]
Private method create_basic_request creates by using private method header_add an general request header. @param string method @access private
[ "Private", "method", "create_basic_request" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1331-L1347
212,517
moodle/moodle
lib/webdavlib.php
webdav_client.digest_auth
private function digest_auth() { $headers = array(); $headers[] = sprintf('%s %s %s', 'HEAD', $this->_path, $this->_protocol); $headers[] = sprintf('Host: %s:%s', $this->_server, $this->_port); $headers[] = sprintf('User-Agent: %s', $this->_user_agent); $headers = implode("\r\n", $headers); $headers .= "\r\n\r\n"; fputs($this->sock, $headers); // Reads the headers. $i = 0; $header = ''; do { $header .= fread($this->sock, 1); $i++; } while (!preg_match('/\\r\\n\\r\\n$/', $header, $matches) && $i < $this->_maxheaderlenth); // Analyse the headers. $digest = array(); $splitheaders = explode("\r\n", $header); foreach ($splitheaders as $line) { if (!preg_match('/^WWW-Authenticate: Digest/', $line)) { continue; } $line = substr($line, strlen('WWW-Authenticate: Digest ')); $params = explode(',', $line); foreach ($params as $param) { list($key, $value) = explode('=', trim($param), 2); $digest[$key] = trim($value, '"'); } break; } $this->_digestchallenge = $digest; }
php
private function digest_auth() { $headers = array(); $headers[] = sprintf('%s %s %s', 'HEAD', $this->_path, $this->_protocol); $headers[] = sprintf('Host: %s:%s', $this->_server, $this->_port); $headers[] = sprintf('User-Agent: %s', $this->_user_agent); $headers = implode("\r\n", $headers); $headers .= "\r\n\r\n"; fputs($this->sock, $headers); // Reads the headers. $i = 0; $header = ''; do { $header .= fread($this->sock, 1); $i++; } while (!preg_match('/\\r\\n\\r\\n$/', $header, $matches) && $i < $this->_maxheaderlenth); // Analyse the headers. $digest = array(); $splitheaders = explode("\r\n", $header); foreach ($splitheaders as $line) { if (!preg_match('/^WWW-Authenticate: Digest/', $line)) { continue; } $line = substr($line, strlen('WWW-Authenticate: Digest ')); $params = explode(',', $line); foreach ($params as $param) { list($key, $value) = explode('=', trim($param), 2); $digest[$key] = trim($value, '"'); } break; } $this->_digestchallenge = $digest; }
[ "private", "function", "digest_auth", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "'%s %s %s'", ",", "'HEAD'", ",", "$", "this", "->", "_path", ",", "$", "this", "->", "_protocol", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "'Host: %s:%s'", ",", "$", "this", "->", "_server", ",", "$", "this", "->", "_port", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "'User-Agent: %s'", ",", "$", "this", "->", "_user_agent", ")", ";", "$", "headers", "=", "implode", "(", "\"\\r\\n\"", ",", "$", "headers", ")", ";", "$", "headers", ".=", "\"\\r\\n\\r\\n\"", ";", "fputs", "(", "$", "this", "->", "sock", ",", "$", "headers", ")", ";", "// Reads the headers.", "$", "i", "=", "0", ";", "$", "header", "=", "''", ";", "do", "{", "$", "header", ".=", "fread", "(", "$", "this", "->", "sock", ",", "1", ")", ";", "$", "i", "++", ";", "}", "while", "(", "!", "preg_match", "(", "'/\\\\r\\\\n\\\\r\\\\n$/'", ",", "$", "header", ",", "$", "matches", ")", "&&", "$", "i", "<", "$", "this", "->", "_maxheaderlenth", ")", ";", "// Analyse the headers.", "$", "digest", "=", "array", "(", ")", ";", "$", "splitheaders", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "header", ")", ";", "foreach", "(", "$", "splitheaders", "as", "$", "line", ")", "{", "if", "(", "!", "preg_match", "(", "'/^WWW-Authenticate: Digest/'", ",", "$", "line", ")", ")", "{", "continue", ";", "}", "$", "line", "=", "substr", "(", "$", "line", ",", "strlen", "(", "'WWW-Authenticate: Digest '", ")", ")", ";", "$", "params", "=", "explode", "(", "','", ",", "$", "line", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "'='", ",", "trim", "(", "$", "param", ")", ",", "2", ")", ";", "$", "digest", "[", "$", "key", "]", "=", "trim", "(", "$", "value", ",", "'\"'", ")", ";", "}", "break", ";", "}", "$", "this", "->", "_digestchallenge", "=", "$", "digest", ";", "}" ]
Reads the header, stores the challenge information @return void
[ "Reads", "the", "header", "stores", "the", "challenge", "information" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1354-L1389
212,518
moodle/moodle
lib/webdavlib.php
webdav_client.digest_signature
private function digest_signature($method) { if (!$this->_digestchallenge) { $this->digest_auth(); } $signature = array(); $signature['username'] = '"' . $this->_user . '"'; $signature['realm'] = '"' . $this->_digestchallenge['realm'] . '"'; $signature['nonce'] = '"' . $this->_digestchallenge['nonce'] . '"'; $signature['uri'] = '"' . $this->_path . '"'; if (isset($this->_digestchallenge['algorithm']) && $this->_digestchallenge['algorithm'] != 'MD5') { $this->_error_log('Algorithm other than MD5 are not supported'); return false; } $a1 = $this->_user . ':' . $this->_digestchallenge['realm'] . ':' . $this->_pass; $a2 = $method . ':' . $this->_path; if (!isset($this->_digestchallenge['qop'])) { $signature['response'] = '"' . md5(md5($a1) . ':' . $this->_digestchallenge['nonce'] . ':' . md5($a2)) . '"'; } else { // Assume QOP is auth if (empty($this->_cnonce)) { $this->_cnonce = random_string(); $this->_nc = 0; } $this->_nc++; $nc = sprintf('%08d', $this->_nc); $signature['cnonce'] = '"' . $this->_cnonce . '"'; $signature['nc'] = '"' . $nc . '"'; $signature['qop'] = '"' . $this->_digestchallenge['qop'] . '"'; $signature['response'] = '"' . md5(md5($a1) . ':' . $this->_digestchallenge['nonce'] . ':' . $nc . ':' . $this->_cnonce . ':' . $this->_digestchallenge['qop'] . ':' . md5($a2)) . '"'; } $response = array(); foreach ($signature as $key => $value) { $response[] = "$key=$value"; } return 'Authorization: Digest ' . implode(', ', $response); }
php
private function digest_signature($method) { if (!$this->_digestchallenge) { $this->digest_auth(); } $signature = array(); $signature['username'] = '"' . $this->_user . '"'; $signature['realm'] = '"' . $this->_digestchallenge['realm'] . '"'; $signature['nonce'] = '"' . $this->_digestchallenge['nonce'] . '"'; $signature['uri'] = '"' . $this->_path . '"'; if (isset($this->_digestchallenge['algorithm']) && $this->_digestchallenge['algorithm'] != 'MD5') { $this->_error_log('Algorithm other than MD5 are not supported'); return false; } $a1 = $this->_user . ':' . $this->_digestchallenge['realm'] . ':' . $this->_pass; $a2 = $method . ':' . $this->_path; if (!isset($this->_digestchallenge['qop'])) { $signature['response'] = '"' . md5(md5($a1) . ':' . $this->_digestchallenge['nonce'] . ':' . md5($a2)) . '"'; } else { // Assume QOP is auth if (empty($this->_cnonce)) { $this->_cnonce = random_string(); $this->_nc = 0; } $this->_nc++; $nc = sprintf('%08d', $this->_nc); $signature['cnonce'] = '"' . $this->_cnonce . '"'; $signature['nc'] = '"' . $nc . '"'; $signature['qop'] = '"' . $this->_digestchallenge['qop'] . '"'; $signature['response'] = '"' . md5(md5($a1) . ':' . $this->_digestchallenge['nonce'] . ':' . $nc . ':' . $this->_cnonce . ':' . $this->_digestchallenge['qop'] . ':' . md5($a2)) . '"'; } $response = array(); foreach ($signature as $key => $value) { $response[] = "$key=$value"; } return 'Authorization: Digest ' . implode(', ', $response); }
[ "private", "function", "digest_signature", "(", "$", "method", ")", "{", "if", "(", "!", "$", "this", "->", "_digestchallenge", ")", "{", "$", "this", "->", "digest_auth", "(", ")", ";", "}", "$", "signature", "=", "array", "(", ")", ";", "$", "signature", "[", "'username'", "]", "=", "'\"'", ".", "$", "this", "->", "_user", ".", "'\"'", ";", "$", "signature", "[", "'realm'", "]", "=", "'\"'", ".", "$", "this", "->", "_digestchallenge", "[", "'realm'", "]", ".", "'\"'", ";", "$", "signature", "[", "'nonce'", "]", "=", "'\"'", ".", "$", "this", "->", "_digestchallenge", "[", "'nonce'", "]", ".", "'\"'", ";", "$", "signature", "[", "'uri'", "]", "=", "'\"'", ".", "$", "this", "->", "_path", ".", "'\"'", ";", "if", "(", "isset", "(", "$", "this", "->", "_digestchallenge", "[", "'algorithm'", "]", ")", "&&", "$", "this", "->", "_digestchallenge", "[", "'algorithm'", "]", "!=", "'MD5'", ")", "{", "$", "this", "->", "_error_log", "(", "'Algorithm other than MD5 are not supported'", ")", ";", "return", "false", ";", "}", "$", "a1", "=", "$", "this", "->", "_user", ".", "':'", ".", "$", "this", "->", "_digestchallenge", "[", "'realm'", "]", ".", "':'", ".", "$", "this", "->", "_pass", ";", "$", "a2", "=", "$", "method", ".", "':'", ".", "$", "this", "->", "_path", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_digestchallenge", "[", "'qop'", "]", ")", ")", "{", "$", "signature", "[", "'response'", "]", "=", "'\"'", ".", "md5", "(", "md5", "(", "$", "a1", ")", ".", "':'", ".", "$", "this", "->", "_digestchallenge", "[", "'nonce'", "]", ".", "':'", ".", "md5", "(", "$", "a2", ")", ")", ".", "'\"'", ";", "}", "else", "{", "// Assume QOP is auth", "if", "(", "empty", "(", "$", "this", "->", "_cnonce", ")", ")", "{", "$", "this", "->", "_cnonce", "=", "random_string", "(", ")", ";", "$", "this", "->", "_nc", "=", "0", ";", "}", "$", "this", "->", "_nc", "++", ";", "$", "nc", "=", "sprintf", "(", "'%08d'", ",", "$", "this", "->", "_nc", ")", ";", "$", "signature", "[", "'cnonce'", "]", "=", "'\"'", ".", "$", "this", "->", "_cnonce", ".", "'\"'", ";", "$", "signature", "[", "'nc'", "]", "=", "'\"'", ".", "$", "nc", ".", "'\"'", ";", "$", "signature", "[", "'qop'", "]", "=", "'\"'", ".", "$", "this", "->", "_digestchallenge", "[", "'qop'", "]", ".", "'\"'", ";", "$", "signature", "[", "'response'", "]", "=", "'\"'", ".", "md5", "(", "md5", "(", "$", "a1", ")", ".", "':'", ".", "$", "this", "->", "_digestchallenge", "[", "'nonce'", "]", ".", "':'", ".", "$", "nc", ".", "':'", ".", "$", "this", "->", "_cnonce", ".", "':'", ".", "$", "this", "->", "_digestchallenge", "[", "'qop'", "]", ".", "':'", ".", "md5", "(", "$", "a2", ")", ")", ".", "'\"'", ";", "}", "$", "response", "=", "array", "(", ")", ";", "foreach", "(", "$", "signature", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "response", "[", "]", "=", "\"$key=$value\"", ";", "}", "return", "'Authorization: Digest '", ".", "implode", "(", "', '", ",", "$", "response", ")", ";", "}" ]
Generates the digest signature @return string signature to add to the headers @access private
[ "Generates", "the", "digest", "signature" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1397-L1438
212,519
moodle/moodle
lib/webdavlib.php
webdav_client.send_request
private function send_request() { // check if stream is declared to be open // only logical check we are not sure if socket is really still open ... if ($this->_connection_closed) { // reopen it // be sure to close the open socket. $this->close(); $this->reopen(); } // convert array to string $buffer = implode("\r\n", $this->_req); $buffer .= "\r\n\r\n"; $this->_error_log($buffer); fputs($this->sock, $buffer); }
php
private function send_request() { // check if stream is declared to be open // only logical check we are not sure if socket is really still open ... if ($this->_connection_closed) { // reopen it // be sure to close the open socket. $this->close(); $this->reopen(); } // convert array to string $buffer = implode("\r\n", $this->_req); $buffer .= "\r\n\r\n"; $this->_error_log($buffer); fputs($this->sock, $buffer); }
[ "private", "function", "send_request", "(", ")", "{", "// check if stream is declared to be open", "// only logical check we are not sure if socket is really still open ...", "if", "(", "$", "this", "->", "_connection_closed", ")", "{", "// reopen it", "// be sure to close the open socket.", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "reopen", "(", ")", ";", "}", "// convert array to string", "$", "buffer", "=", "implode", "(", "\"\\r\\n\"", ",", "$", "this", "->", "_req", ")", ";", "$", "buffer", ".=", "\"\\r\\n\\r\\n\"", ";", "$", "this", "->", "_error_log", "(", "$", "buffer", ")", ";", "fputs", "(", "$", "this", "->", "sock", ",", "$", "buffer", ")", ";", "}" ]
Private method send_request Sends a ready formed http/webdav request to webdav server. @access private
[ "Private", "method", "send_request" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1447-L1462
212,520
moodle/moodle
lib/webdavlib.php
webdav_client.process_respond
private function process_respond() { $lines = explode("\r\n", $this->_header); $header_done = false; // $this->_error_log($this->_buffer); // First line should be a HTTP status line (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6) // Format is: HTTP-Version SP Status-Code SP Reason-Phrase CRLF list($ret_struct['status']['http-version'], $ret_struct['status']['status-code'], $ret_struct['status']['reason-phrase']) = explode(' ', $lines[0],3); // print "HTTP Version: '$http_version' Status-Code: '$status_code' Reason Phrase: '$reason_phrase'<br>"; // get the response header fields // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6 for($i=1; $i<count($lines); $i++) { if (rtrim($lines[$i]) == '' && !$header_done) { $header_done = true; // print "--- response header end ---<br>"; } if (!$header_done ) { // store all found headers in array ... list($fieldname, $fieldvalue) = explode(':', $lines[$i]); // check if this header was allready set (apache 2.0 webdav module does this....). // If so we add the the value to the end the fieldvalue, separated by comma... if (empty($ret_struct['header'])) { $ret_struct['header'] = array(); } if (empty($ret_struct['header'][$fieldname])) { $ret_struct['header'][$fieldname] = trim($fieldvalue); } else { $ret_struct['header'][$fieldname] .= ',' . trim($fieldvalue); } } } // print 'string len of response_body:'. strlen($response_body); // print '[' . htmlentities($response_body) . ']'; $ret_struct['body'] = $this->_body; $this->_error_log('process_respond: ' . var_export($ret_struct,true)); return $ret_struct; }
php
private function process_respond() { $lines = explode("\r\n", $this->_header); $header_done = false; // $this->_error_log($this->_buffer); // First line should be a HTTP status line (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6) // Format is: HTTP-Version SP Status-Code SP Reason-Phrase CRLF list($ret_struct['status']['http-version'], $ret_struct['status']['status-code'], $ret_struct['status']['reason-phrase']) = explode(' ', $lines[0],3); // print "HTTP Version: '$http_version' Status-Code: '$status_code' Reason Phrase: '$reason_phrase'<br>"; // get the response header fields // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6 for($i=1; $i<count($lines); $i++) { if (rtrim($lines[$i]) == '' && !$header_done) { $header_done = true; // print "--- response header end ---<br>"; } if (!$header_done ) { // store all found headers in array ... list($fieldname, $fieldvalue) = explode(':', $lines[$i]); // check if this header was allready set (apache 2.0 webdav module does this....). // If so we add the the value to the end the fieldvalue, separated by comma... if (empty($ret_struct['header'])) { $ret_struct['header'] = array(); } if (empty($ret_struct['header'][$fieldname])) { $ret_struct['header'][$fieldname] = trim($fieldvalue); } else { $ret_struct['header'][$fieldname] .= ',' . trim($fieldvalue); } } } // print 'string len of response_body:'. strlen($response_body); // print '[' . htmlentities($response_body) . ']'; $ret_struct['body'] = $this->_body; $this->_error_log('process_respond: ' . var_export($ret_struct,true)); return $ret_struct; }
[ "private", "function", "process_respond", "(", ")", "{", "$", "lines", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "this", "->", "_header", ")", ";", "$", "header_done", "=", "false", ";", "// $this->_error_log($this->_buffer);", "// First line should be a HTTP status line (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6)", "// Format is: HTTP-Version SP Status-Code SP Reason-Phrase CRLF", "list", "(", "$", "ret_struct", "[", "'status'", "]", "[", "'http-version'", "]", ",", "$", "ret_struct", "[", "'status'", "]", "[", "'status-code'", "]", ",", "$", "ret_struct", "[", "'status'", "]", "[", "'reason-phrase'", "]", ")", "=", "explode", "(", "' '", ",", "$", "lines", "[", "0", "]", ",", "3", ")", ";", "// print \"HTTP Version: '$http_version' Status-Code: '$status_code' Reason Phrase: '$reason_phrase'<br>\";", "// get the response header fields", "// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "count", "(", "$", "lines", ")", ";", "$", "i", "++", ")", "{", "if", "(", "rtrim", "(", "$", "lines", "[", "$", "i", "]", ")", "==", "''", "&&", "!", "$", "header_done", ")", "{", "$", "header_done", "=", "true", ";", "// print \"--- response header end ---<br>\";", "}", "if", "(", "!", "$", "header_done", ")", "{", "// store all found headers in array ...", "list", "(", "$", "fieldname", ",", "$", "fieldvalue", ")", "=", "explode", "(", "':'", ",", "$", "lines", "[", "$", "i", "]", ")", ";", "// check if this header was allready set (apache 2.0 webdav module does this....).", "// If so we add the the value to the end the fieldvalue, separated by comma...", "if", "(", "empty", "(", "$", "ret_struct", "[", "'header'", "]", ")", ")", "{", "$", "ret_struct", "[", "'header'", "]", "=", "array", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "ret_struct", "[", "'header'", "]", "[", "$", "fieldname", "]", ")", ")", "{", "$", "ret_struct", "[", "'header'", "]", "[", "$", "fieldname", "]", "=", "trim", "(", "$", "fieldvalue", ")", ";", "}", "else", "{", "$", "ret_struct", "[", "'header'", "]", "[", "$", "fieldname", "]", ".=", "','", ".", "trim", "(", "$", "fieldvalue", ")", ";", "}", "}", "}", "// print 'string len of response_body:'. strlen($response_body);", "// print '[' . htmlentities($response_body) . ']';", "$", "ret_struct", "[", "'body'", "]", "=", "$", "this", "->", "_body", ";", "$", "this", "->", "_error_log", "(", "'process_respond: '", ".", "var_export", "(", "$", "ret_struct", ",", "true", ")", ")", ";", "return", "$", "ret_struct", ";", "}" ]
Private method process_respond Processes the webdav server respond and detects its components (header, body). and returns data array structure. @return array ret_struct @access private
[ "Private", "method", "process_respond" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1645-L1685
212,521
moodle/moodle
lib/webdavlib.php
webdav_client.translate_uri
private function translate_uri($uri) { // remove all html entities... $native_path = html_entity_decode($uri); $parts = explode('/', $native_path); for ($i = 0; $i < count($parts); $i++) { // check if part is allready utf8 if (iconv('UTF-8', 'UTF-8', $parts[$i]) == $parts[$i]) { $parts[$i] = rawurlencode($parts[$i]); } else { $parts[$i] = rawurlencode(utf8_encode($parts[$i])); } } return implode('/', $parts); }
php
private function translate_uri($uri) { // remove all html entities... $native_path = html_entity_decode($uri); $parts = explode('/', $native_path); for ($i = 0; $i < count($parts); $i++) { // check if part is allready utf8 if (iconv('UTF-8', 'UTF-8', $parts[$i]) == $parts[$i]) { $parts[$i] = rawurlencode($parts[$i]); } else { $parts[$i] = rawurlencode(utf8_encode($parts[$i])); } } return implode('/', $parts); }
[ "private", "function", "translate_uri", "(", "$", "uri", ")", "{", "// remove all html entities...", "$", "native_path", "=", "html_entity_decode", "(", "$", "uri", ")", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "native_path", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "parts", ")", ";", "$", "i", "++", ")", "{", "// check if part is allready utf8", "if", "(", "iconv", "(", "'UTF-8'", ",", "'UTF-8'", ",", "$", "parts", "[", "$", "i", "]", ")", "==", "$", "parts", "[", "$", "i", "]", ")", "{", "$", "parts", "[", "$", "i", "]", "=", "rawurlencode", "(", "$", "parts", "[", "$", "i", "]", ")", ";", "}", "else", "{", "$", "parts", "[", "$", "i", "]", "=", "rawurlencode", "(", "utf8_encode", "(", "$", "parts", "[", "$", "i", "]", ")", ")", ";", "}", "}", "return", "implode", "(", "'/'", ",", "$", "parts", ")", ";", "}" ]
Private method translate_uri translates an uri to raw url encoded string. Removes any html entity in uri @param string uri @return string translated_uri @access private
[ "Private", "method", "translate_uri" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1711-L1724
212,522
moodle/moodle
lib/webdavlib.php
webdav_client.utf_decode_path
private function utf_decode_path($path) { $fullpath = $path; if (iconv('UTF-8', 'UTF-8', $fullpath) == $fullpath) { $this->_error_log("filename is utf-8. Needs conversion..."); $fullpath = utf8_decode($fullpath); } return $fullpath; }
php
private function utf_decode_path($path) { $fullpath = $path; if (iconv('UTF-8', 'UTF-8', $fullpath) == $fullpath) { $this->_error_log("filename is utf-8. Needs conversion..."); $fullpath = utf8_decode($fullpath); } return $fullpath; }
[ "private", "function", "utf_decode_path", "(", "$", "path", ")", "{", "$", "fullpath", "=", "$", "path", ";", "if", "(", "iconv", "(", "'UTF-8'", ",", "'UTF-8'", ",", "$", "fullpath", ")", "==", "$", "fullpath", ")", "{", "$", "this", "->", "_error_log", "(", "\"filename is utf-8. Needs conversion...\"", ")", ";", "$", "fullpath", "=", "utf8_decode", "(", "$", "fullpath", ")", ";", "}", "return", "$", "fullpath", ";", "}" ]
Private method utf_decode_path decodes a UTF-8 encoded string @return string decodedstring @access private
[ "Private", "method", "utf_decode_path" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/webdavlib.php#L1733-L1740
212,523
moodle/moodle
lib/dml/sqlsrv_native_moodle_recordset.php
sqlsrv_native_moodle_recordset.transaction_starts
public function transaction_starts() { if ($this->buffer !== null) { $this->unregister(); return; } if (!$this->rsrc) { $this->unregister(); return; } // This might eat memory pretty quickly... raise_memory_limit('2G'); $this->buffer = array(); while($next = $this->fetch_next()) { $this->buffer[] = $next; } }
php
public function transaction_starts() { if ($this->buffer !== null) { $this->unregister(); return; } if (!$this->rsrc) { $this->unregister(); return; } // This might eat memory pretty quickly... raise_memory_limit('2G'); $this->buffer = array(); while($next = $this->fetch_next()) { $this->buffer[] = $next; } }
[ "public", "function", "transaction_starts", "(", ")", "{", "if", "(", "$", "this", "->", "buffer", "!==", "null", ")", "{", "$", "this", "->", "unregister", "(", ")", ";", "return", ";", "}", "if", "(", "!", "$", "this", "->", "rsrc", ")", "{", "$", "this", "->", "unregister", "(", ")", ";", "return", ";", "}", "// This might eat memory pretty quickly...", "raise_memory_limit", "(", "'2G'", ")", ";", "$", "this", "->", "buffer", "=", "array", "(", ")", ";", "while", "(", "$", "next", "=", "$", "this", "->", "fetch_next", "(", ")", ")", "{", "$", "this", "->", "buffer", "[", "]", "=", "$", "next", ";", "}", "}" ]
Inform existing open recordsets that transaction is starting, this works around MARS problem described in MDL-37734.
[ "Inform", "existing", "open", "recordsets", "that", "transaction", "is", "starting", "this", "works", "around", "MARS", "problem", "described", "in", "MDL", "-", "37734", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/sqlsrv_native_moodle_recordset.php#L51-L67
212,524
moodle/moodle
lib/dml/sqlsrv_native_moodle_recordset.php
sqlsrv_native_moodle_recordset.unregister
private function unregister() { if ($this->db) { $this->db->recordset_closed($this); $this->db = null; } }
php
private function unregister() { if ($this->db) { $this->db->recordset_closed($this); $this->db = null; } }
[ "private", "function", "unregister", "(", ")", "{", "if", "(", "$", "this", "->", "db", ")", "{", "$", "this", "->", "db", "->", "recordset_closed", "(", "$", "this", ")", ";", "$", "this", "->", "db", "=", "null", ";", "}", "}" ]
Unregister recordset from the global list of open recordsets.
[ "Unregister", "recordset", "from", "the", "global", "list", "of", "open", "recordsets", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/sqlsrv_native_moodle_recordset.php#L72-L77
212,525
moodle/moodle
mod/workshop/allocation/scheduled/classes/observer.php
observer.workshop_viewed
public static function workshop_viewed($event) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/workshop/locallib.php'); $workshop = $event->get_record_snapshot('workshop', $event->objectid); $course = $event->get_record_snapshot('course', $event->courseid); $cm = $event->get_record_snapshot('course_modules', $event->contextinstanceid); $workshop = new \workshop($workshop, $cm, $course); $now = time(); // Non-expensive check to see if the scheduled allocation can even happen. if ($workshop->phase == \workshop::PHASE_SUBMISSION and $workshop->submissionend > 0 and $workshop->submissionend < $now) { // Make sure the scheduled allocation has been configured for this workshop, that it has not // been executed yet and that the passed workshop record is still valid. $sql = "SELECT a.id FROM {workshopallocation_scheduled} a JOIN {workshop} w ON a.workshopid = w.id WHERE w.id = :workshopid AND a.enabled = 1 AND w.phase = :phase AND w.submissionend > 0 AND w.submissionend < :now AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)"; $params = array('workshopid' => $workshop->id, 'phase' => \workshop::PHASE_SUBMISSION, 'now' => $now); if ($DB->record_exists_sql($sql, $params)) { // Allocate submissions for assessments. $allocator = $workshop->allocator_instance('scheduled'); $result = $allocator->execute(); // Todo inform the teachers about the results. } } return true; }
php
public static function workshop_viewed($event) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/workshop/locallib.php'); $workshop = $event->get_record_snapshot('workshop', $event->objectid); $course = $event->get_record_snapshot('course', $event->courseid); $cm = $event->get_record_snapshot('course_modules', $event->contextinstanceid); $workshop = new \workshop($workshop, $cm, $course); $now = time(); // Non-expensive check to see if the scheduled allocation can even happen. if ($workshop->phase == \workshop::PHASE_SUBMISSION and $workshop->submissionend > 0 and $workshop->submissionend < $now) { // Make sure the scheduled allocation has been configured for this workshop, that it has not // been executed yet and that the passed workshop record is still valid. $sql = "SELECT a.id FROM {workshopallocation_scheduled} a JOIN {workshop} w ON a.workshopid = w.id WHERE w.id = :workshopid AND a.enabled = 1 AND w.phase = :phase AND w.submissionend > 0 AND w.submissionend < :now AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)"; $params = array('workshopid' => $workshop->id, 'phase' => \workshop::PHASE_SUBMISSION, 'now' => $now); if ($DB->record_exists_sql($sql, $params)) { // Allocate submissions for assessments. $allocator = $workshop->allocator_instance('scheduled'); $result = $allocator->execute(); // Todo inform the teachers about the results. } } return true; }
[ "public", "static", "function", "workshop_viewed", "(", "$", "event", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/workshop/locallib.php'", ")", ";", "$", "workshop", "=", "$", "event", "->", "get_record_snapshot", "(", "'workshop'", ",", "$", "event", "->", "objectid", ")", ";", "$", "course", "=", "$", "event", "->", "get_record_snapshot", "(", "'course'", ",", "$", "event", "->", "courseid", ")", ";", "$", "cm", "=", "$", "event", "->", "get_record_snapshot", "(", "'course_modules'", ",", "$", "event", "->", "contextinstanceid", ")", ";", "$", "workshop", "=", "new", "\\", "workshop", "(", "$", "workshop", ",", "$", "cm", ",", "$", "course", ")", ";", "$", "now", "=", "time", "(", ")", ";", "// Non-expensive check to see if the scheduled allocation can even happen.", "if", "(", "$", "workshop", "->", "phase", "==", "\\", "workshop", "::", "PHASE_SUBMISSION", "and", "$", "workshop", "->", "submissionend", ">", "0", "and", "$", "workshop", "->", "submissionend", "<", "$", "now", ")", "{", "// Make sure the scheduled allocation has been configured for this workshop, that it has not", "// been executed yet and that the passed workshop record is still valid.", "$", "sql", "=", "\"SELECT a.id\n FROM {workshopallocation_scheduled} a\n JOIN {workshop} w ON a.workshopid = w.id\n WHERE w.id = :workshopid\n AND a.enabled = 1\n AND w.phase = :phase\n AND w.submissionend > 0\n AND w.submissionend < :now\n AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)\"", ";", "$", "params", "=", "array", "(", "'workshopid'", "=>", "$", "workshop", "->", "id", ",", "'phase'", "=>", "\\", "workshop", "::", "PHASE_SUBMISSION", ",", "'now'", "=>", "$", "now", ")", ";", "if", "(", "$", "DB", "->", "record_exists_sql", "(", "$", "sql", ",", "$", "params", ")", ")", "{", "// Allocate submissions for assessments.", "$", "allocator", "=", "$", "workshop", "->", "allocator_instance", "(", "'scheduled'", ")", ";", "$", "result", "=", "$", "allocator", "->", "execute", "(", ")", ";", "// Todo inform the teachers about the results.", "}", "}", "return", "true", ";", "}" ]
Triggered when the '\mod_workshop\event\course_module_viewed' event is triggered. This does the same job as {@link workshopallocation_scheduled_cron()} but for the single workshop. The idea is that we do not need to wait for cron to execute. Displaying the workshop main view.php can trigger the scheduled allocation, too. @param \mod_workshop\event\course_module_viewed $event @return bool
[ "Triggered", "when", "the", "\\", "mod_workshop", "\\", "event", "\\", "course_module_viewed", "event", "is", "triggered", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/allocation/scheduled/classes/observer.php#L47-L83
212,526
moodle/moodle
mod/forum/classes/prune_form.php
mod_forum_prune_form.definition
public function definition() { $mform = $this->_form; $mform->addElement('text', 'name', get_string('discussionname', 'forum'), array('size' => '60', 'maxlength' => '255')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->add_action_buttons(true, get_string('prune', 'forum')); $mform->addElement('hidden', 'prune'); $mform->setType('prune', PARAM_INT); $mform->setConstant('prune', $this->_customdata['prune']); $mform->addElement('hidden', 'confirm'); $mform->setType('confirm', PARAM_INT); $mform->setConstant('confirm', $this->_customdata['confirm']); }
php
public function definition() { $mform = $this->_form; $mform->addElement('text', 'name', get_string('discussionname', 'forum'), array('size' => '60', 'maxlength' => '255')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->add_action_buttons(true, get_string('prune', 'forum')); $mform->addElement('hidden', 'prune'); $mform->setType('prune', PARAM_INT); $mform->setConstant('prune', $this->_customdata['prune']); $mform->addElement('hidden', 'confirm'); $mform->setType('confirm', PARAM_INT); $mform->setConstant('confirm', $this->_customdata['confirm']); }
[ "public", "function", "definition", "(", ")", "{", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "mform", "->", "addElement", "(", "'text'", ",", "'name'", ",", "get_string", "(", "'discussionname'", ",", "'forum'", ")", ",", "array", "(", "'size'", "=>", "'60'", ",", "'maxlength'", "=>", "'255'", ")", ")", ";", "$", "mform", "->", "setType", "(", "'name'", ",", "PARAM_TEXT", ")", ";", "$", "mform", "->", "addRule", "(", "'name'", ",", "null", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "$", "mform", "->", "addRule", "(", "'name'", ",", "get_string", "(", "'maximumchars'", ",", "''", ",", "255", ")", ",", "'maxlength'", ",", "255", ",", "'client'", ")", ";", "$", "this", "->", "add_action_buttons", "(", "true", ",", "get_string", "(", "'prune'", ",", "'forum'", ")", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'prune'", ")", ";", "$", "mform", "->", "setType", "(", "'prune'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "setConstant", "(", "'prune'", ",", "$", "this", "->", "_customdata", "[", "'prune'", "]", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'confirm'", ")", ";", "$", "mform", "->", "setType", "(", "'confirm'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "setConstant", "(", "'confirm'", ",", "$", "this", "->", "_customdata", "[", "'confirm'", "]", ")", ";", "}" ]
Form constructor.
[ "Form", "constructor", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/prune_form.php#L44-L60
212,527
moodle/moodle
blocks/calendar_upcoming/block_calendar_upcoming.php
block_calendar_upcoming.get_upcoming_content
public static function get_upcoming_content($events, $linkhref = null, $showcourselink = false) { debugging( 'get_upcoming_content() is deprecated. ' . 'Please see block_calendar_upcoming::get_content() for the correct API usage.', DEBUG_DEVELOPER ); $content = ''; $lines = count($events); if (!$lines) { return $content; } for ($i = 0; $i < $lines; ++$i) { if (!isset($events[$i]->time)) { continue; } $events[$i] = calendar_add_event_metadata($events[$i]); $content .= '<div class="event"><span class="icon c0">' . $events[$i]->icon . '</span>'; if (!empty($events[$i]->referer)) { // That's an activity event, so let's provide the hyperlink. $content .= $events[$i]->referer; } else { if (!empty($linkhref)) { $href = calendar_get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0, $events[$i]->timestart); $href->set_anchor('event_' . $events[$i]->id); $content .= \html_writer::link($href, $events[$i]->name); } else { $content .= $events[$i]->name; } } $events[$i]->time = str_replace('&raquo;', '<br />&raquo;', $events[$i]->time); if ($showcourselink && !empty($events[$i]->courselink)) { $content .= \html_writer::div($events[$i]->courselink, 'course'); } $content .= '<div class="date">' . $events[$i]->time . '</div></div>'; if ($i < $lines - 1) { $content .= '<hr />'; } } return $content; }
php
public static function get_upcoming_content($events, $linkhref = null, $showcourselink = false) { debugging( 'get_upcoming_content() is deprecated. ' . 'Please see block_calendar_upcoming::get_content() for the correct API usage.', DEBUG_DEVELOPER ); $content = ''; $lines = count($events); if (!$lines) { return $content; } for ($i = 0; $i < $lines; ++$i) { if (!isset($events[$i]->time)) { continue; } $events[$i] = calendar_add_event_metadata($events[$i]); $content .= '<div class="event"><span class="icon c0">' . $events[$i]->icon . '</span>'; if (!empty($events[$i]->referer)) { // That's an activity event, so let's provide the hyperlink. $content .= $events[$i]->referer; } else { if (!empty($linkhref)) { $href = calendar_get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0, $events[$i]->timestart); $href->set_anchor('event_' . $events[$i]->id); $content .= \html_writer::link($href, $events[$i]->name); } else { $content .= $events[$i]->name; } } $events[$i]->time = str_replace('&raquo;', '<br />&raquo;', $events[$i]->time); if ($showcourselink && !empty($events[$i]->courselink)) { $content .= \html_writer::div($events[$i]->courselink, 'course'); } $content .= '<div class="date">' . $events[$i]->time . '</div></div>'; if ($i < $lines - 1) { $content .= '<hr />'; } } return $content; }
[ "public", "static", "function", "get_upcoming_content", "(", "$", "events", ",", "$", "linkhref", "=", "null", ",", "$", "showcourselink", "=", "false", ")", "{", "debugging", "(", "'get_upcoming_content() is deprecated. '", ".", "'Please see block_calendar_upcoming::get_content() for the correct API usage.'", ",", "DEBUG_DEVELOPER", ")", ";", "$", "content", "=", "''", ";", "$", "lines", "=", "count", "(", "$", "events", ")", ";", "if", "(", "!", "$", "lines", ")", "{", "return", "$", "content", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "lines", ";", "++", "$", "i", ")", "{", "if", "(", "!", "isset", "(", "$", "events", "[", "$", "i", "]", "->", "time", ")", ")", "{", "continue", ";", "}", "$", "events", "[", "$", "i", "]", "=", "calendar_add_event_metadata", "(", "$", "events", "[", "$", "i", "]", ")", ";", "$", "content", ".=", "'<div class=\"event\"><span class=\"icon c0\">'", ".", "$", "events", "[", "$", "i", "]", "->", "icon", ".", "'</span>'", ";", "if", "(", "!", "empty", "(", "$", "events", "[", "$", "i", "]", "->", "referer", ")", ")", "{", "// That's an activity event, so let's provide the hyperlink.", "$", "content", ".=", "$", "events", "[", "$", "i", "]", "->", "referer", ";", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "linkhref", ")", ")", "{", "$", "href", "=", "calendar_get_link_href", "(", "new", "\\", "moodle_url", "(", "CALENDAR_URL", ".", "$", "linkhref", ")", ",", "0", ",", "0", ",", "0", ",", "$", "events", "[", "$", "i", "]", "->", "timestart", ")", ";", "$", "href", "->", "set_anchor", "(", "'event_'", ".", "$", "events", "[", "$", "i", "]", "->", "id", ")", ";", "$", "content", ".=", "\\", "html_writer", "::", "link", "(", "$", "href", ",", "$", "events", "[", "$", "i", "]", "->", "name", ")", ";", "}", "else", "{", "$", "content", ".=", "$", "events", "[", "$", "i", "]", "->", "name", ";", "}", "}", "$", "events", "[", "$", "i", "]", "->", "time", "=", "str_replace", "(", "'&raquo;'", ",", "'<br />&raquo;'", ",", "$", "events", "[", "$", "i", "]", "->", "time", ")", ";", "if", "(", "$", "showcourselink", "&&", "!", "empty", "(", "$", "events", "[", "$", "i", "]", "->", "courselink", ")", ")", "{", "$", "content", ".=", "\\", "html_writer", "::", "div", "(", "$", "events", "[", "$", "i", "]", "->", "courselink", ",", "'course'", ")", ";", "}", "$", "content", ".=", "'<div class=\"date\">'", ".", "$", "events", "[", "$", "i", "]", "->", "time", ".", "'</div></div>'", ";", "if", "(", "$", "i", "<", "$", "lines", "-", "1", ")", "{", "$", "content", ".=", "'<hr />'", ";", "}", "}", "return", "$", "content", ";", "}" ]
Get the upcoming event block content. @param array $events list of events @param \moodle_url|string $linkhref link to event referer @param boolean $showcourselink whether links to courses should be shown @return string|null $content html block content @deprecated since 3.4
[ "Get", "the", "upcoming", "event", "block", "content", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/calendar_upcoming/block_calendar_upcoming.php#L82-L126
212,528
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List.remove
public function remove($obs) { $old = $this->_filter; $this->setIteratorFilter(self::HIDE_GROUPS | self::BASE_ELEMENTS); foreach ($this->_normalize($obs) as $val) { $remove = array(); foreach ($this as $key => $val2) { if ($val2->match($val)) { $remove[] = $key; } } foreach (array_reverse($remove) as $key) { unset($this[$key]); } } $this->_filter = $old; }
php
public function remove($obs) { $old = $this->_filter; $this->setIteratorFilter(self::HIDE_GROUPS | self::BASE_ELEMENTS); foreach ($this->_normalize($obs) as $val) { $remove = array(); foreach ($this as $key => $val2) { if ($val2->match($val)) { $remove[] = $key; } } foreach (array_reverse($remove) as $key) { unset($this[$key]); } } $this->_filter = $old; }
[ "public", "function", "remove", "(", "$", "obs", ")", "{", "$", "old", "=", "$", "this", "->", "_filter", ";", "$", "this", "->", "setIteratorFilter", "(", "self", "::", "HIDE_GROUPS", "|", "self", "::", "BASE_ELEMENTS", ")", ";", "foreach", "(", "$", "this", "->", "_normalize", "(", "$", "obs", ")", "as", "$", "val", ")", "{", "$", "remove", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "val2", ")", "{", "if", "(", "$", "val2", "->", "match", "(", "$", "val", ")", ")", "{", "$", "remove", "[", "]", "=", "$", "key", ";", "}", "}", "foreach", "(", "array_reverse", "(", "$", "remove", ")", "as", "$", "key", ")", "{", "unset", "(", "$", "this", "[", "$", "key", "]", ")", ";", "}", "}", "$", "this", "->", "_filter", "=", "$", "old", ";", "}" ]
Remove addresses from the container. This method ignores Group objects. @param mixed $obs Addresses to remove.
[ "Remove", "addresses", "from", "the", "container", ".", "This", "method", "ignores", "Group", "objects", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L135-L155
212,529
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List.unique
public function unique() { $exist = $remove = array(); $old = $this->_filter; $this->setIteratorFilter(self::HIDE_GROUPS | self::BASE_ELEMENTS); // For duplicates, we use the first address that contains personal // information. foreach ($this as $key => $val) { $bare = $val->bare_address; if (isset($exist[$bare])) { if (($exist[$bare] == -1) || is_null($val->personal)) { $remove[] = $key; } else { $remove[] = $exist[$bare]; $exist[$bare] = -1; } } else { $exist[$bare] = is_null($val->personal) ? $key : -1; } } foreach (array_reverse($remove) as $key) { unset($this[$key]); } $this->_filter = $old; }
php
public function unique() { $exist = $remove = array(); $old = $this->_filter; $this->setIteratorFilter(self::HIDE_GROUPS | self::BASE_ELEMENTS); // For duplicates, we use the first address that contains personal // information. foreach ($this as $key => $val) { $bare = $val->bare_address; if (isset($exist[$bare])) { if (($exist[$bare] == -1) || is_null($val->personal)) { $remove[] = $key; } else { $remove[] = $exist[$bare]; $exist[$bare] = -1; } } else { $exist[$bare] = is_null($val->personal) ? $key : -1; } } foreach (array_reverse($remove) as $key) { unset($this[$key]); } $this->_filter = $old; }
[ "public", "function", "unique", "(", ")", "{", "$", "exist", "=", "$", "remove", "=", "array", "(", ")", ";", "$", "old", "=", "$", "this", "->", "_filter", ";", "$", "this", "->", "setIteratorFilter", "(", "self", "::", "HIDE_GROUPS", "|", "self", "::", "BASE_ELEMENTS", ")", ";", "// For duplicates, we use the first address that contains personal", "// information.", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "bare", "=", "$", "val", "->", "bare_address", ";", "if", "(", "isset", "(", "$", "exist", "[", "$", "bare", "]", ")", ")", "{", "if", "(", "(", "$", "exist", "[", "$", "bare", "]", "==", "-", "1", ")", "||", "is_null", "(", "$", "val", "->", "personal", ")", ")", "{", "$", "remove", "[", "]", "=", "$", "key", ";", "}", "else", "{", "$", "remove", "[", "]", "=", "$", "exist", "[", "$", "bare", "]", ";", "$", "exist", "[", "$", "bare", "]", "=", "-", "1", ";", "}", "}", "else", "{", "$", "exist", "[", "$", "bare", "]", "=", "is_null", "(", "$", "val", "->", "personal", ")", "?", "$", "key", ":", "-", "1", ";", "}", "}", "foreach", "(", "array_reverse", "(", "$", "remove", ")", "as", "$", "key", ")", "{", "unset", "(", "$", "this", "[", "$", "key", "]", ")", ";", "}", "$", "this", "->", "_filter", "=", "$", "old", ";", "}" ]
Removes duplicate addresses from list. This method ignores Group objects.
[ "Removes", "duplicate", "addresses", "from", "list", ".", "This", "method", "ignores", "Group", "objects", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L161-L191
212,530
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List.groupCount
public function groupCount() { $ret = 0; foreach ($this->_data as $val) { if ($val instanceof Horde_Mail_Rfc822_Group) { ++$ret; } } return $ret; }
php
public function groupCount() { $ret = 0; foreach ($this->_data as $val) { if ($val instanceof Horde_Mail_Rfc822_Group) { ++$ret; } } return $ret; }
[ "public", "function", "groupCount", "(", ")", "{", "$", "ret", "=", "0", ";", "foreach", "(", "$", "this", "->", "_data", "as", "$", "val", ")", "{", "if", "(", "$", "val", "instanceof", "Horde_Mail_Rfc822_Group", ")", "{", "++", "$", "ret", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Group count. @return integer The number of groups in the list.
[ "Group", "count", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L198-L209
212,531
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List.setIteratorFilter
public function setIteratorFilter($mask = 0, $filter = null) { $this->_filter = array(); if ($mask) { $this->_filter['mask'] = $mask; } if (!is_null($filter)) { $rfc822 = new Horde_Mail_Rfc822(); $this->_filter['filter'] = $rfc822->parseAddressList($filter); } }
php
public function setIteratorFilter($mask = 0, $filter = null) { $this->_filter = array(); if ($mask) { $this->_filter['mask'] = $mask; } if (!is_null($filter)) { $rfc822 = new Horde_Mail_Rfc822(); $this->_filter['filter'] = $rfc822->parseAddressList($filter); } }
[ "public", "function", "setIteratorFilter", "(", "$", "mask", "=", "0", ",", "$", "filter", "=", "null", ")", "{", "$", "this", "->", "_filter", "=", "array", "(", ")", ";", "if", "(", "$", "mask", ")", "{", "$", "this", "->", "_filter", "[", "'mask'", "]", "=", "$", "mask", ";", "}", "if", "(", "!", "is_null", "(", "$", "filter", ")", ")", "{", "$", "rfc822", "=", "new", "Horde_Mail_Rfc822", "(", ")", ";", "$", "this", "->", "_filter", "[", "'filter'", "]", "=", "$", "rfc822", "->", "parseAddressList", "(", "$", "filter", ")", ";", "}", "}" ]
Set the Iterator filter. @param integer $mask Filter masks. @param mixed $filter An e-mail, or as list of e-mails, to filter by.
[ "Set", "the", "Iterator", "filter", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L217-L229
212,532
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List.contains
public function contains($address) { $ob = new Horde_Mail_Rfc822_Address($address); foreach ($this->raw_addresses as $val) { if ($val->match($ob)) { return true; } } return false; }
php
public function contains($address) { $ob = new Horde_Mail_Rfc822_Address($address); foreach ($this->raw_addresses as $val) { if ($val->match($ob)) { return true; } } return false; }
[ "public", "function", "contains", "(", "$", "address", ")", "{", "$", "ob", "=", "new", "Horde_Mail_Rfc822_Address", "(", "$", "address", ")", ";", "foreach", "(", "$", "this", "->", "raw_addresses", "as", "$", "val", ")", "{", "if", "(", "$", "val", "->", "match", "(", "$", "ob", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does this list contain the given e-mail address? @param mixed $address An e-mail address. @return boolean True if the e-mail address is contained in the list.
[ "Does", "this", "list", "contain", "the", "given", "e", "-", "mail", "address?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L267-L278
212,533
moodle/moodle
lib/horde/framework/Horde/Mail/Rfc822/List.php
Horde_Mail_Rfc822_List._normalize
protected function _normalize($obs) { $add = array(); if (!($obs instanceof Horde_Mail_Rfc822_List) && !is_array($obs)) { $obs = array($obs); } foreach ($obs as $val) { if (is_string($val)) { $rfc822 = new Horde_Mail_Rfc822(); $val = $rfc822->parseAddressList($val); } if ($val instanceof Horde_Mail_Rfc822_List) { $val->setIteratorFilter(self::BASE_ELEMENTS); foreach ($val as $val2) { $add[] = $val2; } } elseif ($val instanceof Horde_Mail_Rfc822_Object) { $add[] = $val; } } return $add; }
php
protected function _normalize($obs) { $add = array(); if (!($obs instanceof Horde_Mail_Rfc822_List) && !is_array($obs)) { $obs = array($obs); } foreach ($obs as $val) { if (is_string($val)) { $rfc822 = new Horde_Mail_Rfc822(); $val = $rfc822->parseAddressList($val); } if ($val instanceof Horde_Mail_Rfc822_List) { $val->setIteratorFilter(self::BASE_ELEMENTS); foreach ($val as $val2) { $add[] = $val2; } } elseif ($val instanceof Horde_Mail_Rfc822_Object) { $add[] = $val; } } return $add; }
[ "protected", "function", "_normalize", "(", "$", "obs", ")", "{", "$", "add", "=", "array", "(", ")", ";", "if", "(", "!", "(", "$", "obs", "instanceof", "Horde_Mail_Rfc822_List", ")", "&&", "!", "is_array", "(", "$", "obs", ")", ")", "{", "$", "obs", "=", "array", "(", "$", "obs", ")", ";", "}", "foreach", "(", "$", "obs", "as", "$", "val", ")", "{", "if", "(", "is_string", "(", "$", "val", ")", ")", "{", "$", "rfc822", "=", "new", "Horde_Mail_Rfc822", "(", ")", ";", "$", "val", "=", "$", "rfc822", "->", "parseAddressList", "(", "$", "val", ")", ";", "}", "if", "(", "$", "val", "instanceof", "Horde_Mail_Rfc822_List", ")", "{", "$", "val", "->", "setIteratorFilter", "(", "self", "::", "BASE_ELEMENTS", ")", ";", "foreach", "(", "$", "val", "as", "$", "val2", ")", "{", "$", "add", "[", "]", "=", "$", "val2", ";", "}", "}", "elseif", "(", "$", "val", "instanceof", "Horde_Mail_Rfc822_Object", ")", "{", "$", "add", "[", "]", "=", "$", "val", ";", "}", "}", "return", "$", "add", ";", "}" ]
Normalize objects to add to list. @param mixed $obs Address data to store in this object. @return array Entries to add.
[ "Normalize", "objects", "to", "add", "to", "list", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Mail/Rfc822/List.php#L302-L328
212,534
moodle/moodle
lib/phpexcel/PHPExcel/Calculation/LookupRef.php
PHPExcel_Calculation_LookupRef.LOOKUP
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) { $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); if (!is_array($lookup_vector)) { return PHPExcel_Calculation_Functions::NA(); } $lookupRows = count($lookup_vector); $l = array_keys($lookup_vector); $l = array_shift($l); $lookupColumns = count($lookup_vector[$l]); if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) { $lookup_vector = self::TRANSPOSE($lookup_vector); $lookupRows = count($lookup_vector); $l = array_keys($lookup_vector); $lookupColumns = count($lookup_vector[array_shift($l)]); } if (is_null($result_vector)) { $result_vector = $lookup_vector; } $resultRows = count($result_vector); $l = array_keys($result_vector); $l = array_shift($l); $resultColumns = count($result_vector[$l]); if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) { $result_vector = self::TRANSPOSE($result_vector); $resultRows = count($result_vector); $r = array_keys($result_vector); $resultColumns = count($result_vector[array_shift($r)]); } if ($lookupRows == 2) { $result_vector = array_pop($lookup_vector); $lookup_vector = array_shift($lookup_vector); } if ($lookupColumns != 2) { foreach ($lookup_vector as &$value) { if (is_array($value)) { $k = array_keys($value); $key1 = $key2 = array_shift($k); $key2++; $dataValue1 = $value[$key1]; } else { $key1 = 0; $key2 = 1; $dataValue1 = $value; } $dataValue2 = array_shift($result_vector); if (is_array($dataValue2)) { $dataValue2 = array_shift($dataValue2); } $value = array($key1 => $dataValue1, $key2 => $dataValue2); } unset($value); } return self::VLOOKUP($lookup_value, $lookup_vector, 2); }
php
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null) { $lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value); if (!is_array($lookup_vector)) { return PHPExcel_Calculation_Functions::NA(); } $lookupRows = count($lookup_vector); $l = array_keys($lookup_vector); $l = array_shift($l); $lookupColumns = count($lookup_vector[$l]); if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) { $lookup_vector = self::TRANSPOSE($lookup_vector); $lookupRows = count($lookup_vector); $l = array_keys($lookup_vector); $lookupColumns = count($lookup_vector[array_shift($l)]); } if (is_null($result_vector)) { $result_vector = $lookup_vector; } $resultRows = count($result_vector); $l = array_keys($result_vector); $l = array_shift($l); $resultColumns = count($result_vector[$l]); if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) { $result_vector = self::TRANSPOSE($result_vector); $resultRows = count($result_vector); $r = array_keys($result_vector); $resultColumns = count($result_vector[array_shift($r)]); } if ($lookupRows == 2) { $result_vector = array_pop($lookup_vector); $lookup_vector = array_shift($lookup_vector); } if ($lookupColumns != 2) { foreach ($lookup_vector as &$value) { if (is_array($value)) { $k = array_keys($value); $key1 = $key2 = array_shift($k); $key2++; $dataValue1 = $value[$key1]; } else { $key1 = 0; $key2 = 1; $dataValue1 = $value; } $dataValue2 = array_shift($result_vector); if (is_array($dataValue2)) { $dataValue2 = array_shift($dataValue2); } $value = array($key1 => $dataValue1, $key2 => $dataValue2); } unset($value); } return self::VLOOKUP($lookup_value, $lookup_vector, 2); }
[ "public", "static", "function", "LOOKUP", "(", "$", "lookup_value", ",", "$", "lookup_vector", ",", "$", "result_vector", "=", "null", ")", "{", "$", "lookup_value", "=", "PHPExcel_Calculation_Functions", "::", "flattenSingleValue", "(", "$", "lookup_value", ")", ";", "if", "(", "!", "is_array", "(", "$", "lookup_vector", ")", ")", "{", "return", "PHPExcel_Calculation_Functions", "::", "NA", "(", ")", ";", "}", "$", "lookupRows", "=", "count", "(", "$", "lookup_vector", ")", ";", "$", "l", "=", "array_keys", "(", "$", "lookup_vector", ")", ";", "$", "l", "=", "array_shift", "(", "$", "l", ")", ";", "$", "lookupColumns", "=", "count", "(", "$", "lookup_vector", "[", "$", "l", "]", ")", ";", "if", "(", "(", "(", "$", "lookupRows", "==", "1", ")", "&&", "(", "$", "lookupColumns", ">", "1", ")", ")", "||", "(", "(", "$", "lookupRows", "==", "2", ")", "&&", "(", "$", "lookupColumns", "!=", "2", ")", ")", ")", "{", "$", "lookup_vector", "=", "self", "::", "TRANSPOSE", "(", "$", "lookup_vector", ")", ";", "$", "lookupRows", "=", "count", "(", "$", "lookup_vector", ")", ";", "$", "l", "=", "array_keys", "(", "$", "lookup_vector", ")", ";", "$", "lookupColumns", "=", "count", "(", "$", "lookup_vector", "[", "array_shift", "(", "$", "l", ")", "]", ")", ";", "}", "if", "(", "is_null", "(", "$", "result_vector", ")", ")", "{", "$", "result_vector", "=", "$", "lookup_vector", ";", "}", "$", "resultRows", "=", "count", "(", "$", "result_vector", ")", ";", "$", "l", "=", "array_keys", "(", "$", "result_vector", ")", ";", "$", "l", "=", "array_shift", "(", "$", "l", ")", ";", "$", "resultColumns", "=", "count", "(", "$", "result_vector", "[", "$", "l", "]", ")", ";", "if", "(", "(", "(", "$", "resultRows", "==", "1", ")", "&&", "(", "$", "resultColumns", ">", "1", ")", ")", "||", "(", "(", "$", "resultRows", "==", "2", ")", "&&", "(", "$", "resultColumns", "!=", "2", ")", ")", ")", "{", "$", "result_vector", "=", "self", "::", "TRANSPOSE", "(", "$", "result_vector", ")", ";", "$", "resultRows", "=", "count", "(", "$", "result_vector", ")", ";", "$", "r", "=", "array_keys", "(", "$", "result_vector", ")", ";", "$", "resultColumns", "=", "count", "(", "$", "result_vector", "[", "array_shift", "(", "$", "r", ")", "]", ")", ";", "}", "if", "(", "$", "lookupRows", "==", "2", ")", "{", "$", "result_vector", "=", "array_pop", "(", "$", "lookup_vector", ")", ";", "$", "lookup_vector", "=", "array_shift", "(", "$", "lookup_vector", ")", ";", "}", "if", "(", "$", "lookupColumns", "!=", "2", ")", "{", "foreach", "(", "$", "lookup_vector", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "k", "=", "array_keys", "(", "$", "value", ")", ";", "$", "key1", "=", "$", "key2", "=", "array_shift", "(", "$", "k", ")", ";", "$", "key2", "++", ";", "$", "dataValue1", "=", "$", "value", "[", "$", "key1", "]", ";", "}", "else", "{", "$", "key1", "=", "0", ";", "$", "key2", "=", "1", ";", "$", "dataValue1", "=", "$", "value", ";", "}", "$", "dataValue2", "=", "array_shift", "(", "$", "result_vector", ")", ";", "if", "(", "is_array", "(", "$", "dataValue2", ")", ")", "{", "$", "dataValue2", "=", "array_shift", "(", "$", "dataValue2", ")", ";", "}", "$", "value", "=", "array", "(", "$", "key1", "=>", "$", "dataValue1", ",", "$", "key2", "=>", "$", "dataValue2", ")", ";", "}", "unset", "(", "$", "value", ")", ";", "}", "return", "self", "::", "VLOOKUP", "(", "$", "lookup_value", ",", "$", "lookup_vector", ",", "2", ")", ";", "}" ]
LOOKUP The LOOKUP function searches for value either from a one-row or one-column range or from an array. @param lookup_value The value that you want to match in lookup_array @param lookup_vector The range of cells being searched @param result_vector The column from which the matching value must be returned @return mixed The value of the found cell
[ "LOOKUP", "The", "LOOKUP", "function", "searches", "for", "value", "either", "from", "a", "one", "-", "row", "or", "one", "-", "column", "range", "or", "from", "an", "array", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Calculation/LookupRef.php#L819-L877
212,535
moodle/moodle
grade/lib.php
graded_users_iterator.next_user
public function next_user() { if (!$this->users_rs) { return false; // no users present } if (!$this->users_rs->valid()) { if ($current = $this->_pop()) { // this is not good - user or grades updated between the two reads above :-( } return false; // no more users } else { $user = $this->users_rs->current(); $this->users_rs->next(); } // find grades of this user $grade_records = array(); while (true) { if (!$current = $this->_pop()) { break; // no more grades } if (empty($current->userid)) { break; } if ($current->userid != $user->id) { // grade of the next user, we have all for this user $this->_push($current); break; } $grade_records[$current->itemid] = $current; } $grades = array(); $feedbacks = array(); if (!empty($this->grade_items)) { foreach ($this->grade_items as $grade_item) { if (!isset($feedbacks[$grade_item->id])) { $feedbacks[$grade_item->id] = new stdClass(); } if (array_key_exists($grade_item->id, $grade_records)) { $feedbacks[$grade_item->id]->feedback = $grade_records[$grade_item->id]->feedback; $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat; unset($grade_records[$grade_item->id]->feedback); unset($grade_records[$grade_item->id]->feedbackformat); $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false); } else { $feedbacks[$grade_item->id]->feedback = ''; $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE; $grades[$grade_item->id] = new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false); } $grades[$grade_item->id]->grade_item = $grade_item; } } // Set user suspended status. $user->suspendedenrolment = isset($this->suspendedusers[$user->id]); $result = new stdClass(); $result->user = $user; $result->grades = $grades; $result->feedbacks = $feedbacks; return $result; }
php
public function next_user() { if (!$this->users_rs) { return false; // no users present } if (!$this->users_rs->valid()) { if ($current = $this->_pop()) { // this is not good - user or grades updated between the two reads above :-( } return false; // no more users } else { $user = $this->users_rs->current(); $this->users_rs->next(); } // find grades of this user $grade_records = array(); while (true) { if (!$current = $this->_pop()) { break; // no more grades } if (empty($current->userid)) { break; } if ($current->userid != $user->id) { // grade of the next user, we have all for this user $this->_push($current); break; } $grade_records[$current->itemid] = $current; } $grades = array(); $feedbacks = array(); if (!empty($this->grade_items)) { foreach ($this->grade_items as $grade_item) { if (!isset($feedbacks[$grade_item->id])) { $feedbacks[$grade_item->id] = new stdClass(); } if (array_key_exists($grade_item->id, $grade_records)) { $feedbacks[$grade_item->id]->feedback = $grade_records[$grade_item->id]->feedback; $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat; unset($grade_records[$grade_item->id]->feedback); unset($grade_records[$grade_item->id]->feedbackformat); $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false); } else { $feedbacks[$grade_item->id]->feedback = ''; $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE; $grades[$grade_item->id] = new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false); } $grades[$grade_item->id]->grade_item = $grade_item; } } // Set user suspended status. $user->suspendedenrolment = isset($this->suspendedusers[$user->id]); $result = new stdClass(); $result->user = $user; $result->grades = $grades; $result->feedbacks = $feedbacks; return $result; }
[ "public", "function", "next_user", "(", ")", "{", "if", "(", "!", "$", "this", "->", "users_rs", ")", "{", "return", "false", ";", "// no users present", "}", "if", "(", "!", "$", "this", "->", "users_rs", "->", "valid", "(", ")", ")", "{", "if", "(", "$", "current", "=", "$", "this", "->", "_pop", "(", ")", ")", "{", "// this is not good - user or grades updated between the two reads above :-(", "}", "return", "false", ";", "// no more users", "}", "else", "{", "$", "user", "=", "$", "this", "->", "users_rs", "->", "current", "(", ")", ";", "$", "this", "->", "users_rs", "->", "next", "(", ")", ";", "}", "// find grades of this user", "$", "grade_records", "=", "array", "(", ")", ";", "while", "(", "true", ")", "{", "if", "(", "!", "$", "current", "=", "$", "this", "->", "_pop", "(", ")", ")", "{", "break", ";", "// no more grades", "}", "if", "(", "empty", "(", "$", "current", "->", "userid", ")", ")", "{", "break", ";", "}", "if", "(", "$", "current", "->", "userid", "!=", "$", "user", "->", "id", ")", "{", "// grade of the next user, we have all for this user", "$", "this", "->", "_push", "(", "$", "current", ")", ";", "break", ";", "}", "$", "grade_records", "[", "$", "current", "->", "itemid", "]", "=", "$", "current", ";", "}", "$", "grades", "=", "array", "(", ")", ";", "$", "feedbacks", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "grade_items", ")", ")", "{", "foreach", "(", "$", "this", "->", "grade_items", "as", "$", "grade_item", ")", "{", "if", "(", "!", "isset", "(", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", ")", ")", "{", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", "=", "new", "stdClass", "(", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "grade_item", "->", "id", ",", "$", "grade_records", ")", ")", "{", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", "->", "feedback", "=", "$", "grade_records", "[", "$", "grade_item", "->", "id", "]", "->", "feedback", ";", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", "->", "feedbackformat", "=", "$", "grade_records", "[", "$", "grade_item", "->", "id", "]", "->", "feedbackformat", ";", "unset", "(", "$", "grade_records", "[", "$", "grade_item", "->", "id", "]", "->", "feedback", ")", ";", "unset", "(", "$", "grade_records", "[", "$", "grade_item", "->", "id", "]", "->", "feedbackformat", ")", ";", "$", "grades", "[", "$", "grade_item", "->", "id", "]", "=", "new", "grade_grade", "(", "$", "grade_records", "[", "$", "grade_item", "->", "id", "]", ",", "false", ")", ";", "}", "else", "{", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", "->", "feedback", "=", "''", ";", "$", "feedbacks", "[", "$", "grade_item", "->", "id", "]", "->", "feedbackformat", "=", "FORMAT_MOODLE", ";", "$", "grades", "[", "$", "grade_item", "->", "id", "]", "=", "new", "grade_grade", "(", "array", "(", "'userid'", "=>", "$", "user", "->", "id", ",", "'itemid'", "=>", "$", "grade_item", "->", "id", ")", ",", "false", ")", ";", "}", "$", "grades", "[", "$", "grade_item", "->", "id", "]", "->", "grade_item", "=", "$", "grade_item", ";", "}", "}", "// Set user suspended status.", "$", "user", "->", "suspendedenrolment", "=", "isset", "(", "$", "this", "->", "suspendedusers", "[", "$", "user", "->", "id", "]", ")", ";", "$", "result", "=", "new", "stdClass", "(", ")", ";", "$", "result", "->", "user", "=", "$", "user", ";", "$", "result", "->", "grades", "=", "$", "grades", ";", "$", "result", "->", "feedbacks", "=", "$", "feedbacks", ";", "return", "$", "result", ";", "}" ]
Returns information about the next user @return mixed array of user info, all grades and feedback or null when no more users found
[ "Returns", "information", "about", "the", "next", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L255-L322
212,536
moodle/moodle
grade/lib.php
graded_users_iterator.close
public function close() { if ($this->users_rs) { $this->users_rs->close(); $this->users_rs = null; } if ($this->grades_rs) { $this->grades_rs->close(); $this->grades_rs = null; } $this->gradestack = array(); }
php
public function close() { if ($this->users_rs) { $this->users_rs->close(); $this->users_rs = null; } if ($this->grades_rs) { $this->grades_rs->close(); $this->grades_rs = null; } $this->gradestack = array(); }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "users_rs", ")", "{", "$", "this", "->", "users_rs", "->", "close", "(", ")", ";", "$", "this", "->", "users_rs", "=", "null", ";", "}", "if", "(", "$", "this", "->", "grades_rs", ")", "{", "$", "this", "->", "grades_rs", "->", "close", "(", ")", ";", "$", "this", "->", "grades_rs", "=", "null", ";", "}", "$", "this", "->", "gradestack", "=", "array", "(", ")", ";", "}" ]
Close the iterator, do not forget to call this function
[ "Close", "the", "iterator", "do", "not", "forget", "to", "call", "this", "function" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L327-L337
212,537
moodle/moodle
grade/lib.php
graded_users_iterator.require_active_enrolment
public function require_active_enrolment($onlyactive = true) { if (!empty($this->users_rs)) { debugging('Calling require_active_enrolment() has no effect unless you call init() again', DEBUG_DEVELOPER); } $this->onlyactive = $onlyactive; }
php
public function require_active_enrolment($onlyactive = true) { if (!empty($this->users_rs)) { debugging('Calling require_active_enrolment() has no effect unless you call init() again', DEBUG_DEVELOPER); } $this->onlyactive = $onlyactive; }
[ "public", "function", "require_active_enrolment", "(", "$", "onlyactive", "=", "true", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "users_rs", ")", ")", "{", "debugging", "(", "'Calling require_active_enrolment() has no effect unless you call init() again'", ",", "DEBUG_DEVELOPER", ")", ";", "}", "$", "this", "->", "onlyactive", "=", "$", "onlyactive", ";", "}" ]
Should all enrolled users be exported or just those with an active enrolment? @param bool $onlyactive True to limit the export to users with an active enrolment
[ "Should", "all", "enrolled", "users", "be", "exported", "or", "just", "those", "with", "an", "active", "enrolment?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L344-L349
212,538
moodle/moodle
grade/lib.php
graded_users_iterator.allow_user_custom_fields
public function allow_user_custom_fields($allow = true) { if ($allow) { $this->allowusercustomfields = true; } else { $this->allowusercustomfields = false; } }
php
public function allow_user_custom_fields($allow = true) { if ($allow) { $this->allowusercustomfields = true; } else { $this->allowusercustomfields = false; } }
[ "public", "function", "allow_user_custom_fields", "(", "$", "allow", "=", "true", ")", "{", "if", "(", "$", "allow", ")", "{", "$", "this", "->", "allowusercustomfields", "=", "true", ";", "}", "else", "{", "$", "this", "->", "allowusercustomfields", "=", "false", ";", "}", "}" ]
Allow custom fields to be included @param bool $allow Whether to allow custom fields or not @return void
[ "Allow", "custom", "fields", "to", "be", "included" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L357-L363
212,539
moodle/moodle
grade/lib.php
graded_users_iterator._pop
private function _pop() { global $DB; if (empty($this->gradestack)) { if (empty($this->grades_rs) || !$this->grades_rs->valid()) { return null; // no grades present } $current = $this->grades_rs->current(); $this->grades_rs->next(); return $current; } else { return array_pop($this->gradestack); } }
php
private function _pop() { global $DB; if (empty($this->gradestack)) { if (empty($this->grades_rs) || !$this->grades_rs->valid()) { return null; // no grades present } $current = $this->grades_rs->current(); $this->grades_rs->next(); return $current; } else { return array_pop($this->gradestack); } }
[ "private", "function", "_pop", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "this", "->", "gradestack", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "grades_rs", ")", "||", "!", "$", "this", "->", "grades_rs", "->", "valid", "(", ")", ")", "{", "return", "null", ";", "// no grades present", "}", "$", "current", "=", "$", "this", "->", "grades_rs", "->", "current", "(", ")", ";", "$", "this", "->", "grades_rs", "->", "next", "(", ")", ";", "return", "$", "current", ";", "}", "else", "{", "return", "array_pop", "(", "$", "this", "->", "gradestack", ")", ";", "}", "}" ]
Remove a grade_grade instance from the grade stack @return grade_grade current grade object
[ "Remove", "a", "grade_grade", "instance", "from", "the", "grade", "stack" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L382-L397
212,540
moodle/moodle
grade/lib.php
grade_plugin_return.get_options
public function get_options() { if (empty($this->type)) { return array(); } $params = array(); if (!empty($this->plugin)) { $params['plugin'] = $this->plugin; } if (!empty($this->courseid)) { $params['id'] = $this->courseid; } if (!empty($this->userid)) { $params['userid'] = $this->userid; } if (!empty($this->groupid)) { $params['group'] = $this->groupid; } if (!empty($this->page)) { $params['page'] = $this->page; } return $params; }
php
public function get_options() { if (empty($this->type)) { return array(); } $params = array(); if (!empty($this->plugin)) { $params['plugin'] = $this->plugin; } if (!empty($this->courseid)) { $params['id'] = $this->courseid; } if (!empty($this->userid)) { $params['userid'] = $this->userid; } if (!empty($this->groupid)) { $params['group'] = $this->groupid; } if (!empty($this->page)) { $params['page'] = $this->page; } return $params; }
[ "public", "function", "get_options", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "type", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "params", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "$", "params", "[", "'plugin'", "]", "=", "$", "this", "->", "plugin", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "courseid", ")", ")", "{", "$", "params", "[", "'id'", "]", "=", "$", "this", "->", "courseid", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "userid", ")", ")", "{", "$", "params", "[", "'userid'", "]", "=", "$", "this", "->", "userid", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "groupid", ")", ")", "{", "$", "params", "[", "'group'", "]", "=", "$", "this", "->", "groupid", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "$", "params", "[", "'page'", "]", "=", "$", "this", "->", "page", ";", "}", "return", "$", "params", ";", "}" ]
Returns return parameters as options array suitable for buttons. @return array options
[ "Returns", "return", "parameters", "as", "options", "array", "suitable", "for", "buttons", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L1198-L1226
212,541
moodle/moodle
grade/lib.php
grade_plugin_return.get_return_url
public function get_return_url($default, $extras=null) { global $CFG; if (empty($this->type) or empty($this->plugin)) { return $default; } $url = $CFG->wwwroot.'/grade/'.$this->type.'/'.$this->plugin.'/index.php'; $glue = '?'; if (!empty($this->courseid)) { $url .= $glue.'id='.$this->courseid; $glue = '&amp;'; } if (!empty($this->userid)) { $url .= $glue.'userid='.$this->userid; $glue = '&amp;'; } if (!empty($this->groupid)) { $url .= $glue.'group='.$this->groupid; $glue = '&amp;'; } if (!empty($this->page)) { $url .= $glue.'page='.$this->page; $glue = '&amp;'; } if (!empty($extras)) { foreach ($extras as $key=>$value) { $url .= $glue.$key.'='.$value; $glue = '&amp;'; } } return $url; }
php
public function get_return_url($default, $extras=null) { global $CFG; if (empty($this->type) or empty($this->plugin)) { return $default; } $url = $CFG->wwwroot.'/grade/'.$this->type.'/'.$this->plugin.'/index.php'; $glue = '?'; if (!empty($this->courseid)) { $url .= $glue.'id='.$this->courseid; $glue = '&amp;'; } if (!empty($this->userid)) { $url .= $glue.'userid='.$this->userid; $glue = '&amp;'; } if (!empty($this->groupid)) { $url .= $glue.'group='.$this->groupid; $glue = '&amp;'; } if (!empty($this->page)) { $url .= $glue.'page='.$this->page; $glue = '&amp;'; } if (!empty($extras)) { foreach ($extras as $key=>$value) { $url .= $glue.$key.'='.$value; $glue = '&amp;'; } } return $url; }
[ "public", "function", "get_return_url", "(", "$", "default", ",", "$", "extras", "=", "null", ")", "{", "global", "$", "CFG", ";", "if", "(", "empty", "(", "$", "this", "->", "type", ")", "or", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "return", "$", "default", ";", "}", "$", "url", "=", "$", "CFG", "->", "wwwroot", ".", "'/grade/'", ".", "$", "this", "->", "type", ".", "'/'", ".", "$", "this", "->", "plugin", ".", "'/index.php'", ";", "$", "glue", "=", "'?'", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "courseid", ")", ")", "{", "$", "url", ".=", "$", "glue", ".", "'id='", ".", "$", "this", "->", "courseid", ";", "$", "glue", "=", "'&amp;'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "userid", ")", ")", "{", "$", "url", ".=", "$", "glue", ".", "'userid='", ".", "$", "this", "->", "userid", ";", "$", "glue", "=", "'&amp;'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "groupid", ")", ")", "{", "$", "url", ".=", "$", "glue", ".", "'group='", ".", "$", "this", "->", "groupid", ";", "$", "glue", "=", "'&amp;'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "$", "url", ".=", "$", "glue", ".", "'page='", ".", "$", "this", "->", "page", ";", "$", "glue", "=", "'&amp;'", ";", "}", "if", "(", "!", "empty", "(", "$", "extras", ")", ")", "{", "foreach", "(", "$", "extras", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "url", ".=", "$", "glue", ".", "$", "key", ".", "'='", ".", "$", "value", ";", "$", "glue", "=", "'&amp;'", ";", "}", "}", "return", "$", "url", ";", "}" ]
Returns return url @param string $default default url when params not set @param array $extras Extra URL parameters @return string url
[ "Returns", "return", "url" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L1236-L1274
212,542
moodle/moodle
grade/lib.php
grade_plugin_return.get_form_fields
public function get_form_fields() { if (empty($this->type)) { return ''; } $result = '<input type="hidden" name="gpr_type" value="'.$this->type.'" />'; if (!empty($this->plugin)) { $result .= '<input type="hidden" name="gpr_plugin" value="'.$this->plugin.'" />'; } if (!empty($this->courseid)) { $result .= '<input type="hidden" name="gpr_courseid" value="'.$this->courseid.'" />'; } if (!empty($this->userid)) { $result .= '<input type="hidden" name="gpr_userid" value="'.$this->userid.'" />'; } if (!empty($this->groupid)) { $result .= '<input type="hidden" name="gpr_groupid" value="'.$this->groupid.'" />'; } if (!empty($this->page)) { $result .= '<input type="hidden" name="gpr_page" value="'.$this->page.'" />'; } return $result; }
php
public function get_form_fields() { if (empty($this->type)) { return ''; } $result = '<input type="hidden" name="gpr_type" value="'.$this->type.'" />'; if (!empty($this->plugin)) { $result .= '<input type="hidden" name="gpr_plugin" value="'.$this->plugin.'" />'; } if (!empty($this->courseid)) { $result .= '<input type="hidden" name="gpr_courseid" value="'.$this->courseid.'" />'; } if (!empty($this->userid)) { $result .= '<input type="hidden" name="gpr_userid" value="'.$this->userid.'" />'; } if (!empty($this->groupid)) { $result .= '<input type="hidden" name="gpr_groupid" value="'.$this->groupid.'" />'; } if (!empty($this->page)) { $result .= '<input type="hidden" name="gpr_page" value="'.$this->page.'" />'; } return $result; }
[ "public", "function", "get_form_fields", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "type", ")", ")", "{", "return", "''", ";", "}", "$", "result", "=", "'<input type=\"hidden\" name=\"gpr_type\" value=\"'", ".", "$", "this", "->", "type", ".", "'\" />'", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "$", "result", ".=", "'<input type=\"hidden\" name=\"gpr_plugin\" value=\"'", ".", "$", "this", "->", "plugin", ".", "'\" />'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "courseid", ")", ")", "{", "$", "result", ".=", "'<input type=\"hidden\" name=\"gpr_courseid\" value=\"'", ".", "$", "this", "->", "courseid", ".", "'\" />'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "userid", ")", ")", "{", "$", "result", ".=", "'<input type=\"hidden\" name=\"gpr_userid\" value=\"'", ".", "$", "this", "->", "userid", ".", "'\" />'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "groupid", ")", ")", "{", "$", "result", ".=", "'<input type=\"hidden\" name=\"gpr_groupid\" value=\"'", ".", "$", "this", "->", "groupid", ".", "'\" />'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "$", "result", ".=", "'<input type=\"hidden\" name=\"gpr_page\" value=\"'", ".", "$", "this", "->", "page", ".", "'\" />'", ";", "}", "return", "$", "result", ";", "}" ]
Returns string with hidden return tracking form elements. @return string
[ "Returns", "string", "with", "hidden", "return", "tracking", "form", "elements", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L1280-L1307
212,543
moodle/moodle
grade/lib.php
grade_plugin_return.add_mform_elements
public function add_mform_elements(&$mform) { if (empty($this->type)) { return; } $mform->addElement('hidden', 'gpr_type', $this->type); $mform->setType('gpr_type', PARAM_SAFEDIR); if (!empty($this->plugin)) { $mform->addElement('hidden', 'gpr_plugin', $this->plugin); $mform->setType('gpr_plugin', PARAM_PLUGIN); } if (!empty($this->courseid)) { $mform->addElement('hidden', 'gpr_courseid', $this->courseid); $mform->setType('gpr_courseid', PARAM_INT); } if (!empty($this->userid)) { $mform->addElement('hidden', 'gpr_userid', $this->userid); $mform->setType('gpr_userid', PARAM_INT); } if (!empty($this->groupid)) { $mform->addElement('hidden', 'gpr_groupid', $this->groupid); $mform->setType('gpr_groupid', PARAM_INT); } if (!empty($this->page)) { $mform->addElement('hidden', 'gpr_page', $this->page); $mform->setType('gpr_page', PARAM_INT); } }
php
public function add_mform_elements(&$mform) { if (empty($this->type)) { return; } $mform->addElement('hidden', 'gpr_type', $this->type); $mform->setType('gpr_type', PARAM_SAFEDIR); if (!empty($this->plugin)) { $mform->addElement('hidden', 'gpr_plugin', $this->plugin); $mform->setType('gpr_plugin', PARAM_PLUGIN); } if (!empty($this->courseid)) { $mform->addElement('hidden', 'gpr_courseid', $this->courseid); $mform->setType('gpr_courseid', PARAM_INT); } if (!empty($this->userid)) { $mform->addElement('hidden', 'gpr_userid', $this->userid); $mform->setType('gpr_userid', PARAM_INT); } if (!empty($this->groupid)) { $mform->addElement('hidden', 'gpr_groupid', $this->groupid); $mform->setType('gpr_groupid', PARAM_INT); } if (!empty($this->page)) { $mform->addElement('hidden', 'gpr_page', $this->page); $mform->setType('gpr_page', PARAM_INT); } }
[ "public", "function", "add_mform_elements", "(", "&", "$", "mform", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "type", ")", ")", "{", "return", ";", "}", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_type'", ",", "$", "this", "->", "type", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_type'", ",", "PARAM_SAFEDIR", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_plugin'", ",", "$", "this", "->", "plugin", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_plugin'", ",", "PARAM_PLUGIN", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "courseid", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_courseid'", ",", "$", "this", "->", "courseid", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_courseid'", ",", "PARAM_INT", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "userid", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_userid'", ",", "$", "this", "->", "userid", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_userid'", ",", "PARAM_INT", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "groupid", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_groupid'", ",", "$", "this", "->", "groupid", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_groupid'", ",", "PARAM_INT", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'gpr_page'", ",", "$", "this", "->", "page", ")", ";", "$", "mform", "->", "setType", "(", "'gpr_page'", ",", "PARAM_INT", ")", ";", "}", "}" ]
Add hidden elements into mform @param object &$mform moodle form object @return void
[ "Add", "hidden", "elements", "into", "mform" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L1316-L1348
212,544
moodle/moodle
grade/lib.php
grade_plugin_return.add_url_params
public function add_url_params(moodle_url $url) { if (empty($this->type)) { return $url; } $url->param('gpr_type', $this->type); if (!empty($this->plugin)) { $url->param('gpr_plugin', $this->plugin); } if (!empty($this->courseid)) { $url->param('gpr_courseid' ,$this->courseid); } if (!empty($this->userid)) { $url->param('gpr_userid', $this->userid); } if (!empty($this->groupid)) { $url->param('gpr_groupid', $this->groupid); } if (!empty($this->page)) { $url->param('gpr_page', $this->page); } return $url; }
php
public function add_url_params(moodle_url $url) { if (empty($this->type)) { return $url; } $url->param('gpr_type', $this->type); if (!empty($this->plugin)) { $url->param('gpr_plugin', $this->plugin); } if (!empty($this->courseid)) { $url->param('gpr_courseid' ,$this->courseid); } if (!empty($this->userid)) { $url->param('gpr_userid', $this->userid); } if (!empty($this->groupid)) { $url->param('gpr_groupid', $this->groupid); } if (!empty($this->page)) { $url->param('gpr_page', $this->page); } return $url; }
[ "public", "function", "add_url_params", "(", "moodle_url", "$", "url", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "type", ")", ")", "{", "return", "$", "url", ";", "}", "$", "url", "->", "param", "(", "'gpr_type'", ",", "$", "this", "->", "type", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "$", "url", "->", "param", "(", "'gpr_plugin'", ",", "$", "this", "->", "plugin", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "courseid", ")", ")", "{", "$", "url", "->", "param", "(", "'gpr_courseid'", ",", "$", "this", "->", "courseid", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "userid", ")", ")", "{", "$", "url", "->", "param", "(", "'gpr_userid'", ",", "$", "this", "->", "userid", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "groupid", ")", ")", "{", "$", "url", "->", "param", "(", "'gpr_groupid'", ",", "$", "this", "->", "groupid", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "$", "url", "->", "param", "(", "'gpr_page'", ",", "$", "this", "->", "page", ")", ";", "}", "return", "$", "url", ";", "}" ]
Add return tracking params into url @param moodle_url $url A URL @return string $url with return tracking params
[ "Add", "return", "tracking", "params", "into", "url" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/lib.php#L1357-L1385
212,545
moodle/moodle
mod/lti/service/memberships/classes/local/service/memberships.php
memberships.get_users_json
public static function get_users_json($resource, $context, $contextid, $tool, $role, $limitfrom, $limitnum, $lti, $info) { $withcapability = ''; $exclude = array(); if (!empty($role)) { if ((strpos($role, 'http://') !== 0) && (strpos($role, 'https://') !== 0)) { $role = self::CONTEXT_ROLE_PREFIX . $role; } if ($role === self::CONTEXT_ROLE_INSTRUCTOR) { $withcapability = self::INSTRUCTOR_CAPABILITY; } else if ($role === self::CONTEXT_ROLE_LEARNER) { $exclude = array_keys(get_enrolled_users($context, self::INSTRUCTOR_CAPABILITY, 0, 'u.id', null, null, null, true)); } } $users = get_enrolled_users($context, $withcapability, 0, 'u.*', null, $limitfrom, $limitnum, true); if (count($users) < $limitnum) { $limitfrom = 0; $limitnum = 0; } $json = self::users_to_json($resource, $users, $contextid, $tool, $exclude, $limitfrom, $limitnum, $lti, $info); return $json; }
php
public static function get_users_json($resource, $context, $contextid, $tool, $role, $limitfrom, $limitnum, $lti, $info) { $withcapability = ''; $exclude = array(); if (!empty($role)) { if ((strpos($role, 'http://') !== 0) && (strpos($role, 'https://') !== 0)) { $role = self::CONTEXT_ROLE_PREFIX . $role; } if ($role === self::CONTEXT_ROLE_INSTRUCTOR) { $withcapability = self::INSTRUCTOR_CAPABILITY; } else if ($role === self::CONTEXT_ROLE_LEARNER) { $exclude = array_keys(get_enrolled_users($context, self::INSTRUCTOR_CAPABILITY, 0, 'u.id', null, null, null, true)); } } $users = get_enrolled_users($context, $withcapability, 0, 'u.*', null, $limitfrom, $limitnum, true); if (count($users) < $limitnum) { $limitfrom = 0; $limitnum = 0; } $json = self::users_to_json($resource, $users, $contextid, $tool, $exclude, $limitfrom, $limitnum, $lti, $info); return $json; }
[ "public", "static", "function", "get_users_json", "(", "$", "resource", ",", "$", "context", ",", "$", "contextid", ",", "$", "tool", ",", "$", "role", ",", "$", "limitfrom", ",", "$", "limitnum", ",", "$", "lti", ",", "$", "info", ")", "{", "$", "withcapability", "=", "''", ";", "$", "exclude", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "role", ")", ")", "{", "if", "(", "(", "strpos", "(", "$", "role", ",", "'http://'", ")", "!==", "0", ")", "&&", "(", "strpos", "(", "$", "role", ",", "'https://'", ")", "!==", "0", ")", ")", "{", "$", "role", "=", "self", "::", "CONTEXT_ROLE_PREFIX", ".", "$", "role", ";", "}", "if", "(", "$", "role", "===", "self", "::", "CONTEXT_ROLE_INSTRUCTOR", ")", "{", "$", "withcapability", "=", "self", "::", "INSTRUCTOR_CAPABILITY", ";", "}", "else", "if", "(", "$", "role", "===", "self", "::", "CONTEXT_ROLE_LEARNER", ")", "{", "$", "exclude", "=", "array_keys", "(", "get_enrolled_users", "(", "$", "context", ",", "self", "::", "INSTRUCTOR_CAPABILITY", ",", "0", ",", "'u.id'", ",", "null", ",", "null", ",", "null", ",", "true", ")", ")", ";", "}", "}", "$", "users", "=", "get_enrolled_users", "(", "$", "context", ",", "$", "withcapability", ",", "0", ",", "'u.*'", ",", "null", ",", "$", "limitfrom", ",", "$", "limitnum", ",", "true", ")", ";", "if", "(", "count", "(", "$", "users", ")", "<", "$", "limitnum", ")", "{", "$", "limitfrom", "=", "0", ";", "$", "limitnum", "=", "0", ";", "}", "$", "json", "=", "self", "::", "users_to_json", "(", "$", "resource", ",", "$", "users", ",", "$", "contextid", ",", "$", "tool", ",", "$", "exclude", ",", "$", "limitfrom", ",", "$", "limitnum", ",", "$", "lti", ",", "$", "info", ")", ";", "return", "$", "json", ";", "}" ]
Get the JSON for members. @param \mod_lti\local\ltiservice\resource_base $resource Resource handling the request @param \context_course $context Course context @param string $contextid Course ID @param object $tool Tool instance object @param string $role User role requested (empty if none) @param int $limitfrom Position of first record to be returned @param int $limitnum Maximum number of records to be returned @param object $lti LTI instance record @param \core_availability\info_module $info Conditional availability information for LTI instance (null if context-level request) @return string
[ "Get", "the", "JSON", "for", "members", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/service/memberships/classes/local/service/memberships.php#L105-L128
212,546
moodle/moodle
mod/lti/service/memberships/classes/local/service/memberships.php
memberships.is_allowed_field_set
private static function is_allowed_field_set($toolconfig, $instanceconfig, $fields) { $isallowedstate = []; foreach ($fields as $key => $field) { $allowed = self::ALWAYS_INCLUDE_FIELD == $toolconfig->{$field}; if (!$allowed) { if (self::DELEGATE_TO_INSTRUCTOR == $toolconfig->{$field} && !is_null($instanceconfig)) { $allowed = $instanceconfig->{$field} == self::INSTRUCTOR_INCLUDED; } } $isallowedstate[$key] = $allowed; } return $isallowedstate; }
php
private static function is_allowed_field_set($toolconfig, $instanceconfig, $fields) { $isallowedstate = []; foreach ($fields as $key => $field) { $allowed = self::ALWAYS_INCLUDE_FIELD == $toolconfig->{$field}; if (!$allowed) { if (self::DELEGATE_TO_INSTRUCTOR == $toolconfig->{$field} && !is_null($instanceconfig)) { $allowed = $instanceconfig->{$field} == self::INSTRUCTOR_INCLUDED; } } $isallowedstate[$key] = $allowed; } return $isallowedstate; }
[ "private", "static", "function", "is_allowed_field_set", "(", "$", "toolconfig", ",", "$", "instanceconfig", ",", "$", "fields", ")", "{", "$", "isallowedstate", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "field", ")", "{", "$", "allowed", "=", "self", "::", "ALWAYS_INCLUDE_FIELD", "==", "$", "toolconfig", "->", "{", "$", "field", "}", ";", "if", "(", "!", "$", "allowed", ")", "{", "if", "(", "self", "::", "DELEGATE_TO_INSTRUCTOR", "==", "$", "toolconfig", "->", "{", "$", "field", "}", "&&", "!", "is_null", "(", "$", "instanceconfig", ")", ")", "{", "$", "allowed", "=", "$", "instanceconfig", "->", "{", "$", "field", "}", "==", "self", "::", "INSTRUCTOR_INCLUDED", ";", "}", "}", "$", "isallowedstate", "[", "$", "key", "]", "=", "$", "allowed", ";", "}", "return", "$", "isallowedstate", ";", "}" ]
Determines whether a user attribute may be used as part of LTI membership @param object $toolconfig Tool config @param object $instanceconfig Tool instance config @param array $fields Set of fields to return if allowed or not @return array Verification which associates an attribute with a boolean (allowed or not)
[ "Determines", "whether", "a", "user", "attribute", "may", "be", "used", "as", "part", "of", "LTI", "membership" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/service/memberships/classes/local/service/memberships.php#L267-L279
212,547
moodle/moodle
lib/pear/HTML/QuickForm/Renderer/Default.php
HTML_QuickForm_Renderer_Default._prepareTemplate
function _prepareTemplate($name, $label, $required, $error) { if (is_array($label)) { $nameLabel = array_shift($label); } else { $nameLabel = $label; } if (isset($this->_templates[$name])) { $html = str_replace('{label}', $nameLabel, $this->_templates[$name]); } else { $html = str_replace('{label}', $nameLabel, $this->_elementTemplate); } if ($required) { $html = str_replace('<!-- BEGIN required -->', '', $html); $html = str_replace('<!-- END required -->', '', $html); } else { $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/iU", '', $html); } if (isset($error)) { $html = str_replace('{error}', $error, $html); $html = str_replace('<!-- BEGIN error -->', '', $html); $html = str_replace('<!-- END error -->', '', $html); } else { $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->(\s|\S)*<!-- END error -->([ \t\n\r]*)?/iU", '', $html); } if (is_array($label)) { foreach($label as $key => $text) { $key = is_int($key)? $key + 2: $key; $html = str_replace("{label_{$key}}", $text, $html); $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html); $html = str_replace("<!-- END label_{$key} -->", '', $html); } } if (strpos($html, '{label_')) { $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i', '', $html); } return $html; }
php
function _prepareTemplate($name, $label, $required, $error) { if (is_array($label)) { $nameLabel = array_shift($label); } else { $nameLabel = $label; } if (isset($this->_templates[$name])) { $html = str_replace('{label}', $nameLabel, $this->_templates[$name]); } else { $html = str_replace('{label}', $nameLabel, $this->_elementTemplate); } if ($required) { $html = str_replace('<!-- BEGIN required -->', '', $html); $html = str_replace('<!-- END required -->', '', $html); } else { $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/iU", '', $html); } if (isset($error)) { $html = str_replace('{error}', $error, $html); $html = str_replace('<!-- BEGIN error -->', '', $html); $html = str_replace('<!-- END error -->', '', $html); } else { $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->(\s|\S)*<!-- END error -->([ \t\n\r]*)?/iU", '', $html); } if (is_array($label)) { foreach($label as $key => $text) { $key = is_int($key)? $key + 2: $key; $html = str_replace("{label_{$key}}", $text, $html); $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html); $html = str_replace("<!-- END label_{$key} -->", '', $html); } } if (strpos($html, '{label_')) { $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i', '', $html); } return $html; }
[ "function", "_prepareTemplate", "(", "$", "name", ",", "$", "label", ",", "$", "required", ",", "$", "error", ")", "{", "if", "(", "is_array", "(", "$", "label", ")", ")", "{", "$", "nameLabel", "=", "array_shift", "(", "$", "label", ")", ";", "}", "else", "{", "$", "nameLabel", "=", "$", "label", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_templates", "[", "$", "name", "]", ")", ")", "{", "$", "html", "=", "str_replace", "(", "'{label}'", ",", "$", "nameLabel", ",", "$", "this", "->", "_templates", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "html", "=", "str_replace", "(", "'{label}'", ",", "$", "nameLabel", ",", "$", "this", "->", "_elementTemplate", ")", ";", "}", "if", "(", "$", "required", ")", "{", "$", "html", "=", "str_replace", "(", "'<!-- BEGIN required -->'", ",", "''", ",", "$", "html", ")", ";", "$", "html", "=", "str_replace", "(", "'<!-- END required -->'", ",", "''", ",", "$", "html", ")", ";", "}", "else", "{", "$", "html", "=", "preg_replace", "(", "\"/([ \\t\\n\\r]*)?<!-- BEGIN required -->(\\s|\\S)*<!-- END required -->([ \\t\\n\\r]*)?/iU\"", ",", "''", ",", "$", "html", ")", ";", "}", "if", "(", "isset", "(", "$", "error", ")", ")", "{", "$", "html", "=", "str_replace", "(", "'{error}'", ",", "$", "error", ",", "$", "html", ")", ";", "$", "html", "=", "str_replace", "(", "'<!-- BEGIN error -->'", ",", "''", ",", "$", "html", ")", ";", "$", "html", "=", "str_replace", "(", "'<!-- END error -->'", ",", "''", ",", "$", "html", ")", ";", "}", "else", "{", "$", "html", "=", "preg_replace", "(", "\"/([ \\t\\n\\r]*)?<!-- BEGIN error -->(\\s|\\S)*<!-- END error -->([ \\t\\n\\r]*)?/iU\"", ",", "''", ",", "$", "html", ")", ";", "}", "if", "(", "is_array", "(", "$", "label", ")", ")", "{", "foreach", "(", "$", "label", "as", "$", "key", "=>", "$", "text", ")", "{", "$", "key", "=", "is_int", "(", "$", "key", ")", "?", "$", "key", "+", "2", ":", "$", "key", ";", "$", "html", "=", "str_replace", "(", "\"{label_{$key}}\"", ",", "$", "text", ",", "$", "html", ")", ";", "$", "html", "=", "str_replace", "(", "\"<!-- BEGIN label_{$key} -->\"", ",", "''", ",", "$", "html", ")", ";", "$", "html", "=", "str_replace", "(", "\"<!-- END label_{$key} -->\"", ",", "''", ",", "$", "html", ")", ";", "}", "}", "if", "(", "strpos", "(", "$", "html", ",", "'{label_'", ")", ")", "{", "$", "html", "=", "preg_replace", "(", "'/\\s*<!-- BEGIN label_(\\S+) -->.*<!-- END label_\\1 -->\\s*/i'", ",", "''", ",", "$", "html", ")", ";", "}", "return", "$", "html", ";", "}" ]
Helper method for renderElement @param string Element name @param mixed Element label (if using an array of labels, you should set the appropriate template) @param bool Whether an element is required @param string Error message associated with the element @access private @see renderElement() @return string Html for element
[ "Helper", "method", "for", "renderElement" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Default.php#L241-L278
212,548
moodle/moodle
lib/pear/HTML/QuickForm/Renderer/Default.php
HTML_QuickForm_Renderer_Default.startGroup
function startGroup(&$group, $required, $error) { $name = $group->getName(); $this->_groupTemplate = $this->_prepareTemplate($name, $group->getLabel(), $required, $error); $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name]; $this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name]; $this->_groupElements = array(); $this->_inGroup = true; }
php
function startGroup(&$group, $required, $error) { $name = $group->getName(); $this->_groupTemplate = $this->_prepareTemplate($name, $group->getLabel(), $required, $error); $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name]; $this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name]; $this->_groupElements = array(); $this->_inGroup = true; }
[ "function", "startGroup", "(", "&", "$", "group", ",", "$", "required", ",", "$", "error", ")", "{", "$", "name", "=", "$", "group", "->", "getName", "(", ")", ";", "$", "this", "->", "_groupTemplate", "=", "$", "this", "->", "_prepareTemplate", "(", "$", "name", ",", "$", "group", "->", "getLabel", "(", ")", ",", "$", "required", ",", "$", "error", ")", ";", "$", "this", "->", "_groupElementTemplate", "=", "empty", "(", "$", "this", "->", "_groupTemplates", "[", "$", "name", "]", ")", "?", "''", ":", "$", "this", "->", "_groupTemplates", "[", "$", "name", "]", ";", "$", "this", "->", "_groupWrap", "=", "empty", "(", "$", "this", "->", "_groupWraps", "[", "$", "name", "]", ")", "?", "''", ":", "$", "this", "->", "_groupWraps", "[", "$", "name", "]", ";", "$", "this", "->", "_groupElements", "=", "array", "(", ")", ";", "$", "this", "->", "_inGroup", "=", "true", ";", "}" ]
Called when visiting a group, before processing any group elements @param object An HTML_QuickForm_group object being visited @param bool Whether a group is required @param string An error message associated with a group @access public @return void
[ "Called", "when", "visiting", "a", "group", "before", "processing", "any", "group", "elements" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Default.php#L345-L353
212,549
moodle/moodle
lib/pear/HTML/QuickForm/Renderer/Default.php
HTML_QuickForm_Renderer_Default.finishGroup
function finishGroup(&$group) { $separator = $group->_separator; if (is_array($separator)) { $count = count($separator); $html = ''; for ($i = 0; $i < count($this->_groupElements); $i++) { $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i]; } } else { if (is_null($separator)) { $separator = '&nbsp;'; } $html = implode((string)$separator, $this->_groupElements); } if (!empty($this->_groupWrap)) { $html = str_replace('{content}', $html, $this->_groupWrap); } $this->_html .= str_replace('{element}', $html, $this->_groupTemplate); $this->_inGroup = false; }
php
function finishGroup(&$group) { $separator = $group->_separator; if (is_array($separator)) { $count = count($separator); $html = ''; for ($i = 0; $i < count($this->_groupElements); $i++) { $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i]; } } else { if (is_null($separator)) { $separator = '&nbsp;'; } $html = implode((string)$separator, $this->_groupElements); } if (!empty($this->_groupWrap)) { $html = str_replace('{content}', $html, $this->_groupWrap); } $this->_html .= str_replace('{element}', $html, $this->_groupTemplate); $this->_inGroup = false; }
[ "function", "finishGroup", "(", "&", "$", "group", ")", "{", "$", "separator", "=", "$", "group", "->", "_separator", ";", "if", "(", "is_array", "(", "$", "separator", ")", ")", "{", "$", "count", "=", "count", "(", "$", "separator", ")", ";", "$", "html", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "_groupElements", ")", ";", "$", "i", "++", ")", "{", "$", "html", ".=", "(", "0", "==", "$", "i", "?", "''", ":", "$", "separator", "[", "(", "$", "i", "-", "1", ")", "%", "$", "count", "]", ")", ".", "$", "this", "->", "_groupElements", "[", "$", "i", "]", ";", "}", "}", "else", "{", "if", "(", "is_null", "(", "$", "separator", ")", ")", "{", "$", "separator", "=", "'&nbsp;'", ";", "}", "$", "html", "=", "implode", "(", "(", "string", ")", "$", "separator", ",", "$", "this", "->", "_groupElements", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_groupWrap", ")", ")", "{", "$", "html", "=", "str_replace", "(", "'{content}'", ",", "$", "html", ",", "$", "this", "->", "_groupWrap", ")", ";", "}", "$", "this", "->", "_html", ".=", "str_replace", "(", "'{element}'", ",", "$", "html", ",", "$", "this", "->", "_groupTemplate", ")", ";", "$", "this", "->", "_inGroup", "=", "false", ";", "}" ]
Called when visiting a group, after processing all group elements @param object An HTML_QuickForm_group object being visited @access public @return void
[ "Called", "when", "visiting", "a", "group", "after", "processing", "all", "group", "elements" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Default.php#L362-L382
212,550
moodle/moodle
lib/pear/HTML/QuickForm/Renderer/Default.php
HTML_QuickForm_Renderer_Default.setElementTemplate
function setElementTemplate($html, $element = null) { if (is_null($element)) { $this->_elementTemplate = $html; } else { $this->_templates[$element] = $html; } }
php
function setElementTemplate($html, $element = null) { if (is_null($element)) { $this->_elementTemplate = $html; } else { $this->_templates[$element] = $html; } }
[ "function", "setElementTemplate", "(", "$", "html", ",", "$", "element", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "element", ")", ")", "{", "$", "this", "->", "_elementTemplate", "=", "$", "html", ";", "}", "else", "{", "$", "this", "->", "_templates", "[", "$", "element", "]", "=", "$", "html", ";", "}", "}" ]
Sets element template @param string The HTML surrounding an element @param string (optional) Name of the element to apply template for @access public @return void
[ "Sets", "element", "template" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/pear/HTML/QuickForm/Renderer/Default.php#L392-L399
212,551
moodle/moodle
lib/minify/matthiasmullie-pathconverter/src/Converter.php
Converter.shared
protected function shared($path1, $path2) { // $path could theoretically be empty (e.g. no path is given), in which // case it shouldn't expand to array(''), which would compare to one's // root / $path1 = $path1 ? explode('/', $path1) : array(); $path2 = $path2 ? explode('/', $path2) : array(); $shared = array(); // compare paths & strip identical ancestors foreach ($path1 as $i => $chunk) { if (isset($path2[$i]) && $path1[$i] == $path2[$i]) { $shared[] = $chunk; } else { break; } } return implode('/', $shared); }
php
protected function shared($path1, $path2) { // $path could theoretically be empty (e.g. no path is given), in which // case it shouldn't expand to array(''), which would compare to one's // root / $path1 = $path1 ? explode('/', $path1) : array(); $path2 = $path2 ? explode('/', $path2) : array(); $shared = array(); // compare paths & strip identical ancestors foreach ($path1 as $i => $chunk) { if (isset($path2[$i]) && $path1[$i] == $path2[$i]) { $shared[] = $chunk; } else { break; } } return implode('/', $shared); }
[ "protected", "function", "shared", "(", "$", "path1", ",", "$", "path2", ")", "{", "// $path could theoretically be empty (e.g. no path is given), in which", "// case it shouldn't expand to array(''), which would compare to one's", "// root /", "$", "path1", "=", "$", "path1", "?", "explode", "(", "'/'", ",", "$", "path1", ")", ":", "array", "(", ")", ";", "$", "path2", "=", "$", "path2", "?", "explode", "(", "'/'", ",", "$", "path2", ")", ":", "array", "(", ")", ";", "$", "shared", "=", "array", "(", ")", ";", "// compare paths & strip identical ancestors", "foreach", "(", "$", "path1", "as", "$", "i", "=>", "$", "chunk", ")", "{", "if", "(", "isset", "(", "$", "path2", "[", "$", "i", "]", ")", "&&", "$", "path1", "[", "$", "i", "]", "==", "$", "path2", "[", "$", "i", "]", ")", "{", "$", "shared", "[", "]", "=", "$", "chunk", ";", "}", "else", "{", "break", ";", "}", "}", "return", "implode", "(", "'/'", ",", "$", "shared", ")", ";", "}" ]
Figure out the shared path of 2 locations. Example: /home/forkcms/frontend/core/layout/images/img.gif and /home/forkcms/frontend/cache/minified_css share /home/forkcms/frontend @param string $path1 @param string $path2 @return string
[ "Figure", "out", "the", "shared", "path", "of", "2", "locations", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-pathconverter/src/Converter.php#L101-L121
212,552
moodle/moodle
lib/minify/matthiasmullie-pathconverter/src/Converter.php
Converter.dirname
protected function dirname($path) { if (is_file($path)) { return dirname($path); } if (is_dir($path)) { return rtrim($path, '/'); } // no known file/dir, start making assumptions // ends in / = dir if (mb_substr($path, -1) === '/') { return rtrim($path, '/'); } // has a dot in the name, likely a file if (preg_match('/.*\..*$/', basename($path)) !== 0) { return dirname($path); } // you're on your own here! return $path; }
php
protected function dirname($path) { if (is_file($path)) { return dirname($path); } if (is_dir($path)) { return rtrim($path, '/'); } // no known file/dir, start making assumptions // ends in / = dir if (mb_substr($path, -1) === '/') { return rtrim($path, '/'); } // has a dot in the name, likely a file if (preg_match('/.*\..*$/', basename($path)) !== 0) { return dirname($path); } // you're on your own here! return $path; }
[ "protected", "function", "dirname", "(", "$", "path", ")", "{", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "return", "dirname", "(", "$", "path", ")", ";", "}", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "return", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "// no known file/dir, start making assumptions", "// ends in / = dir", "if", "(", "mb_substr", "(", "$", "path", ",", "-", "1", ")", "===", "'/'", ")", "{", "return", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "// has a dot in the name, likely a file", "if", "(", "preg_match", "(", "'/.*\\..*$/'", ",", "basename", "(", "$", "path", ")", ")", "!==", "0", ")", "{", "return", "dirname", "(", "$", "path", ")", ";", "}", "// you're on your own here!", "return", "$", "path", ";", "}" ]
Attempt to get the directory name from a path. @param string $path @return string
[ "Attempt", "to", "get", "the", "directory", "name", "from", "a", "path", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/minify/matthiasmullie-pathconverter/src/Converter.php#L170-L194
212,553
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php
Horde_Imap_Client_Data_SearchCharset.query
public function query($charset, $cached = false) { $charset = Horde_String::upper($charset); if (isset($this->_charsets[$charset])) { return $this->_charsets[$charset]; } elseif ($cached) { return null; } if (!$this->_baseob) { throw new RuntimeException( 'Base object needs to be defined to query for charset.' ); } /* Use a dummy search query and search for BADCHARSET response. */ $query = new Horde_Imap_Client_Search_Query(); $query->charset($charset, false); $query->ids($this->_baseob->getIdsOb(1, true)); $query->text('a'); try { $this->_baseob->search('INBOX', $query, array( 'nocache' => true, 'sequence' => true )); $this->_charsets[$charset] = true; } catch (Horde_Imap_Client_Exception $e) { $this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET); } $this->notify(); return $this->_charsets[$charset]; }
php
public function query($charset, $cached = false) { $charset = Horde_String::upper($charset); if (isset($this->_charsets[$charset])) { return $this->_charsets[$charset]; } elseif ($cached) { return null; } if (!$this->_baseob) { throw new RuntimeException( 'Base object needs to be defined to query for charset.' ); } /* Use a dummy search query and search for BADCHARSET response. */ $query = new Horde_Imap_Client_Search_Query(); $query->charset($charset, false); $query->ids($this->_baseob->getIdsOb(1, true)); $query->text('a'); try { $this->_baseob->search('INBOX', $query, array( 'nocache' => true, 'sequence' => true )); $this->_charsets[$charset] = true; } catch (Horde_Imap_Client_Exception $e) { $this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET); } $this->notify(); return $this->_charsets[$charset]; }
[ "public", "function", "query", "(", "$", "charset", ",", "$", "cached", "=", "false", ")", "{", "$", "charset", "=", "Horde_String", "::", "upper", "(", "$", "charset", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_charsets", "[", "$", "charset", "]", ")", ")", "{", "return", "$", "this", "->", "_charsets", "[", "$", "charset", "]", ";", "}", "elseif", "(", "$", "cached", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "this", "->", "_baseob", ")", "{", "throw", "new", "RuntimeException", "(", "'Base object needs to be defined to query for charset.'", ")", ";", "}", "/* Use a dummy search query and search for BADCHARSET response. */", "$", "query", "=", "new", "Horde_Imap_Client_Search_Query", "(", ")", ";", "$", "query", "->", "charset", "(", "$", "charset", ",", "false", ")", ";", "$", "query", "->", "ids", "(", "$", "this", "->", "_baseob", "->", "getIdsOb", "(", "1", ",", "true", ")", ")", ";", "$", "query", "->", "text", "(", "'a'", ")", ";", "try", "{", "$", "this", "->", "_baseob", "->", "search", "(", "'INBOX'", ",", "$", "query", ",", "array", "(", "'nocache'", "=>", "true", ",", "'sequence'", "=>", "true", ")", ")", ";", "$", "this", "->", "_charsets", "[", "$", "charset", "]", "=", "true", ";", "}", "catch", "(", "Horde_Imap_Client_Exception", "$", "e", ")", "{", "$", "this", "->", "_charsets", "[", "$", "charset", "]", "=", "(", "$", "e", "->", "getCode", "(", ")", "!==", "Horde_Imap_Client_Exception", "::", "BADCHARSET", ")", ";", "}", "$", "this", "->", "notify", "(", ")", ";", "return", "$", "this", "->", "_charsets", "[", "$", "charset", "]", ";", "}" ]
Query the validity of a charset. @param string $charset The charset to query. @param boolean $cached If true, only query cached values. @return boolean True if the charset is valid for searching.
[ "Query", "the", "validity", "of", "a", "charset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php#L78-L112
212,554
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php
Horde_Imap_Client_Data_SearchCharset.setValid
public function setValid($charset, $valid = true) { $charset = Horde_String::upper($charset); $valid = (bool)$valid; if (!isset($this->_charsets[$charset]) || ($this->_charsets[$charset] !== $valid)) { $this->_charsets[$charset] = $valid; $this->notify(); } }
php
public function setValid($charset, $valid = true) { $charset = Horde_String::upper($charset); $valid = (bool)$valid; if (!isset($this->_charsets[$charset]) || ($this->_charsets[$charset] !== $valid)) { $this->_charsets[$charset] = $valid; $this->notify(); } }
[ "public", "function", "setValid", "(", "$", "charset", ",", "$", "valid", "=", "true", ")", "{", "$", "charset", "=", "Horde_String", "::", "upper", "(", "$", "charset", ")", ";", "$", "valid", "=", "(", "bool", ")", "$", "valid", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_charsets", "[", "$", "charset", "]", ")", "||", "(", "$", "this", "->", "_charsets", "[", "$", "charset", "]", "!==", "$", "valid", ")", ")", "{", "$", "this", "->", "_charsets", "[", "$", "charset", "]", "=", "$", "valid", ";", "$", "this", "->", "notify", "(", ")", ";", "}", "}" ]
Set the validity of a given charset. @param string $charset The charset. @param boolean $valid Is charset valid?
[ "Set", "the", "validity", "of", "a", "given", "charset", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php#L120-L130
212,555
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.new_redis
protected function new_redis($server, $prefix = '', $password = '') { $redis = new Redis(); $port = null; if (strpos($server, ':')) { $serverconf = explode(':', $server); $server = $serverconf[0]; $port = $serverconf[1]; } if ($redis->connect($server, $port)) { if (!empty($password)) { $redis->auth($password); } $redis->setOption(Redis::OPT_SERIALIZER, $this->serializer); if (!empty($prefix)) { $redis->setOption(Redis::OPT_PREFIX, $prefix); } // Database setting option... $this->isready = $this->ping($redis); } else { $this->isready = false; } return $redis; }
php
protected function new_redis($server, $prefix = '', $password = '') { $redis = new Redis(); $port = null; if (strpos($server, ':')) { $serverconf = explode(':', $server); $server = $serverconf[0]; $port = $serverconf[1]; } if ($redis->connect($server, $port)) { if (!empty($password)) { $redis->auth($password); } $redis->setOption(Redis::OPT_SERIALIZER, $this->serializer); if (!empty($prefix)) { $redis->setOption(Redis::OPT_PREFIX, $prefix); } // Database setting option... $this->isready = $this->ping($redis); } else { $this->isready = false; } return $redis; }
[ "protected", "function", "new_redis", "(", "$", "server", ",", "$", "prefix", "=", "''", ",", "$", "password", "=", "''", ")", "{", "$", "redis", "=", "new", "Redis", "(", ")", ";", "$", "port", "=", "null", ";", "if", "(", "strpos", "(", "$", "server", ",", "':'", ")", ")", "{", "$", "serverconf", "=", "explode", "(", "':'", ",", "$", "server", ")", ";", "$", "server", "=", "$", "serverconf", "[", "0", "]", ";", "$", "port", "=", "$", "serverconf", "[", "1", "]", ";", "}", "if", "(", "$", "redis", "->", "connect", "(", "$", "server", ",", "$", "port", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "password", ")", ")", "{", "$", "redis", "->", "auth", "(", "$", "password", ")", ";", "}", "$", "redis", "->", "setOption", "(", "Redis", "::", "OPT_SERIALIZER", ",", "$", "this", "->", "serializer", ")", ";", "if", "(", "!", "empty", "(", "$", "prefix", ")", ")", "{", "$", "redis", "->", "setOption", "(", "Redis", "::", "OPT_PREFIX", ",", "$", "prefix", ")", ";", "}", "// Database setting option...", "$", "this", "->", "isready", "=", "$", "this", "->", "ping", "(", "$", "redis", ")", ";", "}", "else", "{", "$", "this", "->", "isready", "=", "false", ";", "}", "return", "$", "redis", ";", "}" ]
Create a new Redis instance and connect to the server. @param string $server The server connection string @param string $prefix The key prefix @param string $password The server connection password @return Redis
[ "Create", "a", "new", "Redis", "instance", "and", "connect", "to", "the", "server", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L151-L173
212,556
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.ping
protected function ping(Redis $redis) { try { if ($redis->ping() === false) { return false; } } catch (Exception $e) { return false; } return true; }
php
protected function ping(Redis $redis) { try { if ($redis->ping() === false) { return false; } } catch (Exception $e) { return false; } return true; }
[ "protected", "function", "ping", "(", "Redis", "$", "redis", ")", "{", "try", "{", "if", "(", "$", "redis", "->", "ping", "(", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
See if we can ping Redis server @param Redis $redis @return bool
[ "See", "if", "we", "can", "ping", "Redis", "server" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L181-L190
212,557
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.initialise
public function initialise(cache_definition $definition) { $this->definition = $definition; $this->hash = $definition->generate_definition_hash(); return true; }
php
public function initialise(cache_definition $definition) { $this->definition = $definition; $this->hash = $definition->generate_definition_hash(); return true; }
[ "public", "function", "initialise", "(", "cache_definition", "$", "definition", ")", "{", "$", "this", "->", "definition", "=", "$", "definition", ";", "$", "this", "->", "hash", "=", "$", "definition", "->", "generate_definition_hash", "(", ")", ";", "return", "true", ";", "}" ]
Initialize the store. @param cache_definition $definition @return bool
[ "Initialize", "the", "store", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L207-L211
212,558
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.set
public function set($key, $value) { return ($this->redis->hSet($this->hash, $key, $value) !== false); }
php
public function set($key, $value) { return ($this->redis->hSet($this->hash, $key, $value) !== false); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "return", "(", "$", "this", "->", "redis", "->", "hSet", "(", "$", "this", "->", "hash", ",", "$", "key", ",", "$", "value", ")", "!==", "false", ")", ";", "}" ]
Set the value of a key. @param string $key The key to set the value of. @param mixed $value The value. @return bool True if the operation succeeded, false otherwise.
[ "Set", "the", "value", "of", "a", "key", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L258-L260
212,559
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.set_many
public function set_many(array $keyvaluearray) { $pairs = []; foreach ($keyvaluearray as $pair) { $pairs[$pair['key']] = $pair['value']; } if ($this->redis->hMSet($this->hash, $pairs)) { return count($pairs); } return 0; }
php
public function set_many(array $keyvaluearray) { $pairs = []; foreach ($keyvaluearray as $pair) { $pairs[$pair['key']] = $pair['value']; } if ($this->redis->hMSet($this->hash, $pairs)) { return count($pairs); } return 0; }
[ "public", "function", "set_many", "(", "array", "$", "keyvaluearray", ")", "{", "$", "pairs", "=", "[", "]", ";", "foreach", "(", "$", "keyvaluearray", "as", "$", "pair", ")", "{", "$", "pairs", "[", "$", "pair", "[", "'key'", "]", "]", "=", "$", "pair", "[", "'value'", "]", ";", "}", "if", "(", "$", "this", "->", "redis", "->", "hMSet", "(", "$", "this", "->", "hash", ",", "$", "pairs", ")", ")", "{", "return", "count", "(", "$", "pairs", ")", ";", "}", "return", "0", ";", "}" ]
Set the values of many keys. @param array $keyvaluearray An array of key/value pairs. Each item in the array is an associative array with two keys, 'key' and 'value'. @return int The number of key/value pairs successfuly set.
[ "Set", "the", "values", "of", "many", "keys", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L269-L278
212,560
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.delete_many
public function delete_many(array $keys) { // Redis needs the hash as the first argument, so we have to put it at the start of the array. array_unshift($keys, $this->hash); return call_user_func_array(array($this->redis, 'hDel'), $keys); }
php
public function delete_many(array $keys) { // Redis needs the hash as the first argument, so we have to put it at the start of the array. array_unshift($keys, $this->hash); return call_user_func_array(array($this->redis, 'hDel'), $keys); }
[ "public", "function", "delete_many", "(", "array", "$", "keys", ")", "{", "// Redis needs the hash as the first argument, so we have to put it at the start of the array.", "array_unshift", "(", "$", "keys", ",", "$", "this", "->", "hash", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "this", "->", "redis", ",", "'hDel'", ")", ",", "$", "keys", ")", ";", "}" ]
Delete many keys. @param array $keys The keys to delete. @return int The number of keys successfully deleted.
[ "Delete", "many", "keys", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L296-L300
212,561
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.has_any
public function has_any(array $keys) { foreach ($keys as $key) { if ($this->has($key)) { return true; } } return false; }
php
public function has_any(array $keys) { foreach ($keys as $key) { if ($this->has($key)) { return true; } } return false; }
[ "public", "function", "has_any", "(", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines if the store has any of the keys in a list. @see cache_is_key_aware @param array $keys The keys to check for. @return bool True if any of the keys are found, false none of the keys are found.
[ "Determines", "if", "the", "store", "has", "any", "of", "the", "keys", "in", "a", "list", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L338-L345
212,562
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.has_all
public function has_all(array $keys) { foreach ($keys as $key) { if (!$this->has($key)) { return false; } } return true; }
php
public function has_all(array $keys) { foreach ($keys as $key) { if (!$this->has($key)) { return false; } } return true; }
[ "public", "function", "has_all", "(", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determines if the store has all of the keys in a list. @see cache_is_key_aware @param array $keys The keys to check for. @return bool True if all of the keys are found, false otherwise.
[ "Determines", "if", "the", "store", "has", "all", "of", "the", "keys", "in", "a", "list", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L354-L361
212,563
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.check_lock_state
public function check_lock_state($key, $ownerid) { $result = $this->redis->get($key); if ($result === $ownerid) { return true; } if ($result === false) { return null; } return false; }
php
public function check_lock_state($key, $ownerid) { $result = $this->redis->get($key); if ($result === $ownerid) { return true; } if ($result === false) { return null; } return false; }
[ "public", "function", "check_lock_state", "(", "$", "key", ",", "$", "ownerid", ")", "{", "$", "result", "=", "$", "this", "->", "redis", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "result", "===", "$", "ownerid", ")", "{", "return", "true", ";", "}", "if", "(", "$", "result", "===", "false", ")", "{", "return", "null", ";", "}", "return", "false", ";", "}" ]
Checks a lock with a given name and owner information. @see cache_is_lockable @param string $key Name of the lock to check. @param string $ownerid Owner information to check existing lock against. @return mixed True if the lock exists and the owner information matches, null if the lock does not exist, and false otherwise.
[ "Checks", "a", "lock", "with", "a", "given", "name", "and", "owner", "information", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L384-L393
212,564
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.release_lock
public function release_lock($key, $ownerid) { if ($this->check_lock_state($key, $ownerid)) { return ($this->redis->del($key) !== false); } return false; }
php
public function release_lock($key, $ownerid) { if ($this->check_lock_state($key, $ownerid)) { return ($this->redis->del($key) !== false); } return false; }
[ "public", "function", "release_lock", "(", "$", "key", ",", "$", "ownerid", ")", "{", "if", "(", "$", "this", "->", "check_lock_state", "(", "$", "key", ",", "$", "ownerid", ")", ")", "{", "return", "(", "$", "this", "->", "redis", "->", "del", "(", "$", "key", ")", "!==", "false", ")", ";", "}", "return", "false", ";", "}" ]
Releases a given lock if the owner information matches. @see cache_is_lockable @param string $key Name of the lock to release. @param string $ownerid Owner information to use. @return bool True if the lock is released, false if it is not.
[ "Releases", "a", "given", "lock", "if", "the", "owner", "information", "matches", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L429-L434
212,565
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.config_get_configuration_array
public static function config_get_configuration_array($data) { return array( 'server' => $data->server, 'prefix' => $data->prefix, 'password' => $data->password, 'serializer' => $data->serializer ); }
php
public static function config_get_configuration_array($data) { return array( 'server' => $data->server, 'prefix' => $data->prefix, 'password' => $data->password, 'serializer' => $data->serializer ); }
[ "public", "static", "function", "config_get_configuration_array", "(", "$", "data", ")", "{", "return", "array", "(", "'server'", "=>", "$", "data", "->", "server", ",", "'prefix'", "=>", "$", "data", "->", "prefix", ",", "'password'", "=>", "$", "data", "->", "password", ",", "'serializer'", "=>", "$", "data", "->", "serializer", ")", ";", "}" ]
Creates a configuration array from given 'add instance' form data. @see cache_is_configurable @param stdClass $data @return array
[ "Creates", "a", "configuration", "array", "from", "given", "add", "instance", "form", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L443-L450
212,566
moodle/moodle
cache/stores/redis/lib.php
cachestore_redis.config_set_edit_form_data
public static function config_set_edit_form_data(moodleform $editform, array $config) { $data = array(); $data['server'] = $config['server']; $data['prefix'] = !empty($config['prefix']) ? $config['prefix'] : ''; $data['password'] = !empty($config['password']) ? $config['password'] : ''; if (!empty($config['serializer'])) { $data['serializer'] = $config['serializer']; } $editform->set_data($data); }
php
public static function config_set_edit_form_data(moodleform $editform, array $config) { $data = array(); $data['server'] = $config['server']; $data['prefix'] = !empty($config['prefix']) ? $config['prefix'] : ''; $data['password'] = !empty($config['password']) ? $config['password'] : ''; if (!empty($config['serializer'])) { $data['serializer'] = $config['serializer']; } $editform->set_data($data); }
[ "public", "static", "function", "config_set_edit_form_data", "(", "moodleform", "$", "editform", ",", "array", "$", "config", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'server'", "]", "=", "$", "config", "[", "'server'", "]", ";", "$", "data", "[", "'prefix'", "]", "=", "!", "empty", "(", "$", "config", "[", "'prefix'", "]", ")", "?", "$", "config", "[", "'prefix'", "]", ":", "''", ";", "$", "data", "[", "'password'", "]", "=", "!", "empty", "(", "$", "config", "[", "'password'", "]", ")", "?", "$", "config", "[", "'password'", "]", ":", "''", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'serializer'", "]", ")", ")", "{", "$", "data", "[", "'serializer'", "]", "=", "$", "config", "[", "'serializer'", "]", ";", "}", "$", "editform", "->", "set_data", "(", "$", "data", ")", ";", "}" ]
Sets form data from a configuration array. @see cache_is_configurable @param moodleform $editform @param array $config
[ "Sets", "form", "data", "from", "a", "configuration", "array", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/redis/lib.php#L459-L468
212,567
moodle/moodle
lib/php-css-parser/RuleSet/RuleSet.php
RuleSet.getRules
public function getRules($mRule = null) { if ($mRule instanceof Rule) { $mRule = $mRule->getRule(); } $aResult = array(); foreach($this->aRules as $sName => $aRules) { // Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule. if(!$mRule || $sName === $mRule || (strrpos($mRule, '-') === strlen($mRule) - strlen('-') && (strpos($sName, $mRule) === 0 || $sName === substr($mRule, 0, -1)))) { $aResult = array_merge($aResult, $aRules); } } return $aResult; }
php
public function getRules($mRule = null) { if ($mRule instanceof Rule) { $mRule = $mRule->getRule(); } $aResult = array(); foreach($this->aRules as $sName => $aRules) { // Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule. if(!$mRule || $sName === $mRule || (strrpos($mRule, '-') === strlen($mRule) - strlen('-') && (strpos($sName, $mRule) === 0 || $sName === substr($mRule, 0, -1)))) { $aResult = array_merge($aResult, $aRules); } } return $aResult; }
[ "public", "function", "getRules", "(", "$", "mRule", "=", "null", ")", "{", "if", "(", "$", "mRule", "instanceof", "Rule", ")", "{", "$", "mRule", "=", "$", "mRule", "->", "getRule", "(", ")", ";", "}", "$", "aResult", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "aRules", "as", "$", "sName", "=>", "$", "aRules", ")", "{", "// Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule.", "if", "(", "!", "$", "mRule", "||", "$", "sName", "===", "$", "mRule", "||", "(", "strrpos", "(", "$", "mRule", ",", "'-'", ")", "===", "strlen", "(", "$", "mRule", ")", "-", "strlen", "(", "'-'", ")", "&&", "(", "strpos", "(", "$", "sName", ",", "$", "mRule", ")", "===", "0", "||", "$", "sName", "===", "substr", "(", "$", "mRule", ",", "0", ",", "-", "1", ")", ")", ")", ")", "{", "$", "aResult", "=", "array_merge", "(", "$", "aResult", ",", "$", "aRules", ")", ";", "}", "}", "return", "$", "aResult", ";", "}" ]
Returns all rules matching the given rule name @param (null|string|Rule) $mRule pattern to search for. If null, returns all rules. if the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. passing a Rule behaves like calling getRules($mRule->getRule()). @example $oRuleSet->getRules('font-') //returns an array of all rules either beginning with font- or matching font. @example $oRuleSet->getRules('font') //returns array(0 => $oRule, …) or array().
[ "Returns", "all", "rules", "matching", "the", "given", "rule", "name" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/php-css-parser/RuleSet/RuleSet.php#L56-L68
212,568
moodle/moodle
lib/php-css-parser/RuleSet/RuleSet.php
RuleSet.setRules
public function setRules(array $aRules) { $this->aRules = array(); foreach ($aRules as $rule) { $this->addRule($rule); } }
php
public function setRules(array $aRules) { $this->aRules = array(); foreach ($aRules as $rule) { $this->addRule($rule); } }
[ "public", "function", "setRules", "(", "array", "$", "aRules", ")", "{", "$", "this", "->", "aRules", "=", "array", "(", ")", ";", "foreach", "(", "$", "aRules", "as", "$", "rule", ")", "{", "$", "this", "->", "addRule", "(", "$", "rule", ")", ";", "}", "}" ]
Override all the rules of this set. @param array $aRules The rules to override with.
[ "Override", "all", "the", "rules", "of", "this", "set", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/php-css-parser/RuleSet/RuleSet.php#L74-L79
212,569
moodle/moodle
lib/php-css-parser/RuleSet/RuleSet.php
RuleSet.removeRule
public function removeRule($mRule) { if($mRule instanceof Rule) { $sRule = $mRule->getRule(); if(!isset($this->aRules[$sRule])) { return; } foreach($this->aRules[$sRule] as $iKey => $oRule) { if($oRule === $mRule) { unset($this->aRules[$sRule][$iKey]); } } } else { foreach($this->aRules as $sName => $aRules) { // Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule or equals it (without the trailing dash). if(!$mRule || $sName === $mRule || (strrpos($mRule, '-') === strlen($mRule) - strlen('-') && (strpos($sName, $mRule) === 0 || $sName === substr($mRule, 0, -1)))) { unset($this->aRules[$sName]); } } } }
php
public function removeRule($mRule) { if($mRule instanceof Rule) { $sRule = $mRule->getRule(); if(!isset($this->aRules[$sRule])) { return; } foreach($this->aRules[$sRule] as $iKey => $oRule) { if($oRule === $mRule) { unset($this->aRules[$sRule][$iKey]); } } } else { foreach($this->aRules as $sName => $aRules) { // Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule or equals it (without the trailing dash). if(!$mRule || $sName === $mRule || (strrpos($mRule, '-') === strlen($mRule) - strlen('-') && (strpos($sName, $mRule) === 0 || $sName === substr($mRule, 0, -1)))) { unset($this->aRules[$sName]); } } } }
[ "public", "function", "removeRule", "(", "$", "mRule", ")", "{", "if", "(", "$", "mRule", "instanceof", "Rule", ")", "{", "$", "sRule", "=", "$", "mRule", "->", "getRule", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "aRules", "[", "$", "sRule", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "aRules", "[", "$", "sRule", "]", "as", "$", "iKey", "=>", "$", "oRule", ")", "{", "if", "(", "$", "oRule", "===", "$", "mRule", ")", "{", "unset", "(", "$", "this", "->", "aRules", "[", "$", "sRule", "]", "[", "$", "iKey", "]", ")", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "aRules", "as", "$", "sName", "=>", "$", "aRules", ")", "{", "// Either no search rule is given or the search rule matches the found rule exactly or the search rule ends in “-” and the found rule starts with the search rule or equals it (without the trailing dash).", "if", "(", "!", "$", "mRule", "||", "$", "sName", "===", "$", "mRule", "||", "(", "strrpos", "(", "$", "mRule", ",", "'-'", ")", "===", "strlen", "(", "$", "mRule", ")", "-", "strlen", "(", "'-'", ")", "&&", "(", "strpos", "(", "$", "sName", ",", "$", "mRule", ")", "===", "0", "||", "$", "sName", "===", "substr", "(", "$", "mRule", ",", "0", ",", "-", "1", ")", ")", ")", ")", "{", "unset", "(", "$", "this", "->", "aRules", "[", "$", "sName", "]", ")", ";", "}", "}", "}", "}" ]
Remove a rule from this RuleSet. This accepts all the possible values that @link{getRules()} accepts. If given a Rule, it will only remove this particular rule (by identity). If given a name, it will remove all rules by that name. Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would remove all rules with the same name. To get the old behvaiour, use removeRule($oRule->getRule()). @param (null|string|Rule) $mRule pattern to remove. If $mRule is null, all rules are removed. If the pattern ends in a dash, all rules starting with the pattern are removed as well as one matching the pattern with the dash excluded. Passing a Rule behaves matches by identity.
[ "Remove", "a", "rule", "from", "this", "RuleSet", ".", "This", "accepts", "all", "the", "possible", "values", "that" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/php-css-parser/RuleSet/RuleSet.php#L98-L117
212,570
moodle/moodle
admin/tool/log/store/database/classes/privacy/provider.php
provider.get_database_and_table
protected static function get_database_and_table() { $manager = get_log_manager(); $store = new \logstore_database\log\store($manager); $db = $store->get_extdb(); return $db ? [$db, $store->get_config_value('dbtable')] : [null, null]; }
php
protected static function get_database_and_table() { $manager = get_log_manager(); $store = new \logstore_database\log\store($manager); $db = $store->get_extdb(); return $db ? [$db, $store->get_config_value('dbtable')] : [null, null]; }
[ "protected", "static", "function", "get_database_and_table", "(", ")", "{", "$", "manager", "=", "get_log_manager", "(", ")", ";", "$", "store", "=", "new", "\\", "logstore_database", "\\", "log", "\\", "store", "(", "$", "manager", ")", ";", "$", "db", "=", "$", "store", "->", "get_extdb", "(", ")", ";", "return", "$", "db", "?", "[", "$", "db", ",", "$", "store", "->", "get_config_value", "(", "'dbtable'", ")", "]", ":", "[", "null", ",", "null", "]", ";", "}" ]
Get the database object. @return array Containing moodle_database, string, or null values.
[ "Get", "the", "database", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/log/store/database/classes/privacy/provider.php#L132-L137
212,571
moodle/moodle
competency/classes/user_evidence_competency.php
user_evidence_competency.get_competencies_by_userevidenceid
public static function get_competencies_by_userevidenceid($userevidenceid) { global $DB; $sql = "SELECT c.* FROM {" . self::TABLE . "} uec JOIN {" . competency::TABLE . "} c ON uec.userevidenceid = ? AND uec.competencyid = c.id ORDER BY c.shortname"; $competencies = array(); $records = $DB->get_recordset_sql($sql, array($userevidenceid)); foreach ($records as $record) { $competencies[] = new competency(0, $record); } $records->close(); return $competencies; }
php
public static function get_competencies_by_userevidenceid($userevidenceid) { global $DB; $sql = "SELECT c.* FROM {" . self::TABLE . "} uec JOIN {" . competency::TABLE . "} c ON uec.userevidenceid = ? AND uec.competencyid = c.id ORDER BY c.shortname"; $competencies = array(); $records = $DB->get_recordset_sql($sql, array($userevidenceid)); foreach ($records as $record) { $competencies[] = new competency(0, $record); } $records->close(); return $competencies; }
[ "public", "static", "function", "get_competencies_by_userevidenceid", "(", "$", "userevidenceid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT c.*\n FROM {\"", ".", "self", "::", "TABLE", ".", "\"} uec\n JOIN {\"", ".", "competency", "::", "TABLE", ".", "\"} c\n ON uec.userevidenceid = ?\n AND uec.competencyid = c.id\n ORDER BY c.shortname\"", ";", "$", "competencies", "=", "array", "(", ")", ";", "$", "records", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "array", "(", "$", "userevidenceid", ")", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "competencies", "[", "]", "=", "new", "competency", "(", "0", ",", "$", "record", ")", ";", "}", "$", "records", "->", "close", "(", ")", ";", "return", "$", "competencies", ";", "}" ]
Get competencies by user evidence ID. @param int $userevidenceid The user evidence ID. @return competency[]
[ "Get", "competencies", "by", "user", "evidence", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/user_evidence_competency.php#L92-L107
212,572
moodle/moodle
competency/classes/user_evidence_competency.php
user_evidence_competency.get_user_competencies_by_userevidenceid
public static function get_user_competencies_by_userevidenceid($userevidenceid) { global $DB; $sql = "SELECT uc.* FROM {" . user_competency::TABLE . "} uc JOIN {" . self::TABLE . "} uec ON uc.competencyid = uec.competencyid JOIN {" . user_evidence::TABLE . "} ue ON uec.userevidenceid = ue.id AND uc.userid = ue.userid AND ue.id = ? ORDER BY uc.id ASC"; $usercompetencies = array(); $records = $DB->get_recordset_sql($sql, array($userevidenceid)); foreach ($records as $record) { $usercompetencies[] = new user_competency(0, $record); } $records->close(); return $usercompetencies; }
php
public static function get_user_competencies_by_userevidenceid($userevidenceid) { global $DB; $sql = "SELECT uc.* FROM {" . user_competency::TABLE . "} uc JOIN {" . self::TABLE . "} uec ON uc.competencyid = uec.competencyid JOIN {" . user_evidence::TABLE . "} ue ON uec.userevidenceid = ue.id AND uc.userid = ue.userid AND ue.id = ? ORDER BY uc.id ASC"; $usercompetencies = array(); $records = $DB->get_recordset_sql($sql, array($userevidenceid)); foreach ($records as $record) { $usercompetencies[] = new user_competency(0, $record); } $records->close(); return $usercompetencies; }
[ "public", "static", "function", "get_user_competencies_by_userevidenceid", "(", "$", "userevidenceid", ")", "{", "global", "$", "DB", ";", "$", "sql", "=", "\"SELECT uc.*\n FROM {\"", ".", "user_competency", "::", "TABLE", ".", "\"} uc\n JOIN {\"", ".", "self", "::", "TABLE", ".", "\"} uec\n ON uc.competencyid = uec.competencyid\n JOIN {\"", ".", "user_evidence", "::", "TABLE", ".", "\"} ue\n ON uec.userevidenceid = ue.id\n AND uc.userid = ue.userid\n AND ue.id = ?\n ORDER BY uc.id ASC\"", ";", "$", "usercompetencies", "=", "array", "(", ")", ";", "$", "records", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "array", "(", "$", "userevidenceid", ")", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "usercompetencies", "[", "]", "=", "new", "user_competency", "(", "0", ",", "$", "record", ")", ";", "}", "$", "records", "->", "close", "(", ")", ";", "return", "$", "usercompetencies", ";", "}" ]
Get user competencies by user evidence ID. @param int $userevidenceid The user evidence ID. @return user_competency[]
[ "Get", "user", "competencies", "by", "user", "evidence", "ID", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/user_evidence_competency.php#L115-L135
212,573
moodle/moodle
competency/classes/user_evidence_competency.php
user_evidence_competency.delete_by_competencyids
public static function delete_by_competencyids($competencyids) { global $DB; if (empty($competencyids)) { return true; } list($insql, $params) = $DB->get_in_or_equal($competencyids); return $DB->delete_records_select(self::TABLE, "competencyid $insql", $params); }
php
public static function delete_by_competencyids($competencyids) { global $DB; if (empty($competencyids)) { return true; } list($insql, $params) = $DB->get_in_or_equal($competencyids); return $DB->delete_records_select(self::TABLE, "competencyid $insql", $params); }
[ "public", "static", "function", "delete_by_competencyids", "(", "$", "competencyids", ")", "{", "global", "$", "DB", ";", "if", "(", "empty", "(", "$", "competencyids", ")", ")", "{", "return", "true", ";", "}", "list", "(", "$", "insql", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "competencyids", ")", ";", "return", "$", "DB", "->", "delete_records_select", "(", "self", "::", "TABLE", ",", "\"competencyid $insql\"", ",", "$", "params", ")", ";", "}" ]
Delete evidences using competencies. @param array $competencyids Array of competencies ids. @return bool Return true if the delete was successful.
[ "Delete", "evidences", "using", "competencies", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/user_evidence_competency.php#L169-L176
212,574
moodle/moodle
rating/classes/external.php
core_rating_external.get_item_ratings_parameters
public static function get_item_ratings_parameters() { return new external_function_parameters ( array( 'contextlevel' => new external_value(PARAM_ALPHA, 'context level: course, module, user, etc...'), 'instanceid' => new external_value(PARAM_INT, 'the instance id of item associated with the context level'), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'ratingarea' => new external_value(PARAM_AREA, 'rating area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'scaleid' => new external_value(PARAM_INT, 'scale id'), 'sort' => new external_value(PARAM_ALPHA, 'sort order (firstname, rating or timemodified)') ) ); }
php
public static function get_item_ratings_parameters() { return new external_function_parameters ( array( 'contextlevel' => new external_value(PARAM_ALPHA, 'context level: course, module, user, etc...'), 'instanceid' => new external_value(PARAM_INT, 'the instance id of item associated with the context level'), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'ratingarea' => new external_value(PARAM_AREA, 'rating area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'scaleid' => new external_value(PARAM_INT, 'scale id'), 'sort' => new external_value(PARAM_ALPHA, 'sort order (firstname, rating or timemodified)') ) ); }
[ "public", "static", "function", "get_item_ratings_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'contextlevel'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'context level: course, module, user, etc...'", ")", ",", "'instanceid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'the instance id of item associated with the context level'", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "'component'", ")", ",", "'ratingarea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "'rating area'", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'associated id'", ")", ",", "'scaleid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'scale id'", ")", ",", "'sort'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'sort order (firstname, rating or timemodified)'", ")", ")", ")", ";", "}" ]
Returns description of get_item_ratings parameters. @return external_function_parameters @since Moodle 2.9
[ "Returns", "description", "of", "get_item_ratings", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rating/classes/external.php#L49-L61
212,575
moodle/moodle
rating/classes/external.php
core_rating_external.get_item_ratings_returns
public static function get_item_ratings_returns() { return new external_single_structure( array( 'ratings' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'rating id'), 'userid' => new external_value(PARAM_INT, 'user id'), 'userpictureurl' => new external_value(PARAM_URL, 'URL user picture'), 'userfullname' => new external_value(PARAM_NOTAGS, 'user fullname'), 'rating' => new external_value(PARAM_NOTAGS, 'rating on scale'), 'timemodified' => new external_value(PARAM_INT, 'time modified (timestamp)') ), 'Rating' ), 'list of ratings' ), 'warnings' => new external_warnings(), ) ); }
php
public static function get_item_ratings_returns() { return new external_single_structure( array( 'ratings' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'rating id'), 'userid' => new external_value(PARAM_INT, 'user id'), 'userpictureurl' => new external_value(PARAM_URL, 'URL user picture'), 'userfullname' => new external_value(PARAM_NOTAGS, 'user fullname'), 'rating' => new external_value(PARAM_NOTAGS, 'rating on scale'), 'timemodified' => new external_value(PARAM_INT, 'time modified (timestamp)') ), 'Rating' ), 'list of ratings' ), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_item_ratings_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'ratings'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'rating id'", ")", ",", "'userid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'user id'", ")", ",", "'userpictureurl'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'URL user picture'", ")", ",", "'userfullname'", "=>", "new", "external_value", "(", "PARAM_NOTAGS", ",", "'user fullname'", ")", ",", "'rating'", "=>", "new", "external_value", "(", "PARAM_NOTAGS", ",", "'rating on scale'", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'time modified (timestamp)'", ")", ")", ",", "'Rating'", ")", ",", "'list of ratings'", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Returns description of get_item_ratings result values. @return external_single_structure @since Moodle 2.9
[ "Returns", "description", "of", "get_item_ratings", "result", "values", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rating/classes/external.php#L177-L196
212,576
moodle/moodle
rating/classes/external.php
core_rating_external.add_rating_parameters
public static function add_rating_parameters() { return new external_function_parameters ( array( 'contextlevel' => new external_value(PARAM_ALPHA, 'context level: course, module, user, etc...'), 'instanceid' => new external_value(PARAM_INT, 'the instance id of item associated with the context level'), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'ratingarea' => new external_value(PARAM_AREA, 'rating area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'scaleid' => new external_value(PARAM_INT, 'scale id'), 'rating' => new external_value(PARAM_INT, 'user rating'), 'rateduserid' => new external_value(PARAM_INT, 'rated user id'), 'aggregation' => new external_value(PARAM_INT, 'agreggation method', VALUE_DEFAULT, RATING_AGGREGATE_NONE) ) ); }
php
public static function add_rating_parameters() { return new external_function_parameters ( array( 'contextlevel' => new external_value(PARAM_ALPHA, 'context level: course, module, user, etc...'), 'instanceid' => new external_value(PARAM_INT, 'the instance id of item associated with the context level'), 'component' => new external_value(PARAM_COMPONENT, 'component'), 'ratingarea' => new external_value(PARAM_AREA, 'rating area'), 'itemid' => new external_value(PARAM_INT, 'associated id'), 'scaleid' => new external_value(PARAM_INT, 'scale id'), 'rating' => new external_value(PARAM_INT, 'user rating'), 'rateduserid' => new external_value(PARAM_INT, 'rated user id'), 'aggregation' => new external_value(PARAM_INT, 'agreggation method', VALUE_DEFAULT, RATING_AGGREGATE_NONE) ) ); }
[ "public", "static", "function", "add_rating_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'contextlevel'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'context level: course, module, user, etc...'", ")", ",", "'instanceid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'the instance id of item associated with the context level'", ")", ",", "'component'", "=>", "new", "external_value", "(", "PARAM_COMPONENT", ",", "'component'", ")", ",", "'ratingarea'", "=>", "new", "external_value", "(", "PARAM_AREA", ",", "'rating area'", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'associated id'", ")", ",", "'scaleid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'scale id'", ")", ",", "'rating'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'user rating'", ")", ",", "'rateduserid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'rated user id'", ")", ",", "'aggregation'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'agreggation method'", ",", "VALUE_DEFAULT", ",", "RATING_AGGREGATE_NONE", ")", ")", ")", ";", "}" ]
Returns description of add_rating parameters. @return external_function_parameters @since Moodle 3.2
[ "Returns", "description", "of", "add_rating", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rating/classes/external.php#L204-L218
212,577
moodle/moodle
rating/classes/external.php
core_rating_external.add_rating
public static function add_rating($contextlevel, $instanceid, $component, $ratingarea, $itemid, $scaleid, $rating, $rateduserid, $aggregation = RATING_AGGREGATE_NONE) { $warnings = array(); $params = array( 'contextlevel' => $contextlevel, 'instanceid' => $instanceid, 'component' => $component, 'ratingarea' => $ratingarea, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $rating, 'rateduserid' => $rateduserid, 'aggregation' => $aggregation, ); // Validate and normalize parameters. $params = self::validate_parameters(self::add_rating_parameters(), $params); $context = self::get_context_from_params($params); self::validate_context($context); $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST); require_capability('moodle/rating:rate', $context); $rm = new rating_manager(); $result = $rm->add_rating($cm, $context, $params['component'], $params['ratingarea'], $params['itemid'], $params['scaleid'], $params['rating'], $params['rateduserid'], $params['aggregation']); if (!empty($result->error)) { throw new moodle_exception($result->error, 'rating'); } $returndata = array( 'success' => $result->success, 'warnings' => $warnings ); if (isset($result->aggregate)) { $returndata['aggregate'] = $result->aggregate; $returndata['count'] = $result->count; $returndata['itemid'] = $result->itemid; } return $returndata; }
php
public static function add_rating($contextlevel, $instanceid, $component, $ratingarea, $itemid, $scaleid, $rating, $rateduserid, $aggregation = RATING_AGGREGATE_NONE) { $warnings = array(); $params = array( 'contextlevel' => $contextlevel, 'instanceid' => $instanceid, 'component' => $component, 'ratingarea' => $ratingarea, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $rating, 'rateduserid' => $rateduserid, 'aggregation' => $aggregation, ); // Validate and normalize parameters. $params = self::validate_parameters(self::add_rating_parameters(), $params); $context = self::get_context_from_params($params); self::validate_context($context); $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST); require_capability('moodle/rating:rate', $context); $rm = new rating_manager(); $result = $rm->add_rating($cm, $context, $params['component'], $params['ratingarea'], $params['itemid'], $params['scaleid'], $params['rating'], $params['rateduserid'], $params['aggregation']); if (!empty($result->error)) { throw new moodle_exception($result->error, 'rating'); } $returndata = array( 'success' => $result->success, 'warnings' => $warnings ); if (isset($result->aggregate)) { $returndata['aggregate'] = $result->aggregate; $returndata['count'] = $result->count; $returndata['itemid'] = $result->itemid; } return $returndata; }
[ "public", "static", "function", "add_rating", "(", "$", "contextlevel", ",", "$", "instanceid", ",", "$", "component", ",", "$", "ratingarea", ",", "$", "itemid", ",", "$", "scaleid", ",", "$", "rating", ",", "$", "rateduserid", ",", "$", "aggregation", "=", "RATING_AGGREGATE_NONE", ")", "{", "$", "warnings", "=", "array", "(", ")", ";", "$", "params", "=", "array", "(", "'contextlevel'", "=>", "$", "contextlevel", ",", "'instanceid'", "=>", "$", "instanceid", ",", "'component'", "=>", "$", "component", ",", "'ratingarea'", "=>", "$", "ratingarea", ",", "'itemid'", "=>", "$", "itemid", ",", "'scaleid'", "=>", "$", "scaleid", ",", "'rating'", "=>", "$", "rating", ",", "'rateduserid'", "=>", "$", "rateduserid", ",", "'aggregation'", "=>", "$", "aggregation", ",", ")", ";", "// Validate and normalize parameters.", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "add_rating_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "context", "=", "self", "::", "get_context_from_params", "(", "$", "params", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "$", "cm", "=", "get_coursemodule_from_id", "(", "false", ",", "$", "context", "->", "instanceid", ",", "0", ",", "false", ",", "MUST_EXIST", ")", ";", "require_capability", "(", "'moodle/rating:rate'", ",", "$", "context", ")", ";", "$", "rm", "=", "new", "rating_manager", "(", ")", ";", "$", "result", "=", "$", "rm", "->", "add_rating", "(", "$", "cm", ",", "$", "context", ",", "$", "params", "[", "'component'", "]", ",", "$", "params", "[", "'ratingarea'", "]", ",", "$", "params", "[", "'itemid'", "]", ",", "$", "params", "[", "'scaleid'", "]", ",", "$", "params", "[", "'rating'", "]", ",", "$", "params", "[", "'rateduserid'", "]", ",", "$", "params", "[", "'aggregation'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "result", "->", "error", ")", ")", "{", "throw", "new", "moodle_exception", "(", "$", "result", "->", "error", ",", "'rating'", ")", ";", "}", "$", "returndata", "=", "array", "(", "'success'", "=>", "$", "result", "->", "success", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "aggregate", ")", ")", "{", "$", "returndata", "[", "'aggregate'", "]", "=", "$", "result", "->", "aggregate", ";", "$", "returndata", "[", "'count'", "]", "=", "$", "result", "->", "count", ";", "$", "returndata", "[", "'itemid'", "]", "=", "$", "result", "->", "itemid", ";", "}", "return", "$", "returndata", ";", "}" ]
Adds a rating to an item @param string $contextlevel course, module, user... @param int $instanceid the instance if for the context element @param string $component the name of the component @param string $ratingarea rating area @param int $itemid the item id @param int $scaleid the scale id @param int $rating the user rating @param int $rateduserid the rated user id @param int $aggregation the aggregation method @return array result and possible warnings @throws moodle_exception @since Moodle 3.2
[ "Adds", "a", "rating", "to", "an", "item" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rating/classes/external.php#L236-L281
212,578
moodle/moodle
rating/classes/external.php
core_rating_external.add_rating_returns
public static function add_rating_returns() { return new external_single_structure( array( 'success' => new external_value(PARAM_BOOL, 'Whether the rate was successfully created'), 'aggregate' => new external_value(PARAM_TEXT, 'New aggregate', VALUE_OPTIONAL), 'count' => new external_value(PARAM_INT, 'Ratings count', VALUE_OPTIONAL), 'itemid' => new external_value(PARAM_INT, 'Rating item id', VALUE_OPTIONAL), 'warnings' => new external_warnings(), ) ); }
php
public static function add_rating_returns() { return new external_single_structure( array( 'success' => new external_value(PARAM_BOOL, 'Whether the rate was successfully created'), 'aggregate' => new external_value(PARAM_TEXT, 'New aggregate', VALUE_OPTIONAL), 'count' => new external_value(PARAM_INT, 'Ratings count', VALUE_OPTIONAL), 'itemid' => new external_value(PARAM_INT, 'Rating item id', VALUE_OPTIONAL), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "add_rating_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'success'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the rate was successfully created'", ")", ",", "'aggregate'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'New aggregate'", ",", "VALUE_OPTIONAL", ")", ",", "'count'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Ratings count'", ",", "VALUE_OPTIONAL", ")", ",", "'itemid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Rating item id'", ",", "VALUE_OPTIONAL", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Returns description of add_rating result values. @return external_single_structure @since Moodle 3.2
[ "Returns", "description", "of", "add_rating", "result", "values", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rating/classes/external.php#L289-L300
212,579
moodle/moodle
mod/feedback/classes/event/response_submitted.php
response_submitted.init
protected function init() { global $CFG; require_once($CFG->dirroot.'/mod/feedback/lib.php'); $this->data['objecttable'] = 'feedback_completed'; $this->data['crud'] = 'c'; $this->data['edulevel'] = self::LEVEL_PARTICIPATING; }
php
protected function init() { global $CFG; require_once($CFG->dirroot.'/mod/feedback/lib.php'); $this->data['objecttable'] = 'feedback_completed'; $this->data['crud'] = 'c'; $this->data['edulevel'] = self::LEVEL_PARTICIPATING; }
[ "protected", "function", "init", "(", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/feedback/lib.php'", ")", ";", "$", "this", "->", "data", "[", "'objecttable'", "]", "=", "'feedback_completed'", ";", "$", "this", "->", "data", "[", "'crud'", "]", "=", "'c'", ";", "$", "this", "->", "data", "[", "'edulevel'", "]", "=", "self", "::", "LEVEL_PARTICIPATING", ";", "}" ]
Set basic properties for the event.
[ "Set", "basic", "properties", "for", "the", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/event/response_submitted.php#L51-L58
212,580
moodle/moodle
mod/feedback/classes/event/response_submitted.php
response_submitted.create_from_record
public static function create_from_record($completed, $cm) { $event = self::create(array( 'relateduserid' => $completed->userid, 'objectid' => $completed->id, 'context' => \context_module::instance($cm->id), 'anonymous' => ($completed->anonymous_response == FEEDBACK_ANONYMOUS_YES), 'other' => array( 'cmid' => $cm->id, 'instanceid' => $completed->feedback, 'anonymous' => $completed->anonymous_response // Deprecated. ) )); $event->add_record_snapshot('feedback_completed', $completed); return $event; }
php
public static function create_from_record($completed, $cm) { $event = self::create(array( 'relateduserid' => $completed->userid, 'objectid' => $completed->id, 'context' => \context_module::instance($cm->id), 'anonymous' => ($completed->anonymous_response == FEEDBACK_ANONYMOUS_YES), 'other' => array( 'cmid' => $cm->id, 'instanceid' => $completed->feedback, 'anonymous' => $completed->anonymous_response // Deprecated. ) )); $event->add_record_snapshot('feedback_completed', $completed); return $event; }
[ "public", "static", "function", "create_from_record", "(", "$", "completed", ",", "$", "cm", ")", "{", "$", "event", "=", "self", "::", "create", "(", "array", "(", "'relateduserid'", "=>", "$", "completed", "->", "userid", ",", "'objectid'", "=>", "$", "completed", "->", "id", ",", "'context'", "=>", "\\", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'anonymous'", "=>", "(", "$", "completed", "->", "anonymous_response", "==", "FEEDBACK_ANONYMOUS_YES", ")", ",", "'other'", "=>", "array", "(", "'cmid'", "=>", "$", "cm", "->", "id", ",", "'instanceid'", "=>", "$", "completed", "->", "feedback", ",", "'anonymous'", "=>", "$", "completed", "->", "anonymous_response", "// Deprecated.", ")", ")", ")", ";", "$", "event", "->", "add_record_snapshot", "(", "'feedback_completed'", ",", "$", "completed", ")", ";", "return", "$", "event", ";", "}" ]
Creates an instance from the record from db table feedback_completed @param stdClass $completed @param stdClass|cm_info $cm @return self
[ "Creates", "an", "instance", "from", "the", "record", "from", "db", "table", "feedback_completed" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/event/response_submitted.php#L67-L81
212,581
moodle/moodle
mod/feedback/classes/event/response_submitted.php
response_submitted.get_url
public function get_url() { if ($this->anonymous) { return new \moodle_url('/mod/feedback/show_entries.php', array('id' => $this->other['cmid'], 'showcompleted' => $this->objectid)); } else { return new \moodle_url('/mod/feedback/show_entries.php' , array('id' => $this->other['cmid'], 'userid' => $this->userid, 'showcompleted' => $this->objectid)); } }
php
public function get_url() { if ($this->anonymous) { return new \moodle_url('/mod/feedback/show_entries.php', array('id' => $this->other['cmid'], 'showcompleted' => $this->objectid)); } else { return new \moodle_url('/mod/feedback/show_entries.php' , array('id' => $this->other['cmid'], 'userid' => $this->userid, 'showcompleted' => $this->objectid)); } }
[ "public", "function", "get_url", "(", ")", "{", "if", "(", "$", "this", "->", "anonymous", ")", "{", "return", "new", "\\", "moodle_url", "(", "'/mod/feedback/show_entries.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "other", "[", "'cmid'", "]", ",", "'showcompleted'", "=>", "$", "this", "->", "objectid", ")", ")", ";", "}", "else", "{", "return", "new", "\\", "moodle_url", "(", "'/mod/feedback/show_entries.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "other", "[", "'cmid'", "]", ",", "'userid'", "=>", "$", "this", "->", "userid", ",", "'showcompleted'", "=>", "$", "this", "->", "objectid", ")", ")", ";", "}", "}" ]
Returns relevant URL based on the anonymous mode of the response. @return \moodle_url
[ "Returns", "relevant", "URL", "based", "on", "the", "anonymous", "mode", "of", "the", "response", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/event/response_submitted.php#L106-L114
212,582
moodle/moodle
mod/feedback/classes/event/response_submitted.php
response_submitted.can_view
public function can_view($userorid = null) { global $USER; debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER); if (empty($userorid)) { $userorid = $USER; } if ($this->anonymous) { return is_siteadmin($userorid); } else { return has_capability('mod/feedback:viewreports', $this->context, $userorid); } }
php
public function can_view($userorid = null) { global $USER; debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER); if (empty($userorid)) { $userorid = $USER; } if ($this->anonymous) { return is_siteadmin($userorid); } else { return has_capability('mod/feedback:viewreports', $this->context, $userorid); } }
[ "public", "function", "can_view", "(", "$", "userorid", "=", "null", ")", "{", "global", "$", "USER", ";", "debugging", "(", "'can_view() method is deprecated, use anonymous flag instead if necessary.'", ",", "DEBUG_DEVELOPER", ")", ";", "if", "(", "empty", "(", "$", "userorid", ")", ")", "{", "$", "userorid", "=", "$", "USER", ";", "}", "if", "(", "$", "this", "->", "anonymous", ")", "{", "return", "is_siteadmin", "(", "$", "userorid", ")", ";", "}", "else", "{", "return", "has_capability", "(", "'mod/feedback:viewreports'", ",", "$", "this", "->", "context", ",", "$", "userorid", ")", ";", "}", "}" ]
Define whether a user can view the event or not. Make sure no one except admin can see details of an anonymous response. @deprecated since 2.7 @param int|\stdClass $userorid ID of the user. @return bool True if the user can view the event, false otherwise.
[ "Define", "whether", "a", "user", "can", "view", "the", "event", "or", "not", ".", "Make", "sure", "no", "one", "except", "admin", "can", "see", "details", "of", "an", "anonymous", "response", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/event/response_submitted.php#L139-L151
212,583
moodle/moodle
report/competency/classes/output/renderer.php
renderer.notify_message
public function notify_message($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_INFO); return $this->render($n); }
php
public function notify_message($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_INFO); return $this->render($n); }
[ "public", "function", "notify_message", "(", "$", "message", ")", "{", "$", "n", "=", "new", "\\", "core", "\\", "output", "\\", "notification", "(", "$", "message", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_INFO", ")", ";", "return", "$", "this", "->", "render", "(", "$", "n", ")", ";", "}" ]
Output a nofication. @param string $message the message to print out @return string HTML fragment. @see \core\output\notification
[ "Output", "a", "nofication", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/competency/classes/output/renderer.php#L70-L73
212,584
moodle/moodle
report/competency/classes/output/renderer.php
renderer.notify_problem
public function notify_problem($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_ERROR); return $this->render($n); }
php
public function notify_problem($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_ERROR); return $this->render($n); }
[ "public", "function", "notify_problem", "(", "$", "message", ")", "{", "$", "n", "=", "new", "\\", "core", "\\", "output", "\\", "notification", "(", "$", "message", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_ERROR", ")", ";", "return", "$", "this", "->", "render", "(", "$", "n", ")", ";", "}" ]
Output an error notification. @param string $message the message to print out @return string HTML fragment. @see \core\output\notification
[ "Output", "an", "error", "notification", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/competency/classes/output/renderer.php#L82-L85
212,585
moodle/moodle
report/competency/classes/output/renderer.php
renderer.notify_success
public function notify_success($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_SUCCESS); return $this->render($n); }
php
public function notify_success($message) { $n = new \core\output\notification($message, \core\output\notification::NOTIFY_SUCCESS); return $this->render($n); }
[ "public", "function", "notify_success", "(", "$", "message", ")", "{", "$", "n", "=", "new", "\\", "core", "\\", "output", "\\", "notification", "(", "$", "message", ",", "\\", "core", "\\", "output", "\\", "notification", "::", "NOTIFY_SUCCESS", ")", ";", "return", "$", "this", "->", "render", "(", "$", "n", ")", ";", "}" ]
Output a success notification. @param string $message the message to print out @return string HTML fragment. @see \core\output\notification
[ "Output", "a", "success", "notification", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/competency/classes/output/renderer.php#L94-L97
212,586
moodle/moodle
lib/form/classes/privacy/provider.php
provider.export_user_preferences
public static function export_user_preferences(int $userid) { $preference = get_user_preferences('filemanager_recentviewmode'); if ($preference !== null) { switch ($preference) { case 1: $value = get_string('displayasicons', 'core_repository'); break; case 2: $value = get_string('displayastree', 'core_repository'); break; case 3: $value = get_string('displaydetails', 'core_repository'); break; default: $value = $preference; } $desc = get_string('privacy:preference:filemanager_recentviewmode', 'core_form', $value); writer::export_user_preference('core_form', 'filemanager_recentviewmode', $preference, $desc); } }
php
public static function export_user_preferences(int $userid) { $preference = get_user_preferences('filemanager_recentviewmode'); if ($preference !== null) { switch ($preference) { case 1: $value = get_string('displayasicons', 'core_repository'); break; case 2: $value = get_string('displayastree', 'core_repository'); break; case 3: $value = get_string('displaydetails', 'core_repository'); break; default: $value = $preference; } $desc = get_string('privacy:preference:filemanager_recentviewmode', 'core_form', $value); writer::export_user_preference('core_form', 'filemanager_recentviewmode', $preference, $desc); } }
[ "public", "static", "function", "export_user_preferences", "(", "int", "$", "userid", ")", "{", "$", "preference", "=", "get_user_preferences", "(", "'filemanager_recentviewmode'", ")", ";", "if", "(", "$", "preference", "!==", "null", ")", "{", "switch", "(", "$", "preference", ")", "{", "case", "1", ":", "$", "value", "=", "get_string", "(", "'displayasicons'", ",", "'core_repository'", ")", ";", "break", ";", "case", "2", ":", "$", "value", "=", "get_string", "(", "'displayastree'", ",", "'core_repository'", ")", ";", "break", ";", "case", "3", ":", "$", "value", "=", "get_string", "(", "'displaydetails'", ",", "'core_repository'", ")", ";", "break", ";", "default", ":", "$", "value", "=", "$", "preference", ";", "}", "$", "desc", "=", "get_string", "(", "'privacy:preference:filemanager_recentviewmode'", ",", "'core_form'", ",", "$", "value", ")", ";", "writer", "::", "export_user_preference", "(", "'core_form'", ",", "'filemanager_recentviewmode'", ",", "$", "preference", ",", "$", "desc", ")", ";", "}", "}" ]
Export all user preferences for the subsystem. @param int $userid The ID of the user whose data is to be exported.
[ "Export", "all", "user", "preferences", "for", "the", "subsystem", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/classes/privacy/provider.php#L65-L87
212,587
moodle/moodle
admin/roles/classes/allow_role_page.php
core_role_allow_role_page.process_submission
public function process_submission() { global $DB; // Delete all records, then add back the ones that should be allowed. $DB->delete_records($this->tablename); foreach ($this->roles as $fromroleid => $notused) { foreach ($this->roles as $targetroleid => $alsonotused) { if (optional_param('s_' . $fromroleid . '_' . $targetroleid, false, PARAM_BOOL)) { $this->set_allow($fromroleid, $targetroleid); } } } }
php
public function process_submission() { global $DB; // Delete all records, then add back the ones that should be allowed. $DB->delete_records($this->tablename); foreach ($this->roles as $fromroleid => $notused) { foreach ($this->roles as $targetroleid => $alsonotused) { if (optional_param('s_' . $fromroleid . '_' . $targetroleid, false, PARAM_BOOL)) { $this->set_allow($fromroleid, $targetroleid); } } } }
[ "public", "function", "process_submission", "(", ")", "{", "global", "$", "DB", ";", "// Delete all records, then add back the ones that should be allowed.", "$", "DB", "->", "delete_records", "(", "$", "this", "->", "tablename", ")", ";", "foreach", "(", "$", "this", "->", "roles", "as", "$", "fromroleid", "=>", "$", "notused", ")", "{", "foreach", "(", "$", "this", "->", "roles", "as", "$", "targetroleid", "=>", "$", "alsonotused", ")", "{", "if", "(", "optional_param", "(", "'s_'", ".", "$", "fromroleid", ".", "'_'", ".", "$", "targetroleid", ",", "false", ",", "PARAM_BOOL", ")", ")", "{", "$", "this", "->", "set_allow", "(", "$", "fromroleid", ",", "$", "targetroleid", ")", ";", "}", "}", "}", "}" ]
Update the data with the new settings submitted by the user.
[ "Update", "the", "data", "with", "the", "new", "settings", "submitted", "by", "the", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/allow_role_page.php#L60-L71
212,588
moodle/moodle
admin/roles/classes/allow_role_page.php
core_role_allow_role_page.load_current_settings
public function load_current_settings() { global $DB; // Load the current settings. $this->allowed = array(); foreach ($this->roles as $role) { // Make an array $role->id => false. This is probably too clever for its own good. $this->allowed[$role->id] = array_combine(array_keys($this->roles), array_fill(0, count($this->roles), false)); } $rs = $DB->get_recordset($this->tablename); foreach ($rs as $allow) { $this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true; } $rs->close(); }
php
public function load_current_settings() { global $DB; // Load the current settings. $this->allowed = array(); foreach ($this->roles as $role) { // Make an array $role->id => false. This is probably too clever for its own good. $this->allowed[$role->id] = array_combine(array_keys($this->roles), array_fill(0, count($this->roles), false)); } $rs = $DB->get_recordset($this->tablename); foreach ($rs as $allow) { $this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true; } $rs->close(); }
[ "public", "function", "load_current_settings", "(", ")", "{", "global", "$", "DB", ";", "// Load the current settings.", "$", "this", "->", "allowed", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "roles", "as", "$", "role", ")", "{", "// Make an array $role->id => false. This is probably too clever for its own good.", "$", "this", "->", "allowed", "[", "$", "role", "->", "id", "]", "=", "array_combine", "(", "array_keys", "(", "$", "this", "->", "roles", ")", ",", "array_fill", "(", "0", ",", "count", "(", "$", "this", "->", "roles", ")", ",", "false", ")", ")", ";", "}", "$", "rs", "=", "$", "DB", "->", "get_recordset", "(", "$", "this", "->", "tablename", ")", ";", "foreach", "(", "$", "rs", "as", "$", "allow", ")", "{", "$", "this", "->", "allowed", "[", "$", "allow", "->", "roleid", "]", "[", "$", "allow", "->", "{", "$", "this", "->", "targetcolname", "}", "]", "=", "true", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "}" ]
Load the current allows from the database.
[ "Load", "the", "current", "allows", "from", "the", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/allow_role_page.php#L83-L96
212,589
moodle/moodle
admin/roles/classes/allow_role_page.php
core_role_allow_role_page.get_table
public function get_table() { $table = new html_table(); $table->tablealign = 'center'; $table->cellpadding = 5; $table->cellspacing = 0; $table->width = '90%'; $table->align = array('left'); $table->rotateheaders = true; $table->head = array('&#xa0;'); $table->colclasses = array(''); // Add role name headers. foreach ($this->roles as $targetrole) { $table->head[] = $targetrole->localname; $table->align[] = 'left'; if ($this->is_allowed_target($targetrole->id)) { $table->colclasses[] = ''; } else { $table->colclasses[] = 'dimmed_text'; } } // Now the rest of the table. foreach ($this->roles as $fromrole) { $row = array($fromrole->localname); foreach ($this->roles as $targetrole) { $checked = ''; $disabled = ''; if ($this->allowed[$fromrole->id][$targetrole->id]) { $checked = 'checked="checked" '; } if (!$this->is_allowed_target($targetrole->id)) { $disabled = 'disabled="disabled" '; } $name = 's_' . $fromrole->id . '_' . $targetrole->id; $tooltip = $this->get_cell_tooltip($fromrole, $targetrole); $row[] = '<input type="checkbox" name="' . $name . '" id="' . $name . '" title="' . $tooltip . '" value="1" ' . $checked . $disabled . '/>' . '<label for="' . $name . '" class="accesshide">' . $tooltip . '</label>'; } $table->data[] = $row; } return $table; }
php
public function get_table() { $table = new html_table(); $table->tablealign = 'center'; $table->cellpadding = 5; $table->cellspacing = 0; $table->width = '90%'; $table->align = array('left'); $table->rotateheaders = true; $table->head = array('&#xa0;'); $table->colclasses = array(''); // Add role name headers. foreach ($this->roles as $targetrole) { $table->head[] = $targetrole->localname; $table->align[] = 'left'; if ($this->is_allowed_target($targetrole->id)) { $table->colclasses[] = ''; } else { $table->colclasses[] = 'dimmed_text'; } } // Now the rest of the table. foreach ($this->roles as $fromrole) { $row = array($fromrole->localname); foreach ($this->roles as $targetrole) { $checked = ''; $disabled = ''; if ($this->allowed[$fromrole->id][$targetrole->id]) { $checked = 'checked="checked" '; } if (!$this->is_allowed_target($targetrole->id)) { $disabled = 'disabled="disabled" '; } $name = 's_' . $fromrole->id . '_' . $targetrole->id; $tooltip = $this->get_cell_tooltip($fromrole, $targetrole); $row[] = '<input type="checkbox" name="' . $name . '" id="' . $name . '" title="' . $tooltip . '" value="1" ' . $checked . $disabled . '/>' . '<label for="' . $name . '" class="accesshide">' . $tooltip . '</label>'; } $table->data[] = $row; } return $table; }
[ "public", "function", "get_table", "(", ")", "{", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "tablealign", "=", "'center'", ";", "$", "table", "->", "cellpadding", "=", "5", ";", "$", "table", "->", "cellspacing", "=", "0", ";", "$", "table", "->", "width", "=", "'90%'", ";", "$", "table", "->", "align", "=", "array", "(", "'left'", ")", ";", "$", "table", "->", "rotateheaders", "=", "true", ";", "$", "table", "->", "head", "=", "array", "(", "'&#xa0;'", ")", ";", "$", "table", "->", "colclasses", "=", "array", "(", "''", ")", ";", "// Add role name headers.", "foreach", "(", "$", "this", "->", "roles", "as", "$", "targetrole", ")", "{", "$", "table", "->", "head", "[", "]", "=", "$", "targetrole", "->", "localname", ";", "$", "table", "->", "align", "[", "]", "=", "'left'", ";", "if", "(", "$", "this", "->", "is_allowed_target", "(", "$", "targetrole", "->", "id", ")", ")", "{", "$", "table", "->", "colclasses", "[", "]", "=", "''", ";", "}", "else", "{", "$", "table", "->", "colclasses", "[", "]", "=", "'dimmed_text'", ";", "}", "}", "// Now the rest of the table.", "foreach", "(", "$", "this", "->", "roles", "as", "$", "fromrole", ")", "{", "$", "row", "=", "array", "(", "$", "fromrole", "->", "localname", ")", ";", "foreach", "(", "$", "this", "->", "roles", "as", "$", "targetrole", ")", "{", "$", "checked", "=", "''", ";", "$", "disabled", "=", "''", ";", "if", "(", "$", "this", "->", "allowed", "[", "$", "fromrole", "->", "id", "]", "[", "$", "targetrole", "->", "id", "]", ")", "{", "$", "checked", "=", "'checked=\"checked\" '", ";", "}", "if", "(", "!", "$", "this", "->", "is_allowed_target", "(", "$", "targetrole", "->", "id", ")", ")", "{", "$", "disabled", "=", "'disabled=\"disabled\" '", ";", "}", "$", "name", "=", "'s_'", ".", "$", "fromrole", "->", "id", ".", "'_'", ".", "$", "targetrole", "->", "id", ";", "$", "tooltip", "=", "$", "this", "->", "get_cell_tooltip", "(", "$", "fromrole", ",", "$", "targetrole", ")", ";", "$", "row", "[", "]", "=", "'<input type=\"checkbox\" name=\"'", ".", "$", "name", ".", "'\" id=\"'", ".", "$", "name", ".", "'\" title=\"'", ".", "$", "tooltip", ".", "'\" value=\"1\" '", ".", "$", "checked", ".", "$", "disabled", ".", "'/>'", ".", "'<label for=\"'", ".", "$", "name", ".", "'\" class=\"accesshide\">'", ".", "$", "tooltip", ".", "'</label>'", ";", "}", "$", "table", "->", "data", "[", "]", "=", "$", "row", ";", "}", "return", "$", "table", ";", "}" ]
Returns structure that can be passed to print_table, containing one cell for each checkbox. @return html_table a table
[ "Returns", "structure", "that", "can", "be", "passed", "to", "print_table", "containing", "one", "cell", "for", "each", "checkbox", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/allow_role_page.php#L113-L157
212,590
moodle/moodle
auth/ldap/classes/admin_setting_special_contexts_configtext.php
auth_ldap_admin_setting_special_contexts_configtext.write_setting
public function write_setting($data) { // Try to remove duplicates before storing the contexts (to avoid problems in sync_users()). $data = explode(';', $data); $data = array_map(function($x) { return core_text::strtolower(trim($x)); }, $data); $data = implode(';', array_unique($data)); return parent::write_setting($data); }
php
public function write_setting($data) { // Try to remove duplicates before storing the contexts (to avoid problems in sync_users()). $data = explode(';', $data); $data = array_map(function($x) { return core_text::strtolower(trim($x)); }, $data); $data = implode(';', array_unique($data)); return parent::write_setting($data); }
[ "public", "function", "write_setting", "(", "$", "data", ")", "{", "// Try to remove duplicates before storing the contexts (to avoid problems in sync_users()).", "$", "data", "=", "explode", "(", "';'", ",", "$", "data", ")", ";", "$", "data", "=", "array_map", "(", "function", "(", "$", "x", ")", "{", "return", "core_text", "::", "strtolower", "(", "trim", "(", "$", "x", ")", ")", ";", "}", ",", "$", "data", ")", ";", "$", "data", "=", "implode", "(", "';'", ",", "array_unique", "(", "$", "data", ")", ")", ";", "return", "parent", "::", "write_setting", "(", "$", "data", ")", ";", "}" ]
We need to remove duplicates on save to prevent issues in other areas of Moodle. @param string $data Form data. @return string Empty when no errors.
[ "We", "need", "to", "remove", "duplicates", "on", "save", "to", "prevent", "issues", "in", "other", "areas", "of", "Moodle", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/ldap/classes/admin_setting_special_contexts_configtext.php#L42-L50
212,591
moodle/moodle
admin/tool/monitor/classes/output/managerules/renderer.php
renderer.render_add_button
protected function render_add_button($courseid) { global $CFG; $button = \html_writer::tag('button', get_string('addrule', 'tool_monitor'), ['class' => 'btn btn-primary']); $addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('courseid' => $courseid)); return \html_writer::link($addurl, $button); }
php
protected function render_add_button($courseid) { global $CFG; $button = \html_writer::tag('button', get_string('addrule', 'tool_monitor'), ['class' => 'btn btn-primary']); $addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('courseid' => $courseid)); return \html_writer::link($addurl, $button); }
[ "protected", "function", "render_add_button", "(", "$", "courseid", ")", "{", "global", "$", "CFG", ";", "$", "button", "=", "\\", "html_writer", "::", "tag", "(", "'button'", ",", "get_string", "(", "'addrule'", ",", "'tool_monitor'", ")", ",", "[", "'class'", "=>", "'btn btn-primary'", "]", ")", ";", "$", "addurl", "=", "new", "\\", "moodle_url", "(", "$", "CFG", "->", "wwwroot", ".", "'/admin/tool/monitor/edit.php'", ",", "array", "(", "'courseid'", "=>", "$", "courseid", ")", ")", ";", "return", "\\", "html_writer", "::", "link", "(", "$", "addurl", ",", "$", "button", ")", ";", "}" ]
Html to add a button for adding a new rule. @param int $courseid course id. @return string html for the button.
[ "Html", "to", "add", "a", "button", "for", "adding", "a", "new", "rule", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/monitor/classes/output/managerules/renderer.php#L77-L83
212,592
moodle/moodle
admin/tool/monitor/classes/output/managerules/renderer.php
renderer.render_subscriptions_link
public function render_subscriptions_link($manageurl) { echo \html_writer::start_div(); $a = \html_writer::link($manageurl, get_string('managesubscriptions', 'tool_monitor')); $link = \html_writer::tag('span', get_string('managesubscriptionslink', 'tool_monitor', $a)); echo $link; echo \html_writer::end_div(); }
php
public function render_subscriptions_link($manageurl) { echo \html_writer::start_div(); $a = \html_writer::link($manageurl, get_string('managesubscriptions', 'tool_monitor')); $link = \html_writer::tag('span', get_string('managesubscriptionslink', 'tool_monitor', $a)); echo $link; echo \html_writer::end_div(); }
[ "public", "function", "render_subscriptions_link", "(", "$", "manageurl", ")", "{", "echo", "\\", "html_writer", "::", "start_div", "(", ")", ";", "$", "a", "=", "\\", "html_writer", "::", "link", "(", "$", "manageurl", ",", "get_string", "(", "'managesubscriptions'", ",", "'tool_monitor'", ")", ")", ";", "$", "link", "=", "\\", "html_writer", "::", "tag", "(", "'span'", ",", "get_string", "(", "'managesubscriptionslink'", ",", "'tool_monitor'", ",", "$", "a", ")", ")", ";", "echo", "$", "link", ";", "echo", "\\", "html_writer", "::", "end_div", "(", ")", ";", "}" ]
Html to add a link to go to the subscription page. @param moodle_url $manageurl The url of the subscription page. @return string html for the link to the subscription page.
[ "Html", "to", "add", "a", "link", "to", "go", "to", "the", "subscription", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/monitor/classes/output/managerules/renderer.php#L92-L98
212,593
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_subscribe_to_forum
public function can_subscribe_to_forum(stdClass $user) : bool { if ($this->forum->get_type() == 'single') { return false; } return !is_guest($this->get_context(), $user) && subscriptions::is_subscribable($this->get_forum_record()); }
php
public function can_subscribe_to_forum(stdClass $user) : bool { if ($this->forum->get_type() == 'single') { return false; } return !is_guest($this->get_context(), $user) && subscriptions::is_subscribable($this->get_forum_record()); }
[ "public", "function", "can_subscribe_to_forum", "(", "stdClass", "$", "user", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "forum", "->", "get_type", "(", ")", "==", "'single'", ")", "{", "return", "false", ";", "}", "return", "!", "is_guest", "(", "$", "this", "->", "get_context", "(", ")", ",", "$", "user", ")", "&&", "subscriptions", "::", "is_subscribable", "(", "$", "this", "->", "get_forum_record", "(", ")", ")", ";", "}" ]
Can the user subscribe to this forum? @param stdClass $user The user to check @return bool
[ "Can", "the", "user", "subscribe", "to", "this", "forum?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L92-L99
212,594
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_create_discussions
public function can_create_discussions(stdClass $user, int $groupid = null) : bool { if (isguestuser($user) or !isloggedin()) { return false; } if ($this->forum->is_cutoff_date_reached()) { if (!has_capability('mod/forum:canoverridecutoff', $this->get_context())) { return false; } } switch ($this->forum->get_type()) { case 'news': $capability = 'mod/forum:addnews'; break; case 'qanda': $capability = 'mod/forum:addquestion'; break; default: $capability = 'mod/forum:startdiscussion'; } if (!has_capability($capability, $this->forum->get_context(), $user)) { return false; } if ($this->forum->get_type() == 'eachuser') { if (forum_user_has_posted_discussion($this->forum->get_id(), $user->id, $groupid)) { return false; } } if ($this->forum->is_in_group_mode()) { return $groupid ? $this->can_access_group($user, $groupid) : $this->can_access_all_groups($user); } else { return true; } }
php
public function can_create_discussions(stdClass $user, int $groupid = null) : bool { if (isguestuser($user) or !isloggedin()) { return false; } if ($this->forum->is_cutoff_date_reached()) { if (!has_capability('mod/forum:canoverridecutoff', $this->get_context())) { return false; } } switch ($this->forum->get_type()) { case 'news': $capability = 'mod/forum:addnews'; break; case 'qanda': $capability = 'mod/forum:addquestion'; break; default: $capability = 'mod/forum:startdiscussion'; } if (!has_capability($capability, $this->forum->get_context(), $user)) { return false; } if ($this->forum->get_type() == 'eachuser') { if (forum_user_has_posted_discussion($this->forum->get_id(), $user->id, $groupid)) { return false; } } if ($this->forum->is_in_group_mode()) { return $groupid ? $this->can_access_group($user, $groupid) : $this->can_access_all_groups($user); } else { return true; } }
[ "public", "function", "can_create_discussions", "(", "stdClass", "$", "user", ",", "int", "$", "groupid", "=", "null", ")", ":", "bool", "{", "if", "(", "isguestuser", "(", "$", "user", ")", "or", "!", "isloggedin", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "forum", "->", "is_cutoff_date_reached", "(", ")", ")", "{", "if", "(", "!", "has_capability", "(", "'mod/forum:canoverridecutoff'", ",", "$", "this", "->", "get_context", "(", ")", ")", ")", "{", "return", "false", ";", "}", "}", "switch", "(", "$", "this", "->", "forum", "->", "get_type", "(", ")", ")", "{", "case", "'news'", ":", "$", "capability", "=", "'mod/forum:addnews'", ";", "break", ";", "case", "'qanda'", ":", "$", "capability", "=", "'mod/forum:addquestion'", ";", "break", ";", "default", ":", "$", "capability", "=", "'mod/forum:startdiscussion'", ";", "}", "if", "(", "!", "has_capability", "(", "$", "capability", ",", "$", "this", "->", "forum", "->", "get_context", "(", ")", ",", "$", "user", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "forum", "->", "get_type", "(", ")", "==", "'eachuser'", ")", "{", "if", "(", "forum_user_has_posted_discussion", "(", "$", "this", "->", "forum", "->", "get_id", "(", ")", ",", "$", "user", "->", "id", ",", "$", "groupid", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "$", "this", "->", "forum", "->", "is_in_group_mode", "(", ")", ")", "{", "return", "$", "groupid", "?", "$", "this", "->", "can_access_group", "(", "$", "user", ",", "$", "groupid", ")", ":", "$", "this", "->", "can_access_all_groups", "(", "$", "user", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Can the user create discussions in this forum? @param stdClass $user The user to check @param int|null $groupid The current activity group id @return bool
[ "Can", "the", "user", "create", "discussions", "in", "this", "forum?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L108-L145
212,595
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_access_group
public function can_access_group(stdClass $user, int $groupid) : bool { if ($this->can_access_all_groups($user)) { // This user has access to all groups. return true; } // This is a group discussion for a forum in separate groups mode. // Check if the user is a member. // This is the most expensive check. return groups_is_member($groupid, $user->id); }
php
public function can_access_group(stdClass $user, int $groupid) : bool { if ($this->can_access_all_groups($user)) { // This user has access to all groups. return true; } // This is a group discussion for a forum in separate groups mode. // Check if the user is a member. // This is the most expensive check. return groups_is_member($groupid, $user->id); }
[ "public", "function", "can_access_group", "(", "stdClass", "$", "user", ",", "int", "$", "groupid", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "can_access_all_groups", "(", "$", "user", ")", ")", "{", "// This user has access to all groups.", "return", "true", ";", "}", "// This is a group discussion for a forum in separate groups mode.", "// Check if the user is a member.", "// This is the most expensive check.", "return", "groups_is_member", "(", "$", "groupid", ",", "$", "user", "->", "id", ")", ";", "}" ]
Can the user access the given group? @param stdClass $user The user to check @param int $groupid The id of the group that the forum is set to @return bool
[ "Can", "the", "user", "access", "the", "given", "group?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L164-L174
212,596
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_pin_discussions
public function can_pin_discussions(stdClass $user) : bool { return $this->forum->get_type() !== 'single' && has_capability('mod/forum:pindiscussions', $this->get_context(), $user); }
php
public function can_pin_discussions(stdClass $user) : bool { return $this->forum->get_type() !== 'single' && has_capability('mod/forum:pindiscussions', $this->get_context(), $user); }
[ "public", "function", "can_pin_discussions", "(", "stdClass", "$", "user", ")", ":", "bool", "{", "return", "$", "this", "->", "forum", "->", "get_type", "(", ")", "!==", "'single'", "&&", "has_capability", "(", "'mod/forum:pindiscussions'", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "user", ")", ";", "}" ]
Can the user pin discussions in this forum? @param stdClass $user The user to check @return bool
[ "Can", "the", "user", "pin", "discussions", "in", "this", "forum?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L214-L217
212,597
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_split_discussions
public function can_split_discussions(stdClass $user) : bool { $forum = $this->get_forum(); return $forum->get_type() !== 'single' && has_capability('mod/forum:splitdiscussions', $this->get_context(), $user); }
php
public function can_split_discussions(stdClass $user) : bool { $forum = $this->get_forum(); return $forum->get_type() !== 'single' && has_capability('mod/forum:splitdiscussions', $this->get_context(), $user); }
[ "public", "function", "can_split_discussions", "(", "stdClass", "$", "user", ")", ":", "bool", "{", "$", "forum", "=", "$", "this", "->", "get_forum", "(", ")", ";", "return", "$", "forum", "->", "get_type", "(", ")", "!==", "'single'", "&&", "has_capability", "(", "'mod/forum:splitdiscussions'", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "user", ")", ";", "}" ]
Can the user split discussions in this forum? @param stdClass $user The user to check @return bool
[ "Can", "the", "user", "split", "discussions", "in", "this", "forum?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L225-L228
212,598
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.must_post_before_viewing_discussion
public function must_post_before_viewing_discussion(stdClass $user, discussion_entity $discussion) : bool { $forum = $this->get_forum(); if ($forum->get_type() === 'qanda') { // If it's a Q and A forum then the user must either have the capability to view without // posting or the user must have posted before they can view the discussion. return !has_capability('mod/forum:viewqandawithoutposting', $this->get_context(), $user) && !forum_user_has_posted($forum->get_id(), $discussion->get_id(), $user->id); } else { // No other forum types require posting before viewing. return false; } }
php
public function must_post_before_viewing_discussion(stdClass $user, discussion_entity $discussion) : bool { $forum = $this->get_forum(); if ($forum->get_type() === 'qanda') { // If it's a Q and A forum then the user must either have the capability to view without // posting or the user must have posted before they can view the discussion. return !has_capability('mod/forum:viewqandawithoutposting', $this->get_context(), $user) && !forum_user_has_posted($forum->get_id(), $discussion->get_id(), $user->id); } else { // No other forum types require posting before viewing. return false; } }
[ "public", "function", "must_post_before_viewing_discussion", "(", "stdClass", "$", "user", ",", "discussion_entity", "$", "discussion", ")", ":", "bool", "{", "$", "forum", "=", "$", "this", "->", "get_forum", "(", ")", ";", "if", "(", "$", "forum", "->", "get_type", "(", ")", "===", "'qanda'", ")", "{", "// If it's a Q and A forum then the user must either have the capability to view without", "// posting or the user must have posted before they can view the discussion.", "return", "!", "has_capability", "(", "'mod/forum:viewqandawithoutposting'", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "user", ")", "&&", "!", "forum_user_has_posted", "(", "$", "forum", "->", "get_id", "(", ")", ",", "$", "discussion", "->", "get_id", "(", ")", ",", "$", "user", "->", "id", ")", ";", "}", "else", "{", "// No other forum types require posting before viewing.", "return", "false", ";", "}", "}" ]
Is the user required to post in the discussion before they can view it? @param stdClass $user The user to check @param discussion_entity $discussion The discussion to check @return bool
[ "Is", "the", "user", "required", "to", "post", "in", "the", "discussion", "before", "they", "can", "view", "it?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L259-L271
212,599
moodle/moodle
mod/forum/classes/local/managers/capability.php
capability.can_post_in_discussion
public function can_post_in_discussion(stdClass $user, discussion_entity $discussion) : bool { $forum = $this->get_forum(); $forumrecord = $this->get_forum_record(); $discussionrecord = $this->get_discussion_record($discussion); $context = $this->get_context(); $coursemodule = $forum->get_course_module_record(); $course = $forum->get_course_record(); return forum_user_can_post($forumrecord, $discussionrecord, $user, $coursemodule, $course, $context); }
php
public function can_post_in_discussion(stdClass $user, discussion_entity $discussion) : bool { $forum = $this->get_forum(); $forumrecord = $this->get_forum_record(); $discussionrecord = $this->get_discussion_record($discussion); $context = $this->get_context(); $coursemodule = $forum->get_course_module_record(); $course = $forum->get_course_record(); return forum_user_can_post($forumrecord, $discussionrecord, $user, $coursemodule, $course, $context); }
[ "public", "function", "can_post_in_discussion", "(", "stdClass", "$", "user", ",", "discussion_entity", "$", "discussion", ")", ":", "bool", "{", "$", "forum", "=", "$", "this", "->", "get_forum", "(", ")", ";", "$", "forumrecord", "=", "$", "this", "->", "get_forum_record", "(", ")", ";", "$", "discussionrecord", "=", "$", "this", "->", "get_discussion_record", "(", "$", "discussion", ")", ";", "$", "context", "=", "$", "this", "->", "get_context", "(", ")", ";", "$", "coursemodule", "=", "$", "forum", "->", "get_course_module_record", "(", ")", ";", "$", "course", "=", "$", "forum", "->", "get_course_record", "(", ")", ";", "return", "forum_user_can_post", "(", "$", "forumrecord", ",", "$", "discussionrecord", ",", "$", "user", ",", "$", "coursemodule", ",", "$", "course", ",", "$", "context", ")", ";", "}" ]
Can the user post in this discussion? @param stdClass $user The user to check @param discussion_entity $discussion The discussion to check @return bool
[ "Can", "the", "user", "post", "in", "this", "discussion?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/managers/capability.php#L313-L322