Exemplo n.º 1
0
function cr_make_categories_list(&$list, &$parents, $requiredcapability = '', $excludeid = 0, $category = NULL, $path = "")
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/coursecatlib.php';
    // For categories list use just this one function:
    if (empty($list)) {
        $list = array();
    }
    $list += coursecat::cr_make_categories_list($requiredcapability, $excludeid);
    // Building the list of all parents of all categories in the system is highly undesirable and hardly ever needed.
    // Usually user needs only parents for one particular category, in which case should be used:
    // coursecat::get($categoryid)->get_parents()
    if (empty($parents)) {
        $parents = array();
    }
    $all = $DB->get_records_sql('SELECT id, parent FROM {course_categories} ORDER BY sortorder');
    foreach ($all as $record) {
        if ($record->parent) {
            $parents[$record->id] = array_merge($parents[$record->parent], array($record->parent));
        } else {
            $parents[$record->id] = array();
        }
    }
}