]> git.sur5r.net Git - openldap/blob - contrib/php3-tool/include/ldap_entry.inc
New backend routine: back_attribute
[openldap] / contrib / php3-tool / include / ldap_entry.inc
1 <?
2 include 'include/ldap_entry_attribute.inc';
3 class ldap_entry {
4         var $attributes;
5         var $dn;
6         var $parent;
7         var $attributeCount;
8         var $link_identifier;
9         var $r_e_i;
10
11         cfunction ldap_entry($l_i) {
12         //      echo "creating new ldap_entry<br>\n";
13                 $this->link_identifier = $l_i;
14         }
15
16         cfunction getAttributes() {
17                 $i=0;
18                 $attrib = new ldap_entry_attribute($this->dn);
19                 $n = ldap_first_attribute($this->link_identifier, $this->r_e_i, &$ber);
20                 while ($n) {
21                         $attrib->name = $n;
22                         $attrib->getValues($this->link_identifier,$this->r_e_i);
23                         $this->attributes[$i] = $attrib;
24                         $i++;
25                         $attrib = new ldap_entry_attribute($this->dn);
26                         $n = ldap_next_attribute($this->link_identifier, $this->r_e_i, $ber);
27                 }
28         }
29
30         cfunction formatHTMLDN($dn) {
31                 global $FILE, $host;
32                 $string = "";
33                 $attribs = ldap_explode_dn($dn, 0);
34                 $names = ldap_explode_dn($dn, 1);
35                 for ($i=0; $i<$attribs["count"]; $i++) {
36                         $s = $attribs[$i];
37                         for ($j=$i+1; $j<$attribs["count"]; $j++) {
38                                 $s .= ",".$attribs[$j];
39                         }
40                         if (($s[0] == "c") && ($s[1] == "n")) {
41                                 $string .= "<a href=".$FILE."?ldap_action=read&base_dn=".urlencode($s).">".$names[$i]."</a>";
42                         }
43                         else {
44                                 $string .= "<a href=".$FILE."?ldap_action=list&base_dn=".urlencode($s).">".$names[$i]."</a>";
45                         }
46                         if ($i<$attribs["count"]-1) { $string .= ", "; }
47                 }
48                 return $string;
49         }
50
51         cfunction formatHTMLAttributes() {
52                 global $FILE, $host;
53                 $s = "";
54                 $s .= "<tr>\n\t";
55                 $s .= '<td colspan=2 bgcolor="#9380DB" align="center" valign="middle">';
56                 $s .= "\n\t\t<h3 class=head>".$this->formatHTMLDN($this->dn)."</h3>\n";
57                 $s .= "\t\t</td>\n\t</tr>\n";   
58                 $c = count($this->attributes);
59                 for ($i=0; $i<$c; $i++) {
60                         $attrib = $this->attributes[$i];
61                         if ($attrib->isVisible($attrib->name) == "TRUE") {
62                                 $s .= $attrib->formatHTMLValues();
63                         }
64                 }
65                 $a = $this->attributes[0];
66                 $v = $a->values[1];
67                 if ($v == "organizationalUnit" || $v == "organization") {
68                         $s .= "<tr>\n\t<td colspan=2>\n";
69                         $s .= "\t\t<a href=".$FILE."?host=".urlencode($host)."&ldap_action=list&base_dn=".urlencode($this->dn).">Browse</a>\n";
70                         $s .= "\t\t</td>\n\t</tr>\n";
71                 }
72                 else if ($v == "person") {
73                         $s .= "<tr>\n\t<td colspan=2>\n";
74                         $s .= "\t\t<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&admin_action=modify&base_dn=".urlencode($this->dn).">Modify</a>\n";
75                         $s .= "\t\t</td>\n\t</tr>\n";
76                 }
77                 else {
78                         $s .= "<tr>\n\t<td colspan=2>\n\t\t&nbsp;\n\t\t</td>\n\t</tr>\n";
79                 }
80                 return $s;
81         }
82
83         cfunction display() {
84                 global $FILE, $host;
85                 echo "<tr><td colspan=2 bgcolor=gray>";
86                 echo "<h3>".ldap_dn2ufn($this->dn)."</h3>";
87                 echo "</td></tr>";
88                 $c = count($this->attributes);
89                 for ($i=0; $i<$c; $i++) {
90                         $attrib = $this->attributes[$i];
91                         $attrib->display();
92                 }
93                 $a = $this->attributes[0];
94                 $v = $a->values[1];
95                 if ($v == "organizationalUnit" || $v == "organization") {
96                         echo "<tr><td colspan=2>";
97                         echo "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=list&base_dn=".urlencode($this->dn).">Browse</a>";
98                         echo "</td></tr>";
99                 }
100                 else {
101                         echo "<tr><td colspan=2>&nbsp;</td></tr>";
102                 }
103         }
104 }
105 ?>