Example #1
0
 public function actionAdd()
 {
     if (User::thisUser()->reputation < Event::MIN_REPUTATION_EVENT_CREATE) {
         return Yii::$app->getResponse()->redirect(Url::home());
     }
     $event = new Event();
     if ($event->load(Yii::$app->request->post())) {
         $eventPost = Yii::$app->request->post('Event');
         $event->country = $eventPost['country'];
         $event->description = \yii\helpers\HtmlPurifier::process($event->description, []);
         $event->user_id = Yii::$app->user->identity->getId();
         $event->date = strtotime($eventPost['date']);
         $event->like_count = 0;
         $event->show_count = 0;
         if ($event->save()) {
             // Добавляем теги
             $tagsArr = explode(',', Yii::$app->request->post('tags'));
             $tags = array_shift($tagsArr);
             $event->saveTags($tags);
             // Добавляем картинки к записи
             $imgs = Yii::$app->request->post('imgs');
             if (!empty($imgs) && is_array($imgs)) {
                 $event->saveImgs($imgs);
             } else {
                 $event->saveImgs([]);
             }
             $event->saveLocations(Yii::$app->request->post('location'));
             return Yii::$app->getResponse()->redirect($event->getUrl());
         }
     }
     Yii::$app->params['jsZoukVar']['tagsAll'] = Tags::getTags(Tags::TAG_GROUP_ALL);
     return $this->render('add', ['event' => $event]);
 }
 public function actionCreate()
 {
     $event = new Event();
     $event_ru = new Event_ru();
     $event_en = new Event_en();
     $photos = new ActiveDataProvider(['query' => event_photo::find()->where(['event_id' => $id])]);
     if ($event->load(Yii::$app->request->post()) && $event_ru->load(Yii::$app->request->post()) && $event_en->load(Yii::$app->request->post())) {
         $event->author_id = Yii::$app->user->identity->id;
         if ($event->save()) {
             $this->uploadphoto(UploadedFile::getInstances($event, 'images'), $event->id);
             $event_ru->event_id = $event->id;
             $event_ru->publish_status = 0;
             $event_ru->like = 0;
             $event_ru->visited = 0;
             $event_en->event_id = $event->id;
             $event_en->publish_status = 0;
             $event_en->like = 0;
             $event_en->visited = 0;
             $event_ru->save();
             $event_en->save();
         }
         return $this->redirect(['update', 'id' => $event->id]);
     } else {
         return $this->render('create', ['event' => $event, 'event_ru' => $event_ru, 'event_en' => $event_en, 'photos' => $photos]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->Id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #4
0
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($date)
 {
     $model = new Event();
     $model->create_date = $date;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('index');
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     $map = new EventMap();
     if ($model->load(Yii::$app->request->post()) && $model->editsave()) {
         Yii::$app->session->setFlash("event_notification", Yii::t("app", "Event Created!"));
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'map' => $map]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     $categoryModel = new EventCategory();
     $treeParents = TreeHelper::build($categoryModel->find()->addOrderBy('tree')->addOrderBy('lft')->all());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'treeParents' => $treeParents]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @param $url_key
  * @return string|\yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionCreate($url_key)
 {
     $model = new Event();
     /* @var $sport Sport*/
     $sport = $this->findSportModel($url_key);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', Yii::t('app', 'Event wes successfully created.'));
         return $this->redirect(['sport/update', 'url_key' => $model->sport->url_key]);
     } else {
         $model->sport_id = $sport->id;
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post())) {
         $model->created_date = date("Y-m-d h:i:sa");
         $model->updated_date = date("Y-m-d h:i:sa");
         $model->created_by = Yii::$app->user->id;
         $model->updated_by = Yii::$app->user->id;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     // $user = $this->findModel(Yii::$app->user->id);
     // $model->location = $user->address;
     if ($model->load(Yii::$app->request->post())) {
         $model->eeopen_date = $model->eopen_date;
         $model->organiser_id = Yii::$app->user->id;
         $model->created_date = date("Y-m-d h:i:sa");
         $model->updated_date = date("Y-m-d h:i:sa");
         $model->created_by = Yii::$app->user->id;
         $model->updated_by = Yii::$app->user->id;
         $model->is_active = 1;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }