[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/people/controller/ -> PhabricatorPeopleApproveController.php (source)

   1  <?php
   2  
   3  final class PhabricatorPeopleApproveController
   4    extends PhabricatorPeopleController {
   5  
   6    private $id;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->id = idx($data, 'id');
  10    }
  11  
  12    public function processRequest() {
  13  
  14      $request = $this->getRequest();
  15      $admin = $request->getUser();
  16  
  17      $user = id(new PhabricatorPeopleQuery())
  18        ->setViewer($admin)
  19        ->withIDs(array($this->id))
  20        ->executeOne();
  21      if (!$user) {
  22        return new Aphront404Response();
  23      }
  24  
  25      $done_uri = $this->getApplicationURI('query/approval/');
  26  
  27      if ($request->isFormPost()) {
  28        id(new PhabricatorUserEditor())
  29          ->setActor($admin)
  30          ->approveUser($user, true);
  31  
  32        $title = pht(
  33          'Phabricator Account "%s" Approved',
  34          $user->getUsername(),
  35          $admin->getUsername());
  36  
  37        $body = pht(
  38          "Your Phabricator account (%s) has been approved by %s. You can ".
  39          "login here:\n\n  %s\n\n",
  40          $user->getUsername(),
  41          $admin->getUsername(),
  42          PhabricatorEnv::getProductionURI('/'));
  43  
  44        $mail = id(new PhabricatorMetaMTAMail())
  45          ->addTos(array($user->getPHID()))
  46          ->addCCs(array($admin->getPHID()))
  47          ->setSubject('[Phabricator] '.$title)
  48          ->setForceDelivery(true)
  49          ->setBody($body)
  50          ->saveAndSend();
  51  
  52        return id(new AphrontRedirectResponse())->setURI($done_uri);
  53      }
  54  
  55      $dialog = id(new AphrontDialogView())
  56        ->setUser($admin)
  57        ->setTitle(pht('Confirm Approval'))
  58        ->appendChild(
  59          pht(
  60            'Allow %s to access this Phabricator install?',
  61            phutil_tag('strong', array(), $user->getUsername())))
  62        ->addCancelButton($done_uri)
  63        ->addSubmitButton(pht('Approve Account'));
  64  
  65      return id(new AphrontDialogResponse())->setDialog($dialog);
  66    }
  67  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1