From a5fb490342be68567b7a3eaeb1bbd9784ed37820 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Fri, 29 Jul 2011 14:48:49 -0500 Subject: [PATCH 01/17] Minor - reviewed style of array element call --- main/admin/user_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/admin/user_import.php b/main/admin/user_import.php index 0d34dbde55..da7508a7ae 100755 --- a/main/admin/user_import.php +++ b/main/admin/user_import.php @@ -171,7 +171,7 @@ function save_data($users) { if ($send_mail) { $recipient_name = api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS); $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName'); - $emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem')."\n\n".get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator').""; + $emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ".$user['UserName']."\n".get_lang('Pass')." : ".$user['Password']."\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem')."\n\n".get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator').""; $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_admin = api_get_setting('emailAdministrator'); @api_mail($recipient_name, $user['Email'], $emailsubject, $emailbody, $sender_name, $email_admin); From 79c6087da52c77cd7e2b730363b5daeb8b5467b1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 29 Jul 2011 15:36:22 -0500 Subject: [PATCH 02/17] Added scripts to resend passwords and get user details - disabled by default, manual enable required --- main/cron/user_import/get_data_from_mail.php | 35 +++++++++++ .../resend_email_with_new_password.php | 59 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 main/cron/user_import/get_data_from_mail.php create mode 100644 main/cron/user_import/resend_email_with_new_password.php diff --git a/main/cron/user_import/get_data_from_mail.php b/main/cron/user_import/get_data_from_mail.php new file mode 100644 index 0000000000..07b455a4fb --- /dev/null +++ b/main/cron/user_import/get_data_from_mail.php @@ -0,0 +1,35 @@ +$row['firstname'],'LastName'=>$row['lastname'],'UserName'=>$row['username'],'Password'=>$pass,'Email'=>$mail); + $l = api_get_interface_language(); + if (!empty($row['language'])) { + $l = $row['language']; + } + //This comes from main/admin/user_import.php::save_data() slightly modified + $recipient_name = api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS); + $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg',null,$l).' '.api_get_setting('siteName'); + $emailbody = get_lang('Dear',null,$l).' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg',null,$l)." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings',null,$l)."\n\n".get_lang('Username',null,$l)." : ".$user['UserName']."\n".get_lang('Pass',null,$l)." : ".$user['Password']."\n\n".get_lang('Address',null,$l)." ".api_get_setting('siteName')." ".get_lang('Is',null,$l)." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem',null,$l)."\n\n".get_lang('Formula',null,$l).",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager',null,$l)." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email',null,$l)." : ".api_get_setting('emailAdministrator').""; + $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); + $email_admin = api_get_setting('emailAdministrator'); + @api_mail($recipient_name, $user['Email'], $emailsubject, $emailbody, $sender_name, $email_admin); + echo "[OK] Sent to $mail with new password $pass (encrypted:$crypass)... w/ subject: $emailsubject\n"; + } +} From 63ff2a771cc5e10ef29e9d683b64838ea32b548c Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 10:34:51 -0500 Subject: [PATCH 03/17] Fixed bug in XLS import - fixes #3763 --- documentation/changelog.html | 3 ++- main/exercice/upload_exercise.php | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index 5d04e0fc63..a3e2490112 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -35,7 +35,7 @@ This version of Chamilo only includes a few minor new features:
  • Added tokens to announcements (changeset 66d9c5e10b42)
  • Students can download learning paths as PDF (changeset 3bd77279faee)
  • Added tokens to certificates generation (changeset c2201eee3558)
  • -
  • Attendances session support
  • +
  • Attendances session support
  • Debugging

      @@ -73,6 +73,7 @@ This version of Chamilo only includes a few minor new features:
      • Fixed question matching when using french/spanish accents
      • Exercise results: Fixing and improving export to CSV using jquery BT#2722
      • +
      • Fixed bug with feedback in XLS import #3763
    • Gradebook diff --git a/main/exercice/upload_exercise.php b/main/exercice/upload_exercise.php index 9b00a242b5..91631bf6c9 100755 --- a/main/exercice/upload_exercise.php +++ b/main/exercice/upload_exercise.php @@ -141,7 +141,7 @@ function lp_upload_quiz_action_handling() { $feedback_false_index = array(); $number_questions = 0; // Reading all the first column items sequencially to create breakpoints - for ($i = 1; $i < $data->sheets[0]['numRows']; $i++) { + for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) { $quiz_index = $i; // Quiz title position, only occurs once } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') { @@ -152,9 +152,9 @@ function lp_upload_quiz_action_handling() { $question_name_index_end[] = $i - 1; // Question name position $score_index[] = $i; // Question score position } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') { - $feedback_true_index[] = $i; // FeedbackTrue position + $feedback_true_index[] = $i; // FeedbackTrue position (line) } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') { - $feedback_false_index[] = $i; // FeedbackFalse position + $feedback_false_index[] = $i; // FeedbackFalse position (line) } } // Variables @@ -170,7 +170,7 @@ function lp_upload_quiz_action_handling() { for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { if (is_array($data->sheets[0]['cells'][$i])) { $column_data = $data->sheets[0]['cells'][$i]; - // Fill all column with data + // Fill all column with data to have a full array for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) { if (empty($column_data[$x])) { $data->sheets[0]['cells'][$i][$x] = ''; @@ -185,16 +185,16 @@ function lp_upload_quiz_action_handling() { if ($quiz_index == $i) { // The title always in the first position $quiz = $column_data; } elseif (in_array($i, $question_title_index)) { - $question[$k] = $column_data; + $question[$k] = $column_data; //a complete line where 1st column is 'Question' $k++; } elseif (in_array($i, $score_index)) { - $score_list[$z] = $column_data; + $score_list[$z] = $column_data; //a complete line where 1st column is 'Score' $z++; } elseif (in_array($i, $feedback_true_index)) { - $feedback_true_list[$q] = $column_data; + $feedback_true_list[$q] = $column_data;//a complete line where 1st column is 'FeedbackTrue' $q++; } elseif (in_array($i, $feedback_false_index)) { - $feedback_false_list[$l] = $column_data; + $feedback_false_list[$l] = $column_data;//a complete line where 1st column is 'FeedbackFalse' for wrong answers $l++; } } @@ -222,7 +222,9 @@ function lp_upload_quiz_action_handling() { // Variables $type = 2; $random = $active = $results = $max_attempt = $expired_time = 0; - $feedback = 3; + //make sure feedback is enabled (3 to disable), otherwise the fields + // added to the XLS are not shown, which is confusing + $feedback = 0; // Quiz object $quiz_object = new Exercise(); @@ -248,12 +250,17 @@ function lp_upload_quiz_action_handling() { if (strtolower($answer_data[3]) == 'x') { $correct = 1; $score = $score_list[$i][3]; + $comment = $feedback_true_list[$i][2]; + } else { + $comment = $feedback_false_list[$i][2]; } +/* if ($id == 1) { $comment = $feedback_true_list[$i][2]; } elseif ($id == 2) { $comment = $feedback_false_list[$i][2]; } +*/ // Create answer $unique_answer->create_answer($id, $question_id, ($answer), ($comment), $score, $correct); $id++; From 5ef2a6b0839f12b21e49aa3508a32fba42bd75f1 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 30 Jul 2011 15:53:46 -0500 Subject: [PATCH 04/17] Slightly updated dokeos_classic theme to fix breadcrumb border --- main/css/dokeos_classic/default.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/css/dokeos_classic/default.css b/main/css/dokeos_classic/default.css index 3417dbc1e0..109cdf7253 100644 --- a/main/css/dokeos_classic/default.css +++ b/main/css/dokeos_classic/default.css @@ -440,7 +440,7 @@ input[text] { *****************************************************/ #header3 { font-size: 1.0em; - padding: 0.8em 0.5em 0.4em 0.5em; + padding: 0.8em 0.5em 0em 0.5em; background: #E5EDF9; color: #006; border-bottom: 1px solid #4171b5; @@ -548,7 +548,7 @@ input[text] { #header4 { background-color: #fff; color: #009; - padding: 4px 0px 4px 21px; + padding: 0; margin-bottom: 2px; float:left; width:98%; @@ -3058,4 +3058,4 @@ abbr { border-bottom: 1px dotted rgb(102, 102, 102); background-color:#F00; cursor: help; -} \ No newline at end of file +} From 19107babdf9f26e5af745b5256b2aca0bfdfe656 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 16:13:34 -0500 Subject: [PATCH 05/17] Adding check for timezone extension, otherwise skipping, in upgrade from 1.8.6.2 to 1.8.7. Avoids fatal error blocking the installation process right in the middle, but possibly breaks datetimes in database for much later versions (when PHP 5.2 is enabled). --- main/install/update-db-1.8.6.2-1.8.7.inc.php | 71 ++++++++++---------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/main/install/update-db-1.8.6.2-1.8.7.inc.php b/main/install/update-db-1.8.6.2-1.8.7.inc.php index 1043b51888..1e5852a458 100755 --- a/main/install/update-db-1.8.6.2-1.8.7.inc.php +++ b/main/install/update-db-1.8.6.2-1.8.7.inc.php @@ -116,42 +116,43 @@ if (defined('SYSTEM_INSTALLATION')) { } } - // Converting dates and times to UTC using the default timezone of PHP - // Converting gradebook dates and times - $timezone = date_default_timezone_get(); - // Calculating the offset - $dateTimeZoneCurrent = new DateTimeZone($timezone); - $dateTimeUTC = new DateTime("now", new DateTimeZone('UTC')); - $timeOffsetSeconds = $dateTimeZoneCurrent->getOffset($dateTimeUTC); - $timeOffsetHours = $timeOffsetSeconds / 3600; - $timeOffsetString = ""; - - if($timeOffsetHours < 0) { - $timeOffsetString .= "-"; - $timeOffsetHours = abs($timeOffsetHours); - } else { - $timeOffsetString .= "+"; - } - - if($timeOffsetHours < 10) { - $timeOffsetString .= "0"; + if (DATE_TIME_INSTALLED) { + // Converting dates and times to UTC using the default timezone of PHP + // Converting gradebook dates and times + $timezone = date_default_timezone_get(); + // Calculating the offset + $dateTimeZoneCurrent = new DateTimeZone($timezone); + $dateTimeUTC = new DateTime("now", new DateTimeZone('UTC')); + $timeOffsetSeconds = $dateTimeZoneCurrent->getOffset($dateTimeUTC); + $timeOffsetHours = $timeOffsetSeconds / 3600; + $timeOffsetString = ""; + + if($timeOffsetHours < 0) { + $timeOffsetString .= "-"; + $timeOffsetHours = abs($timeOffsetHours); + } else { + $timeOffsetString .= "+"; + } + + if($timeOffsetHours < 10) { + $timeOffsetString .= "0"; + } + + $timeOffsetString .= "$timeOffsetHours"; + $timeOffsetString .= ":00"; + + // Executing the queries to convert everything + $queries[] = "UPDATE gradebook_certificate SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + $queries[] = "UPDATE gradebook_evaluation SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + $queries[] = "UPDATE gradebook_link SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + $queries[] = "UPDATE gradebook_linkeval_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + $queries[] = "UPDATE gradebook_result SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + $queries[] = "UPDATE gradebook_result_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; + + foreach ($queries as $query) { + Database::query($query); + } } - - $timeOffsetString .= "$timeOffsetHours"; - $timeOffsetString .= ":00"; - - // Executing the queries to convert everything - $queries[] = "UPDATE gradebook_certificate SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_evaluation SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_link SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_linkeval_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_result SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - $queries[] = "UPDATE gradebook_result_log SET created_at = CONVERT_TZ(created_at, '".$timeOffsetString."', '+00:00');"; - - foreach ($queries as $query) { - Database::query($query); - } - // Moving user followed by a human resource manager from hr_dept_id field to user_rel_user table $query = "SELECT user_id, hr_dept_id FROM $dbNameForm.user"; $result = Database::query($query); From f92fba92d3f7efdd6d15e969073019f8e7768920 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 16:20:24 -0500 Subject: [PATCH 06/17] Fixed fatal error in upgrade from 1.8.5 by including the image lib - refs BT#2777 --- documentation/changelog.html | 7 ++++++- main/install/update-db-1.8.5-1.8.6.inc.php | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index a3e2490112..63ad0ad832 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -89,7 +89,12 @@ This version of Chamilo only includes a few minor new features:
    • Fixed mp3 previews
    - +
  • +
      +
    • Fixed fatal error in upgrade from 1.8.5 by requiring image.lib.php - BT#2777
    • +
    • Fixed fatal error in upgrade from 1.8.6.2 by checking the availability of the DateTimeZone library in PHP - BT#2777
    • +
    +
  • Learning path
    • Drag and drop to order LP items! #3741
    • diff --git a/main/install/update-db-1.8.5-1.8.6.inc.php b/main/install/update-db-1.8.5-1.8.6.inc.php index 95c260f584..3dbf16675f 100755 --- a/main/install/update-db-1.8.5-1.8.6.inc.php +++ b/main/install/update-db-1.8.5-1.8.6.inc.php @@ -100,6 +100,9 @@ if (defined('SYSTEM_INSTALLATION')) { } } + require_once '../inc/lib/image.lib.php'; //this library has been created + // in 1.8.8, which makes this inclusion retroactively necessary in + // updates from 1.8.5 // Filling the access_url_rel_user table with access_url_id by default = 1 $query = "SELECT user_id FROM $dbNameForm.user"; @@ -126,7 +129,7 @@ if (defined('SYSTEM_INSTALLATION')) { $picture_location = $dir.$user_id.'/'.$file; $big_picture_location = $dir.$user_id.'/big_'.$file; - $temp = new image($image_repository); + $temp = new Image($image_repository); $picture_infos = getimagesize($image_repository); From e7c40438ee3712d06311681dee32d5c146d6f9d1 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 17:05:16 -0500 Subject: [PATCH 07/17] Small fixes to dynamic documents loader - refs BT#2773 --- main/inc/lib/document.lib.php | 4 ++-- user_portal.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 5fb092f322..080032e956 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2550,13 +2550,13 @@ return 'application/octet-stream'; $return .= Display::url(get_lang('NewDocument'), api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id); $return .= ''; } else { - $return .= Display::div(Display::url(Display::return_icon('delete.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_div_'.$course_info['real_id'].'_'.$session_id,'class' =>'close_div')), array('style' => 'position:absolute;right:10px')); + $return .= Display::div(Display::url(Display::return_icon('delete.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_div_'.$course_info['real_id'].'_'.$current_session_id,'class' =>'close_div')), array('style' => 'position:absolute;right:10px')); } // If you want to debug it, I advise you to do "echo" on the eval statements. if (!empty($resources) && $user_in_course) { foreach ($resources as $resource) { - $item_info = api_get_item_property_info($course_info['real_id'], 'document', $resource['id'], $session_id); + $item_info = api_get_item_property_info($course_info['real_id'], 'document', $resource['id'], $current_session_id); if (empty($item_info)) { continue; diff --git a/user_portal.php b/user_portal.php index fcb3c7ff98..6e6673e4c5 100755 --- a/user_portal.php +++ b/user_portal.php @@ -207,11 +207,12 @@ if ($load_dirs) { $(".document_preview").click(function() { var my_id = this.id; course_id = my_id.split("_")[2]; + sess_id = my_id.split("_")[3]; //showing div $(".document_preview_container").hide(); - $("#document_result_" +course_id).show(); + $("#document_result_" +course_id+"_"+sess_id).show(); //Loading var image = $("img", this); @@ -222,7 +223,7 @@ if ($load_dirs) { data: "course_id="+course_id, success: function(return_value) { image.attr("src", "'.$folder_icon.'"); - $("#document_result_" +course_id).html(return_value); + $("#document_result_" +course_id+"_"+sess_id).html(return_value); }, }); From d65544abf6c267276ee92849e40673a2022acc6b Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 17:23:06 -0500 Subject: [PATCH 08/17] Small fixes to dynamic documents loader - show icon for session courses and in special courses - refs BT#2773 --- main/inc/lib/course.lib.php | 34 ++++++++++++++++++++++++++++++---- user_portal.php | 4 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 1a33d0c587..6aa2082e04 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -2522,9 +2522,10 @@ class CourseManager { * Special courses are courses that stick on top of the list and are "auto-registerable" * in the sense that any user clicking them is registered as a student * @param int User id + * @param bool Whether to show the document quick-loader or not * @return void */ - function display_special_courses ($user_id) { + function display_special_courses ($user_id, $load_dirs = false) { $user_id = intval($user_id); $user_info = api_get_user_info($user_id); @@ -2579,12 +2580,32 @@ class CourseManager { echo '
      '; if (api_is_platform_admin()) { - echo '
      '.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), 22).''; + echo '
      '; + + if ($load_dirs) { + echo ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),22).''; + echo ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).''; + echo Display::div('', array('id' => 'document_result_'.$course['id'].'_0', 'class'=>'document_preview_container')); + } else { + echo ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).''; + } + if ($course['status'] == COURSEMANAGER) { - //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'),array('style'=>'width:11px; height:11px;')); + //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); + } + echo '
      '; + } else { + echo '
      '; + if ($load_dirs) { + echo ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),22).''; + echo Display::div('', array('id' => 'document_result_'.$course['id'].'_0', 'class'=>'document_preview_container')); } echo '
      '; + } + + + $course_visibility = $course['visibility']; if ($course_visibility != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) { $course_title = ''.$course['title'].''; @@ -2619,6 +2640,7 @@ class CourseManager { * of course categories, as class userportal-catalog-item. * @uses display_courses_in_category() to display the courses themselves * @param int user id + * @param bool Whether to show the document quick-loader or not * @return void */ function display_courses($user_id, $load_dirs = false) { @@ -2657,6 +2679,7 @@ class CourseManager { * Display courses inside a category (without special courses) as HTML dics of * class userportal-course-item. * @param int User category id + * @param bool Whether to show the document quick-loader or not * @return void */ function display_courses_in_category($user_category_id, $load_dirs = false) { @@ -2719,8 +2742,10 @@ class CourseManager { if ($load_dirs) { echo ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),22).''; - echo ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).''; + echo ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).''; echo Display::div('', array('id' => 'document_result_'.$course['id'].'_0', 'class'=>'document_preview_container')); + } else { + echo ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).''; } if ($course['status'] == COURSEMANAGER) { @@ -2844,6 +2869,7 @@ class CourseManager { * @param integer Session ID * @param string CSS class to apply to course entry * @param boolean Whether the session is supposedly accessible now (not in the case it has passed and is in invisible/unaccessible mode) + * @param bool Whether to show the document quick-loader or not * @return string The HTML to be printed for the course entry * * @version 1.0.3 diff --git a/user_portal.php b/user_portal.php index 6e6673e4c5..b6fad68965 100755 --- a/user_portal.php +++ b/user_portal.php @@ -417,7 +417,7 @@ if (is_array($courses_tree)) { // Sessions and courses that are not in a session category. if (!isset($_GET['history'])) { // If we're not in the history view... - CourseManager :: display_special_courses(api_get_user_id()); + CourseManager :: display_special_courses(api_get_user_id(), $load_dirs); CourseManager :: display_courses(api_get_user_id(), $load_dirs); } // Independent sessions. @@ -445,7 +445,7 @@ if (is_array($courses_tree)) { } if ($session_now > $allowed_time) { //read only and accesible if (api_get_setting('hide_courses_in_sessions') == 'false') { - $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',true); + $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',true,true); //$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',($session['details']['visibility']==3?false:true)); $html_courses_session .= $c[1]; } From 56137ab9850b7f3290b4217b5ac7baf458185c35 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 17:38:39 -0500 Subject: [PATCH 09/17] More fixes to documents dynamic loader - refs BT#2773 --- documentation/changelog.html | 5 +++-- main/inc/ajax/document.ajax.php | 2 +- main/inc/lib/document.lib.php | 3 ++- user_portal.php | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index 63ad0ad832..846f454fd1 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -36,6 +36,7 @@ This version of Chamilo only includes a few minor new features:
    • Students can download learning paths as PDF (changeset 3bd77279faee)
    • Added tokens to certificates generation (changeset c2201eee3558)
    • Attendances session support
    • +
    • Added quick browsing of directories' documents - requires manual activation for now: in user_portal.php, find $load_dirs and set to $load_dirs = true;. Will be setable through admin page in next version (changeset 7f84869233c2)

    Debugging

      @@ -151,7 +152,7 @@ This version of Chamilo only includes a few minor new features:
    • All CSS were reduced and improved in order to use the base.css and base_chamilo.css styles
    • Chosen library (select tag improved)added #3740
    -
  • +

    Security

      @@ -160,7 +161,7 @@ This version of Chamilo only includes a few minor new features:
    • Fixed several potential SQL injections #3601

    Known issues

    -
      +
      • Watermark portal images are now saved in the main/default_course_document/images/ folder. If you used portal-wide watermarks before, you might need to upload the watermark image again.
      • A style-specific switch had been added in 1.8.8.2, which improved the appearance of older style but went against MVC's principles and broke copies of Chamilo-based styles. This switch has been removed, which may lead to the breadcrumb in non-chamilo-based styles to appear as less attractive, but keeps the MVC model safe so anyone can modify the appearance safely from the CSS. This might require very little cosmetic changes from you (in your style's default.css file), but we believe it's for the best.
      diff --git a/main/inc/ajax/document.ajax.php b/main/inc/ajax/document.ajax.php index ce46310eac..5452ef5800 100644 --- a/main/inc/ajax/document.ajax.php +++ b/main/inc/ajax/document.ajax.php @@ -45,7 +45,7 @@ switch($action) { case 'document_preview': $course_info = api_get_course_info_by_id($_REQUEST['course_id']); if (!empty($course_info) && is_array($course_info)) { - echo DocumentManager::get_document_preview($course_info, false, '_blank', $_REQUEST['session_id']); + echo DocumentManager::get_document_preview($course_info, false, '_blank', $_REQUEST['sessid']); } break; } diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 080032e956..59cffe7fb1 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2550,7 +2550,8 @@ return 'application/octet-stream'; $return .= Display::url(get_lang('NewDocument'), api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id); $return .= ''; } else { - $return .= Display::div(Display::url(Display::return_icon('delete.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_div_'.$course_info['real_id'].'_'.$current_session_id,'class' =>'close_div')), array('style' => 'position:absolute;right:10px')); + $txt_sessid = (empty($session_id)?'0':(string)$session_id); + $return .= Display::div(Display::url(Display::return_icon('delete.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_div_'.$course_info['real_id'].'_'.$txt_sessid,'class' =>'close_div')), array('style' => 'position:absolute;right:10px')); } // If you want to debug it, I advise you to do "echo" on the eval statements. diff --git a/user_portal.php b/user_portal.php index b6fad68965..392dfd1cb9 100755 --- a/user_portal.php +++ b/user_portal.php @@ -220,7 +220,7 @@ if ($load_dirs) { $.ajax({ url: "'.$url.'", - data: "course_id="+course_id, + data: "course_id="+course_id+"&sessid="+sess_id, success: function(return_value) { image.attr("src", "'.$folder_icon.'"); $("#document_result_" +course_id+"_"+sess_id).html(return_value); From daff6b3059dc817dfbcb54f6cd28540b19ffb011 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 17:39:31 -0500 Subject: [PATCH 10/17] Disable dynamic loader by default - will have to be set manually, as described in the changelog, until next major version (requires admin setting) --- user_portal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_portal.php b/user_portal.php index 392dfd1cb9..fa77ce184d 100755 --- a/user_portal.php +++ b/user_portal.php @@ -91,7 +91,7 @@ define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatLong')); define("CONFVAL_limitPreviewTo", SCRIPTVAL_NewEntriesOfTheDayOfLastLogin); //$load_dirs = api_get_setting('courses_list_document_dynamic_dropdown'); -$load_dirs = true; +$load_dirs = false; // This is the main function to get the course list. From ad0ff73c872f235b87575b5a04c94295fce167fa Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 17:44:19 -0500 Subject: [PATCH 11/17] Fixed minor missing variable - refs BT#2773 --- user_portal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_portal.php b/user_portal.php index fa77ce184d..2a2fd6498d 100755 --- a/user_portal.php +++ b/user_portal.php @@ -445,7 +445,7 @@ if (is_array($courses_tree)) { } if ($session_now > $allowed_time) { //read only and accesible if (api_get_setting('hide_courses_in_sessions') == 'false') { - $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',true,true); + $c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',true,$load_dirs); //$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',($session['details']['visibility']==3?false:true)); $html_courses_session .= $c[1]; } From 8773efed8130359792f82225a21d6bac3208359a Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sat, 30 Jul 2011 18:07:08 -0500 Subject: [PATCH 12/17] Fixed some of the code to improve session check conditions - shouldn't be based on the session_id parameter as we don't want to set ourselves in the context of a session while there can be several sessions at the same time on user_portal - refs BT#2773 --- main/inc/lib/document.lib.php | 59 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 59cffe7fb1..5cdd7d741f 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2497,25 +2497,25 @@ return 'application/octet-stream'; } //condition for the session - if (isset($session_id) && !empty($session_id)) { + $current_session_id = 0; + if (!empty($session_id)) { $current_session_id = intval($session_id); - } else { - $current_session_id = api_get_session_id(); } - if (!$user_in_course) - if (empty($current_session_id)) { - if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) { - $user_in_course = true; - } - } else { - require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; - $user_status = SessionManager::get_user_status_in_session($user_id, $course_info['code'], $current_session_id); - if (in_array($user_status, array('0', '6'))) { //user and coach - $user_in_course = true; - } - } - + if (!$user_in_course) { + if (empty($current_session_id)) { + if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) { + $user_in_course = true; + } + } else { + require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php'; + $user_status = SessionManager::get_user_status_in_session($user_id, $course_info['code'], $current_session_id); + if (in_array($user_status, array('0', '6'))) { //user and coach + $user_in_course = true; + } + } + } + $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_doc = Database::get_course_table(TABLE_DOCUMENT, $course_info['dbName']); $tbl_item_prop = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_info['dbName']); @@ -2528,18 +2528,16 @@ return 'application/octet-stream'; //$condition_session = " AND (id_session = '$current_session_id' OR (id_session = '0' AND insert_date <= (SELECT creation_date FROM $tbl_course WHERE code = '".$course_info['code']."' )))"; $condition_session = " AND (id_session = '$current_session_id' OR id_session = '0' )"; - $sql_doc = "SELECT last.visibility, docs.* - FROM $tbl_item_prop AS last, $tbl_doc AS docs - WHERE docs.id = last.ref - AND docs.path LIKE '".$path.$added_slash."%' - AND docs.path NOT LIKE '%_DELETED_%' - AND last.tool = '".TOOL_DOCUMENT."' $condition_session - AND last.visibility = '1' - ORDER BY docs.path ASC"; - - $res_doc = Database::query($sql_doc); + $sql_doc = "SELECT last.visibility, docs.* ". + " FROM $tbl_item_prop AS last, $tbl_doc AS docs ". + " WHERE docs.id = last.ref ". + " AND docs.path LIKE '".$path.$added_slash."%' ". + " AND docs.path NOT LIKE '%_DELETED_%' ". + " AND last.tool = '".TOOL_DOCUMENT."' $condition_session ". + " AND last.visibility = '1' ". + "ORDER BY docs.path ASC"; + $res_doc = Database::query($sql_doc); $resources = Database::store_result($res_doc); - $return = ''; $resources_sorted = array(); @@ -2556,8 +2554,8 @@ return 'application/octet-stream'; // If you want to debug it, I advise you to do "echo" on the eval statements. if (!empty($resources) && $user_in_course) { - foreach ($resources as $resource) { - $item_info = api_get_item_property_info($course_info['real_id'], 'document', $resource['id'], $current_session_id); + foreach ($resources as $resource) { + $item_info = api_get_item_property_info($course_info['real_id'], 'document', $resource['id'], $current_session_id); if (empty($item_info)) { continue; @@ -2570,7 +2568,7 @@ return 'application/octet-stream'; foreach ($resource_paths as $key => $resource_path) { if (strpos($resource_path, '.') === false && $key != count($resource_paths) - 1) { // It's a folder. - $path_to_eval .= '["' . $resource_path . '"]["files"]'; + $path_to_eval .= "['$resource_path']['files']"; } else if (strpos($resource_path, '.') !== false) $is_file = true; @@ -2655,7 +2653,6 @@ return 'application/octet-stream'; $web_code_path = api_get_path(WEB_CODE_PATH); $return = ''; - if (count($resources_sorted) > 0) { foreach ($resources_sorted as $key => $resource) { if (isset($resource['id']) && is_int($resource['id'])) { From 68eb9d1e35858e3ec3dbb755ddc3725184baa670 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 31 Jul 2011 18:34:54 -0500 Subject: [PATCH 13/17] Fixed obviously wrong statement using unexisting $row2. Watch for possible behaviour changes due to this update (should re-enable modification of task by user). --- main/work/work.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/work/work.lib.php b/main/work/work.lib.php index c9bc81642e..a906b84890 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -930,7 +930,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',22).''; $row[] = $action; // the user that is not course admin can only edit/delete own document - } elseif ($row2['insert_user_id'] == $_user['user_id']) { + } elseif ($item_property_data['insert_user_id'] == $_user['user_id']) { $action = ''; $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).''; if (api_get_course_setting('student_delete_own_publication') == 1) { From 490c37c9a2df7c5f8b15ae46a7a63a5738522aa5 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 31 Jul 2011 22:55:45 -0500 Subject: [PATCH 14/17] Improved assignment tool so the student can edit it *unless* it has been scored already --- main/work/work.lib.php | 102 ++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/main/work/work.lib.php b/main/work/work.lib.php index a906b84890..b3fb7c393e 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -429,59 +429,27 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $row = Database::fetch_array($sql_result_num); $count_files = $row[0]; + $table_header = array(); + $table_has_actions_column = false; $table_header[] = array(get_lang('Type'), false, 'style="width:40px"'); $table_header[] = array(get_lang('Title'), true); if ($count_files != 0) { $table_header[] = array(get_lang('FirstName'), true); $table_header[] = array(get_lang('LastName'), true); - if ($qualification_exists) + if ($qualification_exists) { $table_header[] = array(get_lang('Qualification'), true); + } } $table_header[] = array(get_lang('Date'), true, 'style="width:160px"'); if ($is_allowed_to_edit) { $table_header[] = array(get_lang('Actions'), false, 'style="width:90px"'); + $table_has_actions_column = true; } - $table_header[] = array('RealDate', true); - - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide - $column_show = array(); - - $column_show[] = 1; // type - $column_show[] = 1; // title - - if ($count_files != 0) { - $column_show[] = 1; // firstname - $column_show[] = 1; // lastname - if ($qualification_exists) { - $column_show[] = 1; // qualification - } - } + // the following column name seems both undefined and unused + //$table_header[] = array('RealDate', true); - $column_show[] = 1; //date - if ($is_allowed_to_edit) { - $column_show[] = 1; // modify - } - $column_show[] = 0; //real date in correct format - - // Here we change the way how the colums are going to be sort - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" - - $column_order = array(); - $i=0; - foreach($table_header as $item) { - $column_order[$i] = $i; - $i++; - } - - if ($count_files != 0) { - $column_order[2] = 2; - } else { - $column_order[2] = 4; - } - $table_data = array(); $dirs_list = get_subdirs_list($work_dir); @@ -885,10 +853,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $qualification_string = ''; $add_string = ''; - - - - + if ($qualification_exists) { if ($work->qualification == '') { $qualification_string = ' - '; @@ -909,18 +874,18 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $row[] = $user_info['firstname']; // $work->author; $row[] = $user_info['lastname']; - if ($qualification_exists) + if ($qualification_exists) { $row[] = $qualification_string; - + } $work_sent_date_local = api_get_local_time($work->sent_date); $row[] = date_to_str_ago($work_sent_date_local).$add_string.'
      '.api_format_date($work_sent_date_local).''; if ($is_allowed_to_edit) { $action = ''; - if ($qualification_exists) + if ($qualification_exists) { $action .= ''. Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), 22).''; - + } $action .= ''.Display::return_icon('move.png', get_lang('Move'),array(), 22).''; if ($work->accepted == '1') { $action .= ''.Display::return_icon('visible.png', get_lang('Invisible'),array(), 22).''; @@ -930,7 +895,11 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',22).''; $row[] = $action; // the user that is not course admin can only edit/delete own document - } elseif ($item_property_data['insert_user_id'] == $_user['user_id']) { + } elseif ($is_author && empty($work->qualification)) { + if (!$table_has_actions_column) { + $table_header[] = array(get_lang('Actions'), false, 'style="width:90px"'); + $table_has_actions_column = true; + } $action = ''; $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).''; if (api_get_course_setting('student_delete_own_publication') == 1) { @@ -948,6 +917,43 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor $sorting_options = array(); $sorting_options['column'] = 1; + // Here we change the way how the colums are going to be sorted + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" + + $column_order = array(); + $i=0; + foreach($table_header as $item) { + $column_order[$i] = $i; + $i++; + } + + if ($count_files != 0) { + $column_order[2] = 2; + } else { + $column_order[2] = 4; + } + + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide + $column_show = array(); + + $column_show[] = 1; // type + $column_show[] = 1; // title + + if ($count_files != 0) { + $column_show[] = 1; // firstname + $column_show[] = 1; // lastname + if ($qualification_exists) { + $column_show[] = 1; // qualification + } + } + + $column_show[] = 1; //date + if ($table_has_actions_column) { + $column_show[] = 1; // modify + } + $column_show[] = 0; //real date in correct format + $paging_options = array(); if (isset($_GET['curdirpath'])) { $my_params = array ('curdirpath' => Security::remove_XSS($_GET['curdirpath'])); From 8b626eb18f76f2a34d568ddc2e966cff35bc236e Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 31 Jul 2011 23:26:36 -0500 Subject: [PATCH 15/17] Minor - Updated confusing label in assignments. --- main/work/work.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/work/work.php b/main/work/work.php index 66beb30e37..3bbdf5575c 100755 --- a/main/work/work.php +++ b/main/work/work.php @@ -282,7 +282,7 @@ if (!empty($_SESSION['toolgroup'])) { } if ($_GET['createdir'] == 1) { - $interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('CreateFolder')); + $interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('CreateAssignment')); } Display :: display_header(null); } else { From 707a61c16de0557c881a2cc6b0553e03393a2447 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 31 Jul 2011 23:27:42 -0500 Subject: [PATCH 16/17] Minor - Updated confusing label in assignments. --- main/work/work.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/work/work.php b/main/work/work.php index 3bbdf5575c..85193094c3 100755 --- a/main/work/work.php +++ b/main/work/work.php @@ -317,7 +317,7 @@ if (!empty($_SESSION['toolgroup'])) { $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditToolOptions')); } if ($_GET['createdir'] == 1) { - $interbreadcrumb[] = array ('url' => '#','name' => get_lang('CreateDir')); + $interbreadcrumb[] = array ('url' => '#','name' => get_lang('CreateAssignment')); } Display :: display_header(null); From f9fcd168c5e9098320c13dff87bbaf57d96e2546 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Sun, 31 Jul 2011 23:42:23 -0500 Subject: [PATCH 17/17] Registered changes in assignments --- documentation/changelog.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/documentation/changelog.html b/documentation/changelog.html index 846f454fd1..7c8539d32a 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -53,7 +53,13 @@ This version of Chamilo only includes a few minor new features:
      • Fixing announcements listing BT#2751
      - + +
    • + Assignments +
        +
      • Made assignments editable/removable by students only until they have been reviewed and scored (>0) by the teacher (changeset bc1b8e1e603d)
      • +
      +
    • Attendances