|
11 | 11 | */ |
12 | 12 | class Plugin |
13 | 13 | { |
14 | | - public static $name = 'DirectAdmin VPS Addon'; |
15 | | - public static $description = 'Allows selling of DirectAdmin Licenses as a VPS Addon. DirectAdmin is a graphical web-based web hosting control panel designed to make administration of websites easier. DirectAdmin is often called DA for short. More info at https://www.directadmin.com/'; |
16 | | - public static $help = ''; |
17 | | - public static $module = 'vps'; |
18 | | - public static $type = 'addon'; |
| 14 | + public static $name = 'DirectAdmin VPS Addon'; |
| 15 | + public static $description = 'Allows selling of DirectAdmin Licenses as a VPS Addon. DirectAdmin is a graphical web-based web hosting control panel designed to make administration of websites easier. DirectAdmin is often called DA for short. More info at https://www.directadmin.com/'; |
| 16 | + public static $help = ''; |
| 17 | + public static $module = 'vps'; |
| 18 | + public static $type = 'addon'; |
19 | 19 |
|
20 | | - /** |
21 | | - * Plugin constructor. |
22 | | - */ |
23 | | - public function __construct() |
24 | | - { |
25 | | - } |
| 20 | + /** |
| 21 | + * Plugin constructor. |
| 22 | + */ |
| 23 | + public function __construct() |
| 24 | + { |
| 25 | + } |
26 | 26 |
|
27 | | - /** |
28 | | - * @return array |
29 | | - */ |
30 | | - public static function getHooks() |
31 | | - { |
32 | | - return [ |
33 | | - 'function.requirements' => [__CLASS__, 'getRequirements'], |
34 | | - self::$module.'.load_addons' => [__CLASS__, 'getAddon'], |
35 | | - self::$module.'.settings' => [__CLASS__, 'getSettings'] |
36 | | - ]; |
37 | | - } |
| 27 | + /** |
| 28 | + * @return array |
| 29 | + */ |
| 30 | + public static function getHooks() |
| 31 | + { |
| 32 | + return [ |
| 33 | + 'function.requirements' => [__CLASS__, 'getRequirements'], |
| 34 | + self::$module.'.load_addons' => [__CLASS__, 'getAddon'], |
| 35 | + self::$module.'.settings' => [__CLASS__, 'getSettings'] |
| 36 | + ]; |
| 37 | + } |
38 | 38 |
|
39 | | - /** |
40 | | - * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
41 | | - */ |
42 | | - public static function getRequirements(GenericEvent $event) |
43 | | - { |
44 | | - /** |
45 | | - * @var \MyAdmin\Plugins\Loader $this->loader |
46 | | - */ |
47 | | - $loader = $event->getSubject(); |
48 | | - $loader->add_page_requirement('vps_add_directadmin', '/../vendor/detain/myadmin-directadmin-vps-addon/src/vps_add_directadmin.php'); |
49 | | - } |
| 39 | + /** |
| 40 | + * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
| 41 | + */ |
| 42 | + public static function getRequirements(GenericEvent $event) |
| 43 | + { |
| 44 | + /** |
| 45 | + * @var \MyAdmin\Plugins\Loader $this->loader |
| 46 | + */ |
| 47 | + $loader = $event->getSubject(); |
| 48 | + $loader->add_page_requirement('vps_add_directadmin', '/../vendor/detain/myadmin-directadmin-vps-addon/src/vps_add_directadmin.php'); |
| 49 | + } |
50 | 50 |
|
51 | | - /** |
52 | | - * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
53 | | - */ |
54 | | - public static function getAddon(GenericEvent $event) |
55 | | - { |
56 | | - /** |
57 | | - * @var \ServiceHandler $service |
58 | | - */ |
59 | | - $service = $event->getSubject(); |
60 | | - function_requirements('class.AddonHandler'); |
61 | | - $addon = new \AddonHandler(); |
62 | | - $addon->setModule(self::$module) |
63 | | - ->set_text('DirectAdmin') |
64 | | - ->set_cost(VPS_DA_COST) |
65 | | - ->set_require_ip(true) |
66 | | - ->setEnable([__CLASS__, 'doEnable']) |
67 | | - ->setDisable([__CLASS__, 'doDisable']) |
68 | | - ->register(); |
69 | | - $service->addAddon($addon); |
70 | | - } |
| 51 | + /** |
| 52 | + * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
| 53 | + */ |
| 54 | + public static function getAddon(GenericEvent $event) |
| 55 | + { |
| 56 | + /** |
| 57 | + * @var \ServiceHandler $service |
| 58 | + */ |
| 59 | + $service = $event->getSubject(); |
| 60 | + function_requirements('class.AddonHandler'); |
| 61 | + $addon = new \AddonHandler(); |
| 62 | + $addon->setModule(self::$module) |
| 63 | + ->set_text('DirectAdmin') |
| 64 | + ->set_cost(VPS_DA_COST) |
| 65 | + ->set_require_ip(true) |
| 66 | + ->setEnable([__CLASS__, 'doEnable']) |
| 67 | + ->setDisable([__CLASS__, 'doDisable']) |
| 68 | + ->register(); |
| 69 | + $service->addAddon($addon); |
| 70 | + } |
71 | 71 |
|
72 | | - /** |
73 | | - * @param \ServiceHandler $serviceOrder |
74 | | - * @param $repeatInvoiceId |
75 | | - * @param bool $regexMatch |
76 | | - */ |
77 | | - public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
78 | | - { |
79 | | - $serviceInfo = $serviceOrder->getServiceInfo(); |
80 | | - $settings = get_module_settings(self::$module); |
81 | | - require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
82 | | - myadmin_log(self::$module, 'info', self::$name.' Activation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
83 | | - $pass = vps_get_password($serviceInfo[$settings['PREFIX'].'_id']); |
84 | | - function_requirements('directadmin_get_best_type'); |
85 | | - function_requirements('activate_directadmin'); |
86 | | - $serviceExtra = run_event('parse_service_extra', $serviceInfo[$settings['PREFIX'].'_extra'], self::$module); |
87 | | - $ostype = directadmin_get_best_type(self::$module, $serviceInfo[$settings['PREFIX'].'_type'], $serviceInfo, $serviceExtra); |
88 | | - activate_directadmin($serviceInfo[$settings['PREFIX'].'_ip'], $ostype, $pass, $GLOBALS['tf']->accounts->cross_reference($serviceInfo[$settings['PREFIX'].'_custid']), self::$module.$serviceInfo[$settings['PREFIX'].'_id']); |
89 | | - } |
| 72 | + /** |
| 73 | + * @param \ServiceHandler $serviceOrder |
| 74 | + * @param $repeatInvoiceId |
| 75 | + * @param bool $regexMatch |
| 76 | + */ |
| 77 | + public static function doEnable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
| 78 | + { |
| 79 | + $serviceInfo = $serviceOrder->getServiceInfo(); |
| 80 | + $settings = get_module_settings(self::$module); |
| 81 | + require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
| 82 | + myadmin_log(self::$module, 'info', self::$name.' Activation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
| 83 | + $pass = vps_get_password($serviceInfo[$settings['PREFIX'].'_id']); |
| 84 | + function_requirements('directadmin_get_best_type'); |
| 85 | + function_requirements('activate_directadmin'); |
| 86 | + $serviceExtra = run_event('parse_service_extra', $serviceInfo[$settings['PREFIX'].'_extra'], self::$module); |
| 87 | + $ostype = directadmin_get_best_type(self::$module, $serviceInfo[$settings['PREFIX'].'_type'], $serviceInfo, $serviceExtra); |
| 88 | + activate_directadmin($serviceInfo[$settings['PREFIX'].'_ip'], $ostype, $pass, $GLOBALS['tf']->accounts->cross_reference($serviceInfo[$settings['PREFIX'].'_custid']), self::$module.$serviceInfo[$settings['PREFIX'].'_id']); |
| 89 | + } |
90 | 90 |
|
91 | | - /** |
92 | | - * @param \ServiceHandler $serviceOrder |
93 | | - * @param $repeatInvoiceId |
94 | | - * @param bool $regexMatch |
95 | | - */ |
96 | | - public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
97 | | - { |
98 | | - $serviceInfo = $serviceOrder->getServiceInfo(); |
99 | | - $settings = get_module_settings(self::$module); |
100 | | - require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
101 | | - myadmin_log(self::$module, 'info', self::$name.' Deactivation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
102 | | - function_requirements('deactivate_directadmin'); |
103 | | - deactivate_directadmin($serviceInfo[$settings['PREFIX'].'_ip']); |
104 | | - $email = $settings['TBLNAME'].' ID: '.$serviceInfo[$settings['PREFIX'].'_id'].'<br>'.$settings['TBLNAME'].' Hostname: '.$serviceInfo[$settings['PREFIX'].'_hostname'].'<br>Repeat Invoice: '.$repeatInvoiceId.'<br>Description: '.self::$name.'<br>'; |
105 | | - $subject = $settings['TBLNAME'].' '.$serviceInfo[$settings['PREFIX'].'_id'].' Canceled '.self::$name; |
106 | | - (new \MyAdmin\Mail())->adminMail($subject, $email, false, 'admin/vps_da_canceled.tpl'); |
107 | | - } |
| 91 | + /** |
| 92 | + * @param \ServiceHandler $serviceOrder |
| 93 | + * @param $repeatInvoiceId |
| 94 | + * @param bool $regexMatch |
| 95 | + */ |
| 96 | + public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
| 97 | + { |
| 98 | + $serviceInfo = $serviceOrder->getServiceInfo(); |
| 99 | + $settings = get_module_settings(self::$module); |
| 100 | + require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
| 101 | + myadmin_log(self::$module, 'info', self::$name.' Deactivation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
| 102 | + function_requirements('deactivate_directadmin'); |
| 103 | + deactivate_directadmin($serviceInfo[$settings['PREFIX'].'_ip']); |
| 104 | + $email = $settings['TBLNAME'].' ID: '.$serviceInfo[$settings['PREFIX'].'_id'].'<br>'.$settings['TBLNAME'].' Hostname: '.$serviceInfo[$settings['PREFIX'].'_hostname'].'<br>Repeat Invoice: '.$repeatInvoiceId.'<br>Description: '.self::$name.'<br>'; |
| 105 | + $subject = $settings['TBLNAME'].' '.$serviceInfo[$settings['PREFIX'].'_id'].' Canceled '.self::$name; |
| 106 | + (new \MyAdmin\Mail())->adminMail($subject, $email, false, 'admin/vps_da_canceled.tpl'); |
| 107 | + } |
108 | 108 |
|
109 | | - /** |
110 | | - * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
111 | | - */ |
112 | | - public static function getSettings(GenericEvent $event) |
113 | | - { |
114 | | - /** |
115 | | - * @var \MyAdmin\Settings $settings |
116 | | - **/ |
117 | | - $settings = $event->getSubject(); |
118 | | - $settings->add_text_setting(self::$module, _('Addon Costs'), 'vps_da_cost', _('VPS DirectAdmin License'), _('This is the cost for purchasing a direct admin license on top of a VPS.'), $settings->get_setting('VPS_DA_COST')); |
119 | | - } |
| 109 | + /** |
| 110 | + * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
| 111 | + */ |
| 112 | + public static function getSettings(GenericEvent $event) |
| 113 | + { |
| 114 | + /** |
| 115 | + * @var \MyAdmin\Settings $settings |
| 116 | + **/ |
| 117 | + $settings = $event->getSubject(); |
| 118 | + $settings->add_text_setting(self::$module, _('Addon Costs'), 'vps_da_cost', _('VPS DirectAdmin License'), _('This is the cost for purchasing a direct admin license on top of a VPS.'), $settings->get_setting('VPS_DA_COST')); |
| 119 | + } |
120 | 120 | } |
0 commit comments