Exemple #1
0
/**
 * Recursive algorithm to UNDO restriction from all sub_categories of a specified category for a specified product_type
 */
function zen_remove_restrict_sub_categories($zf_cat_id, $zf_type)
{
    global $db;
    $zp_sql = "select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $zf_cat_id . "'";
    $zq_sub_cats = $db->Execute($zp_sql);
    while (!$zq_sub_cats->EOF) {
        $sql = "delete from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "\n                where category_id = '" . (int) $zq_sub_cats->fields['categories_id'] . "'\n                and product_type_id = '" . (int) $zf_type . "'";
        $db->Execute($sql);
        zen_remove_restrict_sub_categories($zq_sub_cats->fields['categories_id'], $zf_type);
        $zq_sub_cats->MoveNext();
    }
}
                 $category_products = $db->Execute($sql);
                 while (!$category_products->EOF) {
                     $sql = "update " . TABLE_PRODUCTS . " set products_status='" . $products_status . "' where products_id='" . $category_products->fields['products_id'] . "'";
                     $db->Execute($sql);
                     $category_products->MoveNext();
                 }
             }
         }
         // for
     }
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&cID=' . $_GET['cID']));
     break;
 case 'remove_type':
     $sql = "delete from " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "\n              where category_id = '" . zen_db_prepare_input($_GET['cID']) . "'\n              and product_type_id = '" . zen_db_prepare_input($_GET['type_id']) . "'";
     $db->Execute($sql);
     zen_remove_restrict_sub_categories($_GET['cID'], $_GET['type_id']);
     $action = "edit";
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'action=edit_category&cPath=' . $_GET['cPath'] . '&cID=' . zen_db_prepare_input($_GET['cID'])));
     break;
 case 'setflag':
     if ($_GET['flag'] == '0' || $_GET['flag'] == '1') {
         if (isset($_GET['pID'])) {
             zen_set_product_status($_GET['pID'], $_GET['flag']);
         }
     }
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
     break;
 case 'insert_category':
 case 'update_category':
     if (isset($_POST['add_type']) or isset($_POST['add_type_all'])) {
         // check if it is already restricted
Exemple #3
0
function zen_remove_restrict_sub_categories($zf_cat_id, $zf_type)
{
    global $gBitDb;
    $zp_sql = "SELECT `categories_id` FROM " . TABLE_CATEGORIES . " WHERE `parent_id` = '" . $zf_cat_id . "'";
    $zq_sub_cats = $gBitDb->Execute($zp_sql);
    while (!$zq_sub_cats->EOF) {
        $sql = "delete FROM " . TABLE_PRODUCT_TYPES_TO_CATEGORY . "\n\t\t\t\t\t\t\t\tWHERE `category_id` = '" . $zq_sub_cats->fields['categories_id'] . "'\n\t\t\t\t\t\t\t\tand `product_type_id` = '" . $zf_type . "'";
        $gBitDb->Execute($sql);
        zen_remove_restrict_sub_categories($zq_sub_cats->fields['categories_id'], $zf_type);
        $zq_sub_cats->MoveNext();
    }
}