phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgwapi/setup tables_update.inc.php,1.80


From: ceb
Subject: [Phpgroupware-cvs] phpgwapi/setup tables_update.inc.php,1.80
Date: Thu, 24 Feb 2005 15:58:49 -0000

Update of phpgwapi/setup

Modified Files:
     Branch: MAIN
            tables_update.inc.php lines: +64 -122

Log Message:
fixed various sql errors in function update_0.9.14.508 and following to create 
the contacts tables

====================================================
Index: phpgwapi/setup/tables_update.inc.php
diff -u phpgwapi/setup/tables_update.inc.php:1.79 
phpgwapi/setup/tables_update.inc.php:1.80
--- phpgwapi/setup/tables_update.inc.php:1.79   Sun Jan 16 17:40:22 2005
+++ phpgwapi/setup/tables_update.inc.php        Sun Jan 16 21:33:48 2005
@@ -762,11 +762,18 @@
                return $GLOBALS['setup_info']['phpgwapi']['currentver'];
        }

+       $test[] = '0.9.17.001';
+       function phpgwapi_upgrade0_9_17_001()
+       {
+               $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.508';
+               return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+       }
+

        $test[] = '0.9.14.508';
        function phpgwapi_upgrade0_9_14_508()
        {
-               ////global $setup_info,$phpgw_setup;
+               //global $setup_info,$phpgw_setup;
                //$db1 =& $GLOBALS['phpgw_setup']->db; $db1->auto_stripslashes 
= False; $db1->Halt_On_Error = 'yes';

                
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','person_id',array(
@@ -929,7 +936,7 @@
                        ),
                        'pk' => array('comm_descr_id'),
                        'fk' => array(),
-                       'ix' => array('descr', 'comm_type_id'),
+                       'ix' => array('descr','comm_type_id'),
                        'uc' => array()
                ));

@@ -990,116 +997,58 @@
                $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO 
phpgw_contact_comm_type (type) VALUES ('instant messaging')");
                $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO 
phpgw_contact_comm_type (type) VALUES ('url')");
                $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO 
phpgw_contact_comm_type (type) VALUES ('other')");
-

                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='email'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'home email'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'work email'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $email_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $email_type_id . 
",'home email'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $email_type_id . 
",'work email'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='phone'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'home phone'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'work phone'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'voice phone'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'msg phone'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'pager'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'bbs'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'modem'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'isdn'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'video'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $phone_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+        $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'home phone'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'work phone'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'voice phone'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'msg phone'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'pager'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'bbs'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'modem'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'isdn'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $phone_type_id . 
",'video'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='fax'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'home fax'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'work fax'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $fax_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $fax_type_id . 
",'home fax'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $fax_type_id . 
",'work fax'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='mobile phone'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'mobile (cell) phone'"
-                               .  ")");
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'car phone'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $mobile_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $mobile_type_id . 
",'mobile (cell) phone'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $mobile_type_id . 
",'car phone'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='instant messaging'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'msn'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'aim'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'yahoo'"
-                               .  ")");
-                       $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'icq'"
-                               .  ")");
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'jabber'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $instant_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $instant_type_id . 
",'msn'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $instant_type_id . 
",'aim'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $instant_type_id . 
",'yahoo'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $instant_type_id . 
",'icq'" . ')');
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $instant_type_id . 
",'jabber'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("SELECT comm_type_id FROM 
phpgw_contact_comm_type WHERE type='url'");
-                while ($GLOBALS['phpgw_setup']->oProc->next_record())
-               {
-                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES ("
-                               . 
$GLOBALS['phpgw_setup']->oProc->f('comm_type_id')
-                               . ",'website'"
-                               .  ")");
-                }
+               $GLOBALS['phpgw_setup']->oProc->next_record();
+               $url_type_id = 
intval($GLOBALS['phpgw_setup']->oProc->f('comm_type_id'));
+
+               $GLOBALS['phpgw_setup']->db->query('INSERT INTO 
phpgw_contact_comm_descr (comm_type_id,descr) VALUES (' . $url_type_id . 
",'website'" . ')');
+
                $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO 
phpgw_contact_addr_type (description) VALUES('work')");
                $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO 
phpgw_contact_addr_type (description) VALUES('home')");

@@ -1651,15 +1600,15 @@
        $test[] = '0.9.14.511';
        function phpgwapi_upgrade0_9_14_511()
        {
-               ////global $setup_info,$phpgw_setup;
+               //global $setup_info,$phpgw_setup;
                //$db1 =& $GLOBALS['phpgw_setup']->db; $db1->auto_stripslashes 
= False; $db1->Halt_On_Error = 'yes';

                /* Check if addressmaster exist  */
-               $GLOBALS['phpgw_setup']->oProc->query("SELECT config_name, 
config_value FROM phpgw_config WHERE config_name = 'addressmaster'");
-                $GLOBALS['phpgw_setup']->oProc->next_record();
-               if($GLOBALS['phpgw_setup']->oProc->next_record())
+               $GLOBALS['phpgw_setup']->db->query("SELECT config_name, 
config_value FROM phpgw_config WHERE config_name = 'addressmaster'");
+               $GLOBALS['phpgw_setup']->db->next_record();
+               if($GLOBALS['phpgw_setup']->db->f(0))
                {
-                       $addressmaster_id = 
$GLOBALS['phpgw_setup']->oProc->f('config_value');
+                       $addressmaster_id = 
$GLOBALS['phpgw_setup']->db->f('config_value');
                }
                else
                {
@@ -1693,16 +1642,15 @@
                        $GLOBALS['phpgw_setup']->db->query("INSERT INTO 
phpgw_contact_person (person_id,first_name,last_name,
                                
prefix,created_by,modified_by,created_on,modified_on) VALUES ("
                                . $contact_id
-                               . ",'" . 
$db1->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_firstname')) . 
"'"
-                               . ",'" . 
$db1->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_lastname')) . "'"
-                               . ",'" . 
$db1->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_lid')) . "'"
+                               . ",'" . 
$GLOBALS['phpgw_setup']->db->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_firstname'))
 . "'"
+                               . ",'" . 
$GLOBALS['phpgw_setup']->db->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_lastname'))
 . "'"
+                               . ",'" . 
$GLOBALS['phpgw_setup']->db->db_addslashes($GLOBALS['phpgw_setup']->oProc->f('account_lid'))
 . "'"
                                . "," . $addressmaster_id
                                . "," . $addressmaster_id
                                . "," . time()
                                . "," . time(). ')');

-                       $GLOBALS['phpgw_setup']->db->query("UPDATE 
phpgw_accounts SET person_id = ". $contact_id .
-                                                          " WHERE account_id = 
". $GLOBALS['phpgw_setup']->oProc->f('account_id'));
+                       $GLOBALS['phpgw_setup']->db->query('UPDATE 
phpgw_accounts SET person_id=' . $contact_id . ' WHERE account_id='. 
intval($GLOBALS['phpgw_setup']->oProc->f('account_id')));
                }

                $GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.14.512';
@@ -1779,10 +1727,4 @@
        {
                return $GLOBALS['setup_info']['phpgwapi']['currentver']= 
'0.9.17.500';
        }
-
-       $test[] = '0.9.17.001';
-       function phpgwapi_upgrade0_9_17_001()
-       {
-               return $GLOBALS['setup_info']['phpgwapi']['currentver']= 
'0.9.17.500';
-       }
 ?>






reply via email to

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