Added chinese installer translation and updated empty.po.
[fa-stable.git] / sql / alter2.3.php
index fe455bfb4874a165fd9a4fa0c831528dd7208ba7..0b1c230c4df1fa2c17d2dafd317de5d00390dd70 100644 (file)
@@ -26,7 +26,10 @@ class fa2_3 {
        //
        function install($pref, $force) 
        {
-               global $core_version;
+               global $db_version, $dflt_lang;
+
+               if (!$this->preconf)
+                       return false;
 
                if (!$this->beta) {
                        // all specials below are already done on 2.3beta
@@ -88,13 +91,15 @@ class fa2_3 {
                        if (!db_query($sql))
                                return false;
                }
-               return  update_company_prefs(array('version_id'=>$core_version), $pref);
+               $this->update_lang_cfg();
+               return  update_company_prefs(array('version_id'=>$db_version), $pref);
        }
        //
        //      Checking before install
        //
        function pre_check($pref, $force)
        {
+
                if ($this->beta && !$force)
                        $this->sql = 'alter2.3rc.sql';
 
@@ -105,6 +110,7 @@ class fa2_3 {
        //
        function installed($pref) {
                $this->beta = !check_table($pref, 'suppliers', 'tax_included');
+               $this->preconf = $this->fix_extensions();
 
                $n = 1; // number of patches to be installed
                $patchcnt = 0;
@@ -257,6 +263,107 @@ class fa2_3 {
                }
        return true;
        }
+       
+       function fix_extensions()
+       {
+               global $path_to_root, $next_extension_id, $installed_languages;
+               
+               $lang_chd = false;
+               foreach($installed_languages as $i => $lang) {
+                       if (!isset($lang['path'])) {
+                               $code = $lang['code'];
+                               $installed_languages[$i]['path'] = 'lang/'.$code;
+                               $installed_languages[$i]['package'] = $code;
+                               $lang_chd = true;
+                       }
+               }
+               if ($lang_chd)
+                       write_lang();
+
+               $installed_extensions= get_company_extensions();
+               
+               if (!isset($next_extension_id))
+                       $next_extension_id = 1;
+               $new_exts = array();
+               
+               foreach($installed_extensions as $i => $ext)
+               {
+                       if (isset($ext['title'])) // old type entry
+                       {
+                               if ($ext['type'] == 'module') {
+                                       $new['type'] = 'extension';
+                                       $new['tabs'][] = array(
+                                               'url' => $ext['filename'],
+                                               'access' => isset($ext['access']) ? $ext['access'] : 'SA_OPEN',
+                                               'tab_id' => $ext['tab'],
+                                               'title' => $ext['title']
+                                       );
+                                       $new['path'] = $ext['path'];
+                               }
+                               else // plugin
+                               {
+                                       $new['type'] = 'extension';
+                                       $new['tabs'] = array();
+                                       $new['path'] = 'modules/'.$ext['path'];
+                                       $new['entries'][] = array(
+                                               'url' => $ext['filename'],
+                                               'access' => isset($ext['access']) ? $ext['access'] : 'SA_OPEN',
+                                               'tab_id' => $ext['tab'],
+                                               'title' => $ext['title']
+                                       );
+                               }
+                               if (isset($ext['acc_file']))
+                                       $new['acc_file'] = $ext['acc_file'];
+                               $new['name'] = $ext['name']; // albo access_string(title)
+                               $new['package'] = $new['package'] = '';
+                               $new['active'] = 1;
+
+                               $new_exts[$i] = $new;
+                       }
+               }
+               // Add non-standard themes
+               $path = $path_to_root.'/themes/';
+               $themes = array();
+               $themedir = opendir($path);
+               while (false !== ($fname = readdir($themedir)))
+               {
+                       if ($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname)
+                               && !in_array($fname, array('aqua', 'cool', 'default')))
+                       {
+                               foreach($installed_extensions as $ext)  
+                                       if ($ext['path'] == 'themes/'.$fname) // skip if theme is already listed
+                                               continue 2;
+                               $new_exts[$next_extension_id++] = array(
+                                       'name' => 'Theme '. ucwords($fname),
+                                       'package' => $fname,
+                                       'type' => 'theme',
+                                       'active' => true,
+                                       'path' => 'themes/'.$fname
+                               );
+                       }
+               }
+               closedir($themedir);
+
+               if (count($new_exts)) {
+                       return update_extensions($new_exts);
+               } else
+                       return true;
+       }
+       
+       function update_lang_cfg()
+       {
+               global $dflt_lang, $installed_languages;
+
+               foreach($installed_languages as $n => $lang) {
+                       if ($lang['code'] == 'en_GB') {
+                               $installed_languages[$n] = array('code'=>'C','name'=>'English',
+                                       'encoding'=>'iso-8859-1', 'path' => '', 'package' => '');
+                               if ($dflt_lang == 'en_GB')
+                                       $dflt_lang = 'C';
+                               write_lang();
+                       }
+               }
+       }
 }
 
 $install = new fa2_3;