diff --git a/cosmogramme/sql/patch/patch_279.php b/cosmogramme/sql/patch/patch_279.php new file mode 100644 index 0000000000000000000000000000000000000000..cf912d874623fe762fac494f0ba5807a6081cba8 --- /dev/null +++ b/cosmogramme/sql/patch/patch_279.php @@ -0,0 +1,32 @@ +<?php +$ids_module = [1, 2, 3]; +$profil = Class_Profil::find(2048); + +foreach ($ids_module as $id) { + $preferences = $profil->getModuleAccueilConfig($id, 'SITO')['preferences']; + + $group = $preferences['group_by_categorie']; + $type = $preferences['type_aff']; + $order = $preferences['display_order']; + unset($preferences['group_by_categorie']); + + if ($group) + $preferences['type_aff'] = 2; + + if ($type == 2) { + $preferences['type_aff'] = 1; + $preferences['display_order'] = 'Recent'; + } + + if ($type == 2 && $group) { + $preferences['type_aff'] = 2; + $preferences['display_order'] = 'Recent'; + } + + $module_config['preferences'] = $preferences; + + $profil + ->updateModuleConfigAccueil($id, $module_config) + ->save(); +} +?> diff --git a/tests/fixtures/SitoPreferencesSerialize.txt b/tests/fixtures/SitoPreferencesSerialize.txt new file mode 100644 index 0000000000000000000000000000000000000000..7e409adb89f9866a663ce346ffb060bba88a0b97 --- /dev/null +++ b/tests/fixtures/SitoPreferencesSerialize.txt @@ -0,0 +1 @@ +a:4:{s:7:"modules";a:3:{i:3;a:3:{s:11:"type_module";s:4:"SITO";s:11:"preferences";a:11:{s:5:"titre";s:14:"GROUPED recent";s:8:"type_aff";s:1:"2";s:12:"id_categorie";s:3:"2-3";s:8:"id_items";s:0:"";s:6:"nb_aff";s:2:"10";s:3:"rss";s:1:"0";s:18:"group_by_categorie";s:1:"1";s:13:"display_order";s:6:"Random";s:5:"boite";s:0:"";s:9:"id_module";s:1:"3";s:7:"Valider";s:7:"Valider";}s:8:"division";s:1:"2";}i:1;a:3:{s:11:"type_module";s:4:"SITO";s:11:"preferences";a:11:{s:5:"titre";s:12:"PAGED recent";s:8:"type_aff";s:1:"2";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"5";s:3:"rss";s:1:"0";s:18:"group_by_categorie";s:1:"0";s:13:"display_order";s:6:"Random";s:5:"boite";s:0:"";s:9:"id_module";s:1:"1";s:7:"Valider";s:7:"Valider";}s:8:"division";s:1:"2";}i:2;a:3:{s:11:"type_module";s:4:"SITO";s:11:"preferences";a:11:{s:5:"titre";s:14:"GROUPED random";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:3:"3-2";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"2";s:3:"rss";s:1:"0";s:18:"group_by_categorie";s:1:"1";s:13:"display_order";s:6:"Random";s:5:"boite";s:0:"";s:9:"id_module";s:1:"2";s:7:"Valider";s:7:"Valider";}s:8:"division";s:1:"2";}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}