From 3f18d39848baaf0300c812a4820c74249e9c9630 Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 12:58:50 +0200 Subject: [PATCH 1/6] fix issue #2170 (selectable parent category) fix issue #2170 (selectable parent category) --- oc-includes/osclass/helpers/hValidate.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/oc-includes/osclass/helpers/hValidate.php b/oc-includes/osclass/helpers/hValidate.php index a4d115e3cc..02ac0c4a6e 100755 --- a/oc-includes/osclass/helpers/hValidate.php +++ b/oc-includes/osclass/helpers/hValidate.php @@ -181,11 +181,14 @@ function osc_validate_location ($city,$sCity,$region,$sRegion,$country,$sCountry function osc_validate_category ($value) { if ( osc_validate_nozero($value) ) { $data = Category::newInstance()->findByPrimaryKey($value); + $subs = Category::newInstance()->findSubcategoriesEnabled($value); if (isset($data['b_enabled']) && $data['b_enabled'] == 1) { - if(osc_selectable_parent_categories()){ + if(osc_selectable_parent_categories()) { return true; } else { - if($data['fk_i_parent_id']!=null) { + if($data['fk_i_parent_id']!=null && count($subs)>0) { + return true; + } else if($data['fk_i_parent_id']==null && count($subs)==0) { return true; } } @@ -267,7 +270,7 @@ function osc_validate_email ($email, $required = true) // Split out the local and domain parts list($local, $domain) = explode('@', $email, 2); - + // LOCAL PART // Test for invalid characters if (!preg_match('/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local)) { From 40935c0afc636fc8fbee54adcd1e5aca040a9ca9 Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 13:03:02 +0200 Subject: [PATCH 2/6] fix issue #2170 (selectable parent category) fix issue #2170 (selectable parent category) --- oc-includes/osclass/frm/Item.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oc-includes/osclass/frm/Item.form.class.php b/oc-includes/osclass/frm/Item.form.class.php index 0fa7075456..5e1a09b960 100755 --- a/oc-includes/osclass/frm/Item.form.class.php +++ b/oc-includes/osclass/frm/Item.form.class.php @@ -54,8 +54,10 @@ static public function category_select($categories = null, $item = null, $defaul foreach($categories as $c) { if ( !osc_selectable_parent_categories() && !$parent_selectable ) { echo ''; - if(isset($c['categories']) && is_array($c['categories'])) { + if(isset($c['categories']) && is_array($c['categories']) && count($c['categories'])>0) { ItemForm::subcategory_select($c['categories'], $item, $default_item, 1); + } else { + echo ''; } } else { $selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) ); From 2199140dffd7c974d329c1662f17c23b5fdc9b6e Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 13:24:04 +0200 Subject: [PATCH 3/6] fix --- oc-includes/osclass/frm/Item.form.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/oc-includes/osclass/frm/Item.form.class.php b/oc-includes/osclass/frm/Item.form.class.php index 5e1a09b960..e0a1acd4a4 100755 --- a/oc-includes/osclass/frm/Item.form.class.php +++ b/oc-includes/osclass/frm/Item.form.class.php @@ -57,6 +57,7 @@ static public function category_select($categories = null, $item = null, $defaul if(isset($c['categories']) && is_array($c['categories']) && count($c['categories'])>0) { ItemForm::subcategory_select($c['categories'], $item, $default_item, 1); } else { + $selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) ); echo ''; } } else { From 8b2a16c87fdad38e94ec3b66d84ba1b06d6dc701 Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 13:25:15 +0200 Subject: [PATCH 4/6] fix tab/space indentation --- oc-includes/osclass/frm/Item.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oc-includes/osclass/frm/Item.form.class.php b/oc-includes/osclass/frm/Item.form.class.php index e0a1acd4a4..dba30a2e7e 100755 --- a/oc-includes/osclass/frm/Item.form.class.php +++ b/oc-includes/osclass/frm/Item.form.class.php @@ -57,7 +57,7 @@ static public function category_select($categories = null, $item = null, $defaul if(isset($c['categories']) && is_array($c['categories']) && count($c['categories'])>0) { ItemForm::subcategory_select($c['categories'], $item, $default_item, 1); } else { - $selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) ); + $selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) ); echo ''; } } else { From d374225f658da60ce01368d0a33abe01e69460ea Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 18:02:14 +0200 Subject: [PATCH 5/6] fix condition fix condition --- oc-includes/osclass/helpers/hValidate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oc-includes/osclass/helpers/hValidate.php b/oc-includes/osclass/helpers/hValidate.php index 02ac0c4a6e..67c14f084f 100755 --- a/oc-includes/osclass/helpers/hValidate.php +++ b/oc-includes/osclass/helpers/hValidate.php @@ -186,7 +186,7 @@ function osc_validate_category ($value) { if(osc_selectable_parent_categories()) { return true; } else { - if($data['fk_i_parent_id']!=null && count($subs)>0) { + if($data['fk_i_parent_id']!=null) { return true; } else if($data['fk_i_parent_id']==null && count($subs)==0) { return true; From 7d9f27f38150bad826ecc740b9958f0336477c31 Mon Sep 17 00:00:00 2001 From: Darko Date: Tue, 25 Apr 2017 18:10:30 +0200 Subject: [PATCH 6/6] space format space format --- oc-includes/osclass/helpers/hValidate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oc-includes/osclass/helpers/hValidate.php b/oc-includes/osclass/helpers/hValidate.php index 67c14f084f..522dc457a2 100755 --- a/oc-includes/osclass/helpers/hValidate.php +++ b/oc-includes/osclass/helpers/hValidate.php @@ -186,9 +186,9 @@ function osc_validate_category ($value) { if(osc_selectable_parent_categories()) { return true; } else { - if($data['fk_i_parent_id']!=null) { + if($data['fk_i_parent_id'] != null) { return true; - } else if($data['fk_i_parent_id']==null && count($subs)==0) { + } else if($data['fk_i_parent_id'] == null && count($subs) == 0) { return true; } }