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

55 lines
1.3 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 AliasesDelete extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
/* verify alias exists */
$alias = $f3->get('PARAMS.alias');
$domain = $f3->get('PARAMS.domain');
$f3->call('\Panel::vGet', array("vmail-aliases-get.sh -a $alias -d $domain -c"));
}
static function get($f3) {
$f3->set('confirm', 'true');
echo \Template::instance()->render('vmail/aliases-delete.html');
}
function post($f3) {
/* run delete command here */
$domain = $f3->get('PARAMS.domain');
$alias = $f3->get('PARAMS.alias');
$messages = array();
exec("/usr/local/bin/vmail-aliases-del.sh -a $alias -d $domain", $output, $result_code);
if ($result_code == 0) {
$messages[] = "Alias '$alias@$domain' has been deleted.";
} else {
$messages[] = "Error deleting alias '$alias@$domain'.";
}
$f3->set('SESSION.messages', $messages);
2023-03-30 10:15:35 -07:00
$mapping = $f3->get('NAV.mapping');
if ($mapping == 'vmail') {
$f3->reroute("/Aliases");
} else {
$f3->reroute("/Email/$domain/Aliases");
}
2022-07-01 15:24:26 -07:00
}
}