spacejewel-ipn-communication/source/defs/Virtualmin/Virtualmin.php
Miguel Nogueira c3f882960c Change wrong DSN name for db wrapper and update config class
This commit changes how the config class gets it's values to a more solid way.
Additonally, the DSN was updated to use a correct format, allowing PDO to connect (With a wrong DSN, it tries to connect to something that doesn't exist).
2018-06-08 18:58:48 +00:00

115 lines
3.1 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.
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));
}
}