/**
  * Creates a new Album model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Album();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Album model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $this->layout = 'admin';
     $model = new Album();
     if ($model->load(Yii::$app->request->post())) {
         $this->Uploads(false);
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         $model->ref = substr(Yii::$app->getSecurity()->generateRandomString(), 10);
     }
     return $this->render('create', ['model' => $model]);
 }
 /**
  * Creates a new Album model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Album();
     $data = Yii::$app->request->post();
     $ret = $model->load($data);
     $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
     if ($ret && $model->upload() && $model->save()) {
         if (isset($data['Album']['categoryID'])) {
             foreach ($data['Album']['categoryID'] as $val) {
                 $relation = new CategoryRelationship();
                 $relation->media = $model->ID;
                 $relation->category = $val;
                 $relation->type = 0;
                 $relation->save();
             }
         }
         return $this->redirect(['view', 'id' => $model->ID]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionAlbum_add()
 {
     $this->redirectOnHomepageIfGuest($user, $isMyProfile);
     $model = new Album();
     $model->scenario = 'album_add_edit';
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         // Зберігаємо доданий альбом
         $model->id_user = \Yii::$app->user->getId();
         $model->date = (new \DateTime())->format('Y-m-d H:i:s');
         if ($_POST['Album']['parent_id'] != "" && Album::checkParentAlbum($_POST['Album']['parent_id'])) {
             $model->parent_id = $_POST['Album']['parent_id'];
             Album::childAlbumSetParentPrivacy($model);
         }
         $model->save();
         // @todo перекласти
         \Yii::$app->session->setFlash('notify', 'Ви успішно створили альбом');
         $this->redirect('/download_photos/album' . $model->id);
     }
     return $this->render('album_add', ['model' => $model, 'user' => $user, 'isMyProfile' => $isMyProfile]);
 }