本文整理汇总了PHP中AphrontRequest::isFormPost方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::isFormPost方法的具体用法?PHP AphrontRequest::isFormPost怎么用?PHP AphrontRequest::isFormPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::isFormPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$job = id(new PhabricatorWorkerBulkJobQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->executeOne();
if (!$job) {
return new Aphront404Response();
}
// If the user clicks "Continue" on a completed job, take them back to
// whatever application sent them here.
if ($request->getStr('done')) {
if ($request->isFormPost()) {
$done_uri = $job->getDoneURI();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
}
$title = pht('Bulk Job %d', $job->getID());
if ($job->getStatus() == PhabricatorWorkerBulkJob::STATUS_CONFIRM) {
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $job, PhabricatorPolicyCapability::CAN_EDIT);
if ($can_edit) {
if ($request->isFormPost()) {
$type_status = PhabricatorWorkerBulkJobTransaction::TYPE_STATUS;
$xactions = array();
$xactions[] = id(new PhabricatorWorkerBulkJobTransaction())->setTransactionType($type_status)->setNewValue(PhabricatorWorkerBulkJob::STATUS_WAITING);
$editor = id(new PhabricatorWorkerBulkJobEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->applyTransactions($job, $xactions);
return id(new AphrontRedirectResponse())->setURI($job->getMonitorURI());
} else {
return $this->newDialog()->setTitle(pht('Confirm Bulk Job'))->appendParagraph($job->getDescriptionForConfirm())->appendParagraph(pht('Start work on this bulk job?'))->addCancelButton($job->getManageURI(), pht('Details'))->addSubmitButton(pht('Start Work'));
}
} else {
return $this->newDialog()->setTitle(pht('Waiting For Confirmation'))->appendParagraph(pht('This job is waiting for confirmation before work begins.'))->addCancelButotn($job->getManageURI(), pht('Details'));
}
}
$dialog = $this->newDialog()->setTitle(pht('%s: %s', $title, $job->getStatusName()))->addCancelButton($job->getManageURI(), pht('Details'));
switch ($job->getStatus()) {
case PhabricatorWorkerBulkJob::STATUS_WAITING:
$dialog->appendParagraph(pht('This job is waiting for tasks to be queued.'));
break;
case PhabricatorWorkerBulkJob::STATUS_RUNNING:
$dialog->appendParagraph(pht('This job is running.'));
break;
case PhabricatorWorkerBulkJob::STATUS_COMPLETE:
$dialog->appendParagraph(pht('This job is complete.'));
break;
}
$counts = $job->loadTaskStatusCounts();
if ($counts) {
$dialog->appendParagraph($this->renderProgress($counts));
}
switch ($job->getStatus()) {
case PhabricatorWorkerBulkJob::STATUS_COMPLETE:
$dialog->addHiddenInput('done', true);
$dialog->addSubmitButton(pht('Continue'));
break;
default:
Javelin::initBehavior('bulk-job-reload');
break;
}
return $dialog;
}
示例2: extendOAuthEditForm
protected function extendOAuthEditForm(AphrontRequest $request, AphrontFormView $form, array $values, array $issues, $id_label, $secret_label)
{
$key_id = $this->getIDKey();
$key_secret = $this->getSecretKey();
$key_note = self::PROPERTY_NOTE;
$v_id = $values[$key_id];
$v_secret = $values[$key_secret];
if ($v_secret) {
$v_secret = str_repeat('*', strlen($v_secret));
}
$v_note = $values[$key_note];
$e_id = idx($issues, $key_id, $request->isFormPost() ? null : true);
$e_secret = idx($issues, $key_secret, $request->isFormPost() ? null : true);
$form->appendChild(id(new AphrontFormTextControl())->setLabel($id_label)->setName($key_id)->setValue($v_id)->setError($e_id))->appendChild(id(new AphrontFormPasswordControl())->setLabel($secret_label)->setDisableAutocomplete(true)->setName($key_secret)->setValue($v_secret)->setError($e_secret))->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('OAuth App Notes'))->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setName($key_note)->setValue($v_note));
}
示例3: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
if (!$document) {
return new Aphront404Response();
}
$document_uri = PhrictionDocument::getSlugURI($document->getSlug());
$e_text = null;
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_DELETE)->setNewValue(true);
$editor = id(new PhrictionTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($document, $xactions);
return id(new AphrontRedirectResponse())->setURI($document_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$e_text = phutil_implode_html("\n", $ex->getErrorMessages());
}
}
if ($e_text) {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Can Not Delete Document!'))->appendChild($e_text)->addCancelButton($document_uri);
} else {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Delete Document?'))->appendChild(pht('Really delete this document? You can recover it later by ' . 'reverting to a previous version.'))->addSubmitButton(pht('Delete'))->addCancelButton($document_uri);
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$initiative = id(new FundInitiativeQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$initiative) {
return new Aphront404Response();
}
$initiative_uri = '/' . $initiative->getMonogram();
$is_close = !$initiative->isClosed();
if ($request->isFormPost()) {
$type_status = FundInitiativeTransaction::TYPE_STATUS;
if ($is_close) {
$new_status = FundInitiative::STATUS_CLOSED;
} else {
$new_status = FundInitiative::STATUS_OPEN;
}
$xaction = id(new FundInitiativeTransaction())->setTransactionType($type_status)->setNewValue($new_status);
$editor = id(new FundInitiativeEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true);
$editor->applyTransactions($initiative, array($xaction));
return id(new AphrontRedirectResponse())->setURI($initiative_uri);
}
if ($is_close) {
$title = pht('Close Initiative?');
$body = pht('Really close this initiative? Users will no longer be able to ' . 'back it.');
$button_text = pht('Close Initiative');
} else {
$title = pht('Reopen Initiative?');
$body = pht('Really reopen this initiative?');
$button_text = pht('Reopen Initiative');
}
return $this->newDialog()->setTitle($title)->appendParagraph($body)->addCancelButton($initiative_uri)->addSubmitButton($button_text);
}
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$book_name = $request->getURIData('book');
$book = id(new DivinerBookQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needProjectPHIDs(true)->withNames(array($book_name))->executeOne();
if (!$book) {
return new Aphront404Response();
}
$view_uri = '/book/' . $book->getName() . '/';
if ($request->isFormPost()) {
$v_projects = $request->getArr('projectPHIDs');
$v_view = $request->getStr('viewPolicy');
$v_edit = $request->getStr('editPolicy');
$xactions = array();
$xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($v_projects)));
$xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
$xactions[] = id(new DivinerLiveBookTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
id(new DivinerLiveBookEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($book, $xactions);
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Basics'));
$title = pht('Edit %s', $book->getTitle());
$policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($book)->execute();
$view_capability = PhabricatorPolicyCapability::CAN_VIEW;
$edit_capability = PhabricatorPolicyCapability::CAN_EDIT;
$form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new PhabricatorProjectDatasource())->setName('projectPHIDs')->setLabel(pht('Projects'))->setValue($book->getProjectPHIDs()))->appendControl(id(new AphrontFormTokenizerControl())->setDatasource(new DiffusionRepositoryDatasource())->setName('repositoryPHIDs')->setLabel(pht('Repository'))->setDisableBehavior(true)->setLimit(1)->setValue($book->getRepositoryPHID() ? array($book->getRepositoryPHID()) : null))->appendChild(id(new AphrontFormPolicyControl())->setName('viewPolicy')->setPolicyObject($book)->setCapability($view_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($view_capability)))->appendChild(id(new AphrontFormPolicyControl())->setName('editPolicy')->setPolicyObject($book)->setCapability($edit_capability)->setPolicies($policies)->setCaption($book->describeAutomaticCapability($edit_capability)))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($view_uri));
$object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
$timeline = $this->buildTransactionTimeline($book, new DivinerLiveBookTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(array($crumbs, $object_box, $timeline), array('title' => $title));
}
示例6: handleRequest
public function handleRequest(AphrontRequest $request)
{
$response = $this->loadDiffusionContextForEdit();
if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
if (!$repository->supportsStaging()) {
return new Aphront404Response();
}
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_area = $repository->getHumanReadableDetail('staging-uri');
if ($request->isFormPost()) {
$v_area = $request->getStr('area');
$xactions = array();
$template = id(new PhabricatorRepositoryTransaction());
$type_encoding = PhabricatorRepositoryTransaction::TYPE_STAGING_URI;
$xactions[] = id(clone $template)->setTransactionType($type_encoding)->setNewValue($v_area);
id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Staging'));
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht("To make it easier to run integration tests and builds on code " . "under review, you can configure a **Staging Area**. When `arc` " . "creates a diff, it will push a copy of the changes to the " . "configured staging area with a corresponding tag." . "\n\n" . "IMPORTANT: This feature is new, experimental, and not supported. " . "Use it at your own risk."))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Staging Area URI'))->setName('area')->setValue($v_area))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($edit_uri));
$object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($object_box);
}
示例7: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
if ($request->isFormPost()) {
$log = PhabricatorUserLog::initializeNewLog($viewer, $viewer->getPHID(), PhabricatorUserLog::ACTION_LOGOUT);
$log->save();
// Destroy the user's session in the database so logout works even if
// their cookies have some issues. We'll detect cookie issues when they
// try to login again and tell them to clear any junk.
$phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
if (strlen($phsid)) {
$session = id(new PhabricatorAuthSessionQuery())->setViewer($viewer)->withSessionKeys(array($phsid))->executeOne();
if ($session) {
$session->delete();
}
}
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
return id(new AphrontRedirectResponse())->setURI('/auth/loggedout/');
}
if ($viewer->getPHID()) {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Log out of Phabricator?'))->appendChild(pht('Are you sure you want to log out?'))->addSubmitButton(pht('Logout'))->addCancelButton('/');
return id(new AphrontDialogResponse())->setDialog($dialog);
}
return id(new AphrontRedirectResponse())->setURI('/');
}
示例8: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$viewer = $request->getUser();
$drequest = $this->diffusionRequest;
$repository = $drequest->getRepository();
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne();
if (!$repository) {
return new Aphront404Response();
}
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
// NOTE: We're inverting these here, because the storage is silly.
$v_notify = !$repository->getHumanReadableDetail('herald-disabled');
$v_autoclose = !$repository->getHumanReadableDetail('disable-autoclose');
if ($request->isFormPost()) {
$v_notify = $request->getBool('notify');
$v_autoclose = $request->getBool('autoclose');
$xactions = array();
$template = id(new PhabricatorRepositoryTransaction());
$type_notify = PhabricatorRepositoryTransaction::TYPE_NOTIFY;
$type_autoclose = PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE;
$xactions[] = id(clone $template)->setTransactionType($type_notify)->setNewValue($v_notify);
$xactions[] = id(clone $template)->setTransactionType($type_autoclose)->setNewValue($v_autoclose);
id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($viewer)->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
}
$content = array();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Actions'));
$title = pht('Edit Actions (%s)', $repository->getName());
$policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($repository)->execute();
$form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions(pht("Normally, Phabricator publishes notifications when it discovers " . "new commits. You can disable publishing for this repository by " . "turning off **Notify/Publish**. This will disable notifications, " . "feed, and Herald (including audits and build plans) for this " . "repository.\n\n" . "When Phabricator discovers a new commit, it can automatically " . "close associated revisions and tasks. If you don't want " . "Phabricator to close objects when it discovers new commits in " . "this repository, you can disable **Autoclose**."))->appendChild(id(new AphrontFormSelectControl())->setName('notify')->setLabel(pht('Notify/Publish'))->setValue((int) $v_notify)->setOptions(array(1 => pht('Enable Notifications, Feed and Herald'), 0 => pht('Disable Notifications, Feed and Herald'))))->appendChild(id(new AphrontFormSelectControl())->setName('autoclose')->setLabel(pht('Autoclose'))->setValue((int) $v_autoclose)->setOptions(array(1 => pht('Enable Autoclose'), 0 => pht('Disable Autoclose'))))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Actions'))->addCancelButton($edit_uri));
$form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form);
return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$post = id(new PhamePostQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
if (!$post) {
return new Aphront404Response();
}
$view_uri = $post->getViewURI();
$v_blog = $post->getBlog()->getPHID();
if ($request->isFormPost()) {
$v_blog = $request->getStr('blogPHID');
$xactions = array();
$xactions[] = id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_BLOG)->setNewValue($v_blog);
$editor = id(new PhamePostEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
$editor->applyTransactions($post, $xactions);
$view_uri = $post->getViewURI();
return id(new AphrontRedirectResponse())->setURI($view_uri . '?moved=1');
}
$blogs = id(new PhameBlogQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
$options = mpull($blogs, 'getName', 'getPHID');
asort($options);
$form = id(new PHUIFormLayoutView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Blog'))->setName('blogPHID')->setOptions($options)->setValue($v_blog));
return $this->newDialog()->setTitle(pht('Move Post'))->appendChild($form)->addSubmitButton(pht('Move Post'))->addCancelButton($view_uri);
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$post = id(new PhamePostQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_VIEW))->executeOne();
if (!$post) {
return new Aphront404Response();
}
$view_uri = '/post/view/' . $post->getID() . '/';
$view_uri = $this->getApplicationURI($view_uri);
if ($request->isFormPost()) {
$blog = id(new PhameBlogQuery())->setViewer($viewer)->withIDs(array($request->getInt('blog')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if ($blog) {
$post->setBlogPHID($blog->getPHID());
$post->save();
return id(new AphrontRedirectResponse())->setURI($view_uri . '?moved=1');
}
}
$blogs = id(new PhameBlogQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->execute();
$options = mpull($blogs, 'getName', 'getID');
asort($options);
$selected_value = null;
if ($post && $post->getBlog()) {
$selected_value = $post->getBlog()->getID();
}
$form = id(new PHUIFormLayoutView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Blog'))->setName('blog')->setOptions($options)->setValue($selected_value));
return $this->newDialog()->setTitle(pht('Move Post'))->appendChild($form)->addSubmitButton(pht('Move Post'))->addCancelButton($view_uri);
}
示例11: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->executeOne();
if (!$document) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$document_uri = $this->getApplicationURI('view/' . $document->getID());
$comment = $request->getStr('comment');
$xactions = array();
if (strlen($comment)) {
$xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($comment));
}
$editor = id(new LegalpadDocumentEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($document, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($document_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('branchID');
$branch = id(new ReleephBranchQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($id))->executeOne();
if (!$branch) {
return new Aphront404Response();
}
$this->setBranch($branch);
$symbolic_name = $request->getStr('symbolicName', $branch->getSymbolicName());
if ($request->isFormPost()) {
$existing_with_same_symbolic_name = id(new ReleephBranch())->loadOneWhere('id != %d AND releephProjectID = %d AND symbolicName = %s', $branch->getID(), $branch->getReleephProjectID(), $symbolic_name);
$branch->openTransaction();
$branch->setSymbolicName($symbolic_name);
if ($existing_with_same_symbolic_name) {
$existing_with_same_symbolic_name->setSymbolicName(null)->save();
}
$branch->save();
$branch->saveTransaction();
return id(new AphrontRedirectResponse())->setURI($this->getBranchViewURI($branch));
}
$phids = array();
$phids[] = $creator_phid = $branch->getCreatedByUserPHID();
$phids[] = $cut_commit_phid = $branch->getCutPointCommitPHID();
$handles = id(new PhabricatorHandleQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute();
$form = id(new AphrontFormView())->setUser($request->getUser())->appendChild(id(new AphrontFormStaticControl())->setLabel(pht('Branch Name'))->setValue($branch->getName()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Cut Point'))->setValue($handles[$cut_commit_phid]->renderLink()))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Created By'))->setValue($handles[$creator_phid]->renderLink()))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Symbolic Name'))->setName('symbolicName')->setValue($symbolic_name)->setCaption(pht('Mutable alternate name, for easy reference, (e.g. "LATEST")')))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getBranchViewURI($branch))->setValue(pht('Save Branch')));
$title = pht('Edit Branch %s', $branch->getDisplayNameWithDetail());
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit'));
$box = id(new PHUIObjectBoxView())->setHeaderText($title)->appendChild($form);
return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title));
}
示例13: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$project) {
return new Aphront404Response();
}
$this->setProject($project);
$done_uri = "/project/members/{$id}/";
if (!$project->supportsEditMembers()) {
$copy = pht('Parent projects and milestones do not support adding ' . 'members. You can add members directly to any non-parent subproject.');
return $this->newDialog()->setTitle(pht('Unsupported Project'))->appendParagraph($copy)->addCancelButton($done_uri);
}
if ($request->isFormPost()) {
$member_phids = $request->getArr('memberPHIDs');
$type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST;
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_member)->setNewValue(array('+' => array_fuse($member_phids)));
$editor = id(new PhabricatorProjectTransactionEditor($project))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
$form = id(new AphrontFormView())->setUser($viewer)->appendControl(id(new AphrontFormTokenizerControl())->setName('memberPHIDs')->setLabel(pht('Members'))->setDatasource(new PhabricatorPeopleDatasource()));
return $this->newDialog()->setTitle(pht('Add Members'))->appendForm($form)->addCancelButton($done_uri)->addSubmitButton(pht('Add Members'));
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$engine_key = $request->getURIData('engineKey');
$this->setEngineKey($engine_key);
$key = $request->getURIData('key');
$viewer = $this->getViewer();
$config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$config) {
return id(new Aphront404Response());
}
$cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
if ($request->isFormPost()) {
$xactions = array();
$locks = $request->getArr('locks');
$type_locks = PhabricatorEditEngineConfigurationTransaction::TYPE_LOCKS;
$xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type_locks)->setNewValue($locks);
$editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
$editor->applyTransactions($config, $xactions);
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
}
$engine = $config->getEngine();
$fields = $engine->getFieldsForConfig($config);
$help = pht(<<<EOTEXT
**Locked** fields are visible in the form, but their values can not be changed
by the user.
**Hidden** fields are not visible in the form.
Any assigned default values are still respected, even if the field is locked
or hidden.
EOTEXT
);
$form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions($help);
$locks = $config->getFieldLocks();
$lock_visible = PhabricatorEditEngineConfiguration::LOCK_VISIBLE;
$lock_locked = PhabricatorEditEngineConfiguration::LOCK_LOCKED;
$lock_hidden = PhabricatorEditEngineConfiguration::LOCK_HIDDEN;
$map = array($lock_visible => pht('Visible'), $lock_locked => pht("🔒 Locked"), $lock_hidden => pht("✘ Hidden"));
foreach ($fields as $field) {
if (!$field->getIsLockable()) {
continue;
}
$key = $field->getKey();
$label = $field->getLabel();
if (!strlen($label)) {
$label = $key;
}
if ($field->getIsHidden()) {
$value = $lock_hidden;
} else {
if ($field->getIsLocked()) {
$value = $lock_locked;
} else {
$value = $lock_visible;
}
}
$form->appendControl(id(new AphrontFormSelectControl())->setName('locks[' . $key . ']')->setLabel($label)->setValue($value)->setOptions($map));
}
return $this->newDialog()->setTitle(pht('Lock / Hide Fields'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendForm($form)->addSubmitButton(pht('Save Changes'))->addCancelButton($cancel_uri);
}
示例15: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$badge = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withIDs(array($id))->needRecipients(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$badge) {
return new Aphront404Response();
}
$recipient_phids = $badge->getRecipientPHIDs();
$remove_phid = $request->getStr('phid');
if (!in_array($remove_phid, $recipient_phids)) {
return new Aphront404Response();
}
$recipients_uri = $this->getApplicationURI('recipients/' . $badge->getID() . '/');
if ($request->isFormPost()) {
$recipient_spec = array();
$recipient_spec['-'] = array($remove_phid => $remove_phid);
$type_recipient = PhabricatorBadgeHasRecipientEdgeType::EDGECONST;
$xactions = array();
$xactions[] = id(new PhabricatorBadgesTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $type_recipient)->setNewValue($recipient_spec);
$editor = id(new PhabricatorBadgesEditor($badge))->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($badge, $xactions);
return id(new AphrontRedirectResponse())->setURI($recipients_uri);
}
$handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($remove_phid))->executeOne();
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Really Revoke Badge?'))->appendParagraph(pht('Really revoke the badge "%s" from %s?', phutil_tag('strong', array(), $badge->getName()), phutil_tag('strong', array(), $handle->getName())))->addCancelButton($recipients_uri)->addSubmitButton(pht('Revoke Badge'));
return $dialog;
}