From 5f6dc365a8445a48156b45912827eac39fd64fc5 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 16 Mar 2014 21:01:42 -0300 Subject: Squashed 'mod/subgroups/' content from commit 835015b git-subtree-dir: mod/subgroups git-subtree-split: 835015b66b9de6dc6de91ab39f95e1f09b2dbf84 --- views/default/subgroups/groups_i_can_edit.php | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 views/default/subgroups/groups_i_can_edit.php (limited to 'views/default/subgroups/groups_i_can_edit.php') diff --git a/views/default/subgroups/groups_i_can_edit.php b/views/default/subgroups/groups_i_can_edit.php new file mode 100644 index 000000000..45b0c9e6e --- /dev/null +++ b/views/default/subgroups/groups_i_can_edit.php @@ -0,0 +1,71 @@ + 'group', + 'owner_guid' => $user_guid, + 'limit' => 0, +)); +$entities = array_merge( + $entities, + elgg_get_entities_from_relationship(array( + 'type' => 'group', + 'relationship' => 'operator', + 'relationship_guid' => $user_guid, + 'limit' => 0, + )) +); + +$all_entities = array(); +while (!empty($entities)) { + $entity = array_pop($entities); + $childs = elgg_get_entities(array( + 'type' => 'group', + 'container_guid' => $entity->guid, + )); + foreach ($childs as $child) { + array_push($entities, $child); + } + $all_entities[] = $entity; +} + +$results = array(); +foreach ($all_entities as $entity) { + + if (!preg_match("/^{$q}/i", $entity->name)) { + continue; + } + + $output = elgg_view_list_item($entity, array( + 'use_hover' => false, + 'class' => 'elgg-autocomplete-item', + )); + + $icon = elgg_view_entity_icon($entity, 'tiny', array( + 'use_hover' => false, + )); + $results[$entity->name . $entity->guid] = array( + 'type' => 'group', + 'name' => $entity->name, + 'desc' => strip_tags($entity->description), + 'guid' => $entity->guid, + 'label' => $output, + 'value' => $entity->guid, + 'icon' => $icon, + 'url' => $entity->getURL(), + ); +} + +ksort($results); +header("Content-Type: application/json"); +echo json_encode(array_values($results)); +exit; -- cgit v1.2.3