forked from XoopsModules25x/newbb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.php
139 lines (126 loc) · 6.86 KB
/
print.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
<?php
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000-2016 XOOPS.org //
// <http://xoops.org/> //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J., [email protected]) //
// URL: http://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
/*
* Print contents of a post or a topic
* currently only available for post print
*
* TODO: topic print; print with page splitting
*
*/
include_once __DIR__ . '/header.php';
error_reporting(0);
$xoopsLogger->activated = false;
if (!XoopsRequest::getString('post_data', '', 'POST')) {
$forum = XoopsRequest::getInt('forum', 0, 'GET');
$topic_id = XoopsRequest::getInt('topic_id', 0, 'GET');
$post_id = XoopsRequest::getInt('post_id', 0, 'GET');
if (0 === $post_id && 0 === $topic_id) {
exit(_MD_ERRORTOPIC);
}
if (0 !== $post_id) {
$postHandler = xoops_getModuleHandler('post', 'newbb');
$post = $postHandler->get($post_id);
if (!$approved = $post->getVar('approved')) {
exit(_MD_NORIGHTTOVIEW);
}
$topic_id = $post->getVar('topic_id');
$post_data = $postHandler->getPostForPrint($post);
$isPost = 1;
$post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id;
if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
$post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>');
$post_data['url'] = str_replace('<a href="', '', $post_data['url']);
$post_data['url'] = str_replace('"></a>', '', $post_data['url']);
}
}
$topicHandler = xoops_getModuleHandler('topic', 'newbb');
$topic_obj = $topicHandler->get($topic_id);
$topic_id = $topic_obj->getVar('topic_id');
$forum = $topic_obj->getVar('forum_id');
if (!$approved = $topic_obj->getVar('approved')) {
exit(_MD_NORIGHTTOVIEW);
}
$isadmin = newbb_isAdmin($forum_obj);
if (!$isadmin && $topic_obj->getVar('approved') < 0) {
exit(_MD_NORIGHTTOVIEW);
}
$forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forum = $topic_obj->getVar('forum_id');
$forum_obj = $forumHandler->get($forum);
if (!$forumHandler->getPermission($forum_obj)) {
exit(_MD_NORIGHTTOVIEW);
}
if (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'view')) {
exit(_MD_NORIGHTTOVIEW);
}
// irmtfan add print permission
if (!$topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'print')) {
exit(_MD_NORIGHTTOPRINT);
}
} else {
$post_data = unserialize(base64_decode(XoopsRequest::getString('post_data', '', 'POST')));
$isPost = 1;
}
xoops_header(false);
if (empty($isPost)) {
echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'>
<div style='width: 750px; border: 1px solid #000; padding: 20px;'>
<div style='text-align: center; display: block; margin: 0 0 6px 0;'>
<img src='" . XOOPS_URL . "/modules/newbb/assets/images/xoopsbb_slogo.png' border='0' alt='' />
<br><br> ";
$postsArray = $topicHandler->getAllPosts($topic_obj);
foreach ($postsArray as $post) {
if (!$post->getVar('approved')) {
continue;
}
$post_data = $postHandler->getPostForPrint($post);
echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2>
<div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div>
<div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>
<div>" . $post_data['text'] . "</div>
<div style='padding-top: 12px; border-top: 2px solid #ccc;'></div><br>";
}
echo '<p>' . _MD_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>';
echo '</div></div>';
echo '</body></html>';
} else {
echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'>
<div style='width: 750px; border: 1px solid #000; padding: 20px;'>
<div style='text-align: center; display: block; margin: 0 0 6px 0;'>
<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2></div>
<div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div>
<div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div>
<div>" . $post_data['text'] . "</div>
<div style='padding-top: 12px; border-top: 2px solid #ccc;'></div>
<p>" . _MD_COMEFROM . ' ' . $post_data['url'] . '</p>
</div>
<br><br></body></html>';
}