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

51 lines
1.2 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 ForwardsDelete extends \Panel\Vmail {
function beforeRoute($f3) {
parent::beforeRoute($f3);
}
static function get($f3) {
$f3->set('confirm', 'true');
echo \Template::instance()->render('vmail/forwards-delete.html');
}
function post($f3) {
/* run delete command here */
$domain = $f3->get('PARAMS.domain');
$mbox = $f3->get('PARAMS.mbox');
$messages = array();
exec("/usr/local/bin/vmail-forwards-del.sh -e $mbox@$domain", $output, $result_code);
$result_code = 0;
if ($result_code == 0) {
$messages[] = "Forward for email account '$mbox@$domain' has been deleted.";
} else {
$messages[] = "Error deleting forwarding for email account '$mbox@$domain'.";
}
$f3->set('SESSION.messages', $messages);
$mapping = $f3->get('NAV.mapping');
if ($mapping == 'vmail') {
$f3->reroute("/Accounts/$mbox");
} else {
$f3->reroute("/Email/$domain/Accounts/$mbox");
}
}
}