po/src/manufacturer.edit.2.php

56 lines
2.1 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/profile.php";
include_once "include/site.php";
$manufacturer_id = pg_escape_string($database, $_REQUEST['manufacturer']);
$manufacturer_name = pg_escape_string($database, $_REQUEST['manufacturer_name']);
$manufacturer_url = pg_escape_string($database, $_REQUEST['manufacturer_url']);
$database = site_prolog(PO_USER_TYPE_USER);
if (($manufacturer_id!="") && ($manufacturer_name!="")) {
if ($po_user['type'] != PO_USER_TYPE_ADMIN) {
$result = pg_fetch_row(pg_query($database, "select count(identifier) from manufacturer where identifier=$manufacturer_id and last_modifying_users=$po_user[id]"));
if ($result[0] == 0) {
site_epilog($database);
site_push_error($strings['errors_not_owner']);
header("Location: my.profile.php?selector=".$profile_data['manufacturer']['idx']);
exit();
}
}
$result = pg_query($database, "update manufacturer set name='$manufacturer_name', url='$manufacturer_url' where identifier='$manufacturer_id'");
if (!$result) {
site_push_error($strings['errors_db_insert_failed']);
}
}
if ($memcache) {
po_log("memcache: del manuf_all", PEAR_LOG_DEBUG);
$memcache->delete("manuf_all");
}
site_epilog($database);
header("Location: my.profile.php?selector=".$profile_data['manufacturer']['idx']);
?>