aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/group.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-06 01:49:35 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-11-06 01:49:35 +0000
commit45eaa94d22b0237c4a5119645d3a5327545342a3 (patch)
tree70cb48b0131cce3b0d2601f1a5015dcbb35dd328 /engine/lib/group.php
parent436820f2b1de59269f3ebb640df4292bafe832b3 (diff)
downloadelgg-45eaa94d22b0237c4a5119645d3a5327545342a3.tar.gz
elgg-45eaa94d22b0237c4a5119645d3a5327545342a3.tar.bz2
Added search for group, tags, and users.
git-svn-id: http://code.elgg.org/elgg/trunk@3624 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/group.php')
-rw-r--r--engine/lib/group.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/engine/lib/group.php b/engine/lib/group.php
index 9fc937ff3..289e1fc0c 100644
--- a/engine/lib/group.php
+++ b/engine/lib/group.php
@@ -950,4 +950,54 @@ function group_init() {
register_plugin_hook('search','all','search_list_groups_by_name');
}
+
+/**
+ * Return default results for searches on groups.
+ *
+ * @param unknown_type $hook
+ * @param unknown_type $type
+ * @param unknown_type $value
+ * @param unknown_type $params
+ * @return unknown_type
+ */
+function groups_search_hook($hook, $type, $value, $params) {
+ global $CONFIG;
+
+ $query = $params['query'];
+
+ $join = "JOIN {$CONFIG->dbprefix}groups_entity ge ON e.guid = ge.guid";
+ $params['joins'] = array($join);
+
+ $where = "(ge.guid = e.guid
+ AND (ge.name LIKE '%$query%'
+ OR ge.description LIKE '%$query%'
+ )
+ )";
+ $params['wheres'] = array($where);
+
+ $entities = elgg_get_entities($params);
+ $params['count'] = TRUE;
+ $count = elgg_get_entities($params);
+
+ // no need to continue if nothing here.
+ if (!$count) {
+ return array('entities' => array(), 'count' => $count);
+ }
+
+ // add the volatile data for why these entities have been returned.
+ foreach ($entities as $entity) {
+ $description = search_get_relevant_substring($entity->description, $query, '<strong class="searchMatch">', '</strong>');
+ $entity->setVolatileData('search_matched_title', $description);
+
+ $name = search_get_relevant_substring($entity->name, $query, '<strong class="searchMatch">', '</strong>');
+ $entity->setVolatileData('search_matched_description', $name);
+ }
+
+ return array(
+ 'entities' => $entities,
+ 'count' => $count,
+ );
+}
+
register_elgg_event_handler('init','system','group_init');
+register_plugin_hook('search', 'group', 'groups_search_hook');