diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-16 21:01:42 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-16 21:01:42 -0300 |
commit | 5f6dc365a8445a48156b45912827eac39fd64fc5 (patch) | |
tree | 0dc3326151072bb5d97592513e1af4b40be32e07 /views/default/subgroups | |
download | elgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.gz elgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.bz2 |
Squashed 'mod/subgroups/' content from commit 835015b
git-subtree-dir: mod/subgroups
git-subtree-split: 835015b66b9de6dc6de91ab39f95e1f09b2dbf84
Diffstat (limited to 'views/default/subgroups')
-rw-r--r-- | views/default/subgroups/group_module.php | 51 | ||||
-rw-r--r-- | views/default/subgroups/groups_i_can_edit.php | 71 | ||||
-rw-r--r-- | views/default/subgroups/subgroups_icons.php | 11 |
3 files changed, 133 insertions, 0 deletions
diff --git a/views/default/subgroups/group_module.php b/views/default/subgroups/group_module.php new file mode 100644 index 000000000..083e50b16 --- /dev/null +++ b/views/default/subgroups/group_module.php @@ -0,0 +1,51 @@ +<?php +/** + * List subgroups on group profile page + * + * @package ElggSubgroups + */ + +$group = elgg_get_page_owner_entity(); + +if ($group->subgroups_enable != "yes") { + return true; +} + +$all_link = elgg_view('output/url', array( + 'href' => "subgroups/owner/$group->guid/all", + 'text' => elgg_echo('link:view:all'), + 'is_trusted' => true, +)); + +$options = array( + 'type' => 'group', + 'container_guid' => $group->guid, + 'type' => 'group', + 'limit' => 6, + 'full_view' => false, + 'pagination' => false, +); + +elgg_push_context('widgets'); +$content = elgg_list_entities($options); +elgg_pop_context(); + +if (!$content) { + $content = '<p>' . elgg_echo('subgroups:none') . '</p>'; +} +if($group->canEdit()) { + $new_link = elgg_view('output/url', array( + 'href' => "subgroups/add/$group->guid", + 'text' => elgg_echo('subgroups:add'), + 'is_trusted' => true, + )); +} else { + $new_link = false; +} + +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('subgroups:group'), + 'content' => $content, + 'all_link' => $all_link, + 'add_link' => $new_link, +)); 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 @@ +<?php + +if (!elgg_is_logged_in()) { + exit(); +} + +$q = sanitise_string(get_input('term')); + +// replace mysql vars with escaped strings +$q = str_replace(array('_', '%'), array('\_', '\%'), $q); + +$user_guid = elgg_get_logged_in_user_guid(); +$entities = elgg_get_entities(array( + 'type' => '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; diff --git a/views/default/subgroups/subgroups_icons.php b/views/default/subgroups/subgroups_icons.php new file mode 100644 index 000000000..dfd5b29fa --- /dev/null +++ b/views/default/subgroups/subgroups_icons.php @@ -0,0 +1,11 @@ +<?php +elgg_load_library('elgg:subgroups'); + +$subgroups = get_subgroups($vars['entity']); +foreach ($subgroups as $subgroup) { + echo elgg_view('icon/default', array( + 'entity' => $subgroup, + 'size' => 'tiny' + )); + echo " "; +} |