diff options
-rw-r--r-- | admin/user_list.php | 381 | ||||
-rw-r--r-- | doc/ChangeLog | 13 | ||||
-rw-r--r-- | include/user.inc.php | 18 | ||||
-rw-r--r-- | template/default/admin/user_list.tpl | 173 | ||||
-rw-r--r-- | template/default/default.css | 6 | ||||
-rw-r--r-- | template/default/theme/permissions.png | bin | 0 -> 728 bytes | |||
-rw-r--r-- | template/default/theme/profile.png | bin | 0 -> 795 bytes |
7 files changed, 560 insertions, 31 deletions
diff --git a/admin/user_list.php b/admin/user_list.php index c53a39220..23c467eb4 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -52,6 +52,140 @@ if (isset($_POST['submit_add'])) } // +-----------------------------------------------------------------------+ +// | preferences form submission | +// +-----------------------------------------------------------------------+ + +$errors = array(); + +if (isset($_POST['pref_submit'])) +{ + $collection = array(); + + switch ($_POST['target']) + { + case 'all' : + { + $query = ' +SELECT id + FROM '.USERS_TABLE.' + WHERE id != 2 +;'; + $collection = array_from_query($query, 'id'); + break; + } + case 'selection' : + { + $collection = $_POST['selection']; + break; + } + } + + 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'); + + // 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)); + } + + mass_inserts(USER_GROUP_TABLE, + array('group_id', 'user_id'), + $datas); + } + + 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()); + + $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') + { + array_push($dbfields['update'], $formfield); + } + } + + // updating elements is useful only if needed... + if (count($dbfields['update']) > 0) + { + $datas = array(); + + foreach ($collection as $user_id) + { + $data = array(); + $data['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 ('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); + } + +// echo '<pre>'; print_r($dbfields); echo '</pre>'; +// echo '<pre>'; print_r($datas); echo '</pre>'; + mass_updates(USERS_TABLE, $dbfields, $datas); + } +} + +// +-----------------------------------------------------------------------+ +// | groups list | +// +-----------------------------------------------------------------------+ + +$groups = array(); + +$query = ' +SELECT id, name + FROM '.GROUPS_TABLE.' +;'; +$result = pwg_query($query); + +while ($row = mysql_fetch_array($result)) +{ + $groups[$row['id']] = $row['name']; +} + +// +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ @@ -83,6 +217,21 @@ $template->assign_vars( 'L_ACTIONS' => $lang['actions'], 'L_PERMISSIONS' => $lang['permissions'], 'L_USERS_LIST' => $lang['title_liste_users'], + 'L_LANGUAGE' => $lang['language'], + 'L_NB_IMAGE_LINE' => $lang['nb_image_per_row'], + 'L_NB_LINE_PAGE' => $lang['nb_row_per_page'], + 'L_TEMPLATE' => $lang['theme'], + 'L_RECENT_PERIOD' => $lang['recent_period'], + 'L_EXPAND' => $lang['auto_expand'], + 'L_SHOW_NB_COMMENTS' => $lang['show_nb_comments'], + 'L_MAXWIDTH' => $lang['maxwidth'], + 'L_MAXHEIGHT' => $lang['maxheight'], + 'L_YES' => $lang['yes'], + 'L_NO' => $lang['no'], + 'L_SUBMIT' => $lang['submit'], + 'L_RESET' => $lang['reset'], + 'L_DELETE' => $lang['user_delete'], + 'L_DELETE_HINT' => $lang['user_delete_hint'], 'F_ADD_ACTION' => $base_url, 'F_USERNAME' => @$_GET['username'], @@ -136,21 +285,15 @@ $template->assign_block_vars( 'SELECTED' => '' )); -$query = ' -SELECT id, name - FROM '.GROUPS_TABLE.' -;'; -$result = pwg_query($query); - -while ($row = mysql_fetch_array($result)) +foreach ($groups as $group_id => $group_name) { - $selected = (isset($_GET['group']) and $_GET['group'] == $row['id']) ? + $selected = (isset($_GET['group']) and $_GET['group'] == $group_id) ? 'selected="selected"' : ''; $template->assign_block_vars( $blockname, array( - 'VALUE' => $row['id'], - 'CONTENT' => $row['name'], + 'VALUE' => $group_id, + 'CONTENT' => $group_name, 'SELECTED' => $selected )); } @@ -178,6 +321,194 @@ foreach (get_enums(USERS_TABLE, 'status') as $status) )); } +// --- +// $user['template'] = $conf['default_template']; +// $user['nb_image_line'] = $conf['nb_image_line']; +// $user['nb_line_page'] = $conf['nb_line_page']; +// $user['language'] = $conf['default_language']; +// $user['maxwidth'] = $conf['default_maxwidth']; +// $user['maxheight'] = $conf['default_maxheight']; +// $user['recent_period'] = $conf['recent_period']; +// $user['expand'] = $conf['auto_expand']; +// $user['show_nb_comments'] = $conf['show_nb_comments']; +// --- + +if (isset($_POST['pref_submit'])) +{ +// echo '<pre>'; print_r($_POST); echo '</pre>'; + $template->assign_vars( + array( + 'NB_IMAGE_LINE' => $_POST['nb_image_line'], + 'NB_LINE_PAGE' => $_POST['nb_line_page'], + 'MAXWIDTH' => $_POST['maxwidth'], + 'MAXHEIGHT' => $_POST['maxheight'], + 'RECENT_PERIOD' => $_POST['recent_period'], + 'EXPAND_YES' => 'true' == $_POST['expand'] ? 'checked="checked"' : '', + 'EXPAND_NO' => 'false' == $_POST['expand'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_YES' => + 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_NO' => + 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '' + )); +} +else +{ + $template->assign_vars( + array( + 'NB_IMAGE_LINE' => $conf['nb_image_line'], + 'NB_LINE_PAGE' => $conf['nb_line_page'], + 'MAXWIDTH' => @$conf['default_maxwidth'], + 'MAXHEIGHT' => @$conf['default_maxheight'], + 'RECENT_PERIOD' => $conf['recent_period'], + 'EXPAND_YES' => $conf['auto_expand'] ? 'checked="checked"' : '', + 'EXPAND_NO' => !$conf['auto_expand'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_YES' => + $conf['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_NO' => + !$conf['show_nb_comments'] ? 'checked="checked"' : '' + )); +} + +$blockname = 'template_option'; + +foreach (get_templates() as $pwg_template) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; + } + else if ($conf['default_template'] == $pwg_template) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $pwg_template, + 'CONTENT' => $pwg_template, + 'SELECTED' => $selected + )); +} + +$blockname = 'language_option'; + +foreach (get_languages() as $language_code => $language_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['language']==$language_code ? 'selected="selected"':''; + } + else if ($conf['default_language'] == $language_code) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $language_code, + 'CONTENT' => $language_name, + 'SELECTED' => $selected + )); +} + +$blockname = 'pref_status_option'; + +foreach (get_enums(USERS_TABLE, 'status') as $status) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['status'] == $status ? 'selected="selected"' : ''; + } + else if ('guest' == $status) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $status, + 'CONTENT' => $lang['user_status_'.$status], + 'SELECTED' => $selected + )); +} + +// associate +$blockname = 'associate_option'; + +$template->assign_block_vars( + $blockname, + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + )); + +foreach ($groups as $group_id => $group_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['associate'] == $group_id ? 'selected="selected"' : ''; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $group_id, + 'CONTENT' => $group_name, + 'SELECTED' => $selected + )); +} + +// dissociate +$blockname = 'dissociate_option'; + +$template->assign_block_vars( + $blockname, + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + )); + +foreach ($groups as $group_id => $group_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['dissociate'] == $group_id ? 'selected="selected"' : ''; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $group_id, + 'CONTENT' => $group_name, + 'SELECTED' => $selected + )); +} + // +-----------------------------------------------------------------------+ // | filter | // +-----------------------------------------------------------------------+ @@ -261,7 +592,6 @@ $perm_url = PHPWG_ROOT_PATH.'admin.php?page=user_perm&user_id='; $users = array(); $user_ids = array(); -$groups_content = array(); $order_by = 'id'; if (isset($_GET['order_by']) @@ -311,32 +641,45 @@ while ($row = mysql_fetch_array($result)) if (count($user_ids) > 0) { $query = ' -SELECT user_id, group_id, name - FROM '.USER_GROUP_TABLE.' INNER JOIN '.GROUPS_TABLE.' ON group_id = id +SELECT user_id, group_id + FROM '.USER_GROUP_TABLE.' WHERE user_id IN ('.implode(',', $user_ids).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_array($result)) { - $groups_content[$row['group_id']] = $row['name']; array_push($user_groups[$row['user_id']], $row['group_id']); } - foreach ($users as $item) + foreach ($users as $num => $item) { - $groups = preg_replace('/(\d+)/e', - "\$groups_content['$1']", - implode(', ', $user_groups[$item['id']])); + $groups_string = preg_replace('/(\d+)/e', + "\$groups['$1']", + implode(', ', $user_groups[$item['id']])); + + if (isset($_POST['pref_submit']) + and isset($_POST['selection']) + and in_array($item['id'], $_POST['selection'])) + { + $checked = 'checked="checked"'; + } + else + { + $checked = ''; + } $template->assign_block_vars( 'user', array( + 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1', + 'ID'=>$item['id'], + 'CHECKED'=>$checked, 'U_MOD'=>add_session_id($profile_url.$item['id']), 'U_PERM'=>add_session_id($perm_url.$item['id']), 'USERNAME'=>$item['username'], 'STATUS'=>$lang['user_status_'.$item['status']], 'EMAIL'=>isset($item['mail_address']) ? $item['mail_address'] : '', - 'GROUPS'=>$groups + 'GROUPS'=>$groups_string )); } } diff --git a/doc/ChangeLog b/doc/ChangeLog index cff4f3ff0..2887060bb 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,16 @@ +2005-05-10 Pierrick LE GALL + + * user list : links to profile page and permissions page are + represented by icons (more compact) + + * user list : ability to associate to a group or to dissociate + from a group a list of selected users + + * user list : ability to set user properties in "batch" mode (a + selection of users at once) + + * user list : alternate background color for each line + 2005-04-30 Pierrick LE GALL * user list updated : ability to filter list on status. Function diff --git a/include/user.inc.php b/include/user.inc.php index 6e5e0c8ed..b388943c0 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -26,13 +26,17 @@ // +-----------------------------------------------------------------------+ // Dynamic change of language with database persistency -if (isset($_POST['language'])) -{ - $query = "UPDATE ".USERS_TABLE." SET language = '"; - $query.= $_POST['language']; - $query.= "' WHERE id = ".$_POST['userid'].";"; - pwg_query($query); -} +// +// FIXME : ce bout de code fait planter l'assignation d'un language a +// plusieurs users simultanement dans la nouvelle page admin/user_list.php +// +// if (isset($_POST['language'])) +// { +// $query = "UPDATE ".USERS_TABLE." SET language = '"; +// $query.= $_POST['language']; +// $query.= "' WHERE id = ".$_POST['userid'].";"; +// pwg_query($query); +// } // retrieving connected user informations diff --git a/template/default/admin/user_list.tpl b/template/default/admin/user_list.tpl index 215564879..1b25a251e 100644 --- a/template/default/admin/user_list.tpl +++ b/template/default/admin/user_list.tpl @@ -52,8 +52,11 @@ </form> -<table style="width:100%;" > +<form method="post" name="preferences" action="{F_PREF_ACTION}"> + +<table class="table2" style="width:100%;" > <tr class="throw"> + <th style="width:1%;"></th> <th style="width:20%;">{L_USERNAME}</th> <th style="width:20%;">{L_STATUS}</th> <th style="width:30%;">{L_EMAIL}</th> @@ -61,13 +64,175 @@ <th style="width:1%;">{L_ACTIONS}</th> </tr> <!-- BEGIN user --> - <tr> - <td><a href="{user.U_MOD}">{user.USERNAME}</a></td> + <tr class="{user.CLASS}"> + <td><input type="checkbox" name="selection[]" value="{user.ID}" {user.CHECKED} id="selection-{user.ID}" /></td> + <td><label for="selection-{user.ID}">{user.USERNAME}</label></td> <td>{user.STATUS}</td> <td>{user.EMAIL}</td> <td>{user.GROUPS}</td> - <td>[<a href="{user.U_PERM}">{L_PERMISSIONS}</a>]</td> + <td style="text-align:center;"> + <a href="{user.U_MOD}"><img src="./template/default/theme/profile.png" style="border:none" alt="profile" title="profile" /></a> + <a href="{user.U_PERM}"><img src="./template/default/theme/permissions.png" style="border:none" alt="{L_PERMISSIONS}" title="{L_PERMISSIONS}" /></a> + </td> </tr> <!-- END user --> </table> <div class="navigationBar">{NAVBAR}</div> + +<!-- form to set properties for many users at once --> +<div class="admin">Preferences</div> + +<table> + + <tr> + <td>associate to groupe</td> + <td> + <select name="associate" size="1"> + <!-- BEGIN associate_option --> + <option {associate_option.SELECTED} value="{associate_option.VALUE}">{associate_option.CONTENT}</option> + <!-- END associate_option --> + </select> + </td> + </tr> + + <tr> + <td>dissociate from groupe</td> + <td> + <select name="dissociate" size="1"> + <!-- BEGIN dissociate_option --> + <option {dissociate_option.SELECTED} value="{dissociate_option.VALUE}">{dissociate_option.CONTENT}</option> + <!-- END dissociate_option --> + </select> + </td> + </tr> + + <tr> + <td>{L_NB_IMAGE_LINE}</td> + <td> + <input type="radio" name="nb_image_line_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="nb_image_line_action" value="set" id="nb_image_line_action_set" /> set to + <input onmousedown="document.getElementById('nb_image_line_action_set').checked = true;" + size="3" maxlength="2" type="text" name="nb_image_line" value="{NB_IMAGE_LINE}" /> + </td> + </tr> + + <tr> + <td>{L_NB_LINE_PAGE}</td> + <td> + <input type="radio" name="nb_line_page_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="nb_line_page_action" value="set" id="nb_line_page_action_set" /> set to + <input onmousedown="document.getElementById('nb_line_page_action_set').checked = true;" + size="3" maxlength="2" type="text" name="nb_line_page" value="{NB_LINE_PAGE}" /> + <td> + </tr> + + <tr> + <td>{L_TEMPLATE}</td> + <td> + <input type="radio" name="template_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="template_action" value="set" id="template_action_set" /> set to + <select onmousedown="document.getElementById('template_action_set').checked = true;" name="template" size="1"> + <!-- BEGIN template_option --> + <option {template_option.SELECTED} value="{template_option.VALUE}">{template_option.CONTENT}</option> + <!-- END template_option --> + </select> + </td> + </tr> + + <tr> + <td>{L_LANGUAGE}</td> + <td> + <input type="radio" name="language_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="language_action" value="set" id="language_action_set" /> set to + <select onmousedown="document.getElementById('language_action_set').checked = true;" name="language" size="1"> + <!-- BEGIN language_option --> + <option {language_option.SELECTED} value="{language_option.VALUE}">{language_option.CONTENT}</option> + <!-- END language_option --> + </select> + </td> + </tr> + + <tr> + <td>{L_RECENT_PERIOD}</td> + <td> + <input type="radio" name="recent_period_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="recent_period_action" value="set" id="recent_period_action_set" /> set to + <input onmousedown="document.getElementById('recent_period_action_set').checked = true;" + type="text" size="3" maxlength="2" name="recent_period" value="{RECENT_PERIOD}" /> + </td> + </tr> + + <tr> + <td>{L_EXPAND}</td> + <td> + <input type="radio" name="expand_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="expand_action" value="set" id="expand_action_set" /> set to + <input onmousedown="document.getElementById('expand_action_set').checked = true;" + type="radio" class="radio" name="expand" value="true" {EXPAND_YES} />{L_YES} + <input onmousedown="document.getElementById('expand_action_set').checked = true;" + type="radio" class="radio" name="expand" value="false" {EXPAND_NO} />{L_NO} + </td> + </tr> + + <tr> + <td>{L_SHOW_NB_COMMENTS}</td> + <td> + <input type="radio" name="show_nb_comments_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="show_nb_comments_action" value="set" id="show_nb_comments_action_set" /> set to + <input onmousedown="document.getElementById('show_nb_comments_action_set').checked = true;" + type="radio" class="radio" name="show_nb_comments" value="true" {SHOW_NB_COMMENTS_YES} />{L_YES} + <input onmousedown="document.getElementById('show_nb_comments_action_set').checked = true;" + type="radio" class="radio" name="show_nb_comments" value="false" {SHOW_NB_COMMENTS_NO} />{L_NO} + </td> + </tr> + + <tr> + <td>{L_MAXWIDTH}</td> + <td> + <input type="radio" name="maxwidth_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="maxwidth_action" value="unset" /> unset + <input type="radio" name="maxwidth_action" value="set" id="maxwidth_action_set" /> set to + <input onmousedown="document.getElementById('maxwidth_action_set').checked = true;" + type="text" size="4" maxlength="4" name="maxwidth" value="{MAXWIDTH}" /> + </td> + </tr> + + + <tr> + <td>{L_MAXHEIGHT}</td> + <td> + <input type="radio" name="maxheight_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="maxheight_action" value="unset" /> unset + <input type="radio" name="maxheight_action" value="set" id="maxheight_action_set" /> set to + <input onmousedown="document.getElementById('maxheight_action_set').checked = true;" + type="text" size="4" maxlength="4" name="maxheight" value="{maxheight}" /> + </td> + </tr> + + <tr> + <td>{L_STATUS}</td> + <td> + <input type="radio" name="status_action" value="leave" checked="checked" /> leave unchanged + <input type="radio" name="status_action" value="set" id="status_action_set" /> set to + <select onmousedown="document.getElementById('status_action_set').checked = true;" name="status" size="1"> + <!-- BEGIN pref_status_option --> + <option {pref_status_option.SELECTED} value="{pref_status_option.VALUE}">{pref_status_option.CONTENT}</option> + <!-- END pref_status_option --> + </select> + </td> + </tr> + +</table> + +<p style="text-align:center;"> + target + <input type="radio" name="target" value="all" /> all + <input type="radio" name="target" value="selection" checked="checked" /> selection +</p> + +<p style="text-align:center;"> + <input type="submit" value="{L_SUBMIT}" name="pref_submit" class="bouton" /> + <input type="reset" value="{L_RESET}" name="pref_reset" class="bouton" /> +</p> + +</form> diff --git a/template/default/default.css b/template/default/default.css index 8337b8dbc..35f54769c 100644 --- a/template/default/default.css +++ b/template/default/default.css @@ -376,4 +376,8 @@ div.remoteLocal { } /* for debugging purpose */ -pre { text-align:left; }
\ No newline at end of file +pre { text-align:left; } + +label:hover { + cursor: pointer; +} diff --git a/template/default/theme/permissions.png b/template/default/theme/permissions.png Binary files differnew file mode 100644 index 000000000..5758896de --- /dev/null +++ b/template/default/theme/permissions.png diff --git a/template/default/theme/profile.png b/template/default/theme/profile.png Binary files differnew file mode 100644 index 000000000..d04cb347b --- /dev/null +++ b/template/default/theme/profile.png |