source: trunk/admin/group_perm.php @ 170

Last change on this file since 170 was 170, checked in by z0rglub, 21 years ago

Checking favorites after modifying group permissions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
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 170 2003-10-05 10:42:54Z 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 ***************************************************************************/
19include_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' );
26templatize_array( $tpl, 'lang', $sub );
27$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
28//--------------------------------------------------------------------- updates
29if ( 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  // confirmation display
64  $vtp->addSession( $sub, 'confirmation' );
65  $url = './admin.php?page=group_list';
66  $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
67  $vtp->closeSession( $sub, 'confirmation' );
68}
69//---------------------------------------------------------------- form display
70$restrictions = get_group_restrictions( $_GET['group_id'] );
71$action = './admin.php?page=group_perm&amp;group_id='.$_GET['group_id'];
72$vtp->setVar( $sub, 'action', add_session_id( $action ) );
73// only private categories are listed
74$query = 'SELECT id';
75$query.= ' FROM '.PREFIX_TABLE.'categories';
76$query.= " WHERE status = 'private'";
77$query.= ';';
78$result = mysql_query( $query );
79while ( $row = mysql_fetch_array( $result ) )
80{
81  $vtp->addSession( $sub, 'category' );
82  $vtp->setVar( $sub, 'category.id', $row['id'] );
83  $url = './admin.php?page=cat_perm&amp;cat_id='.$row['id'];
84  $vtp->setVar( $sub, 'category.cat_perm_link', add_session_id( $url ) );
85  // Is the group allowed to access this category
86  $is_group_allowed = is_group_allowed( $row['id'], $restrictions );
87  if ( $is_group_allowed == 0 )
88  {
89    $vtp->setVar( $sub, 'category.color', 'green' );
90  }
91  else
92  {
93    $vtp->setVar( $sub, 'category.color', 'red' );
94  }
95  // category name
96  $cat_infos = get_cat_info( $row['id'] );
97  $name = get_cat_display_name( $cat_infos['name'],' &gt; ',
98                                'font-weight:bold;' );
99  $vtp->setVar( $sub, 'category.name', $name );
100  // any subcat forbidden for this group ?
101  if ( $is_group_allowed == 2 )
102  {
103    $vtp->addSession( $sub, 'parent_forbidden' );
104    $vtp->closeSession( $sub, 'parent_forbidden' );
105  }
106  // forbidden or authorized access ?
107  if ( $is_group_allowed == 0 or $is_group_allowed == 2 )
108  {
109    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
110  }
111  else
112  {
113    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
114  }
115  $vtp->closeSession( $sub, 'category' );
116}
117//----------------------------------------------------------- sending html code
118$vtp->Parse( $handle , 'sub', $sub );
119?>
Note: See TracBrowser for help on using the repository browser.