Exemplo n.º 1
0
function tag_cloud()
{
    global $conf;
    global $LDAP_CON;
    global $FIELDS;
    if (!$FIELDS['_marker']) {
        return;
    }
    $result = ldap_queryabooks('(objectClass=inetOrgPerson)', $FIELDS['_marker']);
    $max = 0;
    $min = 999999999;
    $tags = array();
    foreach ($result as $entry) {
        if (!empty($entry[$FIELDS['_marker']]) && count($entry[$FIELDS['_marker']])) {
            foreach ($entry[$FIELDS['_marker']] as $marker) {
                $marker = strtolower($marker);
                if (empty($tags[$marker])) {
                    $tags[$marker] = 0;
                }
                $tags[$marker] += 1;
                if ($tags[$marker] > $max) {
                    $max = $tags[$marker];
                }
                if ($tags[$marker] < $min) {
                    $min = $tags[$marker];
                }
            }
        }
    }
    ksort($tags);
    tag_cloud_weight(&$tags, $min, $max, 6);
    $out = '';
    foreach ($tags as $tag => $cnt) {
        $out .= '<a href="index.php?marker=' . rawurlencode($tag) . '" class="cloud_' . $cnt . '">';
        $out .= htmlspecialchars($tag) . '</a> ';
    }
    return $out;
}
Exemplo n.º 2
0
require_once 'inc/init.php';
ldap_login();
// select entry template
if (!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv') {
    $entrytpl = 'list_csv_entry.tpl';
} elseif (!empty($_REQUEST['export']) && $_REQUEST['export'] == 'map') {
    $entrytpl = 'list_map_entry.tpl';
} else {
    $entrytpl = 'list_entry.tpl';
}
// check which fields are needed
$fields = get_fields_from_template($entrytpl);
//prepare filter
$ldapfilter = _makeldapfilter();
// fetch results
$result = ldap_queryabooks($ldapfilter, $fields);
$list = '';
if (count($result) == 1 && $_REQUEST['search']) {
    //only one result on a search -> display page
    header("Location: entry.php?dn=" . rawurlencode($result[0]['dn']));
    exit;
} elseif (count($result)) {
    $keys = array_keys($result);
    uksort($keys, "_namesort");
    foreach ($keys as $key) {
        tpl_entry($result[$key]);
        $list .= $smarty->fetch($entrytpl);
    }
}
//prepare templates
tpl_std();
Exemplo n.º 3
0
/**
 * Assigns all distinct organization names to the template
 */
function tpl_orgs()
{
    global $conf;
    global $LDAP_CON;
    global $smarty;
    global $FIELDS;
    $orgs = array();
    $result = ldap_queryabooks("ObjectClass=inetOrgPerson", array($FIELDS['organization']));
    if (count($result)) {
        foreach ($result as $entry) {
            if (!empty($entry[$FIELDS['organization']][0])) {
                array_push($orgs, $entry[$FIELDS['organization']][0]);
            }
        }
    }
    $orgs = array_unique($orgs);
    natcasesort($orgs);
    $smarty->assign('orgs', $orgs);
}
Exemplo n.º 4
0
/**
 * Do a simple lookup in any simple field
 */
function ajax_lookup($field, $search)
{
    header('Content-Type: text/xml; charset=utf-8');
    global $conf;
    global $LDAP_CON;
    global $FIELDS;
    if (!$FIELDS[$field]) {
        return;
    }
    $field = $FIELDS[$field];
    $search = ldap_filterescape($search);
    $filter = "(&(objectClass=inetOrgPerson)({$field}={$search}*))";
    $result = ldap_queryabooks($filter, $field);
    if (!count($result)) {
        return;
    }
    $items = array();
    foreach ($result as $entry) {
        if (isset($entry[$field]) && !empty($entry[$field])) {
            $items[] = $entry[$field][0];
        }
    }
    $items = array_unique($items);
    sort($items, SORT_STRING);
    echo '<?xml version="1.0"?>' . NL;
    echo '<ajaxresponse>' . NL;
    foreach ($items as $out) {
        echo '<item>' . NL;
        echo '<value>' . htmlspecialchars($out) . '</value>' . NL;
        echo '<text>' . htmlspecialchars($out) . '</text>' . NL;
        echo '</item>' . NL;
    }
    echo '</ajaxresponse>' . NL;
}