@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 defualt view and default edit policies for tasks

Summary: Ref T603. Allow global default policies to be configured for tasks.

Test Plan:
- Created task via web UI.
- Created task via Conduit.
- Created task via email.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7267

+88 -18
+4
src/__phutil_library_map__.php
··· 706 706 'LiskRawMigrationIterator' => 'infrastructure/storage/lisk/LiskRawMigrationIterator.php', 707 707 'ManiphestAction' => 'applications/maniphest/constants/ManiphestAction.php', 708 708 'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php', 709 + 'ManiphestCapabilityDefaultEdit' => 'applications/maniphest/capability/ManiphestCapabilityDefaultEdit.php', 710 + 'ManiphestCapabilityDefaultView' => 'applications/maniphest/capability/ManiphestCapabilityDefaultView.php', 709 711 'ManiphestConfiguredCustomField' => 'applications/maniphest/field/ManiphestConfiguredCustomField.php', 710 712 'ManiphestConstants' => 'applications/maniphest/constants/ManiphestConstants.php', 711 713 'ManiphestController' => 'applications/maniphest/controller/ManiphestController.php', ··· 2821 2823 'LiskRawMigrationIterator' => 'PhutilBufferedIterator', 2822 2824 'ManiphestAction' => 'ManiphestConstants', 2823 2825 'ManiphestBatchEditController' => 'ManiphestController', 2826 + 'ManiphestCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 2827 + 'ManiphestCapabilityDefaultView' => 'PhabricatorPolicyCapability', 2824 2828 'ManiphestConfiguredCustomField' => 2825 2829 array( 2826 2830 0 => 'ManiphestCustomField',
+13
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 90 90 return $status; 91 91 } 92 92 93 + protected function getCustomCapabilities() { 94 + return array( 95 + ManiphestCapabilityDefaultView::CAPABILITY => array( 96 + 'caption' => pht( 97 + 'Default view policy for newly created tasks.'), 98 + ), 99 + ManiphestCapabilityDefaultEdit::CAPABILITY => array( 100 + 'caption' => pht( 101 + 'Default edit policy for newly created tasks.'), 102 + ), 103 + ); 104 + } 105 + 93 106 } 94 107
+16
src/applications/maniphest/capability/ManiphestCapabilityDefaultEdit.php
··· 1 + <?php 2 + 3 + final class ManiphestCapabilityDefaultEdit 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'maniphest.default.edit'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Default Edit Policy'); 14 + } 15 + 16 + }
+16
src/applications/maniphest/capability/ManiphestCapabilityDefaultView.php
··· 1 + <?php 2 + 3 + final class ManiphestCapabilityDefaultView 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'maniphest.default.view'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Default View Policy'); 14 + } 15 + 16 + }
+1 -3
src/applications/maniphest/conduit/ConduitAPI_maniphest_createtask_Method.php
··· 25 25 } 26 26 27 27 protected function execute(ConduitAPIRequest $request) { 28 - $task = new ManiphestTask(); 29 - $task->setPriority(ManiphestTaskPriority::getDefaultPriority()); 30 - $task->setAuthorPHID($request->getUser()->getPHID()); 28 + $task = ManiphestTask::initializeNewTask($request->getUser()); 31 29 32 30 $this->applyRequest($task, $request, $is_new = true); 33 31
+1 -3
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 34 34 return new Aphront404Response(); 35 35 } 36 36 } else { 37 - $task = new ManiphestTask(); 38 - $task->setPriority(ManiphestTaskPriority::getDefaultPriority()); 39 - $task->setAuthorPHID($user->getPHID()); 37 + $task = ManiphestTask::initializeNewTask($user); 40 38 41 39 // These allow task creation with defaults. 42 40 if (!$request->isFormPost()) {
+1 -2
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
··· 7 7 $authorPHID = $this->loadPhabrictorUserPHID(); 8 8 $author = id(new PhabricatorUser()) 9 9 ->loadOneWhere('phid = %s', $authorPHID); 10 - $task = id(new ManiphestTask()) 10 + $task = ManiphestTask::initializeNewTask($author) 11 11 ->setSubPriority($this->generateTaskSubPriority()) 12 - ->setAuthorPHID($authorPHID) 13 12 ->setTitle($this->generateTitle()) 14 13 ->setStatus(ManiphestTaskStatus::STATUS_OPEN); 15 14
+1 -4
src/applications/maniphest/mail/ManiphestCreateMailReceiver.php
··· 60 60 PhabricatorMetaMTAReceivedMail $mail, 61 61 PhabricatorUser $sender) { 62 62 63 - $task = new ManiphestTask(); 64 - 65 - $task->setAuthorPHID($sender->getPHID()); 63 + $task = ManiphestTask::initializeNewTask($sender); 66 64 $task->setOriginalEmailSource($mail->getHeader('From')); 67 - $task->setPriority(ManiphestTaskPriority::getDefaultPriority()); 68 65 69 66 $editor = new ManiphestTransactionEditor(); 70 67 $editor->setActor($sender);
+16 -3
src/applications/maniphest/storage/ManiphestTask.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group maniphest 5 - */ 6 3 final class ManiphestTask extends ManiphestDAO 7 4 implements 8 5 PhabricatorMarkupInterface, ··· 39 36 40 37 private $groupByProjectPHID = self::ATTACHABLE; 41 38 private $customFields = self::ATTACHABLE; 39 + 40 + public static function initializeNewTask(PhabricatorUser $actor) { 41 + $app = id(new PhabricatorApplicationQuery()) 42 + ->setViewer($actor) 43 + ->withClasses(array('PhabricatorApplicationManiphest')) 44 + ->executeOne(); 45 + 46 + $view_policy = $app->getPolicy(ManiphestCapabilityDefaultView::CAPABILITY); 47 + $edit_policy = $app->getPolicy(ManiphestCapabilityDefaultEdit::CAPABILITY); 48 + 49 + return id(new ManiphestTask()) 50 + ->setPriority(ManiphestTaskPriority::getDefaultPriority()) 51 + ->setAuthorPHID($actor->getPHID()) 52 + ->setViewPolicy($view_policy) 53 + ->setEditPolicy($edit_policy); 54 + } 42 55 43 56 public function getConfiguration() { 44 57 return array(
+6
src/applications/metamta/management/PhabricatorMailManagementShowInboundWorkflow.php
··· 54 54 $info[] = pht('Author PHID: %s', $message->getAuthorPHID()); 55 55 $info[] = pht('Message ID Hash: %s', $message->getMessageIDHash()); 56 56 57 + if ($message->getMessage()) { 58 + $info[] = null; 59 + $info[] = pht('MESSAGE'); 60 + $info[] = $message->getMessage(); 61 + } 62 + 57 63 $info[] = null; 58 64 $info[] = pht('HEADERS'); 59 65 foreach ($message->getHeaders() as $key => $value) {
+3 -1
src/applications/policy/capability/PhabricatorPolicyCapability.php
··· 36 36 * @return string Human-readable name describing what failing a check for this 37 37 * capability prevents the user from doing. 38 38 */ 39 - abstract public function describeCapabilityRejection(); 39 + public function describeCapabilityRejection() { 40 + return null; 41 + } 40 42 41 43 42 44 final public static function getCapabilityByKey($key) {
+10 -2
src/applications/policy/filter/PhabricatorPolicyFilter.php
··· 243 243 } 244 244 245 245 $capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability); 246 + $rejection = null; 246 247 if ($capobj) { 247 248 $rejection = $capobj->describeCapabilityRejection(); 248 249 $capability_name = $capobj->getCapabilityName(); 249 250 } else { 251 + $capability_name = $capability; 252 + } 253 + 254 + if (!$rejection) { 255 + // We couldn't find the capability object, or it doesn't provide a 256 + // tailored rejection string. 250 257 $rejection = pht( 251 258 'You do not have the required capability ("%s") to do whatever you '. 252 259 'are trying to do.', 253 260 $capability); 254 - $capability_name = $capability; 255 261 } 256 262 257 263 $more = PhabricatorPolicy::getPolicyExplanation($this->viewer, $policy); ··· 264 270 // a better error message if we can. 265 271 266 272 $phid = '?'; 267 - if ($object instanceof PhabricatorLiskDAO) { 273 + if (($object instanceof PhabricatorLiskDAO) || 274 + (method_exists($object, 'getPHID'))) { 268 275 try { 269 276 $phid = $object->getPHID(); 270 277 } catch (Exception $ignored) { ··· 276 283 ->setViewer($this->viewer) 277 284 ->withPHIDs(array($phid)) 278 285 ->executeOne(); 286 + 279 287 $object_name = pht( 280 288 '%s %s', 281 289 $handle->getTypeName(),