-
Notifications
You must be signed in to change notification settings - Fork 0
/
maintain.class.php
68 lines (55 loc) · 1.72 KB
/
maintain.class.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
<?php
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
class m365connect_maintain extends PluginMaintain
{
private $default_conf = array(
'display_menubar' => true,
'display_register' => true
);
private $file;
function __construct($plugin_id)
{
parent::__construct($plugin_id);
$this->file = PWG_LOCAL_DIR . 'config/hybridauth.inc.php';
}
function install($plugin_version, &$errors=array())
{
global $conf;
if (empty($conf['m365connect']))
{
conf_update_param('m365connect', $this->default_conf, true);
}
else
{
$conf['m365connect'] = safe_unserialize($conf['m365connect']);
if (!isset($conf['m365connect']['allow_merge_accounts']))
{
conf_update_param('m365connect', $conf['m365connect']);
}
}
// add 'total' and 'enabled' fields in hybridauth conf file
if (file_exists($this->file))
{
$hybridauth_conf = include($this->file);
if (!isset($hybridauth_conf['total']))
{
$enabled = array_filter($hybridauth_conf['providers'], create_function('$p', 'return $p["enabled"];'));
$hybridauth_conf['total'] = count($hybridauth_conf['providers']);
$hybridauth_conf['enabled'] = count($enabled);
$content = "<?php\ndefined('PHPWG_ROOT_PATH') or die('Hacking attempt!');\n\nreturn ";
$content.= var_export($hybridauth_conf, true);
$content.= ";\n?>";
file_put_contents($this->file, $content);
}
}
}
function update($old_version, $new_version, &$errors=array())
{
$this->install($new_version, $errors);
}
function uninstall()
{
conf_delete_param('m365connect');
@unlink($this->file);
}
}