Example #1
0
 public static function addSqlAssociation($table, $alias, $inner_join = true, $on = null, $force_not_default = false)
 {
     $sql = parent::addSqlAssociation($table, $alias, $inner_join, $on, $force_not_default);
     if (!Module::isInstalled('agilemultipleshop')) {
         return $sql;
     }
     $eaccess = AgileSellerManager::get_entity_access($table);
     if ($eaccess['owner_table_type'] == AgileSellerManager::OWNER_TABLE_UNKNOWN) {
         return $sql;
     }
     $xr_table = $eaccess['owner_xr_table'];
     $include_shared = '';
     if (!$eaccess['is_exclusive']) {
         $include_shared = ',0';
     }
     if (Shop::$id_shop_owner > 0) {
         $join = $inner_join ? 'INNER JOIN ' : 'LEFT JOIN ';
         if ($table == 'feature') {
             $join = 'LEFT JOIN ';
         }
         if ($eaccess['owner_table_type'] == AgileSellerManager::OWNER_TABLE_DEFINED) {
             $sql .= $join . _DB_PREFIX_ . $table . '_owner ' . $table . '_owner ON (' . $alias . '.id_' . $table . '=' . $table . '_owner.id_' . $table . ' AND IFNULL(' . $table . '_owner.id_owner,0) IN (' . Shop::$id_shop_owner . $include_shared . '))';
         } else {
             $sql .= $join . _DB_PREFIX_ . 'object_owner ' . $table . '_object_owner ON (' . $table . '_object_owner.entity=\'' . $table . '\' AND ' . $alias . '.id_' . $table . '= ' . $table . '_object_owner.id_object AND IFNULL(' . $table . '_object_owner.id_owner,0) IN (' . Shop::$id_shop_owner . $include_shared . '))';
         }
     }
     return $sql;
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     $this->domain = Tools::getShopDomain(true);
     $this->virtual_uri = '';
     $this->base_uri = '';
 }
Example #3
0
    /**
     * Load ObjectModel
     * @param $id
     * @param $id_lang
     * @param $entity \ObjectModel
     * @param $entity_defs
     * @param $id_shop
     * @param $should_cache_objects
     * @throws \PrestaShopDatabaseException
     */
    public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cache_objects)
    {
        // Load object from database if object id is present
        $cache_id = 'objectmodel_' . $entity_defs['classname'] . '_' . (int) $id . '_' . (int) $id_shop . '_' . (int) $id_lang;
        if (!$should_cache_objects || !\Cache::isStored($cache_id)) {
            $sql = new \DbQuery();
            $sql->from($entity_defs['table'], 'a');
            $sql->where('a.`' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id);
            // Get lang informations
            if ($id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
                $sql->leftJoin($entity_defs['table'] . '_lang', 'b', 'a.`' . bqSQL($entity_defs['primary']) . '` = b.`' . bqSQL($entity_defs['primary']) . '` AND b.`id_lang` = ' . (int) $id_lang);
                if ($id_shop && !empty($entity_defs['multilang_shop'])) {
                    $sql->where('b.`id_shop` = ' . (int) $id_shop);
                }
            }
            // Get shop informations
            if (\ShopCore::isTableAssociated($entity_defs['table'])) {
                $sql->leftJoin($entity_defs['table'] . '_shop', 'c', 'a.`' . bqSQL($entity_defs['primary']) . '` = c.`' . bqSQL($entity_defs['primary']) . '` AND c.`id_shop` = ' . (int) $id_shop);
            }
            if ($object_datas = \Db::getInstance()->getRow($sql)) {
                if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
                    $sql = 'SELECT *
							FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang`
							WHERE `' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id . ($id_shop && $entity->isLangMultishop() ? ' AND `id_shop` = ' . (int) $id_shop : '');
                    if ($object_datas_lang = \Db::getInstance()->executeS($sql)) {
                        foreach ($object_datas_lang as $row) {
                            foreach ($row as $key => $value) {
                                if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) {
                                    if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) {
                                        $object_datas[$key] = array();
                                    }
                                    $object_datas[$key][$row['id_lang']] = $value;
                                }
                            }
                        }
                    }
                }
                $entity->id = (int) $id;
                foreach ($object_datas as $key => $value) {
                    if (array_key_exists($key, $entity)) {
                        $entity->{$key} = $value;
                    } else {
                        unset($object_datas[$key]);
                    }
                }
                if ($should_cache_objects) {
                    \Cache::store($cache_id, $object_datas);
                }
            }
        } else {
            $object_datas = \Cache::retrieve($cache_id);
            if ($object_datas) {
                $entity->id = (int) $id;
                foreach ($object_datas as $key => $value) {
                    $entity->{$key} = $value;
                }
            }
        }
    }
Example #4
0
 public function genreYML()
 {
     header('content-type: text/xml');
     $ci = ShopCore::$ci;
     $pictureBaseUrl = base_url() . "uploads/shop/products/main/";
     /* @var $p SProducts */
     foreach ($this->getProducts() as $p) {
         /* @var $v SProductVariants */
         foreach ($p->getProductVariants() as $v) {
             if (!$v->getPrice()) {
                 continue;
             }
             $unique_id = $p->getId() . $v->getId();
             $param = ShopCore::app()->SPropertiesRenderer->renderPropertiesArray($p);
             $this->offers[$unique_id]['url'] = ShopCore::$ci->config->item('base_url') . '/shop/product/' . $p->url;
             $this->offers[$unique_id]['price'] = $v->getPrice();
             $this->offers[$unique_id]['currencyId'] = $this->currencyCode;
             $this->offers[$unique_id]['categoryId'] = $p->getCategoryId();
             $this->offers[$unique_id]['picture'] = $pictureBaseUrl . $v->getMainImage();
             $images = null;
             $images = $p->getSProductImagess();
             if (count($images) > 0) {
                 foreach ($images as $key => $image) {
                     $this->offers[$unique_id]['picture' . $key] = productImageUrl('products/additional/' . $image->getImageName());
                 }
             }
             $this->offers[$unique_id]['name'] = $this->forName($p->getName(), $v->getName());
             $this->offers[$unique_id]['vendor'] = $p->getBrand() ? htmlspecialchars($p->getBrand()->getName()) : ' ';
             $this->offers[$unique_id]['vendorCode'] = $v->getNumber() ? htmlspecialchars($v->getNumber()) : ' ';
             $this->offers[$unique_id]['description'] = htmlspecialchars($p->getFullDescription());
             $this->db->select('value');
             $this->db->where('id', 1);
             $query = $this->db->get('mod_yandex_market_adalt');
             $adalt = $query->row_array();
             if ($adalt['value'] == 1) {
                 $this->offers[$unique_id]['adult'] = 'true';
             }
             $this->offers[$unique_id]['param'] = $param;
         }
     }
     echo '<?xml version="1.0" encoding="utf-8"?>
                         <!DOCTYPE yml_catalog SYSTEM "shops.dtd">
                         <yml_catalog date="' . date('Y-m-d H:i') . '">
                         <shop>
                         <name>' . $this->settings['site_short_title'] . '</name>
                         <company>' . $this->settings['site_title'] . '</company>
                         <url>' . $ci->config->item('base_url') . '</url>
                         <platform>ImageCMS</platform>
                         <version>' . IMAGECMS_NUMBER . '</version>
                         <email>' . siteinfo('siteinfo_adminemail') . '</email>';
     echo "\n\n";
     echo '<currencies>
                         <currency id="' . $this->currencyCode . '" rate="1"/>
                 </currencies>' . "\n\n";
     echo $this->renderCategories();
     echo $this->renderOffers();
     echo "</shop>\n";
     echo "</yml_catalog>";
 }
Example #5
0
 protected function loadSettings()
 {
     $settingsKey = $this->paymentMethod->getId() . '_TreasurerData';
     $data = unserialize(ShopCore::app()->SSettings->{$settingsKey});
     if ($data === false) {
         $data = array();
     }
     return array_map('encode', $data);
 }
Example #6
0
 public function set_price($priceRange = null)
 {
     if (null === $priceRange) {
         $priceRange = \ShopCore::app()->SFilter->getPricerange();
     }
     $minPrice = (int) $priceRange['minCost'];
     $maxPrice = (int) $priceRange['maxCost'];
     $curMin = $_GET['lp'] ? (int) $_GET['lp'] : $minPrice;
     $curMax = $_GET['rp'] ? (int) $_GET['rp'] : $maxPrice;
     \CMSFactory\assetManager::create()->setData(array('minPrice' => (int) $priceRange['minCost'], 'maxPrice' => (int) $priceRange['maxCost'], 'curMax' => $curMax, 'curMin' => $curMin));
 }
Example #7
0
 public function genreYML($indicator = null)
 {
     header('content-type: text/xml');
     $ci = ShopCore::$ci;
     $pictureBaseUrl = base_url() . "uploads/shop/products/main/";
     /* @var $p SProducts */
     foreach ($this->getProducts() as $p) {
         /* @var $v SProductVariants */
         foreach ($p->getProductVariants() as $v) {
             if (!$v->getPrice()) {
                 continue;
             }
             $unique_id = $p->getId() . $v->getId();
             $param = ShopCore::app()->SPropertiesRenderer->renderPropertiesArray($p);
             $this->offers[$unique_id]['url'] = ShopCore::$ci->config->item('base_url') . '/shop/product/' . $p->url;
             $this->offers[$unique_id]['priceRUAH'] = $v->getPrice();
             $this->offers[$unique_id]['categoryId'] = $p->getCategoryId();
             $this->offers[$unique_id]['image'] = $pictureBaseUrl . $v->getMainImage();
             if ($indicator == null) {
                 $this->offers[$unique_id]['name'] = $this->forName($p->getName(), $v->getName());
             }
             if ($indicator == 1) {
                 $vendor = $p->getBrand() ? htmlspecialchars($p->getBrand()->getName()) : ' ';
                 $name = $this->forName($p->getName(), $v->getName());
                 $query = $this->db->query("\n                           SELECT shop_product_properties_data.value  FROM mod_hotline_properties\n                           LEFT JOIN shop_product_properties_data ON (mod_hotline_properties.property_id = shop_product_properties_data.property_id)\n                           WHERE shop_product_properties_data.product_id = " . $p->getId() . "  and category_id = " . $p->getCategoryId() . " \n                        ");
                 $arr = $query->result_array();
                 $properties = '';
                 foreach ($arr as $value) {
                     $properties .= $value['value'] . ' ';
                 }
                 $this->offers[$unique_id]['name'] = $vendor . ' ' . $p->getName() . ' ' . $v->getNumber() . ' ' . $properties;
             }
             $this->offers[$unique_id]['vendor'] = $p->getBrand() ? htmlspecialchars($p->getBrand()->getName()) : ' ';
             $this->offers[$unique_id]['code'] = $v->getNumber() ? htmlspecialchars($v->getNumber()) : ' ';
             $this->offers[$unique_id]['description'] = htmlspecialchars($p->getFullDescription());
             if ((int) $v->getStock() > 0) {
                 $this->offers[$unique_id]['stock'] = 'На складе';
             }
         }
     }
     $model = ShopSettingsQuery::create()->filterByName('shopNumber')->findOne();
     $shop = $model->getValue();
     echo '<?xml version="1.0" encoding="utf-8"?>
                         <price>
                         <date>' . date('Y-m-d H:i') . '</date>
                         <firmName>' . $this->settings['site_title'] . '</firmName>
                         <firmId>' . $shop . '</firmId>
                         <rate>8.12</rate>';
     echo "\n\n";
     echo $this->renderCategoriesHotline();
     echo $this->renderOffersHotline();
     echo "</price>\n";
 }
 /**
  * Provides user login
  * @return json
  * @access public
  * @copyright ImageCMS (c) 2013
  */
 public function login()
 {
     if (!$this->dx_auth->is_logged_in()) {
         $this->form_validation->set_message('required', lang('The %s is required', 'auth'));
         /** Set form validation rules */
         $this->form_validation->set_rules('email', lang('E-Mail Address', 'auth'), 'trim|required|min_length[3]|xss_clean|valid_email|callback_email_check_for_login');
         $this->form_validation->set_rules('password', lang('Password', 'auth'), 'trim|required|min_length[3]|max_length[30]|xss_clean');
         $this->form_validation->set_rules('remember', lang('Remeber me', 'auth'), 'integer');
         $this->form_validation->set_rules('redirect_to', lang('Redirect to', 'auth'), 'trim|min_length[3]|max_length[255]|xss_clean');
         /** Validate rules and change password */
         $validationResult = $this->form_validation->run();
         $doLoginResult = $this->dx_auth->login($this->input->post('email'), $this->input->post('password'), $this->input->post('remember'));
         /** Prepare response */
         if (true === $validationResult and true === $doLoginResult) {
             if (class_exists('ShopCore') && SHOP_INSTALLED) {
                 ShopCore::app()->SCart->transferCartData();
             }
             $jsonResponse['msg'] = lang('User successfully logged in', 'auth');
             $jsonResponse['status'] = true;
             $jsonResponse['refresh'] = true;
             $jsonResponse['redirect'] = FAlSE;
         } else {
             /** Check if the user is failed logged in because user is banned user or not */
             if ($this->dx_auth->is_banned()) {
                 $this->ban_reason = $this->dx_auth->get_ban_reason();
                 $this->banned();
                 exit;
             } else {
                 $validationResult = validation_errors();
                 if (empty($validationResult)) {
                     $jsonResponse['msg'] = lang('User with this name and password is not found', 'auth');
                     $jsonResponse['validations'] = array('email' => lang('User with this name and password is not found', 'auth'));
                 } else {
                     $jsonResponse['msg'] = $validationResult;
                     $jsonResponse['validations'] = array('email' => form_error('email'), 'password' => form_error('password'), 'remember' => form_error('remember'));
                 }
                 /** Return json data for render login form */
                 $jsonResponse['status'] = false;
                 $jsonResponse['refresh'] = false;
                 $jsonResponse['redirect'] = false;
             }
         }
     } else {
         $jsonResponse['refresh'] = false;
         $jsonResponse['redirect'] = false;
         $jsonResponse['status'] = false;
         $jsonResponse['msg'] = lang('User is already logged in', 'auth');
     }
     /** return JSON Data */
     echo json_encode($jsonResponse);
 }
Example #9
0
 /**
  * Generates an array of data to create a body xml
  */
 public function index()
 {
     $ci = ShopCore::$ci;
     $this->settings = $this->ymarket_model->init();
     $this->currencyCode = ShopCore::app()->SCurrencyHelper->current->code;
     $categories = \Category\CategoryApi::getInstance()->getCategory($this->settings['unserCats']);
     /* @var $p SProducts */
     foreach ($this->ymarket_model->getProducts($this->settings['unserCats']) as $p) {
         $param = ShopCore::app()->SPropertiesRenderer->renderPropertiesArray($p);
         $additionalImages = $this->getAdditionalImages($p);
         /* @var $v SProductVariants */
         foreach ($p->getProductVariants() as $v) {
             if (!$v->getPrice()) {
                 continue;
             }
             $unique_id += $p->getId() . '.' . $v->getId();
             $this->offers[$unique_id]['url'] = $ci->config->item('base_url') . '/shop/product/' . $p->url;
             $this->offers[$unique_id]['price'] = $v->getPrice();
             $this->offers[$unique_id]['currencyId'] = $this->currencyCode;
             $this->offers[$unique_id]['categoryId'] = $p->getCategoryId();
             $this->offers[$unique_id]['picture'] = array_merge(array(productImageUrl('products/main/' . $v->getMainImage())), $additionalImages);
             $this->offers[$unique_id]['name'] = $this->forName($p->getName(), $v->getName());
             $this->offers[$unique_id]['vendor'] = $p->getBrand() ? htmlspecialchars($p->getBrand()->getName()) : '';
             $this->offers[$unique_id]['vendorCode'] = $v->getNumber() ? $v->getNumber() : '';
             $this->offers[$unique_id]['description'] = htmlspecialchars($p->getFullDescription());
             if ($this->settings['adult']) {
                 $this->offers[$unique_id]['adult'] = 'true';
             }
             $this->offers[$unique_id]['param'] = $param;
         }
     }
     $infoXml['categories'] = $categories;
     $infoXml['offers'] = $this->offers;
     $infoXml['site_short_title'] = $this->settings['site_short_title'];
     $infoXml['site_title'] = $this->settings['site_title'];
     $infoXml['base_url'] = $ci->config->item('base_url');
     $infoXml['imagecms_number'] = IMAGECMS_NUMBER;
     $infoXml['siteinfo_adminemail'] = siteinfo('siteinfo_adminemail');
     $infoXml['currencyCode'] = $this->currencyCode;
     \CMSFactory\assetManager::create()->setData('infoXml', $infoXml)->render('main', true);
     exit;
 }
Example #10
0
 public function _install()
 {
     $this->db->where('name', 'digital_products')->update('components', array('autoload' => '1', 'enabled' => '1'));
     $field = new CustomFields();
     $field->setEntity('Product')->setIsActive(true)->setname('dplink')->setfLabel('Link to digital content')->settypeId(3);
     $field->save();
     ShopCore::app()->SSettings->set('DPLinkCFID', $field->getId());
     /** We recomend to use http://ellislab.com/codeigniter/user-guide/database/forge.html */
     /**
      $this->load->dbforge();
     
      $fields = array(
      'id' => array('type' => 'INT', 'constraint' => 11, 'auto_increment' => TRUE,),
      'name' => array('type' => 'VARCHAR', 'constraint' => 50,),
      'value' => array('type' => 'VARCHAR', 'constraint' => 100,)
      );
     
      $this->dbforge->add_key('id', TRUE);
      $this->dbforge->add_field($fields);
      $this->dbforge->create_table('mod_empty', TRUE);
     */
     /**
      */
 }
    ?>
 setAction" data-rel="tooltip"
                    data-placement="top" data-original-title="<?php 
    echo lang('Promotion', 'admin');
    ?>
"><i class="icon-star"></i>
            </button>
        <?php 
}
?>
    </td>
    <td>
        <span class="pull-right">
            <span
                    class="neigh_form_field help-inline"></span>&nbsp;&nbsp;<?php 
echo ShopCore::app()->SCurrencyHelper->getSymbolById($model->firstVariant->getCurrency());
?>
</span>

        <div class="p_r o_h frame_price number">
            <?php 
$price = preg_replace('/\\.?0*$/', '', number_format($model->firstVariant->getPriceInMain(), 5, ".", ""));
?>
            <?php 
$price = $price ? $price : 0;
?>
            <input type="text"
                   value="<?php 
if (isset($price)) {
    echo $price;
}
Example #12
0
 /**
  * Prepare and return template for module 
  * @param type $data
  * @param type $pageId
  * @return type
  */
 public function prepareInterface($data, $pageId)
 {
     $currentCategories = $this->db->where('content_id', $pageId)->get('mod_shop_news')->row_array();
     $currentCategories = explode(',', $currentCategories['shop_categories_ids']);
     return \CMSFactory\assetManager::create()->setData(array('shopNews' => $data, 'categories' => ShopCore::app()->SCategoryTree->getTree(), 'currentCategories' => $currentCategories))->registerScript('scripts')->fetchTemplate('/admin/adminModuleInterface');
 }
 private function bootstrapInitShop()
 {
     if (FALSE == $this->CI->config->item('is_installed') || FALSE === ($shopPath = getModulePath('shop'))) {
         return;
     }
     define('SHOP_DIR', $shopPath);
     ClassLoader::getInstance()->registerNamespacedPath(SHOP_DIR . 'models2/generated-classes')->registerClassesPath(SHOP_DIR . 'models2/generated-classes')->registerClassesPath(SHOP_DIR . 'classes')->registerNamespacedPath(SHOP_DIR . 'classes');
     ShopCore::init();
     // Diable CSRF library form web money service
     $this->CI =& get_instance();
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['result'] == 'true' && $_GET['pm'] > 0) {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for robokassa
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['getResult'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for privat
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'order' && $this->CI->uri->segment(3) == 'view' && $_POST) {
         define('ICMS_DISBALE_CSRF', true);
     }
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['succes'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'cart' && $this->CI->uri->segment(3) == 'view' && $_GET['fail'] == 'true') {
         define('ICMS_DISBALE_CSRF', true);
     }
     if (isset($_SERVER['HTTP_REFERER']) and strpos($_SERVER['HTTP_REFERER'] . "", 'facebook.com')) {
         define('ICMS_DISBALE_CSRF', true);
     }
     // Support for privat
     if ($this->CI->uri->segment(1) == 'shop' && $this->CI->uri->segment(2) == 'order' && $this->CI->uri->segment(3) == 'view') {
         define('ICMS_DISBALE_CSRF', true);
     }
     //new payment system
     if (preg_match("/payment_method_/i", $this->CI->uri->segment(1)) || preg_match("/payment_method_/i", $this->CI->uri->segment(2))) {
         define('ICMS_DISBALE_CSRF', true);
     }
 }
 public function sidebar_cats()
 {
     echo '<div id="categories">';
     if (isset($_GET['first'])) {
         $this->db->where('name', 'shop');
         $this->db->limit(1);
         $query = $this->db->get('components');
         if ($query->num_rows() > 0) {
             ShopCore::app()->SAdminSidebarRenderer->render();
             exit;
         }
     }
     $this->template->assign('tree', $this->lib_category->build());
     $this->template->show('cats_sidebar', FALSE);
     echo '</div>';
 }
Example #15
0
 /**
  * get discount for product in cart with his discount
  * @access private
  * @author DevImageCms
  * @param ----
  * @return float 
  * @copyright (c) 2013, ImageCMS
  */
 private function getDiscountProducts()
 {
     foreach ($this->cartData as $item) {
         $priceOrigin = number_format($item->originPrice, \ShopCore::app()->SSettings->pricePrecision, '.', '');
         // new Cart
         if (abs($priceOrigin - $item->price) > 1) {
             $discountValue += ($priceOrigin - $item->price) * $item->quantity;
         }
     }
     return $discountValue;
 }
 function register($username, $password, $email, $address = '', $key, $phone = '', $login_user = TRUE)
 {
     // Load Models
     $this->ci->load->model('dx_auth/users', 'users');
     $this->ci->load->model('dx_auth/user_temp', 'user_temp');
     $this->ci->load->helper('url');
     // Default return value
     $result = FALSE;
     $new_user = array('username' => $username, 'password' => crypt($this->_encode($password)), 'address' => $address, 'email' => $email, 'key' => $key, 'phone' => $phone, 'last_ip' => $this->ci->input->ip_address());
     // Do we need to send email to activate user
     if ($this->ci->config->item('DX_email_activation')) {
         // Add activation key to user array
         $new_user['activation_key'] = md5(rand() . microtime());
         // Create temporary user in database which means the user still unactivated.
         $insert = $this->ci->user_temp->create_temp($new_user);
         $from = $this->ci->config->item('DX_webmaster_email');
         $subject = sprintf(lang('auth activate subject'), $this->ci->config->item('DX_website_name'));
         // Activation Link
         $new_user['activate_url'] = site_url($this->ci->config->item('DX_activate_uri') . "{$new_user['email']}/{$new_user['activation_key']}");
         // Trigger event and get email content
         $this->ci->dx_auth_event->sending_activation_email($new_user, $message);
         // Send email with activation link
         //            $this->_email($email, $from, $subject, $message);
     } else {
         // Create user
         $insert = $this->ci->users->create_user($new_user);
         $last_user_id = $this->ci->db->insert_id();
         // Trigger event
         $this->ci->dx_auth_event->user_activated($last_user_id);
     }
     if ($insert) {
         // Replace password with plain for email
         $new_user['password'] = $password;
         $new_user['id_user'] = $last_user_id;
         $result = $new_user;
         // Send email based on config
         // Check if user need to activate it's account using email
         if ($this->ci->config->item('DX_email_activation')) {
             // Create email
             $from = $this->ci->config->item('DX_webmaster_email');
             $subject = sprintf(lang('auth activate subject'), $this->ci->config->item('DX_website_name'));
             // Activation Link
             $new_user['activate_url'] = site_url();
             // Trigger event and get email content
             $this->ci->dx_auth_event->sending_account_email($new_user, $message);
             // Send email with activation link
             //                $this->_email($email, $from, $subject, $message);
         } else {
             // Check if need to email account details
             if ($this->ci->config->item('DX_email_account_details')) {
                 // Create email
                 $from = $this->ci->config->item('DX_webmaster_email');
                 $subject = sprintf(lang('auth account subject'), $this->ci->config->item('DX_website_name'));
                 // Trigger event and get email content
                 $this->ci->dx_auth_event->sending_account_email($new_user, $message);
                 // Send email with account details
                 //                    $this->_email($email, $from, $subject, $message);
             }
             $user_variables = array('user_name' => $username, 'user_password' => $password, 'user_address' => $address, 'user_email' => $email, 'user_phone' => $phone);
             \cmsemail\email::getInstance()->sendEmail($email, 'create_user', $user_variables);
             if ($login_user) {
                 if ($this->login($email, $password)) {
                     if (class_exists('ShopCore')) {
                         ShopCore::app()->SCart->transferCartData();
                     }
                     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
                         redirect('', 'location');
                     }
                     //                    if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
                 }
             }
         }
     }
     return $result;
 }
Example #17
0
 /**
  * Render admin template
  */
 public function renderAdmin()
 {
     $categories = \ShopCore::app()->SCategoryTree->getTree();
     $categoriesT = array();
     foreach ($categories as $category) {
         if ($category->parent_id == 0) {
             $categoriesT[$category->id]['category'] = $category;
         }
     }
     foreach ($categories as $category) {
         if ($categoriesT[$category->parent_id]) {
             if (!$categoriesT[$category->parent_id]['children']) {
                 $categoriesT[$category->parent_id]['children'] = array();
             }
             $categoriesT[$category->parent_id]['children'][$category->id]['category'] = $category;
         }
     }
     foreach ($categories as $category) {
         foreach ($categoriesT as $key => $categoryT) {
             if (isset($categoryT['children']) && $categoryT['children'][$category->parent_id]) {
                 if (!$categoriesT[$key]['children'][$category->parent_id]['children']) {
                     $categoriesT[$key]['children'][$category->parent_id]['children'] = array();
                 }
                 $categoriesT[$key]['children'][$category->parent_id]['children'][] = $category;
             }
         }
     }
     $this->cAssetManager->registerScript('scripts', 'after');
     $this->cAssetManager->display('admin/main', array('handler' => $this->name, 'openLevels' => $this->getOpenLevels(), 'categoriesT' => $categoriesT));
 }
 /**
  * get origin product price for id variant
  * @param (int) $id
  * @return (float) price
  */
 public function getPrice($id)
 {
     $priceProd = $this->db->query("select price from shop_product_variants where id = '{$id}'")->row();
     return number_format($priceProd->price, ShopCore::app()->SSettings->pricePrecision, '.', '');
 }
Example #19
0
 function sending_forgot_password_email($data, &$content)
 {
     if (class_exists(ShopCore)) {
         $replaceData = array('%webSiteName%' => $this->ci->config->item('DX_website_name'), '%resetPasswordUri%' => $data['reset_password_uri'], '%password%' => $data['password'], '%key%' => $data['key'], '%webMasterEmail%' => $this->ci->config->item('DX_webmaster_email'));
         $content = str_replace(array_keys($replaceData), $replaceData, ShopCore::app()->SSettings->forgotPasswordMessageText);
     } else {
         // Create content
         $content = sprintf($this->ci->lang->line('auth_forgot_password_content'), $this->ci->config->item('DX_website_name'), $data['reset_password_uri'], $data['password'], $data['key'], $this->ci->config->item('DX_webmaster_email'), $this->ci->config->item('DX_website_name'));
     }
 }
 /**
  * Validation atribute lables
  * @return array
  */
 public function attributeLabels()
 {
     return array('value' => ShopCore::t(lang('Value', 'mod_discount')));
 }
            <?php 
if ($pagination > '') {
    ?>
                <?php 
    if (isset($pagination)) {
        echo $pagination;
    }
    ?>
            <?php 
}
?>
            <div class="pagination pull-right">
                <select style="max-width:60px;" onchange="change_per_page(this);
                                return false;">
                    <?php 
if ($_COOKIE['per_page'] == ShopCore::app()->SSettings->adminProductsPerPage) {
    ?>
<option selected="selected" value="<?php 
    echo $_COOKIE['per_page'];
    ?>
"><?php 
    echo $_COOKIE['per_page'];
    ?>
</option><?php 
}
?>
                    <option <?php 
if ($_COOKIE['per_page'] == 10) {
    ?>
selected="selected"<?php 
}
            ?>
                        </div>
                        <!-- End. Wish List & Compare List buttons -->
                    </div>
                <?php 
        }
        ?>
                <!-- End. Collect information about Variants, for future processing -->
                <?php 
        if (!$opi_widget && !$opi_compare && !$opi_defaultItem && !$opi_wishListPage) {
            ?>
                    <div class="frame-without-top">
                        <div class="no-vis-table">
                            <!--Start. Description-->
                            <?php 
            if ($props = ShopCore::app()->SPropertiesRenderer->renderPropertiesInlineNew($p->getId())) {
                ?>
                                <div class="short-desc">
                                    <p><?php 
                echo $props;
                ?>
</p>
                                </div>
                            <?php 
            } elseif (trim($p->getShortDescription()) != '') {
                ?>
                                <div class="short-desc">
                                    <?php 
                echo strip_tags($p->getShortDescription());
                ?>
                                </div>
        <div class="btn-autocomplete">
        <a href="<?php 
echo shop_url('search');
?>
?text=<%- items.queryString %>"  class="f-s_0 t-d_u">
        <span class="icon_show_all"></span><span class="text-el"><?php 
echo lang('Посмотреть все результаты', 'lightVertical');
?>
 →</span>
        </a>
        </div>
        <!-- End. Show link  -->
        <% } else {%>    
    <div class="msg f-s_0">
    <div class="info"><span class="icon_info"></span><span class="text-el"><?php 
echo ShopCore::t(lang('По Вашему запросу ничего не найдено', 'lightVertical'));
?>
</span></div>
    </div>
    <% }%>
    </div>
    </div>
</script>

        <script type="text/template" id="reportappearance">
            <% var nextCsCond = nextCs == '' ? false : true %>
            <ul class="items items-bask item-report">
            <li>
            <a href="<%-item.url%>" class="frame-photo-title" title="<%-item.name%>">
            <span class="photo-block">
            <span class="helper"></span>
Example #24
0
 /**
  * Edit discount 
  * @paran (int) $id
  * @paran (string) $locale
  * @return html  
  */
 public function edit($id, $locale = null)
 {
     if (null === $locale) {
         $locale = \MY_Controller::getCurrentLocale();
     }
     if ($this->input->post()) {
         $postArray = $this->input->post();
         $typeDiscount = $postArray['type_discount'];
         $discauntManager = new \mod_discount\classes\DiscountManager();
         $discauntManager->validation($postArray, $id);
         if (count($discauntManager->error) == 0) {
             // If empty field with discount key, then generate key
             if ($postArray['key'] == null) {
                 $postArray['key'] = $this->generateDiscountKey();
             }
             //Prepare data for insert in table mod_shop_discounts
             $data = array('name' => $postArray['name'], 'key' => $postArray['key'], 'max_apply' => $postArray['max_apply'], 'type_value' => $postArray['type_value'], 'value' => $postArray['value'], 'type_discount' => $typeDiscount, 'date_begin' => strtotime($postArray['date_begin']), 'date_end' => strtotime($postArray['date_end']), 'active' => '1');
             //Prepare data for inserting in the table of selected discount type
             $typeDiscountData = $postArray[$typeDiscount];
             // Check range for cumulative discount
             if ($typeDiscount == "comulativ" and $this->discount_model_admin->checkRangeForCumulativeDiscount($postArray[$typeDiscount], $id)) {
                 showMessage(lang('Has been already created with the cumulative discount value', 'mod_discount'), '', 'r');
                 return;
             }
             // Insert data
             if ($this->discount_model_admin->updateDiscountById($id, $data, $typeDiscountData, $locale)) {
                 showMessage(lang('Changes saved', 'mod_discount'));
             }
             //Return to list of discounts, if user clicked 'save and exit'
             if ($postArray['action'] == 'tomain') {
                 pjax('/admin/components/init_window/mod_discount/index' . $_SESSION['QueryDiscountList']);
             } else {
                 pjax('/admin/components/init_window/mod_discount/edit/' . $id);
             }
         } else {
             showMessage(implode('<br/> ', $discauntManager->error), '', 'r');
         }
     } else {
         //Get list of user roles and info about current discount
         $userGroups = $this->discount_model_admin->getUserGroups(MY_Controller::getCurrentLocale());
         $discountData = $this->discount_model_admin->getDiscountAllDataById($id, $locale);
         //if can't get info about discount from database then 404 error
         if ($discountData == false) {
             $this->error404(lang('Discount not found', 'mod_discount'));
         }
         //If discount type user then get user name and email
         if ($discountData['type_discount'] == 'user') {
             $discountData['user']['userInfo'] = $this->discount_model_admin->getUserNameAndEmailById($discountData['user']['user_id']);
         }
         //If discount type product then get product name
         if ($discountData['type_discount'] == 'product') {
             $discountData['product']['productInfo'] = $this->discount_model_admin->getProductById($discountData['product']['product_id']);
         }
         //Prepare date for rendering
         $data = array('discount' => $discountData, 'userGroups' => $userGroups, 'CS' => $this->discount_model_admin->getMainCurrencySymbol(), 'filterQuery' => $_SESSION['QueryDiscountList'], 'categories' => ShopCore::app()->SCategoryTree->getTree(), 'languages' => $this->db->get('languages')->result_array(), 'locale' => $locale);
         //Render template and set data
         \CMSFactory\assetManager::create()->setData($data)->renderAdmin('edit');
     }
 }
*       $product->name(): method which return product name
*       $product->getmainimage(): method which return product main image
*       $product->getId(): method which return product id
*
*   $pagination: variale which contains HTML code of page pagination
*
*   $totalProducts: variale which contains total count of products in brand category
*
*   $model: (object) instance of SBrands
*
*   $Comments: array which contains count of comments for each product
*/
?>
    <!-- Get category tree -->
    <?php 
ShopCore::app()->SCategoryTree->getTree(SCategoryTree::MODE_MULTI);
?>
    <div class="frame-crumbs">
        <?php 
echo widget('path');
?>
    </div>

    <div class="frame-menu-main vertical-menu">
        <?php 
\Category\RenderMenu::create()->setConfig(array('cache' => TRUE))->load('category_menu');
?>
    </div>
    <div class="content">

        <div class="frame-inside">
 public function sortProductIdList(array $productList, $filterParams)
 {
     if (count($productList) < 2) {
         return false;
     }
     if (!isset($filterParams['filter_category'])) {
         throw new \Exception('Cannot sort when filterParams does not contains \'filter_category\'.', 5010);
     }
     foreach ($filterParams as $k => $v) {
         if ($v == '' || strpos($k, 'filter_') !== 0) {
             continue;
         }
         if ($k == 'filter_category') {
             continue;
         }
         throw new \Exception('Cannot sort when filterParams contains other filter than \'filter_category\'.', 5010);
     }
     $categoryId = $filterParams['filter_category'];
     /* Sorting items on one page only, with ONE SQL UPDATE query,
      * then fixing bugs (duplicates and 0 values) on next pages with more queries, if needed.
      *
      * Most complicated case example:
      * We have to sort items from offset 5, limit 5, on total object count: 14
      * The previous AND the next pages MUST NOT be impacted but fixed if needed.
      * legend:  #<id>|P<position>
      *
      * Before sort:
      * #1|P2 #2|P4 #3|P5 #7|P8 #6|P9   #5|P10 #8|P11 #10|P13 #12|P14 #11|P15   #9|P16 #12|P18 #14|P19 #22|P24
      * (there is holes in positions)
      *
      * Sort request:
      *                                 #5|P?? #10|P?? #12|P?? #8|P?? #11|P??
      *
      * After sort:
      * (previous page unchanged)       (page to sort: sort and no duplicates) (the next pages MUST be shifted to avoid duplicates if any)
      *
      * Request input:
      *                               [#5]P10 [#10]P13 [#12]P14 [#8]P11 [#11]P15
      */
     $maxPosition = max(array_values($productList));
     $sortedPositions = array_values($productList);
     sort($sortedPositions);
     // new positions to update
     // avoid '0', starts with '1', so shift right (+1)
     if ($sortedPositions[1] === 0) {
         foreach ($sortedPositions as $k => $v) {
             $sortedPositions[$k] = $v + 1;
         }
     }
     // combine old positions with new position in an array
     $combinedOldNewPositions = array_combine(array_values($productList), $sortedPositions);
     ksort($combinedOldNewPositions);
     // (keys: old positions starting at '1', values: new positions)
     $positionsMatcher = array_replace(array_pad(array(), $maxPosition, 0), $combinedOldNewPositions);
     // pad holes with 0
     array_shift($positionsMatcher);
     // shift because [0] is not used in MySQL FIELD()
     $fields = implode(',', $positionsMatcher);
     // update current pages.
     $updatePositions = 'UPDATE `' . _DB_PREFIX_ . 'category_product` cp
         INNER JOIN `' . _DB_PREFIX_ . 'product` p ON (cp.`id_product` = p.`id_product`)
         ' . \ShopCore::addSqlAssociation('product', 'p') . '
         SET cp.`position` = ELT(cp.`position`, ' . $fields . '),
             p.`date_upd` = "' . date('Y-m-d H:i:s') . '",
             product_shop.`date_upd` = "' . date('Y-m-d H:i:s') . '"
         WHERE cp.`id_category` = ' . $categoryId . ' AND cp.`id_product` IN (' . implode(',', array_keys($productList)) . ')';
     \Db::getInstance()->query($updatePositions);
     // Fixes duplicates on all pages
     \Db::getInstance()->query('SET @i := 0');
     $selectPositions = 'UPDATE`' . _DB_PREFIX_ . 'category_product` cp
         SET cp.`position` = (SELECT @i := @i + 1)
         WHERE cp.`id_category` = ' . $categoryId . '
         ORDER BY cp.`id_product` NOT IN (' . implode(',', array_keys($productList)) . '), cp.`position` ASC';
     \Db::getInstance()->query($selectPositions);
     return true;
 }
</script>
<div style="display: none;">
    <img src="<?php 
echo $model->firstVariant->getLargePhoto();
?>
" alt="<?php 
echo ShopCore::encode($model->getName());
?>
" class="vImgPr"/>
    <?php 
if (is_true_array($productImages)) {
    foreach ($productImages as $key => $image) {
        ?>
    <img src="<?php 
        echo productImageUrl('products/additional/' . $image->getImageName());
        ?>
" alt="<?php 
        echo ShopCore::encode($model->getName());
        ?>
 - <?php 
        echo ++$key;
        ?>
"/>
    <?php 
    }
}
?>
</div><?php 
$mabilis_ttl = 1444767728;
$mabilis_last_modified = 1440056636;
///home/igor/sites/skidka-shop.com.ua/www/templates/lightVertical/shop/product.tpl
Example #28
0
 /**
  * Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID)
  *
  * @param bool|string $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value
  * @return array
  */
 public function getContextListShopID($share = false)
 {
     return \ShopCore::getContextListShopID($share);
 }
Example #29
0
 /**
  * Change the current shop context
  *
  * @param int $type Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP
  * @param int $id ID shop if CONTEXT_SHOP or id shop group if CONTEXT_GROUP
  */
 public static function setContext($type, $id = null)
 {
     switch ($type) {
         case self::CONTEXT_ALL:
             self::$context_id_shop = null;
             self::$context_id_shop_group = null;
             break;
         case self::CONTEXT_GROUP:
             self::$context_id_shop = null;
             self::$context_id_shop_group = (int) $id;
             break;
         case self::CONTEXT_SHOP:
             self::$context_id_shop = (int) $id;
             self::$context_id_shop_group = Shop::getGroupFromShop($id);
             break;
         default:
             throw new PrestaShopException('Unknown context for shop');
     }
     self::$context = $type;
 }
Example #30
0
 /**
  * apply user gift
  * @access private
  * @author DevImageCms
  * @param ---
  * @return ---
  * @copyright (c) 2013, ImageCMS
  */
 private function applyGift()
 {
     $key = $this->input->post('gift');
     $aplyGift = false;
     foreach ($this->baseDiscount->discountType['all_order'] as $disc) {
         if ($disc['key'] == $key and $disc['is_gift']) {
             $value = $this->baseDiscount->getDiscountValue($disc, $this->baseDiscount->cart->getTotalPrice());
             $this->baseDiscount->cart->gift_info = $disc['key'];
             $this->baseDiscount->cart->gift_value = $value;
             if (\ShopCore::app()->SSettings->pricePrecision == 0) {
                 $this->baseDiscount->cart->gift_value = floor($value);
             }
             $cartTotalPrice = $this->baseDiscount->cart->getTotalPrice() - $value;
             $this->baseDiscount->cart->setTotalPrice($cartTotalPrice > 0 ? $cartTotalPrice : \Cart\BaseCart::MIN_ORDER_PRICE);
             $aplyGift = true;
             break;
         }
     }
     if (!$aplyGift) {
         $this->baseDiscount->cart->gift_error = TRUE;
     }
 }