Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/editor/PhabricatorUserEditor.php
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | $user->openTransaction(); | ||||
| // so, erase the IDs we attached. | // so, erase the IDs we attached. | ||||
| $user->setID(null); | $user->setID(null); | ||||
| $user->setPHID(null); | $user->setPHID(null); | ||||
| $user->killTransaction(); | $user->killTransaction(); | ||||
| throw $ex; | throw $ex; | ||||
| } | } | ||||
| $log = PhabricatorUserLog::initializeNewLog( | |||||
| $this->requireActor(), | |||||
| $user->getPHID(), | |||||
| PhabricatorUserLog::ACTION_CREATE); | |||||
| $log->setNewValue($email->getAddress()); | |||||
| $log->save(); | |||||
| if ($is_reassign) { | if ($is_reassign) { | ||||
| $log = PhabricatorUserLog::initializeNewLog( | $log = PhabricatorUserLog::initializeNewLog( | ||||
| $this->requireActor(), | $this->requireActor(), | ||||
| $user->getPHID(), | $user->getPHID(), | ||||
| PhabricatorUserLog::ACTION_EMAIL_REASSIGN); | PhabricatorUserLog::ACTION_EMAIL_REASSIGN); | ||||
| $log->setNewValue($email->getAddress()); | $log->setNewValue($email->getAddress()); | ||||
| $log->save(); | $log->save(); | ||||
| } | } | ||||
| $user->saveTransaction(); | $user->saveTransaction(); | ||||
| if ($email->getIsVerified()) { | if ($email->getIsVerified()) { | ||||
| $this->didVerifyEmail($user, $email); | $this->didVerifyEmail($user, $email); | ||||
| } | } | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | |||||
| * @task edit | |||||
| */ | |||||
| public function updateUser( | |||||
| PhabricatorUser $user, | |||||
| PhabricatorUserEmail $email = null) { | |||||
| if (!$user->getID()) { | |||||
| throw new Exception(pht('User has not been created yet!')); | |||||
| } | |||||
| $user->openTransaction(); | |||||
| $user->save(); | |||||
| if ($email) { | |||||
| $email->save(); | |||||
| } | |||||
| $log = PhabricatorUserLog::initializeNewLog( | |||||
| $this->requireActor(), | |||||
| $user->getPHID(), | |||||
| PhabricatorUserLog::ACTION_EDIT); | |||||
| $log->save(); | |||||
| $user->saveTransaction(); | |||||
| return $this; | |||||
| } | |||||
| /* -( Editing Roles )------------------------------------------------------ */ | /* -( Editing Roles )------------------------------------------------------ */ | ||||
| /** | /** | ||||
| * @task role | * @task role | ||||
| */ | */ | ||||
| public function makeSystemAgentUser(PhabricatorUser $user, $system_agent) { | public function makeSystemAgentUser(PhabricatorUser $user, $system_agent) { | ||||
| $actor = $this->requireActor(); | $actor = $this->requireActor(); | ||||
| if (!$user->getID()) { | if (!$user->getID()) { | ||||
| throw new Exception(pht('User has not been created yet!')); | throw new Exception(pht('User has not been created yet!')); | ||||
| } | } | ||||
| $user->openTransaction(); | $user->openTransaction(); | ||||
| $user->beginWriteLocking(); | $user->beginWriteLocking(); | ||||
| $user->reload(); | $user->reload(); | ||||
| if ($user->getIsSystemAgent() == $system_agent) { | if ($user->getIsSystemAgent() == $system_agent) { | ||||
| $user->endWriteLocking(); | $user->endWriteLocking(); | ||||
| $user->killTransaction(); | $user->killTransaction(); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| $log = PhabricatorUserLog::initializeNewLog( | |||||
| $actor, | |||||
| $user->getPHID(), | |||||
| PhabricatorUserLog::ACTION_SYSTEM_AGENT); | |||||
| $log->setOldValue($user->getIsSystemAgent()); | |||||
| $log->setNewValue($system_agent); | |||||
| $user->setIsSystemAgent((int)$system_agent); | $user->setIsSystemAgent((int)$system_agent); | ||||
| $user->save(); | $user->save(); | ||||
| $log->save(); | |||||
| $user->endWriteLocking(); | $user->endWriteLocking(); | ||||
| $user->saveTransaction(); | $user->saveTransaction(); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | /** | ||||
| * @task role | * @task role | ||||
| Show All 10 Lines | $user->openTransaction(); | ||||
| $user->reload(); | $user->reload(); | ||||
| if ($user->getIsMailingList() == $mailing_list) { | if ($user->getIsMailingList() == $mailing_list) { | ||||
| $user->endWriteLocking(); | $user->endWriteLocking(); | ||||
| $user->killTransaction(); | $user->killTransaction(); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| $log = PhabricatorUserLog::initializeNewLog( | |||||
| $actor, | |||||
| $user->getPHID(), | |||||
| PhabricatorUserLog::ACTION_MAILING_LIST); | |||||
| $log->setOldValue($user->getIsMailingList()); | |||||
| $log->setNewValue($mailing_list); | |||||
| $user->setIsMailingList((int)$mailing_list); | $user->setIsMailingList((int)$mailing_list); | ||||
| $user->save(); | $user->save(); | ||||
| $log->save(); | |||||
| $user->endWriteLocking(); | $user->endWriteLocking(); | ||||
| $user->saveTransaction(); | $user->saveTransaction(); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /* -( Adding, Removing and Changing Email )-------------------------------- */ | /* -( Adding, Removing and Changing Email )-------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 350 Lines • Show Last 20 Lines | |||||