aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-24 15:48:42 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-24 15:48:42 +0000
commit2b74ad2a779fc787644eb42ac4c0d072e3ae2c46 (patch)
tree36ba49eed80b6a9a96bf9562b249a10758597f45
parentbcbdc8a7eda9a36166075ea7a07c99fadcab2b81 (diff)
downloadelgg-2b74ad2a779fc787644eb42ac4c0d072e3ae2c46.tar.gz
elgg-2b74ad2a779fc787644eb42ac4c0d072e3ae2c46.tar.bz2
Introducing the (still issue-packed) friend picker.
git-svn-id: https://code.elgg.org/elgg/trunk@1511 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/access.php20
-rw-r--r--engine/lib/relationships.php2
-rw-r--r--engine/schema/mysql.sql4
-rw-r--r--languages/en.php2
-rw-r--r--views/default/friends/collection.php45
-rw-r--r--views/default/friends/collections.php59
-rw-r--r--views/default/friends/picker.php144
7 files changed, 272 insertions, 4 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 8600fc719..64d982e30 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -326,6 +326,26 @@
}
+ /**
+ * Displays a user's access collections, using the friends/collections view
+ *
+ * @param int $owner_guid The GUID of the owning user
+ * @return string A formatted rendition of the collections
+ */
+ function elgg_view_access_collections($owner_guid) {
+
+ if ($collections = get_user_access_collections($owner_guid)) {
+
+ foreach($collections as $key => $collection) {
+ $collections[$key]->entities = get_members_of_access_collection($collection->id);
+ }
+
+ }
+
+ return elgg_view('friends/collections',array('collections' => $collections));
+
+ }
+
/**
* Some useful constant definitions
*/
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index e3f2c2085..142861a97 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -480,7 +480,7 @@
if ($owner_guid != "")
$where[] = "e.container_guid='$owner_guid'";
if ($site_guid > 0)
- $where[] = "e.container_guid = {$site_guid}";
+ $where[] = "e.site_guid = {$site_guid}";
// Select what we're joining based on the options
$joinon = "e.guid = r.guid_one";
diff --git a/engine/schema/mysql.sql b/engine/schema/mysql.sql
index b223984db..38fc60095 100644
--- a/engine/schema/mysql.sql
+++ b/engine/schema/mysql.sql
@@ -74,14 +74,12 @@ CREATE TABLE `prefix_entity_relationships` (
-- Table structure for table `access_collections`
CREATE TABLE `prefix_access_collections` (
`id` int(11) NOT NULL auto_increment,
- `name` varchar(16) NOT NULL,
+ `name` text NOT NULL,
`owner_guid` bigint(20) unsigned NOT NULL,
`site_guid` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
- KEY `name` (`name`)
) AUTO_INCREMENT=3;
-
-- Access containers
CREATE TABLE `prefix_access_collection_membership` (
`user_guid` int(11) NOT NULL,
diff --git a/languages/en.php b/languages/en.php
index 1dc3858cc..e7fe65c51 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -195,6 +195,8 @@
'friends:none' => "This user hasn't added anyone as a friend yet.",
'friends:none:you' => "You haven't added anyone as a friend! Search for your interests to begin finding people to follow.",
+ 'friends:none:found' => "No friends were found.",
+
'friends:of:none' => "Nobody has added this user as a friend yet.",
'friends:of:none:you' => "Nobody has added you as a friend yet. Start adding content and fill in your profile to let people find you!",
diff --git a/views/default/friends/collection.php b/views/default/friends/collection.php
new file mode 100644
index 000000000..4d08e5b06
--- /dev/null
+++ b/views/default/friends/collection.php
@@ -0,0 +1,45 @@
+<?php
+
+ /**
+ * Elgg friends collection
+ * Lists one of a user's friends collections
+ *
+ * @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/
+ *
+ * @see collections.php
+ *
+ * @uses $vars['collection'] The individual friends collection
+ */
+
+ $coll = $vars['collection'];
+
+ if (is_array($vars['collection']->entities)) {
+ $count = sizeof($vars['collection']->entities);
+ } else {
+ $count = 0;
+ }
+
+ echo "<li><h2>";
+
+ //as collections are private, check that the logged in user is the owner
+ if($coll->owner_guid == $_SESSION['user']->getGUID())
+ echo "<div class=\"friends_collections_controls\"> (<a href=\"" . $vars['url'] . "mod/friends/edit.php?collection={$coll->id}\">" . elgg_echo('edit') . "</a>) (<a href=\"" . $vars['url'] . "action/friends/deletecollection?collection={$coll->id}\">" . elgg_echo('delete') . "</a>)";
+
+ echo "</div>";
+ echo $coll->name;
+ echo " ({$count}) </h2>";
+
+ // Ben - this is where the friends picker view needs to go
+ if($members = $vars['collection']->entities){
+ echo elgg_view('friends/picker',array('entities' => $members));
+ }
+
+ // close friends_picker div and the accordian list item
+ echo "</li>";
+
+?> \ No newline at end of file
diff --git a/views/default/friends/collections.php b/views/default/friends/collections.php
new file mode 100644
index 000000000..a98e80c3a
--- /dev/null
+++ b/views/default/friends/collections.php
@@ -0,0 +1,59 @@
+<?php
+
+ /**
+ * Elgg friends collections
+ * Lists a user's friends collections
+ *
+ * @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/
+ *
+ * @uses $vars['collections'] The array of friends collections
+ */
+
+ if (is_array($vars['collections']) && sizeof($vars['collections'])) {
+
+ echo "<div class=\"expandall\"><p>expand all</p></div>";
+ echo "<ul id=\"friends_collections_accordian\">";
+
+ foreach($vars['collections'] as $collection) {
+
+ echo elgg_view('friends/collection',array('collection' => $collection));
+
+ }
+
+ echo "</ul>";
+
+ } else {
+
+ echo elgg_echo("friends:nocollections");
+
+ }
+
+?>
+
+<script>
+$(document).ready(function(){
+
+$('#friends_collections_accordian h2').click(function () {
+ $(this.parentNode).children("[class=friends_picker]").slideToggle("fast");
+ return false;
+});
+
+// global more info expand all/close all
+$('div.expandall p').click(function () {
+ if (this.innerHTML == 'close all') {
+ $('div.friends_picker').slideUp("fast");
+ $('div.expandall p').html('expand all');
+}
+else {
+ $('div.friends_picker:hidden').slideDown("fast");
+ $('div.expandall p').html('close all');
+ }
+});
+
+});
+</script> \ No newline at end of file
diff --git a/views/default/friends/picker.php b/views/default/friends/picker.php
new file mode 100644
index 000000000..d821aa268
--- /dev/null
+++ b/views/default/friends/picker.php
@@ -0,0 +1,144 @@
+<?php
+
+ /**
+ * Elgg friends picker
+ * Lists the friends picker
+ *
+ * @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/
+ *
+ * @uses $vars['entities'] The array of ElggUser objects
+ */
+
+ // Initialise internalname
+ if (!isset($vars['internalname'])) {
+ $internalname = "friend";
+ } else {
+ $internalname = $vars['internalname'];
+ }
+
+ // We need to count the number of friends pickers on the page.
+ static $friendspicker;
+ if (!isset($friendspicker)) $friendspicker = 0;
+ $friendspicker++;
+
+ $users = array();
+
+ // Sort users by letter
+ if (is_array($vars['entities']) && sizeof($vars['entities']))
+ foreach($vars['entities'] as $user) {
+
+ $letter = strtoupper(substr($user->name,0,1));
+ if ($letter >= "0" && $letter <= "9") {
+ $letter = "0";
+ }
+ if (!isset($users[$letter])) {
+ $users[$letter] = array();
+ }
+ $users[$letter][$user->name] = $user;
+
+ }
+
+?>
+
+<div class="friends_picker">
+ <div id="friendsPicker<?php echo $friendspicker; ?>">
+ <div class="friendsPicker_container">
+<?php
+
+ // Initialise letters
+ $letter = 'A';
+ while (1 == 1) {
+?>
+ <div class="panel" title="<?php echo $letter; ?>">
+ <div class="wrapper">
+ <h3><?php echo $letter; ?></h3>
+
+<?php
+
+ if (isset($users[$letter])) {
+ ksort($users[$letter]);
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+ $col = 0;
+
+ foreach($users[$letter] as $friend) {
+ if ($col == 0) echo "<tr>";
+
+ //echo "<p>" . $user->name . "</p>";
+ $label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny'));
+ $options[$label] = $friend->getGUID();
+
+?>
+
+ <td>
+
+ <input type="checkbox" name="shares[]" value="<?php echo $options[$label]; ?>" />
+
+ </td>
+
+ <td >
+
+ <div style="width: 25px; margin-bottom: 15px;">
+<?php
+
+ echo $label;
+
+?>
+ </div>
+ </td>
+ <td style="width: 300px; padding: 5px;">
+<?php
+
+ echo $friend->name;
+
+?>
+ </td>
+<?php
+
+ $col++;
+ if ($col == 3) echo "</tr>";
+ }
+ if ($col < 3) echo "</tr>";
+
+ echo "</table>";
+
+ }
+
+?>
+
+ </div>
+ </div>
+<?php
+ if ($letter == 'Z') break;
+ $letter++;
+ }
+
+?>
+ </div>
+ </div>
+</div>
+
+<script type="text/javascript">
+ jQuery(window).bind("load", function() {
+ // initialise picker
+ $("div#friendsPicker<?php echo $friendspicker; ?>").friendsPicker();
+ });
+</script>
+<script>
+ // manually add class to corresponding tab for panels that have content - needs to be automated eventually
+<?php
+
+ if (sizeof($users) > 0)
+ foreach($users as $letter => $gumph) {
+?>
+ $("div#friendsPickerNavigation" + j + " li.tab3 <?php echo $letter; ?>").addClass("tabHasContent");
+<?php
+ }
+
+?>
+</script> \ No newline at end of file