source: trunk/admin/group_perm.php @ 642

Last change on this file since 642 was 642, checked in by plg, 19 years ago
  • in admin menu, status option for categories is not "permissions" but "private or public" choice = different language item
  • get_cat_display_name changed : use $conflevel_separator to unify presentation
  • default values for category properties commentable, uploadable, status and visible (set in include/config.inc.php) used for category creation (admin/update, admin/remote_site, admin/cat_list)
  • use mass_inserts in admin/update for inserting new categories
  • only one query for counting the number of sub categories in admin/cat_list
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
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-12-12 21:06:39 +0000 (Sun, 12 Dec 2004) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 642 $
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// +-----------------------------------------------------------------------+
27include_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' );
34templatize_array( $tpl, 'lang', $sub );
35$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
36//--------------------------------------------------------------------- updates
37if ( 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&amp;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 );
89while ( $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&amp;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  $vtp->setVar( $sub, 'category.name', $name );
109  // any subcat forbidden for this group ?
110  if ( $is_group_allowed == 2 )
111  {
112    $vtp->addSession( $sub, 'parent_forbidden' );
113    $vtp->closeSession( $sub, 'parent_forbidden' );
114  }
115  // forbidden or authorized access ?
116  if ( $is_group_allowed == 0 or $is_group_allowed == 2 )
117  {
118    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
119  }
120  else
121  {
122    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
123  }
124  $vtp->closeSession( $sub, 'category' );
125}
126//----------------------------------------------------------- sending html code
127$vtp->Parse( $handle , 'sub', $sub );
128?>
Note: See TracBrowser for help on using the repository browser.