Esempio n. 1
1
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
 /**
  * Magic getter. Returns this widget's packages. 
  */
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('TwoColumnSortableWidgetManagerJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/sortableWidgets/TwoColumnSortableWidgetManager.js'), 'depends' => array('SortableWidgetManagerJS'))));
     }
     return $this->_packages;
 }
Esempio n. 3
1
 public function run($action, $to, $id)
 {
     $to = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $to);
     $moved = CActiveRecord::model($this->getController()->CQtreeGreedView['modelClassName'])->findByPk((int) $id);
     if (!is_null($to) && !is_null($moved)) {
         try {
             switch ($action) {
                 case 'child':
                     $moved->moveAsLast($to);
                     break;
                 case 'before':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveBefore($to);
                     }
                     break;
                 case 'after':
                     if ($to->isRoot()) {
                         $moved->moveAsRoot();
                     } else {
                         $moved->moveAfter($to);
                     }
                     break;
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('CQTeeGridView', $e->getMessage());
         }
     }
     $this->getController()->redirect(array($this->getController()->CQtreeGreedView['adminAction']));
 }
Esempio n. 4
1
 /**
  * @param string $url
  * @param string $method
  * @param string $body
  *
  * @return FhirResponse
  */
 public function request($url, $method = 'GET', $body = null)
 {
     $server_name = null;
     foreach ($this->servers as $name => $server) {
         if (substr($url, 0, strlen($server['base_url']))) {
             $server_name = $name;
             break;
         }
     }
     $this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
     $this->http_client->setUri($url);
     $this->http_client->setMethod($method);
     if ($body) {
         $this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
     }
     $response = $this->http_client->request();
     $this->http_client->resetParameters();
     if ($body = $response->getBody()) {
         $use_errors = libxml_use_internal_errors(true);
         $value = Yii::app()->fhirMarshal->parseXml($body);
         $errors = libxml_get_errors();
         libxml_use_internal_errors($use_errors);
         if ($errors) {
             throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
         }
     } else {
         $value = null;
     }
     return new FhirResponse($response->getStatus(), $value);
 }
 /**
  * Renders the content of the widget.
  * @throws CException
  */
 public function run()
 {
     // Hide empty breadcrumbs.
     if (empty($this->links)) {
         return;
     }
     $links = array();
     if (!isset($this->homeLink)) {
         $content = CHtml::link(Yii::t('zii', 'Inicio'), Yii::app()->homeUrl);
         $links[] = $this->renderItem($content);
     } else {
         if ($this->homeLink !== false) {
             $links[] = $this->renderItem($this->homeLink);
         }
     }
     foreach ($this->links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             $content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url);
             $links[] = $this->renderItem($content);
         } else {
             $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true);
         }
     }
     echo CHtml::tag('ul', $this->htmlOptions, implode('', $links));
 }
Esempio n. 6
0
 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
 public function checkAccess()
 {
     // Save users last action on this space
     $membership = $this->space->getMembership(Yii::app()->user->id);
     if ($membership != null) {
         $membership->updateLastVisit();
     } else {
         // Super Admin can always enter
         if (!Yii::app()->user->isAdmin()) {
             // Space invisible?
             if ($this->space->visibility == Space::VISIBILITY_NONE) {
                 // Not Space Member
                 throw new CHttpException(404, Yii::t('SpaceModule.behaviors_SpaceControllerBehavior', 'Space is invisible!'));
             }
         }
     }
     // Delete all pending notifications for this space
     $notifications = Notification::model()->findAllByAttributes(array('space_id' => $this->space->id, 'user_id' => Yii::app()->user->id), 'seen != 1');
     foreach ($notifications as $n) {
         // Ignore Approval Notifications
         if ($n->class == "SpaceApprovalRequestNotification" || $n->class == "SpaceInviteNotification") {
             continue;
         }
         $n->seen = 1;
         $n->save();
     }
 }
 protected function makeBuilderPredefinedEmailTemplate($name, $unserializedData, $subject = null, $modelClassName = null, $language = null, $type = null, $isDraft = 0, $textContent = null, $htmlContent = null)
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = $type;
     //EmailTemplate::TYPE_WORKFLOW;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
     $emailTemplate->isDraft = $isDraft;
     $emailTemplate->modelClassName = $modelClassName;
     $emailTemplate->name = $name;
     if (empty($subject)) {
         $subject = $name;
     }
     $emailTemplate->subject = $subject;
     if (!isset($language)) {
         $language = Yii::app()->languageHelper->getForCurrentUser();
     }
     $emailTemplate->language = $language;
     $emailTemplate->htmlContent = $htmlContent;
     $emailTemplate->textContent = $textContent;
     $emailTemplate->serializedData = CJSON::encode($unserializedData);
     $emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
     $saved = $emailTemplate->save(false);
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $emailTemplate = EmailTemplate::getById($emailTemplate->id);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
     $saved = $emailTemplate->save(false);
     assert('$saved');
 }
Esempio n. 9
0
 /**
  *  $controller::$configuration['statusKey'] = 'status' by default
  * $controller::$configuration['statusError'] = 'error' by default
  * $controller::$configuration['resourceKey'] = 'resource' by default
  * $controller::$configuration['errorDescriptionKey'] = 'errorDescription' by default
  * @param string $errorCode is a key of Response::$errorDictionary array.
  * @param array $errorresource null by default. Can be added to specify error body (resource) of response
  * @return array  prepeared to be JSON encoded 
  */
 public static function error($errorCode, $errorresource = null)
 {
     $controller = Yii::app()->controller;
     $errorDescription = self::errorDescription($errorCode);
     self::$response = array($controller::$configuration['statusKey'] => $controller::$configuration['statusError'], $controller::$configuration['statusError'] => array($controller::$configuration['errorCodeKey'] => $errorCode, $controller::$configuration['errorDescriptionKey'] => $errorDescription, $controller::$configuration['resourceKey'] => $errorresource));
     return self::get();
 }
Esempio n. 10
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_EMAIL_INVALID:
                 $this->addError("username", t("Email is incorrect."));
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError("username", t("Username is incorrect."));
                 break;
             case UserIdentity::ERROR_STATUS_NOTACTIV:
                 $this->addError("status", t("You account is not activated."));
                 break;
             case UserIdentity::ERROR_STATUS_BAN:
                 $this->addError("status", t("You account is blocked."));
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError("password", t("Password is incorrect."));
                 break;
         }
     }
 }
Esempio n. 11
0
 protected function getBanners()
 {
     // images at {theme_path}/bnr
     $base_url = Yii::app()->theme->baseUrl;
     // 150x40
     $banners[] = array('link' => 'http://www.adyra.com', 'image' => $base_url . '/bnr/adyra.png');
     //$banners[] = array('link' => 'http://www.grupomoyvesa.com', 'image' => $base_url.'/bnr/moyvesa.png');
     //$banners[] = array('link' => 'http://www.melicar.com', 'image' => $base_url.'/bnr/melicar.png');
     //$banners[] = array('link' => 'http://www.fiateira.com', 'image' => $base_url.'/bnr/fiateira.png');
     $banners[] = array('link' => 'http://www.llantaslandin.com', 'image' => $base_url . '/bnr/landin.png');
     $banners[] = array('link' => 'http://www.grupotrigocar.com', 'image' => $base_url . '/bnr/trigocar.png');
     $banners[] = array('link' => 'http://www.imgautosubastas.com', 'image' => $base_url . '/bnr/imgautosubastas.png');
     $banners[] = array('link' => 'http://www.autosrema.com', 'image' => $base_url . '/bnr/rema.png');
     $banners[] = array('link' => 'http://www.automovilesmlosada.com', 'image' => $base_url . '/bnr/losada.png');
     $banners[] = array('link' => 'http://www.carballeiraautomocion.com', 'image' => $base_url . '/bnr/carballeira.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/monterey.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/mediodia.png');
     $banners[] = array('link' => 'http://www.donsilencioso.com', 'image' => $base_url . '/bnr/donsilencioso.png');
     $banners[] = array('link' => 'http://www.hangar.es', 'image' => $base_url . '/bnr/hangar.png');
     $banners[] = array('link' => 'http://rysservicios.com/', 'image' => $base_url . '/bnr/rys.png');
     // talleresmonterrey
     // talleresmediodia
     // donsilencioso
     shuffle($banners);
     return $banners;
 }
Esempio n. 12
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError('username', Yii::t('lan', 'Username is incorrect.'));
                 break;
             case UserIdentity::ERROR_BANNED:
                 $this->addError('username', Yii::t('lan', 'User is banned.'));
                 break;
             case UserIdentity::ERROR_CONFIRMREGISTRATION:
                 $this->addError('username', Yii::t('lan', 'Confirm user email.'));
                 break;
             default:
                 $this->addError('password', Yii::t('lan', 'Password is incorrect.'));
                 break;
         }
     }
 }
Esempio n. 13
0
 /**
  * Позволяет тонко сконфигурировать грид перед самой отрисовкой
  *
  * @param BeforeGridEvent $event
  */
 public function onBeforeGrid(BeforeGridEvent $event)
 {
     if (isset(Yii::app()->controller->buttons)) {
         foreach (Yii::app()->controller->buttons as $key => $buttonConfig) {
             if (isset($buttonConfig['code']) && $buttonConfig['code'] == 'create') {
                 // Модули - типы создаваемого экземпляра
                 $addButtonData = null;
                 $phpScripts = PhpScript::model()->findAllByAttributes(array('id_php_script_interface' => PhpScript::ID_PHP_SCRIPT_INTERFACE_MODULE));
                 if (count($phpScripts) > 0) {
                     $addButtonData = '<button class="btn navbar-btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>';
                     $addButtonData .= '<ul class="dropdown-menu">' . "\n";
                     foreach ($phpScripts as $phpScript) {
                         /**
                          * @var $phpScript PhpScript
                          */
                         $linkModule = ObjectUrlRule::createUrlFromCurrent(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT_INSTANCE => -1, ObjectUrlRule::PARAM_SYSTEM_MODULE => $phpScript->id_php_script_type));
                         $addButtonData .= "<li><a href='" . $linkModule . "'>" . $phpScript->description . "</a></li>";
                     }
                     $addButtonData .= '</ul>' . "\n";
                 }
                 $buttonConfig['addButtonData'] = $addButtonData;
                 Yii::app()->controller->buttons[$key] = $buttonConfig;
                 break;
             }
         }
     }
 }
 public function up()
 {
     $sql = "SELECT a.id addressId,\n\t\t\t\tp.pro_id as propertyId,\n\t\t\t\tp.pro_addr1,p.pro_addr2,p.pro_addr3,p.pro_addr4,p.pro_addr5,p.pro_postcode,\n\t\t\t\ta.line1,a.line2,a.line3,a.line4,a.line5,a.postcode,\n\n\t\t\t\tconcat_ws(' ', p.pro_addr1, p.pro_addr2, p.pro_addr3, p.pro_addr4, p.pro_addr5, p.pro_postcode) as propertyRecordAddress,\n\t\t\t\tconcat_ws(' ', a.line1,a.line2,a.line3,a.line4,a.line5,a.postcode) as AddressRecord\n\n\t\t\t\tFROM property p\n\t\t\t\tLEFT JOIN address a on p.addressId = a.id\n\t\t\t\tWHERE\n\t\t\t\treplace(concat_ws('', p.pro_addr1, p.pro_addr2, p.pro_addr3, p.pro_addr4, p.pro_addr5, p.pro_postcode), ' ', '') != replace(concat_ws('', a.line1,a.line2,a.line3,a.line4,a.line5,a.postcode), ' ', '')\n\t\t\t\tOR p.addressId is null\n\t\t\t\tOR p.addressId = 0";
     $insertIntoAddress = "\n\t\t\t\tINSERT INTO address SET\n\t\t\t\tline1 = :pro_addr1,\n\t\t\t\tline2 = :pro_addr2,\n\t\t\t\tline3 = :pro_addr3,\n\t\t\t\tline4 = :pro_addr4,\n\t\t\t\tline5 = :pro_addr5,\n\t\t\t\tpostcode = :pro_postcode";
     $updatePropertyAddress = "\n\t\t\t\t\t\t\t\tUPDATE property SET\n\t\t\t\t\t\t\t\tpro_addr1 = :line1,\n\t\t\t\t\t\t\t\tpro_addr2 = :line2,\n\t\t\t\t\t\t\t\tpro_addr3 = :line3,\n\t\t\t\t\t\t\t\tpro_addr4 = :line4,\n\t\t\t\t\t\t\t\tpro_addr5 = :line5,\n\t\t\t\t\t\t\t\tpro_postcode = :postcode\n\t\t\t\t\t\t\t\tWHERE pro_id = :propertyId";
     $updatePropertyAddressId = "UPDATE property SET addressId = :addressId WHERE pro_id = :propertyId";
     $updatePropertyAddressId = Yii::app()->db->createCommand($updatePropertyAddressId);
     $insertIntoAddress = Yii::app()->db->createCommand($insertIntoAddress);
     $updatePropertyAddress = Yii::app()->db->createCommand($updatePropertyAddress);
     //PREPARE QUERIES
     $data = Yii::app()->db->createCommand($sql)->queryAll();
     foreach ($data as $value) {
         if ($value['addressId']) {
             // has address ID => address changed and needs to be synchronized with pro_address
             $updatePropertyAddress->execute(array('line1' => $value['line1'], 'line2' => $value['line2'], 'line3' => $value['line3'], 'line4' => $value['line4'], 'line5' => $value['line5'], 'postcode' => $value['postcode'], 'propertyId' => $value['propertyId']));
         } else {
             if (trim($value['propertyRecordAddress'])) {
                 // has pro_address fields but no related address object.
                 $insertIntoAddress->execute(array('pro_addr1' => $value['pro_addr1'], 'pro_addr2' => $value['pro_addr2'], 'pro_addr3' => $value['pro_addr3'], 'pro_addr4' => $value['pro_addr4'], 'pro_addr5' => $value['pro_addr5'], 'pro_postcode' => $value['pro_postcode']));
                 // set addressID of property to correct value
                 $updatePropertyAddressId->execute(array('addressId' => Yii::app()->db->getLastInsertID(), 'propertyId' => $value['propertyId']));
             }
         }
     }
     return true;
 }
Esempio n. 15
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id;
     echo '</div>';
     /** @var CClientScript $cs */
     $cs = Yii::app()->getClientScript();
     $options = CJavaScript::encode($this->options);
     $cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').modal({$options});");
     // Register the "show" event-handler.
     if (isset($this->events['show'])) {
         $fn = CJavaScript::encode($this->events['show']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.show', "jQuery('#{$id}').on('show', {$fn});");
     }
     // Register the "shown" event-handler.
     if (isset($this->events['shown'])) {
         $fn = CJavaScript::encode($this->events['shown']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.shown', "jQuery('#{$id}').on('shown', {$fn});");
     }
     // Register the "hide" event-handler.
     if (isset($this->events['hide'])) {
         $fn = CJavaScript::encode($this->events['hide']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hide', "jQuery('#{$id}').on('hide', {$fn});");
     }
     // Register the "hidden" event-handler.
     if (isset($this->events['hidden'])) {
         $fn = CJavaScript::encode($this->events['hidden']);
         $cs->registerScript(__CLASS__ . '#' . $id . '.hidden', "jQuery('#{$id}').on('hidden', {$fn});");
     }
 }
 /**
  * @access protected
  * @param  $attribute
  * @param  $value
  * @return CDbCommand
  */
 protected function getSaveEavAttributeCommand($attribute, $value)
 {
     if ($this->getOwner()->asa('AuditBehavior')) {
         $auditId = Yii::app()->auditTracker->id;
         try {
             $userid = Yii::app()->user->id;
         } catch (Exception $e) {
             //If we have no user object, this must be a command line program
             $userid = 0;
         }
         $old = isset($this->dbAttributes[$attribute]) ? $this->dbAttributes[$attribute] : '';
         $new = $value;
         // log in the audit trail
         if ($old != $new) {
             $log = new YdAuditTrail();
             $log->old_value = $old;
             $log->new_value = $new;
             $log->action = 'EAV SAVE';
             $log->model = get_class($this->owner->getAuditModel());
             $log->model_id = $this->owner->getAuditModel()->getPrimaryKey();
             $log->field = $this->tableName . '.' . $attribute;
             $log->created = date('Y-m-d H:i:s');
             $log->user_id = $userid;
             $log->audit_id = $auditId;
             $log->save();
         }
     }
     // return parent
     return parent::getSaveEavAttributeCommand($attribute, $value);
 }
 public function init()
 {
     // enable the KCFINDER uploads
     $KCFINDER = array('disabled' => false, 'uploadURL' => Yii::app()->baseUrl . "/uploads/", 'uploadDir' => Yii::app()->basePath . "/../uploads/");
     Yii::app()->session['KCFINDER'] = $KCFINDER;
     parent::init();
 }
Esempio n. 18
0
 /**
  * Execute the action.
  * @param array $args command line parameters specific for this command
  * @return integer non zero application exit code after printing help
  */
 public function run($args)
 {
     $runner = $this->getCommandRunner();
     $commands = $runner->commands;
     if (isset($args[0])) {
         $name = strtolower($args[0]);
     }
     if (!isset($args[0]) || !isset($commands[$name])) {
         if (!empty($commands)) {
             echo "Yii command runner (based on Yii v" . Yii::getVersion() . ")\n";
             echo "Usage: " . $runner->getScriptName() . " <command-name> [parameters...]\n";
             echo "\nThe following commands are available:\n";
             $commandNames = array_keys($commands);
             sort($commandNames);
             echo ' - ' . implode("\n - ", $commandNames);
             echo "\n\nTo see individual command help, use the following:\n";
             echo "   " . $runner->getScriptName() . " help <command-name>\n";
         } else {
             echo "No available commands.\n";
             echo "Please define them under the following directory:\n";
             echo "\t" . Yii::app()->getCommandPath() . "\n";
         }
     } else {
         echo $runner->createCommand($name)->getHelp();
     }
     return 1;
 }
Esempio n. 19
0
 public function run()
 {
     // Незачем выполнять последующие действия
     // для авторизованного пользователя:
     if (Yii::app()->user->isAuthenticated()) {
         $this->controller->redirect(Yii::app()->getUser()->getReturnUrl());
     }
     $module = Yii::app()->getModule('user');
     // Если восстановление отключено - ошбочка ;)
     if ($module->recoveryDisabled) {
         throw new CHttpException(404, Yii::t('UserModule.user', 'requested page was not found!'));
     }
     // Новая форма восстановления пароля:
     $form = new RecoveryForm();
     if (($data = Yii::app()->getRequest()->getPost('RecoveryForm')) !== null) {
         $form->setAttributes($data);
         if ($form->validate() && Yii::app()->userManager->passwordRecovery($form->email)) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'Letter with password recovery instructions was sent on email which you choose during register'));
             $this->controller->redirect(array('/user/account/backendlogin'));
         } else {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'Password recovery error.'));
         }
     }
     $this->controller->render('recovery', array('model' => $form));
 }
Esempio n. 20
0
 /**
  * Create the links for resources in the resource root
  * @return array the links, name => config
  */
 protected function createLinks()
 {
     $app = \Yii::app();
     /* @var \Restyii\Web\Application $app */
     $controller = $this->getController();
     $module = $controller->getModule();
     if (!$module) {
         $module = $app;
     }
     $controllers = $app->getSchema()->getControllerInstances($module);
     /* @var \Restyii\Controller\Base[]|\CController[] $controllers */
     $links = array('self' => array('title' => $module->name, 'href' => trim($app->getBaseUrl(), '/') . '/'));
     foreach ($controllers as $id => $controller) {
         if ($id === $module->defaultController) {
             continue;
         }
         $links[$id] = array('title' => method_exists($controller, 'classLabel') ? $controller->classLabel(true) : String::pluralize(String::humanize(substr(get_class($controller), 0, -10))), 'href' => $controller->createUrl('search'));
         if (method_exists($controller, 'classDescription')) {
             $links[$id]['description'] = $controller->classDescription();
         }
         if (isset($controller->modelClass)) {
             $links[$id]['profile'] = array($controller->modelClass);
         }
     }
     return $links;
 }
 /**
  * Render a test button. This link calls a modal
  * popup.
  * @return The element's content as a string.
  */
 protected function renderTestButton()
 {
     $content = '<span>';
     $content .= ZurmoHtml::ajaxLink(ZurmoHtml::tag('span', array('class' => 'z-label'), Zurmo::t('ZurmoModule', 'Test Connection')), Yii::app()->createUrl('zurmo/ldap/testConnection/', array()), static::resolveAjaxOptionsForTestLdapConnection($this->form->getId()), array('id' => 'TestLdapConnectionButton', 'class' => 'LdapTestingButton z-button'));
     $content .= '</span>';
     return $content;
 }
Esempio n. 22
0
 /**
  * Initializes the application component.
  * This method overrides the parent implementation by setting default cache key prefix.
  */
 public function init()
 {
     parent::init();
     if ($this->keyPrefix === null) {
         $this->keyPrefix = Yii::app()->getId();
     }
 }
Esempio n. 23
0
 protected function performAjaxValidation($model)
 {
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'create-category-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
 }
Esempio n. 24
0
 public function afterSave()
 {
     parent::afterSave();
     $sql = "UPDATE p_nfy_subscription_categories " . "set category = 'role_{$this->role_name}.' " . "where category = 'role_{$this->oldName}.';";
     Yii::app()->db->createCommand($sql)->execute();
     return true;
 }
Esempio n. 25
0
 protected function showGeneralForm()
 {
     $model = new SettingGeneralForm();
     settings()->deleteCache();
     //Set Value for the Settings
     $model->site_name = Yii::app()->settings->get('general', 'site_name');
     $model->site_title = Yii::app()->settings->get('general', 'site_title');
     $model->site_description = Yii::app()->settings->get('general', 'site_description');
     $model->slogan = Yii::app()->settings->get('general', 'slogan');
     $model->homepage = Yii::app()->settings->get('general', 'homepage');
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'settings-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['SettingGeneralForm'])) {
         $model->attributes = $_POST['SettingGeneralForm'];
         if ($model->validate()) {
             settings()->deleteCache();
             foreach ($model->attributes as $key => $value) {
                 Yii::app()->settings->set('general', $key, $value);
             }
             user()->setFlash('success', t('General Settings Updated Successfully!'));
         }
     }
     $this->render('cmswidgets.views.settings.settings_general_widget', array('model' => $model));
 }
Esempio n. 26
0
 public function actionProject()
 {
     $form = "";
     if (Yii::app()->getRequest()->ispostRequest) {
         $project_des = Yii::app()->request->getParam('project_des');
         $project_price = Yii::app()->request->getParam('project_price');
         $project_name = Yii::app()->request->getParam('project_name');
         $project_type = Yii::app()->request->getParam('project_type');
         $project_time = Yii::app()->request->getParam('project_time');
         if ($project_des != '') {
             Yii::app()->session['project_des'] = Yii::app()->request->getParam('project_des');
         }
         if ($project_name != '') {
             Yii::app()->session['project_name'] = Yii::app()->request->getParam('project_name');
         }
         if ($project_price != '') {
             Yii::app()->session['project_price'] = Yii::app()->request->getParam('project_price');
         }
         if ($project_type != '') {
             Yii::app()->session['project_type'] = Yii::app()->request->getParam('project_type');
         }
         if ($project_time != '') {
             Yii::app()->session['project_time'] = Yii::app()->request->getParam('project_time');
         }
         echo 'success!';
     }
     $this->renderPartial('_project', compact("form"), false, true);
 }
Esempio n. 27
0
 /**
  * @param Order $order
  */
 public function sendOrderChangesNotify(Order $order)
 {
     $theme = Yii::t('OrderModule.order', 'Order #{n} in {site} store is changed', ['{n}' => $order->id, '{site}' => Yii::app()->getModule('yupe')->siteName]);
     $from = $this->module->notifyEmailFrom ?: Yii::app()->getModule('yupe')->email;
     $body = $this->view->renderPartial('/order/email/orderChangeStatus', ['order' => $order], true);
     $this->mail->send($from, $order->email, $theme, $body);
 }
 public function redirect($url, $terminate = true, $statusCode = 302)
 {
     $this->setHeader('Location', $url);
     if ($terminate) {
         Yii::app()->end(0, false);
     }
 }
 public function actionView()
 {
     $radioId = Yii::app()->request->getParam("id", 0);
     $radioName = WapRadioModel::model()->findByPk($radioId)->name;
     $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id");
     $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1');
     $album = WapAlbumModel::model()->published()->findByPk($albumId);
     if (!$album) {
         $this->forward("/site/error", true);
     }
     $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
     $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
     $phone = yii::app()->user->getState('msisdn');
     $errorCode = 'success';
     $errorDescription = '';
     $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     ///meta tag
     $AlbumDetail = AlbumModel::model()->findByPk($albumId);
     $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
     $ArtistInfo = ArtistModel::model()->findByPk($artistId);
     $this->itemName = $AlbumDetail->name;
     $this->artist = $ArtistInfo->name;
     $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
     $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
     $this->description = strip_tags($AlbumDetail->description);
     //get other radio
     $parent_id = Yii::app()->params['horoscope']['parent_id'];
     $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id);
     $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar));
 }
Esempio n. 30
0
 public function run()
 {
     echo date('Y-m-d H:i:s') . " [Quotation] start \n";
     Yii::app()->getComponent('log');
     Yii::log(date('Y-m-d H:i:s') . " [Quotation] start", 'info', 'command');
     $time = $_SERVER['REQUEST_TIME'];
     $failuretime = 3600 * 24 * 2;
     //2天
     $t = $time - $failuretime;
     //无询价单的报价单失效
     $quosql = 'update `pap_quotation` set Status="5" where IfSend="2" and CreateTime<' . $t . ' and Status="1" and InquiryID=0';
     $quocount = Yii::app()->papdb->CreateCommand($quosql)->execute();
     Yii::log(date('Y-m-d H:i:s') . " The quotation " . $quocount . " total failure(not inq)" . " [Quotation] end \n", 'info', 'command');
     //根据询价单发送的报价单(已报价未确认或拒绝)
     $inq = 'update `pap_inquiry` set Status="5" where Status=1 and InquiryID in( select InquiryID from `pap_quotation` ' . 'where IfSend="2" and CreateTime<' . $t . ' and Status="1" and InquiryID!=0)';
     $inqcount_quo = Yii::app()->papdb->CreateCommand($inq)->execute();
     Yii::log(date('Y-m-d H:i:s') . " The inquiry " . $inqcount_quo . " total failure(have quo)" . " [Quotation] end \n", 'info', 'command');
     $quosql_inq = 'update `pap_quotation` set Status="5" where CreateTime<' . $t . ' and Status="1" and InquiryID!=0';
     $quocount_inq = Yii::app()->papdb->CreateCommand($quosql_inq)->execute();
     Yii::log(date('Y-m-d H:i:s') . " The quotation " . $quocount_inq . " total failure(have inq)" . " [Quotation] end \n", 'info', 'command');
     //询价单失效(未报价)
     $inqsql = 'update `pap_inquiry` set Status="5" where  CreateTime<' . $t . ' and Status=0';
     $inqcount = Yii::app()->papdb->CreateCommand($inqsql)->execute();
     Yii::log(date('Y-m-d H:i:s') . " The inquiry " . $inqcount . " total failure(not quo)" . " [Quotation] end \n", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [Quotation] end \n";
 }