Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13994112
D7595.id17314.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7595.id17314.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -2970,10 +2970,14 @@
'DrydockManagementWaitForLeaseWorkflow' => 'DrydockManagementWorkflow',
'DrydockManagementWorkflow' => 'PhutilArgumentWorkflow',
'DrydockPreallocatedHostBlueprint' => 'DrydockBlueprint',
- 'DrydockResource' => 'DrydockDAO',
+ 'DrydockResource' =>
+ array(
+ 0 => 'DrydockDAO',
+ 1 => 'PhabricatorPolicyInterface',
+ ),
'DrydockResourceCloseController' => 'DrydockController',
'DrydockResourceListController' => 'DrydockController',
- 'DrydockResourceQuery' => 'PhabricatorOffsetPagedQuery',
+ 'DrydockResourceQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DrydockResourceStatus' => 'DrydockConstants',
'DrydockResourceViewController' => 'DrydockController',
'DrydockSSHCommandInterface' => 'DrydockCommandInterface',
Index: src/applications/drydock/controller/DrydockResourceListController.php
===================================================================
--- src/applications/drydock/controller/DrydockResourceListController.php
+++ src/applications/drydock/controller/DrydockResourceListController.php
@@ -14,6 +14,7 @@
$pager = new AphrontPagerView();
$pager->setURI(new PhutilURI('/drydock/resource/'), 'offset');
$resources = id(new DrydockResourceQuery())
+ ->setViewer($user)
->executeWithOffsetPager($pager);
$resource_list = $this->buildResourceListView($resources);
Index: src/applications/drydock/query/DrydockResourceQuery.php
===================================================================
--- src/applications/drydock/query/DrydockResourceQuery.php
+++ src/applications/drydock/query/DrydockResourceQuery.php
@@ -1,15 +1,28 @@
<?php
-final class DrydockResourceQuery extends PhabricatorOffsetPagedQuery {
+final class DrydockResourceQuery
+ extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
+ private $statuses;
+ private $types;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
- public function execute() {
+ public function withTypes(array $types) {
+ $this->types = $types;
+ return $this;
+ }
+
+ public function withStatuses(array $statuses) {
+ $this->statuses = $statuses;
+ return $this;
+ }
+
+ public function loadPage() {
$table = new DrydockResource();
$conn_r = $table->establishConnection('r');
@@ -36,11 +49,27 @@
$this->ids);
}
+ if ($this->types) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'type IN (%Ls)',
+ $this->types);
+ }
+
+ if ($this->statuses) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'status IN (%Ls)',
+ $this->statuses);
+ }
+
+ $where[] = $this->buildPagingClause($conn_r);
+
return $this->formatWhereClause($where);
}
- private function buildOrderClause(AphrontDatabaseConnection $conn_r) {
- return qsprintf($conn_r, 'ORDER BY id DESC');
+ public function getQueryApplicationClass() {
+ return 'PhabricatorApplicationDrydock';
}
}
Index: src/applications/drydock/storage/DrydockResource.php
===================================================================
--- src/applications/drydock/storage/DrydockResource.php
+++ src/applications/drydock/storage/DrydockResource.php
@@ -1,6 +1,7 @@
<?php
-final class DrydockResource extends DrydockDAO {
+final class DrydockResource extends DrydockDAO
+ implements PhabricatorPolicyInterface {
protected $id;
protected $phid;
@@ -84,4 +85,28 @@
$this->saveTransaction();
}
+
+/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
+
+ public function getCapabilities() {
+ return array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ );
+ }
+
+ public function getPolicy($capability) {
+ switch ($capability) {
+ case PhabricatorPolicyCapability::CAN_VIEW:
+ return PhabricatorPolicies::getMostOpenPolicy();
+ }
+ }
+
+ public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
+ return false;
+ }
+
+ public function describeAutomaticCapability($capability) {
+ return null;
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 24, 3:52 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6742820
Default Alt Text
D7595.id17314.diff (4 KB)
Attached To
Mode
D7595: Update a few things in Drydock for policies
Attached
Detach File
Event Timeline
Log In to Comment