Skip to content

Commit 4ff2874

Browse files
committed
Add display preferences migration
Bump version
1 parent 2000124 commit 4ff2874

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

hook.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,79 @@ function plugin_tasklists_install()
128128
// Add record notification
129129
call_user_func([NotificationTargetTask::class, 'install']);
130130

131+
//DisplayPreferences Migration
132+
$classes = ['PluginTasklistsTask' => Task::class,
133+
'PluginTasklistsTaskType' => TaskType::class];
134+
135+
foreach ($classes as $old => $new) {
136+
$displayusers = $DB->request([
137+
'SELECT' => [
138+
'users_id'
139+
],
140+
'DISTINCT' => true,
141+
'FROM' => 'glpi_displaypreferences',
142+
'WHERE' => [
143+
'itemtype' => $old,
144+
],
145+
]);
146+
147+
if (count($displayusers) > 0) {
148+
foreach ($displayusers as $displayuser) {
149+
$iterator = $DB->request([
150+
'SELECT' => [
151+
'num',
152+
'id'
153+
],
154+
'FROM' => 'glpi_displaypreferences',
155+
'WHERE' => [
156+
'itemtype' => $old,
157+
'users_id' => $displayuser['users_id'],
158+
'interface' => 'central'
159+
],
160+
]);
161+
162+
if (count($iterator) > 0) {
163+
foreach ($iterator as $data) {
164+
$iterator2 = $DB->request([
165+
'SELECT' => [
166+
'id'
167+
],
168+
'FROM' => 'glpi_displaypreferences',
169+
'WHERE' => [
170+
'itemtype' => $new,
171+
'users_id' => $displayuser['users_id'],
172+
'num' => $data['num'],
173+
'interface' => 'central'
174+
],
175+
]);
176+
if (count($iterator2) > 0) {
177+
foreach ($iterator2 as $dataid) {
178+
$query = $DB->buildDelete(
179+
'glpi_displaypreferences',
180+
[
181+
'id' => $dataid['id'],
182+
]
183+
);
184+
$DB->doQuery($query);
185+
}
186+
} else {
187+
$query = $DB->buildUpdate(
188+
'glpi_displaypreferences',
189+
[
190+
'itemtype' => $new,
191+
],
192+
[
193+
'id' => $data['id'],
194+
]
195+
);
196+
$DB->doQuery($query);
197+
}
198+
}
199+
}
200+
}
201+
}
202+
}
203+
131204
Profile::initProfile();
132205
Profile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
133206

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
use GlpiPlugin\Tasklists\Ticket;
3737
use GlpiPlugin\Tasklists\Task;
3838

39-
define('PLUGIN_TASKLISTS_VERSION', '2.1.2');
39+
define('PLUGIN_TASKLISTS_VERSION', '2.1.3');
4040

4141
if (!defined("PLUGIN_TASKLISTS_DIR")) {
4242
define("PLUGIN_TASKLISTS_DIR", Plugin::getPhpDir("tasklists"));

tasklists.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
<author>Infotel</author>
2626
</authors>
2727
<versions>
28+
<version>
29+
<num>2.1.3</num>
30+
<compatibility>~11.0</compatibility>
31+
<download_url>https://github.com/InfotelGLPI/tasklists/releases/download/2.1.3/glpi-tasklists-2.1.3.tar.bz2</download_url>
32+
</version>
2833
<version>
2934
<num>2.1.2</num>
3035
<compatibility>~11.0</compatibility>

0 commit comments

Comments
 (0)