Minor - 1.11.x fixes

pull/2837/head
Julio Montoya 6 years ago
parent f729b4b81b
commit 6e07810c64
  1. 1
      main/inc/ajax/agenda.ajax.php
  2. 20
      main/inc/ajax/course_home.ajax.php
  3. 6
      main/inc/ajax/exercise.ajax.php
  4. 11
      main/inc/ajax/model.ajax.php
  5. 30
      main/inc/ajax/sequence.ajax.php
  6. 28
      main/inc/ajax/user_manager.ajax.php
  7. 3
      main/inc/ajax/work.ajax.php
  8. 64
      main/inc/lib/TicketManager.php
  9. 44
      main/lp/learnpath.class.php
  10. 1
      src/CoreBundle/Component/Editor/Driver/CourseDriver.php

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.
*/ */

@ -139,17 +139,17 @@ switch ($action) {
require_once __DIR__.'/../global.inc.php'; require_once __DIR__.'/../global.inc.php';
// Get the name of the database course. // Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']); $course_info = api_get_course_info($_GET['code']);
$content = get_lang('NoDescription');
if (!empty($course_info)) {
if (api_get_setting('course_catalog_hide_private') === 'true' && if (api_get_setting('course_catalog_hide_private') === 'true' &&
$course_info['visibility'] == COURSE_VISIBILITY_REGISTERED $course_info['visibility'] == COURSE_VISIBILITY_REGISTERED
) { ) {
echo get_lang('PrivateAccess'); echo get_lang('PrivateAccess');
break; break;
} }
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$sql = "SELECT * FROM $tbl_course_description $sql = "SELECT * FROM $table
WHERE c_id = ".$course_info['real_id']." AND session_id = 0 WHERE c_id = ".$course_info['real_id']." AND session_id = 0
ORDER BY id"; ORDER BY id";
$result = Database::query($sql); $result = Database::query($sql);
@ -157,17 +157,15 @@ switch ($action) {
while ($description = Database::fetch_object($result)) { while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description; $descriptions[$description->id] = $description;
} }
$extraField = new ExtraField('course');
$fieldValues = $extraField->getDataAndFormattedValues($course_info['real_id']);
// Function that displays the details of the course description in html. $content = CourseManager::get_details_course_description_html(
echo CourseManager::get_details_course_description_html(
$descriptions, $descriptions,
$fieldValues api_get_system_encoding(),
false
); );
} else {
echo get_lang('NoDescription');
} }
}
echo $content;
break; break;
case 'session_courses_lp_default': case 'session_courses_lp_default':
/** /**

@ -730,7 +730,11 @@ switch ($action) {
$objExercise = new Exercise(); $objExercise = new Exercise();
$objExercise->read($exerciseId); $objExercise->read($exerciseId);
$objQuestion = Question::read($questionId); $objQuestion = Question::read($questionId);
$id = '';
if (api_get_configuration_value('show_question_id')) {
$id = '<h4>#'.$objQuestion->course['code'].'-'.$objQuestion->iid.'</h4>';
}
echo $id;
echo '<p class="lead">'.$objQuestion->get_question_type_name().'</p>'; echo '<p class="lead">'.$objQuestion->get_question_type_name().'</p>';
if ($objQuestion->type === FILL_IN_BLANKS) { if ($objQuestion->type === FILL_IN_BLANKS) {
echo '<script> echo '<script>

@ -842,7 +842,7 @@ switch ($action) {
'*', '*',
$object->table, $object->table,
[ [
'where' => ["session_id = ? " => $sessionId], 'where' => ['session_id = ? ' => $sessionId],
'order' => "$sidx $sord", 'order' => "$sidx $sord",
'LIMIT' => "$start , $limit", ] 'LIMIT' => "$start , $limit", ]
); );
@ -1425,6 +1425,9 @@ switch ($action) {
break; break;
case 'get_sessions_tracking': case 'get_sessions_tracking':
if (api_is_drh() || api_is_session_admin()) { if (api_is_drh() || api_is_session_admin()) {
$orderByName = Database::escape_string($sidx);
$orderByName = in_array($orderByName, ['name', 'access_start_date']) ? $orderByName : 'name';
$orderBy = " ORDER BY $orderByName $sord";
$sessions = SessionManager::get_sessions_followed_by_drh( $sessions = SessionManager::get_sessions_followed_by_drh(
api_get_user_id(), api_get_user_id(),
$start, $start,
@ -1432,7 +1435,7 @@ switch ($action) {
false, false,
false, false,
false, false,
null, $orderBy,
$keyword, $keyword,
$description $description
); );
@ -1444,7 +1447,9 @@ switch ($action) {
$limit, $limit,
false, false,
$keyword, $keyword,
$description $description,
$sidx,
$sord
); );
} }

@ -42,12 +42,24 @@ switch ($action) {
$graphviz = new GraphViz(); $graphviz = new GraphViz();
$graphImage = ''; $graphImage = '';
try { try {
$graphImage = $graphviz->createImageHtml($graph); $graphImage = $graphviz->createImageSrc($graph);
echo Display::img(
$graphImage,
get_lang('GraphDependencyTree'),
['class' => 'center-block'],
false
);
} catch (UnexpectedValueException $e) { } catch (UnexpectedValueException $e) {
error_log($e->getMessage().' - Graph could not be rendered in resources sequence because GraphViz command "dot" could not be executed - Make sure graphviz is installed.'); error_log(
$graphImage = '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog').'</small></p>'; $e->getMessage()
.' - Graph could not be rendered in resources sequence'
.' because GraphViz command "dot" could not be executed '
.'- Make sure graphviz is installed.'
);
echo '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog')
.'</small></p>';
} }
echo $graphImage;
} }
break; break;
} }
@ -94,7 +106,15 @@ switch ($action) {
$link .= '<div class="big-icon">'; $link .= '<div class="big-icon">';
$link .= $image; $link .= $image;
$link .= '<div class="sequence-course">'.$sessionInfo['name'].'</div>'; $link .= '<div class="sequence-course">'.$sessionInfo['name'].'</div>';
$link .= '<a href="#" class="sequence-id">'.$id.'</a>'; $link .= Display::tag(
'button',
$id,
[
'class' => 'sequence-id',
'title' => get_lang('UseAsReference'),
'type' => 'button',
]
);
$link .= $linkDelete; $link .= $linkDelete;
$link .= $linkUndo; $link .= $linkUndo;
$link .= '</div></div>'; $link .= '</div></div>';

@ -14,21 +14,23 @@ $action = $_GET['a'];
switch ($action) { switch ($action) {
case 'get_user_like': case 'get_user_like':
$query = $_REQUEST['q']; if (api_is_platform_admin() || api_is_drh()) {
$conditions = [ $query = $_REQUEST['q'];
'username' => $query, $conditions = [
'firstname' => $query, 'username' => $query,
'lastname' => $query, 'firstname' => $query,
]; 'lastname' => $query,
$users = UserManager::getUserListLike($conditions, [], false, 'OR'); ];
$result = []; $users = UserManager::getUserListLike($conditions, [], false, 'OR');
if (!empty($users)) { $result = [];
foreach ($users as $user) { if (!empty($users)) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')']; foreach ($users as $user) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
}
$result['items'] = $result;
} }
$result['items'] = $result; echo json_encode($result);
} }
echo json_encode($result);
break; break;
case 'get_user_popup': case 'get_user_popup':
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0; $courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;

@ -64,7 +64,8 @@ switch ($action) {
$json = []; $json = [];
if (!empty($result) && is_array($result) && empty($result['error'])) { if (!empty($result) && is_array($result) && empty($result['error'])) {
$json['name'] = Display::url( $json['name'] = api_htmlentities($result['title']);
$json['link'] = Display::url(
api_htmlentities($result['title']), api_htmlentities($result['title']),
api_htmlentities($result['view_url']), api_htmlentities($result['view_url']),
['target' => '_blank'] ['target' => '_blank']

@ -50,6 +50,7 @@ class TicketManager
$table_support_project = Database::get_main_table(TABLE_TICKET_PROJECT); $table_support_project = Database::get_main_table(TABLE_TICKET_PROJECT);
$order = empty($order) ? 'category.total_tickets DESC' : $order; $order = empty($order) ? 'category.total_tickets DESC' : $order;
$order = Database::escape_string($order);
$projectId = (int) $projectId; $projectId = (int) $projectId;
$sql = "SELECT $sql = "SELECT
@ -89,9 +90,9 @@ class TicketManager
if (!in_array($direction, ['ASC', 'DESC'])) { if (!in_array($direction, ['ASC', 'DESC'])) {
$direction = 'ASC'; $direction = 'ASC';
} }
$column = intval($column); $column = (int) $column;
$from = intval($from); $from = (int) $from;
$numberItems = intval($numberItems); $numberItems = (int) $numberItems;
//$sql .= " ORDER BY col$column $direction "; //$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$numberItems"; $sql .= " LIMIT $from,$numberItems";
@ -166,7 +167,7 @@ class TicketManager
*/ */
public static function deleteCategory($id) public static function deleteCategory($id)
{ {
$id = intval($id); $id = (int) $id;
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
@ -260,7 +261,7 @@ class TicketManager
public static function get_all_tickets_status() public static function get_all_tickets_status()
{ {
$table = Database::get_main_table(TABLE_TICKET_STATUS); $table = Database::get_main_table(TABLE_TICKET_STATUS);
$sql = "SELECT * FROM ".$table; $sql = "SELECT * FROM $table";
$result = Database::query($sql); $result = Database::query($sql);
$types = []; $types = [];
while ($row = Database::fetch_assoc($result)) { while ($row = Database::fetch_assoc($result)) {
@ -590,11 +591,11 @@ class TicketManager
return false; return false;
} }
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$ticket = self::get_ticket_detail_by_id($ticketId); $ticket = self::get_ticket_detail_by_id($ticketId);
if ($ticket) { if ($ticket) {
$sql = "UPDATE $table_support_tickets $table = Database::get_main_table(TABLE_TICKET_TICKET);
$sql = "UPDATE $table
SET assigned_last_user = $userId SET assigned_last_user = $userId
WHERE id = $ticketId"; WHERE id = $ticketId";
Database::query($sql); Database::query($sql);
@ -641,10 +642,13 @@ class TicketManager
$table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE); $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
if ($sendConfirmation) { if ($sendConfirmation) {
$form = '<form action="ticket_details.php?ticket_id='.$ticketId.'" id="confirmticket" method="POST" > $form =
'<form action="ticket_details.php?ticket_id='.$ticketId.'" id="confirmticket" method="POST" >
<p>'.get_lang('TicketWasThisAnswerSatisfying').'</p> <p>'.get_lang('TicketWasThisAnswerSatisfying').'</p>
<button class="btn btn-primary responseyes" name="response" id="responseyes" value="1">'.get_lang('Yes').'</button> <button class="btn btn-primary responseyes" name="response" id="responseyes" value="1">'.
<button class="btn btn-danger responseno" name="response" id="responseno" value="0">'.get_lang('No').'</button> get_lang('Yes').'</button>
<button class="btn btn-danger responseno" name="response" id="responseno" value="0">'.
get_lang('No').'</button>
</form>'; </form>';
$content .= $form; $content .= $form;
} }
@ -713,7 +717,7 @@ class TicketManager
) { ) {
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
$userId = api_get_user_id(); $userId = api_get_user_id();
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$new_file_name = add_ext_on_mime( $new_file_name = add_ext_on_mime(
stripslashes($file_attach['name']), stripslashes($file_attach['name']),
$file_attach['type'] $file_attach['type']
@ -986,7 +990,7 @@ class TicketManager
} }
if ($isAdmin) { if ($isAdmin) {
$ticket['0'] .= '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="load_history_ticket(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')"> $ticket['0'] .= '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="load_history_ticket(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')">
<img onclick="load_course_list(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.png').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/> <img onclick="load_course_list(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.gif').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/>
<div class="blackboard_hide" id="div_'.$row['ticket_id'].'">&nbsp;&nbsp;</div> <div class="blackboard_hide" id="div_'.$row['ticket_id'].'">&nbsp;&nbsp;</div>
</a>&nbsp;&nbsp;'; </a>&nbsp;&nbsp;';
} }
@ -1144,7 +1148,7 @@ class TicketManager
*/ */
public static function get_ticket_detail_by_id($ticketId) public static function get_ticket_detail_by_id($ticketId)
{ {
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$table_support_category = Database::get_main_table(TABLE_TICKET_CATEGORY); $table_support_category = Database::get_main_table(TABLE_TICKET_CATEGORY);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_priority = Database::get_main_table(TABLE_TICKET_PRIORITY); $table_support_priority = Database::get_main_table(TABLE_TICKET_PRIORITY);
@ -1232,7 +1236,8 @@ class TicketManager
$result_attach = Database::query($sql); $result_attach = Database::query($sql);
while ($row2 = Database::fetch_assoc($result_attach)) { while ($row2 = Database::fetch_assoc($result_attach)) {
$archiveURL = $webPath.'ticket/download.php?ticket_id='.$ticketId.'&id='.$row2['id']; $archiveURL = $webPath.'ticket/download.php?ticket_id='.$ticketId.'&id='.$row2['id'];
$row2['attachment_link'] = $attach_icon.'&nbsp;<a href="'.$archiveURL.'">'.$row2['filename'].'</a>&nbsp;('.$row2['size'].')'; $row2['attachment_link'] = $attach_icon.
'&nbsp;<a href="'.$archiveURL.'">'.$row2['filename'].'</a>&nbsp;('.$row2['size'].')';
$message['attachments'][] = $row2; $message['attachments'][] = $row2;
} }
$ticket['messages'][] = $message; $ticket['messages'][] = $message;
@ -1250,11 +1255,9 @@ class TicketManager
*/ */
public static function update_message_status($ticketId, $userId) public static function update_message_status($ticketId, $userId)
{ {
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$userId = intval($userId); $userId = (int) $userId;
$table_support_messages = Database::get_main_table( $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
TABLE_TICKET_MESSAGE
);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
$sql = "UPDATE $table_support_messages $sql = "UPDATE $table_support_messages
@ -1433,11 +1436,11 @@ class TicketManager
) { ) {
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$status_id = intval($status_id); $status_id = (int) $status_id;
$userId = intval($userId); $userId = (int) $userId;
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
$sql = "UPDATE $table_support_tickets $sql = "UPDATE $table_support_tickets
SET SET
status_id = '$status_id', status_id = '$status_id',
@ -1465,9 +1468,7 @@ class TicketManager
public static function getNumberOfMessages() public static function getNumberOfMessages()
{ {
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_messages = Database::get_main_table( $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
TABLE_TICKET_MESSAGE
);
$table_main_user = Database::get_main_table(TABLE_MAIN_USER); $table_main_user = Database::get_main_table(TABLE_MAIN_USER);
$table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$user_info = api_get_user_info(); $user_info = api_get_user_info();
@ -1520,8 +1521,8 @@ class TicketManager
*/ */
public static function close_ticket($ticketId, $userId) public static function close_ticket($ticketId, $userId)
{ {
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$userId = intval($userId); $userId = (int) $userId;
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$now = api_get_utc_datetime(); $now = api_get_utc_datetime();
@ -1570,7 +1571,7 @@ class TicketManager
public static function get_assign_log($ticketId) public static function get_assign_log($ticketId)
{ {
$table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG); $table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$ticketId = intval($ticketId); $ticketId = (int) $ticketId;
$sql = "SELECT * FROM $table $sql = "SELECT * FROM $table
WHERE ticket_id = $ticketId WHERE ticket_id = $ticketId
@ -1612,8 +1613,8 @@ class TicketManager
$direction, $direction,
$userId = null $userId = null
) { ) {
$from = intval($from); $from = (int) $from;
$number_of_items = intval($number_of_items); $number_of_items = (int) $number_of_items;
$table_support_category = Database::get_main_table( $table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY TABLE_TICKET_CATEGORY
); );
@ -2274,7 +2275,6 @@ class TicketManager
*/ */
public static function getSettingsMenuItems($exclude = null) public static function getSettingsMenuItems($exclude = null)
{ {
$items = [];
$project = [ $project = [
'icon' => 'project.png', 'icon' => 'project.png',
'url' => 'projects.php', 'url' => 'projects.php',

@ -6941,24 +6941,21 @@ class learnpath
$creatorId = empty($creatorId) ? api_get_user_id() : $creatorId; $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId;
$folder = false; $folder = false;
//if (!is_dir($filepath.'/'.$dir)) {
$folderData = create_unexisting_directory( $folderData = create_unexisting_directory(
$course, $course,
$creatorId, $creatorId,
0, 0,
null, null,
0, 0,
$filepath, $filepath,
$dir, $dir,
get_lang('LearningPaths'), get_lang('LearningPaths'),
0 0
); );
if (!empty($folderData)) { if (!empty($folderData)) {
$folder = true; $folder = true;
} }
/*} else {
$folder = true;
}*/
return $folder; return $folder;
} }
@ -6990,17 +6987,16 @@ class learnpath
$documentId = null; $documentId = null;
if ($folder) { if ($folder) {
$filepath = api_get_path(SYS_COURSE_PATH).$course['path'].'/document'; $filepath = api_get_path(SYS_COURSE_PATH).$course['path'].'/document';
//if (!is_dir($filepath.'/'.$dir)) {
$folderData = create_unexisting_directory( $folderData = create_unexisting_directory(
$course, $course,
$creatorId, $creatorId,
0, 0,
0, 0,
0, 0,
$filepath, $filepath,
$dir, $dir,
$lp_name $lp_name
); );
if (!empty($folderData)) { if (!empty($folderData)) {
$folder = true; $folder = true;
} }

@ -39,7 +39,6 @@ class CourseDriver extends Driver implements DriverInterface
if (!file_exists($baseDir.'/shared_folder')) { if (!file_exists($baseDir.'/shared_folder')) {
$title = get_lang('UserFolders'); $title = get_lang('UserFolders');
$folderName = '/shared_folder'; $folderName = '/shared_folder';
$visibility = 0; $visibility = 0;
create_unexisting_directory( create_unexisting_directory(
$courseInfo, $courseInfo,

Loading…
Cancel
Save