1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * edit_cat.php * |
---|
4 | * ------------------- * |
---|
5 | * application : PhpWebGallery 1.3 * |
---|
6 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
7 | * * |
---|
8 | ***************************************************************************/ |
---|
9 | |
---|
10 | /*************************************************************************** |
---|
11 | * * |
---|
12 | * This program is free software; you can redistribute it and/or modify * |
---|
13 | * it under the terms of the GNU General Public License as published by * |
---|
14 | * the Free Software Foundation; * |
---|
15 | * * |
---|
16 | ***************************************************************************/ |
---|
17 | |
---|
18 | include_once( './include/isadmin.inc.php' ); |
---|
19 | //----------------------------------------------------- template initialization |
---|
20 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/edit_cat.vtp' ); |
---|
21 | $tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1', |
---|
22 | 'editcat_name', 'editcat_comment', 'editcat_status', |
---|
23 | 'editcat_status_info', 'submit' ); |
---|
24 | templatize_array( $tpl, 'lang', $sub ); |
---|
25 | //--------------------------------------------------------- form criteria check |
---|
26 | if ( isset( $_POST['submit'] ) ) |
---|
27 | { |
---|
28 | $query = 'UPDATE '.PREFIX_TABLE.'categories'; |
---|
29 | if ( $_POST['name'] == '' ) |
---|
30 | { |
---|
31 | $query.= ' SET name = NULL'; |
---|
32 | } |
---|
33 | else |
---|
34 | { |
---|
35 | $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'"; |
---|
36 | } |
---|
37 | if ( $_POST['comment'] == '' ) |
---|
38 | { |
---|
39 | $query.= ', comment = NULL'; |
---|
40 | } |
---|
41 | else |
---|
42 | { |
---|
43 | $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'"; |
---|
44 | } |
---|
45 | $query.= ", status = '".$_POST['status']."'"; |
---|
46 | $query.= " WHERE id = '".$_GET['cat']."'"; |
---|
47 | $query.= ';'; |
---|
48 | mysql_query( $query ); |
---|
49 | |
---|
50 | $query = 'SELECT id'; |
---|
51 | $query.= ' FROM '.PREFIX_TABLE.'users'; |
---|
52 | $query.= " WHERE username != '".$conf['webmaster']."'"; |
---|
53 | $query.= ';'; |
---|
54 | $result = mysql_query( $query ); |
---|
55 | while ( $row = mysql_fetch_array ( $result ) ) |
---|
56 | { |
---|
57 | check_favorites( $row['id'] ); |
---|
58 | } |
---|
59 | $vtp->addSession( $sub, 'confirmation' ); |
---|
60 | $url = add_session_id( './admin.php?page=cat' ); |
---|
61 | $vtp->setVar( $sub, 'confirmation.back_url', $url ); |
---|
62 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
63 | } |
---|
64 | //------------------------------------------------------------------------ form |
---|
65 | $form_action = './admin.php?page=edit_cat&cat='.$_GET['cat']; |
---|
66 | $vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) ); |
---|
67 | |
---|
68 | $query = 'SELECT a.id,name,dir,status,comment'; |
---|
69 | $query.= ',id_uppercat,site_id,galleries_url'; |
---|
70 | $query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b'; |
---|
71 | $query.= ' WHERE a.id = '.$_GET['cat']; |
---|
72 | $query.= ' AND a.site_id = b.id'; |
---|
73 | $query.= ';'; |
---|
74 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
75 | $result = get_cat_info( $row['id'] ); |
---|
76 | |
---|
77 | $cat_name = get_cat_display_name( $result['name'], ' - ', '' ); |
---|
78 | $vtp->setVar( $sub, 'cat:name', $cat_name ); |
---|
79 | $vtp->setVar( $sub, 'cat:dir', $row['dir'] ); |
---|
80 | if ( $row['site_id'] != 1 ) |
---|
81 | { |
---|
82 | $vtp->addSession( $sub, 'server' ); |
---|
83 | $vtp->setVar( $sub, 'server.url', $row['galleries_url'] ); |
---|
84 | $vtp->closeSession( $sub, 'server' ); |
---|
85 | } |
---|
86 | $vtp->setVar( $sub, 'name', $row['name'] ); |
---|
87 | $vtp->setVar( $sub, 'comment', $row['comment'] ); |
---|
88 | $options = get_enums( PREFIX_TABLE.'categories', 'status' ); |
---|
89 | foreach ( $options as $option ) { |
---|
90 | $vtp->addSession( $sub, 'status_option' ); |
---|
91 | $vtp->setVar( $sub, 'status_option.option', $option ); |
---|
92 | if ( $option == $row['status'] ) |
---|
93 | { |
---|
94 | $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' ); |
---|
95 | } |
---|
96 | $vtp->closeSession( $sub, 'status_option' ); |
---|
97 | } |
---|
98 | //----------------------------------------------------------- sending html code |
---|
99 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
100 | ?> |
---|