diff --git a/gosa-plugins/systems/admin/systems/class_componentGeneric.inc b/gosa-plugins/systems/admin/systems/class_componentGeneric.inc
index 583625188ab6e8c2063b5ba4f5025d699feb759d..b3ff77e38c4df28568bca1ea8d2d5cb9496def74 100644 (file)
<?php
+/*
+ * 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
+ */
class componentGeneric extends plugin
{
- /* CLI vars */
- var $cli_summary= "Manage component base objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* Generic terminal attributes */
var $interfaces= array();
var $ignore_account= TRUE;
var $cn= "";
var $description= "";
var $orig_dn= "";
+ var $orig_cn= "";
+ var $orig_base= "";
/* attribute list for save action */
var $attributes= array("cn", "description");
$this->base= dn2base($ui->dn);
$this->cn= "";
} else {
- $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+ $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("componentRDN"), '/')."/i", "", $this->dn);
}
$this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true);
/* Save dn for later references */
$this->orig_dn= $this->dn;
+
+ $this->orig_base = $this->base;
+ $this->orig_cn = $this->cn;
}
/* Do we represent a valid phone? */
if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=middle> <b>".
- _("This 'dn' has no network features.")."</b>";
+ $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
+ msgPool::noValidExtension(_("component"))."</b>";
return($display);
}
new log("remove","component/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of system component/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
+
$this->handle_post_events(array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
/* Delete references to object groups */
$message= plugin::check();
$message= array_merge($message,$this->netConfigDNS->check());
- $this->dn= "cn=".$this->cn.",".get_ou('componentou').$this->base;
+ $this->dn= "cn=".$this->cn.",".get_ou('componentRDN').$this->base;
if ($this->cn == "" ){
- $message[]= _("The required field 'Component name' is not set.");
+ $message[]= msgPool::required(_("Component name"));
}
/* Check if given name is a valid host/dns name */
if(!tests::is_dns_name($this->cn)){
- $message[] = _("Please specify a valid name for this object.");
+ $message[]= msgPool::invalid(_("Component name"), $this->cn, "/[a-z0-9\.\-]/i");
}
/* To check for valid ip*/
if($this->netConfigDNS->ipHostNumber == ""){
- $message[]= _("The required field IP address is empty.");
+ $message[]= msgPool::required(_("IP address"));
} else {
if (!tests::is_ip($this->netConfigDNS->ipHostNumber)){
- $message[]= _("The field IP address contains an invalid address.");
+ $message[]= msgPool::invalid(_("IP address"), "", "", "192.168.1.2");
}
}
if(preg_match("/cn=dhcp,/",$attrs['dn'])){
continue;
}
- if ($attrs['dn'] != $this->orig_dn){
- $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
+ if ($attrs['dn'] != $this->orig_dn && preg_match("/".preg_quote(get_ou("componentRDN"), '/')."/i",$attrs['dn'])){
+ $message[]= msgPool::duplicated(_("Component name"));
break;
}
}
}
}
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return ($message);
}
$this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
} else {
- if ($this->orig_dn != $this->dn){
- $this->move($this->orig_dn, $this->dn);
- }
-
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save();
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system component/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+ }
}
/* Return plugin informations for acl handling */
"plProvidedAcls"=> array(
"cn" => _("Name"),
"base" => _("Base"),
- "description" => _("Description"))
+ "description" => _("Description"),
+ "userPassword" => _("Root password"))
));
}
$this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
}
}
+
+
+ function is_modal_dialog()
+ {
+ return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: