phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: /sitemgr/setup setup.inc.php,1.5,1.5.2.1 tables_


From: Patrick Walsh <address@hidden>
Subject: [Phpgroupware-cvs] CVS: /sitemgr/setup setup.inc.php,1.5,1.5.2.1 tables_current.inc.php,1.5,1.5.2.1 tables_update.inc.php,1.4,1.4.2.1
Date: Fri, 22 Nov 2002 01:01:02 -0500

Update of /cvsroot/phpgroupware//sitemgr/setup
In directory subversions:/tmp/cvs-serv14291

Modified Files:
      Tag: Version-0_9_14-branch
        setup.inc.php tables_current.inc.php tables_update.inc.php 
Log Message:
Updates tables to fix pgsql bug and add multi-lingual support


Index: setup.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//sitemgr/setup/setup.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** setup.inc.php       7 Sep 2002 05:57:29 -0000       1.5
--- setup.inc.php       22 Nov 2002 06:00:58 -0000      1.5.2.1
***************
*** 14,20 ****
        $setup_info['sitemgr']['name']      = 'sitemgr';
        $setup_info['sitemgr']['title']     = 'SiteMgr Web Content Manager';
!       $setup_info['sitemgr']['version']   = '0.9.14.002';
        $setup_info['sitemgr']['app_order'] = 8;
!       $setup_info['sitemgr']['tables']    = 
array('phpgw_sitemgr_pages','phpgw_sitemgr_blocks','phpgw_sitemgr_preferences');
        $setup_info['sitemgr']['enable']    = 1;
  
--- 14,20 ----
        $setup_info['sitemgr']['name']      = 'sitemgr';
        $setup_info['sitemgr']['title']     = 'SiteMgr Web Content Manager';
!       $setup_info['sitemgr']['version']   = '0.9.14.005';
        $setup_info['sitemgr']['app_order'] = 8;
!       $setup_info['sitemgr']['tables']    = 
array('phpgw_sitemgr_pages','phpgw_sitemgr_pages_lang','phpgw_sitemgr_categories_lang','phpgw_sitemgr_blocks','phpgw_sitemgr_preferences');
        $setup_info['sitemgr']['enable']    = 1;
  

Index: tables_current.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//sitemgr/setup/tables_current.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** tables_current.inc.php      7 Sep 2002 06:18:58 -0000       1.5
--- tables_current.inc.php      22 Nov 2002 06:00:58 -0000      1.5.2.1
***************
*** 20,41 ****
                                'hide_page' => array('type' => 'int', 
'precision' => 4),
                                'name' => array('type' => 'varchar', 
'precision' => 100),
                                'title' => array('type' => 'varchar', 
'precision' => 256),
                                'subtitle' => array('type' => 'varchar', 
'precision' => 256),
                                'content' => array('type' => 'text')
                        ),
!                       'pk' => array('page_id'),
                        'fk' => array(),
!                       'ix' => array('cat_id'),
                        'uc' => array()
                ),
!               'phpgw_sitemgr_categories' => array(
                        'fd' => array(
                                'cat_id' => array('type' => 'auto', 'nullable' 
=> false),
!                               'sort_order' => array('type' => 'int', 
'precision' => 4),
!                               'parent' => array('type' => 'int', 'precision' 
=> 4),
                                'name' => array('type' => 'varchar', 
'precision' => 100),
                                'description' => array('type' => 'varchar', 
'precision' => 256)
                        ),
!                       'pk' => array('cat_id'),
                        'fk' => array(),
                        'ix' => array(),
--- 20,50 ----
                                'hide_page' => array('type' => 'int', 
'precision' => 4),
                                'name' => array('type' => 'varchar', 
'precision' => 100),
+                       ),
+                       'pk' => array('page_id'),
+                       'fk' => array(),
+                       'ix' => array('cat_id'),
+                       'uc' => array()
+               ),
+               'phpgw_sitemgr_pages_lang' => array(
+                       'fd' => array(
+                               'page_id' => array('type' => 'auto', 'nullable' 
=> false),
+                               'lang' => array('type' => 'varchar', 
'precision' => 2, 'nullable' => false),
                                'title' => array('type' => 'varchar', 
'precision' => 256),
                                'subtitle' => array('type' => 'varchar', 
'precision' => 256),
                                'content' => array('type' => 'text')
                        ),
!                       'pk' => array('page_id','lang'),
                        'fk' => array(),
!                       'ix' => array(),
                        'uc' => array()
                ),
!               'phpgw_sitemgr_categories_lang' => array(
                        'fd' => array(
                                'cat_id' => array('type' => 'auto', 'nullable' 
=> false),
!                               'lang' => array('type' => 'varchar', 
'precision' => 2, 'nullable' => false),
                                'name' => array('type' => 'varchar', 
'precision' => 100),
                                'description' => array('type' => 'varchar', 
'precision' => 256)
                        ),
!                       'pk' => array('cat_id','lang'),
                        'fk' => array(),
                        'ix' => array(),
***************
*** 46,50 ****
                                'block_id' => array('type' => 'auto', 
'nullable' => false),
                                'side' => array('type' => 'int', 'precision' => 
4),
!                               'position' => array('type' => 'int', 
'precision' => 4),
                                'filename' => array('type' => 'varchar', 
'precision' => 300),
                                'title' => array('type' => 'varchar', 
'precision' => 256)
--- 55,59 ----
                                'block_id' => array('type' => 'auto', 
'nullable' => false),
                                'side' => array('type' => 'int', 'precision' => 
4),
!                               'pos' => array('type' => 'int', 'precision' => 
4),
                                'filename' => array('type' => 'varchar', 
'precision' => 300),
                                'title' => array('type' => 'varchar', 
'precision' => 256)

Index: tables_update.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware//sitemgr/setup/tables_update.inc.php,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** tables_update.inc.php       7 Sep 2002 05:57:29 -0000       1.4
--- tables_update.inc.php       22 Nov 2002 06:00:58 -0000      1.4.2.1
***************
*** 62,68 ****
--- 62,240 ----
                // Finally, delete the categories table
                //$phpgw_setup->oProc->DropTable('phpgw_sitemgr_categories');
+               
+               // Turns out that convert_to_phpgwapi() must be run under 
+               // the normal phpgw environment and not the setup env.
+               // This upgrade routine has been moved to the main body 
+               // of code.
  
                return $setup_info['sitemgr']['currentver'];
        }
+ 
+       $test[] = '0.9.14.003';
+       function sitemgr_upgrade0_9_14_003()
+       {
+               global $setup_info,$phpgw_setup;
+               $setup_info['sitemgr']['currentver'] = '0.9.14.004';
                
+               if (!file_exists(PHPGW_SERVER_ROOT 
.'/sitemgr/setup/sitemgr_sitelang'))
+               {
+                       echo '<hr><b>Sitemgr upgrade <i>incomplete</i>.  Please 
read the following instructions below and try again.</b><p>';
+                       echo 'Sitemgr verion ' . 
$setup_info['sitemgr']['currentver'] . ' is now fully multilingual. It stores 
all data in new tables which associate pages and categories to languages. 
<i>Before upgrading to this version, you have to tell the setup program what 
language your existing site has been written for.</i><p> Create a file with the 
name <b>sitemgr_sitelang</b> in the <b>sitemgr/setup</b> directory which first 
line contains the two letter language code for your site.  For example, "en" if 
your existing site is in English (don\'t put the quotes in the sitemgr_sitelang 
file).<hr>';
+                       return false;
+               }
+               else
+               {
+                       $langfile = file(PHPGW_SERVER_ROOT . 
'/sitemgr/setup/sitemgr_sitelang');
+                       $lang = rtrim($langfile[0]);
+                       if (strlen($lang) != 2)
+                       {
+                               echo 'The first line of' . PHPGW_SERVER_ROOT .
+                                       '/sitemgr/setup/sitemgr_sitelang should 
contain a two letter language code with no spaces or other characters.';
+                               return false;
+                       }
+               }
+ 
+               echo 'Updating sitemgr to a multilingual architecture with 
existing site language ' . $lang;
+ 
+               $db2 = $phpgw_setup->db;
+ 
+               
$GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_sitemgr_pages_lang',
+                       array(
+                               'fd' => array(
+                                       'page_id' => array('type' => 'auto', 
'nullable' => false),
+                                       'lang' => array('type' => 'varchar', 
'precision' => 2, 
+                                               'nullable' => false),
+                                       'title' => array('type' => 'varchar', 
'precision' => 256),
+                                       'subtitle' => array('type' => 
'varchar', 
+                                               'precision' => 256),
+                                       'content' => array('type' => 'text')
+                               ),
+                               'pk' => array('page_id','lang'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'phpgw_sitemgr_categories_lang',
+                       array(
+                               'fd' => array(
+                                       'cat_id' => array('type' => 'auto', 
'nullable' => false),
+                                       'lang' => array('type' => 'varchar', 
'precision' => 2, 
+                                               'nullable' => false),
+                                       'name' => array('type' => 'varchar', 
'precision' => 100),
+                                       'description' => array('type' => 
'varchar', 
+                                               'precision' => 256)
+                               ),
+                               'pk' => array('cat_id','lang'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+               $GLOBALS['phpgw_setup']->oProc->query("select * from 
phpgw_categories where cat_appname='sitemgr'");
+               while($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $cat_id = $GLOBALS['phpgw_setup']->oProc->f('cat_id');
+                       $name = $GLOBALS['phpgw_setup']->oProc->f('cat_name');
+                       $description = 
$GLOBALS['phpgw_setup']->oProc->f('cat_description');
+                       $db2->query("INSERT INTO phpgw_sitemgr_categories_lang 
(cat_id, lang, name, description) VALUES ($cat_id, '$lang', '$name', 
'$description')");
+               }
+ 
+               $GLOBALS['phpgw_setup']->oProc->query("select * from 
phpgw_sitemgr_pages");
+               while($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $page_id = $GLOBALS['phpgw_setup']->oProc->f('page_id');
+                       $title = $GLOBALS['phpgw_setup']->oProc->f('title');
+                       $subtitle = 
$GLOBALS['phpgw_setup']->oProc->f('subtitle');
+                       $content =  
$GLOBALS['phpgw_setup']->oProc->f('content');
+                     
+                       $db2->query("INSERT INTO phpgw_sitemgr_pages_lang 
(page_id, lang, title, subtitle, content) VALUES ($page_id,, '$lang', '$itle', 
'$subtitle', '$content')");
+               }
+         
+               $newtbldef = array(
+                       'fd' => array(
+                               'page_id' => array('type' => 'auto', 'nullable' 
=> false),
+                               'cat_id' => array('type' => 'int', 'precision' 
=> 4),
+                               'sort_order' => array('type' => 'int', 
'precision' => 4),
+                               'hide_page' => array('type' => 'int', 
'precision' => 4),
+                               'name' => array('type' => 'varchar', 
'precision' => 100),
+                               'subtitle' => array('type' => 'varchar', 
'precision' => 256),
+                               'content' => array('type' => 'text')
+                       ),
+                       'pk' => array('page_id'),
+                       'fk' => array(),
+                       'ix' => array('cat_id'),
+                       'uc' => array()
+               );
+               
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_sitemgr_pages',
+                       $newtbldef,'title');
+               $newtbldef = array(
+                       'fd' => array(
+                               'page_id' => array('type' => 'auto', 'nullable' 
=> false),
+                               'cat_id' => array('type' => 'int', 'precision' 
=> 4),
+                               'sort_order' => array('type' => 'int', 
'precision' => 4),
+                               'hide_page' => array('type' => 'int', 
'precision' => 4),
+                               'name' => array('type' => 'varchar', 
'precision' => 100),
+                               'content' => array('type' => 'text')
+                       ),
+                       'pk' => array('page_id'),
+                       'fk' => array(),
+                       'ix' => array('cat_id'),
+                       'uc' => array()
+               );
+               
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_sitemgr_pages',
+                       $newtbldef,'subtitle');
+               $newtbldef = array(
+                       'fd' => array(
+                               'page_id' => array('type' => 'auto', 'nullable' 
=> false),
+                               'cat_id' => array('type' => 'int', 'precision' 
=> 4),
+                               'sort_order' => array('type' => 'int', 
'precision' => 4),
+                               'hide_page' => array('type' => 'int', 
'precision' => 4),
+                               'name' => array('type' => 'varchar', 
'precision' => 100)
+                       ),
+                       'pk' => array('page_id'),
+                       'fk' => array(),
+                       'ix' => array('cat_id'),
+                       'uc' => array()
+               );
+               
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_sitemgr_pages',
+                       $newtbldef,'content');
+ 
+               // try to set the sitelanguages preference. 
+               // if it already exists do nothing
+               $db2->query("SELECT pref_id FROM phpgw_sitemgr_preferences 
WHERE name='sitelanguages'");
+               if ($db2->next_record())
+               {
+               }
+               else
+               {
+                       $db2->query("INSERT INTO phpgw_sitemgr_preferences 
(name, value) VALUES ('sitelanguages', '$lang')");
+               }
+ 
+               //internationalize the names for site-name, header and footer 
+               //preferences
+               $prefstochange = 
array('sitemgr-site-name','siteheader','sitefooter');
+         
+               foreach ($prefstochange as $oldprefname)
+               {
+                       $newprefname = $oldprefname . '-' . $lang;
+                       //echo "DEBUG: Changing $oldprefname to $newprefname. ";
+                       $db2->query("UPDATE phpgw_sitemgr_preferences SET 
name='$newprefname' where name='$oldprefname'");
+               }
+ 
+               return $setup_info['sitemgr']['currentver'];      
+       }       
+ 
+     $test[] = '0.9.14.004';
+       function sitemgr_upgrade0_9_14_004()
+       {
+               global $setup_info,$phpgw_setup;
+               $setup_info['sitemgr']['currentver'] = '0.9.14.005';
+ 
+               echo 'Fixing column names.';
+               $phpgw_setup->oProc->RenameColumn('phpgw_sitemgr_blocks', 
'position', 'pos');
+ 
+               return $setup_info['sitemgr']['currentver'];                    
         
+       }                                                                       
     
  ?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]