Code Duplication    Length = 26-28 lines in 2 locations

main/dropbox/dropbox_class.inc.php 2 locations

@@ 614-639 (lines=26) @@
611
	 *
612
	 * @param integer $id
613
	 */
614
	function deleteReceivedWork($id)
615
    {
616
	    $course_id = api_get_course_int_id();
617
        $dropbox_cnf = getDropboxConf();
618
		$id = intval($id);
619
620
		// index check
621
		$found = false;
622
		foreach ($this->receivedWork as $w) {
623
			if ($w->id == $id) {
624
			   $found = true;
625
			   break;
626
			}
627
		}
628
629
		if (!$found) {
630
			if (!$this->deleteReceivedWorkFolder($id)) {
631
				die(get_lang('GeneralError').' (code 216)');
632
			}
633
		}
634
		// Delete entries in person table concerning received works
635
        $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
636
                WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
637
		Database::query($sql);
638
		removeUnusedFiles();	// Check for unused files
639
	}
640
641
	/**
642
	 * Deletes all the sent dropbox files of this person
@@ 663-690 (lines=28) @@
660
	 *
661
	 * @param unknown_type $id
662
	 */
663
	function deleteSentWork($id)
664
    {
665
	    $course_id = api_get_course_int_id();
666
        $dropbox_cnf = getDropboxConf();
667
668
		$id = intval($id);
669
670
		// index check
671
		$found = false;
672
		foreach ($this->sentWork as $w) {
673
			if ($w->id == $id) {
674
			   $found = true;
675
			   break;
676
			}
677
		}
678
		if (!$found) {
679
			if (!$this->deleteReceivedWorkFolder($id)) {
680
				die(get_lang('GeneralError').' (code 219)');
681
			}
682
		}
683
		//$file_id = $this->sentWork[$index]->id;
684
		// Delete entries in person table concerning sent works
685
        $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
686
                WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
687
		Database::query($sql);
688
		removeMoreIfMailing($id);
689
		removeUnusedFiles();	// Check for unused files
690
	}
691
692
	/**
693
	 * Updates feedback for received work of this person with id=$id