-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordChange.php
67 lines (61 loc) · 1.93 KB
/
PasswordChange.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
<?php
use WHMCS\Mail\Template as EmailTemplate;
use WHMCS\Module\Addon\PasswordChange\Admin\AdminDispatcher;
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
function PasswordChange_config(): array
{
return [
'name' => 'Password Change for WHMCS',
'description' => 'Admin change passwords for users',
'version' => '2.0',
'author' => 'Md Mahfuz Reham'
];
}
function PasswordChange_activate(): array
{
try {
$changeTemplate = new EmailTemplate;
$changeTemplate->type = 'user';
$changeTemplate->name = 'Password Change for User';
$changeTemplate->subject = 'Your password has been changed';
$changeTemplate->message = /** @lang text */
'<p>Dear Client.</p>
<p>You have requested a password change. Your new password is <b>{$password}</b>.</p>
<p>Please login and update your password as soon as possible.</p>;
{$signature}';
$changeTemplate->save();
return [
'status' => 'success',
'description' => 'PasswordChange has been activated'
];
}catch(Exception $e){
return [
'status' => 'error',
'description' => 'Could not create email template: '.$e->getMessage()
];
}
}
function PasswordChange_deactivate(): array
{
try {
EmailTemplate::where('name', 'Password Change for User')->delete();
return [
'status' => 'success',
'description' => 'PasswordChange has been deactivated'
];
} catch (Exception $e){
return [
'status' => 'error',
'description' => 'Could not delete email template: '.$e->getMessage()
];
}
}
function PasswordChange_output($vars): void
{
$action = $_REQUEST['action'] ?? '';
$dispatcher = new AdminDispatcher();
$response = $dispatcher->dispatch($action, $vars);
echo $response;
}