public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $editable = $this->getAccountEditable(); // There's no sense in showing a change password panel if the user // can't change their password if (!$editable || !PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) { return new Aphront400Response(); } $errors = array(); if ($request->isFormPost()) { if ($user->comparePassword($request->getStr('old_pw'))) { $pass = $request->getStr('new_pw'); $conf = $request->getStr('conf_pw'); if ($pass === $conf) { if (strlen($pass)) { $user->setPassword($pass); // This write is unguarded because the CSRF token has already // been checked in the call to $request->isFormPost() and // the CSRF token depends on the password hash, so when it // is changed here the CSRF token check will fail. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $user->save(); unset($unguarded); return id(new AphrontRedirectResponse())->setURI('/settings/page/password/?saved=true'); } else { $errors[] = 'Your new password is too short.'; } } else { $errors[] = 'New password and confirmation do not match.'; } } else { $errors[] = 'The old password you entered is incorrect.'; } } $notice = null; if (!$errors) { if ($request->getStr('saved')) { $notice = new AphrontErrorView(); $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice->setTitle('Changes Saved'); $notice->appendChild('<p>Your password has been updated.</p>'); } } else { $notice = new AphrontErrorView(); $notice->setTitle('Error Changing Password'); $notice->setErrors($errors); } $form = new AphrontFormView(); $form->setUser($user)->appendChild(id(new AphrontFormPasswordControl())->setLabel('Old Password')->setName('old_pw')); $form->appendChild(id(new AphrontFormPasswordControl())->setLabel('New Password')->setName('new_pw')); $form->appendChild(id(new AphrontFormPasswordControl())->setLabel('Confirm Password')->setName('conf_pw')); $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Save')); $panel = new AphrontPanelView(); $panel->setHeader('Change Password'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); return id(new AphrontNullView())->appendChild(array($notice, $panel)); }
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 processRequest() { $request = $this->getRequest(); $methods = $this->getAllMethods(); if (empty($methods[$this->method])) { return new Aphront404Response(); } $this->setFilter('method/' . $this->method); $method_class = $methods[$this->method]; $method_object = newv($method_class, array()); $status = $method_object->getMethodStatus(); $reason = $method_object->getMethodStatusDescription(); $status_view = null; if ($status != ConduitAPIMethod::METHOD_STATUS_STABLE) { $status_view = new AphrontErrorView(); switch ($status) { case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: $status_view->setTitle('Deprecated Method'); $status_view->appendChild(phutil_escape_html(nonempty($reason, "This method is deprecated."))); break; case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: $status_view->setSeverity(AphrontErrorView::SEVERITY_WARNING); $status_view->setTitle('Unstable Method'); $status_view->appendChild(phutil_escape_html(nonempty($reason, "This method is new and unstable. Its interface is subject " . "to change."))); break; } } $error_description = array(); $error_types = $method_object->defineErrorTypes(); if ($error_types) { $error_description[] = '<ul>'; foreach ($error_types as $error => $meaning) { $error_description[] = '<li>' . '<strong>' . phutil_escape_html($error) . ':</strong> ' . phutil_escape_html($meaning) . '</li>'; } $error_description[] = '</ul>'; $error_description = implode("\n", $error_description); } else { $error_description = "This method does not raise any specific errors."; } $form = new AphrontFormView(); $form->setUser($request->getUser())->setAction('/api/' . $this->method)->appendChild(id(new AphrontFormStaticControl())->setLabel('Description')->setValue($method_object->getMethodDescription()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Returns')->setValue($method_object->defineReturnType()))->appendChild(id(new AphrontFormMarkupControl())->setLabel('Errors')->setValue($error_description))->appendChild('<p class="aphront-form-instructions">Enter parameters using ' . '<strong>JSON</strong>. For instance, to enter a list, type: ' . '<tt>["apple", "banana", "cherry"]</tt>'); $params = $method_object->defineParamTypes(); foreach ($params as $param => $desc) { $form->appendChild(id(new AphrontFormTextControl())->setLabel($param)->setName("params[{$param}]")->setCaption(phutil_escape_html($desc))); } $form->appendChild(id(new AphrontFormSelectControl())->setLabel('Output Format')->setName('output')->setOptions(array('human' => 'Human Readable', 'json' => 'JSON')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Call Method')); $panel = new AphrontPanelView(); $panel->setHeader('Conduit API: ' . phutil_escape_html($this->method)); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FULL); return $this->buildStandardPageResponse(array($status_view, $panel), array('title' => 'Conduit Console - ' . $this->method)); }
public function processRequest() { $this->requireApplicationCapability(ManiphestBulkEditCapability::CAPABILITY); $request = $this->getRequest(); $user = $request->getUser(); $task_ids = $request->getArr('batch'); $tasks = id(new ManiphestTaskQuery())->setViewer($user)->withIDs($task_ids)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute(); $actions = $request->getStr('actions'); if ($actions) { $actions = json_decode($actions, true); } if ($request->isFormPost() && is_array($actions)) { foreach ($tasks as $task) { $field_list = PhabricatorCustomField::getObjectFields($task, PhabricatorCustomField::ROLE_EDIT); $field_list->readFieldsFromStorage($task); $xactions = $this->buildTransactions($actions, $task); if ($xactions) { // TODO: Set content source to "batch edit". $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($task, $xactions); } } $task_ids = implode(',', mpull($tasks, 'getID')); return id(new AphrontRedirectResponse())->setURI('/maniphest/?ids=' . $task_ids); } $handles = ManiphestTaskListView::loadTaskHandles($user, $tasks); $list = new ManiphestTaskListView(); $list->setTasks($tasks); $list->setUser($user); $list->setHandles($handles); $template = new AphrontTokenizerTemplateView(); $template = $template->render(); $projects_source = new PhabricatorProjectDatasource(); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); $owner_source = new PhabricatorTypeaheadOwnerDatasource(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior('maniphest-batch-editor', array('root' => 'maniphest-batch-edit-form', 'tokenizerTemplate' => $template, 'sources' => array('project' => array('src' => $projects_source->getDatasourceURI(), 'placeholder' => $projects_source->getPlaceholderText()), 'owner' => array('src' => $owner_source->getDatasourceURI(), 'placeholder' => $owner_source->getPlaceholderText(), 'limit' => 1), 'cc' => array('src' => $mailable_source->getDatasourceURI(), 'placeholder' => $mailable_source->getPlaceholderText())), 'input' => 'batch-form-actions', 'priorityMap' => ManiphestTaskPriority::getTaskPriorityMap(), 'statusMap' => ManiphestTaskStatus::getTaskStatusMap())); $form = new AphrontFormView(); $form->setUser($user); $form->setID('maniphest-batch-edit-form'); foreach ($tasks as $task) { $form->appendChild(phutil_tag('input', array('type' => 'hidden', 'name' => 'batch[]', 'value' => $task->getID()))); } $form->appendChild(phutil_tag('input', array('type' => 'hidden', 'name' => 'actions', 'id' => 'batch-form-actions'))); $form->appendChild(phutil_tag('p', array(), pht('These tasks will be edited:'))); $form->appendChild($list); $form->appendChild(id(new AphrontFormInsetView())->setTitle('Actions')->setRightButton(javelin_tag('a', array('href' => '#', 'class' => 'button green', 'sigil' => 'add-action', 'mustcapture' => true), pht('Add Another Action')))->setContent(javelin_tag('table', array('sigil' => 'maniphest-batch-actions', 'class' => 'maniphest-batch-actions-table'), '')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Update Tasks'))->addCancelButton('/maniphest/')); $title = pht('Batch Editor'); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Batch Edit Tasks'))->setForm($form); return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title, 'device' => false)); }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $document_phids = $saved_query->getParameter('documentPHIDs', array()); $signer_phids = $saved_query->getParameter('signerPHIDs', array()); $phids = array_merge($document_phids, $signer_phids); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute(); if (!$this->document) { $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new LegalpadDocumentDatasource())->setName('documents')->setLabel(pht('Documents'))->setValue(array_select_keys($handles, $document_phids))); } $name_contains = $saved_query->getParameter('nameContains', ''); $email_contains = $saved_query->getParameter('emailContains', ''); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('signers')->setLabel(pht('Signers'))->setValue(array_select_keys($handles, $signer_phids)))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name Contains'))->setName('nameContains')->setValue($name_contains))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Email Contains'))->setName('emailContains')->setValue($email_contains)); }
public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); $method = id(new PhabricatorConduitMethodQuery())->setViewer($viewer)->withMethods(array($this->method))->executeOne(); if (!$method) { return new Aphront404Response(); } $can_call_method = false; $status = $method->getMethodStatus(); $reason = $method->getMethodStatusDescription(); $errors = array(); switch ($status) { case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: $reason = nonempty($reason, pht('This method is deprecated.')); $errors[] = pht('Deprecated Method: %s', $reason); break; case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: $reason = nonempty($reason, pht('This method is new and unstable. Its interface is subject ' . 'to change.')); $errors[] = pht('Unstable Method: %s', $reason); break; } $error_types = $method->defineErrorTypes(); if ($error_types) { $error_description = array(); foreach ($error_types as $error => $meaning) { $error_description[] = hsprintf('<li><strong>%s:</strong> %s</li>', $error, $meaning); } $error_description = phutil_tag('ul', array(), $error_description); } else { $error_description = pht('This method does not raise any specific errors.'); } $form = new AphrontFormView(); $form->setUser($request->getUser())->setAction('/api/' . $this->method)->addHiddenInput('allowEmptyParams', 1)->appendChild(id(new AphrontFormStaticControl())->setLabel('Description')->setValue($method->getMethodDescription()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Returns')->setValue($method->defineReturnType()))->appendChild(id(new AphrontFormMarkupControl())->setLabel('Errors')->setValue($error_description))->appendChild(hsprintf('<p class="aphront-form-instructions">Enter parameters using ' . '<strong>JSON</strong>. For instance, to enter a list, type: ' . '<tt>["apple", "banana", "cherry"]</tt>')); $params = $method->defineParamTypes(); foreach ($params as $param => $desc) { $form->appendChild(id(new AphrontFormTextControl())->setLabel($param)->setName("params[{$param}]")->setCaption($desc)); } $must_login = !$viewer->isLoggedIn() && $method->shouldRequireAuthentication(); if ($must_login) { $errors[] = pht('Login Required: This method requires authentication. You must ' . 'log in before you can make calls to it.'); } else { $form->appendChild(id(new AphrontFormSelectControl())->setLabel('Output Format')->setName('output')->setOptions(array('human' => 'Human Readable', 'json' => 'JSON')))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getApplicationURI())->setValue(pht('Call Method'))); } $header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($method->getAPIMethodName()); $form_box = id(new PHUIObjectBoxView())->setHeader($header)->setFormErrors($errors)->setForm($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($method->getAPIMethodName()); return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $method->getAPIMethodName())); }
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 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) { $responsible_phids = $saved->getParameter('responsiblePHIDs', array()); $author_phids = $saved->getParameter('authorPHIDs', array()); $reviewer_phids = $saved->getParameter('reviewerPHIDs', array()); $subscriber_phids = $saved->getParameter('subscriberPHIDs', array()); $repository_phids = $saved->getParameter('repositoryPHIDs', array()); $only_draft = $saved->getParameter('draft', false); $all_phids = array_mergev(array($responsible_phids, $author_phids, $reviewer_phids, $subscriber_phids, $repository_phids)); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($all_phids)->execute(); $form->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Responsible Users'))->setName('responsibles')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $responsible_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Authors'))->setName('authors')->setDatasource(new PhabricatorPeopleDatasource())->setValue(array_select_keys($handles, $author_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Reviewers'))->setName('reviewers')->setDatasource(new PhabricatorProjectOrUserDatasource())->setValue(array_select_keys($handles, $reviewer_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Subscribers'))->setName('subscribers')->setDatasource(new PhabricatorMetaMTAMailableDatasource())->setValue(array_select_keys($handles, $subscriber_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Repositories'))->setName('repositories')->setDatasource(new DiffusionRepositoryDatasource())->setValue(array_select_keys($handles, $repository_phids)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setOptions($this->getStatusOptions())->setValue($saved->getParameter('status'))); if ($this->requireViewer()->isLoggedIn()) { $form->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('draft', 1, pht('Show only revisions with a draft comment.'), $only_draft)); } $form->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Order'))->setName('order')->setOptions($this->getOrderOptions())->setValue($saved->getParameter('order'))); }
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 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 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 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')); } }
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(); $voted = $saved_query->getParameter('voted', false); $statuses = $saved_query->getParameter('statuses', array()); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->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) { $phids = $saved_query->getParameter('authorPHIDs', array()); $author_handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute(); $content_type = $saved_query->getParameter('contentType'); $rule_type = $saved_query->getParameter('ruleType'); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Authors'))->setValue($author_handles))->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 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 processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $task_ids = $request->getArr('batch'); $tasks = id(new ManiphestTask())->loadAllWhere('id IN (%Ld)', $task_ids); $actions = $request->getStr('actions'); if ($actions) { $actions = json_decode($actions, true); } if ($request->isFormPost() && is_array($actions)) { foreach ($tasks as $task) { $xactions = $this->buildTransactions($actions, $task); if ($xactions) { $editor = new ManiphestTransactionEditor(); $editor->applyTransactions($task, $xactions); } } $task_ids = implode(',', mpull($tasks, 'getID')); return id(new AphrontRedirectResponse())->setURI('/maniphest/view/custom/?s=oc&tasks=' . $task_ids); } $panel = new AphrontPanelView(); $panel->setHeader('Maniphest Batch Editor'); $handle_phids = mpull($tasks, 'getOwnerPHID'); $handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles(); $list = new ManiphestTaskListView(); $list->setTasks($tasks); $list->setUser($user); $list->setHandles($handles); $template = new AphrontTokenizerTemplateView(); $template = $template->render(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior('maniphest-batch-editor', array('root' => 'maniphest-batch-edit-form', 'tokenizerTemplate' => $template, 'sources' => array('project' => array('src' => '/typeahead/common/projects/', 'placeholder' => 'Type a project name...'), 'owner' => array('src' => '/typeahead/common/searchowner/', 'placeholder' => 'Type a user name...', 'limit' => 1)), 'input' => 'batch-form-actions', 'priorityMap' => ManiphestTaskPriority::getTaskPriorityMap(), 'statusMap' => ManiphestTaskStatus::getTaskStatusMap())); $form = new AphrontFormView(); $form->setUser($user); $form->setID('maniphest-batch-edit-form'); foreach ($tasks as $task) { $form->appendChild(phutil_render_tag('input', array('type' => 'hidden', 'name' => 'batch[]', 'value' => $task->getID()), null)); } $form->appendChild(phutil_render_tag('input', array('type' => 'hidden', 'name' => 'actions', 'id' => 'batch-form-actions'), null)); $form->appendChild('<p>These tasks will be edited:</p>'); $form->appendChild($list); $form->appendChild(id(new AphrontFormInsetView())->setTitle('Actions')->setRightButton(javelin_render_tag('a', array('href' => '#', 'class' => 'button green', 'sigil' => 'add-action', 'mustcapture' => true), 'Add Another Action'))->setContent(javelin_render_tag('table', array('sigil' => 'maniphest-batch-actions', 'class' => 'maniphest-batch-actions-table'), '')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Update Tasks')->addCancelButton('/maniphest/', 'Done')); $panel->appendChild($form); return $this->buildStandardPageResponse($panel, array('title' => 'Batch Editor')); }
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 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 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); $phids = array_merge($user_phids); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute(); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('users')->setLabel(pht('Users'))->setValue($handles))->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 processRequest() { if ($this->id) { $item = id(new PhabricatorDirectoryItem())->load($this->id); if (!$item) { return new Aphront404Response(); } } else { $item = new PhabricatorDirectoryItem(); } $e_name = true; $e_href = true; $errors = array(); $request = $this->getRequest(); if ($request->isFormPost()) { $item->setName($request->getStr('name')); $item->setHref($request->getStr('href')); $item->setDescription($request->getStr('description')); $item->setCategoryID($request->getStr('categoryID')); $item->setSequence($request->getStr('sequence')); if (!strlen($item->getName())) { $errors[] = 'Item name is required.'; $e_name = 'Required'; } if (!strlen($item->getHref())) { $errors[] = 'Item link is required.'; $e_href = 'Required'; } if (!$errors) { $item->save(); return id(new AphrontRedirectResponse())->setURI('/directory/item/'); } } $error_view = null; if ($errors) { $error_view = id(new AphrontErrorView())->setTitle('Form Errors')->setErrors($errors); } $form = new AphrontFormView(); $form->setUser($request->getUser()); if ($item->getID()) { $form->setAction('/directory/item/edit/' . $item->getID() . '/'); } else { $form->setAction('/directory/item/edit/'); } $categories = id(new PhabricatorDirectoryCategory())->loadAll(); $category_map = mpull($categories, 'getName', 'getID'); $form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($item->getName())->setError($e_name))->appendChild(id(new AphrontFormSelectControl())->setLabel('Category')->setName('categoryID')->setOptions($category_map)->setValue($item->getCategoryID()))->appendChild(id(new AphrontFormTextControl())->setLabel('Link')->setName('href')->setValue($item->getHref())->setError($e_href))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Description')->setName('description')->setValue($item->getDescription()))->appendChild(id(new AphrontFormTextControl())->setLabel('Order')->setName('sequence')->setCaption('Items in a category are sorted by "order", then by name.')->setValue((int) $item->getSequence()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save')->addCancelButton('/directory/item/')); $panel = new AphrontPanelView(); if ($item->getID()) { $panel->setHeader('Edit Directory Item'); } else { $panel->setHeader('Create New Directory Item'); } $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Edit Directory Item')); }
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); }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved) { $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name Contains'))->setName('name')->setValue($saved->getParameter('name'))); $all_types = array(); foreach (DivinerAtom::getAllTypes() as $type) { $all_types[$type] = DivinerAtom::getAtomTypeNameString($type); } asort($all_types); $types = $saved->getParameter('types', array()); $types = array_fuse($types); $type_control = id(new AphrontFormCheckboxControl())->setLabel(pht('Types')); foreach ($all_types as $type => $name) { $type_control->addCheckbox('types[]', $type, $name, isset($types[$type])); } $form->appendChild($type_control); $form->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DivinerBookDatasource())->setName('bookPHIDs')->setLabel(pht('Books'))->setValue($saved->getParameter('bookPHIDs'))); $form->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Repositories'))->setName('repositoryPHIDs')->setDatasource(new DiffusionRepositoryDatasource())->setValue($saved->getParameter('repositoryPHIDs'))); }
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 renderExample() { $filter = new AphrontListFilterView(); $filter->addButton(phutil_render_tag('a', array('href' => '#', 'class' => 'button green'), 'Create New Thing')); $form = new AphrontFormView(); $form->setUser($this->getRequest()->getUser()); $form->appendChild(id(new AphrontFormTextControl())->setLabel('Query'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Search')); $filter->appendChild($form); return $filter; }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $status = $saved_query->getParameter('status', ''); $paneltype = $saved_query->getParameter('paneltype', ''); $panel_types = PhabricatorDashboardPanelType::getAllPanelTypes(); $panel_types = mpull($panel_types, 'getPanelTypeName', 'getPanelTypeKey'); asort($panel_types); $panel_types = array('' => pht('(All Types)')) + $panel_types; $form->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Status'))->setName('status')->setValue($status)->setOptions(array('' => pht('(All Panels)'), 'active' => pht('Active Panels'), 'archived' => pht('Archived Panels'))))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Panel Type'))->setName('paneltype')->setValue($paneltype)->setOptions($panel_types)); }
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()); $phids = array_mergev(array($auditor_phids, $commit_author_phids, $repository_phids)); $handles = id(new PhabricatorHandleQuery())->setViewer($this->requireViewer())->withPHIDs($phids)->execute(); $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionAuditorDatasource())->setName('auditorPHIDs')->setLabel(pht('Auditors'))->setValue(array_select_keys($handles, $auditor_phids)))->appendChild(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('authors')->setLabel(pht('Commit Authors'))->setValue(array_select_keys($handles, $commit_author_phids)))->appendChild(id(new AphrontFormSelectControl())->setName('auditStatus')->setLabel(pht('Audit Status'))->setOptions($this->getAuditStatusOptions())->setValue($audit_status))->appendChild(id(new AphrontFormTokenizerControl())->setLabel(pht('Repositories'))->setName('repositoryPHIDs')->setDatasource(new DiffusionRepositoryDatasource())->setValue(array_select_keys($handles, $repository_phids))); }
public function processRequest() { $request = $this->getRequest(); if ($request->isFormPost()) { $mail = new PhabricatorMetaMTAMail(); $mail->addTos($request->getArr('to')); $mail->addCCs($request->getArr('cc')); $mail->setSubject($request->getStr('subject')); $mail->setBody($request->getStr('body')); $files = $request->getArr('files'); if ($files) { foreach ($files as $phid) { $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid); $mail->addAttachment(new PhabricatorMetaMTAAttachment($file->loadFileData(), $file->getName(), $file->getMimeType())); } } $mail->setFrom($request->getUser()->getPHID()); $mail->setSimulatedFailureCount($request->getInt('failures')); $mail->setIsHTML($request->getInt('html')); $mail->setIsBulk($request->getInt('bulk')); $mail->setMailTags($request->getStrList('mailtags')); $mail->save(); if ($request->getInt('immediately')) { $mail->sendNow(); } return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/view/' . $mail->getID() . '/')); } $failure_caption = "Enter a number to simulate that many consecutive send failures before " . "really attempting to deliver via the underlying MTA."; $doclink_href = PhabricatorEnv::getDoclink('article/Configuring_Outbound_Email.html'); $doclink = phutil_render_tag('a', array('href' => $doclink_href, 'target' => '_blank'), 'Configuring Outbound Email'); $instructions = '<p class="aphront-form-instructions">This form will send a normal ' . 'email using the settings you have configured for Phabricator. For more ' . 'information, see ' . $doclink . '.</p>'; $adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter'); $warning = null; if ($adapter == 'PhabricatorMailImplementationTestAdapter') { $warning = new AphrontErrorView(); $warning->setTitle('Email is Disabled'); $warning->setSeverity(AphrontErrorView::SEVERITY_WARNING); $warning->appendChild('<p>This installation of Phabricator is currently set to use ' . '<tt>PhabricatorMailImplementationTestAdapter</tt> to deliver ' . 'outbound email. This completely disables outbound email! All ' . 'outbound email will be thrown in a deep, dark hole until you ' . 'configure a real adapter.</p>'); } $panel_id = celerity_generate_unique_node_id(); $phdlink_href = PhabricatorEnv::getDoclink('article/Managing_Daemons_with_phd.html'); $phdlink = phutil_render_tag('a', array('href' => $phdlink_href, 'target' => '_blank'), '"phd start"'); $form = new AphrontFormView(); $form->setUser($request->getUser()); $form->appendChild($instructions)->appendChild(id(new AphrontFormStaticControl())->setLabel('Adapter')->setValue($adapter))->appendChild(id(new AphrontFormTokenizerControl())->setLabel('To')->setName('to')->setDatasource('/typeahead/common/mailable/'))->appendChild(id(new AphrontFormTokenizerControl())->setLabel('CC')->setName('cc')->setDatasource('/typeahead/common/mailable/'))->appendChild(id(new AphrontFormTextControl())->setLabel('Subject')->setName('subject'))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Body')->setName('body'))->appendChild(id(new AphrontFormTextControl())->setLabel('Mail Tags')->setName('mailtags')->setCaption('Example: <tt>differential-cc, differential-comment</tt>'))->appendChild(id(new AphrontFormDragAndDropUploadControl())->setLabel('Attach Files')->setName('files')->setDragAndDropTarget($panel_id)->setActivatedClass('aphront-panel-view-drag-and-drop'))->appendChild(id(new AphrontFormTextControl())->setLabel('Simulate Failures')->setName('failures')->setCaption($failure_caption))->appendChild(id(new AphrontFormCheckboxControl())->setLabel('HTML')->addCheckbox('html', '1', 'Send as HTML email.'))->appendChild(id(new AphrontFormCheckboxControl())->setLabel('Bulk')->addCheckbox('bulk', '1', 'Send with bulk email headers.'))->appendChild(id(new AphrontFormCheckboxControl())->setLabel('Send Now')->addCheckbox('immediately', '1', 'Send immediately. (Do not enqueue for daemons.)', PhabricatorEnv::getEnvConfig('metamta.send-immediately'))->setCaption('Daemons can be started with ' . $phdlink . '.'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Send Mail')); $panel = new AphrontPanelView(); $panel->setHeader('Send Email'); $panel->appendChild($form); $panel->setID($panel_id); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $nav = $this->buildSideNavView(); $nav->selectFilter('send'); $nav->appendChild(array($warning, $panel)); return $this->buildApplicationPage($nav, array('title' => 'Send Test')); }
public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved_query) { $creator_phids = $saved_query->getParameter('creatorPHIDs', array()); $contributor_phids = $saved_query->getParameter('contributorPHIDs', array()); $viewer_signature = $saved_query->getParameter('withViewerSignature'); if (!$this->requireViewer()->getPHID()) { $viewer_signature = false; } $form->appendChild(id(new AphrontFormCheckboxControl())->addCheckbox('withViewerSignature', 1, pht('Show only documents I have signed.'), $viewer_signature)->setDisabled(!$this->requireViewer()->getPHID()))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('creators')->setLabel(pht('Creators'))->setValue($creator_phids))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorPeopleDatasource())->setName('contributors')->setLabel(pht('Contributors'))->setValue($contributor_phids)); $this->buildDateRange($form, $saved_query, 'createdStart', pht('Created After'), 'createdEnd', pht('Created Before')); }