Internal: Fix queries, fix legacy code.

pull/3466/head
Julio Montoya 5 years ago
parent d7e8927039
commit 1a81860219
  1. 91
      public/main/forum/forumfunction.inc.php
  2. 20
      public/main/forum/iframe_thread.php
  3. 3
      public/main/forum/reply.php
  4. 5
      public/main/gradebook/lib/be/category.class.php
  5. 4
      public/main/inc/lib/groupmanager.lib.php
  6. 19
      public/main/lp/aicc.class.php
  7. 4
      public/main/lp/lp_subscribe_users.php

@ -960,8 +960,6 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$forumId = $forum->getIid(); $forumId = $forum->getIid();
if ($forumId > 0) { if ($forumId > 0) {
$sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $forumId";
Database::query($sql);
$courseCode = $courseInfo['code']; $courseCode = $courseInfo['code'];
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications'); $subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications');
@ -1045,7 +1043,7 @@ function delete_post($post_id)
/** @var CForumPost $post */ /** @var CForumPost $post */
$post = $em $post = $em
->getRepository('ChamiloCourseBundle:CForumPost') ->getRepository('ChamiloCourseBundle:CForumPost')
->findOneBy(['cId' => $course_id, 'postId' => $post_id]); ->findOneBy(['cId' => $course_id, 'iid' => $post_id]);
if ($post) { if ($post) {
$em $em
@ -1061,7 +1059,7 @@ function delete_post($post_id)
->execute([ ->execute([
'parent_of_deleted_post' => $post->getPostParentId(), 'parent_of_deleted_post' => $post->getPostParentId(),
'course' => $course_id, 'course' => $course_id,
'post' => $post->getPostId(), 'post' => $post->getIid(),
'thread_of_deleted_post' => $post->getThread() ? $post->getThread()->getIid() : 0, 'thread_of_deleted_post' => $post->getThread() ? $post->getThread()->getIid() : 0,
'forum_of_deleted_post' => $post->getForum(), 'forum_of_deleted_post' => $post->getForum(),
]); ]);
@ -1084,9 +1082,9 @@ function delete_post($post_id)
$sql = "UPDATE $table_threads $sql = "UPDATE $table_threads
SET SET
thread_replies = thread_replies - 1, thread_replies = thread_replies - 1,
thread_last_post = ".(int) ($last_post_of_thread['post_id']).", thread_last_post = ".(int) ($last_post_of_thread['iid']).",
thread_date='".Database::escape_string($last_post_of_thread['post_date'])."' thread_date='".Database::escape_string($last_post_of_thread['post_date'])."'
WHERE c_id = $course_id AND thread_id = ".(int) ($_GET['thread']); WHERE c_id = $course_id AND iid = ".(int) ($_GET['thread']);
Database::query($sql); Database::query($sql);
return 'PostDeleted'; return 'PostDeleted';
@ -1094,7 +1092,7 @@ function delete_post($post_id)
if (!$last_post_of_thread) { if (!$last_post_of_thread) {
// We deleted the very single post of the thread so we need to delete the entry in the thread table also. // We deleted the very single post of the thread so we need to delete the entry in the thread table also.
$sql = "DELETE FROM $table_threads $sql = "DELETE FROM $table_threads
WHERE c_id = $course_id AND thread_id = ".(int) ($_GET['thread']); WHERE c_id = $course_id AND iid = ".(int) ($_GET['thread']);
Database::query($sql); Database::query($sql);
return 'PostDeletedSpecial'; return 'PostDeletedSpecial';
@ -1124,9 +1122,9 @@ function check_if_last_post_of_thread($thread_id)
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) > 0) { if (Database::num_rows($result) > 0) {
return Database::fetch_array($result); return Database::fetch_array($result);
} else {
return false;
} }
return false;
} }
/** /**
@ -1675,7 +1673,7 @@ function get_last_post_by_thread($course_id, $thread_id, $forum_id, $show_visibl
$sql .= ' AND visible = 1 '; $sql .= ' AND visible = 1 ';
} }
$sql .= ' ORDER BY post_id DESC LIMIT 1'; $sql .= ' ORDER BY iid DESC LIMIT 1';
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
return Database::fetch_array($result, 'ASSOC'); return Database::fetch_array($result, 'ASSOC');
@ -1719,7 +1717,7 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
// First get the threads to make sure there is no inconsistency in the // First get the threads to make sure there is no inconsistency in the
// database between forum and thread // database between forum and thread
$sql = "SELECT thread_id FROM $table_threads $sql = "SELECT iid as thread_id FROM $table_threads
WHERE WHERE
forum_id = $forum_id AND forum_id = $forum_id AND
c_id = $course_id AND c_id = $course_id AND
@ -1736,7 +1734,7 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
$threadsList = implode(',', $threads); $threadsList = implode(',', $threads);
// Now get the posts that are linked to these threads // Now get the posts that are linked to these threads
$sql = "SELECT $sql = "SELECT
post.post_id, post.iid as post_id,
post.forum_id, post.forum_id,
post.poster_id, post.poster_id,
post.poster_name, post.poster_name,
@ -1754,11 +1752,10 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
$table_item_property thread_properties, $table_item_property thread_properties,
$table_item_property forum_properties $table_item_property forum_properties
WHERE WHERE
post.forum_id = $forum_id post.forum_id = $forum_id AND
AND post.thread_id IN ($threadsList) post.thread_id IN ($threadsList) AND
AND post.poster_id = users.user_id post.poster_id = users.id AND
AND post.thread_id = thread_properties.ref post.thread_id = thread_properties.ref AND thread_properties.tool='".TOOL_FORUM_THREAD."'
AND thread_properties.tool='".TOOL_FORUM_THREAD."'
AND post.forum_id=forum_properties.ref AND post.forum_id=forum_properties.ref
AND forum_properties.tool='".TOOL_FORUM."' AND forum_properties.tool='".TOOL_FORUM."'
AND post.c_id = $course_id AND AND post.c_id = $course_id AND
@ -1920,11 +1917,12 @@ function getThreadInfo($threadId, $cId)
{ {
$repo = Database::getManager()->getRepository('ChamiloCourseBundle:CForumThread'); $repo = Database::getManager()->getRepository('ChamiloCourseBundle:CForumThread');
/** @var CForumThread $forumThread */ /** @var CForumThread $forumThread */
$forumThread = $repo->findOneBy(['threadId' => $threadId, 'cId' => $cId]); $forumThread = $repo->findOneBy(['iid' => $threadId, 'cId' => $cId]);
$thread = []; $thread = [];
if ($forumThread) { if ($forumThread) {
$thread['threadId'] = $forumThread->getThreadId(); $thread['iid'] = $forumThread->getIid();
$thread['threadId'] = $forumThread->getIid();
$thread['threadTitle'] = $forumThread->getThreadTitle(); $thread['threadTitle'] = $forumThread->getThreadTitle();
$thread['forumId'] = $forumThread->getForum() ? $forumThread->getForum()->getIid() : 0; $thread['forumId'] = $forumThread->getForum() ? $forumThread->getForum()->getIid() : 0;
$thread['sessionId'] = $forumThread->getSessionId(); $thread['sessionId'] = $forumThread->getSessionId();
@ -1999,7 +1997,7 @@ function getPosts(
$qb = $em->getRepository('ChamiloCourseBundle:CForumPost')->createQueryBuilder('p'); $qb = $em->getRepository('ChamiloCourseBundle:CForumPost')->createQueryBuilder('p');
$qb->select('p') $qb->select('p')
->addCriteria($criteria) ->addCriteria($criteria)
->addOrderBy('p.postId', $orderDirection); ->addOrderBy('p.iid', $orderDirection);
if ($filterModerated && 1 == $forum->isModerated()) { if ($filterModerated && 1 == $forum->isModerated()) {
if (!api_is_allowed_to_edit(false, true)) { if (!api_is_allowed_to_edit(false, true)) {
@ -2023,7 +2021,7 @@ function getPosts(
$postInfo = [ $postInfo = [
'iid' => $post->getIid(), 'iid' => $post->getIid(),
'c_id' => $post->getCId(), 'c_id' => $post->getCId(),
'post_id' => $post->getPostId(), 'post_id' => $post->getIid(),
'post_title' => $post->getPostTitle(), 'post_title' => $post->getPostTitle(),
'post_text' => $post->getPostText(), 'post_text' => $post->getPostText(),
'thread_id' => $post->getThread() ? $post->getThread()->getIid() : 0, 'thread_id' => $post->getThread() ? $post->getThread()->getIid() : 0,
@ -2043,7 +2041,7 @@ function getPosts(
if (!empty($posterId)) { if (!empty($posterId)) {
$user = api_get_user_entity($posterId); $user = api_get_user_entity($posterId);
if ($user) { if ($user) {
$postInfo['user_id'] = $user->getUserId(); $postInfo['user_id'] = $user->getId();
$postInfo['username'] = $user->getUsername(); $postInfo['username'] = $user->getUsername();
$postInfo['username_canonical'] = $user->getUsernameCanonical(); $postInfo['username_canonical'] = $user->getUsernameCanonical();
$postInfo['lastname'] = $user->getLastname(); $postInfo['lastname'] = $user->getLastname();
@ -2064,7 +2062,7 @@ function getPosts(
$threadId, $threadId,
$orderDirection, $orderDirection,
$recursive, $recursive,
$post->getPostId(), $post->getIid(),
$depth $depth
) )
); );
@ -2368,7 +2366,7 @@ function updateThread($values)
'thread_title' => $values['thread_title'], 'thread_title' => $values['thread_title'],
'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : 0, 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : 0,
]; ];
$where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]]; $where = ['c_id = ? AND iid = ?' => [$courseId, $values['thread_id']]];
Database::update($threadTable, $params, $where); Database::update($threadTable, $params, $where);
$id = $values['thread_id']; $id = $values['thread_id'];
@ -2382,8 +2380,7 @@ function updateThread($values)
$gradebookLink = null; $gradebookLink = null;
$em = Database::getManager(); $em = Database::getManager();
if (!empty($linkInfo) && isset($linkInfo['id'])) { if (!empty($linkInfo) && isset($linkInfo['id'])) {
$linkId = $linkInfo['id']; $gradebookLink = $em->getRepository('ChamiloCoreBundle:GradebookLink')->find($linkInfo['id']);
$gradebookLink = $em->getRepository('ChamiloCoreBundle:GradebookLink')->find($linkId);
} }
// values 1 or 0 // values 1 or 0
@ -2430,7 +2427,7 @@ function updateThread($values)
'thread_weight' => 0, 'thread_weight' => 0,
'thread_peer_qualify' => 0, 'thread_peer_qualify' => 0,
]; ];
$where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]]; $where = ['c_id = ? AND iid = ?' => [$courseId, $values['thread_id']]];
Database::update($threadTable, $params, $where); Database::update($threadTable, $params, $where);
if (!empty($linkInfo)) { if (!empty($linkInfo)) {
@ -2540,10 +2537,6 @@ function store_thread(
); );
} }
$thread->setThreadId($thread->getIid());
$em->persist($thread);
$em->flush();
/*api_item_property_update( /*api_item_property_update(
$courseInfo, $courseInfo,
TOOL_FORUM_THREAD, TOOL_FORUM_THREAD,
@ -2641,19 +2634,13 @@ function store_thread(
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
if ($postId) {
$post->setPostId($postId);
$em->persist($post);
$em->flush();
}
// Now we have to update the thread table to fill the thread_last_post // Now we have to update the thread table to fill the thread_last_post
// field (so that we know when the thread has been updated for the last time). // field (so that we know when the thread has been updated for the last time).
$sql = "UPDATE $table_threads $sql = "UPDATE $table_threads
SET thread_last_post = '".$postId."' SET thread_last_post = '".$postId."'
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
thread_id='".$thread->getIid()."'"; iid = '".$thread->getIid()."'";
Database::query($sql); Database::query($sql);
$message = get_lang('The new thread has been added'); $message = get_lang('The new thread has been added');
@ -3300,11 +3287,6 @@ function saveThreadScore(
VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')"; VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
Database::query($sql); Database::query($sql);
$insertId = Database::insert_id(); $insertId = Database::insert_id();
if ($insertId) {
$sql = "UPDATE $table_threads_qualify SET id = iid
WHERE iid = $insertId";
Database::query($sql);
}
return 'insert'; return 'insert';
} else { } else {
@ -3485,13 +3467,6 @@ function saveThreadScoreHistory(
$sql = "INSERT INTO $table_threads_qualify_log (c_id, user_id, thread_id, qualify, qualify_user_id,qualify_time,session_id) $sql = "INSERT INTO $table_threads_qualify_log (c_id, user_id, thread_id, qualify, qualify_user_id,qualify_time,session_id)
VALUES(".$course_id.", '".$user_id."','".$thread_id."',".(float) $row[0].", '".$qualify_user_id."','".$row[1]."','')"; VALUES(".$course_id.", '".$user_id."','".$thread_id."',".(float) $row[0].", '".$qualify_user_id."','".$row[1]."','')";
Database::query($sql); Database::query($sql);
$insertId = Database::insert_id();
if ($insertId) {
$sql = "UPDATE $table_threads_qualify_log SET id = iid
WHERE iid = $insertId";
Database::query($sql);
}
} }
} }
@ -4033,7 +4008,7 @@ function increase_thread_view($thread_id)
SET thread_views = thread_views + 1 SET thread_views = thread_views + 1
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
thread_id = '".(int) $thread_id."'"; iid = '".(int) $thread_id."'";
Database::query($sql); Database::query($sql);
} }
@ -4058,7 +4033,7 @@ function updateThreadInfo($threadId, $lastPostId, $post_date)
thread_date = '".Database::escape_string($post_date)."' thread_date = '".Database::escape_string($post_date)."'
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
thread_id='".Database::escape_string($threadId)."'"; // this needs to be cleaned first iid ='".Database::escape_string($threadId)."'"; // this needs to be cleaned first
Database::query($sql); Database::query($sql);
} }
@ -4110,7 +4085,7 @@ function get_whats_new()
post_date > '".Database::escape_string($lastForumAccess)."'"; post_date > '".Database::escape_string($lastForumAccess)."'";
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$postInfo[$row['forum_id']][$row['thread_id']][$row['post_id']] = $row['post_date']; $postInfo[$row['forum_id']][$row['thread_id']][$row['iid']] = $row['post_date'];
} }
Session::write('whatsnew_post_info', $postInfo); Session::write('whatsnew_post_info', $postInfo);
} }
@ -4587,11 +4562,11 @@ function store_move_post($values)
// Resetting the last post of the old thread and decreasing the number of replies and the thread. // Resetting the last post of the old thread and decreasing the number of replies and the thread.
$sql = "SELECT * FROM $table_posts $sql = "SELECT * FROM $table_posts
WHERE c_id = $course_id AND thread_id='".$threadId."' WHERE c_id = $course_id AND thread_id='".$threadId."'
ORDER BY post_id DESC"; ORDER BY iid DESC";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
$sql = "UPDATE $table_threads SET $sql = "UPDATE $table_threads SET
thread_last_post='".$row['post_id']."', thread_last_post='".$row['iid']."',
thread_replies=thread_replies-1 thread_replies=thread_replies-1
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
@ -5523,7 +5498,7 @@ function get_notifications($content, $id)
$id = (int) $id; $id = (int) $id;
$sql = "SELECT user.id as user_id, user.firstname, user.lastname, user.email, user.user_id user $sql = "SELECT user.id as user_id, user.firstname, user.lastname, user.email, user.id user
FROM $table_users user, $table_notification notification FROM $table_users user, $table_notification notification
WHERE WHERE
notification.c_id = $course_id AND user.active = 1 AND notification.c_id = $course_id AND user.active = 1 AND
@ -6288,12 +6263,12 @@ function getAttachmentIdsByPostId($postId, $courseId = 0)
} }
if ($courseId > 0) { if ($courseId > 0) {
$forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT); $forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$sql = "SELECT id FROM $forumAttachmentTable $sql = "SELECT iid FROM $forumAttachmentTable
WHERE c_id = $courseId AND post_id = $postId"; WHERE c_id = $courseId AND post_id = $postId";
$result = Database::query($sql); $result = Database::query($sql);
if (false !== $result && Database::num_rows($result) > 0) { if (false !== $result && Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
$array[] = $row['id']; $array[] = $row['iid'];
} }
} }
} }

@ -56,7 +56,9 @@ $sessionEntity = api_get_session_entity(api_get_session_id());
// if the user is not a course administrator and the forum is hidden // if the user is not a course administrator and the forum is hidden
// then the user is not allowed here. // then the user is not allowed here.
if (!api_is_allowed_to_edit(false, true) && if (!api_is_allowed_to_edit(false, true) &&
(false == $forumEntity->isVisible($courseEntity, $sessionEntity) || false == $threadEntity->isVisible($courseEntity, $sessionEntity)) ( false == $forumEntity->isVisible($courseEntity, $sessionEntity) ||
false == $threadEntity->isVisible($courseEntity, $sessionEntity)
)
) { ) {
api_not_allowed(false); api_not_allowed(false);
} }
@ -66,18 +68,14 @@ $course_id = api_get_course_int_id();
$table_posts = Database::get_course_table(TABLE_FORUM_POST); $table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_users = Database::get_main_table(TABLE_MAIN_USER); $table_users = Database::get_main_table(TABLE_MAIN_USER);
/* Display Forum Category and the Forum information */ $sql = "SELECT username, firstname, lastname, u.id, post_date, post_title, post_text
FROM $table_posts posts
// We are getting all the information about the current forum and forum category. INNER JOIN $table_users u
// Note pcool: I tried to use only one sql statement (and function) for this, ON (posts.poster_id = u.id)
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$sql = "SELECT * FROM $table_posts posts
INNER JOIN $table_users users
ON (posts.poster_id = users.user_id)
WHERE WHERE
posts.c_id = $course_id AND posts.c_id = $course_id AND
posts.thread_id='".$threadEntity->getIid()."' posts.thread_id='".$threadEntity->getIid()."'
ORDER BY posts.post_id ASC"; ORDER BY posts.iid ASC";
$result = Database::query($sql); $result = Database::query($sql);
$template = new Template('', false, false); $template = new Template('', false, false);
@ -87,7 +85,7 @@ while ($row = Database::fetch_array($result)) {
$content .= '<tr>'; $content .= '<tr>';
$content .= '<td rowspan="2" class="forum_message_left">'; $content .= '<td rowspan="2" class="forum_message_left">';
$username = api_htmlentities(sprintf(get_lang('Login: %s'), $row['username']), ENT_QUOTES); $username = api_htmlentities(sprintf(get_lang('Login: %s'), $row['username']), ENT_QUOTES);
if ('0' == $row['user_id']) { if ('0' == $row['id']) {
$name = $row['poster_name']; $name = $row['poster_name'];
} else { } else {
$name = api_get_person_name($row['firstname'], $row['lastname']); $name = api_get_person_name($row['firstname'], $row['lastname']);

@ -71,7 +71,8 @@ if (!api_is_allowed_to_edit(false, true) &&
) { ) {
api_not_allowed(true); api_not_allowed(true);
} }
if (!$_user['user_id'] && 0 == $forum->getAllowAnonymous()) { if (!$_user['user_id'] &&
0 == $forum->getAllowAnonymous()) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -545,8 +545,9 @@ class Category implements GradebookItem
$category->set_id($gradebookCategory->getId()); $category->set_id($gradebookCategory->getId());
$category->set_name($gradebookCategory->getName()); $category->set_name($gradebookCategory->getName());
$category->set_description($gradebookCategory->getDescription()); $category->set_description($gradebookCategory->getDescription());
$category->set_user_id($gradebookCategory->getUserId()); $category->set_user_id($gradebookCategory->getId());
$category->set_course_code($gradebookCategory->getCourseCode()); //$category->set_course_code($gradebookCategory->getCourseCode());
$category->setCourseId($gradebookCategory->getCourse()->getId());
$category->set_parent_id($gradebookCategory->getParentId()); $category->set_parent_id($gradebookCategory->getParentId());
$category->set_weight($gradebookCategory->getWeight()); $category->set_weight($gradebookCategory->getWeight());
$category->set_visible($gradebookCategory->getVisible()); $category->set_visible($gradebookCategory->getVisible());

@ -1004,10 +1004,6 @@ class GroupManager
$categoryId = Database::insert($table, $params); $categoryId = Database::insert($table, $params);
if ($categoryId) { if ($categoryId) {
$sql = "UPDATE $table SET id = iid
WHERE iid = $categoryId";
Database::query($sql);
return $categoryId; return $categoryId;
} }

@ -276,11 +276,8 @@ class aicc extends learnpath
$lp_id = Database::insert_id(); $lp_id = Database::insert_id();
if ($lp_id) { if ($lp_id) {
$sql = "UPDATE $new_lp SET id = iid WHERE iid = $lp_id";
Database::query($sql);
$this->lp_id = $lp_id; $this->lp_id = $lp_id;
/*
api_item_property_update( api_item_property_update(
$courseInfo, $courseInfo,
TOOL_LEARNPATH, TOOL_LEARNPATH,
@ -295,7 +292,7 @@ class aicc extends learnpath
$this->lp_id, $this->lp_id,
'visible', 'visible',
api_get_user_id() api_get_user_id()
); );*/
} }
$previous = 0; $previous = 0;
@ -330,12 +327,6 @@ class aicc extends learnpath
error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0);
} }
$item_id = Database::insert_id(); $item_id = Database::insert_id();
if ($item_id) {
$sql = "UPDATE $new_lp_item SET id = iid WHERE iid = $lp_id";
Database::query($sql);
}
// Now update previous item to change next_item_id. // Now update previous item to change next_item_id.
if (0 != $previous) { if (0 != $previous) {
$upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous"; $upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous";
@ -647,7 +638,7 @@ class aicc extends learnpath
$lp = $this->get_id(); $lp = $this->get_id();
if (0 != $lp) { if (0 != $lp) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN); $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET preview_image = '$preview_image' $sql = "UPDATE $tbl_lp SET preview_image = '$preview_image'
WHERE c_id = ".$course_id." id = ".$lp; WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql); Database::query($sql);
@ -670,7 +661,7 @@ class aicc extends learnpath
$lp = $this->get_id(); $lp = $this->get_id();
if (0 != $lp) { if (0 != $lp) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN); $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET author = '$author' $sql = "UPDATE $tbl_lp SET author = '$author'
WHERE c_id = ".$course_id." id = ".$lp; WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql); Database::query($sql);
@ -696,7 +687,7 @@ class aicc extends learnpath
$lp = $this->get_id(); $lp = $this->get_id();
if (0 != $lp) { if (0 != $lp) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN); $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "UPDATE $tbl_lp SET content_maker = '$maker' $sql = "UPDATE $tbl_lp SET content_maker = '$maker'
WHERE c_id = ".$course_id." id = ".$lp; WHERE c_id = ".$course_id." id = ".$lp;
Database::query($sql); Database::query($sql);

@ -69,7 +69,7 @@ if (!$session) {
if ($list) { if ($list) {
/** @var SessionRelCourseRelUser $sessionCourseUser */ /** @var SessionRelCourseRelUser $sessionCourseUser */
foreach ($list as $sessionCourseUser) { foreach ($list as $sessionCourseUser) {
$subscribedUsers[$sessionCourseUser->getUser()->getUserId()] = $sessionCourseUser->getUser(); $subscribedUsers[$sessionCourseUser->getUser()->getId()] = $sessionCourseUser->getUser();
} }
} }
} }
@ -78,7 +78,7 @@ if (!$session) {
$choices = []; $choices = [];
/** @var User $user */ /** @var User $user */
foreach ($subscribedUsers as $user) { foreach ($subscribedUsers as $user) {
$choices[$user->getUserId()] = $user->getCompleteNameWithClasses(); $choices[$user->getId()] = $user->getCompleteNameWithClasses();
} }
// Getting subscribed users to a LP. // Getting subscribed users to a LP.

Loading…
Cancel
Save