Fixes after merge with 1.11.x

pull/3063/head
Julio Montoya 7 years ago
parent eb84c04402
commit f8024eca25
  1. 54
      main/inc/lib/exercise.lib.php
  2. 64
      main/inc/lib/message.lib.php
  3. 12
      main/social/view_promoted_message.php

@ -2889,7 +2889,7 @@ HOTSPOT;
// But also keep the round values settings.
$format = api_get_configuration_value('exercise_score_format');
if (!empty($format)) {
$html = ScoreDisplay::instance()->display_score([ $score, $weight], $format);
$html = ScoreDisplay::instance()->display_score([$score, $weight], $format);
}
$html = Display::span($html, ['class' => 'score_exercise']);
@ -3191,17 +3191,16 @@ EOT;
}
$now = api_get_utc_datetime();
$time_conditions = '';
$timeConditions = '';
if ($check_publication_dates) {
//start and end are set
$time_conditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' ) OR ";
// Start and end are set
$timeConditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' ) OR ";
// only start is set
$time_conditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
$timeConditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
// only end is set
$time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
$timeConditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
// nothing is set
$time_conditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
$timeConditions .= ' (start_time IS NULL AND end_time IS NULL)) ';
}
$needle_where = !empty($search) ? " AND title LIKE '?' " : '';
@ -3220,7 +3219,7 @@ EOT;
if ($search_all_sessions == true) {
$conditions = [
'where' => [
$active_sql.' c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' c_id = ? '.$needle_where.$timeConditions => [
$course_id,
$needle,
],
@ -3231,7 +3230,7 @@ EOT;
if (empty($session_id)) {
$conditions = [
'where' => [
$active_sql.' (session_id = 0 OR session_id IS NULL) AND c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' (session_id = 0 OR session_id IS NULL) AND c_id = ? '.$needle_where.$timeConditions => [
$course_id,
$needle,
],
@ -3241,7 +3240,7 @@ EOT;
} else {
$conditions = [
'where' => [
$active_sql.' (session_id = 0 OR session_id IS NULL OR session_id = ? ) AND c_id = ? '.$needle_where.$time_conditions => [
$active_sql.' (session_id = 0 OR session_id IS NULL OR session_id = ? ) AND c_id = ? '.$needle_where.$timeConditions => [
$session_id,
$course_id,
$needle,
@ -3257,32 +3256,6 @@ EOT;
return Database::select('*', $table, $conditions);
}
/**
* Get exercise information by id.
*
* @param int $exerciseId Exercise Id
* @param int $courseId The course ID (necessary as c_quiz.id is not unique)
*
* @return array Exercise info
*/
public static function get_exercise_by_id($exerciseId = 0, $courseId = 0)
{
$table = Database::get_course_table(TABLE_QUIZ_TEST);
if (empty($courseId)) {
$courseId = api_get_course_int_id();
} else {
$courseId = intval($courseId);
}
$conditions = [
'where' => [
'id = ?' => [$exerciseId],
' AND c_id = ? ' => $courseId,
],
];
return Database::select('*', $table, $conditions);
}
/**
* Getting all exercises (active only or all)
* from a course from a session
@ -3797,10 +3770,10 @@ EOT;
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$question_id = intval($question_id);
$exercise_id = intval($exercise_id);
$question_id = (int) $question_id;
$exercise_id = (int) $exercise_id;
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$session_id = (int) $session_id;
$courseId = api_get_course_int_id($course_code);
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
@ -3988,7 +3961,6 @@ EOT;
$track_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$question_id = (int) $question_id;

@ -63,7 +63,7 @@ class MessageManager
$messageStatusCondition = implode("','", $messageStatus);
$table = Database::get_main_table(TABLE_MESSAGE);
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
$keyword = isset($params['keyword']) && !empty($params['keyword']) ? $params['keyword'] : '';
$keywordCondition = '';
if (!empty($keyword)) {
@ -125,8 +125,11 @@ class MessageManager
$column = 2;
}
$keyword = isset($extraParams['keyword']) ? $extraParams['keyword'] : '';
$viewUrl = isset($extraParams['view_url']) ? $extraParams['view_url'] : api_get_path(WEB_CODE_PATH).'message/view_message.php';
$keyword = isset($extraParams['keyword']) && !empty($extraParams['keyword']) ? $extraParams['keyword'] : '';
$viewUrl = api_get_path(WEB_CODE_PATH).'messages/view_message.php';
if (isset($extraParams['view_url']) && !empty($extraParams['view_url'])) {
$viewUrl = $extraParams['view_url'];
}
$keywordCondition = '';
if (!empty($keyword)) {
@ -1190,7 +1193,7 @@ class MessageManager
}
$table = Database::get_main_table(TABLE_MESSAGE);
$request = api_is_xml_http_request();
$keyword = isset($extraParams['keyword']) ? $extraParams['keyword'] : '';
$keyword = isset($extraParams['keyword']) && !empty($extraParams['keyword']) ? $extraParams['keyword'] : '';
$keywordCondition = '';
if (!empty($keyword)) {
$keyword = Database::escape_string($keyword);
@ -1270,38 +1273,43 @@ class MessageManager
*
* @return string html with the message content
*/
public static function showMessageBox($messageId, $source = 'inbox')
public static function showMessageBox($messageId, $source)
{
$table = Database::get_main_table(TABLE_MESSAGE);
$messageId = (int) $messageId;
if (empty($messageId)) {
return '';
}
$currentUserId = api_get_user_id();
if ($source === 'outbox') {
if (isset($messageId) && is_numeric($messageId)) {
$query = "SELECT * FROM $table
WHERE
user_sender_id = ".$currentUserId." AND
id = $messageId AND
msg_status = ".MESSAGE_STATUS_OUTBOX;
$result = Database::query($query);
}
} else {
if (is_numeric($messageId) && !empty($messageId)) {
switch ($source) {
case 'outbox':
$status = MESSAGE_STATUS_OUTBOX;
$userCondition = " user_sender_id = $currentUserId AND ";
break;
case 'inbox':
$status = MESSAGE_STATUS_NEW;
$userCondition = " user_receiver_id = $currentUserId AND ";
$query = "UPDATE $table SET
msg_status = '".MESSAGE_STATUS_NEW."'
WHERE
user_receiver_id=".$currentUserId." AND
id = '".$messageId."'";
WHERE id = $messageId ";
Database::query($query);
$query = "SELECT * FROM $table
WHERE
msg_status<> ".MESSAGE_STATUS_OUTBOX." AND
user_receiver_id = ".$currentUserId." AND
id = '".$messageId."'";
$result = Database::query($query);
}
}
break;
case 'promoted_messages':
$status = MESSAGE_STATUS_PROMOTED;
$userCondition = " user_receiver_id = $currentUserId AND ";
break;
}
$query = "SELECT * FROM $table
WHERE
id = $messageId AND
$userCondition
msg_status = $status";
$result = Database::query($query);
$row = Database::fetch_array($result, 'ASSOC');
if (empty($row)) {

@ -17,17 +17,6 @@ $interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/social/home.php', 'n
$interbreadcrumb[] = ['url' => 'promoted_messages.php', 'name' => get_lang('PromotedMessages')];
$social_right_content = '';
/*$social_right_content = '<div class="actions">';
if (api_get_setting('allow_message_tool') === 'true') {
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
$social_right_content .= '</div>';*/
if (empty($_GET['id'])) {
$messageId = $_GET['id_send'];
$source = 'outbox';
@ -46,7 +35,6 @@ $logInfo = [
'action_details' => 'view-message',
];
Event::registerLog($logInfo);
$social_menu_block = SocialManager::show_social_menu($show_menu);
$message .= MessageManager::showMessageBox($messageId, 'promoted_messages');

Loading…
Cancel
Save