From 7c7fac52ebcf4449e7103c41bccf8babbc213b95 Mon Sep 17 00:00:00 2001 From: nickw Date: Wed, 9 Jun 2010 22:26:41 +0000 Subject: Pre-populating userpicker list when values are passed. git-svn-id: http://code.elgg.org/elgg/trunk@6430 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/userpicker.php | 66 ++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php index a9351a36f..001090729 100644 --- a/views/default/input/userpicker.php +++ b/views/default/input/userpicker.php @@ -22,10 +22,37 @@ global $user_picker_js_sent; +function user_picker_add_user($user_id) { + $user = get_entity($user_id); + $icon = $user->getIcon('tiny'); + + $code = '
  • '; + $code .= ""; + $code .= "$user->name - $user->username"; + $code .= '
    '; + $code .= "X"; + $code .= '
    '; + $code .= ""; + $code .= '
  • '; + + return $code; +} + if (!isset($vars['value']) || $vars['value'] === FALSE) { $vars['value'] = elgg_get_sticky_value($vars['internalname']); } +// loop over all values and prepare them so that "in" will work in javascript +if (!is_array($vars['value'])) { + $vars['value'] = array($vars['value']); +} +foreach ($vars['value'] as $value) { + $values[$value] = TRUE; +} + +// convert the values to a json-encoded list +$json_values = json_encode($values); + if (!$user_picker_js_sent) { ?> @@ -33,6 +60,7 @@ if (!$user_picker_js_sent) {