From 4a3e2c04f008dd8532159b8d74f32a136b1b8707 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 2 May 2016 15:13:53 +0200 Subject: [PATCH 01/26] Fix fatal error see #8176 --- main/exercice/question.class.php | 38 ++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 6cf0148e9c..317fcd4173 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]); } From 30e3411ee79e67894b1fe4724994fc0415fbe300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Mon, 2 May 2016 09:11:22 -0500 Subject: [PATCH 02/26] Minor Fix in Attachment mail announcements --- main/inc/lib/message.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 71e51788f3..3be2dc06bc 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 ); } From 97c0d24a2cdd6f78da5c9731c406884296d2feaa Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 2 May 2016 10:55:32 -0500 Subject: [PATCH 03/26] Fix migration using the group idd instead of group id in c_item_property - refs #8200 --- app/Migrations/Schema/V110/Version20150603181728.php | 2 ++ 1 file changed, 2 insertions(+) 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)'); From ab8df6b2cde25511fe119567684bb62482c58b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 21 Apr 2016 10:55:36 -0500 Subject: [PATCH 04/26] Added My Certificates link in dropdown user menu - Refs #8191 --- main/inc/lib/template.lib.php | 5 +++++ main/template/default/layout/menu.tpl | 1 + 2 files changed, 6 insertions(+) diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 7b407dee40..427294bb91 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -916,6 +916,11 @@ class Template $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); + //Certificate Link + $certificatesUrl = api_get_path(WEB_CODE_PATH).'gradebook/my_certificates.php'; + $certificateLink = Display::url(get_lang('MyCertificates'), $certificatesUrl); + $this->assign('certificate_link', $certificateLink); + $institution = api_get_setting('Institution'); $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; diff --git a/main/template/default/layout/menu.tpl b/main/template/default/layout/menu.tpl index 0f4e41389b..78ff684dc6 100755 --- a/main/template/default/layout/menu.tpl +++ b/main/template/default/layout/menu.tpl @@ -28,6 +28,7 @@
  • {{ profile_link }} {{ message_link }} + {{ certificate_link }}
  • From d9b490b537d1188a61f57f62f5ed3482b3b65c52 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 3 May 2016 09:00:42 +0200 Subject: [PATCH 05/26] Add sql_mode = '' to avoid errors in php 5.7 see #8200 Fix queries --- app/Migrations/Schema/V110/Version110.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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"); From d30235711163af546b45cc91f978ed5addd85acf Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 3 May 2016 13:14:01 +0200 Subject: [PATCH 06/26] Add number validators see #8177 --- main/exercice/exercise.class.php | 2 ++ .../lib/pear/HTML/QuickForm/Rule/Range.php | 30 ++++++++++--------- .../lib/pear/HTML/QuickForm/RuleRegistry.php | 5 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 33a61274bc..83699b4519 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2243,6 +2243,8 @@ class Exercise array('id' => 'pass_percentage') ); $form->addRule('pass_percentage', get_lang('Numeric'), 'numeric'); + $form->addRule('pass_percentage', get_lang('ValueTooSmall'), 'min_numeric_length', 0); + $form->addRule('pass_percentage', get_lang('ValueTooBig'), 'max_numeric_length', 100); // add the text_when_finished textbox $form->addHtmlEditor( diff --git a/main/inc/lib/pear/HTML/QuickForm/Rule/Range.php b/main/inc/lib/pear/HTML/QuickForm/Rule/Range.php index b40222ca31..65da6b429c 100755 --- a/main/inc/lib/pear/HTML/QuickForm/Rule/Range.php +++ b/main/inc/lib/pear/HTML/QuickForm/Rule/Range.php @@ -40,21 +40,25 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule * @access public * @return boolean true if value is valid */ - function validate($value, $options) + public function validate($value, $options) { - // Modified by Ivan Tcholakov, 16-MAR-2010. - //$length = strlen($value); $length = api_strlen($value); - // + switch ($this->name) { - case 'minlength': return ($length >= $options); - case 'maxlength': return ($length <= $options); - default: return ($length >= $options[0] && $length <= $options[1]); + case 'min_numeric_length': + return (float) $value >= $options; + case 'max_numeric_length': + return (float) $value <= $options; + case 'minlength': + return $length >= $options; + case 'maxlength': + return $length <= $options; + default: + return $length >= $options[0] && $length <= $options[1]; } - } // end func validate - + } - function getValidationScript($options = null) + public function getValidationScript($options = null) { switch ($this->name) { case 'minlength': @@ -67,7 +71,5 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule $test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')'; } return array('', "{jsVar} != '' && {$test}"); - } // end func getValidationScript - -} // end class HTML_QuickForm_Rule_Range -?> + } +} \ No newline at end of file diff --git a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php index 4b90f49830..838b22cae3 100755 --- a/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php +++ b/main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php @@ -119,6 +119,8 @@ class HTML_QuickForm_RuleRegistry 'required' => 'HTML_QuickForm_Rule_Required', 'maxlength' => 'HTML_QuickForm_Rule_Range', 'minlength' => 'HTML_QuickForm_Rule_Range', + 'max_numeric_length' => 'HTML_QuickForm_Rule_Range', + 'min_numeric_length' => 'HTML_QuickForm_Rule_Range', 'rangelength' => 'HTML_QuickForm_Rule_Range', 'email' => 'HTML_QuickForm_Rule_Email', 'regex' => 'HTML_QuickForm_Rule_Regex', @@ -149,8 +151,7 @@ class HTML_QuickForm_RuleRegistry 'maxfilesize', 'HTML_QuickForm_Rule_MaxFileSize', 'mimetype', 'HTML_QuickForm_Rule_MimeType', 'filename', 'HTML_QuickForm_Rule_FileName', - 'validquestiontype' => 'HTML_QuickForm_Rule_QuestionType', - + 'validquestiontype' => 'HTML_QuickForm_Rule_QuestionType' ); $class = $rules[$ruleName]; From 31e1f2772b4852885f0c3b1beafb94158ff04b87 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 3 May 2016 08:51:22 -0500 Subject: [PATCH 07/26] Remove unused variables - refs BT#11148 --- main/exercice/exercise_show.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index cf5572411a..bd929c4bb4 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -398,7 +398,6 @@ foreach ($questionList as $questionId) { $questionScore = $question_result['score']; $totalScore += $question_result['score']; } elseif ($answerType == FREE_ANSWER) { - $answer = $str; $question_result = $objExercise->manage_answer( $id, $questionId, @@ -413,7 +412,6 @@ foreach ($questionList as $questionId) { $questionScore = $question_result['score']; $totalScore += $question_result['score']; } elseif ($answerType == ORAL_EXPRESSION) { - $answer = $str; $question_result = $objExercise->manage_answer( $id, $questionId, From 53c7f92d7b958a2b65d16dac141551af4d840709 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 3 May 2016 18:36:39 -0500 Subject: [PATCH 08/26] Minor - Remove E_NOTICE --- main/forum/forumfunction.inc.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 68a7e0acd9..3029c51d80 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -178,10 +178,8 @@ function handle_forum_and_forumcategories($lp_id = null) */ function show_add_forumcategory_form($inputvalues = array(), $lp_id) { - $gradebook = Security::remove_XSS($_GET['gradebook']); - // Initialize the object. - $form = new FormValidator('forumcategory', 'post', 'index.php?gradebook='.$gradebook.'&'.api_get_cidreq()); + $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); // hidden field if from learning path $form->addElement('hidden', 'lp_id', $lp_id); @@ -231,8 +229,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id) function show_add_forum_form($inputvalues = array(), $lp_id) { $_course = api_get_course_info(); - $gradebook = Security::remove_XSS($_GET['gradebook']); - $form = new FormValidator('forumcategory', 'post', 'index.php?gradebook='.$gradebook.'&'.api_get_cidreq()); + $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); // The header for the form if (!empty($inputvalues)) { From 3eec0c93af0514172ab7a0c1225dc7d46263a262 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 3 May 2016 18:37:34 -0500 Subject: [PATCH 09/26] Add Behat feature to test forum tool as a platform admin --- tests/features/forum.feature | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/features/forum.feature diff --git a/tests/features/forum.feature b/tests/features/forum.feature new file mode 100644 index 0000000000..13a8fcfbe6 --- /dev/null +++ b/tests/features/forum.feature @@ -0,0 +1,31 @@ +Feature: Forum tool + In order to use the Forum tool + The teachers should be able to create forum categories, forums, forum threads + + Background: + Given I am a platform administrator + And I am on course "TEMP" homepage + + Scenario: Create a forum category + Given I am on "/main/forum/index.php?action=add&content=forumcategory" + When I fill in the following: + | forum_category_title | Forum Category Test | + | forum_category_comment | This is the first forum category for test | + And I press "SubmitForumCategory" + Then I should see "The forum category has been added" + + Scenario: Create a forum + Given I am on "/main/forum/index.php?action=add&content=forum" + When I fill in the following: + | forum_title | Forum Test | + | forum_comment | This is the first forum for test | + And I press "SubmitForum" + Then I should see "The forum has been added" + + Scenario: Create a forum thread + Given I am on "/main/forum/newthread.php?forum=5" + When I fill in the following: + | 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 From 14c3b6c04a7cb3d4689e9fec433ad489d9b8eca7 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 4 May 2016 11:15:11 +0200 Subject: [PATCH 10/26] Add faq in menu --- src/Chamilo/CoreBundle/Menu/NavBuilder.php | 23 +++++++++++++++++++ .../FaqBundle/Resources/config/routing.yml | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/Chamilo/CoreBundle/Menu/NavBuilder.php b/src/Chamilo/CoreBundle/Menu/NavBuilder.php index 7145f64680..3cbda53756 100644 --- a/src/Chamilo/CoreBundle/Menu/NavBuilder.php +++ b/src/Chamilo/CoreBundle/Menu/NavBuilder.php @@ -126,6 +126,29 @@ class NavBuilder extends ContainerAware } } + $categories = $this->container->get('faq.entity.category_repository')->retrieveActive(); + if ($categories) { + $faq = $menu->addChild( + 'FAQ', + [ + 'route' => 'faq_index', + ] + ); + /** @var Category $category */ + foreach ($categories as $category) { + $faq->addChild( + $category->getHeadline(), + array( + 'route' => 'faq', + 'routeParameters' => array( + 'categorySlug' => $category->getSlug(), + 'questionSlug' => '', + ), + ) + )->setAttribute('divider_append', true); + } + } + // Getting site information $site = $this->container->get('sonata.page.site.selector'); diff --git a/src/Chamilo/FaqBundle/Resources/config/routing.yml b/src/Chamilo/FaqBundle/Resources/config/routing.yml index ac86738c57..db4f8aec69 100644 --- a/src/Chamilo/FaqBundle/Resources/config/routing.yml +++ b/src/Chamilo/FaqBundle/Resources/config/routing.yml @@ -1,3 +1,7 @@ +faq_index: + pattern: /faq + defaults: { _controller: ChamiloFaqBundle:Faq:index, categorySlug: null, questionSlug: null } + faq: pattern: /faq/{categorySlug}/{questionSlug} defaults: { _controller: ChamiloFaqBundle:Faq:index, categorySlug: null, questionSlug: null } From 8dc508bda4caeb72e078c864511c127b2652285c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Wed, 4 May 2016 10:00:21 -0500 Subject: [PATCH 11/26] Fix bug when you set a value in in score field it show the default value if you editing it - Refs #8183 --- main/exercice/fill_blanks.class.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index 0d31442b42..922198d8fc 100755 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -149,15 +149,11 @@ class FillBlanks extends Question if (isset($listAnswersInfo) && count($listAnswersInfo["tabweighting"]) > 0) { foreach ($listAnswersInfo["tabweighting"] as $i => $weighting) { - if (!empty($i)) { - echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";'; - } + echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";'; } foreach ($listAnswersInfo["tabinputsize"] as $i => $sizeOfInput) { - if (!empty($i)) { - echo 'document.getElementById("sizeofinput['.$i.']").value = "'.$sizeOfInput.'";'; - echo '$("#samplesize\\\['.$i.'\\\]").width('.$sizeOfInput.');'; - } + echo 'document.getElementById("sizeofinput['.$i.']").value = "'.$sizeOfInput.'";'; + echo '$("#samplesize\\\['.$i.'\\\]").width('.$sizeOfInput.');'; } } From 1324e42ec2cf2aea612870e1e60574e586f41b50 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 4 May 2016 10:16:43 -0500 Subject: [PATCH 12/26] Fix HTTPS inclusion of HTTP resources in documentation --- documentation/optimization.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 1e2f740042432206f502e9d8091da443d6fa9991 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 10:18:59 -0500 Subject: [PATCH 13/26] Fix form to create forum thread + fix its behat test --- main/forum/forumfunction.inc.php | 1 + tests/features/forum.feature | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 3029c51d80..5f13b23404 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -2773,6 +2773,7 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id = 'post_text', get_lang('Text'), true, + false, api_is_allowed_to_edit(null, true) ? array( 'ToolbarSet' => 'Forum', 'Width' => '100%', diff --git a/tests/features/forum.feature b/tests/features/forum.feature index 13a8fcfbe6..3172fc1b73 100644 --- a/tests/features/forum.feature +++ b/tests/features/forum.feature @@ -23,7 +23,7 @@ Feature: Forum tool Then I should see "The forum has been added" Scenario: Create a forum thread - Given I am on "/main/forum/newthread.php?forum=5" + Given I am on "/main/forum/newthread.php?forum=1" When I fill in the following: | post_title | Thread One | | post_text | This is a the first thread in a forum for test | From ab9ee71f5a9dcb66c5fd22b4ecc2af2c0638af82 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 4 May 2016 10:19:53 -0500 Subject: [PATCH 14/26] Fix HTTPS inclusion of HTTP resources in documentation --- documentation/changelog.html | 4 ++-- documentation/credits.html | 4 ++-- documentation/dependencies.html | 4 ++-- documentation/index.html | 4 ++-- documentation/installation_guide.html | 4 ++-- documentation/installation_guide_es_ES.html | 4 ++-- documentation/installation_guide_fr_FR.html | 4 ++-- documentation/license.html | 4 ++-- documentation/migration-checklist.html | 4 ++-- documentation/readme.html | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) 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/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 From 870291c28dac13bce55945822ad4584479330a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Wed, 4 May 2016 14:10:36 -0500 Subject: [PATCH 15/26] Fix size of input blank width reducing when you are writing in the ckeditor --- main/exercice/fill_blanks.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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+"]")) { From 7158ee4186b8cf2b884b0415d55e7608eeaf15f5 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 14:24:24 -0500 Subject: [PATCH 16/26] Revert "Fix thread creation" This reverts commit bc8e0a49b8da0f20d5886b4c74cb8dee48cbee5e. --- main/forum/forumfunction.inc.php | 4 ++-- main/forum/newthread.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 5f13b23404..53522c2417 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -2937,8 +2937,8 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id = return false; } Security::clear_token(); - - store_thread($current_forum, $values); + + return $values; } } else { $token = Security::get_token(); diff --git a/main/forum/newthread.php b/main/forum/newthread.php index fc85151e37..ab266611a8 100755 --- a/main/forum/newthread.php +++ b/main/forum/newthread.php @@ -167,7 +167,7 @@ echo ''; // Set forum attachment data into $_SESSION getAttachedFiles($current_forum['forum_id'], 0, 0); -show_add_post_form( +$values = show_add_post_form( $current_forum, $forum_setting, 'newthread', @@ -175,6 +175,11 @@ show_add_post_form( isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null ); +if (!empty($values) && isset($values['SubmitPost'])) { + // Add new thread in table forum_thread. + store_thread($current_forum, $values); +} + if (isset($origin) && $origin == 'learnpath') { Display::display_reduced_footer(); } else { From 00ff6fe1d2125ae1320cd6e171f08947de716414 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 17:12:44 -0500 Subject: [PATCH 17/26] Set post_parent_id field in c_forum_post to null instead of 0 --- main/forum/forumfunction.inc.php | 60 +++++++++++++----------- main/webservices/cm_webservice_forum.php | 27 ++++++----- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 53522c2417..01cb1c60e2 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -875,32 +875,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); @@ -1867,7 +1871,7 @@ function getThreadInfo($threadId, $cId) * * @return array containing all the information about the posts of a given thread */ -function getPosts($threadId, $orderDirection = 'ASC', $recursive = false, $postId = 0, $depth = -1) +function getPosts($threadId, $orderDirection = 'ASC', $recursive = false, $postId = null, $depth = -1) { $list = []; @@ -2498,7 +2502,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']) ? $values['post_notification'] : '', - 'post_parent_id' => 0, + 'post_parent_id' => null, 'visible' => $visible, ]; $last_post_id = Database::insert($table_posts, $params); @@ -3379,7 +3383,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'); } @@ -3481,7 +3485,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')); @@ -4264,12 +4268,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); @@ -4328,12 +4332,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/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; From 71b6ee6e611994b866e5d246a9458f2aae8fde4c Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 17:12:44 -0500 Subject: [PATCH 18/26] Set post_parent_id field in c_forum_post to null instead of 0 --- main/forum/forumfunction.inc.php | 60 +++++++++++++----------- main/webservices/cm_webservice_forum.php | 27 ++++++----- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 0bf88d1a49..b3bac490f4 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 = []; @@ -2526,7 +2530,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 +3419,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 +3535,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 +4325,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 +4389,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/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; From 761be6d5a6f43a4e3340a7d6383f06404b6a3270 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 18:12:02 -0500 Subject: [PATCH 19/26] Add Behat test for reply/delete/quote a forum message --- tests/features/forum.feature | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 From 01d6d530ac1488bdeb65c6b2c7217e9a172e304d Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 4 May 2016 18:12:02 -0500 Subject: [PATCH 20/26] Add Behat test for reply/delete/quote a forum message --- tests/features/forum.feature | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 From c593ba95a460159ef91f71116e5640368837e7e2 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 5 May 2016 10:48:08 +0200 Subject: [PATCH 21/26] Minor - format code. --- main/inc/lib/tracking.lib.php | 35 +++++++++---------- main/newscorm/learnpath.class.php | 57 +++++++++++++++++-------------- main/newscorm/lp_view.php | 2 +- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 2d90e6e368..25f5ee8ba7 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/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index f24c18da0a..309ae04f8b 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -1594,7 +1594,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 (); } @@ -1605,21 +1606,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(); } /** @@ -1958,7 +1962,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); } @@ -3296,6 +3300,7 @@ class learnpath $html .= ''; } } + return $html; } @@ -6274,18 +6279,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 @@ -6300,7 +6305,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); @@ -6315,7 +6320,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 @@ -6331,7 +6336,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); @@ -6339,23 +6344,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 8ee602c7c5..a6573e978d 100755 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -253,7 +253,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']; From b402c0f3f116ae35512aa8eeb6a3f422cfcc7fdb Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 5 May 2016 10:51:21 +0200 Subject: [PATCH 22/26] Fix auth/inscription.php url see #8221 --- custompages/index-unlogged-dist.php | 4 ++-- main/create_course/add_course.php | 3 +-- main/template/default/layout/login_form.tpl | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) 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/main/create_course/add_course.php b/main/create_course/add_course.php index 55616ca8cf..ff01a79f72 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/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 %} From f2edc8b3b678b6210a2324a15b093d0bc2d006ae Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Mon, 2 May 2016 15:15:56 -0500 Subject: [PATCH 23/26] fix slider tpl in layout BT#10657 --- main/inc/lib/system_announcements.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index a887073693..2df6e799b7 100755 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -804,8 +804,9 @@ class SystemAnnouncementManager $template = new Template(null, false, false); $template->assign('announcements', $announcements); + $layout = $template->get_template('announcement/slider.tpl'); - return $template->fetch('default/announcement/slider.tpl'); + return $template->fetch($layout); } /** @@ -854,7 +855,8 @@ class SystemAnnouncementManager $template = new Template(null, false, false); $template->assign('announcement', $announcement); + $layout = $template->get_template('announcement/view.tpl'); - return $template->fetch('default/announcement/view.tpl'); + return $template->fetch($layout); } } From f6a1be2a3e7f8fd91b48b2661d31951734d82acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 5 May 2016 11:09:58 -0500 Subject: [PATCH 24/26] Add minor code validations and corrections in new course grid template --- main/inc/lib/course.lib.php | 13 ++++++------- main/inc/lib/userportal.lib.php | 12 +++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 15d1b06172..f154446da9 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -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/userportal.lib.php b/main/inc/lib/userportal.lib.php index b1ea82d2b0..253d8003f0 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1050,7 +1050,7 @@ class IndexManager $user_id, $this->load_directories_preview ); - + // Display courses. $courses = CourseManager::returnCourses( $user_id, @@ -1058,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')); } else { $listCourse = $this->tpl->fetch( $this->tpl->get_template('/user_portal/classic_courses.tpl')); - } - $courseCount = $specialCourses['course_count'] + $courses['course_count']; + } + if (!empty($specialCourses['course_count']) && !empty($courses['course_count'])) { + $courseCount = intval($specialCourses['course_count']) + intval($courses['course_count']); + } } $sessions_with_category = ''; @@ -1365,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 ]; From bc01f1703bae94611c9457175027b5251ecf9bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 5 May 2016 11:22:40 -0500 Subject: [PATCH 25/26] Update the max size of crop for course image (from 300 to 400) --- main/inc/lib/course.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index f154446da9..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; From cfdd3015efac4ca5344f41a8d1c10984b27b1c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 5 May 2016 12:27:29 -0500 Subject: [PATCH 26/26] Fix returnThumbnail function to return the correct course category --- main/template/default/auth/courses_categories.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 .= '
    '; }