Code

Applied planned layout modifications
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jul 2005 05:58:02 +0000 (05:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Jul 2005 05:58:02 +0000 (05:58 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1017 594d385d-05f5-0310-b6e9-bd551577e9d8

24 files changed:
Changelog
TODO
html/main.php
html/themes/default/style.css
include/class_config.inc
include/class_divlist.inc
plugins/addons/addressbook/class_addressbook.inc
plugins/addons/addressbook/contents.tpl
plugins/admin/applications/class_applicationManagement.inc
plugins/admin/applications/headpage.tpl
plugins/admin/departments/class_departmentManagement.inc
plugins/admin/departments/headpage.tpl
plugins/admin/groups/class_groupManagement.inc
plugins/admin/groups/headpage.tpl
plugins/admin/ogroups/class_ogroupManagement.inc
plugins/admin/ogroups/headpage.tpl
plugins/admin/systems/class_systemManagement.inc
plugins/admin/systems/headpage.tpl
plugins/admin/users/class_userManagement.inc
plugins/admin/users/headpage.tpl
plugins/gofax/blocklists/class_blocklistManagement.inc
plugins/gofax/blocklists/headpage.tpl
plugins/gofon/macro/class_gofonMacroManagement.inc
plugins/gofon/macro/headpage.tpl

index d149283722d90e58cc8b78bbc11c226900d9f8cd..a527a0d8b7103fe0e12b18395c0e4fe64ba1bfb0 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,7 @@ GOsa2 changelog
 ===============
 
 * gosa 2.4beta3
+  - Updated layout
   - Fixed application removal
   - Improved accessibility for disabled persons
   - Added intranet account to list of connectivity plugins
diff --git a/TODO b/TODO
index ae928bb1cf4724c6f7f3a6eeeaf6c5f4af77a2ef..132fb0da6d8d790f1d9120ac50958fbd1f3f5aa8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,8 +3,38 @@ Things to fix before 2.4:
 
 * Finish kolab integration
   - shared folders
+
 * Fix problem with winstation and invalid structural object class chain (inetOrgPerson/device)
 
+* Deparment dialog
+  - adapt base when creating a new department
+  - show different symbol when the department contains subdepartments
+
+* User dialog
+  - adapt base when creating a new user/template
+  - Add button for template created users
+
+* Group dialog
+  - Add properties
+  - tooltips
+  - Check strings
+
+* Systems dialog
+  - Add buttons for all system types
+  
+* All dialogs
+  - adapt base when creating a new entity
+  - sorting
+  - cleanup, remove not used code fragments
+  - &nbsp; between pictures ... if needed (convert_list ? )
+  - ALT tags are partly wrong and not translated 
+
+* include/class_mail-methods-kolab.inc -> gosaMailQuota not defined when opening "cajus"
+
+* Autofs entries cannot be removed
+
+* Minimize "reload" calls during post of depselect in all plugins
+
 
 Target for 2.5:
 ===============
index bb9ad7c16fb56bab23cbf148c7d3eedf299b6ba2..859e8d1239915cd387f49eec9f8495f23e123104 100644 (file)
@@ -289,7 +289,7 @@ if (isset($config->data['MAIN']['W3CTEST']) && preg_match('/true/i', $config->da
   tidy_clean_repair($display);
   $cnt =  (tidy_error_count($display))+(tidy_warning_count($display));
   if($cnt != 0){
-    echo "<table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black'><tr><td><img alt=\"\" align=\"middle\" src='images/warning.png'>&nbsp;<font style='font-size:14px;font-weight:bold'>"._("Generating this page caused the W3C conformance checker to raise some errors!")."</font></td><td align=right><button onClick='toggle(\"w3cbox\")'>"._("Toggle information")."</button></td></tr></table><div id='w3cbox' style='width:100%; position:absolute; z-index:0; visibility: hidden; background-color:white; border-bottom:1px solid black;'>";
+    echo "<table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black'><tr><td><img alt=\"W3C\" align=\"middle\" src='images/warning.png'>&nbsp;<font style='font-size:14px;font-weight:bold'>"._("Generating this page caused the W3C conformance checker to raise some errors!")."</font></td><td align=right><button onClick='toggle(\"w3cbox\")'>"._("Toggle information")."</button></td></tr></table><div id='w3cbox' style='width:100%; position:absolute; z-index:0; visibility: hidden; background-color:white; border-bottom:1px solid black;'>";
 
     echo nl2br(htmlentities($display->errorBuffer))."</div>";
   }
index e95c79f30391e8a32acb0ae800734549f56753f8..893abd3c67342e12b43b8a1f5c32a91cb6704c26 100644 (file)
@@ -1,3 +1,31 @@
+table.listframe {
+       width:600px;
+       background:#F3F3F3;
+}
+
+tr.listrow {
+       background:#EAEAEA;
+}
+
+td.listheader {
+       background:#E5E5E5;
+       font-weight:bold;
+    border-right:1px solid #C0C0C0;
+       padding:3px;
+}
+
+td.list0 {
+       background:#F0F0F0;
+    border-right:1px solid #C0C0C0;
+       padding:3px;
+}
+
+td.list1 {
+       background:white;
+    border-right:1px solid #C0C0C0;
+       padding:3px;
+}
+
 body
 {
   margin-left: 0px;
index bda66489dff0932dccb9f20321d473a005f0773a..5721b58aa31c45f1bb11de0653e3f85bc5d02982 100644 (file)
@@ -435,7 +435,7 @@ class config  {
        }
   }
 
-  function make_idepartments($max_size= 40)
+  function make_idepartments($max_size= 28)
   {
        $this->idepartments= array();
        foreach ($this->departments as $key => $val){
index 49e671e26298e93f490e1dd6eba6364192b8bf50..d94da0bfe8987ea2b7338de71add320fca6fc4b5 100644 (file)
@@ -117,9 +117,7 @@ class divlist {
 
                $appendempty = ($this->_numentries() -$start);
 
-
-
-               for($i = $start ; $i <= $stop;$i++){
+               for($i = $start ; $i < $stop;$i++){
                        
                        if(isset($this->a_entries[$i])){
                                                        
index 77ada8f460f440a6f37f60aad12c10677d38cac0..6a964bfdc79c895e671d721422479d0a259bbb92 100644 (file)
@@ -402,6 +402,7 @@ $this->telephone_list[$attrs['sn'][0].$attrs['dn']]=
        $smarty->assign("global", $phonefilter['global']);
        $smarty->assign("organizational", $phonefilter['organizational']);
        $smarty->assign("search_image", get_template_path('images/search.png'));
+       $smarty->assign("obj_image", get_template_path('images/list_ogroup.png'));
        $smarty->assign("tree_image", get_template_path('images/tree.png'));
        $smarty->assign("infoimage", get_template_path('images/info.png'));
        $smarty->assign("actionimage", get_template_path('images/action.png'));
index b4248bf760776a5a511d9e4bfb3e22808289cc32..6be1965f3d9460150714fc35e7da61607c755812 100644 (file)
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
                <td>
-                       <img alt="" src="{$tree_image}" align=middle>
-                       &nbsp;<LABEL for="search_base">{t}Display results for department{/t}</LABEL>
+                       <LABEL for="search_base"><img alt="" src="{$tree_image}" align=middle title='{t}Display results for department{/t}'></LABEL>
                </td>
        <td>
-                       <select name="search_base" size="1" onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
+                       <select name="search_base" style='width:99%' size="1" onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
                        {html_options options=$deplist selected=$depselect}
                                <option disabled>&nbsp;</option>
                </select>
                </td>
        </tr>
 </table>
-
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
-               <td width="50%"><img alt="" src="{$search_image}" align=middle>
-                       &nbsp;<LABEL for="search_for">{t}Search for{/t}</LABEL>
+               <td>
+                       <LABEL for="object_type"><img alt="" src="{$obj_image}" align=middle title='{t}Match object{/t}'></LABEL>
                </td>
            <td>
-                       <input id="search_for" type='text' name='search_for' maxlength='20' value='{$search_for}' title='{t}Search string{/t}' onChange="mainform.submit()">
-               </td>
+                       <select id="object_type" style='width:99%' name="object_type" size="1" onChange="mainform.submit()" title="{t}Choose the object that will be searched in{/t}">
+                       {html_options options=$objlist selected=$object_type}
+                               <option disabled>&nbsp;</option>
+               </select>
+           </td>
        </tr>
 </table>
-
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
-               <td width="50%">
-                       <img alt="" src="{$search_image}" align=middle>&nbsp;<LABEL for="object_type">{t}Match object{/t}</LABEL>
+               <td><LABEL for="search_for"><img alt="" src="{$search_image}" align=middle title='{t}Search for{/t}'></LABEL>
                </td>
            <td>
-               <select id="object_type" name="object_type" size="1" onChange="mainform.submit()" title="{t}Choose the object that will be searched in{/t}">
-                       {html_options options=$objlist selected=$object_type}
-                               <option disabled>&nbsp;</option>
-               </select>
-           </td>
+                       <input id="search_for" style='width:99%' type='text' name='search_for' maxlength='20' value='{$search_for}' title='{t}Search string{/t}' onChange="mainform.submit()">
+               </td>
        </tr>
 </table>
    {$apply}
index 7142121b63dd1cc71af351a251f0edd0ca3e7fd0..e52646bd9ed7524b9af7ee8864234dafdfe202ff 100644 (file)
@@ -48,72 +48,144 @@ class applicationManagement extends plugin
 
   function execute()
   {
-        /* Save data */
-        $appfilter= get_global("appfilter");
-        foreach( array("depselect", "regex") as $type){
-                if (isset($_POST[$type])){
-                        $appfilter[$type]= $_POST[$type];
-                }
-        }
-        if (isset($_GET['search'])){
-               $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-                if ($s == "**"){
-                        $s= "*";
-                }
-                $appfilter['regex']= $s;
-        }
-        register_global("appfilter", $appfilter);
-
-        /* Check sorting variable */
-       if (!isset($this->apptabs) &&
-            !isset($_POST['new_app']) &&
-            !isset($_POST['delete_app']) &&
-            !isset($_POST['select_app'])){
-               $this->reload();
-       }
-       $smarty= get_smarty();
-
-        /* Check for exeeded sizelimit */
-        if (($message= check_sizelimit()) != ""){
-                return($message);
-        }
-
-       /* New application? */
-       if (isset($_POST['new_app'])){
-
-               /* By default we set 'dn' to 'new', all relevant plugins will
-                  react on this. */
-               $this->dn= "new";
-
-               /* Create new usertab object */
-               $this->apptabs= new apptabs($this->config,
-                               $this->config->data['TABS']['APPSTABS'], $this->dn);
-               $this->apptabs->set_acl(array(':all'));
-       }
-
-       /* Cancel dialogs */
-       if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
-               del_lock ($this->apptabs->dn);
-               unset ($this->apptabs);
-               $this->apptabs= NULL;
-               unset ($_SESSION['objectinfo']);
-       }
-
-       /* Finish apps edit is triggered by the tabulator dialog, so
-          the user wants to save edited data. Check and save at this
-          point. */
-       if (isset($_POST['edit_finish'])){
-
-               /* Check tabs, will feed message array */
-               $this->apptabs->last= $this->apptabs->current;
-               $this->apptabs->save_object();
-               $message= $this->apptabs->check();
-
-               /* Save, or display error message? */
-               if (count($message) == 0){
-
-                       /* Save data data to ldap */
-                       $this->apptabs->save();
+         /* Save data */
+         $appfilter    = get_global("appfilter");
+         $smarty       = get_smarty();             // Smarty instance
+         $s_action     = "";                       // Contains the action to proceed
+         $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+            $s_action="open";
+            $s_entry = base64_decode($_GET['dep_id']);
+            $appfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+            $this->reload();
+    }
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/appl_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/appl_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/appl_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/appl_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/appl_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $appfilter['depselect']= $_POST['depselect'];
+      $this->reload();
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $appfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $appfilter['depselect']=(preg_replace("/^[^,]+,/","",$appfilter['depselect']));
+      $this->reload();
+    }
+
+    if($s_action=="root"){
+      $appfilter['depselect']=($this->config->current['BASE']);
+      $this->reload();
+    }
+
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$appfilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $appfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $appfilter['depselect']= $this->config->departments["/"];
+      }
+      $this->reload();
+    }
+
+    if (isset($_POST['regex'])){
+      $appfilter['regex']= $_POST['regex'];
+    }
+    if (isset($_GET['search'])){
+      $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+      if ($s == "**"){
+        $s= "*";
+      }
+      $appfilter['regex']= $s;
+    }
+    register_global("appfilter", $appfilter);
+
+    /* Check sorting variable */
+    if (!isset($this->apptabs) &&
+        !isset($_POST['new_app']) &&
+        !isset($_POST['delete_app']) &&
+        !isset($_POST['select_app'])){
+      $this->reload();
+    }
+    $smarty= get_smarty();
+
+    /* Check for exeeded sizelimit */
+    if (($message= check_sizelimit()) != ""){
+      return($message);
+    }
+
+
+    /* New application? */
+    if ($s_action=="new"){
+
+      /* By default we set 'dn' to 'new', all relevant plugins will
+         react on this. */
+      $this->dn= "new";
+
+      /* Create new usertab object */
+      $this->apptabs= new apptabs($this->config,
+          $this->config->data['TABS']['APPSTABS'], $this->dn);
+      $this->apptabs->set_acl(array(':all'));
+    }
+
+    /* Cancel dialogs */
+    if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
+      del_lock ($this->apptabs->dn);
+      unset ($this->apptabs);
+      $this->apptabs= NULL;
+      unset ($_SESSION['objectinfo']);
+    }
+
+    /* Finish apps edit is triggered by the tabulator dialog, so
+       the user wants to save edited data. Check and save at this
+       point. */
+    if (isset($_POST['edit_finish'])){
+
+      /* Check tabs, will feed message array */
+      $this->apptabs->last= $this->apptabs->current;
+      $this->apptabs->save_object();
+      $message= $this->apptabs->check();
+
+      /* Save, or display error message? */
+      if (count($message) == 0){
+
+        /* Save data data to ldap */
+        $this->apptabs->save();
                        gosa_log ("Application object'".$this->dn."' has been saved");
 
                        /* Application has been saved successfully, remove lock from
@@ -136,10 +208,10 @@ class applicationManagement extends plugin
        }
 
        /* User wants to edit data? */
-       if ((isset($_POST['select_app']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['applist']) && $_POST['applist'] != ""){
+       if ($s_action=="edit"){
 
                /* Get 'dn' from posted 'applist', must be unique */
-               $this->dn= trim($_POST['applist']);
+               $this->dn= $this->applications[$s_entry]['dn'];
 
                /* Check locking, save current plugin in 'back_plugin', so
                   the dialog knows where to return. */
@@ -162,10 +234,10 @@ class applicationManagement extends plugin
        }
 
        /* Remove user was requested */
-       if (isset($_POST['delete_app']) && isset($_POST['applist'])){
+       if ($s_action == "del"){
 
                /* Get 'dn' from posted 'uid' */
-               $this->dn= trim($_POST['applist']);
+               $this->dn= $this->applications[$s_entry]['dn'];
 
                /* Load permissions for selected 'dn' and check if
                   we're allowed to remove this 'dn' */
@@ -244,22 +316,97 @@ class applicationManagement extends plugin
                 return ($display);
         }
 
-       /* Show main page */
-       $smarty->assign("applications", $this->applications);
-       $smarty->assign("search_image", get_template_path('images/search.png'));
-       $smarty->assign("tree_image", get_template_path('images/tree.png'));
-        $smarty->assign("infoimage", get_template_path('images/info.png'));
-        $smarty->assign("launchimage", get_template_path('images/launch.png'));
-       $smarty->assign("deplist", $this->config->idepartments);
-        foreach( array("depselect", "regex") as $type){
-                $smarty->assign("$type", $appfilter[$type]);
+        /* Show main page */
+
+        /* Prepare departments */
+        $options= "";
+        foreach ($this->config->idepartments as $key => $value){
+          if ($appfilter['depselect'] == $key){
+            $options.= "<option selected value='$key'>$value</option>";
+          } else {
+            $options.= "<option value='$key'>$value</option>";
+          }
         }
        
-       /* Extend if we are not using javascript */
+        // Managment
+        $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+          " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+          " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+          " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
+          " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+          " <input type='image' align='middle' src='images/list_new_app.png' alt='"._("new")."' name='appl_new'>&nbsp;".
+          " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+          _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+          " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+          "</div>";
+
+
+        $actions = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='appl_edit_%KEY%' title='"._("Edit this entry")."'>";
+        $actions.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='appl_del_%KEY%' title='"._("Delete this entry")."'>";
+
+        // Defining Links
+        $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+        // image Buttons
+        $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+        $userimg  = "<img src='images/select_groups.png' alt='User'    title='%s'>";
+
+        // Extension images
+        $applimg  = "<img src='images/select_application.png' alt='A'  title='"._("Application")."'>";
+
+        // Space
+        $empty    = "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
+
+
+        $divlist = new divlist();
+        $divlist->SetHeader(array(
+              array("string" => ""),
+              array("string" => _("Application name")." / "._("Department")),
+              array("string" => _("Actions")    ,"attach"=>"style='border:none;width:40px;'")
+              ));
+
+
+        $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
+        $divlist->SetEntriesPerPage(20);
+
+        foreach($this->departments as $key=> $val){
+
+          $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+          $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+          $field3 = array("string" => "&nbsp;","attach"=>"style='text-align:right;border:none'");
+
+          $divlist->AddEntry(array($field1,$field2,$field3));
+        }
+
+        foreach($this->applications as $key => $val){
+          $title = "title='gid : ".$key." - dn : ".$val['dn']."'";
+
+          if(!isset($val['description'][0])){
+            $desc = "";
+          }else{
+            $desc = " - [ ".$val['description'][0]." ]";
+          }
+          $field1 = array("string" => sprintf($applimg,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+          $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)),"attach"=>$title);
+          $field3 = array("string" => preg_replace("/%KEY%/", $key, $actions),"attach"=>"style='text-align:right;border:none'");
+
+          $divlist->AddEntry(array($field1,$field2,$field3));
+        }
+
+        $smarty->assign("applicationshead", $listhead);
+        $smarty->assign("applications", $divlist->DrawList());
+        $smarty->assign("search_image", get_template_path('images/search.png'));
+        $smarty->assign("tree_image", get_template_path('images/tree.png'));
+        $smarty->assign("infoimage", get_template_path('images/info.png'));
+        $smarty->assign("launchimage", get_template_path('images/launch.png'));
+        $smarty->assign("deplist", $this->config->idepartments);
+        $smarty->assign("regex", $appfilter['regex']);
+
+        /* Extend if we are not using javascript */
         $smarty->assign("apply", apply_filter());
         $smarty->assign("alphabet", generate_alphabet());
-       $smarty->assign("hint", print_sizelimit_warning());
-       
+        $smarty->assign("hint", print_sizelimit_warning());
+
         return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
   }
 
@@ -278,19 +425,39 @@ class applicationManagement extends plugin
         } else {
                 $regex= "*";
         }
-       
-       /* Generate application list */
-       $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)(objectClass=gosaApplication))", TRUE, $base, array("cn", "description"), TRUE);
-       $this->applications= array();
-       foreach ($res as $value){
-               $this->applications[$value["dn"]]= $value["cn"][0];
-               if (isset($value["description"][0])){
-                       $this->applications[$value["dn"]]= $value["cn"][0]." (".
-                                       $value["description"][0].")";
-               }
-       }
-       natcasesort ($this->applications);
-       reset ($this->applications);
+
+        /* Generate application list */
+        $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)(objectClass=gosaApplication))", TRUE, $base, array("*"), TRUE);
+        $this->applications= array();
+        foreach ($res as $value){
+          $this->applications[]= $value;
+        }
+        reset ($this->applications);
+
+
+
+        /* NEW LIST MANAGMENT
+         * We also need to search for the departments
+         * So we are able to navigate like in konquerer
+         */
+        $base2 = preg_replace("/ou=people,/i","",$base);
+
+        $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+            TRUE, $base2, array("ou", "description"), TRUE);
+
+        $this->departments= array();
+        foreach ($res3 as $value){
+          if($value["description"][0]!=".."){
+            $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+          }else{
+            $this->departments[$value['dn']]=$value["description"][0];
+          }
+        }
+
+        /* END NEW LIST MANAGMENT
+         */
+
+
   }
 
   function remove_from_parent()
@@ -339,5 +506,5 @@ class applicationManagement extends plugin
   }
 
 }
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 8daa16fe8314ae83958d296e35681b244b85ebac..65f69d467f135be07c0778e7695564dabdffa9a1 100644 (file)
@@ -7,17 +7,12 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select style="width:500px; height:450px;" name="applist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-      {html_options options=$applications}
-               <option disabled>&nbsp;</option>
-    </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_app">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_app">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_app">&nbsp;
+      {$applicationshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+      {$applications}
     <input type=hidden name="edit_helper">
-   </p>
   </div>
   </td>
   <td style="vertical-align:top">
@@ -28,9 +23,6 @@
    <p class="contentboxb">
     {t}This menu allows you to add, edit and remove selected applications. You may want to use the range selector on top of the application listbox, when working with a large number of applications.{/t}
    </p>
-   <p class="contentboxb">
-    {t}-Edit- and -New...- will execute an assistant to aid you in editing properties. -Delete- will ask for confirmation before removing applications.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
     <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
                <tr>
                        <td>
-                               <img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display applications of department{/t}
-                       </td>
-                   <td>
-                               <select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-                                 {html_options options=$deplist selected=$depselect}
-                               </select>
-                       </td>
-               </tr>
-       </table>
-    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-               <tr>
-                       <td>
-                               <img alt="" src="{$search_image}" align=middle>&nbsp;<LABEL for="regex">{t}Display applications matching{/t}</LABEL>
+                               <LABEL for="regex"><img alt="" src="{$search_image}" align=middle title='{t}Display applications matching{/t}'>&nbsp;</LABEL>
                        </td>
                <td>
-                               <input type='text' id="regex" name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching application names{/t}' onChange="mainform.submit()">
+                               <input style='width:99%' type='text' id="regex" name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching application names{/t}' onChange="mainform.submit()">
                        </td>
                </tr>
        </table>
index 8e34de931c9672c2a4f4d00817ac3a1922259b8a..38753f4b171a9a38fd8b77c4e86453203709576f 100644 (file)
 <?php
 /*
-  This code is part of GOsa (https://gosa.gonicus.de)
-  Copyright (C) 2003  Cajus Pollmeier
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2003  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 require "tabs_department.inc";
 
 class departmentManagement extends plugin
 {
-  /* Definitions */
-  var $plHeadline= "Departments";
-  var $plDescription= "This does something";
-
-  /* CLI vars */
-  var $cli_summary= "Handling of LDAP subtrees";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
-  /* Headpage attributes */
-  var $last_dep_sorting= "invalid";
-  var $departments= array();
-  var $deptabs= NULL;
-
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-
-  function departmentManagement ($config, $ui)
-  {
-       $this->ui= $ui;
-       $this->dn= "";
-       $this->config= $config;
-
-        /* Get global filter config */
-        if (!is_global("depfilter")){
-                $base= get_base_from_people($ui->dn);
-                $depfilter= array("depselect" => $base,
-                                  "regex" => "*");
-                register_global("depfilter", $depfilter);
-        }
-  }
-
-  function execute()
-  {
-       /* Reload departments */
-       $this->config->departments= get_departments();
-       $this->config->make_idepartments();
-       $smarty= get_smarty();
-
-        /* Save data */
-        $depfilter= get_global("depfilter");
-        foreach( array("depselect", "regex") as $type){
-                if (isset($_POST[$type])){
-                        $depfilter[$type]= $_POST[$type];
-                }
-        }
-        if (isset($_GET['search'])){
-                $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-                if ($s == "**"){
-                        $s= "*";
-                }
-                $depfilter['regex']= $s;
-        }
-        register_global("depfilter", $depfilter);
-
-
-       /* Create new department? */
-       if (isset($_POST['new_department'])){
-               $this->acl= array(":all");
-               $this->dn= "new";
-
-                /* Register deptabs to trigger edit dialog */
-               $this->deptabs= new deptabs($this->config,
-                               $this->config->data['TABS']['DEPTABS'], $this->dn);
-               $this->deptabs->set_acl($this->acl);
+       /* Definitions */
+       var $plHeadline= "Departments";
+       var $plDescription= "This does something";
+
+       /* CLI vars */
+       var $cli_summary= "Handling of LDAP subtrees";
+       var $cli_description= "Some longer text\nfor help";
+       var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+       /* Headpage attributes */
+       var $last_dep_sorting= "invalid";
+       var $departments= array();
+       var $deptabs= NULL;
+
+       /* attribute list for save action */
+       var $attributes= array();
+       var $objectclasses= array();
+
+       function departmentManagement ($config, $ui)
+       {
+               $this->ui= $ui;
+               $this->dn= "";
+               $this->config= $config;
+
+               /* Get global filter config */
+               if (!is_global("depfilter")){
+                       $base= get_base_from_people($ui->dn);
+                       $depfilter= array("depselect" => $base,
+                                       "regex" => "*");
+                       register_global("depfilter", $depfilter);
+               }
        }
 
-       /* Edit existing department */
-       if ((isset($_POST['select_department']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['deplist']) != ""){
-               $this->dn= $this->config->departments[trim($_POST['deplist'])];
+       function execute()
+       {
+               /* Reload departments */
+               $this->config->departments      = get_departments();
+               $smarty                                         = get_smarty();
+               $display                                        = "";
+               $depfilter                                      = get_global("depfilter");
+               $s_action                                       = "";  // Will contain an action, like del or edit
+               $s_entry                                        = "";  // The entry name for edit delete -...
+
+               $this->config->make_idepartments();
 
-               /* Check locking, save current plugin in 'back_plugin', so
-                  the dialog knows where to return. */
-               if (($user= get_lock($this->dn)) != ""){
-                       return(gen_locked_message ($user, $this->dn));
+               if (isset($_POST['regex'])){
+                       $depfilter['regex']= $_POST['regex'];
                }
 
-               /* Lock the current entry, so everyone will get the
-                  above dialog */
-               add_lock ($this->dn, $this->ui->dn);
+               // Check Post action
+               foreach($_POST as $key => $val){
+                       // Post for delete
+                       if(preg_match("/dep_del.*/",$key)){
+                               $s_action = "del";
+                               $s_entry  = preg_replace("/dep_".$s_action."_/i","",$key);
+                       // Post for edit
+                       }elseif(preg_match("/dep_edit_.*/",$key)){
+                               $s_action="edit";
+                               $s_entry  = preg_replace("/dep_".$s_action."_/i","",$key);
+                               // Post for new
+                       }elseif(preg_match("/dep_new.*/",$key)){
+                               $s_action="new";
+                       }elseif(preg_match("/dep_back.*/i",$key)){
+                               $s_action="back";
+                       }elseif(preg_match("/dep_home.*/i",$key)){
+                               $s_action="home";
+                       }elseif(preg_match("/dep_root.*/i",$key)){
+                               $s_action="root";
+                       }
+               }
 
-               /* Set up the users ACL's for this 'dn' */
-               $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+               if(isset($_POST['depselect']) && $_POST['depselect']){
+                       $depfilter['depselect']= $_POST['depselect'];
+            $this->reload();
+               }
+               
+               if($s_action=="root"){
+                       $depfilter['depselect']=($this->config->current['BASE']);
+                       $this->reload();
+               }
 
-                /* Register deptabs to trigger edit dialog */
-               $this->deptabs= new deptabs($this->config,
-                               $this->config->data['TABS']['DEPTABS'], $this->dn);
-               $this->deptabs->set_acl($this->acl);
-               $_SESSION['objectinfo']= $this->dn;
-       }
+               if($s_action=="home"){
+                       $depfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+                       $depfilter['depselect']=(preg_replace("/^[^,]+,/","",$depfilter['depselect']));
+                       $this->reload();
+               }
 
+               if($s_action=="back"){
+                       $base_back                      = preg_replace("/^[^,]+,/","",$depfilter['depselect']);
+                       $base_back          = convert_department_dn($base_back);
+            
+                       if(isset($this->config->departments[trim($base_back)])){
+                               $depfilter['depselect']= $this->config->departments[trim($base_back)];
+                       }else{
+                               $depfilter['depselect']= $this->config->departments["/"];
+                       }
+            $this->reload();
+               }
 
-       /* Delete requested department */
-       $display= "";
-       if (isset($_POST['delete_department']) && isset($_POST['deplist'])){
-               $this->dn= $this->config->departments[trim($_POST['deplist'])];
+               if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+                       $s_action="open";
+                       $s_entry = base64_decode($_GET['dep_id']);
+                       $depfilter['depselect']= $this->config->departments[trim($s_entry)];
+                       $this->reload();
+               }
 
-               /* Check locking */
-               if (($user= get_lock($this->dn)) != ""){
-                       $_SESSION['dn']= $this->dn;
-                       return(gen_locked_message($user, $this->dn));
-               } else {
-                       # Lock this dn for editing
-                       add_lock ($this->dn, $this->ui->dn);
 
-                       $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn));
-                       $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
-                       return ($display);
+               $s_entry  = preg_replace("/_.*/","",$s_entry);
+
+               if (isset($_GET['search'])){
+                       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+                       if ($s == "**"){
+                               $s= "*";
+                       }
+                       $depfilter['regex']= $s;
                }
-       }
+               register_global("depfilter", $depfilter);
 
-       /* Finally delete department */
-       if (isset($_POST['delete_department_confirm'])){
-               $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-               $acl= get_module_permission($acl, "department", $this->dn);
-               if (chkacl($acl, "all") == ""){
-                       $this->remove_from_parent();
-                       gosa_log ("Department object'".$this->dn."' has been removed");
-                       $this->reload ();
-               } else {
-                       print_red (_("You have no permission to remove this department."));
+               /* New Entry if Posted action (s_action) == new
+                */
+               if ($s_action=="new"){
+                       $this->acl= array(":all");
+                       $this->dn= "new";
+
+                       $this->deptabs= new deptabs($this->config,
+                                       $this->config->data['TABS']['DEPTABS'], $this->dn);
+                       $this->deptabs->set_acl($this->acl);
                }
-       }
 
-       /* Finish request */
-       if (isset($_POST['edit_finish'])){
+               /* Edit Entry if Posted action (s_action) == edit 
+                * The entry which will be edited is defined in $s_entry
+                */
+               if ($s_action=="edit"){
 
-                /* Check tabs, will feed message array */
-                $message= $this->deptabs->check();
+                       $this->dn= $this->config->departments[trim($s_entry)];
 
-                /* Save, or display error message? */
-                if (count($message) == 0){
+                       if (($user= get_lock($this->dn)) != ""){
+                               return(gen_locked_message ($user, $this->dn));
+                       }
 
-                        /* Save user data to ldap */
-                        $this->deptabs->save();
-                        gosa_log ("Department object'".$this->dn."' has been saved");
+                       /* Lock the current entry, so everyone will get the  above dialog */
+                       add_lock ($this->dn, $this->ui->dn);
 
-                        /* Group has been saved successfully, remove lock from
-                           LDAP. */
-                        if ($this->dn != "new"){
-                                del_lock ($this->dn);
-                        }
+                       /* Set up the users ACL's for this 'dn' */
+                       $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
 
-                        /* There's no page reload so we have to read new users at
-                           this point. */
-                        $this->reload ();
-                        unset ($this->deptabs);
-                        $this->deptabs= NULL;
-                       unset ($_SESSION['objectinfo']);
+                       /* Register deptabs to trigger edit dialog */
+                       $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn);
+                       $this->deptabs->set_acl($this->acl);
+                       $_SESSION['objectinfo']= $this->dn;
+               }
 
-                } else {
-                        /* Ok. There seem to be errors regarding to the tab data,
-                           show message and continue as usual. */
-                        show_errors($message);
-                }
-        }
+               /* Delete Entry if Posted action (s_action) == del 
+         * The entry which will be deleted is defined in $s_entry
+                */
+               if ($s_action =="del"){
+                       $this->dn= $this->config->departments[trim($s_entry)];
+
+                       /* Check locking */
+                       if (($user= get_lock($this->dn)) != ""){
+                               $_SESSION['dn']= $this->dn;
+                               return(gen_locked_message($user, $this->dn));
+                       } else {
+                               add_lock ($this->dn, $this->ui->dn);
+                               $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn));
+                               $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
+                               return ($display);
+                       }
+               }
 
+               /* If department deletion is accepted ...
+                * Finally delete department 
+                */
+               if (isset($_POST['delete_department_confirm'])){
+                       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+                       $acl= get_module_permission($acl, "department", $this->dn);
+                       if (chkacl($acl, "all") == ""){
+                               $this->remove_from_parent();
+                               gosa_log ("Department object'".$this->dn."' has been removed");
+                               $this->reload ();
+                       } else {
+                               print_red (_("You have no permission to remove this department."));
+                       }
+               }
 
-       /* Cancel dialog */
-       if (isset($_POST['edit_cancel']) || isset($_POST['delete_cancel']) ||
-               isset($_POST['delete_department_confirm']) || isset($_POST['delete_lock'])){
+               /* Edit Complete ...
+                * Finish request 
+         */
+               if (isset($_POST['edit_finish'])){
+
+                       /* Check tabs, will feed message array */
+                       $message= $this->deptabs->check();
+
+                       /* Save, or display error message? */
+                       if (count($message) == 0){
+
+                               /* Save user data to ldap */
+                               $this->deptabs->save();
+                               gosa_log ("Department object'".$this->dn."' has been saved");
+
+                               /* Group has been saved successfully, remove lock from
+                                  LDAP. */
+                               if ($this->dn != "new"){
+                                       del_lock ($this->dn);
+                               }
+
+                               /* There's no page reload so we have to read new users at
+                                  this point. */
+                               $this->reload ();
+                               unset ($this->deptabs);
+                               $this->deptabs= NULL;
+                               unset ($_SESSION['objectinfo']);
+
+                       } else {
+                               /* Ok. There seem to be errors regarding to the tab data,
+                                  show message and continue as usual. */
+                               show_errors($message);
+                       }
+               }
 
-               del_lock ($this->dn);
-               unset($this->depdabs);
-               $this->deptabs= NULL;
-               unset ($_SESSION['objectinfo']);
-       }
+
+               /* User cancelt edit oder delete
+         * Cancel dialog 
+         */
+               if (isset($_POST['edit_cancel']) || isset($_POST['delete_cancel']) ||
+                               isset($_POST['delete_department_confirm']) || isset($_POST['delete_lock'])){
+
+                       del_lock ($this->dn);
+                       unset($this->depdabs);
+                       $this->deptabs= NULL;
+                       unset ($_SESSION['objectinfo']);
+               }
 
 
-       /* Headpage or normal plugin screen? */
-       if ($this->deptabs == NULL){
-               /* Check sorting variable */
-               $this->reload();
-
-               /* Check for exeeded sizelimit */
-               if (($message= check_sizelimit()) != ""){
-                       return($message);
-               }
-
-               /* Show main page */
-               $smarty->assign("departments", $this->departments);
-               $smarty->assign("search_image", get_template_path('images/search.png'));
-               $smarty->assign("tree_image", get_template_path('images/tree.png'));
-               $smarty->assign("infoimage", get_template_path('images/info.png'));
-               $smarty->assign("launchimage", get_template_path('images/launch.png'));
-               $smarty->assign("deplist", $this->config->idepartments);
-               foreach( array("depselect", "regex") as $type){
-                       $smarty->assign("$type", $depfilter[$type]);
+               /* Headpage or normal plugin screen? */
+               if ($this->deptabs == NULL){
+                       /* Check sorting variable */
+                       $this->reload();
+
+                       /* Check for exeeded sizelimit */
+                       if (($message= check_sizelimit()) != ""){
+                               return($message);
+                       }
+
+                       /* Prepare departments */
+                       $options= "";
+                       foreach ($this->config->idepartments as $key => $value){
+                               if ($depfilter['depselect'] == $key){
+                                       $options.= "<option selected value='$key'>$value</option>";
+                               } else {
+                                       $options.= "<option value='$key'>$value</option>";
+                               }
+                       }
+
+                       /* Generate list head */
+                       $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+                                               " <input type='image' src='images/list_up.png' align='middle' title='"._("Go up one department")."' name='dep_back' alt='"._("Up")."'>&nbsp;".
+                                               " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+                                               " <input type='image' src='images/list_home.png' align='middle' title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
+                                               " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+                                               " <input type='image' src='images/list_new_department.png' align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp;".
+                                               " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+                                               _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+                                               " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+                                               "</div>";
+
+                       /* Show main page */
+                       $divlist = new divlist();
+                       $divlist->SetSummary(_("This table displays all departments, in the selected tree."));
+                       $divlist->SetEntriesPerPage(20);
+                       $actions= "<input type='image' src='images/edit.png'             alt='"._("edit")."'    name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+                       $actions.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."'        name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
+
+                       $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+                       $divlist->SetHeader(array(array("string" => "&nbsp;"),
+                                                                         array("string"=>_("Department name")),
+                                      array("string" =>_("Actions"), "attach" => "style='text-align:  right;border:none'")));
+
+                       foreach($this->departments as $key => $val) {
+                               if(!isset($this->config->departments[trim($key)])){
+                                       $this->config->departments[trim($key)]="";
+                               }
+                               $field0 = array("string" => "<img src='images/folder.png' alt='department'>","attach"=>"style='width:20px;'");
+                               $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "width='100%'");
+                               $field2 = array("string" => preg_replace("/%KEY%/", $key, $actions),"attach"=>"style='text-align:right;border:none'");
+
+                               $divlist->AddEntry( array($field0,$field1,$field2));
+
+                       }
+                       $smarty->assign("departments",$divlist->DrawList() );
+                       $smarty->assign("departmentshead",$listhead);
+                       $smarty->assign("search_image", get_template_path('images/search.png'));
+                       $smarty->assign("tree_image", get_template_path('images/tree.png'));
+                       $smarty->assign("infoimage", get_template_path('images/info.png'));
+                       $smarty->assign("launchimage", get_template_path('images/launch.png'));
+                       $smarty->assign("deplist", $this->config->idepartments);
+
+                       foreach( array("depselect", "regex") as $type){
+                               $smarty->assign("$type", $depfilter[$type]);
+                       }
+
+                       /* Extend if we are not using javascript */
+                       $smarty->assign("apply", apply_filter());
+                       $smarty->assign("alphabet", generate_alphabet());
+                       $smarty->assign("hint", print_sizelimit_warning());
+
+                       $display= $smarty->fetch(get_template_path('headpage.tpl', TRUE));
+                       return($display);
                }
 
-               /* Extend if we are not using javascript */
-               $smarty->assign("apply", apply_filter());
-               $smarty->assign("alphabet", generate_alphabet());
-               $smarty->assign("hint", print_sizelimit_warning());
+               /* Show main page (tabs) */
+               $display= $this->deptabs->execute();
+
+               $display.= "<p style=\"text-align:right\">\n";
+               $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
+               $display.= "&nbsp;\n";
+               $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+               $display.= "</p>";
 
-               $display= $smarty->fetch(get_template_path('headpage.tpl', TRUE));
-               return($display);
+               return ($display);
        }
 
-       /* Show main page (tabs) */
-       $display= $this->deptabs->execute();
 
-       $display.= "<p style=\"text-align:right\">\n";
-       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
-       $display.= "&nbsp;\n";
-       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-       $display.= "</p>";
+       function reload()
+       {
+               /* Get config */
+               $depfilter= get_global('depfilter');
+               // Added for dirlist function...
+
+               if(isset($_POST['deplist'])){
+                       $depfilter= get_global("depfilter");
+                       $depfilter['depselect']= $this->config->departments[trim($_POST['deplist'])];
+                       register_global("depfilter", $depfilter);
+               }
+
+               /* Set base for all searches */
+               $base= $depfilter['depselect'];
+
+               /* Regex filter? */
+               if ($depfilter['regex'] != ""){
+                       $regex= $depfilter['regex'];
+               } else {
+                       $regex= "*";
+               }
 
-       return ($display);
-  }
+               // Configure Back Address
+               $base_back = preg_replace("/^[^,]+,/","",$base);
 
+               // Create Array to Test if we have a valid back button
+               $tmp = array_flip($_SESSION['config']->departments);
 
-  function reload()
-  {
-       /* Get config */
-        $depfilter= get_global('depfilter');
+               // In case of a valid back button create entry
+               if(isset($tmp[$base_back])){
+                       $tmp2    ['dn']          = convert_department_dn($base_back);
 
-        /* Set base for all searches */
-        $base= $depfilter['depselect'];
+                       // If empty always go to top
+                       if(empty($tmp2['dn'])){
+                               $tmp2['dn']="/";
+                       }
+                       $tmp2    ['description'][0] = _("..");
+                       $result[$tmp[$base_back]]=$tmp2;
+               }
 
-        /* Regex filter? */
-        if ($depfilter['regex'] != ""){
-                $regex= $depfilter['regex'];
-        } else {
-                $regex= "*";
-        }
+               $res= get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", 
+                               TRUE, $base, array("ou", "description"), TRUE);
+
+               //hickert Replaced Block
+               //    $this->departments= array();
+               //    foreach ($res as $value){
+               //           $title= convert_department_dn($value["dn"]);
+               //           $this->departments[$title]= "$title [".$value["description"][0]."]";
+               //           $this->departments[$value['dn']]= "[".$value["description"][0]."]";
+               //    }
+
+               $this->departments= array();
+               foreach ($res as $value){
+                       if($value["description"][0]!=".."){
+                               $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+                       }else{
+                               $this->departments[$value['dn']]=$value["description"][0];
+                       }
+               }
+               natcasesort ($this->departments);
+               reset ($this->departments);
+       }
 
-       /*Get all gosaDepartments */
-       $res= get_list($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", TRUE, $base, array("ou", "description"), TRUE);
+       function remove_from_parent()
+       {
+               $ldap= $this->config->get_ldap_link();
+               $ldap->cd ($this->dn);
+               $ldap->recursive_remove();
+
+               /* Optionally execute a command after we're done */
+               $this->postremove();
+
+               /* Delete references to object groups */
+               $ldap->cd ($this->config->current['BASE']);
+               $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+               while ($ldap->fetch()){
+                       $og= new ogroup($this->config, $ldap->getDN());
+                       unset($og->member[$this->dn]);
+                       $og->save ();
+               }
 
-       $this->departments= array();
-       foreach ($res as $value){
-               $title= convert_department_dn($value["dn"]);
-               $this->departments[$title]= "$title [".$value["description"][0]."]";
        }
-       natcasesort ($this->departments);
-       reset ($this->departments);
-  }
-
-  function remove_from_parent()
-  {
-       $ldap= $this->config->get_ldap_link();
-       $ldap->cd ($this->dn);
-       $ldap->recursive_remove();
-
-       /* Optionally execute a command after we're done */
-       $this->postremove();
-
-        /* Delete references to object groups */
-        $ldap->cd ($this->config->current['BASE']);
-        $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
-        while ($ldap->fetch()){
-                $og= new ogroup($this->config, $ldap->getDN());
-                unset($og->member[$this->dn]);
-                $og->save ();
-        }
-
-  }
-
-  function remove_lock()
-  {
-       if (isset($this->dn)){
-               del_lock ($this->dn);
+
+       function remove_lock()
+       {
+               if (isset($this->dn)){
+                       del_lock ($this->dn);
+               }
        }
-  }
 
-}
+       }
 
-?>
+       ?>
index 6366a594cc90af727adc2bb4a6bf529f730aeed5..e5672bca52e32b2f059ef167bbffc88b1261cb6c 100644 (file)
@@ -1,23 +1,18 @@
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
 <tr>
-  <td style="vertical-align:top;">
+  <td style="vertical-align:top;width:600px">
   <div class="contentboxh">
     <p class="contentboxh">
      {t}List of departments{/t} {$hint}
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select style="width:500px; height:450px;" name="deplist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-      {html_options options=$departments}
-       <option disabled>&nbsp;</option> 
-       </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_department">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_department">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_department">&nbsp;
+      {$departmentshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+      {$departments}
     <input type=hidden name="edit_helper">
-   </p>
   </div>
   </td>
   <td style="vertical-align:top;">
@@ -28,9 +23,6 @@
    <p class="contentboxb">
      {t}This menu allows you to create, delete and edit selected departments. Having a large size of departments, you might prefer the range selectors on top of the department list.{/t}
    </p>
-   <p class="contentboxb">
-     {t}-Edit- and -New...- will provide an assistant to aid you when performing changes on your departments. -Delete- will ask for confirmation before deleting departments.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
      </table>
     <table summary=""  style="width:100%;border-top:1px solid #B0B0B0;">
                        <tr>
-                                       <td width="50%"><img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display subdepartments of{/t}</td>
-                                   <td>
-                                               <select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-                                                     {html_options options=$deplist selected=$depselect}
-                                           </select>
-                                       </td>
-                       </tr>
-       </table>
-    <table summary=""  style="width:100%;border-top:1px solid #B0B0B0;">
-                       <tr>
-                               <td width="50%">
-                                               <img alt="" src="{$search_image}" align=middle>&nbsp;{t}Display departments matching{/t}</td>
+                               <td>
+                                               <img alt="" src="{$search_image}" align=middle title='{t}Display departments matching{/t}'></td>
                            <td>
-                                               <input id="regex" type='text' name='regex' maxlength='20' value='{$regex}' 
+                                               <input id="regex" type='text' name='regex' maxlength='20' style='width:99%' value='{$regex}' 
                                                        title='{t}Regular expression for matching department names{/t}' onChange="mainform.submit()">
                                </td>
                        </tr>
index d9463cc1e10873e5822feafb104dfeae4a33bb9f..680d36a3c7cd358d50dea0056c3977c8dcaaa699 100644 (file)
@@ -24,6 +24,7 @@ class groupManagement extends plugin
   /* Definitions */
   var $plHeadline= "Groups";
   var $plDescription= "This does something";
+  var $departments = array();
 
   /* Dialog attributes */
   var $grouptab= NULL;
@@ -57,13 +58,17 @@ class groupManagement extends plugin
   {
     /* Save data */
     $groupfilter= get_global("groupfilter");
+    $s_action   = "";
+    $s_entry    = "";
+
+
     if (!isset($this->grouptab)){
       foreach( array("depselect", "guser", "regex") as $type){
         if (isset($_POST[$type])){
           $groupfilter[$type]= $_POST[$type];
         } 
       }
-      if (isset($_POST['depselect'])){
+      if (isset($_POST['regex'])){
         foreach( array("primarygroups", "sambagroups", "mailgroups", "appgroups",
               "functionalgroups", "subsearch") as $type){
 
@@ -84,6 +89,81 @@ class groupManagement extends plugin
       register_global("groupfilter", $groupfilter);
     }
 
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/group_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/group_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/group_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/group_tplnew.*/i",$key)){
+        $s_action="new_tpl";
+      }elseif(preg_match("/group_chgpw.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/group_chgpw_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+    $s_entry  = preg_replace("/_.$/","",$s_entry); 
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+      $s_action="open";
+      $s_entry = base64_decode($_GET['dep_id']);
+      $groupfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+      $this->reload();
+    }
+
+    // Edit if
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $groupfilter['depselect']= $_POST['depselect'];
+      $this->reload();
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $groupfilter['depselect']= (preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $groupfilter['depselect']= (preg_replace("/^[^,]+,/","",$groupfilter['depselect']));
+      $this->reload();
+    }
+
+    if($s_action=="root"){
+      $groupfilter['depselect']=($this->config->current['BASE']);
+      $this->reload();
+    }
+
+    /* If Backbutton is Posted */
+    if($s_action == "back"){
+      $base_back= preg_replace("/^[^,]+,/","",$groupfilter['depselect']);
+      $base_back= convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $groupfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $groupfilter['depselect']= $this->config->departments["/"];
+      }
+      $this->reload();
+    }
+    register_global("groupfilter", $groupfilter);
+
     $smarty= get_smarty();
 
     /* Prepare formular */
@@ -100,7 +180,7 @@ class groupManagement extends plugin
     }
 
     /* New group? */
-    if (isset($_POST['new_group'])){
+    if ($s_action=="new"){
 
       /* By default we set 'dn' to 'new', all relevant plugins will
          react on this. */
@@ -156,10 +236,10 @@ class groupManagement extends plugin
     }
 
     /* User wants to edit data? */
-    if ((isset($_POST['select_group']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['grouplist']) && $_POST['grouplist'] != ""){
+    if ($s_action=="edit"){
 
       /* Get 'dn' from posted 'uid', must be unique */
-      $this->dn= trim($_POST['grouplist']);
+      $this->dn= $this->grouplist[trim($s_entry)]['dn'];
 
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
@@ -182,10 +262,9 @@ class groupManagement extends plugin
     }
 
     /* Remove user was requested */
-    if (isset($_POST['delete_group']) && isset($_POST['grouplist'])){
-
+    if ($s_action=="del"){
       /* Get 'dn' from posted 'uid' */
-      $this->dn= trim($_POST['grouplist']);
+      $this->dn= $this->grouplist[trim($s_entry)]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -264,16 +343,109 @@ class groupManagement extends plugin
       return ($display);
     }
 
+    /* Prepare departments */
+    $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($groupfilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+
+    // Managment
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+      " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+      " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+      " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."'
+ alt='"._("Home")."' name='dep_home'>&nbsp;".
+      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      " <input type='image' align='middle' src='images/list_new_group.png' title='"._("Create new group")."'
+ alt='"._("New")."' name='group_new'>&nbsp;".
+      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+       " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."'   name='submit_department' alt='"._("Submit")."'>&nbsp;".
+      "</div>";
+
+    
+    $actions = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
+    $actions.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
+
+    // Defining Links
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+    // image Buttons 
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $userimg  = "<img src='images/select_groups.png' alt='User'    title='%s'>";
+
+    // Extension images 
+    $posiximg = "<img src='images/select_groups.png'        alt='P'  title='"._("Posix")  ."'>";
+    $mailimg  = "<img src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
+    $sambaimg = "<img src='images/select_winstation.png'  alt='S'  title='"._("Samba")  ."'>";
+    $applimg  = "<img src='images/select_application.png' alt='A'  title='"._("Application")."'>"; 
+    $phoneimg  = "<img src='images/select_phone.png'      alt='Ph' title='"._("Phone")  ."'>"; 
+    // Space
+    $empty    = "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
+
+
+    $divlist = new divlist();
+    $divlist->SetHeader(array(
+          array("string" => "&nbsp;"),
+          array("string" => _("Groupname")." / "._("Department")),
+          array("string" => _("Properties"), "attach" => "style='width:100px;'"),
+          array("string" => _("Actions")    ,"attach" => "style='border:none'")
+          ));
+
+
+    $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
+    $divlist->SetEntriesPerPage(20);
+
+    foreach($this->departments as $key=> $val){
+
+      $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+      $field3 = array("string" => "&nbsp;");
+      $field4 = array("string" => "&nbsp;","attach"=>"style='text-align:right;border:none'");
+
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
+    foreach($this->grouplist as $key => $val){
+
+      if(isset($val['objectClass'])){
+        if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;   else $posix   = $empty;
+        if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;    else $mail    = $empty;
+        if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;   else $samba   = $empty;
+        if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;    else $appl    = $empty;
+        if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;   else $phone   = $empty;
+      }else{
+        $posix=$mail=$samba=$appl=$phone=$empty;
+      }
+
+      $title = "title='gid : ".$key." - dn : ".$val['dn']."'";
+
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }      
+      $field1 = array("string" => sprintf($userimg,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+      $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)),"attach"=>$title);
+      $field3 = array("string" => $posix."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone);  
+      $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions),"attach"=>"style='text-align:right;border:none;width:32px;'");
+      
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));    
+    }
+
     /* Show main page */
-    $smarty->assign("grouplist", $this->grouplist);
+    $smarty->assign("grouplisthead", $listhead);
+    $smarty->assign("grouplist", $divlist->DrawList());
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("tree_image", get_template_path('images/tree.png'));
     $smarty->assign("infoimage", get_template_path('images/info.png'));
     $smarty->assign("launchimage", get_template_path('images/launch.png'));
     $smarty->assign("deplist", $this->config->idepartments);
-    foreach( array("depselect", "guser", "regex", "primarygroups", "mailgroups",
-          "appgroups", "sambagroups", "functionalgroups", "subsearch") as $type){
-
+    foreach( array("depselect", "guser", "regex", "primarygroups", "mailgroups","appgroups", "sambagroups", "functionalgroups", "subsearch") as $type){
       $smarty->assign("$type", $groupfilter[$type]);
     }
 
@@ -355,16 +527,36 @@ class groupManagement extends plugin
       $error2= $ldap->error;
       while ($attrs= $ldap->fetch()){
         if (!isset($primaries[$attrs['gidNumber'][0]])){
-          if (isset($attrs["description"][0])){
-            $this->grouplist[$attrs["dn"]]= $attrs["cn"][0]." [".
-              $attrs["description"][0]."]";
-          } else {
-            $this->grouplist[$attrs["dn"]]= $attrs["cn"][0];
-          }
+          $this->grouplist[$attrs['gidNumber'][0]]= $attrs;
         }
       }
     }
 
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+                              TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    foreach ($res3 as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
+      }
+    }
+
+    /* END NEW LIST MANAGMENT
+     */
+
+
+
+
+
     /* Generate grouplist */
     if ($filter != ""){
       $filter= "(&(cn=$regex)(objectClass=posixGroup)(|$filter))";
@@ -383,15 +575,9 @@ class groupManagement extends plugin
     }
 
     foreach ($res as $value){
-      if (isset($value["description"][0])){
-        $this->grouplist[$value["dn"]]= $value["cn"][0]." [".
-          $value["description"][0]."]";
-      } else {
-        $this->grouplist[$value["dn"]]= $value["cn"][0];
-      }
+      $this->grouplist[$value['gidNumber'][0]]= $value;
     }
 
-    natcasesort ($this->grouplist);
     reset ($this->grouplist);
   }
 
index b828354991558cab4eed8a4a7a41ccbe9267ad2d..c9612094ef8ac82a1f241dac6269a2548a4e061b 100644 (file)
@@ -7,17 +7,12 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select id="grouplist" style="width:500px; height:450px;" name="grouplist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-      {html_options options=$grouplist}
-               <option disabled>&nbsp;</option>
-    </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_group">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_group">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_group">&nbsp;
+      {$grouplisthead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+      {$grouplist}
     <input type=hidden name="edit_helper">
-   </p>
   </div>
 
   </td>
@@ -29,9 +24,6 @@
    <p class="contentboxb">
      {t}This menu allows you to add, edit and remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.{/t}
     </p>
-    <p class="contentboxb">
-      {t}-Edit- and -New...- will execute an assistant to aid you in editing group properties. -Delete- will ask for confirmation before removing groups.{/t}
-    </p>
    </div>
    <br>
    <div class="contentboxh">
         </tr>
     </table>
 
-    
-    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-        <tr>
-            <td>
-               <input type=checkbox name="subsearch" value="1" {$subsearch} onClick="mainform.submit()" title="{t}Dive into LDAP subtrees when searching{/t}">{t}Search in subtrees{/t}<br>
-                       </td>
-               </tr>
-       </table>
-       
-    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-               <tr>
-                       <td width="50%">
-                               <img alt="" src="{$tree_image}" align=middle>&nbsp;
-                               <LABEL for="depselect">{t}Display groups of department{/t}</LABEL>
-                       </td>
-               <td>
-                               <select id="depselect" name="depselect" size=1 onChange="mainform.submit()" 
-                                               title="{t}Choose the department the search will be based on{/t}">
-                               {html_options options=$deplist selected=$depselect}
-                       </select>
-                       </td>
-               </tr>
-       </table>
     <table summary=""  style="width:100%;border-top:1px solid #B0B0B0;">
                <tr>
                        <td width="50%"><img alt="" src="{$search_image}" align=middle>&nbsp;
index 15eb4b5065983558a72ee751426c622d1b14eb61..17d0c10047e106347e3db7c7db2062d523994d9d 100644 (file)
@@ -73,15 +73,16 @@ class ogroupManagement extends plugin
     /* Prepare template */
     $smarty= get_smarty();
 
-    /* Save data */
     $ogroupfilter= get_global("ogroupfilter");
+    $s_action   = "";
+    $s_entry    = "";
 
     foreach( array("depselect", "regex") as $type){
       if (isset($_POST[$type])){
         $ogroupfilter[$type]= $_POST[$type];
       }
     }
-    if (isset($_POST['depselect'])){
+    if (isset($_POST['regex'])){
       foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
             "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups") as $type){
 
@@ -99,6 +100,82 @@ class ogroupManagement extends plugin
       }
       $ogroupfilter['regex']= $s;
     }
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/group_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/group_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/group_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/group_tplnew.*/i",$key)){
+        $s_action="new_tpl";
+      }elseif(preg_match("/group_chgpw.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/group_chgpw_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $ogroupfilter['depselect']= $_POST['depselect'];
+      $this->reload();
+    }
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+      $s_action="open";
+      $s_entry = base64_decode($_GET['dep_id']);
+      $ogroupfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+      $this->reload();
+    }
+
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$ogroupfilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $ogroupfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $ogroupfilter['depselect']= $this->config->departments["/"];
+      }
+      register_global("ogroupfilter", $ogroupfilter);
+      $this->reload();
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$ogroupfilter['depselect']));
+      $this->reload();
+    }
+
+    /* root posted */ 
+    if($s_action=="root"){
+      $ogroupfilter['depselect']=($this->config->current['BASE']);
+      $this->reload();
+    }
+
+    // Edit if
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
     register_global("ogroupfilter", $ogroupfilter);
 
     /* Prepare formular */
@@ -115,7 +192,7 @@ class ogroupManagement extends plugin
     }
 
     /* New group? */
-    if (isset($_POST['new_group'])){
+    if ($s_action=="new"){
 
       /* By default we set 'dn' to 'new', all relevant plugins will
          react on this. */
@@ -127,10 +204,10 @@ class ogroupManagement extends plugin
       $this->ogroup->set_acl(array(':all'));
     }
 
-    if (isset($_POST['delete_group']) && isset($_POST['grouplist'])){
+    if ($s_action=="del"){
 
       /* Get 'dn' from posted 'uid' */
-      $this->dn= trim($_POST['grouplist']);
+      $this->dn= $this->ogrouplist[$s_entry]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -194,10 +271,10 @@ class ogroupManagement extends plugin
       unset($_SESSION['objectinfo']);
     }
 
-    if ((isset($_POST['select_group']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['grouplist']) && $_POST['grouplist'] != ""){
+    if ($s_action=="edit"){
 
       /* Get 'dn' from posted 'uid', must be unique */
-      $this->dn= trim($_POST['grouplist']);
+      $this->dn= $this->ogrouplist[$s_entry]['dn'];
 
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
@@ -275,6 +352,99 @@ class ogroupManagement extends plugin
       return ($display);
     }
 
+    /* Prepare departments */
+    $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($ogroupfilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+
+    // Managment
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+      " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+      " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."'
+name='dep_root' alt='"._("Root")."'>&nbsp;".
+      " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."'
+ alt='"._("Home")."' name='dep_home'>&nbsp;".
+      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      " <input type='image' align='middle' src='images/list_new_ogroup.png' title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>".
+      " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+      _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+      " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+      "</div>";
+
+
+    $actions = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
+    $actions.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
+
+    // Defining Links
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+    // image Buttons
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    $userimg  = "<img src='images/select_groups.png' alt='User'    title='%s'>";
+
+    // Extension images
+    $mailimg  = "<img src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
+
+    // Space
+    $empty    = "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
+
+    // List Setup
+    $divlist = new divlist();
+    $divlist->SetHeader(array(
+          array("string" => "&nbsp;","attach"=>"style='width:20px;'"),
+          array("string" => _("Name of object groups")." / "._("Departments")),
+          array("string" => _("Properties") ,"attach"=>"style='width:50px;'"),
+          array("string" => _("Actions")    ,"attach"=>"style='width:50px;border:none;'")
+          ));
+
+
+    $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
+    $divlist->SetEntriesPerPage(20);
+
+    foreach($this->departments as $key=> $val){
+
+      $field1 = array("string" => "<img src='images/folder.png' alt='"._("Department")."'>");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+      $field3 = array("string" => "&nbsp;");
+      $field4 = array("string" => "&nbsp;","attach"=>"style='text-align:right;border:none'");
+
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
+    // Assigning ogroups 
+    foreach($this->ogrouplist as $key => $val){
+
+      if(isset($val['mail'])){
+        $mail = $mailimg;
+      }else{
+        $mail = $empty;
+      }
+
+      $title = "title='gid : ".$key." - dn : ".$val['dn']."'";
+
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }
+      $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."'>");
+      $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)),"attach"=>$title);
+      $field3 = array("string" => $this->convert_list($val)."&nbsp;".$mail);
+      $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions),"attach"=>"style='text-align:right;border:none'");
+
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
+
+
+
+
+
     /* Show main page */
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("tree_image", get_template_path('images/tree.png'));
@@ -282,7 +452,8 @@ class ogroupManagement extends plugin
     $smarty->assign("launchimage", get_template_path('images/launch.png'));
     $smarty->assign("deplist", $this->config->idepartments);
 
-    $smarty->assign("groups", $this->convert_list($this->grouplist));
+    $smarty->assign("groupshead", $listhead);
+    $smarty->assign("groups", $divlist->DrawList());
 
     foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
           "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups", "regex", "depselect") as $type){
@@ -299,6 +470,8 @@ class ogroupManagement extends plugin
   function convert_list($input)
   {
     $temp= "";
+
+
     $conv= array(   "U" => "select_user.png",
         "G" => "select_groups.png",
         "A" => "select_application.png",
@@ -309,25 +482,25 @@ class ogroupManagement extends plugin
         "T" => "select_terminal.png",
         "P" => "select_printer.png");
 
-    foreach ($input as $key => $value){
-
-      /* Assemble picture */
-      $type= $value['type'];
-      if (isset($type[0])){
-        $p1= $conv[$type[0]];
-      } else {
-        $p1= "empty.png";
-      }
-      if (isset($type[1])){
-        $p2= $conv[$type[1]];
-      } else {
-        $p2= "empty.png";
-      }
-
-      /* Generate output */
-      $temp= "<option value=\"$key\" class=\"select\" style=\"background-image:url('combine.php?image1=$p1&amp;image2=$p2');padding-left:35px;\">".$value['text']."</option>\n".$temp;
+    /* Assemble picture */
+    $type= $input['gosaGroupObjects'][0];
+    $type= preg_replace("/[^A-Z]/i","",$type);
+    if (isset($type[0])){
+      $p1['pic']= $conv[$type[0]];
+      $p1['alt']= $type[0];
+    } else {
+      $p1['pic']= "empty.png";
+      $p1['alt']= "";
     }
-
+    if (isset($type[1])){
+      $p2['pic']= $conv[$type[1]];
+      $p2['alt']= $type[1];
+    } else {
+      $p2['pic']= "empty.png";
+      $p2['alt']= "";
+    }
+    $temp = "<img src='images/".$p1['pic']."' alt='".$p1['alt']."'>";
+    $temp.= "<img src='images/".$p2['pic']."' alt='".$p2['alt']."'>";
     return ($temp);
   }
 
@@ -348,9 +521,9 @@ class ogroupManagement extends plugin
     }
 
     /* User filter? */
-    $this->grouplist= array();
+    $this->oogrouplist= array();
 
-    /* Generate grouplist filter */
+    /* Generate oogrouplist filter */
     $filter= "";
 
     if ($ogroupfilter['usergroups'] == "checked"){
@@ -386,22 +559,36 @@ class ogroupManagement extends plugin
     } else {
       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames))";
     }
-    $res= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("cn", "description", "gosaGroupObjects"), TRUE);
-    foreach ($res as $value){
-      $pictype= preg_replace('/[\[\]]/', '', $value["gosaGroupObjects"][0]);
-      $sortstring= preg_split('//', $pictype, -1, PREG_SPLIT_NO_EMPTY);
-      sort($sortstring);
-      $pictype= implode("", $sortstring);
-      if (isset($value["description"][0])){
-        $this->grouplist[$value["dn"]]= array("text" => $value["cn"][0]." [".
-            $value["description"][0]."]", "type" => $pictype);
-      } else {
-        $this->grouplist[$value["dn"]]= array("text" => $value["cn"][0],
-            "type" => $pictype);
+    $res= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("*"), TRUE);
+    $this->ogrouplist= $res;
+    ksort ($this->ogrouplist);
+    reset ($this->ogrouplist);
+
+
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+                              TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    foreach ($res3 as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
       }
     }
-    ksort ($this->grouplist);
-    reset ($this->grouplist);
+
+    /* END NEW LIST MANAGMENT
+     */
+
+
+
+
   }
 
 }
index fb31c5b5dccb2ba8c4cc617dac1cc41dda315889..6c18ce8336dc498fc0fb25404bc46a559e6826af 100644 (file)
@@ -7,17 +7,11 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select style="width:500px; height:450px;" name="grouplist" size="15" ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
+      {$groupshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
       {$groups}
-        <option disabled>&nbsp;</option> 
-    </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_group">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_group">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_group">&nbsp;
-    <input type=hidden name="edit_helper">
-   </p>
   </div>
 
   </td>
@@ -29,9 +23,6 @@
    <p class="contentboxb">
      {t}This menu allows you to add, edit or remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups.{/t}
     </p>
-    <p class="contentboxb">
-      {t}-Edit- and -New...- will execute an assistant to aid you in editing group properties. -Delete- will ask for confirmation before removing groups.{/t}
-    </p>
    </div>
    <br>
    <div class="contentboxh">
        </tr>
 </table>    
 
-    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;"><tr><td width="50%"><img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display groups of department{/t}</td>
-    <td><select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-      {html_options options=$deplist selected=$depselect}
-    </select></td></tr></table>
-    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;"><tr><td width="50%"><img alt="" src="{$search_image}" align=middle>&nbsp;{t}Display groups matching{/t}</td>
-    <td><input type='text' name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching group names{/t}' onChange="mainform.submit()"></td></tr></table>
+    <table summary="" style="width:100%;border-top:1px solid #B0B0B0;"><tr><td><img alt="" src="{$search_image}" align=middle title='{t}Display groups matching{/t}'></td>
+    <td><input type='text' name='regex' style='width:99%' maxlength='20' value='{$regex}' title='{t}Regular expression for matching group names{/t}' onChange="mainform.submit()"></td></tr></table>
    {$apply}
    </div>
   </td>
index 4020c6b1a04479b59e130a69fef1a6be6b3a1ff9..e553b92065aa615220ecb6208b40457432cb26ec 100644 (file)
@@ -31,6 +31,7 @@ class systems extends plugin
   /* Definitions */
   var $plHeadline= "Systems";
   var $plDescription= "This does something";
+  var $departments=array();
 
   /* Dialog attributes */
   var $systab= NULL;
@@ -88,17 +89,85 @@ class systems extends plugin
       }
       $terminalfilter['regex']= $s;
     }
-    register_global("terminalfilter", $terminalfilter);
 
-    /* Check sorting variable */
-    if (!isset($this->systab) &&
-        !isset($_POST['new_terminal']) &&
-        !isset($_POST['delete_terminal']) &&
-        !isset($_POST['set_password']) &&
-        !isset($_POST['select_terminal'])){
-      $this->reload();
+    $terminalfilter   = get_global("terminalfilter"); // contains Filter Settings
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+    $smarty       = get_smarty();
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+            $s_action="open";
+            $s_entry = base64_decode($_GET['dep_id']);
+            $terminalfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+            $this->reload();
+    }
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/user_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/user_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/user_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/user_tplnew.*/i",$key)){
+        $s_action="new_tpl";
+      }elseif(preg_match("/user_setpwd_.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/user_setpwd_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+
+     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $terminalfilter['depselect']= $_POST['depselect'];
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $terminalfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $terminalfilter['depselect']=(preg_replace("/^[^,]+,/","",$terminalfilter['depselect']));
+    }
+
+    if($s_action=="root"){
+      $terminalfilter['depselect']=($this->config->current['BASE']);
+    }
+
+
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$terminalfilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $terminalfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $terminalfilter['depselect']= $this->config->departments["/"];
+      }
     }
-    $smarty= get_smarty();
+
+    register_global("terminalfilter", $terminalfilter);
+    $this->reload();
 
     /* Check for exeeded sizelimit */
     if (($message= check_sizelimit()) != ""){
@@ -106,7 +175,7 @@ class systems extends plugin
     }
 
     /* Try to get informations about what kind of system to create */
-    if (isset($_POST['new_terminal'])) {
+    if ($s_action=="new") {
       return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
     }
 
@@ -159,11 +228,10 @@ class systems extends plugin
     }
 
     /* User wants to edit data? */
-    if ((isset($_POST['select_terminal']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['termlist']) &&
-          $_POST['termlist'] != ""){
+    if ($s_action == "edit"){
 
       /* Get 'dn' from posted 'cn', must be unique */
-      $this->dn= trim($_POST['termlist']);
+      $this->dn= $this->terminals[$s_entry]['dn'];
 
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
@@ -250,8 +318,8 @@ class systems extends plugin
     }
 
     /* Set terminals root password */
-    if (isset($_POST['set_password']) && isset($_POST['termlist'])){
-      $this->dn= trim($_POST['termlist']);
+    if ($s_action=="change_pw"){
+      $this->dn= $this->terminals[$s_entry]['dn'];
       $_SESSION['objectinfo']= $this->dn;
       return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
     }
@@ -297,10 +365,10 @@ class systems extends plugin
     }
 
     /* Remove terminal was requested */
-    if (isset($_POST['delete_terminal']) && isset($_POST['termlist'])){
+    if ($s_action=="del"){
 
       /* Get 'dn' from posted termlinst */
-      $this->dn= $_POST['termlist'];
+      $this->dn= $this->terminals[$s_entry]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -445,8 +513,127 @@ class systems extends plugin
       return ($display);
     }
 
+
+
+
+
+
+    /* Prepare departments */
+    $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($terminalfilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+
+
+  /* NEW LIST MANAGMENT */
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+    " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+    " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+    " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."'                     name='dep_home'>&nbsp;".
+    " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+    " <input type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."'                    name='user_new'>&nbsp;".
+    " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+    _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+    " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='".           _("Submit")."'>&nbsp;".
+    "</div>";
+
+
+
+    $action= "<input type='image' src='images/edit.png' alt='"._("edit")."'     name='user_edit_%KEY%' title='"._("Edit user")."'>";
+    $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."'   name='user_del_%KEY%' title='"._("Delete user")."'>";
+
+
+    $divlist = new divlist();
+    $divlist->SetHeader(array(
+          array("string" => "&nbsp;"),
+          array("string" => _("System")." / "._("Department")),
+          array("string" => _("Actions"), "attach" => "style='border:none'" )));
+
+
+    $divlist->SetSummary(_("This table displays all users, in the selected tree."));
+    $divlist->SetEntriesPerPage(20);
+
+    // Defining Links
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+    foreach($this->departments as $key=> $val){
+      $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+      $field3 = array("string" => "&nbsp;", "attach" => "style='border:none'");
+      $divlist->AddEntry(array($field1,$field2,$field3));
+    }
+
+    // Space
+    $empty    ="";//= "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
+
+    // User and Template  Images
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+
+    // Pictures for Extensions
+    $img1  = "<img src='images/printer.png'            alt='C' title='"._("Cups Server")  ."'>";
+    $img2  = "<img src='images/scanner.png'            alt='L' title='"._("Log Db") ."'>";
+    $img3  = "<img src='images/select_terminal.png'    alt='L' title='"._("Syslog Server") ."'>";
+    $img4  = "<img src='images/mailto.png'             alt='M' title='"._("Mail Server")  ."'>";
+    $img5  = "<img src='images/select_phone.png'       alt='I' title='"._("Imap Server") ."'>";
+    $img6  = "<img src='images/fax_small.png'          alt='F' title='"._("Nfs Server")   ."'>";
+    $img7  = "<img src='images/select_winstation.png'  alt='K' title='"._("Kerberos Server") ."'>";
+    $img8  = "<img src='images/select_phone.png'       alt='A' title='"._("Asterisk Server") ."'>";
+    $img9  = "<img src='images/fax_small.png'          alt='F' title='"._("Fax Server") ."'>";
+    $img10 = "<img src='images/save.png'               alt='L' title='"._("Ldap Server") ."'>";
+
+    // Test Every Entry and generate divlist Array
+    foreach($this->terminals as $key => $val){
+      // Specify Pics for Extensions
+      if(in_array("goCupsServer"    ,$val['objectClass'])) $cups    = $img1;   else $cups  =$empty;
+      if(in_array("goLogDBServer"   ,$val['objectClass'])) $logdb   = $img2;   else $logdb =$empty;
+      if(in_array("goSyslogServer"  ,$val['objectClass'])) $syslog  = $img3;   else $syslog=$empty;
+      if(in_array("goImapServer"    ,$val['objectClass'])) $imap    = $img4;   else $imap  =$empty;
+      if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba   = $img5;   else $samba =$empty;
+      if(in_array("goNfsServer"     ,$val['objectClass'])) $nfs     = $img6;   else $nfs   =$empty;
+      if(in_array("goKrbServer"     ,$val['objectClass'])) $krb     = $img7;   else $krb   =$empty;
+      if(in_array("goFonServer"     ,$val['objectClass'])) $fon     = $img8;   else $fon   =$empty;
+      if(in_array("goFaxServer"     ,$val['objectClass'])) $fax     = $img9;   else $fax   =$empty;
+      if(in_array("goLdapServer"    ,$val['objectClass'])) $ldap     = $img10;   else $ldap   =$empty;
+  
+      $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap;
+      $pics = "";
+      // Generate Array to Add
+      if((isset($val['is_new']))&&(!empty($val['is_new']))){
+        $display= "".$val["cn"][0]." ".$val['is_new'];
+      }else{
+        $display= "".$val["cn"][0]."";
+      }
+
+      if(in_array("gotoTerminal",$val['objectClass'])){
+        $action2 = "<input type='image' src='images/certs.png' alt='"._("Password")."'   name='user_setpwd_%KEY%' title='"._("Set root password")."'>";
+      }else{
+        $action2 = "";
+      }
+
+
+      if(isset($val['message'])){
+        $display.= "  (".$val['message']." '".$this->config->idepartments[$terminalfilter['depselect']]."'  )";
+      }
+
+      $img=$this->convert_list($val);
+
+      $field1 = array("string" => sprintf($img['img'],$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
+      $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action),"attach" => "style='border:none; text-align:right;width:48px'");
+      $divlist->AddEntry( array($field1,$field2,$field3));
+    }
+
+
+
+
+
     /* Show main page */
-    $smarty->assign("terminals", $this->convert_list($this->terminals));
+    $smarty->assign("terminalshead", $listhead);
+    $smarty->assign("terminals", $divlist->DrawList());
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("tree_image", get_template_path('images/tree.png'));
     $smarty->assign("infoimage", get_template_path('images/info.png'));
@@ -471,7 +658,9 @@ class systems extends plugin
   {
     $temp= "";
     $conv= array(      "D" => "select_default.png",
-        "T" => "select_terminal.png",
+        
+
+  "T" => "select_terminal.png",
         "L" => "select_workstation.png",
         "F" => "select_phone.png",
         "S" => "select_server.png",
@@ -481,22 +670,16 @@ class systems extends plugin
         "C" => "select_component.png",
         "P" => "select_printer.png");
 
-    foreach ($input as $key => $value){
-      $mode= preg_replace('/^.*(.)$/', '\\1', $value);
-      if ($mode == "D"){
-        $temp= "<option value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path('images/select_default.png')."');\">".preg_replace('/.$/', '', $value)."</option>\n".$temp;
-      } else {
-        if (preg_match('/^\+/', $value)){
-          $value= preg_replace('/^\+ /', '', $value);
-          $new= "N";
-        } else {
-          $new= "";
-        }
-        $temp.= "<option value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path('images/'.$conv["$new$mode"])."');\">".preg_replace('/.$/', '', $value)."</option>\n";
+   if((isset($input['is_new']))&&(!empty($input['is_new']))){
+     $input['type']="N".$input['type'];
+   }
+   foreach ($conv  as $key => $value){
+      if($input['type']==$key){
+        $tmp['img'] ="<img src='images/".$value."' alt='".$key."' title='%s'>";
+        $tmp['class']=$key;
+        return $tmp;
       }
     }
-
-    return ($temp);
   }
 
   function remove_from_parent()
@@ -611,6 +794,35 @@ class systems extends plugin
     $this->terminals= array();
 
     $res= get_list($this->ui->subtreeACL, "(|$termfilter$workfilter$winfilter$printfilter$phonefilter$serverfilter$netfilter)", TRUE, $base, array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), TRUE);
+
+      
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+                              TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    $tmp = array();
+    foreach ($res3 as $value){
+      $tmp[strtolower($value['dn']).$value['dn']]=$value;
+    }
+    ksort($tmp);
+    foreach($tmp as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
+      }
+    }
+
+    /* END NEW LIST MANAGMENT
+     */
+
+
     foreach ($res as $value){
 
       /* Look for new terminals and mark them with '+' */
@@ -650,57 +862,42 @@ class systems extends plugin
         $add= "";
       }
 
+      $terminal = array();
+  
       if (in_array ($tmp, $responsible) || $add != ""){
         if (in_array('gotoTerminal', $value["objectClass"])){
-          if (isset($value["macAddress"][0]) &&
-              $value["macAddress"][0] != "-"){
-
-            $this->terminals[$value["dn"]]= $add." ".
-              $value["cn"][0].
-              " [".$value["macAddress"][0]."]T";
+          if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
+            $terminal             = $value;
+            $terminal['type']     = "T";
+            $terminal['is_new']   = $add;
           } else {
-            $location= array_search($tmp, $this->config->departments);
-            $this->terminals[$value["dn"]]= _("Thin client template for").
-              " $location"."D";
+            $terminal             = $value;
+            $terminal['type']     = "D";
+            $terminal['message']  = _("Terminal template for");
+            $terminal['location'] = array_search($tmp, $this->config->departments); 
           }
         } elseif (in_array('gotoWorkstation', $value["objectClass"])){
-          if (isset($value["macAddress"][0]) &&
-              $value["macAddress"][0] != "-"){
-
-            $this->terminals[$value["dn"]]= $add." ".
-              $value["cn"][0].
-              " [".$value["macAddress"][0]."]L";
+          if (isset($value["macAddress"][0]) &&  $value["macAddress"][0] != "-"){
+            $terminal             = $value;
+            $terminal['type']     = "L";
           } else {
-            $location= array_search($tmp, $this->config->departments);
-            $this->terminals[$value["dn"]]= _("Workstation template for").
-              " $location"."D";
+            $terminal             = $value;
+            $terminal['type']     = "D";
+            $terminal['location'] = array_search($tmp, $this->config->departments);
+            $terminal['message']  = _("Workstation template for");
           }
         } elseif (in_array('gotoPrinter', $value["objectClass"])){
-          if (isset($value['description'][0])){
-            $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]P";
-          } else {
-            $this->terminals[$value['dn']]= $value['cn'][0]."P";
-          }
+            $terminal             = $value;
+            $terminal['type']     = "P";
         } elseif (in_array('goServer', $value["objectClass"])){
-          if (isset($value['description'][0])){
-            $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]S";
-          } else {
-            $this->terminals[$value['dn']]= $value['cn'][0]."S";
-          }
+            $terminal             = $value;
+            $terminal['type']     = "S";
         } elseif (in_array('goFonHardware', $value["objectClass"])){
-
-          if (isset($value['description'][0])){
-            $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]F";
-          } else {
-            $this->terminals[$value['dn']]= $value['cn'][0]."F";
-          }
+            $terminal             = $value;
+            $terminal['type']     = "F";
         } elseif (in_array('ieee802Device', $value["objectClass"])){
-
-          if (isset($value['description'][0])){
-            $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]C";
-          } else {
-            $this->terminals[$value['dn']]= $value['cn'][0]."C";
-          }
+            $terminal             = $value;
+            $terminal['type']     = "C";
         } else{
           $name= preg_replace('/\$$/', '', $value['cn'][0]);
           if (isset($value['sambaDomainName'])){
@@ -708,11 +905,23 @@ class systems extends plugin
           } else {
             $domain= "";
           }
-          $this->terminals[$value['dn']]= $name.$domain."W";
+            $terminal=$value;
+            $terminal['type']     ="W";
+            $terminal['domain']   = $name.$domain;
         }
+      $this->terminals[]=$terminal;
       }
     }
-    natcasesort ($this->terminals);
+
+    $tmp=array();
+    foreach($this->terminals as $tkey => $val ){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+    }
+    ksort($tmp);
+    $this->terminals=array();
+    foreach($tmp as $val){
+      $this->terminals[]=$val;
+    }
     reset ($this->terminals);
   }
 
index c374e1854e316d83982ea4f3fb4fb579675837d8..62fff7c38041aa8e07a2a14fd94c0cf92adfd0c7 100644 (file)
@@ -7,17 +7,12 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select style="width:500px; height:450px;" name="termlist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
+      {$terminalshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
       {$terminals}
-    </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_terminal">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_terminal">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_terminal">&nbsp;
-    <input type=submit value="{t}Set password{/t}" name="set_password">&nbsp;
     <input type=hidden name="edit_helper">
-   </p>
   </div>
   </td>
   <td style="vertical-align:top;">
@@ -28,9 +23,6 @@
    <p class="contentboxb">
     {t}This menu allows you to add, remove and change the properties of specific systems. You can only add systems which have already been started once.{/t}
    </p>
-   <p>
-    {t}-Edit- will execute an assistant to aid you in changing the system properties. -Delete- will ask for confirmation before deleting systems.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
                </td>
        </tr>
 </table>    
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-       <tr>
-               <td width="50%"><img alt="" src="{$tree_image}" align=middle>
-                       &nbsp;{t}Display systems of department{/t}
-               </td>
-           <td>
-                       <select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-                             {html_options options=$deplist selected=$depselect}
-                   </select>
-               </td>
-       </tr>
-</table>
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
                <td width="50%"><img alt="" src="{$search_image}" align=middle>
index a2a65bcf6fac5ad0850461a420f13b5bfc5dcaaf..6e8c5d124a9f7ea5d1e4c2bf7ff10fa745bca029 100644 (file)
@@ -32,6 +32,7 @@ class userManagement extends plugin
   var $acl= "";
   var $templates= array();
   var $got_uid= false;
+  var $departments=array();
 
   function userManagement ($config, $ui)
   {
@@ -58,45 +59,124 @@ class userManagement extends plugin
 
   function execute()
   {
-    $smarty= get_smarty();
-    $userfilter= get_global("userfilter");
+    $smarty       = get_smarty();             // Smarty instance
+    $userfilter   = get_global("userfilter"); // contains Filter Settings
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+            $s_action="open";
+            $s_entry = base64_decode($_GET['dep_id']);
+            $userfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+            $this->reload();
+    }
+
+    /* Test Posts */  
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/user_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/user_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/user_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/user_tplnew.*/i",$key)){
+        $s_action="new_tpl";
+      }elseif(preg_match("/user_chgpw.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/user_chgpw_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+    
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $userfilter['depselect']= $_POST['depselect'];
+      $this->reload();
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $userfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $userfilter['depselect']=(preg_replace("/^[^,]+,/","",$userfilter['depselect']));
+      $this->reload();
+    }
+
+    if($s_action=="root"){
+      $userfilter['depselect']=($this->config->current['BASE']);
+      $this->reload();
+    }
+
+
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$userfilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $userfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $userfilter['depselect']= $this->config->departments["/"];
+      }
+      $this->reload();
+    }
+
+    /* End for new List Managment */
 
     /* Save filter data if we are in the headpage */
     if (!isset($this->usertab)){
-      foreach( array("depselect", "regex") as $type){
+      foreach( array("regex") as $type){
         if (isset($_POST[$type])){
           $userfilter[$type]= $_POST[$type];
         }
       }
-      if (isset($_POST['depselect'])){
-        foreach( array("functionalusers", "unixusers", "mailusers",
-              "sambausers", "proxyusers", "faxusers", "templates", "subsearch") as $type){
-
-          if (isset($_POST[$type])) {
-            $userfilter[$type]= "checked";
-          } else {
-            $userfilter[$type]= "";
-          }
+    }
+    if(isset($_POST['regex'])){
+      foreach( array("functionalusers", "unixusers", "mailusers","sambausers", "proxyusers", "faxusers", "templates", "subsearch") as $type){
+        if (isset($_POST[$type])) {
+          $userfilter[$type]= "checked";
+        } else {
+          $userfilter[$type]= "";
         }
       }
-      if (isset($_GET['search'])){
-        $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-        if ($s == "**"){
-          $s= "*";
-        }
-        $userfilter['regex']= $s;
+    }
+    if (isset($_GET['search'])){
+      $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+      if ($s == "**"){
+        $s= "*";
       }
-      register_global("userfilter", $userfilter);
+      $userfilter['regex']= $s;
     }
+    register_global("userfilter", $userfilter);
+    
 
     /* React on user interaction here */
-    if ($_SERVER["REQUEST_METHOD"] == "POST"){
+    if (($_SERVER["REQUEST_METHOD"] == "POST")||($_SERVER["REQUEST_METHOD"]== "GET")){
 
       /* User wants to edit data? */
-      if ( (isset($_POST['select_user']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['userlist']) && $_POST['userlist'] != ""){
+      if ($s_action=="edit"){
 
         /* Get 'dn' from posted 'uid', must be unique */
-        $this->dn= trim($_POST['userlist']);
+        
+        $this->dn= $this->list[trim($s_entry)]['dn'];
 
         /* Check locking, save current plugin in 'back_plugin', so
            the dialog knows where to return. */
@@ -135,10 +215,10 @@ class userManagement extends plugin
     }
 
     /* Password change requested */
-    if (isset($_POST['setpass_user']) && isset($_POST['userlist'])){
+    if ($s_action=="change_pw"){
 
       /* Get 'dn' from posted 'uid' */
-      $this->dn= trim($_POST['userlist']);
+      $this->dn= $this->list[trim($s_entry)]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -222,10 +302,10 @@ class userManagement extends plugin
 
 
     /* Remove user was requested */
-    if (isset($_POST['delete_user']) && isset($_POST['userlist'])){
+    if ($s_action=="del"){
 
       /* Get 'dn' from posted 'uid' */
-      $this->dn= trim($_POST['userlist']);
+      $this->dn= $this->list[trim($s_entry)]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -350,7 +430,7 @@ class userManagement extends plugin
     }
 
     /* Generate template list */
-    if (isset($_POST['new_user'])){
+    if ($s_action=="new"){
       $this->templates= array();
       $ldap= $this->config->get_ldap_link();
       foreach ($this->config->departments as $key => $value){
@@ -374,8 +454,7 @@ class userManagement extends plugin
     }
 
     /* New user/template request */
-    if (isset($_POST['new_user']) || isset($_POST['new_template'])){
-
+    if (($s_action=="new") || ($s_action=="new_tpl")){
       /* By default we set 'dn' to 'new', all relevant plugins will
          react on this. */
       $this->dn= "new";
@@ -391,7 +470,7 @@ class userManagement extends plugin
       $this->usertab->set_acl(array(':all'));
 
       /* Take care about templates */
-      if (isset($_POST['new_template'])){
+      if ($s_action=="new_tpl"){
         $this->is_template= TRUE;
         $this->usertab->set_template_mode ();
       } else {
@@ -529,8 +608,133 @@ class userManagement extends plugin
       return($message);
     }
 
+    /* Prepare departments */
+    $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($userfilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+    /* NEW LIST MANAGMENT */
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+            " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+            " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+            " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
+            " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+            " <input type='image' align='middle' src='images/list_new_user.png' title='"._("Create new user")."' alt='"._("New user")."' name='user_new'>&nbsp;".
+            " <input type='image' align='middle' src='images/list_new.png' title='"._("Create new template")."' alt='"._("New template")."' name='user_tplnew'>&nbsp;".
+            " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+            _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+            " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+            "</div>";
+
+    $action= "<input type='image' src='images/edit.png' alt='"._("edit")."'     name='user_edit_%KEY%' title='"._("Edit user")."'>";
+    $action.= "<input type='image' src='images/list_password.png' alt='"._("password")."' name='user_chgpw_%KEY%' title='"._("Change password")."'>";
+    $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."'   name='user_del_%KEY%' title='"._("Delete user")."'>";
+
+
+
+    $divlist = new divlist();
+    $divlist->SetHeader(array(
+                              array("string" => "&nbsp;"),
+                              array("string" => _("Username")." / "._("Department")),
+                              array("string" => _("Properties")),
+                              array("string" => _("Actions"), "attach" => "style='border:none'" )));
+                                    
+
+    $divlist->SetSummary(_("This table displays all users, in the selected tree."));
+    $divlist->SetEntriesPerPage(20);
+
+    // Defining Links 
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+    foreach($this->departments as $key=> $val){
+
+      $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+      $field3 = array("string" => "&nbsp;");
+      $field4 = array("string" => "&nbsp;", "attach" => "style='border:none'");
+
+      
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
+    // Pictures for Extensions 
+    $usrimg  = "<img src='images/penguin.png'             alt='U' title='"._("GOsa")  ."'>";
+    $posiximg = "<img src='images/select_user.png'        alt='P' title='"._("Posix") ."'>";
+    $mailimg  = "<img src='images/mailto.png'             alt='M' title='"._("Mail")  ."'>";
+    $fonimg   = "<img src='images/select_phone.png'       alt='T' title='"._("Phone") ."'>";
+    $faximg   = "<img src='images/fax_small.png'          alt='F' title='"._("Fax")   ."'>";
+    $sambaimg = "<img src='images/select_winstation.png'  alt='S' title='"._("Samba") ."'>";
+    // Space 
+    $empty    = "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>"; 
+    
+    // User and Template  Images  
+    $userimg  = "<img src='images/select_user.png' alt='User' title='%s'>";   
+    $tplimg   = "<img src='images/select_template.png' alt='Template' title='%s'>";   
+   
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+    // Defines Arrays to save User and Templates
+    $tpls = array();
+    $users= array();
+
+    // Test Every Entry and generate divlist Array  
+    foreach($this->list as $key => $val){
+
+      // Specify Pics for Extensions  
+      if(in_array("posixAccount"    ,$val['objectClass'])) $posix = $posiximg;  else $posix=$empty; 
+      if(in_array("gosaMailAccount" ,$val['objectClass'])) $maila = $mailimg;   else $maila=$empty; 
+      if(in_array("goFonAccount"    ,$val['objectClass'])) $fonac = $fonimg;    else $fonac=$empty; 
+      if(in_array("goFaxAccount"    ,$val['objectClass'])) $faxac = $faximg;    else $faxac=$empty; 
+      if(in_array("sambaSamAccount" ,$val['objectClass'])) $samba = $sambaimg;  else $samba=$empty; 
+      if(in_array("gosaUserTemplate",$val['objectClass'])) $tpl   = $tplimg;    else $tpl=$userimg;
+        
+      // Generate Array to Add 
+      if (isset($val["sn"]) && isset($val["givenName"])){
+        $display= $val["sn"][0].", ".$val["givenName"][0]." [".$val["uid"][0]."]";
+      } else {
+        $display= "[".$val["uid"][0]."]";
+      }
+
+      $field1 = array("string" => sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
+      $field3 = array("string" => $usrimg."&nbsp;".$posix."&nbsp;".$maila."&nbsp;".$fonac."&nbsp;".$faxac."&nbsp;".$samba,"attach" => "style='width:118px;'");
+      $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:48px'");
+    
+      $add = array($field1,$field2,$field3,$field4);
+      
+      // Template or User
+      if(in_array("gosaUserTemplate",$val['objectClass'])){
+        $tpls[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
+      }else{
+        $users[strtolower( $val['sn']['0'].$val['uid']['0'])]=$add;
+      }
+    }
+    
+    // Sort Entries 
+    ksort($users);
+    ksort($tpls);
+
+    // Append Templates
+    foreach($tpls as $key => $val){
+      $divlist->AddEntry( $val, array(""));
+    }
+    // Append Users 
+    foreach($users as $key => $val){
+      $divlist->AddEntry( $val, array(""));
+    }
     /* Show main page */
-    $smarty->assign("userlist", $this->userlist);
+    //$smarty->assign("userlist",   nl2br(htmlentities($divlist->DrawList())));
+    $smarty->assign("userlist",   $divlist->DrawList());
+    $smarty->assign("userlisthead", $listhead);
+
+    /* END NEW LIST MANAGMENT
+     */  
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("tree_image", get_template_path('images/tree.png'));
     $smarty->assign("infoimage", get_template_path('images/info.png'));
@@ -610,6 +814,30 @@ class userManagement extends plugin
       $this->list= get_list($this->ui->subtreeACL, "$filter", FALSE, $base, array("uid", "givenName", "sn", "objectClass"), TRUE);
     }
 
+
+
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer 
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+                              TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    foreach ($res3 as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
+      }
+    }
+    
+    /* END NEW LIST MANAGMENT 
+     */
+  
+    
     $this->userlist= array();
 
     foreach ($this->list as $value){
@@ -627,6 +855,7 @@ class userManagement extends plugin
         }
       }
     }
+
     natcasesort ($this->userlist);
     reset ($this->userlist);
   }
index 8ad51c846afe8172f5c6731313289a7b324c1a9e..d46e4a2a8617cb4266e369379bdd233981a4a7d2 100644 (file)
@@ -1,25 +1,18 @@
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
 <tr>
-  <td style="vertical-align:top;">
+  <td style="vertical-align:top;width:50%;">
   <div class="contentboxh">
     <p class="contentboxh">
      <LABEL for="userlist">{t}List of users{/t}</LABEL> {$hint}
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-      <select style="width:500px; height:450px;" id="userlist" name="userlist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-                       {html_options options=$userlist}
-                       <option disabled>&nbsp;</option>
-      </select>
-      <br>
-      <input type=submit value="{t}New{/t}..." name="new_user">&nbsp;
-      <input type=submit value="{t}New template{/t}" name="new_template">&nbsp;
-      <input type=submit value="{t}Edit{/t}" name="select_user">&nbsp;
-      <input type=submit value="{t}Delete{/t}" name="delete_user">&nbsp;
-      <input type=submit value="{t}Set password{/t}" name="setpass_user">
+               {$userlisthead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+                       {$userlist}
       <input type=hidden name="edit_helper">
-    </p>
   </div>
   </td>
   <td style="vertical-align:top;">
@@ -30,9 +23,6 @@
    <p class="contentboxb">
     {t}This menu allows you to create, edit and delete selected users. Having a great number of users, you may want to use the range selectors on top of the user list.{/t}
     </p>
-   <p class="contentboxb">
-   {t}-Edit- and -New...- execute an assistant to aid you in managing your account informations. -Delete- will ask for confirmation before deleting users.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
             </td>
         </tr>
     </table>
-    <table summary="" style="border-top:1px solid #B0B0B0;" width="100%">
-        <tr>
-            <td>
-
-                               <input type=checkbox name="subsearch" value="1" {$subsearch} onClick="mainform.submit()" title="{t}Dive into LDAP subtrees when searching{/t}">{t}Search in subtrees{/t}<br>
-                       </td>
-               </tr>
-       </table>        
-
-                       <table summary="" width="100%" style="border-top:1px solid #B0B0B0;"><tr><td width="50%"><img alt="" src="{$tree_image}" align="middle">&nbsp;{t}Display users of department{/t}</td>
-    <td><select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-      {html_options options=$deplist selected=$depselect}
-    </select></td></tr></table>
-    <table summary="" width="100%" style="border-top:1px solid #B0B0B0;"><tr><td width="50%"><img alt="" src="{$search_image}" align="middle">&nbsp;{t}Display users matching{/t}</td>
-    <td><input type='text' name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching user names{/t}' onChange="mainform.submit()"></td></tr></table>
+    <table summary="" width="100%" style="border-top:1px solid #B0B0B0;"><tr><td><img alt="Search" src="{$search_image}" align="middle" title="{t}Display users matching{/t}"></td>
+    <td><input style='width:99%' type='text' name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching user names{/t}' onChange="mainform.submit()"></td></tr></table>
    {$apply}
    </div>
   </td>
index bc9bd46ea9c77168a8377ac455e17314df15e284..f9a4533ae82c704f51e97d64beb8dc7720b4741d 100644 (file)
@@ -26,423 +26,574 @@ class blocklist extends plugin
 
   function blocklist ($config, $ui)
   {
-       $this->ui= $ui;
-       $this->dn= "";
-       $this->config= $config;
-
-        /* Get global filter config */
-        if (!is_global("blockfilter")){
-                $ui= get_userinfo();
-                $base= get_base_from_people($ui->dn);
-                $blockfilter= array("sendlists" => "checked",
-                                "receivelists" => "checked",
-                                "entry" => "*",
-                                "depselect" => $base,
-                                "regex" => "*");
-                register_global("blockfilter", $blockfilter);
-        }
+    $this->ui= $ui;
+    $this->dn= "";
+    $this->config= $config;
+
+    /* Get global filter config */
+    if (!is_global("blockfilter")){
+      $ui= get_userinfo();
+      $base= get_base_from_people($ui->dn);
+      $blockfilter= array("sendlists" => "checked",
+          "receivelists" => "checked",
+          "entry" => "*",
+          "depselect" => $base,
+          "regex" => "*");
+      register_global("blockfilter", $blockfilter);
+    }
 
   }
 
   function execute()
   {
-       /* Get global smarty instance */
-       $smarty= get_smarty();
-
-        /* Save data */
-        $blockfilter= get_global("blockfilter");
-        foreach( array("depselect", "entry", "regex") as $type){
-                if (isset($_POST[$type])){
-                        $blockfilter[$type]= $_POST[$type];
-                }
+    /* Get global smarty instance */
+    $smarty= get_smarty();
+    $blockfilter   = get_global("blockfilter"); // contains Filter Settings
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+      $s_action="open";
+      $s_entry = base64_decode($_GET['dep_id']);
+      $blockfilter['depselect']= "".$this->config->departments[trim($s_entry)];
+      $this->reload();
+    }
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/user_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/user_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/user_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/user_tplnew.*/i",$key)){
+        $s_action="new_tpl";
+      }elseif(preg_match("/user_chgpw.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/user_chgpw_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+
+
+
+    if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $blockfilter['depselect']= $_POST['depselect'];
+      $this->reload();
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $blockfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $blockfilter['depselect']=(preg_replace("/^[^,]+,/","",$blockfilter['depselect']));
+      $this->reload();
+    }
+
+    if($s_action=="root"){
+      $blockfilter['depselect']=($this->config->current['BASE']);
+      $this->reload();
+    }
+    
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$blockfilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $blockfilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $blockfilter['depselect']= $this->config->departments["/"];
+      }
+      $this->reload();
+    }
+
+    register_global("blockfilter", $blockfilter);
+
+    /* Save data */
+    $blockfilter= get_global("blockfilter");
+    foreach( array( "entry", "regex") as $type){
+      if (isset($_POST[$type])){
+        $blockfilter[$type]= $_POST[$type];
+      }
+    }
+    if (isset($_POST['depselect'])){
+      foreach( array("sendlists", "receivelists") as $type){
+
+        if (isset($_POST[$type])) {
+          $blockfilter[$type]= "checked";
+        } else {
+          $blockfilter[$type]= "";
         }
-        if (isset($_POST['depselect'])){
-                foreach( array("sendlists", "receivelists") as $type){
-
-                        if (isset($_POST[$type])) {
-                                $blockfilter[$type]= "checked";
-                        } else {
-                                $blockfilter[$type]= "";
-                        }
-                }
+      }
+    }
+    if (isset($_GET['search'])){
+      $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+      if ($s == "**"){
+        $s= "*";
+      }
+      $blockfilter['regex']= $s;
+    }
+    register_global("blockfilter", $blockfilter);
+
+    /* Create new blocklist? */
+    if ($s_action=="new"){
+      $this->clear_fields();
+      $this->acl= "#all#";
+      $this->dn= "new";
+      plugin::plugin ($this->config, $this->dn);
+    }
+
+    /* Edit selected blocklist? */
+    if ($s_action=="edit"){
+      $this->clear_fields();
+      $this->dn=$this->blocklists[$s_entry]['dn']; 
+      $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+      $this->acl= get_module_permission($this->acl, "blocklists", $this->dn);
+      plugin::plugin ($this->config, $this->dn);
+
+      /* Load missing lists */
+      if (isset($this->attrs["goFaxSBlocklist"])){
+        for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){
+          $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i];
         }
-        if (isset($_GET['search'])){
-                $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-                if ($s == "**"){
-                        $s= "*";
-                }
-                $blockfilter['regex']= $s;
+        $this->type= 0;
+      } elseif (isset($this->attrs["goFaxRBlocklist"])){
+        for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){
+          $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i];
         }
-        register_global("blockfilter", $blockfilter);
-
-       /* Create new blocklist? */
-       if (isset($_POST['new_blocklist'])){
-               $this->clear_fields();
-               $this->acl= "#all#";
-               $this->dn= "new";
-               plugin::plugin ($this->config, $this->dn);
-       }
-
-       /* Edit selected blocklist? */
-       if ((isset($_POST['select_blocklist']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['blocklist']) != ""){
-               $this->clear_fields();
-               $this->dn= trim($_POST['blocklist']);
-               $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-               $this->acl= get_module_permission($this->acl, "blocklists", $this->dn);
-               plugin::plugin ($this->config, $this->dn);
-
-               /* Load missing lists */
-               if (isset($this->attrs["goFaxSBlocklist"])){
-                       for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){
-                               $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i];
-                       }
-                       $this->type= 0;
-               } elseif (isset($this->attrs["goFaxRBlocklist"])){
-                       for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){
-                               $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i];
-                       }
-                       $this->type= 1;
-               }
-               $_SESSION['objectinfo']= trim($this->dn);
-       }
-
-       /* Delete blocklist requested */
-       if (isset($_POST['delete_blocklist']) && isset($_POST['blocklist'])){
-               $this->dn= trim($_POST['blocklist']);
-
-               /* Check locking */
-               if (($user= get_lock($this->dn)) != ""){
-                       $_SESSION['dn']= $this->dn;
-                       return(gen_locked_message($user, $this->dn));
-               } else {
-                       # Lock this dn for editing
-                       add_lock ($this->dn, $this->ui->dn);
-
-                       $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn));
-                       return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
-               }
-       }
-
-       /* Finally delete blocklist */
-       if (isset($_POST['delete_blocklist_confirm'])){
-               $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-               $acl= get_module_permission($acl, "blocklists", $this->dn);
-               if (chkacl($acl, "all") == ""){
-                       $this->remove_from_parent();
-                       gosa_log ("Blocklist object'".$this->dn."' has been removed");
-                       $this->reload ();
-               } else {
-                       print_red (_("You have no permission to remove this blocklist."));
-               }
-       }
-
-       /* Cancel dialog */
-       if (isset($_POST['edit_cancel']) || isset($_POST['delete_blocklist_cancel']) ||
-               isset($_POST['delete_blocklist_confirm']) || isset($_POST['delete_lock'])){
-
-               del_lock ($this->dn);
-               $this->clear_fields();
-               unset($_SESSION['objectinfo']);
-       }
-
-       /* Handle interactions: add */
-       if (isset($_POST['add_number']) && $_POST['number'] != ""){
-               if (is_phone_nr($_POST['number'])){
-                       $this->addNumber ($_POST['number']);
-               } else {
-                       print_red (_("Please specify a valid phone number."));
-               }
-       }
-
-       /* Handle interactions: delete */
-       if (isset($_POST['delete_number']) && count($_POST['numbers']) > 0){
-               $this->delNumber ($_POST['numbers']);
-       }
-
-       /* What about finish? */
-       if (isset($_POST['edit_finish'])){
-               $message= $this->check();
-
-               /* No errors, save object */
-               if (count ($message) == 0){
-
-                       /* Perpare 'dn' in case of new entries */
-                       if ($this->dn == "new"){
-                               $this->dn= "cn=$this->cn,ou=gofax,ou=systems,".$this->base;
-                       }
-
-                       $this->save ();
-                       gosa_log ("Blocklist object'".$this->dn."' has been saved");
-                       $this->acl= "#none#";
-                       $this->dn= "";
-                       del_lock ($this->ui->dn);
-                       unset($_SESSION['objectinfo']);
-               } else {
-                       /* Errors found, show message */
-                       show_errors ($message);
-               }
-       }
-       
-       /* Headpage or normal plugin screen? */
-       if ($this->dn == ""){
-               /* Check sorting variable */
-               $this->reload();
-
-               /* Check for exeeded sizelimit */
-               if (($message= check_sizelimit()) != ""){
-                       return($message);
-               }
-
-               /* Show main page */
-               $smarty->assign("blocklists", $this->blocklists);
-               $smarty->assign("search_image", get_template_path('images/search.png'));
-               $smarty->assign("tree_image", get_template_path('images/tree.png'));
-               $smarty->assign("infoimage", get_template_path('images/info.png'));
-               $smarty->assign("launchimage", get_template_path('images/launch.png'));
-               $smarty->assign("apply", apply_filter());
-               foreach( array("depselect", "entry", "regex", "sendlists", "receivelists") as $type){
-                       $smarty->assign("$type", $blockfilter[$type]);
-               }
-               $smarty->assign("deplist", $this->config->idepartments);
-               $smarty->assign("alphabet", generate_alphabet());
-               $smarty->assign("hint", print_sizelimit_warning());
-
-               return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
-       }
-
-       /* Set base */
-       if ($this->base == ""){
-               if ($this->dn == "new"){
-                       $ui= get_userinfo();
-                       $this->base= dn2base($ui->dn);
-               } else {
-                       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
-               }
-       }
-
-       /* Fill templating stuff */
-       $smarty->assign("bases", $this->config->idepartments);
-       $smarty->assign("base_select", $this->base);
-       $smarty->assign("types", array(0 => _("send"), 1 => _("receive")));
-        if ($this->dn == "new" || preg_match ("/,ou=incoming,/", $this->dn)){
-                $smarty->assign("selectmode", "");
-                $smarty->assign("mode", "");
-        } else {
-                $smarty->assign("selectmode", "disabled");
-                $smarty->assign("mode", "readonly");
+        $this->type= 1;
+      }
+      $_SESSION['objectinfo']= trim($this->dn);
+    }
+
+    /* Delete blocklist requested */
+    if ($s_action=="del"){
+      $this->dn=$this->blocklists[$s_entry]['dn'];
+      /* Check locking */
+      if (($user= get_lock($this->dn)) != ""){
+        $_SESSION['dn']= $this->dn;
+        return(gen_locked_message($user, $this->dn));
+      } else {
+# Lock this dn for editing
+        add_lock ($this->dn, $this->ui->dn);
+
+        $smarty->assign("info", sprintf(_("You're about to delete the blocklist '%s'."), $this->dn));
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
+    }
+
+    /* Finally delete blocklist */
+    if (isset($_POST['delete_blocklist_confirm'])){
+      $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
+      $acl= get_module_permission($acl, "blocklists", $this->dn);
+      if (chkacl($acl, "all") == ""){
+        $this->remove_from_parent();
+        gosa_log ("Blocklist object'".$this->dn."' has been removed");
+        $this->reload ();
+      } else {
+        print_red (_("You have no permission to remove this blocklist."));
+      }
+    }
+
+    /* Cancel dialog */
+    if (isset($_POST['edit_cancel']) || isset($_POST['delete_blocklist_cancel']) ||
+        isset($_POST['delete_blocklist_confirm']) || isset($_POST['delete_lock'])){
+
+      del_lock ($this->dn);
+      $this->clear_fields();
+      unset($_SESSION['objectinfo']);
+    }
+
+    /* Handle interactions: add */
+    if (isset($_POST['add_number']) && $_POST['number'] != ""){
+      if (is_phone_nr($_POST['number'])){
+        $this->addNumber ($_POST['number']);
+      } else {
+        print_red (_("Please specify a valid phone number."));
+      }
+    }
+
+    /* Handle interactions: delete */
+    if (isset($_POST['delete_number']) && count($_POST['numbers']) > 0){
+      $this->delNumber ($_POST['numbers']);
+    }
+
+    /* What about finish? */
+    if (isset($_POST['edit_finish'])){
+      $message= $this->check();
+
+      /* No errors, save object */
+      if (count ($message) == 0){
+
+        /* Perpare 'dn' in case of new entries */
+        if ($this->dn == "new"){
+          $this->dn= "cn=$this->cn,ou=gofax,ou=systems,".$this->base;
         }
-       foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
-               $smarty->assign("$val", $this->$val);
-               $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
-       }
-
-       /* Lock blocklist type for non new entries */
-       if ($this->dn != "new"){
-               $smarty->assign('typeACL', "disabled");
-       }
-
-       /* Show main page */
-       return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
+
+        $this->save ();
+        gosa_log ("Blocklist object'".$this->dn."' has been saved");
+        $this->acl= "#none#";
+        $this->dn= "";
+        del_lock ($this->ui->dn);
+        unset($_SESSION['objectinfo']);
+      } else {
+        /* Errors found, show message */
+        show_errors ($message);
+      }
+    }
+
+    /* Headpage or normal plugin screen? */
+    if ($this->dn == ""){
+      /* Check sorting variable */
+      $this->reload();
+
+      /* Check for exeeded sizelimit */
+      if (($message= check_sizelimit()) != ""){
+        return($message);
+      }
+
+   $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($blockfilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+
+
+
+      /* NEW LIST MANAGMENT */
+      $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+        " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+        " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
+        " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
+        " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+        " <input type='image' align='middle' src='images/list_new_blocklist.png' title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'>&nbsp;".
+        " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;"._("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+        " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+        "</div>";
+
+      $action= "<input type='image' src='images/edit.png' alt='"._("edit")."'     name='user_edit_%KEY%' title='"._("Edit user")."'>";
+      $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."'   name='user_del_%KEY%' title='"._("Delete user")."'>";
+
+
+      $divlist = new divlist();
+      $divlist->SetHeader(array(
+            array("string" => "&nbsp;"),
+            array("string" => _("Blocklist name")." / "._("Department")),
+            array("string" => _("Actions"), "attach" => "style='border:none'" )));
+
+
+      $divlist->SetSummary(_("This table displays faxblocklists for the selected tree."));
+      $divlist->SetEntriesPerPage(20);
+
+      // Defining Links
+      $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+      foreach($this->departments as $key=> $val){
+        $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+        $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+        $field3 = array("string" => "&nbsp;", "attach" => "style='border:none'");
+        $divlist->AddEntry(array($field1,$field2,$field3));
+      }
+
+      // User and Template  Images
+      $blockimg = "<img src='images/list_blocklist.png' alt='User' title='%s'>";
+      $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+
+      foreach($this->blocklists as $key => $val){
+        // Generate Array to Add
+        $display= "[".$val["cn"][0]."]";
+        $field1 = array("string" => sprintf($blockimg,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+        $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
+        $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:40px'");
+        $divlist->AddEntry( array($field1,$field2,$field3));
+      }
+
+      /* Show main page */
+      $smarty->assign("blocklistshead", $listhead);
+      $smarty->assign("blocklists", $divlist->DrawList());
+      $smarty->assign("search_image", get_template_path('images/search.png'));
+      $smarty->assign("tree_image", get_template_path('images/tree.png'));
+      $smarty->assign("infoimage", get_template_path('images/info.png'));
+      $smarty->assign("launchimage", get_template_path('images/launch.png'));
+      $smarty->assign("apply", apply_filter());
+      foreach( array("depselect", "entry", "regex", "sendlists", "receivelists") as $type){
+        $smarty->assign("$type", $blockfilter[$type]);
+      }
+      $smarty->assign("deplist", $this->config->idepartments);
+      $smarty->assign("alphabet", generate_alphabet());
+      $smarty->assign("hint", print_sizelimit_warning());
+
+      return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
+    }
+
+    /* Set base */
+    if ($this->base == ""){
+      if ($this->dn == "new"){
+        $ui= get_userinfo();
+        $this->base= dn2base($ui->dn);
+      } else {
+        $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+      }
+    }
+
+    /* Fill templating stuff */
+    $smarty->assign("bases", $this->config->idepartments);
+    $smarty->assign("base_select", $this->base);
+    $smarty->assign("types", array(0 => _("send"), 1 => _("receive")));
+    if ($this->dn == "new" || preg_match ("/,ou=incoming,/", $this->dn)){
+      $smarty->assign("selectmode", "");
+      $smarty->assign("mode", "");
+    } else {
+      $smarty->assign("selectmode", "disabled");
+      $smarty->assign("mode", "readonly");
+    }
+    foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
+      $smarty->assign("$val", $this->$val);
+      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
+    }
+
+    /* Lock blocklist type for non new entries */
+    if ($this->dn != "new"){
+      $smarty->assign('typeACL', "disabled");
+    }
+
+    /* Show main page */
+    return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
   }
 
   function clear_fields()
   {
-       $this->dn= "";
-       $this->description= "";
-       $this->cn= "";
-       $this->base= "";
-       $this->goFaxBlocklist= array();
-       $this->acl= "#none#";
+    $this->dn= "";
+    $this->description= "";
+    $this->cn= "";
+    $this->base= "";
+    $this->goFaxBlocklist= array();
+    $this->acl= "#none#";
   }
 
   function reload()
   {
-       /* Get config */
-        $blockfilter= get_global('blockfilter');
-
-        /* Set base for all searches */
-        $base= $blockfilter['depselect'];
-       $filter= "";
-
-        /* Regex filter? */
-        if ($blockfilter['regex'] != ""){
-                $regex= $blockfilter['regex'];
-        } else {
-                $regex= "*";
-        }
-
-        /* Entry filter? */
-        /* Get list of blocklists to be shown */
-        if ($blockfilter['sendlists'] == "checked"){
-               $filter.= "(objectClass=goFaxSBlock)";
-        }
-        if ($blockfilter['receivelists'] == "checked"){
-               $filter.= "(objectClass=goFaxRBlock)";
-        }
-       if ($filter != ""){
-               $filter= "(|$filter)";
-       }
-
-        if ($blockfilter['entry'] != "" && $blockfilter['entry'] != "*"){
-                $filter.= "(|(goFaxSBlocklist=".$blockfilter['entry'].")(goFaxRBlocklist=".$blockfilter['entry']."))";
-        }
-
-       /* Generate blocklists */
-       $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)$filter)", TRUE, $base, array("cn", "description"));
-
-       $this->blocklists= array();
-       foreach ($res as $value){
-
-               /* Unwanted? */
-               $this->blocklists[$value["dn"]]= $value["cn"][0];
-               if (isset($value["description"][0])){
-                       $this->blocklists[$value["dn"]]= $value["cn"][0]." (".
-                                               $value["description"][0].")";
-               }
-       }
-       natcasesort ($this->blocklists);
-       reset ($this->blocklists);
+    /* Get config */
+    $blockfilter= get_global('blockfilter');
+
+    /* Set base for all searches */
+    $base= $blockfilter['depselect'];
+    $filter= "";
+
+    /* Regex filter? */
+    if ($blockfilter['regex'] != ""){
+      $regex= $blockfilter['regex'];
+    } else {
+      $regex= "*";
+    }
+
+    /* Entry filter? */
+    /* Get list of blocklists to be shown */
+    if ($blockfilter['sendlists'] == "checked"){
+      $filter.= "(objectClass=goFaxSBlock)";
+    }
+    if ($blockfilter['receivelists'] == "checked"){
+      $filter.= "(objectClass=goFaxRBlock)";
+    }
+    if ($filter != ""){
+      $filter= "(|$filter)";
+    }
+
+    if ($blockfilter['entry'] != "" && $blockfilter['entry'] != "*"){
+      $filter.= "(|(goFaxSBlocklist=".$blockfilter['entry'].")(goFaxRBlocklist=".$blockfilter['entry']."))";
+    }
+
+    /* Generate blocklists */
+    $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)$filter)", TRUE, $base, array("*"));
+
+    $this->blocklists=$res;
+
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+        TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    foreach ($res3 as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
+      }
+    }
+
+    /* END NEW LIST MANAGMENT
+     */
+
+    reset ($this->blocklists);
   }
 
   function remove_from_parent()
   {
-       $ldap= $this->config->get_ldap_link();
-       $ldap->rmDir($this->dn);
-       $this->handle_post_events("remove");
+    $ldap= $this->config->get_ldap_link();
+    $ldap->rmDir($this->dn);
+    $this->handle_post_events("remove");
   }
 
 
   /* Save data to object */
   function save_object()
   {
-       plugin::save_object();
-       
-       /* Save type, needed to detect objectClass */
-       if (isset($_POST['type']) && chkacl($this->acl, "cn") == ""){
-               $this->type= $_POST['type'];
-       }
-
-        /* Save base, since this is no LDAP attribute */
-        if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
-                $this->base= $_POST['base'];
-        }
+    plugin::save_object();
+
+    /* Save type, needed to detect objectClass */
+    if (isset($_POST['type']) && chkacl($this->acl, "cn") == ""){
+      $this->type= $_POST['type'];
+    }
+
+    /* Save base, since this is no LDAP attribute */
+    if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
+      $this->base= $_POST['base'];
+    }
   }
 
 
   /* Check values */
   function check()
   {
-       $message= array();
-
-       /* Permissions for that base? */
-       if ($this->base != ""){
-               $new_dn= "cn=".$this->cn.",ou=gofax,ou=systems,".$this->base;
-       } else {
-               $new_dn= $this->dn;
-       }
-
-       $ui= get_userinfo();
-       $acl= get_permissions ($new_dn, $ui->subtreeACL);
-       $acl= get_module_permission($acl, "blocklist", $new_dn);
-       if (chkacl($acl, "create") != ""){
-               $message[]= _("You have no permissions to create a blocklist on this 'Base'.");
-       }
-
-
-       /* check syntax: must cn */
-       if ($this->cn == ""){
-               $message[]= _("Required field 'Name' is not set.");
-       } else {
-               if (!is_uid($this->cn)){
-                       $message[]= _("Required field 'Name' contains invalid characters");
-               }
-               if ($this->dn == 'new'){
-                       $ldap= $this->config->get_ldap_link();
-                       $ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]);
-                       $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))".
-                                       "(cn=".$this->cn."))", array("cn"));
-                       if ($ldap->count() != 0){
-                               $message[]= _("Specified name is already used.");
-                       }
-               }
-       }
-
-       /* Is user allowed to create in 'base'? */
-       if (chkacl($this->acl, "create") != ""){
-               $message[]= _("No permission to create a blocklist on this base.");
-       }
-
-       return $message;
+    $message= array();
+
+    /* Permissions for that base? */
+    if ($this->base != ""){
+      $new_dn= "cn=".$this->cn.",ou=gofax,ou=systems,".$this->base;
+    } else {
+      $new_dn= $this->dn;
+    }
+
+    $ui= get_userinfo();
+    $acl= get_permissions ($new_dn, $ui->subtreeACL);
+    $acl= get_module_permission($acl, "blocklist", $new_dn);
+    if (chkacl($acl, "create") != ""){
+      $message[]= _("You have no permissions to create a blocklist on this 'Base'.");
+    }
+
+
+    /* check syntax: must cn */
+    if ($this->cn == ""){
+      $message[]= _("Required field 'Name' is not set.");
+    } else {
+      if (!is_uid($this->cn)){
+        $message[]= _("Required field 'Name' contains invalid characters");
+      }
+      if ($this->dn == 'new'){
+        $ldap= $this->config->get_ldap_link();
+        $ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]);
+        $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))".
+            "(cn=".$this->cn."))", array("cn"));
+        if ($ldap->count() != 0){
+          $message[]= _("Specified name is already used.");
+        }
+      }
+    }
+
+    /* Is user allowed to create in 'base'? */
+    if (chkacl($this->acl, "create") != ""){
+      $message[]= _("No permission to create a blocklist on this base.");
+    }
+
+    return $message;
   }
 
 
   /* Save to LDAP */
   function save()
   {
-       plugin::save();
-
-       /* Type selection */
-       if ($this->type == 0){
-               $type= "goFaxSBlock";
-       } else {
-               $type= "goFaxRBlock";
-       }
-
-       /* Add list */
-       $this->attrs['objectClass']= $type;
-       if (count($this->goFaxBlocklist)){
-               $this->attrs["$type"."list"]= $this->goFaxBlocklist;
-       }
-
-       /* Write back to ldap */
-       $ldap= $this->config->get_ldap_link();
-       $ldap->cd($ldap->getParentDir($this->dn));
-       $ldap->search("cn=$this->cn");
-       $a= $ldap->fetch();
-       if (count($a)){
-               if (!isset($this->attrs["$type"."list"])){
-                       $this->attrs["$type"."list"]= array();
-               }
-               $ldap->cd($this->dn);
-               $ldap->modify($this->attrs);
-               $this->handle_post_events("modify");
-       } else {
-               $ldap->cd($this->config->current['BASE']);
-               $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
-               $ldap->cd($this->dn);
-               $ldap->add($this->attrs);
-               $this->handle_post_events("add");
-       }
-       show_ldap_error($ldap->get_error());
+    plugin::save();
+
+    /* Type selection */
+    if ($this->type == 0){
+      $type= "goFaxSBlock";
+    } else {
+      $type= "goFaxRBlock";
+    }
+
+    /* Add list */
+    $this->attrs['objectClass']= $type;
+    if (count($this->goFaxBlocklist)){
+      $this->attrs["$type"."list"]= $this->goFaxBlocklist;
+    }
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($ldap->getParentDir($this->dn));
+    $ldap->search("cn=$this->cn");
+    $a= $ldap->fetch();
+    if (count($a)){
+      if (!isset($this->attrs["$type"."list"])){
+        $this->attrs["$type"."list"]= array();
+      }
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);
+      $this->handle_post_events("modify");
+    } else {
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      $this->handle_post_events("add");
+    }
+    show_ldap_error($ldap->get_error());
   }
 
 
   function addNumber($number)
   {
-       if (!in_array($number, $this->goFaxBlocklist)){
-               $this->goFaxBlocklist[]= $number;
-               sort($this->goFaxBlocklist);
-       }
+    if (!in_array($number, $this->goFaxBlocklist)){
+      $this->goFaxBlocklist[]= $number;
+      sort($this->goFaxBlocklist);
+    }
   }
 
   function delNumber($numbers)
   {
-       $tmp= array();
-       foreach ($this->goFaxBlocklist as $val){
-               if (!in_array($val, $numbers)){
-                       $tmp[]= $val;
-               }
-       }
-       $this->goFaxBlocklist= $tmp;
+    $tmp= array();
+    foreach ($this->goFaxBlocklist as $val){
+      if (!in_array($val, $numbers)){
+        $tmp[]= $val;
+      }
+    }
+    $this->goFaxBlocklist= $tmp;
   }
 
   function remove_lock()
   {
-       if (isset($this->dn)){
-               del_lock ($this->dn);
-       }
+    if (isset($this->dn)){
+      del_lock ($this->dn);
+    }
   }
 
 }
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 0168b7ecc6b0f3cdfb439bbb30e121d9f9827a15..835a6ad07eb846e45656464ee8444125f7be126c 100644 (file)
@@ -7,17 +7,12 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-      <select style="width:500px; height:450px;" name="blocklist" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-         {html_options options=$blocklists}
-      <option disabled>&nbsp;</option>
-         </select>
-      <br>
-      <input type=submit value="{t}New{/t}..." name="new_blocklist">&nbsp;
-      <input type=submit value="{t}Edit{/t}" name="select_blocklist">&nbsp;
-      <input type=submit value="{t}Delete{/t}" name="delete_blocklist">
+         {$blocklistshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+         {$blocklists}
       <input type=hidden name="edit_helper">
-    </p>
   </div>
   </td>
   <td style="vertical-align:top;">
@@ -28,9 +23,6 @@
    <p class="contentboxb">
     {t}This menu allows you to create, delete and edit selected blocklists. Having a large size of lists, you might prefer the range selectors on top of the select box.{/t}
    </p>
-   <p class="contentboxb">
-    {t}-Edit- and -New...- will execute an assistant to aid you when performing changes on your blocklist. -Delete- will ask you for confirmation before really deleting anything.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
                        </td>
                </tr>
        </table>    
-
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-       <tr>
-               <td width="50%">
-                       <img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display lists of department{/t}
-               </td>
-       <td>
-                       <select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-                            {html_options options=$deplist selected=$depselect}
-                       <option disabled>&nbsp;</option>
-                   </select>
-               </td>
-       </tr>
-</table>
-
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
                <td width="50%"><img alt=""  src="{$search_image}" align=middle>
@@ -76,8 +53,8 @@
 
 <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
        <tr>
-               <td width="50%">
-                       <img alt="" src="{$search_image}" align=middle>&nbsp;{t}Display lists containing{/t}
+               <td width=50%>
+                       <img alt="Search" src="{$search_image}" align=middle>{t}Display lists containing{/t}
                </td>
            <td>
                <input type='text' name='entry' maxlength='20' value='{$entry}' title='{t}Show lists containing entered numbers{/t}' onChange="mainform.submit()">
index ba19f05af79b046d74363c5e9f8b078869aaa77c..53281d0c52557c9ef27e7c34719db2d748cca24d 100755 (executable)
@@ -61,17 +61,79 @@ class gofonMacro extends plugin
       }
       $macrofilter['regex']= $s;
     }
-    /* Save (new) Filter */
-    register_global("macrofilter", $macrofilter);
 
-    /* Check sorting variable */
-    if (!isset($this->macrotabs) &&
-        !isset($_POST['new_mac']) &&
-        !isset($_POST['delete_mac']) &&
-        !isset($_POST['select_mac'])){
-      $this->reload();
+    $s_action     = "";                       // Contains the action to proceed
+    $s_entry      = "";                       // The value for s_action
+    $base_back    = "";                       // The Link for Backbutton
+
+    /* Start for New List Managment */
+    if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+            $s_action="open";
+            $s_entry = base64_decode($_GET['dep_id']);
+            $macrofilter['depselect']= "".$this->config->departments[trim($s_entry)];
     }
-  
+
+    /* Test Posts */
+    foreach($_POST as $key => $val){
+      // Post for delete
+      if(preg_match("/user_del.*/",$key)){
+        $s_action = "del";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for edit
+      }elseif(preg_match("/user_edit_.*/",$key)){
+        $s_action="edit";
+        $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
+        // Post for new
+      }elseif(preg_match("/dep_back.*/i",$key)){
+        $s_action="back";
+      }elseif(preg_match("/user_new.*/",$key)){
+        $s_action="new";
+      }elseif(preg_match("/dep_home.*/i",$key)){
+        $s_action="home";
+      }elseif(preg_match("/user_chgpw.*/i",$key)){
+        $s_action="change_pw";
+        $s_entry  = preg_replace("/user_chgpw_/i","",$key);
+      }elseif(preg_match("/dep_root.*/i",$key)){
+        $s_action="root";
+      }
+    }
+  if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
+      $s_action ="edit";
+      $s_entry  = $_GET['id'];
+    }
+
+    $s_entry  = preg_replace("/_.$/","",$s_entry);
+
+    /* Department changed? */
+    if(isset($_POST['depselect']) && $_POST['depselect']){
+      $macrofilter['depselect']= $_POST['depselect'];
+    }
+
+    /* Homebutton is posted */
+    if($s_action=="home"){
+      $macrofilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+      $macrofilter['depselect']=(preg_replace("/^[^,]+,/","",$macrofilter['depselect']));
+    }
+
+    if($s_action=="root"){
+      $macrofilter['depselect']=($this->config->current['BASE']);
+    }
+
+
+    /* If Backbutton is Posted */
+    if($s_action=="back"){
+      $base_back          = preg_replace("/^[^,]+,/","",$macrofilter['depselect']);
+      $base_back          = convert_department_dn($base_back);
+
+      if(isset($this->config->departments[trim($base_back)])){
+        $macrofilter['depselect']= $this->config->departments[trim($base_back)];
+      }else{
+        $macrofilter['depselect']= $this->config->departments["/"];
+      }
+    }
+
+    register_global("macrofilter", $macrofilter);
+    $this->reload();
     
     $smarty= get_smarty();
 
@@ -81,7 +143,7 @@ class gofonMacro extends plugin
     }
 
     /* New macro? */
-    if (isset($_POST['new_mac'])){
+    if ($s_action=="new"){
 
       /* By default we set 'dn' to 'new', all relevant plugins will
          react on this. */
@@ -137,10 +199,10 @@ class gofonMacro extends plugin
     }
 
     /* User wants to edit data? */
-    if ((isset($_POST['select_mac']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['macrolists']) && $_POST['macrolists'] != ""){
+    if ($s_action=="edit"){
 
       /* Get 'dn' from posted 'macrolists', must be unique */
-      $this->dn= trim($_POST['macrolists']);
+      $this->dn= $this->macros[$s_entry]['dn']; 
 
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
@@ -163,10 +225,10 @@ class gofonMacro extends plugin
     }
 
     /* Remove user was requested */
-    if (isset($_POST['delete_mac']) && isset($_POST['macrolists'])){
+    if ($s_action=="del"){
 
       /* Get 'dn' from posted 'uid' */
-      $this->dn= trim($_POST['macrolists']);
+      $this->dn= $this->macros[$s_entry]['dn'];
 
       /* Load permissions for selected 'dn' and check if
          we're allowed to remove this 'dn' */
@@ -243,8 +305,93 @@ class gofonMacro extends plugin
       return ($display);
     }
 
+
+
+
+    /* Prepare departments */
+    $options= "";
+    foreach ($this->config->idepartments as $key => $value){
+            if ($macrofilter['depselect'] == $key){
+                    $options.= "<option selected value='$key'>$value</option>";
+            } else {
+                    $options.= "<option value='$key'>$value</option>";
+            }
+    }
+
+
+   /* NEW LIST MANAGMENT */
+    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+            " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
+            " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root").        "'>&nbsp;".
+            " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."'                     name='dep_home'>&nbsp;".
+            " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+            " <input type='image' align='middle' src='images/list_new_macro.png' title='"._("Create new phone macro")."' alt='"._("New")."' name='user_new'>&nbsp;".
+            " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+            _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
+            " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+            "</div>";
+
+
+    /* Options */
+    $action= "<input type='image' src='images/edit.png' alt='"._("edit")."'     name='user_edit_%KEY%' title='"._("Edit user")."'>";
+    $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."'   name='user_del_%KEY%' title='"._("Delete user")."'>";
+
+    $divlist = new divlist();
+    $divlist->SetHeader(array(
+                              array("string" => "&nbsp;"),
+                              array("string" => _("Username")." / "._("Department")),
+                              array("string" => _("Visible"), "attach" => "style='width:30px;'"),
+                              array("string" => _("Actions"), "attach" => "style='border:none'" )));
+
+
+    $divlist->SetSummary(_("This table displays all phone macros, in the selected tree."));
+    $divlist->SetEntriesPerPage(20);
+
+    // Defining Links
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+    foreach($this->departments as $key=> $val){
+      $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
+      $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
+      $field3 = array("string" => "&nbsp;");
+      $field4 = array("string" => "&nbsp;", "attach" => "style='border:none'");
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
+    // Pictures for Extensions
+    $empty    = "<img src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
+
+    // User and Template  Images
+    $macroimg   = "<img src='images/list_macro.png' alt='"._("Macro")."' title='%s'>";
+    $visible    = "<img src='images/true.png' alt='"._("yes")."' title='"._("visible")."'>";
+    $invisible  = "<img src='images/false.png' alt='"._("no")."'title='"._("invisible")."'>";
+
+    // Link for edit
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+  
+    // Test Every Entry and generate divlist Array
+    foreach($this->macros as $key => $val){
+      // Generate Array to Add
+      $display= $val["displayName"][0];
+    
+      
+      if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){
+        $pic1 = $visible;
+      }else{
+        $pic1 = $invisible;
+      }
+
+      $field1 = array("string" => sprintf($macroimg,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
+      $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
+      $field3 = array("string" => $pic1, "attach" => "style='width:20px;text-align:right;'");
+      $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none;text-align:right;width:48px'");
+
+      $divlist->AddEntry(array($field1,$field2,$field3,$field4));
+    }
+
     /* Show main page */
-    $smarty->assign("macros", $this->macros);
+    $smarty->assign("macroshead", $listhead);
+    $smarty->assign("macros", $divlist->DrawList());
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("tree_image", get_template_path('images/tree.png'));
     $smarty->assign("infoimage", get_template_path('images/info.png'));
@@ -279,16 +426,31 @@ class gofonMacro extends plugin
     }
 
     /* Generate macro list */
-    $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)(objectClass=goFonMacro))", TRUE, $base, array("cn", "description"), TRUE);
-    $this->macros= array();
-    foreach ($res as $value){
-      $this->macros[$value["dn"]]= $value["cn"][0];
-      if (isset($value["description"][0])){
-        $this->macros[$value["dn"]]= $value["cn"][0]." (".
-          $value["description"][0].")";
+    $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)(objectClass=goFonMacro))", TRUE, $base, array("*"), TRUE);
+    $this->macros= $res;
+
+    /* NEW LIST MANAGMENT
+     * We also need to search for the departments
+     * So we are able to navigate like in konquerer
+     */
+    $base2 = preg_replace("/ou=people,/i","",$base);
+
+    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+        TRUE, $base2, array("ou", "description"), TRUE);
+
+    $this->departments= array();
+    foreach ($res3 as $value){
+      if($value["description"][0]!=".."){
+        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$value['dn']]=$value["description"][0];
       }
     }
-    natcasesort ($this->macros);
+
+    /* END NEW LIST MANAGMENT
+     */
+
+
     reset ($this->macros);
   }
 
index 13660ad2ef2e2f1a63739f9f158edb8c4b1d161c..b7d055b6b059f4834bf8803a9d6b1228967f6957 100755 (executable)
@@ -7,17 +7,12 @@
     </p>
   </div>
   <div class="contentboxb">
-    <p class="contentboxb">
-     <select style="width:500px; height:450px;" name="macrolists" size=15 ondblclick="this.form.edit_helper.value='1'; this.form.submit()">
-      {html_options options=$macros}
-               <option disabled>&nbsp;</option>
-    </select>
-    <br>
-    <input type=submit value="{t}New{/t}..." name="new_mac">&nbsp;
-    <input type=submit value="{t}Edit{/t}" name="select_mac">&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_mac">&nbsp;
+      {$macroshead}
+  </div>
+  <div style='height:4px;'></div>
+  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+      {$macros}
     <input type=hidden name="edit_helper">
-   </p>
   </div>
   </td>
   <td style="vertical-align:top">
@@ -28,9 +23,6 @@
    <p class="contentboxb">
     {t}This menu allows you to add, edit and remove selected macros. You may want to use the range selector on top of the macro listbox, when working with a large number of macros.{/t}
    </p>
-   <p class="contentboxb">
-    {t}-Edit- and -New...- will execute an assistant to aid you in editing properties. -Delete- will ask for confirmation before removing macros.{/t}
-   </p>
    </div>
    <br>
    <div class="contentboxh">
     <table style="width:100%;border-top:1px solid #B0B0B0;" summary="">
                <tr>
                        <td>
-                               <img alt="" src="{$tree_image}" align=middle>&nbsp;{t}Display macros of department{/t}
-                       </td>
-                   <td>
-                               <select name="depselect" size=1 onChange="mainform.submit()" title="{t}Choose the department the search will be based on{/t}">
-                                 {html_options options=$deplist selected=$depselect}
-                                       <option disabled>&nbsp;</option>
-                               </select>
-                       </td>
-               </tr>
-       </table>
-    <table style="width:100%;border-top:1px solid #B0B0B0;" summary="">
-               <tr>
-                       <td>
-                               <img alt="" src="{$search_image}" align=middle>&nbsp;{t}Display macros  matching{/t}
+                               <img alt="Search" src="{$search_image}" align=middle title='{t}Display macros  matching{/t}'>
                        </td>
                <td>
-                               <input type='text' name='regex' maxlength='20' value='{$regex}' title='{t}Regular expression for matching macro names{/t}' onChange="mainform.submit()">
+                               <input type='text' name='regex' maxlength='20' value='{$regex}' style='width:99%;' title='{t}Regular expression for matching macro names{/t}' onChange="mainform.submit()">
                        </td>
                </tr>
        </table>