Source for file formselectuser.php
Documentation is available at formselectuser.php
* user select with page navigation
* limit: Only work with javascript enabled
* @copyright The XOOPS project http://www.xoops.org/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
* @version $Id: formselectuser.php 1052 2007-09-15 03:38:30Z phppp $
die("XOOPS root path not defined");
include_once XOOPS_ROOT_PATH. "/class/xoopsform/formelementtray.php";
include_once XOOPS_ROOT_PATH. "/class/xoopsform/formselect.php";
* @param mixed $value Pre-selected value (or array of them).
* For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item
* @param bool $include_anon Include user "anonymous"?
* @param int $size Number or rows. "1" makes a drop-down-list.
* @param bool $multiple Allow multiple selections?
function XoopsFormSelectUser($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false)
$select_element = new XoopsFormSelect("", $name, $value, $size, $multiple);
$select_element->addOption(0, $GLOBALS["xoopsConfig"]['anonymous']);
$user_count = $member_handler->getUserCount();
$value = is_array($value) ? $value : ( empty($value) ? array() : array($value) );
if ($user_count > $limit && count($value) > 0) {
$criteria->setLimit($limit);
$criteria->setSort('uname');
$criteria->setOrder('ASC');
$users = $member_handler->getUserList($criteria);
$select_element->addOptionArray($users);
if ($user_count <= $limit) {
if (!@include_once XOOPS_ROOT_PATH. "/language/". $GLOBALS["xoopsConfig"]["language"]. "/findusers.php") {
"<script type=\"text/javascript\">
var num = opts.substring(0, opts.indexOf(\":\"));
opts = opts.substring(opts.indexOf(\":\")+1, opts.length);
var sel = xoopsGetElementById(\"". $name . ($multiple ? "[]" : "") . "\");
var arr = new Array(num);
for (var n=0; n < num; n++) {
var nm = opts.substring(0, opts.indexOf(\":\"));
opts = opts.substring(opts.indexOf(\":\")+1, opts.length);
var val = opts.substring(0, opts.indexOf(\":\"));
opts = opts.substring(opts.indexOf(\":\")+1, opts.length);
var txt = opts.substring(0, nm - val.length);
opts = opts.substring(nm - val.length, opts.length);
for (var k = 0; k < sel.options.length; k++) {
if(sel.options[k].value == val){
sel.options[k] = new Option(txt, val);
sel.options[k].selected = true;
$token = $GLOBALS['xoopsSecurity']->createToken();
$action_tray->addElement(new XoopsFormLabel('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ( $multiple ? "[]" : "" ) . "\");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>"));
$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));
|