Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/conpherence/controller/ConpherenceColumnViewController.php b/src/applications/conpherence/controller/ConpherenceColumnViewController.php
index a6ee236d5f..f6bac7aa91 100644
--- a/src/applications/conpherence/controller/ConpherenceColumnViewController.php
+++ b/src/applications/conpherence/controller/ConpherenceColumnViewController.php
@@ -1,100 +1,99 @@
<?php
final class ConpherenceColumnViewController extends
ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$latest_conpherences = array();
$latest_participant = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($user->getPHID()))
->setLimit(6)
->execute();
if ($latest_participant) {
$conpherence_phids = mpull($latest_participant, 'getConpherencePHID');
$latest_conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
- ->needTransactions(true)
->needParticipantCache(true)
->execute();
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
$latest_conpherences = array_select_keys(
$latest_conpherences,
$conpherence_phids);
}
$conpherence = null;
$should_404 = false;
if ($request->getInt('id')) {
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($request->getInt('id')))
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
$should_404 = true;
} else if ($latest_participant) {
$participant = head($latest_participant);
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array($participant->getConpherencePHID()))
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
$should_404 = true;
}
$durable_column = id(new ConpherenceDurableColumnView())
->setUser($user)
->setVisible(true);
if (!$conpherence) {
if ($should_404) {
return new Aphront404Response();
}
$conpherence_id = null;
$conpherence_phid = null;
$latest_transaction_id = null;
$can_edit = false;
} else {
$this->setConpherence($conpherence);
$participant = $conpherence->getParticipant($user->getPHID());
$transactions = $conpherence->getTransactions();
$latest_transaction = head($transactions);
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$participant->markUpToDate($conpherence, $latest_transaction);
unset($write_guard);
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$durable_column
->setDraft($draft)
->setSelectedConpherence($conpherence)
->setConpherences($latest_conpherences);
$conpherence_id = $conpherence->getID();
$conpherence_phid = $conpherence->getPHID();
$latest_transaction_id = $latest_transaction->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
}
$response = array(
'content' => hsprintf('%s', $durable_column),
'threadID' => $conpherence_id,
'threadPHID' => $conpherence_phid,
'latestTransactionID' => $latest_transaction_id,
'canEdit' => $can_edit,
);
return id(new AphrontAjaxResponse())->setContent($response);
}
}
diff --git a/src/applications/conpherence/controller/ConpherenceListController.php b/src/applications/conpherence/controller/ConpherenceListController.php
index 2045dfcf71..0921ff59cd 100644
--- a/src/applications/conpherence/controller/ConpherenceListController.php
+++ b/src/applications/conpherence/controller/ConpherenceListController.php
@@ -1,152 +1,151 @@
<?php
final class ConpherenceListController extends ConpherenceController {
const SELECTED_MODE = 'selected';
const UNSELECTED_MODE = 'unselected';
/**
* Two main modes of operation...
*
* 1 - /conpherence/ - UNSELECTED_MODE
* 2 - /conpherence/<id>/ - SELECTED_MODE
*
* UNSELECTED_MODE is not an Ajax request while the other two are Ajax
* requests.
*/
private function determineMode() {
$request = $this->getRequest();
$mode = self::UNSELECTED_MODE;
if ($request->isAjax()) {
$mode = self::SELECTED_MODE;
}
return $mode;
}
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$title = pht('Conpherence');
$conpherence = null;
$limit = ConpherenceThreadListView::SEE_MORE_LIMIT * 5;
$all_participation = array();
$mode = $this->determineMode();
switch ($mode) {
case self::SELECTED_MODE:
$conpherence_id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
if ($conpherence->getTitle()) {
$title = $conpherence->getTitle();
}
$cursor = $conpherence->getParticipantIfExists($user->getPHID());
$data = $this->loadDefaultParticipation($limit);
$all_participation = $data['all_participation'];
if (!$cursor) {
$menu_participation = id(new ConpherenceParticipant())
->makeEphemeral()
->setConpherencePHID($conpherence->getPHID())
->setParticipantPHID($user->getPHID());
} else {
$menu_participation = $cursor;
}
$all_participation =
array($conpherence->getPHID() => $menu_participation) +
$all_participation;
break;
case self::UNSELECTED_MODE:
default:
$data = $this->loadDefaultParticipation($limit);
$all_participation = $data['all_participation'];
break;
}
$threads = $this->loadConpherenceThreadData(
$all_participation);
$thread_view = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setThreads($threads);
switch ($mode) {
case self::SELECTED_MODE:
$response = id(new AphrontAjaxResponse())->setContent($thread_view);
break;
case self::UNSELECTED_MODE:
default:
$layout = id(new ConpherenceLayoutView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setThreadView($thread_view)
->setRole('list');
if ($conpherence) {
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$layout->setHeader($this->buildHeaderPaneContent(
$conpherence,
$policy_objects));
$layout->setThread($conpherence);
} else {
$thread = ConpherenceThread::initializeNewThread($user);
$thread->attachHandles(array());
$thread->attachTransactions(array());
$thread->makeEphemeral();
$layout->setHeader(
$this->buildHeaderPaneContent($thread, array()));
}
$response = $this->buildApplicationPage(
$layout,
array(
'title' => $title,
));
break;
}
return $response;
}
private function loadDefaultParticipation($limit) {
$viewer = $this->getRequest()->getUser();
$all_participation = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($viewer->getPHID()))
->setLimit($limit)
->execute();
return array(
'all_participation' => $all_participation,
);
}
private function loadConpherenceThreadData($participation) {
$user = $this->getRequest()->getUser();
$conpherence_phids = array_keys($participation);
$conpherences = array();
if ($conpherence_phids) {
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
- ->needTransactions(true)
->needParticipantCache(true)
->execute();
// this will re-sort by participation data
$conpherences = array_select_keys($conpherences, $conpherence_phids);
}
return $conpherences;
}
}
diff --git a/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php b/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
index e101da5f42..e87225c299 100644
--- a/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
+++ b/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
@@ -1,101 +1,102 @@
<?php
final class ConpherenceNotificationPanelController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherences = array();
$unread_status = ConpherenceParticipationStatus::BEHIND;
$participant_data = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($user->getPHID()))
->setLimit(5)
->execute();
if ($participant_data) {
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array_keys($participant_data))
->needTransactions(true)
+ ->setTransactionLimit(3 * 5)
->needParticipantCache(true)
->execute();
}
if ($conpherences) {
require_celerity_resource('conpherence-notification-css');
// re-order the conpherences based on participation data
$conpherences = array_select_keys(
$conpherences, array_keys($participant_data));
$view = new AphrontNullView();
foreach ($conpherences as $conpherence) {
$p_data = $participant_data[$conpherence->getPHID()];
$d_data = $conpherence->getDisplayData($user);
$classes = array(
'phabricator-notification',
'conpherence-notification',
);
if ($p_data->getParticipationStatus() == $unread_status) {
$classes[] = 'phabricator-notification-unread';
}
$uri = $this->getApplicationURI($conpherence->getID().'/');
$title = $d_data['title'];
$subtitle = $d_data['subtitle'];
$unread_count = $d_data['unread_count'];
$epoch = $d_data['epoch'];
$image = $d_data['image'];
$msg_view = id(new ConpherenceMenuItemView())
->setUser($user)
->setTitle($title)
->setSubtitle($subtitle)
->setHref($uri)
->setEpoch($epoch)
->setImageURI($image)
->setUnreadCount($unread_count);
$view->appendChild(javelin_tag(
'div',
array(
'class' => implode(' ', $classes),
'sigil' => 'notification',
'meta' => array(
'href' => $uri,
),
),
$msg_view));
}
$content = $view->render();
} else {
$content = phutil_tag_div(
'phabricator-notification no-notifications',
pht('You have no messages.'));
}
$content = hsprintf(
'<div class="phabricator-notification-header">%s</div>'.
'%s',
phutil_tag(
'a',
array(
'href' => '/conpherence/',
),
pht('Messages')),
$content);
$unread = id(new ConpherenceParticipantCountQuery())
->withParticipantPHIDs(array($user->getPHID()))
->withParticipationStatus($unread_status)
->execute();
$unread_count = idx($unread, $user->getPHID(), 0);
$json = array(
'content' => $content,
'number' => (int)$unread_count,
);
return id(new AphrontAjaxResponse())->setContent($json);
}
}
diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php
index e60d7e0124..2258bc4882 100644
--- a/src/applications/conpherence/controller/ConpherenceUpdateController.php
+++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php
@@ -1,481 +1,481 @@
<?php
final class ConpherenceUpdateController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherence_id = $request->getURIData('id');
if (!$conpherence_id) {
return new Aphront404Response();
}
$need_participants = false;
$needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
$action = $request->getStr('action', ConpherenceUpdateActions::METADATA);
switch ($action) {
case ConpherenceUpdateActions::REMOVE_PERSON:
$person_phid = $request->getStr('remove_person');
if ($person_phid != $user->getPHID()) {
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
}
break;
case ConpherenceUpdateActions::ADD_PERSON:
case ConpherenceUpdateActions::METADATA:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
break;
case ConpherenceUpdateActions::JOIN_ROOM:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN;
break;
case ConpherenceUpdateActions::NOTIFICATIONS:
$need_participants = true;
break;
case ConpherenceUpdateActions::LOAD:
break;
}
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->needFilePHIDs(true)
->needParticipants($need_participants)
->requireCapabilities($needed_capabilities)
->executeOne();
$latest_transaction_id = null;
$response_mode = $request->isAjax() ? 'ajax' : 'redirect';
$error_view = null;
$e_file = array();
$errors = array();
$delete_draft = false;
$xactions = array();
if ($request->isFormPost() || ($action == ConpherenceUpdateActions::LOAD)) {
$editor = id(new ConpherenceEditor())
->setContinueOnNoEffect($request->isContinueRequest())
->setContentSourceFromRequest($request)
->setActor($user);
switch ($action) {
case ConpherenceUpdateActions::DRAFT:
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->setDraft($request->getStr('text'));
$draft->replaceOrDelete();
return new AphrontAjaxResponse();
case ConpherenceUpdateActions::JOIN_ROOM:
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceTransactionType::TYPE_PARTICIPANTS)
->setNewValue(array('+' => array($user->getPHID())));
$delete_draft = true;
$message = $request->getStr('text');
if ($message) {
$message_xactions = $editor->generateTransactionsFromText(
$user,
$conpherence,
$message);
$xactions = array_merge($xactions, $message_xactions);
}
// for now, just redirect back to the conpherence so everything
// will work okay...!
$response_mode = 'redirect';
break;
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
if (strlen($message)) {
$xactions = $editor->generateTransactionsFromText(
$user,
$conpherence,
$message);
$delete_draft = true;
} else {
$action = ConpherenceUpdateActions::LOAD;
$updated = false;
$response_mode = 'ajax';
}
break;
case ConpherenceUpdateActions::ADD_PERSON:
$person_phids = $request->getArr('add_person');
if (!empty($person_phids)) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceTransactionType::TYPE_PARTICIPANTS)
->setNewValue(array('+' => $person_phids));
}
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
if (!$request->isContinueRequest()) {
// do nothing; we'll display a confirmation dialogue instead
break;
}
$person_phid = $request->getStr('remove_person');
if ($person_phid && $person_phid == $user->getPHID()) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceTransactionType::TYPE_PARTICIPANTS)
->setNewValue(array('-' => array($person_phid)));
$response_mode = 'go-home';
}
break;
case ConpherenceUpdateActions::NOTIFICATIONS:
$notifications = $request->getStr('notifications');
$participant = $conpherence->getParticipantIfExists($user->getPHID());
if (!$participant) {
return id(new Aphront404Response());
}
$participant->setSettings(array('notifications' => $notifications));
$participant->save();
$result = pht(
'Updated notification settings to "%s".',
ConpherenceSettings::getHumanString($notifications));
return id(new AphrontAjaxResponse())
->setContent($result);
break;
case ConpherenceUpdateActions::METADATA:
// all metadata updates are continue requests
if (!$request->isContinueRequest()) {
break;
}
$title = $request->getStr('title');
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransactionType::TYPE_TITLE)
->setNewValue($title);
if ($conpherence->getIsRoom()) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($request->getStr('viewPolicy'));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($request->getStr('editPolicy'));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($request->getStr('joinPolicy'));
}
if (!$request->getExists('force_ajax')) {
$response_mode = 'redirect';
}
break;
case ConpherenceUpdateActions::LOAD:
$updated = false;
$response_mode = 'ajax';
break;
default:
throw new Exception('Unknown action: '.$action);
break;
}
if ($xactions) {
try {
$xactions = $editor->applyTransactions($conpherence, $xactions);
if ($delete_draft) {
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->delete();
}
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())
->setCancelURI($this->getApplicationURI($conpherence_id.'/'))
->setException($ex);
}
// xactions had no effect...!
if (empty($xactions)) {
$errors[] = pht(
'That was a non-update. Try cancel.');
}
}
if ($xactions || ($action == ConpherenceUpdateActions::LOAD)) {
switch ($response_mode) {
case 'ajax':
$latest_transaction_id = $request->getInt('latest_transaction_id');
$content = $this->loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id);
return id(new AphrontAjaxResponse())
->setContent($content);
break;
case 'go-home':
return id(new AphrontRedirectResponse())
->setURI($this->getApplicationURI());
break;
case 'redirect':
default:
return id(new AphrontRedirectResponse())
->setURI($this->getApplicationURI($conpherence->getID().'/'));
break;
}
}
}
if ($errors) {
$error_view = id(new PHUIInfoView())
->setErrors($errors);
}
switch ($action) {
case ConpherenceUpdateActions::ADD_PERSON:
$dialogue = $this->renderAddPersonDialogue($conpherence);
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
$dialogue = $this->renderRemovePersonDialogue($conpherence);
break;
case ConpherenceUpdateActions::METADATA:
default:
$dialogue = $this->renderMetadataDialogue($conpherence, $error_view);
break;
}
return id(new AphrontDialogResponse())
->setDialog($dialogue
->setUser($user)
->setWidth(AphrontDialogView::WIDTH_FORM)
->setSubmitURI($this->getApplicationURI('update/'.$conpherence_id.'/'))
->addSubmitButton()
->addCancelButton($this->getApplicationURI($conpherence->getID().'/')));
}
private function renderAddPersonDialogue(
ConpherenceThread $conpherence) {
$request = $this->getRequest();
$user = $request->getUser();
$add_person = $request->getStr('add_person');
$form = id(new AphrontFormView())
->setUser($user)
->setFullWidth(true)
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('add_person')
->setUser($user)
->setDatasource(new PhabricatorPeopleDatasource()));
require_celerity_resource('conpherence-update-css');
$view = id(new AphrontDialogView())
->setTitle(pht('Add Participants'))
->addHiddenInput('action', 'add_person')
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->appendForm($form);
if ($request->getExists('minimal_display')) {
$view->addHiddenInput('minimal_display', true);
}
return $view;
}
private function renderRemovePersonDialogue(
ConpherenceThread $conpherence) {
$request = $this->getRequest();
$user = $request->getUser();
$remove_person = $request->getStr('remove_person');
$participants = $conpherence->getParticipants();
if ($conpherence->getIsRoom()) {
$message = pht(
'Are you sure you want to remove yourself from this room?');
} else {
$message = pht(
'Are you sure you want to remove yourself from this thread?');
if (count($participants) == 1) {
$message .= pht(
'The thread will be inaccessible forever and ever.');
} else {
$message .= pht(
'Someone else in the thread can add you back later.');
}
}
$body = phutil_tag(
'p',
array(
),
$message);
require_celerity_resource('conpherence-update-css');
return id(new AphrontDialogView())
->setTitle(pht('Remove Participants'))
->addHiddenInput('action', 'remove_person')
->addHiddenInput('remove_person', $remove_person)
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->addHiddenInput('__continue__', true)
->appendChild($body);
}
private function renderMetadataDialogue(
ConpherenceThread $conpherence,
$error_view) {
$request = $this->getRequest();
$user = $request->getUser();
$form = id(new PHUIFormLayoutView())
->appendChild($error_view)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))
->setName('title')
->setValue($conpherence->getTitle()));
if ($conpherence->getIsRoom()) {
$title = pht('Update Room');
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$form->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('editPolicy')
->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('joinPolicy')
->setPolicyObject($conpherence)
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
->setPolicies($policies));
} else {
$title = pht('Update Thread');
}
require_celerity_resource('conpherence-update-css');
$view = id(new AphrontDialogView())
->setTitle($title)
->addHiddenInput('action', 'metadata')
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->addHiddenInput('__continue__', true)
->appendChild($form);
if ($request->getExists('minimal_display')) {
$view->addHiddenInput('minimal_display', true);
}
if ($request->getExists('force_ajax')) {
$view->addHiddenInput('force_ajax', true);
}
return $view;
}
private function loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id) {
$need_widget_data = false;
$need_transactions = false;
$need_participant_cache = true;
- $need_transactions = true;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
- break;
case ConpherenceUpdateActions::LOAD:
+ $need_transactions = true;
break;
case ConpherenceUpdateActions::MESSAGE:
case ConpherenceUpdateActions::ADD_PERSON:
+ $need_transactions = true;
$need_widget_data = true;
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
case ConpherenceUpdateActions::NOTIFICATIONS:
default:
break;
}
$user = $this->getRequest()->getUser();
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->setAfterTransactionID($latest_transaction_id)
->needParticipantCache($need_participant_cache)
->needWidgetData($need_widget_data)
->needTransactions($need_transactions)
->withIDs(array($conpherence_id))
->executeOne();
$non_update = false;
if ($need_transactions && $conpherence->getTransactions()) {
$data = ConpherenceTransactionView::renderTransactions(
$user,
$conpherence,
!$this->getRequest()->getExists('minimal_display'));
$participant_obj = $conpherence->getParticipant($user->getPHID());
$participant_obj->markUpToDate($conpherence, $data['latest_transaction']);
} else if ($need_transactions) {
$non_update = true;
$data = array();
} else {
$data = array();
}
$rendered_transactions = idx($data, 'transactions');
$new_latest_transaction_id = idx($data, 'latest_transaction_id');
$widget_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$nav_item = null;
$header = null;
$people_widget = null;
$file_widget = null;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$header = $this->buildHeaderPaneContent($conpherence, $policy_objects);
$nav_item = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->renderSingleThread($conpherence);
break;
case ConpherenceUpdateActions::MESSAGE:
$file_widget = id(new ConpherenceFileWidgetView())
->setUser($this->getRequest()->getUser())
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
break;
case ConpherenceUpdateActions::ADD_PERSON:
$people_widget = id(new ConpherencePeopleWidgetView())
->setUser($user)
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
case ConpherenceUpdateActions::NOTIFICATIONS:
default:
break;
}
$people_html = null;
if ($people_widget) {
$people_html = hsprintf('%s', $people_widget->render());
}
$data = $conpherence->getDisplayData($user);
$content = array(
'non_update' => $non_update,
'transactions' => hsprintf('%s', $rendered_transactions),
'conpherence_title' => (string) $data['title'],
'latest_transaction_id' => $new_latest_transaction_id,
'nav_item' => hsprintf('%s', $nav_item),
'conpherence_phid' => $conpherence->getPHID(),
'header' => hsprintf('%s', $header),
'file_widget' => $file_widget ? $file_widget->render() : null,
'people_widget' => $people_html,
);
return $content;
}
}
diff --git a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
index a5cb4c6f73..636504639e 100644
--- a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
+++ b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
@@ -1,186 +1,185 @@
<?php
final class ConpherenceThreadSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Threads');
}
public function getApplicationClassName() {
return 'PhabricatorConpherenceApplication';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter(
'participantPHIDs',
$this->readUsersFromRequest($request, 'participants'));
$saved->setParameter(
'threadType',
$request->getStr('threadType'));
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new ConpherenceThreadQuery())
- ->needTransactions(true)
->needParticipantCache(true);
$participant_phids = $saved->getParameter('participantPHIDs', array());
if ($participant_phids && is_array($participant_phids)) {
$query->withParticipantPHIDs($participant_phids);
}
$thread_type = $saved->getParameter('threadType');
if (idx($this->getTypeOptions(), $thread_type)) {
switch ($thread_type) {
case 'rooms':
$query->withIsRoom(true);
break;
case 'messages':
$query->withIsRoom(false);
break;
case 'both':
$query->withIsRoom(null);
break;
}
}
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved) {
$participant_phids = $saved->getParameter('participantPHIDs', array());
$form
->appendControl(
id(new AphrontFormTokenizerControl())
->setDatasource(new PhabricatorPeopleDatasource())
->setName('participants')
->setLabel(pht('Participants'))
->setValue($participant_phids))
->appendControl(
id(new AphrontFormSelectControl())
->setLabel(pht('Type'))
->setName('threadType')
->setOptions($this->getTypeOptions())
->setValue($saved->getParameter('threadType')));
}
protected function getURI($path) {
return '/conpherence/search/'.$path;
}
protected function getBuiltinQueryNames() {
$names = array();
$names = array(
'all' => pht('All Rooms'),
);
if ($this->requireViewer()->isLoggedIn()) {
$names['participant'] = pht('Joined Rooms');
$names['messages'] = pht('All Messages');
}
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
$query->setParameter('threadType', 'rooms');
return $query;
case 'participant':
$query->setParameter('threadType', 'rooms');
return $query->setParameter(
'participantPHIDs',
array($this->requireViewer()->getPHID()));
case 'messages':
$query->setParameter('threadType', 'messages');
return $query->setParameter(
'participantPHIDs',
array($this->requireViewer()->getPHID()));
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function getRequiredHandlePHIDsForResultList(
array $conpherences,
PhabricatorSavedQuery $query) {
$recent = mpull($conpherences, 'getRecentParticipantPHIDs');
return array_unique(array_mergev($recent));
}
protected function renderResultList(
array $conpherences,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($conpherences, 'ConpherenceThread');
$viewer = $this->requireViewer();
$policy_objects = ConpherenceThread::loadPolicyObjects(
$viewer,
$conpherences);
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($conpherences as $conpherence) {
$created = phabricator_date($conpherence->getDateCreated(), $viewer);
$data = $conpherence->getDisplayData($viewer);
$title = $data['title'];
if ($conpherence->getIsRoom()) {
$icon_name = $conpherence->getPolicyIconName($policy_objects);
} else {
$icon_name = 'fa-envelope-o';
}
$icon = id(new PHUIIconView())
->setIconFont($icon_name);
$item = id(new PHUIObjectItemView())
->setObjectName($conpherence->getMonogram())
->setHeader($title)
->setHref('/conpherence/'.$conpherence->getID().'/')
->setObject($conpherence)
->addIcon('none', $created)
->addIcon(
'none',
pht('Messages: %d', $conpherence->getMessageCount()))
->addAttribute(
array(
$icon,
' ',
pht(
'Last updated %s',
phabricator_datetime($conpherence->getDateModified(), $viewer)),
));
$list->addItem($item);
}
return $list;
}
private function getTypeOptions() {
return array(
'rooms' => pht('Rooms'),
'messages' => pht('Messages'),
'both' => pht('Both'),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 3:09 PM (10 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
165923
Default Alt Text
(34 KB)

Event Timeline