Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/editor/ConpherenceEditor.php
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { | ||||
| public function getTransactionTypes() { | public function getTransactionTypes() { | ||||
| $types = parent::getTransactionTypes(); | $types = parent::getTransactionTypes(); | ||||
| $types[] = ConpherenceTransaction::TYPE_PARTICIPANTS; | $types[] = ConpherenceTransaction::TYPE_PARTICIPANTS; | ||||
| $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; | ||||
| } | } | ||||
| public function getCreateObjectTitle($author, $object) { | public function getCreateObjectTitle($author, $object) { | ||||
| return pht('%s created this room.', $author); | return pht('%s created this room.', $author); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
| $old_map = array_fuse($xaction->getOldValue()); | $old_map = array_fuse($xaction->getOldValue()); | ||||
| $new_map = array_fuse($xaction->getNewValue()); | $new_map = array_fuse($xaction->getNewValue()); | ||||
| $add = array_keys(array_diff_key($new_map, $old_map)); | $add = array_keys(array_diff_key($new_map, $old_map)); | ||||
| $rem = array_keys(array_diff_key($old_map, $new_map)); | $rem = array_keys(array_diff_key($old_map, $new_map)); | ||||
| $actor_phid = $this->requireActor()->getPHID(); | $actor_phid = $this->requireActor()->getPHID(); | ||||
| $is_join = (($add === array($actor_phid)) && !$rem); | |||||
| $is_leave = (($rem === array($actor_phid)) && !$add); | |||||
| 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. | // You need CAN_EDIT to change participants other than yourself. | ||||
| PhabricatorPolicyFilter::requireCapability( | PhabricatorPolicyFilter::requireCapability( | ||||
| $this->requireActor(), | $this->requireActor(), | ||||
| $object, | $object, | ||||
| PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
| } | |||||
| break; | break; | ||||
| case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: | case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: | ||||
| case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: | case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: | ||||
| PhabricatorPolicyFilter::requireCapability( | PhabricatorPolicyFilter::requireCapability( | ||||
| $this->requireActor(), | $this->requireActor(), | ||||
| $object, | $object, | ||||
| PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines | |||||