reformatted, cleaned
This commit is contained in:
7
hook.php
7
hook.php
@@ -69,7 +69,8 @@ function plugin_remotesupport_install()
|
||||
return true;
|
||||
}
|
||||
|
||||
function plugin_remotesupport_uninstall(){
|
||||
function plugin_remotesupport_uninstall()
|
||||
{
|
||||
global $DB;
|
||||
|
||||
Toolbox::logInFile("remotsupport", "Uninstalling plugin");
|
||||
@@ -90,7 +91,8 @@ function plugin_remotesupport_uninstall(){
|
||||
return true;
|
||||
}
|
||||
|
||||
function plugin_remotesupport_postinit() {
|
||||
function plugin_remotesupport_postinit()
|
||||
{
|
||||
global $CFG_GLPI, $DB;
|
||||
|
||||
if (isset($_GET['id']) && $_GET['id'] != 0 && isset($_GET['_itemtype']) && $_GET['_itemtype'] == "Ticket") {
|
||||
@@ -121,4 +123,3 @@ function plugin_remotesupport_postinit() {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,50 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------
|
||||
FusionInventory
|
||||
Copyright (C) 2010-2011 by the FusionInventory Development Team.
|
||||
|
||||
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
|
||||
------------------------------------------------------------------------
|
||||
|
||||
LICENSE
|
||||
|
||||
This file is part of FusionInventory project.
|
||||
|
||||
FusionInventory is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FusionInventory is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
@package FusionInventory
|
||||
@author Walid Nouh
|
||||
@co-author
|
||||
@copyright Copyright (c) 2010-2011 FusionInventory team
|
||||
@license AGPL License 3.0 or (at your option) any later version
|
||||
http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
@link http://www.fusioninventory.org/
|
||||
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
|
||||
@since 2010
|
||||
|
||||
------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
include ("../../../inc/includes.php");
|
||||
include "../../../inc/includes.php";
|
||||
|
||||
declare (ticks = 1);
|
||||
|
||||
|
||||
global $DB, $agents;
|
||||
|
||||
$check_arr = [];
|
||||
@@ -65,11 +24,10 @@ global $DB,$agents;
|
||||
//print_r($agent->getAgentStatusURLs());
|
||||
}
|
||||
|
||||
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
||||
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
|
||||
2 => array("file", "/tmp/error-output.txt", "a"), // stderr is a file to write to
|
||||
);
|
||||
|
||||
$cwd = '/tmp';
|
||||
@@ -104,14 +62,11 @@ $ret = $req->next();
|
||||
$states_ids[$ret['name']] = $ret['id'];
|
||||
print_r($states_ids);
|
||||
|
||||
|
||||
|
||||
$DB->update("glpi_computers", [
|
||||
'states_id' => $states_ids["Offline"]],
|
||||
['1' => '1']
|
||||
);
|
||||
|
||||
|
||||
foreach ($checked as $s) {
|
||||
echo $s->computers_id . " ";
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
|
||||
|
||||
class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
static function showInfo($item) {
|
||||
class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
{
|
||||
public static function showInfo($item)
|
||||
{
|
||||
|
||||
$fi_path = Plugin::getWebDir('fusioninventory');
|
||||
|
||||
@@ -40,7 +40,8 @@ class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
|
||||
}
|
||||
|
||||
static function getStatesIds() {
|
||||
public static function getStatesIds()
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$states_ids = [];
|
||||
@@ -55,12 +56,12 @@ class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
return $states_ids;
|
||||
}
|
||||
|
||||
static function cronRemotesupport($task) {
|
||||
public static function cronRemotesupport($task)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
Toolbox::logInFile("remotsupport", "Starting search of agents\n");
|
||||
|
||||
|
||||
$check_arr = [];
|
||||
$comps = [];
|
||||
$pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
|
||||
@@ -82,7 +83,7 @@ class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
||||
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
|
||||
2 => array("file", "/tmp/error-output.txt", "a"), // stderr is a file to write to
|
||||
);
|
||||
|
||||
$cwd = '/tmp';
|
||||
@@ -116,7 +117,6 @@ class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
['1' => '1']
|
||||
);
|
||||
|
||||
|
||||
foreach ($checked as $s) {
|
||||
|
||||
$comp = new Computer();
|
||||
@@ -133,7 +133,8 @@ class PluginRemotesupportRemotesupport extends CommonDBTM {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static function cronInfo($name) {
|
||||
public static function cronInfo($name)
|
||||
{
|
||||
return [
|
||||
'description' => "Agent search remotesupport"];
|
||||
}
|
||||
|
||||
18
setup.php
18
setup.php
@@ -33,26 +33,17 @@ function plugin_init_remotesupport()
|
||||
|
||||
if (Plugin::isPluginActive('remotesupport')) {
|
||||
|
||||
// $PLUGIN_HOOKS['add_javascript']['remotesupport'][] = 'js/support.js';
|
||||
|
||||
$PLUGIN_HOOKS['autoinventory_information']['remotesupport'] = array(
|
||||
'Computer' => array('PluginRemotesupportRemotesupport', 'showInfo')
|
||||
'Computer' => array('PluginRemotesupportRemotesupport', 'showInfo'),
|
||||
);
|
||||
|
||||
CronTask::Register('PluginRemotesupportRemotesupport', 'remotesupport', 300,
|
||||
['mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30,
|
||||
'comment' => 'Remotesupport crontab search agents']);
|
||||
|
||||
|
||||
// Add Config Page
|
||||
// Plugin::registerClass('PluginRemotesupportConfig', ['addtabon' => 'Config']);
|
||||
|
||||
// $PLUGIN_HOOKS["menu_toadd"]['remotesupport'] = ['tools' => 'PluginRemotesupportMenu'];
|
||||
// $PLUGIN_HOOKS['config_page']['remotesupport'] = 'front/index.php';
|
||||
$PLUGIN_HOOKS['menu']['remotesupport'] = true;
|
||||
$PLUGIN_HOOKS['post_init']['remotesupport'] = 'plugin_remotesupport_postinit';
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +58,8 @@ function plugin_version_remotesupport()
|
||||
'requirements' => [
|
||||
'glpi' => [
|
||||
'min' => PLUGIN_REMOTESUPPORT_MIN_GLPI,
|
||||
'max' => PLUGIN_REMOTESUPPORT_MAX_GLPI
|
||||
]
|
||||
]
|
||||
'max' => PLUGIN_REMOTESUPPORT_MAX_GLPI,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user