1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * group_perm.php * |
---|
4 | * ------------------ * |
---|
5 | * application : PhpWebGallery 1.3 <http://phpwebgallery.net> * |
---|
6 | * author : Pierrick LE GALL <pierrick@z0rglub.com> * |
---|
7 | * * |
---|
8 | * $Id: group_perm.php 257 2004-01-03 21:31:27Z z0rglub $ |
---|
9 | * * |
---|
10 | ***************************************************************************/ |
---|
11 | |
---|
12 | /*************************************************************************** |
---|
13 | * * |
---|
14 | * This program is free software; you can redistribute it and/or modify * |
---|
15 | * it under the terms of the GNU General Public License as published by * |
---|
16 | * the Free Software Foundation; * |
---|
17 | * * |
---|
18 | ***************************************************************************/ |
---|
19 | include_once( './include/isadmin.inc.php' ); |
---|
20 | //----------------------------------------------------- template initialization |
---|
21 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/group_perm.vtp' ); |
---|
22 | $error = array(); |
---|
23 | $tpl = array( 'permuser_authorized','permuser_forbidden','submit', |
---|
24 | 'permuser_parent_forbidden','permuser_info_message', |
---|
25 | 'adduser_info_back','permuser_only_private' ); |
---|
26 | templatize_array( $tpl, 'lang', $sub ); |
---|
27 | $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); |
---|
28 | //--------------------------------------------------------------------- updates |
---|
29 | if ( isset( $_POST['submit'] ) ) |
---|
30 | { |
---|
31 | // cleaning the user_access table for this group |
---|
32 | $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; |
---|
33 | $query.= ' WHERE group_id = '.$_GET['group_id']; |
---|
34 | $query.= ';'; |
---|
35 | mysql_query( $query ); |
---|
36 | // selecting all private categories |
---|
37 | $query = 'SELECT id'; |
---|
38 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
39 | $query.= " WHERE status = 'private'"; |
---|
40 | $query.= ';'; |
---|
41 | $result = mysql_query( $query ); |
---|
42 | while ( $row = mysql_fetch_array( $result ) ) |
---|
43 | { |
---|
44 | $radioname = 'access-'.$row['id']; |
---|
45 | if ( $_POST[$radioname] == 0 ) |
---|
46 | { |
---|
47 | $query = 'INSERT INTO '.PREFIX_TABLE.'group_access'; |
---|
48 | $query.= ' (group_id,cat_id) VALUES'; |
---|
49 | $query.= ' ('.$_GET['group_id'].','.$row['id'].')'; |
---|
50 | $query.= ';'; |
---|
51 | mysql_query ( $query ); |
---|
52 | } |
---|
53 | } |
---|
54 | // checking users favorites |
---|
55 | $query = 'SELECT id'; |
---|
56 | $query.= ' FROM '.PREFIX_TABLE.'users'; |
---|
57 | $query.= ';'; |
---|
58 | $result = mysql_query( $query ); |
---|
59 | while ( $row = mysql_fetch_array( $result ) ) |
---|
60 | { |
---|
61 | check_favorites( $row['id'] ); |
---|
62 | } |
---|
63 | // synchronization of calculated data |
---|
64 | synchronize_group( $_GET['group_id'] ); |
---|
65 | // confirmation display |
---|
66 | $vtp->addSession( $sub, 'confirmation' ); |
---|
67 | $url = './admin.php?page=group_list'; |
---|
68 | $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) ); |
---|
69 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
70 | } |
---|
71 | //---------------------------------------------------------------- form display |
---|
72 | $restrictions = get_group_restrictions( $_GET['group_id'] ); |
---|
73 | $action = './admin.php?page=group_perm&group_id='.$_GET['group_id']; |
---|
74 | $vtp->setVar( $sub, 'action', add_session_id( $action ) ); |
---|
75 | // only private categories are listed |
---|
76 | $query = 'SELECT id'; |
---|
77 | $query.= ' FROM '.PREFIX_TABLE.'categories'; |
---|
78 | $query.= " WHERE status = 'private'"; |
---|
79 | $query.= ';'; |
---|
80 | $result = mysql_query( $query ); |
---|
81 | while ( $row = mysql_fetch_array( $result ) ) |
---|
82 | { |
---|
83 | $vtp->addSession( $sub, 'category' ); |
---|
84 | $vtp->setVar( $sub, 'category.id', $row['id'] ); |
---|
85 | $url = './admin.php?page=cat_perm&cat_id='.$row['id']; |
---|
86 | $vtp->setVar( $sub, 'category.cat_perm_link', add_session_id( $url ) ); |
---|
87 | // Is the group allowed to access this category |
---|
88 | $is_group_allowed = is_group_allowed( $row['id'], $restrictions ); |
---|
89 | if ( $is_group_allowed == 0 ) |
---|
90 | { |
---|
91 | $vtp->setVar( $sub, 'category.color', 'green' ); |
---|
92 | } |
---|
93 | else |
---|
94 | { |
---|
95 | $vtp->setVar( $sub, 'category.color', 'red' ); |
---|
96 | } |
---|
97 | // category name |
---|
98 | $cat_infos = get_cat_info( $row['id'] ); |
---|
99 | $name = get_cat_display_name( $cat_infos['name'],' > ', |
---|
100 | 'font-weight:bold;' ); |
---|
101 | $vtp->setVar( $sub, 'category.name', $name ); |
---|
102 | // any subcat forbidden for this group ? |
---|
103 | if ( $is_group_allowed == 2 ) |
---|
104 | { |
---|
105 | $vtp->addSession( $sub, 'parent_forbidden' ); |
---|
106 | $vtp->closeSession( $sub, 'parent_forbidden' ); |
---|
107 | } |
---|
108 | // forbidden or authorized access ? |
---|
109 | if ( $is_group_allowed == 0 or $is_group_allowed == 2 ) |
---|
110 | { |
---|
111 | $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' ); |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' ); |
---|
116 | } |
---|
117 | $vtp->closeSession( $sub, 'category' ); |
---|
118 | } |
---|
119 | //----------------------------------------------------------- sending html code |
---|
120 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
121 | ?> |
---|