ldap = new ldap_im();
$this->db = new db_im();
}
public final function getParticipantsExternal()
{
if( !$this->groupsLocked() && $_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit'] )
return "true";
else
return "false";
}
private final function groupsLocked()
{
$memberShip = array();
$groupsLocked = explode(";",$_SESSION['phpgw_info']['jabberit_messenger']['groups_locked']);
foreach($_SESSION['phpgw_info']['jabberit_messenger']['membership'] as $tmp)
$memberShip[] = $tmp['account_name'];
foreach($groupsLocked as $tmp)
{
$groups = explode(":", $tmp);
if( array_search($groups[1], $memberShip) !== False)
return true;
}
return false;
}
public final function list_contacts($param)
{
$users = $this->users_auth_im($param['name']);
$order = array();
if (!is_array($users) && trim($users) === 'Many Results')
return "Many Results";
if( is_array($users) )
{
foreach($users as $tmp)
{
if ( !array_key_exists($tmp['dn'], $order) )
$order[$tmp['dn']] = array();
$order[$tmp['dn']][] = '' . $tmp['cn'] . '' . $tmp['mail'] .'' . $tmp['uid'] . '' . $tmp['photo'] . '';
}
ksort($order);
$return = '';
foreach ( $order as $key => $val )
$return .= '<'.$key.'>'.implode('',$val).''.$key.'>';
$return .= '';
}
else
$return = '';
return $return;
}
private final function users_auth_im($pName)
{
$array_uids = $this->db->get_accounts_acl();
$count = count($array_uids);
$uids_members = array();
for($i = 0; $i < $count ;$i+=50)
{
$partial_uids = array_slice($array_uids,$i,50);
$filter_uid = implode(")(uidnumber=",$partial_uids);
$filter_uid = "(uidnumber=". $filter_uid. ")";
$result = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $this->groupsLocked());
if ( is_array($result) )
$uids_members = array_merge($uids_members,$result);
if(count($uids_members) > 50){
unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);
return 'Many Results';
}
}
if(count($uids_members) > 0)
return $uids_members;
else
return 0;
}
}
?>