3
* © Copyright 2008, 2009 IntraHealth International, Inc.
5
* This File is part of I2CE
7
* I2CE is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
* I2CE_Module_Facility
24
* @author Luke Duncan <lduncan@intrahealth.org>
31
class iHRIS_Module_Venue extends I2CE_Module {
34
* Run the pre upgrade for this module. This can use the old config data before it
35
* has been changed from the config.
36
* @param string $old_vers
37
* @param string $new_vers
38
* @param I2CE_MagicDataNode $new_storage
41
public function pre_upgrade( $old_vers, $new_vers, $new_storage ) {
42
if ( I2CE_Validate::checkVersion( $old_vers, '<', '3.2.3' ) ) {
44
* In 3.2.3 some lists were moved to magicdata storage so we need to save
45
* any old record ids for the old lists for later reference before any field
46
* types get changed in magic data.
48
$migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
49
I2CE_FormStorage::storeMigrateData( array( "venue" =>
50
array( "country", "district", "county" ) ),
53
return parent::pre_upgrade( $old_vers, $new_vers, $new_storage );
58
* Upgrade this module if necessary
59
* @param string $old_vers
60
* @param string $new_vers
63
public function upgrade( $old_vers, $new_vers ) {
65
* In 3.2.3 we moved some lists from entry to magicdata storage so we need to get the
66
* old data from entry and save them to the new form storage.
68
if ( I2CE_Validate::checkVersion( $old_vers, '<', '3.2.3' ) ) {
69
$user = new I2CE_User( 1, false, false, false );
70
$class_config = I2CE::getConfig()->modules->forms->formClasses;
71
$migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
74
if ( I2CE_FormStorage::migrateForm( "venue", "entry", $user, $migrate_path,
75
false, array( "type" ),
76
array( "location" => array( "county" => "county",
77
"district" => "district", "country" => "country" ) ) ) ) {
78
unset( $class_config->iHRIS_Venue->fields->country );
79
unset( $class_config->iHRIS_Venue->fields->district );
80
unset( $class_config->iHRIS_Venue->fields->county );
86
} elseif ( I2CE_Validate::checkVersion( $old_vers, '<', '3.2.4' ) ) {
87
$user = new I2CE_User( 1, false, false, false );
88
$class_config = I2CE::getConfig()->modules->forms->formClasses;
89
$migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
91
if ( !I2CE_FormStorage::migrateForm( "venue", "entry", $user, $migrate_path, false, array( "type" ) ) ) {
94
unset( $class_config->iHRIS_Venue->fields->type );
97
return parent::upgrade( $old_vers, $new_vers );
105
# c-default-style: "bsd"
106
# indent-tabs-mode: nil