1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2004-11-06 21:12:59 +0000 (Sat, 06 Nov 2004) $ |
---|
10 | // | last modifier : $Author: z0rglub $ |
---|
11 | // | revision : $Revision: 593 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | include_once( './admin/include/isadmin.inc.php' ); |
---|
28 | //----------------------------------------------------- template initialization |
---|
29 | $sub = $vtp->Open( './template/'.$user['template'].'/admin/group_perm.vtp' ); |
---|
30 | $error = array(); |
---|
31 | $tpl = array( 'permuser_authorized','permuser_forbidden','submit', |
---|
32 | 'permuser_parent_forbidden','permuser_info_message', |
---|
33 | 'adduser_info_back','permuser_only_private' ); |
---|
34 | templatize_array( $tpl, 'lang', $sub ); |
---|
35 | $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); |
---|
36 | //--------------------------------------------------------------------- updates |
---|
37 | if ( isset( $_POST['submit'] ) ) |
---|
38 | { |
---|
39 | // cleaning the user_access table for this group |
---|
40 | $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; |
---|
41 | $query.= ' WHERE group_id = '.$_GET['group_id']; |
---|
42 | $query.= ';'; |
---|
43 | pwg_query( $query ); |
---|
44 | // selecting all private categories |
---|
45 | $query = 'SELECT id'; |
---|
46 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
47 | $query.= " WHERE status = 'private'"; |
---|
48 | $query.= ';'; |
---|
49 | $result = pwg_query( $query ); |
---|
50 | while ( $row = mysql_fetch_array( $result ) ) |
---|
51 | { |
---|
52 | $radioname = 'access-'.$row['id']; |
---|
53 | if ( $_POST[$radioname] == 0 ) |
---|
54 | { |
---|
55 | $query = 'INSERT INTO '.PREFIX_TABLE.'group_access'; |
---|
56 | $query.= ' (group_id,cat_id) VALUES'; |
---|
57 | $query.= ' ('.$_GET['group_id'].','.$row['id'].')'; |
---|
58 | $query.= ';'; |
---|
59 | pwg_query ( $query ); |
---|
60 | } |
---|
61 | } |
---|
62 | // checking users favorites |
---|
63 | $query = 'SELECT id'; |
---|
64 | $query.= ' FROM '.USERS_TABLE; |
---|
65 | $query.= ';'; |
---|
66 | $result = pwg_query( $query ); |
---|
67 | while ( $row = mysql_fetch_array( $result ) ) |
---|
68 | { |
---|
69 | check_favorites( $row['id'] ); |
---|
70 | } |
---|
71 | // synchronization of calculated data |
---|
72 | synchronize_group( $_GET['group_id'] ); |
---|
73 | // confirmation display |
---|
74 | $vtp->addSession( $sub, 'confirmation' ); |
---|
75 | $url = './admin.php?page=group_list'; |
---|
76 | $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) ); |
---|
77 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
78 | } |
---|
79 | //---------------------------------------------------------------- form display |
---|
80 | $restrictions = get_group_restrictions( $_GET['group_id'] ); |
---|
81 | $action = './admin.php?page=group_perm&group_id='.$_GET['group_id']; |
---|
82 | $vtp->setVar( $sub, 'action', add_session_id( $action ) ); |
---|
83 | // only private categories are listed |
---|
84 | $query = 'SELECT id'; |
---|
85 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
86 | $query.= " WHERE status = 'private'"; |
---|
87 | $query.= ';'; |
---|
88 | $result = pwg_query( $query ); |
---|
89 | while ( $row = mysql_fetch_array( $result ) ) |
---|
90 | { |
---|
91 | $vtp->addSession( $sub, 'category' ); |
---|
92 | $vtp->setVar( $sub, 'category.id', $row['id'] ); |
---|
93 | $url = './admin.php?page=cat_perm&cat_id='.$row['id']; |
---|
94 | $vtp->setVar( $sub, 'category.cat_perm_link', add_session_id( $url ) ); |
---|
95 | // Is the group allowed to access this category |
---|
96 | $is_group_allowed = is_group_allowed( $row['id'], $restrictions ); |
---|
97 | if ( $is_group_allowed == 0 ) |
---|
98 | { |
---|
99 | $vtp->setVar( $sub, 'category.color', 'green' ); |
---|
100 | } |
---|
101 | else |
---|
102 | { |
---|
103 | $vtp->setVar( $sub, 'category.color', 'red' ); |
---|
104 | } |
---|
105 | // category name |
---|
106 | $cat_infos = get_cat_info( $row['id'] ); |
---|
107 | $name = get_cat_display_name( $cat_infos['name'],' > ', |
---|
108 | 'font-weight:bold;' ); |
---|
109 | $vtp->setVar( $sub, 'category.name', $name ); |
---|
110 | // any subcat forbidden for this group ? |
---|
111 | if ( $is_group_allowed == 2 ) |
---|
112 | { |
---|
113 | $vtp->addSession( $sub, 'parent_forbidden' ); |
---|
114 | $vtp->closeSession( $sub, 'parent_forbidden' ); |
---|
115 | } |
---|
116 | // forbidden or authorized access ? |
---|
117 | if ( $is_group_allowed == 0 or $is_group_allowed == 2 ) |
---|
118 | { |
---|
119 | $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' ); |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' ); |
---|
124 | } |
---|
125 | $vtp->closeSession( $sub, 'category' ); |
---|
126 | } |
---|
127 | //----------------------------------------------------------- sending html code |
---|
128 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
129 | ?> |
---|