index 3527494d88e01990e729d981e3ed15fb021018b2..2e10d7215e84e4a0291045348bb438b59a0bbc38 100644 (file)
<?php
/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*! \brief The plugin base class
/* Save unit tags */
var $gosaUnitTag= "";
+ var $skipTagging= FALSE;
/*!
\brief Used standard values
$this->acl_base= $dn;
/* Get LDAP descriptor */
- $ldap= $this->config->get_ldap_link();
if ($dn !== NULL){
/* Load data to 'attrs' and save 'dn' */
if ($parent !== NULL){
$this->attrs= $parent->attrs;
} else {
+ $ldap= $this->config->get_ldap_link();
$ldap->cat ($dn);
$this->attrs= $ldap->fetch();
}
unset($this->saved_attributes["$index"]["count"]);
}
+ if(isset($this->attrs['gosaUnitTag'])){
+ $this->saved_attributes['gosaUnitTag'] = $this->attrs['gosaUnitTag'][0];
+ }
}
/* Save initial account state */
}
/* Handle tagging */
- $this->tag_attrs(&$this->attrs);
+ $this->tag_attrs($this->attrs);
}
function cleanup()
{
foreach ($this->attrs as $index => $value){
-
+
/* Convert arrays with one element to non arrays, if the saved
attributes are no array, too */
if (is_array($this->attrs[$index]) &&
if ($command != ""){
if (!check_command($command)){
- $message[]= sprintf(_("Command '%s', specified as CHECK hook for plugin '%s' doesn't seem to exist."), $command,
- get_class($this));
+ $message[]= msgPool::cmdnotfound("CHECK", get_class($this));
} else {
/* Generate "ldif" for check hook */
$current_csn = getEntryCSN($this->dn);
if($current_csn != $this->entryCSN && !empty($this->entryCSN) && !empty($current_csn)){
$this->entryCSN = $current_csn;
- $message[] = _("The object has changed since opened in GOsa. Please ensure that nobody has done serious changes that may get lost if you save this entry.");
+ $message[] = _("The object has changed since opened in GOsa. All changes that may be done by others get lost if you save this entry!");
}
}
return ($message);
/* Additional attributes */
foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name/", $value, $command);
+ $command= preg_replace("/%$name( |$)/", "$value ", $command);
}
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr/", $this->$attr, $command);
+ $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
}
}
- $command= preg_replace("/%dn/", $this->dn, $command);
+ $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
if (check_command($command)){
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
exec($command);
} else {
- $message= sprintf(_("Command '%s', specified as POSTCREATE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
+ $message[]= msgPool::cmdnotfound("POSTCREATE", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
/* Additional attributes */
foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name/", $value, $command);
+ $command= preg_replace("/%$name( |$)/", "$value ", $command);
}
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr/", $this->$attr, $command);
+ $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
}
}
- $command= preg_replace("/%dn/", $this->dn, $command);
+ $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
if (check_command($command)){
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
exec($command);
} else {
- $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, get_class($this));
+ $message[]= msgPool::cmdnotfound("POSTMODIFY", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
/* Additional attributes */
foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name/", $value, $command);
+ $command= preg_replace("/%$name( |$)/", "$value ", $command);
}
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr/", $this->$attr, $command);
+ $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
}
}
- $command= preg_replace("/%dn/", $this->dn, $command);
-
- /* Additional attributes */
- foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name/", $value, $command);
- }
+ $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
if (check_command($command)){
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
exec($command);
} else {
- $message= sprintf(_("Command '%s', specified as POSTREMOVE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
+ $message[]= msgPool::cmdnotfound("POSTREMOVE", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
}
}
- function tag_attrs($at, $dn= "", $tag= "", $show= false)
+ function tag_attrs(&$at, $dn= "", $tag= "", $show= false)
{
+ /* Skip tagging?
+ If this is called from departmentGeneric, we have to skip this
+ tagging procedure.
+ */
+ if($this->skipTagging){
+ return;
+ }
+
/* No dn? Self-operation... */
if ($dn == ""){
$dn= $this->dn;
}
}
}
-
+
/* Remove tags that may already be here... */
- remove_objectClass("gosaAdministrativeUnitTag", &$at);
+ remove_objectClass("gosaAdministrativeUnitTag", $at);
if (isset($at['gosaUnitTag'])){
unset($at['gosaUnitTag']);
}
/* Set tag? */
if ($tag != ""){
- add_objectClass("gosaAdministrativeUnitTag", &$at);
+ add_objectClass("gosaAdministrativeUnitTag", $at);
$at['gosaUnitTag']= $tag;
}
+
+ /* Initially this object was tagged.
+ - But now, it is no longer inside a tagged department.
+ So force the remove of the tag.
+ (objectClass was already removed obove)
+ */
+ if($tag == "" && $this->gosaUnitTag){
+ $at['gosaUnitTag'] = array();
+ }
}