本文整理汇总了PHP中Tab::initAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Tab::initAccess方法的具体用法?PHP Tab::initAccess怎么用?PHP Tab::initAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tab
的用法示例。
在下文中一共展示了Tab::initAccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* additionnal treatments for Tab when creating new one :
* - generate a new position
* - add access for admin profile
*
* @param bool $autodate
* @param bool $null_values
* @return int id_tab
*/
public function add($autodate = true, $null_values = false)
{
self::$_cache_tabs = array();
// Set good position for new tab
$this->position = Tab::getNewLastPosition($this->id_parent);
$this->module = Tools::strtolower($this->module);
// Add tab
if (parent::add($autodate, $null_values)) {
//forces cache to be reloaded
self::$_getIdFromClassName = null;
return Tab::initAccess($this->id);
}
return false;
}
示例2: add
/**
* additionnal treatments for Tab when creating new one :
* - generate a new position
* - add access for admin profile
*
* @param boolean $autodate
* @param boolean $null_values
* @return int id_tab
*/
public function add($autodate = true, $null_values = false)
{
// @retrocompatibility with old menu (before 1.5.0.9)
$retro = array('AdminPayment' => 'AdminParentModules', 'AdminOrders' => 'AdminParentOrders', 'AdminCustomers' => 'AdminParentCustomer', 'AdminShipping' => 'AdminParentShipping', 'AdminPreferences' => 'AdminParentPreferences', 'AdminStats' => 'AdminParentStats', 'AdminEmployees' => 'AdminAdmin');
$class_name = Tab::getClassNameById($this->id_parent);
if (isset($retro[$class_name])) {
$this->id_parent = Tab::getIdFromClassName($retro[$class_name]);
}
self::$_cache_tabs = array();
// Set good position for new tab
$this->position = Tab::getNewLastPosition($this->id_parent);
// Add tab
if (parent::add($autodate, $null_values)) {
// refresh cache when adding new tab
self::$_getIdFromClassName[strtolower($this->class_name)] = $this->id;
return Tab::initAccess($this->id);
}
return false;
}
示例3: install
public function install()
{
if (!parent::install()) {
return false;
}
if (!$this->registerHookByVersion()) {
return false;
}
if (!file_exists(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE) || !($sql = file_get_contents(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE))) {
return false;
}
$sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
$sql = preg_split("/;\\s*[\r\n]+/", $sql);
foreach ($sql as $k => $query) {
if (!empty($query)) {
Db::getInstance()->execute(trim($query));
}
}
$result = Db::getInstance()->getRow('
SELECT id_tab
FROM `' . _DB_PREFIX_ . 'tab`
WHERE class_name="AdminMondialRelay"');
if (!$result) {
// AdminOrders id_tab
$id_parent = _PS_VERSION_ < '1.5' ? 3 : 9;
/*tab install */
$result = Db::getInstance()->getRow('
SELECT position
FROM `' . _DB_PREFIX_ . 'tab`
WHERE `id_parent` = ' . (int) $id_parent . '
ORDER BY `' . _DB_PREFIX_ . 'tab`.`position` DESC');
$pos = isset($result['position']) ? $result['position'] + 1 : 0;
Db::getInstance()->execute('
INSERT INTO ' . _DB_PREFIX_ . 'tab
(id_parent, class_name, position, module)
VALUES(' . (int) $id_parent . ', "AdminMondialRelay", "' . (int) $pos . '", "mondialrelay")');
$id_tab = Db::getInstance()->Insert_ID();
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
Db::getInstance()->execute('
INSERT INTO ' . _DB_PREFIX_ . 'tab_lang
(id_lang, id_tab, name)
VALUES("' . (int) $language['id_lang'] . '", "' . (int) $id_tab . '", "Mondial Relay")');
}
if (!Tab::initAccess($id_tab)) {
return false;
}
if (is_dir(_PS_MODULE_DIR_ . 'mondialrelay/')) {
@copy(_PS_MODULE_DIR_ . 'mondialrelay/AdminMondialRelay.gif', _PS_IMG_DIR_ . '/AdminMondialRelay.gif');
}
}
// If module isn't installed, set default value
if (!Configuration::get('MONDIAL_RELAY')) {
Configuration::updateValue('MONDIAL_RELAY', $this->version);
Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(time() . rand(0, 10)));
} else {
// Reactive transport if database wasn't remove at the last uninstall
Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'carrier` c, `' . _DB_PREFIX_ . 'mr_method` m
SET c.`deleted` = 0, c.`active` = 1
WHERE c.id_carrier = m.id_carrier');
}
return true;
}
示例4: install
public function install()
{
$sql = array();
$db = Db::getInstance();
// backup possible old order table
if (count($db->executeS('show tables like "' . _DB_PREFIX_ . 'packetery_order"')) > 0) {
$db->execute('rename table `' . _DB_PREFIX_ . 'packetery_order` to `' . _DB_PREFIX_ . 'packetery_order_old`');
$have_old_table = true;
} else {
$have_old_table = false;
}
// create tables
if (!defined('_MYSQL_ENGINE_')) {
define('_MYSQL_ENGINE_', 'MyISAM');
}
include dirname(__FILE__) . '/sql-install.php';
foreach ($sql as $s) {
if (!$db->execute($s)) {
return false;
}
}
// copy data from old order table
if ($have_old_table) {
$fields = array();
foreach ($db->executeS('show columns from `' . _DB_PREFIX_ . 'packetery_order_old`') as $field) {
$fields[] = $field['Field'];
}
$db->execute('insert into `' . _DB_PREFIX_ . 'packetery_order`(`' . implode('`, `', $fields) . '`)
select * from `' . _DB_PREFIX_ . 'packetery_order_old`');
$db->execute('drop table `' . _DB_PREFIX_ . 'packetery_order_old`');
}
// module itself and hooks
if (!parent::install() || !$this->registerHook('extraCarrier') || !$this->registerHook('updateCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('header') || !$this->registerHook('adminOrder')) {
return false;
}
// for PrestaShop >= 1.4.0.2 there is one-page-checkout, more hooks are required
$v = explode('.', _PS_VERSION_);
if (_PS_VERSION_ > '1.4.0' || array_slice($v, 0, 3) == array(1, 4, 0) && $v[3] >= 2) {
if (!$this->registerHook('processCarrier') || !$this->registerHook('paymentTop')) {
return false;
}
}
// optional hooks (allow fail for older versions of PrestaShop)
$this->registerHook('orderDetailDisplayed');
$this->registerHook('backOfficeTop');
$this->registerHook('beforeCarrier');
$this->registerHook('displayMobileHeader');
// create admin tab under Orders
$db->execute('insert into `' . _DB_PREFIX_ . 'tab` (id_parent, class_name, module, position)
select id_parent, "AdminOrderPacketery", "packetery", coalesce(max(position) + 1, 0)
from `' . _DB_PREFIX_ . 'tab` pt where id_parent=(select if (id_parent>0, id_parent, id_tab) from `' . _DB_PREFIX_ . 'tab` as tp where tp.class_name="AdminOrders") group by id_parent');
$tab_id = $db->insert_id();
$tab_name = array('en' => 'Packetery', 'cs' => 'Zásilkovna', 'sk' => 'Zásielkovňa');
foreach (Language::getLanguages(false) as $language) {
$db->execute('insert into `' . _DB_PREFIX_ . 'tab_lang` (id_tab, id_lang, name)
values(' . $tab_id . ', ' . $language['id_lang'] . ', "' . pSQL($tab_name[$language['iso_code']] ? $tab_name[$language['iso_code']] : $tab_name['en']) . '")');
}
if (!Tab::initAccess($tab_id)) {
return false;
}
return true;
}
示例5: installModuleTab
public function installModuleTab($tabClass, $tabName, $parentName)
{
$sql = 'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name="' . pSQL($parentName) . '"';
$idTabParent = Db::getInstance()->getValue($sql);
if (!$idTabParent) {
$this->messages[] = 'Failed to find parent tab ' . $parentName;
return false;
}
@copy(_PS_MODULE_DIR_ . $this->module->name . '/logo.gif', _PS_IMG_DIR_ . 't/' . $tabClass . '.gif');
$tab = new Tab();
$tabNames = array();
foreach (Language::getLanguages(false) as $language) {
$tabNames[$language['id_lang']] = $tabName;
}
$tab->name = $tabNames;
$tab->class_name = $tabClass;
$tab->module = $this->module->name;
$tab->id_parent = $idTabParent;
if (!$tab->save()) {
$this->messages[] = 'Failed save Tab ' . implode(',', $tabNames);
return false;
}
$sql = 'DELETE FROM ' . _DB_PREFIX_ . 'access WHERE id_tab=' . (int) $tab->id;
Db::getInstance()->execute($sql);
if (!Tab::initAccess($tab->id)) {
$this->messages[] = 'Failed save init access ' . implode(',', $tabNames);
return false;
}
return true;
}