group_permissions.inc.php 5.3 KB

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