37 $this->name = _(
'Access Control Management');
41 self::$HookManager->processEvent(
43 array(
'PagesWithObjects' => &$this->PagesWithObjects)
52 self::$foglang[
'ExportAccesscontrol'] = _(
'Export Accesscontrols');
53 self::$foglang[
'ImportAccesscontrol'] = _(
'Import Accesscontrols');
60 parent::__construct($this->name);
62 $this->subMenu = array(
66 '?node=%s&sub=%s&id=%s',
70 ) => _(
'Rule Association'),
74 _(
'Role Name') => $this->obj->get(
'name'),
75 _(
'Description') => $this->obj->get(
'description'),
80 parent::__construct($this->name);
87 $assocrule = preg_match(
117 $this->childClass =
'AccessControlRuleAssociation';
119 $this->childClass =
'AccessControlAssociation';
121 $this->childClass =
'AccessControl';
123 $this->childClass =
'AccessControlRule';
125 $this->childClass =
'AccessControl';
130 parent::__construct($this->name);
132 $this->subMenu = array(
136 '?node=%s&sub=%s&id=%s',
140 ) => _(
'Rule Association'),
143 $this->notes = array(
144 _(
'Role Name') => $this->obj->get(
'name'),
145 _(
'Description') => $this->obj->get(
'description'),
151 $this->childClass =
'AccessControlRule';
153 $this->obj =
new $this->childClass(
$id);
155 '?node=%s&sub=%s&%s=%d',
161 $this->linkformat = sprintf(
165 $this->subMenu = array(
168 '?node=%s&sub=%s&id=%s',
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'),
184 parent::__construct($this->name);
185 $this->childClass =
'AccessControlRule';
188 parent::__construct($this->name);
194 if (in_array($this->node, $this->PagesWithObjects)) {
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'];
216 if (
$id === 0 || !is_numeric(
$id)) {
220 _(
'%s ID %d is not valid'),
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']
242 switch (strtolower($this->childClass)) {
243 case 'accesscontrol':
244 $this->headerData = array(
245 '<input type="checkbox" name="toggle-checkbox" class='
246 .
'"toggle-checkboxAction"/>',
248 _(
'Role Description'),
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>',
257 $this->attributes = array(
259 'class' =>
'filter-false',
267 'ACCESSCONTROL_DATA',
269 'headerData' => &$this->headerData,
270 'data' => &$this->data,
271 'templates' => &$this->templates,
272 'attributes' => &$this->attributes
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
283 unset($AccessControl);
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
295 unset($AccessControlRule);
332 $this->title = _(
'New Role');
333 $this->attributes = array(
334 array(
'class' =>
'col-xs-4'),
335 array(
'class' =>
'col-xs-8 form-group'),
337 $this->templates = array(
341 $name = filter_input(INPUT_POST,
'name');
342 $desc = filter_input(INPUT_POST,
'description');
346 .
'</label>' =>
'<div class="input-group">'
347 .
'<input type="text" name="name" id="name" class="form-control" value="'
352 . _(
'Role Description')
353 .
'</label>' =>
'<div class="input-group">'
354 .
'<textarea class="form-control" name="description" '
360 . _(
'Create New Access Control Role')
361 .
'</label>' =>
'<button type="submit" name="add" id="add" '
362 .
'class="btn btn-info btn-block">'
366 array_walk($fields, $this->fieldsToData);
371 'headerData' => &$this->headerData,
372 'data' => &$this->data,
373 'templates' => &$this->templates,
374 'attributes' => &$this->attributes
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">';
385 echo
'<div class="panel-body">';
386 echo
'<form class="form-horizontal" method="post" action="'
409 $name = filter_input(
413 $desc = filter_input(
420 _(
'A name is required!')
427 _(
'A role already exists with this name!')
432 ->set(
'description', $desc);
433 if (!$AccessControl->save()) {
434 throw new Exception(_(
'Add role failed!'));
436 $hook =
'ROLE_ADD_SUCCESS';
439 'msg' => _(
'Role added!'),
440 'title' => _(
'Role Create Success')
443 }
catch (Exception $e) {
444 $hook =
'ROLE_ADD_FAIL';
447 'error' => $e->getMessage(),
448 'title' => _(
'Role Create Fail')
455 array(
'AccessControl' => &$AccessControl)
457 unset($AccessControl);
475 $this->title = sprintf(
478 $this->obj->get(
'name')
480 $this->attributes = array(
481 array(
'class' =>
'col-xs-4'),
482 array(
'class' =>
'col-xs-8 form-group'),
484 $this->templates = array(
488 $name = filter_input(INPUT_POST,
'name') ?:
489 $this->obj->get(
'name');
490 $desc = filter_input(INPUT_POST,
'description') ?:
491 $this->obj->get(
'description');
495 .
'</label>' =>
'<div class="input-group">'
496 .
'<input type="text" name="name" id="name" class="form-control" value="'
501 . _(
'Role Description')
502 .
'</label>' =>
'<div class="input-group">'
503 .
'<textarea class="form-control" name="description" '
508 '<label for="update">'
510 .
'</label>' =>
'<button type="submit" name="update" id="update" '
511 .
'class="btn btn-info btn-block">'
515 array_walk($fields, $this->fieldsToData);
518 'ACCESSCONTROL_EDIT',
520 'headerData' => &$this->headerData,
521 'data' => &$this->data,
522 'templates' => &$this->templates,
523 'attributes' => &$this->attributes
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');
534 echo
'<div class="panel-body">';
535 echo
'<form class="form-horizontal" method="post" action="'
561 'ACCESSCONTROL_EDIT_POST',
563 'AccessControl' => &$this->obj
566 $name = filter_input(INPUT_POST,
'name');
567 $desc = filter_input(INPUT_POST,
'description');
569 if (
$name != $this->obj->get(
'name')
570 && $this->obj->getManager()->exists(
$name)
572 throw new Exception(_(
'A role already exists with this name!'));
574 if (isset($_POST[
'update'])) {
577 ->set(
'description', $desc);
578 if (!$this->obj->save()) {
579 throw new Exception(_(
'Role update failed!'));
581 $hook =
'ROLE_EDIT_SUCCESS';
584 'msg' => _(
'Role updated!'),
585 'title' => _(
'Role Update Success')
589 }
catch (Exception $e) {
590 $hook =
'ROLE_EDIT_FAIL';
593 'error' => $e->getMessage(),
594 'title' => _(
'Role Update Fail')
601 array(
'AccessControl' => &$this->obj)
620 $this->title = _(
'Access Control Rules');
621 $this->headerData = array(
622 '<input type="checkbox" name="toggle-checkbox" class='
623 .
'"toggle-checkboxAction"/>',
629 $this->templates = array(
630 '<input type="checkbox" name="rule[]" value='
631 .
'"${id}" class="toggle-action"/>',
633 '<a href="?node=%s&sub=editRule&%s=${id}" title='
634 .
'"%s">${type}</a>',
643 $this->attributes = array(
645 'class' =>
'filter-false',
654 $AccessControlRules = json_decode(
657 $AccessControlRules = $AccessControlRules->accesscontrolrules;
658 array_walk($AccessControlRules, static::$returnData);
663 'headerData' => &$this->headerData,
664 'data' => &$this->data,
665 'templates' => &$this->templates,
666 'attributes' => &$this->attributes
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">';
676 echo
'<div class="panel-body">';
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');
687 echo
'<div class="panel-body">';
690 parse_str($components[
'query'], $vars);
691 $vars[
'sub'] =
'deletemultiRule';
693 echo
'<form class="form-horizontal" method="post" action="'
696 echo
'<div class="form-group">';
697 echo
'<label class="control-label col-xs-4" for="del-'
700 echo _(
'Delete Selected');
702 echo $this->node .
'rules';
704 echo
'<div class="col-xs-8">';
705 echo
'<input type="hidden" name="'
708 echo
'<button type="submit" class='
709 .
'"btn btn-danger btn-block" id="'
738 $this->title = sprintf(
740 _(
'Access Control Rule')
749 $this->templates = array(
753 $this->attributes = array(
754 array(
'class' =>
'col-xs-4'),
755 array(
'class' =>
'col-xs-8 form-group')
763 $reqID = array_values(
775 foreach ((array)
$items as &$object) {
776 if (!in_array($object->id, $reqID)) {
779 $this->data[] = array(
780 'field' =>
'<input type="hidden" value="'
782 .
'" name="remitems[]"/>',
783 'input' =>
'<a href="?node='
785 .
'&sub=editRule&id='
793 if (count($this->data) < 1) {
796 $this->data[] = array(
797 'field' =>
'<label for="delete">'
798 . _(
'Remove these items?')
800 'input' =>
'<button class="btn btn-danger btn-block" type="submit" '
801 .
'name="delete" id="delete">'
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">';
813 echo
'<div class="panel-body">';
814 echo
'<div id="deleteDiv"></div>';
815 echo
'<form class="form-horizontal" action="'
819 echo
'<input type="hidden" name="storagegroup" value="0"/>';
832 if (self::getSetting(
'FOG_REAUTH_ON_DELETE')) {
833 $user = filter_input(INPUT_POST,
'fogguiuser');
834 $pass = filter_input(INPUT_POST,
'fogguipass');
845 'title' => _(
'Unable to Authenticate')
851 $remitems = filter_input_array(
855 'flags' => FILTER_REQUIRE_ARRAY
859 $remitems = $remitems[
'remitems'];
860 self::$HookManager->processEvent(
862 array(
'removing' => &$remitems)
867 array(
'id' => $remitems)
871 'msg' => _(
'Successfully deleted'),
872 'title' => _(
'Delete Success')
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'),
890 $this->templates = array(
894 $type = filter_input(
898 $parent = filter_input(
902 $node = filter_input(
906 $value = filter_input(
913 .
'</label>' =>
'<div class="input-group">'
914 .
'<input class="form-control ruletype-input" type='
915 .
'"text" name="type" id="type" required value="'
919 '<label for="parent">'
921 .
'</label>' =>
'<div class="input-group">'
922 .
'<input class="form-control ruleparent-input" type='
923 .
'"text" name="parent" id="parent" required value="'
927 '<label for="nodeParent">'
929 .
'</label>' =>
'<div class="input-group">'
930 .
'<input class="form-control rulenodeparent-input" '
931 .
'type="text" name="nodeParent" id="nodeParent" value="'
935 '<label for="value">'
937 .
'</label>' =>
'<div class="input-group">'
938 .
'<input class="form-control rulevalue-input" '
939 .
'type="text" name="value" id="value" required value="'
945 .
'</label>' =>
'<button class="btn btn-info btn-blcok" name="'
946 .
'add" id="add" type="submit">'
950 array_walk($fields, $this->fieldsToData);
953 'ACCESSCONTROL_RULE_ADD',
955 'headerData' => &$this->headerData,
956 'data' => &$this->data,
957 'templates' => &$this->templates,
958 'attributes' => &$this->attributes
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">';
969 echo
'<div class="panel-body">';
970 echo
'<form class="form-horizontal" method="post" action="'
1021 throw new Exception(_(
'A rule already exists with this name.'));
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!'));
1032 $hook =
'RULE_ADD_SUCCESS';
1035 'msg' => _(
'Rule added!'),
1036 'title' => _(
'Rule Create Success')
1039 }
catch (Exception $e) {
1040 $hook =
'RULE_ADD_FAIL';
1043 'error' => $e->getMessage(),
1044 'title' => _(
'Rule Create Fail')
1051 array(
'AccessControlRule' => &$AccessControlRule)
1053 unset($AccessControlRule);
1064 $this->title = _(
'Edit')
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')
1072 $this->templates = array(
1076 $type = filter_input(
1079 ) ?: $this->obj->get(
'type');
1080 $parent = filter_input(
1083 ) ?: $this->obj->get(
'parent');
1084 $node = filter_input(
1087 ) ?: $this->obj->get(
'node');
1088 $value = filter_input(
1091 ) ?: $this->obj->get(
'value');
1093 '<label for="type">'
1095 .
'</label>' =>
'<div class="input-group">'
1096 .
'<input class="form-control ruletype-input" type='
1097 .
'"text" name="type" id="type" required value="'
1101 '<label for="parent">'
1103 .
'</label>' =>
'<div class="input-group">'
1104 .
'<input class="form-control ruleparent-input" type='
1105 .
'"text" name="parent" id="parent" required value="'
1109 '<label for="nodeParent">'
1111 .
'</label>' =>
'<div class="input-group">'
1112 .
'<input class="form-control rulenodeparent-input" '
1113 .
'type="text" name="nodeParent" id="nodeParent" value="'
1117 '<label for="value">'
1119 .
'</label>' =>
'<div class="input-group">'
1120 .
'<input class="form-control rulevalue-input" '
1121 .
'type="text" name="value" id="value" required value="'
1125 '<label for="updaterule">'
1126 . _(
'Make Changes?')
1127 .
'</label>' =>
'<button class="btn btn-info btn-block" name="'
1128 .
'updaterule" id="updaterule" type="submit">'
1132 foreach ((array)$fields as $field => &$input) {
1133 $this->data[] = array(
1141 'ACCESSCONTROL_RULE_EDIT',
1143 'headerData' => &$this->headerData,
1144 'data' => &$this->data,
1145 'templates' => &$this->templates,
1146 'attributes' => &$this->attributes
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');
1157 echo
'<div class="panel-body">';
1158 echo
'<form class="form-horizontal" method="post" action="'
1184 'ACCESSCONTROL_RULE_EDIT_POST',
1186 'AccessControlRule' => &$this->obj
1214 if (isset($_POST[
'updaterule'])) {
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'));
1223 $hook =
'ROLE_EDIT_SUCCESS';
1226 'msg' => _(
'Rule updated!'),
1227 'title' => _(
'Rule Update Success')
1231 }
catch (Exception $e) {
1232 $hook =
'RULE_EDIT_FAIL';
1235 'error' => $e->getMessage(),
1236 'title' => _(
'Rule Update Fail')
1243 array(
'AccessControlRule' => &$this->obj)
1255 $this->title = sprintf(
1258 $this->obj->get(
'name')
1260 unset($this->headerData);
1261 $this->attributes = array(
1262 array(
'class' =>
'col-xs-4'),
1263 array(
'class' =>
'col-xs-8 form-group')
1265 $this->templates = array(
1270 '<label for="delete">'
1272 .
'</label>' =>
'<input type="hidden" name="remitems[]" '
1274 . $this->obj->get(
'id')
1276 .
'<button type="submit" name="delete" id="delete" '
1277 .
'class="btn btn-danger btn-block">'
1285 'fields' => &$fields,
1286 'AccessControlRule' => &$this->obj
1289 foreach ((array)$fields as $field => &$input) {
1290 $this->data[] = array(
1296 self::$HookManager->processEvent(
1299 'data' => &$this->data,
1300 'headerData' => &$this->headerData,
1301 'attributes' => &$this->attributes,
1302 'templates' => &$this->templates,
1303 'AccessControlRule' => &$this->obj
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">';
1313 echo
'<div class="panel-body">';
1314 echo
'<div id="deleteDiv"></div>';
1315 echo
'<form class="form-horizontal" method="post" action="'
1331 if (self::getSetting(
'FOG_REAUTH_ON_DELETE')) {
1334 $_POST[
'fogguiuser'],
1335 $_POST[
'fogguipass'],
1349 'ACCESSCONTROL_RULE_DELETE_POST',
1350 array(
'AccessControlRule' => &$this->obj)
1353 if (!$this->obj->destroy()) {
1354 throw new Exception(
1355 _(
'Fail to destroy')
1358 $hook =
'ACCESSCONTROL_RULE_DELETE_POST_SUCCESS';
1361 'msg' => _(
'Rule deleted successfully!'),
1362 'title' => _(
'Rule Delete Success')
1366 '?node=%s&sub=ruleList',
1369 }
catch (Exception $e) {
1370 $hook =
'ACCESSCONTROL_RULE_DELETE_POST_FAIL';
1373 'error' => $e->getMessage(),
1374 'title' => _(
'Rule Delete Fail')
1382 array(
'AccessControlRule'=>&$this->obj)
1402 $this->headerData = array(
1403 '<label for="toggler2>'
1404 .
'<input type="checkbox" name="toggle-checkbox'
1406 .
'" class="toggle-checkboxrule" id="toggler2"/>'
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}"/>'
1419 '<a href="?node=%s&sub=editRule&id=${rule_id}">'
1420 .
'${rule_name}</a>',
1425 $this->attributes = array(
1428 'class' =>
'filter-false'
1431 'data-toggle' =>
'tooltip',
1432 'data-placement' =>
'bottom',
1433 'title' => _(
'Edit')
1446 $getter =
'accesscontrolrulesnotinme';
1448 $this->obj->get($getter);
1449 if (!in_array($item->id, (array)$this->obj->get($getter))) {
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,
1462 echo
'<!-- Rule Membership -->';
1463 echo
'<div class="col-xs-9">';
1464 echo
'<div class="tab-pane fade in active" id="'
1467 echo
'<div class="panel panel-info">';
1468 echo
'<div class="panel-heading text-center">';
1469 echo
'<h4 class="title">';
1470 echo $this->childClass
1472 . _(
'Rule Membership');
1475 echo
'<div class="panel-body">';
1476 echo
'<form class="form-horizontal" method="post" action="'
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">';
1488 echo
'<input type="checkbox" name="'
1493 echo _(
'Check here to see what rules can be added');
1498 echo
'<div class="hiddeninitially panel panel-info" id="'
1501 echo
'<div class="panel-heading text-center">';
1502 echo
'<h4 class="title">';
1503 echo _(
'Add Rules');
1506 echo
'<div class="panel-body">';
1508 echo
'<div class="form-group">';
1509 echo
'<label for="updaterules" class="control-label col-xs-4">';
1510 echo _(
'Add selected rules');
1512 echo
'<div class="col-xs-8">';
1513 echo
'<button type="submit" name="addRules" '
1514 .
'id="updaterules" class="btn btn-info btn-block">'
1528 $this->headerData = array(
1529 '<label for="toggler3">'
1530 .
'<input type="checkbox" name="toggle-checkbox" '
1531 .
'class="toggle-checkboxrulerm" id="toggler3"/></label>',
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}"/>'
1543 '<a href="?node=%s&sub=editRule&id=${rule_id}">'
1544 .
'${rule_name}</a>',
1549 $this->attributes = array(
1552 'class' =>
'filter-false'
1555 'data-toggle' =>
'tooltip',
1556 'data-placement' =>
'bottom',
1557 'title' => _(
'Edit')
1565 $getter =
'accesscontrolrules';
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');
1574 echo
'<div class="panel-body">';
1576 echo
'<div class="form-group">';
1577 echo
'<label for="remrules" class="control-label col-xs-4">';
1578 echo _(
'Remove selected rules');
1580 echo
'<div class="col-xs-8">';
1581 echo
'<button type="submit" name="remrules" class='
1582 .
'"btn btn-danger btn-block" id="remrules">'
1604 'flags' => FILTER_REQUIRE_ARRAY
1606 $reqitems = filter_input_array(
1613 $rules = $reqitems[
'rule'];
1614 $rulesdel = $reqitems[
'ruledel'];
1615 if (isset($_POST[
'addRules'])) {
1616 $this->obj->addRule($rules);
1618 if (isset($_POST[
'remrules'])) {
1619 $this->obj->removeRule($rulesdel);
1621 if ($this->obj->save()) {
1632 $reqitems = filter_input_array(
1636 'accesscontrolIDArray'
1639 $accesscontrol = $reqitems[
'accesscontrol'];
1640 $accesscontrolrules = array_unique(
1642 explode(
',', $reqitems[
'accesscontrolIDArray'])
1646 if (!$accesscontrol) {
1647 throw new Exception(_(
'No role selected'));
1649 if (count($accesstrolrules) < 1) {
1650 throw new Exception(_(
'No rule selected'));
1653 foreach ((array)$accesscontrolrules as $ruleID) {
1655 $name = $Role->get(
'name')
1657 . $Rule->get(
'name');
1658 $AccessControlRuleAssociation
1660 ->set(
'accesscontrolID', $accesscontrol)
1661 ->set(
'name',
$name)
1662 ->set(
'accesscontrolruleID', $ruleID);
1663 if (!$AccessControlRuleAssociation->save()) {
1664 throw new Exception(_(
'Associate rule failed!'));
1666 unset($AccessControlRuleAssociation);
1670 $hook =
'RULEASSOC_SUCCESS';
1673 'msg' => _(
'Rule associate success!'),
1674 'title' => _(
'Rule Associate Success')
1677 }
catch (Exception $e) {
1678 $hook =
'RULEASSOC_FAIL';
1681 'error' => $e->getMessage(),
1682 'title' => _(
'Rule Associate Fail')
1686 self::$HookManager->processEvent(
1706 $this->headerData = array(
1707 '<label for="toggler">'
1708 .
'<input type="checkbox" name="toggle-checkbox'
1710 .
'" class="toggle-checkboxuser" id="toggler"/>'
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}"/>'
1721 '<a href="?node=user&sub=edit&id=${user_id}">'
1722 .
'${user_name}</a>',
1725 $this->attributes = array(
1728 'class' =>
'filter-false'
1731 'data-toggle' =>
'tooltip',
1732 'data-placement' =>
'bottom',
1733 'title' => _(
'Edit')
1744 $getter =
'usersnotinme';
1746 $this->obj->get($getter);
1747 if (!in_array($item->id, (array)$this->obj->get($getter))) {
1750 $this->data[] = array(
1751 'user_id' => $item->id,
1752 'user_name' => $item->name,
1753 'friendly' => $item->display
1757 echo
'<!-- Membership -->';
1758 echo
'<div class="col-xs-9">';
1759 echo
'<div class="tab-pane fade in active" id="'
1762 echo
'<div class="panel panel-info">';
1763 echo
'<div class="panel-heading text-center">';
1764 echo
'<h4 class="title">';
1765 echo $this->childClass
1770 echo
'<div class="panel-body">';
1771 echo
'<form class="form-horizontal" method="post" action="'
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">';
1783 echo
'<input type="checkbox" name="'
1788 echo _(
'Check here to see what users can be added');
1793 echo
'<div class="hiddeninitially panel panel-info" id="'
1796 echo
'<div class="panel-heading text-center">';
1797 echo
'<h4 class="title">';
1798 echo _(
'Add Users');
1801 echo
'<div class="panel-body">';
1803 echo
'<div class="form-group">';
1804 echo
'<label for="updateusers" class="control-label col-xs-4">';
1805 echo _(
'Add selected users');
1807 echo
'<div class="col-xs-8">';
1808 echo
'<button type="submit" name="addUsers" '
1809 .
'id="updateusers" class="btn btn-info btn-block">'
1823 $this->headerData = array(
1824 '<label for="toggler1">'
1825 .
'<input type="checkbox" name="toggle-checkbox" '
1826 .
'class="toggle-checkboxuserrm" id="toggler1"/></label>',
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}"/>'
1836 '<a href="?node=user&sub=edit&id=${user_id}">'
1837 .
'${user_name}</a>',
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');
1849 echo
'<div class="panel-body">';
1851 echo
'<div class="form-group">';
1852 echo
'<label for="remusers" class="control-label col-xs-4">';
1853 echo _(
'Remove selected users');
1855 echo
'<div class="col-xs-8">';
1856 echo
'<button type="submit" name="remusers" class='
1857 .
'"btn btn-danger btn-block" id="remusers">'
1879 'flags' => FILTER_REQUIRE_ARRAY
1881 $reqitems = filter_input_array(
1888 $users = $reqitems[
'user'];
1889 $usersdel = $reqitems[
'userdel'];
1890 if (isset($_POST[
'addUsers'])) {
1891 $this->obj->addUser($users);
1893 if (isset($_POST[
'remusers'])) {
1894 $this->obj->removeUser($usersdel);
1896 if ($this->obj->save()) {