예제 #1
0
 public static function checkVersion($version)
 {
     $versions = array('3.0');
     $res = true;
     if ($version && $version == $versions[count($versions) - 1]) {
         return;
     }
     foreach ($versions as $ver) {
         if (!$version || $version && $version < $ver) {
             $res = LeoManagewidgetsInstall::createTables();
             if ($res && LeoManagewidgetsInstall::checkTable('leomanagewidget')) {
                 $res = LeoManagewidgetsInstall::getOldData();
                 if ($res) {
                     $res = Db::getInstance()->execute('RENAME TABLE `' . _DB_PREFIX_ . 'leomanagewidget` TO `' . _DB_PREFIX_ . 'leomanagewidget_backup`');
                 }
                 if ($res) {
                     Configuration::updateValue('LEO_MANAGERWIDGETS_VERSION', pSQL($ver));
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * @see Module::install()
  */
 public function install()
 {
     if ($this->_leotype == 0) {
         LeoManagewidgetsInstall::installModuleTab($this->name, 'Leo Manage widgets', 'widgets', 'AdminParentModules');
         LeoManagewidgetsInstall::installModuleTab($this->name, 'Leo Manage Widget Images', 'images', -1);
     }
     /* Adds Module */
     $res = true;
     if (parent::install()) {
         $res &= $this->registerHook('header');
         $res &= $this->registerHook('actionShopDataDuplication');
         $res &= $this->registerHook('actionAdminPerformanceControllerAfter');
         // clear cache
         foreach ($this->_hooksPos as $value) {
             $res &= $this->registerHook($value);
         }
     }
     /* Creates tables */
     if ($this->_leotype == 1) {
         Configuration::updateValue('LEO_MANAGERWIDGETS_VERSION', $this->version);
         require_once _PS_MODULE_DIR_ . 'leotempcp/libs/DataSample.php';
         $sample = new Datasample(1);
         return $sample->processImport($this->name);
     } else {
         $res &= LeoManagewidgetsInstall::createTables();
     }
     return (bool) $res;
 }