17 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
51 public static function evaluate($settings, &$state)
55 if (empty($state[
'asset'])) {
57 if (empty($state[
'assetid'])) {
60 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
66 switch ($settings[
'perm']) {
67 case SQ_PERMISSION_READ:
68 $condition = $state[
'asset']->readAccess();
71 case SQ_PERMISSION_WRITE:
72 $condition = $state[
'asset']->writeAccess();
75 case SQ_PERMISSION_ADMIN:
76 $condition = $state[
'asset']->adminAccess();
80 return $settings[
'grant'] ? $condition : !$condition;
95 public static function getInterface($settings, $prefix, $write_access=FALSE)
98 SQ_PERMISSION_READ => translate(
'read').
' '.translate(
'permission'),
99 SQ_PERMISSION_WRITE => translate(
'write').
' '.translate(
'permission'),
100 SQ_PERMISSION_ADMIN => translate(
'admin').
' '.translate(
'permission'),
104 0 =>
'does not have',
107 $selected_perm = array_get_index($settings,
'perm', SQ_PERMISSION_READ);
108 $selected_grant = array_get_index($settings,
'grant', 1);
113 combo_box($prefix.
'[grant]', $grant, FALSE, $selected_grant);
115 echo $grant[$selected_grant];
117 $part1 = ob_get_contents();
121 combo_box($prefix.
'[perm]', $perm, FALSE, $selected_perm);
123 echo $perm[$selected_perm];
125 $part2 = ob_get_contents();
130 return 'Current user '.$part1.
' '.$part2.
' on the asset that the action is executing on.';
146 $settings[
'perm'] = array_get_index($request_data,
'perm', SQ_PERMISSION_READ);
147 $settings[
'grant'] = array_get_index($request_data,
'grant', 1);