[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/conpherence/controller/ -> ConpherenceNewController.php (source)

   1  <?php
   2  
   3  final class ConpherenceNewController extends ConpherenceController {
   4  
   5    public function processRequest() {
   6      $request = $this->getRequest();
   7      $user = $request->getUser();
   8  
   9      $title = pht('New Message');
  10      $participants = array();
  11      $participant_prefill = null;
  12      $message = '';
  13      $e_participants = null;
  14      $e_message = null;
  15  
  16      // this comes from ajax requests from all over. should be a single phid.
  17  
  18      if ($request->isFormPost()) {
  19        $participants = $request->getArr('participants');
  20        $message = $request->getStr('message');
  21        list($error_codes, $conpherence) = ConpherenceEditor::createConpherence(
  22          $user,
  23          $participants,
  24          $conpherence_title = null,
  25          $message,
  26          PhabricatorContentSource::newFromRequest($request));
  27  
  28        if ($error_codes) {
  29          foreach ($error_codes as $error_code) {
  30            switch ($error_code) {
  31              case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
  32                $e_message = true;
  33                break;
  34              case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
  35                $e_participants = true;
  36                break;
  37            }
  38          }
  39        } else {
  40          $uri = $this->getApplicationURI($conpherence->getID());
  41          return id(new AphrontRedirectResponse())
  42            ->setURI($uri);
  43        }
  44      } else {
  45        $participant_prefill = $request->getStr('participant');
  46        if ($participant_prefill) {
  47          $participants[] = $participant_prefill;
  48        }
  49      }
  50  
  51  
  52      $participant_handles = array();
  53      if ($participants) {
  54        $participant_handles = id(new PhabricatorHandleQuery())
  55          ->setViewer($user)
  56          ->withPHIDs($participants)
  57          ->execute();
  58      }
  59  
  60      $submit_uri = $this->getApplicationURI('new/');
  61      $cancel_uri = $this->getApplicationURI();
  62  
  63      // TODO - we can get a better cancel_uri once we get better at crazy
  64      // ajax jonx T2086
  65      if ($participant_prefill) {
  66        $handle = $participant_handles[$participant_prefill];
  67        $cancel_uri = $handle->getURI();
  68      }
  69  
  70      $dialog = id(new AphrontDialogView())
  71        ->setWidth(AphrontDialogView::WIDTH_FORM)
  72        ->setUser($user)
  73        ->setTitle($title)
  74        ->addCancelButton($cancel_uri)
  75        ->addSubmitButton(pht('Send Message'));
  76  
  77      $form = id(new PHUIFormLayoutView())
  78        ->setUser($user)
  79        ->setFullWidth(true)
  80        ->appendChild(
  81          id(new AphrontFormTokenizerControl())
  82          ->setName('participants')
  83          ->setValue($participant_handles)
  84          ->setUser($user)
  85          ->setDatasource(new PhabricatorPeopleDatasource())
  86          ->setLabel(pht('To'))
  87          ->setError($e_participants))
  88        ->appendChild(
  89          id(new PhabricatorRemarkupControl())
  90            ->setUser($user)
  91            ->setName('message')
  92            ->setValue($message)
  93            ->setLabel(pht('Message'))
  94            ->setError($e_message));
  95  
  96      $dialog->appendChild($form);
  97  
  98      return id(new AphrontDialogResponse())->setDialog($dialog);
  99    }
 100  
 101  }


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