[Kolab-devel] server/kolab/kolab/admin/sharedfolder create_sharedfolder.php,1.5,1.6 head.php,1.4,1.5 index.php,1.6,1.7 by martin at doto.intevation.de

root at intevation.de root at intevation.de
Sat Jun 14 15:52:40 CEST 2003


Update of /kolabrepository/server/kolab/kolab/admin/sharedfolder
In directory doto:/tmp/cvs-serv20737

Modified Files:
	create_sharedfolder.php head.php index.php 
Log Message:
Martin K.: Another CCS update this time for shared folders


Index: create_sharedfolder.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/sharedfolder/create_sharedfolder.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- create_sharedfolder.php	22 May 2003 17:50:35 -0000	1.5
+++ create_sharedfolder.php	14 Jun 2003 13:52:38 -0000	1.6
@@ -10,12 +10,6 @@
   Head();
 ?>
 
-<P>
-</FONT>
-<TABLE WIDTH="100%" CELLSPACING=0 CELLPADDING=0 BORDER=0>
-<TR><TD HEIGHT=20></TD></TR>
-<TR><TD><CENTER>
-
 <?  
 
 function debug ($a)
@@ -109,13 +103,13 @@
    if ($action == "delete") {
       if (!$dn) array_push($errors, "Internal Error: need dn to delete shared folder");
       else {
-         print("<TR><TD><center><H1> Delete Shared Folder </H1></center></TD></TR>\n");
+         print("<div class=\"maintitle\"> Delete Shared Folder </div>\n");
          $attrs['deleteflag'][0] = 'TRUE';
          if (!(ldap_modify($link,$dn,$attrs))) {
             array_push($errors, "LDAP Error: could not mark ".utf8_decode($dn)." for deletion ".ldap_error($link));
 	 } else {
-	    system("sudo -u kolab /kolab/etc/kolab/kolab_buildconfig &");
-	    print("<tr><td><center> The object ".utf8_decode($dn)." has been deleted </td></tr>\n");
+	    system("sudo -u kolab /kolab/etc/kolab/kolab_buildconfig & ");
+	    print("<div class=\"message\"> The object ".utf8_decode($dn)." has been deleted </div>\n");
 	 }
       }
    } else {
@@ -174,25 +168,25 @@
          } else {
             if ($dn && !ldap_add($link,$dn,$attrs)) {
                array_push($errors, "LDAP Error: could not add $dn to ldap (entry already exists) ".ldap_error($link));
-               print("<TR><TD><center><H1> Create New Shared Folder </H1></center></TD></TR>\n");
+               print("<div class=\"maintitle\"> Create New Shared Folder </div>\n");
                $action = "create";
                $blacklist = array();
 	       break;
             } 
          }
-	 system("sudo -u kolab /kolab/etc/kolab/kolab_buildconfig &");
+	 system("sudo -u kolab /kolab/etc/kolab/kolab_buildconfig & ");
          $blacklist = array('cn');
          $action = "modify";
-         print "<h1> Modify Existing Shared Folder </h1>\n";
+         print "<div class=\"maintitle\"> Modify Existing Shared Folder </div>\n";
          break;
 
       case "create":
-         print "<h1> Create New Shared Folder </h1>\n";
+         print "<div class=\"maintitle\"> Create New Shared Folder </div>\n";
          $blacklist=array();
          break;
 
       case "modify":
-         print "<h1> Modify Existing Shared Folder </h1>\n";
+         print "<div class=\"maintitle\"> Modify Existing Shared Folder </div>\n";
          $blacklist = array('cn');
          break;
    }
@@ -227,14 +221,14 @@
 
 if ($action != "delete") {
 
-print "<form action=\"$myself\" method=\"GET\">\n";
+print "<div class=\"contenttable\"><form action=\"$myself\" method=\"GET\">\n";
 if ($action == "create") {
    print "<input type=\"hidden\" name=\"action\" value=\"firstsave\">\n";
 } else {
    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";
 print "<tr><th> Attribute </th><th> Value </th><th> Option </th><th> Comment </th></tr>\n";
 
 
@@ -286,26 +280,22 @@
 }   
 
 print "</table>\n";
-print "<table cellspacing=\"20\" cellpadding=\"0\">\n";
+print "<table class=\"button\">\n";
 print "<tr><td></td><td><input type=\"image\" src=\"../pics/button_ok.png\" name=\"apply\" value=\"Apply\"></td>\n";
 print "<td><a href=\"index.php\"> <img src=\"../pics/button_cancel.png\" alt=\"cancel\"></a></td></tr>\n";
-print "</table>\n";
-print "</form>\n";
-print "</center></td></tr></table>\n";
+print "</table></form></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");
 }
 
-print("</TABLE>\n");
 
 Foot(); 
 ?>

Index: head.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/sharedfolder/head.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- head.php	22 May 2003 17:50:35 -0000	1.4
+++ head.php	14 Jun 2003 13:52:38 -0000	1.5
@@ -20,6 +20,5 @@
     global $title;
     idxPrefix("../");
     Mainhead("- Shared Folder Settings".$title);
-    print("<IMG SRC=\"../pics/kolab_logo.gif\">");
   }
 ?>

Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/admin/sharedfolder/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:35 -0000	1.6
+++ index.php	14 Jun 2003 13:52:38 -0000	1.7
@@ -8,16 +8,11 @@
   include("head.php");
   This("sharedfolder/");
   Head();
-?>
-
-<TABLE WIDTH="100%" CELLSPACING=0 CELLPADDING=0 BORDER=0>
-<TR><TD HEIGHT=20></TD></TR>
-<TR><TD><center><H1> Manage Shared Folders </H1></center></TD></TR>
-
-<?
+ 
 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";
 $errors = array();
 
 // check user authentication
@@ -29,6 +24,9 @@
 if (!$errors && $group != "admin" && $group != "maintainer")
    array_push($errors, "Error: You don't have Permissions to access this Menue");
 
+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'];
@@ -40,72 +38,151 @@
 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]":
-      $searchFilter = "(&(|(cn=F*)(cn=E*)(cn=D*)(cn=C*)(cn=B*)(cn=A*))(objectClass=sharedfolder))";
-      break;
-   case "[G-L]":
-      $searchFilter = "(&(|(cn=G*)(cn=H*)(cn=I*)(cn=J*)(cn=K*)(cn=L*))(objectClass=sharedfolder))";
-      break;
-   case "[M-S]":
-      $searchFilter = "(&(|(cn=M*)(cn=N*)(cn=O*)(cn=P*)(cn=Q*)(cn=R*)(cn=S*))(objectClass=sharedfolder))";
-      break;
-   case "[T-Z]":
-      $searchFilter = "(&(|(cn=T*)(cn=U*)(cn=V*)(cn=W*)(cn=X*)(cn=Y*)(cn=Z*))(objectClass=sharedfolder))";
-      break;
-   default:
-      $searchFilter = "(objectClass=sharedfolder)";
+
+// get all entries & dynamically split the letters with growing entries
+	$filter = "(objectClass=sharedfolder)";
+	$result = ldap_search($link, $base_dn, $filter);
+	// counting all entries
+	$entries= ldap_count_entries($link, $result);
+	ldap_free_result($result);
+
+if (!$errors) {
+	printf("<div class=\"maintitle\">Manage Shared Folders (%s Folders)</div>", $entries);
+	// 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");
+
+		for ($i = 65; $i < 91; $i++) {
+			switch ($alphaselect) {
+				case "[".chr($i)."]":
+					$searchFilter = "(&(|(cn=".chr($i)."*))(objectClass=sharedfolder))";
+				break;
+			}
+		}
+	}
+	// 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]":
+					$searchFilter = "(&(|(cn=F*)(cn=E*)(cn=D*)(cn=C*)(cn=B*)(cn=A*))(objectClass=sharedfolder))";
+				break;
+				case "[G-L]":
+					$searchFilter = "(&(|(cn=G*)(cn=H*)(cn=I*)(cn=J*)(cn=K*)(cn=L*))(objectClass=sharedfolder))";
+				break;
+				case "[M-S]":
+					$searchFilter = "(&(|(cn=M*)(cn=N*)(cn=O*)(cn=P*)(cn=Q*)(cn=R*)(cn=S*))(objectClass=sharedfolder))";
+				break;
+				case "[T-Z]":
+					$searchFilter = "(&(|(cn=T*)(cn=U*)(cn=V*)(cn=W*)(cn=X*)(cn=Y*)(cn=Z*))(objectClass=sharedfolder))";
+				break;
+				default: 
+					$searchFilter = "(objectClass=sharedfolder)";
+				break;
+			}
+		
+	}
+	// if there are less than 50 entries, all entries are shown - w/o options
+	else { echo "<div class=\"alphabetlisting\"></div>\n"; $alphaselect = "[all]"; $searchFilter = "(objectClass=sharedfolder)"; }
+
+}
+
+// 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>");
 
 if (!$errors) {
-   $result = ldap_search($link,$_SESSION['base_dn'],$searchFilter);
+   $result = ldap_search($link,$base_dn,$searchFilter);
    if ($result) {
-      print("<tr><td><form method=\"POST\" action=\"$myself\"><center><h2>\n");
-      $text="[A-F]";
-      print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
-      $text="[G-L]";
-      print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
-      $text="[M-S]";
-      print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
-      $text="[T-Z]";
-      print("<a href=\"$myself?alphaselect=$text\"> $text </a>\n");
-      $text="[all]";
-      print("<a href=\"$myself?alphaselect=$text\">  $text  </a>\n");
-      print("</h2></form></center></td></tr>\n");
-      print("<TR><TD HEIGHT=20></TD></TR>\n");
-
-      print("<TD ALIGN=center>\n");
-      print("<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 bgcolor=\"#dcdcdc\" CELLPADDING=3 nosave>\n");
+      print("<div class=\"contenttable\"><TABLE class=\"content\" nosave>\n");
       ldap_sort($link,$result,'cn');
       $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 (!$entry) {
-         print("<tr><td align=center> No shared folders in the category $alphaselect</td></tr>\n");
+         print("<tr><td class=\"nocontent\"> No shared folders in the category $alphaselect</td></tr>\n");
       } else {
-         print("<thead><td><b>Folder Name</b></td><td><b> Actions </b></td></thead>\n");
+         print("<thead><td class=\"content\"> Folder Name </td><td class=\"content\"> Actions </td></thead>\n");
          while ($entry) {
             // $dn = urlencode($resultEntries[$i]["dn"]);
             $dn = ldap_get_dn($link, $entry);
             $attrs = ldap_get_attributes($link,$entry);
             $cn = utf8_decode($attrs['cn'][0]);
-	    printf("<tr align=center><td>%s</td><td>
+			printf("<tr><td class=\"content\">%s</td><td class=\"contentaction\">
                    <a href=\"create_sharedfolder.php?action=modify&dn=%s\"> [Modify]</a>
                    <a href=\"create_sharedfolder.php?action=delete&dn=%s\"> [Delete]</a>
 		   </td></tr>\n",$cn,$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);
    } 
    ldap_close($link);
-   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