From 7e8a3d71ca771f077edea92e3e73685d30ca7aba Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 31 Jul 2008 14:05:54 +0000 Subject: Friends collections are now fully part of the main core git-svn-id: https://code.elgg.org/elgg/trunk@1630 36083f99-b078-4883-b0ff-0f9b5a30f544 --- actions/friends/addcollection.php | 49 +++++++++++++++++++++++ actions/friends/deletecollection.php | 49 +++++++++++++++++++++++ actions/friends/editcollection.php | 52 +++++++++++++++++++++++++ engine/lib/users.php | 59 +++++++++++++++++++++++++++- friends/add.php | 28 ++++++++++++++ friends/collections.php | 28 ++++++++++++++ friends/edit.php | 39 +++++++++++++++++++ languages/en.php | 28 +++++++++++++- views/default/friends/forms/edit.php | 75 ++++++++++++++++++++++++++++++++++++ 9 files changed, 404 insertions(+), 3 deletions(-) create mode 100644 actions/friends/addcollection.php create mode 100644 actions/friends/deletecollection.php create mode 100644 actions/friends/editcollection.php create mode 100644 friends/add.php create mode 100644 friends/collections.php create mode 100644 friends/edit.php create mode 100644 views/default/friends/forms/edit.php 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 @@ +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 @@ +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 @@ +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 @@ -914,6 +914,16 @@ return $user->getGUID(); } + /** + * 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 @@ + 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 @@ +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 @@ + $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 @@ + + * @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 = ""; + } + +?> + +
+

+ +

+

+ "; + foreach($vars['collection_members'] as $mem){ + + echo elgg_view("profile/icon",array('entity' => $mem, 'size' => 'tiny')); + echo $mem->name; + + } + } + ?> +

+

+ +

+

+ + +

+ +
\ No newline at end of file -- cgit v1.2.3