summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3644520)
raw | patch | inline | side by side (parent: 3644520)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Jan 2006 14:07:01 +0000 (14:07 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Jan 2006 14:07:01 +0000 (14:07 +0000) |
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 117aa379252699a08db0270f4e689ce3deb0e490..a24c3382af4e34bb89133b346fb79e2532574d01 100644 (file)
$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 195bea382e3d3d52f1134c40ff8ce21b218c48d5..f235666999e74839ff1b429fcc41e496f19e6031 100644 (file)
var $DeviceAttrs = array();
var $AllowedDevices = array();
+ var $Selected = array();
function glpiDeviceManagement ($config, $dn= NULL)
{
$editdel = "<a href='?plug=".$_GET['plug']."&act=edit_device&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
$editdel.= "<a href='?plug=".$_GET['plug']."&act=del_device&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
- $useDevice = "<input type='checkbox' value='%s' name='useDevice_%s' >";
+ $useDevice = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useDevice_%s' %USE%>";
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;'");
*/
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])){
}
}
+ /* 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
*/
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 9c64ae60a0a3e4a5a243b41b151821eb8ba2ee82..03f2d562e36c6166e0101c0b25bfe9acae269392 100644 (file)
<input type="hidden" name="ignore">
<p class="seperator"> </p>
<div align="right">
- <input type="submit" name="SelectUserCancel" value="{t}Cancel{/t}">
+ <input type="submit" name="SelectDeviceSave" value="{t}Use{/t}">
+ <input type="submit" name="SelectDeviceCancel" value="{t}Cancel{/t}">
</div>