|
@@ 3663-3687 (lines=25) @@
|
| 3660 |
|
* @param string $fields Default: id, pagetitle, description, parent, alias, menutitle |
| 3661 |
|
* @return array |
| 3662 |
|
*/ |
| 3663 |
|
public function getAllChildren($id = 0, $sort = 'menuindex', $dir = 'ASC', $fields = 'id, pagetitle, description, parent, alias, menutitle') |
| 3664 |
|
{ |
| 3665 |
|
|
| 3666 |
|
$cacheKey = md5(print_r(func_get_args(), true)); |
| 3667 |
|
if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) { |
| 3668 |
|
return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 3669 |
|
} |
| 3670 |
|
|
| 3671 |
|
$tblsc = $this->getFullTableName("site_content"); |
| 3672 |
|
$tbldg = $this->getFullTableName("document_groups"); |
| 3673 |
|
// modify field names to use sc. table reference |
| 3674 |
|
$fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
| 3675 |
|
$sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
| 3676 |
|
// get document groups for current user |
| 3677 |
|
if ($docgrp = $this->getUserDocGroups()) { |
| 3678 |
|
$docgrp = implode(",", $docgrp); |
| 3679 |
|
} |
| 3680 |
|
// build query |
| 3681 |
|
$access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
| 3682 |
|
$result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3683 |
|
LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3684 |
|
$resourceArray = $this->db->makeArray($result); |
| 3685 |
|
$this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray; |
| 3686 |
|
return $resourceArray; |
| 3687 |
|
} |
| 3688 |
|
|
| 3689 |
|
/** |
| 3690 |
|
* Gets all active child documents of the specified document, i.e. those which published and not deleted. |
|
@@ 3700-3726 (lines=27) @@
|
| 3697 |
|
* @param string $fields Default: id, pagetitle, description, parent, alias, menutitle |
| 3698 |
|
* @return array |
| 3699 |
|
*/ |
| 3700 |
|
public function getActiveChildren($id = 0, $sort = 'menuindex', $dir = 'ASC', $fields = 'id, pagetitle, description, parent, alias, menutitle') |
| 3701 |
|
{ |
| 3702 |
|
$cacheKey = md5(print_r(func_get_args(), true)); |
| 3703 |
|
if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) { |
| 3704 |
|
return $this->tmpCache[__FUNCTION__][$cacheKey]; |
| 3705 |
|
} |
| 3706 |
|
|
| 3707 |
|
$tblsc = $this->getFullTableName("site_content"); |
| 3708 |
|
$tbldg = $this->getFullTableName("document_groups"); |
| 3709 |
|
|
| 3710 |
|
// modify field names to use sc. table reference |
| 3711 |
|
$fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
| 3712 |
|
$sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
| 3713 |
|
// get document groups for current user |
| 3714 |
|
if ($docgrp = $this->getUserDocGroups()) { |
| 3715 |
|
$docgrp = implode(",", $docgrp); |
| 3716 |
|
} |
| 3717 |
|
// build query |
| 3718 |
|
$access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
| 3719 |
|
$result = $this->db->select("DISTINCT {$fields}", "{$tblsc} sc |
| 3720 |
|
LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND sc.published=1 AND sc.deleted=0 AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
| 3721 |
|
$resourceArray = $this->db->makeArray($result); |
| 3722 |
|
|
| 3723 |
|
$this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray; |
| 3724 |
|
|
| 3725 |
|
return $resourceArray; |
| 3726 |
|
} |
| 3727 |
|
|
| 3728 |
|
/** |
| 3729 |
|
* getDocumentChildren |