1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Owners search.

This commit is contained in:
epriestley 2011-04-03 22:12:22 -07:00
parent 23f882a0ee
commit a54f1395c2
2 changed files with 45 additions and 1 deletions

View file

@ -59,16 +59,59 @@ class PhabricatorOwnersListController extends PhabricatorOwnersController {
} }
$package = new PhabricatorOwnersPackage(); $package = new PhabricatorOwnersPackage();
$owner = new PhabricatorOwnersOwner();
$path = new PhabricatorOwnersPath();
switch ($this->view) { switch ($this->view) {
case 'search': case 'search':
$packages = array(); $packages = array();
$conn_r = $package->establishConnection('r');
$where = array('1 = 1');
$join = array();
if ($request->getStr('name')) {
$where[] = qsprintf(
$conn_r,
'p.name LIKE %~',
$request->getStr('name'));
}
if ($request->getStr('path')) {
$join[] = qsprintf(
$conn_r,
'JOIN %T path ON path.packageID = p.id',
$path->getTableName());
$where[] = qsprintf(
$conn_r,
'path.path LIKE %~',
$request->getStr('path'));
}
if ($request->getArr('owner')) {
$join[] = qsprintf(
$conn_r,
'JOIN %T o ON o.packageID = p.id',
$owner->getTableName());
$where[] = qsprintf(
$conn_r,
'o.userPHID IN (%Ls)',
$request->getArr('owner'));
}
$data = queryfx_all(
$conn_r,
'SELECT p.* FROM %T p %Q WHERE %Q GROUP BY p.id',
$package->getTableName(),
implode(' ', $join),
'('.implode(') AND (', $where).')');
$packages = $package->loadAllFromArray($data);
$header = 'Search Results'; $header = 'Search Results';
$nodata = 'No packages match your query.'; $nodata = 'No packages match your query.';
break; break;
case 'owned': case 'owned':
$owner = new PhabricatorOwnersOwner();
$data = queryfx_all( $data = queryfx_all(
$package->establishConnection('r'), $package->establishConnection('r'),
'SELECT p.* FROM %T p JOIN %T o ON p.id = o.packageID 'SELECT p.* FROM %T p JOIN %T o ON p.id = o.packageID

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/owners/storage/owner');
phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/owners/storage/package');
phutil_require_module('phabricator', 'applications/owners/storage/path'); phutil_require_module('phabricator', 'applications/owners/storage/path');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/base');