source: trunk/admin/user_search.php @ 649

Last change on this file since 649 was 642, checked in by plg, 20 years ago
  • in admin menu, status option for categories is not "permissions" but "private or public" choice = different language item
  • get_cat_display_name changed : use $conflevel_separator to unify presentation
  • default values for category properties commentable, uploadable, status and visible (set in include/config.inc.php) used for category creation (admin/update, admin/remote_site, admin/cat_list)
  • use mass_inserts in admin/update for inserting new categories
  • only one query for counting the number of sub categories in admin/cat_list
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
RevLine 
[393]1<?php
2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net |
[393]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[393]8// | file          : $RCSfile$
9// | last update   : $Date: 2004-12-12 21:06:39 +0000 (Sun, 12 Dec 2004) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 642 $
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.= ';';
[587]48  pwg_query( $query );
[393]49  // selecting all private categories
50  $query = 'SELECT id FROM '.CATEGORIES_TABLE;
51  $query.= " WHERE status = 'private'";
52  $query.= ';';
[587]53  $result = pwg_query( $query );
[393]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.= ';';
[587]63      pwg_query ( $query );
[393]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'],
[539]77  'L_AUTHORIZED'=>$lang['authorized'],
78  'L_FORBIDDEN'=>$lang['forbidden'],
[393]79  'L_PARENT_FORBIDDEN'=>$lang['permuser_parent_forbidden'],
80
[631]81  'F_SEARCH_USER_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=profile'),
82  'F_AUTH_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=profile&amp;user_id='.$user_id),
[393]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';";
[587]99  $result = pwg_query( $query );
[393]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'] );
[642]105    $template->assign_block_vars(
106      'permission.category',
107      array(
108        'CAT_NAME'=> get_cat_display_name($cat_infos['name']),
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   
[393]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.