2013-11-10 23:22:22 +01:00
|
|
|
<?php
|
2015-04-07 01:09:58 +02:00
|
|
|
/**
|
|
|
|
* Postfix Admin
|
|
|
|
*
|
|
|
|
* LICENSE
|
|
|
|
* This source file is subject to the GPL license that is bundled with
|
|
|
|
* this package in the file LICENSE.TXT
|
|
|
|
*
|
|
|
|
* Further details on the project are available at http://postfixadmin.sf.net
|
|
|
|
*
|
|
|
|
* @version $Id$
|
|
|
|
* @license GNU GPL v2 or later.
|
|
|
|
*
|
2022-10-12 17:46:15 +02:00
|
|
|
* File: editactive.php
|
|
|
|
* Used to switch active status for admins, domains, mailboxes, aliases and aliasdomains, etc.
|
2013-11-10 23:22:22 +01:00
|
|
|
*
|
2022-10-12 21:41:14 +02:00
|
|
|
* Template File:
|
2022-10-18 23:19:36 +02:00
|
|
|
* none - redirects to $formconf['listview']
|
2013-11-10 23:22:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('common.php');
|
|
|
|
|
2018-01-26 15:45:57 +01:00
|
|
|
if (safeget('token') != $_SESSION['PFA_token']) {
|
|
|
|
die('Invalid token!');
|
|
|
|
}
|
2013-11-10 23:22:22 +01:00
|
|
|
|
|
|
|
$username = authentication_get_username(); # enforce login
|
|
|
|
|
2020-11-09 22:40:52 +01:00
|
|
|
$id = safeget('id');
|
|
|
|
$table = safeget('table');
|
2024-01-07 15:25:17 +01:00
|
|
|
$field = safeget('field');
|
2013-11-10 23:22:22 +01:00
|
|
|
$active = safeget('active');
|
2024-01-07 15:25:17 +01:00
|
|
|
if ($field === '') $field = 'active';
|
2013-11-10 23:22:22 +01:00
|
|
|
|
2020-11-09 22:40:52 +01:00
|
|
|
if (empty($table)) {
|
|
|
|
die("Invalid table name given");
|
|
|
|
}
|
|
|
|
|
2013-11-10 23:22:22 +01:00
|
|
|
$handlerclass = ucfirst($table) . 'Handler';
|
|
|
|
|
2018-01-26 15:45:57 +01:00
|
|
|
if (!preg_match('/^[a-z]+$/', $table) || !file_exists(dirname(__FILE__) . "/../model/$handlerclass.php")) { # validate $table
|
|
|
|
die("Invalid table name given!");
|
2013-11-10 23:22:22 +01:00
|
|
|
}
|
|
|
|
|
2015-04-07 01:09:58 +02:00
|
|
|
$handler = new $handlerclass(0, $username);
|
2013-11-10 23:22:22 +01:00
|
|
|
|
|
|
|
$formconf = $handler->webformConfig();
|
|
|
|
|
|
|
|
authentication_require_role($formconf['required_role']);
|
|
|
|
|
|
|
|
if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-)
|
2024-01-07 15:25:17 +01:00
|
|
|
if ($table == 'mailbox') {
|
|
|
|
if ($field != 'active' && $field != 'smtp_active') {
|
|
|
|
die(Config::Lang('invalid_parameter'));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($field != 'active') {
|
|
|
|
die(Config::Lang('invalid_parameter'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-10 23:22:22 +01:00
|
|
|
if ($active != '0' && $active != '1') {
|
|
|
|
die(Config::Lang('invalid_parameter'));
|
|
|
|
}
|
|
|
|
|
2024-01-07 15:25:17 +01:00
|
|
|
if ($handler->set(array($field => $active))) {
|
2020-09-25 22:43:34 +02:00
|
|
|
$handler->save();
|
2013-11-10 23:22:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flash_error($handler->errormsg);
|
|
|
|
flash_info($handler->infomsg);
|
|
|
|
|
2022-07-30 22:23:57 +02:00
|
|
|
if ($formconf['listview'] == 'list-virtual.php') {
|
|
|
|
$bits = [];
|
|
|
|
$bits['domain'] = $_SESSION['list-virtual:domain'] ?? null;
|
|
|
|
$bits['limit'] = $_SESSION['list-virtual:limit'] ?? null;
|
|
|
|
header("Location: " . $formconf['listview'] . '?' . http_build_query(array_filter($bits)));
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2018-01-26 15:45:57 +01:00
|
|
|
header("Location: " . $formconf['listview']);
|
2013-11-10 23:22:22 +01:00
|
|
|
exit;
|
|
|
|
|
|
|
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|