source: trunk/admin/user_list.php @ 25405

Last change on this file since 25405 was 25282, checked in by plg, 11 years ago

feature 2976: pwg.users.delete requires pwg_token

  • Property svn:eol-style set to LF
File size: 4.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24/**
25 * Add users and manage users list
26 */
27
28// +-----------------------------------------------------------------------+
29// | tabs                                                                  |
30// +-----------------------------------------------------------------------+
31
32include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
33
34$my_base_url = get_root_url().'admin.php?page=';
35
36$tabsheet = new tabsheet();
37$tabsheet->set_id('users');
38$tabsheet->select('user_list');
39$tabsheet->assign();
40
41// +-----------------------------------------------------------------------+
42// |                              groups list                              |
43// +-----------------------------------------------------------------------+
44
45$groups = array();
46
47$query = '
48SELECT id, name
49  FROM '.GROUPS_TABLE.'
50  ORDER BY name ASC
51;';
52$result = pwg_query($query);
53
54while ($row = pwg_db_fetch_assoc($result))
55{
56  $groups[$row['id']] = $row['name'];
57}
58
59// +-----------------------------------------------------------------------+
60// | template                                                              |
61// +-----------------------------------------------------------------------+
62
63$template->set_filenames(array('user_list'=>'user_list.tpl'));
64
65$query = '
66SELECT
67    DISTINCT u.'.$conf['user_fields']['id'].' AS id,
68    u.'.$conf['user_fields']['username'].' AS username,
69    u.'.$conf['user_fields']['email'].' AS email,
70    ui.status,
71    ui.enabled_high,
72    ui.level
73  FROM '.USERS_TABLE.' AS u
74    INNER JOIN '.USER_INFOS_TABLE.' AS ui ON u.'.$conf['user_fields']['id'].' = ui.user_id
75  WHERE u.'.$conf['user_fields']['id'].' > 0
76;';
77
78$result = pwg_query($query);
79while ($row = pwg_db_fetch_assoc($result))
80{
81  $users[] = $row;
82  $user_ids[] = $row['id'];
83}
84
85$template->assign(
86  array(
87    'users' => $users,
88    'all_users' => join(',', $user_ids),
89    'Double_Password' => $conf['double_password_type_in_admin']
90    )
91  );
92
93// echo '<pre>'; print_r($users); echo '</pre>';
94
95$default_user = get_default_user_info(true);
96
97$template->assign(
98  array(
99    'PWG_TOKEN' => get_pwg_token(),
100    'NB_IMAGE_PAGE' => $default_user['nb_image_page'],
101    'RECENT_PERIOD' => $default_user['recent_period'],
102    'theme_options' => get_pwg_themes(),
103    'theme_selected' => get_default_theme(),
104    'language_options' => get_languages(),
105    'language_selected' => get_default_language(),
106    'association_options' => $groups,
107    )
108  );
109
110// Status options
111foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
112{
113  // Only status <= can be assign
114  if (is_autorize_status(get_access_type_status($status)))
115  {
116    $pref_status_options[$status] = l10n('user_status_'.$status);
117  }
118}
119$template->assign('pref_status_options', $pref_status_options);
120$template->assign('pref_status_selected', 'normal');
121
122// user level options
123foreach ($conf['available_permission_levels'] as $level)
124{
125  $level_options[$level] = l10n(sprintf('Level %d', $level));
126}
127$template->assign('level_options', $level_options);
128$template->assign('level_selected', $default_user['level']);
129
130
131// +-----------------------------------------------------------------------+
132// | html code display                                                     |
133// +-----------------------------------------------------------------------+
134
135$template->assign_var_from_handle('ADMIN_CONTENT', 'user_list');
136?>
Note: See TracBrowser for help on using the repository browser.