Uninstall and install hook
This commit is contained in:
60
hook.php
60
hook.php
@@ -25,12 +25,68 @@ function plugin_remotesupport_install()
|
|||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
Toolbox::logInFile("remotsupport","Installing plugin");
|
||||||
|
$state_online = [
|
||||||
|
'name' => 'Online',
|
||||||
|
'entities_id' => 0,
|
||||||
|
'is_recursive' => 0,
|
||||||
|
'comment' => '',
|
||||||
|
'states_id' => 0,
|
||||||
|
'completename' => 'Online',
|
||||||
|
'level' => 1,
|
||||||
|
'ancestors_cache' => '[]',
|
||||||
|
'sons_cache' => 'NULL',
|
||||||
|
'is_visible_computer' => 1,
|
||||||
|
'is_visible_monitor' => 0,
|
||||||
|
'is_visible_networkequipment' => 0,
|
||||||
|
'is_visible_peripheral' => 0,
|
||||||
|
'is_visible_phone' => 0,
|
||||||
|
'is_visible_printer' => 0,
|
||||||
|
'is_visible_softwareversion' => 0,
|
||||||
|
'is_visible_softwarelicense' => 0,
|
||||||
|
'is_visible_line' => 0,
|
||||||
|
'is_visible_certificate' => 0,
|
||||||
|
'is_visible_rack' => 0,
|
||||||
|
'is_visible_passivedcequipment' => 0,
|
||||||
|
'is_visible_enclosure' => 0,
|
||||||
|
'is_visible_pdu' => 0,
|
||||||
|
'is_visible_cluster' => 0,
|
||||||
|
'is_visible_contract' => 0,
|
||||||
|
'is_visible_appliance' => 0];
|
||||||
|
|
||||||
|
$ret = $DB->insert(
|
||||||
|
'glpi_states', $state_online
|
||||||
|
);
|
||||||
|
|
||||||
|
$state_offline = $state_online;
|
||||||
|
$state_offline["name"] = 'Offline';
|
||||||
|
$state_offline["completename"] = 'Offline';
|
||||||
|
|
||||||
|
$ret = $DB->insert(
|
||||||
|
'glpi_states', $state_offline
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function plugin_remotesupport_uninstall(){
|
function plugin_remotesupport_uninstall(){
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
Toolbox::logInFile("remotsupport","Uninstalling plugin");
|
||||||
|
CronTask::Unregister('remotesupport');
|
||||||
|
|
||||||
|
$req = $DB->request('glpi_states', ['FIELDS' => ['glpi_states' => ['id', 'name']]], [ 'OR' => [ 'name' => 'Online', 'name' => 'Offline']]);
|
||||||
|
|
||||||
|
$ret = $req->next();
|
||||||
|
$states_ids[$ret['name']] = $ret['id'];
|
||||||
|
$ret = $req->next();
|
||||||
|
$states_ids[$ret['name']] = $ret['id'];
|
||||||
|
|
||||||
|
$DB->query('UPDATE glpi_computers SET states_id=NULL WHERE id='.$states_ids["Offline"]);
|
||||||
|
$DB->query('UPDATE glpi_computers SET states_id=NULL WHERE id='.$states_ids["Online"]);
|
||||||
|
$DB->query('DELETE FROM glpi_states WHERE id='.$states_ids["Offline"]);
|
||||||
|
$DB->query('DELETE FROM glpi_states WHERE id='.$states_ids["Online"]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user