Code Duplication    Length = 17-19 lines in 5 locations

main/lp/learnpath.class.php 5 locations

@@ 4886-4903 (lines=18) @@
4883
     * @param	string	Optional string giving the new theme of this learnpath
4884
     * @return   bool    Returns true if theme name is not empty
4885
     */
4886
    public function set_theme($name = '')
4887
    {
4888
        $course_id = api_get_course_int_id();
4889
        if ($this->debug > 0) {
4890
            error_log('New LP - In learnpath::set_theme()', 0);
4891
        }
4892
        $this->theme = $name;
4893
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4894
        $lp_id = $this->get_id();
4895
        $sql = "UPDATE $lp_table SET theme = '".Database::escape_string($this->theme)."'
4896
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4897
        if ($this->debug > 2) {
4898
            error_log('New LP - lp updated with new theme : '.$this->theme, 0);
4899
        }
4900
        Database::query($sql);
4901
4902
        return true;
4903
    }
4904
4905
    /**
4906
     * Sets the image of an LP (and save)
@@ 4910-4928 (lines=19) @@
4907
     * @param	 string	Optional string giving the new image of this learnpath
4908
     * @return bool   Returns true if theme name is not empty
4909
     */
4910
    public function set_preview_image($name = '')
4911
    {
4912
        $course_id = api_get_course_int_id();
4913
        if ($this->debug > 0) {
4914
            error_log('New LP - In learnpath::set_preview_image()', 0);
4915
        }
4916
4917
        $this->preview_image = $name;
4918
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4919
        $lp_id = $this->get_id();
4920
        $sql = "UPDATE $lp_table SET
4921
                preview_image = '".Database::escape_string($this->preview_image)."'
4922
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4923
        if ($this->debug > 2) {
4924
            error_log('New LP - lp updated with new preview image : '.$this->preview_image, 0);
4925
        }
4926
        Database::query($sql);
4927
        return true;
4928
    }
4929
4930
    /**
4931
     * Sets the author of a LP (and save)
@@ 4935-4952 (lines=18) @@
4932
     * @param	string	Optional string giving the new author of this learnpath
4933
     * @return   bool    Returns true if author's name is not empty
4934
     */
4935
    public function set_author($name = '')
4936
    {
4937
        $course_id = api_get_course_int_id();
4938
        if ($this->debug > 0) {
4939
            error_log('New LP - In learnpath::set_author()', 0);
4940
        }
4941
        $this->author = $name;
4942
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4943
        $lp_id = $this->get_id();
4944
        $sql = "UPDATE $lp_table SET author = '".Database::escape_string($name)."'
4945
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4946
        if ($this->debug > 2) {
4947
            error_log('New LP - lp updated with new preview author : '.$this->author, 0);
4948
        }
4949
        Database::query($sql);
4950
4951
        return true;
4952
    }
4953
4954
    /**
4955
     * Sets the hide_toc_frame parameter of a LP (and save)
@@ 4988-5004 (lines=17) @@
4985
     * @param	int		integer giving the new prerequisite of this learnpath
4986
     * @return 	bool 	returns true if prerequisite is not empty
4987
     */
4988
    public function set_prerequisite($prerequisite)
4989
    {
4990
        $course_id = api_get_course_int_id();
4991
        if ($this->debug > 0) {
4992
            error_log('New LP - In learnpath::set_prerequisite()', 0);
4993
        }
4994
        $this->prerequisite = intval($prerequisite);
4995
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
4996
        $lp_id = $this->get_id();
4997
        $sql = "UPDATE $lp_table SET prerequisite = '".$this->prerequisite."'
4998
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
4999
        if ($this->debug > 2) {
5000
            error_log('New LP - lp updated with new preview requisite : '.$this->requisite, 0);
5001
        }
5002
        Database::query($sql);
5003
        return true;
5004
    }
5005
5006
    /**
5007
     * Sets the location/proximity of the LP (local/remote) (and save)
@@ 5153-5169 (lines=17) @@
5150
     * Sets and saves the expired_on date
5151
     * @return   bool    Returns true if author's name is not empty
5152
     */
5153
    public function set_modified_on()
5154
    {
5155
        $course_id = api_get_course_int_id();
5156
        if ($this->debug > 0) {
5157
            error_log('New LP - In learnpath::set_expired_on()', 0);
5158
        }
5159
        $this->modified_on = api_get_utc_datetime();
5160
        $lp_table = Database::get_course_table(TABLE_LP_MAIN);
5161
        $lp_id = $this->get_id();
5162
        $sql = "UPDATE $lp_table SET modified_on = '".$this->modified_on."'
5163
                WHERE c_id = ".$course_id." AND id = '$lp_id'";
5164
        if ($this->debug > 2) {
5165
            error_log('New LP - lp updated with new expired_on : '.$this->modified_on, 0);
5166
        }
5167
        Database::query($sql);
5168
5169
        return true;
5170
    }
5171
5172
    /**