Completed
Push — 1.10.x ( 48dd82...5e3ab9 )
by Yannick
48:23
created
main/webservices/webservice_session.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -453,6 +453,7 @@
 block discarded – undo
453 453
 	 * @param string Session id field name
454 454
 	 * @param string Session id value
455 455
 	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
+	 * @param integer $state
456 457
 	 * @return mixed True on success, WSError otherwise
457 458
 	 */
458 459
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
Please login to merge, or discard this patch.
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -14,177 +14,177 @@  discard block
 block discarded – undo
14 14
 class WSSession extends WS
15 15
 {
16 16
 
17
-	/**
18
-	 * Creates a session (helper method)
19
-	 *
20
-	 * @param string Name of the session
21
-	 * @param string Start date, use the 'YYYY-MM-DD' format
22
-	 * @param string End date, use the 'YYYY-MM-DD' format
23
-	 * @param int Access delays of the coach (days before)
24
-	 * @param int Access delays of the coach (days after)
25
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
-	 * @param int Visibility
27
-	 * @param string User id field name for the coach
28
-	 * @param string User id value for the coach
29
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
-	 * @param string Original session id value
31
-	 * @param array Array of extra fields
32
-	 * @return mixed Generated id in case of success, WSError otherwise
33
-	 */
34
-	protected function createSessionHelper(
35
-		$name,
36
-		$start_date,
37
-		$end_date,
38
-		$nb_days_access_before,
39
-		$nb_days_access_after,
40
-		$nolimit,
41
-		$visibility,
42
-		$user_id_field_name,
43
-		$user_id_value,
44
-		$session_id_field_name,
45
-		$session_id_value,
46
-		$extras
47
-	) {
48
-		// Verify that coach exists and get its id
49
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
-		if ($user_id instanceof WSError) {
51
-			return $user_id;
52
-		}
17
+    /**
18
+     * Creates a session (helper method)
19
+     *
20
+     * @param string Name of the session
21
+     * @param string Start date, use the 'YYYY-MM-DD' format
22
+     * @param string End date, use the 'YYYY-MM-DD' format
23
+     * @param int Access delays of the coach (days before)
24
+     * @param int Access delays of the coach (days after)
25
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
+     * @param int Visibility
27
+     * @param string User id field name for the coach
28
+     * @param string User id value for the coach
29
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
+     * @param string Original session id value
31
+     * @param array Array of extra fields
32
+     * @return mixed Generated id in case of success, WSError otherwise
33
+     */
34
+    protected function createSessionHelper(
35
+        $name,
36
+        $start_date,
37
+        $end_date,
38
+        $nb_days_access_before,
39
+        $nb_days_access_after,
40
+        $nolimit,
41
+        $visibility,
42
+        $user_id_field_name,
43
+        $user_id_value,
44
+        $session_id_field_name,
45
+        $session_id_value,
46
+        $extras
47
+    ) {
48
+        // Verify that coach exists and get its id
49
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
+        if ($user_id instanceof WSError) {
51
+            return $user_id;
52
+        }
53 53
 
54
-		$coachStartDate = null;
55
-		if (!empty($nb_days_access_before)) {
56
-			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
-		}
54
+        $coachStartDate = null;
55
+        if (!empty($nb_days_access_before)) {
56
+            $day = intval($nb_days_access_before);
57
+            $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
+        }
59 59
 
60
-		$coachEndDate = null;
61
-		if (!empty($nb_days_access_after)) {
62
-			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
-		}
60
+        $coachEndDate = null;
61
+        if (!empty($nb_days_access_after)) {
62
+            $day = intval($nb_days_access_after);
63
+            $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
+        }
65 65
 
66
-		// Try to create the session
67
-		$session_id = SessionManager::create_session(
68
-			$name,
69
-			$start_date,
70
-			$end_date,
71
-			$start_date,
72
-			$end_date,
73
-			$coachStartDate,
74
-			$coachEndDate,
75
-			$user_id,
76
-			0,
77
-			$visibility
78
-		);
79
-		if(!is_int($session_id)) {
80
-			return new WSError(301, 'Could not create the session');
81
-		} else {
82
-			// Add the Original session id to the extra fields
83
-			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
85
-				$extras_associative[$session_id_field_name] = $session_id_value;
86
-			}
87
-			foreach($extras as $extra) {
88
-				$extras_associative[$extra['field_name']] = $extra['field_value'];
89
-			}
90
-			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
92
-				SessionManager::create_session_extra_field($fname, 1, $fname);
93
-				SessionManager::update_session_extra_field_value(
94
-					$session_id,
95
-					$fname,
96
-					$fvalue
97
-				);
98
-			}
99
-			return $session_id;
100
-		}
101
-	}
66
+        // Try to create the session
67
+        $session_id = SessionManager::create_session(
68
+            $name,
69
+            $start_date,
70
+            $end_date,
71
+            $start_date,
72
+            $end_date,
73
+            $coachStartDate,
74
+            $coachEndDate,
75
+            $user_id,
76
+            0,
77
+            $visibility
78
+        );
79
+        if(!is_int($session_id)) {
80
+            return new WSError(301, 'Could not create the session');
81
+        } else {
82
+            // Add the Original session id to the extra fields
83
+            $extras_associative = array();
84
+            if($session_id_field_name != "chamilo_session_id") {
85
+                $extras_associative[$session_id_field_name] = $session_id_value;
86
+            }
87
+            foreach($extras as $extra) {
88
+                $extras_associative[$extra['field_name']] = $extra['field_value'];
89
+            }
90
+            // Create the extra fields
91
+            foreach($extras_associative as $fname => $fvalue) {
92
+                SessionManager::create_session_extra_field($fname, 1, $fname);
93
+                SessionManager::update_session_extra_field_value(
94
+                    $session_id,
95
+                    $fname,
96
+                    $fvalue
97
+                );
98
+            }
99
+            return $session_id;
100
+        }
101
+    }
102 102
 
103
-	/**
104
-	 * Creates a session
105
-	 *
106
-	 * @param string API secret key
107
-	 * @param string Name of the session
108
-	 * @param string Start date, use the 'YYYY-MM-DD' format
109
-	 * @param string End date, use the 'YYYY-MM-DD' format
110
-	 * @param int Access delays of the coach (days before)
111
-	 * @param int Access delays of the coach (days after)
112
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
-	 * @param int Visibility
114
-	 * @param string User id field name for the coach
115
-	 * @param string User id value for the coach
116
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
-	 * @param string Original session id value
118
-	 * @param array Array of extra fields
119
-	 * @return int Session id generated
120
-	 */
121
-	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
-		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
124
-			$this->handleError($verifKey);
125
-		} else {
126
-			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
128
-				$this->handleError($session_id);
129
-			} else {
130
-				return $session_id;
131
-			}
132
-		}
133
-	}
103
+    /**
104
+     * Creates a session
105
+     *
106
+     * @param string API secret key
107
+     * @param string Name of the session
108
+     * @param string Start date, use the 'YYYY-MM-DD' format
109
+     * @param string End date, use the 'YYYY-MM-DD' format
110
+     * @param int Access delays of the coach (days before)
111
+     * @param int Access delays of the coach (days after)
112
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
+     * @param int Visibility
114
+     * @param string User id field name for the coach
115
+     * @param string User id value for the coach
116
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
+     * @param string Original session id value
118
+     * @param array Array of extra fields
119
+     * @return int Session id generated
120
+     */
121
+    public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
+        $verifKey = $this->verifyKey($secret_key);
123
+        if($verifKey instanceof WSError) {
124
+            $this->handleError($verifKey);
125
+        } else {
126
+            $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
+            if($session_id instanceof WSError) {
128
+                $this->handleError($session_id);
129
+            } else {
130
+                return $session_id;
131
+            }
132
+        }
133
+    }
134 134
 
135
-	/**
136
-	 * Deletes a session (helper method)
137
-	 *
138
-	 * @param string Session id field name
139
-	 * @param string Session id value
140
-	 * @return mixed True in case of success, WSError otherwise
141
-	 */
142
-	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
145
-			return $session_id;
146
-		} else {
147
-			SessionManager::delete($session_id, true);
148
-			return true;
149
-		}
150
-	}
135
+    /**
136
+     * Deletes a session (helper method)
137
+     *
138
+     * @param string Session id field name
139
+     * @param string Session id value
140
+     * @return mixed True in case of success, WSError otherwise
141
+     */
142
+    protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
+        if($session_id instanceof WSError) {
145
+            return $session_id;
146
+        } else {
147
+            SessionManager::delete($session_id, true);
148
+            return true;
149
+        }
150
+    }
151 151
 
152
-	/**
153
-	 * Deletes a session
154
-	 *
155
-	 * @param string API secret key
156
-	 * @param string Session id field name
157
-	 * @param string Session id value
158
-	 */
159
-	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
-		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
162
-			$this->handleError($verifKey);
163
-		} else {
164
-			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
166
-				$this->handleError($result);
167
-			}
168
-		}
169
-	}
152
+    /**
153
+     * Deletes a session
154
+     *
155
+     * @param string API secret key
156
+     * @param string Session id field name
157
+     * @param string Session id value
158
+     */
159
+    public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
+        $verifKey = $this->verifyKey($secret_key);
161
+        if($verifKey instanceof WSError) {
162
+            $this->handleError($verifKey);
163
+        } else {
164
+            $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
+            if($result instanceof WSError) {
166
+                $this->handleError($result);
167
+            }
168
+        }
169
+    }
170 170
 
171
-	/**
172
-	 * Edits a session (helper method)
173
-	 *
174
-	 * @param string Name of the session
175
-	 * @param string Start date, use the 'YYYY-MM-DD' format
176
-	 * @param string End date, use the 'YYYY-MM-DD' format
177
-	 * @param int Access delays of the coach (days before)
178
-	 * @param int Access delays of the coach (days after)
179
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
-	 * @param int Visibility
181
-	 * @param string User id field name for the coach
182
-	 * @param string User id value for the coach
183
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
-	 * @param string Original session id value
185
-	 * @param array Array of extra fields
186
-	 * @return mixed True on success, WSError otherwise
187
-	 */
171
+    /**
172
+     * Edits a session (helper method)
173
+     *
174
+     * @param string Name of the session
175
+     * @param string Start date, use the 'YYYY-MM-DD' format
176
+     * @param string End date, use the 'YYYY-MM-DD' format
177
+     * @param int Access delays of the coach (days before)
178
+     * @param int Access delays of the coach (days after)
179
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
+     * @param int Visibility
181
+     * @param string User id field name for the coach
182
+     * @param string User id value for the coach
183
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
+     * @param string Original session id value
185
+     * @param array Array of extra fields
186
+     * @return mixed True on success, WSError otherwise
187
+     */
188 188
     protected function editSessionHelper(
189 189
         $name,
190 190
         $start_date,
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
         $session_id_value,
200 200
         $extras
201 201
     ) {
202
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
204
-			return $session_id;
205
-		} else {
206
-			// Verify that coach exists and get its id
207
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
-			if ($user_id instanceof WSError) {
209
-				return $user_id;
210
-			}
202
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
+        if($session_id instanceof WSError) {
204
+            return $session_id;
205
+        } else {
206
+            // Verify that coach exists and get its id
207
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
+            if ($user_id instanceof WSError) {
209
+                return $user_id;
210
+            }
211 211
 
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
@@ -234,127 +234,127 @@  discard block
 block discarded – undo
234 234
                 0,
235 235
                 (int)$visibility
236 236
             );
237
-			if(!is_int($result_id)) {
238
-				return new WSError(302, 'Could not edit the session');
239
-			} else {
240
-				if(!empty($extras)) {
241
-					$extras_associative = array();
242
-					foreach($extras as $extra) {
243
-						$extras_associative[$extra['field_name']] = $extra['field_value'];
244
-					}
245
-					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
247
-						SessionManager::create_session_extra_field($fname, 1, $fname);
248
-						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
-					}
250
-				}
251
-				return true;
252
-			}
253
-		}
254
-	}
237
+            if(!is_int($result_id)) {
238
+                return new WSError(302, 'Could not edit the session');
239
+            } else {
240
+                if(!empty($extras)) {
241
+                    $extras_associative = array();
242
+                    foreach($extras as $extra) {
243
+                        $extras_associative[$extra['field_name']] = $extra['field_value'];
244
+                    }
245
+                    // Create the extra fields
246
+                    foreach($extras_associative as $fname => $fvalue) {
247
+                        SessionManager::create_session_extra_field($fname, 1, $fname);
248
+                        SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
+                    }
250
+                }
251
+                return true;
252
+            }
253
+        }
254
+    }
255 255
 
256
-	/**
257
-	 * Edits a session
258
-	 *
259
-	 * @param string API secret key
260
-	 * @param string Name of the session
261
-	 * @param string Start date, use the 'YYYY-MM-DD' format
262
-	 * @param string End date, use the 'YYYY-MM-DD' format
263
-	 * @param int Access delays of the coach (days before)
264
-	 * @param int Access delays of the coach (days after)
265
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
-	 * @param int Visibility
267
-	 * @param string User id field name for the coach
268
-	 * @param string User id value for the coach
269
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
-	 * @param string Original session id value
271
-	 * @param array Array of extra fields
272
-	 */
273
-	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
-		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
276
-			$this->handleError($verifKey);
277
-		} else {
278
-			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
280
-				$this->handleError($result);
281
-			}
282
-		}
283
-	}
256
+    /**
257
+     * Edits a session
258
+     *
259
+     * @param string API secret key
260
+     * @param string Name of the session
261
+     * @param string Start date, use the 'YYYY-MM-DD' format
262
+     * @param string End date, use the 'YYYY-MM-DD' format
263
+     * @param int Access delays of the coach (days before)
264
+     * @param int Access delays of the coach (days after)
265
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
+     * @param int Visibility
267
+     * @param string User id field name for the coach
268
+     * @param string User id value for the coach
269
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
+     * @param string Original session id value
271
+     * @param array Array of extra fields
272
+     */
273
+    public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
+        $verifKey = $this->verifyKey($secret_key);
275
+        if($verifKey instanceof WSError) {
276
+            $this->handleError($verifKey);
277
+        } else {
278
+            $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
+            if($session_id_value instanceof WSError) {
280
+                $this->handleError($result);
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Change user subscription (helper method)
287
-	 *
288
-	 * @param string User id field name
289
-	 * @param string User id value
290
-	 * @param string Session id field name
291
-	 * @param string Session id value
292
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
293
-	 * @return mixed True on success, WSError otherwise
294
-	 */
295
-	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
298
-			return $session_id;
299
-		} else {
300
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
302
-				return $user_id;
303
-			} else {
304
-				if($state  == 1) {
305
-					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
-				} else {
307
-					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
-					if (!$result) {
309
-						return new WSError(303, 'There was an error unsubscribing this user from the session');
310
-					}
311
-				}
312
-				return true;
313
-			}
314
-		}
315
-	}
285
+    /**
286
+     * Change user subscription (helper method)
287
+     *
288
+     * @param string User id field name
289
+     * @param string User id value
290
+     * @param string Session id field name
291
+     * @param string Session id value
292
+     * @param int State (1 to subscribe, 0 to unsubscribe)
293
+     * @return mixed True on success, WSError otherwise
294
+     */
295
+    protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
+        if($session_id instanceof WSError) {
298
+            return $session_id;
299
+        } else {
300
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
+            if($user_id instanceof WSError) {
302
+                return $user_id;
303
+            } else {
304
+                if($state  == 1) {
305
+                    SessionManager::suscribe_users_to_session($session_id, array($user_id));
306
+                } else {
307
+                    $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
+                    if (!$result) {
309
+                        return new WSError(303, 'There was an error unsubscribing this user from the session');
310
+                    }
311
+                }
312
+                return true;
313
+            }
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Subscribe user to a session
319
-	 *
320
-	 * @param string API secret key
321
-	 * @param string User id field name
322
-	 * @param string User id value
323
-	 * @param string Session id field name
324
-	 * @param string Session id value
325
-	 */
326
-	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
-		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
329
-			$this->handleError($verifKey);
330
-		} else {
331
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
333
-				$this->handleError($result);
334
-			}
335
-		}
336
-	}
317
+    /**
318
+     * Subscribe user to a session
319
+     *
320
+     * @param string API secret key
321
+     * @param string User id field name
322
+     * @param string User id value
323
+     * @param string Session id field name
324
+     * @param string Session id value
325
+     */
326
+    public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
+        $verifKey = $this->verifyKey($secret_key);
328
+        if($verifKey instanceof WSError) {
329
+            $this->handleError($verifKey);
330
+        } else {
331
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
+            if($result instanceof WSError) {
333
+                $this->handleError($result);
334
+            }
335
+        }
336
+    }
337 337
 
338
-	/**
339
-	 * Subscribe user to a session
340
-	 *
341
-	 * @param string API secret key
342
-	 * @param string User id field name
343
-	 * @param string User id value
344
-	 * @param string Session id field name
345
-	 * @param string Session id value
346
-	 */
347
-	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
-		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
350
-			$this->handleError($verifKey);
351
-		} else {
352
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
354
-				$this->handleError($result);
355
-			}
356
-		}
357
-	}
338
+    /**
339
+     * Subscribe user to a session
340
+     *
341
+     * @param string API secret key
342
+     * @param string User id field name
343
+     * @param string User id value
344
+     * @param string Session id field name
345
+     * @param string Session id value
346
+     */
347
+    public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
+        $verifKey = $this->verifyKey($secret_key);
349
+        if($verifKey instanceof WSError) {
350
+            $this->handleError($verifKey);
351
+        } else {
352
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
+            if($result instanceof WSError) {
354
+                $this->handleError($result);
355
+            }
356
+        }
357
+    }
358 358
     
359 359
     /**
360 360
      * Change Teacher subscription (helper method)
@@ -446,79 +446,79 @@  discard block
 block discarded – undo
446 446
     }
447 447
 
448 448
     /**
449
-	 * Change course subscription
450
-	 *
451
-	 * @param string Course id field name
452
-	 * @param string Course id value
453
-	 * @param string Session id field name
454
-	 * @param string Session id value
455
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
-	 * @return mixed True on success, WSError otherwise
457
-	 */
458
-	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
461
-			return $session_id;
462
-		} else {
463
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
465
-				return $course_id;
466
-			} else {
467
-				if($state  == 1) {
468
-					SessionManager::add_courses_to_session($session_id, array($course_id));
469
-					return true;
470
-				} else {
471
-					$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
-					if ($result) {
473
-						return true;
474
-					} else {
475
-						return new WSError(304, 'Error unsubscribing course from session');
476
-					}
477
-				}
478
-			}
479
-		}
449
+     * Change course subscription
450
+     *
451
+     * @param string Course id field name
452
+     * @param string Course id value
453
+     * @param string Session id field name
454
+     * @param string Session id value
455
+     * @param int State (1 to subscribe, 0 to unsubscribe)
456
+     * @return mixed True on success, WSError otherwise
457
+     */
458
+    protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
+        if($session_id instanceof WSError) {
461
+            return $session_id;
462
+        } else {
463
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
+            if($course_id instanceof WSError) {
465
+                return $course_id;
466
+            } else {
467
+                if($state  == 1) {
468
+                    SessionManager::add_courses_to_session($session_id, array($course_id));
469
+                    return true;
470
+                } else {
471
+                    $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
+                    if ($result) {
473
+                        return true;
474
+                    } else {
475
+                        return new WSError(304, 'Error unsubscribing course from session');
476
+                    }
477
+                }
478
+            }
479
+        }
480 480
     }
481 481
 
482
-	/**
483
-	 * Subscribe course to session
484
-	 *
485
-	 * @param string API secret key
486
-	 * @param string Course id field name
487
-	 * @param string Course id value
488
-	 * @param string Session id field name
489
-	 * @param string Session id value
490
-	 */
491
-	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
-		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
494
-			$this->handleError($verifKey);
495
-		} else {
496
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
498
-				$this->handleError($result);
499
-			}
500
-		}
501
-	}
482
+    /**
483
+     * Subscribe course to session
484
+     *
485
+     * @param string API secret key
486
+     * @param string Course id field name
487
+     * @param string Course id value
488
+     * @param string Session id field name
489
+     * @param string Session id value
490
+     */
491
+    public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
+        $verifKey = $this->verifyKey($secret_key);
493
+        if($verifKey instanceof WSError) {
494
+            $this->handleError($verifKey);
495
+        } else {
496
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
+            if($result instanceof WSError) {
498
+                $this->handleError($result);
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	 * Unsubscribe course from session
505
-	 *
506
-	 * @param string API secret key
507
-	 * @param string Course id field name
508
-	 * @param string Course id value
509
-	 * @param string Session id field name
510
-	 * @param string Session id value
511
-	 */
512
-	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
-		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
515
-			$this->handleError($verifKey);
516
-		} else {
517
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
519
-				$this->handleError($result);
520
-			}
521
-		}
522
-	}
503
+    /**
504
+     * Unsubscribe course from session
505
+     *
506
+     * @param string API secret key
507
+     * @param string Course id field name
508
+     * @param string Course id value
509
+     * @param string Session id field name
510
+     * @param string Session id value
511
+     */
512
+    public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
+        $verifKey = $this->verifyKey($secret_key);
514
+        if($verifKey instanceof WSError) {
515
+            $this->handleError($verifKey);
516
+        } else {
517
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
+            if($result instanceof WSError) {
519
+                $this->handleError($result);
520
+            }
521
+        }
522
+    }
523 523
 
524 524
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 		$coachStartDate = null;
55 55
 		if (!empty($nb_days_access_before)) {
56 56
 			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
57
+			$coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
58 58
 		}
59 59
 
60 60
 		$coachEndDate = null;
61 61
 		if (!empty($nb_days_access_after)) {
62 62
 			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
63
+			$coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
64 64
 		}
65 65
 
66 66
 		// Try to create the session
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 			0,
77 77
 			$visibility
78 78
 		);
79
-		if(!is_int($session_id)) {
79
+		if (!is_int($session_id)) {
80 80
 			return new WSError(301, 'Could not create the session');
81 81
 		} else {
82 82
 			// Add the Original session id to the extra fields
83 83
 			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
84
+			if ($session_id_field_name != "chamilo_session_id") {
85 85
 				$extras_associative[$session_id_field_name] = $session_id_value;
86 86
 			}
87
-			foreach($extras as $extra) {
87
+			foreach ($extras as $extra) {
88 88
 				$extras_associative[$extra['field_name']] = $extra['field_value'];
89 89
 			}
90 90
 			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
91
+			foreach ($extras_associative as $fname => $fvalue) {
92 92
 				SessionManager::create_session_extra_field($fname, 1, $fname);
93 93
 				SessionManager::update_session_extra_field_value(
94 94
 					$session_id,
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122 122
 		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
123
+		if ($verifKey instanceof WSError) {
124 124
 			$this->handleError($verifKey);
125 125
 		} else {
126 126
 			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
127
+			if ($session_id instanceof WSError) {
128 128
 				$this->handleError($session_id);
129 129
 			} else {
130 130
 				return $session_id;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143 143
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
144
+		if ($session_id instanceof WSError) {
145 145
 			return $session_id;
146 146
 		} else {
147 147
 			SessionManager::delete($session_id, true);
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160 160
 		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
161
+		if ($verifKey instanceof WSError) {
162 162
 			$this->handleError($verifKey);
163 163
 		} else {
164 164
 			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
165
+			if ($result instanceof WSError) {
166 166
 				$this->handleError($result);
167 167
 			}
168 168
 		}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         $extras
201 201
     ) {
202 202
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
203
+		if ($session_id instanceof WSError) {
204 204
 			return $session_id;
205 205
 		} else {
206 206
 			// Verify that coach exists and get its id
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
214 214
                 $day = intval($nb_days_access_before);
215
-                $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
215
+                $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days'));
216 216
             }
217 217
 
218 218
             $coachEndDate = null;
219 219
             if (!empty($nb_days_access_after)) {
220 220
                 $day = intval($nb_days_access_after);
221
-                $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
221
+                $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days'));
222 222
             }
223 223
 
224 224
             $result_id = SessionManager::edit_session(
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
                 $coachEndDate,
233 233
                 $user_id,
234 234
                 0,
235
-                (int)$visibility
235
+                (int) $visibility
236 236
             );
237
-			if(!is_int($result_id)) {
237
+			if (!is_int($result_id)) {
238 238
 				return new WSError(302, 'Could not edit the session');
239 239
 			} else {
240
-				if(!empty($extras)) {
240
+				if (!empty($extras)) {
241 241
 					$extras_associative = array();
242
-					foreach($extras as $extra) {
242
+					foreach ($extras as $extra) {
243 243
 						$extras_associative[$extra['field_name']] = $extra['field_value'];
244 244
 					}
245 245
 					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
246
+					foreach ($extras_associative as $fname => $fvalue) {
247 247
 						SessionManager::create_session_extra_field($fname, 1, $fname);
248 248
 						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249 249
 					}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274 274
 		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
275
+		if ($verifKey instanceof WSError) {
276 276
 			$this->handleError($verifKey);
277 277
 		} else {
278 278
 			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
279
+			if ($session_id_value instanceof WSError) {
280 280
 				$this->handleError($result);
281 281
 			}
282 282
 		}
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296 296
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
297
+		if ($session_id instanceof WSError) {
298 298
 			return $session_id;
299 299
 		} else {
300 300
 			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
301
+			if ($user_id instanceof WSError) {
302 302
 				return $user_id;
303 303
 			} else {
304
-				if($state  == 1) {
304
+				if ($state == 1) {
305 305
 					SessionManager::suscribe_users_to_session($session_id, array($user_id));
306 306
 				} else {
307 307
 					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327 327
 		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
328
+		if ($verifKey instanceof WSError) {
329 329
 			$this->handleError($verifKey);
330 330
 		} else {
331 331
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
332
+			if ($result instanceof WSError) {
333 333
 				$this->handleError($result);
334 334
 			}
335 335
 		}
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348 348
 		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
349
+		if ($verifKey instanceof WSError) {
350 350
 			$this->handleError($verifKey);
351 351
 		} else {
352 352
 			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
353
+			if ($result instanceof WSError) {
354 354
 				$this->handleError($result);
355 355
 			}
356 356
 		}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                     if ($state == 1) {
386 386
                         SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id);
387 387
                     } else {
388
-                        $user_id = array (0 => $user_id);
388
+                        $user_id = array(0 => $user_id);
389 389
                         $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id);
390 390
                         if (!$result) {
391 391
                             return new WSError(303, 'There was an error unsubscribing this Teacher from the session');
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459 459
 		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
460
+		if ($session_id instanceof WSError) {
461 461
 			return $session_id;
462 462
 		} else {
463 463
 			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
464
+			if ($course_id instanceof WSError) {
465 465
 				return $course_id;
466 466
 			} else {
467
-				if($state  == 1) {
467
+				if ($state == 1) {
468 468
 					SessionManager::add_courses_to_session($session_id, array($course_id));
469 469
 					return true;
470 470
 				} else {
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492 492
 		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
493
+		if ($verifKey instanceof WSError) {
494 494
 			$this->handleError($verifKey);
495 495
 		} else {
496 496
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
497
+			if ($result instanceof WSError) {
498 498
 				$this->handleError($result);
499 499
 			}
500 500
 		}
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	 */
512 512
 	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513 513
 		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
514
+		if ($verifKey instanceof WSError) {
515 515
 			$this->handleError($verifKey);
516 516
 		} else {
517 517
 			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
518
+			if ($result instanceof WSError) {
519 519
 				$this->handleError($result);
520 520
 			}
521 521
 		}
Please login to merge, or discard this patch.
main/webservices/webservice_user.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -36,6 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param array Users
38 38
 	 * @param int Set to 1 to enable and to 0 to disable
39
+	 * @param integer $state
39 40
 	 * @return array Array of results
40 41
 	 */
41 42
 	protected function changeUsersActiveState($users, $state) {
@@ -217,6 +218,11 @@  discard block
 block discarded – undo
217 218
 	 * @param string Phone.
218 219
 	 * @param string Expiration date
219 220
 	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
221
+	 * @param integer|null $visibility
222
+	 * @param string|null $email
223
+	 * @param string|null $language
224
+	 * @param string|null $phone
225
+	 * @param string|null $expiration_date
220 226
 	 * @return mixed New user id generated by the system, WSError otherwise
221 227
 	 */
222 228
 	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
Please login to merge, or discard this patch.
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -11,458 +11,458 @@
 block discarded – undo
11 11
  */
12 12
 class WSUser extends WS {
13 13
 
14
-	/**
15
-	 * Enables or disables a user
16
-	 *
17
-	 * @param string User id field name
18
-	 * @param string User id value
19
-	 * @param int Set to 1 to enable and to 0 to disable
20
-	 */
21
-	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
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
-			if($state == 0) {
27
-				UserManager::disable($user_id);
28
-			} else if($state == 1) {
29
-				UserManager::enable($user_id);
30
-			}
31
-		}
32
-	}
14
+    /**
15
+     * Enables or disables a user
16
+     *
17
+     * @param string User id field name
18
+     * @param string User id value
19
+     * @param int Set to 1 to enable and to 0 to disable
20
+     */
21
+    protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
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
+            if($state == 0) {
27
+                UserManager::disable($user_id);
28
+            } else if($state == 1) {
29
+                UserManager::enable($user_id);
30
+            }
31
+        }
32
+    }
33 33
 
34
-	/**
35
-	 * Enables or disables multiple users
36
-	 *
37
-	 * @param array Users
38
-	 * @param int Set to 1 to enable and to 0 to disable
39
-	 * @return array Array of results
40
-	 */
41
-	protected function changeUsersActiveState($users, $state) {
42
-		$results = array();
43
-		foreach($users as $user) {
44
-			$result_tmp = array();
45
-			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
-			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
48
-				// Return the error in the results
49
-				$result_tmp['result'] = $result_op->toArray();
50
-			} else {
51
-				$result_tmp['result'] = $this->getSuccessfulResult();
52
-			}
53
-			$results[] = $result_tmp;
54
-		}
55
-		return $results;
56
-	}
34
+    /**
35
+     * Enables or disables multiple users
36
+     *
37
+     * @param array Users
38
+     * @param int Set to 1 to enable and to 0 to disable
39
+     * @return array Array of results
40
+     */
41
+    protected function changeUsersActiveState($users, $state) {
42
+        $results = array();
43
+        foreach($users as $user) {
44
+            $result_tmp = array();
45
+            $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46
+            $result_tmp['user_id_value'] = $user['user_id_value'];
47
+            if($result_op instanceof WSError) {
48
+                // Return the error in the results
49
+                $result_tmp['result'] = $result_op->toArray();
50
+            } else {
51
+                $result_tmp['result'] = $this->getSuccessfulResult();
52
+            }
53
+            $results[] = $result_tmp;
54
+        }
55
+        return $results;
56
+    }
57 57
 
58
-	/**
59
-	 * Disables a user
60
-	 *
61
-	 * @param string API secret key
62
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
-	 * @param string User id value
64
-	 */
65
-	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
-		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
68
-			// Let the implementation handle it
69
-			$this->handleError($verifKey);
70
-		} else {
71
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
73
-				$this->handleError($result);
74
-			}
75
-		}
76
-	}
58
+    /**
59
+     * Disables a user
60
+     *
61
+     * @param string API secret key
62
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
63
+     * @param string User id value
64
+     */
65
+    public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66
+        $verifKey = $this->verifyKey($secret_key);
67
+        if($verifKey instanceof WSError) {
68
+            // Let the implementation handle it
69
+            $this->handleError($verifKey);
70
+        } else {
71
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
+            if($result instanceof WSError) {
73
+                $this->handleError($result);
74
+            }
75
+        }
76
+    }
77 77
 
78
-	/**
79
-	 * Disables multiple users
80
-	 *
81
-	 * @param string API secret key
82
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
-	 * than 0, an error occured
85
-	 */
86
-	public function DisableUsers($secret_key, $users) {
87
-		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
89
-			// Let the implementation handle it
90
-			$this->handleError($verifKey);
91
-		} else {
92
-			return $this->changeUsersActiveState($users, 0);
93
-		}
94
-	}
78
+    /**
79
+     * Disables multiple users
80
+     *
81
+     * @param string API secret key
82
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
83
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
84
+     * than 0, an error occured
85
+     */
86
+    public function DisableUsers($secret_key, $users) {
87
+        $verifKey = $this->verifyKey($secret_key);
88
+        if($verifKey instanceof WSError) {
89
+            // Let the implementation handle it
90
+            $this->handleError($verifKey);
91
+        } else {
92
+            return $this->changeUsersActiveState($users, 0);
93
+        }
94
+    }
95 95
 
96
-	/**
97
-	 * Enables a user
98
-	 *
99
-	 * @param string API secret key
100
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
-	 * @param string User id value
102
-	 */
103
-	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
-		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
106
-			$this->handleError($verifKey);
107
-		} else {
108
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
110
-				$this->handleError($result);
111
-			}
112
-		}
113
-	}
96
+    /**
97
+     * Enables a user
98
+     *
99
+     * @param string API secret key
100
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
101
+     * @param string User id value
102
+     */
103
+    public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104
+        $verifKey = $this->verifyKey($secret_key);
105
+        if($verifKey instanceof WSError) {
106
+            $this->handleError($verifKey);
107
+        } else {
108
+            $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
+            if($result instanceof WSError) {
110
+                $this->handleError($result);
111
+            }
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Enables multiple users
117
-	 *
118
-	 * @param string API secret key
119
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
-	 * than 0, an error occured
122
-	 */
123
-	public function EnableUsers($secret_key, $users) {
124
-		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
126
-			// Let the implementation handle it
127
-			$this->handleError($verifKey);
128
-		} else {
129
-			return $this->changeUsersActiveState($users, 1);
130
-		}
131
-	}
115
+    /**
116
+     * Enables multiple users
117
+     *
118
+     * @param string API secret key
119
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
120
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
121
+     * than 0, an error occured
122
+     */
123
+    public function EnableUsers($secret_key, $users) {
124
+        $verifKey = $this->verifyKey($secret_key);
125
+        if($verifKey instanceof WSError) {
126
+            // Let the implementation handle it
127
+            $this->handleError($verifKey);
128
+        } else {
129
+            return $this->changeUsersActiveState($users, 1);
130
+        }
131
+    }
132 132
 
133
-	/**
134
-	 * Deletes a user (helper method)
135
-	 *
136
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
-	 * @param string User id value
138
-	 * @return mixed True if user was successfully deleted, WSError otherwise
139
-	 */
140
-	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
143
-			return $user_id;
144
-		} else {
145
-			if(!UserManager::delete_user($user_id)) {
146
-				return new WSError(101, "There was a problem while deleting this user");
147
-			} else {
148
-				return true;
149
-			}
150
-		}
151
-	}
133
+    /**
134
+     * Deletes a user (helper method)
135
+     *
136
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
137
+     * @param string User id value
138
+     * @return mixed True if user was successfully deleted, WSError otherwise
139
+     */
140
+    protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
+        if($user_id instanceof WSError) {
143
+            return $user_id;
144
+        } else {
145
+            if(!UserManager::delete_user($user_id)) {
146
+                return new WSError(101, "There was a problem while deleting this user");
147
+            } else {
148
+                return true;
149
+            }
150
+        }
151
+    }
152 152
 
153
-	/**
154
-	 * Deletes a user
155
-	 *
156
-	 * @param string API secret key
157
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
-	 * @param string User id value
159
-	 */
160
-	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
-		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
163
-			$this->handleError($verifKey);
164
-		} else {
165
-			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
167
-				$this->handleError($result);
168
-			}
169
-		}
170
-	}
153
+    /**
154
+     * Deletes a user
155
+     *
156
+     * @param string API secret key
157
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
158
+     * @param string User id value
159
+     */
160
+    public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161
+        $verifKey = $this->verifyKey($secret_key);
162
+        if($verifKey instanceof WSError) {
163
+            $this->handleError($verifKey);
164
+        } else {
165
+            $result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
+            if($result instanceof WSError) {
167
+                $this->handleError($result);
168
+            }
169
+        }
170
+    }
171 171
 
172
-	/**
173
-	 * Deletes multiple users
174
-	 *
175
-	 * @param string API secret key
176
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
-	 * than 0, an error occured
179
-	 */
180
-	public function DeleteUsers($secret_key, $users) {
181
-		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
183
-			$this->handleError($verifKey);
184
-		} else {
185
-			$results = array();
186
-			foreach($users as $user) {
187
-				$result_tmp = array();
188
-				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
-				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
191
-					// Return the error in the results
192
-					$result_tmp['result'] = $result_op->toArray();
193
-				} else {
194
-					$result_tmp['result'] = $this->getSuccessfulResult();
195
-				}
196
-				$results[] = $result_tmp;
197
-			}
198
-			return $results;
199
-		}
200
-	}
172
+    /**
173
+     * Deletes multiple users
174
+     *
175
+     * @param string API secret key
176
+     * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
177
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
178
+     * than 0, an error occured
179
+     */
180
+    public function DeleteUsers($secret_key, $users) {
181
+        $verifKey = $this->verifyKey($secret_key);
182
+        if($verifKey instanceof WSError) {
183
+            $this->handleError($verifKey);
184
+        } else {
185
+            $results = array();
186
+            foreach($users as $user) {
187
+                $result_tmp = array();
188
+                $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189
+                $result_tmp['user_id_value'] = $user['user_id_value'];
190
+                if($result_op instanceof WSError) {
191
+                    // Return the error in the results
192
+                    $result_tmp['result'] = $result_op->toArray();
193
+                } else {
194
+                    $result_tmp['result'] = $this->getSuccessfulResult();
195
+                }
196
+                $results[] = $result_tmp;
197
+            }
198
+            return $results;
199
+        }
200
+    }
201 201
 
202
-	/**
203
-	 * Creates a user (helper method)
204
-	 *
205
-	 * @param string User first name
206
-	 * @param string User last name
207
-	 * @param int User status
208
-	 * @param string Login name
209
-	 * @param string Password (encrypted or not)
210
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
-	 * to include the salt in the extra fields if you are encrypting the password
212
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
-	 * @param string User id value. Leave blank if you are using the internal user_id
214
-	 * @param int Visibility.
215
-	 * @param string User email.
216
-	 * @param string Language.
217
-	 * @param string Phone.
218
-	 * @param string Expiration date
219
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
-	 * @return mixed New user id generated by the system, WSError otherwise
221
-	 */
222
-	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
202
+    /**
203
+     * Creates a user (helper method)
204
+     *
205
+     * @param string User first name
206
+     * @param string User last name
207
+     * @param int User status
208
+     * @param string Login name
209
+     * @param string Password (encrypted or not)
210
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
211
+     * to include the salt in the extra fields if you are encrypting the password
212
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
213
+     * @param string User id value. Leave blank if you are using the internal user_id
214
+     * @param int Visibility.
215
+     * @param string User email.
216
+     * @param string Language.
217
+     * @param string Phone.
218
+     * @param string Expiration date
219
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
220
+     * @return mixed New user id generated by the system, WSError otherwise
221
+     */
222
+    protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
223 223
         global $api_failureList;
224
-		// Add the original user id field name and value to the extra fields if needed
225
-		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
227
-			$extras_associative[$user_id_field_name] = $user_id_value;
228
-		}
224
+        // Add the original user id field name and value to the extra fields if needed
225
+        $extras_associative = array();
226
+        if($user_id_field_name != "chamilo_user_id") {
227
+            $extras_associative[$user_id_field_name] = $user_id_value;
228
+        }
229 229
                 if (!empty($extras)) {
230 230
                     foreach($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
234
-		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
-		if (!$result) {
236
-			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
238
-				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
240
-				return new WSError(103, 'The encryption of the password is invalid');
241
-			} else {
242
-				return new WSError(104, 'There was an error creating the user');
243
-			}
244
-		} else {
245
-			return $result;
246
-		}
247
-	}
234
+        $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235
+        if (!$result) {
236
+            $failure = $api_failureList[0];
237
+            if($failure == 'login-pass already taken') {
238
+                return new WSError(102, 'This username is already taken');
239
+            } else if($failure == 'encrypt_method invalid') {
240
+                return new WSError(103, 'The encryption of the password is invalid');
241
+            } else {
242
+                return new WSError(104, 'There was an error creating the user');
243
+            }
244
+        } else {
245
+            return $result;
246
+        }
247
+    }
248 248
 
249
-	/**
250
-	 * Creates a user
251
-	 *
252
-	 * @param string API secret key
253
-	 * @param string User first name
254
-	 * @param string User last name
255
-	 * @param int User status
256
-	 * @param string Login name
257
-	 * @param string Password (encrypted or not)
258
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
259
-	 * to include the salt in the extra fields if you are encrypting the password
260
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
-	 * @param string User id value. Leave blank if you are using the internal user_id
262
-	 * @param int Visibility. Set by default to 1
263
-	 * @param string User email. Set by default to an empty string
264
-	 * @param string Language. Set by default to english
265
-	 * @param string Phone. Set by default to an empty string
266
-	 * @param string Expiration date. Set to null by default
267
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
268
-	 * @return int New user id generated by the system
269
-	 */
270
-	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271
-		// First, verify the secret key
272
-		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
274
-			$this->handleError($verifKey);
275
-		} else {
276
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
278
-				$this->handleError($result);
279
-			} else {
280
-				return $result;
281
-			}
282
-		}
283
-	}
249
+    /**
250
+     * Creates a user
251
+     *
252
+     * @param string API secret key
253
+     * @param string User first name
254
+     * @param string User last name
255
+     * @param int User status
256
+     * @param string Login name
257
+     * @param string Password (encrypted or not)
258
+     * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
259
+     * to include the salt in the extra fields if you are encrypting the password
260
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
+     * @param string User id value. Leave blank if you are using the internal user_id
262
+     * @param int Visibility. Set by default to 1
263
+     * @param string User email. Set by default to an empty string
264
+     * @param string Language. Set by default to english
265
+     * @param string Phone. Set by default to an empty string
266
+     * @param string Expiration date. Set to null by default
267
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
268
+     * @return int New user id generated by the system
269
+     */
270
+    public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271
+        // First, verify the secret key
272
+        $verifKey = $this->verifyKey($secret_key);
273
+        if($verifKey instanceof WSError) {
274
+            $this->handleError($verifKey);
275
+        } else {
276
+            $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
+            if($result instanceof WSError) {
278
+                $this->handleError($result);
279
+            } else {
280
+                return $result;
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Creates multiple users
287
-	 *
288
-	 * @param string API secret key
289
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
-	 * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
291
-	 */
292
-	public function CreateUsers($secret_key, $users) {
293
-		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
295
-			$this->handleError($verifKey);
296
-		} else {
297
-			$results = array();
298
-			foreach($users as $user) {
299
-				$result_tmp = array();
285
+    /**
286
+     * Creates multiple users
287
+     *
288
+     * @param string API secret key
289
+     * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
+     * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
291
+     */
292
+    public function CreateUsers($secret_key, $users) {
293
+        $verifKey = $this->verifyKey($secret_key);
294
+        if($verifKey instanceof WSError) {
295
+            $this->handleError($verifKey);
296
+        } else {
297
+            $results = array();
298
+            foreach($users as $user) {
299
+                $result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302
-				extract($user);
303
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
305
-					$result_tmp['result'] = $result->toArray();
306
-					$result_tmp['user_id_value'] = $user_id_value;
307
-					$result_tmp['user_id_generated'] = 0;
308
-				} else {
309
-					$result_tmp['result'] = $this->getSuccessfulResult();
310
-					$result_tmp['user_id_value'] = $user_id_value;
311
-					$result_tmp['user_id_generated'] = $result;
312
-				}
313
-				$results[] = $result_tmp;
314
-			}
315
-			return $results;
316
-		}
317
-	}
302
+                extract($user);
303
+                $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
+                if($result instanceof WSError) {
305
+                    $result_tmp['result'] = $result->toArray();
306
+                    $result_tmp['user_id_value'] = $user_id_value;
307
+                    $result_tmp['user_id_generated'] = 0;
308
+                } else {
309
+                    $result_tmp['result'] = $this->getSuccessfulResult();
310
+                    $result_tmp['user_id_value'] = $user_id_value;
311
+                    $result_tmp['user_id_generated'] = $result;
312
+                }
313
+                $results[] = $result_tmp;
314
+            }
315
+            return $results;
316
+        }
317
+    }
318 318
 
319
-	/**
320
-	 * Edits user info (helper method)
321
-	 *
322
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
-	 * @param string User id value
324
-	 * @param string First name
325
-	 * @param string Last name
326
-	 * @param int User status
327
-	 * @param string Login name
328
-	 * @param string Password. Leave blank if you don't want to update it
329
-	 * @param string Encrypt method
330
-	 * @param string User email
331
-	 * @param string Language. Set by default to english
332
-	 * @param string Phone. Set by default to an empty string
333
-	 * @param string Expiration date. Set to null by default
334
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
335
-	 * @return mixed True if user was successfully updated, WSError otherwise
336
-	 */
337
-	protected function editUserHelper(
338
-		$user_id_field_name,
339
-		$user_id_value,
340
-		$firstname,
341
-		$lastname,
342
-		$status,
343
-		$loginname,
344
-		$password,
345
-		$encrypt_method,
346
-		$email,
347
-		$language,
348
-		$phone,
349
-		$expiration_date,
350
-		$extras
351
-	) {
319
+    /**
320
+     * Edits user info (helper method)
321
+     *
322
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
+     * @param string User id value
324
+     * @param string First name
325
+     * @param string Last name
326
+     * @param int User status
327
+     * @param string Login name
328
+     * @param string Password. Leave blank if you don't want to update it
329
+     * @param string Encrypt method
330
+     * @param string User email
331
+     * @param string Language. Set by default to english
332
+     * @param string Phone. Set by default to an empty string
333
+     * @param string Expiration date. Set to null by default
334
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
335
+     * @return mixed True if user was successfully updated, WSError otherwise
336
+     */
337
+    protected function editUserHelper(
338
+        $user_id_field_name,
339
+        $user_id_value,
340
+        $firstname,
341
+        $lastname,
342
+        $status,
343
+        $loginname,
344
+        $password,
345
+        $encrypt_method,
346
+        $email,
347
+        $language,
348
+        $phone,
349
+        $expiration_date,
350
+        $extras
351
+    ) {
352 352
         global $api_failureList;
353
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
355
-			return $user_id;
356
-		} else {
357
-			if($password == '') {
358
-				$password = null;
359
-			}
360
-			$user_info = api_get_user_info($user_id);
361
-			if (count($extras) == 0) {
362
-				$extras = null;
363
-			}
353
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
+        if($user_id instanceof WSError) {
355
+            return $user_id;
356
+        } else {
357
+            if($password == '') {
358
+                $password = null;
359
+            }
360
+            $user_info = api_get_user_info($user_id);
361
+            if (count($extras) == 0) {
362
+                $extras = null;
363
+            }
364 364
 
365
-			$result = UserManager::update_user(
366
-				$user_id,
367
-				$firstname,
368
-				$lastname,
369
-				$loginname,
370
-				$password,
371
-				PLATFORM_AUTH_SOURCE,
372
-				$email,
373
-				$status,
374
-				'',
375
-				$phone,
376
-				$user_info['picture_uri'],
377
-				$expiration_date,
378
-				$user_info['active'],
379
-				null,
380
-				$user_info['hr_dept_id'],
381
-				$extras,
382
-				$encrypt_method
383
-			);
384
-			if (!$result) {
385
-				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
387
-					return new WSError(103, 'The encryption of the password is invalid');
388
-				} else {
389
-					return new WSError(105, 'There was an error updating the user');
390
-				}
391
-			} else {
392
-				return $result;
393
-			}
394
-		}
395
-	}
365
+            $result = UserManager::update_user(
366
+                $user_id,
367
+                $firstname,
368
+                $lastname,
369
+                $loginname,
370
+                $password,
371
+                PLATFORM_AUTH_SOURCE,
372
+                $email,
373
+                $status,
374
+                '',
375
+                $phone,
376
+                $user_info['picture_uri'],
377
+                $expiration_date,
378
+                $user_info['active'],
379
+                null,
380
+                $user_info['hr_dept_id'],
381
+                $extras,
382
+                $encrypt_method
383
+            );
384
+            if (!$result) {
385
+                $failure = $api_failureList[0];
386
+                if($failure == 'encrypt_method invalid') {
387
+                    return new WSError(103, 'The encryption of the password is invalid');
388
+                } else {
389
+                    return new WSError(105, 'There was an error updating the user');
390
+                }
391
+            } else {
392
+                return $result;
393
+            }
394
+        }
395
+    }
396 396
 
397
-	/**
398
-	 * Edits user info
399
-	 *
400
-	 * @param string API secret key
401
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
-	 * @param string User id value
403
-	 * @param string First name
404
-	 * @param string Last name
405
-	 * @param int User status
406
-	 * @param string Login name
407
-	 * @param string Password. Leave blank if you don't want to update it
408
-	 * @param string Encrypt method
409
-	 * @param string User email
410
-	 * @param string Language. Set by default to english
411
-	 * @param string Phone. Set by default to an empty string
412
-	 * @param string Expiration date. Set to null by default
413
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
414
-	 */
415
-	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416
-		// First, verify the secret key
417
-		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
419
-			$this->handleError($verifKey);
420
-		} else {
397
+    /**
398
+     * Edits user info
399
+     *
400
+     * @param string API secret key
401
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
+     * @param string User id value
403
+     * @param string First name
404
+     * @param string Last name
405
+     * @param int User status
406
+     * @param string Login name
407
+     * @param string Password. Leave blank if you don't want to update it
408
+     * @param string Encrypt method
409
+     * @param string User email
410
+     * @param string Language. Set by default to english
411
+     * @param string Phone. Set by default to an empty string
412
+     * @param string Expiration date. Set to null by default
413
+     * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
414
+     */
415
+    public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416
+        // First, verify the secret key
417
+        $verifKey = $this->verifyKey($secret_key);
418
+        if($verifKey instanceof WSError) {
419
+            $this->handleError($verifKey);
420
+        } else {
421 421
 
422
-			$extras_associative = array();
423
-			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
425
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
426
-				}
427
-			}
422
+            $extras_associative = array();
423
+            if (!empty($extras)) {
424
+                foreach($extras as $extra) {
425
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
426
+                }
427
+            }
428 428
 
429
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
431
-				$this->handleError($result);
432
-			}
433
-		}
434
-	}
429
+            $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
+            if($result instanceof WSError) {
431
+                $this->handleError($result);
432
+            }
433
+        }
434
+    }
435 435
 
436
-	/**
437
-	 * Edits multiple users
438
-	 *
439
-	 * @param string API secret key
440
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
442
-	 * than 0, an error occured
443
-	 */
444
-	public function EditUsers($secret_key, $users) {
445
-		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
447
-			$this->handleError($verifKey);
448
-		} else {
449
-			$results = array();
450
-			foreach($users as $user) {
451
-				$result_tmp = array();
436
+    /**
437
+     * Edits multiple users
438
+     *
439
+     * @param string API secret key
440
+     * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
+     * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
442
+     * than 0, an error occured
443
+     */
444
+    public function EditUsers($secret_key, $users) {
445
+        $verifKey = $this->verifyKey($secret_key);
446
+        if($verifKey instanceof WSError) {
447
+            $this->handleError($verifKey);
448
+        } else {
449
+            $results = array();
450
+            foreach($users as $user) {
451
+                $result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454
-				extract($user);
455
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
-				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
458
-					// Return the error in the results
459
-					$result_tmp['result'] = $result_op->toArray();
460
-				} else {
461
-					$result_tmp['result'] = $this->getSuccessfulResult();
462
-				}
463
-				$results[] = $result_tmp;
464
-			}
465
-			return $results;
466
-		}
467
-	}
454
+                extract($user);
455
+                $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
+                $result_tmp['user_id_value'] = $user['user_id_value'];
457
+                if($result_op instanceof WSError) {
458
+                    // Return the error in the results
459
+                    $result_tmp['result'] = $result_op->toArray();
460
+                } else {
461
+                    $result_tmp['result'] = $this->getSuccessfulResult();
462
+                }
463
+                $results[] = $result_tmp;
464
+            }
465
+            return $results;
466
+        }
467
+    }
468 468
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
22 22
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
23
-		if($user_id instanceof WSError) {
23
+		if ($user_id instanceof WSError) {
24 24
 			return $user_id;
25 25
 		} else {
26
-			if($state == 0) {
26
+			if ($state == 0) {
27 27
 				UserManager::disable($user_id);
28
-			} else if($state == 1) {
28
+			} else if ($state == 1) {
29 29
 				UserManager::enable($user_id);
30 30
 			}
31 31
 		}
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected function changeUsersActiveState($users, $state) {
42 42
 		$results = array();
43
-		foreach($users as $user) {
43
+		foreach ($users as $user) {
44 44
 			$result_tmp = array();
45 45
 			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
46 46
 			$result_tmp['user_id_value'] = $user['user_id_value'];
47
-			if($result_op instanceof WSError) {
47
+			if ($result_op instanceof WSError) {
48 48
 				// Return the error in the results
49 49
 				$result_tmp['result'] = $result_op->toArray();
50 50
 			} else {
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
66 66
 		$verifKey = $this->verifyKey($secret_key);
67
-		if($verifKey instanceof WSError) {
67
+		if ($verifKey instanceof WSError) {
68 68
 			// Let the implementation handle it
69 69
 			$this->handleError($verifKey);
70 70
 		} else {
71 71
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
72
-			if($result instanceof WSError) {
72
+			if ($result instanceof WSError) {
73 73
 				$this->handleError($result);
74 74
 			}
75 75
 		}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function DisableUsers($secret_key, $users) {
87 87
 		$verifKey = $this->verifyKey($secret_key);
88
-		if($verifKey instanceof WSError) {
88
+		if ($verifKey instanceof WSError) {
89 89
 			// Let the implementation handle it
90 90
 			$this->handleError($verifKey);
91 91
 		} else {
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
104 104
 		$verifKey = $this->verifyKey($secret_key);
105
-		if($verifKey instanceof WSError) {
105
+		if ($verifKey instanceof WSError) {
106 106
 			$this->handleError($verifKey);
107 107
 		} else {
108 108
 			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
109
-			if($result instanceof WSError) {
109
+			if ($result instanceof WSError) {
110 110
 				$this->handleError($result);
111 111
 			}
112 112
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function EnableUsers($secret_key, $users) {
124 124
 		$verifKey = $this->verifyKey($secret_key);
125
-		if($verifKey instanceof WSError) {
125
+		if ($verifKey instanceof WSError) {
126 126
 			// Let the implementation handle it
127 127
 			$this->handleError($verifKey);
128 128
 		} else {
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
141 141
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
142
-		if($user_id instanceof WSError) {
142
+		if ($user_id instanceof WSError) {
143 143
 			return $user_id;
144 144
 		} else {
145
-			if(!UserManager::delete_user($user_id)) {
145
+			if (!UserManager::delete_user($user_id)) {
146 146
 				return new WSError(101, "There was a problem while deleting this user");
147 147
 			} else {
148 148
 				return true;
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
161 161
 		$verifKey = $this->verifyKey($secret_key);
162
-		if($verifKey instanceof WSError) {
162
+		if ($verifKey instanceof WSError) {
163 163
 			$this->handleError($verifKey);
164 164
 		} else {
165 165
 			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
166
-			if($result instanceof WSError) {
166
+			if ($result instanceof WSError) {
167 167
 				$this->handleError($result);
168 168
 			}
169 169
 		}
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function DeleteUsers($secret_key, $users) {
181 181
 		$verifKey = $this->verifyKey($secret_key);
182
-		if($verifKey instanceof WSError) {
182
+		if ($verifKey instanceof WSError) {
183 183
 			$this->handleError($verifKey);
184 184
 		} else {
185 185
 			$results = array();
186
-			foreach($users as $user) {
186
+			foreach ($users as $user) {
187 187
 				$result_tmp = array();
188 188
 				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
189 189
 				$result_tmp['user_id_value'] = $user['user_id_value'];
190
-				if($result_op instanceof WSError) {
190
+				if ($result_op instanceof WSError) {
191 191
 					// Return the error in the results
192 192
 					$result_tmp['result'] = $result_op->toArray();
193 193
 				} else {
@@ -223,20 +223,20 @@  discard block
 block discarded – undo
223 223
         global $api_failureList;
224 224
 		// Add the original user id field name and value to the extra fields if needed
225 225
 		$extras_associative = array();
226
-		if($user_id_field_name != "chamilo_user_id") {
226
+		if ($user_id_field_name != "chamilo_user_id") {
227 227
 			$extras_associative[$user_id_field_name] = $user_id_value;
228 228
 		}
229 229
                 if (!empty($extras)) {
230
-                    foreach($extras as $extra) {
230
+                    foreach ($extras as $extra) {
231 231
                         $extras_associative[$extra['field_name']] = $extra['field_value'];
232 232
                     }
233 233
                 }
234 234
 		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
235 235
 		if (!$result) {
236 236
 			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
237
+			if ($failure == 'login-pass already taken') {
238 238
 				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
239
+			} else if ($failure == 'encrypt_method invalid') {
240 240
 				return new WSError(103, 'The encryption of the password is invalid');
241 241
 			} else {
242 242
 				return new WSError(104, 'There was an error creating the user');
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
271 271
 		// First, verify the secret key
272 272
 		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
273
+		if ($verifKey instanceof WSError) {
274 274
 			$this->handleError($verifKey);
275 275
 		} else {
276 276
 			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
277
+			if ($result instanceof WSError) {
278 278
 				$this->handleError($result);
279 279
 			} else {
280 280
 				return $result;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function CreateUsers($secret_key, $users) {
293 293
 		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
294
+		if ($verifKey instanceof WSError) {
295 295
 			$this->handleError($verifKey);
296 296
 		} else {
297 297
 			$results = array();
298
-			foreach($users as $user) {
298
+			foreach ($users as $user) {
299 299
 				$result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302 302
 				extract($user);
303 303
 				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
304
+				if ($result instanceof WSError) {
305 305
 					$result_tmp['result'] = $result->toArray();
306 306
 					$result_tmp['user_id_value'] = $user_id_value;
307 307
 					$result_tmp['user_id_generated'] = 0;
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 	) {
352 352
         global $api_failureList;
353 353
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
354
+		if ($user_id instanceof WSError) {
355 355
 			return $user_id;
356 356
 		} else {
357
-			if($password == '') {
357
+			if ($password == '') {
358 358
 				$password = null;
359 359
 			}
360 360
 			$user_info = api_get_user_info($user_id);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			);
384 384
 			if (!$result) {
385 385
 				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
386
+				if ($failure == 'encrypt_method invalid') {
387 387
 					return new WSError(103, 'The encryption of the password is invalid');
388 388
 				} else {
389 389
 					return new WSError(105, 'There was an error updating the user');
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
 	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
416 416
 		// First, verify the secret key
417 417
 		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
418
+		if ($verifKey instanceof WSError) {
419 419
 			$this->handleError($verifKey);
420 420
 		} else {
421 421
 
422 422
 			$extras_associative = array();
423 423
 			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
424
+				foreach ($extras as $extra) {
425 425
 					$extras_associative[$extra['field_name']] = $extra['field_value'];
426 426
 				}
427 427
 			}
428 428
 
429 429
 			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
430
+			if ($result instanceof WSError) {
431 431
 				$this->handleError($result);
432 432
 			}
433 433
 		}
@@ -443,18 +443,18 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function EditUsers($secret_key, $users) {
445 445
 		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
446
+		if ($verifKey instanceof WSError) {
447 447
 			$this->handleError($verifKey);
448 448
 		} else {
449 449
 			$results = array();
450
-			foreach($users as $user) {
450
+			foreach ($users as $user) {
451 451
 				$result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454 454
 				extract($user);
455 455
 				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456 456
 				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
457
+				if ($result_op instanceof WSError) {
458 458
 					// Return the error in the results
459 459
 					$result_tmp['result'] = $result_op->toArray();
460 460
 				} else {
Please login to merge, or discard this patch.
main/wiki/wiki.inc.php 3 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use Chamilo\CoreBundle\Component\Editor\Connector;
5 4
 use Chamilo\CoreBundle\Component\Filesystem\Data;
6 5
 use ChamiloSession as Session;
7
-use MediaAlchemyst\Alchemyst;
8
-use MediaAlchemyst\DriversContainer;
9
-use Neutron\TemporaryFilesystem\Manager;
10
-use Neutron\TemporaryFilesystem\TemporaryFilesystem;
11
-use Symfony\Component\Filesystem\Filesystem;
12 6
 
13 7
 /**
14 8
  * Class Wiki
Please login to merge, or discard this patch.
Braces   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1879 1879
                 if($session_id==0){
1880 1880
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1881
-                }else{
1881
+                } else{
1882 1882
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1883 1883
                 }
1884 1884
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -2261,8 +2261,7 @@  discard block
 block discarded – undo
2261 2261
                                         s1.reflink = s2.reflink AND
2262 2262
                                         ".$groupfilter.$condition_session.")";
2263 2263
                     // warning don't use group by reflink because don't return the last version
2264
-                }
2265
-                else {
2264
+                } else {
2266 2265
                     $sql = " SELECT * FROM ".$tbl_wiki." s1
2267 2266
                             WHERE
2268 2267
                                 s1.c_id = $course_id AND
@@ -3696,8 +3695,7 @@  discard block
 block discarded – undo
3696 3695
                 '.api_htmlentities($obj->title).'</a>';
3697 3696
                 if ($obj->user_id <>0) {
3698 3697
                     $row[] = UserManager::getUserProfileLink($userinfo);
3699
-                }
3700
-                else {
3698
+                } else {
3701 3699
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
3702 3700
                 }
3703 3701
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
@@ -3932,8 +3930,7 @@  discard block
 block discarded – undo
3932 3930
                         api_htmlentities($obj->title).'</a>';
3933 3931
                     if ($obj->user_id <>0) {
3934 3932
                         $row[] = UserManager::getUserProfileLink($userinfo);
3935
-                    }
3936
-                    else {
3933
+                    } else {
3937 3934
                         $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3938 3935
                     }
3939 3936
                     $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
Please login to merge, or discard this patch.
Spacing   +647 added lines, -647 removed lines patch added patch discarded remove patch
@@ -99,25 +99,25 @@  discard block
 block discarded – undo
99 99
      **/
100 100
     public function links_to($input)
101 101
     {
102
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
102
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
103 103
         $all_links = array();
104 104
 
105 105
         foreach ($input_array as $key=>$value) {
106
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' &&
107
-                isset($input_array[$key+1]) && $input_array[$key+1] == ']]'
106
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' &&
107
+                isset($input_array[$key + 1]) && $input_array[$key + 1] == ']]'
108 108
             ) {
109 109
                 if (api_strpos($value, "|") !== false) {
110
-                    $full_link_array=explode("|", $value);
111
-                    $link=trim($full_link_array[0]);
112
-                    $title=trim($full_link_array[1]);
110
+                    $full_link_array = explode("|", $value);
111
+                    $link = trim($full_link_array[0]);
112
+                    $title = trim($full_link_array[1]);
113 113
                 } else {
114
-                    $link=trim($value);
115
-                    $title=trim($value);
114
+                    $link = trim($value);
115
+                    $title = trim($value);
116 116
                 }
117
-                unset($input_array[$key-1]);
118
-                unset($input_array[$key+1]);
117
+                unset($input_array[$key - 1]);
118
+                unset($input_array[$key + 1]);
119 119
                 //replace blank spaces by _ within the links. But to remove links at the end add a blank space
120
-                $all_links[]= Database::escape_string(str_replace(' ','_',$link)).' ';
120
+                $all_links[] = Database::escape_string(str_replace(' ', '_', $link)).' ';
121 121
             }
122 122
         }
123 123
         $output = implode($all_links);
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      **/
132 132
     public function detect_external_link($input)
133 133
     {
134
-        $exlink='href=';
135
-        $exlinkStyle='class="wiki_link_ext" href=';
136
-        $output=str_replace($exlink, $exlinkStyle, $input);
134
+        $exlink = 'href=';
135
+        $exlinkStyle = 'class="wiki_link_ext" href=';
136
+        $output = str_replace($exlink, $exlinkStyle, $input);
137 137
         return $output;
138 138
     }
139 139
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function detect_anchor_link($input)
145 145
     {
146 146
         $anchorlink = 'href="#';
147
-        $anchorlinkStyle='class="wiki_anchor_link" href="#';
147
+        $anchorlinkStyle = 'class="wiki_anchor_link" href="#';
148 148
         $output = str_replace($anchorlink, $anchorlinkStyle, $input);
149 149
 
150 150
         return $output;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      **/
170 170
     public function detect_ftp_link($input)
171 171
     {
172
-        $ftplink='href="ftp';
172
+        $ftplink = 'href="ftp';
173 173
         $ftplinkStyle = 'class="wiki_ftp_link" href="ftp';
174 174
         $output = str_replace($ftplink, $ftplinkStyle, $input);
175 175
 
@@ -214,21 +214,21 @@  discard block
 block discarded – undo
214 214
     {
215 215
         $groupId = api_get_group_id();
216 216
         //now doubles brackets
217
-        $input_array = preg_split("/(\[\[|\]\])/",$input,-1, PREG_SPLIT_DELIM_CAPTURE);
217
+        $input_array = preg_split("/(\[\[|\]\])/", $input, -1, PREG_SPLIT_DELIM_CAPTURE);
218 218
 
219 219
         foreach ($input_array as $key => $value) {
220 220
             //now doubles brackets
221
-            if (isset($input_array[$key-1]) && $input_array[$key-1] == '[[' AND
222
-                $input_array[$key+1] == ']]'
221
+            if (isset($input_array[$key - 1]) && $input_array[$key - 1] == '[[' AND
222
+                $input_array[$key + 1] == ']]'
223 223
             ) {
224 224
                 // now full wikilink
225
-                if (api_strpos($value, "|") !== false){
226
-                    $full_link_array=explode("|", $value);
227
-                    $link=trim(strip_tags($full_link_array[0]));
228
-                    $title=trim($full_link_array[1]);
225
+                if (api_strpos($value, "|") !== false) {
226
+                    $full_link_array = explode("|", $value);
227
+                    $link = trim(strip_tags($full_link_array[0]));
228
+                    $title = trim($full_link_array[1]);
229 229
                 } else {
230
-                    $link=trim(strip_tags($value));
231
-                    $title=trim($value);
230
+                    $link = trim(strip_tags($value));
231
+                    $title = trim($value);
232 232
                 }
233 233
 
234 234
                 //if wikilink is homepage
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
                 }
241 241
 
242 242
                 // note: checkreflink checks if the link is still free. If it is not used then it returns true, if it is used, then it returns false. Now the title may be different
243
-                if (self::checktitle(strtolower(str_replace(' ','_',$link)))) {
243
+                if (self::checktitle(strtolower(str_replace(' ', '_', $link)))) {
244 244
                     $link = api_html_entity_decode($link);
245
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
245
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=addnew&amp;title='.Security::remove_XSS($link).'&group_id='.$groupId.'" class="new_wiki_link">'.$title.'</a>';
246 246
                 } else {
247
-                    $input_array[$key]='<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ','_',$link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
247
+                    $input_array[$key] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?'.api_get_cidreq().'&action=showpage&amp;title='.urlencode(strtolower(str_replace(' ', '_', $link))).'&group_id='.$groupId.'" class="wiki_link">'.$title.'</a>';
248 248
                 }
249
-                unset($input_array[$key-1]);
250
-                unset($input_array[$key+1]);
249
+                unset($input_array[$key - 1]);
250
+                unset($input_array[$key + 1]);
251 251
             }
252 252
         }
253
-        $output = implode('',$input_array);
253
+        $output = implode('', $input_array);
254 254
         return $output;
255 255
     }
256 256
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
         // are not made here, but through the interce buttons
293 293
 
294 294
         // cleaning the variables
295
-        if (api_get_setting('htmlpurifier_wiki') == 'true'){
295
+        if (api_get_setting('htmlpurifier_wiki') == 'true') {
296 296
             //$purifier = new HTMLPurifier();
297 297
             $values['content'] = Security::remove_XSS($values['content']);
298 298
         }
299
-        $version = intval($values['version']) + 1 ;
299
+        $version = intval($values['version']) + 1;
300 300
         $linkTo = self::links_to($values['content']); //and check links content
301 301
 
302 302
         //cleaning config variables
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $_clean['startdate_assig'] = '0000-00-00 00:00:00';
320 320
         }
321 321
 
322
-        if (isset($values['initenddate']) && $values['initenddate']==1) {
322
+        if (isset($values['initenddate']) && $values['initenddate'] == 1) {
323 323
             $_clean['enddate_assig'] = $values['enddate_assig'];
324 324
         } else {
325 325
             $_clean['enddate_assig'] = '0000-00-00 00:00:00';
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         }
331 331
 
332 332
         if (!empty($values['max_text']) || !empty($values['max_version'])) {
333
-            $_clean['max_text']	= $values['max_text'];
333
+            $_clean['max_text'] = $values['max_text'];
334 334
             $_clean['max_version'] = $values['max_version'];
335 335
         }
336 336
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                 $groupId
382 382
             );
383 383
 
384
-            if ($values['page_id']== 0) {
384
+            if ($values['page_id'] == 0) {
385 385
                 $sql = 'UPDATE '.$tbl_wiki.' SET page_id="'.$id.'"
386 386
                         WHERE c_id = '.$course_id.' AND iid ="'.$id.'"';
387 387
                 Database::query($sql);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $_course = $this->courseInfo;
466 466
         $r_user_id = api_get_user_id();
467 467
         $r_dtime = api_get_utc_datetime();
468
-        $r_version = $r_version+1;
468
+        $r_version = $r_version + 1;
469 469
         $r_comment = get_lang('RestoredFromVersion').': '.$c_version;
470 470
         $session_id = api_get_session_id();
471 471
         $course_id = api_get_course_int_id();
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
         // Unlike ordinary pages of pages of assignments.
571 571
         // Allow create a ordinary page although there is a assignment with the same name
572 572
         if ($_clean['assignment'] == 2 || $_clean['assignment'] == 1) {
573
-            $page = str_replace(' ','_',$values['title']."_uass".$assig_user_id);
573
+            $page = str_replace(' ', '_', $values['title']."_uass".$assig_user_id);
574 574
         } else {
575
-            $page = str_replace(' ','_',$values['title']);
575
+            $page = str_replace(' ', '_', $values['title']);
576 576
         }
577 577
         $_clean['reflink'] = $page;
578 578
         $_clean['title']   = trim($values['title']);
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 
609 609
         $groupId = api_get_group_id();
610 610
 
611
-        $_clean['linksto'] = self::links_to($_clean['content']);	//check wikilinks
611
+        $_clean['linksto'] = self::links_to($_clean['content']); //check wikilinks
612 612
 
613 613
         // cleaning config variables
614 614
         $_clean['task'] = isset($values['task']) ? $values['task'] : '';
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      */
725 725
     public function setForm($form, $row = array())
726 726
     {
727
-        $toolBar = api_is_allowed_to_edit(null,true)
727
+        $toolBar = api_is_allowed_to_edit(null, true)
728 728
             ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
729 729
             : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student');
730 730
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 
736 736
         $form->addElement('select', 'progress', get_lang('Progress'), $progress);
737 737
 
738
-        if ((api_is_allowed_to_edit(false,true) ||
738
+        if ((api_is_allowed_to_edit(false, true) ||
739 739
             api_is_platform_admin()) &&
740 740
             isset($row['reflink']) && $row['reflink'] != 'index'
741 741
         ) {
@@ -875,13 +875,13 @@  discard block
 block discarded – undo
875 875
         if ($newtitle) {
876 876
             $pageMIX = $newtitle; //display the page after it is created
877 877
         } else {
878
-            $pageMIX = $page;//display current page
878
+            $pageMIX = $page; //display current page
879 879
         }
880 880
 
881 881
         $filter = null;
882 882
         if (isset($_GET['view']) && $_GET['view']) {
883 883
             $_clean['view'] = Database::escape_string($_GET['view']);
884
-            $filter =' AND w.id="'.$_clean['view'].'"';
884
+            $filter = ' AND w.id="'.$_clean['view'].'"';
885 885
         }
886 886
 
887 887
         // First, check page visibility in the first page version
@@ -923,14 +923,14 @@  discard block
 block discarded – undo
923 923
         }
924 924
 
925 925
         // if both are empty and we are displaying the index page then we display the default text.
926
-        if ($row['content']=='' && $row['title']=='' && $page=='index') {
926
+        if ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
927 927
             if (api_is_allowed_to_edit(false, true) ||
928 928
                 api_is_platform_admin() ||
929 929
                 GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
930 930
             ) {
931 931
                 //Table structure for better export to pdf
932
-                $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
933
-                $default_table_for_content_End='</td></tr></table>';
932
+                $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
933
+                $default_table_for_content_End = '</td></tr></table>';
934 934
                 $content = $default_table_for_content_Start.
935 935
                     sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).
936 936
                     $default_table_for_content_End;
@@ -945,23 +945,23 @@  discard block
 block discarded – undo
945 945
 
946 946
         //assignment mode: identify page type
947 947
         $icon_assignment = null;
948
-        if ($row['assignment']==1) {
949
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
950
-        } elseif($row['assignment']==2) {
951
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
948
+        if ($row['assignment'] == 1) {
949
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
950
+        } elseif ($row['assignment'] == 2) {
951
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
952 952
         }
953 953
 
954 954
         //task mode
955 955
         $icon_task = null;
956 956
         if (!empty($row['task'])) {
957
-            $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
957
+            $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
958 958
         }
959 959
 
960 960
         // Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view
961 961
         if ($KeyVisibility == "1" ||
962 962
             api_is_allowed_to_edit(false, true) ||
963 963
             api_is_platform_admin() ||
964
-            ($row['assignment'] == 2 && $KeyVisibility=="0" && (api_get_user_id() == $row['user_id']))
964
+            ($row['assignment'] == 2 && $KeyVisibility == "0" && (api_get_user_id() == $row['user_id']))
965 965
         ) {
966 966
             $actionsLeft = '';
967 967
 
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
             $protect_page = null;
987 987
             $lock_unlock_protect = null;
988 988
             // page action: protecting (locking) the page
989
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
990
-                if (self::check_protect_page()==1) {
989
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
990
+                if (self::check_protect_page() == 1) {
991 991
                     $protect_page = Display::return_icon('lock.png', get_lang('PageLockedExtra'), '', ICON_SIZE_MEDIUM);
992
-                    $lock_unlock_protect='unlock';
992
+                    $lock_unlock_protect = 'unlock';
993 993
                 } else {
994 994
                     $protect_page = Display::return_icon('unlock.png', get_lang('PageUnlockedExtra'), '', ICON_SIZE_MEDIUM);
995
-                    $lock_unlock_protect='lock';
995
+                    $lock_unlock_protect = 'lock';
996 996
                 }
997 997
             }
998 998
 
@@ -1004,13 +1004,13 @@  discard block
 block discarded – undo
1004 1004
             $visibility_page = null;
1005 1005
             $lock_unlock_visibility = null;
1006 1006
             //page action: visibility
1007
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1007
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1008 1008
                 if (self::check_visibility_page() == 1) {
1009
-                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'),'', ICON_SIZE_MEDIUM);
1009
+                    $visibility_page = Display::return_icon('visible.png', get_lang('ShowPageExtra'), '', ICON_SIZE_MEDIUM);
1010 1010
                     $lock_unlock_visibility = 'invisible';
1011 1011
 
1012 1012
                 } else {
1013
-                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'),'', ICON_SIZE_MEDIUM);
1013
+                    $visibility_page = Display::return_icon('invisible.png', get_lang('HidePageExtra'), '', ICON_SIZE_MEDIUM);
1014 1014
                     $lock_unlock_visibility = 'visible';
1015 1015
                 }
1016 1016
             }
@@ -1022,11 +1022,11 @@  discard block
 block discarded – undo
1022 1022
 
1023 1023
             //page action: notification
1024 1024
             if (api_is_allowed_to_session_edit()) {
1025
-                if (self::check_notify_page($page)==1) {
1026
-                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_MEDIUM);
1025
+                if (self::check_notify_page($page) == 1) {
1026
+                    $notify_page = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_MEDIUM);
1027 1027
                     $lock_unlock_notify_page = 'unlocknotify';
1028 1028
                 } else {
1029
-                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_MEDIUM);
1029
+                    $notify_page = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_MEDIUM);
1030 1030
                     $lock_unlock_notify_page = 'locknotify';
1031 1031
                 }
1032 1032
             }
@@ -1038,33 +1038,33 @@  discard block
 block discarded – undo
1038 1038
                 ) {
1039 1039
                     // menu discuss page
1040 1040
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=discuss&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('discuss').'>'.
1041
-                        Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1041
+                        Display::return_icon('discuss.png', get_lang('DiscussThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1042 1042
                 }
1043 1043
 
1044 1044
                 //menu history
1045 1045
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=history&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('history').'>'.
1046
-                    Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>';
1046
+                    Display::return_icon('history.png', get_lang('ShowPageHistory'), '', ICON_SIZE_MEDIUM).'</a>';
1047 1047
                 //menu linkspages
1048 1048
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'action=links&title='.api_htmlentities(urlencode($page)).'" '.self::is_active_navigation_tab('links').'>'.
1049
-                    Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>';
1049
+                    Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_MEDIUM).'</a>';
1050 1050
 
1051 1051
                 //menu delete wikipage
1052
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1052
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1053 1053
                     $actionsRight .= '<a href="index.php?action=delete&'.api_get_cidreq().'&title='.api_htmlentities(urlencode($page)).'"'.self::is_active_navigation_tab('delete').'>'.
1054
-                        Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
1054
+                        Display::return_icon('delete.png', get_lang('DeleteThisPage'), '', ICON_SIZE_MEDIUM).'</a>';
1055 1055
                 }
1056 1056
 
1057 1057
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=showpage&actionpage='.$lock_unlock_notify_page.'&title='.api_htmlentities(urlencode($page)).'">'.
1058 1058
                     $notify_page.'</a>';
1059 1059
 
1060 1060
                 // Page action: copy last version to doc area
1061
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1061
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1062 1062
                     $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export2doc&wiki_id='.$row['id'].'">'.
1063 1063
                         Display::return_icon('export_to_documents.png', get_lang('ExportToDocArea'), '', ICON_SIZE_MEDIUM).'</a>';
1064 1064
                 }
1065 1065
 
1066 1066
                 $actionsRight .= '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf&wiki_id='.$row['id'].'">'.
1067
-                    Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
1067
+                    Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
1068 1068
 
1069 1069
                 $unoconv = api_get_configuration_value('unoconv.binaries');
1070 1070
                 if ($unoconv) {
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                     )
1121 1121
                 );
1122 1122
 
1123
-            $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress']*10).'%&nbsp;&nbsp;&nbsp;'.get_lang('Rating').': '.$row['score'].'&nbsp;&nbsp;&nbsp;'.get_lang('Words').': '.self::word_count($content).'</div>';
1123
+            $footerWiki = '<div id="wikifooter">'.get_lang('Progress').': '.($row['progress'] * 10).'%&nbsp;&nbsp;&nbsp;'.get_lang('Rating').': '.$row['score'].'&nbsp;&nbsp;&nbsp;'.get_lang('Words').': '.self::word_count($content).'</div>';
1124 1124
 
1125 1125
             echo Display::panel($pageWiki, $pageTitle, $footerWiki);
1126 1126
         } //end filter visibility
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 
1145 1145
         # strip all html tags
1146 1146
         $wc = strip_tags($document);
1147
-        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8');// TODO:test also old html_entity_decode(utf8_encode($wc))
1147
+        $wc = html_entity_decode($wc, ENT_NOQUOTES, 'UTF-8'); // TODO:test also old html_entity_decode(utf8_encode($wc))
1148 1148
 
1149 1149
         # remove 'words' that don't consist of alphanumerical characters or punctuation. And fix accents and some letters
1150 1150
         $pattern = "#[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-|:|\&|@|á|é|í|ó|ú|à|è|ì|ò|ù|ä|ë|ï|ö|ü|Á|É|Í|Ó|Ú|À|È|Ò|Ù|Ä|Ë|Ï|Ö|Ü|â|ê|î|ô|û|Â|Ê|Î|Ô|Û|ñ|Ñ|ç|Ç)]+#";
@@ -1177,15 +1177,15 @@  discard block
 block discarded – undo
1177 1177
 
1178 1178
         $course_id = api_get_course_int_id();
1179 1179
 
1180
-        $sql='SELECT id FROM '.$tbl_wiki.'
1180
+        $sql = 'SELECT id FROM '.$tbl_wiki.'
1181 1181
               WHERE
1182 1182
                 c_id = '.$course_id.' AND
1183 1183
                 title="'.Database::escape_string($title).'" AND
1184 1184
                 '.$groupfilter.$condition_session.'
1185 1185
               ORDER BY id ASC';
1186
-        $result=Database::query($sql);
1187
-        $cant=Database::num_rows($result);
1188
-        if ($cant>0) {
1186
+        $result = Database::query($sql);
1187
+        $cant = Database::num_rows($result);
1188
+        if ($cant > 0) {
1189 1189
             return true;
1190 1190
         } else {
1191 1191
             return false;
@@ -1267,20 +1267,20 @@  discard block
 block discarded – undo
1267 1267
         $page = $this->page;
1268 1268
 
1269 1269
         $course_id = api_get_course_int_id();
1270
-        $sql='SELECT * FROM '.$tbl_wiki.'
1270
+        $sql = 'SELECT * FROM '.$tbl_wiki.'
1271 1271
               WHERE
1272 1272
                 c_id = '.$course_id.' AND
1273 1273
                 reflink="'.Database::escape_string($page).'" AND
1274 1274
                 '.$groupfilter.$condition_session.'
1275 1275
               ORDER BY id ASC';
1276 1276
 
1277
-        $result=Database::query($sql);
1278
-        $row=Database::fetch_array($result);
1277
+        $result = Database::query($sql);
1278
+        $row = Database::fetch_array($result);
1279 1279
         $status_editlock = $row['editlock'];
1280 1280
         $id = $row['id'];
1281 1281
 
1282 1282
         ///change status
1283
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1283
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1284 1284
             if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lock' && $status_editlock == 0) {
1285 1285
                 $status_editlock = 1;
1286 1286
             }
@@ -1292,13 +1292,13 @@  discard block
 block discarded – undo
1292 1292
                     WHERE c_id = '.$course_id.' AND id="'.$id.'"';
1293 1293
             Database::query($sql);
1294 1294
 
1295
-            $sql='SELECT * FROM '.$tbl_wiki.'
1295
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1296 1296
                   WHERE
1297 1297
                     c_id = '.$course_id.' AND
1298 1298
                     reflink="'.Database::escape_string($page).'" AND
1299 1299
                     '.$groupfilter.$condition_session.'
1300 1300
                   ORDER BY id ASC';
1301
-            $result=Database::query($sql);
1301
+            $result = Database::query($sql);
1302 1302
             $row = Database::fetch_array($result);
1303 1303
         }
1304 1304
 
@@ -1329,13 +1329,13 @@  discard block
 block discarded – undo
1329 1329
         $row = Database::fetch_array($result);
1330 1330
         $status_visibility = $row['visibility'];
1331 1331
         //change status
1332
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1333
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='visible' && $status_visibility==0) {
1334
-                $status_visibility=1;
1332
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1333
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'visible' && $status_visibility == 0) {
1334
+                $status_visibility = 1;
1335 1335
 
1336 1336
             }
1337
-            if (isset($_GET['actionpage']) && $_GET['actionpage']=='invisible' && $status_visibility==1) {
1338
-                $status_visibility=0;
1337
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'invisible' && $status_visibility == 1) {
1338
+                $status_visibility = 0;
1339 1339
             }
1340 1340
 
1341 1341
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility="'.Database::escape_string($status_visibility).'"
@@ -1352,12 +1352,12 @@  discard block
 block discarded – undo
1352 1352
                         reflink="'.Database::escape_string($page).'" AND
1353 1353
                         '.$groupfilter.$condition_session.'
1354 1354
                     ORDER BY id ASC';
1355
-            $result=Database::query($sql);
1355
+            $result = Database::query($sql);
1356 1356
             $row = Database::fetch_array($result);
1357 1357
         }
1358 1358
 
1359 1359
         if (empty($row['id'])) {
1360
-            $row['visibility']= 1;
1360
+            $row['visibility'] = 1;
1361 1361
         }
1362 1362
 
1363 1363
         //show status
@@ -1384,18 +1384,18 @@  discard block
 block discarded – undo
1384 1384
                     reflink="'.Database::escape_string($page).'" AND
1385 1385
                     '.$groupfilter.$condition_session.'
1386 1386
                 ORDER BY id ASC';
1387
-        $result=Database::query($sql);
1388
-        $row=Database::fetch_array($result);
1387
+        $result = Database::query($sql);
1388
+        $row = Database::fetch_array($result);
1389 1389
 
1390 1390
         $status_visibility_disc = $row['visibility_disc'];
1391 1391
 
1392 1392
         //change status
1393
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1394
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='showdisc' && $status_visibility_disc==0) {
1395
-                $status_visibility_disc=1;
1393
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1394
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'showdisc' && $status_visibility_disc == 0) {
1395
+                $status_visibility_disc = 1;
1396 1396
             }
1397
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='hidedisc' && $status_visibility_disc==1) {
1398
-                $status_visibility_disc=0;
1397
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'hidedisc' && $status_visibility_disc == 1) {
1398
+                $status_visibility_disc = 0;
1399 1399
             }
1400 1400
 
1401 1401
             $sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'"
@@ -1443,14 +1443,14 @@  discard block
 block discarded – undo
1443 1443
         $result = Database::query($sql);
1444 1444
         $row = Database::fetch_array($result);
1445 1445
 
1446
-        $status_addlock_disc=$row['addlock_disc'];
1446
+        $status_addlock_disc = $row['addlock_disc'];
1447 1447
 
1448 1448
         //change status
1449 1449
         if (api_is_allowed_to_edit() || api_is_platform_admin()) {
1450
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockdisc' && $status_addlock_disc==0) {
1450
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockdisc' && $status_addlock_disc == 0) {
1451 1451
                 $status_addlock_disc = 1;
1452 1452
             }
1453
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockdisc' && $status_addlock_disc==1) {
1453
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockdisc' && $status_addlock_disc == 1) {
1454 1454
                 $status_addlock_disc = 0;
1455 1455
             }
1456 1456
 
@@ -1472,8 +1472,8 @@  discard block
 block discarded – undo
1472 1472
                         reflink="'.Database::escape_string($page).'" AND
1473 1473
                         '.$groupfilter.$condition_session.'
1474 1474
                     ORDER BY id ASC';
1475
-            $result=Database::query($sql);
1476
-            $row=Database::fetch_array($result);
1475
+            $result = Database::query($sql);
1476
+            $row = Database::fetch_array($result);
1477 1477
         }
1478 1478
 
1479 1479
         return $row['addlock_disc'];
@@ -1498,17 +1498,17 @@  discard block
 block discarded – undo
1498 1498
                     reflink="'.Database::escape_string($page).'" AND
1499 1499
                     '.$groupfilter.$condition_session.'
1500 1500
                 ORDER BY id ASC';
1501
-        $result=Database::query($sql);
1502
-        $row=Database::fetch_array($result);
1503
-        $status_ratinglock_disc=$row['ratinglock_disc'];
1501
+        $result = Database::query($sql);
1502
+        $row = Database::fetch_array($result);
1503
+        $status_ratinglock_disc = $row['ratinglock_disc'];
1504 1504
 
1505 1505
         //change status
1506
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
1507
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockrating' && $status_ratinglock_disc==0) {
1508
-                $status_ratinglock_disc=1;
1506
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
1507
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'lockrating' && $status_ratinglock_disc == 0) {
1508
+                $status_ratinglock_disc = 1;
1509 1509
             }
1510
-            if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlockrating' && $status_ratinglock_disc==1) {
1511
-                $status_ratinglock_disc=0;
1510
+            if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlockrating' && $status_ratinglock_disc == 1) {
1511
+                $status_ratinglock_disc = 0;
1512 1512
             }
1513 1513
 
1514 1514
             $sql = 'UPDATE '.$tbl_wiki.'
@@ -1524,14 +1524,14 @@  discard block
 block discarded – undo
1524 1524
             // these three lines remain necessary. They do that by changing the
1525 1525
             // page state is made when you press the button and not have to wait
1526 1526
             // to change his page
1527
-            $sql='SELECT * FROM '.$tbl_wiki.'
1527
+            $sql = 'SELECT * FROM '.$tbl_wiki.'
1528 1528
                   WHERE
1529 1529
                     c_id = '.$course_id.' AND
1530 1530
                     reflink="'.Database::escape_string($page).'" AND
1531 1531
                     '.$groupfilter.$condition_session.'
1532 1532
                   ORDER BY id ASC';
1533
-            $result=Database::query($sql);
1534
-            $row=Database::fetch_array($result);
1533
+            $result = Database::query($sql);
1534
+            $row = Database::fetch_array($result);
1535 1535
         }
1536 1536
 
1537 1537
         return $row['ratinglock_disc'];
@@ -1556,24 +1556,24 @@  discard block
 block discarded – undo
1556 1556
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1557 1557
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1558 1558
                 ORDER BY id ASC';
1559
-        $result=Database::query($sql);
1560
-        $row=Database::fetch_array($result);
1559
+        $result = Database::query($sql);
1560
+        $row = Database::fetch_array($result);
1561 1561
         $id = $row['id'];
1562
-        $sql='SELECT * FROM '.$tbl_wiki_mailcue.'
1562
+        $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1563 1563
               WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P"';
1564
-        $result=Database::query($sql);
1565
-        $row=Database::fetch_array($result);
1564
+        $result = Database::query($sql);
1565
+        $row = Database::fetch_array($result);
1566 1566
 
1567 1567
         $idm = $row['id'];
1568 1568
 
1569 1569
         if (empty($idm)) {
1570
-            $status_notify=0;
1570
+            $status_notify = 0;
1571 1571
         } else {
1572
-            $status_notify=1;
1572
+            $status_notify = 1;
1573 1573
         }
1574 1574
 
1575 1575
         // Change status
1576
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) {
1576
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotify' && $status_notify == 0) {
1577 1577
             $sql = "SELECT id FROM $tbl_wiki_mailcue
1578 1578
                     WHERE c_id = $course_id AND id = $id AND user_id = $userId";
1579 1579
             $result = Database::query($sql);
@@ -1582,18 +1582,18 @@  discard block
 block discarded – undo
1582 1582
                 $exist = true;
1583 1583
             }
1584 1584
             if ($exist == false) {
1585
-                $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1585
+                $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1586 1586
                 ($course_id, '".$id."','".api_get_user_id()."','P','".$groupId."','".$session_id."')";
1587 1587
                 Database::query($sql);
1588 1588
             }
1589
-            $status_notify=1;
1589
+            $status_notify = 1;
1590 1590
         }
1591 1591
 
1592
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotify' && $status_notify==1) {
1592
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotify' && $status_notify == 1) {
1593 1593
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1594 1594
                     WHERE id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="P" AND c_id = '.$course_id;
1595 1595
             Database::query($sql);
1596
-            $status_notify=0;
1596
+            $status_notify = 0;
1597 1597
         }
1598 1598
 
1599 1599
         return $status_notify;
@@ -1619,9 +1619,9 @@  discard block
 block discarded – undo
1619 1619
         $sql = 'SELECT * FROM '.$tbl_wiki.'
1620 1620
                 WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
1621 1621
                 ORDER BY id ASC';
1622
-        $result=Database::query($sql);
1623
-        $row=Database::fetch_array($result);
1624
-        $id=$row['id'];
1622
+        $result = Database::query($sql);
1623
+        $row = Database::fetch_array($result);
1624
+        $id = $row['id'];
1625 1625
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1626 1626
                 WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
1627 1627
         $result = Database::query($sql);
@@ -1629,23 +1629,23 @@  discard block
 block discarded – undo
1629 1629
         $idm = $row['id'];
1630 1630
 
1631 1631
         if (empty($idm)) {
1632
-            $status_notify_disc=0;
1632
+            $status_notify_disc = 0;
1633 1633
         } else {
1634
-            $status_notify_disc=1;
1634
+            $status_notify_disc = 1;
1635 1635
         }
1636 1636
 
1637 1637
         //change status
1638
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifydisc' && $status_notify_disc==0) {
1639
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1638
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifydisc' && $status_notify_disc == 0) {
1639
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, id, user_id, type, group_id, session_id) VALUES
1640 1640
             ($course_id, '".$id."','".api_get_user_id()."','D','".$groupId."','".$session_id."')";
1641 1641
             Database::query($sql);
1642
-            $status_notify_disc=1;
1642
+            $status_notify_disc = 1;
1643 1643
         }
1644
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifydisc' && $status_notify_disc==1) {
1644
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'unlocknotifydisc' && $status_notify_disc == 1) {
1645 1645
             $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1646 1646
                     WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D" AND c_id = '.$course_id;
1647 1647
             Database::query($sql);
1648
-            $status_notify_disc=0;
1648
+            $status_notify_disc = 0;
1649 1649
         }
1650 1650
 
1651 1651
         return $status_notify_disc;
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1661 1661
         $course_id = api_get_course_int_id();
1662 1662
         $groupId = api_get_group_id();
1663
-        $session_id=api_get_session_id();
1663
+        $session_id = api_get_session_id();
1664 1664
 
1665 1665
         $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1666 1666
                 WHERE
@@ -1669,31 +1669,31 @@  discard block
 block discarded – undo
1669 1669
                     type="F" AND
1670 1670
                     group_id="'.$groupId.'" AND
1671 1671
                     session_id="'.$session_id.'"';
1672
-        $result=Database::query($sql);
1673
-        $row=Database::fetch_array($result);
1672
+        $result = Database::query($sql);
1673
+        $row = Database::fetch_array($result);
1674 1674
 
1675
-        $idm=$row['user_id'];
1675
+        $idm = $row['user_id'];
1676 1676
 
1677 1677
         if (empty($idm)) {
1678
-            $status_notify_all=0;
1678
+            $status_notify_all = 0;
1679 1679
         } else {
1680
-            $status_notify_all=1;
1680
+            $status_notify_all = 1;
1681 1681
         }
1682 1682
 
1683 1683
         //change status
1684
-        if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotifyall' && $status_notify_all==0) {
1685
-            $sql="INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1684
+        if (isset($_GET['actionpage']) && $_GET['actionpage'] == 'locknotifyall' && $status_notify_all == 0) {
1685
+            $sql = "INSERT INTO ".$tbl_wiki_mailcue." (c_id, user_id, type, group_id, session_id) VALUES
1686 1686
             ($course_id, '".api_get_user_id()."','F','".$groupId."','".$session_id."')";
1687 1687
             Database::query($sql);
1688
-            $status_notify_all=1;
1688
+            $status_notify_all = 1;
1689 1689
         }
1690 1690
 
1691 1691
         if (isset($_GET['actionpage']) &&
1692 1692
             isset($_GET['actionpage']) &&
1693
-            $_GET['actionpage']  =='unlocknotifyall' &&
1693
+            $_GET['actionpage'] == 'unlocknotifyall' &&
1694 1694
             $status_notify_all == 1
1695 1695
         ) {
1696
-            $sql ='DELETE FROM '.$tbl_wiki_mailcue.'
1696
+            $sql = 'DELETE FROM '.$tbl_wiki_mailcue.'
1697 1697
                    WHERE
1698 1698
                     c_id = '.$course_id.' AND
1699 1699
                     user_id="'.api_get_user_id().'" AND
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
                     session_id="'.$session_id.'" AND
1703 1703
                     c_id = '.$course_id;
1704 1704
             Database::query($sql);
1705
-            $status_notify_all=0;
1705
+            $status_notify_all = 0;
1706 1706
         }
1707 1707
 
1708 1708
         //show status
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
     /**
1713 1713
      * Sends pending e-mails
1714 1714
      */
1715
-    public function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='')
1715
+    public function check_emailcue($id_or_ref, $type, $lastime = '', $lastuser = '')
1716 1716
     {
1717 1717
         $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
1718 1718
         $tbl_wiki = $this->tbl_wiki;
@@ -1720,14 +1720,14 @@  discard block
 block discarded – undo
1720 1720
         $groupfilter = $this->groupfilter;
1721 1721
         $_course = $this->courseInfo;
1722 1722
         $groupId = api_get_group_id();
1723
-        $session_id=api_get_session_id();
1723
+        $session_id = api_get_session_id();
1724 1724
         $course_id = api_get_course_int_id();
1725 1725
 
1726
-        $group_properties  = GroupManager :: get_group_properties($groupId);
1726
+        $group_properties = GroupManager :: get_group_properties($groupId);
1727 1727
         $group_name = $group_properties['name'];
1728 1728
         $allow_send_mail = false; //define the variable to below
1729 1729
         $email_assignment = null;
1730
-        if ($type=='P') {
1730
+        if ($type == 'P') {
1731 1731
             //if modifying a wiki page
1732 1732
             //first, current author and time
1733 1733
             //Who is the author?
@@ -1738,22 +1738,22 @@  discard block
 block discarded – undo
1738 1738
             $year = substr($lastime, 0, 4);
1739 1739
             $month = substr($lastime, 5, 2);
1740 1740
             $day = substr($lastime, 8, 2);
1741
-            $hours=substr($lastime, 11,2);
1742
-            $minutes=substr($lastime, 14,2);
1743
-            $seconds=substr($lastime, 17,2);
1744
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1741
+            $hours = substr($lastime, 11, 2);
1742
+            $minutes = substr($lastime, 14, 2);
1743
+            $seconds = substr($lastime, 17, 2);
1744
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1745 1745
 
1746 1746
             //second, extract data from first reg
1747 1747
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1748 1748
                     WHERE  c_id = '.$course_id.' AND reflink="'.$id_or_ref.'" AND '.$groupfilter.$condition_session.'
1749 1749
                     ORDER BY id ASC';
1750
-            $result=Database::query($sql);
1751
-            $row=Database::fetch_array($result);
1750
+            $result = Database::query($sql);
1751
+            $row = Database::fetch_array($result);
1752 1752
 
1753
-            $id=$row['id'];
1754
-            $email_page_name=$row['title'];
1755
-            if ($row['visibility']==1) {
1756
-                $allow_send_mail=true; //if visibility off - notify off
1753
+            $id = $row['id'];
1754
+            $email_page_name = $row['title'];
1755
+            if ($row['visibility'] == 1) {
1756
+                $allow_send_mail = true; //if visibility off - notify off
1757 1757
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1758 1758
                         WHERE
1759 1759
                             c_id = '.$course_id.' AND
@@ -1763,10 +1763,10 @@  discard block
 block discarded – undo
1763 1763
                             group_id="'.$groupId.'" AND
1764 1764
                             session_id="'.$session_id.'"';
1765 1765
                 //type: P=page, D=discuss, F=full.
1766
-                $result=Database::query($sql);
1767
-                $emailtext=get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1766
+                $result = Database::query($sql);
1767
+                $emailtext = get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1768 1768
             }
1769
-        } elseif ($type=='D') {
1769
+        } elseif ($type == 'D') {
1770 1770
             //if added a post to discuss
1771 1771
 
1772 1772
             //first, current author and time
@@ -1778,25 +1778,25 @@  discard block
 block discarded – undo
1778 1778
             $year = substr($lastime, 0, 4);
1779 1779
             $month = substr($lastime, 5, 2);
1780 1780
             $day = substr($lastime, 8, 2);
1781
-            $hours=substr($lastime, 11,2);
1782
-            $minutes=substr($lastime, 14,2);
1783
-            $seconds=substr($lastime, 17,2);
1784
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1781
+            $hours = substr($lastime, 11, 2);
1782
+            $minutes = substr($lastime, 14, 2);
1783
+            $seconds = substr($lastime, 17, 2);
1784
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1785 1785
 
1786 1786
             //second, extract data from first reg
1787 1787
 
1788
-            $id=$id_or_ref; //$id_or_ref is id from tblwiki
1788
+            $id = $id_or_ref; //$id_or_ref is id from tblwiki
1789 1789
 
1790 1790
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1791 1791
                     WHERE c_id = '.$course_id.' AND id="'.$id.'"
1792 1792
                     ORDER BY id ASC';
1793 1793
 
1794
-            $result=Database::query($sql);
1795
-            $row=Database::fetch_array($result);
1794
+            $result = Database::query($sql);
1795
+            $row = Database::fetch_array($result);
1796 1796
 
1797
-            $email_page_name=$row['title'];
1798
-            if ($row['visibility_disc']==1) {
1799
-                $allow_send_mail=true; //if visibility off - notify off
1797
+            $email_page_name = $row['title'];
1798
+            if ($row['visibility_disc'] == 1) {
1799
+                $allow_send_mail = true; //if visibility off - notify off
1800 1800
                 $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1801 1801
                         WHERE
1802 1802
                             c_id = '.$course_id.' AND
@@ -1807,22 +1807,22 @@  discard block
 block discarded – undo
1807 1807
                             session_id="'.$session_id.'"';
1808 1808
                 //type: P=page, D=discuss, F=full
1809 1809
                 $result = Database::query($sql);
1810
-                $emailtext=get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1810
+                $emailtext = get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
1811 1811
             }
1812
-        } elseif($type=='A') {
1812
+        } elseif ($type == 'A') {
1813 1813
             //for added pages
1814
-            $id=0; //for tbl_wiki_mailcue
1814
+            $id = 0; //for tbl_wiki_mailcue
1815 1815
             $sql = 'SELECT * FROM '.$tbl_wiki.'
1816 1816
                     WHERE c_id = '.$course_id.'
1817 1817
                     ORDER BY id DESC'; //the added is always the last
1818 1818
 
1819
-            $result=Database::query($sql);
1820
-            $row=Database::fetch_array($result);
1821
-            $email_page_name=$row['title'];
1819
+            $result = Database::query($sql);
1820
+            $row = Database::fetch_array($result);
1821
+            $email_page_name = $row['title'];
1822 1822
 
1823 1823
             //Who is the author?
1824 1824
             $userinfo = api_get_user_info($row['user_id']);
1825
-            $email_user_author= get_lang('AddedBy').': '.$userinfo['complete_name'];
1825
+            $email_user_author = get_lang('AddedBy').': '.$userinfo['complete_name'];
1826 1826
 
1827 1827
             //When ?
1828 1828
             $year = substr($row['dtime'], 0, 4);
@@ -1831,33 +1831,33 @@  discard block
 block discarded – undo
1831 1831
             $hours = substr($row['dtime'], 11, 2);
1832 1832
             $minutes = substr($row['dtime'], 14, 2);
1833 1833
             $seconds = substr($row['dtime'], 17, 2);
1834
-            $email_date_changes=$day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1835
-
1836
-            if($row['assignment']==0) {
1837
-                $allow_send_mail=true;
1838
-            } elseif($row['assignment']==1) {
1839
-                $email_assignment=get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1840
-                $allow_send_mail=true;
1841
-            } elseif($row['assignment']==2) {
1842
-                $allow_send_mail=false; //Mode tasks: avoids notifications to all users about all users
1834
+            $email_date_changes = $day.' '.$month.' '.$year.' '.$hours.":".$minutes.":".$seconds;
1835
+
1836
+            if ($row['assignment'] == 0) {
1837
+                $allow_send_mail = true;
1838
+            } elseif ($row['assignment'] == 1) {
1839
+                $email_assignment = get_lang('AssignmentDescExtra').' ('.get_lang('AssignmentMode').')';
1840
+                $allow_send_mail = true;
1841
+            } elseif ($row['assignment'] == 2) {
1842
+                $allow_send_mail = false; //Mode tasks: avoids notifications to all users about all users
1843 1843
             }
1844 1844
 
1845 1845
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1846 1846
                     WHERE c_id = '.$course_id.' AND  id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
1847 1847
             //type: P=page, D=discuss, F=full
1848
-            $result=Database::query($sql);
1848
+            $result = Database::query($sql);
1849 1849
 
1850
-            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki');
1851
-        } elseif ($type=='E') {
1852
-            $id=0;
1853
-            $allow_send_mail=true;
1850
+            $emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '.get_lang('Wiki');
1851
+        } elseif ($type == 'E') {
1852
+            $id = 0;
1853
+            $allow_send_mail = true;
1854 1854
 
1855 1855
             //Who is the author?
1856
-            $userinfo = api_get_user_info(api_get_user_id());	//current user
1856
+            $userinfo = api_get_user_info(api_get_user_id()); //current user
1857 1857
             $email_user_author = get_lang('DeletedBy').': '.$userinfo['complete_name'];
1858 1858
             //When ?
1859
-            $today = date('r');		//current time
1860
-            $email_date_changes=$today;
1859
+            $today = date('r'); //current time
1860
+            $email_date_changes = $today;
1861 1861
 
1862 1862
             $sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
1863 1863
                     WHERE
@@ -1871,16 +1871,16 @@  discard block
 block discarded – undo
1871 1871
         ///make and send email
1872 1872
         if ($allow_send_mail) {
1873 1873
             while ($row = Database::fetch_array($result)) {
1874
-                $userinfo = api_get_user_info($row['user_id']);	//$row['user_id'] obtained from tbl_wiki_mailcue
1874
+                $userinfo = api_get_user_info($row['user_id']); //$row['user_id'] obtained from tbl_wiki_mailcue
1875 1875
                 $name_to = $userinfo['complete_name'];
1876 1876
                 $email_to = $userinfo['email'];
1877 1877
                 $sender_name = api_get_setting('emailAdministrator');
1878 1878
                 $sender_email = api_get_setting('emailAdministrator');
1879 1879
                 $email_subject = get_lang('EmailWikiChanges').' - '.$_course['official_code'];
1880 1880
                 $email_body = get_lang('DearUser').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).',<br /><br />';
1881
-                if($session_id==0){
1881
+                if ($session_id == 0) {
1882 1882
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' - '.$group_name.'</strong><br /><br /><br />';
1883
-                }else{
1883
+                } else {
1884 1884
                     $email_body .= $emailtext.' <strong>'.$_course['name'].' ('.api_get_session_name(api_get_session_id()).') - '.$group_name.'</strong><br /><br /><br />';
1885 1885
                 }
1886 1886
                 $email_body .= $email_user_author.' ('.$email_date_changes.')<br /><br /><br />';
@@ -1958,25 +1958,25 @@  discard block
 block discarded – undo
1958 1958
             $template);
1959 1959
 
1960 1960
         if (0 != $groupId) {
1961
-            $groupPart = '_group' . $groupId; // and add groupId to put the same document title in different groups
1962
-            $group_properties  = GroupManager :: get_group_properties($groupId);
1961
+            $groupPart = '_group'.$groupId; // and add groupId to put the same document title in different groups
1962
+            $group_properties = GroupManager :: get_group_properties($groupId);
1963 1963
             $groupPath = $group_properties['directory'];
1964 1964
         } else {
1965 1965
             $groupPart = '';
1966
-            $groupPath ='';
1966
+            $groupPath = '';
1967 1967
         }
1968 1968
 
1969
-        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path(). '/document'.$groupPath;
1970
-        $exportFile = api_replace_dangerous_char($wikiTitle) . $groupPart;
1969
+        $exportDir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$groupPath;
1970
+        $exportFile = api_replace_dangerous_char($wikiTitle).$groupPart;
1971 1971
         $wikiContents = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $wikiContents));
1972 1972
         //TODO: put link instead of title
1973 1973
 
1974 1974
         $wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
1975 1975
 
1976 1976
         // replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents
1977
-        if (api_strpos($wikiContents,'../../courses/') !== false) {
1977
+        if (api_strpos($wikiContents, '../../courses/') !== false) {
1978 1978
             $web_course_path = api_get_path(WEB_COURSE_PATH);
1979
-            $wikiContents = str_replace('../../courses/',$web_course_path,$wikiContents);
1979
+            $wikiContents = str_replace('../../courses/', $web_course_path, $wikiContents);
1980 1980
         }
1981 1981
 
1982 1982
         $i = 1;
@@ -1985,8 +1985,8 @@  discard block
 block discarded – undo
1985 1985
             $i++;
1986 1986
         }
1987 1987
 
1988
-        $wikiFileName = $exportFile . '_' . $i . '.html';
1989
-        $exportPath = $exportDir . '/' . $wikiFileName;
1988
+        $wikiFileName = $exportFile.'_'.$i.'.html';
1989
+        $exportPath = $exportDir.'/'.$wikiFileName;
1990 1990
 
1991 1991
         file_put_contents($exportPath, $wikiContents);
1992 1992
         $doc_id = add_document(
@@ -2031,14 +2031,14 @@  discard block
 block discarded – undo
2031 2031
         $content_pdf = api_html_entity_decode($data['content'], ENT_QUOTES, api_get_system_encoding());
2032 2032
 
2033 2033
         //clean wiki links
2034
-        $content_pdf=trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2034
+        $content_pdf = trim(preg_replace("/\[[\[]?([^\]|]*)[|]?([^|\]]*)\][\]]?/", "$1", $content_pdf));
2035 2035
         //TODO: It should be better to display the link insted of the tile but it is hard for [[title]] links
2036 2036
 
2037 2037
         $title_pdf = api_html_entity_decode($data['title'], ENT_QUOTES, api_get_system_encoding());
2038 2038
         $title_pdf = api_utf8_encode($title_pdf, api_get_system_encoding());
2039 2039
         $content_pdf = api_utf8_encode($content_pdf, api_get_system_encoding());
2040 2040
 
2041
-        $html='
2041
+        $html = '
2042 2042
         <!-- defines the headers/footers - this must occur before the headers/footers are set -->
2043 2043
 
2044 2044
         <!--mpdf
@@ -2093,9 +2093,9 @@  discard block
 block discarded – undo
2093 2093
         $session_id = $this->session_id;
2094 2094
         $groupId = api_get_group_id();
2095 2095
 
2096
-        if ($groupId==0) {
2096
+        if ($groupId == 0) {
2097 2097
             //extract course members
2098
-            if(!empty($session_id)) {
2098
+            if (!empty($session_id)) {
2099 2099
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id);
2100 2100
             } else {
2101 2101
                 $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0);
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES));
2122 2122
         $name = $userinfo['complete_name']." - ".$username;
2123 2123
 
2124
-        $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '"  width="40" height="50" align="top" title="' . $name . '"  />';
2124
+        $photo = '<img src="'.$userinfo['avatar'].'" alt="'.$name.'"  width="40" height="50" align="top" title="'.$name.'"  />';
2125 2125
 
2126 2126
         // teacher assignment title
2127 2127
         $title_orig = $values['title'];
@@ -2149,24 +2149,24 @@  discard block
 block discarded – undo
2149 2149
                 $userPicture = UserManager::getUserPicture($assig_user_id);
2150 2150
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES));
2151 2151
                 $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
2152
-                $photo= '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2152
+                $photo = '<img src="'.$userPicture.'" alt="'.$name.'"  width="40" height="50" align="bottom" title="'.$name.'"  />';
2153 2153
 
2154 2154
                 $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor
2155 2155
                 $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId);
2156 2156
                 // student is tutor and member
2157 2157
 
2158 2158
                 if ($is_tutor_and_member) {
2159
-                    $status_in_group=get_lang('GroupTutorAndMember');
2159
+                    $status_in_group = get_lang('GroupTutorAndMember');
2160 2160
                 } else {
2161
-                    if($is_tutor_of_group) {
2162
-                        $status_in_group=get_lang('GroupTutor');
2161
+                    if ($is_tutor_of_group) {
2162
+                        $status_in_group = get_lang('GroupTutor');
2163 2163
                     } else {
2164
-                        $status_in_group=" "; //get_lang('GroupStandardMember')
2164
+                        $status_in_group = " "; //get_lang('GroupStandardMember')
2165 2165
                     }
2166 2166
                 }
2167 2167
 
2168
-                if ($assignment_type==1) {
2169
-                    $values['title']= $title_orig;
2168
+                if ($assignment_type == 1) {
2169
+                    $values['title'] = $title_orig;
2170 2170
                     $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6">
2171 2171
                     <table border="0">
2172 2172
                     <tr><td style="font-size:24px">'.get_lang('AssignmentWork').'</td></tr>
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
                         ).
2183 2183
                         ' [['.$_POST['title']."_uass".$assig_user_id.' | '.$photo.']] '.$status_in_group.'</li>';
2184 2184
                     //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name)
2185
-                    $values['assignment']=2;
2185
+                    $values['assignment'] = 2;
2186 2186
                 }
2187 2187
                 $this->assig_user_id = $assig_user_id;
2188 2188
                 self::save_new_wiki($values);
@@ -2191,12 +2191,12 @@  discard block
 block discarded – undo
2191 2191
 
2192 2192
         foreach ($a_users_to_add as $o_user_to_add) {
2193 2193
             if ($o_user_to_add['user_id'] == $userId) {
2194
-                $assig_user_id=$o_user_to_add['user_id'];
2194
+                $assig_user_id = $o_user_to_add['user_id'];
2195 2195
                 if ($assignment_type == 1) {
2196
-                    $values['title']= $title_orig;
2197
-                    $values['comment']=get_lang('AssignmentDesc');
2196
+                    $values['title'] = $title_orig;
2197
+                    $values['comment'] = get_lang('AssignmentDesc');
2198 2198
                     sort($all_students_pages);
2199
-                    $values['content']=$content_orig_A.$content_orig_B.'<br/>
2199
+                    $values['content'] = $content_orig_A.$content_orig_B.'<br/>
2200 2200
                     <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
2201 2201
                     '.get_lang('AssignmentLinkstoStudentsPage').'
2202 2202
                     </div><br/>
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
                     <ol>'.implode($all_students_pages).'</ol>
2205 2205
                     </div>
2206 2206
                     <br/>';
2207
-                    $values['assignment']=1;
2207
+                    $values['assignment'] = 1;
2208 2208
                 }
2209 2209
                 $this->assig_user_id = $assig_user_id;
2210 2210
                 self::save_new_wiki($values);
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
      * @param   int     Whether to search the contents (1) or just the titles (0)
2219 2219
      * @param int
2220 2220
      */
2221
-    public function display_wiki_search_results($search_term, $search_content=0, $all_vers=0)
2221
+    public function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0)
2222 2222
     {
2223 2223
         $tbl_wiki = $this->tbl_wiki;
2224 2224
         $condition_session = $this->condition_session;
@@ -2230,9 +2230,9 @@  discard block
 block discarded – undo
2230 2230
         echo '</legend>';
2231 2231
 
2232 2232
         //only by professors when page is hidden
2233
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
2234
-            if ($all_vers=='1') {
2235
-                if ($search_content=='1') {
2233
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2234
+            if ($all_vers == '1') {
2235
+                if ($search_content == '1') {
2236 2236
                     $sql = "SELECT * FROM ".$tbl_wiki."
2237 2237
                             WHERE
2238 2238
                                 c_id = $course_id AND
@@ -2249,7 +2249,7 @@  discard block
 block discarded – undo
2249 2249
                     //search all pages and all versions
2250 2250
                 }
2251 2251
             } else {
2252
-                if ($search_content=='1') {
2252
+                if ($search_content == '1') {
2253 2253
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2254 2254
                             WHERE
2255 2255
                                 s1.c_id = $course_id AND
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
                     //search all pages and all versions
2301 2301
                 }
2302 2302
             } else {
2303
-                if($search_content=='1') {
2303
+                if ($search_content == '1') {
2304 2304
                     $sql = "SELECT * FROM ".$tbl_wiki." s1
2305 2305
                             WHERE
2306 2306
                                 s1.c_id = $course_id AND
@@ -2348,17 +2348,17 @@  discard block
 block discarded – undo
2348 2348
                 $seconds = substr($obj->dtime, 17, 2);
2349 2349
 
2350 2350
                 //get type assignment icon
2351
-                if($obj->assignment==1) {
2352
-                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
2353
-                } elseif ($obj->assignment==2) {
2354
-                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
2355
-                } elseif ($obj->assignment==0) {
2351
+                if ($obj->assignment == 1) {
2352
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
2353
+                } elseif ($obj->assignment == 2) {
2354
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
2355
+                } elseif ($obj->assignment == 0) {
2356 2356
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
2357 2357
                 }
2358 2358
                 $row = array();
2359 2359
                 $row[] = $ShowAssignment;
2360 2360
 
2361
-                if($all_vers=='1') {
2361
+                if ($all_vers == '1') {
2362 2362
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.
2363 2363
                         api_htmlentities($obj->title).'</a>';
2364 2364
                 } else {
@@ -2369,21 +2369,21 @@  discard block
 block discarded – undo
2369 2369
                 $row[] = $obj->user_id != 0 ? UserManager::getUserProfileLink($userinfo) : get_lang('Anonymous').' ('.$obj->user_ip.')';
2370 2370
                 $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
2371 2371
 
2372
-                if ($all_vers=='1') {
2372
+                if ($all_vers == '1') {
2373 2373
                     $row[] = $obj->version;
2374 2374
                 } else {
2375 2375
                     $showdelete = '';
2376
-                    if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
2377
-                        $showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2378
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
2376
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
2377
+                        $showdelete = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2378
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
2379 2379
                     }
2380 2380
                     $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2381
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a>
2381
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a>
2382 2382
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2383
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a>
2383
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a>
2384 2384
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2385
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2386
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
2385
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
2386
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
2387 2387
                 }
2388 2388
                 $rows[] = $row;
2389 2389
             }
@@ -2408,16 +2408,16 @@  discard block
 block discarded – undo
2408 2408
                     'all_vers' => $all_vers,
2409 2409
                 )
2410 2410
             );
2411
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
2412
-            $table->set_header(1,get_lang('Title'), true);
2411
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
2412
+            $table->set_header(1, get_lang('Title'), true);
2413 2413
             if ($all_vers == '1') {
2414
-                $table->set_header(2,get_lang('Author'), true);
2415
-                $table->set_header(3,get_lang('Date'), true);
2416
-                $table->set_header(4,get_lang('Version'), true);
2414
+                $table->set_header(2, get_lang('Author'), true);
2415
+                $table->set_header(3, get_lang('Date'), true);
2416
+                $table->set_header(4, get_lang('Version'), true);
2417 2417
             } else {
2418
-                $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
2419
-                $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
2420
-                $table->set_header(4,get_lang('Actions'), false, array ('style' => 'width:130px;'));
2418
+                $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
2419
+                $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
2420
+                $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;'));
2421 2421
             }
2422 2422
             $table->display();
2423 2423
         } else {
@@ -2430,14 +2430,14 @@  discard block
 block discarded – undo
2430 2430
      * @todo replace this function with the formvalidator datepicker
2431 2431
      *
2432 2432
      */
2433
-    public function draw_date_picker($prefix,$default='')
2433
+    public function draw_date_picker($prefix, $default = '')
2434 2434
     {
2435 2435
         if (empty($default)) {
2436 2436
             $default = date('Y-m-d H:i:s');
2437 2437
         }
2438 2438
         $parts = explode(' ', $default);
2439
-        list($d_year,$d_month,$d_day) = explode('-',$parts[0]);
2440
-        list($d_hour,$d_minute) = explode(':',$parts[1]);
2439
+        list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
2440
+        list($d_hour, $d_minute) = explode(':', $parts[1]);
2441 2441
 
2442 2442
         $month_list = array(
2443 2443
             1 => get_lang('JanuaryLong'),
@@ -2454,9 +2454,9 @@  discard block
 block discarded – undo
2454 2454
             12 => get_lang('DecemberLong'),
2455 2455
         );
2456 2456
 
2457
-        $minute = range(10,59);
2458
-        array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
2459
-        $date_form = self::make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day);
2457
+        $minute = range(10, 59);
2458
+        array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
2459
+        $date_form = self::make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day);
2460 2460
         $date_form .= self::make_select($prefix.'_month', $month_list, $d_month);
2461 2461
         $date_form .= self::make_select(
2462 2462
                 $prefix.'_year',
@@ -2469,7 +2469,7 @@  discard block
 block discarded – undo
2469 2469
                 ),
2470 2470
                 $d_year
2471 2471
             ).'&nbsp;&nbsp;&nbsp;&nbsp;';
2472
-        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : ';
2472
+        $date_form .= self::make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : ';
2473 2473
         $date_form .= self::make_select($prefix.'_minute', $minute, $d_minute);
2474 2474
 
2475 2475
         return $date_form;
@@ -2479,11 +2479,11 @@  discard block
 block discarded – undo
2479 2479
      * Draws an HTML form select with the given options
2480 2480
      *
2481 2481
      */
2482
-    public function make_select($name,$values,$checked='')
2482
+    public function make_select($name, $values, $checked = '')
2483 2483
     {
2484 2484
         $output = '<select name="'.$name.'" id="'.$name.'">';
2485
-        foreach($values as $key => $value) {
2486
-            $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
2485
+        foreach ($values as $key => $value) {
2486
+            $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2487 2487
         }
2488 2488
         $output .= '</select>';
2489 2489
         return $output;
@@ -2507,7 +2507,7 @@  discard block
 block discarded – undo
2507 2507
      */
2508 2508
     public function two_digits($number)
2509 2509
     {
2510
-        $number = (int)$number;
2510
+        $number = (int) $number;
2511 2511
         return ($number < 10) ? '0'.$number : $number;
2512 2512
     }
2513 2513
 
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
                 WHERE c_id = '.$course_id.' AND id = '.$id.' ';
2526 2526
         $result = Database::query($sql);
2527 2527
         $data = array();
2528
-        while ($row=Database::fetch_array($result,'ASSOC'))   {
2528
+        while ($row = Database::fetch_array($result, 'ASSOC')) {
2529 2529
             $data = $row;
2530 2530
         }
2531 2531
         return $data;
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
         $result = Database::query($sql);
2580 2580
         $data = array();
2581 2581
         if (Database::num_rows($result)) {
2582
-            $data = Database::fetch_array($result,'ASSOC');
2582
+            $data = Database::fetch_array($result, 'ASSOC');
2583 2583
         }
2584 2584
 
2585 2585
         return $data;
@@ -2673,9 +2673,9 @@  discard block
 block discarded – undo
2673 2673
         $result = self::getAllWiki();
2674 2674
         if (!empty($result)) {
2675 2675
             foreach ($result  as $is_editing_block) {
2676
-                $max_edit_time	= 1200; // 20 minutes
2677
-                $timestamp_edit	= strtotime($is_editing_block['time_edit']);
2678
-                $time_editing	= time()-$timestamp_edit;
2676
+                $max_edit_time = 1200; // 20 minutes
2677
+                $timestamp_edit = strtotime($is_editing_block['time_edit']);
2678
+                $time_editing = time() - $timestamp_edit;
2679 2679
 
2680 2680
                 // First prevent concurrent users and double version
2681 2681
                 if ($is_editing_block['is_editing'] == $userId) {
@@ -2684,7 +2684,7 @@  discard block
 block discarded – undo
2684 2684
                     unset($_SESSION['_version']);
2685 2685
                 }
2686 2686
                 // Second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
2687
-                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action!='edit')) {
2687
+                if ($time_editing > $max_edit_time || ($is_editing_block['is_editing'] == $userId && $action != 'edit')) {
2688 2688
                     self::updateWikiIsEditing($is_editing_block['is_editing']);
2689 2689
                 }
2690 2690
             }
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
                 FROM ".$tbl_wiki."
2733 2733
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2734 2734
 
2735
-        $allpages=Database::query($sql);
2735
+        $allpages = Database::query($sql);
2736 2736
         while ($row = Database::fetch_array($allpages)) {
2737 2737
             $total_versions = $row['TOTAL_VERS'];
2738 2738
             $total_visits = intval($row['TOTAL_VISITS']);
@@ -2742,30 +2742,30 @@  discard block
 block discarded – undo
2742 2742
                 WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
2743 2743
         $allpages = Database::query($sql);
2744 2744
 
2745
-        while ($row=Database::fetch_array($allpages)) {
2745
+        while ($row = Database::fetch_array($allpages)) {
2746 2746
             $total_words = $total_words + self::word_count($row['content']);
2747
-            $total_links 			= $total_links+substr_count($row['content'], "href=");
2748
-            $total_links_anchors 	= $total_links_anchors+substr_count($row['content'], 'href="#');
2749
-            $total_links_mail		= $total_links_mail+substr_count($row['content'], 'href="mailto');
2750
-            $total_links_ftp 		= $total_links_ftp+substr_count($row['content'], 'href="ftp');
2751
-            $total_links_irc		= $total_links_irc+substr_count($row['content'], 'href="irc');
2752
-            $total_links_news 		= $total_links_news+substr_count($row['content'], 'href="news');
2753
-            $total_wlinks 			= $total_wlinks+substr_count($row['content'], "[[");
2754
-            $total_images 			= $total_images+substr_count($row['content'], "<img");
2747
+            $total_links = $total_links + substr_count($row['content'], "href=");
2748
+            $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#');
2749
+            $total_links_mail		= $total_links_mail + substr_count($row['content'], 'href="mailto');
2750
+            $total_links_ftp 		= $total_links_ftp + substr_count($row['content'], 'href="ftp');
2751
+            $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc');
2752
+            $total_links_news = $total_links_news + substr_count($row['content'], 'href="news');
2753
+            $total_wlinks 			= $total_wlinks + substr_count($row['content'], "[[");
2754
+            $total_images 			= $total_images + substr_count($row['content'], "<img");
2755 2755
             $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
2756
-            $total_flash			= $total_flash+substr_count($clean_total_flash, '.swf"');
2756
+            $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"');
2757 2757
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2758
-            $total_mp3				= $total_mp3+substr_count($row['content'], ".mp3");
2759
-            $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
2760
-            $total_flv				=	$total_flv_p/5;
2761
-            $total_youtube			= $total_youtube+substr_count($row['content'], "http://www.youtube.com");
2762
-            $total_multimedia		= $total_multimedia+substr_count($row['content'], "video/x-msvideo");
2763
-            $total_tables			= $total_tables+substr_count($row['content'], "<table");
2758
+            $total_mp3				= $total_mp3 + substr_count($row['content'], ".mp3");
2759
+            $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv");
2760
+            $total_flv				= $total_flv_p / 5;
2761
+            $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com");
2762
+            $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo");
2763
+            $total_tables = $total_tables + substr_count($row['content'], "<table");
2764 2764
         }
2765 2765
 
2766 2766
         //check only last version of all pages (current page)
2767 2767
 
2768
-        $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2768
+        $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
2769 2769
                 FROM  '.$tbl_wiki.' s1
2770 2770
                 WHERE s1.c_id = '.$course_id.' AND id=(
2771 2771
                     SELECT MAX(s2.id)
@@ -2776,9 +2776,9 @@  discard block
 block discarded – undo
2776 2776
                         '.$groupfilter.' AND
2777 2777
                         session_id='.$session_id.')';
2778 2778
         $allpages = Database::query($sql);
2779
-        while ($row=Database::fetch_array($allpages)) {
2780
-            $total_pages	 		= $row['TOTAL_PAGES'];
2781
-            $total_visits_lv 		= intval($row['TOTAL_VISITS_LV']);
2779
+        while ($row = Database::fetch_array($allpages)) {
2780
+            $total_pages = $row['TOTAL_PAGES'];
2781
+            $total_visits_lv = intval($row['TOTAL_VISITS_LV']);
2782 2782
         }
2783 2783
 
2784 2784
         $total_words_lv = 0;
@@ -2810,29 +2810,29 @@  discard block
 block discarded – undo
2810 2810
                 )';
2811 2811
         $allpages = Database::query($sql);
2812 2812
 
2813
-        while ($row=Database::fetch_array($allpages)) {
2814
-            $total_words_lv 		= $total_words_lv+ self::word_count($row['content']);
2815
-            $total_links_lv 		= $total_links_lv+substr_count($row['content'], "href=");
2816
-            $total_links_anchors_lv	= $total_links_anchors_lv+substr_count($row['content'], 'href="#');
2817
-            $total_links_mail_lv 	= $total_links_mail_lv+substr_count($row['content'], 'href="mailto');
2818
-            $total_links_ftp_lv 	= $total_links_ftp_lv+substr_count($row['content'], 'href="ftp');
2819
-            $total_links_irc_lv 	= $total_links_irc_lv+substr_count($row['content'], 'href="irc');
2820
-            $total_links_news_lv 	= $total_links_news_lv+substr_count($row['content'], 'href="news');
2821
-            $total_wlinks_lv 		= $total_wlinks_lv+substr_count($row['content'], "[[");
2822
-            $total_images_lv 		= $total_images_lv+substr_count($row['content'], "<img");
2813
+        while ($row = Database::fetch_array($allpages)) {
2814
+            $total_words_lv 		= $total_words_lv + self::word_count($row['content']);
2815
+            $total_links_lv 		= $total_links_lv + substr_count($row['content'], "href=");
2816
+            $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#');
2817
+            $total_links_mail_lv 	= $total_links_mail_lv + substr_count($row['content'], 'href="mailto');
2818
+            $total_links_ftp_lv 	= $total_links_ftp_lv + substr_count($row['content'], 'href="ftp');
2819
+            $total_links_irc_lv 	= $total_links_irc_lv + substr_count($row['content'], 'href="irc');
2820
+            $total_links_news_lv 	= $total_links_news_lv + substr_count($row['content'], 'href="news');
2821
+            $total_wlinks_lv 		= $total_wlinks_lv + substr_count($row['content'], "[[");
2822
+            $total_images_lv 		= $total_images_lv + substr_count($row['content'], "<img");
2823 2823
             $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
2824
-            $total_flash_lv			= $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
2824
+            $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"');
2825 2825
             //.swf" end quotes prevent insert swf through flvplayer (is not counted)
2826
-            $total_mp3_lv			= $total_mp3_lv+substr_count($row['content'], ".mp3");
2827
-            $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
2828
-            $total_flv_lv			= $total_flv_p_lv/5;
2829
-            $total_youtube_lv		= $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com");
2830
-            $total_multimedia_lv	= $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo");
2831
-            $total_tables_lv		= $total_tables_lv+substr_count($row['content'], "<table");
2826
+            $total_mp3_lv			= $total_mp3_lv + substr_count($row['content'], ".mp3");
2827
+            $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv");
2828
+            $total_flv_lv			= $total_flv_p_lv / 5;
2829
+            $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com");
2830
+            $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo");
2831
+            $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table");
2832 2832
         }
2833 2833
 
2834 2834
         //Total pages edited at this time
2835
-        $total_editing_now=0;
2835
+        $total_editing_now = 0;
2836 2836
         $sql = 'SELECT *, COUNT(*) AS TOTAL_EDITING_NOW
2837 2837
                 FROM  '.$tbl_wiki.' s1
2838 2838
                 WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND
@@ -2847,66 +2847,66 @@  discard block
 block discarded – undo
2847 2847
         )';
2848 2848
 
2849 2849
         // Can not use group by because the mark is set in the latest version
2850
-        $allpages=Database::query($sql);
2851
-        while ($row=Database::fetch_array($allpages)) {
2852
-            $total_editing_now	= $row['TOTAL_EDITING_NOW'];
2850
+        $allpages = Database::query($sql);
2851
+        while ($row = Database::fetch_array($allpages)) {
2852
+            $total_editing_now = $row['TOTAL_EDITING_NOW'];
2853 2853
         }
2854 2854
 
2855 2855
         // Total hidden pages
2856
-        $total_hidden=0;
2856
+        $total_hidden = 0;
2857 2857
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2858 2858
                 WHERE  c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
2859 2859
                 GROUP BY reflink';
2860 2860
         // or group by page_id. As the mark of hidden places it in all versions of the page, I can use group by to see the first
2861
-        $allpages=Database::query($sql);
2862
-        while ($row=Database::fetch_array($allpages)) {
2863
-            $total_hidden = $total_hidden+1;
2861
+        $allpages = Database::query($sql);
2862
+        while ($row = Database::fetch_array($allpages)) {
2863
+            $total_hidden = $total_hidden + 1;
2864 2864
         }
2865 2865
 
2866 2866
         //Total protect pages
2867
-        $total_protected=0;
2867
+        $total_protected = 0;
2868 2868
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2869 2869
                 WHERE  c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.'
2870 2870
                 GROUP BY reflink';
2871 2871
         // or group by page_id. As the mark of protected page is the first version of the page, I can use group by
2872 2872
 
2873
-        $allpages=Database::query($sql);
2874
-        while ($row=Database::fetch_array($allpages)) {
2875
-            $total_protected = $total_protected+1;
2873
+        $allpages = Database::query($sql);
2874
+        while ($row = Database::fetch_array($allpages)) {
2875
+            $total_protected = $total_protected + 1;
2876 2876
         }
2877 2877
 
2878 2878
         // Total empty versions.
2879
-        $total_empty_content=0;
2879
+        $total_empty_content = 0;
2880 2880
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2881 2881
                 WHERE
2882 2882
                     c_id = '.$course_id.' AND
2883 2883
                     content="" AND
2884 2884
                     '.$groupfilter.$condition_session.'';
2885 2885
         $allpages = Database::query($sql);
2886
-        while ($row=Database::fetch_array($allpages)) {
2887
-            $total_empty_content	= $total_empty_content+1;
2886
+        while ($row = Database::fetch_array($allpages)) {
2887
+            $total_empty_content = $total_empty_content + 1;
2888 2888
         }
2889 2889
 
2890 2890
         //Total empty pages (last version)
2891 2891
 
2892
-        $total_empty_content_lv=0;
2892
+        $total_empty_content_lv = 0;
2893 2893
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2894 2894
                 WHERE s1.c_id = '.$course_id.' AND content="" AND id=(
2895 2895
                 SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2896 2896
                 WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2897
-        $allpages=Database::query($sql);
2897
+        $allpages = Database::query($sql);
2898 2898
         while ($row = Database::fetch_array($allpages)) {
2899
-            $total_empty_content_lv	= $total_empty_content_lv+1;
2899
+            $total_empty_content_lv = $total_empty_content_lv + 1;
2900 2900
         }
2901 2901
 
2902 2902
         // Total locked discuss pages
2903
-        $total_lock_disc=0;
2903
+        $total_lock_disc = 0;
2904 2904
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2905 2905
                 WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.'
2906 2906
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2907
-        $allpages=Database::query($sql);
2907
+        $allpages = Database::query($sql);
2908 2908
         while ($row = Database::fetch_array($allpages)) {
2909
-            $total_lock_disc	= $total_lock_disc+1;
2909
+            $total_lock_disc = $total_lock_disc + 1;
2910 2910
         }
2911 2911
 
2912 2912
         // Total hidden discuss pages.
@@ -2917,7 +2917,7 @@  discard block
 block discarded – undo
2917 2917
         //group by because mark lock in all vers, then always is ok
2918 2918
         $allpages = Database::query($sql);
2919 2919
         while ($row = Database::fetch_array($allpages)) {
2920
-            $total_hidden_disc	= $total_hidden_disc+1;
2920
+            $total_hidden_disc = $total_hidden_disc + 1;
2921 2921
         }
2922 2922
 
2923 2923
         //Total versions with any short comment by user or system
@@ -2925,44 +2925,44 @@  discard block
 block discarded – undo
2925 2925
         $total_comment_version = 0;
2926 2926
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2927 2927
                 WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.'';
2928
-        $allpages=Database::query($sql);
2928
+        $allpages = Database::query($sql);
2929 2929
         while ($row = Database::fetch_array($allpages)) {
2930
-            $total_comment_version	= $total_comment_version+1;
2930
+            $total_comment_version = $total_comment_version + 1;
2931 2931
         }
2932 2932
 
2933 2933
         // Total pages that can only be scored by teachers.
2934 2934
 
2935
-        $total_only_teachers_rating=0;
2935
+        $total_only_teachers_rating = 0;
2936 2936
         $sql = 'SELECT * FROM '.$tbl_wiki.'
2937 2937
                 WHERE c_id = '.$course_id.' AND
2938 2938
                 ratinglock_disc = 0 AND
2939 2939
                 '.$groupfilter.$condition_session.'
2940 2940
                 GROUP BY reflink';//group by because mark lock in all vers, then always is ok
2941
-        $allpages=Database::query($sql);
2942
-        while ($row=Database::fetch_array($allpages)) {
2943
-            $total_only_teachers_rating	= $total_only_teachers_rating+1;
2941
+        $allpages = Database::query($sql);
2942
+        while ($row = Database::fetch_array($allpages)) {
2943
+            $total_only_teachers_rating = $total_only_teachers_rating + 1;
2944 2944
         }
2945 2945
 
2946 2946
         // Total pages scored by peers
2947 2947
         // put always this line alfter check num all pages and num pages rated by teachers
2948
-        $total_rating_by_peers=$total_pages-$total_only_teachers_rating;
2948
+        $total_rating_by_peers = $total_pages - $total_only_teachers_rating;
2949 2949
 
2950 2950
         //Total pages identified as standard task
2951 2951
 
2952
-        $total_task=0;
2953
-        $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2952
+        $total_task = 0;
2953
+        $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
2954 2954
               WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
2955 2955
                '.$tbl_wiki_conf.'.task!="" AND
2956 2956
                '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
2957 2957
                 '.$tbl_wiki.'.'.$groupfilter.$condition_session;
2958 2958
         $allpages = Database::query($sql);
2959
-        while ($row=Database::fetch_array($allpages)) {
2960
-            $total_task=$total_task+1;
2959
+        while ($row = Database::fetch_array($allpages)) {
2960
+            $total_task = $total_task + 1;
2961 2961
         }
2962 2962
 
2963 2963
         //Total pages identified as teacher page (wiki portfolio mode - individual assignment)
2964 2964
 
2965
-        $total_teacher_assignment=0;
2965
+        $total_teacher_assignment = 0;
2966 2966
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2967 2967
                 WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=(
2968 2968
                     SELECT MAX(s2.id)
@@ -2972,20 +2972,20 @@  discard block
 block discarded – undo
2972 2972
         //mark all versions, but do not use group by reflink because y want the pages not versions
2973 2973
         $allpages = Database::query($sql);
2974 2974
         while ($row = Database::fetch_array($allpages)) {
2975
-            $total_teacher_assignment=$total_teacher_assignment+1;
2975
+            $total_teacher_assignment = $total_teacher_assignment + 1;
2976 2976
         }
2977 2977
 
2978 2978
         //Total pages identifies as student page (wiki portfolio mode - individual assignment)
2979 2979
 
2980
-        $total_student_assignment=0;
2980
+        $total_student_assignment = 0;
2981 2981
         $sql = 'SELECT  * FROM  '.$tbl_wiki.' s1
2982 2982
                 WHERE s1.c_id = '.$course_id.' AND assignment=2 AND
2983 2983
                 id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
2984 2984
                 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
2985 2985
         //mark all versions, but do not use group by reflink because y want the pages not versions
2986
-        $allpages=Database::query($sql);
2987
-        while ($row=Database::fetch_array($allpages)) {
2988
-            $total_student_assignment = $total_student_assignment+1;
2986
+        $allpages = Database::query($sql);
2987
+        while ($row = Database::fetch_array($allpages)) {
2988
+            $total_student_assignment = $total_student_assignment + 1;
2989 2989
         }
2990 2990
 
2991 2991
         //Current Wiki status add new pages
@@ -2994,36 +2994,36 @@  discard block
 block discarded – undo
2994 2994
                 GROUP BY addlock';//group by because mark 0 in all vers, then always is ok
2995 2995
         $allpages = Database::query($sql);
2996 2996
         $wiki_add_lock = null;
2997
-        while ($row=Database::fetch_array($allpages)) {
2998
-            $wiki_add_lock=$row['addlock'];
2997
+        while ($row = Database::fetch_array($allpages)) {
2998
+            $wiki_add_lock = $row['addlock'];
2999 2999
         }
3000 3000
 
3001
-        if ($wiki_add_lock==1) {
3002
-            $status_add_new_pag=get_lang('Yes');
3001
+        if ($wiki_add_lock == 1) {
3002
+            $status_add_new_pag = get_lang('Yes');
3003 3003
         } else {
3004
-            $status_add_new_pag=get_lang('No');
3004
+            $status_add_new_pag = get_lang('No');
3005 3005
         }
3006 3006
 
3007 3007
         //Creation date of the oldest wiki page and version
3008 3008
 
3009
-        $first_wiki_date='0000-00-00 00:00:00';
3009
+        $first_wiki_date = '0000-00-00 00:00:00';
3010 3010
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3011 3011
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3012 3012
                 ORDER BY dtime ASC LIMIT 1';
3013
-        $allpages=Database::query($sql);
3014
-        while ($row=Database::fetch_array($allpages)) {
3015
-            $first_wiki_date=$row['dtime'];
3013
+        $allpages = Database::query($sql);
3014
+        while ($row = Database::fetch_array($allpages)) {
3015
+            $first_wiki_date = $row['dtime'];
3016 3016
         }
3017 3017
 
3018 3018
         // Date of publication of the latest wiki version.
3019 3019
 
3020
-        $last_wiki_date='0000-00-00 00:00:00';
3020
+        $last_wiki_date = '0000-00-00 00:00:00';
3021 3021
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3022 3022
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3023 3023
                 ORDER BY dtime DESC LIMIT 1';
3024
-        $allpages=Database::query($sql);
3025
-        while ($row=Database::fetch_array($allpages)) {
3026
-            $last_wiki_date=$row['dtime'];
3024
+        $allpages = Database::query($sql);
3025
+        while ($row = Database::fetch_array($allpages)) {
3026
+            $last_wiki_date = $row['dtime'];
3027 3027
         }
3028 3028
 
3029 3029
         // Average score of all wiki pages. (If a page has not scored zero rated)
@@ -3035,18 +3035,18 @@  discard block
 block discarded – undo
3035 3035
         // Do not use "count" because using "group by", would give a wrong value
3036 3036
         $allpages = Database::query($sql);
3037 3037
         $total_score = 0;
3038
-        while ($row=Database::fetch_array($allpages)) {
3039
-            $total_score = $total_score+$row['TOTAL_SCORE'];
3038
+        while ($row = Database::fetch_array($allpages)) {
3039
+            $total_score = $total_score + $row['TOTAL_SCORE'];
3040 3040
         }
3041 3041
 
3042 3042
         if (!empty($total_pages)) {
3043
-            $media_score = $total_score/$total_pages;
3043
+            $media_score = $total_score / $total_pages;
3044 3044
             //put always this line alfter check num all pages
3045 3045
         }
3046 3046
 
3047 3047
         // Average user progress in his pages.
3048 3048
 
3049
-        $media_progress=0;
3049
+        $media_progress = 0;
3050 3050
         $sql = 'SELECT  *, SUM(progress) AS TOTAL_PROGRESS
3051 3051
                 FROM  '.$tbl_wiki.' s1
3052 3052
                 WHERE s1.c_id = '.$course_id.' AND id=
@@ -3060,24 +3060,24 @@  discard block
 block discarded – undo
3060 3060
         // As the value is only the latest version I can not use group by
3061 3061
         $allpages = Database::query($sql);
3062 3062
         while ($row = Database::fetch_array($allpages)) {
3063
-            $total_progress	= $row['TOTAL_PROGRESS'];
3063
+            $total_progress = $row['TOTAL_PROGRESS'];
3064 3064
         }
3065 3065
 
3066 3066
         if (!empty($total_pages)) {
3067
-            $media_progress=$total_progress/$total_pages;
3067
+            $media_progress = $total_progress / $total_pages;
3068 3068
             //put always this line alfter check num all pages
3069 3069
         }
3070 3070
 
3071 3071
         //Total users that have participated in the Wiki
3072 3072
 
3073
-        $total_users=0;
3073
+        $total_users = 0;
3074 3074
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3075 3075
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3076 3076
                 GROUP BY user_id';
3077 3077
         //as the mark of user it in all versions of the page, I can use group by to see the first
3078
-        $allpages=Database::query($sql);
3079
-        while ($row=Database::fetch_array($allpages)) {
3080
-            $total_users = $total_users+1;
3078
+        $allpages = Database::query($sql);
3079
+        while ($row = Database::fetch_array($allpages)) {
3080
+            $total_users = $total_users + 1;
3081 3081
         }
3082 3082
 
3083 3083
         // Total of different IP addresses that have participated in the wiki
@@ -3085,9 +3085,9 @@  discard block
 block discarded – undo
3085 3085
         $sql = 'SELECT * FROM '.$tbl_wiki.'
3086 3086
               WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
3087 3087
               GROUP BY user_ip';
3088
-        $allpages=Database::query($sql);
3089
-        while ($row=Database::fetch_array($allpages)) {
3090
-            $total_ip	= $total_ip+1;
3088
+        $allpages = Database::query($sql);
3089
+        while ($row = Database::fetch_array($allpages)) {
3090
+            $total_ip = $total_ip + 1;
3091 3091
         }
3092 3092
 
3093 3093
         echo '<table class="data_table">';
@@ -3286,11 +3286,11 @@  discard block
 block discarded – undo
3286 3286
                 } else {
3287 3287
                     $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
3288 3288
                 }
3289
-                $row[] ='<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
3289
+                $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
3290 3290
                 $rows[] = $row;
3291 3291
             }
3292 3292
 
3293
-            $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
3293
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'MostActiveUsersA_table', '', '', 'DESC');
3294 3294
             $table->set_additional_parameters(
3295 3295
                 array(
3296 3296
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -3299,8 +3299,8 @@  discard block
 block discarded – undo
3299 3299
                     'group_id' => Security::remove_XSS($_GET['group_id'])
3300 3300
                 )
3301 3301
             );
3302
-            $table->set_header(0,get_lang('Author'), true);
3303
-            $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
3302
+            $table->set_header(0, get_lang('Author'), true);
3303
+            $table->set_header(1, get_lang('Contributions'), true, array('style' => 'width:30px;'));
3304 3304
             $table->display();
3305 3305
         }
3306 3306
     }
@@ -3316,8 +3316,8 @@  discard block
 block discarded – undo
3316 3316
         $groupfilter = $this->groupfilter;
3317 3317
         $tbl_wiki_discuss = $this->tbl_wiki_discuss;
3318 3318
 
3319
-        if (api_get_session_id()!=0 &&
3320
-            api_is_allowed_to_session_edit(false,true)==false
3319
+        if (api_get_session_id() != 0 &&
3320
+            api_is_allowed_to_session_edit(false, true) == false
3321 3321
         ) {
3322 3322
             api_not_allowed();
3323 3323
         }
@@ -3380,9 +3380,9 @@  discard block
 block discarded – undo
3380 3380
         //mode assignment: previous to show  page type
3381 3381
         $icon_assignment = null;
3382 3382
         if ($row['assignment'] == 1) {
3383
-            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
3383
+            $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
3384 3384
         } elseif ($row['assignment'] == 2) {
3385
-            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
3385
+            $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
3386 3386
         }
3387 3387
 
3388 3388
         $countWPost = null;
@@ -3393,23 +3393,23 @@  discard block
 block discarded – undo
3393 3393
             // Show discussion to students if isn't hidden.
3394 3394
             // Show page to all teachers if is hidden.
3395 3395
             // Mode assignments: If is hidden, show pages to student only if student is the author
3396
-            if ($row['visibility_disc']==1 ||
3397
-                api_is_allowed_to_edit(false,true) ||
3396
+            if ($row['visibility_disc'] == 1 ||
3397
+                api_is_allowed_to_edit(false, true) ||
3398 3398
                 api_is_platform_admin() ||
3399
-                ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))
3399
+                ($row['assignment'] == 2 && $row['visibility_disc'] == 0 && (api_get_user_id() == $row['user_id']))
3400 3400
             ) {
3401 3401
                 echo '<div id="wikititle">';
3402 3402
 
3403 3403
                 // discussion action: protecting (locking) the discussion
3404 3404
                 $addlock_disc = null;
3405 3405
                 $lock_unlock_disc = null;
3406
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3406
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3407 3407
                     if (self::check_addlock_discuss() == 1) {
3408
-                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL);
3409
-                        $lock_unlock_disc ='unlockdisc';
3408
+                        $addlock_disc = Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'), '', ICON_SIZE_SMALL);
3409
+                        $lock_unlock_disc = 'unlockdisc';
3410 3410
                     } else {
3411
-                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL);
3412
-                        $lock_unlock_disc ='lockdisc';
3411
+                        $addlock_disc = Display::return_icon('lock.png', get_lang('LockDiscussExtra'), '', ICON_SIZE_SMALL);
3412
+                        $lock_unlock_disc = 'lockdisc';
3413 3413
                     }
3414 3414
                 }
3415 3415
                 echo '<span style="float:right">';
@@ -3419,13 +3419,13 @@  discard block
 block discarded – undo
3419 3419
                 // discussion action: visibility.  Show discussion to students if isn't hidden. Show page to all teachers if is hidden.
3420 3420
                 $visibility_disc = null;
3421 3421
                 $hide_show_disc = null;
3422
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3423
-                    if (self::check_visibility_discuss()==1) {
3422
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3423
+                    if (self::check_visibility_discuss() == 1) {
3424 3424
                         /// TODO: 	Fix Mode assignments: If is hidden, show discussion to student only if student is the author
3425
-                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL);
3425
+                        $visibility_disc = Display::return_icon('visible.png', get_lang('ShowDiscussExtra'), '', ICON_SIZE_SMALL);
3426 3426
                         $hide_show_disc = 'hidedisc';
3427 3427
                     } else {
3428
-                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL);
3428
+                        $visibility_disc = Display::return_icon('invisible.png', get_lang('HideDiscussExtra'), '', ICON_SIZE_SMALL);
3429 3429
                         $hide_show_disc = 'showdisc';
3430 3430
                     }
3431 3431
                 }
@@ -3436,12 +3436,12 @@  discard block
 block discarded – undo
3436 3436
                 //discussion action: check add rating lock. Show/Hide list to rating for all student
3437 3437
                 $lock_unlock_rating_disc = null;
3438 3438
                 $ratinglock_disc = null;
3439
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3439
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3440 3440
                     if (self::check_ratinglock_discuss() == 1) {
3441
-                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3441
+                        $ratinglock_disc = Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3442 3442
                         $lock_unlock_rating_disc = 'unlockrating';
3443 3443
                     } else {
3444
-                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
3444
+                        $ratinglock_disc = Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'), '', ICON_SIZE_SMALL);
3445 3445
                         $lock_unlock_rating_disc = 'lockrating';
3446 3446
                     }
3447 3447
                 }
@@ -3452,11 +3452,11 @@  discard block
 block discarded – undo
3452 3452
 
3453 3453
                 //discussion action: email notification
3454 3454
                 if (self::check_notify_discuss($page) == 1) {
3455
-                    $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3456
-                    $lock_unlock_notify_disc='unlocknotifydisc';
3455
+                    $notify_disc = Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3456
+                    $lock_unlock_notify_disc = 'unlocknotifydisc';
3457 3457
                 } else {
3458
-                    $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
3459
-                    $lock_unlock_notify_disc='locknotifydisc';
3458
+                    $notify_disc = Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'), '', ICON_SIZE_SMALL);
3459
+                    $lock_unlock_notify_disc = 'locknotifydisc';
3460 3460
                 }
3461 3461
                 echo '<span style="float:right">';
3462 3462
                 echo '<a href="index.php?action=discuss&amp;actionpage='.$lock_unlock_notify_disc.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>';
@@ -3468,22 +3468,22 @@  discard block
 block discarded – undo
3468 3468
 
3469 3469
                 echo '</div>';
3470 3470
 
3471
-                if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3471
+                if ($row['addlock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3472 3472
                     //show comments but students can't add theirs
3473 3473
                     ?>
3474 3474
                     <form name="form1" method="post" action="">
3475 3475
                         <table>
3476 3476
                             <tr>
3477
-                                <td valign="top" ><?php echo get_lang('Comments');?>:</td>
3478
-                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?>
3477
+                                <td valign="top" ><?php echo get_lang('Comments'); ?>:</td>
3478
+                                <?php  echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">'; //prevent double post ?>
3479 3479
                                 <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
3480 3480
                             </tr>
3481 3481
                             <tr>
3482 3482
                                 <?php
3483 3483
                                 //check if rating is allowed
3484
-                                if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3484
+                                if ($row['ratinglock_disc'] == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3485 3485
                                     ?>
3486
-                                    <td><?php echo get_lang('Rating');?>: </td>
3486
+                                    <td><?php echo get_lang('Rating'); ?>: </td>
3487 3487
                                     <td valign="top"><select name="rating" id="rating">
3488 3488
                                             <option value="-" selected>-</option>
3489 3489
                                             <option value="0">0</option>
@@ -3500,7 +3500,7 @@  discard block
 block discarded – undo
3500 3500
                                         </select></td>
3501 3501
                                 <?php
3502 3502
                                 } else {
3503
-                                    echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically
3503
+                                    echo '<input type=hidden name="rating" value="-">'; // must pass a default value to avoid rate automatically
3504 3504
                                 }
3505 3505
                                 ?>
3506 3506
                             </tr>
@@ -3540,12 +3540,12 @@  discard block
 block discarded – undo
3540 3540
                 $sql = "SELECT * FROM $tbl_wiki_discuss
3541 3541
                         WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
3542 3542
                 $result3 = Database::query($sql);
3543
-                $countWPost_score= Database::num_rows($result3);
3543
+                $countWPost_score = Database::num_rows($result3);
3544 3544
 
3545
-                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;//
3545
+                echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score; //
3546 3546
 
3547
-                if ($countWPost_score!=0) {
3548
-                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
3547
+                if ($countWPost_score != 0) {
3548
+                    $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score, 2).' / 10';
3549 3549
                 } else {
3550 3550
                     $avg_WPost_score = $countWPost_score;
3551 3551
                 }
@@ -3563,16 +3563,16 @@  discard block
 block discarded – undo
3563 3563
 
3564 3564
                 echo '<hr noshade size="1">';
3565 3565
 
3566
-                while ($row=Database::fetch_array($result)) {
3566
+                while ($row = Database::fetch_array($result)) {
3567 3567
                     $userinfo = api_get_user_info($row['userc_id']);
3568
-                    if (($userinfo['status'])=="5") {
3569
-                        $author_status=get_lang('Student');
3568
+                    if (($userinfo['status']) == "5") {
3569
+                        $author_status = get_lang('Student');
3570 3570
                     } else {
3571
-                        $author_status=get_lang('Teacher');
3571
+                        $author_status = get_lang('Teacher');
3572 3572
                     }
3573 3573
 
3574 3574
                     $name = $userinfo['complete_name'];
3575
-                    $author_photo= '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3575
+                    $author_photo = '<img src="'.$userinfo['avatar'].'" alt="'.api_htmlentities($name).'"  width="40" height="50" align="top"  title="'.api_htmlentities($name).'"  />';
3576 3576
 
3577 3577
                     //stars
3578 3578
                     $p_score = $row['p_score'];
@@ -3651,7 +3651,7 @@  discard block
 block discarded – undo
3651 3651
         }
3652 3652
         echo '</div>';
3653 3653
 
3654
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3654
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3655 3655
             $sql = 'SELECT  *
3656 3656
                     FROM  '.$tbl_wiki.' s1
3657 3657
         		    WHERE s1.c_id = '.$course_id.' AND id=(
@@ -3677,26 +3677,26 @@  discard block
 block discarded – undo
3677 3677
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
3678 3678
 
3679 3679
                 //get type assignment icon
3680
-                if ($obj->assignment==1) {
3681
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3682
-                } elseif ($obj->assignment==2) {
3683
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3684
-                } elseif ($obj->assignment==0) {
3680
+                if ($obj->assignment == 1) {
3681
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3682
+                } elseif ($obj->assignment == 2) {
3683
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3684
+                } elseif ($obj->assignment == 0) {
3685 3685
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
3686 3686
                 }
3687 3687
 
3688 3688
                 //get icon task
3689 3689
                 if (!empty($obj->task)) {
3690
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3690
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3691 3691
                 } else {
3692
-                    $icon_task= Display::return_icon('px_transparent.gif');
3692
+                    $icon_task = Display::return_icon('px_transparent.gif');
3693 3693
                 }
3694 3694
 
3695 3695
                 $row = array();
3696 3696
                 $row[] = $ShowAssignment.$icon_task;
3697 3697
                 $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">
3698 3698
                 '.api_htmlentities($obj->title).'</a>';
3699
-                if ($obj->user_id <>0) {
3699
+                if ($obj->user_id <> 0) {
3700 3700
                     $row[] = UserManager::getUserProfileLink($userinfo);
3701 3701
                 }
3702 3702
                 else {
@@ -3704,29 +3704,29 @@  discard block
 block discarded – undo
3704 3704
                 }
3705 3705
                 $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
3706 3706
                 $showdelete = '';
3707
-                if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
3708
-                    $showdelete =' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3709
-                        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
3707
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3708
+                    $showdelete = ' <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3709
+                        Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
3710 3710
                 }
3711
-                if (api_is_allowed_to_session_edit(false,true) ) {
3711
+                if (api_is_allowed_to_session_edit(false, true)) {
3712 3712
                     $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3713
-                        Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3714
-                        Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3715
-                        Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a>
3713
+                        Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=discuss&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3714
+                        Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3715
+                        Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL).'</a>
3716 3716
                         <a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3717
-                        Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
3717
+                        Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL).'</a>'.$showdelete;
3718 3718
                 }
3719 3719
                 $rows[] = $row;
3720 3720
             }
3721 3721
 
3722
-            $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
3723
-            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'group_id'=>Security::remove_XSS($_GET['group_id'])));
3724
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
3725
-            $table->set_header(1,get_lang('Title'), true);
3726
-            $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
3727
-            $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
3728
-            if (api_is_allowed_to_session_edit(false,true) ) {
3729
-                $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;'));
3722
+            $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC');
3723
+            $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']), 'action'=>Security::remove_XSS($action), 'group_id'=>Security::remove_XSS($_GET['group_id'])));
3724
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
3725
+            $table->set_header(1, get_lang('Title'), true);
3726
+            $table->set_header(2, get_lang('Author').' ('.get_lang('LastVersion').')', true);
3727
+            $table->set_header(3, get_lang('Date').' ('.get_lang('LastVersion').')', true);
3728
+            if (api_is_allowed_to_session_edit(false, true)) {
3729
+                $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;'));
3730 3730
             }
3731 3731
             $table->display();
3732 3732
         }
@@ -3746,13 +3746,13 @@  discard block
 block discarded – undo
3746 3746
         $groupfilter = $this->groupfilter;
3747 3747
         $tbl_wiki_conf = $this->tbl_wiki_conf;
3748 3748
 
3749
-        if (api_is_allowed_to_session_edit(false,true) ) {
3750
-            if (self::check_notify_all()==1) {
3751
-                $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3752
-                $lock_unlock_notify_all='unlocknotifyall';
3749
+        if (api_is_allowed_to_session_edit(false, true)) {
3750
+            if (self::check_notify_all() == 1) {
3751
+                $notify_all = Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
3752
+                $lock_unlock_notify_all = 'unlocknotifyall';
3753 3753
             } else {
3754
-                $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3755
-                $lock_unlock_notify_all='locknotifyall';
3754
+                $notify_all = Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'), '', ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
3755
+                $lock_unlock_notify_all = 'locknotifyall';
3756 3756
             }
3757 3757
         }
3758 3758
 
@@ -3760,7 +3760,7 @@  discard block
 block discarded – undo
3760 3760
         echo '<a href="index.php?action=recentchanges&amp;actionpage='.$lock_unlock_notify_all.'&amp;title='.api_htmlentities(urlencode($page)).'">'.$notify_all.'</a>';
3761 3761
         echo '</span>'.get_lang('RecentChanges').'</div>';
3762 3762
 
3763
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
3763
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
3764 3764
             $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
3765 3765
         		WHERE 	'.$tbl_wiki_conf.'.c_id= '.$course_id.' AND
3766 3766
         				'.$tbl_wiki.'.c_id= '.$course_id.' AND
@@ -3788,19 +3788,19 @@  discard block
 block discarded – undo
3788 3788
                 $userinfo = api_get_user_info($obj->user_id);
3789 3789
 
3790 3790
                 //get type assignment icon
3791
-                if ($obj->assignment==1) {
3792
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3793
-                } elseif ($obj->assignment==2) {
3794
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3795
-                } elseif ($obj->assignment==0) {
3796
-                    $ShowAssignment=Display::return_icon('px_transparent.gif');
3791
+                if ($obj->assignment == 1) {
3792
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3793
+                } elseif ($obj->assignment == 2) {
3794
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3795
+                } elseif ($obj->assignment == 0) {
3796
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
3797 3797
                 }
3798 3798
 
3799 3799
                 // Get icon task
3800 3800
                 if (!empty($obj->task)) {
3801
-                    $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
3801
+                    $icon_task = Display::return_icon('wiki_task.png', get_lang('StandardTask'), '', ICON_SIZE_SMALL);
3802 3802
                 } else {
3803
-                    $icon_task=Display::return_icon('px_transparent.gif');
3803
+                    $icon_task = Display::return_icon('px_transparent.gif');
3804 3804
                 }
3805 3805
 
3806 3806
                 $row = array();
@@ -3808,8 +3808,8 @@  discard block
 block discarded – undo
3808 3808
                 $row[] = $ShowAssignment.$icon_task;
3809 3809
                 $row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&amp;view='.$obj->id.'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'">'.
3810 3810
                     api_htmlentities($obj->title).'</a>';
3811
-                $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
3812
-                if ($obj->user_id <> 0 ) {
3811
+                $row[] = $obj->version > 1 ? get_lang('EditedBy') : get_lang('AddedBy');
3812
+                if ($obj->user_id <> 0) {
3813 3813
                     $row[] = UserManager::getUserProfileLink($userinfo);
3814 3814
                 } else {
3815 3815
                     $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
                 $rows[] = $row;
3818 3818
             }
3819 3819
 
3820
-            $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
3820
+            $table = new SortableTableFromArrayConfig($rows, 0, 10, 'RecentPages_table', '', '', 'DESC');
3821 3821
             $table->set_additional_parameters(
3822 3822
                 array(
3823 3823
                     'cidReq' =>api_get_course_id(),
@@ -3826,11 +3826,11 @@  discard block
 block discarded – undo
3826 3826
                     'group_id' => api_get_group_id()
3827 3827
                 )
3828 3828
             );
3829
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
3830
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
3831
-            $table->set_header(2,get_lang('Title'), true);
3832
-            $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
3833
-            $table->set_header(4,get_lang('Author'), true);
3829
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
3830
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
3831
+            $table->set_header(2, get_lang('Title'), true);
3832
+            $table->set_header(3, get_lang('Actions'), true, array('style' => 'width:80px;'));
3833
+            $table->set_header(4, get_lang('Author'), true);
3834 3834
             $table->display();
3835 3835
         }
3836 3836
     }
@@ -3862,17 +3862,17 @@  discard block
 block discarded – undo
3862 3862
 
3863 3863
             //get type assignment icon
3864 3864
             $ShowAssignment = '';
3865
-            if ($row['assignment']==1) {
3866
-                $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3867
-            } elseif ($row['assignment']==2) {
3868
-                $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3869
-            } elseif ($row['assignment']==0) {
3870
-                $ShowAssignment=Display::return_icon('px_transparent.gif');
3865
+            if ($row['assignment'] == 1) {
3866
+                $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3867
+            } elseif ($row['assignment'] == 2) {
3868
+                $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3869
+            } elseif ($row['assignment'] == 0) {
3870
+                $ShowAssignment = Display::return_icon('px_transparent.gif');
3871 3871
             }
3872 3872
 
3873 3873
             //fix Title to reflink (link Main Page)
3874
-            if ($page==get_lang('DefaultTitle')) {
3875
-                $page='index';
3874
+            if ($page == get_lang('DefaultTitle')) {
3875
+                $page = 'index';
3876 3876
             }
3877 3877
 
3878 3878
             echo '<div id="wikititle">';
@@ -3883,11 +3883,11 @@  discard block
 block discarded – undo
3883 3883
             //fix index to title Main page into linksto
3884 3884
 
3885 3885
             if ($page == 'index') {
3886
-                $page = str_replace(' ','_',get_lang('DefaultTitle'));
3886
+                $page = str_replace(' ', '_', get_lang('DefaultTitle'));
3887 3887
             }
3888 3888
 
3889 3889
             //table
3890
-            if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
3890
+            if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
3891 3891
                 //only by professors if page is hidden
3892 3892
                 $sql = "SELECT * FROM ".$tbl_wiki." s1
3893 3893
                         WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)."%' AND id=(
@@ -3914,25 +3914,25 @@  discard block
 block discarded – undo
3914 3914
                     //get time
3915 3915
                     $year 	 = substr($obj->dtime, 0, 4);
3916 3916
                     $month	 = substr($obj->dtime, 5, 2);
3917
-                    $day 	 = substr($obj->dtime, 8, 2);
3918
-                    $hours   = substr($obj->dtime, 11,2);
3919
-                    $minutes = substr($obj->dtime, 14,2);
3920
-                    $seconds = substr($obj->dtime, 17,2);
3917
+                    $day = substr($obj->dtime, 8, 2);
3918
+                    $hours   = substr($obj->dtime, 11, 2);
3919
+                    $minutes = substr($obj->dtime, 14, 2);
3920
+                    $seconds = substr($obj->dtime, 17, 2);
3921 3921
 
3922 3922
                     //get type assignment icon
3923
-                    if ($obj->assignment==1) {
3924
-                        $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
3925
-                    } elseif ($obj->assignment==2) {
3926
-                        $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
3927
-                    } elseif ($obj->assignment==0) {
3928
-                        $ShowAssignment=Display::return_icon('px_transparent.gif');
3923
+                    if ($obj->assignment == 1) {
3924
+                        $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
3925
+                    } elseif ($obj->assignment == 2) {
3926
+                        $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
3927
+                    } elseif ($obj->assignment == 0) {
3928
+                        $ShowAssignment = Display::return_icon('px_transparent.gif');
3929 3929
                     }
3930 3930
 
3931 3931
                     $row = array();
3932
-                    $row[] =$ShowAssignment;
3932
+                    $row[] = $ShowAssignment;
3933 3933
                     $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
3934 3934
                         api_htmlentities($obj->title).'</a>';
3935
-                    if ($obj->user_id <>0) {
3935
+                    if ($obj->user_id <> 0) {
3936 3936
                         $row[] = UserManager::getUserProfileLink($userinfo);
3937 3937
                     }
3938 3938
                     else {
@@ -4041,7 +4041,7 @@  discard block
 block discarded – undo
4041 4041
             '&session_id='.$this->session_id.'&group_id='.$this->group_id.'">
4042 4042
             </a></div>';
4043 4043
 
4044
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4044
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4045 4045
             //only by professors if page is hidden
4046 4046
             $sql = 'SELECT * FROM '.$tbl_wiki.'
4047 4047
                     WHERE
@@ -4066,19 +4066,19 @@  discard block
 block discarded – undo
4066 4066
                 // Get time
4067 4067
                 $year 	 = substr($obj->dtime, 0, 4);
4068 4068
                 $month	 = substr($obj->dtime, 5, 2);
4069
-                $day 	 = substr($obj->dtime, 8, 2);
4070
-                $hours   = substr($obj->dtime, 11,2);
4071
-                $minutes = substr($obj->dtime, 14,2);
4072
-                $seconds = substr($obj->dtime, 17,2);
4069
+                $day = substr($obj->dtime, 8, 2);
4070
+                $hours   = substr($obj->dtime, 11, 2);
4071
+                $minutes = substr($obj->dtime, 14, 2);
4072
+                $seconds = substr($obj->dtime, 17, 2);
4073 4073
 
4074 4074
                 //get type assignment icon
4075 4075
                 $ShowAssignment = '';
4076
-                if ($obj->assignment==1) {
4077
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4078
-                } elseif ($obj->assignment==2) {
4079
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4080
-                } elseif ($obj->assignment==0) {
4081
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4076
+                if ($obj->assignment == 1) {
4077
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4078
+                } elseif ($obj->assignment == 2) {
4079
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4080
+                } elseif ($obj->assignment == 0) {
4081
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4082 4082
                 }
4083 4083
 
4084 4084
                 $row = array();
@@ -4094,7 +4094,7 @@  discard block
 block discarded – undo
4094 4094
 
4095 4095
             }
4096 4096
 
4097
-            $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
4097
+            $table = new SortableTableFromArrayConfig($rows, 2, 10, 'UsersContributions_table', '', '', 'ASC');
4098 4098
             $table->set_additional_parameters(
4099 4099
                 array(
4100 4100
                     'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4104,13 +4104,13 @@  discard block
 block discarded – undo
4104 4104
                     'group_id' => intval($_GET['group_id']),
4105 4105
                 )
4106 4106
             );
4107
-            $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
4108
-            $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
4109
-            $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
4110
-            $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
4111
-            $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
4112
-            $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
4113
-            $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
4107
+            $table->set_header(0, get_lang('Date'), true, array('style' => 'width:200px;'));
4108
+            $table->set_header(1, get_lang('Type'), true, array('style' => 'width:30px;'));
4109
+            $table->set_header(2, get_lang('Title'), true, array('style' => 'width:200px;'));
4110
+            $table->set_header(3, get_lang('Version'), true, array('style' => 'width:30px;'));
4111
+            $table->set_header(4, get_lang('Comment'), true, array('style' => 'width:200px;'));
4112
+            $table->set_header(5, get_lang('Progress'), true, array('style' => 'width:30px;'));
4113
+            $table->set_header(6, get_lang('Rating'), true, array('style' => 'width:30px;'));
4114 4114
             $table->display();
4115 4115
         }
4116 4116
     }
@@ -4128,7 +4128,7 @@  discard block
 block discarded – undo
4128 4128
 
4129 4129
         echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
4130 4130
 
4131
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4131
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4132 4132
             $sql = 'SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.'
4133 4133
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4134 4134
                     GROUP BY reflink';//TODO:check MAX and group by return last version
@@ -4146,12 +4146,12 @@  discard block
 block discarded – undo
4146 4146
             while ($obj = Database::fetch_object($allpages)) {
4147 4147
                 //get type assignment icon
4148 4148
                 $ShowAssignment = '';
4149
-                if ($obj->assignment==1) {
4150
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4151
-                } elseif ($obj->assignment==2) {
4152
-                    $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4153
-                } elseif ($obj->assignment==0) {
4154
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4149
+                if ($obj->assignment == 1) {
4150
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4151
+                } elseif ($obj->assignment == 2) {
4152
+                    $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4153
+                } elseif ($obj->assignment == 0) {
4154
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4155 4155
                 }
4156 4156
 
4157 4157
                 $row = array();
@@ -4179,9 +4179,9 @@  discard block
 block discarded – undo
4179 4179
                     'group_id' => intval($_GET['group_id']),
4180 4180
                 )
4181 4181
             );
4182
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4183
-            $table->set_header(1,get_lang('Title'), true);
4184
-            $table->set_header(2,get_lang('Changes'), true);
4182
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4183
+            $table->set_header(1, get_lang('Title'), true);
4184
+            $table->set_header(2, get_lang('Changes'), true);
4185 4185
             $table->display();
4186 4186
         }
4187 4187
     }
@@ -4206,7 +4206,7 @@  discard block
 block discarded – undo
4206 4206
         /* Only teachers and platform admin can edit the index page.
4207 4207
         Only teachers and platform admin can edit an assignment teacher*/
4208 4208
         if (($current_row['reflink'] == 'index' || $current_row['reflink'] == '' || $current_row['assignment'] == 1) &&
4209
-            (!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
4209
+            (!api_is_allowed_to_edit(false, true) && $this->group_id == 0)
4210 4210
         ) {
4211 4211
             self::setMessage(
4212 4212
                 Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true)
@@ -4216,7 +4216,7 @@  discard block
 block discarded – undo
4216 4216
             // check if is a wiki group
4217 4217
             if ($current_row['group_id'] != 0) {
4218 4218
                 //Only teacher, platform admin and group members can edit a wiki group
4219
-                if (api_is_allowed_to_edit(false,true) ||
4219
+                if (api_is_allowed_to_edit(false, true) ||
4220 4220
                     api_is_platform_admin() ||
4221 4221
                     GroupManager :: is_user_in_group($userId, $this->group_id)
4222 4222
                 ) {
@@ -4234,9 +4234,9 @@  discard block
 block discarded – undo
4234 4234
             //$icon_assignment = null;
4235 4235
             if ($current_row['assignment'] == 1) {
4236 4236
                 self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
4237
-            } elseif($current_row['assignment']==2) {
4238
-                if (($userId == $current_row['user_id'])==false) {
4239
-                    if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4237
+            } elseif ($current_row['assignment'] == 2) {
4238
+                if (($userId == $current_row['user_id']) == false) {
4239
+                    if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4240 4240
                         $PassEdit = true;
4241 4241
                     } else {
4242 4242
                         self::setMessage(Display::display_warning_message(get_lang('LockByTeacher'), false, true));
@@ -4250,11 +4250,11 @@  discard block
 block discarded – undo
4250 4250
             //show editor if edit is allowed
4251 4251
             if ($PassEdit) {
4252 4252
                 if ($current_row['editlock'] == 1 &&
4253
-                    (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)
4253
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4254 4254
                 ) {
4255 4255
                     self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
4256 4256
                 } else {
4257
-                    if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
4257
+                    if ($last_row['is_editing'] != 0 && $last_row['is_editing'] != $userId) {
4258 4258
                         // Checking for concurrent users
4259 4259
                         $timestamp_edit = strtotime($last_row['time_edit']);
4260 4260
                         $time_editing = time() - $timestamp_edit;
@@ -4263,7 +4263,7 @@  discard block
 block discarded – undo
4263 4263
                         $userinfo = api_get_user_info($last_row['is_editing']);
4264 4264
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' <a href='.$userinfo['profile_url'].'>'.
4265 4265
                             Display::tag('span', $userinfo['complete_name_with_username']).
4266
-                            get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes');
4266
+                            get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes');
4267 4267
                         self::setMessage(Display::display_normal_message($is_being_edited, false, true));
4268 4268
                     } else {
4269 4269
                         self::setMessage(Display::display_confirmation_message(
@@ -4371,9 +4371,9 @@  discard block
 block discarded – undo
4371 4371
                 GROUP BY reflink
4372 4372
                 ORDER BY reflink ASC';
4373 4373
         $allpages = Database::query($sql);
4374
-        while ($row=Database::fetch_array($allpages)) {
4375
-            if ($row['reflink']=='index') {
4376
-                $row['reflink']=str_replace(' ', '_', get_lang('DefaultTitle'));
4374
+        while ($row = Database::fetch_array($allpages)) {
4375
+            if ($row['reflink'] == 'index') {
4376
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4377 4377
             }
4378 4378
             $pages[] = $row['reflink'];
4379 4379
         }
@@ -4391,16 +4391,16 @@  discard block
 block discarded – undo
4391 4391
 
4392 4392
         $allpages = Database::query($sql);
4393 4393
 
4394
-        while ($row=Database::fetch_array($allpages)) {
4394
+        while ($row = Database::fetch_array($allpages)) {
4395 4395
             //remove self reference
4396
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
4396
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"]));
4397 4397
             $refs = explode(" ", trim($row["linksto"]));
4398 4398
 
4399 4399
             // Find linksto into reflink. If found ->page is linked
4400 4400
             foreach ($refs as $v) {
4401 4401
                 if (in_array($v, $pages)) {
4402
-                    if (trim($v)!="") {
4403
-                        $linked[]=$v;
4402
+                    if (trim($v) != "") {
4403
+                        $linked[] = $v;
4404 4404
                     }
4405 4405
                 }
4406 4406
             }
@@ -4412,12 +4412,12 @@  discard block
 block discarded – undo
4412 4412
         $rows = array();
4413 4413
         foreach ($linked as $linked_show) {
4414 4414
             $row = array();
4415
-            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_',' ',$linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
4416
-                str_replace('_',' ',$linked_show).'</a>';
4415
+            $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_', ' ', $linked_show))).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
4416
+                str_replace('_', ' ', $linked_show).'</a>';
4417 4417
             $rows[] = $row;
4418 4418
         }
4419 4419
 
4420
-        $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
4420
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'LinkedPages_table', '', '', 'DESC');
4421 4421
         $table->set_additional_parameters(
4422 4422
             array(
4423 4423
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4426,7 +4426,7 @@  discard block
 block discarded – undo
4426 4426
                 'group_id' => intval($_GET['group_id']),
4427 4427
             )
4428 4428
         );
4429
-        $table->set_header(0,get_lang('Title'), true);
4429
+        $table->set_header(0, get_lang('Title'), true);
4430 4430
         $table->display();
4431 4431
     }
4432 4432
 
@@ -4451,8 +4451,8 @@  discard block
 block discarded – undo
4451 4451
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4452 4452
                 GROUP BY reflink
4453 4453
                 ORDER BY reflink ASC';
4454
-        $allpages=Database::query($sql);
4455
-        while ($row=Database::fetch_array($allpages)) {
4454
+        $allpages = Database::query($sql);
4455
+        while ($row = Database::fetch_array($allpages)) {
4456 4456
             $pages[] = $row['reflink'];
4457 4457
         }
4458 4458
 
@@ -4467,14 +4467,14 @@  discard block
 block discarded – undo
4467 4467
                 )';
4468 4468
         $allpages = Database::query($sql);
4469 4469
         $array_refs_linked = array();
4470
-        while ($row=Database::fetch_array($allpages)) {
4471
-            $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4470
+        while ($row = Database::fetch_array($allpages)) {
4471
+            $row['linksto'] = str_replace($row["reflink"], " ", trim($row["linksto"])); //remove self reference
4472 4472
             $refs = explode(" ", trim($row["linksto"]));
4473
-            foreach ($refs as $ref_linked){
4474
-                if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
4475
-                    $ref_linked='index';
4473
+            foreach ($refs as $ref_linked) {
4474
+                if ($ref_linked == str_replace(' ', '_', get_lang('DefaultTitle'))) {
4475
+                    $ref_linked = 'index';
4476 4476
                 }
4477
-                $array_refs_linked[]= $ref_linked;
4477
+                $array_refs_linked[] = $ref_linked;
4478 4478
             }
4479 4479
         }
4480 4480
 
@@ -4496,20 +4496,20 @@  discard block
 block discarded – undo
4496 4496
 		                '.$groupfilter.$condition_session.' AND
4497 4497
 		                reflink="'.Database::escape_string($orphaned_show).'"
4498 4498
                     GROUP BY reflink';
4499
-            $allpages=Database::query($sql);
4500
-            while ($row=Database::fetch_array($allpages)) {
4501
-                $orphaned_title=$row['title'];
4502
-                $orphaned_visibility=$row['visibility'];
4503
-                if ($row['assignment']==1) {
4504
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
4505
-                } elseif ($row['assignment']==2) {
4506
-                    $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
4507
-                } elseif ($row['assignment']==0) {
4508
-                    $ShowAssignment= Display::return_icon('px_transparent.gif');
4499
+            $allpages = Database::query($sql);
4500
+            while ($row = Database::fetch_array($allpages)) {
4501
+                $orphaned_title = $row['title'];
4502
+                $orphaned_visibility = $row['visibility'];
4503
+                if ($row['assignment'] == 1) {
4504
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', '', '', ICON_SIZE_SMALL);
4505
+                } elseif ($row['assignment'] == 2) {
4506
+                    $ShowAssignment = Display::return_icon('wiki_work.png', '', '', ICON_SIZE_SMALL);
4507
+                } elseif ($row['assignment'] == 0) {
4508
+                    $ShowAssignment = Display::return_icon('px_transparent.gif');
4509 4509
                 }
4510 4510
             }
4511 4511
 
4512
-            if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() && $orphaned_visibility==0){
4512
+            if (!api_is_allowed_to_edit(false, true) || !api_is_platform_admin() && $orphaned_visibility == 0) {
4513 4513
                 continue;
4514 4514
             }
4515 4515
 
@@ -4521,7 +4521,7 @@  discard block
 block discarded – undo
4521 4521
             $rows[] = $row;
4522 4522
         }
4523 4523
 
4524
-        $table = new SortableTableFromArrayConfig($rows,1, 10, 'OrphanedPages_table','','','DESC');
4524
+        $table = new SortableTableFromArrayConfig($rows, 1, 10, 'OrphanedPages_table', '', '', 'DESC');
4525 4525
         $table->set_additional_parameters(
4526 4526
             array(
4527 4527
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4530,8 +4530,8 @@  discard block
 block discarded – undo
4530 4530
                 'group_id' => intval($_GET['group_id']),
4531 4531
             )
4532 4532
         );
4533
-        $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4534
-        $table->set_header(1,get_lang('Title'), true);
4533
+        $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4534
+        $table->set_header(1, get_lang('Title'), true);
4535 4535
         $table->display();
4536 4536
     }
4537 4537
 
@@ -4553,11 +4553,11 @@  discard block
 block discarded – undo
4553 4553
                 WHERE  c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4554 4554
                 GROUP BY reflink
4555 4555
                 ORDER BY reflink ASC';
4556
-        $allpages=Database::query($sql);
4556
+        $allpages = Database::query($sql);
4557 4557
 
4558
-        while ($row=Database::fetch_array($allpages)) {
4559
-            if ($row['reflink']=='index'){
4560
-                $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
4558
+        while ($row = Database::fetch_array($allpages)) {
4559
+            if ($row['reflink'] == 'index') {
4560
+                $row['reflink'] = str_replace(' ', '_', get_lang('DefaultTitle'));
4561 4561
             }
4562 4562
             $pages[] = $row['reflink'];
4563 4563
         }
@@ -4571,31 +4571,31 @@  discard block
 block discarded – undo
4571 4571
 
4572 4572
         $allpages = Database::query($sql);
4573 4573
 
4574
-        while ($row=Database::fetch_array($allpages)) {
4574
+        while ($row = Database::fetch_array($allpages)) {
4575 4575
             $refs = explode(" ", trim($row["linksto"]));
4576 4576
             // Find linksto into reflink. If not found ->page is wanted
4577 4577
             foreach ($refs as $v) {
4578 4578
 
4579 4579
                 if (!in_array($v, $pages)) {
4580
-                    if (trim($v)!="") {
4581
-                        $wanted[]=$v;
4580
+                    if (trim($v) != "") {
4581
+                        $wanted[] = $v;
4582 4582
                     }
4583 4583
                 }
4584 4584
             }
4585 4585
         }
4586 4586
 
4587
-        $wanted = array_unique($wanted);//make a unique list
4587
+        $wanted = array_unique($wanted); //make a unique list
4588 4588
 
4589 4589
         //show table
4590 4590
         $rows = array();
4591 4591
         foreach ($wanted as $wanted_show) {
4592 4592
             $row = array();
4593 4593
             $wanted_show = Security::remove_XSS($wanted_show);
4594
-            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';//meter un remove xss en lugar de htmlentities
4594
+            $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_', ' ', $wanted_show).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_', ' ', $wanted_show).'</a>'; //meter un remove xss en lugar de htmlentities
4595 4595
             $rows[] = $row;
4596 4596
         }
4597 4597
 
4598
-        $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC');
4598
+        $table = new SortableTableFromArrayConfig($rows, 0, 10, 'WantedPages_table', '', '', 'DESC');
4599 4599
         $table->set_additional_parameters(
4600 4600
             array(
4601 4601
                 'cidReq' => Security::remove_XSS($_GET['cidReq']),
@@ -4604,7 +4604,7 @@  discard block
 block discarded – undo
4604 4604
                 'group_id' => intval($_GET['group_id']),
4605 4605
             )
4606 4606
         );
4607
-        $table->set_header(0,get_lang('Title'), true);
4607
+        $table->set_header(0, get_lang('Title'), true);
4608 4608
         $table->display();
4609 4609
     }
4610 4610
 
@@ -4621,7 +4621,7 @@  discard block
 block discarded – undo
4621 4621
 
4622 4622
         echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
4623 4623
 
4624
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
4624
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden
4625 4625
             $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
4626 4626
                     WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
4627 4627
                     GROUP BY reflink';
@@ -4642,11 +4642,11 @@  discard block
 block discarded – undo
4642 4642
             while ($obj = Database::fetch_object($allpages)) {
4643 4643
                 //get type assignment icon
4644 4644
                 $ShowAssignment = '';
4645
-                if ($obj->assignment==1) {
4646
-                    $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
4647
-                } elseif ($obj->assignment==2) {
4648
-                    $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
4649
-                } elseif ($obj->assignment==0) {
4645
+                if ($obj->assignment == 1) {
4646
+                    $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL);
4647
+                } elseif ($obj->assignment == 2) {
4648
+                    $ShowAssignment = $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL);
4649
+                } elseif ($obj->assignment == 0) {
4650 4650
                     $ShowAssignment = Display::return_icon('px_transparent.gif');
4651 4651
                 }
4652 4652
 
@@ -4675,7 +4675,7 @@  discard block
 block discarded – undo
4675 4675
                     'group_id' => intval($_GET['group_id']),
4676 4676
                 )
4677 4677
             );
4678
-            $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
4678
+            $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;'));
4679 4679
             $table->set_header(1, get_lang('Title'), true);
4680 4680
             $table->set_header(2, get_lang('Visits'), true);
4681 4681
             $table->display();
@@ -4700,8 +4700,8 @@  discard block
 block discarded – undo
4700 4700
 
4701 4701
         if (api_is_allowed_to_session_edit(false, true) && api_is_allowed_to_edit()) {
4702 4702
             // menu add page
4703
-            $actionsLeft .= '<a href="index.php?cidReq=' . $_course['id'] . '&action=addnew&session_id=' . $session_id . '&group_id=' . $groupId . '"' . self::is_active_navigation_tab('addnew').'>'
4704
-            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM) . '</a>';
4703
+            $actionsLeft .= '<a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$groupId.'"'.self::is_active_navigation_tab('addnew').'>'
4704
+            . Display::return_icon('add.png', get_lang('AddNew'), '', ICON_SIZE_MEDIUM).'</a>';
4705 4705
         }
4706 4706
 
4707 4707
         $lock_unlock_addnew = null;
@@ -4709,12 +4709,12 @@  discard block
 block discarded – undo
4709 4709
 
4710 4710
         if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4711 4711
             // page action: enable or disable the adding of new pages
4712
-            if (self::check_addnewpagelock()==0) {
4712
+            if (self::check_addnewpagelock() == 0) {
4713 4713
                 $protect_addnewpage = Display::return_icon('off.png', get_lang('AddOptionProtected'));
4714
-                $lock_unlock_addnew ='unlockaddnew';
4714
+                $lock_unlock_addnew = 'unlockaddnew';
4715 4715
             } else {
4716 4716
                 $protect_addnewpage = Display::return_icon('on.png', get_lang('AddOptionUnprotected'));
4717
-                $lock_unlock_addnew ='lockaddnew';
4717
+                $lock_unlock_addnew = 'lockaddnew';
4718 4718
             }
4719 4719
         }
4720 4720
 
@@ -4734,7 +4734,7 @@  discard block
 block discarded – undo
4734 4734
             get_lang('RecentChanges').'</a>';
4735 4735
 
4736 4736
 
4737
-        echo Display::toolbarAction('toolbar-wiki', array( 0 => $actionsLeft));
4737
+        echo Display::toolbarAction('toolbar-wiki', array(0 => $actionsLeft));
4738 4738
     }
4739 4739
 
4740 4740
     /**
@@ -4752,7 +4752,7 @@  discard block
 block discarded – undo
4752 4752
             return;
4753 4753
         }
4754 4754
 
4755
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
4755
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4756 4756
             self::setMessage('<div id="wikititle">'.get_lang('DeletePageHistory').'</div>');
4757 4757
 
4758 4758
             if ($page == "index") {
@@ -4794,7 +4794,7 @@  discard block
 block discarded – undo
4794 4794
         $userId = api_get_user_id();
4795 4795
 
4796 4796
         if (api_get_session_id() != 0 &&
4797
-            api_is_allowed_to_session_edit(false,true) == false
4797
+            api_is_allowed_to_session_edit(false, true) == false
4798 4798
         ) {
4799 4799
             api_not_allowed();
4800 4800
         }
@@ -4817,12 +4817,12 @@  discard block
 block discarded – undo
4817 4817
                 Display::display_error_message(get_lang('MustSelectPage'), false, true)
4818 4818
             );
4819 4819
             return;
4820
-        } elseif ($row['content']=='' && $row['title']=='' && $page=='index') {
4820
+        } elseif ($row['content'] == '' && $row['title'] == '' && $page == 'index') {
4821 4821
 
4822 4822
             // Table structure for better export to pdf
4823 4823
             $default_table_for_content_Start = '<table align="center" border="0"><tr><td align="center">';
4824 4824
             $default_table_for_content_End = '</td></tr></table>';
4825
-            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4825
+            $content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'), api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
4826 4826
             $title = get_lang('DefaultTitle');
4827 4827
             $page_id = 0;
4828 4828
         } else {
@@ -4847,7 +4847,7 @@  discard block
 block discarded – undo
4847 4847
             // Check if is a wiki group
4848 4848
             if (!empty($groupId)) {
4849 4849
                 //Only teacher, platform admin and group members can edit a wiki group
4850
-                if (api_is_allowed_to_edit(false,true) ||
4850
+                if (api_is_allowed_to_edit(false, true) ||
4851 4851
                     api_is_platform_admin() ||
4852 4852
                     GroupManager :: is_user_in_group($userId, $groupId)
4853 4853
                 ) {
@@ -4860,7 +4860,7 @@  discard block
 block discarded – undo
4860 4860
                     );
4861 4861
                 }
4862 4862
             } else {
4863
-                $PassEdit=true;
4863
+                $PassEdit = true;
4864 4864
             }
4865 4865
 
4866 4866
             $icon_assignment = null;
@@ -4870,10 +4870,10 @@  discard block
 block discarded – undo
4870 4870
                     Display::return_message(get_lang('EditAssignmentWarning'))
4871 4871
                 );
4872 4872
 
4873
-                $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
4873
+                $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
4874 4874
             } elseif ($row['assignment'] == 2) {
4875
-                $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
4876
-                if (($userId == $row['user_id'])==false) {
4875
+                $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
4876
+                if (($userId == $row['user_id']) == false) {
4877 4877
                     if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
4878 4878
                         $PassEdit = true;
4879 4879
                     } else {
@@ -4893,7 +4893,7 @@  discard block
 block discarded – undo
4893 4893
             if ($PassEdit) {
4894 4894
                 //show editor if edit is allowed
4895 4895
                 if ($row['editlock'] == 1 &&
4896
-                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin()==false)
4896
+                    (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)
4897 4897
                 ) {
4898 4898
                     Display::addFlash(
4899 4899
                         Display::return_message(
@@ -4904,8 +4904,8 @@  discard block
 block discarded – undo
4904 4904
                     // Check tasks
4905 4905
 
4906 4906
                     if (!empty($row['startdate_assig']) &&
4907
-                        $row['startdate_assig']!='0000-00-00 00:00:00' &&
4908
-                        time()<strtotime($row['startdate_assig'])
4907
+                        $row['startdate_assig'] != '0000-00-00 00:00:00' &&
4908
+                        time() < strtotime($row['startdate_assig'])
4909 4909
                     ) {
4910 4910
                         $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
4911 4911
 
@@ -4922,10 +4922,10 @@  discard block
 block discarded – undo
4922 4922
                     }
4923 4923
 
4924 4924
                     if (!empty($row['enddate_assig']) &&
4925
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
4925
+                        $row['enddate_assig'] != '0000-00-00 00:00:00' &&
4926 4926
                         time() > strtotime($row['enddate_assig']) &&
4927
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
4928
-                        $row['delayedsubmit']==0
4927
+                        $row['enddate_assig'] != '0000-00-00 00:00:00' &&
4928
+                        $row['delayedsubmit'] == 0
4929 4929
                     ) {
4930 4930
                         $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
4931 4931
                         Display::addFlash(
@@ -4934,20 +4934,20 @@  discard block
 block discarded – undo
4934 4934
                                 'warning'
4935 4935
                             )
4936 4936
                         );
4937
-                        if (!api_is_allowed_to_edit(false,true)) {
4937
+                        if (!api_is_allowed_to_edit(false, true)) {
4938 4938
                             $this->redirectHome();
4939 4939
                         }
4940 4940
                     }
4941 4941
 
4942
-                    if (!empty($row['max_version']) && $row['version']>=$row['max_version']) {
4943
-                        $message=get_lang('HasReachedMaxiNumVersions');
4942
+                    if (!empty($row['max_version']) && $row['version'] >= $row['max_version']) {
4943
+                        $message = get_lang('HasReachedMaxiNumVersions');
4944 4944
                         Display::addFlash(
4945 4945
                             Display::return_message(
4946 4946
                                 $message,
4947 4947
                                 'warning'
4948 4948
                             )
4949 4949
                         );
4950
-                        if (!api_is_allowed_to_edit(false,true)) {
4950
+                        if (!api_is_allowed_to_edit(false, true)) {
4951 4951
                             $this->redirectHome();
4952 4952
                         }
4953 4953
                     }
@@ -4960,50 +4960,50 @@  discard block
 block discarded – undo
4960 4960
                                 'warning'
4961 4961
                             )
4962 4962
                         );
4963
-                        if (!api_is_allowed_to_edit(false,true)) {
4963
+                        if (!api_is_allowed_to_edit(false, true)) {
4964 4964
                             $this->redirectHome();
4965 4965
                         }
4966 4966
                     }
4967 4967
 
4968 4968
                     if (!empty($row['task'])) {
4969 4969
                         //previous change 0 by text
4970
-                        if ($row['startdate_assig']=='0000-00-00 00:00:00') {
4971
-                            $message_task_startdate  =get_lang('No');
4970
+                        if ($row['startdate_assig'] == '0000-00-00 00:00:00') {
4971
+                            $message_task_startdate = get_lang('No');
4972 4972
                         } else {
4973 4973
                             $message_task_startdate = api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
4974 4974
                         }
4975 4975
 
4976
-                        if ($row['enddate_assig']=='0000-00-00 00:00:00') {
4976
+                        if ($row['enddate_assig'] == '0000-00-00 00:00:00') {
4977 4977
                             $message_task_enddate = get_lang('No');
4978 4978
                         } else {
4979 4979
                             $message_task_enddate = api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
4980 4980
                         }
4981 4981
 
4982
-                        if ($row['delayedsubmit']==0) {
4983
-                            $message_task_delayedsubmit=get_lang('No');
4982
+                        if ($row['delayedsubmit'] == 0) {
4983
+                            $message_task_delayedsubmit = get_lang('No');
4984 4984
                         } else {
4985
-                            $message_task_delayedsubmit=get_lang('Yes');
4985
+                            $message_task_delayedsubmit = get_lang('Yes');
4986 4986
                         }
4987 4987
 
4988
-                        if ($row['max_version']==0) {
4989
-                            $message_task_max_version=get_lang('No');
4988
+                        if ($row['max_version'] == 0) {
4989
+                            $message_task_max_version = get_lang('No');
4990 4990
                         } else {
4991
-                            $message_task_max_version=$row['max_version'];
4991
+                            $message_task_max_version = $row['max_version'];
4992 4992
                         }
4993 4993
 
4994
-                        if ($row['max_text']==0) {
4995
-                            $message_task_max_text=get_lang('No');
4994
+                        if ($row['max_text'] == 0) {
4995
+                            $message_task_max_text = get_lang('No');
4996 4996
                         } else {
4997
-                            $message_task_max_text=$row['max_text'];
4997
+                            $message_task_max_text = $row['max_text'];
4998 4998
                         }
4999 4999
 
5000 5000
                         // Comp message
5001
-                        $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5002
-                        $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5003
-                        $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
5004
-                        $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5005
-                        $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5006
-                        $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
5001
+                        $message_task = '<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
5002
+                        $message_task .= '<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
5003
+                        $message_task .= '<p>'.get_lang('EndDate').': '.$message_task_enddate;
5004
+                        $message_task .= ' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
5005
+                        $message_task .= '<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
5006
+                        $message_task .= ' '.get_lang('NMaxWords').': '.$message_task_max_text;
5007 5007
                         // Display message
5008 5008
                         Display::addFlash(
5009 5009
                             Display::return_message(
@@ -5014,11 +5014,11 @@  discard block
 block discarded – undo
5014 5014
 
5015 5015
                     $feedback_message = '';
5016 5016
                     if ($row['progress'] == $row['fprogress1'] && !empty($row['fprogress1'])) {
5017
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5017
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
5018 5018
                     } elseif ($row['progress'] == $row['fprogress2'] && !empty($row['fprogress2'])) {
5019
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5019
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
5020 5020
                     } elseif ($row['progress'] == $row['fprogress3'] && !empty($row['fprogress3'])) {
5021
-                        $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5021
+                        $feedback_message = '<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
5022 5022
                     }
5023 5023
 
5024 5024
                     if (!empty($feedback_message)) {
@@ -5043,14 +5043,14 @@  discard block
 block discarded – undo
5043 5043
                                 WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"';
5044 5044
                         Database::query($sql);
5045 5045
                     } elseif ($row['is_editing'] != $userId) {
5046
-                        $timestamp_edit=strtotime($row['time_edit']);
5046
+                        $timestamp_edit = strtotime($row['time_edit']);
5047 5047
                         $time_editing = time() - $timestamp_edit;
5048 5048
                         $max_edit_time = 1200; // 20 minutes
5049 5049
                         $rest_time = $max_edit_time - $time_editing;
5050 5050
 
5051 5051
                         $userinfo = api_get_user_info($row['is_editing']);
5052 5052
                         $is_being_edited = get_lang('ThisPageisBeginEditedBy').' '.UserManager::getUserProfileLink($userinfo).'
5053
-                            '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
5053
+                            '.get_lang('ThisPageisBeginEditedTryLater').' '.date("i", $rest_time).' '.get_lang('MinMinutes').'';
5054 5054
 
5055 5055
                         Display::addFlash(
5056 5056
                             Display::return_message(
@@ -5064,7 +5064,7 @@  discard block
 block discarded – undo
5064 5064
                     // Form.
5065 5065
                     $url = api_get_self().'?action=edit&title='.urlencode($page).'&session_id='.api_get_session_id().'&group_id='.api_get_group_id().'&'.api_get_cidreq();
5066 5066
                     $form = new FormValidator('wiki', 'post', $url);
5067
-                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;',3).api_htmlentities($title));
5067
+                    $form->addElement('header', $icon_assignment.str_repeat('&nbsp;', 3).api_htmlentities($title));
5068 5068
                     self::setForm($form, $row);
5069 5069
                     $form->addElement('hidden', 'title');
5070 5070
                     $form->addElement('button', 'SaveWikiChange', get_lang('Save'));
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
                             );
5088 5088
                         } elseif (!self::double_post($_POST['wpost_id'])) {
5089 5089
                             //double post
5090
-                        } elseif ($_POST['version']!='' && $_SESSION['_version'] !=0 && $_POST['version'] != $_SESSION['_version']) {
5090
+                        } elseif ($_POST['version'] != '' && $_SESSION['_version'] != 0 && $_POST['version'] != $_SESSION['_version']) {
5091 5091
                             //prevent concurrent users and double version
5092 5092
                             Display::addFlash(
5093 5093
                                 Display::return_message(
@@ -5149,7 +5149,7 @@  discard block
 block discarded – undo
5149 5149
         $KeyAssignment = null;
5150 5150
         $KeyTitle = null;
5151 5151
         $KeyUserId = null;
5152
-        while ($row=Database::fetch_array($result)) {
5152
+        while ($row = Database::fetch_array($result)) {
5153 5153
             $KeyVisibility = $row['visibility'];
5154 5154
             $KeyAssignment = $row['assignment'];
5155 5155
             $KeyTitle = $row['title'];
@@ -5158,7 +5158,7 @@  discard block
 block discarded – undo
5158 5158
         $icon_assignment = null;
5159 5159
         if ($KeyAssignment == 1) {
5160 5160
             $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL);
5161
-        } elseif($KeyAssignment == 2) {
5161
+        } elseif ($KeyAssignment == 2) {
5162 5162
             $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL);
5163 5163
         }
5164 5164
 
@@ -5166,10 +5166,10 @@  discard block
 block discarded – undo
5166 5166
 
5167 5167
         //if the page is hidden and is a job only sees its author and professor
5168 5168
         if ($KeyVisibility == 1 ||
5169
-            api_is_allowed_to_edit(false,true) ||
5169
+            api_is_allowed_to_edit(false, true) ||
5170 5170
             api_is_platform_admin() ||
5171 5171
             (
5172
-                $KeyAssignment==2 && $KeyVisibility==0 &&
5172
+                $KeyAssignment == 2 && $KeyVisibility == 0 &&
5173 5173
                 ($userId == $KeyUserId)
5174 5174
             )
5175 5175
         ) {
@@ -5199,7 +5199,7 @@  discard block
 block discarded – undo
5199 5199
                     get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
5200 5200
                 echo '<br/><br/>';
5201 5201
 
5202
-                $counter=0;
5202
+                $counter = 0;
5203 5203
                 $total_versions = Database::num_rows($result);
5204 5204
 
5205 5205
                 while ($row = Database::fetch_array($result)) {
@@ -5207,10 +5207,10 @@  discard block
 block discarded – undo
5207 5207
                     $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
5208 5208
 
5209 5209
                     echo '<li style="margin-bottom: 5px;">';
5210
-                    ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
5211
-                    ($counter==0) ? $newchecked=' checked': $newchecked='';
5212
-                    ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
5213
-                    ($counter==1) ? $oldchecked=' checked':$oldchecked='';
5210
+                    ($counter == 0) ? $oldstyle = 'style="visibility: hidden;"' : $oldstyle = '';
5211
+                    ($counter == 0) ? $newchecked = ' checked' : $newchecked = '';
5212
+                    ($counter == $total_versions - 1) ? $newstyle = 'style="visibility: hidden;"' : $newstyle = '';
5213
+                    ($counter == 1) ? $oldchecked = ' checked' : $oldchecked = '';
5214 5214
                     echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
5215 5215
                     echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
5216 5216
                     echo '<a href="'.api_get_self().'?action=showpage&amp;title='.api_htmlentities(urlencode($page)).'&amp;view='.$row['id'].'">';
@@ -5228,7 +5228,7 @@  discard block
 block discarded – undo
5228 5228
                     $comment = $row['comment'];
5229 5229
                     if (!empty($comment)) {
5230 5230
                         echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'], 0, 100));
5231
-                        if (api_strlen($row['comment'])>100) {
5231
+                        if (api_strlen($row['comment']) > 100) {
5232 5232
                             echo '... ';
5233 5233
                         }
5234 5234
                     } else {
@@ -5253,8 +5253,8 @@  discard block
 block discarded – undo
5253 5253
 
5254 5254
                 $sql_new = "SELECT * FROM $tbl_wiki
5255 5255
                             WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
5256
-                $result_new=Database::query($sql_new);
5257
-                $version_new=Database::fetch_array($result_new);
5256
+                $result_new = Database::query($sql_new);
5257
+                $version_new = Database::fetch_array($result_new);
5258 5258
                 $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null;
5259 5259
                 $oldContent = isset($version_old['content']) ? $version_old['content'] : null;
5260 5260
 
@@ -5281,9 +5281,9 @@  discard block
 block discarded – undo
5281 5281
 
5282 5282
 
5283 5283
                 if (isset($_POST['HistoryDifferences'])) {
5284
-                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line' ).'</table>'; // format_line mode is better for words
5284
+                    echo '<table>'.diff($oldContent, $version_new['content'], true, 'format_table_line').'</table>'; // format_line mode is better for words
5285 5285
                     echo '<br />';
5286
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5286
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5287 5287
                     echo '<table><tr>';
5288 5288
                     echo  '<td>';
5289 5289
                     echo '</td><td>';
@@ -5302,7 +5302,7 @@  discard block
 block discarded – undo
5302 5302
                     $renderer = new Text_Diff_Renderer_inline();
5303 5303
                     echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
5304 5304
                     echo '<br />';
5305
-                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
5305
+                    echo '<strong>'.get_lang('Legend').'</strong><div class="diff">'."\n";
5306 5306
                     echo '<table><tr>';
5307 5307
                     echo  '<td>';
5308 5308
                     echo '</td><td>';
@@ -5350,7 +5350,7 @@  discard block
 block discarded – undo
5350 5350
         echo '<td style="vertical-align:top">';
5351 5351
         echo '<ul>';
5352 5352
         // Submenu Statistics
5353
-        if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5353
+        if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5354 5354
             echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$groupId.'">'.get_lang('Statistics').'</a></li>';
5355 5355
         }
5356 5356
         echo '      </ul>';
@@ -5423,7 +5423,7 @@  discard block
 block discarded – undo
5423 5423
                 break;
5424 5424
             case 'deletewiki':
5425 5425
                 $title = '<div class="actions">'.get_lang('DeleteWiki').'</div>';
5426
-                if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
5426
+                if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) {
5427 5427
                     $message = get_lang('ConfirmDeleteWiki');
5428 5428
                     $message .= '<p>
5429 5429
                         <a href="index.php?'.api_get_cidreq().'">'.get_lang('No').'</a>
@@ -5454,14 +5454,14 @@  discard block
 block discarded – undo
5454 5454
                 self::getLinks($page);
5455 5455
                 break;
5456 5456
             case 'addnew':
5457
-                if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
5457
+                if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
5458 5458
                     api_not_allowed();
5459 5459
                 }
5460 5460
                 echo '<div class="actions">'.get_lang('AddNew').'</div>';
5461 5461
                 echo '<br/>';
5462 5462
                 //first, check if page index was created. chektitle=false
5463 5463
                 if (self::checktitle('index')) {
5464
-                    if (api_is_allowed_to_edit(false,true) ||
5464
+                    if (api_is_allowed_to_edit(false, true) ||
5465 5465
                         api_is_platform_admin() ||
5466 5466
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())
5467 5467
                     ) {
@@ -5469,10 +5469,10 @@  discard block
 block discarded – undo
5469 5469
                     } else {
5470 5470
                         self::setMessage(Display::display_normal_message(get_lang('WikiStandBy'), false, true));
5471 5471
                     }
5472
-                } elseif (self::check_addnewpagelock()==0 && (api_is_allowed_to_edit(false, true)==false || api_is_platform_admin()==false)) {
5472
+                } elseif (self::check_addnewpagelock() == 0 && (api_is_allowed_to_edit(false, true) == false || api_is_platform_admin() == false)) {
5473 5473
                     self::setMessage(Display::display_error_message(get_lang('AddPagesLocked'), false, true));
5474 5474
                 } else {
5475
-                    if (api_is_allowed_to_edit(false,true) ||
5475
+                    if (api_is_allowed_to_edit(false, true) ||
5476 5476
                         api_is_platform_admin() ||
5477 5477
                         GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id()) ||
5478 5478
                         $_GET['group_id'] == 0
Please login to merge, or discard this patch.
main/work/downloadfolder.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
  * @param array $arr1 first array
213 213
  * @param array $arr2 second array
214 214
  *
215
- * @return array difference between the two arrays
215
+ * @return string difference between the two arrays
216 216
  */
217 217
 function diff($arr1, $arr2)
218 218
 {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 if (api_is_allowed_to_edit() || api_is_coach()) {
64 64
     //Search for all files that are not deleted => visibility != 2
65
-   $sql = "SELECT DISTINCT
65
+    $sql = "SELECT DISTINCT
66 66
                 url,
67 67
                 title,
68 68
                 description,
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 $work_id = $_GET['id'];
11 11
 require_once '../inc/global.inc.php';
12
-$current_course_tool  = TOOL_STUDENTPUBLICATION;
12
+$current_course_tool = TOOL_STUDENTPUBLICATION;
13 13
 $_course = api_get_course_info();
14 14
 
15 15
 // Protection
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 if (!empty($files)) {
179 179
     $fileName = api_replace_dangerous_char($work_data['title']);
180 180
     // Logging
181
-    Event::event_download($fileName .'.zip (folder)');
181
+    Event::event_download($fileName.'.zip (folder)');
182 182
 
183 183
     //start download of created file
184
-    $name = $fileName .'.zip';
184
+    $name = $fileName.'.zip';
185 185
     if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
186 186
         DocumentManager::file_send_for_download($temp_zip_file, true, $name);
187 187
         @unlink($temp_zip_file);
Please login to merge, or discard this patch.
main/work/upload_corrections.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use ChamiloSession as Session;
5 4
 use Symfony\Component\Finder\Finder;
6 5
 
7 6
 require_once '../inc/global.inc.php';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Symfony\Component\Finder\Finder;
6 6
 
7 7
 require_once '../inc/global.inc.php';
8
-$current_course_tool  = TOOL_STUDENTPUBLICATION;
8
+$current_course_tool = TOOL_STUDENTPUBLICATION;
9 9
 
10 10
 api_protect_course_script(true);
11 11
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $zip = new PclZip($_FILES['file']['tmp_name']);
71 71
 
72 72
         // Check the zip content (real size and file extension)
73
-        $zipFileList = (array)$zip->listContent();
73
+        $zipFileList = (array) $zip->listContent();
74 74
 
75 75
         $realSize = 0;
76 76
         foreach ($zipFileList as & $this_content) {
Please login to merge, or discard this patch.
main/work/work.lib.php 2 patches
Doc Comments   +18 added lines, -17 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * Create a group of select from a date
159 159
  * @param FormValidator $form
160 160
  * @param string $prefix
161
- * @return array
161
+ * @return HTML_QuickForm_element[]
162 162
  */
163 163
 function create_group_date_select($form, $prefix = '')
164 164
 {
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  * @author Bert Vanderkimpen
753 753
  * @author Yannick Warnier <[email protected]> Adaptation for work tool
754 754
  * @param   string $base_work_dir Base work dir (.../work)
755
- * @param   string $desiredDirName complete path of the desired name
755
+ * @param   string $desired_dir_name complete path of the desired name
756 756
  *
757 757
  * @return  string actual directory name if it succeeds, boolean false otherwise
758 758
  */
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 /**
775 775
  * Delete a work-tool directory
776 776
  * @param   int  $id work directory id to delete
777
- * @return  integer -1 on error
777
+ * @return  boolean|null -1 on error
778 778
  */
779 779
 function deleteDirWork($id)
780 780
 {
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
  * Update the url of a dir in the student_publication table
918 918
  * @param  array $work_data work original data
919 919
  * @param  string $newPath Example: "folder1"
920
- * @return bool
920
+ * @return boolean|null
921 921
  */
922 922
 function updateDirName($work_data, $newPath)
923 923
 {
@@ -974,6 +974,7 @@  discard block
 block discarded – undo
974 974
 /**
975 975
  * Transform an all directory structure (only directories) in an array
976 976
  * @param   string path of the directory
977
+ * @param string $directory
977 978
  * @return  array the directory structure into an array
978 979
  * @author  Julio Montoya Dokeos
979 980
  * @version April 2008
@@ -1043,7 +1044,7 @@  discard block
 block discarded – undo
1043 1044
  * @param   string the path of the directory
1044 1045
  * @param   boolean true if we want the total quantity of files
1045 1046
  * include in others child directories, false only  files in the directory
1046
- * @return  array the first element is an integer with the number of files
1047
+ * @return  integer[] the first element is an integer with the number of files
1047 1048
  * in the folder, the second element is the number of directories
1048 1049
  * @author  Julio Montoya
1049 1050
  * @version April 2008
@@ -2319,7 +2320,7 @@  discard block
 block discarded – undo
2319 2320
 }
2320 2321
 
2321 2322
 /**
2322
- * @param $name
2323
+ * @param string $name
2323 2324
  * @param $values
2324 2325
  * @param string $checked
2325 2326
  * @return string
@@ -2845,7 +2846,7 @@  discard block
 block discarded – undo
2845 2846
  * @param int $userId
2846 2847
  * @param int $workId
2847 2848
  * @param int $courseId
2848
- * @return bool
2849
+ * @return boolean|null
2849 2850
  */
2850 2851
 function allowOnlySubscribedUser($userId, $workId, $courseId)
2851 2852
 {
@@ -2963,7 +2964,7 @@  discard block
 block discarded – undo
2963 2964
 /**
2964 2965
  * Get total score from a work list
2965 2966
  * @param $workList
2966
- * @return int|null
2967
+ * @return integer
2967 2968
  */
2968 2969
 function getTotalWorkScore($workList)
2969 2970
 {
@@ -2979,7 +2980,7 @@  discard block
 block discarded – undo
2979 2980
  * Get comment count from a work list (docs sent by students)
2980 2981
  * @param array $workList
2981 2982
  * @param array $courseInfo
2982
- * @return int|null
2983
+ * @return integer
2983 2984
  */
2984 2985
 function getTotalWorkComment($workList, $courseInfo = array())
2985 2986
 {
@@ -3122,6 +3123,7 @@  discard block
 block discarded – undo
3122 3123
  * @param int $parentId
3123 3124
  * @param array $courseInfo
3124 3125
  * @param int $sessionId
3126
+ * @param integer $userId
3125 3127
  * @return int
3126 3128
  */
3127 3129
 function getLastWorkStudentFromParentByUser(
@@ -3738,12 +3740,11 @@  discard block
 block discarded – undo
3738 3740
 
3739 3741
 /**
3740 3742
  * Creates a new task (directory) in the assignment tool
3741
- * @param array $params
3742 3743
  * @param int $user_id
3743 3744
  * @param array $courseInfo
3744 3745
  * @param int $group_id
3745 3746
  * @param int $session_id
3746
- * @return bool|int
3747
+ * @return string|false
3747 3748
  * @note $params can have the following elements, but should at least have the 2 first ones: (
3748 3749
  *       'new_dir' => 'some-name',
3749 3750
  *       'description' => 'some-desc',
@@ -4239,7 +4240,7 @@  discard block
 block discarded – undo
4239 4240
 }
4240 4241
 
4241 4242
 /**
4242
- * @return array
4243
+ * @return string[]
4243 4244
  */
4244 4245
 function getUploadDocumentType()
4245 4246
 {
@@ -4611,7 +4612,7 @@  discard block
 block discarded – undo
4611 4612
  * @param int Session ID
4612 4613
  * @param $correction
4613 4614
  *
4614
- * @return array|bool
4615
+ * @return boolean
4615 4616
  */
4616 4617
 function getFileContents($id, $course_info, $sessionId = 0, $correction = false)
4617 4618
 {
@@ -4729,7 +4730,7 @@  discard block
 block discarded – undo
4729 4730
  * @param int $userId
4730 4731
  * @param array $courseInfo
4731 4732
  * @param string $format
4732
- * @return bool
4733
+ * @return false|null
4733 4734
  */
4734 4735
 function exportAllWork($userId, $courseInfo, $format = 'pdf')
4735 4736
 {
@@ -4777,7 +4778,7 @@  discard block
 block discarded – undo
4777 4778
  * @param array $courseInfo
4778 4779
  * @param int $sessionId
4779 4780
  * @param string $format
4780
- * @return bool
4781
+ * @return false|null
4781 4782
  */
4782 4783
 function exportAllStudentWorkFromPublication(
4783 4784
     $workId,
@@ -4915,7 +4916,7 @@  discard block
 block discarded – undo
4915 4916
  * Downloads all user files per user
4916 4917
  * @param int $userId
4917 4918
  * @param array $courseInfo
4918
- * @return bool
4919
+ * @return false|null
4919 4920
  */
4920 4921
 function downloadAllFilesPerUser($userId, $courseInfo)
4921 4922
 {
@@ -5029,7 +5030,7 @@  discard block
 block discarded – undo
5029 5030
 /**
5030 5031
  * @param array $courseInfo
5031 5032
  * @param int $workId
5032
- * @return bool
5033
+ * @return boolean|null
5033 5034
  */
5034 5035
 function protectWork($courseInfo, $workId)
5035 5036
 {
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -35,27 +35,27 @@  discard block
 block discarded – undo
35 35
 
36 36
     if (!empty($id)) {
37 37
         $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'&id='.$my_back_id.'">'.
38
-            Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
38
+            Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
39 39
     }
40 40
 
41 41
     if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
42 42
         // Create dir
43 43
         if (empty($id)) {
44 44
             $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=create_dir&origin='.$origin.'&gradebook='.$gradebook.'">';
45
-            $display_output .= Display::return_icon('new_work.png', get_lang('CreateAssignment'),'',ICON_SIZE_MEDIUM).'</a>';
45
+            $display_output .= Display::return_icon('new_work.png', get_lang('CreateAssignment'), '', ICON_SIZE_MEDIUM).'</a>';
46 46
         }
47 47
         if (empty($id)) {
48 48
             // Options
49 49
             $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=settings&origin='.$origin.'&gradebook='.$gradebook.'">';
50
-            $display_output .= Display::return_icon('settings.png', get_lang('EditToolOptions'),'',ICON_SIZE_MEDIUM).'</a>';
50
+            $display_output .= Display::return_icon('settings.png', get_lang('EditToolOptions'), '', ICON_SIZE_MEDIUM).'</a>';
51 51
         }
52
-        $display_output .= '<a id="open-view-list" href="#">' . Display::return_icon('listwork.png', get_lang('ViewStudents'),'',ICON_SIZE_MEDIUM) . '</a>';
52
+        $display_output .= '<a id="open-view-list" href="#">'.Display::return_icon('listwork.png', get_lang('ViewStudents'), '', ICON_SIZE_MEDIUM).'</a>';
53 53
 
54 54
     }
55 55
 
56 56
     if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath' && api_is_allowed_to_session_edit(false, true)) {
57 57
         // Delete all files
58
-        if (api_get_setting('permanently_remove_deleted_files') == 'true'){
58
+        if (api_get_setting('permanently_remove_deleted_files') == 'true') {
59 59
             $message = get_lang('ConfirmYourChoiceDeleteAllfiles');
60 60
         } else {
61 61
             $message = get_lang('ConfirmYourChoice');
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function two_digits($number)
114 114
 {
115
-    $number = (int)$number;
115
+    $number = (int) $number;
116 116
     return ($number < 10) ? '0'.$number : $number;
117 117
 }
118 118
 
@@ -547,11 +547,11 @@  discard block
 block discarded – undo
547 547
     );
548 548
 
549 549
     $columnModel = array(
550
-        array('name'=>'type', 'index'=>'type', 'width'=>'30',   'align'=>'center', 'sortable' => 'false'),
551
-        array('name'=>'title', 'index'=>'title', 'width'=>'250',   'align'=>'left'),
552
-        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'80',  'align'=>'center', 'sortable'=>'false'),
553
-        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80',  'align'=>'center'),
554
-        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125',  'align'=>'center'),
550
+        array('name'=>'type', 'index'=>'type', 'width'=>'30', 'align'=>'center', 'sortable' => 'false'),
551
+        array('name'=>'title', 'index'=>'title', 'width'=>'250', 'align'=>'left'),
552
+        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'80', 'align'=>'center', 'sortable'=>'false'),
553
+        array('name'=>'feedback', 'index'=>'feedback', 'width'=>'80', 'align'=>'center'),
554
+        array('name'=>'last_upload', 'index'=>'feedback', 'width'=>'125', 'align'=>'center'),
555 555
     );
556 556
 
557 557
     if ($courseInfo['show_score'] == 0) {
@@ -588,10 +588,10 @@  discard block
 block discarded – undo
588 588
 {
589 589
     $columnModel = array(
590 590
         array('name'=>'type', 'index'=>'type', 'width'=>'35', 'align'=>'center', 'sortable' => 'false'),
591
-        array('name'=>'title', 'index'=>'title',  'width'=>'300',   'align'=>'left', 'wrap_cell' => "true"),
592
-        array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125',  'align'=>'center'),
593
-        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125',  'align'=>'center'),
594
-        array('name'=>'amount', 'index'=>'end_on', 'width'=>'110',  'align'=>'center'),
591
+        array('name'=>'title', 'index'=>'title', 'width'=>'300', 'align'=>'left', 'wrap_cell' => "true"),
592
+        array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125', 'align'=>'center'),
593
+        array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125', 'align'=>'center'),
594
+        array('name'=>'amount', 'index'=>'end_on', 'width'=>'110', 'align'=>'center'),
595 595
         array('name'=>'actions', 'index'=>'actions', 'width'=>'110', 'align'=>'left', 'sortable'=>'false')
596 596
     );
597 597
 
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         return false;
794 794
     }
795 795
 
796
-    $base_work_dir = api_get_path(SYS_COURSE_PATH) .$_course['path'].'/work';
796
+    $base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work';
797 797
     $work_data_url = $base_work_dir.$work_data['url'];
798 798
     $check = Security::check_abs_path($work_data_url.'/', $base_work_dir.'/');
799 799
 
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 function get_work_path($id)
864 864
 {
865 865
     $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
866
-    $course_id  = api_get_course_int_id();
866
+    $course_id = api_get_course_int_id();
867 867
     $sql = 'SELECT url FROM '.$table.'
868 868
             WHERE c_id = '.$course_id.' AND id='.intval($id);
869 869
     $res = Database::query($sql);
@@ -984,9 +984,9 @@  discard block
 block discarded – undo
984 984
     if ($handle = @opendir($directory)) {
985 985
         while (false !== ($file = readdir($handle))) {
986 986
             if ($file != '.' && $file != '..') {
987
-                if (is_dir($directory. '/' . $file)) {
988
-                    $array_items = array_merge($array_items, directory_to_array($directory. '/' . $file));
989
-                    $file = $directory . '/' . $file;
987
+                if (is_dir($directory.'/'.$file)) {
988
+                    $array_items = array_merge($array_items, directory_to_array($directory.'/'.$file));
989
+                    $file = $directory.'/'.$file;
990 990
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
991 991
                 }
992 992
             }
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
     $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
1020 1020
 
1021
-    for($i = 0; $i < count($only_dir); $i++) {
1021
+    for ($i = 0; $i < count($only_dir); $i++) {
1022 1022
         $url = $only_dir[$i];
1023 1023
 
1024 1024
         $params = [
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
             if (is_dir($path_dir.'/'.$entry)) {
1059 1059
                 $count_dir++;
1060 1060
                 if ($recurse) {
1061
-                    $count += count_dir($path_dir . '/' . $entry, $recurse);
1061
+                    $count += count_dir($path_dir.'/'.$entry, $recurse);
1062 1062
                 }
1063 1063
             } else {
1064 1064
                 $count++;
@@ -1323,11 +1323,11 @@  discard block
 block discarded – undo
1323 1323
         $courseInfo
1324 1324
     );
1325 1325
 
1326
-    if (!in_array($direction, array('asc','desc'))) {
1326
+    if (!in_array($direction, array('asc', 'desc'))) {
1327 1327
         $direction = 'desc';
1328 1328
     }
1329 1329
     if (!empty($where_condition)) {
1330
-        $where_condition = ' AND ' . $where_condition;
1330
+        $where_condition = ' AND '.$where_condition;
1331 1331
     }
1332 1332
 
1333 1333
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
         $direction = 'desc';
1471 1471
     }
1472 1472
     if (!empty($where_condition)) {
1473
-        $where_condition = ' AND ' . $where_condition;
1473
+        $where_condition = ' AND '.$where_condition;
1474 1474
     }
1475 1475
 
1476 1476
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
             );
1528 1528
 
1529 1529
             $work['amount'] = Display::label(
1530
-                $countUniqueAttempts . '/' .
1530
+                $countUniqueAttempts.'/'.
1531 1531
                 $totalUsers,
1532 1532
                 'success'
1533 1533
             );
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
                         array(),
1577 1577
                         ICON_SIZE_SMALL
1578 1578
                     ),
1579
-                    api_get_path(WEB_CODE_PATH) . 'work/downloadfolder.inc.php?id=' . $workId . '&' . api_get_cidreq()
1579
+                    api_get_path(WEB_CODE_PATH).'work/downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq()
1580 1580
                 );
1581 1581
             } else {
1582 1582
                 $downloadLink = Display::url(
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
     $userCondition = " AND u.user_id = $studentId ";
1661 1661
     $sessionCondition = " AND w.session_id = $sessionId ";
1662 1662
     $workCondition = " AND w_rel.work_id = $workId";
1663
-    $workParentCondition  = " AND w.parent_id = $workId";
1663
+    $workParentCondition = " AND w.parent_id = $workId";
1664 1664
 
1665 1665
     $sql = "(
1666 1666
                 $select1 FROM $userTable u
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
         }
1769 1769
 
1770 1770
         if ($allowEdition && !empty($itemId)) {
1771
-            $deleteLink  = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
1771
+            $deleteLink = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
1772 1772
         } else {
1773 1773
             $deleteLink = null;
1774 1774
         }
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
     $start = intval($start);
1850 1850
     $limit = intval($limit);
1851 1851
 
1852
-    if (!in_array($direction, array('asc','desc'))) {
1852
+    if (!in_array($direction, array('asc', 'desc'))) {
1853 1853
         $direction = 'desc';
1854 1854
     }
1855 1855
 
@@ -1917,13 +1917,13 @@  discard block
 block discarded – undo
1917 1917
         $work_assignment = get_work_assignment_by_id($work_id);
1918 1918
 
1919 1919
         if (!empty($studentId)) {
1920
-            $where_condition.= " AND u.user_id = ".intval($studentId);
1920
+            $where_condition .= " AND u.user_id = ".intval($studentId);
1921 1921
         }
1922 1922
 
1923 1923
         $sql = " $select
1924 1924
                 FROM $work_condition  $user_condition
1925 1925
                 WHERE $extra_conditions $where_condition $condition_session
1926
-                    AND u.status != " . INVITEE . "
1926
+                    AND u.status != ".INVITEE."
1927 1927
                 ORDER BY $column $direction";
1928 1928
 
1929 1929
         if (!empty($start) && !empty($limit)) {
@@ -1980,7 +1980,7 @@  discard block
 block discarded – undo
1980 1980
                     $qualification_string = Display::label('-');
1981 1981
                 } else {
1982 1982
                     $label = 'info';
1983
-                    $relativeScore = $work['qualification']/$work_data['qualification'];
1983
+                    $relativeScore = $work['qualification'] / $work_data['qualification'];
1984 1984
                     if ($relativeScore < 0.5) {
1985 1985
                         $label = 'important';
1986 1986
                     } elseif ($relativeScore < 0.75) {
@@ -2036,10 +2036,10 @@  discard block
 block discarded – undo
2036 2036
                 // If URL is present then there's a file to download keep BC.
2037 2037
                 if ($work['contains_file'] || !empty($work['url'])) {
2038 2038
                     $link_to_download = '<a href="'.$url.'download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
2039
-                        Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
2039
+                        Display::return_icon('save.png', get_lang('Save'), array(), ICON_SIZE_SMALL).'</a> ';
2040 2040
                 }
2041 2041
 
2042
-                $send_to = Portfolio::share('work', $work['id'],  array('style' => 'white-space:nowrap;'));
2042
+                $send_to = Portfolio::share('work', $work['id'], array('style' => 'white-space:nowrap;'));
2043 2043
 
2044 2044
                 $feedback = null;
2045 2045
                 $count = getWorkCommentCount($item_id, $course_info);
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
                 $work_date = api_convert_and_format_date($work['sent_date']);
2059 2059
 
2060 2060
                 $work['sent_date_from_db'] = $work['sent_date'];
2061
-                $work['sent_date'] = '<div class="date-time">' . date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . ' ' . $work_date . '</div>';
2061
+                $work['sent_date'] = '<div class="date-time">'.date_to_str_ago(api_get_local_time($work['sent_date'])).' '.$add_string.' '.$work_date.'</div>';
2062 2062
 
2063 2063
                 // Actions.
2064 2064
                 $correction = '';
@@ -2076,8 +2076,8 @@  discard block
 block discarded – undo
2076 2076
                         Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL).'</a> ';
2077 2077
 
2078 2078
                     if ($unoconv && empty($work['contains_file'])) {
2079
-                        $action .=  '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=export_to_doc&item_id='.$item_id.'" title="'.get_lang('ExportToDoc').'" >'.
2080
-                            Display::return_icon('export_doc.png', get_lang('ExportToDoc'),array(), ICON_SIZE_SMALL).'</a> ';
2079
+                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=export_to_doc&item_id='.$item_id.'" title="'.get_lang('ExportToDoc').'" >'.
2080
+                            Display::return_icon('export_doc.png', get_lang('ExportToDoc'), array(), ICON_SIZE_SMALL).'</a> ';
2081 2081
                     }
2082 2082
 
2083 2083
                     $correction = '
@@ -2120,9 +2120,9 @@  discard block
 block discarded – undo
2120 2120
 
2121 2121
                     if ($locked) {
2122 2122
                         if ($qualification_exists) {
2123
-                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
2123
+                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL);
2124 2124
                         } else {
2125
-                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'),array(), ICON_SIZE_SMALL);
2125
+                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'), array(), ICON_SIZE_SMALL);
2126 2126
                         }
2127 2127
                     } else {
2128 2128
                         if ($qualification_exists) {
@@ -2136,45 +2136,45 @@  discard block
 block discarded – undo
2136 2136
 
2137 2137
                     if ($work['contains_file']) {
2138 2138
                         if ($locked) {
2139
-                            $action .= Display::return_icon('move_na.png', get_lang('Move'),array(), ICON_SIZE_SMALL);
2139
+                            $action .= Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
2140 2140
                         } else {
2141 2141
                             $action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=move&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Move').'">'.
2142
-                                Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
2142
+                                Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL).'</a>';
2143 2143
                         }
2144 2144
                     }
2145 2145
 
2146 2146
                     if ($work['accepted'] == '1') {
2147 2147
                         $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_invisible&item_id='.$item_id.'" title="'.get_lang('Invisible').'" >'.
2148
-                            Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
2148
+                            Display::return_icon('visible.png', get_lang('Invisible'), array(), ICON_SIZE_SMALL).'</a>';
2149 2149
                     } else {
2150 2150
                         $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_visible&item_id='.$item_id.'" title="'.get_lang('Visible').'" >'.
2151
-                            Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
2151
+                            Display::return_icon('invisible.png', get_lang('Visible'), array(), ICON_SIZE_SMALL).'</a> ';
2152 2152
                     }
2153 2153
 
2154 2154
                     if ($locked) {
2155 2155
                         $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
2156 2156
                     } else {
2157
-                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.
2158
-                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
2157
+                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.
2158
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
2159 2159
                     }
2160 2160
                 } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
2161 2161
                     $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
2162
-                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';
2162
+                        Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL).'</a>';
2163 2163
 
2164 2164
                     if (api_get_course_setting('student_delete_own_publication') == 1) {
2165 2165
                         if (api_is_allowed_to_session_edit(false, true)) {
2166 2166
                             $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
2167
-                                Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).'</a>';
2167
+                                Display::return_icon('edit.png', get_lang('Comment'), array(), ICON_SIZE_SMALL).'</a>';
2168 2168
                         }
2169
-                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"  >'.
2170
-                            Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
2169
+                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"  >'.
2170
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
2171 2171
                     } else {
2172
-                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
2172
+                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
2173 2173
                     }
2174 2174
                 } else {
2175 2175
                     $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
2176
-                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';
2177
-                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
2176
+                        Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL).'</a>';
2177
+                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
2178 2178
                 }
2179 2179
 
2180 2180
                 // Status.
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
     $_course = api_get_course_info();
2208 2208
     $task_id = $task_data['id'];
2209 2209
     $task_title = !empty($task_data['title']) ? $task_data['title'] : basename($task_data['url']);
2210
-    $subject = '[' . api_get_setting('siteName') . '] ';
2210
+    $subject = '['.api_get_setting('siteName').'] ';
2211 2211
 
2212 2212
     // The body can be as long as you wish, and any combination of text and variables
2213 2213
     $content = get_lang('ReminderToSubmitPendingTask')."\n".get_lang('CourseName').' : '.$_course['name']."\n";
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
     $mails_sent_to = array();
2219 2219
     foreach ($list_users as $user) {
2220 2220
         $name_user = api_get_person_name($user[1], $user[0], null, PERSON_NAME_EMAIL_ADDRESS);
2221
-        $dear_line = get_lang('Dear')." ".api_get_person_name($user[1], $user[0]) .", \n\n";
2221
+        $dear_line = get_lang('Dear')." ".api_get_person_name($user[1], $user[0]).", \n\n";
2222 2222
         $body      = $dear_line.$content;
2223 2223
         MessageManager::send_message($user[3], $subject, $body);
2224 2224
         $mails_sent_to[] = $name_user;
@@ -2247,22 +2247,22 @@  discard block
 block discarded – undo
2247 2247
     } else {
2248 2248
         $students = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId);
2249 2249
     }
2250
-    $emailsubject = '[' . api_get_setting('siteName') . '] '.get_lang('HomeworkCreated');
2250
+    $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('HomeworkCreated');
2251 2251
     $currentUser = api_get_user_info(api_get_user_id());
2252 2252
     if (!empty($students)) {
2253
-        foreach($students as $student) {
2253
+        foreach ($students as $student) {
2254 2254
             $user_info = api_get_user_info($student["user_id"]);
2255
-            if(!empty($user_info["mail"])) {
2255
+            if (!empty($user_info["mail"])) {
2256 2256
                 $name_user = api_get_person_name(
2257 2257
                     $user_info["firstname"],
2258 2258
                     $user_info["lastname"],
2259 2259
                     null,
2260 2260
                     PERSON_NAME_EMAIL_ADDRESS
2261 2261
                 );
2262
-                $link = api_get_path(WEB_CODE_PATH) . 'work/work_list_all.php?' . api_get_cidreq() . '&id=' . $workId;
2262
+                $link = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId;
2263 2263
                 $emailbody = get_lang('Dear')." ".$name_user.",\n\n";
2264 2264
                 $emailbody .= get_lang('HomeworkHasBeenCreatedForTheCourse')." ".$courseCode.". "."\n\n".
2265
-                    '<a href="'. $link . '">' . get_lang('PleaseCheckHomeworkPage') . '</a>';
2265
+                    '<a href="'.$link.'">'.get_lang('PleaseCheckHomeworkPage').'</a>';
2266 2266
                 $emailbody .= "\n\n".api_get_person_name($currentUser["firstname"], $currentUser["lastname"]);
2267 2267
 
2268 2268
                 $additionalParameters = array(
@@ -2304,7 +2304,7 @@  discard block
 block discarded – undo
2304 2304
     $url = Database::escape_string($url);
2305 2305
     $sql = "SELECT id FROM $work_table WHERE url='$url'";
2306 2306
     $result = Database::query($sql);
2307
-    if (Database::num_rows($result)> 0) {
2307
+    if (Database::num_rows($result) > 0) {
2308 2308
         $row = Database::fetch_row($result);
2309 2309
         if (empty($row)) {
2310 2310
             return false;
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
 {
2327 2327
     $output = '<select name="'.$name.'" id="'.$name.'">';
2328 2328
     foreach ($values as $key => $value) {
2329
-        $output .= '<option value="'.$key.'" '.(($checked==$key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2329
+        $output .= '<option value="'.$key.'" '.(($checked == $key) ? 'selected="selected"' : '').'>'.$value.'</option>';
2330 2330
     }
2331 2331
     $output .= '</select>';
2332 2332
     return $output;
@@ -2340,9 +2340,9 @@  discard block
 block discarded – undo
2340 2340
  */
2341 2341
 function make_checkbox($name, $checked = '', $label = null)
2342 2342
 {
2343
-    $check = '<input id ="'.$name.'" type="checkbox" value="1" name="'.$name.'" '.((!empty($checked))?'checked="checked"':'').'/>';
2343
+    $check = '<input id ="'.$name.'" type="checkbox" value="1" name="'.$name.'" '.((!empty($checked)) ? 'checked="checked"' : '').'/>';
2344 2344
     if (!empty($label)) {
2345
-        $check .="<label for ='$name'>$label</label>";
2345
+        $check .= "<label for ='$name'>$label</label>";
2346 2346
     }
2347 2347
     return $check;
2348 2348
 }
@@ -2496,7 +2496,7 @@  discard block
 block discarded – undo
2496 2496
     }
2497 2497
 
2498 2498
     if (!empty($studentId)) {
2499
-        $sql_users.= " AND u.user_id = ".intval($studentId);
2499
+        $sql_users .= " AND u.user_id = ".intval($studentId);
2500 2500
     }
2501 2501
 
2502 2502
     $group_id = api_get_group_id();
@@ -2506,7 +2506,7 @@  discard block
 block discarded – undo
2506 2506
     if ($group_id) {
2507 2507
         $group_user_list = GroupManager::get_subscribed_users($group_id);
2508 2508
         if (!empty($group_user_list)) {
2509
-            foreach($group_user_list as $group_user) {
2509
+            foreach ($group_user_list as $group_user) {
2510 2510
                 $new_group_user_list[] = $group_user['user_id'];
2511 2511
             }
2512 2512
         }
@@ -2927,7 +2927,7 @@  discard block
 block discarded – undo
2927 2927
 function getWorkComments($work)
2928 2928
 {
2929 2929
     $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
2930
-    $userTable= Database::get_main_table(TABLE_MAIN_USER);
2930
+    $userTable = Database::get_main_table(TABLE_MAIN_USER);
2931 2931
 
2932 2932
     $courseId = intval($work['c_id']);
2933 2933
     $workId = intval($work['id']);
@@ -3610,7 +3610,7 @@  discard block
 block discarded – undo
3610 3610
             null,
3611 3611
             PERSON_NAME_EMAIL_ADDRESS
3612 3612
         );
3613
-        $subject = "[" . api_get_setting('siteName') . "] ".get_lang('SendMailBody')."\n ".get_lang('CourseName').": ".$courseInfo['name']."  ";
3613
+        $subject = "[".api_get_setting('siteName')."] ".get_lang('SendMailBody')."\n ".get_lang('CourseName').": ".$courseInfo['name']."  ";
3614 3614
         foreach ($user_list as $user_data) {
3615 3615
             $to_user_id = $user_data['user_id'];
3616 3616
             $user_info = api_get_user_info($to_user_id);
@@ -3659,7 +3659,7 @@  discard block
 block discarded – undo
3659 3659
 
3660 3660
     $title = $values['title'];
3661 3661
     $description = $values['description'];
3662
-    $contains_file = isset($values['contains_file']) && !empty($values['contains_file']) ? intval($values['contains_file']): 0;
3662
+    $contains_file = isset($values['contains_file']) && !empty($values['contains_file']) ? intval($values['contains_file']) : 0;
3663 3663
 
3664 3664
     $saveWork = true;
3665 3665
     $message = null;
@@ -4026,8 +4026,8 @@  discard block
 block discarded – undo
4026 4026
                     LINK_STUDENTPUBLICATION,
4027 4027
                     $workId,
4028 4028
                     $params['new_dir'],
4029
-                    (float)$params['weight'],
4030
-                    (float)$params['qualification'],
4029
+                    (float) $params['weight'],
4030
+                    (float) $params['qualification'],
4031 4031
                     $params['description'],
4032 4032
                     1,
4033 4033
                     api_get_session_id()
@@ -4287,15 +4287,15 @@  discard block
 block discarded – undo
4287 4287
     // changing the tool setting: is a student allowed to delete his/her own document
4288 4288
 
4289 4289
     // counting the number of occurrences of this setting (if 0 => add, if 1 => update)
4290
-    $query = "SELECT * FROM " . $table_course_setting . "
4290
+    $query = "SELECT * FROM ".$table_course_setting."
4291 4291
               WHERE c_id = $courseId AND variable = 'student_delete_own_publication'";
4292 4292
 
4293 4293
     $result = Database::query($query);
4294 4294
     $number_of_setting = Database::num_rows($result);
4295 4295
 
4296 4296
     if ($number_of_setting == 1) {
4297
-        $query = "UPDATE " . $table_course_setting . " SET
4298
-                  value='" . Database::escape_string($studentDeleteOwnPublication) . "'
4297
+        $query = "UPDATE ".$table_course_setting." SET
4298
+                  value='" . Database::escape_string($studentDeleteOwnPublication)."'
4299 4299
                   WHERE variable = 'student_delete_own_publication' AND c_id = $courseId";
4300 4300
         Database::query($query);
4301 4301
     } else {
@@ -4334,9 +4334,9 @@  discard block
 block discarded – undo
4334 4334
     $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
4335 4335
     $item_id = intval($item_id);
4336 4336
     $course_id = $course_info['real_id'];
4337
-    $sql = "UPDATE  " . $work_table . "
4337
+    $sql = "UPDATE  ".$work_table."
4338 4338
             SET accepted = 0
4339
-            WHERE c_id = $course_id AND id = '" . $item_id . "'";
4339
+            WHERE c_id = $course_id AND id = '".$item_id."'";
4340 4340
     Database::query($sql);
4341 4341
     api_item_property_update(
4342 4342
         $course_info,
@@ -4480,7 +4480,7 @@  discard block
 block discarded – undo
4480 4480
                 $courseCode,
4481 4481
                 $sessionId,
4482 4482
                 $limitString,
4483
-                $orderBy ,
4483
+                $orderBy,
4484 4484
                 STUDENT,
4485 4485
                 $getCount
4486 4486
             );
@@ -4817,8 +4817,8 @@  discard block
 block discarded – undo
4817 4817
     if (!empty($sessionId)) {
4818 4818
         $sessionInfo = api_get_session_info($sessionId);
4819 4819
         if (!empty($sessionInfo)) {
4820
-            $header .= ' - ' . $sessionInfo['name'];
4821
-            $header .= '<br />' . $sessionInfo['description'];
4820
+            $header .= ' - '.$sessionInfo['name'];
4821
+            $header .= '<br />'.$sessionInfo['description'];
4822 4822
             $teachers = SessionManager::getCoachesByCourseSessionToString(
4823 4823
                 $sessionId,
4824 4824
                 $courseInfo['real_id']
@@ -4834,12 +4834,12 @@  discard block
 block discarded – undo
4834 4834
     $expiresOn = null;
4835 4835
 
4836 4836
     if (!empty($assignment) && isset($assignment['expires_on'])) {
4837
-        $content .= '<br /><strong>' . get_lang('ExpirationDate') . '</strong>: ' . api_get_local_time($assignment['expires_on']);
4837
+        $content .= '<br /><strong>'.get_lang('ExpirationDate').'</strong>: '.api_get_local_time($assignment['expires_on']);
4838 4838
         $expiresOn = api_get_local_time($assignment['expires_on']);
4839 4839
     }
4840 4840
 
4841 4841
     if (!empty($workData['description'])) {
4842
-        $content .= '<br /><strong>' . get_lang('Description') . '</strong>: ' . $workData['description'];
4842
+        $content .= '<br /><strong>'.get_lang('Description').'</strong>: '.$workData['description'];
4843 4843
     }
4844 4844
 
4845 4845
     $workList = get_work_user_list(null, null, null, null, $workId);
@@ -4860,7 +4860,7 @@  discard block
 block discarded – undo
4860 4860
                 );
4861 4861
 
4862 4862
                 $column = 0;
4863
-                foreach($headers as $header) {
4863
+                foreach ($headers as $header) {
4864 4864
                     $table->setHeaderContents(0, $column, $header);
4865 4865
                     $column++;
4866 4866
                 }
@@ -4908,7 +4908,7 @@  discard block
 block discarded – undo
4908 4908
 
4909 4909
                 if (!empty($content)) {
4910 4910
                     $params = array(
4911
-                        'filename' => $workData['title'] . '_' . api_get_local_time(),
4911
+                        'filename' => $workData['title'].'_'.api_get_local_time(),
4912 4912
                         'pdf_title' => api_replace_dangerous_char($workData['title']),
4913 4913
                         'course_code' => $courseInfo['code'],
4914 4914
                         'add_signatures' => false
@@ -4939,7 +4939,7 @@  discard block
 block discarded – undo
4939 4939
     $tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
4940 4940
     $coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work/';
4941 4941
 
4942
-    $zip  = new PclZip($tempZipFile);
4942
+    $zip = new PclZip($tempZipFile);
4943 4943
 
4944 4944
     $workPerUser = getWorkPerUser($userId);
4945 4945
 
Please login to merge, or discard this patch.
plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
      * Register a user into a queue for a session
371 371
      * @param $userId
372 372
      * @param $sessionId
373
-     * @return bool|int
373
+     * @return false|string
374 374
      */
375 375
     public function addToQueue($userId, $sessionId)
376 376
     {
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
      * Register message with type and status
397 397
      * @param $mailId
398 398
      * @param $userId
399
-     * @param $sessionId
399
+     * @param integer $sessionId
400 400
      * @return bool|int
401 401
      */
402 402
     public function saveLastMessage($mailId, $userId, $sessionId)
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 
510 510
     /**
511 511
      * Check if session is open for subscription
512
-     * @param $sessionId
512
+     * @param integer $sessionId
513 513
      * @param string $fieldVariable
514 514
      * @return bool
515 515
      */
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 
532 532
     /**
533 533
      * Check if user is in the session's target group based on its area
534
-     * @param $userId
535
-     * @param $sessionId
534
+     * @param integer $userId
535
+     * @param integer $sessionId
536 536
      * @param string $userFieldVariable
537 537
      * @param string $sessionFieldVariable
538 538
      * @return bool
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
     /**
1003 1003
      * Return the session details data from a session ID (including the extra
1004 1004
      * fields used for the advanced subscription mechanism)
1005
-     * @param $sessionId
1005
+     * @param integer $sessionId
1006 1006
      * @return bool|mixed
1007 1007
      */
1008 1008
     public function getSessionDetails($sessionId)
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
     /**
1104 1104
      * Return the url to go to session
1105
-     * @param $sessionId
1105
+     * @param integer $sessionId
1106 1106
      *
1107 1107
      * @return string
1108 1108
      */
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1069,7 +1069,7 @@
 block discarded – undo
1069 1069
      */
1070 1070
     public function getStatusMessage($status, $isAble = true)
1071 1071
     {
1072
-	$message = '';
1072
+    $message = '';
1073 1073
         switch ($status) {
1074 1074
             case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
1075 1075
                 if ($isAble) {
Please login to merge, or discard this patch.
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
108 108
 
109
-        $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (" .
110
-            "id int UNSIGNED NOT NULL AUTO_INCREMENT, " .
111
-            "session_id int UNSIGNED NOT NULL, " .
112
-            "user_id int UNSIGNED NOT NULL, " .
113
-            "status int UNSIGNED NOT NULL, " .
114
-            "last_message_id int UNSIGNED NOT NULL, " .
115
-            "created_at datetime NOT NULL, " .
116
-            "updated_at datetime NULL, " .
117
-            "PRIMARY KEY PK_advanced_subscription_queue (id), " .
109
+        $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (".
110
+            "id int UNSIGNED NOT NULL AUTO_INCREMENT, ".
111
+            "session_id int UNSIGNED NOT NULL, ".
112
+            "user_id int UNSIGNED NOT NULL, ".
113
+            "status int UNSIGNED NOT NULL, ".
114
+            "last_message_id int UNSIGNED NOT NULL, ".
115
+            "created_at datetime NOT NULL, ".
116
+            "updated_at datetime NULL, ".
117
+            "PRIMARY KEY PK_advanced_subscription_queue (id), ".
118 118
             "UNIQUE KEY UK_advanced_subscription_queue (user_id, session_id)); ";
119 119
         Database::query($sql);
120 120
     }
@@ -265,11 +265,10 @@  discard block
 block discarded – undo
265 265
         $now = new DateTime(api_get_utc_datetime());
266 266
         $newYearDate = $plugin->get('course_session_credit_year_start_date');
267 267
         $newYearDate = !empty($newYearDate) ?
268
-            new \DateTime($newYearDate . $now->format('/Y')) :
269
-            $now;
268
+            new \DateTime($newYearDate.$now->format('/Y')) : $now;
270 269
         $extra = new ExtraFieldValue('session');
271
-        $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su INNER JOIN ' .
272
-            Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.session_id';
270
+        $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER).' su INNER JOIN '.
271
+            Database::get_main_table(TABLE_MAIN_SESSION).' s ON s.id = su.session_id';
273 272
         $whereSessionParams = 'su.relation_type = ? AND s.access_start_date >= ? AND su.user_id = ?';
274 273
         $whereSessionParamsValues = array(
275 274
             0,
@@ -734,14 +733,14 @@  discard block
 block discarded – undo
734 733
                     $tpl->assign('termsContent', $termsAndConditions);
735 734
                     $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl');
736 735
                     $pdf = new PDF();
737
-                    $filename = 'terms' . sha1(rand(0,99999));
736
+                    $filename = 'terms'.sha1(rand(0, 99999));
738 737
                     $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F');
739 738
                     $fileAttachments['file'][] = array(
740
-                        'name' => $filename . '.pdf',
741
-                        'application/pdf' => $filename . '.pdf',
742
-                        'tmp_name' => api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf',
739
+                        'name' => $filename.'.pdf',
740
+                        'application/pdf' => $filename.'.pdf',
741
+                        'tmp_name' => api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf',
743 742
                         'error' => UPLOAD_ERR_OK,
744
-                        'size' => filesize(api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf'),
743
+                        'size' => filesize(api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf'),
745 744
                     );
746 745
                     $fileAttachments['comments'][] = get_lang('TermsAndConditions');
747 746
                 }
@@ -1032,7 +1031,7 @@  discard block
 block discarded – undo
1032 1031
 
1033 1032
             $mergedArray = array_merge(array($sessionId), array_keys($fields));
1034 1033
 
1035
-            $sql = "SELECT * FROM " . Database::get_main_table(TABLE_EXTRA_FIELD_VALUES) ."
1034
+            $sql = "SELECT * FROM ".Database::get_main_table(TABLE_EXTRA_FIELD_VALUES)."
1036 1035
                     WHERE item_id = %d AND field_id IN (%d, %d, %d, %d, %d, %d, %d)";
1037 1036
             $sql = vsprintf($sql, $mergedArray);
1038 1037
             $sessionFieldValueList = Database::query($sql);
@@ -1048,10 +1047,10 @@  discard block
 block discarded – undo
1048 1047
             $sessionArray['description'] = SessionManager::getDescriptionFromSessionId($sessionId);
1049 1048
 
1050 1049
             if (isset($sessionArray['brochure'])) {
1051
-                $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['brochure'];
1050
+                $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['brochure'];
1052 1051
             }
1053 1052
             if (isset($sessionArray['banner'])) {
1054
-                $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['banner'];
1053
+                $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['banner'];
1055 1054
             }
1056 1055
 
1057 1056
             return $sessionArray;
@@ -1108,7 +1107,7 @@  discard block
 block discarded – undo
1108 1107
      */
1109 1108
     public function getSessionUrl($sessionId)
1110 1109
     {
1111
-        $url = api_get_path(WEB_CODE_PATH) . 'session/?session_id=' . intval($sessionId);
1110
+        $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.intval($sessionId);
1112 1111
 
1113 1112
         return $url;
1114 1113
     }
@@ -1157,16 +1156,16 @@  discard block
 block discarded – undo
1157 1156
      */
1158 1157
     public function getQueueUrl($params)
1159 1158
     {
1160
-        $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/ajax/advanced_subscription.ajax.php?' .
1161
-            'a=' . Security::remove_XSS($params['action']) . '&' .
1162
-            's=' . intval($params['sessionId']) . '&' .
1163
-            'current_user_id=' . intval($params['currentUserId']) . '&' .
1164
-            'e=' . intval($params['newStatus']) . '&' .
1165
-            'u=' . intval($params['studentUserId']) . '&' .
1166
-            'q=' . intval($params['queueId']) . '&' .
1167
-            'is_connected=' . 1 . '&' .
1168
-            'profile_completed=' . intval($params['profile_completed']) . '&' .
1169
-            'v=' . $this->generateHash($params);
1159
+        $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/ajax/advanced_subscription.ajax.php?'.
1160
+            'a='.Security::remove_XSS($params['action']).'&'.
1161
+            's='.intval($params['sessionId']).'&'.
1162
+            'current_user_id='.intval($params['currentUserId']).'&'.
1163
+            'e='.intval($params['newStatus']).'&'.
1164
+            'u='.intval($params['studentUserId']).'&'.
1165
+            'q='.intval($params['queueId']).'&'.
1166
+            'is_connected='.1.'&'.
1167
+            'profile_completed='.intval($params['profile_completed']).'&'.
1168
+            'v='.$this->generateHash($params);
1170 1169
 
1171 1170
         return $url;
1172 1171
     }
@@ -1219,7 +1218,7 @@  discard block
 block discarded – undo
1219 1218
         }
1220 1219
         $queueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE);
1221 1220
         $userTable = Database::get_main_table(TABLE_MAIN_USER);
1222
-        $userJoinTable = $queueTable . ' q INNER JOIN ' . $userTable . ' u ON q.user_id = u.user_id';
1221
+        $userJoinTable = $queueTable.' q INNER JOIN '.$userTable.' u ON q.user_id = u.user_id';
1223 1222
         $where = array(
1224 1223
             'where' => array(
1225 1224
                 'q.session_id = ?' => array(
@@ -1232,7 +1231,7 @@  discard block
 block discarded – undo
1232 1231
         $students = Database::select($select, $userJoinTable, $where);
1233 1232
         foreach ($students as &$student) {
1234 1233
             $status = intval($student['status']);
1235
-            switch($status) {
1234
+            switch ($status) {
1236 1235
                 case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE:
1237 1236
                 case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START:
1238 1237
                     $student['validation'] = '';
@@ -1246,7 +1245,7 @@  discard block
 block discarded – undo
1246 1245
                     $student['validation'] = 'Yes';
1247 1246
                     break;
1248 1247
                 default:
1249
-                    error_log(__FILE__ . ' ' . __FUNCTION__ . ' Student status no detected');
1248
+                    error_log(__FILE__.' '.__FUNCTION__.' Student status no detected');
1250 1249
             }
1251 1250
         }
1252 1251
         $return = array(
@@ -1295,7 +1294,7 @@  discard block
 block discarded – undo
1295 1294
         $dataPrepared['queueId'] = intval($data['queueId']);
1296 1295
         $dataPrepared['newStatus'] = intval($data['newStatus']);
1297 1296
         $dataPrepared = serialize($dataPrepared);
1298
-        return sha1($dataPrepared . $key);
1297
+        return sha1($dataPrepared.$key);
1299 1298
     }
1300 1299
 
1301 1300
     /**
@@ -1350,12 +1349,12 @@  discard block
 block discarded – undo
1350 1349
                 break;
1351 1350
         }
1352 1351
 
1353
-        $url = api_get_path(WEB_PLUGIN_PATH) . "advanced_subscription/src/terms_and_conditions.php?";
1352
+        $url = api_get_path(WEB_PLUGIN_PATH)."advanced_subscription/src/terms_and_conditions.php?";
1354 1353
         $url .= http_build_query($urlParams);
1355 1354
 
1356 1355
         // Launch popup
1357 1356
         if ($mode == ADVANCED_SUBSCRIPTION_TERMS_MODE_POPUP) {
1358
-            $url = 'javascript:void(window.open(\'' . $url .'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))';
1357
+            $url = 'javascript:void(window.open(\''.$url.'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))';
1359 1358
         }
1360 1359
         return $url;
1361 1360
     }
@@ -1367,9 +1366,9 @@  discard block
 block discarded – undo
1367 1366
      */
1368 1367
     public function getRenderMailUrl($params)
1369 1368
     {
1370
-        $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/src/render_mail.php?' .
1371
-            'q=' . $params['queueId'] . '&' .
1372
-            'v=' . $this->generateHash($params);
1369
+        $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/src/render_mail.php?'.
1370
+            'q='.$params['queueId'].'&'.
1371
+            'v='.$this->generateHash($params);
1373 1372
         return $url;
1374 1373
     }
1375 1374
 
@@ -1440,7 +1439,7 @@  discard block
 block discarded – undo
1440 1439
                 sf.extra_field_type = $extraFieldType AND
1441 1440
                 sf.variable = 'is_induction_session' AND
1442 1441
                 su.relation_type = 0 AND
1443
-                su.user_id = " . intval($userId);
1442
+                su.user_id = ".intval($userId);
1444 1443
 
1445 1444
         $result = Database::query($sql);
1446 1445
 
Please login to merge, or discard this patch.
plugin/bbb/lib/bbb.lib.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     /**
241 241
      * Returns a meeting "join" URL
242 242
      * @param string The name of the meeting (usually the course code)
243
-     * @return mixed The URL to join the meeting, or false on error
243
+     * @return false|string The URL to join the meeting, or false on error
244 244
      * @todo implement moderator pass
245 245
      * @assert ('') === false
246 246
      * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
      * Closes a meeting (usually when the user click on the close button from
648 648
      * the conferences listing.
649 649
      * @param string The internal ID of the meeting (id field for this meeting)
650
-     * @return void
650
+     * @return false|null
651 651
      * @assert (0) === false
652 652
      */
653 653
     public function endMeeting($id)
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
         $params['session_id'] = api_get_session_id();
123 123
 
124 124
         $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id();
125
-        $attendeePassword =  $params['attendee_pw'];
125
+        $attendeePassword = $params['attendee_pw'];
126 126
         $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword();
127 127
         $moderatorPassword = $params['moderator_pw'];
128 128
 
129 129
         $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false;
130 130
         $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode);
131
-        $max =  isset($max) ? $max : -1;
131
+        $max = isset($max) ? $max : -1;
132 132
         $params['status'] = 1;
133 133
         // Generate a pseudo-global-unique-id to avoid clash of conferences on
134 134
         // the same BBB server with several Chamilo portals
135 135
         $params['remote_id'] = uniqid(true, true);
136 136
         // Each simultaneous conference room needs to have a different
137 137
         // voice_bridge composed of a 5 digits number, so generating a random one
138
-        $params['voice_bridge'] = rand(10000,99999);
138
+        $params['voice_bridge'] = rand(10000, 99999);
139 139
 
140 140
         if ($this->debug) {
141 141
             error_log("enter create_meeting ".print_r($params, 1));
@@ -158,23 +158,23 @@  discard block
 block discarded – undo
158 158
             $duration = 300;
159 159
 
160 160
             $bbbParams = array(
161
-                'meetingId' => $params['remote_id'], 					// REQUIRED
162
-                'meetingName' => $meetingName, 	// REQUIRED
163
-                'attendeePw' => $attendeePassword, 					// Match this value in getJoinMeetingURL() to join as attendee.
164
-                'moderatorPw' => $moderatorPassword, 					// Match this value in getJoinMeetingURL() to join as moderator.
165
-                'welcomeMsg' => $welcomeMessage, 					// ''= use default. Change to customize.
166
-                'dialNumber' => '', 					// The main number to call into. Optional.
167
-                'voiceBridge' => $params['voice_bridge'], 					// PIN to join voice. Required.
168
-                'webVoice' => '', 						// Alphanumeric to join voice. Optional.
161
+                'meetingId' => $params['remote_id'], // REQUIRED
162
+                'meetingName' => $meetingName, // REQUIRED
163
+                'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee.
164
+                'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator.
165
+                'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize.
166
+                'dialNumber' => '', // The main number to call into. Optional.
167
+                'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required.
168
+                'webVoice' => '', // Alphanumeric to join voice. Optional.
169 169
                 'logoutUrl' =>  $this->logout_url,
170
-                'maxParticipants' => $max, 				// Optional. -1 = unlimitted. Not supported in BBB. [number]
171
-                'record' => $record, 					// New. 'true' will tell BBB to record the meeting.
172
-                'duration' => $duration, 				// Default = 0 which means no set duration in minutes. [number]
170
+                'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
171
+                'record' => $record, // New. 'true' will tell BBB to record the meeting.
172
+                'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
173 173
                 //'meta_category' => '', 				// Use to pass additional info to BBB server. See API docs.
174 174
             );
175 175
 
176 176
             if ($this->debug) {
177
-                error_log("create_meeting params: ".print_r($bbbParams,1));
177
+                error_log("create_meeting params: ".print_r($bbbParams, 1));
178 178
             }
179 179
 
180 180
             $status = false;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 ) {
189 189
                     if ($this->debug) {
190 190
                         error_log(
191
-                            "create_meeting result: " . print_r($result, 1)
191
+                            "create_meeting result: ".print_r($result, 1)
192 192
                         );
193 193
                     }
194 194
                     $meeting = $this->joinMeeting($meetingName, true);
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
             if ($this->debug) {
308 308
                 error_log(
309
-                    "meeting is running: " . intval($meetingInfoExists)
309
+                    "meeting is running: ".intval($meetingInfoExists)
310 310
                 );
311 311
             }
312 312
 
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 
324 324
         if ($meetingInfoExists) {
325 325
             $joinParams = array(
326
-                'meetingId' => $meetingData['remote_id'],	//	-- REQUIRED - A unique id for the meeting
327
-                'username' => $this->user_complete_name,	//-- REQUIRED - The name that will display for the user in the meeting
328
-                'password' => $pass,			//-- REQUIRED - The attendee or moderator password, depending on what's passed here
326
+                'meetingId' => $meetingData['remote_id'], //	-- REQUIRED - A unique id for the meeting
327
+                'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
328
+                'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
329 329
                 //'createTime' => api_get_utc_datetime(),			//-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
330
-                'userID' => api_get_user_id(),				//-- OPTIONAL - string
330
+                'userID' => api_get_user_id(), //-- OPTIONAL - string
331 331
                 'webVoiceConf' => ''	//	-- OPTIONAL - string
332 332
             );
333 333
             $url = $this->api->getJoinMeetingURL($joinParams);
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             $url = $this->logout_url;
337 337
         }
338 338
         if ($this->debug) {
339
-            error_log("return url :" . $url);
339
+            error_log("return url :".$url);
340 340
         }
341 341
         return $url;
342 342
     }
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             }
398 398
             $meetingBBB['end_url'] = api_get_self().'?'.api_get_cidreq().'&action=end&id='.$meetingDB['id'];
399 399
 
400
-            if ((string)$meetingBBB['returncode'] == 'FAILED') {
400
+            if ((string) $meetingBBB['returncode'] == 'FAILED') {
401 401
                 if ($meetingDB['status'] == 1 && $this->isTeacher()) {
402 402
                     $this->endMeeting($meetingDB['id']);
403 403
                 }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
                     $item['action_links'] = implode('<br />', $actionLinksArray);
588 588
                 }
589 589
                 //var_dump($recordArray);
590
-                $item['show_links']  = implode('<br />', $recordArray);
590
+                $item['show_links'] = implode('<br />', $recordArray);
591 591
                 $item['action_links'] = implode('<br />', $actionLinksArray);
592 592
             }
593 593
 
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
 
601 601
             if ($meetingDB['status'] == 1) {
602 602
                 $joinParams = array(
603
-                    'meetingId' => $meetingDB['remote_id'],		//-- REQUIRED - A unique id for the meeting
604
-                    'username' => $this->user_complete_name,	//-- REQUIRED - The name that will display for the user in the meeting
605
-                    'password' => $pass,			//-- REQUIRED - The attendee or moderator password, depending on what's passed here
606
-                    'createTime' => '',			//-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
607
-                    'userID' => '',			//	-- OPTIONAL - string
603
+                    'meetingId' => $meetingDB['remote_id'], //-- REQUIRED - A unique id for the meeting
604
+                    'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting
605
+                    'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
606
+                    'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
607
+                    'userID' => '', //	-- OPTIONAL - string
608 608
                     'webVoiceConf' => ''	//	-- OPTIONAL - string
609 609
                 );
610 610
                 $item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
         $pass = $this->getUserMeetingPassword();
660 660
 
661 661
         $endParams = array(
662
-            'meetingId' => $meetingData['remote_id'],   // REQUIRED - We have to know which meeting to end.
663
-            'password' => $pass,        // REQUIRED - Must match moderator pass for meeting.
662
+            'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end.
663
+            'password' => $pass, // REQUIRED - Must match moderator pass for meeting.
664 664
         );
665 665
         $this->api->endMeetingWithXmlResponseArray($endParams);
666 666
         Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id));
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
      */
843 843
     public function redirectToBBB($url)
844 844
     {
845
-        if (file_exists(__DIR__ . '/../config.vm.php')) {
845
+        if (file_exists(__DIR__.'/../config.vm.php')) {
846 846
             // Using VM
847 847
             echo Display::url(get_lang('ClickToContinue'), $url);
848 848
             exit;
Please login to merge, or discard this patch.
plugin/bbb/lib/bbb_api.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@
 block discarded – undo
59 59
 		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60 60
 	}
61 61
 
62
+	/**
63
+	 * @param string $url
64
+	 */
62 65
 	private function _processXmlResponse($url){
63 66
 	/*
64 67
 	A private utility method used by other public methods to process XML responses.
Please login to merge, or discard this patch.
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -44,107 +44,107 @@  discard block
 block discarded – undo
44 44
 
45 45
 class BigBlueButtonBN {
46 46
 
47
-	private $_securitySalt;
48
-	private $_bbbServerBaseUrl;
47
+    private $_securitySalt;
48
+    private $_bbbServerBaseUrl;
49 49
 
50
-	/* ___________ General Methods for the BigBlueButton Class __________ */
50
+    /* ___________ General Methods for the BigBlueButton Class __________ */
51 51
 
52
-	function __construct() {
53
-	/*
52
+    function __construct() {
53
+    /*
54 54
 	Establish just our basic elements in the constructor:
55 55
 	*/
56
-		// BASE CONFIGS - set these for your BBB server in config.php and they will
57
-		// simply flow in here via the constants:
58
-		$this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
-		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60
-	}
61
-
62
-	private function _processXmlResponse($url){
63
-	/*
56
+        // BASE CONFIGS - set these for your BBB server in config.php and they will
57
+        // simply flow in here via the constants:
58
+        $this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
+        $this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
60
+    }
61
+
62
+    private function _processXmlResponse($url){
63
+    /*
64 64
 	A private utility method used by other public methods to process XML responses.
65 65
 	*/
66
-		if (extension_loaded('curl')) {
67
-			$ch = curl_init() or die ( curl_error($ch) );
68
-			$timeout = 10;
69
-			curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
-			curl_setopt( $ch, CURLOPT_URL, $url );
71
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
-			curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
-			$data = curl_exec( $ch );
74
-			curl_close( $ch );
75
-
76
-			if($data)
77
-				return (new SimpleXMLElement($data));
78
-			else
79
-				return false;
80
-		}
81
-		return (simplexml_load_file($url));
82
-	}
83
-
84
-	private function _requiredParam($param) {
85
-		/* Process required params and throw errors if we don't get values */
86
-		if ((isset($param)) && ($param != '')) {
87
-			return $param;
88
-		}
89
-		elseif (!isset($param)) {
90
-			throw new Exception('Missing parameter.');
91
-		}
92
-		else {
93
-			throw new Exception(''.$param.' is required.');
94
-		}
95
-	}
96
-
97
-	private function _optionalParam($param) {
98
-		/* Pass most optional params through as set value, or set to '' */
99
-		/* Don't know if we'll use this one, but let's build it in case. */
100
-		if ((isset($param)) && ($param != '')) {
101
-			return $param;
102
-		}
103
-		else {
104
-			$param = '';
105
-			return $param;
106
-		}
107
-	}
108
-
109
-	/* __________________ BBB ADMINISTRATION METHODS _________________ */
110
-	/* The methods in the following section support the following categories of the BBB API:
66
+        if (extension_loaded('curl')) {
67
+            $ch = curl_init() or die ( curl_error($ch) );
68
+            $timeout = 10;
69
+            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
+            curl_setopt( $ch, CURLOPT_URL, $url );
71
+            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
+            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
+            $data = curl_exec( $ch );
74
+            curl_close( $ch );
75
+
76
+            if($data)
77
+                return (new SimpleXMLElement($data));
78
+            else
79
+                return false;
80
+        }
81
+        return (simplexml_load_file($url));
82
+    }
83
+
84
+    private function _requiredParam($param) {
85
+        /* Process required params and throw errors if we don't get values */
86
+        if ((isset($param)) && ($param != '')) {
87
+            return $param;
88
+        }
89
+        elseif (!isset($param)) {
90
+            throw new Exception('Missing parameter.');
91
+        }
92
+        else {
93
+            throw new Exception(''.$param.' is required.');
94
+        }
95
+    }
96
+
97
+    private function _optionalParam($param) {
98
+        /* Pass most optional params through as set value, or set to '' */
99
+        /* Don't know if we'll use this one, but let's build it in case. */
100
+        if ((isset($param)) && ($param != '')) {
101
+            return $param;
102
+        }
103
+        else {
104
+            $param = '';
105
+            return $param;
106
+        }
107
+    }
108
+
109
+    /* __________________ BBB ADMINISTRATION METHODS _________________ */
110
+    /* The methods in the following section support the following categories of the BBB API:
111 111
 	-- create
112 112
 	-- join
113 113
 	-- end
114 114
 	*/
115 115
 
116
-	public function getCreateMeetingUrl($creationParams) {
117
-		/*
116
+    public function getCreateMeetingUrl($creationParams) {
117
+        /*
118 118
 		USAGE:
119 119
 		(see $creationParams array in createMeetingArray method.)
120 120
 		*/
121
-		$this->_meetingId = $this->_requiredParam($creationParams['meetingId']);
122
-		$this->_meetingName = $this->_requiredParam($creationParams['meetingName']);
123
-		// Set up the basic creation URL:
124
-		$creationUrl = $this->_bbbServerBaseUrl."api/create?";
125
-		// Add params:
126
-		$params =
127
-		'name='.urlencode($this->_meetingName).
128
-		'&meetingID='.urlencode($this->_meetingId).
129
-		'&attendeePW='.urlencode($creationParams['attendeePw']).
130
-		'&moderatorPW='.urlencode($creationParams['moderatorPw']).
131
-		'&dialNumber='.urlencode($creationParams['dialNumber']).
132
-		'&voiceBridge='.urlencode($creationParams['voiceBridge']).
133
-		'&webVoice='.urlencode($creationParams['webVoice']).
134
-		'&logoutURL='.urlencode($creationParams['logoutUrl']).
135
-		'&maxParticipants='.urlencode($creationParams['maxParticipants']).
136
-		'&record='.urlencode($creationParams['record']).
137
-		'&duration='.urlencode($creationParams['duration']);
138
-		//'&meta_category='.urlencode($creationParams['meta_category']);
139
-		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
141
-			$params .= '&welcome='.urlencode($welcomeMessage);
142
-		// Return the complete URL:
143
-		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144
-	}
145
-
146
-	public function createMeetingWithXmlResponseArray($creationParams) {
147
-		/*
121
+        $this->_meetingId = $this->_requiredParam($creationParams['meetingId']);
122
+        $this->_meetingName = $this->_requiredParam($creationParams['meetingName']);
123
+        // Set up the basic creation URL:
124
+        $creationUrl = $this->_bbbServerBaseUrl."api/create?";
125
+        // Add params:
126
+        $params =
127
+        'name='.urlencode($this->_meetingName).
128
+        '&meetingID='.urlencode($this->_meetingId).
129
+        '&attendeePW='.urlencode($creationParams['attendeePw']).
130
+        '&moderatorPW='.urlencode($creationParams['moderatorPw']).
131
+        '&dialNumber='.urlencode($creationParams['dialNumber']).
132
+        '&voiceBridge='.urlencode($creationParams['voiceBridge']).
133
+        '&webVoice='.urlencode($creationParams['webVoice']).
134
+        '&logoutURL='.urlencode($creationParams['logoutUrl']).
135
+        '&maxParticipants='.urlencode($creationParams['maxParticipants']).
136
+        '&record='.urlencode($creationParams['record']).
137
+        '&duration='.urlencode($creationParams['duration']);
138
+        //'&meta_category='.urlencode($creationParams['meta_category']);
139
+        $welcomeMessage = $creationParams['welcomeMsg'];
140
+        if(trim($welcomeMessage))
141
+            $params .= '&welcome='.urlencode($welcomeMessage);
142
+        // Return the complete URL:
143
+        return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144
+    }
145
+
146
+    public function createMeetingWithXmlResponseArray($creationParams) {
147
+        /*
148 148
 		USAGE:
149 149
 		$creationParams = array(
150 150
 			'name' => 'Meeting Name',	-- A name for the meeting (or username)
@@ -162,34 +162,34 @@  discard block
 block discarded – undo
162 162
 			'meta_category' => '', 		-- Use to pass additional info to BBB server. See API docs to enable.
163 163
 		);
164 164
 		*/
165
-		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
165
+        $xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 166
 
167 167
         if ($xml) {
168
-			if($xml->meetingID)
169
-				return array(
170
-					'returncode' => $xml->returncode,
171
-					'message' => $xml->message,
172
-					'messageKey' => $xml->messageKey,
173
-					'meetingId' => $xml->meetingID,
174
-					'attendeePw' => $xml->attendeePW,
175
-					'moderatorPw' => $xml->moderatorPW,
176
-					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
177
-					'createTime' => $xml->createTime
178
-					);
179
-			else
180
-				return array(
181
-					'returncode' => $xml->returncode,
182
-					'message' => $xml->message,
183
-					'messageKey' => $xml->messageKey
184
-					);
185
-		}
186
-		else {
187
-			return null;
188
-		}
189
-	}
190
-
191
-	public function getJoinMeetingURL($joinParams) {
192
-		/*
168
+            if($xml->meetingID)
169
+                return array(
170
+                    'returncode' => $xml->returncode,
171
+                    'message' => $xml->message,
172
+                    'messageKey' => $xml->messageKey,
173
+                    'meetingId' => $xml->meetingID,
174
+                    'attendeePw' => $xml->attendeePW,
175
+                    'moderatorPw' => $xml->moderatorPW,
176
+                    'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
177
+                    'createTime' => $xml->createTime
178
+                    );
179
+            else
180
+                return array(
181
+                    'returncode' => $xml->returncode,
182
+                    'message' => $xml->message,
183
+                    'messageKey' => $xml->messageKey
184
+                    );
185
+        }
186
+        else {
187
+            return null;
188
+        }
189
+    }
190
+
191
+    public function getJoinMeetingURL($joinParams) {
192
+        /*
193 193
 		NOTE: At this point, we don't use a corresponding joinMeetingWithXmlResponse here because the API
194 194
 		doesn't respond on success, but you can still code that method if you need it. Or, you can take the URL
195 195
 		that's returned from this method and simply send your users off to that URL in your code.
@@ -203,249 +203,249 @@  discard block
 block discarded – undo
203 203
 			'webVoiceConf' => ''		-- OPTIONAL - string
204 204
 		);
205 205
 		*/
206
-		$this->_meetingId = $this->_requiredParam($joinParams['meetingId']);
207
-		$this->_username = $this->_requiredParam($joinParams['username']);
208
-		$this->_password = $this->_requiredParam($joinParams['password']);
209
-		// Establish the basic join URL:
210
-		$joinUrl = $this->_bbbServerBaseUrl."api/join?";
211
-		// Add parameters to the URL:
212
-		$params =
213
-		'meetingID='.urlencode($this->_meetingId).
214
-		'&fullName='.urlencode($this->_username).
215
-		'&password='.urlencode($this->_password).
216
-		'&userID='.urlencode($joinParams['userId']).
217
-		'&webVoiceConf='.urlencode($joinParams['webVoiceConf']);
218
-		// Only use createTime if we really want to use it. If it's '', then don't pass it:
219
-		if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) {
220
-			$params .= '&createTime='.urlencode($joinParams['createTime']);
221
-		}
222
-		// Return the URL:
223
-		return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt));
224
-	}
225
-
226
-	public function getEndMeetingURL($endParams) {
227
-		/* USAGE:
206
+        $this->_meetingId = $this->_requiredParam($joinParams['meetingId']);
207
+        $this->_username = $this->_requiredParam($joinParams['username']);
208
+        $this->_password = $this->_requiredParam($joinParams['password']);
209
+        // Establish the basic join URL:
210
+        $joinUrl = $this->_bbbServerBaseUrl."api/join?";
211
+        // Add parameters to the URL:
212
+        $params =
213
+        'meetingID='.urlencode($this->_meetingId).
214
+        '&fullName='.urlencode($this->_username).
215
+        '&password='.urlencode($this->_password).
216
+        '&userID='.urlencode($joinParams['userId']).
217
+        '&webVoiceConf='.urlencode($joinParams['webVoiceConf']);
218
+        // Only use createTime if we really want to use it. If it's '', then don't pass it:
219
+        if (((isset($joinParams['createTime'])) && ($joinParams['createTime'] != ''))) {
220
+            $params .= '&createTime='.urlencode($joinParams['createTime']);
221
+        }
222
+        // Return the URL:
223
+        return ($joinUrl.$params.'&checksum='.sha1("join".$params.$this->_securitySalt));
224
+    }
225
+
226
+    public function getEndMeetingURL($endParams) {
227
+        /* USAGE:
228 228
 		$endParams = array (
229 229
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
230 230
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
231 231
 		);
232 232
 		*/
233
-		$this->_meetingId = $this->_requiredParam($endParams['meetingId']);
234
-		$this->_password = $this->_requiredParam($endParams['password']);
235
-		$endUrl = $this->_bbbServerBaseUrl."api/end?";
236
-		$params =
237
-		'meetingID='.urlencode($this->_meetingId).
238
-		'&password='.urlencode($this->_password);
239
-		return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt));
240
-	}
241
-
242
-	public function endMeetingWithXmlResponseArray($endParams) {
243
-		/* USAGE:
233
+        $this->_meetingId = $this->_requiredParam($endParams['meetingId']);
234
+        $this->_password = $this->_requiredParam($endParams['password']);
235
+        $endUrl = $this->_bbbServerBaseUrl."api/end?";
236
+        $params =
237
+        'meetingID='.urlencode($this->_meetingId).
238
+        '&password='.urlencode($this->_password);
239
+        return ($endUrl.$params.'&checksum='.sha1("end".$params.$this->_securitySalt));
240
+    }
241
+
242
+    public function endMeetingWithXmlResponseArray($endParams) {
243
+        /* USAGE:
244 244
 		$endParams = array (
245 245
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
246 246
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
247 247
 		);
248 248
 		*/
249
-		$xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
250
-		if ($xml) {
251
-			return array(
252
-				'returncode' => $xml->returncode,
253
-				'message' => $xml->message,
254
-				'messageKey' => $xml->messageKey
255
-				);
256
-		}
257
-		else {
258
-			return null;
259
-		}
260
-
261
-	}
262
-
263
-	/* __________________ BBB MONITORING METHODS _________________ */
264
-	/* The methods in the following section support the following categories of the BBB API:
249
+        $xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
250
+        if ($xml) {
251
+            return array(
252
+                'returncode' => $xml->returncode,
253
+                'message' => $xml->message,
254
+                'messageKey' => $xml->messageKey
255
+                );
256
+        }
257
+        else {
258
+            return null;
259
+        }
260
+
261
+    }
262
+
263
+    /* __________________ BBB MONITORING METHODS _________________ */
264
+    /* The methods in the following section support the following categories of the BBB API:
265 265
 	-- isMeetingRunning
266 266
 	-- getMeetings
267 267
 	-- getMeetingInfo
268 268
 	*/
269 269
 
270
-	public function getIsMeetingRunningUrl($meetingId) {
271
-		/* USAGE:
270
+    public function getIsMeetingRunningUrl($meetingId) {
271
+        /* USAGE:
272 272
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
273 273
 		*/
274
-		$this->_meetingId = $this->_requiredParam($meetingId);
275
-		$runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?";
276
-		$params =
277
-		'meetingID='.urlencode($this->_meetingId);
278
-		return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt));
279
-	}
280
-
281
-	public function isMeetingRunningWithXmlResponseArray($meetingId) {
282
-		/* USAGE:
274
+        $this->_meetingId = $this->_requiredParam($meetingId);
275
+        $runningUrl = $this->_bbbServerBaseUrl."api/isMeetingRunning?";
276
+        $params =
277
+        'meetingID='.urlencode($this->_meetingId);
278
+        return ($runningUrl.$params.'&checksum='.sha1("isMeetingRunning".$params.$this->_securitySalt));
279
+    }
280
+
281
+    public function isMeetingRunningWithXmlResponseArray($meetingId) {
282
+        /* USAGE:
283 283
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
284 284
 		*/
285
-		$xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
-		if($xml) {
287
-			return array(
288
-				'returncode' => $xml->returncode,
289
-				'running' => $xml->running 	// -- Returns true/false.
290
-				);
291
-		}
292
-		else {
293
-			return null;
294
-		}
295
-
296
-	}
297
-
298
-	public function getGetMeetingsUrl() {
299
-		/* Simply formulate the getMeetings URL
285
+        $xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
+        if($xml) {
287
+            return array(
288
+                'returncode' => $xml->returncode,
289
+                'running' => $xml->running 	// -- Returns true/false.
290
+                );
291
+        }
292
+        else {
293
+            return null;
294
+        }
295
+
296
+    }
297
+
298
+    public function getGetMeetingsUrl() {
299
+        /* Simply formulate the getMeetings URL
300 300
 		We do this in a separate function so we have the option to just get this
301 301
 		URL and print it if we want for some reason.
302 302
 		*/
303
-		$getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt);
304
-		return $getMeetingsUrl;
305
-	}
303
+        $getMeetingsUrl = $this->_bbbServerBaseUrl."api/getMeetings?checksum=".sha1("getMeetings".$this->_securitySalt);
304
+        return $getMeetingsUrl;
305
+    }
306 306
 
307
-	public function getMeetingsWithXmlResponseArray() {
308
-		/* USAGE:
307
+    public function getMeetingsWithXmlResponseArray() {
308
+        /* USAGE:
309 309
 		We don't need to pass any parameters with this one, so we just send the query URL off to BBB
310 310
 		and then handle the results that we get in the XML response.
311 311
 		*/
312
-		$xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
-		if($xml) {
314
-			// If we don't get a success code, stop processing and return just the returncode:
315
-			if ($xml->returncode != 'SUCCESS') {
316
-				$result = array(
317
-					'returncode' => $xml->returncode
318
-				);
319
-				return $result;
320
-			}
321
-			elseif ($xml->messageKey == 'noMeetings') {
322
-				/* No meetings on server, so return just this info: */
323
-				$result = array(
324
-					'returncode' => $xml->returncode,
325
-					'messageKey' => $xml->messageKey,
326
-					'message' => $xml->message
327
-				);
328
-				return $result;
329
-			}
330
-			else {
331
-				// In this case, we have success and meetings. First return general response:
332
-				$result = array(
333
-					'returncode' => $xml->returncode,
334
-					'messageKey' => $xml->messageKey,
335
-					'message' => $xml->message
336
-				);
337
-				// Then interate through meeting results and return them as part of the array:
338
-				foreach ($xml->meetings->meeting as $m) {
339
-					$result[] = array(
340
-						'meetingId' => $m->meetingID,
341
-						'meetingName' => $m->meetingName,
342
-						'createTime' => $m->createTime,
343
-						'attendeePw' => $m->attendeePW,
344
-						'moderatorPw' => $m->moderatorPW,
345
-						'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded,
346
-						'running' => $m->running
347
-						);
348
-					}
349
-				return $result;
350
-			}
351
-		}
352
-		else {
353
-			return null;
354
-		}
355
-
356
-	}
357
-
358
-	public function getMeetingInfoUrl($infoParams) {
359
-		/* USAGE:
312
+        $xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
+        if($xml) {
314
+            // If we don't get a success code, stop processing and return just the returncode:
315
+            if ($xml->returncode != 'SUCCESS') {
316
+                $result = array(
317
+                    'returncode' => $xml->returncode
318
+                );
319
+                return $result;
320
+            }
321
+            elseif ($xml->messageKey == 'noMeetings') {
322
+                /* No meetings on server, so return just this info: */
323
+                $result = array(
324
+                    'returncode' => $xml->returncode,
325
+                    'messageKey' => $xml->messageKey,
326
+                    'message' => $xml->message
327
+                );
328
+                return $result;
329
+            }
330
+            else {
331
+                // In this case, we have success and meetings. First return general response:
332
+                $result = array(
333
+                    'returncode' => $xml->returncode,
334
+                    'messageKey' => $xml->messageKey,
335
+                    'message' => $xml->message
336
+                );
337
+                // Then interate through meeting results and return them as part of the array:
338
+                foreach ($xml->meetings->meeting as $m) {
339
+                    $result[] = array(
340
+                        'meetingId' => $m->meetingID,
341
+                        'meetingName' => $m->meetingName,
342
+                        'createTime' => $m->createTime,
343
+                        'attendeePw' => $m->attendeePW,
344
+                        'moderatorPw' => $m->moderatorPW,
345
+                        'hasBeenForciblyEnded' => $m->hasBeenForciblyEnded,
346
+                        'running' => $m->running
347
+                        );
348
+                    }
349
+                return $result;
350
+            }
351
+        }
352
+        else {
353
+            return null;
354
+        }
355
+
356
+    }
357
+
358
+    public function getMeetingInfoUrl($infoParams) {
359
+        /* USAGE:
360 360
 		$infoParams = array(
361 361
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
362 362
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
363 363
 		);
364 364
 		*/
365
-		$this->_meetingId = $this->_requiredParam($infoParams['meetingId']);
366
-		$this->_password = $this->_requiredParam($infoParams['password']);
367
-		$infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?";
368
-		$params =
369
-		'meetingID='.urlencode($this->_meetingId).
370
-		'&password='.urlencode($this->_password);
371
-		return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt));
372
-	}
373
-
374
-	public function getMeetingInfoWithXmlResponseArray($infoParams) {
375
-		/* USAGE:
365
+        $this->_meetingId = $this->_requiredParam($infoParams['meetingId']);
366
+        $this->_password = $this->_requiredParam($infoParams['password']);
367
+        $infoUrl = $this->_bbbServerBaseUrl."api/getMeetingInfo?";
368
+        $params =
369
+        'meetingID='.urlencode($this->_meetingId).
370
+        '&password='.urlencode($this->_password);
371
+        return ($infoUrl.$params.'&checksum='.sha1("getMeetingInfo".$params.$this->_securitySalt));
372
+    }
373
+
374
+    public function getMeetingInfoWithXmlResponseArray($infoParams) {
375
+        /* USAGE:
376 376
 		$infoParams = array(
377 377
 			'meetingId' => '1234',		-- REQUIRED - The unique id for the meeting
378 378
 			'password' => 'mp'			-- REQUIRED - The moderator password for the meeting
379 379
 		);
380 380
 		*/
381
-		$xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
-		if($xml) {
383
-			// If we don't get a success code or messageKey, find out why:
384
-			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385
-				$result = array(
386
-					'returncode' => $xml->returncode,
387
-					'messageKey' => $xml->messageKey,
388
-					'message' => $xml->message
389
-				);
390
-				return $result;
391
-			}
392
-			else {
393
-				// In this case, we have success and meeting info:
394
-				$result = array(
395
-					'returncode' => $xml->returncode,
396
-					'meetingName' => $xml->meetingName,
397
-					'meetingId' => $xml->meetingID,
398
-					'createTime' => $xml->createTime,
399
-					'voiceBridge' => $xml->voiceBridge,
400
-					'attendeePw' => $xml->attendeePW,
401
-					'moderatorPw' => $xml->moderatorPW,
402
-					'running' => $xml->running,
403
-					'recording' => $xml->recording,
404
-					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
405
-					'startTime' => $xml->startTime,
406
-					'endTime' => $xml->endTime,
407
-					'participantCount' => $xml->participantCount,
408
-					'maxUsers' => $xml->maxUsers,
409
-					'moderatorCount' => $xml->moderatorCount,
410
-				);
411
-				// Then interate through attendee results and return them as part of the array:
412
-				foreach ($xml->attendees->attendee as $a) {
413
-					$result[] = array(
414
-						'userId' => $a->userID,
415
-						'fullName' => $a->fullName,
416
-						'role' => $a->role
417
-						);
418
-					}
419
-				return $result;
420
-			}
421
-		}
422
-		else {
423
-			return null;
424
-		}
425
-
426
-	}
427
-
428
-	/* __________________ BBB RECORDING METHODS _________________ */
429
-	/* The methods in the following section support the following categories of the BBB API:
381
+        $xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
+        if($xml) {
383
+            // If we don't get a success code or messageKey, find out why:
384
+            if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385
+                $result = array(
386
+                    'returncode' => $xml->returncode,
387
+                    'messageKey' => $xml->messageKey,
388
+                    'message' => $xml->message
389
+                );
390
+                return $result;
391
+            }
392
+            else {
393
+                // In this case, we have success and meeting info:
394
+                $result = array(
395
+                    'returncode' => $xml->returncode,
396
+                    'meetingName' => $xml->meetingName,
397
+                    'meetingId' => $xml->meetingID,
398
+                    'createTime' => $xml->createTime,
399
+                    'voiceBridge' => $xml->voiceBridge,
400
+                    'attendeePw' => $xml->attendeePW,
401
+                    'moderatorPw' => $xml->moderatorPW,
402
+                    'running' => $xml->running,
403
+                    'recording' => $xml->recording,
404
+                    'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
405
+                    'startTime' => $xml->startTime,
406
+                    'endTime' => $xml->endTime,
407
+                    'participantCount' => $xml->participantCount,
408
+                    'maxUsers' => $xml->maxUsers,
409
+                    'moderatorCount' => $xml->moderatorCount,
410
+                );
411
+                // Then interate through attendee results and return them as part of the array:
412
+                foreach ($xml->attendees->attendee as $a) {
413
+                    $result[] = array(
414
+                        'userId' => $a->userID,
415
+                        'fullName' => $a->fullName,
416
+                        'role' => $a->role
417
+                        );
418
+                    }
419
+                return $result;
420
+            }
421
+        }
422
+        else {
423
+            return null;
424
+        }
425
+
426
+    }
427
+
428
+    /* __________________ BBB RECORDING METHODS _________________ */
429
+    /* The methods in the following section support the following categories of the BBB API:
430 430
 	-- getRecordings
431 431
 	-- publishRecordings
432 432
 	-- deleteRecordings
433 433
 	*/
434 434
 
435
-	public function getRecordingsUrl($recordingParams) {
436
-		/* USAGE:
435
+    public function getRecordingsUrl($recordingParams) {
436
+        /* USAGE:
437 437
 		$recordingParams = array(
438 438
 			'meetingId' => '1234',		-- OPTIONAL - comma separate if multiple ids
439 439
 		);
440 440
 		*/
441
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?";
442
-		$params = 'meetingID='.urlencode($recordingParams['meetingId']);
443
-		return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt));
441
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/getRecordings?";
442
+        $params = 'meetingID='.urlencode($recordingParams['meetingId']);
443
+        return ($recordingsUrl.$params.'&checksum='.sha1("getRecordings".$params.$this->_securitySalt));
444 444
 
445
-	}
445
+    }
446 446
 
447
-	public function getRecordingsWithXmlResponseArray($recordingParams) {
448
-		/* USAGE:
447
+    public function getRecordingsWithXmlResponseArray($recordingParams) {
448
+        /* USAGE:
449 449
 		$recordingParams = array(
450 450
 			'meetingId' => '1234',		-- OPTIONAL - comma separate if multiple ids
451 451
 		);
@@ -453,121 +453,121 @@  discard block
 block discarded – undo
453 453
 		when creating a meeting, it will kick users out after the duration. Should
454 454
 		probably be required in user code when 'recording' is set to true.
455 455
 		*/
456
-		$xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
-		if($xml) {
458
-			// If we don't get a success code or messageKey, find out why:
459
-			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460
-				$result = array(
461
-					'returncode' => $xml->returncode,
462
-					'messageKey' => $xml->messageKey,
463
-					'message' => $xml->message
464
-				);
465
-				return $result;
466
-			}
467
-			else {
468
-				// In this case, we have success and recording info:
469
-				$result = array(
470
-					'returncode' => $xml->returncode,
471
-					'messageKey' => $xml->messageKey,
472
-					'message' => $xml->message
473
-				);
474
-
475
-				foreach ($xml->recordings->recording as $r) {
476
-					$result[] = array(
477
-						'recordId' => $r->recordID,
478
-						'meetingId' => $r->meetingID,
479
-						'name' => $r->name,
480
-						'published' => $r->published,
481
-						'startTime' => $r->startTime,
482
-						'endTime' => $r->endTime,
483
-						'playbackFormatType' => $r->playback->format->type,
484
-						'playbackFormatUrl' => $r->playback->format->url,
485
-						'playbackFormatLength' => $r->playback->format->length,
486
-						'metadataTitle' => $r->metadata->title,
487
-						'metadataSubject' => $r->metadata->subject,
488
-						'metadataDescription' => $r->metadata->description,
489
-						'metadataCreator' => $r->metadata->creator,
490
-						'metadataContributor' => $r->metadata->contributor,
491
-						'metadataLanguage' => $r->metadata->language,
492
-						// Add more here as needed for your app depending on your
493
-						// use of metadata when creating recordings.
494
-						);
495
-					}
496
-				return $result;
497
-			}
498
-		}
499
-		else {
500
-			return null;
501
-		}
502
-	}
503
-
504
-	public function getPublishRecordingsUrl($recordingParams) {
505
-		/* USAGE:
456
+        $xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
+        if($xml) {
458
+            // If we don't get a success code or messageKey, find out why:
459
+            if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460
+                $result = array(
461
+                    'returncode' => $xml->returncode,
462
+                    'messageKey' => $xml->messageKey,
463
+                    'message' => $xml->message
464
+                );
465
+                return $result;
466
+            }
467
+            else {
468
+                // In this case, we have success and recording info:
469
+                $result = array(
470
+                    'returncode' => $xml->returncode,
471
+                    'messageKey' => $xml->messageKey,
472
+                    'message' => $xml->message
473
+                );
474
+
475
+                foreach ($xml->recordings->recording as $r) {
476
+                    $result[] = array(
477
+                        'recordId' => $r->recordID,
478
+                        'meetingId' => $r->meetingID,
479
+                        'name' => $r->name,
480
+                        'published' => $r->published,
481
+                        'startTime' => $r->startTime,
482
+                        'endTime' => $r->endTime,
483
+                        'playbackFormatType' => $r->playback->format->type,
484
+                        'playbackFormatUrl' => $r->playback->format->url,
485
+                        'playbackFormatLength' => $r->playback->format->length,
486
+                        'metadataTitle' => $r->metadata->title,
487
+                        'metadataSubject' => $r->metadata->subject,
488
+                        'metadataDescription' => $r->metadata->description,
489
+                        'metadataCreator' => $r->metadata->creator,
490
+                        'metadataContributor' => $r->metadata->contributor,
491
+                        'metadataLanguage' => $r->metadata->language,
492
+                        // Add more here as needed for your app depending on your
493
+                        // use of metadata when creating recordings.
494
+                        );
495
+                    }
496
+                return $result;
497
+            }
498
+        }
499
+        else {
500
+            return null;
501
+        }
502
+    }
503
+
504
+    public function getPublishRecordingsUrl($recordingParams) {
505
+        /* USAGE:
506 506
 		$recordingParams = array(
507 507
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
508 508
 			'publish' => 'true',		-- REQUIRED - boolean: true/false
509 509
 		);
510 510
 		*/
511
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?";
512
-		$params =
513
-		'recordID='.urlencode($recordingParams['recordId']).
514
-		'&publish='.urlencode($recordingParams['publish']);
515
-		return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt));
511
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/publishRecordings?";
512
+        $params =
513
+        'recordID='.urlencode($recordingParams['recordId']).
514
+        '&publish='.urlencode($recordingParams['publish']);
515
+        return ($recordingsUrl.$params.'&checksum='.sha1("publishRecordings".$params.$this->_securitySalt));
516 516
 
517
-	}
517
+    }
518 518
 
519
-	public function publishRecordingsWithXmlResponseArray($recordingParams) {
520
-		/* USAGE:
519
+    public function publishRecordingsWithXmlResponseArray($recordingParams) {
520
+        /* USAGE:
521 521
 		$recordingParams = array(
522 522
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
523 523
 			'publish' => 'true',		-- REQUIRED - boolean: true/false
524 524
 		);
525 525
 		*/
526
-		$xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
-		if($xml) {
528
-			return array(
529
-				'returncode' => $xml->returncode,
530
-				'published' => $xml->published 	// -- Returns true/false.
531
-				);
532
-		}
533
-		else {
534
-			return null;
535
-		}
536
-
537
-
538
-	}
539
-
540
-	public function getDeleteRecordingsUrl($recordingParams) {
541
-		/* USAGE:
526
+        $xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
+        if($xml) {
528
+            return array(
529
+                'returncode' => $xml->returncode,
530
+                'published' => $xml->published 	// -- Returns true/false.
531
+                );
532
+        }
533
+        else {
534
+            return null;
535
+        }
536
+
537
+
538
+    }
539
+
540
+    public function getDeleteRecordingsUrl($recordingParams) {
541
+        /* USAGE:
542 542
 		$recordingParams = array(
543 543
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
544 544
 		);
545 545
 		*/
546
-		$recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?";
547
-		$params =
548
-		'recordID='.urlencode($recordingParams['recordId']);
549
-		return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt));
550
-	}
551
-
552
-	public function deleteRecordingsWithXmlResponseArray($recordingParams) {
553
-		/* USAGE:
546
+        $recordingsUrl = $this->_bbbServerBaseUrl."api/deleteRecordings?";
547
+        $params =
548
+        'recordID='.urlencode($recordingParams['recordId']);
549
+        return ($recordingsUrl.$params.'&checksum='.sha1("deleteRecordings".$params.$this->_securitySalt));
550
+    }
551
+
552
+    public function deleteRecordingsWithXmlResponseArray($recordingParams) {
553
+        /* USAGE:
554 554
 		$recordingParams = array(
555 555
 			'recordId' => '1234',		-- REQUIRED - comma separate if multiple ids
556 556
 		);
557 557
 		*/
558 558
 
559
-		$xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
-		if($xml) {
561
-			return array(
562
-				'returncode' => $xml->returncode,
563
-				'deleted' => $xml->deleted 	// -- Returns true/false.
564
-				);
565
-		}
566
-		else {
567
-			return null;
568
-		}
569
-
570
-	}
559
+        $xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
+        if($xml) {
561
+            return array(
562
+                'returncode' => $xml->returncode,
563
+                'deleted' => $xml->deleted 	// -- Returns true/false.
564
+                );
565
+        }
566
+        else {
567
+            return null;
568
+        }
569
+
570
+    }
571 571
 
572 572
 
573 573
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
 	*/
56 56
 		// BASE CONFIGS - set these for your BBB server in config.php and they will
57 57
 		// simply flow in here via the constants:
58
-		$this->_securitySalt 		= CONFIG_SECURITY_SALT;
59
-		$this->_bbbServerBaseUrl 	= CONFIG_SERVER_BASE_URL;
58
+		$this->_securitySalt = CONFIG_SECURITY_SALT;
59
+		$this->_bbbServerBaseUrl = CONFIG_SERVER_BASE_URL;
60 60
 	}
61 61
 
62
-	private function _processXmlResponse($url){
62
+	private function _processXmlResponse($url) {
63 63
 	/*
64 64
 	A private utility method used by other public methods to process XML responses.
65 65
 	*/
66 66
 		if (extension_loaded('curl')) {
67
-			$ch = curl_init() or die ( curl_error($ch) );
67
+			$ch = curl_init() or die (curl_error($ch));
68 68
 			$timeout = 10;
69
-			curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
70
-			curl_setopt( $ch, CURLOPT_URL, $url );
71
-			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
72
-			curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
-			$data = curl_exec( $ch );
74
-			curl_close( $ch );
75
-
76
-			if($data)
69
+			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
70
+			curl_setopt($ch, CURLOPT_URL, $url);
71
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
72
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
73
+			$data = curl_exec($ch);
74
+			curl_close($ch);
75
+
76
+			if ($data)
77 77
 				return (new SimpleXMLElement($data));
78 78
 			else
79 79
 				return false;
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 		'&duration='.urlencode($creationParams['duration']);
138 138
 		//'&meta_category='.urlencode($creationParams['meta_category']);
139 139
 		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
140
+		if (trim($welcomeMessage))
141 141
 			$params .= '&welcome='.urlencode($welcomeMessage);
142 142
 		// Return the complete URL:
143
-		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
143
+		return ($creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt));
144 144
 	}
145 145
 
146 146
 	public function createMeetingWithXmlResponseArray($creationParams) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 166
 
167 167
         if ($xml) {
168
-			if($xml->meetingID)
168
+			if ($xml->meetingID)
169 169
 				return array(
170 170
 					'returncode' => $xml->returncode,
171 171
 					'message' => $xml->message,
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		$meetingId = '1234'		-- REQUIRED - The unique id for the meeting
284 284
 		*/
285 285
 		$xml = $this->_processXmlResponse($this->getIsMeetingRunningUrl($meetingId));
286
-		if($xml) {
286
+		if ($xml) {
287 287
 			return array(
288 288
 				'returncode' => $xml->returncode,
289 289
 				'running' => $xml->running 	// -- Returns true/false.
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		and then handle the results that we get in the XML response.
311 311
 		*/
312 312
 		$xml = $this->_processXmlResponse($this->getGetMeetingsUrl());
313
-		if($xml) {
313
+		if ($xml) {
314 314
 			// If we don't get a success code, stop processing and return just the returncode:
315 315
 			if ($xml->returncode != 'SUCCESS') {
316 316
 				$result = array(
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		);
380 380
 		*/
381 381
 		$xml = $this->_processXmlResponse($this->getMeetingInfoUrl($infoParams));
382
-		if($xml) {
382
+		if ($xml) {
383 383
 			// If we don't get a success code or messageKey, find out why:
384 384
 			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
385 385
 				$result = array(
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		probably be required in user code when 'recording' is set to true.
455 455
 		*/
456 456
 		$xml = $this->_processXmlResponse($this->getRecordingsUrl($recordingParams));
457
-		if($xml) {
457
+		if ($xml) {
458 458
 			// If we don't get a success code or messageKey, find out why:
459 459
 			if (($xml->returncode != 'SUCCESS') || ($xml->messageKey == null)) {
460 460
 				$result = array(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 		);
525 525
 		*/
526 526
 		$xml = $this->_processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
527
-		if($xml) {
527
+		if ($xml) {
528 528
 			return array(
529 529
 				'returncode' => $xml->returncode,
530 530
 				'published' => $xml->published 	// -- Returns true/false.
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		*/
558 558
 
559 559
 		$xml = $this->_processXmlResponse($this->getDeleteRecordingsUrl($recordingParams));
560
-		if($xml) {
560
+		if ($xml) {
561 561
 			return array(
562 562
 				'returncode' => $xml->returncode,
563 563
 				'deleted' => $xml->deleted 	// -- Returns true/false.
Please login to merge, or discard this patch.
Braces   +28 added lines, -40 removed lines patch added patch discarded remove patch
@@ -73,10 +73,11 @@  discard block
 block discarded – undo
73 73
 			$data = curl_exec( $ch );
74 74
 			curl_close( $ch );
75 75
 
76
-			if($data)
77
-				return (new SimpleXMLElement($data));
78
-			else
79
-				return false;
76
+			if($data) {
77
+							return (new SimpleXMLElement($data));
78
+			} else {
79
+							return false;
80
+			}
80 81
 		}
81 82
 		return (simplexml_load_file($url));
82 83
 	}
@@ -85,11 +86,9 @@  discard block
 block discarded – undo
85 86
 		/* Process required params and throw errors if we don't get values */
86 87
 		if ((isset($param)) && ($param != '')) {
87 88
 			return $param;
88
-		}
89
-		elseif (!isset($param)) {
89
+		} elseif (!isset($param)) {
90 90
 			throw new Exception('Missing parameter.');
91
-		}
92
-		else {
91
+		} else {
93 92
 			throw new Exception(''.$param.' is required.');
94 93
 		}
95 94
 	}
@@ -99,8 +98,7 @@  discard block
 block discarded – undo
99 98
 		/* Don't know if we'll use this one, but let's build it in case. */
100 99
 		if ((isset($param)) && ($param != '')) {
101 100
 			return $param;
102
-		}
103
-		else {
101
+		} else {
104 102
 			$param = '';
105 103
 			return $param;
106 104
 		}
@@ -137,8 +135,9 @@  discard block
 block discarded – undo
137 135
 		'&duration='.urlencode($creationParams['duration']);
138 136
 		//'&meta_category='.urlencode($creationParams['meta_category']);
139 137
 		$welcomeMessage = $creationParams['welcomeMsg'];
140
-		if(trim($welcomeMessage))
141
-			$params .= '&welcome='.urlencode($welcomeMessage);
138
+		if(trim($welcomeMessage)) {
139
+					$params .= '&welcome='.urlencode($welcomeMessage);
140
+		}
142 141
 		// Return the complete URL:
143 142
 		return ( $creationUrl.$params.'&checksum='.sha1("create".$params.$this->_securitySalt) );
144 143
 	}
@@ -165,8 +164,8 @@  discard block
 block discarded – undo
165 164
 		$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
166 165
 
167 166
         if ($xml) {
168
-			if($xml->meetingID)
169
-				return array(
167
+			if($xml->meetingID) {
168
+							return array(
170 169
 					'returncode' => $xml->returncode,
171 170
 					'message' => $xml->message,
172 171
 					'messageKey' => $xml->messageKey,
@@ -176,14 +175,14 @@  discard block
 block discarded – undo
176 175
 					'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded,
177 176
 					'createTime' => $xml->createTime
178 177
 					);
179
-			else
180
-				return array(
178
+			} else {
179
+							return array(
181 180
 					'returncode' => $xml->returncode,
182 181
 					'message' => $xml->message,
183 182
 					'messageKey' => $xml->messageKey
184 183
 					);
185
-		}
186
-		else {
184
+			}
185
+		} else {
187 186
 			return null;
188 187
 		}
189 188
 	}
@@ -253,8 +252,7 @@  discard block
 block discarded – undo
253 252
 				'message' => $xml->message,
254 253
 				'messageKey' => $xml->messageKey
255 254
 				);
256
-		}
257
-		else {
255
+		} else {
258 256
 			return null;
259 257
 		}
260 258
 
@@ -288,8 +286,7 @@  discard block
 block discarded – undo
288 286
 				'returncode' => $xml->returncode,
289 287
 				'running' => $xml->running 	// -- Returns true/false.
290 288
 				);
291
-		}
292
-		else {
289
+		} else {
293 290
 			return null;
294 291
 		}
295 292
 
@@ -317,8 +314,7 @@  discard block
 block discarded – undo
317 314
 					'returncode' => $xml->returncode
318 315
 				);
319 316
 				return $result;
320
-			}
321
-			elseif ($xml->messageKey == 'noMeetings') {
317
+			} elseif ($xml->messageKey == 'noMeetings') {
322 318
 				/* No meetings on server, so return just this info: */
323 319
 				$result = array(
324 320
 					'returncode' => $xml->returncode,
@@ -326,8 +322,7 @@  discard block
 block discarded – undo
326 322
 					'message' => $xml->message
327 323
 				);
328 324
 				return $result;
329
-			}
330
-			else {
325
+			} else {
331 326
 				// In this case, we have success and meetings. First return general response:
332 327
 				$result = array(
333 328
 					'returncode' => $xml->returncode,
@@ -348,8 +343,7 @@  discard block
 block discarded – undo
348 343
 					}
349 344
 				return $result;
350 345
 			}
351
-		}
352
-		else {
346
+		} else {
353 347
 			return null;
354 348
 		}
355 349
 
@@ -388,8 +382,7 @@  discard block
 block discarded – undo
388 382
 					'message' => $xml->message
389 383
 				);
390 384
 				return $result;
391
-			}
392
-			else {
385
+			} else {
393 386
 				// In this case, we have success and meeting info:
394 387
 				$result = array(
395 388
 					'returncode' => $xml->returncode,
@@ -418,8 +411,7 @@  discard block
 block discarded – undo
418 411
 					}
419 412
 				return $result;
420 413
 			}
421
-		}
422
-		else {
414
+		} else {
423 415
 			return null;
424 416
 		}
425 417
 
@@ -463,8 +455,7 @@  discard block
 block discarded – undo
463 455
 					'message' => $xml->message
464 456
 				);
465 457
 				return $result;
466
-			}
467
-			else {
458
+			} else {
468 459
 				// In this case, we have success and recording info:
469 460
 				$result = array(
470 461
 					'returncode' => $xml->returncode,
@@ -495,8 +486,7 @@  discard block
 block discarded – undo
495 486
 					}
496 487
 				return $result;
497 488
 			}
498
-		}
499
-		else {
489
+		} else {
500 490
 			return null;
501 491
 		}
502 492
 	}
@@ -529,8 +519,7 @@  discard block
 block discarded – undo
529 519
 				'returncode' => $xml->returncode,
530 520
 				'published' => $xml->published 	// -- Returns true/false.
531 521
 				);
532
-		}
533
-		else {
522
+		} else {
534 523
 			return null;
535 524
 		}
536 525
 
@@ -562,8 +551,7 @@  discard block
 block discarded – undo
562 551
 				'returncode' => $xml->returncode,
563 552
 				'deleted' => $xml->deleted 	// -- Returns true/false.
564 553
 				);
565
-		}
566
-		else {
554
+		} else {
567 555
 			return null;
568 556
 		}
569 557
 
Please login to merge, or discard this patch.