[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class UserRemoveStatusConduitAPIMethod extends UserConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'user.removestatus'; 7 } 8 9 public function getMethodStatus() { 10 return self::METHOD_STATUS_DEPRECATED; 11 } 12 13 public function getMethodDescription() { 14 return pht('Delete status information of 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 return array( 25 'fromEpoch' => 'required int', 26 'toEpoch' => 'required int', 27 ); 28 } 29 30 public function defineReturnType() { 31 return 'int'; 32 } 33 34 public function defineErrorTypes() { 35 return array( 36 'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.", 37 ); 38 } 39 40 protected function execute(ConduitAPIRequest $request) { 41 $user_phid = $request->getUser()->getPHID(); 42 $from = $request->getValue('fromEpoch'); 43 $to = $request->getValue('toEpoch'); 44 45 if ($to <= $from) { 46 throw new ConduitException('ERR-BAD-EPOCH'); 47 } 48 49 $table = new PhabricatorCalendarEvent(); 50 $table->openTransaction(); 51 $table->beginReadLocking(); 52 53 $overlap = $table->loadAllWhere( 54 'userPHID = %s AND dateFrom < %d AND dateTo > %d', 55 $user_phid, 56 $to, 57 $from); 58 foreach ($overlap as $status) { 59 if ($status->getDateFrom() < $from) { 60 if ($status->getDateTo() > $to) { 61 // Split the interval. 62 id(new PhabricatorCalendarEvent()) 63 ->setUserPHID($user_phid) 64 ->setDateFrom($to) 65 ->setDateTo($status->getDateTo()) 66 ->setStatus($status->getStatus()) 67 ->setDescription($status->getDescription()) 68 ->save(); 69 } 70 $status->setDateTo($from); 71 $status->save(); 72 } else if ($status->getDateTo() > $to) { 73 $status->setDateFrom($to); 74 $status->save(); 75 } else { 76 $status->delete(); 77 } 78 } 79 80 $table->endReadLocking(); 81 $table->saveTransaction(); 82 return count($overlap); 83 } 84 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |