source: trunk/admin/group_perm.php @ 29

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

template as user_template for displaying pictures in the template

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
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 ***************************************************************************/
17include_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' );
24templatize_array( $tpl, 'lang', $sub );
25$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
26//--------------------------------------------------------------------- updates
27if ( isset( $_POST['submit'] ) )
28{
29  // cleaning the user_access table for this group
30  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
31  $query.= ' WHERE group_id = '.$_GET['group_id'];
32  $query.= ';';
33  mysql_query( $query );
34  // selecting all private categories
35  $query = 'SELECT id';
36  $query.= ' FROM '.PREFIX_TABLE.'categories';
37  $query.= " WHERE status = 'private'";
38  $query.= ';';
39  $result = mysql_query( $query );
40  while ( $row = mysql_fetch_array( $result ) )
41  {
42    $radioname = 'access-'.$row['id'];
43    if ( $_POST[$radioname] == 0 )
44    {
45      $query = 'INSERT INTO '.PREFIX_TABLE.'group_access';
46      $query.= ' (group_id,cat_id) VALUES';
47      $query.= ' ('.$_GET['group_id'].','.$row['id'].')';
48      $query.= ';';
49      mysql_query ( $query );
50    }
51  }
52  $vtp->addSession( $sub, 'confirmation' );
53  $url = './admin.php?page=group_list';
54  $vtp->setVar( $sub, 'confirmation.back_url', add_session_id( $url ) );
55  $vtp->closeSession( $sub, 'confirmation' );
56}
57//---------------------------------------------------------------- form display
58$restrictions = get_group_restrictions( $_GET['group_id'] );
59$action = './admin.php?page=group_perm&amp;group_id='.$_GET['group_id'];
60$vtp->setVar( $sub, 'action', add_session_id( $action ) );
61// only private categories are listed
62$query = 'SELECT id';
63$query.= ' FROM '.PREFIX_TABLE.'categories';
64$query.= " WHERE status = 'private'";
65$query.= ';';
66$result = mysql_query( $query );
67while ( $row = mysql_fetch_array( $result ) )
68{
69  $vtp->addSession( $sub, 'category' );
70  $vtp->setVar( $sub, 'category.id', $row['id'] );
71  // Is the group allowed to access this category
72  $is_group_allowed = is_group_allowed( $row['id'], $restrictions );
73  if ( $is_group_allowed == 0 )
74  {
75    $vtp->setVar( $sub, 'category.color', 'green' );
76  }
77  else
78  {
79    $vtp->setVar( $sub, 'category.color', 'red' );
80  }
81  // category name
82  $cat_infos = get_cat_info( $row['id'] );
83  $name = get_cat_display_name( $cat_infos['name'],' &gt; ',
84                                'font-weight:bold;' );
85  $vtp->setVar( $sub, 'category.name', $name );
86  // any subcat forbidden for this group ?
87  if ( $is_group_allowed == 2 )
88  {
89    $vtp->addSession( $sub, 'parent_forbidden' );
90    $vtp->closeSession( $sub, 'parent_forbidden' );
91  }
92  // forbidden or authorized access ?
93  if ( $is_group_allowed == 0 or $is_group_allowed == 2 )
94  {
95    $vtp->setVar( $sub, 'category.authorized_checked', ' checked="checked"' );
96  }
97  else
98  {
99    $vtp->setVar( $sub, 'category.forbidden_checked', ' checked="checked"' );
100  }
101  $vtp->closeSession( $sub, 'category' );
102}
103//----------------------------------------------------------- sending html code
104$vtp->Parse( $handle , 'sub', $sub );
105?>
Note: See TracBrowser for help on using the repository browser.