Пример #1
0
function fn_delete_localization($localization_ids)
{
    $loc_objects = fn_get_localization_objects();
    fn_set_progress('parts', sizeof($localization_ids) * sizeof($loc_objects));
    foreach ($localization_ids as $loc_id) {
        foreach ($loc_objects as $table) {
            fn_set_progress('echo', __('converting_data_in_table', array('[table]' => $table)));
            db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id));
        }
        db_query("DELETE FROM ?:localizations WHERE localization_id = ?i", $loc_id);
        db_query("DELETE FROM ?:localization_descriptions WHERE localization_id = ?i", $loc_id);
        db_query("DELETE FROM ?:localization_elements WHERE localization_id = ?i", $loc_id);
    }
    fn_set_notification('N', __('notice'), __('done'));
}
Пример #2
0
/**
 * Add value to set (e.g. add 2 from "1,3" results in "1,3,2")
 *
 * @param string $field table field with set
 * @param string $value value to add
 * @return string database construction for add value to set
 */
function fn_add_to_set($field, $value)
{
    return Database::quote("TRIM(BOTH ',' FROM CONCAT_WS(',', ?p, ?s))", fn_remove_from_set($field, $value), $value);
}
Пример #3
0
function fn_gift_certificates_delete_order(&$order_id)
{
    db_query("UPDATE ?:gift_certificates SET order_ids = ?p", fn_remove_from_set('order_ids', $order_id));
}
Пример #4
0
/**
 * Delete tax
 *
 * @param int $tax_id ID of the tax to be removed.
 * @return boolean
 */
function fn_delete_tax($tax_id)
{
    /**
     * Delete taxes (running before fn_delete_taxes() function)
     *
     * @param array $tax_ids Taxes identifier
     */
    fn_set_hook('delete_tax_pre', $tax_id);
    $result = db_query("DELETE FROM ?:taxes WHERE tax_id = ?i", $tax_id);
    db_query("DELETE FROM ?:tax_descriptions WHERE tax_id = ?i", $tax_id);
    db_query("DELETE FROM ?:tax_rates WHERE tax_id = ?i", $tax_id);
    db_query("UPDATE ?:products SET tax_ids = ?p", fn_remove_from_set('tax_ids', $tax_id));
    db_query("UPDATE ?:shippings SET tax_ids = ?p", fn_remove_from_set('tax_ids', $tax_id));
    return $result;
}
Пример #5
0
/**
 * Removes category by identifier
 *
 * @param int $category_id Category identifier
 * @param boolean $recurse Flag that defines if category should be deleted recursively
 * @return int/boolean Identifiers of deleted categories or false if categories were not found
 */
function fn_delete_category($category_id, $recurse = true)
{
    /**
     * Actions before category and its related data removal
     *
     * @param  int         $category_id Category identifier to delete
     * @param  boolean     $recurse     Flag that defines if category should be deleted recursively
     * @return int|boolean Identifiers of deleted categories or false if categories were not found
     */
    fn_set_hook('delete_category_pre', $category_id, $recurse);
    if (empty($category_id)) {
        return false;
    }
    // Log category deletion
    fn_log_event('categories', 'delete', array('category_id' => $category_id));
    // Delete all subcategories
    if ($recurse == true) {
        $id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $category_id);
        $category_ids = db_get_fields("SELECT category_id FROM ?:categories WHERE category_id = ?i OR id_path LIKE ?l", $category_id, "{$id_path}/%");
    } else {
        $category_ids[] = $category_id;
    }
    foreach ($category_ids as $k => $category_id) {
        /**
         * Process category delete (run before category is deleted)
         *
         * @param int $category_id Category identifier
         */
        fn_set_hook('delete_category_before', $category_id);
        Block::instance()->removeDynamicObjectdata('categories', $category_id);
        // Deleting category
        db_query("DELETE FROM ?:categories WHERE category_id = ?i", $category_id);
        db_query("DELETE FROM ?:category_descriptions WHERE category_id = ?i", $category_id);
        // Deleting additional product associations without deleting products itself
        db_query("DELETE FROM ?:products_categories WHERE category_id = ?i AND link_type = 'A'", $category_id);
        // Remove this category from features assignments
        db_query("UPDATE ?:product_features SET categories_path = ?p", fn_remove_from_set('categories_path', $category_id));
        if (!fn_allowed_for('ULTIMATE')) {
            // Deleting main products association with deleting products
            $products_to_delete = db_get_fields("SELECT product_id FROM ?:products_categories WHERE category_id = ?i AND link_type = 'M'", $category_id);
            if (!empty($products_to_delete)) {
                foreach ($products_to_delete as $key => $value) {
                    fn_delete_product($value);
                }
            }
        }
        // Deleting category images
        fn_delete_image_pairs($category_id, 'category');
        /**
         * Process category delete (run after category is deleted)
         *
         * @param int $category_id Category identifier
         */
        fn_set_hook('delete_category_after', $category_id);
    }
    /**
     * Actions after category and its related data removal
     *
     * @param int     $category_id  Category identifier to delete
     * @param boolean $recurse      Flag that defines if category should be deleted recursively
     * @param int     $category_ids Category identifiers that were removed
     */
    fn_set_hook('delete_category_post', $category_id, $recurse, $category_ids);
    return $category_ids;
    // Returns ids of deleted categories
}
Пример #6
0
    }
    return array(CONTROLLER_STATUS_OK, $url);
} elseif ($mode == 'bulk_actions') {
    fn_block_bulk_actions($_REQUEST['block_id'], ACTION);
    return array(CONTROLLER_STATUS_OK, "block_manager.manage");
} elseif ($mode == 'update_status') {
    // Check if global (all_pages) block is disabled for sub-location (products, categories etc.)
    if (!empty($_REQUEST['selected_location']) && $_REQUEST['selected_location'] != 'all_pages' && $_REQUEST['block_location'] == 'all_pages') {
        $disabled_locations = db_get_field("SELECT disabled_locations FROM ?:blocks WHERE block_id = ?i", $_REQUEST['id']);
        if (strpos($disabled_locations, $_REQUEST['selected_location']) === false && $_REQUEST['status'] != 'A') {
            // disable block
            $query = fn_add_to_set('disabled_locations', $_REQUEST['selected_location']);
            $_action = 'disabled';
        } else {
            // enable block
            $query = fn_remove_from_set('disabled_locations', $_REQUEST['selected_location']);
            $_action = 'enabled';
        }
        db_query("UPDATE ?:blocks SET disabled_locations = ?p WHERE block_id = ?i", $query, $_REQUEST['id']);
        fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var("block_{$_action}"));
        exit;
    }
}
if ($mode == 'manage') {
    $locations = fn_get_block_locations();
    // [Page sections]
    if (!empty($locations)) {
        foreach ($locations as $location => $_location) {
            Registry::set("navigation.tabs.{$location}", array('title' => fn_get_lang_var($location), 'href' => "block_manager.manage?selected_section={$location}"));
        }
    }
Пример #7
0
function fn_mve_delete_shipping($shipping_id)
{
    db_query("UPDATE ?:companies SET shippings = ?p", fn_remove_from_set('shippings', $shipping_id));
}
Пример #8
0
/**
 * Add value to set (e.g. add 2 from "1,3" results in "1,3,2")
 *
 * @param string $field table field with set
 * @param string $value value to add
 * @return string database construction for add value to set
 */
function fn_add_to_set($field, $value)
{
    return Tygh::$app['db']->quote("TRIM(BOTH ',' FROM CONCAT_WS(',', ?p, ?s))", fn_remove_from_set($field, $value), $value);
}
Пример #9
0
    }
    if ($mode == 'apply_selected_taxes') {
        if (!empty($_REQUEST['tax_ids'])) {
            $tax_names = fn_get_tax_name($_REQUEST['tax_ids']);
            foreach ($_REQUEST['tax_ids'] as $v) {
                db_query("UPDATE ?:products SET tax_ids = ?p", fn_add_to_set('?:products.tax_ids', $v));
                fn_set_notification('N', __('notice'), __('text_tax_applied', array('[tax]' => $tax_names[$v])));
            }
        }
        $suffix = '.manage';
    }
    if ($mode == 'unset_selected_taxes') {
        if (!empty($_REQUEST['tax_ids'])) {
            $tax_names = fn_get_tax_name($_REQUEST['tax_ids']);
            foreach ($_REQUEST['tax_ids'] as $v) {
                db_query("UPDATE ?:products SET tax_ids = ?p", fn_remove_from_set('?:products.tax_ids', $v));
                fn_set_notification('N', __('notice'), __('text_tax_unset', array('[tax]' => $tax_names[$v])));
            }
        }
        $suffix = '.manage';
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['tax_id'])) {
            fn_delete_taxes($_REQUEST['tax_id']);
        }
        $suffix = '.manage';
    }
    return array(CONTROLLER_STATUS_OK, 'taxes' . $suffix);
}
// ---------------------- GET routines ---------------------------------------
// Edit tax rates
Пример #10
0
/**
 * Function delete object from the block (product, category, page etc)
 *
 * @param string $object the type of object
 * @param int $object_id
 *
 * @return true
 */
function fn_clean_block_items($object, $object_id)
{
    $blocks = db_get_array("SELECT block_id, text_id, block_type, location, properties FROM ?:blocks WHERE block_type = 'B'");
    $block_ids = array();
    foreach ($blocks as $block) {
        $block_prop = fn_unserialize_block_properties($block['properties'], $block['location'], $block['block_type'], $block['text_id']);
        if (!empty($block_prop['list_object']) && $block_prop['list_object'] == $object) {
            $block_ids[] = $block['block_id'];
        }
    }
    if (!empty($block_ids)) {
        $rm = fn_remove_from_set('?:block_links.item_ids', $object_id);
        db_query("UPDATE ?:block_links SET item_ids = ?p WHERE block_id IN (?n)", $rm, $block_ids);
    }
    return true;
}
Пример #11
0
function fn_delete_taxes($tax_ids)
{
    foreach ((array) $tax_ids as $v) {
        db_query("DELETE FROM ?:taxes WHERE tax_id = ?i", $v);
        db_query("DELETE FROM ?:tax_descriptions WHERE tax_id = ?i", $v);
        db_query("DELETE FROM ?:tax_rates WHERE tax_id = ?i", $v);
        db_query("UPDATE ?:products SET tax_ids = ?p", fn_remove_from_set('tax_ids', $v));
        db_query("UPDATE ?:shippings SET tax_ids = ?p", fn_remove_from_set('tax_ids', $v));
    }
}
Пример #12
0
function fn_delete_localization($localization_ids)
{
    fn_start_scroller();
    foreach ($localization_ids as $loc_id) {
        foreach (fn_get_localization_objects() as $table) {
            fn_echo('<br />' . str_replace('[table]', $table, fn_get_lang_var('converting_data_in_table')) . '...' . '<br />');
            db_query("UPDATE ?:{$table} SET localization = ?p", fn_remove_from_set('localization', $loc_id));
        }
        fn_stop_scroller();
        db_query("DELETE FROM ?:localizations WHERE localization_id = ?i", $loc_id);
        db_query("DELETE FROM ?:localization_descriptions WHERE localization_id = ?i", $loc_id);
        db_query("DELETE FROM ?:localization_elements WHERE localization_id = ?i", $loc_id);
    }
}
Пример #13
0
function fn_delete_category($category_id, $recurse = true)
{
    // Log category deletion
    fn_log_event('categories', 'delete', array('category_id' => $category_id));
    fn_clean_block_items('categories', $category_id);
    fn_clean_block_links('categories', $category_id);
    $category_ids = array();
    $category_ids[] = $category_id;
    if (!empty($category_ids[0])) {
        // Delete all subcategories
        if ($recurse == true) {
            $id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $category_id);
            $category_ids = db_get_fields("SELECT category_id FROM ?:categories WHERE category_id = ?i OR id_path LIKE ?l", $category_id, "{$id_path}/%");
        }
        foreach ($category_ids as $k => $v) {
            $category_id = $v;
            fn_clean_block_items('categories', $category_id);
            // Deleting category
            db_query("DELETE FROM ?:categories WHERE category_id = ?i", $category_id);
            db_query("DELETE FROM ?:category_descriptions WHERE category_id = ?i", $category_id);
            // Deleting additional product associations without deleting products itself
            db_query("DELETE FROM ?:products_categories WHERE category_id = ?i AND link_type = 'A'", $category_id);
            // Remove this category from features assignments
            db_query("UPDATE ?:product_features SET categories_path = ?p", fn_remove_from_set('categories_path', $v));
            // Deleting main products association with deleting products
            $products_to_delete = db_get_fields("SELECT product_id FROM ?:products_categories WHERE category_id = ?i AND link_type = 'M'", $category_id);
            if (!empty($products_to_delete)) {
                foreach ($products_to_delete as $key => $value) {
                    fn_delete_product($value);
                }
            }
            // Deleting category images
            fn_delete_image_pairs($category_id, 'category');
            // Executing delete_category functions from active addons
            fn_set_hook('delete_category', $category_id);
        }
        return $category_ids;
        // Returns ids of deleted categories
    } else {
        return false;
    }
}
Пример #14
0
 /**
  * Add value to set (e.g. add 2 from "1,3" results in "1,3,2")
  *
  * @param string $field table field with set
  * @param string $value value to add
  * @return string database construction for add value to set
  */
 public function fn_add_to_set($field, $value)
 {
     return $this->db_quote("TRIM(BOTH ',' FROM CONCAT_WS(',', ?p, ?s))", fn_remove_from_set($field, $value), $value);
 }