Issues (1014)

Themes/default/Memberlist.template.php (2 issues)

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.0
11
 */
12
13
/**
14
 * Displays a sortable listing of all members registered on the forum.
15
 */
16
function template_main()
17
{
18
	global $context, $settings, $scripturl, $txt;
19
20
	echo '
21
	<div class="main_section" id="memberlist">
22
		<div class="pagesection">
23
			', template_button_strip($context['memberlist_buttons'], 'right'), '
0 ignored issues
show
Are you sure the usage of template_button_strip($c...ist_buttons'], 'right') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
24
			<div class="pagelinks floatleft">', $context['page_index'], '</div>
25
		</div>
26
		<div class="cat_bar">
27
			<h3 class="catbg">
28
				<span class="floatleft">', $txt['members_list'], '</span>';
29
30
	if (!isset($context['old_search']))
31
		echo '
32
				<span class="floatright">', $context['letter_links'], '</span>';
33
	echo '
34
			</h3>
35
		</div>';
36
37
	echo '
38
		<div id="mlist">
39
			<table class="table_grid">
40
				<thead>
41
					<tr class="title_bar">';
42
43
	// Display each of the column headers of the table.
44
	foreach ($context['columns'] as $key => $column)
45
	{
46
		// @TODO maybe find something nicer?
47
		if ($key == 'email_address' && !$context['can_send_email'])
48
			continue;
49
50
		// This is a selected column, so underline it or some such.
51
		if ($column['selected'])
52
			echo '
53
						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '>
54
							<a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="main_icons sort_' . $context['sort_direction'] . '"></span></th>';
55
56
		// This is just some column... show the link and be done with it.
57
		else
58
			echo '
59
						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '>
60
						', $column['link'], '</th>';
61
	}
62
63
	echo '
64
					</tr>
65
				</thead>
66
				<tbody>';
67
68
	// Assuming there are members loop through each one displaying their data.
69
	if (!empty($context['members']))
70
	{
71
		foreach ($context['members'] as $member)
72
		{
73
			echo '
74
					<tr class="windowbg"', empty($member['sort_letter']) ? '' : ' id="letter' . $member['sort_letter'] . '"', '>
75
						<td class="is_online centertext">
76
							', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span>' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', '
77
						</td>
78
						<td class="real_name lefttext">', $member['link'], '</td>';
79
80
			if (!isset($context['disabled_fields']['website']))
81
				echo '
82
						<td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="main_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>';
83
84
			// Group and date.
85
			echo '
86
						<td class="id_group centertext">', empty($member['group']) ? $member['post_group'] : $member['group'], '</td>
87
						<td class="registered centertext">', $member['registered_date'], '</td>';
88
89
			if (!isset($context['disabled_fields']['posts']))
90
			{
91
				echo '
92
						<td class="post_count centertext">';
93
94
				if (!empty($member['posts']))
95
					echo '
96
							<div class="generic_bar">
97
								<div class="bar" style="width: ', $member['post_percent'], '%;"></div>
98
								<span>', $member['posts'], '</span>
99
							</div>';
100
101
				echo '
102
						</td>';
103
			}
104
105
			// Show custom fields marked to be shown here
106
			if (!empty($context['custom_profile_fields']['columns']))
107
				foreach ($context['custom_profile_fields']['columns'] as $key => $column)
108
					echo '
109
						<td class="', $key, ' centertext">', $member['options'][$key], '</td>';
110
111
			echo '
112
					</tr>';
113
		}
114
	}
115
	// No members?
116
	else
117
		echo '
118
					<tr>
119
						<td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td>
120
					</tr>';
121
122
	echo '
123
				</tbody>
124
			</table>
125
		</div><!-- #mlist -->';
126
127
	// Show the page numbers again. (makes 'em easier to find!)
128
	echo '
129
		<div class="pagesection">
130
			<div class="pagelinks floatleft">', $context['page_index'], '</div>';
131
132
	// If it is displaying the result of a search show a "search again" link to edit their criteria.
133
	if (isset($context['old_search']))
134
		echo '
135
			<div class="buttonlist floatright">
136
				<a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>
137
			</div>';
138
	echo '
139
		</div>
140
	</div><!-- #memberlist -->';
141
142
}
143
144
/**
145
 * A page allowing people to search the member list.
146
 */
147
function template_search()
148
{
149
	global $context, $scripturl, $txt;
150
151
	// Start the submission form for the search!
152
	echo '
153
	<form action="', $scripturl, '?action=mlist;sa=search" method="post" accept-charset="', $context['character_set'], '">
154
		<div id="memberlist">
155
			<div class="pagesection">
156
				', template_button_strip($context['memberlist_buttons'], 'right'), '
0 ignored issues
show
Are you sure the usage of template_button_strip($c...ist_buttons'], 'right') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
157
			</div>
158
			<div class="cat_bar">
159
				<h3 class="catbg mlist">
160
					<span class="main_icons filter"></span>', $txt['mlist_search'], '
161
				</h3>
162
			</div>
163
			<div id="advanced_search" class="roundframe">
164
				<dl id="mlist_search" class="settings">
165
					<dt>
166
						<label><strong>', $txt['search_for'], ':</strong></label>
167
					</dt>
168
					<dd>
169
						<input type="text" name="search" value="', $context['old_search'], '" size="40">
170
					</dd>
171
					<dt>
172
						<label><strong>', $txt['mlist_search_filter'], ':</strong></label>
173
					</dt>
174
					<dd>
175
						<ul>';
176
177
	foreach ($context['search_fields'] as $id => $title)
178
		echo '
179
							<li>
180
								<input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '>
181
								<label for="fields-', $id, '">', $title, '</label>
182
							</li>';
183
184
	echo '
185
						</ul>
186
					</dd>
187
				</dl>
188
				<input type="submit" name="submit" value="' . $txt['search'] . '" class="button floatright">
189
			</div><!-- #advanced_search -->
190
		</div><!-- #memberlist -->
191
	</form>';
192
}
193
194
?>