public function actionSaveSort() { $objTypeId = Yii::app()->request->getParam('id', NULL); $sort = Yii::app()->request->getParam('sort'); if (count($sort) >= param('searchMaxField', 15)) { HAjax::jsonError(tt('Search max field ') . param('searchMaxField', 3)); } if ($objTypeId !== NULL && $sort && is_array($sort)) { $elements = SearchForm::getSearchFields(); $sql = "DELETE FROM {{search_form}} WHERE obj_type_id=:id AND status!=:status"; Yii::app()->db->createCommand($sql)->execute(array(':id' => $objTypeId, ':status' => SearchFormModel::STATUS_NOT_REMOVE)); $i = 3; foreach ($sort as $field) { if (!isset($elements[$field])) { continue; } $search = new SearchFormModel(); $search->attributes = array('obj_type_id' => $objTypeId, 'field' => $field, 'status' => $elements[$field]['status'], 'sorter' => $i, 'formdesigner_id' => isset($elements[$field]['formdesigner_id']) ? $elements[$field]['formdesigner_id'] : 0); $search->save(); $i++; } // delete assets js cache ConfigurationModel::clearGenerateJSAssets(); HAjax::jsonOk(); } HAjax::jsonError(); }
public function actionDeleteImg($id) { $model = $this->loadModel($id); $model->delImage(); $model->bg_image = ''; if ($model->update('bg_image')) { Yii::app()->user->setFlash('success', tt('Image successfully deleted', 'themes')); } else { Yii::app()->user->setFlash('error', HAjax::implodeModelErrors($model)); } $this->redirect(array('update', 'id' => $id)); }
public function actionAjaxDelAva() { if (Yii::app()->user->isGuest || !Yii::app()->request->isAjaxRequest) { throw404(); } $id = Yii::app()->request->getQuery('id', 0); if ($id && in_array(Yii::app()->user->role, array(User::ROLE_MODERATOR, User::ROLE_ADMIN))) { $user = $this->loadModel($id); } else { $user = HUser::getModel(); } $folder = HUser::getUploadDirectory($user, HUser::UPLOAD_AVA) . DIRECTORY_SEPARATOR; @unlink($folder . $user->ava); @unlink($folder . User::AVA_PREFIX . $user->ava); $user->ava = ''; $user->update(array('ava')); $result['avaHtml'] = '<div class="user-ava-crop">' . CHtml::image(Yii::app()->theme->baseUrl . '/images/ava-default.jpg', $user->username, array('class' => 'message_ava')) . '</div>'; HAjax::jsonOk(tc('Success'), $result); }
public function actionLoadForm() { if (!Yii::app()->request->isAjaxRequest) { throw404(); } $this->objType = Yii::app()->request->getParam('obj_type_id'); $isInner = Yii::app()->request->getParam('is_inner'); $roomsMin = Yii::app()->request->getParam('room_min'); $roomsMax = Yii::app()->request->getParam('room_max'); if ($roomsMin || $roomsMax) { $this->roomsCountMin = $roomsMin; $this->roomsCountMax = $roomsMax; } $this->sApId = (int) Yii::app()->request->getParam('sApId'); $floorMin = Yii::app()->request->getParam('floor_min'); $floorMax = Yii::app()->request->getParam('floor_max'); if ($floorMin || $floorMax) { $this->floorCountMin = $floorMin; $this->floorCountMax = $floorMax; } $floor = Yii::app()->request->getParam('floor'); if ($floor) { $this->floorCount = $floor; } if (issetModule('selecttoslider') && param('useSquareSlider') == 1) { $squareMin = Yii::app()->request->getParam('square_min'); $squareMax = Yii::app()->request->getParam('square_max'); if ($squareMin || $squareMax) { $this->squareCountMin = $squareMin; $this->squareCountMax = $squareMax; } } else { $square = Yii::app()->request->getParam('square'); if ($square) { $this->squareCount = $square; } } if (issetModule('location') && param('useLocation', 1)) { $country = Yii::app()->request->getParam('country'); if ($country) { $this->selectedCountry = $country; } $region = Yii::app()->request->getParam('region'); if ($region) { $this->selectedRegion = $region; } $city = Yii::app()->request->getParam('city'); if ($city) { $this->selectedCity = $city; } } else { $city = Yii::app()->request->getParam('city'); if ($city) { $this->selectedCity = $city; } } $this->objType = Yii::app()->request->getParam('objType'); $this->apType = Yii::app()->request->getParam('apType'); /* if(issetModule('selecttoslider') && param('usePriceSlider') == 1) { $priceMin = Yii::app()->request->getParam("price_min"); $priceMax = Yii::app()->request->getParam("price_max"); if($priceMin || $priceMax) { $this->priceSlider["min"] = $priceMin; $this->priceSlider["max"] = $priceMax; } } else { $price = Yii::app()->request->getParam('price'); if(issetModule('currency')){ $priceDefault = ceil(Currency::convertToDefault($price)); } else { $priceDefault = $price; } if($priceDefault) { $this->price = $price; } }*/ if (issetModule('formeditor')) { $newFieldsAll = FormDesigner::getNewFields(); foreach ($newFieldsAll as $field) { $value = CHtml::encode(Yii::app()->request->getParam($field->field)); if (!$value) { continue; } $fieldString = $field->field; $this->newFields[$fieldString] = $value; } } $compact = Yii::app()->request->getParam('compact', 0); HAjax::jsonOk('', array('html' => $this->renderPartial('//site/_search_form', array('isInner' => $isInner, 'compact' => $compact), true), 'sliderRangeFields' => SearchForm::getSliderRangeFields(), 'cityField' => SearchForm::getCityField(), 'countFiled' => SearchForm::getCountFiled(), 'compact' => $compact)); }
public function actionAjaxSetAgentStatus() { if (Yii::app()->request->getParam('id') && Yii::app()->request->getParam('value') != null) { $status = Yii::app()->request->getParam('value', null); $id = Yii::app()->request->getParam('id', null); $user = User::model()->findByPk($id); $availableStatuses = User::getAgentStatusList(); if (!array_key_exists($status, $availableStatuses) || !$user) { HAjax::jsonError(); } $user->agent_status = $status; $user->update(array('agent_status')); } echo CHtml::link($availableStatuses[$status]); }
public function actionRecover($id) { if (demo()) { HAjax::jsonError(tc('Sorry, this action is not allowed on the demo server.')); } $model = $this->loadModel($id); $tempRecoverPassword = $model->randomString(); $recoverPasswordKey = User::generateActivateKey(); $model->temprecoverpassword = $tempRecoverPassword; $model->recoverPasswordKey = $recoverPasswordKey; $model->update(array('temprecoverpassword', 'recoverPasswordKey')); $model->recoverPasswordLink = Yii::app()->createAbsoluteUrl('/site/recover?key=' . $recoverPasswordKey); // send email $notifier = new Notifier(); $notifier->raiseEvent('onRecoveryPassword', $model, array('user' => $model)); HAjax::jsonOk(Yii::t('module_notifier', 'A new password has been created and sent to {email}.', array('{email}' => $model->email))); }