forked from thoinv/forums
/
Abstract.php
180 lines (150 loc) · 4.9 KB
/
Abstract.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
/**
* @package Nobita Social Groups Nulled by HQCoder
* @author Nobita
* @nuller Congngheaz
* @link http://www.congngheaz.com/forums/Xenforo-addon-nulled-free/
* @copyright (c) 2015 AZ Technologies, Inc. All rights reserved!
*/
/*====================================================================*\
|| ################################################################## ||
|| # Copyright 2015 AZ Technologies, Inc. # ||
|| # All Rights Reserved. # ||
|| ################################################################## ||
\*====================================================================*/
class Nobita_Teams_ControllerPublic_Abstract extends XenForo_ControllerPublic_Abstract
{
protected function _preDispatch($action)
{
if (XenForo_Application::isRegistered('addOns'))
{
$addOns = XenForo_Application::get('addOns');
if (!empty($addOns['nobita_Teams']) && $addOns['nobita_Teams'] < 172)
{
$response = $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
throw $this->responseException($response, 503);
}
}
if (!$this->_getTeamModel()->canViewTeams($error))
{
throw $this->getErrorOrNoPermissionResponseException($error);
}
}
protected function _postDispatch($controllerResponse, $controllerName, $action)
{
if (isset($controllerResponse->params['category']))
{
$controllerResponse->containerParams['teamCategory'] = $controllerResponse->params['category'];
}
if (isset($controllerResponse->params['team']))
{
$controllerResponse->containerParams['team'] = $controllerResponse->params['team'];
}
}
public function _getTeamViewWrapper($selectedTab, array $team, array $category,
XenForo_ControllerResponse_View $subView)
{
return $this->_getTeamHelper()->getTeamViewWrapper($selectedTab, $team, $category, $subView);
}
public function getPostSpecificRedirect(array $post, array $team,
$redirectType = XenForo_ControllerResponse_Redirect::SUCCESS, array $redirectParams = array()
)
{
if ($post['last_comment_date'] < XenForo_Application::$time)
{
$postModel = $this->_getPostModel();
$setup = Nobita_Teams_Setup::getInstance();
$requester = $setup->getTeamFromVisitor($team['team_id']);
$conditions = $postModel->getPermissionBasedPostConditions($team, $requester) + array(
'last_comment_date' => array('>', $post['last_comment_date'])
);
$count = $postModel->countPostsForTeamId($team['team_id'], $conditions);
$page = floor($count / XenForo_Application::get('options')->messagesPerPage) + 1;
}
else
{
$page = 1;
}
$extraParams = array(
'page' => $page,
'wtype' => $post['discussion_type']
);
return $this->responseRedirect(
$redirectType,
XenForo_Link::buildPublicLink(
TEAM_ROUTE_ACTION, $team, $extraParams
) . '#post-' . $post['post_id'],
null,
$redirectParams
);
}
protected function _getTeamListFetchOptions()
{
$fetchOptions = array();
$fetchOptions['join'] = Nobita_Teams_Model_Team::FETCH_PROFILE
| Nobita_Teams_Model_Team::FETCH_PRIVACY
| Nobita_Teams_Model_Team::FETCH_CATEGORY
| Nobita_Teams_Model_Team::FETCH_USER
| Nobita_Teams_Model_Team::FETCH_FEATURED;
$visitor = XenForo_Visitor::getInstance();
$fetchOptions['banUserId'] = $visitor['user_id'];
$fetchOptions['memberUserId'] = $visitor['user_id'];
return $fetchOptions;
}
protected function _getTeamHelper()
{
return $this->getHelper('Nobita_Teams_ControllerHelper_Team');
}
protected function _getTeamModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Team');
}
protected function _getBanningModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Banning');
}
protected function _getCategoryModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Category');
}
protected function _getCategoryWatchModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_CategoryWatch');
}
protected function _getFieldModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Field');
}
protected function _getAvatarModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Avatar');
}
protected function _getCoverModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Cover');
}
protected function _getMemberModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Member');
}
protected function _getMemberGroupModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_MemberGroup');
}
protected function _getPostModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Post');
}
protected function _getCommentModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Comment');
}
protected function _getEventModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Event');
}
protected function _getInviteModel()
{
return $this->getModelFromCache('Nobita_Teams_Model_Invite');
}
}