aboutsummaryrefslogtreecommitdiffstats
path: root/admin/user_list.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-07-17 15:09:24 +0000
committerplegall <plg@piwigo.org>2005-07-17 15:09:24 +0000
commit3643e999a59e0b2f2a05c44850b03f7c0e36423c (patch)
tree968412222b7b13ad164399b7ae2b2979e3fb9bb7 /admin/user_list.php
parente96510957cd6fb539fcaacb80e47f6f78abdefb7 (diff)
- bug fixed : in admin/user_list, if target is "selection" and that no user
is selected, an error occurs git-svn-id: http://piwigo.org/svn/trunk@805 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/user_list.php133
1 files changed, 72 insertions, 61 deletions
diff --git a/admin/user_list.php b/admin/user_list.php
index 26a98ebaf..9ffc84e10 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -73,96 +73,107 @@ SELECT id
}
case 'selection' :
{
- $collection = $_POST['selection'];
+ if (isset($_POST['selection']))
+ {
+ $collection = $_POST['selection'];
+ }
break;
}
}
- if (-1 != $_POST['associate'])
+ if (count($collection) > 0)
{
- $datas = array();
+ if (-1 != $_POST['associate'])
+ {
+ $datas = array();
- $query = '
+ $query = '
SELECT user_id
FROM '.USER_GROUP_TABLE.'
WHERE group_id = '.$_POST['associate'].'
;';
- $associated = array_from_query($query, 'user_id');
+ $associated = array_from_query($query, 'user_id');
- // TODO : if $associable array is empty, no further actions
- $associable = array_diff($collection, $associated);
-
- foreach ($associable as $item)
- {
- array_push($datas,
- array('group_id'=>$_POST['associate'],
- 'user_id'=>$item));
+ $associable = array_diff($collection, $associated);
+
+ if (count($associable) > 0)
+ {
+ 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);
+ }
}
-
- 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);
- }
-
- // properties to set for the collection (a user list)
- $datas = array();
- $dbfields = array('primary' => array('id'), 'update' => array());
+ pwg_query($query);
+ }
- $formfields = array('nb_image_line', 'nb_line_page', 'template', 'language',
- 'recent_period', 'expand', 'show_nb_comments',
- 'maxwidth', 'maxheight', 'status');
+ // properties to set for the collection (a user list)
+ $datas = array();
+ $dbfields = array('primary' => array('id'), 'update' => array());
+
+ $formfields =
+ array('nb_image_line', 'nb_line_page', 'template', 'language',
+ 'recent_period', 'expand', 'show_nb_comments', 'maxwidth',
+ 'maxheight', 'status');
- foreach ($formfields as $formfield)
- {
- if ($_POST[$formfield.'_action'] != 'leave')
+ foreach ($formfields as $formfield)
{
- array_push($dbfields['update'], $formfield);
+ if ($_POST[$formfield.'_action'] != 'leave')
+ {
+ array_push($dbfields['update'], $formfield);
+ }
}
- }
-
- // updating elements is useful only if needed...
- if (count($dbfields['update']) > 0)
- {
- $datas = array();
- foreach ($collection as $user_id)
+ // updating elements is useful only if needed...
+ if (count($dbfields['update']) > 0)
{
- $data = array();
- $data['id'] = $user_id;
-
- // TODO : verify if submited values are semanticaly correct
- foreach ($dbfields['update'] as $dbfield)
+ $datas = array();
+
+ foreach ($collection as $user_id)
{
- // if the action is 'unset', the key won't be in row and
- // mass_updates function will set this field to NULL
- if ('set' == $_POST[$dbfield.'_action'])
+ $data = array();
+ $data['id'] = $user_id;
+
+ // TODO : verify if submited values are semanticaly correct
+ foreach ($dbfields['update'] as $dbfield)
{
- $data[$dbfield] = $_POST[$dbfield];
+ // if the action is 'unset', the key won't be in row and
+ // mass_updates function will set this field to NULL
+ if ('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']))
+ {
+ $data['status'] = 'admin';
+ }
+
+ array_push($datas, $data);
}
- // Webmaster (user_id = 1) status must not be changed
- if (1 == $user_id and isset($data['status']))
- {
- $data['status'] = 'admin';
- }
-
- array_push($datas, $data);
+ mass_updates(USERS_TABLE, $dbfields, $datas);
}
-
-// echo '<pre>'; print_r($dbfields); echo '</pre>';
-// echo '<pre>'; print_r($datas); echo '</pre>';
- mass_updates(USERS_TABLE, $dbfields, $datas);
+ }
+ else
+ {
+ array_push($page['errors'], l10n('Select at least one user'));
}
}