]> git.mjollnir.org Git - moodle.git/commitdiff
Cleaned up the logic a bit
authormoodler <moodler>
Thu, 16 Jan 2003 11:57:34 +0000 (11:57 +0000)
committermoodler <moodler>
Thu, 16 Jan 2003 11:57:34 +0000 (11:57 +0000)
course/categories.php

index 63c67635822fc8b17b61a77f6ead022068fa22be..a07f95f3f0e5447b50c937575e2473b75efd55b6 100644 (file)
 
         // Peel out all the data from variable names.
         foreach ($form as $key => $val) {
-            if ($key == "new" and $val != "") {
-                $cat->name = $val;
-                if (!insert_record("course_categories", $cat)) {
-                    error("Could not insert the new category '$val'");
-                } else {
-                    notify(get_string("categoryadded", "", $val));
+            if ($key == "new") {
+                if (!empty($val)) {
+                    $cat->name = $val;
+                    if (!insert_record("course_categories", $cat)) {
+                        error("Could not insert the new category '$val'");
+                    } else {
+                        notify(get_string("categoryadded", "", $val));
+                    }
                 }
             
             } else {
-                $cat->id  = substr($key,1);
+                $cat->id   = substr($key,1);
                 $cat->name = $val;
                 if (!update_record("course_categories", $cat)) {
                     error("Could not update the category '$val'");