Changeset 787
- Timestamp:
- May 10, 2005, 12:34:21 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/user_list.php
r786 r787 53 53 54 54 // +-----------------------------------------------------------------------+ 55 // | preferences form submission | 56 // +-----------------------------------------------------------------------+ 57 58 $errors = array(); 59 60 if (isset($_POST['pref_submit'])) 61 { 62 $collection = array(); 63 64 switch ($_POST['target']) 65 { 66 case 'all' : 67 { 68 $query = ' 69 SELECT id 70 FROM '.USERS_TABLE.' 71 WHERE id != 2 72 ;'; 73 $collection = array_from_query($query, 'id'); 74 break; 75 } 76 case 'selection' : 77 { 78 $collection = $_POST['selection']; 79 break; 80 } 81 } 82 83 if (-1 != $_POST['associate']) 84 { 85 $datas = array(); 86 87 $query = ' 88 SELECT user_id 89 FROM '.USER_GROUP_TABLE.' 90 WHERE group_id = '.$_POST['associate'].' 91 ;'; 92 $associated = array_from_query($query, 'user_id'); 93 94 // TODO : if $associable array is empty, no further actions 95 $associable = array_diff($collection, $associated); 96 97 foreach ($associable as $item) 98 { 99 array_push($datas, 100 array('group_id'=>$_POST['associate'], 101 'user_id'=>$item)); 102 } 103 104 mass_inserts(USER_GROUP_TABLE, 105 array('group_id', 'user_id'), 106 $datas); 107 } 108 109 if (-1 != $_POST['dissociate']) 110 { 111 $query = ' 112 DELETE FROM '.USER_GROUP_TABLE.' 113 WHERE group_id = '.$_POST['dissociate'].' 114 AND user_id IN ('.implode(',', $collection).') 115 '; 116 pwg_query($query); 117 } 118 119 // properties to set for the collection (a user list) 120 $datas = array(); 121 $dbfields = array('primary' => array('id'), 'update' => array()); 122 123 $formfields = array('nb_image_line', 'nb_line_page', 'template', 'language', 124 'recent_period', 'expand', 'show_nb_comments', 125 'maxwidth', 'maxheight', 'status'); 126 127 foreach ($formfields as $formfield) 128 { 129 if ($_POST[$formfield.'_action'] != 'leave') 130 { 131 array_push($dbfields['update'], $formfield); 132 } 133 } 134 135 // updating elements is useful only if needed... 136 if (count($dbfields['update']) > 0) 137 { 138 $datas = array(); 139 140 foreach ($collection as $user_id) 141 { 142 $data = array(); 143 $data['id'] = $user_id; 144 145 // TODO : verify if submited values are semanticaly correct 146 foreach ($dbfields['update'] as $dbfield) 147 { 148 // if the action is 'unset', the key won't be in row and 149 // mass_updates function will set this field to NULL 150 if ('set' == $_POST[$dbfield.'_action']) 151 { 152 $data[$dbfield] = $_POST[$dbfield]; 153 } 154 } 155 156 // Webmaster (user_id = 1) status must not be changed 157 if (1 == $user_id and isset($data['status'])) 158 { 159 $data['status'] = 'admin'; 160 } 161 162 array_push($datas, $data); 163 } 164 165 // echo '<pre>'; print_r($dbfields); echo '</pre>'; 166 // echo '<pre>'; print_r($datas); echo '</pre>'; 167 mass_updates(USERS_TABLE, $dbfields, $datas); 168 } 169 } 170 171 // +-----------------------------------------------------------------------+ 172 // | groups list | 173 // +-----------------------------------------------------------------------+ 174 175 $groups = array(); 176 177 $query = ' 178 SELECT id, name 179 FROM '.GROUPS_TABLE.' 180 ;'; 181 $result = pwg_query($query); 182 183 while ($row = mysql_fetch_array($result)) 184 { 185 $groups[$row['id']] = $row['name']; 186 } 187 188 // +-----------------------------------------------------------------------+ 55 189 // | template init | 56 190 // +-----------------------------------------------------------------------+ … … 84 218 'L_PERMISSIONS' => $lang['permissions'], 85 219 'L_USERS_LIST' => $lang['title_liste_users'], 220 'L_LANGUAGE' => $lang['language'], 221 'L_NB_IMAGE_LINE' => $lang['nb_image_per_row'], 222 'L_NB_LINE_PAGE' => $lang['nb_row_per_page'], 223 'L_TEMPLATE' => $lang['theme'], 224 'L_RECENT_PERIOD' => $lang['recent_period'], 225 'L_EXPAND' => $lang['auto_expand'], 226 'L_SHOW_NB_COMMENTS' => $lang['show_nb_comments'], 227 'L_MAXWIDTH' => $lang['maxwidth'], 228 'L_MAXHEIGHT' => $lang['maxheight'], 229 'L_YES' => $lang['yes'], 230 'L_NO' => $lang['no'], 231 'L_SUBMIT' => $lang['submit'], 232 'L_RESET' => $lang['reset'], 233 'L_DELETE' => $lang['user_delete'], 234 'L_DELETE_HINT' => $lang['user_delete_hint'], 86 235 87 236 'F_ADD_ACTION' => $base_url, … … 137 286 )); 138 287 139 $query = ' 140 SELECT id, name 141 FROM '.GROUPS_TABLE.' 142 ;'; 143 $result = pwg_query($query); 144 145 while ($row = mysql_fetch_array($result)) 146 { 147 $selected = (isset($_GET['group']) and $_GET['group'] == $row['id']) ? 288 foreach ($groups as $group_id => $group_name) 289 { 290 $selected = (isset($_GET['group']) and $_GET['group'] == $group_id) ? 148 291 'selected="selected"' : ''; 149 292 $template->assign_block_vars( 150 293 $blockname, 151 294 array( 152 'VALUE' => $ row['id'],153 'CONTENT' => $ row['name'],295 'VALUE' => $group_id, 296 'CONTENT' => $group_name, 154 297 'SELECTED' => $selected 155 298 )); … … 179 322 } 180 323 324 // --- 325 // $user['template'] = $conf['default_template']; 326 // $user['nb_image_line'] = $conf['nb_image_line']; 327 // $user['nb_line_page'] = $conf['nb_line_page']; 328 // $user['language'] = $conf['default_language']; 329 // $user['maxwidth'] = $conf['default_maxwidth']; 330 // $user['maxheight'] = $conf['default_maxheight']; 331 // $user['recent_period'] = $conf['recent_period']; 332 // $user['expand'] = $conf['auto_expand']; 333 // $user['show_nb_comments'] = $conf['show_nb_comments']; 334 // --- 335 336 if (isset($_POST['pref_submit'])) 337 { 338 // echo '<pre>'; print_r($_POST); echo '</pre>'; 339 $template->assign_vars( 340 array( 341 'NB_IMAGE_LINE' => $_POST['nb_image_line'], 342 'NB_LINE_PAGE' => $_POST['nb_line_page'], 343 'MAXWIDTH' => $_POST['maxwidth'], 344 'MAXHEIGHT' => $_POST['maxheight'], 345 'RECENT_PERIOD' => $_POST['recent_period'], 346 'EXPAND_YES' => 'true' == $_POST['expand'] ? 'checked="checked"' : '', 347 'EXPAND_NO' => 'false' == $_POST['expand'] ? 'checked="checked"' : '', 348 'SHOW_NB_COMMENTS_YES' => 349 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', 350 'SHOW_NB_COMMENTS_NO' => 351 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '' 352 )); 353 } 354 else 355 { 356 $template->assign_vars( 357 array( 358 'NB_IMAGE_LINE' => $conf['nb_image_line'], 359 'NB_LINE_PAGE' => $conf['nb_line_page'], 360 'MAXWIDTH' => @$conf['default_maxwidth'], 361 'MAXHEIGHT' => @$conf['default_maxheight'], 362 'RECENT_PERIOD' => $conf['recent_period'], 363 'EXPAND_YES' => $conf['auto_expand'] ? 'checked="checked"' : '', 364 'EXPAND_NO' => !$conf['auto_expand'] ? 'checked="checked"' : '', 365 'SHOW_NB_COMMENTS_YES' => 366 $conf['show_nb_comments'] ? 'checked="checked"' : '', 367 'SHOW_NB_COMMENTS_NO' => 368 !$conf['show_nb_comments'] ? 'checked="checked"' : '' 369 )); 370 } 371 372 $blockname = 'template_option'; 373 374 foreach (get_templates() as $pwg_template) 375 { 376 if (isset($_POST['pref_submit'])) 377 { 378 $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; 379 } 380 else if ($conf['default_template'] == $pwg_template) 381 { 382 $selected = 'selected="selected"'; 383 } 384 else 385 { 386 $selected = ''; 387 } 388 389 $template->assign_block_vars( 390 $blockname, 391 array( 392 'VALUE'=> $pwg_template, 393 'CONTENT' => $pwg_template, 394 'SELECTED' => $selected 395 )); 396 } 397 398 $blockname = 'language_option'; 399 400 foreach (get_languages() as $language_code => $language_name) 401 { 402 if (isset($_POST['pref_submit'])) 403 { 404 $selected = $_POST['language']==$language_code ? 'selected="selected"':''; 405 } 406 else if ($conf['default_language'] == $language_code) 407 { 408 $selected = 'selected="selected"'; 409 } 410 else 411 { 412 $selected = ''; 413 } 414 415 $template->assign_block_vars( 416 $blockname, 417 array( 418 'VALUE'=> $language_code, 419 'CONTENT' => $language_name, 420 'SELECTED' => $selected 421 )); 422 } 423 424 $blockname = 'pref_status_option'; 425 426 foreach (get_enums(USERS_TABLE, 'status') as $status) 427 { 428 if (isset($_POST['pref_submit'])) 429 { 430 $selected = $_POST['status'] == $status ? 'selected="selected"' : ''; 431 } 432 else if ('guest' == $status) 433 { 434 $selected = 'selected="selected"'; 435 } 436 else 437 { 438 $selected = ''; 439 } 440 441 $template->assign_block_vars( 442 $blockname, 443 array( 444 'VALUE' => $status, 445 'CONTENT' => $lang['user_status_'.$status], 446 'SELECTED' => $selected 447 )); 448 } 449 450 // associate 451 $blockname = 'associate_option'; 452 453 $template->assign_block_vars( 454 $blockname, 455 array( 456 'VALUE'=> -1, 457 'CONTENT' => '------------', 458 'SELECTED' => '' 459 )); 460 461 foreach ($groups as $group_id => $group_name) 462 { 463 if (isset($_POST['pref_submit'])) 464 { 465 $selected = $_POST['associate'] == $group_id ? 'selected="selected"' : ''; 466 } 467 else 468 { 469 $selected = ''; 470 } 471 472 $template->assign_block_vars( 473 $blockname, 474 array( 475 'VALUE' => $group_id, 476 'CONTENT' => $group_name, 477 'SELECTED' => $selected 478 )); 479 } 480 481 // dissociate 482 $blockname = 'dissociate_option'; 483 484 $template->assign_block_vars( 485 $blockname, 486 array( 487 'VALUE'=> -1, 488 'CONTENT' => '------------', 489 'SELECTED' => '' 490 )); 491 492 foreach ($groups as $group_id => $group_name) 493 { 494 if (isset($_POST['pref_submit'])) 495 { 496 $selected = $_POST['dissociate'] == $group_id ? 'selected="selected"' : ''; 497 } 498 else 499 { 500 $selected = ''; 501 } 502 503 $template->assign_block_vars( 504 $blockname, 505 array( 506 'VALUE' => $group_id, 507 'CONTENT' => $group_name, 508 'SELECTED' => $selected 509 )); 510 } 511 181 512 // +-----------------------------------------------------------------------+ 182 513 // | filter | … … 262 593 $users = array(); 263 594 $user_ids = array(); 264 $groups_content = array();265 595 266 596 $order_by = 'id'; … … 312 642 { 313 643 $query = ' 314 SELECT user_id, group_id , name315 FROM '.USER_GROUP_TABLE.' INNER JOIN '.GROUPS_TABLE.' ON group_id = id644 SELECT user_id, group_id 645 FROM '.USER_GROUP_TABLE.' 316 646 WHERE user_id IN ('.implode(',', $user_ids).') 317 647 ;'; … … 319 649 while ($row = mysql_fetch_array($result)) 320 650 { 321 $groups_content[$row['group_id']] = $row['name'];322 651 array_push($user_groups[$row['user_id']], $row['group_id']); 323 652 } 324 653 325 foreach ($users as $item) 326 { 327 $groups = preg_replace('/(\d+)/e', 328 "\$groups_content['$1']", 329 implode(', ', $user_groups[$item['id']])); 654 foreach ($users as $num => $item) 655 { 656 $groups_string = preg_replace('/(\d+)/e', 657 "\$groups['$1']", 658 implode(', ', $user_groups[$item['id']])); 659 660 if (isset($_POST['pref_submit']) 661 and isset($_POST['selection']) 662 and in_array($item['id'], $_POST['selection'])) 663 { 664 $checked = 'checked="checked"'; 665 } 666 else 667 { 668 $checked = ''; 669 } 330 670 331 671 $template->assign_block_vars( 332 672 'user', 333 673 array( 674 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1', 675 'ID'=>$item['id'], 676 'CHECKED'=>$checked, 334 677 'U_MOD'=>add_session_id($profile_url.$item['id']), 335 678 'U_PERM'=>add_session_id($perm_url.$item['id']), … … 337 680 'STATUS'=>$lang['user_status_'.$item['status']], 338 681 'EMAIL'=>isset($item['mail_address']) ? $item['mail_address'] : '', 339 'GROUPS'=>$groups 682 'GROUPS'=>$groups_string 340 683 )); 341 684 } -
trunk/doc/ChangeLog
r777 r787 1 2005-05-10 Pierrick LE GALL 2 3 * user list : links to profile page and permissions page are 4 represented by icons (more compact) 5 6 * user list : ability to associate to a group or to dissociate 7 from a group a list of selected users 8 9 * user list : ability to set user properties in "batch" mode (a 10 selection of users at once) 11 12 * user list : alternate background color for each line 13 1 14 2005-04-30 Pierrick LE GALL 2 15 -
trunk/include/user.inc.php
r772 r787 27 27 28 28 // Dynamic change of language with database persistency 29 if (isset($_POST['language'])) 30 { 31 $query = "UPDATE ".USERS_TABLE." SET language = '"; 32 $query.= $_POST['language']; 33 $query.= "' WHERE id = ".$_POST['userid'].";"; 34 pwg_query($query); 35 } 29 // 30 // FIXME : ce bout de code fait planter l'assignation d'un language a 31 // plusieurs users simultanement dans la nouvelle page admin/user_list.php 32 // 33 // if (isset($_POST['language'])) 34 // { 35 // $query = "UPDATE ".USERS_TABLE." SET language = '"; 36 // $query.= $_POST['language']; 37 // $query.= "' WHERE id = ".$_POST['userid'].";"; 38 // pwg_query($query); 39 // } 36 40 37 41 -
trunk/template/default/admin/user_list.tpl
r777 r787 53 53 </form> 54 54 55 <table style="width:100%;" > 55 <form method="post" name="preferences" action="{F_PREF_ACTION}"> 56 57 <table class="table2" style="width:100%;" > 56 58 <tr class="throw"> 59 <th style="width:1%;"></th> 57 60 <th style="width:20%;">{L_USERNAME}</th> 58 61 <th style="width:20%;">{L_STATUS}</th> … … 62 65 </tr> 63 66 <!-- BEGIN user --> 64 <tr> 65 <td><a href="{user.U_MOD}">{user.USERNAME}</a></td> 67 <tr class="{user.CLASS}"> 68 <td><input type="checkbox" name="selection[]" value="{user.ID}" {user.CHECKED} id="selection-{user.ID}" /></td> 69 <td><label for="selection-{user.ID}">{user.USERNAME}</label></td> 66 70 <td>{user.STATUS}</td> 67 71 <td>{user.EMAIL}</td> 68 72 <td>{user.GROUPS}</td> 69 <td>[<a href="{user.U_PERM}">{L_PERMISSIONS}</a>]</td> 73 <td style="text-align:center;"> 74 <a href="{user.U_MOD}"><img src="./template/default/theme/profile.png" style="border:none" alt="profile" title="profile" /></a> 75 <a href="{user.U_PERM}"><img src="./template/default/theme/permissions.png" style="border:none" alt="{L_PERMISSIONS}" title="{L_PERMISSIONS}" /></a> 76 </td> 70 77 </tr> 71 78 <!-- END user --> 72 79 </table> 73 80 <div class="navigationBar">{NAVBAR}</div> 81 82 <!-- form to set properties for many users at once --> 83 <div class="admin">Preferences</div> 84 85 <table> 86 87 <tr> 88 <td>associate to groupe</td> 89 <td> 90 <select name="associate" size="1"> 91 <!-- BEGIN associate_option --> 92 <option {associate_option.SELECTED} value="{associate_option.VALUE}">{associate_option.CONTENT}</option> 93 <!-- END associate_option --> 94 </select> 95 </td> 96 </tr> 97 98 <tr> 99 <td>dissociate from groupe</td> 100 <td> 101 <select name="dissociate" size="1"> 102 <!-- BEGIN dissociate_option --> 103 <option {dissociate_option.SELECTED} value="{dissociate_option.VALUE}">{dissociate_option.CONTENT}</option> 104 <!-- END dissociate_option --> 105 </select> 106 </td> 107 </tr> 108 109 <tr> 110 <td>{L_NB_IMAGE_LINE}</td> 111 <td> 112 <input type="radio" name="nb_image_line_action" value="leave" checked="checked" /> leave unchanged 113 <input type="radio" name="nb_image_line_action" value="set" id="nb_image_line_action_set" /> set to 114 <input onmousedown="document.getElementById('nb_image_line_action_set').checked = true;" 115 size="3" maxlength="2" type="text" name="nb_image_line" value="{NB_IMAGE_LINE}" /> 116 </td> 117 </tr> 118 119 <tr> 120 <td>{L_NB_LINE_PAGE}</td> 121 <td> 122 <input type="radio" name="nb_line_page_action" value="leave" checked="checked" /> leave unchanged 123 <input type="radio" name="nb_line_page_action" value="set" id="nb_line_page_action_set" /> set to 124 <input onmousedown="document.getElementById('nb_line_page_action_set').checked = true;" 125 size="3" maxlength="2" type="text" name="nb_line_page" value="{NB_LINE_PAGE}" /> 126 <td> 127 </tr> 128 129 <tr> 130 <td>{L_TEMPLATE}</td> 131 <td> 132 <input type="radio" name="template_action" value="leave" checked="checked" /> leave unchanged 133 <input type="radio" name="template_action" value="set" id="template_action_set" /> set to 134 <select onmousedown="document.getElementById('template_action_set').checked = true;" name="template" size="1"> 135 <!-- BEGIN template_option --> 136 <option {template_option.SELECTED} value="{template_option.VALUE}">{template_option.CONTENT}</option> 137 <!-- END template_option --> 138 </select> 139 </td> 140 </tr> 141 142 <tr> 143 <td>{L_LANGUAGE}</td> 144 <td> 145 <input type="radio" name="language_action" value="leave" checked="checked" /> leave unchanged 146 <input type="radio" name="language_action" value="set" id="language_action_set" /> set to 147 <select onmousedown="document.getElementById('language_action_set').checked = true;" name="language" size="1"> 148 <!-- BEGIN language_option --> 149 <option {language_option.SELECTED} value="{language_option.VALUE}">{language_option.CONTENT}</option> 150 <!-- END language_option --> 151 </select> 152 </td> 153 </tr> 154 155 <tr> 156 <td>{L_RECENT_PERIOD}</td> 157 <td> 158 <input type="radio" name="recent_period_action" value="leave" checked="checked" /> leave unchanged 159 <input type="radio" name="recent_period_action" value="set" id="recent_period_action_set" /> set to 160 <input onmousedown="document.getElementById('recent_period_action_set').checked = true;" 161 type="text" size="3" maxlength="2" name="recent_period" value="{RECENT_PERIOD}" /> 162 </td> 163 </tr> 164 165 <tr> 166 <td>{L_EXPAND}</td> 167 <td> 168 <input type="radio" name="expand_action" value="leave" checked="checked" /> leave unchanged 169 <input type="radio" name="expand_action" value="set" id="expand_action_set" /> set to 170 <input onmousedown="document.getElementById('expand_action_set').checked = true;" 171 type="radio" class="radio" name="expand" value="true" {EXPAND_YES} />{L_YES} 172 <input onmousedown="document.getElementById('expand_action_set').checked = true;" 173 type="radio" class="radio" name="expand" value="false" {EXPAND_NO} />{L_NO} 174 </td> 175 </tr> 176 177 <tr> 178 <td>{L_SHOW_NB_COMMENTS}</td> 179 <td> 180 <input type="radio" name="show_nb_comments_action" value="leave" checked="checked" /> leave unchanged 181 <input type="radio" name="show_nb_comments_action" value="set" id="show_nb_comments_action_set" /> set to 182 <input onmousedown="document.getElementById('show_nb_comments_action_set').checked = true;" 183 type="radio" class="radio" name="show_nb_comments" value="true" {SHOW_NB_COMMENTS_YES} />{L_YES} 184 <input onmousedown="document.getElementById('show_nb_comments_action_set').checked = true;" 185 type="radio" class="radio" name="show_nb_comments" value="false" {SHOW_NB_COMMENTS_NO} />{L_NO} 186 </td> 187 </tr> 188 189 <tr> 190 <td>{L_MAXWIDTH}</td> 191 <td> 192 <input type="radio" name="maxwidth_action" value="leave" checked="checked" /> leave unchanged 193 <input type="radio" name="maxwidth_action" value="unset" /> unset 194 <input type="radio" name="maxwidth_action" value="set" id="maxwidth_action_set" /> set to 195 <input onmousedown="document.getElementById('maxwidth_action_set').checked = true;" 196 type="text" size="4" maxlength="4" name="maxwidth" value="{MAXWIDTH}" /> 197 </td> 198 </tr> 199 200 201 <tr> 202 <td>{L_MAXHEIGHT}</td> 203 <td> 204 <input type="radio" name="maxheight_action" value="leave" checked="checked" /> leave unchanged 205 <input type="radio" name="maxheight_action" value="unset" /> unset 206 <input type="radio" name="maxheight_action" value="set" id="maxheight_action_set" /> set to 207 <input onmousedown="document.getElementById('maxheight_action_set').checked = true;" 208 type="text" size="4" maxlength="4" name="maxheight" value="{maxheight}" /> 209 </td> 210 </tr> 211 212 <tr> 213 <td>{L_STATUS}</td> 214 <td> 215 <input type="radio" name="status_action" value="leave" checked="checked" /> leave unchanged 216 <input type="radio" name="status_action" value="set" id="status_action_set" /> set to 217 <select onmousedown="document.getElementById('status_action_set').checked = true;" name="status" size="1"> 218 <!-- BEGIN pref_status_option --> 219 <option {pref_status_option.SELECTED} value="{pref_status_option.VALUE}">{pref_status_option.CONTENT}</option> 220 <!-- END pref_status_option --> 221 </select> 222 </td> 223 </tr> 224 225 </table> 226 227 <p style="text-align:center;"> 228 target 229 <input type="radio" name="target" value="all" /> all 230 <input type="radio" name="target" value="selection" checked="checked" /> selection 231 </p> 232 233 <p style="text-align:center;"> 234 <input type="submit" value="{L_SUBMIT}" name="pref_submit" class="bouton" /> 235 <input type="reset" value="{L_RESET}" name="pref_reset" class="bouton" /> 236 </p> 237 238 </form> -
trunk/template/default/default.css
r772 r787 378 378 /* for debugging purpose */ 379 379 pre { text-align:left; } 380 381 label:hover { 382 cursor: pointer; 383 }
Note: See TracChangeset
for help on using the changeset viewer.