Example #1
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $html = '';
     $language_id = Context::getContext()->language->id;
     if (is_array($setting['html']) && isset($setting['html'][$language_id])) {
         $html = $setting['html'][$language_id];
         $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
     }
     $header = '';
     $content = $html;
     $ac = array();
     $language_id = Context::getContext()->language->id;
     for ($i = 1; $i <= 6; $i++) {
         $header = isset($setting['header_' . $i . '_' . $language_id]) ? $setting['header_' . $i . '_' . $language_id] : '';
         if (!empty($header)) {
             $content = isset($setting['content_' . $i . '_' . $language_id]) ? $setting['content_' . $i . '_' . $language_id] : '';
             $ac[] = array('header' => $header, 'content' => trim($content));
         }
     }
     $setting['accordions'] = $ac;
     $setting['id'] = rand() + rand() + count($ac);
     $output = array('type' => 'accordion', 'data' => $setting);
     return $output;
 }
Example #2
0
 public function __construct()
 {
     /** Backward compatibility */
     include_once _PS_MODULE_DIR_ . '/paypal/backward_compatibility/backward.php';
     $this->context = Context::getContext();
     parent::__construct();
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->required_database = true;
        $this->required_fields = array('company', 'address2', 'postcode', 'other', 'phone', 'phone_mobile', 'vat_number', 'dni');
        $this->table = 'address';
        $this->className = 'Address';
        $this->lang = false;
        $this->addressType = 'customer';
        $this->explicitSelect = true;
        $this->context = Context::getContext();
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->allow_export = true;
        if (!Tools::getValue('realedit')) {
            $this->deleted = true;
        }
        $countries = Country::getCountries($this->context->language->id);
        foreach ($countries as $country) {
            $this->countries_array[$country['id_country']] = $country['name'];
        }
        $this->fields_list = array('id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name'), 'filter_key' => 'a!firstname'), 'lastname' => array('title' => $this->l('Last Name'), 'filter_key' => 'a!lastname'), 'address1' => array('title' => $this->l('Address')), 'postcode' => array('title' => $this->l('Zip/Postal Code'), 'align' => 'right'), 'city' => array('title' => $this->l('City')), 'country' => array('title' => $this->l('Country'), 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country'));
        parent::__construct();
        $this->_select = 'cl.`name` as country';
        $this->_join = '
			LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . (int) $this->context->language->id . ')
			LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON a.id_customer = c.id_customer
		';
        $this->_where = 'AND a.id_customer != 0 ' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c');
    }
 public function renderContent($setting)
 {
     $t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
     $setting = array_merge($t, $setting);
     $context = Context::getContext();
     //$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
     $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
     //echo "<pre>".print_r($categorytab,1); die;
     $categories = $this->getCategories($setting['categoryBox'], $context->language->id);
     if ($categories) {
         foreach ($categories as &$category) {
             $obj = new Category($category['id_category']);
             $category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true);
             $category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false);
             $category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false;
             $category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id);
             $tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : '';
             if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) {
                 $category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon'];
             } else {
                 $category['icon'] = '';
             }
             $category['icon_class'] = $tg['icon_class'];
         }
     }
     $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
     $setting['categories_info'] = $categories;
     $output = array('type' => 'categoriesinfo', 'data' => $setting);
     return $output;
 }
 public function initPageHeaderToolbar()
 {
     if ($this->display == 'details') {
         $this->page_header_toolbar_btn['back_to_list'] = array('href' => Context::getContext()->link->getAdminLink('AdminStockManagement'), 'desc' => $this->l('Back to list', null, null, false), 'icon' => 'process-icon-back');
     }
     parent::initPageHeaderToolbar();
 }
Example #6
0
function upgrade_module_0_9($module)
{
    $module_path = $module->getLocalPath();
    $img_folder_path = $module->getLocalPath() . 'img';
    $fixture_img_path = $module->getLocalPath() . 'img' . DIRECTORY_SEPARATOR . 'fixtures';
    if (!Tools::file_exists_cache($img_folder_path)) {
        mkdir($img_folder_path);
    }
    if (!Tools::file_exists_cache($fixture_img_path)) {
        mkdir($fixture_img_path);
    }
    $files = scandir($module->getLocalPath());
    foreach ($files as $file) {
        if (strncmp($file, 'advertising', 11) == 0) {
            if ($file == 'advertising.jpg') {
                copy($module_path . $file, $fixture_img_path . DIRECTORY_SEPARATOR . $file);
            } else {
                copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
            }
            unlink($module_path . $file);
        }
    }
    Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('blockadvertising.tpl'));
    return true;
}
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'neo_whitelist';
        $this->identifier = 'id_neo_whitelist';
        $this->className = 'NeoWhitelist';
        $this->deleted = false;
        $this->explicitSelect = true;
        $this->allow_export = true;
        $this->addRowAction('edit');
        $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;
        $this->_select = '
		a.`id_neo_whitelist`,
		a.`price`,
		p.`price` AS `pprice`,
		pl.`name`';
        $this->_join = '
        LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON (p.`id_product` = a.`id_product`)
        LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.`id_product` = a.`id_product`)
        ';
        $this->_orderBy = 'id_neo_whitelist';
        $this->_orderWay = 'DESC';
        $this->fields_list = array('id_neo_whitelist' => array('title' => $this->l('ID'), 'align' => 'text-center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Nombre'), 'havingFilter' => true), 'pprice' => array('title' => $this->l('Precio Real')), 'price' => array('title' => $this->l('Precio Intercambio')));
        parent::__construct();
    }
Example #8
0
 /**
  * Generate a cached thumbnail for object lists (eg. carrier, order states...etc)
  *
  * @param string $image Real image filename
  * @param string $cache_image Cached filename
  * @param int $size Desired size
  * @param string $image_type Image type
  * @param bool $disable_cache When turned on a timestamp will be added to the image URI to disable the HTTP cache
  * @return string
  */
 public static function thumbnail($image, $cache_image, $size, $image_type = 'jpg', $disable_cache = false)
 {
     if (!file_exists($image)) {
         return '';
     }
     if (!file_exists(_PS_TMP_IMG_DIR_ . $cache_image)) {
         $infos = getimagesize($image);
         // Evaluate the memory required to resize the image: if it's too much, you can't resize it.
         if (!ImageManager::checkImageMemoryLimit($image)) {
             return false;
         }
         $x = $infos[0];
         $y = $infos[1];
         $max_x = $size * 3;
         // Size is already ok
         if ($y < $size && $x <= $max_x) {
             copy($image, _PS_TMP_IMG_DIR_ . $cache_image);
         } else {
             $ratio_x = $x / ($y / $size);
             if ($ratio_x > $max_x) {
                 $ratio_x = $max_x;
                 $size = $y / ($x / $max_x);
             }
             ImageManager::resize($image, _PS_TMP_IMG_DIR_ . $cache_image, $ratio_x, $size, $image_type);
         }
     }
     // Relative link will always work, whatever the base uri set in the admin
     if (Context::getContext()->controller->controller_type == 'admin') {
         return '<img src="../img/tmp/' . $cache_image . (!$disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm" />';
     } else {
         return '<img src="' . _PS_TMP_IMG_ . $cache_image . (!$disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm" />';
     }
 }
Example #9
0
 public static function redirectAdmin($url)
 {
     if (!is_object(Context::getContext()->controller)) {
         Context::getContext()->controller = new StdClass();
     }
     Context::getContext()->controller->setRedirectAfter($url);
 }
Example #10
0
 public function __construct()
 {
     parent::__construct();
     $this->context = Context::getContext();
     $aResponse['error'] = false;
     $aResponse['message'] = '';
     if (isset($_POST['action'])) {
         $id_video = $_POST['idBox'];
         $ratting = $_POST['rate'];
         if (VideosRatting::checkRatting($id_video)) {
             $videosRatting = new VideosRatting();
             $videosRatting->add(array('id_video' => $id_video, 'ratting' => $ratting));
             $aResponse['error'] = FALSE;
             $aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate';
         } else {
             $aResponse['error'] = true;
             $aResponse['message'] = 'Your have rated for images';
         }
     } else {
         $aResponse['error'] = true;
         $aResponse['message'] = 'An error occured during the request. Please retry';
     }
     echo json_encode($aResponse);
     die;
 }
Example #11
0
 /**
  * Get all available glossaries
  *
  * @param integer $id_lang Language id
  * @param array $criteria Criterias for where clause
  * @param integer $start Start number
  * @param integer $limit Number of glossaries to return
  * @param string $order_by Field for ordering
  * @param string $order_way Way for ordering (ASC or DESC)
  * @param boolean $only_active Returns only active glossaries if TRUE
  * @param Context|null $context
  *
  * @return array list of glossaries
  */
 public static function getGlossaries($id_lang, $criteria = array(), $start = null, $limit = null, $order_by = null, $order_way = null, $only_active = false, Context $context = null)
 {
     $where = '';
     if (!$context) {
         $context = Context::getContext();
     }
     if ($order_by !== null) {
         if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
             die(Tools::displayError());
         }
         if ($order_by == 'id') {
             $order_by_prefix = 'l';
         } else {
             $order_by_prefix = 'll';
         }
         if (strpos($order_by, '.') > 0) {
             $order_by = explode('.', $order_by);
             $order_by_prefix = $order_by[0];
             $order_by = $order_by[1];
         }
     }
     if (isset($criteria['k'])) {
         $where .= " AND ll.name LIKE '" . pSQL($criteria['k']) . "%' ";
     }
     $sql = 'SELECT l.*, ll.*
             FROM `' . _DB_PREFIX_ . 'lexikotron` l
             LEFT JOIN `' . _DB_PREFIX_ . 'lexikotron_lang` ll ON (l.`id_lexikotron` = ll.`id_lexikotron`)
             WHERE ll.`id_lang` = ' . (int) $id_lang . ($only_active ? ' AND l.`active` = 1' : '') . '
                 ' . $where . '
                 ' . ($order_by != null ? 'ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) : '') . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : '');
     $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
     return $rows;
 }
Example #12
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
     $catids = $setting['categories'] ? $setting['categories'] : array();
     $orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
     $orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
     $items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3;
     $columns_page = $setting['columns'] ? (int) $setting['columns'] : 3;
     $categories = array();
     foreach ($catids as $catid) {
         $category = new Category($catid, (int) Context::getContext()->language->id);
         if ($category->id) {
             $categories[$catid]['id'] = $category->id;
             $categories[$catid]['name'] = $category->name;
             $categories[$catid]['link'] = $category->getLink();
             $products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
             Context::getContext()->controller->addColorsToProductList($products);
             $categories[$catid]['products'] = $products;
         }
     }
     $setting['leocategories'] = $categories;
     $setting['itemsperpage'] = $items_page;
     $setting['columnspage'] = $columns_page;
     $setting['scolumn'] = 12 / $columns_page;
     $setting['myTab'] = 'leocategorytab' . rand(20, rand());
     $output = array('type' => 'categoriestabs', 'data' => $setting);
     return $output;
 }
 function __construct()
 {
     $this->context = Context::getContext();
     $this->setDefaultSmartyVars();
     $this->getLanguageInterface();
     $this->getNavigationLinks();
 }
Example #14
0
    public function renderForm($data)
    {
        $key = time();
        $helper = $this->getFormHelper();
        $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')));
        $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Folder Path'), 'name' => 'imageslist', 'class' => 'imageupload', 'default' => '', 'id' => 'imageslist' . $key, 'desc' => 'Put image folder in the image folder ROOT_SHOP_DIR/img/'), array('type' => 'text', 'label' => $this->l('Image size'), 'name' => 'size', 'class' => 'image', 'default' => '', 'id' => 'imagesize' . $key, 'desc' => 'Enter image size. Example: thumbnail, medium, large, full or other sizes defined by current theme. 
						Alternatively enter image size in pixels: 200x100 (Width x Height). Leave empty to use \'thumbnail\' size.'), array('type' => 'select', 'label' => $this->l('Columns'), 'name' => 'columns', 'options' => array('query' => array(array('id' => '1', 'name' => $this->l('1 Column')), array('id' => '2', 'name' => $this->l('2 Columns')), array('id' => '3', 'name' => $this->l('3 Columns')), array('id' => '4', 'name' => $this->l('4 Columns')), array('id' => '5', 'name' => $this->l('5 Columns'))), 'id' => 'id', 'name' => 'name'), 'default' => 4), array('type' => 'select', 'label' => $this->l('Type'), 'name' => 'type', 'options' => array('query' => array(array('id' => 'grid', 'name' => $this->l('Grid')), array('id' => 'slider-nivo', 'name' => $this->l('Nivo Slider')), array('id' => 'slider-bt', 'name' => $this->l('Bootstrap Slider'))), 'id' => 'id', 'name' => 'name'), 'default' => 'grid'), array('type' => 'textarea', 'label' => $this->l('Custom links'), 'name' => 'links', 'desc' => 'Enter links for each slide here. Divide links with linebreaks (Enter).', 'rows' => '20'), array('type' => 'switch', 'label' => $this->l('Enable Popup Image'), 'desc' => $this->l('Show the original image on a modal box'), 'name' => 'ispopup', 'default' => 1, 'values' => $soption)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
        $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang);
        $string = '<fieldset class="panel">
				<h3>' . $this->l('Images Management') . '</h3>
				<div class="alert aleart-info">
					
					<div id="imagelist' . $key . '">
						<button class="btn btn-info">' . $this->l('Add Images') . '</button>
						<div class="images-content"></div>
					</div>
				</div>
				</fieldset>


				<script type="text/javascript">
						$(".imageupload").WPO_Gallery({gallery:true});
				</script>
			';
        return '<div id="imageslist' . $key . '">' . $helper->generateForm($this->fields_form) . $string . '</div>';
    }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'cms';
        $this->list_id = 'cms';
        $this->className = 'CMS';
        $this->lang = true;
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->fields_list = array('id_cms' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'link_rewrite' => array('title' => $this->l('URL')), 'meta_title' => array('title' => $this->l('Title'), 'filter_key' => 'b!meta_title'), 'position' => array('title' => $this->l('Position'), 'filter_key' => 'position', 'align' => 'center', 'class' => 'fixed-width-sm', 'position' => 'position'), 'active' => array('title' => $this->l('Displayed'), 'align' => 'center', 'active' => 'status', 'class' => 'fixed-width-sm', 'type' => 'bool', 'orderby' => false));
        // The controller can't be call directly
        // In this case, AdminCmsContentController::getCurrentCMSCategory() is null
        if (!AdminCmsContentController::getCurrentCMSCategory()) {
            $this->redirect_after = '?controller=AdminCmsContent&token=' . Tools::getAdminTokenLite('AdminCmsContent');
            $this->redirect();
        }
        $this->_category = AdminCmsContentController::getCurrentCMSCategory();
        $this->tpl_list_vars['icon'] = 'icon-folder-close';
        $this->tpl_list_vars['title'] = sprintf($this->l('Pages in category "%s"'), $this->_category->name[Context::getContext()->employee->id_lang]);
        $this->_join = '
		LEFT JOIN `' . _DB_PREFIX_ . 'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)';
        $this->_select = 'a.position ';
        $this->_where = ' AND c.id_cms_category = ' . (int) $this->_category->id;
        parent::__construct();
    }
 public function __construct()
 {
     $this->display_column_left = false;
     $this->display_column_right = false;
     parent::__construct();
     $this->context = Context::getContext();
 }
Example #17
0
 /**
  * Get data if the cookie exists and else initialize an new one
  *
  * @param $name string Cookie name before encrypting
  * @param $path string
  */
 public function __construct($name, $path = '', $expire = null, $shared_urls = null, $standalone = false)
 {
     $this->_content = array();
     $this->_standalone = $standalone;
     $this->_expire = is_null($expire) ? time() + 1728000 : (int) $expire;
     $this->_name = md5(($this->_standalone ? '' : _PS_VERSION_) . $name);
     $this->_path = trim(($this->_standalone ? '' : Context::getContext()->shop->physical_uri) . $path, '/\\') . '/';
     if ($this->_path[0] != '/') {
         $this->_path = '/' . $this->_path;
     }
     $this->_path = rawurlencode($this->_path);
     $this->_path = str_replace('%2F', '/', $this->_path);
     $this->_path = str_replace('%7E', '~', $this->_path);
     $this->_domain = $this->getDomain($shared_urls);
     $this->_allow_writing = true;
     $this->_salt = $this->_standalone ? str_pad('', 8, md5('ps' . __FILE__)) : _COOKIE_IV_;
     if ($this->_standalone) {
         $this->_cipherTool = new Blowfish(str_pad('', 56, md5('ps' . __FILE__)), str_pad('', 56, md5('iv' . __FILE__)));
     } elseif (!Configuration::get('PS_CIPHER_ALGORITHM')) {
         $this->_cipherTool = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_);
     } else {
         $this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
     }
     $this->update();
 }
 public function __construct($module, $file, $path)
 {
     $this->file = $file;
     $this->module = $module;
     $this->context = Context::getContext();
     $this->_path = $path;
 }
    public function reOrderPositions()
    {
        $id_slide = $this->id;
        $context = Context::getContext();
        $id_shop = $context->shop->id;
        $max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT MAX(hss.`position`) as position
			FROM `' . _DB_PREFIX_ . 'tmleftbanner_slides` hss, `' . _DB_PREFIX_ . 'tmleftbanner` hs
			WHERE hss.`id_tmleftbanner_slides` = hs.`id_tmleftbanner_slides` AND hs.`id_shop` = ' . (int) $id_shop);
        if ((int) $max == (int) $id_slide) {
            return true;
        }
        $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT hss.`position` as position, hss.`id_tmleftbanner_slides` as id_slide
			FROM `' . _DB_PREFIX_ . 'tmleftbanner_slides` hss
			LEFT JOIN `' . _DB_PREFIX_ . 'tmleftbanner` hs ON (hss.`id_tmleftbanner_slides` = hs.`id_tmleftbanner_slides`)
			WHERE hs.`id_shop` = ' . (int) $id_shop . ' AND hss.`position` > ' . (int) $this->position);
        foreach ($rows as $row) {
            $current_slide = new leftBanner($row['id_slide']);
            --$current_slide->position;
            $current_slide->update();
            unset($current_slide);
        }
        return true;
    }
 public function __construct()
 {
     $this->table = 'employee';
     $this->className = 'Employee';
     $this->lang = false;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->context = Context::getContext();
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
     /*
     check if there are more than one superAdmin
     if it's the case then we can delete a superAdmin
     */
     $super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true);
     if ($super_admin == 1) {
         $super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true);
         $super_admin_id = array();
         foreach ($super_admin_array as $key => $val) {
             $super_admin_id[] = $val['id_employee'];
         }
         $this->addRowActionSkipList('delete', $super_admin_id);
     }
     $profiles = Profile::getProfiles($this->context->language->id);
     if (!$profiles) {
         $this->errors[] = Tools::displayError('No profile');
     } else {
         foreach ($profiles as $profile) {
             $this->profiles_array[$profile['name']] = $profile['name'];
         }
     }
     $this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'lastname' => array('title' => $this->l('Last name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'width' => 130), 'email' => array('title' => $this->l('E-mail address'), 'width' => 180), 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'), 'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 30));
     $this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'desc' => $this->l('Security: minimum time to wait between two password changes'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize language used in Admin panel forms'), 'desc' => $this->l('Allow employees to select a specific language for Admin panel forms'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array()));
     $path = _PS_ADMIN_DIR_ . '/themes/';
     foreach (scandir($path) as $theme) {
         if ($theme[0] != '.' && is_dir($path . $theme) && file_exists($path . $theme . '/css/admin.css')) {
             $this->themes[] = $theme;
         }
     }
     $home_tab = Tab::getInstanceFromClassName('adminHome');
     $this->tabs_list[$home_tab->id] = array('name' => $home_tab->name[$this->context->language->id], 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name[$this->context->language->id])));
     foreach (Tab::getTabs($this->context->language->id, 0) as $tab) {
         if (Tab::checkTabRights($tab['id_tab'])) {
             $this->tabs_list[$tab['id_tab']] = $tab;
             foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) {
                 if (Tab::checkTabRights($children['id_tab'])) {
                     $this->tabs_list[$tab['id_tab']]['children'][] = $children;
                 }
             }
         }
     }
     parent::__construct();
     // An employee can edit its own profile
     if ($this->context->employee->id == Tools::getValue('id_employee')) {
         $this->tabAccess['view'] = '1';
         if (!$this->tabAccess['edit']) {
             $this->restrict_edition = true;
         }
         $this->tabAccess['edit'] = '1';
     }
 }
 public function __construct()
 {
     $this->table = 'delivery';
     $this->context = Context::getContext();
     $this->fields_options = array('general' => array('title' => $this->l('Delivery slip options'), 'fields' => array('PS_DELIVERY_PREFIX' => array('title' => $this->l('Delivery prefix:'), 'desc' => $this->l('Prefix used for delivery slips'), 'size' => 6, 'type' => 'textLang'), 'PS_DELIVERY_NUMBER' => array('title' => $this->l('Delivery number:'), 'desc' => $this->l('The next delivery slip will begin with this number and then increase with each additional slip.'), 'size' => 6, 'cast' => 'intval', 'type' => 'text')), 'submit' => array()));
     parent::__construct();
 }
Example #22
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $shop_name = htmlentities(Configuration::get('PS_SHOP_NAME'), NULL, 'utf-8');
     $shop_url = Tools::getHttpHost(true, true);
     $customer = Context::getContext()->customer;
     if (!preg_match("#.*\\.html\$#Ui", Tools::getValue('mail')) or !preg_match("#.*\\.html\$#Ui", Tools::getValue('mail'))) {
         die(Tools::redirect());
     }
     $file = file_get_contents(dirname(__FILE__) . '/../../mails/' . strval(preg_replace('#\\.{2,}#', '.', Tools::getValue('mail'))));
     $file = str_replace('{shop_name}', $shop_name, $file);
     $file = str_replace('{shop_url}', $shop_url . __PS_BASE_URI__, $file);
     $file = str_replace('{shop_logo}', $shop_url . _PS_IMG_ . 'logo.jpg', $file);
     $file = str_replace('{firstname}', $customer->firstname, $file);
     $file = str_replace('{lastname}', $customer->lastname, $file);
     $file = str_replace('{email}', $customer->email, $file);
     $file = str_replace('{firstname_friend}', 'XXXXX', $file);
     $file = str_replace('{lastname_friend}', 'xxxxxx', $file);
     $file = str_replace('{link}', 'authentication.php?create_account=1', $file);
     $discount_type = (int) Configuration::get('REFERRAL_DISCOUNT_TYPE');
     if ($discount_type == 1) {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_PERCENTAGE'), $discount_type, new Currency($this->context->currency->id)), $file);
     } else {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_DISCOUNT_VALUE_' . $this->context->currency->id), $discount_type, new Currency($this->context->currency->id)), $file);
     }
     $this->context->smarty->assign(array('content' => $file));
     $this->setTemplate('email.tpl');
 }
 public function __construct()
 {
     $this->name = 'adminmarketingestep8';
     $this->bootstrap = true;
     $this->module = 'expressmailing';
     $this->context = Context::getContext();
     $this->lang = false;
     $this->default_form_language = $this->context->language->id;
     $this->campaign_id = (int) Tools::getValue('campaign_id');
     if (empty($this->campaign_id)) {
         Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX'));
         exit;
     }
     parent::__construct();
     // On retrouve l'ID du message sur l'API
     // -------------------------------------
     $this->campaign_api_message_id = $this->getApiMessageId();
     // API initialization
     // ------------------
     include _PS_MODULE_DIR_ . $this->module->name . '/controllers/admin/session_api.php';
     $this->session_api = new SessionApi();
     // Checking the session
     // --------------------
     if (!$this->session_api->connectFromCredentials('email')) {
         Tools::redirectAdmin('index.php?controller=AdminMarketingEStep5&token=' . Tools::getAdminTokenLite('AdminMarketingEStep5'));
         exit;
     }
 }
Example #24
0
 public function render($display = true)
 {
     $render = false;
     $this->pdf_renderer->setFontForLang(Context::getContext()->language->iso_code);
     foreach ($this->objects as $object) {
         $template = $this->getTemplateObject($object);
         if (!$template) {
             continue;
         }
         if (empty($this->filename)) {
             $this->filename = $template->getFilename();
             if (count($this->objects) > 1) {
                 $this->filename = $template->getBulkFilename();
             }
         }
         $template->assignHookData($object);
         $this->pdf_renderer->createHeader($template->getHeader());
         $this->pdf_renderer->createFooter($template->getFooter());
         $this->pdf_renderer->createContent($template->getContent());
         $this->pdf_renderer->writePage();
         $render = true;
         unset($template);
     }
     if ($render) {
         // clean the output buffer
         if (ob_get_level() && ob_get_length() > 0) {
             ob_clean();
         }
         return $this->pdf_renderer->render($this->filename, $display);
     }
 }
Example #25
0
 public function __construct()
 {
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     parent::__construct();
     $this->run();
 }
 public function getContext()
 {
     if (!isset($this->_context)) {
         $this->_context = Context::getContext();
     }
     return $this->_context;
 }
 public function __construct()
 {
     $this->name = 'adminmarketingfstep7';
     $this->bootstrap = true;
     $this->module = 'expressmailing';
     $this->context = Context::getContext();
     $this->lang = false;
     $this->default_form_language = $this->context->language->id;
     parent::__construct();
     $this->campaign_id = (int) Tools::getValue('campaign_id');
     if (empty($this->campaign_id)) {
         Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX'));
         exit;
     }
     // API initialization
     // ------------------
     include _PS_MODULE_DIR_ . $this->module->name . '/controllers/admin/session_api.php';
     $this->session_api = new SessionApi();
     // Checking the session
     // --------------------
     if (!$this->session_api->connectFromCredentials('fax')) {
         Tools::redirectAdmin('index.php?controller=AdminMarketingFStep6&token=' . Tools::getAdminTokenLite('AdminMarketingFStep6'));
         exit;
     }
     $this->getFieldsValues();
 }
Example #28
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();
 }
Example #29
0
 public function initializeContext()
 {
     global $smarty;
     // Clean all cache values
     Cache::clean('*');
     Context::getContext()->shop = new Shop(1);
     Shop::setContext(Shop::CONTEXT_SHOP, 1);
     Configuration::loadConfiguration();
     if (!isset(Context::getContext()->language) || !Validate::isLoadedObject(Context::getContext()->language)) {
         if ($id_lang = (int) Configuration::get('PS_LANG_DEFAULT')) {
             Context::getContext()->language = new Language($id_lang);
         }
     }
     if (!isset(Context::getContext()->country) || !Validate::isLoadedObject(Context::getContext()->country)) {
         if ($id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT')) {
             Context::getContext()->country = new Country((int) $id_country);
         }
     }
     if (!isset(Context::getContext()->currency) || !Validate::isLoadedObject(Context::getContext()->currency)) {
         if ($id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT')) {
             Context::getContext()->currency = new Currency((int) $id_currency);
         }
     }
     Context::getContext()->cart = new Cart();
     Context::getContext()->employee = new Employee(1);
     if (!defined('_PS_SMARTY_FAST_LOAD_')) {
         define('_PS_SMARTY_FAST_LOAD_', true);
     }
     require_once _PS_ROOT_DIR_ . '/config/smarty.config.inc.php';
     Context::getContext()->smarty = $smarty;
 }
 public function setUp()
 {
     Module::updateTranslationsAfterInstall(false);
     Context::getContext()->employee = new Employee();
     Context::getContext()->employee->id = 1;
     Context::getContext()->employee->id_profile = _PS_ADMIN_PROFILE_;
 }