vpanel-stack/panel/classes/Panel/Vmail/Domains.php
Matthew Saunders Brown fd94a4e3c4 initial commit
2022-07-01 15:24:26 -07:00

75 lines
2.0 KiB
PHP

<?php
/**
* vpanel-stack
* https://git.stack-source.com/msb/vpanel-stack
* Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
*/
namespace Panel\Vmail;
class Domains extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
if ($f3->exists('PARAMS.domain')) {
$domain = $f3->get('PARAMS.domain');
if ($domain_array = $f3->call('\Panel::vGet', array("vmail-domains-get.sh -d $domain -c", FALSE))) {
$f3->set('domain_array', $domain_array[0]);
}
} else {
if ($domains_array = $f3->call('\Panel::vGet', array("vmail-domains-get.sh -c", FALSE))) {
$f3->set('domains_array', $domains_array);
}
}
}
static function get($f3) {
if ($f3->exists('PARAMS.domain')) {
$domain_array = $f3->get('domain_array');
/* convert data for frontend display */
if ($domain_array['status'] == 1) {
$domain_array['status'] = 'Enabled';
} else {
$domain_array['status'] = 'Disabled';
}
if ($domain_array['mbox_limit'] == "NULL") {
$domain_array['mbox_limit'] = 'Unlimited';
}
if ($domain_array['mbox_quota_default'] == "NULL") {
$domain_array['mbox_quota_default'] = 'Unlimited';
} else {
$domain_array['mbox_quota_default'] .= ' GB';
}
if ($domain_array['mbox_ratelimit_default'] == "NULL") {
$domain_array['mbox_ratelimit_default'] = 'Unlimited';
} else {
$domain_array['mbox_ratelimit_default'] .= ' emails per hour';
}
$f3->set('domain_array', $domain_array);
$domain = $f3->get('PARAMS.domain');
$f3->set('page_header', "Email Domain $domain");
echo \Template::instance()->render('vmail/domains-domain.html');
} else {
$f3->set('page_header', "Email Domains");
echo \Template::instance()->render('vmail/domains.html');
}
}
}