Okay, I’m having this problem and had some issues with the following part of the patch:
I also had to apply the same patch the document.parser.class.inc.php file in the following functions:
getAllChildren()
getActiveChildren()
getDocumentChildren()
getDocuments()
I have a few sites running with this and all are sorting trees and menus correctly, with no obvious side-effects, ATM.
I managed to do the getAllChildren section okay, and the getActiveChildren okay but this part threw errors, which means I screwed it up somehow:
function getDocumentChildren($parentid=0, $published=1, $deleted=0, $fields="*", $where='', $sort="menuindex", $dir="ASC", $limit="") {
$limit = ($limit != "") ? "LIMIT $limit" : "";
$tblsc = $this->getFullTableName("site_content");
$tbldg = $this->getFullTableName("document_groups");
// modify field names to use sc. table reference
$fields = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
$sort = ($sort=="") ? "":'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
if ($where!='') $where = 'AND '.$where;
// get document groups for current user
if($docgrp = $this->getUserDocGroups()) $docgrp = implode(",",$docgrp);
// build query
$access = ($this->isFrontend() ? "sc.privateweb=0":"1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").
(!$docgrp ? "":" OR dg.document_group IN ($docgrp)");
$sql = "SELECT DISTINCT $fields
FROM $tblsc sc
LEFT JOIN $tbldg dg on dg.document = sc.id
WHERE sc.parent = '$parentid' AND sc.published=$published AND sc.deleted=$deleted $where
AND ($access) ".
GROUP BY sc.id
($sort ? " ORDER BY $sort $dir ":"")." $limit ";
$result = $this->dbQuery($sql);
$resourceArray = array();
for($i=0;$i<@$this->recordCount($result);$i++) {
array_push($resourceArray,@$this->fetchRow($result));
}
return $resourceArray;
}
function getDocuments($ids=array(), $published=1, $deleted=0, $fields="*", $where='', $sort="menuindex", $dir="ASC", $limit="") {
if(count($ids)==0) {
return false;
} else {
$limit = ($limit != "") ? "LIMIT $limit" : ""; // LIMIT capabilities - rad14701
$tblsc = $this->getFullTableName("site_content");
$tbldg = $this->getFullTableName("document_groups");
// modify field names to use sc. table reference
$fields = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
$sort = ($sort=="") ? "":'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
if ($where!='') $where = 'AND '.$where;
// get document groups for current user
if($docgrp = $this->getUserDocGroups()) $docgrp = implode(",",$docgrp);
$access = ($this->isFrontend() ? "sc.privateweb=0":"1='".$_SESSION['mgrRole']."' OR sc.privatemgr=0").
(!$docgrp ? "":" OR dg.document_group IN ($docgrp)");
$sql = "SELECT DISTINCT $fields FROM $tblsc sc
LEFT JOIN $tbldg dg on dg.document = sc.id
WHERE (sc.id IN (".join($ids, ",").") AND sc.published=$published AND sc.deleted=$deleted $where)
AND ($access) ".
GROUP BY sc.id
($sort ? " ORDER BY $sort $dir":"")." $limit ";
$result = $this->dbQuery($sql);
$resourceArray = array();
for($i=0;$i<@$this->recordCount($result);$i++) {
array_push($resourceArray,@$this->fetchRow($result));
}
return $resourceArray;
}
}
I also couldn’t find this to save my soul, and it’s the sort order in Ditto I’m working to fix:
Attention: This also affects ditto, in classes/functions.class.inc.php line around 250.
Any help would be greatly appreciated.