当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsUser::setUPS方法代码示例

本文整理汇总了PHP中cmsUser::setUPS方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::setUPS方法的具体用法?PHP cmsUser::setUPS怎么用?PHP cmsUser::setUPS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsUser的用法示例。


在下文中一共展示了cmsUser::setUPS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run


//.........这里部分代码省略.........
                     unset($user[$field['name']]);
                 }
             }
         }
         $errors = $form->validate($this, $user);
         if (!$errors) {
             //
             // проверяем код приглашения
             //
             if ($this->options['is_reg_invites']) {
                 $invite = $this->model->getInviteByCode($user['inv']);
                 if (!$invite) {
                     $errors['inv'] = LANG_REG_WRONG_INVITE_CODE;
                 } else {
                     if ($this->options['is_invites_strict'] && $invite['email'] != $user['email']) {
                         $errors['inv'] = LANG_REG_WRONG_INVITE_CODE_EMAIL;
                     } else {
                         $user['inviter_id'] = $invite['user_id'];
                     }
                 }
             }
             //
             // проверяем допустимость e-mail, имени и IP
             //
             if (!$this->isEmailAllowed($user['email'])) {
                 $errors['email'] = sprintf(LANG_AUTH_RESTRICTED_EMAIL, $user['email']);
             }
             if (!$this->isNameAllowed($user['nickname'])) {
                 $errors['nickname'] = sprintf(LANG_AUTH_RESTRICTED_NAME, $user['nickname']);
             }
             if (!$this->isIPAllowed(cmsUser::get('ip'))) {
                 cmsUser::addSessionMessage(sprintf(LANG_AUTH_RESTRICTED_IP, cmsUser::get('ip')), 'error');
                 $errors = true;
             }
         }
         //
         // Проверяем капчу
         //
         if (!$errors && $this->options['reg_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
             if (!$is_captcha_valid) {
                 $errors = true;
                 cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
             }
         }
         if (!$errors) {
             unset($user['inv']);
             //
             // Блокируем пользователя, если включена верификация e-mail
             //
             if ($this->options['verify_email']) {
                 $user = array_merge($user, array('is_locked' => true, 'lock_reason' => LANG_REG_CFG_VERIFY_LOCK_REASON, 'pass_token' => string_random(32, $user['email']), 'date_token' => ''));
             }
             $result = $users_model->addUser($user);
             if ($result['success']) {
                 $user['id'] = $result['id'];
                 cmsUser::addSessionMessage(LANG_REG_SUCCESS, 'success');
                 cmsUser::setUPS('first_auth', 1, $user['id']);
                 // отправляем письмо верификации e-mail
                 if ($this->options['verify_email']) {
                     $this->options['verify_exp'] = empty($this->options['verify_exp']) ? 48 : $this->options['verify_exp'];
                     $messenger = cmsCore::getController('messages');
                     $to = array('email' => $user['email'], 'name' => $user['nickname']);
                     $letter = array('name' => 'reg_verify');
                     $messenger->sendEmail($to, $letter, array('nickname' => $user['nickname'], 'page_url' => href_to_abs('auth', 'verify', $user['pass_token']), 'pass_token' => $user['pass_token'], 'valid_until' => html_date(date('d.m.Y H:i', time() + $this->options['verify_exp'] * 3600), true)));
                     cmsUser::addSessionMessage(sprintf(LANG_REG_SUCCESS_NEED_VERIFY, $user['email']), 'info');
                 } else {
                     cmsEventsManager::hook('user_registered', $user);
                     // авторизуем пользователя автоматически
                     if ($this->options['reg_auto_auth']) {
                         $logged_id = cmsUser::login($user['email'], $user['password1']);
                         if ($logged_id) {
                             cmsEventsManager::hook('auth_login', $logged_id);
                         }
                     }
                 }
                 $back_url = cmsUser::sessionGet('auth_back_url') ? cmsUser::sessionGet('auth_back_url', true) : false;
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirect($this->getAuthRedirectUrl($this->options['first_auth_redirect']));
                 }
             } else {
                 $errors = $result['errors'];
             }
         }
         if ($errors && $is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     // Капча
     if ($this->options['reg_captcha']) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     // запоминаем откуда пришли на регистрацию
     if (empty($errors) && $this->options['first_auth_redirect'] == 'none') {
         cmsUser::sessionSet('auth_back_url', $this->getBackURL());
     }
     return $this->cms_template->render('registration', array('user' => $user, 'form' => $form, 'captcha_html' => isset($captcha_html) ? $captcha_html : false, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:101,代码来源:register.php

示例2: run

 public function run($ctype_id, $parent_id)
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $content_model = cmsCore::getModel('content');
     $ctype = $content_model->getContentType($ctype_id);
     if (!$ctype) {
         $this->halt();
     }
     $category = $content_model->getCategory($ctype['name'], $parent_id);
     if (!$category) {
         $this->halt();
     }
     $grid = $this->loadDataGrid('content_items', $ctype['name']);
     $filter = array();
     $filter_str = $this->request->get('filter');
     // Одновременно смениться и тип контента, и настройка diff_order не могут
     $diff_order = cmsUser::getUPS('admin.grid_filter.content.diff_order');
     if ($filter_str && mb_strpos($filter_str, 'ctype_changed=1') !== false && $diff_order) {
         // Изменён тип контента и должна быть сохранена сортировка
         // Проверим, что эта сортировка есть в бд, иначе будет использоваться пришедшая
         $ups_filter_str = cmsUser::getUPS('admin.grid_filter.content.' . $ctype['name']);
         if ($ups_filter_str) {
             $filter_str = $ups_filter_str;
         }
         // Чтобы заполнить поля поиска фильтра
         $grid['options']['load_columns'] = true;
     } else {
         $filter_str = cmsUser::getUPSActual('admin.grid_filter.content.' . $ctype['name'], $filter_str);
     }
     if ($filter_str) {
         parse_str($filter_str, $filter);
         if (!empty($filter['advanced_filter'])) {
             parse_str($filter['advanced_filter'], $dataset_filters);
             if (!empty($dataset_filters['dataset'])) {
                 $dataset_id = $dataset_filters['dataset'];
                 $dataset = $content_model->getContentDataset($dataset_id);
                 $content_model->applyDatasetFilters($dataset, true);
             }
             $content_model->applyDatasetFilters($dataset_filters);
             // Различная сортировка у разных типов контента, сохранение настройки
             $new_diff_order = !empty($dataset_filters['diff_order']) ? '1' : '0';
             if ($new_diff_order !== $diff_order) {
                 cmsUser::setUPS('admin.grid_filter.content.diff_order', $new_diff_order);
             }
         }
         $content_model->applyGridFilter($grid, $filter);
         // В случае обновления 'columns' грида для заполнения полей фильтров
         $grid['filter'] = $filter;
     }
     $content_model->filterCategory($ctype['name'], $category, $ctype['is_cats_recursive']);
     $content_model->disableApprovedFilter();
     $content_model->disablePubFilter();
     $total = $content_model->getContentItemsCount($ctype['name']);
     $perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage;
     $pages = ceil($total / $perpage);
     $content_model->setPerPage($perpage);
     $items = $content_model->getContentItems($ctype['name']);
     cmsTemplate::getInstance()->renderGridRowsJSON($grid, $items, $total, $pages);
     $this->halt();
 }
开发者ID:roman-burachenko,项目名称:icms2,代码行数:62,代码来源:content_items_ajax.php


注:本文中的cmsUser::setUPS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。