Code Duplication    Length = 25-27 lines in 2 locations

manager/includes/document.parser.class.inc.php 2 locations

@@ 3757-3781 (lines=25) @@
3754
     * @param string $fields Default: id, pagetitle, description, parent, alias, menutitle
3755
     * @return array
3756
     */
3757
    public function getAllChildren(
3758
        $id = 0,
3759
        $sort = 'menuindex',
3760
        $dir = 'ASC',
3761
        $fields = 'id, pagetitle, description, parent, alias, menutitle'
3762
    ) {
3763
3764
        $cacheKey = md5(print_r(func_get_args(), true));
3765
        if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) {
3766
            return $this->tmpCache[__FUNCTION__][$cacheKey];
3767
        }
3768
3769
        $tblsc = $this->getFullTableName("site_content");
3770
        $tbldg = $this->getFullTableName("document_groups");
3771
        // modify field names to use sc. table reference
3772
        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3773
        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3774
        // get document groups for current user
3775
        if ($docgrp = $this->getUserDocGroups()) {
3776
            $docgrp = implode(",", $docgrp);
3777
        }
3778
        // build query
3779
        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3780
        $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3781
                LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id",
3782
            "{$sort} {$dir}");
3783
        $resourceArray = $this->db->makeArray($result);
3784
        $this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray;
@@ 3800-3826 (lines=27) @@
3797
     * @param string $fields Default: id, pagetitle, description, parent, alias, menutitle
3798
     * @return array
3799
     */
3800
    public function getActiveChildren(
3801
        $id = 0,
3802
        $sort = 'menuindex',
3803
        $dir = 'ASC',
3804
        $fields = 'id, pagetitle, description, parent, alias, menutitle'
3805
    ) {
3806
        $cacheKey = md5(print_r(func_get_args(), true));
3807
        if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) {
3808
            return $this->tmpCache[__FUNCTION__][$cacheKey];
3809
        }
3810
3811
        $tblsc = $this->getFullTableName("site_content");
3812
        $tbldg = $this->getFullTableName("document_groups");
3813
3814
        // modify field names to use sc. table reference
3815
        $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
3816
        $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
3817
        // get document groups for current user
3818
        if ($docgrp = $this->getUserDocGroups()) {
3819
            $docgrp = implode(",", $docgrp);
3820
        }
3821
        // build query
3822
        $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
3823
        $result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc
3824
                LEFT JOIN {$tbldg} dg on dg.document = sc.id",
3825
            "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}");
3826
        $resourceArray = $this->db->makeArray($result);
3827
3828
        $this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray;
3829