[Kolab-devel] server/kolab/kolab/admin/addressbook create_vcard.php,1.5,1.6 head.php,1.5,1.6 index.php,1.6,1.7 by martin at doto.intevation.de
root at intevation.de
root at intevation.de
Sat Jun 14 19:06:33 CEST 2003
Update of /kolabrepository/server/kolab/kolab/admin/addressbook
In directory doto:/tmp/cvs-serv24612/addressbook
Modified Files:
create_vcard.php head.php index.php
Log Message:
Martin K.: Merged css stuff from Konsec
Index: create_vcard.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/addressbook/create_vcard.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- create_vcard.php 22 May 2003 17:50:34 -0000 1.5
+++ create_vcard.php 14 Jun 2003 17:06:31 -0000 1.6
@@ -191,11 +191,11 @@
array_push($errors, "Error: you need administrative permissions to delete users");
if (!$errors) {
- print("<TR><TD><center><H1> Delete Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Delete Address Book Entry </div>\n");
if (!(ldap_delete($link,$dn))) {
array_push($errors, "LDAP Error: could not delete ".utf8_decode($dn)." ".ldap_error($link));
} else {
- print("<tr><td><center> The object ".utf8_decode($dn)." has been deleted </td></tr>\n");
+ print("<div class=\"message\"> The object ".utf8_decode($dn)." has been deleted </div>\n");
}
}
@@ -209,14 +209,14 @@
if (!empty($HTTP_GET_VARS['firstname'])) {
$firstname = trim(urldecode($HTTP_GET_VARS['firstname']));
} else {
- $comment['firstname'] = "<span style=\"color:#FF0000\"> Fill in firstname </span>";
+ $comment['firstname'] = "<span class=\"warning\"> Fill in firstname </span>";
missing_input();
}
if (!empty($HTTP_GET_VARS['lastname'])) {
$ldap_object['sn'] = trim(urldecode($HTTP_GET_VARS['lastname']));
if ($firstname) $ldap_object['cn'] = $firstname." ".$ldap_object['sn'];
} else {
- $comment['lastname'] = "<span style=\"color:#FF0000\"> Fill in lastname </span>";
+ $comment['lastname'] = "<span class=\"warning\"> Fill in lastname </span>";
missing_input();
}
foreach ($attributes as $attr) {
@@ -263,26 +263,26 @@
array_push($errors, "LDAP Error: could not add object ".utf8_decode($dn)." ".ldap_error($link));
}
if ($errors) {
- print("<TR><TD><center><H1> Create New Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Create New Address Book Entry </div>\n");
$action = "create";
$ldap_object = from_utf8($ldap_object);
break;
}
}
$action = "modify";
- print("<TR><TD><center><H1> Modify Existing Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Modify Existing Address Book Entry </div>\n");
break;
case "create":
- print("<TR><TD><center><H1> Create New Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Create New Address Book Entry </div>\n");
break;
case "modify":
- print("<TR><TD><center><H1> Modify Existing Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Modify Existing Address Book Entry </div>\n");
break;
case "delete":
- print("<TR><TD><center><H1> Confirm Delete Address Book Entry </H1></center></TD></TR>\n");
+ print("<div class=\"maintitle\"> Confirm Delete Address Book Entry </div>\n");
}
if ($dn) {
@@ -303,7 +303,7 @@
if ($action != "kill") {
-print "<TR><TD><CENTER><form action=\"$myself\" method=\"GET\">\n";
+print "<div class=\"contenttable\"><form action=\"$myself\" method=\"GET\">\n";
switch ($action) {
case "create":
print("<input type=\"hidden\" name=\"action\" value=\"firstsave\">\n");
@@ -315,7 +315,9 @@
print("<input type=\"hidden\" name=\"action\" value=\"save\">\n");
}
if ($dn) print "<input type=\"hidden\" name=\"dn\" value=\"$dn\">\n";
-print "<table cellspacing=0 cellpadding=3>\n";
+
+
+print "<table class=\"contentform\">\n";
if (is_array($ldap_object['sn'])) $lastname = $ldap_object['sn'][0];
else $lastname = $ldap_object['sn'];
@@ -360,27 +362,24 @@
$count++;
}
}
-print "</table></CENTER></TD><TR>\n";
+print "</table>\n";
-print "<tr><td><center><table cellspacing=0 cellpadding=3>\n";
+print "<table class=\"button\">\n";
print "<tr><td><input type=\"image\" src=\"../pics/button_ok.png\" name=\"apply\" value=\"Apply\"></td>\n";
if ($group == "user") {
print "<td><a href=\"..\"> <img src=\"../pics/button_cancel.png\" alt=\"cancel\"></a></td></tr>\n";
} else {
print "<td><a href=\"index.php\"> <img src=\"../pics/button_cancel.png\" alt=\"cancel\"></a></td></tr>\n";
}
-print "</center></td></tr>\n";
-
} // if $action != delete
-print("</table>\n");
+print("</table></div>\n");
if ($errors) {
- print("<TABLE WIDTH=\"100%\" CELLSPACING=20 CELLPADDING=0 BORDER=0>\n");
- print("<TR><TD HEIGHT=20></TD></TR>\n");
- print("<TR><TD><H3> There were Errors : </H3></TD></TR>\n");
- print("<TR><TD>\n");
- foreach ($errors as $message) print("<span style=\"color:#FF0000\">".$message."</span><br>");
+ print("<TABLE style=\"errors\">\n");
+ print("<TR><TD class=\"head\"> There were Errors : </TD></TR>\n");
+ print("<TR><TD class=\"body\">\n");
+ foreach ($errors as $message) print($message);
print("</TD></TR>\n");
print("</TABLE>\n");
}
Index: head.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/addressbook/head.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- head.php 22 May 2003 17:50:34 -0000 1.5
+++ head.php 14 Jun 2003 17:06:31 -0000 1.6
@@ -29,6 +29,5 @@
idxPrefix("../");
Mainhead("- Addressbook Settings".$title);
- print("<IMG SRC=\"../pics/kolab_logo.gif\">");
}
?>
Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/addressbook/index.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- index.php 22 May 2003 17:50:34 -0000 1.6
+++ index.php 14 Jun 2003 17:06:31 -0000 1.7
@@ -10,15 +10,6 @@
This("addressbook/");
Head();
-?>
-
-<TABLE WIDTH="100%" CELLSPACING=0 CELLPADDING=0 BORDER=0>
-<TR><TD HEIGHT=20></TD></TR>
-<TR><TD><center><H1> Manage Address Book </H1></center></TD></TR>
-
-<TR><TD><center>(only external addresses without a kolab user account)</center></TD></TR>
-
-<?
$utf8 = array ( 'cn', 'sn' );
@@ -35,8 +26,14 @@
// read selector for register display
if (isset($HTTP_GET_VARS['alphaselect'])) $alphaselect = $HTTP_GET_VARS['alphaselect'];
- else $alphaselect = "[A-F]";
+ else $alphaselect = "[all]";
+if (isset($HTTP_GET_VARS['page'])) $page = $HTTP_GET_VARS['page'];
+ else $page = "1";
+
+if (isset($_SESSION['base_dn'])) $base_dn = $_SESSION['base_dn'];
+ else $base_dn = 'k=kolab' ;
+
$myself = $_SERVER['PHP_SELF'];
if (isset($_SESSION['ldap_server'])) $ldap_server = $_SESSION['ldap_server'];
@@ -48,63 +45,127 @@
if (!$errors && !($link = ldap_connect($ldap_server,$ldap_port)) || !ldap_bind($link))
array_push($errors, "Communication Error: could not query ldap://$ldap_server:$ldap_port ".ldap_error($link));
-switch ($alphaselect) {
- case "[A-F]":
- $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=F*)(sn=E*)(sn=D*)(sn=C*)(sn=B*)(sn=A*)";
- $filter = $filter."(sn=f*)(sn=e*)(sn=d*)(sn=c*)(sn=b*)(sn=a*)";
- if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ä")."*)(sn=".utf8_encode("ä")."*)";
- $filter = $filter."))";
- break;
-
- case "[G-L]":
- $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=G*)(sn=H*)(sn=I*)(sn=J*)(sn=K*)(sn=L*)";
- $filter = $filter."(sn=g*)(sn=h*)(sn=i*)(sn=j*)(sn=k*)(sn=l*)))";
- break;
- case "[M-S]":
- $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=M*)(sn=N*)(sn=O*)(sn=P*)(sn=Q*)(sn=R*)(sn=S*)";
- $filter = $filter."(sn=m*)(sn=n*)(sn=o*)(sn=p*)(sn=q*)(sn=r*)(sn=s*)";
- if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ö")."*)(sn=".utf8_encode("ö")."*)".
- "(sn=".utf8_encode("Ü")."*)(sn=".utf8_encode("ü")."*)";
- $filter = $filter."))";
- break;
+// get all entries & dynamically split the letters with growing entries
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(sn=*))";
+ $result = ldap_search($link, $base_dn, $filter);
+ if (!$errors) {
+ $entries = ldap_count_entries($link, $result);
+ printf("<div class=\"maintitle\">Manage Address Book (%s Addresses)</div>", $entries);
+ printf("<div class=\"mainsubtitle\">(only external addresses without a kolab user account)</div>");
+ // if there are more than 2000 entries, split in 26 categories for every letter
+ if ($entries > 2000) {
+ print("<div class=\"alphabetlisting\"><form method=\"POST\" action=\"$myself\">\n\n");
+ for ($i = 65; $i < 91; $i++) {
+ printf("<a href=\"$myself?alphaselect=[%s]\"> [%s] </a>", chr($i), chr($i));
+ }
+ $text="[all]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
+ print("</form></div>\n");
- case "[T-Z]":
- $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=T*)(sn=U*)(sn=V*)(sn=W*)(sn=X*)(sn=Y*)(sn=Z*)";
- $filter = $filter."(sn=t*)(sn=u*)(sn=v*)(sn=w*)(sn=x*)(sn=y*)(sn=z*)))";
- break;
+ for ($i = 65; $i < 91; $i++) {
+ switch ($alphaselect) {
+ case "[".chr($i)."]":
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(uid=*)(mail=*)(|(sn=".chr($i)."*)(sn=".chr($i+32)."*)";
+ if ($i == 65) {
+ if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ä")."*)(sn=".utf8_encode("ä")."*)"; }
+ if ($i == 79) {
+ if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ö")."*)(sn=".utf8_encode("ö")."*)"; }
+ if ($i == 85) {
+ if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ü")."*)(sn=".utf8_encode("ü")."*)"; }
+ $filter = $filter."))";
+ break;
+ }
+ }
+ ldap_free_result($result);
+ $result = ldap_search($link, $base_dn, $filter);
+ $entries = ldap_count_entries($link, $result);
+ }
+ // if there are more than 50 entries, split in four categories
+ elseif ($entries >50) {
+ print("<div class=\"alphabetlisting\"><form method=\"POST\" action=\"$myself\">\n\n");
+ $text = "[A-F]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
+ $text = "[G-L]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
+ $text="[M-S]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
+ $text="[T-Z]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
+ $text="[all]";
+ print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
+ print("</form></div>\n");
+ switch ($alphaselect) {
+ case "[A-F]":
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=F*)(sn=E*)(sn=D*)(sn=C*)(sn=B*)(sn=A*)";
+ $filter = $filter."(sn=f*)(sn=e*)(sn=d*)(sn=c*)(sn=b*)(sn=a*)";
+ if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ä")."*)(sn=".utf8_encode("ä")."*)";
+ $filter = $filter."))";
+ break;
+ case "[G-L]":
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=G*)(sn=H*)(sn=I*)(sn=J*)(sn=K*)(sn=L*)";
+ $filter = $filter."(sn=g*)(sn=h*)(sn=i*)(sn=j*)(sn=k*)(sn=l*)))";
+ break;
+ case "[M-S]":
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=M*)(sn=N*)(sn=O*)(sn=P*)(sn=Q*)(sn=R*)(sn=S*)";
+ $filter = $filter."(sn=m*)(sn=n*)(sn=o*)(sn=p*)(sn=q*)(sn=r*)(sn=s*)";
+ if (in_array('sn', $utf8)) $filter = $filter."(sn=".utf8_encode("Ö")."*)(sn=".utf8_encode("ö")."*)".
+ "(sn=".utf8_encode("Ü")."*)(sn=".utf8_encode("ü")."*)";
+ $filter = $filter."))";
+ break;
+ case "[T-Z]":
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(|(sn=T*)(sn=U*)(sn=V*)(sn=W*)(sn=X*)(sn=Y*)(sn=Z*)";
+ $filter = $filter."(sn=t*)(sn=u*)(sn=v*)(sn=w*)(sn=x*)(sn=y*)(sn=z*)))";
+ break;
+ default:
+ $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(sn=*))";
+ break;
+ }
+ ldap_free_result($result);
+ $result = ldap_search($link, $base_dn, $filter);
+ $entries = ldap_count_entries($link, $result);
- default:
- $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(sn=*))";
- break;
-}
+ }
+ // if there are less than 50 entries, all entries are shown - w/o options
+ else { echo "<div class=\"alphabetlisting\"></div>\n"; $alphaselect = "[all]"; }
+ }
if (!$errors) {
-$result = ldap_search($link, $_SESSION['base_dn'], $filter);
-if ($result) {
- print("<tr><td><center><form method=\"POST\" action=\"$myself\">\n<h2>\n");
- $text = "[A-F]";
- print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
- $text = "[G-L]";
- print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
- $text="[M-S]";
- print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
- $text="[T-Z]";
- print("<a href=\"$myself?alphaselect=$text\"> $text </a>");
- $text="[all]";
- print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
- print("</h2></form></center></td></tr>");
- print("<TR><TD HEIGHT=20></TD></TR>\n");
+// splitting into more than one page?
+print("<div class=\"pagelisting\">");
+$pages = ceil($entries / $views);
+if ($pages > 1) {
+ for ($i = 1; $i < $pages; $i++) {
+ // the actual page won't be clickable
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> |\n", $alphaselect, $i, $i);
+ else
+ printf(" %s |\n", $i);
+ }
+ // last item w/o vertical dash
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> \n", $alphaselect, $i, $i);
+ else
+ printf(" %s ", $i);
+}
+print("</div>");
- print("<TD ALIGN=center>\n");
- print("<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 bgcolor=\"#dcdcdc\" CELLPADDING=3 nosave>\n");
+if ($result) {
+ print("<div class=\"contenttable\">");
+ print("<TABLE class=\"content\" nosave>\n");
ldap_sort($link,$result,'sn');
$entry = ldap_first_entry($link, $result);
+ // skipping to correct page and start with first entry
+ if ($page != '1') {
+ for ($i = 1; $i <= ($page-1)*$views; $i++) {
+ $entry = ldap_next_entry($link, $entry);
+ }
+ }
if (ldap_count_entries($link,$result) <= 0) {
- print("<tr><td align=center> (No external address book entries in the category $alphaselect) </td></tr>\n");
+ print("<tr><td class=\"nocontent\"> (No external address book entries in the category $alphaselect) </td></tr>\n");
} else {
- printf("<thead><td><b> Name </b></td><td><b> Action </b></td></thead>\n");
+ printf("<thead><td class=\"content\"> Name </td><td class=\"content\"> Action </td></thead>\n");
while ($entry) {
$dn = ldap_get_dn($link,$entry);
$attrs = ldap_get_attributes($link, $entry);
@@ -116,11 +177,15 @@
$b = strlen($cn);
$fn = substr($cn, 0, $b - $a);
$dn = urlencode($dn);
- printf("<tr align=center><td> %s, %s </td><td>
+ printf("<tr><td class=\"content\"> %s, %s </td><td class=\"contentaction\">
<a href=\"create_vcard.php?action=modify&dn=%s\"> [Modify]</a>
<a href=\"create_vcard.php?action=delete&dn=%s\"> [Delete]</a>
</td></tr>\n", $sn, $fn, $dn,$dn);
$entry = ldap_next_entry($link, $entry);
+ // counts the entries, which are already listed on this page and breaks on overflow
+ $countentries++;
+ if ($countentries >= $views) break;
+
}
ldap_free_result($result);
}
@@ -128,14 +193,29 @@
} else array_push($errors, "Communication Error: ldap server did not answer query for user information");
}
-print("</table>\n");
-
+print("</table>\n<div class=\"pagelisting\">");
+// splitting into more than one page?
+$pages = ceil($entries / $views);
+if ($pages > 1) {
+ for ($i = 1; $i < $pages; $i++) {
+ // the actual page won't be clickable
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> |\n", $alphaselect, $i, $i);
+ else
+ printf(" %s |\n", $i);
+ }
+ // last item w/o vertical dash
+ if ($page != $i)
+ printf(" <a href=\"index.php?alphaselect=%s&page=%s\">%s</a> \n", $alphaselect, $i, $i);
+ else
+ printf(" %s ", $i);
+}
+print("</div>\n");
if ($errors) {
- print("<TABLE WIDTH=\"100%\" CELLSPACING=20 CELLPADDING=0 BORDER=0>\n");
- print("<TR><TD HEIGHT=20></TD></TR>\n");
- print("<TR><TD><H3> There were Errors : </H3></TD></TR>\n");
- print("<TR><TD>\n");
- foreach ($errors as $message) print("<span style=\"color:#FF0000\">".$message."</span><br>");
+ print("<TABLE style=\"errors\">\n");
+ print("<TR><TD class=\"head\"> There were Errors : </TD></TR>\n");
+ print("<TR><TD class=\"body\">\n");
+ foreach ($errors as $message) print($message);
print("</TD></TR>\n");
print("</TABLE>\n");
}
More information about the devel
mailing list