public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $options = array();
     $author_value = null;
     $owner_value = null;
     $subscribers_value = null;
     $project_value = null;
     $author_phids = $saved->getParameter('authorPHIDs', array());
     $owner_phids = $saved->getParameter('ownerPHIDs', array());
     $subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
     $project_phids = $saved->getParameter('projectPHIDs', array());
     $all_phids = array_merge($author_phids, $owner_phids, $subscriber_phids, $project_phids);
     $all_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
     $author_handles = array_select_keys($all_handles, $author_phids);
     $owner_handles = array_select_keys($all_handles, $owner_phids);
     $subscriber_handles = array_select_keys($all_handles, $subscriber_phids);
     $project_handles = array_select_keys($all_handles, $project_phids);
     $with_unowned = $saved->getParameter('withUnowned', array());
     $status_values = $saved->getParameter('statuses', array());
     $status_values = array_fuse($status_values);
     $statuses = array(PhabricatorSearchRelationship::RELATIONSHIP_OPEN => pht('Open'), PhabricatorSearchRelationship::RELATIONSHIP_CLOSED => pht('Closed'));
     $status_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Status'));
     foreach ($statuses as $status => $name) {
         $status_control->addCheckbox('statuses[]', $status, $name, isset($status_values[$status]));
     }
     $type_values = $saved->getParameter('types', array());
     $type_values = array_fuse($type_values);
     $types = self::getIndexableDocumentTypes($this->requireViewer());
     $types_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Document Types'));
     foreach ($types as $type => $name) {
         $types_control->addCheckbox('types[]', $type, $name, isset($type_values[$type]));
     }
     $form->appendChild(phutil_tag('input', array('type' => 'hidden', 'name' => 'jump', 'value' => 'no')))->appendChild(id(new AphrontFormTextControl())->setLabel('Query')->setName('query')->setValue($saved->getParameter('query')))->appendChild($status_control)->appendChild($types_control)->appendChild(id(new AphrontFormTokenizerControl())->setName('authorPHIDs')->setLabel('Authors')->setDatasource(new PhabricatorPeopleDatasource())->setValue($author_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('ownerPHIDs')->setLabel('Owners')->setDatasource(new PhabricatorTypeaheadOwnerDatasource())->setValue($owner_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('withUnowned', 1, pht('Show only unowned documents.'), $with_unowned))->appendChild(id(new AphrontFormTokenizerControl())->setName('subscriberPHIDs')->setLabel('Subscribers')->setDatasource(new PhabricatorPeopleDatasource())->setValue($subscriber_handles))->appendChild(id(new AphrontFormTokenizerControl())->setName('projectPHIDs')->setLabel('In Any Project')->setDatasource(new PhabricatorProjectDatasource())->setValue($project_handles));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $phids = $saved_query->getParameter('authorPHIDs', array());
     $author_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
     $upcoming = $saved_query->getParameter('upcoming');
     $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('upcoming', 1, pht('Show only countdowns that are still counting down.'), $upcoming));
 }
 public function render()
 {
     $question = $this->question;
     $viewer = $this->user;
     $authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
     if (isset($authors[$viewer->getPHID()])) {
         return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
     }
     $info_panel = null;
     if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
         $info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
          but you can still leave a new answer.'));
     }
     $box_style = null;
     $own_question = null;
     $hide_action_id = celerity_generate_unique_node_id();
     $show_action_id = celerity_generate_unique_node_id();
     if ($question->getAuthorPHID() == $viewer->getPHID()) {
         $box_style = 'display: none;';
         $open_link = javelin_tag('a', array('sigil' => 'reveal-content', 'class' => 'mml', 'id' => $hide_action_id, 'href' => '#', 'meta' => array('showIDs' => array($show_action_id), 'hideIDs' => array($hide_action_id))), pht('Add an answer.'));
         $own_question = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setID($hide_action_id)->appendChild(pht('This is your own question. You are welcome to provide
         an answer if you have found a resolution.'))->appendChild($open_link);
     }
     $header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
     $form = new AphrontFormView();
     $form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
     $box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
     if ($info_panel) {
         $box->setInfoView($info_panel);
     }
     $box = phutil_tag('div', array('style' => $box_style, 'class' => 'mlt', 'id' => $show_action_id), $box);
     return array($own_question, $box);
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $user_phids = $saved_query->getParameter('userPHIDs', array());
     $ended = $saved_query->getParameter('ended', PhrequentUserTimeQuery::ENDED_ALL);
     $order = $saved_query->getParameter('order', PhrequentUserTimeQuery::ORDER_ENDED_DESC);
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('users')->setLabel(pht('Users'))->setValue($user_phids))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Ended'))->setName('ended')->setValue($ended)->setOptions(PhrequentUserTimeQuery::getEndedSearchOptions()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Order'))->setName('order')->setValue($order)->setOptions(PhrequentUserTimeQuery::getOrderSearchOptions()));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $author_phids = $saved_query->getParameter('authorPHIDs', array());
     $content_type = $saved_query->getParameter('contentType');
     $rule_type = $saved_query->getParameter('ruleType');
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendChild(id(new AphrontFormSelectControl())->setName('contentType')->setLabel(pht('Content Type'))->setValue($content_type)->setOptions($this->getContentTypeOptions()))->appendChild(id(new AphrontFormSelectControl())->setName('ruleType')->setLabel(pht('Rule Type'))->setValue($rule_type)->setOptions($this->getRuleTypeOptions()))->appendChild(id(new AphrontFormSelectControl())->setName('disabled')->setLabel(pht('Rule Status'))->setValue($this->getBoolFromQuery($saved_query, 'disabled'))->setOptions(array('' => pht('Show Enabled and Disabled Rules'), 'false' => pht('Show Only Enabled Rules'), 'true' => pht('Show Only Disabled Rules'))));
 }
 public function processRequest()
 {
     $event = id(new PhabricatorTimelineEvent('NULL'))->load($this->id);
     if (!$event) {
         return new Aphront404Response();
     }
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($event->getDataID()) {
         $data = id(new PhabricatorTimelineEventData())->load($event->getDataID());
     }
     if ($data) {
         $data = json_encode($data->getEventData());
     } else {
         $data = 'null';
     }
     $form = new AphrontFormView();
     $form->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($event->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($event->getType()))->appendChild(id(new AphrontFormTextAreaControl())->setDisabled(true)->setLabel('Data')->setValue($data))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/timeline/'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Event');
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $panel->appendChild($form);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('timeline');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'Timeline Event'));
 }
 public function processRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $username = $user->getUsername();
     $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
     $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT;
     $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY;
     $preferences = $user->loadPreferences();
     $errors = array();
     if ($request->isFormPost()) {
         $new_timezone = $request->getStr('timezone');
         if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
             $user->setTimezoneIdentifier($new_timezone);
         } else {
             $errors[] = pht('The selected timezone is not a valid timezone.');
         }
         $preferences->setPreference($pref_time, $request->getStr($pref_time))->setPreference($pref_date, $request->getStr($pref_date))->setPreference($pref_week_start, $request->getStr($pref_week_start));
         if (!$errors) {
             $preferences->save();
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
         }
     }
     $timezone_ids = DateTimeZone::listIdentifiers();
     $timezone_id_map = array_fuse($timezone_ids);
     $form = new AphrontFormView();
     $form->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Timezone'))->setName('timezone')->setOptions($timezone_id_map)->setValue($user->getTimezoneIdentifier()))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Time-of-Day Format'))->setName($pref_time)->setOptions(array('g:i A' => pht('12-hour (2:34 PM)'), 'H:i' => pht('24-hour (14:34)')))->setCaption(pht('Format used when rendering a time of day.'))->setValue($preferences->getPreference($pref_time)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Date Format'))->setName($pref_date)->setOptions(array('Y-m-d' => pht('ISO 8601 (2000-02-28)'), 'n/j/Y' => pht('US (2/28/2000)'), 'd-m-Y' => pht('European (28-02-2000)')))->setCaption(pht('Format used when rendering a date.'))->setValue($preferences->getPreference($pref_date)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Week Starts On'))->setOptions($this->getWeekDays())->setName($pref_week_start)->setCaption(pht('Calendar weeks will start with this day.'))->setValue($preferences->getPreference($pref_week_start, 0)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Account Settings')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Date and Time Settings'))->setFormSaved($request->getStr('saved'))->setFormErrors($errors)->setForm($form);
     return array($form_box);
 }
 public function processRequest()
 {
     if ($this->id) {
         $macro = id(new PhabricatorFileImageMacro())->load($this->id);
         if (!$macro) {
             return new Aphront404Response();
         }
     } else {
         $macro = new PhabricatorFileImageMacro();
     }
     $errors = array();
     $e_name = true;
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         $macro->setName($request->getStr('name'));
         if (!strlen($macro->getName())) {
             $errors[] = 'Macro name is required.';
             $e_name = 'Required';
         } else {
             if (!preg_match('/^[a-z0-9_-]{3,}$/', $macro->getName())) {
                 $errors[] = 'Macro must be at least three characters long and contain ' . 'only lowercase letters, digits, hyphen and underscore.';
                 $e_name = 'Invalid';
             } else {
                 $e_name = null;
             }
         }
         if (!$errors) {
             $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $user->getPHID()));
             $macro->setFilePHID($file->getPHID());
             try {
                 $macro->save();
                 return id(new AphrontRedirectResponse())->setURI('/file/macro/');
             } catch (AphrontQueryDuplicateKeyException $ex) {
                 $errors[] = 'Macro name is not unique!';
                 $e_name = 'Duplicate';
             }
         }
     }
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setTitle('Form Errors');
         $error_view->setErrors($errors);
     } else {
         $error_view = null;
     }
     $form = new AphrontFormView();
     $form->setAction('/file/macro/edit/');
     $form->setUser($request->getUser());
     $form->setEncType('multipart/form-data')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($macro->getName())->setCaption('This word or phrase will be replaced with the image.')->setError($e_name))->appendChild(id(new AphrontFormFileControl())->setLabel('File')->setName('file')->setError(true))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save Image Macro')->addCancelButton('/file/macro/'));
     $panel = new AphrontPanelView();
     if ($macro->getID()) {
         $panel->setHeader('Edit Image Macro');
     } else {
         $panel->setHeader('Create Image Macro');
     }
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Image Macro'));
 }
 public function renderValidateFactorForm(PhabricatorAuthFactorConfig $config, AphrontFormView $form, PhabricatorUser $viewer, $validation_result)
 {
     if (!$validation_result) {
         $validation_result = array();
     }
     $form->appendChild(id(new AphrontFormTextControl())->setName($this->getParameterName($config, 'totpcode'))->setLabel(pht('App Code'))->setCaption(pht('Factor Name: %s', $config->getFactorName()))->setValue(idx($validation_result, 'value'))->setError(idx($validation_result, 'error', true)));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $backer_phids = $saved->getParameter('backerPHIDs', array());
     $all_phids = array_mergev(array($backer_phids));
     $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute();
     $form->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Backers'))->setName('backers')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $backer_phids)));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $user_phids = $saved_query->getParameter('userPHIDs', array());
     $proj_phids = $saved_query->getParameter('projectPHIDs', array());
     $viewer_projects = $saved_query->getParameter('viewerProjects');
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('users')->setLabel(pht('Include Users'))->setValue($user_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Include Projects'))->setValue($proj_phids))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('viewerProjects', 1, pht('Include stories about projects I am a member of.'), $viewer_projects));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         $receiver = PhabricatorMetaMTAReceivedMail::loadReceiverObject($request->getStr('obj'));
         if (!$receiver) {
             throw new Exception("No such task or revision!");
         }
         $hash = PhabricatorMetaMTAReceivedMail::computeMailHash($receiver->getMailKey(), $user->getPHID());
         $received = new PhabricatorMetaMTAReceivedMail();
         $received->setHeaders(array('to' => $request->getStr('obj') . '+' . $user->getID() . '+' . $hash . '@'));
         $received->setBodies(array('text' => $request->getStr('body')));
         $received->save();
         $received->processReceivedMail();
         $phid = $receiver->getPHID();
         $handles = $this->loadViewerHandles(array($phid));
         $uri = $handles[$phid]->getURI();
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $form = new AphrontFormView();
     $form->setUser($request->getUser());
     $form->setAction($this->getApplicationURI('/receive/'));
     $form->appendChild('<p class="aphront-form-instructions">This form will simulate ' . 'sending mail to an object.</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('To')->setName('obj')->setCaption('e.g. <tt>D1234</tt> or <tt>T1234</tt>'))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Body')->setName('body'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Receive Mail'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Receive Email');
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('receive');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'Receive Test'));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $author_phids = $saved_query->getParameter('authorPHIDs', array());
     $voted = $saved_query->getParameter('voted', false);
     $statuses = $saved_query->getParameter('statuses', array());
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('voted', 1, pht("Show only polls I've voted in."), $voted))->appendChild(id(new AphrontFormCheckboxControl())->setLabel(pht('Status'))->addCheckbox('statuses[]', 'open', pht('Open'), in_array('open', $statuses))->addCheckbox('statuses[]', 'closed', pht('Closed'), in_array('closed', $statuses)));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $author_phids = $saved_query->getParameter('authorPHIDs', array());
     $answerer_phids = $saved_query->getParameter('answererPHIDs', array());
     $status = $saved_query->getParameter('status', PonderQuestionStatus::STATUS_OPEN);
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('answerers')->setLabel(pht('Answered By'))->setValue($answerer_phids))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(PonderQuestionStatus::getQuestionStatusMap()));
 }
Esempio n. 15
0
 public function render()
 {
     $question = $this->question;
     $viewer = $this->getViewer();
     $authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
     if (isset($authors[$viewer->getPHID()])) {
         $view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
         return phutil_tag_div('ponder-add-answer-view', $view);
     }
     $info_panel = null;
     if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
         $info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
          but you can still leave a new answer.'));
     }
     $box_style = null;
     $header = id(new PHUIHeaderView())->setHeader(pht('New Answer'))->addClass('ponder-add-answer-header');
     $form = new AphrontFormView();
     $form->setViewer($viewer)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setViewer($viewer))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
     if (!$viewer->isLoggedIn()) {
         $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/Q' . $question->getID());
         $form = id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Answer'))->setHref((string) $login_href));
     }
     $box = id(new PHUIObjectBoxView())->appendChild($form)->setHeaderText('Answer')->addClass('ponder-add-answer-view');
     if ($info_panel) {
         $box->setInfoView($info_panel);
     }
     return array($header, $box);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     if ($request->isFormPost()) {
         $parser = new ArcanistDiffParser();
         $diff = null;
         try {
             $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
         } catch (Exception $ex) {
             $diff = $request->getStr('diff');
         }
         $changes = $parser->parseDiff($diff);
         $diff = DifferentialDiff::newFromRawChanges($changes);
         $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
         $diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP);
         $diff->setAuthorPHID($request->getUser()->getPHID());
         $diff->setCreationMethod('web');
         $diff->save();
         return id(new AphrontRedirectResponse())->setURI('/differential/diff/' . $diff->getID() . '/');
     }
     $form = new AphrontFormView();
     $arcanist_href = PhabricatorEnv::getDoclink('article/Arcanist_User_Guide.html');
     $arcanist_link = phutil_render_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), 'Arcanist');
     $form->setAction('/differential/diff/create/')->setEncType('multipart/form-data')->setUser($request->getUser())->appendChild('<p class="aphront-form-instructions">The best way to create a ' . "Differential diff is by using {$arcanist_link}, but you " . 'can also just paste a diff (e.g., from <tt>svn diff</tt> or ' . '<tt>git diff</tt>) into this box or upload it as a file if you ' . 'really want.</p>')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Raw Diff')->setName('diff')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))->appendChild(id(new AphrontFormFileControl())->setLabel('Raw Diff from file')->setName('diff-file'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Create Diff »"));
     $panel = new AphrontPanelView();
     $panel->setHeader('Create New Diff');
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     return $this->buildStandardPageResponse($panel, array('title' => 'Create Diff', 'tab' => 'create'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $phids = $request->getStrList('phids');
     if ($phids) {
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
         $rows = array();
         foreach ($handles as $handle) {
             if ($handle->getURI()) {
                 $link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getURI()));
             } else {
                 $link = null;
             }
             $rows[] = array(phutil_escape_html($handle->getPHID()), phutil_escape_html($handle->getType()), phutil_escape_html($handle->getName()), $link);
         }
         $table = new AphrontTableView($rows);
         $table->setHeaders(array('PHID', 'Type', 'Name', 'URI'));
         $table->setColumnClasses(array(null, null, null, 'wide'));
         $panel = new AphrontPanelView();
         $panel->setHeader('PHID Handles');
         $panel->appendChild($table);
         return $this->buildStandardPageResponse($panel, array('title' => 'PHID Lookup Results'));
     }
     $lookup_form = new AphrontFormView();
     $lookup_form->setUser($request->getUser());
     $lookup_form->setAction('/phid/')->appendChild(id(new AphrontFormTextAreaControl())->setName('phids')->setCaption('Enter PHIDs separated by spaces or commas.'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Lookup PHIDs'));
     $lookup_panel = new AphrontPanelView();
     $lookup_panel->setHeader('Lookup PHIDs');
     $lookup_panel->appendChild($lookup_form);
     $lookup_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
     return $this->buildStandardPageResponse(array($lookup_panel), array('title' => 'PHID Lookup'));
 }
 public function appendFieldsToForm(AphrontFormView $form)
 {
     $enabled = array();
     foreach ($this->fields as $field) {
         if ($field->shouldEnableForRole(PhabricatorCustomField::ROLE_EDIT)) {
             $enabled[] = $field;
         }
     }
     $phids = array();
     foreach ($enabled as $field_key => $field) {
         $phids[$field_key] = $field->getRequiredHandlePHIDsForEdit();
     }
     $all_phids = array_mergev($phids);
     if ($all_phids) {
         $handles = id(new PhabricatorHandleQuery())->setViewer($this->viewer)->withPHIDs($all_phids)->execute();
     } else {
         $handles = array();
     }
     foreach ($enabled as $field_key => $field) {
         $field_handles = array_select_keys($handles, $phids[$field_key]);
         $instructions = $field->getInstructionsForEdit();
         if (strlen($instructions)) {
             $form->appendRemarkupInstructions($instructions);
         }
         $form->appendChild($field->renderEditControl($field_handles));
     }
 }
 public function render()
 {
     $viewer = $this->getViewer();
     $this->requireResource('differential-revision-add-comment-css');
     $revision = $this->revision;
     $action = null;
     if ($this->draft) {
         $action = idx($this->draft->getMetadata(), 'action');
     }
     $enable_reviewers = DifferentialAction::allowReviewers($action);
     $enable_ccs = $action == DifferentialAction::ACTION_ADDCCS;
     $add_reviewers_labels = array('add_reviewers' => pht('Add Reviewers'), 'request_review' => pht('Add Reviewers'), 'resign' => pht('Suggest Reviewers'));
     $mailable_source = new PhabricatorMetaMTAMailableDatasource();
     // TODO: This should be a reviewers datasource, but it's a mess.
     $reviewer_source = new PhabricatorMetaMTAMailableDatasource();
     $form = new AphrontFormView();
     $form->setWorkflow(true)->setViewer($viewer)->setAction($this->actionURI)->addHiddenInput('revision_id', $revision->getID())->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Action'))->setName('action')->setValue($action)->setID('comment-action')->setOptions($this->actions))->appendControl(id(new AphrontFormTokenizerControl())->setLabel($enable_reviewers ? $add_reviewers_labels[$action] : $add_reviewers_labels['add_reviewers'])->setName('reviewers')->setControlID('add-reviewers')->setControlStyle($enable_reviewers ? null : 'display: none')->setID('add-reviewers-tokenizer')->setDisableBehavior(true)->setDatasource($reviewer_source))->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Add Subscribers'))->setName('ccs')->setControlID('add-ccs')->setControlStyle($enable_ccs ? null : 'display: none')->setID('add-ccs-tokenizer')->setDisableBehavior(true)->setDatasource($mailable_source))->appendChild(id(new PhabricatorRemarkupControl())->setName('comment')->setID('comment-content')->setLabel(pht('Comment'))->setValue($this->draft ? $this->draft->getDraft() : null)->setViewer($viewer))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Submit')));
     Javelin::initBehavior('differential-add-reviewers-and-ccs', array('dynamic' => array('add-reviewers-tokenizer' => array('actions' => array('request_review' => 1, 'add_reviewers' => 1, 'resign' => 1), 'src' => $reviewer_source->getDatasourceURI(), 'value' => $this->reviewers, 'row' => 'add-reviewers', 'labels' => $add_reviewers_labels, 'placeholder' => $reviewer_source->getPlaceholderText()), 'add-ccs-tokenizer' => array('actions' => array('add_ccs' => 1), 'src' => $mailable_source->getDatasourceURI(), 'value' => $this->ccs, 'row' => 'add-ccs', 'placeholder' => $mailable_source->getPlaceholderText())), 'select' => 'comment-action'));
     $diff = $revision->loadActiveDiff();
     $rev_id = $revision->getID();
     Javelin::initBehavior('differential-feedback-preview', array('uri' => '/differential/comment/preview/' . $rev_id . '/', 'preview' => 'comment-preview', 'action' => 'comment-action', 'content' => 'comment-content', 'previewTokenizers' => array('reviewers' => 'add-reviewers-tokenizer', 'ccs' => 'add-ccs-tokenizer'), 'inlineuri' => '/differential/comment/inline/preview/' . $rev_id . '/', 'inline' => 'inline-comment-preview'));
     $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
     $header_text = $is_serious ? pht('Add Comment') : pht('Leap Into Action!');
     $header = id(new PHUIHeaderView())->setHeader($header_text);
     $anchor = id(new PhabricatorAnchorView())->setAnchorName('comment')->setNavigationMarker(true);
     $loading = phutil_tag('span', array('class' => 'aphront-panel-preview-loading-text'), pht('Loading comment preview...'));
     $preview = phutil_tag_div('aphront-panel-preview aphront-panel-flush', array(phutil_tag('div', array('id' => 'comment-preview'), $loading), phutil_tag('div', array('id' => 'inline-comment-preview'))));
     $comment_box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($anchor)->appendChild($form);
     if ($this->errorView) {
         $comment_box->setInfoView($this->errorView);
     }
     return array($comment_box, $preview);
 }
 public function processRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $ldap_info = id(new PhabricatorUserLDAPInfo())->loadOneWhere('userID = %d', $user->getID());
     $forms = array();
     if (!$ldap_info) {
         $unlink = 'Link LDAP Account';
         $unlink_form = new AphrontFormView();
         $unlink_form->setUser($user)->setAction('/ldap/login/')->appendChild('<p class="aphront-form-instructions">There is currently no ' . 'LDAP account linked to your Phabricator account. You can link an ' . 'account, which will allow you to use it to log into Phabricator</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('LDAP username')->setName('username'))->appendChild(id(new AphrontFormPasswordControl())->setLabel('Password')->setName('password'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Link LDAP Account »"));
         $forms['Link Account'] = $unlink_form;
     } else {
         $unlink = 'Unlink LDAP Account';
         $unlink_form = new AphrontFormView();
         $unlink_form->setUser($user)->appendChild('<p class="aphront-form-instructions">You may unlink this account ' . 'from your LDAP account. This will prevent you from logging in with ' . 'your LDAP credentials.</p>')->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/ldap/unlink/', $unlink));
         $forms['Unlink Account'] = $unlink_form;
     }
     $panel = new AphrontPanelView();
     $panel->setHeader('LDAP Account Settings');
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     foreach ($forms as $name => $form) {
         if ($name) {
             $panel->appendChild('<br /><h1>' . $name . '</h1><br />');
         }
         $panel->appendChild($form);
     }
     return array($panel);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $project = new PhabricatorProject();
     $project->setAuthorPHID($user->getPHID());
     $profile = new PhabricatorProjectProfile();
     $e_name = true;
     $errors = array();
     if ($request->isFormPost()) {
         try {
             $editor = new PhabricatorProjectEditor($project);
             $editor->setUser($user);
             $editor->setName($request->getStr('name'));
             $editor->save();
         } catch (PhabricatorProjectNameCollisionException $ex) {
             $e_name = 'Not Unique';
             $errors[] = $ex->getMessage();
         }
         $project->setStatus(PhabricatorProjectStatus::ONGOING);
         $profile->setBlurb($request->getStr('blurb'));
         if (!$errors) {
             $project->save();
             $profile->setProjectPHID($project->getPHID());
             $profile->save();
             id(new PhabricatorProjectAffiliation())->setUserPHID($user->getPHID())->setProjectPHID($project->getPHID())->setRole('Owner')->setIsOwner(true)->save();
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('phid' => $project->getPHID(), 'name' => $project->getName()));
             } else {
                 return id(new AphrontRedirectResponse())->setURI('/project/view/' . $project->getID() . '/');
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setTitle('Form Errors');
         $error_view->setErrors($errors);
     }
     if ($request->isAjax()) {
         $form = new AphrontFormLayoutView();
     } else {
         $form = new AphrontFormView();
         $form->setUser($user);
     }
     $form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($project->getName())->setError($e_name))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Blurb')->setName('blurb')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setValue($profile->getBlurb()));
     if ($request->isAjax()) {
         if ($error_view) {
             $error_view->setWidth(AphrontErrorView::WIDTH_DIALOG);
         }
         $dialog = id(new AphrontDialogView())->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle('Create a New Project')->appendChild($error_view)->appendChild($form)->addSubmitButton('Create Project')->addCancelButton('/project/');
         return id(new AphrontDialogResponse())->setDialog($dialog);
     } else {
         $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Create')->addCancelButton('/project/'));
         $panel = new AphrontPanelView();
         $panel->setWidth(AphrontPanelView::WIDTH_FORM)->setHeader('Create a New Project')->appendChild($form);
         return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create new Project'));
     }
 }
Esempio n. 22
0
 public function render()
 {
     $question = $this->question;
     $header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
     $form = new AphrontFormView();
     $form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
     return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $auditor_phids = $saved->getParameter('auditorPHIDs', array());
     $commit_author_phids = $saved->getParameter('commitAuthorPHIDs', array());
     $audit_status = $saved->getParameter('auditStatus', null);
     $repository_phids = $saved->getParameter('repositoryPHIDs', array());
     $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionAuditorDatasource())->setName('auditorPHIDs')->setLabel(pht('Auditors'))->setValue($auditor_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Commit Authors'))->setValue($commit_author_phids))->appendChild(id(new AphrontFormSelectControl())->setName('auditStatus')->setLabel(pht('Audit Status'))->setOptions($this->getAuditStatusOptions())->setValue($audit_status))->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Repositories'))->setName('repositoryPHIDs')->setDatasource(new DiffusionRepositoryDatasource())->setValue($repository_phids));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $phids = $saved_query->getParameter('authorPHIDs', array());
     $author_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
     $explicit = $saved_query->getParameter('explicit');
     $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('explicit', 1, pht('Show only manually uploaded files.'), $explicit));
     $this->buildDateRange($form, $saved_query, 'createdStart', pht('Created After'), 'createdEnd', pht('Created Before'));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name Contains'))->setName('nameContains')->setValue($saved->getParameter('nameContains')));
     $is_stable = $saved->getParameter('isStable');
     $is_unstable = $saved->getParameter('isUnstable');
     $is_deprecated = $saved->getParameter('isDeprecated');
     $form->appendChild(id(new AphrontFormCheckboxControl())->setLabel('Stability')->addCheckbox('isStable', 1, hsprintf('<strong>%s</strong>: %s', pht('Stable Methods'), pht('Show established API methods with stable interfaces.')), $is_stable)->addCheckbox('isUnstable', 1, hsprintf('<strong>%s</strong>: %s', pht('Unstable Methods'), pht('Show new methods which are subject to change.')), $is_unstable)->addCheckbox('isDeprecated', 1, hsprintf('<strong>%s</strong>: %s', pht('Deprecated Methods'), pht('Show old methods which will be deleted in a future ' . 'version of Phabricator.')), $is_deprecated));
 }
 public function renderExample()
 {
     $filter = new AphrontListFilterView();
     $form = new AphrontFormView();
     $form->setUser($this->getRequest()->getUser());
     $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Query')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Search')));
     $filter->appendChild($form);
     return $filter;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $e_name = true;
     $e_callsign = true;
     $repository = new PhabricatorRepository();
     $type_map = PhabricatorRepositoryType::getAllRepositoryTypes();
     $errors = array();
     if ($request->isFormPost()) {
         $repository->setName($request->getStr('name'));
         $repository->setCallsign($request->getStr('callsign'));
         $repository->setVersionControlSystem($request->getStr('type'));
         if (!strlen($repository->getName())) {
             $e_name = 'Required';
             $errors[] = 'Repository name is required.';
         } else {
             $e_name = null;
         }
         if (!strlen($repository->getCallsign())) {
             $e_callsign = 'Required';
             $errors[] = 'Callsign is required.';
         } else {
             if (!preg_match('/^[A-Z]+$/', $repository->getCallsign())) {
                 $e_callsign = 'Invalid';
                 $errors[] = 'Callsign must be ALL UPPERCASE LETTERS.';
             } else {
                 $e_callsign = null;
             }
         }
         if (empty($type_map[$repository->getVersionControlSystem()])) {
             $errors[] = 'Invalid version control system.';
         }
         if (!$errors) {
             try {
                 $repository->save();
                 return id(new AphrontRedirectResponse())->setURI('/repository/edit/' . $repository->getID() . '/');
             } catch (AphrontQueryDuplicateKeyException $ex) {
                 $e_callsign = 'Duplicate';
                 $errors[] = 'Callsign must be unique. Another repository already ' . 'uses that callsign.';
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setErrors($errors);
         $error_view->setTitle('Form Errors');
     }
     $form = new AphrontFormView();
     $form->setUser($user)->setAction('/repository/create/')->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($repository->getName())->setError($e_name)->setCaption('Human-readable repository name.'))->appendChild('<p class="aphront-form-instructions">Select a "Callsign" &mdash; a ' . 'short, uppercase string to identify revisions in this repository. If ' . 'you choose "EX", revisions in this repository will be identified ' . 'with the prefix "rEX".</p>')->appendChild(id(new AphrontFormTextControl())->setLabel('Callsign')->setName('callsign')->setValue($repository->getCallsign())->setError($e_callsign)->setCaption('Short, UPPERCASE identifier. Once set, it can not be changed.'))->appendChild(id(new AphrontFormSelectControl())->setLabel('Type')->setName('type')->setOptions($type_map)->setValue($repository->getVersionControlSystem()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Repository')->addCancelButton('/repository/'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Create Repository');
     $panel->appendChild($form);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create Repository'));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $author_phids = $saved_query->getParameter('authorPHIDs', array());
     $answerer_phids = $saved_query->getParameter('answererPHIDs', array());
     $status = $saved_query->getParameter('status', PonderQuestionStatus::STATUS_OPEN);
     $phids = array_merge($author_phids, $answerer_phids);
     $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
     $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue(array_select_keys($handles, $author_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('answerers')->setLabel(pht('Answered By'))->setValue(array_select_keys($handles, $answerer_phids)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(PonderQuestionStatus::getQuestionStatusMap()));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query)
 {
     $phids = $saved_query->getParameter('authorPHIDs', array());
     $author_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute();
     $statuses = array('' => pht('Any Status'), 'closed' => pht('Closed'), 'open' => pht('Open'));
     $status = $saved_query->getParameter('statuses', array());
     $status = head($status);
     $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setOptions($statuses)->setValue($status));
 }
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $statuses = $saved->getParameter('statuses', array());
     $status_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Status'));
     foreach (DrydockLeaseStatus::getAllStatuses() as $status) {
         $status_control->addCheckbox('statuses[]', $status, DrydockLeaseStatus::getNameForStatus($status), in_array($status, $statuses));
     }
     $form->appendChild($status_control);
 }