当前位置: 首页>>代码示例>>PHP>>正文


PHP category_delete_full函数代码示例

本文整理汇总了PHP中category_delete_full函数的典型用法代码示例。如果您正苦于以下问题:PHP category_delete_full函数的具体用法?PHP category_delete_full怎么用?PHP category_delete_full使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了category_delete_full函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: redirect

    if ($mform->is_cancelled()) {
        redirect('index.php');
    } else {
        if (!($data = $mform->get_data())) {
            require_once $CFG->libdir . '/questionlib.php';
            echo $OUTPUT->header();
            echo $OUTPUT->heading($heading);
            $mform->display();
            echo $OUTPUT->footer();
            exit;
        }
    }
    echo $OUTPUT->header();
    echo $OUTPUT->heading($heading);
    if ($data->fulldelete) {
        $deletedcourses = category_delete_full($deletecat, true);
        foreach ($deletedcourses as $course) {
            echo $OUTPUT->notification(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
        }
        echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($deletecat->name)), 'notifysuccess');
    } else {
        category_delete_move($deletecat, $data->newparent, true);
    }
    // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
    if ($delete == $CFG->defaultrequestcategory) {
        set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
    }
    echo $OUTPUT->continue_button('index.php');
    echo $OUTPUT->footer();
    die;
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:enrolmentsolicitudes.php

示例2: delete_categories

 /**
  * Delete categories
  *
  * @param array $categories A list of category ids
  * @return array
  * @since Moodle 2.3
  */
 public static function delete_categories($categories)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/course/lib.php";
     // Validate parameters.
     $params = self::validate_parameters(self::delete_categories_parameters(), array('categories' => $categories));
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['categories'] as $category) {
         if (!($deletecat = $DB->get_record('course_categories', array('id' => $category['id'])))) {
             throw new moodle_exception('unknowcategory');
         }
         $context = context_coursecat::instance($deletecat->id);
         require_capability('moodle/category:manage', $context);
         self::validate_context($context);
         self::validate_context(get_category_or_system_context($deletecat->parent));
         if ($category['recursive']) {
             // If recursive was specified, then we recursively delete the category's contents.
             category_delete_full($deletecat, false);
         } else {
             // In this situation, we don't delete the category's contents, we either move it to newparent or parent.
             // If the parent is the root, moving is not supported (because a course must always be inside a category).
             // We must move to an existing category.
             if (!empty($category['newparent'])) {
                 if (!$DB->record_exists('course_categories', array('id' => $category['newparent']))) {
                     throw new moodle_exception('unknowcategory');
                 }
                 $newparent = $category['newparent'];
             } else {
                 $newparent = $deletecat->parent;
             }
             // This operation is not allowed. We must move contents to an existing category.
             if ($newparent == 0) {
                 throw new moodle_exception('movecatcontentstoroot');
             }
             $parentcontext = get_category_or_system_context($newparent);
             require_capability('moodle/category:manage', $parentcontext);
             self::validate_context($parentcontext);
             category_delete_move($deletecat, $newparent, false);
         }
     }
     $transaction->allow_commit();
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:49,代码来源:externallib.php

示例3: category_delete_full

/**
 * Recursively delete category including all subcategories and courses.
 * @param stdClass $category
 * @param boolean $showfeedback display some notices
 * @return array return deleted courses
 */
function category_delete_full($category, $showfeedback = true)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/gradelib.php';
    require_once $CFG->libdir . '/questionlib.php';
    require_once $CFG->dirroot . '/cohort/lib.php';
    if ($children = $DB->get_records('course_categories', array('parent' => $category->id), 'sortorder ASC')) {
        foreach ($children as $childcat) {
            category_delete_full($childcat, $showfeedback);
        }
    }
    $deletedcourses = array();
    if ($courses = $DB->get_records('course', array('category' => $category->id), 'sortorder ASC')) {
        foreach ($courses as $course) {
            if (!delete_course($course, false)) {
                throw new moodle_exception('cannotdeletecategorycourse', '', '', $course->shortname);
            }
            $deletedcourses[] = $course;
        }
    }
    // move or delete cohorts in this context
    cohort_delete_category($category);
    // now delete anything that may depend on course category context
    grade_course_category_delete($category->id, 0, $showfeedback);
    if (!question_delete_course_category($category, 0, $showfeedback)) {
        throw new moodle_exception('cannotdeletecategoryquestions', '', '', $category->name);
    }
    // finally delete the category and it's context
    $DB->delete_records('course_categories', array('id' => $category->id));
    delete_context(CONTEXT_COURSECAT, $category->id);
    events_trigger('course_category_deleted', $category);
    return $deletedcourses;
}
开发者ID:numbas,项目名称:moodle,代码行数:39,代码来源:lib.php

示例4: category_delete_full

/**
 * Recursively delete category including all subcategories and courses.
 * @param object $ccategory
 * @return bool status
 */
function category_delete_full($category, $showfeedback = true)
{
    global $CFG;
    require_once $CFG->libdir . '/gradelib.php';
    require_once $CFG->libdir . '/questionlib.php';
    if ($children = get_records('course_categories', 'parent', $category->id, 'sortorder ASC')) {
        foreach ($children as $childcat) {
            if (!category_delete_full($childcat, $showfeedback)) {
                notify("Error deleting category {$childcat->name}");
                return false;
            }
        }
    }
    if ($courses = get_records('course', 'category', $category->id, 'sortorder ASC')) {
        foreach ($courses as $course) {
            if (!delete_course($course->id, false)) {
                notify("Error deleting course {$course->shortname}");
                return false;
            }
            notify(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
        }
    }
    // now delete anything that may depend on course category context
    grade_course_category_delete($category->id, 0, $showfeedback);
    if (!question_delete_course_category($category, 0, $showfeedback)) {
        notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
        return false;
    }
    // finally delete the category and it's context
    delete_records('course_categories', 'id', $category->id);
    delete_context(CONTEXT_COURSECAT, $category->id);
    events_trigger('course_category_deleted', $category);
    notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
    return true;
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:40,代码来源:lib.php

示例5: redirect

    if ($mform->is_cancelled()) {
        redirect('index.php');
    } else {
        if (!($data = $mform->get_data(false))) {
            require_once $CFG->libdir . '/questionlib.php';
            print_category_edit_header();
            print_heading($heading);
            $mform->display();
            admin_externalpage_print_footer();
            exit;
        }
    }
    print_category_edit_header();
    print_heading($heading);
    if ($data->fulldelete) {
        category_delete_full($deletecat, true);
    } else {
        category_delete_move($deletecat, $data->newparent, true);
    }
    // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
    if ($delete == $CFG->defaultrequestcategory) {
        set_config('defaultrequestcategory', get_field('course_categories', 'MIN(id)', 'parent', 0));
    }
    print_continue('index.php');
    admin_externalpage_print_footer();
    die;
}
/// Print headings
print_category_edit_header();
print_heading($strcategories);
/// Create a default category if necessary
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:index.php

示例6: require_capability

 require_capability('moodle/category:manage', $context);
 require_capability('moodle/category:manage', get_category_or_system_context($cattodelete->parent));
 $heading = get_string('deletecategory', 'moodle', format_string($cattodelete->name, true, array('context' => $context)));
 require_once $CFG->dirroot . '/course/delete_category_form.php';
 $mform = new delete_category_form(null, $cattodelete);
 $mform->set_data(array('deletecat' => $deletecat));
 if ($mform->is_cancelled()) {
     redirect(new moodle_url('/course/manage.php'));
 }
 // Start output.
 echo $OUTPUT->header();
 echo $OUTPUT->heading($heading);
 if ($data = $mform->get_data()) {
     // The form has been submit handle it.
     if ($data->fulldelete) {
         $deletedcourses = category_delete_full($cattodelete, true);
         foreach ($deletedcourses as $course) {
             echo $OUTPUT->notification(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
         }
         $cattodeletename = format_string($cattodelete->name, true, array('context' => $context));
         echo $OUTPUT->notification(get_string('coursecategorydeleted', '', $catetodeletename), 'notifysuccess');
     } else {
         category_delete_move($cattodelete, $data->newparent, true);
     }
     if ($deletecat == $CFG->defaultrequestcategory) {
         // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
         set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
     }
     echo $OUTPUT->continue_button(new moodle_url('/course/manage.php'));
 } else {
     // Display the form.
开发者ID:Burick,项目名称:moodle,代码行数:31,代码来源:manage.php


注:本文中的category_delete_full函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。