Code Duplication    Length = 17-19 lines in 5 locations

main/newscorm/learnpath.class.php 5 locations

@@ 4685-4702 (lines=18) @@
4682
     * @param	string	Optional string giving the new theme of this learnpath
4683
     * @return   bool    Returns true if theme name is not empty
4684
     */
4685
    public function set_theme($name = '')
4686
    {
4687
        $course_id = api_get_course_int_id();
4688
        if ($this->debug > 0) {
4689
            error_log('New LP - In learnpath::set_theme()', 0);
4690
        }
4691
        $this->theme = $name;
4692
        $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4693
        $lp_id = $this->get_id();
4694
        $sql = "UPDATE $lp_table SET theme = '" . Database::escape_string($this->theme). "'
4695
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4696
        if ($this->debug > 2) {
4697
            error_log('New LP - lp updated with new theme : ' . $this->theme, 0);
4698
        }
4699
        Database::query($sql);
4700
4701
        return true;
4702
    }
4703
4704
    /**
4705
     * Sets the image of an LP (and save)
@@ 4709-4727 (lines=19) @@
4706
     * @param	 string	Optional string giving the new image of this learnpath
4707
     * @return bool   Returns true if theme name is not empty
4708
     */
4709
    public function set_preview_image($name = '')
4710
    {
4711
        $course_id = api_get_course_int_id();
4712
        if ($this->debug > 0) {
4713
            error_log('New LP - In learnpath::set_preview_image()', 0);
4714
        }
4715
4716
        $this->preview_image = $name;
4717
        $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4718
        $lp_id = $this->get_id();
4719
        $sql = "UPDATE $lp_table SET
4720
                preview_image = '" . Database::escape_string($this->preview_image). "'
4721
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4722
        if ($this->debug > 2) {
4723
            error_log('New LP - lp updated with new preview image : ' . $this->preview_image, 0);
4724
        }
4725
        Database::query($sql);
4726
        return true;
4727
    }
4728
4729
    /**
4730
     * Sets the author of a LP (and save)
@@ 4734-4751 (lines=18) @@
4731
     * @param	string	Optional string giving the new author of this learnpath
4732
     * @return   bool    Returns true if author's name is not empty
4733
     */
4734
    public function set_author($name = '')
4735
    {
4736
        $course_id = api_get_course_int_id();
4737
        if ($this->debug > 0) {
4738
            error_log('New LP - In learnpath::set_author()', 0);
4739
        }
4740
        $this->author = $name;
4741
        $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4742
        $lp_id = $this->get_id();
4743
        $sql = "UPDATE $lp_table SET author = '" . Database::escape_string($name). "'
4744
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4745
        if ($this->debug > 2) {
4746
            error_log('New LP - lp updated with new preview author : ' . $this->author, 0);
4747
        }
4748
        Database::query($sql);
4749
4750
        return true;
4751
    }
4752
4753
    /**
4754
     * Sets the hide_toc_frame parameter of a LP (and save)
@@ 4787-4803 (lines=17) @@
4784
     * @param	int		integer giving the new prerequisite of this learnpath
4785
     * @return 	bool 	returns true if prerequisite is not empty
4786
     */
4787
    public function set_prerequisite($prerequisite)
4788
    {
4789
        $course_id = api_get_course_int_id();
4790
        if ($this->debug > 0) {
4791
            error_log('New LP - In learnpath::set_prerequisite()', 0);
4792
        }
4793
        $this->prerequisite = intval($prerequisite);
4794
        $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4795
        $lp_id = $this->get_id();
4796
        $sql = "UPDATE $lp_table SET prerequisite = '".$this->prerequisite."'
4797
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4798
        if ($this->debug > 2) {
4799
            error_log('New LP - lp updated with new preview requisite : ' . $this->requisite, 0);
4800
        }
4801
        Database::query($sql);
4802
        return true;
4803
    }
4804
4805
    /**
4806
     * Sets the location/proximity of the LP (local/remote) (and save)
@@ 4934-4950 (lines=17) @@
4931
     * Sets and saves the expired_on date
4932
     * @return   bool    Returns true if author's name is not empty
4933
     */
4934
    public function set_modified_on()
4935
    {
4936
        $course_id = api_get_course_int_id();
4937
        if ($this->debug > 0) {
4938
            error_log('New LP - In learnpath::set_expired_on()', 0);
4939
        }
4940
        $this->modified_on = api_get_utc_datetime();
4941
        $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4942
        $lp_id = $this->get_id();
4943
        $sql = "UPDATE $lp_table SET modified_on = '" . $this->modified_on . "'
4944
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4945
        if ($this->debug > 2) {
4946
            error_log('New LP - lp updated with new expired_on : ' . $this->modified_on, 0);
4947
        }
4948
        Database::query($sql);
4949
        return true;
4950
    }
4951
4952
    /**
4953
     * Sets the object's error message