116 lines
3.2 KiB
PHP
116 lines
3.2 KiB
PHP
<?php
|
|
|
|
use \HnhDigital\Virtualmin as Virtualmin;
|
|
|
|
// This class serves as a mini wrapper to HnhDigital's wrapper class.
|
|
// It takes the methods it needs and proxies them for applicational use.
|
|
class VirtualminHandler
|
|
{
|
|
private $virtualmin;
|
|
|
|
public function __construct()
|
|
{
|
|
$Config = new Config();
|
|
$cConfigArray = $Config->getConfig();
|
|
|
|
$url = $cConfigArray['virtualmin']['vmin-url'];
|
|
$username = $cConfigArray['virtualmin']['username'];
|
|
$password = $cConfigArray['virtualmin']['password'];
|
|
|
|
$this->virtualmin = new Virtualmin\VirtualServersClient($url, $username, $password);
|
|
}
|
|
|
|
// Creates a domain with the specified password. The username will be the domain with the .tld removed.
|
|
// The features array will be populated when the method is exposed with the correct package name provided.
|
|
// Note: the features array contains the numerical ID of the chosen plan.
|
|
public function CreateVirtualServer($DomainName, $Password, Array $Features = [])
|
|
{
|
|
return $this->virtualmin->create($DomainName, $Password, $Features);
|
|
}
|
|
|
|
public function DeleteVirtualServer($DomainName)
|
|
{
|
|
|
|
|
|
return $this->virtualmin->delete($DomainName);
|
|
|
|
}
|
|
|
|
// NOTICE! This deletes all domain names linked to a user account. This action is IRREVERSIBLE!
|
|
public function DeleteAllFromUser($User)
|
|
{
|
|
|
|
return $this->virtualmin->deleteByUser($User);
|
|
|
|
}
|
|
|
|
public function SuspendVirtualServer($DomainName, $SuspensionReason)
|
|
{
|
|
// TODO: Flag account as inactive within system's database (At Hookmanager class)
|
|
|
|
return $this->virtualmin->suspend($DomainName, $SuspensionReason);
|
|
|
|
}
|
|
|
|
|
|
public function DisableFeature($DomainName, $FeatureName)
|
|
{
|
|
|
|
return $this->virtualmin->disableFeatureByDomain($DomainName, $FeatureName);
|
|
|
|
}
|
|
|
|
// Deattaches all features from all domains by this user
|
|
public function DisableFeaturesByUser($Username, $Features)
|
|
{
|
|
|
|
return $this->virtualmin->disableFeatureByUser($Username, $Feature);
|
|
|
|
}
|
|
|
|
public function DisableFeatureFromAllDomains($FeatureName)
|
|
{
|
|
|
|
|
|
return $this->virtualmin->disableFeatureAllDomains($Feature);
|
|
|
|
}
|
|
|
|
|
|
public function EnableFeatureByDomain($Domain, $Feature)
|
|
{
|
|
|
|
return $this->virtualmin->enableFeatureByDomain($Domain, $Feature);
|
|
|
|
}
|
|
|
|
public function enableFeatureByUser($User, $Feature)
|
|
{
|
|
|
|
return $this->virtualmin->enableFeatureByUser($User, $Feature);
|
|
|
|
}
|
|
|
|
public function enableFeatureAllDomains($Feature)
|
|
{
|
|
|
|
return $this->virtualmin->enableFeatureAllDomains($Feature);
|
|
|
|
}
|
|
|
|
// SPECIAL: GDPR READINESS
|
|
|
|
// This
|
|
public function modifyDomain($Domain, Array $ModifiableOptions)
|
|
{
|
|
$optionsArr =
|
|
[
|
|
"domain" => $Domain
|
|
];
|
|
return $this->virtualmin->modifyDomain(array_merge($optionsArr, $ModifiableOptions));
|
|
}
|
|
|
|
}
|
|
|
|
|