當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhabricatorUser::endWriteLocking方法代碼示例

本文整理匯總了PHP中PhabricatorUser::endWriteLocking方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorUser::endWriteLocking方法的具體用法?PHP PhabricatorUser::endWriteLocking怎麽用?PHP PhabricatorUser::endWriteLocking使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhabricatorUser的用法示例。


在下文中一共展示了PhabricatorUser::endWriteLocking方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: verifyEmail

 /**
  * Verify a user's email address.
  *
  * This verifies an individual email address. If the address is the user's
  * primary address and their account was not previously verified, their
  * account is marked as email verified.
  *
  * @task email
  */
 public function verifyEmail(PhabricatorUser $user, PhabricatorUserEmail $email)
 {
     $actor = $this->requireActor();
     if (!$user->getID()) {
         throw new Exception('User has not been created yet!');
     }
     if (!$email->getID()) {
         throw new Exception('Email has not been created yet!');
     }
     $user->openTransaction();
     $user->beginWriteLocking();
     $user->reload();
     $email->reload();
     if ($email->getUserPHID() != $user->getPHID()) {
         throw new Exception(pht('User does not own email!'));
     }
     if (!$email->getIsVerified()) {
         $email->setIsVerified(1);
         $email->save();
         $log = PhabricatorUserLog::initializeNewLog($actor, $user->getPHID(), PhabricatorUserLog::ACTION_EMAIL_VERIFY);
         $log->setNewValue($email->getAddress());
         $log->save();
     }
     if (!$user->getIsEmailVerified()) {
         // If the user just verified their primary email address, mark their
         // account as email verified.
         $user_primary = $user->loadPrimaryEmail();
         if ($user_primary->getID() == $email->getID()) {
             $user->setIsEmailVerified(1);
             $user->save();
         }
     }
     $user->endWriteLocking();
     $user->saveTransaction();
 }
開發者ID:denghp,項目名稱:phabricator,代碼行數:44,代碼來源:PhabricatorUserEditor.php

示例2: addEmail

 /**
  * @task email
  */
 public function addEmail(PhabricatorUser $user, PhabricatorUserEmail $email)
 {
     $actor = $this->requireActor();
     if (!$user->getID()) {
         throw new Exception("User has not been created yet!");
     }
     if ($email->getID()) {
         throw new Exception("Email has already been created!");
     }
     // Use changePrimaryEmail() to change primary email.
     $email->setIsPrimary(0);
     $email->setUserPHID($user->getPHID());
     $this->willAddEmail($email);
     $user->openTransaction();
     $user->beginWriteLocking();
     $user->reload();
     try {
         $email->save();
     } catch (AphrontQueryDuplicateKeyException $ex) {
         $user->endWriteLocking();
         $user->killTransaction();
         throw $ex;
     }
     $log = PhabricatorUserLog::newLog($this->actor, $user, PhabricatorUserLog::ACTION_EMAIL_ADD);
     $log->setNewValue($email->getAddress());
     $log->save();
     $user->endWriteLocking();
     $user->saveTransaction();
     return $this;
 }
開發者ID:nexeck,項目名稱:phabricator,代碼行數:33,代碼來源:PhabricatorUserEditor.php

示例3: reassignEmail

 /**
  * Reassign an unverified email address.
  */
 public function reassignEmail(PhabricatorUser $user, PhabricatorUserEmail $email)
 {
     $actor = $this->requireActor();
     if (!$user->getID()) {
         throw new Exception(pht('User has not been created yet!'));
     }
     if (!$email->getID()) {
         throw new Exception(pht('Email has not been created yet!'));
     }
     $user->openTransaction();
     $user->beginWriteLocking();
     $user->reload();
     $email->reload();
     $old_user = $email->getUserPHID();
     if ($old_user != $user->getPHID()) {
         if ($email->getIsVerified()) {
             throw new Exception(pht('Verified email addresses can not be reassigned.'));
         }
         if ($email->getIsPrimary()) {
             throw new Exception(pht('Primary email addresses can not be reassigned.'));
         }
         $email->setUserPHID($user->getPHID());
         $email->save();
         $log = PhabricatorUserLog::initializeNewLog($actor, $user->getPHID(), PhabricatorUserLog::ACTION_EMAIL_REASSIGN);
         $log->setNewValue($email->getAddress());
         $log->save();
     }
     $user->endWriteLocking();
     $user->saveTransaction();
 }
開發者ID:truSense,項目名稱:phabricator,代碼行數:33,代碼來源:PhabricatorUserEditor.php


注:本文中的PhabricatorUser::endWriteLocking方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。