Fixing some chat function

skala
Julio Montoya 14 years ago
parent b603b6978a
commit 6b3694084e
  1. 26
      main/chat/chat_functions.lib.php
  2. 3
      main/coursecopy/classes/CourseRecycler.class.php
  3. 22
      main/forum/forumfunction.inc.php
  4. 5
      main/inc/lib/add_course.lib.inc.php
  5. 6
      tests/main/chat/chat_functions.lib.test.php

@ -10,16 +10,15 @@
* @param integer the user id
* @param string the database name
* @return boolean
* @todo this function need more parameters seems not to be use anymore
* @deprecated fix this function or create another
*/
function user_connected_in_chat ($user_id) {
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$user_id = intval($user_id);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$user_id = intval($user_id);
$course_id = api_get_course_int_id();
$course_id = api_get_course_int_id();
$extra_condition = '';
if (!empty($group_id)) {
@ -39,12 +38,10 @@ function user_connected_in_chat ($user_id) {
* @return void
*/
function exit_of_chat($user_id) {
$user_id = intval($user_id);
$course_id = api_get_course_int_id();
$list_course = array();
$list_course = CourseManager::get_courses_list_by_user_id($user_id);
$user_id = intval($user_id);
$list_course = CourseManager::get_courses_list_by_user_id($user_id);
$session_id = api_get_session_id();
/*$session_id = api_get_session_id();
$group_id = api_get_group_id();
$extra_condition = '';
@ -53,15 +50,16 @@ function exit_of_chat($user_id) {
} else {
$extra_condition = api_get_session_condition($session_id);
}
$extra_condition.= " AND course_id = $course_id";
$extra_condition.= " AND course_id = $course_id";*/
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
foreach ($list_course as $course) {
$response = user_connected_in_chat($user_id);
if ($response === true) {
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id='.$user_id.$extra_condition;
//if ($response === true) {
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id = '.$user_id;
Database::query($sql);
}
//}
}
}

@ -153,8 +153,7 @@ class CourseRecycler
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql);
$sql = "DELETE FROM ".$table_mail_queue.
" USING ".$table_mail_queue." INNER JOIN ".$table_post.
$sql = "DELETE FROM ".$table_mail_queue." USING ".$table_mail_queue." INNER JOIN ".$table_post.
" WHERE c_id = ".$this->course_id." AND ".$table_mail_queue.".post_id = ".$table_post.".post_id".
" AND ".$table_post.".forum_id IN(".$forum_ids.");";
Database::query($sql);

@ -2984,30 +2984,14 @@ function send_notification_mails($thread_id, $reply_info) {
// The forum category, the forum, the thread and the reply are visible to the user.
if ($send_mails) {
send_notifications($current_thread['forum_id'], $thread_id);
/*
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT DISTINCT user.firstname, user.lastname, user.email, user.user_id
FROM $table_posts post, $table_user user
WHERE post.thread_id='".Database::escape_string($thread_id)."'
AND post.post_notification='1'
AND post.poster_id=user.user_id";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
send_mail($row, $current_thread);
}
*/
} else {
/*
$sql = "SELECT * FROM $table_posts WHERE thread_id='".Database::escape_string($thread_id)."' AND post_notification='1'";
$result = Database::query($sql);
*/
send_notifications($current_thread['forum_id'], $thread_id);
} else {
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
$sql = "SELECT * FROM $table_notification WHERE c_id = ".api_get_course_int_id()." AND (forum_id = '".Database::escape_string($current_forum['forum_id'])."' OR thread_id = '".Database::escape_string($thread_id)."' ) ";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$sql_mailcue = "INSERT INTO $table_mailcue (c_id, thread_id, post_id) VALUES (".api_get_course_int_id().", '".Database::escape_string($thread_id)."', '".Database::escape_string($reply_info['new_post_id'])."')";
$result_mailcue = Database::query($sql_mailcue);
Database::query($sql_mailcue);
}
}
}

@ -619,12 +619,13 @@ function create_course_tables($course_db_name = null) {
// Forum Mailcue
$sql = "
CREATE TABLE `".$TABLETOOLFORUMMAILCUE . "` (
CREATE TABLE `".$TABLETOOLFORUMMAILCUE."` (
$add_to_all_tables
id int NOT NULL auto_increment,
thread_id int default NULL,
user_id int default NULL,
post_id int default NULL,
PRIMARY KEY ( c_id, thread_id, user_id, post_id )
PRIMARY KEY (id, c_id, thread_id, user_id, post_id )
)" . $charset_clause;
Database::query($sql);

@ -20,10 +20,8 @@ class TestChatFunctions extends UnitTestCase {
function testuser_connected_in_chat () {
$course_code = 'COURSETEST';
$user_id=1;
$course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName'];
$res = user_connected_in_chat($user_id,$database_name);
$user_id = 1;
$res = user_connected_in_chat($user_id);
$this->assertTrue(is_bool($res));
}

Loading…
Cancel
Save