Skip to content

Commit 3d6049d

Browse files
author
Chad Little
committed
Remove CAN_JOIN policy from Conpherence
Summary: Fixes T12178, Fixes T11704 Not sure this feature gets any use and I can't find a similar option in other software, so removing it I think simiplifies a number of things. Removes CAN_JOIN and joinable is basically now CAN_VIEW and !$participating. Also removed some old transaction strings for other policies. Don't seem used. Test Plan: Create a new room, edit room policies, see changes. Log into second account, search for rooms, everything now is visible. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12178, T11704 Differential Revision: https://secure.phabricator.com/D17675
1 parent 03f2a41 commit 3d6049d

File tree

7 files changed

+11
-105
lines changed

7 files changed

+11
-105
lines changed

src/applications/conpherence/controller/ConpherenceController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ protected function buildHeaderPaneContent(
7878
}
7979

8080
$participating = $conpherence->getParticipantIfExists($viewer->getPHID());
81-
$can_join = PhabricatorPolicyFilter::hasCapability(
82-
$viewer,
83-
$conpherence,
84-
PhabricatorPolicyCapability::CAN_JOIN);
8581

8682
$header->addActionItem(
8783
id(new PHUIIconCircleView())
@@ -129,7 +125,7 @@ protected function buildHeaderPaneContent(
129125
->setColor('green')
130126
->addClass('conpherence-search-toggle'));
131127

132-
if ($can_join && !$participating) {
128+
if (!$participating) {
133129
$action = ConpherenceUpdateActions::JOIN_ROOM;
134130
$uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
135131
$button = phutil_tag(

src/applications/conpherence/controller/ConpherenceNewRoomController.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public function handleRequest(AphrontRequest $request) {
3434
$xactions[] = id(new ConpherenceTransaction())
3535
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
3636
->setNewValue($request->getStr('editPolicy'));
37-
$xactions[] = id(new ConpherenceTransaction())
38-
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
39-
->setNewValue($request->getStr('joinPolicy'));
4037

4138
try {
4239
$editor
@@ -55,7 +52,6 @@ public function handleRequest(AphrontRequest $request) {
5552

5653
$conpherence->setViewPolicy($request->getStr('viewPolicy'));
5754
$conpherence->setEditPolicy($request->getStr('editPolicy'));
58-
$conpherence->setJoinPolicy($request->getStr('joinPolicy'));
5955
}
6056
} else {
6157
if ($request->getStr('participant')) {
@@ -110,12 +106,6 @@ public function handleRequest(AphrontRequest $request) {
110106
->setName('editPolicy')
111107
->setPolicyObject($conpherence)
112108
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
113-
->setPolicies($policies))
114-
->appendChild(
115-
id(new AphrontFormPolicyControl())
116-
->setName('joinPolicy')
117-
->setPolicyObject($conpherence)
118-
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
119109
->setPolicies($policies));
120110

121111
$dialog->appendChild($form);

src/applications/conpherence/controller/ConpherenceUpdateController.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public function handleRequest(AphrontRequest $request) {
2424
case ConpherenceUpdateActions::METADATA:
2525
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
2626
break;
27-
case ConpherenceUpdateActions::JOIN_ROOM:
28-
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
29-
break;
3027
case ConpherenceUpdateActions::NOTIFICATIONS:
3128
$need_participants = true;
3229
break;
@@ -153,9 +150,6 @@ public function handleRequest(AphrontRequest $request) {
153150
$xactions[] = id(new ConpherenceTransaction())
154151
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
155152
->setNewValue($request->getStr('editPolicy'));
156-
$xactions[] = id(new ConpherenceTransaction())
157-
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
158-
->setNewValue($request->getStr('joinPolicy'));
159153
if (!$request->getExists('force_ajax')) {
160154
$response_mode = 'redirect';
161155
}
@@ -256,16 +250,9 @@ private function renderPreferencesDialog(
256250

257251
$participant = $conpherence->getParticipantIfExists($user->getPHID());
258252
if (!$participant) {
259-
$can_join = PhabricatorPolicyFilter::hasCapability(
260-
$user,
261-
$conpherence,
262-
PhabricatorPolicyCapability::CAN_JOIN);
263-
if ($can_join) {
253+
if ($user->isLoggedIn()) {
264254
$text = pht(
265255
'Notification settings are available after joining the room.');
266-
} else if ($user->isLoggedIn()) {
267-
$text = pht(
268-
'Notification settings not applicable to rooms you can not join.');
269256
} else {
270257
$text = pht(
271258
'Notification settings are available after logging in and joining '.
@@ -459,12 +446,6 @@ private function renderMetadataDialog(
459446
->setName('editPolicy')
460447
->setPolicyObject($conpherence)
461448
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
462-
->setPolicies($policies))
463-
->appendChild(
464-
id(new AphrontFormPolicyControl())
465-
->setName('joinPolicy')
466-
->setPolicyObject($conpherence)
467-
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
468449
->setPolicies($policies));
469450

470451
$view = id(new AphrontDialogView())

src/applications/conpherence/controller/ConpherenceViewController.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ public function handleRequest(AphrontRequest $request) {
119119
return id(new AphrontAjaxResponse())->setContent($content);
120120
}
121121

122-
$can_join = PhabricatorPolicyFilter::hasCapability(
123-
$user,
124-
$conpherence,
125-
PhabricatorPolicyCapability::CAN_JOIN);
126-
127122
$layout = id(new ConpherenceLayoutView())
128123
->setUser($user)
129124
->setBaseURI($this->getApplicationURI())
@@ -151,12 +146,9 @@ private function renderFormContent() {
151146

152147
$conpherence = $this->getConpherence();
153148
$user = $this->getRequest()->getUser();
154-
$can_join = PhabricatorPolicyFilter::hasCapability(
155-
$user,
156-
$conpherence,
157-
PhabricatorPolicyCapability::CAN_JOIN);
149+
158150
$participating = $conpherence->getParticipantIfExists($user->getPHID());
159-
if (!$can_join && !$participating && $user->isLoggedIn()) {
151+
if (!$participating && $user->isLoggedIn()) {
160152
return null;
161153
}
162154
$draft = PhabricatorDraft::newFromUserAndKey(

src/applications/conpherence/editor/ConpherenceEditor.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public function getTransactionTypes() {
9292
$types[] = PhabricatorTransactions::TYPE_COMMENT;
9393
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
9494
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
95-
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
9695

9796
return $types;
9897
}
@@ -383,24 +382,12 @@ protected function requireCapabilities(
383382

384383
$actor_phid = $this->requireActor()->getPHID();
385384

386-
$is_join = (($add === array($actor_phid)) && !$rem);
387-
$is_leave = (($rem === array($actor_phid)) && !$add);
388-
389-
if ($is_join) {
390-
// You need CAN_JOIN to join a room.
391-
PhabricatorPolicyFilter::requireCapability(
392-
$this->requireActor(),
393-
$object,
394-
PhabricatorPolicyCapability::CAN_JOIN);
395-
} else if ($is_leave) {
396-
// You don't need any capabilities to leave a conpherence thread.
397-
} else {
398-
// You need CAN_EDIT to change participants other than yourself.
399-
PhabricatorPolicyFilter::requireCapability(
400-
$this->requireActor(),
401-
$object,
402-
PhabricatorPolicyCapability::CAN_EDIT);
403-
}
385+
// You need CAN_EDIT to change participants other than yourself.
386+
PhabricatorPolicyFilter::requireCapability(
387+
$this->requireActor(),
388+
$object,
389+
PhabricatorPolicyCapability::CAN_EDIT);
390+
404391
break;
405392
case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE:
406393
case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE:

src/applications/conpherence/storage/ConpherenceThread.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function initializeNewRoom(PhabricatorUser $sender) {
3333
->attachParticipants(array())
3434
->setViewPolicy($default_policy)
3535
->setEditPolicy($default_policy)
36-
->setJoinPolicy($default_policy);
36+
->setJoinPolicy('');
3737
}
3838

3939
protected function getConfiguration() {
@@ -298,7 +298,6 @@ public function getCapabilities() {
298298
return array(
299299
PhabricatorPolicyCapability::CAN_VIEW,
300300
PhabricatorPolicyCapability::CAN_EDIT,
301-
PhabricatorPolicyCapability::CAN_JOIN,
302301
);
303302
}
304303

@@ -308,8 +307,6 @@ public function getPolicy($capability) {
308307
return $this->getViewPolicy();
309308
case PhabricatorPolicyCapability::CAN_EDIT:
310309
return $this->getEditPolicy();
311-
case PhabricatorPolicyCapability::CAN_JOIN:
312-
return $this->getJoinPolicy();
313310
}
314311
return PhabricatorPolicies::POLICY_NOONE;
315312
}
@@ -322,7 +319,6 @@ public function hasAutomaticCapability($capability, PhabricatorUser $user) {
322319

323320
switch ($capability) {
324321
case PhabricatorPolicyCapability::CAN_EDIT:
325-
case PhabricatorPolicyCapability::CAN_JOIN:
326322
return false;
327323
}
328324

src/applications/conpherence/storage/ConpherenceTransaction.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ public function getTitle() {
5353
$new = $this->getNewValue();
5454

5555
switch ($this->getTransactionType()) {
56-
case PhabricatorTransactions::TYPE_VIEW_POLICY:
57-
case PhabricatorTransactions::TYPE_EDIT_POLICY:
58-
case PhabricatorTransactions::TYPE_JOIN_POLICY:
59-
return $this->getRoomTitle();
60-
break;
6156
case self::TYPE_PARTICIPANTS:
6257
$add = array_diff($new, $old);
6358
$rem = array_diff($old, $new);
@@ -90,37 +85,6 @@ public function getTitle() {
9085
return parent::getTitle();
9186
}
9287

93-
private function getRoomTitle() {
94-
$author_phid = $this->getAuthorPHID();
95-
96-
$old = $this->getOldValue();
97-
$new = $this->getNewValue();
98-
99-
switch ($this->getTransactionType()) {
100-
case PhabricatorTransactions::TYPE_VIEW_POLICY:
101-
return pht(
102-
'%s changed the visibility of this room from "%s" to "%s".',
103-
$this->renderHandleLink($author_phid),
104-
$this->renderPolicyName($old, 'old'),
105-
$this->renderPolicyName($new, 'new'));
106-
break;
107-
case PhabricatorTransactions::TYPE_EDIT_POLICY:
108-
return pht(
109-
'%s changed the edit policy of this room from "%s" to "%s".',
110-
$this->renderHandleLink($author_phid),
111-
$this->renderPolicyName($old, 'old'),
112-
$this->renderPolicyName($new, 'new'));
113-
break;
114-
case PhabricatorTransactions::TYPE_JOIN_POLICY:
115-
return pht(
116-
'%s changed the join policy of this room from "%s" to "%s".',
117-
$this->renderHandleLink($author_phid),
118-
$this->renderPolicyName($old, 'old'),
119-
$this->renderPolicyName($new, 'new'));
120-
break;
121-
}
122-
}
123-
12488
public function getRequiredHandlePHIDs() {
12589
$phids = parent::getRequiredHandlePHIDs();
12690

0 commit comments

Comments
 (0)