~kibsden/ihris-uganda/baylor-train

« back to all changes in this revision

Viewing changes to modules/Venue/lib/iHRIS_Module_Venue.php

  • Committer: Dennis Kibiye
  • Date: 2012-08-15 12:39:06 UTC
  • Revision ID: kibsden@gmail.com-20120815123906-ckmfgnpgi8xqiz9o
First Initialisation of In Service Baylor Training System Based on iHRIS Manage

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php 
 
2
/**
 
3
 * © Copyright 2008, 2009 IntraHealth International, Inc.
 
4
 * 
 
5
 * This File is part of I2CE 
 
6
 * 
 
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.
 
11
 * 
 
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.
 
16
 * 
 
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/>.
 
19
 */
 
20
/**
 
21
 *  I2CE_Module_Facility
 
22
 * @package iHRIS
 
23
 * @subpackage Common
 
24
 * @author Luke Duncan <lduncan@intrahealth.org>
 
25
 * @version 3.2.3
 
26
 * @since 3.2.3
 
27
 * @access public
 
28
 */
 
29
 
 
30
 
 
31
class iHRIS_Module_Venue extends I2CE_Module {
 
32
 
 
33
    /**
 
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
 
39
     * @return boolean
 
40
     */
 
41
    public function pre_upgrade( $old_vers, $new_vers, $new_storage ) {
 
42
        if ( I2CE_Validate::checkVersion( $old_vers, '<', '3.2.3' ) ) {
 
43
            /**
 
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.
 
47
             */
 
48
            $migrate_path = "/I2CE/formsData/migrate_data/3.2.3";
 
49
            I2CE_FormStorage::storeMigrateData( array( "venue" => 
 
50
                        array( "country", "district", "county" ) ), 
 
51
                    $migrate_path );
 
52
        }   
 
53
        return parent::pre_upgrade( $old_vers, $new_vers, $new_storage );
 
54
    }   
 
55
 
 
56
 
 
57
    /**
 
58
     * Upgrade this module if necessary
 
59
     * @param string $old_vers
 
60
     * @param string $new_vers
 
61
     * @return boolean
 
62
     */
 
63
    public function upgrade( $old_vers, $new_vers ) {
 
64
        /*
 
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.
 
67
         */
 
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";
 
72
 
 
73
           
 
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 );
 
81
                
 
82
            } else {
 
83
                return false;
 
84
            }
 
85
 
 
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";
 
90
 
 
91
            if ( !I2CE_FormStorage::migrateForm( "venue", "entry", $user, $migrate_path, false, array( "type" ) ) ) {
 
92
                return false;
 
93
            }
 
94
            unset( $class_config->iHRIS_Venue->fields->type );
 
95
 
 
96
        }
 
97
        return parent::upgrade( $old_vers, $new_vers );
 
98
    }
 
99
 
 
100
 
 
101
}
 
102
 
 
103
# Local Variables:
 
104
# mode: php
 
105
# c-default-style: "bsd"
 
106
# indent-tabs-mode: nil
 
107
# c-basic-offset: 4
 
108
# End: