16 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
54 public static function execute($settings, &$state)
56 if (empty($state[
'asset'])) {
58 if (empty($state[
'assetid'])) {
61 $state[
'asset'] = &$GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
64 if (is_null($state[
'asset']))
return FALSE;
66 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
67 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
71 $bind_vars = Array(
'assetid' => (
string) $state[
'assetid']);
73 }
catch (Exception $e) {
74 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
75 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
76 throw new Exception(
'Unable to decrement hit count due to database error: '.$e->getMessage());
80 if (!empty($asset_hit_count)) {
81 if (isset($asset_hit_count[0][
'hitcount'])) {
82 if ((
int) $asset_hit_count[0][
'hitcount'] == 1) {
86 $new_hit_count = (int) $asset_hit_count[0][
'hitcount'];
91 'assetid' => (
string) $state[
'assetid'],
92 'hitcount' => $new_hit_count,
95 }
catch (Exception $e) {
96 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
97 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
98 throw new Exception(
'Unable to decrement hit count due to database error: '.$e->getMessage());
106 if (isset($deleterow) && $deleterow) {
109 $bind_vars = Array(
'assetid' => (
string) $state[
'assetid']);
111 }
catch (Exception $e) {
112 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
113 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
114 throw new Exception(
'Unable to decrement hit count due to database error: '.$e->getMessage());
118 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
119 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
134 public static function getInterface($settings, $prefix, $write_access=FALSE)
170 public static function getLocks($settings, &$state)
172 return Array($state[
'assetid'] => Array(
'lookups'));