Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_action_redirect.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 
31 {
32 
33 
51  public static function execute($settings, &$state)
52  {
53  // check required settings
54  if (!isset($settings['url_string']) || empty($settings['url_string'])) {
55  return FALSE;
56  }
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  if (is_null($state['asset'])) return FALSE;
67 
68  require_once SQ_FUDGE_PATH.'/general/text.inc';
69  $url = $settings['url_string'];
70  $keywords = retrieve_keywords_replacements($url);
71  if (!empty($keywords)) {
72  $replacements = Array();
73  foreach ($keywords as $keyword) {
74  $replacements[$keyword] = $state['asset']->getKeywordReplacement($keyword);
75  }
76  replace_keywords($url, $replacements);
77  }
78 
79  if (!empty($url)) {
80  header('Location: '.$url);
81 
82  return Array(
83  'assetid' => $state['asset']->id,
84  'url' => $url,
85  );
86  } else {
87  return FALSE;
88  }
89 
90  }//end execute()
91 
92 
103  public static function getInterface($settings, $prefix, $write_access=FALSE)
104  {
105  ob_start();
106 
107  $url_string = array_get_index($settings, 'url_string', '');
108  echo translate('trigger_action_redirect_redirect_url').' ';
109  if ($write_access) {
110  text_box($prefix.'[url_string]', $url_string, 75);
111  } else {
112  echo '<b>'.$url_string.'</b>';
113  }
114  echo '<br />'.translate('trigger_action_redirect_url_instructions');
115 
116  return ob_get_clean();
117 
118  }//end getInterface()
119 
120 
132  public static function processInterface(&$settings, $request_data)
133  {
134  $settings['url_string'] = trim(array_get_index($request_data, 'url_string', ''));
135 
136  return FALSE;
137 
138  }//end processInterface()
139 
140 
150  public static function getLocks($settings, &$state)
151  {
152  return Array();
153 
154  }//end getLocks()
155 
156 
157 }//end class
158 
159 ?>