Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectController.php
| Show All 10 Lines | protected function setProject(PhabricatorProject $project) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getProject() { | protected function getProject() { | ||||
| return $this->project; | return $this->project; | ||||
| } | } | ||||
| protected function loadProject() { | protected function loadProject() { | ||||
| return $this->loadProjectWithCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| )); | |||||
| } | |||||
| protected function loadProjectForEdit() { | |||||
| return $this->loadProjectWithCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| )); | |||||
| } | |||||
| private function loadProjectWithCapabilities(array $capabilities) { | |||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $id = nonempty( | $id = nonempty( | ||||
| $request->getURIData('projectID'), | $request->getURIData('projectID'), | ||||
| $request->getURIData('id')); | $request->getURIData('id')); | ||||
| $slug = $request->getURIData('slug'); | $slug = $request->getURIData('slug'); | ||||
| if ($slug) { | if ($slug) { | ||||
| $normal_slug = PhabricatorSlug::normalizeProjectSlug($slug); | $normal_slug = PhabricatorSlug::normalizeProjectSlug($slug); | ||||
| $is_abnormal = ($slug !== $normal_slug); | $is_abnormal = ($slug !== $normal_slug); | ||||
| $normal_uri = "/tag/{$normal_slug}/"; | $normal_uri = "/tag/{$normal_slug}/"; | ||||
| } else { | } else { | ||||
| $is_abnormal = false; | $is_abnormal = false; | ||||
| } | } | ||||
| $query = id(new PhabricatorProjectQuery()) | $query = id(new PhabricatorProjectQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->requireCapabilities($capabilities) | |||||
| ->needMembers(true) | ->needMembers(true) | ||||
| ->needWatchers(true) | ->needWatchers(true) | ||||
| ->needImages(true) | ->needImages(true) | ||||
| ->needSlugs(true); | ->needSlugs(true); | ||||
| if ($slug) { | if ($slug) { | ||||
| $query->withSlugs(array($slug)); | $query->withSlugs(array($slug)); | ||||
| } else { | } else { | ||||
| ▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines | |||||