1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * group_perm.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 | include_once( './include/isadmin.inc.php' ); |
---|
18 | //----------------------------------------------------- template initialization |
---|
19 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/group_perm.vtp' ); |
---|
20 | $error = array(); |
---|
21 | $tpl = array( 'permuser_authorized','permuser_forbidden','submit', |
---|
22 | 'permuser_parent_forbidden','permuser_info_message', |
---|
23 | 'adduser_info_back' ); |
---|
24 | templatize_array( $tpl, 'lang', $sub ); |
---|
25 | //--------------------------------------------------------------------- updates |
---|
26 | if ( isset( $_POST['submit'] ) ) |
---|
27 | { |
---|
28 | // cleaning the user_access table for this group |
---|
29 | $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; |
---|
30 | $query.= ' WHERE group_id = '.$_GET['group_id']; |
---|
31 | $query.= ';'; |
---|
32 | mysql_query( $query ); |
---|
33 | // selecting all private categories |
---|
34 | $query = 'SELECT id'; |
---|
35 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
36 | $query.= " WHERE status = 'private'"; |
---|
37 | $query.= ';'; |
---|
38 | $result = mysql_query( $query ); |
---|
39 | while ( $row = mysql_fetch_array( $result ) ) |
---|
40 | { |
---|
41 | $radioname = 'access-'.$row['id']; |
---|
42 | if ( $_POST[$radioname] == 0 ) |
---|
43 | { |
---|
44 | $query = 'INSERT INTO '.PREFIX_TABLE.'group_access'; |
---|
45 | $query.= ' (group_id,cat_id) VALUES'; |
---|
46 | $query.= ' ('.$_GET['group_id'].','.$row['id'].')'; |
---|
47 | $query.= ';'; |
---|
48 | mysql_query ( $query ); |
---|
49 | } |
---|
50 | } |
---|
51 | $vtp->addSession( $sub, 'confirmation' ); |
---|
52 | $url = './admin.php?page=group_list'; |
---|
53 | $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) ); |
---|
54 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
55 | } |
---|
56 | //---------------------------------------------------------------- form display |
---|
57 | $restrictions = get_group_restrictions( $_GET['group_id'] ); |
---|
58 | $action = './admin.php?page=group_perm&group_id='.$_GET['group_id']; |
---|
59 | $vtp->setVar( $sub, 'action', add_session_id( $action ) ); |
---|
60 | // only private categories are listed |
---|
61 | $query = 'SELECT id'; |
---|
62 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
63 | $query.= " WHERE status = 'private'"; |
---|
64 | $query.= ';'; |
---|
65 | $result = mysql_query( $query ); |
---|
66 | while ( $row = mysql_fetch_array( $result ) ) |
---|
67 | { |
---|
68 | $vtp->addSession( $sub, 'category' ); |
---|
69 | $vtp->setVar( $sub, 'category.id', $row['id'] ); |
---|
70 | // Is the group allowed to access this category |
---|
71 | $is_group_allowed = is_group_allowed( $row['id'], $restrictions ); |
---|
72 | if ( $is_group_allowed == 0 ) |
---|
73 | { |
---|
74 | $vtp->setVar( $sub, 'category.color', 'green' ); |
---|
75 | } |
---|
76 | else |
---|
77 | { |
---|
78 | $vtp->setVar( $sub, 'category.color', 'red' ); |
---|
79 | } |
---|
80 | // category name |
---|
81 | $cat_infos = get_cat_info( $row['id'] ); |
---|
82 | $name = get_cat_display_name( $cat_infos['name'],' > ', |
---|
83 | 'font-weight:bold;' ); |
---|
84 | $vtp->setVar( $sub, 'category.name', $name ); |
---|
85 | // any subcat forbidden for this group ? |
---|
86 | if ( $is_group_allowed == 2 ) |
---|
87 | { |
---|
88 | $vtp->addSession( $sub, 'parent_forbidden' ); |
---|
89 | $vtp->closeSession( $sub, 'parent_forbidden' ); |
---|
90 | } |
---|
91 | // forbidden or authorized access ? |
---|
92 | if ( $is_group_allowed == 0 or $is_group_allowed == 2 ) |
---|
93 | { |
---|
94 | $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' ); |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' ); |
---|
99 | } |
---|
100 | $vtp->closeSession( $sub, 'category' ); |
---|
101 | } |
---|
102 | //----------------------------------------------------------- sending html code |
---|
103 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
104 | ?> |
---|