[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/workflow/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 22972 2006-12-10 21:00:40Z regis_glc $ */
  13  
  14      $test[] = '1.0.1';
  15  	function workflow_upgrade1_0_1()
  16      {    
  17          # add an instance_supplements table
  18          $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_instance_supplements', 
  19              array(
  20                  'fd' => array(
  21                      'wf_supplement_id'     => array('type' => 'auto', 'precision' => '4', 'nullable' => False),
  22                      'wf_supplement_type'    => array('type' => 'varchar', 'precision' => '50', 'nullable' => True),
  23                      'wf_supplement_name'    => array('type' => 'varchar', 'precision' => '100', 'nullable' => True),
  24                      'wf_supplement_value'    => array('type' => 'text', 'nullable' => True),
  25                      'wf_workitem_id'    => array('type' => 'int', 'precision' => '4', 'nullable' => True),
  26                      'wf_supplement_blob'    => array('type' => 'blob', 'nullable' => True)
  27                  ),
  28                  'pk' => array('wf_supplement_id'),
  29                  'fk' => array(),
  30                  'ix' => array(),
  31                  'uc' => array()
  32              )
  33          );
  34          
  35          #Add in activities table is_reassign_box, is_report, default_user and default group
  36          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_is_reassign_box',array('type' => 'char', 'precision' => 1, 'nullable' => True));
  37          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_is_report',array('type' => 'char', 'precision' => 1, 'nullable' => True));
  38          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_default_user', array('type' => 'varchar', 'precision' => '200', 'nullable' => True, 'default' => '*'));
  39          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_default_group', array('type' => 'varchar', 'precision' => '200', 'nullable' => True, 'default' => '*'));
  40  
  41          #Add in instance_activities table the group field
  42          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instance_activities' ,'wf_group',array('type' => 'varchar', 'precision' => 200, 'nullable' => True, 'default' => '*'));
  43          
  44          #Add in instance table the name, and the priority, we keep the properties for the moment
  45          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_priority',array('type' => 'int', 'precision' => 4, 'nullable' => True));
  46          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_name',array('type' => 'varchar', 'precision' => 120, 'nullable' => True));
  47          
  48          #Add in workitems table note and action
  49          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_workitems' ,'wf_note',array('type' => 'text', 'precision' => 50, 'nullable' => True));
  50          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_workitems' ,'wf_action',array('type' => 'text', 'precision' => 50, 'nullable' => True));
  51          
  52          #Add in user_roles table the account type
  53          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_user_roles' ,'wf_account_type',array('type' => 'char', 'precision' => 1, 'nullable' => True, 'default' => 'u'));
  54              #modifying the sequence as well
  55              #we need a RefreshTable
  56          $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_user_roles' ,array(
  57               'fd' => array(
  58                  'wf_role_id'            => array('type' => 'auto', 'precision' => '4', 'nullable' => False),
  59                  'wf_p_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False),
  60                  'wf_user'               => array('type' => 'varchar', 'precision' => '200', 'nullable' => False),
  61                  'wf_account_type'       => array('type' => 'char', 'precision' => '1', 'nullable' => True, 'default' => 'u'),
  62               ),
  63               'pk' => array('wf_role_id', 'wf_user', 'wf_account_type'),
  64               'fk' => array(),
  65               'ix' => array(),
  66               'uc' => array()
  67          ));
  68          
  69          #updating the current version
  70          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.00.000';
  71          return $GLOBALS['setup_info']['workflow']['currentver'];
  72      }
  73  
  74      $test[] = '1.1.00.000';
  75  	function workflow_upgrade1_1_00_000()
  76      {    
  77          # add a process_config table
  78          $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_process_config', 
  79              array(
  80                  'fd' => array(
  81                      'wf_p_id'               => array('type' => 'int', 'precision' => '4', 'nullable' => False),
  82                      'wf_config_name'     => array('type' => 'varchar', 'precision' => '255', 'nullable' => False),
  83                      'wf_config_value'    => array('type' => 'text', 'nullable' => True),
  84                      'wf_config_value_int'    => array('type' => 'int', 'precision' => '4', 'nullable' => True),
  85                  ),
  86                  'pk' => array('wf_p_id','wf_config_name'),
  87                  'fk' => array(),
  88                  'ix' => array(),
  89                  'uc' => array()
  90              )
  91          );
  92          
  93          //change de default value for priority
  94          
  95  
  96          #updating the current version
  97          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.01.000';
  98          return $GLOBALS['setup_info']['workflow']['currentver'];
  99      }
 100  
 101      $test[] = '1.1.01.000';
 102  	function workflow_upgrade1_1_01_000()
 103      {    
 104          #remove unused 'new' fields in activity and add a agent key
 105           $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_is_reassign_box');
 106           $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_is_report');
 107           $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities', '', 'wf_default_group');
 108           $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activities' ,'wf_agent', array('type' => 'int', 'precision' => '4', 'nullable' => True));
 109           
 110          #add a readonly attribute to role/activty mapping
 111          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_activity_roles' ,'wf_readonly', array('type' => 'int', 'precision' => '1', 'nullable' => False, 'default'=> 0));
 112  
 113          #add a instance category attribute
 114          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_category', array('type' => 'int', 'precision'=>'4', 'nullable' => True));
 115          
 116          #updating the current version
 117          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.02.000';
 118          return $GLOBALS['setup_info']['workflow']['currentver'];
 119      }
 120  
 121  
 122      $test[] = '1.1.02.000';
 123  	function workflow_upgrade1_1_02_000()
 124      {    
 125           //drop the agent key in activity, we need something more complex in fact
 126           $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_activities','','wf_agent');
 127  
 128          //add the agent table, link between activities and agents
 129          $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_activity_agents', 
 130              array(
 131                  'fd' => array(
 132                      'wf_activity_id'    => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 133                      'wf_agent_id'         => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 134                      'wf_agent_type'        => array('type' => 'varchar', 'precision' => '15', 'nullable' => False),
 135                  ),
 136                  'pk' => array('wf_activity_id', 'wf_agent_id'),
 137                  'fk' => array(),
 138                  'ix' => array(),
 139                  'uc' => array()
 140              )
 141          );
 142           
 143          // add the mail_smtp agent table
 144          $GLOBALS['phpgw_setup']->oProc->createTable('egw_wf_agent_mail_smtp', 
 145              array(
 146                  'fd' => array(
 147                      'wf_agent_id'        => array('type' => 'auto', 'precision' => '4', 'nullable' => False),
 148                      'wf_to'         => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '%roles%'),
 149                      'wf_cc'            => array('type' => 'varchar', 'precision' => '255', 'nullable' => True),
 150                      'wf_bcc'        => array('type' => 'varchar', 'precision' => '255', 'nullable' => True),
 151                      'wf_from'        => array('type' => 'varchar', 'precision' => '255', 'nullable' => True, 'default' => '%user%'),
 152                      'wf_replyTo'        => array('type' => 'varchar', 'precision' => '255', 'nullable' => True, 'default' => '%user%'),
 153                      'wf_subject'        => array('type' => 'varchar', 'precision' => '255', 'nullable' => True),
 154                      'wf_message'        => array('type' => 'text', 'nullable' => True),
 155                      'wf_send_mode'        => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default' => 0),
 156                  ),
 157                  'pk' => array('wf_agent_id'),
 158                  'fk' => array(),
 159                  'ix' => array(),
 160                  'uc' => array()
 161              )
 162          );
 163           
 164          #updating the current version
 165          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.03.000';
 166          return $GLOBALS['setup_info']['workflow']['currentver'];
 167      }
 168  
 169      $test[] = '1.1.03.000';
 170  	function workflow_upgrade1_1_03_000()
 171      {    
 172          //change type of wf_next_user to handle serialization -> multiple states if instance has multiple activities running
 173          //we will loose current wf_next_activity but the update should'nt be made when instances are running and this is
 174          //a field needed only at runtime, normally.
 175          $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_instances','','wf_next_activity');
 176          $GLOBALS['phpgw_setup']->oProc->AddColumn('egw_wf_instances' ,'wf_next_activity', array('type' => 'blob', 'nullable' => True));
 177  
 178          #updating the current version
 179          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.04.000';
 180          return $GLOBALS['setup_info']['workflow']['currentver'];
 181      }
 182  
 183      $test[] = '1.1.04.000';
 184  	function workflow_upgrade1_1_04_000()
 185      {    
 186          //unused column. Notice I had to do this manually with MAIN versions of phpgwapi/class.schema_proc.inc.php
 187          $GLOBALS['phpgw_setup']->oProc->DropColumn('egw_wf_instance_activities','','wf_group');
 188  
 189          //Adding some indexes on some tables:
 190          
 191          //we need a RefreshTable for that
 192          $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_instance_activities' ,array(
 193              'fd' => array(
 194                  'wf_instance_id'    => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 195                  'wf_activity_id'    => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 196                  'wf_started'        => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 197                  'wf_ended'        => array('type' => 'int', 'precision' => '4', 'nullable' => True),
 198                  'wf_user'        => array('type' => 'varchar', 'precision' => '200', 'nullable' => True),
 199                  'wf_status'        => array('type' => 'varchar', 'precision' => '25', 'nullable' => True),
 200              ),
 201              'pk' => array('wf_instance_id', 'wf_activity_id'),
 202              'fk' => array(),
 203              'ix' => array(array('wf_activity_id'),array('wf_instance_id'), array('wf_user')),
 204              'uc' => array()
 205          ));
 206          // we change some indexes
 207          // we need a RefreshTable
 208          $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_instances' ,array(
 209              'fd' => array(
 210                  'wf_instance_id'    => array('type' => 'auto', 'precision' => '4', 'nullable' => False),
 211                  'wf_p_id'        => array('type' => 'int', 'precision' => '4', 'nullable' => False),
 212                  'wf_started'        => array('type' => 'int', 'precision' => '4', 'nullable' => True),
 213                  'wf_owner'        => array('type' => 'varchar', 'precision' => '200', 'nullable' => True),
 214                  'wf_next_activity'    => array('type' => 'blob', 'nullable' => True),
 215                  'wf_next_user'        => array('type' => 'varchar', 'precision' => '200', 'nullable' => True),
 216                  'wf_ended'        => array('type' => 'int', 'precision' => '4', 'nullable' => True),
 217                  'wf_status'        => array('type' => 'varchar', 'precision' => '25', 'nullable' => True),
 218                  'wf_priority'        => array('type' => 'int', 'precision' => '4', 'nullable' => True, 'default'=> 0),
 219                  'wf_properties'        => array('type' => 'blob', 'nullable' => True),
 220                  'wf_name'        => array('type' => 'varchar', 'precision'=>'120', 'nullable' => True),
 221                  'wf_category'        => array('type' => 'int', 'precision'=>'4', 'nullable' => True),
 222              ),
 223              'pk' => array('wf_instance_id'),
 224              'fk' => array(),
 225              'ix' => array(array('wf_owner'), array('wf_status')),
 226              'uc' => array()
 227          ));
 228          // we change some indexes
 229          // we need a RefreshTable
 230          $GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_wf_processes' ,array(
 231              'fd' => array(
 232                  'wf_p_id'        => array('type' => 'auto', 'precision' => '4', 'nullable' => False),
 233                  'wf_name'        => array('type' => 'varchar', 'precision' => '80', 'nullable' => True),
 234                  'wf_is_valid'        => array('type' => 'char', 'precision' => '1', 'nullable' => True),
 235                  'wf_is_active'        => array('type' => 'char', 'precision' => '1', 'nullable' => True),
 236                  'wf_version'        => array('type' => 'varchar', 'precision' => '12', 'nullable' => True),
 237                  'wf_description'    => array('type' => 'text', 'nullable' => True),
 238                  'wf_last_modif'        => array('type' => 'int', 'precision' => '4', 'nullable' => True),
 239                  'wf_normalized_name'    => array('type' => 'varchar', 'precision' => '80', 'nullable' => True),
 240              ),
 241              'pk' => array('wf_p_id'),
 242              'fk' => array(),
 243              'ix' => array(array('wf_p_id','wf_is_active')),
 244              'uc' => array()
 245          ));
 246          
 247          #updating the current version
 248          $GLOBALS['setup_info']['workflow']['currentver'] = '1.1.05.000';
 249          return $GLOBALS['setup_info']['workflow']['currentver'];
 250      }
 251  
 252      $test[] = '1.1.05.000';
 253  	function workflow_upgrade1_1_05_000()
 254      {    
 255          #serialized data is now stored with a Base64 encoding to ensure it work in all case (even with \' for example)
 256          //We gonna make our updates manually here:
 257          //they were an error (quotes) in the first version of this upgrade, if your database is MySQL you should
 258          //set the version to 1.1.05.000 in egw_applications and rerun this upgrade for old properties
 259          $GLOBALS['egw']->ADOdb->SetFetchMode(ADODB_FETCH_ASSOC);
 260          $result = $GLOBALS['egw']->ADOdb->query('select * from egw_wf_instances');
 261          if (!(empty($result)))
 262          {
 263              while ($res = $result->fetchRow())
 264              {
 265                  $new_props = base64_encode($res['wf_properties']);
 266                  $new_next = base64_encode($res['wf_next_activity']);
 267                  $ok =  $GLOBALS['egw']->ADOdb->query(
 268                      'update egw_wf_instances set wf_properties = ?, wf_next_activity=? where wf_instance_id = ?',
 269                      array($new_props,$new_next, (int)$res['wf_instance_id'])
 270                  );
 271              }
 272          }
 273          $result = $GLOBALS['egw']->ADOdb->query('select * from egw_wf_workitems');
 274          if (!(empty($result)))
 275          {
 276              while ($res = $result->fetchRow())
 277              {
 278                  $new_props = base64_encode($res['wf_properties']);
 279                  $ok =  $GLOBALS['egw']->ADOdb->query(
 280                      'update egw_wf_workitems set wf_properties = ?  where wf_item_id = ?',
 281                      array($new_props, (int)$res['wf_item_id'])
 282                  );
 283              }
 284          }
 285  
 286          #updating the current version
 287          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.000';
 288          return $GLOBALS['setup_info']['workflow']['currentver'];
 289      }
 290  
 291      $test[] = '1.2.00.000';
 292  	function workflow_upgrade1_2_00_000()
 293      {
 294          #updating the current version
 295          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.001';
 296          return $GLOBALS['setup_info']['workflow']['currentver'];
 297      }
 298      $test[] = '1.2.00.001';
 299  	function workflow_upgrade1_2_00_001()
 300      {
 301          #updating the current version
 302          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.00.002';
 303          return $GLOBALS['setup_info']['workflow']['currentver'];
 304      }
 305      $test[] = '1.2.00.002';
 306  	function workflow_upgrade1_2_00_002()
 307      {
 308          #groups Ids are now negative in egroupware, we need to negative all user id which is positive and of type 'g'
 309          #code inspired by phpgwapi/setup/table_update.inc.php
 310          // convert all positive group id's to negative ones
 311          // this allows duplicate id for users and groups in ldap
 312          $where = false;
 313          list($table,$col,$where) = $data;
 314          $table = 'egw_wf_user_roles';
 315          $col = 'wf_user';
 316          $where = "wf_account_type='g' and (SUBSTR($col,1,1) <> '-')";
 317          $set = $col.'='.$GLOBALS['egw_setup']->db->concat("'-'",$col);
 318          $query = "UPDATE $table SET $set WHERE $where";
 319          //echo "<p>debug query: $query</p>\n";
 320          $GLOBALS['egw_setup']->db->query($query,__LINE__,__FILE__);
 321  
 322          #updating the current version
 323          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.000';
 324          return $GLOBALS['setup_info']['workflow']['currentver'];
 325      }
 326      
 327      $test[] = '1.2.01.000';
 328          function workflow_upgrade1_2_01_000()
 329          {
 330                  #updating the current version
 331                  $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.001';
 332                  return $GLOBALS['setup_info']['workflow']['currentver'];
 333          }
 334  
 335          $test[] = '1.2.01.001';
 336          function workflow_upgrade1_2_01_001()
 337          {
 338                  #updating the current version
 339                  $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.002';
 340                  return $GLOBALS['setup_info']['workflow']['currentver'];
 341          }
 342  
 343          $test[] = '1.2.01.002';
 344          function workflow_upgrade1_2_01_002()
 345          {
 346                  #updating the current version
 347                  $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.003';
 348                  return $GLOBALS['setup_info']['workflow']['currentver'];
 349          }
 350  
 351      $test[] = '1.2.01.003';
 352  	function workflow_upgrade1_2_01_003()
 353      {
 354          #updating the current version
 355          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.004';
 356          return $GLOBALS['setup_info']['workflow']['currentver'];
 357      }
 358  
 359      $test[] = '1.2.01.004';
 360          function workflow_upgrade1_2_01_004()
 361          {
 362                  #updating the current version
 363                  $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.005';
 364                  return $GLOBALS['setup_info']['workflow']['currentver'];
 365          }
 366  
 367          $test[] = '1.2.01.005';
 368          function workflow_upgrade1_2_01_005()
 369          {
 370                  #updating the current version
 371                  $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.006';
 372                  return $GLOBALS['setup_info']['workflow']['currentver'];
 373          }
 374  
 375      $test[] = '1.2.01.006';
 376  	function workflow_upgrade1_2_01_006()
 377      {
 378          #updating the current version
 379          $GLOBALS['setup_info']['workflow']['currentver'] = '1.2.01.007';
 380          return $GLOBALS['setup_info']['workflow']['currentver'];
 381      }
 382  ?>


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