group_permissions.inc.php 4.9 KB

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