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


PHP UserAccount::getId方法代码示例

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


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

示例1: saveUser

 public function saveUser($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->firstName) || ($firstName = trim($params->CallbackParameter->firstName)) === '') {
             throw new Exception('System Error: firstName is mandatory!');
         }
         if (!isset($params->CallbackParameter->lastName) || ($lastName = trim($params->CallbackParameter->lastName)) === '') {
             throw new Exception('System Error: lastName is mandatory!');
         }
         if (!isset($params->CallbackParameter->userName) || ($userName = trim($params->CallbackParameter->userName)) === '') {
             throw new Exception('System Error: userName is mandatory!');
         }
         if (!isset($params->CallbackParameter->roleid) || !($role = Role::get($params->CallbackParameter->roleid)) instanceof Role) {
             throw new Exception('System Error: role is mandatory!');
         }
         $newpassword = trim($params->CallbackParameter->newpassword);
         if (!isset($params->CallbackParameter->userid) || !($userAccount = UserAccount::get($params->CallbackParameter->userid)) instanceof UserAccount) {
             $userAccount = new UserAccount();
             $person = new Person();
             if ($newpassword === '') {
                 throw new Exception('System Error: new password is mandatory!');
             }
             $newpassword = sha1($newpassword);
         } else {
             $person = $userAccount->getPerson();
             if ($newpassword === '') {
                 $newpassword = $userAccount->getPassword();
             } else {
                 $newpassword = sha1($newpassword);
             }
         }
         //double check whether the username has been used
         $users = UserAccount::getAllByCriteria('username=? and id!=?', array($userName, $userAccount->getId()), false, 1, 1);
         if (count($users) > 0) {
             throw new Exception('Username(=' . $userName . ') has been used by another user, please choose another one!');
         }
         $person->setFirstName($firstName)->setLastName($lastName)->save();
         $userAccount->setUserName($userName)->setPassword($newpassword)->setPerson($person)->save();
         $results = $userAccount->clearRoles()->addRole($role)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:48,代码来源:UsersController.php

示例2: _preActionCheck

 /**
  * checking whether we can do the action
  *
  * @param UserAccount $user
  *
  * @throws EntityException
  * @return Task
  */
 private function _preActionCheck(UserAccount $user)
 {
     if (trim($this->getId()) === '') {
         throw new EntityException('Please save the task before you do any actions to the task');
     }
     if (!($status = $this->getStatus()) instanceof TaskStatus || in_array(intval($this->getStatus()->getId()), TaskStatus::getClosedStatusIds())) {
         throw new EntityException('Can NOT Take Task(' . $this->getId() . ') is at status:' . ($status instanceof TaskStatus ? $this->getStatus()->getName() : ''));
     }
     if ($this->getTechnician() instanceof UserAccount) {
         if ($user->getId() === $this->getTechnician()->getId()) {
             return $this;
         }
         throw new EntityException('Can NOT Action on a Task(' . $this->getId() . ') owned by tech:' . $this->getTechnician()->getPerson()->getFullName());
     }
     return $this;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:24,代码来源:Task.php


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