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


PHP coursecat::delete_full方法代码示例

本文整理汇总了PHP中coursecat::delete_full方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::delete_full方法的具体用法?PHP coursecat::delete_full怎么用?PHP coursecat::delete_full使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coursecat的用法示例。


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

示例1: delete_full

 /**
  * Recursively delete category including all subcategories and courses
  *
  * Function {@link coursecat::can_delete_full()} MUST be called prior
  * to calling this function because there is no capability check
  * inside this function
  *
  * @param boolean $showfeedback display some notices
  * @return array return deleted courses
  * @throws moodle_exception
  */
 public function delete_full($showfeedback = true)
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->libdir . '/questionlib.php';
     require_once $CFG->dirroot . '/cohort/lib.php';
     $deletedcourses = array();
     // Get children. Note, we don't want to use cache here because it would be rebuilt too often.
     $children = $DB->get_records('course_categories', array('parent' => $this->id), 'sortorder ASC');
     foreach ($children as $record) {
         $coursecat = new coursecat($record);
         $deletedcourses += $coursecat->delete_full($showfeedback);
     }
     if ($courses = $DB->get_records('course', array('category' => $this->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($this);
     // Now delete anything that may depend on course category context.
     grade_course_category_delete($this->id, 0, $showfeedback);
     if (!question_delete_course_category($this, 0, $showfeedback)) {
         throw new moodle_exception('cannotdeletecategoryquestions', '', '', $this->get_formatted_name());
     }
     // Finally delete the category and it's context.
     $DB->delete_records('course_categories', array('id' => $this->id));
     $coursecatcontext = context_coursecat::instance($this->id);
     $coursecatcontext->delete();
     cache_helper::purge_by_event('changesincoursecat');
     // Trigger a course category deleted event.
     /* @var \core\event\course_category_deleted $event */
     $event = \core\event\course_category_deleted::create(array('objectid' => $this->id, 'context' => $coursecatcontext, 'other' => array('name' => $this->name)));
     $event->set_coursecat($this);
     $event->trigger();
     // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
     if ($this->id == $CFG->defaultrequestcategory) {
         set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
     }
     return $deletedcourses;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:55,代码来源:coursecatlib.php

示例2: delete_full

 /**
  * Recursively delete category including all subcategories and courses
  *
  * Function {@link coursecat::can_delete_full()} MUST be called prior
  * to calling this function because there is no capability check
  * inside this function
  *
  * @param boolean $showfeedback display some notices
  * @return array return deleted courses
  */
 public function delete_full($showfeedback = true)
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->libdir . '/questionlib.php';
     require_once $CFG->dirroot . '/cohort/lib.php';
     $deletedcourses = array();
     // Get children. Note, we don't want to use cache here because
     // it would be rebuilt too often
     $children = $DB->get_records('course_categories', array('parent' => $this->id), 'sortorder ASC');
     foreach ($children as $record) {
         $coursecat = new coursecat($record);
         $deletedcourses += $coursecat->delete_full($showfeedback);
     }
     if ($courses = $DB->get_records('course', array('category' => $this->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($this);
     // now delete anything that may depend on course category context
     grade_course_category_delete($this->id, 0, $showfeedback);
     if (!question_delete_course_category($this, 0, $showfeedback)) {
         throw new moodle_exception('cannotdeletecategoryquestions', '', '', $this->get_formatted_name());
     }
     // finally delete the category and it's context
     $DB->delete_records('course_categories', array('id' => $this->id));
     delete_context(CONTEXT_COURSECAT, $this->id);
     add_to_log(SITEID, "category", "delete", "index.php", "{$this->name} (ID {$this->id})");
     cache_helper::purge_by_event('changesincoursecat');
     events_trigger('course_category_deleted', $this);
     // If we deleted $CFG->defaultrequestcategory, make it point somewhere else.
     if ($this->id == $CFG->defaultrequestcategory) {
         set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent' => 0)));
     }
     return $deletedcourses;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:51,代码来源:coursecatlib.php


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