本文整理汇总了PHP中course_category_hide函数的典型用法代码示例。如果您正苦于以下问题:PHP course_category_hide函数的具体用法?PHP course_category_hide怎么用?PHP course_category_hide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了course_category_hide函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: require_capability
if (!empty($move) and $moveto >= 0 and confirm_sesskey()) {
if ($cattomove = $DB->get_record('course_categories', array('id' => $move))) {
require_capability('moodle/category:manage', get_category_or_system_context($cattomove->parent));
if ($cattomove->parent != $moveto) {
$newparent = $DB->get_record('course_categories', array('id' => $moveto));
require_capability('moodle/category:manage', get_category_or_system_context($moveto));
move_category($cattomove, $newparent);
}
}
}
/// Hide or show a category
if ($hide and confirm_sesskey()) {
if ($tempcat = $DB->get_record('course_categories', array('id' => $hide))) {
require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent));
if ($tempcat->visible == 1) {
course_category_hide($tempcat);
}
}
} else {
if ($show and confirm_sesskey()) {
if ($tempcat = $DB->get_record('course_categories', array('id' => $show))) {
require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent));
if ($tempcat->visible == 0) {
course_category_show($tempcat);
}
}
}
}
/// Move a category up or down
if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) {
fix_course_sortorder();
示例2: move_category
/**
* Efficiently moves a category - NOTE that this can have
* a huge impact access-control-wise...
*/
function move_category($category, $newparentcat)
{
global $CFG, $DB;
$context = get_context_instance(CONTEXT_COURSECAT, $category->id);
$hidecat = false;
if (empty($newparentcat->id)) {
$DB->set_field('course_categories', 'parent', 0, array('id' => $category->id));
$newparent = get_context_instance(CONTEXT_SYSTEM);
} else {
$DB->set_field('course_categories', 'parent', $newparentcat->id, array('id' => $category->id));
$newparent = get_context_instance(CONTEXT_COURSECAT, $newparentcat->id);
if (!$newparentcat->visible and $category->visible) {
// better hide category when moving into hidden category, teachers may unhide afterwards and the hidden children will be restored properly
$hidecat = true;
}
}
context_moved($context, $newparent);
// now make it last in new category
$DB->set_field('course_categories', 'sortorder', MAX_COURSES_IN_CATEGORY * MAX_COURSE_CATEGORIES, array('id' => $category->id));
// and fix the sortorders
fix_course_sortorder();
if ($hidecat) {
course_category_hide($category);
}
}