public function init()
 {
     parent::init();
     if (!$this->items) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
     }
 }
 public function actionEdit($id)
 {
     $this->pageTitle = Yii::t('app', 'Редактирование категории');
     $model = ShopCategories::model()->findByPk($id);
     if (!$model) {
         throw new CHttpException(404, Yii::t('app', 'Категория не найдена'));
     }
     //var_dump($model->url);die;
     // var_dump($model->path);die;
     //var_dump($model->breadcrumbs);
     //die;
     $this->breadcrumbs = array_merge($this->breadcrumbs, array('Редактирование категории "' . $model->title . '"'));
     $possibleParents = $model->getPossibleParents();
     if (!empty($_POST) && array_key_exists('ShopCategories', $_POST)) {
         $this->performAjaxValidation($model);
         $model->attributes = $_POST['ShopCategories'];
         //var_dump($model->attributes);die;
         if ($model->validate()) {
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', 'Категория "' . $model->title . '" успешно отредактирована');
                 Yii::app()->request->redirect($this->createUrl('index'));
             }
         }
     }
     //var_dump($possibleParents);die;
     $this->render('edit', array('model' => $model, 'possibleParents' => $possibleParents));
 }
 /**
  * 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));
 }
Exemple #4
0
 public function run()
 {
     if (Yii::app()->user->isAuthenticated()) {
         $this->controller->redirect(Url::redirectUrl(Yii::app()->getUser()->getReturnUrl()));
     }
     /**
      * Если было совершено больше 3х попыток входа
      * в систему, используем сценарий с капчей:
      **/
     $badLoginCount = Yii::app()->authenticationManager->getBadLoginCount(Yii::app()->getUser());
     $module = Yii::app()->getModule('user');
     $scenario = $badLoginCount > (int) $module->badLoginCount ? LoginForm::LOGIN_LIMIT_SCENARIO : '';
     $form = new LoginForm($scenario);
     if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['LoginForm'])) {
         $form->setAttributes(Yii::app()->getRequest()->getPost('LoginForm'));
         if ($form->validate() && Yii::app()->authenticationManager->login($form, Yii::app()->getUser(), Yii::app()->getRequest())) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'You authorized successfully!'));
             if (Yii::app()->getUser()->isSuperUser() && $module->loginAdminSuccess) {
                 $redirect = $module->loginAdminSuccess;
             } else {
                 $redirect = empty($module->loginSuccess) ? Yii::app()->getBaseUrl() : $module->loginSuccess;
             }
             $redirect = Yii::app()->getUser()->getReturnUrl($redirect);
             Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), 0);
             $this->controller->redirect(Url::redirectUrl($redirect));
         } else {
             $form->addError('email', Yii::t('UserModule.user', 'Email or password was typed wrong!'));
             Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), $badLoginCount + 1);
         }
     }
     $this->controller->render($this->id, array('model' => $form));
 }
Exemple #5
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             Comment::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Comment::model()->updateAll(['status' => Comment::STATUS_SHOW], $criteria);
             break;
         case 'hide':
             //隐藏
             Comment::model()->updateAll(['status' => Comment::STATUS_HIDE], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
 public function checkEmail($attribute, $params)
 {
     $model = User::model()->find('email = :email', array(':email' => $this->{$attribute}));
     if ($model) {
         $this->addError('email', Yii::t('UserModule.user', 'Email already busy'));
     }
 }
 public function loadModel($id)
 {
     if (($model = DictionaryGroup::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('DictionaryModule.dictionary', 'Requested page was not found'));
     }
     return $model;
 }
 public function getHint()
 {
     if ($this->owner->isNewRecord || !$this->file) {
         return '';
     }
     return Html::a(Yii::t('app', 'View attached file'), $this->fileUrl, ['target' => '_blank']);
 }
 public function init()
 {
     $this->name = \Yii::t('skeeks/shop/app', 'Delivery services');
     $this->modelShowAttribute = "name";
     $this->modelClassName = ShopDelivery::className();
     parent::init();
 }
 /**
  * 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));
 }
Exemple #11
0
 public function init()
 {
     $data = array('content' => array(), 'error' => Yii::t('main', 'Модуль отключен.'));
     if (config('forum_threads.allow') == 1) {
         $data = cache()->get(CacheNames::FORUM_THREADS);
         if ($data === FALSE) {
             $data = array();
             try {
                 // Подключаюсь к БД
                 $this->db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'), 'enableProfiling' => YII_DEBUG, 'enableParamLogging' => TRUE, 'username' => config('forum_threads.db_user'), 'password' => config('forum_threads.db_pass'), 'charset' => 'utf8', 'emulatePrepare' => TRUE, 'tablePrefix' => config('forum_threads.prefix')));
                 app()->setComponent('ForumThreadsDb', $this->db);
                 $forumType = config('forum_threads.type');
                 if (method_exists($this, $forumType)) {
                     $data['content'] = $this->{$forumType}();
                     foreach ($data['content'] as $k => $v) {
                         $data['content'][$k]['user_link'] = $this->getUserLink($v['starter_id'], $v['starter_name']);
                         $data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']);
                         $data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']);
                     }
                     if (config('forum_threads.cache')) {
                         cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60);
                     }
                 } else {
                     $data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>'));
                 }
             } catch (Exception $e) {
                 $data['error'] = $e->getMessage();
             }
         }
     }
     app()->controller->renderPartial('//forum-threads', $data);
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionEdit()
 {
     $model = $this->loadUser();
     $profile = $model->profile;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->image = CUploadedFile::getInstance($model, 'image');
         $profile->attributes = $_POST['Profile'];
         if ($model->validate() && $profile->validate()) {
             $model->save();
             $profile->save();
             Yii::app()->user->updateSession();
             Yii::app()->user->setFlash('profileMessage', Yii::t('main', "Data saved successfully!"));
             $this->redirect(array('/user/profile'));
         } else {
             $profile->validate();
         }
     }
     $this->render('edit', array('model' => $model, 'profile' => $profile));
 }
 /**
  * Specifies the access control rules.
  * This method is used by the 'accessControl' filter.
  * @return array access control rules
  */
 public function accessRules()
 {
     if (!Yii::app()->user->checkAccess(Yii::app()->controller->action->id)) {
         throw new CHttpException(401, Yii::t('mds', 'You are prohibited to access this page. Contact Super Administrator'));
     }
     return array(array('allow', 'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete', 'print', 'details', 'bayar', 'PrintDetails', 'bayarkan'), 'users' => array('@')), array('deny', 'users' => array('*')));
 }
 public function handleRequest($request)
 {
     if (empty($this->catchAll)) {
         list($route, $params) = $request->resolve();
     } else {
         $route = $this->catchAll[0];
         $params = array_splice($this->catchAll, 1);
     }
     try {
         LuLu::trace("Route requested: '{$route}'", __METHOD__);
         $this->requestedRoute = $route;
         $actionsResult = $this->runAction($route, $params);
         $result = $actionsResult instanceof ActionResult ? $actionsResult->result : $actionsResult;
         if ($result instanceof \yii\web\Response) {
             return $result;
         } else {
             $response = $this->getResponse();
             if ($result !== null) {
                 $response->data = $result;
             }
             return $response;
         }
     } catch (InvalidRouteException $e) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
     }
 }
 public function init()
 {
     $this->name = \Yii::t('skeeks/shop/app', 'Order statuses');
     $this->modelShowAttribute = "name";
     $this->modelClassName = ShopOrderStatus::className();
     parent::init();
 }
Exemple #16
0
    public function init()
    {
        $this->close = Yii::t('cp', 'Close');
        $this->min = Yii::t('cp', 'Min');
        $this->max = Yii::t('cp', 'Max');
        $r = <<<EOT
    <table class="mac_panel">
       <tr class="panel_top">
        <td class="left"></td> 
        <td class="middle drag_handle">
          <span class="title">{$this->title}</span>
        </td>
        <td class="left_ct" >
          <span class="ct close" title="{$this->close}"></span>
          <!--<span class="ct min" title="{$this->min}"></span>-->
          <span class="ct max" title="{$this->max}"></span>
        </td>
        <td class="right"></td>
      </tr>
    </table>
    \t<!-- mac panel middle start -->
     <table class="mac_panel" id="content">
       <tr class="panel_middle">
         <td class="left"></td>
         <td class="middle">        
EOT;
        echo $r;
    }
Exemple #17
0
 /**
  * @param string $value directory for storing log files.
  * @throws CException if the path is invalid
  */
 public function setLogPath($value)
 {
     $this->_logPath = realpath($value);
     if ($this->_logPath === false || !is_dir($this->_logPath) || !is_writable($this->_logPath)) {
         throw new CException(Yii::t('yii', 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.', array('{path}' => $value)));
     }
 }
Exemple #18
0
 /**
  * Renders the content of the widget.
  */
 public function run()
 {
     $links = array();
     if ($this->homeLink === null || !(isset($this->homeLink['label']) && isset($this->homeLink['url']))) {
         $this->homeLink = array('label' => Yii::t('bootstrap', 'Home'), 'url' => Yii::app()->homeUrl);
     }
     if (!empty($this->links)) {
         $content = CHtml::link($this->homeLink['label'], $this->homeLink['url']);
         $links[] = $this->renderItem($content);
     } else {
         $links[] = $this->renderItem($this->homeLink['label'], true);
     }
     foreach ($this->links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             $label = $this->encodeLabel ? CHtml::encode($label) : $label;
             $content = CHtml::link($label, $url);
             $links[] = $this->renderItem($content);
         } else {
             $links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true);
         }
     }
     echo CHtml::openTag('ul', $this->htmlOptions);
     echo implode('', $links);
     echo '</ul>';
 }
 /**
  * Displays a particular model.
  */
 public function actionView($id)
 {
     $this->layout = '//layouts/templates/admin';
     $model = System::loadModel('User', $id);
     $this->seo(Yii::t('admin', 'View user') . ' ' . $model->username);
     $this->render('view', array('model' => $model));
 }
Exemple #20
0
 public function login($identity, $duration = 0)
 {
     if (!$this->_checkMod($identity->role)) {
         return false;
     }
     //::app()->session['loginrole']=$identity->role;
     //var_dump(Yii::app()->session);exit;
     $id = $identity->getId();
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($id, $states, false)) {
         $this->changeIdentity($id, $identity->getName(), get_object_vars($identity));
         if ($duration > 0) {
             if ($this->allowAutoLogin) {
                 $this->saveToCookie($duration);
             } else {
                 throw new CException(Yii::t('yii', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
             }
         }
         if ($this->absoluteAuthTimeout) {
             $this->setState(self::AUTH_ABSOLUTE_TIMEOUT_VAR, time() + $this->absoluteAuthTimeout);
         }
         $this->afterLogin(false);
     }
     return !$this->getIsGuest();
 }
Exemple #21
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     $this->_identity = new UserIdentity($this->username, $this->password);
     if (!$this->_identity->authenticate()) {
         $this->addError('password', Yii::t('cp', 'Incorrect username or password.'));
     }
 }
 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();
     }
 }
 /**
  * filterUserAdminControl 
  * 
  * @param mixed $filterChain 
  * @return void
  */
 public function filterUserAdminControl($filterChain)
 {
     // Get login action url
     if (is_array(Yii::app()->user->loginUrl)) {
         $loginUrl = trim(Yii::app()->user->loginUrl[0], '/');
     } else {
         $loginUrl = trim(Yii::app()->user->loginUrl, '/');
     }
     $errorAction = trim(Yii::app()->errorHandler->errorAction, '/');
     // If it's not error or login action
     if (strtolower($this->route) === strtolower($loginUrl) or strtolower($this->route) === strtolower($errorAction)) {
         $filterChain->run();
     } elseif ($this->freeAccess === true or in_array($this->action->id, $this->freeAccessActions)) {
         $filterChain->run();
     } elseif (Yii::app()->user->isGuest) {
         if ($this->_isRouteAllowed($this->_getGuestAllowedRoutes())) {
             $filterChain->run();
         } else {
             Yii::app()->user->returnUrl = array('/' . $this->route);
             $this->redirect(Yii::app()->user->loginUrl);
         }
     } elseif (User::checkRole('isSuperAdmin')) {
         $filterChain->run();
     } else {
         if ($this->_isRouteAllowed(array_merge($this->_getAllowedUserRoutes(), $this->_getGuestAllowedRoutes()))) {
             $filterChain->run();
         } else {
             throw new CHttpException(403, Yii::t("UserAdminModule.front", "You are not authorized to perform this action."));
         }
     }
 }
 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));
 }
 /**
  * @return array the config array passed to widget ()
  */
 public function getGridViewConfig()
 {
     if (!isset($this->_gridViewConfig)) {
         $this->_gridViewConfig = array_merge(parent::getGridViewConfig(), array('moduleName' => 'Accounts', 'defaultGvSettings' => array('gvCheckbox' => 30, 'name' => 184, 'type' => 153, 'phone' => 115), 'specialColumns' => array('name' => array('name' => 'name', 'header' => Yii::t('accounts', 'Name'), 'value' => '$data->link', 'type' => 'raw'))));
     }
     return $this->_gridViewConfig;
 }
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of eAccelerator.
  * @throws CException if eAccelerator extension is not loaded, is disabled or the cache functions are not compiled in.
  */
 public function init()
 {
     parent::init();
     if (!function_exists('eaccelerator_get')) {
         throw new CException(Yii::t('yii', 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.'));
     }
 }
Exemple #27
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;
         }
     }
 }
Exemple #28
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);
 }
Exemple #29
0
 public function login()
 {
     $login = parent::getLogin();
     $password = parent::getPassword();
     $identity = new AdminIdentity($login, $password);
     $identity->authenticate();
     switch ($identity->errorCode) {
         case AdminIdentity::ERROR_USERNAME_INVALID:
         case AdminIdentity::ERROR_PASSWORD_INVALID:
             $this->addError('login', Yii::t('backend', 'Аккаунт не найден.'));
             break;
         case AdminIdentity::ERROR_STATUS_BANNED:
             $this->addError('login', Yii::t('backend', 'Аккаунт забанен.'));
             break;
         case AdminIdentity::ERROR_STATUS_INACTIVE:
             $this->addError('login', Yii::t('backend', 'Аккаунт не активирован.'));
             break;
         case AdminIdentity::ERROR_STATUS_IP_NO_ACCESS:
             $this->addError('login', Yii::t('backend', 'Доступ к аккаунту для вашего IP запрещён.'));
             break;
         default:
             $duration = 3600 * 24 * 7;
             // 7 days
             admin()->login($identity, $duration);
             return TRUE;
     }
     return FALSE;
 }
Exemple #30
-1
 /**
  * Initializes this application component.
  * This method is required by the {@link IApplicationComponent} interface.
  * It checks the availability of Zend Data Cache.
  * @throws CException if Zend Data Cache extension is not loaded.
  */
 public function init()
 {
     parent::init();
     if (!function_exists('zend_shm_cache_store')) {
         throw new CException(Yii::t('yii', 'CZendDataCache requires PHP Zend Data Cache extension to be loaded.'));
     }
 }