Completed
Push — 1.11.x ( 55a6a1...a914dc )
by José
60:32 queued 35:06
created
main/gradebook/lib/be/studentpublicationlink.class.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@
 block discarded – undo
195 195
         $parentId = !$assignment ? 0 : $assignment->getId();
196 196
 
197 197
         if (empty($session)) {
198
-           $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
198
+            $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
199 199
                    WHERE
200 200
                         a.cId = :course AND
201 201
                         a.active = :active AND
Please login to merge, or discard this patch.
main/gradebook/lib/be/evaluation.class.php 1 patch
Indentation   +745 added lines, -745 removed lines patch added patch discarded remove patch
@@ -9,365 +9,365 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class Evaluation implements GradebookItem
11 11
 {
12
-	private $id;
13
-	private $name;
14
-	private $description;
15
-	private $user_id;
16
-	private $course_code;
17
-	/** @var Category */
18
-	private $category;
19
-	private $created_at;
20
-	private $weight;
21
-	private $eval_max;
22
-	private $visible;
23
-	private $sessionId;
24
-	public $studentList;
25
-
26
-	/**
27
-	 * Construct
28
-	 */
29
-	public function __construct()
30
-	{
31
-	}
32
-
33
-	/**
34
-	 * @return Category
35
-	 */
36
-	public function getCategory()
37
-	{
38
-		return $this->category;
39
-	}
40
-
41
-	/**
42
-	 * @param Category $category
43
-	 */
44
-	public function setCategory($category)
45
-	{
46
-		$this->category = $category;
47
-	}
48
-
49
-	/**
50
-	 * @return int
51
-	 */
52
-	public function get_category_id()
53
-	{
54
-		return $this->category->get_id();
55
-	}
56
-
57
-	/**
58
-	 * @param int $category_id
59
-	 */
60
-	public function set_category_id($category_id)
61
-	{
62
-		$categories = Category::load($category_id);
63
-		if (isset($categories[0])) {
64
-			$this->setCategory($categories[0]);
65
-		}
66
-	}
67
-
68
-	/**
69
-	 * @return int
70
-	 */
71
-	public function get_id()
72
-	{
73
-		return $this->id;
74
-	}
75
-
76
-	/**
77
-	 * @return string
78
-	 */
79
-	public function get_name()
80
-	{
81
-		return $this->name;
82
-	}
83
-
84
-	/**
85
-	 * @return string
86
-	 */
87
-	public function get_description()
88
-	{
89
-		return $this->description;
90
-	}
91
-
92
-	public function get_user_id()
93
-	{
94
-		return $this->user_id;
95
-	}
96
-
97
-	public function get_course_code()
98
-	{
99
-		return $this->course_code;
100
-	}
101
-
102
-	/**
103
-	 * @return int
104
-	 */
105
-	public function getSessionId()
106
-	{
107
-		return $this->sessionId;
108
-	}
109
-
110
-	/**
111
-	 * @param int $sessionId
112
-	 */
113
-	public function setSessionId($sessionId)
114
-	{
115
-		$this->sessionId = intval($sessionId);
116
-	}
117
-
118
-	public function get_date()
119
-	{
120
-		return $this->created_at;
121
-	}
122
-
123
-	public function get_weight()
124
-	{
125
-		return $this->weight;
126
-	}
127
-
128
-	public function get_max()
129
-	{
130
-		return $this->eval_max;
131
-	}
132
-
133
-	public function get_type()
134
-	{
135
-		return $this->type;
136
-	}
137
-
138
-	public function is_visible()
139
-	{
140
-		return $this->visible;
141
-	}
142
-
143
-	public function get_locked()
144
-	{
145
-		return $this->locked;
146
-	}
147
-
148
-	public function is_locked()
149
-	{
150
-		return isset($this->locked) && $this->locked == 1 ? true : false;
151
-	}
152
-
153
-	public function set_id($id)
154
-	{
155
-		$this->id = $id;
156
-	}
157
-
158
-	public function set_name($name)
159
-	{
160
-		$this->name = $name;
161
-	}
162
-
163
-	public function set_description($description)
164
-	{
165
-		$this->description = $description;
166
-	}
167
-
168
-	public function set_user_id($user_id)
169
-	{
170
-		$this->user_id = $user_id;
171
-	}
172
-
173
-	public function set_course_code($course_code)
174
-	{
175
-		$this->course_code = $course_code;
176
-	}
177
-
178
-	public function set_date($date)
179
-	{
180
-		$this->created_at = $date;
181
-	}
182
-
183
-	public function set_weight($weight)
184
-	{
185
-		$this->weight = $weight;
186
-	}
187
-
188
-	public function set_max($max)
189
-	{
190
-		$this->eval_max = $max;
191
-	}
192
-
193
-	public function set_visible($visible)
194
-	{
195
-		$this->visible = $visible;
196
-	}
197
-
198
-	public function set_type($type)
199
-	{
200
-		$this->type = $type;
201
-	}
202
-
203
-	public function set_locked($locked)
204
-	{
205
-		$this->locked = $locked;
206
-	}
207
-
208
-	/**
209
-	 * Retrieve evaluations and return them as an array of Evaluation objects
210
-	 * @param int $id evaluation id
211
-	 * @param int $user_id user id (evaluation owner)
212
-	 * @param string $course_code course code
213
-	 * @param int $category_id parent category
214
-	 * @param integer $visible visible
215
-	 */
216
-	public static function load(
217
-		$id = null,
218
-		$user_id = null,
219
-		$course_code = null,
220
-		$category_id = null,
221
-		$visible = null,
222
-		$locked = null
223
-	) {
224
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
225
-		$sql = 'SELECT * FROM '.$tbl_grade_evaluations;
226
-		$paramcount = 0;
227
-
228
-		if (isset ($id)) {
229
-			$sql.= ' WHERE id = '.intval($id);
230
-			$paramcount ++;
231
-		}
232
-
233
-		if (isset($user_id)) {
234
-			if ($paramcount != 0) $sql .= ' AND';
235
-			else $sql .= ' WHERE';
236
-			$sql .= ' user_id = '.intval($user_id);
237
-			$paramcount ++;
238
-		}
239
-
240
-		if (isset($course_code) && $course_code <> '-1') {
241
-			if ($paramcount != 0) $sql .= ' AND';
242
-			else $sql .= ' WHERE';
243
-			$sql .= " course_code = '".Database::escape_string($course_code)."'";
244
-			$paramcount ++;
245
-		}
246
-
247
-		if (isset($category_id)) {
248
-			if ($paramcount != 0) $sql .= ' AND';
249
-			else $sql .= ' WHERE';
250
-			$sql .= ' category_id = '.intval($category_id);
251
-			$paramcount ++;
252
-		}
253
-
254
-		if (isset($visible)) {
255
-			if ($paramcount != 0) $sql .= ' AND';
256
-			else $sql .= ' WHERE';
257
-			$sql .= ' visible = '.intval($visible);
258
-			$paramcount ++;
259
-		}
260
-
261
-		if (isset($locked)) {
262
-			if ($paramcount != 0) $sql .= ' AND';
263
-			else $sql .= ' WHERE';
264
-			$sql .= ' locked = '.intval($locked);
265
-		}
266
-
267
-		$result = Database::query($sql);
268
-		$allEval = Evaluation::create_evaluation_objects_from_sql_result($result);
269
-
270
-		return $allEval;
271
-	}
272
-
273
-	/**
274
-	 * @param array $result
275
-	 * @return array
276
-	 */
277
-	private static function create_evaluation_objects_from_sql_result($result)
278
-	{
279
-		$alleval = array();
280
-		if (Database::num_rows($result)) {
281
-			while ($data = Database::fetch_array($result)) {
282
-				$eval= new Evaluation();
283
-				$eval->set_id($data['id']);
284
-				$eval->set_name($data['name']);
285
-				$eval->set_description($data['description']);
286
-				$eval->set_user_id($data['user_id']);
287
-				$eval->set_course_code($data['course_code']);
288
-				$eval->set_category_id($data['category_id']);
289
-				$eval->set_date(api_get_local_time($data['created_at']));
290
-				$eval->set_weight($data['weight']);
291
-				$eval->set_max($data['max']);
292
-				$eval->set_visible($data['visible']);
293
-				$eval->set_type($data['type']);
294
-				$eval->set_locked($data['locked']);
295
-				$eval->setSessionId(api_get_session_id());
296
-
297
-				$alleval[] = $eval;
298
-			}
299
-		}
300
-
301
-		return $alleval;
302
-	}
303
-
304
-	/**
305
-	 * Insert this evaluation into the database
306
-	 */
12
+    private $id;
13
+    private $name;
14
+    private $description;
15
+    private $user_id;
16
+    private $course_code;
17
+    /** @var Category */
18
+    private $category;
19
+    private $created_at;
20
+    private $weight;
21
+    private $eval_max;
22
+    private $visible;
23
+    private $sessionId;
24
+    public $studentList;
25
+
26
+    /**
27
+     * Construct
28
+     */
29
+    public function __construct()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * @return Category
35
+     */
36
+    public function getCategory()
37
+    {
38
+        return $this->category;
39
+    }
40
+
41
+    /**
42
+     * @param Category $category
43
+     */
44
+    public function setCategory($category)
45
+    {
46
+        $this->category = $category;
47
+    }
48
+
49
+    /**
50
+     * @return int
51
+     */
52
+    public function get_category_id()
53
+    {
54
+        return $this->category->get_id();
55
+    }
56
+
57
+    /**
58
+     * @param int $category_id
59
+     */
60
+    public function set_category_id($category_id)
61
+    {
62
+        $categories = Category::load($category_id);
63
+        if (isset($categories[0])) {
64
+            $this->setCategory($categories[0]);
65
+        }
66
+    }
67
+
68
+    /**
69
+     * @return int
70
+     */
71
+    public function get_id()
72
+    {
73
+        return $this->id;
74
+    }
75
+
76
+    /**
77
+     * @return string
78
+     */
79
+    public function get_name()
80
+    {
81
+        return $this->name;
82
+    }
83
+
84
+    /**
85
+     * @return string
86
+     */
87
+    public function get_description()
88
+    {
89
+        return $this->description;
90
+    }
91
+
92
+    public function get_user_id()
93
+    {
94
+        return $this->user_id;
95
+    }
96
+
97
+    public function get_course_code()
98
+    {
99
+        return $this->course_code;
100
+    }
101
+
102
+    /**
103
+     * @return int
104
+     */
105
+    public function getSessionId()
106
+    {
107
+        return $this->sessionId;
108
+    }
109
+
110
+    /**
111
+     * @param int $sessionId
112
+     */
113
+    public function setSessionId($sessionId)
114
+    {
115
+        $this->sessionId = intval($sessionId);
116
+    }
117
+
118
+    public function get_date()
119
+    {
120
+        return $this->created_at;
121
+    }
122
+
123
+    public function get_weight()
124
+    {
125
+        return $this->weight;
126
+    }
127
+
128
+    public function get_max()
129
+    {
130
+        return $this->eval_max;
131
+    }
132
+
133
+    public function get_type()
134
+    {
135
+        return $this->type;
136
+    }
137
+
138
+    public function is_visible()
139
+    {
140
+        return $this->visible;
141
+    }
142
+
143
+    public function get_locked()
144
+    {
145
+        return $this->locked;
146
+    }
147
+
148
+    public function is_locked()
149
+    {
150
+        return isset($this->locked) && $this->locked == 1 ? true : false;
151
+    }
152
+
153
+    public function set_id($id)
154
+    {
155
+        $this->id = $id;
156
+    }
157
+
158
+    public function set_name($name)
159
+    {
160
+        $this->name = $name;
161
+    }
162
+
163
+    public function set_description($description)
164
+    {
165
+        $this->description = $description;
166
+    }
167
+
168
+    public function set_user_id($user_id)
169
+    {
170
+        $this->user_id = $user_id;
171
+    }
172
+
173
+    public function set_course_code($course_code)
174
+    {
175
+        $this->course_code = $course_code;
176
+    }
177
+
178
+    public function set_date($date)
179
+    {
180
+        $this->created_at = $date;
181
+    }
182
+
183
+    public function set_weight($weight)
184
+    {
185
+        $this->weight = $weight;
186
+    }
187
+
188
+    public function set_max($max)
189
+    {
190
+        $this->eval_max = $max;
191
+    }
192
+
193
+    public function set_visible($visible)
194
+    {
195
+        $this->visible = $visible;
196
+    }
197
+
198
+    public function set_type($type)
199
+    {
200
+        $this->type = $type;
201
+    }
202
+
203
+    public function set_locked($locked)
204
+    {
205
+        $this->locked = $locked;
206
+    }
207
+
208
+    /**
209
+     * Retrieve evaluations and return them as an array of Evaluation objects
210
+     * @param int $id evaluation id
211
+     * @param int $user_id user id (evaluation owner)
212
+     * @param string $course_code course code
213
+     * @param int $category_id parent category
214
+     * @param integer $visible visible
215
+     */
216
+    public static function load(
217
+        $id = null,
218
+        $user_id = null,
219
+        $course_code = null,
220
+        $category_id = null,
221
+        $visible = null,
222
+        $locked = null
223
+    ) {
224
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
225
+        $sql = 'SELECT * FROM '.$tbl_grade_evaluations;
226
+        $paramcount = 0;
227
+
228
+        if (isset ($id)) {
229
+            $sql.= ' WHERE id = '.intval($id);
230
+            $paramcount ++;
231
+        }
232
+
233
+        if (isset($user_id)) {
234
+            if ($paramcount != 0) $sql .= ' AND';
235
+            else $sql .= ' WHERE';
236
+            $sql .= ' user_id = '.intval($user_id);
237
+            $paramcount ++;
238
+        }
239
+
240
+        if (isset($course_code) && $course_code <> '-1') {
241
+            if ($paramcount != 0) $sql .= ' AND';
242
+            else $sql .= ' WHERE';
243
+            $sql .= " course_code = '".Database::escape_string($course_code)."'";
244
+            $paramcount ++;
245
+        }
246
+
247
+        if (isset($category_id)) {
248
+            if ($paramcount != 0) $sql .= ' AND';
249
+            else $sql .= ' WHERE';
250
+            $sql .= ' category_id = '.intval($category_id);
251
+            $paramcount ++;
252
+        }
253
+
254
+        if (isset($visible)) {
255
+            if ($paramcount != 0) $sql .= ' AND';
256
+            else $sql .= ' WHERE';
257
+            $sql .= ' visible = '.intval($visible);
258
+            $paramcount ++;
259
+        }
260
+
261
+        if (isset($locked)) {
262
+            if ($paramcount != 0) $sql .= ' AND';
263
+            else $sql .= ' WHERE';
264
+            $sql .= ' locked = '.intval($locked);
265
+        }
266
+
267
+        $result = Database::query($sql);
268
+        $allEval = Evaluation::create_evaluation_objects_from_sql_result($result);
269
+
270
+        return $allEval;
271
+    }
272
+
273
+    /**
274
+     * @param array $result
275
+     * @return array
276
+     */
277
+    private static function create_evaluation_objects_from_sql_result($result)
278
+    {
279
+        $alleval = array();
280
+        if (Database::num_rows($result)) {
281
+            while ($data = Database::fetch_array($result)) {
282
+                $eval= new Evaluation();
283
+                $eval->set_id($data['id']);
284
+                $eval->set_name($data['name']);
285
+                $eval->set_description($data['description']);
286
+                $eval->set_user_id($data['user_id']);
287
+                $eval->set_course_code($data['course_code']);
288
+                $eval->set_category_id($data['category_id']);
289
+                $eval->set_date(api_get_local_time($data['created_at']));
290
+                $eval->set_weight($data['weight']);
291
+                $eval->set_max($data['max']);
292
+                $eval->set_visible($data['visible']);
293
+                $eval->set_type($data['type']);
294
+                $eval->set_locked($data['locked']);
295
+                $eval->setSessionId(api_get_session_id());
296
+
297
+                $alleval[] = $eval;
298
+            }
299
+        }
300
+
301
+        return $alleval;
302
+    }
303
+
304
+    /**
305
+     * Insert this evaluation into the database
306
+     */
307 307
     public function add()
308
-	{
309
-		if (isset($this->name) &&
310
-			isset($this->user_id) &&
311
-			isset($this->weight) &&
312
-			isset ($this->eval_max) &&
313
-			isset($this->visible)
314
-		) {
315
-			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
316
-
317
-			$sql = 'INSERT INTO '.$tbl_grade_evaluations
318
-				.' (name, user_id, weight, max, visible';
319
-			if (isset($this->description)) {
320
-				$sql .= ',description';
321
-			}
322
-			if (isset($this->course_code)) {
323
-				$sql .= ', course_code';
324
-			}
325
-			if (isset($this->category)) {
326
-				$sql .= ', category_id';
327
-			}
328
-			$sql .= ', created_at';
329
-			$sql .= ',type';
330
-			$sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
331
-				.','.intval($this->get_user_id())
332
-				.','.floatval($this->get_weight())
333
-				.','.intval($this->get_max())
334
-				.','.intval($this->is_visible());
335
-			if (isset($this->description)) {
336
-				$sql .= ",'".Database::escape_string($this->get_description())."'";
337
-			}
338
-			if (isset($this->course_code)) {
339
-				$sql .= ",'".Database::escape_string($this->get_course_code())."'";
340
-			}
341
-			if (isset($this->category)) {
342
-				$sql .= ','.intval($this->get_category_id());
343
-			}
344
-			if (empty($this->type)) {
345
-				$this->type = 'evaluation';
346
-			}
347
-			$sql .= ", '".api_get_utc_datetime()."'";
348
-			$sql .= ',\''.Database::escape_string($this->type).'\'';
349
-			$sql .= ")";
350
-
351
-			Database::query($sql);
352
-			$this->set_id(Database::insert_id());
353
-		} else {
354
-			die('Error in Evaluation add: required field empty');
355
-		}
356
-	}
357
-
358
-	/**
359
-	 * @param int $idevaluation
360
-	 */
361
-	public function add_evaluation_log($idevaluation)
362
-	{
363
-		if (!empty($idevaluation)) {
364
-			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
365
-			$tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
366
-			$eval = new Evaluation();
367
-			$dateobject = $eval->load($idevaluation,null,null,null,null);
368
-			$arreval = get_object_vars($dateobject[0]);
369
-			if (!empty($arreval['id'])) {
370
-				$sql = 'SELECT weight from '.$tbl_grade_evaluations.'
308
+    {
309
+        if (isset($this->name) &&
310
+            isset($this->user_id) &&
311
+            isset($this->weight) &&
312
+            isset ($this->eval_max) &&
313
+            isset($this->visible)
314
+        ) {
315
+            $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
316
+
317
+            $sql = 'INSERT INTO '.$tbl_grade_evaluations
318
+                .' (name, user_id, weight, max, visible';
319
+            if (isset($this->description)) {
320
+                $sql .= ',description';
321
+            }
322
+            if (isset($this->course_code)) {
323
+                $sql .= ', course_code';
324
+            }
325
+            if (isset($this->category)) {
326
+                $sql .= ', category_id';
327
+            }
328
+            $sql .= ', created_at';
329
+            $sql .= ',type';
330
+            $sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
331
+                .','.intval($this->get_user_id())
332
+                .','.floatval($this->get_weight())
333
+                .','.intval($this->get_max())
334
+                .','.intval($this->is_visible());
335
+            if (isset($this->description)) {
336
+                $sql .= ",'".Database::escape_string($this->get_description())."'";
337
+            }
338
+            if (isset($this->course_code)) {
339
+                $sql .= ",'".Database::escape_string($this->get_course_code())."'";
340
+            }
341
+            if (isset($this->category)) {
342
+                $sql .= ','.intval($this->get_category_id());
343
+            }
344
+            if (empty($this->type)) {
345
+                $this->type = 'evaluation';
346
+            }
347
+            $sql .= ", '".api_get_utc_datetime()."'";
348
+            $sql .= ',\''.Database::escape_string($this->type).'\'';
349
+            $sql .= ")";
350
+
351
+            Database::query($sql);
352
+            $this->set_id(Database::insert_id());
353
+        } else {
354
+            die('Error in Evaluation add: required field empty');
355
+        }
356
+    }
357
+
358
+    /**
359
+     * @param int $idevaluation
360
+     */
361
+    public function add_evaluation_log($idevaluation)
362
+    {
363
+        if (!empty($idevaluation)) {
364
+            $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
365
+            $tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
366
+            $eval = new Evaluation();
367
+            $dateobject = $eval->load($idevaluation,null,null,null,null);
368
+            $arreval = get_object_vars($dateobject[0]);
369
+            if (!empty($arreval['id'])) {
370
+                $sql = 'SELECT weight from '.$tbl_grade_evaluations.'
371 371
                         WHERE id='.$arreval['id'];
372 372
                 $rs = Database::query($sql);
373 373
                 $row_old_weight = Database::fetch_array($rs, 'ASSOC');
@@ -383,426 +383,426 @@  discard block
 block discarded – undo
383 383
                     'user_id_log' => api_get_user_id()
384 384
                 ];
385 385
                 Database::insert($tbl_grade_linkeval_log, $params);
386
-			}
387
-		}
388
-	}
389
-
390
-	/**
391
-	 * Update the properties of this evaluation in the database
392
-	 */
393
-	public function save()
394
-	{
395
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
396
-		$sql = 'UPDATE '.$tbl_grade_evaluations
397
-			." SET name = '".Database::escape_string($this->get_name())."'"
398
-			.', description = ';
399
-		if (isset($this->description)) {
400
-			$sql .= "'".Database::escape_string($this->get_description())."'";
401
-		}else {
402
-			$sql .= 'null';
403
-		}
404
-		$sql .= ', user_id = '.intval($this->get_user_id())
405
-			.', course_code = ';
406
-		if (isset($this->course_code)) {
407
-			$sql .= "'".Database::escape_string($this->get_course_code())."'";
408
-		} else {
409
-			$sql .= 'null';
410
-		}
411
-		$sql .= ', category_id = ';
412
-		if (isset($this->category)) {
413
-			$sql .= intval($this->get_category_id());
414
-		} else {
415
-			$sql .= 'null';
416
-		}
417
-		$sql .= ', weight = "'.Database::escape_string($this->get_weight()).'" '
418
-			.', max = '.intval($this->get_max())
419
-			.', visible = '.intval($this->is_visible())
420
-			.' WHERE id = '.intval($this->id);
421
-		//recorded history
422
-
423
-		$eval_log = new Evaluation();
424
-		$eval_log->add_evaluation_log($this->id);
425
-		Database::query($sql);
426
-	}
427
-
428
-	/**
429
-	 * Delete this evaluation from the database
430
-	 */
431
-	public function delete()
432
-	{
433
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
434
-		$sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
435
-		Database::query($sql);
436
-	}
437
-
438
-	/**
439
-	 * Check if an evaluation name (with the same parent category) already exists
440
-	 * @param $name name to check (if not given, the name property of this object will be checked)
441
-	 * @param $parent parent category
442
-	 */
443
-	public function does_name_exist($name, $parent)
444
-	{
445
-		if (!isset ($name)) {
446
-			$name = $this->name;
447
-			$parent = $this->category;
448
-		}
449
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
450
-		$sql = 'SELECT count(id) AS number'
451
-			.' FROM '.$tbl_grade_evaluations
452
-			." WHERE name = '".Database::escape_string($name)."'";
453
-
454
-		if (api_is_allowed_to_edit()) {
455
-			$parent = Category::load($parent);
456
-			$code = $parent[0]->get_course_code();
457
-			$courseInfo = api_get_course_info($code);
458
-			$courseId = $courseInfo['real_id'];
459
-
460
-			if (isset($code) && $code != '0') {
461
-				$main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
462
-				$sql .= ' AND user_id IN (
386
+            }
387
+        }
388
+    }
389
+
390
+    /**
391
+     * Update the properties of this evaluation in the database
392
+     */
393
+    public function save()
394
+    {
395
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
396
+        $sql = 'UPDATE '.$tbl_grade_evaluations
397
+            ." SET name = '".Database::escape_string($this->get_name())."'"
398
+            .', description = ';
399
+        if (isset($this->description)) {
400
+            $sql .= "'".Database::escape_string($this->get_description())."'";
401
+        }else {
402
+            $sql .= 'null';
403
+        }
404
+        $sql .= ', user_id = '.intval($this->get_user_id())
405
+            .', course_code = ';
406
+        if (isset($this->course_code)) {
407
+            $sql .= "'".Database::escape_string($this->get_course_code())."'";
408
+        } else {
409
+            $sql .= 'null';
410
+        }
411
+        $sql .= ', category_id = ';
412
+        if (isset($this->category)) {
413
+            $sql .= intval($this->get_category_id());
414
+        } else {
415
+            $sql .= 'null';
416
+        }
417
+        $sql .= ', weight = "'.Database::escape_string($this->get_weight()).'" '
418
+            .', max = '.intval($this->get_max())
419
+            .', visible = '.intval($this->is_visible())
420
+            .' WHERE id = '.intval($this->id);
421
+        //recorded history
422
+
423
+        $eval_log = new Evaluation();
424
+        $eval_log->add_evaluation_log($this->id);
425
+        Database::query($sql);
426
+    }
427
+
428
+    /**
429
+     * Delete this evaluation from the database
430
+     */
431
+    public function delete()
432
+    {
433
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
434
+        $sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
435
+        Database::query($sql);
436
+    }
437
+
438
+    /**
439
+     * Check if an evaluation name (with the same parent category) already exists
440
+     * @param $name name to check (if not given, the name property of this object will be checked)
441
+     * @param $parent parent category
442
+     */
443
+    public function does_name_exist($name, $parent)
444
+    {
445
+        if (!isset ($name)) {
446
+            $name = $this->name;
447
+            $parent = $this->category;
448
+        }
449
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
450
+        $sql = 'SELECT count(id) AS number'
451
+            .' FROM '.$tbl_grade_evaluations
452
+            ." WHERE name = '".Database::escape_string($name)."'";
453
+
454
+        if (api_is_allowed_to_edit()) {
455
+            $parent = Category::load($parent);
456
+            $code = $parent[0]->get_course_code();
457
+            $courseInfo = api_get_course_info($code);
458
+            $courseId = $courseInfo['real_id'];
459
+
460
+            if (isset($code) && $code != '0') {
461
+                $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
462
+                $sql .= ' AND user_id IN (
463 463
 					 SELECT user_id FROM '.$main_course_user_table.'
464 464
 					 WHERE
465 465
 						c_id = '.$courseId.' AND
466 466
 						status = '.COURSEMANAGER.'
467 467
 					)';
468
-			} else {
469
-				$sql .= ' AND user_id = '.api_get_user_id();
470
-			}
471
-
472
-		}else {
473
-			$sql .= ' AND user_id = '.api_get_user_id();
474
-		}
475
-
476
-		if (!isset ($parent)) {
477
-			$sql.= ' AND category_id is null';
478
-		} else {
479
-			$sql.= ' AND category_id = '.intval($parent);
480
-		}
481
-		$result = Database::query($sql);
482
-		$number=Database::fetch_row($result);
483
-
484
-		return $number[0] != 0;
485
-	}
486
-
487
-	/**
488
-	 * Are there any results for this evaluation yet ?
489
-	 * The 'max' property should not be changed then.
490
-	 */
491
-	public function has_results()
492
-	{
493
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
494
-		$sql = 'SELECT count(id) AS number
468
+            } else {
469
+                $sql .= ' AND user_id = '.api_get_user_id();
470
+            }
471
+
472
+        }else {
473
+            $sql .= ' AND user_id = '.api_get_user_id();
474
+        }
475
+
476
+        if (!isset ($parent)) {
477
+            $sql.= ' AND category_id is null';
478
+        } else {
479
+            $sql.= ' AND category_id = '.intval($parent);
480
+        }
481
+        $result = Database::query($sql);
482
+        $number=Database::fetch_row($result);
483
+
484
+        return $number[0] != 0;
485
+    }
486
+
487
+    /**
488
+     * Are there any results for this evaluation yet ?
489
+     * The 'max' property should not be changed then.
490
+     */
491
+    public function has_results()
492
+    {
493
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
494
+        $sql = 'SELECT count(id) AS number
495 495
 				FROM '.$tbl_grade_results.'
496 496
 				WHERE evaluation_id = '.intval($this->id);
497
-		$result = Database::query($sql);
498
-		$number=Database::fetch_row($result);
499
-
500
-		return ($number[0] != 0);
501
-	}
502
-
503
-	/**
504
-	 * Delete all results for this evaluation
505
-	 */
506
-	public function delete_results()
507
-	{
508
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
509
-		$sql = 'DELETE FROM '.$tbl_grade_results.'
497
+        $result = Database::query($sql);
498
+        $number=Database::fetch_row($result);
499
+
500
+        return ($number[0] != 0);
501
+    }
502
+
503
+    /**
504
+     * Delete all results for this evaluation
505
+     */
506
+    public function delete_results()
507
+    {
508
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
509
+        $sql = 'DELETE FROM '.$tbl_grade_results.'
510 510
 				WHERE evaluation_id = '.intval($this->id);
511
-		Database::query($sql);
512
-	}
513
-
514
-	/**
515
-	 * Delete this evaluation and all underlying results.
516
-	 */
517
-	public function delete_with_results()
518
-	{
519
-		$this->delete_results();
520
-		$this->delete();
521
-	}
522
-
523
-	/**
524
-	 * Check if the given score is possible for this evaluation
525
-	 */
526
-	public function is_valid_score($score)
527
-	{
528
-		return is_numeric($score) && $score >= 0 && $score <= $this->eval_max;
529
-	}
530
-
531
-	/**
532
-	 * Calculate the score of this evaluation
533
-	 * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
534
-	 * @param string $type (best, average, ranking)
535
-	 * @return	array (score, max) if student is given
536
-	 * 			array (sum of scores, number of scores) otherwise
537
-	 * 			or null if no scores available
538
-	 */
539
-	public function calc_score($stud_id = null, $type = null)
540
-	{
511
+        Database::query($sql);
512
+    }
513
+
514
+    /**
515
+     * Delete this evaluation and all underlying results.
516
+     */
517
+    public function delete_with_results()
518
+    {
519
+        $this->delete_results();
520
+        $this->delete();
521
+    }
522
+
523
+    /**
524
+     * Check if the given score is possible for this evaluation
525
+     */
526
+    public function is_valid_score($score)
527
+    {
528
+        return is_numeric($score) && $score >= 0 && $score <= $this->eval_max;
529
+    }
530
+
531
+    /**
532
+     * Calculate the score of this evaluation
533
+     * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
534
+     * @param string $type (best, average, ranking)
535
+     * @return	array (score, max) if student is given
536
+     * 			array (sum of scores, number of scores) otherwise
537
+     * 			or null if no scores available
538
+     */
539
+    public function calc_score($stud_id = null, $type = null)
540
+    {
541 541
         $useSession = true;
542
-		if (isset($stud_id) && empty($type)) {
543
-			$key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id;
544
-			$data = Session::read('calc_score');
542
+        if (isset($stud_id) && empty($type)) {
543
+            $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id;
544
+            $data = Session::read('calc_score');
545 545
             $results = isset($data[$key]) ? $data[$key] : null;
546 546
 
547 547
             if ($useSession == false) {
548 548
                 $results  = null;
549 549
             }
550
-			if (empty($results)) {
551
-				$results = Result::load(null, $stud_id, $this->id);
552
-				Session::write('calc_score', array($key => $results));
553
-			}
554
-
555
-			$score = 0;
556
-			/** @var Result $res */
557
-			foreach ($results as $res) {
558
-				$score = $res->get_score();
559
-			}
560
-
561
-			return array($score, $this->get_max());
562
-		} else {
563
-
564
-			$count = 0;
565
-			$sum = 0;
566
-			$bestResult = 0;
567
-			$weight = 0;
568
-			$sumResult = 0;
569
-
570
-			$key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id;
550
+            if (empty($results)) {
551
+                $results = Result::load(null, $stud_id, $this->id);
552
+                Session::write('calc_score', array($key => $results));
553
+            }
554
+
555
+            $score = 0;
556
+            /** @var Result $res */
557
+            foreach ($results as $res) {
558
+                $score = $res->get_score();
559
+            }
560
+
561
+            return array($score, $this->get_max());
562
+        } else {
563
+
564
+            $count = 0;
565
+            $sum = 0;
566
+            $bestResult = 0;
567
+            $weight = 0;
568
+            $sumResult = 0;
569
+
570
+            $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id;
571 571
             $data = Session::read('calc_score');
572 572
             $allResults = isset($data[$key]) ? $data[$key] : null;
573 573
             if ($useSession == false) {
574 574
                 $allResults  = null;
575 575
             }
576
-			if (empty($allResults)) {
577
-				$allResults = Result::load(null, null, $this->id);
578
-				Session::write($key, $allResults);
579
-			}
580
-
581
-			$students = array();
582
-			/** @var Result $res */
583
-			foreach ($allResults as $res) {
584
-				$score = $res->get_score();
585
-				if (!empty($score) || $score == '0') {
586
-					$count++;
587
-					$sum += $score / $this->get_max();
588
-					$sumResult += $score;
589
-					if ($score > $bestResult) {
590
-						$bestResult = $score;
591
-					}
592
-					$weight = $this->get_max();
593
-				}
594
-				$students[$res->get_user_id()] = $score;
595
-			}
596
-
597
-			if (empty($count)) {
598
-				return null;
599
-			}
600
-
601
-			switch ($type) {
602
-				case 'best':
603
-					return array($bestResult, $weight);
604
-					break;
605
-				case 'average':
606
-					return array($sumResult/$count, $weight);
607
-					break;
608
-				case 'ranking':
576
+            if (empty($allResults)) {
577
+                $allResults = Result::load(null, null, $this->id);
578
+                Session::write($key, $allResults);
579
+            }
580
+
581
+            $students = array();
582
+            /** @var Result $res */
583
+            foreach ($allResults as $res) {
584
+                $score = $res->get_score();
585
+                if (!empty($score) || $score == '0') {
586
+                    $count++;
587
+                    $sum += $score / $this->get_max();
588
+                    $sumResult += $score;
589
+                    if ($score > $bestResult) {
590
+                        $bestResult = $score;
591
+                    }
592
+                    $weight = $this->get_max();
593
+                }
594
+                $students[$res->get_user_id()] = $score;
595
+            }
596
+
597
+            if (empty($count)) {
598
+                return null;
599
+            }
600
+
601
+            switch ($type) {
602
+                case 'best':
603
+                    return array($bestResult, $weight);
604
+                    break;
605
+                case 'average':
606
+                    return array($sumResult/$count, $weight);
607
+                    break;
608
+                case 'ranking':
609 609
                     $students = array();
610 610
                     /** @var Result $res */
611 611
                     foreach ($allResults as $res) {
612 612
                         $score = $res->get_score();
613 613
                         $students[$res->get_user_id()] = $score;
614 614
                     }
615
-					return AbstractLink::getCurrentUserRanking($stud_id, $students);
616
-					break;
617
-				default:
618
-					return array($sum, $count);
619
-					break;
620
-			}
621
-		}
622
-	}
623
-
624
-	/**
625
-	 * Generate an array of possible categories where this evaluation can be moved to.
626
-	 * Notice: its own parent will be included in the list: it's up to the frontend
627
-	 * to disable this element.
628
-	 * @return array 2-dimensional array - every element contains 3 subelements (id, name, level)
629
-	 */
630
-	public function get_target_categories()
631
-	{
632
-		// - course independent evaluation
633
-		//   -> movable to root or other course independent categories
634
-		// - evaluation inside a course
635
-		//   -> movable to root, independent categories or categories inside the course
636
-		$user = (api_is_platform_admin() ? null : api_get_user_id());
637
-		$targets = array();
638
-		$level = 0;
639
-
640
-		$root = array(0, get_lang('RootCat'), $level);
641
-		$targets[] = $root;
642
-
643
-		if (isset($this->course_code) && !empty($this->course_code)) {
644
-			$crscats = Category::load(null,null,$this->course_code,0);
645
-			foreach ($crscats as $cat) {
646
-				$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
647
-				$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
648
-			}
649
-		}
650
-
651
-		$indcats = Category::load(null,$user,0,0);
652
-		foreach ($indcats as $cat) {
653
-			$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
654
-			$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
655
-		}
656
-
657
-		return $targets;
658
-	}
659
-
660
-	/**
661
-	 * Internal function used by get_target_categories()
662
-	 * @param integer $level
663
-	 */
664
-	private function add_target_subcategories($targets, $level, $catid)
665
-	{
666
-		$subcats = Category::load(null,null,null,$catid);
667
-		foreach ($subcats as $cat) {
668
-			$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
669
-			$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
670
-		}
671
-		return $targets;
672
-	}
673
-
674
-	/**
675
-	 * Move this evaluation to the given category.
676
-	 * If this evaluation moves from inside a course to outside,
677
-	 * its course code is also changed.
678
-	 */
679
-	public function move_to_cat($cat)
680
-	{
681
-		$this->set_category_id($cat->get_id());
682
-		if ($this->get_course_code() != $cat->get_course_code()) {
683
-			$this->set_course_code($cat->get_course_code());
684
-		}
685
-		$this->save();
686
-	}
687
-
688
-	/**
689
-	 * Retrieve evaluations where a student has results for
690
-	 * and return them as an array of Evaluation objects
691
-	 * @param int $cat_id parent category (use 'null' to retrieve them in all categories)
692
-	 * @param int $stud_id student id
693
-	 */
694
-	public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id)
695
-	{
696
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
697
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
698
-
699
-		$sql = 'SELECT * FROM '.$tbl_grade_evaluations.'
615
+                    return AbstractLink::getCurrentUserRanking($stud_id, $students);
616
+                    break;
617
+                default:
618
+                    return array($sum, $count);
619
+                    break;
620
+            }
621
+        }
622
+    }
623
+
624
+    /**
625
+     * Generate an array of possible categories where this evaluation can be moved to.
626
+     * Notice: its own parent will be included in the list: it's up to the frontend
627
+     * to disable this element.
628
+     * @return array 2-dimensional array - every element contains 3 subelements (id, name, level)
629
+     */
630
+    public function get_target_categories()
631
+    {
632
+        // - course independent evaluation
633
+        //   -> movable to root or other course independent categories
634
+        // - evaluation inside a course
635
+        //   -> movable to root, independent categories or categories inside the course
636
+        $user = (api_is_platform_admin() ? null : api_get_user_id());
637
+        $targets = array();
638
+        $level = 0;
639
+
640
+        $root = array(0, get_lang('RootCat'), $level);
641
+        $targets[] = $root;
642
+
643
+        if (isset($this->course_code) && !empty($this->course_code)) {
644
+            $crscats = Category::load(null,null,$this->course_code,0);
645
+            foreach ($crscats as $cat) {
646
+                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
647
+                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
648
+            }
649
+        }
650
+
651
+        $indcats = Category::load(null,$user,0,0);
652
+        foreach ($indcats as $cat) {
653
+            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
654
+            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
655
+        }
656
+
657
+        return $targets;
658
+    }
659
+
660
+    /**
661
+     * Internal function used by get_target_categories()
662
+     * @param integer $level
663
+     */
664
+    private function add_target_subcategories($targets, $level, $catid)
665
+    {
666
+        $subcats = Category::load(null,null,null,$catid);
667
+        foreach ($subcats as $cat) {
668
+            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
669
+            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
670
+        }
671
+        return $targets;
672
+    }
673
+
674
+    /**
675
+     * Move this evaluation to the given category.
676
+     * If this evaluation moves from inside a course to outside,
677
+     * its course code is also changed.
678
+     */
679
+    public function move_to_cat($cat)
680
+    {
681
+        $this->set_category_id($cat->get_id());
682
+        if ($this->get_course_code() != $cat->get_course_code()) {
683
+            $this->set_course_code($cat->get_course_code());
684
+        }
685
+        $this->save();
686
+    }
687
+
688
+    /**
689
+     * Retrieve evaluations where a student has results for
690
+     * and return them as an array of Evaluation objects
691
+     * @param int $cat_id parent category (use 'null' to retrieve them in all categories)
692
+     * @param int $stud_id student id
693
+     */
694
+    public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id)
695
+    {
696
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
697
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
698
+
699
+        $sql = 'SELECT * FROM '.$tbl_grade_evaluations.'
700 700
 				WHERE id IN (
701 701
 					SELECT evaluation_id FROM '.$tbl_grade_results.'
702 702
 					WHERE user_id = '.intval($stud_id).' AND score IS NOT NULL
703 703
 				)';
704
-		if (!api_is_allowed_to_edit()) {
705
-			$sql .= ' AND visible = 1';
706
-		}
707
-		if (isset($cat_id)) {
708
-			$sql .= ' AND category_id = '.intval($cat_id);
709
-		} else {
710
-			$sql .= ' AND category_id >= 0';
711
-		}
712
-
713
-		$result = Database::query($sql);
714
-		$alleval = Evaluation::create_evaluation_objects_from_sql_result($result);
715
-
716
-		return $alleval;
717
-	}
718
-
719
-	/**
720
-	 * Get a list of students that do not have a result record for this evaluation
721
-	 */
722
-	public function get_not_subscribed_students($first_letter_user = '')
723
-	{
724
-		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
725
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
726
-
727
-		$sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user
728
-			." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'"
729
-			.' AND status = '.STUDENT
730
-			.' AND user_id NOT IN'
731
-			.' (SELECT user_id FROM '.$tbl_grade_results
732
-			.' WHERE evaluation_id = '.intval($this->id)
733
-			.' )'
734
-			.' ORDER BY lastname';
735
-
736
-		$result = Database::query($sql);
737
-		$users = Database::store_result($result);
738
-
739
-		return $users;
740
-	}
741
-
742
-	/**
743
-	 * Find evaluations by name
744
-	 * @param string $name_mask search string
745
-	 * @return array evaluation objects matching the search criterium
746
-	 * @todo can be written more efficiently using a new (but very complex) sql query
747
-	 */
748
-	public function find_evaluations($name_mask,$selectcat)
749
-	{
750
-		$rootcat = Category::load($selectcat);
751
-		$evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
752
-		$foundevals = array();
753
-		foreach ($evals as $eval) {
754
-			if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
755
-				$foundevals[] = $eval;
756
-			}
757
-		}
758
-		return $foundevals;
759
-	}
760
-
761
-	public function get_item_type()
762
-	{
763
-		return 'E';
764
-	}
765
-
766
-	public function get_icon_name()
767
-	{
768
-		return $this->has_results() ? 'evalnotempty' : 'evalempty';
769
-	}
770
-
771
-	/**
772
-	 * Locks an evaluation, only one who can unlock it is the platform administrator.
773
-	 * @param int locked 1 or unlocked 0
774
-	 *
775
-	 **/
776
-	function lock($locked)
777
-	{
778
-		$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
779
-		$sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
780
-		Database::query($sql);
781
-	}
782
-
783
-	function check_lock_permissions()
784
-	{
785
-		if (api_is_platform_admin()) {
786
-			return true;
787
-		} else {
788
-			if ($this->is_locked()) {
789
-				api_not_allowed();
790
-			}
791
-		}
792
-	}
793
-
794
-	function delete_linked_data()
795
-	{
796
-
797
-	}
704
+        if (!api_is_allowed_to_edit()) {
705
+            $sql .= ' AND visible = 1';
706
+        }
707
+        if (isset($cat_id)) {
708
+            $sql .= ' AND category_id = '.intval($cat_id);
709
+        } else {
710
+            $sql .= ' AND category_id >= 0';
711
+        }
712
+
713
+        $result = Database::query($sql);
714
+        $alleval = Evaluation::create_evaluation_objects_from_sql_result($result);
715
+
716
+        return $alleval;
717
+    }
718
+
719
+    /**
720
+     * Get a list of students that do not have a result record for this evaluation
721
+     */
722
+    public function get_not_subscribed_students($first_letter_user = '')
723
+    {
724
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
725
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
726
+
727
+        $sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user
728
+            ." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'"
729
+            .' AND status = '.STUDENT
730
+            .' AND user_id NOT IN'
731
+            .' (SELECT user_id FROM '.$tbl_grade_results
732
+            .' WHERE evaluation_id = '.intval($this->id)
733
+            .' )'
734
+            .' ORDER BY lastname';
735
+
736
+        $result = Database::query($sql);
737
+        $users = Database::store_result($result);
738
+
739
+        return $users;
740
+    }
741
+
742
+    /**
743
+     * Find evaluations by name
744
+     * @param string $name_mask search string
745
+     * @return array evaluation objects matching the search criterium
746
+     * @todo can be written more efficiently using a new (but very complex) sql query
747
+     */
748
+    public function find_evaluations($name_mask,$selectcat)
749
+    {
750
+        $rootcat = Category::load($selectcat);
751
+        $evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
752
+        $foundevals = array();
753
+        foreach ($evals as $eval) {
754
+            if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
755
+                $foundevals[] = $eval;
756
+            }
757
+        }
758
+        return $foundevals;
759
+    }
760
+
761
+    public function get_item_type()
762
+    {
763
+        return 'E';
764
+    }
765
+
766
+    public function get_icon_name()
767
+    {
768
+        return $this->has_results() ? 'evalnotempty' : 'evalempty';
769
+    }
770
+
771
+    /**
772
+     * Locks an evaluation, only one who can unlock it is the platform administrator.
773
+     * @param int locked 1 or unlocked 0
774
+     *
775
+     **/
776
+    function lock($locked)
777
+    {
778
+        $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
779
+        $sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
780
+        Database::query($sql);
781
+    }
782
+
783
+    function check_lock_permissions()
784
+    {
785
+        if (api_is_platform_admin()) {
786
+            return true;
787
+        } else {
788
+            if ($this->is_locked()) {
789
+                api_not_allowed();
790
+            }
791
+        }
792
+    }
793
+
794
+    function delete_linked_data()
795
+    {
796
+
797
+    }
798 798
 
799 799
     public function getStudentList()
800 800
     {
801 801
         return $this->studentList;
802 802
     }
803 803
 
804
-	public function setStudentList($list)
805
-	{
806
-		$this->studentList = $list;
807
-	}
804
+    public function setStudentList($list)
805
+    {
806
+        $this->studentList = $list;
807
+    }
808 808
 }
Please login to merge, or discard this patch.
main/exercise/hotpotatoes_exercise_result.class.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 * @param string $document_path
22
-	 */
23
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     * @param string $document_path
22
+     */
23
+    public function getExercisesReporting($document_path, $hotpotato_name)
24 24
     {
25
-		$return = array();
25
+        $return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27 27
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
37
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
37
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         $this->results = $return;
112 112
 
113 113
         return true;
114
-	}
114
+    }
115 115
 
116 116
 
117
-	/**
118
-	 * Exports the complete report as a CSV file
119
-	 * @param	string		Document path inside the document tool
120
-	 * @param	integer		Optional user ID
121
-	 * @param	boolean		Whether to include user fields or not
122
-	 * @return	boolean		False on error
123
-	 */
124
-	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
117
+    /**
118
+     * Exports the complete report as a CSV file
119
+     * @param	string		Document path inside the document tool
120
+     * @param	integer		Optional user ID
121
+     * @param	boolean		Whether to include user fields or not
122
+     * @return	boolean		False on error
123
+     */
124
+    public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
125 125
     {
126
-		global $charset;
127
-		$this->getExercisesReporting($document_path, $hotpotato_name);
128
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
129
-		if (!empty($user_id)) {
130
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
-		}
132
-		$data = '';
126
+        global $charset;
127
+        $this->getExercisesReporting($document_path, $hotpotato_name);
128
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
129
+        if (!empty($user_id)) {
130
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
+        }
132
+        $data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135 135
             if(!empty($this->results[0]['first_name'])) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         }
149 149
         $data .= get_lang('Email').';';
150 150
 
151
-		/*if ($export_user_fields) {
151
+        /*if ($export_user_fields) {
152 152
 			//show user fields section with a big th colspan that spans over all fields
153 153
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
154 154
 			$num = count($extra_user_fields);
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 		}*/
159 159
 
160
-		$data .= get_lang('Title').';';
161
-		$data .= get_lang('StartDate').';';
162
-		$data .= get_lang('Score').';';
163
-		$data .= get_lang('Total').';';
164
-		$data .= "\n";
160
+        $data .= get_lang('Title').';';
161
+        $data .= get_lang('StartDate').';';
162
+        $data .= get_lang('Score').';';
163
+        $data .= get_lang('Total').';';
164
+        $data .= "\n";
165 165
 
166
-		//results
167
-		foreach($this->results as $row) {
166
+        //results
167
+        foreach($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176 176
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178
-			/*if ($export_user_fields) {
178
+            /*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
180 180
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
181 181
 				foreach($user_fields_values as $value) {
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
190
-			$data .= "\n";
191
-		}
192
-
193
-		//output the results
194
-		$len = strlen($data);
195
-		header('Content-type: application/octet-stream');
196
-		header('Content-Type: application/force-download');
197
-		header('Content-length: '.$len);
198
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
-			header('Content-Disposition: filename= '.$filename);
200
-		} else {
201
-			header('Content-Disposition: attachment; filename= '.$filename);
202
-		}
203
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
-			header('Pragma: ');
205
-			header('Cache-Control: ');
206
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
-		}
208
-		header('Content-Description: '.$filename);
209
-		header('Content-transfer-encoding: binary');
210
-		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
-		echo $data;
213
-		return true;
214
-	}
215
-
216
-	/**
217
-	 * Exports the complete report as an XLS file
218
-	 * @return	boolean		False on error
219
-	 */
186
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
189
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
190
+            $data .= "\n";
191
+        }
192
+
193
+        //output the results
194
+        $len = strlen($data);
195
+        header('Content-type: application/octet-stream');
196
+        header('Content-Type: application/force-download');
197
+        header('Content-length: '.$len);
198
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
+            header('Content-Disposition: filename= '.$filename);
200
+        } else {
201
+            header('Content-Disposition: attachment; filename= '.$filename);
202
+        }
203
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
+            header('Pragma: ');
205
+            header('Cache-Control: ');
206
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
+        }
208
+        header('Content-Description: '.$filename);
209
+        header('Content-transfer-encoding: binary');
210
+        // @todo add this utf-8 header for all csv files
211
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
+        echo $data;
213
+        return true;
214
+    }
215
+
216
+    /**
217
+     * Exports the complete report as an XLS file
218
+     * @return	boolean		False on error
219
+     */
220 220
     public function exportCompleteReportXLS(
221 221
         $document_path = '',
222 222
         $user_id = null,
@@ -225,36 +225,36 @@  discard block
 block discarded – undo
225 225
         $exercise_id = 0,
226 226
         $hotpotato_name = null
227 227
     ) {
228
-		global $charset;
229
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
231
-		if (!empty($user_id)) {
232
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
-		}
228
+        global $charset;
229
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
231
+        if (!empty($user_id)) {
232
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
+        }
234 234
 
235 235
         $spreadsheet = new PHPExcel();
236 236
         $spreadsheet->setActiveSheetIndex(0);
237 237
         $worksheet = $spreadsheet->getActiveSheet();
238 238
 
239 239
 
240
-		$line = 0;
241
-		$column = 0; //skip the first column (row titles)
240
+        $line = 0;
241
+        $column = 0; //skip the first column (row titles)
242 242
 
243
-		// check if exists column 'user'
244
-		$with_column_user = false;
245
-		foreach ($this->results as $result) {
246
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
-				$with_column_user = true;
248
-				break;
249
-			}
250
-		}
243
+        // check if exists column 'user'
244
+        $with_column_user = false;
245
+        foreach ($this->results as $result) {
246
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
+                $with_column_user = true;
248
+                break;
249
+            }
250
+        }
251 251
 
252
-		if ($with_column_user) {
253
-		    $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
-		    $column++;
252
+        if ($with_column_user) {
253
+            $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
+            $column++;
255 255
             if (api_is_western_name_order()) {
256
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
257
-    			$column++;
256
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
257
+                $column++;
258 258
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
259 259
                 $column++;
260 260
             } else {
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
264 264
                 $column++;
265 265
             }
266
-		}
266
+        }
267 267
 
268
-		if ($export_user_fields) {
269
-			//show user fields section with a big th colspan that spans over all fields
270
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
268
+        if ($export_user_fields) {
269
+            //show user fields section with a big th colspan that spans over all fields
270
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
271 271
 
272
-			//show the fields names for user fields
273
-			foreach ($extra_user_fields as $field) {
272
+            //show the fields names for user fields
273
+            foreach ($extra_user_fields as $field) {
274 274
                 $worksheet->setCellValueByColumnAndRow(
275 275
                     $column,
276 276
                     $line,
@@ -280,27 +280,27 @@  discard block
 block discarded – undo
280 280
                         $charset
281 281
                     )
282 282
                 );
283
-				$column++;
284
-			}
285
-		}
283
+                $column++;
284
+            }
285
+        }
286 286
 
287
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
288
-		$column++;
289
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
287
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
288
+        $column++;
289
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
290 290
         $column++;
291 291
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
292 292
         $column++;
293 293
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
294
-		$column++;
295
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
296
-		$column++;
297
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
298
-		$column++;
294
+        $column++;
295
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
296
+        $column++;
297
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
298
+        $column++;
299 299
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
300
-		$line++;
300
+        $line++;
301 301
 
302
-		foreach ($this->results as $row) {
303
-			$column = 0;
302
+        foreach ($this->results as $row) {
303
+            $column = 0;
304 304
 
305 305
             if ($with_column_user) {
306 306
                 $worksheet->setCellValueByColumnAndRow(
@@ -325,38 +325,38 @@  discard block
 block discarded – undo
325 325
                     $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
326 326
                     $column++;
327 327
                 }
328
-			}
328
+            }
329 329
 
330
-			if ($export_user_fields) {
331
-				//show user fields data, if any, for this user
332
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
333
-				foreach($user_fields_values as $value) {
334
-					$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
335
-					$column++;
336
-				}
337
-			}
330
+            if ($export_user_fields) {
331
+                //show user fields data, if any, for this user
332
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
333
+                foreach($user_fields_values as $value) {
334
+                    $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
335
+                    $column++;
336
+                }
337
+            }
338 338
 
339
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
340
-			$column++;
341
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
339
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
340
+            $column++;
341
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
342 342
             $column++;
343
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
343
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
344
+            $column++;
345
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
346
+            $column++;
347
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
348
+            $column++;
349
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
344 350
             $column++;
345
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
346
-			$column++;
347
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
348
-			$column++;
349
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
350
-			$column++;
351 351
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']);
352
-			$line++;
353
-		}
352
+            $line++;
353
+        }
354 354
 
355 355
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
356 356
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
357 357
         $writer->save($file);
358 358
         DocumentManager::file_send_for_download($file, true, $filename);
359 359
 
360
-		return true;
361
-	}
360
+        return true;
361
+    }
362 362
 }
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 1 patch
Indentation   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1371 1371
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1372 1372
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1373
-               break;
1373
+                break;
1374 1374
             case 'custom':
1375 1375
                 if (!empty($start_date) && !empty($end_date)) {
1376 1376
                     $start_date = Database::escape_string($start_date);
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                 break;
1381 1381
         }
1382 1382
 
1383
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1383
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1384 1384
     	        FROM '.$tbl_track_login.'
1385 1385
                 WHERE '.$userCondition.$condition_time;
1386
-    	$rs = Database::query($sql);
1386
+        $rs = Database::query($sql);
1387 1387
         $row = Database::fetch_array($rs, 'ASSOC');
1388 1388
         $diff = $row['diff'];
1389 1389
 
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1406 1406
     {
1407 1407
         $courseId = intval($courseId);
1408
-    	$session_id  = intval($session_id);
1409
-
1410
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
-    	if (is_array($user_id)) {
1412
-    	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
-    	} else {
1415
-    		$user_id = intval($user_id);
1416
-    		$condition_user = " AND user_id = $user_id ";
1417
-    	}
1418
-
1419
-    	$sql = "SELECT
1408
+        $session_id  = intval($session_id);
1409
+
1410
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
+        if (is_array($user_id)) {
1412
+            $user_id = array_map('intval', $user_id);
1413
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
+        } else {
1415
+            $user_id = intval($user_id);
1416
+            $condition_user = " AND user_id = $user_id ";
1417
+        }
1418
+
1419
+        $sql = "SELECT
1420 1420
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1421 1421
                 FROM $tbl_track_course
1422 1422
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1431,9 +1431,9 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
         $sql .= $condition_user;
1433 1433
         $rs = Database::query($sql);
1434
-    	$row = Database::fetch_array($rs);
1434
+        $row = Database::fetch_array($rs);
1435 1435
 
1436
-    	return $row['nb_seconds'];
1436
+        return $row['nb_seconds'];
1437 1437
     }
1438 1438
 
1439 1439
     /**
@@ -1444,25 +1444,25 @@  discard block
 block discarded – undo
1444 1444
      */
1445 1445
     public static function get_first_connection_date($student_id)
1446 1446
     {
1447
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
-    	$sql = 'SELECT login_date
1447
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
+        $sql = 'SELECT login_date
1449 1449
     	        FROM ' . $tbl_track_login . '
1450 1450
                 WHERE login_user_id = ' . intval($student_id) . '
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454
-    	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1456
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1454
+        $rs = Database::query($sql);
1455
+        if (Database::num_rows($rs)>0) {
1456
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
1459 1459
                     DATE_FORMAT_SHORT,
1460 1460
                     date_default_timezone_get()
1461 1461
                 );
1462
-    		}
1463
-    	}
1462
+            }
1463
+        }
1464 1464
 
1465
-    	return false;
1465
+        return false;
1466 1466
     }
1467 1467
 
1468 1468
     /**
@@ -1475,38 +1475,38 @@  discard block
 block discarded – undo
1475 1475
      */
1476 1476
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1477 1477
     {
1478
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
-    	$sql = 'SELECT login_date
1478
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
+        $sql = 'SELECT login_date
1480 1480
     	        FROM ' . $table . '
1481 1481
                 WHERE login_user_id = ' . intval($student_id) . '
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
1485
-    	$rs = Database::query($sql);
1486
-    	if (Database::num_rows($rs) > 0) {
1487
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1488
-    			$last_login_date = api_get_local_time($last_login_date);
1489
-    			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1491
-    			} else {
1492
-    				if (!$warning_message) {
1493
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
-    				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1496
-    					$currentTimestamp = time();
1497
-
1498
-    					//If the last connection is > than 7 days, the text is red
1499
-    					//345600 = 7 days in seconds
1500
-    					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
-    					} else {
1503
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
-    					}
1505
-    				}
1506
-    			}
1507
-    		}
1508
-    	}
1509
-    	return false;
1485
+        $rs = Database::query($sql);
1486
+        if (Database::num_rows($rs) > 0) {
1487
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1488
+                $last_login_date = api_get_local_time($last_login_date);
1489
+                if ($return_timestamp) {
1490
+                    return api_strtotime($last_login_date,'UTC');
1491
+                } else {
1492
+                    if (!$warning_message) {
1493
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
+                    } else {
1495
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1496
+                        $currentTimestamp = time();
1497
+
1498
+                        //If the last connection is > than 7 days, the text is red
1499
+                        //345600 = 7 days in seconds
1500
+                        if ($currentTimestamp - $timestamp > 604800) {
1501
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
+                        } else {
1503
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
+                        }
1505
+                    }
1506
+                }
1507
+            }
1508
+        }
1509
+        return false;
1510 1510
     }
1511 1511
 
1512 1512
     /**
@@ -1560,30 +1560,30 @@  discard block
 block discarded – undo
1560 1560
         $session_id = 0,
1561 1561
         $convert_date = true
1562 1562
     ) {
1563
-    	$student_id  = intval($student_id);
1563
+        $student_id  = intval($student_id);
1564 1564
         $courseId = intval($courseId);
1565
-    	$session_id  = intval($session_id);
1565
+        $session_id  = intval($session_id);
1566 1566
 
1567
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
-    	$sql = 'SELECT login_course_date
1567
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
+        $sql = 'SELECT login_course_date
1569 1569
     	        FROM '.$tbl_track_login.'
1570 1570
                 WHERE
1571 1571
                     user_id = '.$student_id.' AND
1572 1572
                     c_id = '.$courseId.' AND
1573 1573
                     session_id = '.$session_id.'
1574 1574
                 ORDER BY login_course_date ASC LIMIT 0,1';
1575
-    	$rs = Database::query($sql);
1576
-    	if (Database::num_rows($rs) > 0) {
1577
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1578
-    			if ($convert_date) {
1579
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
-    			} else {
1581
-    				return $first_login_date;
1582
-    			}
1583
-    		}
1584
-    	}
1585
-
1586
-    	return false;
1575
+        $rs = Database::query($sql);
1576
+        if (Database::num_rows($rs) > 0) {
1577
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1578
+                if ($convert_date) {
1579
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
+                } else {
1581
+                    return $first_login_date;
1582
+                }
1583
+            }
1584
+        }
1585
+
1586
+        return false;
1587 1587
     }
1588 1588
 
1589 1589
     /**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
         $session_id = 0,
1600 1600
         $convert_date = true
1601 1601
     ) {
1602
-    	// protect data
1603
-    	$student_id  = intval($student_id);
1602
+        // protect data
1603
+        $student_id  = intval($student_id);
1604 1604
         $courseId = $courseInfo['real_id'];
1605
-    	$session_id  = intval($session_id);
1605
+        $session_id  = intval($session_id);
1606 1606
 
1607
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
-    	$sql = 'SELECT access_date
1607
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
+        $sql = 'SELECT access_date
1609 1609
                 FROM '.$tbl_track_e_access.'
1610 1610
                 WHERE   access_user_id = '.$student_id.' AND
1611 1611
                         c_id = "'.$courseId.'" AND
@@ -1613,39 +1613,39 @@  discard block
 block discarded – undo
1613 1613
                 ORDER BY access_date DESC
1614 1614
                 LIMIT 0,1';
1615 1615
 
1616
-    	$rs = Database::query($sql);
1617
-    	if (Database::num_rows($rs) > 0) {
1618
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1616
+        $rs = Database::query($sql);
1617
+        if (Database::num_rows($rs) > 0) {
1618
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1619 1619
                 if (empty($last_login_date)) {
1620 1620
                     return false;
1621 1621
                 }
1622 1622
                 //see #5736
1623 1623
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1624
-    			$now = time();
1625
-    			//If the last connection is > than 7 days, the text is red
1626
-    			//345600 = 7 days in seconds
1627
-    			if ($now - $last_login_date_timestamp > 604800) {
1628
-    				if ($convert_date) {
1624
+                $now = time();
1625
+                //If the last connection is > than 7 days, the text is red
1626
+                //345600 = 7 days in seconds
1627
+                if ($now - $last_login_date_timestamp > 604800) {
1628
+                    if ($convert_date) {
1629 1629
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1630 1630
                         $icon = api_is_allowed_to_edit() ?
1631 1631
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1636
-    				} else {
1637
-    					return $last_login_date;
1638
-    				}
1639
-    			} else {
1640
-    				if ($convert_date) {
1641
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
-    				} else {
1643
-    					return $last_login_date;
1644
-    				}
1645
-    			}
1646
-    		}
1647
-    	}
1648
-    	return false;
1635
+                        return $icon. Display::label($last_login_date, 'warning');
1636
+                    } else {
1637
+                        return $last_login_date;
1638
+                    }
1639
+                } else {
1640
+                    if ($convert_date) {
1641
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
+                    } else {
1643
+                        return $last_login_date;
1644
+                    }
1645
+                }
1646
+            }
1647
+        }
1648
+        return false;
1649 1649
     }
1650 1650
 
1651 1651
     /**
@@ -1659,11 +1659,11 @@  discard block
 block discarded – undo
1659 1659
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1660 1660
     {
1661 1661
         if ($start < 0) {
1662
-    		$start = 0;
1663
-    	}
1664
-    	if (!isset($stop) or ($stop < 0)) {
1665
-    		$stop = api_get_utc_datetime();
1666
-    	}
1662
+            $start = 0;
1663
+        }
1664
+        if (!isset($stop) or ($stop < 0)) {
1665
+            $stop = api_get_utc_datetime();
1666
+        }
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
1675
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1675
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1676 1676
 
1677 1677
         $courseId = intval($courseId);
1678
-    	$session_id  = intval($session_id);
1679
-    	$count = 0;
1678
+        $session_id  = intval($session_id);
1679
+        $count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681 1681
         $sql =  "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             }
1716 1716
         }
1717 1717
 
1718
-    	return $count;
1718
+        return $count;
1719 1719
     }
1720 1720
 
1721 1721
     /**
@@ -1726,25 +1726,25 @@  discard block
 block discarded – undo
1726 1726
      */
1727 1727
     public static function count_course_per_student($user_id, $include_sessions = true)
1728 1728
     {
1729
-    	$user_id = intval($user_id);
1730
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1729
+        $user_id = intval($user_id);
1730
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733
-    	$sql = 'SELECT DISTINCT c_id
1733
+        $sql = 'SELECT DISTINCT c_id
1734 1734
                 FROM ' . $tbl_course_rel_user . '
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736
-    	$rs = Database::query($sql);
1737
-    	$nb_courses = Database::num_rows($rs);
1736
+        $rs = Database::query($sql);
1737
+        $nb_courses = Database::num_rows($rs);
1738 1738
 
1739
-    	if ($include_sessions) {
1740
-    		$sql = 'SELECT DISTINCT c_id
1739
+        if ($include_sessions) {
1740
+            $sql = 'SELECT DISTINCT c_id
1741 1741
                     FROM ' . $tbl_session_course_rel_user . '
1742 1742
                     WHERE user_id = ' . $user_id;
1743
-    		$rs = Database::query($sql);
1744
-    		$nb_courses += Database::num_rows($rs);
1745
-    	}
1743
+            $rs = Database::query($sql);
1744
+            $nb_courses += Database::num_rows($rs);
1745
+        }
1746 1746
 
1747
-    	return $nb_courses;
1747
+        return $nb_courses;
1748 1748
     }
1749 1749
 
1750 1750
     /**
@@ -1775,25 +1775,25 @@  discard block
 block discarded – undo
1775 1775
         $into_lp = 0
1776 1776
     ) {
1777 1777
         $course_code = Database::escape_string($course_code);
1778
-    	$course_info = api_get_course_info($course_code);
1779
-    	if (!empty($course_info)) {
1780
-    		// table definition
1781
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
-
1784
-    		// Compose a filter based on optional exercise given
1785
-    		$condition_quiz = "";
1786
-    		if (!empty($exercise_id)) {
1787
-    			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1789
-    		}
1790
-
1791
-    		// Compose a filter based on optional session id given
1792
-    		$condition_session = "";
1793
-    		if (isset($session_id)) {
1794
-    			$session_id = intval($session_id);
1795
-    			$condition_session = " AND session_id = $session_id ";
1796
-    		}
1778
+        $course_info = api_get_course_info($course_code);
1779
+        if (!empty($course_info)) {
1780
+            // table definition
1781
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
+
1784
+            // Compose a filter based on optional exercise given
1785
+            $condition_quiz = "";
1786
+            if (!empty($exercise_id)) {
1787
+                $exercise_id = intval($exercise_id);
1788
+                $condition_quiz =" AND id = $exercise_id ";
1789
+            }
1790
+
1791
+            // Compose a filter based on optional session id given
1792
+            $condition_session = "";
1793
+            if (isset($session_id)) {
1794
+                $session_id = intval($session_id);
1795
+                $condition_session = " AND session_id = $session_id ";
1796
+            }
1797 1797
             if ($active_filter == 1) {
1798 1798
                 $condition_active = 'AND active <> -1';
1799 1799
             } elseif ($active_filter == 0) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
                 $select_lp_id = ', orig_lp_id as lp_id ';
1810 1810
             }
1811 1811
 
1812
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1812
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1813 1813
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1814 1814
             $count_quiz = 0;
1815 1815
             $countQuizResult = Database::query($sql);
@@ -1817,21 +1817,21 @@  discard block
 block discarded – undo
1817 1817
                 $count_quiz = Database::fetch_row($countQuizResult);
1818 1818
             }
1819 1819
 
1820
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
-    			if (is_array($student_id)) {
1820
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
+                if (is_array($student_id)) {
1822 1822
                     $student_id = array_map('intval', $student_id);
1823
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
-    			} else {
1823
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
+                } else {
1825 1825
                     $student_id = intval($student_id);
1826
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1827
-    			}
1826
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1827
+                }
1828 1828
 
1829
-    			if (empty($exercise_id)) {
1830
-    				$sql = "SELECT id FROM $tbl_course_quiz
1829
+                if (empty($exercise_id)) {
1830
+                    $sql = "SELECT id FROM $tbl_course_quiz
1831 1831
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1832 1832
                     $result = Database::query($sql);
1833 1833
                     $exercise_list = array();
1834
-    				$exercise_id = null;
1834
+                    $exercise_id = null;
1835 1835
                     if (!empty($result) && Database::num_rows($result)) {
1836 1836
                         while ($row = Database::fetch_array($result)) {
1837 1837
                             $exercise_list[] = $row['id'];
@@ -1840,11 +1840,11 @@  discard block
 block discarded – undo
1840 1840
                     if (!empty($exercise_list)) {
1841 1841
                         $exercise_id = implode("','",$exercise_list);
1842 1842
                     }
1843
-    			}
1843
+                }
1844 1844
 
1845
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1845
+                $count_quiz = Database::fetch_row(Database::query($sql));
1846 1846
 
1847
-    			$sql = "SELECT
1847
+                $sql = "SELECT
1848 1848
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1849 1849
     			        COUNT(*) as num_attempts
1850 1850
     			        $select_lp_id
@@ -1858,20 +1858,20 @@  discard block
 block discarded – undo
1858 1858
                             $condition_into_lp
1859 1859
                         ORDER BY exe_date DESC";
1860 1860
 
1861
-    			$res = Database::query($sql);
1862
-    			$row = Database::fetch_array($res);
1863
-    			$quiz_avg_score = null;
1861
+                $res = Database::query($sql);
1862
+                $row = Database::fetch_array($res);
1863
+                $quiz_avg_score = null;
1864 1864
 
1865
-    			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1867
-    			}
1865
+                if (!empty($row['avg_score'])) {
1866
+                    $quiz_avg_score = round($row['avg_score'],2);
1867
+                }
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1870
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
-    			}
1872
-    			if (is_array($student_id)) {
1873
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
-    			}
1869
+                if(!empty($row['num_attempts'])) {
1870
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
+                }
1872
+                if (is_array($student_id)) {
1873
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
+                }
1875 1875
                 if ($into_lp == 0) {
1876 1876
                     return $quiz_avg_score;
1877 1877
                 } else {
@@ -1894,9 +1894,9 @@  discard block
 block discarded – undo
1894 1894
                         return array($quiz_avg_score, null);
1895 1895
                     }
1896 1896
                 }
1897
-    		}
1898
-    	}
1899
-    	return null;
1897
+            }
1898
+        }
1899
+        return null;
1900 1900
     }
1901 1901
 
1902 1902
     /**
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
         $find_all_lp = 0
1930 1930
     ) {
1931 1931
         $courseId = intval($courseId);
1932
-    	$student_id  = intval($student_id);
1933
-    	$exercise_id = intval($exercise_id);
1934
-    	$session_id  = intval($session_id);
1932
+        $student_id  = intval($student_id);
1933
+        $exercise_id = intval($exercise_id);
1934
+        $session_id  = intval($session_id);
1935 1935
 
1936
-    	$lp_id = intval($lp_id);
1936
+        $lp_id = intval($lp_id);
1937 1937
         $lp_item_id = intval($lp_item_id);
1938
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1938
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1939 1939
 
1940
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1940
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1941 1941
                 WHERE  ex.c_id = $courseId
1942 1942
                 AND ex.exe_exo_id = $exercise_id
1943 1943
                 AND status = ''
@@ -1952,11 +1952,11 @@  discard block
 block discarded – undo
1952 1952
                 AND orig_lp_item_id = $lp_item_id";
1953 1953
         }
1954 1954
 
1955
-    	$rs = Database::query($sql);
1956
-    	$row = Database::fetch_row($rs);
1957
-    	$count_attempts = $row[0];
1955
+        $rs = Database::query($sql);
1956
+        $row = Database::fetch_row($rs);
1957
+        $count_attempts = $row[0];
1958 1958
 
1959
-    	return $count_attempts;
1959
+        return $count_attempts;
1960 1960
     }
1961 1961
 
1962 1962
     /**
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
      * @param int    $user_id
1967 1967
      * @param int    $courseId
1968 1968
      * @param int    $session_id
1969
-    */
1969
+     */
1970 1970
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1971 1971
     {
1972 1972
         $courseId = intval($courseId);
@@ -3634,8 +3634,8 @@  discard block
 block discarded – undo
3634 3634
 
3635 3635
         $condition_session = '';
3636 3636
         if (isset($session_id)) {
3637
-             $session_id = intval($session_id);
3638
-             $condition_session = ' AND f.session_id = '. $session_id;
3637
+                $session_id = intval($session_id);
3638
+                $condition_session = ' AND f.session_id = '. $session_id;
3639 3639
         }
3640 3640
 
3641 3641
         $groupId = intval($groupId);
@@ -5564,9 +5564,9 @@  discard block
 block discarded – undo
5564 5564
     }
5565 5565
 
5566 5566
     /**
5567
-    * @param FormValidator $form
5568
-    * @return mixed
5569
-    */
5567
+     * @param FormValidator $form
5568
+     * @return mixed
5569
+     */
5570 5570
     public static function setUserSearchForm($form)
5571 5571
     {
5572 5572
         global $_configuration;
@@ -5961,26 +5961,26 @@  discard block
 block discarded – undo
5961 5961
         $session_id = api_get_session_id();
5962 5962
         $course_id = api_get_course_int_id();
5963 5963
 
5964
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5964
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5966 5966
 
5967
-    	$sql = "SELECT count(tool) AS total_number_of_items
5967
+        $sql = "SELECT count(tool) AS total_number_of_items
5968 5968
     	        FROM $table_item_property track_resource, $table_user user
5969 5969
     	        WHERE
5970 5970
                     track_resource.c_id = $course_id AND
5971 5971
                     track_resource.insert_user_id = user.user_id AND
5972 5972
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5973 5973
 
5974
-    	if (isset($_GET['keyword'])) {
5975
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5976
-    		$sql .= " AND (
5974
+        if (isset($_GET['keyword'])) {
5975
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5976
+            $sql .= " AND (
5977 5977
     		            user.username LIKE '%".$keyword."%' OR
5978 5978
     		            lastedit_type LIKE '%".$keyword."%' OR
5979 5979
     		            tool LIKE '%".$keyword."%'
5980 5980
                     )";
5981
-    	}
5981
+        }
5982 5982
 
5983
-    	$sql .= " AND tool IN (
5983
+        $sql .= " AND tool IN (
5984 5984
     	            'document',
5985 5985
     	            'learnpath',
5986 5986
     	            'quiz',
@@ -5992,10 +5992,10 @@  discard block
 block discarded – undo
5992 5992
     	            'thematic_advance',
5993 5993
     	            'thematic_plan'
5994 5994
                 )";
5995
-    	$res = Database::query($sql);
5996
-    	$obj = Database::fetch_object($res);
5995
+        $res = Database::query($sql);
5996
+        $obj = Database::fetch_object($res);
5997 5997
 
5998
-    	return $obj->total_number_of_items;
5998
+        return $obj->total_number_of_items;
5999 5999
     }
6000 6000
 
6001 6001
     /**
@@ -6010,12 +6010,12 @@  discard block
 block discarded – undo
6010 6010
         $session_id = api_get_session_id();
6011 6011
         $course_id = api_get_course_int_id();
6012 6012
 
6013
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
-    	$session_id = intval($session_id);
6013
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
+        $session_id = intval($session_id);
6017 6017
 
6018
-    	$sql = "SELECT
6018
+        $sql = "SELECT
6019 6019
                     tool as col0,
6020 6020
                     lastedit_type as col1,
6021 6021
                     ref as ref,
@@ -6029,16 +6029,16 @@  discard block
 block discarded – undo
6029 6029
                   track_resource.insert_user_id = user.user_id AND
6030 6030
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6031 6031
 
6032
-    	if (isset($_GET['keyword'])) {
6033
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
6034
-    		$sql .= " AND (
6032
+        if (isset($_GET['keyword'])) {
6033
+            $keyword = Database::escape_string(trim($_GET['keyword']));
6034
+            $sql .= " AND (
6035 6035
     		            user.username LIKE '%".$keyword."%' OR
6036 6036
     		            lastedit_type LIKE '%".$keyword."%' OR
6037 6037
     		            tool LIKE '%".$keyword."%'
6038 6038
                      ) ";
6039
-    	}
6039
+        }
6040 6040
 
6041
-    	$sql .= " AND tool IN (
6041
+        $sql .= " AND tool IN (
6042 6042
     	            'document',
6043 6043
     	            'learnpath',
6044 6044
     	            'quiz',
@@ -6051,41 +6051,41 @@  discard block
 block discarded – undo
6051 6051
     	            'thematic_plan'
6052 6052
                 )";
6053 6053
 
6054
-    	if ($column == 0) {
6055
-    		$column = '0';
6056
-    	}
6057
-    	if ($column != '' && $direction != '') {
6058
-    		if ($column != 2 && $column != 4) {
6059
-    			$sql .= " ORDER BY col$column $direction";
6060
-    		}
6061
-    	} else {
6062
-    		$sql .= " ORDER BY col5 DESC ";
6063
-    	}
6054
+        if ($column == 0) {
6055
+            $column = '0';
6056
+        }
6057
+        if ($column != '' && $direction != '') {
6058
+            if ($column != 2 && $column != 4) {
6059
+                $sql .= " ORDER BY col$column $direction";
6060
+            }
6061
+        } else {
6062
+            $sql .= " ORDER BY col5 DESC ";
6063
+        }
6064 6064
 
6065 6065
         $from = intval($from);
6066 6066
         $number_of_items = intval($number_of_items);
6067 6067
 
6068
-    	$sql .= " LIMIT $from, $number_of_items ";
6069
-
6070
-    	$res = Database::query($sql);
6071
-    	$resources = array();
6072
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
-    	while ($row = Database::fetch_array($res)) {
6074
-    		$ref = $row['ref'];
6075
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
6068
+        $sql .= " LIMIT $from, $number_of_items ";
6077 6069
 
6078
-    		$id = $table_name['id_tool'];
6079
-    		$recorset = false;
6080
-
6081
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
-    			$sql = "SELECT thematic_id FROM $table_tool
6070
+        $res = Database::query($sql);
6071
+        $resources = array();
6072
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
+        while ($row = Database::fetch_array($res)) {
6074
+            $ref = $row['ref'];
6075
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
+            $table_tool = Database :: get_course_table($table_name['table_name']);
6077
+
6078
+            $id = $table_name['id_tool'];
6079
+            $recorset = false;
6080
+
6081
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
+                $sql = "SELECT thematic_id FROM $table_tool
6084 6084
     			        WHERE c_id = $course_id AND id = $ref";
6085
-    			$rs_thematic  = Database::query($sql);
6086
-    			if (Database::num_rows($rs_thematic)) {
6087
-    				$row_thematic = Database::fetch_array($rs_thematic);
6088
-    				$thematic_id = $row_thematic['thematic_id'];
6085
+                $rs_thematic  = Database::query($sql);
6086
+                if (Database::num_rows($rs_thematic)) {
6087
+                    $row_thematic = Database::fetch_array($rs_thematic);
6088
+                    $thematic_id = $row_thematic['thematic_id'];
6089 6089
 
6090 6090
                     $sql = "SELECT session.id, session.name, user.username
6091 6091
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -6094,9 +6094,9 @@  discard block
 block discarded – undo
6094 6094
                               t.session_id = session.id AND
6095 6095
                               session.id_coach = user.user_id AND
6096 6096
                               t.id = $thematic_id";
6097
-    				$recorset = Database::query($sql);
6098
-    			}
6099
-    		} else {
6097
+                    $recorset = Database::query($sql);
6098
+                }
6099
+            } else {
6100 6100
                 $sql = "SELECT session.id, session.name, user.username
6101 6101
                           FROM $table_tool tool, $table_session session, $table_user user
6102 6102
     			          WHERE
@@ -6104,134 +6104,134 @@  discard block
 block discarded – undo
6104 6104
     			              tool.session_id = session.id AND
6105 6105
     			              session.id_coach = user.user_id AND
6106 6106
     			              tool.$id = $ref";
6107
-    			$recorset = Database::query($sql);
6108
-    		}
6109
-
6110
-    		if (!empty($recorset)) {
6111
-    			$obj = Database::fetch_object($recorset);
6112
-
6113
-    			$name_session = '';
6114
-    			$coach_name = '';
6115
-    			if (!empty($obj)) {
6116
-    				$name_session = $obj->name;
6117
-    				$coach_name   = $obj->username;
6118
-    			}
6119
-
6120
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
-    			$row[0] = '';
6122
-    			if ($row['col6'] != 2) {
6123
-    				if (in_array($row['col0'], $thematic_tools)) {
6124
-
6125
-    					$exp_thematic_tool = explode('_', $row['col0']);
6126
-    					$thematic_tool_title = '';
6127
-    					if (is_array($exp_thematic_tool)) {
6128
-    						foreach ($exp_thematic_tool as $exp) {
6129
-    							$thematic_tool_title .= api_ucfirst($exp);
6130
-    						}
6131
-    					} else {
6132
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6133
-    					}
6134
-
6135
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
-    				} else {
6137
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
-    				}
6139
-    			} else {
6140
-    				$row[0] = api_ucfirst($row['col0']);
6141
-    			}
6142
-    			$row[1] = get_lang($row[1]);
6143
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
-    			$row[5] = '';
6145
-    			//@todo Improve this code please
6146
-    			switch ($table_name['table_name']) {
6147
-    				case 'document':
6148
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
6107
+                $recorset = Database::query($sql);
6108
+            }
6109
+
6110
+            if (!empty($recorset)) {
6111
+                $obj = Database::fetch_object($recorset);
6112
+
6113
+                $name_session = '';
6114
+                $coach_name = '';
6115
+                if (!empty($obj)) {
6116
+                    $name_session = $obj->name;
6117
+                    $coach_name   = $obj->username;
6118
+                }
6119
+
6120
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
+                $row[0] = '';
6122
+                if ($row['col6'] != 2) {
6123
+                    if (in_array($row['col0'], $thematic_tools)) {
6124
+
6125
+                        $exp_thematic_tool = explode('_', $row['col0']);
6126
+                        $thematic_tool_title = '';
6127
+                        if (is_array($exp_thematic_tool)) {
6128
+                            foreach ($exp_thematic_tool as $exp) {
6129
+                                $thematic_tool_title .= api_ucfirst($exp);
6130
+                            }
6131
+                        } else {
6132
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6133
+                        }
6134
+
6135
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
+                    } else {
6137
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
+                    }
6139
+                } else {
6140
+                    $row[0] = api_ucfirst($row['col0']);
6141
+                }
6142
+                $row[1] = get_lang($row[1]);
6143
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
+                $row[5] = '';
6145
+                //@todo Improve this code please
6146
+                switch ($table_name['table_name']) {
6147
+                    case 'document':
6148
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6149 6149
                                 WHERE c_id = $course_id AND id = $ref";
6150
-    					$rs_document = Database::query($sql);
6151
-    					$obj_document = Database::fetch_object($rs_document);
6150
+                        $rs_document = Database::query($sql);
6151
+                        $obj_document = Database::fetch_object($rs_document);
6152 6152
                         if ($obj_document) {
6153 6153
                             $row[5] = $obj_document->title;
6154 6154
                         }
6155
-    					break;
6156
-    				case 'announcement':
6155
+                        break;
6156
+                    case 'announcement':
6157 6157
                         $sql = "SELECT title FROM $table_tool
6158 6158
                                 WHERE c_id = $course_id AND id = $ref";
6159
-    					$rs_document = Database::query($sql);
6160
-    					$obj_document = Database::fetch_object($rs_document);
6159
+                        $rs_document = Database::query($sql);
6160
+                        $obj_document = Database::fetch_object($rs_document);
6161 6161
                         if ($obj_document) {
6162 6162
                             $row[5] = $obj_document->title;
6163 6163
                         }
6164
-    					break;
6165
-    				case 'glossary':
6164
+                        break;
6165
+                    case 'glossary':
6166 6166
                         $sql = "SELECT name FROM $table_tool
6167 6167
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6168
-    					$rs_document = Database::query($sql);
6169
-    					$obj_document = Database::fetch_object($rs_document);
6168
+                        $rs_document = Database::query($sql);
6169
+                        $obj_document = Database::fetch_object($rs_document);
6170 6170
                         if ($obj_document) {
6171 6171
                             $row[5] = $obj_document->name;
6172 6172
                         }
6173
-    					break;
6174
-    				case 'lp':
6173
+                        break;
6174
+                    case 'lp':
6175 6175
                         $sql = "SELECT name
6176 6176
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6177
-    					$rs_document = Database::query($sql);
6178
-    					$obj_document = Database::fetch_object($rs_document);
6179
-    					$row[5] = $obj_document->name;
6180
-    					break;
6181
-    				case 'quiz':
6177
+                        $rs_document = Database::query($sql);
6178
+                        $obj_document = Database::fetch_object($rs_document);
6179
+                        $row[5] = $obj_document->name;
6180
+                        break;
6181
+                    case 'quiz':
6182 6182
                         $sql = "SELECT title FROM $table_tool
6183 6183
                                 WHERE c_id = $course_id AND id = $ref";
6184
-    					$rs_document = Database::query($sql);
6185
-    					$obj_document = Database::fetch_object($rs_document);
6184
+                        $rs_document = Database::query($sql);
6185
+                        $obj_document = Database::fetch_object($rs_document);
6186 6186
                         if ($obj_document) {
6187 6187
                             $row[5] = $obj_document->title;
6188 6188
                         }
6189
-    					break;
6190
-    				case 'course_description':
6189
+                        break;
6190
+                    case 'course_description':
6191 6191
                         $sql = "SELECT title FROM $table_tool
6192 6192
                                 WHERE c_id = $course_id AND id = $ref";
6193
-    					$rs_document = Database::query($sql);
6194
-    					$obj_document = Database::fetch_object($rs_document);
6193
+                        $rs_document = Database::query($sql);
6194
+                        $obj_document = Database::fetch_object($rs_document);
6195 6195
                         if ($obj_document) {
6196 6196
                             $row[5] = $obj_document->title;
6197 6197
                         }
6198
-    					break;
6199
-    				case 'thematic':
6200
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
-    					if (Database::num_rows($rs) > 0) {
6202
-    						$obj = Database::fetch_object($rs);
6198
+                        break;
6199
+                    case 'thematic':
6200
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
+                        if (Database::num_rows($rs) > 0) {
6202
+                            $obj = Database::fetch_object($rs);
6203 6203
                             if ($obj) {
6204 6204
                                 $row[5] = $obj->title;
6205 6205
                             }
6206
-    					}
6207
-    					break;
6208
-    				case 'thematic_advance':
6209
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
-    					if (Database::num_rows($rs) > 0) {
6211
-    						$obj = Database::fetch_object($rs);
6206
+                        }
6207
+                        break;
6208
+                    case 'thematic_advance':
6209
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
+                        if (Database::num_rows($rs) > 0) {
6211
+                            $obj = Database::fetch_object($rs);
6212 6212
                             if ($obj) {
6213 6213
                                 $row[5] = $obj->content;
6214 6214
                             }
6215
-    					}
6216
-    					break;
6217
-    				case 'thematic_plan':
6218
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
-    					if (Database::num_rows($rs) > 0) {
6220
-    						$obj = Database::fetch_object($rs);
6215
+                        }
6216
+                        break;
6217
+                    case 'thematic_plan':
6218
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
+                        if (Database::num_rows($rs) > 0) {
6220
+                            $obj = Database::fetch_object($rs);
6221 6221
                             if ($obj) {
6222 6222
                                 $row[5] = $obj->title;
6223 6223
                             }
6224
-    					}
6225
-    					break;
6226
-    				default:
6227
-    					break;
6228
-    			}
6229
-
6230
-    			$row2 = $name_session;
6231
-    			if (!empty($coach_name)) {
6232
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
-    			}
6234
-    			$row[2] = $row2;
6224
+                        }
6225
+                        break;
6226
+                    default:
6227
+                        break;
6228
+                }
6229
+
6230
+                $row2 = $name_session;
6231
+                if (!empty($coach_name)) {
6232
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
+                }
6234
+                $row[2] = $row2;
6235 6235
                 if (!empty($row['col3'])) {
6236 6236
                     $userInfo = api_get_user_info($row['user_id']);
6237 6237
                     $row['col3'] = Display::url(
@@ -6247,11 +6247,11 @@  discard block
 block discarded – undo
6247 6247
                     $row[4] = $ip;
6248 6248
                 }
6249 6249
 
6250
-    			$resources[] = $row;
6251
-    		}
6252
-    	}
6250
+                $resources[] = $row;
6251
+            }
6252
+        }
6253 6253
 
6254
-    	return $resources;
6254
+        return $resources;
6255 6255
     }
6256 6256
 
6257 6257
     /**
@@ -6261,63 +6261,63 @@  discard block
 block discarded – undo
6261 6261
      */
6262 6262
     public static function get_tool_name_table($tool)
6263 6263
     {
6264
-    	switch ($tool) {
6265
-    		case 'document':
6266
-    			$table_name = TABLE_DOCUMENT;
6267
-    			$link_tool = 'document/document.php';
6268
-    			$id_tool = 'id';
6269
-    			break;
6270
-    		case 'learnpath':
6271
-    			$table_name = TABLE_LP_MAIN;
6272
-    			$link_tool = 'lp/lp_controller.php';
6273
-    			$id_tool = 'id';
6274
-    			break;
6275
-    		case 'quiz':
6276
-    			$table_name = TABLE_QUIZ_TEST;
6277
-    			$link_tool = 'exercise/exercise.php';
6278
-    			$id_tool = 'id';
6279
-    			break;
6280
-    		case 'glossary':
6281
-    			$table_name = TABLE_GLOSSARY;
6282
-    			$link_tool = 'glossary/index.php';
6283
-    			$id_tool = 'glossary_id';
6284
-    			break;
6285
-    		case 'link':
6286
-    			$table_name = TABLE_LINK;
6287
-    			$link_tool = 'link/link.php';
6288
-    			$id_tool = 'id';
6289
-    			break;
6290
-    		case 'course_description':
6291
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6292
-    			$link_tool = 'course_description/';
6293
-    			$id_tool = 'id';
6294
-    			break;
6295
-    		case 'announcement':
6296
-    			$table_name = TABLE_ANNOUNCEMENT;
6297
-    			$link_tool = 'announcements/announcements.php';
6298
-    			$id_tool = 'id';
6299
-    			break;
6300
-    		case 'thematic':
6301
-    			$table_name = TABLE_THEMATIC;
6302
-    			$link_tool = 'course_progress/index.php';
6303
-    			$id_tool = 'id';
6304
-    			break;
6305
-    		case 'thematic_advance':
6306
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6307
-    			$link_tool = 'course_progress/index.php';
6308
-    			$id_tool = 'id';
6309
-    			break;
6310
-    		case 'thematic_plan':
6311
-    			$table_name = TABLE_THEMATIC_PLAN;
6312
-    			$link_tool = 'course_progress/index.php';
6313
-    			$id_tool = 'id';
6314
-    			break;
6315
-    		default:
6316
-    			$table_name = $tool;
6317
-    		break;
6318
-    	}
6319
-
6320
-    	return array(
6264
+        switch ($tool) {
6265
+            case 'document':
6266
+                $table_name = TABLE_DOCUMENT;
6267
+                $link_tool = 'document/document.php';
6268
+                $id_tool = 'id';
6269
+                break;
6270
+            case 'learnpath':
6271
+                $table_name = TABLE_LP_MAIN;
6272
+                $link_tool = 'lp/lp_controller.php';
6273
+                $id_tool = 'id';
6274
+                break;
6275
+            case 'quiz':
6276
+                $table_name = TABLE_QUIZ_TEST;
6277
+                $link_tool = 'exercise/exercise.php';
6278
+                $id_tool = 'id';
6279
+                break;
6280
+            case 'glossary':
6281
+                $table_name = TABLE_GLOSSARY;
6282
+                $link_tool = 'glossary/index.php';
6283
+                $id_tool = 'glossary_id';
6284
+                break;
6285
+            case 'link':
6286
+                $table_name = TABLE_LINK;
6287
+                $link_tool = 'link/link.php';
6288
+                $id_tool = 'id';
6289
+                break;
6290
+            case 'course_description':
6291
+                $table_name = TABLE_COURSE_DESCRIPTION;
6292
+                $link_tool = 'course_description/';
6293
+                $id_tool = 'id';
6294
+                break;
6295
+            case 'announcement':
6296
+                $table_name = TABLE_ANNOUNCEMENT;
6297
+                $link_tool = 'announcements/announcements.php';
6298
+                $id_tool = 'id';
6299
+                break;
6300
+            case 'thematic':
6301
+                $table_name = TABLE_THEMATIC;
6302
+                $link_tool = 'course_progress/index.php';
6303
+                $id_tool = 'id';
6304
+                break;
6305
+            case 'thematic_advance':
6306
+                $table_name = TABLE_THEMATIC_ADVANCE;
6307
+                $link_tool = 'course_progress/index.php';
6308
+                $id_tool = 'id';
6309
+                break;
6310
+            case 'thematic_plan':
6311
+                $table_name = TABLE_THEMATIC_PLAN;
6312
+                $link_tool = 'course_progress/index.php';
6313
+                $id_tool = 'id';
6314
+                break;
6315
+            default:
6316
+                $table_name = $tool;
6317
+            break;
6318
+        }
6319
+
6320
+        return array(
6321 6321
             'table_name' => $table_name,
6322 6322
             'link_tool' => $link_tool,
6323 6323
             'id_tool' => $id_tool
@@ -6326,45 +6326,45 @@  discard block
 block discarded – undo
6326 6326
 
6327 6327
     public static function display_additional_profile_fields()
6328 6328
     {
6329
-    	// getting all the extra profile fields that are defined by the platform administrator
6330
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
-
6332
-    	// creating the form
6333
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
-
6335
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
-    	// the information the users have entered or selected.
6337
-    	$return .= '<select name="additional_profile_field">';
6338
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
-    	$extra_fields_to_show = 0;
6340
-    	foreach ($extra_fields as $key=>$field) {
6341
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
-    		if ($field[6]==1 && $field[8] == 1) {
6343
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
-    				$selected = 'selected="selected"';
6345
-    			} else {
6346
-    				$selected = '';
6347
-    			}
6348
-    			$extra_fields_to_show++;
6349
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
-    		}
6351
-    	}
6352
-    	$return .= '</select>';
6353
-
6354
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6355
-    	foreach ($_GET as $key=>$value){
6356
-    		if ($key <> 'additional_profile_field')    {
6357
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
-    		}
6359
-    	}
6360
-    	// the submit button
6361
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
-    	$return .= '</form>';
6363
-    	if ($extra_fields_to_show > 0) {
6364
-    		return $return;
6365
-    	} else {
6366
-    		return '';
6367
-    	}
6329
+        // getting all the extra profile fields that are defined by the platform administrator
6330
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
+
6332
+        // creating the form
6333
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
+
6335
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
+        // the information the users have entered or selected.
6337
+        $return .= '<select name="additional_profile_field">';
6338
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
+        $extra_fields_to_show = 0;
6340
+        foreach ($extra_fields as $key=>$field) {
6341
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
+            if ($field[6]==1 && $field[8] == 1) {
6343
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
+                    $selected = 'selected="selected"';
6345
+                } else {
6346
+                    $selected = '';
6347
+                }
6348
+                $extra_fields_to_show++;
6349
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
+            }
6351
+        }
6352
+        $return .= '</select>';
6353
+
6354
+        // the form elements for the $_GET parameters (because the form is passed through GET
6355
+        foreach ($_GET as $key=>$value){
6356
+            if ($key <> 'additional_profile_field')    {
6357
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
+            }
6359
+        }
6360
+        // the submit button
6361
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
+        $return .= '</form>';
6363
+        if ($extra_fields_to_show > 0) {
6364
+            return $return;
6365
+        } else {
6366
+            return '';
6367
+        }
6368 6368
     }
6369 6369
 
6370 6370
     /**
@@ -6383,31 +6383,31 @@  discard block
 block discarded – undo
6383 6383
      */
6384 6384
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6385 6385
     {
6386
-    	// Database table definition
6387
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6386
+        // Database table definition
6387
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6389 6389
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6390
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6391
-
6392
-    	if (!empty($users)) {
6393
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
-    			foreach($users as $user_id) {
6395
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6396
-    				$tag_list = array();
6397
-    				foreach($user_result as $item) {
6398
-    					$tag_list[] = $item['tag'];
6399
-    				}
6400
-    				$return[$user_id][] = implode(', ',$tag_list);
6401
-    			}
6402
-    		} else {
6403
-    			$new_user_array = array();
6404
-    			foreach ($users as $user_id) {
6405
-    				$new_user_array[]= "'".$user_id."'";
6406
-    			}
6407
-    			$users = implode(',',$new_user_array);
6390
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6391
+
6392
+        if (!empty($users)) {
6393
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
+                foreach($users as $user_id) {
6395
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6396
+                    $tag_list = array();
6397
+                    foreach($user_result as $item) {
6398
+                        $tag_list[] = $item['tag'];
6399
+                    }
6400
+                    $return[$user_id][] = implode(', ',$tag_list);
6401
+                }
6402
+            } else {
6403
+                $new_user_array = array();
6404
+                foreach ($users as $user_id) {
6405
+                    $new_user_array[]= "'".$user_id."'";
6406
+                }
6407
+                $users = implode(',',$new_user_array);
6408 6408
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6409
-    			// Selecting only the necessary information NOT ALL the user list
6410
-    			$sql = "SELECT user.user_id, v.value
6409
+                // Selecting only the necessary information NOT ALL the user list
6410
+                $sql = "SELECT user.user_id, v.value
6411 6411
     			        FROM $table_user user
6412 6412
     			        INNER JOIN $table_user_field_values v
6413 6413
                         ON (user.user_id = v.item_id)
@@ -6418,27 +6418,27 @@  discard block
 block discarded – undo
6418 6418
                             v.field_id=".intval($field_id)." AND
6419 6419
                             user.user_id IN ($users)";
6420 6420
 
6421
-    			$result = Database::query($sql);
6422
-    			while($row = Database::fetch_array($result)) {
6423
-    				// get option value for field type double select by id
6424
-    				if (!empty($row['value'])) {
6425
-    					if ($result_extra_field['field_type'] ==
6421
+                $result = Database::query($sql);
6422
+                while($row = Database::fetch_array($result)) {
6423
+                    // get option value for field type double select by id
6424
+                    if (!empty($row['value'])) {
6425
+                        if ($result_extra_field['field_type'] ==
6426 6426
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6427 6427
                         ) {
6428
-    						$id_double_select = explode(';', $row['value']);
6429
-    						if (is_array($id_double_select)) {
6430
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
-    							$row['value'] = ($value1.';'.$value2);
6433
-    						}
6434
-    					}
6435
-    				}
6436
-    				// get other value from extra field
6437
-    				$return[$row['user_id']][] = $row['value'];
6438
-    			}
6439
-    		}
6440
-    	}
6441
-    	return $return;
6428
+                            $id_double_select = explode(';', $row['value']);
6429
+                            if (is_array($id_double_select)) {
6430
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
+                                $row['value'] = ($value1.';'.$value2);
6433
+                            }
6434
+                        }
6435
+                    }
6436
+                    // get other value from extra field
6437
+                    $return[$row['user_id']][] = $row['value'];
6438
+                }
6439
+            }
6440
+        }
6441
+        return $return;
6442 6442
     }
6443 6443
 
6444 6444
     /**
@@ -6447,18 +6447,18 @@  discard block
 block discarded – undo
6447 6447
      */
6448 6448
     public function count_student_in_course()
6449 6449
     {
6450
-    	global $nbStudents;
6451
-    	return $nbStudents;
6450
+        global $nbStudents;
6451
+        return $nbStudents;
6452 6452
     }
6453 6453
 
6454 6454
     public function sort_users($a, $b)
6455 6455
     {
6456
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6456
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6457 6457
     }
6458 6458
 
6459 6459
     public function sort_users_desc($a, $b)
6460 6460
     {
6461
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6461
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6462 6462
     }
6463 6463
 
6464 6464
     /**
@@ -6467,8 +6467,8 @@  discard block
 block discarded – undo
6467 6467
      */
6468 6468
     public static function get_number_of_users()
6469 6469
     {
6470
-    	global $user_ids;
6471
-    	return count($user_ids);
6470
+        global $user_ids;
6471
+        return count($user_ids);
6472 6472
     }
6473 6473
 
6474 6474
     /**
@@ -6484,37 +6484,37 @@  discard block
 block discarded – undo
6484 6484
     {
6485 6485
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6486 6486
 
6487
-    	$course_code = Database::escape_string($course_code);
6488
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6487
+        $course_code = Database::escape_string($course_code);
6488
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6490 6490
 
6491
-    	$access_url_id = api_get_current_access_url_id();
6491
+        $access_url_id = api_get_current_access_url_id();
6492 6492
 
6493
-    	// get all users data from a course for sortable with limit
6494
-    	if (is_array($user_ids)) {
6495
-    		$user_ids = array_map('intval', $user_ids);
6496
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
-    	} else {
6498
-    		$user_ids = intval($user_ids);
6499
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6500
-    	}
6493
+        // get all users data from a course for sortable with limit
6494
+        if (is_array($user_ids)) {
6495
+            $user_ids = array_map('intval', $user_ids);
6496
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
+        } else {
6498
+            $user_ids = intval($user_ids);
6499
+            $condition_user = " WHERE user.user_id = $user_ids ";
6500
+        }
6501 6501
 
6502
-    	if (!empty($_GET['user_keyword'])) {
6503
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
-    		$condition_user .=  " AND (
6502
+        if (!empty($_GET['user_keyword'])) {
6503
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
+            $condition_user .=  " AND (
6505 6505
                 user.firstname LIKE '%".$keyword."%' OR
6506 6506
                 user.lastname LIKE '%".$keyword."%'  OR
6507 6507
                 user.username LIKE '%".$keyword."%'  OR
6508 6508
                 user.email LIKE '%".$keyword."%'
6509 6509
              ) ";
6510
-    	}
6510
+        }
6511 6511
 
6512 6512
         $url_table = null;
6513 6513
         $url_condition = null;
6514
-    	if (api_is_multiple_url_enabled()) {
6515
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6516
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
-    	}
6514
+        if (api_is_multiple_url_enabled()) {
6515
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6516
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
+        }
6518 6518
 
6519 6519
         $invitedUsersCondition = '';
6520 6520
 
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6523 6523
         }
6524 6524
 
6525
-    	$sql = "SELECT  user.user_id as user_id,
6525
+        $sql = "SELECT  user.user_id as user_id,
6526 6526
                     user.official_code  as col0,
6527 6527
                     user.lastname       as col1,
6528 6528
                     user.firstname      as col2,
@@ -6530,16 +6530,16 @@  discard block
 block discarded – undo
6530 6530
                 FROM $tbl_user as user $url_table
6531 6531
     	        $condition_user $url_condition $invitedUsersCondition";
6532 6532
 
6533
-    	if (!in_array($direction, array('ASC','DESC'))) {
6534
-    		$direction = 'ASC';
6535
-    	}
6533
+        if (!in_array($direction, array('ASC','DESC'))) {
6534
+            $direction = 'ASC';
6535
+        }
6536 6536
 
6537
-    	$column = intval($column);
6538
-    	$from = intval($from);
6539
-    	$number_of_items = intval($number_of_items);
6537
+        $column = intval($column);
6538
+        $from = intval($from);
6539
+        $number_of_items = intval($number_of_items);
6540 6540
 
6541
-    	$sql .= " ORDER BY col$column $direction ";
6542
-    	$sql .= " LIMIT $from,$number_of_items";
6541
+        $sql .= " ORDER BY col$column $direction ";
6542
+        $sql .= " LIMIT $from,$number_of_items";
6543 6543
 
6544 6544
         $res = Database::query($sql);
6545 6545
         $users = array();
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
             }
6574 6574
         }
6575 6575
 
6576
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6576
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6577 6577
             $courseInfo = api_get_course_info($course_code);
6578 6578
             $courseId = $courseInfo['real_id'];
6579 6579
 
@@ -6604,10 +6604,10 @@  discard block
 block discarded – undo
6604 6604
                 $session_id
6605 6605
             );
6606 6606
 
6607
-    		if (empty($avg_student_progress)) {
6607
+            if (empty($avg_student_progress)) {
6608 6608
                 $avg_student_progress = 0;
6609
-    		}
6610
-    		$user['average_progress'] = $avg_student_progress.'%';
6609
+            }
6610
+            $user['average_progress'] = $avg_student_progress.'%';
6611 6611
 
6612 6612
             $total_user_exercise = Tracking::get_exercise_student_progress(
6613 6613
                 $total_exercises,
@@ -6627,11 +6627,11 @@  discard block
 block discarded – undo
6627 6627
 
6628 6628
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6629 6629
 
6630
-    		if (is_numeric($avg_student_score)) {
6631
-    			$user['student_score']  = $avg_student_score.'%';
6632
-    		} else {
6633
-    			$user['student_score']  = $avg_student_score;
6634
-    		}
6630
+            if (is_numeric($avg_student_score)) {
6631
+                $user['student_score']  = $avg_student_score.'%';
6632
+            } else {
6633
+                $user['student_score']  = $avg_student_score;
6634
+            }
6635 6635
 
6636 6636
             $user['count_assignments'] = Tracking::count_student_assignments(
6637 6637
                 $user['user_id'],
@@ -6654,29 +6654,29 @@  discard block
 block discarded – undo
6654 6654
                 $session_id
6655 6655
             );
6656 6656
 
6657
-    		// we need to display an additional profile field
6658
-    		$user['additional'] = '';
6657
+            // we need to display an additional profile field
6658
+            $user['additional'] = '';
6659 6659
 
6660
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6660
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6662 6662
                     is_array($additional_user_profile_info[$user['user_id']])
6663 6663
                 ) {
6664
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
-    			}
6666
-    		}
6664
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
+                }
6666
+            }
6667 6667
 
6668 6668
             if (empty($session_id)) {
6669 6669
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6670 6670
             }
6671 6671
 
6672
-    		$user['link'] = '<center>
6672
+            $user['link'] = '<center>
6673 6673
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6674 6674
     		                 '.Display::return_icon('2rightarrow.png').'
6675 6675
     		                 </a>
6676 6676
                          </center>';
6677 6677
 
6678
-    		// store columns in array $users
6679
-    		$is_western_name_order = api_is_western_name_order();
6678
+            // store columns in array $users
6679
+            $is_western_name_order = api_is_western_name_order();
6680 6680
             $user_row = array();
6681 6681
             $user_row[]= $user['official_code']; //0
6682 6682
             if ($is_western_name_order) {
@@ -6712,21 +6712,21 @@  discard block
 block discarded – undo
6712 6712
 
6713 6713
             $users[] = $user_row;
6714 6714
 
6715
-    		if ($export_csv) {
6716
-    		    if (empty($session_id)) {
6715
+            if ($export_csv) {
6716
+                if (empty($session_id)) {
6717 6717
                     $user_row = array_map('strip_tags', $user_row);
6718
-    			    unset($user_row[14]);
6719
-    			    unset($user_row[15]);
6718
+                    unset($user_row[14]);
6719
+                    unset($user_row[15]);
6720 6720
                 } else {
6721 6721
                     $user_row = array_map('strip_tags', $user_row);
6722 6722
                     unset($user_row[13]);
6723 6723
                     unset($user_row[14]);
6724 6724
                 }
6725 6725
 
6726
-    			$csv_content[] = $user_row;
6727
-    		}
6728
-    	}
6729
-    	return $users;
6726
+                $csv_content[] = $user_row;
6727
+            }
6728
+        }
6729
+        return $users;
6730 6730
     }
6731 6731
 }
6732 6732
 
@@ -6744,18 +6744,18 @@  discard block
 block discarded – undo
6744 6744
      */
6745 6745
     public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6746 6746
     {
6747
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6748
-
6749
-    	// protected data
6750
-    	$user_id = intval($user_id);
6751
-    	$session_id = intval($session_id);
6752
-    	$course_id = Database::escape_string($course_id);
6753
-
6754
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
-    	$tempView = $view;
6756
-    	if(substr($view,0,1) == '1') {
6757
-    		$new_view = substr_replace($view,'0',0,1);
6758
-    		echo "
6747
+        $MonthsLong = $GLOBALS['MonthsLong'];
6748
+
6749
+        // protected data
6750
+        $user_id = intval($user_id);
6751
+        $session_id = intval($session_id);
6752
+        $course_id = Database::escape_string($course_id);
6753
+
6754
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
+        $tempView = $view;
6756
+        if(substr($view,0,1) == '1') {
6757
+            $new_view = substr_replace($view,'0',0,1);
6758
+            echo "
6759 6759
                 <tr>
6760 6760
                     <td valign='top'>
6761 6761
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6763,9 +6763,9 @@  discard block
 block discarded – undo
6763 6763
                     </td>
6764 6764
                 </tr>
6765 6765
                 ";
6766
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6766
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6767 6767
 
6768
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6768
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6769 6769
                         FROM $track_access_table
6770 6770
                         WHERE access_user_id = $user_id
6771 6771
                         AND c_id = $course_id
@@ -6773,11 +6773,11 @@  discard block
 block discarded – undo
6773 6773
                         GROUP BY YEAR(access_date),MONTH(access_date)
6774 6774
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6775 6775
 
6776
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
-    		$results = getManyResults3Col($sql);
6776
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
+            $results = getManyResults3Col($sql);
6778 6778
 
6779
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
-    		echo "<tr>
6779
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
+            echo "<tr>
6781 6781
                     <td class='secLine'>
6782 6782
                     ".get_lang('LoginsTitleMonthColumn')."
6783 6783
                     </td>
@@ -6785,36 +6785,36 @@  discard block
 block discarded – undo
6785 6785
                     ".get_lang('LoginsTitleCountColumn')."
6786 6786
                     </td>
6787 6787
                 </tr>";
6788
-    		$total = 0;
6789
-    		if (is_array($results)) {
6790
-    			for($j = 0 ; $j < count($results) ; $j++) {
6791
-    				echo "<tr>";
6792
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
-    				echo"</tr>";
6795
-    				$total = $total + $results[$j][1];
6796
-    			}
6797
-    			echo "<tr>";
6798
-    			echo "<td>".get_lang('Total')."</td>";
6799
-    			echo "<td align='right' class='content'>".$total."</td>";
6800
-    			echo"</tr>";
6801
-    		} else {
6802
-    			echo "<tr>";
6803
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
-    			echo"</tr>";
6805
-    		}
6806
-    		echo "</table>";
6807
-    		echo "</td></tr>";
6808
-    	} else {
6809
-    		$new_view = substr_replace($view,'1',0,1);
6810
-    		echo "
6788
+            $total = 0;
6789
+            if (is_array($results)) {
6790
+                for($j = 0 ; $j < count($results) ; $j++) {
6791
+                    echo "<tr>";
6792
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
+                    echo"</tr>";
6795
+                    $total = $total + $results[$j][1];
6796
+                }
6797
+                echo "<tr>";
6798
+                echo "<td>".get_lang('Total')."</td>";
6799
+                echo "<td align='right' class='content'>".$total."</td>";
6800
+                echo"</tr>";
6801
+            } else {
6802
+                echo "<tr>";
6803
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
+                echo"</tr>";
6805
+            }
6806
+            echo "</table>";
6807
+            echo "</td></tr>";
6808
+        } else {
6809
+            $new_view = substr_replace($view,'1',0,1);
6810
+            echo "
6811 6811
                 <tr>
6812 6812
                     <td valign='top'>
6813 6813
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6814 6814
                     </td>
6815 6815
                 </tr>
6816 6816
             ";
6817
-    	}
6817
+        }
6818 6818
     }
6819 6819
 
6820 6820
     /**
@@ -6827,38 +6827,38 @@  discard block
 block discarded – undo
6827 6827
      */
6828 6828
     public static function display_exercise_tracking_info($view, $user_id, $courseCode)
6829 6829
     {
6830
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6830
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6831 6831
         $courseId = api_get_course_int_id($courseCode);
6832
-    	if(substr($view,1,1) == '1') {
6833
-    		$new_view = substr_replace($view,'0',1,1);
6834
-    		echo "<tr>
6832
+        if(substr($view,1,1) == '1') {
6833
+            $new_view = substr_replace($view,'0',1,1);
6834
+            echo "<tr>
6835 6835
                     <td valign='top'>
6836 6836
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6837 6837
                     </td>
6838 6838
                 </tr>";
6839
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6839
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6840 6840
 
6841
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6841
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6842 6842
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6843 6843
                     WHERE te.c_id = $courseId
6844 6844
                         AND te.exe_user_id = ".intval($user_id)."
6845 6845
                         AND te.exe_exo_id = ce.id
6846 6846
                     ORDER BY ce.title ASC, te.exe_date ASC";
6847 6847
 
6848
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6848
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6849 6849
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6850 6850
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6851 6851
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6852 6852
 
6853
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6853
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6854 6854
 
6855
-    		$NoTestRes = 0;
6856
-    		$NoHPTestRes = 0;
6855
+            $NoTestRes = 0;
6856
+            $NoHPTestRes = 0;
6857 6857
 
6858
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6860
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
-    		echo "
6858
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6860
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
+            echo "
6862 6862
                 <tr bgcolor='#E6E6E6'>
6863 6863
                     <td>
6864 6864
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6871,28 +6871,28 @@  discard block
 block discarded – undo
6871 6871
                     </td>
6872 6872
                 </tr>";
6873 6873
 
6874
-    		if (is_array($results)) {
6875
-    			for($i = 0; $i < sizeof($results); $i++) {
6876
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
-    				echo "<tr>\n";
6878
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
-    				echo "<td class='content'>".$display_date."</td>\n";
6880
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
-    				echo "</tr>\n";
6882
-    			}
6883
-    		} else {
6884
-    			// istvan begin
6885
-    			$NoTestRes = 1;
6886
-    		}
6887
-
6888
-    		// The Result of Tests
6889
-    		if (is_array($hpresults)) {
6890
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6891
-    				$title = GetQuizName($hpresults[$i][0],'');
6892
-    				if ($title == '')
6893
-    				$title = basename($hpresults[$i][0]);
6894
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
-    				?>
6874
+            if (is_array($results)) {
6875
+                for($i = 0; $i < sizeof($results); $i++) {
6876
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
+                    echo "<tr>\n";
6878
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
+                    echo "<td class='content'>".$display_date."</td>\n";
6880
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
+                    echo "</tr>\n";
6882
+                }
6883
+            } else {
6884
+                // istvan begin
6885
+                $NoTestRes = 1;
6886
+            }
6887
+
6888
+            // The Result of Tests
6889
+            if (is_array($hpresults)) {
6890
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6891
+                    $title = GetQuizName($hpresults[$i][0],'');
6892
+                    if ($title == '')
6893
+                    $title = basename($hpresults[$i][0]);
6894
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
+                    ?>
6896 6896
                     <tr>
6897 6897
                         <td class="content"><?php echo $title; ?></td>
6898 6898
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6902,26 +6902,26 @@  discard block
 block discarded – undo
6902 6902
 
6903 6903
                     <?php
6904 6904
                 }
6905
-    		} else {
6906
-    			$NoHPTestRes = 1;
6907
-    		}
6908
-
6909
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
-    			echo "<tr>\n";
6911
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
-    			echo "</tr>\n";
6913
-    		}
6914
-    		echo "</table>";
6915
-    		echo "</td>\n</tr>\n";
6916
-    	} else {
6917
-    		$new_view = substr_replace($view,'1',1,1);
6918
-    		echo "
6905
+            } else {
6906
+                $NoHPTestRes = 1;
6907
+            }
6908
+
6909
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
+                echo "<tr>\n";
6911
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
+                echo "</tr>\n";
6913
+            }
6914
+            echo "</table>";
6915
+            echo "</td>\n</tr>\n";
6916
+        } else {
6917
+            $new_view = substr_replace($view,'1',1,1);
6918
+            echo "
6919 6919
                 <tr>
6920 6920
                     <td valign='top'>
6921 6921
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6922 6922
                     </td>
6923 6923
                 </tr>";
6924
-    	}
6924
+        }
6925 6925
     }
6926 6926
 
6927 6927
     /**
@@ -6930,27 +6930,27 @@  discard block
 block discarded – undo
6930 6930
      */
6931 6931
     public static function display_student_publications_tracking_info($view, $user_id, $course_id)
6932 6932
     {
6933
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6933
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6934 6934
         $_course = api_get_course_info_by_id($course_id);
6935 6935
 
6936
-    	if (substr($view,2,1) == '1') {
6937
-    		$new_view = substr_replace($view,'0',2,1);
6938
-    		echo "<tr>
6936
+        if (substr($view,2,1) == '1') {
6937
+            $new_view = substr_replace($view,'0',2,1);
6938
+            echo "<tr>
6939 6939
                     <td valign='top'>
6940 6940
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6941 6941
                     </td>
6942 6942
                 </tr>";
6943
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6943
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6945 6945
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6946 6946
                     WHERE u.upload_work_id = w.id
6947 6947
                         AND u.upload_user_id = '".intval($user_id)."'
6948 6948
                         AND u.c_id = '".intval($course_id)."'
6949 6949
                     ORDER BY u.upload_date DESC";
6950
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6952
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
-    		echo "<tr>
6950
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6952
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
+            echo "<tr>
6954 6954
                     <td class='secLine' width='40%'>
6955 6955
                     ".get_lang('WorkTitle')."
6956 6956
                     </td>
@@ -6961,35 +6961,35 @@  discard block
 block discarded – undo
6961 6961
                     ".get_lang('Date')."
6962 6962
                     </td>
6963 6963
                 </tr>";
6964
-    		if (is_array($results)) {
6965
-    			for($j = 0 ; $j < count($results) ; $j++) {
6966
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>"
6970
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
-    				."</td>";
6972
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6973
-    				echo "<td class='content'>".$beautifulDate."</td>";
6974
-    				echo"</tr>";
6975
-    			}
6976
-    		} else {
6977
-    			echo "<tr>";
6978
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
-    			echo"</tr>";
6980
-    		}
6981
-    		echo "</table>";
6982
-    		echo "</td></tr>";
6983
-    	} else {
6984
-    		$new_view = substr_replace($view,'1',2,1);
6985
-    		echo "
6964
+            if (is_array($results)) {
6965
+                for($j = 0 ; $j < count($results) ; $j++) {
6966
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>"
6970
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
+                    ."</td>";
6972
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6973
+                    echo "<td class='content'>".$beautifulDate."</td>";
6974
+                    echo"</tr>";
6975
+                }
6976
+            } else {
6977
+                echo "<tr>";
6978
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
+                echo"</tr>";
6980
+            }
6981
+            echo "</table>";
6982
+            echo "</td></tr>";
6983
+        } else {
6984
+            $new_view = substr_replace($view,'1',2,1);
6985
+            echo "
6986 6986
                 <tr>
6987 6987
                     <td valign='top'>
6988 6988
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6989 6989
                     </td>
6990 6990
                 </tr>
6991 6991
             ";
6992
-    	}
6992
+        }
6993 6993
     }
6994 6994
 
6995 6995
     /**
@@ -6998,55 +6998,55 @@  discard block
 block discarded – undo
6998 6998
      */
6999 6999
     public static function display_links_tracking_info($view, $user_id, $courseCode)
7000 7000
     {
7001
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7001
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7002 7002
         $courseId = api_get_course_int_id($courseCode);
7003
-    	if (substr($view,3,1) == '1') {
7004
-    		$new_view = substr_replace($view,'0',3,1);
7005
-    		echo "
7003
+        if (substr($view,3,1) == '1') {
7004
+            $new_view = substr_replace($view,'0',3,1);
7005
+            echo "
7006 7006
                 <tr>
7007 7007
                         <td valign='top'>
7008 7008
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
7009 7009
                         </td>
7010 7010
                 </tr>
7011 7011
             ";
7012
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
-    		$sql = "SELECT cl.title, cl.url
7012
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
+            $sql = "SELECT cl.title, cl.url
7014 7014
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7015 7015
                     WHERE sl.links_link_id = cl.id
7016 7016
                         AND sl.c_id = $courseId
7017 7017
                         AND sl.links_user_id = ".intval($user_id)."
7018 7018
                     GROUP BY cl.title, cl.url";
7019
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
-    		$results = StatsUtils::getManyResults2Col($sql);
7021
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
-    		echo "<tr>
7019
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
+            $results = StatsUtils::getManyResults2Col($sql);
7021
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
+            echo "<tr>
7023 7023
                     <td class='secLine'>
7024 7024
                     ".get_lang('LinksTitleLinkColumn')."
7025 7025
                     </td>
7026 7026
                 </tr>";
7027
-    		if (is_array($results)) {
7028
-    			for($j = 0 ; $j < count($results) ; $j++) {
7029
-    				echo "<tr>";
7030
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
-    				echo"</tr>";
7032
-    			}
7033
-    		} else {
7034
-    			echo "<tr>";
7035
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
-    			echo"</tr>";
7037
-    		}
7038
-    		echo "</table>";
7039
-    		echo "</td></tr>";
7040
-    	} else {
7041
-    		$new_view = substr_replace($view,'1',3,1);
7042
-    		echo "
7027
+            if (is_array($results)) {
7028
+                for($j = 0 ; $j < count($results) ; $j++) {
7029
+                    echo "<tr>";
7030
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
+                    echo"</tr>";
7032
+                }
7033
+            } else {
7034
+                echo "<tr>";
7035
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
+                echo"</tr>";
7037
+            }
7038
+            echo "</table>";
7039
+            echo "</td></tr>";
7040
+        } else {
7041
+            $new_view = substr_replace($view,'1',3,1);
7042
+            echo "
7043 7043
                 <tr>
7044 7044
                     <td valign='top'>
7045 7045
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
7046 7046
                     </td>
7047 7047
                 </tr>
7048 7048
             ";
7049
-    	}
7049
+        }
7050 7050
     }
7051 7051
 
7052 7052
     /**
@@ -7059,61 +7059,61 @@  discard block
 block discarded – undo
7059 7059
      */
7060 7060
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
7061 7061
     {
7062
-    	// protect data
7062
+        // protect data
7063 7063
         $user_id = intval($user_id);
7064 7064
         $courseId = api_get_course_int_id($course_code);
7065
-    	$session_id = intval($session_id);
7065
+        $session_id = intval($session_id);
7066 7066
 
7067
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
-    	if(substr($view,4,1) == '1') {
7069
-    		$new_view = substr_replace($view,'0',4,1);
7070
-    		echo "
7067
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
+        if(substr($view,4,1) == '1') {
7069
+            $new_view = substr_replace($view,'0',4,1);
7070
+            echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
7073 7073
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
7074 7074
                     </td>
7075 7075
                 </tr>
7076 7076
             ";
7077
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7077
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7078 7078
 
7079
-    		$sql = "SELECT down_doc_path
7079
+            $sql = "SELECT down_doc_path
7080 7080
                     FROM $downloads_table
7081 7081
                     WHERE c_id = $courseId
7082 7082
                         AND down_user_id = $user_id
7083 7083
                         AND down_session_id = $session_id
7084 7084
                     GROUP BY down_doc_path";
7085 7085
 
7086
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
-    		$results = StatsUtils::getManyResults1Col($sql);
7088
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
-    		echo "<tr>
7086
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
+            $results = StatsUtils::getManyResults1Col($sql);
7088
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
+            echo "<tr>
7090 7090
                     <td class='secLine'>
7091 7091
                     ".get_lang('DocumentsTitleDocumentColumn')."
7092 7092
                     </td>
7093 7093
                 </tr>";
7094
-    		if (is_array($results)) {
7095
-    			for($j = 0 ; $j < count($results) ; $j++) {
7096
-    				echo "<tr>";
7097
-    				echo "<td class='content'>".$results[$j]."</td>";
7098
-    				echo"</tr>";
7099
-    			}
7100
-    		} else {
7101
-    			echo "<tr>";
7102
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
-    			echo"</tr>";
7104
-    		}
7105
-    		echo "</table>";
7106
-    		echo "</td></tr>";
7107
-    	} else {
7108
-    		$new_view = substr_replace($view,'1',4,1);
7109
-    		echo "
7094
+            if (is_array($results)) {
7095
+                for($j = 0 ; $j < count($results) ; $j++) {
7096
+                    echo "<tr>";
7097
+                    echo "<td class='content'>".$results[$j]."</td>";
7098
+                    echo"</tr>";
7099
+                }
7100
+            } else {
7101
+                echo "<tr>";
7102
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
+                echo"</tr>";
7104
+            }
7105
+            echo "</table>";
7106
+            echo "</td></tr>";
7107
+        } else {
7108
+            $new_view = substr_replace($view,'1',4,1);
7109
+            echo "
7110 7110
                 <tr>
7111 7111
                     <td valign='top'>
7112 7112
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
7113 7113
                     </td>
7114 7114
                 </tr>
7115 7115
             ";
7116
-    	}
7116
+        }
7117 7117
     }
7118 7118
 
7119 7119
     /**
@@ -7170,43 +7170,43 @@  discard block
 block discarded – undo
7170 7170
      */
7171 7171
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7172 7172
     {
7173
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7174
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
-
7176
-    	// protected data
7177
-    	$user_id    = intval($user_id);
7178
-    	$session_id = intval($session_id);
7179
-    	$course_id  = intval($course_id);
7180
-
7181
-    	$tempView = $view;
7182
-    	if (substr($view,0,1) == '1') {
7183
-    		$new_view = substr_replace($view,'0',0,1);
7184
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7173
+        $MonthsLong = $GLOBALS['MonthsLong'];
7174
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
+
7176
+        // protected data
7177
+        $user_id    = intval($user_id);
7178
+        $session_id = intval($session_id);
7179
+        $course_id  = intval($course_id);
7180
+
7181
+        $tempView = $view;
7182
+        if (substr($view,0,1) == '1') {
7183
+            $new_view = substr_replace($view,'0',0,1);
7184
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7186 7186
                     FROM $track_access_table
7187 7187
                     WHERE access_user_id = $user_id
7188 7188
                     AND c_id = $course_id
7189 7189
                     AND access_session_id = $session_id
7190 7190
                     GROUP BY YEAR(access_date),MONTH(access_date)
7191 7191
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7192
-    		//$results = getManyResults2Col($sql);
7193
-    		$results = getManyResults3Col($sql);
7194
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
-    		$line='';
7196
-    		$total = 0;
7197
-    		if (is_array($results)) {
7198
-    			for($j = 0 ; $j < count($results) ; $j++) {
7199
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
-    				$total = $total + $results[$j][1];
7201
-    			}
7202
-    			$line .= get_lang('Total').";".$total."\n";
7203
-    		} else {
7204
-    			$line= get_lang('NoResult')."</center></td>";
7205
-    		}
7206
-    	} else {
7207
-    		$new_view = substr_replace($view,'1',0,1);
7208
-    	}
7209
-    	return array($title_line, $line);
7192
+            //$results = getManyResults2Col($sql);
7193
+            $results = getManyResults3Col($sql);
7194
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
+            $line='';
7196
+            $total = 0;
7197
+            if (is_array($results)) {
7198
+                for($j = 0 ; $j < count($results) ; $j++) {
7199
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
+                    $total = $total + $results[$j][1];
7201
+                }
7202
+                $line .= get_lang('Total').";".$total."\n";
7203
+            } else {
7204
+                $line= get_lang('NoResult')."</center></td>";
7205
+            }
7206
+        } else {
7207
+            $new_view = substr_replace($view,'1',0,1);
7208
+        }
7209
+        return array($title_line, $line);
7210 7210
     }
7211 7211
 
7212 7212
     /**
@@ -7219,67 +7219,67 @@  discard block
 block discarded – undo
7219 7219
      */
7220 7220
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7221 7221
     {
7222
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7222
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7223 7223
         $courseId = api_get_course_int_id($courseCode);
7224 7224
         $userId = intval($userId);
7225
-    	if (substr($view,1,1) == '1') {
7226
-    		$new_view = substr_replace($view,'0',1,1);
7227
-    		$title[1] = get_lang('ExercicesDetails');
7228
-    		$line = '';
7229
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7225
+        if (substr($view,1,1) == '1') {
7226
+            $new_view = substr_replace($view,'0',1,1);
7227
+            $title[1] = get_lang('ExercicesDetails');
7228
+            $line = '';
7229
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7230 7230
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7231 7231
                     WHERE te.c_id = $courseId
7232 7232
                         AND te.exe_user_id = $userId
7233 7233
                         AND te.exe_exo_id = ce.id
7234 7234
                     ORDER BY ce.title ASC, te.exe_date ASC";
7235 7235
 
7236
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7236
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7237 7237
                         FROM $TABLETRACK_HOTPOTATOES AS te
7238 7238
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7239 7239
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7240 7240
 
7241
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7241
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7242 7242
 
7243
-    		$NoTestRes = 0;
7244
-    		$NoHPTestRes = 0;
7243
+            $NoTestRes = 0;
7244
+            $NoHPTestRes = 0;
7245 7245
 
7246
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7247
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7246
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7247
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7248 7248
 
7249
-    		if (is_array($results)) {
7250
-    			for($i = 0; $i < sizeof($results); $i++)
7251
-    			{
7252
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
-    			}
7255
-    		} else {
7249
+            if (is_array($results)) {
7250
+                for($i = 0; $i < sizeof($results); $i++)
7251
+                {
7252
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
+                }
7255
+            } else {
7256 7256
                 // istvan begin
7257
-    			$NoTestRes = 1;
7258
-    		}
7259
-
7260
-    		// The Result of Tests
7261
-    		if (is_array($hpresults)) {
7262
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7263
-    				$title = GetQuizName($hpresults[$i][0],'');
7264
-
7265
-    				if ($title == '')
7266
-    				$title = basename($hpresults[$i][0]);
7267
-
7268
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
-
7270
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
-    			}
7272
-    		} else {
7273
-    			$NoHPTestRes = 1;
7274
-    		}
7275
-
7276
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
-    			$line=get_lang('NoResult');
7278
-    		}
7279
-    	} else {
7280
-    		$new_view = substr_replace($view,'1',1,1);
7281
-    	}
7282
-    	return array($title_line, $line);
7257
+                $NoTestRes = 1;
7258
+            }
7259
+
7260
+            // The Result of Tests
7261
+            if (is_array($hpresults)) {
7262
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7263
+                    $title = GetQuizName($hpresults[$i][0],'');
7264
+
7265
+                    if ($title == '')
7266
+                    $title = basename($hpresults[$i][0]);
7267
+
7268
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
+
7270
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
+                }
7272
+            } else {
7273
+                $NoHPTestRes = 1;
7274
+            }
7275
+
7276
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
+                $line=get_lang('NoResult');
7278
+            }
7279
+        } else {
7280
+            $new_view = substr_replace($view,'1',1,1);
7281
+        }
7282
+        return array($title_line, $line);
7283 7283
     }
7284 7284
 
7285 7285
     /**
@@ -7288,37 +7288,37 @@  discard block
 block discarded – undo
7288 7288
      */
7289 7289
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7290 7290
     {
7291
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7291
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7292 7292
         $_course = api_get_course_info();
7293 7293
         $user_id = intval($user_id);
7294 7294
         $course_id = intval($course_id);
7295 7295
 
7296
-    	if (substr($view,2,1) == '1') {
7297
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7296
+        if (substr($view,2,1) == '1') {
7297
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7298 7298
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7299 7299
                     WHERE
7300 7300
                         u.upload_work_id = w.id AND
7301 7301
                         u.upload_user_id = '$user_id' AND
7302 7302
                         u.c_id = '$course_id'
7303 7303
                     ORDER BY u.upload_date DESC";
7304
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7305
-
7306
-    		$title[1]=get_lang('WorksDetails');
7307
-    		$line='';
7308
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
-
7310
-    		if (is_array($results)) {
7311
-    			for($j = 0 ; $j < count($results) ; $j++) {
7312
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
-    			}
7316
-
7317
-    		} else {
7318
-    			$line= get_lang('NoResult');
7319
-    		}
7320
-    	}
7321
-    	return array($title_line, $line);
7304
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7305
+
7306
+            $title[1]=get_lang('WorksDetails');
7307
+            $line='';
7308
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
+
7310
+            if (is_array($results)) {
7311
+                for($j = 0 ; $j < count($results) ; $j++) {
7312
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
+                }
7316
+
7317
+            } else {
7318
+                $line= get_lang('NoResult');
7319
+            }
7320
+        }
7321
+        return array($title_line, $line);
7322 7322
     }
7323 7323
 
7324 7324
     /**
@@ -7327,32 +7327,32 @@  discard block
 block discarded – undo
7327 7327
      */
7328 7328
     public function display_links_tracking_info($view, $userId, $courseCode)
7329 7329
     {
7330
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7330
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7331 7331
         $courseId = api_get_course_int_id($courseCode);
7332 7332
         $userId = intval($userId);
7333 7333
         $line = null;
7334
-    	if (substr($view,3,1) == '1') {
7335
-    		$new_view = substr_replace($view,'0',3,1);
7336
-    		$title[1]=get_lang('LinksDetails');
7337
-    		$sql = "SELECT cl.title, cl.url
7334
+        if (substr($view,3,1) == '1') {
7335
+            $new_view = substr_replace($view,'0',3,1);
7336
+            $title[1]=get_lang('LinksDetails');
7337
+            $sql = "SELECT cl.title, cl.url
7338 7338
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7339 7339
                         WHERE sl.links_link_id = cl.id
7340 7340
                             AND sl.c_id = $courseId
7341 7341
                             AND sl.links_user_id = $userId
7342 7342
                         GROUP BY cl.title, cl.url";
7343
-    		$results = StatsUtils::getManyResults2Col($sql);
7344
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
-    		if (is_array($results)) {
7346
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7347
-    				$line .= $results[$j][0]."\n";
7348
-    			}
7349
-    		} else {
7350
-    			$line=get_lang('NoResult');
7351
-    		}
7352
-    	} else {
7353
-    		$new_view = substr_replace($view,'1',3,1);
7354
-    	}
7355
-    	return array($title_line, $line);
7343
+            $results = StatsUtils::getManyResults2Col($sql);
7344
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
+            if (is_array($results)) {
7346
+                for ($j = 0 ; $j < count($results) ; $j++) {
7347
+                    $line .= $results[$j][0]."\n";
7348
+                }
7349
+            } else {
7350
+                $line=get_lang('NoResult');
7351
+            }
7352
+        } else {
7353
+            $new_view = substr_replace($view,'1',3,1);
7354
+        }
7355
+        return array($title_line, $line);
7356 7356
     }
7357 7357
 
7358 7358
     /**
@@ -7365,38 +7365,38 @@  discard block
 block discarded – undo
7365 7365
      */
7366 7366
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7367 7367
     {
7368
-    	// protect data
7369
-    	$user_id     = intval($user_id);
7368
+        // protect data
7369
+        $user_id     = intval($user_id);
7370 7370
         $courseId = api_get_course_int_id($courseCode);
7371
-    	$session_id = intval($session_id);
7371
+        $session_id = intval($session_id);
7372 7372
 
7373
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7373
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7374 7374
 
7375
-    	if (substr($view,4,1) == '1') {
7376
-    		$new_view = substr_replace($view,'0',4,1);
7377
-    		$title[1]= get_lang('DocumentsDetails');
7375
+        if (substr($view,4,1) == '1') {
7376
+            $new_view = substr_replace($view,'0',4,1);
7377
+            $title[1]= get_lang('DocumentsDetails');
7378 7378
 
7379
-    		$sql = "SELECT down_doc_path
7379
+            $sql = "SELECT down_doc_path
7380 7380
                         FROM $downloads_table
7381 7381
                         WHERE c_id = $courseId
7382 7382
                             AND down_user_id = $user_id
7383 7383
                             AND down_session_id = $session_id
7384 7384
                         GROUP BY down_doc_path";
7385 7385
 
7386
-    		$results = StatsUtils::getManyResults1Col($sql);
7387
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7386
+            $results = StatsUtils::getManyResults1Col($sql);
7387
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7388 7388
             $line = null;
7389
-    		if (is_array($results)) {
7390
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7391
-    				$line .= $results[$j]."\n";
7392
-    			}
7393
-    		} else {
7394
-    			$line = get_lang('NoResult');
7395
-    		}
7396
-    	} else {
7397
-    		$new_view = substr_replace($view,'1',4,1);
7398
-    	}
7399
-    	return array($title_line, $line);
7389
+            if (is_array($results)) {
7390
+                for ($j = 0 ; $j < count($results) ; $j++) {
7391
+                    $line .= $results[$j]."\n";
7392
+                }
7393
+            } else {
7394
+                $line = get_lang('NoResult');
7395
+            }
7396
+        } else {
7397
+            $new_view = substr_replace($view,'1',4,1);
7398
+        }
7399
+        return array($title_line, $line);
7400 7400
     }
7401 7401
 
7402 7402
     /**
Please login to merge, or discard this patch.
main/exercise/hotspot_actionscript.as.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
 // Query db for answers
34 34
 if ($answer_type==HOT_SPOT_DELINEATION) {
35
-	$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
35
+    $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
36 36
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY iid";
37 37
 } else {
38
-	$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
38
+    $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
39 39
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY iid";
40 40
 }
41 41
 $result = Database::query($sql);
@@ -77,37 +77,37 @@  discard block
 block discarded – undo
77 77
     $hotSpot['iid'] = $hotspot['iid'];
78 78
     $hotSpot['answer'] = $hotspot['answer'];
79 79
 
80
-	// Square or rectancle
81
-	if ($hotspot['hotspot_type'] == 'square' )
82
-	{
80
+    // Square or rectancle
81
+    if ($hotspot['hotspot_type'] == 'square' )
82
+    {
83 83
         $hotSpot['type'] = 'square';
84
-	}
85
-	// Circle or ovale
86
-	if ($hotspot['hotspot_type'] == 'circle')
87
-	{
84
+    }
85
+    // Circle or ovale
86
+    if ($hotspot['hotspot_type'] == 'circle')
87
+    {
88 88
         $hotSpot['type'] = 'circle';
89
-	}
90
-	// Polygon
91
-	if ($hotspot['hotspot_type'] == 'poly')
92
-	{
89
+    }
90
+    // Polygon
91
+    if ($hotspot['hotspot_type'] == 'poly')
92
+    {
93 93
         $hotSpot['type'] = 'poly';
94
-	}
95
-	// Delineation
96
-	if ($hotspot['hotspot_type'] == 'delineation')
97
-	{
94
+    }
95
+    // Delineation
96
+    if ($hotspot['hotspot_type'] == 'delineation')
97
+    {
98 98
         $hotSpot['type'] = 'delineation';
99
-	}
100
-	// No error
101
-	if ($hotspot['hotspot_type'] == 'noerror')
102
-	{
99
+    }
100
+    // No error
101
+    if ($hotspot['hotspot_type'] == 'noerror')
102
+    {
103 103
         $hotSpot['type'] = 'noerror';
104
-	}
104
+    }
105 105
 
106
-	// This is a good answer, count + 1 for nmbr of clicks
107
-	if ($hotspot['hotspot_type'] > 0)
108
-	{
109
-		$nmbrTries++;
110
-	}
106
+    // This is a good answer, count + 1 for nmbr of clicks
107
+    if ($hotspot['hotspot_type'] > 0)
108
+    {
109
+        $nmbrTries++;
110
+    }
111 111
 
112 112
     $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
113 113
 
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/ExtraField.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -253,9 +253,9 @@
 block discarded – undo
253 253
         return $this;
254 254
     }
255 255
 
256
-     /**
257
-     * @return boolean
258
-     */
256
+        /**
257
+         * @return boolean
258
+         */
259 259
     public function isChangeable()
260 260
     {
261 261
         return $this->changeable;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_server.php 1 patch
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -12,1079 +12,1079 @@  discard block
 block discarded – undo
12 12
 */
13 13
 class nusoap_server extends nusoap_base
14 14
 {
15
-	/**
16
-	 * HTTP headers of request
17
-	 * @var array
18
-	 * @access private
19
-	 */
20
-	var $headers = array();
21
-	/**
22
-	 * HTTP request
23
-	 * @var string
24
-	 * @access private
25
-	 */
26
-	var $request = '';
27
-	/**
28
-	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
-	 * @var string
30
-	 * @access public
31
-	 */
32
-	var $requestHeaders = '';
33
-	/**
34
-	 * SOAP Headers from request (parsed)
35
-	 * @var mixed
36
-	 * @access public
37
-	 */
38
-	var $requestHeader = NULL;
39
-	/**
40
-	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
-	 * @var string
42
-	 * @access public
43
-	 */
44
-	var $document = '';
45
-	/**
46
-	 * SOAP payload for request (text)
47
-	 * @var string
48
-	 * @access public
49
-	 */
50
-	var $requestSOAP = '';
51
-	/**
52
-	 * requested method namespace URI
53
-	 * @var string
54
-	 * @access private
55
-	 */
56
-	var $methodURI = '';
57
-	/**
58
-	 * name of method requested
59
-	 * @var string
60
-	 * @access private
61
-	 */
62
-	var $methodname = '';
63
-	/**
64
-	 * method parameters from request
65
-	 * @var array
66
-	 * @access private
67
-	 */
68
-	var $methodparams = array();
69
-	/**
70
-	 * SOAP Action from request
71
-	 * @var string
72
-	 * @access private
73
-	 */
74
-	var $SOAPAction = '';
75
-	/**
76
-	 * character set encoding of incoming (request) messages
77
-	 * @var string
78
-	 * @access public
79
-	 */
80
-	var $xml_encoding = '';
81
-	/**
82
-	 * toggles whether the parser decodes element content w/ utf8_decode()
83
-	 * @var boolean
84
-	 * @access public
85
-	 */
15
+    /**
16
+     * HTTP headers of request
17
+     * @var array
18
+     * @access private
19
+     */
20
+    var $headers = array();
21
+    /**
22
+     * HTTP request
23
+     * @var string
24
+     * @access private
25
+     */
26
+    var $request = '';
27
+    /**
28
+     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
+     * @var string
30
+     * @access public
31
+     */
32
+    var $requestHeaders = '';
33
+    /**
34
+     * SOAP Headers from request (parsed)
35
+     * @var mixed
36
+     * @access public
37
+     */
38
+    var $requestHeader = NULL;
39
+    /**
40
+     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
+     * @var string
42
+     * @access public
43
+     */
44
+    var $document = '';
45
+    /**
46
+     * SOAP payload for request (text)
47
+     * @var string
48
+     * @access public
49
+     */
50
+    var $requestSOAP = '';
51
+    /**
52
+     * requested method namespace URI
53
+     * @var string
54
+     * @access private
55
+     */
56
+    var $methodURI = '';
57
+    /**
58
+     * name of method requested
59
+     * @var string
60
+     * @access private
61
+     */
62
+    var $methodname = '';
63
+    /**
64
+     * method parameters from request
65
+     * @var array
66
+     * @access private
67
+     */
68
+    var $methodparams = array();
69
+    /**
70
+     * SOAP Action from request
71
+     * @var string
72
+     * @access private
73
+     */
74
+    var $SOAPAction = '';
75
+    /**
76
+     * character set encoding of incoming (request) messages
77
+     * @var string
78
+     * @access public
79
+     */
80
+    var $xml_encoding = '';
81
+    /**
82
+     * toggles whether the parser decodes element content w/ utf8_decode()
83
+     * @var boolean
84
+     * @access public
85
+     */
86 86
     var $decode_utf8 = true;
87 87
 
88
-	/**
89
-	 * HTTP headers of response
90
-	 * @var array
91
-	 * @access public
92
-	 */
93
-	var $outgoing_headers = array();
94
-	/**
95
-	 * HTTP response
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $response = '';
100
-	/**
101
-	 * SOAP headers for response (text or array of soapval or associative array)
102
-	 * @var mixed
103
-	 * @access public
104
-	 */
105
-	var $responseHeaders = '';
106
-	/**
107
-	 * SOAP payload for response (text)
108
-	 * @var string
109
-	 * @access private
110
-	 */
111
-	var $responseSOAP = '';
112
-	/**
113
-	 * method return value to place in response
114
-	 * @var mixed
115
-	 * @access private
116
-	 */
117
-	var $methodreturn = false;
118
-	/**
119
-	 * whether $methodreturn is a string of literal XML
120
-	 * @var boolean
121
-	 * @access public
122
-	 */
123
-	var $methodreturnisliteralxml = false;
124
-	/**
125
-	 * SOAP fault for response (or false)
126
-	 * @var mixed
127
-	 * @access private
128
-	 */
129
-	var $fault = false;
130
-	/**
131
-	 * text indication of result (for debugging)
132
-	 * @var string
133
-	 * @access private
134
-	 */
135
-	var $result = 'successful';
88
+    /**
89
+     * HTTP headers of response
90
+     * @var array
91
+     * @access public
92
+     */
93
+    var $outgoing_headers = array();
94
+    /**
95
+     * HTTP response
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $response = '';
100
+    /**
101
+     * SOAP headers for response (text or array of soapval or associative array)
102
+     * @var mixed
103
+     * @access public
104
+     */
105
+    var $responseHeaders = '';
106
+    /**
107
+     * SOAP payload for response (text)
108
+     * @var string
109
+     * @access private
110
+     */
111
+    var $responseSOAP = '';
112
+    /**
113
+     * method return value to place in response
114
+     * @var mixed
115
+     * @access private
116
+     */
117
+    var $methodreturn = false;
118
+    /**
119
+     * whether $methodreturn is a string of literal XML
120
+     * @var boolean
121
+     * @access public
122
+     */
123
+    var $methodreturnisliteralxml = false;
124
+    /**
125
+     * SOAP fault for response (or false)
126
+     * @var mixed
127
+     * @access private
128
+     */
129
+    var $fault = false;
130
+    /**
131
+     * text indication of result (for debugging)
132
+     * @var string
133
+     * @access private
134
+     */
135
+    var $result = 'successful';
136 136
 
137
-	/**
138
-	 * assoc array of operations => opData; operations are added by the register()
139
-	 * method or by parsing an external WSDL definition
140
-	 * @var array
141
-	 * @access private
142
-	 */
143
-	var $operations = array();
144
-	/**
145
-	 * wsdl instance (if one)
146
-	 * @var mixed
147
-	 * @access private
148
-	 */
149
-	var $wsdl = false;
150
-	/**
151
-	 * URL for WSDL (if one)
152
-	 * @var mixed
153
-	 * @access private
154
-	 */
155
-	var $externalWSDLURL = false;
156
-	/**
157
-	 * whether to append debug to response as XML comment
158
-	 * @var boolean
159
-	 * @access public
160
-	 */
161
-	var $debug_flag = false;
137
+    /**
138
+     * assoc array of operations => opData; operations are added by the register()
139
+     * method or by parsing an external WSDL definition
140
+     * @var array
141
+     * @access private
142
+     */
143
+    var $operations = array();
144
+    /**
145
+     * wsdl instance (if one)
146
+     * @var mixed
147
+     * @access private
148
+     */
149
+    var $wsdl = false;
150
+    /**
151
+     * URL for WSDL (if one)
152
+     * @var mixed
153
+     * @access private
154
+     */
155
+    var $externalWSDLURL = false;
156
+    /**
157
+     * whether to append debug to response as XML comment
158
+     * @var boolean
159
+     * @access public
160
+     */
161
+    var $debug_flag = false;
162 162
 
163 163
 
164
-	/**
165
-	* constructor
166
-    * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
-	*
168
-    * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
-	* @access   public
170
-	*/
171
-	function __construct($wsdl=false)
164
+    /**
165
+     * constructor
166
+     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
+     *
168
+     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
+     * @access   public
170
+     */
171
+    function __construct($wsdl=false)
172 172
     {
173
-		parent::__construct();
174
-		// turn on debugging?
175
-		global $debug;
176
-		global $HTTP_SERVER_VARS;
173
+        parent::__construct();
174
+        // turn on debugging?
175
+        global $debug;
176
+        global $HTTP_SERVER_VARS;
177 177
 
178
-		if (isset($_SERVER)) {
179
-			$this->debug("_SERVER is defined:");
180
-			$this->appendDebug($this->varDump($_SERVER));
181
-		} elseif (isset($HTTP_SERVER_VARS)) {
182
-			$this->debug("HTTP_SERVER_VARS is defined:");
183
-			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
-		} else {
185
-			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
-		}
178
+        if (isset($_SERVER)) {
179
+            $this->debug("_SERVER is defined:");
180
+            $this->appendDebug($this->varDump($_SERVER));
181
+        } elseif (isset($HTTP_SERVER_VARS)) {
182
+            $this->debug("HTTP_SERVER_VARS is defined:");
183
+            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
+        } else {
185
+            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
+        }
187 187
 
188
-		if (isset($debug)) {
189
-			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
-			$this->debug_flag = $debug;
191
-		} elseif (isset($_SERVER['QUERY_STRING'])) {
192
-			$qs = explode('&', $_SERVER['QUERY_STRING']);
193
-			foreach ($qs as $v) {
194
-				if (substr($v, 0, 6) == 'debug=') {
195
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
-					$this->debug_flag = substr($v, 6);
197
-				}
198
-			}
199
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
-			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
-			foreach ($qs as $v) {
202
-				if (substr($v, 0, 6) == 'debug=') {
203
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
-					$this->debug_flag = substr($v, 6);
205
-				}
206
-			}
207
-		}
188
+        if (isset($debug)) {
189
+            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
+            $this->debug_flag = $debug;
191
+        } elseif (isset($_SERVER['QUERY_STRING'])) {
192
+            $qs = explode('&', $_SERVER['QUERY_STRING']);
193
+            foreach ($qs as $v) {
194
+                if (substr($v, 0, 6) == 'debug=') {
195
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
+                    $this->debug_flag = substr($v, 6);
197
+                }
198
+            }
199
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
+            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
+            foreach ($qs as $v) {
202
+                if (substr($v, 0, 6) == 'debug=') {
203
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
+                    $this->debug_flag = substr($v, 6);
205
+                }
206
+            }
207
+        }
208 208
 
209
-		// wsdl
210
-		if($wsdl){
211
-			$this->debug("In nusoap_server, WSDL is specified");
212
-			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
-				$this->wsdl = $wsdl;
209
+        // wsdl
210
+        if($wsdl){
211
+            $this->debug("In nusoap_server, WSDL is specified");
212
+            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
+                $this->wsdl = $wsdl;
214 214
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
215
-				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
-			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
219
-				$this->wsdl = new wsdl($wsdl);
215
+                $this->externalWSDLURL = $this->wsdl->wsdl;
216
+                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
+            } else {
218
+                $this->debug('Create wsdl from ' . $wsdl);
219
+                $this->wsdl = new wsdl($wsdl);
220 220
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
221
-				$this->externalWSDLURL = $wsdl;
222
-			}
223
-			$this->appendDebug($this->wsdl->getDebug());
224
-			$this->wsdl->clearDebug();
225
-			if($err = $this->wsdl->getError()){
226
-				die('WSDL ERROR: '.$err);
227
-			}
228
-		}
229
-	}
221
+                $this->externalWSDLURL = $wsdl;
222
+            }
223
+            $this->appendDebug($this->wsdl->getDebug());
224
+            $this->wsdl->clearDebug();
225
+            if($err = $this->wsdl->getError()){
226
+                die('WSDL ERROR: '.$err);
227
+            }
228
+        }
229
+    }
230 230
 
231
-	/**
232
-	* processes request and returns response
233
-	*
234
-	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
-	* @access   public
236
-	*/
237
-	function service($data){
238
-		global $HTTP_SERVER_VARS;
231
+    /**
232
+     * processes request and returns response
233
+     *
234
+     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
+     * @access   public
236
+     */
237
+    function service($data){
238
+        global $HTTP_SERVER_VARS;
239 239
 
240
-		if (isset($_SERVER['REQUEST_METHOD'])) {
241
-			$rm = $_SERVER['REQUEST_METHOD'];
242
-		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
-			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
-		} else {
245
-			$rm = '';
246
-		}
240
+        if (isset($_SERVER['REQUEST_METHOD'])) {
241
+            $rm = $_SERVER['REQUEST_METHOD'];
242
+        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
+            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
+        } else {
245
+            $rm = '';
246
+        }
247 247
 
248
-		if (isset($_SERVER['QUERY_STRING'])) {
249
-			$qs = $_SERVER['QUERY_STRING'];
250
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
-			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
-		} else {
253
-			$qs = '';
254
-		}
255
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
248
+        if (isset($_SERVER['QUERY_STRING'])) {
249
+            $qs = $_SERVER['QUERY_STRING'];
250
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
+            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
+        } else {
253
+            $qs = '';
254
+        }
255
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
256 256
 
257
-		if ($rm == 'POST') {
258
-			$this->debug("In service, invoke the request");
259
-			$this->parse_request($data);
260
-			if (! $this->fault) {
261
-				$this->invoke_method();
262
-			}
263
-			if (! $this->fault) {
264
-				$this->serialize_return();
265
-			}
266
-			$this->send_response();
267
-		} elseif (preg_match('/wsdl/', $qs) ){
268
-			$this->debug("In service, this is a request for WSDL");
269
-			if ($this->externalWSDLURL){
270
-              if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
-				$this->debug("In service, re-direct for WSDL");
272
-				header('Location: '.$this->externalWSDLURL);
273
-              } else { // assume file
274
-				$this->debug("In service, use file passthru for WSDL");
257
+        if ($rm == 'POST') {
258
+            $this->debug("In service, invoke the request");
259
+            $this->parse_request($data);
260
+            if (! $this->fault) {
261
+                $this->invoke_method();
262
+            }
263
+            if (! $this->fault) {
264
+                $this->serialize_return();
265
+            }
266
+            $this->send_response();
267
+        } elseif (preg_match('/wsdl/', $qs) ){
268
+            $this->debug("In service, this is a request for WSDL");
269
+            if ($this->externalWSDLURL){
270
+                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
+                $this->debug("In service, re-direct for WSDL");
272
+                header('Location: '.$this->externalWSDLURL);
273
+                } else { // assume file
274
+                $this->debug("In service, use file passthru for WSDL");
275 275
                 header("Content-Type: text/xml\r\n");
276
-				$pos = strpos($this->externalWSDLURL, "file://");
277
-				if ($pos === false) {
278
-					$filename = $this->externalWSDLURL;
279
-				} else {
280
-					$filename = substr($this->externalWSDLURL, $pos + 7);
281
-				}
276
+                $pos = strpos($this->externalWSDLURL, "file://");
277
+                if ($pos === false) {
278
+                    $filename = $this->externalWSDLURL;
279
+                } else {
280
+                    $filename = substr($this->externalWSDLURL, $pos + 7);
281
+                }
282 282
                 $fp = fopen($this->externalWSDLURL, 'r');
283 283
                 fpassthru($fp);
284
-              }
285
-			} elseif ($this->wsdl) {
286
-				$this->debug("In service, serialize WSDL");
284
+                }
285
+            } elseif ($this->wsdl) {
286
+                $this->debug("In service, serialize WSDL");
287 287
                 header("Content-Type: text/xml; charset=".$this->soap_defencoding."\r\n");
288
-				print $this->wsdl->serialize($this->debug_flag);
289
-				if ($this->debug_flag) {
290
-					$this->debug('wsdl:');
291
-					$this->appendDebug($this->varDump($this->wsdl));
292
-					print $this->getDebugAsXMLComment();
293
-				}
294
-			} else {
295
-				$this->debug("In service, there is no WSDL");
288
+                print $this->wsdl->serialize($this->debug_flag);
289
+                if ($this->debug_flag) {
290
+                    $this->debug('wsdl:');
291
+                    $this->appendDebug($this->varDump($this->wsdl));
292
+                    print $this->getDebugAsXMLComment();
293
+                }
294
+            } else {
295
+                $this->debug("In service, there is no WSDL");
296 296
                 header("Content-Type: text/html; charset=".$this->soap_defencoding."\r\n");
297
-				print "This service does not provide WSDL";
298
-			}
299
-		} elseif ($this->wsdl) {
300
-			$this->debug("In service, return Web description");
301
-			print $this->wsdl->webDescription();
302
-		} else {
303
-			$this->debug("In service, no Web description");
304
-			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
-			print "This service does not provide a Web description";
306
-		}
307
-	}
297
+                print "This service does not provide WSDL";
298
+            }
299
+        } elseif ($this->wsdl) {
300
+            $this->debug("In service, return Web description");
301
+            print $this->wsdl->webDescription();
302
+        } else {
303
+            $this->debug("In service, no Web description");
304
+            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
+            print "This service does not provide a Web description";
306
+        }
307
+    }
308 308
 
309
-	/**
310
-	* parses HTTP request headers.
311
-	*
312
-	* The following fields are set by this function (when successful)
313
-	*
314
-	* headers
315
-	* request
316
-	* xml_encoding
317
-	* SOAPAction
318
-	*
319
-	* @access   private
320
-	*/
321
-	function parse_http_headers() {
322
-		global $HTTP_SERVER_VARS;
309
+    /**
310
+     * parses HTTP request headers.
311
+     *
312
+     * The following fields are set by this function (when successful)
313
+     *
314
+     * headers
315
+     * request
316
+     * xml_encoding
317
+     * SOAPAction
318
+     *
319
+     * @access   private
320
+     */
321
+    function parse_http_headers() {
322
+        global $HTTP_SERVER_VARS;
323 323
 
324
-		$this->request = '';
325
-		$this->SOAPAction = '';
326
-		if(function_exists('getallheaders')){
327
-			$this->debug("In parse_http_headers, use getallheaders");
328
-			$headers = getallheaders();
329
-			foreach($headers as $k=>$v){
330
-				$k = strtolower($k);
331
-				$this->headers[$k] = $v;
332
-				$this->request .= "$k: $v\r\n";
333
-				$this->debug("$k: $v");
334
-			}
335
-			// get SOAPAction header
336
-			if(isset($this->headers['soapaction'])){
337
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
-			}
339
-			// get the character encoding of the incoming request
340
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
-					$this->xml_encoding = strtoupper($enc);
344
-				} else {
345
-					$this->xml_encoding = 'US-ASCII';
346
-				}
347
-			} else {
348
-				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
-				$this->xml_encoding = 'ISO-8859-1';
350
-			}
351
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
352
-			$this->debug("In parse_http_headers, use _SERVER");
353
-			foreach ($_SERVER as $k => $v) {
354
-				if (substr($k, 0, 5) == 'HTTP_') {
355
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
-				} else {
357
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
-				}
359
-				if ($k == 'soapaction') {
360
-					// get SOAPAction header
361
-					$k = 'SOAPAction';
362
-					$v = str_replace('"', '', $v);
363
-					$v = str_replace('\\', '', $v);
364
-					$this->SOAPAction = $v;
365
-				} else if ($k == 'content-type') {
366
-					// get the character encoding of the incoming request
367
-					if (strpos($v, '=')) {
368
-						$enc = substr(strstr($v, '='), 1);
369
-						$enc = str_replace('"', '', $enc);
370
-						$enc = str_replace('\\', '', $enc);
371
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
-							$this->xml_encoding = strtoupper($enc);
373
-						} else {
374
-							$this->xml_encoding = 'US-ASCII';
375
-						}
376
-					} else {
377
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
-						$this->xml_encoding = 'ISO-8859-1';
379
-					}
380
-				}
381
-				$this->headers[$k] = $v;
382
-				$this->request .= "$k: $v\r\n";
383
-				$this->debug("$k: $v");
384
-			}
385
-		} elseif (is_array($HTTP_SERVER_VARS)) {
386
-			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
-			foreach ($HTTP_SERVER_VARS as $k => $v) {
388
-				if (substr($k, 0, 5) == 'HTTP_') {
389
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
-				} else {
391
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
-				}
393
-				if ($k == 'soapaction') {
394
-					// get SOAPAction header
395
-					$k = 'SOAPAction';
396
-					$v = str_replace('"', '', $v);
397
-					$v = str_replace('\\', '', $v);
398
-					$this->SOAPAction = $v;
399
-				} else if ($k == 'content-type') {
400
-					// get the character encoding of the incoming request
401
-					if (strpos($v, '=')) {
402
-						$enc = substr(strstr($v, '='), 1);
403
-						$enc = str_replace('"', '', $enc);
404
-						$enc = str_replace('\\', '', $enc);
405
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
-							$this->xml_encoding = strtoupper($enc);
407
-						} else {
408
-							$this->xml_encoding = 'US-ASCII';
409
-						}
410
-					} else {
411
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
-						$this->xml_encoding = 'ISO-8859-1';
413
-					}
414
-				}
415
-				$this->headers[$k] = $v;
416
-				$this->request .= "$k: $v\r\n";
417
-				$this->debug("$k: $v");
418
-			}
419
-		} else {
420
-			$this->debug("In parse_http_headers, HTTP headers not accessible");
421
-			$this->setError("HTTP headers not accessible");
422
-		}
423
-	}
324
+        $this->request = '';
325
+        $this->SOAPAction = '';
326
+        if(function_exists('getallheaders')){
327
+            $this->debug("In parse_http_headers, use getallheaders");
328
+            $headers = getallheaders();
329
+            foreach($headers as $k=>$v){
330
+                $k = strtolower($k);
331
+                $this->headers[$k] = $v;
332
+                $this->request .= "$k: $v\r\n";
333
+                $this->debug("$k: $v");
334
+            }
335
+            // get SOAPAction header
336
+            if(isset($this->headers['soapaction'])){
337
+                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
+            }
339
+            // get the character encoding of the incoming request
340
+            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
+                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
+                if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
+                    $this->xml_encoding = strtoupper($enc);
344
+                } else {
345
+                    $this->xml_encoding = 'US-ASCII';
346
+                }
347
+            } else {
348
+                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
+                $this->xml_encoding = 'ISO-8859-1';
350
+            }
351
+        } elseif(isset($_SERVER) && is_array($_SERVER)){
352
+            $this->debug("In parse_http_headers, use _SERVER");
353
+            foreach ($_SERVER as $k => $v) {
354
+                if (substr($k, 0, 5) == 'HTTP_') {
355
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
+                } else {
357
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
+                }
359
+                if ($k == 'soapaction') {
360
+                    // get SOAPAction header
361
+                    $k = 'SOAPAction';
362
+                    $v = str_replace('"', '', $v);
363
+                    $v = str_replace('\\', '', $v);
364
+                    $this->SOAPAction = $v;
365
+                } else if ($k == 'content-type') {
366
+                    // get the character encoding of the incoming request
367
+                    if (strpos($v, '=')) {
368
+                        $enc = substr(strstr($v, '='), 1);
369
+                        $enc = str_replace('"', '', $enc);
370
+                        $enc = str_replace('\\', '', $enc);
371
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
+                            $this->xml_encoding = strtoupper($enc);
373
+                        } else {
374
+                            $this->xml_encoding = 'US-ASCII';
375
+                        }
376
+                    } else {
377
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
+                        $this->xml_encoding = 'ISO-8859-1';
379
+                    }
380
+                }
381
+                $this->headers[$k] = $v;
382
+                $this->request .= "$k: $v\r\n";
383
+                $this->debug("$k: $v");
384
+            }
385
+        } elseif (is_array($HTTP_SERVER_VARS)) {
386
+            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
+            foreach ($HTTP_SERVER_VARS as $k => $v) {
388
+                if (substr($k, 0, 5) == 'HTTP_') {
389
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
+                } else {
391
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
+                }
393
+                if ($k == 'soapaction') {
394
+                    // get SOAPAction header
395
+                    $k = 'SOAPAction';
396
+                    $v = str_replace('"', '', $v);
397
+                    $v = str_replace('\\', '', $v);
398
+                    $this->SOAPAction = $v;
399
+                } else if ($k == 'content-type') {
400
+                    // get the character encoding of the incoming request
401
+                    if (strpos($v, '=')) {
402
+                        $enc = substr(strstr($v, '='), 1);
403
+                        $enc = str_replace('"', '', $enc);
404
+                        $enc = str_replace('\\', '', $enc);
405
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
+                            $this->xml_encoding = strtoupper($enc);
407
+                        } else {
408
+                            $this->xml_encoding = 'US-ASCII';
409
+                        }
410
+                    } else {
411
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
+                        $this->xml_encoding = 'ISO-8859-1';
413
+                    }
414
+                }
415
+                $this->headers[$k] = $v;
416
+                $this->request .= "$k: $v\r\n";
417
+                $this->debug("$k: $v");
418
+            }
419
+        } else {
420
+            $this->debug("In parse_http_headers, HTTP headers not accessible");
421
+            $this->setError("HTTP headers not accessible");
422
+        }
423
+    }
424 424
 
425
-	/**
426
-	* parses a request
427
-	*
428
-	* The following fields are set by this function (when successful)
429
-	*
430
-	* headers
431
-	* request
432
-	* xml_encoding
433
-	* SOAPAction
434
-	* request
435
-	* requestSOAP
436
-	* methodURI
437
-	* methodname
438
-	* methodparams
439
-	* requestHeaders
440
-	* document
441
-	*
442
-	* This sets the fault field on error
443
-	*
444
-	* @param    string $data XML string
445
-	* @access   private
446
-	*/
447
-	function parse_request($data='') {
448
-		$this->debug('entering parse_request()');
449
-		$this->parse_http_headers();
450
-		$this->debug('got character encoding: '.$this->xml_encoding);
451
-		// uncompress if necessary
452
-		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
-			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
-		    	// if decoding works, use it. else assume data wasn't gzencoded
456
-				if (function_exists('gzuncompress')) {
457
-					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
-						$data = $degzdata;
459
-					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
-						$data = $degzdata;
461
-					} else {
462
-						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
-						return;
464
-					}
465
-				} else {
466
-					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
-					return;
468
-				}
469
-			}
470
-		}
471
-		$this->request .= "\r\n".$data;
472
-		$data = $this->parseRequest($this->headers, $data);
473
-		$this->requestSOAP = $data;
474
-		$this->debug('leaving parse_request');
475
-	}
425
+    /**
426
+     * parses a request
427
+     *
428
+     * The following fields are set by this function (when successful)
429
+     *
430
+     * headers
431
+     * request
432
+     * xml_encoding
433
+     * SOAPAction
434
+     * request
435
+     * requestSOAP
436
+     * methodURI
437
+     * methodname
438
+     * methodparams
439
+     * requestHeaders
440
+     * document
441
+     *
442
+     * This sets the fault field on error
443
+     *
444
+     * @param    string $data XML string
445
+     * @access   private
446
+     */
447
+    function parse_request($data='') {
448
+        $this->debug('entering parse_request()');
449
+        $this->parse_http_headers();
450
+        $this->debug('got character encoding: '.$this->xml_encoding);
451
+        // uncompress if necessary
452
+        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
+            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
+            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
+                // if decoding works, use it. else assume data wasn't gzencoded
456
+                if (function_exists('gzuncompress')) {
457
+                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
+                        $data = $degzdata;
459
+                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
+                        $data = $degzdata;
461
+                    } else {
462
+                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
+                        return;
464
+                    }
465
+                } else {
466
+                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
+                    return;
468
+                }
469
+            }
470
+        }
471
+        $this->request .= "\r\n".$data;
472
+        $data = $this->parseRequest($this->headers, $data);
473
+        $this->requestSOAP = $data;
474
+        $this->debug('leaving parse_request');
475
+    }
476 476
 
477
-	/**
478
-	* invokes a PHP function for the requested SOAP method
479
-	*
480
-	* The following fields are set by this function (when successful)
481
-	*
482
-	* methodreturn
483
-	*
484
-	* Note that the PHP function that is called may also set the following
485
-	* fields to affect the response sent to the client
486
-	*
487
-	* responseHeaders
488
-	* outgoing_headers
489
-	*
490
-	* This sets the fault field on error
491
-	*
492
-	* @access   private
493
-	*/
494
-	function invoke_method() {
495
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
477
+    /**
478
+     * invokes a PHP function for the requested SOAP method
479
+     *
480
+     * The following fields are set by this function (when successful)
481
+     *
482
+     * methodreturn
483
+     *
484
+     * Note that the PHP function that is called may also set the following
485
+     * fields to affect the response sent to the client
486
+     *
487
+     * responseHeaders
488
+     * outgoing_headers
489
+     *
490
+     * This sets the fault field on error
491
+     *
492
+     * @access   private
493
+     */
494
+    function invoke_method() {
495
+        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
496 496
 
497
-		//
498
-		// if you are debugging in this area of the code, your service uses a class to implement methods,
499
-		// you use SOAP RPC, and the client is .NET, please be aware of the following...
500
-		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
-		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
-		// the XML request and reading the XML response.  you need to add the RequestElementName and
503
-		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
-		// generates for the method.  these parameters are used to specify the correct XML element names
505
-		// for .NET to use, i.e. the names with the '.' in them.
506
-		//
507
-		$orig_methodname = $this->methodname;
508
-		if ($this->wsdl) {
509
-			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
512
-			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
-				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
516
-				$this->methodname = $this->opData['name'];
517
-			} else {
518
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
-				return;
521
-			}
522
-		} else {
523
-			$this->debug('in invoke_method, no WSDL to validate method');
524
-		}
497
+        //
498
+        // if you are debugging in this area of the code, your service uses a class to implement methods,
499
+        // you use SOAP RPC, and the client is .NET, please be aware of the following...
500
+        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
+        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
+        // the XML request and reading the XML response.  you need to add the RequestElementName and
503
+        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
+        // generates for the method.  these parameters are used to specify the correct XML element names
505
+        // for .NET to use, i.e. the names with the '.' in them.
506
+        //
507
+        $orig_methodname = $this->methodname;
508
+        if ($this->wsdl) {
509
+            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
+                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
512
+            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
+                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
+                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
516
+                $this->methodname = $this->opData['name'];
517
+            } else {
518
+                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
+                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
+                return;
521
+            }
522
+        } else {
523
+            $this->debug('in invoke_method, no WSDL to validate method');
524
+        }
525 525
 
526
-		// if a . is present in $this->methodname, we see if there is a class in scope,
527
-		// which could be referred to. We will also distinguish between two deliminators,
528
-		// to allow methods to be called a the class or an instance
529
-		if (strpos($this->methodname, '..') > 0) {
530
-			$delim = '..';
531
-		} else if (strpos($this->methodname, '.') > 0) {
532
-			$delim = '.';
533
-		} else {
534
-			$delim = '';
535
-		}
536
-		$this->debug("in invoke_method, delim=$delim");
526
+        // if a . is present in $this->methodname, we see if there is a class in scope,
527
+        // which could be referred to. We will also distinguish between two deliminators,
528
+        // to allow methods to be called a the class or an instance
529
+        if (strpos($this->methodname, '..') > 0) {
530
+            $delim = '..';
531
+        } else if (strpos($this->methodname, '.') > 0) {
532
+            $delim = '.';
533
+        } else {
534
+            $delim = '';
535
+        }
536
+        $this->debug("in invoke_method, delim=$delim");
537 537
 
538
-		$class = '';
539
-		$method = '';
540
-		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
-			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
-			if (class_exists($try_class)) {
543
-				// get the class and method name
544
-				$class = $try_class;
545
-				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
-				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
-			} else {
548
-				$this->debug("in invoke_method, class=$try_class not found");
549
-			}
550
-		} else {
551
-			$try_class = '';
552
-			$this->debug("in invoke_method, no class to try");
553
-		}
538
+        $class = '';
539
+        $method = '';
540
+        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
+            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
+            if (class_exists($try_class)) {
543
+                // get the class and method name
544
+                $class = $try_class;
545
+                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
+                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
+            } else {
548
+                $this->debug("in invoke_method, class=$try_class not found");
549
+            }
550
+        } else {
551
+            $try_class = '';
552
+            $this->debug("in invoke_method, no class to try");
553
+        }
554 554
 
555
-		// does method exist?
556
-		if ($class == '') {
557
-			if (!function_exists($this->methodname)) {
558
-				$this->debug("in invoke_method, function '$this->methodname' not found!");
559
-				$this->result = 'fault: method not found';
560
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
-				return;
562
-			}
563
-		} else {
564
-			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
-			if (!in_array($method_to_compare, get_class_methods($class))) {
566
-				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
-				$this->result = 'fault: method not found';
568
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
-				return;
570
-			}
571
-		}
555
+        // does method exist?
556
+        if ($class == '') {
557
+            if (!function_exists($this->methodname)) {
558
+                $this->debug("in invoke_method, function '$this->methodname' not found!");
559
+                $this->result = 'fault: method not found';
560
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
+                return;
562
+            }
563
+        } else {
564
+            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
+            if (!in_array($method_to_compare, get_class_methods($class))) {
566
+                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
+                $this->result = 'fault: method not found';
568
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
+                return;
570
+            }
571
+        }
572 572
 
573
-		// evaluate message, getting back parameters
574
-		// verify that request parameters match the method's signature
575
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
576
-			// debug
577
-			$this->debug('ERROR: request not verified against method signature');
578
-			$this->result = 'fault: request failed validation against method signature';
579
-			// return fault
580
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
-			return;
582
-		}
573
+        // evaluate message, getting back parameters
574
+        // verify that request parameters match the method's signature
575
+        if(! $this->verify_method($this->methodname,$this->methodparams)){
576
+            // debug
577
+            $this->debug('ERROR: request not verified against method signature');
578
+            $this->result = 'fault: request failed validation against method signature';
579
+            // return fault
580
+            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
+            return;
582
+        }
583 583
 
584
-		// if there are parameters to pass
585
-		$this->debug('in invoke_method, params:');
586
-		$this->appendDebug($this->varDump($this->methodparams));
587
-		$this->debug("in invoke_method, calling '$this->methodname'");
588
-		if (!function_exists('call_user_func_array')) {
589
-			if ($class == '') {
590
-				$this->debug('in invoke_method, calling function using eval()');
591
-				$funcCall = "\$this->methodreturn = $this->methodname(";
592
-			} else {
593
-				if ($delim == '..') {
594
-					$this->debug('in invoke_method, calling class method using eval()');
595
-					$funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
-				} else {
597
-					$this->debug('in invoke_method, calling instance method using eval()');
598
-					// generate unique instance name
599
-					$instname = "\$inst_".time();
600
-					$funcCall = $instname." = new ".$class."(); ";
601
-					$funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
-				}
603
-			}
604
-			if ($this->methodparams) {
605
-				foreach ($this->methodparams as $param) {
606
-					if (is_array($param) || is_object($param)) {
607
-						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
-						return;
609
-					}
610
-					$funcCall .= "\"$param\",";
611
-				}
612
-				$funcCall = substr($funcCall, 0, -1);
613
-			}
614
-			$funcCall .= ');';
615
-			$this->debug('in invoke_method, function call: '.$funcCall);
616
-			@eval($funcCall);
617
-		} else {
618
-			if ($class == '') {
619
-				$this->debug('in invoke_method, calling function using call_user_func_array()');
620
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
-			} elseif ($delim == '..') {
622
-				$this->debug('in invoke_method, calling class method using call_user_func_array()');
623
-				$call_arg = array ($class, $method);
624
-			} else {
625
-				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
-				$instance = new $class ();
627
-				$call_arg = array(&$instance, $method);
628
-			}
629
-			if (is_array($this->methodparams)) {
630
-				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
-			} else {
632
-				$this->methodreturn = call_user_func_array($call_arg, array());
633
-			}
634
-		}
584
+        // if there are parameters to pass
585
+        $this->debug('in invoke_method, params:');
586
+        $this->appendDebug($this->varDump($this->methodparams));
587
+        $this->debug("in invoke_method, calling '$this->methodname'");
588
+        if (!function_exists('call_user_func_array')) {
589
+            if ($class == '') {
590
+                $this->debug('in invoke_method, calling function using eval()');
591
+                $funcCall = "\$this->methodreturn = $this->methodname(";
592
+            } else {
593
+                if ($delim == '..') {
594
+                    $this->debug('in invoke_method, calling class method using eval()');
595
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
+                } else {
597
+                    $this->debug('in invoke_method, calling instance method using eval()');
598
+                    // generate unique instance name
599
+                    $instname = "\$inst_".time();
600
+                    $funcCall = $instname." = new ".$class."(); ";
601
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
+                }
603
+            }
604
+            if ($this->methodparams) {
605
+                foreach ($this->methodparams as $param) {
606
+                    if (is_array($param) || is_object($param)) {
607
+                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
+                        return;
609
+                    }
610
+                    $funcCall .= "\"$param\",";
611
+                }
612
+                $funcCall = substr($funcCall, 0, -1);
613
+            }
614
+            $funcCall .= ');';
615
+            $this->debug('in invoke_method, function call: '.$funcCall);
616
+            @eval($funcCall);
617
+        } else {
618
+            if ($class == '') {
619
+                $this->debug('in invoke_method, calling function using call_user_func_array()');
620
+                $call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
+            } elseif ($delim == '..') {
622
+                $this->debug('in invoke_method, calling class method using call_user_func_array()');
623
+                $call_arg = array ($class, $method);
624
+            } else {
625
+                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
+                $instance = new $class ();
627
+                $call_arg = array(&$instance, $method);
628
+            }
629
+            if (is_array($this->methodparams)) {
630
+                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
+            } else {
632
+                $this->methodreturn = call_user_func_array($call_arg, array());
633
+            }
634
+        }
635 635
         $this->debug('in invoke_method, methodreturn:');
636 636
         $this->appendDebug($this->varDump($this->methodreturn));
637
-		$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
-	}
637
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
+    }
639 639
 
640
-	/**
641
-	* serializes the return value from a PHP function into a full SOAP Envelope
642
-	*
643
-	* The following fields are set by this function (when successful)
644
-	*
645
-	* responseSOAP
646
-	*
647
-	* This sets the fault field on error
648
-	*
649
-	* @access   private
650
-	*/
651
-	function serialize_return() {
652
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
-		// if fault
654
-		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
-			$this->debug('got a fault object from method');
656
-			$this->fault = $this->methodreturn;
657
-			return;
658
-		} elseif ($this->methodreturnisliteralxml) {
659
-			$return_val = $this->methodreturn;
660
-		// returned value(s)
661
-		} else {
662
-			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
-			$this->debug('serializing return value');
664
-			if($this->wsdl){
665
-				$opParams = "";
666
-				if (sizeof($this->opData['output']['parts']) > 1) {
667
-					$this->debug('more than one output part, so use the method return unchanged');
668
-			    	$opParams = $this->methodreturn;
669
-			    } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
-					$this->debug('exactly one output part, so wrap the method return in a simple array');
671
-					// TODO: verify that it is not already wrapped!
672
-			    	//foreach ($this->opData['output']['parts'] as $name => $type) {
673
-					//	$this->debug('wrap in element named ' . $name);
674
-			    	//}
675
-			    	$opParams = array($this->methodreturn);
676
-			    }
677
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
-			    $this->appendDebug($this->wsdl->getDebug());
679
-			    $this->wsdl->clearDebug();
680
-				if($errstr = $this->wsdl->getError()){
681
-					$this->debug('got wsdl error: '.$errstr);
682
-					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
-					return;
684
-				}
685
-			} else {
686
-				if (isset($this->methodreturn)) {
687
-					$return_val = $this->serialize_val($this->methodreturn, 'return');
688
-				} else {
689
-					$return_val = '';
690
-					$this->debug('in absence of WSDL, assume void return for backward compatibility');
691
-				}
692
-			}
693
-		}
694
-		$this->debug('return value:');
695
-		$this->appendDebug($this->varDump($return_val));
640
+    /**
641
+     * serializes the return value from a PHP function into a full SOAP Envelope
642
+     *
643
+     * The following fields are set by this function (when successful)
644
+     *
645
+     * responseSOAP
646
+     *
647
+     * This sets the fault field on error
648
+     *
649
+     * @access   private
650
+     */
651
+    function serialize_return() {
652
+        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
+        // if fault
654
+        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
+            $this->debug('got a fault object from method');
656
+            $this->fault = $this->methodreturn;
657
+            return;
658
+        } elseif ($this->methodreturnisliteralxml) {
659
+            $return_val = $this->methodreturn;
660
+        // returned value(s)
661
+        } else {
662
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
+            $this->debug('serializing return value');
664
+            if($this->wsdl){
665
+                $opParams = "";
666
+                if (sizeof($this->opData['output']['parts']) > 1) {
667
+                    $this->debug('more than one output part, so use the method return unchanged');
668
+                    $opParams = $this->methodreturn;
669
+                } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
+                    $this->debug('exactly one output part, so wrap the method return in a simple array');
671
+                    // TODO: verify that it is not already wrapped!
672
+                    //foreach ($this->opData['output']['parts'] as $name => $type) {
673
+                    //	$this->debug('wrap in element named ' . $name);
674
+                    //}
675
+                    $opParams = array($this->methodreturn);
676
+                }
677
+                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
+                $this->appendDebug($this->wsdl->getDebug());
679
+                $this->wsdl->clearDebug();
680
+                if($errstr = $this->wsdl->getError()){
681
+                    $this->debug('got wsdl error: '.$errstr);
682
+                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
+                    return;
684
+                }
685
+            } else {
686
+                if (isset($this->methodreturn)) {
687
+                    $return_val = $this->serialize_val($this->methodreturn, 'return');
688
+                } else {
689
+                    $return_val = '';
690
+                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
691
+                }
692
+            }
693
+        }
694
+        $this->debug('return value:');
695
+        $this->appendDebug($this->varDump($return_val));
696 696
 
697
-		$this->debug('serializing response');
698
-		if ($this->wsdl) {
699
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
-			if ($this->opData['style'] == 'rpc') {
701
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
-				if ($this->opData['output']['use'] == 'literal') {
703
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
-					if ($this->methodURI) {
705
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
-					} else {
707
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
-					}
709
-				} else {
710
-					if ($this->methodURI) {
711
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
-					} else {
713
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
-					}
715
-				}
716
-			} else {
717
-				$this->debug('style is not rpc for serialization: assume document');
718
-				$payload = $return_val;
719
-			}
720
-		} else {
721
-			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
-			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
-		}
724
-		$this->result = 'successful';
725
-		if($this->wsdl){
726
-			//if($this->debug_flag){
727
-            	$this->appendDebug($this->wsdl->getDebug());
697
+        $this->debug('serializing response');
698
+        if ($this->wsdl) {
699
+            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
+            if ($this->opData['style'] == 'rpc') {
701
+                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
+                if ($this->opData['output']['use'] == 'literal') {
703
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
+                    if ($this->methodURI) {
705
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
+                    } else {
707
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
+                    }
709
+                } else {
710
+                    if ($this->methodURI) {
711
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
+                    } else {
713
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
+                    }
715
+                }
716
+            } else {
717
+                $this->debug('style is not rpc for serialization: assume document');
718
+                $payload = $return_val;
719
+            }
720
+        } else {
721
+            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
+            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
+        }
724
+        $this->result = 'successful';
725
+        if($this->wsdl){
726
+            //if($this->debug_flag){
727
+                $this->appendDebug($this->wsdl->getDebug());
728 728
             //	}
729
-			if (isset($this->opData['output']['encodingStyle'])) {
730
-				$encodingStyle = $this->opData['output']['encodingStyle'];
731
-			} else {
732
-				$encodingStyle = '';
733
-			}
734
-			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
-		} else {
737
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
-		}
739
-		$this->debug("Leaving serialize_return");
740
-	}
729
+            if (isset($this->opData['output']['encodingStyle'])) {
730
+                $encodingStyle = $this->opData['output']['encodingStyle'];
731
+            } else {
732
+                $encodingStyle = '';
733
+            }
734
+            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
+        } else {
737
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
+        }
739
+        $this->debug("Leaving serialize_return");
740
+    }
741 741
 
742
-	/**
743
-	* sends an HTTP response
744
-	*
745
-	* The following fields are set by this function (when successful)
746
-	*
747
-	* outgoing_headers
748
-	* response
749
-	*
750
-	* @access   private
751
-	*/
752
-	function send_response() {
753
-		$this->debug('Enter send_response');
754
-		if ($this->fault) {
755
-			$payload = $this->fault->serialize();
756
-			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
-			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
-		} else {
759
-			$payload = $this->responseSOAP;
760
-			// Some combinations of PHP+Web server allow the Status
761
-			// to come through as a header.  Since OK is the default
762
-			// just do nothing.
763
-			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
-			// $this->outgoing_headers[] = "Status: 200 OK";
765
-		}
742
+    /**
743
+     * sends an HTTP response
744
+     *
745
+     * The following fields are set by this function (when successful)
746
+     *
747
+     * outgoing_headers
748
+     * response
749
+     *
750
+     * @access   private
751
+     */
752
+    function send_response() {
753
+        $this->debug('Enter send_response');
754
+        if ($this->fault) {
755
+            $payload = $this->fault->serialize();
756
+            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
+            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
+        } else {
759
+            $payload = $this->responseSOAP;
760
+            // Some combinations of PHP+Web server allow the Status
761
+            // to come through as a header.  Since OK is the default
762
+            // just do nothing.
763
+            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
+            // $this->outgoing_headers[] = "Status: 200 OK";
765
+        }
766 766
         // add debug data if in debug mode
767
-		if(isset($this->debug_flag) && $this->debug_flag){
768
-        	$payload .= $this->getDebugAsXMLComment();
767
+        if(isset($this->debug_flag) && $this->debug_flag){
768
+            $payload .= $this->getDebugAsXMLComment();
769
+        }
770
+        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
+        // Let the Web server decide about this
774
+        //$this->outgoing_headers[] = "Connection: Close\r\n";
775
+        $payload = $this->getHTTPBody($payload);
776
+        $type = $this->getHTTPContentType();
777
+        $charset = $this->getHTTPContentTypeCharset();
778
+        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
+        //begin code to compress payload - by John
780
+        // NOTE: there is no way to know whether the Web server will also compress
781
+        // this data.
782
+        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
+            if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
+                if (function_exists('gzencode')) {
785
+                    if (isset($this->debug_flag) && $this->debug_flag) {
786
+                        $payload .= "<!-- Content being gzipped -->";
787
+                    }
788
+                    $this->outgoing_headers[] = "Content-Encoding: gzip";
789
+                    $payload = gzencode($payload);
790
+                } else {
791
+                    if (isset($this->debug_flag) && $this->debug_flag) {
792
+                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
+                    }
794
+                }
795
+            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
+                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
+                // instead of gzcompress output,
798
+                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
+                if (function_exists('gzdeflate')) {
800
+                    if (isset($this->debug_flag) && $this->debug_flag) {
801
+                        $payload .= "<!-- Content being deflated -->";
802
+                    }
803
+                    $this->outgoing_headers[] = "Content-Encoding: deflate";
804
+                    $payload = gzdeflate($payload);
805
+                } else {
806
+                    if (isset($this->debug_flag) && $this->debug_flag) {
807
+                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
+                    }
809
+                }
810
+            }
769 811
         }
770
-		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
-		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
-		// Let the Web server decide about this
774
-		//$this->outgoing_headers[] = "Connection: Close\r\n";
775
-		$payload = $this->getHTTPBody($payload);
776
-		$type = $this->getHTTPContentType();
777
-		$charset = $this->getHTTPContentTypeCharset();
778
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
-		//begin code to compress payload - by John
780
-		// NOTE: there is no way to know whether the Web server will also compress
781
-		// this data.
782
-		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
-			if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
-				if (function_exists('gzencode')) {
785
-					if (isset($this->debug_flag) && $this->debug_flag) {
786
-						$payload .= "<!-- Content being gzipped -->";
787
-					}
788
-					$this->outgoing_headers[] = "Content-Encoding: gzip";
789
-					$payload = gzencode($payload);
790
-				} else {
791
-					if (isset($this->debug_flag) && $this->debug_flag) {
792
-						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
-					}
794
-				}
795
-			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
-				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
-				// instead of gzcompress output,
798
-				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
-				if (function_exists('gzdeflate')) {
800
-					if (isset($this->debug_flag) && $this->debug_flag) {
801
-						$payload .= "<!-- Content being deflated -->";
802
-					}
803
-					$this->outgoing_headers[] = "Content-Encoding: deflate";
804
-					$payload = gzdeflate($payload);
805
-				} else {
806
-					if (isset($this->debug_flag) && $this->debug_flag) {
807
-						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
-					}
809
-				}
810
-			}
811
-		}
812
-		//end code
813
-		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
-		reset($this->outgoing_headers);
815
-		foreach($this->outgoing_headers as $hdr){
816
-			header($hdr, false);
817
-		}
818
-		print $payload;
819
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
-	}
812
+        //end code
813
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
+        reset($this->outgoing_headers);
815
+        foreach($this->outgoing_headers as $hdr){
816
+            header($hdr, false);
817
+        }
818
+        print $payload;
819
+        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
+    }
821 821
 
822
-	/**
823
-	* takes the value that was created by parsing the request
824
-	* and compares to the method's signature, if available.
825
-	*
826
-	* @param	string	$operation	The operation to be invoked
827
-	* @param	array	$request	The array of parameter values
828
-	* @return	boolean	Whether the operation was found
829
-	* @access   private
830
-	*/
831
-	function verify_method($operation,$request){
832
-		if(isset($this->wsdl) && is_object($this->wsdl)){
833
-			if($this->wsdl->getOperationData($operation)){
834
-				return true;
835
-			}
836
-	    } elseif(isset($this->operations[$operation])){
837
-			return true;
838
-		}
839
-		return false;
840
-	}
822
+    /**
823
+     * takes the value that was created by parsing the request
824
+     * and compares to the method's signature, if available.
825
+     *
826
+     * @param	string	$operation	The operation to be invoked
827
+     * @param	array	$request	The array of parameter values
828
+     * @return	boolean	Whether the operation was found
829
+     * @access   private
830
+     */
831
+    function verify_method($operation,$request){
832
+        if(isset($this->wsdl) && is_object($this->wsdl)){
833
+            if($this->wsdl->getOperationData($operation)){
834
+                return true;
835
+            }
836
+        } elseif(isset($this->operations[$operation])){
837
+            return true;
838
+        }
839
+        return false;
840
+    }
841 841
 
842
-	/**
843
-	* processes SOAP message received from client
844
-	*
845
-	* @param	array	$headers	The HTTP headers
846
-	* @param	string	$data		unprocessed request data from client
847
-	* @return	mixed	value of the message, decoded into a PHP type
848
-	* @access   private
849
-	*/
842
+    /**
843
+     * processes SOAP message received from client
844
+     *
845
+     * @param	array	$headers	The HTTP headers
846
+     * @param	string	$data		unprocessed request data from client
847
+     * @return	mixed	value of the message, decoded into a PHP type
848
+     * @access   private
849
+     */
850 850
     function parseRequest($headers, $data) {
851
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
-		$this->appendDebug($this->varDump($headers));
853
-    	if (!isset($headers['content-type'])) {
854
-			$this->setError('Request not of type text/xml (no content-type header)');
855
-			return false;
856
-    	}
857
-		if (!strstr($headers['content-type'], 'text/xml')) {
858
-			$this->setError('Request not of type text/xml');
859
-			return false;
860
-		}
861
-		if (strpos($headers['content-type'], '=')) {
862
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
-			$this->debug('Got response encoding: ' . $enc);
864
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
-				$this->xml_encoding = strtoupper($enc);
866
-			} else {
867
-				$this->xml_encoding = 'US-ASCII';
868
-			}
869
-		} else {
870
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
-			$this->xml_encoding = 'ISO-8859-1';
872
-		}
873
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
-		// parse response, get soap parser obj
875
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
851
+        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
+        $this->appendDebug($this->varDump($headers));
853
+        if (!isset($headers['content-type'])) {
854
+            $this->setError('Request not of type text/xml (no content-type header)');
855
+            return false;
856
+        }
857
+        if (!strstr($headers['content-type'], 'text/xml')) {
858
+            $this->setError('Request not of type text/xml');
859
+            return false;
860
+        }
861
+        if (strpos($headers['content-type'], '=')) {
862
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
+            $this->debug('Got response encoding: ' . $enc);
864
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
+                $this->xml_encoding = strtoupper($enc);
866
+            } else {
867
+                $this->xml_encoding = 'US-ASCII';
868
+            }
869
+        } else {
870
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
+            $this->xml_encoding = 'ISO-8859-1';
872
+        }
873
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
+        // parse response, get soap parser obj
875
+        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
876 876
 
877
-		// parser debug
878
-		$this->debug("parser debug: \n".$parser->getDebug());
879
-		// if fault occurred during message parsing
880
-		if($err = $parser->getError()){
881
-			$this->result = 'fault: error in msg parsing: '.$err;
882
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
-		// else successfully parsed request into soapval object
884
-		} else {
885
-			// get/set methodname
886
-			$this->methodURI = $parser->root_struct_namespace;
887
-			$this->methodname = $parser->root_struct_name;
888
-			$this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
-			$this->debug('calling parser->get_soapbody()');
890
-			$this->methodparams = $parser->get_soapbody();
891
-			// get SOAP headers
892
-			$this->requestHeaders = $parser->getHeaders();
893
-			// get SOAP Header
894
-			$this->requestHeader = $parser->get_soapheader();
877
+        // parser debug
878
+        $this->debug("parser debug: \n".$parser->getDebug());
879
+        // if fault occurred during message parsing
880
+        if($err = $parser->getError()){
881
+            $this->result = 'fault: error in msg parsing: '.$err;
882
+            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
+        // else successfully parsed request into soapval object
884
+        } else {
885
+            // get/set methodname
886
+            $this->methodURI = $parser->root_struct_namespace;
887
+            $this->methodname = $parser->root_struct_name;
888
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
+            $this->debug('calling parser->get_soapbody()');
890
+            $this->methodparams = $parser->get_soapbody();
891
+            // get SOAP headers
892
+            $this->requestHeaders = $parser->getHeaders();
893
+            // get SOAP Header
894
+            $this->requestHeader = $parser->get_soapheader();
895 895
             // add document for doclit support
896 896
             $this->document = $parser->document;
897
-		}
898
-	 }
897
+        }
898
+        }
899 899
 
900
-	/**
901
-	* gets the HTTP body for the current response.
902
-	*
903
-	* @param string $soapmsg The SOAP payload
904
-	* @return string The HTTP body, which includes the SOAP payload
905
-	* @access private
906
-	*/
907
-	function getHTTPBody($soapmsg) {
908
-		return $soapmsg;
909
-	}
900
+    /**
901
+     * gets the HTTP body for the current response.
902
+     *
903
+     * @param string $soapmsg The SOAP payload
904
+     * @return string The HTTP body, which includes the SOAP payload
905
+     * @access private
906
+     */
907
+    function getHTTPBody($soapmsg) {
908
+        return $soapmsg;
909
+    }
910 910
 
911
-	/**
912
-	* gets the HTTP content type for the current response.
913
-	*
914
-	* Note: getHTTPBody must be called before this.
915
-	*
916
-	* @return string the HTTP content type for the current response.
917
-	* @access private
918
-	*/
919
-	function getHTTPContentType() {
920
-		return 'text/xml';
921
-	}
911
+    /**
912
+     * gets the HTTP content type for the current response.
913
+     *
914
+     * Note: getHTTPBody must be called before this.
915
+     *
916
+     * @return string the HTTP content type for the current response.
917
+     * @access private
918
+     */
919
+    function getHTTPContentType() {
920
+        return 'text/xml';
921
+    }
922 922
 
923
-	/**
924
-	* gets the HTTP content type charset for the current response.
925
-	* returns false for non-text content types.
926
-	*
927
-	* Note: getHTTPBody must be called before this.
928
-	*
929
-	* @return string the HTTP content type charset for the current response.
930
-	* @access private
931
-	*/
932
-	function getHTTPContentTypeCharset() {
933
-		return $this->soap_defencoding;
934
-	}
923
+    /**
924
+     * gets the HTTP content type charset for the current response.
925
+     * returns false for non-text content types.
926
+     *
927
+     * Note: getHTTPBody must be called before this.
928
+     *
929
+     * @return string the HTTP content type charset for the current response.
930
+     * @access private
931
+     */
932
+    function getHTTPContentTypeCharset() {
933
+        return $this->soap_defencoding;
934
+    }
935 935
 
936
-	/**
937
-	* add a method to the dispatch map (this has been replaced by the register method)
938
-	*
939
-	* @param    string $methodname
940
-	* @param    string $in array of input values
941
-	* @param    string $out array of output values
942
-	* @access   public
943
-	* @deprecated
944
-	*/
945
-	function add_to_map($methodname,$in,$out){
946
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
-	}
936
+    /**
937
+     * add a method to the dispatch map (this has been replaced by the register method)
938
+     *
939
+     * @param    string $methodname
940
+     * @param    string $in array of input values
941
+     * @param    string $out array of output values
942
+     * @access   public
943
+     * @deprecated
944
+     */
945
+    function add_to_map($methodname,$in,$out){
946
+            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
+    }
948 948
 
949
-	/**
950
-	* register a service function with the server
951
-	*
952
-	* @param    string $name the name of the PHP function, class.method or class..method
953
-	* @param    array $in assoc array of input values: key = param name, value = param type
954
-	* @param    array $out assoc array of output values: key = param name, value = param type
955
-	* @param	mixed $namespace the element namespace for the method or false
956
-	* @param	mixed $soapaction the soapaction for the method or false
957
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
-	* @param	mixed $use optional (encoded|literal) or false
959
-	* @param	string $documentation optional Description to include in WSDL
960
-	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
-	* @access   public
962
-	*/
963
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
-		global $HTTP_SERVER_VARS;
949
+    /**
950
+     * register a service function with the server
951
+     *
952
+     * @param    string $name the name of the PHP function, class.method or class..method
953
+     * @param    array $in assoc array of input values: key = param name, value = param type
954
+     * @param    array $out assoc array of output values: key = param name, value = param type
955
+     * @param	mixed $namespace the element namespace for the method or false
956
+     * @param	mixed $soapaction the soapaction for the method or false
957
+     * @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
+     * @param	mixed $use optional (encoded|literal) or false
959
+     * @param	string $documentation optional Description to include in WSDL
960
+     * @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
+     * @access   public
962
+     */
963
+    function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
+        global $HTTP_SERVER_VARS;
965 965
 
966
-		if($this->externalWSDLURL){
967
-			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
-		}
969
-		if (! $name) {
970
-			die('You must specify a name when you register an operation');
971
-		}
972
-		if (!is_array($in)) {
973
-			die('You must provide an array for operation inputs');
974
-		}
975
-		if (!is_array($out)) {
976
-			die('You must provide an array for operation outputs');
977
-		}
978
-		if(false == $namespace) {
979
-		}
980
-		if(false == $soapaction) {
981
-			if (isset($_SERVER)) {
982
-				$SERVER_NAME = $_SERVER['SERVER_NAME'];
983
-				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
-				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
-			} elseif (isset($HTTP_SERVER_VARS)) {
986
-				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
-				$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
-				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
-			} else {
990
-				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
-			}
992
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
993
-        		$SCHEME = 'https';
994
-        	} else {
995
-        		$SCHEME = 'http';
996
-        	}
997
-			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
-		}
999
-		if(false == $style) {
1000
-			$style = "rpc";
1001
-		}
1002
-		if(false == $use) {
1003
-			$use = "encoded";
1004
-		}
1005
-		if ($use == 'encoded' && $encodingStyle == '') {
1006
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
-		}
966
+        if($this->externalWSDLURL){
967
+            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
+        }
969
+        if (! $name) {
970
+            die('You must specify a name when you register an operation');
971
+        }
972
+        if (!is_array($in)) {
973
+            die('You must provide an array for operation inputs');
974
+        }
975
+        if (!is_array($out)) {
976
+            die('You must provide an array for operation outputs');
977
+        }
978
+        if(false == $namespace) {
979
+        }
980
+        if(false == $soapaction) {
981
+            if (isset($_SERVER)) {
982
+                $SERVER_NAME = $_SERVER['SERVER_NAME'];
983
+                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
+                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
+            } elseif (isset($HTTP_SERVER_VARS)) {
986
+                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
+                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
+                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
+            } else {
990
+                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
+            }
992
+            if ($HTTPS == '1' || $HTTPS == 'on') {
993
+                $SCHEME = 'https';
994
+            } else {
995
+                $SCHEME = 'http';
996
+            }
997
+            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
+        }
999
+        if(false == $style) {
1000
+            $style = "rpc";
1001
+        }
1002
+        if(false == $use) {
1003
+            $use = "encoded";
1004
+        }
1005
+        if ($use == 'encoded' && $encodingStyle == '') {
1006
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
+        }
1008 1008
 
1009
-		$this->operations[$name] = array(
1010
-	    'name' => $name,
1011
-	    'in' => $in,
1012
-	    'out' => $out,
1013
-	    'namespace' => $namespace,
1014
-	    'soapaction' => $soapaction,
1015
-	    'style' => $style);
1009
+        $this->operations[$name] = array(
1010
+        'name' => $name,
1011
+        'in' => $in,
1012
+        'out' => $out,
1013
+        'namespace' => $namespace,
1014
+        'soapaction' => $soapaction,
1015
+        'style' => $style);
1016 1016
         if($this->wsdl){
1017
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
-	    }
1019
-		return true;
1020
-	}
1017
+            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
+        }
1019
+        return true;
1020
+    }
1021 1021
 
1022
-	/**
1023
-	* Specify a fault to be returned to the client.
1024
-	* This also acts as a flag to the server that a fault has occured.
1025
-	*
1026
-	* @param	string $faultcode
1027
-	* @param	string $faultstring
1028
-	* @param	string $faultactor
1029
-	* @param	string $faultdetail
1030
-	* @access   public
1031
-	*/
1032
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
-		if ($faultdetail == '' && $this->debug_flag) {
1034
-			$faultdetail = $this->getDebug();
1035
-		}
1036
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
-		$this->fault->soap_defencoding = $this->soap_defencoding;
1038
-	}
1022
+    /**
1023
+     * Specify a fault to be returned to the client.
1024
+     * This also acts as a flag to the server that a fault has occured.
1025
+     *
1026
+     * @param	string $faultcode
1027
+     * @param	string $faultstring
1028
+     * @param	string $faultactor
1029
+     * @param	string $faultdetail
1030
+     * @access   public
1031
+     */
1032
+    function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
+        if ($faultdetail == '' && $this->debug_flag) {
1034
+            $faultdetail = $this->getDebug();
1035
+        }
1036
+        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
+        $this->fault->soap_defencoding = $this->soap_defencoding;
1038
+    }
1039 1039
 
1040 1040
     /**
1041
-    * Sets up wsdl object.
1042
-    * Acts as a flag to enable internal WSDL generation
1043
-    *
1044
-    * @param string $serviceName, name of the service
1045
-    * @param mixed $namespace optional 'tns' service namespace or false
1046
-    * @param mixed $endpoint optional URL of service endpoint or false
1047
-    * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
-    * @param string $transport optional SOAP transport
1049
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
-    */
1041
+     * Sets up wsdl object.
1042
+     * Acts as a flag to enable internal WSDL generation
1043
+     *
1044
+     * @param string $serviceName, name of the service
1045
+     * @param mixed $namespace optional 'tns' service namespace or false
1046
+     * @param mixed $endpoint optional URL of service endpoint or false
1047
+     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
+     * @param string $transport optional SOAP transport
1049
+     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
+     */
1051 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1052 1052
     {
1053
-    	global $HTTP_SERVER_VARS;
1053
+        global $HTTP_SERVER_VARS;
1054 1054
 
1055
-		if (isset($_SERVER)) {
1056
-			$SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
-			$SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
-			$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
-			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
-		} elseif (isset($HTTP_SERVER_VARS)) {
1061
-			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
-			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
-			$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
-			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
-		} else {
1066
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
-		}
1068
-		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
-		$colon = strpos($SERVER_NAME,":");
1070
-		if ($colon) {
1071
-		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
-		}
1073
-		if ($SERVER_PORT == 80) {
1074
-			$SERVER_PORT = '';
1075
-		} else {
1076
-			$SERVER_PORT = ':' . $SERVER_PORT;
1077
-		}
1055
+        if (isset($_SERVER)) {
1056
+            $SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
+            $SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
+            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
+            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
+        } elseif (isset($HTTP_SERVER_VARS)) {
1061
+            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
+            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
+            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
+            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
+        } else {
1066
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
+        }
1068
+        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
+        $colon = strpos($SERVER_NAME,":");
1070
+        if ($colon) {
1071
+            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
+        }
1073
+        if ($SERVER_PORT == 80) {
1074
+            $SERVER_PORT = '';
1075
+        } else {
1076
+            $SERVER_PORT = ':' . $SERVER_PORT;
1077
+        }
1078 1078
         if(false == $namespace) {
1079 1079
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1080 1080
         }
1081 1081
 
1082 1082
         if(false == $endpoint) {
1083
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
1084
-        		$SCHEME = 'https';
1085
-        	} else {
1086
-        		$SCHEME = 'http';
1087
-        	}
1083
+            if ($HTTPS == '1' || $HTTPS == 'on') {
1084
+                $SCHEME = 'https';
1085
+            } else {
1086
+                $SCHEME = 'http';
1087
+            }
1088 1088
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1089 1089
         }
1090 1090
 
@@ -1094,28 +1094,28 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
         $this->wsdl = new wsdl();
1096 1096
         $this->wsdl->soap_defencoding = $this->soap_defencoding;
1097
-		$this->wsdl->serviceName = $serviceName;
1097
+        $this->wsdl->serviceName = $serviceName;
1098 1098
         $this->wsdl->endpoint = $endpoint;
1099
-		$this->wsdl->namespaces['tns'] = $namespace;
1100
-		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
-		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
-		if ($schemaTargetNamespace != $namespace) {
1103
-			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
-		}
1099
+        $this->wsdl->namespaces['tns'] = $namespace;
1100
+        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
+        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
+        if ($schemaTargetNamespace != $namespace) {
1103
+            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
+        }
1105 1105
         $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
1106 1106
         if ($style == 'document') {
1107
-	        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1107
+            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1108 1108
         }
1109 1109
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
1110 1110
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
1111 1111
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
1112 1112
         $this->wsdl->bindings[$serviceName.'Binding'] = array(
1113
-        	'name'=>$serviceName.'Binding',
1113
+            'name'=>$serviceName.'Binding',
1114 1114
             'style'=>$style,
1115 1115
             'transport'=>$transport,
1116 1116
             'portType'=>$serviceName.'PortType');
1117 1117
         $this->wsdl->ports[$serviceName.'Port'] = array(
1118
-        	'binding'=>$serviceName.'Binding',
1118
+            'binding'=>$serviceName.'Binding',
1119 1119
             'location'=>$endpoint,
1120 1120
             'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
1121 1121
     }
Please login to merge, or discard this patch.
main/webservices/webservice_session.php 1 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::subscribe_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::subscribe_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.
main/messages/download.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 $message_uid = '';
51 51
 $message_type = array('inbox','outbox');
52 52
 if (in_array($_GET['type'],$message_type)) {
53
-	if ($_GET['type'] == 'inbox') {
54
-		$message_uid = $row_users['user_receiver_id'];
55
-	} else {
56
-		$message_uid = $row_users['user_sender_id'];
57
-	}
53
+    if ($_GET['type'] == 'inbox') {
54
+        $message_uid = $row_users['user_receiver_id'];
55
+    } else {
56
+        $message_uid = $row_users['user_sender_id'];
57
+    }
58 58
 }
59 59
 
60 60
 // allow to the correct user for download this file
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 $userGroup = new UserGroup();
63 63
 
64 64
 if (!empty($row_users['group_id'])) {
65
-	$users_group = $userGroup->get_all_users_by_group($row_users['group_id']);
66
-	if (!in_array($current_uid,array_keys($users_group))) {
67
-		$not_allowed_to_edit = true;
68
-	}
65
+    $users_group = $userGroup->get_all_users_by_group($row_users['group_id']);
66
+    if (!in_array($current_uid,array_keys($users_group))) {
67
+        $not_allowed_to_edit = true;
68
+    }
69 69
 } else {
70
-	if ($current_uid != $message_uid) {
71
-		$not_allowed_to_edit = true;
72
-	}
70
+    if ($current_uid != $message_uid) {
71
+        $not_allowed_to_edit = true;
72
+    }
73 73
 }
74 74
 
75 75
 if ($not_allowed_to_edit) {
76
-	api_not_allowed(true);
77
-	exit;
76
+    api_not_allowed(true);
77
+    exit;
78 78
 }
79 79
 
80 80
 // set the path directory file
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         true
86 86
     );
87 87
 } else {
88
-	$path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
88
+    $path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
89 89
 }
90 90
 
91 91
 $full_file_name = $path_user_info['dir'].'message_attachments/'.$file_url;
Please login to merge, or discard this patch.