Passed
Push — 1.10.x ( e0e55b...e86630 )
by Angel Fernando Quiroz
63:13 queued 13:24
created
main/permissions/roles.php 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -18,56 +18,56 @@  discard block
 block discarded – undo
18 18
 // storing all the permission for a given role when the checkbox approach is used
19 19
 if ($_POST['StoreRolePermissions'])
20 20
 {
21
-	if (!empty($_POST['role_name']))
22
-	{
23
-		$table_role=Database::get_course_table(TABLE_ROLE);
24
-		$sql="INSERT INTO $table_role (role_name, role_comment, default_role)
21
+    if (!empty($_POST['role_name']))
22
+    {
23
+        $table_role=Database::get_course_table(TABLE_ROLE);
24
+        $sql="INSERT INTO $table_role (role_name, role_comment, default_role)
25 25
 					VALUES ('".Database::escape_string($_POST['role_name'])."','".Database::escape_string($_POST['role_comment'])."','".Database::escape_string($_POST['default_role'])."')";
26
-		$result=Database::query($sql);
27
-		$role_id=Database::insert_id();
28
-		$result_message=store_permissions('role', $role_id);
29
-	}
30
-	else
31
-	{
32
-		$result_message=get_lang('ErrorPleaseGiveRoleName');
33
-	}
26
+        $result=Database::query($sql);
27
+        $role_id=Database::insert_id();
28
+        $result_message=store_permissions('role', $role_id);
29
+    }
30
+    else
31
+    {
32
+        $result_message=get_lang('ErrorPleaseGiveRoleName');
33
+    }
34 34
 }
35 35
 // storing a permission for a given role when the image approach is used
36 36
 if (isset($_GET['action']) AND isset($_GET['permission']) AND isset($_GET['tool']))
37 37
 {
38
-	if ($_GET['action']=='grant' OR $_GET['action']=='revoke')
39
-	{
40
-		$result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']);
41
-	}
38
+    if ($_GET['action']=='grant' OR $_GET['action']=='revoke')
39
+    {
40
+        $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']);
41
+    }
42 42
 }
43 43
 
44 44
 // deleting a role
45 45
 if (isset($_GET['action']) AND isset($_GET['role_id']) AND $_GET['action']=='delete') {
46
-	//deleting the assignments fo this role: users
47
-	$table=Database::get_course_table(TABLE_ROLE_USER);
48
-	$sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
49
-	$result=Database::query($sql);
46
+    //deleting the assignments fo this role: users
47
+    $table=Database::get_course_table(TABLE_ROLE_USER);
48
+    $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
49
+    $result=Database::query($sql);
50 50
 
51
-	// deleting the assignments of this role: groups
52
-	$table=Database::get_course_table(TABLE_ROLE_GROUP);
53
-	$sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
54
-	$result=Database::query($sql);
51
+    // deleting the assignments of this role: groups
52
+    $table=Database::get_course_table(TABLE_ROLE_GROUP);
53
+    $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
54
+    $result=Database::query($sql);
55 55
 
56
-	// deleting the permissions of this role
57
-	$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
58
-	$sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
59
-	$result=Database::query($sql);
56
+    // deleting the permissions of this role
57
+    $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
58
+    $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'";
59
+    $result=Database::query($sql);
60 60
 
61
-	// deleting the role
62
-	$table_role=Database::get_course_table(TABLE_ROLE);
63
-	$sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'";
64
-	$result=Database::query($sql);
65
-	$result_message=get_lang('RoleDeleted');
61
+    // deleting the role
62
+    $table_role=Database::get_course_table(TABLE_ROLE);
63
+    $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'";
64
+    $result=Database::query($sql);
65
+    $result_message=get_lang('RoleDeleted');
66 66
 }
67 67
 
68 68
 // displaying the return message of the actions
69 69
 if (isset($result_message)) {
70
-	Display::display_normal_message($result_message);
70
+    Display::display_normal_message($result_message);
71 71
 }
72 72
 
73 73
 // 		ADDING A NEW ROLE (FORM AND LINK)
@@ -75,73 +75,73 @@  discard block
 block discarded – undo
75 75
 
76 76
 if ($_GET['action']=='add')
77 77
 {
78
-	echo "<form method=\"post\" action=\"".api_get_self()."\">";
79
-	echo "\n<table>";
80
-	echo "\n\t<tr>";
81
-	echo "\n\t\t<td>";
82
-	echo get_lang('RoleName');
83
-	echo "\n\t\t</td>";
84
-	echo "\n\t\t<td>";
85
-	echo "\n\t\t\t<input type='text' name='role_name'>";
86
-	echo "\n\t\t</td>";
87
-	echo "\n\t</tr>";
88
-	echo "\n\t<tr>";
89
-	echo "\n\t\t<td>";
90
-	echo get_lang('RoleComment');
91
-	echo "\n\t\t</td>";
92
-	echo "\n\t\t<td>";
93
-	echo "\n\t\t\t<textarea name='role_comment'></textarea>";
94
-	echo "\n\t\t</td>";
95
-	echo "\n\t</tr>";
96
-	echo "\n\t<tr>";
97
-	echo "\n\t\t<td>";
98
-	echo get_lang('DefaultRole');
99
-	echo "\n\t\t</td>";
100
-	echo "\n\t\t<td>";
101
-	echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">";
102
-	echo "\n\t\t</td>";
103
-	echo "\n\t</tr>";
104
-	echo "\n</table>";
105
-	echo "<table class=\"data_table\">\n";
78
+    echo "<form method=\"post\" action=\"".api_get_self()."\">";
79
+    echo "\n<table>";
80
+    echo "\n\t<tr>";
81
+    echo "\n\t\t<td>";
82
+    echo get_lang('RoleName');
83
+    echo "\n\t\t</td>";
84
+    echo "\n\t\t<td>";
85
+    echo "\n\t\t\t<input type='text' name='role_name'>";
86
+    echo "\n\t\t</td>";
87
+    echo "\n\t</tr>";
88
+    echo "\n\t<tr>";
89
+    echo "\n\t\t<td>";
90
+    echo get_lang('RoleComment');
91
+    echo "\n\t\t</td>";
92
+    echo "\n\t\t<td>";
93
+    echo "\n\t\t\t<textarea name='role_comment'></textarea>";
94
+    echo "\n\t\t</td>";
95
+    echo "\n\t</tr>";
96
+    echo "\n\t<tr>";
97
+    echo "\n\t\t<td>";
98
+    echo get_lang('DefaultRole');
99
+    echo "\n\t\t</td>";
100
+    echo "\n\t\t<td>";
101
+    echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">";
102
+    echo "\n\t\t</td>";
103
+    echo "\n\t</tr>";
104
+    echo "\n</table>";
105
+    echo "<table class=\"data_table\">\n";
106 106
 
107
-	// the header
108
-	if (api_get_setting('permissions')=='limited')
109
-	{
110
-		$header_array=$rights_limited;
111
-	}
112
-	if (api_get_setting('permissions')=='full')
113
-	{
114
-		$header_array=$rights_full;
115
-	}
116
-	echo "\t<tr>\n";
117
-	echo "\t\t<th>".get_lang('Module')."</th>\n";
118
-	foreach ($header_array as $header_key=>$header_value)
119
-	{
120
-		echo "\t\t<th>".get_lang($header_value)."</th>\n";
121
-	}
122
-	echo "\t</tr>\n";
107
+    // the header
108
+    if (api_get_setting('permissions')=='limited')
109
+    {
110
+        $header_array=$rights_limited;
111
+    }
112
+    if (api_get_setting('permissions')=='full')
113
+    {
114
+        $header_array=$rights_full;
115
+    }
116
+    echo "\t<tr>\n";
117
+    echo "\t\t<th>".get_lang('Module')."</th>\n";
118
+    foreach ($header_array as $header_key=>$header_value)
119
+    {
120
+        echo "\t\t<th>".get_lang($header_value)."</th>\n";
121
+    }
122
+    echo "\t</tr>\n";
123 123
 
124
-	// the main area with the checkboxes or images
125
-	foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
126
-	{
127
-		echo "\t<tr>\n";
128
-		echo "\t\t<td>\n";
129
-		echo get_lang($tool);
130
-		echo "\t\t</td>\n";
124
+    // the main area with the checkboxes or images
125
+    foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
126
+    {
127
+        echo "\t<tr>\n";
128
+        echo "\t\t<td>\n";
129
+        echo get_lang($tool);
130
+        echo "\t\t</td>\n";
131 131
 
132
-		foreach ($header_array as $key=>$value)
133
-		{
134
-			echo "\t\t<td align='center'>\n";
135
-			display_checkbox_matrix(array(), $tool, $value);
136
-			echo "\t\t</td>\n";
137
-		}
138
-		echo "\t</tr>\n";
139
-	}
132
+        foreach ($header_array as $key=>$value)
133
+        {
134
+            echo "\t\t<td align='center'>\n";
135
+            display_checkbox_matrix(array(), $tool, $value);
136
+            echo "\t\t</td>\n";
137
+        }
138
+        echo "\t</tr>\n";
139
+    }
140 140
 
141
-	echo "</table>\n";
141
+    echo "</table>\n";
142 142
 
143
-	echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
144
-	echo "</form>";
143
+    echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
144
+    echo "</form>";
145 145
 
146 146
 }
147 147
 
@@ -154,23 +154,23 @@  discard block
 block discarded – undo
154 154
 $all_roles=get_all_roles('platform');
155 155
 foreach ($all_roles as $role)
156 156
 {
157
-	echo '<div><a href="roles.php?action=view&amp;role_id='.$role['role_id'].'&amp;scope=platform">'.$role['role_name'].'</a></div>';
158
-	echo '<div>'.$role['role_comment'].'</div><br />';
159
-	if ($role['role_id']==$_GET['role_id'])
160
-	{
161
-		$current_role_info=$role;
162
-	}
157
+    echo '<div><a href="roles.php?action=view&amp;role_id='.$role['role_id'].'&amp;scope=platform">'.$role['role_name'].'</a></div>';
158
+    echo '<div>'.$role['role_comment'].'</div><br />';
159
+    if ($role['role_id']==$_GET['role_id'])
160
+    {
161
+        $current_role_info=$role;
162
+    }
163 163
 }
164 164
 // course roles
165 165
 $all_roles=get_all_roles();
166 166
 foreach ($all_roles as $role)
167 167
 {
168
-	echo '<div><a href="roles.php?action=view&amp;role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&amp;role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>';
169
-	echo '<div>'.$role['role_comment'].'</div><br />';
170
-	if ($role['role_id']==$_GET['role_id'])
171
-	{
172
-		$current_role_info=$role;
173
-	}
168
+    echo '<div><a href="roles.php?action=view&amp;role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&amp;role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>';
169
+    echo '<div>'.$role['role_comment'].'</div><br />';
170
+    if ($role['role_id']==$_GET['role_id'])
171
+    {
172
+        $current_role_info=$role;
173
+    }
174 174
 }
175 175
 
176 176
 // ===================================================
@@ -178,83 +178,83 @@  discard block
 block discarded – undo
178 178
 // ===================================================
179 179
 if ($_GET['role_id'])
180 180
 {
181
-	$current_role_permissions=get_permissions('role',$_GET['role_id']);
181
+    $current_role_permissions=get_permissions('role',$_GET['role_id']);
182 182
 
183
-	// ---------------------------------------------------
184
-	// 			LIMITED OR FULL
185
-	// ---------------------------------------------------
186
-	$current_role_permissions=limited_or_full($current_role_permissions);
187
-	if (api_get_setting('permissions')=='limited')
188
-	{
189
-		$header_array=$rights_limited;
190
-	}
191
-	if (api_get_setting('permissions')=='full')
192
-	{
193
-		$header_array=$rights_full;
194
-	}
195
-	// ---------------------------------------------------
196
-	// 			DISPLAYING THE MATRIX
197
-	// ---------------------------------------------------
198
-	echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
183
+    // ---------------------------------------------------
184
+    // 			LIMITED OR FULL
185
+    // ---------------------------------------------------
186
+    $current_role_permissions=limited_or_full($current_role_permissions);
187
+    if (api_get_setting('permissions')=='limited')
188
+    {
189
+        $header_array=$rights_limited;
190
+    }
191
+    if (api_get_setting('permissions')=='full')
192
+    {
193
+        $header_array=$rights_full;
194
+    }
195
+    // ---------------------------------------------------
196
+    // 			DISPLAYING THE MATRIX
197
+    // ---------------------------------------------------
198
+    echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
199 199
 
200
-	// the list of the roles for the user
201
-	echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />';
202
-	if ($_GET['scope']=='platform')
203
-	{
204
-		echo get_lang('IsPlatformRoleNotEditable').'<br />';
205
-	}
200
+    // the list of the roles for the user
201
+    echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />';
202
+    if ($_GET['scope']=='platform')
203
+    {
204
+        echo get_lang('IsPlatformRoleNotEditable').'<br />';
205
+    }
206 206
 
207
-	echo "<table class=\"data_table\">\n";
207
+    echo "<table class=\"data_table\">\n";
208 208
 
209
-	// the header
210
-	echo "\t<tr>\n";
211
-	echo "\t\t<th>".get_lang('Module')."</th>\n";
212
-	foreach ($header_array as $header_key=>$header_value)
213
-	{
214
-		echo "\t\t<th>".get_lang($header_value)."</th>\n";
215
-	}
216
-	echo "\t</tr>\n";
209
+    // the header
210
+    echo "\t<tr>\n";
211
+    echo "\t\t<th>".get_lang('Module')."</th>\n";
212
+    foreach ($header_array as $header_key=>$header_value)
213
+    {
214
+        echo "\t\t<th>".get_lang($header_value)."</th>\n";
215
+    }
216
+    echo "\t</tr>\n";
217 217
 
218
-	// the main area with the checkboxes or images
219
-	foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
220
-	{
221
-		echo "\t<tr>\n";
222
-		echo "\t\t<td>\n";
223
-		echo get_lang($tool);
224
-		echo "\t\t</td>\n";
218
+    // the main area with the checkboxes or images
219
+    foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights
220
+    {
221
+        echo "\t<tr>\n";
222
+        echo "\t\t<td>\n";
223
+        echo get_lang($tool);
224
+        echo "\t\t</td>\n";
225 225
 
226
-		foreach ($header_array as $key=>$value)
227
-		{
228
-			echo "\t\t<td align='center'>\n";
229
-			if (in_array($value,$rights))
230
-			{
231
-				if ($setting_visualisation=='checkbox')
232
-				{
233
-					display_checkbox_matrix($current_role_permissions, $tool, $value);
234
-				}
235
-				if ($setting_visualisation=='image')
236
-				{
237
-					if ($_GET['scope']=='platform')
238
-					{
239
-						$roles_editable=false;
240
-					}
241
-					else
242
-					{
243
-						$roles_editable=true;
244
-					}
245
-					display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable);
246
-				}
247
-			}
248
-			echo "\t\t</td>\n";
249
-		}
250
-		echo "\t</tr>\n";
251
-	}
226
+        foreach ($header_array as $key=>$value)
227
+        {
228
+            echo "\t\t<td align='center'>\n";
229
+            if (in_array($value,$rights))
230
+            {
231
+                if ($setting_visualisation=='checkbox')
232
+                {
233
+                    display_checkbox_matrix($current_role_permissions, $tool, $value);
234
+                }
235
+                if ($setting_visualisation=='image')
236
+                {
237
+                    if ($_GET['scope']=='platform')
238
+                    {
239
+                        $roles_editable=false;
240
+                    }
241
+                    else
242
+                    {
243
+                        $roles_editable=true;
244
+                    }
245
+                    display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable);
246
+                }
247
+            }
248
+            echo "\t\t</td>\n";
249
+        }
250
+        echo "\t</tr>\n";
251
+    }
252 252
 
253
-	echo "</table>\n";
254
-	if ($setting_visualisation=='checkbox')
255
-	{
256
-		echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
257
-	}
258
-	echo "</form>";
253
+    echo "</table>\n";
254
+    if ($setting_visualisation=='checkbox')
255
+    {
256
+        echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">";
257
+    }
258
+    echo "</form>";
259 259
 }
260 260
 Display::display_footer();
261 261
\ No newline at end of file
Please login to merge, or discard this patch.
main/webservices/webservice_course.php 1 patch
Indentation   +457 added lines, -457 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
 $libpath = api_get_path(LIBRARY_PATH);
8 8
 require_once(dirname(__FILE__).'/webservice.php');
@@ -12,490 +12,490 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class WSCourse extends WS
14 14
 {
15
-	/**
16
-	 * Deletes a course (helper method)
17
-	 *
18
-	 * @param string Course id field name
19
-	 * @param string Course id value
20
-	 * @return mixed True if the course was successfully deleted, WSError otherwise
21
-	 */
22
-	protected function deleteCourseHelper($course_id_field_name, $course_id_value) {
23
-		$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
24
-		if($course_id instanceof WSError) {
25
-			return $course_id;
26
-		} else {
27
-			$course_code = CourseManager::get_course_code_from_course_id($course_id);
28
-			CourseManager::delete_course($course_code);
29
-			return true;
30
-		}
31
-	}
15
+    /**
16
+     * Deletes a course (helper method)
17
+     *
18
+     * @param string Course id field name
19
+     * @param string Course id value
20
+     * @return mixed True if the course was successfully deleted, WSError otherwise
21
+     */
22
+    protected function deleteCourseHelper($course_id_field_name, $course_id_value) {
23
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
24
+        if($course_id instanceof WSError) {
25
+            return $course_id;
26
+        } else {
27
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
28
+            CourseManager::delete_course($course_code);
29
+            return true;
30
+        }
31
+    }
32 32
 
33
-	/**
34
-	 * Deletes a course
35
-	 *
36
-	 * @param string API secret key
37
-	 * @param string Course id field name
38
-	 * @param string Course id value
39
-	 */
40
-	public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) {
41
-		$verifKey = $this->verifyKey($secret_key);
42
-		if($verifKey instanceof WSError) {
43
-			$this->handleError($verifKey);
44
-		} else {
45
-			$result = $this->deleteCourseHelper($course_id_field_name, $course_id_value);
46
-			if($result instanceof WSError) {
47
-				$this->handleError($result);
48
-			}
49
-		}
50
-	}
33
+    /**
34
+     * Deletes a course
35
+     *
36
+     * @param string API secret key
37
+     * @param string Course id field name
38
+     * @param string Course id value
39
+     */
40
+    public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) {
41
+        $verifKey = $this->verifyKey($secret_key);
42
+        if($verifKey instanceof WSError) {
43
+            $this->handleError($verifKey);
44
+        } else {
45
+            $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value);
46
+            if($result instanceof WSError) {
47
+                $this->handleError($result);
48
+            }
49
+        }
50
+    }
51 51
 
52
-	/**
53
-	 * Deletes multiple courses
54
-	 *
55
-	 * @param string API secret key
56
-	 * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value')
57
-	 * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
58
-	 * than 0, an error occured
59
-	 */
60
-	public function DeleteCourses($secret_key, $courses) {
61
-		$verifKey = $this->verifyKey($secret_key);
62
-		if($verifKey instanceof WSError) {
63
-			$this->handleError($verifKey);
64
-		} else {
65
-			$results = array();
66
-			foreach($courses as $course) {
67
-				$result_tmp = array();
68
-				$result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']);
69
-				$result_tmp['course_id_value'] = $course['course_id_value'];
70
-				if($result_op instanceof WSError) {
71
-					// Return the error in the results
72
-					$result_tmp['result'] = $result_op->toArray();
73
-				} else {
74
-					$result_tmp['result'] = $this->getSuccessfulResult();
75
-				}
76
-				$results[] = $result_tmp;
77
-			}
78
-			return $results;
79
-		}
80
-	}
52
+    /**
53
+     * Deletes multiple courses
54
+     *
55
+     * @param string API secret key
56
+     * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value')
57
+     * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
58
+     * than 0, an error occured
59
+     */
60
+    public function DeleteCourses($secret_key, $courses) {
61
+        $verifKey = $this->verifyKey($secret_key);
62
+        if($verifKey instanceof WSError) {
63
+            $this->handleError($verifKey);
64
+        } else {
65
+            $results = array();
66
+            foreach($courses as $course) {
67
+                $result_tmp = array();
68
+                $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']);
69
+                $result_tmp['course_id_value'] = $course['course_id_value'];
70
+                if($result_op instanceof WSError) {
71
+                    // Return the error in the results
72
+                    $result_tmp['result'] = $result_op->toArray();
73
+                } else {
74
+                    $result_tmp['result'] = $this->getSuccessfulResult();
75
+                }
76
+                $results[] = $result_tmp;
77
+            }
78
+            return $results;
79
+        }
80
+    }
81 81
 
82
-	/**
83
-	 * Creates a course (helper method)
84
-	 *
85
-	 * @param string Title
86
-	 * @param string Category code
87
-	 * @param string Wanted code. If it's not defined, it will be generated automatically
88
-	 * @param string Tutor name
89
-	 * @param string Course admin user id field name
90
-	 * @param string Course admin user id value
91
-	 * @param string Course language
92
-	 * @param string Course id field name
93
-	 * @param string Course id value
94
-	 * @param array Course extra fields
95
-	 * @return mixed Generated id if creation was successful, WSError otherwise
96
-	 */
97
-	protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
98
-		// Add the original course id field name and value to the extra fields if needed
99
-		$extras_associative = array();
100
-		if($course_id_field_name != "chamilo_course_id") {
101
-			$extras_associative[$course_id_field_name] = $course_id_value;
102
-		}
103
-		foreach($extras as $extra) {
104
-			$extras_associative[$extra['field_name']] = $extra['field_value'];
105
-		}
106
-		$course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value);
107
-		if($course_admin_id instanceof WSError) {
108
-			return $course_admin_id;
109
-		}
110
-		if($wanted_code == '') {
111
-			$wanted_code = CourseManager::generate_course_code($title);
112
-		}
113
-		$result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
114
-		if (!$result) {
115
-			return new WSError(202, 'There was an error creating the course');
116
-		} else {
117
-			// Update extra fields
118
-			foreach($extras_associative as $fname => $fvalue) {
119
-				CourseManager::update_course_extra_field_value($result, $fname, $fvalue);
120
-			}
121
-			// Get course id
122
-			$course_info = CourseManager::get_course_information($result);
123
-			return $course_info['real_id'];
124
-		}
125
-	}
82
+    /**
83
+     * Creates a course (helper method)
84
+     *
85
+     * @param string Title
86
+     * @param string Category code
87
+     * @param string Wanted code. If it's not defined, it will be generated automatically
88
+     * @param string Tutor name
89
+     * @param string Course admin user id field name
90
+     * @param string Course admin user id value
91
+     * @param string Course language
92
+     * @param string Course id field name
93
+     * @param string Course id value
94
+     * @param array Course extra fields
95
+     * @return mixed Generated id if creation was successful, WSError otherwise
96
+     */
97
+    protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
98
+        // Add the original course id field name and value to the extra fields if needed
99
+        $extras_associative = array();
100
+        if($course_id_field_name != "chamilo_course_id") {
101
+            $extras_associative[$course_id_field_name] = $course_id_value;
102
+        }
103
+        foreach($extras as $extra) {
104
+            $extras_associative[$extra['field_name']] = $extra['field_value'];
105
+        }
106
+        $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value);
107
+        if($course_admin_id instanceof WSError) {
108
+            return $course_admin_id;
109
+        }
110
+        if($wanted_code == '') {
111
+            $wanted_code = CourseManager::generate_course_code($title);
112
+        }
113
+        $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
114
+        if (!$result) {
115
+            return new WSError(202, 'There was an error creating the course');
116
+        } else {
117
+            // Update extra fields
118
+            foreach($extras_associative as $fname => $fvalue) {
119
+                CourseManager::update_course_extra_field_value($result, $fname, $fvalue);
120
+            }
121
+            // Get course id
122
+            $course_info = CourseManager::get_course_information($result);
123
+            return $course_info['real_id'];
124
+        }
125
+    }
126 126
 
127
-	/**
128
-	 * Creates a course
129
-	 *
130
-	 * @param string API secret key
131
-	 * @param string Title
132
-	 * @param string Category code
133
-	 * @param string Wanted code. If it's not defined, it will be generated automatically
134
-	 * @param string Tutor name
135
-	 * @param string Course admin user id field name
136
-	 * @param string Course admin user id value
137
-	 * @param string Course language
138
-	 * @param string Course id field name
139
-	 * @param string Course id value
140
-	 * @param array Course extra fields
141
-	 * @return int Course id generated
142
-	 */
143
-	public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
144
-		// First, verify the secret key
145
-		$verifKey = $this->verifyKey($secret_key);
146
-		if($verifKey instanceof WSError) {
147
-			$this->handleError($verifKey);
148
-		} else {
149
-			$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
150
-			if($result instanceof WSError) {
151
-				$this->handleError($result);
152
-			} else {
153
-				return $result;
154
-			}
155
-		}
156
-	}
127
+    /**
128
+     * Creates a course
129
+     *
130
+     * @param string API secret key
131
+     * @param string Title
132
+     * @param string Category code
133
+     * @param string Wanted code. If it's not defined, it will be generated automatically
134
+     * @param string Tutor name
135
+     * @param string Course admin user id field name
136
+     * @param string Course admin user id value
137
+     * @param string Course language
138
+     * @param string Course id field name
139
+     * @param string Course id value
140
+     * @param array Course extra fields
141
+     * @return int Course id generated
142
+     */
143
+    public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
144
+        // First, verify the secret key
145
+        $verifKey = $this->verifyKey($secret_key);
146
+        if($verifKey instanceof WSError) {
147
+            $this->handleError($verifKey);
148
+        } else {
149
+            $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
150
+            if($result instanceof WSError) {
151
+                $this->handleError($result);
152
+            } else {
153
+                return $result;
154
+            }
155
+        }
156
+    }
157 157
 
158
-	/**
159
-	 * Create multiple courses
160
-	 *
161
-	 * @param string API secret key
162
-	 * @param array Courses to be created, with elements following the structure presented in CreateCourse
163
-	 * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
164
-	 */
165
-	public function CreateCourses($secret_key, $courses) {
166
-		// First, verify the secret key
167
-		$verifKey = $this->verifyKey($secret_key);
168
-		if($verifKey instanceof WSError) {
169
-			$this->handleError($verifKey);
170
-		} else {
171
-			$results = array();
172
-			foreach($courses as $course) {
173
-				$result_tmp = array();
158
+    /**
159
+     * Create multiple courses
160
+     *
161
+     * @param string API secret key
162
+     * @param array Courses to be created, with elements following the structure presented in CreateCourse
163
+     * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
164
+     */
165
+    public function CreateCourses($secret_key, $courses) {
166
+        // First, verify the secret key
167
+        $verifKey = $this->verifyKey($secret_key);
168
+        if($verifKey instanceof WSError) {
169
+            $this->handleError($verifKey);
170
+        } else {
171
+            $results = array();
172
+            foreach($courses as $course) {
173
+                $result_tmp = array();
174 174
                 // re-initialize variables just in case
175 175
                 $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = 0;
176
-				extract($course);
177
-				$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
178
-				if($result instanceof WSError) {
179
-					$result_tmp['result'] = $result->toArray();
180
-					$result_tmp['course_id_value'] = $course_id_value;
181
-					$result_tmp['course_id_generated'] = 0;
182
-				} else {
183
-					$result_tmp['result'] = $this->getSuccessfulResult();
184
-					$result_tmp['course_id_value'] = $course_id_value;
185
-					$result_tmp['course_id_generated'] = $result;
186
-				}
187
-				$results[] = $result_tmp;
188
-			}
189
-			return $results;
190
-		}
191
-	}
176
+                extract($course);
177
+                $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
178
+                if($result instanceof WSError) {
179
+                    $result_tmp['result'] = $result->toArray();
180
+                    $result_tmp['course_id_value'] = $course_id_value;
181
+                    $result_tmp['course_id_generated'] = 0;
182
+                } else {
183
+                    $result_tmp['result'] = $this->getSuccessfulResult();
184
+                    $result_tmp['course_id_value'] = $course_id_value;
185
+                    $result_tmp['course_id_generated'] = $result;
186
+                }
187
+                $results[] = $result_tmp;
188
+            }
189
+            return $results;
190
+        }
191
+    }
192 192
 
193
-	/**
194
-	 * Edits a course (helper method)
195
-	 *
196
-	 * @param string Course id field name
197
-	 * @param string Course id value
198
-	 * @param string Title
199
-	 * @param string Category code
200
-	 * @param string Department name
201
-	 * @param string Department url
202
-	 * @param string Course language
203
-	 * @param int Visibility
204
-	 * @param int Subscribe (0 = denied, 1 = allowed)
205
-	 * @param int Unsubscribe (0 = denied, 1 = allowed)
206
-	 * @param string Visual code
207
-	 * @param array Course extra fields
208
-	 * @return mixed True in case of success, WSError otherwise
209
-	 */
210
-	protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) {
211
-		$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
212
-		if($course_id instanceof WSError) {
213
-			return $course_id;
214
-		} else {
215
-			$attributes = array();
216
-			if(!is_empty($title)) {
217
-				$attributes['title'] = $title;
218
-			}
219
-			if(!is_empty($category_code)) {
220
-				$attributes['category_code'] = $category_code;
221
-			}
222
-			if(!is_empty($department_name)) {
223
-				$attributes['department_name'] = $department_name;
224
-			}
225
-			if(!is_empty($department_url)) {
226
-				$attributes['department_url'] = $department_url;
227
-			}
228
-			if(!is_empty($language)) {
229
-				$attributes['course_language'] = $language;
230
-			}
231
-			if($visibility != '') {
232
-				$attributes['visibility'] = (int)$visibility;
233
-			}
234
-			if($subscribe != '') {
235
-				$attributes['subscribe'] = (int)$subscribe;
236
-			}
237
-			if($unsubscribe != '') {
238
-				$attributes['unsubscribe'] = (int)$unsubscribe;
239
-			}
240
-			if(!is_empty($visual_code)) {
241
-				$attributes['visual_code'] = $visual_code;
242
-			}
243
-			if(!is_empty($attributes)) {
244
-				CourseManager::update_attributes($course_id, $attributes);
245
-			}
246
-			if(!empty($extras)) {
247
-				$course_code = CourseManager::get_course_code_from_course_id($course_id);
248
-				$extras_associative = array();
249
-				foreach($extras as $extra) {
250
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
251
-				}
252
-				foreach($extras_associative as $fname => $fvalue) {
253
-					CourseManager::update_extra_field_value($course_code, $fname, $fvalue);
254
-				}
255
-			}
256
-			return true;
257
-		}
258
-	}
193
+    /**
194
+     * Edits a course (helper method)
195
+     *
196
+     * @param string Course id field name
197
+     * @param string Course id value
198
+     * @param string Title
199
+     * @param string Category code
200
+     * @param string Department name
201
+     * @param string Department url
202
+     * @param string Course language
203
+     * @param int Visibility
204
+     * @param int Subscribe (0 = denied, 1 = allowed)
205
+     * @param int Unsubscribe (0 = denied, 1 = allowed)
206
+     * @param string Visual code
207
+     * @param array Course extra fields
208
+     * @return mixed True in case of success, WSError otherwise
209
+     */
210
+    protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) {
211
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
212
+        if($course_id instanceof WSError) {
213
+            return $course_id;
214
+        } else {
215
+            $attributes = array();
216
+            if(!is_empty($title)) {
217
+                $attributes['title'] = $title;
218
+            }
219
+            if(!is_empty($category_code)) {
220
+                $attributes['category_code'] = $category_code;
221
+            }
222
+            if(!is_empty($department_name)) {
223
+                $attributes['department_name'] = $department_name;
224
+            }
225
+            if(!is_empty($department_url)) {
226
+                $attributes['department_url'] = $department_url;
227
+            }
228
+            if(!is_empty($language)) {
229
+                $attributes['course_language'] = $language;
230
+            }
231
+            if($visibility != '') {
232
+                $attributes['visibility'] = (int)$visibility;
233
+            }
234
+            if($subscribe != '') {
235
+                $attributes['subscribe'] = (int)$subscribe;
236
+            }
237
+            if($unsubscribe != '') {
238
+                $attributes['unsubscribe'] = (int)$unsubscribe;
239
+            }
240
+            if(!is_empty($visual_code)) {
241
+                $attributes['visual_code'] = $visual_code;
242
+            }
243
+            if(!is_empty($attributes)) {
244
+                CourseManager::update_attributes($course_id, $attributes);
245
+            }
246
+            if(!empty($extras)) {
247
+                $course_code = CourseManager::get_course_code_from_course_id($course_id);
248
+                $extras_associative = array();
249
+                foreach($extras as $extra) {
250
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
251
+                }
252
+                foreach($extras_associative as $fname => $fvalue) {
253
+                    CourseManager::update_extra_field_value($course_code, $fname, $fvalue);
254
+                }
255
+            }
256
+            return true;
257
+        }
258
+    }
259 259
 
260
-	/**
261
-	 * Edits a course
262
-	 *
263
-	 * @param string API secret key
264
-	 * @param string Course id field name
265
-	 * @param string Course id value
266
-	 * @param string Title
267
-	 * @param string Category code
268
-	 * @param string Department name
269
-	 * @param string Department url
270
-	 * @param string Course language
271
-	 * @param int Visibility
272
-	 * @param int Subscribe (0 = denied, 1 = allowed)
273
-	 * @param int Unsubscribe (0 = denied, 1 = allowed)
274
-	 * @param string Visual code
275
-	 * @param array Course extra fields
276
-	 */
277
-	public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) {
278
-		$verifKey = $this->verifyKey($secret_key);
279
-		if($verifKey instanceof WSError) {
280
-			$this->handleError($verifKey);
281
-		} else {
282
-			$result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras);
283
-			if($result instanceof WSError) {
284
-				$this->handleError($result);
285
-			}
286
-		}
287
-	}
260
+    /**
261
+     * Edits a course
262
+     *
263
+     * @param string API secret key
264
+     * @param string Course id field name
265
+     * @param string Course id value
266
+     * @param string Title
267
+     * @param string Category code
268
+     * @param string Department name
269
+     * @param string Department url
270
+     * @param string Course language
271
+     * @param int Visibility
272
+     * @param int Subscribe (0 = denied, 1 = allowed)
273
+     * @param int Unsubscribe (0 = denied, 1 = allowed)
274
+     * @param string Visual code
275
+     * @param array Course extra fields
276
+     */
277
+    public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) {
278
+        $verifKey = $this->verifyKey($secret_key);
279
+        if($verifKey instanceof WSError) {
280
+            $this->handleError($verifKey);
281
+        } else {
282
+            $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras);
283
+            if($result instanceof WSError) {
284
+                $this->handleError($result);
285
+            }
286
+        }
287
+    }
288 288
 
289
-	/**
290
-	 * List courses
291
-	 *
292
-	 * @param string API secret key
293
-	 * @param string A list of visibility filter we want to apply
294
-	 * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
295
-	 * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id')
296
-	 */
297
-	public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') {
298
-		$verifKey = $this->verifyKey($secret_key);
299
-		if($verifKey instanceof WSError) {
300
-			$this->handleError($verifKey);
301
-		} else {
289
+    /**
290
+     * List courses
291
+     *
292
+     * @param string API secret key
293
+     * @param string A list of visibility filter we want to apply
294
+     * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
295
+     * 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id')
296
+     */
297
+    public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') {
298
+        $verifKey = $this->verifyKey($secret_key);
299
+        if($verifKey instanceof WSError) {
300
+            $this->handleError($verifKey);
301
+        } else {
302 302
             $visibilities = split(',',$visibility);
303 303
             $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
304 304
             foreach ($visibilities as $p => $visibility) {
305 305
                 $visibilities[$p] = $vis[$visibility];
306 306
             }
307
-			$courses_result = array();
308
-			$category_names = array();
307
+            $courses_result = array();
308
+            $category_names = array();
309 309
 
310
-			$courses = CourseManager::get_courses_list();
311
-			foreach($courses as $course) {
310
+            $courses = CourseManager::get_courses_list();
311
+            foreach($courses as $course) {
312 312
                 //skip elements that do not match required visibility
313 313
                 if (!in_array($course['visibility'],$visibilities)) { continue; }
314
-				$course_tmp = array();
315
-				$course_tmp['id'] = $course['id'];
316
-				$course_tmp['code'] = $course['code'];
317
-				$course_tmp['title'] = $course['title'];
318
-				$course_tmp['language'] = $course['course_language'];
319
-				$course_tmp['visibility'] = $course['visibility'];
314
+                $course_tmp = array();
315
+                $course_tmp['id'] = $course['id'];
316
+                $course_tmp['code'] = $course['code'];
317
+                $course_tmp['title'] = $course['title'];
318
+                $course_tmp['language'] = $course['course_language'];
319
+                $course_tmp['visibility'] = $course['visibility'];
320 320
 
321
-				// Determining category name
322
-				if($category_names[$course['category_code']]) {
323
-					$course_tmp['category_name'] = $category_names[$course['category_code']];
324
-				} else {
325
-					$category = CourseManager::get_course_category($course['category_code']);
326
-					$category_names[$course['category_code']] = $category['name'];
327
-					$course_tmp['category_name'] = $category['name'];
328
-				}
321
+                // Determining category name
322
+                if($category_names[$course['category_code']]) {
323
+                    $course_tmp['category_name'] = $category_names[$course['category_code']];
324
+                } else {
325
+                    $category = CourseManager::get_course_category($course['category_code']);
326
+                    $category_names[$course['category_code']] = $category['name'];
327
+                    $course_tmp['category_name'] = $category['name'];
328
+                }
329 329
 
330
-				// Determining number of students registered in course
331
-				$user_list = CourseManager::get_user_list_from_course_code($course['code'], 0);
332
-				$course_tmp['number_students'] = count($user_list);
330
+                // Determining number of students registered in course
331
+                $user_list = CourseManager::get_user_list_from_course_code($course['code'], 0);
332
+                $course_tmp['number_students'] = count($user_list);
333 333
 
334
-				// Determining external course id - this code misses the external course id field name
335
-				// $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
334
+                // Determining external course id - this code misses the external course id field name
335
+                // $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
336 336
 
337 337
 
338
-				$courses_result[] = $course_tmp;
339
-			}
338
+                $courses_result[] = $course_tmp;
339
+            }
340 340
 
341
-			return $courses_result;
342
-		}
343
-	}
341
+            return $courses_result;
342
+        }
343
+    }
344 344
 
345
-	/**
346
-	 * Subscribe or unsubscribe user to a course (helper method)
347
-	 *
348
-	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
349
-	 * @param string Course id value.
350
-	 * @param string User id field name. Use "chamilo_user_id" to use internal id
351
-	 * @param string User id value
352
-	 * @param int Set to 1 to subscribe, 0 to unsubscribe
353
-	 * @param int Status (STUDENT or TEACHER) Used for subscription only
354
-	 * @return mixed True if subscription or unsubscription was successful, false otherwise
355
-	 */
356
-	protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) {
357
-		$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
358
-		if($course_id instanceof WSError) {
359
-			return $course_id;
360
-		} else {
361
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
362
-			if($user_id instanceof WSError) {
363
-				return $user_id;
364
-			} else {
365
-				$course_code = CourseManager::get_course_code_from_course_id($course_id);
366
-				if($state == 0) {
367
-					// Unsubscribe user
368
-					CourseManager::unsubscribe_user($user_id, $course_code);
369
-					return true;
370
-				} else {
371
-					// Subscribe user
372
-					if(CourseManager::subscribe_user($user_id, $course_code, $status)) {
373
-						return true;
374
-					} else {
375
-						return new WSError(203, 'An error occured subscribing to this course');
376
-					}
377
-				}
378
-			}
379
-		}
380
-	}
345
+    /**
346
+     * Subscribe or unsubscribe user to a course (helper method)
347
+     *
348
+     * @param string Course id field name. Use "chamilo_course_id" to use internal id
349
+     * @param string Course id value.
350
+     * @param string User id field name. Use "chamilo_user_id" to use internal id
351
+     * @param string User id value
352
+     * @param int Set to 1 to subscribe, 0 to unsubscribe
353
+     * @param int Status (STUDENT or TEACHER) Used for subscription only
354
+     * @return mixed True if subscription or unsubscription was successful, false otherwise
355
+     */
356
+    protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) {
357
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
358
+        if($course_id instanceof WSError) {
359
+            return $course_id;
360
+        } else {
361
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
362
+            if($user_id instanceof WSError) {
363
+                return $user_id;
364
+            } else {
365
+                $course_code = CourseManager::get_course_code_from_course_id($course_id);
366
+                if($state == 0) {
367
+                    // Unsubscribe user
368
+                    CourseManager::unsubscribe_user($user_id, $course_code);
369
+                    return true;
370
+                } else {
371
+                    // Subscribe user
372
+                    if(CourseManager::subscribe_user($user_id, $course_code, $status)) {
373
+                        return true;
374
+                    } else {
375
+                        return new WSError(203, 'An error occured subscribing to this course');
376
+                    }
377
+                }
378
+            }
379
+        }
380
+    }
381 381
 
382
-	/**
383
-	 * Subscribe user to a course
384
-	 *
385
-	 * @param string API secret key
386
-	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
387
-	 * @param string Course id value.
388
-	 * @param string User id field name. Use "chamilo_user_id" to use internal id
389
-	 * @param string User id value
390
-	 * @param int Status (1 = Teacher, 5 = Student)
391
-	 */
392
-	public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) {
393
-		$verifKey = $this->verifyKey($secret_key);
394
-		if($verifKey instanceof WSError) {
395
-			$this->handleError($verifKey);
396
-		} else {
397
-			$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status);
398
-			if($result instanceof WSError) {
399
-				$this->handleError($result);
400
-			}
401
-		}
402
-	}
382
+    /**
383
+     * Subscribe user to a course
384
+     *
385
+     * @param string API secret key
386
+     * @param string Course id field name. Use "chamilo_course_id" to use internal id
387
+     * @param string Course id value.
388
+     * @param string User id field name. Use "chamilo_user_id" to use internal id
389
+     * @param string User id value
390
+     * @param int Status (1 = Teacher, 5 = Student)
391
+     */
392
+    public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) {
393
+        $verifKey = $this->verifyKey($secret_key);
394
+        if($verifKey instanceof WSError) {
395
+            $this->handleError($verifKey);
396
+        } else {
397
+            $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status);
398
+            if($result instanceof WSError) {
399
+                $this->handleError($result);
400
+            }
401
+        }
402
+    }
403 403
 
404
-	/**
405
-	 * Unsusbscribe user from course
406
-	 *
407
-	 * @param string API secret key
408
-	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
409
-	 * @param string Course id value.
410
-	 * @param string User id field name. Use "chamilo_user_id" to use internal id
411
-	 * @param string User id value
412
-	 */
413
-	public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) {
414
-		$verifKey = $this->verifyKey($secret_key);
415
-		if($verifKey instanceof WSError) {
416
-			$this->handleError($verifKey);
417
-		} else {
418
-			$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0);
419
-			if($result instanceof WSError) {
420
-				$this->handleError($result);
421
-			}
422
-		}
423
-	}
404
+    /**
405
+     * Unsusbscribe user from course
406
+     *
407
+     * @param string API secret key
408
+     * @param string Course id field name. Use "chamilo_course_id" to use internal id
409
+     * @param string Course id value.
410
+     * @param string User id field name. Use "chamilo_user_id" to use internal id
411
+     * @param string User id value
412
+     */
413
+    public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) {
414
+        $verifKey = $this->verifyKey($secret_key);
415
+        if($verifKey instanceof WSError) {
416
+            $this->handleError($verifKey);
417
+        } else {
418
+            $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0);
419
+            if($result instanceof WSError) {
420
+                $this->handleError($result);
421
+            }
422
+        }
423
+    }
424 424
 
425
-	/**
426
-	 * Returns the descriptions of a course, along with their id
427
-	 *
428
-	 * @param string API secret key
429
-	 * @param string Course id field name
430
-	 * @param string Course id value
431
-	 * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content')
432
-	 */
433
-	public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) {
434
-		$verifKey = $this->verifyKey($secret_key);
435
-		if($verifKey instanceof WSError) {
436
-			$this->handleError($verifKey);
437
-		} else {
438
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
439
-			if($course_id instanceof WSError) {
440
-				return $course_id;
441
-			} else {
442
-				// Course exists, get its descriptions
443
-				$descriptions = CourseDescription::get_descriptions($course_id);
444
-				$results = array();
445
-				foreach($descriptions as $description) {
446
-					$results[] = array('course_desc_id' => $description->get_description_type(),
447
-										'course_desc_title' => $description->get_title(),
448
-										'course_desc_content' => $description->get_content());
449
-				}
450
-				return $results;
451
-			}
452
-		}
453
-	}
425
+    /**
426
+     * Returns the descriptions of a course, along with their id
427
+     *
428
+     * @param string API secret key
429
+     * @param string Course id field name
430
+     * @param string Course id value
431
+     * @return array Returns an array with elements of the form ('course_desc_id' => 1, 'course_desc_title' => 'Title', 'course_desc_content' => 'Content')
432
+     */
433
+    public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) {
434
+        $verifKey = $this->verifyKey($secret_key);
435
+        if($verifKey instanceof WSError) {
436
+            $this->handleError($verifKey);
437
+        } else {
438
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
439
+            if($course_id instanceof WSError) {
440
+                return $course_id;
441
+            } else {
442
+                // Course exists, get its descriptions
443
+                $descriptions = CourseDescription::get_descriptions($course_id);
444
+                $results = array();
445
+                foreach($descriptions as $description) {
446
+                    $results[] = array('course_desc_id' => $description->get_description_type(),
447
+                                        'course_desc_title' => $description->get_title(),
448
+                                        'course_desc_content' => $description->get_content());
449
+                }
450
+                return $results;
451
+            }
452
+        }
453
+    }
454 454
 
455 455
 
456
-	/**
457
-	 * Edit course description
458
-	 *
459
-	 * @param string API secret key
460
-	 * @param string Course id field name
461
-	 * @param string Course id value
462
-	 * @param int Category id from course description
463
-	 * @param string Description title
464
-	 * @param string Course description content
465
-	 */
466
-	public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) {
467
-		$verifKey = $this->verifyKey($secret_key);
468
-		if($verifKey instanceof WSError) {
469
-			$this->handleError($verifKey);
470
-		} else {
471
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
472
-			if($course_id instanceof WSError) {
473
-				return $course_id;
474
-			} else {
475
-				// Create the new course description
476
-				$cd = new CourseDescription();
477
-				$cd->set_description_type($course_desc_id);
478
-				$cd->set_title($course_desc_title);
479
-				$cd->set_content($course_desc_content);
480
-				$cd->set_session_id(0);
481
-				// Get course info
482
-				$course_info = CourseManager::get_course_information(CourseManager::get_course_code_from_course_id($course_id));
456
+    /**
457
+     * Edit course description
458
+     *
459
+     * @param string API secret key
460
+     * @param string Course id field name
461
+     * @param string Course id value
462
+     * @param int Category id from course description
463
+     * @param string Description title
464
+     * @param string Course description content
465
+     */
466
+    public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) {
467
+        $verifKey = $this->verifyKey($secret_key);
468
+        if($verifKey instanceof WSError) {
469
+            $this->handleError($verifKey);
470
+        } else {
471
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
472
+            if($course_id instanceof WSError) {
473
+                return $course_id;
474
+            } else {
475
+                // Create the new course description
476
+                $cd = new CourseDescription();
477
+                $cd->set_description_type($course_desc_id);
478
+                $cd->set_title($course_desc_title);
479
+                $cd->set_content($course_desc_content);
480
+                $cd->set_session_id(0);
481
+                // Get course info
482
+                $course_info = CourseManager::get_course_information(CourseManager::get_course_code_from_course_id($course_id));
483 483
                 $cd->set_course_id($course_info['real_id']);
484
-				// Check if this course description exists
485
-				$descriptions = CourseDescription::get_descriptions($course_id);
486
-				$exists = false;
487
-				foreach($descriptions as $description) {
488
-					if($description->get_description_type() == $course_desc_id) {
489
-						$exists = true;
490
-					}
491
-				}
492
-				if (!$exists) {
493
-					$cd->set_progress(0);
494
-					$cd->insert();
495
-				} else {
496
-					$cd->update();
497
-				}
498
-			}
499
-		}
500
-	}
484
+                // Check if this course description exists
485
+                $descriptions = CourseDescription::get_descriptions($course_id);
486
+                $exists = false;
487
+                foreach($descriptions as $description) {
488
+                    if($description->get_description_type() == $course_desc_id) {
489
+                        $exists = true;
490
+                    }
491
+                }
492
+                if (!$exists) {
493
+                    $cd->set_progress(0);
494
+                    $cd->insert();
495
+                } else {
496
+                    $cd->update();
497
+                }
498
+            }
499
+        }
500
+    }
501 501
 }
Please login to merge, or discard this patch.
main/webservices/additional_webservices.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @package chamilo.webservices
5
- * @author Francis Gonzales
6
- */
4
+     * @package chamilo.webservices
5
+     * @author Francis Gonzales
6
+     */
7 7
 
8 8
 require_once '../inc/global.inc.php';
9 9
 $libpath = api_get_path(LIBRARY_PATH);
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/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.
main/webservices/lp.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -581,7 +581,7 @@
 block discarded – undo
581 581
     /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
582 582
     $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
583 583
 
584
-     $courseInfo = CourseManager::getCourseInfoFromOriginalId(
584
+        $courseInfo = CourseManager::getCourseInfoFromOriginalId(
585 585
         $courseIdValue,
586 586
         $courseIdName
587 587
     );
Please login to merge, or discard this patch.
main/webservices/cm_soap_course.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -9,255 +9,255 @@  discard block
 block discarded – undo
9 9
 $s = WSCMSoapServer::singleton();
10 10
 
11 11
 $s->wsdl->addComplexType(
12
-	'course_id',
13
-	'complexType',
14
-	'struct',
15
-	'all',
16
-	'',
17
-	array(
18
-		'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
19
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
20
-	)
12
+    'course_id',
13
+    'complexType',
14
+    'struct',
15
+    'all',
16
+    '',
17
+    array(
18
+        'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
19
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
20
+    )
21 21
 );
22 22
 
23 23
 $s->wsdl->addComplexType(
24
-	'course_result',
25
-	'complexType',
26
-	'struct',
27
-	'all',
28
-	'',
29
-	array(
30
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
31
-		'result' => array('name' => 'result', 'type' => 'tns:result')
32
-	)
24
+    'course_result',
25
+    'complexType',
26
+    'struct',
27
+    'all',
28
+    '',
29
+    array(
30
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
31
+        'result' => array('name' => 'result', 'type' => 'tns:result')
32
+    )
33 33
 );
34 34
 
35 35
 $s->wsdl->addComplexType(
36
-	'course_result_array',
37
-	'complexType',
38
-	'array',
39
-	'',
40
-	'SOAP-ENC:Array',
41
-	array(),
42
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
43
-	'tns:course_result'
36
+    'course_result_array',
37
+    'complexType',
38
+    'array',
39
+    '',
40
+    'SOAP-ENC:Array',
41
+    array(),
42
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
43
+    'tns:course_result'
44 44
 );
45 45
 
46 46
 $s->register(
47
-	'WSCMCourse.DeleteCourse',
48
-	array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string')
47
+    'WSCMCourse.DeleteCourse',
48
+    array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string')
49 49
 );
50 50
 
51 51
 $s->register(
52
-	'WSCMCourse.DeleteCourses',
53
-	array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
54
-	array('return' => 'tns:course_result_array')
52
+    'WSCMCourse.DeleteCourses',
53
+    array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
54
+    array('return' => 'tns:course_result_array')
55 55
 );
56 56
 
57 57
 $s->register(
58
-	'WSCMCourse.CreateCourse',
59
-	array(
60
-		'secret_key' => 'xsd:string',
61
-		'title' => 'xsd:string',
62
-		'category_code' => 'xsd:string',
63
-		'wanted_code' => 'xsd:string',
64
-		'tutor_name' => 'xsd:string',
65
-		'course_admin_user_id_field_name' => 'xsd:string',
66
-		'course_admin_user_id_value' => 'xsd:string',
67
-		'language' => 'xsd:string',
68
-		'course_id_field_name' => 'xsd:string',
69
-		'course_id_value' => 'xsd:string',
70
-		'extras' => 'tns:extra_field[]'
71
-	),
72
-	array('return' => 'xsd:int')
58
+    'WSCMCourse.CreateCourse',
59
+    array(
60
+        'secret_key' => 'xsd:string',
61
+        'title' => 'xsd:string',
62
+        'category_code' => 'xsd:string',
63
+        'wanted_code' => 'xsd:string',
64
+        'tutor_name' => 'xsd:string',
65
+        'course_admin_user_id_field_name' => 'xsd:string',
66
+        'course_admin_user_id_value' => 'xsd:string',
67
+        'language' => 'xsd:string',
68
+        'course_id_field_name' => 'xsd:string',
69
+        'course_id_value' => 'xsd:string',
70
+        'extras' => 'tns:extra_field[]'
71
+    ),
72
+    array('return' => 'xsd:int')
73 73
 );
74 74
 
75 75
 $s->wsdl->addComplexType(
76
-	'course_create',
77
-	'complexType',
78
-	'struct',
79
-	'all',
80
-	'',
81
-	array(
82
-		'title' => array('name' => 'title', 'type' => 'xsd:string'),
83
-		'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
84
-		'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
85
-		'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
86
-		'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
87
-		'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
88
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
89
-		'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
90
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
91
-		'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
92
-	)
76
+    'course_create',
77
+    'complexType',
78
+    'struct',
79
+    'all',
80
+    '',
81
+    array(
82
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
83
+        'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
84
+        'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
85
+        'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
86
+        'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
87
+        'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
88
+        'language' => array('name' => 'language', 'type' => 'xsd:string'),
89
+        'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
90
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
91
+        'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
92
+    )
93 93
 );
94 94
 
95 95
 $s->wsdl->addComplexType(
96
-	'course_create_result',
97
-	'complexType',
98
-	'struct',
99
-	'all',
100
-	'',
101
-	array(
102
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
103
-		'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
104
-		'result' => array('name' => 'result', 'type' => 'tns:result')
105
-	)
96
+    'course_create_result',
97
+    'complexType',
98
+    'struct',
99
+    'all',
100
+    '',
101
+    array(
102
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
103
+        'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
104
+        'result' => array('name' => 'result', 'type' => 'tns:result')
105
+    )
106 106
 );
107 107
 
108 108
 $s->wsdl->addComplexType(
109
-	'course_create_result_array',
110
-	'complexType',
111
-	'array',
112
-	'',
113
-	'SOAP-ENC:Array',
114
-	array(),
115
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
116
-	'tns:course_create_result'
109
+    'course_create_result_array',
110
+    'complexType',
111
+    'array',
112
+    '',
113
+    'SOAP-ENC:Array',
114
+    array(),
115
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
116
+    'tns:course_create_result'
117 117
 );
118 118
 
119 119
 $s->register(
120
-	'WSCMCourse.CreateCourses',
121
-	array(
122
-		'secret_key' => 'xsd:string',
123
-		'courses' => 'tns:course_create[]'
124
-	),
125
-	array('return' => 'tns:course_create_result_array')
120
+    'WSCMCourse.CreateCourses',
121
+    array(
122
+        'secret_key' => 'xsd:string',
123
+        'courses' => 'tns:course_create[]'
124
+    ),
125
+    array('return' => 'tns:course_create_result_array')
126 126
 );
127 127
 
128 128
 $s->register(
129
-	'WSCMCourse.EditCourse',
130
-	array(
131
-		'secret_key' => 'xsd:string',
132
-		'course_id_field_name' => 'xsd:string',
133
-		'course_id_value' => 'xsd:string',
134
-		'title' => 'xsd:string',
135
-		'category_code' => 'xsd:string',
136
-		'department_name' => 'xsd:string',
137
-		'department_url' => 'xsd:string',
138
-		'language' => 'xsd:string',
139
-		'visibility' => 'xsd:int',
140
-		'subscribe' => 'xsd:int',
141
-		'unsubscribe' => 'xsd:int',
142
-		'visual_code' => 'xsd:string',
143
-		'extras' => 'tns:extra_field[]'
144
-	)
129
+    'WSCMCourse.EditCourse',
130
+    array(
131
+        'secret_key' => 'xsd:string',
132
+        'course_id_field_name' => 'xsd:string',
133
+        'course_id_value' => 'xsd:string',
134
+        'title' => 'xsd:string',
135
+        'category_code' => 'xsd:string',
136
+        'department_name' => 'xsd:string',
137
+        'department_url' => 'xsd:string',
138
+        'language' => 'xsd:string',
139
+        'visibility' => 'xsd:int',
140
+        'subscribe' => 'xsd:int',
141
+        'unsubscribe' => 'xsd:int',
142
+        'visual_code' => 'xsd:string',
143
+        'extras' => 'tns:extra_field[]'
144
+    )
145 145
 );
146 146
 
147 147
 $s->wsdl->addComplexType(
148
-	'course',
149
-	'complexType',
150
-	'struct',
151
-	'all',
152
-	'',
153
-	array(
154
-		'id' => array('name' => 'id', 'type' => 'xsd:int'),
155
-		'code' => array('name' => 'code', 'type' => 'xsd:string'),
156
-		'title' => array('name' => 'title', 'type' => 'xsd:string'),
157
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
158
-		'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
159
-		'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
160
-		'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
161
-		'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
162
-	)
148
+    'course',
149
+    'complexType',
150
+    'struct',
151
+    'all',
152
+    '',
153
+    array(
154
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
155
+        'code' => array('name' => 'code', 'type' => 'xsd:string'),
156
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
157
+        'language' => array('name' => 'language', 'type' => 'xsd:string'),
158
+        'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
159
+        'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
160
+        'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
161
+        'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
162
+    )
163 163
 );
164 164
 
165 165
 $s->wsdl->addComplexType(
166
-	'course_array',
167
-	'complexType',
168
-	'array',
169
-	'',
170
-	'SOAP-ENC:Array',
171
-	array(),
172
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
173
-	'tns:course'
166
+    'course_array',
167
+    'complexType',
168
+    'array',
169
+    '',
170
+    'SOAP-ENC:Array',
171
+    array(),
172
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
173
+    'tns:course'
174 174
 );
175 175
 
176 176
 $s->register(
177
-	'WSCMCourse.ListCourses',
178
-	array(
179
-		'secret_key' => 'xsd:string',
180
-		'course_id_field_name' => 'xsd:string'
181
-	),
182
-	array('return' => 'tns:course_array')
177
+    'WSCMCourse.ListCourses',
178
+    array(
179
+        'secret_key' => 'xsd:string',
180
+        'course_id_field_name' => 'xsd:string'
181
+    ),
182
+    array('return' => 'tns:course_array')
183 183
 );
184 184
 
185 185
 $s->register(
186
-	'WSCMCourse.SubscribeUserToCourse',
187
-	array(
188
-		'secret_key' => 'xsd:string',
189
-		'course_id_field_name' => 'xsd:string',
190
-		'course_id_value' => 'xsd:string',
191
-		'user_id_field_name' => 'xsd:string',
192
-		'user_id_value' => 'xsd:string',
193
-		'status' => 'xsd:int'
194
-	)
186
+    'WSCMCourse.SubscribeUserToCourse',
187
+    array(
188
+        'secret_key' => 'xsd:string',
189
+        'course_id_field_name' => 'xsd:string',
190
+        'course_id_value' => 'xsd:string',
191
+        'user_id_field_name' => 'xsd:string',
192
+        'user_id_value' => 'xsd:string',
193
+        'status' => 'xsd:int'
194
+    )
195 195
 );
196 196
 
197 197
 $s->register(
198
-	'WSCMCourse.UnsubscribeUserFromCourse',
199
-	array(
200
-		'secret_key' => 'xsd:string',
201
-		'course_id_field_name' => 'xsd:string',
202
-		'course_id_value' => 'xsd:string',
203
-		'user_id_field_name' => 'xsd:string',
204
-		'user_id_value' => 'xsd:string'
205
-	)
198
+    'WSCMCourse.UnsubscribeUserFromCourse',
199
+    array(
200
+        'secret_key' => 'xsd:string',
201
+        'course_id_field_name' => 'xsd:string',
202
+        'course_id_value' => 'xsd:string',
203
+        'user_id_field_name' => 'xsd:string',
204
+        'user_id_value' => 'xsd:string'
205
+    )
206 206
 );
207 207
 
208 208
 $s->wsdl->addComplexType(
209
-	'course_description',
210
-	'complexType',
211
-	'struct',
212
-	'all',
213
-	'',
214
-	array(
215
-		'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
216
-		'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
217
-		'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
218
-	)
209
+    'course_description',
210
+    'complexType',
211
+    'struct',
212
+    'all',
213
+    '',
214
+    array(
215
+        'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
216
+        'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
217
+        'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
218
+    )
219 219
 );
220 220
 
221 221
 $s->wsdl->addComplexType(
222
-	'course_description_array',
223
-	'complexType',
224
-	'array',
225
-	'',
226
-	'SOAP-ENC:Array',
227
-	array(),
228
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
229
-	'tns:course_description'
222
+    'course_description_array',
223
+    'complexType',
224
+    'array',
225
+    '',
226
+    'SOAP-ENC:Array',
227
+    array(),
228
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
229
+    'tns:course_description'
230 230
 );
231 231
 
232 232
 $s->register(
233
-	'WSCMCourse.GetCourseDescriptions',
234
-	array(
235
-		'secret_key' => 'xsd:string',
236
-		'course_id_field_name' => 'xsd:string',
237
-		'course_id_value' => 'xsd:string'
238
-	),
239
-	array('return' => 'tns:course_description_array')
233
+    'WSCMCourse.GetCourseDescriptions',
234
+    array(
235
+        'secret_key' => 'xsd:string',
236
+        'course_id_field_name' => 'xsd:string',
237
+        'course_id_value' => 'xsd:string'
238
+    ),
239
+    array('return' => 'tns:course_description_array')
240 240
 );
241 241
 
242 242
 $s->register(
243
-	'WSCMCourse.EditCourseDescription',
244
-	array(
245
-		'secret_key' => 'xsd:string',
246
-		'course_id_field_name' => 'xsd:string',
247
-		'course_id_value' => 'xsd:string',
248
-		'course_desc_id' => 'xsd:int',
249
-		'course_desc_title' => 'xsd:string',
250
-		'course_desc_content' => 'xsd:string'
251
-	)
243
+    'WSCMCourse.EditCourseDescription',
244
+    array(
245
+        'secret_key' => 'xsd:string',
246
+        'course_id_field_name' => 'xsd:string',
247
+        'course_id_value' => 'xsd:string',
248
+        'course_desc_id' => 'xsd:int',
249
+        'course_desc_title' => 'xsd:string',
250
+        'course_desc_content' => 'xsd:string'
251
+    )
252 252
 );
253 253
 
254 254
 $s->register(
255
-	'WSCMCourse.unreadMessage',
256
-	array(
257
-		'username' => 'xsd:string',
258
-		'password' => 'xsd:string',
259
-	),
260
-	array('return' => 'xsd:string'),
255
+    'WSCMCourse.unreadMessage',
256
+    array(
257
+        'username' => 'xsd:string',
258
+        'password' => 'xsd:string',
259
+    ),
260
+    array('return' => 'xsd:string'),
261 261
         'urn:WSCMService',
262 262
         '',
263 263
         '',
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 
269 269
 
270 270
 $s->register(
271
-	'WSCMCourse.getIdMessage',
272
-	array(
273
-		'username' => 'xsd:string',
274
-		'password' => 'xsd:string',
275
-	),
276
-	array('return' => 'xsd:string'),
271
+    'WSCMCourse.getIdMessage',
272
+    array(
273
+        'username' => 'xsd:string',
274
+        'password' => 'xsd:string',
275
+    ),
276
+    array('return' => 'xsd:string'),
277 277
         'urn:WSCMService',
278 278
         '',
279 279
         '',
Please login to merge, or discard this patch.