public function actionDeleteAttach()
 {
     if (!isset($_POST['id'])) {
         $this->response('error');
     }
     $id = $_POST['id'];
     $model = AttachmentProject::model()->findByPk($id);
     if ($model === null) {
         $this->response('error');
     }
     $model->delete();
     $this->response('success');
 }
Example #2
0
 protected function beforeDelete()
 {
     if (!parent::beforeDelete()) {
         return false;
     }
     foreach ($this->attachment as $key => $value) {
         $model = AttachmentProject::model()->findByPk($value->id);
         $model->delete();
     }
     $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $this->img;
     $fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $this->img;
     if (file_exists($file) and $this->img != '') {
         unlink($file);
     }
     if (file_exists($fileMini) and $this->img != '') {
         unlink($fileMini);
     }
     return true;
 }