Minor - Code style

pull/2487/head
Yannick Warnier 9 years ago
parent 1fcaacc439
commit c6af145c07
  1. 175
      main/permissions/blog_permissions.inc.php
  2. 150
      main/permissions/group_permissions.inc.php

@ -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('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
echo "<form method=\"post\" action=\"" . str_replace('&', '&amp;', $_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 />';

@ -13,71 +13,62 @@ echo $group_id;
// ---------------------------------------------------
// ACTIONS
// ---------------------------------------------------
if ($_POST['StoreGroupPermissions'] and $setting_visualisation=='checkbox')
{
$result_message=store_permissions('group', $group_id);
if ($result_message)
{
Display::display_normal_message($result_message);
}
if ($_POST['StoreGroupPermissions'] and $setting_visualisation == 'checkbox') {
$result_message = store_permissions('group', $group_id);
if ($result_message) {
Display::display_normal_message($result_message);
}
}
if (isset($_GET['action']))
{
if (($_GET['action']=='grant' OR $_GET['action']=='revoke') AND isset($_GET['permission']) AND isset($_GET['tool']))
{
$result_message=store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']);
}
if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
{
$result_message=assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']);
echo 'hier';
}
if (isset($_GET['action'])) {
if (($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke') AND isset($_GET['permission']) AND isset($_GET['tool'])) {
$result_message = store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']);
}
if (isset($_GET['role']) AND ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke')) {
$result_message = assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']);
echo 'hier';
}
}
if (isset($result_message))
{
Display::display_normal_message($result_message);
if (isset($result_message)) {
Display::display_normal_message($result_message);
}
// ---------------------------------------------------
// RETRIEVING THE PERMISSIONS
// ---------------------------------------------------
$current_group_permissions=array();
$current_group_permissions=get_permissions('group',$group_id);
$current_group_permissions = array();
$current_group_permissions = get_permissions('group', $group_id);
// @todo current group permissions and current role permissions
// ---------------------------------------------------
// INHERITED PERMISSIONS (group roles)
// ---------------------------------------------------
$group_course_roles_permissions=get_roles_permissions('group',$group_id, 'course');
$group_platform_roles_permissions=get_roles_permissions('group',$group_id, 'platform');
$inherited_permissions=permission_array_merge($group_course_roles_permissions,$group_platform_roles_permissions);
$group_course_roles_permissions = get_roles_permissions('group', $group_id, 'course');
$group_platform_roles_permissions = get_roles_permissions('group', $group_id, 'platform');
$inherited_permissions = permission_array_merge($group_course_roles_permissions, $group_platform_roles_permissions);
// ---------------------------------------------------
// LIMITED OR FULL
// ---------------------------------------------------
$current_group_permissions=limited_or_full($current_group_permissions);
$inherited_permissions=limited_or_full($inherited_permissions);
if (api_get_setting('permissions')=='limited')
{
$header_array=$rights_limited;
$current_group_permissions = limited_or_full($current_group_permissions);
$inherited_permissions = limited_or_full($inherited_permissions);
if (api_get_setting('permissions') == 'limited') {
$header_array = $rights_limited;
}
if (api_get_setting('permissions')=='full')
{
$header_array=$rights_full;
if (api_get_setting('permissions') == 'full') {
$header_array = $rights_full;
}
echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
echo "<form method=\"post\" action=\"" . str_replace('&', '&amp;', $_SERVER['REQUEST_URI']) . "\">";
// ---------------------------------------------------
// DISPLAYING THE ROLES LIST
// ---------------------------------------------------
if (api_get_setting('group_roles')=='true')
{
// the list of the roles for the user
echo '<strong>'.get_lang('GroupRoles').'</strong><br />';
$current_group_course_roles=get_roles('group',$group_id);
$current_group_platform_roles=get_roles('group',$group_id, 'platform');
display_role_list($current_group_course_roles, $current_group_platform_roles);
echo '<br />';
if (api_get_setting('group_roles') == 'true') {
// the list of the roles for the user
echo '<strong>' . get_lang('GroupRoles') . '</strong><br />';
$current_group_course_roles = get_roles('group', $group_id);
$current_group_platform_roles = get_roles('group', $group_id, 'platform');
display_role_list($current_group_course_roles, $current_group_platform_roles);
echo '<br />';
}
@ -89,59 +80,54 @@ echo "<table class=\"data_table\">\n";
// the header
echo "\t<tr>\n";
echo "\t\t<th>".get_lang('Module')."</th>\n";
foreach ($header_array as $header_key=>$header_value)
{
echo "\t\t<th>".get_lang($header_value)."</th>\n";
echo "\t\t<th>" . get_lang('Module') . "</th>\n";
foreach ($header_array as $header_key => $header_value) {
echo "\t\t<th>" . get_lang($header_value) . "</th>\n";
}
echo "\t</tr>\n";
// the main area with the checkboxes or images
foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
foreach ($tool_rights as $tool => $rights) // $tool_rights contains all the possible tools and their rights
{
echo "\t<tr>\n";
echo "\t\t<td>\n";
echo get_lang($tool);
echo "\t\t</td>\n";
echo "\t<tr>\n";
echo "\t\t<td>\n";
echo get_lang($tool);
echo "\t\t</td>\n";
foreach ($header_array as $key=>$value)
{
echo "\t\t<td align='center'>\n";
if (in_array($value,$rights))
{
if ($setting_visualisation=='checkbox')
{
//display_checkbox_matrix($current_group_permissions, $tool, $value);
display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,$course_admin);
}
if ($setting_visualisation=='image')
{
//display_image_matrix($current_group_permissions, $tool, $value);
display_image_matrix($current_group_permissions, $tool, $value,$inherited_permissions, $course_admin);
}
}
// 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";
foreach ($header_array as $key => $value) {
echo "\t\t<td align='center'>\n";
if (in_array($value, $rights)) {
if ($setting_visualisation == 'checkbox') {
//display_checkbox_matrix($current_group_permissions, $tool, $value);
display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,
$course_admin);
}
if ($setting_visualisation == 'image') {
//display_image_matrix($current_group_permissions, $tool, $value);
display_image_matrix($current_group_permissions, $tool, $value, $inherited_permissions, $course_admin);
}
}
// 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";
if ($setting_visualisation=='checkbox')
{
echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">";
if ($setting_visualisation == 'checkbox') {
echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"" . get_lang('StorePermissions') . "\">";
}
echo "</form>";
// ---------------------------------------------------
// 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 />';
?>

Loading…
Cancel
Save