source: trunk/admin/user_list.php @ 25282

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

feature 2976: pwg.users.delete requires pwg_token

  • Property svn:eol-style set to LF
File size: 4.9 KB
RevLine 
[768]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[768]23
24/**
25 * Add users and manage users list
26 */
27
28// +-----------------------------------------------------------------------+
[25237]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// +-----------------------------------------------------------------------+
[787]42// |                              groups list                              |
43// +-----------------------------------------------------------------------+
44
[25194]45$groups = array();
[787]46
47$query = '
48SELECT id, name
49  FROM '.GROUPS_TABLE.'
[1960]50  ORDER BY name ASC
[787]51;';
52$result = pwg_query($query);
53
[4325]54while ($row = pwg_db_fetch_assoc($result))
[787]55{
56  $groups[$row['id']] = $row['name'];
57}
58
59// +-----------------------------------------------------------------------+
[25194]60// | template                                                              |
[768]61// +-----------------------------------------------------------------------+
62
[2530]63$template->set_filenames(array('user_list'=>'user_list.tpl'));
[768]64
[25194]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;';
[768]77
[25194]78$result = pwg_query($query);
79while ($row = pwg_db_fetch_assoc($result))
[768]80{
[25194]81  $users[] = $row;
82  $user_ids[] = $row['id'];
[768]83}
84
[2253]85$template->assign(
[768]86  array(
[25194]87    'users' => $users,
88    'all_users' => join(',', $user_ids),
[25237]89    'Double_Password' => $conf['double_password_type_in_admin']
[25194]90    )
91  );
[1620]92
[25194]93// echo '<pre>'; print_r($users); echo '</pre>';
[768]94
[25194]95$default_user = get_default_user_info(true);
[3935]96
[25194]97$template->assign(
98  array(
[25282]99    'PWG_TOKEN' => get_pwg_token(),
[25194]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  );
[768]109
[2253]110// Status options
[808]111foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
[787]112{
[1085]113  // Only status <= can be assign
114  if (is_autorize_status(get_access_type_status($status)))
115  {
[2253]116    $pref_status_options[$status] = l10n('user_status_'.$status);
[1085]117  }
[787]118}
[2253]119$template->assign('pref_status_options', $pref_status_options);
[25194]120$template->assign('pref_status_selected', 'normal');
[787]121
[2084]122// user level options
123foreach ($conf['available_permission_levels'] as $level)
124{
[2253]125  $level_options[$level] = l10n(sprintf('Level %d', $level));
[2084]126}
[2253]127$template->assign('level_options', $level_options);
[25194]128$template->assign('level_selected', $default_user['level']);
[2084]129
[768]130
131// +-----------------------------------------------------------------------+
[25194]132// | html code display                                                     |
[768]133// +-----------------------------------------------------------------------+
134
135$template->assign_var_from_handle('ADMIN_CONTENT', 'user_list');
[25194]136?>
Note: See TracBrowser for help on using the repository browser.