Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-35198 replace key_exists by array_key_exists

  • Loading branch information...
commit 71daa4a6d678dab1822ad7d54ade02158e706641 1 parent f9a8571
Jérôme Mouneyrac mouneyrac authored
2  admin/webservice/service_users.php
@@ -97,7 +97,7 @@
97 97
98 98 //add the missing capabilities to the allowed users object to be displayed by renderer
99 99 foreach ($allowedusers as &$alloweduser) {
100   - if (!is_siteadmin($alloweduser->id) and key_exists($alloweduser->id, $usersmissingcaps)) {
  100 + if (!is_siteadmin($alloweduser->id) and array_key_exists($alloweduser->id, $usersmissingcaps)) {
101 101 $alloweduser->missingcapabilities = implode(', ', $usersmissingcaps[$alloweduser->id]);
102 102 }
103 103 }
2  blocks/community/forms.php
@@ -140,7 +140,7 @@ public function definition() {
140 140 $options = array();
141 141 $firsthub = false;
142 142 foreach ($hubs as $hub) {
143   - if (key_exists('id', $hub)) {
  143 + if (array_key_exists('id', $hub)) {
144 144 $params = array('hubid' => $hub['id'],
145 145 'filetype' => HUB_HUBSCREENSHOT_FILE_TYPE);
146 146 $imgurl = new moodle_url(HUB_HUBDIRECTORYURL .
10 course/externallib.php
@@ -267,7 +267,7 @@ public static function get_courses($options = array()) {
267 267 array('options' => $options));
268 268
269 269 //retrieve courses
270   - if (!key_exists('ids', $params['options'])
  270 + if (!array_key_exists('ids', $params['options'])
271 271 or empty($params['options']['ids'])) {
272 272 $courses = $DB->get_records('course');
273 273 } else {
@@ -504,13 +504,13 @@ public static function create_courses($courses) {
504 504 require_capability('moodle/course:create', $context);
505 505
506 506 // Make sure lang is valid
507   - if (key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
  507 + if (array_key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
508 508 throw new moodle_exception(
509 509 get_string('errorinvalidparam', 'webservice', 'lang'));
510 510 }
511 511
512 512 // Make sure theme is valid
513   - if (key_exists('forcetheme', $course)) {
  513 + if (array_key_exists('forcetheme', $course)) {
514 514 if (!empty($CFG->allowcoursethemes)) {
515 515 if (empty($availablethemes[$course['forcetheme']])) {
516 516 throw new moodle_exception(
@@ -530,10 +530,10 @@ public static function create_courses($courses) {
530 530 //set default value for completion
531 531 $courseconfig = get_config('moodlecourse');
532 532 if (completion_info::is_enabled_for_site()) {
533   - if (!key_exists('enablecompletion', $course)) {
  533 + if (!array_key_exists('enablecompletion', $course)) {
534 534 $course['enablecompletion'] = $courseconfig->enablecompletion;
535 535 }
536   - if (!key_exists('completionstartonenrol', $course)) {
  536 + if (!array_key_exists('completionstartonenrol', $course)) {
537 537 $course['completionstartonenrol'] = $courseconfig->completionstartonenrol;
538 538 }
539 539 } else {
4 enrol/externallib.php
@@ -371,7 +371,7 @@ public static function assign_roles($assignments) {
371 371 // throw an exception if user is not able to assign the role in this context
372 372 $roles = get_assignable_roles($context, ROLENAME_SHORT);
373 373
374   - if (!key_exists($assignment['roleid'], $roles)) {
  374 + if (!array_key_exists($assignment['roleid'], $roles)) {
375 375 throw new invalid_parameter_exception('Can not assign roleid='.$assignment['roleid'].' in contextid='.$assignment['contextid']);
376 376 }
377 377
@@ -433,7 +433,7 @@ public static function unassign_roles($unassignments) {
433 433
434 434 // throw an exception if user is not able to unassign the role in this context
435 435 $roles = get_assignable_roles($context, ROLENAME_SHORT);
436   - if (!key_exists($unassignment['roleid'], $roles)) {
  436 + if (!array_key_exists($unassignment['roleid'], $roles)) {
437 437 throw new invalid_parameter_exception('Can not unassign roleid='.$unassignment['roleid'].' in contextid='.$unassignment['contextid']);
438 438 }
439 439
2  enrol/manual/externallib.php
@@ -90,7 +90,7 @@ public static function enrol_users($enrolments) {
90 90
91 91 //throw an exception if user is not able to assign the role
92 92 $roles = get_assignable_roles($context);
93   - if (!key_exists($enrolment['roleid'], $roles)) {
  93 + if (!array_key_exists($enrolment['roleid'], $roles)) {
94 94 $errorparams = new stdClass();
95 95 $errorparams->roleid = $enrolment['roleid'];
96 96 $errorparams->courseid = $enrolment['courseid'];
2  lib/adminlib.php
@@ -7584,7 +7584,7 @@ public function output_html($data, $query='') {
7584 7584 array(array('id' => $token->userid)), $token->serviceid);
7585 7585
7586 7586 if (!is_siteadmin($token->userid) and
7587   - key_exists($token->userid, $usermissingcaps)) {
  7587 + array_key_exists($token->userid, $usermissingcaps)) {
7588 7588 $missingcapabilities = implode(', ',
7589 7589 $usermissingcaps[$token->userid]);
7590 7590 if (!empty($missingcapabilities)) {
4 lib/upgradelib.php
@@ -877,7 +877,7 @@ function external_update_descriptions($component) {
877 877 $dbfunction->classpath = $function['classpath'];
878 878 $update = true;
879 879 }
880   - $functioncapabilities = key_exists('capabilities', $function)?$function['capabilities']:'';
  880 + $functioncapabilities = array_key_exists('capabilities', $function)?$function['capabilities']:'';
881 881 if ($dbfunction->capabilities != $functioncapabilities) {
882 882 $dbfunction->capabilities = $functioncapabilities;
883 883 $update = true;
@@ -893,7 +893,7 @@ function external_update_descriptions($component) {
893 893 $dbfunction->methodname = $function['methodname'];
894 894 $dbfunction->classpath = empty($function['classpath']) ? null : $function['classpath'];
895 895 $dbfunction->component = $component;
896   - $dbfunction->capabilities = key_exists('capabilities', $function)?$function['capabilities']:'';
  896 + $dbfunction->capabilities = array_key_exists('capabilities', $function)?$function['capabilities']:'';
897 897 $dbfunction->id = $DB->insert_record('external_functions', $dbfunction);
898 898 }
899 899 unset($functions);
2  webservice/lib.php
@@ -511,7 +511,7 @@ public function get_missing_capabilities_by_users($users, $serviceid) {
511 511 //detect the missing capabilities
512 512 foreach ($servicecaps as $functioname => $functioncaps) {
513 513 foreach ($functioncaps as $functioncap) {
514   - if (!key_exists($functioncap, $usercaps)) {
  514 + if (!array_key_exists($functioncap, $usercaps)) {
515 515 if (!isset($usersmissingcaps[$user->id])
516 516 or array_search($functioncap, $usersmissingcaps[$user->id]) === false) {
517 517 $usersmissingcaps[$user->id][] = $functioncap;
6 webservice/simpletest/testwebservice.php
@@ -448,15 +448,15 @@ function moodle_course_get_courses($client) {
448 448 $dbcourses[$course['id']]->timecreated);
449 449 $this->assertEqual($course['timemodified'],
450 450 $dbcourses[$course['id']]->timemodified);
451   - if (key_exists('enablecompletion', $course)) {
  451 + if (array_key_exists('enablecompletion', $course)) {
452 452 $this->assertEqual($course['enablecompletion'],
453 453 $dbcourses[$course['id']]->enablecompletion);
454 454 }
455   - if (key_exists('completionstartonenrol', $course)) {
  455 + if (array_key_exists('completionstartonenrol', $course)) {
456 456 $this->assertEqual($course['completionstartonenrol'],
457 457 $dbcourses[$course['id']]->completionstartonenrol);
458 458 }
459   - if (key_exists('completionnotify', $course)) {
  459 + if (array_key_exists('completionnotify', $course)) {
460 460 $this->assertEqual($course['completionnotify'],
461 461 $dbcourses[$course['id']]->completionnotify);
462 462 }

0 comments on commit 71daa4a

Please sign in to comment.
Something went wrong with that request. Please try again.