public function actionCreate() { $this->channel = 'contribute'; $form = new PostForm(); if (request()->getIsPostRequest() && isset($_POST['PostForm'])) { $form->attributes = $_POST['PostForm']; if ($form->validate()) { $post = $form->save(); if (!$post->hasErrors()) { user()->setFlash('success_post_id', $post->id); $this->redirect(url('post/success')); exit(0); } } } else { $key = param('sess_post_create_token'); if (!app()->session->contains($key) || empty(app()->session[$key])) { app()->session->add($key, uniqid('beta', true)); } else { $token = app()->session[$key]; $tempPictures = Upload::model()->findAllByAttributes(array('token' => $token)); } } $captchaWidget = $form->hasErrors('captcha') ? $this->widget('BetaCaptcha', array(), true) : $this->widget('BetaCaptcha', array('skin' => 'defaultLazy'), true); $captchaClass = $form->hasErrors('captcha') ? 'error' : 'hide'; $this->setSiteTitle(t('contribute_post')); cs()->registerMetaTag('noindex, follow', 'robots'); $this->render('create', array('form' => $form, 'captchaClass' => $captchaClass, 'captchaWidget' => $captchaWidget, 'tempPictures' => $tempPictures)); }