source: trunk/admin/group_perm.php @ 102

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

Right link to change category permissions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 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 102 2003-09-14 16:03:15Z 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' );
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  $vtp->addSession( $sub, 'confirmation' );
55  $url = './admin.php?page=group_list';
56  $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
57  $vtp->closeSession( $sub, 'confirmation' );
58}
59//---------------------------------------------------------------- form display
60$restrictions = get_group_restrictions( $_GET['group_id'] );
61$action = './admin.php?page=group_perm&amp;group_id='.$_GET['group_id'];
62$vtp->setVar( $sub, 'action', add_session_id( $action ) );
63// only private categories are listed
64$query = 'SELECT id';
65$query.= ' FROM '.PREFIX_TABLE.'categories';
66$query.= " WHERE status = 'private'";
67$query.= ';';
68$result = mysql_query( $query );
69while ( $row = mysql_fetch_array( $result ) )
70{
71  $vtp->addSession( $sub, 'category' );
72  $vtp->setVar( $sub, 'category.id', $row['id'] );
73  $url = './admin.php?page=cat_perm&amp;cat_id='.$row['id'];
74  $vtp->setVar( $sub, 'category.cat_perm_link', add_session_id( $url ) );
75  // Is the group allowed to access this category
76  $is_group_allowed = is_group_allowed( $row['id'], $restrictions );
77  if ( $is_group_allowed == 0 )
78  {
79    $vtp->setVar( $sub, 'category.color', 'green' );
80  }
81  else
82  {
83    $vtp->setVar( $sub, 'category.color', 'red' );
84  }
85  // category name
86  $cat_infos = get_cat_info( $row['id'] );
87  $name = get_cat_display_name( $cat_infos['name'],' &gt; ',
88                                'font-weight:bold;' );
89  $vtp->setVar( $sub, 'category.name', $name );
90  // any subcat forbidden for this group ?
91  if ( $is_group_allowed == 2 )
92  {
93    $vtp->addSession( $sub, 'parent_forbidden' );
94    $vtp->closeSession( $sub, 'parent_forbidden' );
95  }
96  // forbidden or authorized access ?
97  if ( $is_group_allowed == 0 or $is_group_allowed == 2 )
98  {
99    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
100  }
101  else
102  {
103    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
104  }
105  $vtp->closeSession( $sub, 'category' );
106}
107//----------------------------------------------------------- sending html code
108$vtp->Parse( $handle , 'sub', $sub );
109?>
Note: See TracBrowser for help on using the repository browser.