po/src/admin.user.edit.2.php

89 lines
3.6 KiB
PHP

<?php
// Copyright (C) 2002-2006 Balint Kis (balint@k-i-s.net)
// Copyright (C) 2005-2013 Solomon Peachy (pizza@shaftnet.org)
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
include_once "include/config.php";
include_once "include/mail.php";
include_once "include/site.php";
include_once "include/admin.php";
include_once "include/common.php";
$database = site_prolog(PO_USER_TYPE_ADMIN);
$auth_handle = new $po_auth();
$user_id = pg_escape_string($database, $_REQUEST['user']);
$type = pg_escape_string($database, $_REQUEST['type']);
$email = pg_escape_string($database, $_REQUEST['email']);
$username = pg_escape_string($database, $_REQUEST['username']);
$hide = pg_escape_string($database, $_REQUEST['hide']);
$bulk_upload_enable = pg_escape_string($database, $_REQUEST['bulk_upload_enable']);
$local_print_enable = pg_escape_string($database, $_REQUEST['local_print_enable']);
$quota_size = pg_escape_string($database, $_REQUEST['quota_size']);
$quota_count = pg_escape_string($database, $_REQUEST['quota_count']);
$show_ads = pg_escape_string($database, $_REQUEST['show_ads']);
$local_path = pg_escape_string($database, $_REQUEST['local_path']);
$password_1 = pg_escape_string($database, $_REQUEST['password_1']);
$password_2 = pg_escape_string($database, $_REQUEST['password_2']);
$quota_size = $quota_size * 1048576;
if ($password_1 || $password_2) {
if (($password_2 != $password_1) ||
($password_2 == "") ||
($password_1 == "")) {
site_push_error($strings['errors_password_mismatch']);
} else {
if ($auth_handle->can_change_pass === TRUE) {
if ($auth_handle->force_change_pass($username, $password_1) === FALSE) {
site_push_error($strings['errors_password_change_failed']);
}
}
}
}
pg_query($database, "begin");
$result = pg_query($database, "update users set type='$type', hide='$hide', username='$username' where identifier='$user_id'");
if ($result)
$result = store_user_pref($database, $user_id, 'quota_size', $quota_size);
if ($result)
$result = store_user_pref($database, $user_id, 'quota_count', $quota_count);
if ($result)
$result = store_user_pref($database, $user_id, 'bulk_upload_enable', $bulk_upload_enable);
if ($result)
$result = store_user_pref($database, $user_id, 'show_ads', $show_ads);
if ($result)
$result = store_user_pref($database, $user_id, 'local_bulk_upload_path', $local_path);
if ($result)
$result = store_user_pref($database, $user_id, 'local_print', $local_print_enable);
if ($result)
$result = pg_query($database, "update users set email='$email' where identifier = $user_id");
if ($result) {
pg_query($database, "commit");
send_po_account_change_notification($database, $user_id);
} else {
site_push_error($strings['errors_db_insert_failed']);
pg_query($database, "rollback");
site_epilog($database);
}
site_epilog($database);
header("Location: admin.php?selector=".$admin_data['users_n_clients']['idx']);
?>