@@ -1057,23 +1057,22 @@ public function postProcess()
1057
1057
$ post ->id_author = Tools::getValue ('id_author ' );
1058
1058
}
1059
1059
// Categories, products and tags
1060
- // Default category is fully required and cannot be root
1060
+ // Default category cannot be root and defaults to unclassed
1061
1061
$ rootCategory = EverPsBlogCategory::getRootCategory ();
1062
- if (!Tools::getValue ('id_default_category ' )
1063
- || !Validate::isUnsignedInt (Tools::getValue ('id_default_category ' ))
1064
- ) {
1065
- $ this ->errors [] = $ this ->l ('Default category is required ' );
1066
- } elseif ((int ) Tools::getValue ('id_default_category ' ) == (int ) $ rootCategory ->id ) {
1062
+ $ idDefaultCategory = (int ) Tools::getValue ('id_default_category ' );
1063
+ if (!$ idDefaultCategory || !Validate::isUnsignedInt ($ idDefaultCategory )) {
1064
+ $ post ->id_default_category = (int ) $ this ->unclassedCategory ;
1065
+ } elseif ($ idDefaultCategory == (int ) $ rootCategory ->id ) {
1067
1066
$ this ->errors [] = $ this ->l ('Default category cannot be the root category ' );
1068
1067
} else {
1069
- $ post ->id_default_category = Tools:: getValue ( ' id_default_category ' ) ;
1068
+ $ post ->id_default_category = $ idDefaultCategory ;
1070
1069
}
1071
1070
$ post_categories = Tools::getValue ('post_categories ' );
1072
1071
if (!is_array ($ post_categories )) {
1073
1072
$ post_categories = [$ post_categories ];
1074
1073
}
1075
- if (!in_array (Tools:: getValue ( ' id_default_category ' ) , $ post_categories )) {
1076
- $ post_categories [] = (int ) Tools:: getValue ( ' id_default_category ' ) ;
1074
+ if (!in_array ($ post -> id_default_category , $ post_categories )) {
1075
+ $ post_categories [] = (int ) $ post -> id_default_category ;
1077
1076
}
1078
1077
$ post ->post_categories = json_encode ($ post_categories );
1079
1078
$ post ->allowed_groups = json_encode (Tools::getValue ('allowed_groups ' ));
0 commit comments