-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupd.nameguard.php
More file actions
94 lines (82 loc) · 2.51 KB
/
upd.nameguard.php
File metadata and controls
94 lines (82 loc) · 2.51 KB
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
84
85
86
87
88
89
90
91
92
93
94
<?php
class Nameguard_upd
{
public $version = '1.1.1';
/**
* Install the add-on
*
* @return bool
*/
public function install()
{
// Register the module for installation tracking
ee()->db->insert('modules', [
'module_name' => 'Nameguard',
'module_version' => $this->version,
'has_cp_backend' => 'n',
'has_publish_fields' => 'n'
]);
// Register the extension hook for registration errors
ee()->db->insert('extensions', [
'class' => 'Nameguard_ext',
'method' => 'validate_screen_name',
'hook' => 'member_member_register_errors',
'settings' => '',
'priority' => 5,
'version' => $this->version,
'enabled' => 'y'
]);
// Also hook into registration start for diagnostic confirmation
ee()->db->insert('extensions', [
'class' => 'Nameguard_ext',
'method' => 'on_register_start',
'hook' => 'member_member_register_start',
'settings' => '',
'priority' => 5,
'version' => $this->version,
'enabled' => 'y'
]);
return true;
}
/**
* Uninstall the add-on
*
* @return bool
*/
public function uninstall()
{
// Remove the module
ee()->db->where('module_name', 'Nameguard')->delete('modules');
// Remove all extension hooks
ee()->db->where('class', 'Nameguard_ext')->delete('extensions');
return true;
}
/**
* Update the add-on
*
* @param string $current Current version
* @return bool
*/
public function update($current = '')
{
if (version_compare($current, $this->version, '==')) {
return false;
}
// If upgrading from 1.0.x, register the new diagnostic hook
if (version_compare($current, '1.1.0', '<')) {
ee()->db->insert('extensions', [
'class' => 'Nameguard_ext',
'method' => 'on_register_start',
'hook' => 'member_member_register_start',
'settings' => '',
'priority' => 5,
'version' => $this->version,
'enabled' => 'y'
]);
}
// Update all extension hooks to the current version
ee()->db->where('class', 'Nameguard_ext')
->update('extensions', ['version' => $this->version]);
return true;
}
}