chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @package chamilo.permissions |
||
| 4 | */ |
||
| 5 | $user_id = $userIdViewed; |
||
| 6 | if ($mainUserInfo['status'] == 1) { |
||
| 7 | $course_admin = 1; |
||
| 8 | } |
||
| 9 | include_once 'permissions_functions.inc.php'; |
||
| 10 | include_once 'all_permissions.inc.php'; |
||
| 11 | include_once api_get_library_path()."/groupmanager.lib.php"; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 12 | include_once api_get_library_path()."/blog.lib.php"; |
||
| 13 | // ACTIONS |
||
| 14 | if ($_POST['StoreUserPermissions'] and $setting_visualisation == 'checkbox') { |
||
| 15 | $result_message = store_permissions('user', $user_id); |
||
| 16 | if ($result_message) { |
||
| 17 | echo Display::return_message($result_message); |
||
| 18 | } |
||
| 19 | } |
||
| 20 | if (isset($_GET['action'])) { |
||
| 21 | if (isset($_GET['permission']) and isset($_GET['tool']) and ($_GET['action'] == 'grant' or $_GET['action'] == 'revoke')) { |
||
| 22 | $result_message = store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']); |
||
| 23 | } |
||
| 24 | if (isset($_GET['role']) and ($_GET['action'] == 'grant' or $_GET['action'] == 'revoke')) { |
||
| 25 | $result_message = assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | if (isset($result_message)) { |
||
| 30 | echo Display::return_message($result_message); |
||
| 31 | } |
||
| 32 | |||
| 33 | // --------------------------------------------------- |
||
| 34 | // RETRIEVING THE PERMISSIONS OF THE USER |
||
| 35 | // --------------------------------------------------- |
||
| 36 | $current_user_permissions = []; |
||
| 37 | $current_user_permissions = get_permissions('user', $user_id); |
||
| 38 | |||
| 39 | // INHERITED PERMISSIONS (group permissions, user roles, group roles) |
||
| 40 | |||
| 41 | // RETRIEVING THE PERMISSIONS OF THE GROUPS OF THE USER |
||
| 42 | $groups_of_user = []; |
||
| 43 | $groups_of_user = GroupManager::get_group_ids($_course['real_id'], $user_id); |
||
| 44 | foreach ($groups_of_user as $group) { |
||
| 45 | $this_group_permissions = get_permissions('group', $group); |
||
| 46 | foreach ($this_group_permissions as $tool => $permissions) { |
||
| 47 | foreach ($permissions as $permission) { |
||
| 48 | $inherited_group_permissions[$tool][] = $permission; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 | $inherited_permissions = $inherited_group_permissions; |
||
| 53 | |||
| 54 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
||
| 55 | if (api_get_setting('user_roles') == 'true') { |
||
| 56 | // course roles that are assigned to the user |
||
| 57 | $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id); |
||
| 58 | $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
||
| 59 | // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
||
| 60 | // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
||
| 61 | // groepsge�rfde permissions in beschouwing worden genomen |
||
| 62 | // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
||
| 63 | // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
||
| 64 | // omvatten. |
||
| 65 | // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
||
| 66 | // ophalen. |
||
| 67 | // platform roles that are assigned to the user |
||
| 68 | $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id, 'platform'); |
||
| 69 | $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
||
| 70 | } |
||
| 71 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
||
| 72 | if (api_get_setting('group_roles') == 'true') { |
||
| 73 | // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
||
| 74 | foreach ($groups_of_user as $group) { |
||
| 75 | $this_current_group_role_permissions_of_user = get_roles_permissions('user', $user_id); |
||
| 76 | //$inherited_permissions[$tool][]=$permission; |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | // LIMITED OR FULL |
||
| 81 | $current_user_permissions = limited_or_full($current_user_permissions); |
||
| 82 | $inherited_permissions = limited_or_full($inherited_permissions); |
||
| 83 | if (api_get_setting('permissions') == 'limited') { |
||
| 84 | $header_array = $rights_limited; |
||
| 85 | } |
||
| 86 | if (api_get_setting('permissions') == 'full') { |
||
| 87 | $header_array = $rights_full; |
||
| 88 | } |
||
| 89 | |||
| 90 | echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
||
| 91 | // DISPLAYING THE ROLES LIST |
||
| 92 | |||
| 93 | if (api_get_setting('user_roles') == 'true') { |
||
| 94 | // the list of the roles for the user |
||
| 95 | echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
||
| 96 | $current_user_course_roles = get_roles('user', $user_id); |
||
| 97 | $current_user_platform_roles = get_roles('user', $user_id, 'platform'); |
||
| 98 | display_role_list($current_user_course_roles, $current_user_platform_roles); |
||
| 99 | echo '<br />'; |
||
| 100 | } |
||
| 101 | |||
| 102 | // --------------------------------------------------- |
||
| 103 | // DISPLAYING THE MATRIX (user permissions) |
||
| 104 | // --------------------------------------------------- |
||
| 105 | echo '<strong>'.get_lang('UserPermissions').'</strong>'; |
||
| 106 | echo "<table class=\"table table-hover table-striped data_table\">\n"; |
||
| 107 | |||
| 108 | // the header |
||
| 109 | echo "\t<tr>\n"; |
||
| 110 | echo "\t\t<th>".get_lang('Module')."</th>\n"; |
||
| 111 | foreach ($header_array as $header_key => $header_value) { |
||
| 112 | echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
||
| 113 | } |
||
| 114 | echo "\t</tr>\n"; |
||
| 115 | |||
| 116 | // the main area with the checkboxes or images |
||
| 117 | // $tool_rights contains all the possible tools and their rights |
||
| 118 | foreach ($tool_rights as $tool => $rights) { |
||
| 119 | echo "\t<tr>\n"; |
||
| 120 | echo "\t\t<td>\n"; |
||
| 121 | if (strstr($tool, 'BLOG')) { |
||
| 122 | // Not dealing with a real tool here, get name of this blog |
||
| 123 | // Strip blog id |
||
| 124 | $tmp = strpos($tool, '_') + 1; |
||
| 125 | $blog_id = substr($tool, $tmp, strlen($tool)); |
||
| 126 | // Get title |
||
| 127 | echo get_lang('Blog').": ".Blog::getBlogTitle($blog_id); |
||
| 128 | } else { |
||
| 129 | echo get_lang($tool); |
||
| 130 | } |
||
| 131 | |||
| 132 | echo "\t\t</td>\n"; |
||
| 133 | |||
| 134 | foreach ($header_array as $key => $value) { |
||
| 135 | echo "\t\t<td align='center'>\n"; |
||
| 136 | if (in_array($value, $rights)) { |
||
| 137 | if ($setting_visualisation == 'checkbox') { |
||
| 138 | display_checkbox_matrix( |
||
| 139 | $current_user_permissions, |
||
| 140 | $tool, |
||
| 141 | $value, |
||
| 142 | $inherited_permissions, |
||
| 143 | $course_admin |
||
| 144 | ); |
||
| 145 | } |
||
| 146 | if ($setting_visualisation == 'image') { |
||
| 147 | display_image_matrix( |
||
| 148 | $current_user_permissions, |
||
| 149 | $tool, |
||
| 150 | $value, |
||
| 151 | $inherited_permissions, |
||
| 152 | $course_admin |
||
| 153 | ); |
||
| 154 | } |
||
| 155 | } |
||
| 156 | // note: in a later stage this part will be replaced by a function |
||
| 157 | // so that we can easily switch between a checkbox approach or an image approach |
||
| 158 | // where every click is in fact a change of status. In the checkbox approach you first have to |
||
| 159 | // do the changes and then store them by clicking the submit button. |
||
| 160 | echo "\t\t</td>\n"; |
||
| 161 | } |
||
| 162 | echo "\t</tr>\n"; |
||
| 163 | } |
||
| 164 | |||
| 165 | echo "</table>\n"; |
||
| 166 | if ($setting_visualisation == 'checkbox') { |
||
| 167 | echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
||
| 168 | } |
||
| 169 | echo "</form><br />"; |
||
| 170 | |||
| 171 | // LEGEND |
||
| 172 | echo '<strong>'.get_lang('Legend').'</strong><br />'; |
||
| 173 | echo '<img src="../img/wrong.gif" /> '.get_lang('UserHasPermissionNot').'<br />'; |
||
| 174 | echo '<img src="../img/checkbox_on2.gif" /> '.get_lang('UserHasPermission').'<br />'; |
||
| 175 | echo '<img src="../img/checkbox_on3.gif" /> '.get_lang('UserHasPermissionByRoleGroup').'<br />'; |
||
| 176 |