" . utf8_decode($entries[$i]['cn'][0]) . " | " . utf8_decode($entries[$i]['cn'][0]). " (" . $entries[$i]['uid'][0] . ")" . " | " . $entries[$i]['mail'][0] . " | |
";
$trs[$tr] = utf8_decode($entries[$i]['cn'][0]);
}
}
$trs_string = '';
if (count($trs))
{
natcasesort($trs);
foreach ($trs as $tr=>$cn)
{
$trs_string .= $tr;
}
}
$return['status'] = 'true';
$return['trs'] = $trs_string;
return $return;
}
function get_shared_account_data($params)
{
if (!$this->functions->check_acl($_SESSION['phpgw_info']['expresso']['user']['account_lid'], 'edit_shared_accounts'))
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('You do not have right to edit an shared accounts') . ".";
return $return;
}
$uid = $params['uid'];
//$justthese = array("accountStatus", "phpgwAccountVisible", "cn", "mail", "mailForwardingAddress", "description");
$shared_accounts = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], ("(&(phpgwAccountType=s)(uid=$uid))"));
$entrie = ldap_get_entries($this->ldap, $shared_accounts);
if ($entrie['count'] != 1)
{
$return['status'] = 'false';
$result['msg'] = $this->functions->lang('Problems loading datas') . '.';
}
else
{
$tmp_user_context = preg_split('/,/', $entrie[0]['dn']);
$tmp_reverse_user_context = array_reverse($tmp_user_context);
array_pop($tmp_reverse_user_context);
$return['user_context'] = implode(",", array_reverse($tmp_reverse_user_context));
$return['status'] = 'true';
$return['accountStatus'] = $entrie[0]['accountstatus'][0];
$return['phpgwAccountVisible'] = $entrie[0]['phpgwaccountvisible'][0];
$return['cn'] = utf8_decode($entrie[0]['cn'][0]);
$return['mail'] = $entrie[0]['mail'][0];
$return['description'] = utf8_decode($entrie[0]['description'][0]);
$return['dn'] = utf8_decode($entrie[0]['dn']);
$return['mailalternateaddress'] = $entrie[0]['mailalternateaddress'];
}
return $return;
}
function mailforwardingaddress2uidnumber($mail)
{
$justthese = array("uidnumber","cn", "uid");
$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], ("(&(phpgwAccountType=u)(mail=$mail))"), $justthese);
$entrie = ldap_get_entries($this->ldap, $search);
if ($entrie['count'] != 1)
return false;
else
{
$return['uidnumber'] = $entrie[0]['uidnumber'][0];
$return['cn'] = utf8_decode($entrie[0]['cn'][0]);
$return['uid'] = $entrie[0]['uid'][0];
return $return;
}
}
function uid2mailforwardingaddress($uid)
{
$justthese = array("mail");
$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], ("(&(phpgwAccountType=u)(uid=$uid))"), $justthese);
$entrie = ldap_get_entries($this->ldap, $search);
if ($entrie['count'] != 1)
return false;
else
{
$return['mail'] = $entrie[0]['mail'][0];
return $return;
}
}
function delete_institutional_account_data($params)
{
if (!$this->functions->check_acl($_SESSION['phpgw_info']['expresso']['user']['account_lid'], 'remove_institutional_accounts'))
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('You do not have right to delete institutional accounts') . ".";
return $return;
}
$uid = $params['uid'];
$return['status'] = true;
$justthese = array("cn");
$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], ("(&(phpgwAccountType=i)(uid=$uid))"), $justthese);
$entrie = ldap_get_entries($this->ldap, $search);
if ($entrie['count'] > 1)
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('More then one uid was found');
return $return;
}
if ($entrie['count'] == 0)
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('No uid was found');
return $return;
}
$dn = utf8_decode($entrie[0]['dn']);
if (!@ldap_delete($this->ldap, $dn))
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('Error on function') . " ldap_functions->delete_institutional_accounts: ldap_delete";
$return['msg'] .= "\n" . $this->functions->lang('Server return') . ': ' . ldap_error($this->ldap);
return $return;
}
return $return;
}
function replace_mail_from_institutional_account($newMail, $oldMail)
{
$filter = "(&(phpgwAccountType=i)(mailforwardingaddress=$oldMail))";
$justthese = array("dn");
$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
$entries = ldap_get_entries($this->ldap, $search);
$result['status'] = true;
for ($i=0; $i<$entries['count']; $i++)
{
$attrs['mailforwardingaddress'] = $oldMail;
$res1 = @ldap_mod_del($this->ldap, $entries[$i]['dn'], $attrs);
$attrs['mailforwardingaddress'] = $newMail;
$res2 = @ldap_mod_add($this->ldap, $entries[$i]['dn'], $attrs);
if ((!$res1) || (!$res2))
{
$result['status'] = false;
$return['msg'] = $this->functions->lang('Error on function') . " ldap_functions->replace_mail_from_institutional_account.";
}
}
return $result;
}
function delete_shared_account_data($params)
{
if (!$this->functions->check_acl($_SESSION['phpgw_info']['expresso']['user']['account_lid'], 'delete_shared_accounts'))
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('You do not have right to delete shared accounts') . ".";
return $return;
}
$uid = $params['uid'];
$return['status'] = true;
$justthese = array("cn");
$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], "(&(phpgwAccountType=s)(uid=$uid))", $justthese);
$entrie = ldap_get_entries($this->ldap, $search);
if ($entrie['count'] > 1)
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('More then one uid was found');
return $return;
}
if ($entrie['count'] == 0)
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('No uid was found');
return $return;
}
$dn = $entrie[0]['dn'];
if (!@ldap_delete($this->ldap, $dn))
{
$return['status'] = false;
$return['msg'] = $this->functions->lang('Error on function') . " ldap_functions->delete_shared_accounts: ldap_delete";
$return['msg'] .= "\n" . $this->functions->lang('Server return') . ': ' . ldap_error($this->ldap);
return $return;
}
return $return;
}
}
?>