1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Add Subscribe option to maniphest

Summary:
Same as //Subscribe//, //Unsubscribe// and //Automatically Subscribed// in differential.

Manually updated library map as windows is fun!

Test Plan: Subscribe, Unsubscribe!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5809
This commit is contained in:
Gareth Evans 2013-05-03 15:47:39 -07:00 committed by epriestley
parent 0ca15f1f3b
commit 67da5d6e4b
5 changed files with 99 additions and 1 deletions

View file

@ -633,6 +633,7 @@ phutil_register_library_map(array(
'ManiphestSavedQueryListController' => 'applications/maniphest/controller/ManiphestSavedQueryListController.php',
'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestSubscribeController' => 'applications/maniphest/controller/ManiphestSubscribeController.php',
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/ManiphestTaskAuxiliaryStorage.php',
'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/ManiphestTaskDescriptionChangeController.php',

View file

@ -73,6 +73,8 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'ManiphestSavedQueryEditController',
'delete/(?P<id>[1-9]\d*)/' => 'ManiphestSavedQueryDeleteController',
),
'subscribe/(?P<action>add|rem)/(?P<id>[1-9]\d*)/'
=> 'ManiphestSubscribeController',
),
);
}

View file

@ -0,0 +1,40 @@
<?php
final class ManiphestSubscribeController extends ManiphestController {
private $id;
private $action;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
$this->action = $data['action'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$task = id(new ManiphestTask())->load($this->id);
if (!$task) {
return new Aphront404Response();
}
switch ($this->action) {
case 'add':
ManiphestTransactionEditor::addCC(
$task,
$user);
break;
case 'rem':
ManiphestTransactionEditor::removeCC(
$task,
$user);
break;
default:
return new Aphront400Response();
}
return id(new AphrontRedirectResponse())->setURI('/T'.$task->getID());
}
}

View file

@ -383,6 +383,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
private function buildActionView(ManiphestTask $task) {
$viewer = $this->getRequest()->getUser();
$viewer_phid = $viewer->getPHID();
$viewer_is_cc = in_array($viewer_phid, $task->getCCPHIDs());
$id = $task->getID();
$phid = $task->getPHID();
@ -397,12 +399,31 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setIcon('edit')
->setHref($this->getApplicationURI("/task/edit/{$id}/")));
if ($task->getOwnerPHID() === $viewer_phid) {
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Automatically Subscribed'))
->setDisabled(true)
->setIcon('subscribe-auto'));
} else {
$action = $viewer_is_cc ? 'rem' : 'add';
$name = $viewer_is_cc ? 'Unsubscribe' : 'Subscribe';
$icon = $viewer_is_cc ? 'subscribe-delete' : 'subscribe-add';
$view->addAction(
id(new PhabricatorActionView())
->setName(pht($name))
->setHref("/maniphest/subscribe/{$action}/{$id}/")
->setRenderAsForm(true)
->setUser($viewer)
->setIcon($icon));
}
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Merge Duplicates'))
->setHref("/search/attach/{$phid}/TASK/merge/")
->setWorkflow(true)
->setWorkflow(true)
->setIcon('merge'));
$view->addAction(

View file

@ -438,5 +438,39 @@ final class ManiphestTransactionEditor extends PhabricatorEditor {
return (double)(2 << 32);
}
public static function addCC(
ManiphestTask $task,
PhabricatorUser $user) {
$current_ccs = $task->getCCPHIDs();
$new_ccs = array_merge($current_ccs, array($user->getPHID()));
$transaction = new ManiphestTransaction();
$transaction->setTaskID($task->getID());
$transaction->setAuthorPHID($user->getPHID());
$transaction->setTransactionType(ManiphestTransactionType::TYPE_CCS);
$transaction->setNewValue(array_unique($new_ccs));
$transaction->setOldValue($current_ccs);
id(new ManiphestTransactionEditor())
->setActor($user)
->applyTransactions($task, array($transaction));
}
public static function removeCC(
ManiphestTask $task,
PhabricatorUser $user) {
$current_ccs = $task->getCCPHIDs();
$new_ccs = array_diff($current_ccs, array($user->getPHID()));
$transaction = new ManiphestTransaction();
$transaction->setTaskID($task->getID());
$transaction->setAuthorPHID($user->getPHID());
$transaction->setTransactionType(ManiphestTransactionType::TYPE_CCS);
$transaction->setNewValue(array_unique($new_ccs));
$transaction->setOldValue($current_ccs);
id(new ManiphestTransactionEditor())
->setActor($user)
->applyTransactions($task, array($transaction));
}
}