source: trunk/admin/user_search.php @ 539

Last change on this file since 539 was 539, checked in by gweltas, 20 years ago
  • Change of the picture page behavior to be able to open the full size image in a new window
  • Minor modification for template migration
  • Rename of script.js in scripts.js
  • 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-10-01 22:50:50 +0000 (Fri, 01 Oct 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 539 $
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}
68
69$user_id = (!empty($userdata['id']))?$userdata['id']:'';
70$template->set_filenames( array('user'=>'admin/user_perm.tpl') );
71$template->assign_vars(array(
72  'L_SELECT_USERNAME'=>$lang['Select_username'],
73  'L_LOOKUP_USER'=>$lang['Look_up_user'],
74  'L_FIND_USERNAME'=>$lang['Find_username'],
75  'L_AUTH_USER'=>$lang['permuser_only_private'],
76  'L_SUBMIT'=>$lang['submit'],
77  'L_AUTHORIZED'=>$lang['authorized'],
78  'L_FORBIDDEN'=>$lang['forbidden'],
79  'L_PARENT_FORBIDDEN'=>$lang['permuser_parent_forbidden'],
80
81  'F_SEARCH_USER_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_search'),
82  'F_AUTH_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_search&amp;user_id='.$user_id),
83  'U_SEARCH_USER' => add_session_id(PHPWG_ROOT_PATH.'admin/search.php')
84  ));
85
86if (!$userdata)
87{
88  $template->assign_block_vars('search',array());
89}
90else
91{
92  $template->assign_block_vars('permission',array());
93  $restrictions = get_user_restrictions( $userdata['id'], $userdata['status'],
94                                  false, false );
95
96  // only private categories are listed
97  $query = 'SELECT id FROM '.CATEGORIES_TABLE;
98  $query.= " WHERE status = 'private';";
99  $result = mysql_query( $query );
100  while ( $row = mysql_fetch_array( $result ) )
101  {
102    $is_user_allowed = is_user_allowed( $row['id'], $restrictions );
103    $url = PHPWG_ROOT_PATH.'admin.php?page=cat_perm&amp;cat_id='.$row['id'];
104    $cat_infos = get_cat_info( $row['id'] );
105    $template->assign_block_vars('permission.category',array(
106      'CAT_NAME'=> get_cat_display_name($cat_infos['name'],' &gt; ', 'font-weight:bold;' ),
107          'CAT_ID'=>$row['id'],
108          'AUTH_YES'=>!$is_user_allowed?'checked="checked"':'',
109          'AUTH_NO' =>$is_user_allowed?'checked="checked"':'',
110          'CAT_URL'=>add_session_id($url)
111        ));
112
113    // any subcat forbidden for this user ?
114    if ( $is_user_allowed == 2 )
115    {
116      $template->assign_block_vars('permission.category.parent_forbidden',array());
117    }
118  }
119}
120
121//----------------------------------------------------------- sending html code
122$template->assign_var_from_handle('ADMIN_CONTENT', 'user');
123?>
Note: See TracBrowser for help on using the repository browser.