18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
19 require_once SQ_PACKAGES_PATH.
'/trim/lib/trim_common.inc';
48 'cached_result' => Array (
50 'type' =>
'serialise',
52 'parameters' => Array (
53 'allow_empty' => FALSE,
56 'trim_connector_id' => Array(
60 'description' =>
'The asset we will be using as content in the email',
62 'download_files' => Array(
66 'description' =>
'Whether to download the files attached with documents or not',
67 'parameters' => Array(
68 'allow_empty' => FALSE,
71 'use_downloader' => Array(
73 'type' =>
'selection',
75 'description' =>
'Whether to create the helper downloader asset',
77 'parameters' => Array(
78 'allow_empty' => FALSE,
96 'download_limit' => Array(
100 'parameters' => Array (
101 'allow_empty' => FALSE,
102 'allow_negative' => FALSE,
105 'record_search_type' => Array (
107 'type' =>
'serialise',
109 'StringSearch' =>
'StringSearch',
111 'parameters' => Array (
112 'allow_empty' => FALSE,
116 'dynamic_vars' => Array(
118 'type' =>
'serialise',
120 'search_parent_container' =>
'',
121 'search_clauses' => Array(
122 'search_groups' => Array(),
123 'global_logic' =>
'AND',
125 'result_fields' => Array (
126 'recTitle' =>
'Title',
127 'recNumber' =>
'Record Number',
128 'recRecordType' =>
'Record Type',
129 'recDocumentType' =>
'Document Type',
130 'recCreatorLoc' =>
'Creator',
134 'search_sort_1' =>
'None',
135 'search_sort_2' =>
'None',
136 'search_sort_3' =>
'None',
137 'sort_1_descending' => FALSE,
138 'sort_2_descending' => FALSE,
139 'sort_3_descending' => FALSE,
140 'record_type_filter' => Array(),
143 'parameter_map' => Array (
145 'type' =>
'parameter_map',
146 'default' => Array(),
147 'parameters' => Array (
148 'parameters' => Array(),
151 'retrieved_fields' => Array (
153 'type' =>
'serialise',
154 'default' => Array(),
155 'parameters' => Array (
156 'allow_empty' => TRUE,
159 'classification' => Array (
164 'classification_sub' => Array (
168 'description' =>
'Whether to include records in sub classifications',
169 'parameters' => Array(
170 'allow_empty' => FALSE,
173 'convert_timezone' => Array(
177 'description' =>
'Whether to convert GMT datetime to local timezone',
178 'parameters' => Array(
179 'allow_empty' => FALSE,
213 if (!parent::_upgrade($current_version))
return FALSE;
215 $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(),
'name'));
217 if (version_compare($current_version,
'0.2',
'<')) {
218 pre_echo(
'STARTING UPGRADE OF '.$asset_name.
' FROM VERSION '.$current_version.
' TO VERSION 0.2');
219 $saved_search_ids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'trim_saved_search', FALSE, TRUE);
223 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
224 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
226 pre_echo(
'Updating TRIM Saved Search...');
232 foreach ($saved_search_ids as $id => $blank) {
233 $saved_search = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id, $blank[
'type_code']);
234 $var_list = $saved_search->attr(
'dynamic_vars');
235 if(isset($var_list[
'fields'])) {
236 $result_fields = Array();
237 foreach ($var_list[
'fields'] as $field_name) {
238 if(isset($available_fields[$field_name]))
239 $result_fields[$field_name] = $available_fields[$field_name];
241 $var_list[
'result_fields'] = $result_fields;
242 unset ($var_list[
'fields']);
244 if(isset($var_list[
'string_search_type'][0]) && isset($var_list[
'search_keyword'])) {
246 $search_name = $var_list[
'string_search_type'][0];
247 $search_caption = $available_search_type[$search_name];
248 $search_keyword = $var_list[
'search_keyword'];
249 $var_list[
'search_clauses'] = Array(
250 'search_groups' => Array (
254 'name' => $search_name,
255 'caption' => $search_caption,
256 'keyword' => $search_keyword,
259 'group_logic' =>
'AND',
262 'global_logic' =>
'AND',
264 unset ($var_list[
'string_search_type']);
265 unset ($var_list[
'search_keyword']);
269 $saved_search->setAttrValue(
'dynamic_vars', $var_list);
271 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
273 if (!$saved_search->saveAttributes()) {
274 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
275 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
277 pre_echo($asset_name.
' UPGRADE FAILED - Could not save attributes');
281 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
283 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($saved_search);
284 unset($saved_search);
289 pre_echo(
'Updated TRIM Saved Search - '.$count.
' assets(s)...');
292 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
293 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
295 pre_echo($asset_name.
' SUCCESSFULLY UPGRADED TO VERSION 0.2');
297 $current_version =
'0.2';
302 if (version_compare($current_version,
'0.3',
'<')) {
303 pre_echo(
'STARTING UPGRADE OF '.$asset_name.
' FROM VERSION '.$current_version.
' TO VERSION 0.3');
304 $saved_search_ids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'trim_saved_search', FALSE, TRUE);
308 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
309 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
311 pre_echo(
'Updating TRIM Saved Search...');
315 foreach ($saved_search_ids as $id => $blank) {
316 $saved_search = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id, $blank[
'type_code']);
317 $var_list = $saved_search->attr(
'dynamic_vars');
318 if(!isset($var_list[
'record_type_filter'])) {
319 $var_list[
'record_type_filter'] = Array();
323 $saved_search->setAttrValue(
'dynamic_vars', $var_list);
325 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
327 if (!$saved_search->saveAttributes()) {
328 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
329 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
331 pre_echo($asset_name.
' UPGRADE FAILED - Could not save attributes');
335 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
337 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($saved_search);
338 unset($saved_search);
343 pre_echo(
'Updated TRIM Saved Search - '.$count.
' assets(s)...');
345 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
346 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
348 pre_echo($asset_name.
' SUCCESSFULLY UPGRADED TO VERSION 0.3');