diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index dbcd95c80a..10bf1574bb 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.php @@ -34,6 +34,7 @@ class Version110 extends AbstractMigrationChamilo public function up(Schema $schema) { // Use $schema->createTable + $this->addSql('set sql_mode=""'); $this->addSql("CREATE TABLE IF NOT EXISTS course_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)"); $this->addSql("CREATE TABLE IF NOT EXISTS session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)"); @@ -49,8 +50,17 @@ class Version110 extends AbstractMigrationChamilo $this->addSql("ALTER TABLE skill_rel_user MODIFY COLUMN acquired_skill_at datetime default NULL"); $this->addSql("ALTER TABLE track_e_access MODIFY COLUMN access_date datetime DEFAULT NULL"); $this->addSql("ALTER TABLE track_e_lastaccess MODIFY COLUMN access_date datetime DEFAULT NULL"); - $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id"); - $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id"); + + $table = $schema->getTable('skill_rel_user'); + + if (!$table->hasColumn('course_id')) { + $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id"); + } + + if (!$table->hasColumn('session_id')) { + $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id"); + } + $this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)"); // Delete info of session_rel_user if session does not exists; @@ -113,9 +123,9 @@ class Version110 extends AbstractMigrationChamilo $this->addSql("ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''"); $this->addSql("ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''"); - $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT null"); + $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT NULL"); $this->addSql("ALTER TABLE user DROP PRIMARY KEY"); - $this->addSql("ALTER TABLE user ADD COLUMN id INT DEFAULT null"); + $this->addSql("ALTER TABLE user ADD COLUMN id INT DEFAULT NULL"); $this->addSql("UPDATE user SET id = user_id"); $this->addSql("ALTER TABLE user MODIFY COLUMN id INT NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id"); diff --git a/app/Migrations/Schema/V110/Version20150603181728.php b/app/Migrations/Schema/V110/Version20150603181728.php index f262b5c9d3..632a462a28 100644 --- a/app/Migrations/Schema/V110/Version20150603181728.php +++ b/app/Migrations/Schema/V110/Version20150603181728.php @@ -66,6 +66,8 @@ class Version20150603181728 extends AbstractMigrationChamilo $this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)"); $this->addSql("DELETE FROM c_item_property WHERE to_group_id NOT IN (SELECT id FROM c_group_info)"); + $this->addSql('UPDATE c_item_property cip SET cip.to_group_id = (SELECT cgi.iid FROM c_group_info cgi WHERE cgi.c_id = cip.c_id AND cgi.id = cip.to_group_id)'); + $this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course(id)'); $this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181330D47E9 FOREIGN KEY (to_group_id) REFERENCES c_group_info (iid)'); $this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id)'); diff --git a/custompages/index-unlogged-dist.php b/custompages/index-unlogged-dist.php index 202ade8818..0025f223c9 100644 --- a/custompages/index-unlogged-dist.php +++ b/custompages/index-unlogged-dist.php @@ -101,12 +101,12 @@ $rootWeb = api_get_path('WEB_PATH'); diff --git a/documentation/changelog.html b/documentation/changelog.html index a9cdd201a4..d676d5fb73 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -5085,9 +5085,9 @@ a simple videoconferencing interface.


- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/credits.html b/documentation/credits.html index f0f926ad5b..6f548e8ba8 100755 --- a/documentation/credits.html +++ b/documentation/credits.html @@ -765,8 +765,8 @@ To know more about the Chamilo Association and how to get involve, Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/dependencies.html b/documentation/dependencies.html index bce4278497..cf93844e18 100755 --- a/documentation/dependencies.html +++ b/documentation/dependencies.html @@ -137,9 +137,9 @@ ensure all components are installed by an expert in the field.

- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/index.html b/documentation/index.html index 1d9fb51bb1..e8e409def5 100755 --- a/documentation/index.html +++ b/documentation/index.html @@ -56,8 +56,8 @@
- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/installation_guide.html b/documentation/installation_guide.html index 7809bae2a6..50e5b106cb 100755 --- a/documentation/installation_guide.html +++ b/documentation/installation_guide.html @@ -787,9 +787,9 @@ If you have issues with files taking a long time to download, make sure you reco
- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/installation_guide_es_ES.html b/documentation/installation_guide_es_ES.html index bb276d151c..96ba9d2732 100755 --- a/documentation/installation_guide_es_ES.html +++ b/documentation/installation_guide_es_ES.html @@ -805,9 +805,9 @@ Apache2: La configuración para nuestro sitio de ejemplo my.chamilo10.net sería
- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/installation_guide_fr_FR.html b/documentation/installation_guide_fr_FR.html index d5b47602ad..7e32ea1953 100644 --- a/documentation/installation_guide_fr_FR.html +++ b/documentation/installation_guide_fr_FR.html @@ -818,9 +818,9 @@ Ce sont uniquement les redirections à placer dans un bloc server{}, comme les a
-Valid XHTML 1.0 Transitional +Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/license.html b/documentation/license.html index 3fe5991f96..8096e7832b 100755 --- a/documentation/license.html +++ b/documentation/license.html @@ -733,10 +733,10 @@ Public License instead of this License. But first, please read Valid XHTML 1.0 Transitional - Valid CSS diff --git a/documentation/migration-checklist.html b/documentation/migration-checklist.html index 08e35b8b5b..46a073c72f 100755 --- a/documentation/migration-checklist.html +++ b/documentation/migration-checklist.html @@ -55,9 +55,9 @@
Don't have time or resources to optimize your Chamilo installation yourself? Hire an official Chamilo provider and get it sorted out professionally by specialists. - Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS

Authors

diff --git a/documentation/optimization.html b/documentation/optimization.html index d6867b1870..84fb71dcb7 100755 --- a/documentation/optimization.html +++ b/documentation/optimization.html @@ -406,9 +406,9 @@ Header append Vary User-Agent env=!dont-vary
Don't have time or resources to optimize your Chamilo installation yourself? Hire an official Chamilo provider and get it sorted out professionally by specialists. - Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS
@@ -604,10 +604,10 @@ This should have an immediate effect on the load average on your server.
Don't have time or resources to optimize your Chamilo installation - yourself? Hire an official Chamilo provider and get it sorted out professionally by specialists. - Valid XHTML 1.0 Transitional + yourself? Hire an official Chamilo provider and get it sorted out professionally by specialists. + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/documentation/readme.html b/documentation/readme.html index 927c8b7828..8ccd606451 100755 --- a/documentation/readme.html +++ b/documentation/readme.html @@ -140,9 +140,9 @@ Mail: info@chamilo.org
- Valid XHTML 1.0 Transitional + Valid XHTML 1.0 Transitional - Valid CSS + Valid CSS diff --git a/main/create_course/add_course.php b/main/create_course/add_course.php index 3b477be96b..19b9c1edf3 100755 --- a/main/create_course/add_course.php +++ b/main/create_course/add_course.php @@ -183,8 +183,7 @@ if ($course_validation_feature) { // if it is activated. if (empty($terms_and_conditions_url)) { if (api_get_setting('allow_terms_conditions') == 'true') { - $terms_and_conditions_url = api_get_path(WEB_CODE_PATH); - $terms_and_conditions_url .= 'auth/inscription.php?legal'; + $terms_and_conditions_url = api_get_path(WEB_CODE_PATH).'auth/inscription.php?legal'; } } diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index 922198d8fc..ec11083be1 100755 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -118,7 +118,8 @@ class FillBlanks extends Question // get input size var lainputsize = 200; if ($("#samplesize\\\["+i+"\\\]").width()) { - lainputsize = $("#samplesize\\\["+i+"\\\]").width(); + // this is a weird patch to avoid to reduce the size of input blank when you are writing in the ckeditor. + lainputsize = $("#samplesize\\\["+i+"\\\]").width() + 9; } if (document.getElementById("weighting["+i+"]")) { diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index edafbcd084..2d4f1206f0 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1190,7 +1190,7 @@ abstract class Question * @author Olivier Brouckaert * @param integer $deleteFromEx - exercise ID if the question is only removed from one exercise */ - function delete($deleteFromEx = 0) + public function delete($deleteFromEx = 0) { $course_id = api_get_course_int_id(); @@ -1199,7 +1199,7 @@ abstract class Question $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER); $TBL_QUIZ_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); - $id = $this->id; + $id = intval($this->id); // if the question must be removed from all exercises if (!$deleteFromEx) { @@ -1223,27 +1223,33 @@ abstract class Question } $sql = "DELETE FROM $TBL_EXERCISE_QUESTION - WHERE c_id = $course_id AND question_id = " . intval($id) . ""; + WHERE c_id = $course_id AND question_id = " . $id; Database::query($sql); $sql = "DELETE FROM $TBL_QUESTIONS - WHERE c_id = $course_id AND id = " . intval($id) . ""; + WHERE c_id = $course_id AND id = " . $id; Database::query($sql); $sql = "DELETE FROM $TBL_REPONSES - WHERE c_id = $course_id AND question_id = " . intval($id) . ""; + WHERE c_id = $course_id AND question_id = " . $id; Database::query($sql); // remove the category of this question in the question_rel_category table $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY - WHERE c_id = $course_id AND question_id = " . intval($id) . " AND c_id=" . api_get_course_int_id(); + WHERE + c_id = $course_id AND + question_id = " . $id; Database::query($sql); - api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionDeleted', api_get_user_id()); + api_item_property_update( + $this->course, + TOOL_QUIZ, + $id, + 'QuizQuestionDeleted', + api_get_user_id() + ); $this->removePicture(); - // resets the object - $this->Question(); } else { // just removes the exercise from the list $this->removeFromList($deleteFromEx); @@ -1251,7 +1257,14 @@ abstract class Question // disassociate question with this exercise $this->search_engine_edit($deleteFromEx, FALSE, TRUE); } - api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionDeleted', api_get_user_id()); + + api_item_property_update( + $this->course, + TOOL_QUIZ, + $id, + 'QuizQuestionDeleted', + api_get_user_id() + ); } } @@ -1259,10 +1272,10 @@ abstract class Question * Duplicates the question * * @author Olivier Brouckaert - * @param array Course info of the destination course + * @param array $course_info Course info of the destination course * @return int ID of the new question */ - public function duplicate($course_info = null) + public function duplicate($course_info = []) { if (empty($course_info)) { $course_info = $this->course; @@ -1348,6 +1361,7 @@ abstract class Question public function get_question_type_name() { $key = self::$questionTypes[$this->type]; + return get_lang($key[1]); } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 0bf88d1a49..50ffee04b8 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -891,32 +891,36 @@ function deleteForumCategoryThread($content, $id) */ function delete_post($post_id) { - $table_posts = Database :: get_course_table(TABLE_FORUM_POST); $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); $post_id = intval($post_id); $course_id = api_get_course_int_id(); + $em = Database::getManager(); - // Get parent_post_id of deleted post. - $tab_post_info = get_post_information($post_id); + $post = $em + ->getRepository('ChamiloCourseBundle:CForumPost') + ->findOneBy(['cId' => $course_id, 'postId' => $post_id]); - if ($tab_post_info) { - $post_parent_id_of_deleted_post = intval($tab_post_info['post_parent_id']); - $thread_id_of_deleted_post = $tab_post_info['thread_id']; - $forum_if_of_deleted_post = $tab_post_info['forum_id']; - $sql = "UPDATE $table_posts - SET post_parent_id=$post_parent_id_of_deleted_post + if ($post) { + $em + ->createQuery(' + UPDATE ChamiloCourseBundle:CForumPost p + SET p.postParentId = :parent_of_deleted_post WHERE - c_id = $course_id AND - post_parent_id=$post_id AND - thread_id=$thread_id_of_deleted_post AND - forum_id=$forum_if_of_deleted_post"; - - Database::query($sql); - - // Note: This has to be a recursive function that deletes all of the posts in this block. - $sql = "DELETE FROM $table_posts - WHERE c_id = $course_id AND post_id = ".intval($post_id).""; - Database::query($sql); + p.cId = :course AND + p.postParentId = :post AND + p.threadId = :thread_of_deleted_post AND + p.forumId = :forum_of_deleted_post + ') + ->execute([ + 'parent_of_deleted_post' => $post->getPostParentId(), + 'course' => $course_id, + 'post' => $post->getPostId(), + 'thread_of_deleted_post' => $post->getThreadId(), + 'forum_of_deleted_post' => $post->getForumId() + ]); + + $em->remove($post); + $em->flush(); // Delete attachment file about this post id. delete_attachment($post_id); @@ -1884,7 +1888,7 @@ function getThreadInfo($threadId, $cId) * * @return array containing all the information about the posts of a given thread */ -function getPosts($forumInfo, $threadId, $orderDirection = 'ASC', $recursive = false, $postId = 0, $depth = -1) +function getPosts($forumInfo, $threadId, $orderDirection = 'ASC', $recursive = false, $postId = null, $depth = -1) { $list = []; @@ -1918,7 +1922,6 @@ function getPosts($forumInfo, $threadId, $orderDirection = 'ASC', $recursive = f ->addCriteria($criteria) ->addOrderBy('p.postId', $orderDirection); - $posts = $qb->getQuery()->getResult(); $depth++; @@ -2526,7 +2529,7 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa 'poster_name' => isset($values['poster_name']) ? $values['poster_name'] : '', 'post_date' => $post_date, 'post_notification' => isset($values['post_notification']) ? (int) $values['post_notification'] : 0, - 'post_parent_id' => 0, + 'post_parent_id' => null, 'visible' => $visible, 'post_id' => 0 ]; @@ -3415,7 +3418,7 @@ function show_edit_post_form( $form->addElement('hidden', 'thread_id', $current_thread['thread_id']); $form->addElement('hidden', 'id_attach', $id_attach); - if ($current_post['post_parent_id'] == 0) { + if (empty($current_post['post_parent_id'])) { $form->addElement('hidden', 'is_first_post_of_thread', '1'); } @@ -3531,7 +3534,7 @@ function show_edit_post_form( if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && - $current_post['post_parent_id'] == 0 + empty($current_post['post_parent_id']) ) { // The sticky checkbox only appears when it is the first post of a thread. $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost')); @@ -4321,12 +4324,12 @@ function store_move_post($values) ); // Moving the post to the newly created thread. - $sql = "UPDATE $table_posts SET thread_id='".intval($new_thread_id)."', post_parent_id='0' + $sql = "UPDATE $table_posts SET thread_id='".intval($new_thread_id)."', post_parent_id = NULL WHERE c_id = $course_id AND post_id='".intval($values['post_id'])."'"; Database::query($sql); // Resetting the parent_id of the thread to 0 for all those who had this moved post as parent. - $sql = "UPDATE $table_posts SET post_parent_id='0' + $sql = "UPDATE $table_posts SET post_parent_id = NULL WHERE c_id = $course_id AND post_parent_id='".intval($values['post_id'])."'"; Database::query($sql); @@ -4385,12 +4388,12 @@ function store_move_post($values) Database::query($sql); // moving to the chosen thread - $sql = "UPDATE $table_posts SET thread_id='".intval($_POST['thread'])."', post_parent_id='0' + $sql = "UPDATE $table_posts SET thread_id='".intval($_POST['thread'])."', post_parent_id = NULL WHERE c_id = $course_id AND post_id='".intval($values['post_id'])."'"; Database::query($sql); // resetting the parent_id of the thread to 0 for all those who had this moved post as parent - $sql = "UPDATE $table_posts SET post_parent_id='0' + $sql = "UPDATE $table_posts SET post_parent_id = NULL WHERE c_id = $course_id AND post_parent_id='".intval($values['post_id'])."'"; Database::query($sql); diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 15d1b06172..edb913d106 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3236,7 +3236,7 @@ class CourseManager $medium->resize(85); $medium->send_image($course_medium_image, -1, 'png'); $normal = new Image($source_file); - $normal->resize(300); + $normal->resize(400); $normal->send_image($course_image, -1, 'png'); $result = $medium && $normal; @@ -3358,7 +3358,7 @@ class CourseManager $with_special_courses = ' course.code IN ("' . implode('","', $special_course_list) . '")'; } - $courseList = array(); + $courseList = []; if (!empty($with_special_courses)) { $sql = "SELECT course.id, @@ -3385,7 +3385,7 @@ class CourseManager continue; } - $params = array(); + $params = []; // Get notifications. $course_info['id_session'] = null; $course_info['status'] = $course['status']; @@ -3402,13 +3402,13 @@ class CourseManager if ($load_dirs) { $params['document'] = '' . Display::returnFontAwesomeIcon('folder-open') . ''; - $params['document'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container')); + $params['document'] .= Display::div('', ['id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container']); } }else{ if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED && $load_dirs) { $params['document'] = '' . Display::returnFontAwesomeIcon('folder-open') . ''; - $params['document'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container')); + $params['document'] .= Display::div('', ['id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container']); } } @@ -3426,9 +3426,8 @@ class CourseManager if (api_get_setting('display_teacher_in_courselist') === 'true') { $params['teachers'] = CourseManager::getTeachersFromCourseByCode($course['code']); } - - $iconName = basename($course_info['course_image']); - if ($showCustomIcon === 'true' && $iconName != 'course.png') { + + if ($showCustomIcon === 'true') { $params['thumbnails'] = $course_info['course_image']; $params['image'] = $course_info['course_image_large']; } diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 8cbed34d30..810f8551c9 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -406,7 +406,8 @@ class MessageManager $new_user_list, $subject, $content, - $group_info + $group_info, + $file_attachments ); } diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index b482084a76..3944c97acb 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -2266,16 +2266,12 @@ class Tracking $groupBy";*/ $sql = " - SELECT - lp_id, - view_count, - progress - FROM $lpViewTable lp_view + SELECT lp_id, view_count, progress FROM $lpViewTable lp_view WHERE - $conditionToString - $groupBy + $conditionToString + $groupBy ORDER BY view_count DESC - "; + "; $result = Database::query($sql); @@ -2787,8 +2783,8 @@ class Tracking // Check the real number of LPs corresponding to the filter in the // database (and if no list was given, get them all) - - $res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table WHERE c_id = $course_id $condition_lp"); + $sql = "SELECT DISTINCT(id) FROM $lp_table WHERE c_id = $course_id $condition_lp"; + $res_row_lp = Database::query($sql); $count_row_lp = Database::num_rows($res_row_lp); // calculates time @@ -2796,15 +2792,18 @@ class Tracking while ($row_lp = Database::fetch_array($res_row_lp)) { $lp_id = intval($row_lp['id']); $sql = 'SELECT SUM(total_time) - FROM '.$t_lpiv.' AS item_view - INNER JOIN '.$t_lpv.' AS view - ON item_view.lp_view_id = view.id + FROM '.$t_lpiv.' AS item_view + INNER JOIN '.$t_lpv.' AS view + ON ( + item_view.lp_view_id = view.id AND + item_view.c_id = view.c_id + ) WHERE - item_view.c_id = '.$course_id.' AND - view.c_id = '.$course_id.' AND - view.lp_id = '.$lp_id.' - AND view.user_id = '.$student_id.' AND - session_id = '.$session_id; + item_view.c_id = '.$course_id.' AND + view.c_id = '.$course_id.' AND + view.lp_id = '.$lp_id.' AND + view.user_id = '.$student_id.' AND + session_id = '.$session_id; $rs = Database::query($sql); if (Database :: num_rows($rs) > 0) { diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index e506c2b1ba..253d8003f0 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -208,8 +208,6 @@ class IndexManager $html .= '
  • '.get_lang('Dashboard').'
  • '; } } - - $html .= ''; } @@ -934,8 +932,6 @@ class IndexManager $show_create_link = false; $show_course_link = false; - $userInfo = api_get_user_info(); - if ((api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) || api_is_student() ) { @@ -1000,14 +996,6 @@ class IndexManager } } - $my_account_content .= '
  • '. - Display::return_icon('new-course.png', get_lang('Diagnosis')) . get_lang('Diagnosis').'
  • '; - - if ($userInfo['status'] == DRH) { - $my_account_content .= '
  • ' . - Display::return_icon('new-course.png', get_lang('ManageDiagnosis')) . get_lang('Diagnosis') . '
  • '; - } - $my_account_content .= ''; if (!empty($my_account_content)) { @@ -1062,7 +1050,7 @@ class IndexManager $user_id, $this->load_directories_preview ); - + // Display courses. $courses = CourseManager::returnCourses( $user_id, @@ -1070,14 +1058,16 @@ class IndexManager ); $this->tpl->assign('special_courses', $specialCourses); $this->tpl->assign('courses', $courses); - if ($_configuration['view_grid_courses']==true) { + if (isset($_configuration['view_grid_courses']) && $_configuration['view_grid_courses']) { $listCourse = $this->tpl->fetch( - $this->tpl->get_template('user_portal/grid_courses.tpl')); + $this->tpl->get_template('/user_portal/grid_courses.tpl')); } else { $listCourse = $this->tpl->fetch( - $this->tpl->get_template('user_portal/classic_courses.tpl')); - } - $courseCount = $specialCourses['course_count'] + $courses['course_count']; + $this->tpl->get_template('/user_portal/classic_courses.tpl')); + } + if (!empty($specialCourses['course_count']) && !empty($courses['course_count'])) { + $courseCount = intval($specialCourses['course_count']) + intval($courses['course_count']); + } } $sessions_with_category = ''; @@ -1377,7 +1367,7 @@ class IndexManager } return [ - 'html' => $sessions_with_category.$sessions_with_no_category.$listCourse.$special_courses, + 'html' => $sessions_with_category.$sessions_with_no_category.$listCourse, 'session_count' => $sessionCount, 'course_count' => $courseCount ]; diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 36dbeb3508..9efd75366f 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -1595,7 +1595,8 @@ class learnpath error_log('New LP - In learnpath::get_brother_chapters()', 0); } - if (empty($id)|| $id != strval(intval($id))) { + if (empty($id) || $id != strval(intval($id))) { + return array (); } @@ -1606,21 +1607,24 @@ class learnpath if (Database :: num_rows($res_parent) > 0) { $row_parent = Database :: fetch_array($res_parent); $parent = $row_parent['parent_item_id']; - $sql_bros = "SELECT * FROM $lp_item - WHERE - c_id = ".$course_id." AND - parent_item_id = $parent AND - id = $id AND - item_type='dokeos_chapter' - ORDER BY display_order"; - $res_bros = Database::query($sql_bros); - $list = array (); + $sql = "SELECT * FROM $lp_item + WHERE + c_id = ".$course_id." AND + parent_item_id = $parent AND + id = $id AND + item_type='dokeos_chapter' + ORDER BY display_order"; + $res_bros = Database::query($sql); + + $list = array(); while ($row_bro = Database :: fetch_array($res_bros)) { $list[] = $row_bro; } + return $list; } - return array (); + + return array(); } /** @@ -1959,7 +1963,7 @@ class learnpath * Gets the navigation bar for the learnpath display screen * @return string The HTML string to use as a navigation bar */ - public function get_navigation_bar($idBar = null, $display=null) { + public function get_navigation_bar($idBar = null, $display = null) { if ($this->debug > 0) { error_log('New LP - In learnpath::get_navigation_bar()', 0); } @@ -3295,6 +3299,7 @@ class learnpath $html .= ''; } } + return $html; } @@ -6355,18 +6360,18 @@ class learnpath $res = Database::query($sql); $row = Database::fetch_array($res); switch ($row['item_type']) { - case 'dokeos_chapter' : - case 'dir' : - case 'asset' : - case 'sco' : - if (isset ($_GET['view']) && $_GET['view'] == 'build') { + case 'dokeos_chapter': + case 'dir': + case 'asset': + case 'sco': + if (isset($_GET['view']) && $_GET['view'] == 'build') { $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_item_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', 'edit', $item_id, $row); } else { $return .= $this->display_item_small_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', $row); } break; - case TOOL_DOCUMENT : + case TOOL_DOCUMENT: $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); $sql = "SELECT lp.*, doc.path as dir FROM " . $tbl_lp_item . " as lp @@ -6381,7 +6386,7 @@ class learnpath $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_document_form('edit', $item_id, $row_step); break; - case TOOL_LINK : + case TOOL_LINK: $link_id = (string) $row['path']; if (ctype_digit($link_id)) { $tbl_link = Database :: get_course_table(TABLE_LINK); @@ -6396,7 +6401,7 @@ class learnpath $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_link_form('edit', $item_id, $row); break; - case TOOL_LP_FINAL_ITEM : + case TOOL_LP_FINAL_ITEM: $_SESSION['finalItem'] = true; $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); $sql = "SELECT lp.*, doc.path as dir @@ -6412,7 +6417,7 @@ class learnpath $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_document_form('edit', $item_id, $row_step); break; - case 'dokeos_module' : + case 'dokeos_module': if (isset ($_GET['view']) && $_GET['view'] == 'build') { $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_item_form($row['item_type'], get_lang('EditCurrentModule') . ' :', 'edit', $item_id, $row); @@ -6420,23 +6425,23 @@ class learnpath $return .= $this->display_item_small_form($row['item_type'], get_lang('EditCurrentModule') . ' :', $row); } break; - case TOOL_QUIZ : + case TOOL_QUIZ: $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_quiz_form('edit', $item_id, $row); break; - case TOOL_HOTPOTATOES : + case TOOL_HOTPOTATOES: $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_hotpotatoes_form('edit', $item_id, $row); break; - case TOOL_STUDENTPUBLICATION : + case TOOL_STUDENTPUBLICATION: $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_student_publication_form('edit', $item_id, $row); break; - case TOOL_FORUM : + case TOOL_FORUM: $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_forum_form('edit', $item_id, $row); break; - case TOOL_THREAD : + case TOOL_THREAD: $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_thread_form('edit', $item_id, $row); break; diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index 0e959707f0..99526b6b3b 100755 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -272,7 +272,7 @@ if ( $time_start_date = api_strtotime($row_dates['start_date'], 'UTC'); $time_exe_date = api_strtotime($row_dates['exe_date'], 'UTC'); - $mytime = ((int) $time_exe_date - (int) $time_start_date); + $mytime = (int) $time_exe_date - (int) $time_start_date; $score = (float) $row_dates['exe_result']; $max_score = (float) $row_dates['exe_weighting']; diff --git a/main/template/default/auth/courses_categories.php b/main/template/default/auth/courses_categories.php index 2ca5f6c581..0df1cfc51a 100755 --- a/main/template/default/auth/courses_categories.php +++ b/main/template/default/auth/courses_categories.php @@ -190,7 +190,6 @@ if ($showCourses && $action != 'display_sessions') { if (!empty($search_term)) { echo "

    ".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."
    "; } - $listCategory = CourseManager::getCategoriesList(); $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $user_id = api_get_user_id(); @@ -222,7 +221,7 @@ if ($showCourses && $action != 'display_sessions') { $html .= '

    '; // display thumbnail - $html .= returnThumbnail($course, $listCategory[$course['category']]); + $html .= returnThumbnail($course); // display course title and button bloc $html .= '
    '; @@ -289,10 +288,9 @@ echo $cataloguePagination; /** * Display the course catalog image of a course * @param array $course - * @param string $categoryTitle * @return string HTML string */ -function returnThumbnail($course, $categoryTitle=null) +function returnThumbnail($course) { $html = ''; $title = cut($course['title'], 70); @@ -308,7 +306,10 @@ function returnThumbnail($course, $categoryTitle=null) $html .= '
    '; $html .= ''.api_htmlentities($title).''; + $categoryTitle = $course['category']; if (!empty($categoryTitle)) { + $listCategory = CourseManager::getCategoriesList(); + $categoryTitle = $listCategory[$categoryTitle]; $html .= ''. $categoryTitle.''; $html .= '
    '; } diff --git a/main/template/default/layout/login_form.tpl b/main/template/default/layout/login_form.tpl index 4cac75ea34..b3d1b86a39 100755 --- a/main/template/default/layout/login_form.tpl +++ b/main/template/default/layout/login_form.tpl @@ -16,11 +16,11 @@ {% if "allow_lostpassword" | get_setting == 'true' or "allow_registration" | get_setting == 'true' %} {% endif %} diff --git a/main/webservices/cm_webservice_forum.php b/main/webservices/cm_webservice_forum.php index ddd68eface..c5250a29ed 100755 --- a/main/webservices/cm_webservice_forum.php +++ b/main/webservices/cm_webservice_forum.php @@ -234,6 +234,7 @@ class WSCMForum extends WSCM { if($this->verifyUserPass($username, $password) == "valid") { + $em = Database::getManager(); $course_db = CourseManager::get_course_information($course_code); $user_id = UserManager::get_user_id_from_username($username); @@ -251,19 +252,23 @@ class WSCMForum extends WSCM $title = htmlentities($title); $content = htmlentities($content); - $sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible) - VALUES ('".Database::escape_string($title)."', - '".Database::escape_string(isset($content) ? (api_html_entity_decode($content)) : null)."', - '".Database::escape_string($thread_id)."', - '".Database::escape_string($forum_id)."', - '".Database::escape_string($user_id)."', - '".Database::escape_string($post_date)."', - '".Database::escape_string(isset($post_notification)?$post_notification:null)."', - '".Database::escape_string(isset($my_post)?$my_post:null)."', - '".Database::escape_string($visible)."')"; + $postDate = new DateTime(api_get_utc_datetime(), new DateTimeZone('UTC')); + $post = new \Chamilo\CourseBundle\Entity\CForumPost(); + $post + ->setPostTitle($title) + ->setPostText(isset($content) ? (api_html_entity_decode($content)) : null) + ->setThreadId($thread_id) + ->setForumId($forum_id) + ->setPosterId($user_id) + ->setPostDate($postDate) + ->setPostNotification(isset($post_notification) ? $post_notification : null) + ->setPostParentId(isset($my_post) ? $my_post : null) + ->setVisible($visible); + + $em->persist($post); + $em->flush(); - $result=Database::query($sql); return "Post enviado!"; //return $sql; diff --git a/src/Chamilo/CoreBundle/Menu/NavBuilder.php b/src/Chamilo/CoreBundle/Menu/NavBuilder.php index 4032737841..0464d3afd3 100644 --- a/src/Chamilo/CoreBundle/Menu/NavBuilder.php +++ b/src/Chamilo/CoreBundle/Menu/NavBuilder.php @@ -121,7 +121,7 @@ class NavBuilder extends ContainerAware 'route' => 'main', 'routeParameters' => array( 'name' => 'social/home.php', - ), + ) ) ); } @@ -151,6 +151,7 @@ class NavBuilder extends ContainerAware } // Getting site information + $site = $this->container->get('sonata.page.site.selector'); $host = $site->getRequestContext()->getHost(); $siteManager = $this->container->get('sonata.page.manager.site'); @@ -259,7 +260,7 @@ class NavBuilder extends ContainerAware 'uid' => $user->getId(), ), 'query' => '1', - 'icon' => 'fa fa-sign-out', + 'icon' => 'fa fa-sign-out' ) ); diff --git a/tests/features/forum.feature b/tests/features/forum.feature index 3172fc1b73..18f35cff2d 100644 --- a/tests/features/forum.feature +++ b/tests/features/forum.feature @@ -28,4 +28,20 @@ Feature: Forum tool | post_title | Thread One | | post_text | This is a the first thread in a forum for test | And I press "SubmitPost" - Then I should see "The new thread has been added" \ No newline at end of file + Then I should see "The new thread has been added" + + Scenario: Reply to forum message + Given I am on "/main/forum/reply.php?forum=1&thread=1&post=1&action=replymessage" + When I fill in the following: + | post_text | This is a reply to the first message for test | + And I press "SubmitPost" + Then I should see "The reply has been added" + + Scenario: Delete a forum message + Given I am on "/main/forum/viewthread.php?forum=1&thread=1&action=delete&content=post&id=2" + Then I should see "Post has been deleted" + + Scenario: Quote a forum message + Given I am on "/main/forum/reply.php?forum=1&thread=1&post=1&action=quote" + When I press "SubmitPost" + Then I should see "The reply has been added" \ No newline at end of file