X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_glpiDeviceManagement.inc;h=5095f0de3f13e2e624a07738b0bb1a55d8ce7b68;hb=ccb05fb19fe5af3570c2c57b703a595b1c78bf28;hp=126ac4ad3c0d79a9cb81f26092bb14af184c7cd0;hpb=d84912b9703faf3e479517ddd6e9152a7fb72ae6;p=gosa.git diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc index 126ac4ad3..5095f0de3 100644 --- a/plugins/admin/systems/class_glpiDeviceManagement.inc +++ b/plugins/admin/systems/class_glpiDeviceManagement.inc @@ -2,11 +2,6 @@ class glpiDeviceManagement 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(); @@ -24,6 +19,8 @@ class glpiDeviceManagement extends plugin var $Selected = array(); + var $delete = array(); + function glpiDeviceManagement ($config, $dn= NULL,$used=NULL) { plugin::plugin ($config, $dn); @@ -70,14 +67,16 @@ class glpiDeviceManagement extends plugin $smarty= get_smarty(); $display= ""; - /* Check if we should create a new entry .... */ + /* this var is used to ensure that every post is only performed once */ $only_once = true; + + /* Check Post for some actions */ foreach($_POST as $name => $value){ - /* All Post vars starts with new */ + /* If new_ then we should create an new device */ if((preg_match("/^new_/",$name))&&($only_once)){ - /* do this twice */ + /* don't do this twice */ $only_once = false; /*extract device device_type */ @@ -98,12 +97,44 @@ class glpiDeviceManagement extends plugin } } - /* Open entry for editing if requested */ + /* delete was requested ... show dialog */ if((isset($_GET['act']))&&($_GET['act']=="del_device")){ $id = base64_decode($_GET['id']); $tmp = $this->devices[$id]; - $this->parent->handle->deleteDevice($tmp); - $this->reload(); + + $this->delete = $tmp; + + if(isset($tmp['name'])){ + $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name'])); + }elseif(isset($tmp['designation'])){ + $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation'])); + }else{ + print_red(_("Can't detect object name.")); + } + + return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE))); + } + + /* Delete entry, but check if this device is in currently in use */ + if(isset($_POST['delete_glpi_confirm'])){ + if(count($this->parent->handle->is_deviceUsed($this->delete))){ + + $tmp = $this->parent->handle->is_deviceUsed($this->delete); + + $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 device, it is still in use by these system(s) '%s'"),$names)); + }else{ + $this->parent->handle->deleteDevice($this->delete); + $this->reload(); + } } /* Open entry for editing if requested */ @@ -145,11 +176,12 @@ class glpiDeviceManagement extends plugin */ $divlist = new divlist("glpi devices"); + $divlist->SetPluginMode(); $divlist->SetEntriesPerPage(0); $divlist->SetHeader(array( array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), - array("string" => _("devices")." / "._("Departments"), "attach" => "style=''"), - array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); + array("string" => _("devices"), "attach" => "style=''"), + array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); $edit = "%s"; $editdel = ""._("Edit").""; @@ -172,7 +204,7 @@ class glpiDeviceManagement extends plugin } /* Dawn databse struckture ....*/ - if(empty($user['comment'])) { + if(empty($user['comment']) && isset($user['comments'])) { $user['comment'] = $user['comments']; } @@ -188,43 +220,43 @@ class glpiDeviceManagement extends plugin "  ". "  ". + src='images/mainboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'> ". "  ". + src='images/processor.png' title='"._("New processor")."' alt='"._("P")."' name='new_processor'> ". "  ". + src='images/server.png' title='"._("New case")."' alt='"._("C")."' name='new_case'> ". "  ". + src='images/net_hardware.png' title='"._("New network interface")."' alt='"._("NI")."' name='new_iface'> ". "  ". + src='images/memory.png' title='"._("New ram")."' alt='"._("R")."' name='new_ram'> ". "  ". + src='images/fai_partitionTable.png' title='"._("New hard disk")."' alt='"._("HDD")."' name='new_hdd'> ". "  ". + src='images/drives.png' title='"._("New drive")."' alt='"._("D")."' name='new_drive'> ". "  ". + src='images/hardware.png' title='"._("New controller")."' alt='"._("CS")."' name='new_control'> ". "  ". + src='images/gfx_hardware.png' title='"._("New graphics card")."' alt='"._("GC")."' name='new_gfxcard'> ". "  ". + src='images/snd_hardware.png' title='"._("New sound card")."' alt='"._("SC")."' name='new_sndcard'> ". "  ". + src='images/power.png' title='"._("New power supply")."' alt='"._("PS")."' name='new_power'> ". "  ". + src='images/fai_template.png' title='"._("New misc device")."' alt='"._("OC")."' name='new_pci'> ". ""; + $filter= $_SESSION['glpiDeviceRegex']; $smarty->assign("devicehead", $listhead); $smarty->assign("devices", $divlist->DrawList()); $smarty->assign("search_image", get_template_path('images/search.png')); $smarty->assign("searchu_image", get_template_path('images/search_user.png')); $smarty->assign("tree_image", get_template_path('images/tree.png')); - $smarty->assign("infoimage", get_template_path('images/info.png')); - $smarty->assign("launchimage", get_template_path('images/launch.png')); + $smarty->assign("infoimage", get_template_path('images/info_small.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); $smarty->assign("apply", apply_filter()); $smarty->assign("alphabet", generate_alphabet()); $smarty->assign("device_regex", $filter['device_regex']); - $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE)); return($display); } @@ -296,11 +328,12 @@ class glpiDeviceManagement extends plugin /* This function cehck all created devices if you wan't to create device specific check use >>if($attr['device_type']=="moboard")<< to create a device type depending check - */ + */ function check($attr) { - $message = array(); - + /* Call common method to give check the hook */ + $message= plugin::check(); + if(isset($attr['designation'])){ $str2 = "designation"; }else{ @@ -313,6 +346,9 @@ class glpiDeviceManagement extends plugin /* Avoid same name twice */ $devices = ($this->parent->handle->getDevices()); foreach($devices as $dev){ + + /* Some devices use designation some name for name + */ if(isset($dev['designation'])){ $str = "designation"; }else{ @@ -320,7 +356,7 @@ class glpiDeviceManagement extends plugin } if($dev[$str]==$attr[$str2]){ - + /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */ if(isset($attr['ID'])){ if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){ @@ -335,8 +371,8 @@ class glpiDeviceManagement extends plugin return($message); } - /* This funtions displays the tempalte for all available devices - * This funtion is also used if we create a new device + /* This functions displays the template for all available devices + * This function is also used if we create a new device */ function editDevice($entry) { @@ -344,7 +380,7 @@ class glpiDeviceManagement extends plugin /* Transfer given data to smarty */ foreach($this->EditEntry as $name => $value){ - $smarty->assign($name,$value); + $smarty->assign($name,htmlentities(utf8_decode($value))); } /* Set default select boxes, manufacturers ... */