function USER_ACCOUNT_POPUP($userid) { $tpl = new templates(); if ($userid == null) { writelogs("USER_ACCOUNT::Userid is null !! fatal error!!", __FUNCTION__, __FILE__, __LINE__); return false; } if (strlen($_GET["dn"]) > 0) { $userdn = base64_decode($_GET["dn"]); } $us = new user($userid, $userdn); if ($us->DoesNotExists) { return USER_NOTEXISTS($userid, $us->error . "<br>Func:USER_ACCOUNT_POPUP()"); } $as_connected_user = false; if ($_GET["userid"] == $_SESSION["uid"]) { $as_connected_user = true; } include_once dirname(__FILE__) . '/ressources/class.obm.inc'; writelogs("USER_ACCOUNT::{$_GET["userid"]}/{$userid}", __FUNCTION__, __FILE__, __LINE__); $ldap = new clladp(); $usermenus = new usersMenus(); $sock = new sockets(); $SambaEnabled = $sock->GET_INFO("SambaEnabled"); if (!is_numeric($SambaEnabled)) { $SambaEnabled = 1; } if ($SambaEnabled == 0) { $usermenus->SAMBA_INSTALLED = false; } $page = CurrentPageName(); $styleTDRight = "style='padding:5px;font-size:11px'"; $styleTDLeft = "style='padding:5px;font-size:11px'"; $cellRol = CellRollOver(); writelogs("USER_ACCOUNT::{$us->uid} checking OBM", __FUNCTION__, __FILE__, __LINE__); $obm = new obm_export_single($us->uid); if ($obm->CheckOBM()) { if ($obm->IsUserExists($us->uidNumber)) { $obm_info = "<p style='background-color:#FFFFFF;padding:3px;border:1px solid #CCCCCC;font-size:11px'>{user_is_an_obm_user}</p>"; } } if ($usermenus->cyrus_imapd_installed == true) { $button_mailboxes = "<input type='button' value='{mailbox settings} »' OnClick=\"javascript:TreeUserMailBoxForm('{$userid}');\" style='margin-right:20px'>"; } $priv = new usersMenus(); $uidenc = urlencode($us->uid); $button = "<input type='button' value='{submit} »' OnClick=\"javascript:ParseForm('userLdapform','{$page}',true,false,false,'userform',\n\t'domains.edit.user.php?userid={$uidenc}&ajaxmode=yes§ion=account');\">"; if ($usermenus->SIMPLE_GROUPEWARE_INSTALLED) { include_once "ressources/class.mysql.inc"; $sql = new mysql(); if ($sql->SIMPLE_GROUPWARE_ENABLED($userid)) { $SIMPLE_GROUPWARE_ENABLED = 1; $SIMPLE_GROUPWARE_TXT = "yes"; } else { $SIMPLE_GROUPWARE_ENABLED = 0; $SIMPLE_GROUPWARE_TXT = "No"; } $simple_groupware_activation_admin = "\n\t\t\t\t<tr {$cellRol}>\n\t\t\t\t\t<td align='right' nowrap class=legend {$styleTDRight}>{SimpleGroupWareActive}:</strong>\n\t\t\t\t\t<td {$styleTDLeft}>" . Field_numeric_checkbox_img('SimpleGroupWareActive', $SIMPLE_GROUPWARE_ENABLED) . "</td>\n\t\t\t\t</tr>\t"; $simple_groupware_activation_user = "******"; } if ($us->DisplayName == null) { $us->DisplayName = "unknown"; } if ($usermenus->PUREFTP_INSTALLED or $usermenus->SAMBA_INSTALLED) { $HomeBinding = Paragraphe("64-hand-user.png", '{HomeBinding}', '{HomeBinding_text}', "javascript:Loadjs('home.binding.php?userid={$userid}')"); } $HomeBinding_grey = Paragraphe("64-hand-user-grey.png", '{HomeBinding}', '{HomeBinding_text}'); $EndOfLife = "\n\t<td width=1%><img src='img/folder-tasks-32.png'></td>\n\t<td style='padding:5px' {$cellRol}>" . texttooltip('{FinalDateToLive}', '{FinalDateToLive_text}', "UserEndOfLIfe('{$userid}')", null, 0, 'font-size:12px;font-weight:bold') . "</td>"; $EndOfLife = Paragraphe("time-64.png", '{FinalDateToLive}', '{FinalDateToLive_text}', "javascript:UserEndOfLIfe('{$userid}')"); $SystemInfoUser = "******" . texttooltip('{UserSystemInfos}', '{UserSystemInfos_text}', "UserSystemInfos('{$userid}')", null, 0, 'font-size:12px;font-weight:bold') . "</td>"; $SystemInfoUser = Paragraphe("processor-64.png", '{UserSystemInfos}', '{UserSystemInfos_text}', "javascript:Loadjs('domains.edit.user.system.php?uid={$userid}')"); $SystemInfoUser_disabled = Paragraphe("system-64.org-grey.png", '{UserSystemInfos}', '{UserSystemInfos_text}'); $PRIVILEGES = Paragraphe('members-priv-64.png', '{privileges}', '{privileges_text}', "javascript:YahooWin(755,'domains.edit.group.php?GroupPriv=-2&userid={$userid}&start=yes','{privileges}')"); $PRIVILEGES_DISABLED = Paragraphe('members-priv-64-grey.png', '{privileges}', '{privileges_text}', ""); $ChangeGuid = "\n\t<td width=1%><img src='img/change-identifiant-32.png'></td>\n\t<td style='padding:5px' {$cellRol}>" . texttooltip('{change_uid}', '{change_uid_text}', "YahooWin3(650,'domains.edit.user.php?changeuid=yes&userid={$userid}','{$userid}:{change_uid}');", null, 0, 'font-size:12px;font-weight:bold') . "</td>"; $ChangeGuid = Paragraphe("logon-profiles-64.png", '{change_uid}', '{change_uid_text}', "javascript:YahooWin3(650,'domains.edit.user.php?changeuid=yes&userid={$userid}','{$userid}:{change_uid}');"); $ChangeGuid_disabled = Paragraphe("logon-profiles-64-grey.png", '{change_uid}', '{change_uid_text}'); $joomla = "\n\t<td width=1%><img src='img/32-joomla.png'></td>\n\t<td style='padding:5px' {$cellRol}>" . texttooltip('{joomla_privileges}', '{joomla_privileges_text}', "Loadjs('users.joomla.php?userid={$userid}');", null, 210, 'font-size:12px;font-weight:bold') . "</td>"; $joomla = Paragraphe("64.joomla.png", '{joomla_privileges}', '{joomla_privileges_text}', "javascript:Loadjs('users.joomla.php?userid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $usersinterface = Paragraphe("folder-interface-64.jpg", '{user_interface}', '{user_interface_text}', "Loadjs('users.tabs.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $button_backup = "\n\t<td width=1%><img src='img/32-backup.png'></td>\n\t<td style='padding:5px' {$cellRol}>" . texttooltip('{backup_parameters}', '{backup_parameters_text}', "Loadjs('domains.edit.user.backup.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold') . "</td>"; $button_backup = Paragraphe("64-backup.png", '{backup_parameters}', '{backup_parameters_text}', "javascript:Loadjs('domains.edit.user.backup.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $button_webdav = Paragraphe("webdav-64.png", '{USER_WEBDAV}', '{USER_WEBDAV_TEXT}', "javascript:Loadjs('domains.edit.user.webdav.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $button_webdav_disabled = Paragraphe("webdav-64-grey.png", '{USER_WEBDAV}', '{USER_WEBDAV_TEXT}'); $emule = Paragraphe("64-emule.png", '{MLDONKEY_USER}', '{MLDONKEY_USER_TEXT}', "javascript:Loadjs('domains.edit.user.mldonkey.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $delete = BuildParagraphe("delete_this_user", "delete_this_user_text", "Loadjs('domains.delete.user.php?uid={$userid}');", "32-cancel.png", true); $password = BuildParagraphe("change_password", "change_password_text", "ChangeUserPassword('{$userid}');", "32-key.png", true); $delete = Paragraphe("delete-64.png", '{delete}', '{delete_this_user}', "javascript:Loadjs('domains.delete.user.php?uid={$userid}');", null, 210, 'font-size:12px;font-weight:bold'); $delete_disabled = Paragraphe("delete-64-grey.png", '{delete}', '{delete_this_user}'); if (strlen($_GET["dn"]) > 0) { $deletedn = Paragraphe("delete-64.png", '{delete_this_user_dn}', '{delete_this_user_dn_text}', "javascript:Loadjs('domains.delete.userdn.php?uid={$userid}&dn={$_GET["dn"]}');", null, 210, 'font-size:12px;font-weight:bold'); } $deletedn_disabled = Paragraphe("delete-64-grey.png", '{delete_this_user_dn}', '{delete_this_user_dn_text}'); $password = Paragraphe("64-ssl-key.png", '{change_password}', '{change_password_text}', "javascript:YahooWin5('556','domains.edit.user.php?ChangeUserPassword=yes&uid={$userid}','{$userid}::{change_password}');", null, 210, 'font-size:12px;font-weight:bold'); $password_disabled = Paragraphe("64-ssl-key-grey.png", '{change_password}', '{change_password_text}'); $address = Paragraphe("64-addressbook.png", '{address}', '{address_user_text}', "javascript:Loadjs('contact.php?uidUser={$userid}')", null, 210, 'font-size:12px;font-weight:bold'); $address_disabled = Paragraphe("64-addressbook-grey.png", '{address}', '{address_user_text}'); if ($us->jpegPhotoError != null) { $imcontact = "unknown-user-64.png"; $text = "{error_image_missing}<br>{$us->jpegPhotoError}"; } else { $imcontact = $us->img_identity; $imcontact = str_replace("img/", "", $imcontact); } $picture = $picture; $mots = strlen($us->mail); $size_text = 14; if ($mots > 42) { $size_text = 12; } $email_address_hidden = "<strong style='font-size:{$size_text}px;font-family:Arial, Helvetica, sans-serif. '>{$us->mail}</strong>"; $email_address = "<span style='font-size:12px;font-family:Arial, Helvetica, sans-serif'>{$us->mail}</span>"; $quotaDisk = Paragraphe("rename-disk-64.png", '{disk_user_quota}', '{disk_user_quota_text}', "javascript:Loadjs('domains.edit.user.quota.php?uid={$userid}&ou={$us->ou}&userid={$userid}')", null, 210, 'font-size:12px;font-weight:bold'); $quotaDisk_disabled = Paragraphe("rename-disk-64-grey.png", '{disk_user_quota}', '{disk_user_quota_text}'); $changeuid = Paragraphe("64-folder-user.png", '{change_uid}', '{change_uid_text}', "javascript:YahooWin3(650,'domains.edit.user.php?changeuid=yes&userid={$userid}','{$userid}:{change_uid}');", null, 210, 'font-size:12px;font-weight:bold'); $changeuid_disabled = Paragraphe("mysql-user-settings-grey.png", '{change_uid}', '{change_uid_text}'); if (!$usermenus->POSTFIX_INSTALLED) { $recipients_translations = null; $domainName = null; $ChangeGuid = null; $email_address = Field_hidden('mail', "{$userid}@localhost") . Field_hidden('SenderCanonical', "{$us->SenderCanonical}"); $AmavisSettings = null; $changeemail = null; $button_recipient_features = null; $sender_settings = $EndOfLife; $EndOfLife = null; $button_recipient_features = $button_backup; $button_backup = null; } if (!$usermenus->JOOMLA_INSTALLED) { $joomla = null; } if ($as_connected_user) { $emule = null; $delete = null; $button_webdav = null; $deletedn = null; $PRIVILEGES = $PRIVILEGES_DISABLED; if (!$priv->AllowSenderCanonical) { $sender_settings = null; $recipients_translations = null; } if (!$priv->AllowChangeUserPassword && !$priv->AllowAddUsers) { $password = null; $button = null; } if (!$priv->AllowAddUsers) { $SystemInfoUser = $SystemInfoUser_disabled; $delete = $delete_disabled; $ChangeGuid = $changeuid_disabled; $joomla = null; $button_backup = null; $changeemail = null; $changeuid = $changeuid_disabled; $emule = null; $button_webdav = $button_webdav_disabled; $deletedn = $deletedn_disabled; $quotaDisk = $quotaDisk_disabled; } $loginShell = $loginShell_hidden; $domainName = $domainName_hidden; $EndOfLife = $EndOfLife_hidden; $simple_groupware_activation_admin = $simple_groupware_activation_user; $HomeBinding = null; } if (!$usermenus->MLDONKEY_INSTALLED) { $emule = null; } else { $sock = new sockets(); $EnableMLDonKey = trim($sock->GET_INFO("EnableMLDonKey")); if ($EnableMLDonKey == null) { $EnableMLDonKey = 1; } if ($EnableMLDonKey == 0) { $emule = null; } } if (!$priv->APACHE_MODE_WEBDAV) { $button_webdav = $button_webdav_disabled; } if (!$priv->QUOTA_INSTALLED) { $quotaDisk = $quotaDisk_disabled; } $moveorguser_grey = Paragraphe("user-move-64-grey.png", '{change_organization}', '{change_user_organization_text}', ""); if ($priv->AsSystemAdministrator) { $moveorguser = Paragraphe("user-move-64.png", '{change_organization}', '{change_user_organization_text}', "javascript:Loadjs('domains.edit.user.moveorg.php?userid={$userid}')"); } if ($us->AsActiveDirectoryMember) { $usermenus->EnableManageUsersTroughActiveDirectory = true; } if ($usermenus->EnableManageUsersTroughActiveDirectory) { $SystemInfoUser = $SystemInfoUser_disabled; $address = $address_disabled; $password = $password_disabled; $deletedn = $deletedn_disabled; $delete = $delete_disabled; $changeuid = $changeuid_disabled; $HomeBinding = $HomeBinding_grey; $moveorguser = $moveorguser_grey; $PRIVILEGES = $PRIVILEGES_DISABLED; $quotaDisk = $quotaDisk_disabled; } $tr[] = $PRIVILEGES; $tr[] = $SystemInfoUser; $tr[] = $loginShell; $tr[] = $domainName; $tr[] = $address; $tr[] = $HomeBinding; $tr[] = $delete; $tr[] = $deletedn; $tr[] = $password; $tr[] = $changeuid; $tr[] = $moveorguser; $tr[] = $EndOfLife; $tr[] = $button_webdav; $tr[] = $quotaDisk; $tr[] = $joomla; $tr[] = $simple_groupware_activation_admin; $tr[] = $button_backup; $tr[] = $emule; $tables_formatted = $tpl->_ENGINE_parse_body(CompileTr4($tr, true)); $DisplayName = $us->DisplayName; if (strlen($DisplayName) > 27) { $DisplayName = texttooltip(substr($DisplayName, 0, 24), $DisplayName, null, 1) . "..."; } if (strlen($us->jpegPhoto) > 0) { $array["img"] = $us->img_identity; } else { $array["img"] = "img/contact-unknown-user.png"; } $array["mail"] = $us->mail; $array["phone"] = $us->telephoneNumber; $array["sn"] = $us->sn; $array["displayname"] = $us->DisplayName; $array["givenname"] = $us->givenName; $array["JS"] = "javascript:s_PopUp('edit.thumbnail.php?uid={$us->uid}',600,300)"; $array["title"] = $us->title; $array["mobile"] = $us->mobile; $array["ou"] = $us->ou; $array["uid"] = $_GET["userid"]; $array["uidNumber"] = $us->uidNumber; $useridentity = finduser_format($array, true); $userid = urlencode($userid); $html = "\n\t\t<input type='hidden' id='delete_this_user' value='{delete_this_user}'>\n\t\t<form name='userLdapform'>\n\t\t<input type='hidden' name='ou' value='{$us->ou}'>\n\t\t<input type='hidden' name='SaveLdapUser' value='yes'>\n\t\t<input type='hidden' name='dn' value='{$us->dn}'>\n\t\t<input type='hidden' name='uid' id='uid' value='{$us->uid}'>\n\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td valign='top' style='vertical-align:top' style='vertical-align:top'>{$useridentity}</td>\n\t\t\t<td valign='top' style='vertical-align:top' style='vertical-align:top'><div id='userid-warning'></div></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<center>\n\t\t\n\t\t\t{$tables_formatted}\n\t\t</center>"; $html = "\n\t<div style='width:100%'>\n\t{$obm_info}\n\t{$html}\n\t</div>\n\t<script>\n\t\t\n\t\tLoadAjax('userid-warning','{$page}?userid-warning=yes&userid={$userid}&dn={$_GET["dn"]}');\n\t</script>\n\t"; writelogs("done", __FUNCTION__, __FILE__, __LINE__); return $tpl->_ENGINE_parse_body($html); }
function finduser() { header("Pragma: no-cache"); header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); $stringtofind = $_GET["finduser"]; writelogs("Want to search {$stringtofind}", __FUNCTION__, __FILE__); $tpl = new templates(); $usermenu = new usersMenus(); $ldap = new clladp(); if ($usermenu->AsAnAdministratorGeneric == true) { writelogs("It is an administrator search in the entire tree", __FUNCTION__, __FILE__); $hash_full = $ldap->UserSearch(null, $stringtofind); } else { $us = $ldap->UserDatas($_SESSION["uid"]); writelogs("It is an user search in the {$us["ou"]} tree", __FUNCTION__, __FILE__); $hash_full = $ldap->UserSearch($us["ou"], $stringtofind); } $hash1 = $hash_full[0]; $hash2 = $hash_full[1]; writelogs("Search results " . count($hash1) . " users and " . count($hash2) . " contacts", __FUNCTION__, __FILE__); $count = 0; if (is_array($hash1)) { while (list($num, $ligne) = each($hash1)) { if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { continue; } $hash[$count]["displayname"][0] = $ligne["displayname"][0]; $hash[$count]["givenname"][0] = $ligne["givenname"][0]; $hash[$count]["uid"][0] = $ligne["uid"][0]; $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0]; $hash[$count]["title"][0] = $ligne["title"][0]; $hash[$count]["uri"][0] = $ligne["uri"][0]; $hash[$count]["mail"][0] = $ligne["mail"][0]; $hash[$count]["phone"][0] = $ligne["telephonenumber"][0]; $hash[$count]["sn"][0] = $ligne["sn"][0]; $count = $count + 1; } } if (is_array($hash2)) { while (list($num, $ligne) = each($hash2)) { if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { continue; } $hash[$count]["displayname"][0] = $ligne["displayname"][0]; $hash[$count]["givenname"][0] = $ligne["givenname"][0]; $hash[$count]["uid"][0] = $ligne["uid"][0]; $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0]; $hash[$count]["title"][0] = $ligne["title"][0]; $hash[$count]["uri"][0] = $ligne["uri"][0]; $hash[$count]["mail"][0] = $ligne["mail"][0]; $hash[$count]["phone"][0] = $ligne["telephonenumber"][0]; $hash[$count]["sn"][0] = $ligne["sn"][0]; $count = $count + 1; } } $count = count($hash); writelogs("Search results {$count} items", __FUNCTION__, __FILE__); if (is_array($hash)) { while (list($num, $ligne) = each($hash)) { if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { continue; } if ($ligne["uid"][0] == "squidinternalauth") { $count = $count - 1; continue; } $edit_config_user = MEMBER_JS($ligne["uid"][0], 1); if ($usermenu->AllowAddUsers == true) { $uri = $edit_config_user; } else { $uri = null; } if ($usermenu->AsOrgAdmin == true) { $uri = $edit_config_user; } else { $uri = null; } if ($usermenu->AsArticaAdministrator == true) { $uri = $edit_config_user; } else { $uri = null; } $displayname = $ligne["displayname"][0]; $givenname = $ligne["givenname"][0]; $mail = $ligne["mail"][0]; if ($displayname == null) { $displayname = $ligne["uid"][0]; } if ($givenname == null) { $givenname = '{unknown}'; } if ($mail == null) { $mail = '{unknown}'; } if ($ligne["employeenumber"][0] != null) { $user = new contacts($_SESSION["uid"], $ligne["employeenumber"][0]); $array["title"] = $user->displayName; $uri = "javascript:Loadjs('contact.php?employeeNumber={$ligne["employeenumber"][0]}')"; } else { if ($ligne["uid"][0] != null) { $array["title"] = $ligne["uid"][0]; $user = new user($ligne["uid"][0]); } } if (strlen($user->jpegPhoto) > 0) { $array["img"] = $user->img_identity; } else { $array["img"] = "img/contact-unknown-user.png"; } writelogs("identity:{$user->img_identity} ", __FUNCTION__, __FILE__); $array["uri"] = $uri; $array["mail"] = $ligne["mail"][0]; $array["phone"] = $ligne["telephonenumber"][0]; $array["sn"] = $ligne["sn"][0]; if ($displayname == null) { $displayname = "{$givenname} {$ligne["sn"][0]}"; } $array["displayname"] = $displayname; $array["givenname"] = $givenname; $array["JS"] = $edit_config_user; $array["title"] = $ligne["title"][0]; $tr_users[] = finduser_format($array); } } $tables[] = "<table style='width:100%'><tr>"; $t = 0; while (list($key, $line) = each($tr_users)) { $line = trim($line); if ($line == null) { continue; } $t = $t + 1; $tables[] = "<td valign='top'>{$line}</td>"; if ($t == 2) { $t = 0; $tables[] = "</tr><tr>"; } } if ($t < 2) { for ($i = 0; $i <= $t; $i++) { $tables[] = "<td valign='top'> </td>"; } } $tables[] = "</table>"; $add = Paragraphe("my-address-book-user-add.png", '{add_new_contact}', '{add_new_contact_text}', "javascript:Loadjs('contact.php')"); if ($_SESSION["uid"] == -100) { $add = null; } $html = "<p style='font-size:18px'>{search}:«{$stringtofind}» ({$count} {entries})</p>\n\t\n\t<center>\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top'>" . implode("\n", $tables) . "\n\t\t\n\t</td>\n\t<td valign='top'>\n\t{$add}\n\t</td>\n\t</tr>\n\t</table>\n\t\n\t</center>"; echo $tpl->_ENGINE_parse_body($html); }
function finduser_list() { $keycached = "{$_GET["finduser"]}"; header("Pragma: no-cache"); header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); $GLOBALS["OUTPUT_DEBUG"] = false; $stringtofind = trim($_GET["finduser"]); if ($_POST["query"] != null) { $stringtofind = $_POST["query"]; } if (!isset($_POST["rp"])) { $_POST["rp"] = 15; } $users = new usersMenus(); $sock = new sockets(); $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory"); if (!is_numeric($EnableManageUsersTroughActiveDirectory)) { $EnableManageUsersTroughActiveDirectory = 0; } if (preg_match("#debug:(.+)#", $stringtofind, $re)) { $GLOBALS["OUTPUT_DEBUG"] = true; $stringtofind = trim($re[1]); } if ($GLOBALS["OUTPUT_DEBUG"]) { echo "Want to search {$stringtofind}<br>"; } $tpl = new templates(); $usermenu = new usersMenus(); $ldap = new clladp(); if (!$ldap->IsKerbAuth()) { if ($usermenu->AsAnAdministratorGeneric == true) { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "It is an administrator search in the entire tree<br>"; } $hash_full = $ldap->UserSearch(null, $stringtofind, $_POST["rp"]); } else { $us = $ldap->UserDatas($_SESSION["uid"]); if ($GLOBALS["OUTPUT_DEBUG"]) { echo "It is an user search in the {$us["ou"]} tree<br>"; } $hash_full = $ldap->UserSearch($us["ou"], $stringtofind, $_POST["rp"]); } $hash1 = $hash_full[0]; $hash2 = $hash_full[1]; if ($GLOBALS["OUTPUT_DEBUG"]) { echo "Search results " . count($hash1) . " users and " . count($hash2) . " contacts<br>"; } } else { include_once dirname(__FILE__) . "/ressources/class.external.ad.inc"; $ad = new external_ad_search(); $hash_full = $ad->UserSearch(null, $stringtofind, $_POST["rp"]); $hash1 = $hash_full[0]; $hash2 = $hash_full[1]; if ($GLOBALS["OUTPUT_DEBUG"]) { echo "Search results " . count($hash1) . " users and " . count($hash2) . " contacts<br>"; } } $hash = array(); $count = 0; $data = array(); $data['page'] = 1; $data['total'] = 0; $data['rows'] = array(); if (is_array($hash1)) { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "<strong>Search results ->HASH1</strong><br>\n"; } while (list($num, $ligne) = each($hash1)) { if (isset($ligne["samaccountname"][0])) { $ligne["uid"][0] = $ligne["samaccountname"][0]; } if ($ligne["uid"][0] == null) { if (preg_match("#^CN=(.+?),#i", $ligne["dn"], $re)) { $ligne["uid"][0] = $re[1]; $hash[$count]["displayname"][0] = $re[1]; } } if ($EnableManageUsersTroughActiveDirectory == 0) { if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { continue; } } if (strpos($ligne["dn"], "dc=pureftpd,dc=organizations") > 0) { continue; } $hash[$count]["displayname"][0] = trim($ligne["displayname"][0]); $hash[$count]["givenname"][0] = $ligne["givenname"][0]; if ($EnableManageUsersTroughActiveDirectory == 1) { $hash[$count]["uid"][0] = $ligne["samaccountname"][0]; } else { $hash[$count]["uid"][0] = $ligne["uid"][0]; } if (substr($hash[$count]["uid"][0], strlen($hash[$count]["uid"][0]) - 1, 1) == '$') { continue; } $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0]; $hash[$count]["title"][0] = $ligne["title"][0]; $hash[$count]["uri"][0] = $ligne["uri"][0]; $hash[$count]["mail"][0] = $ligne["mail"][0]; $hash[$count]["phone"][0] = $ligne["telephonenumber"][0]; $hash[$count]["sn"][0] = $ligne["sn"][0]; $hash[$count]["dn"] = $ligne["dn"]; $count++; } } else { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "<strong>Search results ->HASH1 NOT AN ARRAY</strong><br>\n"; } } if (is_array($hash2)) { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "<strong>Search results ->HASH2</strong><br>\n"; } while (list($num, $ligne) = each($hash2)) { if (isset($ligne["samaccountname"][0])) { $ligne["uid"][0] = $ligne["samaccountname"][0]; } if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { continue; } if (strpos($ligne["dn"], "dc=pureftpd,dc=organizations") > 0) { continue; } $hash[$count]["displayname"][0] = $ligne["displayname"][0]; $hash[$count]["givenname"][0] = $ligne["givenname"][0]; $hash[$count]["uid"][0] = $ligne["uid"][0]; $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0]; $hash[$count]["title"][0] = $ligne["title"][0]; $hash[$count]["uri"][0] = $ligne["uri"][0]; $hash[$count]["mail"][0] = $ligne["mail"][0]; $hash[$count]["phone"][0] = $ligne["telephonenumber"][0]; $hash[$count]["sn"][0] = $ligne["sn"][0]; $hash[$count]["dn"] = $ligne["dn"]; $count = $count + 1; } } else { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "<strong>Search results ->HASH2 NOT AN ARRAY</strong><br>\n"; } } $count = count($hash); $data['total'] = $count; if ($count == 0) { json_error_show("no data", 1); } if ($GLOBALS["OUTPUT_DEBUG"]) { echo "<strong>Search results {$count} items</strong><br>\n"; } if (is_array($hash)) { while (list($num, $ligne) = each($hash)) { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "dn:{$ligne["dn"]}<br>"; } if ($GLOBALS["OUTPUT_DEBUG"]) { echo "uid:{$ligne["uid"][0]}<br>"; } if ($GLOBALS["OUTPUT_DEBUG"]) { echo "employeenumber:{$ligne["employeenumber"][0]}<br>"; } if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) { if ($GLOBALS["OUTPUT_DEBUG"]) { echo "null twice, aborting...<br>"; } continue; } if ($ligne["uid"][0] == "squidinternalauth") { $count = $count - 1; continue; } if ($GLOBALS["OUTPUT_DEBUG"]) { echo "edit_config_user={$ligne["uid"][0]}<br>"; } $edit_config_user = MEMBER_JS($ligne["uid"][0], 1, 0, $ligne["dn"]); if ($usermenu->AllowAddUsers == true) { $uri = $edit_config_user; } else { $uri = null; } if ($usermenu->AsOrgAdmin == true) { $uri = $edit_config_user; } else { $uri = null; } if ($usermenu->AsArticaAdministrator == true) { $uri = $edit_config_user; } else { $uri = null; } $displayname = trim($ligne["displayname"][0]); $givenname = $ligne["givenname"][0]; $mail = $ligne["mail"][0]; if ($displayname == null) { $displayname = $ligne["uid"][0]; } if ($givenname == null) { $givenname = '{unknown}'; } if ($mail == null) { $mail = '{unknown}'; } if ($ligne["employeenumber"][0] != null) { $array["employeenumber"] = $ligne["employeenumber"][0]; $user = new contacts($_SESSION["uid"], $ligne["employeenumber"][0]); $array["title"] = $user->displayName; $uri = "javascript:Loadjs('contact.php?employeeNumber={$ligne["employeenumber"][0]}')"; } else { if ($ligne["uid"][0] != null) { $array["title"] = $ligne["uid"][0]; $user = new user($ligne["uid"][0]); } } if (strlen($user->jpegPhoto) > 0) { $array["img"] = $user->img_identity; } else { $array["img"] = "img/contact-unknown-user.png"; } writelogs("identity:{$user->img_identity} ", __FUNCTION__, __FILE__); $array["uri"] = $uri; $array["mail"] = $ligne["mail"][0]; $array["phone"] = $ligne["telephonenumber"][0]; $array["sn"] = $ligne["sn"][0]; if (!$ldap->EnableManageUsersTroughActiveDirectory) { if ($displayname == null) { $displayname = "{$givenname} {$ligne["sn"][0]}"; } } $array["displayname"] = $displayname; $array["givenname"] = $givenname; $array["JS"] = $edit_config_user; $array["title"] = $ligne["title"][0]; $array["ou"] = $user->ou; $array["uid"] = $ligne["uid"][0]; $data['rows'][] = finduser_format($array); } } echo json_encode($data); }
function finduser(){ $keycached="{$_GET["finduser"]}"; if(GET_CACHED(__FILE__,__FUNCTION__,$keycached)){return null;} header("Pragma: no-cache"); header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); $GLOBALS["OUTPUT_DEBUG"]=false; $stringtofind=trim($_GET["finduser"]); $users=new usersMenus(); if(preg_match("#debug:(.+)#",$stringtofind,$re)){ $GLOBALS["OUTPUT_DEBUG"]=true; $stringtofind=trim($re[1]); } if($GLOBALS["OUTPUT_DEBUG"]){echo "Want to search $stringtofind<br>";} $tpl=new templates(); $usermenu=new usersMenus(); $ldap=new clladp(); if($usermenu->AsAnAdministratorGeneric==true){ if($GLOBALS["OUTPUT_DEBUG"]){echo "It is an administrator search in the entire tree<br>";} $hash_full=$ldap->UserSearch(null,$stringtofind); }else{ $us=$ldap->UserDatas($_SESSION["uid"]); if($GLOBALS["OUTPUT_DEBUG"]){echo "It is an user search in the {$us["ou"]} tree<br>";} $hash_full=$ldap->UserSearch($us["ou"],$stringtofind); } $hash1=$hash_full[0]; $hash2=$hash_full[1]; if($GLOBALS["OUTPUT_DEBUG"]){echo "Search results ".count($hash1) ." users and ".count($hash2)." contacts<br>";} $hash=array(); $count=0; if(is_array($hash1)){ while (list ($num, $ligne) = each ($hash1) ){ if(!$ldap->EnableManageUsersTroughActiveDirectory){ if(($ligne["uid"][0]==null) && ($ligne["employeenumber"][0]==null)){continue;}} if(strpos($ligne["dn"],"dc=pureftpd,dc=organizations")>0){continue;} $hash[$count]["displayname"][0]=trim($ligne["displayname"][0]); $hash[$count]["givenname"][0]=$ligne["givenname"][0]; if($ldap->EnableManageUsersTroughActiveDirectory){ $hash[$count]["uid"][0]=$ligne["samaccountname"][0]; }else{ $hash[$count]["uid"][0]=$ligne["uid"][0]; } if(substr($hash[$count]["uid"][0],strlen($hash[$count]["uid"][0])-1,1)=='$'){continue;} $hash[$count]["employeenumber"][0]=$ligne["employeenumber"][0]; $hash[$count]["title"][0]=$ligne["title"][0]; $hash[$count]["uri"][0]=$ligne["uri"][0]; $hash[$count]["mail"][0]=$ligne["mail"][0]; $hash[$count]["phone"][0]=$ligne["telephonenumber"][0]; $hash[$count]["sn"][0]=$ligne["sn"][0]; $hash[$count]["dn"]=$ligne["dn"]; $count++; }} if(is_array($hash2)){ while (list ($num, $ligne) = each ($hash2) ){ if(($ligne["uid"][0]==null) && ($ligne["employeenumber"][0]==null)){continue;} if(strpos($ligne["dn"],"dc=pureftpd,dc=organizations")>0){continue;} $hash[$count]["displayname"][0]=$ligne["displayname"][0]; $hash[$count]["givenname"][0]=$ligne["givenname"][0]; $hash[$count]["uid"][0]=$ligne["uid"][0]; $hash[$count]["employeenumber"][0]=$ligne["employeenumber"][0]; $hash[$count]["title"][0]=$ligne["title"][0]; $hash[$count]["uri"][0]=$ligne["uri"][0]; $hash[$count]["mail"][0]=$ligne["mail"][0]; $hash[$count]["phone"][0]=$ligne["telephonenumber"][0]; $hash[$count]["sn"][0]=$ligne["sn"][0]; $hash[$count]["dn"]=$ligne["dn"]; $count=$count+1; }} $count=count($hash); writelogs("Search results $count items" ,__FUNCTION__,__FILE__); if(is_array($hash)){ while (list ($num, $ligne) = each ($hash) ){ if($GLOBALS["OUTPUT_DEBUG"]){echo "dn:{$ligne["dn"]}<br>";} if($GLOBALS["OUTPUT_DEBUG"]){echo "uid:{$ligne["uid"][0]}<br>";} if($GLOBALS["OUTPUT_DEBUG"]){echo "employeenumber:{$ligne["employeenumber"][0]}<br>";} if(($ligne["uid"][0]==null) && ($ligne["employeenumber"][0]==null)){ if($GLOBALS["OUTPUT_DEBUG"]){echo "null twice, aborting...<br>";} continue; } if($ligne["uid"][0]=="squidinternalauth"){$count=$count-1;continue;} if($GLOBALS["OUTPUT_DEBUG"]){echo "edit_config_user={$ligne["uid"][0]}<br>";} $edit_config_user=MEMBER_JS($ligne["uid"][0],1,0,$ligne["dn"]); if($usermenu->AllowAddUsers==true){$uri=$edit_config_user;}else{$uri=null;} if($usermenu->AsOrgAdmin==true){$uri=$edit_config_user;}else{$uri=null;} if($usermenu->AsArticaAdministrator==true){$uri=$edit_config_user;}else{$uri=null;} $displayname=trim($ligne["displayname"][0]); $givenname=$ligne["givenname"][0]; $mail=$ligne["mail"][0]; if($displayname==null){$displayname=$ligne["uid"][0];} if($givenname==null){$givenname='{unknown}';} if($mail==null){$mail='{unknown}';} if($ligne["employeenumber"][0]<>null){ $user=new contacts($_SESSION["uid"],$ligne["employeenumber"][0]); $array["title"]=$user->displayName; $uri="javascript:Loadjs('contact.php?employeeNumber={$ligne["employeenumber"][0]}')"; }else{ if($ligne["uid"][0]<>null){ $array["title"]=$ligne["uid"][0]; $user=new user($ligne["uid"][0]); } } if(strlen($user->jpegPhoto)>0){$array["img"]=$user->img_identity;}else{$array["img"]="img/contact-unknown-user.png";} writelogs("identity:$user->img_identity ",__FUNCTION__,__FILE__); $array["uri"]=$uri; $array["mail"]=$ligne["mail"][0];; $array["phone"]=$ligne["telephonenumber"][0]; $array["sn"]=$ligne["sn"][0]; if(!$ldap->EnableManageUsersTroughActiveDirectory){ if($displayname==null){$displayname="$givenname {$ligne["sn"][0]}";} } $array["displayname"]=$displayname; $array["givenname"]=$givenname; $array["JS"]=$edit_config_user; $array["title"]=$ligne["title"][0];;; $tr_users[]=finduser_format($array); } } $tables[]="<table style='width:100%'><tr>"; $t=0; while (list ($key, $line) = each ($tr_users) ){ $line=trim($line); if($line==null){continue;} $t=$t+1; $tables[]="<td valign='top'>$line</td>"; if($t==2){$t=0;$tables[]="</tr><tr>";} } if($t<2){ for($i=0;$i<=$t;$i++){ $tables[]="<td valign='top'> </td>"; } } $tables[]="</table>"; $add=Paragraphe("my-address-book-user-add.png",'{add_new_contact}','{add_new_contact_text}',"javascript:Loadjs('contact.php')"); if($_SESSION["uid"]==-100){$add=null;} $html="<p style='font-size:18px'>{search}:«$stringtofind» ($count {entries})</p> <center> <table style='width:100%'> <tr> <td valign='top'>". implode("\n",$tables). " </td> <td valign='top'> $add </td> </tr> </table> </center>"; $html=$tpl->_ENGINE_parse_body($html); SET_CACHED(__FILE__,__FUNCTION__,$keycached,$html); echo $html; }