static function deleteFile($id, $notes = null)
 {
     $m = D2files::model();
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t("D2filesModule.model", "The requested record does not exist."));
     }
     $model->deleted = 1;
     if ($notes) {
         $model->notes = $notes;
     }
     $model->save();
 }
 public function loadModel($id)
 {
     $m = D2files::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('D2filesModule.crud_static', 'The requested page does not exist.'));
     }
     return $model;
 }
Exemple #3
0
 /**
  * get model record files
  * @param string $model_name model name in format [module name].[model name]
  * @param int $model_id record is
  * @param int $type attachment type
  * @return array d2files models
  */
 public static function getModelRecorFiles($model_name, $model_id, $type = false)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('model', $model_name);
     $criteria->compare('model_id', $model_id);
     if ($type) {
         $criteria->compare('type_id', $type);
     }
     $criteria->compare('deleted', 0);
     return D2files::model()->findAll($criteria);
 }