Revision ad6689da
Davantage de correction liées aux conventions
Change-Id: I7680cf42d0b10ac300d44085d695e15064d33094
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2369
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/vigilo_hooks.php | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
$res = file_put_contents($file, $host, LOCK_EX); |
24 |
if ($res !== false) {
|
|
24 |
if (false !== $res) {
|
|
25 | 25 |
chgrp($file, "vigiconf"); |
26 | 26 |
chmod($file, 0660); |
27 | 27 |
} |
... | ... | |
37 | 37 |
{ |
38 | 38 |
global $DB; |
39 | 39 |
|
40 |
if ($computer->getField("is_template") == 0) {
|
|
40 |
if (!$computer->getField("is_template")) {
|
|
41 | 41 |
$template_id = PluginVigiloVigiloTemplate::getVigiloTemplateNameByID( |
42 | 42 |
$computer->getField("vigilo_template") |
43 | 43 |
); |
... | ... | |
61 | 61 |
|
62 | 62 |
public function addNetworkEquipment($networkequipment) |
63 | 63 |
{ |
64 |
if ($networkequipment->getField("is_template") == 0) { |
|
65 |
global $DB; |
|
66 |
|
|
64 |
if (!$networkequipment->getField("is_template")) { |
|
67 | 65 |
$host = new VigiloNetworkEquipment($networkequipment); |
68 | 66 |
$this->saveHost($host, "hosts"); |
69 | 67 |
} |
... | ... | |
71 | 69 |
|
72 | 70 |
public function addPrinter($printer) |
73 | 71 |
{ |
74 |
if ($printer->getField("is_template") == 0) { |
|
75 |
global $DB; |
|
76 |
|
|
72 |
if (!$printer->getField("is_template")) { |
|
77 | 73 |
$host = new VigiloPrinter($printer); |
78 | 74 |
$this->saveHost($host, "hosts"); |
79 | 75 |
} |
... | ... | |
86 | 82 |
|
87 | 83 |
public function update($computer) |
88 | 84 |
{ |
89 |
global $PLUGIN_HOOKS, $DB; |
|
90 | 85 |
if (isset($computer->oldvalues["name"])) { |
91 | 86 |
$this->unmonitor($computer->oldvalues["name"]); |
92 | 87 |
} |
... | ... | |
121 | 116 |
|
122 | 117 |
public function manageComputerSoftwareVersion($computer_software_version) |
123 | 118 |
{ |
124 |
global $DB; |
|
125 |
$computer=new Computer(); |
|
119 |
$computer = new Computer(); |
|
126 | 120 |
$computer->getFromDB($computer_software_version->getField("computers_id")); |
127 | 121 |
$this->updateComputer($computer); |
128 | 122 |
} |
129 | 123 |
|
130 | 124 |
public function manageSoftwares($software) |
131 | 125 |
{ |
132 |
global $DB; |
|
133 |
$softwareVer=new SoftwareVersion(); |
|
134 |
$idSoftwareVersion=$softwareVer->find('softwares_id=' . $software->getID()); |
|
126 |
$softwareVer = new SoftwareVersion(); |
|
127 |
$idSoftwareVersion = $softwareVer->find('softwares_id=' . $software->getID()); |
|
135 | 128 |
foreach ($idSoftwareVersion as $idVersion) { |
136 |
if ($idVersion['id']) { |
|
137 |
$computerVer=new Computer_SoftwareVersion(); |
|
138 |
$goodField='softwareversions_id=' . $idVersion['id']; |
|
139 |
$updateComp=$computerVer->find($goodField); |
|
140 |
foreach ($updateComp as $idComputer) { |
|
141 |
if ($idComputer['computers_id'] != -1) { |
|
142 |
$computer=new Computer(); |
|
143 |
$computer->getFromDB($idComputer['computers_id']); |
|
144 |
$this->updateComputer($computer); |
|
145 |
} |
|
129 |
if (!$idVersion['id']) { |
|
130 |
continue; |
|
131 |
} |
|
132 |
|
|
133 |
$computerVer = new Computer_SoftwareVersion(); |
|
134 |
$goodField = 'softwareversions_id=' . $idVersion['id']; |
|
135 |
$updateComp = $computerVer->find($goodField); |
|
136 |
|
|
137 |
foreach ($updateComp as $idComputer) { |
|
138 |
if (-1 === $idComputer['computers_id']) { |
|
139 |
continue; |
|
146 | 140 |
} |
141 |
|
|
142 |
$computer = new Computer(); |
|
143 |
$computer->getFromDB($idComputer['computers_id']); |
|
144 |
$this->updateComputer($computer); |
|
147 | 145 |
} |
148 | 146 |
} |
149 | 147 |
} |
150 | 148 |
|
151 | 149 |
public function manageDisks($disk) |
152 | 150 |
{ |
153 |
global $DB; |
|
154 |
$id=$disk->getField('computers_id'); |
|
155 |
$computer=new Computer(); |
|
151 |
$id = $disk->getField('computers_id'); |
|
152 |
$computer = new Computer(); |
|
156 | 153 |
$computer->getFromDB($id); |
157 | 154 |
$this->updateComputer($computer); |
158 | 155 |
} |
159 | 156 |
|
160 | 157 |
public function manageAddresses($address) |
161 | 158 |
{ |
162 |
global $DB; |
|
163 | 159 |
$id = $address->getField('mainitems_id'); |
164 | 160 |
$comp = new Computer(); |
165 | 161 |
$comp->getFromDB($id); |
... | ... | |
168 | 164 |
|
169 | 165 |
public function manageNetworks($network) |
170 | 166 |
{ |
171 |
global $DB; |
|
172 | 167 |
$id = $network->getField('items_id'); |
173 | 168 |
$itemtype = $network->getField('itemtype'); |
174 | 169 |
if ($itemtype === 'Computer') { |
... | ... | |
192 | 187 |
// Le nom de la méthode est imposé par GLPI. |
193 | 188 |
// @codingStandardsIgnoreEnd |
194 | 189 |
$options = array(); |
190 |
|
|
195 | 191 |
if ($itemtype == 'Computer' || $itemtype == 'PluginVigiloComputer') { |
196 | 192 |
$options['7007']['table'] = 'glpi_computers'; |
197 | 193 |
$options['7007']['field'] = 'vigilo_template'; |
... | ... | |
199 | 195 |
$options['7007']['massiveaction'] = 'TRUE'; |
200 | 196 |
$options['7007']['datatype'] = 'dropdown'; |
201 | 197 |
} |
198 |
|
|
202 | 199 |
return $options; |
203 | 200 |
} |
204 | 201 |
} |
Also available in: Unified diff