Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_condition_tree_location_management.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
18 
31 {
32 
41  function _upgrade($current_version)
42  {
43  if (!parent::_upgrade($current_version)) return FALSE;
44 
45  if (version_compare($current_version, '0.3', '<')) {
46  pre_echo('UPGRADING TRIGGER CONDITION TREE LOCATION FROM v < 0.3');
47 
48  $tm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('trigger_manager');
49  $trigger_list = $tm->getTriggerList();
50  foreach ($trigger_list as $info){
51  $trigger = $tm->getAsset($info['id']);
52  $conditions = $trigger->attr('conditions');
53 
54  foreach ($conditions as &$condition_info){
55  if ($condition_info['type'] == 'trigger_condition_tree_location'){
56  if (!empty($condition_info['data']['assetid'])){
57  $condition_info['data']['assetids'] = Array($condition_info['data']['assetid']);
58  $condition_info['data']['immed_child'] = Array(
59  $condition_info['data']['assetid'] => $condition_info['data']['immed_child']
60  );
61  $condition_info['data']['propagate'] = Array(
62  $condition_info['data']['assetid'] => $condition_info['data']['propagate']
63  );
64  //unset old settings indices
65  unset($condition_info['data']['assetid']);
66  unset($condition_info['data']['treeid']);
67  }
68  }
69  }
70 
71  $trigger->setAttrValue('conditions', $conditions);
72  $trigger->saveAttributes();
73  unset($condition_info);
74  }
75  }//end if
76 
77  return TRUE;
78 
79  }//end _upgrade()
80 
81 }//end class
82 
83 ?>