function xos_get_category_tree_for_movings($parent_id = '0', $spacing = '', $category_tree_array = '', $move_product = false)
{
    if (!is_array($category_tree_array)) {
        $category_tree_array = array();
    }
    if (sizeof($category_tree_array) < 1) {
        $category_tree_array[] = $move_product ? array('id' => '0', 'text' => TEXT_TOP, 'params' => 'style="color: grey;" disabled="disabled"') : array('id' => '0', 'text' => TEXT_TOP);
    }
    $categories_query = xos_db_query("select c.categories_or_pages_id, cpd.categories_or_pages_name, c.parent_id, c.categories_or_pages_status from " . TABLE_CATEGORIES_OR_PAGES . " c, " . TABLE_CATEGORIES_OR_PAGES_DATA . " cpd where c.categories_or_pages_id = cpd.categories_or_pages_id and c.is_page = 'false' and cpd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and c.parent_id = '" . (int) $parent_id . "' order by c.sort_order, cpd.categories_or_pages_name");
    while ($categories = xos_db_fetch_array($categories_query)) {
        if (xos_children_in_category_count($categories['categories_or_pages_id']) > 0 && $move_product || xos_children_in_category_count($categories['categories_or_pages_id']) == 0 && xos_products_in_category_count($categories['categories_or_pages_id'], true) > 0 && !$move_product) {
            $category_tree_array[] = array('id' => $categories['categories_or_pages_id'], 'text' => $spacing . $categories['categories_or_pages_name'], 'params' => 'style="color: grey;" disabled="disabled"');
        } else {
            $category_tree_array[] = array('id' => $categories['categories_or_pages_id'], 'text' => $spacing . $categories['categories_or_pages_name'], 'params' => $categories['categories_or_pages_status'] == 0 ? 'style="color: red;"' : '');
        }
        $category_tree_array = xos_get_category_tree_for_movings($categories['categories_or_pages_id'], $spacing . '&nbsp;&nbsp;&nbsp;', $category_tree_array, $move_product);
    }
    return $category_tree_array;
}
Exemple #2
0
function xos_children_in_category_count($categories_or_pages_id)
{
    $categories_count = 0;
    $categories_query = xos_db_query("select categories_or_pages_id from " . TABLE_CATEGORIES_OR_PAGES . " where is_page = 'false' and parent_id = '" . (int) $categories_or_pages_id . "'");
    while ($categories = xos_db_fetch_array($categories_query)) {
        $categories_count++;
        $categories_count += xos_children_in_category_count($categories['categories_or_pages_id']);
    }
    return $categories_count;
}
         }
     }
     $sql_data_array = array('products_image' => serialize($image_array), 'products_price' => serialize($prices_array));
     xos_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int) $products_id . "'");
     $smarty_cache_control->clearAllCache();
     if ($specials_error) {
         $messageStack->add_session('price_error', ERROR_NOT_ALL_NECESSARY_PRICES, 'error');
         xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . '&errGr=' . substr($spec_err_gr, 0, -1) . '&action=new_product'));
     }
     xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
     break;
 case 'copy_to_confirm':
     if (isset($_POST['products_id']) && isset($_POST['categories_or_pages_id'])) {
         $products_id = xos_db_prepare_input($_POST['products_id']);
         $categories_or_pages_id = xos_db_prepare_input($_POST['categories_or_pages_id']);
         if (xos_children_in_category_count($categories_or_pages_id) > 0) {
             $messageStack->add_session('header', ERROR_CANNOT_LINKED_PRODUCT_TO_TOP_OR_TO_CATEGORY_CONTAINS_SUBCATEGORIES, 'error');
             xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
         } else {
             if ($_POST['copy_as'] == 'link') {
                 if ($categories_or_pages_id != $current_category_id) {
                     $check_query = xos_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $products_id . "' and categories_or_pages_id = '" . (int) $categories_or_pages_id . "'");
                     $check = xos_db_fetch_array($check_query);
                     if ($check['total'] < '1') {
                         xos_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_or_pages_id) values ('" . (int) $products_id . "', '" . (int) $categories_or_pages_id . "')");
                         $smarty_cache_control->clearAllCache();
                     }
                 } else {
                     $messageStack->add_session('header', ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
                 }
             } elseif ($_POST['copy_as'] == 'duplicate') {
//              Copyright (c) 2003 osCommerce
//              filename: categories.php
//
//              Released under the GNU General Public License
////////////////////////////////////////////////////////////////////////////////
if (!(@(include DIR_FS_SMARTY . 'admin/templates/' . ADMIN_TPL . '/php/includes/modules/categories_and_products.php') == 'overwrite_all')) {
    $categories_count = 0;
    $rows = 0;
    if (!isset($_GET['search'])) {
        $categories_query = xos_db_query("select c.categories_or_pages_id, cpd.categories_or_pages_name, c.categories_image, c.parent_id, c.product_list_b, c.sort_order, c.date_added, c.last_modified, c.categories_or_pages_status  from " . TABLE_CATEGORIES_OR_PAGES . " c, " . TABLE_CATEGORIES_OR_PAGES_DATA . " cpd where c.parent_id = '" . (int) $current_category_id . "' and c.categories_or_pages_id = cpd.categories_or_pages_id and c.is_page = 'false' and cpd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' order by c.sort_order, cpd.categories_or_pages_name");
        $categories_array = array();
        while ($categories = xos_db_fetch_array($categories_query)) {
            $categories_count++;
            $rows++;
            if ((!isset($_GET['cpID']) && !isset($_GET['pID']) || isset($_GET['cpID']) && $_GET['cpID'] == $categories['categories_or_pages_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') {
                $category_children = array('children_count' => xos_children_in_category_count($categories['categories_or_pages_id']));
                $category_products = array('products_count' => xos_products_in_category_count($categories['categories_or_pages_id']));
                $cInfo_array = array_merge((array) $categories, (array) $category_children, (array) $category_products);
                $cInfo = new objectInfo($cInfo_array);
            }
            $categories_array[] = array('selected' => isset($cInfo) && is_object($cInfo) && $categories['categories_or_pages_id'] == $cInfo->categories_or_pages_id ? true : false, 'status' => $categories['categories_or_pages_status'] == '1' ? true : false, 'name' => htmlspecialchars($categories['categories_or_pages_name']), 'sort_order' => $categories['sort_order'], 'icon_status_green' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_green.gif', ICON_TITLE_STATUS_GREEN), 'icon_status_red' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_red.gif', ICON_TITLE_STATUS_RED), 'icon_status_green_light' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_green_light.gif', ICON_TITLE_STATUS_GREEN_LIGHT), 'icon_status_red_light' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_red_light.gif', ICON_TITLE_STATUS_RED_LIGHT), 'link_filename_categories_flag_0' => xos_href_link(FILENAME_CATEGORIES, 'action=setflag_cat&flag=0&cpID=' . $categories['categories_or_pages_id'] . '&cPath=' . $cPath), 'link_filename_categories_flag_1' => xos_href_link(FILENAME_CATEGORIES, 'action=setflag_cat&flag=1&cpID=' . $categories['categories_or_pages_id'] . '&cPath=' . $cPath), 'link_filename_categories_get_path' => xos_href_link(FILENAME_CATEGORIES, xos_get_path($categories['categories_or_pages_id'])), 'link_filename_categories_cpath_cpath_cid' => xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cpID=' . $categories['categories_or_pages_id']));
        }
    }
    $products_count = 0;
    if (isset($_GET['search'])) {
        $search = xos_db_prepare_input($_GET['search']);
        $products_query = xos_db_query("select distinct p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_sort_order, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_or_pages_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and p.products_id = p2c.products_id and pd.products_name like '%" . xos_db_input($search) . "%' group by p.products_id order by p.products_sort_order, pd.products_name LIMIT 20");
    } else {
        $products_query = xos_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_sort_order, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and p.products_id = p2c.products_id and p2c.categories_or_pages_id = '" . (int) $current_category_id . "' order by p.products_sort_order, pd.products_name");
    }
    $products_array = array();