Code Duplication    Length = 86-86 lines in 2 locations

index.php 1 location

@@ 158-243 (lines=86) @@
155
    $xoopsTpl->assign( 'total_found', $total );
156
	$xoopsTpl->assign( 'totalmember', $total );
157
158
    if ( $total == 0 ) {
159
    } elseif ( $start < $total ) {
160
        if ( $iamadmin ) {
161
            $xoopsTpl->assign( 'is_admin', true );
162
        }
163
        $criteria->setSort( $sort );
164
        $criteria->setOrder( $order );
165
        $criteria->setStart( $start );
166
        $criteria->setLimit( $limit );
167
        $foundusers = $member_handler->getUsers( $criteria, true );
168
        foreach ( array_keys( $foundusers ) as $j ) {
169
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
170
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
171
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
172
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
173
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
174
                $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>';
175
            } else {
176
                $userdata["email"] = '&nbsp;';
177
            }
178
            if ( $xoopsUser ) {
179
                $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>';
180
            } else {
181
                $userdata["pmlink"] = '&nbsp;';
182
            }
183
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
184
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
185
            } else {
186
                $userdata["website"] = '&nbsp;';
187
            }
188
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
189
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
190
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
191
            } else {
192
                $userdata["lastlogin"] = '&nbsp;';
193
            }
194
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
195
            if ( $iamadmin ) {
196
                $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 . "' />"
197
198
                . '</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>';
199
            }
200
            $xoopsTpl->append( "users", $userdata );
201
        }
202
203
        $totalpages = ceil( $total / $limit );
204
        if ( $totalpages > 1 ) {
205
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
206
            foreach ( $_POST as $k => $v ) {
207
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
208
            }
209
            if ( !isset( $_POST['limit'] ) ) {
210
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
211
            }
212
            if ( !isset( $_POST['start'] ) ) {
213
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
214
            }
215
            $prev = $start - $limit;
216
            if ( $start - $limit >= 0 ) {
217
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
218
            }
219
            $counter = 1;
220
            $currentpage = ( $start + $limit ) / $limit;
221
            while ( $counter <= $totalpages ) {
222
                if ( $counter == $currentpage ) {
223
                    $hiddenform .= '<b>' . $counter . '</b> ';
224
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
225
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
226
                        $hiddenform .= '... ';
227
                    }
228
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
229
                    if ( $counter == 1 && $currentpage > 5 ) {
230
                        $hiddenform .= '... ';
231
                    }
232
                }
233
                $counter++;
234
            }
235
            $next = $start + $limit;
236
            if ( $total > $next ) {
237
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
238
            }
239
            $hiddenform .= '</form>';
240
            $xoopsTpl->assign( 'pagenav', $hiddenform );
241
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
242
        }
243
    }
244
245
246
include_once XOOPS_ROOT_PATH . '/footer.php';

searchmembers.php 1 location

@@ 242-327 (lines=86) @@
239
    $total = $member_handler->getUserCount( $criteria );
240
    $xoopsTpl->assign( 'total_found', $total );
241
242
    if ( $total == 0 ) {
243
    } elseif ( $start < $total ) {
244
        if ( $iamadmin ) {
245
            $xoopsTpl->assign( 'is_admin', true );
246
        }
247
        $criteria->setSort( $sort );
248
        $criteria->setOrder( $order );
249
        $criteria->setStart( $start );
250
        $criteria->setLimit( $limit );
251
        $foundusers = $member_handler->getUsers( $criteria, true );
252
        foreach ( array_keys( $foundusers ) as $j ) {
253
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
254
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
255
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
256
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
257
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
258
                $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>';
259
            } else {
260
                $userdata["email"] = '&nbsp;';
261
            }
262
            if ( $xoopsUser ) {
263
                $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>';
264
            } else {
265
                $userdata["pmlink"] = '&nbsp;';
266
            }
267
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
268
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
269
            } else {
270
                $userdata["website"] = '&nbsp;';
271
            }
272
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
273
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
274
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
275
            } else {
276
                $userdata["lastlogin"] = '&nbsp;';
277
            }
278
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
279
            if ( $iamadmin ) {
280
                $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 . "' />"
281
282
                . '</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>';
283
            }
284
            $xoopsTpl->append( "users", $userdata );
285
        }
286
287
        $totalpages = ceil( $total / $limit );
288
        if ( $totalpages > 1 ) {
289
            $hiddenform = '<form name="findnext" action="searchmembers.php" method="post">';
290
            foreach ( $_POST as $k => $v ) {
291
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
292
            }
293
            if ( !isset( $_POST['limit'] ) ) {
294
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
295
            }
296
            if ( !isset( $_POST['start'] ) ) {
297
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
298
            }
299
            $prev = $start - $limit;
300
            if ( $start - $limit >= 0 ) {
301
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
302
            }
303
            $counter = 1;
304
            $currentpage = ( $start + $limit ) / $limit;
305
            while ( $counter <= $totalpages ) {
306
                if ( $counter == $currentpage ) {
307
                    $hiddenform .= '<b>' . $counter . '</b> ';
308
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
309
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
310
                        $hiddenform .= '... ';
311
                    }
312
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
313
                    if ( $counter == 1 && $currentpage > 5 ) {
314
                        $hiddenform .= '... ';
315
                    }
316
                }
317
                $counter++;
318
            }
319
            $next = $start + $limit;
320
            if ( $total > $next ) {
321
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
322
            }
323
            $hiddenform .= '</form>';
324
            $xoopsTpl->assign( 'pagenav', $hiddenform );
325
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
326
        }
327
    }
328
}
329
330
include_once XOOPS_ROOT_PATH . '/footer.php';