Passed
Push — 1.10.x ( f9cbcd...83c791 )
by Yannick
657:30 queued 614:41
created
main/social/group_view.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 api_block_anonymous_users();
13 13
 
14
-if (api_get_setting('allow_social_tool') !='true') {
14
+if (api_get_setting('allow_social_tool') != 'true') {
15 15
     api_not_allowed();
16 16
 }
17 17
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	document.getElementById("filepath_"+counter_image).innerHTML = "\n\
66 66
         <input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />\n\
67 67
         <a href=\"javascript:remove_image_form("+id_elem1+")\">\n\
68
-            <img src=\"' . api_get_path(WEB_IMG_PATH) . 'delete.gif\">\n\
68
+            <img src=\"' . api_get_path(WEB_IMG_PATH).'delete.gif\">\n\
69 69
         </a>\n\
70 70
     ";
71 71
 
@@ -87,31 +87,31 @@  discard block
 block discarded – undo
87 87
 
88 88
 </script>';
89 89
 
90
-$allowed_views = array('mygroups','newest','pop');
90
+$allowed_views = array('mygroups', 'newest', 'pop');
91 91
 $content = null;
92 92
 
93
-if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
93
+if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
94 94
     if ($_GET['view'] == 'mygroups') {
95
-        $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
96
-        $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('MyGroups'));
97
-    } else if ( $_GET['view'] == 'newest') {
98
-        $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
99
-        $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Newest'));
100
-    } else  {
101
-        $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
102
-        $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Popular'));
95
+        $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
96
+        $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('MyGroups'));
97
+    } else if ($_GET['view'] == 'newest') {
98
+        $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
99
+        $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('Newest'));
100
+    } else {
101
+        $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
102
+        $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('Popular'));
103 103
     }
104 104
 } else {
105
-    $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
105
+    $interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
106 106
     if (!isset($_GET['id'])) {
107
-        $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('GroupList'));
107
+        $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('GroupList'));
108 108
     } else {
109 109
         //$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Group'));
110 110
     }
111 111
 }
112 112
 
113 113
 // getting group information
114
-$group_id	= isset($_GET['id']) ? intval($_GET['id']) : null;
114
+$group_id = isset($_GET['id']) ? intval($_GET['id']) : null;
115 115
 $relation_group_title = '';
116 116
 $role = 0;
117 117
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 if ($group_id != 0) {
121 121
     $group_info = $usergroup->get($group_id);
122 122
 
123
-    $interbreadcrumb[]= array ('url' =>'#','name' => $group_info['name']);
123
+    $interbreadcrumb[] = array('url' =>'#', 'name' => $group_info['name']);
124 124
 
125
-    if (isset($_GET['action']) && $_GET['action']=='leave') {
125
+    if (isset($_GET['action']) && $_GET['action'] == 'leave') {
126 126
         $user_leaved = intval($_GET['u']);
127 127
         //I can "leave me myself"
128 128
         if (api_get_user_id() == $user_leaved) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         }
134 134
     }
135 135
     // add a user to a group if its open
136
-    if (isset($_GET['action']) && $_GET['action']=='join') {
136
+    if (isset($_GET['action']) && $_GET['action'] == 'join') {
137 137
         // we add a user only if is a open group
138 138
         $user_join = intval($_GET['u']);
139 139
         if (api_get_user_id() == $user_join && !empty($group_id)) {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 $group_info = $usergroup->get($group_id);
162 162
 
163 163
 //Loading group information
164
-if (isset($_GET['status']) && $_GET['status']=='sent') {
164
+if (isset($_GET['status']) && $_GET['status'] == 'sent') {
165 165
     $social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false);
166 166
 }
167 167
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
172 172
     if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
173
-        $social_right_content .=  Display::return_message(get_lang('YouAlreadySentAnInvitation'));
173
+        $social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation'));
174 174
     }
175 175
 }
176 176
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
         if (!in_array($role,
180 180
             array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))
181 181
         ) {
182
-            $social_right_content .=  '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
182
+            $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
183 183
                 get_lang('JoinGroup').'</a>';
184 184
         } elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
185
-            $social_right_content .=  '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
185
+            $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.
186 186
                 get_lang('YouHaveBeenInvitedJoinNow').'</a>';
187 187
         }
188
-        $social_right_content .=  '<br /><br />';
188
+        $social_right_content .= '<br /><br />';
189 189
     }
190 190
     $content = MessageManager::display_messages_for_group($group_id);
191 191
     if ($is_group_member) {
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
         foreach ($members as $member) {
245 245
             // if is a member
246 246
             if (in_array($member['relation_type'],
247
-                array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))
247
+                array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR))
248 248
             ) {
249 249
                 //add icons
250 250
                 if ($member['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
251
-                    $icon= Display::return_icon('social_group_admin.png', get_lang('Admin'));
251
+                    $icon = Display::return_icon('social_group_admin.png', get_lang('Admin'));
252 252
                 } elseif ($member['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
253
-                    $icon= Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
253
+                    $icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
254 254
                 } else {
255
-                    $icon= '';
255
+                    $icon = '';
256 256
                 }
257 257
 
258 258
                 $userPicture = UserManager::getUserPicture($member['id']);
259 259
 
260 260
                 $member_content .= '<div class="">';
261
-                $member_name = Display::url(api_get_person_name(cut($member['firstname'],15),cut($member['lastname'],15)).'&nbsp;'.$icon, $member['user_info']['profile_url']);
261
+                $member_name = Display::url(api_get_person_name(cut($member['firstname'], 15), cut($member['lastname'], 15)).'&nbsp;'.$icon, $member['user_info']['profile_url']);
262 262
                 $member_content .= Display::div('<img class="social-groups-image img-circle" src="'.$userPicture.'"/>&nbsp'.$member_name);
263 263
                 $member_content .= '</div>';
264 264
             }
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     }
267 267
 
268 268
     if (!empty($create_thread_link)) {
269
-        $create_thread_link =  Display::div($create_thread_link, array('class'=>'pull-right'));
269
+        $create_thread_link = Display::div($create_thread_link, array('class'=>'pull-right'));
270 270
     }
271 271
     $headers = array(get_lang('Discussions'), get_lang('Members'));
272
-    $social_right_content .= Display::tabs($headers, array($content, $member_content),'tabs');
272
+    $social_right_content .= Display::tabs($headers, array($content, $member_content), 'tabs');
273 273
 } else {
274 274
     // if I already sent an invitation message
275 275
     if (!in_array(
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
         )
281 281
     )
282 282
     ) {
283
-        $social_right_content .=  '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
283
+        $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
284 284
     } elseif ($role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
285
-        $social_right_content .=  '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
285
+        $social_right_content .= '<a class="btn" href="group_view.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
286 286
     }
287 287
 }
288 288
 
Please login to merge, or discard this patch.
main/social/group_members.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     $group_id
118 118
 );
119 119
 $social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
120
-$social_right_content = '<h2>' . $group_info['name'] . '</h2>';
120
+$social_right_content = '<h2>'.$group_info['name'].'</h2>';
121 121
 
122 122
 foreach ($users as $user) {
123 123
     switch ($user['relation_type']) {
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
                 )
137 137
             )
138 138
             ) {
139
-                $user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=delete">' .
139
+                $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=delete">'.
140 140
                     Display::return_icon(
141 141
                         'delete.png',
142 142
                         get_lang('DeleteFromGroup')
143
-                    ) . '</a>' .
144
-                    '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=set_moderator">' .
143
+                    ).'</a>'.
144
+                    '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=set_moderator">'.
145 145
                     Display::return_icon(
146 146
                         'social_moderator_add.png',
147 147
                         get_lang('AddModerator')
148
-                    ) . '</a>';
148
+                    ).'</a>';
149 149
             }
150 150
             break;
151 151
         case GROUP_USER_PERMISSION_PENDING_INVITATION:
152
-            $user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=add">' .
152
+            $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=add">'.
153 153
                 Display::return_icon(
154 154
                     'pending_invitation.png',
155 155
                     get_lang('PendingInvitation')
156
-                ) . '</a>';
156
+                ).'</a>';
157 157
             break;
158 158
         case GROUP_USER_PERMISSION_MODERATOR:
159 159
             $user['link'] = Display::return_icon(
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
             );
163 163
             //only group admin can manage moderators
164 164
             if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
165
-                $user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=delete_moderator">'.
165
+                $user['link'] .= '<a href="group_members.php?id='.$group_id.'&u='.$user['id'].'&action=delete_moderator">'.
166 166
                     Display::return_icon(
167 167
                         'social_moderator_delete.png',
168 168
                         get_lang('DeleteModerator')
169
-                    ) . '</a>';
169
+                    ).'</a>';
170 170
             }
171 171
             break;
172 172
     }
173 173
 
174 174
     $userPicture = UserManager::getUserPicture($user['id']);
175
-    $user['image'] = '<img src="' . $userPicture . '"  width="50px" height="50px"  />';
175
+    $user['image'] = '<img src="'.$userPicture.'"  width="50px" height="50px"  />';
176 176
     $new_member_list[] = $user;
177 177
 }
178 178
 if (count($new_member_list) > 0) {
Please login to merge, or discard this patch.
main/social/group_add.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@  discard block
 block discarded – undo
6 6
  * @author Julio Montoya <[email protected]>
7 7
  */
8 8
 
9
-$language_file= 'userInfo';
9
+$language_file = 'userInfo';
10 10
 $cidReset = true;
11 11
 require_once '../inc/global.inc.php';
12 12
 
13 13
 api_block_anonymous_users();
14
-if (api_get_setting('allow_social_tool') !='true') {
14
+if (api_get_setting('allow_social_tool') != 'true') {
15 15
     api_not_allowed();
16 16
 }
17 17
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 $nameTools = get_lang('AddGroup');
39 39
 $this_section = SECTION_SOCIAL;
40 40
 
41
-$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
42
-$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
43
-$interbreadcrumb[]= array ('url' =>'#','name' => $nameTools);
41
+$interbreadcrumb[] = array('url' =>'home.php', 'name' => get_lang('Social'));
42
+$interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
43
+$interbreadcrumb[] = array('url' =>'#', 'name' => $nameTools);
44 44
 
45 45
 $social_avatar_block = SocialManager::show_social_avatar_block('group_add');
46 46
 $social_menu_block = SocialManager::show_social_menu('group_add');
Please login to merge, or discard this patch.
main/social/group_waiting_list.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 require_once '../inc/global.inc.php';
12 12
 
13 13
 api_block_anonymous_users();
14
-if (api_get_setting('allow_social_tool') !='true') {
14
+if (api_get_setting('allow_social_tool') != 'true') {
15 15
     api_not_allowed();
16 16
 }
17 17
 
18 18
 $this_section = SECTION_SOCIAL;
19 19
 
20
-$group_id= intval($_GET['id']);
20
+$group_id = intval($_GET['id']);
21 21
 $usergroup = new UserGroup();
22 22
 
23 23
 //todo @this validation could be in a function in group_portal_manager
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     }
36 36
 }
37 37
 
38
-$interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
38
+$interbreadcrumb[] = array('url' =>'groups.php', 'name' => get_lang('Groups'));
39 39
 $interbreadcrumb[] = array('url' => 'group_view.php?id='.$group_id, 'name' => $group_info['name']);
40
-$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('WaitingList'));
40
+$interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('WaitingList'));
41 41
 
42 42
 // Group information
43 43
 $admins = $usergroup->get_users_by_group(
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 );
50 50
 $show_message = '';
51 51
 
52
-if (isset($_GET['action']) && $_GET['action']=='accept') {
52
+if (isset($_GET['action']) && $_GET['action'] == 'accept') {
53 53
     // we add a user only if is a open group
54 54
     $user_join = intval($_GET['u']);
55 55
     //if i'm a moderator
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     }
60 60
 }
61 61
 
62
-if (isset($_GET['action']) && $_GET['action']=='deny') {
62
+if (isset($_GET['action']) && $_GET['action'] == 'deny') {
63 63
     // we add a user only if is a open group
64 64
     $user_join = intval($_GET['u']);
65 65
     //if i'm a moderator
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     }
70 70
 }
71 71
 
72
-if (isset($_GET['action']) && $_GET['action']=='set_moderator') {
72
+if (isset($_GET['action']) && $_GET['action'] == 'set_moderator') {
73 73
     // we add a user only if is a open group
74
-    $user_moderator= intval($_GET['u']);
74
+    $user_moderator = intval($_GET['u']);
75 75
     //if i'm the admin
76 76
     if ($usergroup->is_group_admin($group_id)) {
77 77
         $usergroup->update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 $social_left_content = SocialManager::show_social_menu('waiting_list', $group_id);
92 92
 
93 93
 // Display form
94
-foreach($users as $user) {
94
+foreach ($users as $user) {
95 95
     switch ($user['relation_type']) {
96 96
         case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
97 97
             $user['link']  = '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=accept">'.
Please login to merge, or discard this patch.
main/social/friends.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -132,15 +132,15 @@
 block discarded – undo
132 132
 
133 133
                 $friend_html .= '
134 134
                     <div class="col-md-3">
135
-                        <div class="thumbnail text-center" id="div_' . $friends[$j]['friend_user_id'] . '">
136
-                            <img src="' . $userPicture . '" class="img-responsive" id="imgfriend_' . $friend['friend_user_id'] . '" title="'.$user_name.'">
135
+                        <div class="thumbnail text-center" id="div_' . $friends[$j]['friend_user_id'].'">
136
+                            <img src="' . $userPicture.'" class="img-responsive" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'">
137 137
                             <div class="caption">
138 138
                                 <h3>
139
-                                    <a href="profile.php?u=' . $friend['friend_user_id'] . '">' . $user_name . '</a>
139
+                                    <a href="profile.php?u=' . $friend['friend_user_id'].'">'.$user_name.'</a>
140 140
                                 </h3>
141 141
                                 <p>
142
-                                    <button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'] . '>
143
-                                        ' . get_lang('Delete') . '
142
+                                    <button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'].'>
143
+                                        ' . get_lang('Delete').'
144 144
                                     </button>
145 145
                                 </p>
146 146
                             </div>
Please login to merge, or discard this patch.
main/permissions/group_permissions.inc.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 // ---------------------------------------------------
14 14
 // 			ACTIONS
15 15
 // ---------------------------------------------------
16
-if ($_POST['StoreGroupPermissions'] and $setting_visualisation=='checkbox')
16
+if ($_POST['StoreGroupPermissions'] and $setting_visualisation == 'checkbox')
17 17
 {
18
-	$result_message=store_permissions('group', $group_id);
18
+	$result_message = store_permissions('group', $group_id);
19 19
 	if ($result_message)
20 20
 	{
21 21
 		Display::display_normal_message($result_message);
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
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']))
26
+	if (($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke') AND isset($_GET['permission']) AND isset($_GET['tool']))
27 27
 	{
28
-		$result_message=store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']);
28
+		$result_message = store_one_permission('group', $_GET['action'], $group_id, $_GET['tool'], $_GET['permission']);
29 29
 	}
30
-	if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
30
+	if (isset($_GET['role']) AND ($_GET['action'] == 'grant' OR $_GET['action'] == 'revoke'))
31 31
 	{
32
-		$result_message=assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']);
32
+		$result_message = assign_role('group', $_GET['action'], $group_id, $_GET['role'], $_GET['scope']);
33 33
 		echo 'hier';
34 34
 	}
35 35
 }
@@ -41,41 +41,41 @@  discard block
 block discarded – undo
41 41
 // ---------------------------------------------------
42 42
 // 			RETRIEVING THE PERMISSIONS
43 43
 // ---------------------------------------------------
44
-$current_group_permissions=array();
45
-$current_group_permissions=get_permissions('group',$group_id);
44
+$current_group_permissions = array();
45
+$current_group_permissions = get_permissions('group', $group_id);
46 46
 // @todo current group permissions and current role permissions
47 47
 
48 48
 // ---------------------------------------------------
49 49
 //   INHERITED PERMISSIONS (group roles)
50 50
 // ---------------------------------------------------
51
-$group_course_roles_permissions=get_roles_permissions('group',$group_id, 'course');
52
-$group_platform_roles_permissions=get_roles_permissions('group',$group_id, 'platform');
53
-$inherited_permissions=permission_array_merge($group_course_roles_permissions,$group_platform_roles_permissions);
51
+$group_course_roles_permissions = get_roles_permissions('group', $group_id, 'course');
52
+$group_platform_roles_permissions = get_roles_permissions('group', $group_id, 'platform');
53
+$inherited_permissions = permission_array_merge($group_course_roles_permissions, $group_platform_roles_permissions);
54 54
 
55 55
 // ---------------------------------------------------
56 56
 // 			LIMITED OR FULL
57 57
 // ---------------------------------------------------
58
-$current_group_permissions=limited_or_full($current_group_permissions);
59
-$inherited_permissions=limited_or_full($inherited_permissions);
60
-if (api_get_setting('permissions')=='limited')
58
+$current_group_permissions = limited_or_full($current_group_permissions);
59
+$inherited_permissions = limited_or_full($inherited_permissions);
60
+if (api_get_setting('permissions') == 'limited')
61 61
 {
62
-	$header_array=$rights_limited;
62
+	$header_array = $rights_limited;
63 63
 }
64
-if (api_get_setting('permissions')=='full')
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('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
70 70
 // ---------------------------------------------------
71 71
 // 		DISPLAYING THE ROLES LIST
72 72
 // ---------------------------------------------------
73
-if (api_get_setting('group_roles')=='true')
73
+if (api_get_setting('group_roles') == 'true')
74 74
 {
75 75
 	// the list of the roles for the user
76 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');
77
+	$current_group_course_roles = get_roles('group', $group_id);
78
+	$current_group_platform_roles = get_roles('group', $group_id, 'platform');
79 79
 	display_role_list($current_group_course_roles, $current_group_platform_roles);
80 80
 	echo '<br />';
81 81
 }
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	foreach ($header_array as $key=>$value)
108 108
 	{
109 109
 		echo "\t\t<td align='center'>\n";
110
-		if (in_array($value,$rights))
110
+		if (in_array($value, $rights))
111 111
 		{
112
-			if ($setting_visualisation=='checkbox')
112
+			if ($setting_visualisation == 'checkbox')
113 113
 			{
114 114
 				//display_checkbox_matrix($current_group_permissions, $tool, $value);
115
-				display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions,$course_admin);
115
+				display_checkbox_matrix($current_group_permissions, $tool, $value, $inherited_permissions, $course_admin);
116 116
 			}
117
-			if ($setting_visualisation=='image')
117
+			if ($setting_visualisation == 'image')
118 118
 			{
119 119
 				//display_image_matrix($current_group_permissions, $tool, $value);
120
-				display_image_matrix($current_group_permissions, $tool, $value,$inherited_permissions, $course_admin);
120
+				display_image_matrix($current_group_permissions, $tool, $value, $inherited_permissions, $course_admin);
121 121
 			}
122 122
 		}
123 123
 		// note: in a later stage this part will be replaced by a function
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 echo "</table>\n";
133
-if ($setting_visualisation=='checkbox')
133
+if ($setting_visualisation == 'checkbox')
134 134
 {
135 135
 	echo "<input type=\"Submit\" name=\"StoreGroupPermissions\" value=\"".get_lang('StorePermissions')."\">";
136 136
 }
Please login to merge, or discard this patch.
main/permissions/all_permissions.inc.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
  * Code
11 11
  */
12 12
 // possible permissions
13
-$rights_full=array("View","Add","Edit","Delete","Visibility","Move");
14
-$rights_limited=array("Add","Edit","Delete");
13
+$rights_full = array("View", "Add", "Edit", "Delete", "Visibility", "Move");
14
+$rights_limited = array("Add", "Edit", "Delete");
15 15
 
16 16
 
17 17
 // first we determine what can be done in each tool. We do this for each tool.
18
-$tool_rights[TOOL_LINK]=array("View","Add","Edit","Delete","Visibility", "Move");
19
-$tool_rights[TOOL_DOCUMENT]=array("View","Add","Edit","Delete","Visibility","Move");
18
+$tool_rights[TOOL_LINK] = array("View", "Add", "Edit", "Delete", "Visibility", "Move");
19
+$tool_rights[TOOL_DOCUMENT] = array("View", "Add", "Edit", "Delete", "Visibility", "Move");
20 20
 //$tool_rights[TOOL_CALENDAR_EVENT]=array("View","Add","Edit","Delete","Visibility");
21
-$tool_rights[TOOL_ANNOUNCEMENT]=array("View","Add","Edit","Delete","Visibility", "Move");
21
+$tool_rights[TOOL_ANNOUNCEMENT] = array("View", "Add", "Edit", "Delete", "Visibility", "Move");
22 22
 //$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Edit","Delete","Visibility");
23 23
 //$tool_rights[TOOL_COURSE_DESCRIPTION]=array("View","Add","Edit","Delete","Visibility");
24 24
 //$tool_rights[TOOL_LEARNPATH]=array("View","Add","Edit","Delete","Visibility");
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 //$tool_rights[TOOL_BB_POST]=array("View","Add","Edit","Delete");
27 27
 //$tool_rights[TOOL_DROPBOX]=array("View","Add","Delete");
28 28
 //$tool_rights[TOOL_QUIZ]=array("View","Add","Edit","Delete","Visibility");
29
-$tool_rights[TOOL_USER]=array("View","Add","Edit","Delete");
29
+$tool_rights[TOOL_USER] = array("View", "Add", "Edit", "Delete");
30 30
 //$tool_rights[TOOL_GROUP]=array("View","Add","Edit","Delete");
31 31
 //$tool_rights[TOOL_CHAT]=array("View","Delete");
32 32
 //$tool_rights[TOOL_CONFERENCE]=array("View","Add","Edit","Delete");
33 33
 //$tool_rights[TOOL_STUDENTPUBLICATION]=array("View","Add","Edit","Delete");
34 34
 
35 35
 // this value can be checkbox or image
36
-$setting_visualisation='image';
36
+$setting_visualisation = 'image';
37 37
 
38 38
 ?>
Please login to merge, or discard this patch.
main/permissions/blog_permissions.inc.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 // Remove the blog creater because he has all the rights automatically
45 45
 // and we want to keep it that way.
46
-$tbl_course_rel_user = $table=Database::get_main_table(TABLE_MAIN_COURSE_USER);
46
+$tbl_course_rel_user = $table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
47 47
 $sql = "SELECT user_id
48 48
 		FROM $tbl_course_rel_user
49 49
 		WHERE status = '1' AND c_id = '".api_get_course_int_id()."'";
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 // ------------------------------------------------------------------
84 84
 // 			RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER
85 85
 // ------------------------------------------------------------------
86
-if (api_get_setting('user_roles')=='true') {
86
+if (api_get_setting('user_roles') == 'true') {
87 87
 	// course roles that are assigned to the user
88
-	$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id);
89
-	$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
88
+	$current_user_role_permissions_of_user = get_roles_permissions('user', $user_id);
89
+	$inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user);
90 90
 	// NOTE: deze array moet nog gemerged worden met de $inherited_permissions array
91 91
 	// (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de
92 92
 	// groepsge�rfde permissions in beschouwing worden genomen
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 	// NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal
97 97
 	// ophalen.
98 98
 	// platform roles that are assigned to the user
99
-	$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform');
100
-	$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
99
+	$current_user_role_permissions_of_user = get_roles_permissions('user', $user_id, 'platform');
100
+	$inherited_permissions = permission_array_merge($inherited_permissions, $current_user_role_permissions_of_user);
101 101
 }
102 102
 // ------------------------------------------------------------------
103 103
 //	RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER
104 104
 // ------------------------------------------------------------------
105
-if (api_get_setting('group_roles')=='true') {
105
+if (api_get_setting('group_roles') == 'true') {
106 106
 	// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
107 107
 	foreach ($groups_of_user as $group) {
108
-		$this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
108
+		$this_current_group_role_permissions_of_user = get_roles_permissions('user', $user_id);
109 109
 		//$inherited_permissions[$tool][]=$permission;
110 110
 	}
111 111
 }
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 // 		DISPLAYING THE ROLES LIST
117 117
 // ---------------------------------------------------
118 118
 
119
-if (api_get_setting('user_roles')=='true')
119
+if (api_get_setting('user_roles') == 'true')
120 120
 {
121 121
 	// the list of the roles for the user
122 122
 	echo '<strong>'.get_lang('UserRoles').'</strong><br />';
123
-	$current_user_course_roles=get_roles('user',$user_id);
124
-	$current_user_platform_roles=get_roles('user',$user_id, 'platform');
123
+	$current_user_course_roles = get_roles('user', $user_id);
124
+	$current_user_platform_roles = get_roles('user', $user_id, 'platform');
125 125
 	display_role_list($current_user_course_roles, $current_user_platform_roles);
126 126
 	echo '<br />';
127 127
 }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	foreach ($rights_full as $key => $value) {
170 170
 
171 171
 		echo "\t\t<td align='center'>\n";
172
-		if (in_array($value,$rights_blog)) {
172
+		if (in_array($value, $rights_blog)) {
173 173
 			display_image_matrix_for_blogs(
174 174
 				$current_user_permissions,
175 175
 				$user_id,
Please login to merge, or discard this patch.
main/permissions/permissions_functions.inc.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
     $course_id = api_get_course_int_id();
27 27
     
28 28
 	// Which database are we using (depending on the $content parameter)
29
-	if ($content=='user')
29
+	if ($content == 'user')
30 30
 	{
31
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
31
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
32 32
 		$id_field = user_id;
33 33
 	}
34
-	if ($content=='group')
34
+	if ($content == 'group')
35 35
 	{
36
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
36
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
37 37
 		$id_field = group_id;
38 38
 	}
39
-	if ($content=='role')
39
+	if ($content == 'role')
40 40
 	{
41
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
41
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
42 42
 		$id_field = role_id;
43 43
 	}
44 44
 
45 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);
46
+	$sql = "DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
+	$result = Database::query($sql);
48 48
 
49 49
 	// looping through the post values to find the permission (containing the string permission* )
50 50
 	foreach ($_POST as $key => $value)
51 51
 	{
52
-		if (strstr($key,"permission*"))
52
+		if (strstr($key, "permission*"))
53 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);
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 57
 		}
58 58
 	}
59 59
 	return get_lang('PermissionsStored');
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 * @author Patrick Cool <[email protected]>, Ghent University
70 70
 * @version 1.0
71 71
 */
72
-function store_one_permission($content, $action, $id, $tool,$permission) {
72
+function store_one_permission($content, $action, $id, $tool, $permission) {
73 73
 	global $rights_full;
74 74
     $course_id = api_get_course_int_id();
75 75
 	// for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
@@ -82,35 +82,35 @@  discard block
 block discarded – undo
82 82
 
83 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);
85
+	if ($content == 'user') {
86
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
87 87
 		$id_field = user_id;
88 88
 	}
89
-	if ($content=='group')
89
+	if ($content == 'group')
90 90
 	{
91
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
91
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
92 92
 		$id_field = group_id;
93 93
 	}
94
-	if ($content=='role')
94
+	if ($content == 'role')
95 95
 	{
96
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
96
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
97 97
 		$id_field = role_id;
98 98
 	}
99 99
 
100 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');
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 106
 		}
107 107
 	}
108
-	if ($action=='revoke')
108
+	if ($action == 'revoke')
109 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');
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 114
 		}
115 115
 	}
116 116
 	return $result_message;
@@ -125,44 +125,44 @@  discard block
 block discarded – undo
125 125
 */
126 126
 function get_permissions($content, $id) {
127 127
     $course_id = api_get_course_int_id();
128
-	$currentpermissions=array();
128
+	$currentpermissions = array();
129 129
 	// Which database are we using (depending on the $content parameter)
130 130
     $course_id_condition = " c_id = $course_id AND ";
131 131
 	if ($content == 'user')
132 132
 	{
133
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
133
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
134 134
 		$id_field = 'user_id';
135 135
 	}
136 136
 	elseif ($content == 'group')
137 137
 	{
138
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
138
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
139 139
 		$id_field = 'group_id';
140 140
 	}
141 141
 	elseif ($content == 'role')
142 142
 	{
143
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
143
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
144 144
 		$id_field = 'role_id';
145 145
 	}
146 146
 	elseif ($content == 'platform_role')
147 147
 	{
148
-		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
148
+		$table = Database::get_main_table(TABLE_ROLE_PERMISSION);
149 149
 		$id_field = 'role_id';
150 150
         $course_id_condition = '';
151 151
 	}
152 152
 	elseif ($content == 'task')
153 153
 	{
154
-		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
154
+		$table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155 155
 		$id_field = 'task_id';
156 156
 	}
157 157
 
158 158
 	// finding all the permissions. We store this in a multidimensional array
159 159
 	// where the first dimension is the tool.
160
-	$sql="
161
-		SELECT * FROM " . $table . "
162
-		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
160
+	$sql = "
161
+		SELECT * FROM " . $table."
162
+		WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'";
163 163
 	$result = Database::query($sql);
164 164
 
165
-	while($row = Database::fetch_array($result))
165
+	while ($row = Database::fetch_array($result))
166 166
 		$currentpermissions[$row['tool']][] = $row['action'];
167 167
 
168 168
 	return $currentpermissions;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 */
180 180
 function limited_or_full($current_permissions)
181 181
 {
182
-	if (api_get_setting('permissions')=='limited')
182
+	if (api_get_setting('permissions') == 'limited')
183 183
 	{
184 184
 		foreach ($current_permissions as $tool=>$tool_rights)
185 185
 		{
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 			// if it is visibility or move we have to grant the edit right
188 188
 			foreach ($tool_rights as $key=>$value)
189 189
 			{
190
-				if ($value=='View')
190
+				if ($value == 'View')
191 191
 				{
192 192
 					unset($current_permissions[$tool][$key]);
193 193
 				}
194
-				if ($value=='Visibility' OR $value=='Move')
194
+				if ($value == 'Visibility' OR $value == 'Move')
195 195
 				{
196
-					if (!in_array('Edit',$current_permissions[$tool]))
196
+					if (!in_array('Edit', $current_permissions[$tool]))
197 197
 					{
198
-						$current_permissions[$tool][]='Edit';
198
+						$current_permissions[$tool][] = 'Edit';
199 199
 					}
200 200
 					unset($current_permissions[$tool][$key]);
201 201
 				}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		}
208 208
 		return $current_permissions;
209 209
 	}
210
-	if (api_get_setting('permissions')=='full')
210
+	if (api_get_setting('permissions') == 'full')
211 211
 	{
212 212
 		return $current_permissions;
213 213
 	}
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 * @author Patrick Cool <[email protected]>, Ghent University
223 223
 * @version 1.0
224 224
 */
225
-function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array())
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]))
227
+	$checked = "";
228
+	if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool]))
229 229
 	{
230
-		$checked="checked";
230
+		$checked = "checked";
231 231
 	}
232 232
 	echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
233 233
 
@@ -243,28 +243,28 @@  discard block
 block discarded – undo
243 243
 * @author Patrick Cool <[email protected]>, Ghent University
244 244
 * @version 1.0
245 245
 */
246
-function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
246
+function display_image_matrix($permission_array, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true)
247 247
 {
248 248
 	if ($course_admin) {
249 249
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250 250
 	} else {
251
-		if (in_array($permission,$inherited_permissions[$tool])) {
251
+		if (in_array($permission, $inherited_permissions[$tool])) {
252 252
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253 253
 		} else {
254
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
254
+			if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) {
255 255
 				if ($editable) {
256
-					$url=api_get_self();
256
+					$url = api_get_self();
257 257
 					$urlparameters = '';
258
-					foreach($_GET as $key=>$value) {
259
-						$parameter[$key]=$value;
258
+					foreach ($_GET as $key=>$value) {
259
+						$parameter[$key] = $value;
260 260
 					}
261
-					$parameter['action']='revoke';
262
-					$parameter['permission']=$permission;
263
-					$parameter['tool']=$tool;
261
+					$parameter['action'] = 'revoke';
262
+					$parameter['permission'] = $permission;
263
+					$parameter['tool'] = $tool;
264 264
 					foreach ($parameter as $key=>$value) {
265
-						$urlparameters.=$key.'='.$value.'&amp;';
265
+						$urlparameters .= $key.'='.$value.'&amp;';
266 266
 					}
267
-					$url=$url.'?'.$urlparameters;
267
+					$url = $url.'?'.$urlparameters;
268 268
 
269 269
 					echo "\t\t\t <a href=\"".$url."\">";
270 270
 				}
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
 			} else {
276 276
 				if ($editable)
277 277
 				{
278
-					$url=api_get_self();
278
+					$url = api_get_self();
279 279
 					$urlparameters = '';
280 280
 					foreach ($_GET as $key=>$value)
281 281
 					{
282
-						$parameter[$key]=$value;
282
+						$parameter[$key] = $value;
283 283
 					}
284
-					$parameter['action']='grant';
285
-					$parameter['permission']=$permission;
286
-					$parameter['tool']=$tool;
284
+					$parameter['action'] = 'grant';
285
+					$parameter['permission'] = $permission;
286
+					$parameter['tool'] = $tool;
287 287
 					foreach ($parameter as $key=>$value)
288 288
 					{
289
-						$urlparameters.=$key.'='.$value.'&amp;';
289
+						$urlparameters .= $key.'='.$value.'&amp;';
290 290
 					}
291
-					$url=$url.'?'.$urlparameters;
291
+					$url = $url.'?'.$urlparameters;
292 292
 
293 293
 					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294 294
 					echo "\t\t\t <a href=\"".$url."\">";
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 * @author Patrick Cool <[email protected]>, Ghent University
316 316
 * @version 1.0
317 317
 */
318
-function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
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 321
 	if ($course_admin)
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 	else
326 326
 	{
327
-		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
327
+		if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool]))
328 328
 		{
329 329
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330 330
 		}
331 331
 		else
332 332
 		{
333
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
333
+			if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool]))
334 334
 			{
335 335
 				if ($editable)
336 336
 				{
337 337
 					$url = api_get_self();
338 338
 					$urlparameters = '';
339
-					foreach($_GET as $key => $value)
339
+					foreach ($_GET as $key => $value)
340 340
 					{
341 341
 						$parameter[$key] = $value;
342 342
 					}
343
-					$parameter['action']='manage_rights';
344
-					$parameter['do']='revoke';
345
-					$parameter['permission']=$permission;
346
-					$parameter['tool']=$tool;
347
-					$parameter['user_id']=$user_id;
343
+					$parameter['action'] = 'manage_rights';
344
+					$parameter['do'] = 'revoke';
345
+					$parameter['permission'] = $permission;
346
+					$parameter['tool'] = $tool;
347
+					$parameter['user_id'] = $user_id;
348 348
 					foreach ($parameter as $key=>$value)
349 349
 					{
350
-						$urlparameters .= $key . '=' . $value . '&amp;';
350
+						$urlparameters .= $key.'='.$value.'&amp;';
351 351
 					}
352
-					$url = $url . '?' . $urlparameters;
352
+					$url = $url.'?'.$urlparameters;
353 353
 
354 354
 					echo "\t\t\t <a href=\"".$url."\">";
355 355
 				}
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 					$url = api_get_self();
363 363
 					$urlparameters = '';
364 364
 					foreach ($_GET as $key=>$value) {
365
-						$parameter[$key]=$value;
365
+						$parameter[$key] = $value;
366 366
 					}
367
-					$parameter['action']='manage_rights';
368
-					$parameter['do']='grant';
369
-					$parameter['permission']=$permission;
370
-					$parameter['tool']=$tool;
371
-					$parameter['user_id']=$user_id;
367
+					$parameter['action'] = 'manage_rights';
368
+					$parameter['do'] = 'grant';
369
+					$parameter['permission'] = $permission;
370
+					$parameter['tool'] = $tool;
371
+					$parameter['user_id'] = $user_id;
372 372
 					foreach ($parameter as $key=>$value) {
373
-						$urlparameters .= $key . '=' . $value . '&amp;';
373
+						$urlparameters .= $key.'='.$value.'&amp;';
374 374
 					}
375
-					$url=$url.'?'.$urlparameters;
375
+					$url = $url.'?'.$urlparameters;
376 376
 
377 377
 					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378 378
 					echo "\t\t\t <a href=\"".$url."\">";
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 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";
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
 	}
431 431
 */
432 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))
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 436
 	{
437 437
 		if (in_array($row['role_id'], $current_course_roles))
438 438
 		{
439
-			$checked='checked';
440
-			$image='checkbox_on2.gif';
441
-			$action='revoke';
439
+			$checked = 'checked';
440
+			$image = 'checkbox_on2.gif';
441
+			$action = 'revoke';
442 442
 		}
443 443
 		else
444 444
 		{
445
-			$checked='';
446
-			$image='wrong.gif';
447
-			$action='grant';
445
+			$checked = '';
446
+			$image = 'wrong.gif';
447
+			$action = 'grant';
448 448
 		}
449
-		if ($setting_visualisation=='checkbox')
449
+		if ($setting_visualisation == 'checkbox')
450 450
 		{
451 451
 			echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
452 452
 		}
453
-		if ($setting_visualisation=='image')
453
+		if ($setting_visualisation == 'image')
454 454
 		{
455 455
 			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>";
456 456
 		}
@@ -470,24 +470,24 @@  discard block
 block discarded – undo
470 470
 * @author Patrick Cool <[email protected]>, Ghent University
471 471
 * @version 1.0
472 472
 */
473
-function get_roles($content,$id, $scope='course') {
474
-    $course_id  = api_get_course_int_id();    
475
-	if ($content=='user') {
476
-		$table=Database::get_course_table(TABLE_ROLE_USER);
473
+function get_roles($content, $id, $scope = 'course') {
474
+    $course_id = api_get_course_int_id();    
475
+	if ($content == 'user') {
476
+		$table = Database::get_course_table(TABLE_ROLE_USER);
477 477
 		$id_field = user_id;
478 478
 	}
479
-	if ($content=='group') {
480
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
479
+	if ($content == 'group') {
480
+		$table = Database::get_course_table(TABLE_ROLE_GROUP);
481 481
 		$id_field = 'group_id';
482 482
 	}
483
-	$table_role=Database::get_course_table(TABLE_ROLE);
483
+	$table_role = Database::get_course_table(TABLE_ROLE);
484 484
 
485
-	$current_roles=array();
485
+	$current_roles = array();
486 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'];
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 491
 	}
492 492
 	return $current_roles;
493 493
 }
@@ -498,26 +498,26 @@  discard block
 block discarded – undo
498 498
 * @author Patrick Cool <[email protected]>, Ghent University
499 499
 * @version 1.0
500 500
 */
501
-function get_all_roles($content='course') {
501
+function get_all_roles($content = 'course') {
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')
505
+	if ($content == 'course')
506 506
 	{
507
-		$table_role=Database::get_course_table(TABLE_ROLE);
507
+		$table_role = Database::get_course_table(TABLE_ROLE);
508 508
 	}
509
-	if ($content=='platform')
509
+	if ($content == 'platform')
510 510
 	{
511
-		$table_role=Database::get_main_table(TABLE_ROLE);
511
+		$table_role = Database::get_main_table(TABLE_ROLE);
512 512
 		$course_id_condition = '';
513 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))
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 519
 	{
520
-		$roles[]=$row;
520
+		$roles[] = $row;
521 521
 	}
522 522
 
523 523
 	return $roles;
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 * @author Patrick Cool <[email protected]>, Ghent University
535 535
 * @version 1.0
536 536
 */
537
-function get_roles_permissions($content,$id, $scope='course') {
537
+function get_roles_permissions($content, $id, $scope = 'course') {
538 538
     $course_id = api_get_course_int_id();
539 539
 	if ($content == 'user') {
540
-		$table=Database::get_course_table(TABLE_ROLE_USER);
540
+		$table = Database::get_course_table(TABLE_ROLE_USER);
541 541
 		$id_field = 'user_id';
542 542
 	}
543 543
 
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 	$sql = "
567 567
 		SELECT *
568 568
 		FROM
569
-			" . $table . " role_group_user,
570
-			" . $table_role . " role,
571
-			" . $table_role_permissions . " role_permissions
569
+			" . $table." role_group_user,
570
+			" . $table_role." role,
571
+			" . $table_role_permissions." role_permissions
572 572
 		WHERE
573 573
 		    role_group_user.c_id = $course_id AND
574 574
 		    $role_condition
575
-			role_group_user.scope = '" . $scope . "' AND
576
-			role_group_user." . $id_field . " = '" . $id . "' AND
575
+			role_group_user.scope = '".$scope."' AND
576
+			role_group_user." . $id_field." = '".$id."' AND
577 577
 			role_group_user.role_id = role.role_id AND
578 578
 			role.role_id = role_permissions.role_id";
579 579
 
580 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 585
 	return $current_role_permissions;
586 586
 }
@@ -594,33 +594,33 @@  discard block
 block discarded – undo
594 594
 * @author Patrick Cool <[email protected]>, Ghent University
595 595
 */
596 596
 
597
-function assign_role($content, $action, $id, $role_id, $scope='course') {
597
+function assign_role($content, $action, $id, $role_id, $scope = 'course') {
598 598
     $course_id = api_get_course_int_id();
599 599
 	// Which database are we using (depending on the $content parameter)
600
-	if ($content=='user') {
601
-		$table=Database::get_course_table(TABLE_ROLE_USER);
600
+	if ($content == 'user') {
601
+		$table = Database::get_course_table(TABLE_ROLE_USER);
602 602
 		$id_field = 'user_id';
603
-	} elseif($content=='group') {
604
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
603
+	} elseif ($content == 'group') {
604
+		$table = Database::get_course_table(TABLE_ROLE_GROUP);
605 605
 		$id_field = 'group_id';
606 606
 	} else {
607 607
 		return  get_lang('Error');
608 608
 	}
609 609
 
610 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);
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 614
 		if ($result) {
615
-			$result_message=get_lang('RoleGranted');
615
+			$result_message = get_lang('RoleGranted');
616 616
 		}
617 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);
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 622
 		if ($result) {
623
-			$result_message=get_lang('RoleRevoked');
623
+			$result_message = get_lang('RoleRevoked');
624 624
 		}
625 625
 	}
626 626
 	return $result_message;
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	{
638 638
 		foreach ($permissions as $permissionkey=>$permissionvalue)
639 639
 		{
640
-			$array1[$tool][]=$permissionvalue;
640
+			$array1[$tool][] = $permissionvalue;
641 641
 		}
642 642
 	}
643 643
 	return $array1;
Please login to merge, or discard this patch.