fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

accesscontrolmanagementpage.class.php
Go to the documentation of this file.
1 <?php
23 {
24  public $node = 'accesscontrol';
32  public function __construct($name = '')
33  {
37  $this->name = _('Access Control Management');
41  self::$HookManager->processEvent(
42  'PAGES_WITH_OBJECTS',
43  array('PagesWithObjects' => &$this->PagesWithObjects)
44  );
49  global $node;
50  global $sub;
51  global $id;
52  self::$foglang['ExportAccesscontrol'] = _('Export Accesscontrols');
53  self::$foglang['ImportAccesscontrol'] = _('Import Accesscontrols');
57  switch ($sub) {
58  case 'edit':
59  case 'delete':
60  parent::__construct($this->name);
61  if ($id) {
62  $this->subMenu = array(
63  "$this->linkformat#role-general" => self::$foglang['General'],
64  $this->membership => self::$foglang['Members'],
65  sprintf(
66  '?node=%s&sub=%s&id=%s',
67  $this->node,
68  'assocRule',
69  $id
70  ) => _('Rule Association'),
71  "$this->delformat" => self::$foglang['Delete'],
72  );
73  $this->notes = array(
74  _('Role Name') => $this->obj->get('name'),
75  _('Description') => $this->obj->get('description'),
76  );
77  }
78  break;
79  case 'deletemulti':
80  parent::__construct($this->name);
87  $assocrule = preg_match(
88  '#items=assocRule#i',
89  self::$querystring
90  );
94  $user = preg_match(
95  '#items=user#i',
96  self::$querystring
97  );
101  $role = preg_match(
102  '#items=role#i',
103  self::$querystring
104  );
108  $rule = preg_match(
109  '#items=rule#i',
110  self::$querystring
111  );
116  if ($assocrule) {
117  $this->childClass = 'AccessControlRuleAssociation';
118  } elseif ($user) {
119  $this->childClass = 'AccessControlAssociation';
120  } elseif ($role) {
121  $this->childClass = 'AccessControl';
122  } elseif ($rule) {
123  $this->childClass = 'AccessControlRule';
124  } else {
125  $this->childClass = 'AccessControl';
126  }
127  break;
128  case 'membership':
129  case 'assocRule':
130  parent::__construct($this->name);
131  if ($id) {
132  $this->subMenu = array(
133  "$this->linkformat#role-general" => self::$foglang['General'],
134  $this->membership => self::$foglang['Members'],
135  sprintf(
136  '?node=%s&sub=%s&id=%s',
137  $this->node,
138  'assocRule',
139  $id
140  ) => _('Rule Association'),
141  "$this->delformat" => self::$foglang['Delete'],
142  );
143  $this->notes = array(
144  _('Role Name') => $this->obj->get('name'),
145  _('Description') => $this->obj->get('description'),
146  );
147  }
148  break;
149  case 'editRule':
150  case 'deleteRule':
151  $this->childClass = 'AccessControlRule';
152  if ($id) {
153  $this->obj = new $this->childClass($id);
154  $link = sprintf(
155  '?node=%s&sub=%s&%s=%d',
156  $this->node,
157  '%s',
158  $this->id,
159  $id
160  );
161  $this->linkformat = sprintf(
162  $link,
163  'editRule'
164  );
165  $this->subMenu = array(
166  "$this->linkformat" => self::$foglang['General'],
167  sprintf(
168  '?node=%s&sub=%s&id=%s',
169  $this->node,
170  'deleteRule',
171  $id
172  ) => self::$foglang['Delete'],
173  );
174  $this->notes = array(
175  _('Rule type') => $this->obj->get('type'),
176  _('Rule value') => $this->obj->get('value'),
177  _('Parent Node') => $this->obj->get('parent'),
178  );
179  }
180  break;
181  case 'addRule':
182  case 'ruleList':
183  case 'addRuleGroup':
184  parent::__construct($this->name);
185  $this->childClass = 'AccessControlRule';
186  break;
187  default:
188  parent::__construct($this->name);
189  }
193  $this->title = $this->name;
194  if (in_array($this->node, $this->PagesWithObjects)) {
195  $classVars = self::getClass(
196  $this->childClass,
197  '',
198  true
199  );
200  $this->databaseTable
201  = $classVars['databaseTable'];
202  $this->databaseFields
203  = $classVars['databaseFields'];
204  $this->databaseFieldsRequired
205  = $classVars['databaseFieldsRequired'];
206  $this->databaseFieldClassRelationships
207  = $classVars['databaseFieldClassRelationships'];
208  $this->additionalFields
209  = $classVars['additionalFields'];
210  unset($classVars);
211  $this->obj = self::getClass(
212  $this->childClass,
213  $id
214  );
215  if (isset($id)) {
216  if ($id === 0 || !is_numeric($id)) {
217  unset($this->obj);
219  sprintf(
220  _('%s ID %d is not valid'),
221  $this->childClass,
222  $id
223  )
224  );
226  sprintf(
227  '?node=%s',
228  $this->node
229  )
230  );
231  }
232  }
233  }
234  $this->menu = array(
235  'list' => sprintf(_('List all roles')),
236  'addRole' => sprintf(_('Add new role')),
237  'ruleList' => sprintf(_('List all rules')),
238  'addRule' => sprintf(_('Add new rule')),
239  'export' => $this->menu['export'],
240  'import' => $this->menu['import']
241  );
242  switch (strtolower($this->childClass)) {
243  case 'accesscontrol':
244  $this->headerData = array(
245  '<input type="checkbox" name="toggle-checkbox" class='
246  . '"toggle-checkboxAction"/>',
247  _('Role Name'),
248  _('Role Description'),
249  );
250  $this->templates = array(
251  '<input type="checkbox" name="accesscontrol[]" value='
252  . '"${id}" class="toggle-action"/>',
253  '<a href="?node=accesscontrol&sub=edit'
254  . '&id=${id}" title="Edit">${name}</a>',
255  '${description}',
256  );
257  $this->attributes = array(
258  array(
259  'class' => 'filter-false',
260  'width' => 16
261  ),
262  array(),
263  array()
264  );
265  self::$HookManager
266  ->processEvent(
267  'ACCESSCONTROL_DATA',
268  array(
269  'headerData' => &$this->headerData,
270  'data' => &$this->data,
271  'templates' => &$this->templates,
272  'attributes' => &$this->attributes
273  )
274  );
275  self::$returnData = function (&$AccessControl) {
276  $this->data[] = array(
277  'id' => $AccessControl->id,
278  'name' => $AccessControl->name,
279  'description' => $AccessControl->description,
280  'createdBy' => $AccessControl->createdBy,
281  'createdTime' => $AccessControl->createdTime
282  );
283  unset($AccessControl);
284  };
285  break;
286  case 'accesscontrolrule':
287  self::$returnData = function (&$AccessControlRule) {
288  $this->data[] = array(
289  'type' => $AccessControlRule->type,
290  'id' => $AccessControlRule->id,
291  'value' => $AccessControlRule->value,
292  'parent' => $AccessControlRule->parent,
293  'node' => $AccessControlRule->node
294  );
295  unset($AccessControlRule);
296  };
297  break;
298  }
299  }
305  public function addRole()
306  {
307  $this->add();
308  }
314  public function addRolePost()
315  {
316  $this->addPost();
317  }
323  public function add()
324  {
325  unset(
326  $this->form,
327  $this->data,
328  $this->headerData,
329  $this->templates,
330  $this->attributes
331  );
332  $this->title = _('New Role');
333  $this->attributes = array(
334  array('class' => 'col-xs-4'),
335  array('class' => 'col-xs-8 form-group'),
336  );
337  $this->templates = array(
338  '${field}',
339  '${input}',
340  );
341  $name = filter_input(INPUT_POST, 'name');
342  $desc = filter_input(INPUT_POST, 'description');
343  $fields = array(
344  '<label for="name">'
345  . _('Role Name')
346  . '</label>' => '<div class="input-group">'
347  . '<input type="text" name="name" id="name" class="form-control" value="'
348  . $name
349  . '"/>'
350  . '</div>',
351  '<label for="desc">'
352  . _('Role Description')
353  . '</label>' => '<div class="input-group">'
354  . '<textarea class="form-control" name="description" '
355  . 'id="desc">'
356  . $desc
357  . '</textarea>'
358  . '</div>',
359  '<label for="add">'
360  . _('Create New Access Control Role')
361  . '</label>' => '<button type="submit" name="add" id="add" '
362  . 'class="btn btn-info btn-block">'
363  . _('Add')
364  . '</button>'
365  );
366  array_walk($fields, $this->fieldsToData);
367  self::$HookManager
368  ->processEvent(
369  'ACCESSCONTROL_ADD',
370  array(
371  'headerData' => &$this->headerData,
372  'data' => &$this->data,
373  'templates' => &$this->templates,
374  'attributes' => &$this->attributes
375  )
376  );
377  unset($fields);
378  echo '<div class="col-xs-9">';
379  echo '<div class="panel panel-info">';
380  echo '<div class="panel-heading text-center">';
381  echo '<h4 class="title">';
382  echo $this->title;
383  echo '</h4>';
384  echo '</div>';
385  echo '<div class="panel-body">';
386  echo '<form class="form-horizontal" method="post" action="'
387  . $this->formAction
388  . '">';
389  $this->render(12);
390  echo '</form>';
391  echo '</div>';
392  echo '</div>';
393  echo '</div>';
394  unset(
395  $this->data,
396  $this->form,
397  $this->headerData,
398  $this->templates,
399  $this->attributes
400  );
401  }
407  public function addPost()
408  {
409  $name = filter_input(
410  INPUT_POST,
411  'name'
412  );
413  $desc = filter_input(
414  INPUT_POST,
415  'description'
416  );
417  try {
418  if (!$name) {
419  throw new Exception(
420  _('A name is required!')
421  );
422  }
423  $exists = self::getClass('AccessControlManager')
424  ->exists($name);
425  if ($exists) {
426  throw new Exception(
427  _('A role already exists with this name!')
428  );
429  }
430  $AccessControl = self::getClass('AccessControl')
431  ->set('name', $name)
432  ->set('description', $desc);
433  if (!$AccessControl->save()) {
434  throw new Exception(_('Add role failed!'));
435  }
436  $hook = 'ROLE_ADD_SUCCESS';
437  $msg = json_encode(
438  array(
439  'msg' => _('Role added!'),
440  'title' => _('Role Create Success')
441  )
442  );
443  } catch (Exception $e) {
444  $hook = 'ROLE_ADD_FAIL';
445  $msg = json_encode(
446  array(
447  'error' => $e->getMessage(),
448  'title' => _('Role Create Fail')
449  )
450  );
451  }
452  self::$HookManager
453  ->processEvent(
454  $hook,
455  array('AccessControl' => &$AccessControl)
456  );
457  unset($AccessControl);
458  echo $msg;
459  exit;
460  }
466  public function edit()
467  {
468  unset(
469  $this->data,
470  $this->form,
471  $this->headerData,
472  $this->templates,
473  $this->attributes
474  );
475  $this->title = sprintf(
476  '%s: %s',
477  _('Edit'),
478  $this->obj->get('name')
479  );
480  $this->attributes = array(
481  array('class' => 'col-xs-4'),
482  array('class' => 'col-xs-8 form-group'),
483  );
484  $this->templates = array(
485  '${field}',
486  '${input}',
487  );
488  $name = filter_input(INPUT_POST, 'name') ?:
489  $this->obj->get('name');
490  $desc = filter_input(INPUT_POST, 'description') ?:
491  $this->obj->get('description');
492  $fields = array(
493  '<label for="name">'
494  . _('Role Name')
495  . '</label>' => '<div class="input-group">'
496  . '<input type="text" name="name" id="name" class="form-control" value="'
497  . $name
498  . '"/>'
499  . '</div>',
500  '<label for="desc">'
501  . _('Role Description')
502  . '</label>' => '<div class="input-group">'
503  . '<textarea class="form-control" name="description" '
504  . 'id="desc">'
505  . $desc
506  . '</textarea>'
507  . '</div>',
508  '<label for="update">'
509  . _('Make Changes?')
510  . '</label>' => '<button type="submit" name="update" id="update" '
511  . 'class="btn btn-info btn-block">'
512  . _('Update')
513  . '</button>'
514  );
515  array_walk($fields, $this->fieldsToData);
516  self::$HookManager
517  ->processEvent(
518  'ACCESSCONTROL_EDIT',
519  array(
520  'headerData' => &$this->headerData,
521  'data' => &$this->data,
522  'templates' => &$this->templates,
523  'attributes' => &$this->attributes
524  )
525  );
526  echo '<div class="col-xs-9 tab-content">';
527  echo '<div class="tab-pane fade in active" id="role-general">';
528  echo '<div class="panel panel-info">';
529  echo '<div class="panel-heading text-center">';
530  echo '<h4 class="title">';
531  echo _('Access Control Role General');
532  echo '</h4>';
533  echo '</div>';
534  echo '<div class="panel-body">';
535  echo '<form class="form-horizontal" method="post" action="'
536  . $this->formAction
537  . '">';
538  $this->render(12);
539  echo '</form>';
540  echo '</div>';
541  echo '</div>';
542  echo '</div>';
543  echo '</div>';
544  unset(
545  $this->data,
546  $this->form,
547  $this->headerData,
548  $this->templates,
549  $this->attributes
550  );
551  }
557  public function editPost()
558  {
559  self::$HookManager
560  ->processEvent(
561  'ACCESSCONTROL_EDIT_POST',
562  array(
563  'AccessControl' => &$this->obj
564  )
565  );
566  $name = filter_input(INPUT_POST, 'name');
567  $desc = filter_input(INPUT_POST, 'description');
568  try {
569  if ($name != $this->obj->get('name')
570  && $this->obj->getManager()->exists($name)
571  ) {
572  throw new Exception(_('A role already exists with this name!'));
573  }
574  if (isset($_POST['update'])) {
575  $this->obj
576  ->set('name', $name)
577  ->set('description', $desc);
578  if (!$this->obj->save()) {
579  throw new Exception(_('Role update failed!'));
580  }
581  $hook = 'ROLE_EDIT_SUCCESS';
582  $msg = json_encode(
583  array(
584  'msg' => _('Role updated!'),
585  'title' => _('Role Update Success')
586  )
587  );
588  }
589  } catch (Exception $e) {
590  $hook = 'ROLE_EDIT_FAIL';
591  $msg = json_encode(
592  array(
593  'error' => $e->getMessage(),
594  'title' => _('Role Update Fail')
595  )
596  );
597  }
598  self::$HookManager
599  ->processEvent(
600  $hook,
601  array('AccessControl' => &$this->obj)
602  );
603  echo $msg;
604  exit;
605  }
611  public function ruleList()
612  {
613  unset(
614  $this->data,
615  $this->form,
616  $this->headerData,
617  $this->templates,
618  $this->attributes
619  );
620  $this->title = _('Access Control Rules');
621  $this->headerData = array(
622  '<input type="checkbox" name="toggle-checkbox" class='
623  . '"toggle-checkboxAction"/>',
624  _('Type'),
625  _('Value'),
626  _('Parent'),
627  _('Node')
628  );
629  $this->templates = array(
630  '<input type="checkbox" name="rule[]" value='
631  . '"${id}" class="toggle-action"/>',
632  sprintf(
633  '<a href="?node=%s&sub=editRule&%s=${id}" title='
634  . '"%s">${type}</a>',
635  $this->node,
636  $this->id,
637  _('Edit')
638  ),
639  '${value}',
640  '${parent}',
641  '${node}'
642  );
643  $this->attributes = array(
644  array(
645  'class' => 'filter-false',
646  'width' => 16
647  ),
648  array(),
649  array(),
650  array(),
651  array()
652  );
653  Route::listem('accesscontrolrule');
654  $AccessControlRules = json_decode(
656  );
657  $AccessControlRules = $AccessControlRules->accesscontrolrules;
658  array_walk($AccessControlRules, static::$returnData);
659  self::$HookManager
660  ->processEvent(
661  'RULE_DATA',
662  array(
663  'headerData' => &$this->headerData,
664  'data' => &$this->data,
665  'templates' => &$this->templates,
666  'attributes' => &$this->attributes
667  )
668  );
669  echo '<div class="col-xs-9">';
670  echo '<div class="panel panel-info">';
671  echo '<div class="panel-heading text-center">';
672  echo '<h4 clas="title">';
673  echo $this->title;
674  echo '</h4>';
675  echo '</div>';
676  echo '<div class="panel-body">';
677  $this->render(12);
678  echo '</div>';
679  echo '</div>';
680  echo '<div class="action-boxes del hiddeninitially">';
681  echo '<div class="panel panel-warning">';
682  echo '<div class="panel-heading text-center">';
683  echo '<h4 class="title">';
684  echo _('Delete Selected');
685  echo '</h4>';
686  echo '</div>';
687  echo '<div class="panel-body">';
689  $components = parse_url($formAction);
690  parse_str($components['query'], $vars);
691  $vars['sub'] = 'deletemultiRule';
692  $formAction = '?'.http_build_query($vars);
693  echo '<form class="form-horizontal" method="post" action="'
694  . $formAction
695  . '">';
696  echo '<div class="form-group">';
697  echo '<label class="control-label col-xs-4" for="del-'
698  . $this->node
699  . 'rule">';
700  echo _('Delete Selected');
701  echo ' ';
702  echo $this->node . 'rules';
703  echo '</label>';
704  echo '<div class="col-xs-8">';
705  echo '<input type="hidden" name="'
706  . $this->node
707  . 'ruleIDArray"/>';
708  echo '<button type="submit" class='
709  . '"btn btn-danger btn-block" id="'
710  . 'del-'
711  . $this->node
712  . 'rule">';
713  echo _('Delete');
714  echo '</button>';
715  echo '</div>';
716  echo '</div>';
717  echo '</form>';
718  echo '</div>';
719  echo '</div>';
720  echo '</div>';
721  unset(
722  $this->data,
723  $this->form,
724  $this->headerData,
725  $this->templates,
726  $this->attributes
727  );
728  }
734  public function deletemultiRule()
735  {
736  global $sub;
737  global $node;
738  $this->title = sprintf(
739  "%s's to remove",
740  _('Access Control Rule')
741  );
742  unset(
743  $this->data,
744  $this->form,
745  $this->headerData,
746  $this->templates,
747  $this->attributes
748  );
749  $this->templates = array(
750  '${field}',
751  '${input}'
752  );
753  $this->attributes = array(
754  array('class' => 'col-xs-4'),
755  array('class' => 'col-xs-8 form-group')
756  );
757  $reqID = $node
758  . 'ruleIDArray';
759  $items = filter_input(
760  INPUT_POST,
761  $reqID
762  );
763  $reqID = array_values(
764  array_filter(
765  array_unique(
766  explode(',', $items)
767  )
768  )
769  );
770  Route::listem('accesscontrolrule');
771  $items = json_decode(
773  );
774  $items = $items->accesscontrolrules;
775  foreach ((array)$items as &$object) {
776  if (!in_array($object->id, $reqID)) {
777  continue;
778  }
779  $this->data[] = array(
780  'field' => '<input type="hidden" value="'
781  . $object->id
782  . '" name="remitems[]"/>',
783  'input' => '<a href="?node='
784  . $node
785  . '&sub=editRule&id='
786  . $object->id
787  . '">'
788  . $object->name
789  . '</a>'
790  );
791  unset($object);
792  }
793  if (count($this->data) < 1) {
794  self::redirect('?node=' . $node . '&sub=ruleList');
795  }
796  $this->data[] = array(
797  'field' => '<label for="delete">'
798  . _('Remove these items?')
799  . '</label>',
800  'input' => '<button class="btn btn-danger btn-block" type="submit" '
801  . 'name="delete" id="delete">'
802  . _('Delete')
803  . '</button>'
804  );
805  echo '<!-- Delete Items -->';
806  echo '<div class="col-xs-9">';
807  echo '<div class="panel panel-warning">';
808  echo '<div class="panel-heading text-center">';
809  echo '<h4 class="title">';
810  echo $this->title;
811  echo '</h4>';
812  echo '</div>';
813  echo '<div class="panel-body">';
814  echo '<div id="deleteDiv"></div>';
815  echo '<form class="form-horizontal" action="'
816  . $this->formAction
817  . '">';
818  $this->render(12);
819  echo '<input type="hidden" name="storagegroup" value="0"/>';
820  echo '</form>';
821  echo '</div>';
822  echo '</div>';
823  echo '</div>';
824  }
830  public function deletemultiRuleAjax()
831  {
832  if (self::getSetting('FOG_REAUTH_ON_DELETE')) {
833  $user = filter_input(INPUT_POST, 'fogguiuser');
834  $pass = filter_input(INPUT_POST, 'fogguipass');
835  $validate = self::getClass('User')
836  ->passwordValidate(
837  $user,
838  $pass,
839  true
840  );
841  if (!$validate) {
842  echo json_encode(
843  array(
844  'error' => self::$foglang['InvalidLogin'],
845  'title' => _('Unable to Authenticate')
846  )
847  );
848  exit;
849  }
850  }
851  $remitems = filter_input_array(
852  INPUT_POST,
853  array(
854  'remitems' => array(
855  'flags' => FILTER_REQUIRE_ARRAY
856  )
857  )
858  );
859  $remitems = $remitems['remitems'];
860  self::$HookManager->processEvent(
861  'MULTI_REMOVE',
862  array('removing' => &$remitems)
863  );
864  self::getClass('AccessControlRule')
865  ->getManager()
866  ->destroy(
867  array('id' => $remitems)
868  );
869  echo json_encode(
870  array(
871  'msg' => _('Successfully deleted'),
872  'title' => _('Delete Success')
873  )
874  );
875  exit;
876  }
882  public function addRule()
883  {
884  $this->title = _('New Rule');
885  unset($this->headerData);
886  $this->attributes = array(
887  array('class' => 'col-xs-4'),
888  array('class' => 'col-xs-8 form-group'),
889  );
890  $this->templates = array(
891  '${field}',
892  '${input}',
893  );
894  $type = filter_input(
895  INPUT_POST,
896  'type'
897  );
898  $parent = filter_input(
899  INPUT_POST,
900  'parent'
901  );
902  $node = filter_input(
903  INPUT_POST,
904  'nodeParent'
905  );
906  $value = filter_input(
907  INPUT_POST,
908  'value'
909  );
910  $fields = array(
911  '<label for="type">'
912  . _('Rule Type')
913  . '</label>' => '<div class="input-group">'
914  . '<input class="form-control ruletype-input" type='
915  . '"text" name="type" id="type" required value="'
916  . $type
917  . '"/>'
918  . '</div>',
919  '<label for="parent">'
920  . _('Parent')
921  . '</label>' => '<div class="input-group">'
922  . '<input class="form-control ruleparent-input" type='
923  . '"text" name="parent" id="parent" required value="'
924  . $parent
925  . '"/>'
926  . '</div>',
927  '<label for="nodeParent">'
928  . _('Node Parent')
929  . '</label>' => '<div class="input-group">'
930  . '<input class="form-control rulenodeparent-input" '
931  . 'type="text" name="nodeParent" id="nodeParent" value="'
932  . $node
933  . '"/>'
934  . '</div>',
935  '<label for="value">'
936  . _('Rule Value')
937  . '</label>' => '<div class="input-group">'
938  . '<input class="form-control rulevalue-input" '
939  . 'type="text" name="value" id="value" required value="'
940  . $value
941  . '"/>'
942  . '</div>',
943  '<label for="add">'
944  . _('Create Rule?')
945  . '</label>' => '<button class="btn btn-info btn-blcok" name="'
946  . 'add" id="add" type="submit">'
947  . _('Create')
948  . '</button>'
949  );
950  array_walk($fields, $this->fieldsToData);
951  self::$HookManager
952  ->processEvent(
953  'ACCESSCONTROL_RULE_ADD',
954  array(
955  'headerData' => &$this->headerData,
956  'data' => &$this->data,
957  'templates' => &$this->templates,
958  'attributes' => &$this->attributes
959  )
960  );
961  unset($fields);
962  echo '<div class="col-xs-9">';
963  echo '<div class="panel panel-info">';
964  echo '<div class="panel-heading text-center">';
965  echo '<h4 class="title">';
966  echo $this->title;
967  echo '</h4>';
968  echo '</div>';
969  echo '<div class="panel-body">';
970  echo '<form class="form-horizontal" method="post" action="'
971  . $this->formAction
972  . '">';
973  $this->render(12);
974  echo '</form>';
975  echo '</div>';
976  echo '</div>';
977  echo '</div>';
978  }
984  public function addRulePost()
985  {
986  self::$HookManager
987  ->processEvent(
988  'ADD_RULE_POST'
989  );
990  $value = trim(
991  filter_input(
992  INPUT_POST,
993  'value'
994  )
995  );
996  $type = trim(
997  filter_input(
998  INPUT_POST,
999  'type'
1000  )
1001  );
1002  $name = $type
1003  . '-'
1004  . $value;
1005  $parent = trim(
1006  filter_input(
1007  INPUT_POST,
1008  'parent'
1009  )
1010  );
1011  $node = trim(
1012  filter_input(
1013  INPUT_POST,
1014  'nodeParent'
1015  )
1016  );
1017  try {
1018  $exists = self::getClass('AccessControlRuleManager')
1019  ->exists($value);
1020  if ($exists) {
1021  throw new Exception(_('A rule already exists with this name.'));
1022  }
1023  $AccessControlRule = self::getClass('AccessControlRule')
1024  ->set('type', $type)
1025  ->set('value', $value)
1026  ->set('name', $name)
1027  ->set('parent', $parent)
1028  ->set('node', $node);
1029  if (!$AccessControlRule->save()) {
1030  throw new Exception(_('Add rule failed!'));
1031  }
1032  $hook = 'RULE_ADD_SUCCESS';
1033  $msg = json_encode(
1034  array(
1035  'msg' => _('Rule added!'),
1036  'title' => _('Rule Create Success')
1037  )
1038  );
1039  } catch (Exception $e) {
1040  $hook = 'RULE_ADD_FAIL';
1041  $msg = json_encode(
1042  array(
1043  'error' => $e->getMessage(),
1044  'title' => _('Rule Create Fail')
1045  )
1046  );
1047  }
1048  self::$HookManager
1049  ->processEvent(
1050  $hook,
1051  array('AccessControlRule' => &$AccessControlRule)
1052  );
1053  unset($AccessControlRule);
1054  echo $msg;
1055  exit;
1056  }
1062  public function editRule()
1063  {
1064  $this->title = _('Edit')
1065  . ': '
1066  . $this->obj->get('name');
1067  unset($this->headerData);
1068  $this->attributes = array(
1069  array('class' => 'col-xs-4'),
1070  array('class' => 'col-xs-8 form-group')
1071  );
1072  $this->templates = array(
1073  '${field}',
1074  '${input}'
1075  );
1076  $type = filter_input(
1077  INPUT_POST,
1078  'type'
1079  ) ?: $this->obj->get('type');
1080  $parent = filter_input(
1081  INPUT_POST,
1082  'parent'
1083  ) ?: $this->obj->get('parent');
1084  $node = filter_input(
1085  INPUT_POST,
1086  'nodeParent'
1087  ) ?: $this->obj->get('node');
1088  $value = filter_input(
1089  INPUT_POST,
1090  'value'
1091  ) ?: $this->obj->get('value');
1092  $fields = array(
1093  '<label for="type">'
1094  . _('Rule Type')
1095  . '</label>' => '<div class="input-group">'
1096  . '<input class="form-control ruletype-input" type='
1097  . '"text" name="type" id="type" required value="'
1098  . $type
1099  . '"/>'
1100  . '</div>',
1101  '<label for="parent">'
1102  . _('Parent')
1103  . '</label>' => '<div class="input-group">'
1104  . '<input class="form-control ruleparent-input" type='
1105  . '"text" name="parent" id="parent" required value="'
1106  . $parent
1107  . '"/>'
1108  . '</div>',
1109  '<label for="nodeParent">'
1110  . _('Node Parent')
1111  . '</label>' => '<div class="input-group">'
1112  . '<input class="form-control rulenodeparent-input" '
1113  . 'type="text" name="nodeParent" id="nodeParent" value="'
1114  . $node
1115  . '"/>'
1116  . '</div>',
1117  '<label for="value">'
1118  . _('Rule Value')
1119  . '</label>' => '<div class="input-group">'
1120  . '<input class="form-control rulevalue-input" '
1121  . 'type="text" name="value" id="value" required value="'
1122  . $value
1123  . '"/>'
1124  . '</div>',
1125  '<label for="updaterule">'
1126  . _('Make Changes?')
1127  . '</label>' => '<button class="btn btn-info btn-block" name="'
1128  . 'updaterule" id="updaterule" type="submit">'
1129  . _('Update')
1130  . '</button>'
1131  );
1132  foreach ((array)$fields as $field => &$input) {
1133  $this->data[] = array(
1134  'field' => $field,
1135  'input' => $input
1136  );
1137  unset($input);
1138  }
1139  self::$HookManager
1140  ->processEvent(
1141  'ACCESSCONTROL_RULE_EDIT',
1142  array(
1143  'headerData' => &$this->headerData,
1144  'data' => &$this->data,
1145  'templates' => &$this->templates,
1146  'attributes' => &$this->attributes
1147  )
1148  );
1149  echo '<div class="col-xs-9 tab-content">';
1150  echo '<div class="tab-pane fade in active" id="rule-general">';
1151  echo '<div class="panel panel-info">';
1152  echo '<div class="panel-heading text-center">';
1153  echo '<h4 class="title">';
1154  echo _('Access Control Rule General');
1155  echo '</h4>';
1156  echo '</div>';
1157  echo '<div class="panel-body">';
1158  echo '<form class="form-horizontal" method="post" action="'
1159  . $this->formAction
1160  . '">';
1161  $this->render(12);
1162  echo '</form>';
1163  echo '</div>';
1164  echo '</div>';
1165  echo '</div>';
1166  echo '</div>';
1167  unset(
1168  $this->data,
1169  $this->form,
1170  $this->headerData,
1171  $this->attributes,
1172  $this->templates
1173  );
1174  }
1180  public function editRulePost()
1181  {
1182  self::$HookManager
1183  ->processEvent(
1184  'ACCESSCONTROL_RULE_EDIT_POST',
1185  array(
1186  'AccessControlRule' => &$this->obj
1187  )
1188  );
1189  $value = trim(
1190  filter_input(
1191  INPUT_POST,
1192  'value'
1193  )
1194  );
1195  $parent = trim(
1196  filter_input(
1197  INPUT_POST,
1198  'parent'
1199  )
1200  );
1201  $node = trim(
1202  filter_input(
1203  INPUT_POST,
1204  'nodeParent'
1205  )
1206  );
1207  $type = trim(
1208  filter_input(
1209  INPUT_POST,
1210  'type'
1211  )
1212  );
1213  try {
1214  if (isset($_POST['updaterule'])) {
1215  $this->obj
1216  ->set('type', $type)
1217  ->set('parent', $parent)
1218  ->set('node', $node)
1219  ->set('value', $value);
1220  if (!$this->obj->save()) {
1221  throw new Exception(_('Failed to update'));
1222  }
1223  $hook = 'ROLE_EDIT_SUCCESS';
1224  $msg = json_encode(
1225  array(
1226  'msg' => _('Rule updated!'),
1227  'title' => _('Rule Update Success')
1228  )
1229  );
1230  }
1231  } catch (Exception $e) {
1232  $hook = 'RULE_EDIT_FAIL';
1233  $msg = json_encode(
1234  array(
1235  'error' => $e->getMessage(),
1236  'title' => _('Rule Update Fail')
1237  )
1238  );
1239  }
1240  self::$HookManager
1241  ->processEvent(
1242  $hook,
1243  array('AccessControlRule' => &$this->obj)
1244  );
1245  echo $msg;
1246  exit;
1247  }
1253  public function deleteRule()
1254  {
1255  $this->title = sprintf(
1256  '%s: %s',
1257  self::$foglang['Remove'],
1258  $this->obj->get('name')
1259  );
1260  unset($this->headerData);
1261  $this->attributes = array(
1262  array('class' => 'col-xs-4'),
1263  array('class' => 'col-xs-8 form-group')
1264  );
1265  $this->templates = array(
1266  '${field}',
1267  '${input}'
1268  );
1269  $fields = array(
1270  '<label for="delete">'
1271  . $this->title
1272  . '</label>' => '<input type="hidden" name="remitems[]" '
1273  . 'value="'
1274  . $this->obj->get('id')
1275  . '"/>'
1276  . '<button type="submit" name="delete" id="delete" '
1277  . 'class="btn btn-danger btn-block">'
1278  . _('Delete')
1279  . '</button>'
1280  );
1281  self::$HookManager
1282  ->processEvent(
1283  'RULE_DEL_FIELDS',
1284  array(
1285  'fields' => &$fields,
1286  'AccessControlRule' => &$this->obj
1287  )
1288  );
1289  foreach ((array)$fields as $field => &$input) {
1290  $this->data[] = array(
1291  'field' => $field,
1292  'input' => $input
1293  );
1294  unset($input);
1295  }
1296  self::$HookManager->processEvent(
1297  'RULE_DEL',
1298  array(
1299  'data' => &$this->data,
1300  'headerData' => &$this->headerData,
1301  'attributes' => &$this->attributes,
1302  'templates' => &$this->templates,
1303  'AccessControlRule' => &$this->obj
1304  )
1305  );
1306  echo '<div class="col-xs-9">';
1307  echo '<div class="panel panel-warning">';
1308  echo '<div class="panel-heading text-center">';
1309  echo '<h4 class="title">';
1310  echo $this->title;
1311  echo '</h4>';
1312  echo '</div>';
1313  echo '<div class="panel-body">';
1314  echo '<div id="deleteDiv"></div>';
1315  echo '<form class="form-horizontal" method="post" action="'
1316  . $this->formAction
1317  . '">';
1318  $this->render(12);
1319  echo '</form>';
1320  echo '</div>';
1321  echo '</div>';
1322  echo '</div>';
1323  }
1329  public function deleteRulePost()
1330  {
1331  if (self::getSetting('FOG_REAUTH_ON_DELETE')) {
1332  $validate = self::getClass('User')
1333  ->passwordValidate(
1334  $_POST['fogguiuser'],
1335  $_POST['fogguipass'],
1336  true
1337  );
1338  if (!$validate) {
1339  echo json_encode(
1340  array(
1341  'error' => self::$foglang['InvalidLogin']
1342  )
1343  );
1344  exit;
1345  }
1346  }
1347  self::$HookManager
1348  ->processEvent(
1349  'ACCESSCONTROL_RULE_DELETE_POST',
1350  array('AccessControlRule' => &$this->obj)
1351  );
1352  try {
1353  if (!$this->obj->destroy()) {
1354  throw new Exception(
1355  _('Fail to destroy')
1356  );
1357  }
1358  $hook = 'ACCESSCONTROL_RULE_DELETE_POST_SUCCESS';
1359  $msg = json_encode(
1360  array(
1361  'msg' => _('Rule deleted successfully!'),
1362  'title' => _('Rule Delete Success')
1363  )
1364  );
1365  $url = sprintf(
1366  '?node=%s&sub=ruleList',
1367  $this->node
1368  );
1369  } catch (Exception $e) {
1370  $hook = 'ACCESSCONTROL_RULE_DELETE_POST_FAIL';
1371  $msg = json_encode(
1372  array(
1373  'error' => $e->getMessage(),
1374  'title' => _('Rule Delete Fail')
1375  )
1376  );
1378  }
1379  self::$HookManager
1380  ->processEvent(
1381  $hook,
1382  array('AccessControlRule'=>&$this->obj)
1383  );
1385  echo $msg;
1387  }
1393  public function assocRule()
1394  {
1395  unset(
1396  $this->data,
1397  $this->form,
1398  $this->headerData,
1399  $this->templates,
1400  $this->attributes
1401  );
1402  $this->headerData = array(
1403  '<label for="toggler2>'
1404  . '<input type="checkbox" name="toggle-checkbox'
1405  . $this->node
1406  . '" class="toggle-checkboxrule" id="toggler2"/>'
1407  . '</label>',
1408  _('Rule Name'),
1409  _('Value'),
1410  _('Parent'),
1411  _('Node')
1412  );
1413  $this->templates = array(
1414  '<label for="rule-${rule_id}">'
1415  . '<input type="checkbox" name="rule[]" class="toggle-'
1416  . 'rule" id="rule-${rule_id}" '
1417  . 'value="${rule_id}"/>'
1418  . '</label>',
1419  '<a href="?node=%s&sub=editRule&id=${rule_id}">'
1420  . '${rule_name}</a>',
1421  '${value}',
1422  '${parent}',
1423  '${node}'
1424  );
1425  $this->attributes = array(
1426  array(
1427  'width' => 16,
1428  'class' => 'filter-false'
1429  ),
1430  array(
1431  'data-toggle' => 'tooltip',
1432  'data-placement' => 'bottom',
1433  'title' => _('Edit')
1434  . ' '
1435  . '${rule_name}'
1436  ),
1437  array(),
1438  array(),
1439  array()
1440  );
1441  Route::listem('accesscontrolrule');
1442  $items = json_decode(
1443  Route::getData()
1444  );
1445  $items = $items->accesscontrolrules;
1446  $getter = 'accesscontrolrulesnotinme';
1447  $returnData = function (&$item) use (&$getter) {
1448  $this->obj->get($getter);
1449  if (!in_array($item->id, (array)$this->obj->get($getter))) {
1450  return;
1451  }
1452  $this->data[] = array(
1453  'rule_id' => $item->id,
1454  'rule_name' => $item->name,
1455  'value' => $item->value,
1456  'parent' => $item->parent,
1457  'node' => $item->node,
1458  );
1459  unset($item);
1460  };
1461  array_walk($items, $returnData);
1462  echo '<!-- Rule Membership -->';
1463  echo '<div class="col-xs-9">';
1464  echo '<div class="tab-pane fade in active" id="'
1465  . $this->node
1466  . '-membership">';
1467  echo '<div class="panel panel-info">';
1468  echo '<div class="panel-heading text-center">';
1469  echo '<h4 class="title">';
1470  echo $this->childClass
1471  . ' '
1472  . _('Rule Membership');
1473  echo '</h4>';
1474  echo '</div>';
1475  echo '<div class="panel-body">';
1476  echo '<form class="form-horizontal" method="post" action="'
1477  . $this->formAction
1478  . '">';
1479  if (count($this->data) > 0) {
1480  $notInMe = $meShow = 'accesscontrolrule';
1481  $meShow .= 'MeShow';
1482  $notInMe .= 'NotInMe';
1483  echo '<div class="text-center">';
1484  echo '<div class="checkbox">';
1485  echo '<label for="'
1486  . $meShow
1487  . '">';
1488  echo '<input type="checkbox" name="'
1489  . $meShow
1490  . '" id="'
1491  . $meShow
1492  . '"/>';
1493  echo _('Check here to see what rules can be added');
1494  echo '</label>';
1495  echo '</div>';
1496  echo '</div>';
1497  echo '<br/>';
1498  echo '<div class="hiddeninitially panel panel-info" id="'
1499  . $notInMe
1500  . '">';
1501  echo '<div class="panel-heading text-center">';
1502  echo '<h4 class="title">';
1503  echo _('Add Rules');
1504  echo '</h4>';
1505  echo '</div>';
1506  echo '<div class="panel-body">';
1507  $this->render(12);
1508  echo '<div class="form-group">';
1509  echo '<label for="updaterules" class="control-label col-xs-4">';
1510  echo _('Add selected rules');
1511  echo '</label>';
1512  echo '<div class="col-xs-8">';
1513  echo '<button type="submit" name="addRules" '
1514  . 'id="updaterules" class="btn btn-info btn-block">'
1515  . _('Add')
1516  . '</button>';
1517  echo '</div>';
1518  echo '</div>';
1519  echo '</div>';
1520  echo '</div>';
1521  }
1522  unset(
1523  $this->data,
1524  $this->form,
1525  $this->headerData,
1526  $this->templates
1527  );
1528  $this->headerData = array(
1529  '<label for="toggler3">'
1530  . '<input type="checkbox" name="toggle-checkbox" '
1531  . 'class="toggle-checkboxrulerm" id="toggler3"/></label>',
1532  _('Rule Name'),
1533  _('Value'),
1534  _('Parent'),
1535  _('Node')
1536  );
1537  $this->templates = array(
1538  '<label for="rulerm-${rule_id}">'
1539  . '<input type="checkbox" name="ruledel[]" class="toggle-'
1540  . 'rulerm" id="rulerm-${rule_id}" '
1541  . 'value="${rule_id}"/>'
1542  . '</label>',
1543  '<a href="?node=%s&sub=editRule&id=${rule_id}">'
1544  . '${rule_name}</a>',
1545  '${value}',
1546  '${parent}',
1547  '${node}'
1548  );
1549  $this->attributes = array(
1550  array(
1551  'width' => 16,
1552  'class' => 'filter-false'
1553  ),
1554  array(
1555  'data-toggle' => 'tooltip',
1556  'data-placement' => 'bottom',
1557  'title' => _('Edit')
1558  . ' '
1559  . '${rule_name}'
1560  ),
1561  array(),
1562  array(),
1563  array()
1564  );
1565  $getter = 'accesscontrolrules';
1566  array_walk($items, $returnData);
1567  if (count($this->data) > 0) {
1568  echo '<div class="panel panel-warning">';
1569  echo '<div class="panel-heading text-center">';
1570  echo '<h4 class="title">';
1571  echo _('Remove Accesscontrol Rules');
1572  echo '</h4>';
1573  echo '</div>';
1574  echo '<div class="panel-body">';
1575  $this->render(12);
1576  echo '<div class="form-group">';
1577  echo '<label for="remrules" class="control-label col-xs-4">';
1578  echo _('Remove selected rules');
1579  echo '</label>';
1580  echo '<div class="col-xs-8">';
1581  echo '<button type="submit" name="remrules" class='
1582  . '"btn btn-danger btn-block" id="remrules">'
1583  . _('Remove')
1584  . '</button>';
1585  echo '</div>';
1586  echo '</div>';
1587  echo '</div>';
1588  echo '</div>';
1589  }
1590  echo '</form>';
1591  echo '</div>';
1592  echo '</div>';
1593  echo '</div>';
1594  echo '</div>';
1595  }
1601  public function assocRulePost()
1602  {
1603  $flags = array(
1604  'flags' => FILTER_REQUIRE_ARRAY
1605  );
1606  $reqitems = filter_input_array(
1607  INPUT_POST,
1608  array(
1609  'rule' => $flags,
1610  'ruledel' => $flags
1611  )
1612  );
1613  $rules = $reqitems['rule'];
1614  $rulesdel = $reqitems['ruledel'];
1615  if (isset($_POST['addRules'])) {
1616  $this->obj->addRule($rules);
1617  }
1618  if (isset($_POST['remrules'])) {
1619  $this->obj->removeRule($rulesdel);
1620  }
1621  if ($this->obj->save()) {
1622  self::redirect($this->formAction);
1623  }
1624  }
1630  public function addRuleGroup()
1631  {
1632  $reqitems = filter_input_array(
1633  INPUT_POST,
1634  array(
1635  'accesscontrol',
1636  'accesscontrolIDArray'
1637  )
1638  );
1639  $accesscontrol = $reqitems['accesscontrol'];
1640  $accesscontrolrules = array_unique(
1641  array_filter(
1642  explode(',', $reqitems['accesscontrolIDArray'])
1643  )
1644  );
1645  try {
1646  if (!$accesscontrol) {
1647  throw new Exception(_('No role selected'));
1648  }
1649  if (count($accesstrolrules) < 1) {
1650  throw new Exception(_('No rule selected'));
1651  }
1652  $Role = new AccessControl($accesscontrol);
1653  foreach ((array)$accesscontrolrules as $ruleID) {
1654  $Rule = new AccessControlRule($ruleID);
1655  $name = $Role->get('name')
1656  . '-'
1657  . $Rule->get('name');
1658  $AccessControlRuleAssociation
1659  = self::getClass('AccessControlRuleAssociation')
1660  ->set('accesscontrolID', $accesscontrol)
1661  ->set('name', $name)
1662  ->set('accesscontrolruleID', $ruleID);
1663  if (!$AccessControlRuleAssociation->save()) {
1664  throw new Exception(_('Associate rule failed!'));
1665  }
1666  unset($AccessControlRuleAssociation);
1667  unset($Rule);
1668  }
1669  unset($ruleID);
1670  $hook = 'RULEASSOC_SUCCESS';
1671  $msg = json_encode(
1672  array(
1673  'msg' => _('Rule associate success!'),
1674  'title' => _('Rule Associate Success')
1675  )
1676  );
1677  } catch (Exception $e) {
1678  $hook = 'RULEASSOC_FAIL';
1679  $msg = json_encode(
1680  array(
1681  'error' => $e->getMessage(),
1682  'title' => _('Rule Associate Fail')
1683  )
1684  );
1685  }
1686  self::$HookManager->processEvent(
1687  $hook
1688  );
1689  echo $msg;
1690  exit;
1691  }
1697  public function membership()
1698  {
1699  unset(
1700  $this->data,
1701  $this->form,
1702  $this->headerData,
1703  $this->templates,
1704  $this->attributes
1705  );
1706  $this->headerData = array(
1707  '<label for="toggler">'
1708  . '<input type="checkbox" name="toggle-checkbox'
1709  . $this->node
1710  . '" class="toggle-checkboxuser" id="toggler"/>'
1711  . '</label>',
1712  _('User name'),
1713  _('Friendly Name')
1714  );
1715  $this->templates = array(
1716  '<label for="user-${user_id}">'
1717  . '<input type="checkbox" name="user[]" class="toggle-'
1718  . 'user" id="user-${user_id}" '
1719  . 'value="${user_id}"/>'
1720  . '</label>',
1721  '<a href="?node=user&sub=edit&id=${user_id}">'
1722  . '${user_name}</a>',
1723  '${friendly}'
1724  );
1725  $this->attributes = array(
1726  array(
1727  'width' => 16,
1728  'class' => 'filter-false'
1729  ),
1730  array(
1731  'data-toggle' => 'tooltip',
1732  'data-placement' => 'bottom',
1733  'title' => _('Edit')
1734  . ' '
1735  . '${user_name}'
1736  ),
1737  array()
1738  );
1739  Route::listem('user');
1740  $items = json_decode(
1741  Route::getData()
1742  );
1743  $items = $items->users;
1744  $getter = 'usersnotinme';
1745  $returnData = function (&$item) use (&$getter) {
1746  $this->obj->get($getter);
1747  if (!in_array($item->id, (array)$this->obj->get($getter))) {
1748  return;
1749  }
1750  $this->data[] = array(
1751  'user_id' => $item->id,
1752  'user_name' => $item->name,
1753  'friendly' => $item->display
1754  );
1755  };
1756  array_walk($items, $returnData);
1757  echo '<!-- Membership -->';
1758  echo '<div class="col-xs-9">';
1759  echo '<div class="tab-pane fade in active" id="'
1760  . $this->node
1761  . '-membership">';
1762  echo '<div class="panel panel-info">';
1763  echo '<div class="panel-heading text-center">';
1764  echo '<h4 class="title">';
1765  echo $this->childClass
1766  . ' '
1767  . _('Membership');
1768  echo '</h4>';
1769  echo '</div>';
1770  echo '<div class="panel-body">';
1771  echo '<form class="form-horizontal" method="post" action="'
1772  . $this->formAction
1773  . '">';
1774  if (count($this->data) > 0) {
1775  $notInMe = $meShow = 'user';
1776  $meShow .= 'MeShow';
1777  $notInMe .= 'NotInMe';
1778  echo '<div class="text-center">';
1779  echo '<div class="checkbox">';
1780  echo '<label for="'
1781  . $meShow
1782  . '">';
1783  echo '<input type="checkbox" name="'
1784  . $meShow
1785  . '" id="'
1786  . $meShow
1787  . '"/>';
1788  echo _('Check here to see what users can be added');
1789  echo '</label>';
1790  echo '</div>';
1791  echo '</div>';
1792  echo '<br/>';
1793  echo '<div class="hiddeninitially panel panel-info" id="'
1794  . $notInMe
1795  . '"/>';
1796  echo '<div class="panel-heading text-center">';
1797  echo '<h4 class="title">';
1798  echo _('Add Users');
1799  echo '</h4>';
1800  echo '</div>';
1801  echo '<div class="panel-body">';
1802  $this->render(12);
1803  echo '<div class="form-group">';
1804  echo '<label for="updateusers" class="control-label col-xs-4">';
1805  echo _('Add selected users');
1806  echo '</label>';
1807  echo '<div class="col-xs-8">';
1808  echo '<button type="submit" name="addUsers" '
1809  . 'id="updateusers" class="btn btn-info btn-block">'
1810  . _('Add')
1811  . '</button>';
1812  echo '</div>';
1813  echo '</div>';
1814  echo '</div>';
1815  echo '</div>';
1816  }
1817  unset(
1818  $this->data,
1819  $this->form,
1820  $this->headerData,
1821  $this->templates
1822  );
1823  $this->headerData = array(
1824  '<label for="toggler1">'
1825  . '<input type="checkbox" name="toggle-checkbox" '
1826  . 'class="toggle-checkboxuserrm" id="toggler1"/></label>',
1827  _('User Name'),
1828  _('Friendly Name')
1829  );
1830  $this->templates = array(
1831  '<label for="userrm-${user_id}">'
1832  . '<input type="checkbox" name="userdel[]" '
1833  . 'value="${user_id}" class="toggle-userrm" id="'
1834  . 'userrm-${user_id}"/>'
1835  . '</label>',
1836  '<a href="?node=user&sub=edit&id=${user_id}">'
1837  . '${user_name}</a>',
1838  '${friendly}'
1839  );
1840  $getter = 'users';
1841  array_walk($items, $returnData);
1842  if (count($this->data) > 0) {
1843  echo '<div class="panel panel-warning">';
1844  echo '<div class="panel-heading text-center">';
1845  echo '<h4 class="title">';
1846  echo _('Remove Users');
1847  echo '</h4>';
1848  echo '</div>';
1849  echo '<div class="panel-body">';
1850  $this->render(12);
1851  echo '<div class="form-group">';
1852  echo '<label for="remusers" class="control-label col-xs-4">';
1853  echo _('Remove selected users');
1854  echo '</label>';
1855  echo '<div class="col-xs-8">';
1856  echo '<button type="submit" name="remusers" class='
1857  . '"btn btn-danger btn-block" id="remusers">'
1858  . _('Remove')
1859  . '</button>';
1860  echo '</div>';
1861  echo '</div>';
1862  echo '</div>';
1863  echo '</div>';
1864  }
1865  echo '</form>';
1866  echo '</div>';
1867  echo '</div>';
1868  echo '</div>';
1869  echo '</div>';
1870  }
1876  public function membershipPost()
1877  {
1878  $flags = array(
1879  'flags' => FILTER_REQUIRE_ARRAY
1880  );
1881  $reqitems = filter_input_array(
1882  INPUT_POST,
1883  array(
1884  'user' => $flags,
1885  'userdel' => $flags
1886  )
1887  );
1888  $users = $reqitems['user'];
1889  $usersdel = $reqitems['userdel'];
1890  if (isset($_POST['addUsers'])) {
1891  $this->obj->addUser($users);
1892  }
1893  if (isset($_POST['remusers'])) {
1894  $this->obj->removeUser($usersdel);
1895  }
1896  if ($this->obj->save()) {
1897  self::redirect($this->formAction);
1898  }
1899  }
1900 }
AccessControlManagementPage
Definition: accesscontrolmanagementpage.class.php:23
FOGPage\render
render($colsize=9)
Definition: fogpage.class.php:605
exit
exit
Definition: download.php:102
AccessControlManagementPage\addRolePost
addRolePost()
Definition: accesscontrolmanagementpage.class.php:314
FOGPage\$formAction
$formAction
Definition: fogpage.class.php:141
AccessControlManagementPage\deleteRulePost
deleteRulePost()
Definition: accesscontrolmanagementpage.class.php:1329
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
AccessControlManagementPage\$node
$node
Definition: accesscontrolmanagementpage.class.php:24
AccessControlManagementPage\deleteRule
deleteRule()
Definition: accesscontrolmanagementpage.class.php:1253
FOGPage\$title
$title
Definition: fogpage.class.php:49
AccessControlManagementPage\__construct
__construct($name='')
Definition: accesscontrolmanagementpage.class.php:32
AccessControlManagementPage\addRule
addRule()
Definition: accesscontrolmanagementpage.class.php:882
FOGPage\$returnData
static $returnData
Definition: fogpage.class.php:201
AccessControl
Definition: accesscontrol.class.php:23
$exists
$exists
Definition: check_node_exists.php:26
$items
$items
Definition: boot.php:24
AccessControlManagementPage\membershipPost
membershipPost()
Definition: accesscontrolmanagementpage.class.php:1876
$user
$user
Definition: advanced.php:38
AccessControlManagementPage\addRuleGroup
addRuleGroup()
Definition: accesscontrolmanagementpage.class.php:1630
FOGPage\$name
$name
Definition: fogpage.class.php:31
AccessControlManagementPage\addRulePost
addRulePost()
Definition: accesscontrolmanagementpage.class.php:984
AccessControlManagementPage\editRulePost
editRulePost()
Definition: accesscontrolmanagementpage.class.php:1180
AccessControlManagementPage\add
add()
Definition: accesscontrolmanagementpage.class.php:323
AccessControlManagementPage\assocRule
assocRule()
Definition: accesscontrolmanagementpage.class.php:1393
AccessControlManagementPage\deletemultiRule
deletemultiRule()
Definition: accesscontrolmanagementpage.class.php:734
AccessControlManagementPage\deletemultiRuleAjax
deletemultiRuleAjax()
Definition: accesscontrolmanagementpage.class.php:830
AccessControlManagementPage\ruleList
ruleList()
Definition: accesscontrolmanagementpage.class.php:611
AccessControlRule
Definition: accesscontrolrule.class.php:23
FOGBase\redirect
static redirect($url='')
Definition: fogbase.class.php:831
FOGPage
Definition: fogpage.class.php:25
AccessControlManagementPage\membership
membership()
Definition: accesscontrolmanagementpage.class.php:1697
Route\getData
static getData()
Definition: route.class.php:1173
FOGPage\$id
$id
Definition: fogpage.class.php:43
Route\listem
static listem( $class, $sortby='name', $bypass=false, $find=array(), $item='')
Definition: route.class.php:429
AccessControlManagementPage\editPost
editPost()
Definition: accesscontrolmanagementpage.class.php:557
AccessControlManagementPage\edit
edit()
Definition: accesscontrolmanagementpage.class.php:466
$foglang
$foglang['Display']
Definition: text.php:22
FOGBase\resetRequest
static resetRequest()
Definition: fogbase.class.php:983
$msg
if($Host->isValid()) $msg
Definition: hostnameloop.php:42
$url
$url
Definition: kernelvers.php:27
FOGBase\setMessage
static setMessage($txt, $data=array())
Definition: fogbase.class.php:784
AccessControlManagementPage\assocRulePost
assocRulePost()
Definition: accesscontrolmanagementpage.class.php:1601
$link
$link
Definition: dbrunning.php:26
$pass
$pass
Definition: hostinfo.php:161
AccessControlManagementPage\addPost
addPost()
Definition: accesscontrolmanagementpage.class.php:407
AccessControlManagementPage\editRule
editRule()
Definition: accesscontrolmanagementpage.class.php:1062
AccessControlManagementPage\addRole
addRole()
Definition: accesscontrolmanagementpage.class.php:305