Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_decision_tree_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
38  function __construct(&$pm)
39  {
40  $this->Asset_Management($pm);
41 
42  $this->vars = Array(
43 
44  'bodycopy_points' => Array(
45  'added' => '0.0.1',
46  'type' => 'serialise',
47  'default' => Array()
48  ),
49 
50  );
51 
52  }//end constructor
53 
54 
61  function getEventList()
62  {
63  return Array(
64  Array(
65  'event_name' => 'requestKeywords',
66  'broadcast_type_code' => 'content_type',
67  'broadcast_strict_type_code' => FALSE,
68  'options' => Array(
69  'side_of_link' => 'major',
70  'indirect' => TRUE,
71  'is_exclusive' => NULL,
72  'is_dependant' => TRUE,
73  'value' => '',
74  'link_type' => SQ_LINK_TYPE_2,
75  ),
76  ),
77  );
78 
79  }//end getEventList()
80 
81 
90  function _upgrade($current_version)
91  {
92  if (!parent::_upgrade($current_version)) return FALSE;
93 
94  if (version_compare($current_version, '0.2', '<')) {
95  pre_echo('UPGRADING DECISION TREE FROM v < 0.2');
96 
97  $page_ids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('page_decision_tree', TRUE, TRUE);
98  foreach ($page_ids as $page_id => $type) {
99  $page = $GLOBALS['SQ_SYSTEM']->am->getAsset($page_id, $type['type_code']);
100 
101  $first_link = $GLOBALS['SQ_SYSTEM']->am->getLink($page->id, SQ_LINK_TYPE_2, 'decision_tree_question', FALSE, 'first_question', 'major', TRUE);
102  if (!empty($first_link)){
103  $first_question = $GLOBALS['SQ_SYSTEM']->am->getAsset($first_link['minorid']);
104  if ($GLOBALS['SQ_SYSTEM']->am->createAssetLink($page, $first_question, SQ_LINK_NOTICE, 'first_question')){
105  $GLOBALS['SQ_SYSTEM']->am->updateLink($first_link['linkid'], NULL, '');
106  }
107  }
108 
109  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($page);
110  unset($page);
111  }
112  }//end if
113 
114  return TRUE;
115 
116  }//end _upgrade()
117 
118 
119 }//end class
120 
121 ?>