public static function getProfileAccesses($id_profile, $type = 'id_tab') { if (!in_array($type, array('id_tab', 'class_name'))) { return false; } if (!isset(self::$_cache_accesses[$id_profile])) { self::$_cache_accesses[$id_profile] = array(); } if (!isset(self::$_cache_accesses[$id_profile][$type])) { self::$_cache_accesses[$id_profile][$type] = array(); // Super admin profile has full auth if ($id_profile == _PS_ADMIN_PROFILE_) { foreach (Tab::getTabs(Context::getContext()->language->id) as $tab) { self::$_cache_accesses[$id_profile][$type][$tab[$type]] = array('id_profile' => _PS_ADMIN_PROFILE_, 'id_tab' => $tab['id_tab'], 'class_name' => $tab['class_name'], 'view' => '1', 'add' => '1', 'edit' => '1', 'delete' => '1'); } } else { $result = Db::getInstance()->executeS(' SELECT * FROM `' . _DB_PREFIX_ . 'access` a LEFT JOIN `' . _DB_PREFIX_ . 'tab` t ON t.id_tab = a.id_tab WHERE `id_profile` = ' . (int) $id_profile); foreach ($result as $row) { self::$_cache_accesses[$id_profile][$type][$row[$type]] = $row; } } } return self::$_cache_accesses[$id_profile][$type]; }
/** * AdminController::renderForm() override * @see AdminController::renderForm() */ public function renderForm() { $current_profile = (int) $this->getCurrentProfileId(); $profiles = Profile::getProfiles($this->context->language->id); $tabs = Tab::getTabs($this->context->language->id); $accesses = array(); foreach ($profiles as $profile) { $accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']); } // Deleted id_tab that do not have access foreach ($tabs as $key => $tab) { // Don't allow permissions for unnamed tabs (ie. AdminLogin) if (empty($tab['name'])) { unset($tabs[$key]); } foreach ($this->accesses_black_list as $id_tab) { if ($tab['id_tab'] == (int) $id_tab) { unset($tabs[$key]); } } } $modules = array(); foreach ($profiles as $profile) { $modules[$profile['id_profile']] = Module::getModulesAccessesByIdProfile($profile['id_profile']); uasort($modules[$profile['id_profile']], array($this, 'sortModuleByName')); } $this->fields_form = array(''); $this->tpl_form_vars = array('profiles' => $profiles, 'accesses' => $accesses, 'id_tab_parentmodule' => (int) Tab::getIdFromClassName('AdminParentModules'), 'id_tab_module' => (int) Tab::getIdFromClassName('AdminModules'), 'tabs' => $this->displayTabs($tabs), 'current_profile' => (int) $current_profile, 'admin_profile' => (int) _PS_ADMIN_PROFILE_, 'access_edit' => $this->access('edit'), 'perms' => array('view', 'add', 'edit', 'delete'), 'modules' => $modules, 'link' => $this->context->link); return parent::renderForm(); }
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 ' <script type="text/javascript"> setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Update in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\')); </script> <div id="ajax_confirmation"></div> <table class="table" cellspacing="0"> <tr> <th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '> <select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">'; if ($profiles) { foreach ($profiles as $profile) { echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>'; } } $tabsize = sizeof($tabs); foreach ($tabs as $tab) { if ($tab['id_tab'] > $tabsize) { $tabsize = $tab['id_tab']; } } echo ' </select> </th>'; if ($currentProfile != (int) _PS_ADMIN_PROFILE_) { echo ' <th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" onclick="ajax_power(this, \'view\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th> <th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" onclick="ajax_power(this, \'add\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th> <th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" onclick="ajax_power(this, \'edit\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th> <th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" onclick="ajax_power(this, \'delete\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th> <th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" onclick="ajax_power(this, \'all\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th> </tr>'; } if (!sizeof($tabs)) { echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>'; } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) { echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>'; } else { foreach ($tabs as $tab) { if (!$tab['id_parent'] or (int) $tab['id_parent'] == -1) { $this->printTabAccess((int) $currentProfile, $tab, $accesses[$tab['id_tab']], false, $tabsize, sizeof($tabs)); foreach ($tabs as $child) { if ($child['id_parent'] === $tab['id_tab']) { if (isset($accesses[$child['id_tab']])) { $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true, $tabsize, sizeof($tabs)); } } } } } } echo '</table>'; }
public function __construct() { $this->table = 'employee'; $this->className = 'Employee'; $this->lang = false; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->context = Context::getContext(); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); /* check if there are more than one superAdmin if it's the case then we can delete a superAdmin */ $super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true); if ($super_admin == 1) { $super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true); $super_admin_id = array(); foreach ($super_admin_array as $key => $val) { $super_admin_id[] = $val['id_employee']; } $this->addRowActionSkipList('delete', $super_admin_id); } $profiles = Profile::getProfiles($this->context->language->id); if (!$profiles) { $this->errors[] = Tools::displayError('No profile'); } else { foreach ($profiles as $profile) { $this->profiles_array[$profile['name']] = $profile['name']; } } $this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'lastname' => array('title' => $this->l('Last name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'width' => 130), 'email' => array('title' => $this->l('E-mail address'), 'width' => 180), 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'), 'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 30)); $this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'desc' => $this->l('Security: minimum time to wait between two password changes'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize language used in Admin panel forms'), 'desc' => $this->l('Allow employees to select a specific language for Admin panel forms'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array())); $path = _PS_ADMIN_DIR_ . '/themes/'; foreach (scandir($path) as $theme) { if ($theme[0] != '.' && is_dir($path . $theme) && file_exists($path . $theme . '/css/admin.css')) { $this->themes[] = $theme; } } $home_tab = Tab::getInstanceFromClassName('adminHome'); $this->tabs_list[$home_tab->id] = array('name' => $home_tab->name[$this->context->language->id], 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name[$this->context->language->id]))); foreach (Tab::getTabs($this->context->language->id, 0) as $tab) { if (Tab::checkTabRights($tab['id_tab'])) { $this->tabs_list[$tab['id_tab']] = $tab; foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) { if (Tab::checkTabRights($children['id_tab'])) { $this->tabs_list[$tab['id_tab']]['children'][] = $children; } } } } parent::__construct(); // An employee can edit its own profile if ($this->context->employee->id == Tools::getValue('id_employee')) { $this->tabAccess['view'] = '1'; if (!$this->tabAccess['edit']) { $this->restrict_edition = true; } $this->tabAccess['edit'] = '1'; } }
private function _displayForm() { global $cookie, $smarty; $tabsInfo = Tab::getTabs($cookie->id_lang, 0); $smarty->assign(array('tabsInfo'=>$tabsInfo, 'selectedTab'=>Configuration::get('NSletter_id_parent_tab'))); return $this->display(__FILE__, 'adminform.tpl'); }
public function displayForm($isMainTab = true) { global $cookie, $currentIndex; parent::displayForm(); $currentProfile = (int) Tools::getValue('id_profile'); if (!$currentProfile) { $currentProfile = 1; } $tabs = Tab::getTabs((int) $cookie->id_lang); $profiles = Profile::getProfiles((int) $cookie->id_lang); $permissions = Profile::getProfileAccesses((int) $currentProfile); echo ' <form action="' . $currentIndex . '&submitAddPermissions=1&token=' . $this->token . '" id="form_permissions" method="post"> <input type="hidden" name="id_profile" value="' . (int) $currentProfile . '" /> <table class="table" cellspacing="0"> <tr> <th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '>' . $this->l('Profile') . ' <select name="id_profile" onchange="window.location = \'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&id_profile=\'+this.options[this.selectedIndex].value;">'; if ($profiles) { foreach ($profiles as $profile) { echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . Tools::safeOutput($profile['name']) . '</option>'; } } echo ' </select> </th>'; if ($currentProfile != (int) _PS_ADMIN_PROFILE_) { echo ' <th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" /></th> <th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" /></th> <th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" /></th> <th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" /></th> <th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" /></th> </tr>'; } if (!count($tabs)) { echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>'; } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) { echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>'; } else { foreach ($tabs as $tab) { if (!$tab['id_parent'] || (int) $tab['id_parent'] == -1) { echo $this->printTabAccess((int) $currentProfile, $tab, isset($permissions[(int) $tab['id_tab']]) ? $permissions[(int) $tab['id_tab']] : 0, false); foreach ($tabs as $child) { if ($child['id_parent'] === $tab['id_tab']) { echo $this->printTabAccess($currentProfile, $child, isset($permissions[(int) $child['id_tab']]) ? $permissions[(int) $child['id_tab']] : 0, true); } } } } } echo '</table> <p><input type="submit" value="' . $this->l(' Save ') . '" name="submitAddPermissions" class="button" /></p> </form> <script type="text/javascript">managePermissions();</script>'; }
public function displayForm($isMainTab = true) { global $cookie, $currentIndex; parent::displayForm(); $currentProfile = intval($this->getCurrentProfileId()); $tabs = Tab::getTabs($cookie->id_lang); $profiles = Profile::getProfiles(intval($cookie->id_lang)); $accesses = Profile::getProfileAccesses(intval($currentProfile)); echo ' <script type="text/javascript"> setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Updating in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\')); </script> <div id="ajax_confirmation"></div> <table class="table" cellspacing="0"> <tr> <th> <select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">'; if ($profiles) { foreach ($profiles as $profile) { echo '<option value="' . intval($profile['id_profile']) . '" ' . (intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>'; } } echo ' </select> </th> <th>' . $this->l('View') . '</th> <th>' . $this->l('Add') . '</th> <th>' . $this->l('Edit') . '</th> <th>' . $this->l('Delete') . '</th> </tr>'; if (!sizeof($tabs)) { echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>'; } else { if ($currentProfile == intval(_PS_ADMIN_PROFILE_)) { echo '<tr><td colspan="5">' . $this->l('Administrator permissions can\'t be modified.') . '</td></tr>'; } else { foreach ($tabs as $tab) { if (!$tab['id_parent'] or intval($tab['id_parent']) == -1) { $this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false); foreach ($tabs as $child) { if ($child['id_parent'] === $tab['id_tab']) { $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true); } } } } } } echo '</table>'; }
/** * AdminController::renderForm() override * @see AdminController::renderForm() */ public function renderForm() { $current_profile = (int) $this->getCurrentProfileId(); $profiles = Profile::getProfiles($this->context->language->id); $tabs = Tab::getTabs($this->context->language->id); $accesses = array(); foreach ($profiles as $profile) { $accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']); } // Deleted id_tab that do not have access foreach ($tabs as $key => $tab) { // Don't allow permissions for unnamed tabs (ie. AdminLogin) if (empty($tab['name'])) { unset($tabs[$key]); } foreach ($this->accesses_black_list as $id_tab) { if ($tab['id_tab'] == (int) $id_tab) { unset($tabs[$key]); } } } $modules = array(); foreach ($profiles as $profile) { $modules[$profile['id_profile']] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT ma.`id_module`, m.`name`, ma.`view`, ma.`configure`, ma.`uninstall` FROM ' . _DB_PREFIX_ . 'module_access ma LEFT JOIN ' . _DB_PREFIX_ . 'module m ON ma.id_module = m.id_module WHERE id_profile = ' . (int) $profile['id_profile'] . ' ORDER BY m.name '); foreach ($modules[$profile['id_profile']] as $k => &$module) { $m = Module::getInstanceById($module['id_module']); // the following condition handles invalid modules if ($m) { $module['name'] = $m->displayName; } else { unset($modules[$profile['id_profile']][$k]); } } uasort($modules[$profile['id_profile']], array($this, 'sortModuleByName')); } $this->fields_form = array(''); $this->tpl_form_vars = array('profiles' => $profiles, 'accesses' => $accesses, 'id_tab_parentmodule' => (int) Tab::getIdFromClassName('AdminParentModules'), 'id_tab_module' => (int) Tab::getIdFromClassName('AdminModules'), 'tabs' => $tabs, 'current_profile' => (int) $current_profile, 'admin_profile' => (int) _PS_ADMIN_PROFILE_, 'access_edit' => $this->tabAccess['edit'], 'perms' => array('view', 'add', 'edit', 'delete'), 'modules' => $modules, 'link' => $this->context->link); return parent::renderForm(); }
/** * AdminController::renderForm() override * @see AdminController::renderForm() */ public function renderForm() { $tabs = Tab::getTabs($this->context->language->id, 0); // If editing, we clean itself if (Tools::isSubmit('id_tab')) { foreach ($tabs as $key => $tab) { if ($tab['id_tab'] == Tools::getValue('id_tab')) { unset($tabs[$key]); } } } // added category "Home" in var $tabs $tab_zero = array('id_tab' => 0, 'name' => $this->l('Home')); array_unshift($tabs, $tab_zero); $this->fields_form = array('legend' => array('title' => $this->l('Menus'), 'image' => '../img/admin/tab.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'position', 'required' => false), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'lang' => true, 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Class:'), 'name' => 'class_name', 'required' => true), array('type' => 'text', 'label' => $this->l('Module:'), 'name' => 'module'), array('type' => 'file', 'label' => $this->l('Icon:'), 'name' => 'icon', 'desc' => $this->l('Upload logo from your computer (.gif, .jpg, .jpeg or .png).')), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', '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('Show or hide menu.')), array('type' => 'select', 'label' => $this->l('Parent:'), 'name' => 'id_parent', 'options' => array('query' => $tabs, 'id' => 'id_tab', 'name' => 'name'))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button')); return parent::renderForm(); }
function displayForm() { global $cookie, $currentIndex; $currentProfile = intval($this->getCurrentProfileId()); $tabs = Tab::getTabs($cookie->id_lang); $profiles = Profile::getProfiles(intval($cookie->id_lang)); $accesses = Profile::getProfileAccesses(intval($currentProfile)); echo ' <script type="text/javascript"> setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Updating in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\')); </script> <div id="ajax_confirmation"></div> <table class="table" cellspacing="0"> <tr> <th> <select name="profile" onchange="redirect(\'' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">'; if ($profiles) { foreach ($profiles as $profile) { echo '<option value="' . intval($profile['id_profile']) . '" ' . (intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>'; } } echo ' </select> </th> <th>' . $this->l('View') . '</th> <th>' . $this->l('Add') . '</th> <th>' . $this->l('Edit') . '</th> <th>' . $this->l('Delete') . '</th> </tr>'; if (!sizeof($tabs)) { echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>'; } else { foreach ($tabs as $tab) { if (!$tab['id_parent'] or intval($tab['id_parent']) == -1) { $this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false); foreach ($tabs as $child) { if ($child['id_parent'] === $tab['id_tab']) { $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true); } } } } } echo '</table>'; }
/** * AdminController::renderForm() override * @see AdminController::renderForm() */ public function renderForm() { $tabs = Tab::getTabs($this->context->language->id, 0); // If editing, we clean itself if (Tools::isSubmit('id_tab')) { foreach ($tabs as $key => $tab) { if ($tab['id_tab'] == Tools::getValue('id_tab')) { unset($tabs[$key]); } } } // added category "Home" in var $tabs $tab_zero = array('id_tab' => 0, 'name' => $this->l('Home')); array_unshift($tabs, $tab_zero); $this->fields_form = array('legend' => array('title' => $this->l('Menus'), 'icon' => 'icon-list-ul'), 'input' => array(array('type' => 'hidden', 'name' => 'position', 'required' => false), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'lang' => true, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Class'), 'name' => 'class_name', 'required' => true), array('type' => 'text', 'label' => $this->l('Module'), 'name' => 'module'), 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'))), 'hint' => $this->l('Show or hide menu.'))), 'submit' => array('title' => $this->l('Save'))); $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Parent'), 'name' => 'id_parent', 'options' => array('query' => $tabs, 'id' => 'id_tab', 'name' => 'name')); return parent::renderForm(); }
public static function init_profile_prmission_for_existing_tabs($id_profile, $view, $edit, $add, $delete) { global $cookie; ${${"GLOBALS"}["jjeyroellcp"]} = Tab::getTabs($cookie->id_lang); foreach (${${"GLOBALS"}["jjeyroellcp"]} as ${${"GLOBALS"}["numudxywby"]}) { $vucwgcmltbn = "id_profile"; ${"GLOBALS"}["otdfkstqedr"] = "delete"; ${"GLOBALS"}["mckxexvh"] = "add"; $eukriss = "tab"; self::update_access(${$vucwgcmltbn}, ${$eukriss}["class_name"], ${${"GLOBALS"}["qrwijdgnot"]}, ${${"GLOBALS"}["xkqtghm"]}, ${${"GLOBALS"}["mckxexvh"]}, ${${"GLOBALS"}["otdfkstqedr"]}); } }
public static function init_profile_prmission_for_existing_tabs($id_profile, $view, $edit, $add, $delete) { global $cookie; ${${"GLOBALS"}["ileecwgymir"]} = Tab::getTabs($cookie->id_lang); foreach (${${"GLOBALS"}["ileecwgymir"]} as ${${"GLOBALS"}["bkvochxb"]}) { ${"GLOBALS"}["cjjttgqkg"] = "edit"; self::update_access(${${"GLOBALS"}["acxljbmxxa"]}, ${${"GLOBALS"}["bkvochxb"]}["class_name"], ${${"GLOBALS"}["nrovpyoqoln"]}, ${${"GLOBALS"}["cjjttgqkg"]}, ${${"GLOBALS"}["ixwisvsx"]}, ${${"GLOBALS"}["xqoudczlgu"]}); } }
public function exportTabs() { // Get name tabs by iso code $tabs = Tab::getTabs($this->lang_selected->id); // Get name of the default tabs $tabs_default_lang = Tab::getTabs(1); $tabs_default = array(); foreach ($tabs_default_lang as $tab) { $tabs_default[$tab['class_name']] = pSQL($tab['name']); } // Create content $content = "<?php\n\n\$tabs = array();"; if (!empty($tabs)) { foreach ($tabs as $tab) { if ($tabs_default[$tab['class_name']] != pSQL($tab['name'])) { $content .= "\n\$tabs['" . $tab['class_name'] . "'] = '" . pSQL($tab['name']) . "';"; } } } $content .= "\n\nreturn \$tabs;"; $dir = _PS_TRANSLATIONS_DIR_ . $this->lang_selected->iso_code . DIRECTORY_SEPARATOR; $path = $dir . 'tabs.php'; // Check if tabs.php exists for the selected Iso Code if (!Tools::file_exists_cache($dir)) { if (!mkdir($dir, 0777, true)) { throw new PrestaShopException('The file ' . $dir . ' cannot be created.'); } } if (!file_put_contents($path, $content)) { throw new PrestaShopException('File "' . $path . '" doesn\'t exists and cannot be created in ' . $dir); } if (!is_writable($path)) { $this->displayWarning(sprintf(Tools::displayError('This file must be writable: %s'), $path)); } }
public static function init_profile_prmission_for_existing_tabs($id_profile, $view, $edit, $add, $delete) { ${"GLOBALS"}["zfpphwaefnn"] = "tab"; global $cookie; $dmtlvwskh = "tabs"; ${$dmtlvwskh} = Tab::getTabs($cookie->id_lang); foreach (${${"GLOBALS"}["iwnjexy"]} as ${${"GLOBALS"}["zfpphwaefnn"]}) { ${"GLOBALS"}["yydhsdm"] = "id_profile"; ${"GLOBALS"}["twguiumgcr"] = "delete"; self::update_access(${${"GLOBALS"}["yydhsdm"]}, ${${"GLOBALS"}["yvcsprqq"]}["class_name"], ${${"GLOBALS"}["fciyknoqlv"]}, ${${"GLOBALS"}["ifqjdxpgs"]}, ${${"GLOBALS"}["piauhnij"]}, ${${"GLOBALS"}["twguiumgcr"]}); } }
public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); if (!($obj = $this->loadObject(true))) { return; } echo ' <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data"> ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . (int) $obj->id . '" />' : '') . ' ' . ($obj->position ? '<input type="hidden" name="position" value="' . (int) $obj->position . '" />' : '') . ' <fieldset><legend><img src="../img/admin/tab.gif" />' . $this->l('Tabs') . '</legend> <label>' . $this->l('Name:') . ' </label> <div class="margin-form">'; foreach ($this->_languages as $language) { echo ' <div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); echo ' </div> <div class="clear"> </div> <label>' . $this->l('Class:') . ' </label> <div class="margin-form"> <input type="text" name="class_name" value="' . htmlentities($this->getFieldValue($obj, 'class_name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup> </div> <div class="clear"> </div> <label>' . $this->l('Module:') . ' </label> <div class="margin-form"> <input type="text" name="module" value="' . htmlentities($this->getFieldValue($obj, 'module'), ENT_COMPAT, 'UTF-8') . '" /> </div> <div class="clear"> </div> <label>' . $this->l('Icon') . '</label> <div class="margin-form"> ' . ($obj->id ? '<img src="../img/t/' . $obj->class_name . '.gif" /> /img/t/' . $obj->class_name . '.gif' : '') . ' <p><input type="file" name="icon" /></p> <p>' . $this->l('Upload logo from your computer') . ' (.gif, .jpg, .jpeg ' . $this->l('or') . ' .png)</p> </div> <div class="clear"> </div> <label>' . $this->l('Parent') . '</label> <div class="margin-form"> <select name="id_parent"> <option value="-1" ' . ($this->getFieldValue($obj, 'id_parent') == -1 ? 'selected="selected"' : '') . '>' . $this->l('None') . '</option> <option value="0" ' . ($this->getFieldValue($obj, 'id_parent') == 0 ? 'selected="selected"' : '') . '>' . $this->l('Home') . '</option>'; foreach (Tab::getTabs((int) $cookie->id_lang, 0) as $tab) { echo ' <option value="' . $tab['id_tab'] . '" ' . ($tab['id_tab'] == $this->getFieldValue($obj, 'id_parent') ? 'selected="selected"' : '') . '>' . $tab['name'] . '</option>'; } echo ' </select> </div> <div class="clear"> </div> <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form>'; }
echo ' <li' . (($t['class_name'] == $tab or $id_parent_tab_current == $t['id_tab']) ? ' class="active"' : '') . '> <a href="index.php?tab=' . $t['class_name'] . '&token=' . Tools::getAdminToken($t['class_name'] . intval($t['id_tab']) . intval($cookie->id_employee)) . '"><img src="' . $img . '" alt="" style="width:16px;height:16px" /> ' . $t['name'] . '</a> </li>'; } } ?> </ul> <div id="main"> <ul id="submenu"> <?php global $cookie; /* Display tabs belonging to opened tab */ $id_parent = isset($id_parent) ? $id_parent : $id_parent_tab_current; if (isset($id_parent) and $id_parent != -1) { $subTabs = Tab::getTabs(intval($cookie->id_lang), intval($id_parent)); foreach ($subTabs as $t) { if (checkTabRights($t['id_tab']) === true) { $img = '../img/t/' . $t['class_name'] . '.gif'; if (trim($t['module']) != '') { $img = _MODULE_DIR_ . $t['module'] . '/' . $t['class_name'] . '.gif'; } echo ' <li> <a href="index.php?tab=' . $t['class_name'] . '&token=' . Tools::getAdminToken($t['class_name'] . intval($t['id_tab']) . intval($cookie->id_employee)) . '"><img src="' . $img . '" alt="" style="width:16px;height:16px" /></a> <a href="index.php?tab=' . $t['class_name'] . '&token=' . Tools::getAdminToken($t['class_name'] . intval($t['id_tab']) . intval($cookie->id_employee)) . '">' . $t['name'] . '</a> </li>'; } } } ?> </ul>
$echoLis = ''; $mainsubtablist = ''; foreach ($tabs as $t) { if (checkTabRights($t['id_tab']) === true) { $img = (Tools::file_exists_cache(($path_name = _PS_ADMIN_DIR_ . '/themes/' . $employee->bo_theme . '/img/t/') . $t['class_name'] . '.gif') ? 'themes/' . $employee->bo_theme . '/img/' : _PS_IMG_ . '/') . 't/' . $t['class_name'] . '.gif'; if (trim($t['module']) != '') { $img = _MODULE_DIR_ . $t['module'] . '/' . $t['class_name'] . '.gif'; } $current = ($t['class_name'] == $tab or $id_parent_tab_current == $t['id_tab']); echo '<li class="submenu_size ' . ($current ? 'active' : '') . '" id="maintab' . $t['id_tab'] . '"> <a href="index.php?tab=' . $t['class_name'] . '&token=' . Tools::getAdminToken($t['class_name'] . (int) $t['id_tab'] . (int) $cookie->id_employee) . '"> <img src="' . $img . '" alt="" /> ' . $t['name'] . ' </a> </li>'; $echoLi = ''; $subTabs = Tab::getTabs((int) $cookie->id_lang, (int) $t['id_tab']); foreach ($subTabs as $t2) { if (checkTabRights($t2['id_tab']) === true) { $echoLi .= '<li><a href="index.php?tab=' . $t2['class_name'] . '&token=' . Tools::getAdminTokenLite($t2['class_name']) . '">' . $t2['name'] . '</a></li>'; } } if ($current) { $mainsubtablist = $echoLi; } $echoLis .= '<div id="tab' . (int) $t['id_tab'] . '_subtabs" style="display:none">' . $echoLi . '</div>'; } } echo ' </ul>' . $echoLis; if ($employee->bo_uimode == 'hover') { echo ' <script type="text/javascript"> $("#menu li").hoverIntent({over:hoverTabs,timeout:100,out:outTabs});
public function exportTabs() { // Get name tabs by iso code $tabs = Tab::getTabs($this->lang_selected->id); // Get name of the default tabs $tabs_default_lang = Tab::getTabs(1); $tabs_default = array(); foreach ($tabs_default_lang as $tab) { $tabs_default[$tab['class_name']] = pSQL($tab['name']); } // Create content $content = "<?php\n\n\$tabs = array();"; if (!empty($tabs)) { foreach ($tabs as $tab) { /** * We don't export tab translations that are identical to the default * tab translations to avoid a problem that would occur in the followin scenario: * * 1) install PrestaShop in, say, Spanish => tabs are by default in Spanish * 2) create a new language, say, Klingon => tabs are populated using the default, Spanish, tabs * 3) export the Klingon language pack * * => Since you have not yet translated the tabs into Klingon, * without the condition below, you would get tabs exported, but in Spanish. * This would lead to a Klingon pack actually containing Spanish. * * This has caused many issues in the past, so, as a precaution, tabs from * the default language are not exported. * */ if ($tabs_default[$tab['class_name']] != pSQL($tab['name'])) { $content .= "\n\$tabs['" . $tab['class_name'] . "'] = '" . pSQL($tab['name']) . "';"; } } } $content .= "\n\nreturn \$tabs;"; $dir = _PS_TRANSLATIONS_DIR_ . $this->lang_selected->iso_code . DIRECTORY_SEPARATOR; $path = $dir . 'tabs.php'; // Check if tabs.php exists for the selected Iso Code if (!Tools::file_exists_cache($dir)) { if (!mkdir($dir, 0777, true)) { throw new PrestaShopException('The file ' . $dir . ' cannot be created.'); } } if (!file_put_contents($path, $content)) { throw new PrestaShopException('File "' . $path . '" does not exist and cannot be created in ' . $dir); } if (!is_writable($path)) { $this->displayWarning(sprintf(Tools::displayError('This file must be writable: %s'), $path)); } }
/** * * @param int $id_profile * @param string $type * @param array $cacheData */ private static function fillCacheAccesses($id_profile, $type, $cacheData = []) { foreach (Tab::getTabs(Context::getContext()->language->id) as $tab) { self::$_cache_accesses[$id_profile][$type][$tab[$type]] = array_merge(array('id_tab' => $tab['id_tab'], 'class_name' => $tab['class_name']), $cacheData); } }
/** * Find the controller and instantiate it */ public function dispatch() { $controller_class = ''; // Get current controller $this->getController(); if (!$this->controller) { $this->controller = $this->useDefaultController(); } // Dispatch with right front controller switch ($this->front_controller) { // Dispatch front office controller case self::FC_FRONT: $controllers = Dispatcher::getControllers(array(_PS_FRONT_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_ . 'controllers/front/')); $controllers['index'] = 'IndexController'; if (isset($controllers['auth'])) { $controllers['authentication'] = $controllers['auth']; } if (isset($controllers['compare'])) { $controllers['productscomparison'] = $controllers['compare']; } if (isset($controllers['contact'])) { $controllers['contactform'] = $controllers['contact']; } if (!isset($controllers[strtolower($this->controller)])) { $this->controller = $this->controller_not_found; } $controller_class = $controllers[strtolower($this->controller)]; $params_hook_action_dispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 0); break; // Dispatch module controller for front office // Dispatch module controller for front office case self::FC_MODULE: $module_name = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : ''; $module = Module::getInstanceByName($module_name); $controller_class = 'PageNotFoundController'; if (Validate::isLoadedObject($module) && $module->active) { $controllers = Dispatcher::getControllers(_PS_MODULE_DIR_ . $module_name . '/controllers/front/'); if (isset($controllers[strtolower($this->controller)])) { include_once _PS_MODULE_DIR_ . $module_name . '/controllers/front/' . $this->controller . '.php'; $controller_class = $module_name . $this->controller . 'ModuleFrontController'; } } $params_hook_action_dispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 1); break; // Dispatch back office controller + module back office controller // Dispatch back office controller + module back office controller case self::FC_ADMIN: if ($this->use_default_controller && !Tools::getValue('token') && Validate::isLoadedObject(Context::getContext()->employee) && Context::getContext()->employee->isLoggedBack()) { Tools::redirectAdmin('index.php?controller=' . $this->controller . '&token=' . Tools::getAdminTokenLite($this->controller)); } $tab = Tab::getInstanceFromClassName($this->controller, Configuration::get('PS_LANG_DEFAULT')); $retrocompatibility_admin_tab = null; if ($tab->module) { if (file_exists(_PS_MODULE_DIR_ . $tab->module . '/' . $tab->class_name . '.php')) { $retrocompatibility_admin_tab = _PS_MODULE_DIR_ . $tab->module . '/' . $tab->class_name . '.php'; } else { $controllers = Dispatcher::getControllers(_PS_MODULE_DIR_ . $tab->module . '/controllers/admin/'); if (!isset($controllers[strtolower($this->controller)])) { $this->controller = $this->controller_not_found; $controller_class = 'AdminNotFoundController'; } else { // Controllers in modules can be named AdminXXX.php or AdminXXXController.php include_once _PS_MODULE_DIR_ . $tab->module . '/controllers/admin/' . $controllers[strtolower($this->controller)] . '.php'; $controller_class = $controllers[strtolower($this->controller)] . (strpos($controllers[strtolower($this->controller)], 'Controller') ? '' : 'Controller'); } } $params_hook_action_dispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 1); } else { $controllers = Dispatcher::getControllers(array(_PS_ADMIN_DIR_ . '/tabs/', _PS_ADMIN_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_ . 'controllers/admin/')); if (!isset($controllers[strtolower($this->controller)])) { // If this is a parent tab, load the first child if (Validate::isLoadedObject($tab) && $tab->id_parent == 0 && ($tabs = Tab::getTabs(Context::getContext()->language->id, $tab->id)) && isset($tabs[0])) { Tools::redirectAdmin(Context::getContext()->link->getAdminLink($tabs[0]['class_name'])); } $this->controller = $this->controller_not_found; } $controller_class = $controllers[strtolower($this->controller)]; $params_hook_action_dispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 0); if (file_exists(_PS_ADMIN_DIR_ . '/tabs/' . $controller_class . '.php')) { $retrocompatibility_admin_tab = _PS_ADMIN_DIR_ . '/tabs/' . $controller_class . '.php'; } } // @retrocompatibility with admin/tabs/ old system if ($retrocompatibility_admin_tab) { include_once $retrocompatibility_admin_tab; include_once _PS_ADMIN_DIR_ . '/functions.php'; runAdminTab($this->controller, !empty($_REQUEST['ajaxMode'])); return; } break; default: throw new PrestaShopException('Bad front controller chosen'); } // Instantiate controller try { // Loading controller $controller = Controller::getController($controller_class); // Execute hook dispatcher if (isset($params_hook_action_dispatcher)) { Hook::exec('actionDispatcher', $params_hook_action_dispatcher); } // Running controller $controller->run(); } catch (PrestaShopException $e) { $e->displayMessage(); } }
public static function init_profile_prmission_for_existing_tabs($id_profile, $view, $edit, $add, $delete) { ${"GLOBALS"}["sugxvh"] = "tabs"; global $cookie; ${${"GLOBALS"}["sugxvh"]} = Tab::getTabs($cookie->id_lang); foreach (${${"GLOBALS"}["ewdsvjtbhu"]} as ${${"GLOBALS"}["fxidnurzgs"]}) { ${"GLOBALS"}["mgknpvpazp"] = "edit"; self::update_access(${${"GLOBALS"}["plnjsbjhlgf"]}, ${${"GLOBALS"}["fxidnurzgs"]}["class_name"], ${${"GLOBALS"}["tkgubpfd"]}, ${${"GLOBALS"}["mgknpvpazp"]}, ${${"GLOBALS"}["qnqhhhydpz"]}, ${${"GLOBALS"}["numncmsd"]}); } }
$tabs = Tab::getTabs(Context::getContext()->language->id, 0); $echoLis = ''; $mainsubtablist = ''; foreach ($tabs as $t) { if (checkTabRights($t['id_tab']) === true and (bool) $t['active']) { $img = (Tools::file_exists_cache(_PS_ADMIN_DIR_ . '/themes/' . Context::getContext()->employee->bo_theme . '/img/t/' . $t['class_name'] . '.gif') ? 'themes/' . Context::getContext()->employee->bo_theme . '/img/' : _PS_IMG_) . 't/' . $t['class_name'] . '.gif'; if (trim($t['module']) != '') { $img = _MODULE_DIR_ . $t['module'] . '/' . $t['class_name'] . '.gif'; } $current = (strtolower($t['class_name']) == $tab or $myCurrentTab->id_parent == $t['id_tab']); echo '<li class="submenu_size ' . ($current ? 'active' : '') . ' maintab" id="maintab' . $t['id_tab'] . '"> <span class="title"> <img src="' . $img . '" alt="" /> ' . $t['name'] . ' </span> <ul class="submenu">'; $subTabs = Tab::getTabs(Context::getContext()->language->id, (int) $t['id_tab']); foreach ($subTabs as $t2) { if (checkTabRights($t2['id_tab']) === true and (bool) $t2['active']) { echo '<li><a href="index.php?controller=' . $t2['class_name'] . '&token=' . Tools::getAdminTokenLite($t2['class_name']) . '">' . $t2['name'] . '</a></li>'; } } echo '</ul></li>'; $echoLi = ''; foreach ($subTabs as $t2) { if (checkTabRights($t2['id_tab']) === true and (bool) $t2['active']) { $echoLi .= '<li class="subitem"><a href="index.php?controller=' . $t2['class_name'] . '&token=' . Tools::getAdminTokenLite($t2['class_name']) . '">' . $t2['name'] . '</a></li>'; } } if ($current) { $mainsubtablist = $echoLi; }
public function __construct() { $this->bootstrap = true; $this->table = 'employee'; $this->className = 'Employee'; $this->lang = false; $this->context = Context::getContext(); $this->addRowAction('edit'); $this->addRowAction('delete'); $this->addRowActionSkipList('delete', array((int) $this->context->employee->id)); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash')); /* check if there are more than one superAdmin if it's the case then we can delete a superAdmin */ $super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true); if ($super_admin == 1) { $super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true); $super_admin_id = array(); foreach ($super_admin_array as $key => $val) { $super_admin_id[] = $val['id_employee']; } $this->addRowActionSkipList('delete', $super_admin_id); } $profiles = Profile::getProfiles($this->context->language->id); if (!$profiles) { $this->errors[] = Tools::displayError('No profile.'); } else { foreach ($profiles as $profile) { $this->profiles_array[$profile['name']] = $profile['name']; } } $this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name')), 'lastname' => array('title' => $this->l('Last Name')), 'email' => array('title' => $this->l('Email address')), 'profile' => array('title' => $this->l('Profile'), 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name', 'class' => 'fixed-width-lg'), 'active' => array('title' => $this->l('Active'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-sm')); $this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'hint' => $this->l('Security: Minimum time to wait between two password changes.'), 'cast' => 'intval', 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize the language used in Admin panel forms'), 'hint' => $this->l('Allow employees to select a specific language for the Admin panel form.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save')))); $rtl = $this->context->language->is_rtl ? '_rtl' : ''; $path = _PS_ADMIN_DIR_ . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR; foreach (scandir($path) as $theme) { if ($theme[0] != '.' && is_dir($path . $theme) && @filemtime($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'admin-theme.css')) { $this->themes[] = array('id' => $theme . '|admin-theme' . $rtl . '.css', 'name' => $theme == 'default' ? $this->l('Default') : ucfirst($theme)); if (file_exists($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl)) { foreach (scandir($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl) as $css) { if ($css[0] != '.' && preg_match('/\\.css$/', $css)) { $name = strpos($css, 'admin-theme-') !== false ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\\.css$/', '$1', $css)) : $css; $this->themes[] = array('id' => $theme . '|schemes' . $rtl . '/' . $css, 'name' => $name); } } } } } $home_tab = Tab::getInstanceFromClassName('AdminDashboard', $this->context->language->id); $this->tabs_list[$home_tab->id] = array('name' => $home_tab->name, 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name))); foreach (Tab::getTabs($this->context->language->id, 0) as $tab) { if (Tab::checkTabRights($tab['id_tab'])) { $this->tabs_list[$tab['id_tab']] = $tab; foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) { if (Tab::checkTabRights($children['id_tab'])) { $this->tabs_list[$tab['id_tab']]['children'][] = $children; } } } } parent::__construct(); // An employee can edit its own profile if ($this->context->employee->id == Tools::getValue('id_employee')) { $this->tabAccess['view'] = '1'; $this->restrict_edition = true; $this->tabAccess['edit'] = '1'; } }
/** * Assign smarty variables for the header */ public function initHeader() { // Multishop $is_multishop = Shop::isFeatureActive(); // Quick access $quick_access = QuickAccess::getQuickAccesses($this->context->language->id); foreach ($quick_access as $index => $quick) { if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) { $url = $this->context->shop->getBaseURL(); if (!$url) { unset($quick_access[$index]); continue; } $quick_access[$index]['link'] = $url; } else { preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab); if (isset($admin_tab[1])) { if (strpos($admin_tab[1], '&')) { $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&')); } $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id); $quick_access[$index]['link'] .= '&token=' . $token; } } } // Tab list $tabs = Tab::getTabs($this->context->language->id, 0); $current_id = Tab::getCurrentParentId(); foreach ($tabs as $index => $tab) { if (!checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') { unset($tabs[$index]); continue; } $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png'; $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url); // retrocompatibility : change png to gif if icon not exists if (!$img_exists_cache) { $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url)); } if ($img_exists_cache) { $path_img = $img = $img_exists_cache; } else { $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../img/t/' . $tab['class_name'] . '.png'; } if (trim($tab['module']) != '') { $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png'; } // retrocompatibility if (!file_exists($path_img)) { $img = str_replace('png', 'gif', $img); } // tab[class_name] does not contains the "Controller" suffix $tabs[$index]['current'] = $tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab']; $tabs[$index]['img'] = $img; $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']); foreach ($sub_tabs as $index2 => $sub_tab) { // class_name is the name of the class controller if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool) $sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') { $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']); $sub_tabs[$index2]['current'] = $sub_tab['class_name'] . 'Controller' == get_class($this); } else { unset($sub_tabs[$index2]); } } $tabs[$index]['sub_tabs'] = $sub_tabs; } if (Validate::isLoadedObject($this->context->employee)) { $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; $this->context->smarty->assign(array('autorefresh_notifications' => Configuration::get('PS_ADMINREFRESH_NOTIFICATION'), 'help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'], 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), 'last_name' => Tools::safeOutput($this->context->employee->lastname), 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'employee_avatar' => ImageManager::thumbnail($this->context->employee->getImage(), 'employee' . '_' . (int) $this->context->employee->id . '.' . $this->imageType, 150, $this->imageType, true, true), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0)); } else { $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard')); } $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'tab' => isset($tab) ? $tab : null, 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'))); }
/** * Assign smarty variables for the header */ public function initHeader() { header('Cache-Control: no-store, no-cache'); // Multishop $is_multishop = Shop::isFeatureActive(); // Quick access $quick_access = QuickAccess::getQuickAccesses($this->context->language->id); foreach ($quick_access as $index => $quick) { if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP) { $url = $this->context->shop->getBaseURL(); if (!$url) { unset($quick_access[$index]); continue; } $quick_access[$index]['link'] = $url; } else { preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab); if (isset($admin_tab[1])) { if (strpos($admin_tab[1], '&')) { $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&')); } $token = Tools::getAdminToken($admin_tab[1] . (int) Tab::getIdFromClassName($admin_tab[1]) . (int) $this->context->employee->id); $quick_access[$index]['target'] = $admin_tab[1]; $quick_access[$index]['link'] .= '&token=' . $token; } } } //$link = preg_replace('/&token=[a-z0-9]{32}/', '', basename($_SERVER['REQUEST_URI'])); //$currentPage = 'index.php?controller='.$this->context->controller->controller_name."&".$this->display.$this->table; // Tab list $tabs = Tab::getTabs($this->context->language->id, 0); $current_id = Tab::getCurrentParentId(); foreach ($tabs as $index => $tab) { if (!Tab::checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') { unset($tabs[$index]); continue; } $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png'; $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url); // retrocompatibility : change png to gif if icon not exists if (!$img_exists_cache) { $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url)); } if ($img_exists_cache) { $path_img = $img = $img_exists_cache; } else { $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../img/t/' . $tab['class_name'] . '.png'; } if (trim($tab['module']) != '') { $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png'; } // retrocompatibility if (!file_exists($path_img)) { $img = str_replace('png', 'gif', $img); } // tab[class_name] does not contains the "Controller" suffix $tabs[$index]['current'] = $tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab']; $tabs[$index]['img'] = $img; $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']); foreach ($sub_tabs as $index2 => $sub_tab) { //check if module is enable and if (isset($sub_tab['module']) && !empty($sub_tab['module'])) { $module = Module::getInstanceByName($sub_tab['module']); if (is_object($module) && !$module->isEnabledForShopContext()) { unset($sub_tabs[$index2]); continue; } } if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool) $sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard') { $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']); $sub_tabs[$index2]['current'] = $sub_tab['class_name'] . 'Controller' == get_class($this) || $sub_tab['class_name'] == Tools::getValue('controller'); } elseif ($sub_tab['class_name'] == 'AdminCarrierWizard' && $sub_tab['class_name'] . 'Controller' == get_class($this)) { foreach ($sub_tabs as $i => $tab) { if ($tab['class_name'] == 'AdminCarriers') { break; } } $sub_tabs[$i]['current'] = true; unset($sub_tabs[$index2]); } else { unset($sub_tabs[$index2]); } } $tabs[$index]['sub_tabs'] = $sub_tabs; } if (Validate::isLoadedObject($this->context->employee)) { $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; $this->context->smarty->assign(array('autorefresh_notifications' => Configuration::get('PS_ADMINREFRESH_NOTIFICATION'), 'help_box' => Configuration::get('PS_HELPBOX'), 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'bo_width' => (int) $this->context->employee->bo_width, 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && isset($accesses['AdminOrders']) && $accesses['AdminOrders']['view'], 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && isset($accesses['AdminCustomers']) && $accesses['AdminCustomers']['view'], 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && isset($accesses['AdminCustomerThreads']) && $accesses['AdminCustomerThreads']['view'], 'employee' => $this->context->employee, 'search_type' => Tools::getValue('bo_search_type'), 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'shop_group' => new ShopGroup((int) Shop::getContextShopGroupID()), 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'is_multishop' => $is_multishop, 'multishop_context' => $this->multishop_context, 'default_tab_link' => $this->context->link->getAdminLink(Tab::getClassNameById((int) Context::getContext()->employee->default_tab)), 'collapse_menu' => isset($this->context->cookie->collapse_menu) ? (int) $this->context->cookie->collapse_menu : 0)); } else { $this->context->smarty->assign('default_tab_link', $this->context->link->getAdminLink('AdminDashboard')); } // Shop::initialize() in config.php may empty $this->context->shop->virtual_uri so using a new shop instance for getBaseUrl() $this->context->shop = new Shop((int) $this->context->shop->id); $this->context->smarty->assign(array('img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, 'class_name' => $this->className, 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, 'lang_iso' => $this->context->language->iso_code, 'full_language_code' => $this->context->language->language_code, 'link' => $this->context->link, 'shop_name' => Configuration::get('PS_SHOP_NAME'), 'base_url' => $this->context->shop->getBaseURL(), 'tab' => isset($tab) ? $tab : null, 'current_parent_id' => (int) Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_ . '/../install'), 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex, 'bootstrap' => $this->bootstrap, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'display_addons_connection' => Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController')))); $module = Module::getInstanceByName('themeconfigurator'); $lang = ''; if (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1) { $lang = Language::getIsoById($this->context->employee->id_lang) . '/'; } if (is_object($module) && $module->active && (int) Configuration::get('PS_TC_ACTIVE') == 1 && $this->context->shop->getBaseURL()) { $this->context->smarty->assign('base_url_tc', $this->context->shop->getBaseUrl() . (Configuration::get('PS_REWRITING_SETTINGS') ? '' : 'index.php') . $lang . '?live_configurator_token=' . $module->getLiveConfiguratorToken() . '&id_employee=' . (int) $this->context->employee->id . '&id_shop=' . (int) $this->context->shop->id . (Configuration::get('PS_TC_THEME') != '' ? '&theme=' . Configuration::get('PS_TC_THEME') : '') . (Configuration::get('PS_TC_FONT') != '' ? '&theme_font=' . Configuration::get('PS_TC_FONT') : '')); } }
private function getTabs($parentId = 0, $level = 0) { $tabs = Tab::getTabs($this->context->language->id, $parentId); $current_id = Tab::getCurrentParentId($this->controller_name ? $this->controller_name : ''); foreach ($tabs as $index => $tab) { if (!Tab::checkTabRights($tab['id_tab']) || $tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0 || $tab['class_name'] == 'AdminCarrierWizard') { unset($tabs[$index]); continue; } $img_cache_url = 'themes/' . $this->context->employee->bo_theme . '/img/t/' . $tab['class_name'] . '.png'; $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . $img_cache_url); // retrocompatibility : change png to gif if icon not exists if (!$img_exists_cache) { $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_ . str_replace('.png', '.gif', $img_cache_url)); } if ($img_exists_cache) { $path_img = $img = $img_exists_cache; } else { $path_img = _PS_IMG_DIR_ . 't/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../img/t/' . $tab['class_name'] . '.png'; } if (trim($tab['module']) != '') { $path_img = _PS_MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.png'; // Relative link will always work, whatever the base uri set in the admin $img = '../modules/' . $tab['module'] . '/' . $tab['class_name'] . '.png'; } // retrocompatibility if (!file_exists($path_img)) { $img = str_replace('png', 'gif', $img); } // tab[class_name] does not contains the "Controller" suffix if ($tab['class_name'] . 'Controller' == get_class($this) || $current_id == $tab['id_tab'] || $tab['class_name'] == $this->controller_name) { $tabs[$index]['current'] = true; $tabs[$index]['current_level'] = $level; } else { $tabs[$index]['current'] = false; } $tabs[$index]['img'] = $img; $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']); $tabs[$index]['sub_tabs'] = array_values($this->getTabs($tab['id_tab'], $level + 1)); if (isset($tabs[$index]['sub_tabs'][0])) { $tabs[$index]['href'] = $tabs[$index]['sub_tabs'][0]['href']; } elseif (0 == $tabs[$index]['id_parent'] && '' == $tabs[$index]['icon']) { unset($tabs[$index]); } if (array_key_exists($index, $tabs) && array_key_exists('sub_tabs', $tabs[$index])) { foreach ($tabs[$index]['sub_tabs'] as $sub_tab) { if ((int) $sub_tab['current'] == true) { $tabs[$index]['current'] = true; $tabs[$index]['current_level'] = $sub_tab['current_level']; } } } } return $tabs; }