Skip to content

Commit 3eddf82

Browse files
committed
GLPI v11 compatibility fix
1 parent f74607b commit 3eddf82

10 files changed

Lines changed: 1678 additions & 98 deletions

dataflows.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
<author>Eric Feron</author>
2525
</authors>
2626
<versions>
27+
<version>
28+
<num>3.0.14</num>
29+
<compatibility>~10.0.0 || ~11.0.0</compatibility>
30+
<download_url>https://github.com/ericferon/glpi-dataflows/releases/download/v3.0.14/dataflows-v3.0.14.tar.gz</download_url>
31+
</version>
2732
<version>
2833
<num>3.0.13</num>
2934
<compatibility>~10.0.0</compatibility>

hook.php

Lines changed: 56 additions & 56 deletions
Large diffs are not rendered by default.

inc/dataflow.class.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ static function getTypeName($nb=0) {
4141
return _n('Dataflow', 'Dataflows', $nb, 'dataflows');
4242
}
4343

44-
public static function canCreate() {
44+
/* public static function canCreate(): bool {
4545
return Session::haveRight(static::$rightname, UPDATE);
4646
}
4747
48-
public static function canView() {
48+
public static function canView(): bool {
4949
return Session::haveRight(static::$rightname, READ);
5050
}
51-
51+
*/
5252
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
5353

5454
if ($item->getType()=='Supplier') {
@@ -107,7 +107,7 @@ function rawSearchOptions() {
107107

108108
$linktable = [];
109109
$tablequery = "SELECT * FROM `glpi_plugin_dataflows_configdflinks`";
110-
$tableresult = $DB->query($tablequery);
110+
$tableresult = $DB->doQuery($tablequery);
111111
while ($tabledata = $DB->fetchAssoc($tableresult)) {
112112
$linktable[$tabledata['id']]['name'] = $tabledata['name'];
113113
$linktable[$tabledata['id']]['has_dropdown'] = $tabledata['has_dropdown'];
@@ -116,7 +116,7 @@ function rawSearchOptions() {
116116

117117
$datatypetable = [];
118118
$datatypequery = "SELECT * FROM `glpi_plugin_dataflows_configdfdatatypes`";
119-
$datatyperesult = $DB->query($datatypequery);
119+
$datatyperesult = $DB->doQuery($datatypequery);
120120
while ($datatypedata = $DB->fetchAssoc($datatyperesult)) {
121121
$datatypetable[$datatypedata['id']]['name'] = $datatypedata['name'];
122122
}
@@ -125,7 +125,7 @@ function rawSearchOptions() {
125125
FROM `glpi_plugin_dataflows_configdfs`
126126
WHERE `is_deleted` = 0
127127
ORDER BY `id`";
128-
$fieldresult = $DB->query($fieldquery);
128+
$fieldresult = $DB->doQuery($fieldquery);
129129
$rowcount = $DB->numrows($fieldresult);
130130
$tabid = 1; // tabid 1 is used for name
131131
$tabtable = $this->getTable();
@@ -304,7 +304,7 @@ function showForm ($ID, $options=[]) {
304304
$columnquery = "SELECT *
305305
FROM `glpi_plugin_dataflows_configdfs`
306306
WHERE `is_deleted` = 0 AND `plugin_dataflows_configdfhaligns_id` in (3,4,5)";
307-
$columnresult = $DB->query($columnquery);
307+
$columnresult = $DB->doQuery($columnquery);
308308
$rowcount = $DB->numrows($columnresult);
309309
if ($rowcount == 0) {
310310
$columncount = 4;
@@ -333,7 +333,7 @@ function showForm ($ID, $options=[]) {
333333

334334
$linktable = [];
335335
$tablequery = "SELECT * FROM `glpi_plugin_dataflows_configdflinks`";
336-
$tableresult = $DB->query($tablequery);
336+
$tableresult = $DB->doQuery($tablequery);
337337
while ($tabledata = $DB->fetchAssoc($tableresult)) {
338338
$linktable[$tabledata['id']]['name'] = $tabledata['name'];
339339
$linktable[$tabledata['id']]['has_dropdown'] = $tabledata['has_dropdown'];
@@ -344,7 +344,7 @@ function showForm ($ID, $options=[]) {
344344
FROM `glpi_plugin_dataflows_configdfs`
345345
WHERE `is_deleted` = 0 AND `plugin_dataflows_configdffieldgroups_id` = 0
346346
ORDER BY `row`, `plugin_dataflows_configdfhaligns_id`";
347-
$fieldresult = $DB->query($fieldquery);
347+
$fieldresult = $DB->doQuery($fieldquery);
348348
$rowcount = $DB->numrows($fieldresult);
349349
if ($rowcount > 0) {
350350
$fgroupname = '';
@@ -453,7 +453,7 @@ function showForm ($ID, $options=[]) {
453453
$fgroupquery = "SELECT *
454454
FROM `glpi_plugin_dataflows_configdffieldgroups`
455455
ORDER BY `sortorder`";
456-
$fgroupresult = $DB->query($fgroupquery);
456+
$fgroupresult = $DB->doQuery($fgroupquery);
457457

458458
while ($fgroupdata = $DB->fetchAssoc($fgroupresult)) {
459459
$fgroupid = $fgroupdata['id'];
@@ -465,7 +465,7 @@ function showForm ($ID, $options=[]) {
465465
FROM `glpi_plugin_dataflows_configdfs`
466466
WHERE `is_deleted` = 0 AND `plugin_dataflows_configdffieldgroups_id` = $fgroupid
467467
ORDER BY `row`, `plugin_dataflows_configdfhaligns_id`";
468-
$fieldresult = $DB->query($fieldquery);
468+
$fieldresult = $DB->doQuery($fieldquery);
469469
$rowcount = $DB->numrows($fieldresult);
470470
if ($rowcount > 0) {
471471
// Accordion separator
@@ -700,7 +700,7 @@ static function dropdownDataflow($options=[]) {
700700
FROM `glpi_plugin_dataflows_dataflows`
701701
$where)
702702
ORDER BY `name`";
703-
$result = $DB->query($query);
703+
$result = $DB->doQuery($query);
704704

705705
$values = [0 => Dropdown::EMPTY_VALUE];
706706

@@ -793,7 +793,7 @@ function showPluginFromSupplier($ID,$withtemplate='') {
793793
. getEntitiesRestrictRequest(" AND ","glpi_plugin_dataflows_dataflows",'','',$this->maybeRecursive());
794794
$query.= " ORDER BY `glpi_plugin_dataflows_dataflows`.`name` ";
795795

796-
$result = $DB->query($query);
796+
$result = $DB->doQuery($query);
797797
$number = $DB->numrows($result);
798798

799799
if (Session::isMultiEntitiesMode()) {

inc/dataflow_item.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function getFromDBbyDataflowsAndItem($plugin_dataflows_dataflows_id,$items_id,$i
153153
"WHERE `plugin_dataflows_dataflows_id` = '" . $plugin_dataflows_dataflows_id . "'
154154
AND `itemtype` = '" . $items_id . "'
155155
AND `items_id` = '" . $itemtype . "'";
156-
if ($result = $DB->query($query)) {
156+
if ($result = $DB->doQuery($query)) {
157157
if ($DB->numrows($result) != 1) {
158158
return false;
159159
}
@@ -216,7 +216,7 @@ public static function showForDataflow(PluginDataflowsDataflow $dataflow) {
216216
ORDER BY `itemtype`
217217
LIMIT ".count(PluginDataflowsDataflow::getTypes(true));
218218

219-
$result = $DB->query($query);
219+
$result = $DB->doQuery($query);
220220
$number = $DB->numrows($result);
221221

222222
if (Session::isMultiEntitiesMode()) {
@@ -302,7 +302,7 @@ public static function showForDataflow(PluginDataflowsDataflow $dataflow) {
302302
}
303303
$query.=" ORDER BY `glpi_entities`.`completename`, `".$itemTable."`.`$column`";
304304

305-
if ($result_linked=$DB->query($query)) {
305+
if ($result_linked=$DB->doQuery($query)) {
306306
if ($DB->numrows($result_linked)) {
307307

308308
Session::initNavigateListItems($itemType,PluginDataflowsDataflow::getTypeName(2)." = ".$dataflow->fields['name']);
@@ -403,7 +403,7 @@ static function showForItem(CommonDBTM $item, $withtemplate='') {
403403

404404
$query .= " ORDER BY `assocName`";
405405

406-
$result = $DB->query($query);
406+
$result = $DB->doQuery($query);
407407
$number = $DB->numrows($result);
408408
$i = 0;
409409

@@ -440,7 +440,7 @@ static function showForItem(CommonDBTM $item, $withtemplate='') {
440440
WHERE `is_deleted` = '0'
441441
$limit";
442442

443-
$result = $DB->query($q);
443+
$result = $DB->doQuery($q);
444444
$nb = $DB->result($result,0,0);
445445

446446
echo "<div class='firstbloc'>";

inc/profile.class.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ static function migrateOneProfile($profiles_id) {
193193
return true;
194194
}
195195

196-
foreach ($DB->request('glpi_plugin_dataflows_profiles',
197-
"`profiles_id`='$profiles_id'") as $profile_data) {
196+
foreach ($DB->request(['FROM' => 'glpi_plugin_dataflows_profiles',
197+
'WHERE' => ['profiles_id' => $profiles_id]]) as $profile_data) {
198198

199199
$matching = ['dataflows' => 'plugin_dataflows',
200200
'open_ticket' => 'plugin_dataflows_open_ticket'];
@@ -204,7 +204,7 @@ static function migrateOneProfile($profiles_id) {
204204
$query = "UPDATE `glpi_profilerights`
205205
SET `rights`='".self::translateARight($profile_data[$old])."'
206206
WHERE `name`='$new' AND `profiles_id`='$profiles_id'";
207-
$DB->query($query);
207+
$DB->doQuery($query);
208208
}
209209
}
210210
}
@@ -227,13 +227,15 @@ static function initProfile() {
227227
}
228228

229229
//Migration old rights in new ones
230-
foreach ($DB->request("SELECT `id` FROM `glpi_profiles`") as $prof) {
230+
foreach ($DB->request(['SELECT'=> 'id',
231+
'FROM' => 'glpi_profiles']
232+
) as $prof) {
231233
self::migrateOneProfile($prof['id']);
232234
}
233-
foreach ($DB->request("SELECT *
234-
FROM `glpi_profilerights`
235-
WHERE `profiles_id`='".$_SESSION['glpiactiveprofile']['id']."'
236-
AND `name` LIKE '%plugin_dataflows%'") as $prof) {
235+
foreach ($DB->request(['FROM' => 'glpi_profilerights',
236+
'WHERE' => ['profiles_id' => $_SESSION['glpiactiveprofile']['id'],
237+
'name' => ['LIKE', '%plugin_dataflows%']]]
238+
) as $prof) {
237239
$_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights'];
238240
}
239241
}

setup.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
along with Dataflows. If not, see <http://www.gnu.org/licenses/>.
2424
--------------------------------------------------------------------------
2525
*/
26+
define('PLUGIN_DATAFLOWS_VERSION', '3.0.14');
27+
28+
// Minimal GLPI version, inclusive
29+
define('PLUGIN_DATAFLOWS_MIN_GLPI', '10.0.0');
30+
// Maximum GLPI version, exclusive
31+
define('PLUGIN_DATAFLOWS_MAX_GLPI', '11.0.99');
2632

2733
// Init the hooks of the plugins -Needed
2834
function plugin_init_dataflows() {
@@ -123,14 +129,15 @@ function plugin_version_dataflows() {
123129

124130
return array (
125131
'name' => _n('Dataflow', 'Dataflows', 2, 'dataflows'),
126-
'version' => '3.0.13',
132+
'version' => PLUGIN_DATAFLOWS_VERSION,
127133
'author' => "Eric Feron",
128134
'license' => 'GPLv2+',
129135
'homepage'=> 'https://github.com/ericferon/glpi-dataflows',
130136
'requirements' => [
131137
'glpi' => [
132-
'min' => '9.5',
133-
'dev' => false
138+
'min' => PLUGIN_DATAFLOWS_MIN_GLPI,
139+
'max' => PLUGIN_DATAFLOWS_MAX_GLPI,
140+
// 'dev' => false
134141
]
135142
]
136143
);
@@ -140,21 +147,13 @@ function plugin_version_dataflows() {
140147
// Optional : check prerequisites before install : may print errors or add to message after redirect
141148
function plugin_dataflows_check_prerequisites() {
142149
global $DB;
143-
if (version_compare(GLPI_VERSION, '10.0', 'lt')
144-
|| version_compare(GLPI_VERSION, '10.1', 'ge')) {
145-
if (method_exists('Plugin', 'messageIncompatible')) {
146-
echo Plugin::messageIncompatible('core', '10.0');
147-
}
148-
return false;
149-
} else {
150150
$query = "select * from glpi_plugins where directory in ('archisw', 'statecheck') and state = 1";
151-
$result_query = $DB->query($query);
151+
$result_query = $DB->doQuery($query);
152152
if($DB->numRows($result_query) == 2) {
153153
return true;
154154
} else {
155155
echo "The 2 plugins 'archisw' (a.k.a Apps structure inventory) and 'statecheck' must be installed before using 'dataflows' (Dataflows)";
156156
}
157-
}
158157
}
159158

160159
// Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
@@ -179,7 +178,7 @@ function hook_pre_item_add_dataflows_configdf(CommonDBTM $item) {
179178
if($item->fields['plugin_dataflows_configdfdatatypes_id'] == 6) {// if dropdown, add key
180179
$query .= ", ADD KEY IF NOT EXISTS $fieldname ($fieldname)";
181180
}
182-
$result = $DB->query($query);
181+
$result = $DB->doQuery($query);
183182
return true;
184183
}
185184
return false;
@@ -199,7 +198,7 @@ function hook_pre_item_update_dataflows_configdf(CommonDBTM $item) {
199198
if($item->input['plugin_dataflows_configdfdatatypes_id'] == 6) {// if dropdown, add key
200199
$query .= ", ADD KEY IF NOT EXISTS $newfieldname ($newfieldname)";
201200
}
202-
$result = $DB->query($query);
201+
$result = $DB->doQuery($query);
203202
return true;
204203
}
205204
return false;
@@ -210,10 +209,10 @@ function hook_pre_item_purge_dataflows_configdf(CommonDBTM $item) {
210209
$oldfieldname = $item->fields['name'];
211210
// suppress in glpi_plugin_dataflows_labeltranslations
212211
$query = "DELETE FROM `glpi_plugin_dataflows_labeltranslations` WHERE `items_id` = '".$oldid."'";
213-
$result = $DB->query($query);
212+
$result = $DB->doQuery($query);
214213
// suppress column
215214
$query = "ALTER TABLE `glpi_plugin_dataflows_dataflows` DROP COLUMN IF EXISTS $oldfieldname";
216-
$result = $DB->query($query);
215+
$result = $DB->doQuery($query);
217216
return true;
218217
}
219218
?>

0 commit comments

Comments
 (0)