Beispiel #1
0
function uddeIMselectComboUserlist( $myself, $my_gid, $lids, $config ) {
	$database = uddeIMgetDatabase();
	$users = Array();
	
	getAdditonalGroups($add_special, $add_admin, $config);

	$ret = '<select multiple="multiple" name="userlist" class="inputbox" ondblclick="userlistdblclick(this.selectedIndex, \'listsform\', \'userlist\', \'selectionlist\', '.$config->maxonlists.')" size="10">';

	if (($config->restrictcon==1 && uddeIMisReggedOnly($my_gid)) ||
		($config->restrictcon==2 && uddeIMisAllNotAdmin($my_gid) && !uddeIMisAdmin2($my_gid, $config)) ||
		($config->restrictcon==3) ) {

		if ($lids)
			$temp = "u.id NOT IN (".uddeIMquoteSmart($lids).") AND ";
		$somanyfriends = 0;
		if (uddeIMcheckCB()) {
			$users = uddeIMselectCBbuddies($myself, $config, $temp);
			$somanyfriends = count($users);
		}

		if (!$somanyfriends) { // no friends found, maybe there are some in CBE?
			if (uddeIMcheckCBE()) {
				$users = uddeIMselectCBEbuddies($myself, $config, $temp);
				$somanyfriends = count($users);
			}
			if (uddeIMcheckCBE2()) {
				$users = uddeIMselectCBE2buddies($myself, $config, $temp);
				$somanyfriends = count($users);
			}
		}

		if (!$somanyfriends) { // no friends found, maybe there are some in JS?
			if (uddeIMcheckJS()) {
				$users = uddeIMselectJSbuddies($myself, $config, $temp);
				$somanyfriends = count($users);
			}
		}

	} else {


		if (uddeIMcheckJversion()>=2) {		// J1.6
			$temp = "";
			if ($lids)
				$temp = "AND u.id NOT IN (".uddeIMquoteSmart($lids).") ";
			switch ($config->hideallusers) {
				case 3:		// special users
					$sql="SELECT DISTINCT u.id,u.".($config->realnames ? "name" : "username")." AS displayname FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) 
								INNER JOIN #__usergroups AS g ON um.group_id=g.id 
								WHERE u.block=0 ".$temp."AND g.id NOT IN (3,4,5,6,7,8".$add_admin.$add_special.") ORDER BY u.".($config->realnames ? "name" : "username");
					break;
				case 2:		// admins
					$sql="SELECT DISTINCT u.id,u.".($config->realnames ? "name" : "username")." AS displayname FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) 
								INNER JOIN #__usergroups AS g ON um.group_id=g.id 
								WHERE u.block=0 ".$temp."AND g.id NOT IN (7,8".$add_admin.") ORDER BY u.".($config->realnames ? "name" : "username");
					break;
				case 1:		// superadmins
					$sql="SELECT DISTINCT u.id,u.".($config->realnames ? "name" : "username")." AS displayname FROM (#__users AS u INNER JOIN #__user_usergroup_map AS um ON u.id=um.user_id) 
								INNER JOIN #__usergroups AS g ON um.group_id=g.id 
								WHERE u.block=0 ".$temp."AND g.id NOT IN (8) ORDER BY u.".($config->realnames ? "name" : "username");
					break;
				default:	// none
					$sql="SELECT u.id,u.".($config->realnames ? "name" : "username")." AS displayname FROM #__users AS u WHERE u.block=0 ".$temp."ORDER BY u.".($config->realnames ? "name" : "username");
					break;
			}
			if (uddeIMisAdmin($my_gid) || uddeIMisAdmin2($my_gid, $config))		// do not hide users when it is an admin
				$sql="SELECT u.id,u.".($config->realnames ? "name" : "username")." AS displayname FROM #__users AS u WHERE u.block=0 ".$temp."ORDER BY u.".($config->realnames ? "name" : "username");
		} else {
			$temp = "";
			if ($lids)
				$temp = "AND id NOT IN (".uddeIMquoteSmart($lids).") ";
			switch ($config->hideallusers) {
				case 3:		// special users
					$sql="SELECT id,".($config->realnames ? "name" : "username")." AS displayname FROM #__users WHERE block=0 ".$temp."AND gid NOT IN (19,20,21,23,24,25".$add_admin.$add_special.") ORDER BY ".($config->realnames ? "name" : "username");
					break;
				case 2:		// admins
					$sql="SELECT id,".($config->realnames ? "name" : "username")." AS displayname FROM #__users WHERE block=0 ".$temp."AND gid NOT IN (24,25".$add_admin.") ORDER BY ".($config->realnames ? "name" : "username");
					break;
				case 1:		// superadmins
					$sql="SELECT id,".($config->realnames ? "name" : "username")." AS displayname FROM #__users WHERE block=0 ".$temp."AND gid NOT IN (25) ORDER BY ".($config->realnames ? "name" : "username");
					break;
				default:	// none
					$sql="SELECT id,".($config->realnames ? "name" : "username")." AS displayname FROM #__users WHERE block=0 ".$temp."ORDER BY ".($config->realnames ? "name" : "username");
					break;
			}
			if (uddeIMisAdmin($my_gid) || uddeIMisAdmin2($my_gid, $config))		// do not hide users when it is an admin
				$sql="SELECT id,".($config->realnames ? "name" : "username")." AS displayname FROM #__users WHERE block=0 ".$temp."ORDER BY ".($config->realnames ? "name" : "username");
		}
		$database->setQuery( $sql );
		$users = $database->loadObjectList(); 
		if (!$users)
			$users = Array();
	}

	if ( count( $users ) )  {
		foreach ( $users as $user )
			$ret .= '<option value="'.$user->id.'">'.$user->displayname.'</option>';
	}
	$ret .= '</select>';
	return $ret;
}
Beispiel #2
0
function uddeIMdoShowConnections($myself, $my_gid, $config) {						
	$sep=",";
	if ($config->separator==1)
		$sep=";";

	$somanyfriends = 0;
	if ($config->showconnex) {
		if (uddeIMcheckCB()) {
			$rows = uddeIMselectCBbuddies($myself, $config);
			$somanyfriends = count($rows);
		}

		if (!$somanyfriends) { // no friends found, maybe there are some in CBE?
			if (uddeIMcheckCBE()) {
				$rows = uddeIMselectCBEbuddies($myself, $config);
				$somanyfriends = count($rows);
			}
			if (uddeIMcheckCBE2()) {
				$rows = uddeIMselectCBE2buddies($myself, $config);
				$somanyfriends = count($rows);
			}
		}

		if (!$somanyfriends) { // no friends found, maybe there are some in JS?
			if (uddeIMcheckJS()) {
				$rows = uddeIMselectJSbuddies($myself, $config);
				$somanyfriends = count($rows);
			}
		}
	}

	// collect lists
	$somanylists=0;
	if( ($config->enablelists==1) ||
	    ($config->enablelists==2 && (uddeIMisSpecial($my_gid) || uddeIMisSpecial2($my_gid, $config))) || 
	    ($config->enablelists==3 && (uddeIMisAdmin($my_gid)   || uddeIMisAdmin2($my_gid, $config))) ) {
		$my_lists = uddeIMselectAllUserlists($myself, $my_gid, $config, true); 		
		$somanylists = count($my_lists);
	}

	if ($somanyfriends>0 || $somanylists>0) {

		if ($somanyfriends>0 && $somanylists>0)
			$mycons = _UDDEIM_CONNECTIONS."/"._UDDEIM_LISTS."<br />";
		elseif ($somanyfriends>0)
			$mycons = _UDDEIM_CONNECTIONS."<br />";
		elseif ($somanylists>0)
			$mycons = _UDDEIM_LISTS."<br />";
		else
			$mycons = "";

		if ($config->connex_listbox) {
			if ($config->connexallowmultipleuser)
				$mycons.="<select size=\"1\" class=\"inputbox\" onchange=\"document.sendeform.to_name.value=(document.sendeform.to_name.value.length>0 &amp;&amp; this.options[this.selectedIndex].value.length>0) ? document.sendeform.to_name.value+'".$sep."'+this.options[this.selectedIndex].value : this.options[this.selectedIndex].value; return false;\" name=\"connexlistbox\">";
			else
				$mycons.="<select size=\"1\" class=\"inputbox\" onchange=\"document.sendeform.to_name.value=this.options[this.selectedIndex].value; return false;\" name=\"connexlistbox\">";
			$mycons.="<option value=''>&nbsp;</option>";

			if ($somanyfriends>0)
				foreach ($rows as $row)
					$mycons.="<option value=\"".$row->displayname."\">".$row->displayname."</option>";
			if ($somanylists>0)
				foreach ($my_lists as $row)
					$mycons.="<option value=\"#".$row->name."\">#".$row->name."</option>";

			$mycons.="</select>";
		} else {
			if ($config->connexallowmultipleuser) {
				$mycons.="<ul>";
				$mycons.="<li><a href=\"#\" onclick=\"document.sendeform.to_name.value=''; return false;\">"._UDDEIM_CLEAR."</a></li>&nbsp; ";
				if ($somanyfriends>0)
					foreach ($rows as $row)
						$mycons.="<li><a href=\"#\" onclick=\"document.sendeform.to_name.value=(document.sendeform.to_name.value.length>0) ? document.sendeform.to_name.value+'".$sep."'+'".$row->displayname."' : '".$row->displayname."'; return false;\">".$row->displayname."</a></li>&nbsp; ";
				if ($somanylists>0)
					foreach ($my_lists as $row)
						$mycons.="<li><a href=\"#\" onclick=\"document.sendeform.to_name.value=(document.sendeform.to_name.value.length>0) ? document.sendeform.to_name.value+'".$sep."'+'#".$row->name."' : '#".$row->name."'; return false;\">#".$row->name."</a></li>&nbsp; ";
				$mycons.="</ul>";
			} else {
				if ($somanyfriends>0)
					foreach ($rows as $row)
						$mycons.="<a href=\"#\" onclick=\"document.sendeform.to_name.value='".$row->displayname."'; return false;\">".$row->displayname."</a>&nbsp; ";
				if ($somanylists>0)
					foreach ($my_lists as $row)
						$mycons.="<a href=\"#\" onclick=\"document.sendeform.to_name.value='#".$row->name."'; return false;\">#".$row->name."</a>&nbsp; ";
			}
		}

// START THIRD LINE IN TABLE (when connections exist)
		if ($config->connex_listbox) {
			echo "<tr><td valign='top'>&nbsp;</td><td valign='top' align='right'>".$mycons."</td></tr>";
		} else {
			echo "<tr><td colspan='2'>".$mycons."</td></tr>";
		}
	}
}