aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/access.php18
-rw-r--r--views/default/friends/collection.php7
-rw-r--r--views/default/friends/picker.php28
3 files changed, 39 insertions, 14 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 64d982e30..2c9a886e6 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -310,17 +310,24 @@
* Get all of members of a friend collection
*
* @param int $collection The collection's ID
+ * @param true|false $idonly If set to true, will only return the members' IDs (default: false)
* @return ElggUser entities if successful, false if not
*/
- function get_members_of_access_collection($collection) {
+ function get_members_of_access_collection($collection, $idonly = false) {
$collection = (int)$collection;
global $CONFIG;
- $query = "select e.* from {$CONFIG->dbprefix}access_collection_membership m join {$CONFIG->dbprefix}entities e on e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
-
- $collection_members = get_data($query, "entity_row_to_elggstar");
+ if (!$idonly) {
+ $query = "select e.* from {$CONFIG->dbprefix}access_collection_membership m join {$CONFIG->dbprefix}entities e on e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
+ $collection_members = get_data($query, "entity_row_to_elggstar");
+ } else {
+ $query = "select e.guid from {$CONFIG->dbprefix}access_collection_membership m join {$CONFIG->dbprefix}entities e on e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
+ $collection_members = get_data($query);
+ foreach($collection_members as $key => $val)
+ $collection_members[$key] = $val->guid;
+ }
return $collection_members;
@@ -337,7 +344,8 @@
if ($collections = get_user_access_collections($owner_guid)) {
foreach($collections as $key => $collection) {
- $collections[$key]->entities = get_members_of_access_collection($collection->id);
+ $collections[$key]->members = get_members_of_access_collection($collection->id, true);
+ $collections[$key]->entities = get_user_friends($owner_guid,"",9999);
}
}
diff --git a/views/default/friends/collection.php b/views/default/friends/collection.php
index 4d08e5b06..b42b4467a 100644
--- a/views/default/friends/collection.php
+++ b/views/default/friends/collection.php
@@ -19,7 +19,7 @@
$coll = $vars['collection'];
if (is_array($vars['collection']->entities)) {
- $count = sizeof($vars['collection']->entities);
+ $count = sizeof($vars['collection']->members);
} else {
$count = 0;
}
@@ -35,8 +35,9 @@
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));
+ if($friends = $vars['collection']->entities){
+ $members = $vars['collection']->members;
+ echo elgg_view('friends/picker',array('entities' => $friends, 'value' => $members));
}
// close friends_picker div and the accordian list item
diff --git a/views/default/friends/picker.php b/views/default/friends/picker.php
index a226f24e1..4be60b12e 100644
--- a/views/default/friends/picker.php
+++ b/views/default/friends/picker.php
@@ -20,6 +20,16 @@
} else {
$internalname = $vars['internalname'];
}
+
+ // Initialise values
+ if (!isset($vars['value'])) {
+ $vars['value'] = array();
+ } else {
+ if (!is_array($vars['value'])) {
+ $vars['value'] = (int) $vars['value'];
+ $vars['value'] = array($vars['value']);
+ }
+ }
// We need to count the number of friends pickers on the page.
global $friendspicker;
@@ -27,6 +37,7 @@
$friendspicker++;
$users = array();
+ $activeletters = array();
// Sort users by letter
if (is_array($vars['entities']) && sizeof($vars['entities']))
@@ -73,12 +84,19 @@
//echo "<p>" . $user->name . "</p>";
$label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny'));
$options[$label] = $friend->getGUID();
+ if (in_array($friend->getGUID(),$vars['value'])) {
+ $checked = "checked = \"checked\"";
+ if (!in_array($letter,$activeletters))
+ $activeletters[] = $letter;
+ } else {
+ $checked = "";
+ }
?>
<td>
- <input type="checkbox" name="<?php echo $internalname; ?>[]" value="<?php echo $options[$label]; ?>" />
+ <input type="checkbox" <?php echo $checked; ?> name="<?php echo $internalname; ?>[]" value="<?php echo $options[$label]; ?>" />
</td>
@@ -135,15 +153,13 @@
jQuery(window).bind("load", function() {
// manually add class to corresponding tab for panels that have content - needs to be automated eventually
<?php
- if (sizeof($users) > 0)
+ if (sizeof($activeletters) > 0)
$chararray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- foreach($users as $letter => $gumph) {
+ foreach($activeletters as $letter) {
$tab = strpos($chararray, $letter) + 1;
- if (is_array($gumph) && sizeof($gumph)) {
?>
$("div#friendsPickerNavigation<?php echo $friendspicker - 1; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent");
-<?php
- }
+<?php
}
?>