Skip to content

Commit 1486506

Browse files
committed
Merge branch 'master' of github.com:fusinv/fusioninventory-for-glpi
2 parents 328600e + 8ebb29c commit 1486506

13 files changed

+295
-424
lines changed

fusioninventory/inc/agent.class.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ function defineTabs($options=array()){
183183
*/
184184
function getComments() {
185185

186-
$comment = __('Useragent', 'fusioninventory').' : '.$this->fields['useragent'].'<br/>
187-
'.__('Last contact', 'fusioninventory').' : '.Html::convDateTime($this->fields['last_contact']).' minutes';
186+
$comment = __('Useragent', 'fusioninventory').' : '.$this->fields['useragent'].'<br/>'.
187+
__('Last contact', 'fusioninventory').' : '.
188+
Html::convDateTime($this->fields['last_contact']).' minutes';
188189

189190
if (!empty($comment)) {
190191
return Html::showToolTip($comment, array('display' => false));
@@ -239,7 +240,8 @@ function showForm($computers_id, $options=array()) {
239240
$oComputer = new Computer();
240241
$oComputer->getFromDB($this->fields["computers_id"]);
241242
echo $oComputer->getLink(1);
242-
echo "<input type='hidden' name='computers_id' value='".$this->fields["computers_id"]."'/>";
243+
echo "<input type='hidden' name='computers_id' ".
244+
"value='".$this->fields["computers_id"]."'/>";
243245
} else {
244246
Computer_Item::dropdownConnect("Computer", "Computer", 'computers_id',
245247
$_SESSION['glpiactive_entity']);
@@ -266,9 +268,13 @@ function showForm($computers_id, $options=array()) {
266268
echo "</tr>";
267269

268270
echo "<tr class='tab_bg_1'>";
269-
echo "<td>".__('Threads number', 'fusioninventory')."&nbsp;(".strtolower(__('Network discovery', 'fusioninventory')).")&nbsp;:</td>";
271+
echo "<td>".__('Threads number', 'fusioninventory')."&nbsp;".
272+
"(".strtolower(__('Network discovery', 'fusioninventory')).")&nbsp;:</td>";
270273
echo "<td align='center'>";
271-
Dropdown::showInteger("threads_networkdiscovery", $this->fields["threads_networkdiscovery"], 1, 400);
274+
Dropdown::showInteger("threads_networkdiscovery",
275+
$this->fields["threads_networkdiscovery"],
276+
1,
277+
400);
272278
echo "</td>";
273279
echo "<td>".__('Useragent', 'fusioninventory')."&nbsp:</td>";
274280
echo "<td align='center'>";
@@ -277,9 +283,13 @@ function showForm($computers_id, $options=array()) {
277283
echo "</tr>";
278284

279285
echo "<tr class='tab_bg_1'>";
280-
echo "<td>".__('Threads number', 'fusioninventory')."&nbsp;(".strtolower(__('Network inventory (SNMP)', 'fusioninventory')).")&nbsp;:</td>";
286+
echo "<td>".__('Threads number', 'fusioninventory')."&nbsp;".
287+
"(".strtolower(__('Network inventory (SNMP)', 'fusioninventory')).")&nbsp;:</td>";
281288
echo "<td align='center'>";
282-
Dropdown::showInteger("threads_networkinventory", $this->fields["threads_networkinventory"], 1, 400);
289+
Dropdown::showInteger("threads_networkinventory",
290+
$this->fields["threads_networkinventory"],
291+
1,
292+
400);
283293
echo "</td>";
284294
echo "<td>".__('Last contact', 'fusioninventory')."&nbsp:</td>";
285295
echo "<td align='center'>";
@@ -315,7 +325,7 @@ function InfosByKey($device_id) {
315325
global $DB;
316326

317327
$query = "SELECT * FROM `".$this->getTable()."`
318-
WHERE `device_id`='".$device_id."' LIMIT 1";
328+
WHERE `device_id`='".$device_id."' LIMIT 1";
319329

320330
$agent = array();
321331
$result = $DB->query($query);
@@ -362,7 +372,7 @@ function importToken($arrayinventory) {
362372
}
363373
$input['last_contact'] = date("Y-m-d H:i:s");
364374
if (isset($_SERVER['HTTP_USER_AGENT'])) {
365-
$input['useragent'] = $_SERVER['HTTP_USER_AGENT'];
375+
$input['useragent'] = $_SERVER['HTTP_USER_AGENT'];
366376
}
367377
$pfAgent->update($input);
368378
return $data['id'];
@@ -457,7 +467,8 @@ function setAgentWithComputerid($computers_id, $device_id) {
457467

458468
$a_agent = $this->find("`computers_id`='".$computers_id."'", "", 1);
459469
// Is this computer already linked to an agent?
460-
if ($agent = array_shift($a_agent)) {
470+
$agent = array_shift($a_agent);
471+
if (is_array($agent)) {
461472

462473
// relation
463474
if ($agent['device_id'] != $device_id) {
@@ -524,7 +535,6 @@ function forceRemoteAgent() {
524535
echo "<tr>";
525536
echo "<th colspan='2'>";
526537
echo __('Agent state', 'fusioninventory');
527-
528538
echo "</th>";
529539
echo "</tr>";
530540

@@ -536,7 +546,6 @@ function forceRemoteAgent() {
536546
$pfAgent = new PluginFusioninventoryAgent();
537547
$pfAgent->getFromDB($agent_id);
538548
echo $pfAgent->getLink(1);
539-
540549
echo "</td>";
541550
echo "</tr>";
542551

@@ -559,18 +568,15 @@ function forceRemoteAgent() {
559568

560569
case 'running':
561570
echo __('Running');
562-
563571
break;
564572

565573
case 'noanswer':
566574
echo __('Impossible to communicate with agent!', 'fusioninventory');
567-
568575
break;
569576

570577
case 'waiting':
571578
$waiting = 1;
572579
echo __('Available');
573-
574580
echo "<input type='hidden' name='ip' value='".$ip."' />";
575581
echo "<input type='hidden' name='agent_id' value='".$agent_id."' />";
576582
break;
@@ -588,7 +594,6 @@ function forceRemoteAgent() {
588594
echo "<tr>";
589595
echo "<th colspan='2'>";
590596
echo "<input name='startagent' value=\"".__('Force inventory', 'fusioninventory').
591-
592597
"\" class='submit' type='submit'>";
593598
echo "</th>";
594599
echo "</tr>";
@@ -750,7 +755,8 @@ static function showConfig() {
750755
echo "<tr class='tab_bg_1'>";
751756
echo "<td width='50%'>";
752757
$array = explode("/", $_SERVER['HTTP_REFERER']);
753-
$create_url = $array[0]."//".$array[2]. str_replace("front/wizard.php", "", $_SERVER['PHP_SELF']);
758+
$create_url = $array[0]."//".$array[2].
759+
str_replace("front/wizard.php", "", $_SERVER['PHP_SELF']);
754760
echo __('Communication url of the server', 'fusioninventory')."&nbsp;:";
755761
echo "</td>";
756762
echo "<td>";

fusioninventory/inc/agentmodule.class.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ function showForm() {
102102

103103
$a_modules = $this->find();
104104
foreach ($a_modules as $data) {
105-
echo "<form name='form_ic' method='post' action='". Toolbox::getItemTypeFormURL(__CLASS__)."'>";
105+
echo "<form name='form_ic' method='post' action='".
106+
Toolbox::getItemTypeFormURL(__CLASS__)."'>";
106107
echo "<table class='tab_cadre_fixe'>";
107108
echo "<tr>";
108109
echo "<th width='130'>".__('Module', 'fusioninventory')."</th>";
@@ -238,15 +239,15 @@ function showFormAgentException($items_id) {
238239
$checked = $data['is_active'];
239240
$a_agentList = importArrayFromDB($data['exceptions']);
240241
if (in_array($items_id, $a_agentList)) {
242+
$checked = 1;
241243
if ($checked == 1)
242244
$checked = 0;
243-
else
244-
$checked = 1;
245245
}
246246
$check = "";
247247
if ($checked == 1)
248248
$check = "checked='checked'";
249-
echo "<input type='checkbox' name='activation-".$data["modulename"]."' value='Activation' ".$check." />";
249+
echo "<input type='checkbox' name='activation-".$data["modulename"]."' ".
250+
"value='Activation' ".$check." />";
250251
echo "</td>";
251252
if ($i == 1) {
252253
echo "</tr>";
@@ -263,7 +264,8 @@ function showFormAgentException($items_id) {
263264
echo "<tr>";
264265
echo "<td class='tab_bg_2 center' colspan='4'>";
265266
echo "<input type='hidden' name='id' value=\"".$items_id."\">";
266-
echo "<input type='submit' name='updateexceptions' value=\"".__('Update')."\" class='submit'>";
267+
echo "<input type='submit' name='updateexceptions' ".
268+
"value=\"".__('Update')."\" class='submit'>";
267269
echo "</td>";
268270
echo "</tr>";
269271
echo "</table>";
@@ -402,7 +404,8 @@ static function getUrlForModule($modulename) {
402404

403405
# Construct the path to the JSON back from the agent_base_url.
404406
# agent_base_url is the initial URL used by the agent
405-
return $config->getValue('agent_base_url').'/plugins/fusioninventory/b/'.strtolower($modulename).'/';
407+
return $config->getValue('agent_base_url').'/plugins/fusioninventory/b/'.
408+
strtolower($modulename).'/';
406409
}
407410
}
408411

fusioninventory/inc/communication.class.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class PluginFusioninventoryCommunication {
5252

5353

5454
function __construct() {
55-
$this->message = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8'?><REPLY></REPLY>");
55+
$this->message = new SimpleXMLElement(
56+
"<?xml version='1.0' encoding='UTF-8'?><REPLY></REPLY>"
57+
);
5658
PluginFusioninventoryToolbox::logIfExtradebug(
5759
'pluginFusioninventory-communication',
5860
'New PluginFusioninventoryCommunication object.'
@@ -187,16 +189,24 @@ function import($arrayinventory) {
187189
}
188190

189191
if (isset($this->message['CONTENT']['MODULEVERSION'])) {
190-
$pfAgent->setAgentVersions($agent['id'], $xmltag, $this->message['CONTENT']['MODULEVERSION']);
192+
$pfAgent->setAgentVersions($agent['id'],
193+
$xmltag,
194+
$this->message['CONTENT']['MODULEVERSION']);
191195
} else if (isset($this->message['CONTENT']['VERSIONCLIENT'])) {
192-
$version = str_replace("FusionInventory-Agent_", "", $this->message['CONTENT']['VERSIONCLIENT']);
196+
$version = str_replace("FusionInventory-Agent_",
197+
"",
198+
$this->message['CONTENT']['VERSIONCLIENT']);
193199
$pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
194200
}
195201

196202
if (isset($this->message->CONTENT->MODULEVERSION)) {
197-
$pfAgent->setAgentVersions($agent['id'], $xmltag, (string)$this->message->CONTENT->MODULEVERSION);
203+
$pfAgent->setAgentVersions($agent['id'],
204+
$xmltag,
205+
(string)$this->message->CONTENT->MODULEVERSION);
198206
} else if (isset($this->message->CONTENT->VERSIONCLIENT)) {
199-
$version = str_replace("FusionInventory-Agent_", "", (string)$this->message->CONTENT->VERSIONCLIENT);
207+
$version = str_replace("FusionInventory-Agent_",
208+
"",
209+
(string)$this->message->CONTENT->VERSIONCLIENT);
200210
$pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
201211
}
202212

@@ -291,13 +301,12 @@ function handleFusionCommunication() {
291301

292302
// old POST protocol
293303
function handleOCSCommunication($xml='') {
294-
global $PLUGIN_HOOKS;
304+
295305
// ***** For debug only ***** //
296306
//$GLOBALS["HTTP_RAW_POST_DATA"] = gzcompress('');
297307
// ********** End ********** //
298308

299309
$config = new PluginFusioninventoryConfig();
300-
$plugin = new Plugin();
301310
$user = new User();
302311

303312
// ob_start();
@@ -375,9 +384,9 @@ function handleOCSCommunication($xml='') {
375384
(!isset($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] != "on")
376385
) {
377386
$communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>
378-
<REPLY>
387+
<REPLY>
379388
<ERROR>SSL REQUIRED BY SERVER</ERROR>
380-
</REPLY>");
389+
</REPLY>");
381390
$communication->sendMessage($compressmode);
382391
return;
383392
}
@@ -391,17 +400,19 @@ function handleOCSCommunication($xml='') {
391400
$pxml = '';
392401
if ($pxml = @simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)) {
393402

394-
} else if ($pxml = @simplexml_load_string(utf8_encode($xml), 'SimpleXMLElement', LIBXML_NOCDATA)) {
403+
} else if ($pxml = @simplexml_load_string(utf8_encode($xml),
404+
'SimpleXMLElement',
405+
LIBXML_NOCDATA)) {
395406
$xml = utf8_encode($xml);
396407
} else {
397408
$xml = preg_replace ('/<FOLDER>.*?<\/SOURCE>/', '', $xml);
398409
$pxml = @simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
399410

400411
if (!$pxml) {
401412
$communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>
402-
<REPLY>
413+
<REPLY>
403414
<ERROR>XML not well formed!</ERROR>
404-
</REPLY>");
415+
</REPLY>");
405416
$communication->sendMessage($compressmode);
406417
return;
407418
}

0 commit comments

Comments
 (0)