示例#1
0
 /**
  * BeforeDelete
  * Clears caches for rebuilding
  * @see CActiveRecord::beforeDelete
  */
 public function beforeDelete()
 {
     Yii::app()->cache->delete('CiiMS::Content::list');
     Yii::app()->cache->delete('CiiMS::Routes');
     Yii::app()->cache->delete('content-' . $this->id . '-layout');
     Yii::app()->cache->delete('content-' . $this->id . '-view');
     return parent::beforeDelete();
 }
示例#2
0
 /**
  * BeforeDelete
  * Clears caches for rebuilding
  * @see CActiveRecord::beforeDelete
  */
 public function beforeDelete()
 {
     Yii::app()->cache->delete('content');
     Yii::app()->cache->delete('content-listing');
     Yii::app()->cache->delete('WFF-content-url-rules');
     Yii::app()->cache->delete('content-' . $this->id . '-layout');
     Yii::app()->cache->delete('content-' . $this->id . '-view');
     return parent::beforeDelete();
 }
示例#3
0
 /**
  * Automatically corrects parent tree issues that arise when a parent category node
  * is deleted.
  * @return boolean
  */
 public function beforeDelete()
 {
     // Prevents the main "uncategorized category from being deleted"
     if ($this->id == 1) {
         Yii::app()->user->setFlash('error', Yii::t('ciims.models.Categories', 'This category cannot be deleted'));
         return false;
     }
     Yii::app()->cache->delete('CiiMS::Content::list');
     Yii::app()->cache->delete('CiiMS::Routes');
     Yii::app()->cache->delete('categories-pid');
     $parent = $this->parent_id;
     $id = $this->id;
     // Reassign all posts to the parent category
     Yii::app()->db->createCommand('UPDATE content SET category_id = :parent_id WHERE category_id = :id')->bindParam(':parent_id', $parent)->bindParam(':id', $id)->execute();
     // Reassign all child categories to the parent category
     $data = $this->findAllByAttributes(array('parent_id' => $id));
     foreach ($data as $row) {
         $id = $row->id;
         Yii::app()->db->createCommand('UPDATE categories SET parent_id = :parent_id WHERE id = :id')->bindParam(':parent_id', $parent)->bindParam(':id', $id)->execute();
     }
     return parent::beforeDelete();
 }