vpanel-stack/panel/classes/Panel/Vmail/DomainsEdit.php

75 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2022-07-01 15:24:26 -07:00
<?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 DomainsEdit extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
$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]);
}
}
static function get($f3) {
$domain_array = $f3->get('domain_array');
/* convert data for frontend display */
foreach ($domain_array as $k=>$v) {
if ($domain_array['mbox_limit'] == "NULL") {
$domain_array['mbox_limit'] = 'Unlimited';
}
if ($domain_array['mbox_quota_default'] == "NULL") {
$domain_array['mbox_quota_default'] = 'Unlimited';
}
if ($domain_array['mbox_ratelimit_default'] == "NULL") {
$domain_array['mbox_ratelimit_default'] = 'Unlimited';
}
}
/* reset f3 domains_array with converted data */
$f3->set('domain_array', $domain_array);
echo \Template::instance()->render('vmail/domains-edit.html');
}
function post($f3) {
/* run mod command here */
$domain = $f3->get('PARAMS.domain');
$domain_array = $_POST;
$f3->set('domain_array', $domain_array);
foreach ($domain_array as $k=>$v) {
if (strtolower($v) == 'unlimited') {
$domain_array[$k] = 'NULL';
}
}
extract($domain_array);
/* run domain mod command */
exec("/usr/local/bin/vmail-domains-mod.sh -d $domain -s $status -l $mbox_limit -q $mbox_quota_default -r $mbox_ratelimit_default", $output, $result_code);
$messages[] = "Email domain '$domain' has been updated.";
$f3->set('SESSION.messages', $messages);
$f3->reroute("/Email/$domain");
}
}