@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add initial skeleton for Dashboard application

Summary:
Ref T3583. General idea here is:

- Users will be able to create `DashboardPanel`s, which are things like the jump nav, or a minifeed, or recent assigned tasks, or recent tokens given, or whatever else.
- The `DashboardPanel`s can be combined into `Dashboard`s, which select specific panels and arrange them in some layout (and maybe have a few other options eventually).
- Then, you'll be able to set a specific `Dashboard` for your home page, and maybe for project home pages. But you can also use `Dashboard`s on their own if you just like dashboards.

My plan is pretty much:

- Put in basic infrastructure for dashboards (this diff).
- Add basic create/edit (next few diffs).
- Once dashboards sort of work, do the homepage integration.

This diff does very little: you can't create dashboards or panels yet, and thus there are no dashboards to look at. This is all skeleton code, pretty much.

IMPORTANT: We need an icon bwahahahahaha

Test Plan:
omg si purrfect

{F106367}

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3583

Differential Revision: https://secure.phabricator.com/D8109

+653
+10
resources/sql/autopatches/20140130.dash.1.board.sql
··· 1 + CREATE TABLE {$NAMESPACE}_dashboard.dashboard ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARCHAR(64) NOT NULL COLLATE utf8_bin, 4 + name VARCHAR(255) NOT NULL, 5 + viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin, 6 + editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin, 7 + dateCreated INT UNSIGNED NOT NULL, 8 + dateModified INT UNSIGNED NOT NULL, 9 + UNIQUE KEY `key_phid` (phid) 10 + ) ENGINE=InnoDB, COLLATE=utf8_general_ci;
+11
resources/sql/autopatches/20140130.dash.2.panel.sql
··· 1 + CREATE TABLE {$NAMESPACE}_dashboard.dashboard_panel ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + phid VARCHAR(64) NOT NULL COLLATE utf8_bin, 4 + name VARCHAR(255) NOT NULL, 5 + viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin, 6 + editPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin, 7 + properties LONGTEXT NOT NULL COLLATE utf8_bin, 8 + dateCreated INT UNSIGNED NOT NULL, 9 + dateModified INT UNSIGNED NOT NULL, 10 + UNIQUE KEY `key_phid` (phid) 11 + ) ENGINE=InnoDB, COLLATE=utf8_general_ci;
+38
src/__phutil_library_map__.php
··· 1075 1075 'PhabricatorApplicationConpherence' => 'applications/conpherence/application/PhabricatorApplicationConpherence.php', 1076 1076 'PhabricatorApplicationCountdown' => 'applications/countdown/application/PhabricatorApplicationCountdown.php', 1077 1077 'PhabricatorApplicationDaemons' => 'applications/daemon/application/PhabricatorApplicationDaemons.php', 1078 + 'PhabricatorApplicationDashboard' => 'applications/dashboard/application/PhabricatorApplicationDashboard.php', 1078 1079 'PhabricatorApplicationDetailViewController' => 'applications/meta/controller/PhabricatorApplicationDetailViewController.php', 1079 1080 'PhabricatorApplicationDifferential' => 'applications/differential/application/PhabricatorApplicationDifferential.php', 1080 1081 'PhabricatorApplicationDiffusion' => 'applications/diffusion/application/PhabricatorApplicationDiffusion.php', ··· 1378 1379 'PhabricatorDaemonManagementWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementWorkflow.php', 1379 1380 'PhabricatorDaemonReference' => 'infrastructure/daemon/control/PhabricatorDaemonReference.php', 1380 1381 'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php', 1382 + 'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php', 1383 + 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', 1384 + 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 1385 + 'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php', 1386 + 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 1387 + 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', 1388 + 'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php', 1389 + 'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php', 1390 + 'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php', 1391 + 'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php', 1392 + 'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php', 1393 + 'PhabricatorDashboardSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardSearchEngine.php', 1381 1394 'PhabricatorDataNotAttachedException' => 'infrastructure/storage/lisk/PhabricatorDataNotAttachedException.php', 1382 1395 'PhabricatorDebugController' => 'applications/system/PhabricatorDebugController.php', 1383 1396 'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/PhabricatorDefaultFileStorageEngineSelector.php', ··· 3662 3675 'PhabricatorApplicationConpherence' => 'PhabricatorApplication', 3663 3676 'PhabricatorApplicationCountdown' => 'PhabricatorApplication', 3664 3677 'PhabricatorApplicationDaemons' => 'PhabricatorApplication', 3678 + 'PhabricatorApplicationDashboard' => 'PhabricatorApplication', 3665 3679 'PhabricatorApplicationDetailViewController' => 'PhabricatorApplicationsController', 3666 3680 'PhabricatorApplicationDifferential' => 'PhabricatorApplication', 3667 3681 'PhabricatorApplicationDiffusion' => 'PhabricatorApplication', ··· 4007 4021 'PhabricatorDaemonManagementStopWorkflow' => 'PhabricatorDaemonManagementWorkflow', 4008 4022 'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow', 4009 4023 'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector', 4024 + 'PhabricatorDashboard' => 4025 + array( 4026 + 0 => 'PhabricatorDashboardDAO', 4027 + 1 => 'PhabricatorPolicyInterface', 4028 + ), 4029 + 'PhabricatorDashboardController' => 'PhabricatorController', 4030 + 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 4031 + 'PhabricatorDashboardListController' => 4032 + array( 4033 + 0 => 'PhabricatorDashboardController', 4034 + 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 4035 + ), 4036 + 'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType', 4037 + 'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType', 4038 + 'PhabricatorDashboardPanel' => 'PhabricatorDashboardDAO', 4039 + 'PhabricatorDashboardPanelListController' => 4040 + array( 4041 + 0 => 'PhabricatorDashboardController', 4042 + 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 4043 + ), 4044 + 'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4045 + 'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine', 4046 + 'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4047 + 'PhabricatorDashboardSearchEngine' => 'PhabricatorApplicationSearchEngine', 4010 4048 'PhabricatorDataNotAttachedException' => 'Exception', 4011 4049 'PhabricatorDebugController' => 'PhabricatorController', 4012 4050 'PhabricatorDefaultFileStorageEngineSelector' => 'PhabricatorFileStorageEngineSelector',
+40
src/applications/dashboard/application/PhabricatorApplicationDashboard.php
··· 1 + <?php 2 + 3 + final class PhabricatorApplicationDashboard extends PhabricatorApplication { 4 + 5 + public function getBaseURI() { 6 + return '/dashboard/'; 7 + } 8 + 9 + public function getShortDescription() { 10 + return pht('Such Data'); 11 + } 12 + 13 + public function getIconName() { 14 + return 'dashboard'; 15 + } 16 + 17 + public function getRoutes() { 18 + return array( 19 + '/W(?P<id>\d+)' => 'PhabricatorDashboardPanelViewController', 20 + '/dashboard/' => array( 21 + '(?:query/(?P<queryKey>[^/]+)/)?' 22 + => 'PhabricatorDashboardListController', 23 + 'view/(?P<id>\d+)/' => 'PhabricatorDashboardViewController', 24 + 'panel/' => array( 25 + '(?:query/(?P<queryKey>[^/]+)/)?' 26 + => 'PhabricatorDashboardPanelListController', 27 + ), 28 + ), 29 + ); 30 + } 31 + 32 + public function shouldAppearInLaunchView() { 33 + return false; 34 + } 35 + 36 + public function canUninstall() { 37 + return false; 38 + } 39 + 40 + }
+5
src/applications/dashboard/controller/PhabricatorDashboardController.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorDashboardController extends PhabricatorController { 4 + 5 + }
+43
src/applications/dashboard/controller/PhabricatorDashboardListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardListController 4 + extends PhabricatorDashboardController 5 + implements PhabricatorApplicationSearchResultsControllerInterface { 6 + 7 + private $queryKey; 8 + public function willProcessRequest(array $data) { 9 + $this->queryKey = idx($data, 'queryKey'); 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $controller = id(new PhabricatorApplicationSearchController($request)) 15 + ->setQueryKey($this->queryKey) 16 + ->setSearchEngine(new PhabricatorDashboardSearchEngine()) 17 + ->setNavigation($this->buildSideNavView()); 18 + return $this->delegateToController($controller); 19 + } 20 + 21 + public function buildSideNavView() { 22 + $user = $this->getRequest()->getUser(); 23 + 24 + $nav = new AphrontSideNavFilterView(); 25 + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 26 + 27 + id(new PhabricatorDashboardSearchEngine()) 28 + ->setViewer($user) 29 + ->addNavigationItems($nav->getMenu()); 30 + 31 + $nav->selectFilter(null); 32 + 33 + return $nav; 34 + } 35 + 36 + public function renderResultsList( 37 + array $dashboards, 38 + PhabricatorSavedQuery $query) { 39 + 40 + return 'got '.count($dashboards).' ok'; 41 + } 42 + 43 + }
+43
src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelListController 4 + extends PhabricatorDashboardController 5 + implements PhabricatorApplicationSearchResultsControllerInterface { 6 + 7 + private $queryKey; 8 + public function willProcessRequest(array $data) { 9 + $this->queryKey = idx($data, 'queryKey'); 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $controller = id(new PhabricatorApplicationSearchController($request)) 15 + ->setQueryKey($this->queryKey) 16 + ->setSearchEngine(new PhabricatorDashboardPanelSearchEngine()) 17 + ->setNavigation($this->buildSideNavView()); 18 + return $this->delegateToController($controller); 19 + } 20 + 21 + public function buildSideNavView() { 22 + $user = $this->getRequest()->getUser(); 23 + 24 + $nav = new AphrontSideNavFilterView(); 25 + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 26 + 27 + id(new PhabricatorDashboardPanelSearchEngine()) 28 + ->setViewer($user) 29 + ->addNavigationItems($nav->getMenu()); 30 + 31 + $nav->selectFilter(null); 32 + 33 + return $nav; 34 + } 35 + 36 + public function renderResultsList( 37 + array $panels, 38 + PhabricatorSavedQuery $query) { 39 + 40 + return 'got '.count($panels).' ok'; 41 + } 42 + 43 + }
+42
src/applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPHIDTypeDashboard extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'DSHB'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Dashboard'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhabricatorDashboard(); 17 + } 18 + 19 + protected function buildQueryForObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorDashboardQuery()) 24 + ->withPHIDs($phids); 25 + } 26 + 27 + public function loadHandles( 28 + PhabricatorHandleQuery $query, 29 + array $handles, 30 + array $objects) { 31 + 32 + foreach ($handles as $phid => $handle) { 33 + $dashboard = $objects[$phid]; 34 + 35 + $id = $dashboard->getID(); 36 + 37 + $handle->setName($dashboard->getName()); 38 + $handle->setURI("/dashboard/view/{$id}/"); 39 + } 40 + } 41 + 42 + }
+73
src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPHIDTypePanel extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'DSHP'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Panel'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhabricatorDashboardPanel(); 17 + } 18 + 19 + protected function buildQueryForObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorDashboardPanelQuery()) 24 + ->withPHIDs($phids); 25 + } 26 + 27 + public function loadHandles( 28 + PhabricatorHandleQuery $query, 29 + array $handles, 30 + array $objects) { 31 + 32 + foreach ($handles as $phid => $handle) { 33 + $panel = $objects[$phid]; 34 + 35 + $name = $panel->getName(); 36 + $monogram = $panel->getMonogram(); 37 + 38 + $handle->setName($panel->getMonogram()); 39 + $handle->setFullName("{$monogram} {$name}"); 40 + $handle->setURI("/{$monogram}"); 41 + } 42 + } 43 + 44 + public function canLoadNamedObject($name) { 45 + return preg_match('/^W\d*[1-9]\d*$/i', $name); 46 + } 47 + 48 + public function loadNamedObjects( 49 + PhabricatorObjectQuery $query, 50 + array $names) { 51 + 52 + $id_map = array(); 53 + foreach ($names as $name) { 54 + $id = (int)substr($name, 1); 55 + $id_map[$id][] = $name; 56 + } 57 + 58 + $objects = id(new PhabricatorDashboardPanelQuery()) 59 + ->setViewer($query->getViewer()) 60 + ->withIDs(array_keys($id_map)) 61 + ->execute(); 62 + 63 + $results = array(); 64 + foreach ($objects as $id => $object) { 65 + foreach (idx($id_map, $id, array()) as $name) { 66 + $results[$name] = $object; 67 + } 68 + } 69 + 70 + return $results; 71 + } 72 + 73 + }
+60
src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + 9 + public function withIDs(array $ids) { 10 + $this->ids = $ids; 11 + return $this; 12 + } 13 + 14 + public function withPHIDs(array $phids) { 15 + $this->phids = $phids; 16 + return $this; 17 + } 18 + 19 + protected function loadPage() { 20 + $table = new PhabricatorDashboardPanel(); 21 + $conn_r = $table->establishConnection('r'); 22 + 23 + $data = queryfx_all( 24 + $conn_r, 25 + 'SELECT * FROM %T %Q %Q %Q', 26 + $table->getTableName(), 27 + $this->buildWhereClause($conn_r), 28 + $this->buildOrderClause($conn_r), 29 + $this->buildLimitClause($conn_r)); 30 + 31 + return $table->loadAllFromArray($data); 32 + } 33 + 34 + protected function buildWhereClause($conn_r) { 35 + $where = array(); 36 + 37 + if ($this->ids) { 38 + $where[] = qsprintf( 39 + $conn_r, 40 + 'id IN (%Ld)', 41 + $this->ids); 42 + } 43 + 44 + if ($this->phids) { 45 + $where[] = qsprintf( 46 + $conn_r, 47 + 'phid IN (%Ls)', 48 + $this->phids); 49 + } 50 + 51 + $where[] = $this->buildPagingClause($conn_r); 52 + 53 + return $this->formatWhereClause($where); 54 + } 55 + 56 + public function getQueryApplicationClass() { 57 + return 'PhabricatorApplicationDashboard'; 58 + } 59 + 60 + }
+49
src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 + $saved = new PhabricatorSavedQuery(); 8 + 9 + return $saved; 10 + } 11 + 12 + public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 + $query = id(new PhabricatorDashboardPanelQuery()); 14 + 15 + return $query; 16 + } 17 + 18 + public function buildSearchForm( 19 + AphrontFormView $form, 20 + PhabricatorSavedQuery $saved_query) { 21 + return; 22 + } 23 + 24 + protected function getURI($path) { 25 + return '/dashboard/panel/'.$path; 26 + } 27 + 28 + public function getBuiltinQueryNames() { 29 + $names = array( 30 + 'all' => pht('All Panels'), 31 + ); 32 + 33 + return $names; 34 + } 35 + 36 + public function buildSavedQueryFromBuiltin($query_key) { 37 + 38 + $query = $this->newSavedQuery(); 39 + $query->setQueryKey($query_key); 40 + 41 + switch ($query_key) { 42 + case 'all': 43 + return $query; 44 + } 45 + 46 + return parent::buildSavedQueryFromBuiltin($query_key); 47 + } 48 + 49 + }
+60
src/applications/dashboard/query/PhabricatorDashboardQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + 9 + public function withIDs(array $ids) { 10 + $this->ids = $ids; 11 + return $this; 12 + } 13 + 14 + public function withPHIDs(array $phids) { 15 + $this->phids = $phids; 16 + return $this; 17 + } 18 + 19 + protected function loadPage() { 20 + $table = new PhabricatorDashboard(); 21 + $conn_r = $table->establishConnection('r'); 22 + 23 + $data = queryfx_all( 24 + $conn_r, 25 + 'SELECT * FROM %T %Q %Q %Q', 26 + $table->getTableName(), 27 + $this->buildWhereClause($conn_r), 28 + $this->buildOrderClause($conn_r), 29 + $this->buildLimitClause($conn_r)); 30 + 31 + return $table->loadAllFromArray($data); 32 + } 33 + 34 + protected function buildWhereClause($conn_r) { 35 + $where = array(); 36 + 37 + if ($this->ids) { 38 + $where[] = qsprintf( 39 + $conn_r, 40 + 'id IN (%Ld)', 41 + $this->ids); 42 + } 43 + 44 + if ($this->phids) { 45 + $where[] = qsprintf( 46 + $conn_r, 47 + 'phid IN (%Ls)', 48 + $this->phids); 49 + } 50 + 51 + $where[] = $this->buildPagingClause($conn_r); 52 + 53 + return $this->formatWhereClause($where); 54 + } 55 + 56 + public function getQueryApplicationClass() { 57 + return 'PhabricatorApplicationDashboard'; 58 + } 59 + 60 + }
+49
src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 + $saved = new PhabricatorSavedQuery(); 8 + 9 + return $saved; 10 + } 11 + 12 + public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 + $query = id(new PhabricatorDashboardQuery()); 14 + 15 + return $query; 16 + } 17 + 18 + public function buildSearchForm( 19 + AphrontFormView $form, 20 + PhabricatorSavedQuery $saved_query) { 21 + return; 22 + } 23 + 24 + protected function getURI($path) { 25 + return '/dashboard/'.$path; 26 + } 27 + 28 + public function getBuiltinQueryNames() { 29 + $names = array( 30 + 'all' => pht('All Dashboards'), 31 + ); 32 + 33 + return $names; 34 + } 35 + 36 + public function buildSavedQueryFromBuiltin($query_key) { 37 + 38 + $query = $this->newSavedQuery(); 39 + $query->setQueryKey($query_key); 40 + 41 + switch ($query_key) { 42 + case 'all': 43 + return $query; 44 + } 45 + 46 + return parent::buildSavedQueryFromBuiltin($query_key); 47 + } 48 + 49 + }
+52
src/applications/dashboard/storage/PhabricatorDashboard.php
··· 1 + <?php 2 + 3 + /** 4 + * A collection of dashboard panels with a specific layout. 5 + */ 6 + final class PhabricatorDashboard extends PhabricatorDashboardDAO 7 + implements PhabricatorPolicyInterface { 8 + 9 + private $name; 10 + private $viewPolicy; 11 + private $editPolicy; 12 + 13 + public function getConfiguration() { 14 + return array( 15 + self::CONFIG_AUX_PHID => true, 16 + ) + parent::getConfiguration(); 17 + } 18 + 19 + public function generatePHID() { 20 + return PhabricatorPHID::generateNewPHID( 21 + PhabricatorDashboardPHIDTypeDashboard::TYPECONST); 22 + } 23 + 24 + 25 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 26 + 27 + 28 + public function getCapabilities() { 29 + return array( 30 + PhabricatorPolicyCapability::CAN_VIEW, 31 + PhabricatorPolicyCapability::CAN_EDIT, 32 + ); 33 + } 34 + 35 + public function getPolicy($capability) { 36 + switch ($capability) { 37 + case PhabricatorPolicyCapability::CAN_VIEW: 38 + return $this->getViewPolicy(); 39 + case PhabricatorPolicyCapability::CAN_EDIT: 40 + return $this->getEditPolicy(); 41 + } 42 + } 43 + 44 + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 45 + return false; 46 + } 47 + 48 + public function describeAutomaticCapability($capability) { 49 + return null; 50 + } 51 + 52 + }
+9
src/applications/dashboard/storage/PhabricatorDashboardDAO.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorDashboardDAO extends PhabricatorLiskDAO { 4 + 5 + public function getApplicationName() { 6 + return 'dashboard'; 7 + } 8 + 9 + }
+68
src/applications/dashboard/storage/PhabricatorDashboardPanel.php
··· 1 + <?php 2 + 3 + /** 4 + * An individual dashboard panel. 5 + */ 6 + final class PhabricatorDashboardPanel extends PhabricatorDashboardDAO { 7 + 8 + private $name; 9 + private $viewPolicy; 10 + private $editPolicy; 11 + private $properties = array(); 12 + 13 + public function getConfiguration() { 14 + return array( 15 + self::CONFIG_AUX_PHID => true, 16 + self::CONFIG_SERIALIZATION => array( 17 + 'properties' => self::SERIALIZATION_JSON, 18 + ), 19 + ) + parent::getConfiguration(); 20 + } 21 + 22 + public function generatePHID() { 23 + return PhabricatorPHID::generateNewPHID( 24 + PhabricatorDashboardPHIDTypeDashboard::TYPECONST); 25 + } 26 + 27 + public function getProperty($key, $default = null) { 28 + return idx($this->properties, $key, $default); 29 + } 30 + 31 + public function setProperty($key, $value) { 32 + $this->properties[$key] = $value; 33 + return $this; 34 + } 35 + 36 + public function getMonogram() { 37 + return 'W'.$this->getID(); 38 + } 39 + 40 + 41 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 42 + 43 + 44 + public function getCapabilities() { 45 + return array( 46 + PhabricatorPolicyCapability::CAN_VIEW, 47 + PhabricatorPolicyCapability::CAN_EDIT, 48 + ); 49 + } 50 + 51 + public function getPolicy($capability) { 52 + switch ($capability) { 53 + case PhabricatorPolicyCapability::CAN_VIEW: 54 + return $this->getViewPolicy(); 55 + case PhabricatorPolicyCapability::CAN_EDIT: 56 + return $this->getEditPolicy(); 57 + } 58 + } 59 + 60 + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 61 + return false; 62 + } 63 + 64 + public function describeAutomaticCapability($capability) { 65 + return null; 66 + } 67 + 68 + }
+1
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 117 117 'db.nuance' => array(), 118 118 'db.passphrase' => array(), 119 119 'db.phragment' => array(), 120 + 'db.dashboard' => array(), 120 121 '0000.legacy.sql' => array( 121 122 'legacy' => 0, 122 123 ),