public function initContent()
 {
     $this->errors[] = $this->trans('Controller not found', array(), 'Admin.Notifications.Error');
     $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller'));
     $this->context->smarty->assign($tpl_vars);
     parent::initContent();
 }
 public function initContent()
 {
     $this->errors[] = Tools::displayError('Controller not found');
     $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller'));
     $this->context->smarty->assign($tpl_vars);
     parent::initContent();
 }
 public function initContent()
 {
     parent::initContent();
     if ($id_category = Tools::getvalue('id_category') && Tools::getvalue('id_category') != Null) {
         $this->context->smarty->assign(BlogCategory::GetMetaByCategory(Tools::getvalue('id_category')));
     }
     if ($id_post = Tools::getvalue('id_post') && Tools::getvalue('id_post') != Null) {
         $this->context->smarty->assign(SmartBlogPost::GetPostMetaByPost(Tools::getvalue('id_post')));
     }
     if (Tools::getvalue('id_category') == Null && Tools::getvalue('id_post') == Null) {
         $meta['meta_title'] = Configuration::get('smartblogmetatitle');
         $meta['meta_description'] = Configuration::get('smartblogmetadescrip');
         $meta['meta_keywords'] = Configuration::get('smartblogmetakeyword');
         $this->context->smarty->assign($meta);
     }
     if (Configuration::get('smartshowcolumn') == 0) {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     } elseif (Configuration::get('smartshowcolumn') == 1) {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft')));
     } elseif (Configuration::get('smartshowcolumn') == 2) {
         $this->context->smarty->assign(array('HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     } elseif (Configuration::get('smartshowcolumn') == 3) {
         $this->context->smarty->assign(array());
     } else {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     }
 }
 public function init()
 {
     parent::init();
     // context->shop is set in the init() function, so we move the _category instanciation after that
     if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete') {
         $this->_category = new Category($id_category);
     } else {
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $this->_category = new Category($this->context->shop->id_category);
         } else {
             if (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1) {
                 $this->_category = Category::getTopCategory();
             } else {
                 $this->_category = new Category(Configuration::get('PS_HOME_CATEGORY'));
             }
         }
     }
     // if we are not in a shop context, we remove the position column
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
         unset($this->fields_list['position']);
     }
     // shop restriction : if category is not available for current shop, we redirect to the list from default category
     if (!$this->_category->isAssociatedToShop() && Shop::getContext() == Shop::CONTEXT_SHOP) {
         $this->redirect_after = self::$currentIndex . '&id_category=' . (int) $this->context->shop->getCategory() . '&token=' . $this->token;
         $this->redirect();
     }
 }
 public function _posts()
 {
     $SmartBlogPost = new SmartBlogPost();
     if (Tools::isSubmit('addComment')) {
         $id_lang = $this->context->language->id;
         $id_post = Tools::getValue('id_post');
         $post = $SmartBlogPost->getPost($id_post, $id_lang);
         if ($post['comment_status'] == 1) {
             $blogcomment = new Blogcomment();
             $name = Tools::getValue('name');
             $comment = Tools::getValue('comment');
             $mail = Tools::getValue('mail');
             if (Tools::getValue('mail') == '') {
                 $website = '#';
             } else {
                 $website = Tools::getValue('website');
             }
             $id_parent_post = (int) Tools::getValue('id_parent_post');
             if (empty($name)) {
                 $this->_report .= '<p class="error">' . $this->module->l('Name is required') . '</p>';
             } elseif (empty($comment)) {
                 $this->_report .= '<p class="error">' . $this->module->l('Comment is required') . '</p>';
             } elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
                 $this->_report .= '<p class="error">' . $this->module->l('E-mail is not valid') . '</p>';
             } else {
                 $comments['name'] = $name;
                 $comments['mail'] = $mail;
                 $comments['comment'] = $comment;
                 $comments['website'] = $website;
                 if (!($id_parent_post = Tools::getvalue('comment_parent'))) {
                     $id_parent_post = 0;
                 }
                 $value = Configuration::get('smartacceptcomment');
                 if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) {
                     $value = Configuration::get('smartacceptcomment');
                 } else {
                     $value = 0;
                 }
                 $bc = new Blogcomment();
                 $bc->id_post = (int) $id_post;
                 $bc->name = $name;
                 $bc->email = $mail;
                 $bc->content = $comment;
                 $bc->website = $website;
                 $bc->id_parent = (int) $id_parent_post;
                 $bc->active = (int) $value;
                 if ($bc->add()) {
                     $this->_report .= '<p class="success">' . $this->module->l('Comment added !') . '</p>';
                     Hook::exec('actionsbpostcomment', array('bc' => $bc));
                     $this->smartsendMail($name, $mail, $comment);
                 }
             }
         }
     }
 }
 public function init()
 {
     parent::init();
     // context->shop is set in the init() function, so we move the _category instanciation after that
     if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete') {
         $this->_category = new Category($id_category);
     } else {
         if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
             $this->_category = new Category($this->context->shop->id_category);
         } elseif (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1) {
             $this->_category = Category::getTopCategory();
         } else {
             $this->_category = new Category(Configuration::get('PS_HOME_CATEGORY'));
         }
     }
     $count_categories_without_parent = count(Category::getCategoriesWithoutParent());
     $top_category = Category::getTopCategory();
     if (Tools::isSubmit('id_category')) {
         $id_parent = $this->_category->id;
     } elseif (!Shop::isFeatureActive() && $count_categories_without_parent > 1) {
         $id_parent = $top_category->id;
     } elseif (Shop::isFeatureActive() && $count_categories_without_parent == 1) {
         $id_parent = Configuration::get('PS_HOME_CATEGORY');
     } elseif (Shop::isFeatureActive() && $count_categories_without_parent > 1 && Shop::getContext() != Shop::CONTEXT_SHOP) {
         if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) == 1) {
             $id_parent = $this->context->shop->id_category;
         } else {
             $id_parent = $top_category->id;
         }
     } else {
         $id_parent = $this->context->shop->id_category;
     }
     $this->_select = 'sa.position position';
     $this->_filter .= ' AND `id_parent` = ' . (int) $id_parent . ' ';
     if (Shop::getContext() == Shop::CONTEXT_SHOP) {
         $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = ' . (int) $this->context->shop->id . ') ';
     } else {
         $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = a.id_shop_default) ';
     }
     // we add restriction for shop
     if (Shop::getContext() == Shop::CONTEXT_SHOP && Shop::isFeatureActive()) {
         $this->_where = ' AND sa.`id_shop` = ' . (int) Context::getContext()->shop->id;
     }
     // if we are not in a shop context, we remove the position column
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
         unset($this->fields_list['position']);
     }
     // shop restriction : if category is not available for current shop, we redirect to the list from default category
     if (!$this->_category->isAssociatedToShop() && Shop::getContext() == Shop::CONTEXT_SHOP) {
         $this->redirect_after = self::$currentIndex . '&id_category=' . (int) $this->context->shop->getCategory() . '&token=' . $this->token;
         $this->redirect();
     }
 }
    public function getContent()
    {
        if (Tools::isSubmit('submitModule')) {
            Configuration::updateValue('AUTHORIZE_AIM_LOGIN_ID', Tools::getvalue('authorizeaim_login_id'));
            Configuration::updateValue('AUTHORIZE_AIM_KEY', Tools::getvalue('authorizeaim_key'));
            Configuration::updateValue('AUTHORIZE_AIM_DEMO', Tools::getvalue('authorizeaim_demo_mode'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_VISA', Tools::getvalue('authorizeaim_card_visa'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_MASTERCARD', Tools::getvalue('authorizeaim_card_mastercard'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_DISCOVER', Tools::getvalue('authorizeaim_card_discover'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_AX', Tools::getvalue('authorizeaim_card_ax'));
            echo $this->displayConfirmation($this->l('Configuration updated'));
        }
        return '
		<h2>' . $this->displayName . '</h2>
		<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" alt="" /> ' . $this->l('Help') . '</legend>
			<a href="http://www.authorize.net/signupnow/" style="float: right;"><img src="../modules/' . $this->name . '/logo_authorize.png" alt="" /></a>
			<h3>' . $this->l('In your PrestaShop admin panel') . '</h3>
			- ' . $this->l('Fill the Login ID field with the one provided by Authorize.net') . '<br />
			- ' . $this->l('Fill the key field with the transaction key provided by Authorize.net') . '<br />
			<span style="color: red;" >- ' . $this->l('Warning: Your website must possess a SSL certificate to use the Authorize.net AIM payment system. You are responsible for the safety of your customers\' bank information. PrestaShop cannot be blamed for any security issue on your website.') . '</span><br />
			<br />
		</fieldset><br />
		<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset class="width2">
				<legend><img src="../img/admin/contact.gif" alt="" />' . $this->l('Settings') . '</legend>
				<label for="authorizeaim_login_id">' . $this->l('Login ID') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_login_id" value="' . Configuration::get('AUTHORIZE_AIM_LOGIN_ID') . '" /></div>
				<label for="authorizeaim_key">' . $this->l('Key') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_key" value="' . Configuration::get('AUTHORIZE_AIM_KEY') . '" /></div>
				<label for="authorizeaim_demo_mode">' . $this->l('Mode:') . '</label>
				<div class="margin-form" id="authorizeaim_demo">
					<input type="radio" name="authorizeaim_demo_mode" value="0" style="vertical-align: middle;" ' . (!Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #080;">' . $this->l('Production') . '</span>
					<input type="radio" name="authorizeaim_demo_mode" value="1" style="vertical-align: middle;" ' . (Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #900;">' . $this->l('Test') . '</span>
				</div>
				<label for="authorizeaim_cards">' . $this->l('Cards:') . '</label>
				<div class="margin-form" id="authorizeaim_cards">
					<input type="checkbox" name="authorizeaim_card_visa" ' . (Configuration::get('AUTHORIZE_AIM_CARD_VISA') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/visa.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_mastercard" ' . (Configuration::get('AUTHORIZE_AIM_CARD_MASTERCARD') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/mastercard.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_discover" ' . (Configuration::get('AUTHORIZE_AIM_CARD_DISCOVER') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/discover.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_ax" ' . (Configuration::get('AUTHORIZE_AIM_CARD_AX') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/ax.gif" alt="visa" />
				</div>
				<br /><center><input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
			</fieldset>
		</form>';
    }
 public function getContent()
 {
     $html = '';
     if (Tools::isSubmit('save' . $this->name)) {
         Configuration::updateValue('smartshowhomepost', Tools::getvalue('smartshowhomepost'));
         $html = $this->displayConfirmation($this->l('The settings have been updated successfully.'));
         $helper = $this->SettingForm();
         $html .= $helper->generateForm($this->fields_form);
         return $html;
     } else {
         $helper = $this->SettingForm();
         $html .= $helper->generateForm($this->fields_form);
         return $html;
     }
 }
 public function initProcess()
 {
     if ($this->token != Tools::getvalue('token')) {
         die;
     }
     $view = Tools::getvalue('view');
     if (isset($view) && !empty($view)) {
         $file = _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/' . $view . '.php';
         if (file_exists($file)) {
             require_once $file;
         }
     } else {
         die;
     }
 }
 public function renderForm()
 {
     $img_desc = '';
     $img_desc .= $this->l('Upload a Avatar from your computer.<br/>N.B : Only jpg image is allowed');
     if (Tools::getvalue('id_smart_blog_category') != '' && Tools::getvalue('id_smart_blog_category') != NULL) {
         $img_desc .= '<br/><img style="height:auto;width:300px;clear:both;border:1px solid black;" alt="" src="' . __PS_BASE_URI__ . 'modules/smartblog/images/category/' . Tools::getvalue('id_smart_blog_category') . '.jpg" /><br />';
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Blog Category')), 'input' => array(array('type' => 'text', 'label' => $this->l('Meta Title'), 'name' => 'meta_title', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Category Name'), 'lang' => true), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => false, 'desc' => $this->l('Enter Your Category Description')), array('type' => 'file', 'label' => $this->l('Category Image:'), 'name' => 'category_image', 'display_image' => false, 'desc' => $img_desc), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Category Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Category Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => true, 'desc' => $this->l('Enetr Your Category Slug. Use In SEO Friendly URL')), array('type' => 'select', 'label' => $this->l('Parent Category'), 'name' => 'id_parent', 'options' => array('query' => BlogCategory::getCategory(), 'id' => 'id_smart_blog_category', 'name' => 'meta_title'), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($BlogCategory = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
     return parent::renderForm();
 }
 public function getContent()
 {
     $html = '';
     if (Tools::isSubmit('submitModule')) {
         Configuration::updateValue('PAYNETZ_API_MERCHANT_URL', Tools::getvalue('api_merchant_url'));
         Configuration::updateValue('PAYNETZ_API_SERVER_PORT', Tools::getvalue('api_server_port'));
         Configuration::updateValue('PAYNETZ_API_LOGIN_ID', Tools::getvalue('api_login_id'));
         Configuration::updateValue('PAYNETZ_API_PASSWORD', Tools::getvalue('api_password'));
         Configuration::updateValue('PAYNETZ_API_PRODUCT_ID', Tools::getvalue('api_product_id'));
         $html .= $this->displayConfirmation($this->l('Configuration updated'));
     }
     // For "Hold for Review" order status
     $currencies = Currency::getCurrencies(false, true);
     $order_states = OrderState::getOrderStates((int) $this->context->cookie->id_lang);
     $this->context->smarty->assign(array('available_currencies' => $this->aim_available_currencies, 'currencies' => $currencies, 'module_dir' => $this->_path, 'order_states' => $order_states, 'PAYNETZ_API_MERCHANT_URL' => Configuration::get('PAYNETZ_API_MERCHANT_URL'), 'PAYNETZ_API_SERVER_PORT' => Configuration::get('PAYNETZ_API_SERVER_PORT'), 'PAYNETZ_API_LOGIN_ID' => Configuration::get('PAYNETZ_API_LOGIN_ID'), 'PAYNETZ_API_PASSWORD' => Configuration::get('PAYNETZ_API_PASSWORD'), 'PAYNETZ_API_PRODUCT_ID' => Configuration::get('PAYNETZ_API_PRODUCT_ID')));
     return $this->context->smarty->fetch($this->local_path . 'views/templates/admin/configuration.tpl');
 }
Example #12
0
 public function initContent()
 {
     parent::initContent();
     $blogcomment = new Blogcomment();
     $year = Tools::getvalue('year');
     $month = Tools::getvalue('month');
     $title_category = '';
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if ((bool) Tools::getValue('page')) {
         $c = (int) Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     $result = SmartBlogPost::getArchiveResult($month, $year, $limit_start, $limit);
     $total = count($result);
     $totalpages = ceil($total / $posts_per_page);
     $i = 0;
     $to = array();
     if (!empty($result)) {
         foreach ($result as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $result[$j]['totalcomment'] = 0;
             } else {
                 $result[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
     $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content);
     $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'postcategory' => $result, 'title_category' => $title_category, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'totalpages' => $totalpages));
     $template_name = 'archivecategory.tpl';
     $this->setTemplate($template_name);
 }
 public function getContent()
 {
     $html = '';
     if (Tools::isSubmit('submitModule')) {
         $simplepay_mode = (int) Tools::getvalue('simplepay_test_mode');
         if ($simplepay_mode) {
             Configuration::updateValue('SIMPLEPAY_TEST_MODE', 1);
         } else {
             Configuration::updateValue('SIMPLEPAY_TEST_MODE', 0);
         }
         Configuration::updateValue('SIMPLEPAY_LIVE_PRIVATE_KEY', Tools::getvalue('simplepay_live_private_key'));
         Configuration::updateValue('SIMPLEPAY_LIVE_PUBLIC_KEY', Tools::getvalue('simplepay_live_public_key'));
         Configuration::updateValue('SIMPLEPAY_TEST_PRIVATE_KEY', Tools::getvalue('simplepay_test_private_key'));
         Configuration::updateValue('SIMPLEPAY_TEST_PUBLIC_KEY', Tools::getvalue('simplepay_test_public_key'));
         Configuration::updateValue('SIMPLEPAY_PAYMENT_DESCRIPTION', Tools::getvalue('simplepay_payment_description'));
         Configuration::updateValue('SIMPLEPAY_IMAGE', Tools::getvalue('simplepay_image'));
         $html .= $this->displayConfirmation($this->l('SimplePay settings updated'));
     }
     $this->context->smarty->assign(array('module_dir' => $this->_path, 'simplepay_test_mode' => Configuration::get('SIMPLEPAY_TEST_MODE'), 'simplepay_live_private_key' => Configuration::get('SIMPLEPAY_LIVE_PRIVATE_KEY'), 'simplepay_live_public_key' => Configuration::get('SIMPLEPAY_LIVE_PUBLIC_KEY'), 'simplepay_test_private_key' => Configuration::get('SIMPLEPAY_TEST_PRIVATE_KEY'), 'simplepay_test_public_key' => Configuration::get('SIMPLEPAY_TEST_PUBLIC_KEY'), 'simplepay_payment_description' => Configuration::get('SIMPLEPAY_PAYMENT_DESCRIPTION'), 'simplepay_image' => Configuration::get('SIMPLEPAY_IMAGE')));
     return $this->context->smarty->fetch(dirname(__FILE__) . '/views/templates/admin/configuration.tpl');
 }
Example #14
0
 private function priceInput($name, $value = '')
 {
     return '<input type="text" value="' . Tools::getvalue($name, $value) . '" name="' . $name . '" size="20" maxlength="10" /> <span>' . $this->context->currency->sign . '</span>';
 }
 public function postProcess()
 {
     if (Tools::isSubmit('deleteemployee') || Tools::isSubmit('status') || Tools::isSubmit('statusemployee')) {
         /* PrestaShop demo mode */
         if (_PS_MODE_DEMO_ && ($id_employee = Tools::getValue('id_employee') && (int) $id_employee == _PS_DEMO_MAIN_BO_ACCOUNT_)) {
             $this->errors[] = Tools::displayError('This functionality has been disabled.');
             return;
         }
         if ($this->context->employee->id == Tools::getValue('id_employee')) {
             $this->errors[] = Tools::displayError('You cannot disable or delete your own account.');
             return false;
         }
         $employee = new Employee(Tools::getValue('id_employee'));
         if ($employee->isLastAdmin()) {
             $this->errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
             return false;
         }
         // It is not possible to delete an employee if he manages warehouses
         $warehouses = Warehouse::getWarehousesByEmployee((int) Tools::getValue('id_employee'));
         if (Tools::isSubmit('deleteemployee') && count($warehouses) > 0) {
             $this->errors[] = Tools::displayError('You cannot delete this account because it manages warehouses. Check your warehouses first.');
             return false;
         }
     } elseif (Tools::isSubmit('submitAddemployee')) {
         $employee = new Employee((int) Tools::getValue('id_employee'));
         // If the employee is editing its own account
         if ($this->restrict_edition) {
             $_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile;
             $_POST['active'] = $_GET['active'] = $employee->active;
             // Unset set shops
             foreach ($_POST as $postkey => $postvalue) {
                 if (strstr($postkey, 'checkBoxShopAsso_' . $this->table) !== false) {
                     unset($_POST[$postkey]);
                 }
             }
             foreach ($_GET as $postkey => $postvalue) {
                 if (strstr($postkey, 'checkBoxShopAsso_' . $this->table) !== false) {
                     unset($_GET[$postkey]);
                 }
             }
             // Add current shops associated to the employee
             $result = Shop::getShopById((int) $employee->id, $this->identifier, $this->table);
             foreach ($result as $row) {
                 $key = 'checkBoxShopAsso_' . $this->table;
                 if (!isset($_POST[$key])) {
                     $_POST[$key] = array();
                 }
                 if (!isset($_GET[$key])) {
                     $_GET[$key] = array();
                 }
                 $_POST[$key][$row['id_shop']] = 1;
                 $_GET[$key][$row['id_shop']] = 1;
             }
         }
         //if profile is super admin, manually fill checkBoxShopAsso_employee because in the form they are disabled.
         if ($_POST['id_profile'] == _PS_ADMIN_PROFILE_) {
             $result = Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop');
             foreach ($result as $row) {
                 $key = 'checkBoxShopAsso_' . $this->table;
                 if (!isset($_POST[$key])) {
                     $_POST[$key] = array();
                 }
                 if (!isset($_GET[$key])) {
                     $_GET[$key] = array();
                 }
                 $_POST[$key][$row['id_shop']] = 1;
                 $_GET[$key][$row['id_shop']] = 1;
             }
         }
         if ($employee->isLastAdmin()) {
             if (Tools::getValue('id_profile') != (int) _PS_ADMIN_PROFILE_) {
                 $this->errors[] = Tools::displayError('You should have at least one employee in the administrator group.');
                 return false;
             }
             if (Tools::getvalue('active') == 0) {
                 $this->errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
                 return false;
             }
         }
         if (!in_array(Tools::getValue('bo_theme'), $this->themes)) {
             $this->errors[] = Tools::displayError('Invalid theme.');
             return false;
         }
         $assos = $this->getSelectedAssoShop($this->table);
         if (!$assos && ($this->table = 'employee')) {
             if (Shop::isFeatureActive() && _PS_ADMIN_PROFILE_ != $_POST['id_profile']) {
                 $this->errors[] = Tools::displayError('The employee must be associated with at least one shop');
             }
         }
     }
     return parent::postProcess();
 }
Example #16
0
 public function postProcess()
 {
     if (Tools::getValue('reindex') === 'true') {
         Cmsearch::indexation();
         die;
     }
     if (Tools::getValue('state')) {
         switch (Tools::getValue('state')) {
             case 1:
                 return $this->displayConfirmation($this->l('Configuration updated'));
             case 2:
                 return $this->displayError($this->l('An error occurred while attempting to get certificate.'));
             case 3:
                 return $this->displayError($this->l('An error occurred while attempting to get hash.'));
             case 4:
                 return $this->displayError($this->l('An error occurred while attempting to create fields.'));
         }
     }
     if (Tools::getValue('cm_token')) {
         $convermax = new ConvermaxAPI();
         if ($convermax->getCertificate(Tools::getValue('cm_token'))) {
             if ($convermax->getHash()) {
                 if ($convermax->createIndexFields()) {
                     Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=1&configure=convermax&token=' . Tools::getValue('token'));
                 }
                 Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=4&configure=convermax&token=' . Tools::getValue('token'));
             }
             Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=3&configure=convermax&token=' . Tools::getValue('token'));
         }
         Tools::redirectAdmin($_SERVER['SCRIPT_NAME'] . '?controller=AdminModules&state=2&configure=convermax&token=' . Tools::getValue('token'));
     }
     if (Tools::isSubmit('submitModule')) {
         if (isset($_FILES['cert']) && isset($_FILES['cert']['tmp_name']) && !empty($_FILES['cert']['tmp_name'])) {
             if (!stristr(Tools::substr($_FILES['cert']['name'], -4), '.pem')) {
                 return $this->displayError($this->l('Invalid file'));
             } else {
                 Configuration::updateValue('CONVERMAX_CERT', Tools::file_get_contents($_FILES['cert']['tmp_name']));
             }
         }
         if (stristr(Tools::substr(Tools::getvalue('url'), -1), '/')) {
             $url = Tools::substr(Tools::getvalue('url'), 0, -1);
         } else {
             $url = Tools::getvalue('url');
         }
         if (!$url) {
             return $this->displayError($this->l('Enter URL'));
         }
         Configuration::updateValue('CONVERMAX_URL', $url);
         return $this->displayConfirmation($this->l('Configuration updated'));
     }
 }
Example #17
0
 /**
  * renderForm contains all necessary initialization needed for all tabs
  *
  * @return string|void
  */
 public function renderForm()
 {
     // This nice code (irony) is here to store the product name, because the row after will erase product name in multishop context
     $this->product_name = $this->object->name[$this->context->language->id];
     if (!method_exists($this, 'initForm' . $this->tab_display)) {
         return;
     }
     $product = $this->object;
     // Product for multishop
     $this->context->smarty->assign('bullet_common_field', '');
     if (Shop::isFeatureActive() && $this->display == 'edit') {
         if (Shop::getContext() != Shop::CONTEXT_SHOP) {
             $this->context->smarty->assign(array('display_multishop_checkboxes' => true, 'multishop_check' => Tools::getValue('multishop_check')));
         }
         if (Shop::getContext() != Shop::CONTEXT_ALL) {
             $this->context->smarty->assign('bullet_common_field', '<i class="icon-circle text-orange"></i>');
             $this->context->smarty->assign('display_common_field', true);
         }
     }
     $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
     $this->tpl_form_vars['product_type'] = (int) Tools::getValue('type_product', $product->getType());
     $this->getLanguages();
     $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['currentIndex'] = self::$currentIndex;
     $this->tpl_form_vars['display_multishop_checkboxes'] = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit';
     $this->fields_form = array('');
     $this->tpl_form_vars['token'] = $this->token;
     $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST);
     $this->tpl_form_vars['save_error'] = !empty($this->errors);
     $this->tpl_form_vars['ps_force_friendly_product'] = Configuration::get('PS_FORCE_FRIENDLY_PRODUCT');
     // autoload rich text editor (tiny mce)
     $this->tpl_form_vars['tinymce'] = true;
     $iso = $this->context->language->iso_code;
     $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_;
     $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_);
     if (Validate::isLoadedObject($this->object)) {
         $id_product = (int) $this->object->id;
     } else {
         $id_product = (int) Tools::getvalue('id_product');
     }
     $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminProducts') . '&' . ($id_product ? 'id_product=' . (int) $id_product : 'addproduct');
     $this->tpl_form_vars['id_product'] = $id_product;
     //ะ”ะพะฑะฐะฒะปัะตะผ ะฒ ั„ะพั€ะผัƒ ะฟะตั€ะตะผะตะฝะฝัƒัŽ ั ั€ะตะบะพะผะตะฝะดัƒะตะผั‹ะผ reference = ะผะฐะบัะธะผะฐะปัŒะฝั‹ะน ะฒ ะฑะฐะทะต + 1
     if (!$id_product) {
         $result = "";
         $sql = "SELECT LPAD(max(LPAD(RIGHT(`reference`, 5),5,0))+1,5,0) as ref FROM `" . _DB_PREFIX_ . "product`\nWHERE `reference` REGEXP '^-?[0-9]+\$'";
         $result = Db::getInstance()->getValue($sql);
         if ($result) {
             $this->tpl_form_vars['next_free_reference'] = $result;
         }
     }
     // Transform configuration option 'upload_max_filesize' in octets
     $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize'));
     // Transform configuration option 'upload_max_filesize' in MegaOctets
     $upload_max_filesize = $upload_max_filesize / 1024 / 1024;
     $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
     $this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
     $this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
     $this->product_exists_in_shop = true;
     if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) {
         $this->product_exists_in_shop = false;
         if ($this->tab_display == 'Informations') {
             $this->displayWarning($this->l('Warning: The product does not exist in this shop'));
         }
         $default_product = new Product();
         $definition = ObjectModel::getDefinition($product);
         foreach ($definition['fields'] as $field_name => $field) {
             if (isset($field['shop']) && $field['shop']) {
                 $product->{$field_name} = ObjectModel::formatValue($default_product->{$field_name}, $field['type']);
             }
         }
     }
     // let's calculate this once for all
     if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
         $this->errors[] = 'Unable to load object';
     } else {
         $this->_displayDraftWarning($this->object->active);
         // if there was an error while saving, we don't want to lose posted data
         if (!empty($this->errors)) {
             $this->copyFromPost($this->object, $this->table);
         }
         $this->initPack($this->object);
         $this->{'initForm' . $this->tab_display}($this->object);
         $this->tpl_form_vars['product'] = $this->object;
         if ($this->ajax) {
             if (!isset($this->tpl_form_vars['custom_form'])) {
                 throw new PrestaShopException('custom_form empty for action ' . $this->tab_display);
             } else {
                 return $this->tpl_form_vars['custom_form'];
             }
         }
     }
     $parent = parent::renderForm();
     $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     return $parent;
 }
Example #18
0
 /**
  * Retrieve the controller from url or request uri if routes are activated
  *
  * @param int $id_shop, defaults null
  * @return string
  */
 public function getController($id_shop = null)
 {
     if (defined('_PS_ADMIN_DIR_')) {
         $_GET['controllerUri'] = Tools::getvalue('controller');
     }
     if ($this->controller) {
         $_GET['controller'] = $this->controller;
         return $this->controller;
     }
     if (null === $id_shop) {
         $id_shop = (int) Context::getContext()->shop->id;
     }
     $controller = Tools::getValue('controller');
     if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\\?(.*)=(.*)$/Ui', $controller, $m)) {
         $controller = $m[1];
         if (isset($_GET['controller'])) {
             $_GET[$m[2]] = $m[3];
         } elseif (isset($_POST['controller'])) {
             $_POST[$m[2]] = $m[3];
         }
     }
     if (!Validate::isControllerName($controller)) {
         $controller = false;
     }
     // Use routes ? (for url rewriting)
     if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) {
         if (!$this->request_uri) {
             return strtolower($this->controller_not_found);
         }
         $controller = $this->controller_not_found;
         // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher)
         if (!preg_match('/\\.(gif|jpe?g|png|css|js|ico)$/i', $this->request_uri)) {
             // Add empty route as last route to prevent this greedy regexp to match request uri before right time
             if ($this->empty_route) {
                 $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop);
             }
             list($uri) = explode('?', $this->request_uri);
             if (isset($this->routes[$id_shop][Context::getContext()->language->id])) {
                 $findRoute = array();
                 // check, whether request_uri is template or not
                 foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) {
                     if (preg_match($route['regexp'], $uri, $m)) {
                         $isTemplate = false;
                         $module = isset($route['params']['module']) ? $route['params']['module'] : '';
                         switch ($route['controller'] . $module) {
                             // Avoid name collision between core and modules' controllers
                             case 'supplier':
                             case 'manufacturer':
                                 // these two can be processed in normal way and also as template
                                 if (false !== strpos($route['rule'], '{')) {
                                     $isTemplate = true;
                                 }
                                 break;
                             case 'cms':
                             case 'product':
                                 $isTemplate = true;
                                 break;
                             case 'category':
                                 // category can be processed in two ways
                                 if (false === strpos($route['rule'], 'selected_filters')) {
                                     $isTemplate = true;
                                 }
                                 break;
                         }
                         if (!$isTemplate) {
                             $findRoute = $route;
                             break;
                         }
                     }
                 }
                 // if route is not found, we have to find rewrite link in database
                 if (empty($findRoute)) {
                     // get the path from requested URI, and remove "/" at the beginning
                     $short_link = ltrim(parse_url($uri, PHP_URL_PATH), '/');
                     if (!Dispatcher::isProductLink($short_link)) {
                         if (!Dispatcher::isCategoryLink($short_link)) {
                             if (!Dispatcher::isCmsLink($short_link)) {
                                 if (!Dispatcher::isManufacturerLink($short_link)) {
                                     if (!Dispatcher::isSupplierLink($short_link)) {
                                     } else {
                                         $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['supplier_rule'];
                                     }
                                 } else {
                                     $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['manufacturer_rule'];
                                 }
                             } else {
                                 $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['cms_rule'];
                             }
                         } else {
                             $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['category_rule'];
                         }
                     } else {
                         $findRoute = $this->routes[$id_shop][Context::getContext()->language->id]['product_rule'];
                     }
                 }
                 if (!empty($findRoute)) {
                     if (preg_match($findRoute['regexp'], $uri, $m)) {
                         // Route found ! Now fill $_GET with parameters of uri
                         foreach ($m as $k => $v) {
                             if (!is_numeric($k)) {
                                 $_GET[$k] = $v;
                             }
                         }
                         $controller = $findRoute['controller'] ? $findRoute['controller'] : $_GET['controller'];
                         if (!empty($findRoute['params'])) {
                             foreach ($findRoute['params'] as $k => $v) {
                                 $_GET[$k] = $v;
                             }
                         }
                         // A patch for module friendly urls
                         if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m)) {
                             $_GET['module'] = $m[1];
                             $_GET['fc'] = 'module';
                             $controller = $m[2];
                         }
                         if (isset($_GET['fc']) && $_GET['fc'] == 'module') {
                             $this->front_controller = self::FC_MODULE;
                         }
                     }
                 }
             }
         }
         if ($controller == 'index' || $this->request_uri == '/index.php') {
             $controller = $this->default_controller;
         }
         $this->controller = $controller;
     } else {
         // Default mode, take controller from url
         $this->controller = $controller;
     }
     $this->controller = str_replace('-', '', $this->controller);
     $_GET['controller'] = $this->controller;
     return $this->controller;
 }
    public function getContent()
    {
        $html = '';
        if (Tools::isSubmit('submitModule')) {
            Configuration::updateValue('AUTHORIZE_AIM_LOGIN_ID', Tools::getvalue('authorizeaim_login_id'));
            Configuration::updateValue('AUTHORIZE_AIM_KEY', Tools::getvalue('authorizeaim_key'));
            Configuration::updateValue('AUTHORIZE_AIM_DEMO', Tools::getvalue('authorizeaim_demo_mode'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_VISA', Tools::getvalue('authorizeaim_card_visa'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_MASTERCARD', Tools::getvalue('authorizeaim_card_mastercard'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_DISCOVER', Tools::getvalue('authorizeaim_card_discover'));
            Configuration::updateValue('AUTHORIZE_AIM_CARD_AX', Tools::getvalue('authorizeaim_card_ax'));
            Configuration::updateValue('AUTHORIZE_AIM_HOLD_REVIEW_OS', Tools::getvalue('authorizeaim_hold_review_os'));
            $html .= $this->displayConfirmation($this->l('Configuration updated'));
        }
        // For Hold for Review
        $orderStates = OrderState::getOrderStates((int) $this->context->cookie->id_lang);
        $html .= '<h2>' . $this->displayName . '</h2>
		<fieldset><legend><img src="../modules/' . $this->name . '/logo.gif" alt="" /> ' . $this->l('Help') . '</legend>
			<a href="http://api.prestashop.com/partner/authorize.net/" target="_blank" style="float: right;"><img src="../modules/' . $this->name . '/logo_authorize.png" alt="" /></a>
			<h3>' . $this->l('In your PrestaShop admin panel') . '</h3>
			- ' . $this->l('Fill the  Login ID  provided by Authorize.net') . '<br />
			- ' . $this->l('Fill the key field with the transaction key provided by Authorize.net') . '<br />
			<span style="color: red;" >- ' . $this->l('Warning: Your website must possess a SSL certificate to use the Authorize.net AIM payment system. You are responsible for the safety of your customers\' bank information. PrestaShop cannot be blamed for any security issue on your website.') . '</span><br />
			<br />
		</fieldset><br />
		<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset class="width2">
				<legend><img src="../img/admin/contact.gif" alt="" />' . $this->l('Settings') . '</legend>
				<label for="authorizeaim_login_id">' . $this->l('Login ID') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_login_id" value="' . Configuration::get('AUTHORIZE_AIM_LOGIN_ID') . '" /></div>
				<label for="authorizeaim_key">' . $this->l('Key') . '</label>
				<div class="margin-form"><input type="text" size="20" id="authorizeaim_login_id" name="authorizeaim_key" value="' . Configuration::get('AUTHORIZE_AIM_KEY') . '" /></div>
				<label for="authorizeaim_demo_mode">' . $this->l('Mode:') . '</label>
				<div class="margin-form" id="authorizeaim_demo">
					<input type="radio" name="authorizeaim_demo_mode" value="0" style="vertical-align: middle;" ' . (!Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #080;">' . $this->l('Production') . '</span>
					<input type="radio" name="authorizeaim_demo_mode" value="1" style="vertical-align: middle;" ' . (Tools::getValue('authorizeaim_demo_mode', Configuration::get('AUTHORIZE_AIM_DEMO')) ? 'checked="checked"' : '') . ' />
					<span style="color: #900;">' . $this->l('Test') . '</span>
				</div>
				<label for="authorizeaim_cards">' . $this->l('Cards:') . '</label>
				<div class="margin-form" id="authorizeaim_cards">
					<input type="checkbox" name="authorizeaim_card_visa" ' . (Configuration::get('AUTHORIZE_AIM_CARD_VISA') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/visa.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_mastercard" ' . (Configuration::get('AUTHORIZE_AIM_CARD_MASTERCARD') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/mastercard.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_discover" ' . (Configuration::get('AUTHORIZE_AIM_CARD_DISCOVER') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/discover.gif" alt="visa" />
					<input type="checkbox" name="authorizeaim_card_ax" ' . (Configuration::get('AUTHORIZE_AIM_CARD_AX') ? 'checked="checked"' : '') . ' />
						<img src="../modules/' . $this->name . '/cards/ax.gif" alt="visa" />
				</div>

				<label for="authorizeaim_hold_review_os">' . $this->l('Order status:  "Hold for Review" ') . '</label>
				<div class="margin-form">
								<select id="authorizeaim_hold_review_os" name="authorizeaim_hold_review_os">';
        // Hold for Review order state selection
        foreach ($orderStates as $os) {
            $html .= '
				<option value="' . (int) $os['id_order_state'] . '"' . ((int) $os['id_order_state'] == (int) Configuration::get('AUTHORIZE_AIM_HOLD_REVIEW_OS') ? ' selected' : '') . '>' . Tools::stripslashes($os['name']) . '</option>' . "\n";
        }
        return $html . '</select></div>
				<br /><center><input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
			</fieldset>
		</form>';
    }
 public function renderForm()
 {
     $this->post_format_fields = smartblog::$post_meta_fields;
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $shops = false;
     if (Shop::isFeatureActive()) {
         $shops = Shop::getShops();
     }
     if ($shops) {
         foreach ($shops as $key => $shop) {
             if (!$obj->isAssociatedToShop($shop['id_shop'])) {
                 unset($shops[$key]);
             }
         }
     }
     $languages = Language::getLanguages(false);
     //Added From Old
     /*         * ************* featured image ****************** */
     $featured_image = _MODULE_SMARTBLOG_DIR_ . $obj->id . '.jpg';
     $image_url = ImageManager::thumbnail($featured_image, $this->table . '_' . pSQL(Tools::getvalue('id_smart_blog_post')) . '.jpg', 200, 'jpg', true, true);
     $image_size = file_exists($featured_image) ? filesize($featured_image) / 1000 : false;
     /*         * ************* featured image ****************** */
     // image gallary
     $id_smart_blog_post = (int) Tools::getValue('id_smart_blog_post');
     $images = SmartBlogGallaryImage::getImages($this->context->language->id, $id_smart_blog_post);
     foreach ($images as $k => $image) {
         $images[$k] = new SmartBlogGallaryImage($image['id_smart_blog_gallary_images']);
     }
     //start sdsimage type
     $image_uploader = new HelperImageUploader('file');
     $image_uploader->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminSmartBlogAjax') . '&ajax=1&id_smart_blog_post=' . (int) Tools::getvalue('id_smart_blog_post') . '&action=addGallaryImage');
     // test code
     $root = BlogCategory::getRootCategory();
     $default_category = $root['id_smart_blog_category'];
     if (!Tools::isSubmit('id_smart_blog_post')) {
         $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
     } else {
         if (Tools::isSubmit('categoryBox')) {
             $selected_cat = BlogCategory::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
         } else {
             $selected_cat = BlogCategory::getPostCategoriesFull((int) Tools::getValue('id_smart_blog_post'), $this->default_form_language);
         }
     }
     $categories = array();
     foreach ($selected_cat as $key => $category) {
         $categories[] = $key;
     }
     $tree = new SmartBlogHelperTreeCategories('smartblog-associated-categories-tree', 'Associated categories');
     $tree->setTemplate('tree_associated_categories.tpl')->setHeaderTemplate('tree_associated_header.tpl')->setRootCategory((int) $root['id_category'])->setUseCheckBox(true)->setUseSearch(false)->setSelectedCategories($categories);
     // end test code
     $temp_employees = Employee::getEmployees();
     $employees = array();
     foreach ($temp_employees as $employee) {
         $employee['fullname'] = $employee['firstname'] . ' ' . $employee['lastname'];
         $employee['id_select'] = $employee['id_employee'];
         $employees[] = $employee;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'id' => 'name', 'class' => 'copyMeta2friendlyURL', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'select', 'label' => $this->l('Author'), 'name' => 'id_author', 'options' => array('query' => $employees, 'id' => 'id_select', 'name' => 'fullname')), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'desc' => $this->l('Enter Your Post Description')), array('type' => 'file', 'label' => $this->l('Featured Image:'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . pSQL(Tools::getvalue('id_smart_blog_post')) . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'html', 'label' => $this->l('Blog Categories'), 'name' => 'id_category_big', 'required' => true, 'html_content' => $tree->render(), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'desc' => $this->l('Enter Your Post Short Description')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'desc' => $this->l('Enetr Your Post Slug. Use In SEO Friendly URL')), array('type' => 'tags', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' &lt;&gt;;=#{}')), array('type' => 'switch', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('label' => $this->l('Published Date'), 'name' => 'created', 'title' => $this->l('Published date'), 'type' => 'datetime'), array('type' => 'associations', 'label' => $this->l('Related Product(s)'), 'name' => 'associations', 'size' => 60, 'lang' => true, 'required' => false), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'gallary' => array('images' => array('count' => count($images), 'max_image_size' => $this->max_image_size / 1024 / 1024, 'table' => $this->table, 'images' => $images, 'id_smart_blog_post' => (int) Tools::getValue('id_smart_blog_post'), 'object' => $this->object, 'image_uploader' => $image_uploader->render())));
     $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Post Format'), 'name' => 'post_type', 'required' => true, 'values' => array(array('id' => 'post_type_default', 'value' => '', 'label' => '<i class="icon-home"></i> ' . $this->l('None')), array('id' => 'post_type_gallery', 'value' => 'gallery', 'label' => '<i class="icon-picture"></i> ' . $this->l('Gallery')), array('id' => 'post_type_audio', 'value' => 'audio', 'label' => '<i class="icon-music"></i> ' . $this->l('Audio')), array('id' => 'post_type_video', 'value' => 'video', 'label' => '<i class="icon-film"></i> ' . $this->l('Video')), array('id' => 'post_type_quote', 'value' => 'quote', 'label' => '<i class="icon-quote-left"></i> ' . $this->l('Quote')), array('id' => 'post_type_link', 'value' => 'link', 'label' => '<i class="icon-link"></i> ' . $this->l('Link'))));
     $this->fields_form['input'][] = array('type' => 'html', 'label' => $this->l('Post Format Fields'), 'name' => 'post_format_fields', 'html_content' => $this->AdminMetaFields(), 'desc' => $this->l('Set exclusive fields for the post format'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($SmartBlogPost = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true);
     $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false);
     if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) {
         foreach (Language::getLanguages(false) as $lang) {
             $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']);
         }
     }
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     // related product using Accessories block
     $accessories = SmartBlogPost::getAccessoriesLight($this->context->language->id, $SmartBlogPost->id_smart_blog_post);
     if ($post_accessories = Tools::getValue('inputAccessories')) {
         $post_accessories_tab = explode('-', $post_accessories);
         foreach ($post_accessories_tab as $accessory_id) {
             if (!$this->haveThisAccessory($accessory_id, $accessories) && ($accessory = Product::getAccessoryById($accessory_id))) {
                 $accessories[] = $accessory;
             }
         }
     }
     $this->tpl_form_vars['accessories'] = $accessories;
     /* image gallary */
     $this->tpl_form_vars['images'] = $images;
     $this->tpl_form_vars['image_uploader'] = $image_uploader->render();
     $this->tpl_form_vars['max_image_size'] = $this->max_image_size / 1024 / 1024;
     $this->tpl_form_vars['languages'] = $languages;
     $this->tpl_form_vars['iso_lang'] = $languages[0]['iso_code'];
     $this->tpl_form_vars['imageType'] = 'home-small';
     $this->tpl_form_vars['id_smart_blog_post'] = (int) Tools::getValue('id_smart_blog_post');
     $this->tpl_form_vars['default_language'] = (int) Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['table'] = $this->table;
     $this->tpl_form_vars['token'] = Tools::getAdminTokenLite('AdminBlogPost');
     $this->tpl_form_vars['gallary_path'] = _MODULE_DIR_ . 'smartblog/gallary/';
     // $this->tpl_form_vars['token_book'] = Tools::getAdminTokenLite('AdminBook');
     return parent::renderForm();
 }
 /**
  * renderForm contains all necessary initialization needed for all tabs
  *
  * @return void
  */
 public function renderForm()
 {
     // This nice code (irony) is here to store the product name, because the row after will erase product name in multishop context
     $this->product_name = $this->object->name[$this->context->language->id];
     if (!method_exists($this, 'initForm' . $this->tab_display)) {
         return;
     }
     $product = $this->object;
     // Product for multishop
     $this->context->smarty->assign('bullet_common_field', '');
     if (Shop::isFeatureActive() && $this->display == 'edit') {
         if (Shop::getContext() != Shop::CONTEXT_SHOP) {
             $this->context->smarty->assign(array('display_multishop_checkboxes' => true, 'multishop_check' => Tools::getValue('multishop_check')));
         }
         if (Shop::getContext() != Shop::CONTEXT_ALL) {
             $this->context->smarty->assign('bullet_common_field', '<img src="themes/' . $this->context->employee->bo_theme . '/img/bullet_orange.png" style="vertical-align: bottom" />');
             $this->context->smarty->assign('display_common_field', true);
         }
     }
     $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
     $this->tpl_form_vars['product_type'] = (int) Tools::getValue('type_product', $product->getType());
     $this->getLanguages();
     $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['currentIndex'] = self::$currentIndex;
     $this->tpl_form_vars['display_multishop_checkboxes'] = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit';
     $this->fields_form = array('');
     $this->tpl_form_vars['token'] = $this->token;
     $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST);
     $this->tpl_form_vars['save_error'] = !empty($this->errors);
     // autoload rich text editor (tiny mce)
     $this->tpl_form_vars['tinymce'] = true;
     $iso = $this->context->language->iso_code;
     $this->tpl_form_vars['iso'] = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     $this->tpl_form_vars['ad'] = dirname($_SERVER['PHP_SELF']);
     if (Validate::isLoadedObject($this->object)) {
         $id_product = (int) $this->object->id;
     } else {
         $id_product = (int) Tools::getvalue('id_product');
     }
     $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminProducts') . '&amp;' . ($id_product ? 'id_product=' . (int) $id_product : 'addproduct');
     $this->tpl_form_vars['id_product'] = $id_product;
     // Transform configuration option 'upload_max_filesize' in octets
     $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize'));
     // Transform configuration option 'upload_max_filesize' in MegaOctets
     $upload_max_filesize = $upload_max_filesize / 1024 / 1024;
     $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
     $this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
     $this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
     $this->product_exists_in_shop = true;
     if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) {
         $this->product_exists_in_shop = false;
         if ($this->tab_display == 'Informations') {
             $this->displayWarning($this->l('Warning: The product does not exist in this shop.'));
         }
         $default_product = new Product();
         $definition = ObjectModel::getDefinition($product);
         foreach ($definition['fields'] as $field_name => $field) {
             if (isset($field['shop']) && $field['shop']) {
                 $product->{$field_name} = ObjectModel::formatValue($default_product->{$field_name}, $field['type']);
             }
         }
     }
     // let's calculate this once for all
     if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
         $this->errors[] = 'Unable to load object';
     } else {
         $this->_displayDraftWarning($this->object->active);
         // if there was an error while saving, we don't want to lose posted data
         if (!empty($this->errors)) {
             $this->copyFromPost($this->object, $this->table);
         }
         $this->initPack($this->object);
         $this->{'initForm' . $this->tab_display}($this->object);
         $this->tpl_form_vars['product'] = $this->object;
         if ($this->ajax) {
             if (!isset($this->tpl_form_vars['custom_form'])) {
                 throw new PrestaShopException('custom_form empty for action ' . $this->tab_display);
             } else {
                 return $this->tpl_form_vars['custom_form'];
             }
         }
     }
     $parent = parent::renderForm();
     $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     return $parent;
 }
 public function renderForm()
 {
     $this->product_name = $this->object->name[$this->context->language->id];
     if (!method_exists($this, 'initForm' . $this->tab_display)) {
         return;
     }
     $product = $this->object;
     $this->context->smarty->assign('bullet_common_field', '');
     if (Shop::isFeatureActive() && $this->display == 'edit') {
         if (Shop::getContext() != Shop::CONTEXT_SHOP) {
             $this->context->smarty->assign(array('display_multishop_checkboxes' => true, 'multishop_check' => Tools::getValue('multishop_check')));
         }
         if (Shop::getContext() != Shop::CONTEXT_ALL) {
             $this->context->smarty->assign('bullet_common_field', '<i class="icon-circle text-orange"></i>');
             $this->context->smarty->assign('display_common_field', true);
         }
     }
     $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
     $this->tpl_form_vars['product_type'] = (int) Tools::getValue('type_product', $product->getType());
     $this->getLanguages();
     $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT');
     $this->tpl_form_vars['currentIndex'] = self::$currentIndex;
     $this->tpl_form_vars['display_multishop_checkboxes'] = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit';
     $this->fields_form = array('');
     $this->tpl_form_vars['token'] = $this->token;
     $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     $this->tpl_form_vars['post_data'] = json_encode($_POST);
     $this->tpl_form_vars['save_error'] = !empty($this->errors);
     $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive');
     $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security');
     $this->tpl_form_vars['ps_force_friendly_product'] = Configuration::get('PS_FORCE_FRIENDLY_PRODUCT');
     $this->tpl_form_vars['tinymce'] = true;
     $iso = $this->context->language->iso_code;
     $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_;
     $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_);
     if (Validate::isLoadedObject($this->object)) {
         $id_product = (int) $this->object->id;
     } else {
         $id_product = (int) Tools::getvalue('id_product');
     }
     $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminProducts') . '&' . ($id_product ? 'id_product=' . (int) $id_product : 'addproduct');
     $this->tpl_form_vars['id_product'] = $id_product;
     $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize'));
     $upload_max_filesize = $upload_max_filesize / 1024 / 1024;
     $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
     $this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
     $this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
     $this->product_exists_in_shop = true;
     if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) {
         $this->product_exists_in_shop = false;
         if ($this->tab_display == 'Informations') {
             $this->displayWarning($this->l('Warning: The product does not exist in this shop'));
         }
         $default_product = new Product();
         $definition = ObjectModel::getDefinition($product);
         foreach ($definition['fields'] as $field_name => $field) {
             if (isset($field['shop']) && $field['shop']) {
                 $product->{$field_name} = ObjectModel::formatValue($default_product->{$field_name}, $field['type']);
             }
         }
     }
     if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
         $this->errors[] = 'Unable to load object';
     } else {
         $this->_displayDraftWarning($this->object->active);
         if (!empty($this->errors)) {
             $this->copyFromPost($this->object, $this->table);
         }
         $this->initPack($this->object);
         $this->{'initForm' . $this->tab_display}($this->object);
         $this->tpl_form_vars['product'] = $this->object;
         if ($this->ajax) {
             if (!isset($this->tpl_form_vars['custom_form'])) {
                 throw new PrestaShopException('custom_form empty for action ' . $this->tab_display);
             } else {
                 return $this->tpl_form_vars['custom_form'];
             }
         }
     }
     $parent = parent::renderForm();
     $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     return $parent;
 }
Example #23
0
 public function smartblogrelatedproductHookdisplayProductTabContent($params)
 {
     $id_lang = $this->context->language->id;
     $posts = SmartBlogPost::getRelatedPostsByProduct($id_lang, Tools::getvalue('id_product'));
     $this->smarty->assign(array('posts' => $posts));
     return $this->display(__FILE__, 'views/templates/front/plugins/smart_product_tab_creator.tpl');
 }
Example #24
0
function _posts()
{
    $SmartBlogPost = new SmartBlogPost();
    $SmartBlog = new SmartBlog();
    $array_error = array();
    $id_lang = (int) Context::getContext()->language->id;
    $id_post = pSQL(Tools::getValue('id_post'));
    $post = $SmartBlogPost->getPost($id_post, $id_lang);
    $context = Context::getContext();
    if ($post['comment_status'] == 1) {
        $name = pSQL(Tools::getValue('name'));
        $comment = pSQL(Tools::getValue('comment'));
        $mail = pSQL(Tools::getValue('mail'));
        $captcha = pSQL(Tools::getvalue('smartblogcaptcha'));
        $m_captcha = $context->cookie->__get('ssmartblogcaptcha');
        if (Tools::getValue('website') == '') {
            $website = '#';
        } else {
            $website = pSQL(Tools::getValue('website'));
        }
        $id_parent_post = (int) pSQL(Tools::getValue('id_parent_post'));
        //'name'=>'Name between 2 - 25 characters !',
        if (empty($name)) {
            $array_error['name'] = $SmartBlog->nrl;
        }
        if (empty($comment)) {
            $array_error['comment'] = $SmartBlog->crl;
        }
        if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
            $array_error['mail'] = $SmartBlog->erl;
        }
        if (Configuration::get('smartcaptchaoption') == '1') {
            if ($captcha != $m_captcha) {
                $array_error['captcha'] = $SmartBlog->capl;
            }
        }
        if (is_array($array_error) && count($array_error)) {
            $array_error['common'] = $SmartBlog->warl;
            die(Tools::jsonEncode(array('error' => $array_error)));
        } else {
            $array_success = array();
            $comments = array();
            $comments['name'] = $name;
            $comments['mail'] = $mail;
            $comments['comment'] = $comment;
            $comments['website'] = $website;
            if (!($id_parent_post = Tools::getvalue('comment_parent'))) {
                $id_parent_post = 0;
            }
            $value = Configuration::get('smartacceptcomment');
            if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) {
                $value = Configuration::get('smartacceptcomment');
            } else {
                $value = 0;
            }
            $bc = new Blogcomment();
            $bc->id_post = (int) $id_post;
            $bc->name = $name;
            $bc->email = $mail;
            $bc->content = $comment;
            $bc->website = $website;
            $bc->id_parent = (int) $id_parent_post;
            $bc->active = (int) $value;
            $bc->created = Date('y-m-d H:i:s');
            if ($bc->add()) {
                $array_success['common'] = $SmartBlog->sucl;
                $array_success['success'] = $SmartBlog->sucl;
                Hook::exec('actionsbpostcomment', array('bc' => $bc));
                die(Tools::jsonEncode($array_success));
            }
        }
    }
}
 public function renderForm()
 {
     $img_desc = '';
     $img_desc .= $this->l('Upload a Feature Image from your computer.<br/>N.B : Only jpg image is allowed');
     if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) {
         $img_desc .= '<br/><img style="height:auto;width:300px;clear:both;border:1px solid black;" alt="" src="' . __PS_BASE_URI__ . 'modules/smartblog/images/' . Tools::getvalue('id_smart_blog_post') . '.jpg" /><br />';
     }
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $image = _MODULE_SMARTBLOG_DIR_ . $obj->id . '.jpg';
     $image_url = ImageManager::thumbnail($image, $this->table . '_' . Tools::getvalue('id_smart_blog_post') . '.jpg', 200, 'jpg', true, true);
     $image_size = file_exists($image) ? filesize($image) / 1000 : false;
     $this->fields_form = array('legend' => array('title' => $this->l('Blog Post')), 'input' => array(array('type' => 'hidden', 'name' => 'post_type', 'default_value' => 0), array('type' => 'text', 'label' => $this->l('Blog Title'), 'name' => 'meta_title', 'id' => 'name', 'class' => 'copyMeta2friendlyURL', 'size' => 60, 'required' => true, 'desc' => $this->l('Enter Your Blog Post Title'), 'lang' => true), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'content', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => true, 'hint' => array($this->l('Enter Your Post Description'), $this->l('Invalid characters:') . ' <>;=#{}')), array('type' => 'file', 'label' => $this->l('Feature Image:'), 'name' => 'image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . Tools::getvalue('id_smart_blog_post') . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'select', 'label' => $this->l('Blog Category'), 'name' => 'id_category', 'options' => array('query' => BlogCategory::getCategory(), 'id' => 'id_smart_blog_category', 'name' => 'meta_title'), 'desc' => $this->l('Select Your Parent Category')), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' &lt;&gt;;=#{}')), array('type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'short_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => true, 'hint' => array($this->l('Enter Your Post Short Description'))), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Post Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => $this->l('Only letters and the hyphen (-) character are allowed.')), array('type' => 'tags', 'label' => $this->l('Tag'), 'name' => 'tags', 'size' => 60, 'lang' => true, 'required' => false, 'hint' => array($this->l('To add "tags" click in the field, write something, and then press "Enter."'), $this->l('Invalid characters:') . ' &lt;&gt;;=#{}')), array('type' => 'radio', 'label' => $this->l('Comment Status'), 'name' => 'comment_status', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('You Can Enable or Disable Your Comments')), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Is Featured?'), 'name' => 'is_featured', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_featured', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'is_featured', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($SmartBlogPost = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
     $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg', $this->table . '_' . (int) $SmartBlogPost->id_smart_blog_post . '.' . $this->imageType, 350, $this->imageType, true);
     $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . $SmartBlogPost->id_smart_blog_post . '.jpg') / 1000 : false);
     if (Tools::getvalue('id_smart_blog_post') != '' && Tools::getvalue('id_smart_blog_post') != NULL) {
         foreach (Language::getLanguages(false) as $lang) {
             $this->fields_value['tags'][(int) $lang['id_lang']] = SmartBlogPost::getProductTagsBylang((int) Tools::getvalue('id_smart_blog_post'), (int) $lang['id_lang']);
         }
     }
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     return parent::renderForm();
 }
Example #26
0
 /**
  * Retrieve the controller from url or request uri if routes are activated
  *
  * @return string
  */
 public function getController($id_shop = null)
 {
     if (defined('_PS_ADMIN_DIR_')) {
         $_GET['controllerUri'] = Tools::getvalue('controller');
     }
     if ($this->controller) {
         $_GET['controller'] = $this->controller;
         return $this->controller;
     }
     if (isset(Context::getContext()->shop) && $id_shop === null) {
         $id_shop = (int) Context::getContext()->shop->id;
     }
     $controller = Tools::getValue('controller');
     if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\\?(.*)=(.*)$/Ui', $controller, $m)) {
         $controller = $m[1];
         if (isset($_GET['controller'])) {
             $_GET[$m[2]] = $m[3];
         } elseif (isset($_POST['controller'])) {
             $_POST[$m[2]] = $m[3];
         }
     }
     if (!Validate::isControllerName($controller)) {
         $controller = false;
     }
     // Use routes ? (for url rewriting)
     if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) {
         if (!$this->request_uri) {
             return strtolower($this->controller_not_found);
         }
         $controller = $this->controller_not_found;
         $test_request_uri = preg_replace('/(=http:\\/\\/)/', '=', $this->request_uri);
         // If the request_uri matches a static file, then there is no need to check the routes, we keep "controller_not_found" (a static file should not go through the dispatcher)
         if (!preg_match('/\\.(gif|jpe?g|png|css|js|ico)$/i', parse_url($test_request_uri, PHP_URL_PATH))) {
             // Add empty route as last route to prevent this greedy regexp to match request uri before right time
             if ($this->empty_route) {
                 $this->addRoute($this->empty_route['routeID'], $this->empty_route['rule'], $this->empty_route['controller'], Context::getContext()->language->id, array(), array(), $id_shop);
             }
             list($uri) = explode('?', $this->request_uri);
             if (isset($this->routes[$id_shop][Context::getContext()->language->id])) {
                 foreach ($this->routes[$id_shop][Context::getContext()->language->id] as $route) {
                     if (preg_match($route['regexp'], $uri, $m)) {
                         // Route found ! Now fill $_GET with parameters of uri
                         foreach ($m as $k => $v) {
                             if (!is_numeric($k)) {
                                 $_GET[$k] = $v;
                             }
                         }
                         $controller = $route['controller'] ? $route['controller'] : $_GET['controller'];
                         if (!empty($route['params'])) {
                             foreach ($route['params'] as $k => $v) {
                                 $_GET[$k] = $v;
                             }
                         }
                         // A patch for module friendly urls
                         if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9_]+)$#i', $controller, $m)) {
                             $_GET['module'] = $m[1];
                             $_GET['fc'] = 'module';
                             $controller = $m[2];
                         }
                         if (isset($_GET['fc']) && $_GET['fc'] == 'module') {
                             $this->front_controller = self::FC_MODULE;
                         }
                         break;
                     }
                 }
             }
         }
         if ($controller == 'index' || preg_match('/^\\/index.php(?:\\?.*)?$/', $this->request_uri)) {
             $controller = $this->useDefaultController();
         }
     }
     $this->controller = str_replace('-', '', $controller);
     $_GET['controller'] = $this->controller;
     return $this->controller;
 }
 public function postProcess()
 {
     global $cookie;
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
         return;
     }
     /* PrestaShop demo mode*/
     if (Tools::isSubmit('deleteemployee') or Tools::isSubmit('status') or Tools::isSubmit('statusemployee')) {
         if ($cookie->id_employee == Tools::getValue('id_employee')) {
             $this->_errors[] = Tools::displayError('You cannot disable or delete your own account.');
             return false;
         }
         $employee = new Employee(Tools::getValue('id_employee'));
         if ($employee->isLastAdmin()) {
             $this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
             return false;
         }
     } elseif (Tools::isSubmit('submitAddemployee')) {
         $employee = new Employee((int) Tools::getValue('id_employee'));
         if (!(int) $this->tabAccess['edit']) {
             $_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile;
         }
         if ($employee->isLastAdmin()) {
             if (Tools::getValue('id_profile') != (int) _PS_ADMIN_PROFILE_) {
                 $this->_errors[] = Tools::displayError('You should have at least one employee in the administrator group.');
                 return false;
             }
             if (Tools::getvalue('active') == 0) {
                 $this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
                 return false;
             }
         }
     }
     return parent::postProcess();
 }
Example #28
0
function _posts()
{
    $SmartBlogPost = new SmartBlogPost();
    $SmartBlog = new SmartBlog();
    $array_error = array();
    $context = $id_lang = (int) Context::getContext()->language->id;
    $id_post = Tools::getValue('id_post');
    $post = $SmartBlogPost->getPost($id_post, $id_lang);
    if ($post['comment_status'] == 1) {
        $blogcomment = new Blogcomment();
        $name = Tools::getValue('name');
        $comment = Tools::getValue('comment');
        $mail = Tools::getValue('mail');
        $captcha = Tools::getvalue('smartblogcaptcha');
        $m_captcha = $_SESSION['ssmartblogcaptcha'];
        if (Tools::getValue('website') == '') {
            $website = '#';
        } else {
            $website = Tools::getValue('website');
        }
        $id_parent_post = (int) Tools::getValue('id_parent_post');
        //'name'=>'Name between 2 - 25 characters !',
        if (empty($name)) {
            $array_error['name'] = $SmartBlog->l('Name is required');
        }
        if (empty($comment)) {
            $array_error['comment'] = $SmartBlog->l('Comment must be between 25 and 1500 characters!');
        }
        if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
            $array_error['mail'] = $SmartBlog->l('E-mail address not valid !');
        }
        if (Configuration::get('smartcaptchaoption') == '1') {
            if ($captcha != $m_captcha) {
                $array_error['captcha'] = $SmartBlog->l('Captcha is not valid');
            }
        }
        if (is_array($array_error) && count($array_error)) {
            $array_error['common'] = $SmartBlog->l('Warning: Please check required form bellow!');
            die(Tools::jsonEncode(array('error' => $array_error)));
        } else {
            $array_success = array();
            $comments['name'] = $name;
            $comments['mail'] = $mail;
            $comments['comment'] = $comment;
            $comments['website'] = $website;
            if (!($id_parent_post = Tools::getvalue('comment_parent'))) {
                $id_parent_post = 0;
            }
            $value = Configuration::get('smartacceptcomment');
            if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) {
                $value = Configuration::get('smartacceptcomment');
            } else {
                $value = 0;
            }
            $bc = new Blogcomment();
            $bc->id_post = (int) $id_post;
            $bc->name = $name;
            $bc->email = $mail;
            $bc->content = $comment;
            $bc->website = $website;
            $bc->id_parent = (int) $id_parent_post;
            $bc->active = (int) $value;
            $bc->created = Date('y-m-d H:i:s');
            if ($bc->add()) {
                $array_success['common'] = $SmartBlog->l('Your comment successfully submitted.');
                $array_success['success'] = $SmartBlog->l('Your comment successfully submitted');
                Hook::exec('actionsbpostcomment', array('bc' => $bc));
                die(Tools::jsonEncode($array_success));
            }
        }
    }
}
Example #29
0
 private function _postProcess()
 {
     if ($this->_postValidation() == false) {
         return false;
     }
     $this->_errors = array();
     if (Tools::isSubmit('submitBlockCMS')) {
         $this->context->controller->getLanguages();
         $id_cms_category = (int) Tools::getvalue('id_category');
         $display_store = (int) Tools::getValue('display_stores');
         $location = (int) Tools::getvalue('block_location');
         $position = BlockCMSModel::getMaxPosition($location);
         if (Tools::isSubmit('addBlockCMS')) {
             $id_cms_block = BlockCMSModel::insertCMSBlock($id_cms_category, $location, $position, $display_store);
             if ($id_cms_block !== false) {
                 foreach ($this->context->controller->_languages as $language) {
                     BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
                 }
                 $shops = Shop::getContextListShopID();
                 foreach ($shops as $shop) {
                     BlockCMSModel::insertCMSBlockShop($id_cms_block, $shop);
                 }
             }
             $this->_errors[] = $this->l('New block cannot be created!');
         } elseif (Tools::isSubmit('editBlockCMS')) {
             $id_cms_block = Tools::getvalue('id_cms_block');
             $old_block = BlockCMSModel::getBlockCMS($id_cms_block);
             BlockCMSModel::deleteCMSBlockPage($id_cms_block);
             if ($old_block[1]['location'] != (int) Tools::getvalue('block_location')) {
                 BlockCMSModel::updatePositions($old_block[1]['position'], $old_block[1]['position'] + 1, $old_block[1]['location']);
             }
             BlockCMSModel::updateCMSBlock($id_cms_block, $id_cms_category, $position, $location, $display_store);
             foreach ($this->context->controller->_languages as $language) {
                 $block_name = Tools::getValue('block_name_' . $language['id_lang']);
                 BlockCMSModel::updateCMSBlockLang($id_cms_block, $block_name, $language['id_lang']);
             }
         }
         $cmsBoxes = Tools::getValue('cmsBox');
         if ($cmsBoxes) {
             foreach ($cmsBoxes as $cmsBox) {
                 $cms_properties = explode('_', $cmsBox);
                 BlockCMSModel::insertCMSBlockPage($id_cms_block, $cms_properties[1], $cms_properties[0]);
             }
         }
         if (Tools::isSubmit('addBlockCMS')) {
             $redirect = 'addBlockCMSConfirmation';
         } elseif (Tools::isSubmit('editBlockCMS')) {
             $redirect = 'editBlockCMSConfirmation';
         }
         Tools::redirectAdmin(AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&' . $redirect);
     } elseif (Tools::isSubmit('deleteBlockCMS') && Tools::getValue('id_cms_block')) {
         $id_cms_block = Tools::getvalue('id_cms_block');
         if ($id_cms_block) {
             BlockCMSModel::deleteCMSBlock((int) $id_cms_block);
             BlockCMSModel::deleteCMSBlockPage((int) $id_cms_block);
             Tools::redirectAdmin(AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&deleteBlockCMSConfirmation');
         } else {
             $this->_html .= $this->displayError($this->l('Error: you are trying to delete a non-existent block cms'));
         }
     } elseif (Tools::isSubmit('submitFooterCMS')) {
         $powered_by = Tools::getValue('cms_footer_powered_by_on') ? 1 : 0;
         $footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : '';
         $block_activation = Tools::getValue('cms_footer_on') == 1 ? 1 : 0;
         Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'));
         Configuration::updateValue('FOOTER_POWEREDBY', $powered_by);
         Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation);
         $this->_html .= $this->displayConfirmation($this->l('Footer\'s information updated'));
     } elseif (Tools::isSubmit('addBlockCMSConfirmation')) {
         $this->_html .= $this->displayConfirmation($this->l('Block CMS added'));
     } elseif (Tools::isSubmit('editBlockCMSConfirmation')) {
         $this->_html .= $this->displayConfirmation($this->l('Block CMS edited'));
     } elseif (Tools::isSubmit('deleteBlockCMSConfirmation')) {
         $this->_html .= $this->displayConfirmation($this->l('Deletion successful'));
     } elseif (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location')) {
         $this->changePosition();
     } elseif (Tools::isSubmit('updatePositions')) {
         $this->updatePositionsDnd();
     }
     if (count($this->_errors)) {
         foreach ($this->_errors as $err) {
             $this->_html .= '<div class="alert error">' . $err . '</div>';
         }
     }
 }
 public function validateRules($class_name = false)
 {
     $employee = new Employee((int) Tools::getValue('id_employee'));
     if (!Validate::isLoadedObject($employee) && !Validate::isPasswd(Tools::getvalue('passwd'), Validate::ADMIN_PASSWORD_LENGTH)) {
         return !($this->errors[] = sprintf(Tools::displayError('The password must be at least %s characters long.'), Validate::ADMIN_PASSWORD_LENGTH));
     }
     return parent::validateRules($class_name);
 }