Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_action_set_force_secure.inc
1 <?php
17 require_once SQ_LIB_PATH.'/html_form/html_form.inc';
18 require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
19 require_once SQ_CORE_PACKAGE_PATH.'/system/triggers/trigger_action/trigger_action.inc';
20 
33 {
34 
35 
52  public static function execute($settings, &$state)
53  {
54 
55  if (empty($state['asset'])) {
56  // grab the asset if assetid is given, but not the asset.
57  if (empty($state['assetid'])) {
58  return FALSE;
59  } else {
60  $state['asset'] = $GLOBALS['SQ_SYSTEM']->am->getAsset($state['assetid']);
61  }
62  }
63  if (is_null($state['asset'])) return FALSE;
64 
65  $GLOBALS['SQ_SYSTEM']->setRunLevel($GLOBALS['SQ_SYSTEM']->getRunLevel() & SQ_RUN_LEVEL_FORCED);
66  if (!$state['asset']->setForceSecure($settings['force_secure'])) return FALSE;
67  if (!$state['asset']->updateLookups()) return FALSE;
68  $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
69  return TRUE;
70 
71  }//end execute()
72 
73 
84  public static function getInterface($settings, $prefix, $write_access=FALSE)
85  {
86  ob_start();
87  $options = Array(
88  '0' => 'Allow all protocols',
89  '1' => 'Force secure protocol (HTTPS)',
90  '-' => 'Force insecure protocol (HTTP)',
91  );
92  combo_box($prefix.'_force_secure', $options, FALSE, isset($settings['force_secure']) ? $settings['force_secure'] : '');
93  $basic_part = ob_get_contents();
94  ob_end_clean();
95 
96  return translate('trigger_set_force_secure_basic', $basic_part);
97 
98 
99  }//end getInterface()
100 
101 
113  public static function processInterface(&$settings, $request_data)
114  {
115  $settings['force_secure'] = $request_data;
116  return FALSE;
117 
118  }//end processInterface()
119 
120 
130  public static function getLocks($settings, &$state)
131  {
132  return Array(
133  $state['assetid'] => Array('settings'),
134  );
135 
136  }//end getLocks()
137 
138 
139 }//end class