Example #1
0
 public function RunMultishopUpdate($multishop_page_uid = '')
 {
     $settings = array();
     // attribute fixer
     $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_options', 'language_id=\'0\'', '', 'sort_order', '');
     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
     $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($qry);
     if ($rows) {
         while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
             // now load the related values
             $str2 = $GLOBALS['TYPO3_DB']->SELECTquery('povp.products_options_id,povp.products_options_values_id', 'tx_multishop_products_options_values_to_products_options povp, tx_multishop_products_options_values pov', 'povp.products_options_id=\'' . $row['products_options_id'] . '\' and povp.products_options_values_id=pov.products_options_values_id and pov.language_id=\'0\' and povp.sort_order=0', '', '', '');
             $qry2 = $GLOBALS['TYPO3_DB']->sql_query($str2);
             $rows2 = $GLOBALS['TYPO3_DB']->sql_num_rows($qry2);
             if ($rows2 > 1) {
                 $fix_attribute_values = 1;
                 break;
             }
         }
     }
     if ($fix_attribute_values) {
         // attribute fixer
         $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_options', 'language_id=\'0\'', '', 'sort_order', '');
         $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
         $rows = $GLOBALS['TYPO3_DB']->sql_num_rows($qry);
         if ($rows) {
             while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
                 // now load the related values
                 $str2 = $GLOBALS['TYPO3_DB']->SELECTquery('povp.products_options_id,povp.products_options_values_id', 'tx_multishop_products_options_values_to_products_options povp, tx_multishop_products_options_values pov', 'povp.products_options_id=\'' . $row['products_options_id'] . '\' and povp.products_options_values_id=pov.products_options_values_id and pov.language_id=\'0\'', '', 'povp.sort_order', '');
                 $qry2 = $GLOBALS['TYPO3_DB']->sql_query($str2);
                 $counter = 0;
                 while (($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry2)) != false) {
                     $where = "products_options_id='" . $row2['products_options_id'] . "' and products_options_values_id = " . $row2['products_options_values_id'];
                     $updateArray = array('sort_order' => $counter);
                     $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_products_options_values_to_products_options', $where, $updateArray);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                     $counter++;
                 }
             }
         }
         // end attribute fixer
     }
     $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_configuration_values', 'page_uid="' . $multishop_page_uid . '"', '', '', '');
     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
         while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) != false) {
             if (isset($row['configuration_value']) and $row['configuration_value'] != '') {
                 $settings['LOCAL_MODULES'][$row['configuration_key']] = $row['configuration_value'];
             }
         }
     }
     // load local front-end module config eof
     // load global front-end module config
     $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_configuration', '', '', '', '');
     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
         while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) != false) {
             if (isset($row['configuration_value'])) {
                 $settings['GLOBAL_MODULES'][$row['configuration_key']] = $row['configuration_value'];
             }
         }
     }
     // load global front-end module config eof
     // merge global with local front-end module config
     if (is_array($settings['GLOBAL_MODULES']) && count($settings['GLOBAL_MODULES'])) {
         foreach ($settings['GLOBAL_MODULES'] as $key => $value) {
             if (isset($settings['LOCAL_MODULES'][$key])) {
                 $settings[$key] = $settings['LOCAL_MODULES'][$key];
             } else {
                 $settings[$key] = $value;
             }
         }
     }
     // merge global with local front-end module config eof
     if ($settings['COUNTRY_ISO_NR']) {
         $country = mslib_fe::getCountryByIso($settings['COUNTRY_ISO_NR']);
         $settings['CURRENCY_ARRAY'] = mslib_befe::loadCurrency($country['cn_currency_iso_nr']);
         switch ($settings['COUNTRY_ISO_NR']) {
             case '528':
             case '276':
                 $settings['CURRENCY'] = '€';
                 break;
             default:
                 $settings['CURRENCY'] = $settings['CURRENCY_ARRAY']['cu_symbol_left'];
                 break;
         }
     }
     // check database
     $messages = array();
     $skip = 0;
     $settings['update_database'] = 1;
     if ($settings['update_database']) {
         set_time_limit(86400);
         ignore_user_abort(true);
         require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/front_pages/includes/compare_database.php';
     }
     // check database eof
     // delete duplicates eof
     // load default vars for upgrade purposes eof
     if (!count($messages)) {
         $content = $this->pi_getLL('admin_label_nothing_updated_already_using_latest_version');
     } else {
         $content = addslashes(str_replace("\n", "", implode("<br />", $messages)));
     }
     return $content;
 }
 /**
  * @return the $configurationArray
  */
 public function generateConfigurationArray()
 {
     if ($this->staticConfiguration == true) {
         static $settings;
         if (is_array($settings)) {
             // the settings are already loaded before so lets return them.
             $this->configurationArray = $settings;
             return '';
         }
         // first check if we already loaded the configuration before
     }
     $settings = array();
     $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_configuration_values', 'page_uid="' . $this->shopPid . '"', '', '', '');
     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             if (isset($row['configuration_value']) and $row['configuration_value'] != '') {
                 $settings['LOCAL_MODULES'][$row['configuration_key']] = $row['configuration_value'];
             }
         }
     }
     // load local front-end module config eof
     // load global front-end module config
     $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_configuration', '', '', '', '');
     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             if (isset($row['configuration_value'])) {
                 $settings['GLOBAL_MODULES'][$row['configuration_key']] = $row['configuration_value'];
             }
         }
     }
     // load global front-end module config eof
     // merge global with local front-end module config
     foreach ($settings['GLOBAL_MODULES'] as $key => $value) {
         if (isset($settings['LOCAL_MODULES'][$key])) {
             $settings[$key] = $settings['LOCAL_MODULES'][$key];
         } else {
             $settings[$key] = $value;
         }
     }
     // merge global with local front-end module config eof
     if ($settings['COUNTRY_ISO_NR']) {
         $country = mslib_fe::getCountryByIso($settings['COUNTRY_ISO_NR']);
         $settings['CURRENCY_ARRAY'] = mslib_befe::loadCurrency($country['cn_currency_iso_nr']);
         // if default currency is not set then define it to the store country currency
         if (!$settings['DEFAULT_CURRENCY']) {
             $settings['DEFAULT_CURRENCY'] = $settings['CURRENCY_ARRAY']['cu_iso_3'];
         }
         switch ($settings['COUNTRY_ISO_NR']) {
             case '528':
             case '276':
                 $settings['CURRENCY'] = '&#8364;';
                 break;
             default:
                 $settings['CURRENCY'] = $settings['CURRENCY_ARRAY']['cu_symbol_left'];
                 break;
         }
     }
     if (!$this->cookie['selected_currency']) {
         $this->cookie['selected_currency'] = $settings['DEFAULT_CURRENCY'];
     }
     if ($this->cookie['selected_currency']) {
         // load customer selected currency
         $settings['CUSTOMER_CURRENCY_ARRAY'] = mslib_befe::loadCurrency($this->cookie['selected_currency'], 'cu_iso_3');
         $settings['CUSTOMER_CURRENCY'] = $settings['CUSTOMER_CURRENCY_ARRAY']['cu_symbol_left'];
     }
     //hook to let other plugins further manipulate the settings
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['loadConfiguration'])) {
         $params = array('settings' => &$settings, 'this' => &$this);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['loadConfiguration'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     $this->configurationArray = $settings;
 }