diff --git a/main/auth/cas/authcas.php b/main/auth/cas/authcas.php
index 673c228baa..27e22c1b50 100755
--- a/main/auth/cas/authcas.php
+++ b/main/auth/cas/authcas.php
@@ -88,7 +88,7 @@ function cas_is_authenticated()
// if option is on we update user automatically from ldap server
if (api_get_setting("update_user_info_cas_with_ldap") == "true") {
$ldapuser = extldap_authenticate($login, 'nopass', true);
- if ($ldap_user !== false) {
+ if ($ldapuser !== false) {
$chamilo_user = extldap_get_chamilo_user($ldapuser);
$chamilo_user['user_id'] = $tab_user_info['user_id'];
$chamilo_user['status'] = $tab_user_info['status'];
@@ -114,7 +114,7 @@ function cas_is_authenticated()
// user has already been authenticated by CAS
// If user not found in LDAP, user not created
$ldapuser = extldap_authenticate($login, 'nopass', true);
- if ($ldap_user !== false) {
+ if ($ldapuser !== false) {
$chamilo_user = extldap_get_chamilo_user($ldapuser);
$chamilo_user['username'] = $login;
$chamilo_user['auth_source'] = CAS_AUTH_SOURCE;
diff --git a/main/coursecopy/import_backup.php b/main/coursecopy/import_backup.php
index b4c0c968eb..7475770c05 100755
--- a/main/coursecopy/import_backup.php
+++ b/main/coursecopy/import_backup.php
@@ -62,6 +62,10 @@ if (Security::check_token('post') && (
$error = false;
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
// Partial backup here we recover the documents posted
+ // This gets $_POST['course']. Beware that when using Suhosin,
+ // the post.max_value_length limit might get in the way of the
+ // restoration of a course with many items. A value of 1,000,000 bytes
+ // might be too short.
$course = CourseSelectForm::get_posted_course();
} else {
@@ -89,7 +93,7 @@ if (Security::check_token('post') && (
}
}
- if (!$error && $course->has_resources()) {
+ if (!$error && is_object($course) && $course->has_resources()) {
$cr = new CourseRestorer($course);
$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore();
diff --git a/main/exercice/quiz_template.xls b/main/exercice/quiz_template.xls
index 6ea839da8a..967b619c14 100755
Binary files a/main/exercice/quiz_template.xls and b/main/exercice/quiz_template.xls differ
diff --git a/main/exercice/upload_exercise.php b/main/exercice/upload_exercise.php
index 0377351586..6b2eafd9df 100755
--- a/main/exercice/upload_exercise.php
+++ b/main/exercice/upload_exercise.php
@@ -466,6 +466,8 @@ function lp_upload_quiz_action_handling() {
) {
$score = $score_list[$i][3] * -1;
}
+ } else {
+ $score = $score_list[$i][3] * -1;
}
$score /= $numberRightAnswers;
break;
diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php
index fe958914af..c61658ca5a 100755
--- a/main/forum/forumfunction.inc.php
+++ b/main/forum/forumfunction.inc.php
@@ -1450,21 +1450,18 @@ function get_forums(
) {
$course_info = api_get_course_info($course_code);
- $table_users = Database :: get_main_table(TABLE_MAIN_USER);
$table_forums = Database :: get_course_table(TABLE_FORUM);
$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database :: get_course_table(TABLE_FORUM_POST);
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
- // GETTING ALL THE FORUMS
-
// Condition for the session
if (empty($sessionId)) {
$session_id = api_get_session_id();
} else {
$session_id = $sessionId;
}
-
+
$sessionIdLink = ($session_id === 0) ? '' : 'AND threads.session_id = item_properties.session_id';
$condition_session = api_get_session_condition(
@@ -1505,7 +1502,7 @@ function get_forums(
INNER JOIN ".$table_item_property." item_properties
ON (
threads.thread_id=item_properties.ref AND
- threads.c_id = item_properties.c_id
+ threads.c_id = item_properties.c_id
$sessionIdLink
)
WHERE
@@ -1515,20 +1512,6 @@ function get_forums(
item_properties.c_id = $course_id
GROUP BY threads.forum_id";
- // Select the number of posts of the forum (post that are visible and that are in a thread that is visible).
- $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id
- FROM $table_posts posts, $table_threads threads, ".$table_item_property." item_properties
- WHERE
- posts.visible=1 AND
- posts.thread_id=threads.thread_id AND
- threads.thread_id=item_properties.ref AND
- threads.session_id = item_properties.session_id AND
- item_properties.visibility=1 AND
- item_properties.tool='".TOOL_FORUM_THREAD."' AND
- threads.c_id = $course_id AND
- posts.c_id = $course_id AND
- item_properties.c_id = $course_id
- GROUP BY threads.forum_id";
// Course Admin
if (api_is_allowed_to_edit()) {
@@ -1554,7 +1537,7 @@ function get_forums(
INNER JOIN ".$table_item_property." item_properties
ON (
threads.thread_id=item_properties.ref AND
- threads.c_id = item_properties.c_id
+ threads.c_id = item_properties.c_id
$sessionIdLink
)
WHERE
@@ -1563,19 +1546,6 @@ function get_forums(
threads.c_id = $course_id AND
item_properties.c_id = $course_id
GROUP BY threads.forum_id";
- // Select the number of posts of the forum.
- $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id
- FROM $table_posts posts, $table_threads threads, ".$table_item_property." item_properties
- WHERE
- posts.thread_id=threads.thread_id AND
- threads.thread_id=item_properties.ref AND
- threads.session_id = item_properties.session_id AND
- item_properties.visibility=1 AND
- item_properties.tool='".TOOL_FORUM_THREAD."' AND
- posts.c_id = $course_id AND
- threads.c_id = $course_id AND
- item_properties.c_id = $course_id
- GROUP BY threads.forum_id";
}
} else {
// GETTING ONE SPECIFIC FORUM
@@ -1605,31 +1575,6 @@ function get_forums(
forum_id = ".intval($id)." AND
c_id = $course_id
GROUP BY forum_id";
-
- // Select the number of posts of the forum.
- $sql3 = "SELECT count(*) AS number_of_posts, forum_id
- FROM $table_posts
- WHERE
- forum_id = ".intval($id)." AND
- c_id = $course_id
- GROUP BY forum_id";
-
- // Select the last post and the poster (note: this is probably no longer needed).
- $sql4 = "SELECT
- post.post_id,
- post.forum_id,
- post.poster_id,
- post.poster_name,
- post.post_date,
- users.lastname,
- users.firstname
- FROM $table_posts post, $table_users users
- WHERE
- forum_id = ".intval($id)." AND
- post.poster_id=users.user_id AND
- post.c_id = $course_id
- GROUP BY post.forum_id
- ORDER BY post.post_id ASC";
}
// Handling all the forum information.
@@ -1653,25 +1598,16 @@ function get_forums(
}
}
- // Handling the postcount information.
- $result3 = Database::query($sql3);
- while ($row3 = Database::fetch_array($result3)) {
- if ($id == '') {
- // This is needed because sql3 takes also the deleted forums into account.
- if (array_key_exists($row3['forum_id'], $forum_list)) {
- $forum_list[$row3['forum_id']]['number_of_posts'] = $row3['number_of_posts'];
- }
- } else {
- $forum_list['number_of_posts'] = $row3['number_of_posts'];
- }
- }
-
/* Finding the last post information
(last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
if ($id == '') {
if (is_array($forum_list)) {
foreach ($forum_list as $key => $value) {
- $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit(), $course_id);
+ $last_post_info_of_forum = get_last_post_information(
+ $key,
+ api_is_allowed_to_edit(),
+ $course_id
+ );
$forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
$forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
$forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -1683,7 +1619,11 @@ function get_forums(
$forum_list = array();
}
} else {
- $last_post_info_of_forum = get_last_post_information($id, api_is_allowed_to_edit(), $course_id);
+ $last_post_info_of_forum = get_last_post_information(
+ $id,
+ api_is_allowed_to_edit(),
+ $course_id
+ );
$forum_list['last_post_id'] = $last_post_info_of_forum['last_post_id'];
$forum_list['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
$forum_list['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -2767,7 +2707,8 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
empty($values['weight_calification'])
) {
Display::display_error_message(
- get_lang('YouMustAssignWeightOfQualification').' '.get_lang('Back').'',
+ get_lang('YouMustAssignWeightOfQualification').' '.
+ get_lang('Back').'',
false
);
@@ -3111,10 +3052,11 @@ function store_reply($current_forum, $values)
'visible' => $visible,
]
);
- if ($new_post_id) {
+ if ($new_post_id) {
$sql = "UPDATE $table_posts SET post_id = iid WHERE iid = $new_post_id";
Database::query($sql);
+
$values['new_post_id'] = $new_post_id;
$message = get_lang('ReplyAdded');
@@ -3142,12 +3084,19 @@ function store_reply($current_forum, $values)
api_get_user_id()
);
+ // Insert post
+ api_item_property_update(
+ $_course,
+ TOOL_FORUM_POST,
+ $new_post_id,
+ 'NewPost',
+ api_get_user_id()
+ );
+
if ($current_forum['approval_direct_post'] == '1' &&
!api_is_allowed_to_edit(null, true)
) {
- $message .= '
'.get_lang(
- 'MessageHasToBeApproved'
- ).'
';
+ $message .= '
'.get_lang('MessageHasToBeApproved').'
';
}
// Setting the notification correctly.
@@ -3157,7 +3106,6 @@ function store_reply($current_forum, $values)
}
send_notification_mails($values['thread_id'], $values);
-
add_forum_attachment_file('', $new_post_id);
}
@@ -3732,7 +3680,10 @@ function get_post_topics_of_forum($forum_id)
$number_of_topics = 0; // Due to the nature of the group by this can result in an empty string.
}
- $return = array('number_of_topics' => $number_of_topics, 'number_of_posts' => $number_of_posts);
+ $return = array(
+ 'number_of_topics' => $number_of_topics,
+ 'number_of_posts' => $number_of_posts,
+ );
return $return;
}
@@ -4354,6 +4305,7 @@ function display_forum_search_results($search_term)
$forum_list = get_forums();
$result = Database::query($sql);
+ $search_results = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$display_result = false;
/*
diff --git a/main/forum/index.php b/main/forum/index.php
index cae84da8ce..3594a60c0b 100755
--- a/main/forum/index.php
+++ b/main/forum/index.php
@@ -490,7 +490,7 @@ if (is_array($forumCategories)) {
$html .= '
'.$number_posts.' ' . get_lang('Posts') . '
' + $html .= ''.$number_threads.' ' . get_lang('ForumThreads') . '
' . '' . $my_number_posts . ' ' . get_lang('Posts') . '
' . $my_number_threads . ' ' . get_lang('ForumThreads') . '