Code Duplication    Length = 105-105 lines in 2 locations

class/PublicWallUpdates.php 1 location

@@ 407-511 (lines=105) @@
404
        $xoopsTpl->assign('myavatar_highwide', $myavatar_highwide);
405
        $xoopsTpl->assign('avatar', $user_img);
406
407
        if (!empty($updatesarray)) {
408
            foreach ($updatesarray as $data) {
409
                // Is update's user a friend ?
410
                $frU = $check->friendcheck($id, $data['uid_fk']);
411
412
                $USW             = [];
413
                $USW['posts']    = 0;
414
                $USW['comments'] = 0;
415
416
                if ($xoopsUser) {
417
                    if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $data['uid_fk'] == $id) {
418
                        $USW['posts']    = 1;
419
                        $USW['comments'] = 1;
420
                        $frU[0]          = 2;
421
                    } else {
422
                        $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
423
                    }
424
                }
425
426
                if (!$xoopsUser) {
427
                    $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
428
                }
429
430
                $wm['msg_id']          = $data['msg_id'];
431
                $wm['orimessage']      = (1 == $USW['posts'] || $profile >= 2) ? str_replace(["\r", "\n"], '', Smallworld_stripWordsKeepUrl($data['message'])) : '';
432
                $wm['message']         = (1 == $USW['posts'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($data['message']), $data['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETPOSTS;
433
                $wm['message']         = Smallworld_cleanup($wm['message']);
434
                $wm['created']         = smallworld_time_stamp($data['created']);
435
                $wm['username']        = $data['username'];
436
                $wm['uid_fk']          = $data['uid_fk'];
437
                $wm['priv']            = $data['priv'];
438
                $wm['avatar']          = $this->Gravatar($data['uid_fk']);
439
                $wm['avatar_link']     = smallworld_getAvatarLink($data['uid_fk'], $wm['avatar']);
440
                $wm['avatar_size']     = smallworld_getImageSize(80, 100, $wm['avatar_link']);
441
                $wm['avatar_highwide'] = smallworld_imageResize($wm['avatar_size'][0], $wm['avatar_size'][1], 50);
442
                $wm['vote_up']         = $this->countVotes('msg', 'up', $data['msg_id']);
443
                $wm['vote_down']       = $this->countVotes('msg', 'down', $data['msg_id']);
444
                $wm['sharelinkurl']    = XOOPS_URL . '/modules/smallworld/smallworldshare.php?ownerid=' . $data['uid_fk'];
445
                $wm['sharelinkurl']    .= '&updid=' . $data['msg_id'] . '';
446
                $wm['usernameTitle']   = $wm['username'] . _SMALLWORLD_UPDATEONSITEMETA . $xoopsConfig['sitename'];
447
                if (1 == $USW['posts'] || $profile >= 2) {
448
                    $wm['sharelink'] = $this->GetSharing($wm['msg_id'], $wm['priv']);
449
                } else {
450
                    $wm['sharelink'] = $this->GetSharing($wm['msg_id'], 1);
451
                }
452
453
                if (1 == $USW['posts'] || $profile >= 2) {
454
                    $wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], $wm['priv'], $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
455
                } else {
456
                    $wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], 1, $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
457
                }
458
                $wm['linkimage']     = XOOPS_URL . '/modules/smallworld/assets/images/link.png';
459
                $wm['permalink']     = XOOPS_URL . '/modules/smallworld/permalink.php?ownerid=' . $data['uid_fk'] . '&updid=' . $data['msg_id'];
460
                $wm['commentsarray'] = $this->Comments($data['msg_id']);
461
462
                if (2 == $frU[0] || 1 == $USW['posts']) {
463
                    $xoopsTpl->append('walldata', $wm);
464
                }
465
466
                if (!empty($wm['commentsarray'])) {
467
                    foreach ($wm['commentsarray'] as $cdata) {
468
                        // Is commentuser a friend ?
469
                        $frC = $check->friendcheck($id, $cdata['uid_fk']);
470
471
                        $USC             = [];
472
                        $USC['posts']    = 0;
473
                        $USC['comments'] = 0;
474
475
                        if ($xoopsUser) {
476
                            if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $cdata['uid_fk'] == $id) {
477
                                $USC['posts']    = 1;
478
                                $USC['comments'] = 1;
479
                                $frC[0]          = 2;
480
                            } else {
481
                                $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
482
                            }
483
                        }
484
485
                        if (!$xoopsUser) {
486
                            $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
487
                        }
488
489
                        $wc['msg_id_fk']       = $cdata['msg_id_fk'];
490
                        $wc['com_id']          = $cdata['com_id'];
491
                        $wc['comment']         = (1 == $USC['comments'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($cdata['comment']), $cdata['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETCOMMENTS;
492
                        $wc['comment']         = Smallworld_cleanup($wc['comment']);
493
                        $wc['time']            = smallworld_time_stamp($cdata['created']);
494
                        $wc['username']        = $cdata['username'];
495
                        $wc['uid']             = $cdata['uid_fk'];
496
                        $wc['myavatar']        = $this->Gravatar($id);
497
                        $wc['myavatar_link']   = $myavatarlink;
498
                        $wc['avatar_size']     = smallworld_getImageSize(80, 100, $wc['myavatar_link']);
499
                        $wc['avatar_highwide'] = smallworld_imageResize($wc['avatar_size'][0], $wc['avatar_size'][1], 35);
500
                        $wc['cface']           = $this->Gravatar($cdata['uid_fk']);
501
                        $wc['avatar_link']     = smallworld_getAvatarLink($cdata['uid_fk'], $wc['cface']);
502
                        $wc['vote_up']         = $this->countVotesCom('com', 'up', $cdata['msg_id_fk'], $cdata['com_id']);
503
                        $wc['vote_down']       = $this->countVotesCom('com', 'down', $cdata['msg_id_fk'], $cdata['com_id']);
504
505
                        if (2 == $frC[0] || 1 == $USC['comments']) {
506
                            $xoopsTpl->append('comm', $wc);
507
                        }
508
                    }
509
                }
510
            }
511
        }
512
    }
513
}
514

class/WallUpdates.php 1 location

@@ 469-573 (lines=105) @@
466
        $xoopsTpl->assign('myavatarlink', $myavatarlink);
467
        $xoopsTpl->assign('myavatar_highwide', $myavatar_highwide);
468
469
        if (!empty($updatesarray)) {
470
            foreach ($updatesarray as $data) {
471
                // Is update's user a friend ?
472
                $frU = $check->friendcheck($id, $data['uid_fk']);
473
474
                $USW             = [];
475
                $USW['posts']    = 0;
476
                $USW['comments'] = 0;
477
478
                if ($xoopsUser) {
479
                    if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $data['uid_fk'] == $id) {
480
                        $USW['posts']    = 1;
481
                        $USW['comments'] = 1;
482
                        $frU[0]          = 2;
483
                    } else {
484
                        $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
485
                    }
486
                }
487
488
                if (!$xoopsUser) {
489
                    $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
490
                }
491
492
                $wm['msg_id']          = $data['msg_id'];
493
                $wm['orimessage']      = (1 == $USW['posts'] || $profile >= 2) ? str_replace(["\r", "\n"], '', Smallworld_stripWordsKeepUrl($data['message'])) : '';
494
                $wm['message']         = (1 == $USW['posts'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($data['message']), $data['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETPOSTS;
495
                $wm['message']         = Smallworld_cleanup($wm['message']);
496
                $wm['created']         = smallworld_time_stamp($data['created']);
497
                $wm['username']        = $data['username'];
498
                $wm['uid_fk']          = $data['uid_fk'];
499
                $wm['priv']            = $data['priv'];
500
                $wm['avatar']          = $this->Gravatar($data['uid_fk']);
501
                $wm['avatar_link']     = smallworld_getAvatarLink($data['uid_fk'], $wm['avatar']);
502
                $wm['avatar_size']     = smallworld_getImageSize(80, 100, $wm['avatar_link']);
503
                $wm['avatar_highwide'] = smallworld_imageResize($wm['avatar_size'][0], $wm['avatar_size'][1], 50);
504
                $wm['vote_up']         = $this->countVotes('msg', 'up', $data['msg_id']);
505
                $wm['vote_down']       = $this->countVotes('msg', 'down', $data['msg_id']);
506
                $wm['sharelinkurl']    = XOOPS_URL . '/modules/smallworld/smallworldshare.php?ownerid=' . $data['uid_fk'];
507
                $wm['sharelinkurl']    .= '&updid=' . $data['msg_id'] . '';
508
                $wm['usernameTitle']   = $wm['username'] . _SMALLWORLD_UPDATEONSITEMETA . $xoopsConfig['sitename'];
509
                if (1 == $USW['posts'] || $profile >= 2) {
510
                    $wm['sharelink'] = $this->GetSharing($wm['msg_id'], $wm['priv']);
511
                } else {
512
                    $wm['sharelink'] = $this->GetSharing($wm['msg_id'], 1);
513
                }
514
515
                if (1 == $USW['posts'] || $profile >= 2) {
516
                    $wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], $wm['priv'], $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
517
                } else {
518
                    $wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], 1, $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']);
519
                }
520
                $wm['linkimage']     = XOOPS_URL . '/modules/smallworld/assets/images/link.png';
521
                $wm['permalink']     = XOOPS_URL . '/modules/smallworld/permalink.php?ownerid=' . $data['uid_fk'] . '&updid=' . $data['msg_id'];
522
                $wm['commentsarray'] = $this->Comments($data['msg_id']);
523
524
                if (2 == $frU[0] || 1 == $USW['posts']) {
525
                    $xoopsTpl->append('walldata', $wm);
526
                }
527
528
                if (!empty($wm['commentsarray'])) {
529
                    foreach ($wm['commentsarray'] as $cdata) {
530
                        // Is commentuser a friend ?
531
                        $frC = $check->friendcheck($id, $cdata['uid_fk']);
532
533
                        $USC             = [];
534
                        $USC['posts']    = 0;
535
                        $USC['comments'] = 0;
536
537
                        if ($xoopsUser) {
538
                            if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $cdata['uid_fk'] == $id) {
539
                                $USC['posts']    = 1;
540
                                $USC['comments'] = 1;
541
                                $frC[0]          = 2;
542
                            } else {
543
                                $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
544
                            }
545
                        }
546
547
                        if (!$xoopsUser) {
548
                            $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
549
                        }
550
551
                        $wc['msg_id_fk']       = $cdata['msg_id_fk'];
552
                        $wc['com_id']          = $cdata['com_id'];
553
                        $wc['comment']         = (1 == $USC['comments'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($cdata['comment']), $cdata['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETCOMMENTS;
554
                        $wc['comment']         = Smallworld_cleanup($wc['comment']);
555
                        $wc['time']            = smallworld_time_stamp($cdata['created']);
556
                        $wc['username']        = $cdata['username'];
557
                        $wc['uid']             = $cdata['uid_fk'];
558
                        $wc['myavatar']        = $this->Gravatar($id);
559
                        $wc['myavatar_link']   = $myavatarlink;
560
                        $wc['avatar_size']     = smallworld_getImageSize(80, 100, $wc['myavatar_link']);
561
                        $wc['avatar_highwide'] = smallworld_imageResize($wc['avatar_size'][0], $wc['avatar_size'][1], 35);
562
                        $wc['cface']           = $this->Gravatar($cdata['uid_fk']);
563
                        $wc['avatar_link']     = smallworld_getAvatarLink($cdata['uid_fk'], $wc['cface']);
564
                        $wc['vote_up']         = $this->countVotesCom('com', 'up', $cdata['msg_id_fk'], $cdata['com_id']);
565
                        $wc['vote_down']       = $this->countVotesCom('com', 'down', $cdata['msg_id_fk'], $cdata['com_id']);
566
567
                        if (2 == $frC[0] || 1 == $USC['comments']) {
568
                            $xoopsTpl->append('comm', $wc);
569
                        }
570
                    }
571
                }
572
            }
573
        }
574
    }
575
}
576