-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Edward Crocombe
committed
Dec 20, 2022
1 parent
4c3bbf8
commit 7edfa36
Showing
19 changed files
with
3,255 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
/** | ||
* FOSSBilling. | ||
* | ||
* @copyright FOSSBilling (https://www.fossbilling.org) | ||
* @license Apache-2.0 | ||
* | ||
* Copyright FOSSBilling 2022 | ||
* This software may contain code previously used in the BoxBilling project. | ||
* Copyright BoxBilling, Inc 2011-2021 | ||
* | ||
* This source file is subject to the Apache-2.0 License that is bundled | ||
* with this source code in the file LICENSE | ||
*/ | ||
|
||
namespace Box\Mod\Servicesaas\Api; | ||
|
||
/** | ||
* Hosting service management. | ||
*/ | ||
class Client extends \Api_Abstract | ||
{ | ||
/** | ||
* Change hosting account username. | ||
* | ||
* @param int $order_id - Hosting account order id | ||
* @param string $username - New username | ||
* | ||
* @return bool | ||
*/ | ||
public function change_username($data) | ||
{ | ||
[$order, $s] = $this->_getService($data); | ||
|
||
return $this->getService()->changeAccountUsername($order, $s, $data); | ||
} | ||
|
||
/** | ||
* Change hosting account domain. | ||
* | ||
* @param int $order_id - Hosting account order id | ||
* @param string $password - New second level domain name, ie: mydomain | ||
* @param string $password_confirm - New top level domain, ie: .com | ||
* | ||
* @return bool | ||
*/ | ||
public function change_domain($data) | ||
{ | ||
[$order, $s] = $this->_getService($data); | ||
|
||
return $this->getService()->changeAccountDomain($order, $s, $data); | ||
} | ||
|
||
/** | ||
* Change hosting account password. | ||
* | ||
* @param int $order_id - Hosting account order id | ||
* @param string $password - New account password | ||
* @param string $password_confirm - Repeat new password | ||
* | ||
* @return bool | ||
*/ | ||
public function change_password($data) | ||
{ | ||
[$order, $s] = $this->_getService($data); | ||
|
||
return $this->getService()->changeAccountPassword($order, $s, $data); | ||
} | ||
|
||
/** | ||
* Get hosting plans pairs. Usually for select box. | ||
* | ||
* @return array | ||
*/ | ||
public function hp_get_pairs($data) | ||
{ | ||
return $this->getService()->getHpPairs(); | ||
} | ||
|
||
public function _getService($data) | ||
{ | ||
if (!isset($data['order_id'])) { | ||
throw new \Box_Exception('Order id is required'); | ||
} | ||
$identity = $this->getIdentity(); | ||
$order = $this->di['db']->findOne('ClientOrder', 'id = ? and client_id = ?', [$data['order_id'], $identity->id]); | ||
if (!$order instanceof \Model_ClientOrder) { | ||
throw new \Box_Exception('Order not found'); | ||
} | ||
|
||
$orderService = $this->di['mod_service']('order'); | ||
$s = $orderService->getOrderService($order); | ||
if (!$s instanceof \Model_Servicesaas) { | ||
throw new \Box_Exception('Order is not activated'); | ||
} | ||
|
||
return [$order, $s]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* FOSSBilling. | ||
* | ||
* @copyright FOSSBilling (https://www.fossbilling.org) | ||
* @license Apache-2.0 | ||
* | ||
* Copyright FOSSBilling 2022 | ||
* This software may contain code previously used in the BoxBilling project. | ||
* Copyright BoxBilling, Inc 2011-2021 | ||
* | ||
* This source file is subject to the Apache-2.0 License that is bundled | ||
* with this source code in the file LICENSE | ||
*/ | ||
|
||
namespace Box\Mod\Servicesaas\Api; | ||
|
||
/** | ||
* Hosting service management. | ||
*/ | ||
class Guest extends \Api_Abstract | ||
{ | ||
/** | ||
* @param array $data | ||
* | ||
* @return array | ||
* | ||
* @throws \Box_Exception | ||
*/ | ||
public function free_tlds($data = []) | ||
{ | ||
$required = [ | ||
'product_id' => 'Product id is missing', | ||
]; | ||
$this->di['validator']->checkRequiredParamsForArray($required, $data); | ||
|
||
$product_id = $this->di['array_get']($data, 'product_id', 0); | ||
$product = $this->di['db']->getExistingModelById('Product', $product_id, 'Product was not found'); | ||
|
||
if (\Model_Product::HOSTING !== $product->type) { | ||
throw new \Box_Exception('Product type is invalid'); | ||
} | ||
|
||
return $this->getService()->getFreeTlds($product); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/** | ||
* FOSSBilling. | ||
* | ||
* @copyright FOSSBilling (https://www.fossbilling.org) | ||
* @license Apache-2.0 | ||
* | ||
* Copyright FOSSBilling 2022 | ||
* This software may contain code previously used in the BoxBilling project. | ||
* Copyright BoxBilling, Inc 2011-2021 | ||
* | ||
* This source file is subject to the Apache-2.0 License that is bundled | ||
* with this source code in the file LICENSE | ||
*/ | ||
|
||
namespace Box\Mod\Servicesaas\Controller; | ||
|
||
class Admin implements \Box\InjectionAwareInterface | ||
{ | ||
protected $di; | ||
|
||
/** | ||
* @param mixed $di | ||
*/ | ||
public function setDi($di) | ||
{ | ||
$this->di = $di; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getDi() | ||
{ | ||
return $this->di; | ||
} | ||
|
||
public function fetchNavigation() | ||
{ | ||
return [ | ||
'subpages' => [ | ||
[ | ||
'location' => 'system', | ||
'index' => 140, | ||
'label' => 'Hosting plans and servers', | ||
'uri' => $this->di['url']->adminLink('Servicesaas'), | ||
'class' => '', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
public function register(\Box_App &$app) | ||
{ | ||
$app->get('/Servicesaas', 'get_index', null, get_class($this)); | ||
$app->get('/Servicesaas/plan/:id', 'get_plan', ['id' => '[0-9]+'], get_class($this)); | ||
$app->get('/Servicesaas/server/:id', 'get_server', ['id' => '[0-9]+'], get_class($this)); | ||
} | ||
|
||
public function get_index(\Box_App $app) | ||
{ | ||
$this->di['is_admin_logged']; | ||
|
||
return $app->render('mod_Servicesaas_index'); | ||
} | ||
|
||
public function get_plan(\Box_App $app, $id) | ||
{ | ||
$api = $this->di['api_admin']; | ||
$hp = $api->Servicesaas_hp_get(['id' => $id]); | ||
|
||
return $app->render('mod_Servicesaas_hp', ['hp' => $hp]); | ||
} | ||
|
||
public function get_server(\Box_App $app, $id) | ||
{ | ||
$api = $this->di['api_admin']; | ||
$server = $api->Servicesaas_server_get(['id' => $id]); | ||
|
||
return $app->render('mod_Servicesaas_server', ['server' => $server]); | ||
} | ||
} |
Oops, something went wrong.