lastcache}&js=friendsPickerv1&viewtype=$viewtype", 'friendsPicker'); $chararray = elgg_echo('friendspicker:chararray'); // Initialise internalname if (!isset($vars['internalname'])) { $internalname = "friend"; } else { $internalname = $vars['internalname']; } // Are we highlighting default or all? if (empty($vars['highlight'])) { $vars['highlight'] = 'default'; } if ($vars['highlight'] != 'all') { $vars['highlight'] = 'default'; } // 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']); } } // Initialise whether we're calling back or not if (isset($vars['callback'])) { $callback = $vars['callback']; } else { $callback = false; } // We need to count the number of friends pickers on the page. if (!isset($vars['friendspicker'])) { global $friendspicker; if (!isset($friendspicker)) { $friendspicker = 0; } $friendspicker++; } else { $friendspicker = $vars['friendspicker']; } $users = array(); $activeletters = array(); // Are we displaying form tags and submit buttons? // (If we've been given a target, then yes! Otherwise, no.) if (isset($vars['formtarget'])) { $formtarget = $vars['formtarget']; } else { $formtarget = false; } // Sort users by letter if (is_array($vars['entities']) && sizeof($vars['entities'])) { foreach($vars['entities'] as $user) { if (is_callable('mb_substr')) { $letter = strtoupper(mb_substr($user->name,0,1)); } else { $letter = strtoupper(substr($user->name,0,1)); } if (!substr_count($chararray,$letter)) { $letter = "*"; } if (!isset($users[$letter])) { $users[$letter] = array(); } $users[$letter][$user->guid] = $user; } } // sort users in letters alphabetically foreach ($users as $letter => $letter_users) { usort($letter_users, create_function('$a, $b', ' return strcasecmp($a->name, $b->name); ')); $users[$letter] = $letter_users; } if (!$callback) { ?>