source: trunk/admin/user_list.php @ 25237

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

feature 1668, user manager redesign: ability to add a new user (call to pwg.users.add through AJAX)

Move the "send connection settings" code to function register_user (avoid code duplication).

  • Property svn:eol-style set to LF
File size: 4.8 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    'NB_IMAGE_PAGE' => $default_user['nb_image_page'],
100    'RECENT_PERIOD' => $default_user['recent_period'],
101    'theme_options' => get_pwg_themes(),
102    'theme_selected' => get_default_theme(),
103    'language_options' => get_languages(),
104    'language_selected' => get_default_language(),
105    'association_options' => $groups,
106    )
107  );
108
109// Status options
110foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
111{
112  // Only status <= can be assign
113  if (is_autorize_status(get_access_type_status($status)))
114  {
115    $pref_status_options[$status] = l10n('user_status_'.$status);
116  }
117}
118$template->assign('pref_status_options', $pref_status_options);
119$template->assign('pref_status_selected', 'normal');
120
121// user level options
122foreach ($conf['available_permission_levels'] as $level)
123{
124  $level_options[$level] = l10n(sprintf('Level %d', $level));
125}
126$template->assign('level_options', $level_options);
127$template->assign('level_selected', $default_user['level']);
128
129
130// +-----------------------------------------------------------------------+
131// | html code display                                                     |
132// +-----------------------------------------------------------------------+
133
134$template->assign_var_from_handle('ADMIN_CONTENT', 'user_list');
135?>
Note: See TracBrowser for help on using the repository browser.