From: hickert Date: Tue, 3 Jan 2006 14:07:01 +0000 (+0000) Subject: Some modifications X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c00c5a7e816808583bb16c9f223dd54bc2178eeb;p=gosa.git Some modifications git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2396 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc index 117aa3792..a24c3382a 100644 --- a/plugins/admin/systems/class_glpiAccount.inc +++ b/plugins/admin/systems/class_glpiAccount.inc @@ -111,6 +111,21 @@ class glpiAccount extends plugin $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn); } + /* We have selected some devices and pressed use button */ + if(isset($_POST['SelectDeviceSave'])){ + $this->cur_dialog->save_object(); + print_a($this->cur_dialog->getSelected()); + $this->cur_dialog = false; + $this->dialog = false; + $this->edit_type=false; + } + + /* Aborted Device selction */ + if(isset($_POST['SelectDeviceCancel'])){ + $this->dialog = false; + $this->cur_dialog = false; + $this->edit_type=false; + } /* System type management */ diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc index 195bea382..f23566699 100644 --- a/plugins/admin/systems/class_glpiDeviceManagement.inc +++ b/plugins/admin/systems/class_glpiDeviceManagement.inc @@ -22,6 +22,7 @@ class glpiDeviceManagement extends plugin var $DeviceAttrs = array(); var $AllowedDevices = array(); + var $Selected = array(); function glpiDeviceManagement ($config, $dn= NULL) { @@ -147,10 +148,17 @@ class glpiDeviceManagement extends plugin $editdel = ""._("Edit").""; $editdel.= ""._("Delete").""; - $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;'"); + + if(isset($this->Selected[$user['device_type']][$user['designation']])){ + $use = " checked "; + }else{ + $use =""; + } + + $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['designation']." [".$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;'"); @@ -226,6 +234,24 @@ class glpiDeviceManagement extends plugin */ function save_object() { + foreach($_POST as $name => $value){ + if(preg_match("/wasOnPage_/",$name)){ + $dN = base64_decode($value); + + $device = $this->devices[$dN]; + $type = $device['device_type']; + + + if(isset($_POST['useDevice_'.$value])){ + $this->Selected[$type][$device['designation']] = $device; + }else{ + if(isset($this->Selected[$type][$device['designation']])){ + unset($this->Selected[$type][$device['designation']]); + } + } + } + } + if(is_array($this->EditEntry)){ foreach($this->EditEntry as $name => $value){ if(isset($_POST[$name])){ @@ -236,6 +262,12 @@ class glpiDeviceManagement extends plugin } } + /* returns the selected devices */ + function getSelected() + { + return($this->Selected); + } + /* 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 */ @@ -245,6 +277,23 @@ class glpiDeviceManagement extends plugin if(empty($attr['designation'])){ $message[]=(_("You have to specify a valid name for this device.")); } + + /* Avoid same name twice */ + $devices = ($this->parent->handle->getDevices()); + foreach($devices as $dev){ + if($dev['designation']==$attr['designation']){ + + /* 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']))){ + $message[] = _("This device name is already in use."); + } + }else{ + $message[] = _("This device name is already in use."); + } + } + } + return($message); } diff --git a/plugins/admin/systems/glpiDeviceManagement.tpl b/plugins/admin/systems/glpiDeviceManagement.tpl index 9c64ae60a..03f2d562e 100644 --- a/plugins/admin/systems/glpiDeviceManagement.tpl +++ b/plugins/admin/systems/glpiDeviceManagement.tpl @@ -49,5 +49,6 @@

 

- + +