summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 939b0d5)
raw | patch | inline | side by side (parent: 939b0d5)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 23 Jan 2006 10:32:30 +0000 (10:32 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 23 Jan 2006 10:32:30 +0000 (10:32 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2542 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/include/class_glpi.inc b/include/class_glpi.inc
index 6bfd37bc12552ae85211d3ea878a1fc738cd8e80..5760e984e156d6bd3fbf5d714a20aee4cf0e571d 100644 (file)
--- a/include/class_glpi.inc
+++ b/include/class_glpi.inc
*/
function is_deviceUsed($item)
{
-
$deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
$deviceMappingTableNameID = $this->deviceMappingTableNameID;
if($this->is_connected){
$tablename = $deviceMappingGOsaGlpi[$item['device_type']];
$type = $item['device_type'];
+ $ret = array();
+
if($type=="monitor"){
- $str = "SELECT * FROM glpi_connect_wire WHERE end1=".$item['ID']." AND type=4;";
+ $str = "SELECT c.name FROM glpi_connect_wire as w, glpi_computers as c WHERE w.end1=".$item['ID']." AND w.end2 = c.ID AND w.type=4;";
}else{
- $str = "SELECT * FROM glpi_computer_device WHERE device_type=".$deviceMappingTableNameID[$type]." AND FK_device=".$item['ID'].";";
+ $str = "SELECT c.name FROM glpi_computer_device as d, glpi_computers as c WHERE d.FK_computers=c.ID AND FK_device=".$item['ID']." AND device_type=".$deviceMappingTableNameID[$type]." ;";
}
- return(count($this->query($str)));
+
+ $res = $this->query($str);
+
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+
+ return($ret);//count($this->query($str)));
}else{
echo "not connected";
return(false);
function is_attachmentUsed($id)
{
if($this->is_connected){
- $qry = "SELECT * FROM glpi_doc_device WHERE FK_doc =".$id." LIMIT 1; ";
- return(count($this->query($qry)));
+ $ret = array();
+ $qry = "SELECT t.name FROM glpi_computers as t, glpi_doc_device WHERE t.ID = glpi_doc_device.FK_device AND FK_doc =".$id." LIMIT 3;";
+ $res = $this->query($qry);
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+ return($ret);
}else{
echo "not connected";
return(false);
diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc
index c10adddd88a516a0c513cec7e02a796ac385b344..643503a2fd6c4db528b82673baddbcfb7f20c8a2 100644 (file)
}
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']);
}
diff --git a/plugins/admin/systems/class_glpiAttachmentPool.inc b/plugins/admin/systems/class_glpiAttachmentPool.inc
index 3a8c3d9dede3074df5509ad320863d2ed430a7ff..40a7c3e13bad835e9e00768eb51a9d0bf88046a2 100644 (file)
if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
if($this->parent->handle->is_attachmentUsed($this->delAttach)){
- print_red(_("Can't delete this attachment, it is still in use."));
+ $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
+
+ $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 attachment, it is still in use by these system(s) '%s'"),$names));
+
}else{
$this->parent->handle->deleteAttachment($this->delAttach);
$attach = $this->parent->handle->getAttachments();
diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc
index e3a5497bc2f6a429ea1a62c3d565d22c170303f9..48062f056e62c9f8727c2a218151976026b51655 100644 (file)
/* Delete entry, but check if this device is in currently in use */
if(isset($_POST['delete_glpi_confirm'])){
- if($this->parent->handle->is_deviceUsed($this->delete)){
- print_red(_("Can't delete this device, it is actually in use by some glpi accounts. Remove this relation first."));
+ 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();