Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #2170 (selectable single parent category) #2183

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion oc-includes/osclass/frm/Item.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<optgroup label="' . $c['s_name'] . '">';
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 '<option value="' . $c['pk_i_id'] . '"' . ($selected ? ' selected="selected"' : '' ). '>' . $c['s_name'] . '</option>';
}
} else {
$selected = ( (isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id']) || (isset($catId) && $catId == $c['pk_i_id']) );
Expand Down
9 changes: 6 additions & 3 deletions oc-includes/osclass/helpers/hValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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)) {
Expand Down