3 final class PhabricatorFlagEditController
extends PhabricatorFlagController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $viewer = $request->getViewer();
7 $phid = $request->getURIData('phid');
9 $handle = id(new PhabricatorHandleQuery())
11 ->withPHIDs(array($phid))
14 if (!$handle->isComplete()) {
15 return new Aphront404Response();
18 $flag = PhabricatorFlagQuery
::loadUserFlag($viewer, $phid);
21 $flag = new PhabricatorFlag();
22 $flag->setOwnerPHID($viewer->getPHID());
23 $flag->setType($handle->getType());
24 $flag->setObjectPHID($handle->getPHID());
25 $flag->setReasonPHID($viewer->getPHID());
28 if ($request->isDialogFormPost()) {
29 $flag->setColor($request->getInt('color'));
30 $flag->setNote($request->getStr('note'));
33 return id(new AphrontReloadResponse())->setURI('/flag/');
36 $type_name = $handle->getTypeName();
38 $dialog = new AphrontDialogView();
39 $dialog->setUser($viewer);
41 $dialog->setTitle(pht('Flag %s', $type_name));
43 require_celerity_resource('phabricator-flag-css');
45 $form = new PHUIFormLayoutView();
47 $is_new = !$flag->getID();
51 ->appendChild(hsprintf(
53 pht('You can flag this %s if you want to remember to look '.
58 $radio = new AphrontFormRadioButtonControl();
59 foreach (PhabricatorFlagColor
::getColorNameMap() as $color => $text) {
60 $class = 'phabricator-flag-radio phabricator-flag-color-'.$color;
61 $radio->addButton($color, $text, '', $class);
68 ->setLabel(pht('Flag Color'))
69 ->setValue($flag->getColor()))
71 id(new AphrontFormTextAreaControl())
72 ->setHeight(AphrontFormTextAreaControl
::HEIGHT_VERY_SHORT
)
74 ->setLabel(pht('Note'))
75 ->setValue($flag->getNote()));
77 $dialog->appendChild($form);
79 $dialog->addCancelButton($handle->getURI());
80 $dialog->addSubmitButton(
81 $is_new ?
pht('Create Flag') : pht('Save'));
83 return id(new AphrontDialogResponse())->setDialog($dialog);