示例#1
0
 /**
  * Delete the context content and the context record itself
  */
 public function delete()
 {
     global $DB;
     // double check the context still exists
     if (!$DB->record_exists('context', array('id' => $this->_id))) {
         context::cache_remove($this);
         return;
     }
     $this->delete_content();
     $DB->delete_records('context', array('id' => $this->_id));
     // purge static context cache if entry present
     context::cache_remove($this);
     // do not mark dirty contexts if parents unknown
     if (!is_null($this->_path) and $this->_depth > 0) {
         $this->mark_dirty();
     }
 }
示例#2
0
    /**
     * Delete the context content and the context record itself
     */
    public function delete() {
        global $DB;

        if ($this->_contextlevel <= CONTEXT_SYSTEM) {
            throw new coding_exception('Cannot delete system context');
        }

        // double check the context still exists
        if (!$DB->record_exists('context', array('id'=>$this->_id))) {
            context::cache_remove($this);
            return;
        }

        $this->delete_content();
        $DB->delete_records('context', array('id'=>$this->_id));
        // purge static context cache if entry present
        context::cache_remove($this);

        // do not mark dirty contexts if parents unknown
        if (!is_null($this->_path) and $this->_depth > 0) {
            $this->mark_dirty();
        }
    }