X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_glpiDeviceManagement.inc;h=e8fe8b56e8b073ad7154594740ee08313baf12dd;hb=49866d5f3a99b5675b11310ffba4c2e50d967eb7;hp=195bea382e3d3d52f1134c40ff8ce21b218c48d5;hpb=3644520502707cc1a35a915bfa358105e86c4818;p=gosa.git
diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc
index 195bea382..e8fe8b56e 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();
@@ -22,8 +17,11 @@ class glpiDeviceManagement extends plugin
var $DeviceAttrs = array();
var $AllowedDevices = array();
+ var $Selected = array();
+
+ var $delete = array();
- function glpiDeviceManagement ($config, $dn= NULL)
+ function glpiDeviceManagement ($config, $dn= NULL,$used=NULL)
{
plugin::plugin ($config, $dn);
@@ -32,6 +30,10 @@ class glpiDeviceManagement extends plugin
$_SESSION['glpiDeviceRegex'] = $tmp;
}
$this->ui = get_userinfo();
+
+ if(isset($used)){
+ $this->Selected = $used;
+ }
/* Specify which vars are allowed for a sepcific type of device */
$this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
@@ -46,8 +48,11 @@ class glpiDeviceManagement extends plugin
$this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default");
$this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx");
$this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size",
+ "flags_micro","flags_speaker","flags_subd","flags_bnc",
+ "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname");
- $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci");
+ $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor");
}
function execute()
@@ -62,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 */
@@ -90,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 */
@@ -140,18 +179,36 @@ class glpiDeviceManagement extends plugin
$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 = "";
$editdel.= "
";
- $useDevice = "";
+ $useDevice = "";
foreach($this->devices as $key=>$user){
- $field1 = array("string" => sprintf($useDevice,base64_encode($key),base64_encode($key)), "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($edit,base64_encode($key),$user['designation']." [".$user['comment']."]"), "attach" => "style=''");
+
+ if(isset($user['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($this->Selected[$user['device_type']][$user[$str]])){
+ $use = " checked ";
+ }else{
+ $use ="";
+ }
+
+ /* Dawn databse struckture ....*/
+ if(empty($user['comment']) && isset($user['comments'])) {
+ $user['comment'] = $user['comments'];
+ }
+
+ $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''");
$field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)),
"attach" => "style='width:60px;border-right:0px;text-align:right;'");
$divlist->AddEntry(array($field1,$field2,$field3));
@@ -160,43 +217,45 @@ class glpiDeviceManagement extends plugin
$listhead = "