forked from modxcms/evolution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecure_web_documents.inc.php
More file actions
27 lines (24 loc) · 1.1 KB
/
Copy pathsecure_web_documents.inc.php
File metadata and controls
27 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
/**
* Secure Web Documents
* This script will mark web documents as private
*
* A document will be marked as private only if a web user group
* is assigned to the document group that the document belongs to.
*
*/
function secureWebDocument($docid='') {
global $modx;
$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privateweb = 0 WHERE ".($docid>0 ? "id='$docid'":"privateweb = 1"));
$sql = "SELECT DISTINCT sc.id
FROM ".$modx->getFullTableName("site_content")." sc
LEFT JOIN ".$modx->getFullTableName("document_groups")." dg ON dg.document = sc.id
LEFT JOIN ".$modx->getFullTableName("webgroup_access")." wga ON wga.documentgroup = dg.document_group
WHERE ".($docid>0 ? " sc.id='$docid' AND ":"")."wga.id>0";
$ids = $modx->db->getColumn("id",$sql);
if(count($ids)>0) {
$modx->db->query("UPDATE ".$modx->getFullTableName("site_content")." SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
}
}
?>