group_permissions.inc.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 = array();
  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. {
  67. echo "\t<tr>\n";
  68. echo "\t\t<td>\n";
  69. echo get_lang($tool);
  70. echo "\t\t</td>\n";
  71. foreach ($header_array as $key => $value) {
  72. echo "\t\t<td align='center'>\n";
  73. if (in_array($value, $rights)) {
  74. if ($setting_visualisation == 'checkbox') {
  75. //display_checkbox_matrix($current_group_permissions, $tool, $value);
  76. display_checkbox_matrix(
  77. $current_group_permissions,
  78. $tool,
  79. $value,
  80. $inherited_permissions,
  81. $course_admin
  82. );
  83. }
  84. if ($setting_visualisation == 'image') {
  85. //display_image_matrix($current_group_permissions, $tool, $value);
  86. display_image_matrix(
  87. $current_group_permissions,
  88. $tool,
  89. $value,
  90. $inherited_permissions,
  91. $course_admin
  92. );
  93. }
  94. }
  95. // note: in a later stage this part will be replaced by a function
  96. // so that we can easily switch between a checkbox approach or an image approach
  97. // where every click is in fact a change of status. In the checkbox approach you first have to
  98. // do the changes and then store them by clicking the submit button.
  99. echo "\t\t</td>\n";
  100. }
  101. echo "\t</tr>\n";
  102. }
  103. echo "</table>\n";
  104. if ($setting_visualisation == 'checkbox') {
  105. echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">";
  106. }
  107. echo "</form>";
  108. // LEGEND
  109. echo '<strong>'.get_lang('Legend').'</strong><br />';
  110. echo '<img src="../img/wrong.gif" /> '.get_lang('UserHasPermissionNot').'<br />';
  111. echo '<img src="../img/checkbox_on2.gif" /> '.get_lang('UserHasPermission').'<br />';
  112. echo '<img src="../img/checkbox_on3.gif" /> '.get_lang('UserHasPermissionByRoleGroup').'<br />';