Code Duplication    Length = 86-86 lines in 2 locations

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';

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
143
include_once XOOPS_ROOT_PATH . '/footer.php';