index bd30dfd7b02e47a170cc1292ccdcddb4b97e69d2..5f2a567b741e14943f12e995f8806ad7fdf11580 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
*/
var $attrs= array();
+ /* Keep set of conflicting plugins */
+ var $conflicts= array();
+
/* Save unit tags */
var $gosaUnitTag= "";
var $new= TRUE;
var $saved_attributes= array();
+ /* This can be set to render the tabulators in another stylesheet */
+ var $pl_notify= FALSE;
+
/*! \brief plugin constructor
If 'dn' is set, the node loads the given 'dn' from LDAP
\param dn Distinguished name to initialize plugin from
\sa plugin()
*/
- function plugin ($config, $dn= NULL)
+ function plugin ($config, $dn= NULL, $parent= NULL)
{
/* Configuration is fine, allways */
$this->config= $config;
if ($dn != NULL){
/* Load data to 'attrs' and save 'dn' */
- $ldap->cat ($dn);
- $this->attrs= $ldap->fetch();
+ if ($parent != NULL){
+ $this->attrs= $parent->attrs;
+ } else {
+ $ldap->cat ($dn);
+ $this->attrs= $ldap->fetch();
+ }
/* Copy needed attributes */
foreach ($this->attributes as $val){
foreach ($this->attributes as $val){
if (chkacl ($this->acl, "$val") == "" && isset ($_POST["$val"])){
/* Check for modifications */
- if (get_magic_quotes_gpc()) {
+ if ((get_magic_quotes_gpc()) && !is_array($_POST["$val"])) {
$data= stripcslashes($_POST["$val"]);
} else {
$data= $this->$val = $_POST["$val"];
}
}
}
+
+ /* Update saved attributes and ensure that next cleanups will be successful too */
+ foreach($this->attrs as $name => $value){
+ $this->saved_attributes[$name] = $value;
+ }
}
/* Check formular input */
/* Show header message for tab dialogs */
function show_header($button_text, $text, $disabled= FALSE)
{
+ $state = "disabled";
+ if($this->is_account && $this->acl == "#all#"){
+ $state= "";
+ }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+ $state= "";
+ }
+
if ($disabled == TRUE){
$state= "disabled";
- } else {
- $state= "";
}
+
$display= "<table summary=\"\" width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
- $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".
- chkacl($this->acl, "all")." ".$state.
- "><p class=\"seperator\"> </p></td></tr></table>";
+ $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".$state.">".
+ "<p class=\"seperator\"> </p></td></tr></table>";
return($display);
}
{
/* Rename dn in possible object groups */
$ldap= $this->config->get_ldap_link();
- $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.$src_dn.'))',
+ $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($src_dn).'))',
array('cn'));
while ($attrs= $ldap->fetch()){
$og= new ogroup($this->config, $ldap->getDN());
$ldap->cat($dst_dn);
$attrs= $ldap->fetch();
if (count($attrs)){
- trigger_error("Trying to overwrite $dst_dn, which already exists.",
+ trigger_error("Trying to overwrite ".@LDAP::fix($dst_dn).", which already exists.",
E_USER_WARNING);
return (FALSE);
}
$ldap->cat($src_dn);
$attrs= $ldap->fetch();
if (!count($attrs)){
- trigger_error("Trying to move $src_dn, which does not seem to exist.",
+ trigger_error("Trying to move ".@LDAP::fix($src_dn).", which does not seem to exist.",
E_USER_WARNING);
return (FALSE);
}
$r=ldap_bind($ds,$this->config->current['ADMIN'], $this->config->current['PASSWORD']);
error_reporting (0);
- $sr=ldap_read($ds, $ldap->fix($src_dn), "objectClass=*");
+ $sr=ldap_read($ds, @LDAP::fix($src_dn), "objectClass=*");
/* Fill data from LDAP */
$new= array();
/* Adapt naming attribute */
$dst_name= preg_replace("/^([^=]+)=.*$/", "\\1", $dst_dn);
$dst_val = preg_replace("/^[^=]+=([^,+]+).*,.*$/", "\\1", $dst_dn);
- $new[$dst_name]= $dst_val;
+ $new[$dst_name]= @LDAP::fix($dst_val);
/* Check if this is a department.
* If it is a dep. && there is a , override in his ou
* change \2C to , again, else this entry can't be saved ...
*/
- if((isset($new['ou'])) &&( preg_match("/\\\\2C/",$new['ou']))){
- $new['ou'] = preg_replace("/\\\\2C/",",",$new['ou']);
+ if((isset($new['ou'])) &&( preg_match("/\\,/",$new['ou']))){
+ $new['ou'] = preg_replace("/\\\\,/",",",$new['ou']);
}
/* Save copy */
}
$todo[] = "is_account";
foreach($todo as $var){
- $this->$var = $source->$var;
+ if (isset($source->$var)){
+ $this->$var= $source->$var;
+ }
}
}
$attrs= $ldap->fetch();
if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
if ($show) {
- echo sprintf(_("Processing: Object '%s' is already tagged"), $dn)."<br>";
+ echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
flush();
}
return;
}
if (count($attrs)){
if ($show){
- echo sprintf(_("Processing: Adding tag (%s) to object '%s'"), $tag,$dn)."<br>";
+ echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
flush();
}
- $nattrs= array("gosaUnitTag" => $this->gosaUnitTag);
+ $nattrs= array("gosaUnitTag" => $tag);
$nattrs['objectClass']= array();
for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
$oc= $attrs['objectClass'][$i];
$nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
$ldap->cd($dn);
$ldap->modify($nattrs);
+ show_ldap_error($ldap->get_error(), _("Handle object tagging failed"));
} else {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
}
}
if (count($attrs)){
if ($show){
- echo sprintf(_("Processing: Removing tag from object '%s'"), $dn)."<br>";
+ echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
flush();
}
$nattrs= array("gosaUnitTag" => array());
}
+
+ /* Add possibility to stop remove process */
+ function allow_remove()
+ {
+ $reason= "";
+ return $reason;
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>