diff -r d807dcd7aed7 -r a8891e108c95 plugins/SpecialUserFuncs.php --- a/plugins/SpecialUserFuncs.php Sun Aug 26 16:48:15 2007 -0400 +++ b/plugins/SpecialUserFuncs.php Sun Aug 26 20:45:33 2007 -0400 @@ -83,6 +83,13 @@ \'namespace\'=>\'Special\', \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', )); + + $paths->add_page(Array( + \'name\'=>\'Member list\', + \'urlname\'=>\'Memberlist\', + \'namespace\'=>\'Special\', + \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', + )); '); // function names are IMPORTANT!!! The name pattern is: page__ @@ -1066,4 +1073,185 @@ $template->footer(); } +function page_Special_Memberlist() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $template->header(); + + $startletters = 'abcdefghijklmnopqrstuvwxyz'; + $startletters = enano_str_split($startletters); + $startletter = ( isset($_GET['letter']) ) ? strtolower($_GET['letter']) : ''; + if ( !in_array($startletter, $startletters) && $startletter != 'chr' ) + { + $startletter = ''; + } + + $startletter_sql = $startletter; + if ( $startletter == 'chr' ) + { + $startletter_sql = '([^a-z])'; + } + + // determine number of rows + $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE u.username REGEXP "^' . $startletter_sql . '" AND u.username != "Anonymous";'); + if ( !$q ) + $db->_die(); + + $num_rows = $db->numrows(); + $db->free_result(); + + // offset + $offset = ( isset($_GET['offset']) && strval(intval($_GET['offset'])) === $_GET['offset']) ? intval($_GET['offset']) : 0; + + // sort order + $sortkeys = array( + 'uid' => 'u.user_id', + 'username' => 'u.username', + 'email' => 'u.email' + ); + + $sortby = ( isset($_GET['sort']) && isset($sortkeys[$_GET['sort']]) ) ? $_GET['sort'] : 'username'; + $sort_sqllet = $sortkeys[$sortby]; + + $target_order = ( isset($_GET['orderby']) && in_array($_GET['orderby'], array('ASC', 'DESC')) )? $_GET['orderby'] : 'ASC'; + + $sortorders = array(); + foreach ( $sortkeys as $k => $_unused ) + { + $sortorders[$k] = ( $sortby == $k ) ? ( $target_order == 'ASC' ? 'DESC' : 'ASC' ) : 'ASC'; + } + + // Why 3.3714%? 100 percent / 28 cells, minus a little (0.2% / cell) to account for cell spacing + + echo '
+ + '; + echo ''; + echo ''; + foreach ( $startletters as $letter ) + { + echo ''; + } + echo ' +
All#' . strtoupper($letter) . '
+
'; + + // formatter parameters + $formatter = new MemberlistFormatter(); + $formatters = array( + 'username' => array($formatter, 'username'), + 'user_level' => array($formatter, 'user_level'), + 'email' => array($formatter, 'email') + ); + + // Column markers + $headings = ' + + # + + + Username + + + E-mail + + '; + + $q = $db->sql_unbuffered_query('SELECT u.user_id, u.username, u.reg_time, u.email, u.user_level, x.email_public FROM '.table_prefix.'users AS u + LEFT JOIN '.table_prefix.'users_extra AS x + ON ( u.user_id = x.user_id ) + WHERE u.username REGEXP "^' . $startletter_sql . '" AND u.username != "Anonymous" + ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';'); + if ( !$q ) + $db->_die(); + + $html = paginate( + $q, // MySQL result resource + ' + {user_id} + {username}
{user_level} + {email} + + ', // TPL code for rows + $num_rows, // Number of results + makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&offset=%s&sort=' . $sortby . '&orderby=' . $target_order ), // Result URL + $offset, // Start at this number + 25, // Results per page + $formatters, // Formatting hooks + '
+ + ' . $headings . ' + ', // Header (printed before rows) + ' ' . $headings . ' +
+
+ ' // Footer (printed after rows) + ); + + if ( $num_rows < 1 ) + { + echo '

Sorry - no users with usernames that start with that letter could be found.

'; + } + else + { + echo $html; + } + + $template->footer(); +} + +/** + * Class for formatting results for the memberlist. + * @access private + */ + +class MemberlistFormatter +{ + function username($username, $row) + { + global $db, $session, $paths, $template, $plugins; // Common objects + $userpage = $paths->nslist['User'] . sanitize_page_id($username); + $class = ( isPage($userpage) ) ? ' title="Click to view this user\'s userpage"' : ' class="wikilink-nonexistent" title="This user hasn\'t created a userpage yet, but you can still view profile details by clicking this link."'; + $anchor = '' . htmlspecialchars($username) . ''; + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + $anchor .= ' - Administer user'; + } + return $anchor; + } + function user_level($level, $row) + { + global $db, $session, $paths, $template, $plugins; // Common objects + switch ( $level ) + { + case USER_LEVEL_GUEST: + $s_level = 'Guest'; break; + case USER_LEVEL_MEMBER: + case USER_LEVEL_CHPREF: + $s_level = 'Member'; break; + case USER_LEVEL_MOD: + $s_level = 'Moderator'; break; + case USER_LEVEL_ADMIN: + $s_level = 'Site administrator'; break; + default: + $s_level = 'Unknown (level ' . $level . ')'; + } + return $s_level; + } + function email($addy, $row) + { + if ( $row['email_public'] == '1' ) + { + global $email; + $addy = $email->encryptEmail($addy); + return $addy; + } + else + { + return '<Non-public>'; + } + } +} + ?> \ No newline at end of file