Code

Moved get_departments to class config
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Apr 2006 10:52:03 +0000 (10:52 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Apr 2006 10:52:03 +0000 (10:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3166 594d385d-05f5-0310-b6e9-bd551577e9d8

html/main.php
include/class_config.inc
include/class_plugin.inc
include/functions.inc
plugins/admin/departments/class_departmentGeneric.inc
plugins/admin/departments/class_departmentManagement.inc
plugins/admin/departments/generic.tpl

index 8c096eb3b49a7bc8396b84dcd5bdc7b09b2c1690..e589f95975a8ec85b702f6ab13cf15f4f8f3aa35 100644 (file)
@@ -232,9 +232,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST"){
    compromise between speed and beeing up to date */
 if (isset($_GET['reset'])){
   if (!isset($_SESSION['cached_departments'])){
-    $_SESSION['cached_departments']= get_departments();
+    $config->get_departments();
+    $_SESSION['cached_departments']= $config->departments;
+  } else {
+    $config->departments= $_SESSION['cached_departments'];
   }
-  $config->departments= $_SESSION['cached_departments'];
   $config->make_idepartments ();
   if (isset($_SESSION['objectinfo'])){
     unset ($_SESSION['objectinfo']);
index bca1f5bdcc49db7763f14aacde8e40f3bee7e838..ef1c93c669e9b47ec270b12b36545c872f95b1e9 100644 (file)
@@ -462,6 +462,35 @@ class config  {
     }
   }
 
+
+  function get_departments($ignore_dn= "")
+  {
+    global $config;
+
+    /* Initialize result hash */
+    $result= array();
+    $result['/']= $this->current['BASE'];
+
+    /* Get list of department objects */
+    $ldap= $this->get_ldap_link();
+    $ldap->cd ($this->current['BASE']);
+    $ldap->search ("(objectClass=gosaDepartment)", array("ou"));
+    while ($attrs= $ldap->fetch()){
+      $dn= $ldap->getDN();
+      if ($dn == $ignore_dn){
+        continue;
+      }
+
+      /* Only assign non-root departments */
+      if ($dn != $result['/']){
+        $result[convert_department_dn($dn)]= $dn;
+      }
+    }
+
+    $this->departments= $result;
+  }
+
+
   function make_idepartments($max_size= 28)
   {
     global $config;
index 66a191fc89f11acfa5cd864ede95bae3de8e3d75..9d7de4e59ff66c58dd69c003e8ca18b90a35a51d 100644 (file)
@@ -204,7 +204,9 @@ class plugin
     $_SESSION['LOCK_VARS_TO_USE'] =array();
   }
 
-  /* remove object from parent */
+  /*! \brief execute plugin
+     Removes object from parent
+   */
   function remove_from_parent()
   {
     /* include global link_info */
@@ -846,6 +848,23 @@ class plugin
     }
   }
 
+
+  function handle_object_tagging()
+  {
+    /* Watch out for an administrative unit below own base */
+    echo "<b>handle_object_tagging()</b><br><pre>";
+    echo "DN  : ".$this->dn."\n";
+    echo "Base: ".$this->config->current['BASE']."\n";
+    echo "</pre>";
+
+    /* Make a base search on every department */
+    //FIXME: evaluate if these informations should be cached, too
+    #$parts= split(',', preg_replace("/,".normalizePreg($this->config->current['BASE'])."$/", '', $this->dn));
+
+    /* Set objectclass and attribute */
+    
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index d93aa89095ea95dc1562d330af0273c7ea62fecb..e051a3948c32447ef7e3b2a501fee4f9384cae3c 100644 (file)
@@ -819,34 +819,6 @@ function get_base_from_people($dn)
 }
 
 
-function get_departments($ignore_dn= "")
-{
-  global $config;
-
-  /* Initialize result hash */
-  $result= array();
-  $result['/']= $config->current['BASE'];
-
-  /* Get list of department objects */
-  $ldap= $config->get_ldap_link();
-  $ldap->cd ($config->current['BASE']);
-  $ldap->search ("(objectClass=gosaDepartment)", array("ou"));
-  while ($attrs= $ldap->fetch()){
-    $dn= $ldap->getDN();
-    if ($dn == $ignore_dn){
-      continue;
-    }
-
-    /* Only assign non-root departments */
-    if ($dn != $result['/']){
-      $result[convert_department_dn($dn)]= $dn;
-    }
-  }
-
-  return ($result);
-}
-
-
 function chkacl($acl, $name)
 {
   /* Look for attribute in ACL */
index bf6b7e8214032aa70628a0a9c98036d2b5dfd10d..97bc429efb0fa555ffcd40184a475ebd6e7a555e 100644 (file)
@@ -31,16 +31,13 @@ class department extends plugin
        var $telephoneNumber= "";
        var $facsimileTelephoneNumber= "";
        var $orig_dn= "";
+       var $is_administrational_unit= false;
+       var $gosaUnitTag= "";
 
        var $rec_dst=false;     // Destination for recursive move
        var $rec_src=false;     // Source for recursive move 
        var $rec_cpy=false;     // Is recursive move requested ? 
 
-       function am_i_moved()
-       {
-               return $this->rec_cpy;
-       }
-
        /* Headpage attributes */
        var $last_dep_sorting= "invalid";
        var $departments= array();
@@ -71,10 +68,16 @@ class department extends plugin
                } else {
                        $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
                }
+
                /* set permissions */
                $ui= get_userinfo();
                $acl= get_permissions ($ui->dn, $ui->subtreeACL);
                $this->acl= get_module_permission($acl, "department", $ui->dn);
+
+               /* Is administrational Unit? */
+               if ($dn != "new" && in_array_ics('gosaAdministrationalUnit', $this->attrs['objectClass'])){
+                       $this->is_administrational_unit= true;
+               }
        }
 
        function execute()
@@ -83,7 +86,7 @@ class department extends plugin
                plugin::execute();
 
                /* Reload departments */
-               $this->config->departments= get_departments($this->dn);
+               $this->config->get_departments($this->dn);
                $this->config->make_idepartments();
                $smarty= get_smarty();
 
@@ -133,6 +136,15 @@ class department extends plugin
                        $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
                }
                $smarty->assign("base_select", $this->base);
+
+               /* Set admin unit flag */
+               if ($this->is_administrational_unit) {
+                       $smarty->assign("unitTag", "checked");
+               } else {
+                       $smarty->assign("unitTag", "");
+               }
+               $smarty->assign("unitTag"."ACL", chkacl($this->acl, "unitTag"));
+               
                return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
        }
 
@@ -169,6 +181,15 @@ class department extends plugin
                        if (chkacl($this->acl, "create") == ""){
                                $this->base= $_POST['base'];
                        }
+
+                       /* Save tagging flag */
+                       if (chkacl($this->acl, "unitTag") == ""){
+                               if (isset($_POST['unitTag'])){
+                                       $this->is_administrational_unit= true;
+                               } else {
+                                       $this->is_administrational_unit= false;
+                               }
+                       }
                }
        }
 
@@ -224,6 +245,14 @@ class department extends plugin
        /* Save to LDAP */
        function save()
        {
+               /* Add tag objects if needed */
+               if ($this->is_administrational_unit){
+                       $this->objectclasses[]= "gosaAdministrationalUnit";
+                       $this->attributes[]= "gosaUnitTag";
+               } else {
+                       plugin::handle_object_tagging();
+               }
+
                plugin::save();
 
                /* Write back to ldap */
@@ -231,6 +260,7 @@ class department extends plugin
                $ldap->cat($this->dn);
                $a= $ldap->fetch();
                $ldap->cd($this->dn);
+               
                if (count($a)){
                        $this->cleanup();
                        $ldap->modify ($this->attrs); 
@@ -242,10 +272,29 @@ class department extends plugin
                }
                show_ldap_error($ldap->get_error());
 
+               if ($this->is_administrational_unit){
+                       $this->tag_objects();
+               } else {
+                       $this->untag_objects();
+               }
+
                /* Optionally execute a command after we're done */
                $this->postcreate();
        }
 
+
+       /* Tag objects to have the gosaAdministrationalUnitTag */
+       function tag_objects()
+       {
+               echo "Tag";
+       }
+
+       /* Remove the gosaAdministrationalUnitTag from objects */
+       function untag_objects()
+       {
+               echo "Untag";
+       }
+
        /* Move/Rename complete trees */
        function recursive_move($src_dn, $dst_dn,$force = false)
        {
@@ -339,6 +388,10 @@ class department extends plugin
                }
        }
 
+       function am_i_moved()
+       {
+               return $this->rec_cpy;
+       }
 
 }
 
index eb578897611b817ab99b300388d9ab0001d7dba3..c15e2a2d62f64b732011ee65b5e9ef28784467cf 100644 (file)
@@ -65,7 +65,7 @@ class departmentManagement extends plugin
        $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/");
 
                /* Reload departments */
-               $this->config->departments      = get_departments();
+               $this->config->get_departments();
                $smarty                                         = get_smarty();
                $display                                        = "";
                $depfilter                                      = get_global("depfilter");
index ef30d12d1642052faec2271382d5c1276eacf4e8..620c971ddddeeec0c6326931cb6137ba0dd2ffaf 100644 (file)
  </tr>
 </table>
 
+<p class='seperator'>&nbsp;</p>
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+ <tr>
+   <td style="vertical-align:top; width:100%">
+     <h2><img class="center" alt="" align="middle" src="images/closedlock.png"> {t}Administrational settings{/t}</h2>
+
+     <input id="unitTag" type=checkbox name="unitTag" value="1" {$unitTag} {$unitTagACL}><label for="unitTag">{t}Tag department as an independent administrational unit{/t}</label>
+   </td>
+  </tr>
+</table>
+
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page