71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use GlpiPlugin\Urbackup\Config;
|
|
use GlpiPlugin\Urbackup\Profile;
|
|
use GlpiPlugin\Urbackup\Server;
|
|
use GlpiPlugin\Urbackup\ServerAsset;
|
|
use GlpiPlugin\Urbackup\MassiveAction as PluginUrbackupMassiveAction;
|
|
|
|
require_once __DIR__ . '/install/install.php';
|
|
require_once __DIR__ . '/install/uninstall.php';
|
|
|
|
/**
|
|
* Get plugin classes.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
function plugin_urbackup_get_classes(): array
|
|
{
|
|
return [
|
|
Config::class,
|
|
Profile::class,
|
|
Server::class,
|
|
ServerAsset::class,
|
|
PluginUrbackupMassiveAction::class,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Declare plugin massive actions.
|
|
*
|
|
* In GLPI this hook receives the current itemtype as string,
|
|
* for example Computer, Printer, Peripheral.
|
|
*
|
|
* It does not receive a MassiveAction object.
|
|
*
|
|
* @param mixed $type Current itemtype
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
function plugin_urbackup_MassiveActions($type): array
|
|
{
|
|
$actions = [];
|
|
|
|
if (!is_string($type) || $type === '') {
|
|
return $actions;
|
|
}
|
|
|
|
if (!Config::isItemtypeEnabled($type)) {
|
|
return $actions;
|
|
}
|
|
|
|
if (Profile::canCurrentUser(UPDATE) || Profile::canCurrentUser(CREATE)) {
|
|
$actions[
|
|
PluginUrbackupMassiveAction::class
|
|
. \MassiveAction::CLASS_ACTION_SEPARATOR
|
|
. PluginUrbackupMassiveAction::ACTION_CONNECT_SERVER
|
|
] = __('UrBackup - connect to server', 'urbackup');
|
|
}
|
|
|
|
if (Profile::canCurrentUser(UPDATE)) {
|
|
$actions[
|
|
PluginUrbackupMassiveAction::class
|
|
. \MassiveAction::CLASS_ACTION_SEPARATOR
|
|
. PluginUrbackupMassiveAction::ACTION_DISCONNECT_SERVER
|
|
] = __('UrBackup - disconnect from server', 'urbackup');
|
|
}
|
|
|
|
return $actions;
|
|
} |