*/ /** * Display functions, for multiple and single tables output. */ /** * Display HTML results from an LDAP query in multiple tables. * * @param array $attributes The list of attributes to display * @param array $entry The entries array from the ldap_get_entries search result * @param string $sortby * @return void */ function directory_dispresultsMulti ($attributes, $entry, $sortby) { global $languages, $data_dir, $username, $compose_new_win, $base_uri, $color, $ldq_attributes, $ldq_lang, $charset, $orgs, $popup, $ldq_enablemailalternate, $ldq_privacy_attribute, $ldq_privacy_url, $ldq_skip_empty_attributes; if ($entry['count'] == 0) { print _("No records found") . "
\n"; return; } /** * sort the entries. First, build an array with the sortby as the key and * the entry index as the value */ for ($i=0 ; $i < $entry['count']; $i++) { $Val = $entry[$i][$sortby][0] . $i; $sorted[$Val] = $i; } if ($sortby == 'cn') { uksort ($sorted, 'directory_compcns'); } else { uksort ($sorted, 'directory_compattrs'); } /** * Print the table! */ foreach ($sorted as $key=>$i) { /** * LDAP Privacy attribute, if it is set. * Gather all attributes to be private, in array $privateattrs. */ if(!empty($ldq_privacy_attribute)) { if(isset($entry[$i][$ldq_privacy_attribute])) { for($l=0; $l<$entry[$i][$ldq_privacy_attribute]['count']; $l++) { $privateattrs[] = strtolower($entry[$i][$ldq_privacy_attribute][$l]); } } else { $privateattrs = array(); } } print ''; foreach ($attributes as $attr) { if(empty($entry[$i][$attr]) && $ldq_skip_empty_attributes) { continue; } print ''. '
'. ''.$ldq_attributes[$attr]['text'].''; if(isset($entry[$i][$attr])) { directory_print_attribute($attr, $entry[$i], $privateattrs); } /** END **/ } print "
\n
"; } } /** * Display HTML results from an LDAP query with each record being one row in * a single table. * * @param array $attributes The list of attributes to display * @param array $entry The entries array from the ldap_get_entries search result * @param string $sortby * @param array $secondary * @return void */ function directory_dispresultsSingle ($attributes, &$entry, $sortby, $secondary = '') { global $languages, $data_dir, $username, $compose_new_win, $plugins, $base_uri, $color, $ldq_attributes, $ldq_lang, $charset, $ldq_enablemailalternate, $location, $follow, $orgs, $formname, $inputname, $popup, $ldq_privacy_attribute, $ldq_privacy_url, $ldq_standalone; if ($entry['count'] == 0) { print _("No records found") . "
\n"; return; } /** * sort the entries. * First, build an array with the sortby as the key and the entry index * as the value. */ if($entry['count'] == 1) { $sorted[$entry[0][$sortby][0]] = 0; } else { for ($i=0; $i<$entry['count']; $i++) { $Val = $entry[$i][$sortby][0] . $i; $sorted[$Val] = $i; } if ($sortby == 'cn') { uksort ($sorted, 'directory_compcns'); } else { uksort ($sorted, 'directory_compattrs'); } } /** * Table Header */ print ''; print ''; if(isset($popup)) { print ''; } print ''; foreach ($attributes as $attr) { // $Var = "directory_showattr_" . $attr; // global $$Var; // if ($$Var == "on") print ''; } /* Header for AddACL stuff (useracl plugin) */ if(in_array('useracl', $plugins) && !isset($popup)) { print ''; } print ''; $toggle = false; /** * Table content */ foreach ($sorted as $key=>$i) { /** * LDAP Privacy attribute, if it is set. * Gather all attributes to be private, in array $privateattrs. */ $privateattrs = array(); if(!empty($ldq_privacy_attribute)) { if(isset($entry[$i][$ldq_privacy_attribute])) { for($l=0; $l<$entry[$i][$ldq_privacy_attribute]['count']; $l++) { $privateattrs[] = strtolower($entry[$i][$ldq_privacy_attribute][$l]); } } } /** * Start Printing */ print ''; if(isset($popup)) { if(isset($entry[$i]['mail'][0])) { $email = $entry[$i]['mail'][0]; $userid = $entry[$i]['uid'][0]; if(!empty($formname)) { if($formname != 'compose' && isset($inputname)) { /* Parent form was something other than * compose, e.g. useracl */ print html_tag( 'td', ''. '"._("Add").""); } else { /* Parent form was compose.php */ print html_tag( 'td', ''. 'To | " . 'Cc | " . 'Bcc", 'center', '', ' width="5%" nowrap' ); } } } else { print ''; } } /* VCard HyperLink */ print ''; /* Values!! */ foreach ($attributes as $attr) { // $Var = "directory_showattr_" . $attr; // global $$Var; // if ($$Var == "on") { print ''; // } } /* Shares */ if(in_array('useracl', $plugins) && !isset($popup)) { echo ''; } print "\n"; if(!$toggle) { $toggle = true; } elseif($toggle) { $toggle = false; } } print "
'.$ldq_attributes[$attr]['text'].''. _("Add Share") .'
'; if(!empty($entry[$i]['uid'][0])) { if($ldq_standalone) { $vcard_uri = 'vcard.php?uid='.urlencode($entry[$i]['uid'][0]); print 'VCard'; } else { $vcard_link = 'vcard.php?uid='.urlencode($entry[$i]['uid'][0]); $vcard_uri = 'plugins/directory/'.$vcard_link; print 'VCard'; } } print ''; directory_print_attribute($attr, $entry[$i], $privateattrs); print ''; $acl_uri = 'plugins/useracl/addacl.php?user='.$entry[$i]['uid'][0].'&addacl=1'; $disp = ''; print makeComposeLink($acl_uri, $disp); print '
\n"; } /** * Print value of an attribute. To be used inside a table cell. * * @param string $attr * @param array $values A single object entry, as returned by ldap_get_entries() * (with 'count' key). For instance, $entry = $entries[$i]. * @param array $privateattrs * @return void * * @see directory_print_href() */ function directory_print_attribute($attr, $entry, $privateattrs = array()) { global $ldq_privacy_url, $ldq_enablemailalternate, $ldq_attributes, $ldq_lang, $charset, $orgs, $popup, $formname, $inputname, $ldq_standalone; /* Just print a line break if there is no entry. */ if (!array_key_exists($attr, $entry) || ( array_key_exists($attr, $entry) && ($entry[$attr]['count'] == 0)) ) { echo '
'; return; } if(in_array($attr, $privateattrs)) { /* Don't show since user wants to keep it private */ if(isset($ldq_privacy_url) && !empty($ldq_privacy_url)) { echo ''; } echo ''._( '. _("Private"); if(isset($ldq_privacy_url) && !empty($ldq_privacy_url)) { echo ''; } } else { $uri_xtra = ''; if(isset($popup) && $popup == 1) { $uri_xtra = 'popup=1'; if(!empty($formname)) { $uri_xtra = '&formname='.$formname; } if(!empty($inputname)) { $uri_xtra = '&inputname='.$inputname; } } for ($x=0 ; $x < $entry[$attr]['count'] ; $x++) { switch ($attr) { case 'labeleduri': /* split up url and label parts */ echo directory_print_labeledurl($entry[$attr][$x]); break; case 'mail': $val = $entry[$attr][$x]; echo directory_href('mail', $val); if($ldq_enablemailalternate == true) { if(isset ($entry['mailalternateaddress']['count']) && ($entry['mailalternateaddress']['count'] > 0 )) { for($k=0; $k<$entry['mailalternateaddress']['count']; $k++) { echo "
"; $val2 = $entry['mailalternateaddress'][$k]; echo directory_href('mail', $val2); echo ''; } } } break; case 'cn': $val = $entry[$attr][$x]; $vcard_uri = SM_PATH . 'plugins/directory/vcard.php?uid='.urlencode($entry['uid'][0]); echo ''.$val.''; break; default: /* Use language attribute value, if it is available */ $attr_lang = $attr.';lang-'.$ldq_lang; if(array_key_exists($attr_lang, $entry) && !empty($entry[$attr_lang][$x]) && ($entry[$attr_lang][$x] != " ") ) { $val = directory_string_convert($entry[$attr_lang][$x], "UTF-8", $charset); } else { $val = $entry[$attr][$x]; } if(isset($ldq_attributes[$attr]['map'])) { $val = $ldq_attributes[$attr]['map'][trim($val)]; } if($attr == 'edupersonaffiliation') { if(isset($entry['edupersonprimaryaffiliation'][0]) && $entry['edupersonprimaryaffiliation'][0] == $entry[$attr][$x]) { $important = true; } } if($attr == 'edupersonorgunitdn') { if(isset($entry['edupersonprimaryorgunitdn'][0]) && $entry['edupersonprimaryorgunitdn'][0] == $entry[$attr][$x]) { $important = true; } } if(isset($ldq_attributes[$attr]['followme'])) { $val = strtolower($val); if(isset($follow[$val])) { $val = directory_href($attr, $val, $uri_xtra, $follow[$val]); } elseif(isset($orgs[$val])) { $val = directory_href($attr, $val, $uri_xtra, ( isset($orgs[$val]['struct']) ? '' . $orgs[$val]['struct'] . ' ' : '' ) . $orgs[$val]['text']); } else { $val = ''; } } else { if(isset($ldq_attributes[$attr]['url'])) { $val = directory_href($attr, $val); } } if(isset($important)) { $val = ''.$val.''; unset($important); } echo $val . "
"; } } } } ?>