Code Duplication    Length = 29-29 lines in 2 locations

main/lp/learnpath.class.php 2 locations

@@ 5077-5105 (lines=29) @@
5074
     * @param   string  $expired_on Optional string giving the new author of this learnpath
5075
     * @return   bool    Returns true if author's name is not empty
5076
     */
5077
    public function set_expired_on($expired_on)
5078
    {
5079
        if ($this->debug > 0) {
5080
            error_log('New LP - In learnpath::set_expired_on()', 0);
5081
        }
5082
5083
        $em = Database::getManager();
5084
        /** @var CLp $lp */
5085
        $lp = $em
5086
            ->getRepository('ChamiloCourseBundle:CLp')
5087
            ->findOneBy(
5088
                [
5089
                    'id' => $this->get_id(),
5090
                    'cId' => api_get_course_int_id()
5091
                ]
5092
            );
5093
5094
        if (!$lp) {
5095
            return false;
5096
        }
5097
5098
        $this->expired_on = !empty($expired_on) ? api_get_utc_datetime($expired_on, false, true) : null;
5099
5100
        $lp->setExpiredOn($this->expired_on);
5101
        $em->persist($lp);
5102
        $em->flush();
5103
5104
        if ($this->debug > 2) {
5105
            error_log('New LP - lp updated with new expired_on : '.$this->expired_on, 0);
5106
        }
5107
5108
        return true;
@@ 5116-5144 (lines=29) @@
5113
     * @param   string  $publicated_on Optional string giving the new author of this learnpath
5114
     * @return   bool    Returns true if author's name is not empty
5115
     */
5116
    public function set_publicated_on($publicated_on)
5117
    {
5118
        if ($this->debug > 0) {
5119
            error_log('New LP - In learnpath::set_expired_on()', 0);
5120
        }
5121
5122
        $em = Database::getManager();
5123
        /** @var CLp $lp */
5124
        $lp = $em
5125
            ->getRepository('ChamiloCourseBundle:CLp')
5126
            ->findOneBy(
5127
                [
5128
                    'id' => $this->get_id(),
5129
                    'cId' => api_get_course_int_id()
5130
                ]
5131
            );
5132
5133
        if (!$lp) {
5134
            return false;
5135
        }
5136
5137
        $this->publicated_on = !empty($publicated_on) ? api_get_utc_datetime($publicated_on, false, true) : null;
5138
        $lp->setPublicatedOn($this->publicated_on);
5139
        $em->persist($lp);
5140
        $em->flush();
5141
5142
        if ($this->debug > 2) {
5143
            error_log('New LP - lp updated with new publicated_on : '.$this->publicated_on, 0);
5144
        }
5145
5146
        return true;
5147
    }