From: cajus Date: Fri, 10 Feb 2006 06:32:01 +0000 (+0000) Subject: Added more intelligent object modifiers X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8a2a50193975c3458935210358bdac7b17275415;p=gosa.git Added more intelligent object modifiers Added upper/lower case detection of attributes Added Debug messages for testing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2651 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/TODO b/TODO index cdbb3ca19..a966dda4d 100644 --- a/TODO +++ b/TODO @@ -20,6 +20,9 @@ Target for 2.4.1: * LabeledURI fix +* Phone account is not removable if the mysql database is not reachable. + This is no real problem, but I'd like to see the hint message for it. + Target for 2.5: =============== diff --git a/debian/rules b/debian/rules index 608cf565f..104068f7d 100755 --- a/debian/rules +++ b/debian/rules @@ -50,6 +50,7 @@ install-stamp: -rm -rf debian/gosa/usr/share/gosa/compile -mkdir -p debian/gosa/etc/gosa/vacation -cp -R debian/apache.conf debian/gosa/etc/gosa/apache.conf + -cp -R contrib/encodings debian/gosa/etc/gosa/encodings -cp -R plugins/personal/mail/sieve-*.txt debian/gosa/etc/gosa -cp contrib/shells debian/gosa/etc/gosa -rm -rf debian/gosa/usr/share/gosa/contrib diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 624714b6f..17814d986 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -100,6 +100,7 @@ class plugin var $attributes= array(); var $objectclasses= array(); var $new= TRUE; + var $saved_attributes= array(); /*! \brief plugin constructor @@ -129,8 +130,10 @@ class plugin /* Copy needed attributes */ foreach ($this->attributes as $val){ - if (isset($this->attrs["$val"][0])){ - $this->$val= $this->attrs["$val"][0]; + #if (isset($this->attrs["$val"][0])){ + $found= array_key_ics($val, $this->attrs); + if ($found != ""){ + $this->$val= $this->attrs["$found"][0]; } } @@ -162,6 +165,27 @@ class plugin @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "found", "Object check"); } + + /* Prepare saved attributes */ + $this->saved_attributes= $this->attrs; + foreach ($this->saved_attributes as $index => $value){ + if (preg_match('/^[0-9]+$/', $index)){ + unset($this->saved_attributes[$index]); + continue; + } + if (!in_array($index, $this->attributes) && $index != "objectClass"){ + unset($this->saved_attributes[$index]); + continue; + } + if ($this->saved_attributes[$index]["count"] == 1){ + $tmp= $this->saved_attributes[$index][0]; + unset($this->saved_attributes[$index]); + $this->saved_attributes[$index]= $tmp; + continue; + } + + unset($this->saved_attributes["$index"]["count"]); + } } /* Save initial account state */ @@ -291,6 +315,29 @@ class plugin } } + /* Clean up */ + foreach ($this->attrs as $index => $value){ + if (is_array($this->attrs[$index]) && count($this->attrs[$index]) == 0 && !isset($this->saved_attributes[$index])){ + unset ($this->attrs[$index]); + continue; + } + + if (!is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) + && !is_array($this->saved_attributes[$index]) && $value == $this->saved_attributes[$index]){ + unset ($this->attrs[$index]); + continue; + } + + if (is_array($this->attrs[$index]) && is_array($this->saved_attributes[$index]) && + count(array_diff($this->attrs[$index], $this->saved_attributes[$index]))==0 && $index != "objectClass"){ + unset ($this->attrs[$index]); + continue; + } + } +################################# +; echo "--- DEBUG: changes ---" ; +; print_a ($this->attrs) ; +################################# } /* Check formular input */ @@ -661,7 +708,6 @@ class plugin } } - } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/include/functions.inc b/include/functions.inc index 57ded91d4..1fa462740 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1806,6 +1806,22 @@ height:".$height."px; } +function array_key_ics($ikey, $items) +{ + /* Gather keys, make them lowercase */ + $tmp= array(); + foreach ($items as $key => $value){ + $tmp[strtolower($key)]= $key; + } + + if (isset($tmp[strtolower($ikey)])){ + return($tmp[strtolower($ikey)]); + } + + return (""); +} + + function search_config($arr, $name, $return) { if (is_array($arr)){ diff --git a/plugins/admin/groups/class_groupMail.inc b/plugins/admin/groups/class_groupMail.inc index 0ea53a5e1..f759f7435 100644 --- a/plugins/admin/groups/class_groupMail.inc +++ b/plugins/admin/groups/class_groupMail.inc @@ -28,6 +28,7 @@ class mailgroup extends plugin var $mailusers= array(); var $perms= array(); var $imapacl= array('anyone' => 'p', '%members%' => 'lrsp', '' => 'p'); + var $mmethod= ""; /* Helper */ var $indexed_acl= array(); @@ -52,16 +53,17 @@ class mailgroup extends plugin /* Set mailMethod to the one defined in gosa.conf */ if (isset($this->config->current['MAILMETHOD'])){ - $method= $this->config->current['MAILMETHOD']; - if (class_exists("mailMethod$method")){ - $this->method= "mailMethod$method"; - } else { - print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $method)); - } + $this->mmethod= $this->config->current['MAILMETHOD']; + } + + if (class_exists("mailMethod$this->mmethod")){ + $this->method= "mailMethod$this->mmethod"; + } else { + print_red(sprintf(_("There is no mail method '%s' specified in your gosa.conf available."), $this->mmethod)); } /* Load Mailserver string, only in case of kolab ???? */ - if(preg_match("/kolab/i",$this->config->current['MAILMETHOD'])){ + if(preg_match("/kolab/i",$this->mmethod)){ if(isset($this->attrs['gosaMailServer'][0])){ $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; } @@ -153,7 +155,7 @@ class mailgroup extends plugin /* Load permissions */ $tmp = array(); - if(preg_match("/kolab/i",$this->config->current['MAILMETHOD'])){ + if(preg_match("/kolab/i",$this->mmethod)){ $ldap = $this->config->get_ldap_link(); if (isset($this->attrs['acl'])){ for ($i= 0; $i<$this->attrs['acl']['count']; $i++){ @@ -723,7 +725,7 @@ class mailgroup extends plugin /* Save shared folder target */ $this->attrs['gosaSharedFolderTarget']= "share+".$this->uid; - if(preg_match("/kolab/i",$this->config->current['MAILMETHOD'])){ + if(preg_match("/kolab/i",$this->mmethod)){ /* Save acl's */ $this->attrs['acl']= array(); foreach ($this->imapacl as $user => $acl){ @@ -752,7 +754,7 @@ class mailgroup extends plugin } /* Only do IMAP actions if we are not a template */ - if(preg_match("/kolab/i",$this->config->current['MAILMETHOD'])){ + if(preg_match("/kolab/i",$this->mmethod)){ if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){ if(isset($this->attrs['gosaMailServer'][0])){ $this->gosaMailServer = $this->attrs['gosaMailServer'][0]; diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc index 40694034e..db1c304c2 100644 --- a/plugins/gofon/phoneaccount/class_phoneAccount.inc +++ b/plugins/gofon/phoneaccount/class_phoneAccount.inc @@ -1010,7 +1010,6 @@ class phoneAccount extends plugin function remove_from_parent() { - foreach($this->attributes as $key=>$val){ if(in_array($val,array("uid","cn","mail"))){ unset($this->attributes[$key]); @@ -1070,7 +1069,6 @@ class phoneAccount extends plugin $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->uid."';\n"; $SQL[] = "DELETE FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';\n"; - foreach($SQL as $query){ if(!@mysql_query($query,$r_con)){ print_red(_("Stop".mysql_error())); @@ -1079,7 +1077,6 @@ class phoneAccount extends plugin } } - /* unset macro attr, it will cause an error */ $tmp = array_flip($this->attributes); unset($tmp['macro']);