public function construct()
 {
     $installedVersion = $this->getClassInstalledVersion(__CLASS__);
     if ($installedVersion != self::CLASS_VERSION) {
         $this->linker->db->updateQueries(__CLASS__);
         if (version_compare($installedVersion, '1.1.11.03.29', '<')) {
             // The class datas are not in the same version as this file, or don't exist (installation)
             $this->helper->addClassesSharedMethods('sh_admin', sh_admin::ADMINMENUENTRIES, __CLASS__);
             $this->helper->addClassesSharedMethods('sh_facebook', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_searcher', 'scopes', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_sitemap', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_path', '', $this->className);
             if (!is_dir(SH_IMAGES_FOLDER . 'small/')) {
                 mkdir(SH_IMAGES_FOLDER . 'small/');
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'small/', sh_browser::ALL);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'small/');
             $this->linker->browser->addDimension(SH_IMAGES_FOLDER . 'small/', 100, 100);
             $this->db_execute('create_table', array());
         }
         if (version_compare($installedVersion, '1.1.11.07.13', '<')) {
             $this->db_execute('modify_table_1', array());
         }
         if (version_compare($installedVersion, '1.1.11.07.14', '<')) {
             $this->linker->renderer->add_render_tag('render_newsBox', __CLASS__, 'render_newsBox');
         }
         if (version_compare($installedVersion, '1.1.11.07.14.2', '<')) {
             sh_browser::setRights(SH_IMAGES_FOLDER . 'site/', sh_browser::ALL);
         }
         if (version_compare($installedVersion, '1.1.12.08.20', '<')) {
             $this->db_execute('modify_table_2', array());
             $params = $this->getParam('news>0', array());
             $this->setParam('news>1', $params);
             $this->removeParam('news>0');
             $this->writeParams();
         }
         if (version_compare($installedVersion, '1.1.12.08.21', '<')) {
             $this->helper->addClassesSharedMethods('sh_site', 'sharedSettings', __CLASS__);
         }
         $this->setClassInstalledVersion(self::CLASS_VERSION);
     }
     $this->news_is_active = $this->getParam('news_module_active', true);
 }
 public function construct()
 {
     $installedVersion = $this->getClassInstalledVersion();
     if ($installedVersion != self::CLASS_VERSION) {
         if (version_compare($installedVersion, '1.1.11.03.29') < 0) {
             $this->helper->addClassesSharedMethods('sh_admin', sh_admin::ADMINMENUENTRIES, __CLASS__);
             $this->helper->addClassesSharedMethods('sh_cron', '', __CLASS__);
             if (!is_dir(SH_IMAGES_FOLDER . 'banks')) {
                 mkdir(SH_IMAGES_FOLDER . 'banks');
                 sh_browser::setRights(SH_IMAGES_FOLDER . 'banks', sh_browser::READ + sh_browser::ADDFILE + sh_browser::DELETEFILE + sh_browser::RENAMEFILE);
                 sh_browser::setOwner(SH_IMAGES_FOLDER . 'banks');
                 sh_browser::addDimension(SH_IMAGES_FOLDER . 'banks', 100, 100);
             }
         }
         if (version_compare($installedVersion, '1.1.11.11.15') < 0) {
             $this->getBanksList(true);
         }
         $this->setClassInstalledVersion(self::CLASS_VERSION);
     }
     return false;
 }
Example #3
0
 /**
  * public function construct
  * Initiates the object
  */
 public function construct()
 {
     if ($this->linker->user->isMasterServer(false) && !SH_MASTERISUSER) {
         // No need for this class on a masterServer
         return true;
     }
     define('SH_SHOPIMAGES_PATH', SH_IMAGES_PATH . 'shop/');
     define('SH_SHOPIMAGES_FOLDER', SH_IMAGES_FOLDER . 'shop/');
     $installedVersion = $this->getClassInstalledVersion();
     if ($installedVersion != self::CLASS_VERSION) {
         $this->linker->db->updateQueries(__CLASS__);
         // The class datas are not in the same version as this file, or don't exist (installation)
         if (version_compare($installedVersion, '1.1.11.03.28', '<')) {
             $this->helper->addClassesSharedMethods('sh_admin', sh_admin::ADMINMENUENTRIES, __CLASS__);
             $this->helper->addClassesSharedMethods('sh_cron', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_facebook', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_legacy', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_payment', 'beforeNoPaymentModes', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_payment', 'onNoPaymentModes', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_searcher', 'scopes', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_sitemap', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_user', 'accountTabs', __CLASS__);
             // Constructing the database tables
             for ($a = 1; $a <= 10; $a++) {
                 $this->db_execute('create_table_' . $a, array());
             }
         }
         if (version_compare($installedVersion, '1.1.11.05.27', '<')) {
             $this->helper->addClassesSharedMethods('sh_template', 'change', __CLASS__);
         }
         if (version_compare($installedVersion, '1.1.11.05.31.3', '<')) {
             $this->db_execute('addActiveFieldToCategories', array());
             $this->db_execute('create_table_11', array());
             $this->db_execute('create_table_12', array());
         }
         if (version_compare($installedVersion, '1.1.11.05.31.4', '<')) {
             $this->db_execute('create_table_13', array());
             $this->db_execute('create_table_14', array());
         }
         if (version_compare($installedVersion, '1.1.11.05.31.5', '<')) {
             $this->db_execute('update_table_price_cache_1', array());
         }
         if (version_compare($installedVersion, '1.1.11.05.31.6', '<')) {
             $this->db_execute('update_table_price_cache_2', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.01', '<')) {
             $this->db_execute('update_table_price_cache_3', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.01.2', '<')) {
             $this->db_execute('update_table_promotions_1', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.01.3', '<')) {
             $this->db_execute('update_table_promotions_2', array());
             $this->db_execute('update_table_promotions_3', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.09', '<')) {
             if (!is_dir(SH_IMAGES_FOLDER . 'shop/')) {
                 mkdir(SH_IMAGES_FOLDER . 'shop/');
                 $this->shopsailors_addSite(SH_SITENAME);
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'shop/', sh_browser::ADDFOLDER + sh_browser::DELETEFOLDER + sh_browser::RENAMEFOLDER + sh_browser::READ + sh_browser::ADDFOLDER);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'shop/');
             if (!is_dir(SH_IMAGES_FOLDER . 'shop/shippers/')) {
                 mkdir(SH_IMAGES_FOLDER . 'shop/shippers/');
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'shop/shippers/', sh_browser::ADDFILE + sh_browser::DELETEFILE + sh_browser::RENAMEFILE + sh_browser::READ + sh_browser::ADDFOLDER);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'shop/shippers/');
             sh_browser::setDimensions(SH_IMAGES_FOLDER . 'shop/shippers/', 100, 80);
             if (!is_dir(SH_IMAGES_FOLDER . 'shop/categories/')) {
                 mkdir(SH_IMAGES_FOLDER . 'shop/categories/');
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'shop/categories/', sh_browser::ADDFILE + sh_browser::DELETEFILE + sh_browser::RENAMEFILE + sh_browser::READ + sh_browser::ADDFOLDER);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'shop/categories/');
             if (!is_dir(SH_IMAGES_FOLDER . 'shop/products/')) {
                 mkdir(SH_IMAGES_FOLDER . 'shop/products/');
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'shop/products/', sh_browser::ADDFILE + sh_browser::DELETEFILE + sh_browser::RENAMEFILE + sh_browser::READ + sh_browser::ADDFOLDER);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'shop/products/');
         }
         if (version_compare($installedVersion, '1.1.11.06.09.1', '<')) {
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'shop/shippers/');
         }
         if (version_compare($installedVersion, '1.1.11.06.14', '<')) {
             // We should update the prices
             $this->cron_job(sh_cron::JOB_DAY);
         }
         if (version_compare($installedVersion, '1.1.11.06.17', '<')) {
             $this->db_execute('update_table_products', array());
             $this->db_execute('create_table_packs', array());
             $this->db_execute('create_table_packs_contents', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.20', '<')) {
             $this->db_execute('update_table_products_2', array());
             $this->db_execute('update_table_products_3', array());
         }
         if (version_compare($installedVersion, '1.1.11.06.21', '<')) {
             $this->db_execute('update_table_packs', array());
         }
         if (version_compare($installedVersion, '1.1.11.09.01', '<')) {
             $name = $this->setI18n(0, $this->getI18n('mainCategory_name'));
             $description = $this->setI18n(0, $this->getI18n('mainCategory_description'));
             $shortDescription = $this->setI18n(0, $this->getI18n('mainCategory_shortDescription'));
             $this->db_execute('create_main_category', array('name' => $name, 'description' => $description, 'shortDescription' => $shortDescription));
         }
         if (version_compare($installedVersion, '1.1.11.09.01.2', '<')) {
             $this->linker->sitemap->renew();
         }
         if (version_compare($installedVersion, '1.1.11.11.30', '<')) {
             $this->db_execute('create_layout_table', array());
             $this->db_execute('layout_create_first', array('id' => 1, 'top' => 0, 'bottom' => 0, 'name' => 'Default'));
         }
         if (version_compare($installedVersion, '1.1.11.11.30.2', '<')) {
             $this->db_execute('update_categories_add_layout', array());
             $this->db_execute('update_products_add_layout', array());
         }
         if (version_compare($installedVersion, '1.1.11.12.01', '<')) {
             $this->db_execute('update_packs_add_layout', array());
         }
         if (version_compare($installedVersion, '1.1.11.12.07', '<')) {
             $this->db_execute('create_categories_cached_datas_table', array());
             $this->db_execute('update_prices_cache_unique_add_min_quantity', array());
         }
         if (version_compare($installedVersion, '1.1.12.03.22', '<')) {
             // Re-generating the list of commands that could have been deleted by error by a previous version
             $commandListFile = SH_SITE_FOLDER . __CLASS__ . '/commands/list.php';
             if (file_exists($commandListFile)) {
                 include $commandListFile;
                 $files = glob(SH_SITE_FOLDER . __CLASS__ . '/commands/*/*/*/*.php');
                 foreach ($files as $filename) {
                     include $filename;
                     $file = substr(str_replace(SH_SITE_FOLDER . __CLASS__ . '/commands/', '', $filename), 0, -4);
                     $commandList[$command['billId']] = $file;
                     $command['totalHT_float'] = str_replace(array(' ', '€', ','), array('', '', '.'), $command['totalHT']);
                     $command['totalTTC_float'] = str_replace(array(' ', '€', ','), array('', '', '.'), $command['totalTTC']);
                     $this->helper->writeArrayInFile($filename, 'command', $command);
                 }
                 $this->helper->writeArrayInFile($commandListFile, 'commandList', $commandList);
             }
         }
         if (version_compare($installedVersion, '1.1.12.08.17', '<')) {
             $this->helper->addClassesSharedMethods('sh_site', 'sharedSettings', __CLASS__);
         }
         if (version_compare($installedVersion, '1.1.12.12.10', '<')) {
             $this->linker->renderer->add_render_tag('render_shopproduct', __CLASS__, 'render_shopproduct');
         }
         $this->setClassInstalledVersion(self::CLASS_VERSION);
     }
     if (!$this->getParam('activateShop', true)) {
         return true;
     }
     $this->activateShop = true;
     $css = $this->linker->template->getCSSFile(__CLASS__, SH_TEMPLATE_FOLDER . 'global/' . __CLASS__ . '.css');
     $this->linker->html->addCSS($css, __CLASS__);
     self::$default_logo = '/images/shared/default/shop_default_logo_bill.png';
     $this->shopFolder = SH_SITE_FOLDER . __CLASS__ . '/';
     $this->commandsFolder = $this->shopFolder . 'commands/';
     $this->cartsFolder = $this->shopFolder . 'carts/';
     $monneyFormat = $this->getParam('monney_format');
     $monneyKey = 'monney_formats_listing>' . $monneyFormat . '>';
     $this->decimals = $this->getParam($monneyKey . 'decimals', 2);
     $this->decSeparator = $this->getParam($monneyKey . 'decSeparator', ',');
     $this->thousSeparator = $this->getParam($monneyKey . 'thousSeparator', ' ');
     $this->currency = $this->getParam('currency', 'Euro');
     $this->currencyBefore = $this->getParam('currencies>' . $this->currency . '>before', '');
     $this->currencyAfter = $this->getParam('currencies>' . $this->currency . '>after', '€');
     $this->taxes = $this->getParam('taxes');
     $this->taxRate = $this->getParam('taxRate');
     $this->showTaxSymbol = $this->getParam('showTaxSymbol');
     // Defining the constants
     $this->constants = array('currency' => $this->currency, 'currencyBefore' => $this->currencyBefore, 'currencyAfter' => $this->currencyAfter, 'taxes' => $this->taxes, 'taxRate' => $this->taxRate, 'I18N_NAME' => self::I18N_NAME, 'I18N_REFERENCE' => self::I18N_REFERENCE, 'I18N_DESCRIPTION' => self::I18N_DESCRIPTION, 'I18N_SHORTDESCRIPTION' => self::I18N_SHORTDESCRIPTION, 'I18N_STOCK' => self::I18N_STOCK, 'I18N_IMAGE' => self::I18N_IMAGE, 'I18N_PRICE' => self::I18N_PRICE, 'I18N_BILLHEADLINE' => self::I18N_BILLHEADLINE, 'I18N_BILLFOOTER' => self::I18N_BILLFOOTER, 'I18N_BILLCUSTOMERSERVICE' => self::I18N_BILLCUSTOMERSERVICE);
     if ($this->showTaxSymbol) {
         $this->constants['showTaxSymbol'] = true;
     }
     if ($this->getParam('showQuantity', true)) {
         $this->constants['showQuantity'] = true;
     }
     if ($this->getParam('shipping>activated', true)) {
         $this->constants['shipping_activated'] = true;
     }
     $this->sellingActivated = $this->getParam('selling>activated');
     if ($this->sellingActivated) {
         $this->constants['sellingActivated'] = true;
     } else {
         $this->constants['sellingNotActivated'] = true;
     }
     $this->renderer_addConstants($this->constants);
     $this->linker->html->addSpecialContents('shop_cart_content', $this->get_cart_plugin());
     return true;
 }
 /**
  * Shows the form and save the result for the diaporamas editor.
  */
 public function edit()
 {
     $this->debug(__METHOD__, 2, __LINE__);
     $this->onlyAdmin();
     $id = (int) $this->linker->path->page['id'];
     if ($this->formSubmitted('manage_diaporamas')) {
         $datas = $this->getList(true);
         krsort($_POST['diapo']);
         $max = 1;
         foreach ($_POST['diapo'] as $id => $diapo) {
             $max = max($max, $id);
             if ($id == 0) {
                 //This is a new diapo
                 $id = $max + 1;
                 $name = sh_browser::modifyName($diapo['name']);
                 $folder = $this->diapoFolder . $name . '/';
                 mkdir($folder);
                 $this->helper->writeInFile($folder . '.diaporama_id', $id);
                 sh_browser::setOwner($folder);
                 $this->helper->writeInFile($folder . sh_browser::MAXDIMENSIONFILE, '1000x1000');
                 $this->helper->writeInFile($folder . '/.diaporama_dimensions', $diapo['width'] . 'x' . $diapo['height']);
                 $this->helper->writeInFile($folder . sh_browser::ONCHANGE, 'sh_diaporama|onChange|');
                 sh_browser::setRights($folder, sh_browser::READ + sh_browser::ADDFILE + sh_browser::DELETEFILE + sh_browser::RENAMEFILE);
             } else {
                 $name = $_SESSION[__CLASS__]['id_to_name'][$id];
                 $this->helper->writeInFile($this->diapoFolder . $name . '/.diaporama_dimensions', $diapo['width'] . 'x' . $diapo['height']);
             }
         }
     }
     $datas = $this->getList(true);
     $max = 0;
     unset($_SESSION[__CLASS__]['id_to_name']);
     foreach ($datas['diaporamas'] as $oneData) {
         $_SESSION[__CLASS__]['id_to_name'][$oneData['id']] = $oneData['name'];
         $max++;
     }
     $this->render('add_edit', $datas);
     return true;
 }