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