diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/members/languages/en.php | 16 | ||||
-rw-r--r-- | mod/members/manifest.xml | 17 | ||||
-rw-r--r-- | mod/members/pages/members/index.php | 37 | ||||
-rw-r--r-- | mod/members/pages/members/search.php | 44 | ||||
-rw-r--r-- | mod/members/start.php | 39 | ||||
-rw-r--r-- | mod/members/views/default/members/nav.php | 24 | ||||
-rw-r--r-- | mod/members/views/default/members/sidebar.php | 25 |
7 files changed, 202 insertions, 0 deletions
diff --git a/mod/members/languages/en.php b/mod/members/languages/en.php new file mode 100644 index 000000000..73783143e --- /dev/null +++ b/mod/members/languages/en.php @@ -0,0 +1,16 @@ +<?php +/** + * Members English language file + */ + +$english = array( + 'members:label:newest' => 'Newest', + 'members:label:popular' => 'Popular', + 'members:label:online' => 'Online', + 'members:searchname' => 'Search members by name', + 'members:searchtag' => 'Search members by tag', + 'members:title:searchname' => 'Member search for %s', + 'members:title:searchtag' => 'Members tagged with %s', +); + +add_translation('en', $english); diff --git a/mod/members/manifest.xml b/mod/members/manifest.xml new file mode 100644 index 000000000..b96684198 --- /dev/null +++ b/mod/members/manifest.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Members</name> + <author>Core developers</author> + <version>1.8</version> + <category>bundled</category> + <description>Lists the members of your site</description> + <website>http://www.elgg.org/</website> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU Public License version 2</license> + <requires> + <type>elgg_version</type> + <version>2010030101</version> + </requires> + <activate_on_install>true</activate_on_install> + <admin_interface>advanced</admin_interface> +</plugin_manifest>
\ No newline at end of file diff --git a/mod/members/pages/members/index.php b/mod/members/pages/members/index.php new file mode 100644 index 000000000..4f23c6322 --- /dev/null +++ b/mod/members/pages/members/index.php @@ -0,0 +1,37 @@ +<?php +/** + * Members index + * + */ + +$num_members = get_number_users(); + +$title = elgg_echo('members'); + +$options = array('type' => 'user', 'full_view' => false); +switch ($vars['page']) { + case 'popular': + $options['relationship'] = 'friend'; + $options['inverse_relationship'] = false; + $content = elgg_list_entities_from_relationship_count($options); + break; + case 'online': + $content = get_online_users(); + break; + case 'newest': + default: + $content = elgg_list_entities($options); + break; +} + +$params = array( + 'content' => $content, + 'sidebar' => elgg_view('members/sidebar'), + 'title' => $title . " ($num_members)", + 'buttons' => '', + 'filter_override' => elgg_view('members/nav', array('selected' => $vars['page'])), +); + +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/mod/members/pages/members/search.php b/mod/members/pages/members/search.php new file mode 100644 index 000000000..39b54990e --- /dev/null +++ b/mod/members/pages/members/search.php @@ -0,0 +1,44 @@ +<?php +/** + * Members search page + * + */ + +if ($vars['search_type'] == 'tag') { + $tag = get_input('tag'); + + $title = elgg_echo('members:title:searchtag', array($tag)); + + $options = array(); + $options['query'] = $tag; + $options['type'] = "user"; + $options['offset'] = $offset; + $options['limit'] = $limit; + $results = elgg_trigger_plugin_hook('search', 'tags', $options, array()); + $count = $results['count']; + $users = $results['entities']; + $content = elgg_view_entity_list($users, $count, $offset, $limit, false, false, true); +} else { + $name = get_input('name'); + + $title = elgg_echo('members:title:searchname', array($name)); + + global $CONFIG; + $params = array( + 'type' => 'user', + 'full_view' => false, + 'joins' => array("join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid"), + 'wheres' => array("(u.name like \"%{$name}%\" or u.username like \"%{$name}%\")"), + ); + $content .= elgg_list_entities($params); +} + +$params = array( + 'title' => $title, + 'content' => $content, + 'sidebar' => elgg_view('members/sidebar'), +); + +$body = elgg_view_layout('one_sidebar', $params); + +echo elgg_view_page($title, $body); diff --git a/mod/members/start.php b/mod/members/start.php new file mode 100644 index 000000000..2c1793c17 --- /dev/null +++ b/mod/members/start.php @@ -0,0 +1,39 @@ +<?php +/** + * Members plugin intialization + */ + +elgg_register_event_handler('init', 'system', 'members_init'); + +/** + * Initialize page handler and site menu item + */ +function members_init() { + elgg_register_page_handler('members', 'members_page_handler'); + + $item = new ElggMenuItem('members', elgg_echo('members'), 'members'); + elgg_register_menu_item('site', $item); +} + +/** + * Members page handler + * + * @param array $page url segments + */ +function members_page_handler($page) { + $base = elgg_get_plugins_path() . 'members/pages/members'; + + if (!isset($page[0])) { + $page[0] = 'newest'; + } + + $vars = array(); + $vars['page'] = $page[0]; + + if ($page[0] == 'search') { + $vars['search_type'] = $page[1]; + require_once "$base/search.php"; + } else { + require_once "$base/index.php"; + } +} diff --git a/mod/members/views/default/members/nav.php b/mod/members/views/default/members/nav.php new file mode 100644 index 000000000..510d1849b --- /dev/null +++ b/mod/members/views/default/members/nav.php @@ -0,0 +1,24 @@ +<?php +/** + * Members navigation + */ + +$tabs = array( + 'newest' => array( + 'title' => elgg_echo('members:label:newest'), + 'url' => "members/newest", + 'selected' => $vars['selected'] == 'newest', + ), + 'popular' => array( + 'title' => elgg_echo('members:label:popular'), + 'url' => "members/popular", + 'selected' => $vars['selected'] == 'popular', + ), + 'online' => array( + 'title' => elgg_echo('members:label:online'), + 'url' => "members/online", + 'selected' => $vars['selected'] == 'online', + ), +); + +echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/members/views/default/members/sidebar.php b/mod/members/views/default/members/sidebar.php new file mode 100644 index 000000000..8fa0fe02b --- /dev/null +++ b/mod/members/views/default/members/sidebar.php @@ -0,0 +1,25 @@ +<?php +/** + * Members sidebar + */ + +// Tag search +$params = array( + 'method' => 'get', + 'action' => elgg_get_site_url() . 'members/search/tag', + 'disable_security' => true, +); + +$body = elgg_view_form('members/tag_search', $params); + +echo elgg_view_module('aside', elgg_echo('members:searchtag'), $body); + +// name search +$params = array( + 'method' => 'get', + 'action' => elgg_get_site_url() . 'members/search/name', + 'disable_security' => true, +); +$body = elgg_view_form('members/name_search', $params); + +echo elgg_view_module('aside', elgg_echo('members:searchname'), $body);
\ No newline at end of file |