po/src/camera.edit.php

169 lines
6.7 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";
include_once "include/common.php";
$manufacturer_filter = pg_escape_string($database, isset($_REQUEST['filter']) ? $_REQUEST['filter'] : "");
$camera_id = pg_escape_string($database, array_key_exists('item', $_REQUEST) ? $_REQUEST['item'] : 0);
$database = site_prolog(PO_USER_TYPE_USER);
$type = 'camera';
$camera_current_value = pg_fetch_row(pg_query($database, "select name, model, variation, serial_number, date_of_purchase, purchased_new, url, access_rights, raw_icc_profile, users, ignore_comment
from view_camera where identifier=$camera_id"));
/* Ensure the user owns it !*/
if (($po_user['id'] != $camera_current_value[9]) &&
($po_user['type'] != PO_USER_TYPE_ADMIN)) {
site_referer_error('not_owner');
site_epilog($database);
exit();
}
$camera_type_current_value = pg_fetch_row(pg_query($database, "select type from camera where identifier=$camera_id"));
if ($camera_type_current_value == FALSE) {
$camera_type_current_value[0] = 0;
}
$manufacturer = get_generic_query_all($database, "select identifier, name from manufacturer order by name", 'manuf_all');
switch ($manufacturer_filter) {
case 'All':
case '':
$all_camera_types = pg_query($database, "select identifier, name, model, variation, url, raw_icc_profile from view_camera_type order by name");
break;
default:
$all_camera_types = pg_query($database, "select identifier, name, model, variation, url, raw_icc_profile
from view_camera_type where name='$manufacturer_filter' or identifier=$camera_type_current_value[0] order by name");
}
site_header(sprintf($strings['profile_edit'], $strings['generic_'.$type]));
site_navigator(6);
site_navigator_status(emit_a(generate_link('user', ''), $strings['generic_users'])." : ".emit_a("my.profile.php", $strings['generic_my_profile'])." : ".sprintf($strings['profile_edit'], $strings['generic_'.$type]), "");
theme_display_navigator_box_top($profile_data['camera']['idx'], $profile_data, "100%");
print "<form method=\"post\" action=\"camera.edit.2.php\" accept-charset=\"".$strings['formats_encoding']."\">";
print "<input type=\"hidden\" name=\"item_id\" value=\"$camera_id\">";
print "<table class=\"profile\">\n";
print emit_profile_manuf_combo("camera.edit.php?type=$type&amp;item=$camera_id", $type, 4, $manufacturer, $manufacturer_filter);
print "<tr>\n";
print emit_th("");
print emit_th($strings['profile_manufacturer'], "width=\"29%\"");
print emit_th($strings['profile_model'], "width=\"25%\"");
print emit_th($strings['profile_variation'], "width=\"21%\"");
print emit_th($strings['profile_icc_profile'], "width=\"21%\"");
print "</tr>\n";
$num_of_camera_types = pg_num_rows($all_camera_types);
if ($num_of_camera_types > 0) {
for ($i=0; $i < $num_of_camera_types; $i++) {
$camera_type = pg_fetch_row($all_camera_types, $i);
print "<tr>";
print emit_td(emit_radio_item("camera_type_id", $camera_type[0], $camera_type_current_value[0] == $camera_type[0]));
print "<td><a target=\"_new\" href=\"$camera_type[4]\">$camera_type[1]</a></td>";
print "<td>$camera_type[2]</td>";
print "<td>$camera_type[3]</td>";
if ($camera_type[5] != "") {
print "<td>" . $icc_profiles[$camera_type[5]]['name'] . "</td>";
} else {
print "<td></td>";
}
print "</tr>";
}
}
else
print "<tr><td colspan=\"6\">".sprintf($strings['profile_none_found'], $strings['generic_'.$type])."</td></tr>\n";
print "</table>\n";
print "<table class=\"profile\">\n";
print "<tr class=\"folder_top\">";
print "<td colspan=\"6\">".sprintf($strings['profile_edit_type'], $strings['generic_'.$type])."</td>\n";
print "</tr>";
print "<tr>\n";
print emit_th("");
print emit_th($strings['profile_manufacturer'], "width=\"29%\"");
print emit_th($strings['profile_model'], "width=\"25%\"");
print emit_th($strings['profile_variation'], "width=\"21%\"");
print emit_th($strings['profile_icc_profile'], "width=\"21%\"");
print "</tr>\n";
print "<tr>";
print emit_td(emit_radio_item("camera_type_id", "custom", false));
print "<td>";
print emit_manufacturer_combo('manufacturer_id', $manufacturer, $camera_current_value[0]);
print "</td>";
print "<td>";
print "<input type=\"text\" name=\"camera_model\" value=\"$camera_current_value[1]\" />";
print "</td>";
print "<td>";
print "<input type=\"text\" name=\"camera_variation\" value=\"$camera_current_value[2]\" />";
print "</td>";
print "<td>";
print emit_icc_profiles_combo("camera_icc_profile", $camera_current_value[8]);
print "</td>";
print "</tr>";
print "</table>\n";
print "<table class=\"profile\">\n";
print "<tr class=\"folder_top\"><td colspan=\"6\">".sprintf($strings['profile_specific_data'], $strings['generic_'.$type])."</td></tr>\n";
print "<tr>\n";
print emit_th($strings['profile_serial']);
print emit_th($strings['profile_purchased']);
print emit_th($strings['profile_new']);
print emit_th($strings['profile_ignore_comment']);
print emit_th($strings['generic_access']);
print "</tr>\n";
print "<tr>";
print "<td>";
print "<input type=\"text\" name=\"camera_serial_number\" value=\"$camera_current_value[3]\"/></td>";
$date_of_purchase= substr($camera_current_value[4], 0, 10);
print "<td>\n";
print emit_date_input_form("camera_purchase_timestamp", $date_of_purchase);
print "</td>\n";
print "<td>";
print emit_yes_no_combo("camera_purchased_new", $camera_current_value[5]);
print "</td>\n";
print "<td>";
print emit_yes_no_combo("camera_ignore_comment", $camera_current_value[10]);
print "</td>\n";
print "<td>";
print emit_access_combo("camera_access_rights", $camera_current_value[7], "");
print "</td>\n";
print "</tr>";
print "</table>";
print $thm_elem['button.save.changes'];
print $thm_elem['button.clear'];
print $thm_elem['button.cancel'];
print "</form>";
theme_display_navigator_box_bottom("100%");
site_footer($database);
site_epilog($database);
?>