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


PHP UserHelper::isUser方法代码示例

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


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

示例1: act_add_user

 public function act_add_user()
 {
     // var_dump($_POST);
     include_once APPROOT . 'inc/lib_form.inc';
     include_once APPROOT . 'inc/lib_form_util.inc';
     include_once APPROOT . 'inc/lib_validate.inc';
     include_once APPROOT . 'inc//security/lib_auth.inc';
     include_once 'lib_user.inc';
     $this->user_form = user_get_form();
     if (isset($_POST['save'])) {
         $valide = true;
         $username = $_POST['username'];
         $password1 = $_POST['password1'];
         $password2 = $_POST['password2'];
         $firstName = $_POST['first_name'];
         $lastName = $_POST['last_name'];
         $organization = $_POST['organization'];
         $designation = $_POST['designation'];
         $email = $_POST['email'];
         $address = $_POST['address'];
         $role = $_POST['role'];
         $status = $_POST['status'];
         $locale = $_POST['locale'];
         $user_form = $this->user_form;
         if (trim($username) == '') {
             $user_form['username']['extra_opts'] = array();
             $user_form['username']['extra_opts']['error'] = array();
             $user_form['username']['extra_opts']['error'][] = _t("USERNAME_CANNOT_BE_EMPTY");
             $user_form['username']['extra_opts']['required'][] = true;
             $valide = false;
         }
         if (UserHelper::isUser($username)) {
             $user_form['username']['extra_opts'] = array();
             $user_form['username']['extra_opts']['error'] = array();
             $user_form['username']['extra_opts']['error'][] = _t("USERNAME_ALREADY_EXISTS__USE_A_DIFFERENT_USERNAME");
             $user_form['username']['extra_opts']['required'][] = true;
             $valide = false;
         }
         if (trim($password1) == '') {
             $user_form['password1']['extra_opts'] = array();
             $user_form['password1']['extra_opts']['error'] = array();
             $user_form['password1']['extra_opts']['error'][] = _t("PASSWORD_REQUIRED");
             $user_form['password1']['extra_opts']['required'][] = true;
             $valide = false;
         }
         if (trim($password2) == '') {
             $user_form['password2']['extra_opts'] = array();
             $user_form['password2']['extra_opts']['error'] = array();
             $user_form['password2']['extra_opts']['error'][] = _t("PASSWORD_REQUIRED");
             $user_form['password2']['extra_opts']['required'][] = true;
             $valide = false;
         }
         if ($password1 != $password2) {
             $user_form['password2']['extra_opts'] = array();
             $user_form['password2']['extra_opts']['error'] = array();
             $user_form['password2']['extra_opts']['error'][] = _t("PASSWORD_MISMATCH");
             $user_form['password2']['extra_opts']['required'][] = true;
             $valide = false;
         }
         if (true) {
             //password match policy
         }
         if ($email != '' && !shn_valid_email($email)) {
             //email not valide
             $user_form['email']['extra_opts'] = array();
             $user_form['email']['extra_opts']['error'] = array();
             $user_form['email']['extra_opts']['error'][] = _t("INVALID_EMAIL_ADDRESS");
             $valide = false;
         }
         $status = $status == 'active' || $status == 'disable' ? $status : 'disable';
         $this->user_form = $user_form;
         if ($valide == true) {
             $userProfile = new UserProfile();
             $userProfile->username = $username;
             $userProfile->first_name = $firstName;
             $userProfile->last_name = $lastName;
             $userProfile->organization = $organization;
             $userProfile->designation = $designation;
             $userProfile->email = $email;
             $userProfile->address = $address;
             //$userProfile->Save();
             $userConfig = array();
             $userConfig['locale'] = $locale;
             shn_auth_add_user($username, $password1, $role, $userProfile, $status, $userConfig);
             set_redirect_header('admin', 'user_management');
         }
     }
 }
开发者ID:GeraldScott,项目名称:OpenEvSys,代码行数:88,代码来源:adminModule.class.php

示例2: act_permissions

 public function act_permissions()
 {
     $gacl_api = acl_get_gacl_api();
     $this->roles = acl_get_roles();
     if (isset($_POST['update'])) {
         foreach ($this->roles as $role_val => $role_name) {
             if ($role_val == 'admin') {
                 continue;
             }
             $acl_id = $gacl_api->search_acl('access', 'access', FALSE, FALSE, $role_name, 'events', $this->event->event_record_number, FALSE, FALSE);
             if (isset($_POST['roles']) && in_array($role_val, $_POST['roles'])) {
                 if (count($acl_id) == 0) {
                     $aro_grp = $gacl_api->get_group_id($role_val, $role_name, 'ARO');
                     $return = $gacl_api->add_acl(array('access' => array('access')), null, array($aro_grp), array('events' => array($this->event->event_record_number)), null, 1);
                 }
             } else {
                 $gacl_api->del_acl($acl_id[0]);
             }
         }
         set_redirect_header('events', 'permissions');
     }
     if (isset($_POST['add_user']) && $_POST['add_user'] != '') {
         $username = $_POST['add_user'];
         if (UserHelper::isUser($username)) {
             $return = $gacl_api->add_acl(array('access' => array('access')), array("users" => array($username)), null, array('events' => array($this->event->event_record_number)), null, 1);
         } else {
             shnMessageQueue::addError(_t('USERID_DOES_NOT_EXISTS_'));
         }
     }
     if (isset($_POST['remove_user'])) {
         $acl_id = $gacl_api->search_acl('access', 'access', 'users', $_POST['remove_user'], FALSE, 'events', $this->event->event_record_number, FALSE, FALSE);
         if (isset($acl_id[0])) {
             $gacl_api->del_acl($acl_id[0]);
         }
     }
     //populate checkboxes
     $this->value = array();
     foreach ($this->roles as $role_val => $role_name) {
         $acl_id = $gacl_api->search_acl('access', 'access', FALSE, FALSE, $role_name, 'events', $this->event->event_record_number, FALSE, FALSE);
         if (count($acl_id) > 0) {
             $this->value[$role_val] = $role_val;
         }
     }
     //get users with permissions
     $this->users = acl_get_allowed_users($this->event->event_record_number);
 }
开发者ID:GeraldScott,项目名称:OpenEvSys,代码行数:46,代码来源:eventsModule.class.php


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