22 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
43 function XoopsFormSelectUser($caption, $name, $include_anon =
false, $value = null, $size = 1, $multiple =
false)
46 $select_element =
new XoopsFormSelect(
'', $name, $value, $size, $multiple);
48 $select_element->addOption(0,
$GLOBALS[
'xoopsConfig'][
'anonymous']);
52 $value = is_array($value) ? $value : (empty($value) ? array() : array($value));
53 if ($user_count >
$limit && count($value) > 0) {
62 $select_element->addOptionArray($users);
63 if ($user_count <=
$limit) {
64 $this->XoopsFormElementTray($caption,
"", $name);
65 $this->addElement($select_element);
70 $js_addusers =
"<script type='text/javascript'>
71 function addusers(opts){
72 var num = opts.substring(0, opts.indexOf(':'));
73 opts = opts.substring(opts.indexOf(':')+1, opts.length);
74 var sel = xoopsGetElementById('" . $name .
"');
75 var arr = new Array(num);
76 for (var n=0; n < num; n++) {
77 var nm = opts.substring(0, opts.indexOf(':'));
78 opts = opts.substring(opts.indexOf(':')+1, opts.length);
79 var val = opts.substring(0, opts.indexOf(':'));
80 opts = opts.substring(opts.indexOf(':')+1, opts.length);
81 var txt = opts.substring(0, nm - val.length);
82 opts = opts.substring(nm - val.length, opts.length);
84 for (var k = 0; k < sel.options.length; k++) {
85 if(sel.options[k].value == val){
91 sel.options[k] = new Option(txt, val);
92 sel.options[k].selected = true;
99 $action_tray =
new XoopsFormElementTray(
"",
" | ");
100 $action_tray->addElement(
new XoopsFormLabel(
'',
'<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name .
'\');
for (var i = sel.options.length-1; i >= 0; i--) {
if (!sel.options[i].selected) {sel.options[i] = null;}};
return false;
">' . _MA_USER_REMOVE . "</a>
"));
101 $action_tray->addElement(new XoopsFormLabel('', '<a href="#
" onclick="openWithSelfMain(\
'' . XOOPS_URL .
'/include/findusers.php?target=' . $name .
'&multiple=' . $multiple .
'&token=' .
$token .
'\', \
'userselect\', 800, 600, null); return false;" >' .
_MA_USER_MORE .
"</a>" . $js_addusers));
103 $this->addElement($select_element);
104 $this->addElement($action_tray);