* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) */ namespace Panel\Vmail; class ForwardsEdit extends \Panel\Vmail { function beforeRoute($f3) { parent::beforeRoute($f3); $mbox = $f3->get('PARAMS.mbox'); $domain = $f3->get('PARAMS.domain'); if ($forward_array = $f3->call('\Panel::vGet', array("vmail-forwards-get.sh -e $mbox@$domain -c", FALSE))) { $f3->set('forward_array', $forward_array[0]); } } static public function get($f3) { echo \Template::instance()->render('vmail/forwards-edit.html'); } function post($f3) { /* run mod command here */ $mbox = $f3->get('PARAMS.mbox'); $domain = $f3->get('PARAMS.domain'); $forward_array = $_POST; $f3->set('forward_array', $forward_array); extract($forward_array); $f3->call('\Panel::validateEmail', array($forward)); /* 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-forwards-mod.sh -e $mbox@$domain -f $forward -k $save_local", $output, $result_code); if ($result_code == 0) { $messages[] = "Success: Forwarding for $mbox@$domain updated."; $f3->set('SESSION.messages', $messages); $mapping = $f3->get('NAV.mapping'); if ($mapping == 'vmail') { $f3->reroute("/Accounts/$mbox/Forwarding"); } else { $f3->reroute("/Email/$domain/Accounts/$mbox/Forwarding"); } } else { $messages[] = "Error."; $f3->set('SESSION.messages', $messages); $f3->call('\Panel\Vmail\ForwardsEdit::get', $f3); } } } }