/
tiki-view_blog_post.php
148 lines (130 loc) · 4.81 KB
/
tiki-view_blog_post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-view_blog_post.php 42038 2012-06-22 19:09:56Z jonnybradley $
$section = 'blogs';
require_once ('tiki-setup.php');
include_once ('lib/blogs/bloglib.php');
$auto_query_args = array(
'postId',
'blogId',
'offset',
'find',
'sort_mode',
'page',
'mode',
'show_comments'
);
$access->check_feature('feature_blogs');
if (empty($_REQUEST["postId"])) {
$smarty->assign('msg', tra('No post indicated'));
$smarty->display('error.tpl');
die;
} else {
$postId = $_REQUEST['postId'];
}
$post_info = $bloglib->get_post($postId);
if (!$post_info) {
$smarty->assign('msg', tra("Post not found"));
$smarty->display("error.tpl");
die;
} else {
$bloglib->add_blog_post_hit($postId);
}
$blogId = $post_info['blogId'];
//Keep track of month of last viewed posts for months_links module foldable display
$_SESSION['blogs_last_viewed_month'] = TikiLib::date_format("%Y-%m", $post_info['created']);
$blog_data = $bloglib->get_blog($blogId);
if (!$blog_data) {
$smarty->assign('msg', tra("Blog not found"));
$smarty->display("error.tpl");
die;
}
$tikilib->get_perm_object($blogId, 'blog');
$access->check_permission('tiki_p_read_blog');
$ownsblog = 'n';
if ($user && $user == $blog_data["user"]) {
$ownsblog = 'y';
}
if ($ownsblog == 'n' && $tiki_p_blog_admin != 'y' && $post_info["priv"] == 'y') {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("You do not have permission to view this blog post while it is marked as private"));
$smarty->display("error.tpl");
die;
}
if ($ownsblog == 'n' && $tiki_p_blog_admin != 'y' && $post_info['created'] > $tikilib->now) {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra('Permission denied'));
$smarty->display("error.tpl");
die;
}
$post_info['adjacent'] = $bloglib->_get_adjacent_posts($blogId, $post_info['created'], $tiki_p_blog_admin == 'y'? null: $tikilib->now, $user);
if (isset($post_info['priv']) && ($post_info['priv'] == 'y')) {
$post_info['title'] .= ' (' . tra("private") . ')';
}
if ($prefs['feature_freetags'] == 'y') {
// Get Tags
include_once ('lib/freetag/freetaglib.php');
$post_info['freetags'] = $freetaglib->get_tags_on_object($postId, "blog post");
if ($blog_data['show_related'] == 'y' && !empty($post_info['freetags'])) {
$post_info['related_posts'] = $bloglib->get_related_posts($postId, $blog_data['related_max']);
}
}
if ($prefs['feature_categories'] == 'y') {
$cat_type = 'blog post';
$cat_objid = $postId;
require_once('categorize_list.php');
}
$smarty->assign('ownsblog', $ownsblog);
if ($post_info['wysiwyg'] !== 'y') {
$post_info['data'] = TikiLib::htmldecode($post_info['data']);
}
$smarty->assign('postId', $postId);
$smarty->assign('blog_data', $blog_data);
$smarty->assign('blogId', $blogId);
$smarty->assign('headtitle', $post_info['title'] . ' : ' . $blog_data['title']);
$smarty->assign('title', $post_info['title'] . ' : ' . $blog_data['title']);
if (!isset($_REQUEST['offset'])) $_REQUEST['offset'] = 0;
if (!isset($_REQUEST['sort_mode'])) $_REQUEST['sort_mode'] = 'created_desc';
if (!isset($_REQUEST['find'])) $_REQUEST['find'] = '';
$smarty->assign('offset', $_REQUEST["offset"]);
$smarty->assign('sort_mode', $_REQUEST["sort_mode"]);
$smarty->assign('find', $_REQUEST["find"]);
$offset = $_REQUEST["offset"];
$sort_mode = $_REQUEST["sort_mode"];
$find = $_REQUEST["find"];
if ($post_info['wysiwyg'] == "y")
$parsed_data = $tikilib->parse_data($post_info["data"], array('is_html' => true));
else
$parsed_data = $tikilib->parse_data($post_info["data"]);
if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
$pages = $bloglib->get_number_of_pages($parsed_data);
$post_info['parsed_data'] = $bloglib->get_page($parsed_data, $_REQUEST['page']);
$post_info['pages'] = $pages;
if ($pages > $_REQUEST['page']) {
$post_info['next_page'] = $_REQUEST['page'] + 1;
} else {
$post_info['next_page'] = $_REQUEST['page'];
}
if ($_REQUEST['page'] > 1) {
$post_info['prev_page'] = $_REQUEST['page'] - 1;
} else {
$post_info['prev_page'] = 1;
}
$post_info['first_page'] = 1;
$post_info['last_page'] = $pages;
$post_info['pagenum'] = $_REQUEST['page'];
$smarty->assign('post_info', $post_info);
$cat_type = 'blog';
$cat_objid = $blogId;
include_once ('tiki-section_options.php');
if ($user && $prefs['feature_notepad'] == 'y' && $tiki_p_notepad == 'y' && isset($_REQUEST['savenotepad'])) {
check_ticket('view-blog-post');
$tikilib->replace_note($user, 0, $post_info['title'] ? $post_info['title'] : $tikilib->date_format("%d/%m/%Y [%H:%M]", $post_info['created']), $post_info['data']);
}
ask_ticket('view-blog-post');
// Display the template
$smarty->assign('mid', 'tiki-view_blog_post.tpl');
$smarty->display("tiki.tpl");