|
@@ -68,18 +68,16 @@ class Blog {
|
|
|
*/
|
|
|
public static function get_blog_users ($blog_id) {
|
|
|
// Database table definitions
|
|
|
- $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
- $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
+ $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Get blog members
|
|
|
- $sql = "SELECT
|
|
|
- user.user_id,
|
|
|
- user.firstname,
|
|
|
- user.lastname
|
|
|
- FROM " . $tbl_blogs_rel_user . " blogs_rel_user
|
|
|
- INNER JOIN " . $tbl_users . " user ON blogs_rel_user.user_id = user.user_id
|
|
|
- WHERE blogs_rel_user.blog_id = '" . Database::escape_string((int)$blog_id)."'";
|
|
|
+ $sql = "SELECT user.user_id, user.firstname, user.lastname
|
|
|
+ FROM " . $tbl_blogs_rel_user . " blogs_rel_user INNER JOIN " . $tbl_users . " user ON blogs_rel_user.user_id = user.user_id
|
|
|
+ WHERE blogs_rel_user.c_id = $course_id AND
|
|
|
+ blogs_rel_user.blog_id = '" . (int)$blog_id."'";
|
|
|
$result = Database::query($sql);
|
|
|
$blog_members = array ();
|
|
|
while($user = Database::fetch_array($result)) {
|
|
@@ -110,10 +108,12 @@ class Blog {
|
|
|
$sql='SELECT COUNT(*) as count FROM '.$tbl_blogs.' WHERE blog_name="'.Database::escape_string($title).'" AND blog_subtitle="'.Database::escape_string($subtitle).'";';
|
|
|
$res=Database::query($sql);
|
|
|
$info_count=Database::result($res,0,0);
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
if ($info_count==0) {
|
|
|
// Create the blog
|
|
|
- $sql = "INSERT INTO $tbl_blogs (blog_name, blog_subtitle, date_creation, visibility, session_id )
|
|
|
- VALUES ('".Database::escape_string($title)."', '".Database::escape_string($subtitle)."', '".$current_date."', '1', '$session_id');";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs (c_id, blog_name, blog_subtitle, date_creation, visibility, session_id )
|
|
|
+ VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($subtitle)."', '".$current_date."', '1', '$session_id');";
|
|
|
Database::query($sql);
|
|
|
$this_blog_id = Database::insert_id();
|
|
|
|
|
@@ -123,13 +123,13 @@ class Blog {
|
|
|
}
|
|
|
|
|
|
// Make first post. :)
|
|
|
- $sql = "INSERT INTO $tbl_blogs_posts (title, full_text, date_creation, blog_id, author_id )
|
|
|
- VALUES ('".get_lang("Welcome")."', '" . get_lang('FirstPostText')."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string((int)$_user['user_id'])."');";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
|
|
|
+ VALUES ($course_id, '".get_lang("Welcome")."', '" . get_lang('FirstPostText')."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string((int)$_user['user_id'])."');";
|
|
|
Database::query($sql);
|
|
|
|
|
|
// Put it on course homepage
|
|
|
- $sql = "INSERT INTO $tbl_tool (name, link, image, visibility, admin, address, added_tool, session_id)
|
|
|
- VALUES ('".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
|
|
|
+ $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
|
|
|
+ VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
|
|
|
Database::query($sql);
|
|
|
|
|
|
// Subscribe the teacher to this blog
|
|
@@ -225,6 +225,9 @@ class Blog {
|
|
|
$upload_ok=true;
|
|
|
$has_attachment=false;
|
|
|
$current_date=date('Y-m-d H:i:s',time());
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
|
|
|
if(!empty($_FILES['user_upload']['name'])) {
|
|
|
require_once('fileUpload.lib.php');
|
|
@@ -237,8 +240,8 @@ class Blog {
|
|
|
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
|
|
|
|
|
|
// Create the post
|
|
|
- $sql = "INSERT INTO " . $tbl_blogs_posts." (title, full_text, date_creation, blog_id, author_id )
|
|
|
- VALUES ('".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
|
|
|
+ VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
|
|
|
|
|
|
Database::query($sql);
|
|
|
$last_post_id=Database::insert_id();
|
|
@@ -267,16 +270,15 @@ class Blog {
|
|
|
|
|
|
// Storing the attachments if any
|
|
|
if ($result) {
|
|
|
- $sql='INSERT INTO '.$blog_table_attachment.'(filename,comment, path, post_id,size, blog_id,comment_id) '.
|
|
|
- "VALUES ( '".Database::escape_string($file_name)."', '".Database::escape_string($comment)."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )";
|
|
|
+ $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
|
|
|
+ "VALUES ($course_id, '".Database::escape_string($file_name)."', '".Database::escape_string($comment)."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )";
|
|
|
$result=Database::query($sql);
|
|
|
$message.=' / '.get_lang('AttachmentUpload');
|
|
|
+ exit;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
Display::display_error_message(get_lang('UplNoFileUploaded'));
|
|
|
}
|
|
|
}
|
|
@@ -340,9 +342,10 @@ class Blog {
|
|
|
global $_course;
|
|
|
global $blog_table_attachment;
|
|
|
|
|
|
- $upload_ok=true;
|
|
|
- $has_attachment=false;
|
|
|
- $current_date=date('Y-m-d H:i:s',time());
|
|
|
+ $upload_ok = true;
|
|
|
+ $has_attachment = false;
|
|
|
+ $current_date = date('Y-m-d H:i:s',time());
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
if(!empty($_FILES['user_upload']['name']))
|
|
|
{
|
|
@@ -351,14 +354,13 @@ class Blog {
|
|
|
$has_attachment=true;
|
|
|
}
|
|
|
|
|
|
- if($upload_ok)
|
|
|
- {
|
|
|
+ if ($upload_ok) {
|
|
|
// Table Definition
|
|
|
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
|
|
|
|
|
|
// Create the comment
|
|
|
- $sql = "INSERT INTO $tbl_blogs_comments (title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
|
|
|
- VALUES ('".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
|
|
|
+ VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
|
|
|
Database::query($sql);
|
|
|
|
|
|
// Empty post values, or they are shown on the page again
|
|
@@ -393,8 +395,8 @@ class Blog {
|
|
|
// Storing the attachments if any
|
|
|
if ($result)
|
|
|
{
|
|
|
- $sql='INSERT INTO '.$blog_table_attachment.'(filename,comment, path, post_id,size,blog_id,comment_id) '.
|
|
|
- "VALUES ( '".Database::escape_string($file_name)."', '".Database::escape_string($comment)."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )";
|
|
|
+ $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
|
|
|
+ "VALUES ($course_id, '".Database::escape_string($file_name)."', '".Database::escape_string($comment)."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )";
|
|
|
$result=Database::query($sql);
|
|
|
$message.=' / '.get_lang('AttachmentUpload');
|
|
|
}
|
|
@@ -450,55 +452,42 @@ class Blog {
|
|
|
// Init
|
|
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Create the task
|
|
|
- $sql = "INSERT INTO $tbl_blogs_tasks (blog_id, title, description, color, system_task )
|
|
|
- VALUES ('".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task )
|
|
|
+ VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
|
|
|
Database::query($sql);
|
|
|
|
|
|
$task_id = Database::insert_id();
|
|
|
$tool = 'BLOG_' . $blog_id;
|
|
|
|
|
|
- if($articleDelete == 'on')
|
|
|
- {
|
|
|
- $sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ if ($articleDelete == 'on') {
|
|
|
+ $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_delete'
|
|
|
)";
|
|
|
-
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
|
|
|
- if($articleEdit == 'on')
|
|
|
- {
|
|
|
+ if($articleEdit == 'on') {
|
|
|
$sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_edit'
|
|
|
)";
|
|
|
-
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
|
|
|
- if($commentsDelete == 'on')
|
|
|
- {
|
|
|
+ if($commentsDelete == 'on') {
|
|
|
$sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_comments_delete'
|
|
@@ -531,20 +520,14 @@ class Blog {
|
|
|
|
|
|
$tool = 'BLOG_' . $blog_id;
|
|
|
|
|
|
- $sql = "
|
|
|
- DELETE FROM " . $tbl_tasks_permissions . "
|
|
|
- WHERE task_id = '" . (int)$task_id."'";
|
|
|
-
|
|
|
+ $sql = "DELETE FROM " . $tbl_tasks_permissions . " WHERE task_id = '" . (int)$task_id."'";
|
|
|
Database::query($sql);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
- if($articleDelete == 'on')
|
|
|
- {
|
|
|
- $sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ if($articleDelete == 'on') {
|
|
|
+ $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_delete'
|
|
@@ -553,35 +536,23 @@ class Blog {
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
|
|
|
- if($articleEdit == 'on')
|
|
|
- {
|
|
|
- $sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ if($articleEdit == 'on') {
|
|
|
+ $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_edit'
|
|
|
)";
|
|
|
-
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
|
|
|
- if($commentsDelete == 'on')
|
|
|
- {
|
|
|
- $sql = "
|
|
|
- INSERT INTO " . $tbl_tasks_permissions . " (
|
|
|
- task_id,
|
|
|
- tool,
|
|
|
- action
|
|
|
- ) VALUES (
|
|
|
+ if($commentsDelete == 'on') {
|
|
|
+ $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
|
'" . Database::escape_string($tool) . "',
|
|
|
'article_comments_delete'
|
|
|
)";
|
|
|
-
|
|
|
Database::query($sql);
|
|
|
}
|
|
|
}
|
|
@@ -622,24 +593,29 @@ class Blog {
|
|
|
global $_user;
|
|
|
|
|
|
// Init
|
|
|
- $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
- $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
- $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
+ $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
+ $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
+ $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
- if($_user['user_id'])
|
|
|
- {
|
|
|
+ if($_user['user_id']) {
|
|
|
$sql = "SELECT task_rel_user.*, task.title, blog.blog_name FROM $tbl_blogs_tasks_rel_user task_rel_user
|
|
|
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
|
|
|
INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
|
|
|
AND blog.blog_id = ".intval($_GET['blog_id'])."
|
|
|
- WHERE task_rel_user.user_id = ".(int)$_user['user_id']." ORDER BY target_date ASC";
|
|
|
+ WHERE
|
|
|
+ task.c_id = $course_id AND
|
|
|
+ blog.c_id = $course_id AND
|
|
|
+ task_rel_user.c_id = $course_id AND
|
|
|
+ task_rel_user.user_id = ".(int)$_user['user_id']."
|
|
|
+ ORDER BY target_date ASC";
|
|
|
+
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
- if (Database::num_rows($result) > 0)
|
|
|
- {
|
|
|
+ if (Database::num_rows($result) > 0) {
|
|
|
echo '<ul>';
|
|
|
- while($mytask = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ while($mytask = Database::fetch_array($result)) {
|
|
|
echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
|
|
|
}
|
|
|
echo '<ul>';
|
|
@@ -665,6 +641,7 @@ class Blog {
|
|
|
// Init
|
|
|
$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Get blog properties
|
|
|
$sql = "SELECT blog_name, visibility FROM $tbl_blogs WHERE blog_id='".(int)$blog_id."'";
|
|
@@ -688,8 +665,8 @@ class Blog {
|
|
|
$sql = "UPDATE $tbl_blogs SET visibility = '1' WHERE blog_id ='".(int)$blog_id."' LIMIT 1";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
- $sql = "INSERT INTO $tbl_tool (name, link, image, visibility, admin, address, added_tool, target )
|
|
|
- VALUES ('".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
|
|
|
+ $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
|
|
|
+ VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
|
|
|
$result = Database::query($sql);
|
|
|
}
|
|
|
}
|
|
@@ -707,13 +684,16 @@ class Blog {
|
|
|
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
|
|
|
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
global $dateFormatLong;
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Get posts and authors
|
|
|
$sql = "SELECT post.*, user.lastname, user.firstname FROM $tbl_blogs_posts post
|
|
|
INNER JOIN $tbl_users user ON post.author_id = user.user_id
|
|
|
- WHERE post.blog_id = '".(int)$blog_id."'
|
|
|
- AND $filter
|
|
|
- ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
|
|
|
+ WHERE post.blog_id = '".(int)$blog_id."' AND
|
|
|
+ post.c_id = $course_id AND
|
|
|
+ $filter
|
|
|
+ ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
// Display
|
|
@@ -833,12 +813,17 @@ class Blog {
|
|
|
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
|
|
|
global $charset,$dateFormatLong;
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
|
|
|
// Get posts and author
|
|
|
$sql = "SELECT post.*, user.lastname, user.firstname FROM $tbl_blogs_posts post
|
|
|
INNER JOIN $tbl_users user ON post.author_id = user.user_id
|
|
|
- WHERE post.blog_id = '".(int)$blog_id."'
|
|
|
- AND post.post_id = '".(int)$post_id."'
|
|
|
+ WHERE
|
|
|
+ post.c_id = $course_id AND
|
|
|
+ post.blog_id = '".(int)$blog_id."' AND
|
|
|
+ post.post_id = '".(int)$post_id."'
|
|
|
ORDER BY post_id DESC";
|
|
|
$result = Database::query($sql);
|
|
|
$blog_post = Database::fetch_array($result);
|
|
@@ -924,6 +909,7 @@ class Blog {
|
|
|
|
|
|
// Init
|
|
|
$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Check if the user has already rated this post/comment
|
|
|
$sql = "SELECT rating_id FROM $tbl_blogs_rating
|
|
@@ -935,8 +921,8 @@ class Blog {
|
|
|
|
|
|
if(Database::num_rows($result) == 0) // Add rating
|
|
|
{
|
|
|
- $sql = "INSERT INTO $tbl_blogs_rating ( blog_id, rating_type, item_id, user_id, rating )
|
|
|
- VALUES ('".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
|
|
|
+ VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
|
|
|
$result = Database::query($sql);
|
|
|
return true;
|
|
|
}
|
|
@@ -1031,10 +1017,12 @@ class Blog {
|
|
|
*/
|
|
|
public static function get_threaded_comments ($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) {
|
|
|
// Init
|
|
|
- $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
|
|
|
- $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
- $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
+ $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
|
|
|
+ $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
+ $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
global $charset,$dateFormatLong;
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Select top level comments
|
|
|
$next_level = $current_level + 1;
|
|
@@ -1042,19 +1030,22 @@ class Blog {
|
|
|
FROM $tbl_blogs_comments comments
|
|
|
INNER JOIN $tbl_users user ON comments.author_id = user.user_id
|
|
|
LEFT JOIN $tbl_blogs_tasks task ON comments.task_id = task.task_id
|
|
|
- WHERE parent_comment_id = $current
|
|
|
- AND comments.blog_id = '".(int)$blog_id."'
|
|
|
- AND comments.post_id = '".(int)$post_id."'";
|
|
|
+ WHERE comments.c_id = $course_id AND
|
|
|
+ task.c_id = $course_id AND
|
|
|
+ parent_comment_id = $current AND
|
|
|
+ comments.blog_id = '".(int)$blog_id."' AND
|
|
|
+ comments.post_id = '".(int)$post_id."'";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
- while($comment = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ while($comment = Database::fetch_array($result)) {
|
|
|
// Select the children recursivly
|
|
|
$tmp = "SELECT comments.*, user.lastname, user.firstname FROM $tbl_blogs_comments comments
|
|
|
INNER JOIN $tbl_users user ON comments.author_id = user.user_id
|
|
|
- WHERE comment_id = $current
|
|
|
- AND blog_id = '".(int)$blog_id."'
|
|
|
- AND post_id = '".(int)$post_id."'";
|
|
|
+ WHERE
|
|
|
+ comments.c_id = $course_id AND
|
|
|
+ comment_id = $current
|
|
|
+ AND blog_id = '".(int)$blog_id."'
|
|
|
+ AND post_id = '".(int)$post_id."'";
|
|
|
$tmp = Database::query($tmp);
|
|
|
$tmp = Database::fetch_array($tmp);
|
|
|
$parent_cat = $tmp['parent_comment_id'];
|
|
@@ -1067,8 +1058,7 @@ class Blog {
|
|
|
if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
|
|
|
if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
|
|
|
|
|
|
- if(!is_null($comment['task_id']))
|
|
|
- {
|
|
|
+ if(!is_null($comment['task_id'])) {
|
|
|
$border_color = ' border-left: 3px solid #' . $comment['color'];
|
|
|
}
|
|
|
|
|
@@ -1265,12 +1255,16 @@ class Blog {
|
|
|
// Init
|
|
|
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
|
|
|
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
-
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
// Get posts and author
|
|
|
$sql = "SELECT post.*, user.lastname, user.firstname FROM $tbl_blogs_posts post
|
|
|
INNER JOIN $tbl_users user ON post.author_id = user.user_id
|
|
|
- WHERE post.blog_id = '".(int)$blog_id ."'
|
|
|
- AND post.post_id = '".(int)$post_id."'
|
|
|
+ WHERE
|
|
|
+ post.c_id = $course_id AND
|
|
|
+ post.blog_id = '".(int)$blog_id ."'
|
|
|
+ AND post.post_id = '".(int)$post_id."'
|
|
|
ORDER BY post_id DESC";
|
|
|
$result = Database::query($sql);
|
|
|
$blog_post = Database::fetch_array($result);
|
|
@@ -1287,25 +1281,21 @@ class Blog {
|
|
|
echo '<div><span class="form_required">*</span>' . get_lang('Title') . ': <input name="post_title" id="post_title" type="text" size="60" value="'.stripslashes($blog_post['title']) . '" /><br /></div>';
|
|
|
|
|
|
// article text
|
|
|
- $oFCKeditor = new FCKeditor('post_full_text') ;
|
|
|
+ $oFCKeditor = new FCKeditor('post_full_text') ;
|
|
|
|
|
|
- $oFCKeditor->Width = '100%';
|
|
|
- $oFCKeditor->Height = '200';
|
|
|
+ $oFCKeditor->Width = '100%';
|
|
|
+ $oFCKeditor->Height = '200';
|
|
|
|
|
|
- if(!api_is_allowed_to_edit())
|
|
|
- {
|
|
|
- $oFCKeditor->ToolbarSet = 'ProjectStudent';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $oFCKeditor->ToolbarSet = 'Project';
|
|
|
- }
|
|
|
- $oFCKeditor->Value = isset($_POST['post_full_text'])?stripslashes($_POST['post_full_text']):$blog_post_text;
|
|
|
+ if(!api_is_allowed_to_edit()) {
|
|
|
+ $oFCKeditor->ToolbarSet = 'ProjectStudent';
|
|
|
+ } else {
|
|
|
+ $oFCKeditor->ToolbarSet = 'Project';
|
|
|
+ }
|
|
|
+ $oFCKeditor->Value = isset($_POST['post_full_text'])?stripslashes($_POST['post_full_text']):$blog_post_text;
|
|
|
echo '<div class="formw">';
|
|
|
echo $oFCKeditor->Create();
|
|
|
echo '</div>';
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
// submit
|
|
|
echo ' <div class="row">
|
|
|
<div class="label">
|
|
@@ -1422,18 +1412,21 @@ class Blog {
|
|
|
"<th><b>",get_lang('Description'),"</b></th>\n",
|
|
|
"<th><b>",get_lang('TargetDate'),"</b></th>\n",
|
|
|
"<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
|
|
|
- "</tr>\n";
|
|
|
-
|
|
|
+ "</tr>";
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
- $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, task.description, task.system_task, task.blog_id, task.task_id FROM $tbl_blogs_tasks_rel_user task_rel_user
|
|
|
- INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
|
|
|
- INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
|
|
|
- WHERE task_rel_user.blog_id = '".(int)$blog_id."' ORDER BY target_date ASC";
|
|
|
+ $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, task.description, task.system_task, task.blog_id, task.task_id
|
|
|
+ FROM $tbl_blogs_tasks_rel_user task_rel_user
|
|
|
+ INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
|
|
|
+ INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
|
|
|
+ WHERE task_rel_user.c_id = $course_id AND
|
|
|
+ task.c_id = $course_id AND
|
|
|
+ task_rel_user.blog_id = '".(int)$blog_id."'
|
|
|
+ ORDER BY target_date ASC";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
-
|
|
|
- while($assignment = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ while($assignment = Database::fetch_array($result)) {
|
|
|
$counter++;
|
|
|
$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
|
|
|
$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
|
|
@@ -1659,12 +1652,15 @@ class Blog {
|
|
|
$month = date("m");
|
|
|
$year = date("Y");
|
|
|
global $MonthsLong;
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
|
|
|
// Get users in this blog / make select list of it
|
|
|
$sql = "SELECT user.user_id, user.firstname, user.lastname FROM $tbl_users user
|
|
|
INNER JOIN $tbl_blogs_rel_user blogs_rel_user
|
|
|
ON user.user_id = blogs_rel_user.user_id
|
|
|
- WHERE blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
+ WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
$result = Database::query($sql);
|
|
|
$select_user_list = '<select name="task_user_id">';
|
|
|
while($user = Database::fetch_array($result))
|
|
@@ -1793,38 +1789,16 @@ class Blog {
|
|
|
*
|
|
|
*/
|
|
|
public static function display_edit_assigned_task_form ($blog_id, $task_id, $user_id) {
|
|
|
- //$parameters = explode('_', $assignment_id);
|
|
|
- //$task_id = $parameters[0];
|
|
|
- //$user_id = $parameters[1];
|
|
|
-
|
|
|
- /* ------------- */
|
|
|
- // Init
|
|
|
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
|
|
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
-
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
$year = date("Y");
|
|
|
global $MonthsLong;
|
|
|
|
|
|
- /*// Get assignd tasks of user
|
|
|
- $sql = "
|
|
|
- SELECT task_id
|
|
|
- FROM $tbl_blogs_tasks_rel_user
|
|
|
- WHERE
|
|
|
- user_id = $user_id AND
|
|
|
- blog_id = $blog_id";
|
|
|
-
|
|
|
- $result = Database::query($sql);
|
|
|
-
|
|
|
- $arrUserTasks = array();
|
|
|
-
|
|
|
- while ($row = Database::fetch_assoc($result))
|
|
|
- {
|
|
|
- $arrUserTasks[] = $row['task_id'];
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
// Get assignd date;
|
|
|
$sql = "
|
|
|
SELECT target_date
|
|
@@ -1842,17 +1816,15 @@ class Blog {
|
|
|
$sql = "
|
|
|
SELECT user.user_id, user.firstname, user.lastname
|
|
|
FROM $tbl_users user
|
|
|
- INNER JOIN $tbl_blogs_rel_user blogs_rel_user on user.user_id = blogs_rel_user.user_id
|
|
|
- WHERE blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
+ INNER JOIN $tbl_blogs_rel_user blogs_rel_user O user.user_id = blogs_rel_user.user_id
|
|
|
+ WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
$select_user_list = '<select name="task_user_id">';
|
|
|
-
|
|
|
- while($user = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ while($user = Database::fetch_array($result)) {
|
|
|
$select_user_list .= '<option ' . (($user_id == $user['user_id']) ? 'selected="selected "' : ' ') . 'value="' . $user['user_id'] . '">' . api_get_person_name($user['firstname'], $user['lastname']) . '</option>';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$select_user_list .= '</select>';
|
|
|
|
|
|
// Get tasks in this blog / make select list of it
|
|
@@ -1866,15 +1838,12 @@ class Blog {
|
|
|
system_task
|
|
|
FROM " . $tbl_blogs_tasks . "
|
|
|
WHERE blog_id = " . (int)$blog_id . "
|
|
|
- ORDER BY
|
|
|
- system_task,
|
|
|
- title";
|
|
|
+ ORDER BY system_task, title";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
$select_task_list = '<select name="task_task_id">';
|
|
|
|
|
|
- while($task = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ while($task = Database::fetch_array($result)) {
|
|
|
//if(!in_array($task['task_id'], $arrUserTasks) || $task_id == $task['task_id'])
|
|
|
$select_task_list .= '<option ' . (($task_id == $task['task_id']) ? 'selected="selected "' : ' ') . 'value="' . $task['task_id'] . '">'.stripslashes($task['title']) . '</option>';
|
|
|
}
|
|
@@ -1962,6 +1931,7 @@ class Blog {
|
|
|
public static function assign_task ($blog_id, $user_id, $task_id, $target_date) {
|
|
|
// Init
|
|
|
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
$sql = "
|
|
|
SELECT COUNT(*) as 'number'
|
|
@@ -1974,15 +1944,16 @@ class Blog {
|
|
|
$result = @Database::query($sql);
|
|
|
$row = Database::fetch_assoc($result);
|
|
|
|
|
|
- if($row['number'] == 0)
|
|
|
- {
|
|
|
+ if($row['number'] == 0) {
|
|
|
$sql = "
|
|
|
INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
|
|
|
+ c_id,
|
|
|
blog_id,
|
|
|
user_id,
|
|
|
task_id,
|
|
|
target_date
|
|
|
) VALUES (
|
|
|
+ '" . (int)$course_id . "',
|
|
|
'" . (int)$blog_id . "',
|
|
|
'" . (int)$user_id . "',
|
|
|
'" . (int)$task_id . "',
|
|
@@ -1996,9 +1967,10 @@ class Blog {
|
|
|
public static function edit_assigned_task ($blog_id, $user_id, $task_id, $target_date, $old_user_id, $old_task_id, $old_target_date) {
|
|
|
// Init
|
|
|
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
- $sql = "
|
|
|
- SELECT COUNT(*) as 'number'
|
|
|
+ $sql = "SELECT COUNT(*) as 'number'
|
|
|
FROM " . $tbl_blogs_tasks_rel_user . "
|
|
|
WHERE
|
|
|
blog_id = " . (int)$blog_id . " AND
|
|
@@ -2009,8 +1981,7 @@ class Blog {
|
|
|
$result = @Database::query($sql);
|
|
|
$row = Database::fetch_assoc($result);
|
|
|
|
|
|
- if($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id))
|
|
|
- {
|
|
|
+ if($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
|
|
|
$sql = "
|
|
|
UPDATE " . $tbl_blogs_tasks_rel_user . "
|
|
|
SET
|
|
@@ -2018,6 +1989,7 @@ class Blog {
|
|
|
task_id = " . (int)$task_id . ",
|
|
|
target_date = '" . Database::escape_string($target_date) . "'
|
|
|
WHERE
|
|
|
+ c_id = $course_id AND
|
|
|
blog_id = " . (int)$blog_id . " AND
|
|
|
user_id = " . (int)$old_user_id . " AND
|
|
|
task_id = " . (int)$old_task_id . " AND
|
|
@@ -2039,39 +2011,31 @@ class Blog {
|
|
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
|
|
|
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
-
|
|
|
- $sql = "
|
|
|
- SELECT title, description
|
|
|
- FROM $tbl_blogs_tasks
|
|
|
- WHERE task_id = '".(int)$task_id."'";
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
+
|
|
|
+ $sql = "SELECT title, description FROM $tbl_blogs_tasks
|
|
|
+ WHERE task_id = '".(int)$task_id."'";
|
|
|
$result = Database::query($sql);
|
|
|
$row = Database::fetch_assoc($result);
|
|
|
// Get posts and authors
|
|
|
- $sql = "
|
|
|
- SELECT
|
|
|
- post.*,
|
|
|
- user.lastname,
|
|
|
- user.firstname
|
|
|
- FROM $tbl_blogs_posts post
|
|
|
- INNER JOIN $tbl_users user ON post.author_id = user.user_id
|
|
|
- WHERE post.blog_id = '".(int)$blog_id."'
|
|
|
- ORDER BY post_id DESC
|
|
|
- LIMIT 0, 100";
|
|
|
+ $sql = "SELECT post.*, user.lastname, user.firstname
|
|
|
+ FROM $tbl_blogs_posts post
|
|
|
+ INNER JOIN $tbl_users user ON post.author_id = user.user_id
|
|
|
+ WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
|
|
|
+ ORDER BY post_id DESC
|
|
|
+ LIMIT 0, 100";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
// Display
|
|
|
echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
|
|
|
echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
|
|
|
|
|
|
-
|
|
|
- if(Database::num_rows($result) > 0)
|
|
|
- {
|
|
|
- while($blog_post = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ if(Database::num_rows($result) > 0) {
|
|
|
+ while($blog_post = Database::fetch_array($result)) {
|
|
|
echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(api_get_person_name($blog_post['firstname'], $blog_post['lastname'])) . '<br />';
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
+ } else
|
|
|
echo get_lang('NoArticles');
|
|
|
}
|
|
|
|
|
@@ -2086,15 +2050,17 @@ class Blog {
|
|
|
// Init
|
|
|
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
|
|
|
$tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
// Subscribe the user
|
|
|
- $sql = "INSERT INTO $tbl_blogs_rel_user ( blog_id, user_id ) VALUES ('".(int)$blog_id."', '".(int)$user_id."');";
|
|
|
+ $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
// Give this user basic rights
|
|
|
- $sql="INSERT INTO $tbl_user_permissions (user_id,tool,action) VALUES ('".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
|
|
|
+ $sql="INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
|
|
|
$result = Database::query($sql);
|
|
|
- $sql="INSERT INTO $tbl_user_permissions (user_id,tool,action) VALUES ('".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
|
|
|
+ $sql="INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
|
|
|
$result = Database::query($sql);
|
|
|
}
|
|
|
|
|
@@ -2138,17 +2104,17 @@ class Blog {
|
|
|
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
|
|
|
|
|
echo '<div class="row"><div class="form_header">'.get_lang('SubscribeMembers').'</div></div>';
|
|
|
-
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
$properties["width"] = "100%";
|
|
|
|
|
|
// Get blog members' id.
|
|
|
$sql = "SELECT user.user_id FROM $tbl_users user
|
|
|
INNER JOIN $tbl_blogs_rel_user blogs_rel_user
|
|
|
ON user.user_id = blogs_rel_user.user_id
|
|
|
- WHERE blogs_rel_user.blog_id = '".intval($blog_id)."'";
|
|
|
+ WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
- $blog_member_ids = array ();
|
|
|
+ $blog_member_ids = array();
|
|
|
while($user = Database::fetch_array($result))
|
|
|
{
|
|
|
$blog_member_ids[] = $user['user_id'];
|
|
@@ -2259,12 +2225,13 @@ class Blog {
|
|
|
$column_header[] = array (get_lang('Email'), true, '');
|
|
|
$column_header[] = array (get_lang('TaskManager'), true, '');
|
|
|
$column_header[] = array (get_lang('UnRegister'), false, '');
|
|
|
-
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
+
|
|
|
$sql_query = "SELECT user.user_id, user.lastname, user.firstname, user.email
|
|
|
- FROM $tbl_users user
|
|
|
- INNER JOIN $tbl_blogs_rel_user blogs_rel_user
|
|
|
+ FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
|
|
|
ON user.user_id = blogs_rel_user.user_id
|
|
|
- WHERE blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
+ WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
|
|
|
|
|
|
if (!($sql_result = Database::query($sql_query))) {
|
|
|
return false;
|
|
@@ -2272,8 +2239,7 @@ class Blog {
|
|
|
|
|
|
$user_data = array ();
|
|
|
|
|
|
- while($myrow = Database::fetch_array($sql_result))
|
|
|
- {
|
|
|
+ while($myrow = Database::fetch_array($sql_result)) {
|
|
|
$row = array ();
|
|
|
$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.(($_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
|
|
|
if ($is_western_name_order) {
|
|
@@ -2288,7 +2254,10 @@ class Blog {
|
|
|
$sql = "SELECT bt.title task
|
|
|
FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
|
|
|
INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt ON btu.task_id = bt.task_id
|
|
|
- WHERE btu.blog_id = $blog_id AND btu.user_id = " . $myrow['user_id'] . "";
|
|
|
+ WHERE btu.c_id = $course_id AND
|
|
|
+ bt.c_id = $course_id AND
|
|
|
+ btu.blog_id = $blog_id AND
|
|
|
+ btu.user_id = " . $myrow['user_id'];
|
|
|
|
|
|
if (!($sql_res = Database::query($sql))) {
|
|
|
die(Database::error());
|
|
@@ -2454,6 +2423,8 @@ class Blog {
|
|
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
|
|
|
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
|
|
|
$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
+
|
|
|
+ $course_id = api_get_course_int_id();
|
|
|
|
|
|
//Handle leap year
|
|
|
$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
|
@@ -2474,17 +2445,16 @@ class Blog {
|
|
|
$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname FROM $tbl_blogs_posts post
|
|
|
INNER JOIN $tbl_users user
|
|
|
ON post.author_id = user.user_id
|
|
|
- WHERE post.blog_id = '".(int)$blog_id."'
|
|
|
- AND MONTH(date_creation) = '".(int)$month."'
|
|
|
- AND YEAR(date_creation) = '".(int)$year."'
|
|
|
+ WHERE post.c_id = $course_id AND
|
|
|
+ post.blog_id = '".(int)$blog_id."' AND
|
|
|
+ MONTH(date_creation) = '".(int)$month."' AND
|
|
|
+ YEAR(date_creation) = '".(int)$year."'
|
|
|
ORDER BY date_creation";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
|
// We will create an array of days on which there are posts.
|
|
|
- if( Database::num_rows($result) > 0)
|
|
|
- {
|
|
|
- while($blog_post = Database::fetch_array($result))
|
|
|
- {
|
|
|
+ if( Database::num_rows($result) > 0) {
|
|
|
+ while($blog_post = Database::fetch_array($result)) {
|
|
|
// If the day of this post is not yet in the array, add it.
|
|
|
if(!in_array($blog_post['post_day'], $posts))
|
|
|
$posts[] = $blog_post['post_day'];
|
|
@@ -2492,18 +2462,16 @@ class Blog {
|
|
|
}
|
|
|
|
|
|
// Get tasks for this month
|
|
|
- if($_user['user_id'])
|
|
|
- {
|
|
|
- $sql = "
|
|
|
- SELECT
|
|
|
- task_rel_user.*,
|
|
|
- DAYOFMONTH(target_date) as task_day,
|
|
|
- task.title,
|
|
|
- blog.blog_name
|
|
|
+ if($_user['user_id']) {
|
|
|
+ $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
|
|
|
FROM $tbl_blogs_tasks_rel_user task_rel_user
|
|
|
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
|
|
|
INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
|
|
|
- WHERE task_rel_user.user_id = '".(int)$_user['user_id']."'
|
|
|
+ WHERE
|
|
|
+ task_rel_user.c_id = $course_id AND
|
|
|
+ task.c_id = $course_id AND
|
|
|
+ blog.c_id = $course_id AND
|
|
|
+ task_rel_user.user_id = '".(int)$_user['user_id']."'
|
|
|
AND MONTH(target_date) = '".(int)$month."'
|
|
|
AND YEAR(target_date) = '".(int)$year."'
|
|
|
ORDER BY target_date ASC";
|
|
@@ -2713,10 +2681,12 @@ class Blog {
|
|
|
|
|
|
$sql = 'SELECT blog_name,blog_subtitle,visibility,blog_id FROM '.$tbl_blogs.' ORDER BY date_creation DESC ';
|
|
|
$result = Database::query($sql);
|
|
|
-
|
|
|
- while ($row_project=Database::fetch_row($result)) {
|
|
|
- $list_info[]=$row_project;
|
|
|
+ if (Database::num_rows($result)) {
|
|
|
+ while ($row_project=Database::fetch_row($result)) {
|
|
|
+ $list_info[]=$row_project;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
|
|
|
$list_content_blog = array();
|
|
|
$list_body_blog = array();
|
|
@@ -2901,25 +2871,28 @@ function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
|
|
|
* @param string db course name
|
|
|
* @param int user id
|
|
|
*/
|
|
|
-function get_blog_post_from_user($course_db_name, $user_id) {
|
|
|
-
|
|
|
- $tbl_blogs = Database::get_course_table(TABLE_BLOGS,$course_db_name);
|
|
|
- $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS,$course_db_name);
|
|
|
+function get_blog_post_from_user($course_code, $user_id) {
|
|
|
+ $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
+ $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS);
|
|
|
+ $course_info = api_get_course_info($course_code);
|
|
|
+ $course_id = $course_info['real_id'];
|
|
|
+
|
|
|
$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
|
|
|
FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post
|
|
|
ON (blog.blog_id = post.blog_id)
|
|
|
- WHERE author_id = $user_id AND visibility = 1
|
|
|
+ WHERE
|
|
|
+ blog.c_id = $course_id AND
|
|
|
+ post.c_id = $course_id AND
|
|
|
+ author_id = $user_id AND visibility = 1
|
|
|
ORDER BY post.date_creation DESC ";
|
|
|
$result = Database::query($sql);
|
|
|
$return_data = '';
|
|
|
- //$my_course_info=explode('_',$course_db_name);
|
|
|
- $my_course_id=CourseManager::get_course_id_by_database_name($course_db_name);
|
|
|
+
|
|
|
if (Database::num_rows($result)!=0) {
|
|
|
while ($row=Database::fetch_array($result)) {
|
|
|
$return_data.= '<div class="clear"></div><br />';
|
|
|
$return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
|
|
|
$return_data.= '<br / >';
|
|
|
- //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';
|
|
|
$return_data.= $row['full_text'];
|
|
|
$return_data.= '<br /><br />';
|
|
|
}
|
|
@@ -2932,24 +2905,28 @@ function get_blog_post_from_user($course_db_name, $user_id) {
|
|
|
* @param string db course name
|
|
|
* @param int user id
|
|
|
*/
|
|
|
-function get_blog_comment_from_user($course_db_name, $user_id) {
|
|
|
-
|
|
|
- $tbl_blogs = Database::get_course_table(TABLE_BLOGS,$course_db_name);
|
|
|
- $tbl_blog_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS,$course_db_name);
|
|
|
- $user_id = Database::escape_string($user_id);
|
|
|
+function get_blog_comment_from_user($course_code, $user_id) {
|
|
|
+ $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
|
|
|
+ $tbl_blog_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS);
|
|
|
+ $user_id = Database::escape_string($user_id);
|
|
|
+
|
|
|
+ $course_info = api_get_course_info($course_code);
|
|
|
+ $course_id = $course_info['real_id'];
|
|
|
|
|
|
$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
|
|
|
FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment
|
|
|
ON (blog.blog_id = comment.blog_id)
|
|
|
- WHERE author_id = $user_id AND visibility = 1
|
|
|
+ WHERE blog.c_id = $course_id AND
|
|
|
+ comment.c_id = $course_id AND
|
|
|
+ author_id = $user_id AND
|
|
|
+ visibility = 1
|
|
|
ORDER BY blog_name";
|
|
|
$result = Database::query($sql);
|
|
|
$return_data = '';
|
|
|
- $my_course_info=explode('_',$course_db_name);
|
|
|
if (Database::num_rows($result)!=0) {
|
|
|
while ($row=Database::fetch_array($result)) {
|
|
|
$return_data.= '<div class="clear"></div><br />';
|
|
|
- $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_info[1].' " >'.get_lang('SeeBlog').'</a></div></div>';
|
|
|
+ $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
|
|
|
$return_data.= '<br / >';
|
|
|
//$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
|
|
|
$return_data.= $row['comment'];
|