[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/people/conduit/ -> UserAddStatusConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class UserAddStatusConduitAPIMethod extends UserConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'user.addstatus';
   7    }
   8  
   9    public function getMethodStatus() {
  10      return self::METHOD_STATUS_DEPRECATED;
  11    }
  12  
  13    public function getMethodDescription() {
  14      return pht('Add status information to the logged-in user.');
  15    }
  16  
  17    public function getMethodStatusDescription() {
  18      return pht(
  19        'Statuses are becoming full-fledged events as part of the '.
  20        'Calendar application.');
  21    }
  22  
  23    public function defineParamTypes() {
  24      $status_const = $this->formatStringConstants(array('away', 'sporadic'));
  25  
  26      return array(
  27        'fromEpoch'   => 'required int',
  28        'toEpoch'     => 'required int',
  29        'status'      => 'required '.$status_const,
  30        'description' => 'optional string',
  31      );
  32    }
  33  
  34    public function defineReturnType() {
  35      return 'void';
  36    }
  37  
  38    public function defineErrorTypes() {
  39      return array(
  40        'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.",
  41        'ERR-OVERLAP'   =>
  42          'There must be no status in any part of the specified epoch.',
  43      );
  44    }
  45  
  46    protected function execute(ConduitAPIRequest $request) {
  47      $user_phid   = $request->getUser()->getPHID();
  48      $from        = $request->getValue('fromEpoch');
  49      $to          = $request->getValue('toEpoch');
  50      $status      = $request->getValue('status');
  51      $description = $request->getValue('description', '');
  52  
  53      try {
  54        id(new PhabricatorCalendarEvent())
  55          ->setUserPHID($user_phid)
  56          ->setDateFrom($from)
  57          ->setDateTo($to)
  58          ->setTextStatus($status)
  59          ->setDescription($description)
  60          ->save();
  61      } catch (PhabricatorCalendarEventInvalidEpochException $e) {
  62        throw new ConduitException('ERR-BAD-EPOCH');
  63      }
  64    }
  65  
  66  }


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