/** * Add admin tabs in the menu * @param Array $tabs * Array[ * Array[ * id_parent => 0 || void * className => Controller to link to * module => modulename to easily delete when uninstalling * name => name to display * position => position * ] * ] */ public static function addAdminTab($data) { // Get ID Parent $id_parent = isset($data['id_parent']) ? (int) $data['id_parent'] : (int) Tab::getIdFromClassName($data['classNameParent']); // Tab $tab = Tab::getInstanceFromClassName($data['className']); $tab->id_parent = (int) $id_parent; $tab->class_name = $data['className']; $tab->module = $data['module']; $tab->position = Tab::getNewLastPosition((int) $id_parent); $tab->active = 1; $languages = Language::getLanguages(false); foreach ($languages as $lang) { $tab->name[(int) $lang['id_lang']] = $data['name']; } if (!$tab->save()) { return false; } return $tab->id; }
/** * Overrides update to set position to last when changing parent tab * * @see ObjectModel::update * @param bool $null_values * @return bool */ public function update($null_values = false) { $current_tab = new Tab($this->id); if ($current_tab->id_parent != $this->id_parent) { $this->position = Tab::getNewLastPosition($this->id_parent); } self::$_cache_tabs = array(); return parent::update($null_values); }
public function install() { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Génération du fichier log"); /** database tables creation * */ $sqlfile = dirname(__FILE__) . '/install.sql'; if (!file_exists($sqlfile) || !($sql = file_get_contents($sqlfile))) { return false; } $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql); $queries = preg_split("/;\\s*[\r\n]+/", $sql); foreach ($queries as $query) { if (!Db::getInstance()->Execute(trim($query))) { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Install impossible, génération base échouée : " . Db::getInstance()->getMsgError()); return false; } } //Certissim order stats insertion foreach ($this->_certissim_states as $id => $label) { $sql = "INSERT INTO `" . _DB_PREFIX_ . self::CERTISSIM_STATE_TABLE_NAME . "` (`id_certissim_state`,`label`) VALUES ('" . (int) $id . "','" . (string) $label . "')"; $insert = Db::getInstance()->execute($sql); if (!$insert) { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Insertion state {$id}.{$label} échouée : " . Db::getInstance()->getMsgError()); } } $tab_admin_order_id = Tab::getIdFromClassName('AdminOrders'); //AdminCertissimController registration $tab_controller_main = new Tab(); $tab_controller_main->active = 1; $tab_controller_main->class_name = "AdminCertissim"; foreach (Language::getLanguages() as $language) { $tab_controller_main->name[$language['id_lang']] = "Certissim"; } $tab_controller_main->id_parent = $tab_admin_order_id; $tab_controller_main->module = $this->name; $tab_controller_main->add(); $tab_controller_main->move(Tab::getNewLastPosition(0)); return parent::install() && $this->registerHook('newOrder') && $this->registerHook('paymentConfirm') && $this->registerHook('adminOrder') && $this->registerHook('backOfficeHeader'); }