Improve queries, format code, use png icons.

pull/2487/head
jmontoyaa 8 years ago
parent 5916f1a1da
commit 9d54b9ffa6
  1. 35
      main/inc/lib/blog.lib.php

@ -2850,27 +2850,34 @@ class Blog
$visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible'; $visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible';
$visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible'; $visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible';
$my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">';
$my_image .= Display::return_icon('edit.png', get_lang('EditBlog'));
$my_image = '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">';
$my_image .= Display::return_icon($visibility_icon.'.png', get_lang($visibility_info));
$my_image .= "</a>"; $my_image .= "</a>";
$my_image .= '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">';
$my_image .= Display::return_icon('edit.png', get_lang('EditBlog'));
$my_image .= "</a>";
$my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" '; $my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" ';
$my_image .= 'onclick="javascript:if(!confirm(\''.addslashes( $my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(
api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset) api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)
).'\')) return false;" >'; ).'\')) return false;" >';
$my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog')); $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog'));
$my_image .= "</a>"; $my_image .= "</a>";
$my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">';
$my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info));
$my_image .= "</a>";
$list_body_blog[] = $my_image; $list_body_blog[] = $my_image;
$list_content_blog[] = $list_body_blog; $list_content_blog[] = $list_body_blog;
$list_body_blog = array(); $list_body_blog = array();
} }
$table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project'); $table = new SortableTableFromArrayConfig(
$list_content_blog,
1,
20,
'project'
);
$table->set_header(0, get_lang('Title')); $table->set_header(0, get_lang('Title'));
$table->set_header(1, get_lang('SubTitle')); $table->set_header(1, get_lang('SubTitle'));
$table->set_header(2, get_lang('Modify')); $table->set_header(2, get_lang('Modify'));
@ -2991,12 +2998,13 @@ class Blog
$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
FROM $tbl_blogs blog FROM $tbl_blogs blog
INNER JOIN $tbl_blog_post post INNER JOIN $tbl_blog_post post
ON (blog.blog_id = post.blog_id) ON (blog.blog_id = post.blog_id AND blog.c_id = post.c_id)
WHERE WHERE
blog.c_id = $courseId AND blog.c_id = $courseId AND
post.c_id = $courseId AND post.c_id = $courseId AND
author_id = $userId AND visibility = 1 author_id = $userId AND
visibility = 1
ORDER BY post.date_creation DESC "; ORDER BY post.date_creation DESC ";
$result = Database::query($sql); $result = Database::query($sql);
$return_data = ''; $return_data = '';
@ -3035,11 +3043,12 @@ class Blog
$courseId = intval($courseId); $courseId = intval($courseId);
$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment FROM $tbl_blogs blog
ON (blog.blog_id = comment.blog_id) INNER JOIN $tbl_blog_comment comment
ON (blog.blog_id = comment.blog_id AND blog.c_id = comment.c_id)
WHERE blog.c_id = $courseId AND WHERE blog.c_id = $courseId AND
comment.c_id = $courseId AND comment.c_id = $courseId AND
author_id = $userId AND author_id = $userId AND
visibility = 1 visibility = 1
ORDER BY blog_name"; ORDER BY blog_name";
$result = Database::query($sql); $result = Database::query($sql);

Loading…
Cancel
Save