@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 authorPHID to Dashboards

Summary: Adds an authorPHIDs, populates olds ones.

Test Plan: Make a new Dashboard, see that I created it.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+82 -4
+39
resources/sql/autopatches/20161210.dashboards.01.author.php
··· 1 + <?php 2 + 3 + // Set authorPHID on Dashboards 4 + // 5 + $table = new PhabricatorDashboard(); 6 + $conn_w = $table->establishConnection('w'); 7 + 8 + $txn_table = new PhabricatorDashboardTransaction(); 9 + $txn_conn = $table->establishConnection('r'); 10 + 11 + echo pht("Building Dashboard authorPHIDs...\n"); 12 + 13 + foreach (new LiskMigrationIterator($table) as $dashboard) { 14 + 15 + if ($dashboard->getAuthorPHID()) { 16 + continue; 17 + } 18 + 19 + $author_row = queryfx_one( 20 + $txn_conn, 21 + 'SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1', 22 + $txn_table->getTableName(), 23 + $dashboard->getPHID()); 24 + 25 + if (!$author_row) { 26 + $author_phid = id(new PhabricatorDashboardApplication())->getPHID(); 27 + } else { 28 + $author_phid = $author_row['authorPHID']; 29 + } 30 + 31 + queryfx( 32 + $conn_w, 33 + 'UPDATE %T SET authorPHID = %s WHERE id = %d', 34 + $table->getTableName(), 35 + $author_phid, 36 + $dashboard->getID()); 37 + } 38 + 39 + echo pht("Done\n");
+2
resources/sql/autopatches/20161210.dashboards.01.author.sql
··· 1 + ALTER TABLE {$NAMESPACE}_dashboard.dashboard 2 + ADD authorPHID VARBINARY(64) NOT NULL;
+13
src/applications/dashboard/query/PhabricatorDashboardQuery.php
··· 6 6 private $ids; 7 7 private $phids; 8 8 private $statuses; 9 + private $authorPHIDs; 9 10 10 11 private $needPanels; 11 12 private $needProjects; ··· 22 23 23 24 public function withStatuses(array $statuses) { 24 25 $this->statuses = $statuses; 26 + return $this; 27 + } 28 + 29 + public function withAuthorPHIDs(array $authors) { 30 + $this->authorPHIDs = $authors; 25 31 return $this; 26 32 } 27 33 ··· 119 125 $conn, 120 126 'status IN (%Ls)', 121 127 $this->statuses); 128 + } 129 + 130 + if ($this->authorPHIDs !== null) { 131 + $where[] = qsprintf( 132 + $conn, 133 + 'authorPHID IN (%Ls)', 134 + $this->authorPHIDs); 122 135 } 123 136 124 137 return $where;
+25 -4
src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
··· 18 18 19 19 protected function buildCustomSearchFields() { 20 20 return array( 21 + id(new PhabricatorSearchDatasourceField()) 22 + ->setLabel(pht('Authored By')) 23 + ->setKey('authorPHIDs') 24 + ->setDatasource(new PhabricatorPeopleUserFunctionDatasource()), 21 25 id(new PhabricatorSearchCheckboxesField()) 22 26 ->setKey('statuses') 23 27 ->setLabel(pht('Status')) ··· 30 34 } 31 35 32 36 protected function getBuiltinQueryNames() { 33 - return array( 34 - 'open' => pht('Active Dashboards'), 35 - 'all' => pht('All Dashboards'), 36 - ); 37 + $names = array(); 38 + 39 + if ($this->requireViewer()->isLoggedIn()) { 40 + $names['authored'] = pht('Authored'); 41 + } 42 + 43 + $names['open'] = pht('Active Dashboards'); 44 + $names['all'] = pht('All Dashboards'); 45 + 46 + return $names; 37 47 } 38 48 39 49 public function buildSavedQueryFromBuiltin($query_key) { 40 50 $query = $this->newSavedQuery(); 41 51 $query->setQueryKey($query_key); 52 + $viewer = $this->requireViewer(); 42 53 43 54 switch ($query_key) { 44 55 case 'all': 45 56 return $query; 57 + case 'authored': 58 + return $query->setParameter( 59 + 'authored', 60 + array( 61 + $viewer->getPHID(), 62 + )); 46 63 case 'open': 47 64 return $query->setParameter( 48 65 'statuses', ··· 59 76 60 77 if ($map['statuses']) { 61 78 $query->withStatuses($map['statuses']); 79 + } 80 + 81 + if ($map['authorPHIDs']) { 82 + $query->withAuthorPHIDs($map['authorPHIDs']); 62 83 } 63 84 64 85 return $query;
+3
src/applications/dashboard/storage/PhabricatorDashboard.php
··· 12 12 PhabricatorProjectInterface { 13 13 14 14 protected $name; 15 + protected $authorPHID; 15 16 protected $viewPolicy; 16 17 protected $editPolicy; 17 18 protected $status; ··· 31 32 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 32 33 ->setEditPolicy($actor->getPHID()) 33 34 ->setStatus(self::STATUS_ACTIVE) 35 + ->setAuthorPHID($actor->getPHID()) 34 36 ->attachPanels(array()) 35 37 ->attachPanelPHIDs(array()); 36 38 } ··· 61 63 self::CONFIG_COLUMN_SCHEMA => array( 62 64 'name' => 'text255', 63 65 'status' => 'text32', 66 + 'authorPHID' => 'phid', 64 67 ), 65 68 ) + parent::getConfiguration(); 66 69 }