Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Prepare 9.5 version
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Jun 8, 2020
1 parent 45a479f commit d4b5aa3
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 43 deletions.
16 changes: 11 additions & 5 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"] . "';";
Expand All @@ -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"] . "'
Expand Down Expand Up @@ -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']);
}
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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() . "<br>";
}
Expand Down
47 changes: 28 additions & 19 deletions inc/database.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -394,10 +403,10 @@ function showForm($ID, $options = []) {
echo "</tr>";
echo "<tr class='tab_bg_1'>";

echo "<td>" . __('Link') . "</td>";
echo "<td>" . __('URL') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "link");
echo "&nbsp;<a target='_blank' href='".$this->getField("link")."'><i class=\"fas fa-link\"></i></a>";
echo "&nbsp;<a target='_blank' href='" . $this->getField("link") . "'><i class=\"fas fa-link\"></i></a>";
echo "</td>";

echo "<td></td><td>";
Expand Down Expand Up @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -595,7 +604,7 @@ function showPluginFromSupplier($ID, $withtemplate = '') {

echo "</tr>";

while ($data = $DB->fetch_array($result)) {
while ($data = $DB->fetchArray($result)) {

echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>";
if ($withtemplate != 3 && $canread && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["is_recursive"])) {
Expand Down Expand Up @@ -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();
Expand All @@ -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) {

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions inc/database_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"]);

Expand Down Expand Up @@ -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'];
}
Expand Down
2 changes: 1 addition & 1 deletion inc/databasetype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion inc/instance.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
5 changes: 5 additions & 0 deletions inc/menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion inc/script.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
30 changes: 17 additions & 13 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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,
Expand All @@ -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']);

Expand Down Expand Up @@ -92,15 +96,15 @@ function plugin_init_databases() {
function plugin_version_databases() {

return [
'name' => _n('Database', 'Databases', 2, 'databases'),
'version' => PLUGIN_DATABASES_VERSION,
'author' => "<a href='http://blogglpi.infotel.com'>Infotel</a>",
'oldname' => 'sgbd',
'license' => 'GPLv2+',
'homepage' => 'https://github.com/InfotelGLPI/databases',
'requirements' => [
'name' => _n('Database', 'Databases', 2, 'databases'),
'version' => PLUGIN_DATABASES_VERSION,
'author' => "<a href='http://blogglpi.infotel.com'>Infotel</a>",
'oldname' => 'sgbd',
'license' => 'GPLv2+',
'homepage' => 'https://github.com/InfotelGLPI/databases',
'requirements' => [
'glpi' => [
'min' => '9.4',
'min' => '9.5',
'dev' => false
]
]
Expand All @@ -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;
}
Expand Down

0 comments on commit d4b5aa3

Please sign in to comment.