Differential D17675 Diff 42512 src/applications/conpherence/controller/ConpherenceUpdateController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/controller/ConpherenceUpdateController.php
| Show All 18 Lines | switch ($action) { | ||||
| if ($person_phid != $user->getPHID()) { | if ($person_phid != $user->getPHID()) { | ||||
| $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; | $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; | ||||
| } | } | ||||
| break; | break; | ||||
| case ConpherenceUpdateActions::ADD_PERSON: | case ConpherenceUpdateActions::ADD_PERSON: | ||||
| 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; | ||||
| case ConpherenceUpdateActions::LOAD: | case ConpherenceUpdateActions::LOAD: | ||||
| break; | break; | ||||
| } | } | ||||
| $conpherence = id(new ConpherenceThreadQuery()) | $conpherence = id(new ConpherenceThreadQuery()) | ||||
| ->setViewer($user) | ->setViewer($user) | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | if ($request->isFormPost() || ($action == ConpherenceUpdateActions::LOAD)) { | ||||
| ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) | ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) | ||||
| ->setNewValue($topic); | ->setNewValue($topic); | ||||
| $xactions[] = id(new ConpherenceTransaction()) | $xactions[] = id(new ConpherenceTransaction()) | ||||
| ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ||||
| ->setNewValue($request->getStr('viewPolicy')); | ->setNewValue($request->getStr('viewPolicy')); | ||||
| $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'; | ||||
| } | } | ||||
| break; | break; | ||||
| case ConpherenceUpdateActions::LOAD: | case ConpherenceUpdateActions::LOAD: | ||||
| $updated = false; | $updated = false; | ||||
| $response_mode = 'ajax'; | $response_mode = 'ajax'; | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | final class ConpherenceUpdateController | ||||
| private function renderPreferencesDialog( | private function renderPreferencesDialog( | ||||
| ConpherenceThread $conpherence) { | ConpherenceThread $conpherence) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $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 '. | ||||
| 'the room.'); | 'the room.'); | ||||
| } | } | ||||
| return id(new AphrontDialogView()) | return id(new AphrontDialogView()) | ||||
| ->setTitle(pht('Room Preferences')) | ->setTitle(pht('Room Preferences')) | ||||
| ->appendParagraph($text); | ->appendParagraph($text); | ||||
| ▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | $form | ||||
| ->setPolicyObject($conpherence) | ->setPolicyObject($conpherence) | ||||
| ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) | ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) | ||||
| ->setPolicies($policies)) | ->setPolicies($policies)) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
| ->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()) | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->addHiddenInput('action', 'metadata') | ->addHiddenInput('action', 'metadata') | ||||
| ->addHiddenInput( | ->addHiddenInput( | ||||
| 'latest_transaction_id', | 'latest_transaction_id', | ||||
| $request->getInt('latest_transaction_id')) | $request->getInt('latest_transaction_id')) | ||||
| ▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines | |||||