aboutsummaryrefslogtreecommitdiffstats
path: root/admin/user_list.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-09-03 16:36:05 +0000
committerplegall <plg@piwigo.org>2005-09-03 16:36:05 +0000
commit7eae7595909a49d4355453c73638151097a53f20 (patch)
treeec20fce221086be1ece0f292a953264d90ec5360 /admin/user_list.php
parent857eec2218afe027b9d87f91aa7de144fc4e3111 (diff)
- modification : less configuration parameters in administration
screen. These parameters are move to include/config_default.inc.php. - new : ability to add a single picture to caddie from picture.php - new : contextual help, only a few pages are available. - new : ability to delete users from admin/user_list - modification : reorganization of configuration file - new : configuration parameter use_exif_mapping - improvement : MOD hidemail added to standard git-svn-id: http://piwigo.org/svn/trunk@858 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/user_list.php208
1 files changed, 123 insertions, 85 deletions
diff --git a/admin/user_list.php b/admin/user_list.php
index e4a4c6d7e..0671dabc3 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -49,10 +49,10 @@ if (isset($_POST['submit_add']))
}
// +-----------------------------------------------------------------------+
-// | preferences form submission |
+// | selected users |
// +-----------------------------------------------------------------------+
-if (isset($_POST['pref_submit']))
+if (isset($_POST['delete']) or isset($_POST['pref_submit']))
{
$collection = array();
@@ -78,116 +78,154 @@ SELECT id
}
}
- if (count($collection) > 0)
+ if (count($collection) == 0)
+ {
+ array_push($page['errors'], l10n('Select at least one user'));
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | delete users |
+// +-----------------------------------------------------------------------+
+
+if (isset($_POST['delete']) and count($collection) > 0)
+{
+ if (in_array($conf['webmaster_id'], $collection))
+ {
+ array_push($page['errors'], l10n('Webmaster cannot be deleted'));
+ }
+ else
{
- if (-1 != $_POST['associate'])
+ if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion'])
+ {
+ foreach ($collection as $user_id)
+ {
+ delete_user($user_id);
+ }
+ array_push(
+ $page['infos'],
+ sprintf(
+ l10n('%d users deleted'),
+ count($collection)
+ )
+ );
+ }
+ else
{
- $datas = array();
+ array_push($page['errors'], l10n('You need to confirm deletion'));
+ }
+ }
+}
- $query = '
+// +-----------------------------------------------------------------------+
+// | preferences form submission |
+// +-----------------------------------------------------------------------+
+
+if (isset($_POST['pref_submit']) and count($collection) > 0)
+{
+ if (-1 != $_POST['associate'])
+ {
+ $datas = array();
+
+ $query = '
SELECT user_id
FROM '.USER_GROUP_TABLE.'
WHERE group_id = '.$_POST['associate'].'
;';
- $associated = array_from_query($query, 'user_id');
-
- $associable = array_diff($collection, $associated);
-
- if (count($associable) > 0)
+ $associated = array_from_query($query, 'user_id');
+
+ $associable = array_diff($collection, $associated);
+
+ if (count($associable) > 0)
+ {
+ foreach ($associable as $item)
{
- foreach ($associable as $item)
- {
- array_push($datas,
- array('group_id'=>$_POST['associate'],
- 'user_id'=>$item));
- }
-
- mass_inserts(USER_GROUP_TABLE,
- array('group_id', 'user_id'),
- $datas);
+ array_push($datas,
+ array('group_id'=>$_POST['associate'],
+ 'user_id'=>$item));
}
+
+ mass_inserts(USER_GROUP_TABLE,
+ array('group_id', 'user_id'),
+ $datas);
}
-
- if (-1 != $_POST['dissociate'])
- {
- $query = '
+ }
+
+ if (-1 != $_POST['dissociate'])
+ {
+ $query = '
DELETE FROM '.USER_GROUP_TABLE.'
WHERE group_id = '.$_POST['dissociate'].'
AND user_id IN ('.implode(',', $collection).')
';
- pwg_query($query);
+ pwg_query($query);
+ }
+
+ // properties to set for the collection (a user list)
+ $datas = array();
+ $dbfields = array('primary' => array('user_id'), 'update' => array());
+
+ $formfields =
+ array('nb_image_line', 'nb_line_page', 'template', 'language',
+ 'recent_period', 'maxwidth', 'expand', 'show_nb_comments',
+ 'maxheight', 'status');
+
+ $true_false_fields = array('expand', 'show_nb_comments');
+
+ foreach ($formfields as $formfield)
+ {
+ // special for true/false fields
+ if (in_array($formfield, $true_false_fields))
+ {
+ $test = $formfield;
+ }
+ else
+ {
+ $test = $formfield.'_action';
}
-
- // properties to set for the collection (a user list)
- $datas = array();
- $dbfields = array('primary' => array('user_id'), 'update' => array());
-
- $formfields =
- array('nb_image_line', 'nb_line_page', 'template', 'language',
- 'recent_period', 'maxwidth', 'expand', 'show_nb_comments',
- 'maxheight', 'status');
-
- $true_false_fields = array('expand', 'show_nb_comments');
- foreach ($formfields as $formfield)
+ if ($_POST[$test] != 'leave')
{
- // special for true/false fields
- if (in_array($formfield, $true_false_fields))
- {
- $test = $formfield;
- }
- else
- {
- $test = $formfield.'_action';
- }
-
- if ($_POST[$test] != 'leave')
- {
- array_push($dbfields['update'], $formfield);
- }
+ array_push($dbfields['update'], $formfield);
}
-
- // updating elements is useful only if needed...
- if (count($dbfields['update']) > 0)
+ }
+
+ // updating elements is useful only if needed...
+ if (count($dbfields['update']) > 0)
+ {
+ $datas = array();
+
+ foreach ($collection as $user_id)
{
- $datas = array();
+ $data = array();
+ $data['user_id'] = $user_id;
- foreach ($collection as $user_id)
+ // TODO : verify if submited values are semanticaly correct
+ foreach ($dbfields['update'] as $dbfield)
{
- $data = array();
- $data['user_id'] = $user_id;
-
- // TODO : verify if submited values are semanticaly correct
- foreach ($dbfields['update'] as $dbfield)
- {
- // if the action is 'unset', the key won't be in row and
- // mass_updates function will set this field to NULL
- if (in_array($dbfield, $true_false_fields)
- or 'set' == $_POST[$dbfield.'_action'])
- {
- $data[$dbfield] = $_POST[$dbfield];
- }
- }
-
- // Webmaster (user_id = 1) status must not be changed
- if (1 == $user_id and isset($data['status']))
+ // if the action is 'unset', the key won't be in row and
+ // mass_updates function will set this field to NULL
+ if (in_array($dbfield, $true_false_fields)
+ or 'set' == $_POST[$dbfield.'_action'])
{
- $data['status'] = 'admin';
+ $data[$dbfield] = $_POST[$dbfield];
}
-
- array_push($datas, $data);
}
-
+
+ // Webmaster status must not be changed
+ if ($conf['webmaster_id'] == $user_id and isset($data['status']))
+ {
+ $data['status'] = 'admin';
+ }
+
+ array_push($datas, $data);
+ }
+
// echo '<pre>';
// print_r($datas);
// echo '</pre>';
-
- mass_updates(USER_INFOS_TABLE, $dbfields, $datas);
- }
- }
- else
- {
- array_push($page['errors'], l10n('Select at least one user'));
+
+ mass_updates(USER_INFOS_TABLE, $dbfields, $datas);
}
}