WIP: Add Create Domain capability

This commit is contained in:
Miguel Nogueira
2019-01-30 13:39:28 +00:00
parent a8f089e3b2
commit c7bcaa2093
3 changed files with 51 additions and 16 deletions

View File

@@ -25,9 +25,15 @@ class Hookmanager
private $Mailer;
private $VirtualminHandler;
// Can be overloaded by child classes in order to add new features.W
// Can be overloaded by child classes in order to add new features.
// alert types are defined by wordpress.
protected $alertTypes =
[
"subscription_created",
@@ -47,11 +53,14 @@ class Hookmanager
public function __construct()
{
// TODO: Switch project to MVC structuring.
// This doesn't make much sense.
$this->Customer = new Customer();
$this->Renderview = new EmailRenderer();
$this->APITools = new ApplicationAPI();
$this->JsonHelper = new Json();
$this->VirtualminHandler = new VirtualminHandler();
$this->PackageController = new PackageController();
// Create mailer when needed
@@ -105,6 +114,8 @@ class Hookmanager
}
// The response and request method is passed by the redirecting method
// KISS and DRY might not apply here
// This method choses what to do based on the request's "intent".
private function redirectAlert(Request $Request, Response $response, $intent)
{
@@ -153,7 +164,7 @@ class Hookmanager
$this->JsonHelper->set
([
"status" => "fail",
"message" => "Error: Invalid alert type (Or middleman attack in-progress)",
"message" => "Error: Invalid alert type!",
"code" => 500
]);
@@ -171,19 +182,24 @@ class Hookmanager
// Return POST variable list in a structured array, DRY
private function getStructuredVariableList(Request $request)
{
$PDATA = $request->getParsedBody();
$dArr = $PDATA;
return $request->getParsedBody();
return $dArr;
}
// These methods below interact directly with the Virtualmin controller.
// args should also provide email and ip, not only plan
public function EventSubscriptionCreated(Request $request, Response $response, $args)
{
return $response->write($this->getStructuredVariableList($Request))->withStatus(200);
// Creates a subscription in the database.
// This method sends information directly to the virtualmin controller.
$combinedArguments = array_merge($this->PackageController->getDefaultOptionsArray(), $this->PackageController->selectPackage($args['package']));
$this->VirtualminHandler->CreateVirtualServer($domain, $password, $combinedArguments);
}
@@ -226,5 +242,10 @@ class Hookmanager
}
private function postProcessFor($domain, $password)
{
}
}