diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc
index f235666999e74839ff1b429fcc41e496f19e6031..19541ba4105371b31ea171336175492b09f85c85 100644 (file)
var $Selected = array();
var $Selected = array();
- function glpiDeviceManagement ($config, $dn= NULL)
+ var $delete = array();
+
+ function glpiDeviceManagement ($config, $dn= NULL,$used=NULL)
{
plugin::plugin ($config, $dn);
{
plugin::plugin ($config, $dn);
$_SESSION['glpiDeviceRegex'] = $tmp;
}
$this->ui = get_userinfo();
$_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");
/* Specify which vars are allowed for a sepcific type of device */
$this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
$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['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()
}
function execute()
if((isset($_GET['act']))&&($_GET['act']=="del_device")){
$id = base64_decode($_GET['id']);
$tmp = $this->devices[$id];
if((isset($_GET['act']))&&($_GET['act']=="del_device")){
$id = base64_decode($_GET['id']);
$tmp = $this->devices[$id];
- $this->parent->handle->deleteDevice($tmp);
+
+ $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_a(_("Can't detect object name."));
+ }
+
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+
+ if(isset($_POST['delete_glpi_confirm'])){
+ $this->parent->handle->deleteDevice($this->delete);
$this->reload();
}
$this->reload();
}
foreach($this->devices as $key=>$user){
foreach($this->devices as $key=>$user){
- if(isset($this->Selected[$user['device_type']][$user['designation']])){
+ if(isset($user['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($this->Selected[$user['device_type']][$user[$str]])){
$use = " checked ";
}else{
$use ="";
}
$use = " checked ";
}else{
$use ="";
}
+ /* Dawn databse struckture ....*/
+ if(empty($user['comment'])) {
+ $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;'");
$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=''");
+ $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));
$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));
}
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
}
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image' align='middle'
+ src='images/monitor.png' title='"._("New monitor")."' alt='"._("M")."' name='new_monitor'> ".
" <input class='center' type='image' align='middle'
src='images/keyboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='images/keyboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New ram")."' alt='"._("R")."' name='new_ram'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New ram")."' alt='"._("R")."' name='new_ram'> ".
" <input class='center' type='image' align='middle'
- src='mages/list_back.png' title='"._("New hard disk drive")."' alt='"._("HDD")."' name='new_hdd'> ".
+ src='mages/list_back.png' title='"._("New hard disk")."' alt='"._("HDD")."' name='new_hdd'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
- src='mages/list_back.png' title='"._("New drives")."' alt='"._("D")."' name='new_drive'> ".
+ src='mages/list_back.png' title='"._("New drive")."' alt='"._("D")."' name='new_drive'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
- src='mages/list_back.png' title='"._("New controllers")."' alt='"._("CS")."' name='new_control'> ".
+ src='mages/list_back.png' title='"._("New controller")."' alt='"._("CS")."' name='new_control'> ".
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New graphics card")."' alt='"._("GC")."' name='new_gfxcard'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New graphics card")."' alt='"._("GC")."' name='new_gfxcard'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New power supply")."' alt='"._("PS")."' name='new_power'> ".
" <input class='center' type='image' align='middle'
" <input class='center' type='image' align='middle'
src='mages/list_back.png' title='"._("New power supply")."' alt='"._("PS")."' name='new_power'> ".
" <input class='center' type='image' align='middle'
- src='mages/list_back.png' title='"._("New other peripherals")."' alt='"._("OC")."' name='new_pci'> ".
+ src='mages/list_back.png' title='"._("New misc device")."' alt='"._("OC")."' name='new_pci'> ".
"</div>";
"</div>";
+
$filter= $_SESSION['glpiDeviceRegex'];
$smarty->assign("devicehead", $listhead);
$smarty->assign("devices", $divlist->DrawList());
$filter= $_SESSION['glpiDeviceRegex'];
$smarty->assign("devicehead", $listhead);
$smarty->assign("devices", $divlist->DrawList());
$smarty->assign("alphabet", generate_alphabet());
$smarty->assign("device_regex", $filter['device_regex']);
$smarty->assign("alphabet", generate_alphabet());
$smarty->assign("device_regex", $filter['device_regex']);
-
$display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
return($display);
}
$display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
return($display);
}
function save_object()
{
foreach($_POST as $name => $value){
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(preg_match("/wasOnPage_/",$name)){
$dN = base64_decode($value);
$device = $this->devices[$dN];
$type = $device['device_type'];
+ if(isset($device['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
if(isset($_POST['useDevice_'.$value])){
if(isset($_POST['useDevice_'.$value])){
- $this->Selected[$type][$device['designation']] = $device;
+ $this->Selected[$type][$device[$str]] = $device;
}else{
}else{
- if(isset($this->Selected[$type][$device['designation']])){
- unset($this->Selected[$type][$device['designation']]);
+ if(isset($this->Selected[$type][$device[$str]])){
+ unset($this->Selected[$type][$device[$str]]);
}
}
}
}
}
}
function check($attr)
{
$message = array();
function check($attr)
{
$message = array();
- if(empty($attr['designation'])){
+
+ if(isset($attr['designation'])){
+ $str2 = "designation";
+ }else{
+ $str2 = "name";
+ }
+ if(empty($attr[$str2])){
$message[]=(_("You have to specify a valid name for this device."));
}
/* Avoid same name twice */
$devices = ($this->parent->handle->getDevices());
foreach($devices as $dev){
$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']){
+ if(isset($dev['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ 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'])){
/* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
if(isset($attr['ID'])){
return($message);
}
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)
{
*/
function editDevice($entry)
{
/* Transfer given data to smarty */
foreach($this->EditEntry as $name => $value){
/* Transfer given data to smarty */
foreach($this->EditEntry as $name => $value){
- $smarty->assign($name,$value);
+ $smarty->assign($name,htmlentities($value));
}
/* Set default select boxes, manufacturers ... */
$smarty->assign("device_type",$entry['device_type']);
$none = array(0 => _("none"));
}
/* Set default select boxes, manufacturers ... */
$smarty->assign("device_type",$entry['device_type']);
$none = array(0 => _("none"));
- $manufacturer = array_merge($none,$this->parent->handle->getEnterprisesTypes());
+ $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
$ramtypes = $this->parent->handle->getRAMTypes();
$ramtypes = $this->parent->handle->getRAMTypes();
$smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
$smarty->assign("FK_glpi_enterprises", $manufacturer);
$smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
$smarty->assign("FK_glpi_enterprises", $manufacturer);
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+
$smarty->assign("formats",array("Large","Medium","Micro"));
$smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));
$smarty->assign("formats",array("Large","Medium","Micro"));
$smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));