50f811e5ec
Fixes #7
115 lines
3.0 KiB
PHP
115 lines
3.0 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['vmin-url'];
|
|
$username = $cConfigArray['username'];
|
|
$password = $cConfigArray['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.
|
|
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));
|
|
}
|
|
|
|
}
|
|
|
|
|