本文整理汇总了PHP中Tools::getvalue方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::getvalue方法的具体用法?PHP Tools::getvalue怎么用?PHP Tools::getvalue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::getvalue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
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();
}
示例2: 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();
}
示例3: 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')));
}
}
示例4: init
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();
}
}
示例5: _posts
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);
}
}
}
}
}
示例6: init
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();
}
}
示例7: getContent
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>';
}
示例8: getContent
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;
}
}
示例9: initProcess
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;
}
}
示例10: renderForm
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();
}
示例11: getContent
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');
}
示例12: initContent
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);
}
示例13: getContent
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');
}
示例14: priceInput
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>';
}
示例15: postProcess
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();
}