@@ 3918-3942 (lines=25) @@ | ||
3915 | * @param string $fields Default: id, pagetitle, description, parent, alias, menutitle |
|
3916 | * @return array |
|
3917 | */ |
|
3918 | public function getAllChildren($id = 0, $sort = 'menuindex', $dir = 'ASC', $fields = 'id, pagetitle, description, parent, alias, menutitle') |
|
3919 | { |
|
3920 | ||
3921 | $cacheKey = md5(print_r(func_get_args(), true)); |
|
3922 | if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) { |
|
3923 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
|
3924 | } |
|
3925 | ||
3926 | $tblsc = $this->getDatabase()->getFullTableName("site_content"); |
|
3927 | $tbldg = $this->getDatabase()->getFullTableName("document_groups"); |
|
3928 | // modify field names to use sc. table reference |
|
3929 | $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3930 | $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3931 | // get document groups for current user |
|
3932 | if ($docgrp = $this->getUserDocGroups()) { |
|
3933 | $docgrp = implode(",", $docgrp); |
|
3934 | } |
|
3935 | // build query |
|
3936 | $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3937 | $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
3938 | LEFT JOIN {$tbldg} dg on dg.document = sc.id", "sc.parent = '{$id}' AND ({$access}) GROUP BY sc.id", "{$sort} {$dir}"); |
|
3939 | $resourceArray = $this->getDatabase()->makeArray($result); |
|
3940 | $this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray; |
|
3941 | return $resourceArray; |
|
3942 | } |
|
3943 | ||
3944 | /** |
|
3945 | * Gets all active child documents of the specified document, i.e. those which published and not deleted. |
|
@@ 3955-3981 (lines=27) @@ | ||
3952 | * @param string $fields Default: id, pagetitle, description, parent, alias, menutitle |
|
3953 | * @return array |
|
3954 | */ |
|
3955 | public function getActiveChildren($id = 0, $sort = 'menuindex', $dir = 'ASC', $fields = 'id, pagetitle, description, parent, alias, menutitle') |
|
3956 | { |
|
3957 | $cacheKey = md5(print_r(func_get_args(), true)); |
|
3958 | if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) { |
|
3959 | return $this->tmpCache[__FUNCTION__][$cacheKey]; |
|
3960 | } |
|
3961 | ||
3962 | $tblsc = $this->getDatabase()->getFullTableName("site_content"); |
|
3963 | $tbldg = $this->getDatabase()->getFullTableName("document_groups"); |
|
3964 | ||
3965 | // modify field names to use sc. table reference |
|
3966 | $fields = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $fields)))); |
|
3967 | $sort = 'sc.' . implode(',sc.', array_filter(array_map('trim', explode(',', $sort)))); |
|
3968 | // get document groups for current user |
|
3969 | if ($docgrp = $this->getUserDocGroups()) { |
|
3970 | $docgrp = implode(",", $docgrp); |
|
3971 | } |
|
3972 | // build query |
|
3973 | $access = ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") . (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)"); |
|
3974 | $result = $this->getDatabase()->select("DISTINCT {$fields}", "{$tblsc} sc |
|
3975 | 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}"); |
|
3976 | $resourceArray = $this->getDatabase()->makeArray($result); |
|
3977 | ||
3978 | $this->tmpCache[__FUNCTION__][$cacheKey] = $resourceArray; |
|
3979 | ||
3980 | return $resourceArray; |
|
3981 | } |
|
3982 | ||
3983 | /** |
|
3984 | * getDocumentChildren |