popup();
}
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_select.php");
class user_select
{
function user_list($class, $form_name)
{
global $sql, $tp;
if($class === FALSE) { $class = e_UC_MEMBER;}
switch ($class)
{
case e_UC_ADMIN:
$where = "user_admin = 1";
break;
case e_UC_MEMBER:
$where = "user_ban != 1";
break;
case e_UC_NOBODY:
return "";
break;
default:
$where = "user_class REGEXP '(^|,)(".$tp -> toDB($class, true).")(,|$)'";
break;
}
$text = "";
$text .= "".US_LAN_1." ";
$sql -> db_Select("user", "user_name", $where." ORDER BY user_name");
while ($row = $sql -> db_Fetch()) {
$text .= "".$row['user_name']." ";
}
$text .= " ";
return $text;
}
/**
* Display selection dropdown of all user classes
*
* @param int $class - if its e_UC_MEMBER, all classes are shown. Otherwise only the class matching the value is shown.
*/
function class_list($class, $form_name)
{
global $sql;
$text = "";
$text .= "".US_LAN_2." ";
if (ADMINPERMS == '0' && $class == e_UC_MEMBER)
{
$text .= "".US_LAN_3." ";
}
if ($class == e_UC_MEMBER)
{
$sql -> db_Select("userclass_classes", "userclass_id, userclass_name", "ORDER BY userclass_name", "nowhere");
while ($row = $sql -> db_Fetch())
{
if (check_class($row['userclass_id']) || ADMINPERMS == '0')
{
$text .= "".$row['userclass_name']." ";
}
}
}
else
{
$sql -> db_Select("userclass_classes", "userclass_id, userclass_name", "userclass_id='".intval($class)."' ORDER BY userclass_name");
while ($row = $sql -> db_Fetch())
{
$text .= "".$row['userclass_name']." ";
}
}
return $text;
}
/**
* Put up user selection form
*
* @param string $type (list|popup) - determines type of display
* @param string $user_form - type.name (textarea|input).name of text box or text area to accept user name (popups only)
* @param string $user_value - initial value of user input box
* @param int|boolean $class - if non-false, userclass ID to filter list (was unused parameter called $class_form)
* @param string $dummy - unused parameter (was called $class_value)
* @param int|boolean $oldClass - unused parameter; for legacy purposes, if non-false, overrides $class
*
* @return string html for display
*
* @todo remove unused parameters when possible
* N.B. Only used by pm plugin in 0.7 core distribution
*/
// function select_form($type, $user_form, $user_value = '', $class_form = false, $class_value = '', $class = false)
function select_form($type, $user_form, $user_value = '', $class = false, $dummy = '', $oldClass = FALSE)
{
global $tp;
if ($oldClass !== FALSE) $class = $oldClass; // Handle legacy position of $class
$text = "";
list($form_type, $form_id) = explode(".", $user_form);
if($form_id == "") { $form_id = $form_type; }
if ($type == 'list')
{
$text .= $this -> user_list($class, 'user');
}
else if ($type == 'popup')
{
if($form_type == 'textarea')
{
$text .= " ";
}
else
{
$text .= " ";
}
// @todo popup doesn't work ATM because e_HANDLER_ABS not valid
$text .= " ";
}
/*
This appears to duplicate other functionality, in an unhelpful way!
if ($class !== false)
{
if (($class < e_UC_NOBODY && USERCLASS) || ADMINPERMS == '0')
{
$text .= ' '.$this -> class_list($class, 'class');
}
}
*/
return $text;
}
function real_name($_id)
{
global $sql;
$sql -> db_Select("user", "user_name", "user_id='".intval($_id)."' ");
if ($row = $sql -> db_Fetch())
{
return $row['user_name'];
}
}
function popup()
{
global $ns, $tp;
list($elementType, $elementID) = explode(".", e_QUERY);
if($elementType == 'textarea')
{
$job = "
curval = parent.opener.document.getElementById('{$elementID}').value;
lastchr = curval.substring(curval.length-1, curval.length);
if(lastchr != '\\n' && curval.length > 0)
{
curval = curval+'\\n';
}
parent.opener.document.getElementById('{$elementID}').value = curval+d+'\\n';";
}
else
{
if($elementID == "")
{
$elementID = $elementType;
}
$job = "parent.opener.document.getElementById('{$elementID}').value = d;";
}
// send the charset to the browser - overrides spurious server settings with the lan pack settings.
header("Content-type: text/html; charset=utf-8", TRUE);
echo (defined("STANDARDS_MODE") ? "" : "\n")."\n";
echo "
".SITENAME." \n";
echo "
";
$text = "
";
if (isset($_POST['dosrch']))
{
$userlist = $this -> findusers($_POST['srch']);
if($userlist == FALSE)
{
$fcount= 0;
}
else
{
$fcount = count($userlist);
}
$text .= "
";
}
$ns -> tablerender(US_LAN_4, $text);
echo "\n\n";
}
function findusers($s,$banned=FALSE) {
global $sql, $tp;
$inc = ($banned == FALSE) ? " AND user_ban != 1" : "";
if ($sql->db_Select("user", "*", "user_name LIKE '%".$tp -> toDB($s)."%'".$inc))
{
while ($row = $sql -> db_Fetch()) {
$ret[strtolower($row['user_name'])] = $row['user_name'];
}
ksort($ret);
} else {
$ret = FALSE;
}
return $ret;
}
}
?>