@@ -128,7 +128,7 @@ |
||
128 | 128 | if (isset($friends[$j])) { |
129 | 129 | $friend = $friends[$j]; |
130 | 130 | $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']); |
131 | - $userPicture = UserManager::getUserPicture($friend['friend_user_id']); |
|
131 | + $userPicture = UserManager::getUserPicture($friend['friend_user_id']); |
|
132 | 132 | |
133 | 133 | $friend_html .= ' |
134 | 134 | <div class="col-md-3"> |
@@ -132,15 +132,15 @@ |
||
132 | 132 | |
133 | 133 | $friend_html .= ' |
134 | 134 | <div class="col-md-3"> |
135 | - <div class="thumbnail text-center" id="div_' . $friends[$j]['friend_user_id'] . '"> |
|
136 | - <img src="' . $userPicture . '" class="img-responsive" id="imgfriend_' . $friend['friend_user_id'] . '" title="'.$user_name.'"> |
|
135 | + <div class="thumbnail text-center" id="div_' . $friends[$j]['friend_user_id'].'"> |
|
136 | + <img src="' . $userPicture.'" class="img-responsive" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'"> |
|
137 | 137 | <div class="caption"> |
138 | 138 | <h3> |
139 | - <a href="profile.php?u=' . $friend['friend_user_id'] . '">' . $user_name . '</a> |
|
139 | + <a href="profile.php?u=' . $friend['friend_user_id'].'">'.$user_name.'</a> |
|
140 | 140 | </h3> |
141 | 141 | <p> |
142 | - <button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'] . '> |
|
143 | - ' . get_lang('Delete') . ' |
|
142 | + <button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'].'> |
|
143 | + ' . get_lang('Delete').' |
|
144 | 144 | </button> |
145 | 145 | </p> |
146 | 146 | </div> |
@@ -15,27 +15,27 @@ discard block |
||
15 | 15 | // --------------------------------------------------- |
16 | 16 | if ($_POST['StoreGroupPermissions'] and $setting_visualisation=='checkbox') |
17 | 17 | { |
18 | - $result_message=store_permissions('group', $group_id); |
|
19 | - if ($result_message) |
|
20 | - { |
|
21 | - Display::display_normal_message($result_message); |
|
22 | - } |
|
18 | + $result_message=store_permissions('group', $group_id); |
|
19 | + if ($result_message) |
|
20 | + { |
|
21 | + Display::display_normal_message($result_message); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | if (isset($_GET['action'])) |
25 | 25 | { |
26 | - if (($_GET['action']=='grant' OR $_GET['action']=='revoke') AND isset($_GET['permission']) AND isset($_GET['tool'])) |
|
27 | - { |
|
28 | - $result_message=store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']); |
|
29 | - } |
|
30 | - if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
31 | - { |
|
32 | - $result_message=assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']); |
|
33 | - echo 'hier'; |
|
34 | - } |
|
26 | + if (($_GET['action']=='grant' OR $_GET['action']=='revoke') AND isset($_GET['permission']) AND isset($_GET['tool'])) |
|
27 | + { |
|
28 | + $result_message=store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']); |
|
29 | + } |
|
30 | + if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
31 | + { |
|
32 | + $result_message=assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']); |
|
33 | + echo 'hier'; |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | if (isset($result_message)) |
37 | 37 | { |
38 | - Display::display_normal_message($result_message); |
|
38 | + Display::display_normal_message($result_message); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // --------------------------------------------------- |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $inherited_permissions=limited_or_full($inherited_permissions); |
60 | 60 | if (api_get_setting('permissions')=='limited') |
61 | 61 | { |
62 | - $header_array=$rights_limited; |
|
62 | + $header_array=$rights_limited; |
|
63 | 63 | } |
64 | 64 | if (api_get_setting('permissions')=='full') |
65 | 65 | { |
66 | - $header_array=$rights_full; |
|
66 | + $header_array=$rights_full; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | // --------------------------------------------------- |
73 | 73 | if (api_get_setting('group_roles')=='true') |
74 | 74 | { |
75 | - // the list of the roles for the user |
|
76 | - echo '<strong>'.get_lang('GroupRoles').'</strong><br />'; |
|
77 | - $current_group_course_roles=get_roles('group',$group_id); |
|
78 | - $current_group_platform_roles=get_roles('group',$group_id, 'platform'); |
|
79 | - display_role_list($current_group_course_roles, $current_group_platform_roles); |
|
80 | - echo '<br />'; |
|
75 | + // the list of the roles for the user |
|
76 | + echo '<strong>'.get_lang('GroupRoles').'</strong><br />'; |
|
77 | + $current_group_course_roles=get_roles('group',$group_id); |
|
78 | + $current_group_platform_roles=get_roles('group',$group_id, 'platform'); |
|
79 | + display_role_list($current_group_course_roles, $current_group_platform_roles); |
|
80 | + echo '<br />'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -92,47 +92,47 @@ discard block |
||
92 | 92 | echo "\t\t<th>".get_lang('Module')."</th>\n"; |
93 | 93 | foreach ($header_array as $header_key=>$header_value) |
94 | 94 | { |
95 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
95 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
96 | 96 | } |
97 | 97 | echo "\t</tr>\n"; |
98 | 98 | |
99 | 99 | // the main area with the checkboxes or images |
100 | 100 | foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
101 | 101 | { |
102 | - echo "\t<tr>\n"; |
|
103 | - echo "\t\t<td>\n"; |
|
104 | - echo get_lang($tool); |
|
105 | - echo "\t\t</td>\n"; |
|
102 | + echo "\t<tr>\n"; |
|
103 | + echo "\t\t<td>\n"; |
|
104 | + echo get_lang($tool); |
|
105 | + echo "\t\t</td>\n"; |
|
106 | 106 | |
107 | - foreach ($header_array as $key=>$value) |
|
108 | - { |
|
109 | - echo "\t\t<td align='center'>\n"; |
|
110 | - if (in_array($value,$rights)) |
|
111 | - { |
|
112 | - if ($setting_visualisation=='checkbox') |
|
113 | - { |
|
114 | - //display_checkbox_matrix($current_group_permissions, $tool, $value); |
|
115 | - display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
116 | - } |
|
117 | - if ($setting_visualisation=='image') |
|
118 | - { |
|
119 | - //display_image_matrix($current_group_permissions, $tool, $value); |
|
120 | - display_image_matrix($current_group_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
121 | - } |
|
122 | - } |
|
123 | - // note: in a later stage this part will be replaced by a function |
|
124 | - // so that we can easily switch between a checkbox approach or an image approach |
|
125 | - // where every click is in fact a change of status. In the checkbox approach you first have to |
|
126 | - // do the changes and then store them by clicking the submit button. |
|
127 | - echo "\t\t</td>\n"; |
|
128 | - } |
|
129 | - echo "\t</tr>\n"; |
|
107 | + foreach ($header_array as $key=>$value) |
|
108 | + { |
|
109 | + echo "\t\t<td align='center'>\n"; |
|
110 | + if (in_array($value,$rights)) |
|
111 | + { |
|
112 | + if ($setting_visualisation=='checkbox') |
|
113 | + { |
|
114 | + //display_checkbox_matrix($current_group_permissions, $tool, $value); |
|
115 | + display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
116 | + } |
|
117 | + if ($setting_visualisation=='image') |
|
118 | + { |
|
119 | + //display_image_matrix($current_group_permissions, $tool, $value); |
|
120 | + display_image_matrix($current_group_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
121 | + } |
|
122 | + } |
|
123 | + // note: in a later stage this part will be replaced by a function |
|
124 | + // so that we can easily switch between a checkbox approach or an image approach |
|
125 | + // where every click is in fact a change of status. In the checkbox approach you first have to |
|
126 | + // do the changes and then store them by clicking the submit button. |
|
127 | + echo "\t\t</td>\n"; |
|
128 | + } |
|
129 | + echo "\t</tr>\n"; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | echo "</table>\n"; |
133 | 133 | if ($setting_visualisation=='checkbox') |
134 | 134 | { |
135 | - echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
135 | + echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
136 | 136 | } |
137 | 137 | echo "</form>"; |
138 | 138 |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | // --------------------------------------------------- |
14 | 14 | // ACTIONS |
15 | 15 | // --------------------------------------------------- |
16 | -if ($_POST['StoreGroupPermissions'] and $setting_visualisation=='checkbox') |
|
16 | +if ($_POST['StoreGroupPermissions'] and $setting_visualisation == 'checkbox') |
|
17 | 17 | { |
18 | - $result_message=store_permissions('group', $group_id); |
|
18 | + $result_message = store_permissions('group', $group_id); |
|
19 | 19 | if ($result_message) |
20 | 20 | { |
21 | 21 | Display::display_normal_message($result_message); |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | } |
24 | 24 | if (isset($_GET['action'])) |
25 | 25 | { |
26 | - if (($_GET['action']=='grant' OR $_GET['action']=='revoke') AND isset($_GET['permission']) AND isset($_GET['tool'])) |
|
26 | + if (($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke') AND isset($_GET['permission']) AND isset($_GET['tool'])) |
|
27 | 27 | { |
28 | - $result_message=store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']); |
|
28 | + $result_message = store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']); |
|
29 | 29 | } |
30 | - if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
30 | + if (isset($_GET['role']) AND ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke')) |
|
31 | 31 | { |
32 | - $result_message=assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']); |
|
32 | + $result_message = assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']); |
|
33 | 33 | echo 'hier'; |
34 | 34 | } |
35 | 35 | } |
@@ -41,41 +41,41 @@ discard block |
||
41 | 41 | // --------------------------------------------------- |
42 | 42 | // RETRIEVING THE PERMISSIONS |
43 | 43 | // --------------------------------------------------- |
44 | -$current_group_permissions=array(); |
|
45 | -$current_group_permissions=get_permissions('group',$group_id); |
|
44 | +$current_group_permissions = array(); |
|
45 | +$current_group_permissions = get_permissions('group', $group_id); |
|
46 | 46 | // @todo current group permissions and current role permissions |
47 | 47 | |
48 | 48 | // --------------------------------------------------- |
49 | 49 | // INHERITED PERMISSIONS (group roles) |
50 | 50 | // --------------------------------------------------- |
51 | -$group_course_roles_permissions=get_roles_permissions('group',$group_id, 'course'); |
|
52 | -$group_platform_roles_permissions=get_roles_permissions('group',$group_id, 'platform'); |
|
53 | -$inherited_permissions=permission_array_merge($group_course_roles_permissions,$group_platform_roles_permissions); |
|
51 | +$group_course_roles_permissions = get_roles_permissions('group', $group_id, 'course'); |
|
52 | +$group_platform_roles_permissions = get_roles_permissions('group', $group_id, 'platform'); |
|
53 | +$inherited_permissions = permission_array_merge($group_course_roles_permissions, $group_platform_roles_permissions); |
|
54 | 54 | |
55 | 55 | // --------------------------------------------------- |
56 | 56 | // LIMITED OR FULL |
57 | 57 | // --------------------------------------------------- |
58 | -$current_group_permissions=limited_or_full($current_group_permissions); |
|
59 | -$inherited_permissions=limited_or_full($inherited_permissions); |
|
60 | -if (api_get_setting('permissions')=='limited') |
|
58 | +$current_group_permissions = limited_or_full($current_group_permissions); |
|
59 | +$inherited_permissions = limited_or_full($inherited_permissions); |
|
60 | +if (api_get_setting('permissions') == 'limited') |
|
61 | 61 | { |
62 | - $header_array=$rights_limited; |
|
62 | + $header_array = $rights_limited; |
|
63 | 63 | } |
64 | -if (api_get_setting('permissions')=='full') |
|
64 | +if (api_get_setting('permissions') == 'full') |
|
65 | 65 | { |
66 | - $header_array=$rights_full; |
|
66 | + $header_array = $rights_full; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
70 | 70 | // --------------------------------------------------- |
71 | 71 | // DISPLAYING THE ROLES LIST |
72 | 72 | // --------------------------------------------------- |
73 | -if (api_get_setting('group_roles')=='true') |
|
73 | +if (api_get_setting('group_roles') == 'true') |
|
74 | 74 | { |
75 | 75 | // the list of the roles for the user |
76 | 76 | echo '<strong>'.get_lang('GroupRoles').'</strong><br />'; |
77 | - $current_group_course_roles=get_roles('group',$group_id); |
|
78 | - $current_group_platform_roles=get_roles('group',$group_id, 'platform'); |
|
77 | + $current_group_course_roles = get_roles('group', $group_id); |
|
78 | + $current_group_platform_roles = get_roles('group', $group_id, 'platform'); |
|
79 | 79 | display_role_list($current_group_course_roles, $current_group_platform_roles); |
80 | 80 | echo '<br />'; |
81 | 81 | } |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | foreach ($header_array as $key=>$value) |
108 | 108 | { |
109 | 109 | echo "\t\t<td align='center'>\n"; |
110 | - if (in_array($value,$rights)) |
|
110 | + if (in_array($value, $rights)) |
|
111 | 111 | { |
112 | - if ($setting_visualisation=='checkbox') |
|
112 | + if ($setting_visualisation == 'checkbox') |
|
113 | 113 | { |
114 | 114 | //display_checkbox_matrix($current_group_permissions, $tool, $value); |
115 | - display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
115 | + display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions, $course_admin); |
|
116 | 116 | } |
117 | - if ($setting_visualisation=='image') |
|
117 | + if ($setting_visualisation == 'image') |
|
118 | 118 | { |
119 | 119 | //display_image_matrix($current_group_permissions, $tool, $value); |
120 | - display_image_matrix($current_group_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
120 | + display_image_matrix($current_group_permissions, $tool, $value, $inherited_permissions, $course_admin); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | // note: in a later stage this part will be replaced by a function |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | echo "</table>\n"; |
133 | -if ($setting_visualisation=='checkbox') |
|
133 | +if ($setting_visualisation == 'checkbox') |
|
134 | 134 | { |
135 | 135 | echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
136 | 136 | } |
@@ -97,9 +97,11 @@ |
||
97 | 97 | echo "\t</tr>\n"; |
98 | 98 | |
99 | 99 | // the main area with the checkboxes or images |
100 | -foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
100 | +foreach ($tool_rights as $tool=>$rights) { |
|
101 | + // $tool_rights contains all the possible tools and their rights |
|
101 | 102 | { |
102 | 103 | echo "\t<tr>\n"; |
104 | +} |
|
103 | 105 | echo "\t\t<td>\n"; |
104 | 106 | echo get_lang($tool); |
105 | 107 | echo "\t\t</td>\n"; |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | * Code |
11 | 11 | */ |
12 | 12 | // possible permissions |
13 | -$rights_full=array("View","Add","Edit","Delete","Visibility","Move"); |
|
14 | -$rights_limited=array("Add","Edit","Delete"); |
|
13 | +$rights_full = array("View", "Add", "Edit", "Delete", "Visibility", "Move"); |
|
14 | +$rights_limited = array("Add", "Edit", "Delete"); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | // first we determine what can be done in each tool. We do this for each tool. |
18 | -$tool_rights[TOOL_LINK]=array("View","Add","Edit","Delete","Visibility", "Move"); |
|
19 | -$tool_rights[TOOL_DOCUMENT]=array("View","Add","Edit","Delete","Visibility","Move"); |
|
18 | +$tool_rights[TOOL_LINK] = array("View", "Add", "Edit", "Delete", "Visibility", "Move"); |
|
19 | +$tool_rights[TOOL_DOCUMENT] = array("View", "Add", "Edit", "Delete", "Visibility", "Move"); |
|
20 | 20 | //$tool_rights[TOOL_CALENDAR_EVENT]=array("View","Add","Edit","Delete","Visibility"); |
21 | -$tool_rights[TOOL_ANNOUNCEMENT]=array("View","Add","Edit","Delete","Visibility", "Move"); |
|
21 | +$tool_rights[TOOL_ANNOUNCEMENT] = array("View", "Add", "Edit", "Delete", "Visibility", "Move"); |
|
22 | 22 | //$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Edit","Delete","Visibility"); |
23 | 23 | //$tool_rights[TOOL_COURSE_DESCRIPTION]=array("View","Add","Edit","Delete","Visibility"); |
24 | 24 | //$tool_rights[TOOL_LEARNPATH]=array("View","Add","Edit","Delete","Visibility"); |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | //$tool_rights[TOOL_BB_POST]=array("View","Add","Edit","Delete"); |
27 | 27 | //$tool_rights[TOOL_DROPBOX]=array("View","Add","Delete"); |
28 | 28 | //$tool_rights[TOOL_QUIZ]=array("View","Add","Edit","Delete","Visibility"); |
29 | -$tool_rights[TOOL_USER]=array("View","Add","Edit","Delete"); |
|
29 | +$tool_rights[TOOL_USER] = array("View", "Add", "Edit", "Delete"); |
|
30 | 30 | //$tool_rights[TOOL_GROUP]=array("View","Add","Edit","Delete"); |
31 | 31 | //$tool_rights[TOOL_CHAT]=array("View","Delete"); |
32 | 32 | //$tool_rights[TOOL_CONFERENCE]=array("View","Add","Edit","Delete"); |
33 | 33 | //$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Add","Edit","Delete"); |
34 | 34 | |
35 | 35 | // this value can be checkbox or image |
36 | -$setting_visualisation='image'; |
|
36 | +$setting_visualisation = 'image'; |
|
37 | 37 | |
38 | 38 | ?> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | WHERE status = '1' AND c_id = '".api_get_course_int_id()."'"; |
50 | 50 | $result = Database::query($sql); |
51 | 51 | while ($user = Database::fetch_assoc($result)) { |
52 | - unset($blog_users[$user['user_id']]); |
|
52 | + unset($blog_users[$user['user_id']]); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //$user_id=$userIdViewed; |
@@ -84,30 +84,30 @@ discard block |
||
84 | 84 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
85 | 85 | // ------------------------------------------------------------------ |
86 | 86 | if (api_get_setting('user_roles')=='true') { |
87 | - // course roles that are assigned to the user |
|
88 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
89 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
90 | - // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
91 | - // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
92 | - // groepsge�rfde permissions in beschouwing worden genomen |
|
93 | - // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
94 | - // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
95 | - // omvatten. |
|
96 | - // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
97 | - // ophalen. |
|
98 | - // platform roles that are assigned to the user |
|
99 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
100 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
87 | + // course roles that are assigned to the user |
|
88 | + $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
89 | + $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
90 | + // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
91 | + // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
92 | + // groepsge�rfde permissions in beschouwing worden genomen |
|
93 | + // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
94 | + // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
95 | + // omvatten. |
|
96 | + // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
97 | + // ophalen. |
|
98 | + // platform roles that are assigned to the user |
|
99 | + $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
100 | + $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
101 | 101 | } |
102 | 102 | // ------------------------------------------------------------------ |
103 | 103 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
104 | 104 | // ------------------------------------------------------------------ |
105 | 105 | if (api_get_setting('group_roles')=='true') { |
106 | - // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
107 | - foreach ($groups_of_user as $group) { |
|
108 | - $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
109 | - //$inherited_permissions[$tool][]=$permission; |
|
110 | - } |
|
106 | + // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
107 | + foreach ($groups_of_user as $group) { |
|
108 | + $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
109 | + //$inherited_permissions[$tool][]=$permission; |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | |
119 | 119 | if (api_get_setting('user_roles')=='true') |
120 | 120 | { |
121 | - // the list of the roles for the user |
|
122 | - echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
|
123 | - $current_user_course_roles=get_roles('user',$user_id); |
|
124 | - $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
125 | - display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
126 | - echo '<br />'; |
|
121 | + // the list of the roles for the user |
|
122 | + echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
|
123 | + $current_user_course_roles=get_roles('user',$user_id); |
|
124 | + $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
125 | + display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
126 | + echo '<br />'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // --------------------------------------------------- |
@@ -133,59 +133,59 @@ discard block |
||
133 | 133 | |
134 | 134 | // the header |
135 | 135 | echo "\t<tr>\n"; |
136 | - echo "\t\t<th rowspan=\"2\">".get_lang('Module')."</th>\n"; |
|
137 | - echo "\t\t<th colspan=\"4\">".get_lang('ArticleManager')."</th>\n"; |
|
138 | - echo "\t\t<th colspan=\"3\">".get_lang('CommentManager')."</th>\n"; |
|
139 | - echo "\t\t<th colspan=\"3\">".get_lang('BlogManager')."</th>\n"; |
|
136 | + echo "\t\t<th rowspan=\"2\">".get_lang('Module')."</th>\n"; |
|
137 | + echo "\t\t<th colspan=\"4\">".get_lang('ArticleManager')."</th>\n"; |
|
138 | + echo "\t\t<th colspan=\"3\">".get_lang('CommentManager')."</th>\n"; |
|
139 | + echo "\t\t<th colspan=\"3\">".get_lang('BlogManager')."</th>\n"; |
|
140 | 140 | echo "\t</tr>\n"; |
141 | 141 | |
142 | 142 | // Subheader |
143 | 143 | echo "\t<tr>\n"; |
144 | - echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
145 | - echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
146 | - echo "\t\t<th align='center'>".get_lang('Edit')."</th>\n"; |
|
147 | - echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
148 | - echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
149 | - echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
150 | - echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
151 | - echo "\t\t<th align='center'>".get_lang('Tasks')."</th>\n"; |
|
152 | - echo "\t\t<th align='center'>".get_lang('Members')."</th>\n"; |
|
153 | - echo "\t\t<th align='center'>".get_lang('Roles')."</th>\n"; |
|
144 | + echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
145 | + echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
146 | + echo "\t\t<th align='center'>".get_lang('Edit')."</th>\n"; |
|
147 | + echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
148 | + echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
149 | + echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
150 | + echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
151 | + echo "\t\t<th align='center'>".get_lang('Tasks')."</th>\n"; |
|
152 | + echo "\t\t<th align='center'>".get_lang('Members')."</th>\n"; |
|
153 | + echo "\t\t<th align='center'>".get_lang('Roles')."</th>\n"; |
|
154 | 154 | echo "\t</tr>\n"; |
155 | 155 | |
156 | 156 | // the main area with the checkboxes or images |
157 | 157 | foreach ($blog_users as $user_id => $user_name) { // $blog_users contains all the users in this blog |
158 | - // --------------------------------------------------- |
|
159 | - // RETRIEVING THE PERMISSIONS OF THE USER |
|
160 | - // --------------------------------------------------- |
|
161 | - $current_user_permissions = array(); |
|
162 | - $current_user_permissions = get_permissions('user', $user_id); |
|
163 | - |
|
164 | - echo "\t<tr>\n"; |
|
165 | - echo "\t\t<td>\n"; |
|
166 | - echo $user_name; |
|
167 | - echo "\t\t</td>\n"; |
|
168 | - |
|
169 | - foreach ($rights_full as $key => $value) { |
|
170 | - |
|
171 | - echo "\t\t<td align='center'>\n"; |
|
172 | - if (in_array($value,$rights_blog)) { |
|
173 | - display_image_matrix_for_blogs( |
|
174 | - $current_user_permissions, |
|
175 | - $user_id, |
|
176 | - 'BLOG_'.$blog_id, |
|
177 | - $value, |
|
178 | - (isset($inherited_permissions) ? $inherited_permissions : null), |
|
179 | - (isset($course_admin) ? $course_admin : null) |
|
180 | - ); |
|
181 | - } |
|
182 | - // note: in a later stage this part will be replaced by a function |
|
183 | - // so that we can easily switch between a checkbox approach or an image approach |
|
184 | - // where every click is in fact a change of status. In the checkbox approach you first have to |
|
185 | - // do the changes and then store them by clicking the submit button. |
|
186 | - echo "\t\t</td>\n"; |
|
187 | - } |
|
188 | - echo "\t</tr>\n"; |
|
158 | + // --------------------------------------------------- |
|
159 | + // RETRIEVING THE PERMISSIONS OF THE USER |
|
160 | + // --------------------------------------------------- |
|
161 | + $current_user_permissions = array(); |
|
162 | + $current_user_permissions = get_permissions('user', $user_id); |
|
163 | + |
|
164 | + echo "\t<tr>\n"; |
|
165 | + echo "\t\t<td>\n"; |
|
166 | + echo $user_name; |
|
167 | + echo "\t\t</td>\n"; |
|
168 | + |
|
169 | + foreach ($rights_full as $key => $value) { |
|
170 | + |
|
171 | + echo "\t\t<td align='center'>\n"; |
|
172 | + if (in_array($value,$rights_blog)) { |
|
173 | + display_image_matrix_for_blogs( |
|
174 | + $current_user_permissions, |
|
175 | + $user_id, |
|
176 | + 'BLOG_'.$blog_id, |
|
177 | + $value, |
|
178 | + (isset($inherited_permissions) ? $inherited_permissions : null), |
|
179 | + (isset($course_admin) ? $course_admin : null) |
|
180 | + ); |
|
181 | + } |
|
182 | + // note: in a later stage this part will be replaced by a function |
|
183 | + // so that we can easily switch between a checkbox approach or an image approach |
|
184 | + // where every click is in fact a change of status. In the checkbox approach you first have to |
|
185 | + // do the changes and then store them by clicking the submit button. |
|
186 | + echo "\t\t</td>\n"; |
|
187 | + } |
|
188 | + echo "\t</tr>\n"; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | echo "</table>\n"; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | // Remove the blog creater because he has all the rights automatically |
45 | 45 | // and we want to keep it that way. |
46 | -$tbl_course_rel_user = $table=Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
46 | +$tbl_course_rel_user = $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
47 | 47 | $sql = "SELECT user_id |
48 | 48 | FROM $tbl_course_rel_user |
49 | 49 | WHERE status = '1' AND c_id = '".api_get_course_int_id()."'"; |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | // ------------------------------------------------------------------ |
84 | 84 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
85 | 85 | // ------------------------------------------------------------------ |
86 | -if (api_get_setting('user_roles')=='true') { |
|
86 | +if (api_get_setting('user_roles') == 'true') { |
|
87 | 87 | // course roles that are assigned to the user |
88 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
89 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
88 | + $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
89 | + $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
90 | 90 | // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
91 | 91 | // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
92 | 92 | // groepsge�rfde permissions in beschouwing worden genomen |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
97 | 97 | // ophalen. |
98 | 98 | // platform roles that are assigned to the user |
99 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
100 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
99 | + $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id, 'platform'); |
|
100 | + $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
101 | 101 | } |
102 | 102 | // ------------------------------------------------------------------ |
103 | 103 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
104 | 104 | // ------------------------------------------------------------------ |
105 | -if (api_get_setting('group_roles')=='true') { |
|
105 | +if (api_get_setting('group_roles') == 'true') { |
|
106 | 106 | // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
107 | 107 | foreach ($groups_of_user as $group) { |
108 | - $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
108 | + $this_current_group_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
109 | 109 | //$inherited_permissions[$tool][]=$permission; |
110 | 110 | } |
111 | 111 | } |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | // DISPLAYING THE ROLES LIST |
117 | 117 | // --------------------------------------------------- |
118 | 118 | |
119 | -if (api_get_setting('user_roles')=='true') |
|
119 | +if (api_get_setting('user_roles') == 'true') |
|
120 | 120 | { |
121 | 121 | // the list of the roles for the user |
122 | 122 | echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
123 | - $current_user_course_roles=get_roles('user',$user_id); |
|
124 | - $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
123 | + $current_user_course_roles = get_roles('user', $user_id); |
|
124 | + $current_user_platform_roles = get_roles('user', $user_id, 'platform'); |
|
125 | 125 | display_role_list($current_user_course_roles, $current_user_platform_roles); |
126 | 126 | echo '<br />'; |
127 | 127 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | foreach ($rights_full as $key => $value) { |
170 | 170 | |
171 | 171 | echo "\t\t<td align='center'>\n"; |
172 | - if (in_array($value,$rights_blog)) { |
|
172 | + if (in_array($value, $rights_blog)) { |
|
173 | 173 | display_image_matrix_for_blogs( |
174 | 174 | $current_user_permissions, |
175 | 175 | $user_id, |
@@ -132,24 +132,20 @@ discard block |
||
132 | 132 | { |
133 | 133 | $table=Database::get_course_table(TABLE_PERMISSION_USER); |
134 | 134 | $id_field = 'user_id'; |
135 | - } |
|
136 | - elseif ($content == 'group') |
|
135 | + } elseif ($content == 'group') |
|
137 | 136 | { |
138 | 137 | $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
139 | 138 | $id_field = 'group_id'; |
140 | - } |
|
141 | - elseif ($content == 'role') |
|
139 | + } elseif ($content == 'role') |
|
142 | 140 | { |
143 | 141 | $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
144 | 142 | $id_field = 'role_id'; |
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
143 | + } elseif ($content == 'platform_role') |
|
147 | 144 | { |
148 | 145 | $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
149 | 146 | $id_field = 'role_id'; |
150 | 147 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
148 | + } elseif ($content == 'task') |
|
153 | 149 | { |
154 | 150 | $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
155 | 151 | $id_field = 'task_id'; |
@@ -162,8 +158,9 @@ discard block |
||
162 | 158 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | 159 | $result = Database::query($sql); |
164 | 160 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
161 | + while($row = Database::fetch_array($result)) { |
|
162 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
163 | + } |
|
167 | 164 | |
168 | 165 | return $currentpermissions; |
169 | 166 | } |
@@ -321,14 +318,12 @@ discard block |
||
321 | 318 | if ($course_admin) |
322 | 319 | { |
323 | 320 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
324 | - } |
|
325 | - else |
|
321 | + } else |
|
326 | 322 | { |
327 | 323 | if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
328 | 324 | { |
329 | 325 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | - } |
|
331 | - else |
|
326 | + } else |
|
332 | 327 | { |
333 | 328 | if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
334 | 329 | { |
@@ -439,8 +434,7 @@ discard block |
||
439 | 434 | $checked='checked'; |
440 | 435 | $image='checkbox_on2.gif'; |
441 | 436 | $action='revoke'; |
442 | - } |
|
443 | - else |
|
437 | + } else |
|
444 | 438 | { |
445 | 439 | $checked=''; |
446 | 440 | $image='wrong.gif'; |
@@ -25,38 +25,38 @@ discard block |
||
25 | 25 | function store_permissions($content, $id) { |
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | - // Which database are we using (depending on the $content parameter) |
|
29 | - if ($content=='user') |
|
30 | - { |
|
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | - $id_field = user_id; |
|
33 | - } |
|
34 | - if ($content=='group') |
|
35 | - { |
|
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | - $id_field = group_id; |
|
38 | - } |
|
39 | - if ($content=='role') |
|
40 | - { |
|
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | - $id_field = role_id; |
|
43 | - } |
|
44 | - |
|
45 | - // We first delete all the existing permissions for that user/group/role |
|
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
48 | - |
|
49 | - // looping through the post values to find the permission (containing the string permission* ) |
|
50 | - foreach ($_POST as $key => $value) |
|
51 | - { |
|
52 | - if (strstr($key,"permission*")) |
|
53 | - { |
|
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
57 | - } |
|
58 | - } |
|
59 | - return get_lang('PermissionsStored'); |
|
28 | + // Which database are we using (depending on the $content parameter) |
|
29 | + if ($content=='user') |
|
30 | + { |
|
31 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | + $id_field = user_id; |
|
33 | + } |
|
34 | + if ($content=='group') |
|
35 | + { |
|
36 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | + $id_field = group_id; |
|
38 | + } |
|
39 | + if ($content=='role') |
|
40 | + { |
|
41 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | + $id_field = role_id; |
|
43 | + } |
|
44 | + |
|
45 | + // We first delete all the existing permissions for that user/group/role |
|
46 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result=Database::query($sql); |
|
48 | + |
|
49 | + // looping through the post values to find the permission (containing the string permission* ) |
|
50 | + foreach ($_POST as $key => $value) |
|
51 | + { |
|
52 | + if (strstr($key,"permission*")) |
|
53 | + { |
|
54 | + list($brol,$tool,$action)=explode("*",$key); |
|
55 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result=Database::query($sql); |
|
57 | + } |
|
58 | + } |
|
59 | + return get_lang('PermissionsStored'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -70,50 +70,50 @@ discard block |
||
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | 72 | function store_one_permission($content, $action, $id, $tool,$permission) { |
73 | - global $rights_full; |
|
73 | + global $rights_full; |
|
74 | 74 | $course_id = api_get_course_int_id(); |
75 | - // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
75 | + // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
|
76 | 76 | |
77 | - // check |
|
78 | - //if(!in_array($permission, $rights_full)) |
|
79 | - //{ |
|
80 | - // return get_lang('Error'); |
|
81 | - //} |
|
77 | + // check |
|
78 | + //if(!in_array($permission, $rights_full)) |
|
79 | + //{ |
|
80 | + // return get_lang('Error'); |
|
81 | + //} |
|
82 | 82 | |
83 | - // Which database are we using (depending on the $content parameter) |
|
83 | + // Which database are we using (depending on the $content parameter) |
|
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | - $id_field = user_id; |
|
88 | - } |
|
89 | - if ($content=='group') |
|
90 | - { |
|
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | - $id_field = group_id; |
|
93 | - } |
|
94 | - if ($content=='role') |
|
95 | - { |
|
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | - $id_field = role_id; |
|
98 | - } |
|
99 | - |
|
100 | - // grating a right |
|
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
106 | - } |
|
107 | - } |
|
108 | - if ($action=='revoke') |
|
109 | - { |
|
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
114 | - } |
|
115 | - } |
|
116 | - return $result_message; |
|
85 | + if ($content=='user') { |
|
86 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | + $id_field = user_id; |
|
88 | + } |
|
89 | + if ($content=='group') |
|
90 | + { |
|
91 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | + $id_field = group_id; |
|
93 | + } |
|
94 | + if ($content=='role') |
|
95 | + { |
|
96 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | + $id_field = role_id; |
|
98 | + } |
|
99 | + |
|
100 | + // grating a right |
|
101 | + if ($action=='grant') { |
|
102 | + $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result=Database::query($sql); |
|
104 | + if($result) { |
|
105 | + $result_message=get_lang('PermissionGranted'); |
|
106 | + } |
|
107 | + } |
|
108 | + if ($action=='revoke') |
|
109 | + { |
|
110 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result=Database::query($sql); |
|
112 | + if($result) { |
|
113 | + $result_message=get_lang('PermissionRevoked'); |
|
114 | + } |
|
115 | + } |
|
116 | + return $result_message; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,47 +125,47 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
129 | - // Which database are we using (depending on the $content parameter) |
|
128 | + $currentpermissions=array(); |
|
129 | + // Which database are we using (depending on the $content parameter) |
|
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | - if ($content == 'user') |
|
132 | - { |
|
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | - $id_field = 'user_id'; |
|
135 | - } |
|
136 | - elseif ($content == 'group') |
|
137 | - { |
|
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | - $id_field = 'group_id'; |
|
140 | - } |
|
141 | - elseif ($content == 'role') |
|
142 | - { |
|
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | - $id_field = 'role_id'; |
|
145 | - } |
|
146 | - elseif ($content == 'platform_role') |
|
147 | - { |
|
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | - $id_field = 'role_id'; |
|
131 | + if ($content == 'user') |
|
132 | + { |
|
133 | + $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | + $id_field = 'user_id'; |
|
135 | + } |
|
136 | + elseif ($content == 'group') |
|
137 | + { |
|
138 | + $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | + $id_field = 'group_id'; |
|
140 | + } |
|
141 | + elseif ($content == 'role') |
|
142 | + { |
|
143 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | + $id_field = 'role_id'; |
|
145 | + } |
|
146 | + elseif ($content == 'platform_role') |
|
147 | + { |
|
148 | + $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | + $id_field = 'role_id'; |
|
150 | 150 | $course_id_condition = ''; |
151 | - } |
|
152 | - elseif ($content == 'task') |
|
153 | - { |
|
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | - $id_field = 'task_id'; |
|
156 | - } |
|
157 | - |
|
158 | - // finding all the permissions. We store this in a multidimensional array |
|
159 | - // where the first dimension is the tool. |
|
160 | - $sql=" |
|
151 | + } |
|
152 | + elseif ($content == 'task') |
|
153 | + { |
|
154 | + $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | + $id_field = 'task_id'; |
|
156 | + } |
|
157 | + |
|
158 | + // finding all the permissions. We store this in a multidimensional array |
|
159 | + // where the first dimension is the tool. |
|
160 | + $sql=" |
|
161 | 161 | SELECT * FROM " . $table . " |
162 | 162 | WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
163 | - $result = Database::query($sql); |
|
163 | + $result = Database::query($sql); |
|
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
166 | - $currentpermissions[$row['tool']][] = $row['action']; |
|
165 | + while($row = Database::fetch_array($result)) |
|
166 | + $currentpermissions[$row['tool']][] = $row['action']; |
|
167 | 167 | |
168 | - return $currentpermissions; |
|
168 | + return $currentpermissions; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -179,38 +179,38 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
183 | - { |
|
184 | - foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | - { |
|
186 | - // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | - // if it is visibility or move we have to grant the edit right |
|
188 | - foreach ($tool_rights as $key=>$value) |
|
189 | - { |
|
190 | - if ($value=='View') |
|
191 | - { |
|
192 | - unset($current_permissions[$tool][$key]); |
|
193 | - } |
|
194 | - if ($value=='Visibility' OR $value=='Move') |
|
195 | - { |
|
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | - { |
|
198 | - $current_permissions[$tool][]='Edit'; |
|
199 | - } |
|
200 | - unset($current_permissions[$tool][$key]); |
|
201 | - } |
|
202 | - //else |
|
203 | - //{ |
|
204 | - // $current_permissions[$tool][]=$value; |
|
205 | - //} |
|
206 | - } |
|
207 | - } |
|
208 | - return $current_permissions; |
|
209 | - } |
|
210 | - if (api_get_setting('permissions')=='full') |
|
211 | - { |
|
212 | - return $current_permissions; |
|
213 | - } |
|
182 | + if (api_get_setting('permissions')=='limited') |
|
183 | + { |
|
184 | + foreach ($current_permissions as $tool=>$tool_rights) |
|
185 | + { |
|
186 | + // we loop through the possible permissions of a tool and unset the entry if it is view |
|
187 | + // if it is visibility or move we have to grant the edit right |
|
188 | + foreach ($tool_rights as $key=>$value) |
|
189 | + { |
|
190 | + if ($value=='View') |
|
191 | + { |
|
192 | + unset($current_permissions[$tool][$key]); |
|
193 | + } |
|
194 | + if ($value=='Visibility' OR $value=='Move') |
|
195 | + { |
|
196 | + if (!in_array('Edit',$current_permissions[$tool])) |
|
197 | + { |
|
198 | + $current_permissions[$tool][]='Edit'; |
|
199 | + } |
|
200 | + unset($current_permissions[$tool][$key]); |
|
201 | + } |
|
202 | + //else |
|
203 | + //{ |
|
204 | + // $current_permissions[$tool][]=$value; |
|
205 | + //} |
|
206 | + } |
|
207 | + } |
|
208 | + return $current_permissions; |
|
209 | + } |
|
210 | + if (api_get_setting('permissions')=='full') |
|
211 | + { |
|
212 | + return $current_permissions; |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | /** |
216 | 216 | * This function displays a checked or unchecked checkbox. The checkbox will be checked if the |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | */ |
225 | 225 | function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | - { |
|
230 | - $checked="checked"; |
|
231 | - } |
|
232 | - echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
227 | + $checked=""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
229 | + { |
|
230 | + $checked="checked"; |
|
231 | + } |
|
232 | + echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | |
@@ -245,62 +245,62 @@ discard block |
||
245 | 245 | */ |
246 | 246 | function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
247 | 247 | { |
248 | - if ($course_admin) { |
|
249 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | - } else { |
|
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | - } else { |
|
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | - if ($editable) { |
|
256 | - $url=api_get_self(); |
|
257 | - $urlparameters = ''; |
|
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
260 | - } |
|
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
264 | - foreach ($parameter as $key=>$value) { |
|
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
266 | - } |
|
267 | - $url=$url.'?'.$urlparameters; |
|
268 | - |
|
269 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | - } |
|
271 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | - if ($editable) { |
|
273 | - echo "</a>"; |
|
274 | - } |
|
275 | - } else { |
|
276 | - if ($editable) |
|
277 | - { |
|
278 | - $url=api_get_self(); |
|
279 | - $urlparameters = ''; |
|
280 | - foreach ($_GET as $key=>$value) |
|
281 | - { |
|
282 | - $parameter[$key]=$value; |
|
283 | - } |
|
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
287 | - foreach ($parameter as $key=>$value) |
|
288 | - { |
|
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
290 | - } |
|
291 | - $url=$url.'?'.$urlparameters; |
|
292 | - |
|
293 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | - } |
|
296 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | - if ($editable) |
|
298 | - { |
|
299 | - echo "</a>"; |
|
300 | - } |
|
301 | - } |
|
302 | - } |
|
303 | - } |
|
248 | + if ($course_admin) { |
|
249 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
250 | + } else { |
|
251 | + if (in_array($permission,$inherited_permissions[$tool])) { |
|
252 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
253 | + } else { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
255 | + if ($editable) { |
|
256 | + $url=api_get_self(); |
|
257 | + $urlparameters = ''; |
|
258 | + foreach($_GET as $key=>$value) { |
|
259 | + $parameter[$key]=$value; |
|
260 | + } |
|
261 | + $parameter['action']='revoke'; |
|
262 | + $parameter['permission']=$permission; |
|
263 | + $parameter['tool']=$tool; |
|
264 | + foreach ($parameter as $key=>$value) { |
|
265 | + $urlparameters.=$key.'='.$value.'&'; |
|
266 | + } |
|
267 | + $url=$url.'?'.$urlparameters; |
|
268 | + |
|
269 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
270 | + } |
|
271 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>"; |
|
272 | + if ($editable) { |
|
273 | + echo "</a>"; |
|
274 | + } |
|
275 | + } else { |
|
276 | + if ($editable) |
|
277 | + { |
|
278 | + $url=api_get_self(); |
|
279 | + $urlparameters = ''; |
|
280 | + foreach ($_GET as $key=>$value) |
|
281 | + { |
|
282 | + $parameter[$key]=$value; |
|
283 | + } |
|
284 | + $parameter['action']='grant'; |
|
285 | + $parameter['permission']=$permission; |
|
286 | + $parameter['tool']=$tool; |
|
287 | + foreach ($parameter as $key=>$value) |
|
288 | + { |
|
289 | + $urlparameters.=$key.'='.$value.'&'; |
|
290 | + } |
|
291 | + $url=$url.'?'.$urlparameters; |
|
292 | + |
|
293 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
294 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
295 | + } |
|
296 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/>"; |
|
297 | + if ($editable) |
|
298 | + { |
|
299 | + echo "</a>"; |
|
300 | + } |
|
301 | + } |
|
302 | + } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -318,72 +318,72 @@ discard block |
||
318 | 318 | function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
319 | 319 | { |
320 | 320 | |
321 | - if ($course_admin) |
|
322 | - { |
|
323 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | - } |
|
325 | - else |
|
326 | - { |
|
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | - { |
|
329 | - echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | - { |
|
335 | - if ($editable) |
|
336 | - { |
|
337 | - $url = api_get_self(); |
|
338 | - $urlparameters = ''; |
|
339 | - foreach($_GET as $key => $value) |
|
340 | - { |
|
341 | - $parameter[$key] = $value; |
|
342 | - } |
|
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
348 | - foreach ($parameter as $key=>$value) |
|
349 | - { |
|
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
351 | - } |
|
352 | - $url = $url . '?' . $urlparameters; |
|
353 | - |
|
354 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | - } |
|
356 | - echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | - if ($editable) { |
|
358 | - echo "</a>"; |
|
359 | - } |
|
360 | - } else { |
|
361 | - if ($editable) { |
|
362 | - $url = api_get_self(); |
|
363 | - $urlparameters = ''; |
|
364 | - foreach ($_GET as $key=>$value) { |
|
365 | - $parameter[$key]=$value; |
|
366 | - } |
|
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
372 | - foreach ($parameter as $key=>$value) { |
|
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
374 | - } |
|
375 | - $url=$url.'?'.$urlparameters; |
|
376 | - |
|
377 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | - echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | - } |
|
380 | - echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | - if ($editable) { |
|
382 | - echo "</a>"; |
|
383 | - } |
|
384 | - } |
|
385 | - } |
|
386 | - } |
|
321 | + if ($course_admin) |
|
322 | + { |
|
323 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
324 | + } |
|
325 | + else |
|
326 | + { |
|
327 | + if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
328 | + { |
|
329 | + echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
334 | + { |
|
335 | + if ($editable) |
|
336 | + { |
|
337 | + $url = api_get_self(); |
|
338 | + $urlparameters = ''; |
|
339 | + foreach($_GET as $key => $value) |
|
340 | + { |
|
341 | + $parameter[$key] = $value; |
|
342 | + } |
|
343 | + $parameter['action']='manage_rights'; |
|
344 | + $parameter['do']='revoke'; |
|
345 | + $parameter['permission']=$permission; |
|
346 | + $parameter['tool']=$tool; |
|
347 | + $parameter['user_id']=$user_id; |
|
348 | + foreach ($parameter as $key=>$value) |
|
349 | + { |
|
350 | + $urlparameters .= $key . '=' . $value . '&'; |
|
351 | + } |
|
352 | + $url = $url . '?' . $urlparameters; |
|
353 | + |
|
354 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
355 | + } |
|
356 | + echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">"; |
|
357 | + if ($editable) { |
|
358 | + echo "</a>"; |
|
359 | + } |
|
360 | + } else { |
|
361 | + if ($editable) { |
|
362 | + $url = api_get_self(); |
|
363 | + $urlparameters = ''; |
|
364 | + foreach ($_GET as $key=>$value) { |
|
365 | + $parameter[$key]=$value; |
|
366 | + } |
|
367 | + $parameter['action']='manage_rights'; |
|
368 | + $parameter['do']='grant'; |
|
369 | + $parameter['permission']=$permission; |
|
370 | + $parameter['tool']=$tool; |
|
371 | + $parameter['user_id']=$user_id; |
|
372 | + foreach ($parameter as $key=>$value) { |
|
373 | + $urlparameters .= $key . '=' . $value . '&'; |
|
374 | + } |
|
375 | + $url=$url.'?'.$urlparameters; |
|
376 | + |
|
377 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
|
378 | + echo "\t\t\t <a href=\"".$url."\">"; |
|
379 | + } |
|
380 | + echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">"; |
|
381 | + if ($editable) { |
|
382 | + echo "</a>"; |
|
383 | + } |
|
384 | + } |
|
385 | + } |
|
386 | + } |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -394,41 +394,41 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function display_role_list($current_course_roles, $current_platform_roles) |
396 | 396 | { |
397 | - global $setting_visualisation; |
|
397 | + global $setting_visualisation; |
|
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | - |
|
402 | - // course roles |
|
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
406 | - { |
|
407 | - if (in_array($row['role_id'], $current_course_roles)) |
|
408 | - { |
|
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
412 | - } |
|
413 | - else |
|
414 | - { |
|
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
418 | - } |
|
419 | - if ($setting_visualisation=='checkbox') |
|
420 | - { |
|
421 | - echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | - } |
|
423 | - if ($setting_visualisation=='image') |
|
424 | - { |
|
425 | - echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | - echo $row['role_comment']."<br />\n"; |
|
431 | - } |
|
400 | + $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | + |
|
402 | + // course roles |
|
403 | + $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result=Database::query($sql); |
|
405 | + while ($row=Database::fetch_array($result)) |
|
406 | + { |
|
407 | + if (in_array($row['role_id'], $current_course_roles)) |
|
408 | + { |
|
409 | + $checked='checked'; |
|
410 | + $image='checkbox_on2.gif'; |
|
411 | + $action='revoke'; |
|
412 | + } |
|
413 | + else |
|
414 | + { |
|
415 | + $checked=''; |
|
416 | + $image='wrong.gif'; |
|
417 | + $action='grant'; |
|
418 | + } |
|
419 | + if ($setting_visualisation=='checkbox') |
|
420 | + { |
|
421 | + echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
422 | + } |
|
423 | + if ($setting_visualisation=='image') |
|
424 | + { |
|
425 | + echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
430 | + echo $row['role_comment']."<br />\n"; |
|
431 | + } |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -442,24 +442,24 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function get_roles($content,$id, $scope='course') { |
444 | 444 | $course_id = api_get_course_int_id(); |
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | - $id_field = user_id; |
|
448 | - } |
|
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | - $id_field = 'group_id'; |
|
452 | - } |
|
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | - |
|
455 | - $current_roles=array(); |
|
456 | - //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
461 | - } |
|
462 | - return $current_roles; |
|
445 | + if ($content=='user') { |
|
446 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
447 | + $id_field = user_id; |
|
448 | + } |
|
449 | + if ($content=='group') { |
|
450 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | + $id_field = 'group_id'; |
|
452 | + } |
|
453 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
454 | + |
|
455 | + $current_roles=array(); |
|
456 | + //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
|
457 | + $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result=Database::query($sql); |
|
459 | + while ($row=Database::fetch_array($result)) { |
|
460 | + $current_roles[]=$row['role_id']; |
|
461 | + } |
|
462 | + return $current_roles; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -472,25 +472,25 @@ discard block |
||
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
476 | - { |
|
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | - } |
|
479 | - if ($content=='platform') |
|
480 | - { |
|
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | - $course_id_condition = ''; |
|
483 | - } |
|
484 | - |
|
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
489 | - { |
|
490 | - $roles[]=$row; |
|
491 | - } |
|
492 | - |
|
493 | - return $roles; |
|
475 | + if ($content=='course') |
|
476 | + { |
|
477 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
478 | + } |
|
479 | + if ($content=='platform') |
|
480 | + { |
|
481 | + $table_role=Database::get_main_table(TABLE_ROLE); |
|
482 | + $course_id_condition = ''; |
|
483 | + } |
|
484 | + |
|
485 | + $current_roles=array(); |
|
486 | + $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result=Database::query($sql); |
|
488 | + while ($row=Database::fetch_array($result)) |
|
489 | + { |
|
490 | + $roles[]=$row; |
|
491 | + } |
|
492 | + |
|
493 | + return $roles; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function get_roles_permissions($content,$id, $scope='course') { |
508 | 508 | $course_id = api_get_course_int_id(); |
509 | - if ($content == 'user') { |
|
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | - $id_field = 'user_id'; |
|
512 | - } |
|
513 | - |
|
514 | - if ($content == 'group') { |
|
515 | - $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | - $id_field = 'group_id'; |
|
517 | - } |
|
518 | - |
|
519 | - // course roles or platform roles |
|
520 | - $scope = 'course'; |
|
521 | - if ($scope == 'course') { |
|
522 | - $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | - $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
509 | + if ($content == 'user') { |
|
510 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
511 | + $id_field = 'user_id'; |
|
512 | + } |
|
513 | + |
|
514 | + if ($content == 'group') { |
|
515 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
516 | + $id_field = 'group_id'; |
|
517 | + } |
|
518 | + |
|
519 | + // course roles or platform roles |
|
520 | + $scope = 'course'; |
|
521 | + if ($scope == 'course') { |
|
522 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
523 | + $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
524 | 524 | |
525 | 525 | $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND "; |
526 | - } |
|
526 | + } |
|
527 | 527 | |
528 | - if ($scope == 'platform') { |
|
529 | - $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | - $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
528 | + if ($scope == 'platform') { |
|
529 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
530 | + $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
531 | 531 | $role_condition = ''; |
532 | - } |
|
532 | + } |
|
533 | 533 | |
534 | - $current_roles = array(); |
|
534 | + $current_roles = array(); |
|
535 | 535 | |
536 | - $sql = " |
|
536 | + $sql = " |
|
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | 539 | " . $table . " role_group_user, |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | - $result = Database::query($sql); |
|
550 | + $result = Database::query($sql); |
|
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row=Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][]=$row['action']; |
|
554 | 554 | } |
555 | - return $current_role_permissions; |
|
555 | + return $current_role_permissions; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -566,34 +566,34 @@ discard block |
||
566 | 566 | |
567 | 567 | function assign_role($content, $action, $id, $role_id, $scope='course') { |
568 | 568 | $course_id = api_get_course_int_id(); |
569 | - // Which database are we using (depending on the $content parameter) |
|
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | - $id_field = 'user_id'; |
|
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | - $id_field = 'group_id'; |
|
576 | - } else { |
|
577 | - return get_lang('Error'); |
|
578 | - } |
|
579 | - |
|
580 | - // grating a right |
|
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
584 | - if ($result) { |
|
585 | - $result_message=get_lang('RoleGranted'); |
|
586 | - } |
|
587 | - } |
|
569 | + // Which database are we using (depending on the $content parameter) |
|
570 | + if ($content=='user') { |
|
571 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
572 | + $id_field = 'user_id'; |
|
573 | + } elseif($content=='group') { |
|
574 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | + $id_field = 'group_id'; |
|
576 | + } else { |
|
577 | + return get_lang('Error'); |
|
578 | + } |
|
579 | + |
|
580 | + // grating a right |
|
581 | + if ($action=='grant') { |
|
582 | + $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result=Database::query($sql); |
|
584 | + if ($result) { |
|
585 | + $result_message=get_lang('RoleGranted'); |
|
586 | + } |
|
587 | + } |
|
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
592 | - if ($result) { |
|
593 | - $result_message=get_lang('RoleRevoked'); |
|
594 | - } |
|
595 | - } |
|
596 | - return $result_message; |
|
589 | + if ($action=='revoke') { |
|
590 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result=Database::query($sql); |
|
592 | + if ($result) { |
|
593 | + $result_message=get_lang('RoleRevoked'); |
|
594 | + } |
|
595 | + } |
|
596 | + return $result_message; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | |
@@ -603,21 +603,21 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function permission_array_merge($array1, $array2) |
605 | 605 | { |
606 | - foreach ($array2 as $tool=>$permissions) |
|
607 | - { |
|
608 | - foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | - { |
|
610 | - $array1[$tool][]=$permissionvalue; |
|
611 | - } |
|
612 | - } |
|
613 | - return $array1; |
|
606 | + foreach ($array2 as $tool=>$permissions) |
|
607 | + { |
|
608 | + foreach ($permissions as $permissionkey=>$permissionvalue) |
|
609 | + { |
|
610 | + $array1[$tool][]=$permissionvalue; |
|
611 | + } |
|
612 | + } |
|
613 | + return $array1; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
617 | 617 | function my_print_r($array) |
618 | 618 | { |
619 | - echo '<pre>'; |
|
620 | - print_r($array); |
|
621 | - echo '</pre>'; |
|
619 | + echo '<pre>'; |
|
620 | + print_r($array); |
|
621 | + echo '</pre>'; |
|
622 | 622 | } |
623 | 623 | ?> |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | $course_id = api_get_course_int_id(); |
27 | 27 | |
28 | 28 | // Which database are we using (depending on the $content parameter) |
29 | - if ($content=='user') |
|
29 | + if ($content == 'user') |
|
30 | 30 | { |
31 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
31 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
32 | 32 | $id_field = user_id; |
33 | 33 | } |
34 | - if ($content=='group') |
|
34 | + if ($content == 'group') |
|
35 | 35 | { |
36 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
36 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
37 | 37 | $id_field = group_id; |
38 | 38 | } |
39 | - if ($content=='role') |
|
39 | + if ($content == 'role') |
|
40 | 40 | { |
41 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
41 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
42 | 42 | $id_field = role_id; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // We first delete all the existing permissions for that user/group/role |
46 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | - $result=Database::query($sql); |
|
46 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'"; |
|
47 | + $result = Database::query($sql); |
|
48 | 48 | |
49 | 49 | // looping through the post values to find the permission (containing the string permission* ) |
50 | 50 | foreach ($_POST as $key => $value) |
51 | 51 | { |
52 | - if (strstr($key,"permission*")) |
|
52 | + if (strstr($key, "permission*")) |
|
53 | 53 | { |
54 | - list($brol,$tool,$action)=explode("*",$key); |
|
55 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | - $result=Database::query($sql); |
|
54 | + list($brol, $tool, $action) = explode("*", $key); |
|
55 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')"; |
|
56 | + $result = Database::query($sql); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | return get_lang('PermissionsStored'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @author Patrick Cool <[email protected]>, Ghent University |
70 | 70 | * @version 1.0 |
71 | 71 | */ |
72 | -function store_one_permission($content, $action, $id, $tool,$permission) { |
|
72 | +function store_one_permission($content, $action, $id, $tool, $permission) { |
|
73 | 73 | global $rights_full; |
74 | 74 | $course_id = api_get_course_int_id(); |
75 | 75 | // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out. |
@@ -82,35 +82,35 @@ discard block |
||
82 | 82 | |
83 | 83 | // Which database are we using (depending on the $content parameter) |
84 | 84 | |
85 | - if ($content=='user') { |
|
86 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
85 | + if ($content == 'user') { |
|
86 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
87 | 87 | $id_field = user_id; |
88 | 88 | } |
89 | - if ($content=='group') |
|
89 | + if ($content == 'group') |
|
90 | 90 | { |
91 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
91 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
92 | 92 | $id_field = group_id; |
93 | 93 | } |
94 | - if ($content=='role') |
|
94 | + if ($content == 'role') |
|
95 | 95 | { |
96 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
96 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
97 | 97 | $id_field = role_id; |
98 | 98 | } |
99 | 99 | |
100 | 100 | // grating a right |
101 | - if ($action=='grant') { |
|
102 | - $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | - $result=Database::query($sql); |
|
104 | - if($result) { |
|
105 | - $result_message=get_lang('PermissionGranted'); |
|
101 | + if ($action == 'grant') { |
|
102 | + $sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')"; |
|
103 | + $result = Database::query($sql); |
|
104 | + if ($result) { |
|
105 | + $result_message = get_lang('PermissionGranted'); |
|
106 | 106 | } |
107 | 107 | } |
108 | - if ($action=='revoke') |
|
108 | + if ($action == 'revoke') |
|
109 | 109 | { |
110 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | - $result=Database::query($sql); |
|
112 | - if($result) { |
|
113 | - $result_message=get_lang('PermissionRevoked'); |
|
110 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'"; |
|
111 | + $result = Database::query($sql); |
|
112 | + if ($result) { |
|
113 | + $result_message = get_lang('PermissionRevoked'); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | return $result_message; |
@@ -125,44 +125,44 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function get_permissions($content, $id) { |
127 | 127 | $course_id = api_get_course_int_id(); |
128 | - $currentpermissions=array(); |
|
128 | + $currentpermissions = array(); |
|
129 | 129 | // Which database are we using (depending on the $content parameter) |
130 | 130 | $course_id_condition = " c_id = $course_id AND "; |
131 | 131 | if ($content == 'user') |
132 | 132 | { |
133 | - $table=Database::get_course_table(TABLE_PERMISSION_USER); |
|
133 | + $table = Database::get_course_table(TABLE_PERMISSION_USER); |
|
134 | 134 | $id_field = 'user_id'; |
135 | 135 | } |
136 | 136 | elseif ($content == 'group') |
137 | 137 | { |
138 | - $table=Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
138 | + $table = Database::get_course_table(TABLE_PERMISSION_GROUP); |
|
139 | 139 | $id_field = 'group_id'; |
140 | 140 | } |
141 | 141 | elseif ($content == 'role') |
142 | 142 | { |
143 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
143 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
144 | 144 | $id_field = 'role_id'; |
145 | 145 | } |
146 | 146 | elseif ($content == 'platform_role') |
147 | 147 | { |
148 | - $table=Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
148 | + $table = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
149 | 149 | $id_field = 'role_id'; |
150 | 150 | $course_id_condition = ''; |
151 | 151 | } |
152 | 152 | elseif ($content == 'task') |
153 | 153 | { |
154 | - $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
154 | + $table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | 155 | $id_field = 'task_id'; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // finding all the permissions. We store this in a multidimensional array |
159 | 159 | // where the first dimension is the tool. |
160 | - $sql=" |
|
161 | - SELECT * FROM " . $table . " |
|
162 | - WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'"; |
|
160 | + $sql = " |
|
161 | + SELECT * FROM " . $table." |
|
162 | + WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'"; |
|
163 | 163 | $result = Database::query($sql); |
164 | 164 | |
165 | - while($row = Database::fetch_array($result)) |
|
165 | + while ($row = Database::fetch_array($result)) |
|
166 | 166 | $currentpermissions[$row['tool']][] = $row['action']; |
167 | 167 | |
168 | 168 | return $currentpermissions; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function limited_or_full($current_permissions) |
181 | 181 | { |
182 | - if (api_get_setting('permissions')=='limited') |
|
182 | + if (api_get_setting('permissions') == 'limited') |
|
183 | 183 | { |
184 | 184 | foreach ($current_permissions as $tool=>$tool_rights) |
185 | 185 | { |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | // if it is visibility or move we have to grant the edit right |
188 | 188 | foreach ($tool_rights as $key=>$value) |
189 | 189 | { |
190 | - if ($value=='View') |
|
190 | + if ($value == 'View') |
|
191 | 191 | { |
192 | 192 | unset($current_permissions[$tool][$key]); |
193 | 193 | } |
194 | - if ($value=='Visibility' OR $value=='Move') |
|
194 | + if ($value == 'Visibility' OR $value == 'Move') |
|
195 | 195 | { |
196 | - if (!in_array('Edit',$current_permissions[$tool])) |
|
196 | + if (!in_array('Edit', $current_permissions[$tool])) |
|
197 | 197 | { |
198 | - $current_permissions[$tool][]='Edit'; |
|
198 | + $current_permissions[$tool][] = 'Edit'; |
|
199 | 199 | } |
200 | 200 | unset($current_permissions[$tool][$key]); |
201 | 201 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | return $current_permissions; |
209 | 209 | } |
210 | - if (api_get_setting('permissions')=='full') |
|
210 | + if (api_get_setting('permissions') == 'full') |
|
211 | 211 | { |
212 | 212 | return $current_permissions; |
213 | 213 | } |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @author Patrick Cool <[email protected]>, Ghent University |
223 | 223 | * @version 1.0 |
224 | 224 | */ |
225 | -function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array()) |
|
225 | +function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions = array()) |
|
226 | 226 | { |
227 | - $checked=""; |
|
228 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
227 | + $checked = ""; |
|
228 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
229 | 229 | { |
230 | - $checked="checked"; |
|
230 | + $checked = "checked"; |
|
231 | 231 | } |
232 | 232 | echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n"; |
233 | 233 | |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | * @author Patrick Cool <[email protected]>, Ghent University |
244 | 244 | * @version 1.0 |
245 | 245 | */ |
246 | -function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
246 | +function display_image_matrix($permission_array, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
247 | 247 | { |
248 | 248 | if ($course_admin) { |
249 | 249 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
250 | 250 | } else { |
251 | - if (in_array($permission,$inherited_permissions[$tool])) { |
|
251 | + if (in_array($permission, $inherited_permissions[$tool])) { |
|
252 | 252 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
253 | 253 | } else { |
254 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) { |
|
254 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) { |
|
255 | 255 | if ($editable) { |
256 | - $url=api_get_self(); |
|
256 | + $url = api_get_self(); |
|
257 | 257 | $urlparameters = ''; |
258 | - foreach($_GET as $key=>$value) { |
|
259 | - $parameter[$key]=$value; |
|
258 | + foreach ($_GET as $key=>$value) { |
|
259 | + $parameter[$key] = $value; |
|
260 | 260 | } |
261 | - $parameter['action']='revoke'; |
|
262 | - $parameter['permission']=$permission; |
|
263 | - $parameter['tool']=$tool; |
|
261 | + $parameter['action'] = 'revoke'; |
|
262 | + $parameter['permission'] = $permission; |
|
263 | + $parameter['tool'] = $tool; |
|
264 | 264 | foreach ($parameter as $key=>$value) { |
265 | - $urlparameters.=$key.'='.$value.'&'; |
|
265 | + $urlparameters .= $key.'='.$value.'&'; |
|
266 | 266 | } |
267 | - $url=$url.'?'.$urlparameters; |
|
267 | + $url = $url.'?'.$urlparameters; |
|
268 | 268 | |
269 | 269 | echo "\t\t\t <a href=\"".$url."\">"; |
270 | 270 | } |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | } else { |
276 | 276 | if ($editable) |
277 | 277 | { |
278 | - $url=api_get_self(); |
|
278 | + $url = api_get_self(); |
|
279 | 279 | $urlparameters = ''; |
280 | 280 | foreach ($_GET as $key=>$value) |
281 | 281 | { |
282 | - $parameter[$key]=$value; |
|
282 | + $parameter[$key] = $value; |
|
283 | 283 | } |
284 | - $parameter['action']='grant'; |
|
285 | - $parameter['permission']=$permission; |
|
286 | - $parameter['tool']=$tool; |
|
284 | + $parameter['action'] = 'grant'; |
|
285 | + $parameter['permission'] = $permission; |
|
286 | + $parameter['tool'] = $tool; |
|
287 | 287 | foreach ($parameter as $key=>$value) |
288 | 288 | { |
289 | - $urlparameters.=$key.'='.$value.'&'; |
|
289 | + $urlparameters .= $key.'='.$value.'&'; |
|
290 | 290 | } |
291 | - $url=$url.'?'.$urlparameters; |
|
291 | + $url = $url.'?'.$urlparameters; |
|
292 | 292 | |
293 | 293 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
294 | 294 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @author Patrick Cool <[email protected]>, Ghent University |
316 | 316 | * @version 1.0 |
317 | 317 | */ |
318 | -function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true) |
|
318 | +function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true) |
|
319 | 319 | { |
320 | 320 | |
321 | 321 | if ($course_admin) |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool])) |
|
327 | + if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool])) |
|
328 | 328 | { |
329 | 329 | echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">"; |
330 | 330 | } |
331 | 331 | else |
332 | 332 | { |
333 | - if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) |
|
333 | + if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) |
|
334 | 334 | { |
335 | 335 | if ($editable) |
336 | 336 | { |
337 | 337 | $url = api_get_self(); |
338 | 338 | $urlparameters = ''; |
339 | - foreach($_GET as $key => $value) |
|
339 | + foreach ($_GET as $key => $value) |
|
340 | 340 | { |
341 | 341 | $parameter[$key] = $value; |
342 | 342 | } |
343 | - $parameter['action']='manage_rights'; |
|
344 | - $parameter['do']='revoke'; |
|
345 | - $parameter['permission']=$permission; |
|
346 | - $parameter['tool']=$tool; |
|
347 | - $parameter['user_id']=$user_id; |
|
343 | + $parameter['action'] = 'manage_rights'; |
|
344 | + $parameter['do'] = 'revoke'; |
|
345 | + $parameter['permission'] = $permission; |
|
346 | + $parameter['tool'] = $tool; |
|
347 | + $parameter['user_id'] = $user_id; |
|
348 | 348 | foreach ($parameter as $key=>$value) |
349 | 349 | { |
350 | - $urlparameters .= $key . '=' . $value . '&'; |
|
350 | + $urlparameters .= $key.'='.$value.'&'; |
|
351 | 351 | } |
352 | - $url = $url . '?' . $urlparameters; |
|
352 | + $url = $url.'?'.$urlparameters; |
|
353 | 353 | |
354 | 354 | echo "\t\t\t <a href=\"".$url."\">"; |
355 | 355 | } |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | $url = api_get_self(); |
363 | 363 | $urlparameters = ''; |
364 | 364 | foreach ($_GET as $key=>$value) { |
365 | - $parameter[$key]=$value; |
|
365 | + $parameter[$key] = $value; |
|
366 | 366 | } |
367 | - $parameter['action']='manage_rights'; |
|
368 | - $parameter['do']='grant'; |
|
369 | - $parameter['permission']=$permission; |
|
370 | - $parameter['tool']=$tool; |
|
371 | - $parameter['user_id']=$user_id; |
|
367 | + $parameter['action'] = 'manage_rights'; |
|
368 | + $parameter['do'] = 'grant'; |
|
369 | + $parameter['permission'] = $permission; |
|
370 | + $parameter['tool'] = $tool; |
|
371 | + $parameter['user_id'] = $user_id; |
|
372 | 372 | foreach ($parameter as $key=>$value) { |
373 | - $urlparameters .= $key . '=' . $value . '&'; |
|
373 | + $urlparameters .= $key.'='.$value.'&'; |
|
374 | 374 | } |
375 | - $url=$url.'?'.$urlparameters; |
|
375 | + $url = $url.'?'.$urlparameters; |
|
376 | 376 | |
377 | 377 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
378 | 378 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -397,30 +397,30 @@ discard block |
||
397 | 397 | global $setting_visualisation; |
398 | 398 | $course_id = api_get_course_int_id(); |
399 | 399 | |
400 | - $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
400 | + $coures_roles_table = Database::get_course_table(TABLE_ROLE); |
|
401 | 401 | |
402 | 402 | // course roles |
403 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | - $result=Database::query($sql); |
|
405 | - while ($row=Database::fetch_array($result)) |
|
403 | + $sql = "SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
404 | + $result = Database::query($sql); |
|
405 | + while ($row = Database::fetch_array($result)) |
|
406 | 406 | { |
407 | 407 | if (in_array($row['role_id'], $current_course_roles)) |
408 | 408 | { |
409 | - $checked='checked'; |
|
410 | - $image='checkbox_on2.gif'; |
|
411 | - $action='revoke'; |
|
409 | + $checked = 'checked'; |
|
410 | + $image = 'checkbox_on2.gif'; |
|
411 | + $action = 'revoke'; |
|
412 | 412 | } |
413 | 413 | else |
414 | 414 | { |
415 | - $checked=''; |
|
416 | - $image='wrong.gif'; |
|
417 | - $action='grant'; |
|
415 | + $checked = ''; |
|
416 | + $image = 'wrong.gif'; |
|
417 | + $action = 'grant'; |
|
418 | 418 | } |
419 | - if ($setting_visualisation=='checkbox') |
|
419 | + if ($setting_visualisation == 'checkbox') |
|
420 | 420 | { |
421 | 421 | echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
422 | 422 | } |
423 | - if ($setting_visualisation=='image') |
|
423 | + if ($setting_visualisation == 'image') |
|
424 | 424 | { |
425 | 425 | echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
426 | 426 | } |
@@ -440,24 +440,24 @@ discard block |
||
440 | 440 | * @author Patrick Cool <[email protected]>, Ghent University |
441 | 441 | * @version 1.0 |
442 | 442 | */ |
443 | -function get_roles($content,$id, $scope='course') { |
|
444 | - $course_id = api_get_course_int_id(); |
|
445 | - if ($content=='user') { |
|
446 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
443 | +function get_roles($content, $id, $scope = 'course') { |
|
444 | + $course_id = api_get_course_int_id(); |
|
445 | + if ($content == 'user') { |
|
446 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
447 | 447 | $id_field = user_id; |
448 | 448 | } |
449 | - if ($content=='group') { |
|
450 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
449 | + if ($content == 'group') { |
|
450 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
451 | 451 | $id_field = 'group_id'; |
452 | 452 | } |
453 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
453 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
454 | 454 | |
455 | - $current_roles=array(); |
|
455 | + $current_roles = array(); |
|
456 | 456 | //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'"; |
457 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | - $result=Database::query($sql); |
|
459 | - while ($row=Database::fetch_array($result)) { |
|
460 | - $current_roles[]=$row['role_id']; |
|
457 | + $sql = "SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
458 | + $result = Database::query($sql); |
|
459 | + while ($row = Database::fetch_array($result)) { |
|
460 | + $current_roles[] = $row['role_id']; |
|
461 | 461 | } |
462 | 462 | return $current_roles; |
463 | 463 | } |
@@ -468,26 +468,26 @@ discard block |
||
468 | 468 | * @author Patrick Cool <[email protected]>, Ghent University |
469 | 469 | * @version 1.0 |
470 | 470 | */ |
471 | -function get_all_roles($content='course') { |
|
471 | +function get_all_roles($content = 'course') { |
|
472 | 472 | $course_id = api_get_course_int_id(); |
473 | 473 | $course_id_condition = " WHERE c_id = $course_id "; |
474 | 474 | |
475 | - if ($content=='course') |
|
475 | + if ($content == 'course') |
|
476 | 476 | { |
477 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
477 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
478 | 478 | } |
479 | - if ($content=='platform') |
|
479 | + if ($content == 'platform') |
|
480 | 480 | { |
481 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
481 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
482 | 482 | $course_id_condition = ''; |
483 | 483 | } |
484 | 484 | |
485 | - $current_roles=array(); |
|
486 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
487 | - $result=Database::query($sql); |
|
488 | - while ($row=Database::fetch_array($result)) |
|
485 | + $current_roles = array(); |
|
486 | + $sql = "SELECT * FROM $table_role $course_id_condition "; |
|
487 | + $result = Database::query($sql); |
|
488 | + while ($row = Database::fetch_array($result)) |
|
489 | 489 | { |
490 | - $roles[]=$row; |
|
490 | + $roles[] = $row; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $roles; |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @author Patrick Cool <[email protected]>, Ghent University |
505 | 505 | * @version 1.0 |
506 | 506 | */ |
507 | -function get_roles_permissions($content,$id, $scope='course') { |
|
507 | +function get_roles_permissions($content, $id, $scope = 'course') { |
|
508 | 508 | $course_id = api_get_course_int_id(); |
509 | 509 | if ($content == 'user') { |
510 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
510 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
511 | 511 | $id_field = 'user_id'; |
512 | 512 | } |
513 | 513 | |
@@ -536,21 +536,21 @@ discard block |
||
536 | 536 | $sql = " |
537 | 537 | SELECT * |
538 | 538 | FROM |
539 | - " . $table . " role_group_user, |
|
540 | - " . $table_role . " role, |
|
541 | - " . $table_role_permissions . " role_permissions |
|
539 | + " . $table." role_group_user, |
|
540 | + " . $table_role." role, |
|
541 | + " . $table_role_permissions." role_permissions |
|
542 | 542 | WHERE |
543 | 543 | role_group_user.c_id = $course_id AND |
544 | 544 | $role_condition |
545 | - role_group_user.scope = '" . $scope . "' AND |
|
546 | - role_group_user." . $id_field . " = '" . $id . "' AND |
|
545 | + role_group_user.scope = '".$scope."' AND |
|
546 | + role_group_user." . $id_field." = '".$id."' AND |
|
547 | 547 | role_group_user.role_id = role.role_id AND |
548 | 548 | role.role_id = role_permissions.role_id"; |
549 | 549 | |
550 | 550 | $result = Database::query($sql); |
551 | 551 | $current_role_permissions = array(); |
552 | - while ($row=Database::fetch_array($result)) { |
|
553 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
552 | + while ($row = Database::fetch_array($result)) { |
|
553 | + $current_role_permissions[$row['tool']][] = $row['action']; |
|
554 | 554 | } |
555 | 555 | return $current_role_permissions; |
556 | 556 | } |
@@ -564,33 +564,33 @@ discard block |
||
564 | 564 | * @author Patrick Cool <[email protected]>, Ghent University |
565 | 565 | */ |
566 | 566 | |
567 | -function assign_role($content, $action, $id, $role_id, $scope='course') { |
|
567 | +function assign_role($content, $action, $id, $role_id, $scope = 'course') { |
|
568 | 568 | $course_id = api_get_course_int_id(); |
569 | 569 | // Which database are we using (depending on the $content parameter) |
570 | - if ($content=='user') { |
|
571 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
570 | + if ($content == 'user') { |
|
571 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
572 | 572 | $id_field = 'user_id'; |
573 | - } elseif($content=='group') { |
|
574 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
573 | + } elseif ($content == 'group') { |
|
574 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
575 | 575 | $id_field = 'group_id'; |
576 | 576 | } else { |
577 | 577 | return get_lang('Error'); |
578 | 578 | } |
579 | 579 | |
580 | 580 | // grating a right |
581 | - if ($action=='grant') { |
|
582 | - $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | - $result=Database::query($sql); |
|
581 | + if ($action == 'grant') { |
|
582 | + $sql = "INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')"; |
|
583 | + $result = Database::query($sql); |
|
584 | 584 | if ($result) { |
585 | - $result_message=get_lang('RoleGranted'); |
|
585 | + $result_message = get_lang('RoleGranted'); |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | - if ($action=='revoke') { |
|
590 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | - $result=Database::query($sql); |
|
589 | + if ($action == 'revoke') { |
|
590 | + $sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
591 | + $result = Database::query($sql); |
|
592 | 592 | if ($result) { |
593 | - $result_message=get_lang('RoleRevoked'); |
|
593 | + $result_message = get_lang('RoleRevoked'); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | return $result_message; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | foreach ($permissions as $permissionkey=>$permissionvalue) |
609 | 609 | { |
610 | - $array1[$tool][]=$permissionvalue; |
|
610 | + $array1[$tool][] = $permissionvalue; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | return $array1; |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Code |
7 | 7 | */ |
8 | -$user_id=$userIdViewed; |
|
9 | -if ($mainUserInfo['status']==1) |
|
8 | +$user_id = $userIdViewed; |
|
9 | +if ($mainUserInfo['status'] == 1) |
|
10 | 10 | { |
11 | - $course_admin=1; |
|
11 | + $course_admin = 1; |
|
12 | 12 | } |
13 | 13 | include_once('permissions_functions.inc.php'); |
14 | 14 | include_once('all_permissions.inc.php'); |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | // --------------------------------------------------- |
18 | 18 | // ACTIONS |
19 | 19 | // --------------------------------------------------- |
20 | -if ($_POST['StoreUserPermissions'] and $setting_visualisation=='checkbox') |
|
20 | +if ($_POST['StoreUserPermissions'] and $setting_visualisation == 'checkbox') |
|
21 | 21 | { |
22 | - $result_message=store_permissions('user', $user_id); |
|
22 | + $result_message = store_permissions('user', $user_id); |
|
23 | 23 | if ($result_message) |
24 | 24 | { |
25 | 25 | Display::display_normal_message($result_message); |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | } |
28 | 28 | if (isset($_GET['action'])) |
29 | 29 | { |
30 | - if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
30 | + if (isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke')) |
|
31 | 31 | { |
32 | - $result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']); |
|
32 | + $result_message = store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']); |
|
33 | 33 | } |
34 | - if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
34 | + if (isset($_GET['role']) AND ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke')) |
|
35 | 35 | { |
36 | - $result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']); |
|
36 | + $result_message = assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | if (isset($result_message)) |
@@ -44,33 +44,33 @@ discard block |
||
44 | 44 | // --------------------------------------------------- |
45 | 45 | // RETRIEVING THE PERMISSIONS OF THE USER |
46 | 46 | // --------------------------------------------------- |
47 | -$current_user_permissions=array(); |
|
48 | -$current_user_permissions=get_permissions('user',$user_id); |
|
47 | +$current_user_permissions = array(); |
|
48 | +$current_user_permissions = get_permissions('user', $user_id); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | // INHERITED PERMISSIONS (group permissions, user roles, group roles) |
52 | 52 | |
53 | 53 | // RETRIEVING THE PERMISSIONS OF THE GROUPS OF THE USER |
54 | -$groups_of_user=array(); |
|
55 | -$groups_of_user=GroupManager::get_group_ids($_course['real_id'],$user_id); |
|
54 | +$groups_of_user = array(); |
|
55 | +$groups_of_user = GroupManager::get_group_ids($_course['real_id'], $user_id); |
|
56 | 56 | foreach ($groups_of_user as $group) |
57 | 57 | { |
58 | - $this_group_permissions=get_permissions('group',$group); |
|
58 | + $this_group_permissions = get_permissions('group', $group); |
|
59 | 59 | foreach ($this_group_permissions as $tool=>$permissions) |
60 | 60 | { |
61 | 61 | foreach ($permissions as $permission) |
62 | 62 | { |
63 | - $inherited_group_permissions[$tool][]=$permission; |
|
63 | + $inherited_group_permissions[$tool][] = $permission; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | -$inherited_permissions=$inherited_group_permissions; |
|
67 | +$inherited_permissions = $inherited_group_permissions; |
|
68 | 68 | |
69 | 69 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
70 | -if (api_get_setting('user_roles')=='true') { |
|
70 | +if (api_get_setting('user_roles') == 'true') { |
|
71 | 71 | // course roles that are assigned to the user |
72 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
73 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
72 | + $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
73 | + $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
74 | 74 | // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
75 | 75 | // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
76 | 76 | // groepsge�rfde permissions in beschouwing worden genomen |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
81 | 81 | // ophalen. |
82 | 82 | // platform roles that are assigned to the user |
83 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
84 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
83 | + $current_user_role_permissions_of_user = get_roles_permissions('user', $user_id, 'platform'); |
|
84 | + $inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
85 | 85 | } |
86 | 86 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
87 | -if (api_get_setting('group_roles')=='true') |
|
87 | +if (api_get_setting('group_roles') == 'true') |
|
88 | 88 | { |
89 | 89 | // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
90 | 90 | foreach ($groups_of_user as $group) |
91 | 91 | { |
92 | - $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
92 | + $this_current_group_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
93 | 93 | //$inherited_permissions[$tool][]=$permission; |
94 | 94 | } |
95 | 95 | } |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | // --------------------------------------------------- |
98 | 98 | // LIMITED OR FULL |
99 | 99 | // --------------------------------------------------- |
100 | -$current_user_permissions=limited_or_full($current_user_permissions); |
|
101 | -$inherited_permissions=limited_or_full($inherited_permissions); |
|
102 | -if (api_get_setting('permissions')=='limited') |
|
100 | +$current_user_permissions = limited_or_full($current_user_permissions); |
|
101 | +$inherited_permissions = limited_or_full($inherited_permissions); |
|
102 | +if (api_get_setting('permissions') == 'limited') |
|
103 | 103 | { |
104 | - $header_array=$rights_limited; |
|
104 | + $header_array = $rights_limited; |
|
105 | 105 | } |
106 | -if (api_get_setting('permissions')=='full') |
|
106 | +if (api_get_setting('permissions') == 'full') |
|
107 | 107 | { |
108 | - $header_array=$rights_full; |
|
108 | + $header_array = $rights_full; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | // --------------------------------------------------- |
115 | 115 | // DISPLAYING THE ROLES LIST |
116 | 116 | // --------------------------------------------------- |
117 | -if (api_get_setting('user_roles')=='true') |
|
117 | +if (api_get_setting('user_roles') == 'true') |
|
118 | 118 | { |
119 | 119 | // the list of the roles for the user |
120 | 120 | echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
121 | - $current_user_course_roles=get_roles('user',$user_id); |
|
122 | - $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
121 | + $current_user_course_roles = get_roles('user', $user_id); |
|
122 | + $current_user_platform_roles = get_roles('user', $user_id, 'platform'); |
|
123 | 123 | display_role_list($current_user_course_roles, $current_user_platform_roles); |
124 | 124 | echo '<br />'; |
125 | 125 | } |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | { |
145 | 145 | echo "\t<tr>\n"; |
146 | 146 | echo "\t\t<td>\n"; |
147 | - if (strstr($tool,'BLOG')) |
|
147 | + if (strstr($tool, 'BLOG')) |
|
148 | 148 | { |
149 | 149 | // Not dealing with a real tool here, get name of this blog |
150 | 150 | // Strip blog id |
151 | - $tmp = strpos($tool,'_')+1; |
|
152 | - $blog_id = substr($tool,$tmp,strlen($tool)); |
|
151 | + $tmp = strpos($tool, '_') + 1; |
|
152 | + $blog_id = substr($tool, $tmp, strlen($tool)); |
|
153 | 153 | // Get title |
154 | 154 | echo get_lang('Blog').": ".Blog::get_blog_title($blog_id); |
155 | 155 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | { |
165 | 165 | |
166 | 166 | echo "\t\t<td align='center'>\n"; |
167 | - if (in_array($value,$rights)) |
|
167 | + if (in_array($value, $rights)) |
|
168 | 168 | { |
169 | - if ($setting_visualisation=='checkbox') |
|
169 | + if ($setting_visualisation == 'checkbox') |
|
170 | 170 | { |
171 | - display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
171 | + display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions, $course_admin); |
|
172 | 172 | } |
173 | - if ($setting_visualisation=='image') |
|
173 | + if ($setting_visualisation == 'image') |
|
174 | 174 | { |
175 | - display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
175 | + display_image_matrix($current_user_permissions, $tool, $value, $inherited_permissions, $course_admin); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | // note: in a later stage this part will be replaced by a function |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | echo "</table>\n"; |
188 | -if ($setting_visualisation=='checkbox') |
|
188 | +if ($setting_visualisation == 'checkbox') |
|
189 | 189 | { |
190 | 190 | echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
191 | 191 | } |
@@ -140,9 +140,11 @@ discard block |
||
140 | 140 | echo "\t</tr>\n"; |
141 | 141 | |
142 | 142 | // the main area with the checkboxes or images |
143 | -foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
143 | +foreach ($tool_rights as $tool=>$rights) { |
|
144 | + // $tool_rights contains all the possible tools and their rights |
|
144 | 145 | { |
145 | 146 | echo "\t<tr>\n"; |
147 | +} |
|
146 | 148 | echo "\t\t<td>\n"; |
147 | 149 | if (strstr($tool,'BLOG')) |
148 | 150 | { |
@@ -152,8 +154,7 @@ discard block |
||
152 | 154 | $blog_id = substr($tool,$tmp,strlen($tool)); |
153 | 155 | // Get title |
154 | 156 | echo get_lang('Blog').": ".Blog::get_blog_title($blog_id); |
155 | - } |
|
156 | - else |
|
157 | + } else |
|
157 | 158 | { |
158 | 159 | echo get_lang($tool); |
159 | 160 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | $user_id=$userIdViewed; |
9 | 9 | if ($mainUserInfo['status']==1) |
10 | 10 | { |
11 | - $course_admin=1; |
|
11 | + $course_admin=1; |
|
12 | 12 | } |
13 | 13 | include_once('permissions_functions.inc.php'); |
14 | 14 | include_once('all_permissions.inc.php'); |
@@ -19,26 +19,26 @@ discard block |
||
19 | 19 | // --------------------------------------------------- |
20 | 20 | if ($_POST['StoreUserPermissions'] and $setting_visualisation=='checkbox') |
21 | 21 | { |
22 | - $result_message=store_permissions('user', $user_id); |
|
23 | - if ($result_message) |
|
24 | - { |
|
25 | - Display::display_normal_message($result_message); |
|
26 | - } |
|
22 | + $result_message=store_permissions('user', $user_id); |
|
23 | + if ($result_message) |
|
24 | + { |
|
25 | + Display::display_normal_message($result_message); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | if (isset($_GET['action'])) |
29 | 29 | { |
30 | - if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
31 | - { |
|
32 | - $result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']); |
|
33 | - } |
|
34 | - if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
35 | - { |
|
36 | - $result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']); |
|
37 | - } |
|
30 | + if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
31 | + { |
|
32 | + $result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']); |
|
33 | + } |
|
34 | + if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke')) |
|
35 | + { |
|
36 | + $result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | if (isset($result_message)) |
40 | 40 | { |
41 | - Display::display_normal_message($result_message); |
|
41 | + Display::display_normal_message($result_message); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // --------------------------------------------------- |
@@ -55,43 +55,43 @@ discard block |
||
55 | 55 | $groups_of_user=GroupManager::get_group_ids($_course['real_id'],$user_id); |
56 | 56 | foreach ($groups_of_user as $group) |
57 | 57 | { |
58 | - $this_group_permissions=get_permissions('group',$group); |
|
59 | - foreach ($this_group_permissions as $tool=>$permissions) |
|
60 | - { |
|
61 | - foreach ($permissions as $permission) |
|
62 | - { |
|
63 | - $inherited_group_permissions[$tool][]=$permission; |
|
64 | - } |
|
65 | - } |
|
58 | + $this_group_permissions=get_permissions('group',$group); |
|
59 | + foreach ($this_group_permissions as $tool=>$permissions) |
|
60 | + { |
|
61 | + foreach ($permissions as $permission) |
|
62 | + { |
|
63 | + $inherited_group_permissions[$tool][]=$permission; |
|
64 | + } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | $inherited_permissions=$inherited_group_permissions; |
68 | 68 | |
69 | 69 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
70 | 70 | if (api_get_setting('user_roles')=='true') { |
71 | - // course roles that are assigned to the user |
|
72 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
73 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
74 | - // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
75 | - // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
76 | - // groepsge�rfde permissions in beschouwing worden genomen |
|
77 | - // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
78 | - // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
79 | - // omvatten. |
|
80 | - // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
81 | - // ophalen. |
|
82 | - // platform roles that are assigned to the user |
|
83 | - $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
84 | - $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
71 | + // course roles that are assigned to the user |
|
72 | + $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
73 | + $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
74 | + // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
75 | + // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
76 | + // groepsge�rfde permissions in beschouwing worden genomen |
|
77 | + // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
78 | + // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
79 | + // omvatten. |
|
80 | + // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
81 | + // ophalen. |
|
82 | + // platform roles that are assigned to the user |
|
83 | + $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
84 | + $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
85 | 85 | } |
86 | 86 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
87 | 87 | if (api_get_setting('group_roles')=='true') |
88 | 88 | { |
89 | - // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
90 | - foreach ($groups_of_user as $group) |
|
91 | - { |
|
92 | - $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
93 | - //$inherited_permissions[$tool][]=$permission; |
|
94 | - } |
|
89 | + // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
90 | + foreach ($groups_of_user as $group) |
|
91 | + { |
|
92 | + $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
93 | + //$inherited_permissions[$tool][]=$permission; |
|
94 | + } |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | // --------------------------------------------------- |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | $inherited_permissions=limited_or_full($inherited_permissions); |
102 | 102 | if (api_get_setting('permissions')=='limited') |
103 | 103 | { |
104 | - $header_array=$rights_limited; |
|
104 | + $header_array=$rights_limited; |
|
105 | 105 | } |
106 | 106 | if (api_get_setting('permissions')=='full') |
107 | 107 | { |
108 | - $header_array=$rights_full; |
|
108 | + $header_array=$rights_full; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | // --------------------------------------------------- |
117 | 117 | if (api_get_setting('user_roles')=='true') |
118 | 118 | { |
119 | - // the list of the roles for the user |
|
120 | - echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
|
121 | - $current_user_course_roles=get_roles('user',$user_id); |
|
122 | - $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
123 | - display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
124 | - echo '<br />'; |
|
119 | + // the list of the roles for the user |
|
120 | + echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
|
121 | + $current_user_course_roles=get_roles('user',$user_id); |
|
122 | + $current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
123 | + display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
124 | + echo '<br />'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // --------------------------------------------------- |
@@ -135,59 +135,59 @@ discard block |
||
135 | 135 | echo "\t\t<th>".get_lang('Module')."</th>\n"; |
136 | 136 | foreach ($header_array as $header_key=>$header_value) |
137 | 137 | { |
138 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
138 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
139 | 139 | } |
140 | 140 | echo "\t</tr>\n"; |
141 | 141 | |
142 | 142 | // the main area with the checkboxes or images |
143 | 143 | foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
144 | 144 | { |
145 | - echo "\t<tr>\n"; |
|
146 | - echo "\t\t<td>\n"; |
|
147 | - if (strstr($tool,'BLOG')) |
|
148 | - { |
|
149 | - // Not dealing with a real tool here, get name of this blog |
|
150 | - // Strip blog id |
|
151 | - $tmp = strpos($tool,'_')+1; |
|
152 | - $blog_id = substr($tool,$tmp,strlen($tool)); |
|
153 | - // Get title |
|
154 | - echo get_lang('Blog').": ".Blog::get_blog_title($blog_id); |
|
155 | - } |
|
156 | - else |
|
157 | - { |
|
158 | - echo get_lang($tool); |
|
159 | - } |
|
160 | - |
|
161 | - echo "\t\t</td>\n"; |
|
162 | - |
|
163 | - foreach ($header_array as $key=>$value) |
|
164 | - { |
|
165 | - |
|
166 | - echo "\t\t<td align='center'>\n"; |
|
167 | - if (in_array($value,$rights)) |
|
168 | - { |
|
169 | - if ($setting_visualisation=='checkbox') |
|
170 | - { |
|
171 | - display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
172 | - } |
|
173 | - if ($setting_visualisation=='image') |
|
174 | - { |
|
175 | - display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
176 | - } |
|
177 | - } |
|
178 | - // note: in a later stage this part will be replaced by a function |
|
179 | - // so that we can easily switch between a checkbox approach or an image approach |
|
180 | - // where every click is in fact a change of status. In the checkbox approach you first have to |
|
181 | - // do the changes and then store them by clicking the submit button. |
|
182 | - echo "\t\t</td>\n"; |
|
183 | - } |
|
184 | - echo "\t</tr>\n"; |
|
145 | + echo "\t<tr>\n"; |
|
146 | + echo "\t\t<td>\n"; |
|
147 | + if (strstr($tool,'BLOG')) |
|
148 | + { |
|
149 | + // Not dealing with a real tool here, get name of this blog |
|
150 | + // Strip blog id |
|
151 | + $tmp = strpos($tool,'_')+1; |
|
152 | + $blog_id = substr($tool,$tmp,strlen($tool)); |
|
153 | + // Get title |
|
154 | + echo get_lang('Blog').": ".Blog::get_blog_title($blog_id); |
|
155 | + } |
|
156 | + else |
|
157 | + { |
|
158 | + echo get_lang($tool); |
|
159 | + } |
|
160 | + |
|
161 | + echo "\t\t</td>\n"; |
|
162 | + |
|
163 | + foreach ($header_array as $key=>$value) |
|
164 | + { |
|
165 | + |
|
166 | + echo "\t\t<td align='center'>\n"; |
|
167 | + if (in_array($value,$rights)) |
|
168 | + { |
|
169 | + if ($setting_visualisation=='checkbox') |
|
170 | + { |
|
171 | + display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions,$course_admin); |
|
172 | + } |
|
173 | + if ($setting_visualisation=='image') |
|
174 | + { |
|
175 | + display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin); |
|
176 | + } |
|
177 | + } |
|
178 | + // note: in a later stage this part will be replaced by a function |
|
179 | + // so that we can easily switch between a checkbox approach or an image approach |
|
180 | + // where every click is in fact a change of status. In the checkbox approach you first have to |
|
181 | + // do the changes and then store them by clicking the submit button. |
|
182 | + echo "\t\t</td>\n"; |
|
183 | + } |
|
184 | + echo "\t</tr>\n"; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | echo "</table>\n"; |
188 | 188 | if ($setting_visualisation=='checkbox') |
189 | 189 | { |
190 | - echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
190 | + echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
191 | 191 | } |
192 | 192 | echo "</form><br />"; |
193 | 193 |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | // storing all the permission for a given role when the checkbox approach is used |
19 | 19 | if ($_POST['StoreRolePermissions']) |
20 | 20 | { |
21 | - if (!empty($_POST['role_name'])) |
|
22 | - { |
|
23 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
24 | - $sql="INSERT INTO $table_role (role_name, role_comment, default_role) |
|
21 | + if (!empty($_POST['role_name'])) |
|
22 | + { |
|
23 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
24 | + $sql="INSERT INTO $table_role (role_name, role_comment, default_role) |
|
25 | 25 | VALUES ('".Database::escape_string($_POST['role_name'])."','".Database::escape_string($_POST['role_comment'])."','".Database::escape_string($_POST['default_role'])."')"; |
26 | - $result=Database::query($sql); |
|
27 | - $role_id=Database::insert_id(); |
|
28 | - $result_message=store_permissions('role', $role_id); |
|
29 | - } |
|
30 | - else |
|
31 | - { |
|
32 | - $result_message=get_lang('ErrorPleaseGiveRoleName'); |
|
33 | - } |
|
26 | + $result=Database::query($sql); |
|
27 | + $role_id=Database::insert_id(); |
|
28 | + $result_message=store_permissions('role', $role_id); |
|
29 | + } |
|
30 | + else |
|
31 | + { |
|
32 | + $result_message=get_lang('ErrorPleaseGiveRoleName'); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | // storing a permission for a given role when the image approach is used |
36 | 36 | if (isset($_GET['action']) AND isset($_GET['permission']) AND isset($_GET['tool'])) |
37 | 37 | { |
38 | - if ($_GET['action']=='grant' OR $_GET['action']=='revoke') |
|
39 | - { |
|
40 | - $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
41 | - } |
|
38 | + if ($_GET['action']=='grant' OR $_GET['action']=='revoke') |
|
39 | + { |
|
40 | + $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // deleting a role |
45 | 45 | if (isset($_GET['action']) AND isset($_GET['role_id']) AND $_GET['action']=='delete') { |
46 | - //deleting the assignments fo this role: users |
|
47 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
48 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | - $result=Database::query($sql); |
|
46 | + //deleting the assignments fo this role: users |
|
47 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
48 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | + $result=Database::query($sql); |
|
50 | 50 | |
51 | - // deleting the assignments of this role: groups |
|
52 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | - $result=Database::query($sql); |
|
51 | + // deleting the assignments of this role: groups |
|
52 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | + $result=Database::query($sql); |
|
55 | 55 | |
56 | - // deleting the permissions of this role |
|
57 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | - $result=Database::query($sql); |
|
56 | + // deleting the permissions of this role |
|
57 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | + $result=Database::query($sql); |
|
60 | 60 | |
61 | - // deleting the role |
|
62 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
63 | - $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | - $result=Database::query($sql); |
|
65 | - $result_message=get_lang('RoleDeleted'); |
|
61 | + // deleting the role |
|
62 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
63 | + $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | + $result=Database::query($sql); |
|
65 | + $result_message=get_lang('RoleDeleted'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // displaying the return message of the actions |
69 | 69 | if (isset($result_message)) { |
70 | - Display::display_normal_message($result_message); |
|
70 | + Display::display_normal_message($result_message); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // ADDING A NEW ROLE (FORM AND LINK) |
@@ -75,73 +75,73 @@ discard block |
||
75 | 75 | |
76 | 76 | if ($_GET['action']=='add') |
77 | 77 | { |
78 | - echo "<form method=\"post\" action=\"".api_get_self()."\">"; |
|
79 | - echo "\n<table>"; |
|
80 | - echo "\n\t<tr>"; |
|
81 | - echo "\n\t\t<td>"; |
|
82 | - echo get_lang('RoleName'); |
|
83 | - echo "\n\t\t</td>"; |
|
84 | - echo "\n\t\t<td>"; |
|
85 | - echo "\n\t\t\t<input type='text' name='role_name'>"; |
|
86 | - echo "\n\t\t</td>"; |
|
87 | - echo "\n\t</tr>"; |
|
88 | - echo "\n\t<tr>"; |
|
89 | - echo "\n\t\t<td>"; |
|
90 | - echo get_lang('RoleComment'); |
|
91 | - echo "\n\t\t</td>"; |
|
92 | - echo "\n\t\t<td>"; |
|
93 | - echo "\n\t\t\t<textarea name='role_comment'></textarea>"; |
|
94 | - echo "\n\t\t</td>"; |
|
95 | - echo "\n\t</tr>"; |
|
96 | - echo "\n\t<tr>"; |
|
97 | - echo "\n\t\t<td>"; |
|
98 | - echo get_lang('DefaultRole'); |
|
99 | - echo "\n\t\t</td>"; |
|
100 | - echo "\n\t\t<td>"; |
|
101 | - echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">"; |
|
102 | - echo "\n\t\t</td>"; |
|
103 | - echo "\n\t</tr>"; |
|
104 | - echo "\n</table>"; |
|
105 | - echo "<table class=\"data_table\">\n"; |
|
78 | + echo "<form method=\"post\" action=\"".api_get_self()."\">"; |
|
79 | + echo "\n<table>"; |
|
80 | + echo "\n\t<tr>"; |
|
81 | + echo "\n\t\t<td>"; |
|
82 | + echo get_lang('RoleName'); |
|
83 | + echo "\n\t\t</td>"; |
|
84 | + echo "\n\t\t<td>"; |
|
85 | + echo "\n\t\t\t<input type='text' name='role_name'>"; |
|
86 | + echo "\n\t\t</td>"; |
|
87 | + echo "\n\t</tr>"; |
|
88 | + echo "\n\t<tr>"; |
|
89 | + echo "\n\t\t<td>"; |
|
90 | + echo get_lang('RoleComment'); |
|
91 | + echo "\n\t\t</td>"; |
|
92 | + echo "\n\t\t<td>"; |
|
93 | + echo "\n\t\t\t<textarea name='role_comment'></textarea>"; |
|
94 | + echo "\n\t\t</td>"; |
|
95 | + echo "\n\t</tr>"; |
|
96 | + echo "\n\t<tr>"; |
|
97 | + echo "\n\t\t<td>"; |
|
98 | + echo get_lang('DefaultRole'); |
|
99 | + echo "\n\t\t</td>"; |
|
100 | + echo "\n\t\t<td>"; |
|
101 | + echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">"; |
|
102 | + echo "\n\t\t</td>"; |
|
103 | + echo "\n\t</tr>"; |
|
104 | + echo "\n</table>"; |
|
105 | + echo "<table class=\"data_table\">\n"; |
|
106 | 106 | |
107 | - // the header |
|
108 | - if (api_get_setting('permissions')=='limited') |
|
109 | - { |
|
110 | - $header_array=$rights_limited; |
|
111 | - } |
|
112 | - if (api_get_setting('permissions')=='full') |
|
113 | - { |
|
114 | - $header_array=$rights_full; |
|
115 | - } |
|
116 | - echo "\t<tr>\n"; |
|
117 | - echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
118 | - foreach ($header_array as $header_key=>$header_value) |
|
119 | - { |
|
120 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
121 | - } |
|
122 | - echo "\t</tr>\n"; |
|
107 | + // the header |
|
108 | + if (api_get_setting('permissions')=='limited') |
|
109 | + { |
|
110 | + $header_array=$rights_limited; |
|
111 | + } |
|
112 | + if (api_get_setting('permissions')=='full') |
|
113 | + { |
|
114 | + $header_array=$rights_full; |
|
115 | + } |
|
116 | + echo "\t<tr>\n"; |
|
117 | + echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
118 | + foreach ($header_array as $header_key=>$header_value) |
|
119 | + { |
|
120 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
121 | + } |
|
122 | + echo "\t</tr>\n"; |
|
123 | 123 | |
124 | - // the main area with the checkboxes or images |
|
125 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
126 | - { |
|
127 | - echo "\t<tr>\n"; |
|
128 | - echo "\t\t<td>\n"; |
|
129 | - echo get_lang($tool); |
|
130 | - echo "\t\t</td>\n"; |
|
124 | + // the main area with the checkboxes or images |
|
125 | + foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
126 | + { |
|
127 | + echo "\t<tr>\n"; |
|
128 | + echo "\t\t<td>\n"; |
|
129 | + echo get_lang($tool); |
|
130 | + echo "\t\t</td>\n"; |
|
131 | 131 | |
132 | - foreach ($header_array as $key=>$value) |
|
133 | - { |
|
134 | - echo "\t\t<td align='center'>\n"; |
|
135 | - display_checkbox_matrix(array(), $tool, $value); |
|
136 | - echo "\t\t</td>\n"; |
|
137 | - } |
|
138 | - echo "\t</tr>\n"; |
|
139 | - } |
|
132 | + foreach ($header_array as $key=>$value) |
|
133 | + { |
|
134 | + echo "\t\t<td align='center'>\n"; |
|
135 | + display_checkbox_matrix(array(), $tool, $value); |
|
136 | + echo "\t\t</td>\n"; |
|
137 | + } |
|
138 | + echo "\t</tr>\n"; |
|
139 | + } |
|
140 | 140 | |
141 | - echo "</table>\n"; |
|
141 | + echo "</table>\n"; |
|
142 | 142 | |
143 | - echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
144 | - echo "</form>"; |
|
143 | + echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
144 | + echo "</form>"; |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -154,23 +154,23 @@ discard block |
||
154 | 154 | $all_roles=get_all_roles('platform'); |
155 | 155 | foreach ($all_roles as $role) |
156 | 156 | { |
157 | - echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'&scope=platform">'.$role['role_name'].'</a></div>'; |
|
158 | - echo '<div>'.$role['role_comment'].'</div><br />'; |
|
159 | - if ($role['role_id']==$_GET['role_id']) |
|
160 | - { |
|
161 | - $current_role_info=$role; |
|
162 | - } |
|
157 | + echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'&scope=platform">'.$role['role_name'].'</a></div>'; |
|
158 | + echo '<div>'.$role['role_comment'].'</div><br />'; |
|
159 | + if ($role['role_id']==$_GET['role_id']) |
|
160 | + { |
|
161 | + $current_role_info=$role; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | // course roles |
165 | 165 | $all_roles=get_all_roles(); |
166 | 166 | foreach ($all_roles as $role) |
167 | 167 | { |
168 | - echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>'; |
|
169 | - echo '<div>'.$role['role_comment'].'</div><br />'; |
|
170 | - if ($role['role_id']==$_GET['role_id']) |
|
171 | - { |
|
172 | - $current_role_info=$role; |
|
173 | - } |
|
168 | + echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>'; |
|
169 | + echo '<div>'.$role['role_comment'].'</div><br />'; |
|
170 | + if ($role['role_id']==$_GET['role_id']) |
|
171 | + { |
|
172 | + $current_role_info=$role; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // =================================================== |
@@ -178,83 +178,83 @@ discard block |
||
178 | 178 | // =================================================== |
179 | 179 | if ($_GET['role_id']) |
180 | 180 | { |
181 | - $current_role_permissions=get_permissions('role',$_GET['role_id']); |
|
181 | + $current_role_permissions=get_permissions('role',$_GET['role_id']); |
|
182 | 182 | |
183 | - // --------------------------------------------------- |
|
184 | - // LIMITED OR FULL |
|
185 | - // --------------------------------------------------- |
|
186 | - $current_role_permissions=limited_or_full($current_role_permissions); |
|
187 | - if (api_get_setting('permissions')=='limited') |
|
188 | - { |
|
189 | - $header_array=$rights_limited; |
|
190 | - } |
|
191 | - if (api_get_setting('permissions')=='full') |
|
192 | - { |
|
193 | - $header_array=$rights_full; |
|
194 | - } |
|
195 | - // --------------------------------------------------- |
|
196 | - // DISPLAYING THE MATRIX |
|
197 | - // --------------------------------------------------- |
|
198 | - echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
|
183 | + // --------------------------------------------------- |
|
184 | + // LIMITED OR FULL |
|
185 | + // --------------------------------------------------- |
|
186 | + $current_role_permissions=limited_or_full($current_role_permissions); |
|
187 | + if (api_get_setting('permissions')=='limited') |
|
188 | + { |
|
189 | + $header_array=$rights_limited; |
|
190 | + } |
|
191 | + if (api_get_setting('permissions')=='full') |
|
192 | + { |
|
193 | + $header_array=$rights_full; |
|
194 | + } |
|
195 | + // --------------------------------------------------- |
|
196 | + // DISPLAYING THE MATRIX |
|
197 | + // --------------------------------------------------- |
|
198 | + echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
|
199 | 199 | |
200 | - // the list of the roles for the user |
|
201 | - echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />'; |
|
202 | - if ($_GET['scope']=='platform') |
|
203 | - { |
|
204 | - echo get_lang('IsPlatformRoleNotEditable').'<br />'; |
|
205 | - } |
|
200 | + // the list of the roles for the user |
|
201 | + echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />'; |
|
202 | + if ($_GET['scope']=='platform') |
|
203 | + { |
|
204 | + echo get_lang('IsPlatformRoleNotEditable').'<br />'; |
|
205 | + } |
|
206 | 206 | |
207 | - echo "<table class=\"data_table\">\n"; |
|
207 | + echo "<table class=\"data_table\">\n"; |
|
208 | 208 | |
209 | - // the header |
|
210 | - echo "\t<tr>\n"; |
|
211 | - echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
212 | - foreach ($header_array as $header_key=>$header_value) |
|
213 | - { |
|
214 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
215 | - } |
|
216 | - echo "\t</tr>\n"; |
|
209 | + // the header |
|
210 | + echo "\t<tr>\n"; |
|
211 | + echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
212 | + foreach ($header_array as $header_key=>$header_value) |
|
213 | + { |
|
214 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
215 | + } |
|
216 | + echo "\t</tr>\n"; |
|
217 | 217 | |
218 | - // the main area with the checkboxes or images |
|
219 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
220 | - { |
|
221 | - echo "\t<tr>\n"; |
|
222 | - echo "\t\t<td>\n"; |
|
223 | - echo get_lang($tool); |
|
224 | - echo "\t\t</td>\n"; |
|
218 | + // the main area with the checkboxes or images |
|
219 | + foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
220 | + { |
|
221 | + echo "\t<tr>\n"; |
|
222 | + echo "\t\t<td>\n"; |
|
223 | + echo get_lang($tool); |
|
224 | + echo "\t\t</td>\n"; |
|
225 | 225 | |
226 | - foreach ($header_array as $key=>$value) |
|
227 | - { |
|
228 | - echo "\t\t<td align='center'>\n"; |
|
229 | - if (in_array($value,$rights)) |
|
230 | - { |
|
231 | - if ($setting_visualisation=='checkbox') |
|
232 | - { |
|
233 | - display_checkbox_matrix($current_role_permissions, $tool, $value); |
|
234 | - } |
|
235 | - if ($setting_visualisation=='image') |
|
236 | - { |
|
237 | - if ($_GET['scope']=='platform') |
|
238 | - { |
|
239 | - $roles_editable=false; |
|
240 | - } |
|
241 | - else |
|
242 | - { |
|
243 | - $roles_editable=true; |
|
244 | - } |
|
245 | - display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable); |
|
246 | - } |
|
247 | - } |
|
248 | - echo "\t\t</td>\n"; |
|
249 | - } |
|
250 | - echo "\t</tr>\n"; |
|
251 | - } |
|
226 | + foreach ($header_array as $key=>$value) |
|
227 | + { |
|
228 | + echo "\t\t<td align='center'>\n"; |
|
229 | + if (in_array($value,$rights)) |
|
230 | + { |
|
231 | + if ($setting_visualisation=='checkbox') |
|
232 | + { |
|
233 | + display_checkbox_matrix($current_role_permissions, $tool, $value); |
|
234 | + } |
|
235 | + if ($setting_visualisation=='image') |
|
236 | + { |
|
237 | + if ($_GET['scope']=='platform') |
|
238 | + { |
|
239 | + $roles_editable=false; |
|
240 | + } |
|
241 | + else |
|
242 | + { |
|
243 | + $roles_editable=true; |
|
244 | + } |
|
245 | + display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable); |
|
246 | + } |
|
247 | + } |
|
248 | + echo "\t\t</td>\n"; |
|
249 | + } |
|
250 | + echo "\t</tr>\n"; |
|
251 | + } |
|
252 | 252 | |
253 | - echo "</table>\n"; |
|
254 | - if ($setting_visualisation=='checkbox') |
|
255 | - { |
|
256 | - echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
257 | - } |
|
258 | - echo "</form>"; |
|
253 | + echo "</table>\n"; |
|
254 | + if ($setting_visualisation=='checkbox') |
|
255 | + { |
|
256 | + echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
257 | + } |
|
258 | + echo "</form>"; |
|
259 | 259 | } |
260 | 260 | Display::display_footer(); |
261 | 261 | \ No newline at end of file |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | { |
21 | 21 | if (!empty($_POST['role_name'])) |
22 | 22 | { |
23 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
24 | - $sql="INSERT INTO $table_role (role_name, role_comment, default_role) |
|
23 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
24 | + $sql = "INSERT INTO $table_role (role_name, role_comment, default_role) |
|
25 | 25 | VALUES ('".Database::escape_string($_POST['role_name'])."','".Database::escape_string($_POST['role_comment'])."','".Database::escape_string($_POST['default_role'])."')"; |
26 | - $result=Database::query($sql); |
|
27 | - $role_id=Database::insert_id(); |
|
28 | - $result_message=store_permissions('role', $role_id); |
|
26 | + $result = Database::query($sql); |
|
27 | + $role_id = Database::insert_id(); |
|
28 | + $result_message = store_permissions('role', $role_id); |
|
29 | 29 | } |
30 | 30 | else |
31 | 31 | { |
32 | - $result_message=get_lang('ErrorPleaseGiveRoleName'); |
|
32 | + $result_message = get_lang('ErrorPleaseGiveRoleName'); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | // storing a permission for a given role when the image approach is used |
36 | 36 | if (isset($_GET['action']) AND isset($_GET['permission']) AND isset($_GET['tool'])) |
37 | 37 | { |
38 | - if ($_GET['action']=='grant' OR $_GET['action']=='revoke') |
|
38 | + if ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke') |
|
39 | 39 | { |
40 | - $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
40 | + $result_message = store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | // deleting a role |
45 | -if (isset($_GET['action']) AND isset($_GET['role_id']) AND $_GET['action']=='delete') { |
|
45 | +if (isset($_GET['action']) AND isset($_GET['role_id']) AND $_GET['action'] == 'delete') { |
|
46 | 46 | //deleting the assignments fo this role: users |
47 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
48 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | - $result=Database::query($sql); |
|
47 | + $table = Database::get_course_table(TABLE_ROLE_USER); |
|
48 | + $sql = "DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | + $result = Database::query($sql); |
|
50 | 50 | |
51 | 51 | // deleting the assignments of this role: groups |
52 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | - $result=Database::query($sql); |
|
52 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | + $sql = "DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | + $result = Database::query($sql); |
|
55 | 55 | |
56 | 56 | // deleting the permissions of this role |
57 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | - $result=Database::query($sql); |
|
57 | + $table = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | + $sql = "DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | + $result = Database::query($sql); |
|
60 | 60 | |
61 | 61 | // deleting the role |
62 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
63 | - $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | - $result=Database::query($sql); |
|
65 | - $result_message=get_lang('RoleDeleted'); |
|
62 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
63 | + $sql = "DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | + $result = Database::query($sql); |
|
65 | + $result_message = get_lang('RoleDeleted'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // displaying the return message of the actions |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // ADDING A NEW ROLE (FORM AND LINK) |
74 | 74 | echo '<img src="../img/add.png" /> <a href="roles.php?action=add">'.get_lang('AddRole').'</a>'; |
75 | 75 | |
76 | -if ($_GET['action']=='add') |
|
76 | +if ($_GET['action'] == 'add') |
|
77 | 77 | { |
78 | 78 | echo "<form method=\"post\" action=\"".api_get_self()."\">"; |
79 | 79 | echo "\n<table>"; |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | echo "<table class=\"data_table\">\n"; |
106 | 106 | |
107 | 107 | // the header |
108 | - if (api_get_setting('permissions')=='limited') |
|
108 | + if (api_get_setting('permissions') == 'limited') |
|
109 | 109 | { |
110 | - $header_array=$rights_limited; |
|
110 | + $header_array = $rights_limited; |
|
111 | 111 | } |
112 | - if (api_get_setting('permissions')=='full') |
|
112 | + if (api_get_setting('permissions') == 'full') |
|
113 | 113 | { |
114 | - $header_array=$rights_full; |
|
114 | + $header_array = $rights_full; |
|
115 | 115 | } |
116 | 116 | echo "\t<tr>\n"; |
117 | 117 | echo "\t\t<th>".get_lang('Module')."</th>\n"; |
@@ -151,25 +151,25 @@ discard block |
||
151 | 151 | // DISPLAYING THE EXISTING ROLES |
152 | 152 | // =================================================== |
153 | 153 | // platform roles |
154 | -$all_roles=get_all_roles('platform'); |
|
154 | +$all_roles = get_all_roles('platform'); |
|
155 | 155 | foreach ($all_roles as $role) |
156 | 156 | { |
157 | 157 | echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'&scope=platform">'.$role['role_name'].'</a></div>'; |
158 | 158 | echo '<div>'.$role['role_comment'].'</div><br />'; |
159 | - if ($role['role_id']==$_GET['role_id']) |
|
159 | + if ($role['role_id'] == $_GET['role_id']) |
|
160 | 160 | { |
161 | - $current_role_info=$role; |
|
161 | + $current_role_info = $role; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | // course roles |
165 | -$all_roles=get_all_roles(); |
|
165 | +$all_roles = get_all_roles(); |
|
166 | 166 | foreach ($all_roles as $role) |
167 | 167 | { |
168 | 168 | echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>'; |
169 | 169 | echo '<div>'.$role['role_comment'].'</div><br />'; |
170 | - if ($role['role_id']==$_GET['role_id']) |
|
170 | + if ($role['role_id'] == $_GET['role_id']) |
|
171 | 171 | { |
172 | - $current_role_info=$role; |
|
172 | + $current_role_info = $role; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | // =================================================== |
179 | 179 | if ($_GET['role_id']) |
180 | 180 | { |
181 | - $current_role_permissions=get_permissions('role',$_GET['role_id']); |
|
181 | + $current_role_permissions = get_permissions('role', $_GET['role_id']); |
|
182 | 182 | |
183 | 183 | // --------------------------------------------------- |
184 | 184 | // LIMITED OR FULL |
185 | 185 | // --------------------------------------------------- |
186 | - $current_role_permissions=limited_or_full($current_role_permissions); |
|
187 | - if (api_get_setting('permissions')=='limited') |
|
186 | + $current_role_permissions = limited_or_full($current_role_permissions); |
|
187 | + if (api_get_setting('permissions') == 'limited') |
|
188 | 188 | { |
189 | - $header_array=$rights_limited; |
|
189 | + $header_array = $rights_limited; |
|
190 | 190 | } |
191 | - if (api_get_setting('permissions')=='full') |
|
191 | + if (api_get_setting('permissions') == 'full') |
|
192 | 192 | { |
193 | - $header_array=$rights_full; |
|
193 | + $header_array = $rights_full; |
|
194 | 194 | } |
195 | 195 | // --------------------------------------------------- |
196 | 196 | // DISPLAYING THE MATRIX |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | // the list of the roles for the user |
201 | 201 | echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />'; |
202 | - if ($_GET['scope']=='platform') |
|
202 | + if ($_GET['scope'] == 'platform') |
|
203 | 203 | { |
204 | 204 | echo get_lang('IsPlatformRoleNotEditable').'<br />'; |
205 | 205 | } |
@@ -226,23 +226,23 @@ discard block |
||
226 | 226 | foreach ($header_array as $key=>$value) |
227 | 227 | { |
228 | 228 | echo "\t\t<td align='center'>\n"; |
229 | - if (in_array($value,$rights)) |
|
229 | + if (in_array($value, $rights)) |
|
230 | 230 | { |
231 | - if ($setting_visualisation=='checkbox') |
|
231 | + if ($setting_visualisation == 'checkbox') |
|
232 | 232 | { |
233 | 233 | display_checkbox_matrix($current_role_permissions, $tool, $value); |
234 | 234 | } |
235 | - if ($setting_visualisation=='image') |
|
235 | + if ($setting_visualisation == 'image') |
|
236 | 236 | { |
237 | - if ($_GET['scope']=='platform') |
|
237 | + if ($_GET['scope'] == 'platform') |
|
238 | 238 | { |
239 | - $roles_editable=false; |
|
239 | + $roles_editable = false; |
|
240 | 240 | } |
241 | 241 | else |
242 | 242 | { |
243 | - $roles_editable=true; |
|
243 | + $roles_editable = true; |
|
244 | 244 | } |
245 | - display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable); |
|
245 | + display_image_matrix($current_role_permissions, $tool, $value, '', '', $roles_editable); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | echo "\t\t</td>\n"; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | echo "</table>\n"; |
254 | - if ($setting_visualisation=='checkbox') |
|
254 | + if ($setting_visualisation == 'checkbox') |
|
255 | 255 | { |
256 | 256 | echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
257 | 257 | } |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | $result=Database::query($sql); |
27 | 27 | $role_id=Database::insert_id(); |
28 | 28 | $result_message=store_permissions('role', $role_id); |
29 | - } |
|
30 | - else |
|
29 | + } else |
|
31 | 30 | { |
32 | 31 | $result_message=get_lang('ErrorPleaseGiveRoleName'); |
33 | 32 | } |
@@ -122,9 +121,11 @@ discard block |
||
122 | 121 | echo "\t</tr>\n"; |
123 | 122 | |
124 | 123 | // the main area with the checkboxes or images |
125 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
124 | + foreach ($tool_rights as $tool=>$rights) { |
|
125 | + // $tool_rights contains all the possible tools and their rights |
|
126 | 126 | { |
127 | 127 | echo "\t<tr>\n"; |
128 | + } |
|
128 | 129 | echo "\t\t<td>\n"; |
129 | 130 | echo get_lang($tool); |
130 | 131 | echo "\t\t</td>\n"; |
@@ -216,9 +217,11 @@ discard block |
||
216 | 217 | echo "\t</tr>\n"; |
217 | 218 | |
218 | 219 | // the main area with the checkboxes or images |
219 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
220 | + foreach ($tool_rights as $tool=>$rights) { |
|
221 | + // $tool_rights contains all the possible tools and their rights |
|
220 | 222 | { |
221 | 223 | echo "\t<tr>\n"; |
224 | + } |
|
222 | 225 | echo "\t\t<td>\n"; |
223 | 226 | echo get_lang($tool); |
224 | 227 | echo "\t\t</td>\n"; |
@@ -237,8 +240,7 @@ discard block |
||
237 | 240 | if ($_GET['scope']=='platform') |
238 | 241 | { |
239 | 242 | $roles_editable=false; |
240 | - } |
|
241 | - else |
|
243 | + } else |
|
242 | 244 | { |
243 | 245 | $roles_editable=true; |
244 | 246 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | */ |
6 | 6 | $ip = trim($_SERVER['REMOTE_ADDR']); |
7 | 7 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
8 | - list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
9 | - $ip = trim($ip1); |
|
8 | + list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
9 | + $ip = trim($ip1); |
|
10 | 10 | } |
11 | 11 | echo htmlentities($ip); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | */ |
6 | 6 | $ip = trim($_SERVER['REMOTE_ADDR']); |
7 | 7 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
8 | - list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
8 | + list($ip1, $ip2) = preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']); |
|
9 | 9 | $ip = trim($ip1); |
10 | 10 | } |
11 | 11 | echo htmlentities($ip); |
@@ -11,32 +11,32 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class WSReport extends WS { |
13 | 13 | |
14 | - /** |
|
15 | - * Gets the time spent on the platform by a given user |
|
16 | - * |
|
17 | - * @param string User id field name |
|
18 | - * @param string User id value |
|
14 | + /** |
|
15 | + * Gets the time spent on the platform by a given user |
|
16 | + * |
|
17 | + * @param string User id field name |
|
18 | + * @param string User id value |
|
19 | 19 | * @return array Array of results |
20 | - */ |
|
21 | - public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) { |
|
22 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | - if($user_id instanceof WSError) { |
|
24 | - return $user_id; |
|
25 | - } else { |
|
20 | + */ |
|
21 | + public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) { |
|
22 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | + if($user_id instanceof WSError) { |
|
24 | + return $user_id; |
|
25 | + } else { |
|
26 | 26 | return Tracking::get_time_spent_on_the_platform($user_id); |
27 | - } |
|
28 | - } |
|
27 | + } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * Gets the time spent in a course by a given user |
32 | - * |
|
32 | + * |
|
33 | 33 | * @param string User id field name |
34 | 34 | * @param string User id value |
35 | 35 | * @param string Course id field name |
36 | 36 | * @param string Course id value |
37 | - * @return array Array of results |
|
38 | - */ |
|
39 | - public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
|
37 | + * @return array Array of results |
|
38 | + */ |
|
39 | + public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
|
40 | 40 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
41 | 41 | if($user_id instanceof WSError) { |
42 | 42 | return $user_id; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
49 | 49 | } |
50 | 50 | return Tracking::get_time_spent_on_the_course($user_id, $course_id); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Gets the time spent in a course by a given user |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | } |
129 | 129 | $lp = new learnpath($course_code, $learnpath_id, $user_id); |
130 | 130 | $return = array( |
131 | - 'progress_bar_mode' => $lp->progress_bar_mode, |
|
132 | - 'progress_db' => $lp->progress_db, |
|
131 | + 'progress_bar_mode' => $lp->progress_bar_mode, |
|
132 | + 'progress_db' => $lp->progress_db, |
|
133 | 133 | ); |
134 | 134 | return $return; |
135 | 135 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | |
192 | 192 | $lp = new learnpath($course_code, $learnpath_id, $user_id); |
193 | 193 | $return = array( |
194 | - 'min_score' => $lp->items[$learnpath_item_id]->min_score, |
|
195 | - 'max_score' => $lp->items[$learnpath_item_id]->max_score, |
|
196 | - 'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score, |
|
197 | - 'current_score' => $lp->items[$learnpath_item_id]->current_score, |
|
194 | + 'min_score' => $lp->items[$learnpath_item_id]->min_score, |
|
195 | + 'max_score' => $lp->items[$learnpath_item_id]->max_score, |
|
196 | + 'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score, |
|
197 | + 'current_score' => $lp->items[$learnpath_item_id]->current_score, |
|
198 | 198 | ); |
199 | 199 | return $return; |
200 | 200 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) { |
22 | 22 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
23 | - if($user_id instanceof WSError) { |
|
23 | + if ($user_id instanceof WSError) { |
|
24 | 24 | return $user_id; |
25 | 25 | } else { |
26 | 26 | return Tracking::get_time_spent_on_the_platform($user_id); |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
40 | 40 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
41 | - if($user_id instanceof WSError) { |
|
41 | + if ($user_id instanceof WSError) { |
|
42 | 42 | return $user_id; |
43 | 43 | } |
44 | 44 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
45 | - if($course_id instanceof WSError) { |
|
45 | + if ($course_id instanceof WSError) { |
|
46 | 46 | return $course_id; |
47 | 47 | } else { |
48 | 48 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -61,17 +61,17 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function GetTimeSpentOnCourseInSession($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
63 | 63 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
64 | - if($user_id instanceof WSError) { |
|
64 | + if ($user_id instanceof WSError) { |
|
65 | 65 | return $user_id; |
66 | 66 | } |
67 | 67 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
68 | - if($course_id instanceof WSError) { |
|
68 | + if ($course_id instanceof WSError) { |
|
69 | 69 | return $course_id; |
70 | 70 | } else { |
71 | 71 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
72 | 72 | } |
73 | 73 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
74 | - if($session_id instanceof WSError) { |
|
74 | + if ($session_id instanceof WSError) { |
|
75 | 75 | return $session_id; |
76 | 76 | } |
77 | 77 | return Tracking::get_time_spent_on_the_course($user_id, $course_id, $session_id); |
@@ -87,17 +87,17 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function GetLearnpathsByCourse($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
89 | 89 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
90 | - if($user_id instanceof WSError) { |
|
90 | + if ($user_id instanceof WSError) { |
|
91 | 91 | return $user_id; |
92 | 92 | } |
93 | 93 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
94 | - if($course_id instanceof WSError) { |
|
94 | + if ($course_id instanceof WSError) { |
|
95 | 95 | return $course_id; |
96 | 96 | } else { |
97 | 97 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
98 | 98 | } |
99 | 99 | |
100 | - $lp = new LearnpathList($user_id,$course_code); |
|
100 | + $lp = new LearnpathList($user_id, $course_code); |
|
101 | 101 | $list = $lp->list; |
102 | 102 | $return = array(); |
103 | 103 | foreach ($list as $id => $item) { |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function GetLearnpathProgress($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) { |
119 | 119 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
120 | - if($user_id instanceof WSError) { |
|
120 | + if ($user_id instanceof WSError) { |
|
121 | 121 | return $user_id; |
122 | 122 | } |
123 | 123 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
124 | - if($course_id instanceof WSError) { |
|
124 | + if ($course_id instanceof WSError) { |
|
125 | 125 | return $course_id; |
126 | 126 | } else { |
127 | 127 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function GetLearnpathHighestLessonLocation($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) { |
152 | 152 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
153 | - if($user_id instanceof WSError) { |
|
153 | + if ($user_id instanceof WSError) { |
|
154 | 154 | return $user_id; |
155 | 155 | } |
156 | 156 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
157 | - if($course_id instanceof WSError) { |
|
157 | + if ($course_id instanceof WSError) { |
|
158 | 158 | return $course_id; |
159 | 159 | } else { |
160 | 160 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function GetLearnpathScoreSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id, $learnpath_item_id) { |
181 | 181 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
182 | - if($user_id instanceof WSError) { |
|
182 | + if ($user_id instanceof WSError) { |
|
183 | 183 | return $user_id; |
184 | 184 | } |
185 | 185 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
186 | - if($course_id instanceof WSError) { |
|
186 | + if ($course_id instanceof WSError) { |
|
187 | 187 | return $course_id; |
188 | 188 | } else { |
189 | 189 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id, $learnpath_item_id) { |
215 | 215 | $verifKey = $this->verifyKey($secret_key); |
216 | - if($verifKey instanceof WSError) { |
|
216 | + if ($verifKey instanceof WSError) { |
|
217 | 217 | $this->handleError($verifKey); |
218 | 218 | } else { |
219 | 219 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
220 | - if($user_id instanceof WSError) { |
|
220 | + if ($user_id instanceof WSError) { |
|
221 | 221 | return $user_id; |
222 | 222 | } |
223 | 223 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
224 | - if($course_id instanceof WSError) { |
|
224 | + if ($course_id instanceof WSError) { |
|
225 | 225 | return $course_id; |
226 | 226 | } else { |
227 | 227 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |