Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_action_increment_version.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
18 require_once SQ_CORE_PACKAGE_PATH.'/system/triggers/trigger_action/trigger_action.inc';
19 
32 {
33 
34 
53  public static function execute($settings, &$state)
54  {
55  // check required settings
56  if (empty($settings['version'])) return FALSE;
57 
58  if (empty($state['asset'])) {
59  // grab the asset if assetid is given, but not the asset.
60  if (empty($state['assetid'])) {
61  return FALSE;
62  } else {
63  $state['asset'] = $GLOBALS['SQ_SYSTEM']->am->getAsset($state['assetid']);
64  }
65  }
66 
67  if (!$state['asset']->incrementVersion($settings['version'])) {
68  return FALSE;
69  }
70 
71  return Array(
72  'assetid' => $state['asset']->id,
73  'version_set' => $settings['version'],
74  'new_version' => $state['asset']->version,
75  );
76 
77  }//end execute()
78 
79 
90  public static function getInterface($settings, $prefix, $write_access=FALSE)
91  {
92  if (empty($settings['version'])) {
93  // set to default
94  $selected_status = 'major';
95  } else {
96  $selected_status = $settings['version'];
97  }
98 
99  $version_list = Array(
100  'major' => 'Major',
101  'minor' => 'Minor',
102  'micro' => 'Micro',
103  );
104 
105  if (!$write_access) {
106  $form_element_extras = 'disabled="disabled"';
107  } else {
108  $form_element_extras = '';
109  }
110 
111  ob_start();
112  combo_box($prefix.'[version]', $version_list, FALSE, $selected_status, NULL, $form_element_extras);
113  $basic_part_1 = ob_get_contents();
114  ob_end_clean();
115 
116 
117  return translate('trigger_increment_version', $basic_part_1);
118 
119  }//end getInterface()
120 
121 
133  public static function processInterface(&$settings, $request_data)
134  {
135  $version = array_get_index($request_data, 'version', FALSE);
136  if (!$version) return 'Version has not been specified';
137 
138  $version_list = Array(
139  'major' => 'Major',
140  'minor' => 'Minor',
141  'micro' => 'Micro',
142  );
143 
144  // check if the status is valid
145  if (isset($version_list[$version])) {
146  $settings['version'] = $version;
147  return FALSE;
148  } else {
149  return 'Specified version is invalid';
150  }
151 
152  }//end processInterface()
153 
154 
155 }//end class
156 
157 ?>