1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Ideas extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\ideas\controller; |
12
|
|
|
|
13
|
|
|
use phpbb\auth\auth; |
14
|
|
|
use phpbb\config\config; |
15
|
|
|
use phpbb\controller\helper; |
16
|
|
|
use phpbb\ideas\factory\ideas; |
17
|
|
|
use phpbb\ideas\factory\linkhelper; |
18
|
|
|
use phpbb\language\language; |
19
|
|
|
use phpbb\pagination; |
20
|
|
|
use phpbb\request\request; |
21
|
|
|
use phpbb\template\template; |
22
|
|
|
use phpbb\user; |
23
|
|
|
|
24
|
|
|
abstract class base |
25
|
|
|
{ |
26
|
|
|
/** @var auth */ |
27
|
|
|
protected $auth; |
28
|
|
|
|
29
|
|
|
/* @var config */ |
30
|
|
|
protected $config; |
31
|
|
|
|
32
|
|
|
/* @var helper */ |
33
|
|
|
protected $helper; |
34
|
|
|
|
35
|
|
|
/* @var ideas */ |
36
|
|
|
protected $ideas; |
37
|
|
|
|
38
|
|
|
/** @var language */ |
39
|
|
|
protected $language; |
40
|
|
|
|
41
|
|
|
/* @var linkhelper */ |
42
|
|
|
protected $link_helper; |
43
|
|
|
|
44
|
|
|
/** @var pagination */ |
45
|
|
|
protected $pagination; |
46
|
|
|
|
47
|
|
|
/* @var request */ |
48
|
|
|
protected $request; |
49
|
|
|
|
50
|
|
|
/* @var template */ |
51
|
|
|
protected $template; |
52
|
|
|
|
53
|
|
|
/* @var user */ |
54
|
|
|
protected $user; |
55
|
|
|
|
56
|
|
|
/** @var string */ |
57
|
|
|
protected $root_path; |
58
|
|
|
|
59
|
|
|
/** @var string */ |
60
|
|
|
protected $php_ext; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param auth $auth |
64
|
|
|
* @param config $config |
65
|
|
|
* @param helper $helper |
66
|
|
|
* @param ideas $ideas |
67
|
|
|
* @param language $language |
68
|
|
|
* @param linkhelper $link_helper |
69
|
|
|
* @param pagination $pagination |
70
|
|
|
* @param request $request |
71
|
|
|
* @param template $template |
72
|
|
|
* @param user $user |
73
|
|
|
* @param string $root_path |
74
|
|
|
* @param string $php_ext |
75
|
|
|
*/ |
76
|
|
|
public function __construct(auth $auth, config $config, helper $helper, ideas $ideas, language $language, linkhelper $link_helper, pagination $pagination, request $request, template $template, user $user, $root_path, $php_ext) |
77
|
|
|
{ |
78
|
|
|
$this->auth = $auth; |
79
|
|
|
$this->config = $config; |
80
|
|
|
$this->helper = $helper; |
81
|
|
|
$this->ideas = $ideas; |
82
|
|
|
$this->language = $language; |
83
|
|
|
$this->link_helper = $link_helper; |
84
|
|
|
$this->pagination = $pagination; |
85
|
|
|
$this->request = $request; |
86
|
|
|
$this->template = $template; |
87
|
|
|
$this->user = $user; |
88
|
|
|
$this->root_path = $root_path; |
89
|
|
|
$this->php_ext = $php_ext; |
90
|
|
|
|
91
|
|
|
$this->language->add_lang('common', 'phpbb/ideas'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Check if Ideas is properly configured after installation |
96
|
|
|
* Ideas is available only after forum settings have been set in ACP |
97
|
|
|
* |
98
|
|
|
* @return bool Depending on whether or not the extension is properly configured |
99
|
|
|
*/ |
100
|
|
|
public function is_available() |
101
|
|
|
{ |
102
|
|
|
return (bool) $this->config['ideas_forum_id']; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Assign idea lists template variables |
107
|
|
|
* |
108
|
|
|
* @param string $block The template block var name |
109
|
|
|
* @param array $rows The Idea row data |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
protected function assign_template_block_vars($block, $rows) |
114
|
|
|
{ |
115
|
|
|
foreach ($rows as $row) |
116
|
|
|
{ |
117
|
|
|
$this->template->assign_block_vars($block, array( |
118
|
|
|
'ID' => $row['idea_id'], |
119
|
|
|
'LINK' => $this->link_helper->get_idea_link($row['idea_id']), |
120
|
|
|
'TITLE' => $row['idea_title'], |
121
|
|
|
'AUTHOR' => $this->link_helper->get_user_link($row['idea_author']), |
122
|
|
|
'DATE' => $this->user->format_date($row['idea_date']), |
123
|
|
|
'READ' => $row['read'], |
124
|
|
|
'VOTES_UP' => $row['idea_votes_up'], |
125
|
|
|
'VOTES_DOWN' => $row['idea_votes_down'], |
126
|
|
|
'USER_VOTED' => $row['u_voted'], |
127
|
|
|
'POINTS' => $row['idea_votes_up'] - $row['idea_votes_down'], |
128
|
|
|
'STATUS' => $row['idea_status'], // for status icons (not currently implemented) |
129
|
|
|
'LOCKED' => $row['topic_status'] == ITEM_LOCKED, |
130
|
|
|
'U_UNAPPROVED_IDEA' => (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $this->auth->acl_get('m_approve', $this->config['ideas_forum_id'])) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&mode=approve_details&t=' . $row['topic_id'], true, $this->user->session_id) : '', |
131
|
|
|
)); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Assign common template variables for Ideas pages |
137
|
|
|
* |
138
|
|
|
* @return void |
139
|
|
|
*/ |
140
|
|
|
protected function display_common_vars() |
141
|
|
|
{ |
142
|
|
|
$this->template->assign_vars([ |
143
|
|
|
'S_DISPLAY_SEARCHBOX' => (bool) $this->auth->acl_get('u_search') && $this->auth->acl_get('f_search', $this->config['ideas_forum_id']) && $this->config['load_search'], |
144
|
|
|
'S_SEARCHBOX_ACTION' => append_sid("{$this->root_path}search.{$this->php_ext}"), |
145
|
|
|
'S_SEARCH_IDEAS_HIDDEN_FIELDS' => build_hidden_fields(['fid' => [$this->config['ideas_forum_id']]]), |
146
|
|
|
|
147
|
|
|
'U_SEARCH_MY_IDEAS' => $this->helper->route('phpbb_ideas_list_controller', ['sort' => ideas::SORT_MYIDEAS, 'status' => '-1']), |
148
|
|
|
]); |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|