From 45502fdaea3a09f6c3684a4b2bb989b75d2bb18e Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 17 Dec 2007 14:33:36 +0000 Subject: [PATCH] Updated Attributes detection for multi plug git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8136 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_multi_plug.inc | 45 +++++++++++++------ gosa-core/include/class_plugin.inc | 12 +++++ .../personal/mail/class_mailAccount.inc | 9 +++- .../personal/posix/class_posixAccount.inc | 10 ++--- 4 files changed, 56 insertions(+), 20 deletions(-) diff --git a/gosa-core/include/class_multi_plug.inc b/gosa-core/include/class_multi_plug.inc index 84637992e..89f025687 100644 --- a/gosa-core/include/class_multi_plug.inc +++ b/gosa-core/include/class_multi_plug.inc @@ -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); } } diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 025729703..0241603ec 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -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 */ diff --git a/gosa-core/plugins/personal/mail/class_mailAccount.inc b/gosa-core/plugins/personal/mail/class_mailAccount.inc index 6d919d344..c98525c69 100644 --- a/gosa-core/plugins/personal/mail/class_mailAccount.inc +++ b/gosa-core/plugins/personal/mail/class_mailAccount.inc @@ -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() diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc index 554e7e6f7..438fa4147 100644 --- a/gosa-core/plugins/personal/posix/class_posixAccount.inc +++ b/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -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; } -- 2.30.2