Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13975882
D7371.id16588.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D7371.id16588.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1519,6 +1519,7 @@
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
'PhabricatorProjectEditor' => 'applications/project/editor/PhabricatorProjectEditor.php',
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
+ 'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
@@ -1533,6 +1534,7 @@
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
'PhabricatorProjectTestDataGenerator' => 'applications/project/lipsum/PhabricatorProjectTestDataGenerator.php',
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
+ 'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
@@ -3732,6 +3734,7 @@
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
'PhabricatorProjectEditor' => 'PhabricatorEditor',
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
+ 'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
'PhabricatorProjectListController' =>
array(
0 => 'PhabricatorProjectController',
@@ -3749,6 +3752,7 @@
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction',
+ 'PhabricatorProjectTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRedirectController' => 'PhabricatorController',
Index: src/applications/project/application/PhabricatorApplicationProject.php
===================================================================
--- src/applications/project/application/PhabricatorApplicationProject.php
+++ src/applications/project/application/PhabricatorApplicationProject.php
@@ -47,6 +47,7 @@
'create/' => 'PhabricatorProjectCreateController',
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
=> 'PhabricatorProjectUpdateController',
+ 'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
),
);
}
Index: src/applications/project/controller/PhabricatorProjectHistoryController.php
===================================================================
--- /dev/null
+++ src/applications/project/controller/PhabricatorProjectHistoryController.php
@@ -0,0 +1,60 @@
+<?php
+
+final class PhabricatorProjectHistoryController
+ extends PhabricatorProjectController {
+
+ private $id;
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function willProcessRequest(array $data) {
+ $this->id = $data['id'];
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $id = $this->id;
+
+ $project = id(new PhabricatorProjectQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ if (!$project) {
+ return new Aphront404Response();
+ }
+
+ $xactions = id(new PhabricatorProjectTransactionQuery())
+ ->setViewer($viewer)
+ ->withObjectPHIDs(array($project->getPHID()))
+ ->execute();
+
+ $timeline = id(new PhabricatorApplicationTransactionView())
+ ->setUser($viewer)
+ ->setObjectPHID($project->getPHID())
+ ->setTransactions($xactions);
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName($project->getName())
+ ->setHref($this->getApplicationURI("view/{$id}/")));
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName(pht('History')));
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $timeline,
+ ),
+ array(
+ 'title' => $project->getName(),
+ 'device' => true,
+ ));
+ }
+
+}
Index: src/applications/project/controller/PhabricatorProjectProfileController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfileController.php
+++ src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -248,6 +248,12 @@
}
$view->addAction($action);
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('View History'))
+ ->setHref($this->getApplicationURI("history/{$id}/"))
+ ->setIcon('transcript'));
+
return $view;
}
Index: src/applications/project/query/PhabricatorProjectTransactionQuery.php
===================================================================
--- /dev/null
+++ src/applications/project/query/PhabricatorProjectTransactionQuery.php
@@ -0,0 +1,10 @@
+<?php
+
+final class PhabricatorProjectTransactionQuery
+ extends PhabricatorApplicationTransactionQuery {
+
+ public function getTemplateApplicationTransaction() {
+ return new PhabricatorProjectTransaction();
+ }
+
+}
Index: src/applications/project/storage/PhabricatorProjectTransaction.php
===================================================================
--- src/applications/project/storage/PhabricatorProjectTransaction.php
+++ src/applications/project/storage/PhabricatorProjectTransaction.php
@@ -15,4 +15,91 @@
return PhabricatorProjectPHIDTypeProject::TYPECONST;
}
+ public function getRequiredHandlePHIDs() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ $req_phids = array();
+ switch ($this->getTransactionType()) {
+ case PhabricatorProjectTransaction::TYPE_MEMBERS:
+ $add = array_diff($new, $old);
+ $rem = array_diff($old, $new);
+ $req_phids = array_merge($add, $rem);
+ break;
+ }
+
+ return array_merge($req_phids, parent::getRequiredHandlePHIDs());
+ }
+
+ public function getTitle() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+ $author_handle = $this->renderHandleLink($this->getAuthorPHID());
+
+ switch ($this->getTransactionType()) {
+ case PhabricatorProjectTransaction::TYPE_NAME:
+ if ($old === null) {
+ return pht(
+ '%s created this project.',
+ $author_handle);
+ } else {
+ return pht(
+ '%s renamed this project from "%s" to "%s".',
+ $author_handle,
+ $old,
+ $new);
+ }
+ case PhabricatorProjectTransaction::TYPE_STATUS:
+ if ($old == 0) {
+ return pht(
+ '%s closed this project.',
+ $author_handle);
+ } else {
+ return pht(
+ '%s reopened this project.',
+ $author_handle);
+ }
+ case PhabricatorProjectTransaction::TYPE_MEMBERS:
+ $add = array_diff($new, $old);
+ $rem = array_diff($old, $new);
+
+ if ($add && $rem) {
+ return pht(
+ '%s changed project member(s), added %d: %s; removed %d: %s',
+ $author_handle,
+ count($add),
+ $this->renderHandleList($add),
+ count($rem),
+ $this->renderHandleList($rem));
+ } else if ($add) {
+ if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) {
+ return pht(
+ '%s joined this project.',
+ $author_handle);
+ } else {
+ return pht(
+ '%s added %d project member(s): %s',
+ $author_handle,
+ count($add),
+ $this->renderHandleList($add));
+ }
+ } else if ($rem) {
+ if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) {
+ return pht(
+ '%s left this project.',
+ $author_handle);
+ } else {
+ return pht(
+ '%s removed %d project member(s): %s',
+ $author_handle,
+ count($rem),
+ $this->renderHandleList($rem));
+ }
+ }
+ }
+
+ return parent::getTitle();
+ }
+
+
}
Index: src/applications/transactions/storage/PhabricatorApplicationTransaction.php
===================================================================
--- src/applications/transactions/storage/PhabricatorApplicationTransaction.php
+++ src/applications/transactions/storage/PhabricatorApplicationTransaction.php
@@ -148,6 +148,7 @@
break;
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
$phids[] = array($old);
}
@@ -226,6 +227,7 @@
return 'message';
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
return 'lock';
case PhabricatorTransactions::TYPE_EDGE:
return 'link';
@@ -242,6 +244,7 @@
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
if ($this->getOldValue() === null) {
return true;
} else {
@@ -270,6 +273,10 @@
return pht(
'This %s already has that edit policy.',
$this->getApplicationObjectTypeName());
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
+ return pht(
+ 'This %s already has that join policy.',
+ $this->getApplicationObjectTypeName());
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht(
'All users are already subscribed to this %s.',
@@ -306,6 +313,13 @@
$this->getApplicationObjectTypeName(),
$this->renderPolicyName($old),
$this->renderPolicyName($new));
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
+ return pht(
+ '%s changed the join policy of this %s from "%s" to "%s".',
+ $this->renderHandleLink($author_phid),
+ $this->getApplicationObjectTypeName(),
+ $this->renderPolicyName($old),
+ $this->renderPolicyName($new));
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
@@ -420,6 +434,11 @@
'%s changed the edit policy for %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
+ return pht(
+ '%s changed the join policy for %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht(
'%s updated subscribers of %s.',
@@ -487,6 +506,7 @@
return pht('Commented On');
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
+ case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht('Changed Policy');
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return pht('Changed Subscribers');
Index: src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
===================================================================
--- src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
+++ src/infrastructure/internationalization/PhabricatorBaseEnglishTranslation.php
@@ -793,6 +793,23 @@
'%s edited commit(s), added %d: %s; removed %d: %s.' =>
'%s edited commits, added %3$s; removed %5$s.',
+ '%s changed project member(s), added %d: %s; removed %d: %s' =>
+ '%s changed project members, added %3$s; removed %5$s',
+
+ '%s added %d project member(s): %s' => array(
+ array(
+ '%s added a member: %3$s',
+ '%s added members: %3$s',
+ ),
+ ),
+
+ '%s removed %d project member(s): %s' => array(
+ array(
+ '%s removed a member: %3$s',
+ '%s removed members: %3$s',
+ ),
+ ),
+
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 19, 12:02 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732017
Default Alt Text
D7371.id16588.diff (12 KB)
Attached To
Mode
D7371: Add project history and title strings
Attached
Detach File
Event Timeline
Log In to Comment