ryxeo-glpi-git / plugins / manageentity / inc / plugin_manageentity.functions_db.php @ 57ea0d38
Historique | Voir | Annoter | Télécharger (4,54 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
----------------------------------------------------------------------
|
4 |
GLPI - Gestionnaire Libre de Parc Informatique
|
5 |
Copyright (C) 2003-2008 by the INDEPNET Development Team.
|
6 |
|
7 |
http://indepnet.net/ http://glpi-project.org/
|
8 |
----------------------------------------------------------------------
|
9 |
|
10 |
LICENSE
|
11 |
|
12 |
This file is part of GLPI.
|
13 |
|
14 |
GLPI is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License as published by
|
16 |
the Free Software Foundation; either version 2 of the License, or
|
17 |
(at your option) any later version.
|
18 |
|
19 |
GLPI is distributed in the hope that it will be useful,
|
20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
GNU General Public License for more details.
|
23 |
|
24 |
You should have received a copy of the GNU General Public License
|
25 |
along with GLPI; if not, write to the Free Software
|
26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
27 |
------------------------------------------------------------------------
|
28 |
*/
|
29 |
|
30 |
// ----------------------------------------------------------------------
|
31 |
// Original Author of file: GRISARD Jean Marc & CAILLAUD Xavier
|
32 |
// Purpose of file:
|
33 |
// ----------------------------------------------------------------------
|
34 |
|
35 |
if (!defined('GLPI_ROOT')){ |
36 |
die("Sorry. You can't access directly to this file"); |
37 |
} |
38 |
|
39 |
function plugin_manageentity_checkIfPreferenceExists($user_id) |
40 |
{ |
41 |
global $DB; |
42 |
$result = $DB->query("SELECT ID FROM glpi_plugin_manageentity_preference WHERE user_id=".$user_id); |
43 |
if ($DB->numrows($result) > 0) |
44 |
return $DB->result($result,0,"ID"); |
45 |
else
|
46 |
return 0; |
47 |
} |
48 |
|
49 |
function plugin_manageentity_addDefaultPreference($user_id) |
50 |
{ |
51 |
$input["user_id"]=$user_id; |
52 |
$input["show"]=2; |
53 |
|
54 |
$pref = new plugin_manageentity_preference; |
55 |
return $pref->add($input); |
56 |
} |
57 |
|
58 |
function plugin_manageentity_checkPreferenceValue($user_id) |
59 |
{ |
60 |
global $DB; |
61 |
$result = $DB->query("SELECT * FROM glpi_plugin_manageentity_preference WHERE user_id=".$user_id); |
62 |
if ($DB->numrows($result) > 0) |
63 |
return $DB->result($result,0,"show"); |
64 |
else
|
65 |
return 0; |
66 |
} |
67 |
|
68 |
function plugin_manageentity_addcontracts($eID,$cID){ |
69 |
|
70 |
$DB = new DB; |
71 |
$query="INSERT INTO glpi_plugin_manageentity_contracts (FK_contracts,FK_entity) VALUES ('$eID','$cID');"; |
72 |
$result = $DB->query($query); |
73 |
} |
74 |
|
75 |
function plugin_manageentity_deletecontracts($ID){ |
76 |
|
77 |
$DB = new DB; |
78 |
$query="DELETE FROM glpi_plugin_manageentity_contracts WHERE ID= '$ID';"; |
79 |
$result = $DB->query($query); |
80 |
} |
81 |
|
82 |
function plugin_manageentity_adddocuments($eID,$cID){ |
83 |
|
84 |
$DB = new DB; |
85 |
$query="INSERT INTO glpi_plugin_manageentity_documents (FK_documents,FK_entity) VALUES ('$eID','$cID');"; |
86 |
$result = $DB->query($query); |
87 |
} |
88 |
|
89 |
function plugin_manageentity_deletecontacts($ID){ |
90 |
|
91 |
$DB = new DB; |
92 |
$query="DELETE FROM glpi_plugin_manageentity_contacts WHERE ID= '$ID';"; |
93 |
$result = $DB->query($query); |
94 |
} |
95 |
|
96 |
function plugin_manageentity_addcontacts($eID,$cID){ |
97 |
|
98 |
$DB = new DB; |
99 |
$query="INSERT INTO glpi_plugin_manageentity_contacts (FK_contacts,FK_entity) VALUES ('$eID','$cID');"; |
100 |
$result = $DB->query($query); |
101 |
} |
102 |
|
103 |
function plugin_manageentity_deletedocuments($ID){ |
104 |
|
105 |
$DB = new DB; |
106 |
$query="DELETE FROM glpi_plugin_manageentity_documents WHERE ID= '$ID';"; |
107 |
$result = $DB->query($query); |
108 |
} |
109 |
|
110 |
function plugin_manageentity_createfirstaccess($ID){ |
111 |
|
112 |
GLOBAL $DB; |
113 |
|
114 |
$plugin_manageentity_Profile=new plugin_manageentity_Profile(); |
115 |
if (!$plugin_manageentity_Profile->GetfromDB($ID)){ |
116 |
|
117 |
$Profile=new Profile(); |
118 |
$Profile->GetfromDB($ID); |
119 |
$name=$Profile->fields["name"]; |
120 |
|
121 |
$query ="INSERT INTO `glpi_plugin_manageentity_profiles` ( `ID`, `name` , `interface`, `is_default`, `manageentity`) VALUES ('$ID', '$name','manageentity','0','w');"; |
122 |
$DB->query($query); |
123 |
} |
124 |
} |
125 |
|
126 |
function plugin_manageentity_createaccess($ID){ |
127 |
|
128 |
GLOBAL $DB; |
129 |
|
130 |
$Profile=new Profile(); |
131 |
$Profile->GetfromDB($ID); |
132 |
$name=$Profile->fields["name"]; |
133 |
|
134 |
$query ="INSERT INTO `glpi_plugin_manageentity_profiles` ( `ID`, `name` , `interface`, `is_default`, `manageentity`) VALUES ('$ID', '$name','manageentity','0',NULL);"; |
135 |
|
136 |
$DB->query($query); |
137 |
|
138 |
} |
139 |
|
140 |
//ryxeo
|
141 |
function plugin_manageentity_anetinsertnextupgrade($eID,$text){ |
142 |
$DB = new DB; |
143 |
$query="SELECT ID FROM glpi_plugin_anet_epacks_upgrade WHERE FK_serveur='$eID';"; |
144 |
$result = $DB->query($query); |
145 |
if($DB->numrows($result)>0) |
146 |
$query="UPDATE glpi_plugin_anet_epacks_upgrade SET upgradecmd='$text' WHERE FK_serveur='$eID';"; |
147 |
else
|
148 |
$query="INSERT INTO glpi_plugin_anet_epacks_upgrade (FK_serveur,upgradecmd) VALUES ('$eID','$text');"; |
149 |
$result = $DB->query($query); |
150 |
} |
151 |
|
152 |
?>
|