|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| -* smartBlogs add-on: it must be possible to change rights for every single blog |
4 |
| -* in a course. |
5 |
| -* |
6 |
| -* @author Toon Keppens |
7 |
| -* @package chamilo.permissions |
8 |
| -*/ |
| 3 | + * smartBlogs add-on: it must be possible to change rights for every single blog |
| 4 | + * in a course. |
| 5 | + * |
| 6 | + * @author Toon Keppens |
| 7 | + * @package chamilo.permissions |
| 8 | + */ |
9 | 9 | /**
|
10 | 10 | * Init
|
11 | 11 | */
|
|
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 |
| - WHERE status = '1' AND c_id = '".api_get_course_int_id()."'"; |
| 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;
|
|
83 | 83 | // ------------------------------------------------------------------
|
84 | 84 | // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER
|
85 | 85 | // ------------------------------------------------------------------
|
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); |
| 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); |
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') { |
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 |
| - } |
| 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 | + } |
111 | 111 | }
|
112 | 112 |
|
113 |
| -echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
| 113 | +echo "<form method=\"post\" action=\"" . str_replace('&', '&', $_SERVER['REQUEST_URI']) . "\">"; |
114 | 114 |
|
115 | 115 | // ---------------------------------------------------
|
116 | 116 | // DISPLAYING THE ROLES LIST
|
117 | 117 | // ---------------------------------------------------
|
118 | 118 |
|
119 |
| -if (api_get_setting('user_roles')=='true') |
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 />'; |
| 119 | +if (api_get_setting('user_roles') == 'true') { |
| 120 | + // the list of the roles for the user |
| 121 | + echo '<strong>' . get_lang('UserRoles') . '</strong><br />'; |
| 122 | + $current_user_course_roles = get_roles('user', $user_id); |
| 123 | + $current_user_platform_roles = get_roles('user', $user_id, 'platform'); |
| 124 | + display_role_list($current_user_course_roles, $current_user_platform_roles); |
| 125 | + echo '<br />'; |
127 | 126 | }
|
128 | 127 |
|
129 | 128 | // ---------------------------------------------------
|
|
133 | 132 |
|
134 | 133 | // the header
|
135 | 134 | 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"; |
| 135 | +echo "\t\t<th rowspan=\"2\">" . get_lang('Module') . "</th>\n"; |
| 136 | +echo "\t\t<th colspan=\"4\">" . get_lang('ArticleManager') . "</th>\n"; |
| 137 | +echo "\t\t<th colspan=\"3\">" . get_lang('CommentManager') . "</th>\n"; |
| 138 | +echo "\t\t<th colspan=\"3\">" . get_lang('BlogManager') . "</th>\n"; |
140 | 139 | echo "\t</tr>\n";
|
141 | 140 |
|
142 | 141 | // Subheader
|
143 | 142 | 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"; |
| 143 | +echo "\t\t<th align='center'>" . get_lang('Add') . "</th>\n"; |
| 144 | +echo "\t\t<th align='center'>" . get_lang('Delete') . "</th>\n"; |
| 145 | +echo "\t\t<th align='center'>" . get_lang('Edit') . "</th>\n"; |
| 146 | +echo "\t\t<th align='center'>" . get_lang('Rate') . "</th>\n"; |
| 147 | +echo "\t\t<th align='center'>" . get_lang('Add') . "</th>\n"; |
| 148 | +echo "\t\t<th align='center'>" . get_lang('Delete') . "</th>\n"; |
| 149 | +echo "\t\t<th align='center'>" . get_lang('Rate') . "</th>\n"; |
| 150 | +echo "\t\t<th align='center'>" . get_lang('Tasks') . "</th>\n"; |
| 151 | +echo "\t\t<th align='center'>" . get_lang('Members') . "</th>\n"; |
| 152 | +echo "\t\t<th align='center'>" . get_lang('Roles') . "</th>\n"; |
154 | 153 | echo "\t</tr>\n";
|
155 | 154 |
|
156 | 155 | // the main area with the checkboxes or images
|
157 | 156 | 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"; |
| 157 | + // --------------------------------------------------- |
| 158 | + // RETRIEVING THE PERMISSIONS OF THE USER |
| 159 | + // --------------------------------------------------- |
| 160 | + $current_user_permissions = array(); |
| 161 | + $current_user_permissions = get_permissions('user', $user_id); |
| 162 | + |
| 163 | + echo "\t<tr>\n"; |
| 164 | + echo "\t\t<td>\n"; |
| 165 | + echo $user_name; |
| 166 | + echo "\t\t</td>\n"; |
| 167 | + |
| 168 | + foreach ($rights_full as $key => $value) { |
| 169 | + |
| 170 | + echo "\t\t<td align='center'>\n"; |
| 171 | + if (in_array($value, $rights_blog)) { |
| 172 | + display_image_matrix_for_blogs( |
| 173 | + $current_user_permissions, |
| 174 | + $user_id, |
| 175 | + 'BLOG_' . $blog_id, |
| 176 | + $value, |
| 177 | + (isset($inherited_permissions) ? $inherited_permissions : null), |
| 178 | + (isset($course_admin) ? $course_admin : null) |
| 179 | + ); |
| 180 | + } |
| 181 | + // note: in a later stage this part will be replaced by a function |
| 182 | + // so that we can easily switch between a checkbox approach or an image approach |
| 183 | + // where every click is in fact a change of status. In the checkbox approach you first have to |
| 184 | + // do the changes and then store them by clicking the submit button. |
| 185 | + echo "\t\t</td>\n"; |
| 186 | + } |
| 187 | + echo "\t</tr>\n"; |
189 | 188 | }
|
190 | 189 |
|
191 | 190 | echo "</table>\n";
|
192 | 191 | echo "</form><br />";
|
193 | 192 |
|
194 | 193 | // LEGEND
|
195 |
| -echo '<strong>'.get_lang('Legend').'</strong><br />'; |
196 |
| -echo '<img src="../img/wrong.gif" /> '.get_lang('UserHasPermissionNot').'<br />'; |
197 |
| -echo '<img src="../img/checkbox_on2.gif" /> '.get_lang('UserHasPermission').'<br />'; |
198 |
| -echo '<img src="../img/checkbox_on3.gif" /> '.get_lang('UserHasPermissionByRoleGroup').'<br />'; |
| 194 | +echo '<strong>' . get_lang('Legend') . '</strong><br />'; |
| 195 | +echo '<img src="../img/wrong.gif" /> ' . get_lang('UserHasPermissionNot') . '<br />'; |
| 196 | +echo '<img src="../img/checkbox_on2.gif" /> ' . get_lang('UserHasPermission') . '<br />'; |
| 197 | +echo '<img src="../img/checkbox_on3.gif" /> ' . get_lang('UserHasPermissionByRoleGroup') . '<br />'; |
0 commit comments