From f309960a2d784511f7c3ec9580b7cd9ea78fc20d Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 8 May 2015 14:59:11 -0700 Subject: [PATCH] Conpherence - allow for public rooms to really work Summary: Fixes T8102. This makes public rooms actually work. Also lets users see the search listings page so they can wander into all public rooms without logging in. Test Plan: As logged out user, visited ZXX and ZYY. ZXX was public, so I could see it and had a little "Login to Participate" button in the bottom. ZYY was not public so I was prompted to login. Back on ZXX I clicked the Conpherence crumb and got a sensible UI where most links prompted me to login. CLicked "search" and saw listings for all public rooms. Reviewers: epriestley, chad Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8102 Differential Revision: https://secure.phabricator.com/D12778 --- resources/celerity/map.php | 4 ++-- .../controller/ConpherenceListController.php | 4 ++++ .../controller/ConpherenceNewController.php | 3 +-- .../ConpherenceNewRoomController.php | 3 +-- .../ConpherenceRoomListController.php | 4 ++++ .../ConpherenceUpdateController.php | 2 +- .../controller/ConpherenceViewController.php | 21 ++++++++++++++++--- .../ConpherenceWidgetController.php | 12 ++++++++++- src/view/form/PHUIFormLayoutView.php | 9 +++++++- .../application/conpherence/message-pane.css | 8 +++++++ 10 files changed, 58 insertions(+), 12 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index eec3ad47fa..ad7a2c1b62 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -47,7 +47,7 @@ return array( 'rsrc/css/application/config/unhandled-exception.css' => '37d4f9a2', 'rsrc/css/application/conpherence/durable-column.css' => '2e68a92f', 'rsrc/css/application/conpherence/menu.css' => 'f389e048', - 'rsrc/css/application/conpherence/message-pane.css' => '3150e2a2', + 'rsrc/css/application/conpherence/message-pane.css' => '0e75feef', 'rsrc/css/application/conpherence/notification.css' => 'd208f806', 'rsrc/css/application/conpherence/transaction.css' => '885433f0', 'rsrc/css/application/conpherence/update.css' => '1099a660', @@ -514,7 +514,7 @@ return array( 'config-welcome-css' => '6abd79be', 'conpherence-durable-column-view' => '2e68a92f', 'conpherence-menu-css' => 'f389e048', - 'conpherence-message-pane-css' => '3150e2a2', + 'conpherence-message-pane-css' => '0e75feef', 'conpherence-notification-css' => 'd208f806', 'conpherence-thread-manager' => '9e507b59', 'conpherence-transaction-css' => '885433f0', diff --git a/src/applications/conpherence/controller/ConpherenceListController.php b/src/applications/conpherence/controller/ConpherenceListController.php index f8be8f7de6..ad672ff6d8 100644 --- a/src/applications/conpherence/controller/ConpherenceListController.php +++ b/src/applications/conpherence/controller/ConpherenceListController.php @@ -25,6 +25,10 @@ final class ConpherenceListController extends ConpherenceController { return $mode; } + public function shouldAllowPublic() { + return true; + } + public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $title = pht('Conpherence'); diff --git a/src/applications/conpherence/controller/ConpherenceNewController.php b/src/applications/conpherence/controller/ConpherenceNewController.php index a887404c7d..102cf0e5ea 100644 --- a/src/applications/conpherence/controller/ConpherenceNewController.php +++ b/src/applications/conpherence/controller/ConpherenceNewController.php @@ -42,9 +42,8 @@ final class ConpherenceNewController extends ConpherenceController { } } } else { - $uri = $this->getApplicationURI($conpherence->getID()); return id(new AphrontRedirectResponse()) - ->setURI($uri); + ->setURI('/'.$conpherence->getMonogram()); } } else { $participant_prefill = $request->getStr('participant'); diff --git a/src/applications/conpherence/controller/ConpherenceNewRoomController.php b/src/applications/conpherence/controller/ConpherenceNewRoomController.php index ce9afcb195..a401da0a19 100644 --- a/src/applications/conpherence/controller/ConpherenceNewRoomController.php +++ b/src/applications/conpherence/controller/ConpherenceNewRoomController.php @@ -36,9 +36,8 @@ final class ConpherenceNewRoomController extends ConpherenceController { ->setActor($user) ->applyTransactions($conpherence, $xactions); - $uri = $this->getApplicationURI($conpherence->getID()); return id(new AphrontRedirectResponse()) - ->setURI($uri); + ->setURI('/'.$conpherence->getMonogram()); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; diff --git a/src/applications/conpherence/controller/ConpherenceRoomListController.php b/src/applications/conpherence/controller/ConpherenceRoomListController.php index 299ca6b8d0..43c36d20d1 100644 --- a/src/applications/conpherence/controller/ConpherenceRoomListController.php +++ b/src/applications/conpherence/controller/ConpherenceRoomListController.php @@ -2,6 +2,10 @@ final class ConpherenceRoomListController extends ConpherenceController { + public function shouldAllowPublic() { + return true; + } + public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 3e86accf7c..eea1d1dc8a 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -251,7 +251,7 @@ final class ConpherenceUpdateController case 'redirect': default: return id(new AphrontRedirectResponse()) - ->setURI($this->getApplicationURI($conpherence->getID().'/')); + ->setURI('/'.$conpherence->getMonogram()); break; } } diff --git a/src/applications/conpherence/controller/ConpherenceViewController.php b/src/applications/conpherence/controller/ConpherenceViewController.php index e0a39030c3..39138a40b4 100644 --- a/src/applications/conpherence/controller/ConpherenceViewController.php +++ b/src/applications/conpherence/controller/ConpherenceViewController.php @@ -5,6 +5,10 @@ final class ConpherenceViewController extends const OLDER_FETCH_LIMIT = 5; + public function shouldAllowPublic() { + return true; + } + public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); @@ -138,7 +142,7 @@ final class ConpherenceViewController extends $conpherence, PhabricatorPolicyCapability::CAN_JOIN); $participating = $conpherence->getParticipantIfExists($user->getPHID()); - if (!$can_join && !$participating) { + if (!$can_join && !$participating && $user->isLoggedIn()) { return null; } $draft = PhabricatorDraft::newFromUserAndKey( @@ -147,9 +151,20 @@ final class ConpherenceViewController extends if ($participating) { $action = ConpherenceUpdateActions::MESSAGE; $button_text = pht('Send'); - } else { + } else if ($user->isLoggedIn()) { $action = ConpherenceUpdateActions::JOIN_ROOM; $button_text = pht('Join'); + } else { + // user not logged in so give them a login button. + $login_href = id(new PhutilURI('/auth/start/')) + ->setQueryParam('next', '/'.$conpherence->getMonogram()); + return id(new PHUIFormLayoutView()) + ->addClass('login-to-participate') + ->appendChild( + id(new PHUIButtonView()) + ->setTag('a') + ->setText(pht('Login to Participate')) + ->setHref((string)$login_href)); } $update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/'); @@ -157,10 +172,10 @@ final class ConpherenceViewController extends $form = id(new AphrontFormView()) + ->setUser($user) ->setAction($update_uri) ->addSigil('conpherence-pontificate') ->setWorkflow(true) - ->setUser($user) ->addHiddenInput('action', $action) ->appendChild( id(new PhabricatorRemarkupControl()) diff --git a/src/applications/conpherence/controller/ConpherenceWidgetController.php b/src/applications/conpherence/controller/ConpherenceWidgetController.php index f7775dcc32..9a06f0dcf9 100644 --- a/src/applications/conpherence/controller/ConpherenceWidgetController.php +++ b/src/applications/conpherence/controller/ConpherenceWidgetController.php @@ -13,6 +13,10 @@ final class ConpherenceWidgetController extends ConpherenceController { return $this->userPreferences; } + public function shouldAllowPublic() { + return true; + } + public function handleRequest(AphrontRequest $request) { $request = $this->getRequest(); $user = $request->getUser(); @@ -26,6 +30,9 @@ final class ConpherenceWidgetController extends ConpherenceController { ->withIDs(array($conpherence_id)) ->needWidgetData(true) ->executeOne(); + if (!$conpherence) { + return new Aphront404Response(); + } $this->setConpherence($conpherence); $this->setUserPreferences($user->loadPreferences()); @@ -138,8 +145,11 @@ final class ConpherenceWidgetController extends ConpherenceController { PhabricatorPolicyCapability::CAN_JOIN); if ($can_join) { $text = pht('Settings are available after joining the room.'); - } else { + } else if ($viewer->isLoggedIn()) { $text = pht('Settings not applicable to rooms you can not join.'); + } else { + $text = pht( + 'Settings are available after logging in and joining the room.'); } return phutil_tag( 'div', diff --git a/src/view/form/PHUIFormLayoutView.php b/src/view/form/PHUIFormLayoutView.php index fa05a72a59..87e35e03c1 100644 --- a/src/view/form/PHUIFormLayoutView.php +++ b/src/view/form/PHUIFormLayoutView.php @@ -7,6 +7,7 @@ */ final class PHUIFormLayoutView extends AphrontView { + private $classes = array(); private $fullWidth; public function setFullWidth($width) { @@ -14,6 +15,11 @@ final class PHUIFormLayoutView extends AphrontView { return $this; } + public function addClass($class) { + $this->classes[] = $class; + return $this; + } + public function appendInstructions($text) { return $this->appendChild( phutil_tag( @@ -38,7 +44,8 @@ final class PHUIFormLayoutView extends AphrontView { } public function render() { - $classes = array('phui-form-view'); + $classes = $this->classes; + $classes[] = 'phui-form-view'; if ($this->fullWidth) { $classes[] = 'phui-form-full-width'; diff --git a/webroot/rsrc/css/application/conpherence/message-pane.css b/webroot/rsrc/css/application/conpherence/message-pane.css index 5226480031..e702b34083 100644 --- a/webroot/rsrc/css/application/conpherence/message-pane.css +++ b/webroot/rsrc/css/application/conpherence/message-pane.css @@ -113,6 +113,14 @@ right: 241px; } +.conpherence-message-pane .phui-form-view.login-to-participate { + height: 28px; +} + +.conpherence-message-pane .login-to-participate a.button { + float: right; +} + .conpherence-message-pane .aphront-form-control-submit button, .conpherence-message-pane .aphront-form-control-submit a.button { margin-top: 6px;