|
|
|
|
@ -1,11 +1,11 @@ |
|
|
|
|
<?php |
|
|
|
|
/** |
|
|
|
|
* smartBlogs add-on: it must be possible to change rights for every single blog |
|
|
|
|
* in a course. |
|
|
|
|
* |
|
|
|
|
* @author Toon Keppens |
|
|
|
|
* @package chamilo.permissions |
|
|
|
|
*/ |
|
|
|
|
* smartBlogs add-on: it must be possible to change rights for every single blog |
|
|
|
|
* in a course. |
|
|
|
|
* |
|
|
|
|
* @author Toon Keppens |
|
|
|
|
* @package chamilo.permissions |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Init |
|
|
|
|
*/ |
|
|
|
|
@ -43,13 +43,13 @@ $course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
// Remove the blog creater because he has all the rights automatically |
|
|
|
|
// and we want to keep it that way. |
|
|
|
|
$tbl_course_rel_user = $table=Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
|
$tbl_course_rel_user = $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
|
$sql = "SELECT user_id |
|
|
|
|
FROM $tbl_course_rel_user |
|
|
|
|
WHERE status = '1' AND c_id = '".api_get_course_int_id()."'"; |
|
|
|
|
WHERE status = '1' AND c_id = '" . api_get_course_int_id() . "'"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
while ($user = Database::fetch_assoc($result)) { |
|
|
|
|
unset($blog_users[$user['user_id']]); |
|
|
|
|
unset($blog_users[$user['user_id']]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//$user_id=$userIdViewed; |
|
|
|
|
@ -83,47 +83,46 @@ if (isset($_GET['do'])) { |
|
|
|
|
// ------------------------------------------------------------------ |
|
|
|
|
// RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER |
|
|
|
|
// ------------------------------------------------------------------ |
|
|
|
|
if (api_get_setting('user_roles')=='true') { |
|
|
|
|
// course roles that are assigned to the user |
|
|
|
|
$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
|
|
|
$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
|
|
|
// NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
|
|
|
// (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
|
|
|
// groepsge<EFBFBD>rfde permissions in beschouwing worden genomen |
|
|
|
|
// dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
|
|
|
// en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
|
|
|
// omvatten. |
|
|
|
|
// NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
|
|
|
// ophalen. |
|
|
|
|
// platform roles that are assigned to the user |
|
|
|
|
$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform'); |
|
|
|
|
$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user); |
|
|
|
|
if (api_get_setting('user_roles') == 'true') { |
|
|
|
|
// course roles that are assigned to the user |
|
|
|
|
$current_user_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
|
|
|
$inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
|
|
|
// NOTE: deze array moet nog gemerged worden met de $inherited_permissions array |
|
|
|
|
// (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de |
|
|
|
|
// groepsge<EFBFBD>rfde permissions in beschouwing worden genomen |
|
|
|
|
// dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker |
|
|
|
|
// en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker |
|
|
|
|
// omvatten. |
|
|
|
|
// NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal |
|
|
|
|
// ophalen. |
|
|
|
|
// platform roles that are assigned to the user |
|
|
|
|
$current_user_role_permissions_of_user = get_roles_permissions('user', $user_id, 'platform'); |
|
|
|
|
$inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user); |
|
|
|
|
} |
|
|
|
|
// ------------------------------------------------------------------ |
|
|
|
|
// RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER |
|
|
|
|
// ------------------------------------------------------------------ |
|
|
|
|
if (api_get_setting('group_roles')=='true') { |
|
|
|
|
// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
|
|
|
foreach ($groups_of_user as $group) { |
|
|
|
|
$this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); |
|
|
|
|
//$inherited_permissions[$tool][]=$permission; |
|
|
|
|
} |
|
|
|
|
if (api_get_setting('group_roles') == 'true') { |
|
|
|
|
// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN |
|
|
|
|
foreach ($groups_of_user as $group) { |
|
|
|
|
$this_current_group_role_permissions_of_user = get_roles_permissions('user', $user_id); |
|
|
|
|
//$inherited_permissions[$tool][]=$permission; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
|
|
|
|
echo "<form method=\"post\" action=\"" . str_replace('&', '&', $_SERVER['REQUEST_URI']) . "\">"; |
|
|
|
|
|
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
// DISPLAYING THE ROLES LIST |
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
|
|
|
|
|
if (api_get_setting('user_roles')=='true') |
|
|
|
|
{ |
|
|
|
|
// the list of the roles for the user |
|
|
|
|
echo '<strong>'.get_lang('UserRoles').'</strong><br />'; |
|
|
|
|
$current_user_course_roles=get_roles('user',$user_id); |
|
|
|
|
$current_user_platform_roles=get_roles('user',$user_id, 'platform'); |
|
|
|
|
display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
|
|
|
echo '<br />'; |
|
|
|
|
if (api_get_setting('user_roles') == 'true') { |
|
|
|
|
// the list of the roles for the user |
|
|
|
|
echo '<strong>' . get_lang('UserRoles') . '</strong><br />'; |
|
|
|
|
$current_user_course_roles = get_roles('user', $user_id); |
|
|
|
|
$current_user_platform_roles = get_roles('user', $user_id, 'platform'); |
|
|
|
|
display_role_list($current_user_course_roles, $current_user_platform_roles); |
|
|
|
|
echo '<br />'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
@ -133,66 +132,66 @@ echo "<table class=\"data_table\">\n"; |
|
|
|
|
|
|
|
|
|
// the header |
|
|
|
|
echo "\t<tr>\n"; |
|
|
|
|
echo "\t\t<th rowspan=\"2\">".get_lang('Module')."</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"4\">".get_lang('ArticleManager')."</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"3\">".get_lang('CommentManager')."</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"3\">".get_lang('BlogManager')."</th>\n"; |
|
|
|
|
echo "\t\t<th rowspan=\"2\">" . get_lang('Module') . "</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"4\">" . get_lang('ArticleManager') . "</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"3\">" . get_lang('CommentManager') . "</th>\n"; |
|
|
|
|
echo "\t\t<th colspan=\"3\">" . get_lang('BlogManager') . "</th>\n"; |
|
|
|
|
echo "\t</tr>\n"; |
|
|
|
|
|
|
|
|
|
// Subheader |
|
|
|
|
echo "\t<tr>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Edit')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Add')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Tasks')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Members')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>".get_lang('Roles')."</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Add') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Delete') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Edit') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Rate') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Add') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Delete') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Rate') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Tasks') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Members') . "</th>\n"; |
|
|
|
|
echo "\t\t<th align='center'>" . get_lang('Roles') . "</th>\n"; |
|
|
|
|
echo "\t</tr>\n"; |
|
|
|
|
|
|
|
|
|
// the main area with the checkboxes or images |
|
|
|
|
foreach ($blog_users as $user_id => $user_name) { // $blog_users contains all the users in this blog |
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
// RETRIEVING THE PERMISSIONS OF THE USER |
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
$current_user_permissions = array(); |
|
|
|
|
$current_user_permissions = get_permissions('user', $user_id); |
|
|
|
|
|
|
|
|
|
echo "\t<tr>\n"; |
|
|
|
|
echo "\t\t<td>\n"; |
|
|
|
|
echo $user_name; |
|
|
|
|
echo "\t\t</td>\n"; |
|
|
|
|
|
|
|
|
|
foreach ($rights_full as $key => $value) { |
|
|
|
|
|
|
|
|
|
echo "\t\t<td align='center'>\n"; |
|
|
|
|
if (in_array($value,$rights_blog)) { |
|
|
|
|
display_image_matrix_for_blogs( |
|
|
|
|
$current_user_permissions, |
|
|
|
|
$user_id, |
|
|
|
|
'BLOG_'.$blog_id, |
|
|
|
|
$value, |
|
|
|
|
(isset($inherited_permissions) ? $inherited_permissions : null), |
|
|
|
|
(isset($course_admin) ? $course_admin : null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
// note: in a later stage this part will be replaced by a function |
|
|
|
|
// so that we can easily switch between a checkbox approach or an image approach |
|
|
|
|
// where every click is in fact a change of status. In the checkbox approach you first have to |
|
|
|
|
// do the changes and then store them by clicking the submit button. |
|
|
|
|
echo "\t\t</td>\n"; |
|
|
|
|
} |
|
|
|
|
echo "\t</tr>\n"; |
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
// RETRIEVING THE PERMISSIONS OF THE USER |
|
|
|
|
// --------------------------------------------------- |
|
|
|
|
$current_user_permissions = array(); |
|
|
|
|
$current_user_permissions = get_permissions('user', $user_id); |
|
|
|
|
|
|
|
|
|
echo "\t<tr>\n"; |
|
|
|
|
echo "\t\t<td>\n"; |
|
|
|
|
echo $user_name; |
|
|
|
|
echo "\t\t</td>\n"; |
|
|
|
|
|
|
|
|
|
foreach ($rights_full as $key => $value) { |
|
|
|
|
|
|
|
|
|
echo "\t\t<td align='center'>\n"; |
|
|
|
|
if (in_array($value, $rights_blog)) { |
|
|
|
|
display_image_matrix_for_blogs( |
|
|
|
|
$current_user_permissions, |
|
|
|
|
$user_id, |
|
|
|
|
'BLOG_' . $blog_id, |
|
|
|
|
$value, |
|
|
|
|
(isset($inherited_permissions) ? $inherited_permissions : null), |
|
|
|
|
(isset($course_admin) ? $course_admin : null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
// note: in a later stage this part will be replaced by a function |
|
|
|
|
// so that we can easily switch between a checkbox approach or an image approach |
|
|
|
|
// where every click is in fact a change of status. In the checkbox approach you first have to |
|
|
|
|
// do the changes and then store them by clicking the submit button. |
|
|
|
|
echo "\t\t</td>\n"; |
|
|
|
|
} |
|
|
|
|
echo "\t</tr>\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "</table>\n"; |
|
|
|
|
echo "</form><br />"; |
|
|
|
|
|
|
|
|
|
// LEGEND |
|
|
|
|
echo '<strong>'.get_lang('Legend').'</strong><br />'; |
|
|
|
|
echo '<img src="../img/wrong.gif" /> '.get_lang('UserHasPermissionNot').'<br />'; |
|
|
|
|
echo '<img src="../img/checkbox_on2.gif" /> '.get_lang('UserHasPermission').'<br />'; |
|
|
|
|
echo '<img src="../img/checkbox_on3.gif" /> '.get_lang('UserHasPermissionByRoleGroup').'<br />'; |
|
|
|
|
echo '<strong>' . get_lang('Legend') . '</strong><br />'; |
|
|
|
|
echo '<img src="../img/wrong.gif" /> ' . get_lang('UserHasPermissionNot') . '<br />'; |
|
|
|
|
echo '<img src="../img/checkbox_on2.gif" /> ' . get_lang('UserHasPermission') . '<br />'; |
|
|
|
|
echo '<img src="../img/checkbox_on3.gif" /> ' . get_lang('UserHasPermissionByRoleGroup') . '<br />'; |
|
|
|
|
|