Differential D19877 Diff 47465 src/applications/people/controller/PhabricatorPeopleApproveController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/controller/PhabricatorPeopleApproveController.php
| Show All 18 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| if ($user->getIsApproved()) { | if ($user->getIsApproved()) { | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Already Approved')) | ->setTitle(pht('Already Approved')) | ||||
| ->appendChild(pht('This user has already been approved.')) | ->appendChild(pht('This user has already been approved.')) | ||||
| ->addCancelButton($done_uri); | ->addCancelButton($done_uri); | ||||
| } | } | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| id(new PhabricatorUserEditor()) | $xactions = array(); | ||||
| ->setActor($viewer) | |||||
| ->approveUser($user, true); | |||||
| $title = pht( | $xactions[] = id(new PhabricatorUserTransaction()) | ||||
| 'Phabricator Account "%s" Approved', | ->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE) | ||||
| $user->getUsername()); | ->setNewValue(true); | ||||
| $body = sprintf( | id(new PhabricatorUserTransactionEditor()) | ||||
| "%s\n\n %s\n\n", | ->setActor($viewer) | ||||
| pht( | ->setContentSourceFromRequest($request) | ||||
| 'Your Phabricator account (%s) has been approved by %s. You can '. | ->setContinueOnMissingFields(true) | ||||
| 'login here:', | ->setContinueOnNoEffect(true) | ||||
| $user->getUsername(), | ->applyTransactions($user, $xactions); | ||||
| $viewer->getUsername()), | |||||
| PhabricatorEnv::getProductionURI('/')); | |||||
| $mail = id(new PhabricatorMetaMTAMail()) | |||||
| ->addTos(array($user->getPHID())) | |||||
| ->addCCs(array($viewer->getPHID())) | |||||
| ->setSubject('[Phabricator] '.$title) | |||||
| ->setForceDelivery(true) | |||||
| ->setBody($body) | |||||
| ->saveAndSend(); | |||||
| return id(new AphrontRedirectResponse())->setURI($done_uri); | return id(new AphrontRedirectResponse())->setURI($done_uri); | ||||
| } | } | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Confirm Approval')) | ->setTitle(pht('Confirm Approval')) | ||||
| ->appendChild( | ->appendChild( | ||||
| pht( | pht( | ||||
| 'Allow %s to access this Phabricator install?', | 'Allow %s to access this Phabricator install?', | ||||
| phutil_tag('strong', array(), $user->getUsername()))) | phutil_tag('strong', array(), $user->getUsername()))) | ||||
| ->addCancelButton($done_uri) | ->addCancelButton($done_uri) | ||||
| ->addSubmitButton(pht('Approve Account')); | ->addSubmitButton(pht('Approve Account')); | ||||
| } | } | ||||
| } | } | ||||