Code Duplication    Length = 105-105 lines in 2 locations

class/PublicWallUpdates.php 1 location

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

class/WallUpdates.php 1 location

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