Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892646
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
10 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/project/controller/list/PhabricatorProjectListController.php b/src/applications/project/controller/list/PhabricatorProjectListController.php
index ecb829dc1c..d8ac9ed702 100644
--- a/src/applications/project/controller/list/PhabricatorProjectListController.php
+++ b/src/applications/project/controller/list/PhabricatorProjectListController.php
@@ -1,181 +1,168 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectListController
extends PhabricatorProjectController {
private $filter;
public function willProcessRequest(array $data) {
$this->filter = idx($data, 'filter');
}
public function processRequest() {
$request = $this->getRequest();
$nav = new AphrontSideNavFilterView();
$nav
->setBaseURI(new PhutilURI('/project/filter/'))
->addLabel('User')
->addFilter('active', 'Active')
->addFilter('owned', 'Owned')
->addSpacer()
->addLabel('All')
->addFilter('all', 'All Projects');
$this->filter = $nav->selectFilter($this->filter, 'active');
$pager = new AphrontPagerView();
$pager->setPageSize(250);
$pager->setURI($request->getRequestURI(), 'page');
$pager->setOffset($request->getInt('page'));
$query = new PhabricatorProjectQuery();
$query->setOffset($pager->getOffset());
$query->setLimit($pager->getPageSize() + 1);
$view_phid = $request->getUser()->getPHID();
switch ($this->filter) {
case 'active':
$table_header = 'Active Projects';
$query->setMembers(array($view_phid));
break;
case 'owned':
$table_header = 'Owned Projects';
$query->setOwners(array($view_phid));
break;
case 'all':
$table_header = 'All Projects';
break;
}
$projects = $query->execute();
$projects = $pager->sliceResults($projects);
$project_phids = mpull($projects, 'getPHID');
$profiles = array();
if ($projects) {
$profiles = id(new PhabricatorProjectProfile())->loadAllWhere(
'projectPHID in (%Ls)',
$project_phids);
$profiles = mpull($profiles, null, 'getProjectPHID');
}
$affil_groups = array();
if ($projects) {
$affil_groups = PhabricatorProjectAffiliation::loadAllForProjectPHIDs(
$project_phids);
}
- $author_phids = mpull($projects, 'getAuthorPHID');
- $handles = id(new PhabricatorObjectHandleData($author_phids))
- ->loadHandles();
-
- $query = id(new ManiphestTaskQuery())
- ->withProjects($project_phids)
- ->withAnyProject(true)
- ->withStatus(ManiphestTaskQuery::STATUS_OPEN)
- ->setLimit(PHP_INT_MAX);
-
- $tasks = $query->execute();
+ $tasks = array();
$groups = array();
- foreach ($tasks as $task) {
- foreach ($task->getProjectPHIDs() as $phid) {
- $groups[$phid][] = $task;
+ if ($project_phids) {
+ $query = id(new ManiphestTaskQuery())
+ ->withProjects($project_phids)
+ ->withAnyProject(true)
+ ->withStatus(ManiphestTaskQuery::STATUS_OPEN)
+ ->setLimit(PHP_INT_MAX);
+
+ $tasks = $query->execute();
+ foreach ($tasks as $task) {
+ foreach ($task->getProjectPHIDs() as $phid) {
+ $groups[$phid][] = $task;
+ }
}
}
$rows = array();
foreach ($projects as $project) {
$phid = $project->getPHID();
$profile = $profiles[$phid];
$affiliations = $affil_groups[$phid];
$group = idx($groups, $phid, array());
$task_count = count($group);
$population = count($affiliations);
- $status = PhabricatorProjectStatus::getNameForStatus(
- $project->getStatus());
-
$blurb = $profile->getBlurb();
- $blurb = phutil_utf8_shorten($blurb, $columns = 100);
+ $blurb = phutil_utf8_shorten($blurb, 64);
+
$rows[] = array(
- phutil_escape_html($project->getName()),
- phutil_escape_html($blurb),
- $handles[$project->getAuthorPHID()]->renderLink(),
- phutil_escape_html($population),
- phutil_escape_html($status),
phutil_render_tag(
'a',
array(
- 'href' => '/maniphest/view/all/?projects='.$phid,
+ 'href' => '/project/view/'.$project->getID().'/',
),
- phutil_escape_html($task_count)),
+ phutil_escape_html($project->getName())),
+ phutil_escape_html($blurb),
+ phutil_escape_html($population),
phutil_render_tag(
'a',
array(
- 'class' => 'small grey button',
- 'href' => '/project/view/'.$project->getID().'/',
+ 'href' => '/maniphest/view/all/?projects='.$phid,
),
- 'View Project Profile'),
+ phutil_escape_html($task_count)),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Project',
'Description',
- 'Mastermind',
'Population',
- 'Status',
'Open Tasks',
- '',
));
$table->setColumnClasses(
array(
'pri',
'wide',
'',
- 'right',
- '',
- 'right',
- 'action',
+ ''
));
$panel = new AphrontPanelView();
$panel->setHeader($table_header);
$panel->setCreateButton('Create New Project', '/project/create/');
$panel->appendChild($table);
$panel->appendChild($pager);
$nav->appendChild($panel);
return $this->buildStandardPageResponse(
$nav,
array(
'title' => 'Projects',
));
}
}
diff --git a/src/applications/project/controller/list/__init__.php b/src/applications/project/controller/list/__init__.php
index 27aedf24f7..d5ad8656c5 100644
--- a/src/applications/project/controller/list/__init__.php
+++ b/src/applications/project/controller/list/__init__.php
@@ -1,26 +1,24 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/maniphest/query');
-phutil_require_module('phabricator', 'applications/phid/handle/data');
-phutil_require_module('phabricator', 'applications/project/constants/status');
phutil_require_module('phabricator', 'applications/project/controller/base');
phutil_require_module('phabricator', 'applications/project/query/project');
phutil_require_module('phabricator', 'applications/project/storage/affiliation');
phutil_require_module('phabricator', 'applications/project/storage/profile');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'parser/uri');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorProjectListController.php');
diff --git a/src/applications/project/query/project/PhabricatorProjectQuery.php b/src/applications/project/query/project/PhabricatorProjectQuery.php
index 2f25ccf7da..679c9aba29 100644
--- a/src/applications/project/query/project/PhabricatorProjectQuery.php
+++ b/src/applications/project/query/project/PhabricatorProjectQuery.php
@@ -1,103 +1,106 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorProjectQuery {
private $owners;
private $members;
private $limit;
private $offset;
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function setOffset($offset) {
$this->offset = $offset;
return $this;
}
public function setOwners(array $owners) {
$this->owners = $owners;
return $this;
}
public function setMembers(array $members) {
$this->members = $members;
return $this;
}
public function execute() {
$table = id(new PhabricatorProject());
$conn_r = $table->establishConnection('r');
$joins = $this->buildJoinsClause($conn_r);
$limit = null;
if ($this->limit) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
$this->limit);
} else if ($this->offset) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
PHP_INT_MAX);
}
+ $order = 'ORDER BY name';
+
$data = queryfx_all(
$conn_r,
- 'SELECT p.* FROM %T p %Q %Q',
+ 'SELECT p.* FROM %T p %Q %Q %Q',
$table->getTableName(),
$joins,
+ $order,
$limit);
return $table->loadAllFromArray($data);
}
private function buildJoinsClause($conn_r) {
$affil_table = new PhabricatorProjectAffiliation();
$joins = array();
if ($this->owners) {
$joins[] = qsprintf(
$conn_r,
'JOIN %T owner ON owner.projectPHID = p.phid AND owner.isOwner = 1
AND owner.userPHID in (%Ls)',
$affil_table->getTableName(),
$this->owners);
}
if ($this->members) {
$joins[] = qsprintf(
$conn_r,
'JOIN %T member ON member.projectPHID = p.phid
AND member.userPHID in (%Ls)',
$affil_table->getTableName(),
$this->members);
}
return implode(' ', $joins);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 17:09 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126803
Default Alt Text
(10 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment