Completed
Pull Request — 1.11.x (#1293)
by José
387:57 queued 349:55
created
main/dropbox/dropbox_class.inc.php 1 patch
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         }
79 79
     }
80 80
 
81
-	/**
82
-	 * private function creating a new work object
83
-	 *
84
-	 * @param int $uploader_id
85
-	 * @param string $title
86
-	 * @param string $description
87
-	 * @param string $author
88
-	 * @param string $filename
89
-	 * @param int $filesize
90
-	 *
91
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
92
-	 * 			As a consequence this parameter can be removed
93
-	 */
94
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
81
+    /**
82
+     * private function creating a new work object
83
+     *
84
+     * @param int $uploader_id
85
+     * @param string $title
86
+     * @param string $description
87
+     * @param string $author
88
+     * @param string $filename
89
+     * @param int $filesize
90
+     *
91
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
92
+     * 			As a consequence this parameter can be removed
93
+     */
94
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
95 95
     {
96 96
         $dropbox_cnf = getDropboxConf();
97 97
 
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
         // Check if object exists already. If it does, the old object is used
110 110
         // with updated information (authors, description, upload_date)
111 111
         $this->isOldWork = false;
112
-		$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
112
+        $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
113 113
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
114 114
         $result = Database::query($sql);
115
-		$res = Database::fetch_array($result);
116
-		if ($res) {
117
-			$this->isOldWork = true;
118
-		}
119
-		// Insert or update the dropbox_file table and set the id property
120
-		if ($this->isOldWork) {
121
-			$this->id = $res['id'];
122
-			$this->upload_date = $res['upload_date'];
115
+        $res = Database::fetch_array($result);
116
+        if ($res) {
117
+            $this->isOldWork = true;
118
+        }
119
+        // Insert or update the dropbox_file table and set the id property
120
+        if ($this->isOldWork) {
121
+            $this->id = $res['id'];
122
+            $this->upload_date = $res['upload_date'];
123 123
 
124 124
             $params = [
125 125
                 'filesize' => $this->filesize,
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
137 137
             );
138 138
 
139
-		} else {
140
-			$this->upload_date = $this->last_upload_date;
141
-			$params = [
139
+        } else {
140
+            $this->upload_date = $this->last_upload_date;
141
+            $params = [
142 142
                 'c_id' => $course_id,
143 143
                 'uploader_id' => $this->uploader_id,
144 144
                 'filename' => $this->filename,
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
                 'last_upload_date' => $this->last_upload_date,
151 151
                 'session_id' => api_get_session_id(),
152 152
                 'cat_id' => 0
153
-			];
153
+            ];
154 154
 
155
-			$this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
156
-			if ($this->id) {
157
-				$sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
158
-				Database::query($sql);
159
-			}
160
-		}
155
+            $this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
156
+            if ($this->id) {
157
+                $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
158
+                Database::query($sql);
159
+            }
160
+        }
161 161
 
162 162
         $sql = "SELECT count(file_id) as count
163 163
         		FROM ".$dropbox_cnf['tbl_person']."
@@ -171,16 +171,16 @@  discard block
 block discarded – undo
171 171
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
172 172
             Database::query($sql);
173 173
         }
174
-	}
175
-
176
-	/**
177
-	 * private function creating existing object by retreiving info from db
178
-	 *
179
-	 * @param int $id
180
-	 */
181
-	public function _createExistingWork($id)
174
+    }
175
+
176
+    /**
177
+     * private function creating existing object by retreiving info from db
178
+     *
179
+     * @param int $id
180
+     */
181
+    public function _createExistingWork($id)
182 182
     {
183
-	    $course_id = api_get_course_int_id();
183
+        $course_id = api_get_course_int_id();
184 184
         $dropbox_cnf = getDropboxConf();
185 185
 
186 186
         $action = isset($_GET['action']) ? $_GET['action'] : null;
@@ -231,52 +231,52 @@  discard block
 block discarded – undo
231 231
             }
232 232
             $this->feedback2= $feedback2;
233 233
         }
234
-	}
234
+    }
235 235
 }
236 236
 
237 237
 class Dropbox_SentWork extends Dropbox_Work
238 238
 {
239
-	public $recipients;	//array of ['id']['name'] arrays
240
-
241
-	/**
242
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
243
-	 * depending on the number of parameters
244
-	 *
245
-	 * @param unknown_type $arg1
246
-	 * @param unknown_type $arg2
247
-	 * @param unknown_type $arg3
248
-	 * @param unknown_type $arg4
249
-	 * @param unknown_type $arg5
250
-	 * @param unknown_type $arg6
251
-	 * @param unknown_type $arg7
252
-	 * @return Dropbox_SentWork
253
-	 */
254
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
239
+    public $recipients;	//array of ['id']['name'] arrays
240
+
241
+    /**
242
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
243
+     * depending on the number of parameters
244
+     *
245
+     * @param unknown_type $arg1
246
+     * @param unknown_type $arg2
247
+     * @param unknown_type $arg3
248
+     * @param unknown_type $arg4
249
+     * @param unknown_type $arg5
250
+     * @param unknown_type $arg6
251
+     * @param unknown_type $arg7
252
+     * @return Dropbox_SentWork
253
+     */
254
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
255 255
     {
256
-		if (func_num_args() > 1) {
257
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
258
-		} else {
259
-			$this->_createExistingSentWork($arg1);
260
-		}
261
-	}
262
-
263
-	/**
264
-	 * private function creating a new SentWork object
265
-	 *
266
-	 * @param int $uploader_id
267
-	 * @param string $title
268
-	 * @param string $description
269
-	 * @param string $author
270
-	 * @param string $filename
271
-	 * @param int $filesize
272
-	 * @param array $recipient_ids
273
-	 */
274
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
256
+        if (func_num_args() > 1) {
257
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
258
+        } else {
259
+            $this->_createExistingSentWork($arg1);
260
+        }
261
+    }
262
+
263
+    /**
264
+     * private function creating a new SentWork object
265
+     *
266
+     * @param int $uploader_id
267
+     * @param string $title
268
+     * @param string $description
269
+     * @param string $author
270
+     * @param string $filename
271
+     * @param int $filesize
272
+     * @param array $recipient_ids
273
+     */
274
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
275 275
     {
276 276
         $dropbox_cnf = getDropboxConf();
277 277
         $_course = api_get_course_info();
278 278
 
279
-		// Call constructor of Dropbox_Work object
279
+        // Call constructor of Dropbox_Work object
280 280
         parent::__construct(
281 281
             $uploader_id,
282 282
             $title,
@@ -286,31 +286,31 @@  discard block
 block discarded – undo
286 286
             $filesize
287 287
         );
288 288
 
289
-		$course_id = api_get_course_int_id();
290
-
291
-		// Do sanity checks on recipient_ids array & property fillin
292
-		// The sanity check for ex-coursemembers is already done in base constructor
293
-		settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
289
+        $course_id = api_get_course_int_id();
294 290
 
295
-		$justSubmit = false;
296
-		if ( is_int($recipient_ids)) {
297
-			$justSubmit = true;
298
-			$recipient_ids = array($recipient_ids + $this->id);
299
-		} elseif ( count($recipient_ids) == 0) {
300
-			$justSubmit = true;
301
-			$recipient_ids = array($uploader_id);
302
-		}
291
+        // Do sanity checks on recipient_ids array & property fillin
292
+        // The sanity check for ex-coursemembers is already done in base constructor
293
+        settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
294
+
295
+        $justSubmit = false;
296
+        if ( is_int($recipient_ids)) {
297
+            $justSubmit = true;
298
+            $recipient_ids = array($recipient_ids + $this->id);
299
+        } elseif ( count($recipient_ids) == 0) {
300
+            $justSubmit = true;
301
+            $recipient_ids = array($uploader_id);
302
+        }
303 303
 
304
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
305
-			die(get_lang('GeneralError').' (code 209)');
306
-		}
304
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
305
+            die(get_lang('GeneralError').' (code 209)');
306
+        }
307 307
 
308
-		foreach ($recipient_ids as $rec) {
309
-			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
310
-			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
311
-				//this check is done when validating submitted data
312
-			$this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
313
-		}
308
+        foreach ($recipient_ids as $rec) {
309
+            if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
310
+            //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
311
+                //this check is done when validating submitted data
312
+            $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
313
+        }
314 314
 
315 315
         $table_post = $dropbox_cnf['tbl_post'];
316 316
         $table_person = $dropbox_cnf['tbl_person'];
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
         $user  = api_get_user_id();
320 320
         $now = api_get_utc_datetime();
321 321
 
322
-		// Insert data in dropbox_post and dropbox_person table for each recipient
323
-		foreach ($this->recipients as $rec) {
322
+        // Insert data in dropbox_post and dropbox_person table for each recipient
323
+        foreach ($this->recipients as $rec) {
324 324
             $file_id = (int)$this->id;
325 325
             $user_id = (int)$rec['id'];
326
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
326
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
327 327
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
328
-	        Database::query($sql);
328
+            Database::query($sql);
329 329
             // If work already exists no error is generated
330 330
 
331 331
             /**
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
                 }
343 343
             }
344 344
 
345
-			// Update item_property table for each recipient
346
-			if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
347
-			    $ownerid = getUserOwningThisMailing($ownerid);
348
-			}
349
-			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
350
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
351
-			}
345
+            // Update item_property table for each recipient
346
+            if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
347
+                $ownerid = getUserOwningThisMailing($ownerid);
348
+            }
349
+            if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
350
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
351
+            }
352 352
             api_item_property_update(
353 353
                 $_course,
354 354
                 TOOL_DROPBOX,
@@ -358,91 +358,91 @@  discard block
 block discarded – undo
358 358
                 null,
359 359
                 $recipid
360 360
             );
361
-		}
362
-	}
363
-
364
-	/**
365
-	 * private function creating existing object by retreiving info from db
366
-	 *
367
-	 * @param unknown_type $id
368
-	 */
369
-	public function _createExistingSentWork($id)
361
+        }
362
+    }
363
+
364
+    /**
365
+     * private function creating existing object by retreiving info from db
366
+     *
367
+     * @param unknown_type $id
368
+     */
369
+    public function _createExistingSentWork($id)
370 370
     {
371 371
         $dropbox_cnf = getDropboxConf();
372 372
         $id = intval($id);
373 373
 
374
-		$course_id = api_get_course_int_id();
374
+        $course_id = api_get_course_int_id();
375 375
 
376
-		// Call constructor of Dropbox_Work object
377
-		parent::__construct($id);
376
+        // Call constructor of Dropbox_Work object
377
+        parent::__construct($id);
378 378
 
379
-		// Fill in recipients array
380
-		$this->recipients = array();
381
-		$sql = "SELECT dest_user_id, feedback_date, feedback
379
+        // Fill in recipients array
380
+        $this->recipients = array();
381
+        $sql = "SELECT dest_user_id, feedback_date, feedback
382 382
 				FROM ".$dropbox_cnf['tbl_post']."
383 383
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
384 384
         $result = Database::query($sql);
385
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
386
-			// Check for deleted users
387
-			$dest_user_id = $res['dest_user_id'];
388
-			$user_info = api_get_user_info($dest_user_id);
389
-			//$this->category = $res['cat_id'];
390
-			if (!$user_info) {
391
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
392
-			} else {
393
-				$this->recipients[] = array(
385
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
386
+            // Check for deleted users
387
+            $dest_user_id = $res['dest_user_id'];
388
+            $user_info = api_get_user_info($dest_user_id);
389
+            //$this->category = $res['cat_id'];
390
+            if (!$user_info) {
391
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
392
+            } else {
393
+                $this->recipients[] = array(
394 394
                     'id' => $dest_user_id,
395 395
                     'name' => $user_info['complete_name'],
396 396
                     'user_id' => $dest_user_id,
397
-				    'feedback_date' => $res['feedback_date'],
397
+                    'feedback_date' => $res['feedback_date'],
398 398
                     'feedback' => $res['feedback']
399 399
                 );
400
-			}
401
-		}
402
-	}
400
+            }
401
+        }
402
+    }
403 403
 }
404 404
 
405 405
 class Dropbox_Person
406 406
 {
407
-	// The receivedWork and the sentWork arrays are sorted.
408
-	public $receivedWork;	// an array of Dropbox_Work objects
409
-	public $sentWork;		// an array of Dropbox_SentWork objects
410
-
411
-	public $userId = 0;
412
-	public $isCourseAdmin = false;
413
-	public $isCourseTutor = false;
414
-	public $_orderBy = '';	// private property that determines by which field
415
-
416
-	/**
417
-	 * Constructor for recreating the Dropbox_Person object
418
-	 *
419
-	 * @param int $userId
420
-	 * @param bool $isCourseAdmin
421
-	 * @param bool $isCourseTutor
422
-	 * @return Dropbox_Person
423
-	 */
424
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
407
+    // The receivedWork and the sentWork arrays are sorted.
408
+    public $receivedWork;	// an array of Dropbox_Work objects
409
+    public $sentWork;		// an array of Dropbox_SentWork objects
410
+
411
+    public $userId = 0;
412
+    public $isCourseAdmin = false;
413
+    public $isCourseTutor = false;
414
+    public $_orderBy = '';	// private property that determines by which field
415
+
416
+    /**
417
+     * Constructor for recreating the Dropbox_Person object
418
+     *
419
+     * @param int $userId
420
+     * @param bool $isCourseAdmin
421
+     * @param bool $isCourseTutor
422
+     * @return Dropbox_Person
423
+     */
424
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
425 425
     {
426
-	    $course_id = api_get_course_int_id();
426
+        $course_id = api_get_course_int_id();
427 427
 
428
-		// Fill in properties
428
+        // Fill in properties
429 429
         $this->userId = $userId;
430 430
         $this->isCourseAdmin = $isCourseAdmin;
431 431
         $this->isCourseTutor = $isCourseTutor;
432 432
         $this->receivedWork = array();
433 433
         $this->sentWork = array();
434 434
 
435
-		// Note: perhaps include an ex coursemember check to delete old files
435
+        // Note: perhaps include an ex coursemember check to delete old files
436 436
 
437
-		$session_id = api_get_session_id();
438
-		$condition_session = api_get_session_condition($session_id);
437
+        $session_id = api_get_session_id();
438
+        $condition_session = api_get_session_condition($session_id);
439 439
 
440
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
441
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
442
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
440
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
441
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
442
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
443 443
 
444 444
         // Find all entries where this person is the recipient
445
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
445
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
446 446
                 FROM $post_tbl r
447 447
                 INNER JOIN $person_tbl p
448 448
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
452 452
 
453 453
         $result = Database::query($sql);
454
-		while ($res = Database::fetch_array($result)) {
455
-			$temp = new Dropbox_Work($res['file_id']);
456
-			$temp->category = $res['cat_id'];
457
-			$this->receivedWork[] = $temp;
458
-		}
459
-		// Find all entries where this person is the sender/uploader
454
+        while ($res = Database::fetch_array($result)) {
455
+            $temp = new Dropbox_Work($res['file_id']);
456
+            $temp->category = $res['cat_id'];
457
+            $this->receivedWork[] = $temp;
458
+        }
459
+        // Find all entries where this person is the sender/uploader
460 460
         $sql = "SELECT DISTINCT f.id
461 461
 				FROM $file_tbl f
462 462
 				INNER JOIN $person_tbl p
@@ -467,261 +467,261 @@  discard block
 block discarded – undo
467 467
                     $condition_session
468 468
                 ";
469 469
         $result = Database::query($sql);
470
-		while ($res = Database::fetch_array($result)) {
471
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
472
-		}
473
-	}
474
-
475
-	/**
476
-	 * This private method is used by the usort function in  the
477
-	 * orderSentWork and orderReceivedWork methods.
478
-	 * It compares 2 work-objects by 1 of the properties of that object, dictated by the
479
-	 * private property _orderBy
480
-	 *
481
-	 * @param unknown_type $a
482
-	 * @param unknown_type $b
483
-	 * @return int -1, 0 or 1 dependent of the result of the comparison.
484
-	 */
485
-	function _cmpWork($a, $b)
470
+        while ($res = Database::fetch_array($result)) {
471
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
472
+        }
473
+    }
474
+
475
+    /**
476
+     * This private method is used by the usort function in  the
477
+     * orderSentWork and orderReceivedWork methods.
478
+     * It compares 2 work-objects by 1 of the properties of that object, dictated by the
479
+     * private property _orderBy
480
+     *
481
+     * @param unknown_type $a
482
+     * @param unknown_type $b
483
+     * @return int -1, 0 or 1 dependent of the result of the comparison.
484
+     */
485
+    function _cmpWork($a, $b)
486 486
     {
487
-		$sort = $this->_orderBy;
488
-		$aval = $a->$sort;
489
-		$bval = $b->$sort;
490
-		if ($sort == 'recipients') {
491
-		    // The recipients property is an array so we do the comparison based
492
-		    // on the first item of the recipients array
493
-		    $aval = $aval[0]['name'];
494
-			$bval = $bval[0]['name'];
495
-		}
496
-		if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
497
-			return $aval < $bval ? -1 : 1;
498
-		} elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
499
-			return api_strnatcmp($aval, $bval);
500
-		} else {
501
-		    return api_strcasecmp($aval, $bval);
502
-		}
503
-	}
504
-
505
-	/**
506
-	 * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
507
-	 * $sort can be lastDate, firstDate, title, size, ...
508
-	 *
509
-	 * @param unknown_type $sort
510
-	 */
511
-	function orderSentWork($sort)
487
+        $sort = $this->_orderBy;
488
+        $aval = $a->$sort;
489
+        $bval = $b->$sort;
490
+        if ($sort == 'recipients') {
491
+            // The recipients property is an array so we do the comparison based
492
+            // on the first item of the recipients array
493
+            $aval = $aval[0]['name'];
494
+            $bval = $bval[0]['name'];
495
+        }
496
+        if ($sort == 'filesize') {    // Filesize is not a string, so we use other comparison technique
497
+            return $aval < $bval ? -1 : 1;
498
+        } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
499
+            return api_strnatcmp($aval, $bval);
500
+        } else {
501
+            return api_strcasecmp($aval, $bval);
502
+        }
503
+    }
504
+
505
+    /**
506
+     * A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
507
+     * $sort can be lastDate, firstDate, title, size, ...
508
+     *
509
+     * @param unknown_type $sort
510
+     */
511
+    function orderSentWork($sort)
512 512
     {
513
-		switch($sort) {
514
-			case 'lastDate':
515
-				$this->_orderBy = 'last_upload_date';
516
-				break;
517
-			case 'firstDate':
518
-				$this->_orderBy = 'upload_date';
519
-				break;
520
-			case 'title':
521
-				$this->_orderBy = 'title';
522
-				break;
523
-			case 'size':
524
-				$this->_orderBy = 'filesize';
525
-				break;
526
-			case 'author':
527
-				$this->_orderBy = 'author';
528
-				break;
529
-			case 'recipient':
530
-				$this->_orderBy = 'recipients';
531
-				break;
532
-			default:
533
-				$this->_orderBy = 'last_upload_date';
534
-		}
535
-
536
-		usort($this->sentWork, array($this, '_cmpWork'));
537
-	}
538
-
539
-	/**
540
-	 * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
541
-	 * $sort can be lastDate, firstDate, title, size, ...
542
-	 * @param unknown_type $sort
543
-	 */
544
-	function orderReceivedWork($sort)
513
+        switch($sort) {
514
+            case 'lastDate':
515
+                $this->_orderBy = 'last_upload_date';
516
+                break;
517
+            case 'firstDate':
518
+                $this->_orderBy = 'upload_date';
519
+                break;
520
+            case 'title':
521
+                $this->_orderBy = 'title';
522
+                break;
523
+            case 'size':
524
+                $this->_orderBy = 'filesize';
525
+                break;
526
+            case 'author':
527
+                $this->_orderBy = 'author';
528
+                break;
529
+            case 'recipient':
530
+                $this->_orderBy = 'recipients';
531
+                break;
532
+            default:
533
+                $this->_orderBy = 'last_upload_date';
534
+        }
535
+
536
+        usort($this->sentWork, array($this, '_cmpWork'));
537
+    }
538
+
539
+    /**
540
+     * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
541
+     * $sort can be lastDate, firstDate, title, size, ...
542
+     * @param unknown_type $sort
543
+     */
544
+    function orderReceivedWork($sort)
545 545
     {
546
-		switch($sort) {
547
-			case 'lastDate':
548
-				$this->_orderBy = 'last_upload_date';
549
-				break;
550
-			case 'firstDate':
551
-				$this->_orderBy = 'upload_date';
552
-				break;
553
-			case 'title':
554
-				$this->_orderBy = 'title';
555
-				break;
556
-			case 'size':
557
-				$this->_orderBy = 'filesize';
558
-				break;
559
-			case 'author':
560
-				$this->_orderBy = 'author';
561
-				break;
562
-			case 'sender':
563
-				$this->_orderBy = 'uploaderName';
564
-				break;
565
-			default:
566
-				$this->_orderBy = 'last_upload_date';
567
-		}
568
-
569
-		usort($this->receivedWork, array($this, '_cmpWork'));
570
-	}
571
-
572
-	/**
573
-	 * Deletes all the received work of this person
574
-	 */
575
-	public function deleteAllReceivedWork()
546
+        switch($sort) {
547
+            case 'lastDate':
548
+                $this->_orderBy = 'last_upload_date';
549
+                break;
550
+            case 'firstDate':
551
+                $this->_orderBy = 'upload_date';
552
+                break;
553
+            case 'title':
554
+                $this->_orderBy = 'title';
555
+                break;
556
+            case 'size':
557
+                $this->_orderBy = 'filesize';
558
+                break;
559
+            case 'author':
560
+                $this->_orderBy = 'author';
561
+                break;
562
+            case 'sender':
563
+                $this->_orderBy = 'uploaderName';
564
+                break;
565
+            default:
566
+                $this->_orderBy = 'last_upload_date';
567
+        }
568
+
569
+        usort($this->receivedWork, array($this, '_cmpWork'));
570
+    }
571
+
572
+    /**
573
+     * Deletes all the received work of this person
574
+     */
575
+    public function deleteAllReceivedWork()
576 576
     {
577
-	    $course_id = api_get_course_int_id();
577
+        $course_id = api_get_course_int_id();
578 578
         $dropbox_cnf = getDropboxConf();
579
-		// Delete entries in person table concerning received works
580
-		foreach ($this->receivedWork as $w) {
579
+        // Delete entries in person table concerning received works
580
+        foreach ($this->receivedWork as $w) {
581 581
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
582 582
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
583
-			Database::query($sql);
584
-		}
583
+            Database::query($sql);
584
+        }
585 585
         // Check for unused files
586
-		removeUnusedFiles();
587
-	}
588
-
589
-	/**
590
-	 * Deletes all the received categories and work of this person
591
-	 * @param integer $id
592
-	 */
593
-	public function deleteReceivedWorkFolder($id)
586
+        removeUnusedFiles();
587
+    }
588
+
589
+    /**
590
+     * Deletes all the received categories and work of this person
591
+     * @param integer $id
592
+     */
593
+    public function deleteReceivedWorkFolder($id)
594 594
     {
595 595
         $dropbox_cnf = getDropboxConf();
596 596
         $course_id = api_get_course_int_id();
597 597
 
598
-		$id = intval($id);
599
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
598
+        $id = intval($id);
599
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
600 600
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
601
-		if (!Database::query($sql)) return false;
602
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
601
+        if (!Database::query($sql)) return false;
602
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
603 603
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
604
-		if (!Database::query($sql)) return false;
605
-		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
604
+        if (!Database::query($sql)) return false;
605
+        $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
606 606
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
607
-		if (!Database::query($sql)) return false;
608
-		return true;
609
-	}
610
-
611
-	/**
612
-	 * Deletes a received dropbox file of this person with id=$id
613
-	 *
614
-	 * @param integer $id
615
-	 */
616
-	public function deleteReceivedWork($id)
607
+        if (!Database::query($sql)) return false;
608
+        return true;
609
+    }
610
+
611
+    /**
612
+     * Deletes a received dropbox file of this person with id=$id
613
+     *
614
+     * @param integer $id
615
+     */
616
+    public function deleteReceivedWork($id)
617 617
     {
618
-	    $course_id = api_get_course_int_id();
618
+        $course_id = api_get_course_int_id();
619 619
         $dropbox_cnf = getDropboxConf();
620
-		$id = intval($id);
621
-
622
-		// index check
623
-		$found = false;
624
-		foreach ($this->receivedWork as $w) {
625
-			if ($w->id == $id) {
626
-			   $found = true;
627
-			   break;
628
-			}
629
-		}
630
-
631
-		if (!$found) {
632
-			if (!$this->deleteReceivedWorkFolder($id)) {
633
-				die(get_lang('GeneralError').' (code 216)');
634
-			}
635
-		}
636
-		// Delete entries in person table concerning received works
620
+        $id = intval($id);
621
+
622
+        // index check
623
+        $found = false;
624
+        foreach ($this->receivedWork as $w) {
625
+            if ($w->id == $id) {
626
+                $found = true;
627
+                break;
628
+            }
629
+        }
630
+
631
+        if (!$found) {
632
+            if (!$this->deleteReceivedWorkFolder($id)) {
633
+                die(get_lang('GeneralError').' (code 216)');
634
+            }
635
+        }
636
+        // Delete entries in person table concerning received works
637 637
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
638 638
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
639
-		Database::query($sql);
640
-		removeUnusedFiles();	// Check for unused files
641
-	}
642
-
643
-	/**
644
-	 * Deletes all the sent dropbox files of this person
645
-	 */
646
-	public function deleteAllSentWork()
639
+        Database::query($sql);
640
+        removeUnusedFiles();	// Check for unused files
641
+    }
642
+
643
+    /**
644
+     * Deletes all the sent dropbox files of this person
645
+     */
646
+    public function deleteAllSentWork()
647 647
     {
648
-	    $course_id = api_get_course_int_id();
648
+        $course_id = api_get_course_int_id();
649 649
         $dropbox_cnf = getDropboxConf();
650
-		//delete entries in person table concerning sent works
651
-		foreach ($this->sentWork as $w) {
650
+        //delete entries in person table concerning sent works
651
+        foreach ($this->sentWork as $w) {
652 652
             $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
653 653
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
654
-			Database::query($sql);
655
-			removeMoreIfMailing($w->id);
656
-		}
657
-		removeUnusedFiles();	// Check for unused files
658
-	}
659
-
660
-	/**
661
-	 * Deletes a sent dropbox file of this person with id=$id
662
-	 *
663
-	 * @param unknown_type $id
664
-	 */
665
-	public function deleteSentWork($id)
654
+            Database::query($sql);
655
+            removeMoreIfMailing($w->id);
656
+        }
657
+        removeUnusedFiles();	// Check for unused files
658
+    }
659
+
660
+    /**
661
+     * Deletes a sent dropbox file of this person with id=$id
662
+     *
663
+     * @param unknown_type $id
664
+     */
665
+    public function deleteSentWork($id)
666 666
     {
667
-	    $course_id = api_get_course_int_id();
667
+        $course_id = api_get_course_int_id();
668 668
         $dropbox_cnf = getDropboxConf();
669 669
 
670
-		$id = intval($id);
671
-
672
-		// index check
673
-		$found = false;
674
-		foreach ($this->sentWork as $w) {
675
-			if ($w->id == $id) {
676
-			   $found = true;
677
-			   break;
678
-			}
679
-		}
680
-		if (!$found) {
681
-			if (!$this->deleteReceivedWorkFolder($id)) {
682
-				die(get_lang('GeneralError').' (code 219)');
683
-			}
684
-		}
685
-		//$file_id = $this->sentWork[$index]->id;
686
-		// Delete entries in person table concerning sent works
670
+        $id = intval($id);
671
+
672
+        // index check
673
+        $found = false;
674
+        foreach ($this->sentWork as $w) {
675
+            if ($w->id == $id) {
676
+                $found = true;
677
+                break;
678
+            }
679
+        }
680
+        if (!$found) {
681
+            if (!$this->deleteReceivedWorkFolder($id)) {
682
+                die(get_lang('GeneralError').' (code 219)');
683
+            }
684
+        }
685
+        //$file_id = $this->sentWork[$index]->id;
686
+        // Delete entries in person table concerning sent works
687 687
         $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
688 688
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
689
-		Database::query($sql);
690
-		removeMoreIfMailing($id);
691
-		removeUnusedFiles();	// Check for unused files
692
-	}
693
-
694
-	/**
695
-	 * Updates feedback for received work of this person with id=$id
696
-	 *
697
-	 * @param string $id
698
-	 * @param string $text
699
-	 */
700
-	public function updateFeedback($id, $text)
689
+        Database::query($sql);
690
+        removeMoreIfMailing($id);
691
+        removeUnusedFiles();	// Check for unused files
692
+    }
693
+
694
+    /**
695
+     * Updates feedback for received work of this person with id=$id
696
+     *
697
+     * @param string $id
698
+     * @param string $text
699
+     */
700
+    public function updateFeedback($id, $text)
701 701
     {
702
-	    $course_id = api_get_course_int_id();
702
+        $course_id = api_get_course_int_id();
703 703
         $_course = api_get_course_info();
704 704
         $dropbox_cnf = getDropboxConf();
705 705
 
706
-		$id = intval($id);
707
-
708
-		// index check
709
-		$found = false;
710
-		$wi = -1;
711
-		foreach ($this->receivedWork as $w) {
712
-			$wi++;
713
-			if ($w->id == $id){
714
-			   $found = true;
715
-			   break;
716
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
717
-		}
718
-		if (!$found) {
719
-			die(get_lang('GeneralError').' (code 221)');
720
-		}
721
-
722
-		$feedback_date = api_get_utc_datetime();
723
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
724
-		$this->receivedWork[$wi]->feedback = $text;
706
+        $id = intval($id);
707
+
708
+        // index check
709
+        $found = false;
710
+        $wi = -1;
711
+        foreach ($this->receivedWork as $w) {
712
+            $wi++;
713
+            if ($w->id == $id){
714
+                $found = true;
715
+                break;
716
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
717
+        }
718
+        if (!$found) {
719
+            die(get_lang('GeneralError').' (code 221)');
720
+        }
721
+
722
+        $feedback_date = api_get_utc_datetime();
723
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
724
+        $this->receivedWork[$wi]->feedback = $text;
725 725
 
726 726
         $params = [
727 727
             'feedback_date' => $feedback_date,
@@ -739,11 +739,11 @@  discard block
 block discarded – undo
739 739
             ]
740 740
         );
741 741
 
742
-		// Update item_property table
742
+        // Update item_property table
743 743
 
744
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
745
-		    $ownerid = getUserOwningThisMailing($ownerid);
746
-		}
744
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
745
+            $ownerid = getUserOwningThisMailing($ownerid);
746
+        }
747 747
         api_item_property_update(
748 748
             $_course,
749 749
             TOOL_DROPBOX,
@@ -754,31 +754,31 @@  discard block
 block discarded – undo
754 754
             $ownerid
755 755
         );
756 756
 
757
-	}
757
+    }
758 758
 
759
-	/**
760
-	 * Filter the received work
761
-	 * @param string $type
762
-	 * @param string $value
763
-	 */
764
-	public function filter_received_work($type, $value)
759
+    /**
760
+     * Filter the received work
761
+     * @param string $type
762
+     * @param string $value
763
+     */
764
+    public function filter_received_work($type, $value)
765 765
     {
766 766
         $dropbox_cnf = getDropboxConf();
767
-    	$new_received_work = array();
768
-		foreach ($this->receivedWork as $work) {
769
-			switch ($type) {
770
-				case 'uploader_id':
771
-					if ($work->uploader_id == $value ||
772
-						($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
767
+        $new_received_work = array();
768
+        foreach ($this->receivedWork as $work) {
769
+            switch ($type) {
770
+                case 'uploader_id':
771
+                    if ($work->uploader_id == $value ||
772
+                        ($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
773 773
                         getUserOwningThisMailing($work->uploader_id) == $value)
774 774
                     ) {
775
-						$new_received_work[] = $work;
776
-					}
777
-					break;
778
-				default:
779
-					$new_received_work[] = $work;
780
-			}
781
-		}
782
-		$this->receivedWork = $new_received_work;
783
-	}
775
+                        $new_received_work[] = $work;
776
+                    }
777
+                    break;
778
+                default:
779
+                    $new_received_work[] = $work;
780
+            }
781
+        }
782
+        $this->receivedWork = $new_received_work;
783
+    }
784 784
 }
Please login to merge, or discard this patch.
main/messages/view_message.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 require_once '../inc/global.inc.php';
8 8
 api_block_anonymous_users();
9 9
 if (api_get_setting('allow_message_tool')!='true') {
10
-	api_not_allowed();
10
+    api_not_allowed();
11 11
 }
12 12
 
13 13
 if (isset($_REQUEST['f']) && $_REQUEST['f'] == 'social') {
14
-	$this_section = SECTION_SOCIAL;
15
-	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
16
-	$interbreadcrumb[]= array ('url' => 'inbox.php?f=social','name' => get_lang('Inbox'));
14
+    $this_section = SECTION_SOCIAL;
15
+    $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
16
+    $interbreadcrumb[]= array ('url' => 'inbox.php?f=social','name' => get_lang('Inbox'));
17 17
 } else {
18
-	$this_section = SECTION_MYPROFILE;
19
-	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
18
+    $this_section = SECTION_MYPROFILE;
19
+    $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
20 20
 }
21 21
 
22 22
 $social_right_content = '';
23 23
 
24 24
 if (isset($_GET['f']) && $_GET['f']=='social') {
25
-	$social_parameter = '?f=social';
25
+    $social_parameter = '?f=social';
26 26
 } else {
27
-	if (api_get_setting('extended_profile') == 'true') {
28
-		$social_right_content .= '<div class="actions">';
27
+    if (api_get_setting('extended_profile') == 'true') {
28
+        $social_right_content .= '<div class="actions">';
29 29
 
30
-		if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
31
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
30
+        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
31
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
32 32
                 Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
33
-		}
34
-		if (api_get_setting('allow_message_tool') === 'true') {
35
-		    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
33
+        }
34
+        if (api_get_setting('allow_message_tool') === 'true') {
35
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
36 36
                 Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
37 37
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
38 38
                 Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
39 39
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
40 40
                 Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
41
-		}
42
-		$social_right_content .= '</div>';
43
-	}
41
+        }
42
+        $social_right_content .= '</div>';
43
+    }
44 44
 }
45 45
 
46 46
 if (empty($_GET['id'])) {
Please login to merge, or discard this patch.
main/messages/new_message.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 * Shows the compose area + a list of users to select from.
68 68
 */
69 69
 function show_compose_to_any($user_id) {
70
-	$online_user_list = MessageManager::get_online_user_list($user_id);
71
-	$default['user_list'] = 0;
72
-	$online_user_list=null;
73
-	$html = manage_form($default, $online_user_list);
70
+    $online_user_list = MessageManager::get_online_user_list($user_id);
71
+    $default['user_list'] = 0;
72
+    $online_user_list=null;
73
+    $html = manage_form($default, $online_user_list);
74 74
     return $html;
75 75
 }
76 76
 
77 77
 function show_compose_reply_to_message($message_id, $receiver_id)
78 78
 {
79
-	$table_message = Database::get_main_table(TABLE_MESSAGE);
80
-	$query = "SELECT user_sender_id FROM $table_message
79
+    $table_message = Database::get_main_table(TABLE_MESSAGE);
80
+    $query = "SELECT user_sender_id FROM $table_message
81 81
 			  WHERE user_receiver_id=".intval($receiver_id)." AND id='".intval($message_id)."';";
82
-	$result = Database::query($query);
83
-	$row = Database::fetch_array($result,'ASSOC');
84
-	if (!isset($row['user_sender_id'])) {
85
-		$html = get_lang('InvalidMessageId');
82
+    $result = Database::query($query);
83
+    $row = Database::fetch_array($result,'ASSOC');
84
+    if (!isset($row['user_sender_id'])) {
85
+        $html = get_lang('InvalidMessageId');
86 86
 
87
-		return $html;
88
-	}
89
-	$userInfo = api_get_user_info($row['user_sender_id']);
90
-	$default['users'] = array($row['user_sender_id']);
91
-	$html = manage_form($default, null, $userInfo['complete_name']);
87
+        return $html;
88
+    }
89
+    $userInfo = api_get_user_info($row['user_sender_id']);
90
+    $default['users'] = array($row['user_sender_id']);
91
+    $html = manage_form($default, null, $userInfo['complete_name']);
92 92
 
93 93
     return $html;
94 94
 }
95 95
 
96 96
 function show_compose_to_user ($receiver_id) {
97
-	$html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
98
-	$default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
99
-	$default['users'] = array($receiver_id);
100
-	$html .= manage_form($default);
97
+    $html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
98
+    $default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
99
+    $default['users'] = array($receiver_id);
100
+    $html .= manage_form($default);
101 101
     return $html;
102 102
 }
103 103
 
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 
253 253
 /* MAIN SECTION */
254 254
 if ($socialToolIsActive) {
255
-	$this_section = SECTION_SOCIAL;
255
+    $this_section = SECTION_SOCIAL;
256 256
     $interbreadcrumb[] = array(
257 257
         'url' => api_get_path(WEB_PATH).'main/social/home.php',
258 258
         'name' => get_lang('SocialNetwork'),
259 259
     );
260 260
 } else {
261
-	$this_section = SECTION_MYPROFILE;
261
+    $this_section = SECTION_MYPROFILE;
262 262
     $interbreadcrumb[] = array(
263 263
         'url' => api_get_path(WEB_PATH).'main/auth/profile.php',
264 264
         'name' => get_lang('Profile'),
@@ -268,30 +268,30 @@  discard block
 block discarded – undo
268 268
 $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
269 269
 $social_right_content = null;
270 270
 if ($group_id != 0) {
271
-	$social_right_content .= '<div class=actions>';
272
-	$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
273
-		Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
274
-	$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
275
-		Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
276
-	$social_right_content .= '</div>';
271
+    $social_right_content .= '<div class=actions>';
272
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
273
+        Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
274
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
275
+        Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
276
+    $social_right_content .= '</div>';
277 277
 } else {
278
-	if ($socialToolIsActive) {
279
-	} else {
280
-		$social_right_content .= '<div class=actions>';
281
-		if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
282
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
278
+    if ($socialToolIsActive) {
279
+    } else {
280
+        $social_right_content .= '<div class=actions>';
281
+        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
282
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
283 283
                 Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
284
-		}
285
-		if (api_get_setting('allow_message_tool') === 'true') {
286
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
284
+        }
285
+        if (api_get_setting('allow_message_tool') === 'true') {
286
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
287 287
                 Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
288
-			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
288
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
289 289
                 Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
290 290
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
291 291
                 Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
292
-		}
293
-		$social_right_content .= '</div>';
294
-	}
292
+        }
293
+        $social_right_content .= '</div>';
294
+    }
295 295
 }
296 296
 
297 297
 // LEFT COLUMN
Please login to merge, or discard this patch.
main/course_info/delete_course.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     $message .= '<p><a class="btn btn-primary" href="'.api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq().'">'.
45 45
         get_lang('No').'</a>&nbsp;<a class="btn btn-danger" href="'.api_get_self().'?delete=yes&'.api_get_cidreq().'">'.
46 46
         get_lang('Yes').'</a></p>';
47
-	$interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
47
+    $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
48 48
 }
49 49
 Display :: display_header($tool_name, 'Settings');
50 50
 echo Display::page_header($tool_name);
Please login to merge, or discard this patch.
main/course_info/download.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 $this_section = SECTION_COURSES;
11 11
 
12 12
 if (isset($_GET['session']) && $_GET['session']) {
13
-	$archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/';
14
-	$_cid = true;
15
-	$is_courseAdmin = true;
13
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/';
14
+    $_cid = true;
15
+    $is_courseAdmin = true;
16 16
 } else {
17
-	$archive_path = api_get_path(SYS_ARCHIVE_PATH);
17
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH);
18 18
 }
19 19
 
20 20
 $archive_file = isset($_GET['archive']) ? $_GET['archive'] : null;
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 list($extension) = getextension($archive_file);
24 24
 
25 25
 if (empty($extension) || !file_exists($archive_path.$archive_file)) {
26
-	exit;
26
+    exit;
27 27
 }
28 28
 
29 29
 $extension = strtolower($extension);
30 30
 $content_type = '';
31 31
 
32 32
 if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
33
-	$content_type = 'application/force-download';
33
+    $content_type = 'application/force-download';
34 34
 } elseif ($extension === 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
35
-	$content_type = 'application/force-download';
35
+    $content_type = 'application/force-download';
36 36
 }
37 37
 
38 38
 if (empty($content_type)) {
Please login to merge, or discard this patch.
main/course_description/add.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,32 +20,32 @@  discard block
 block discarded – undo
20 20
 $i=1;
21 21
 echo '<div class="actions" style="margin-bottom:30px">';
22 22
 echo '<a href="index.php?'.api_get_cidreq().'">'.
23
-	Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM).
24
-	'</a>';
23
+    Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM).
24
+    '</a>';
25 25
 ksort($categories);
26 26
 foreach ($categories as $id => $title) {
27
-	if ($i == ADD_BLOCK) {
28
-		echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
29
-			Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>';
30
-		break;
31
-	} else {
32
-		echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
33
-			Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
34
-		$i++;
35
-	}
27
+    if ($i == ADD_BLOCK) {
28
+        echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
29
+            Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>';
30
+        break;
31
+    } else {
32
+        echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
33
+            Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
34
+        $i++;
35
+    }
36 36
 }
37 37
 echo '</div>';
38 38
 
39 39
 // error messages
40 40
 if (isset($error) && intval($error) == 1) {
41
-	Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
41
+    Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
42 42
 }
43 43
 
44 44
 // default header title form
45 45
 $header = '';
46 46
 $description_type = intval($description_type);
47 47
 if ($description_type >= ADD_BLOCK) {
48
-	$header = $default_description_titles[ADD_BLOCK];
48
+    $header = $default_description_titles[ADD_BLOCK];
49 49
 }
50 50
 
51 51
 // display form
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 
74 74
 // display default questions
75 75
 if (isset ($question[$description_type])) {
76
-	$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
77
-	$message .= $question[$description_type];
78
-	Display::display_normal_message($message, false);
76
+    $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
77
+    $message .= $question[$description_type];
78
+    Display::display_normal_message($message, false);
79 79
 }
80 80
 $form->display();
Please login to merge, or discard this patch.
main/calendar/ical_export.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 $event = $agenda->get_event($id);
44 44
 
45 45
 if (!empty($event)) {
46
-	define('ICAL_LANG',api_get_language_isocode());
46
+    define('ICAL_LANG',api_get_language_isocode());
47 47
 
48 48
     $ical = new vcalendar();
49 49
     $ical->setConfig('unique_id',api_get_path(WEB_PATH));
@@ -137,6 +137,6 @@  discard block
 block discarded – undo
137 137
             die();
138 138
     }
139 139
 } else {
140
-	header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));
141
-	exit;
140
+    header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));
141
+    exit;
142 142
 }
Please login to merge, or discard this patch.
main/inc/lib/add_courses_to_session_functions.lib.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -6,47 +6,47 @@  discard block
 block discarded – undo
6 6
  */
7 7
 class AddCourseToSession
8 8
 {
9
-	/**
10
-	 * Searches a course, given a search string and a type of search box
11
-	 * @param string $needle Search string
12
-	 * @param string $type Type of search box ('single' or anything else)
13
-	 * @return xajaxResponse XajaxResponse
14
-	 * @assert ('abc', 'single') !== null
15
-	 * @assert ('abc', 'multiple') !== null
16
-	 */
17
-	public static function search_courses($needle, $type)
18
-	{
19
-		global $tbl_session_rel_course, $id_session;
9
+    /**
10
+     * Searches a course, given a search string and a type of search box
11
+     * @param string $needle Search string
12
+     * @param string $type Type of search box ('single' or anything else)
13
+     * @return xajaxResponse XajaxResponse
14
+     * @assert ('abc', 'single') !== null
15
+     * @assert ('abc', 'multiple') !== null
16
+     */
17
+    public static function search_courses($needle, $type)
18
+    {
19
+        global $tbl_session_rel_course, $id_session;
20 20
         $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
21
-		$course_title = null;
22
-		$xajax_response = new xajaxResponse();
23
-		$return = '';
24
-		if(!empty($needle) && !empty($type)) {
25
-			// xajax send utf8 datas... datas in db can be non-utf8 datas
26
-			$charset = api_get_system_encoding();
27
-			$needle = api_convert_encoding($needle, $charset, 'utf-8');
21
+        $course_title = null;
22
+        $xajax_response = new xajaxResponse();
23
+        $return = '';
24
+        if(!empty($needle) && !empty($type)) {
25
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
26
+            $charset = api_get_system_encoding();
27
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
28 28
 
29
-			$cond_course_code = '';
30
-			if (!empty($id_session)) {
31
-				$id_session = intval($id_session);
32
-				// check course_code from session_rel_course table
33
-				$sql = 'SELECT c_id FROM '.$tbl_session_rel_course.'
29
+            $cond_course_code = '';
30
+            if (!empty($id_session)) {
31
+                $id_session = intval($id_session);
32
+                // check course_code from session_rel_course table
33
+                $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.'
34 34
 						WHERE session_id = '.$id_session;
35
-				$res = Database::query($sql);
36
-				$course_codes = '';
37
-				if (Database::num_rows($res) > 0) {
38
-					while ($row = Database::fetch_row($res)) {
39
-						$course_codes .= '\''.$row[0].'\',';
40
-					}
41
-					$course_codes = substr($course_codes,0,(strlen($course_codes)-1));
35
+                $res = Database::query($sql);
36
+                $course_codes = '';
37
+                if (Database::num_rows($res) > 0) {
38
+                    while ($row = Database::fetch_row($res)) {
39
+                        $course_codes .= '\''.$row[0].'\',';
40
+                    }
41
+                    $course_codes = substr($course_codes,0,(strlen($course_codes)-1));
42 42
 
43
-					$cond_course_code = ' AND course.id NOT IN('.$course_codes.') ';
44
-				}
45
-			}
43
+                    $cond_course_code = ' AND course.id NOT IN('.$course_codes.') ';
44
+                }
45
+            }
46 46
 
47 47
             if ($type == 'single') {
48
-				// search users where username or firstname or lastname begins likes $needle
49
-				$sql = 'SELECT
48
+                // search users where username or firstname or lastname begins likes $needle
49
+                $sql = 'SELECT
50 50
 							course.code,
51 51
 						 	course.visual_code,
52 52
 						 	course.title,
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
 						WHERE
59 59
 							course.visual_code LIKE "'.$needle.'%" OR
60 60
 							course.title LIKE "'.$needle.'%"';
61
-			} else {
62
-				$sql = 'SELECT course.code, course.visual_code, course.title
61
+            } else {
62
+                $sql = 'SELECT course.code, course.visual_code, course.title
63 63
 						FROM '.$tbl_course.' course
64 64
 						WHERE
65 65
 							course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.'
66 66
 						ORDER BY course.code ';
67
-			}
67
+            }
68 68
 
69
-			if (api_is_multiple_url_enabled()) {
70
-				$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
71
-				$access_url_id = api_get_current_access_url_id();
72
-				if ($access_url_id != -1){
69
+            if (api_is_multiple_url_enabled()) {
70
+                $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
71
+                $access_url_id = api_get_current_access_url_id();
72
+                if ($access_url_id != -1){
73 73
 
74
-					if ($type=='single') {
75
-						$sql = 'SELECT
74
+                    if ($type=='single') {
75
+                        $sql = 'SELECT
76 76
 						            course.code,
77 77
 						            course.visual_code,
78 78
 						            course.title,
@@ -87,41 +87,41 @@  discard block
 block discarded – undo
87 87
 									access_url_id = '.$access_url_id.' AND
88 88
 									(course.visual_code LIKE "'.$needle.'%" OR
89 89
 									course.title LIKE "'.$needle.'%" )';
90
-					} else {
91
-						$sql = 'SELECT course.code, course.visual_code, course.title
90
+                    } else {
91
+                        $sql = 'SELECT course.code, course.visual_code, course.title
92 92
 								FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course
93 93
 								WHERE
94 94
 									url_course.c_id = course.id AND
95 95
 									access_url_id = '.$access_url_id.' AND
96 96
 									course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.'
97 97
 								ORDER BY course.code ';
98
-					}
99
-				}
100
-			}
98
+                    }
99
+                }
100
+            }
101 101
 
102
-			$rs = Database::query($sql);
103
-			$course_list = array();
102
+            $rs = Database::query($sql);
103
+            $course_list = array();
104 104
             if ($type == 'single') {
105
-				while ($course = Database :: fetch_array($rs)) {
106
-					$course_list[] = $course['code'];
107
-					$course_title=str_replace("'","\'",$course_title);
108
-					$return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['code'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />';
109
-				}
110
-				$xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return));
111
-			} else {
112
-				$return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
113
-				while($course = Database :: fetch_array($rs)) {
114
-					$course_list[] = $course['code'];
115
-					$course_title=str_replace("'","\'",$course_title);
116
-					$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
117
-				}
118
-				$return .= '</select>';
105
+                while ($course = Database :: fetch_array($rs)) {
106
+                    $course_list[] = $course['code'];
107
+                    $course_title=str_replace("'","\'",$course_title);
108
+                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['code'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />';
109
+                }
110
+                $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return));
111
+            } else {
112
+                $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
113
+                while($course = Database :: fetch_array($rs)) {
114
+                    $course_list[] = $course['code'];
115
+                    $course_title=str_replace("'","\'",$course_title);
116
+                    $return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
117
+                }
118
+                $return .= '</select>';
119 119
 
120
-				$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
121
-			}
122
-		}
123
-		$_SESSION['course_list'] = $course_list;
120
+                $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
121
+            }
122
+        }
123
+        $_SESSION['course_list'] = $course_list;
124 124
 
125
-		return $xajax_response;
126
-	}
125
+        return $xajax_response;
126
+    }
127 127
 }
Please login to merge, or discard this patch.
main/inc/lib/export.lib.inc.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     /**
118
-    * Export tabular data to XML-file
119
-    * @param array  Simple array of data to put in XML
120
-    * @param string Name of file to be given to the user
121
-    * @param string Name of common tag to place each line in
122
-    * @param string Name of the root element. A root element should always be given.
123
-    * @param string Encoding in which the data is provided
124
-    */
118
+     * Export tabular data to XML-file
119
+     * @param array  Simple array of data to put in XML
120
+     * @param string Name of file to be given to the user
121
+     * @param string Name of common tag to place each line in
122
+     * @param string Name of the root element. A root element should always be given.
123
+     * @param string Encoding in which the data is provided
124
+     */
125 125
     public static function arrayToXml(
126 126
         $data,
127 127
         $filename = 'export',
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         foreach ($data as $row) {
201 201
             $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>';
202 202
             if (is_array($row['value'])) {
203
-            	$string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n";
203
+                $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n";
204 204
                 $string .= str_repeat("\t",$level).'</'.$row['name'].'>';
205 205
             } else {
206 206
                 $string .= $row['value'];
Please login to merge, or discard this patch.