* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7541 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminAccess extends AdminTab { public function postProcess() { if (Tools::isSubmit('submitAddaccess') AND $action = Tools::getValue('action') AND $id_tab = (int)(Tools::getValue('id_tab')) AND $id_profile = (int)(Tools::getValue('id_profile')) AND $this->tabAccess['edit'] == 1) { if ($id_tab == -1 AND $action == 'all' AND (int)(Tools::getValue('perm')) == 0) Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile).' AND `id_tab` != 31'); elseif ($id_tab == -1 AND $action == 'all') Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile)); elseif ($id_tab == -1) Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `'.pSQL($action).'` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile)); elseif ($action == 'all') Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_tab` = '.(int)($id_tab).' AND `id_profile` = '.(int)($id_profile)); else Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `'.pSQL($action).'` = '.(int)(Tools::getValue('perm')).' WHERE `id_tab` = '.(int)($id_tab).' AND `id_profile` = '.(int)($id_profile)); } } public function display() { $this->displayForm(); } /** * Get the current profile id * * @return the $_GET['profile'] if valid, else 1 (the first profile id) */ function getCurrentProfileId() { return (isset($_GET['profile']) AND !empty($_GET['profile']) AND is_numeric($_GET['profile'])) ? (int)($_GET['profile']) : 1; } public function displayForm($isMainTab = true) { global $cookie, $currentIndex; parent::displayForm(); $currentProfile = (int)($this->getCurrentProfileId()); $tabs = Tab::getTabs($cookie->id_lang); $profiles = Profile::getProfiles((int)($cookie->id_lang)); $accesses = Profile::getProfileAccesses((int)($currentProfile)); echo '
'; if ($currentProfile != (int)(_PS_ADMIN_PROFILE_)) echo ' | '.$this->l('View').' |
'.$this->l('Add').' |
'.$this->l('Edit').' |
'.$this->l('Delete').' |
'.$this->l('All').' |
---|---|---|---|---|---|
'.$this->l('No tab').' | |||||
'.$this->l('Administrator permissions can\'t be modified.').' |