public function actionAdd($isFancy = 0) { $model = new Vacancy(); if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $model->attributes = $_POST[$this->modelName]; if ($model->validate()) { $model->user_ip = Yii::app()->controller->currentUserIp; $model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong; if ($model->save(false)) { $model->name = CHtml::encode($model->name); $model->body = CHtml::encode($model->body); $notifier = new Notifier(); $notifier->raiseEvent('onNewReview', $model); if (Yii::app()->user->checkAccess('vacancy_admin')) { Yii::app()->user->setFlash('success', tt('success_send_not_moderation')); } else { Yii::app()->user->setFlash('success', tt('success_send')); } $this->redirect(array('index')); } $model->unsetAttributes(array('name', 'body', 'verifyCode')); } else { Yii::app()->user->setFlash('error', tt('failed_send')); } $model->unsetAttributes(array('verifyCode')); } if ($isFancy) { $this->excludeJs(); $this->renderPartial('add', array('model' => $model), false, true); } else { $this->render('add', array('model' => $model)); } }
public function actionComplain($isFancy = 0) { $id = Yii::app()->request->getParam('id', 0); if (!$id) { throw404(); } $model = new $this->modelName(); $modelApartment = Apartment::model()->findByPk($id); if (!$modelApartment) { throw404(); } if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $model->attributes = $_POST[$this->modelName]; $model->apartment_id = $id; $model->session_id = Yii::app()->session->sessionId; $model->user_id = 0; $model->user_ip = Yii::app()->controller->currentUserIp; $model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong; if (!Yii::app()->user->isGuest) { $model->email = Yii::app()->user->email; $model->name = Yii::app()->user->username; $model->user_id = Yii::app()->user->id; } if ($model->validate()) { if ($this->checkAlreadyComplain($model->apartment_id, $model->user_id, $model->session_id)) { if ($model->save(false)) { $notifier = new Notifier(); $notifier->raiseEvent('onNewComplain', $model); Yii::app()->user->setFlash('success', tt('Thanks_for_complain', 'apartmentsComplain')); $model = new $this->modelName(); // clear fields } } else { Yii::app()->user->setFlash('notice', tt('your_already_post_complain', 'apartmentsComplain')); } } } if ($isFancy) { Yii::app()->clientscript->scriptMap['jquery.js'] = false; Yii::app()->clientscript->scriptMap['jquery.min.js'] = false; Yii::app()->clientscript->scriptMap['jquery-ui.min.js'] = false; $this->renderPartial('complain_form', array('model' => $model, 'apId' => $id, 'isFancy' => true, 'modelApartment' => $modelApartment), false, true); } else { $this->render('complain_form', array('model' => $model, 'apId' => $id, 'modelApartment' => $modelApartment, 'wtf' => 'huilo')); } }
public function actionWriteComment() { $model = new CommentForm(); if (isset($_POST['CommentForm']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $model->attributes = $_POST['CommentForm']; $model->defineShowRating(); if ($model->validate() && Comment::checkExist(null, $model->modelName, $model->modelId)) { if ($model->modelName == 'News' && !param('enableCommentsForNews', 1) || $model->modelName == 'Apartment' && !param('enableCommentsForApartments', 1) || $model->modelName == 'Menu' && !param('enableCommentsForPages', 0) || $model->modelName == 'Article' && !param('enableCommentsForFaq', 1) || $model->modelName == 'InfoPages' && !param('enableCommentsForPages', 0)) { throw404(); } $comment = new Comment(); $comment->body = $model->body; $comment->parent_id = $model->rel; $comment->user_ip = Yii::app()->controller->currentUserIp; $comment->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong; if ($model->rel == 0) { $comment->rating = $model->rating; } else { $comment->rating = -1; } $comment->model_name = $model->modelName; $comment->model_id = $model->modelId; if (Yii::app()->user->isGuest) { $comment->user_name = $model->user_name; $comment->user_email = $model->user_email; } else { $comment->owner_id = Yii::app()->user->id; } if (param('commentNeedApproval', 1) && !Yii::app()->user->checkAccess('backend_access')) { $comment->status = Comment::STATUS_PENDING; Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment. Your comment will be posted once it is approved.')); } else { $comment->status = Comment::STATUS_APPROVED; Yii::app()->user->setFlash('success', Yii::t('module_comments', 'Thank you for your comment.')); } $comment->save(false); $this->redirect($model->url); } } $this->render('commentForm', array('model' => $model)); }
public function actionMainform($isFancy = 0) { $model = new SimpleformModel(); $model->scenario = 'forrent'; if (isset($_POST['SimpleformModel']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $request = Yii::app()->request; $isForBuy = $request->getPost('isForBuy', 0); $model->attributes = $_POST['SimpleformModel']; if ($isForBuy) { $model->scenario = 'forbuy'; } if ($model->validate()) { if (!$isForBuy) { $model->time_inVal = $this->getI18nTimeIn($model->time_in); $model->time_outVal = $this->getI18nTimeOut($model->time_out); } $types = Apartment::getI18nTypesArray(); $model->type = $types[$model->type]; $notifier = new Notifier(); if (!$isForBuy) { $notifier->raiseEvent('onNewSimpleBookingForRent', $model); } else { $notifier->raiseEvent('onNewSimpleBookingForBuy', $model); } Yii::app()->user->setFlash('success', tt('Operation successfully complete. Your order will be reviewed by administrator.')); } } $user = null; if (!Yii::app()->user->isGuest) { $user = User::model()->findByPk(Yii::app()->user->getId()); } $type = Apartment::getTypesWantArray(); if ($isFancy) { $this->excludeJs(); $this->renderPartial('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => true), false, true); } else { $this->render('simpleform', array('model' => $model, 'type' => $type, 'user' => $user, 'isFancy' => false)); } }
public function run() { Yii::import('application.modules.contactform.models.ContactForm'); $model = new ContactForm(); $model->scenario = 'insert'; if (isset($_POST['ContactForm']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $model->attributes = $_POST['ContactForm']; if (!Yii::app()->user->isGuest) { $model->email = Yii::app()->user->email; $model->username = Yii::app()->user->username; } if ($model->validate()) { $notifier = new Notifier(); $notifier->raiseEvent('onNewContactform', $model); Yii::app()->user->setFlash('success', tt('Thanks_for_message', 'contactform')); $model = new ContactForm(); // clear fields } else { $model->unsetAttributes(array('verifyCode')); Yii::app()->user->setFlash('error', tt('Error_send', 'contactform')); } } $this->render('widgetContactform', array('model' => $model)); }
public function actionRegister() { if (!param('useUserRegistration', 0)) { throw404(); } $this->showSearchForm = false; $this->layout = '//layouts/inner'; if (Yii::app()->user->isGuest) { if (param('user_registrationMode') == 'without_confirm') { $model = new User('register_without_confirm'); } else { $model = new User('register'); } if (isset($_POST['User']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) { $model->attributes = $_POST['User']; if ($model->validate()) { $model->activatekey = User::generateActivateKey(); $user = User::createUser($model->attributes); if ($user) { $model->id = $user['id']; $model->password = $user['password']; $model->email = $user['email']; $model->username = $user['username']; $model->activatekey = $user['activatekey']; $model->activateLink = $user['activateLink']; $notifier = new Notifier(); $notifier->raiseEvent('onNewUser', $model, array('user' => $user['userModel'])); if (param('user_registrationMode') == 'without_confirm') { $login = new LoginForm(); $login->setAttributes(array('username' => $user['username'], 'password' => $user['password'])); if ($login->validate() && $login->login()) { User::updateUserSession(); User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp); $this->redirect(array('/usercpanel/main/index')); } else { /*echo 'getErrors=<pre>'; print_r($login->getErrors()); echo '</pre>'; exit;*/ showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered.')); } } else { showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered. The letter for account activation has been sent on {useremail}', array('{useremail}' => $user['email']))); } } else { showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'Error. Repeat attempt later')); } } else { $model->unsetAttributes(array('verifyCode')); } } $this->render('register', array('model' => $model)); } else { $this->redirect('index'); } }