public function actionDelete($page_id = null, $id = null) { $actions = new ModuleActionsData(); if (!is_null($id) && $actions->existsAction($id)) { if ($actions->deleteAction($id)) { $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id); } $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id); } else { $this->redirect(Yii::app()->request->scriptUrl); } }
public function deleteCategory($id) { $result = false; $actions = new ModuleActionsData(); $criteria = new CDbCriteria(); $criteria->select = 'id'; $criteria->condition = 'action_category_id = :id'; $criteria->params = array('id' => $id); foreach ($actions->findAll($criteria) as $value) { $actions->findByPk($value->id)->delete(); } if ($actions->count($criteria) == 0) { if ($this->findByPk($id)->delete()) { $result = true; } } return $result; }
public function actionIndex($page_id = null) { if (!is_null($page_id) && Pages::model()->existsPage($page_id)) { $data = array(); $link_id = ModulesInPages::model()->getLink($page_id, $this->module->id); if ($link_id) { $data = ModuleActionsData::model()->getList($link_id); } $this->render('index', array('page_id' => $page_id, 'data' => $data, 'module_id' => $this->module->id)); } }
public function beforeSave() { if (!$this->isNewRecord) { $img = ModuleActionsData::model()->findByPk($this->id)->small_img_id; if (!is_null($img) && !is_null($this->small_img_id) && $img != $this->small_img_id) { Files::model()->deleteFileById($img, Yii::app()->controller->module->id); } $img = ModuleActionsData::model()->findByPk($this->id)->large_img_id; if (!is_null($img) && !is_null($this->large_img_id) && $img != $this->large_img_id) { Files::model()->deleteFileById($img, Yii::app()->controller->module->id); } } return parent::beforeSave(); }