Beispiel #1
0
/**
 * Delete all images pairs for object
 */
function fn_clean_image_pairs($object_id, $object_type)
{
    $pair_data = db_get_hash_array("SELECT pair_id, image_id, detailed_id, type FROM ?:images_links WHERE object_id = ?i AND object_type = ?s", 'pair_id', $object_id, $object_type);
    foreach ($pair_data as $pair_id => $p_data) {
        fn_delete_image_pair($pair_id, $object_type);
    }
}
Beispiel #2
0
 public function prepareImages($params, $product_id = 0, $object_name = '', $main_type = 'M')
 {
     if (isset($params['main_pair'])) {
         $_REQUEST['file_product_main_image_icon'] = array();
         $_REQUEST['type_product_main_image_icon'] = array();
         $_REQUEST['file_product_main_image_detailed'] = array();
         $_REQUEST['type_product_main_image_detailed'] = array();
         $_REQUEST['product_main_image_data'] = array();
         if ($product_id != 0) {
             $products_images = fn_get_image_pairs($product_id, 'product', 'M', true, true, DEFAULT_LANGUAGE);
             if (!empty($products_images)) {
                 fn_delete_image_pair($products_images['pair_id']);
             }
         }
         if (!empty($params['main_pair']['detailed']['image_path'])) {
             $_REQUEST['file_product_main_image_detailed'][] = $params['main_pair']['detailed']['image_path'];
             $_REQUEST['type_product_main_image_detailed'][] = strpos($params['main_pair']['detailed']['image_path'], '://') === false ? 'server' : 'url';
         }
         if (!empty($params['main_pair']['icon']['image_path'])) {
             $_REQUEST['file_product_main_image_icon'][] = $params['main_pair']['icon']['image_path'];
             $_REQUEST['type_product_main_image_icon'][] = strpos($params['main_pair']['icon']['image_path'], '://') === false ? 'server' : 'url';
         }
         $_REQUEST['product_main_image_data'][] = array('pair_id' => 0, 'type' => 'M', 'object_id' => 0, 'image_alt' => !empty($params['main_pair']['icon']['alt']) ? $params['main_pair']['icon']['alt'] : '', 'detailed_alt' => !empty($params['main_pair']['detailed']['alt']) ? $params['main_pair']['detailed']['alt'] : '');
     }
     if (isset($params['image_pairs'])) {
         $_REQUEST['file_product_add_additional_image_icon'] = array();
         $_REQUEST['type_product_add_additional_image_icon'] = array();
         $_REQUEST['file_product_add_additional_image_detailed'] = array();
         $_REQUEST['type_product_add_additional_image_detailed'] = array();
         $_REQUEST['product_add_additional_image_data'] = array();
         if ($product_id != 0) {
             $additional_images = fn_get_image_pairs($product_id, 'product', 'A', true, true, DEFAULT_LANGUAGE);
             foreach ($additional_images as $pair) {
                 fn_delete_image_pair($pair['pair_id']);
             }
         }
         foreach ($params['image_pairs'] as $pair_id => $pair) {
             if (!empty($pair['icon']['image_path'])) {
                 $_REQUEST['file_product_add_additional_image_icon'][] = $pair['icon']['image_path'];
                 $_REQUEST['type_product_add_additional_image_icon'][] = strpos($pair['icon']['image_path'], '://') === false ? 'server' : 'url';
             }
             if (!empty($pair['detailed']['image_path'])) {
                 $_REQUEST['file_product_add_additional_image_detailed'][] = $pair['detailed']['image_path'];
                 $_REQUEST['type_product_add_additional_image_detailed'][] = strpos($pair['detailed']['image_path'], '://') === false ? 'server' : 'url';
             }
             $_REQUEST['product_add_additional_image_data'][] = array('position' => !empty($pair['position']) ? $pair['position'] : 0, 'pair_id' => 0, 'type' => 'A', 'object_id' => 0, 'image_alt' => !empty($pair['icon']['alt']) ? $pair['icon']['alt'] : '', 'detailed_alt' => !empty($pair['detailed']['alt']) ? $pair['detailed']['alt'] : '');
         }
     }
 }
Beispiel #3
0
        if (AREA == 'A' && !empty($auth['user_id'])) {
            fn_delete_image($_REQUEST['image_id'], $_REQUEST['pair_id'], $_REQUEST['object_type']);
            if (defined('AJAX_REQUEST')) {
                Registry::get('ajax')->assign('deleted', true);
            } elseif (!empty($_SERVER['HTTP_REFERER'])) {
                return array(CONTROLLER_STATUS_REDIRECT, $_SERVER['HTTP_REFERER']);
            }
        }
        exit;
    }
    //
    // Delete image pair
    //
    if ($mode == 'delete_image_pair') {
        if (AREA == 'A' && !empty($auth['user_id'])) {
            fn_delete_image_pair($_REQUEST['pair_id'], $_REQUEST['object_type']);
            if (defined('AJAX_REQUEST')) {
                Registry::get('ajax')->assign('deleted', true);
            }
        }
        exit;
    }
    return;
}
if ($mode == 'captcha') {
    $verification_id = $_REQUEST['verification_id'];
    if (empty($verification_id)) {
        $verification_id = 'common';
    }
    $verification_settings = Settings::instance()->getValues('Image_verification');
    $fonts = array(Registry::get('config.dir.lib') . 'other/captcha/verdana.ttf');
Beispiel #4
0
function fn_exim_1c_add_product_image($filename, $dir_1c_images, $product_id, $type, $lang_code)
{
    if (file_exists($dir_1c_images . $filename)) {
        $detail_file = fn_explode('.', $filename);
        $type_file = array_shift($detail_file);
        $condition = db_quote(" AND images.image_path LIKE ?s", "%" . $type_file . "%");
        $images = db_get_array("SELECT images.image_id, images_links.pair_id" . " FROM ?:images AS images" . " LEFT JOIN ?:images_links AS images_links ON images.image_id = images_links.detailed_id" . " WHERE images_links.object_id = ?i {$condition}", $product_id);
        foreach ($images as $image) {
            fn_delete_image_pair($image['pair_id'], 'product');
        }
        $image_data[] = array('name' => $filename, 'path' => $dir_1c_images . $filename, 'size' => filesize($dir_1c_images . $filename));
        $pair_data[] = array('pair_id' => '', 'type' => $type, 'object_id' => 0, 'image_alt' => '', 'detailed_alt' => '');
        $pair_ids = fn_update_image_pairs(array(), $image_data, $pair_data, $product_id, 'product', array(), 1, $lang_code);
    }
}
Beispiel #5
0
/**
 * Delete all images pairs for object
 */
function fn_clean_image_pairs($object_id, $object_type, $revision = null, $revision_id = null)
{
    $table = 'images_links';
    $itable = 'images';
    $cond = '';
    $rev_data = array();
    if (AREA == 'A' && Registry::is_exist('revisions') && !Registry::get('revisions.working') && $revision !== null) {
        $revisions = Registry::get('revisions');
        if (!empty($object_type) && !empty($revisions['objects'][$object_type]) && !empty($revisions['objects'][$object_type]['tables'])) {
            $object_data = $revisions['objects'][$object_type];
            if ($object_data['images']) {
                $entry = array($object_data['key'] => $object_id);
                $rev_data = db_get_row("SELECT revision, revision_id FROM ?:revisions WHERE object = ?s AND object_id = ?i GROUP BY revision_id", $object_type, $object_id);
                $table = 'rev_images_links';
                $itable = 'rev_images';
                $rev_data = array('revision' => $revision, 'revision_id' => $revision_id);
                $cond = db_quote(" AND revision = ?i AND revision_id = ?i", $revision, $revision_id);
            }
        }
    }
    $pair_data = db_get_hash_array("SELECT pair_id, image_id, detailed_id, type FROM ?:{$table} WHERE object_id = ?i AND object_type = ?s ?p", 'pair_id', $object_id, $object_type, $cond);
    foreach ($pair_data as $pair_id => $p_data) {
        fn_delete_image_pair($pair_id, $object_type, $rev_data);
    }
}
Beispiel #6
0
            foreach ($data as $product) {
                if (!empty($product['product_id'])) {
                    $_REQUEST['update_all_vendors'] = $product['update_all_vendors'];
                    fn_update_product($product, $product['product_id'], $lang_code);
                    fn_set_notification('N', '', fn_twg_get_lang_var('twgadmin_saved'));
                } else {
                    $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'products', __('twgadmin_wrong_api_object_data')));
                }
            }
        } elseif ($object == 'images' && $action == 'delete') {
            foreach ($data as $image) {
                if (empty($image['pair_id'])) {
                    $response->addError('ERROR_WRONG_OBJECT_DATA', str_replace('[object]', 'images', __('twgadmin_wrong_api_object_data')));
                    continue;
                }
                fn_delete_image_pair($image['pair_id'], 'product');
            }
        }
        $response->returnResponse();
    }
}
if ($mode == 'post') {
    if ($action == 'auth.svc') {
        $connector = new TwigmoConnector();
        $request = $connector->parseResponse($_REQUEST['data']);
        if (!$connector->responseIsOk($request) || empty($request['data']['user_login']) || empty($request['data']['password'])) {
            $connector->onError();
        }
        $_POST = $_REQUEST = array_merge($_REQUEST, $request['data']);
        list($status, $user_data, $user_login, $password, $salt) = fn_auth_routines($_REQUEST, $auth);
        $redirect_to_mv_url = fn_twg_check_for_vendor_url($status, $user_data);