1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\AddOn\PHPBB; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Create a interface for PHPBB. |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
class CInterface |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Sample function to integrate with a phpbb installation and lend some |
14
|
|
|
* information on the authorized user. |
15
|
|
|
* |
16
|
|
|
* @param string $path is the install path of PHPBB. |
17
|
|
|
* @return array with details of user. |
18
|
|
|
*/ |
19
|
|
|
public function getSessionDetails($path) |
20
|
|
|
{ |
21
|
|
|
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $auth; |
22
|
|
|
|
23
|
|
|
// Enable to work even if forum is not available |
24
|
|
|
if (!is_file("$path/webb.config")) { |
25
|
|
|
return [ |
26
|
|
|
'is_anonymous' => "No one", |
27
|
|
|
'user_acronym' => "NoOne", |
28
|
|
|
'user_email' => "[email protected]", |
29
|
|
|
'session_id' => null, |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
define('IN_PHPBB', true); |
34
|
|
|
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $path; |
35
|
|
|
$phpEx = "php"; //substr(strrchr(__FILE__, '.'), 1); |
36
|
|
|
include("$path/common.php"); |
37
|
|
|
|
38
|
|
|
// Start session management |
39
|
|
|
$user->session_begin(); |
40
|
|
|
$auth->acl($user->data); |
41
|
|
|
$user->setup(); |
42
|
|
|
|
43
|
|
|
return [ |
44
|
|
|
'is_anonymous' => ($user->data['user_id'] == ANONYMOUS), |
45
|
|
|
'user_acronym' => $user->data['username_clean'], |
46
|
|
|
'user_email' => $user->data['user_email'], |
47
|
|
|
'session_id' => $user->data['session_id'], |
48
|
|
|
]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get latest topics. |
55
|
|
|
* |
56
|
|
|
* @param int $max items to return. |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
/* |
60
|
|
|
public function LatestTopics($max=3) { |
61
|
|
|
global $auth, $db; |
62
|
|
|
|
63
|
|
|
// Create arrays |
64
|
|
|
$topics = array(); |
65
|
|
|
|
66
|
|
|
// Get forums that current user has read rights to. |
67
|
|
|
$forums = array_unique(array_keys($auth->acl_getf('f_read', true))); |
68
|
|
|
|
69
|
|
|
// Get active topics. |
70
|
|
|
$sql="SELECT * |
71
|
|
|
FROM " . TOPICS_TABLE . " |
72
|
|
|
WHERE topic_approved = '1' AND " . $db->sql_in_set('forum_id', $forums) . " |
73
|
|
|
ORDER BY topic_last_post_time DESC"; |
74
|
|
|
$result = $db->sql_query_limit($sql, $max); |
75
|
|
|
while ($r = $db->sql_fetchrow($result)) { |
76
|
|
|
$topics[] = $r; |
77
|
|
|
} |
78
|
|
|
$db->sql_freeresult($result); |
79
|
|
|
|
80
|
|
|
$items = array(); |
81
|
|
|
foreach($topics as $t) { |
82
|
|
|
// Get folder img, topic status/type related information |
83
|
|
|
//$topic_tracking_info = get_complete_topic_tracking($t['forum_id'], $t['topic_id']); |
84
|
|
|
//$unread_topic = (isset($topic_tracking_info[$t['topic_id']]) && $t['topic_last_post_time'] > $topic_tracking_info[$t['topic_id']]) |
85
|
|
|
? true |
86
|
|
|
: false; |
87
|
|
|
//topic_status($t, $t['topic_replies'], $unread_topic, $folder_img, $folder_alt, $topic_type); |
88
|
|
|
// href = $phpbb_root_path |
89
|
|
|
. 'viewtopic.php?f=' |
90
|
|
|
. $t['forum_id'] |
91
|
|
|
. '&t=' |
92
|
|
|
. $t['topic_id'] |
93
|
|
|
. '&p=' |
94
|
|
|
. $t['topic_last_post_id'] |
95
|
|
|
. '#p' |
96
|
|
|
. $t['topic_last_post_id']; |
97
|
|
|
$item['forum_id'] = $t['forum_id']; |
98
|
|
|
$item['topic_id'] = $t['topic_id']; |
99
|
|
|
$item['topic_last_post_id'] = $t['topic_last_post_id']; |
100
|
|
|
$item['topic_title'] = $t['topic_title']; |
101
|
|
|
$items[] = $item; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return($items); |
105
|
|
|
} |
106
|
|
|
*/ |
107
|
|
|
} |
108
|
|
|
|