diff --git a/oc-includes/osclass/frm/Item.form.class.php b/oc-includes/osclass/frm/Item.form.class.php index 0fa7075456..dba30a2e7e 100755 --- a/oc-includes/osclass/frm/Item.form.class.php +++ b/oc-includes/osclass/frm/Item.form.class.php @@ -54,8 +54,11 @@ 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 { + $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 { $selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) ); diff --git a/oc-includes/osclass/helpers/hValidate.php b/oc-includes/osclass/helpers/hValidate.php index a4d115e3cc..522dc457a2 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) { + 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)) {