Code Duplication    Length = 86-86 lines in 2 locations

index.php 1 location

@@ 55-140 (lines=86) @@
52
    $total = $member_handler->getUserCount( $criteria );
53
	$xoopsTpl->assign( 'totalmember', $total );
54
55
    if ( $total == 0 ) {
56
    } elseif ( $start < $total ) {
57
        if ( $iamadmin ) {
58
            $xoopsTpl->assign( 'is_admin', true );
59
        }
60
        $criteria->setSort( $sort );
61
        $criteria->setOrder( $order );
62
        $criteria->setStart( $start );
63
        $criteria->setLimit( $limit );
64
        $foundusers = $member_handler->getUsers( $criteria, true );
65
        foreach ( array_keys( $foundusers ) as $j ) {
66
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
67
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
68
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
69
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
70
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
71
                $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>';
72
            } else {
73
                $userdata["email"] = '&nbsp;';
74
            }
75
            if ( $xoopsUser ) {
76
                $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>';
77
            } else {
78
                $userdata["pmlink"] = '&nbsp;';
79
            }
80
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
81
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
82
            } else {
83
                $userdata["website"] = '&nbsp;';
84
            }
85
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
86
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
87
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
88
            } else {
89
                $userdata["lastlogin"] = '&nbsp;';
90
            }
91
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
92
            if ( $iamadmin ) {
93
                $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 . "' />"
94
95
                . '</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>';
96
            }
97
            $xoopsTpl->append( "users", $userdata );
98
        }
99
100
        $totalpages = ceil( $total / $limit );
101
        if ( $totalpages > 1 ) {
102
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
103
            foreach ( $_POST as $k => $v ) {
104
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
105
            }
106
            if ( !isset( $_POST['limit'] ) ) {
107
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
108
            }
109
            if ( !isset( $_POST['start'] ) ) {
110
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
111
            }
112
            $prev = $start - $limit;
113
            if ( $start - $limit >= 0 ) {
114
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
115
            }
116
            $counter = 1;
117
            $currentpage = ( $start + $limit ) / $limit;
118
            while ( $counter <= $totalpages ) {
119
                if ( $counter == $currentpage ) {
120
                    $hiddenform .= '<b>' . $counter . '</b> ';
121
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
122
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
123
                        $hiddenform .= '... ';
124
                    }
125
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
126
                    if ( $counter == 1 && $currentpage > 5 ) {
127
                        $hiddenform .= '... ';
128
                    }
129
                }
130
                $counter++;
131
            }
132
            $next = $start + $limit;
133
            if ( $total > $next ) {
134
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
135
            }
136
            $hiddenform .= '</form>';
137
            $xoopsTpl->assign( 'pagenav', $hiddenform );
138
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
139
        }
140
    }
141
142
include 'footer.php';
143
include_once XOOPS_ROOT_PATH . '/footer.php';

searchmembers.php 1 location

@@ 207-292 (lines=86) @@
204
    $total = $member_handler->getUserCount( $criteria );
205
    $xoopsTpl->assign( 'total_found', $total );
206
207
    if ( $total == 0 ) {
208
    } elseif ( $start < $total ) {
209
        if ( $iamadmin ) {
210
            $xoopsTpl->assign( 'is_admin', true );
211
        }
212
        $criteria->setSort( $sort );
213
        $criteria->setOrder( $order );
214
        $criteria->setStart( $start );
215
        $criteria->setLimit( $limit );
216
        $foundusers = $member_handler->getUsers( $criteria, true );
217
        foreach ( array_keys( $foundusers ) as $j ) {
218
            $userdata["avatar"] = $foundusers[$j]->getVar( 'user_avatar' ) ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar( 'user_avatar' ) . '" alt="" />' : '&nbsp;';
219
            $userdata["realname"] = $foundusers[$j]->getVar( 'name' ) ? $foundusers[$j]->getVar( 'name' ) : '&nbsp;';
220
            $userdata["name"] = $foundusers[$j]->getVar( 'uname' );
221
            $userdata["id"] = $foundusers[$j]->getVar( 'uid' );
222
            if ( $foundusers[$j]->getVar( 'user_viewemail' ) == 1 || $iamadmin ) {
223
                $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>';
224
            } else {
225
                $userdata["email"] = '&nbsp;';
226
            }
227
            if ( $xoopsUser ) {
228
                $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>';
229
            } else {
230
                $userdata["pmlink"] = '&nbsp;';
231
            }
232
            if ( $foundusers[$j]->getVar( 'url', "e" ) != '' ) {
233
                $userdata["website"] = '<a href="' . $foundusers[$j]->getVar( 'url', "e" ) . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '" /></a>';
234
            } else {
235
                $userdata["website"] = '&nbsp;';
236
            }
237
            $userdata["registerdate"] = formatTimeStamp( $foundusers[$j]->getVar( 'user_regdate' ), 's' );
238
            if ( $foundusers[$j]->getVar( 'last_login' ) != 0 ) {
239
                $userdata["lastlogin"] = formatTimeStamp( $foundusers[$j]->getVar( 'last_login' ), "m" );
240
            } else {
241
                $userdata["lastlogin"] = '&nbsp;';
242
            }
243
            $userdata["posts"] = $foundusers[$j]->getVar( 'posts' );
244
            if ( $iamadmin ) {
245
                $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 . "' />"
246
247
                . '</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>';
248
            }
249
            $xoopsTpl->append( "users", $userdata );
250
        }
251
252
        $totalpages = ceil( $total / $limit );
253
        if ( $totalpages > 1 ) {
254
            $hiddenform = '<form name="findnext" action="searchmembers.php" method="post">';
255
            foreach ( $_POST as $k => $v ) {
256
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars( $k ) . '" value="' . $myts->previewTarea( $v ) . '" />';
257
            }
258
            if ( !isset( $_POST['limit'] ) ) {
259
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '" />';
260
            }
261
            if ( !isset( $_POST['start'] ) ) {
262
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '" />';
263
            }
264
            $prev = $start - $limit;
265
            if ( $start - $limit >= 0 ) {
266
                $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XM_PREVIOUS . '</a>&nbsp;';
267
            }
268
            $counter = 1;
269
            $currentpage = ( $start + $limit ) / $limit;
270
            while ( $counter <= $totalpages ) {
271
                if ( $counter == $currentpage ) {
272
                    $hiddenform .= '<b>' . $counter . '</b> ';
273
                } elseif ( ( $counter > $currentpage-4 && $counter < $currentpage + 4 ) || $counter == 1 || $counter == $totalpages ) {
274
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
275
                        $hiddenform .= '... ';
276
                    }
277
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
278
                    if ( $counter == 1 && $currentpage > 5 ) {
279
                        $hiddenform .= '... ';
280
                    }
281
                }
282
                $counter++;
283
            }
284
            $next = $start + $limit;
285
            if ( $total > $next ) {
286
                $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XM_NEXT . '</a>';
287
            }
288
            $hiddenform .= '</form>';
289
            $xoopsTpl->assign( 'pagenav', $hiddenform );
290
            $xoopsTpl->assign( 'lang_numfound', sprintf( _MD_XM_USERSFOUND, $total ) );
291
        }
292
    }
293
}
294
295
include 'footer.php';