Show all the members
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Memberlist;
class Memberlist {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $base_url = "";
var $first = 0;
var $max_results = 10;
var $sort_key = 'name';
var $sort_order = 'asc';
var $filter = 'ALL';
var $mem_titles = array();
var $mem_groups = array();
function Memberlist()
{
global $ibforums, $DB, $std, $print;
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 'listall';
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_mlist', $ibforums->lang_id );
$this->html = $std->load_template('skin_mlist');
$this->base_url = $ibforums->base_url;
if ($ibforums->member['g_mem_info'] != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
}
$see_groups = array();
//--------------------------------------------
// Get the member groups, member titles stuff
//--------------------------------------------
$DB->query("SELECT g_title, g_id, g_icon from ibf_groups WHERE g_hide_from_list <> 1 ORDER BY g_title");
while ($row = $DB->fetch_row() )
{
$see_groups[] = $row['g_id'];
$this->mem_groups[ $row['g_id'] ] = array( 'TITLE' => $row['g_title'],
'ICON' => $row['g_icon'],
);
}
unset($row);
$group_string = implode( ",", $see_groups );
$DB->free_result();
$DB->query("SELECT title, id, posts, pips from ibf_titles ORDER BY posts DESC");
while ($row = $DB->fetch_row() )
{
$this->mem_titles[ $row['id'] ] = array( 'TITLE' => $row['title'],
'POSTS' => $row['posts'],
'PIPS' => $row['pips'],
);
}
unset($row);
$DB->free_result();
$the_filter = array( 'ALL' => $ibforums->lang['show_all'] );
foreach($this->mem_groups as $id => $data)
{
if ($id == $ibforums->vars['guest_group'])
{
continue;
}
$the_filter[$id] = $data['TITLE'];
}
//------------------------------------------
// Test for input
//------------------------------------------
if (isset($ibforums->input['st'])) $this->first = intval($ibforums->input['st']);
if (isset($ibforums->input['max_results'])) $this->max_results = $ibforums->input['max_results'];
if (isset($ibforums->input['sort_key'])) $this->sort_key = $ibforums->input['sort_key'];
if (isset($ibforums->input['sort_order'])) $this->sort_order = $ibforums->input['sort_order'];
if (isset($ibforums->input['filter'])) $this->filter = $ibforums->input['filter'];
//------------------------------------------
// Fix up the search box
//------------------------------------------
$ibforums->input['name'] = $std->clean_value(trim(urldecode(stripslashes($ibforums->input['name']))));
if ($ibforums->input['name'] == "")
{
$ibforums->input['name_box'] = 'all';
}
//------------------------------------------
// Init some arrays
//------------------------------------------
$the_sort_key = array( 'name' => 'sort_by_name',
'posts' => 'sort_by_posts',
'joined' => 'sort_by_joined',
);
$the_max_results = array( 10 => '10',
20 => '20',
30 => '30',
40 => '40',
50 => '50',
);
$the_sort_order = array( 'desc' => 'descending_order',
'asc' => 'ascending_order',
);
//------------------------------------------
// Start the form stuff
//------------------------------------------
$filter_html = "", $ibforums->lang['sorting_text'] );
$error = 0;
if (! isset($the_sort_key[ $this->sort_key ]) ) $error = 1;
if (! isset($the_sort_order[ $this->sort_order ]) ) $error = 1;
if (! isset($the_filter[ $this->filter ]) ) $error = 1;
if (! isset($the_max_results[ $this->max_results ]) ) $error = 1;
if ($error == 1 )
{
if ( $ibforums->input['b'] == 1 )
{
$std->Error( array( LEVEL=> 1, MSG =>'ml_error') );
}
else
{
$std->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
}
}
//---------------------------------------------
// Find out how many members match our criteria
//---------------------------------------------
$q_extra = "";
if ($this->filter != 'ALL')
{
// Are we allowed to see this group?
if ( ! preg_match( "/(^|,)".$this->filter."(,|$)/", $group_string ) )
{
$q_extra = " AND m.mgroup IN($group_string)";
}
else
{
$q_extra = " AND m.mgroup='".$this->filter."' ";
}
}
if ($ibforums->input['name_box'] != 'all')
{
if ( $ibforums->input['name_box'] == 'begins' )
{
$q_extra .= " AND m.name LIKE '".$ibforums->input['name']."%'";
}
else
{
$q_extra .= " AND m.name LIKE '%".$ibforums->input['name']."%'";
}
}
if ($ibforums->input['photoonly'] == 1)
{
$DB->query("SELECT COUNT(m.id) as total_members FROM ibf_members m
LEFT JOIN ibf_member_extra me ON me.id=m.id
LEFT JOIN ibf_groups g ON m.mgroup=g.g_id
WHERE me.photo_location <> '' AND m.id > 0 AND g.g_hide_from_list <> 1".$q_extra);
$q_extra .= " AND me.photo_location <> ''";
}
else
{
$DB->query("SELECT COUNT(m.id) as total_members FROM ibf_members m
LEFT JOIN ibf_groups g ON m.mgroup=g.g_id
WHERE m.id > 0 AND g.g_hide_from_list <> 1".$q_extra);
}
$max = $DB->fetch_row();
$DB->free_result();
$links = $std->build_pagelinks( array( 'TOTAL_POSS' => $max['total_members'],
'PER_PAGE' => $this->max_results,
'CUR_ST_VAL' => $this->first,
'L_SINGLE' => "",
'L_MULTI' => $ibforums->lang['pages'],
'BASE_URL' => $this->base_url."&act=Members&photoonly={$ibforums->input['photoonly']}&name=".urlencode($ibforums->input['name'])."&name_box={$ibforums->input['name_box']}&max_results={$this->max_results}&filter={$this->filter}&sort_order={$this->sort_order}&sort_key={$this->sort_key}"
)
);
$this->output = $this->html->start();
$this->output .= $this->html->Page_header( array( 'SHOW_PAGES' => $links) );
//-----------------------------
// START THE LISTING
//-----------------------------
$DB->query("SELECT m.name, m.id, m.posts, m.joined, m.mgroup, m.email,m.title, m.hide_email, m.location, m.aim_name, m.icq_number,
me.photo_location, me.photo_type, me.photo_dimensions
FROM ibf_members m
LEFT JOIN ibf_member_extra me ON me.id=m.id
LEFT JOIN ibf_groups g ON m.mgroup=g.g_id
WHERE m.id > 0".$q_extra." AND g.g_hide_from_list <> 1
ORDER BY m.".$this->sort_key." ".$this->sort_order."
LIMIT ".$this->first.",".$this->max_results);
while($member = $DB->fetch_row() )
{
$pips = 0;
foreach($this->mem_titles as $k => $v)
{
if ($member['posts'] >= $v['POSTS'])
{
if (!$member['title'])
{
$member['title'] = $this->mem_titles[ $k ]['TITLE'];
}
$pips = $v['PIPS'];
break;
}
}
if ($this->mem_groups[ $member['mgroup'] ]['ICON'])
{
$member['pips'] = "
";
}
else
{
if ($pips)
{
if (preg_match( "/^\d+$/", $pips ) )
{
for ($i = 1; $i <= $pips; ++$i)
{
$member['pips'] .= "<{A_STAR}>";
}
}
else
{
$member['pips'] = "
";
}
}
}
$member['joined'] = $std->get_date( $member['joined'], 'JOINED' );
$member['group'] = $this->mem_groups[ $member['mgroup'] ]['TITLE'];
if (!$member['hide_email'])
{
$member['member_email'] = "<{P_EMAIL}>";
}
else
{
$member['member_email'] = ' ';
}
if ($member['icq_number'])
{
$member['icq_number'] = "base_url}act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\"><{P_ICQ}>";
}
else
{
$member['icq_number'] = ' ';
}
if ($member['aim_name'])
{
$member['aim_name'] = "base_url}act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\"><{P_AOL}>";
}
else
{
$member['aim_name'] = ' ';
}
if ($member['photo_type'] and $member['photo_location'])
{
$member['camera'] = "base_url}act=Profile&CODE=showphoto&MID={$member['id']}','Photo','200','250','0','1','1','1')\"><{CAMERA}>";
}
$member['password'] = "";
$member['posts'] = $std->do_number_format($member['posts']);
$this->output .= $this->html->show_row($member);
}
$checked = $ibforums->input['photoonly'] == 1 ? 'checked="checked"' : "";
$this->output .= $this->html->Page_end( $checked );
$this->output .= $this->html->end( array( 'SHOW_PAGES' => $links) );
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->lang['page_title'], 'JS' => 0, NAV => array( $ibforums->lang['page_title'] ) ) );
}
}
?>