1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace blitze\sitemaker\services\forum; |
11
|
|
|
|
12
|
|
|
use blitze\sitemaker\services\forum\admin; |
13
|
|
|
|
14
|
|
|
class manager |
15
|
|
|
{ |
16
|
|
|
/** @var \phpbb\auth\auth */ |
17
|
|
|
protected $auth; |
18
|
|
|
|
19
|
|
|
/** @var \phpbb\cache\driver\driver_interface */ |
20
|
|
|
protected $cache; |
21
|
|
|
|
22
|
|
|
/** @var \phpbb\config\config */ |
23
|
|
|
protected $config; |
24
|
|
|
|
25
|
|
|
/** @var \phpbb\db\driver\driver_interface */ |
26
|
|
|
protected $db; |
27
|
|
|
|
28
|
|
|
/** @var \acp_forums */ |
29
|
|
|
protected $forum; |
30
|
|
|
|
31
|
|
|
/** @var string */ |
32
|
|
|
protected $phpbb_root_path; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
protected $php_ext; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Constructor |
39
|
|
|
* |
40
|
|
|
* @param \phpbb\auth\auth $auth Auth object |
41
|
|
|
* @param \phpbb\cache\driver\driver_interface $cache Cache driver interface |
42
|
|
|
* @param \phpbb\config\config $config Config object |
43
|
|
|
* @param \phpbb\db\driver\driver_interface $db Database object |
44
|
|
|
* @param \phpbb\language\language $translator Language object |
45
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
46
|
|
|
* @param string $php_ext php file extension |
47
|
|
|
*/ |
48
|
2 |
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\driver\driver_interface $cache, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\language\language $translator, $phpbb_root_path, $php_ext) |
49
|
|
|
{ |
50
|
2 |
|
$this->auth = $auth; |
51
|
2 |
|
$this->cache = $cache; |
52
|
2 |
|
$this->config = $config; |
53
|
2 |
|
$this->db = $db; |
54
|
2 |
|
$this->phpbb_root_path = $phpbb_root_path; |
55
|
2 |
|
$this->php_ext = $php_ext; |
56
|
|
|
|
57
|
2 |
|
if (!class_exists('acp_forums')) |
58
|
2 |
|
{ |
59
|
1 |
|
include($this->phpbb_root_path . 'includes/acp/acp_forums.' . $this->php_ext); |
60
|
1 |
|
} |
61
|
|
|
|
62
|
2 |
|
$translator->add_lang('acp/forums'); |
63
|
2 |
|
} |
64
|
|
|
|
65
|
1 |
|
public function add(array &$forum_data, $forum_perm_from = 0) |
66
|
|
|
{ |
67
|
|
|
$forum_data += array( |
68
|
1 |
|
'parent_id' => $this->config['sitemaker_parent_forum_id'], |
69
|
|
|
); |
70
|
|
|
|
71
|
1 |
|
$errors = admin::save($forum_data); |
72
|
|
|
|
73
|
1 |
|
if (!sizeof($errors)) |
74
|
1 |
|
{ |
75
|
1 |
|
$forum_data['forum_id'] = (int) $forum_data['forum_id']; |
76
|
|
|
|
77
|
|
|
// Copy permissions? |
78
|
1 |
|
if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id']) |
79
|
1 |
|
{ |
80
|
1 |
|
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], false, false); |
81
|
1 |
|
phpbb_cache_moderators($this->db, $this->cache, $this->auth); |
82
|
1 |
|
} |
83
|
|
|
|
84
|
1 |
|
$this->auth->acl_clear_prefetch(); |
85
|
1 |
|
$this->cache->destroy('sql', FORUMS_TABLE); |
86
|
1 |
|
} |
87
|
|
|
|
88
|
1 |
|
return $errors; |
89
|
|
|
} |
90
|
|
|
|
91
|
1 |
|
public function remove($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) |
92
|
|
|
{ |
93
|
1 |
|
admin::remove($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); |
94
|
1 |
|
} |
95
|
|
|
} |
96
|
|
|
|