diff --git a/src/applications/diffusion/management/DiffusionRepositoryLimitsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryLimitsManagementPanel.php index b57ed5cf5..c495801aa 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryLimitsManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryLimitsManagementPanel.php @@ -1,112 +1,117 @@ isGit(); } public function getManagementPanelIcon() { $repository = $this->getRepository(); $any_limit = false; if ($repository->getFilesizeLimit()) { $any_limit = true; } if ($any_limit) { return 'fa-signal'; } else { return 'fa-signal grey'; } } protected function getEditEngineFieldKeys() { return array( 'filesizeLimit', 'copyTimeLimit', 'touchLimit', ); } public function buildManagementPanelCurtain() { $repository = $this->getRepository(); $viewer = $this->getViewer(); $action_list = $this->newActionList(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $repository, PhabricatorPolicyCapability::CAN_EDIT); $limits_uri = $this->getEditPageURI(); $action_list->addAction( id(new PhabricatorActionView()) ->setIcon('fa-pencil') ->setName(pht('Edit Limits')) ->setHref($limits_uri) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); return $this->newCurtainView() ->setActionList($action_list); } public function buildManagementPanelContent() { $repository = $this->getRepository(); $viewer = $this->getViewer(); $view = id(new PHUIPropertyListView()) ->setViewer($viewer); $byte_limit = $repository->getFilesizeLimit(); if ($byte_limit) { $filesize_display = pht('%s Bytes', new PhutilNumber($byte_limit)); } else { $filesize_display = pht('Unlimited'); $filesize_display = phutil_tag('em', array(), $filesize_display); } $view->addProperty(pht('Filesize Limit'), $filesize_display); $copy_limit = $repository->getCopyTimeLimit(); if ($copy_limit) { $copy_display = pht('%s Seconds', new PhutilNumber($copy_limit)); } else { $copy_default = $repository->getDefaultCopyTimeLimit(); $copy_display = pht( 'Default (%s Seconds)', new PhutilNumber($copy_default)); $copy_display = phutil_tag('em', array(), $copy_display); } $view->addProperty(pht('Clone/Fetch Timeout'), $copy_display); $touch_limit = $repository->getTouchLimit(); if ($touch_limit) { $touch_display = pht('%s Paths', new PhutilNumber($touch_limit)); } else { $touch_display = pht('Unlimited'); $touch_display = phutil_tag('em', array(), $touch_display); } $view->addProperty(pht('Touched Paths Limit'), $touch_display); return $this->newBox(pht('Limits'), $view); } } diff --git a/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php b/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php index e80901b49..57623c007 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php +++ b/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php @@ -1,16 +1,21 @@ viewer = $viewer; return $this; } final public function getViewer() { return $this->viewer; } final public function setRepository(PhabricatorRepository $repository) { $this->repository = $repository; return $this; } final public function getRepository() { return $this->repository; } final public function getRequest() { return $this->controller->getRequest(); } final public function setController(PhabricatorController $controller) { $this->controller = $controller; return $this; } final public function getManagementPanelKey() { return $this->getPhobjectClassConstant('PANELKEY'); } abstract public function getManagementPanelLabel(); abstract public function getManagementPanelOrder(); abstract public function buildManagementPanelContent(); public function buildManagementPanelCurtain() { return null; } public function getManagementPanelIcon() { return 'fa-pencil'; } public function getManagementPanelGroupKey() { return DiffusionRepositoryManagementMainPanelGroup::PANELGROUPKEY; } public function shouldEnableForRepository( PhabricatorRepository $repository) { return true; } - public static function getAllPanels() { - return id(new PhutilClassMapQuery()) + // C4science customization + public static function getAllPanels($viewer) { + $class_map = id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getManagementPanelKey') - ->setSortMethod('getManagementPanelOrder') - ->execute(); + ->setSortMethod('getManagementPanelOrder'); + + if(!$viewer->isOmnipotent()) { + $class_map->setFilterMethod('allowAccess'); + } + + return $class_map->execute(); } + // End of c4s custo final protected function newTimeline() { return $this->controller->newTimeline($this->getRepository()); } final public function getPanelURI() { $repository = $this->getRepository(); $key = $this->getManagementPanelKey(); return $repository->getPathURI("manage/{$key}/"); } final public function newEditEnginePage() { $field_keys = $this->getEditEngineFieldKeys(); if (!$field_keys) { return null; } $key = $this->getManagementPanelKey(); $label = $this->getManagementPanelLabel(); $panel_uri = $this->getPanelURI(); return id(new PhabricatorEditPage()) ->setKey($key) ->setLabel($label) ->setViewURI($panel_uri) ->setFieldKeys($field_keys); } protected function getEditEngineFieldKeys() { return array(); } protected function getEditPageURI($page = null) { if ($page === null) { $page = $this->getManagementPanelKey(); } $repository = $this->getRepository(); $id = $repository->getID(); return "/diffusion/edit/{$id}/page/{$page}/"; } public function getPanelNavigationURI() { return $this->getPanelURI(); } final protected function newActionList() { $viewer = $this->getViewer(); $action_id = celerity_generate_unique_node_id(); return id(new PhabricatorActionListView()) ->setViewer($viewer) ->setID($action_id); } final protected function newCurtainView() { $viewer = $this->getViewer(); return id(new PHUICurtainView()) ->setViewer($viewer); } final protected function newBox($header_text, $body) { $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setViewer($viewer) ->setHeader($header_text); $view = id(new PHUIObjectBoxView()) ->setViewer($viewer) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($body); return $view; } }