|
19 | 19 | * enable_step(), disable_step() and purge_step(). As it is, these methods are defined |
20 | 20 | * in phpbb_extension_base, which this class extends, but you can overwrite them to |
21 | 21 | * give special instructions for those cases. Board Rules must do this because it uses |
22 | | -* the notifications system, which requires the methods enable_notifications(), |
| 22 | +* the notifications' system, which requires the methods enable_notifications(), |
23 | 23 | * disable_notifications() and purge_notifications() be run to properly manage the |
24 | 24 | * notifications created by Board Rules when enabling, disabling or deleting this |
25 | 25 | * extension. |
26 | 26 | */ |
27 | 27 | class ext extends \phpbb\extension\base |
28 | 28 | { |
29 | 29 | /** |
30 | | - * Check whether or not the extension can be enabled. |
| 30 | + * Check whether the extension can be enabled. |
31 | 31 | * The current phpBB version should meet or exceed |
32 | 32 | * the minimum version required by this extension: |
33 | 33 | * |
34 | | - * Requires phpBB 3.2.0 due to new faq controller route for bbcodes, |
35 | | - * the revised notifications system, font awesome and the text reparser. |
| 34 | + * Requires phpBB 3.3.2 due to using role_exists check in permission migration. |
36 | 35 | * |
37 | 36 | * @return bool |
38 | 37 | * @access public |
39 | 38 | */ |
40 | 39 | public function is_enableable() |
41 | 40 | { |
42 | | - return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>='); |
| 41 | + return phpbb_version_compare(PHPBB_VERSION, '3.3.2', '>='); |
43 | 42 | } |
44 | 43 |
|
45 | 44 | /** |
46 | 45 | * Overwrite enable_step to enable board rules notifications |
47 | 46 | * before any included migrations are installed. |
48 | 47 | * |
49 | 48 | * @param mixed $old_state State returned by previous call of this method |
50 | | - * @return mixed Returns false after last step, otherwise temporary state |
| 49 | + * @return bool|string Returns false after last step, otherwise temporary state |
51 | 50 | * @access public |
52 | 51 | */ |
53 | 52 | public function enable_step($old_state) |
54 | 53 | { |
55 | | - switch ($old_state) |
| 54 | + // if nothing has run yet |
| 55 | + if ($old_state === false) |
56 | 56 | { |
57 | | - case '': // Empty means nothing has run yet |
58 | | - |
59 | | - // Enable board rules notifications |
60 | | - $phpbb_notifications = $this->container->get('notification_manager'); |
61 | | - $phpbb_notifications->enable_notifications('phpbb.boardrules.notification.type.boardrules'); |
62 | | - return 'notifications'; |
63 | | - |
64 | | - break; |
65 | | - |
66 | | - default: |
67 | | - |
68 | | - // Run parent enable step method |
69 | | - return parent::enable_step($old_state); |
70 | | - |
71 | | - break; |
| 57 | + // Enable board rules notifications |
| 58 | + $phpbb_notifications = $this->container->get('notification_manager'); |
| 59 | + $phpbb_notifications->enable_notifications('phpbb.boardrules.notification.type.boardrules'); |
| 60 | + return 'notifications'; |
72 | 61 | } |
| 62 | + |
| 63 | + // Run parent enable step method |
| 64 | + return parent::enable_step($old_state); |
73 | 65 | } |
74 | 66 |
|
75 | 67 | /** |
76 | 68 | * Overwrite disable_step to disable board rules notifications |
77 | 69 | * before the extension is disabled. |
78 | 70 | * |
79 | 71 | * @param mixed $old_state State returned by previous call of this method |
80 | | - * @return mixed Returns false after last step, otherwise temporary state |
| 72 | + * @return bool|string Returns false after last step, otherwise temporary state |
81 | 73 | * @access public |
82 | 74 | */ |
83 | 75 | public function disable_step($old_state) |
84 | 76 | { |
85 | | - switch ($old_state) |
| 77 | + // if nothing has run yet |
| 78 | + if ($old_state === false) |
86 | 79 | { |
87 | | - case '': // Empty means nothing has run yet |
88 | | - |
89 | | - // Disable board rules notifications |
90 | | - $phpbb_notifications = $this->container->get('notification_manager'); |
91 | | - $phpbb_notifications->disable_notifications('phpbb.boardrules.notification.type.boardrules'); |
92 | | - return 'notifications'; |
93 | | - |
94 | | - break; |
95 | | - |
96 | | - default: |
97 | | - |
98 | | - // Run parent disable step method |
99 | | - return parent::disable_step($old_state); |
100 | | - |
101 | | - break; |
| 80 | + // Disable board rules notifications |
| 81 | + $phpbb_notifications = $this->container->get('notification_manager'); |
| 82 | + $phpbb_notifications->disable_notifications('phpbb.boardrules.notification.type.boardrules'); |
| 83 | + return 'notifications'; |
102 | 84 | } |
| 85 | + |
| 86 | + // Run parent disable step method |
| 87 | + return parent::disable_step($old_state); |
103 | 88 | } |
104 | 89 |
|
105 | 90 | /** |
106 | 91 | * Overwrite purge_step to purge board rules notifications before |
107 | 92 | * any included and installed migrations are reverted. |
108 | 93 | * |
109 | 94 | * @param mixed $old_state State returned by previous call of this method |
110 | | - * @return mixed Returns false after last step, otherwise temporary state |
| 95 | + * @return bool|string Returns false after last step, otherwise temporary state |
111 | 96 | * @access public |
112 | 97 | */ |
113 | 98 | public function purge_step($old_state) |
114 | 99 | { |
115 | | - switch ($old_state) |
| 100 | + // if nothing has run yet |
| 101 | + if ($old_state === false) |
116 | 102 | { |
117 | | - case '': // Empty means nothing has run yet |
118 | | - |
119 | | - // Purge board rules notifications |
120 | | - $phpbb_notifications = $this->container->get('notification_manager'); |
121 | | - $phpbb_notifications->purge_notifications('phpbb.boardrules.notification.type.boardrules'); |
122 | | - return 'notifications'; |
123 | | - |
124 | | - break; |
125 | | - |
126 | | - default: |
127 | | - |
128 | | - // Run parent purge step method |
129 | | - return parent::purge_step($old_state); |
130 | | - |
131 | | - break; |
| 103 | + // Purge board rules notifications |
| 104 | + $phpbb_notifications = $this->container->get('notification_manager'); |
| 105 | + $phpbb_notifications->purge_notifications('phpbb.boardrules.notification.type.boardrules'); |
| 106 | + return 'notifications'; |
132 | 107 | } |
| 108 | + |
| 109 | + // Run parent purge step method |
| 110 | + return parent::purge_step($old_state); |
133 | 111 | } |
134 | 112 | } |
0 commit comments