Code

Updated Attributes detection for multi plug
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 Dec 2007 14:33:36 +0000 (14:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 17 Dec 2007 14:33:36 +0000 (14:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8136 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_multi_plug.inc
gosa-core/include/class_plugin.inc
gosa-core/plugins/personal/mail/class_mailAccount.inc
gosa-core/plugins/personal/posix/class_posixAccount.inc

index 84637992ea8c04bba4320b6b7d997477246927a8..89f02568790d8d230cb0fda96a537d0cd256c90c 100644 (file)
@@ -60,8 +60,10 @@ multi_plug::multi_plug()
   |
   |->o_tab->enable_multiple_support()       #Enable multiple support for ui handle
   |->detect_multiple_used_attributes()      #Update ui handle with some default values
-    |->handles->attrs
-    |->ui->attrs
+    |->handles[]
+      |->by_object->get_multi_init_values() #Get attributes from all handles
+    |->o_tab
+      |->by_object->init_multiple_support() #Assign values to ui handle
   |
   |->execute()                              #Display ui
   | |->o_tab->execute()
@@ -184,11 +186,20 @@ class multi_plug
    */  
   private function array_combine($base,$add)
   {
+
     foreach($add as $key => $attr) {
       if(!is_numeric($key)){
+  
+        if(!is_array($add[$key])){
+          $add[$key] = array('count' => 1,$add[$key]);
+        }
+
         if(!isset($base[$key])){
           $base[$key] = $add[$key]; 
-        }elseif(is_array($add[$key])){
+        }else{
+          if(!isset($add[$key]['count'])){
+            $add[$key]['count'] = count($add[$key]);
+          }
           for($i=0;$i<$add[$key]['count'];$i++){
             if(!in_array($add[$key][$i],$base[$key])){
               $base[$key][] = $add[$key][$i];
@@ -218,6 +229,9 @@ class multi_plug
         unset($base[$key]);
       }elseif(is_array($base[$key])){
         $tmp = array();
+          if(!isset($base[$key]['count'])){
+            $base[$key]['count'] = count($base[$key]);
+          }
         for($i = 0 ; $i < $base[$key]['count'] ; $i ++){
           if(isset($base[$key][$i]) && in_array($base[$key][$i],$minus[$key])){
             $tmp[] = $base[$key][$i];
@@ -239,18 +253,21 @@ class multi_plug
    */  
   private function detect_multiple_used_attributes()
   {
-    $attrs = array();
-    $first = $this->o_tab->current;
-    $all   = array();
-    foreach($this->a_handles as $handle){
-      if(count($attrs) == 0){
-        $attrs = $handle->by_object[$first]->attrs;
-      }else{
-        $attrs = $this->array_intersect($attrs,$handle->by_object[$first]->attrs);
+    foreach($this->o_tab->by_object as $name => $plug){
+
+      if(empty($name))    continue;
+
+      $attrs = array();
+      $all   = array();
+      foreach($this->a_handles as $hid => $handle){
+        $h_attrs = $this->a_handles[$hid]->by_object[$name]->get_multi_init_values();
+        if(count($attrs) == 0){
+          $attrs = $h_attrs;
+        }else{
+          $attrs = $this->array_intersect($attrs,$h_attrs);
+        }
+        $all = $this->array_combine($all,$h_attrs);
       }
-      $all = $this->array_combine($all,$handle->by_object[$first]->attrs);
-    }
-    foreach($this->o_tab->by_object as $name => $obj){
       $this->o_tab->by_object[$name]->init_multiple_support($attrs,$all);
     }
   }
index 0257297037f0d8272c7cdb346f2d2e3b3699d95d..0241603ecffab35d9685ceaffbf92c3fe3093849 100644 (file)
@@ -1800,6 +1800,18 @@ class plugin
   }
 
 
+  /*! \brief  Returns all attributes of this plugin, 
+               to be able to detect multiple used attributes 
+               in multi_plugg::detect_multiple_used_attributes().
+      @return array Attributes required for intialization of multi_plug
+   */
+  public function get_multi_init_values()
+  {
+    $attrs = $this->attrs;
+    return($attrs);
+  }
+
+
   /*! \brief  Check given values in multiple edit
       @return array Error messages
    */
index 6d919d3441b915fae5b5e56479a8dc74c3c35e76..c98525c69d658ec6614cdf1e4714dc7b798cb69e 100644 (file)
@@ -1211,8 +1211,15 @@ class mailAccount extends plugin
   function init_multiple_support($attrs,$all)
   {
     plugin::init_multiple_support($attrs,$all);
+   
+     
+  }
 
-    
+  function get_multi_init_values()
+  {
+    $attrs = plugin::get_multi_init_values();
+    $attrs['gosaMailQuota'] = $this->gosaMailQuota;
+    return($attrs);
   }
 
   function multiple_execute()
index 554e7e6f760a232fccfa97cf6b5719408b3ce27d..438fa41475a9302f0ee2e1d5752d2d37dfbf39b9 100644 (file)
@@ -151,12 +151,12 @@ class posixAccount extends plugin
       $ldap->cd($this->config->current['BASE']);
       $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description"));
 
-      while ($this->attrs= $ldap->fetch()){
-        if (!isset($this->attrs["description"][0])){
-          $entry= $this->attrs["cn"][0];
+      while ($attrs= $ldap->fetch()){
+        if (!isset($attrs["description"][0])){
+          $entry= $attrs["cn"][0];
         } else {
-          $dsc= preg_replace ('/^Group of user/', _("Group of user"), $this->attrs["description"][0]);
-          $entry= $this->attrs["cn"][0]." [$dsc]";
+          $dsc= preg_replace ('/^Group of user/', _("Group of user"), $attrs["description"][0]);
+          $entry= $attrs["cn"][0]." [$dsc]";
         }
         $this->groupMembership[$ldap->getDN()]= $entry;
       }