Code Duplication    Length = 86-86 lines in 2 locations

index.php 1 location

@@ 134-219 (lines=86) @@
131
    $xoopsTpl->assign( 'total_found', $total );
132
	$xoopsTpl->assign( 'totalmember', $total );
133
134
    if ( $total == 0 ) {
135
    } elseif ( $start < $total ) {
136
        if ( $iamadmin ) {
137
            $xoopsTpl->assign( 'is_admin', true );
138
        }
139
        $criteria->setSort( $sort );
140
        $criteria->setOrder( $order );
141
        $criteria->setStart( $start );
142
        $criteria->setLimit( $limit );
143
        $foundusers = $member_handler->getUsers( $criteria, true );
144
        foreach ( array_keys( $foundusers ) as $j ) {
145
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
146
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
147
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
148
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
149
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
150
                $userdata["email"] = '<a href="mailto:' . $foundusers[$j]->getVar( 'email' ) . '"><img src="' . XOOPS_URL . '/images/icons/email.gif" border="0" alt="' . sprintf( _SENDEMAILTO, $foundusers[$j]->getVar( 'uname', "e" ) ) . '" /></a>';
151
            } else {
152
                $userdata["email"] = '&nbsp;';
153
            }
154
            if ( $xoopsUser ) {
155
                $userdata["pmlink"] = '<a href="javascript:openWithSelfMain(\'' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $foundusers[$j]->getVar( 'uid' ) . '\',\'pmlite\',450,370);"><img src="' . XOOPS_URL . '/images/icons/pm.gif" border="0" alt="' . sprintf( _SENDPMTO, $foundusers[$j]->getVar( 'uname', "e" ) ) . '" /></a>';
156
            } else {
157
                $userdata["pmlink"] = '&nbsp;';
158
            }
159
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
160
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
161
            } else {
162
                $userdata["website"] = '&nbsp;';
163
            }
164
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
165
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
166
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
167
            } else {
168
                $userdata["lastlogin"] = '&nbsp;';
169
            }
170
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
171
            if ( $iamadmin ) {
172
                $userdata["adminlink"] = '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;uid=' . $foundusers[$j]->getVar( 'uid' ) . '&amp;op=users_edit">' . '<img src='. $pathIcon16 .'/edit.png'." alt='" . _EDIT . "' title='" . _EDIT . "' />"
173
174
                . '</a> | <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;op=users_delete&amp;uid=' . $foundusers[$j]->getVar( 'uid' ) . '">' . '<img src='. $pathIcon16 .'/delete.png'." alt='" . _DELETE . "' title='" . _DELETE . "' />" . '</a>';
175
            }
176
            $xoopsTpl->append( "users", $userdata );
177
        }
178
179
        $totalpages = ceil( $total / $limit );
180
        if ( $totalpages > 1 ) {
181
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
182
            foreach ( $_POST as $k => $v ) {
183
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
184
            }
185
            if ( !isset( $_POST['limit'] ) ) {
186
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
187
            }
188
            if ( !isset( $_POST['start'] ) ) {
189
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
190
            }
191
            $prev = $start - $limit;
192
            if ( $start - $limit >= 0 ) {
193
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
194
            }
195
            $counter = 1;
196
            $currentpage = ( $start + $limit ) / $limit;
197
            while ( $counter <= $totalpages ) {
198
                if ( $counter == $currentpage ) {
199
                    $hiddenform .= '<b>' . $counter . '</b> ';
200
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
201
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
202
                        $hiddenform .= '... ';
203
                    }
204
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
205
                    if ( $counter == 1 && $currentpage > 5 ) {
206
                        $hiddenform .= '... ';
207
                    }
208
                }
209
                $counter++;
210
            }
211
            $next = $start + $limit;
212
            if ( $total > $next ) {
213
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
214
            }
215
            $hiddenform .= '</form>';
216
            $xoopsTpl->assign( 'pagenav', $hiddenform );
217
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
218
        }
219
    }
220
221
222
include_once XOOPS_ROOT_PATH . '/footer.php';

searchmembers.php 1 location

@@ 189-274 (lines=86) @@
186
    $total = $member_handler->getUserCount( $criteria );
187
    $xoopsTpl->assign( 'total_found', $total );
188
189
    if ( $total == 0 ) {
190
    } elseif ( $start < $total ) {
191
        if ( $iamadmin ) {
192
            $xoopsTpl->assign( 'is_admin', true );
193
        }
194
        $criteria->setSort( $sort );
195
        $criteria->setOrder( $order );
196
        $criteria->setStart( $start );
197
        $criteria->setLimit( $limit );
198
        $foundusers = $member_handler->getUsers( $criteria, true );
199
        foreach ( array_keys( $foundusers ) as $j ) {
200
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
201
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
202
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
203
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
204
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
205
                $userdata["email"] = '<a href="mailto:' . $foundusers[$j]->getVar( 'email' ) . '"><img src="' . XOOPS_URL . '/images/icons/email.gif" border="0" alt="' . sprintf( _SENDEMAILTO, $foundusers[$j]->getVar( 'uname', "e" ) ) . '" /></a>';
206
            } else {
207
                $userdata["email"] = '&nbsp;';
208
            }
209
            if ( $xoopsUser ) {
210
                $userdata["pmlink"] = '<a href="javascript:openWithSelfMain(\'' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $foundusers[$j]->getVar( 'uid' ) . '\',\'pmlite\',450,370);"><img src="' . XOOPS_URL . '/images/icons/pm.gif" border="0" alt="' . sprintf( _SENDPMTO, $foundusers[$j]->getVar( 'uname', "e" ) ) . '" /></a>';
211
            } else {
212
                $userdata["pmlink"] = '&nbsp;';
213
            }
214
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
215
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
216
            } else {
217
                $userdata["website"] = '&nbsp;';
218
            }
219
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
220
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
221
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
222
            } else {
223
                $userdata["lastlogin"] = '&nbsp;';
224
            }
225
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
226
            if ( $iamadmin ) {
227
                $userdata["adminlink"] = '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;uid=' . $foundusers[$j]->getVar( 'uid' ) . '&amp;op=users_edit">' . '<img src='. $pathIcon16 .'/edit.png'." alt='" . _EDIT . "' title='" . _EDIT . "' />"
228
229
                . '</a> | <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;op=users_delete&amp;uid=' . $foundusers[$j]->getVar( 'uid' ) . '">' . '<img src='. $pathIcon16 .'/delete.png'." alt='" . _DELETE . "' title='" . _DELETE . "' />" . '</a>';
230
            }
231
            $xoopsTpl->append( "users", $userdata );
232
        }
233
234
        $totalpages = ceil( $total / $limit );
235
        if ( $totalpages > 1 ) {
236
            $hiddenform = '<form name="findnext" action="searchmembers.php" method="post">';
237
            foreach ( $_POST as $k => $v ) {
238
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
239
            }
240
            if ( !isset( $_POST['limit'] ) ) {
241
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
242
            }
243
            if ( !isset( $_POST['start'] ) ) {
244
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
245
            }
246
            $prev = $start - $limit;
247
            if ( $start - $limit >= 0 ) {
248
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
249
            }
250
            $counter = 1;
251
            $currentpage = ( $start + $limit ) / $limit;
252
            while ( $counter <= $totalpages ) {
253
                if ( $counter == $currentpage ) {
254
                    $hiddenform .= '<b>' . $counter . '</b> ';
255
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
256
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
257
                        $hiddenform .= '... ';
258
                    }
259
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
260
                    if ( $counter == 1 && $currentpage > 5 ) {
261
                        $hiddenform .= '... ';
262
                    }
263
                }
264
                $counter++;
265
            }
266
            $next = $start + $limit;
267
            if ( $total > $next ) {
268
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
269
            }
270
            $hiddenform .= '</form>';
271
            $xoopsTpl->assign( 'pagenav', $hiddenform );
272
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
273
        }
274
    }
275
}
276
277
include_once XOOPS_ROOT_PATH . '/footer.php';