]> git.mjollnir.org Git - moodle.git/commitdiff
Can delete last profile category if there are no fields in it.
authorikawhero <ikawhero>
Fri, 12 Jan 2007 06:48:05 +0000 (06:48 +0000)
committerikawhero <ikawhero>
Fri, 12 Jan 2007 06:48:05 +0000 (06:48 +0000)
user/profile/lib.php

index 03183adf2562f96b384fb520831280ed783e68a1..f409ac615a2149a53167ba25b4100ff19365c0df 100644 (file)
@@ -578,10 +578,14 @@ function profile_delete_category ($id) {
         /// Retrieve the next category down
         if (!($newcategory = get_record('user_info_category', 'sortorder', ($category->sortorder + 1))) ) {
 
-            /// We cannot find any other categories next to current one:
-            /// 1. The sortorder values are incongruous which means a bug somewhere
-            /// 2. We are the only category => cannot delete this category!
-            return false;
+            if (count_records('user_info_field', 'categoryid', $category->id) > 0) {
+
+                /// We cannot find any other categories next to current one so either:
+                /// 1. The sortorder values are incongruous which means a bug somewhere
+                /// 2. We are the only category but there are fields  => cannot delete this category!
+                
+                return false;
+            }
         }
     }