source: trunk/admin/user_search.php @ 498

Last change on this file since 498 was 393, checked in by gweltas, 21 years ago
  • Template migration
  • Admin Control Panel migration
  • Language migration
  • 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// |                             user_search.php                             |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-03-20 00:52:37 +0000 (Sat, 20 Mar 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 393 $
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// +-----------------------------------------------------------------------+
27
28if( !defined("IN_ADMIN") )
29{
30  die ("Hacking attempt!");
31}
32
33include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
34
35$userdata = array();
36if ( isset( $_POST['submituser'] ) )
37{
38  $userdata = getuserdata($_POST['username']);
39  if (!$userdata) echo "Utilisateur inexistant";
40}
41
42if ( isset( $_POST['submit'] ) )
43{
44  // cleaning the user_access table for this user
45  $query = 'DELETE FROM '.USER_ACCESS_TABLE;
46  $query.= ' WHERE user_id = '.$_GET['user_id'];
47  $query.= ';';
48  mysql_query( $query );
49  // selecting all private categories
50  $query = 'SELECT id FROM '.CATEGORIES_TABLE;
51  $query.= " WHERE status = 'private'";
52  $query.= ';';
53  $result = mysql_query( $query );
54  while ( $row = mysql_fetch_array( $result ) )
55  {
56    $radioname = $row['id'];
57    if ( $_POST[$radioname] == 0 )
58    {
59      $query = 'INSERT INTO '.USER_ACCESS_TABLE;
60      $query.= ' (user_id,cat_id) VALUES';
61      $query.= ' ('.$_GET['user_id'].','.$row['id'].')';
62      $query.= ';';
63      mysql_query ( $query );
64    }
65  }
66  check_favorites( $_GET['user_id'] );
67  synchronize_user( $_GET['user_id'] );
68}
69
70$user_id = (!empty($userdata['id']))?$userdata['id']:'';
71 
72$template->set_filenames( array('user'=>'admin/user_perm.tpl') );
73$template->assign_vars(array(
74  'L_SELECT_USERNAME'=>$lang['Select_username'],
75  'L_LOOKUP_USER'=>$lang['Look_up_user'],
76  'L_FIND_USERNAME'=>$lang['Find_username'],
77  'L_AUTH_USER'=>$lang['permuser_only_private'],
78  'L_SUBMIT'=>$lang['submit'],
79  'L_AUTHORIZED'=>$lang['permuser_authorized'],
80  'L_FORBIDDEN'=>$lang['permuser_forbidden'],
81  'L_PARENT_FORBIDDEN'=>$lang['permuser_parent_forbidden'],
82
83  'F_SEARCH_USER_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_search'),
84  'F_AUTH_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_search&amp;user_id='.$user_id),
85  'U_SEARCH_USER' => add_session_id(PHPWG_ROOT_PATH.'admin/search.php')
86  ));
87
88if (!$userdata)
89{
90  $template->assign_block_vars('search',array());
91}
92else
93{
94  $template->assign_block_vars('permission',array());
95  $restrictions = get_user_restrictions( $userdata['id'], $userdata['status'],
96                                  false, false );
97
98  // only private categories are listed
99  $query = 'SELECT id FROM '.CATEGORIES_TABLE;
100  $query.= " WHERE status = 'private';";
101  $result = mysql_query( $query );
102  while ( $row = mysql_fetch_array( $result ) )
103  {
104    $is_user_allowed = is_user_allowed( $row['id'], $restrictions );
105    $url = PHPWG_ROOT_PATH.'admin.php?page=cat_perm&amp;cat_id='.$row['id'];
106    $cat_infos = get_cat_info( $row['id'] );
107    $template->assign_block_vars('permission.category',array(
108      'CAT_NAME'=> get_cat_display_name($cat_infos['name'],' &gt; ', 'font-weight:bold;' ),
109          'CAT_ID'=>$row['id'],
110          'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'',
111          'AUTH_NO' =>$is_user_allowed?'checked="checked"':'',
112          'CAT_URL'=>add_session_id($url)
113        ));
114
115    // any subcat forbidden for this user ?
116    if ( $is_user_allowed == 2 )
117    {
118      $template->assign_block_vars('permission.category.parent_forbidden',array());
119    }
120  }
121}
122
123//----------------------------------------------------------- sending html code
124$template->assign_var_from_handle('ADMIN_CONTENT', 'user');
125?>
Note: See TracBrowser for help on using the repository browser.