MDL-38147 deprecated get_all_subcategories()
authorMarina Glancy <marina@moodle.com>
Thu, 21 Feb 2013 23:45:07 +0000 (10:45 +1100)
committerMarina Glancy <marina@moodle.com>
Mon, 25 Mar 2013 02:22:38 +0000 (13:22 +1100)
lib/datalib.php
lib/deprecatedlib.php
lib/upgrade.txt

index f75be8d..f5baf90 100644 (file)
@@ -1003,29 +1003,6 @@ function get_categories($parent='none', $sort=NULL, $shallow=true) {
     return $categories;
 }
 
-
-/**
- * Returns an array of category ids of all the subcategories for a given
- * category.
- *
- * @global object
- * @param int $catid - The id of the category whose subcategories we want to find.
- * @return array of category ids.
- */
-function get_all_subcategories($catid) {
-    global $DB;
-
-    $subcats = array();
-
-    if ($categories = $DB->get_records('course_categories', array('parent'=>$catid))) {
-        foreach ($categories as $cat) {
-            array_push($subcats, $cat->id);
-            $subcats = array_merge($subcats, get_all_subcategories($cat->id));
-        }
-    }
-    return $subcats;
-}
-
 /**
  * Fixes course category and course sortorder, also verifies category and course parents and paths.
  * (circular references are not fixed)
index 816edd4..a242c52 100644 (file)
@@ -3704,3 +3704,40 @@ function create_course_category($category) {
 
     return $category;
 }
+
+/**
+ * Returns an array of category ids of all the subcategories for a given
+ * category.
+ *
+ * This function is deprecated.
+ *
+ * To get visible children categories of the given category use:
+ * coursecat::get($categoryid)->get_children();
+ * This function will return the array or coursecat objects, on each of them
+ * you can call get_children() again
+ *
+ * @see coursecat::get()
+ * @see coursecat::get_children()
+ *
+ * @deprecated since 2.5
+ *
+ * @global object
+ * @param int $catid - The id of the category whose subcategories we want to find.
+ * @return array of category ids.
+ */
+function get_all_subcategories($catid) {
+    global $DB;
+
+    debugging('Function get_all_subcategories() is deprecated. Please use appropriate methods() of coursecat class. See phpdocs for more details',
+            DEBUG_DEVELOPER);
+
+    $subcats = array();
+
+    if ($categories = $DB->get_records('course_categories', array('parent' => $catid))) {
+        foreach ($categories as $cat) {
+            array_push($subcats, $cat->id);
+            $subcats = array_merge($subcats, get_all_subcategories($cat->id));
+        }
+    }
+    return $subcats;
+}
index 6ca9915..8922eb8 100644 (file)
@@ -37,7 +37,7 @@ information provided here is intended especially for developers.
 * Functions responsible for managing and accessing course categories are moved to class coursecat
   in lib/coursecatlib.php. The following global functions are deprecated: make_categories_list(),
   category_delete_move(), category_delete_full(), move_category(), course_category_hide(),
-  course_category_show(), get_course_category(), create_course_category()
+  course_category_show(), get_course_category(), create_course_category(), get_all_subcategories()
 
 YUI changes:
 * M.util.help_icon has been deprecated. Code should be updated to use moodle-core-popuphelp