edit-groups.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief окно установки групп доступа для модели
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 if (!($row = Wrong\Database\Controller::find($_GET['id'], 'id', $_GET['table']))) {
11  exit('<script>errorToast("Ошибка!");</script>');
12 }
13 
14 $groups = json_decode($row->groups, true);
15 $owner_group = $row->owner_group;
16 
17 ?>
18 <div class="modal fade" id="<?= $basename ?>" tabindex="-1" data-backdrop="static" data-keyboard="false">
19  <div class="modal-dialog modal-dialog-centered" role="document">
20  <div class="modal-content">
21  <div class="modal-header">
22  <h5 class="modal-title">Группы доступа</h5>
23  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
24  <span aria-hidden="true">&times;</span>
25  </button>
26  </div>
27  <div class="modal-body pt-2">
28  <form action="<?= Wrong\Models\Actions::find(10)->request ?>">
29  <input type="hidden" name="id" value="<?= $row->id ?>">
30  <input type="hidden" name="table" value="<?= $_GET['table'] ?>">
31  <div class="border px-2 py-1 rounded bg-light-info">
32  <small><a onclick="if(~~this.dataset.checked){$(this).html('Отметить все');this.dataset.checked=0;$(this).parents('form').find('[name^=groups]').prop('checked', false);}else{$(this).html('Снять все');this.dataset.checked=1;$(this).parents('form').find('[name^=groups]').prop('checked', true);}return false;" href="#">Отметить все</a></small>
33  <?php
34  foreach (Wrong\Rights\Group::$groups_not_system as $row) {
35  if ($_GET['table'] == 'users' && !in_array($row->id, $user->subordinate_groups)) continue;
36  echo '<div class="custom-control custom-checkbox small">
37  <input type="checkbox" name="groups[' . $row->id . ']" class="custom-control-input" id="check-group-' . $row->id . '" ' . (in_array($row->id, $groups) ? 'checked' : '') . '>
38  <label class="custom-control-label" for="check-group-' . $row->id . '">' . Wrong\Rights\Group::text($row->id) . '</label>
39  </div>';
40  }
41  ?>
42  </div>
43  <button type="submit" class="btn btn-sm btn-block btn-success mt-3">Сохранить</button>
44  </form>
45  </div>
46  </div>
47  </div>
48  <script>
49  $("#<?= $basename ?> form").submit(function(e) {
50  lockSubmit($("#<?= $basename ?> form [type=submit]"));
51  e.preventDefault();
52  $.ajax({
53  type: "POST",
54  url: $(this).attr("action"),
55  data: $(this).serialize(),
56  dataType: "json",
57  statusCode: {
58  404: errorToast,
59  403: errorToast
60  }
61  })
62  .done(response => {
63  if (response.error) {
64  errorToast(response.error);
65  return;
66  }
67  $('.dataTable').DataTable().ajax.reload(null, false);
68  $('.toast').toast('hide');
69  successToast(response.message);
70  $("#<?= $basename ?>").modal("hide");
71  })
72  .always(() => {
73  unlockSubmit($("#<?= $basename ?> form [type=submit]"));
74  });
75  });
76  <?php if ($owner_group == 1) : ?>
77  $('.toast').toast('hide');
78  dangerToast('Владелец Система. Изменение групп доступа для системного функционала может привести к нежелательным последствиям!', 15000);
79  <?php endif; ?>
80  </script>
81 </div>
$user
Definition: from-user.php:38
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
Definition: from-user.php:36
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
Definition: install.php:198
$owner_group
Definition: edit-groups.php:15
endif
Definition: edit-groups.php:79
if(!($row=Wrong\Database\Controller::find($_GET['id'], 'id', $_GET['table']))) $groups
Definition: edit-groups.php:14
href
Definition: main.php:21