aboutsummaryrefslogtreecommitdiff
path: root/mod/members
diff options
context:
space:
mode:
Diffstat (limited to 'mod/members')
-rw-r--r--mod/members/languages/en.php16
-rw-r--r--mod/members/manifest.xml16
-rw-r--r--mod/members/pages/members/index.php36
-rw-r--r--mod/members/pages/members/search.php51
-rw-r--r--mod/members/start.php41
-rw-r--r--mod/members/views/default/members/nav.php24
-rw-r--r--mod/members/views/default/members/sidebar.php25
7 files changed, 209 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..8b18c9f91
--- /dev/null
+++ b/mod/members/manifest.xml
@@ -0,0 +1,16 @@
+<?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 General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <activate_on_install>true</activate_on_install>
+</plugin_manifest>
diff --git a/mod/members/pages/members/index.php b/mod/members/pages/members/index.php
new file mode 100644
index 000000000..330ef66bf
--- /dev/null
+++ b/mod/members/pages/members/index.php
@@ -0,0 +1,36 @@
+<?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)",
+ '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..1f0444d67
--- /dev/null
+++ b/mod/members/pages/members/search.php
@@ -0,0 +1,51 @@
+<?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, array(
+ 'count' => $count,
+ 'offset' => $offset,
+ 'limit' => $limit,
+ 'full_view' => false,
+ 'list_type_toggle' => false,
+ 'pagination' => true,
+ ));
+} else {
+ $name = sanitize_string(get_input('name'));
+
+ $title = elgg_echo('members:title:searchname', array($name));
+
+ $db_prefix = elgg_get_config('dbprefix');
+ $params = array(
+ 'type' => 'user',
+ 'full_view' => false,
+ 'joins' => array("JOIN {$db_prefix}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..54787cd16
--- /dev/null
+++ b/mod/members/start.php
@@ -0,0 +1,41 @@
+<?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
+ * @return bool
+ */
+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";
+ }
+ return true;
+}
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