diff --git a/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc b/gosa-plugins/goto/admin/devices/class_deviceGeneric.inc
index 5a4de8ad20d434fc8f7629f29a4971147092fe4e..b4a8ebe5a6e794693c5c6f43922722ea244d8573 100644 (file)
public $base = "";
public $types;
public $type;
+ public $baseSelector;
public $attributes = array("cn","description","devID","serial","vendor", "type");
public $objectclasses = array("top","gotoDevice");
$this->base= dn2base($ui->dn);
}
} else {
- $this->base =preg_replace ("/^[^,]+,".get_ou('deviceou')."/","",$this->dn);
+ $this->base =preg_replace ("/^[^,]+,".preg_quote(get_ou('deviceRDN'), '/')."/i","",$this->dn);
}
$this->orig_base = $this->base;
$this->orig_dn = $this->dn;
+
+ /* Instanciate base selector */
+ $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
+ $this->baseSelector->setSubmitButton(false);
+ $this->baseSelector->setHeight(300);
+ $this->baseSelector->update(true);
}
public function execute()
{
$smarty = get_smarty();
- $smarty->assign("base",$this->base);
- $smarty->assign("bases",$this->get_allowed_bases());
+ $smarty->assign("usePrototype", "true");
+ $smarty->assign("base", $this->baseSelector->render());
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
}
{
$message = plugin::check();
- if(empty($this->cn)||(preg_match("/[^a-z0-9]/i",$this->cn))){
+ if($this->cn == "" ||(preg_match("/[^a-z0-9]/i",$this->cn))){
$message[]= msgPool::invalid(_("Name"),$this->cn,"/^[a-z0-9]*$/i");
}
if(preg_match("/[^a-z0-9!\"?.,;:-_\(\) ]/i",$this->description)){
/* Skip serial check if vendor and product id are given */
if(preg_match("/^\s+$/i",$this->devID)){
$message[]= msgPool::invalid(_("iSerial"),"","01234");
+ }elseif(empty($this->devID) && $this->devID!="0"){
+ $message[]= msgPool::required(_("iSerial"));
}
if(empty($this->serial) || !$this->is_2byteHex($this->serial)){
- $message[]= msgPool::invalid(_("Serial"),"","","0x1234");
+ $message[]= msgPool::invalid(_("Product-ID"),"","","0x1234");
}
if(empty($this->vendor) || !$this->is_2byteHex($this->vendor)){
- $message[]= msgPool::invalid(_("Vendor ID"),"","","0x1234");
+ $message[]= msgPool::invalid(_("Vendor-ID"),"","","0x1234");
}
/* Check if entry already exists */
public function save_object()
{
+ /* Refresh base */
+ if ($this->acl_is_moveable($this->base)){
+ if (!$this->baseSelector->update()) {
+ msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
+ }
+ if ($this->base != $this->baseSelector->getBase()) {
+ $this->base= $this->baseSelector->getBase();
+ $this->is_modified= TRUE;
+ }
+ }
+
if(isset($_POST['deviceGeneric_posted'])){
plugin::save_object();
-
- if(isset($_POST['base'])){
- $tmp = $this->get_allowed_bases();
- if(isset($tmp[get_post("base")])){
- $this->base = get_post("base");
- }
- }
}
}
{
plugin::save();
- $this->attrs = array();
- $this->attrs['cn'] = $this->cn;
+ /* Unset non ldap attributes
+ */
+ foreach(array("devID","serial","vendor", "type", "description") as $name){
+ if(isset($this->attrs[$name])){
+ unset($this->attrs[$name]);
+ }
+ }
+
$this->attrs['gotoHotplugDevice'] = "";
foreach(array("description","devID","serial","vendor", "type") as $post){
$this->attrs['gotoHotplugDevice'] .= $this->$post."|";
/* check if given str in like this 0xffff*/
function is_2byteHex($str)
{
- return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9][a-f0-9][a-f0-9][a-f0-9]/i",$str);
+ return !strlen($str) || preg_match("/^(0x|x|)[a-f0-9]{4}$/i",$str);
}
"cn" => _("Name"),
"base" => _("Base"),
"description" => _("Description"),
- "type" => _("Tpye"),
+ "type" => _("Type"),
"serial" => _("Serial"),
"vendor" => _("Vendor"),
- "devID" => _("Devive ID"))
+ "devID" => _("Device ID"))
));
}