|
1
|
|
|
<?php |
|
2
|
|
|
// |
|
3
|
|
|
// ------------------------------------------------------------------------ // |
|
4
|
|
|
// XOOPS - PHP Content Management System // |
|
5
|
|
|
// Copyright (c) 2000-2020 XOOPS.org // |
|
6
|
|
|
// <https://xoops.org> // |
|
7
|
|
|
// ------------------------------------------------------------------------ // |
|
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
11
|
|
|
// (at your option) any later version. // |
|
12
|
|
|
// // |
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
14
|
|
|
// of supporting developers from this source code or any supporting // |
|
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
16
|
|
|
// original comment or credit authors. // |
|
17
|
|
|
// // |
|
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
21
|
|
|
// GNU General Public License for more details. // |
|
22
|
|
|
// // |
|
23
|
|
|
// You should have received a copy of the GNU General Public License // |
|
24
|
|
|
// along with this program; if not, write to the Free Software // |
|
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
26
|
|
|
// ------------------------------------------------------------------------ // |
|
27
|
|
|
// Author: phppp (D.J., [email protected]) // |
|
28
|
|
|
// URL: https://xoops.org // |
|
29
|
|
|
// Project: Article Project // |
|
30
|
|
|
// ------------------------------------------------------------------------ // |
|
31
|
|
|
|
|
32
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.php'); |
|
33
|
|
|
if (!defined('NEWBB_NOTIFY_ITEMINFO')) { |
|
34
|
|
|
define('NEWBB_NOTIFY_ITEMINFO', 1); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param $category |
|
38
|
|
|
* @param $item_id |
|
39
|
|
|
* @return mixed |
|
40
|
|
|
*/ |
|
41
|
|
|
function newbb_notify_iteminfo($category, $item_id) |
|
42
|
|
|
{ |
|
43
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
44
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
45
|
|
|
$module = $moduleHandler->getByDirname('newbb'); |
|
46
|
|
|
|
|
47
|
|
|
if ('global' === $category) { |
|
48
|
|
|
$item['name'] = ''; |
|
|
|
|
|
|
49
|
|
|
$item['url'] = ''; |
|
50
|
|
|
|
|
51
|
|
|
return $item; |
|
52
|
|
|
} |
|
53
|
|
|
$item_id = (int)$item_id; |
|
54
|
|
|
|
|
55
|
|
|
if ('forum' === $category) { |
|
56
|
|
|
// Assume we have a valid forum id |
|
57
|
|
|
$sql = 'SELECT forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' WHERE forum_id = ' . $item_id; |
|
58
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
59
|
|
|
// irmtfan full URL |
|
60
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERRORFORUM); |
|
61
|
|
|
} |
|
62
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
|
63
|
|
|
$item['name'] = $result_array['forum_name']; |
|
64
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewforum.php?forum=' . $item_id; |
|
65
|
|
|
|
|
66
|
|
|
return $item; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if ('thread' === $category) { |
|
70
|
|
|
// Assume we have a valid topid id |
|
71
|
|
|
$sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' t, ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' f WHERE t.forum_id = f.forum_id AND t.topic_id = ' . $item_id . ' LIMIT 1'; |
|
72
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
73
|
|
|
// irmtfan full URL |
|
74
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED); |
|
75
|
|
|
} |
|
76
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
|
77
|
|
|
$item['name'] = $result_array['topic_title']; |
|
78
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum=' . $result_array['forum_id'] . '&topic_id=' . $item_id; |
|
79
|
|
|
|
|
80
|
|
|
return $item; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
if ('post' === $category) { |
|
84
|
|
|
// Assume we have a valid post id |
|
85
|
|
|
$sql = 'SELECT subject,topic_id,forum_id FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $item_id . ' LIMIT 1'; |
|
86
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
87
|
|
|
// irmtfan full URL |
|
88
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED); |
|
89
|
|
|
} |
|
90
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
|
91
|
|
|
$item['name'] = $result_array['subject']; |
|
92
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum= ' . $result_array['forum_id'] . '&topic_id=' . $result_array['topic_id'] . '#forumpost' . $item_id; |
|
93
|
|
|
|
|
94
|
|
|
return $item; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|