From: hickert Date: Wed, 12 Dec 2007 09:08:55 +0000 (+0000) Subject: Multiple edit X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=96109a0c3cd0d9e4293c3a7810aad88332eacff0;p=gosa.git Multiple edit -Preset attributes which are used in all objects git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8090 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_multi_plug.inc b/include/class_multi_plug.inc index 0012b2710..e9851afc1 100644 --- a/include/class_multi_plug.inc +++ b/include/class_multi_plug.inc @@ -110,8 +110,40 @@ class multi_plug $this->a_handles[] = $obj; } } + + /* Detect attributes used by all plugins and set + * those values as default in edit handle + */ + $this->detect_multiple_used_attributes(); + } + + + /*! \brief Detect values that are used in all edited objects. + * @returns array All multiple used attributes + */ + private function detect_multiple_used_attributes() + { + $attrs = array(); + restore_error_handler(); + $first = $this->o_tab->current; + foreach($this->a_handles as $handle){ + if(count($attrs) == 0){ + $attrs = $handle->by_object[$first]->attrs; + }else{ + + foreach($attrs as $key => $attr){ + if(!isset($handle->by_object[$first]->attrs[$key]) || !($attr === $handle->by_object[$first]->attrs[$key])){ + unset($attrs[$key]); + } + } + } + } + foreach($this->o_tab->by_object as $name => $obj){ + $this->o_tab->by_object[$name]->init_multiple_support($attrs); + } } + /*! \brief Returns the edit ui for multiple edit. @return string HTML User interface for given tab object. */ diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 7b7910445..5a209ab39 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -1690,18 +1690,22 @@ class plugin } - - - function set_multi_edit_value() - { - - } - - /*! \brief Prepares the plugin to be used for multiple edit + * Update plugin attributes with given array of attribtues. + * @param array Array with attributes that must be updated. */ - function init_multiple_support() + function init_multiple_support($attrs) { + $ldap= $this->config->get_ldap_link(); + $this->attrs= $attrs; + + /* Copy needed attributes */ + foreach ($this->attributes as $val){ + $found= array_key_ics($val, $this->attrs); + if ($found != ""){ + $this->$val= $this->attrs["$found"][0]; + } + } } diff --git a/include/class_tabs.inc b/include/class_tabs.inc index b6060399a..d6ed872a5 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -384,7 +384,6 @@ class tabs foreach($this->by_object as $name => $obj){ if($obj->multiple_support){ $this->by_object[$name]->multiple_support_active = TRUE; - $this->by_object[$name]->init_multiple_support(); }else{ unset($this->by_object[$name]); unset($this->by_name[$name]);