[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/infolog/setup/ -> tables_update.inc.php (source)

   1  <?php
   2    /**************************************************************************\
   3    * eGroupWare - Setup                                                     *
   4    * http://www.egroupware.org                                              *
   5    * --------------------------------------------                             *
   6    *  This program is free software; you can redistribute it and/or modify it *
   7    *  under the terms of the GNU General Public License as published by the   *
   8    *  Free Software Foundation; either version 2 of the License, or (at your  *
   9    *  option) any later version.                                              *
  10    \**************************************************************************/
  11  
  12    /* $Id: tables_update.inc.php 22504 2006-09-26 04:54:53Z ralfbecker $ */
  13  
  14      $test[] = '0.9.11';
  15  	function infolog_upgrade0_9_11()
  16      {
  17          $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_infolog','info_datecreated','info_datemodified');
  18          $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_infolog','info_event_id',array(
  19              'type' => 'int',
  20              'precision' => '4',
  21              'default' => '0',
  22              'nullable' => False
  23          ));
  24  
  25  
  26          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.001';
  27          return $GLOBALS['setup_info']['infolog']['currentver'];
  28      }
  29  
  30  
  31      $test[] = '0.9.15.001';
  32  	function infolog_upgrade0_9_15_001()
  33      {
  34          $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_links',array(
  35              'fd' => array(
  36                  'link_id' => array('type' => 'auto','nullable' => False),
  37                  'link_app1' => array('type' => 'varchar','precision' => '25','nullable' => False),
  38                  'link_id1' => array('type' => 'varchar','precision' => '50','nullable' => False),
  39                  'link_app2' => array('type' => 'varchar','precision' => '25','nullable' => False),
  40                  'link_id2' => array('type' => 'varchar','precision' => '50','nullable' => False),
  41                  'link_remark' => array('type' => 'varchar','precision' => '50','nullable' => True),
  42                  'link_lastmod' => array('type' => 'int','precision' => '4','nullable' => False),
  43                  'link_owner' => array('type' => 'int','precision' => '4','nullable' => False)
  44              ),
  45              'pk' => array('link_id'),
  46              'fk' => array(),
  47              'ix' => array(),
  48              'uc' => array()
  49          ));
  50  
  51  
  52          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.002';
  53          return $GLOBALS['setup_info']['infolog']['currentver'];
  54      }
  55  
  56  
  57      $test[] = '0.9.15.002';
  58  	function infolog_upgrade0_9_15_002()
  59      {
  60          //echo "<p>infolog_upgrade0_9_15_002</p>\n";
  61          $insert = 'INSERT INTO phpgw_links (link_app1,link_id1,link_app2,link_id2,link_remark,link_lastmod,link_owner) ';
  62          $select = "SELECT 'infolog',info_id,'addressbook',info_addr_id,info_from,info_datemodified,info_owner FROM phpgw_infolog WHERE info_addr_id != 0";
  63          //echo "<p>copying address-links: $insert.$select</p>\n";
  64          $GLOBALS['phpgw_setup']->oProc->query($insert.$select);
  65          $select = "SELECT 'infolog',info_id,'projects',info_proj_id,'',info_datemodified,info_owner FROM phpgw_infolog WHERE info_proj_id != 0";
  66          //echo "<p>copying projects-links: $insert.$select</p>\n";
  67          $GLOBALS['phpgw_setup']->oProc->query($insert.$select);
  68          $select = "SELECT 'infolog',info_id,'calendar',info_event_id,'',info_datemodified,info_owner FROM phpgw_infolog WHERE info_event_id != 0";
  69          //echo "<p>copying calendar-links: $insert.$select</p>\n";
  70          $GLOBALS['phpgw_setup']->oProc->query($insert.$select);
  71  
  72          $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
  73              'fd' => array(
  74                  'info_id' => array('type' => 'auto','nullable' => False),
  75                  'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
  76                  'info_proj_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  77                  'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
  78                  'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
  79                  'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
  80                  'info_des' => array('type' => 'text','nullable' => True),
  81                  'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
  82                  'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  83                  'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
  84                  'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  85                  'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
  86                  'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  87                  'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  88                  'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  89                  'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
  90                  'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  91                  'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
  92                  'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
  93                  'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not'),
  94                  'info_event_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False)
  95              ),
  96              'pk' => array('info_id'),
  97              'fk' => array(),
  98              'ix' => array(),
  99              'uc' => array()
 100          ),'info_addr_id');
 101          $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
 102              'fd' => array(
 103                  'info_id' => array('type' => 'auto','nullable' => False),
 104                  'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
 105                  'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
 106                  'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
 107                  'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
 108                  'info_des' => array('type' => 'text','nullable' => True),
 109                  'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
 110                  'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 111                  'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
 112                  'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 113                  'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
 114                  'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 115                  'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 116                  'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 117                  'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
 118                  'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 119                  'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 120                  'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
 121                  'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not'),
 122                  'info_event_id' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False)
 123              ),
 124              'pk' => array('info_id'),
 125              'fk' => array(),
 126              'ix' => array(),
 127              'uc' => array()
 128          ),'info_proj_id');
 129          $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
 130              'fd' => array(
 131                  'info_id' => array('type' => 'auto','nullable' => False),
 132                  'info_type' => array('type' => 'varchar','precision' => '255','default' => 'task','nullable' => False),
 133                  'info_from' => array('type' => 'varchar','precision' => '64','nullable' => True),
 134                  'info_addr' => array('type' => 'varchar','precision' => '64','nullable' => True),
 135                  'info_subject' => array('type' => 'varchar','precision' => '64','nullable' => True),
 136                  'info_des' => array('type' => 'text','nullable' => True),
 137                  'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
 138                  'info_responsible' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 139                  'info_access' => array('type' => 'varchar','precision' => '10','nullable' => True,'default' => 'public'),
 140                  'info_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 141                  'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
 142                  'info_startdate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 143                  'info_enddate' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 144                  'info_id_parent' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 145                  'info_pri' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'normal'),
 146                  'info_time' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 147                  'info_bill_cat' => array('type' => 'int','precision' => '4','default' => '0','nullable' => False),
 148                  'info_status' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'done'),
 149                  'info_confirm' => array('type' => 'varchar','precision' => '255','nullable' => True,'default' => 'not')
 150              ),
 151              'pk' => array('info_id'),
 152              'fk' => array(),
 153              'ix' => array(),
 154              'uc' => array()
 155          ),'info_event_id');
 156  
 157  
 158          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.003';
 159          return $GLOBALS['setup_info']['infolog']['currentver'];
 160      }
 161  
 162  
 163      $test[] = '0.9.15.003';
 164  	function infolog_upgrade0_9_15_003()
 165      {
 166          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_type',array(
 167              'type' => 'varchar',
 168              'precision' => '10',
 169              'nullable' => False,
 170              'default' => 'task'
 171          ));
 172          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_pri',array(
 173              'type' => 'varchar',
 174              'precision' => '10',
 175              'nullable' => True,
 176              'default' => 'normal'
 177          ));
 178          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_status',array(
 179              'type' => 'varchar',
 180              'precision' => '10',
 181              'nullable' => True,
 182              'default' => 'done'
 183          ));
 184          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_confirm',array(
 185              'type' => 'varchar',
 186              'precision' => '10',
 187              'nullable' => True,
 188              'default' => 'not'
 189          ));
 190          $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_infolog','info_modifier',array(
 191              'type' => 'int',
 192              'precision' => '4',
 193              'nullable' => False,
 194              'default' => '0'
 195          ));
 196          $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_infolog','info_link_id',array(
 197              'type' => 'int',
 198              'precision' => '4',
 199              'nullable' => False,
 200              'default' => '0'
 201          ));
 202  
 203          // ORDER BY link_app2 DESC gives addressbook the highes precedens, use ASC for projects
 204          $GLOBALS['phpgw_setup']->oProc->query("SELECT link_id,link_id1 FROM phpgw_links WHERE link_app1='infolog' ORDER BY link_app2 DESC");
 205          $links = array();
 206          while ($GLOBALS['phpgw_setup']->oProc->next_record())
 207          {
 208              $links[$GLOBALS['phpgw_setup']->oProc->f(1)] = $GLOBALS['phpgw_setup']->oProc->f(0);
 209          }
 210          reset($links);
 211          while (list($info_id,$link_id) = each($links))
 212          {
 213              $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_infolog SET info_link_id=$link_id WHERE info_id=$info_id");
 214          }
 215  
 216          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.004';
 217          return $GLOBALS['setup_info']['infolog']['currentver'];
 218      }
 219      
 220      $test[] = '0.9.15.004';
 221  	function infolog_upgrade0_9_15_004()
 222      {
 223          // this update correctes wrong escapes of ' and " in the past
 224          //
 225          $db2 = $GLOBALS['phpgw_setup']->db;    // we need a 2. result-set
 226          
 227          $to_correct = array('info_from','info_subject','info_des');
 228          foreach ($to_correct as $col)
 229          {
 230              $GLOBALS['phpgw_setup']->oProc->query("SELECT info_id,$col FROM phpgw_infolog WHERE $col LIKE '%\\'%' OR $col LIKE '%\"%'");
 231              while ($GLOBALS['phpgw_setup']->oProc->next_record())
 232              {
 233                  $db2->query("UPDATE phpgw_infolog SET $col='".$db2->db_addslashes(stripslashes($GLOBALS['phpgw_setup']->oProc->f($col))).
 234                      "' WHERE info_id=".$GLOBALS['phpgw_setup']->oProc->f('info_id'));
 235              }
 236          }
 237          
 238          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.005';
 239          return $GLOBALS['setup_info']['infolog']['currentver'];
 240      }
 241  
 242  
 243      $test[] = '0.9.15.005';
 244  	function infolog_upgrade0_9_15_005()
 245      {
 246          $GLOBALS['phpgw_setup']->oProc->CreateTable('phpgw_infolog_extra',array(
 247              'fd' => array(
 248                  'info_id' => array('type' => 'int','precision' => '4','nullable' => False),
 249                  'info_extra_name' => array('type' => 'varchar','precision' => '32','nullable' => False),
 250                  'info_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '')
 251              ),
 252              'pk' => array('info_id','info_extra_name'),
 253              'fk' => array(),
 254              'ix' => array(),
 255              'uc' => array()
 256          ));
 257  
 258  
 259          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.006';
 260          return $GLOBALS['setup_info']['infolog']['currentver'];
 261      }
 262  
 263  
 264      // the following series of updates add some indices, to speedup the selects
 265  
 266      $test[] = '0.9.15.006';
 267  	function infolog_upgrade0_9_15_006()
 268      {
 269          $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_links',array(
 270              'fd' => array(
 271                  'link_id' => array('type' => 'auto','nullable' => False),
 272                  'link_app1' => array('type' => 'varchar','precision' => '25','nullable' => False),
 273                  'link_id1' => array('type' => 'varchar','precision' => '50','nullable' => False),
 274                  'link_app2' => array('type' => 'varchar','precision' => '25','nullable' => False),
 275                  'link_id2' => array('type' => 'varchar','precision' => '50','nullable' => False),
 276                  'link_remark' => array('type' => 'varchar','precision' => '50'),
 277                  'link_lastmod' => array('type' => 'int','precision' => '4','nullable' => False),
 278                  'link_owner' => array('type' => 'int','precision' => '4','nullable' => False)
 279              ),
 280              'pk' => array('link_id'),
 281              'fk' => array(),
 282              'ix' => array(array('link_app1','link_id1','link_lastmod'),array('link_app2','link_id2','link_lastmod')),
 283              'uc' => array()
 284          ));
 285  
 286          $GLOBALS['setup_info']['infolog']['currentver'] = '0.9.15.007';
 287          return $GLOBALS['setup_info']['infolog']['currentver'];
 288      }
 289  
 290  
 291      $test[] = '0.9.15.007';
 292  	function infolog_upgrade0_9_15_007()
 293      {
 294          $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_infolog',array(
 295              'fd' => array(
 296                  'info_id' => array('type' => 'auto','nullable' => False),
 297                  'info_type' => array('type' => 'varchar','precision' => '10','nullable' => False,'default' => 'task'),
 298                  'info_from' => array('type' => 'varchar','precision' => '64'),
 299                  'info_addr' => array('type' => 'varchar','precision' => '64'),
 300                  'info_subject' => array('type' => 'varchar','precision' => '64'),
 301                  'info_des' => array('type' => 'text'),
 302                  'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
 303                  'info_responsible' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 304                  'info_access' => array('type' => 'varchar','precision' => '10','default' => 'public'),
 305                  'info_cat' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 306                  'info_datemodified' => array('type' => 'int','precision' => '4','nullable' => False),
 307                  'info_startdate' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 308                  'info_enddate' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 309                  'info_id_parent' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 310                  'info_pri' => array('type' => 'varchar','precision' => '10','default' => 'normal'),
 311                  'info_time' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 312                  'info_bill_cat' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 313                  'info_status' => array('type' => 'varchar','precision' => '10','default' => 'done'),
 314                  'info_confirm' => array('type' => 'varchar','precision' => '10','default' => 'not'),
 315                  'info_modifier' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 316                  'info_link_id' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
 317              ),
 318              'pk' => array('info_id'),
 319              'fk' => array(),
 320              'ix' => array(array('info_owner','info_responsible','info_status','info_startdate'),array('info_id_parent','info_owner','info_responsible','info_status','info_startdate')),
 321              'uc' => array()
 322          ));
 323          
 324          // we dont need to do update 0.9.15.008, as UpdateSequenze is called now by RefreshTable
 325          $GLOBALS['setup_info']['infolog']['currentver'] = '1.0.0';
 326          return $GLOBALS['setup_info']['infolog']['currentver'];
 327      }
 328  
 329      
 330      $test[] = '0.9.15.008';
 331  	function infolog_upgrade0_9_15_008()
 332      {
 333          // update the sequenzes for refreshed tables (postgres only)
 334          $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_infolog','info_id');
 335          $GLOBALS['phpgw_setup']->oProc->UpdateSequence('phpgw_links','link_id');
 336  
 337          $GLOBALS['setup_info']['infolog']['currentver'] = '1.0.0';
 338          return $GLOBALS['setup_info']['infolog']['currentver'];
 339      }
 340  
 341  
 342      $test[] = '1.0.0';
 343  	function infolog_upgrade1_0_0()
 344      {
 345          // longer columns to cope with multibyte charsets
 346          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_type',array(
 347              'type' => 'varchar',
 348              'precision' => '40',
 349              'nullable' => False,
 350              'default' => 'task'
 351          ));
 352          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_from',array(
 353              'type' => 'varchar',
 354              'precision' => '255'
 355          ));
 356          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_addr',array(
 357              'type' => 'varchar',
 358              'precision' => '255'
 359          ));
 360          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_subject',array(
 361              'type' => 'varchar',
 362              'precision' => '255'
 363          ));
 364          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_status',array(
 365              'type' => 'varchar',
 366              'precision' => '40',
 367              'default' => 'done'
 368          ));
 369  
 370          $GLOBALS['setup_info']['infolog']['currentver'] = '1.0.0.001';
 371          return $GLOBALS['setup_info']['infolog']['currentver'];
 372      }
 373  
 374  
 375      $test[] = '1.0.0.001';
 376  	function infolog_upgrade1_0_0_001()
 377      {
 378          $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_infolog','info_time','info_planned_time');
 379          $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_infolog','info_bill_cat','info_used_time');
 380          // timestamps have to be 8byte ints
 381          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_datemodified',array(
 382              'type' => 'int',
 383              'precision' => '8',
 384              'nullable' => False
 385          ));
 386          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_startdate',array(
 387              'type' => 'int',
 388              'precision' => '8',
 389              'nullable' => False,
 390              'default' => '0'
 391          ));
 392          $GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_infolog','info_enddate',array(
 393              'type' => 'int',
 394              'precision' => '8',
 395              'nullable' => False,
 396              'default' => '0'
 397          ));
 398          
 399          // setting numerical priority 3=urgent, 2=high, 1=normal, 0=
 400          $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_infolog','info_priority',array(
 401              'type' => 'int',
 402              'precision' => '2',
 403              'default' => '1'
 404          ));
 405          $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_infolog SET info_priority=(CASE WHEN info_pri='urgent' THEN 3 WHEN info_pri='high' THEN 2 WHEN info_pri='low' THEN 0 ELSE 1 END)",__LINE__,__FILE__);
 406  
 407          $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_infolog',array(
 408              'fd' => array(
 409                  'info_id' => array('type' => 'auto','nullable' => False),
 410                  'info_type' => array('type' => 'varchar','precision' => '40','nullable' => False,'default' => 'task'),
 411                  'info_from' => array('type' => 'varchar','precision' => '255'),
 412                  'info_addr' => array('type' => 'varchar','precision' => '255'),
 413                  'info_subject' => array('type' => 'varchar','precision' => '255'),
 414                  'info_des' => array('type' => 'text'),
 415                  'info_owner' => array('type' => 'int','precision' => '4','nullable' => False),
 416                  'info_responsible' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 417                  'info_access' => array('type' => 'varchar','precision' => '10','default' => 'public'),
 418                  'info_cat' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 419                  'info_datemodified' => array('type' => 'int','precision' => '8','nullable' => False),
 420                  'info_startdate' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
 421                  'info_enddate' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'),
 422                  'info_id_parent' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 423                  'info_planned_time' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 424                  'info_used_time' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 425                  'info_status' => array('type' => 'varchar','precision' => '40','default' => 'done'),
 426                  'info_confirm' => array('type' => 'varchar','precision' => '10','default' => 'not'),
 427                  'info_modifier' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 428                  'info_link_id' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
 429                  'info_priority' => array('type' => 'int','precision' => '2','default' => '1')
 430              ),
 431              'pk' => array('info_id'),
 432              'fk' => array(),
 433              'ix' => array(array('info_owner','info_responsible','info_status','info_startdate'),array('info_id_parent','info_owner','info_responsible','info_status','info_startdate')),
 434              'uc' => array()
 435          ),'info_pri');
 436          
 437          $GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_infolog','egw_infolog');
 438          $GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_infolog_extra','egw_infolog_extra');
 439          // only rename links table, if it has not been moved into the API and therefor been already renamed by the API update
 440          if ($GLOBALS['phpgw_setup']->oProc->GetTableDefinition('phpgw_links'))
 441          {
 442              $GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_links','egw_links');
 443          }
 444          $GLOBALS['setup_info']['infolog']['currentver'] = '1.0.1.001';
 445          return $GLOBALS['setup_info']['infolog']['currentver'];
 446      }
 447  
 448  
 449      $test[] = '1.0.1.001';
 450  	function infolog_upgrade1_0_1_001()
 451      {
 452          $GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_infolog','info_responsible',array(
 453              'type' => 'varchar',
 454              'precision' => '255',
 455              'nullable' => False,
 456              'default' => '0'
 457          ));
 458  
 459          $GLOBALS['setup_info']['infolog']['currentver'] = '1.0.1.002';
 460          return $GLOBALS['setup_info']['infolog']['currentver'];
 461      }
 462  
 463  
 464      $test[] = '1.0.1.002';
 465  	function infolog_upgrade1_0_1_002()
 466      {
 467          $GLOBALS['setup_info']['infolog']['currentver'] = '1.2';
 468          return $GLOBALS['setup_info']['infolog']['currentver'];
 469      }
 470  
 471  
 472      $test[] = '1.2';
 473  	function infolog_upgrade1_2()
 474      {
 475          $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','pl_id',array(
 476              'type' => 'int',
 477              'precision' => '4'
 478          ));
 479  
 480          $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','info_price',array(
 481              'type' => 'float',
 482              'precision' => '8'
 483          ));
 484  
 485          return $GLOBALS['setup_info']['infolog']['currentver'] = '1.2.001';
 486      }
 487  
 488  
 489      $test[] = '1.2.001';
 490  	function infolog_upgrade1_2_001()
 491      {
 492          $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','info_percent',array(
 493              'type' => 'int',
 494              'precision' => '2',
 495              'default' => '0'
 496          ));
 497          $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','info_datecompleted',array(
 498              'type' => 'int',
 499              'precision' => '8'
 500          ));
 501          $GLOBALS['egw_setup']->oProc->AddColumn('egw_infolog','info_location',array(
 502              'type' => 'varchar',
 503              'precision' => '255'
 504          ));
 505          
 506          // all not explicit named stati have the default percent 0
 507          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_percent=10 WHERE info_status='ongoing'",__LINE__,__FILE__);
 508          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_percent=50 WHERE info_status='will-call'",__LINE__,__FILE__);
 509  
 510          for($p = 0; $p <= 90; $p += 10)
 511          {
 512              $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_percent=$p,info_status='".(!$p ? 'not-started' : 'ongoing').
 513                  "' WHERE info_status = '$p%'",__LINE__,__FILE__);
 514          }
 515          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_datecompleted=info_datemodified,info_percent=100 WHERE info_status IN ('done','billed','100%')",__LINE__,__FILE__);
 516          
 517          // remove the percentages from the custom stati, if they exist
 518          $config =& CreateObject('phpgwapi.config','infolog');
 519          $config->read_repository();
 520          if (is_array($config->config_data['status']['task']))
 521          {
 522              $config->config_data['status']['task'] = array_diff($config->config_data['status']['task'],
 523                  array('0%','10%','20%','30%','40%','50%','60%','70%','80%','90%','100%'));
 524              $config->save_repository();
 525          }
 526          return $GLOBALS['setup_info']['infolog']['currentver'] = '1.2.002';
 527      }
 528  
 529  
 530      $test[] = '1.2.002';
 531  	function infolog_upgrade1_2_002()
 532      {
 533          // change the phone-status: call --> not-started, will-call --> ongoing to be able to sync them 
 534          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_status='not-started' WHERE info_status='call'",__LINE__,__FILE__);
 535          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_status='ongoing' WHERE info_status='will-call'",__LINE__,__FILE__);
 536          
 537          // remove the call and will-call from the custom stati, if they exist
 538          $config =& CreateObject('phpgwapi.config','infolog');
 539          $config->read_repository();
 540          if (is_array($config->config_data['status']['phone']))
 541          {
 542              unset($config->config_data['status']['phone']['call']);
 543              unset($config->config_data['status']['phone']['will-call']);
 544  
 545              $config->save_repository();
 546          }
 547          return $GLOBALS['setup_info']['infolog']['currentver'] = '1.2.003';
 548      }
 549  
 550  
 551      $test[] = '1.2.003';
 552  	function infolog_upgrade1_2_003()
 553      {
 554          // fix wrong info_responsible='' --> '0'
 555          $GLOBALS['egw_setup']->oProc->query("UPDATE egw_infolog SET info_responsible='0' WHERE info_responsible=''",__LINE__,__FILE__);
 556  
 557          return $GLOBALS['setup_info']['infolog']['currentver'] = '1.2.004';
 558      }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7