Code Duplication    Length = 21-24 lines in 2 locations

main/inc/lib/tracking.lib.php 2 locations

@@ 7532-7552 (lines=21) @@
7529
        $courseId = api_get_course_int_id($courseCode);
7530
        $userId = intval($userId);
7531
        $line = null;
7532
        if (substr($view, 3, 1) == '1') {
7533
            $new_view = substr_replace($view, '0', 3, 1);
7534
            $title[1] = get_lang('LinksDetails');
7535
            $sql = "SELECT cl.title, cl.url
7536
                        FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7537
                        WHERE sl.links_link_id = cl.id
7538
                            AND sl.c_id = $courseId
7539
                            AND sl.links_user_id = $userId
7540
                        GROUP BY cl.title, cl.url";
7541
            $results = StatsUtils::getManyResults2Col($sql);
7542
            $title_line = get_lang('LinksTitleLinkColumn')."\n";
7543
            if (is_array($results)) {
7544
                for ($j = 0; $j < count($results); $j++) {
7545
                    $line .= $results[$j][0]."\n";
7546
                }
7547
            } else {
7548
                $line = get_lang('NoResult');
7549
            }
7550
        } else {
7551
            $new_view = substr_replace($view, '1', 3, 1);
7552
        }
7553
        return array($title_line, $line);
7554
    }
7555
@@ 7573-7596 (lines=24) @@
7570
7571
        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7572
7573
        if (substr($view, 4, 1) == '1') {
7574
            $new_view = substr_replace($view, '0', 4, 1);
7575
            $title[1] = get_lang('DocumentsDetails');
7576
7577
            $sql = "SELECT down_doc_path
7578
                        FROM $downloads_table
7579
                        WHERE c_id = $courseId
7580
                            AND down_user_id = $user_id
7581
                            AND down_session_id = $session_id
7582
                        GROUP BY down_doc_path";
7583
7584
            $results = StatsUtils::getManyResults1Col($sql);
7585
            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7586
            $line = null;
7587
            if (is_array($results)) {
7588
                for ($j = 0; $j < count($results); $j++) {
7589
                    $line .= $results[$j]."\n";
7590
                }
7591
            } else {
7592
                $line = get_lang('NoResult');
7593
            }
7594
        } else {
7595
            $new_view = substr_replace($view, '1', 4, 1);
7596
        }
7597
        return array($title_line, $line);
7598
    }
7599