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


PHP filter_delete_all_for_context函数代码示例

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


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

示例1: delete_content

 /**
  * Delete all data linked to content, do not delete the context record itself
  */
 public function delete_content()
 {
     global $CFG, $DB;
     blocks_delete_all_for_context($this->_id);
     filter_delete_all_for_context($this->_id);
     require_once $CFG->dirroot . '/comment/lib.php';
     comment::delete_comments(array('contextid' => $this->_id));
     require_once $CFG->dirroot . '/rating/lib.php';
     $delopt = new stdclass();
     $delopt->contextid = $this->_id;
     $rm = new rating_manager();
     $rm->delete_ratings($delopt);
     // delete all files attached to this context
     $fs = get_file_storage();
     $fs->delete_area_files($this->_id);
     // delete all advanced grading data attached to this context
     require_once $CFG->dirroot . '/grade/grading/lib.php';
     grading_manager::delete_all_for_context($this->_id);
     // now delete stuff from role related tables, role_unassign_all
     // and unenrol should be called earlier to do proper cleanup
     $DB->delete_records('role_assignments', array('contextid' => $this->_id));
     $DB->delete_records('role_capabilities', array('contextid' => $this->_id));
     $DB->delete_records('role_names', array('contextid' => $this->_id));
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:27,代码来源:accesslib.php

示例2: remove_course_contents


//.........这里部分代码省略.........
    foreach ($cleanuplugintypes as $type) {
        if (!empty($callbacks[$type])) {
            foreach ($callbacks[$type] as $pluginfunction) {
                debugging("Callback delete_course is deprecated. Function {$pluginfunction} should be converted " . 'to observer of event \\core\\event\\course_content_deleted', DEBUG_DEVELOPER);
                $pluginfunction($course->id, $showfeedback);
            }
            if ($showfeedback) {
                echo $OUTPUT->notification($strdeleted . get_string('type_' . $type . '_plural', 'plugin'), 'notifysuccess');
            }
        }
    }
    // Delete questions and question categories.
    question_delete_course($course, $showfeedback);
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . get_string('questions', 'question'), 'notifysuccess');
    }
    // Make sure there are no subcontexts left - all valid blocks and modules should be already gone.
    $childcontexts = $coursecontext->get_child_contexts();
    // Returns all subcontexts since 2.2.
    foreach ($childcontexts as $childcontext) {
        $childcontext->delete();
    }
    unset($childcontexts);
    // Remove all roles and enrolments by default.
    if (empty($options['keep_roles_and_enrolments'])) {
        // This hack is used in restore when deleting contents of existing course.
        role_unassign_all(array('contextid' => $coursecontext->id, 'component' => ''), true);
        enrol_course_delete($course);
        if ($showfeedback) {
            echo $OUTPUT->notification($strdeleted . get_string('type_enrol_plural', 'plugin'), 'notifysuccess');
        }
    }
    // Delete any groups, removing members and grouping/course links first.
    if (empty($options['keep_groups_and_groupings'])) {
        groups_delete_groupings($course->id, $showfeedback);
        groups_delete_groups($course->id, $showfeedback);
    }
    // Filters be gone!
    filter_delete_all_for_context($coursecontext->id);
    // Notes, you shall not pass!
    note_delete_all($course->id);
    // Die comments!
    comment::delete_comments($coursecontext->id);
    // Ratings are history too.
    $delopt = new stdclass();
    $delopt->contextid = $coursecontext->id;
    $rm = new rating_manager();
    $rm->delete_ratings($delopt);
    // Delete course tags.
    core_tag_tag::remove_all_item_tags('core', 'course', $course->id);
    // Notify the competency subsystem.
    \core_competency\api::hook_course_deleted($course);
    // Delete calendar events.
    $DB->delete_records('event', array('courseid' => $course->id));
    $fs->delete_area_files($coursecontext->id, 'calendar');
    // Delete all related records in other core tables that may have a courseid
    // This array stores the tables that need to be cleared, as
    // table_name => column_name that contains the course id.
    $tablestoclear = array('backup_courses' => 'courseid', 'user_lastaccess' => 'courseid');
    foreach ($tablestoclear as $table => $col) {
        $DB->delete_records($table, array($col => $course->id));
    }
    // Delete all course backup files.
    $fs->delete_area_files($coursecontext->id, 'backup');
    // Cleanup course record - remove links to deleted stuff.
    $oldcourse = new stdClass();
    $oldcourse->id = $course->id;
    $oldcourse->summary = '';
    $oldcourse->cacherev = 0;
    $oldcourse->legacyfiles = 0;
    if (!empty($options['keep_groups_and_groupings'])) {
        $oldcourse->defaultgroupingid = 0;
    }
    $DB->update_record('course', $oldcourse);
    // Delete course sections.
    $DB->delete_records('course_sections', array('course' => $course->id));
    // Delete legacy, section and any other course files.
    $fs->delete_area_files($coursecontext->id, 'course');
    // Files from summary and section.
    // Delete all remaining stuff linked to context such as files, comments, ratings, etc.
    if (empty($options['keep_roles_and_enrolments']) and empty($options['keep_groups_and_groupings'])) {
        // Easy, do not delete the context itself...
        $coursecontext->delete_content();
    } else {
        // Hack alert!!!!
        // We can not drop all context stuff because it would bork enrolments and roles,
        // there might be also files used by enrol plugins...
    }
    // Delete legacy files - just in case some files are still left there after conversion to new file api,
    // also some non-standard unsupported plugins may try to store something there.
    fulldelete($CFG->dataroot . '/' . $course->id);
    // Delete from cache to reduce the cache size especially makes sense in case of bulk course deletion.
    $cachemodinfo = cache::make('core', 'coursemodinfo');
    $cachemodinfo->delete($courseid);
    // Trigger a course content deleted event.
    $event = \core\event\course_content_deleted::create(array('objectid' => $course->id, 'context' => $coursecontext, 'other' => array('shortname' => $course->shortname, 'fullname' => $course->fullname, 'options' => $options)));
    $event->add_record_snapshot('course', $course);
    $event->trigger();
    return true;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例3: remove_course_contents


//.........这里部分代码省略.........
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . get_string('type_mod_plural', 'plugin'), 'notifysuccess');
    }
    // Cleanup the rest of plugins
    $cleanuplugintypes = array('report', 'coursereport', 'format');
    foreach ($cleanuplugintypes as $type) {
        $plugins = get_plugin_list_with_function($type, 'delete_course', 'lib.php');
        foreach ($plugins as $plugin => $pluginfunction) {
            $pluginfunction($course->id, $showfeedback);
        }
        if ($showfeedback) {
            echo $OUTPUT->notification($strdeleted . get_string('type_' . $type . '_plural', 'plugin'), 'notifysuccess');
        }
    }
    // Delete questions and question categories
    question_delete_course($course, $showfeedback);
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . get_string('questions', 'question'), 'notifysuccess');
    }
    // Make sure there are no subcontexts left - all valid blocks and modules should be already gone
    $childcontexts = $coursecontext->get_child_contexts();
    // returns all subcontexts since 2.2
    foreach ($childcontexts as $childcontext) {
        $childcontext->delete();
    }
    unset($childcontexts);
    // Remove all roles and enrolments by default
    if (empty($options['keep_roles_and_enrolments'])) {
        // this hack is used in restore when deleting contents of existing course
        role_unassign_all(array('contextid' => $coursecontext->id, 'component' => ''), true);
        enrol_course_delete($course);
        if ($showfeedback) {
            echo $OUTPUT->notification($strdeleted . get_string('type_enrol_plural', 'plugin'), 'notifysuccess');
        }
    }
    // Delete any groups, removing members and grouping/course links first.
    if (empty($options['keep_groups_and_groupings'])) {
        groups_delete_groupings($course->id, $showfeedback);
        groups_delete_groups($course->id, $showfeedback);
    }
    // filters be gone!
    filter_delete_all_for_context($coursecontext->id);
    // die comments!
    comment::delete_comments($coursecontext->id);
    // ratings are history too
    $delopt = new stdclass();
    $delopt->contextid = $coursecontext->id;
    $rm = new rating_manager();
    $rm->delete_ratings($delopt);
    // Delete course tags
    coursetag_delete_course_tags($course->id, $showfeedback);
    // Delete calendar events
    $DB->delete_records('event', array('courseid' => $course->id));
    $fs->delete_area_files($coursecontext->id, 'calendar');
    // Delete all related records in other core tables that may have a courseid
    // This array stores the tables that need to be cleared, as
    // table_name => column_name that contains the course id.
    $tablestoclear = array('log' => 'course', 'backup_courses' => 'courseid', 'user_lastaccess' => 'courseid');
    foreach ($tablestoclear as $table => $col) {
        $DB->delete_records($table, array($col => $course->id));
    }
    // delete all course backup files
    $fs->delete_area_files($coursecontext->id, 'backup');
    // cleanup course record - remove links to deleted stuff
    $oldcourse = new stdClass();
    $oldcourse->id = $course->id;
    $oldcourse->summary = '';
    $oldcourse->modinfo = NULL;
    $oldcourse->legacyfiles = 0;
    $oldcourse->enablecompletion = 0;
    if (!empty($options['keep_groups_and_groupings'])) {
        $oldcourse->defaultgroupingid = 0;
    }
    $DB->update_record('course', $oldcourse);
    // Delete course sections and availability options.
    $DB->delete_records_select('course_sections_availability', 'coursesectionid IN (SELECT id from {course_sections} WHERE course=?)', array($course->id));
    $DB->delete_records('course_sections', array('course' => $course->id));
    // delete legacy, section and any other course files
    $fs->delete_area_files($coursecontext->id, 'course');
    // files from summary and section
    // Delete all remaining stuff linked to context such as files, comments, ratings, etc.
    if (empty($options['keep_roles_and_enrolments']) and empty($options['keep_groups_and_groupings'])) {
        // Easy, do not delete the context itself...
        $coursecontext->delete_content();
    } else {
        // Hack alert!!!!
        // We can not drop all context stuff because it would bork enrolments and roles,
        // there might be also files used by enrol plugins...
    }
    // Delete legacy files - just in case some files are still left there after conversion to new file api,
    // also some non-standard unsupported plugins may try to store something there
    fulldelete($CFG->dataroot . '/' . $course->id);
    // Finally trigger the event
    $course->context = $coursecontext;
    // you can not access context in cron event later after course is deleted
    $course->options = $options;
    // not empty if we used any crazy hack
    events_trigger('course_content_removed', $course);
    return true;
}
开发者ID:nmicha,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例4: delete_context

/**
 * Remove a context record and any dependent entries,
 * removes context from static context cache too
 * @param $level
 * @param $instanceid
 *
 * @return bool properly deleted
 */
function delete_context($contextlevel, $instanceid)
{
    global $DB, $ACCESSLIB_PRIVATE;
    // do not use get_context_instance(), because the related object might not exist,
    // or the context does not exist yet and it would be created now
    if ($context = $DB->get_record('context', array('contextlevel' => $contextlevel, 'instanceid' => $instanceid))) {
        $result = $DB->delete_records('role_assignments', array('contextid' => $context->id)) && $DB->delete_records('role_capabilities', array('contextid' => $context->id)) && $DB->delete_records('role_names', array('contextid' => $context->id)) && $DB->delete_records('context', array('id' => $context->id));
        // do not mark dirty contexts if parents unknown
        if (!is_null($context->path) and $context->depth > 0) {
            mark_context_dirty($context->path);
        }
        // purge static context cache if entry present
        unset($ACCESSLIB_PRIVATE->contexts[$contextlevel][$instanceid]);
        unset($ACCESSLIB_PRIVATE->contextsbyid[$context->id]);
        blocks_delete_all_for_context($context->id);
        filter_delete_all_for_context($context->id);
        return $result;
    } else {
        return true;
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:29,代码来源:accesslib.php

示例5: test_filter_delete_all_for_context

 public function test_filter_delete_all_for_context()
 {
     // Setup fixture.
     filter_set_global_state('filter/name', TEXTFILTER_ON);
     filter_set_local_state('filter/name', 123, TEXTFILTER_OFF);
     filter_set_local_config('filter/name', 123, 'settingname', 'A value');
     filter_set_local_config('filter/other', 123, 'settingname', 'Other value');
     filter_set_local_config('filter/other', 122, 'settingname', 'Other value');
     // Exercise SUT.
     filter_delete_all_for_context(123);
     // Validate.
     $this->assertEqual(1, $this->testdb->count_records('filter_active'));
     $this->assertTrue($this->testdb->record_exists('filter_active', array('contextid' => $this->syscontext->id)));
     $this->assertEqual(1, $this->testdb->count_records('filter_config'));
     $this->assertTrue($this->testdb->record_exists('filter_config', array('filter' => 'filter/other')));
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:16,代码来源:testfilterconfig.php

示例6: delete_context

/**
 * Remove a context record and any dependent entries,
 * removes context from static context cache too
 *
 * @param int $level
 * @param int $instanceid
 * @param bool $deleterecord false means keep record for now
 * @return bool returns true or throws an exception
 */
function delete_context($contextlevel, $instanceid, $deleterecord = true)
{
    global $DB, $ACCESSLIB_PRIVATE, $CFG;
    // do not use get_context_instance(), because the related object might not exist,
    // or the context does not exist yet and it would be created now
    if ($context = $DB->get_record('context', array('contextlevel' => $contextlevel, 'instanceid' => $instanceid))) {
        // delete these first because they might fetch the context and try to recreate it!
        blocks_delete_all_for_context($context->id);
        filter_delete_all_for_context($context->id);
        require_once $CFG->dirroot . '/comment/lib.php';
        comment::delete_comments(array('contextid' => $context->id));
        require_once $CFG->dirroot . '/rating/lib.php';
        $delopt = new stdclass();
        $delopt->contextid = $context->id;
        $rm = new rating_manager();
        $rm->delete_ratings($delopt);
        // delete all files attached to this context
        $fs = get_file_storage();
        $fs->delete_area_files($context->id);
        // now delete stuff from role related tables, role_unassign_all
        // and unenrol should be called earlier to do proper cleanup
        $DB->delete_records('role_assignments', array('contextid' => $context->id));
        $DB->delete_records('role_capabilities', array('contextid' => $context->id));
        $DB->delete_records('role_names', array('contextid' => $context->id));
        // and finally it is time to delete the context record if requested
        if ($deleterecord) {
            $DB->delete_records('context', array('id' => $context->id));
            // purge static context cache if entry present
            $ACCESSLIB_PRIVATE->contexcache->remove($context);
        }
        // do not mark dirty contexts if parents unknown
        if (!is_null($context->path) and $context->depth > 0) {
            mark_context_dirty($context->path);
        }
    }
    return true;
}
开发者ID:LMSeXT,项目名称:SAWEE-WS_server-lib,代码行数:46,代码来源:accesslib.php


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