2 class ldap_entry_attribute {
3 var $name, $values, $parent;
4 cfunction ldap_entry_attribute($d) {
5 // echo "creating new ldap_entry_attribtute<br>\n";
7 $a = ldap_explode_dn($this->dn, 1);
11 cfunction getAttributeName($string) {
13 for ($i=0; $i<count($prefs->attribute_names); $i++) {
14 if ($prefs->attribute_names[$i][0] == $string) {
15 return $prefs->attribute_names[$i][1];
20 cfunction isVisible($string) {
22 for ($i=0; $i<count($prefs->attribute_names); $i++) {
23 if ($prefs->attribute_names[$i][0] == $string) {
24 return $prefs->attribute_names[$i][2];
30 cfunction getValues($l_i, $r_e_i) {
31 //echo "My name is ".$this->name."<br>\n";
32 $this->values = ldap_get_values($l_i, $r_e_i, $this->name);
36 echo "<tr>\n\t<td valign=top bgcolor=white>\n";
37 echo "\t\t".$this->name."\n\t\t</td>\n\t<td valign=top bgcolor=lightyellow>\n";
38 echo "<ul type=square>\n";
39 for($i=0; $i<$this->values["count"]; $i++) {
40 //echo "Displaying value ".$i."<br>\n";
42 $this->displayValue($i);
46 echo "</td>\n</tr>\n";
49 cfunction formatHTMLValues() {
50 $ct = $this->values["count"];
52 $str .= "<tr>\n\t<td valign=top bgcolor=white>\n";
53 $n = $this->getAttributeName($this->name);
54 $str .= "\t\t".$n."\n\t\t</td>\n\t<td valign=top bgcolor=lightyellow>\n\t\t<ul type=square>\n";
56 // $str .= "\t\t<ul type=square>\n";
58 for ($i=0; $i<$this->values["count"]; $i++) {
60 $str .= $this->formatHTMLValue($i);
63 //if ($ct > 1) { $str .= "\t\t\t</ul>\n"; }
64 $str .= "\t\t\t</ul>\n\t\t</td>\n\t</tr>\n";
68 cfunction formatHTMLValue($index) {
69 global $prefs, $FILE, $host;
71 switch ($this->name) {
73 $p .= "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&base_dn=".urlencode($this->dn).">".$this->values[$index]."</a>";
76 $p .= "<a href=".$FILE."?ldap_action=list&host=".urlencode($host)."&base_dn=".urlencode($this->dn).">".$this->values[$index]."</a>";
83 case "lastmodifiedby":
85 $p .= "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&base_dn=".urlencode($this->values[$index]).">".ldap_dn2ufn($this->values[$index])."</a>";
88 $p .= "<a href=mailto:".$this->values[$index].">".$this->values[$index]."</a>";
91 case "homepostaladdress":
93 $tok = strtok($this->values[$index], "$");
95 $p .= $i." ".$tok."<br>\n";
101 $tok = strtok($this->values[$index], " ");
102 $tok2 = strtok("\0");
103 $p .= '<a href='.$tok.'>'.$tok2.'</a>';
105 case "lastmodifiedtime":
106 case "modifytimestamp":
107 $t = $this->values[$index];
108 $hour = (int) $t[6].$t[7];
109 $minute = (int) $t[8].$t[9];
110 $second = (int) $t[10].$t[11];
111 $month = (int) $t[2].$t[3];
112 $day = (int) $t[4].$t[5];
113 $year = (int) $t[0].$t[1];
114 $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
115 $date = date("h:i:sa, on l, dS of F Y", $timestamp);
119 $p .= '<a href="'.$prefs->get("PATH.photo").'?base_dn='.urlencode($this->dn).'"><img src="'.$prefs->get("PATH.photo").'?base_dn='.urlencode($this->dn).'" alt="Image of '.$this->cn.'" border=0></a>';
122 $p .= $this->values[$index];
128 cfunction displayValue($index) {
129 //echo "ldap_entry_attribute.displayValue(".$index.")<br>\n";
131 if ($this->name == "cn") {
132 print "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&base_dn=".urlencode($this->dn).">".$this->values[$index]."</a>";
134 else if ($this->name == "ou") {
135 print "<a href=".$FILE."?ldap_action=list&host=".urlencode($host)."&base_dn=".urlencode($this->dn).">".$this->values[$index]."</a>";
137 else if ($this->name == "seealso" || $this->name == "member" || $this->name == "requeststo" || $this->name == "errorsto" || $this->name == "owner" || $this->name == "lastmodifiedby" || $this->name == "modifiersname") {
138 print "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&base_dn=".urlencode($this->values[$index]).">".ldap_dn2ufn($this->values[$index])."</a>";
140 else if ($this->name == "mail") {
141 print "<a href=mailto:".$this->values[$index].">".$this->values[$index]."</a>";
143 else if ($this->name == "labeledurl") {
144 $tok = strtok($this->values[$index], " ");
145 $tok2 = strtok("\0");
146 print '<a href='.$tok.'>'.$tok2.'</a>';
148 else if ($this->name == "lastmodifiedtime" || $this->name == "modifytimestamp") {
149 $t = $this->values[$index];
150 $hour = (int) $t[6].$t[7];
151 $minute = (int) $t[8].$t[9];
152 $second = (int) $t[10].$t[11];
153 $month = (int) $t[2].$t[3];
154 $day = (int) $t[4].$t[5];
155 $year = (int) $t[0].$t[1];
156 $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
157 $date = date("h:i:sa, on l, dS of F Y", $timestamp);
158 // $date = getdate($timestamp);
159 // $date = getdate($this->values[$index]);
160 // echo "".$date["hours"].":".$date["minutes"].",
161 // ".$date["weekday"].",".$date["month"]." ".$date["mday"].", ".$date["year"]."<br>\n";
165 print $this->values[$index];