@@ -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
0 commit comments