@@ -32,15 +32,50 @@ public function install()
32
32
}
33
33
}
34
34
35
- /**
36
- * Example: Run an external SQL script when the module is uninstalled.
37
- */
38
- public function uninstall ()
39
- {
40
- // TODO: Remove civioffice_live_snippets option group.
41
- // TODO: Remove settings created by this extension.
42
- // TODO: Clean-up file cache (rendered files), using a cleanup interface.
35
+ public function uninstall () {
36
+ // Remove settings created by this extension.
37
+ Civi::settings ()->revert (CRM_Civioffice_DocumentStore_Local::LOCAL_TEMP_PATH_SETTINGS_KEY );
38
+ Civi::settings ()->revert (CRM_Civioffice_DocumentStore_Local::LOCAL_STATIC_PATH_SETTINGS_KEY );
39
+ Civi::settings ()->revert (CRM_Civioffice_DocumentStore_Upload::UPLOAD_PRIVATE_ENABLED_SETTINGS_KEY );
40
+ Civi::settings ()->revert (CRM_Civioffice_DocumentStore_Upload::UPLOAD_PUBLIC_ENABLED_SETTINGS_KEY );
41
+
42
+ // Revert contact settings for each live snippet.
43
+ $ liveSnippetNames = \Civi \Api4 \OptionValue::get (FALSE )
44
+ ->addSelect ('name ' )
45
+ ->addWhere ('option_group_id.name ' , '= ' , 'civioffice_live_snippets ' )
46
+ ->execute ()
47
+ ->column ('name ' );
48
+
49
+ // Revert/delete contact settings.
50
+ $ contactSettingsLike = implode (
51
+ ' OR ' ,
52
+ [
53
+ CRM_Civioffice_Form_DocumentFromSingleContact::UNOCONV_CREATE_SINGLE_ACTIVIY_ATTACHMENT ,
54
+ CRM_Civioffice_Form_DocumentFromSingleContact::UNOCONV_CREATE_SINGLE_ACTIVIY_TYPE ,
55
+ 'civioffice_create_%_activity_type ' ,
56
+ 'civioffice.create_%.activity_type_id ' ,
57
+ ]
58
+ + array_map (fn ($ liveSnippetName ) => "civioffice.live_snippets. {$ liveSnippetName }" , $ liveSnippetNames )
59
+ );
60
+ // Civi::contactSettings()->revert() does not support reverting for all contacts.
61
+ CRM_Core_DAO::executeQuery (
62
+ <<<SQL
63
+ DELETE FROM `civicrm_setting` WHERE `name` LIKE ' {$ contactSettingsLike }';
64
+ SQL
65
+ );
66
+
67
+ // Remove "civioffice_live_snippets" option group.
68
+ \Civi \Api4 \OptionGroup::delete (FALSE )
69
+ ->addWhere ('name ' , '= ' , 'civioffice_live_snippets ' )
70
+ ->execute ();
71
+
72
+ // Revert renderer settings.
73
+ foreach ((array ) Civi::settings ()->get ('civioffice_renderers ' ) as $ renderer_uri => $ renderer_name ) {
74
+ Civi::settings ()->revert ('civioffice_renderer_ ' . $ renderer_uri );
43
75
}
76
+ Civi::settings ()->revert ('civioffice_renderers ' );
77
+ // TODO: Clean-up file cache (temporary rendered files), using a cleanup interface.
78
+ }
44
79
45
80
/**
46
81
* Support Live Snippets.
0 commit comments