Differential D16595 Diff 39947 src/applications/conpherence/controller/ConpherenceViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/controller/ConpherenceViewController.php
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | if ($request->isAjax()) { | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$content['aphlictDropdownData'] = array( | $content['aphlictDropdownData'] = array( | ||||
$dropdown_query->getNotificationData(), | $dropdown_query->getNotificationData(), | ||||
$dropdown_query->getConpherenceData(), | $dropdown_query->getConpherenceData(), | ||||
); | ); | ||||
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()) | ||||
->setThread($conpherence) | ->setThread($conpherence) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setMessages($messages) | ->setMessages($messages) | ||||
->setReplyForm($form) | ->setReplyForm($form) | ||||
->setLatestTransactionID($data['latest_transaction_id']) | ->setLatestTransactionID($data['latest_transaction_id']) | ||||
->setRole('thread'); | ->setRole('thread'); | ||||
$participating = $conpherence->getParticipantIfExists($user->getPHID()); | |||||
if (!$user->isLoggedIn() || ($can_join && !$participating)) { | |||||
$layout->addClass('conpherence-no-pontificate'); | |||||
} | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setPageObjectPHIDs(array($conpherence->getPHID())) | ->setPageObjectPHIDs(array($conpherence->getPHID())) | ||||
->appendChild($layout); | ->appendChild($layout); | ||||
} | } | ||||
private function renderFormContent() { | private function renderFormContent() { | ||||
$conpherence = $this->getConpherence(); | $conpherence = $this->getConpherence(); | ||||
$user = $this->getRequest()->getUser(); | $user = $this->getRequest()->getUser(); | ||||
$can_join = PhabricatorPolicyFilter::hasCapability( | $can_join = PhabricatorPolicyFilter::hasCapability( | ||||
$user, | $user, | ||||
$conpherence, | $conpherence, | ||||
PhabricatorPolicyCapability::CAN_JOIN); | PhabricatorPolicyCapability::CAN_JOIN); | ||||
$participating = $conpherence->getParticipantIfExists($user->getPHID()); | $participating = $conpherence->getParticipantIfExists($user->getPHID()); | ||||
if (!$can_join && !$participating && $user->isLoggedIn()) { | if (!$can_join && !$participating && $user->isLoggedIn()) { | ||||
return null; | return null; | ||||
} | } | ||||
$draft = PhabricatorDraft::newFromUserAndKey( | $draft = PhabricatorDraft::newFromUserAndKey( | ||||
$user, | $user, | ||||
$conpherence->getPHID()); | $conpherence->getPHID()); | ||||
if ($participating) { | |||||
$action = ConpherenceUpdateActions::MESSAGE; | |||||
$button_text = pht('Send'); | |||||
} else if ($user->isLoggedIn()) { | |||||
$action = ConpherenceUpdateActions::JOIN_ROOM; | |||||
$button_text = pht('Join Room'); | |||||
} 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().'/'); | $update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/'); | ||||
if ($participating) { | |||||
$this->initBehavior('conpherence-pontificate'); | $this->initBehavior('conpherence-pontificate'); | ||||
return | |||||
$form = | |||||
id(new AphrontFormView()) | id(new AphrontFormView()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setAction($update_uri) | ->setAction($update_uri) | ||||
->addSigil('conpherence-pontificate') | ->addSigil('conpherence-pontificate') | ||||
->setWorkflow(true) | ->setWorkflow(true) | ||||
->addHiddenInput('action', $action) | ->addHiddenInput('action', ConpherenceUpdateActions::MESSAGE) | ||||
->appendChild( | ->appendChild( | ||||
id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setName('text') | ->setName('text') | ||||
->setValue($draft->getDraft())) | ->setValue($draft->getDraft())) | ||||
->render(); | |||||
} else if ($user->isLoggedIn()) { | |||||
return | |||||
id(new AphrontFormView()) | |||||
->setUser($user) | |||||
->setAction($update_uri) | |||||
->addSigil('conpherence-pontificate') | |||||
->setWorkflow(true) | |||||
->addClass('join-room') | |||||
->addHiddenInput('action', ConpherenceUpdateActions::JOIN_ROOM) | |||||
->appendInstructions(pht('Join this room to participate.')) | |||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->setValue($button_text)) | ->setValue(pht('Join Room'))); | ||||
->render(); | |||||
return $form; | } 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') | |||||
->appendInstructions(pht('Log in to join this room and participate.')) | |||||
->appendChild( | |||||
id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setText(pht('Login to Participate')) | |||||
->setHref((string)$login_href)); | |||||
} | |||||
} | } | ||||
private function getNeededTransactions( | private function getNeededTransactions( | ||||
ConpherenceThread $conpherence, | ConpherenceThread $conpherence, | ||||
$message_id) { | $message_id) { | ||||
if ($message_id) { | if ($message_id) { | ||||
$newer_transactions = $conpherence->getTransactions(); | $newer_transactions = $conpherence->getTransactions(); | ||||
Show All 30 Lines |