Ejemplo n.º 1
0
 public function run()
 {
     $model_files = new D1files('search');
     $model_files->model = $this->model_name;
     $model_files->model_id = $this->model_id;
     $model_files->deleted = 0;
     $files = $model_files->findAll($model_files->searchCriteria());
     $this->render($this->template_view, array('files' => $files));
 }
 public function actionDownloadFile($id)
 {
     $m = D1files::model();
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested record in d1files does not exist.');
     }
     Yii::import("vendor.dbrisinajumi.d1files.compnents.*");
     $oUploadHandler = new UploadHandlerD1files(array('model_name' => 'CcmpCompany', 'model_id' => $id, 'download_via_php' => TRUE, 'file_name' => $model->file_name));
 }
Ejemplo n.º 3
0
 /**
  * save file info in DB
  * @param char $file_name
  * @param char $model_name
  * @param int $model_id
  * @return int record id
  * @throws CHttpException
  */
 public function saveToDb($file_name, $model_name, $model_id)
 {
     $model = new D1files();
     $model->type = D1files::TYPE_DOCUMENT;
     $model->file_name = $file_name;
     $model->upload_path = 'tttt';
     $model->add_datetime = date('Y.m.d H:i:s');
     $model->user_id = Yii::app()->user->id;
     $model->model = $model_name;
     $model->model_id = $model_id;
     try {
         $model->save();
     } catch (Exception $e) {
         throw new CHttpException(500, $e->getMessage());
     }
     return $model->primaryKey;
 }
Ejemplo n.º 4
0
 public function loadModel($id)
 {
     $m = D1files::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('D1filesModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }