Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge branch 'wip-MDL-60281-master' of git://github.com/marinaglancy/…
- Loading branch information
|
@@ -267,7 +267,7 @@ private function array_merge_recursive_keep_keys() { |
|
|
|
|
|
foreach ($arrays as $array) { |
|
|
reset($base); |
|
|
while (list($key, $value) = each($array)) { |
|
|
foreach ($array as $key => $value) { |
|
|
if (is_array($value) && !empty($base[$key]) && is_array($base[$key])) { |
|
|
$base[$key] = $this->array_merge_recursive_keep_keys($base[$key], $value); |
|
|
} else { |
|
|
|
@@ -42,8 +42,9 @@ class auth_ldap_admin_setting_special_contexts_configtext extends admin_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(create_function('$x', 'return core_text::strtolower(trim($x));'), |
|
|
$data); |
|
|
$data = array_map(function($x) { |
|
|
return core_text::strtolower(trim($x)); |
|
|
}, $data); |
|
|
$data = implode(';', array_unique($data)); |
|
|
return parent::write_setting($data); |
|
|
} |
|
|
|
@@ -164,8 +164,8 @@ public function add_final_elements($final_elements) { |
|
|
} |
|
|
|
|
|
public function add_child($element) { |
|
|
if (!($element instanceof base_nested_element)) { // parameter must be a base_nested_element |
|
|
if (!$found = get_class($element)) { |
|
|
if (!is_object($element) || !($element instanceof base_nested_element)) { // parameter must be a base_nested_element |
|
|
if (!is_object($element) || !($found = get_class($element))) { |
|
|
$found = 'non object'; |
|
|
} |
|
|
throw new base_element_struct_exception('nestedelementincorrect', $found); |
|
|
|
@@ -98,7 +98,9 @@ |
|
|
} else { |
|
|
// Get all the roles that user has and use the ones required by this badge. |
|
|
$roles = get_user_roles($context, $USER->id); |
|
|
$roleids = array_map(create_function('$o', 'return $o->roleid;'), $roles); |
|
|
$roleids = array_map(function($o) { |
|
|
return $o->roleid; |
|
|
}, $roles); |
|
|
$selection = array_intersect($acceptedroles, $roleids); |
|
|
} |
|
|
|
|
|
|
@@ -383,7 +383,9 @@ public function save($params = array()) { |
|
|
$params = array_filter($params); |
|
|
// Find out which param matches optional and required ones. |
|
|
$match = array_merge($this->optional_params, array($this->required_param)); |
|
|
$regex = implode('|', array_map(create_function('$a', 'return $a . "_";'), $match)); |
|
|
$regex = implode('|', array_map(function($a) { |
|
|
return $a . "_"; |
|
|
}, $match)); |
|
|
$requiredkeys = preg_grep('/^(' . $regex . ').*$/', array_keys($params)); |
|
|
|
|
|
if ($this->id !== 0) { |
|
|
|
@@ -65,7 +65,9 @@ public function get_options(&$mform) { |
|
|
$none = true; |
|
|
|
|
|
$roles = get_roles_with_capability('moodle/badges:awardbadge', CAP_ALLOW, $PAGE->context); |
|
|
$roleids = array_map(create_function('$o', 'return $o->id;'), $roles); |
|
|
$roleids = array_map(function($o) { |
|
|
return $o->id; |
|
|
}, $roles); |
|
|
$existing = array(); |
|
|
$missing = array(); |
|
|
|
|
|
|
@@ -62,7 +62,9 @@ public function get_options(&$mform) { |
|
|
|
|
|
// Get custom fields. |
|
|
$cfields = $DB->get_records_sql($sql); |
|
|
$cfids = array_map(create_function('$o', 'return $o->fieldid;'), $cfields); |
|
|
$cfids = array_map(function($o) { |
|
|
return $o->fieldid; |
|
|
}, $cfields); |
|
|
|
|
|
if ($this->id !== 0) { |
|
|
$existing = array_keys($this->params); |
|
|
|
@@ -358,7 +358,9 @@ protected function render_issued_badge(issued_badge $ibadge) { |
|
|
// Print evidence. |
|
|
$agg = $badge->get_aggregation_methods(); |
|
|
$evidence = $badge->get_criteria_completions($userinfo->id); |
|
|
$eids = array_map(create_function('$o', 'return $o->critid;'), $evidence); |
|
|
$eids = array_map(function($o) { |
|
|
return $o->critid; |
|
|
}, $evidence); |
|
|
unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); |
|
|
|
|
|
$items = array(); |
|
|
|
@@ -289,8 +289,12 @@ public function get_content() { |
|
|
} |
|
|
|
|
|
// Sort groupgrades according to average grade, ascending. |
|
|
uasort($groupgrades, create_function('$a, $b', |
|
|
'if($a["average"] == $b["average"]) return 0; return ($a["average"] > $b["average"] ? 1 : -1);')); |
|
|
uasort($groupgrades, function($a, $b) { |
|
|
if ($a["average"] == $b["average"]) { |
|
|
return 0; |
|
|
} |
|
|
return ($a["average"] > $b["average"] ? 1 : -1); |
|
|
}); |
|
|
|
|
|
// How many groups do we have with graded member submissions to show? |
|
|
$numbest = empty($this->config->showbest) ? 0 : min($this->config->showbest, count($groupgrades)); |
|
|
|
@@ -125,9 +125,10 @@ public function delete_many(array $keys, $recurse = true) { |
|
|
* Checks if the cache has the requested key. |
|
|
* |
|
|
* @param int|string $key Unused. |
|
|
* @param bool $tryloadifpossible Unused. |
|
|
* @return bool |
|
|
*/ |
|
|
public function has($key) { |
|
|
public function has($key, $tryloadifpossible = false) { |
|
|
return false; |
|
|
} |
|
|
|
|
|
|
@@ -234,7 +234,9 @@ function cohort_get_available_cohorts($currentcontext, $withmembers = 0, $offset |
|
|
// Build context subquery. Find the list of parent context where user is able to see any or visible-only cohorts. |
|
|
// Since this method is normally called for the current course all parent contexts are already preloaded. |
|
|
$contextsany = array_filter($currentcontext->get_parent_context_ids(), |
|
|
create_function('$a', 'return has_capability("moodle/cohort:view", context::instance_by_id($a));')); |
|
|
function($a) { |
|
|
return has_capability("moodle/cohort:view", context::instance_by_id($a)); |
|
|
}); |
|
|
$contextsvisible = array_diff($currentcontext->get_parent_context_ids(), $contextsany); |
|
|
if (empty($contextsany) && empty($contextsvisible)) { |
|
|
// User does not have any permissions to view cohorts. |
|
|
|
@@ -75,6 +75,7 @@ protected function convert_urls_into_links(&$text) { |
|
|
//<a href="blah"> |
|
|
$filterignoretagsopen = array('<a\s[^>]+?>', '<span[^>]+?class="nolink"[^>]*?>'); |
|
|
$filterignoretagsclose = array('</a>', '</span>'); |
|
|
$ignoretags = []; |
|
|
filter_save_ignore_tags($text,$filterignoretagsopen,$filterignoretagsclose,$ignoretags); |
|
|
|
|
|
// Check if we support unicode modifiers in regular expressions. Cache it. |
|
|
|
@@ -1866,7 +1866,7 @@ public function post_write_settings($original) { |
|
|
} |
|
|
|
|
|
$callbackfunction = $this->updatedcallback; |
|
|
if (!empty($callbackfunction) and function_exists($callbackfunction)) { |
|
|
if (!empty($callbackfunction) and is_callable($callbackfunction)) { |
|
|
$callbackfunction($this->get_full_name()); |
|
|
} |
|
|
return true; |
|
@@ -5206,8 +5206,9 @@ public function __construct() { |
|
|
parent::__construct('coursecontact', get_string('coursecontact', 'admin'), |
|
|
get_string('coursecontact_desc', 'admin'), |
|
|
array('editingteacher')); |
|
|
$this->set_updatedcallback(create_function('', |
|
|
"cache::make('core', 'coursecontacts')->purge();")); |
|
|
$this->set_updatedcallback(function (){ |
|
|
cache::make('core', 'coursecontacts')->purge(); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
@@ -141,15 +141,9 @@ public function matches($expectedvalue) { |
|
|
$values = $this->get_selected_options(false); |
|
|
$selectedoptionvalues = $this->get_unescaped_options($values); |
|
|
|
|
|
// Precheck to speed things up. |
|
|
if (count($expectedoptions) !== count($selectedoptiontexts) || |
|
|
count($expectedoptions) !== count($selectedoptionvalues)) { |
|
|
return false; |
|
|
} |
|
|
|
|
|
// We check against string-ordered lists of options. |
|
|
if ($expectedoptions != $selectedoptiontexts && |
|
|
$expectedoptions != $selectedoptionvalues) { |
|
|
if ($expectedoptions !== $selectedoptiontexts && |
|
|
$expectedoptions !== $selectedoptionvalues) { |
|
|
return false; |
|
|
} |
|
|
|
|
|
|
@@ -560,8 +560,12 @@ public static function entities_to_utf8($str, $htmlent=true) { |
|
|
static $callback2 = null ; |
|
|
|
|
|
if (!$callback1 or !$callback2) { |
|
|
$callback1 = create_function('$matches', 'return core_text::code2utf8(hexdec($matches[1]));'); |
|
|
$callback2 = create_function('$matches', 'return core_text::code2utf8($matches[1]);'); |
|
|
$callback1 = function($matches) { |
|
|
return core_text::code2utf8(hexdec($matches[1])); |
|
|
}; |
|
|
$callback2 = function($matches) { |
|
|
return core_text::code2utf8($matches[1]); |
|
|
}; |
|
|
} |
|
|
|
|
|
$result = (string)$str; |
|
@@ -600,7 +604,9 @@ public static function utf8_to_entities($str, $dec=false, $nonnum=false) { |
|
|
|
|
|
if ($dec) { |
|
|
if (!$callback) { |
|
|
$callback = create_function('$matches', 'return \'&#\'.(hexdec($matches[1])).\';\';'); |
|
|
$callback = function($matches) { |
|
|
return '&#' . hexdec($matches[1]) . ';'; |
|
|
}; |
|
|
} |
|
|
$result = preg_replace_callback('/&#x([0-9a-f]+);/i', $callback, $result); |
|
|
} |
|
|
|
@@ -1794,7 +1794,9 @@ public function sql_intersect($selects, $fields) { |
|
|
$rv .= " JOIN (".$selects[$i].") $alias ON ". |
|
|
join(' AND ', |
|
|
array_map( |
|
|
create_function('$a', 'return "'.$falias.'.$a = '.$alias.'.$a";'), |
|
|
function($a) use ($alias, $falias) { |
|
|
return $falias . '.' . $a .' = ' . $alias . '.' . $a; |
|
|
}, |
|
|
preg_split('/,/', $fields)) |
|
|
); |
|
|
} |
|
|
|
@@ -2341,7 +2341,9 @@ function qf_errorHandler(element, _qfMsg, escapedName) { |
|
|
//end of fix |
|
|
$escapedElementName = preg_replace_callback( |
|
|
'/[_\[\]-]/', |
|
|
create_function('$matches', 'return sprintf("_%2x",ord($matches[0]));'), |
|
|
function($matches) { |
|
|
return sprintf("_%2x", ord($matches[0])); |
|
|
}, |
|
|
$elementName); |
|
|
$valFunc = 'validate_' . $this->_formName . '_' . $escapedElementName . '(ev.target, \''.$escapedElementName.'\')'; |
|
|
|
|
|
|
@@ -2359,8 +2359,10 @@ function get_user_timezone($tz = 99) { |
|
|
$tz = 99; |
|
|
|
|
|
// Loop while $tz is, empty but not zero, or 99, and there is another timezone is the array. |
|
|
while (((empty($tz) && !is_numeric($tz)) || $tz == 99) && $next = each($timezones)) { |
|
|
$tz = $next['value']; |
|
|
foreach ($timezones as $nextvalue) { |
|
|
if ((empty($tz) && !is_numeric($tz)) || $tz == 99) { |
|
|
$tz = $nextvalue; |
|
|
} |
|
|
} |
|
|
return is_numeric($tz) ? (float) $tz : $tz; |
|
|
} |
|
|
|
@@ -843,7 +843,7 @@ public function action() { |
|
|
* @copyright 2010 Sam Hemelryk |
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
|
*/ |
|
|
class navigation_node_collection implements IteratorAggregate { |
|
|
class navigation_node_collection implements IteratorAggregate, Countable { |
|
|
/** |
|
|
* A multidimensional array to where the first key is the type and the second |
|
|
* key is the nodes key. |
|
|
|
@@ -2640,7 +2640,7 @@ class html_table { |
|
|
* $row2->cells = array($cell2, $cell3); |
|
|
* $t->data = array($row1, $row2); |
|
|
*/ |
|
|
public $data; |
|
|
public $data = []; |
|
|
|
|
|
/** |
|
|
* @deprecated since Moodle 2.0. Styling should be in the CSS. |
|
|
|
@@ -71,13 +71,16 @@ function _findOperator($name) |
|
|
function validate($values, $operator = null) |
|
|
{ |
|
|
$operator = $this->_findOperator($operator); |
|
|
if ('==' != $operator && '!=' != $operator) { |
|
|
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);'); |
|
|
$a = $values[0]; |
|
|
$b = $values[1]; |
|
|
if ($operator == '==') { |
|
|
return $a == $b; |
|
|
} else if ($operator == '!=') { |
|
|
return $a != $b; |
|
|
} else { |
|
|
$compareFn = create_function('$a, $b', 'return $a ' . $operator . ' $b;'); |
|
|
// One of: <= , >= , < , > . |
|
|
return eval('return ' . floatval($a) . $operator . floatval($b) . ';'); |
|
|
} |
|
|
|
|
|
return $compareFn($values[0], $values[1]); |
|
|
} |
|
|
|
|
|
|
|
|
|
@@ -351,14 +351,18 @@ function _createElements() |
|
|
$this->_options['maxYear'], |
|
|
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1 |
|
|
); |
|
|
array_walk($options, create_function('&$v,$k','$v = substr($v,-2);')); |
|
|
array_walk($options, function(&$v, $k) { |
|
|
$v = substr($v, -2); |
|
|
}); |
|
|
break; |
|
|
case 'h': |
|
|
$options = $this->_createOptionList(1, 12); |
|
|
break; |
|
|
case 'g': |
|
|
$options = $this->_createOptionList(1, 12); |
|
|
array_walk($options, create_function('&$v,$k', '$v = intval($v);')); |
|
|
array_walk($options, function(&$v, $k) { |
|
|
$v = intval($v); |
|
|
}); |
|
|
break; |
|
|
case 'H': |
|
|
$options = $this->_createOptionList(0, 23); |
|
|
|
@@ -759,7 +759,7 @@ function _PEAR_call_destructors() |
|
|
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); |
|
|
} |
|
|
|
|
|
while (list($k, $objref) = each($_PEAR_destructor_object_list)) { |
|
|
foreach ($_PEAR_destructor_object_list as $k => $objref) { |
|
|
$classname = get_class($objref); |
|
|
while ($classname) { |
|
|
$destructor = "_$classname"; |
|
|
|
@@ -32,12 +32,15 @@ MDL-52826 - Remove onsubmit events pointing to the global validation functions a |
|
|
tag moved after the HTML |
|
|
MDL-50484 - _getPersistantData() returns id with _persistant prefixed to element id. |
|
|
MDL-55123 - corrected call to non-static functions in HTML_QuickForm to be PHP7.1-compliant |
|
|
MDL-60281 - replaced deprecated create_function() with lambda functions for PHP7.2 compatibility |
|
|
|
|
|
|
|
|
Pear |
|
|
==== |
|
|
Changed constructors in classes PEAR and PEAR_ERROR to be __construct(). This has |
|
|
been already changed upstream in 1.10.0, remove this line after upgrade. |
|
|
It was decided that we will not upgrade this library from upstream any more, see MDL-52465 |
|
|
|
|
|
Changed constructors in classes PEAR and PEAR_ERROR to be __construct(). |
|
|
MDL-60281 - replaced deprecated function each() with foreach loop for PHP7.2 compatibility |
|
|
|
|
|
|
|
|
Crypt/CHAP |
|
|
|
@@ -73,7 +73,7 @@ public static function assertTag($matcher, $actual, $message = '', $ishtml = tru |
|
|
public static function assertNotTag($matcher, $actual, $message = '', $ishtml = true) { |
|
|
$dom = PHPUnit_Util_XML::load($actual, $ishtml); |
|
|
$tags = self::findNodes($dom, $matcher, $ishtml); |
|
|
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode; |
|
|
$matched = (is_array($tags) && count($tags) > 0) && $tags[0] instanceof DOMNode; |
|
|
self::assertFalse($matched, $message); |
|
|
} |
|
|
|
|
|
|
@@ -51,27 +51,6 @@ |
|
|
/** Extremely large memory limit - not recommended for standard scripts */ |
|
|
define('MEMORY_HUGE', -4); |
|
|
|
|
|
|
|
|
/** |
|
|
* Simple class. It is usually used instead of stdClass because it looks |
|
|
* more familiar to Java developers ;-) Do not use for type checking of |
|
|
* function parameters. Please use stdClass instead. |
|
|
* |
|
|
* @package core |
|
|
* @subpackage lib |
|
|
* @copyright 2009 Petr Skoda {@link http://skodak.org} |
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
|
* @deprecated since 2.0 |
|
|
*/ |
|
|
class object extends stdClass { |
|
|
/** |
|
|
* Constructor. |
|
|
*/ |
|
|
public function __construct() { |
|
|
debugging("'object' class has been deprecated, please use stdClass instead.", DEBUG_DEVELOPER); |
|
|
} |
|
|
}; |
|
|
|
|
|
/** |
|
|
* Base Moodle Exception class |
|
|
* |
|
@@ -1122,7 +1101,9 @@ function workaround_max_input_vars() { |
|
|
} |
|
|
|
|
|
$delim = '&'; |
|
|
$fun = create_function('$p', 'return implode("'.$delim.'", $p);'); |
|
|
$fun = function($p) use ($delim) { |
|
|
return implode($delim, $p); |
|
|
}; |
|
|
$chunks = array_map($fun, array_chunk(explode($delim, $str), $max)); |
|
|
|
|
|
// Clear everything from existing $_POST array, otherwise it might be included |
|
|
|
@@ -469,12 +469,6 @@ public function get_exception_info($ex) { |
|
|
} |
|
|
} |
|
|
|
|
|
public function test_object() { |
|
|
$obj = new object(); |
|
|
$this->assertDebuggingCalled("'object' class has been deprecated, please use stdClass instead."); |
|
|
$this->assertInstanceOf('stdClass', $obj); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Data provider for test_get_real_size(). |
|
|
* |
|
|
|
@@ -954,7 +954,7 @@ function mput($filelist) { |
|
|
|
|
|
$result = true; |
|
|
|
|
|
while (list($localpath, $destpath) = each($filelist)) { |
|
|
foreach ($filelist as $localpath => $destpath) { |
|
|
|
|
|
$localpath = rtrim($localpath, "/"); |
|
|
$destpath = rtrim($destpath, "/"); |
|
@@ -1011,7 +1011,7 @@ function mget($filelist) { |
|
|
|
|
|
$result = true; |
|
|
|
|
|
while (list($remotepath, $localpath) = each($filelist)) { |
|
|
foreach ($filelist as $remotepath => $localpath) { |
|
|
|
|
|
$localpath = rtrim($localpath, "/"); |
|
|
$remotepath = rtrim($remotepath, "/"); |
|
|
Oops, something went wrong.