Select the types of activity you want to include in your feed.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
···11+<?php
22+33+/*
44+ * Copyright 2012 Facebook, Inc.
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ */
1818+1919+/**
2020+ * @group conduit
2121+ */
2222+final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method {
2323+2424+ public function getMethodStatus() {
2525+ return self::METHOD_STATUS_UNSTABLE;
2626+ }
2727+2828+ public function getMethodDescription() {
2929+ return "Delete status information of the logged-in user.";
3030+ }
3131+3232+ public function defineParamTypes() {
3333+ return array(
3434+ 'fromEpoch' => 'required int',
3535+ 'toEpoch' => 'required int',
3636+ );
3737+ }
3838+3939+ public function defineReturnType() {
4040+ return 'int';
4141+ }
4242+4343+ public function defineErrorTypes() {
4444+ return array(
4545+ 'ERR-BAD-EPOCH' => "'toEpoch' must be bigger than 'fromEpoch'.",
4646+ );
4747+ }
4848+4949+ protected function execute(ConduitAPIRequest $request) {
5050+ $user_phid = $request->getUser()->getPHID();
5151+ $from = $request->getValue('fromEpoch');
5252+ $to = $request->getValue('toEpoch');
5353+5454+ if ($to <= $from) {
5555+ throw new ConduitException('ERR-BAD-EPOCH');
5656+ }
5757+5858+ $overlap = id(new PhabricatorUserStatus())->loadAllWhere(
5959+ 'userPHID = %s AND dateFrom < %d AND dateTo > %d',
6060+ $user_phid,
6161+ $to,
6262+ $from);
6363+ foreach ($overlap as $status) {
6464+ if ($status->getDateFrom() < $from) {
6565+ if ($status->getDateTo() > $to) {
6666+ // Split the interval.
6767+ id(new PhabricatorUserStatus())
6868+ ->setUserPHID($user_phid)
6969+ ->setDateFrom($to)
7070+ ->setDateTo($status->getDateTo())
7171+ ->setStatus($status->getStatus())
7272+ ->save();
7373+ }
7474+ $status->setDateTo($from);
7575+ $status->save();
7676+ } else if ($status->getDateTo() > $to) {
7777+ $status->setDateFrom($to);
7878+ $status->save();
7979+ } else {
8080+ $status->delete();
8181+ }
8282+ }
8383+ return count($overlap);
8484+ }
8585+8686+}