From 939b0d5273f458c01d25191c68b1addc5b182aae Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 23 Jan 2006 10:04:47 +0000 Subject: [PATCH] Added check for os removement git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2541 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_glpi.inc | 17 +++++++++++++++++ plugins/admin/systems/class_glpiAccount.inc | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/class_glpi.inc b/include/class_glpi.inc index 5063a0007..6bfd37bc1 100644 --- a/include/class_glpi.inc +++ b/include/class_glpi.inc @@ -339,6 +339,23 @@ class glpiDB{ } } + /* Operating system is used ? */ + function is_osUsed($ID){ + if($this->is_connected){ + $ret = array(); + $qry="SELECT name,type FROM glpi_computers WHERE os=".$ID." LIMIT 3;"; + $res = $this->query($qry); + foreach($res as $val){ + $ret[$val['name']] = $val['name']; + } + return($ret); + }else{ + echo "not connected"; + return(false); + } + } + + /* Operating systems Add a new operating system to the dropdown menus */ diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc index f0340a059..c10adddd8 100644 --- a/plugins/admin/systems/class_glpiAccount.inc +++ b/plugins/admin/systems/class_glpiAccount.inc @@ -329,7 +329,25 @@ class glpiAccount extends plugin /* Delete selected os from list and db */ if((isset($_POST['del_os']))&&(!empty($_POST['select_os']))){ - $this->handle->removeOS_byID($_POST['select_os']); + $tmp = $this->handle->is_osUsed($_POST['select_os']); + + if(count($tmp)){ + + $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 operating system, it is still in use by these system(s) '%s'"),$names)); + + + }else{ + $this->handle->removeOS_byID($_POST['select_os']); + } } /* Rename selected os to given string -- 2.30.2