Passed
Push — 1.10.x ( 5654d2...115d5a )
by Yannick
263:14 queued 212:07
created
main/permissions/group_permissions.inc.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
main/permissions/blog_permissions.inc.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		WHERE status = '1' AND c_id = '".api_get_course_int_id()."'";
50 50
 $result = Database::query($sql);
51 51
 while ($user = Database::fetch_assoc($result)) {
52
-	unset($blog_users[$user['user_id']]);
52
+    unset($blog_users[$user['user_id']]);
53 53
 }
54 54
 
55 55
 //$user_id=$userIdViewed;
@@ -84,30 +84,30 @@  discard block
 block discarded – undo
84 84
 // 			RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER
85 85
 // ------------------------------------------------------------------
86 86
 if (api_get_setting('user_roles')=='true') {
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);
90
-	// NOTE: deze array moet nog gemerged worden met de $inherited_permissions array
91
-	// (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de
92
-	// groepsge�rfde permissions in beschouwing worden genomen
93
-	// dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker
94
-	// en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker
95
-	// omvatten.
96
-	// NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal
97
-	// ophalen.
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);
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);
90
+    // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array
91
+    // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de
92
+    // groepsge�rfde permissions in beschouwing worden genomen
93
+    // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker
94
+    // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker
95
+    // omvatten.
96
+    // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal
97
+    // ophalen.
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);
101 101
 }
102 102
 // ------------------------------------------------------------------
103 103
 //	RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER
104 104
 // ------------------------------------------------------------------
105 105
 if (api_get_setting('group_roles')=='true') {
106
-	// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
107
-	foreach ($groups_of_user as $group) {
108
-		$this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
109
-		//$inherited_permissions[$tool][]=$permission;
110
-	}
106
+    // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
107
+    foreach ($groups_of_user as $group) {
108
+        $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
109
+        //$inherited_permissions[$tool][]=$permission;
110
+    }
111 111
 }
112 112
 
113 113
 echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 
119 119
 if (api_get_setting('user_roles')=='true')
120 120
 {
121
-	// the list of the roles for the user
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');
125
-	display_role_list($current_user_course_roles, $current_user_platform_roles);
126
-	echo '<br />';
121
+    // the list of the roles for the user
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');
125
+    display_role_list($current_user_course_roles, $current_user_platform_roles);
126
+    echo '<br />';
127 127
 }
128 128
 
129 129
 // ---------------------------------------------------
@@ -133,59 +133,59 @@  discard block
 block discarded – undo
133 133
 
134 134
 // the header
135 135
 echo "\t<tr>\n";
136
-	echo "\t\t<th rowspan=\"2\">".get_lang('Module')."</th>\n";
137
-	echo "\t\t<th colspan=\"4\">".get_lang('ArticleManager')."</th>\n";
138
-	echo "\t\t<th colspan=\"3\">".get_lang('CommentManager')."</th>\n";
139
-	echo "\t\t<th colspan=\"3\">".get_lang('BlogManager')."</th>\n";
136
+    echo "\t\t<th rowspan=\"2\">".get_lang('Module')."</th>\n";
137
+    echo "\t\t<th colspan=\"4\">".get_lang('ArticleManager')."</th>\n";
138
+    echo "\t\t<th colspan=\"3\">".get_lang('CommentManager')."</th>\n";
139
+    echo "\t\t<th colspan=\"3\">".get_lang('BlogManager')."</th>\n";
140 140
 echo "\t</tr>\n";
141 141
 
142 142
 // Subheader
143 143
 echo "\t<tr>\n";
144
-	echo "\t\t<th align='center'>".get_lang('Add')."</th>\n";
145
-	echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n";
146
-	echo "\t\t<th align='center'>".get_lang('Edit')."</th>\n";
147
-	echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n";
148
-	echo "\t\t<th align='center'>".get_lang('Add')."</th>\n";
149
-	echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n";
150
-	echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n";
151
-	echo "\t\t<th align='center'>".get_lang('Tasks')."</th>\n";
152
-	echo "\t\t<th align='center'>".get_lang('Members')."</th>\n";
153
-	echo "\t\t<th align='center'>".get_lang('Roles')."</th>\n";
144
+    echo "\t\t<th align='center'>".get_lang('Add')."</th>\n";
145
+    echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n";
146
+    echo "\t\t<th align='center'>".get_lang('Edit')."</th>\n";
147
+    echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n";
148
+    echo "\t\t<th align='center'>".get_lang('Add')."</th>\n";
149
+    echo "\t\t<th align='center'>".get_lang('Delete')."</th>\n";
150
+    echo "\t\t<th align='center'>".get_lang('Rate')."</th>\n";
151
+    echo "\t\t<th align='center'>".get_lang('Tasks')."</th>\n";
152
+    echo "\t\t<th align='center'>".get_lang('Members')."</th>\n";
153
+    echo "\t\t<th align='center'>".get_lang('Roles')."</th>\n";
154 154
 echo "\t</tr>\n";
155 155
 
156 156
 // the main area with the checkboxes or images
157 157
 foreach ($blog_users as $user_id => $user_name) { // $blog_users contains all the users in this blog
158
-	// ---------------------------------------------------
159
-	// 			RETRIEVING THE PERMISSIONS OF THE USER
160
-	// ---------------------------------------------------
161
-	$current_user_permissions = array();
162
-	$current_user_permissions = get_permissions('user', $user_id);
163
-
164
-	echo "\t<tr>\n";
165
-	echo "\t\t<td>\n";
166
-	echo $user_name;
167
-	echo "\t\t</td>\n";
168
-
169
-	foreach ($rights_full as $key => $value) {
170
-
171
-		echo "\t\t<td align='center'>\n";
172
-		if (in_array($value,$rights_blog)) {
173
-			display_image_matrix_for_blogs(
174
-				$current_user_permissions,
175
-				$user_id,
176
-				'BLOG_'.$blog_id,
177
-				$value,
178
-				(isset($inherited_permissions) ? $inherited_permissions : null),
179
-				(isset($course_admin) ? $course_admin : null)
180
-			);
181
-		}
182
-		// note: in a later stage this part will be replaced by a function
183
-		// so that we can easily switch between a checkbox approach or an image approach
184
-		// where every click is in fact a change of status. In the checkbox approach you first have to
185
-		// do the changes and then store them by clicking the submit button.
186
-		echo "\t\t</td>\n";
187
-	}
188
-	echo "\t</tr>\n";
158
+    // ---------------------------------------------------
159
+    // 			RETRIEVING THE PERMISSIONS OF THE USER
160
+    // ---------------------------------------------------
161
+    $current_user_permissions = array();
162
+    $current_user_permissions = get_permissions('user', $user_id);
163
+
164
+    echo "\t<tr>\n";
165
+    echo "\t\t<td>\n";
166
+    echo $user_name;
167
+    echo "\t\t</td>\n";
168
+
169
+    foreach ($rights_full as $key => $value) {
170
+
171
+        echo "\t\t<td align='center'>\n";
172
+        if (in_array($value,$rights_blog)) {
173
+            display_image_matrix_for_blogs(
174
+                $current_user_permissions,
175
+                $user_id,
176
+                'BLOG_'.$blog_id,
177
+                $value,
178
+                (isset($inherited_permissions) ? $inherited_permissions : null),
179
+                (isset($course_admin) ? $course_admin : null)
180
+            );
181
+        }
182
+        // note: in a later stage this part will be replaced by a function
183
+        // so that we can easily switch between a checkbox approach or an image approach
184
+        // where every click is in fact a change of status. In the checkbox approach you first have to
185
+        // do the changes and then store them by clicking the submit button.
186
+        echo "\t\t</td>\n";
187
+    }
188
+    echo "\t</tr>\n";
189 189
 }
190 190
 
191 191
 echo "</table>\n";
Please login to merge, or discard this patch.
main/permissions/permissions_functions.inc.php 1 patch
Indentation   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.'&amp;';
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.'&amp;';
290
-					}
291
-					$url=$url.'?'.$urlparameters;
292
-
293
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;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.'&amp;';
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.'&amp;';
290
+                    }
291
+                    $url=$url.'?'.$urlparameters;
292
+
293
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;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
 block discarded – undo
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 . '&amp;';
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 . '&amp;';
374
-					}
375
-					$url=$url.'?'.$urlparameters;
376
-
377
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;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 . '&amp;';
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 . '&amp;';
374
+                    }
375
+                    $url=$url.'?'.$urlparameters;
376
+
377
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;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
 block discarded – undo
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
 block discarded – undo
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('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;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']."&amp;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('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;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']."&amp;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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
main/permissions/user_permissions.inc.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @package chamilo.permissions
4
- */
3
+     * @package chamilo.permissions
4
+     */
5 5
 /**
6
- * Code
7
- */
6
+     * Code
7
+     */
8 8
 $user_id=$userIdViewed;
9 9
 if ($mainUserInfo['status']==1)
10 10
 {
11
-	$course_admin=1;
11
+    $course_admin=1;
12 12
 }
13 13
 include_once('permissions_functions.inc.php');
14 14
 include_once('all_permissions.inc.php');
@@ -19,26 +19,26 @@  discard block
 block discarded – undo
19 19
 // ---------------------------------------------------
20 20
 if ($_POST['StoreUserPermissions'] and $setting_visualisation=='checkbox')
21 21
 {
22
-	$result_message=store_permissions('user', $user_id);
23
-	if ($result_message)
24
-	{
25
-		Display::display_normal_message($result_message);
26
-	}
22
+    $result_message=store_permissions('user', $user_id);
23
+    if ($result_message)
24
+    {
25
+        Display::display_normal_message($result_message);
26
+    }
27 27
 }
28 28
 if (isset($_GET['action']))
29 29
 {
30
-	if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
31
-	{
32
-		$result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']);
33
-	}
34
-	if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
35
-	{
36
-		$result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']);
37
-	}
30
+    if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
31
+    {
32
+        $result_message=store_one_permission('user', $_GET['action'], $user_id, $_GET['tool'], $_GET['permission']);
33
+    }
34
+    if (isset($_GET['role']) AND ($_GET['action']=='grant' OR $_GET['action']=='revoke'))
35
+    {
36
+        $result_message=assign_role('user', $_GET['action'], $user_id, $_GET['role'], $_GET['scope']);
37
+    }
38 38
 }
39 39
 if (isset($result_message))
40 40
 {
41
-	Display::display_normal_message($result_message);
41
+    Display::display_normal_message($result_message);
42 42
 }
43 43
 
44 44
 // ---------------------------------------------------
@@ -55,43 +55,43 @@  discard block
 block discarded – undo
55 55
 $groups_of_user=GroupManager::get_group_ids($_course['real_id'],$user_id);
56 56
 foreach ($groups_of_user as $group)
57 57
 {
58
-	$this_group_permissions=get_permissions('group',$group);
59
-	foreach ($this_group_permissions as $tool=>$permissions)
60
-	{
61
-		foreach ($permissions as $permission)
62
-		{
63
-			$inherited_group_permissions[$tool][]=$permission;
64
-		}
65
-	}
58
+    $this_group_permissions=get_permissions('group',$group);
59
+    foreach ($this_group_permissions as $tool=>$permissions)
60
+    {
61
+        foreach ($permissions as $permission)
62
+        {
63
+            $inherited_group_permissions[$tool][]=$permission;
64
+        }
65
+    }
66 66
 }
67 67
 $inherited_permissions=$inherited_group_permissions;
68 68
 
69 69
 // 			RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER
70 70
 if (api_get_setting('user_roles')=='true') {
71
-	// course roles that are assigned to the user
72
-	$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id);
73
-	$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
74
-	// NOTE: deze array moet nog gemerged worden met de $inherited_permissions array
75
-	// (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de
76
-	// groepsge�rfde permissions in beschouwing worden genomen
77
-	// dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker
78
-	// en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker
79
-	// omvatten.
80
-	// NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal
81
-	// ophalen.
82
-	// platform roles that are assigned to the user
83
-	$current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform');
84
-	$inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
71
+    // course roles that are assigned to the user
72
+    $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id);
73
+    $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
74
+    // NOTE: deze array moet nog gemerged worden met de $inherited_permissions array
75
+    // (heet momenteel nog $current_group_permissions_of_user omdat voorlopig enkel de
76
+    // groepsge�rfde permissions in beschouwing worden genomen
77
+    // dit moet ook de rol permissies van rollen die toegekend worden aan een gebruiker
78
+    // en de rol permissies van rollen die toegekend worden aan de groepen van een gebruiker
79
+    // omvatten.
80
+    // NOTE: checken als de rollen brol wel degelijk geactiveerd is voordat we dit allemaal
81
+    // ophalen.
82
+    // platform roles that are assigned to the user
83
+    $current_user_role_permissions_of_user=get_roles_permissions('user',$user_id, 'platform');
84
+    $inherited_permissions=permission_array_merge($inherited_permissions,$current_user_role_permissions_of_user);
85 85
 }
86 86
 //	RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER
87 87
 if (api_get_setting('group_roles')=='true')
88 88
 {
89
-	// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
90
-	foreach ($groups_of_user as $group)
91
-	{
92
-		$this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
93
-		//$inherited_permissions[$tool][]=$permission;
94
-	}
89
+    // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
90
+    foreach ($groups_of_user as $group)
91
+    {
92
+        $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
93
+        //$inherited_permissions[$tool][]=$permission;
94
+    }
95 95
 }
96 96
 
97 97
 // ---------------------------------------------------
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 $inherited_permissions=limited_or_full($inherited_permissions);
102 102
 if (api_get_setting('permissions')=='limited')
103 103
 {
104
-	$header_array=$rights_limited;
104
+    $header_array=$rights_limited;
105 105
 }
106 106
 if (api_get_setting('permissions')=='full')
107 107
 {
108
-	$header_array=$rights_full;
108
+    $header_array=$rights_full;
109 109
 }
110 110
 
111 111
 
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 // ---------------------------------------------------
117 117
 if (api_get_setting('user_roles')=='true')
118 118
 {
119
-	// the list of the roles for the user
120
-	echo '<strong>'.get_lang('UserRoles').'</strong><br />';
121
-	$current_user_course_roles=get_roles('user',$user_id);
122
-	$current_user_platform_roles=get_roles('user',$user_id, 'platform');
123
-	display_role_list($current_user_course_roles, $current_user_platform_roles);
124
-	echo '<br />';
119
+    // the list of the roles for the user
120
+    echo '<strong>'.get_lang('UserRoles').'</strong><br />';
121
+    $current_user_course_roles=get_roles('user',$user_id);
122
+    $current_user_platform_roles=get_roles('user',$user_id, 'platform');
123
+    display_role_list($current_user_course_roles, $current_user_platform_roles);
124
+    echo '<br />';
125 125
 }
126 126
 
127 127
 // ---------------------------------------------------
@@ -135,59 +135,59 @@  discard block
 block discarded – undo
135 135
 echo "\t\t<th>".get_lang('Module')."</th>\n";
136 136
 foreach ($header_array as $header_key=>$header_value)
137 137
 {
138
-	echo "\t\t<th>".get_lang($header_value)."</th>\n";
138
+    echo "\t\t<th>".get_lang($header_value)."</th>\n";
139 139
 }
140 140
 echo "\t</tr>\n";
141 141
 
142 142
 // the main area with the checkboxes or images
143 143
 foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
144 144
 {
145
-	echo "\t<tr>\n";
146
-	echo "\t\t<td>\n";
147
-	if (strstr($tool,'BLOG'))
148
-	{
149
-		// Not dealing with a real tool here, get name of this blog
150
-		// Strip blog id
151
-		$tmp = strpos($tool,'_')+1;
152
-		$blog_id = substr($tool,$tmp,strlen($tool));
153
-		// Get title
154
-		echo get_lang('Blog').": ".Blog::get_blog_title($blog_id);
155
-	}
156
-	else
157
-	{
158
-		echo get_lang($tool);
159
-	}
160
-
161
-	echo "\t\t</td>\n";
162
-
163
-	foreach ($header_array as $key=>$value)
164
-	{
165
-
166
-		echo "\t\t<td align='center'>\n";
167
-		if (in_array($value,$rights))
168
-		{
169
-			if ($setting_visualisation=='checkbox')
170
-			{
171
-				display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions,$course_admin);
172
-			}
173
-			if ($setting_visualisation=='image')
174
-			{
175
-				display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin);
176
-			}
177
-		}
178
-		// note: in a later stage this part will be replaced by a function
179
-		// so that we can easily switch between a checkbox approach or an image approach
180
-		// where every click is in fact a change of status. In the checkbox approach you first have to
181
-		// do the changes and then store them by clicking the submit button.
182
-		echo "\t\t</td>\n";
183
-	}
184
-	echo "\t</tr>\n";
145
+    echo "\t<tr>\n";
146
+    echo "\t\t<td>\n";
147
+    if (strstr($tool,'BLOG'))
148
+    {
149
+        // Not dealing with a real tool here, get name of this blog
150
+        // Strip blog id
151
+        $tmp = strpos($tool,'_')+1;
152
+        $blog_id = substr($tool,$tmp,strlen($tool));
153
+        // Get title
154
+        echo get_lang('Blog').": ".Blog::get_blog_title($blog_id);
155
+    }
156
+    else
157
+    {
158
+        echo get_lang($tool);
159
+    }
160
+
161
+    echo "\t\t</td>\n";
162
+
163
+    foreach ($header_array as $key=>$value)
164
+    {
165
+
166
+        echo "\t\t<td align='center'>\n";
167
+        if (in_array($value,$rights))
168
+        {
169
+            if ($setting_visualisation=='checkbox')
170
+            {
171
+                display_checkbox_matrix($current_user_permissions, $tool, $value, $inherited_permissions,$course_admin);
172
+            }
173
+            if ($setting_visualisation=='image')
174
+            {
175
+                display_image_matrix($current_user_permissions, $tool, $value,$inherited_permissions, $course_admin);
176
+            }
177
+        }
178
+        // note: in a later stage this part will be replaced by a function
179
+        // so that we can easily switch between a checkbox approach or an image approach
180
+        // where every click is in fact a change of status. In the checkbox approach you first have to
181
+        // do the changes and then store them by clicking the submit button.
182
+        echo "\t\t</td>\n";
183
+    }
184
+    echo "\t</tr>\n";
185 185
 }
186 186
 
187 187
 echo "</table>\n";
188 188
 if ($setting_visualisation=='checkbox')
189 189
 {
190
-	echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">";
190
+    echo "<input type=\"Submit\" name=\"StoreUserPermissions\" value=\"".get_lang('StorePermissions')."\">";
191 191
 }
192 192
 echo "</form><br />";
193 193
 
Please login to merge, or discard this patch.
main/webservices/webservice_report.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class WSReport extends WS {
13 13
 
14
-	/**
15
-	 * Gets the time spent on the platform by a given user
16
-	 *
17
-	 * @param string User id field name
18
-	 * @param string User id value
14
+    /**
15
+     * Gets the time spent on the platform by a given user
16
+     *
17
+     * @param string User id field name
18
+     * @param string User id value
19 19
      * @return array Array of results
20
-	 */
21
-	public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) {
22
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
24
-			return $user_id;
25
-		} else {
20
+     */
21
+    public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) {
22
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
+        if($user_id instanceof WSError) {
24
+            return $user_id;
25
+        } else {
26 26
             return Tracking::get_time_spent_on_the_platform($user_id);
27
-		}
28
-	}
27
+        }
28
+    }
29 29
 
30
-	/**
30
+    /**
31 31
      * Gets the time spent in a course by a given user
32
-	 *
32
+     *
33 33
      * @param string User id field name
34 34
      * @param string User id value
35 35
      * @param string Course id field name
36 36
      * @param string Course id value
37
-	 * @return array Array of results
38
-	 */
39
-	public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) {
37
+     * @return array Array of results
38
+     */
39
+    public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) {
40 40
         $user_id = $this->getUserId($user_id_field_name, $user_id_value);
41 41
         if($user_id instanceof WSError) {
42 42
             return $user_id;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             $course_code = CourseManager::get_course_code_from_course_id($course_id);
49 49
         }
50 50
         return Tracking::get_time_spent_on_the_course($user_id, $course_id);
51
-	}
51
+    }
52 52
 
53 53
     /**
54 54
      * Gets the time spent in a course by a given user
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
         }
129 129
         $lp = new learnpath($course_code, $learnpath_id, $user_id);
130 130
         $return = array(
131
-          'progress_bar_mode' => $lp->progress_bar_mode,
132
-          'progress_db' => $lp->progress_db,
131
+            'progress_bar_mode' => $lp->progress_bar_mode,
132
+            'progress_db' => $lp->progress_db,
133 133
         );
134 134
         return $return;
135 135
     }
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 
192 192
         $lp = new learnpath($course_code, $learnpath_id, $user_id);
193 193
         $return = array(
194
-          'min_score' => $lp->items[$learnpath_item_id]->min_score,
195
-          'max_score' => $lp->items[$learnpath_item_id]->max_score,
196
-          'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score,
197
-          'current_score' => $lp->items[$learnpath_item_id]->current_score,
194
+            'min_score' => $lp->items[$learnpath_item_id]->min_score,
195
+            'max_score' => $lp->items[$learnpath_item_id]->max_score,
196
+            'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score,
197
+            'current_score' => $lp->items[$learnpath_item_id]->current_score,
198 198
         );
199 199
         return $return;
200 200
     }
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4930,9 +4930,9 @@
 block discarded – undo
4930 4930
     'This service unsubscribe a user from a course'                     // documentation
4931 4931
 );
4932 4932
 /**
4933
- * @param array $params
4934
- * @return array|null|soap_fault
4935
- */
4933
+     * @param array $params
4934
+     * @return array|null|soap_fault
4935
+     */
4936 4936
 function WSUnSubscribeUserFromCourseSimple($params)
4937 4937
 {
4938 4938
     global $debug;
Please login to merge, or discard this patch.
main/webservices/soap.test.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php /* For licensing terms, see /license.txt */
2 2
 /**
3
- * Test script for soap.php
4
- * @author Yannick Warnier <[email protected]>
5
- * @package chamilo.webservices
6
- */
3
+     * Test script for soap.php
4
+     * @author Yannick Warnier <[email protected]>
5
+     * @package chamilo.webservices
6
+     */
7 7
 /**
8
- * Init
9
- */
8
+     * Init
9
+     */
10 10
 exit; //remove to enable
11 11
 // Include the necessary files, assuming this script is located in main/newscorm/ or something like that
12 12
 require_once '../inc/global.inc.php';
Please login to merge, or discard this patch.
main/webservices/webservice.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @package chamilo.webservices
5
- */
4
+     * @package chamilo.webservices
5
+     */
6 6
 require_once(dirname(__FILE__).'/../inc/global.inc.php');
7 7
 
8 8
 /**
@@ -11,237 +11,237 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class WSError
13 13
 {
14
-	/**
15
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
-	 *
17
-	 * @var WSErrorHandler
18
-	 */
19
-	protected static $_handler;
20
-
21
-	/**
22
-	 * Error code
23
-	 *
24
-	 * @var int
25
-	 */
26
-	public $code;
27
-
28
-	/**
29
-	 * Error message
30
-	 *
31
-	 * @var string
32
-	 */
33
-	public $message;
34
-
35
-	/**
36
-	 * Constructor
37
-	 *
38
-	 * @param int Error code
39
-	 * @param string Error message
40
-	 */
41
-	public function __construct($code, $message) {
42
-		$this->code = $code;
43
-		$this->message = $message;
44
-	}
45
-
46
-	/**
47
-	 * Sets the error handler
48
-	 *
49
-	 * @param WSErrorHandler Error handler
50
-	 */
51
-	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
53
-			self::$_handler = $handler;
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Returns the error handler
59
-	 *
60
-	 * @return WSErrorHandler Error handler
61
-	 */
62
-	public static function getErrorHandler() {
63
-		return self::$_handler;
64
-	}
65
-
66
-	/**
67
-	 * Transforms the error into an array
68
-	 *
69
-	 * @return array Associative array with code and message
70
-	 */
71
-	public function toArray() {
72
-		return array('code' => $this->code, 'message' => $this->message);
73
-	}
14
+    /**
15
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
+     *
17
+     * @var WSErrorHandler
18
+     */
19
+    protected static $_handler;
20
+
21
+    /**
22
+     * Error code
23
+     *
24
+     * @var int
25
+     */
26
+    public $code;
27
+
28
+    /**
29
+     * Error message
30
+     *
31
+     * @var string
32
+     */
33
+    public $message;
34
+
35
+    /**
36
+     * Constructor
37
+     *
38
+     * @param int Error code
39
+     * @param string Error message
40
+     */
41
+    public function __construct($code, $message) {
42
+        $this->code = $code;
43
+        $this->message = $message;
44
+    }
45
+
46
+    /**
47
+     * Sets the error handler
48
+     *
49
+     * @param WSErrorHandler Error handler
50
+     */
51
+    public static function setErrorHandler($handler) {
52
+        if($handler instanceof WSErrorHandler) {
53
+            self::$_handler = $handler;
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Returns the error handler
59
+     *
60
+     * @return WSErrorHandler Error handler
61
+     */
62
+    public static function getErrorHandler() {
63
+        return self::$_handler;
64
+    }
65
+
66
+    /**
67
+     * Transforms the error into an array
68
+     *
69
+     * @return array Associative array with code and message
70
+     */
71
+    public function toArray() {
72
+        return array('code' => $this->code, 'message' => $this->message);
73
+    }
74 74
 }
75 75
 
76 76
 /**
77 77
  * Interface that must be implemented by any error handler
78 78
  */
79 79
 interface WSErrorHandler {
80
-	/**
81
-	 * Handle method
82
-	 *
83
-	 * @param WSError Error
84
-	 */
85
-	public function handle($error);
80
+    /**
81
+     * Handle method
82
+     *
83
+     * @param WSError Error
84
+     */
85
+    public function handle($error);
86 86
 }
87 87
 
88 88
 /**
89 89
  * Main class of the webservice. Webservice classes extend this class
90 90
  */
91 91
 class WS {
92
-	/**
93
-	 * Chamilo configuration
94
-	 *
95
-	 * @var array
96
-	 */
97
-	protected $_configuration;
98
-
99
-	/**
100
-	 * Constructor
101
-	 */
102
-	public function __construct() {
103
-		$this->_configuration = $GLOBALS['_configuration'];
104
-	}
105
-
106
-	/**
107
-	 * Verifies the API key
108
-	 *
109
-	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
111
-	 */
112
-	protected function verifyKey($secret_key) {
113
-		$ip = trim($_SERVER['REMOTE_ADDR']);
114
-		// if we are behind a reverse proxy, assume it will send the
115
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
116
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
-			$ip = trim($ip1);
119
-		}
120
-		$security_key = $ip.$this->_configuration['security_key'];
121
-
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
-			return new WSError(1, "API key is invalid");
124
-		} else {
125
-			return null;
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Gets the real user id based on the user id field name and value.
131
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
-	 * in the system database
133
-	 *
134
-	 * @param string User id field name
135
-	 * @param string User id value
136
-	 * @return mixed System user id if the user was found, WSError otherwise
137
-	 */
138
-	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
-				return intval($user_id_value);
142
-			} else {
143
-				return new WSError(100, "User not found");
144
-			}
145
-		} else {
146
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
148
-				return new WSError(100, "User not found");
149
-			} else {
150
-				return $user_id;
151
-			}
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the real course id based on the course id field name and value.
157
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
-	 * in the system database
159
-	 *
160
-	 * @param string Course id field name
161
-	 * @param string Course id value
162
-	 * @return mixed System course id if the course was found, WSError otherwise
163
-	 */
164
-	protected function getCourseId($course_id_field_name, $course_id_value)
165
-	{
166
-		if ($course_id_field_name == "chamilo_course_id") {
167
-			if (CourseManager::get_course_code_from_course_id(
168
-					intval($course_id_value)
169
-				) != null
170
-			) {
171
-				return intval($course_id_value);
172
-			} else {
173
-				return new WSError(200, "Course not found");
174
-			}
175
-		} else {
176
-			$courseId = CourseManager::get_course_code_from_original_id(
177
-				$course_id_value,
178
-				$course_id_field_name
179
-			);
180
-			if (!empty($courseId)) {
181
-				return $courseId;
182
-			} else {
183
-				return new WSError(200, "Course not found");
184
-			}
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Gets the real session id based on the session id field name and value.
190
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
-	 * in the system database
192
-	 *
193
-	 * @param string Session id field name
194
-	 * @param string Session id value
195
-	 * @return mixed System session id if the session was found, WSError otherwise
196
-	 */
197
-	protected function getSessionId($session_id_field_name, $session_id_value)
198
-	{
199
-		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
201
-			if (!empty($session)) {
202
-				return intval($session_id_value);
203
-			} else {
204
-				return new WSError(300, "Session not found");
205
-			}
206
-		} else {
207
-			$session_id = SessionManager::getSessionIdFromOriginalId(
208
-				$session_id_value,
209
-				$session_id_field_name
210
-			);
211
-			if ($session_id == 0) {
212
-				return new WSError(300, "Session not found");
213
-			} else {
214
-				return $session_id;
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Handles an error by calling the WSError error handler
221
-	 *
222
-	 * @param WSError Error
223
-	 */
224
-	protected function handleError($error) {
225
-		$handler = WSError::getErrorHandler();
226
-		$handler->handle($error);
227
-	}
228
-
229
-	/**
230
-	 * Gets a successful result
231
-	 *
232
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
233
-	 */
234
-	protected function getSuccessfulResult() {
235
-		return array('code' => 0, 'message' => 'Operation was successful');
236
-	}
237
-
238
-	/**
239
-	 * Test function. Returns the string success
240
-	 *
241
-	 * @return string Success
242
-	 */
243
-	public function test() {
244
-		return "success";
245
-	}
92
+    /**
93
+     * Chamilo configuration
94
+     *
95
+     * @var array
96
+     */
97
+    protected $_configuration;
98
+
99
+    /**
100
+     * Constructor
101
+     */
102
+    public function __construct() {
103
+        $this->_configuration = $GLOBALS['_configuration'];
104
+    }
105
+
106
+    /**
107
+     * Verifies the API key
108
+     *
109
+     * @param string Secret key
110
+     * @return mixed WSError in case of failure, null in case of success
111
+     */
112
+    protected function verifyKey($secret_key) {
113
+        $ip = trim($_SERVER['REMOTE_ADDR']);
114
+        // if we are behind a reverse proxy, assume it will send the
115
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
116
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
+            list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
+            $ip = trim($ip1);
119
+        }
120
+        $security_key = $ip.$this->_configuration['security_key'];
121
+
122
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
+            return new WSError(1, "API key is invalid");
124
+        } else {
125
+            return null;
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Gets the real user id based on the user id field name and value.
131
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
+     * in the system database
133
+     *
134
+     * @param string User id field name
135
+     * @param string User id value
136
+     * @return mixed System user id if the user was found, WSError otherwise
137
+     */
138
+    protected function getUserId($user_id_field_name, $user_id_value) {
139
+        if($user_id_field_name == "chamilo_user_id") {
140
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
+                return intval($user_id_value);
142
+            } else {
143
+                return new WSError(100, "User not found");
144
+            }
145
+        } else {
146
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
+            if($user_id == 0) {
148
+                return new WSError(100, "User not found");
149
+            } else {
150
+                return $user_id;
151
+            }
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the real course id based on the course id field name and value.
157
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
+     * in the system database
159
+     *
160
+     * @param string Course id field name
161
+     * @param string Course id value
162
+     * @return mixed System course id if the course was found, WSError otherwise
163
+     */
164
+    protected function getCourseId($course_id_field_name, $course_id_value)
165
+    {
166
+        if ($course_id_field_name == "chamilo_course_id") {
167
+            if (CourseManager::get_course_code_from_course_id(
168
+                    intval($course_id_value)
169
+                ) != null
170
+            ) {
171
+                return intval($course_id_value);
172
+            } else {
173
+                return new WSError(200, "Course not found");
174
+            }
175
+        } else {
176
+            $courseId = CourseManager::get_course_code_from_original_id(
177
+                $course_id_value,
178
+                $course_id_field_name
179
+            );
180
+            if (!empty($courseId)) {
181
+                return $courseId;
182
+            } else {
183
+                return new WSError(200, "Course not found");
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Gets the real session id based on the session id field name and value.
190
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
+     * in the system database
192
+     *
193
+     * @param string Session id field name
194
+     * @param string Session id value
195
+     * @return mixed System session id if the session was found, WSError otherwise
196
+     */
197
+    protected function getSessionId($session_id_field_name, $session_id_value)
198
+    {
199
+        if ($session_id_field_name == "chamilo_session_id") {
200
+            $session = SessionManager::fetch((int)$session_id_value);
201
+            if (!empty($session)) {
202
+                return intval($session_id_value);
203
+            } else {
204
+                return new WSError(300, "Session not found");
205
+            }
206
+        } else {
207
+            $session_id = SessionManager::getSessionIdFromOriginalId(
208
+                $session_id_value,
209
+                $session_id_field_name
210
+            );
211
+            if ($session_id == 0) {
212
+                return new WSError(300, "Session not found");
213
+            } else {
214
+                return $session_id;
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Handles an error by calling the WSError error handler
221
+     *
222
+     * @param WSError Error
223
+     */
224
+    protected function handleError($error) {
225
+        $handler = WSError::getErrorHandler();
226
+        $handler->handle($error);
227
+    }
228
+
229
+    /**
230
+     * Gets a successful result
231
+     *
232
+     * @return array Array with a code of 0 and a message 'Operation was successful'
233
+     */
234
+    protected function getSuccessfulResult() {
235
+        return array('code' => 0, 'message' => 'Operation was successful');
236
+    }
237
+
238
+    /**
239
+     * Test function. Returns the string success
240
+     *
241
+     * @return string Success
242
+     */
243
+    public function test() {
244
+        return "success";
245
+    }
246 246
 }
247 247
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice_user.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         global $charset;
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98
-		    $user_id = UserManager::get_user_id_from_username($username);
98
+            $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100 100
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
101 101
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
     /**
138
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
141
-    * @return array An array with all users of the platform.
142
-    * @todo optional course code parameter, optional sorting parameters...
138
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
+     * @param array $order_by a list of fields on which sort
141
+     * @return array An array with all users of the platform.
142
+     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
144 144
      * @todo security filter order by
145
-    */
145
+     */
146 146
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
147 147
     {
148 148
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.