Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent 9f5a91ca74
commit 5d14ff7d33
  1. 38
      main/permissions/all_permissions.inc.php
  2. 1
      main/permissions/blog_permissions.inc.php
  3. 39
      main/permissions/group_permissions.inc.php
  4. 189
      main/permissions/permissions_functions.inc.php
  5. 76
      main/permissions/roles.php
  6. 82
      main/permissions/user_permissions.inc.php

@ -6,19 +6,37 @@
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @package chamilo.permissions
*/
/**
* Code
*/
// possible permissions
$rights_full=array("View","Add","Edit","Delete","Visibility","Move");
$rights_limited=array("Add","Edit","Delete");
$rights_full = array("View", "Add", "Edit", "Delete", "Visibility", "Move");
$rights_limited = array("Add", "Edit", "Delete");
// first we determine what can be done in each tool. We do this for each tool.
$tool_rights[TOOL_LINK]=array("View","Add","Edit","Delete","Visibility", "Move");
$tool_rights[TOOL_DOCUMENT]=array("View","Add","Edit","Delete","Visibility","Move");
$tool_rights[TOOL_LINK] = array(
"View",
"Add",
"Edit",
"Delete",
"Visibility",
"Move",
);
$tool_rights[TOOL_DOCUMENT] = array(
"View",
"Add",
"Edit",
"Delete",
"Visibility",
"Move",
);
//$tool_rights[TOOL_CALENDAR_EVENT]=array("View","Add","Edit","Delete","Visibility");
$tool_rights[TOOL_ANNOUNCEMENT]=array("View","Add","Edit","Delete","Visibility", "Move");
$tool_rights[TOOL_ANNOUNCEMENT] = array(
"View",
"Add",
"Edit",
"Delete",
"Visibility",
"Move",
);
//$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Edit","Delete","Visibility");
//$tool_rights[TOOL_COURSE_DESCRIPTION]=array("View","Add","Edit","Delete","Visibility");
//$tool_rights[TOOL_LEARNPATH]=array("View","Add","Edit","Delete","Visibility");
@ -26,10 +44,10 @@ $tool_rights[TOOL_ANNOUNCEMENT]=array("View","Add","Edit","Delete","Visibility",
//$tool_rights[TOOL_BB_POST]=array("View","Add","Edit","Delete");
//$tool_rights[TOOL_DROPBOX]=array("View","Add","Delete");
//$tool_rights[TOOL_QUIZ]=array("View","Add","Edit","Delete","Visibility");
$tool_rights[TOOL_USER]=array("View","Add","Edit","Delete");
$tool_rights[TOOL_USER] = array("View", "Add", "Edit", "Delete");
//$tool_rights[TOOL_GROUP]=array("View","Add","Edit","Delete");
//$tool_rights[TOOL_CHAT]=array("View","Delete");
//$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Add","Edit","Delete");
// this value can be checkbox or image
$setting_visualisation='image';
$setting_visualisation = 'image';

@ -166,7 +166,6 @@ foreach ($blog_users as $user_id => $user_name) { // $blog_users contains all th
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(

@ -2,17 +2,13 @@
/**
* @package chamilo.permissions
*/
/**
* Code
*/
include_once('permissions_functions.inc.php');
include_once('all_permissions.inc.php');
$group_id = api_get_group_id();
echo $group_id;
// ---------------------------------------------------
// ACTIONS
// ---------------------------------------------------
if ($_POST['StoreGroupPermissions'] and $setting_visualisation == 'checkbox') {
$result_message = store_permissions('group', $group_id);
if ($result_message) {
@ -32,23 +28,17 @@ 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);
// @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);
// ---------------------------------------------------
// 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') {
@ -59,9 +49,7 @@ if (api_get_setting('permissions') == 'full') {
}
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 />';
@ -71,11 +59,7 @@ if (api_get_setting('group_roles') == 'true') {
echo '<br />';
}
// ---------------------------------------------------
// DISPLAYING THE MATRIX (group permissions)
// ---------------------------------------------------
echo "<table class=\"data_table\">\n";
// the header
@ -99,12 +83,23 @@ foreach ($tool_rights as $tool => $rights) // $tool_rights contains all the poss
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);
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);
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
@ -122,12 +117,8 @@ if ($setting_visualisation == 'checkbox') {
}
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 />';
?>

@ -1,43 +1,40 @@
<?php
/**
* This files contains the common functions for the permissions
*
* A list of all the functions (in no particular order)
* ----------------------------------------------------
* store_permissions($content,$id)
* get_permissions($content,$id)
* limited_or_full($current_permissions)
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* This files contains the common functions for the permissions
*
* A list of all the functions (in no particular order)
* ----------------------------------------------------
* store_permissions($content,$id)
* get_permissions($content,$id)
* limited_or_full($current_permissions)
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @package chamilo.permissions
*/
*/
/**
* This function stores the permissions in the correct table.
* Since Checkboxes are used we do not know which ones are unchecked.
* That's why we first delete them all (for the given user/group/role
* and afterwards we store the checked ones only.
* @param $content are we storing rights for a user, a group or a role (the database depends on it)
* @param $id the id of the user, group or role
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function store_permissions($content, $id) {
* This function stores the permissions in the correct table.
* Since Checkboxes are used we do not know which ones are unchecked.
* That's why we first delete them all (for the given user/group/role
* and afterwards we store the checked ones only.
* @param $content are we storing rights for a user, a group or a role (the database depends on it)
* @param $id the id of the user, group or role
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function store_permissions($content, $id)
{
$course_id = api_get_course_int_id();
// Which database are we using (depending on the $content parameter)
if ($content == 'user')
{
if ($content == 'user') {
$table = Database::get_course_table(TABLE_PERMISSION_USER);
$id_field = user_id;
}
if ($content == 'group')
{
if ($content == 'group') {
$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
$id_field = group_id;
}
if ($content == 'role')
{
if ($content == 'role') {
$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
$id_field = role_id;
}
@ -47,15 +44,14 @@ function store_permissions($content, $id) {
$result = Database::query($sql);
// looping through the post values to find the permission (containing the string permission* )
foreach ($_POST as $key => $value)
{
if (strstr($key, "permission*"))
{
foreach ($_POST as $key => $value) {
if (strstr($key, "permission*")) {
list($brol, $tool, $action) = explode("*", $key);
$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)."')";
$result = Database::query($sql);
}
}
return get_lang('PermissionsStored');
}
@ -69,7 +65,8 @@ function store_permissions($content, $id) {
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function store_one_permission($content, $action, $id, $tool, $permission) {
function store_one_permission($content, $action, $id, $tool, $permission)
{
global $rights_full;
$course_id = api_get_course_int_id();
// for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
@ -86,13 +83,11 @@ function store_one_permission($content, $action, $id, $tool, $permission) {
$table = Database::get_course_table(TABLE_PERMISSION_USER);
$id_field = user_id;
}
if ($content == 'group')
{
if ($content == 'group') {
$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
$id_field = group_id;
}
if ($content == 'role')
{
if ($content == 'role') {
$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
$id_field = role_id;
}
@ -105,14 +100,14 @@ function store_one_permission($content, $action, $id, $tool, $permission) {
$result_message = get_lang('PermissionGranted');
}
}
if ($action == 'revoke')
{
if ($action == 'revoke') {
$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)."'";
$result = Database::query($sql);
if ($result) {
$result_message = get_lang('PermissionRevoked');
}
}
return $result_message;
}
@ -123,34 +118,26 @@ function store_one_permission($content, $action, $id, $tool, $permission) {
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function get_permissions($content, $id) {
function get_permissions($content, $id)
{
$course_id = api_get_course_int_id();
$currentpermissions = array();
// Which database are we using (depending on the $content parameter)
$course_id_condition = " c_id = $course_id AND ";
if ($content == 'user')
{
if ($content == 'user') {
$table = Database::get_course_table(TABLE_PERMISSION_USER);
$id_field = 'user_id';
}
elseif ($content == 'group')
{
} elseif ($content == 'group') {
$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
$id_field = 'group_id';
}
elseif ($content == 'role')
{
} elseif ($content == 'role') {
$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
$id_field = 'role_id';
}
elseif ($content == 'platform_role')
{
} elseif ($content == 'platform_role') {
$table = Database::get_main_table(TABLE_ROLE_PERMISSION);
$id_field = 'role_id';
$course_id_condition = '';
}
elseif ($content == 'task')
{
} elseif ($content == 'task') {
$table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
$id_field = 'task_id';
}
@ -162,8 +149,9 @@ function get_permissions($content, $id) {
WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'";
$result = Database::query($sql);
while ($row = Database::fetch_array($result))
while ($row = Database::fetch_array($result)) {
$currentpermissions[$row['tool']][] = $row['action'];
}
return $currentpermissions;
}
@ -179,22 +167,16 @@ function get_permissions($content, $id) {
*/
function limited_or_full($current_permissions)
{
if (api_get_setting('permissions') == 'limited')
{
foreach ($current_permissions as $tool=>$tool_rights)
{
if (api_get_setting('permissions') == 'limited') {
foreach ($current_permissions as $tool => $tool_rights) {
// we loop through the possible permissions of a tool and unset the entry if it is view
// if it is visibility or move we have to grant the edit right
foreach ($tool_rights as $key=>$value)
{
if ($value == 'View')
{
foreach ($tool_rights as $key => $value) {
if ($value == 'View') {
unset($current_permissions[$tool][$key]);
}
if ($value == 'Visibility' OR $value == 'Move')
{
if (!in_array('Edit', $current_permissions[$tool]))
{
if ($value == 'Visibility' OR $value == 'Move') {
if (!in_array('Edit', $current_permissions[$tool])) {
$current_permissions[$tool][] = 'Edit';
}
unset($current_permissions[$tool][$key]);
@ -207,8 +189,7 @@ function limited_or_full($current_permissions)
}
return $current_permissions;
}
if (api_get_setting('permissions') == 'full')
{
if (api_get_setting('permissions') == 'full') {
return $current_permissions;
}
}
@ -277,15 +258,13 @@ function display_image_matrix($permission_array, $tool, $permission, $inherited_
{
$url = api_get_self();
$urlparameters = '';
foreach ($_GET as $key=>$value)
{
foreach ($_GET as $key => $value) {
$parameter[$key] = $value;
}
$parameter['action'] = 'grant';
$parameter['permission'] = $permission;
$parameter['tool'] = $tool;
foreach ($parameter as $key=>$value)
{
foreach ($parameter as $key => $value) {
$urlparameters .= $key.'='.$value.'&amp;';
}
$url = $url.'?'.$urlparameters;
@ -317,23 +296,14 @@ function display_image_matrix($permission_array, $tool, $permission, $inherited_
*/
function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true)
{
if ($course_admin)
{
if ($course_admin) {
echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
}
else
{
if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool]))
{
} else {
if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool])) {
echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
}
else
{
if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool]))
{
if ($editable)
{
} else {
if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) {
if ($editable) {
$url = api_get_self();
$urlparameters = '';
foreach ($_GET as $key => $value)
@ -361,7 +331,7 @@ function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $per
if ($editable) {
$url = api_get_self();
$urlparameters = '';
foreach ($_GET as $key=>$value) {
foreach ($_GET as $key => $value) {
$parameter[$key] = $value;
}
$parameter['action'] = 'manage_rights';
@ -402,26 +372,20 @@ function display_role_list($current_course_roles, $current_platform_roles)
// course roles
$sql = "SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
$result = Database::query($sql);
while ($row = Database::fetch_array($result))
{
if (in_array($row['role_id'], $current_course_roles))
{
while ($row = Database::fetch_array($result)) {
if (in_array($row['role_id'], $current_course_roles)) {
$checked = 'checked';
$image = 'checkbox_on2.gif';
$action = 'revoke';
}
else
{
} else {
$checked = '';
$image = 'wrong.gif';
$action = 'grant';
}
if ($setting_visualisation == 'checkbox')
{
if ($setting_visualisation == 'checkbox') {
echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
}
if ($setting_visualisation == 'image')
{
if ($setting_visualisation == 'image') {
echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
}
@ -440,7 +404,8 @@ function display_role_list($current_course_roles, $current_platform_roles)
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function get_roles($content, $id, $scope = 'course') {
function get_roles($content, $id, $scope = 'course')
{
$course_id = api_get_course_int_id();
if ($content == 'user') {
$table = Database::get_course_table(TABLE_ROLE_USER);
@ -493,7 +458,6 @@ function get_all_roles($content = 'course') {
return $roles;
}
/**
* This function gets all the roles that are defined
* @param $content are we finding the roles for a user or a group (the database depends on it)
@ -504,7 +468,8 @@ function get_all_roles($content = 'course') {
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @version 1.0
*/
function get_roles_permissions($content, $id, $scope = 'course') {
function get_roles_permissions($content, $id, $scope = 'course')
{
$course_id = api_get_course_int_id();
if ($content == 'user') {
$table = Database::get_course_table(TABLE_ROLE_USER);
@ -531,8 +496,6 @@ function get_roles_permissions($content, $id, $scope = 'course') {
$role_condition = '';
}
$current_roles = array();
$sql = "
SELECT *
FROM
@ -563,8 +526,8 @@ function get_roles_permissions($content, $id, $scope = 'course') {
* @param $role_id the id of the role we are giving to a user or a group.
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
*/
function assign_role($content, $action, $id, $role_id, $scope = 'course') {
function assign_role($content, $action, $id, $role_id, $scope = 'course')
{
$course_id = api_get_course_int_id();
// Which database are we using (depending on the $content parameter)
if ($content == 'user') {
@ -598,26 +561,24 @@ function assign_role($content, $action, $id, $role_id, $scope = 'course') {
/**
* This function merges permission arrays. Each permission array has the following structure
* a permission array has a tool contanst as a key and an array as a value. This value array consists of all the permissions that are granted in that tool.
*/
* This function merges permission arrays. Each permission array has the
* following structure
* a permission array has a tool contanst as a key and an array as a value.
* This value array consists of all the permissions that are granted in that tool.
*/
function permission_array_merge($array1, $array2)
{
foreach ($array2 as $tool=>$permissions)
{
foreach ($permissions as $permissionkey=>$permissionvalue)
{
foreach ($array2 as $tool => $permissions) {
foreach ($permissions as $permissionkey => $permissionvalue) {
$array1[$tool][] = $permissionvalue;
}
}
return $array1;
}
function my_print_r($array)
{
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>

@ -2,9 +2,7 @@
/**
* @package chamilo.permissions
*/
/**
* Code
*/
require '../inc/global.inc.php';
require_once 'permissions_functions.inc.php';
require_once 'all_permissions.inc.php';
@ -105,18 +103,15 @@ if ($_GET['action'] == 'add')
echo "<table class=\"data_table\">\n";
// the header
if (api_get_setting('permissions') == 'limited')
{
if (api_get_setting('permissions') == 'limited') {
$header_array = $rights_limited;
}
if (api_get_setting('permissions') == 'full')
{
if (api_get_setting('permissions') == 'full') {
$header_array = $rights_full;
}
echo "\t<tr>\n";
echo "\t\t<th>".get_lang('Module')."</th>\n";
foreach ($header_array as $header_key=>$header_value)
{
foreach ($header_array as $header_key => $header_value) {
echo "\t\t<th>".get_lang($header_value)."</th>\n";
}
echo "\t</tr>\n";
@ -129,8 +124,7 @@ if ($_GET['action'] == 'add')
echo get_lang($tool);
echo "\t\t</td>\n";
foreach ($header_array as $key=>$value)
{
foreach ($header_array as $key => $value) {
echo "\t\t<td align='center'>\n";
display_checkbox_matrix(array(), $tool, $value);
echo "\t\t</td>\n";
@ -139,17 +133,11 @@ if ($_GET['action'] == 'add')
}
echo "</table>\n";
echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
echo "</form>";
}
// ===================================================
// DISPLAYING THE EXISTING ROLES
// ===================================================
// platform roles
$all_roles = get_all_roles('platform');
foreach ($all_roles as $role)
@ -163,8 +151,7 @@ foreach ($all_roles as $role)
}
// course roles
$all_roles = get_all_roles();
foreach ($all_roles as $role)
{
foreach ($all_roles as $role) {
echo '<div><a href="roles.php?action=view&amp;role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&amp;role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>';
echo '<div>'.$role['role_comment'].'</div><br />';
if ($role['role_id'] == $_GET['role_id'])
@ -173,16 +160,10 @@ foreach ($all_roles as $role)
}
}
// ===================================================
// DISPLAYING THE PERMISSIONS OF A GIVEN ROLE
// ===================================================
if ($_GET['role_id'])
{
if ($_GET['role_id']) {
$current_role_permissions = get_permissions('role', $_GET['role_id']);
// ---------------------------------------------------
// LIMITED OR FULL
// ---------------------------------------------------
$current_role_permissions = limited_or_full($current_role_permissions);
if (api_get_setting('permissions') == 'limited')
{
@ -209,8 +190,7 @@ if ($_GET['role_id'])
// the header
echo "\t<tr>\n";
echo "\t\t<th>".get_lang('Module')."</th>\n";
foreach ($header_array as $header_key=>$header_value)
{
foreach ($header_array as $header_key => $header_value) {
echo "\t\t<th>".get_lang($header_value)."</th>\n";
}
echo "\t</tr>\n";
@ -223,26 +203,30 @@ if ($_GET['role_id'])
echo get_lang($tool);
echo "\t\t</td>\n";
foreach ($header_array as $key=>$value)
{
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_role_permissions, $tool, $value);
}
if ($setting_visualisation == 'image')
{
if ($_GET['scope'] == 'platform')
{
if (in_array($value, $rights)) {
if ($setting_visualisation == 'checkbox') {
display_checkbox_matrix(
$current_role_permissions,
$tool,
$value
);
}
if ($setting_visualisation == 'image') {
if ($_GET['scope'] == 'platform') {
$roles_editable = false;
}
else
{
} else {
$roles_editable = true;
}
display_image_matrix($current_role_permissions, $tool, $value, '', '', $roles_editable);
display_image_matrix(
$current_role_permissions,
$tool,
$value,
'',
'',
$roles_editable
);
}
}
echo "\t\t</td>\n";
@ -251,10 +235,10 @@ if ($_GET['role_id'])
}
echo "</table>\n";
if ($setting_visualisation == 'checkbox')
{
if ($setting_visualisation == 'checkbox') {
echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
}
echo "</form>";
}
Display::display_footer();

@ -2,31 +2,23 @@
/**
* @package chamilo.permissions
*/
/**
* Code
*/
$user_id=$userIdViewed;
if ($mainUserInfo['status']==1)
{
$course_admin=1;
$user_id = $userIdViewed;
if ($mainUserInfo['status'] == 1) {
$course_admin = 1;
}
include_once('permissions_functions.inc.php');
include_once('all_permissions.inc.php');
include_once (api_get_library_path()."/groupmanager.lib.php");
include_once (api_get_library_path()."/blog.lib.php");
// ---------------------------------------------------
// ACTIONS
// ---------------------------------------------------
if ($_POST['StoreUserPermissions'] and $setting_visualisation=='checkbox')
{
$result_message=store_permissions('user', $user_id);
if ($result_message)
{
if ($_POST['StoreUserPermissions'] and $setting_visualisation == 'checkbox') {
$result_message = store_permissions('user', $user_id);
if ($result_message) {
Display::display_normal_message($result_message);
}
}
if (isset($_GET['action']))
{
if (isset($_GET['action'])) {
if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
{
$result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']);
@ -36,8 +28,8 @@ if (isset($_GET['action']))
$result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']);
}
}
if (isset($result_message))
{
if (isset($result_message)) {
Display::display_normal_message($result_message);
}
@ -94,9 +86,7 @@ if (api_get_setting('group_roles')=='true')
}
}
// ---------------------------------------------------
// LIMITED OR FULL
// ---------------------------------------------------
$current_user_permissions=limited_or_full($current_user_permissions);
$inherited_permissions=limited_or_full($inherited_permissions);
if (api_get_setting('permissions')=='limited')
@ -108,12 +98,9 @@ if (api_get_setting('permissions')=='full')
$header_array=$rights_full;
}
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
@ -140,39 +127,43 @@ foreach ($header_array as $header_key=>$header_value)
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
{
// $tool_rights contains all the possible tools and their rights
foreach ($tool_rights as $tool => $rights) {
echo "\t<tr>\n";
echo "\t\t<td>\n";
if (strstr($tool,'BLOG'))
{
if (strstr($tool, 'BLOG')) {
// Not dealing with a real tool here, get name of this blog
// Strip blog id
$tmp = strpos($tool,'_')+1;
$blog_id = substr($tool,$tmp,strlen($tool));
// Get title
echo get_lang('Blog').": ".Blog::getBlogTitle($blog_id);
}
else
{
} else {
echo get_lang($tool);
}
echo "\t\t</td>\n";
foreach ($header_array as $key=>$value)
{
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_user_permissions, $tool, $value, $inherited_permissions,$course_admin);
if (in_array($value, $rights)) {
if ($setting_visualisation == 'checkbox') {
display_checkbox_matrix(
$current_user_permissions,
$tool,
$value,
$inherited_permissions,
$course_admin
);
}
if ($setting_visualisation=='image')
{
display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin);
if ($setting_visualisation == 'image') {
display_image_matrix(
$current_user_permissions,
$tool,
$value,
$inherited_permissions,
$course_admin
);
}
}
// note: in a later stage this part will be replaced by a function
@ -185,18 +176,13 @@ foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possib
}
echo "</table>\n";
if ($setting_visualisation=='checkbox')
{
if ($setting_visualisation=='checkbox') {
echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">";
}
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 />';
?>

Loading…
Cancel
Save