@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.

Allow task policies to be edited from the UI; show policy information on the detail page

Summary:
Ref T603. Adds policy controls to the task edit UI.

@chad, status + policy renders a little weird -- did I mess something up? See screenshot.

Test Plan: Edited policies, viewed a task.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T603

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

+49 -2
+3 -1
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 372 372 373 373 private function buildHeaderView(ManiphestTask $task) { 374 374 $view = id(new PHUIHeaderView()) 375 - ->setHeader($task->getTitle()); 375 + ->setHeader($task->getTitle()) 376 + ->setUser($this->getRequest()->getUser()) 377 + ->setPolicyObject($task); 376 378 377 379 $status = $task->getStatus(); 378 380 $status_name = ManiphestTaskStatus::renderFullDescription($status);
+28
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 181 181 $changes[ManiphestTransaction::TYPE_PROJECTS] = 182 182 $request->getArr('projects'); 183 183 184 + $changes[PhabricatorTransactions::TYPE_VIEW_POLICY] = 185 + $request->getStr('viewPolicy'); 186 + $changes[PhabricatorTransactions::TYPE_EDIT_POLICY] = 187 + $request->getStr('editPolicy'); 188 + 184 189 if ($files) { 185 190 $file_map = mpull($files, 'getPHID'); 186 191 $file_map = array_fill_keys($file_map, array()); ··· 431 436 ->setOptions(ManiphestTaskStatus::getTaskStatusMap())); 432 437 } 433 438 439 + $policies = id(new PhabricatorPolicyQuery()) 440 + ->setViewer($user) 441 + ->setObject($task) 442 + ->execute(); 443 + 434 444 $form 435 445 ->appendChild( 436 446 id(new AphrontFormTokenizerControl()) ··· 453 463 ->setName('priority') 454 464 ->setOptions($priority_map) 455 465 ->setValue($task->getPriority())) 466 + ->appendChild( 467 + id(new AphrontFormPolicyControl()) 468 + ->setUser($user) 469 + ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) 470 + ->setPolicyObject($task) 471 + ->setPolicies($policies) 472 + ->setName('viewPolicy')) 473 + ->appendChild( 474 + id(new AphrontFormPolicyControl()) 475 + ->setUser($user) 476 + ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) 477 + ->setPolicyObject($task) 478 + ->setPolicies($policies) 479 + ->setCaption( 480 + pht( 481 + 'NOTE: These policy controls still have some rough edges and '. 482 + 'are not yet fully functional.')) 483 + ->setName('editPolicy')) 456 484 ->appendChild( 457 485 id(new AphrontFormTokenizerControl()) 458 486 ->setLabel(pht('Projects'))
+2
src/applications/maniphest/editor/ManiphestTransactionEditorPro.php
··· 16 16 $types[] = ManiphestTransaction::TYPE_PROJECTS; 17 17 $types[] = ManiphestTransaction::TYPE_ATTACH; 18 18 $types[] = ManiphestTransaction::TYPE_EDGE; 19 + $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 20 + $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 19 21 20 22 return $types; 21 23 }
+16 -1
src/applications/maniphest/storage/ManiphestTask.php
··· 199 199 } 200 200 201 201 public function getPolicy($capability) { 202 - return PhabricatorPolicies::POLICY_USER; 202 + switch ($capability) { 203 + case PhabricatorPolicyCapability::CAN_VIEW: 204 + return $this->getViewPolicy(); 205 + case PhabricatorPolicyCapability::CAN_EDIT: 206 + return $this->getEditPolicy(); 207 + } 203 208 } 204 209 205 210 public function hasAutomaticCapability($capability, PhabricatorUser $user) { 211 + 212 + // The owner of a task can always view and edit it. 213 + $owner_phid = $this->getOwnerPHID(); 214 + if ($owner_phid) { 215 + $user_phid = $user->getPHID(); 216 + if ($user_phid == $owner_phid) { 217 + return true; 218 + } 219 + } 220 + 206 221 return false; 207 222 } 208 223