Browse Source

Merge remote-tracking branch 'origin/1.10.x' into 1.10.x

Yannick Warnier 9 years ago
parent
commit
288426e6bc

+ 8 - 2
main/admin/settings.lib.php

@@ -758,7 +758,7 @@ function handle_search()
         $group = array();
         $url =  Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
         if (empty($sf_values)) {
-            $form->addElement('html', get_lang('SearchPrefilterPrefix').$url);
+            $form->addElement('label', [get_lang('SearchPrefilterPrefix'), $url]);
         } else {
             $form->addElement('select', 'search_prefilter_prefix', array(get_lang('SearchPrefilterPrefix'), $url), $sf_values, '');
             $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
@@ -839,8 +839,14 @@ function handle_search()
             $list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv');
 
             foreach($list_of_programs as $program) {
-                $output = $ret_val = null;
+                $output = [];
+                $ret_val = null;
                 exec("which $program", $output, $ret_val);
+
+                if (!$output) {
+                    $output[] = '';
+                }
+
                 $icon = Display::return_icon('bullet_red.png', get_lang('NotInstalled'));
                 if (!empty($output[0])) {
                     $icon = Display::return_icon('bullet_green.png', get_lang('Installed'));

+ 7 - 7
main/admin/specific_fields.php

@@ -17,7 +17,6 @@ api_protect_admin_script();
 // Breadcrumb
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
-$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
 
 $libpath = api_get_path(LIBRARY_PATH);
 
@@ -30,16 +29,16 @@ $renderer->setCustomElementTemplate('<span>{element}</span> ');
 $form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
 
 // Create a sortable table with specific fields data
-$column_show = array(1,1,1,1);
-$column_order = array(3,2,1,4);
+$column_show = array(1,1,1);
+$column_order = array(3,2,1);
 $extra_fields = get_specific_field_list();
 $number_of_extra_fields = count($extra_fields);
 
 $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
-$table->set_header(0, '', false,null,'width="2%"', 'style="display:none"');
+$table->set_header(0, '&nbsp;', false,null,'width="2%"', 'style="display:none"');
 $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
 $table->set_header(2, get_lang('Name'));
-$table->set_header(3, get_lang('Modify'),true,'width="10%"');
+$table->set_header(3, get_lang('Modify'),false,'width="10%"');
 $table->set_column_filter(3, 'edit_filter');
 
 function edit_filter($id,$url_params,$row) {
@@ -49,15 +48,16 @@ function edit_filter($id,$url_params,$row) {
 	return $return;
 }
 
-if ($_REQUEST['action'] == 'delete') {
+if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
 	delete_specific_field($_REQUEST['field_id']);
 	header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
+    exit;
 }
 
 // Start output
 
 // Displaying the header
-Display::display_header($nameTools);
+Display::display_header(get_lang('SpecificSearchFields'));
 echo Display::display_normal_message(get_lang('SpecificSearchFieldsIntro'));
 
 if(!empty($_GET['message'])) {

+ 9 - 6
main/admin/specific_fields_add.php

@@ -18,18 +18,21 @@ $this_section = SECTION_PLATFORM_ADMIN;
 // user permissions
 api_protect_admin_script();
 
+$fieldId = isset($_REQUEST['field_id']) ? intval($_REQUEST['field_id']) : 0;
+
 $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
 $interbreadcrumb[] = array('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
 $interbreadcrumb[] = array('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
-if ($_GET['action']<>'edit') {
-  $tool_name = get_lang('AddSpecificSearchField');
-} else {
+
+$tool_name = get_lang('AddSpecificSearchField');
+
+if (isset($_GET['action']) && $_GET['action'] === 'edit') {
   $tool_name = get_lang('EditSpecificSearchField');
 }
 // Create the form
 $form = new FormValidator('specific_fields_add');
 // Field variable name
-$form->addElement('hidden','field_id',(int)$_REQUEST['field_id']);
+$form->addElement('hidden','field_id', $fieldId);
 $form->addElement('text','field_name',get_lang('FieldName'));
 $form->applyFilter('field_name','html_filter');
 $form->applyFilter('field_name','trim');
@@ -39,8 +42,8 @@ $form->addRule('field_name', '', 'maxlength',20);
 
 // Set default values (only not empty when editing)
 $defaults = array();
-if (is_numeric($_REQUEST['field_id'])) {
-    $form_information = get_specific_field_list(array( 'id' => (int)$_GET['field_id'] ));
+if ($fieldId) {
+    $form_information = get_specific_field_list(array( 'id' => $fieldId ));
     $defaults['field_name'] = $form_information[0]['name'];
 }
 $form->setDefaults($defaults);

+ 52 - 22
main/calendar/agenda.php

@@ -57,6 +57,33 @@ function plus_repeated_event() {
 </script>
 ";
 
+
+$htmlHeadXtra[] = '<script type="text/javascript">
+var counter_image = 1;
+function add_image_form() {
+	// Multiple filepaths for image form
+	var filepaths = document.getElementById("filepaths");
+	if (document.getElementById("filepath_"+counter_image)) {
+		counter_image = counter_image + 1;
+	}  else {
+		counter_image = counter_image;
+	}
+	var elem1 = document.createElement("div");
+	elem1.setAttribute("id","filepath_"+counter_image);
+	filepaths.appendChild(elem1);
+	id_elem1 = "filepath_"+counter_image;
+	id_elem1 = "\'"+id_elem1+"\'";
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" />&nbsp; <br />'.get_lang('Description').'&nbsp;&nbsp;<input type=\"text\" name=\"legend[]\"  /><br /><br />";
+	if (filepaths.childNodes.length == 6) {
+		var link_attach = document.getElementById("link-more-attach");
+		if (link_attach) {
+			link_attach.innerHTML="";
+		}
+	}
+}
+</script>';
+
+
 // setting the name of the tool
 $nameTools = get_lang('Agenda');
 
@@ -90,8 +117,8 @@ $content = null;
 
 if (api_is_allowed_to_edit(false, true) ||
     (api_get_course_setting('allow_user_edit_agenda') &&
-    !api_is_anonymous() &&
-    api_is_allowed_to_session_edit(false, true)) ||
+        !api_is_anonymous() &&
+        api_is_allowed_to_session_edit(false, true)) ||
     GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) &&
     GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
 ) {
@@ -106,10 +133,9 @@ if (api_is_allowed_to_edit(false, true) ||
                 $sendEmail = isset($values['add_announcement']) ? true : false;
                 $allDay = isset($values['all_day']) ? 'true' : 'false';
 
-                $sendAttachment = isset($_FILES['user_upload']) ? true : false;
-                $attachment = $sendAttachment ? $_FILES['user_upload'] : null;
-                $attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
-
+                $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false;
+                $attachmentList = $sendAttachment ? $_FILES : null;
+                $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null;
                 $comment = isset($values['comment']) ? $values['comment'] : null;
 
                 $startDate = $values['date_range_start'];
@@ -124,8 +150,8 @@ if (api_is_allowed_to_edit(false, true) ||
                     $values['users_to_send'],
                     $sendEmail,
                     null,
-                    $attachment,
-                    $attachmentComment,
+                    $attachmentList,
+                    $attachmentCommentList,
                     $comment
                 );
 
@@ -167,12 +193,14 @@ if (api_is_allowed_to_edit(false, true) ||
                 $values = $form->getSubmitValues();
 
                 $allDay = isset($values['all_day']) ? 'true' : 'false';
+                $sendEmail = isset($values['add_announcement']) ? true : false;
                 $startDate = $values['date_range_start'];
                 $endDate = $values['date_range_end'];
-                $sendEmail = isset($values['add_announcement']) ? true : false;
-                $sendAttachment = isset($_FILES['user_upload']) ? true : false;
-                $attachment = $sendAttachment ? $_FILES['user_upload'] : null;
-                $attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
+
+                $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false;
+                $attachmentList = $sendAttachment ? $_FILES : null;
+                $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null;
+
                 $comment = isset($values['comment']) ? $values['comment'] : null;
 
                 // This is a sub event. Delete the current and create another BT#7803
@@ -189,8 +217,8 @@ if (api_is_allowed_to_edit(false, true) ||
                         $values['users_to_send'],
                         false,
                         null,
-                        $attachment,
-                        $attachmentComment,
+                        $attachmentList,
+                        $attachmentCommentList,
                         $comment
                     );
 
@@ -209,8 +237,8 @@ if (api_is_allowed_to_edit(false, true) ||
                     $values['title'],
                     $values['content'],
                     $values['users_to_send'],
-                    $attachment,
-                    $attachmentComment,
+                    $attachmentList,
+                    $attachmentCommentList,
                     $comment,
                     '',
                     $sendEmail
@@ -227,13 +255,15 @@ if (api_is_allowed_to_edit(false, true) ||
                     );
                 }
 
-                $deleteAttachment = isset($values['delete_attachment']) ? true : false;
+                $deleteAttachmentList = isset($values['delete_attachment']) ? $values['delete_attachment'] : array();
 
-                if ($deleteAttachment && isset($event['attachment']) && !empty($event['attachment'])) {
-                    $agenda->deleteAttachmentFile(
-                        $event['attachment']['id'],
-                        $agenda->course
-                    );
+                if (!empty($deleteAttachmentList)) {
+                    foreach ($deleteAttachmentList as $deleteAttachmentId => $value) {
+                        $agenda->deleteAttachmentFile(
+                            $deleteAttachmentId,
+                            $agenda->course
+                        );
+                    }
                 }
 
                 $message = Display::return_message(get_lang('Updated'), 'confirmation');

+ 2 - 2
main/document/upload.php

@@ -258,11 +258,11 @@ if (api_get_setting('search_enabled') == 'true') {
     $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument').'<div style="font-size: 80%" >'.$supported_formats.'</div>');
     $form->addElement('html', '<br /><div class="sub-form">');
     $form->addElement('html', '<div class="label">'.get_lang('SearchFeatureDocumentLanguage').'</div>');
-    $form->addElement('html', '<div>' . api_get_languages_combo(null) . '</div>');
+    $form->addLabel(get_lang('Language'), api_get_languages_combo());
     $form->addElement('html', '</div><div class="sub-form">');
     $specific_fields = get_specific_field_list();
     foreach ($specific_fields as $specific_field) {
-        $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
+        $form->addElement('text', $specific_field['code'], $specific_field['name']);
     }
     $form->addElement('html', '</div>');
 }

+ 6 - 1
main/exercice/exercise.class.php

@@ -1315,7 +1315,12 @@ class Exercise
 
                 foreach ($specific_fields as $specific_field) {
                     $form->addElement ('text', $specific_field['code'], $specific_field['name']);
-                    $filter = array('c_id'=> "'". api_get_course_int_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\'');
+                    $filter = array(
+                        'c_id' => api_get_course_int_id(),
+                        'field_id' => $specific_field['id'],
+                        'ref_id' => $this->id,
+                        'tool_id' => "'" . TOOL_QUIZ . "'"
+                    );
                     $values = get_specific_field_values_list($filter, array('value'));
                     if ( !empty($values) ) {
                         $arr_str_values = array();

+ 119 - 51
main/inc/lib/agenda.lib.php

@@ -48,6 +48,7 @@ class Agenda
         $this->event_session_color = '#00496D'; // kind of green
         $this->eventOtherSessionColor = '#999';
         $this->event_personal_color = 'steel blue'; //steel blue
+
     }
 
     /**
@@ -120,8 +121,8 @@ class Agenda
      * @param array   $usersToSend array('everyone') or a list of user/group ids
      * @param bool    $addAsAnnouncement event as a *course* announcement
      * @param int $parentEventId
-     * @param array $attachmentArray $_FILES['']
-     * @param string $attachmentComment
+     * @param array $attachmentArray array of $_FILES['']
+     * @param array $attachmentCommentList
      * @param string $eventComment
      * @param string $color
      *
@@ -137,8 +138,8 @@ class Agenda
         $addAsAnnouncement = false,
         $parentEventId = null,
         $attachmentArray = array(),
-        $attachmentComment = '',
-        $eventComment = '',
+        $attachmentCommentList = array(),
+        $eventComment = null,
         $color = ''
     ) {
         $start = api_get_utc_datetime($start);
@@ -294,12 +295,16 @@ class Agenda
 
                     // Add attachment.
                     if (isset($attachmentArray) && !empty($attachmentArray)) {
-                        $this->addAttachment(
-                            $id,
-                            $attachmentArray,
-                            $attachmentComment,
-                            $this->course
-                        );
+                        $counter = 0;
+                        foreach ($attachmentArray as $attachmentItem) {
+                            $this->addAttachment(
+                                $id,
+                                $attachmentItem,
+                                $attachmentCommentList[$counter],
+                                $this->course
+                            );
+                            $counter++;
+                        }
                     }
                 }
                 break;
@@ -555,7 +560,7 @@ class Agenda
      * @param string $content
      * @param array $usersToSend
      * @param array $attachmentArray
-     * @param string $attachmentComment
+     * @param array $attachmentCommentList
      * @param string $comment
      * @param string $color
      * @param bool $addAnnouncement
@@ -571,8 +576,8 @@ class Agenda
         $content,
         $usersToSend = array(),
         $attachmentArray = array(),
-        $attachmentComment = '',
-        $comment = '',
+        $attachmentCommentList = array(),
+        $comment = null,
         $color = '',
         $addAnnouncement = false
     ) {
@@ -781,12 +786,17 @@ class Agenda
 
                     // Add attachment.
                     if (isset($attachmentArray) && !empty($attachmentArray)) {
-                        $this->updateAttachment(
-                            $id,
-                            $attachmentArray,
-                            $attachmentComment,
-                            $this->course
-                        );
+                        $counter = 0;
+                        foreach ($attachmentArray as $attachmentItem) {
+                            $this->updateAttachment(
+                                $attachmentItem['id'],
+                                $id,
+                                $attachmentItem,
+                                $attachmentCommentList[$counter],
+                                $this->course
+                            );
+                            $counter++;
+                        }
                     }
                 }
                 break;
@@ -828,10 +838,11 @@ class Agenda
                 break;
             case 'course':
                 $course_id = api_get_course_int_id();
+
                 if (!empty($course_id) && api_is_allowed_to_edit(null, true)) {
                     // Delete
+                    $eventInfo = $this->get_event($id);
                     if ($deleteAllItemsFromSerie) {
-                        $eventInfo = $this->get_event($id);
                         /* This is one of the children.
                            Getting siblings and delete 'Em all + the father! */
                         if (isset($eventInfo['parent_event_id']) && !empty($eventInfo['parent_event_id'])) {
@@ -874,6 +885,12 @@ class Agenda
                         $this->table_repeat,
                         array('cal_id = ? AND c_id = ?' => array($id, $course_id))
                     );
+
+                    if (isset($eventInfo['attachment']) && !empty($eventInfo['attachment'])) {
+                        foreach ($eventInfo['attachment'] as $attachment) {
+                            self::deleteAttachmentFile($attachment['id'], $this->course);
+                        }
+                    }
                 }
                 break;
             case 'admin':
@@ -1207,7 +1224,7 @@ class Agenda
                             $event['parent_info'] = $this->get_event($event['parent_event_id']);
                         }
 
-                        $event['attachment'] = $this->getAttachment($id, $this->course);
+                        $event['attachment'] = $this->getAttachmentList($id, $this->course);
                     }
                 }
                 break;
@@ -1368,15 +1385,15 @@ class Agenda
         if (!empty($courses)) {
             foreach ($courses as $course) {
                 //if (api_is_coach($sessionId, $course['real_id'])) {
-                    $this->getCourseEvents(
-                        $start,
-                        $end,
-                        $course,
-                        0,
-                        $sessionId,
-                        0,
-                        $color
-                    );
+                $this->getCourseEvents(
+                    $start,
+                    $end,
+                    $course,
+                    0,
+                    $sessionId,
+                    0,
+                    $color
+                );
                 //}
             }
         }
@@ -1600,15 +1617,16 @@ class Agenda
                 );
                 $group_to_array = $items['groups'];
                 $user_to_array = $items['users'];
-                $attachment = $this->getAttachment($row['id'], $courseInfo);
-
-                if (!empty($attachment)) {
-                    $has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment'));
-                    $user_filename = $attachment['filename'];
-                    $url = api_get_path(WEB_CODE_PATH).'calendar/download.php?file='.$attachment['path'].'&course_id='.$course_id.'&'.api_get_cidreq();
-                    $event['attachment'] = $has_attachment.Display::url($user_filename, $url);
-                } else {
-                    $event['attachment'] = '';
+                $attachmentList = $this->getAttachmentList($row['id'], $courseInfo);
+                $event['attachment'] = '';
+
+                if (!empty($attachmentList)) {
+                    foreach ($attachmentList as $attachment) {
+                        $has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment'));
+                        $user_filename = $attachment['filename'];
+                        $url = api_get_path(WEB_CODE_PATH).'calendar/download.php?file='.$attachment['path'].'&course_id='.$course_id.'&'.api_get_cidreq();
+                        $event['attachment'] .= $has_attachment.Display::url($user_filename, $url).'<br />';
+                    }
                 }
 
                 $event['title'] = $row['title'];
@@ -2122,21 +2140,38 @@ class Agenda
 
         if ($this->type == 'course') {
             $form->addElement('textarea', 'comment', get_lang('Comment'));
-            $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
-            if ($showAttachmentForm) {
-                if (isset($params['attachment']) && !empty($params['attachment'])) {
-                    $attachment = $params['attachment'];
+            $form->addLabel(
+                get_lang('FilesAttachment'),
+                '<span id="filepaths">
+                        <div id="filepath_1">
+                            <input type="file" name="attach_1"/><br />
+                            '.get_lang('Description').'&nbsp;&nbsp;<input type="text" name="legend[]" /><br /><br />
+                        </div>
+                    </span>'
+            );
+
+            $form->addLabel('',
+                '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
+
+
+            //if ($showAttachmentForm) {
+
+            if (isset($params['attachment']) && !empty($params['attachment'])) {
+                $attachmentList = $params['attachment'];
+                foreach ($attachmentList as $attachment) {
                     $params['file_comment'] = $attachment['comment'];
                     if (!empty($attachment['path'])) {
                         $form->addElement(
                             'checkbox',
-                            'delete_attachment',
+                            'delete_attachment['.$attachment['id'].']',
                             null,
-                            get_lang('DeleteAttachment').' '.$attachment['filename']
+                            get_lang('DeleteAttachment').': '.$attachment['filename']
                         );
                     }
                 }
+
             }
+            // }
 
             $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
         }
@@ -2257,18 +2292,50 @@ class Agenda
      * @param array $courseInfo
      * @return array with the post info
      */
-    public function getAttachment($eventId, $courseInfo)
+    public function getAttachmentList($eventId, $courseInfo)
     {
         $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
         $courseId = intval($courseInfo['real_id']);
         $eventId = intval($eventId);
-        $row = array();
+
         $sql = "SELECT id, path, filename, comment
                 FROM $tableAttachment
                 WHERE
                     c_id = $courseId AND
                     agenda_id = $eventId";
         $result = Database::query($sql);
+        $list = array();
+        if (Database::num_rows($result) != 0) {
+            $list = Database::store_result($result, 'ASSOC');
+        }
+
+        return $list;
+    }
+
+
+    /**
+     * Show a list with all the attachments according to the post's id
+     * @param int $attachmentId
+     * @param int $eventId
+     * @param array $courseInfo
+     * @return array with the post info
+     */
+    public function getAttachment($attachmentId, $eventId, $courseInfo)
+    {
+        $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
+        $courseId = intval($courseInfo['real_id']);
+        $eventId = intval($eventId);
+        $attachmentId = intval($attachmentId);
+
+        $row = array();
+        $sql = "SELECT id, path, filename, comment
+                FROM $tableAttachment
+                WHERE
+                    c_id = $courseId AND
+                    agenda_id = $eventId AND
+                    id = $attachmentId
+                ";
+        $result = Database::query($sql);
         if (Database::num_rows($result) != 0) {
             $row = Database::fetch_array($result, 'ASSOC');
         }
@@ -2349,16 +2416,17 @@ class Agenda
     }
 
     /**
+     * @param int $attachmentId
      * @param int $eventId
      * @param array $fileUserUpload
      * @param string $comment
      * @param array $courseInfo
      */
-    public function updateAttachment($eventId, $fileUserUpload, $comment, $courseInfo)
+    public function updateAttachment($attachmentId, $eventId, $fileUserUpload, $comment, $courseInfo)
     {
-        $attachment = $this->getAttachment($eventId, $courseInfo);
+        $attachment = $this->getAttachment($attachmentId, $eventId, $courseInfo);
         if (!empty($attachment)) {
-            $this->deleteAttachmentFile($attachment['id'], $courseInfo);
+            $this->deleteAttachmentFile($attachmentId, $courseInfo);
         }
         $this->addAttachment($eventId, $fileUserUpload, $comment, $courseInfo);
     }
@@ -3176,7 +3244,7 @@ class Agenda
                     if (!empty($agendaitems[$curday])) {
                         $items =  $agendaitems[$curday];
                         $items =  msort($items, 'start_date_tms');
-                        
+
                         foreach($items  as $value) {
                             $value['title'] = Security::remove_XSS($value['title']);
                             $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);

+ 1 - 1
main/inc/lib/api.lib.php

@@ -4179,7 +4179,7 @@ function api_get_languages_combo($name = 'language')
     $languages  = $language_list['name'];
     $folder     = $language_list['folder'];
 
-    $ret .= '<select name="' . $name . '" id="language_chosen">';
+    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
     foreach ($languages as $key => $value) {
         if ($folder[$key] == $default) {
             $selected = ' selected="selected"';

+ 65 - 69
main/inc/lib/blog.lib.php

@@ -26,7 +26,6 @@ class Blog
 	    $course_id = api_get_course_int_id();
 
 		if (is_numeric($blog_id)) {
-			// init
 			$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
 
 			$sql = "SELECT blog_name
@@ -35,6 +34,7 @@ class Blog
 
 			$result = Database::query($sql);
 			$blog = Database::fetch_array($result);
+
 			return stripslashes($blog['blog_name']);
 		}
 	}
@@ -96,8 +96,8 @@ class Blog
 	/**
 	 * Creates a new blog in the given course
 	 * @author Toon Keppens
-	 * @param Integer $course_id Id
-	 * @param String $title
+	 * @param int $course_id Id
+	 * @param string $title
 	 * @param Text $description
 	 */
 	public static function create_blog($title, $subtitle)
@@ -111,7 +111,6 @@ class Blog
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
-        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
 
 		//verified if exist blog
 		$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
@@ -186,9 +185,9 @@ class Blog
 	/**
 	 * Update title and subtitle of a blog in the given course
 	 * @author Toon Keppens
-	 * @param Integer $course_id Id
-	 * @param String $title
-	 * @param Text $description
+	 * @param int $course_id Id
+	 * @param string $title
+	 * @param string $description
 	 */
 	public static function edit_blog($blog_id, $title, $subtitle)
 	{
@@ -238,7 +237,6 @@ class Blog
         $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
         $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
-		$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
 
         $course_id = api_get_course_int_id();
         $blog_id = intval($blog_id);
@@ -545,7 +543,6 @@ class Blog
 	 */
 	public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
 	{
-		// Init
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
 		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
 
@@ -1395,11 +1392,11 @@ class Blog
 			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
 			echo "<table class=\"data_table\">";
 			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
-				"</tr>\n";
+					 "<th width='240'><b>",get_lang('Title'),"</b></th>",
+					 "<th><b>",get_lang('Description'),"</b></th>",
+					 "<th><b>",get_lang('Color'),"</b></th>",
+					 "<th width='50'><b>",get_lang('Modify'),"</b></th>",
+				"</tr>";
 
 
 			$sql = " SELECT
@@ -1415,29 +1412,29 @@ class Blog
                     ORDER BY system_task, title";
 			$result = Database::query($sql);
 
-
-			while($task = Database::fetch_array($result)) {
+			while ($task = Database::fetch_array($result)) {
 				$counter++;
 				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
-				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
+				$delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png";
 				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
 				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
 				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
 
-				echo	'<tr class="' . $css_class . '" valign="top">',
-                         '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
-                         '<td>' . Security::remove_XSS($task['description']) . '</td>',
-                         '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
-                         '<td width="50">',
-                            '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
-                            '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
-                            "</a>\n",
-                            '<a href="' . $delete_link . '"',
-                            $delete_confirm,
-                            '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
-                            "</a>\n",
-                         '</td>',
-                    '</tr>';
+				echo '<tr class="' . $css_class . '" valign="top">';
+                echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>';
+                echo '<td>'.Security::remove_XSS($task['description']).'</td>';
+                echo '<td><span style="background-color: #'.$task['color'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>';
+                echo '<td width="50">';
+                echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">',
+                echo Display::return_icon('edit.png', get_lang('EditTask'));
+                      echo "</a>";
+                      echo '<a href="'.$delete_link.'"';
+                      echo $delete_confirm;
+                       echo '>';
+                        echo Display::return_icon($delete_icon, $delete_title);
+                       echo "</a>";
+                     echo '</td>';
+                   echo '</tr>';
 			}
 			echo "</table>";
 		}
@@ -1461,11 +1458,11 @@ class Blog
 		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
 		echo "<table class=\"data_table\">";
 		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
+				 "<th width='240'><b>",get_lang('Member'),"</b></th>",
+				 "<th><b>",get_lang('Task'),"</b></th>",
+				 "<th><b>",get_lang('Description'),"</b></th>",
+				 "<th><b>",get_lang('TargetDate'),"</b></th>",
+				 "<th width='50'><b>",get_lang('Modify'),"</b></th>",
 			"</tr>";
 
 		$course_id = api_get_course_int_id();
@@ -1484,28 +1481,32 @@ class Blog
 		while ($assignment = Database::fetch_array($result)) {
 			$counter++;
 			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
-			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
+			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png";
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
 			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
 			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
 
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
 
-			echo	'<tr class="' . $css_class . '" valign="top">',
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
-						 '<td>' . $assignment['target_date'] . '</td>',
-						 '<td width="50">',
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
-							"</a>\n",
-							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
-							"</a>\n",
-						 '</td>',
-					'</tr>';
+            echo '<tr class="'.$css_class.'" valign="top">';
+            echo '<td width="240">'.Display::tag(
+                    'span',
+                    api_get_person_name($assignment['firstname'], $assignment['lastname']),
+                    array('title' => $username)
+                ).'</td>';
+            echo '<td>'.stripslashes($assignment['title']).'</td>';
+            echo '<td>'.stripslashes($assignment['description']).'</td>';
+            echo '<td>'.$assignment['target_date'].'</td>';
+            echo '<td width="50">';
+            echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">',
+	            echo Display::return_icon('edit.png', get_lang('EditTask'));
+				echo "</a>";
+				echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ';
+				echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
+                echo Display::return_icon($delete_icon, $delete_title);
+				echo "</a>";
+				echo '</td>';
+				echo '</tr>';
 		}
 		echo "</table>";
 	}
@@ -2396,12 +2397,12 @@ class Blog
 		}
 
 		echo 	'<table id="smallcalendar" class="table table-responsive">',
-				"<tr id=\"title\">\n",
-				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
-				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
-				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
+				"<tr id=\"title\">",
+				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>",
+				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>",
+				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>", "</tr>";
 
-		echo "<tr>\n";
+		echo "<tr>";
 
 		for($ii = 1; $ii < 8; $ii ++)
 			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
@@ -2438,8 +2439,9 @@ class Blog
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
 							// Add tasks to calendar
 							foreach ($tasks[$curday] as $task) {
-								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
-								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
+								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">';
+								echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask'));
+                                echo '</a>';
 							}
 						}
 					}
@@ -2527,7 +2529,6 @@ class Blog
 
 		//condition for the session
 		$session_id = api_get_session_id();
-		$condition_session = api_get_session_condition($session_id, false);
 
 		$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
 				FROM $tbl_blogs WHERE c_id = $course_id
@@ -2561,27 +2562,22 @@ class Blog
 			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
                                 $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
 
-				$my_image.= "</a>\n";
+				$my_image.= "</a>";
 				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
 				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
                                 $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
 
-				$my_image.= "</a>\n";
+				$my_image.= "</a>";
 				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
                                 $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
 
-				$my_image.= "</a>\n";
-
+				$my_image.= "</a>";
 				$list_body_blog[]=$my_image;
-
 				$list_content_blog[]=$list_body_blog;
 				$list_body_blog = array();
-
 			}
-			$parameters='';
-			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
+
 			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
-			//$table->set_additional_parameters($parameters);
 			$table->set_header(0, get_lang('Title'));
 			$table->set_header(1, get_lang('SubTitle'));
 			$table->set_header(2, get_lang('Modify'));

+ 6 - 4
main/inc/lib/search/search_widget.php

@@ -67,7 +67,7 @@ function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix='') {
     // Process each prefix type term
     $i = 0;
     $max = count($sf_terms);
-    $multiple_selects .='';
+    $multiple_selects ='';
     foreach ($sf_terms as $prefix => $sf_term_array) {
         if ($prefix == $prefilter_prefix) continue;
         $multiple_select = '';
@@ -91,7 +91,7 @@ function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix='') {
         // get specific field name
         $sf_value = get_specific_field_list(array( 'code' => "'$prefix'" ));
         $sf_value = array_shift($sf_value);
-        $multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">'.$icons_for_search_terms[$prefix].' '.$sf_value['name'].'</label><br />';
+        $multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">' . $sf_value['name'].'</label><br />';
         $multiple_select .= format_one_specific_field_select($prefix, $sf_term_array, $op, 'multiple="multiple" size="7" class="sf-select-multiple"');
         $multiple_select .= '</td>';
         $multiple_selects .= $multiple_select;
@@ -134,8 +134,10 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
         $reset_button 	= '<button class="save"   type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'. get_lang('SearchResetKeywords') .'</button> ';
 	}
 
+    $query = isset($_REQUEST['query']) ? Security::remove_XSS($_REQUEST['query']) : null;
+
     $form = '<form id="chamilo_search" action="'. $action .'" method="GET">
-            <input type="text" id="query" name="query" size="40" value="'.stripslashes(Security::remove_XSS($_REQUEST['query'])).'" />
+            <input type="text" id="query" name="query" size="40" value="' . $query . '" />
             <input type="hidden" name="mode" value="'. $mode .'"/>
             <input type="hidden" name="type" value="'. $type .'"/>
             <input type="hidden" name="tablename_page_nr" value="1" />
@@ -357,7 +359,7 @@ function search_widget_show($action='index.php')
     //check if URL params are defined (to see if we show the thesaurus or not)
     $show_thesaurus = false;
     foreach ($url_params as $param) {
-        if (is_array($_REQUEST[$param])) {
+        if (isset($_REQUEST[$param]) && is_array($_REQUEST[$param])) {
             $thesaurus_decided = FALSE;
             foreach ($_REQUEST[$param] as $term) {
                 if (!empty($term)) {

+ 7 - 1
main/inc/lib/sessionmanager.lib.php

@@ -2609,7 +2609,7 @@ class SessionManager
      * @return array An array with all sessions of the platform.
      * @todo   optional course code parameter, optional sorting parameters...
      */
-    public static function get_sessions_list($conditions = array(), $order_by = array())
+    public static function get_sessions_list($conditions = array(), $order_by = array(), $from = null, $to = null)
     {
         $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
         $session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@@ -2679,6 +2679,12 @@ class SessionManager
             }
         }
 
+        if (!is_null($from) && !is_null($to)) {
+            $to = intval($to);
+            $from = intval($from);
+            $sql_query .= "LIMIT $from, $to";
+        }
+
         $sql_result = Database::query($sql_query);
         if (Database::num_rows($sql_result) > 0) {
             while ($result = Database::fetch_array($sql_result)) {

+ 20 - 0
main/inc/lib/urlmanager.lib.php

@@ -776,6 +776,26 @@ class UrlManager
         return $result;
     }
 
+    /**
+     * Deletes user from all portals
+     * @author Julio Montoya
+     * @param int user id
+     *
+     * @return boolean true if success
+     * */
+    public static function deleteUserFromAllUrls($userId)
+    {
+        $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+        $result = true;
+        if (!empty($userId)) {
+            $sql= "DELETE FROM $table_url_rel_user
+                   WHERE user_id = ".intval($userId);
+            Database::query($sql);
+        }
+
+        return $result;
+    }
+
     /**
     * Deletes an url and course relationship
     * @author Julio Montoya

+ 11 - 9
main/inc/lib/usermanager.lib.php

@@ -475,12 +475,12 @@ class UserManager
      */
     public static function can_delete_user($user_id)
     {
-        global $_configuration;
-        if (isset($_configuration['deny_delete_users']) &&
-            $_configuration['deny_delete_users'] == true
-        ) {
+        $deny = api_get_configuration_value('deny_delete_users');
+
+        if ($deny) {
             return false;
         }
+
         $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
         if ($user_id != strval(intval($user_id))) {
             return false;
@@ -493,12 +493,14 @@ class UserManager
         $res = Database::query($sql);
         while ($course = Database::fetch_object($res)) {
             $sql = "SELECT id FROM $table_course_user
-                    WHERE status=1 AND c_id = " . Database::escape_string($course->c_id);
+                    WHERE status=1 AND c_id = " . intval($course->c_id);
             $res2 = Database::query($sql);
             if (Database::num_rows($res2) == 1) {
+
                 return false;
             }
         }
+
         return true;
     }
 
@@ -612,8 +614,7 @@ class UserManager
         $extraFieldValue = new ExtraFieldValue('user');
         $extraFieldValue->deleteValuesByItem($user_id);
 
-        $url_id = api_get_current_access_url_id();
-        UrlManager::delete_url_rel_user($user_id, $url_id);
+        UrlManager::deleteUserFromAllUrls($user_id);
 
         if (api_get_setting('allow_social_tool') == 'true') {
             $userGroup = new UserGroup();
@@ -648,12 +649,13 @@ class UserManager
                 WHERE lastedit_user_id = '".$user_id."'";
         Database::query($sql);
 
+
+
+
         // Delete user from database
         $sql = "DELETE FROM $table_user WHERE id = '".$user_id."'";
         Database::query($sql);
 
-
-
         // Add event to system log
         $user_id_manager = api_get_user_id();
 

+ 17 - 8
main/newscorm/lp_list_search.php

@@ -49,10 +49,14 @@ if (!empty($_REQUEST['operator']) && in_array($op, array('or', 'and'))) {
     $op = $_REQUEST['operator'];
 }
 
-$query = stripslashes(htmlspecialchars_decode($_REQUEST['query'], ENT_QUOTES));
+$query = null;
+
+if (isset($_REQUEST['query'])) {
+    $query = stripslashes(htmlspecialchars_decode($_REQUEST['query'], ENT_QUOTES));
+}
 
 $mode = 'default';
-if (in_array($_GET['mode'], array('gallery', 'default'))) {
+if (isset($_GET['mode']) && in_array($_GET['mode'], array('gallery', 'default'))) {
     $mode = $_GET['mode'];
 }
 
@@ -111,12 +115,17 @@ if (count($term_array)) {
     }
 }
 
-list($count, $results) = chamilo_query_query(
-    api_convert_encoding($query, 'UTF-8', $charset),
-    0,
-    1000,
-    $fixed_queries
-);
+if ($query) {
+    list($count, $results) = chamilo_query_query(
+        api_convert_encoding($query, 'UTF-8', $charset),
+        0,
+        1000,
+        $fixed_queries
+    );
+} else {
+    $count = 0;
+    $results = [];
+}
 
 // Prepare blocks to show.
 $blocks = array();

+ 9 - 3
main/webservices/registration.soap.php

@@ -5992,6 +5992,8 @@ $server->wsdl->addComplexType(
     'all',
     '',
     array(
+        'from'  => array('name' => 'from',  'type' => 'xsd:int'),
+        'to'    => array('name' => 'to',    'type' => 'xsd:int'),
         'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
         'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
         'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
@@ -6048,8 +6050,9 @@ $server->register('WSListSessions',           // method name
  * @param array List of parameters (security key, date_start and date_end)
  * @return array Sessions list (id=>[title=>'title',url='http://...',date_start=>'...',date_end=>''])
  */
-function WSListSessions($params) {
-    if(!WSHelperVerifyKey($params)) {
+function WSListSessions($params)
+{
+    if (!WSHelperVerifyKey($params)) {
         return returnError(WS_ERROR_SECRET_KEY);
     }
     $sql_params = array();
@@ -6060,7 +6063,10 @@ function WSListSessions($params) {
     if (!empty($params['date_end'])) {
         $sql_params['s.access_end_date'] = array('operator' => '<=', 'value' => $params['date_end']);
     }
-    $sessions_list = SessionManager::get_sessions_list($sql_params);
+    $from = isset($params['from']) ? $params['from'] : null;
+    $to = isset($params['to']) ? $params['to'] : null;
+
+    $sessions_list = SessionManager::get_sessions_list($sql_params, null, $from, $to);
     $return_list = array();
     foreach ($sessions_list as $session) {
         $return_list[] = array(