Procházet zdrojové kódy

Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

Angel Fernando Quiroz Campos před 6 roky
rodič
revize
3848872ec2

+ 1 - 1
.htaccess

@@ -9,7 +9,7 @@
 RewriteEngine on
 
 # Prevent execution of PHP from directories used for different types of uploads
-RedirectMatch 403 ^/app/(cache|courses|home|logs|upload|Resources/public/css)/.*\.ph(p[3457]?|t|tml|ar)$
+RedirectMatch 403 ^/app/(?!courses/proxy)(cache|courses|home|logs|upload|Resources/public/css)/.*\.ph(p[3457]?|t|tml|ar)$
 RedirectMatch 403 ^/main/default_course_document/images/.*\.ph(p[3457]?|t|tml|ar)$
 RedirectMatch 403 ^/main/lang/.*\.ph(p[3457]?|t|tml|ar)$
 RedirectMatch 403 ^/web/css/.*\.ph(p[3457]?|t|tml|ar)$

+ 15 - 13
main/exercise/exercise_show.php

@@ -1092,19 +1092,21 @@ if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress
         );
     }
 
-    $emailForm->addCheckBox(
-        'send_notification',
-        get_lang('SendEmail'),
-        get_lang('SendEmail'),
-        ['onclick' => 'openEmailWrapper();']
-    );
-    $emailForm->addHtml('<div id="email_content_wrapper" style="display:none; margin-bottom: 20px;">');
-    $emailForm->addHtmlEditor(
-        'notification_content',
-        get_lang('Content'),
-        false
-    );
-    $emailForm->addHtml('</div>');
+    if ($objExercise->results_disabled != RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
+        $emailForm->addCheckBox(
+            'send_notification',
+            get_lang('SendEmail'),
+            get_lang('SendEmail'),
+            ['onclick' => 'openEmailWrapper();']
+        );
+        $emailForm->addHtml('<div id="email_content_wrapper" style="display:none; margin-bottom: 20px;">');
+        $emailForm->addHtmlEditor(
+            'notification_content',
+            get_lang('Content'),
+            false
+        );
+        $emailForm->addHtml('</div>');
+    }
 
     if (empty($track_exercise_info['orig_lp_id']) || empty($track_exercise_info['orig_lp_item_id'])) {
         // Default url

+ 19 - 70
main/inc/lib/events.lib.php

@@ -2218,7 +2218,6 @@ class Event
      * @param int    $sessionId   The session in which to add the time (if any)
      * @param string $virtualTime The amount of time to be added,
      *                            in a hh:mm:ss format. If int, we consider it is expressed in hours.
-     * @param string $ip          IP address to go on record for this time record
      *
      * @return true on successful insertion, false otherwise
      */
@@ -2226,80 +2225,32 @@ class Event
         $courseId,
         $userId,
         $sessionId,
-        $virtualTime = '',
-        $ip = ''
+        $virtualTime = ''
     ) {
-        $courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
-        $time = $loginDate = $logoutDate = api_get_utc_datetime();
-
         $courseId = (int) $courseId;
         $userId = (int) $userId;
         $sessionId = (int) $sessionId;
-        $ip = Database::escape_string($ip);
-
-        // Get the current latest course connection register. We need that
-        // record to re-use the data and create a new record.
-        $sql = "SELECT *
-                FROM $courseTrackingTable
-                WHERE
-                    user_id = $userId AND
-                    c_id = $courseId  AND
-                    session_id  = $sessionId AND
-                    login_course_date > '$time' - INTERVAL 3600 SECOND
-                ORDER BY login_course_date DESC 
-                LIMIT 0,1";
-        $result = Database::query($sql);
-
-        // Ignore if we didn't find any course connection record in the last
-        // hour. In this case it wouldn't be right to add a "fake" time record.
-        if (Database::num_rows($result) > 0) {
-            // Found the latest connection
-            $row = Database::fetch_array($result);
-            $courseAccessId = $row['course_access_id'];
-            $courseAccessLoginDate = $row['login_course_date'];
-            $counter = $row['counter'];
-            $counter = $counter ? $counter : 0;
-            // Insert a new record, copy of the current one (except the logout
-            // date that we update to the current time)
-            $sql = "INSERT INTO $courseTrackingTable(
-                    c_id,
-                    user_ip, 
-                    user_id, 
-                    login_course_date, 
-                    logout_course_date, 
-                    counter, 
-                    session_id
-                ) VALUES(
-                    $courseId, 
-                    '$ip', 
-                    $userId, 
-                    '$courseAccessLoginDate', 
-                    '$logoutDate', 
-                    $counter, 
-                    $sessionId
-                )";
-            Database::query($sql);
 
-            $loginDate = ChamiloApi::addOrSubTimeToDateTime(
-                $virtualTime,
-                $courseAccessLoginDate,
-                false
-            );
-            // We update the course tracking table
-            $sql = "UPDATE $courseTrackingTable  
-                    SET 
-                        login_course_date = '$loginDate',
-                        logout_course_date = '$courseAccessLoginDate',
-                        counter = 0
-                    WHERE 
-                        course_access_id = ".intval($courseAccessId)." AND 
-                        session_id = ".$sessionId;
-            Database::query($sql);
+        $logoutDate = api_get_utc_datetime();
+        $loginDate = ChamiloApi::addOrSubTimeToDateTime(
+            $virtualTime,
+            $logoutDate,
+            false
+        );
 
-            return true;
-        }
+        $params = [
+            'login_course_date' => $loginDate,
+            'logout_course_date' => $logoutDate,
+            'session_id' => $sessionId,
+            'user_id' => $userId,
+            'counter' => 0,
+            'c_id' => $courseId,
+            'user_ip' => api_get_real_ip(),
+        ];
+        $courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+        Database::insert($courseTrackingTable, $params);
 
-        return false;
+        return true;
     }
 
     /**
@@ -2331,8 +2282,6 @@ class Event
             return false;
         }
         $courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
-        $time = $loginDate = $logoutDate = api_get_utc_datetime();
-
         $courseId = (int) $courseId;
         $userId = (int) $userId;
         $sessionId = (int) $sessionId;

+ 1 - 22
main/inc/lib/formvalidator/Element/DatePicker.php

@@ -80,28 +80,7 @@ class DatePicker extends HTML_QuickForm_text
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $sizeTemp = $this->getInputSize();
-            if (empty($size)) {
-                $sizeTemp = 8;
-            }
-            $size = [2, $sizeTemp, 2];
-        } else {
-            if (is_array($size)) {
-                if (count($size) != 3) {
-                    $sizeTemp = $this->getInputSize();
-                    if (empty($size)) {
-                        $sizeTemp = 8;
-                    }
-                    $size = [2, $sizeTemp, 2];
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = [2, (int) $size, 2];
-            }
-        }
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:

+ 1 - 22
main/inc/lib/formvalidator/Element/DateTimePicker.php

@@ -79,28 +79,7 @@ class DateTimePicker extends HTML_QuickForm_text
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $sizeTemp = $this->getInputSize();
-            if (empty($size)) {
-                $sizeTemp = 8;
-            }
-            $size = [2, $sizeTemp, 2];
-        } else {
-            if (is_array($size)) {
-                if (count($size) != 3) {
-                    $sizeTemp = $this->getInputSize();
-                    if (empty($size)) {
-                        $sizeTemp = 8;
-                    }
-                    $size = [2, $sizeTemp, 2];
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = [2, (int) $size, 2];
-            }
-        }
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:

+ 1 - 23
main/inc/lib/formvalidator/Element/DateTimeRangePicker.php

@@ -53,29 +53,7 @@ class DateTimeRangePicker extends DateRangePicker
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $sizeTemp = $this->getInputSize();
-            if (empty($size)) {
-                $sizeTemp = 8;
-            }
-            $size = [2, $sizeTemp, 2];
-        } else {
-            if (is_array($size)) {
-                if (count($size) != 3) {
-                    $sizeTemp = $this->getInputSize();
-                    if (empty($size)) {
-                        $sizeTemp = 8;
-                    }
-                    $size = [2, $sizeTemp, 2];
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = [2, (int) $size, 2];
-            }
-        }
-
+        $size = $this->calculateSize();
         $id = $this->getAttribute('id');
 
         switch ($layout) {

+ 1 - 16
main/inc/lib/pear/HTML/QuickForm/button.php

@@ -210,24 +210,9 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
+        $size = $this->calculateSize();
         $attributes = $this->getAttributes();
 
-        if (empty($size)) {
-            $size = array(2, 8, 2);
-        } else {
-            if (is_array($size)) {
-                if (count($size) == 1) {
-                    $size = array(2, intval($size[0]), 2);
-                } elseif (count($size) != 3) {
-                    $size = array(2, 8, 2);
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = array(2, intval($size), 2);
-            }
-        }
-
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:
                 return '

+ 1 - 16
main/inc/lib/pear/HTML/QuickForm/checkbox.php

@@ -163,22 +163,7 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $size = array(2, 8, 2);
-        } else {
-            if (is_array($size)) {
-                if (count($size) == 1) {
-                    $size = array(2, intval($size[0]), 2);
-                } elseif (count($size) != 3) {
-                    $size = array(2, 8, 2);
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = array(2, intval($size), 2);
-            }
-        }
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:

+ 50 - 0
main/inc/lib/pear/HTML/QuickForm/element.php

@@ -39,6 +39,7 @@ class HTML_QuickForm_element extends HTML_Common
     private $icon;
     private $template;
     private $customFrozenTemplate = '';
+    protected $inputSize;
 
     /**
      * Label of the field
@@ -584,4 +585,53 @@ class HTML_QuickForm_element extends HTML_Common
 
         return $this;
     }
+
+
+
+    /**
+     * @return null
+     */
+    public function getInputSize()
+    {
+        return $this->inputSize;
+    }
+
+    /**
+     * @param null $inputSize
+     */
+    public function setInputSize($inputSize)
+    {
+        $this->inputSize = $inputSize;
+    }
+
+    /**
+     * @return array|null
+     */
+    public function calculateSize()
+    {
+        $size = $this->getColumnsSize();
+
+        if (empty($size)) {
+            $sizeTemp = $this->getInputSize();
+            if (empty($size)) {
+                $sizeTemp = 8;
+            }
+            $size = array(2, $sizeTemp, 2);
+        } else {
+            if (is_array($size)) {
+                if (count($size) != 3) {
+                    $sizeTemp = $this->getInputSize();
+                    if (empty($size)) {
+                        $sizeTemp = 8;
+                    }
+                    $size = array(2, $sizeTemp, 2);
+                }
+            } else {
+                // else just keep the $size array as received
+                $size = array(2, (int) $size, 2);
+            }
+        }
+
+        return $size;
+    }
 }

+ 8 - 6
main/inc/lib/pear/HTML/QuickForm/file.php

@@ -263,7 +263,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
         }
 
         return '<script>
-        $(document).ready(function() {
+        $(function() {
             var $inputFile = $(\'#'.$id.'\'),
                 $image = $(\'#'.$id.'_preview_image\'),
                 $input = $(\'[name="'.$id.'_crop_result"]\'),
@@ -386,6 +386,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
     {
         $name = $this->getName();
         $attributes = $this->getAttributes();
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:
@@ -399,7 +400,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
                 </div>';
                 break;
             case FormValidator::LAYOUT_HORIZONTAL:
-                if (isset($attributes['custom']) && $attributes['custom'] == true) {
+                if (isset($attributes['custom']) && $attributes['custom']) {
                     $template = '
                         <div class="input-file-container">  
                             {element}
@@ -434,12 +435,13 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
                     ';
                 } else {
                     $template = '
-                    <div  id="file_' . $name . '" class="form-group {error_class}">
-                        <label {label-for} class="col-sm-3 control-label" >
+                    <div id="file_'.$name.'" class="form-group {error_class}">
+                        
+                        <label {label-for} class="col-sm-'.$size[0].' control-label" >
                             <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
                             {label}
                         </label>
-                        <div class="col-sm-7">
+                         <div class="col-sm-'.$size[1].'">
                             {icon}
                             {element}
                             <!-- BEGIN label_2 -->
@@ -449,7 +451,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
                                 <span class="help-inline help-block">{error}</span>
                             <!-- END error -->
                         </div>
-                        <div class="col-sm-2">
+                        <div class="col-sm-'.$size[2].'">
                             <!-- BEGIN label_3 -->
                                 {label_3}
                             <!-- END label_3 -->

+ 1 - 16
main/inc/lib/pear/HTML/QuickForm/group.php

@@ -536,22 +536,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $size = array(2, 8, 2);
-        } else {
-            if (is_array($size)) {
-                if (count($size) == 1) {
-                    $size = array(2, intval($size[0]), 2);
-                } elseif (count($size) != 3) {
-                    $size = array(2, 8, 2);
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = array(2, intval($size), 2);
-            }
-        }
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:

+ 1 - 16
main/inc/lib/pear/HTML/QuickForm/select.php

@@ -586,22 +586,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
-
-        if (empty($size)) {
-            $size = array(2, 8, 2);
-        } else {
-            if (is_array($size)) {
-                if (count($size) == 1) {
-                    $size = array(2, intval($size[0]), 2);
-                } elseif (count($size) != 3) {
-                    $size = array(2, 8, 2);
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = array(2, intval($size), 2);
-            }
-        }
+        $size = $this->calculateSize();
 
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:

+ 1 - 40
main/inc/lib/pear/HTML/QuickForm/text.php

@@ -33,8 +33,6 @@
  */
 class HTML_QuickForm_text extends HTML_QuickForm_input
 {
-    private $inputSize;
-
     /**
      * Class constructor
      *
@@ -101,30 +99,9 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
      */
     public function getTemplate($layout)
     {
-        $size = $this->getColumnsSize();
+        $size = $this->calculateSize();
         $attributes = $this->getAttributes();
 
-        if (empty($size)) {
-            $sizeTemp = $this->getInputSize();
-            if (empty($size)) {
-                $sizeTemp = 8;
-            }
-            $size = array(2, $sizeTemp, 2);
-        } else {
-            if (is_array($size)) {
-                if (count($size) != 3) {
-                    $sizeTemp = $this->getInputSize();
-                    if (empty($size)) {
-                        $sizeTemp = 8;
-                    }
-                    $size = array(2, $sizeTemp, 2);
-                }
-                // else just keep the $size array as received
-            } else {
-                $size = array(2, intval($size), 2);
-            }
-        }
-
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:
                 return '
@@ -191,22 +168,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
         }
     }
 
-    /**
-     * @return null
-     */
-    public function getInputSize()
-    {
-        return $this->inputSize;
-    }
-
-    /**
-     * @param null $inputSize
-     */
-    public function setInputSize($inputSize)
-    {
-        $this->inputSize = $inputSize;
-    }
-
     /**
      * Sets size of text field
      *

+ 1 - 0
main/social/home.php

@@ -146,5 +146,6 @@ $tpl->assign('social_friend_block', $friend_html);
 $tpl->assign('social_search_block', $social_search_block);
 $tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id));
 $tpl->assign('social_group_block', $social_group_block);
+$tpl->assign('session_list', $social_session_block);
 $social_layout = $tpl->get_template('social/home.tpl');
 $tpl->display($social_layout);

+ 0 - 1
main/social/profile.php

@@ -244,7 +244,6 @@ if ($show_full_profile) {
 
     // Block Social Sessions
     if (count($sessionList) > 0) {
-        //$social_session_block = $htmlSessionList;
         $social_session_block = $sessionList;
     }
 

+ 1 - 1
main/template/default/forum/list.tpl

@@ -146,7 +146,7 @@
 
             <div class="category-forum {{ category_language }}" id="category_{{ item.id }}">
             {% if fold_forum_categories %}
-                {{ display.collapse('category_' ~ item.id, panel_title, panel_content, false, fold_forum_categories, item.tools, panel_icon ) }}
+                {{ display.collapse('category_' ~ item.id, panel_title, panel_content, false, 'false', item.tools, panel_icon ) }}
             {% else %}
                 {{ display.panel(panel_title, panel_content) }}
             {% endif %}

+ 1 - 3
main/work/work.lib.php

@@ -4009,12 +4009,10 @@ function processWorkForm(
                         $courseId,
                         $sessionId
                     );
-
                     if (count($userWorks) == 1) {
                         // The student only uploaded one doc so far, so add the
                         // considered work time to his course connection time
-                        $ip = api_get_real_ip();
-                        Event::eventAddVirtualCourseTime($courseId, $userId, $sessionId, $workingTime, $ip);
+                        Event::eventAddVirtualCourseTime($courseId, $userId, $sessionId, $workingTime);
                     }
                 }
             }

+ 52 - 52
plugin/questionoptionsevaluation/QuestionOptionsEvaluationPlugin.php

@@ -86,58 +86,6 @@ class QuestionOptionsEvaluationPlugin extends Plugin
         return $this;
     }
 
-    /**
-     * @param int      $formula
-     * @param Exercise $exercise
-     */
-    private function recalculateQuestionScore($formula, Exercise $exercise)
-    {
-        foreach ($exercise->questionList as $questionId) {
-            $question = Question::read($questionId);
-
-            if (!in_array($question->selectType(), [UNIQUE_ANSWER, MULTIPLE_ANSWER])) {
-                continue;
-            }
-
-            $questionAnswers = new Answer($questionId, $exercise->course_id, $exercise);
-            $counts = array_count_values($questionAnswers->correct);
-            $weighting = [];
-
-            foreach ($questionAnswers->correct as $i => $correct) {
-                if ($question->selectType() == MULTIPLE_ANSWER || 0 === $formula) {
-                    $weighting[$i] = 1 == $correct ? 1 / $counts[1] : -1 / $counts[0];
-
-                    continue;
-                }
-
-                if ($question->selectType() == UNIQUE_ANSWER) {
-                    $weighting[$i] = 1 == $correct ? 1 : -1 / $formula;
-                }
-            }
-
-            $questionAnswers->new_nbrAnswers = $questionAnswers->nbrAnswers;
-            $questionAnswers->new_answer = $questionAnswers->answer;
-            $questionAnswers->new_comment = $questionAnswers->comment;
-            $questionAnswers->new_correct = $questionAnswers->correct;
-            $questionAnswers->new_weighting = $weighting;
-            $questionAnswers->new_position = $questionAnswers->position;
-            $questionAnswers->new_destination = $questionAnswers->destination;
-            $questionAnswers->new_hotspot_coordinates = $questionAnswers->hotspot_coordinates;
-            $questionAnswers->new_hotspot_type = $questionAnswers->hotspot_type;
-
-            $allowedWeights = array_filter(
-                $weighting,
-                function ($weight) {
-                    return $weight > 0;
-                }
-            );
-
-            $questionAnswers->save();
-            $question->updateWeighting(array_sum($allowedWeights));
-            $question->save($exercise);
-        }
-    }
-
     /**
      * @param int      $formula
      * @param Exercise $exercise
@@ -247,6 +195,58 @@ class QuestionOptionsEvaluationPlugin extends Plugin
         return ($result / count($qTracks)) * $this->getMaxScore();
     }
 
+    /**
+     * @param int      $formula
+     * @param Exercise $exercise
+     */
+    private function recalculateQuestionScore($formula, Exercise $exercise)
+    {
+        foreach ($exercise->questionList as $questionId) {
+            $question = Question::read($questionId);
+
+            if (!in_array($question->selectType(), [UNIQUE_ANSWER, MULTIPLE_ANSWER])) {
+                continue;
+            }
+
+            $questionAnswers = new Answer($questionId, $exercise->course_id, $exercise);
+            $counts = array_count_values($questionAnswers->correct);
+            $weighting = [];
+
+            foreach ($questionAnswers->correct as $i => $correct) {
+                if ($question->selectType() == MULTIPLE_ANSWER || 0 === $formula) {
+                    $weighting[$i] = 1 == $correct ? 1 / $counts[1] : -1 / $counts[0];
+
+                    continue;
+                }
+
+                if ($question->selectType() == UNIQUE_ANSWER) {
+                    $weighting[$i] = 1 == $correct ? 1 : -1 / $formula;
+                }
+            }
+
+            $questionAnswers->new_nbrAnswers = $questionAnswers->nbrAnswers;
+            $questionAnswers->new_answer = $questionAnswers->answer;
+            $questionAnswers->new_comment = $questionAnswers->comment;
+            $questionAnswers->new_correct = $questionAnswers->correct;
+            $questionAnswers->new_weighting = $weighting;
+            $questionAnswers->new_position = $questionAnswers->position;
+            $questionAnswers->new_destination = $questionAnswers->destination;
+            $questionAnswers->new_hotspot_coordinates = $questionAnswers->hotspot_coordinates;
+            $questionAnswers->new_hotspot_type = $questionAnswers->hotspot_type;
+
+            $allowedWeights = array_filter(
+                $weighting,
+                function ($weight) {
+                    return $weight > 0;
+                }
+            );
+
+            $questionAnswers->save();
+            $question->updateWeighting(array_sum($allowedWeights));
+            $question->save($exercise);
+        }
+    }
+
     /**
      * Creates an extrafield.
      */

+ 2 - 2
src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.php

@@ -174,8 +174,8 @@ class ChamiloApi
     /**
      * Adds or Subtract a time in hh:mm:ss to a datetime.
      *
-     * @param string $time      Time in hh:mm:ss format
-     * @param string $datetime  Datetime as accepted by the Datetime class constructor
+     * @param string $time      Time to add or substract in hh:mm:ss format
+     * @param string $datetime  Datetime to be modified as accepted by the Datetime class constructor
      * @param bool   $operation True for Add, False to Subtract
      *
      * @return string

+ 0 - 145
tests/scripts/proxy.php

@@ -1,145 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
- * Script needed in order to avoid mixed content in links inside a learning path
- * In order to use this file you have to:
- *
- * 1. Modify configuration.php and add this setting: $_configuration['lp_fix_embed_content'] = true;
- * 2. Copy this file in app/courses/proxy.php
- * 3. Change your .htaccess in order to let the proxy.php to be read inside app/courses
- *
- */
-
-require_once '../config/configuration.php';
-
-/**
- * Returns "%" or "px"
- *
- * 800px => function returns "px"
- * 800% => function returns %
- *
- * @param string $value
- * @return string
- */
-function addPixelOrPercentage($value)
-{
-    $addPixel = strpos($value, 'px');
-    $addPixel = !($addPixel === false);
-    $addCharacter = '';
-    if ($addPixel == false) {
-        $addPercentage = strpos($value, '%');
-        $addPercentage = !($addPercentage === false);
-        if ($addPercentage) {
-            $addCharacter = '%';
-        }
-    } else {
-        $addCharacter = 'px';
-    }
-
-    return $addCharacter;
-}
-
-function get_http_response_code($theURL)
-{
-    $headers = get_headers($theURL);
-
-    return substr($headers[0], 9, 3);
-}
-
-
-$height = isset($_GET['height']) ? (int) $_GET['height'].addPixelOrPercentage($_GET['height']) : '';
-$width = isset($_GET['width']) ? (int) $_GET['width'].addPixelOrPercentage($_GET['width'])  : '';
-$vars = isset($_GET['flashvars']) ? htmlentities($_GET['flashvars']) : '';
-$src = isset($_GET['src']) ? htmlentities($_GET['src']) : '';
-$id = isset($_GET['id']) ? htmlentities($_GET['id']) : '';
-$type = isset($_GET['type']) ? $_GET['type'] : 'flash';
-
-// Fixes URL like: https://www.vopspsy.ugent.be/pdfs/download.php?own=mvsteenk&file=caleidoscoop.pdf
-if (strpos($src, 'download.php') !== false) {
-    $src = str_replace('download.php', 'download.php?', $src);
-    $src .= isset($_GET['own']) ? '&own='.htmlentities($_GET['own']) : '';
-    $src .= isset($_GET['file']) ? '&file='.htmlentities($_GET['file']) : '';
-}
-
-$result = get_http_response_code($src);
-$urlToTest = parse_url($src, PHP_URL_HOST);
-$g = stream_context_create (array('ssl' => array('capture_peer_cert' => true)));
-$r = @stream_socket_client("ssl://$urlToTest:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $g);
-$cont = stream_context_get_params($r);
-$convertToSecure = false;
-
-$certinfo = openssl_x509_parse($cont['options']['ssl']['peer_certificate']);
-if (isset($certinfo) && isset($certinfo['subject']) && isset($certinfo['subject']['CN'])) {
-    $certUrl = $certinfo['subject']['CN'];
-    $parsed = parse_url($certUrl);
-
-    // Remove www from URL
-    $parsedUrl = preg_replace('#^(http(s)?://)?w{3}\.#', '$1', $certUrl);
-
-    if ($urlToTest == $certUrl || $parsedUrl == $urlToTest) {
-        $convertToSecure = true;
-    }
-
-    if ($urlToTest != $certUrl) {
-        // url and cert url are different this will show a warning in browsers
-        // use normal "http" version
-        $result = false;
-    }
-}
-
-if ($result == false) {
-    $src = str_replace('https', 'http', $src);
-}
-
-if ($convertToSecure) {
-    $src = str_replace('http', 'https', $src);
-}
-
-$result = '';
-switch ($type) {
-    case 'link':
-        // Check if links comes from a course
-        $srcParts = explode('/', $src);
-        $srcParts = array_filter($srcParts);
-        $srcParts = array_values($srcParts);
-
-        if (isset($srcParts[0], $srcParts[2]) && $srcParts[0] === 'courses' && $srcParts[2] === 'document') {
-            $src = $_configuration['root_web'].$src;
-        }
-
-        if (strpos($src, 'http') === false) {
-            $src = "http://$src";
-        }
-        header('Location: '.$src);
-        exit;
-        break;
-    case 'iframe':
-        $result = '<iframe src="'.$src.'" width="'.$width.'" height="'.$height.'" ></iframe>';
-        break;
-    case 'flash':
-        $result =  '
-        <object 
-            id="'.$id.'" width="'.$width.'" height="'.$height.'" align="center"
-            codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-            <param name="id" value="'.$id.'">
-            <param name="width" value="'.$width.'">
-            <param name="height" value="'.$height.'">
-            <param name="bgcolor" value="#ffffff">
-            <param name="align" value="center">
-            <param name="allowfullscreen" value="true">
-            <param name="allowscriptaccess" value="always">
-            <param name="quality" value="high">
-            <param name="wmode" value="transparent">
-            <param name="flashvars" value="'.$vars.'">
-            <param name="src" value="'.$src.'">
-            <embed 
-                id="'.$id.'" width="'.$width.'" height="'.$height.'" bgcolor="#ffffff" align="center" 
-                allowfullscreen="true" allowscriptaccess="always" quality="high" wmode="transparent" 
-                flashvars="'.$vars.'" src="'.$src.'"
-                type="application/x-shockwave-flash" 
-            >
-        </object>';
-}
-
-echo $result;