예제 #1
0
 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);
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 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();
 }