public function init()
    {
        if (Tools::getValue('supplier_rewrite')) {
            $name_supplier = str_replace('-', '%', Tools::getValue('supplier_rewrite'));
            //
            // TODO:: need to core update Prestashop code and
            // DB for link_rewrite for suppliers
            // Should we use the Mysql FullText Index Search ??
            //
            $sql = 'SELECT sp.`id_supplier`
				FROM `' . _DB_PREFIX_ . 'supplier` sp
				LEFT JOIN `' . _DB_PREFIX_ . 'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`)
				WHERE sp.`name` LIKE \'' . $name_supplier . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_supplier = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_supplier > 0) {
                $_GET['id_supplier'] = $id_supplier;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        }
        parent::init();
    }
 public function __construct()
 {
     $this->table = 'smart_blog_comment';
     $this->className = 'Blogcomment';
     $this->module = 'smartblog';
     $this->context = Context::getContext();
     $this->bootstrap = true;
     if (Shop::isFeatureActive()) {
         Shop::addTableAssociation($this->table, array('type' => 'shop'));
     }
     parent::__construct();
     $this->fields_list = array('id_smart_blog_comment' => array('title' => $this->l('Id'), 'width' => 50, 'type' => 'text'), 'email' => array('title' => $this->l('Email'), 'width' => 50, 'type' => 'text', 'lang' => true), 'meta_title' => array('title' => $this->l('Post Title'), 'filter_key' => 'smp!meta_title', 'align' => 'center'), 'name' => array('title' => $this->l('Name'), 'width' => 150, 'type' => 'text'), 'content' => array('title' => $this->l('Comment'), 'width' => 200, 'type' => 'text', 'callback' => 'getCommentClean'), 'created' => array('title' => $this->l('Date'), 'width' => 60, 'type' => 'text', 'lang' => true), 'active' => array('title' => $this->l('Status'), 'width' => '70', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'icon' => 'icon-trash', 'confirm' => $this->l('Delete selected items?')));
     $this->_join = ' LEFT JOIN ' . _DB_PREFIX_ . 'smart_blog_comment_shop sbs ON a.id_smart_blog_comment=sbs.id_smart_blog_comment && sbs.id_shop IN(' . implode(',', Shop::getContextListShopID()) . ')';
     $this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'smart_blog_post_lang smp ON a.id_post=smp.id_smart_blog_post and smp.id_lang = ' . (int) Context::getContext()->language->id;
     $this->_select = 'sbs.id_shop';
     $this->_defaultOrderBy = 'a.id_smart_blog_comment';
     $this->_defaultOrderWay = 'DESC';
     $this->_select = 'smp.meta_title';
     //$this->_defaultOrderBy = 'a.id_smart_blog_comment';
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
         $this->_group = 'GROUP BY a.id_smart_blog_comment';
     }
     parent::__construct();
 }
Exemplo n.º 3
0
 public function init()
 {
     if ($product_rewrite = Tools::getValue('product_rewrite')) {
         $url_id_pattern = '/.*?([0-9]+)\\-([a-zA-Z0-9-]*)(\\.html)?/';
         $lang_id = (int) Context::getContext()->language->id;
         $sql = 'SELECT `id_product`
             FROM `' . _DB_PREFIX_ . 'product_lang`
             WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $product_rewrite)) . '\' AND `id_lang` = ' . $lang_id;
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_product > 0) {
             $_GET['id_product'] = $id_product;
         } elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) {
             $sql = 'SELECT `id_product`
                 FROM `' . _DB_PREFIX_ . 'product_lang`
                 WHERE `id_product` = \'' . pSQL($url_parts[1]) . '\' AND `id_lang` = ' . $lang_id;
             if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                 $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
             }
             $id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
             if ($id_product > 0) {
                 $_GET['id_product'] = $id_product;
             }
         }
     }
     parent::init();
 }
Exemplo n.º 4
0
 public function getContent()
 {
     $output = '<p class="info">' . $this->l('On some versions you could have to disable Cache, save, open your shop home page, than go back and enable it:') . '<br><br>' . sprintf('%s -> %s -> %s', $this->l('Advanced Parameters'), $this->l('Performance'), $this->l('Clear Smarty cache')) . '<br>' . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL off'), $this->l('Save')) . '<br>' . sprintf('%s -> %s -> %s -> %s', $this->l('Preferences'), $this->l('SEO and URLs'), $this->l('Set userfriendly URL on'), $this->l('Save')) . '<br>' . '</p>';
     $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'product_lang`
         WHERE `link_rewrite`
         IN (SELECT `link_rewrite` FROM `' . _DB_PREFIX_ . 'product_lang`
         GROUP BY `link_rewrite`, `id_lang`
         HAVING count(`link_rewrite`) > 1)';
     if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
         $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
     }
     if ($res = Db::getInstance()->ExecuteS($sql)) {
         $err = $this->l('You need to fix duplicate URL entries:') . '<br>';
         foreach ($res as $row) {
             $lang = $this->context->language->getLanguage($row['id_lang']);
             $err .= $row['name'] . ' (' . $row['id_product'] . ') - ' . $row['link_rewrite'] . '<br>';
             $shop = $this->context->shop->getShop($lang['id_shop']);
             $err .= $this->l('Language: ') . $lang['name'] . '<br>' . $this->l('Shop: ') . $shop['name'] . '<br><br>';
         }
         $output .= $this->displayWarning($err);
     } else {
         $output .= $this->displayConfirmation($this->l('Nice. You have no duplicate URL entry.'));
     }
     return '<div class="panel">' . $output . '</div>';
 }
    public static function updateNewMessages($id_shop = null)
    {
        $context = Context::getContext();
        if ($id_shop == null && Shop::getContext() == Shop::CONTEXT_SHOP) {
            $id_shop = Shop::getContextShopID();
        }
        if ($id_shop > 0) {
            if (($mf_employee = Db::getInstance()->getRow('SELECT id_employee, id_last_new_message, id_first_new_message FROM `' . _DB_PREFIX_ . 'mf_employee` WHERE `id_shop`=' . (int) $id_shop . ' AND `id_employee` = ' . (int) $context->employee->id)) != false) {
                $id_last_new_message = Db::getInstance()->getValue('SELECT IFNULL(MAX(`' . self::$definition['primary'] . '`), 0)
						FROM `' . _DB_PREFIX_ . self::$definition['table'] . '` WHERE `id_shop`=' . (int) $id_shop);
                if ($id_last_new_message > $mf_employee['id_last_new_message']) {
                    $id_first_new_message = $mf_employee['id_last_new_message'];
                } else {
                    $id_first_new_message = $mf_employee['id_first_new_message'];
                }
                return Db::getInstance()->execute('
					UPDATE `' . _DB_PREFIX_ . 'mf_employee`
					SET `id_last_new_message` = ' . (int) $id_last_new_message . ',
					`id_first_new_message`=' . (int) $id_first_new_message . '
					WHERE `id_shop`=' . (int) $id_shop . ' AND `id_employee` = ' . (int) $context->employee->id);
            } else {
                return Db::getInstance()->execute('
					INSERT INTO `' . _DB_PREFIX_ . 'mf_employee`
					(`id_last_new_message`, `id_first_new_message`, `id_employee`, `id_shop`) VALUES ((
						SELECT IFNULL(MAX(`' . self::$definition['primary'] . '`), 0)
						FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
					), 0, ' . (int) $context->employee->id . ', ' . (int) $id_shop . ')');
            }
        }
    }
Exemplo n.º 6
0
 public function init()
 {
     if ($cms_rewrite = Tools::getValue('cms_rewrite')) {
         $sql = 'SELECT l.`id_cms`
             FROM `' . _DB_PREFIX_ . 'cms_lang` l
             LEFT JOIN `' . _DB_PREFIX_ . 'cms_shop` s ON (l.`id_cms` = s.`id_cms`)
             WHERE l.`link_rewrite` = \'' . pSQL(str_replace('.html', '', $cms_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms > 0) {
             $_GET['id_cms'] = $id_cms;
         }
     } elseif ($cms_category_rewrite = Tools::getValue('cms_category_rewrite')) {
         $sql = 'SELECT `id_cms_category`
             FROM `' . _DB_PREFIX_ . 'cms_category_lang`
             WHERE `link_rewrite` = \'' . pSQL($cms_category_rewrite) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_cms_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_cms_category > 0) {
             $_GET['id_cms_category'] = $id_cms_category;
         }
     }
     parent::init();
 }
Exemplo n.º 7
0
 /**
  * Render shop list
  *
  * @return string
  */
 public function getRenderedShopList()
 {
     if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
         return '';
     }
     $shop_context = Shop::getContext();
     $context = Context::getContext();
     $tree = Shop::getTree();
     if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) {
         $current_shop_value = '';
         $current_shop_name = Translate::getAdminTranslation('All shops');
     } elseif ($shop_context == Shop::CONTEXT_GROUP) {
         $current_shop_value = 'g-' . Shop::getContextShopGroupID();
         $current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
     } else {
         $current_shop_value = 's-' . Shop::getContextShopID();
         foreach ($tree as $group_id => $group_data) {
             foreach ($group_data['shops'] as $shop_id => $shop_data) {
                 if ($shop_id == Shop::getContextShopID()) {
                     $current_shop_name = $shop_data['name'];
                     break;
                 }
             }
         }
     }
     $tpl = $this->createTemplate('helpers/shops_list/list.tpl');
     $tpl->assign(array('tree' => $tree, 'current_shop_name' => $current_shop_name, 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='));
     return $tpl->fetch();
 }
Exemplo n.º 8
0
 /**
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
         $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_attribute = ' . (int) $this->id);
         $products = array();
         foreach ($result as $row) {
             $combination = new Combination($row['id_product_attribute']);
             $newRequest = Db::getInstance()->executeS('SELECT id_product, default_on FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product_attribute = ' . (int) $row['id_product_attribute']);
             foreach ($newRequest as $value) {
                 if ($value['default_on'] == 1) {
                     $products[] = $value['id_product'];
                 }
             }
             $combination->delete();
         }
         foreach ($products as $product) {
             $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product = ' . (int) $product . ' LIMIT 1');
             foreach ($result as $row) {
                 if (Validate::isLoadedObject($product = new Product((int) $product))) {
                     $product->deleteDefaultAttributes();
                     $product->setDefaultAttribute($row['id_product_attribute']);
                 }
             }
         }
         // Delete associated restrictions on cart rules
         CartRule::cleanProductRuleIntegrity('attributes', $this->id);
         /* Reinitializing position */
         $this->cleanPositions((int) $this->id_attribute_group);
     }
     $return = parent::delete();
     if ($return) {
         Hook::exec('actionAttributeDelete', array('id_attribute' => $this->id));
     }
     return $return;
 }
    public function getContent()
    {
        $output = '';
        $output .= '<div style="display:block;" class="hint">
				On some versions you have to disable Cache save than open your shop home page than go back and enable it.<br/>
				Advanced Parameters > Performance > Clear Smarty cache<br /><br/>
				Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save<br />
				Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save<br />
			</div><br />';
        $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'product_lang`
				WHERE `link_rewrite`
					IN (SELECT `link_rewrite` FROM `' . _DB_PREFIX_ . 'product_lang`
					GROUP BY `link_rewrite`, `id_lang`
					HAVING count(`link_rewrite`) > 1)';
        if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
            $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
        }
        if ($results = Db::getInstance()->ExecuteS($sql)) {
            $output .= 'You need to fix duplicate URL entries<br/>';
            foreach ($results as $row) {
                $language_info = $this->context->language->getLanguage($row['id_lang']);
                $output .= $row['name'] . ' (' . $row['id_product'] . ') - ' . $row['link_rewrite'] . '<br/>';
                $shop_info = $this->context->shop->getShop($language_info['id_shop']);
                $output .= 'Language:' . $language_info['name'] . '<br /> Shop:' . $shop_info['name'] . '<br/><br/>';
            }
        } else {
            $output .= 'Nice you don\'t have any duplicate URL entries.';
        }
        return $output;
    }
Exemplo n.º 10
0
 public function __construct()
 {
     $this->required_database = true;
     $this->required_fields = array('newsletter', 'optin');
     $this->table = 'customer';
     $this->className = 'Customer';
     $this->lang = false;
     $this->deleted = true;
     $this->addRowAction('edit');
     $this->addRowAction('view');
     $this->addRowAction('delete');
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
     $this->context = Context::getContext();
     $this->default_form_language = $this->context->language->id;
     $genders = array();
     $genders_icon = array('default' => 'unknown.gif');
     foreach (Gender::getGenders() as $gender) {
         $gender_file = 'genders/' . $gender->id . '.jpg';
         if (file_exists(_PS_IMG_DIR_ . $gender_file)) {
             $genders_icon[$gender->id] = '../' . $gender_file;
         } else {
             $genders_icon[$gender->id] = $gender->name;
         }
         $genders[$gender->id] = $gender->name;
     }
     $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 20), 'id_gender' => array('title' => $this->l('Gender'), 'width' => 70, 'align' => 'center', 'icon' => $genders_icon, 'orderby' => false, 'type' => 'select', 'list' => $genders, 'filter_key' => 'a!id_gender'), 'lastname' => array('title' => $this->l('Last Name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'width' => 'auto'), 'email' => array('title' => $this->l('E-mail address'), 'width' => 140), 'age' => array('title' => $this->l('Age'), 'width' => 20, 'search' => false, 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'width' => 70, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), 'newsletter' => array('title' => $this->l('News.'), 'width' => 70, 'align' => 'center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false), 'optin' => array('title' => $this->l('Opt.'), 'width' => 70, 'align' => 'center', 'type' => 'bool', 'callback' => 'printOptinIcon', 'orderby' => false), 'date_add' => array('title' => $this->l('Registration'), 'width' => 150, 'type' => 'date', 'align' => 'right'), 'connect' => array('title' => $this->l('Last visit'), 'width' => 100, 'type' => 'datetime', 'search' => false, 'havingFilter' => true));
     $this->shopLinkType = 'shop';
     $this->shopShareDatas = Shop::SHARE_CUSTOMER;
     parent::__construct();
     // Check if we can add a customer
     if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) {
         $this->can_add_customer = false;
     }
 }
Exemplo n.º 11
0
 public function initContent()
 {
     if (!$this->viewAccess()) {
         $this->errors[] = Tools::displayError('You do not have permission to view this.');
     } elseif (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
         $this->displayInformation($this->l('You can only display the page in a shop context.'));
     } elseif (!$this->module->isModuleConfigurationCompleted()) {
         $this->errors[] = Tools::displayError('Mediafinanz module has not been configured for this shop');
     } else {
         $this->getLanguages();
         $this->initToolbar();
         $this->initTabModuleList();
         $this->toolbar_title[0] = $this->l('Inkasso');
         $this->page_header_toolbar_title = $this->l('Inkasso');
         if ($this->display == 'createClaims') {
             $this->content .= $this->renderCreateClaimsList();
         } elseif ($this->display == 'viewMessages') {
             $this->toolbar_title[0] = $this->l('Messages');
             $this->page_header_toolbar_title = $this->l('Messages');
             $this->content .= $this->renderViewMessagesList();
         } elseif ($this->display == 'edit' || $this->display == 'add') {
             if (!$this->loadObject(true)) {
                 return;
             }
             $this->content .= $this->renderForm();
         } elseif ($this->display == 'view') {
             // Some controllers use the view action without an object
             if ($this->className) {
                 $this->loadObject(true);
             }
             $this->content .= $this->renderView();
         } elseif ($this->display == 'details') {
             $this->content .= $this->renderDetails();
         } elseif (!$this->ajax) {
             $this->toolbar_title[] = $this->l('Claims') . ' ' . $this->l('Last update:') . ' ' . Configuration::get('MEDIAFINANZ_LASTSTATUSUPDATE');
             $this->content .= $this->renderModulesList();
             if (_PS_VERSION_ >= '1.6.0.0') {
                 $this->content .= $this->renderKpis();
             }
             $this->content .= $this->renderNewMessagesList();
             $this->content .= $this->renderList();
             $this->content .= $this->renderOptions();
             // if we have to display the required fields form
             if ($this->required_database) {
                 $this->content .= $this->displayRequiredFields();
             }
         }
     }
     $this->toolbar_title[0] = $this->l('Inkasso');
     if (_PS_VERSION_ >= '1.6.0.0') {
         $this->initPageHeaderToolbar();
     }
     $this->context->smarty->assign(array('content' => $this->content, 'lite_display' => $this->lite_display, 'url_post' => self::$currentIndex . '&token=' . $this->token));
     if (_PS_VERSION_ >= '1.6.0.0') {
         $this->context->smarty->assign(array('show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'title' => $this->page_header_toolbar_title, 'toolbar_btn' => $this->page_header_toolbar_btn, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn));
     }
 }
Exemplo n.º 12
0
 public function getCurrentSiteId()
 {
     $currentShopId = Shop::getContext('shop');
     $jsites = unserialize(base64_decode($this->get('sites')));
     if (isset($jsites[$currentShopId]['site_id'])) {
         return $jsites[$currentShopId]['site_id'];
     }
     return false;
 }
Exemplo n.º 13
0
 public function init()
 {
     // No cache for auto-refresh uploaded logo
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     parent::init();
     $this->can_display_themes = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP ? true : false;
     $this->fields_options = array('theme' => array('title' => sprintf($this->l('Select theme for shop %s'), $this->context->shop->name), 'description' => !$this->can_display_themes ? $this->l('You must select a shop from the above list if you want to select a theme') : '', 'fields' => array('theme_for_shop' => array('type' => 'theme', 'themes' => Theme::getThemes(), 'id_theme' => $this->context->shop->id_theme, 'can_display_themes' => $this->can_display_themes, 'no_multishop_checkbox' => true))), 'appearance' => array('title' => $this->l('Appearance'), 'icon' => 'email', 'fields' => array('PS_LOGO' => array('title' => $this->l('Header logo'), 'desc' => $this->l('Will appear on main page'), 'type' => 'file', 'thumb' => _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_LOGO_MAIL' => array('title' => $this->l('Mail logo'), 'desc' => (Configuration::get('PS_LOGO_MAIL') === false ? '<span class="light-warning">' . $this->l('Warning: No e-mail logo defined, the header logo is used instead.') . '</span><br />' : '') . $this->l('Will appear on e-mail headers. If undefined, the Header logo will be used'), 'type' => 'file', 'thumb' => Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL')) ? _PS_IMG_ . Configuration::get('PS_LOGO_MAIL') . '?date=' . time() : _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_LOGO_INVOICE' => array('title' => $this->l('Invoice logo'), 'desc' => (Configuration::get('PS_LOGO_INVOICE') === false ? '<span class="light-warning">' . $this->l('Warning: No invoice logo defined, the header logo is used instead.') . '</span><br />' : '') . $this->l('Will appear on invoice headers. If undefined, the Header logo will be used'), 'type' => 'file', 'thumb' => Configuration::get('PS_LOGO_INVOICE') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_INVOICE')) ? _PS_IMG_ . Configuration::get('PS_LOGO_INVOICE') . '?date=' . time() : _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_FAVICON' => array('title' => $this->l('Favicon'), 'hint' => $this->l('Only ICO format allowed'), 'desc' => $this->l('Will appear in the address bar of your web browser'), 'type' => 'file', 'thumb' => _PS_IMG_ . Configuration::get('PS_FAVICON') . '?date=' . time()), 'PS_STORES_ICON' => array('title' => $this->l('Store icon'), 'hint' => $this->l('Only GIF format allowed'), 'desc' => $this->l('Will appear on the store locator (inside Google Maps)') . '<br />' . $this->l('Suggested size: 30x30, Transparent GIF'), 'type' => 'file', 'thumb' => _PS_IMG_ . Configuration::get('PS_STORES_ICON') . '?date=' . time()), 'PS_NAVIGATION_PIPE' => array('title' => $this->l('Navigation pipe'), 'desc' => $this->l('Used for navigation path inside categories/product'), 'cast' => 'strval', 'type' => 'text', 'size' => 20), 'PS_ALLOW_MOBILE_DEVICE' => array('title' => $this->l('Enable mobile theme'), 'desc' => $this->l('Allows visitors browsing on a mobile device or on a touchpad, to have a light version of website'), 'type' => 'radio', 'required' => true, 'validation' => 'isGenericName', 'choices' => array(0 => $this->l('I want to disable it'), 1 => $this->l('I want to enable it only on mobiles devices'), 2 => $this->l('I want to enable it only on touchpads'), 3 => $this->l('I want to enable it on mobile and touchpad devices')))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')));
     $this->fields_list = array('id_theme' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 20), 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), 'directory' => array('title' => $this->l('Directory'), 'width' => 'auto'));
 }
Exemplo n.º 14
0
 public function init()
 {
     // No cache for auto-refresh uploaded logo
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     parent::init();
     $this->can_display_themes = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP ? true : false;
     $this->fields_options = array('theme' => array('title' => sprintf($this->l('Select a theme for shop %s'), $this->context->shop->name), 'description' => !$this->can_display_themes ? $this->l('You must select a shop from the above list if you wish to choose a theme.') : '', 'fields' => array('theme_for_shop' => array('type' => 'theme', 'themes' => Theme::getThemes(), 'id_theme' => $this->context->shop->id_theme, 'can_display_themes' => $this->can_display_themes, 'no_multishop_checkbox' => true)), 'submit' => array('title' => $this->l('Save'))), 'appearance' => array('title' => $this->l('Appearance'), 'icon' => 'icon-html5', 'fields' => array('PS_LOGO' => array('title' => $this->l('Header logo'), 'hint' => $this->l('Will appear on main page. Recommended height: 52px. Maximum height on default theme: 65px.'), 'type' => 'file', 'name' => 'PS_LOGO', 'thumb' => _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_LOGO_MOBILE' => array('title' => $this->l('Header logo for mobile'), 'desc' => (Configuration::get('PS_LOGO_MOBILE') === false ? '<span class="light-warning">' . $this->l('Warning: No mobile logo has been defined. The header logo will be used instead.') . '</span><br />' : '') . $this->l('Will appear on the main page of your mobile template. If left undefined, the header logo will be used.'), 'type' => 'file', 'name' => 'PS_LOGO_MOBILE', 'thumb' => Configuration::get('PS_LOGO_MOBILE') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MOBILE')) ? _PS_IMG_ . Configuration::get('PS_LOGO_MOBILE') . '?date=' . time() : _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_LOGO_MAIL' => array('title' => $this->l('Mail logo'), 'desc' => (Configuration::get('PS_LOGO_MAIL') === false ? '<span class="light-warning">' . $this->l('Warning: No email logo has been indentified. The header logo will be used instead.') . '</span><br />' : '') . $this->l('Will appear on email headers. If undefined, the header logo will be used.'), 'type' => 'file', 'name' => 'PS_LOGO_MAIL', 'thumb' => Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL')) ? _PS_IMG_ . Configuration::get('PS_LOGO_MAIL') . '?date=' . time() : _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_LOGO_INVOICE' => array('title' => $this->l('Invoice logo'), 'desc' => (Configuration::get('PS_LOGO_INVOICE') === false ? '<span class="light-warning">' . $this->l('Warning: No invoice logo has been defined. The header logo will be used instead.') . '</span><br />' : '') . $this->l('Will appear on invoice headers.') . ' ' . $this->l('Warning: you can use a PNG file for transparency, but it can take up to 1 second per page for processing. Please consider using JPG instead.'), 'type' => 'file', 'name' => 'PS_LOGO_INVOICE', 'thumb' => Configuration::get('PS_LOGO_INVOICE') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_INVOICE')) ? _PS_IMG_ . Configuration::get('PS_LOGO_INVOICE') . '?date=' . time() : _PS_IMG_ . Configuration::get('PS_LOGO') . '?date=' . time()), 'PS_FAVICON' => array('title' => $this->l('Favicon'), 'hint' => $this->l('Only ICO format allowed'), 'hint' => $this->l('Will appear in the address bar of your web browser.'), 'type' => 'file', 'name' => 'PS_FAVICON', 'thumb' => _PS_IMG_ . Configuration::get('PS_FAVICON') . '?date=' . time()), 'PS_STORES_ICON' => array('title' => $this->l('Store icon'), 'hint' => $this->l('Only GIF format allowed.'), 'hint' => $this->l('Will appear on the store locator (inside Google Maps).') . '<br />' . $this->l('Suggested size: 30x30, transparent GIF.'), 'type' => 'file', 'name' => 'PS_STORES_ICON', 'thumb' => _PS_IMG_ . Configuration::get('PS_STORES_ICON') . '?date=' . time()), 'PS_NAVIGATION_PIPE' => array('title' => $this->l('Navigation pipe'), 'hint' => $this->l('Used for the navigation path: Store Name > Category Name > Product Name.'), 'cast' => 'strval', 'type' => 'text', 'size' => 20), 'PS_ALLOW_MOBILE_DEVICE' => array('title' => $this->l('Enable the mobile theme.'), 'hint' => $this->l('Allows visitors browsing on mobile devices to view a lighter version of your website.'), 'type' => 'radio', 'required' => true, 'validation' => 'isGenericName', 'choices' => array(0 => $this->l('I\'d like to disable it, please. '), 1 => $this->l('I\'d like to enable it only on smart phones.'), 2 => $this->l('I\'d like to enable it only on tablets.'), 3 => $this->l('I\'d like to enable it on both smart phones and tablets.'))), 'PS_MAIL_COLOR' => array('title' => $this->l('Mail color'), 'hint' => $this->l('Your mail will be highlighted in this color. HTML colors only, please (e.g. "lightblue", "#CC6600").'), 'type' => 'color', 'name' => 'PS_MAIL_COLOR', 'size' => 30, 'value' => Configuration::get('PS_MAIL_COLOR'))), 'submit' => array('title' => $this->l('Save'))));
     $this->fields_list = array('id_theme' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), 'directory' => array('title' => $this->l('Directory')), 'responsive' => array('title' => $this->l('Responsive'), 'type' => 'bool', 'active' => 'responsive', 'align' => 'center', 'class' => 'fixed-width-xs'), 'default_left_column' => array('title' => $this->l('Default left column'), 'type' => 'bool', 'active' => 'default_left_column', 'align' => 'center', 'class' => 'fixed-width-xs'), 'default_right_column' => array('title' => $this->l('Default right column'), 'type' => 'bool', 'active' => 'default_right_column', 'align' => 'center', 'class' => 'fixed-width-xs'));
 }
Exemplo n.º 15
0
 public function renderView()
 {
     $this->toolbar_title = $this->l('Payment');
     unset($this->toolbar_btn['back']);
     $shop_context = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP;
     if (!$shop_context) {
         $this->tpl_view_vars = array('shop_context' => $shop_context);
         return parent::renderView();
     }
     $this->tpl_view_vars = array('modules_list' => $this->renderModulesList('back-office,AdminPayment,index'), 'ps_base_uri' => __PS_BASE_URI__, 'url_submit' => self::$currentIndex . '&token=' . $this->token, 'shop_context' => $shop_context);
     return parent::renderView();
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->required_database = true;
        $this->required_fields = array('newsletter', 'optin');
        $this->table = 'customer';
        $this->className = 'Customer';
        $this->lang = false;
        $this->deleted = true;
        $this->explicitSelect = true;
        $this->allow_export = true;
        $this->addRowAction('edit');
        $this->addRowAction('view');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->context = Context::getContext();
        $this->default_form_language = $this->context->language->id;
        $titles_array = array();
        $genders = Gender::getGenders($this->context->language->id);
        foreach ($genders as $gender) {
            /** @var Gender $gender */
            $titles_array[$gender->id_gender] = $gender->name;
        }
        $this->_select = '
		a.date_add, gl.name as title, (
			SELECT SUM(total_paid_real / conversion_rate)
			FROM ' . _DB_PREFIX_ . 'orders o
			WHERE o.id_customer = a.id_customer
			' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
			AND o.valid = 1
		) as total_spent, (
			SELECT c.date_add FROM ' . _DB_PREFIX_ . 'guest g
			LEFT JOIN ' . _DB_PREFIX_ . 'connections c ON c.id_guest = g.id_guest
			WHERE g.id_customer = a.id_customer
			ORDER BY c.date_add DESC
			LIMIT 1
		) as connect';
        $this->_join = 'LEFT JOIN ' . _DB_PREFIX_ . 'gender_lang gl ON (a.id_gender = gl.id_gender AND gl.id_lang = ' . (int) $this->context->language->id . ')';
        $this->_use_found_rows = false;
        $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'text-center', 'class' => 'fixed-width-xs'), 'title' => array('title' => $this->l('Social title'), 'filter_key' => 'a!id_gender', 'type' => 'select', 'list' => $titles_array, 'filter_type' => 'int', 'order_key' => 'gl!name'), 'firstname' => array('title' => $this->l('First name')), 'lastname' => array('title' => $this->l('Last name')), 'email' => array('title' => $this->l('Email address')));
        if (Configuration::get('PS_B2B_ENABLE')) {
            $this->fields_list = array_merge($this->fields_list, array('company' => array('title' => $this->l('Company'))));
        }
        $this->fields_list = array_merge($this->fields_list, array('total_spent' => array('title' => $this->l('Sales'), 'type' => 'price', 'search' => false, 'havingFilter' => true, 'align' => 'text-right', 'badge_success' => true), 'active' => array('title' => $this->l('Enabled'), 'align' => 'text-center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'), 'newsletter' => array('title' => $this->l('Newsletter'), 'align' => 'text-center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false), 'optin' => array('title' => $this->l('Opt-in'), 'align' => 'text-center', 'type' => 'bool', 'callback' => 'printOptinIcon', 'orderby' => false), 'date_add' => array('title' => $this->l('Registration'), 'type' => 'date', 'align' => 'text-right'), 'connect' => array('title' => $this->l('Last visit'), 'type' => 'datetime', 'search' => false, 'havingFilter' => true)));
        $this->shopLinkType = 'shop';
        $this->shopShareDatas = Shop::SHARE_CUSTOMER;
        parent::__construct();
        // Check if we can add a customer
        if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) {
            $this->can_add_customer = false;
        }
        self::$meaning_status = array('open' => $this->l('Open'), 'closed' => $this->l('Closed'), 'pending1' => $this->l('Pending 1'), 'pending2' => $this->l('Pending 2'));
    }
Exemplo n.º 17
0
 public function init()
 {
     // No cache for auto-refresh uploaded logo
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     parent::init();
     $this->can_display_themes = !Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP;
     if (Tools::getValue('display') == 'configureLayouts') {
         $this->initConfigureLayouts();
     } elseif (Tools::getValue('action') == 'importtheme') {
         $this->display = 'importtheme';
     }
     libxml_use_internal_errors(true);
 }
    public function initFormFeatures($obj)
    {
        if (!$this->default_form_language) {
            $this->getLanguages();
        }
        $tpl_path = _PS_MODULE_DIR_ . 'advancedfeaturesvalues/views/templates/admin/products/features.tpl';
        $data = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty);
        $data->assign('default_form_language', $this->default_form_language);
        $data->assign('languages', $this->_languages);
        if (!Feature::isFeatureActive()) {
            $this->displayWarning($this->l('This feature has been disabled. ') . '
				<a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>');
        } else {
            if ($obj->id) {
                if ($this->product_exists_in_shop) {
                    $features = Feature::getFeatures($this->context->language->id, Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP);
                    foreach ($features as $k => $tab_features) {
                        $features[$k]['current_item'] = array();
                        $features[$k]['val'] = array();
                        $custom = true;
                        foreach ($obj->getFeatures() as $tab_products) {
                            if ($tab_products['id_feature'] == $tab_features['id_feature']) {
                                $features[$k]['current_item'][] = $tab_products['id_feature_value'];
                            }
                        }
                        $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int) $tab_features['id_feature']);
                        if (count($features[$k]['featureValues'])) {
                            foreach ($features[$k]['featureValues'] as $value) {
                                if (in_array($value['id_feature_value'], $features[$k]['current_item'])) {
                                    $custom = false;
                                }
                            }
                        }
                        if ($custom && !empty($features[$k]['current_item'])) {
                            $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item'][0]);
                        }
                    }
                    $data->assign('available_features', $features);
                    $data->assign('product', $obj);
                    $data->assign('link', $this->context->link);
                    $data->assign('default_form_language', $this->default_form_language);
                } else {
                    $this->displayWarning($this->l('You must save the product in this shop before adding features.'));
                }
            } else {
                $this->displayWarning($this->l('You must save this product before adding features.'));
            }
        }
        $this->tpl_form_vars['custom_form'] = $data->fetch();
    }
Exemplo n.º 19
0
 public function init()
 {
     if ($category_rewrite = Tools::getValue('category_rewrite')) {
         $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang`
             WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $category_rewrite)) . '\' AND `id_lang` = ' . Context::getContext()->language->id;
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_category > 0) {
             $_GET['id_category'] = $id_category;
         }
     }
     parent::init();
 }
 public function init()
 {
     parent::init();
     Shop::addTableAssociation($this->table, array('type' => 'shop'));
     if (Shop::getContext() == Shop::CONTEXT_SHOP) {
         $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'simpleblog_category_shop` sa ON (a.`id_simpleblog_category` = sa.`id_simpleblog_category` AND sa.id_shop = ' . (int) $this->context->shop->id . ') ';
     }
     // else
     //     $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'simpleblog_category_shop` sa ON (a.`simpleblog_category` = sa.`simpleblog_category` AND sa.id_shop = a.id_shop_default) ';
     if (Shop::getContext() == Shop::CONTEXT_SHOP && Shop::isFeatureActive()) {
         $this->_where = ' AND sa.`id_shop` = ' . (int) Context::getContext()->shop->id;
     }
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
         unset($this->fields_list['position']);
     }
 }
    public function init()
    {
        if (Tools::getValue('category_rewrite')) {
            // SQL safe?
            $category_rewrite = Tools::getValue('category_rewrite');
            $sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang`
					WHERE `link_rewrite` = \'' . $category_rewrite . '\' AND `id_lang` = ' . Context::getContext()->language->id;
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
            }
            $categorys_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
            $categorys_count = count($categorys_list);
            if ($categorys_count == 1) {
                // Found ONLY one so dont need to look for parent
                $id_category = (int) $categorys_list[0]['id_category'];
                $_GET['noredirect'] = TRUE;
            } else {
                if ($categorys_count > 1) {
                    // Found more than one so look for parent
                    // SQL safe?
                    $parent_rewrite = Tools::getValue('categories_rewrite');
                    $shop_id = (int) Shop::getContextShopID();
                    $sql = 'SELECT c.`id_category`
						FROM `ps_category` c
						LEFT JOIN `ps_category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.id_shop = ' . $shop_id . ' )
							INNER JOIN ps_category_shop category_shop ON (category_shop.id_category = c.id_category AND category_shop.id_shop = ' . $shop_id . ')
						LEFT JOIN `ps_category_lang` clp ON (c.`id_parent` = clp.`id_category`)
						WHERE cl.`link_rewrite` = \'' . $category_rewrite . '\'
							AND clp.`link_rewrite` = \'' . $parent_rewrite . '\'
							AND cl.`id_lang` = ' . Context::getContext()->language->id;
                    $id_category = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                    $_GET['noredirect'] = TRUE;
                } else {
                    // none found
                    $id_category = 0;
                }
            }
            if ($id_category > 0) {
                $_GET['id_category'] = $id_category;
            } else {
                //TODO: Do we need to send 404?
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
        }
        parent::init();
    }
Exemplo n.º 22
0
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'alias';
        $this->className = 'Alias';
        $this->lang = false;
        parent::__construct();
        // Alias fields
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        if (!Tools::getValue('realedit')) {
            $this->deleted = false;
        }
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->fields_list = array('alias' => array('title' => $this->l('Aliases')), 'search' => array('title' => $this->trans('Search', array(), 'Admin.Actions')), 'active' => array('title' => $this->l('Status'), 'class' => 'fixed-width-sm', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        // Search options
        $current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
        $cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . (Shop::getContext() == Shop::CONTEXT_SHOP ? '&id_shop=' . (int) Context::getContext()->shop->id : '');
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE product_shop.`visibility` IN ("both", "search") AND product_shop.`active` = 1');
        $this->fields_options = array('indexation' => array('title' => $this->l('Indexing'), 'icon' => 'icon-cogs', 'info' => '<p>
						' . $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of a front office search.') . '<br />
						' . $this->l('Indexed products') . ' <strong>' . (int) $indexed . ' / ' . (int) $total . '</strong>.
					</p>
					<p>
						' . $this->l('Building the product index may take a few minutes.') . '
						' . $this->l('If your server stops before the process ends, you can resume the indexing by clicking "Add missing products to the index".') . '
					</p>
					<a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1' . (Shop::getContext() == Shop::CONTEXT_SHOP ? '&id_shop=' . (int) Context::getContext()->shop->id : '') . '" class="btn-link">
						<i class="icon-external-link-sign"></i>
						' . $this->l('Add missing products to the index') . '
					</a><br />
					<a href="searchcron.php?full=1&amp;token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1' . (Shop::getContext() == Shop::CONTEXT_SHOP ? '&id_shop=' . (int) Context::getContext()->shop->id : '') . '" class="btn-link">
						<i class="icon-external-link-sign"></i>
						' . $this->l('Re-build the entire index') . '
					</a><br /><br />
					<p>
						' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . '<br />
						<a href="' . Tools::safeOutput($cron_url) . '">
							<i class="icon-external-link-sign"></i>
							' . Tools::safeOutput($cron_url) . '
						</a>
					</p><br />', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexing'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable the automatic indexing of products. If you enable this feature, the products will be indexed in the search automatically when they are saved. If the feature is disabled, you will have to index products manually by using the links provided in the field set.'))), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))), 'search' => array('title' => $this->trans('Search', array(), 'Admin.Actions'), 'icon' => 'icon-search', 'fields' => array('PS_SEARCH_START' => array('title' => $this->l('Search within word'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => $this->l('By default, to search for “blouse”, you have to enter “blous”, “blo”, etc (beginning of the word) – but not “lous” (within the word).') . '<br/>' . $this->l('With this option enabled, it also gives the good result if you search for “lous”, “ouse”, or anything contained in the word.'), 'hint' => array($this->l('Enable search within a whole word, rather than from its beginning only.'), $this->l('It checks if the searched term is contained in the indexed word. This may be resource-consuming.'))), 'PS_SEARCH_END' => array('title' => $this->l('Search exact end match'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => $this->l('By default, if you search "book", you will have "book", "bookcase" and "bookend".') . '<br/>' . $this->l('With this option enabled, it only gives one result “book”, as exact end of the indexed word is matching.'), 'hint' => array($this->l('Enable more precise search with the end of the word.'), $this->l('It checks if the searched term is the exact end of the indexed word.'))), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'hint' => $this->l('Only words this size or larger will be indexed.'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'validation' => 'isGenericName', 'hint' => $this->l('Please enter the index words separated by a "|".'), 'type' => 'textareaLang')), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'icon-cogs', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when completing a new search.') . '<br />
						' . $this->l('A word with a weight of eight will have four times more value than a word with a weight of two.') . '<br /><br />
						' . $this->l('We advise you to set a greater weight for words which appear in the name or reference of a product. This will allow the search results to be as precise and relevant as possible.') . '<br /><br />
						' . $this->l('Setting a weight to 0 will exclude that field from search index. Re-build of the entire index is required when changing to or from 0'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Brand weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval')), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'))));
    }
    public function __construct()
    {
        $this->required_database = true;
        $this->required_fields = array('newsletter', 'optin');
        $this->table = 'customer';
        $this->className = 'Customer';
        $this->lang = false;
        $this->deleted = true;
        $this->explicitSelect = true;
        $this->allow_export = true;
        $this->addRowAction('edit');
        $this->addRowAction('view');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Would you like to delete the selected items?')));
        $this->context = Context::getContext();
        $this->default_form_language = $this->context->language->id;
        $genders = array();
        $genders_icon = array();
        $genders_icon[] = array('src' => '../genders/Unknown.jpg', 'alt' => '');
        foreach (Gender::getGenders() as $gender) {
            $gender_file = 'genders/' . $gender->id . '.jpg';
            if (file_exists(_PS_IMG_DIR_ . $gender_file)) {
                $genders_icon[$gender->id] = array('src' => '../' . $gender_file, 'alt' => $gender->name);
            } else {
                $genders_icon[$gender->id] = array('src' => '../genders/Unknown.jpg', 'alt' => $gender->name);
            }
            $genders[$gender->id] = $gender->name;
        }
        $this->_select = '
		a.date_add,
		IF (YEAR(`birthday`) = 0, "-", (YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5) < RIGHT(birthday, 5))) AS `age`, (
			SELECT c.date_add FROM ' . _DB_PREFIX_ . 'guest g
			LEFT JOIN ' . _DB_PREFIX_ . 'connections c ON c.id_guest = g.id_guest
			WHERE g.id_customer = a.id_customer
			ORDER BY c.date_add DESC
			LIMIT 1
		) as connect';
        $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 20), 'id_gender' => array('title' => $this->l('Title'), 'width' => 70, 'align' => 'center', 'icon' => $genders_icon, 'orderby' => false, 'type' => 'select', 'list' => $genders, 'filter_key' => 'a!id_gender'), 'lastname' => array('title' => $this->l('Last name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First Name'), 'width' => 'auto'), 'email' => array('title' => $this->l('Email address'), 'width' => 140), 'age' => array('title' => $this->l('Age'), 'width' => 20, 'search' => false, 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'width' => 70, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'), 'newsletter' => array('title' => $this->l('News.'), 'width' => 70, 'align' => 'center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false), 'optin' => array('title' => $this->l('Opt.'), 'width' => 70, 'align' => 'center', 'type' => 'bool', 'callback' => 'printOptinIcon', 'orderby' => false), 'date_add' => array('title' => $this->l('Registration'), 'width' => 150, 'type' => 'date', 'align' => 'right'), 'connect' => array('title' => $this->l('Last visit'), 'width' => 100, 'type' => 'datetime', 'search' => false, 'havingFilter' => true));
        $this->shopLinkType = 'shop';
        $this->shopShareDatas = Shop::SHARE_CUSTOMER;
        parent::__construct();
        // Check if we can add a customer
        if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) {
            $this->can_add_customer = false;
        }
    }
Exemplo n.º 24
0
 public function init()
 {
     if ($supplier_rewrite = Tools::getValue('supplier_rewrite')) {
         $sql = 'SELECT sp.`id_supplier`
             FROM `' . _DB_PREFIX_ . 'supplier` sp
             LEFT JOIN `' . _DB_PREFIX_ . 'supplier_shop` s ON (sp.`id_supplier` = s.`id_supplier`)
             WHERE sp.`name` LIKE \'' . pSQL(str_replace('-', '%', $supplier_rewrite)) . '\'';
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
         }
         $id_supplier = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
         if ($id_supplier > 0) {
             $_GET['id_supplier'] = $id_supplier;
         }
     }
     parent::init();
 }
 public function __construct()
 {
     $this->bootstrap = true;
     $this->display = 'view';
     $this->table = 'carrier';
     $this->identifier = 'id_carrier';
     $this->className = 'Carrier';
     $this->lang = false;
     $this->deleted = true;
     $this->step_number = 0;
     $this->type_context = Shop::getContext();
     $this->old_context = Context::getContext();
     $this->multishop_context = Shop::CONTEXT_ALL;
     $this->context = Context::getContext();
     $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's');
     parent::__construct();
     $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, Tab::getIdFromClassName('AdminCarriers'));
 }
Exemplo n.º 26
0
    public function delete()
    {
        if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
            /* Select children in order to find linked combinations */
            $attribute_ids = Db::getInstance()->executeS('
				SELECT `id_attribute`
				FROM `' . _DB_PREFIX_ . 'attribute`
				WHERE `id_attribute_group` = ' . (int) $this->id);
            if ($attribute_ids === false) {
                return false;
            }
            /* Removing attributes to the found combinations */
            $to_remove = array();
            foreach ($attribute_ids as $attribute) {
                $to_remove[] = (int) $attribute['id_attribute'];
            }
            if (!empty($to_remove) && Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
				WHERE `id_attribute`
					IN (' . implode(', ', $to_remove) . ')') === false) {
                return false;
            }
            /* Remove combinations if they do not possess attributes anymore */
            if (!AttributeGroup::cleanDeadCombinations()) {
                return false;
            }
            /* Also delete related attributes */
            if (count($to_remove)) {
                if (!Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'attribute_lang`
				WHERE `id_attribute`	IN (' . implode(',', $to_remove) . ')') || !Db::getInstance()->execute('
				DELETE FROM `' . _DB_PREFIX_ . 'attribute_shop`
				WHERE `id_attribute`	IN (' . implode(',', $to_remove) . ')') || !Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'attribute` WHERE `id_attribute_group` = ' . (int) $this->id)) {
                    return false;
                }
            }
            $this->cleanPositions();
        }
        $return = parent::delete();
        if ($return) {
            Hook::exec('actionAttributeGroupDelete', array('id_attribute_group' => $this->id));
        }
        return $return;
    }
Exemplo n.º 27
0
 public function delete()
 {
     if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
         $result = Db::getInstance()->executeS('SELECT id_product_attribute FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_attribute = ' . (int) $this->id);
         foreach ($result as $row) {
             $combination = new Combination($row['id_product_attribute']);
             $combination->delete();
         }
         // Delete associated restrictions on cart rules
         CartRule::cleanProductRuleIntegrity('attributes', $this->id);
         /* Reinitializing position */
         $this->cleanPositions((int) $this->id_attribute_group);
     }
     $return = parent::delete();
     if ($return) {
         Hook::exec('actionAttributeDelete', array('id_attribute' => $this->id));
     }
     return $return;
 }
    public function init()
    {
        if ($manufacturer_rewrite = Tools::getValue('manufacturer_rewrite')) {
            $manufacturer_rewrite = str_replace('-', '%', $manufacturer_rewrite);
            $sql = 'SELECT m.`id_manufacturer`
				FROM `' . _DB_PREFIX_ . 'manufacturer` m
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer_shop` s ON (m.`id_manufacturer` = s.`id_manufacturer`)
				WHERE m.`name` LIKE \'' . pSQL($manufacturer_rewrite) . '\'';
            if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
                $sql .= ' AND s.`id_shop` = ' . (int) Shop::getContextShopID();
            }
            $id_manufacturer = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_manufacturer > 0) {
                $_GET['id_manufacturer'] = $id_manufacturer;
                $_GET['noredirect'] = 1;
            }
        }
        parent::init();
    }
 public function __construct()
 {
     $this->bootstrap = true;
     $this->table = 'belvg_staticblocks';
     $this->identifier = 'id_belvg_staticblocks';
     $this->className = 'BelvgStaticBlocks';
     $this->lang = TRUE;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->fields_list = array('id_belvg_staticblocks' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), 'title' => array('title' => $this->l('Block Title'), 'width' => 300), 'block_identifier' => array('title' => $this->l('Identifier'), 'width' => 300), 'status' => array('title' => $this->l('Status'), 'width' => 40, 'active' => 'update', 'align' => 'center', 'type' => 'bool', 'orderby' => FALSE), 'date_add' => array('title' => $this->l('Date Created'), 'width' => 150, 'type' => 'date', 'align' => 'right'), 'date_upd' => array('title' => $this->l('Last Modified'), 'width' => 150, 'type' => 'date', 'align' => 'right'));
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL) {
         $this->_where .= ' AND a.' . $this->identifier . ' IN (
             SELECT sa.' . $this->identifier . '
             FROM `' . _DB_PREFIX_ . $this->table . '_shop` sa
             WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
         )';
     }
     $this->identifiersDnd = array('id_belvg_staticblocks' => 'id_sslide_to_move');
     parent::__construct();
 }
Exemplo n.º 30
-1
 public function postProcess()
 {
     if (Tools::isSubmit('submitStoreConf')) {
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_LINK', Tools::getValue('PRODUCTPAYMENTLOGOS_LINK'));
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_TITLE', Tools::getValue('PRODUCTPAYMENTLOGOS_TITLE'));
         if (isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']) && isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name']) && !empty($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'])) {
             if (ImageManager::validateUpload($_FILES['PRODUCTPAYMENTLOGOS_IMG'], 4000000)) {
                 return $this->displayError($this->l('Invalid image'));
             } else {
                 $ext = Tools::substr($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], Tools::strrpos($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], '.') + 1);
                 $file_name = md5($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name']) . '.' . $ext;
                 if (!move_uploaded_file($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'], dirname(__FILE__) . '/img/' . $file_name)) {
                     return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
                 } else {
                     $file_path = dirname(__FILE__) . '/img/' . Configuration::get('PRODUCTPAYMENTLOGOS_IMG');
                     if (Configuration::hasContext('PRODUCTPAYMENTLOGOS_IMG', null, Shop::getContext()) && Configuration::get('PRODUCTPAYMENTLOGOS_IMG') != $file_name && file_exists($file_path)) {
                         unlink($file_path);
                     }
                     Configuration::updateValue('PRODUCTPAYMENTLOGOS_IMG', $file_name);
                     $this->_clearCache('productpaymentlogos.tpl');
                     Tools::redirectAdmin('index.php?tab=AdminModules&conf=6&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'));
                 }
             }
         }
         $this->_clearCache('productpaymentlogos.tpl');
     }
     return '';
 }