@@ -155,39 +155,57 @@ function plugin_tasklists_uninstall()
155155 $ DB ->doQuery ("DROP TABLE IF EXISTS ` $ table`; " );
156156 }
157157
158- $ tables_glpi = ["glpi_displaypreferences " ,
159- "glpi_notepads " ,
160- "glpi_savedsearches " ,
161- "glpi_items_kanbans " ,
162- "glpi_logs " ,
163- "glpi_documents_items " ];
164-
165- foreach ($ tables_glpi as $ table_glpi ) {
166- $ DB ->doQuery ("DELETE FROM ` $ table_glpi` WHERE `itemtype` LIKE 'GlpiPlugin\Tasklists\Task%'; " );
158+ $ itemtypes = ['Alert ' ,
159+ 'DisplayPreference ' ,
160+ 'Document_Item ' ,
161+ 'ImpactItem ' ,
162+ 'Item_Ticket ' ,
163+ 'Item_Kanban ' ,
164+ 'Link_Itemtype ' ,
165+ 'Notepad ' ,
166+ 'SavedSearch ' ,
167+ 'DropdownTranslation ' ,
168+ 'NotificationTemplate ' ,
169+ 'Notification ' ];
170+ foreach ($ itemtypes as $ itemtype ) {
171+ $ item = new $ itemtype ;
172+ $ item ->deleteByCriteria (['itemtype ' => Task::class]);
167173 }
168174
169- $ notif = new Notification ();
170-
171- $ options = [ ' itemtype ' => Task::class,
172- ' FIELDS ' => 'id ' ];
173- foreach ( $ DB -> request ( ' glpi_notifications ' , $ options ) as $ data ) {
175+ $ notif = new Notification ();
176+ $ options = [ ' itemtype ' => Task::class];
177+ foreach ( $ DB -> request ([
178+ ' FROM ' => 'glpi_notifications ' ,
179+ ' WHERE ' => $ options] ) as $ data ) {
174180 $ notif ->delete ($ data );
175181 }
176182
177- //templates
178- $ template = new NotificationTemplate ();
179- $ translation = new NotificationTemplateTranslation ();
180- $ options = ['itemtype ' => Task::class,
181- 'FIELDS ' => 'id ' ];
182- foreach ($ DB ->request ('glpi_notificationtemplates ' , $ options ) as $ data ) {
183- $ options_template = ['notificationtemplates_id ' => $ data ['id ' ],
184- 'FIELDS ' => 'id ' ];
185-
186- foreach ($ DB ->request ('glpi_notificationtemplatetranslations ' , $ options_template ) as $ data_template ) {
183+ //templates
184+ $ template = new NotificationTemplate ();
185+ $ translation = new NotificationTemplateTranslation ();
186+ $ notif_template = new Notification_NotificationTemplate ();
187+ $ options = ['itemtype ' => Task::class];
188+ foreach ($ DB ->request ([
189+ 'FROM ' => 'glpi_notificationtemplates ' ,
190+ 'WHERE ' => $ options ]) as $ data ) {
191+ $ options_template = [
192+ 'notificationtemplates_id ' => $ data ['id ' ]
193+ ];
194+
195+ foreach ($ DB ->request ([
196+ 'FROM ' => 'glpi_notificationtemplatetranslations ' ,
197+ 'WHERE ' => $ options_template ]) as $ data_template ) {
187198 $ translation ->delete ($ data_template );
188199 }
189200 $ template ->delete ($ data );
201+
202+ foreach ($ DB ->request ([
203+ 'FROM ' => 'glpi_notifications_notificationtemplates ' ,
204+ 'WHERE ' => $ options_template ]) as $ data_template ) {
205+ $ notif_template ->delete ($ data_template );
206+ }
190207 }
208+
191209 //Delete rights associated with the plugin
192210 $ profileRight = new ProfileRight ();
193211 foreach (Profile::getAllRights () as $ right ) {
0 commit comments