Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_future_permission_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job_edit_fns.inc';
19 
32 {
33 
34 
40  function __construct()
41  {
42  parent::__construct();
43 
44  }//end constructor
45 
46 
61  public function paintInLineBackend(Cron_Job_Future_Permission $asset, Backend_Outputter $o, $prefix, $when='', $cascade_to_new=FALSE, $dependants_only=TRUE, $form_extra_elements='', Array $exclude_permission=Array())
62  {
63  $descs = $asset->getAllPermissionDescs();
64  foreach ($exclude_permission as $permission) {
65  unset($descs[$permission]);
66  }
67 
68  $write_access = $asset->writeAccess('attributes');
69  if ($write_access) {
70  combo_box($prefix.'_add_future_permissions', Array('1' => translate('add'), '0' => translate('remove')), FALSE, '1');
71  echo '&nbsp;'.translate('the_following').'&nbsp;';
72  combo_box($prefix.'_future_permission', $descs, FALSE, $asset->attr('permission'), NULL, $form_extra_elements);
73  } else {
74  echo $asset->attr('add')? translate('add') : translate('remove');
75  echo $descs[$asset->attr('permission')];
76  }
77 
78  echo '&nbsp;'.translate('permission').'<br /><br /><br />';
79 
80  if ($write_access) {
81  ?>
82  <table cellspacing="0">
83  <tr>
84  <td colspan="2">
85  <?php
86  combo_box($prefix.'_future_permissions_access[public][granted]', Array('' => '', '1' => translate('grant'), '0' => translate('deny')), FALSE, '');
87  echo ' '.translate('public_permission');
88  ?>
89  </td>
90  </tr>
91  <tr>
92  <td valign="top">
93  <?php
94  combo_box($prefix.'_future_permissions_access[user][granted]', Array('' => '', '1' => translate('grant'), '0' => translate('deny')), FALSE, '');
95  echo ' '.translate('specific_permission');
96  ?>
97  &nbsp;
98  </td>
99  <td><?php multiple_asset_finder($prefix.'_future_permissions_access[user][userid]', Array(), Array('user' => 'D', 'user_group' => 'D')); ?></td>
100  </tr>
101  </table>
102  <?php
103 
104  echo '<br /><br />'.translate('at').'&nbsp;';
105  $this->_paintWhenBox($asset, $o, $prefix, $when, $form_extra_elements);
106 
107  echo '<br /><br />';
108  check_box($prefix.'_cascade_to_new', '1', $cascade_to_new);
109  echo translate('cascade_permission_to_new_children');
110 
111  echo '<br />';
112  check_box($prefix.'_cascade_permission_changes', '1', !$dependants_only);
113  echo translate('update_permission_to_current_children');
114  }//end if
115 
116  return TRUE;
117 
118  }//end paintInLineBackend()
119 
120 
132  {
133  if (!$asset->writeAccess('attributes')) {
134  return FALSE;
135  }
136 
137  if (!empty($_POST[$prefix.'_future_permission']) && $asset->setAttrValue('permission', $_POST[$prefix.'_future_permission'])) {
138  $add_permissions = (!isset($_POST[$prefix.'_add_future_permissions']) || $_POST[$prefix.'_add_future_permissions']) ? TRUE : FALSE;
139  if (!$asset->setAttrValue('add', $add_permissions)) {
140  return FALSE;
141  }
142 
143  $userids = Array();
144  $permission_access = $_POST[$prefix.'_future_permissions_access'];
145  $permission_set = FALSE; //FLAG TO MARK IF PERMISSION IS GRANTED OR DENIED TO AT LEAST ONE USER OR NOT
146  if (isset($permission_access['public']['granted']) && ($permission_access['public']['granted'] != '')) {
147  $public_userid = $GLOBALS['SQ_SYSTEM']->am->getSystemAssetid('public_user');
148  $userids[$public_userid] = (int)$permission_access['public']['granted'];
149  $permission_set = TRUE;
150  }
151  if (isset($permission_access['user']['granted']) && ($permission_access['user']['granted'] != '')) {
152  foreach ($permission_access['user']['userid'] as $entry) {
153  if (!empty($entry['assetid'])) {
154  $userids[$entry['assetid']] = (int)$permission_access['user']['granted'];
155  $permission_set = TRUE;
156  }
157  }
158  }
159  if (!$permission_set || !$asset->setAttrValue('userids', $userids)) {
160  return FALSE;
161  }
162 
163  $cascade_to_new = (isset($_POST[$prefix.'_cascade_to_new']) && $_POST[$prefix.'_cascade_to_new']) ? TRUE : FALSE;
164  $dependants_only = (isset($_POST[$prefix.'_cascade_permission_changes']) && $_POST[$prefix.'_cascade_permission_changes']) ? FALSE : TRUE;
165  if (!$asset->setAttrValue('cascade_to_new', $cascade_to_new) || !$asset->setAttrValue('dependants_only', $dependants_only)) {
166  return FALSE;
167  }
168 
169  if ($when = $this->_processWhenBox($asset, $o, $prefix)) {
170  return ($asset->setAttrValue('when', $when));
171  } else {
172  trigger_localised_error('CRON0058', E_USER_NOTICE);
173  }
174  }
175 
176  return FALSE;
177 
178  }//end processInLineBackend()
179 
180 
181 }//end class
182 
183 ?>