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


PHP Scalr_Account_User::loadByEmail方法代码示例

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


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

示例1: getUserInfoByAccountId

 protected function getUserInfoByAccountId($accountId)
 {
     if (!isset($this->accountsCache[$accountId])) {
         if ($accountId) {
             try {
                 $acc = new \Scalr_Account();
                 $acc->loadById($accountId);
                 $this->accountsCache[$accountId] = array('id' => $acc->getOwner()->id, 'email' => $acc->getOwner()->getEmail());
             } catch (\Exception $e) {
                 $this->console->error($e->getMessage());
                 return array('id' => 0, 'email' => '');
             }
         } else {
             $user = new \Scalr_Account_User();
             $user->loadByEmail('admin', 0);
             $this->accountsCache[$accountId] = array('id' => $user->id, 'email' => $user->getEmail());
         }
     }
     return $this->accountsCache[$accountId];
 }
开发者ID:mheydt,项目名称:scalr,代码行数:20,代码来源:Update20140204143602.php

示例2: xSaveAction

 public function xSaveAction()
 {
     $this->request->defineParams(array('id' => array('type' => 'int'), 'name' => array('type' => 'string'), 'ownerEmail' => array('type' => 'string'), 'ownerPassword' => array('type' => 'string', 'rawValue' => true), 'comments' => array('type' => 'string'), 'ccs' => array('type' => 'json')));
     $account = Scalr_Account::init();
     $validator = new Validator();
     $id = (int) $this->getParam('id');
     $name = $this->getParam('name');
     $ownerEmail = $this->getParam('ownerEmail');
     $ownerPassword = $this->getParam('ownerPassword');
     $validator->validate($name, "name", Validator::NOEMPTY, [], "Name is required");
     $validator->validate($id, "id", Validator::INTEGERNUM);
     if ($id) {
         $account->loadById($id);
     } else {
         $account->status = Scalr_Account::STATUS_ACTIVE;
         if ($this->getContainer()->config->get('scalr.auth_mode') == 'scalr') {
             $validator->validate($ownerEmail, "ownerEmail", Validator::EMAIL);
             $validator->validate($ownerPassword, "ownerPassword", Validator::PASSWORD, ["admin"]);
         } elseif ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap') {
             $validator->validate($ownerEmail, "ownerEmail", Validator::NOEMPTY, [], "Email is required");
         }
     }
     if (!$validator->isValid($this->response)) {
         return;
     }
     $this->db->BeginTrans();
     try {
         $account->name = $name;
         $account->comments = $this->getParam('comments');
         $account->save();
         $account->initializeAcl();
         $account->setLimits(array(Scalr_Limits::ACCOUNT_ENVIRONMENTS => $this->getParam('limitEnv'), Scalr_Limits::ACCOUNT_FARMS => $this->getParam('limitFarms'), Scalr_Limits::ACCOUNT_SERVERS => $this->getParam('limitServers'), Scalr_Limits::ACCOUNT_USERS => $this->getParam('limitUsers')));
         if (!$id) {
             $user = $account->createUser($ownerEmail, $ownerPassword, Scalr_Account_User::TYPE_ACCOUNT_OWNER);
             if ($this->getContainer()->analytics->enabled) {
                 //Default Cost Center should be assigned
                 $cc = $this->getContainer()->analytics->ccs->get($this->getContainer()->analytics->usage->autoCostCentre());
                 //Assigns account with Cost Center
                 $accountCcEntity = new AccountCostCenterEntity($account->id, $cc->ccId);
                 $accountCcEntity->save();
             }
             $account->createEnvironment("default");
         }
         if ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap' && $id) {
             if ($ownerEmail != $account->getOwner()->getEmail()) {
                 $prev = $account->getOwner();
                 $prev->type = Scalr_Account_User::TYPE_TEAM_USER;
                 $prev->save();
                 $user = new Scalr_Account_User();
                 if ($user->loadByEmail($ownerEmail, $account->id)) {
                     $user->type = Scalr_Account_User::TYPE_ACCOUNT_OWNER;
                     $user->save();
                 } else {
                     $account->createUser($ownerEmail, $ownerPassword, Scalr_Account_User::TYPE_ACCOUNT_OWNER);
                 }
             }
         }
         if ($this->getContainer()->analytics->enabled) {
             if (!Scalr::isHostedScalr()) {
                 //save ccs
                 $ccs = (array) $this->getParam('ccs');
                 foreach (AccountCostCenterEntity::findByAccountId($account->id) as $accountCcsEntity) {
                     $index = array_search($accountCcsEntity->ccId, $ccs);
                     if ($index === false) {
                         $accountCcsEntity->delete();
                     } else {
                         unset($ccs[$index]);
                     }
                 }
                 foreach ($ccs as $ccId) {
                     $accountCcsEntity = new AccountCostCenterEntity($account->id, $ccId);
                     $accountCcsEntity->save();
                 }
             }
         }
     } catch (Exception $e) {
         $this->db->RollbackTrans();
         throw $e;
     }
     $this->db->CommitTrans();
     $this->response->data(array('accountId' => $account->id));
 }
开发者ID:mheydt,项目名称:scalr,代码行数:82,代码来源:Accounts.php

示例3: xSaveAction

 public function xSaveAction()
 {
     $this->request->defineParams(array('id' => array('type' => 'int'), 'name' => array('type' => 'string', 'validator' => array(Scalr_Validator::NOHTML => true, Scalr_Validator::REQUIRED => true)), 'comments' => array('type' => 'string')));
     $account = Scalr_Account::init();
     if ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap') {
         $this->request->defineParams(array('ownerEmail' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true))));
     }
     if ($this->getParam('id')) {
         $account->loadById($this->getParam('id'));
     } else {
         $account->status = Scalr_Account::STATUS_ACTIVE;
         if ($this->getContainer()->config->get('scalr.auth_mode') == 'scalr') {
             $this->request->defineParams(array('ownerEmail' => array('type' => 'string', 'validator' => array(Scalr_Validator::REQUIRED => true, Scalr_Validator::EMAIL => true)), 'ownerPassword' => array('type ' => 'string', 'validator' => array(Scalr_Validator::MINMAX => array('min' => 6)))));
         }
     }
     if (!$this->request->validate()->isValid()) {
         $this->response->failure();
         $this->response->data($this->request->getValidationErrors());
         return;
     }
     $this->db->BeginTrans();
     try {
         $account->name = $this->getParam('name');
         $account->comments = $this->getParam('comments');
         $account->save();
         $account->initializeAcl();
         $account->setLimits(array(Scalr_Limits::ACCOUNT_ENVIRONMENTS => $this->getParam('limitEnv'), Scalr_Limits::ACCOUNT_FARMS => $this->getParam('limitFarms'), Scalr_Limits::ACCOUNT_SERVERS => $this->getParam('limitServers'), Scalr_Limits::ACCOUNT_USERS => $this->getParam('limitUsers')));
         if (!$this->getParam('id')) {
             $account->createEnvironment("default");
             $account->createUser($this->getParam('ownerEmail'), $this->getParam('ownerPassword'), Scalr_Account_User::TYPE_ACCOUNT_OWNER);
         }
         if ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap' && $this->getParam('id')) {
             if ($this->getParam('ownerEmail') != $account->getOwner()->getEmail()) {
                 $prev = $account->getOwner();
                 $prev->type = Scalr_Account_User::TYPE_TEAM_USER;
                 $prev->save();
                 $user = new Scalr_Account_User();
                 if ($user->loadByEmail($this->getParam('ownerEmail'), $account->id)) {
                     $user->type = Scalr_Account_User::TYPE_ACCOUNT_OWNER;
                     $user->save();
                 } else {
                     $account->createUser($this->getParam('ownerEmail'), $this->getParam('ownerPassword'), Scalr_Account_User::TYPE_ACCOUNT_OWNER);
                 }
             }
         }
     } catch (Exception $e) {
         $this->db->RollbackTrans();
         throw $e;
     }
     $this->db->CommitTrans();
     $this->response->data(array('accountId' => $account->id));
 }
开发者ID:recipe,项目名称:scalr,代码行数:52,代码来源:Accounts.php


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