Skip to content

Commit 42442fa

Browse files
committed
updated
the formatting
1 parent b457811 commit 42442fa

2 files changed

Lines changed: 182 additions & 183 deletions

File tree

src/Plugin.php

Lines changed: 182 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -13,197 +13,197 @@
1313
*/
1414
class Plugin
1515
{
16-
public static $name = 'Cloudlinux Licensing';
17-
public static $description = 'Allows selling of Cloudlinux Server and VPS License Types. More info at https://www.cloudlinux.com/';
18-
public static $help = 'It provides more than one million end users the ability to quickly install dozens of the leading open source content management systems into their web space. Must have a pre-existing cPanel license with cPanelDirect to purchase a cloudlinux license. Allow 10 minutes for activation.';
19-
public static $module = 'licenses';
20-
public static $type = 'service';
16+
public static $name = 'Cloudlinux Licensing';
17+
public static $description = 'Allows selling of Cloudlinux Server and VPS License Types. More info at https://www.cloudlinux.com/';
18+
public static $help = 'It provides more than one million end users the ability to quickly install dozens of the leading open source content management systems into their web space. Must have a pre-existing cPanel license with cPanelDirect to purchase a cloudlinux license. Allow 10 minutes for activation.';
19+
public static $module = 'licenses';
20+
public static $type = 'service';
2121

22-
/**
23-
* Plugin constructor.
24-
*/
25-
public function __construct()
26-
{
27-
}
22+
/**
23+
* Plugin constructor.
24+
*/
25+
public function __construct()
26+
{
27+
}
2828

29-
/**
30-
* @return array
31-
*/
32-
public static function getHooks()
33-
{
34-
return [
35-
'plugin.install' => [__CLASS__, 'getInstall'],
36-
'plugin.uninstall' => [__CLASS__, 'getUninstall'],
37-
self::$module.'.settings' => [__CLASS__, 'getSettings'],
38-
self::$module.'.activate' => [__CLASS__, 'getActivate'],
39-
self::$module.'.reactivate' => [__CLASS__, 'getActivate'],
40-
self::$module.'.deactivate' => [__CLASS__, 'getDeactivate'],
41-
self::$module.'.deactivate_ip' => [__CLASS__, 'getDeactivateIp'],
42-
self::$module.'.change_ip' => [__CLASS__, 'getChangeIp'],
43-
'function.requirements' => [__CLASS__, 'getRequirements'],
44-
'ui.menu' => [__CLASS__, 'getMenu']
45-
];
46-
}
29+
/**
30+
* @return array
31+
*/
32+
public static function getHooks()
33+
{
34+
return [
35+
'plugin.install' => [__CLASS__, 'getInstall'],
36+
'plugin.uninstall' => [__CLASS__, 'getUninstall'],
37+
self::$module.'.settings' => [__CLASS__, 'getSettings'],
38+
self::$module.'.activate' => [__CLASS__, 'getActivate'],
39+
self::$module.'.reactivate' => [__CLASS__, 'getActivate'],
40+
self::$module.'.deactivate' => [__CLASS__, 'getDeactivate'],
41+
self::$module.'.deactivate_ip' => [__CLASS__, 'getDeactivateIp'],
42+
self::$module.'.change_ip' => [__CLASS__, 'getChangeIp'],
43+
'function.requirements' => [__CLASS__, 'getRequirements'],
44+
'ui.menu' => [__CLASS__, 'getMenu']
45+
];
46+
}
4747

48-
/**
49-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
50-
*/
51-
public static function getInstall(GenericEvent $event)
52-
{
53-
$plugin = $event->getSubject();
54-
$serviceCategory = $plugin->addServiceCategory(self::$module, 'cloudlinux', 'CloudLinux');
55-
$plugin->addDefine('SERVICE_TYPES_CLOUDLINUX', $serviceCategory);
56-
$serviceType = $plugin->addServiceType($serviceCategory, self::$module, 'CloudLinux');
57-
$plugin->addService($serviceCategory, $serviceType, self::$module, 'CloudLinux License', 10.00, 0, 1, 1, '');
58-
$plugin->addService($serviceCategory, $serviceType, self::$module, 'CloudLinux Type2 License', 11.95, 0, 1, 2, '');
59-
$plugin->addService($serviceCategory, $serviceType, self::$module, 'KernelCare License', 2.95, 0, 1, 16, '');
60-
}
48+
/**
49+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
50+
*/
51+
public static function getInstall(GenericEvent $event)
52+
{
53+
$plugin = $event->getSubject();
54+
$serviceCategory = $plugin->addServiceCategory(self::$module, 'cloudlinux', 'CloudLinux');
55+
$plugin->addDefine('SERVICE_TYPES_CLOUDLINUX', $serviceCategory);
56+
$serviceType = $plugin->addServiceType($serviceCategory, self::$module, 'CloudLinux');
57+
$plugin->addService($serviceCategory, $serviceType, self::$module, 'CloudLinux License', 10.00, 0, 1, 1, '');
58+
$plugin->addService($serviceCategory, $serviceType, self::$module, 'CloudLinux Type2 License', 11.95, 0, 1, 2, '');
59+
$plugin->addService($serviceCategory, $serviceType, self::$module, 'KernelCare License', 2.95, 0, 1, 16, '');
60+
}
6161

62-
/**
63-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
64-
*/
65-
public static function getUninstall(GenericEvent $event)
66-
{
67-
$plugin = $event->getSubject();
68-
$plugin->disableServiceCategory(self::$module, 'cloudlinux');
69-
}
62+
/**
63+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
64+
*/
65+
public static function getUninstall(GenericEvent $event)
66+
{
67+
$plugin = $event->getSubject();
68+
$plugin->disableServiceCategory(self::$module, 'cloudlinux');
69+
}
7070

71-
/**
72-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
73-
* @throws \Detain\Cloudlinux\XmlRpcException
74-
*/
75-
public static function getActivate(GenericEvent $event)
76-
{
77-
$serviceClass = $event->getSubject();
78-
if ($event['category'] == get_service_define('CLOUDLINUX')) {
79-
myadmin_log(self::$module, 'info', 'Cloudlinux Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
80-
$cl = new Cloudlinux(CLOUDLINUX_LOGIN, CLOUDLINUX_KEY);
81-
$response = $cl->isLicensed($serviceClass->getIp(), true);
82-
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
83-
if (!is_array($response) || !in_array($event['field1'], array_values($response))) {
84-
$response = $cl->license($serviceClass->getIp(), $event['field1']);
85-
//$serviceExtra = $response['mainKeyNumber'].','.$response['productKey'];
86-
request_log(self::$module, $GLOBALS['tf']->session->account_id, __FUNCTION__, 'cloudlinux', 'license', [$serviceClass->getIp(), $event['field1']], $response);
87-
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
88-
if ($response === false) {
89-
$event['status'] = 'error';
90-
$event['status_text'] = 'Error Licensing the new IP.';
91-
} else {
92-
$event['status'] = 'ok';
93-
$event['status_text'] = 'The IP Address has been licensed.';
94-
}
95-
} else {
96-
$event['status'] = 'ok';
97-
$event['status_text'] = 'The IP Address was already licensed.';
98-
}
99-
$event->stopPropagation();
100-
}
101-
}
71+
/**
72+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
73+
* @throws \Detain\Cloudlinux\XmlRpcException
74+
*/
75+
public static function getActivate(GenericEvent $event)
76+
{
77+
$serviceClass = $event->getSubject();
78+
if ($event['category'] == get_service_define('CLOUDLINUX')) {
79+
myadmin_log(self::$module, 'info', 'Cloudlinux Activation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
80+
$cl = new Cloudlinux(CLOUDLINUX_LOGIN, CLOUDLINUX_KEY);
81+
$response = $cl->isLicensed($serviceClass->getIp(), true);
82+
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
83+
if (!is_array($response) || !in_array($event['field1'], array_values($response))) {
84+
$response = $cl->license($serviceClass->getIp(), $event['field1']);
85+
//$serviceExtra = $response['mainKeyNumber'].','.$response['productKey'];
86+
request_log(self::$module, $GLOBALS['tf']->session->account_id, __FUNCTION__, 'cloudlinux', 'license', [$serviceClass->getIp(), $event['field1']], $response);
87+
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
88+
if ($response === false) {
89+
$event['status'] = 'error';
90+
$event['status_text'] = 'Error Licensing the new IP.';
91+
} else {
92+
$event['status'] = 'ok';
93+
$event['status_text'] = 'The IP Address has been licensed.';
94+
}
95+
} else {
96+
$event['status'] = 'ok';
97+
$event['status_text'] = 'The IP Address was already licensed.';
98+
}
99+
$event->stopPropagation();
100+
}
101+
}
102102

103-
/**
104-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
105-
*/
106-
public static function getDeactivate(GenericEvent $event)
107-
{
108-
$serviceClass = $event->getSubject();
109-
if ($event['category'] == get_service_define('CLOUDLINUX')) {
110-
myadmin_log(self::$module, 'info', 'Cloudlinux Deactivation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
111-
function_requirements('deactivate_cloudlinux');
112-
deactivate_cloudlinux($serviceClass->getIp(), $event['field1']);
113-
$event->stopPropagation();
114-
}
115-
}
103+
/**
104+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
105+
*/
106+
public static function getDeactivate(GenericEvent $event)
107+
{
108+
$serviceClass = $event->getSubject();
109+
if ($event['category'] == get_service_define('CLOUDLINUX')) {
110+
myadmin_log(self::$module, 'info', 'Cloudlinux Deactivation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
111+
function_requirements('deactivate_cloudlinux');
112+
deactivate_cloudlinux($serviceClass->getIp(), $event['field1']);
113+
$event->stopPropagation();
114+
}
115+
}
116116

117-
/**
118-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
119-
*/
120-
public static function getDeactivateIp(GenericEvent $event)
121-
{
122-
$serviceClass = $event->getSubject();
123-
if ($event['category'] == get_service_define('CLOUDLINUX')) {
124-
myadmin_log(self::$module, 'info', 'Cloudlinux Deactivation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
125-
function_requirements('deactivate_cloudlinux');
126-
deactivate_cloudlinux($serviceClass->getIp());
127-
$event->stopPropagation();
128-
}
129-
}
117+
/**
118+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
119+
*/
120+
public static function getDeactivateIp(GenericEvent $event)
121+
{
122+
$serviceClass = $event->getSubject();
123+
if ($event['category'] == get_service_define('CLOUDLINUX')) {
124+
myadmin_log(self::$module, 'info', 'Cloudlinux Deactivation', __LINE__, __FILE__, self::$module, $serviceClass->getId());
125+
function_requirements('deactivate_cloudlinux');
126+
deactivate_cloudlinux($serviceClass->getIp());
127+
$event->stopPropagation();
128+
}
129+
}
130130

131-
/**
132-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
133-
* @throws \Detain\Cloudlinux\XmlRpcException
134-
*/
135-
public static function getChangeIp(GenericEvent $event)
136-
{
137-
if ($event['category'] == get_service_define('CLOUDLINUX')) {
138-
$serviceClass = $event->getSubject();
139-
$settings = get_module_settings(self::$module);
140-
myadmin_log(self::$module, 'info', 'IP Change - OLD:'.$serviceClass->getIp()." NEW:{$event['newip']} Type:{$event['field1']}", __LINE__, __FILE__, self::$module, $serviceClass->getId());
141-
$cl = new Cloudlinux(CLOUDLINUX_LOGIN, CLOUDLINUX_KEY);
142-
$response = $cl->remove($serviceClass->getIp(), $event['field1']);
143-
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
144-
$event['status'] = 'ok';
145-
$event['status_text'] = 'The IP Address has been changed.';
146-
if ($response === false) {
147-
$event['status'] = 'error';
148-
$event['status_text'] = 'Error removing the old license.';
149-
} else {
150-
$response = $cl->isLicensed($event['newip'], true);
151-
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
152-
if (!is_array($response) || !in_array($event['field1'], array_values($response))) {
153-
$response = $cl->license($event['newip'], $event['field1']);
154-
//$serviceExtra = $response['mainKeyNumber'].','.$response['productKey'];
155-
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
156-
if ($response === false) {
157-
$event['status'] = 'error';
158-
$event['status_text'] = 'Error Licensing the new IP.';
159-
}
160-
}
161-
}
162-
if ($event['status'] == 'ok') {
163-
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_ip', $event['newip'], $serviceClass->getId(), $serviceClass->getCustid());
164-
$serviceClass->set_ip($event['newip'])->save();
165-
}
166-
$event->stopPropagation();
167-
}
168-
}
131+
/**
132+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
133+
* @throws \Detain\Cloudlinux\XmlRpcException
134+
*/
135+
public static function getChangeIp(GenericEvent $event)
136+
{
137+
if ($event['category'] == get_service_define('CLOUDLINUX')) {
138+
$serviceClass = $event->getSubject();
139+
$settings = get_module_settings(self::$module);
140+
myadmin_log(self::$module, 'info', 'IP Change - OLD:'.$serviceClass->getIp()." NEW:{$event['newip']} Type:{$event['field1']}", __LINE__, __FILE__, self::$module, $serviceClass->getId());
141+
$cl = new Cloudlinux(CLOUDLINUX_LOGIN, CLOUDLINUX_KEY);
142+
$response = $cl->remove($serviceClass->getIp(), $event['field1']);
143+
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
144+
$event['status'] = 'ok';
145+
$event['status_text'] = 'The IP Address has been changed.';
146+
if ($response === false) {
147+
$event['status'] = 'error';
148+
$event['status_text'] = 'Error removing the old license.';
149+
} else {
150+
$response = $cl->isLicensed($event['newip'], true);
151+
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
152+
if (!is_array($response) || !in_array($event['field1'], array_values($response))) {
153+
$response = $cl->license($event['newip'], $event['field1']);
154+
//$serviceExtra = $response['mainKeyNumber'].','.$response['productKey'];
155+
myadmin_log(self::$module, 'info', 'Response: '.json_encode($response), __LINE__, __FILE__, self::$module, $serviceClass->getId());
156+
if ($response === false) {
157+
$event['status'] = 'error';
158+
$event['status_text'] = 'Error Licensing the new IP.';
159+
}
160+
}
161+
}
162+
if ($event['status'] == 'ok') {
163+
$GLOBALS['tf']->history->add($settings['TABLE'], 'change_ip', $event['newip'], $serviceClass->getId(), $serviceClass->getCustid());
164+
$serviceClass->set_ip($event['newip'])->save();
165+
}
166+
$event->stopPropagation();
167+
}
168+
}
169169

170-
/**
171-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
172-
*/
173-
public static function getMenu(GenericEvent $event)
174-
{
175-
$menu = $event->getSubject();
176-
if ($GLOBALS['tf']->ima == 'admin') {
177-
$menu->add_link(self::$module.'api', 'choice=none.cloudlinux_licenses_list', '/images/myadmin/list.png', _('List all CloudLinux Licenses'));
178-
}
179-
}
170+
/**
171+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
172+
*/
173+
public static function getMenu(GenericEvent $event)
174+
{
175+
$menu = $event->getSubject();
176+
if ($GLOBALS['tf']->ima == 'admin') {
177+
$menu->add_link(self::$module.'api', 'choice=none.cloudlinux_licenses_list', '/images/myadmin/list.png', _('List all CloudLinux Licenses'));
178+
}
179+
}
180180

181-
/**
182-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
183-
*/
184-
public static function getRequirements(GenericEvent $event)
185-
{
186-
/**
187-
* @var \MyAdmin\Plugins\Loader $this->loader
188-
*/
189-
$loader = $event->getSubject();
190-
$loader->add_page_requirement('cloudlinux_licenses_list', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux_licenses_list.php');
191-
$loader->add_requirement('deactivate_kcare', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
192-
$loader->add_requirement('deactivate_cloudlinux', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
193-
$loader->add_requirement('get_cloudlinux_licenses', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
194-
}
181+
/**
182+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
183+
*/
184+
public static function getRequirements(GenericEvent $event)
185+
{
186+
/**
187+
* @var \MyAdmin\Plugins\Loader $this->loader
188+
*/
189+
$loader = $event->getSubject();
190+
$loader->add_page_requirement('cloudlinux_licenses_list', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux_licenses_list.php');
191+
$loader->add_requirement('deactivate_kcare', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
192+
$loader->add_requirement('deactivate_cloudlinux', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
193+
$loader->add_requirement('get_cloudlinux_licenses', '/../vendor/detain/myadmin-cloudlinux-licensing/src/cloudlinux.inc.php');
194+
}
195195

196-
/**
197-
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
198-
*/
199-
public static function getSettings(GenericEvent $event)
200-
{
201-
/**
202-
* @var \MyAdmin\Settings $settings
203-
**/
204-
$settings = $event->getSubject();
205-
$settings->add_text_setting(self::$module, _('Cloudlinux'), 'cloudlinux_login', _('Cloudlinux Login'), _('Cloudlinux Login'), CLOUDLINUX_LOGIN);
206-
$settings->add_text_setting(self::$module, _('Cloudlinux'), 'cloudlinux_key', _('Cloudlinux Key'), _('Cloudlinux Key'), CLOUDLINUX_KEY);
207-
$settings->add_dropdown_setting(self::$module, _('Cloudlinux'), 'outofstock_licenses_cloudlinux', _('Out Of Stock CloudLinux Licenses'), _('Enable/Disable Sales Of This Type'), OUTOFSTOCK_LICENSES_CLOUDLINUX, ['0', '1'], ['No', 'Yes']);
208-
}
196+
/**
197+
* @param \Symfony\Component\EventDispatcher\GenericEvent $event
198+
*/
199+
public static function getSettings(GenericEvent $event)
200+
{
201+
/**
202+
* @var \MyAdmin\Settings $settings
203+
**/
204+
$settings = $event->getSubject();
205+
$settings->add_text_setting(self::$module, _('Cloudlinux'), 'cloudlinux_login', _('Cloudlinux Login'), _('Cloudlinux Login'), CLOUDLINUX_LOGIN);
206+
$settings->add_text_setting(self::$module, _('Cloudlinux'), 'cloudlinux_key', _('Cloudlinux Key'), _('Cloudlinux Key'), CLOUDLINUX_KEY);
207+
$settings->add_dropdown_setting(self::$module, _('Cloudlinux'), 'outofstock_licenses_cloudlinux', _('Out Of Stock CloudLinux Licenses'), _('Enable/Disable Sales Of This Type'), OUTOFSTOCK_LICENSES_CLOUDLINUX, ['0', '1'], ['No', 'Yes']);
208+
}
209209
}

src/cloudlinux_licenses_list.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use Detain\Cloudlinux\Cloudlinux;
1414

15-
1615
function cloudlinux_licenses_list()
1716
{
1817
if ($GLOBALS['tf']->ima == 'admin') {

0 commit comments

Comments
 (0)