Path: blob/master/src/applications/dashboard/install/PhabricatorDashboardObjectInstallWorkflow.php
12242 views
<?php12abstract class PhabricatorDashboardObjectInstallWorkflow3extends PhabricatorDashboardInstallWorkflow {45abstract protected function newQuery();6abstract protected function newConfirmDialog($object);7abstract protected function newObjectSelectionForm($object);89public function handleRequest(AphrontRequest $request) {10$viewer = $this->getViewer();1112$target_identifier = null;1314$target_tokens = $request->getArr('target');15if ($target_tokens) {16$target_identifier = head($target_tokens);17}1819if (!strlen($target_identifier)) {20$target_identifier = $request->getStr('target');21}2223if (!strlen($target_identifier)) {24$target_identifier = $this->getMode();25}2627$target = null;28if (strlen($target_identifier)) {29$targets = array();3031if (ctype_digit($target_identifier)) {32$targets = $this->newQuery()33->setViewer($viewer)34->withIDs(array((int)$target_identifier))35->execute();36}3738if (!$targets) {39$targets = $this->newQuery()40->setViewer($viewer)41->withPHIDs(array($target_identifier))42->execute();43}4445if ($targets) {46$target = head($targets);47}48}4950if ($target) {51$target_phid = $target->getPHID();52} else {53$target_phid = null;54}5556if ($target) {57$can_edit = PhabricatorPolicyFilter::hasCapability(58$viewer,59$target,60PhabricatorPolicyCapability::CAN_EDIT);61} else {62$can_edit = null;63}6465if ($request->isFormPost() && $target && $can_edit) {66if ($request->getBool('confirm')) {67return $this->installDashboard($target, null);68} else {69return $this->newConfirmDialog($target)70->addHiddenInput('confirm', 1)71->addHiddenInput('target', $target_phid);72}73}7475$errors = array();76if (strlen($target_identifier)) {77if (!$target) {78$errors[] = pht('Choose a valid object.');79} else if (!$can_edit) {80$errors[] = pht(81'You do not have permission to edit the selected object. '.82'You can only install dashboards on objects you can edit.');83}84} else if ($request->getBool('pick')) {85$errors[] = pht(86'Choose an object to install this dashboard on.');87}8889$form = $this->newObjectSelectionForm($target)90->addHiddenInput('pick', 1);9192return $this->newDialog()93->setTitle(pht('Add Dashboard to Project Menu'))94->setErrors($errors)95->appendForm($form)96->addSubmitButton(pht('Continue'));97}98}99100101