/** * assigns all countries to the template */ function tpl_country() { global $conf; global $LDAP_CON; global $smarty; if (!$conf['openxchange']) { return; } $country = array(); $sr = ldap_list($LDAP_CON, $conf['publicbook'], "ObjectClass=OXUserObject", array("userCountry")); $result1 = ldap_get_binentries($LDAP_CON, $sr); //check users private addressbook if (!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']) { $sr = @ldap_list($LDAP_CON, $conf['privatebook'] . ',' . $_SESSION['ldapab']['binddn'], "ObjectClass=OXUserObject", array("userCountry")); $result2 = ldap_get_binentries($LDAP_CON, $sr); } $result = array_merge((array) $result1, (array) $result2); if (count($result)) { foreach ($result as $entry) { if (count($entry['userCountry'])) { foreach ($entry['userCountry'] as $c) { array_push($country, $c); } } } } $country = array_unique($country); sort($country, SORT_STRING); $smarty->assign('country', $country); }
/** * Queries public and private addressbooks, combining the * results * * @todo This function should be used where ever possible, replacing * lots of duplicate code */ function ldap_queryabooks($filter, $types) { global $conf; global $LDAP_CON; // make sure $types is an array if (!is_array($types)) { $types = explode(',', $types); $types = array_map('trim', $types); } $results = array(); $result1 = array(); $result2 = array(); $result3 = array(); // public addressbook $sr = @ldap_list($LDAP_CON, $conf['publicbook'], $filter, $types); tpl_ldaperror(); $result1 = ldap_get_binentries($LDAP_CON, $sr); ldap_free_result($sr); // private addressbook if (!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']) { $sr = @ldap_list($LDAP_CON, $conf['privatebook'] . ',' . $_SESSION['ldapab']['binddn'], $filter, $types); if (ldap_errno($LDAP_CON) != 32) { tpl_ldaperror(); } // ignore missing address book $result2 = ldap_get_binentries($LDAP_CON, $sr); } // user account entries if ($conf['displayusertree']) { $sr = @ldap_list($LDAP_CON, $conf['usertree'], $filter, $types); tpl_ldaperror(); $result3 = ldap_get_binentries($LDAP_CON, $sr); ldap_free_result($sr); } // return merged results return array_merge((array) $result1, (array) $result2, (array) $result3); }
<?php require_once 'inc/init.php'; ldap_login(); if ($conf['userlogreq'] && !isset($_SESSION['ldapab']['username'])) { header("HTTP/1.0 401 Access Denied"); echo '<h1>Access Denied</h1>'; exit; } $dn = $_REQUEST['dn']; $sr = ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)', array($FIELDS['photo'])); if (!ldap_count_entries($LDAP_CON, $sr)) { header("HTTP/1.0 404 Not Found"); echo '<h1>Not Found</h1>'; exit; } $result = ldap_get_binentries($LDAP_CON, $sr); $entry = $result[0]; header("Content-type: image/jpeg"); print $entry[$FIELDS['photo']][0];
/** * Load current tags of an entry */ function ajax_loadtags($dn, $type = 'plain') { global $conf; global $LDAP_CON; global $FIELDS; if (!$FIELDS['_marker']) { return; } header('Content-Type: text/html; charset=utf-8'); $sr = ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)', array($FIELDS['_marker'])); if (!ldap_count_entries($LDAP_CON, $sr)) { return false; } $result = ldap_get_binentries($LDAP_CON, $sr); $entry = $result[0]; if ($type == 'plain') { echo join(', ', (array) $entry[$FIELDS['_marker']]); } else { foreach ((array) $entry[$FIELDS['_marker']] as $tag) { echo '<a href="index.php?marker='; echo rawurlencode($tag); echo '" class="tag">'; echo htmlspecialchars($tag); echo '</a> '; } } }
/** * fetches the Data from the LDAP directory and assigns it to * the global smarty object using tpl_entry() */ function _fetchData($dn) { global $LDAP_CON; global $conf; global $smarty; global $users; //contains the users for manager role $sr = @ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)'); tpl_ldaperror(); if (!@ldap_count_entries($LDAP_CON, $sr)) { return false; } $result = ldap_get_binentries($LDAP_CON, $sr); $entry = $result[0]; //remove dn from entry when copy if (!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'copy') { $entry['dn'] = ''; } //assign entry to template: tpl_entry($entry); /*print '<pre>'; print_r($entry); print '</pre>';*/ // make username from dn for manager: if (empty($entry['manager'])) { $entry['manager'] = array(""); } if (empty($users[$entry['manager'][0]])) { $users[$entry['manager'][0]] = ''; } $smarty->assign('managername', $users[$entry['manager'][0]]); return true; }