@@ -10,82 +10,82 @@ |
||
10 | 10 | */ |
11 | 11 | class ToolIntro extends Coursecopy\Resource |
12 | 12 | { |
13 | - public $id; |
|
13 | + public $id; |
|
14 | 14 | |
15 | - /** |
|
16 | - * intro text |
|
17 | - */ |
|
18 | - public $intro_text; |
|
15 | + /** |
|
16 | + * intro text |
|
17 | + */ |
|
18 | + public $intro_text; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Create a new text introduction |
|
22 | - * @param int $id The id of this tool introduction in the Chamilo-course |
|
23 | - * @param string $intro_text |
|
24 | - */ |
|
25 | - public function __construct($id, $intro_text) |
|
26 | - { |
|
27 | - parent::__construct($id, RESOURCE_TOOL_INTRO); |
|
28 | - $this->id = $id; |
|
29 | - $this->intro_text = $intro_text; |
|
30 | - } |
|
20 | + /** |
|
21 | + * Create a new text introduction |
|
22 | + * @param int $id The id of this tool introduction in the Chamilo-course |
|
23 | + * @param string $intro_text |
|
24 | + */ |
|
25 | + public function __construct($id, $intro_text) |
|
26 | + { |
|
27 | + parent::__construct($id, RESOURCE_TOOL_INTRO); |
|
28 | + $this->id = $id; |
|
29 | + $this->intro_text = $intro_text; |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Show this resource |
|
34 | - */ |
|
35 | - function show() |
|
36 | - { |
|
37 | - parent::show(); |
|
38 | - switch ($this->id) |
|
39 | - { |
|
40 | - case TOOL_DOCUMENT: |
|
41 | - $lang_id = 'Documents'; |
|
42 | - break; |
|
43 | - case TOOL_CALENDAR_EVENT: |
|
44 | - $lang_id = 'Agenda'; |
|
45 | - break; |
|
46 | - case TOOL_LINK: |
|
47 | - $lang_id = 'Links'; |
|
48 | - break; |
|
49 | - case TOOL_LEARNPATH: |
|
50 | - $lang_id = 'LearningPath'; |
|
51 | - break; |
|
52 | - case TOOL_ANNOUNCEMENT: |
|
53 | - $lang_id = 'Announcements'; |
|
54 | - break; |
|
55 | - case TOOL_FORUM: |
|
56 | - $lang_id = 'Forums'; |
|
57 | - break; |
|
58 | - case TOOL_DROPBOX: |
|
59 | - $lang_id = 'Dropbox'; |
|
60 | - break; |
|
61 | - case TOOL_QUIZ: |
|
62 | - $lang_id = 'Exercises'; |
|
63 | - break; |
|
64 | - case TOOL_USER: |
|
65 | - $lang_id = 'Users'; |
|
66 | - break; |
|
67 | - case TOOL_GROUP: |
|
68 | - $lang_id = 'Group'; |
|
69 | - break; |
|
70 | - case TOOL_WIKI: |
|
71 | - $lang_id = 'Wiki'; |
|
72 | - break; |
|
73 | - case TOOL_STUDENTPUBLICATION: |
|
74 | - $lang_id = 'StudentPublications'; |
|
75 | - break; |
|
76 | - case TOOL_COURSE_HOMEPAGE: |
|
77 | - $lang_id = 'CourseHomepageLink'; |
|
78 | - break; |
|
79 | - case TOOL_GLOSSARY: |
|
80 | - $lang_id = 'Glossary'; |
|
81 | - break; |
|
82 | - case TOOL_NOTEBOOK: |
|
83 | - $lang_id = 'Notebook'; |
|
84 | - break; |
|
85 | - default: |
|
86 | - $lang_id = ucfirst($this->id); // This is a wild guess. |
|
87 | - } |
|
88 | - echo '<strong>'.get_lang($lang_id, '').':</strong><br />'; |
|
89 | - echo $this->intro_text; |
|
90 | - } |
|
32 | + /** |
|
33 | + * Show this resource |
|
34 | + */ |
|
35 | + function show() |
|
36 | + { |
|
37 | + parent::show(); |
|
38 | + switch ($this->id) |
|
39 | + { |
|
40 | + case TOOL_DOCUMENT: |
|
41 | + $lang_id = 'Documents'; |
|
42 | + break; |
|
43 | + case TOOL_CALENDAR_EVENT: |
|
44 | + $lang_id = 'Agenda'; |
|
45 | + break; |
|
46 | + case TOOL_LINK: |
|
47 | + $lang_id = 'Links'; |
|
48 | + break; |
|
49 | + case TOOL_LEARNPATH: |
|
50 | + $lang_id = 'LearningPath'; |
|
51 | + break; |
|
52 | + case TOOL_ANNOUNCEMENT: |
|
53 | + $lang_id = 'Announcements'; |
|
54 | + break; |
|
55 | + case TOOL_FORUM: |
|
56 | + $lang_id = 'Forums'; |
|
57 | + break; |
|
58 | + case TOOL_DROPBOX: |
|
59 | + $lang_id = 'Dropbox'; |
|
60 | + break; |
|
61 | + case TOOL_QUIZ: |
|
62 | + $lang_id = 'Exercises'; |
|
63 | + break; |
|
64 | + case TOOL_USER: |
|
65 | + $lang_id = 'Users'; |
|
66 | + break; |
|
67 | + case TOOL_GROUP: |
|
68 | + $lang_id = 'Group'; |
|
69 | + break; |
|
70 | + case TOOL_WIKI: |
|
71 | + $lang_id = 'Wiki'; |
|
72 | + break; |
|
73 | + case TOOL_STUDENTPUBLICATION: |
|
74 | + $lang_id = 'StudentPublications'; |
|
75 | + break; |
|
76 | + case TOOL_COURSE_HOMEPAGE: |
|
77 | + $lang_id = 'CourseHomepageLink'; |
|
78 | + break; |
|
79 | + case TOOL_GLOSSARY: |
|
80 | + $lang_id = 'Glossary'; |
|
81 | + break; |
|
82 | + case TOOL_NOTEBOOK: |
|
83 | + $lang_id = 'Notebook'; |
|
84 | + break; |
|
85 | + default: |
|
86 | + $lang_id = ucfirst($this->id); // This is a wild guess. |
|
87 | + } |
|
88 | + echo '<strong>'.get_lang($lang_id, '').':</strong><br />'; |
|
89 | + echo $this->intro_text; |
|
90 | + } |
|
91 | 91 | } |
@@ -11,24 +11,24 @@ |
||
11 | 11 | class CourseSession extends Coursecopy\Resource |
12 | 12 | { |
13 | 13 | // The title session |
14 | - public $title; |
|
14 | + public $title; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Create a new Session |
|
18 | - * @param int $id |
|
19 | - * @param string $title |
|
20 | - */ |
|
21 | - public function __construct($id,$title) |
|
22 | - { |
|
23 | - parent::__construct($id, RESOURCE_SESSION_COURSE); |
|
24 | - $this->title = $title; |
|
25 | - } |
|
16 | + /** |
|
17 | + * Create a new Session |
|
18 | + * @param int $id |
|
19 | + * @param string $title |
|
20 | + */ |
|
21 | + public function __construct($id,$title) |
|
22 | + { |
|
23 | + parent::__construct($id, RESOURCE_SESSION_COURSE); |
|
24 | + $this->title = $title; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Show this Event |
|
29 | - */ |
|
30 | - function show() { |
|
31 | - parent::show(); |
|
32 | - echo $this->title; |
|
33 | - } |
|
27 | + /** |
|
28 | + * Show this Event |
|
29 | + */ |
|
30 | + function show() { |
|
31 | + parent::show(); |
|
32 | + echo $this->title; |
|
33 | + } |
|
34 | 34 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $this_section = SECTION_COURSES; |
11 | 11 | |
12 | 12 | if (extension_loaded('xapian')) { |
13 | - require '../newscorm/lp_list_search.php'; |
|
13 | + require '../newscorm/lp_list_search.php'; |
|
14 | 14 | } else { |
15 | 15 | Display::display_header(get_lang('Search')); |
16 | 16 | Display::display_error_message(get_lang('SearchXapianModuleNotInstalled')); |
@@ -101,8 +101,8 @@ |
||
101 | 101 | $group_url = "group_view.php?id=$id"; |
102 | 102 | |
103 | 103 | $result['name'] = '<div class="group-name">'.Display::url( |
104 | - api_ucwords(cut($result['name'], 40, true)), $group_url) |
|
105 | - .'</div><div class="count-username">'. |
|
104 | + api_ucwords(cut($result['name'], 40, true)), $group_url) |
|
105 | + .'</div><div class="count-username">'. |
|
106 | 106 | Display::returnFontAwesomeIcon('user').$result['count'].'</div>'; |
107 | 107 | |
108 | 108 | $picture = $userGroup->get_picture_group( |
@@ -14,7 +14,7 @@ |
||
14 | 14 | api_block_anonymous_users(); |
15 | 15 | |
16 | 16 | if (isset($_REQUEST['userId'])) { |
17 | - $userId = intval($_REQUEST['userId']); |
|
17 | + $userId = intval($_REQUEST['userId']); |
|
18 | 18 | } else { |
19 | 19 | api_not_allowed(); |
20 | 20 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /chamilo_license.txt */ |
3 | 3 | /** |
4 | - * Redirect file for social network default page |
|
5 | - * @package chamilo.social |
|
6 | - */ |
|
4 | + * Redirect file for social network default page |
|
5 | + * @package chamilo.social |
|
6 | + */ |
|
7 | 7 | /** |
8 | - * Redirect |
|
9 | - */ |
|
8 | + * Redirect |
|
9 | + */ |
|
10 | 10 | header('Location: profile.php'); |
11 | 11 | exit(); |
@@ -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"> |
@@ -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 |
@@ -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); |
|
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 | + } |
|
48 | 44 | |
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'); |
|
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 | - } |
|
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 | 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; |
|
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 | - } |
|
151 | + } |
|
152 | + elseif ($content == 'task') |
|
153 | + { |
|
154 | + $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
155 | + $id_field = 'task_id'; |
|
156 | + } |
|
157 | 157 | |
158 | - // finding all the permissions. We store this in a multidimensional array |
|
159 | - // where the first dimension is the tool. |
|
160 | - $sql=" |
|
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,11 +394,11 @@ 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 | - $platform_roles_table=Database::get_main_table(TABLE_ROLE); |
|
400 | + $coures_roles_table=Database::get_course_table(TABLE_ROLE); |
|
401 | + $platform_roles_table=Database::get_main_table(TABLE_ROLE); |
|
402 | 402 | /* |
403 | 403 | // platform roles |
404 | 404 | $sql="SELECT * FROM $platform_roles_table"; |
@@ -429,36 +429,36 @@ discard block |
||
429 | 429 | echo $row['role_comment']."<br />\n"; |
430 | 430 | } |
431 | 431 | */ |
432 | - // course roles |
|
433 | - $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
434 | - $result=Database::query($sql); |
|
435 | - while ($row=Database::fetch_array($result)) |
|
436 | - { |
|
437 | - if (in_array($row['role_id'], $current_course_roles)) |
|
438 | - { |
|
439 | - $checked='checked'; |
|
440 | - $image='checkbox_on2.gif'; |
|
441 | - $action='revoke'; |
|
442 | - } |
|
443 | - else |
|
444 | - { |
|
445 | - $checked=''; |
|
446 | - $image='wrong.gif'; |
|
447 | - $action='grant'; |
|
448 | - } |
|
449 | - if ($setting_visualisation=='checkbox') |
|
450 | - { |
|
451 | - echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
452 | - } |
|
453 | - if ($setting_visualisation=='image') |
|
454 | - { |
|
455 | - echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
460 | - echo $row['role_comment']."<br />\n"; |
|
461 | - } |
|
432 | + // course roles |
|
433 | + $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id "; |
|
434 | + $result=Database::query($sql); |
|
435 | + while ($row=Database::fetch_array($result)) |
|
436 | + { |
|
437 | + if (in_array($row['role_id'], $current_course_roles)) |
|
438 | + { |
|
439 | + $checked='checked'; |
|
440 | + $image='checkbox_on2.gif'; |
|
441 | + $action='revoke'; |
|
442 | + } |
|
443 | + else |
|
444 | + { |
|
445 | + $checked=''; |
|
446 | + $image='wrong.gif'; |
|
447 | + $action='grant'; |
|
448 | + } |
|
449 | + if ($setting_visualisation=='checkbox') |
|
450 | + { |
|
451 | + echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>"; |
|
452 | + } |
|
453 | + if ($setting_visualisation=='image') |
|
454 | + { |
|
455 | + echo "<a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n"; |
|
460 | + echo $row['role_comment']."<br />\n"; |
|
461 | + } |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -472,24 +472,24 @@ discard block |
||
472 | 472 | */ |
473 | 473 | function get_roles($content,$id, $scope='course') { |
474 | 474 | $course_id = api_get_course_int_id(); |
475 | - if ($content=='user') { |
|
476 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
477 | - $id_field = user_id; |
|
478 | - } |
|
479 | - if ($content=='group') { |
|
480 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
481 | - $id_field = 'group_id'; |
|
482 | - } |
|
483 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
484 | - |
|
485 | - $current_roles=array(); |
|
486 | - //$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."'"; |
|
487 | - $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
488 | - $result=Database::query($sql); |
|
489 | - while ($row=Database::fetch_array($result)) { |
|
490 | - $current_roles[]=$row['role_id']; |
|
491 | - } |
|
492 | - return $current_roles; |
|
475 | + if ($content=='user') { |
|
476 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
477 | + $id_field = user_id; |
|
478 | + } |
|
479 | + if ($content=='group') { |
|
480 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
481 | + $id_field = 'group_id'; |
|
482 | + } |
|
483 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
484 | + |
|
485 | + $current_roles=array(); |
|
486 | + //$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."'"; |
|
487 | + $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'"; |
|
488 | + $result=Database::query($sql); |
|
489 | + while ($row=Database::fetch_array($result)) { |
|
490 | + $current_roles[]=$row['role_id']; |
|
491 | + } |
|
492 | + return $current_roles; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -502,25 +502,25 @@ discard block |
||
502 | 502 | $course_id = api_get_course_int_id(); |
503 | 503 | $course_id_condition = " WHERE c_id = $course_id "; |
504 | 504 | |
505 | - if ($content=='course') |
|
506 | - { |
|
507 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
508 | - } |
|
509 | - if ($content=='platform') |
|
510 | - { |
|
511 | - $table_role=Database::get_main_table(TABLE_ROLE); |
|
512 | - $course_id_condition = ''; |
|
513 | - } |
|
505 | + if ($content=='course') |
|
506 | + { |
|
507 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
508 | + } |
|
509 | + if ($content=='platform') |
|
510 | + { |
|
511 | + $table_role=Database::get_main_table(TABLE_ROLE); |
|
512 | + $course_id_condition = ''; |
|
513 | + } |
|
514 | 514 | |
515 | - $current_roles=array(); |
|
516 | - $sql="SELECT * FROM $table_role $course_id_condition "; |
|
517 | - $result=Database::query($sql); |
|
518 | - while ($row=Database::fetch_array($result)) |
|
519 | - { |
|
520 | - $roles[]=$row; |
|
521 | - } |
|
515 | + $current_roles=array(); |
|
516 | + $sql="SELECT * FROM $table_role $course_id_condition "; |
|
517 | + $result=Database::query($sql); |
|
518 | + while ($row=Database::fetch_array($result)) |
|
519 | + { |
|
520 | + $roles[]=$row; |
|
521 | + } |
|
522 | 522 | |
523 | - return $roles; |
|
523 | + return $roles; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -536,34 +536,34 @@ discard block |
||
536 | 536 | */ |
537 | 537 | function get_roles_permissions($content,$id, $scope='course') { |
538 | 538 | $course_id = api_get_course_int_id(); |
539 | - if ($content == 'user') { |
|
540 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
541 | - $id_field = 'user_id'; |
|
542 | - } |
|
539 | + if ($content == 'user') { |
|
540 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
541 | + $id_field = 'user_id'; |
|
542 | + } |
|
543 | 543 | |
544 | - if ($content == 'group') { |
|
545 | - $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
546 | - $id_field = 'group_id'; |
|
547 | - } |
|
544 | + if ($content == 'group') { |
|
545 | + $table = Database::get_course_table(TABLE_ROLE_GROUP); |
|
546 | + $id_field = 'group_id'; |
|
547 | + } |
|
548 | 548 | |
549 | - // course roles or platform roles |
|
550 | - $scope = 'course'; |
|
551 | - if ($scope == 'course') { |
|
552 | - $table_role = Database::get_course_table(TABLE_ROLE); |
|
553 | - $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
549 | + // course roles or platform roles |
|
550 | + $scope = 'course'; |
|
551 | + if ($scope == 'course') { |
|
552 | + $table_role = Database::get_course_table(TABLE_ROLE); |
|
553 | + $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
554 | 554 | |
555 | 555 | $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND "; |
556 | - } |
|
556 | + } |
|
557 | 557 | |
558 | - if ($scope == 'platform') { |
|
559 | - $table_role = Database::get_main_table(TABLE_ROLE); |
|
560 | - $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
558 | + if ($scope == 'platform') { |
|
559 | + $table_role = Database::get_main_table(TABLE_ROLE); |
|
560 | + $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION); |
|
561 | 561 | $role_condition = ''; |
562 | - } |
|
562 | + } |
|
563 | 563 | |
564 | - $current_roles = array(); |
|
564 | + $current_roles = array(); |
|
565 | 565 | |
566 | - $sql = " |
|
566 | + $sql = " |
|
567 | 567 | SELECT * |
568 | 568 | FROM |
569 | 569 | " . $table . " role_group_user, |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | role_group_user.role_id = role.role_id AND |
578 | 578 | role.role_id = role_permissions.role_id"; |
579 | 579 | |
580 | - $result = Database::query($sql); |
|
580 | + $result = Database::query($sql); |
|
581 | 581 | $current_role_permissions = array(); |
582 | - while ($row=Database::fetch_array($result)) { |
|
583 | - $current_role_permissions[$row['tool']][]=$row['action']; |
|
582 | + while ($row=Database::fetch_array($result)) { |
|
583 | + $current_role_permissions[$row['tool']][]=$row['action']; |
|
584 | 584 | } |
585 | - return $current_role_permissions; |
|
585 | + return $current_role_permissions; |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -596,34 +596,34 @@ discard block |
||
596 | 596 | |
597 | 597 | function assign_role($content, $action, $id, $role_id, $scope='course') { |
598 | 598 | $course_id = api_get_course_int_id(); |
599 | - // Which database are we using (depending on the $content parameter) |
|
600 | - if ($content=='user') { |
|
601 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
602 | - $id_field = 'user_id'; |
|
603 | - } elseif($content=='group') { |
|
604 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
605 | - $id_field = 'group_id'; |
|
606 | - } else { |
|
607 | - return get_lang('Error'); |
|
608 | - } |
|
599 | + // Which database are we using (depending on the $content parameter) |
|
600 | + if ($content=='user') { |
|
601 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
602 | + $id_field = 'user_id'; |
|
603 | + } elseif($content=='group') { |
|
604 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
605 | + $id_field = 'group_id'; |
|
606 | + } else { |
|
607 | + return get_lang('Error'); |
|
608 | + } |
|
609 | 609 | |
610 | - // grating a right |
|
611 | - if ($action=='grant') { |
|
612 | - $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)."')"; |
|
613 | - $result=Database::query($sql); |
|
614 | - if ($result) { |
|
615 | - $result_message=get_lang('RoleGranted'); |
|
616 | - } |
|
617 | - } |
|
610 | + // grating a right |
|
611 | + if ($action=='grant') { |
|
612 | + $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)."')"; |
|
613 | + $result=Database::query($sql); |
|
614 | + if ($result) { |
|
615 | + $result_message=get_lang('RoleGranted'); |
|
616 | + } |
|
617 | + } |
|
618 | 618 | |
619 | - if ($action=='revoke') { |
|
620 | - $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
621 | - $result=Database::query($sql); |
|
622 | - if ($result) { |
|
623 | - $result_message=get_lang('RoleRevoked'); |
|
624 | - } |
|
625 | - } |
|
626 | - return $result_message; |
|
619 | + if ($action=='revoke') { |
|
620 | + $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'"; |
|
621 | + $result=Database::query($sql); |
|
622 | + if ($result) { |
|
623 | + $result_message=get_lang('RoleRevoked'); |
|
624 | + } |
|
625 | + } |
|
626 | + return $result_message; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -633,21 +633,21 @@ discard block |
||
633 | 633 | */ |
634 | 634 | function permission_array_merge($array1, $array2) |
635 | 635 | { |
636 | - foreach ($array2 as $tool=>$permissions) |
|
637 | - { |
|
638 | - foreach ($permissions as $permissionkey=>$permissionvalue) |
|
639 | - { |
|
640 | - $array1[$tool][]=$permissionvalue; |
|
641 | - } |
|
642 | - } |
|
643 | - return $array1; |
|
636 | + foreach ($array2 as $tool=>$permissions) |
|
637 | + { |
|
638 | + foreach ($permissions as $permissionkey=>$permissionvalue) |
|
639 | + { |
|
640 | + $array1[$tool][]=$permissionvalue; |
|
641 | + } |
|
642 | + } |
|
643 | + return $array1; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
647 | 647 | function my_print_r($array) |
648 | 648 | { |
649 | - echo '<pre>'; |
|
650 | - print_r($array); |
|
651 | - echo '</pre>'; |
|
649 | + echo '<pre>'; |
|
650 | + print_r($array); |
|
651 | + echo '</pre>'; |
|
652 | 652 | } |
653 | 653 | ?> |