You are not logged in.
Hello,
I 'm still busy to write my first plugin. The only lqst thing I need to write is for the export right from the Search::show table.
Doesn't I need to write a profile class to have the permission to export from export dropdown menu ?
mizuho > plugin > front > menu.php
<?php
include('../../../inc/includes.php');
$plugin = new Plugin();
if (!$plugin->isActivated('mizuho')) {
Html::displayNotFoundError();
}
Html::header('Mizuho Plugin', '', 'tools', 'PluginMizuhoMenu');
// $plugin_dir = Plugin::getWebDir('mizuho');
$itemtype = 'PluginMizuhoImpactanalysis';
$p = [
'start' => 0,
'is_deleted' => 0,
'sort' => 1,
'order' => 'ASC'
];
Search::showList($itemtype, $p);
Html::footer();
mizuho > inc > menu.class.php
<?php
class PluginMizuhoMenu extends CommonGLPI
{
public static function getTypeName($nb = 0) {
return _x('plugin_info', 'Mizuho plugin', 'mizuho');
}
public static function getMenuName() {
return _x('plugin_info', 'Mizuho plugin', 'mizuho');
}
public static function getIcon() {
return 'fas fa-tablet-alt';
}
public static function canView() {
return Config::canView();
}
}
mizuho > inc > impactanalysis.class.php
<?php
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}
class PluginMizuhoImpactanalysis extends CommonDBTM {
function rawSearchOptions() {
$tab = [];
$tab[] = ['id' => 'common',
'name' => _n('Impact Analysis', 'Impact Analysis', 2, 'mizuho')];
$tab[] = ['id' => '1',
'table' => 'glpi_plugin_mizuho_impactanalysis',
'field' => 'id',
'name' => __('Id'),
'datatype' => 'integer',
'massiveaction' => false,
'nosearch' => true,
'nodisplay' => true];
$tab[] = ['id' => '2',
'table' => 'glpi_plugin_mizuho_impactanalysis',
'field' => 'name',
'name' => __('Name'),
'datatype' => 'text',
'massiveaction' => false,
'nosearch' => true,
'nodisplay' => true];
return $tab;
}
}
mizuho > hook.php
<?php
function plugin_mizuho_install() {
//do some stuff like instantiating databases, default values, ...
return true;
}
function plugin_mizuho_uninstall() {
//to some stuff, like removing tables, generated files, ...
return true;
}
mizuho > setup.php
<?php
define('MIZUHO_VERSION', '1.0.0');
define('PLUGIN_MIZUHO_MIN_GLPI', '10.0.0');
define('PLUGIN_MIZUHO_MAX_GLPI', '10.1.0');
function plugin_init_mizuho() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['mizuho'] = true;
//some code here, like call to Plugin::registerClass(), populating PLUGIN_HOOKS, ...
if (Plugin::isPluginActive('mizuho')) {
$PLUGIN_HOOKS['menu_toadd']['mizuho'] = ['tools' => 'PluginMizuhoMenu'];
}
}
function plugin_version_mizuho() {
return [
'name' => 'Plugin Mizuho',
'version' => MIZUHO_VERSION,
'author' => 'Devoteam',
'license' => 'GLPv2',
'homepage' => '',
'requirements' => [
'glpi' => [
'min' => PLUGIN_MIZUHO_MIN_GLPI,
'max' => PLUGIN_MIZUHO_MAX_GLPI
]
]
];
}
function plugin_mizuho_check_prerequisites()
{
if (!method_exists('Plugin', 'checkGlpiVersion')) {
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
$matchMinGlpiReq = version_compare($version, PLUGIN_MIZUHO_MIN_GLPI, '>=');
$matchMaxGlpiReq = version_compare($version, PLUGIN_MIZUHO_MAX_GLPI, '<');
if (!$matchMinGlpiReq || !$matchMaxGlpiReq) {
echo vsprintf(
'This plugin requires GLPI >= %1$s and < %2$s.',
[
PLUGIN_MIZUHO_MIN_GLPI,
PLUGIN_MIZUHO_MAX_GLPI,
]
);
return false;
}
}
return true;
}
Thanks for your help
Offline