Code Duplication    Length = 28-34 lines in 2 locations

main/newscorm/learnpath.class.php 2 locations

@@ 1590-1623 (lines=34) @@
1587
     * @param	integer	Item ID
1588
     * @return	array	A list of all the "brother items" (or an empty array on failure)
1589
     */
1590
    public function get_brother_chapters($id)
1591
    {
1592
        $course_id = api_get_course_int_id();
1593
        if ($this->debug > 0) {
1594
            error_log('New LP - In learnpath::get_brother_chapters()', 0);
1595
        }
1596
1597
        if (empty($id) || $id != strval(intval($id))) {
1598
1599
            return array ();
1600
        }
1601
1602
        $lp_item = Database :: get_course_table(TABLE_LP_ITEM);
1603
        $sql_parent = "SELECT * FROM $lp_item
1604
                       WHERE c_id = ".$course_id." AND id = $id AND item_type='dokeos_chapter'";
1605
        $res_parent = Database::query($sql_parent);
1606
        if (Database :: num_rows($res_parent) > 0) {
1607
            $row_parent = Database :: fetch_array($res_parent);
1608
            $parent = $row_parent['parent_item_id'];
1609
            $sql = "SELECT * FROM $lp_item
1610
                    WHERE
1611
                        c_id = ".$course_id." AND
1612
                        parent_item_id = $parent AND
1613
                        id = $id AND
1614
                        item_type='dokeos_chapter'
1615
                    ORDER BY display_order";
1616
            $res_bros = Database::query($sql);
1617
1618
            $list = array();
1619
            while ($row_bro = Database :: fetch_array($res_bros)) {
1620
                $list[] = $row_bro;
1621
            }
1622
1623
            return $list;
1624
        }
1625
1626
        return array();
@@ 1635-1662 (lines=28) @@
1632
     * @param	integer	Item ID
1633
     * @return	array	A list of all the "brother items" (or an empty array on failure)
1634
     */
1635
    public function get_brother_items($id)
1636
    {
1637
        $course_id = api_get_course_int_id();
1638
        if ($this->debug > 0) {
1639
            error_log('New LP - In learnpath::get_brother_items(' . $id . ')', 0);
1640
        }
1641
1642
        if (empty ($id) || $id != strval(intval($id))) {
1643
            return array ();
1644
        }
1645
1646
        $lp_item = Database :: get_course_table(TABLE_LP_ITEM);
1647
        $sql_parent = "SELECT * FROM $lp_item WHERE c_id = $course_id AND id = $id";
1648
        $res_parent = Database::query($sql_parent);
1649
        if (Database :: num_rows($res_parent) > 0) {
1650
            $row_parent = Database :: fetch_array($res_parent);
1651
            $parent = $row_parent['parent_item_id'];
1652
            $sql_bros = "SELECT * FROM $lp_item WHERE c_id = ".$course_id." AND parent_item_id = $parent
1653
                         ORDER BY display_order";
1654
            $res_bros = Database::query($sql_bros);
1655
            $list = array ();
1656
            while ($row_bro = Database :: fetch_array($res_bros)) {
1657
                $list[] = $row_bro;
1658
            }
1659
            return $list;
1660
        }
1661
        return array ();
1662
    }
1663
1664
    /**
1665
     * Get the specific prefix index terms of this learning path