diff --git a/hook.php b/hook.php index 23f076a..062d491 100644 --- a/hook.php +++ b/hook.php @@ -107,7 +107,7 @@ function plugin_databases_install() { $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { - while ($data = $DB->fetch_array($result_)) { + while ($data = $DB->fetchArray($result_)) { $query = "UPDATE `glpi_plugin_databases_profiles` SET `profiles_id` = '" . $data["id"] . "' WHERE `id` = '" . $data["id"] . "';"; @@ -124,7 +124,7 @@ function plugin_databases_install() { $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { - while ($data = $DB->fetch_array($result)) { + while ($data = $DB->fetchArray($result)) { $query = "UPDATE `glpi_plugin_databases_instances` SET `entities_id` = '" . $data["entities_id"] . "' AND `is_recursive` = '" . $data["is_recursive"] . "' @@ -202,12 +202,18 @@ function plugin_databases_uninstall() { "glpi_logs", "glpi_items_tickets", "glpi_notepads", - "glpi_dropdowntranslations"]; + "glpi_dropdowntranslations", + "glpi_impactitems"]; foreach ($tables_glpi as $table_glpi) { $DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` LIKE 'PluginDatabases%' ;"); } + $DB->query("DELETE + FROM `glpi_impactrelations` + WHERE `itemtype_source` IN ('PluginDatabasesDatabase') + OR `itemtype_impacted` IN ('PluginDatabasesDatabase')"); + if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(['itemtype' => 'PluginDatabasesDatabase']); } @@ -291,7 +297,7 @@ function plugin_databases_AssignToTicketDropdown($data) { $result = $DB->query($sql); $elements = array(); - while ($res = $DB->fetch_array($result)) { + while ($res = $DB->fetchArray($result)) { $itemtype = $res['itemtype']; $item = new $itemtype; $item->getFromDB($res['items_id']); @@ -551,7 +557,7 @@ function plugin_databases_giveItem($type, $ID, $data, $num) { if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { $item = new $itemtype(); - while ($data = $DB->fetch_assoc($result_linked)) { + while ($data = $DB->fetchAssoc($result_linked)) { if ($item->getFromDB($data['id'])) { $out .= $item::getTypeName(1) . " - " . $item->getLink() . "
"; } diff --git a/inc/database.class.php b/inc/database.class.php index 714be6d..7d21fde 100644 --- a/inc/database.class.php +++ b/inc/database.class.php @@ -40,7 +40,7 @@ class PluginDatabasesDatabase extends CommonDBTM { static $rightname = "plugin_databases"; protected $usenotepad = true; - static $types = ['Computer', 'Software', 'SoftwareLicense']; + static $types = ['Computer', 'Software', 'SoftwareLicense', 'Appliance']; /** * @param int $nb @@ -227,6 +227,14 @@ function rawSearchOptions() { 'datatype' => 'datetime' ]; + $tab[] = [ + 'id' => '15', + 'table' => $this->getTable(), + 'field' => 'link', + 'name' => __('URL'), + 'datatype' => 'weblink' + ]; + $tab[] = [ 'id' => '30', 'table' => $this->getTable(), @@ -272,6 +280,7 @@ function defineTabs($options = []) { $ong = []; $this->addDefaultFormTab($ong); + $this->addImpactTab($ong, $options); $this->addStandardTab('PluginDatabasesDatabase_Item', $ong, $options); $this->addStandardTab('PluginDatabasesInstance', $ong, $options); $this->addStandardTab('PluginDatabasesScript', $ong, $options); @@ -394,10 +403,10 @@ function showForm($ID, $options = []) { echo ""; echo ""; - echo "" . __('Link') . ""; + echo "" . __('URL') . ""; echo ""; Html::autocompletionTextField($this, "link"); - echo " "; + echo " "; echo ""; echo ""; @@ -458,7 +467,7 @@ static function dropdownDatabase($options = []) { $p[$key] = $val; } } - $dbu = new DbUtils(); + $dbu = new DbUtils(); $where = " WHERE `glpi_plugin_databases_databases`.`is_deleted` = '0' " . $dbu->getEntitiesRestrictRequest("AND", "glpi_plugin_databases_databases", '', $p['entity'], true); @@ -477,7 +486,7 @@ static function dropdownDatabase($options = []) { $values = [0 => Dropdown::EMPTY_VALUE]; - while ($data = $DB->fetch_assoc($result)) { + while ($data = $DB->fetchAssoc($result)) { $values[$data['id']] = $data['name']; } $rand = mt_rand(); @@ -512,10 +521,10 @@ static function dropdownDatabase($options = []) { /** * For other plugins, add a type to the linkable types * - * @since version 1.3.0 - * * @param $type string class name - **/ + **@since version 1.3.0 + * + */ static function registerType($type) { if (!in_array($type, self::$types)) { self::$types[] = $type; @@ -595,7 +604,7 @@ function showPluginFromSupplier($ID, $withtemplate = '') { echo ""; - while ($data = $DB->fetch_array($result)) { + while ($data = $DB->fetchArray($result)) { echo ""; if ($withtemplate != 3 && $canread && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["is_recursive"])) { @@ -624,13 +633,13 @@ function showPluginFromSupplier($ID, $withtemplate = '') { } /** + * @param null $checkitem + * + * @return array * @since version 0.85 * * @see CommonDBTM::getSpecificMassiveActions() * - * @param null $checkitem - * - * @return array */ function getSpecificMassiveActions($checkitem = null) { $isadmin = static::canUpdate(); @@ -652,13 +661,13 @@ function getSpecificMassiveActions($checkitem = null) { } /** + * @param MassiveAction $ma + * + * @return bool|false * @since version 0.85 * * @see CommonDBTM::showMassiveActionsSubForm() * - * @param MassiveAction $ma - * - * @return bool|false */ static function showMassiveActionsSubForm(MassiveAction $ma) { @@ -700,15 +709,15 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { /** - * @since version 0.85 - * - * @see CommonDBTM::processMassiveActionsForOneItemtype() - * * @param MassiveAction $ma * @param CommonDBTM $item * @param array $ids * * @return nothing|void + * @since version 0.85 + * + * @see CommonDBTM::processMassiveActionsForOneItemtype() + * */ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { diff --git a/inc/database_item.class.php b/inc/database_item.class.php index 04845e3..8f74266 100644 --- a/inc/database_item.class.php +++ b/inc/database_item.class.php @@ -181,7 +181,7 @@ function getFromDBbyDatabasesAndItem($plugin_databases_databases_id, $items_id, if ($DB->numrows($result) != 1) { return false; } - $this->fields = $DB->fetch_assoc($result); + $this->fields = $DB->fetchAssoc($result); if (is_array($this->fields) && count($this->fields)) { return true; } else { @@ -344,7 +344,7 @@ public static function showForDatabase(PluginDatabasesDatabase $database) { Session::initNavigateListItems($itemType, PluginDatabasesDatabase::getTypeName(2) . " = " . $database->fields['name']); - while ($data = $DB->fetch_assoc($result_linked)) { + while ($data = $DB->fetchAssoc($result_linked)) { $item->getFromDB($data["id"]); @@ -453,7 +453,7 @@ static function showForItem(CommonDBTM $item, $withtemplate = '') { $database = new PluginDatabasesDatabase(); $used = []; if ($numrows = $DB->numrows($result)) { - while ($data = $DB->fetch_assoc($result)) { + while ($data = $DB->fetchAssoc($result)) { $databases[$data['assocID']] = $data; $used[$data['id']] = $data['id']; } diff --git a/inc/databasetype.class.php b/inc/databasetype.class.php index d338c8e..95f6592 100644 --- a/inc/databasetype.class.php +++ b/inc/databasetype.class.php @@ -69,7 +69,7 @@ static function transfer($ID, $entity) { if ($result = $DB->query($query)) { if ($DB->numrows($result)) { - $data = $DB->fetch_assoc($result); + $data = $DB->fetchAssoc($result); $data = Toolbox::addslashes_deep($data); $input['name'] = $data['name']; $input['entities_id'] = $entity; diff --git a/inc/instance.class.php b/inc/instance.class.php index 2fdd47d..a8f345c 100644 --- a/inc/instance.class.php +++ b/inc/instance.class.php @@ -272,7 +272,7 @@ function showInstances(PluginDatabasesDatabase $database) { $i = 0; $row_num = 1; - while ($data = $DB->fetch_array($result)) { + while ($data = $DB->fetchArray($result)) { Session::addToNavigateListItems($this->getType(), $data['id']); diff --git a/inc/menu.class.php b/inc/menu.class.php index feb5ee2..87ca942 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -53,10 +53,15 @@ static function getMenuContent() { if (PluginDatabasesDatabase::canCreate()) { $menu['links']['add'] = PluginDatabasesDatabase::getFormURL(false); } + $menu['icon'] = self::getIcon(); return $menu; } + static function getIcon() { + return "fas fa-database"; + } + static function removeRightsFromSession() { if (isset($_SESSION['glpimenu']['assets']['types']['PluginDatabasesMenu'])) { unset($_SESSION['glpimenu']['assets']['types']['PluginDatabasesMenu']); diff --git a/inc/script.class.php b/inc/script.class.php index 46ddf24..153fea2 100644 --- a/inc/script.class.php +++ b/inc/script.class.php @@ -269,7 +269,7 @@ function showScripts(PluginDatabasesDatabase $database) { $i = 0; $row_num = 1; - while ($data = $DB->fetch_array($result)) { + while ($data = $DB->fetchArray($result)) { Session::addToNavigateListItems($this->getType(), $data['id']); diff --git a/setup.php b/setup.php index 1dcfc69..8588e3d 100644 --- a/setup.php +++ b/setup.php @@ -27,11 +27,11 @@ -------------------------------------------------------------------------- */ -define('PLUGIN_DATABASES_VERSION', '2.2.2'); +define('PLUGIN_DATABASES_VERSION', '2.3.0'); // Init the hooks of the plugins -Needed function plugin_init_databases() { - global $PLUGIN_HOOKS; + global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['databases'] = true; $PLUGIN_HOOKS['change_profile']['databases'] = ['PluginDatabasesProfile', 'initProfile']; @@ -41,6 +41,7 @@ function plugin_init_databases() { //$PLUGIN_HOOKS['assign_to_ticket_itemtype']['databases'] = array('PluginDatabasesDatabase_Item'); Plugin::registerClass('PluginDatabasesDatabase', [ + 'asset_types' => true, 'linkgroup_types' => true, 'linkgroup_tech_types' => true, 'linkuser_tech_types' => true, @@ -49,6 +50,9 @@ function plugin_init_databases() { 'helpdesk_visible_types' => true, 'addtabon' => 'Supplier' ]); + + $CFG_GLPI['impact_asset_types']['PluginDatabasesDatabase'] = "plugins/databases/databases.png"; + Plugin::registerClass('PluginDatabasesProfile', ['addtabon' => 'Profile']); @@ -92,15 +96,15 @@ function plugin_init_databases() { function plugin_version_databases() { return [ - 'name' => _n('Database', 'Databases', 2, 'databases'), - 'version' => PLUGIN_DATABASES_VERSION, - 'author' => "Infotel", - 'oldname' => 'sgbd', - 'license' => 'GPLv2+', - 'homepage' => 'https://github.com/InfotelGLPI/databases', - 'requirements' => [ + 'name' => _n('Database', 'Databases', 2, 'databases'), + 'version' => PLUGIN_DATABASES_VERSION, + 'author' => "Infotel", + 'oldname' => 'sgbd', + 'license' => 'GPLv2+', + 'homepage' => 'https://github.com/InfotelGLPI/databases', + 'requirements' => [ 'glpi' => [ - 'min' => '9.4', + 'min' => '9.5', 'dev' => false ] ] @@ -112,10 +116,10 @@ function plugin_version_databases() { * @return bool */ function plugin_databases_check_prerequisites() { - if (version_compare(GLPI_VERSION, '9.4', 'lt') - || version_compare(GLPI_VERSION, '9.5', 'ge')) { + if (version_compare(GLPI_VERSION, '9.5', 'lt') + || version_compare(GLPI_VERSION, '9.6', 'ge')) { if (method_exists('Plugin', 'messageIncompatible')) { - echo Plugin::messageIncompatible('core', '9.4'); + echo Plugin::messageIncompatible('core', '9.5'); } return false; }