]> git.mjollnir.org Git - moodle.git/commitdiff
improved coding style
authorskodak <skodak>
Thu, 21 Sep 2006 23:15:45 +0000 (23:15 +0000)
committerskodak <skodak>
Thu, 21 Sep 2006 23:15:45 +0000 (23:15 +0000)
admin/roles/manage.php

index af8728f133ea7564004e229d120335213f694175..bdb61b5ec7b55238b0cfab6ec5ec6bafcb6e58ef 100755 (executable)
@@ -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;
                     }
 
                 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)) {
                     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;
                     }
                     }
                 }
 
-                // update normal role settings
-
                 if (empty($errors)) {
+                    // update normal role settings
                     $role->id = $roleid;
                     $role->name = $name;
                     $role->description = $description;