1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

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
This commit is contained in:
Chad Little 2017-04-13 09:04:11 -07:00
parent 03f2a41b16
commit 3d6049d0da
7 changed files with 10 additions and 104 deletions

View file

@ -78,10 +78,6 @@ abstract class ConpherenceController extends PhabricatorController {
} }
$participating = $conpherence->getParticipantIfExists($viewer->getPHID()); $participating = $conpherence->getParticipantIfExists($viewer->getPHID());
$can_join = PhabricatorPolicyFilter::hasCapability(
$viewer,
$conpherence,
PhabricatorPolicyCapability::CAN_JOIN);
$header->addActionItem( $header->addActionItem(
id(new PHUIIconCircleView()) id(new PHUIIconCircleView())
@ -129,7 +125,7 @@ abstract class ConpherenceController extends PhabricatorController {
->setColor('green') ->setColor('green')
->addClass('conpherence-search-toggle')); ->addClass('conpherence-search-toggle'));
if ($can_join && !$participating) { if (!$participating) {
$action = ConpherenceUpdateActions::JOIN_ROOM; $action = ConpherenceUpdateActions::JOIN_ROOM;
$uri = $this->getApplicationURI('update/'.$conpherence->getID().'/'); $uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$button = phutil_tag( $button = phutil_tag(

View file

@ -34,9 +34,6 @@ final class ConpherenceNewRoomController extends ConpherenceController {
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($request->getStr('editPolicy')); ->setNewValue($request->getStr('editPolicy'));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($request->getStr('joinPolicy'));
try { try {
$editor $editor
@ -55,7 +52,6 @@ final class ConpherenceNewRoomController extends ConpherenceController {
$conpherence->setViewPolicy($request->getStr('viewPolicy')); $conpherence->setViewPolicy($request->getStr('viewPolicy'));
$conpherence->setEditPolicy($request->getStr('editPolicy')); $conpherence->setEditPolicy($request->getStr('editPolicy'));
$conpherence->setJoinPolicy($request->getStr('joinPolicy'));
} }
} else { } else {
if ($request->getStr('participant')) { if ($request->getStr('participant')) {
@ -110,12 +106,6 @@ final class ConpherenceNewRoomController extends ConpherenceController {
->setName('editPolicy') ->setName('editPolicy')
->setPolicyObject($conpherence) ->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('joinPolicy')
->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
->setPolicies($policies)); ->setPolicies($policies));
$dialog->appendChild($form); $dialog->appendChild($form);

View file

@ -24,9 +24,6 @@ final class ConpherenceUpdateController
case ConpherenceUpdateActions::METADATA: case ConpherenceUpdateActions::METADATA:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
break; break;
case ConpherenceUpdateActions::JOIN_ROOM:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
break;
case ConpherenceUpdateActions::NOTIFICATIONS: case ConpherenceUpdateActions::NOTIFICATIONS:
$need_participants = true; $need_participants = true;
break; break;
@ -153,9 +150,6 @@ final class ConpherenceUpdateController
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($request->getStr('editPolicy')); ->setNewValue($request->getStr('editPolicy'));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($request->getStr('joinPolicy'));
if (!$request->getExists('force_ajax')) { if (!$request->getExists('force_ajax')) {
$response_mode = 'redirect'; $response_mode = 'redirect';
} }
@ -256,16 +250,9 @@ final class ConpherenceUpdateController
$participant = $conpherence->getParticipantIfExists($user->getPHID()); $participant = $conpherence->getParticipantIfExists($user->getPHID());
if (!$participant) { if (!$participant) {
$can_join = PhabricatorPolicyFilter::hasCapability( if ($user->isLoggedIn()) {
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_JOIN);
if ($can_join) {
$text = pht( $text = pht(
'Notification settings are available after joining the room.'); 'Notification settings are available after joining the room.');
} else if ($user->isLoggedIn()) {
$text = pht(
'Notification settings not applicable to rooms you can not join.');
} else { } else {
$text = pht( $text = pht(
'Notification settings are available after logging in and joining '. 'Notification settings are available after logging in and joining '.
@ -459,12 +446,6 @@ final class ConpherenceUpdateController
->setName('editPolicy') ->setName('editPolicy')
->setPolicyObject($conpherence) ->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('joinPolicy')
->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
->setPolicies($policies)); ->setPolicies($policies));
$view = id(new AphrontDialogView()) $view = id(new AphrontDialogView())

View file

@ -119,11 +119,6 @@ final class ConpherenceViewController extends
return id(new AphrontAjaxResponse())->setContent($content); return id(new AphrontAjaxResponse())->setContent($content);
} }
$can_join = PhabricatorPolicyFilter::hasCapability(
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_JOIN);
$layout = id(new ConpherenceLayoutView()) $layout = id(new ConpherenceLayoutView())
->setUser($user) ->setUser($user)
->setBaseURI($this->getApplicationURI()) ->setBaseURI($this->getApplicationURI())
@ -151,12 +146,9 @@ final class ConpherenceViewController extends
$conpherence = $this->getConpherence(); $conpherence = $this->getConpherence();
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$can_join = PhabricatorPolicyFilter::hasCapability(
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_JOIN);
$participating = $conpherence->getParticipantIfExists($user->getPHID()); $participating = $conpherence->getParticipantIfExists($user->getPHID());
if (!$can_join && !$participating && $user->isLoggedIn()) { if (!$participating && $user->isLoggedIn()) {
return null; return null;
} }
$draft = PhabricatorDraft::newFromUserAndKey( $draft = PhabricatorDraft::newFromUserAndKey(

View file

@ -92,7 +92,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
return $types; return $types;
} }
@ -383,24 +382,12 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$actor_phid = $this->requireActor()->getPHID(); $actor_phid = $this->requireActor()->getPHID();
$is_join = (($add === array($actor_phid)) && !$rem); // You need CAN_EDIT to change participants other than yourself.
$is_leave = (($rem === array($actor_phid)) && !$add); PhabricatorPolicyFilter::requireCapability(
$this->requireActor(),
$object,
PhabricatorPolicyCapability::CAN_EDIT);
if ($is_join) {
// You need CAN_JOIN to join a room.
PhabricatorPolicyFilter::requireCapability(
$this->requireActor(),
$object,
PhabricatorPolicyCapability::CAN_JOIN);
} else if ($is_leave) {
// You don't need any capabilities to leave a conpherence thread.
} else {
// You need CAN_EDIT to change participants other than yourself.
PhabricatorPolicyFilter::requireCapability(
$this->requireActor(),
$object,
PhabricatorPolicyCapability::CAN_EDIT);
}
break; break;
case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE:
case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE:

View file

@ -33,7 +33,7 @@ final class ConpherenceThread extends ConpherenceDAO
->attachParticipants(array()) ->attachParticipants(array())
->setViewPolicy($default_policy) ->setViewPolicy($default_policy)
->setEditPolicy($default_policy) ->setEditPolicy($default_policy)
->setJoinPolicy($default_policy); ->setJoinPolicy('');
} }
protected function getConfiguration() { protected function getConfiguration() {
@ -298,7 +298,6 @@ final class ConpherenceThread extends ConpherenceDAO
return array( return array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_EDIT,
PhabricatorPolicyCapability::CAN_JOIN,
); );
} }
@ -308,8 +307,6 @@ final class ConpherenceThread extends ConpherenceDAO
return $this->getViewPolicy(); return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT: case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy(); return $this->getEditPolicy();
case PhabricatorPolicyCapability::CAN_JOIN:
return $this->getJoinPolicy();
} }
return PhabricatorPolicies::POLICY_NOONE; return PhabricatorPolicies::POLICY_NOONE;
} }
@ -322,7 +319,6 @@ final class ConpherenceThread extends ConpherenceDAO
switch ($capability) { switch ($capability) {
case PhabricatorPolicyCapability::CAN_EDIT: case PhabricatorPolicyCapability::CAN_EDIT:
case PhabricatorPolicyCapability::CAN_JOIN:
return false; return false;
} }

View file

@ -53,11 +53,6 @@ final class ConpherenceTransaction
$new = $this->getNewValue(); $new = $this->getNewValue();
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return $this->getRoomTitle();
break;
case self::TYPE_PARTICIPANTS: case self::TYPE_PARTICIPANTS:
$add = array_diff($new, $old); $add = array_diff($new, $old);
$rem = array_diff($old, $new); $rem = array_diff($old, $new);
@ -90,37 +85,6 @@ final class ConpherenceTransaction
return parent::getTitle(); return parent::getTitle();
} }
private function getRoomTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY:
return pht(
'%s changed the visibility of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
case PhabricatorTransactions::TYPE_EDIT_POLICY:
return pht(
'%s changed the edit policy of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht(
'%s changed the join policy of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
}
}
public function getRequiredHandlePHIDs() { public function getRequiredHandlePHIDs() {
$phids = parent::getRequiredHandlePHIDs(); $phids = parent::getRequiredHandlePHIDs();