Code Duplication    Length = 17-19 lines in 5 locations

main/lp/learnpath.class.php 5 locations

@@ 4847-4864 (lines=18) @@
4844
     * @param	string	Optional string giving the new theme of this learnpath
4845
     * @return   bool    Returns true if theme name is not empty
4846
     */
4847
    public function set_theme($name = '')
4848
    {
4849
        $course_id = api_get_course_int_id();
4850
        if ($this->debug > 0) {
4851
            error_log('New LP - In learnpath::set_theme()', 0);
4852
        }
4853
        $this->theme = $name;
4854
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4855
        $lp_id = $this->get_id();
4856
        $sql = "UPDATE $lp_table SET theme = '".Database::escape_string($this->theme)."'
4857
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4858
        if ($this->debug > 2) {
4859
            error_log('New LP - lp updated with new theme : '.$this->theme, 0);
4860
        }
4861
        Database::query($sql);
4862
4863
        return true;
4864
    }
4865
4866
    /**
4867
     * Sets the image of an LP (and save)
@@ 4871-4889 (lines=19) @@
4868
     * @param	 string	Optional string giving the new image of this learnpath
4869
     * @return bool   Returns true if theme name is not empty
4870
     */
4871
    public function set_preview_image($name = '')
4872
    {
4873
        $course_id = api_get_course_int_id();
4874
        if ($this->debug > 0) {
4875
            error_log('New LP - In learnpath::set_preview_image()', 0);
4876
        }
4877
4878
        $this->preview_image = $name;
4879
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4880
        $lp_id = $this->get_id();
4881
        $sql = "UPDATE $lp_table SET
4882
                preview_image = '".Database::escape_string($this->preview_image)."'
4883
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4884
        if ($this->debug > 2) {
4885
            error_log('New LP - lp updated with new preview image : '.$this->preview_image, 0);
4886
        }
4887
        Database::query($sql);
4888
        return true;
4889
    }
4890
4891
    /**
4892
     * Sets the author of a LP (and save)
@@ 4896-4913 (lines=18) @@
4893
     * @param	string	Optional string giving the new author of this learnpath
4894
     * @return   bool    Returns true if author's name is not empty
4895
     */
4896
    public function set_author($name = '')
4897
    {
4898
        $course_id = api_get_course_int_id();
4899
        if ($this->debug > 0) {
4900
            error_log('New LP - In learnpath::set_author()', 0);
4901
        }
4902
        $this->author = $name;
4903
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4904
        $lp_id = $this->get_id();
4905
        $sql = "UPDATE $lp_table SET author = '".Database::escape_string($name)."'
4906
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4907
        if ($this->debug > 2) {
4908
            error_log('New LP - lp updated with new preview author : '.$this->author, 0);
4909
        }
4910
        Database::query($sql);
4911
4912
        return true;
4913
    }
4914
4915
    /**
4916
     * Sets the hide_toc_frame parameter of a LP (and save)
@@ 4949-4965 (lines=17) @@
4946
     * @param	int		integer giving the new prerequisite of this learnpath
4947
     * @return 	bool 	returns true if prerequisite is not empty
4948
     */
4949
    public function set_prerequisite($prerequisite)
4950
    {
4951
        $course_id = api_get_course_int_id();
4952
        if ($this->debug > 0) {
4953
            error_log('New LP - In learnpath::set_prerequisite()', 0);
4954
        }
4955
        $this->prerequisite = intval($prerequisite);
4956
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4957
        $lp_id = $this->get_id();
4958
        $sql = "UPDATE $lp_table SET prerequisite = '".$this->prerequisite."'
4959
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4960
        if ($this->debug > 2) {
4961
            error_log('New LP - lp updated with new preview requisite : '.$this->requisite, 0);
4962
        }
4963
        Database::query($sql);
4964
        return true;
4965
    }
4966
4967
    /**
4968
     * Sets the location/proximity of the LP (local/remote) (and save)
@@ 5105-5121 (lines=17) @@
5102
     * Sets and saves the expired_on date
5103
     * @return   bool    Returns true if author's name is not empty
5104
     */
5105
    public function set_modified_on()
5106
    {
5107
        $course_id = api_get_course_int_id();
5108
        if ($this->debug > 0) {
5109
            error_log('New LP - In learnpath::set_expired_on()', 0);
5110
        }
5111
        $this->modified_on = api_get_utc_datetime();
5112
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
5113
        $lp_id = $this->get_id();
5114
        $sql = "UPDATE $lp_table SET modified_on = '".$this->modified_on."'
5115
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
5116
        if ($this->debug > 2) {
5117
            error_log('New LP - lp updated with new expired_on : '.$this->modified_on, 0);
5118
        }
5119
        Database::query($sql);
5120
5121
        return true;
5122
    }
5123
5124
    /**