summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 22f3e06)
raw | patch | inline | side by side (parent: 22f3e06)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 2 Jan 2006 10:25:55 +0000 (10:25 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 2 Jan 2006 10:25:55 +0000 (10:25 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2390 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_glpi.inc | patch | blob | history |
diff --git a/include/class_glpi.inc b/include/class_glpi.inc
index 0684c7c583e7d519e9786769af6d620364bfd893..90d475503a066abedbc7663bed3ae86aea2ec3d2 100644 (file)
--- a/include/class_glpi.inc
+++ b/include/class_glpi.inc
}else{
$qry = "SELECT * FROM glpi_computers WHERE name='".$dn."';";
$res = $this->query($qry);
- print_a($res);
+ if(count($res)==0){
+ return(false);
+ }else{
+ return(true);
+ }
}
}
}
}
- /* System types */
- function removeSystemType_byNAME($name)
+ /* Manufacturer */
+ function getEnterprisesTypes()
{
if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE name='".$name."';");
- if(isset($tmp[0])){
- return($this->query("DELETE FROM glpi_type_computers WHERE name='".$name."';"));
- }else{
- echo "can't remove not existing entry";
- return(false);
+ $ret = array();
+ $tmp = $this->query("SELECT * FROM glpi_enterprises;");
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
}
+ return($ret);
}else{
echo "not connected";
return(false);
}
/* Manufacturer */
- function getEnterprisesTypes()
+ function getEnterprise($id)
{
if($this->is_connected){
$ret = array();
- $tmp = $this->query("SELECT * FROM glpi_enterprises;");
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- return($ret);
+ $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
+ return($tmp);
}else{
echo "not connected";
return(false);
if(!is_array($array)){
echo "updateEnterprisesType: first paraeter must be an array";
}elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
+ $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID='".$id."';");
if(isset($tmp[0])){
$atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
return(false);
}else{
$v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_enterprises SET ".$v." WHERE ID=".$id.";"));
+ return($this->query("UPDATE glpi_enterprises SET ".$v." WHERE ID='".$id."';"));
}
}else{
echo "can't update not existing entry";
}
}
+ function addEnterprisesType($array)
+ {
+ if(!is_array($array)){
+ echo "addUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "addUser: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_enterprises (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+
+
function removeEnterprisesType($id)
{
if($this->is_connected){
}
}
+ /* os */
+ function addOS($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ echo "such an entry already exists";
+ return(false);
+ }else{
+ return($this->query("INSERT INTO glpi_dropdown_os (name) VALUES ('".$name."');"));
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* System types */
+ function removeOS_byID($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
+ if(is_array($tmp[0])){
+ return($this->query("DELETE FROM glpi_dropdown_os WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+
+ /* System types */
+ function updateOS($name,$id)
+ {
+
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("UPDATE glpi_dropdown_os SET name='".$name."' WHERE ID=".$id.";"));
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
/* Technical / Responsible person / glpi users */
function getUsers()
{
if($this->is_connected){
- return($this->query("SELECT * FROM glpi_users"));
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_users"));
+ foreach($tmp as $user){
+ $ret[$user['ID']]=$user['name'];
+ }
+ return($ret);
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ function addUser($array,$dn)
+ {
+ if(!is_array($array)){
+ echo "addUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $array['name']=$dn;
+ $atr = array("name","phone","email");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "addUser: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_users (".$a.") VALUES (".$v.");"));
+ }
+
}else{
echo "not connected";
return(false);
}
+
+ }
+
+ function updateUser($array,$dn)
+ {
+ if(!is_array($array)){
+ echo "updateUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_users WHERE name='".$dn."';");
+ if(isset($tmp[0])){
+
+ $atr = array("name","phone","email");
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "UpdateUser: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("UPDATE glpi_users SET ".$v." WHERE name='".$dn."';"));
+ }
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
}
+
+
/* Gets all pulldown and needed tableinformations */
function getDevices()
{
}
}
- function getComputerInformations($id)
+ function getComputerInformations($name)
{
if($this->is_connected){
+ /*
$ret = $this->query( '
SELECT
c.ID,
left join glpi_users as u on (c.tech_num = u.ID)
WHERE c.Name!="" AND c.ID='.$id.';');
+ */
+ $ret = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
return($ret);
}else{
echo "not connected";
}
}
- function updateComputerInformations($array,$id)
+ function updateComputerInformations($array,$name)
{
if(!is_array($array)){
echo "updateComputerInformations: first paraeter must be an array";
}elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_computers WHERE ID=".$id.";");
+ $tmp = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
if(isset($tmp[0])){
- $atr = array( "Id","name","serial","otherserial","contact","contact_num",
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
"tech_num","comments","date_mod","os","location","domain","network",
"model","type","is_template","tplname","FK_glpi_enterprise","deleted");
$v = "";
return(false);
}else{
$v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_computers SET ".$v." WHERE ID=".$id.";"));
+ return($this->query("UPDATE glpi_computers SET ".$v." WHERE name='".$name."';"));
}
}else{
echo "can't update not existing entry";
if(!is_array($array)){
echo "updateComputerInformations: first paraeter must be an array";
}elseif($this->is_connected){
- $atr = array( "Id","name","serial","otherserial","contact","contact_num",
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
"tech_num","comments","date_mod","os","location","domain","network",
"model","type","is_template","tplname","FK_glpi_enterprise","deleted");
$v = "";
function removeComputerInformations($id)
{
- if($this->is_connected){
+/* if($this->is_connected){
$tmp = $this->query("SELECT * FROM glpi_computers WHERE ID=".$id.";");
if(isset($tmp[0])){
return($this->query("DELETE FROM glpi_computers WHERE ID=".$id.";"));
echo "not connected";
return(false);
}
-
+*/
}
function is_connected()