Completed
Push — 1.10.x ( ba9367...ff0ff6 )
by Julito
118:58 queued 74:08
created
main/dropbox/dropbox_class.inc.php 4 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $action = isset($_GET['action']) ? $_GET['action'] : null;
185 185
 
186 186
         // Do some sanity checks
187
-        $id	= intval($id);
187
+        $id = intval($id);
188 188
 
189 189
         // Get the data from DB
190 190
         $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
                 $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
227 227
                 $feedback2[] = $row_feedback;
228 228
             }
229
-            $this->feedback2= $feedback2;
229
+            $this->feedback2 = $feedback2;
230 230
         }
231 231
 	}
232 232
 }
233 233
 
234 234
 class Dropbox_SentWork extends Dropbox_Work
235 235
 {
236
-	public $recipients;	//array of ['id']['name'] arrays
236
+	public $recipients; //array of ['id']['name'] arrays
237 237
 
238 238
 	/**
239 239
 	 * Constructor calls private functions to create a new work or retreive an existing work from DB
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
291 291
 
292 292
 		$justSubmit = false;
293
-		if ( is_int($recipient_ids)) {
293
+		if (is_int($recipient_ids)) {
294 294
 			$justSubmit = true;
295 295
 			$recipient_ids = array($recipient_ids + $this->id);
296
-		} elseif ( count($recipient_ids) == 0) {
296
+		} elseif (count($recipient_ids) == 0) {
297 297
 			$justSubmit = true;
298 298
 			$recipient_ids = array($uploader_id);
299 299
 		}
300 300
 
301
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
301
+		if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
302 302
 			die(get_lang('GeneralError').' (code 209)');
303 303
 		}
304 304
 
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
         $table_person = $dropbox_cnf['tbl_person'];
314 314
         $session_id = api_get_session_id();
315 315
         $uploader_id = $this->uploader_id;
316
-        $user  = api_get_user_id();
316
+        $user = api_get_user_id();
317 317
 		// Insert data in dropbox_post and dropbox_person table for each recipient
318 318
 		foreach ($this->recipients as $rec) {
319
-            $file_id = (int)$this->id;
320
-            $user_id = (int)$rec['id'];
319
+            $file_id = (int) $this->id;
320
+            $user_id = (int) $rec['id'];
321 321
 			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id)
322 322
                     VALUES ($course_id, $file_id, $user_id, $session_id)";
323 323
 	        Database::query($sql);
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                 // Do not add recipient in person table if mailing zip or just upload.
335 335
                 if (!$justSubmit) {
336
-                    Database::query($sql);	// If work already exists no error is generated
336
+                    Database::query($sql); // If work already exists no error is generated
337 337
                 }
338 338
             }
339 339
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			    $ownerid = getUserOwningThisMailing($ownerid);
343 343
 			}
344 344
 			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
345
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
345
+			    $recipid = $ownerid; // mailing file recipient = mailing id, not a person
346 346
 			}
347 347
             api_item_property_update(
348 348
                 $_course,
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 class Dropbox_Person
402 402
 {
403 403
 	// The receivedWork and the sentWork arrays are sorted.
404
-	public $receivedWork;	// an array of Dropbox_Work objects
405
-	public $sentWork;		// an array of Dropbox_SentWork objects
404
+	public $receivedWork; // an array of Dropbox_Work objects
405
+	public $sentWork; // an array of Dropbox_SentWork objects
406 406
 
407 407
 	public $userId = 0;
408 408
 	public $isCourseAdmin = false;
409 409
 	public $isCourseTutor = false;
410
-	public $_orderBy = '';	// private property that determines by which field
410
+	public $_orderBy = ''; // private property that determines by which field
411 411
 
412 412
 	/**
413 413
 	 * Constructor for recreating the Dropbox_Person object
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 */
507 507
 	function orderSentWork($sort)
508 508
     {
509
-		switch($sort) {
509
+		switch ($sort) {
510 510
 			case 'lastDate':
511 511
 				$this->_orderBy = 'last_upload_date';
512 512
 				break;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 */
540 540
 	function orderReceivedWork($sort)
541 541
     {
542
-		switch($sort) {
542
+		switch ($sort) {
543 543
 			case 'lastDate':
544 544
 				$this->_orderBy = 'last_upload_date';
545 545
 				break;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
633 633
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
634 634
 		Database::query($sql);
635
-		removeUnusedFiles();	// Check for unused files
635
+		removeUnusedFiles(); // Check for unused files
636 636
 	}
637 637
 
638 638
 	/**
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 			Database::query($sql);
650 650
 			removeMoreIfMailing($w->id);
651 651
 		}
652
-		removeUnusedFiles();	// Check for unused files
652
+		removeUnusedFiles(); // Check for unused files
653 653
 	}
654 654
 
655 655
 	/**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
684 684
 		Database::query($sql);
685 685
 		removeMoreIfMailing($id);
686
-		removeUnusedFiles();	// Check for unused files
686
+		removeUnusedFiles(); // Check for unused files
687 687
 	}
688 688
 
689 689
 	/**
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 		$wi = -1;
706 706
 		foreach ($this->receivedWork as $w) {
707 707
 			$wi++;
708
-			if ($w->id == $id){
708
+			if ($w->id == $id) {
709 709
 			   $found = true;
710 710
 			   break;
711 711
 			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -303,7 +303,9 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		foreach ($recipient_ids as $rec) {
306
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
306
+			if (empty($rec)) {
307
+			    die(get_lang('GeneralError').' (code 210)');
308
+			}
307 309
 			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
308 310
 				//this check is done when validating submitted data
309 311
 			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
@@ -593,13 +595,19 @@  discard block
 block discarded – undo
593 595
 		$id = intval($id);
594 596
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
595 597
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
596
-		if (!Database::query($sql)) return false;
598
+		if (!Database::query($sql)) {
599
+		    return false;
600
+		}
597 601
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
598 602
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
599
-		if (!Database::query($sql)) return false;
603
+		if (!Database::query($sql)) {
604
+		    return false;
605
+		}
600 606
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
601 607
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
602
-		if (!Database::query($sql)) return false;
608
+		if (!Database::query($sql)) {
609
+		    return false;
610
+		}
603 611
 		return true;
604 612
 	}
605 613
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
 	 * @param string $author
268 268
 	 * @param string $filename
269 269
 	 * @param int $filesize
270
-	 * @param array $recipient_ids
270
+	 * @param unknown_type|null $recipient_ids
271 271
 	 */
272 272
 	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
Please login to merge, or discard this patch.
Indentation   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
         }
78 78
     }
79 79
 
80
-	/**
81
-	 * private function creating a new work object
82
-	 *
83
-	 * @param int $uploader_id
84
-	 * @param string $title
85
-	 * @param string $description
86
-	 * @param string $author
87
-	 * @param string $filename
88
-	 * @param int $filesize
89
-	 *
90
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
91
-	 * 			As a consequence this parameter can be removed
92
-	 */
93
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
80
+    /**
81
+     * private function creating a new work object
82
+     *
83
+     * @param int $uploader_id
84
+     * @param string $title
85
+     * @param string $description
86
+     * @param string $author
87
+     * @param string $filename
88
+     * @param int $filesize
89
+     *
90
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
91
+     * 			As a consequence this parameter can be removed
92
+     */
93
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
94 94
     {
95 95
         $dropbox_cnf = getDropboxConf();
96 96
 
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
         // Check if object exists already. If it does, the old object is used
109 109
         // with updated information (authors, description, upload_date)
110 110
         $this->isOldWork = false;
111
-		$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
111
+        $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
112 112
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
113 113
         $result = Database::query($sql);
114
-		$res = Database::fetch_array($result);
115
-		if ($res) {
116
-			$this->isOldWork = true;
117
-		}
118
-		// Insert or update the dropbox_file table and set the id property
119
-		if ($this->isOldWork) {
120
-			$this->id = $res['id'];
121
-			$this->upload_date = $res['upload_date'];
114
+        $res = Database::fetch_array($result);
115
+        if ($res) {
116
+            $this->isOldWork = true;
117
+        }
118
+        // Insert or update the dropbox_file table and set the id property
119
+        if ($this->isOldWork) {
120
+            $this->id = $res['id'];
121
+            $this->upload_date = $res['upload_date'];
122 122
 
123 123
             $params = [
124 124
                 'filesize' => $this->filesize,
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
136 136
             );
137 137
 
138
-		} else {
139
-			$this->upload_date = $this->last_upload_date;
140
-			$params = [
138
+        } else {
139
+            $this->upload_date = $this->last_upload_date;
140
+            $params = [
141 141
                 'c_id' => $course_id,
142 142
                 'uploader_id' => $this->uploader_id,
143 143
                 'filename' => $this->filename,
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
                 'last_upload_date' => $this->last_upload_date,
150 150
                 'session_id' => api_get_session_id(),
151 151
                 'cat_id' => 0
152
-			];
152
+            ];
153 153
 
154
-			$this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
155
-			if ($this->id) {
156
-				$sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
157
-				Database::query($sql);
158
-			}
159
-		}
154
+            $this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
155
+            if ($this->id) {
156
+                $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
157
+                Database::query($sql);
158
+            }
159
+        }
160 160
 
161 161
         $sql = "SELECT count(file_id) as count
162 162
         		FROM ".$dropbox_cnf['tbl_person']."
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
171 171
             Database::query($sql);
172 172
         }
173
-	}
174
-
175
-	/**
176
-	 * private function creating existing object by retreiving info from db
177
-	 *
178
-	 * @param int $id
179
-	 */
180
-	public function _createExistingWork($id)
173
+    }
174
+
175
+    /**
176
+     * private function creating existing object by retreiving info from db
177
+     *
178
+     * @param int $id
179
+     */
180
+    public function _createExistingWork($id)
181 181
     {
182
-	    $course_id = api_get_course_int_id();
182
+        $course_id = api_get_course_int_id();
183 183
         $dropbox_cnf = getDropboxConf();
184 184
 
185 185
         $action = isset($_GET['action']) ? $_GET['action'] : null;
@@ -229,52 +229,52 @@  discard block
 block discarded – undo
229 229
             }
230 230
             $this->feedback2= $feedback2;
231 231
         }
232
-	}
232
+    }
233 233
 }
234 234
 
235 235
 class Dropbox_SentWork extends Dropbox_Work
236 236
 {
237
-	public $recipients;	//array of ['id']['name'] arrays
238
-
239
-	/**
240
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
241
-	 * depending on the number of parameters
242
-	 *
243
-	 * @param unknown_type $arg1
244
-	 * @param unknown_type $arg2
245
-	 * @param unknown_type $arg3
246
-	 * @param unknown_type $arg4
247
-	 * @param unknown_type $arg5
248
-	 * @param unknown_type $arg6
249
-	 * @param unknown_type $arg7
250
-	 * @return Dropbox_SentWork
251
-	 */
252
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
237
+    public $recipients;	//array of ['id']['name'] arrays
238
+
239
+    /**
240
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
241
+     * depending on the number of parameters
242
+     *
243
+     * @param unknown_type $arg1
244
+     * @param unknown_type $arg2
245
+     * @param unknown_type $arg3
246
+     * @param unknown_type $arg4
247
+     * @param unknown_type $arg5
248
+     * @param unknown_type $arg6
249
+     * @param unknown_type $arg7
250
+     * @return Dropbox_SentWork
251
+     */
252
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
253 253
     {
254
-		if (func_num_args() > 1) {
255
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
256
-		} else {
257
-			$this->_createExistingSentWork($arg1);
258
-		}
259
-	}
260
-
261
-	/**
262
-	 * private function creating a new SentWork object
263
-	 *
264
-	 * @param int $uploader_id
265
-	 * @param string $title
266
-	 * @param string $description
267
-	 * @param string $author
268
-	 * @param string $filename
269
-	 * @param int $filesize
270
-	 * @param array $recipient_ids
271
-	 */
272
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
254
+        if (func_num_args() > 1) {
255
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
256
+        } else {
257
+            $this->_createExistingSentWork($arg1);
258
+        }
259
+    }
260
+
261
+    /**
262
+     * private function creating a new SentWork object
263
+     *
264
+     * @param int $uploader_id
265
+     * @param string $title
266
+     * @param string $description
267
+     * @param string $author
268
+     * @param string $filename
269
+     * @param int $filesize
270
+     * @param array $recipient_ids
271
+     */
272
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
274 274
         $dropbox_cnf = getDropboxConf();
275 275
         $_course = api_get_course_info();
276 276
 
277
-		// Call constructor of Dropbox_Work object
277
+        // Call constructor of Dropbox_Work object
278 278
         parent::__construct(
279 279
             $uploader_id,
280 280
             $title,
@@ -284,31 +284,31 @@  discard block
 block discarded – undo
284 284
             $filesize
285 285
         );
286 286
 
287
-		$course_id = api_get_course_int_id();
288
-
289
-		// Do sanity checks on recipient_ids array & property fillin
290
-		// The sanity check for ex-coursemembers is already done in base constructor
291
-		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
287
+        $course_id = api_get_course_int_id();
292 288
 
293
-		$justSubmit = false;
294
-		if ( is_int($recipient_ids)) {
295
-			$justSubmit = true;
296
-			$recipient_ids = array($recipient_ids + $this->id);
297
-		} elseif ( count($recipient_ids) == 0) {
298
-			$justSubmit = true;
299
-			$recipient_ids = array($uploader_id);
300
-		}
289
+        // Do sanity checks on recipient_ids array & property fillin
290
+        // The sanity check for ex-coursemembers is already done in base constructor
291
+        settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
292
+
293
+        $justSubmit = false;
294
+        if ( is_int($recipient_ids)) {
295
+            $justSubmit = true;
296
+            $recipient_ids = array($recipient_ids + $this->id);
297
+        } elseif ( count($recipient_ids) == 0) {
298
+            $justSubmit = true;
299
+            $recipient_ids = array($uploader_id);
300
+        }
301 301
 
302
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
303
-			die(get_lang('GeneralError').' (code 209)');
304
-		}
302
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
303
+            die(get_lang('GeneralError').' (code 209)');
304
+        }
305 305
 
306
-		foreach ($recipient_ids as $rec) {
307
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
308
-			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
309
-				//this check is done when validating submitted data
310
-			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
311
-		}
306
+        foreach ($recipient_ids as $rec) {
307
+            if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
308
+            //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
309
+                //this check is done when validating submitted data
310
+            $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
311
+        }
312 312
 
313 313
         $table_post = $dropbox_cnf['tbl_post'];
314 314
         $table_person = $dropbox_cnf['tbl_person'];
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
         $user  = api_get_user_id();
318 318
         $now = api_get_utc_datetime();
319 319
 
320
-		// Insert data in dropbox_post and dropbox_person table for each recipient
321
-		foreach ($this->recipients as $rec) {
320
+        // Insert data in dropbox_post and dropbox_person table for each recipient
321
+        foreach ($this->recipients as $rec) {
322 322
             $file_id = (int)$this->id;
323 323
             $user_id = (int)$rec['id'];
324
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
324
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
325 325
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
326
-	        Database::query($sql);
326
+            Database::query($sql);
327 327
             // If work already exists no error is generated
328 328
 
329 329
             /**
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
                 }
341 341
             }
342 342
 
343
-			// Update item_property table for each recipient
344
-			if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
345
-			    $ownerid = getUserOwningThisMailing($ownerid);
346
-			}
347
-			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
348
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
349
-			}
343
+            // Update item_property table for each recipient
344
+            if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
345
+                $ownerid = getUserOwningThisMailing($ownerid);
346
+            }
347
+            if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
348
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
349
+            }
350 350
             api_item_property_update(
351 351
                 $_course,
352 352
                 TOOL_DROPBOX,
@@ -356,92 +356,92 @@  discard block
 block discarded – undo
356 356
                 null,
357 357
                 $recipid
358 358
             );
359
-		}
360
-	}
361
-
362
-	/**
363
-	 * private function creating existing object by retreiving info from db
364
-	 *
365
-	 * @param unknown_type $id
366
-	 */
367
-	public function _createExistingSentWork($id)
359
+        }
360
+    }
361
+
362
+    /**
363
+     * private function creating existing object by retreiving info from db
364
+     *
365
+     * @param unknown_type $id
366
+     */
367
+    public function _createExistingSentWork($id)
368 368
     {
369 369
         $dropbox_cnf = getDropboxConf();
370 370
         $id = intval($id);
371 371
 
372
-		$course_id = api_get_course_int_id();
372
+        $course_id = api_get_course_int_id();
373 373
 
374
-		// Call constructor of Dropbox_Work object
375
-		parent::__construct($id);
374
+        // Call constructor of Dropbox_Work object
375
+        parent::__construct($id);
376 376
 
377
-		// Fill in recipients array
378
-		$this->recipients = array();
379
-		$sql = "SELECT dest_user_id, feedback_date, feedback
377
+        // Fill in recipients array
378
+        $this->recipients = array();
379
+        $sql = "SELECT dest_user_id, feedback_date, feedback
380 380
 				FROM ".$dropbox_cnf['tbl_post']."
381 381
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
382 382
         $result = Database::query($sql);
383
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
384
-
385
-			// Check for deleted users
386
-			$dest_user_id = $res['dest_user_id'];
387
-			$user_info = api_get_user_info($dest_user_id);
388
-			//$this->category = $res['cat_id'];
389
-			if (!$user_info) {
390
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
391
-			} else {
392
-				$this->recipients[] = array(
383
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
384
+
385
+            // Check for deleted users
386
+            $dest_user_id = $res['dest_user_id'];
387
+            $user_info = api_get_user_info($dest_user_id);
388
+            //$this->category = $res['cat_id'];
389
+            if (!$user_info) {
390
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
391
+            } else {
392
+                $this->recipients[] = array(
393 393
                     'id' => $dest_user_id,
394 394
                     'name' => $user_info['complete_name'],
395 395
                     'user_id' => $dest_user_id,
396
-				    'feedback_date' => $res['feedback_date'],
396
+                    'feedback_date' => $res['feedback_date'],
397 397
                     'feedback' => $res['feedback']
398 398
                 );
399
-			}
400
-		}
401
-	}
399
+            }
400
+        }
401
+    }
402 402
 }
403 403
 
404 404
 class Dropbox_Person
405 405
 {
406
-	// The receivedWork and the sentWork arrays are sorted.
407
-	public $receivedWork;	// an array of Dropbox_Work objects
408
-	public $sentWork;		// an array of Dropbox_SentWork objects
409
-
410
-	public $userId = 0;
411
-	public $isCourseAdmin = false;
412
-	public $isCourseTutor = false;
413
-	public $_orderBy = '';	// private property that determines by which field
414
-
415
-	/**
416
-	 * Constructor for recreating the Dropbox_Person object
417
-	 *
418
-	 * @param int $userId
419
-	 * @param bool $isCourseAdmin
420
-	 * @param bool $isCourseTutor
421
-	 * @return Dropbox_Person
422
-	 */
423
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
406
+    // The receivedWork and the sentWork arrays are sorted.
407
+    public $receivedWork;	// an array of Dropbox_Work objects
408
+    public $sentWork;		// an array of Dropbox_SentWork objects
409
+
410
+    public $userId = 0;
411
+    public $isCourseAdmin = false;
412
+    public $isCourseTutor = false;
413
+    public $_orderBy = '';	// private property that determines by which field
414
+
415
+    /**
416
+     * Constructor for recreating the Dropbox_Person object
417
+     *
418
+     * @param int $userId
419
+     * @param bool $isCourseAdmin
420
+     * @param bool $isCourseTutor
421
+     * @return Dropbox_Person
422
+     */
423
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
424 424
     {
425
-	    $course_id = api_get_course_int_id();
425
+        $course_id = api_get_course_int_id();
426 426
 
427
-		// Fill in properties
427
+        // Fill in properties
428 428
         $this->userId = $userId;
429 429
         $this->isCourseAdmin = $isCourseAdmin;
430 430
         $this->isCourseTutor = $isCourseTutor;
431 431
         $this->receivedWork = array();
432 432
         $this->sentWork = array();
433 433
 
434
-		// Note: perhaps include an ex coursemember check to delete old files
434
+        // Note: perhaps include an ex coursemember check to delete old files
435 435
 
436
-		$session_id = api_get_session_id();
437
-		$condition_session = api_get_session_condition($session_id);
436
+        $session_id = api_get_session_id();
437
+        $condition_session = api_get_session_condition($session_id);
438 438
 
439
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
440
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
441
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
439
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
440
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
441
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
442 442
 
443 443
         // Find all entries where this person is the recipient
444
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
444
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
445 445
                 FROM $post_tbl r
446 446
                 INNER JOIN $person_tbl p
447 447
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
451 451
 
452 452
         $result = Database::query($sql);
453
-		while ($res = Database::fetch_array($result)) {
454
-			$temp = new Dropbox_Work($res['file_id']);
455
-			$temp->category = $res['cat_id'];
456
-			$this->receivedWork[] = $temp;
457
-		}
458
-		// Find all entries where this person is the sender/uploader
453
+        while ($res = Database::fetch_array($result)) {
454
+            $temp = new Dropbox_Work($res['file_id']);
455
+            $temp->category = $res['cat_id'];
456
+            $this->receivedWork[] = $temp;
457
+        }
458
+        // Find all entries where this person is the sender/uploader
459 459
         $sql = "SELECT DISTINCT f.id
460 460
 				FROM $file_tbl f
461 461
 				INNER JOIN $person_tbl p
@@ -466,261 +466,261 @@  discard block
 block discarded – undo
466 466
                     $condition_session
467 467
                 ";
468 468
         $result = Database::query($sql);
469
-		while ($res = Database::fetch_array($result)) {
470
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
471
-		}
472
-	}
473
-
474
-	/**
475
-	 * This private method is used by the usort function in  the
476
-	 * orderSentWork and orderReceivedWork methods.
477
-	 * It compares 2 work-objects by 1 of the properties of that object, dictated by the
478
-	 * private property _orderBy
479
-	 *
480
-	 * @param unknown_type $a
481
-	 * @param unknown_type $b
482
-	 * @return -1, 0 or 1 dependent of the result of the comparison.
483
-	 */
484
-	function _cmpWork($a, $b)
469
+        while ($res = Database::fetch_array($result)) {
470
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
471
+        }
472
+    }
473
+
474
+    /**
475
+     * This private method is used by the usort function in  the
476
+     * orderSentWork and orderReceivedWork methods.
477
+     * It compares 2 work-objects by 1 of the properties of that object, dictated by the
478
+     * private property _orderBy
479
+     *
480
+     * @param unknown_type $a
481
+     * @param unknown_type $b
482
+     * @return -1, 0 or 1 dependent of the result of the comparison.
483
+     */
484
+    function _cmpWork($a, $b)
485 485
     {
486
-		$sort = $this->_orderBy;
487
-		$aval = $a->$sort;
488
-		$bval = $b->$sort;
489
-		if ($sort == 'recipients') {
490
-		    // The recipients property is an array so we do the comparison based
491
-		    // on the first item of the recipients array
492
-		    $aval = $aval[0]['name'];
493
-			$bval = $bval[0]['name'];
494
-		}
495
-		if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
496
-			return $aval < $bval ? -1 : 1;
497
-		} elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
498
-			return api_strnatcmp($aval, $bval);
499
-		} else {
500
-		    return api_strcasecmp($aval, $bval);
501
-		}
502
-	}
503
-
504
-	/**
505
-	 * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
506
-	 * $sort can be lastDate, firstDate, title, size, ...
507
-	 *
508
-	 * @param unknown_type $sort
509
-	 */
510
-	function orderSentWork($sort)
486
+        $sort = $this->_orderBy;
487
+        $aval = $a->$sort;
488
+        $bval = $b->$sort;
489
+        if ($sort == 'recipients') {
490
+            // The recipients property is an array so we do the comparison based
491
+            // on the first item of the recipients array
492
+            $aval = $aval[0]['name'];
493
+            $bval = $bval[0]['name'];
494
+        }
495
+        if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
496
+            return $aval < $bval ? -1 : 1;
497
+        } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
498
+            return api_strnatcmp($aval, $bval);
499
+        } else {
500
+            return api_strcasecmp($aval, $bval);
501
+        }
502
+    }
503
+
504
+    /**
505
+     * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
506
+     * $sort can be lastDate, firstDate, title, size, ...
507
+     *
508
+     * @param unknown_type $sort
509
+     */
510
+    function orderSentWork($sort)
511 511
     {
512
-		switch($sort) {
513
-			case 'lastDate':
514
-				$this->_orderBy = 'last_upload_date';
515
-				break;
516
-			case 'firstDate':
517
-				$this->_orderBy = 'upload_date';
518
-				break;
519
-			case 'title':
520
-				$this->_orderBy = 'title';
521
-				break;
522
-			case 'size':
523
-				$this->_orderBy = 'filesize';
524
-				break;
525
-			case 'author':
526
-				$this->_orderBy = 'author';
527
-				break;
528
-			case 'recipient':
529
-				$this->_orderBy = 'recipients';
530
-				break;
531
-			default:
532
-				$this->_orderBy = 'last_upload_date';
533
-		}
534
-
535
-		usort($this->sentWork, array($this, '_cmpWork'));
536
-	}
537
-
538
-	/**
539
-	 * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
540
-	 * $sort can be lastDate, firstDate, title, size, ...
541
-	 * @param unknown_type $sort
542
-	 */
543
-	function orderReceivedWork($sort)
512
+        switch($sort) {
513
+            case 'lastDate':
514
+                $this->_orderBy = 'last_upload_date';
515
+                break;
516
+            case 'firstDate':
517
+                $this->_orderBy = 'upload_date';
518
+                break;
519
+            case 'title':
520
+                $this->_orderBy = 'title';
521
+                break;
522
+            case 'size':
523
+                $this->_orderBy = 'filesize';
524
+                break;
525
+            case 'author':
526
+                $this->_orderBy = 'author';
527
+                break;
528
+            case 'recipient':
529
+                $this->_orderBy = 'recipients';
530
+                break;
531
+            default:
532
+                $this->_orderBy = 'last_upload_date';
533
+        }
534
+
535
+        usort($this->sentWork, array($this, '_cmpWork'));
536
+    }
537
+
538
+    /**
539
+     * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
540
+     * $sort can be lastDate, firstDate, title, size, ...
541
+     * @param unknown_type $sort
542
+     */
543
+    function orderReceivedWork($sort)
544 544
     {
545
-		switch($sort) {
546
-			case 'lastDate':
547
-				$this->_orderBy = 'last_upload_date';
548
-				break;
549
-			case 'firstDate':
550
-				$this->_orderBy = 'upload_date';
551
-				break;
552
-			case 'title':
553
-				$this->_orderBy = 'title';
554
-				break;
555
-			case 'size':
556
-				$this->_orderBy = 'filesize';
557
-				break;
558
-			case 'author':
559
-				$this->_orderBy = 'author';
560
-				break;
561
-			case 'sender':
562
-				$this->_orderBy = 'uploaderName';
563
-				break;
564
-			default:
565
-				$this->_orderBy = 'last_upload_date';
566
-		}
567
-
568
-		usort($this->receivedWork, array($this, '_cmpWork'));
569
-	}
570
-
571
-	/**
572
-	 * Deletes all the received work of this person
573
-	 */
574
-	function deleteAllReceivedWork()
545
+        switch($sort) {
546
+            case 'lastDate':
547
+                $this->_orderBy = 'last_upload_date';
548
+                break;
549
+            case 'firstDate':
550
+                $this->_orderBy = 'upload_date';
551
+                break;
552
+            case 'title':
553
+                $this->_orderBy = 'title';
554
+                break;
555
+            case 'size':
556
+                $this->_orderBy = 'filesize';
557
+                break;
558
+            case 'author':
559
+                $this->_orderBy = 'author';
560
+                break;
561
+            case 'sender':
562
+                $this->_orderBy = 'uploaderName';
563
+                break;
564
+            default:
565
+                $this->_orderBy = 'last_upload_date';
566
+        }
567
+
568
+        usort($this->receivedWork, array($this, '_cmpWork'));
569
+    }
570
+
571
+    /**
572
+     * Deletes all the received work of this person
573
+     */
574
+    function deleteAllReceivedWork()
575 575
     {
576
-	    $course_id = api_get_course_int_id();
576
+        $course_id = api_get_course_int_id();
577 577
         $dropbox_cnf = getDropboxConf();
578
-		// Delete entries in person table concerning received works
579
-		foreach ($this->receivedWork as $w) {
578
+        // Delete entries in person table concerning received works
579
+        foreach ($this->receivedWork as $w) {
580 580
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
581 581
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
582
-			Database::query($sql);
583
-		}
582
+            Database::query($sql);
583
+        }
584 584
         // Check for unused files
585
-		removeUnusedFiles();
586
-	}
587
-
588
-	/**
589
-	 * Deletes all the received categories and work of this person
590
-	 * @param integer $id
591
-	 */
592
-	function deleteReceivedWorkFolder($id)
585
+        removeUnusedFiles();
586
+    }
587
+
588
+    /**
589
+     * Deletes all the received categories and work of this person
590
+     * @param integer $id
591
+     */
592
+    function deleteReceivedWorkFolder($id)
593 593
     {
594 594
         $dropbox_cnf = getDropboxConf();
595 595
         $course_id = api_get_course_int_id();
596 596
 
597
-		$id = intval($id);
598
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
597
+        $id = intval($id);
598
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
599 599
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
600
-		if (!Database::query($sql)) return false;
601
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
600
+        if (!Database::query($sql)) return false;
601
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
602 602
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
603
-		if (!Database::query($sql)) return false;
604
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
603
+        if (!Database::query($sql)) return false;
604
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
605 605
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
606
-		if (!Database::query($sql)) return false;
607
-		return true;
608
-	}
609
-
610
-	/**
611
-	 * Deletes a received dropbox file of this person with id=$id
612
-	 *
613
-	 * @param integer $id
614
-	 */
615
-	function deleteReceivedWork($id)
606
+        if (!Database::query($sql)) return false;
607
+        return true;
608
+    }
609
+
610
+    /**
611
+     * Deletes a received dropbox file of this person with id=$id
612
+     *
613
+     * @param integer $id
614
+     */
615
+    function deleteReceivedWork($id)
616 616
     {
617
-	    $course_id = api_get_course_int_id();
617
+        $course_id = api_get_course_int_id();
618 618
         $dropbox_cnf = getDropboxConf();
619
-		$id = intval($id);
620
-
621
-		// index check
622
-		$found = false;
623
-		foreach ($this->receivedWork as $w) {
624
-			if ($w->id == $id) {
625
-			   $found = true;
626
-			   break;
627
-			}
628
-		}
629
-
630
-		if (!$found) {
631
-			if (!$this->deleteReceivedWorkFolder($id)) {
632
-				die(get_lang('GeneralError').' (code 216)');
633
-			}
634
-		}
635
-		// Delete entries in person table concerning received works
619
+        $id = intval($id);
620
+
621
+        // index check
622
+        $found = false;
623
+        foreach ($this->receivedWork as $w) {
624
+            if ($w->id == $id) {
625
+                $found = true;
626
+                break;
627
+            }
628
+        }
629
+
630
+        if (!$found) {
631
+            if (!$this->deleteReceivedWorkFolder($id)) {
632
+                die(get_lang('GeneralError').' (code 216)');
633
+            }
634
+        }
635
+        // Delete entries in person table concerning received works
636 636
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
637 637
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
638
-		Database::query($sql);
639
-		removeUnusedFiles();	// Check for unused files
640
-	}
641
-
642
-	/**
643
-	 * Deletes all the sent dropbox files of this person
644
-	 */
645
-	function deleteAllSentWork()
638
+        Database::query($sql);
639
+        removeUnusedFiles();	// Check for unused files
640
+    }
641
+
642
+    /**
643
+     * Deletes all the sent dropbox files of this person
644
+     */
645
+    function deleteAllSentWork()
646 646
     {
647
-	    $course_id = api_get_course_int_id();
647
+        $course_id = api_get_course_int_id();
648 648
         $dropbox_cnf = getDropboxConf();
649
-		//delete entries in person table concerning sent works
650
-		foreach ($this->sentWork as $w) {
649
+        //delete entries in person table concerning sent works
650
+        foreach ($this->sentWork as $w) {
651 651
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
652 652
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
653
-			Database::query($sql);
654
-			removeMoreIfMailing($w->id);
655
-		}
656
-		removeUnusedFiles();	// Check for unused files
657
-	}
658
-
659
-	/**
660
-	 * Deletes a sent dropbox file of this person with id=$id
661
-	 *
662
-	 * @param unknown_type $id
663
-	 */
664
-	function deleteSentWork($id)
653
+            Database::query($sql);
654
+            removeMoreIfMailing($w->id);
655
+        }
656
+        removeUnusedFiles();	// Check for unused files
657
+    }
658
+
659
+    /**
660
+     * Deletes a sent dropbox file of this person with id=$id
661
+     *
662
+     * @param unknown_type $id
663
+     */
664
+    function deleteSentWork($id)
665 665
     {
666
-	    $course_id = api_get_course_int_id();
666
+        $course_id = api_get_course_int_id();
667 667
         $dropbox_cnf = getDropboxConf();
668 668
 
669
-		$id = intval($id);
670
-
671
-		// index check
672
-		$found = false;
673
-		foreach ($this->sentWork as $w) {
674
-			if ($w->id == $id) {
675
-			   $found = true;
676
-			   break;
677
-			}
678
-		}
679
-		if (!$found) {
680
-			if (!$this->deleteReceivedWorkFolder($id)) {
681
-				die(get_lang('GeneralError').' (code 219)');
682
-			}
683
-		}
684
-		//$file_id = $this->sentWork[$index]->id;
685
-		// Delete entries in person table concerning sent works
669
+        $id = intval($id);
670
+
671
+        // index check
672
+        $found = false;
673
+        foreach ($this->sentWork as $w) {
674
+            if ($w->id == $id) {
675
+                $found = true;
676
+                break;
677
+            }
678
+        }
679
+        if (!$found) {
680
+            if (!$this->deleteReceivedWorkFolder($id)) {
681
+                die(get_lang('GeneralError').' (code 219)');
682
+            }
683
+        }
684
+        //$file_id = $this->sentWork[$index]->id;
685
+        // Delete entries in person table concerning sent works
686 686
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
687 687
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
688
-		Database::query($sql);
689
-		removeMoreIfMailing($id);
690
-		removeUnusedFiles();	// Check for unused files
691
-	}
692
-
693
-	/**
694
-	 * Updates feedback for received work of this person with id=$id
695
-	 *
696
-	 * @param string $id
697
-	 * @param string $text
698
-	 */
699
-	function updateFeedback($id, $text)
688
+        Database::query($sql);
689
+        removeMoreIfMailing($id);
690
+        removeUnusedFiles();	// Check for unused files
691
+    }
692
+
693
+    /**
694
+     * Updates feedback for received work of this person with id=$id
695
+     *
696
+     * @param string $id
697
+     * @param string $text
698
+     */
699
+    function updateFeedback($id, $text)
700 700
     {
701
-	    $course_id = api_get_course_int_id();
701
+        $course_id = api_get_course_int_id();
702 702
         $_course = api_get_course_info();
703 703
         $dropbox_cnf = getDropboxConf();
704 704
 
705
-		$id = intval($id);
706
-
707
-		// index check
708
-		$found = false;
709
-		$wi = -1;
710
-		foreach ($this->receivedWork as $w) {
711
-			$wi++;
712
-			if ($w->id == $id){
713
-			   $found = true;
714
-			   break;
715
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
716
-		}
717
-		if (!$found) {
718
-			die(get_lang('GeneralError').' (code 221)');
719
-		}
720
-
721
-		$feedback_date = api_get_utc_datetime();
722
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
723
-		$this->receivedWork[$wi]->feedback = $text;
705
+        $id = intval($id);
706
+
707
+        // index check
708
+        $found = false;
709
+        $wi = -1;
710
+        foreach ($this->receivedWork as $w) {
711
+            $wi++;
712
+            if ($w->id == $id){
713
+                $found = true;
714
+                break;
715
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
716
+        }
717
+        if (!$found) {
718
+            die(get_lang('GeneralError').' (code 221)');
719
+        }
720
+
721
+        $feedback_date = api_get_utc_datetime();
722
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
723
+        $this->receivedWork[$wi]->feedback = $text;
724 724
 
725 725
         $params = [
726 726
             'feedback_date' => $feedback_date,
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
             ]
739 739
         );
740 740
 
741
-		// Update item_property table
741
+        // Update item_property table
742 742
 
743
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
744
-		    $ownerid = getUserOwningThisMailing($ownerid);
745
-		}
743
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
744
+            $ownerid = getUserOwningThisMailing($ownerid);
745
+        }
746 746
         api_item_property_update(
747 747
             $_course,
748 748
             TOOL_DROPBOX,
@@ -753,31 +753,31 @@  discard block
 block discarded – undo
753 753
             $ownerid
754 754
         );
755 755
 
756
-	}
756
+    }
757 757
 
758
-	/**
759
-	 * Filter the received work
760
-	 * @param string $type
761
-	 * @param string $value
762
-	 */
763
-	function filter_received_work($type, $value)
758
+    /**
759
+     * Filter the received work
760
+     * @param string $type
761
+     * @param string $value
762
+     */
763
+    function filter_received_work($type, $value)
764 764
     {
765 765
         $dropbox_cnf = getDropboxConf();
766
-    	$new_received_work = array();
767
-		foreach ($this->receivedWork as $work) {
768
-			switch ($type) {
769
-				case 'uploader_id':
770
-					if ($work->uploader_id == $value ||
771
-						($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
766
+        $new_received_work = array();
767
+        foreach ($this->receivedWork as $work) {
768
+            switch ($type) {
769
+                case 'uploader_id':
770
+                    if ($work->uploader_id == $value ||
771
+                        ($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
772 772
                         getUserOwningThisMailing($work->uploader_id) == $value)
773 773
                     ) {
774
-						$new_received_work[] = $work;
775
-					}
776
-					break;
777
-				default:
778
-					$new_received_work[] = $work;
779
-			}
780
-		}
781
-		$this->receivedWork = $new_received_work;
782
-	}
774
+                        $new_received_work[] = $work;
775
+                    }
776
+                    break;
777
+                default:
778
+                    $new_received_work[] = $work;
779
+            }
780
+        }
781
+        $this->receivedWork = $new_received_work;
782
+    }
783 783
 }
Please login to merge, or discard this patch.
main/dropbox/dropbox_submit.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
         $thisIsAMailing = false;
34 34
         $thisIsJustUpload = false;
35 35
 
36
-	    foreach ($_POST['recipients'] as $rec) {
36
+        foreach ($_POST['recipients'] as $rec) {
37 37
             if ($rec == 'mailing') {
38
-	            $thisIsAMailing = true;
38
+                $thisIsAMailing = true;
39 39
             } elseif ($rec == 'upload') {
40
-	            $thisIsJustUpload = true;
40
+                $thisIsJustUpload = true;
41 41
             } elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) {
42
-	        	echo '401';
43
-	        	die(get_lang('BadFormData').' (code 401)');
44
-	        } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
45
-	        	echo '402';
46
-	        	die(get_lang('BadFormData').' (code 402)');
47
-	        }
42
+                echo '401';
43
+                die(get_lang('BadFormData').' (code 401)');
44
+            } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
45
+                echo '402';
46
+                die(get_lang('BadFormData').' (code 402)');
47
+            }
48 48
         }
49 49
 
50
-		// we are doing a mailing but an additional recipient is selected
50
+        // we are doing a mailing but an additional recipient is selected
51 51
         if ($thisIsAMailing && ( count($_POST['recipients']) != 1)) {
52 52
             $error = true;
53 53
             $errormsg = get_lang('MailingSelectNoOther');
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
         }
63 63
     }
64 64
 
65
-	//check if $_POST['cb_overwrite'] is true or false
66
-	$dropbox_overwrite = false;
67
-	if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) {
68
-		$dropbox_overwrite = true;
69
-	}
65
+    //check if $_POST['cb_overwrite'] is true or false
66
+    $dropbox_overwrite = false;
67
+    if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) {
68
+        $dropbox_overwrite = true;
69
+    }
70 70
 
71 71
     /**
72 72
      * FORM SUBMIT : UPLOAD NEW FILE
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
                     }
169 169
                 }
170 170
 
171
-				// After uploading the file, create the db entries
171
+                // After uploading the file, create the db entries
172 172
 
173
-	        	if (!$error) {
174
-		            @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename)
175
-		            	or die(get_lang('UploadError').' (code 407)');
176
-		            new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
177
-	        	}
173
+                if (!$error) {
174
+                    @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename)
175
+                        or die(get_lang('UploadError').' (code 407)');
176
+                    new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
177
+                }
178 178
             }
179 179
         }
180 180
     } //end if(!$error)
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
      * SUBMIT FORM RESULTMESSAGE
184 184
      */
185 185
     if (!$error) {
186
-		$return_message = get_lang('FileUploadSucces');
186
+        $return_message = get_lang('FileUploadSucces');
187 187
     } else {
188
-		$return_message = $errormsg;
188
+        $return_message = $errormsg;
189 189
     }
190 190
 }
191 191
 
@@ -199,25 +199,25 @@  discard block
 block discarded – undo
199 199
  */
200 200
 if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
201 201
          || isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) {
202
-	if ($_GET['mailing']) {
203
-		getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408');
204
-		$dropbox_person = new Dropbox_Person($_GET['mailing'], $is_courseAdmin, $is_courseTutor);
205
-	} else {
206
-	    $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
202
+    if ($_GET['mailing']) {
203
+        getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408');
204
+        $dropbox_person = new Dropbox_Person($_GET['mailing'], $is_courseAdmin, $is_courseTutor);
205
+    } else {
206
+        $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
207 207
     }
208 208
 
209
-	if (isset($_SESSION['sentOrder'])) {
210
-		$dropbox_person->orderSentWork($_SESSION['sentOrder']);
211
-	}
212
-	if (isset($_SESSION['receivedOrder'])) {
213
-		$dropbox_person->orderReceivedWork($_SESSION['receivedOrder']);
214
-	}
209
+    if (isset($_SESSION['sentOrder'])) {
210
+        $dropbox_person->orderSentWork($_SESSION['sentOrder']);
211
+    }
212
+    if (isset($_SESSION['receivedOrder'])) {
213
+        $dropbox_person->orderReceivedWork($_SESSION['receivedOrder']);
214
+    }
215 215
 
216
-	/*if (!$dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) {
216
+    /*if (!$dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) {
217 217
 	    die(get_lang('GeneralError').' (code 408)');
218 218
 	}*/
219 219
 
220
-	$tellUser = get_lang('FileDeleted');
220
+    $tellUser = get_lang('FileDeleted');
221 221
 
222 222
     if (isset($_GET['deleteReceived'])) {
223 223
         if ($_GET['deleteReceived'] == 'all') {
@@ -236,20 +236,20 @@  discard block
 block discarded – undo
236 236
             die(get_lang('GeneralError').' (code 410)');
237 237
         }
238 238
     } elseif (isset($_GET['showFeedback'])) {
239
-		$w = new Dropbox_SentWork($id = $_GET['showFeedback']);
239
+        $w = new Dropbox_SentWork($id = $_GET['showFeedback']);
240 240
 
241
-		if ($w->uploader_id != $_user['user_id']) {
242
-		    getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411');
243
-		}
241
+        if ($w->uploader_id != $_user['user_id']) {
242
+            getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411');
243
+        }
244 244
 
245
-    	foreach ($w -> recipients as $r) {
246
-    		if (($fb = $r['feedback'])) {
247
-    			$fbarray[$r['feedback_date'].$r['name']] = $r['name'].' '.get_lang('SentOn', '').' '.$r['feedback_date'].":\n".$fb;
248
-    		}
249
-    	}
245
+        foreach ($w -> recipients as $r) {
246
+            if (($fb = $r['feedback'])) {
247
+                $fbarray[$r['feedback_date'].$r['name']] = $r['name'].' '.get_lang('SentOn', '').' '.$r['feedback_date'].":\n".$fb;
248
+            }
249
+        }
250 250
 
251
-    	if ($fbarray) {
252
-        	krsort($fbarray);
251
+        if ($fbarray) {
252
+            krsort($fbarray);
253 253
             echo '<textarea class="dropbox_feedbacks">',
254 254
                     htmlspecialchars(implode("\n\n", $fbarray), ENT_QUOTES, api_get_system_encoding()), '</textarea>', "\n";
255 255
         } else {
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
     } else { // if ( isset( $_GET['editFeedback'])) {
262 262
         $id = $_GET['editFeedback'];
263 263
         $found = false;
264
-		foreach ($dropbox_person->receivedWork as $w) {
265
-			if ($w->id == $id) {
266
-			   $found = true;
267
-			   break;
268
-			}
269
-		}
270
-		if (!$found) die(get_lang('GeneralError').' (code 415)');
264
+        foreach ($dropbox_person->receivedWork as $w) {
265
+            if ($w->id == $id) {
266
+                $found = true;
267
+                break;
268
+            }
269
+        }
270
+        if (!$found) die(get_lang('GeneralError').' (code 415)');
271 271
 
272 272
         echo '<form method="post" action="index.php">', "\n",
273 273
             '<input type="hidden" name="feedbackid" value="',
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,9 @@
 block discarded – undo
267 267
 			   break;
268 268
 			}
269 269
 		}
270
-		if (!$found) die(get_lang('GeneralError').' (code 415)');
270
+		if (!$found) {
271
+		    die(get_lang('GeneralError').' (code 415)');
272
+		}
271 273
 
272 274
         echo '<form method="post" action="index.php">', "\n",
273 275
             '<input type="hidden" name="feedbackid" value="',
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
      */
24 24
 
25 25
     // the author or description field is empty
26
-    if (!isset($_POST['authors']) || !isset( $_POST['description'])) {
26
+    if (!isset($_POST['authors']) || !isset($_POST['description'])) {
27 27
         $error = true;
28 28
         $errormsg = get_lang('BadFormData');
29
-    } elseif (!isset( $_POST['recipients']) || count( $_POST['recipients']) <= 0) {
29
+    } elseif (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
30 30
         $error = true;
31 31
         $errormsg = get_lang('NoUserSelected');
32 32
     } else {
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
 		// we are doing a mailing but an additional recipient is selected
51
-        if ($thisIsAMailing && ( count($_POST['recipients']) != 1)) {
51
+        if ($thisIsAMailing && (count($_POST['recipients']) != 1)) {
52 52
             $error = true;
53 53
             $errormsg = get_lang('MailingSelectNoOther');
54 54
         }
55 55
         // we are doing a just upload but an additional recipient is selected.
56
-        elseif ( $thisIsJustUpload && ( count($_POST['recipients']) != 1)) {
56
+        elseif ($thisIsJustUpload && (count($_POST['recipients']) != 1)) {
57 57
             $error = true;
58 58
             $errormsg = get_lang('MailingJustUploadSelectNoOther');
59 59
         } elseif (empty($_FILES['file']['name'])) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                     }
126 126
                 } else {
127 127
                     // rename file to login_filename_uniqueId format
128
-                    $dropbox_filename = getLoginFromId( $_user['user_id']) . '_' . $dropbox_filename . '_'.uniqid('');
128
+                    $dropbox_filename = getLoginFromId($_user['user_id']).'_'.$dropbox_filename.'_'.uniqid('');
129 129
                 }
130 130
 
131 131
                 if (!is_dir(dropbox_cnf('sysPath'))) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                         $newWorkRecipients = dropbox_cnf('mailingIdBase');
148 148
                     } else {
149 149
                         $error = true;
150
-                        $errormsg = $dropbox_title . ': ' . get_lang('MailingWrongZipfile');
150
+                        $errormsg = $dropbox_title.': '.get_lang('MailingWrongZipfile');
151 151
                     }
152 152
                 } elseif ($thisIsJustUpload) {
153 153
                     $newWorkRecipients = array();
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				// After uploading the file, create the db entries
172 172
 
173 173
 	        	if (!$error) {
174
-		            @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename)
174
+		            @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath').'/'.$dropbox_filename)
175 175
 		            	or die(get_lang('UploadError').' (code 407)');
176 176
 		            new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
177 177
 	        	}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
  * - EDIT FEEDBACK
199 199
  */
200 200
 if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
201
-         || isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) {
201
+         || isset($_GET['showFeedback']) || isset($_GET['editFeedback'])) {
202 202
 	if ($_GET['mailing']) {
203 203
 		getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408');
204 204
 		$dropbox_person = new Dropbox_Person($_GET['mailing'], $is_courseAdmin, $is_courseTutor);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         if ($_GET['deleteReceived'] == 'all') {
224 224
             $dropbox_person->deleteAllReceivedWork();
225 225
         } elseif (is_numeric($_GET['deleteReceived'])) {
226
-            $dropbox_person->deleteReceivedWork( $_GET['deleteReceived']);
226
+            $dropbox_person->deleteReceivedWork($_GET['deleteReceived']);
227 227
         } else {
228 228
             die(get_lang('GeneralError').' (code 409)');
229 229
         }
Please login to merge, or discard this patch.
main/dropbox/dropbox_config.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
  */
19 19
 $dropbox_cnf['courseId'] = $_cid;
20 20
 //path to dropbox subdir in course containing the uploaded files
21
-$dropbox_cnf['sysPath'] = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox';
22
-$dropbox_cnf['webPath'] = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/dropbox';
21
+$dropbox_cnf['sysPath'] = api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox';
22
+$dropbox_cnf['webPath'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/dropbox';
23 23
 
24 24
 //file size limit as imposed by the platform admin (see Chamilo Config Settings on the platform administration section)
25 25
 $dropbox_cnf['maxFilesize'] = api_get_setting('dropbox_max_filesize');
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 // false = no mailing functionality
35 35
 $dropbox_cnf['allowMailing'] = api_string_2_boolean(api_get_setting('dropbox_allow_mailing'));
36
-$dropbox_cnf['mailingIdBase'] = 10000000;  // bigger than any user_id,
36
+$dropbox_cnf['mailingIdBase'] = 10000000; // bigger than any user_id,
37 37
 // allowing enough space for pseudo_ids as uploader_id, dest_user_id, user_id:
38 38
 // mailing pseudo_id = dropbox_cnf('mailingIdBase') + mailing id
39 39
 $dropbox_cnf['mailingZipRegexp'] = '/^(.*)(STUDENTID|USERID|LOGINNAME)(.*)\.ZIP$/i';
Please login to merge, or discard this patch.
main/dropbox/dropbox_functions.inc.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@
 block discarded – undo
83 83
     if (strstr($_POST['action'], 'move_')) {
84 84
         // check move_received_n or move_sent_n command
85 85
         if (strstr($_POST['action'], 'received')) {
86
-              $part = 'received';
87
-              $to_cat_id = str_replace('move_received_', '', $_POST['action']);
86
+                $part = 'received';
87
+                $to_cat_id = str_replace('move_received_', '', $_POST['action']);
88 88
         } else {
89
-              $part = 'sent';
90
-              $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
89
+                $part = 'sent';
90
+                $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
91 91
         }
92 92
 
93 93
         foreach ($checked_file_ids as $value) {
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     // STEP 2: at least one file has to be selected. If not we return an error message
43 43
     $ids = isset($_GET['id']) ? $_GET['id'] : array();
44
-    if (count($ids)>0) {
44
+    if (count($ids) > 0) {
45 45
         $checked_file_ids = $_POST['id'];
46 46
     } else {
47 47
         foreach ($_POST as $key => $value) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     }
134 134
 
135 135
     $cat = get_dropbox_category($id);
136
-    if (count($cat)==0) {
136
+    if (count($cat) == 0) {
137 137
         return false;
138 138
     }
139 139
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             WHERE c_id = $course_id AND cat_id='".intval($id)."'";
167 167
     $result = Database::query($sql);
168 168
 
169
-    while($row = Database::fetch_array($result)) {
169
+    while ($row = Database::fetch_array($result)) {
170 170
         $dropboxfile = new Dropbox_Person($user_id, $is_courseAdmin, $is_courseTutor);
171 171
         if ($action == 'deletereceivedcategory') {
172 172
             $dropboxfile->deleteReceivedWork($row[$id_field]);
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
                 $full_name = $userInfo['complete_name'].$groupNameListToString;
659 659
                 $current_user_id = $current_user['user_id'];
660
-                $options['user_' . $current_user_id] = $full_name;
660
+                $options['user_'.$current_user_id] = $full_name;
661 661
             }
662 662
         }
663 663
     }
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 
707 707
     $mailingId = $id - dropbox_cnf('mailingIdBase');
708 708
     if ($mailingId > 0) {
709
-        return get_lang('MailingAsUsername', '') . $mailingId;
709
+        return get_lang('MailingAsUsername', '').$mailingId;
710 710
     }
711 711
     $id = intval($id);
712 712
     $sql = "SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ', lastname)" : "CONCAT(lastname,' ', firstname)")." AS name
713
-            FROM " . $dropbox_cnf['tbl_user'] . "
713
+            FROM " . $dropbox_cnf['tbl_user']."
714 714
             WHERE user_id='$id'";
715 715
     $result = Database::query($sql);
716 716
     $res = Database::fetch_array($result);
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 {
731 731
     $id = intval($id);
732 732
     $sql = "SELECT username
733
-            FROM " . dropbox_cnf('tbl_user') . "
733
+            FROM " . dropbox_cnf('tbl_user')."
734 734
             WHERE user_id='$id'";
735 735
     $result = Database::query($sql);
736 736
     $res = Database::fetch_array($result);
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 
763 763
     // select all files that aren't referenced anymore
764 764
     $sql = "SELECT DISTINCT f.id, f.filename
765
-            FROM " . dropbox_cnf('tbl_file') . " f
766
-            LEFT JOIN " . dropbox_cnf('tbl_person') . " p
765
+            FROM " . dropbox_cnf('tbl_file')." f
766
+            LEFT JOIN " . dropbox_cnf('tbl_person')." p
767 767
             ON (f.id = p.file_id)
768 768
             WHERE p.user_id IS NULL AND
769 769
                   f.c_id = $course_id
@@ -771,14 +771,14 @@  discard block
 block discarded – undo
771 771
     $result = Database::query($sql);
772 772
     while ($res = Database::fetch_array($result)) {
773 773
         //delete the selected files from the post and file tables
774
-        $sql = "DELETE FROM " . dropbox_cnf('tbl_post') . "
775
-                WHERE c_id = $course_id AND file_id = '" . $res['id'] . "'";
774
+        $sql = "DELETE FROM ".dropbox_cnf('tbl_post')."
775
+                WHERE c_id = $course_id AND file_id = '".$res['id']."'";
776 776
         Database::query($sql);
777
-        $sql = "DELETE FROM " . dropbox_cnf('tbl_file') . "
778
-                WHERE c_id = $course_id AND id ='" . $res['id'] . "'";
777
+        $sql = "DELETE FROM ".dropbox_cnf('tbl_file')."
778
+                WHERE c_id = $course_id AND id ='".$res['id']."'";
779 779
         Database::query($sql);
780 780
         //delete file from server
781
-        @unlink( dropbox_cnf('sysPath') . '/' . $res['filename']);
781
+        @unlink(dropbox_cnf('sysPath').'/'.$res['filename']);
782 782
     }
783 783
 }
784 784
 
@@ -801,11 +801,11 @@  discard block
 block discarded – undo
801 801
 
802 802
     $mailingPseudoId = intval($mailingPseudoId);
803 803
     $sql = "SELECT f.uploader_id
804
-            FROM " . $dropbox_cnf['tbl_file'] . " f
805
-            LEFT JOIN " . $dropbox_cnf['tbl_post'] . " p
804
+            FROM " . $dropbox_cnf['tbl_file']." f
805
+            LEFT JOIN " . $dropbox_cnf['tbl_post']." p
806 806
             ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
807 807
             WHERE
808
-                p.dest_user_id = '" . $mailingPseudoId . "' AND
808
+                p.dest_user_id = '".$mailingPseudoId."' AND
809 809
                 p.c_id = $course_id
810 810
             ";
811 811
     $result = Database::query($sql);
@@ -832,20 +832,20 @@  discard block
 block discarded – undo
832 832
     //    for all content files, replace mailingPseudoId by owner as uploader
833 833
     $file_id = intval($file_id);
834 834
     $sql = "SELECT p.dest_user_id
835
-            FROM " . $dropbox_cnf['tbl_post'] . " p
836
-            WHERE c_id = $course_id AND p.file_id = '" . $file_id . "'";
835
+            FROM " . $dropbox_cnf['tbl_post']." p
836
+            WHERE c_id = $course_id AND p.file_id = '".$file_id."'";
837 837
     $result = Database::query($sql);
838 838
 
839 839
     if ($res = Database::fetch_array($result)) {
840 840
         $mailingPseudoId = $res['dest_user_id'];
841 841
         if ($mailingPseudoId > dropbox_cnf('mailingIdBase')) {
842
-            $sql = "DELETE FROM " . dropbox_cnf('tbl_person') . "
843
-                    WHERE c_id = $course_id AND user_id='" . $mailingPseudoId . "'";
842
+            $sql = "DELETE FROM ".dropbox_cnf('tbl_person')."
843
+                    WHERE c_id = $course_id AND user_id='".$mailingPseudoId."'";
844 844
             Database::query($sql);
845 845
 
846
-            $sql = "UPDATE " . dropbox_cnf('tbl_file') ."
847
-                    SET uploader_id='" . api_get_user_id() . "'
848
-                    WHERE c_id = $course_id AND uploader_id='" . $mailingPseudoId . "'";
846
+            $sql = "UPDATE ".dropbox_cnf('tbl_file')."
847
+                    SET uploader_id='" . api_get_user_id()."'
848
+                    WHERE c_id = $course_id AND uploader_id='".$mailingPseudoId."'";
849 849
             Database::query($sql);
850 850
         }
851 851
     }
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
             }
985 985
         }
986 986
     } else {  // rename file to login_filename_uniqueId format
987
-        $dropbox_filename = getLoginFromId($_user['user_id']) . "_" . $dropbox_filename . "_".uniqid('');
987
+        $dropbox_filename = getLoginFromId($_user['user_id'])."_".$dropbox_filename."_".uniqid('');
988 988
     }
989 989
 
990 990
     // creating the array that contains all the users who will receive the file
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
         }
1003 1003
     }
1004 1004
 
1005
-    @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename);
1005
+    @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath').'/'.$dropbox_filename);
1006 1006
 
1007 1007
     $b_send_mail = api_get_course_setting('email_alert_on_new_doc_dropbox');
1008 1008
 
@@ -1023,14 +1023,14 @@  discard block
 block discarded – undo
1023 1023
                 ),
1024 1024
                 $recipent_temp['email'],
1025 1025
                 get_lang('NewDropboxFileUploaded'),
1026
-                get_lang('NewDropboxFileUploadedContent').' <a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?' . api_get_cidreq() . '">'.get_lang('SeeFile').'</a>'.
1026
+                get_lang('NewDropboxFileUploadedContent').' <a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq().'">'.get_lang('SeeFile').'</a>'.
1027 1027
                 "\n\n".
1028 1028
                 api_get_person_name(
1029 1029
                     $_user['firstName'],
1030 1030
                     $_user['lastName'],
1031 1031
                     null,
1032 1032
                     PERSON_NAME_EMAIL_ADDRESS
1033
-                )."\n".  get_lang('Email') ." : ".$_user['mail'],
1033
+                )."\n".get_lang('Email')." : ".$_user['mail'],
1034 1034
                 api_get_person_name(
1035 1035
                     $_user['firstName'],
1036 1036
                     $_user['lastName'],
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
         // Adding the content.
1309 1309
         $return .= "\n<tr>";
1310 1310
         foreach ($column as $column_key => $column_value) {
1311
-            if (!in_array($column_value,$dont_show_columns)) {
1311
+            if (!in_array($column_value, $dont_show_columns)) {
1312 1312
                 $return .= "\n\t<td>";
1313 1313
                 if (in_array($column_value, $make_link)) {
1314 1314
                     $return .= '<a href="'.$value[$column_value].'">'.$value[$column_value].'</a>';
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
             WHERE c_id = $course_id GROUP BY file_id";
1342 1342
     $result = Database::query($sql);
1343 1343
     $return = array();
1344
-    while ($row=Database::fetch_array($result)) {
1344
+    while ($row = Database::fetch_array($result)) {
1345 1345
         $return[$row['file_id']] = $row['total'];
1346 1346
     }
1347 1347
     return $return;
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -734,7 +734,9 @@  discard block
 block discarded – undo
734 734
             WHERE user_id='$id'";
735 735
     $result = Database::query($sql);
736 736
     $res = Database::fetch_array($result);
737
-    if (!$res) return false;
737
+    if (!$res) {
738
+        return false;
739
+    }
738 740
 
739 741
     return stripslashes($res['username']);
740 742
 }
@@ -810,10 +812,15 @@  discard block
 block discarded – undo
810 812
             ";
811 813
     $result = Database::query($sql);
812 814
 
813
-    if (!($res = Database::fetch_array($result)))
814
-        die(get_lang('GeneralError').' (code 901)');
815
-    if ($owner == 0) return $res['uploader_id'];
816
-    if ($res['uploader_id'] == $owner) return true;
815
+    if (!($res = Database::fetch_array($result))) {
816
+            die(get_lang('GeneralError').' (code 901)');
817
+    }
818
+    if ($owner == 0) {
819
+        return $res['uploader_id'];
820
+    }
821
+    if ($res['uploader_id'] == $owner) {
822
+        return true;
823
+    }
817 824
     die(get_lang('GeneralError').' (code '.$or_die.')');
818 825
 }
819 826
 
Please login to merge, or discard this patch.
main/course_progress/thematic_controller.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -390,7 +390,7 @@
 block discarded – undo
390 390
      *
391 391
      */
392 392
     public function thematic_advance($action)
393
-     {
393
+        {
394 394
         $thematic = new Thematic();
395 395
         $attendance = new Attendance();
396 396
         $data = array();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -201,20 +201,20 @@  discard block
 block discarded – undo
201 201
                         $plan_html = null;
202 202
                         if (!empty($data)) {
203 203
                             foreach ($data as $plan) {
204
-                                $plan_html .= '<strong>' . $plan['title'] . '</strong><br /> ' . $plan['description'] . '<br />';
204
+                                $plan_html .= '<strong>'.$plan['title'].'</strong><br /> '.$plan['description'].'<br />';
205 205
                             }
206 206
                         }
207 207
                         $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']);
208 208
                         $advance_html = null;
209 209
                         if (!empty($data)) {
210 210
                             foreach ($data as $advance) {
211
-                                $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG) . ' ('.$advance['duration'].' '.get_lang('HourShort').')<br />'.$advance['content'].'<br />';
211
+                                $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG).' ('.$advance['duration'].' '.get_lang('HourShort').')<br />'.$advance['content'].'<br />';
212 212
                             }
213 213
                         }
214 214
                         $table[] = array($theme['title'], $plan_html, $advance_html);
215 215
                     }
216 216
                     $params = array(
217
-                        'filename' => get_lang('Thematic') . '-' . api_get_local_time(),
217
+                        'filename' => get_lang('Thematic').'-'.api_get_local_time(),
218 218
                         'pdf_title' => get_lang('Thematic'),
219 219
                         'add_signatures' => true,
220 220
                         'format' => 'A4-L',
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
                             unset($_SESSION['thematic_plan_token']);
312 312
                             $data['message'] = 'ok';
313 313
 
314
-                            $saveRedirect = api_get_path(WEB_PATH) . 'main/course_progress/index.php?';
315
-                            $saveRedirect.= api_get_cidreq() . '&';
316
-                            $saveRedirect.= 'thematic_plan_save_message=ok';
314
+                            $saveRedirect = api_get_path(WEB_PATH).'main/course_progress/index.php?';
315
+                            $saveRedirect .= api_get_cidreq().'&';
316
+                            $saveRedirect .= 'thematic_plan_save_message=ok';
317 317
 
318 318
                             header("Location: $saveRedirect");
319 319
                             exit;
Please login to merge, or discard this patch.
main/course_progress/thematic_plan.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@
 block discarded – undo
47 47
             $form->addElement('hidden', 'description_type['.$id.']', $id);
48 48
             $form->addText('title['.$id.']', get_lang('Title'), false, array('size'=>'50'));
49 49
             $form->addHtmlEditor(
50
-               'description['.$id.']',
51
-               get_lang('Description'),
52
-               false,
53
-               false,
54
-               array(
55
-                   'ToolbarStartExpanded' => 'false',
56
-                   'ToolbarSet' => 'TrainingDescription',
57
-                   'Height' => '150'
58
-               )
50
+                'description['.$id.']',
51
+                get_lang('Description'),
52
+                false,
53
+                false,
54
+                array(
55
+                    'ToolbarStartExpanded' => 'false',
56
+                    'ToolbarSet' => 'TrainingDescription',
57
+                    'Height' => '150'
58
+                )
59 59
             );
60 60
 
61 61
             if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,21 +10,21 @@  discard block
 block discarded – undo
10 10
 // actions menu
11 11
 $new_thematic_plan_data = array();
12 12
 if (!empty($thematic_plan_data))
13
-foreach($thematic_plan_data as $thematic_item) {
13
+foreach ($thematic_plan_data as $thematic_item) {
14 14
     $thematic_simple_list[] = $thematic_item['description_type'];
15 15
     $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
16 16
 }
17 17
 
18 18
 $new_id = ADD_THEMATIC_PLAN;
19 19
 if (!empty($thematic_simple_list))
20
-foreach($thematic_simple_list as $item) {
20
+foreach ($thematic_simple_list as $item) {
21 21
     if ($item >= ADD_THEMATIC_PLAN) {
22 22
         $new_id = $item + 1;
23 23
         $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
24 24
     }
25 25
 }
26 26
 
27
-$i=1;
27
+$i = 1;
28 28
 
29 29
 echo Display::tag('h2', $thematic_data['title']);
30 30
 echo $thematic_data['content'];
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
                 $thematic_plan = null;
67 67
             } else {
68 68
                 $thematic_plan = null;
69
-                $default['title['.$id.']']       = $title;
70
-                $default['description['.$id.']']= '';
69
+                $default['title['.$id.']'] = $title;
70
+                $default['description['.$id.']'] = '';
71 71
             }
72 72
             $form->setDefaults($default);
73 73
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $header_form = $default_thematic_plan_title[$description_type];
81 81
     }
82 82
     if (!$error) {
83
-        $token = md5(uniqid(rand(),TRUE));
83
+        $token = md5(uniqid(rand(), TRUE));
84 84
         $_SESSION['thematic_plan_token'] = $token;
85 85
     }
86 86
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
     // error messages
137 137
     if ($error) {
138
-        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
138
+        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
139 139
     }
140 140
     $form->display();
141 141
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,17 +9,19 @@
 block discarded – undo
9 9
 
10 10
 // actions menu
11 11
 $new_thematic_plan_data = array();
12
-if (!empty($thematic_plan_data))
13
-foreach($thematic_plan_data as $thematic_item) {
12
+if (!empty($thematic_plan_data)) {
13
+    foreach($thematic_plan_data as $thematic_item) {
14 14
     $thematic_simple_list[] = $thematic_item['description_type'];
15
+}
15 16
     $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
16 17
 }
17 18
 
18 19
 $new_id = ADD_THEMATIC_PLAN;
19
-if (!empty($thematic_simple_list))
20
-foreach($thematic_simple_list as $item) {
20
+if (!empty($thematic_simple_list)) {
21
+    foreach($thematic_simple_list as $item) {
21 22
     if ($item >= ADD_THEMATIC_PLAN) {
22 23
         $new_id = $item + 1;
24
+}
23 25
         $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
24 26
     }
25 27
 }
Please login to merge, or discard this patch.
main/course_progress/thematic.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,25 +23,25 @@  discard block
 block discarded – undo
23 23
         case 'thematic_add' :
24 24
         case 'thematic_import_select' :
25 25
             echo '<a href="index.php?'.api_get_cidreq().'">'.
26
-                Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'',ICON_SIZE_MEDIUM).'</a>';
26
+                Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ThematicDetails'), '', ICON_SIZE_MEDIUM).'</a>';
27 27
             break;
28 28
         case 'thematic_list' :
29 29
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
30
-                Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
30
+                Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
31 31
             break;
32 32
         case 'thematic_details' :
33 33
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
34
-                Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
34
+                Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
35 35
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.
36
-                Display::return_icon('import_csv.png',get_lang('ImportThematic'),'',ICON_SIZE_MEDIUM).'</a>';
36
+                Display::return_icon('import_csv.png', get_lang('ImportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
37 37
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export'.$url_token.'">'.
38
-                Display::return_icon('export_csv.png',get_lang('ExportThematic'),'', ICON_SIZE_MEDIUM).'</a>';
38
+                Display::return_icon('export_csv.png', get_lang('ExportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
39 39
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'.
40
-                Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>';
40
+                Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
41 41
             break;
42 42
         default :
43 43
             echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
44
-                Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
44
+                Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
45 45
     }
46 46
     echo '</div>';
47 47
 }
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
     $parameters['action'] = $action;
58 58
     $table->set_additional_parameters($parameters);
59 59
     $table->set_header(0, '', false, array('style'=>'width:20px;'));
60
-    $table->set_header(1, get_lang('Title'), false );
60
+    $table->set_header(1, get_lang('Title'), false);
61 61
     if (api_is_allowed_to_edit(null, true)) {
62
-        $table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;'));
63
-        $table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
62
+        $table->set_header(2, get_lang('Actions'), false, array('style'=>'text-align:center;width:40%;'));
63
+        $table->set_form_actions(array('thematic_delete_select' => get_lang('DeleteAllThematics')));
64 64
     }
65 65
     $table->display();
66 66
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
     if (isset($last_id) && $last_id) {
74 74
         $link_to_thematic_plan = '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$last_id.'">'.
75
-            Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
75
+            Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style'=>'vertical-align:middle;float:none;'), ICON_SIZE_SMALL).'</a>';
76 76
         $link_to_thematic_advance = '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$last_id.'">'.
77
-            Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
77
+            Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style'=>'vertical-align:middle;float:none;'), ICON_SIZE_SMALL).'</a>';
78 78
         Display::display_confirmation_message(
79
-            get_lang('ThematicSectionHasBeenCreatedSuccessfull').'<br />'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'),$link_to_thematic_plan, $link_to_thematic_advance),
79
+            get_lang('ThematicSectionHasBeenCreatedSuccessfull').'<br />'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'), $link_to_thematic_plan, $link_to_thematic_advance),
80 80
             false
81 81
         );
82 82
     }
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
             $actions_first_col = '';
114 114
             if (api_is_allowed_to_edit(null, true)) {
115 115
                 // Thematic title
116
-                $actions_first_col  = Display::url(
116
+                $actions_first_col = Display::url(
117 117
                     Display::return_icon('cd.gif', get_lang('Copy')),
118 118
                     'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token
119 119
                 );
120
-                if (api_get_session_id() == 0 ) {
120
+                if (api_get_session_id() == 0) {
121 121
 
122 122
                     if ($thematic['display_order'] > 1) {
123
-                        $actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>';
123
+                        $actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL).'</a>';
124 124
                     } else {
125
-                        $actions_first_col .= ' '.Display::return_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
125
+                        $actions_first_col .= ' '.Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
126 126
                     }
127 127
                     if (isset($thematic['max_thematic_item']) && $thematic['display_order'] < $thematic['max_thematic_item']) {
128
-                        $actions_first_col .= ' <a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('down.png',get_lang('Down'),'',ICON_SIZE_SMALL).'</a>';
128
+                        $actions_first_col .= ' <a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL).'</a>';
129 129
                     } else {
130
-                        $actions_first_col .= ' '.Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
130
+                        $actions_first_col .= ' '.Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
131 131
                     }
132 132
 
133 133
                 }
134 134
                 if (api_get_session_id() == $thematic['session_id']) {
135
-                    $actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
136
-                    $actions_first_col .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
135
+                    $actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
136
+                    $actions_first_col .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
137 137
                 }
138 138
 
139 139
                 $actions_first_col = Display::div($actions_first_col, array('id'=>'thematic_id_content_'.$thematic['id'], 'class'=>'thematic_tools'));
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             //if (api_is_allowed_to_edit(null, true) &&  api_get_session_id() == $thematic['session_id']) {
150 150
             if (api_is_allowed_to_edit(null, true)) {
151 151
                 echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'&width=700&height=500">'.
152
-                    Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),ICON_SIZE_MEDIUM).'</a></div><br />';
152
+                    Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'), ICON_SIZE_MEDIUM).'</a></div><br />';
153 153
             }
154 154
 
155 155
             if (empty($thematic_plan_div[$thematic['id']])) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             //if (api_is_allowed_to_edit(null, true) &&  api_get_session_id() == $thematic['session_id']) {
166 166
             if (api_is_allowed_to_edit(null, true)) {
167 167
                 echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&action=thematic_advance_add&thematic_id='.$thematic['id'].'">'.
168
-                    Display::return_icon('add.png',get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a></div>';
168
+                    Display::return_icon('add.png', get_lang('NewThematicAdvance'), '', ICON_SIZE_MEDIUM).'</a></div>';
169 169
             }
170 170
 
171 171
             //if (api_is_allowed_to_edit(null, true) &&  api_get_session_id() == $thematic['session_id']) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                                 [],
188 188
                                 ICON_SIZE_SMALL
189 189
                             ),
190
-                            'index.php?' . api_get_cidreq() . '&' . http_build_query([
190
+                            'index.php?'.api_get_cidreq().'&'.http_build_query([
191 191
                                 'action' => 'thematic_advance_edit',
192 192
                                 'thematic_id' => $thematic['id'],
193 193
                                 'thematic_advance_id' => $thematic_advance['id'],
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
                                 'data-title' => get_lang('EditThematicAdvance')
199 199
                             ]
200 200
                         );
201
-                        $edit_link  .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
202
-                            Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
201
+                        $edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
202
+                            Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a></center>';
203 203
 
204 204
                         //Links
205 205
                         $edit_link = Display::div(
206
-                            Display::div($edit_link , array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')),
206
+                            Display::div($edit_link, array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')),
207 207
                             array('style'=>'height:20px;')
208 208
                         );
209 209
                     }
210 210
 
211
-                    $thematic_advance_item =  isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
211
+                    $thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
212 212
                     echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
213 213
                     echo $edit_link;
214 214
                     echo '</td>';
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 } elseif ($action == 'thematic_add' || $action == 'thematic_edit') {
254 254
 
255 255
     // Display form
256
-    $form = new FormValidator('thematic_add','POST','index.php?action=thematic_add&'.api_get_cidreq());
256
+    $form = new FormValidator('thematic_add', 'POST', 'index.php?action=thematic_add&'.api_get_cidreq());
257 257
 
258 258
     if ($action == 'thematic_edit') {
259 259
         $form->addElement('header', '', get_lang('EditThematicSection'));
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     $form->addElement('hidden', 'action', $action);
264 264
 
265 265
     if (!empty($thematic_id)) {
266
-        $form->addElement('hidden', 'thematic_id',$thematic_id);
266
+        $form->addElement('hidden', 'thematic_id', $thematic_id);
267 267
     }
268 268
 
269 269
     $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
     if (!empty($thematic_data)) {
276 276
         if (api_get_session_id()) {
277 277
             if ($thematic_data['session_id'] != api_get_session_id()) {
278
-                $show_form  = false;
279
-                Display::display_error_message(get_lang('NotAllowedClickBack'),false);
278
+                $show_form = false;
279
+                Display::display_error_message(get_lang('NotAllowedClickBack'), false);
280 280
             }
281 281
         }
282 282
         // set default values
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 
288 288
     // error messages
289 289
     if (isset($error)) {
290
-        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
290
+        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
291 291
     }
292 292
     if ($show_form) {
293 293
         $form->display();
294 294
     }
295 295
 } elseif ($action == 'thematic_import_select') {
296 296
     // Create form to upload csv file.
297
-    $form = new FormValidator('thematic_import','POST','index.php?action=thematic_import&'.api_get_cidreq().$url_token);
297
+    $form = new FormValidator('thematic_import', 'POST', 'index.php?action=thematic_import&'.api_get_cidreq().$url_token);
298 298
     $form->addElement('header', get_lang('ImportThematic'));
299 299
     $form->addElement('file', 'file');
300 300
     $form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));
Please login to merge, or discard this patch.
main/newscorm/openoffice_text.class.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             if (empty($matches[1][$i]))
127 127
                 continue;
128 128
 
129
-            $content = strstr($content,$matches[0][$i]);
129
+            $content = strstr($content, $matches[0][$i]);
130 130
             if ($i + 1 !== count($matches[0])) {
131 131
                 $chapter_content = substr($content, 0, strpos($content, $matches[0][$i + 1]));
132 132
             } else {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
             $document_id = add_document($_course, $this->created_dir.'/'.$html_file, 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$html_file), $html_file);
150 150
 
151
-            if ($document_id){
151
+            if ($document_id) {
152 152
 
153 153
                 // Put the document in item_property update.
154 154
                 api_item_property_update(
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                         foreach ($specific_fields as $specific_field) {
255 255
                             if (isset($_REQUEST[$specific_field['code']])) {
256 256
                                 $sterms = trim($_REQUEST[$specific_field['code']]);
257
-                                $all_specific_terms .= ' '. $sterms;
257
+                                $all_specific_terms .= ' '.$sterms;
258 258
                                 if (!empty($sterms)) {
259 259
                                     $sterms = explode(',', $sterms);
260 260
                                     foreach ($sterms as $sterm) {
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
                                 }
264 264
                             }
265 265
                         }
266
-                        $page_content = $all_specific_terms .' '. $page_content;
266
+                        $page_content = $all_specific_terms.' '.$page_content;
267 267
                         $ic_slide->addValue('content', $page_content);
268 268
                         // Add a comment to say terms separated by commas.
269
-                        $courseid=api_get_course_id();
269
+                        $courseid = api_get_course_id();
270 270
                         $ic_slide->addCourseId($courseid);
271 271
                         $ic_slide->addToolId(TOOL_LEARNPATH);
272 272
                         $lp_id = $this->lp_id;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                             SE_COURSE_ID => $courseid,
275 275
                             SE_TOOL_ID => TOOL_LEARNPATH,
276 276
                             SE_DATA => array('lp_id' => $lp_id, 'lp_item'=> $previous, 'document_id' => $document_id),
277
-                            SE_USER => (int)api_get_user_id(),
277
+                            SE_USER => (int) api_get_user_id(),
278 278
                         );
279 279
                         $ic_slide->xapian_data = serialize($xapian_data);
280 280
                         $di->addChunk($ic_slide);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      * Returns additional Java command parameters
299 299
      * @return	string	The additional parameters to be used in the Java call
300 300
      */
301
-    function add_command_parameters(){
301
+    function add_command_parameters() {
302 302
         return ' -d woogie "'.$this->base_work_dir.'/'.$this->file_path.'"  "'.$this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html"';
303 303
     }
304 304
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     function format_page_content($header, $content) {
312 312
         // Limit the width of the doc.
313
-        list($max_width, $max_height) = explode('x',api_get_setting('service_ppt2lp','size'));
313
+        list($max_width, $max_height) = explode('x', api_get_setting('service_ppt2lp', 'size'));
314 314
 
315 315
         $content = preg_replace("|<body[^>]*>|i", "\\0\r\n<div style=\"width:".$max_width."\">", $content, -1, $count);
316 316
         if ($count < 1) {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                 }
344 344
 
345 345
             } elseif ($img_width > $max_width - 10) {
346
-                $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width-10).'"', $images[0][$key]);
346
+                $picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width - 10).'"', $images[0][$key]);
347 347
                 $content = str_replace($images[0][$key], $picture_resized, $content);
348 348
             }
349 349
         }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * Gets html pages and compose them into a learning path
40 40
      * @param	array	The files that will compose the generated learning path. Unused so far.
41
-     * @return	boolean	False if file does not exit. Nothing otherwise.
41
+     * @return	false|null	False if file does not exit. Nothing otherwise.
42 42
      */
43 43
     public function make_lp($files = array())
44 44
     {
@@ -92,6 +92,7 @@  discard block
 block discarded – undo
92 92
      * Manages chapter splitting
93 93
      * @param	string	Chapter header
94 94
      * @param	string	Content
95
+     * @param string $content
95 96
      * @return	void
96 97
      */
97 98
     function dealPerChapter($header, $content)
@@ -164,6 +165,7 @@  discard block
 block discarded – undo
164 165
      * Manages page splitting
165 166
      * @param	string	Page header
166 167
      * @param	string	Page body
168
+     * @param string $body
167 169
      * @return	void
168 170
      */
169 171
     function dealPerPage($header, $body)
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@
 block discarded – undo
119 119
 
120 120
         for ($i = 0; $i<count($matches[0]); $i++) {
121 121
 
122
-            if (empty($matches[1][$i]))
123
-                continue;
122
+            if (empty($matches[1][$i])) {
123
+                            continue;
124
+            }
124 125
 
125 126
             $content = api_strstr($content, $matches[0][$i]);
126 127
             if ($i + 1 !== count($matches[0])) {
Please login to merge, or discard this patch.
main/newscorm/lp_admin_view.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
 // Using the resource linker as a tool for adding resources to the learning path.
42 42
 if ($action == 'add' and $type == 'learnpathitem') {
43
-     $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
43
+        $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
44 44
 }
45 45
 if ((!$is_allowed_to_edit) || ($isStudentView)) {
46 46
     error_log('New LP - User not authorized in lp_admin_view.php');
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 $isStudentView  = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
35 35
 $learnpath_id   = (int) $_REQUEST['lp_id'];
36
-$submit			= isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
36
+$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
37 37
 $_course = api_get_course_info();
38 38
 
39 39
 /* MAIN CODE */
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 if (!empty($gradebook) && $gradebook == 'view') {
64
-    $interbreadcrumb[] = array (
64
+    $interbreadcrumb[] = array(
65 65
             'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
66 66
             'name' => get_lang('ToolGradebook')
67 67
         );
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
             $in = implode(',', $lp_items_to_remove_audio);
100 100
         }
101 101
     }
102
-    if (count($lp_items_to_remove_audio)>0) {
103
-        $sql 	= "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$in.")";
102
+    if (count($lp_items_to_remove_audio) > 0) {
103
+        $sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$in.")";
104 104
         $result = Database::query($sql);
105 105
     }
106 106
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
                 // Adding something random to prevent overwriting.
134 134
                 $filename_components[count($filename_components) - 1] = time();
135 135
                 // Reconstructing the new filename.
136
-                $clean_name = implode($filename_components) .'.'.$file_extension;
136
+                $clean_name = implode($filename_components).'.'.$file_extension;
137 137
                 // Using the new name in the $_FILES superglobal.
138 138
                 $_FILES[$key]['name'] = $clean_name;
139 139
             }
140 140
 
141 141
             // Upload the file in the documents tool.
142
-            $file_path = handle_uploaded_document($_course, $_FILES[$key], api_get_path(SYS_COURSE_PATH).$_course['path'].'/document','/audio', api_get_user_id(), '', '', '', '', false);
142
+            $file_path = handle_uploaded_document($_course, $_FILES[$key], api_get_path(SYS_COURSE_PATH).$_course['path'].'/document', '/audio', api_get_user_id(), '', '', '', '', false);
143 143
 
144 144
             // Getting the filename only.
145 145
             $file_components = explode('/', $file_path);
Please login to merge, or discard this patch.