Page MenuHomePhabricator

D8165.diff
No OneTemporary

D8165.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -4555,6 +4555,7 @@
0 => 'PhabricatorProjectDAO',
1 => 'PhabricatorFlaggableInterface',
2 => 'PhabricatorPolicyInterface',
+ 3 => 'PhabricatorSubscribableInterface',
),
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
Index: src/applications/files/storage/PhabricatorFile.php
===================================================================
--- src/applications/files/storage/PhabricatorFile.php
+++ src/applications/files/storage/PhabricatorFile.php
@@ -933,6 +933,14 @@
return ($this->authorPHID == $phid);
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
Index: src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
===================================================================
--- src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
+++ src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
@@ -64,6 +64,14 @@
return false;
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
Index: src/applications/legalpad/storage/LegalpadDocument.php
===================================================================
--- src/applications/legalpad/storage/LegalpadDocument.php
+++ src/applications/legalpad/storage/LegalpadDocument.php
@@ -91,13 +91,25 @@
return 'L'.$this->getID();
}
-/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
+
+/* -( PhabricatorSubscribableInterface )----------------------------------- */
+
public function isAutomaticallySubscribed($phid) {
return ($this->creatorPHID == $phid);
}
-/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
+
+/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
public function getCapabilities() {
return array(
Index: src/applications/macro/storage/PhabricatorFileImageMacro.php
===================================================================
--- src/applications/macro/storage/PhabricatorFileImageMacro.php
+++ src/applications/macro/storage/PhabricatorFileImageMacro.php
@@ -79,6 +79,14 @@
return false;
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
Index: src/applications/paste/storage/PhabricatorPaste.php
===================================================================
--- src/applications/paste/storage/PhabricatorPaste.php
+++ src/applications/paste/storage/PhabricatorPaste.php
@@ -87,6 +87,14 @@
return ($this->authorPHID == $phid);
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
Index: src/applications/pholio/storage/PholioMock.php
===================================================================
--- src/applications/pholio/storage/PholioMock.php
+++ src/applications/pholio/storage/PholioMock.php
@@ -137,6 +137,14 @@
return ($this->authorPHID == $phid);
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
Index: src/applications/phriction/storage/PhrictionDocument.php
===================================================================
--- src/applications/phriction/storage/PhrictionDocument.php
+++ src/applications/phriction/storage/PhrictionDocument.php
@@ -104,6 +104,10 @@
return $parts[1].'/';
}
+
+/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
+
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -133,12 +137,26 @@
return null;
}
+
+/* -( PhabricatorSubscribableInterface )----------------------------------- */
+
+
public function isAutomaticallySubscribed($phid) {
return false;
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
+
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
+
public function getUsersToNotifyOfTokenGiven() {
return PhabricatorSubscribersQuery::loadSubscribersForPHID($this->phid);
}
Index: src/applications/ponder/storage/PonderAnswer.php
===================================================================
--- src/applications/ponder/storage/PonderAnswer.php
+++ src/applications/ponder/storage/PonderAnswer.php
@@ -188,5 +188,12 @@
return ($phid == $this->getAuthorPHID());
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
}
Index: src/applications/ponder/storage/PonderQuestion.php
===================================================================
--- src/applications/ponder/storage/PonderQuestion.php
+++ src/applications/ponder/storage/PonderQuestion.php
@@ -170,10 +170,6 @@
return $this->getPHID();
}
- public function isAutomaticallySubscribed($phid) {
- return ($phid == $this->getAuthorPHID());
- }
-
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
@@ -181,6 +177,20 @@
return parent::save();
}
+ public function getOriginalTitle() {
+ // TODO: Make this actually save/return the original title.
+ return $this->getTitle();
+ }
+
+ public function getFullTitle() {
+ $id = $this->getID();
+ $title = $this->getTitle();
+ return "Q{$id}: {$title}";
+ }
+
+
+/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -210,15 +220,20 @@
'The user who asked a question can always view and edit it.');
}
- public function getOriginalTitle() {
- // TODO: Make this actually save/return the original title.
- return $this->getTitle();
+
+/* -( PhabricatorSubscribableInterface )----------------------------------- */
+
+
+ public function isAutomaticallySubscribed($phid) {
+ return ($phid == $this->getAuthorPHID());
}
- public function getFullTitle() {
- $id = $this->getID();
- $title = $this->getTitle();
- return "Q{$id}: {$title}";
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
}
Index: src/applications/project/controller/PhabricatorProjectProfileController.php
===================================================================
--- src/applications/project/controller/PhabricatorProjectProfileController.php
+++ src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -214,6 +214,7 @@
}
$view->addAction($action);
+
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('View History'))
Index: src/applications/project/storage/PhabricatorProject.php
===================================================================
--- src/applications/project/storage/PhabricatorProject.php
+++ src/applications/project/storage/PhabricatorProject.php
@@ -3,7 +3,8 @@
final class PhabricatorProject extends PhabricatorProjectDAO
implements
PhabricatorFlaggableInterface,
- PhabricatorPolicyInterface {
+ PhabricatorPolicyInterface,
+ PhabricatorSubscribableInterface {
protected $name;
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
@@ -15,7 +16,6 @@
protected $editPolicy;
protected $joinPolicy;
- private $subprojectsNeedUpdate;
private $memberPHIDs = self::ATTACHABLE;
private $sparseMembers = self::ATTACHABLE;
private $profile = self::ATTACHABLE;
@@ -134,4 +134,21 @@
return 'projects/'.$slug;
}
+
+/* -( PhabricatorSubscribableInterface )----------------------------------- */
+
+
+ public function isAutomaticallySubscribed($phid) {
+ return false;
+ }
+
+ public function shouldShowSubscribersProperty() {
+ return false;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return false;
+ }
+
+
}
Index: src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
===================================================================
--- src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
+++ src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
@@ -125,6 +125,14 @@
return ($phid == $this->getAuthorPHID());
}
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
Index: src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
===================================================================
--- src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
+++ src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
@@ -56,6 +56,13 @@
$handle->getURI());
}
+ if (!$object->shouldAllowSubscription($user->getPHID())) {
+ return $this->buildErrorResponse(
+ pht('You Can Not Subscribe'),
+ pht('You can not subscribe to this object.'),
+ $handle->getURI());
+ }
+
if ($object instanceof PhabricatorApplicationTransactionInterface) {
if ($is_add) {
$xaction_value = array(
Index: src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
===================================================================
--- src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
+++ src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
@@ -33,6 +33,11 @@
return;
}
+ if (!$object->shouldAllowSubscription($user->getPHID())) {
+ // This object doesn't allow the viewer to subscribe.
+ return;
+ }
+
if ($object->isAutomaticallySubscribed($user->getPHID())) {
$sub_action = id(new PhabricatorActionView())
->setWorkflow(true)
@@ -95,6 +100,12 @@
// This object isn't subscribable.
return;
}
+
+ if (!$object->shouldShowSubscribersProperty()) {
+ // This object doesn't render subscribers in its property list.
+ return;
+ }
+
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$object->getPHID());
if ($subscribers) {
Index: src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
===================================================================
--- src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
+++ src/applications/subscriptions/interface/PhabricatorSubscribableInterface.php
@@ -13,4 +13,43 @@
*/
public function isAutomaticallySubscribed($phid);
+
+ /**
+ * Return `true` to indicate that "Subscribers:" should be shown when
+ * rendering property lists for this object, or `false` to omit the property.
+ *
+ * @return bool True to show the "Subscribers:" property.
+ */
+ public function shouldShowSubscribersProperty();
+
+
+ /**
+ * Return `true` to indicate that the "Subscribe" action should be shown and
+ * enabled when rendering action lists for this object, or `false` to omit
+ * the action.
+ *
+ * @param phid Viewing or acting user PHID.
+ * @return bool True to allow the user to subscribe.
+ */
+ public function shouldAllowSubscription($phid);
+
}
+
+// TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
+
+/* -( PhabricatorSubscribableInterface )----------------------------------- */
+/*
+
+ public function isAutomaticallySubscribed($phid) {
+ return false;
+ }
+
+ public function shouldShowSubscribersProperty() {
+ return true;
+ }
+
+ public function shouldAllowSubscription($phid) {
+ return true;
+ }
+
+*/

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 10:33 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6728522
Default Alt Text
D8165.diff (12 KB)

Event Timeline