I’ve highlighted the changes that I made to document.parser.class.php below (I’m showing only the affected functions):
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)");
// Ability to get all documents, whether deleted or unpublished, added by Paul Bohman
if ($published == ’*’) $sqlPublished = ’’;
else $sqlPublished = "AND sc.published=$published";
if ($deleted == ’*’) $sqlDeleted = ’’;
else $sqlDeleted = "AND sc.deleted=$deleted";
// end added code
$sql= "SELECT DISTINCT $fields FROM $tblsc sc
LEFT JOIN $tbldg dg on dg.document = sc.id
WHERE (sc.id IN (" . join($ids, ",") . ") $sqlPublished $sqlDeleted $where) // code altered here
AND ($access)
GROUP BY sc.id " .
($sort ? " ORDER BY $sort $dir" : "") . " $limit ";
// end altered code
$result= $this->dbQuery($sql);
$resourceArray= array ();
for ($i= 0; $i < @ $this->recordCount($result); $i++) {
array_push($resourceArray, @ $this->fetchRow($result));
}
return $resourceArray;
}
}
And here’s the next one:
function getTemplateVars($idnames= array (), $fields= "*", $docid= "", $published= 1, $sort= "rank", $dir= "ASC",$deleted=0) {
// The ’deleted’ option was added by Paul Bohman
if (($idnames != ’*’ && !is_array($idnames)) || count($idnames) == 0) {
return false;
} else {
$result= array ();
// get document record
if ($docid == "") {
$docid= $this->documentIdentifier;
$docRow= $this->documentObject;
} else {
$docRow= $this->getDocument($docid, ’*’, $published,$deleted); // code altered here
if (!$docRow)
return false;
}
// get user defined template variables
$fields= ($fields == "") ? "tv.*" : ’tv.’ . implode(’,tv.’, preg_replace("/^\s/i", "", explode(’,’, $fields)));
$sort= ($sort == "") ? "" : ’tv.’ . implode(’,tv.’, preg_replace("/^\s/i", "", explode(’,’, $sort)));
if ($idnames == "*")
$query= "tv.id<>0";
else
$query= (is_numeric($idnames[0]) ? "tv.id" : "tv.name") . " IN (’" . implode("’,’", $idnames) . "’)";
if ($docgrp= $this->getUserDocGroups())
$docgrp= implode(",", $docgrp);
$sql= "SELECT $fields, IF(tvc.value!=’’,tvc.value,tv.default_text) as value ";
$sql .= "FROM " . $this->getFullTableName(’site_tmplvars’)." tv ";
$sql .= "INNER JOIN " . $this->getFullTableName(’site_tmplvar_templates’)." tvtpl ON tvtpl.tmplvarid = tv.id ";
$sql .= "LEFT JOIN " . $this->getFullTableName(’site_tmplvar_contentvalues’)." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = ’" . $docid . "’ ";
$sql .= "WHERE " . $query . " AND tvtpl.templateid = " . $docRow[’template’];
if ($sort)
$sql .= " ORDER BY $sort $dir ";
$rs= $this->dbQuery($sql);
for ($i= 0; $i < @ $this->recordCount($rs); $i++) {
array_push($result, @ $this->fetchRow($rs));
}
// get default/built-in template variables
ksort($docRow);
foreach ($docRow as $key => $value) {
if ($idnames == "*" || in_array($key, $idnames))
array_push($result, array (
"name" => $key,
"value" => $value
));
}
return $result;
}
}
And here’s the next one:
function getTemplateVarOutput($idnames= array (), $docid= "", $published= 1,$deleted=0) {
// The ’deleted’ option was added by Paul Bohman
if (count($idnames) == 0) {
return false;
} else {
$output= array ();
$vars= ($idnames == ’*’ || is_array($idnames)) ? $idnames : array ($idnames);
$docid= intval($docid) ? intval($docid) : $this->documentIdentifier;
$result= $this->getTemplateVars($vars, "*", $docid, $published, "", "",$deleted); // remove sort for speed
// The ’deleted’ option was added above by Paul Bohman
if ($result == false)
return false;
else {
$baspath= $this->config["base_path"] . "manager/includes";
include_once $baspath . "/tmplvars.format.inc.php";
include_once $baspath . "/tmplvars.commands.inc.php";
for ($i= 0; $i < count($result); $i++) {
$row= $result[$i];
// to-do needs fixing when getting tvs from other pages
$replace_richtext= "";
$richtexteditor= "";
$w= "100%";
$h= "300";
$output[$row[’name’]]= getTVDisplayFormat($row[’name’], $row[’value’], $row[’display’], $row[’display_params’], $row[’type’], $docid);
}
return $output;
}
}
}
Hope this helps.