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

Enable prefilling of some Maniphest fields in task creation

Summary:
This came up in discussions with both ccheever and fratrik so I prototyped a
"send screenshot to maniphest" feature, which needs this:

https://www.facebook.com/video/video.php?v=892599296749

Test Plan:
Sent screenshot to maniphest.

Reviewed By: aran
Reviewers: jungejason, tuomaspelkonen, aran
CC: ccheever, fratrik, aran, epriestley
Differential Revision: 240

+57 -1
+53 -1
src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php
··· 29 29 $request = $this->getRequest(); 30 30 $user = $request->getUser(); 31 31 32 + $files = array(); 33 + 32 34 if ($this->id) { 33 35 $task = id(new ManiphestTask())->load($this->id); 34 36 if (!$task) { ··· 38 40 $task = new ManiphestTask(); 39 41 $task->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE); 40 42 $task->setAuthorPHID($user->getPHID()); 43 + 44 + // These allow task creation with defaults. 45 + if (!$request->isFormPost()) { 46 + $task->setTitle($request->getStr('title')); 47 + } 48 + 49 + $file_phids = $request->getArr('files', array()); 50 + if (!$file_phids) { 51 + // Allow a single 'file' key instead, mostly since Mac OS X urlencodes 52 + // square brackets in URLs when passed to 'open', so you can't 'open' 53 + // a URL like '?files[]=xyz' and have PHP interpret it correctly. 54 + $phid = $request->getStr('file'); 55 + if ($phid) { 56 + $file_phids = array($phid); 57 + } 58 + } 59 + 60 + if ($file_phids) { 61 + $files = id(new PhabricatorFile())->loadAllWhere( 62 + 'phid IN (%Ls)', 63 + $file_phids); 64 + } 41 65 } 42 66 43 67 $errors = array(); ··· 93 117 = $request->getArr('projects'); 94 118 } 95 119 120 + if ($files) { 121 + $file_map = mpull($files, 'getPHID'); 122 + $file_map = array_fill_keys($file_map, true); 123 + $changes[ManiphestTransactionType::TYPE_ATTACH] = array( 124 + PhabricatorPHIDConstants::PHID_TYPE_FILE => $file_map, 125 + ); 126 + } 127 + 96 128 $template = new ManiphestTransaction(); 97 129 $template->setAuthorPHID($user->getPHID()); 98 130 $transactions = array(); ··· 172 204 $form = new AphrontFormView(); 173 205 $form 174 206 ->setUser($user) 207 + ->setAction($request->getRequestURI()->getPath()) 175 208 ->appendChild( 176 209 id(new AphrontFormTextAreaControl()) 177 210 ->setLabel('Title') ··· 203 236 ->setLabel('Projects') 204 237 ->setName('projects') 205 238 ->setValue($projects_value) 206 - ->setDatasource('/typeahead/common/projects/')) 239 + ->setDatasource('/typeahead/common/projects/')); 240 + 241 + if ($files) { 242 + $file_display = array(); 243 + foreach ($files as $file) { 244 + $file_display[] = phutil_escape_html($file->getName()); 245 + } 246 + $file_display = implode('<br />', $file_display); 247 + 248 + $form->appendChild( 249 + id(new AphrontFormMarkupControl()) 250 + ->setLabel('Files') 251 + ->setValue($file_display)); 252 + 253 + foreach ($files as $ii => $file) { 254 + $form->addHiddenInput('files['.$ii.']', $file->getPHID()); 255 + } 256 + } 257 + 258 + $form 207 259 ->appendChild( 208 260 id(new AphrontFormTextAreaControl()) 209 261 ->setLabel('Description')
+4
src/applications/maniphest/controller/taskedit/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'aphront/response/404'); 10 10 phutil_require_module('phabricator', 'aphront/response/redirect'); 11 + phutil_require_module('phabricator', 'applications/files/storage/file'); 11 12 phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); 12 13 phutil_require_module('phabricator', 'applications/maniphest/constants/status'); 13 14 phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); ··· 15 16 phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); 16 17 phutil_require_module('phabricator', 'applications/maniphest/storage/task'); 17 18 phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); 19 + phutil_require_module('phabricator', 'applications/phid/constants'); 18 20 phutil_require_module('phabricator', 'applications/phid/handle/data'); 19 21 phutil_require_module('phabricator', 'view/form/base'); 22 + phutil_require_module('phabricator', 'view/form/control/markup'); 20 23 phutil_require_module('phabricator', 'view/form/control/select'); 21 24 phutil_require_module('phabricator', 'view/form/control/submit'); 22 25 phutil_require_module('phabricator', 'view/form/control/textarea'); ··· 24 27 phutil_require_module('phabricator', 'view/form/error'); 25 28 phutil_require_module('phabricator', 'view/layout/panel'); 26 29 30 + phutil_require_module('phutil', 'markup'); 27 31 phutil_require_module('phutil', 'utils'); 28 32 29 33