* Licensed under the GNU GPL. For full terms see the file COPYING. * * $Id: display.php,v 1.1.1.1 2004/01/02 16:00:18 avel Exp $ * * @package plugins * @subpackage directory */ /** * 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 */ function directory_dispresultsMulti ($attributes, $entry, $sortby) { global $languages, $data_dir, $username, $compose_new_win, $base_uri, $color, $ldq_attributes, $ldq_lang, $charset, $ldq_enablemailalternate; 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"); foreach ($sorted as $key=>$i) { print ''; foreach ($attributes as $attr) { for ($x=0 ; $x < $entry[$i][$attr]["count"] ; $x++) { // print one row of table of attr/value pairs // print attribute cell print '"; } } } print "
'.$ldq_attributes[$attr]['text'].''; switch ($attr) { case "labeledurl": /* split up url and label parts */ print directory_print_labeledurl($entry[$i][$attr][$x]); break; case "mail": $val = $entry[$i][$attr][$x]; print directory_href('mail', $val); if($ldq_enablemailalternate == true) { if(isset ($entry[$i]['mailalternateaddress']['count']) && ($entry[$i]['mailalternateaddress']['count'] > 0 )) { for($k=0; $k<$entry[$i]['mailalternateaddress']['count']; $k++) { print "
"; $val2 = $entry[$i]['mailalternateaddress'][$k]; print directory_href('mail', $val2); print ''; } } } break; default: $attr_lang = $attr.';lang-'.$ldq_lang; if(array_key_exists($attr_lang, $entry[$i]) && !is_null($entry[$i][$attr_lang][$x]) && ($entry[$i][$attr_lang][$x] != " ") ) { $val = directory_string_convert($entry[$i][$attr_lang][$x], "UTF-8", $charset); } else { $val = $entry[$i][$attr][$x]; } print "$val
"; 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 */ 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; 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"); /** Table Header */ print ''; print ''; if(isset($popup)) { 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 contents */ foreach ($sorted as $key=>$i) { print ''; if(isset($popup)) { if(isset($entry[$i]['mail'][0])) { $email = $entry[$i]['mail'][0]; $userid = $entry[$i]['uid'][0]; if(isset($formname) && 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 ''; } } 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 (!array_key_exists($attr, $entry[$i]) || ( array_key_exists($attr, $entry[$i]) && ($entry[$i][$attr]["count"] == 0)) ) { print '
'; } if (array_key_exists($attr, $entry[$i])) { for ($x=0 ; $x < $entry[$i][$attr]["count"] ; $x++) { switch ($attr) { case "labeledurl": /* split up url and label parts */ print directory_print_labeledurl($entry[$i][$attr][$x]); break; case "mail": $val = $entry[$i][$attr][$x]; print directory_href('mail', $val); if($ldq_enablemailalternate == true) { if(isset ($entry[$i]['mailalternateaddress']['count']) && ($entry[$i]['mailalternateaddress']['count'] > 0 )) { for($k=0; $k<$entry[$i]['mailalternateaddress']['count']; $k++) { print "
"; $val2 = $entry[$i]['mailalternateaddress'][$k]; print directory_href('mail', $val2); print ''; } } } break; default: /* Use language attribute value, if it is available */ $attr_lang = $attr.';lang-'.$ldq_lang; if(array_key_exists($attr_lang, $entry[$i]) && !empty($entry[$i][$attr_lang][$x]) && ($entry[$i][$attr_lang][$x] != " ") ) { $val = directory_string_convert($entry[$i][$attr_lang][$x], "UTF-8", $charset); } else { $val = $entry[$i][$attr][$x]; } if(isset($ldq_attributes[$attr]['map'])) { $val = $ldq_attributes[$attr]['map'][trim($val)]; } if($attr == 'edupersonaffiliation') { if(isset($entry[$i]['edupersonprimaryaffiliation'][0]) && $entry[$i]['edupersonprimaryaffiliation'][0] == $entry[$i][$attr][$x]) { $important = true; } } if($attr == 'edupersonorgunitdn') { if(isset($entry[$i]['edupersonprimaryorgunitdn'][0]) && $entry[$i]['edupersonprimaryorgunitdn'][0] == $entry[$i][$attr][$x]) { $important = true; } } if(isset($ldq_attributes[$attr]['followme'])) { // print "running directory_href($attr, $val, ".$follow[$val] . ")"; if(isset($follow[$val])) { $val = directory_href($attr, $val, $follow[$val]); } elseif(isset($orgs[$val])) { $val = directory_href($attr, $val, '' . $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); } print $val . "
"; } } } print '
'; $acl_uri = 'plugins/useracl/addacl.php?user='.$entry[$i]['uid'][0].'&addacl=1'; $disp = ''; print makeComposeLink($acl_uri, $disp); print '
\n"; } ?>