本文整理汇总了PHP中coursecat::cr_make_categories_list方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::cr_make_categories_list方法的具体用法?PHP coursecat::cr_make_categories_list怎么用?PHP coursecat::cr_make_categories_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coursecat
的用法示例。
在下文中一共展示了coursecat::cr_make_categories_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cr_make_categories_list
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();
}
}
}