From: ikawhero Date: Fri, 12 Jan 2007 06:48:05 +0000 (+0000) Subject: Can delete last profile category if there are no fields in it. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=eed54b48404341e908ad8eb95d17778cccc312f7;p=moodle.git Can delete last profile category if there are no fields in it. --- diff --git a/user/profile/lib.php b/user/profile/lib.php index 03183adf25..f409ac615a 100644 --- a/user/profile/lib.php +++ b/user/profile/lib.php @@ -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; + } } }