public function actionLogin() { $model = $this->createModel('LoginForm'); if (isPostOrAjaxRequest()) { if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; if ($model->validate()) { $model->login(); } if (isAjax()) { if ($model->hasErrors()) { // was validation errors $this->validationErrorsAjaxResponse($model, FALSE); } else { // success if (Yii::app()->user->returnUrl) { $response['redirect'] = Yii::app()->user->returnUrl; } else { $response['redirect'] = $this->createUrl('index'); } $this->successfulAjaxResponse($response); } } else { $this->setModel($model); } } } $this->setLayout('login-backend'); $this->render('login', array('model' => $this->getModel())); }
public function actionContact() { $pageModel = StaticPages::model()->byPageId(StaticPages::CONTACT)->find(); $this->pageTitle .= ' - ' . $pageModel->getTitle(); $this->setModel(new ContactForm()); if (isPostOrAjaxRequest()) { $this->setAjaxResponseSuccessMessage('Ваше повідомлення надіслане!'); $this->process(); } $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), $pageModel->getTitle()); $this->render('contact', array('pageModel' => $pageModel, 'formModel' => $this->getModel())); }
public function actionMassDelivery() { $this->setModel(new MassDeliveryForm()); if (isPostOrAjaxRequest()) { /** @var $model MassDeliveryForm */ $model = $this->getModel(); $model->receiverEmail = Subscribers::getEmails(Yii::app()->params['emails']['limitForSend']); $this->setModel($model); $this->ajaxResponseErrorMessage = _('Пропущені деякі необхідні поля.'); $this->ajaxResponseSuccessMessage = _('Листи відправлені.'); $this->process(); } $this->render('mass-delivery', array('model' => $this->getModel(), 'formId' => MassDeliveryForm::FORM_ID)); }
/** * For multilingual site mode */ public function runMultilingual() { // check if action is configured $this->checkConditions(array('model', 'tableModelClassName')); /** @var $controller BackendController */ $controller = $this->getController(); if ($this->redirectUrl) { $controller->setRedirectUrl($this->redirectUrl); } $controller->setModel($this->model); if (isPostOrAjaxRequest()) { // in case of multilingual site we will use form model to gather data and save to data storage (DB) $this->model->setTableModelClassName($this->tableModelClassName); $controller->processCreate(); } $controller->render($this->view, array('model' => $controller->getModel(), 'pageTitle' => $this->pageTitle, 'formId' => $this->formId, 'formView' => $this->formView, 'formAction' => $this->formAction, 'innerLinks' => $this->innerLinks, 'imageUploadHandlerUrl' => $this->imageUploadHandlerUrl, 'coverPreviewWidth' => $this->coverPreviewWidth, 'coverPreviewHeight' => $this->coverPreviewHeight)); }
/** * For multilingual site mode */ public function runMultilingual() { // check if action is configured $this->checkConditions(array('model', 'updateRecordId', 'tableModelClassName')); /** @var $controller BackendController */ $controller = $this->getController(); $this->model->setTableModelClassName($this->tableModelClassName); $this->model->loadData($this->updateRecordId); if ($this->redirectUrl) { $controller->setRedirectUrl($this->redirectUrl); } $controller->setModel($this->model); if (isPostOrAjaxRequest()) { $controller->processUpdate(); } $controller->render($this->view, array('model' => $controller->getModel(), 'pageTitle' => $this->pageTitle, 'formId' => $this->formId, 'formView' => $this->formView, 'formAction' => $this->formAction, 'imageUploadHandlerUrl' => $this->imageUploadHandlerUrl, 'coverPreviewWidth' => $this->coverPreviewWidth, 'coverPreviewHeight' => $this->coverPreviewHeight)); }
public function actionChangeCurrentPassword() { $formModel = new ChangePasswordForm(); $formModel->setUserModel(User::getCurrentUser()); $this->setModel($formModel); if (isPostOrAjaxRequest()) { $this->setAjaxResponseSuccessMessage('Пароль змінено'); $this->setAjaxResponseErrorMessage('Дані введено не вірно!'); $this->process(); } $this->render('change-password', array('pageTitle' => _('Зміна паролю для поточного користувача'), 'model' => $this->getModel(), 'formId' => $formModel::FORM_ID)); }
public function actionCreateUpdateTrip($id = NULL) { $model = new TripForm(); $this->setAjaxResponseSuccessMessage('Поїздка запланована'); $this->setRedirectUrl($this->createUrl('myTrips')); $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), 'Туристичні знайомства' => $this->createUrl('index'), 'Мої поїздки' => $this->createUrl('myTrips'), 'Планування поїздку'); if ($id) { $this->breadcrumbs = array('Головна' => $this->createUrl('site/index'), 'Туристичні знайомства' => $this->createUrl('index'), 'Мої поїздки' => $this->createUrl('myTrips'), 'Редагування поїздки'); $this->setAjaxResponseSuccessMessage('Зміни збережені'); $model->load($id); } $this->setModel($model); if (isPostOrAjaxRequest()) { $this->process(); } $this->render('add-edit-trip', array('model' => $this->getModel(), 'purposeOptions' => TripPurpose::getOptions('Для'), 'withOptions' => TripWith::getOptions('Їду з'), 'companionOptions' => TripCompanion::getOptions('Шукаю'), 'countryOptions' => Country::getOptions('Їду в'))); }