-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathext.php
83 lines (71 loc) · 1.86 KB
/
ext.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
<?php
/**
*
* @package Privacy Policy Extension
* @copyright (c) 2018 david63
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace david63\privacypolicy;
use phpbb\extension\base;
class ext extends base
{
const PRIVACY_POLICY_VERSION = '2.1.0 RC7';
/**
* Enable extension if phpBB version requirement is met
*
* @var string Require 3.2.0-a1 due to updated 3.2 syntax
*
* @return bool
* @access public
*/
public function is_enableable()
{
// Set globals for use in the language file
global $ver_error, $cookie_error;
// Requires phpBB 3.2.2 or newer.
$ver = phpbb_version_compare(PHPBB_VERSION, '3.2.2', '>=');
// Display a custom warning message if this requirement fails.
$ver_error = ($ver) ? false : true;
// Is Cookie Policy installed?
$config = $this->container->get('config');
$cookie_policy = !isset($config['cookie_policy_enabled']);
// Display a custom warning message if this exists.
$cookie_error = ($cookie_policy) ? false : true;
// Need to cater for 3.1 and 3.2
if (phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>='))
{
$this->container->get('language')->add_lang('ext_enable_error', 'david63/privacypolicy');
}
else
{
$this->container->get('user')->add_lang_ext('david63/privacypolicy', 'ext_enable_error');
}
return $ver && $cookie_policy;
}
/**
* This method is required for Auto Groups
*/
public function purge_step($old_state)
{
switch ($old_state)
{
case '':
try
{
// Try to remove this extension from auto groups db tables
$autogroups = $this->container->get('phpbb.autogroups.manager');
$autogroups->purge_autogroups_type('david63.privacypolicy.autogroups.type.ppaccept');
}
catch (\InvalidArgumentException $e)
{
// Continue
}
return 'autogroups';
break;
default:
return parent::purge_step($old_state);
break;
}
}
}