@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
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Gareth Evans and committed by
epriestley
67da5d6e 0ca15f1f

+99 -1
+1
src/__phutil_library_map__.php
··· 633 633 'ManiphestSavedQueryListController' => 'applications/maniphest/controller/ManiphestSavedQueryListController.php', 634 634 'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php', 635 635 'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php', 636 + 'ManiphestSubscribeController' => 'applications/maniphest/controller/ManiphestSubscribeController.php', 636 637 'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php', 637 638 'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/ManiphestTaskAuxiliaryStorage.php', 638 639 'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/ManiphestTaskDescriptionChangeController.php',
+2
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 73 73 'edit/(?:(?P<id>[1-9]\d*)/)?' => 'ManiphestSavedQueryEditController', 74 74 'delete/(?P<id>[1-9]\d*)/' => 'ManiphestSavedQueryDeleteController', 75 75 ), 76 + 'subscribe/(?P<action>add|rem)/(?P<id>[1-9]\d*)/' 77 + => 'ManiphestSubscribeController', 76 78 ), 77 79 ); 78 80 }
+40
src/applications/maniphest/controller/ManiphestSubscribeController.php
··· 1 + <?php 2 + 3 + final class ManiphestSubscribeController extends ManiphestController { 4 + 5 + private $id; 6 + private $action; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + $this->action = $data['action']; 11 + } 12 + 13 + public function processRequest() { 14 + 15 + $request = $this->getRequest(); 16 + $user = $request->getUser(); 17 + 18 + $task = id(new ManiphestTask())->load($this->id); 19 + if (!$task) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + switch ($this->action) { 24 + case 'add': 25 + ManiphestTransactionEditor::addCC( 26 + $task, 27 + $user); 28 + break; 29 + case 'rem': 30 + ManiphestTransactionEditor::removeCC( 31 + $task, 32 + $user); 33 + break; 34 + default: 35 + return new Aphront400Response(); 36 + } 37 + 38 + return id(new AphrontRedirectResponse())->setURI('/T'.$task->getID()); 39 + } 40 + }
+22 -1
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 383 383 384 384 private function buildActionView(ManiphestTask $task) { 385 385 $viewer = $this->getRequest()->getUser(); 386 + $viewer_phid = $viewer->getPHID(); 387 + $viewer_is_cc = in_array($viewer_phid, $task->getCCPHIDs()); 386 388 387 389 $id = $task->getID(); 388 390 $phid = $task->getPHID(); ··· 397 399 ->setIcon('edit') 398 400 ->setHref($this->getApplicationURI("/task/edit/{$id}/"))); 399 401 402 + if ($task->getOwnerPHID() === $viewer_phid) { 403 + $view->addAction( 404 + id(new PhabricatorActionView()) 405 + ->setName(pht('Automatically Subscribed')) 406 + ->setDisabled(true) 407 + ->setIcon('subscribe-auto')); 408 + } else { 409 + $action = $viewer_is_cc ? 'rem' : 'add'; 410 + $name = $viewer_is_cc ? 'Unsubscribe' : 'Subscribe'; 411 + $icon = $viewer_is_cc ? 'subscribe-delete' : 'subscribe-add'; 412 + 413 + $view->addAction( 414 + id(new PhabricatorActionView()) 415 + ->setName(pht($name)) 416 + ->setHref("/maniphest/subscribe/{$action}/{$id}/") 417 + ->setRenderAsForm(true) 418 + ->setUser($viewer) 419 + ->setIcon($icon)); 420 + } 421 + 400 422 $view->addAction( 401 423 id(new PhabricatorActionView()) 402 424 ->setName(pht('Merge Duplicates')) 403 425 ->setHref("/search/attach/{$phid}/TASK/merge/") 404 - ->setWorkflow(true) 405 426 ->setWorkflow(true) 406 427 ->setIcon('merge')); 407 428
+34
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 438 438 return (double)(2 << 32); 439 439 } 440 440 441 + public static function addCC( 442 + ManiphestTask $task, 443 + PhabricatorUser $user) { 444 + $current_ccs = $task->getCCPHIDs(); 445 + $new_ccs = array_merge($current_ccs, array($user->getPHID())); 441 446 447 + $transaction = new ManiphestTransaction(); 448 + $transaction->setTaskID($task->getID()); 449 + $transaction->setAuthorPHID($user->getPHID()); 450 + $transaction->setTransactionType(ManiphestTransactionType::TYPE_CCS); 451 + $transaction->setNewValue(array_unique($new_ccs)); 452 + $transaction->setOldValue($current_ccs); 453 + 454 + id(new ManiphestTransactionEditor()) 455 + ->setActor($user) 456 + ->applyTransactions($task, array($transaction)); 457 + } 458 + 459 + public static function removeCC( 460 + ManiphestTask $task, 461 + PhabricatorUser $user) { 462 + $current_ccs = $task->getCCPHIDs(); 463 + $new_ccs = array_diff($current_ccs, array($user->getPHID())); 464 + 465 + $transaction = new ManiphestTransaction(); 466 + $transaction->setTaskID($task->getID()); 467 + $transaction->setAuthorPHID($user->getPHID()); 468 + $transaction->setTransactionType(ManiphestTransactionType::TYPE_CCS); 469 + $transaction->setNewValue(array_unique($new_ccs)); 470 + $transaction->setOldValue($current_ccs); 471 + 472 + id(new ManiphestTransactionEditor()) 473 + ->setActor($user) 474 + ->applyTransactions($task, array($transaction)); 475 + } 442 476 }