From: skodak Date: Thu, 21 Sep 2006 23:15:45 +0000 (+0000) Subject: improved coding style X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0c88b9acf7c87036c02b192bbfd6b6d4923cb914;p=moodle.git improved coding style --- diff --git a/admin/roles/manage.php b/admin/roles/manage.php index af8728f133..bdb61b5ec7 100755 --- a/admin/roles/manage.php +++ b/admin/roles/manage.php @@ -76,7 +76,7 @@ if (!preg_match('|^[a-z_]+/[a-z_]+:[a-z_]+$|', $capname)) { continue; } - $value = (int)$value; + $value = clean_param($value, PARAM_INT); if (!in_array($value, $allowed_values)) { continue; } @@ -100,23 +100,19 @@ if (empty($name)) { $errors['name'] = get_string('errorbadrolename', 'role'); - } else { - if ($rs = get_records('role', 'name', $name)) { - unset($rs[$roleid]); - if (!empty($rs)) { - $errors['name'] = get_string('errorexistsrolename', 'role'); - } + } else if ($rs = get_records('role', 'name', $name)) { + unset($rs[$roleid]); + if (!empty($rs)) { + $errors['name'] = get_string('errorexistsrolename', 'role'); } } if (empty($shortname)) { $errors['shortname'] = get_string('errorbadroleshortname', 'role'); - } else { - if ($rs = get_records('role', 'shortname', $shortname)) { - unset($rs[$roleid]); - if (!empty($rs)) { - $errors['shortname'] = get_string('errorexistsroleshortname', 'role'); - } + } else if ($rs = get_records('role', 'shortname', $shortname)) { + unset($rs[$roleid]); + if (!empty($rs)) { + $errors['shortname'] = get_string('errorexistsroleshortname', 'role'); } } if (!empty($errors)) { @@ -132,7 +128,7 @@ if (!preg_match('|^[a-z_]+/[a-z_]+:[a-z_]+$|', $capname)) { continue; } - $value = (int)$value; + $value = clean_param($value, PARAM_INT); if (!in_array($value, $allowed_values)) { continue; } @@ -164,9 +160,8 @@ } } - // update normal role settings - if (empty($errors)) { + // update normal role settings $role->id = $roleid; $role->name = $name; $role->description = $description;