Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
calendar_event_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
39  {
40  $this->Asset_Management($pm);
41 
42  $this->vars = Array(
43  'name' => Array(
44  'added' => '0.0.1',
45  'type' => 'text',
46  'default' => '',
47  'description' => 'The name of the event',
48  'is_admin' => FALSE,
49  'is_contextable' => TRUE,
50  ),
51  'description' => Array(
52  'added' => '0.0.1',
53  'type' => 'wysiwyg',
54  'default' => '',
55  'description' => 'Description of the event',
56  'is_admin' => FALSE,
57  'is_contextable' => TRUE,
58  ),
59  'start_date' => Array(
60  'added' => '0.0.1',
61  'type' => 'datetime',
62  'default' => '---------- --:--:--',
63  'parameters' => Array(
64  'allow_null' => TRUE,
65  'show' => Array('d','m','y','h','i'),
66  ),
67  'description' => 'The starting date and/or time of the event',
68  'update_fn' => '',
69  'is_admin' => FALSE,
70  ),
71  'end_date' => Array(
72  'added' => '0.0.1',
73  'type' => 'datetime',
74  'default' => '---------- --:--:--',
75  'parameters' => Array('allow_null' => TRUE),
76  'description' => 'The ending date and/or time of the event',
77  'update_fn' => '',
78  'is_admin' => FALSE,
79  ),
80  );
81 
82  }//end constructor
83 
84 
91  function _getFileList()
92  {
93  return Array(
94  'js/date_chooser.js',
95  );
96 
97  }//end _getFileList()
98 
99 
100  function _upgrade($current_version)
101  {
102  if (!parent::_upgrade($current_version)) return FALSE;
103 
104  if (version_compare($current_version, '0.2', '<')) {
105  // Version 0.1 -> 0.2
106  // There is a new method of calculating the timestamp, that eliminates
107  // any timezone issues, and also allows it to be calculated in Oracle
108  // However it requires the timestamp fields to be recached, as they
109  // will now be out of whack by the current time zone
110  pre_echo('STARTING UPGRADE OF CALENDAR EVENT FROM VERSION '.$current_version.' TO VERSION 0.2');
111  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
112  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
113 
114  $calendar_events = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids($this->getAssetType(), FALSE, TRUE);
115  pre_echo('Updating '.count($calendar_events).' asset(s)...');
116  foreach ($calendar_events as $assetid => $type_code) {
117  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid, $type_code);
118  if (is_null($asset)) continue;
119 
120  // Recache our calendar data
121  $asset->cacheCalendarData();
122 
123  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
124  unset($asset);
125 
126  }//end foreach
127 
128  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
129  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
130 
131  pre_echo('CALENDAR EVENT SUCCESSFULLY UPGRADED TO VERSION 0.2');
132 
133  }//end if - upgrade to version 0.2
134 
135  return true;
136 
137  }//end _upgrade()
138 
139 
140 }//end class
141 
142 ?>