aboutsummaryrefslogtreecommitdiffstats
path: root/admin/edit_cat.php
blob: c813bac6619c8715d00c5d3e9cbb4cb78d2d8f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/***************************************************************************
 *                edit_cat.php is a part of PhpWebGallery                  *
 *                            -------------------                          *
 *   last update          : Tuesday, July 16, 2002                         *
 *   email                : pierrick@z0rglub.com                           *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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;                                         *
 *                                                                         *
 ***************************************************************************/
	include_once( "./include/isadmin.inc.php" );
	
	if ( $HTTP_GET_VARS['valider'] == 1 )
	{
		$query = "update PREFIX_TABLE"."categories ";
		if ( $HTTP_POST_VARS['name'] == "" )
		{
			$query.= "set name = NULL, ";
		}
		else
		{
			$query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS['name'], ENT_QUOTES)."', ";
		}
		if ( $HTTP_POST_VARS['comment'] == "" )
		{
			$query.= "comment = NULL, ";
		}
		else
		{
			$query.= "comment = '".htmlspecialchars( $HTTP_POST_VARS['comment'], ENT_QUOTES )."', ";
		}
		$query.= "status = '".$HTTP_POST_VARS['status']."' ";
		$query.= "where id = '".$HTTP_GET_VARS['cat']."';";
		mysql_query( $query );
		
		$result = mysql_query( "select id from PREFIX_TABLE"."users where pseudo != '".$conf['webmaster']."';" );
		while ( $row = mysql_fetch_array ( $result ) )
		{
			check_favorites( $row['id'] );
		}
		
		echo"<div style=\"color:red;text-align:center;\">".$lang['editcat_confirm']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=cat" )."\">".$lang['editcat_back']."</a> ]</div>";		
	}
	
	echo "
	<form action=\"".add_session_id_to_url( "./admin.php?page=edit_cat&amp;cat=".$HTTP_GET_VARS['cat']."&amp;valider=1" )."\" method=\"post\">
		<table style=\"width:100%;\">";
	$query = "select a.id,name,dir,status,comment,id_uppercat,site_id,galleries_url";
	$query.= " from PREFIX_TABLE"."categories as a, PREFIX_TABLE"."sites as b";
	$query.= " where a.id = ".$HTTP_GET_VARS['cat'];
	$query.= " and a.site_id = b.id;";
	$row = mysql_fetch_array( mysql_query( $query ) );
	$result = get_cat_info( $row['id'] );
	$array_cat_names = $result['name'];
	echo "
			<tr>
				<th colspan=\"2\">".$lang['editcat_title1']." ".$lang['category']." \"".get_cat_display_name( $array_cat_names, " - ", "font-style:italic;" )."\" [ dir : ".$row['dir']." ]</th>
			</tr>";
	if ( $row['site_id'] != 1 )
	{
		echo "
			<tr>
				<td style=\"width:20%;\">Server</td>
				<td class=\"row2\">".$row['galleries_url']."</td>
			</tr>";
	}
	echo "
			<tr>
				<td style=\"width:20%;\">".$lang['editcat_name']."</td>
				<td class=\"row2\"><input type=\"text\" name=\"name\" value=\"".$row['name']."\" maxlength=\"255\"/></td>
			</tr>
			<tr>
				<td style=\"width:20%;\">".$lang['editcat_comment']."</td>
				<td class=\"row2\"><textarea name=\"comment\" rows=\"5\" cols=\"50\" style=\"overflow:auto\">".$row['comment']."</textarea></td>
			</tr>
			<tr>
				<td style=\"width:20%;\">".$lang['editcat_status']."</td>
				<td class=\"row2\">
					<select name=\"status\">";
	// on r�cup�re toutes les status possibles dans la base 
	// par l'interm�diaire de la fonction get_enums trouvable 
	// dans le fichier config.php
	$option = get_enums( PREFIX_TABLE."categories", "status" );
	for ( $i = 0; $i < sizeof( $option ); $i++ )
	{
		if ( $option[$i] == $row['status'] )
		{
			echo"
						<option selected>$option[$i]</option>";
		}
		else
		{
			echo"
						<option>$option[$i]</option>";
		}
	}
	echo"
					</select>
					".$lang['editcat_status_info']."
				</td>
			</tr>
			<tr>
				<td colspan=\"2\">&nbsp;</td>
			</tr>
			<tr>
				<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td>
			</tr>
		</table>
	</form>";
?>