aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/friends/addcollection.php49
-rw-r--r--actions/friends/deletecollection.php49
-rw-r--r--actions/friends/editcollection.php52
-rw-r--r--engine/lib/users.php59
-rw-r--r--friends/add.php28
-rw-r--r--friends/collections.php28
-rw-r--r--friends/edit.php39
-rw-r--r--languages/en.php28
-rw-r--r--views/default/friends/forms/edit.php75
9 files changed, 404 insertions, 3 deletions
diff --git a/actions/friends/addcollection.php b/actions/friends/addcollection.php
new file mode 100644
index 000000000..64ee89fe8
--- /dev/null
+++ b/actions/friends/addcollection.php
@@ -0,0 +1,49 @@
+<?php
+
+ /**
+ * Elgg collection add page
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ //must be logged in
+ gatekeeper();
+
+ $collection_name = get_input('collection_name');
+ $friends = get_input('friends_collection');
+
+ //first check to make sure that a collection name has been set and create the new colection
+ if($collection_name){
+
+ //create the collection
+ $create_collection = create_access_collection($collection_name, $_SESSION['user']->getGUID());
+
+ //if the collection was created and the user passed some friends from the form, add them
+ if($create_collection && (!empty($friends))){
+
+ //add friends to the collection
+ foreach($friends as $friend){
+ add_user_to_access_collection($friend, $create_collection);
+ }
+
+ }
+
+ // Success message
+ system_message(elgg_echo("friends:collectionadded"));
+ // Forward to the collections page
+ forward("pg/collections/" . $_SESSION['user']->username);
+
+ } else {
+
+ register_error(elgg_echo("friends:nocollectionname"));
+ // Forward to the add collection page
+ forward("pg/collections/add");
+
+ }
+
+?> \ No newline at end of file
diff --git a/actions/friends/deletecollection.php b/actions/friends/deletecollection.php
new file mode 100644
index 000000000..3d389e6c2
--- /dev/null
+++ b/actions/friends/deletecollection.php
@@ -0,0 +1,49 @@
+<?php
+
+ /**
+ * Elgg friends: delete collection action
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Make sure we're logged in (send us to the front page if not)
+ gatekeeper();
+
+ // Get input data
+ $collection_id = (int) get_input('collection');
+
+ // Check to see that the access collection exist and grab its owner
+ $get_collection = get_access_collection($collection_id);
+
+ if($get_collection){
+
+ if(array_pop($get_collection)->owner_guid == $_SESSION['user']->getGUID()){
+
+ $delete_collection = delete_access_collection($collection_id);
+
+ // Success message
+ system_message(elgg_echo("friends:collectiondeleted"));
+
+ } else {
+
+ // Failure message
+ system_message(elgg_echo("friends:collectiondeletefailed"));
+
+ }
+
+ } else {
+
+ // Failure message
+ system_message(elgg_echo("friends:collectiondeletefailed"));
+
+ }
+
+ // Forward to the collections page
+ forward("pg/collections/" . $_SESSION['user']->username);
+
+?> \ No newline at end of file
diff --git a/actions/friends/editcollection.php b/actions/friends/editcollection.php
new file mode 100644
index 000000000..f8458da46
--- /dev/null
+++ b/actions/friends/editcollection.php
@@ -0,0 +1,52 @@
+<?php
+
+ /**
+ * Elgg collection add page
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ //must be logged in
+ gatekeeper();
+
+ $collection_id = get_input('collection_id');
+ $collection_name = get_input('collection_name');
+
+ //$friends = get_input('friends_collection');
+
+ //chech the colelction exists and the current user owners it
+ if($full_collection = get_access_collection($collection_id)){
+
+ //first check to make sure that a collection name has been set and create the new colection
+ if($collection_name){
+
+ //create the collection
+ $create_collection = create_access_collection($collection_name, $_SESSION['user']->getGUID());
+
+
+ // Success message
+ system_message(elgg_echo("friends:collectionadded"));
+ // Forward to the collections page
+ forward("pg/collections/" . $_SESSION['user']->username);
+
+ } else {
+
+ register_error(elgg_echo("friends:nocollectionname"));
+
+ }
+
+ } else {
+
+ register_error(elgg_echo("friends:nocollectionname"));
+
+ }
+
+ // Forward to the add collection page
+ forward("pg/collections/add");
+
+?> \ No newline at end of file
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 4514931a7..8a427f0f2 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -915,6 +915,16 @@
}
/**
+ * Adds collection submenu items
+ *
+ */
+ function collections_submenu_items() {
+ global $CONFIG;
+ add_submenu_item(elgg_echo('friends:collections'), $CONFIG->wwwroot . "pg/collections/" . $_SESSION['user']->username);
+ add_submenu_item(elgg_echo('friends:collections:add'),$CONFIG->wwwroot."pg/collections/add");
+ }
+
+ /**
* Page handler for friends
*
*/
@@ -923,6 +933,9 @@
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
set_page_owner($user->getGUID());
}
+ if ($_SESSION['guid'] == page_owner()) {
+ collections_submenu_items();
+ }
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/index.php");
}
@@ -936,9 +949,36 @@
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
set_page_owner($user->getGUID());
}
+ if ($_SESSION['guid'] == page_owner()) {
+ collections_submenu_items();
+ }
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/of.php");
}
+
+ /**
+ * Page handler for friends of
+ *
+ */
+ function collections_page_handler($page_elements) {
+
+ if (isset($page_elements[0])) {
+ if ($page_elements[0] == "add") {
+ set_page_owner($_SESSION['guid']);
+ collections_submenu_items();
+ require_once(dirname(dirname(dirname(__FILE__))) . "/friends/add.php");
+ } else {
+ if ($user = get_user_by_username($page_elements[0])) {
+ set_page_owner($user->getGUID());
+ if ($_SESSION['guid'] == page_owner()) {
+ collections_submenu_items();
+ }
+ require_once(dirname(dirname(dirname(__FILE__))) . "/friends/collections.php");
+ }
+ }
+ }
+
+ }
/**
* Sets the last action time of the given user to right now.
@@ -960,13 +1000,29 @@
*/
function users_init() {
+ // Set up menu for logged in users
+ if (isloggedin())
+ add_menu(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . $_SESSION['user']->username);
+
+ //add submenu options
+ if (get_context() == "friends" ||
+ get_context() == "friendsof" ||
+ get_context() == "collections") {
+ add_submenu_item(elgg_echo('friends'),$CONFIG->wwwroot."pg/friends/" . page_owner_entity()->username);
+ add_submenu_item(elgg_echo('friends:of'),$CONFIG->wwwroot."pg/friendsof/" . page_owner_entity()->username);
+ }
+
register_page_handler('friends','friends_page_handler');
register_page_handler('friendsof','friends_of_page_handler');
+ register_page_handler('collections','collections_page_handler');
register_action("register",true);
register_action("useradd",true);
register_action("friends/add");
register_action("friends/remove");
- register_action("email/confirm");
+ register_action("email/confirm");
+ register_action('friends/addcollection');
+ register_action('friends/deletecollection');
+ register_action('friends/editcollection');
register_action("usersettings/save");
@@ -986,6 +1042,7 @@
extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1);
//register_action("user/language");
+
register_plugin_hook('usersettings:save','user','users_settings_save');
register_plugin_hook('search','all','search_list_users_by_name');
diff --git a/friends/add.php b/friends/add.php
new file mode 100644
index 000000000..93dab025e
--- /dev/null
+++ b/friends/add.php
@@ -0,0 +1,28 @@
+<?php
+
+ /**
+ * Elgg add a collection of friends
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Start engine
+ require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+
+ // You need to be logged in for this one
+ gatekeeper();
+
+ $area2 = elgg_view('friends/forms/edit', array('friends' => get_user_friends($_SESSION['user']->getGUID(),"",9999)));
+
+ // Format page
+ $body = elgg_view_layout('two_column_left_sidebar','', elgg_view_title(elgg_echo('friends:collections:add')) . $area2);
+
+ // Draw it
+ echo page_draw(elgg_echo('friends:collections:add'),$body);
+
+?> \ No newline at end of file
diff --git a/friends/collections.php b/friends/collections.php
new file mode 100644
index 000000000..0467a6b42
--- /dev/null
+++ b/friends/collections.php
@@ -0,0 +1,28 @@
+<?php
+
+ /**
+ * Elgg collections of friends
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Start engine
+ require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+
+ // You need to be logged in for this one
+ gatekeeper();
+
+ $area2 = elgg_view_access_collections($_SESSION['user']->getGUID());
+
+ // Format page
+ $body = elgg_view_layout('two_column_left_sidebar', '', elgg_view_title(elgg_echo('friends:collections')) . $area2);
+
+ // Draw it
+ echo page_draw(elgg_echo('friends:collections'),$body);
+
+?> \ No newline at end of file
diff --git a/friends/edit.php b/friends/edit.php
new file mode 100644
index 000000000..48840849d
--- /dev/null
+++ b/friends/edit.php
@@ -0,0 +1,39 @@
+<?php
+
+ /**
+ * Elgg add a collection of friends
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Start engine
+ require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+
+ // You need to be logged in for this one
+ gatekeeper();
+
+ //set the title
+ $area1 = elgg_view_title(elgg_echo('friends:collectionedit'), false);
+
+ //grab the collection id passed to the edit form
+ $collection_id = get_input('collection');
+
+ //get the full collection
+ $collection = get_access_collection($collection_id);
+ //get all members of the collection
+ $collection_members = get_members_of_access_collection($collection_id);
+
+ $area2 = elgg_view('friends/forms/edit', array('collection' => $collection, 'collection_members' => $collection_members));
+
+ // Format page
+ $body = elgg_view_layout('two_column_left_sidebar',$area1. $area2);
+
+ // Draw it
+ echo page_draw(elgg_echo('friends:add'),$body);
+
+?> \ No newline at end of file
diff --git a/languages/en.php b/languages/en.php
index fa0c3981d..b323b6a89 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -203,12 +203,36 @@
'friends:of' => "Friends of",
'friends:of:owned' => "People who have made %s a friend",
+ 'friends:num_display' => "Number of friends to display",
+ 'friends:icon_size' => "Icon size",
+ 'friends:tiny' => "tiny",
+ 'friends:small' => "small",
+ 'friends' => "Friends",
+ 'friends:of' => "Friends of",
+ 'friends:collections' => "Collections of friends",
+ 'friends:collections:add' => "New friends collection",
+ 'friends:addfriends' => "Add friends",
+ 'friends:collectionname' => "Collection name",
+ 'friends:collectionfriends' => "Friends in collection",
+ 'friends:collectionedit' => "Edit this collection",
+ 'friends:nocollections' => "You do not yet have any collections.",
+ 'friends:collectiondeleted' => "That collection has been deleted.",
+ 'friends:collectiondeletefailed' => "We were unable to delete that collection, either you don't have permission, or some other problem has occurred.",
+ 'friends:collectionadded' => "Your collection was successful created",
+ 'friends:nocollectionname' => "You need to give your collection a name before it can be created.",
+
+ 'friends:river:created' => "%s added the friends widget.",
+ 'friends:river:updated' => "%s updated their friends widget.",
+ 'friends:river:delete' => "%s removed their friends widget.",
+ 'friends:river:add' => "%s add someone as a friend.",
+
+
/**
* River
*/
- 'river' => "River",
-
+ 'river' => "River",
'river:relationship:friend' => 'is now friends with',
+
/**
* Plugins
*/
diff --git a/views/default/friends/forms/edit.php b/views/default/friends/forms/edit.php
new file mode 100644
index 000000000..6ed58d5bf
--- /dev/null
+++ b/views/default/friends/forms/edit.php
@@ -0,0 +1,75 @@
+<?php
+
+ /**
+ * Elgg friend collections add/edit
+ *
+ * @package ElggFriends
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Dave Tosh <dave@elgg.com>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ *
+ * @uses $vars['object'] Optionally, the collection edit
+ */
+
+ // var_export($vars['collection'][0]->id);
+
+ // Set title, form destination
+ if (isset($vars['collection'])) {
+ $action = "friends/editcollection";
+ $title = $vars['collection'][0]->name;
+ } else {
+ $action = "friends/addcollection";
+ $title = "";
+ }
+
+?>
+
+ <form action="<?php echo $vars['url']; ?>action/<?php echo $action; ?>" method="post">
+ <p>
+ <label><?php echo elgg_echo("friends:collectionname"); ?><br />
+ <?php
+
+ echo elgg_view("input/text", array(
+ "internalname" => "collection_name",
+ "value" => $title,
+ ));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <?php
+ if($vars['collection_members']){
+ echo elgg_echo("friends:collectionfriends") . "<br />";
+ foreach($vars['collection_members'] as $mem){
+
+ echo elgg_view("profile/icon",array('entity' => $mem, 'size' => 'tiny'));
+ echo $mem->name;
+
+ }
+ }
+ ?>
+ </p>
+ <p>
+ <label><?php echo elgg_echo("friends:addfriends"); ?><br />
+ <?php
+
+ //echo elgg_view('friends/friendslist');
+ echo elgg_view('friends/picker',array('entities' => $vars['friends'], 'internalname' => 'friends_collection'));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <?php
+
+ if (isset($vars['collection'])) {
+ ?><input type="hidden" name="collection_id" value="<?php echo $vars['collection'][0]->id; ?>" /><?php
+ }
+
+ ?>
+ <input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" />
+ </p>
+
+ </form> \ No newline at end of file