Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15282894
D12232.id29384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D12232.id29384.diff
View Options
diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php
--- a/src/applications/conpherence/query/ConpherenceThreadQuery.php
+++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php
@@ -80,12 +80,20 @@
$table = new ConpherenceThread();
$conn_r = $table->establishConnection('r');
+ // Don't allow queries for messages without specifiying participant
+ // phid as at least the viewer. This is to avoid ineffecient
+ // policy queries.
+ if ($this->isRoom !== true && $this->participantPHIDs === null) {
+ $this->participantPHIDs = array($this->getViewer()->getPHID());
+ }
+
$data = queryfx_all(
$conn_r,
- 'SELECT conpherence_thread.* FROM %T conpherence_thread %Q %Q %Q %Q',
+ 'SELECT conpherence_thread.* FROM %T conpherence_thread %Q %Q %Q %Q %Q',
$table->getTableName(),
$this->buildJoinClause($conn_r),
$this->buildWhereClause($conn_r),
+ $this->buildGroupClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
diff --git a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
--- a/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
+++ b/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
@@ -3,9 +3,7 @@
final class ConpherenceThreadSearchEngine
extends PhabricatorApplicationSearchEngine {
- // For now, we only search for rooms, but write this code so its easy to
- // change that decision later
- private $isRooms = true;
+ private $isRooms;
public function setIsRooms($bool) {
$this->isRooms = $bool;
@@ -13,10 +11,12 @@
}
public function getResultTypeDescription() {
- if ($this->isRooms) {
+ if ($this->isRooms === true) {
$type = pht('Rooms');
+ } else if ($this->rooms === false) {
+ $type = pht('Messages');
} else {
- $type = pht('Threads');
+ $type = pht('Rooms and Messages');
}
return $type;
}
@@ -32,12 +32,15 @@
'participantPHIDs',
$this->readUsersFromRequest($request, 'participants'));
+ $saved->setParameter(
+ 'threadType',
+ $request->getStr('threadType'));
+
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new ConpherenceThreadQuery())
- ->withIsRoom($this->isRooms)
->needParticipantCache(true);
$participant_phids = $saved->getParameter('participantPHIDs', array());
@@ -45,6 +48,24 @@
$query->withParticipantPHIDs($participant_phids);
}
+ $thread_type = $saved->getParameter('threadType');
+ if (idx($this->getTypeOptions(), $thread_type)) {
+ switch ($thread_type) {
+ case 'rooms':
+ $this->setIsRooms(true);
+ $query->withIsRoom(true);
+ break;
+ case 'messages':
+ $this->setIsRooms(false);
+ $query->withIsRoom(false);
+ break;
+ case 'both':
+ $this->setIsRooms(null);
+ $query->withIsRoom(null);
+ break;
+ }
+ }
+
return $query;
}
@@ -60,7 +81,13 @@
->setDatasource(new PhabricatorPeopleDatasource())
->setName('participants')
->setLabel(pht('Participants'))
- ->setValue($participant_phids));
+ ->setValue($participant_phids))
+ ->appendControl(
+ id(new AphrontFormSelectControl())
+ ->setLabel(pht('Type'))
+ ->setName('threadType')
+ ->setOptions($this->getTypeOptions())
+ ->setValue($saved->getParameter('threadType')));
}
protected function getURI($path) {
@@ -70,15 +97,13 @@
protected function getBuiltinQueryNames() {
$names = array();
- if ($this->isRooms) {
- $names = array(
- 'all' => pht('All Rooms'),
- );
+ $names = array(
+ 'all' => pht('All Rooms'),
+ );
- if ($this->requireViewer()->isLoggedIn()) {
- $names['participant'] = pht('Joined Rooms');
- $names['messages'] = pht('All Messages');
- }
+ if ($this->requireViewer()->isLoggedIn()) {
+ $names['participant'] = pht('Joined Rooms');
+ $names['messages'] = pht('All Messages');
}
return $names;
@@ -91,13 +116,18 @@
switch ($query_key) {
case 'all':
+ $this->setIsRooms(true);
+ $query->setParameter('threadType', 'rooms');
return $query;
case 'participant':
+ $this->setIsRooms(true);
+ $query->setParameter('threadType', 'rooms');
return $query->setParameter(
'participantPHIDs',
array($this->requireViewer()->getPHID()));
case 'messages':
$this->setIsRooms(false);
+ $query->setParameter('threadType', 'messages');
return $query->setParameter(
'participantPHIDs',
array($this->requireViewer()->getPHID()));
@@ -122,6 +152,10 @@
$viewer = $this->requireViewer();
+ $policy_objects = ConpherenceThread::loadPolicyObjects(
+ $viewer,
+ $conpherences);
+
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($conpherences as $conpherence) {
@@ -129,6 +163,13 @@
$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)
@@ -140,7 +181,7 @@
pht('Messages: %d', $conpherence->getMessageCount()))
->addAttribute(
array(
- id(new PHUIIconView())->setIconFont('fa-envelope-o', 'green'),
+ $icon,
' ',
pht(
'Last updated %s',
@@ -152,4 +193,12 @@
return $list;
}
+
+ private function getTypeOptions() {
+ return array(
+ 'rooms' => pht('Rooms'),
+ 'messages' => pht('Messages'),
+ 'both' => pht('Both'),);
+ }
+
}
diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php
--- a/src/applications/conpherence/storage/ConpherenceThread.php
+++ b/src/applications/conpherence/storage/ConpherenceThread.php
@@ -277,6 +277,30 @@
}
}
+ public static function loadPolicyObjects(
+ PhabricatorUser $viewer,
+ array $conpherences) {
+
+ assert_instances_of($conpherences, 'ConpherenceThread');
+
+ $grouped = mgroup($conpherences, 'getIsRoom');
+ $rooms = idx($grouped, 1, array());
+
+ $policies = array();
+ foreach ($rooms as $room) {
+ $policies[] = $room->getViewPolicy();
+ }
+ $policy_objects = array();
+ if ($policies) {
+ $policy_objects = id(new PhabricatorPolicyQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($policies)
+ ->execute();
+ }
+
+ return $policy_objects;
+ }
+
public function getPolicyIconName(array $policy_objects) {
assert_instances_of($policy_objects, 'PhabricatorPolicy');
diff --git a/src/applications/conpherence/view/ConpherenceThreadListView.php b/src/applications/conpherence/view/ConpherenceThreadListView.php
--- a/src/applications/conpherence/view/ConpherenceThreadListView.php
+++ b/src/applications/conpherence/view/ConpherenceThreadListView.php
@@ -21,27 +21,18 @@
public function render() {
require_celerity_resource('conpherence-menu-css');
- $grouped = mgroup($this->threads, 'getIsRoom');
- $rooms = idx($grouped, true, array());
-
- $policies = array();
- foreach ($rooms as $room) {
- $policies[] = $room->getViewPolicy();
- }
- $policy_objects = array();
- if ($policies) {
- $policy_objects = id(new PhabricatorPolicyQuery())
- ->setViewer($this->getUser())
- ->withPHIDs($policies)
- ->execute();
- }
-
$menu = id(new PHUIListView())
->addClass('conpherence-menu')
->setID('conpherence-menu');
+ $policy_objects = ConpherenceThread::loadPolicyObjects(
+ $this->getUser(),
+ $this->threads);
+
+ $grouped = mgroup($this->threads, 'getIsRoom');
+ $rooms = idx($grouped, 1, array());
$this->addRoomsToMenu($menu, $rooms, $policy_objects);
- $messages = idx($grouped, false, array());
+ $messages = idx($grouped, 0, array());
$this->addMessagesToMenu($menu, $messages);
return $menu;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 3:23 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223454
Default Alt Text
D12232.id29384.diff (8 KB)
Attached To
Mode
D12232: Conpherence - finish basic application search
Attached
Detach File
Event Timeline
Log In to Comment