Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_action_logout_ipb.inc
1 <?php
18 require_once SQ_FUDGE_PATH.'/general/file_system.inc';
19 require_once SQ_CORE_PACKAGE_PATH.'/system/triggers/trigger_action/trigger_action.inc';
20 
21 
34 {
35 
36 
46  function __construct($assetid=0)
47  {
48  parent::__construct($assetid);
49 
50  }//end constructor
51 
52 
70  public static function execute($settings, &$state)
71  {
72  // check settings, state
73  if (empty($settings['ipbsdk_path']) || !file_exists($settings['ipbsdk_path'])) {
74  // if no settings, fail
75  return FALSE;
76  }
77 
78  // state, user asset
79  if (empty($state['asset'])) {
80  // grab the asset if assetid is given, but not the asset.
81  if (empty($state['assetid'])) {
82  return FALSE;
83  } else {
84  $state['asset'] =& $GLOBALS['SQ_SYSTEM']->am->getAsset($state['assetid']);
85  }
86  }
87 
88  // Load and Start IPB SDK
89  if (!file_exists($settings['ipbsdk_path'].'/ipbsdk_class.inc.php')) {
90  trigger_localised_error('IPB0001', E_USER_WARNING);
91  return FALSE;
92  }
93  require_once $settings['ipbsdk_path'].'/ipbsdk_class.inc.php';
94 
95  // We have to supress error reporting level since IPB and IPBSDK
96  // generates many PHP Notice warnings
97  $old_reporting_level = error_reporting(0);
98  $SDK = new IPBSDK();
99  $SDK->logout();
100  error_reporting($old_reporting_level);
101 
102  return TRUE;
103 
104  }//end execute()
105 
106 
117  public static function getInterface($settings, $prefix, $write_access=FALSE)
118  {
119  $ipbsdk_path = array_get_index($settings, 'ipbsdk_path', '');
120  ob_start();
121  ?>
122  <table border="0">
123  <tr>
124  <td valign="top"><b><?php echo translate('ipb_path_to_ipbsdk'); ?></b></td>
125  <td valign="top" style="padding-bottom: 10px;"><?php
126  // level
127  if ($write_access) {
128  echo text_box($prefix.'[ipbsdk_path]', $ipbsdk_path, '50');
129  } else {
130  echo $ipbsdk_path.'&nbsp;';
131  }
132  ?>
133  <br /><b>Note:</b>&nbsp;Please make sure the IPB SDK version is compatible with the installed IPB.
134  <br />For more information, please visit <a href="http://ipbsdk.sourceforge.net/">the IPBSDK website</a>
135  </td>
136  </td>
137  </tr>
138  </table>
139  <?php
140 
141  return ob_get_clean();
142 
143  }//end getInterface()
144 
145 
157  public static function processInterface(&$settings, $request_data)
158  {
159  $ipbsdk_path = array_get_index($request_data, 'ipbsdk_path', '');
160  $ipbsdk_path = trim($ipbsdk_path);
161  if ($ipbsdk_path == '') {
162  trigger_localised_error('IPB0002', E_USER_WARNING);
163  return FALSE;
164  }
165  $settings['ipbsdk_path'] = $ipbsdk_path;
166 
167  return FALSE;
168 
169  }//end processInterface()
170 
171 
181  public static function getLocks($settings, &$state)
182  {
183  return Array(
184  $state['assetid'] => Array(
185  'attributes',
186  ),
187  );
188 
189  }//end getLocks()
190 
191 
192 }//end class