Ejemplo n.º 1
0
         } else {
             return array(CONTROLLER_STATUS_REDIRECT, 'products.update?product_id=' . $_REQUEST['product_id']);
         }
     }
     return array(CONTROLLER_STATUS_REDIRECT, 'products.manage');
 }
 if ($mode == 'delete_subscr') {
     if (!empty($_REQUEST['product_id'])) {
         db_query("DELETE FROM ?:product_subscriptions WHERE product_id = ?i", $_REQUEST['product_id']);
     }
     return array(CONTROLLER_STATUS_REDIRECT, 'products.p_subscr');
 }
 if ($mode == 'clone') {
     if (!empty($_REQUEST['product_id'])) {
         $pid = $_REQUEST['product_id'];
         $pdata = fn_clone_product($pid);
         if (!empty($pdata['product_id'])) {
             $pid = $pdata['product_id'];
             fn_set_notification('N', __('notice'), __('text_product_cloned'));
         }
         return array(CONTROLLER_STATUS_REDIRECT, 'products.update?product_id=' . $pid);
     }
 }
 if ($mode == 'delete_file') {
     if (!empty($_REQUEST['file_id']) && !empty($_REQUEST['product_id'])) {
         if (fn_delete_product_files($_REQUEST['file_id']) == false) {
             return array(CONTROLLER_STATUS_DENIED);
         }
         list($_files) = fn_get_product_files(array('product_id' => $_REQUEST['product_id']));
         list($_folder) = fn_get_product_file_folders(array('product_id' => $_REQUEST['product_id']));
         if (empty($_files) && empty($_folder)) {
Ejemplo n.º 2
0
function fn_clone_products($table_data, $clone_data, $start, $from, $to, $extra)
{
    if (!empty($clone_data)) {
        $limit = 50;
        $start = 0;
        do {
            $data = db_get_array('SELECT product_id, category_id FROM ?:products_categories WHERE link_type = ?s AND category_id IN (?a) LIMIT ?i, ?i', 'M', array_keys($clone_data), $start, $limit);
            foreach ($data as $item) {
                $result = fn_clone_product($item['product_id']);
                db_query('UPDATE ?:products SET company_id = ?i WHERE product_id = ?i', $to, $result['product_id']);
                db_query('UPDATE ?:products_categories SET category_id = ?i WHERE product_id = ?i AND link_type = ?s', $clone_data[$item['category_id']], $result['product_id'], 'M');
                // Get category ids to update product count
                $cids = db_get_fields('SELECT category_id FROM ?:products_categories WHERE product_id = ?i OR product_id = ?i', $item['product_id'], $result['product_id']);
                fn_update_product_count($cids);
            }
            $total = db_get_field('SELECT COUNT(*) FROM ?:products_categories WHERE link_type = ?s AND category_id IN (?a)', 'M', array_keys($clone_data));
            $start += $limit;
        } while ($total >= $start);
    }
}