mirror of
https://github.com/moodle/moodle.git
synced 2025-06-03 14:46:35 +02:00
MDL-35198 replace key_exists by array_key_exists
This commit is contained in:
parent
a3ab18c735
commit
12fc8acf5b
@ -97,7 +97,7 @@ $usersmissingcaps = $webservicemanager->get_missing_capabilities_by_users($allow
|
||||
|
||||
//add the missing capabilities to the allowed users object to be displayed by renderer
|
||||
foreach ($allowedusers as &$alloweduser) {
|
||||
if (!is_siteadmin($alloweduser->id) and key_exists($alloweduser->id, $usersmissingcaps)) {
|
||||
if (!is_siteadmin($alloweduser->id) and array_key_exists($alloweduser->id, $usersmissingcaps)) {
|
||||
$alloweduser->missingcapabilities = implode(', ', $usersmissingcaps[$alloweduser->id]);
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ class community_hub_search_form extends moodleform {
|
||||
$options = array();
|
||||
$firsthub = false;
|
||||
foreach ($hubs as $hub) {
|
||||
if (key_exists('id', $hub)) {
|
||||
if (array_key_exists('id', $hub)) {
|
||||
$params = array('hubid' => $hub['id'],
|
||||
'filetype' => HUB_HUBSCREENSHOT_FILE_TYPE);
|
||||
$imgurl = new moodle_url(HUB_HUBDIRECTORYURL .
|
||||
|
@ -285,7 +285,7 @@ class core_course_external extends external_api {
|
||||
array('options' => $options));
|
||||
|
||||
//retrieve courses
|
||||
if (!key_exists('ids', $params['options'])
|
||||
if (!array_key_exists('ids', $params['options'])
|
||||
or empty($params['options']['ids'])) {
|
||||
$courses = $DB->get_records('course');
|
||||
} else {
|
||||
@ -523,12 +523,12 @@ class core_course_external extends external_api {
|
||||
require_capability('moodle/course:create', $context);
|
||||
|
||||
// Make sure lang is valid
|
||||
if (key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
|
||||
if (array_key_exists('lang', $course) and empty($availablelangs[$course['lang']])) {
|
||||
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'lang');
|
||||
}
|
||||
|
||||
// Make sure theme is valid
|
||||
if (key_exists('forcetheme', $course)) {
|
||||
if (array_key_exists('forcetheme', $course)) {
|
||||
if (!empty($CFG->allowcoursethemes)) {
|
||||
if (empty($availablethemes[$course['forcetheme']])) {
|
||||
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'forcetheme');
|
||||
@ -547,10 +547,10 @@ class core_course_external extends external_api {
|
||||
//set default value for completion
|
||||
$courseconfig = get_config('moodlecourse');
|
||||
if (completion_info::is_enabled_for_site()) {
|
||||
if (!key_exists('enablecompletion', $course)) {
|
||||
if (!array_key_exists('enablecompletion', $course)) {
|
||||
$course['enablecompletion'] = $courseconfig->enablecompletion;
|
||||
}
|
||||
if (!key_exists('completionstartonenrol', $course)) {
|
||||
if (!array_key_exists('completionstartonenrol', $course)) {
|
||||
$course['completionstartonenrol'] = $courseconfig->completionstartonenrol;
|
||||
}
|
||||
} else {
|
||||
|
@ -388,7 +388,7 @@ class core_role_external extends external_api {
|
||||
// throw an exception if user is not able to assign the role in this context
|
||||
$roles = get_assignable_roles($context, ROLENAME_SHORT);
|
||||
|
||||
if (!key_exists($assignment['roleid'], $roles)) {
|
||||
if (!array_key_exists($assignment['roleid'], $roles)) {
|
||||
throw new invalid_parameter_exception('Can not assign roleid='.$assignment['roleid'].' in contextid='.$assignment['contextid']);
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ class core_role_external extends external_api {
|
||||
|
||||
// throw an exception if user is not able to unassign the role in this context
|
||||
$roles = get_assignable_roles($context, ROLENAME_SHORT);
|
||||
if (!key_exists($unassignment['roleid'], $roles)) {
|
||||
if (!array_key_exists($unassignment['roleid'], $roles)) {
|
||||
throw new invalid_parameter_exception('Can not unassign roleid='.$unassignment['roleid'].' in contextid='.$unassignment['contextid']);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class enrol_manual_external extends external_api {
|
||||
|
||||
// Throw an exception if user is not able to assign the role.
|
||||
$roles = get_assignable_roles($context);
|
||||
if (!key_exists($enrolment['roleid'], $roles)) {
|
||||
if (!array_key_exists($enrolment['roleid'], $roles)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->roleid = $enrolment['roleid'];
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
|
@ -7632,7 +7632,7 @@ class admin_setting_managewebservicetokens extends admin_setting {
|
||||
array(array('id' => $token->userid)), $token->serviceid);
|
||||
|
||||
if (!is_siteadmin($token->userid) and
|
||||
key_exists($token->userid, $usermissingcaps)) {
|
||||
array_key_exists($token->userid, $usermissingcaps)) {
|
||||
$missingcapabilities = implode(', ',
|
||||
$usermissingcaps[$token->userid]);
|
||||
if (!empty($missingcapabilities)) {
|
||||
|
@ -966,7 +966,7 @@ function external_update_descriptions($component) {
|
||||
$dbfunction->classpath = $function['classpath'];
|
||||
$update = true;
|
||||
}
|
||||
$functioncapabilities = key_exists('capabilities', $function)?$function['capabilities']:'';
|
||||
$functioncapabilities = array_key_exists('capabilities', $function)?$function['capabilities']:'';
|
||||
if ($dbfunction->capabilities != $functioncapabilities) {
|
||||
$dbfunction->capabilities = $functioncapabilities;
|
||||
$update = true;
|
||||
@ -982,7 +982,7 @@ function external_update_descriptions($component) {
|
||||
$dbfunction->methodname = $function['methodname'];
|
||||
$dbfunction->classpath = empty($function['classpath']) ? null : $function['classpath'];
|
||||
$dbfunction->component = $component;
|
||||
$dbfunction->capabilities = key_exists('capabilities', $function)?$function['capabilities']:'';
|
||||
$dbfunction->capabilities = array_key_exists('capabilities', $function)?$function['capabilities']:'';
|
||||
$dbfunction->id = $DB->insert_record('external_functions', $dbfunction);
|
||||
}
|
||||
unset($functions);
|
||||
|
@ -564,7 +564,7 @@ class webservice {
|
||||
//detect the missing capabilities
|
||||
foreach ($servicecaps as $functioname => $functioncaps) {
|
||||
foreach ($functioncaps as $functioncap) {
|
||||
if (!key_exists($functioncap, $usercaps)) {
|
||||
if (!array_key_exists($functioncap, $usercaps)) {
|
||||
if (!isset($usersmissingcaps[$user->id])
|
||||
or array_search($functioncap, $usersmissingcaps[$user->id]) === false) {
|
||||
$usersmissingcaps[$user->id][] = $functioncap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user