|
11 | 11 | */
|
12 | 12 | class Plugin
|
13 | 13 | {
|
14 |
| - public static $name = 'Softaculous VPS Addon'; |
15 |
| - public static $description = 'Allows selling of Softaculous License Addons to a VPS. Softaculous is the leading Auto Installer having 426 great scripts, 1115 PHP Classes and we are still adding more. Softaculous is widely used in the Web Hosting industry and it has helped millions of users install applications by the click of a button. Softaculous Auto Installer easily integrates into leading Control Panels like cPanel, Plesk, DirectAdmin, InterWorx, H-Sphere. More info at https://www.softaculous.com/'; |
16 |
| - public static $help = ''; |
17 |
| - public static $module = 'vps'; |
18 |
| - public static $type = 'addon'; |
| 14 | + public static $name = 'Softaculous VPS Addon'; |
| 15 | + public static $description = 'Allows selling of Softaculous License Addons to a VPS. Softaculous is the leading Auto Installer having 426 great scripts, 1115 PHP Classes and we are still adding more. Softaculous is widely used in the Web Hosting industry and it has helped millions of users install applications by the click of a button. Softaculous Auto Installer easily integrates into leading Control Panels like cPanel, Plesk, DirectAdmin, InterWorx, H-Sphere. More info at https://www.softaculous.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_softaculous', '/../vendor/detain/myadmin-softaculous-vps-addon/src/vps_add_softaculous.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_softaculous', '/../vendor/detain/myadmin-softaculous-vps-addon/src/vps_add_softaculous.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('Softaculous') |
64 |
| - ->set_cost(VPS_SOFTACULOUS_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('Softaculous') |
| 64 | + ->set_cost(VPS_SOFTACULOUS_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 |
| - $noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD); |
84 |
| - myadmin_log(self::$module, 'info', json_encode($noc->buy($serviceInfo[$settings['PREFIX'].'_ip'], '1M', 2, $GLOBALS['tf']->accounts->cross_reference($serviceInfo[$settings['PREFIX'].'_custid']), 1)), __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
85 |
| - $GLOBALS['tf']->history->add($settings['TABLE'], 'add_softaculous', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_ip'], $serviceInfo[$settings['PREFIX'].'_custid']); |
86 |
| - } |
| 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 | + $noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD); |
| 84 | + myadmin_log(self::$module, 'info', json_encode($noc->buy($serviceInfo[$settings['PREFIX'].'_ip'], '1M', 2, $GLOBALS['tf']->accounts->cross_reference($serviceInfo[$settings['PREFIX'].'_custid']), 1)), __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
| 85 | + $GLOBALS['tf']->history->add($settings['TABLE'], 'add_softaculous', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_ip'], $serviceInfo[$settings['PREFIX'].'_custid']); |
| 86 | + } |
87 | 87 |
|
88 |
| - /** |
89 |
| - * @param \ServiceHandler $serviceOrder |
90 |
| - * @param $repeatInvoiceId |
91 |
| - * @param bool $regexMatch |
92 |
| - */ |
93 |
| - public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
94 |
| - { |
95 |
| - $serviceInfo = $serviceOrder->getServiceInfo(); |
96 |
| - $settings = get_module_settings(self::$module); |
97 |
| - require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
98 |
| - myadmin_log(self::$module, 'info', self::$name.' Deactivation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
99 |
| - $noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD); |
100 |
| - myadmin_log(self::$module, 'info', json_encode($noc->cancel('', $serviceInfo[$settings['PREFIX'].'_ip'])), __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
101 |
| - $GLOBALS['tf']->history->add($settings['TABLE'], 'del_softaculous', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_ip'], $serviceInfo[$settings['PREFIX'].'_custid']); |
102 |
| - $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>'; |
103 |
| - $subject = $settings['TBLNAME'].' '.$serviceInfo[$settings['PREFIX'].'_id'].' Canceled Softaculous'; |
104 |
| - $headers = ''; |
105 |
| - $headers .= 'MIME-Version: 1.0'.PHP_EOL; |
106 |
| - $headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL; |
107 |
| - $headers .= 'From: '.$settings['TITLE'].' <'.$settings['EMAIL_FROM'].'>'.PHP_EOL; |
108 |
| - admin_mail($subject, $email, $headers, false, 'admin/vps_softaculous_canceled.tpl'); |
109 |
| - } |
| 88 | + /** |
| 89 | + * @param \ServiceHandler $serviceOrder |
| 90 | + * @param $repeatInvoiceId |
| 91 | + * @param bool $regexMatch |
| 92 | + */ |
| 93 | + public static function doDisable(\ServiceHandler $serviceOrder, $repeatInvoiceId, $regexMatch = false) |
| 94 | + { |
| 95 | + $serviceInfo = $serviceOrder->getServiceInfo(); |
| 96 | + $settings = get_module_settings(self::$module); |
| 97 | + require_once __DIR__.'/../../../../include/licenses/license.functions.inc.php'; |
| 98 | + myadmin_log(self::$module, 'info', self::$name.' Deactivation', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
| 99 | + $noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(SOFTACULOUS_USERNAME, SOFTACULOUS_PASSWORD); |
| 100 | + myadmin_log(self::$module, 'info', json_encode($noc->cancel('', $serviceInfo[$settings['PREFIX'].'_ip'])), __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id']); |
| 101 | + $GLOBALS['tf']->history->add($settings['TABLE'], 'del_softaculous', $serviceInfo[$settings['PREFIX'].'_id'], $serviceInfo[$settings['PREFIX'].'_ip'], $serviceInfo[$settings['PREFIX'].'_custid']); |
| 102 | + $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>'; |
| 103 | + $subject = $settings['TBLNAME'].' '.$serviceInfo[$settings['PREFIX'].'_id'].' Canceled Softaculous'; |
| 104 | + $headers = ''; |
| 105 | + $headers .= 'MIME-Version: 1.0'.PHP_EOL; |
| 106 | + $headers .= 'Content-type: text/html; charset=UTF-8'.PHP_EOL; |
| 107 | + $headers .= 'From: '.$settings['TITLE'].' <'.$settings['EMAIL_FROM'].'>'.PHP_EOL; |
| 108 | + admin_mail($subject, $email, $headers, false, 'admin/vps_softaculous_canceled.tpl'); |
| 109 | + } |
110 | 110 |
|
111 |
| - /** |
112 |
| - * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
113 |
| - */ |
114 |
| - public static function getSettings(GenericEvent $event) |
115 |
| - { |
116 |
| - /** |
117 |
| - * @var \MyAdmin\Settings $settings |
118 |
| - **/ |
119 |
| - $settings = $event->getSubject(); |
120 |
| - $settings->add_text_setting(self::$module, _('Addon Costs'), 'vps_softaculous_cost', _('VPS Softaculous License'), _('This is the cost for purchasing a softaculous license on top of a VPS.'), $settings->get_setting('VPS_SOFTACULOUS_COST')); |
121 |
| - } |
| 111 | + /** |
| 112 | + * @param \Symfony\Component\EventDispatcher\GenericEvent $event |
| 113 | + */ |
| 114 | + public static function getSettings(GenericEvent $event) |
| 115 | + { |
| 116 | + /** |
| 117 | + * @var \MyAdmin\Settings $settings |
| 118 | + **/ |
| 119 | + $settings = $event->getSubject(); |
| 120 | + $settings->add_text_setting(self::$module, _('Addon Costs'), 'vps_softaculous_cost', _('VPS Softaculous License'), _('This is the cost for purchasing a softaculous license on top of a VPS.'), $settings->get_setting('VPS_SOFTACULOUS_COST')); |
| 121 | + } |
122 | 122 | }
|
0 commit comments