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\migrations\v20x; |
11
|
|
|
|
12
|
|
|
use blitze\sitemaker\services\forum\admin; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Initial schema changes needed for Extension installation |
16
|
|
|
*/ |
17
|
|
|
class m2_initial_data extends \phpbb\db\migration\migration |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @inheritdoc |
21
|
|
|
*/ |
22
|
|
|
public static function depends_on() |
23
|
|
|
{ |
24
|
|
|
return array( |
25
|
|
|
'\blitze\sitemaker\migrations\converter\c2_update_data', |
26
|
|
|
'\blitze\sitemaker\migrations\v20x\m1_initial_schema', |
27
|
|
|
); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritdoc |
32
|
|
|
*/ |
33
|
|
|
public function update_data() |
34
|
|
|
{ |
35
|
|
|
return array( |
36
|
|
|
array('custom', array(array($this, 'create_forum_cat'))), |
37
|
|
|
|
38
|
|
|
array('config.add', array('sitemaker_last_changed', 0)), |
39
|
|
|
array('config.add', array('sitemaker_default_layout', '')), |
40
|
|
|
array('config.add', array('sitemaker_parent_forum_id', 0)), |
41
|
|
|
array('config.add', array('sitemaker_blocks_cleanup_gc', 604800)), |
42
|
|
|
array('config.add', array('sitemaker_blocks_cleanup_last_gc', 0, 1)), |
43
|
|
|
array('config.add', array('sitemaker_startpage_controller', '')), |
44
|
|
|
array('config.add', array('sitemaker_startpage_method', '')), |
45
|
|
|
array('config.add', array('sitemaker_startpage_params', '')), |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @inheritdoc |
51
|
|
|
*/ |
52
|
|
|
public function revert_data() |
53
|
|
|
{ |
54
|
|
|
return array( |
55
|
|
|
array('config.remove', array('sitemaker_last_changed')), |
56
|
|
|
array('config.remove', array('sitemaker_default_layout')), |
57
|
|
|
array('config.remove', array('sitemaker_parent_forum_id')), |
58
|
|
|
array('config.remove', array('sitemaker_blocks_cleanup_gc')), |
59
|
|
|
array('config.remove', array('sitemaker_blocks_cleanup_last_gc')), |
60
|
|
|
array('config.remove', array('sitemaker_startpage_controller')), |
61
|
|
|
array('config.remove', array('sitemaker_startpage_method')), |
62
|
|
|
array('config.remove', array('sitemaker_startpage_params')), |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function create_forum_cat() |
67
|
|
|
{ |
68
|
|
|
if (!class_exists('acp_forums')) |
69
|
|
|
{ |
70
|
|
|
include($this->phpbb_root_path . 'includes/acp/acp_forums.' . $this->php_ext); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$forum_data = array( |
74
|
|
|
'forum_type' => FORUM_CAT, |
75
|
|
|
'forum_name' => 'phpBB Sitemaker Extensions', |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
if (!empty($this->config['sitemaker_parent_forum_id'])) |
79
|
|
|
{ |
80
|
|
|
$forum_data['forum_id'] = (int) $this->config['sitemaker_parent_forum_id']; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$errors = admin::save($forum_data); |
84
|
|
|
|
85
|
|
|
if (!sizeof($errors)) |
86
|
|
|
{ |
87
|
|
|
$this->config->set('sitemaker_parent_forum_id', $forum_data['forum_id']); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|