Code Duplication    Length = 86-86 lines in 2 locations

index.php 1 location

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