Fix forum tool in session for API - refs BT#12749 CT#7402

pull/2487/head
Angel Fernando Quiroz Campos 8 years ago
parent ce6bcc54f8
commit 6fd95e4f74
  1. 10
      main/forum/forumfunction.inc.php
  2. 16
      main/inc/lib/webservices/Rest.php

@ -1698,23 +1698,23 @@ function get_last_post_by_thread($course_id, $thread_id, $forum_id, $show_visibl
/**
* This function gets all the last post information of a certain forum
*
* @param int $forum_id the id of the forum we want to know the last post information of.
* @param bool $show_invisibles
* @param int $forum_id the id of the forum we want to know the last post information of.
* @param bool $show_invisibles
* @param string course db name
* @param int $sessionId Optional. The session id
* @return array containing all the information about the last post
* (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_last_post_information($forum_id, $show_invisibles = false, $course_id = null)
function get_last_post_information($forum_id, $show_invisibles = false, $course_id = null, $sessionId = 0)
{
if (!isset($course_id)) {
$course_id = api_get_course_int_id();
} else {
$course_id = intval($course_id);
}
$sessionId = api_get_session_id();
$sessionId = $sessionId ? intval($sessionId) : api_get_session_id();
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);

@ -527,7 +527,7 @@ class Rest extends WebService
'lastPost' => null
];
$lastPostInfo = get_last_post_information($forumId, false, $this->course->getId());
$lastPostInfo = get_last_post_information($forumId, false, $this->course->getId(), $sessionId);
if ($lastPostInfo) {
$forum['lastPost'] = [
@ -576,7 +576,8 @@ class Rest extends WebService
{
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forumInfo = get_forums($forumId, $this->course->getCode());
$sessionId = $this->session ? $this->session->getId() : 0;
$forumInfo = get_forums($forumId, $this->course->getCode(), true, $sessionId);
if (!isset($forumInfo['iid'])) {
throw new Exception(get_lang('NoForum'));
@ -591,7 +592,7 @@ class Rest extends WebService
'threads' => []
];
$threads = get_threads($forumInfo['iid'], $this->course->getId());
$threads = get_threads($forumInfo['iid'], $this->course->getId(), $sessionId);
foreach ($threads as $thread) {
$forum['threads'][] = [
@ -616,7 +617,8 @@ class Rest extends WebService
{
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$threadInfo = get_thread_information($forumId, $threadId);
$sessionId = $this->session ? $this->session->getId() : 0;
$threadInfo = get_thread_information($forumId, $threadId, $sessionId);
$thread = [
'id' => intval($threadInfo['iid']),
@ -626,7 +628,7 @@ class Rest extends WebService
'posts' => []
];
$forumInfo = get_forums($threadInfo['forum_id'], $this->course->getCode());
$forumInfo = get_forums($threadInfo['forum_id'], $this->course->getCode(), true, $sessionId);
$postsInfo = getPosts($forumInfo, $threadInfo['iid'], 'ASC');
@ -1003,9 +1005,9 @@ class Rest extends WebService
{
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forum = get_forums($forumId, $this->course->getCode());
$courseInfo = api_get_course_info($this->course->getCode());
$sessionId = $this->session ? $this->session->getId() : 0;
$forum = get_forums($forumId, $this->course->getCode(), true, $sessionId);
$courseInfo = api_get_course_info($this->course->getCode());
$id = store_thread($forum, $values, $courseInfo, false, $this->user->getId(), $sessionId);

Loading…
Cancel
Save