get_results("SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A); ?>

Target Market Restrictions

  :
0) && (@ini_get('suhosin.post.max_vars') < 500)) { echo "".__("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider. ",'wpsc').""; } else { ?> Select: 'all'))?>' class='wpsc_select_all'>All  'none'))?>' class='wpsc_select_none'>None
".$country['country']."
\n\r"; }else{ echo "".$country['country']."
\n\r"; } } ?>


".__('Select a Product Group', 'wpsc')."\r\n"; $values = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` ORDER BY `id` ASC",ARRAY_A); foreach($values as $option) { if($curent_category == $option['id']) { $selected = "selected='selected'"; } $options .= "\r\n"; $selected = ""; } $concat .= "\r\n"; return $concat; } function display_categories($group_id, $id = null, $level = 0) { global $wpdb,$category_data; if(is_numeric($id)) { $category_sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('$group_id') AND `active`='1' AND `category_parent` = '".$id."' ORDER BY `id`"; $category_list = $wpdb->get_results($category_sql,ARRAY_A); } else { $category_sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `group_id` IN ('$group_id') AND `active`='1' AND `category_parent` = '0' ORDER BY `id`"; $category_list = $wpdb->get_results($category_sql,ARRAY_A); } if($category_list != null) { foreach($category_list as $category) { display_category_row($category, $level); display_categories($group_id, $category['id'], ($level+1)); } } } function display_category_row($category,$subcategory_level = 0) { echo " \n\r"; echo " \n\r"; if($subcategory_level > 0) { echo "
\n\r"; echo " \n\r"; } echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; echo "
\n\r"; if($category['image'] !=null) { echo " ".$category[\n\r"; } else { echo " ".$category[\n\r"; } echo " \n\r"; echo "".htmlentities(stripslashes($category['name']), ENT_QUOTES, 'UTF-8').""; echo " \n\r"; echo " ".__('Edit', 'wpsc')."\n\r"; echo "
\n\r"; if($subcategory_level > 0) { echo "
\n\r"; } echo " \n\r"; echo " \n\r"; } function wpsc_display_groups_page() { global $wpdb, $wp_rewrite; if(!is_numeric($_GET['category_group']) || ((int)$_GET['category_group'] == null)) { $current_categorisation = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 ",ARRAY_A); } else { $current_categorisation = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1') AND `id` IN ('".(int)$_GET['category_group']."') LIMIT 1 ",ARRAY_A); } if($_POST['submit_action'] == "add") { //exit("
".print_r($_POST,true)."
"); if(($_FILES['image'] != null) && preg_match("/\.(gif|jp(e)*g|png){1}$/i",$_FILES['image']['name'])) { if(function_exists("getimagesize")) { if(((int)$_POST['width'] > 10 && (int)$_POST['width'] < 512) && ((int)$_POST['height'] > 10 && (int)$_POST['height'] < 512) ) { $width = (int)$_POST['width']; $height = (int)$_POST['height']; image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']), $width, $height); } else { image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name'])); } $image = $wpdb->escape($_FILES['image']['name']); } else { $new_image_path = (WPSC_CATEGORY_DIR.basename($_FILES['image']['name'])); move_uploaded_file($_FILES['image']['tmp_name'], $new_image_path); $stat = stat( dirname( $new_image_path )); $perms = $stat['mode'] & 0000666; @ chmod( $new_image_path, $perms ); $image = $wpdb->escape($_FILES['image']['name']); } } else { $image = ''; } if(is_numeric($_POST['category_parent'])) { $parent_category = (int)$_POST['category_parent']; } else { $parent_category = 0; } //$tidied_name = sanitize_title(); //$tidied_name = strtolower($tidied_name); $url_name = sanitize_title($_POST['name']); $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '$url_name', '')) AS `max_number` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `nice-name` REGEXP '^($url_name){1}(\d)*$' ",ARRAY_A); $extension_number = ''; if($similar_names['count'] > 0) { $extension_number = (int)$similar_names['max_number']+1; } $url_name .= $extension_number; switch($_POST['display_type']) { case "grid": $display_type = 'grid'; break; case "list": $display_type = 'list'; break; case "default": $display_type = 'default'; break; default: $display_type = ''; break; } if($_POST['product_height'] > 0) { $product_height = (int)$_POST['product_height']; } else { $product_height = ''; } if($_POST['product_width'] > 0) { $product_width = (int)$_POST['product_width']; } else { $product_width = ''; } if(trim($_POST['name']) != null) { //$_POST['name'] = "test"; $insertsql = "INSERT INTO `".WPSC_TABLE_PRODUCT_CATEGORIES."` (`group_id`, `name` , `nice-name` , `description`, `image`, `fee` , `active`, `category_parent`, `order` ) VALUES ( '".(int)$_POST['categorisation_group']."', '".$wpdb->escape(stripslashes($_POST['name']))."', '".$url_name."', '".$wpdb->escape(stripslashes($_POST['description']))."', '$image', '0', '1' ,'$parent_category', '0')"; $wp_rewrite->flush_rules(); if($wpdb->query($insertsql)) { $category_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` LIMIT 1"); if($_POST['use_additonal_form_set'] != '') { wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']); } else { wpsc_delete_categorymeta($category_id, 'use_additonal_form_set'); } if((bool)(int)$_POST['uses_billing_address'] == true) { wpsc_update_categorymeta($category_id, 'uses_billing_address', 1); $uses_additional_forms = true; } else { wpsc_update_categorymeta($category_id, 'uses_billing_address', 0); $uses_additional_forms = false; } // if($uses_additional_forms == true) { // $checkout_form_sets = get_option('wpsc_checkout_form_sets'); // $checkout_form_sets[$url_name] = $wpdb->escape(stripslashes($_POST['name'])); // update_option('wpsc_checkout_form_sets', $checkout_form_sets); // } echo "

".__('The item has been added', 'wpsc')."

"; } else { echo "

".__('The item has not been added', 'wpsc')."

"; } update_option('wpsc_category_url_cache', array()); $wp_rewrite->flush_rules(); } else { echo "

".__('The item has not been added', 'wpsc')."

"; } // Jeff 15-04-09 Used for category target market options if(($_POST['countrylist2'] != null ) && ($category_id > 0)){ $AllSelected = false; $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`"); if(in_array('all',$_POST['countrylist2'])) { foreach($countryList as $country){ $wpdb->query("INSERT INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )"); //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )
"; } $AllSelected = true; } if(in_array('none', $_POST['countrylist2'])){ foreach($countryList as $country){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$country}', '{$category_id}' )"); } $AllSelected = true; } if($AllSelected != true){ $unselectedCountries = array_diff($countryList, $_POST['countrylist2']); foreach($unselectedCountries as $unselected){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$unselected}', '{$category_id}' )"); //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('0','{$unselected}', '{$category_id}' )
"; } //find the countries that are selected $selectedCountries = array_intersect($countryList, $_POST['countrylist2']); foreach($selectedCountries as $selected){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$selected}', '{$category_id}' )"); //echo "REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$unselected}', '{$category_id}' )
"; } } } } if(($_POST['submit_action'] == "edit") && is_numeric($_POST['prodid'])) { $category_id = absint($_POST['prodid']); if(($_FILES['image'] != null) && preg_match("/\.(gif|jp(e)*g|png){1}$/i",$_FILES['image']['name'])) { if(function_exists("getimagesize")) { if(((int)$_POST['width'] >= 10 && (int)$_POST['width'] <= 512) && ((int)$_POST['height'] >= 10 && (int)$_POST['height'] <= 512) ) { $width = (int)$_POST['width']; $height = (int)$_POST['height']; image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name']), $width, $height); } else { image_processing($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name'])); } $image = $wpdb->escape($_FILES['image']['name']); } else { move_uploaded_file($_FILES['image']['tmp_name'], (WPSC_CATEGORY_DIR.$_FILES['image']['name'])); $image = $wpdb->escape($_FILES['image']['name']); } } else { $image = ''; } if(is_numeric($_POST['height']) && is_numeric($_POST['width']) && ($image == null)) { $imagedata = $wpdb->get_var("SELECT `image` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `id`=".(int)$_POST['prodid']." LIMIT 1"); if($imagedata != null) { $height = $_POST['height']; $width = $_POST['width']; $imagepath = WPSC_CATEGORY_DIR . $imagedata; $image_output = WPSC_CATEGORY_DIR . $imagedata; image_processing($imagepath, $image_output, $width, $height); } } $category_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `id` IN ('".(int)$_POST['prodid']."')", ARRAY_A); if(($_POST['title'] != $category_data['name']) && (trim($_POST['title']) != null)) { $category_name = $_POST['title']; $category_sql_list[] = "`name` = '$category_name' "; /* creates and checks the tidy URL name */ // $tidied_name = trim($category_name); // $tidied_name = strtolower($tidied_name); $url_name = sanitize_title($category_name); if($url_name != $category_data['nice-name']) { $similar_names = $wpdb->get_row("SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '$url_name', '')) AS `max_number` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `nice-name` REGEXP '^($url_name){1}(0-9)*$' AND `id` NOT IN ('".(int)$category_data['id']."') ",ARRAY_A); //exit("
".print_r($similar_names,true)."
"); $extension_number = ''; if($similar_names['count'] > 0) { $extension_number = (int)$similar_names['max_number']+1; } $url_name .= $extension_number; } /* checks again, just in case */ if($url_name != $category_data['nice-name']) { $category_sql_list[] = "`nice-name` = '$url_name' "; } update_option('wpsc_category_url_cache', array()); $wp_rewrite->flush_rules(); } // Jeff 15-04-09 Used for category target market options if($_POST['countrylist2'] != null){ $countryList = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_CURRENCY_LIST."`"); $AllSelected = false; if(in_array('all',$_POST['countrylist2'])){ foreach($countryList as $country){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$country}', '{$category_id}' )"); } $AllSelected = true; } if(in_array('none', $_POST['countrylist2'])){ $wpdb->query("UPDATE `".WPSC_TABLE_CATEGORY_TM."` SET `visible` = '0' WHERE `categoryid`='{$category_id}'"); $AllSelected = true; } if($AllSelected != true){ $unselectedCountries = array_diff($countryList, $_POST['countrylist2']); foreach($unselectedCountries as $unselected){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."` (`visible`, `countryid`, `categoryid`) VALUES (0,'{$unselected}', '{$category_id}' )"); } //find the countries that are selected $selectedCountries = array_intersect($countryList, $_POST['countrylist2']); foreach($selectedCountries as $selected){ $wpdb->query("REPLACE INTO `".WPSC_TABLE_CATEGORY_TM."`(`visible`, `countryid`, `categoryid`) VALUES ('1','{$selected}', '{$category_id}' )"); } } } if($_POST['description'] != $category_data['description']) { $description = $_POST['description']; $category_sql_list[] = "`description` = '$description' "; } if(is_numeric($_POST['category_parent']) and ($_POST['category_parent'] != $category_data['category_parent'])) { $parent_category = (int)$_POST['category_parent']; $category_sql_list[] = "`category_parent` = '$parent_category' "; } if($_POST['deleteimage'] == 1) { $category_sql_list[] = "`image` = ''"; } else { if($image != null) { $category_sql_list[] = "`image` = '$image'"; } } if($_POST['display_type'] != $category_data['display_type']) { switch($_POST['display_type']) { case "grid": $display_type = 'grid'; break; case "list": $display_type = 'list'; break; case "default": $display_type = 'default'; break; default: $display_type = ''; break; } $category_sql_list[] = "`display_type` = '$display_type' "; } //echo "
".print_r($category_sql_list,true)."
"; if($_POST['product_height'] > 0) { $product_height = (int)$_POST['product_height']; } else { $product_height = ''; } $category_sql_list[] = "`image_height` = '$product_height' "; if($_POST['product_width'] > 0) { $product_width = (int)$_POST['product_width']; } else { $product_width = ''; } $category_sql_list[] = "`image_width` = '$product_width' "; if(count($category_sql_list) > 0) { $category_sql = implode(", ",$category_sql_list); $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET $category_sql WHERE `id`='".(int)$_POST['prodid']."' LIMIT 1"); $category_id = absint($_POST['prodid']); update_option('wpsc_category_url_cache', array()); if($_POST['use_additonal_form_set'] != '') { wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $_POST['use_additonal_form_set']); } else { wpsc_delete_categorymeta($category_id, 'use_additonal_form_set'); } if((bool)(int)$_POST['uses_billing_address'] == true) { wpsc_update_categorymeta($category_id, 'uses_billing_address', 1); $uses_additional_forms = true; } else { wpsc_update_categorymeta($category_id, 'uses_billing_address', 0); $uses_additional_forms = false; } // if($uses_additional_forms == true) { // $category_name = $wpdb->escape(stripslashes($_POST['title'])); // $url_name = sanitize_title($category_name); // $checkout_form_sets = get_option('wpsc_checkout_form_sets'); // $checkout_form_sets[$url_name] = $category_name; // //print_r($checkout_form_sets); // //exit(); // update_option('wpsc_checkout_form_sets', $checkout_form_sets); // } $wp_rewrite->flush_rules(); } echo "

".__('The product group has been edited.', 'wpsc')."

"; } if($_POST['submit_action'] == "add_categorisation") { $wpdb->query("INSERT INTO `".WPSC_TABLE_CATEGORISATION_GROUPS."` ( `name`, `description`, `active`, `default`) VALUES ( '".$wpdb->escape(stripslashes($_POST['name']))."', '".$wpdb->escape(stripslashes($_POST['description']))."', '1', '0')"); echo "

".__('The group has been added.', 'wpsc')."

"; } if($_POST['submit_action'] == "edit_categorisation") { $edit_group_id = $_POST['group_id']; $wpdb->query("UPDATE `".WPSC_TABLE_CATEGORISATION_GROUPS."` SET `name` = '".$wpdb->escape(stripslashes($_POST['name']))."', `description` = '".$wpdb->escape(stripslashes($_POST['description']))."' WHERE `id` IN('$edit_group_id') LIMIT 1 "); echo "

".__('The group has been edited.', 'wpsc')."

"; if(!is_numeric($_GET['category_group']) || ((int)$_GET['category_group'] == null)) { $current_categorisation = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 ",ARRAY_A); } else { $current_categorisation = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1') AND `id` IN ('".(int)$_GET['category_group']."') LIMIT 1 ",ARRAY_A); } } if(is_numeric($_GET['category_delete_id'])) { $delete_id = (int)$_GET['category_delete_id']; $deletesql = "UPDATE `".WPSC_TABLE_CATEGORISATION_GROUPS."` SET `active` = '0' WHERE `id`='{$delete_id}' AND `default` IN ('0') LIMIT 1"; $wpdb->query($deletesql); $delete_subcat_sql = "UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `active` = '0', `nice-name` = '' WHERE `group_id`='{$delete_id}'"; $wpdb->query($delete_subcat_sql); update_option('wpsc_category_url_cache', array()); $wp_rewrite->flush_rules(); } if(is_numeric($_GET['deleteid'])) { $delete_id = absint($_GET['deleteid']); $deletesql = "UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `active` = '0', `nice-name` = '' WHERE `id`='{$delete_id}' LIMIT 1"; if($wpdb->query($deletesql)) { $delete_subcat_sql = "UPDATE `".WPSC_TABLE_PRODUCT_CATEGORIES."` SET `active` = '0', `nice-name` = '' WHERE `category_parent`='{$delete_id}'"; $wpdb->query($delete_subcat_sql); // if this is the default category, we need to find a new default category if($delete_id == get_option('wpsc_default_category')) { // select the category that is not deleted with the greatest number of products in it $new_default = $wpdb->get_var("SELECT `cat`.`id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` AS `cat` LEFT JOIN `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` AS `assoc` ON `cat`.`id` = `assoc`.`category_id` WHERE `cat`.`active` IN ( '1' ) GROUP BY `cat`.`id` ORDER BY COUNT( `assoc`.`id` ) DESC LIMIT 1"); if($new_default > 0) { update_option('wpsc_default_category', $new_default); } } update_option('wpsc_category_url_cache', array()); $wp_rewrite->flush_rules(); } } unset($GLOBALS['wpsc_category_url_cache']); update_option('wpsc_category_url_cache', array()); ?>

"; } ?> "; } else { echo "
"; } ?>
' name='page' /> get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')", ARRAY_A); //echo "\n\r"; ?> ".__('Add New Group', 'wpsc').""; ?>

' />

' id='add_categorisation_name' />
' id='add_categorisation_description' />
' /> ' /> ' onclick='return categorisation_conf()' >

\n\r"; echo " \n\r"; if (function_exists('add_object_page')){ echo "
"; echo "

".str_replace("[categorisation]", $current_categorisation['name'], __('"[categorisation]" Group', 'wpsc'))."

"; echo "
"; } //echo "
". __('+ Add new category to the "[categorisation]" Group', 'wpsc')."".str_replace("[categorisation]", $current_categorisation['name'], __('Manage "[categorisation]"', 'wpsc'))." [".__('Edit', 'wpsc')."]
"; echo " \n\r"; if (function_exists('add_object_page')) { echo ""; } else { echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; echo " \n\r"; } echo " \n\r"; echo " \n\r"; echo " \n\r"; display_categories($current_categorisation['id']); if (function_exists('add_object_page')){ echo "
\n\r"; echo __('Image', 'wpsc'); echo " \n\r"; echo __('Name', 'wpsc'); echo " \n\r"; //echo __('Description', 'wpsc'); echo " \n\r"; echo __('Edit', 'wpsc'); echo "
\n\r"; echo "

"; echo str_replace("[categorisation]", $current_categorisation['name'], __('You are editing the "[categorisation]" Group', 'wpsc')); echo " ".__('Edit', 'wpsc').""; echo "

"; echo "
"; echo "
"; //class inside ends echo "
"; //class postbox ends } else { echo "\n\r"; } echo " \n\r"; echo "
"; echo "
\n\r"; if (function_exists('add_object_page')) { echo "

".str_replace("[categorisation]", $current_categorisation['name'], __('You are editing an item in the "[categorisation]" Group', 'wpsc'))."

"; echo "
"; } else { echo "
".__('Edit Details', 'wpsc')."
\n\r"; echo "

".str_replace("[categorisation]", $current_categorisation['name'], __('You are editing an item in the "[categorisation]" Group', 'wpsc')) ."

"; } echo "
\n\r"; echo "
\n\r"; if (function_exists('add_object_page')) { echo "
"; } echo "
\n\r"; echo "
\n\r"; ?>

:
:
:
:
:' /> :' />
Presentation Settings.', 'wpsc'); ?>

:
: : :

*/ ?>
: */ /* */ ?>
:
' /> ' />