2012-05-04 03:38:02 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class UserRemoveStatusConduitAPIMethod extends UserConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'user.removestatus';
|
|
|
|
}
|
2012-05-04 03:38:02 +02:00
|
|
|
|
|
|
|
public function getMethodStatus() {
|
2014-04-22 00:32:48 +02:00
|
|
|
return self::METHOD_STATUS_DEPRECATED;
|
2012-05-04 03:38:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Delete status information of the logged-in user.');
|
2014-04-22 00:32:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getMethodStatusDescription() {
|
|
|
|
return pht(
|
|
|
|
'Statuses are becoming full-fledged events as part of the '.
|
|
|
|
'Calendar application.');
|
2012-05-04 03:38:02 +02:00
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineParamTypes() {
|
2012-05-04 03:38:02 +02:00
|
|
|
return array(
|
|
|
|
'fromEpoch' => 'required int',
|
|
|
|
'toEpoch' => 'required int',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineReturnType() {
|
2012-05-04 03:38:02 +02:00
|
|
|
return 'int';
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineErrorTypes() {
|
2012-05-04 03:38:02 +02:00
|
|
|
return array(
|
|
|
|
'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$user_phid = $request->getUser()->getPHID();
|
|
|
|
$from = $request->getValue('fromEpoch');
|
|
|
|
$to = $request->getValue('toEpoch');
|
|
|
|
|
|
|
|
if ($to <= $from) {
|
|
|
|
throw new ConduitException('ERR-BAD-EPOCH');
|
|
|
|
}
|
|
|
|
|
2014-02-06 19:07:29 +01:00
|
|
|
$table = new PhabricatorCalendarEvent();
|
2012-05-04 23:15:34 +02:00
|
|
|
$table->openTransaction();
|
|
|
|
$table->beginReadLocking();
|
|
|
|
|
|
|
|
$overlap = $table->loadAllWhere(
|
2012-05-04 03:38:02 +02:00
|
|
|
'userPHID = %s AND dateFrom < %d AND dateTo > %d',
|
|
|
|
$user_phid,
|
|
|
|
$to,
|
|
|
|
$from);
|
|
|
|
foreach ($overlap as $status) {
|
|
|
|
if ($status->getDateFrom() < $from) {
|
|
|
|
if ($status->getDateTo() > $to) {
|
|
|
|
// Split the interval.
|
2014-02-06 19:07:29 +01:00
|
|
|
id(new PhabricatorCalendarEvent())
|
2012-05-04 03:38:02 +02:00
|
|
|
->setUserPHID($user_phid)
|
|
|
|
->setDateFrom($to)
|
|
|
|
->setDateTo($status->getDateTo())
|
|
|
|
->setStatus($status->getStatus())
|
2012-10-24 22:22:24 +02:00
|
|
|
->setDescription($status->getDescription())
|
2012-05-04 03:38:02 +02:00
|
|
|
->save();
|
|
|
|
}
|
|
|
|
$status->setDateTo($from);
|
|
|
|
$status->save();
|
|
|
|
} else if ($status->getDateTo() > $to) {
|
|
|
|
$status->setDateFrom($to);
|
|
|
|
$status->save();
|
|
|
|
} else {
|
|
|
|
$status->delete();
|
|
|
|
}
|
|
|
|
}
|
2012-05-04 23:15:34 +02:00
|
|
|
|
|
|
|
$table->endReadLocking();
|
|
|
|
$table->saveTransaction();
|
2012-05-04 03:38:02 +02:00
|
|
|
return count($overlap);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|