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)); }
protected function processDiffusionRequest(AphrontRequest $request) { $repository_phid = $request->getStr('repositoryPHID'); $repository = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs(array($repository_phid))->executeOne(); if (!$repository) { return new Aphront400Response(); } $query_path = $request->getStr('q'); if (preg_match('@/$@', $query_path)) { $query_dir = $query_path; } else { $query_dir = dirname($query_path) . '/'; } $query_dir = ltrim($query_dir, '/'); $drequest = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'repository' => $repository, 'path' => $query_dir)); $this->setDiffusionRequest($drequest); $browse_results = DiffusionBrowseResultSet::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.browsequery', array('path' => $drequest->getPath(), 'commit' => $drequest->getCommit()))); $paths = $browse_results->getPaths(); $output = array(); foreach ($paths as $path) { $full_path = $query_dir . $path->getPath(); if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) { $full_path .= '/'; } $output[] = array('/' . $full_path, null, substr(md5($full_path), 0, 7)); } return id(new AphrontAjaxResponse())->setContent($output); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $query = id(new PhabricatorProjectQuery())->setViewer($user)->needMembers(true)->needWatchers(true)->needImages(true)->needSlugs(true); $id = $request->getURIData('id'); $slug = $request->getURIData('slug'); if ($slug) { $query->withSlugs(array($slug)); } else { $query->withIDs(array($id)); } $project = $query->executeOne(); if (!$project) { return new Aphront404Response(); } if ($slug && $slug != $project->getPrimarySlug()) { return id(new AphrontRedirectResponse())->setURI('/tag/' . $project->getPrimarySlug() . '/'); } require_celerity_resource('phabricator-profile-css'); $query = new PhabricatorFeedQuery(); $query->setFilterPHIDs(array($project->getPHID())); $query->setLimit(50); $query->setViewer($request->getUser()); $stories = $query->execute(); $feed = $this->renderStories($stories); $content = phutil_tag_div('phabricator-project-feed', $feed); $nav = $this->buildIconNavView($project); $nav->selectFilter("feed/{$id}/"); $nav->appendChild($content); return $this->buildApplicationPage($nav, array('title' => $project->getName())); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $query = id(new PhabricatorProjectQuery())->setViewer($user)->needMembers(true)->needWatchers(true)->needImages(true)->needSlugs(true); $id = $request->getURIData('id'); $slug = $request->getURIData('slug'); if ($slug) { $query->withSlugs(array($slug)); } else { $query->withIDs(array($id)); } $project = $query->executeOne(); if (!$project) { return new Aphront404Response(); } if ($slug && $slug != $project->getPrimarySlug()) { return id(new AphrontRedirectResponse())->setURI('/tag/' . $project->getPrimarySlug() . '/'); } $query = new PhabricatorFeedQuery(); $query->setFilterPHIDs(array($project->getPHID())); $query->setLimit(50); $query->setViewer($request->getUser()); $stories = $query->execute(); $feed = $this->renderStories($stories); $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Project Activity'))->appendChild($feed); $nav = $this->buildIconNavView($project); $nav->selectFilter("feed/{$id}/"); $nav->appendChild($box); return $this->buildApplicationPage($nav, array('title' => $project->getName())); }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->needPaths(true)->executeOne(); if (!$package) { return new Aphront404Response(); } $paths = $package->getPaths(); $repository_phids = array(); foreach ($paths as $path) { $repository_phids[$path->getRepositoryPHID()] = true; } if ($repository_phids) { $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array_keys($repository_phids))->execute(); $repositories = mpull($repositories, null, 'getPHID'); } else { $repositories = array(); } $actions = $this->buildPackageActionView($package); $properties = $this->buildPackagePropertyView($package); $properties->setActionList($actions); $header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($package->getName())->setPolicyObject($package); $panel = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $commit_views = array(); $commit_uri = id(new PhutilURI('/audit/'))->setQueryParams(array('auditorPHIDs' => $package->getPHID())); $attention_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->setLimit(10)->execute(); if ($attention_commits) { $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($attention_commits); $commit_views[] = array('view' => $view, 'header' => pht('Commits in this Package that Need Attention'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri->alter('status', 'open'))->setText(pht('View All Problem Commits'))); } $all_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->needCommitData(true)->setLimit(100)->execute(); $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($all_commits)->setNoDataString(pht('No commits in this package.')); $commit_views[] = array('view' => $view, 'header' => pht('Recent Commits in Package'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri)->setText(pht('View All Package Commits'))); $phids = array(); foreach ($commit_views as $commit_view) { $phids[] = $commit_view['view']->getRequiredHandlePHIDs(); } $phids = array_mergev($phids); $handles = $this->loadViewerHandles($phids); $commit_panels = array(); foreach ($commit_views as $commit_view) { $commit_panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader($commit_view['header']); if (isset($commit_view['button'])) { $header->addActionLink($commit_view['button']); } $commit_view['view']->setHandles($handles); $commit_panel->setHeader($header); $commit_panel->appendChild($commit_view['view']); $commit_panels[] = $commit_panel; } $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($package->getName()); $timeline = $this->buildTransactionTimeline($package, new PhabricatorOwnersPackageTransactionQuery()); $timeline->setShouldTerminate(true); return $this->buildApplicationPage(array($crumbs, $panel, $this->renderPathsTable($paths, $repositories), $commit_panels, $timeline), array('title' => $package->getName())); }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $diff = id(new DifferentialDiffQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$diff) { return new Aphront404Response(); } if ($diff->getRevisionID()) { return id(new AphrontRedirectResponse())->setURI('/D' . $diff->getRevisionID() . '?id=' . $diff->getID()); } $diff_phid = $diff->getPHID(); $buildables = id(new HarbormasterBuildableQuery())->setViewer($viewer)->withBuildablePHIDs(array($diff_phid))->withManualBuildables(false)->needBuilds(true)->needTargets(true)->execute(); $buildables = mpull($buildables, null, 'getBuildablePHID'); $diff->attachBuildable(idx($buildables, $diff_phid)); // TODO: implement optgroup support in AphrontFormSelectControl? $select = array(); $select[] = hsprintf('<optgroup label="%s">', pht('Create New Revision')); $select[] = phutil_tag('option', array('value' => ''), pht('Create a new Revision...')); $select[] = hsprintf('</optgroup>'); $selected_id = $request->getInt('revisionID'); $revisions = $this->loadSelectableRevisions($viewer, $selected_id); if ($revisions) { $select[] = hsprintf('<optgroup label="%s">', pht('Update Existing Revision')); foreach ($revisions as $revision) { if ($selected_id == $revision->getID()) { $selected = 'selected'; } else { $selected = null; } $select[] = phutil_tag('option', array('value' => $revision->getID(), 'selected' => $selected), id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString('D' . $revision->getID() . ' ' . $revision->getTitle())); } $select[] = hsprintf('</optgroup>'); } $select = phutil_tag('select', array('name' => 'revisionID'), $select); $form = id(new AphrontFormView())->setUser($request->getUser())->setAction('/differential/revision/edit/')->addHiddenInput('diffID', $diff->getID())->addHiddenInput('viaDiffView', 1)->addHiddenInput(id(new DifferentialRepositoryField())->getFieldKey(), $diff->getRepositoryPHID())->appendRemarkupInstructions(pht('Review the diff for correctness. When you are satisfied, either ' . '**create a new revision** or **update an existing revision**.'))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Attach To'))->setValue($select))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))); $props = id(new DifferentialDiffProperty())->loadAllWhere('diffID = %d', $diff->getID()); $props = mpull($props, 'getData', 'getName'); $property_head = id(new PHUIHeaderView())->setHeader(pht('Properties')); $property_view = new PHUIPropertyListView(); $changesets = $diff->loadChangesets(); $changesets = msort($changesets, 'getSortKey'); $table_of_contents = $this->buildTableOfContents($changesets, $changesets, $diff->loadCoverageMap($viewer)); $refs = array(); foreach ($changesets as $changeset) { $refs[$changeset->getID()] = $changeset->getID(); } $details = id(new DifferentialChangesetListView())->setChangesets($changesets)->setVisibleChangesets($changesets)->setRenderingReferences($refs)->setStandaloneURI('/differential/changeset/')->setDiff($diff)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTitle(pht('Diff %d', $diff->getID()))->setUser($request->getUser()); $title = pht('Diff %d', $diff->getID()); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $header = id(new PHUIHeaderView())->setHeader($title); $prop_box = id(new PHUIObjectBoxView())->setHeader($property_head)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($property_view)->setForm($form); $view = id(new PHUITwoColumnView())->setHeader($header)->setMainColumn(array())->setFooter(array($prop_box, $table_of_contents, $details)); $page = $this->newPage()->setTitle(pht('Diff View'))->setCrumbs($crumbs)->appendChild($view); return $page; }
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(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->execute(); $table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys.")); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $upload_icon = id(new PHUIIconView())->setIconFont('fa-upload'); $upload_button = id(new PHUIButtonView())->setText(pht('Upload Public Key'))->setHref('/auth/sshkey/upload/?objectPHID=' . $user->getPHID())->setWorkflow(true)->setTag('a')->setIcon($upload_icon); try { PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); $can_generate = true; } catch (Exception $ex) { $can_generate = false; } $generate_icon = id(new PHUIIconView())->setIconFont('fa-lock'); $generate_button = id(new PHUIButtonView())->setText(pht('Generate Keypair'))->setHref('/auth/sshkey/generate/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setDisabled(!$can_generate)->setIcon($generate_icon); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($generate_button); $header->addActionLink($upload_button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $id = $request->getURIData('id'); $blog = id(new PhameBlogQuery())->setViewer($user)->withIDs(array($id))->executeOne(); if (!$blog) { return new Aphront404Response(); } if ($blog->getDomain() && $request->getHost() != $blog->getDomain()) { $base_uri = $blog->getLiveURI(); // Don't redirect directly, since the domain is user-controlled and there // are a bevy of security issues associated with automatic redirects to // external domains. // Previously we CSRF'd this and someone found a way to pass OAuth // information through it using anchors. Just make users click a normal // link so that this is no more dangerous than any other external link // on the site. $dialog = id(new AphrontDialogView())->setTitle(pht('Blog Moved'))->setUser($user)->appendParagraph(pht('This blog is now hosted here:'))->appendParagraph(phutil_tag('a', array('href' => $base_uri), $base_uri))->addCancelButton('/'); return id(new AphrontDialogResponse())->setDialog($dialog); } $phame_request = clone $request; $more = $phame_request->getURIData('more', ''); $phame_request->setPath('/' . ltrim($more, '/')); $uri = $blog->getLiveURI(); $skin = $blog->getSkinRenderer($phame_request); $skin->setBlog($blog)->setBaseURI($uri); $skin->willProcessRequest(array()); return $skin->processRequest(); }
protected function processDiffusionRequest(AphrontRequest $request) { $viewer = $request->getUser(); $this->requireApplicationCapability(DiffusionCreateRepositoriesCapability::CAPABILITY); if ($request->isFormPost()) { if ($request->getStr('type')) { switch ($request->getStr('type')) { case 'create': $uri = $this->getApplicationURI('create/'); break; case 'import': default: $uri = $this->getApplicationURI('import/'); break; } return id(new AphrontRedirectResponse())->setURI($uri); } } $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Repository Hosting'); $doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Diffusion User Guide: Repository Hosting')); $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormRadioButtonControl())->setName('type')->addButton('create', pht('Create a New Hosted Repository'), array(pht('Create a new, empty repository which Phabricator will host. ' . 'For instructions on configuring repository hosting, see %s.', $doc_link)))->addButton('import', pht('Import an Existing External Repository'), pht("Import a repository hosted somewhere else, like GitHub, " . "Bitbucket, or your organization's existing servers. " . "Phabricator will read changes from the repository but will " . "not host or manage it. The authoritative master version of " . "the repository will stay where it is now.")))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($this->getApplicationURI())); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('New Repository')); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Create or Import Repository'))->setForm($form); return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => pht('New Repository'))); }
public function handleRequest(AphrontRequest $request) { $phid = $request->getURIData('phid'); $file = id(new PhabricatorFileQuery())->setViewer($request->getUser())->withPHIDs(array($phid))->executeOne(); if (!$file) { return new Aphront404Response(); } $data = $file->loadFileData(); try { $data = phutil_json_decode($data); } catch (PhutilJSONParserException $ex) { throw new PhutilProxyException(pht('Failed to unserialize XHProf profile!'), $ex); } $symbol = $request->getStr('symbol'); $is_framed = $request->getBool('frame'); if ($symbol) { $view = new PhabricatorXHProfProfileSymbolView(); $view->setSymbol($symbol); } else { $view = new PhabricatorXHProfProfileTopLevelView(); $view->setFile($file); $view->setLimit(100); } $view->setBaseURI($request->getRequestURI()->getPath()); $view->setIsFramed($is_framed); $view->setProfileData($data); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('%s Profile', $symbol)); return $this->buildStandardPageResponse(array($crumbs, $view), array('title' => pht('Profile'), 'frame' => $is_framed)); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $nav = $this->renderSideNavFilterView(null); $filter = $request->getURIData('filter'); $filter = $nav->selectFilter('blog/' . $filter, 'blog/user'); $query = id(new PhameBlogQuery())->setViewer($user); switch ($filter) { case 'blog/all': $title = pht('All Blogs'); $nodata = pht('No blogs have been created.'); break; case 'blog/user': $title = pht('Joinable Blogs'); $nodata = pht('There are no blogs you can contribute to.'); $query->requireCapabilities(array(PhabricatorPolicyCapability::CAN_JOIN)); break; default: throw new Exception(pht("Unknown filter '%s'!", $filter)); } $pager = id(new AphrontPagerView())->setURI($request->getRequestURI(), 'offset')->setOffset($request->getInt('offset')); $blogs = $query->executeWithOffsetPager($pager); $blog_list = $this->renderBlogList($blogs, $user, $nodata); $blog_list->setPager($pager); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, $this->getApplicationURI()); $nav->appendChild(array($crumbs, $blog_list)); return $this->buildApplicationPage($nav, array('title' => $title)); }
protected function processDiffusionRequest(AphrontRequest $request) { $user = $request->getUser(); $drequest = $this->diffusionRequest; $repository = $drequest->getRepository(); $repository = id(new PhabricatorRepositoryQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne(); if (!$repository) { return new Aphront404Response(); } 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($user)->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($user)->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->buildApplicationPage(array($crumbs, $object_box), array('title' => $title)); }
protected function processDiffusionRequest(AphrontRequest $request) { $user = $request->getUser(); $drequest = $this->getDiffusionRequest(); $callsign = $drequest->getRepository()->getCallsign(); $repository = $drequest->getRepository(); $commit = $drequest->loadCommit(); $data = $commit->loadCommitData(); $page_title = pht('Edit Diffusion Commit'); if (!$commit) { return new Aphront404Response(); } $commit_phid = $commit->getPHID(); $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($commit_phid, $edge_type); if ($request->isFormPost()) { $xactions = array(); $proj_phids = $request->getArr('projects'); $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edge_type)->setNewValue(array('=' => array_fuse($proj_phids))); $editor = id(new PhabricatorAuditEditor())->setActor($user)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request); $xactions = $editor->applyTransactions($commit, $xactions); return id(new AphrontRedirectResponse())->setURI('/r' . $callsign . $commit->getCommitIdentifier()); } $tokenizer_id = celerity_generate_unique_node_id(); $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Projects'))->setName('projects')->setValue($current_proj_phids)->setID($tokenizer_id)->setCaption(javelin_tag('a', array('href' => '/project/create/', 'mustcapture' => true, 'sigil' => 'project-create'), pht('Create New Project')))->setDatasource(new PhabricatorProjectDatasource())); $reason = $data->getCommitDetail('autocloseReason', false); $reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED; if ($reason !== false) { switch ($reason) { case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: $desc = pht('No, Repository Importing'); break; case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: $desc = pht('No, Autoclose Disabled'); break; case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH: $desc = pht('No, Not On Autoclose Branch'); break; case PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED: $desc = pht('Yes, Forced Via bin/repository CLI Tool.'); break; case null: $desc = pht('Yes'); break; default: $desc = pht('Unknown'); break; } $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); $doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Learn More')); $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Autoclose?'))->setValue(array($desc, " · ", $doc_link))); } Javelin::initBehavior('project-create', array('tokenizerID' => $tokenizer_id)); $submit = id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton('/r' . $callsign . $commit->getCommitIdentifier()); $form->appendChild($submit); $crumbs = $this->buildCrumbs(array('commit' => true)); $crumbs->addTextCrumb(pht('Edit')); $form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setForm($form); return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $page_title)); }
public function readValueFromRequest(AphrontRequest $request) { $control = $this->newDateControl(); $control->setUser($request->getUser()); $value = $control->readValueFromRequest($request); $this->setFieldValue($value); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $issue = $request->getURIData('key'); $verb = $request->getURIData('verb'); $issue_uri = $this->getApplicationURI('issue/' . $issue . '/'); if ($request->isDialogFormPost()) { $this->manageApplication($issue); return id(new AphrontRedirectResponse())->setURI($issue_uri); } if ($verb == 'ignore') { $title = pht('Really ignore this setup issue?'); $submit_title = pht('Ignore'); $body = pht("You can ignore an issue if you don't want to fix it, or plan to " . "fix it later. Ignored issues won't appear on every page but will " . "still be shown in the list of open issues."); } else { if ($verb == 'unignore') { $title = pht('Unignore this setup issue?'); $submit_title = pht('Unignore'); $body = pht('This issue will no longer be suppressed, and will return to its ' . 'rightful place as a global setup warning.'); } else { throw new Exception(pht('Unrecognized verb: %s', $verb)); } } $dialog = id(new AphrontDialogView())->setUser($request->getUser())->setTitle($title)->appendChild($body)->addSubmitButton($submit_title)->addCancelButton($issue_uri); return id(new AphrontDialogResponse())->setDialog($dialog); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $id = $request->getURIData('id'); $post = id(new PhamePostQuery())->setViewer($user)->withIDs(array($id))->executeOne(); if (!$post) { return new Aphront404Response(); } $reasons = array(); if (!$post->getBlog()) { $reasons[] = phutil_tag('p', array(), pht('You can not view the live version of this post because it ' . 'is not associated with a blog. Move the post to a blog in order to ' . 'view it live.')); } if ($post->isDraft()) { $reasons[] = phutil_tag('p', array(), pht('You can not view the live version of this post because it ' . 'is still a draft. Use "Preview/Publish" to publish the post.')); } if ($reasons) { $cancel_uri = $this->getApplicationURI('/post/view/' . $post->getID() . '/'); $dialog = id(new AphrontDialogView())->setUser($user)->setTitle(pht('Post Not Live'))->addCancelButton($cancel_uri); foreach ($reasons as $reason) { $dialog->appendChild($reason); } return id(new AphrontDialogResponse())->setDialog($dialog); } // No reason this can't go live, maybe an old link. Kick them live and see // what happens. $live_uri = $post->getViewURI(); return id(new AphrontRedirectResponse())->setURI($live_uri); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $id = $request->getURIData('id'); if ($id) { $post = id(new PhamePostQuery())->setViewer($user)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$post) { return new Aphront404Response(); } $cancel_uri = $this->getApplicationURI('/post/view/' . $id . '/'); $submit_button = pht('Save Changes'); $page_title = pht('Edit Post'); } else { $blog = id(new PhameBlogQuery())->setViewer($user)->withIDs(array($request->getInt('blog')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_JOIN))->executeOne(); if (!$blog) { return new Aphront404Response(); } $post = PhamePost::initializePost($user, $blog); $cancel_uri = $this->getApplicationURI('/blog/view/' . $blog->getID() . '/'); $submit_button = pht('Save Draft'); $page_title = pht('Create Post'); } $title = $post->getTitle(); $phame_title = $post->getPhameTitle(); $body = $post->getBody(); $comments_widget = $post->getCommentsWidget(); $e_title = true; $e_phame_title = true; $validation_exception = null; if ($request->isFormPost()) { $title = $request->getStr('title'); $phame_title = $request->getStr('phame_title'); $phame_title = PhabricatorSlug::normalize($phame_title); $body = $request->getStr('body'); $comments_widget = $request->getStr('comments_widget'); $xactions = array(id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_TITLE)->setNewValue($title), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_PHAME_TITLE)->setNewValue($phame_title), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_BODY)->setNewValue($body), id(new PhamePostTransaction())->setTransactionType(PhamePostTransaction::TYPE_COMMENTS_WIDGET)->setNewValue($comments_widget)); $editor = id(new PhamePostEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true); try { $editor->applyTransactions($post, $xactions); $uri = $this->getApplicationURI('/post/view/' . $post->getID() . '/'); return id(new AphrontRedirectResponse())->setURI($uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; $e_title = $validation_exception->getShortMessage(PhamePostTransaction::TYPE_TITLE); $e_phame_title = $validation_exception->getShortMessage(PhamePostTransaction::TYPE_PHAME_TITLE); } } $handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($post->getBlogPHID()))->executeOne(); $form = id(new AphrontFormView())->setUser($user)->addHiddenInput('blog', $request->getInt('blog'))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Blog'))->setValue($handle->renderLink()))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Title'))->setName('title')->setValue($title)->setID('post-title')->setError($e_title))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Phame Title'))->setName('phame_title')->setValue(rtrim($phame_title, '/'))->setID('post-phame-title')->setCaption(pht('Up to 64 alphanumeric characters ' . 'with underscores for spaces. ' . 'Formatting is enforced.'))->setError($e_phame_title))->appendChild(id(new PhabricatorRemarkupControl())->setLabel(pht('Body'))->setName('body')->setValue($body)->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)->setID('post-body')->setUser($user)->setDisableMacros(true))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Comments Widget'))->setName('comments_widget')->setvalue($comments_widget)->setOptions($post->getCommentsWidgetOptionsForSelect()))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue($submit_button)); $loading = phutil_tag_div('aphront-panel-preview-loading-text', pht('Loading preview...')); $preview_panel = phutil_tag_div('aphront-panel-preview', array(phutil_tag_div('phame-post-preview-header', pht('Post Preview')), phutil_tag('div', array('id' => 'post-preview'), $loading))); require_celerity_resource('phame-css'); Javelin::initBehavior('phame-post-preview', array('preview' => 'post-preview', 'body' => 'post-body', 'title' => 'post-title', 'phame_title' => 'post-phame-title', 'uri' => '/phame/post/preview/')); $form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setValidationException($validation_exception)->setForm($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($page_title, $this->getApplicationURI('/post/view/' . $id . '/')); $nav = $this->renderSideNavFilterView(null); $nav->appendChild(array($crumbs, $form_box, $preview_panel)); return $this->buildApplicationPage($nav, array('title' => $page_title)); }
public function handleRequest(AphrontRequest $request) { $response = $this->loadProject(); if ($response) { return $response; } $viewer = $request->getUser(); $project = $this->getProject(); $id = $project->getID(); $picture = $project->getProfileImageURI(); $header = id(new PHUIHeaderView())->setHeader($project->getName())->setUser($viewer)->setPolicyObject($project)->setImage($picture); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $actions = $this->buildActionListView($project); $properties = $this->buildPropertyListView($project, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $member_list = id(new PhabricatorProjectMemberListView())->setUser($viewer)->setProject($project)->setLimit(5)->setUserPHIDs($project->getMemberPHIDs()); $watcher_list = id(new PhabricatorProjectWatcherListView())->setUser($viewer)->setProject($project)->setLimit(5)->setUserPHIDs($project->getWatcherPHIDs()); $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_PROFILE); $watch_action = $this->renderWatchAction($project); $stories = id(new PhabricatorFeedQuery())->setViewer($viewer)->setFilterPHIDs(array($project->getPHID()))->setLimit(50)->execute(); $feed = $this->renderStories($stories); $feed_header = id(new PHUIHeaderView())->setHeader(pht('Recent Activity'))->addActionLink($watch_action); $feed = id(new PHUIObjectBoxView())->setHeader($feed_header)->appendChild($feed); $columns = id(new AphrontMultiColumnView())->setFluidLayout(true)->addColumn($feed)->addColumn(array($member_list, $watcher_list)); $crumbs = $this->buildApplicationCrumbs(); return $this->newPage()->setNavigation($nav)->setCrumbs($crumbs)->setTitle($project->getName())->setPageObjectPHIDs(array($project->getPHID()))->appendChild(array($object_box, $columns)); }
public function handleRequest(AphrontRequest $request) { $response = $this->loadProject(); if ($response) { return $response; } $viewer = $request->getUser(); $project = $this->getProject(); $id = $project->getID(); $picture = $project->getProfileImageURI(); $header = id(new PHUIHeaderView())->setHeader(pht('Project History'))->setUser($viewer)->setPolicyObject($project)->setImage($picture); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $actions = $this->buildActionListView($project); $properties = $this->buildPropertyListView($project, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $timeline = $this->buildTransactionTimeline($project, new PhabricatorProjectTransactionQuery()); $timeline->setShouldTerminate(true); $nav = $this->getProfileMenu(); $nav->selectFilter(PhabricatorProject::PANEL_MANAGE); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Manage')); return $this->newPage()->setNavigation($nav)->setCrumbs($crumbs)->setTitle($project->getName())->appendChild(array($object_box, $timeline)); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); if (!$request->isFormPost()) { return new Aphront400Response(); } $event = id(new PhabricatorCalendarEventQuery())->setViewer($user)->withIDs(array($this->id))->executeOne(); if (!$event) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $view_uri = '/' . $event->getMonogram(); $xactions = array(); $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorCalendarEventTransactionComment())->setContent($request->getStr('comment'))); $editor = id(new PhabricatorCalendarEventEditor())->setActor($user)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($event, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse())->setViewer($user)->setTransactions($xactions)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($view_uri); } }
public function handleRequest(AphrontRequest $request) { $admin = $request->getUser(); id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($admin, $request, $this->getApplicationURI()); $v_type = 'standard'; if ($request->isFormPost()) { $v_type = $request->getStr('type'); if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') { return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('new/' . $v_type . '/')); } } $title = pht('Create New User'); $standard_caption = pht('Create a standard user account. These users can log in to Phabricator, ' . 'use the web interface and API, and receive email.'); $standard_admin = pht('Administrators are limited in their ability to access or edit these ' . 'accounts after account creation.'); $bot_caption = pht('Create a bot/script user account, to automate interactions with other ' . 'systems. These users can not use the web interface, but can use the ' . 'API.'); $bot_admin = pht('Administrators have greater access to edit these accounts.'); $types = array(); $can_create = $this->hasApplicationCapability(PeopleCreateUsersCapability::CAPABILITY); if ($can_create) { $types[] = array('type' => 'standard', 'name' => pht('Create Standard User'), 'help' => pht('Create a standard user account.')); } $types[] = array('type' => 'bot', 'name' => pht('Create Bot User'), 'help' => pht('Create a new user for use with automated scripts.')); $types[] = array('type' => 'list', 'name' => pht('Create Mailing List User'), 'help' => pht('Create a mailing list user to represent an existing, external ' . 'mailing list like a Google Group or a Mailman list.')); $buttons = id(new AphrontFormRadioButtonControl())->setLabel(pht('Account Type'))->setName('type')->setValue($v_type); foreach ($types as $type) { $buttons->addButton($type['type'], $type['name'], $type['help']); } $form = id(new AphrontFormView())->setUser($admin)->appendRemarkupInstructions(pht('Choose the type of user account to create. For a detailed ' . 'explanation of user account types, see [[ %s | User Guide: ' . 'Account Roles ]].', PhabricatorEnv::getDoclink('User Guide: Account Roles')))->appendChild($buttons)->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($this->getApplicationURI())->setValue(pht('Continue'))); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $box = id(new PHUIObjectBoxView())->setHeaderText($title)->appendChild($form); return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title)); }
public function processRequest(AphrontRequest $request) { $viewer = $request->getUser(); $tokens = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($viewer)->withObjectPHIDs(array($viewer->getPHID()))->execute(); $rows = array(); foreach ($tokens as $token) { if ($token->isRevocable()) { $button = javelin_tag('a', array('href' => '/auth/token/revoke/' . $token->getID() . '/', 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Revoke')); } else { $button = javelin_tag('a', array('class' => 'small grey button disabled'), pht('Revoke')); } if ($token->getTokenExpires() >= time()) { $expiry = phabricator_datetime($token->getTokenExpires(), $viewer); } else { $expiry = pht('Expired'); } $rows[] = array($token->getTokenReadableTypeName(), $expiry, $button); } $table = new AphrontTableView($rows); $table->setNoDataString(pht("You don't have any active tokens.")); $table->setHeaders(array(pht('Type'), pht('Expires'), pht(''))); $table->setColumnClasses(array('wide', 'right', 'action')); $terminate_button = id(new PHUIButtonView())->setText(pht('Revoke All'))->setHref('/auth/token/revoke/all/')->setTag('a')->setWorkflow(true)->setIcon('fa-exclamation-triangle'); $header = id(new PHUIHeaderView())->setHeader(pht('Temporary Tokens'))->addActionLink($terminate_button); $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table); return $panel; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $space = id(new PhabricatorSpacesNamespaceQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne(); if (!$space) { return new Aphront404Response(); } $is_archive = $request->getURIData('action') == 'archive'; $cancel_uri = '/' . $space->getMonogram(); if ($request->isFormPost()) { $type_archive = PhabricatorSpacesNamespaceTransaction::TYPE_ARCHIVE; $xactions = array(); $xactions[] = id(new PhabricatorSpacesNamespaceTransaction())->setTransactionType($type_archive)->setNewValue($is_archive ? 1 : 0); $editor = id(new PhabricatorSpacesNamespaceEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request); $editor->applyTransactions($space, $xactions); return id(new AphrontRedirectResponse())->setURI($cancel_uri); } $body = array(); if ($is_archive) { $title = pht('Archive Space: %s', $space->getNamespaceName()); $body[] = pht('If you archive this Space, you will no longer be able to create ' . 'new objects inside it.'); $body[] = pht('Existing objects in this Space will be hidden from query results ' . 'by default.'); $button = pht('Archive Space'); } else { $title = pht('Activate Space: %s', $space->getNamespaceName()); $body[] = pht('If you activate this space, you will be able to create objects ' . 'inside it again.'); $body[] = pht('Existing objects will no longer be hidden from query results.'); $button = pht('Activate Space'); } $dialog = $this->newDialog()->setTitle($title)->addCancelButton($cancel_uri)->addSubmitButton($button); foreach ($body as $paragraph) { $dialog->appendParagraph($paragraph); } return $dialog; }
public function handleRequest(AphrontRequest $request) { // No CSRF for Mailgun. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); if (!$this->verifyMessage()) { throw new Exception(pht('Mail signature is not valid. Check your Mailgun API key.')); } $user = $request->getUser(); $raw_headers = $request->getStr('headers'); $raw_headers = explode("\n", rtrim($raw_headers)); $raw_dict = array(); foreach (array_filter($raw_headers) as $header) { list($name, $value) = explode(':', $header, 2); $raw_dict[$name] = ltrim($value); } $headers = array('to' => $request->getStr('recipient'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict; $received = new PhabricatorMetaMTAReceivedMail(); $received->setHeaders($headers); $received->setBodies(array('text' => $request->getStr('stripped-text'), 'html' => $request->getStr('stripped-html'))); $file_phids = array(); foreach ($_FILES as $file_raw) { try { $file = PhabricatorFile::newFromPHPUpload($file_raw, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE)); $file_phids[] = $file->getPHID(); } catch (Exception $ex) { phlog($ex); } } $received->setAttachments($file_phids); $received->save(); $received->processReceivedMail(); $response = new AphrontWebpageResponse(); $response->setContent(pht("Got it! Thanks, Mailgun!\n")); return $response; }
protected function processDiffusionRequest(AphrontRequest $request) { $user = $request->getUser(); $drequest = $this->diffusionRequest; $repository = $drequest->getRepository(); $repository = id(new PhabricatorRepositoryQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne(); if (!$repository) { return new Aphront404Response(); } $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); $v_local = $repository->getHumanReadableDetail('local-path'); $errors = array(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Edit Storage')); $title = pht('Edit %s', $repository->getName()); $service_phid = $repository->getAlmanacServicePHID(); if ($service_phid) { $handles = $this->loadViewerHandles(array($service_phid)); $v_service = $handles[$service_phid]->renderLink(); } else { $v_service = phutil_tag('em', array(), pht('Local')); } $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Storage Service'))->setValue($v_service))->appendChild(id(new AphrontFormMarkupControl())->setName('local')->setLabel(pht('Storage Path'))->setValue($v_local))->appendRemarkupInstructions(pht("You can not adjust the local path for this repository from the " . "web interface. To edit it, run this command:\n\n %s", sprintf('phabricator/ $ ./bin/repository edit %s --as %s --local-path ...', $repository->getMonogram(), $user->getUsername())))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($edit_uri, pht('Done'))); $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form)->setFormErrors($errors); return $this->buildApplicationPage(array($crumbs, $object_box), array('title' => $title)); }
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)); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $title = pht('New Room'); $e_title = true; $validation_exception = null; $conpherence = ConpherenceThread::initializeNewRoom($user); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => array($user->getPHID()))); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_TITLE)->setNewValue($request->getStr('title')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($request->getStr('viewPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($request->getStr('editPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)->setNewValue($request->getStr('joinPolicy')); try { id(new ConpherenceEditor())->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setActor($user)->applyTransactions($conpherence, $xactions); return id(new AphrontRedirectResponse())->setURI('/' . $conpherence->getMonogram()); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; $e_title = $ex->getShortMessage(ConpherenceTransaction::TYPE_TITLE); $conpherence->setViewPolicy($request->getStr('viewPolicy')); $conpherence->setEditPolicy($request->getStr('editPolicy')); $conpherence->setJoinPolicy($request->getStr('joinPolicy')); } } $policies = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($conpherence)->execute(); $submit_uri = $this->getApplicationURI('room/new/'); $cancel_uri = $this->getApplicationURI('search/'); $dialog = $this->newDialog()->setWidth(AphrontDialogView::WIDTH_FORM)->setValidationException($validation_exception)->setUser($user)->setTitle($title)->addCancelButton($cancel_uri)->addSubmitButton(pht('Create Room')); $form = id(new PHUIFormLayoutView())->setUser($user)->setFullWidth(true)->appendChild(id(new AphrontFormTextControl())->setError($e_title)->setLabel(pht('Title'))->setName('title')->setValue($request->getStr('title')))->appendChild(id(new AphrontFormPolicyControl())->setName('viewPolicy')->setPolicyObject($conpherence)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicies($policies))->appendChild(id(new AphrontFormPolicyControl())->setName('editPolicy')->setPolicyObject($conpherence)->setCapability(PhabricatorPolicyCapability::CAN_EDIT)->setPolicies($policies))->appendChild(id(new AphrontFormPolicyControl())->setName('joinPolicy')->setPolicyObject($conpherence)->setCapability(PhabricatorPolicyCapability::CAN_JOIN)->setPolicies($policies)); $dialog->appendChild($form); return id(new AphrontDialogResponse())->setDialog($dialog); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $file = PhabricatorFile::initializeNewFile(); $e_file = true; $errors = array(); if ($request->isFormPost()) { $view_policy = $request->getStr('viewPolicy'); if (!$request->getFileExists('file')) { $e_file = pht('Required'); $errors[] = pht('You must select a file to upload.'); } else { $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true)); } if (!$errors) { return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); } $file->setViewPolicy($view_policy); } $support_id = celerity_generate_unique_node_id(); $instructions = id(new AphrontFormMarkupControl())->setControlID($support_id)->setControlStyle('display: none')->setValue(hsprintf('<br /><br /><strong>%s</strong> %s<br /><br />', pht('Drag and Drop:'), pht('You can also upload files by dragging and dropping them from your ' . 'desktop onto this page or the Phabricator home page.'))); $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($file)->execute(); $form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setLabel(pht('File'))->setName('file')->setError($e_file))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name'))->setName('name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicyObject($file)->setPolicies($policies)->setName('viewPolicy'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload'))->addCancelButton('/file/'))->appendChild($instructions); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Upload'), $request->getRequestURI()); $crumbs->setBorder(true); $title = pht('Upload File'); $global_upload = id(new PhabricatorGlobalUploadTargetView())->setUser($viewer)->setShowIfSupportedID($support_id); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('File'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form); $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-upload'); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $global_upload)); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
public function processRequest(AphrontRequest $request) { $user = $request->getUser(); $preferences = $user->loadPreferences(); $pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE; $dark_console_value = $preferences->getPreference($pref_dark_console); if ($request->isFormPost()) { $new_dark_console = $request->getBool($pref_dark_console); $preferences->setPreference($pref_dark_console, $new_dark_console); // If the user turned Dark Console on, enable it (as though they had hit // "`"). if ($new_dark_console && !$dark_console_value) { $user->setConsoleVisible(true); $user->save(); } $preferences->save(); return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true')); } $is_console_enabled = PhabricatorEnv::getEnvConfig('darkconsole.enabled'); $preamble = pht("**DarkConsole** is a developer console which can help build and " . "debug Phabricator applications. It includes tools for understanding " . "errors, performance, service calls, and other low-level aspects of " . "Phabricator's inner workings."); if ($is_console_enabled) { $instructions = pht("%s\n\n" . 'You can enable it for your account below. Enabling DarkConsole will ' . 'slightly decrease performance, but give you access to debugging ' . 'tools. You may want to disable it again later if you only need it ' . 'temporarily.' . "\n\n" . 'NOTE: After enabling DarkConsole, **press the ##%s## key on your ' . 'keyboard** to show or hide it.', $preamble, '`'); } else { $instructions = pht("%s\n\n" . 'Before you can turn on DarkConsole, it needs to be enabled in ' . 'the configuration for this install (`%s`).', $preamble, 'darkconsole.enabled'); } $form = id(new AphrontFormView())->setUser($user)->appendRemarkupInstructions($instructions)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Dark Console'))->setName($pref_dark_console)->setValue($dark_console_value)->setOptions(array(0 => pht('Disable DarkConsole'), 1 => pht('Enable DarkConsole')))->setDisabled(!$is_console_enabled))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Preferences'))); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Developer Settings'))->setFormSaved($request->getBool('saved'))->setForm($form); return array($form_box); }