Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15420231
D11272.id27080.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D11272.id27080.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2225,6 +2225,7 @@
'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
'PhabricatorProjectUIEventListener' => 'applications/project/events/PhabricatorProjectUIEventListener.php',
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
+ 'PhabricatorProjectViewController' => 'applications/project/controller/PhabricatorProjectViewController.php',
'PhabricatorProjectWatchController' => 'applications/project/controller/PhabricatorProjectWatchController.php',
'PhabricatorProjectWikiExplainController' => 'applications/project/controller/PhabricatorProjectWikiExplainController.php',
'PhabricatorProjectsPolicyRule' => 'applications/policy/rule/PhabricatorProjectsPolicyRule.php',
@@ -5445,6 +5446,7 @@
'PhabricatorProjectTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorProjectUIEventListener' => 'PhabricatorEventListener',
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
+ 'PhabricatorProjectViewController' => 'PhabricatorProjectController',
'PhabricatorProjectWatchController' => 'PhabricatorProjectController',
'PhabricatorProjectWikiExplainController' => 'PhabricatorProjectController',
'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
diff --git a/src/applications/project/application/PhabricatorProjectApplication.php b/src/applications/project/application/PhabricatorProjectApplication.php
--- a/src/applications/project/application/PhabricatorProjectApplication.php
+++ b/src/applications/project/application/PhabricatorProjectApplication.php
@@ -52,8 +52,10 @@
=> 'PhabricatorProjectMembersEditController',
'members/(?P<id>[1-9]\d*)/remove/'
=> 'PhabricatorProjectMembersRemoveController',
- 'view/(?P<id>[1-9]\d*)/'
+ 'profile/(?P<id>[1-9]\d*)/'
=> 'PhabricatorProjectProfileController',
+ 'view/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorProjectViewController',
'picture/(?P<id>[1-9]\d*)/'
=> 'PhabricatorProjectEditPictureController',
'icon/(?P<id>[1-9]\d*)/'
@@ -86,7 +88,7 @@
'wiki/' => 'PhabricatorProjectWikiExplainController',
),
'/tag/' => array(
- '(?P<slug>[^/]+)/' => 'PhabricatorProjectProfileController',
+ '(?P<slug>[^/]+)/' => 'PhabricatorProjectViewController',
'(?P<slug>[^/]+)/board/' => 'PhabricatorProjectBoardViewController',
),
);
diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php
--- a/src/applications/project/controller/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -3,22 +3,11 @@
final class PhabricatorProjectProfileController
extends PhabricatorProjectController {
- private $id;
- private $slug;
-
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- // via /project/view/$id/
- $this->id = idx($data, 'id');
- // via /tag/$slug/
- $this->slug = idx($data, 'slug');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$query = id(new PhabricatorProjectQuery())
@@ -27,16 +16,18 @@
->needWatchers(true)
->needImages(true)
->needSlugs(true);
- if ($this->slug) {
- $query->withSlugs(array($this->slug));
+ $id = $request->getURIData('id');
+ $slug = $request->getURIData('slug');
+ if ($slug) {
+ $query->withSlugs(array($slug));
} else {
- $query->withIDs(array($this->id));
+ $query->withIDs(array($id));
}
$project = $query->executeOne();
if (!$project) {
return new Aphront404Response();
}
- if ($this->slug && $this->slug != $project->getPrimarySlug()) {
+ if ($slug && $slug != $project->getPrimarySlug()) {
return id(new AphrontRedirectResponse())
->setURI('/tag/'.$project->getPrimarySlug().'/');
}
@@ -53,7 +44,7 @@
$project->getPHID(),
));
$query->setLimit(50);
- $query->setViewer($this->getRequest()->getUser());
+ $query->setViewer($request->getUser());
$stories = $query->execute();
$feed = $this->renderStories($stories);
diff --git a/src/applications/project/controller/PhabricatorProjectViewController.php b/src/applications/project/controller/PhabricatorProjectViewController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/controller/PhabricatorProjectViewController.php
@@ -0,0 +1,60 @@
+<?php
+
+final class PhabricatorProjectViewController
+ extends PhabricatorProjectController {
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $request = $this->getRequest();
+ $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 (!$user->isLoggedIn()) {
+ $controller = 'profile';
+ } else {
+ $preferences = $user->loadPreferences();
+ $controller = $preferences->getPreference(
+ $project->getDefaultViewPreferenceKey(),
+ 'profile');
+ }
+
+ switch ($controller) {
+ case 'edit':
+ $controller_object = new PhabricatorProjectEditMainController();
+ break;
+ case 'board':
+ $controller_object = new PhabricatorProjectBoardViewController();
+ break;
+ case 'members':
+ $controller_object = new PhabricatorProjectMembersEditController();
+ break;
+ case 'profile':
+ default:
+ $controller_object = new PhabricatorProjectProfileController();
+ break;
+ }
+
+ return $this->delegateToController($controller_object);
+ }
+
+}
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -273,6 +273,10 @@
return $this->color;
}
+ public function getDefaultViewPreferenceKey() {
+ return 'proj:defaultview:1:'.$this->getPHID();
+ }
+
public function save() {
$this->openTransaction();
$result = parent::save();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 22, 12:21 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7716983
Default Alt Text
D11272.id27080.diff (6 KB)
Attached To
Mode
D11272: Revamp Projects with new navigation
Attached
Detach File
Event Timeline
Log In to Comment