group_permissions.inc.php 5.0 KB

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