group_permissions.inc.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @package chamilo.permissions
  4. */
  5. include_once 'permissions_functions.inc.php';
  6. include_once 'all_permissions.inc.php';
  7. $group_id = api_get_group_id();
  8. echo $group_id;
  9. // ACTIONS
  10. if ($_POST['StoreGroupPermissions'] and $setting_visualisation == 'checkbox') {
  11. $result_message = store_permissions('group', $group_id);
  12. if ($result_message) {
  13. echo Display::return_message($result_message);
  14. }
  15. }
  16. if (isset($_GET['action'])) {
  17. if (($_GET['action'] == 'grant' or $_GET['action'] == 'revoke') and isset($_GET['permission']) and isset($_GET['tool'])) {
  18. $result_message = store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']);
  19. }
  20. if (isset($_GET['role']) and ($_GET['action'] == 'grant' or $_GET['action'] == 'revoke')) {
  21. $result_message = assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']);
  22. echo 'hier';
  23. }
  24. }
  25. if (isset($result_message)) {
  26. echo Display::return_message($result_message);
  27. }
  28. // RETRIEVING THE PERMISSIONS
  29. $current_group_permissions = [];
  30. $current_group_permissions = get_permissions('group', $group_id);
  31. // @todo current group permissions and current role permissions
  32. // INHERITED PERMISSIONS (group roles)
  33. $group_course_roles_permissions = get_roles_permissions('group', $group_id, 'course');
  34. $group_platform_roles_permissions = get_roles_permissions('group', $group_id, 'platform');
  35. $inherited_permissions = permission_array_merge($group_course_roles_permissions, $group_platform_roles_permissions);
  36. // LIMITED OR FULL
  37. $current_group_permissions = limited_or_full($current_group_permissions);
  38. $inherited_permissions = limited_or_full($inherited_permissions);
  39. if (api_get_setting('permissions') == 'limited') {
  40. $header_array = $rights_limited;
  41. }
  42. if (api_get_setting('permissions') == 'full') {
  43. $header_array = $rights_full;
  44. }
  45. echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
  46. // DISPLAYING THE ROLES LIST
  47. if (api_get_setting('group_roles') == 'true') {
  48. // the list of the roles for the user
  49. echo '<strong>'.get_lang('GroupRoles').'</strong><br />';
  50. $current_group_course_roles = get_roles('group', $group_id);
  51. $current_group_platform_roles = get_roles('group', $group_id, 'platform');
  52. display_role_list($current_group_course_roles, $current_group_platform_roles);
  53. echo '<br />';
  54. }
  55. // DISPLAYING THE MATRIX (group permissions)
  56. echo "<table class=\"data_table\">\n";
  57. // the header
  58. echo "\t<tr>\n";
  59. echo "\t\t<th>".get_lang('Module')."</th>\n";
  60. foreach ($header_array as $header_key => $header_value) {
  61. echo "\t\t<th>".get_lang($header_value)."</th>\n";
  62. }
  63. echo "\t</tr>\n";
  64. // the main area with the checkboxes or images
  65. foreach ($tool_rights as $tool => $rights) { // $tool_rights contains all the possible tools and their rights
  66. echo "\t<tr>\n";
  67. echo "\t\t<td>\n";
  68. echo get_lang($tool);
  69. echo "\t\t</td>\n";
  70. foreach ($header_array as $key => $value) {
  71. echo "\t\t<td align='center'>\n";
  72. if (in_array($value, $rights)) {
  73. if ($setting_visualisation == 'checkbox') {
  74. //display_checkbox_matrix($current_group_permissions, $tool, $value);
  75. display_checkbox_matrix(
  76. $current_group_permissions,
  77. $tool,
  78. $value,
  79. $inherited_permissions,
  80. $course_admin
  81. );
  82. }
  83. if ($setting_visualisation == 'image') {
  84. //display_image_matrix($current_group_permissions, $tool, $value);
  85. display_image_matrix(
  86. $current_group_permissions,
  87. $tool,
  88. $value,
  89. $inherited_permissions,
  90. $course_admin
  91. );
  92. }
  93. }
  94. // note: in a later stage this part will be replaced by a function
  95. // so that we can easily switch between a checkbox approach or an image approach
  96. // where every click is in fact a change of status. In the checkbox approach you first have to
  97. // do the changes and then store them by clicking the submit button.
  98. echo "\t\t</td>\n";
  99. }
  100. echo "\t</tr>\n";
  101. }
  102. echo "</table>\n";
  103. if ($setting_visualisation == 'checkbox') {
  104. echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">";
  105. }
  106. echo "</form>";
  107. // LEGEND
  108. echo '<strong>'.get_lang('Legend').'</strong><br />';
  109. echo '<img src="../img/wrong.gif" /> '.get_lang('UserHasPermissionNot').'<br />';
  110. echo '<img src="../img/checkbox_on2.gif" /> '.get_lang('UserHasPermission').'<br />';
  111. echo '<img src="../img/checkbox_on3.gif" /> '.get_lang('UserHasPermissionByRoleGroup').'<br />';