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

65 lines
1.8 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 AliasesEdit extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
$alias = $f3->get('PARAMS.alias');
$domain = $f3->get('PARAMS.domain');
if ($alias_array = $f3->call('\Panel::vGet', array("vmail-aliases-get.sh -a $alias -d $domain -c", FALSE))) {
$f3->set('alias_array', $alias_array["$alias"]);
}
}
static public function get($f3) {
echo \Template::instance()->render('vmail/aliases-edit.html');
}
function post($f3) {
/* run mod command here */
$alias = $f3->get('PARAMS.alias');
$domain = $f3->get('PARAMS.domain');
$alias_array = $_POST;
$f3->set('alias_array', $alias_array);
extract($alias_array);
$f3->call('\Panel::validateEmailLocalpart', array($alias));
/* check for validation errors */
if ($f3->exists('SESSION.messages')) {
$messages = $f3->get('SESSION.messages');
$messages[] = "Please make changes and re-submit the form to try again.";
$f3->set('SESSION.messages', $messages);
$f3->call('\Panel\Vmail\ForwardsEdit::get', $f3);
} else {
exec("/usr/local/bin/vmail-aliases-mod.sh -e $alias@$domain -f $alias -k $save_local", $output, $result_code);
if ($result_code == 0) {
$messages[] = "Success: Forwarding for $alias@$domain updated.";
$f3->set('SESSION.messages', $messages);
$f3->reroute("/Email/$domain/Accounts/$alias/Forwarding");
} else {
$messages[] = "Error.";
$f3->set('SESSION.messages', $messages);
$f3->call('\Panel\Vmail\ForwardsEdit::get', $f3);
}
}
}
}