X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_glpiManufacturer.inc;h=e0a9cfa9a2e3d584908dbfc00609ed0ffdb0a392;hb=5f1f63cbff1a76de561e6e556342179ace8ca24e;hp=0c950d366a2837c35bbfc09f4249a9aa35564d9a;hpb=042053fff5733f6830f8f623cd1d126c71eea1f0;p=gosa.git diff --git a/plugins/admin/systems/class_glpiManufacturer.inc b/plugins/admin/systems/class_glpiManufacturer.inc index 0c950d366..e0a9cfa9a 100644 --- a/plugins/admin/systems/class_glpiManufacturer.inc +++ b/plugins/admin/systems/class_glpiManufacturer.inc @@ -2,11 +2,6 @@ class glpiManufacturer extends plugin { - /* CLI vars */ - var $cli_summary= "Manage server basic objects"; - var $cli_description= "Some longer text\nfor help"; - var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); - /* attribute list for save action */ var $ignore_account= TRUE; var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email"); @@ -28,9 +23,9 @@ class glpiManufacturer extends plugin var $email =""; var $ID =-1; - function glpiManufacturer($config, $dn= NULL) + function glpiManufacturer($config, $dn= NULL, $parent= NULL) { - plugin::plugin ($config, $dn); + plugin::plugin ($config, $dn, $parent); $this->ui = get_userinfo(); } @@ -42,7 +37,23 @@ class glpiManufacturer extends plugin /* Remove enterprise from db */ if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){ - $this->parent->handle->removeEnterprise($_POST['manufacturer']); + + $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']); + if(count($tmp)){ + + $names = ""; + foreach($tmp as $name){ + $names .= ", ".$name; + } + $names = preg_replace("/^, /","",$names); + $names = trim($names); + if(count($tmp) == 3){ + $names .= " ..."; + } + print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names)); + }else{ + $this->parent->handle->removeEnterprise($_POST['manufacturer']); + } } /* Add new Manufactuer : Open dialog with empty fields */ @@ -89,6 +100,21 @@ class glpiManufacturer extends plugin $allok = false; } + $attr = $this->parent->handle->getEnterprises(); + + if($this->ID == -1 ){ + if(in_array($tmp['name'],$attr)){ + $allok = false; + print_red(_("Specified name is already in use, please choose another one.")); + } + }else{ + unset($attr[$this->ID]); + if(in_array($tmp['name'],$attr)){ + $allok = false; + print_red(_("Specified name is already in use, please choose another one.")); + } + } + /* all checks are ok , so save changes */ if($allok){ if($this->Edit_Add == "add"){ @@ -128,7 +154,7 @@ class glpiManufacturer extends plugin { foreach($this->attributes as $attr){ if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; + $this->$attr = stripslashes($_POST[$attr]); } } }