I have changed the demo site by adding the document #64 into a "admDocGrp". So now the document #64 exists in the table document_groups.
So we have the following context:
#64 : public document
webUser ---webGroup=========== WebGrpDoc --------- Doc
asearch ----- web============== asGrpDoc1 --------- 68
asearch ----- web ============== asGrpDoc2 --------- 73
id of asGrpDoc1 = 1 and asGrpDoc2 = 2
mngUser ---mngGroup=========== mngGrpDoc --------- Doc
admin1 ----- admin============= admGrpDoc --------- 64
id of admGrpDoc = 4
All these documents have search terms "proud".
The current results with 1.8.1 release are:
case 1/ When logged as a web user (asearch): you got the documents #63 (public) and #68 and #73 (webGrpDoc)
case 2/ when you are not logged, you get #63 (public) AND #64 (mngGrpDoc)
From my point of view, results of the
case 1 are correct. When you are logged as web user you are not logged as manager user. So you can’t get the #64
the select is:
SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.menutitle, sc.content, sc.publishedon,
GROUP_CONCAT( DISTINCT CAST(ntv.id AS CHAR) SEPARATOR "," ) AS tv_id,
GROUP_CONCAT( DISTINCT ntv.value SEPARATOR ", " ) AS tv_value
FROM `mod2_site_content` sc
LEFT JOIN `mod2_document_groups` dg ON sc.id = dg.document
LEFT JOIN(
SELECT DISTINCT tv.id, tv.value, tv.contentid
FROM `mod2_site_tmplvar_contentvalues` tv
WHERE (((tv.value LIKE '%proud%'))) ) AS ntv ON sc.id = ntv.contentid
WHERE ((sc.id IN (63,308,64,65,66,67,68,69,70,71,72,73,97)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.type='document') AND (ISNULL(dg.document_group) OR (dg.document_group IN (1,2))))
GROUP BY sc.id
HAVING (((sc.pagetitle LIKE '%proud%') OR (sc.longtitle LIKE '%proud%') OR (sc.description LIKE '%proud%') OR (sc.alias LIKE '%proud%') OR (sc.introtext LIKE '%proud%') OR (sc.menutitle LIKE '%proud%') OR (sc.content LIKE '%proud%') OR (tv_value LIKE '%proud%')))
ORDER BY sc.publishedon,sc.pagetitle
To get the #64 document from the admGrpDoc document group you are obliged to link the admGrpDoc to the "web" web user group:
asearch ----- web============== admGrpDoc --------- 64
With this new link you get the four results: #63 (public), #64 (admDocGrp) and #68 & #73
select statement:
SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.menutitle, sc.content, sc.publishedon,
GROUP_CONCAT( DISTINCT CAST(ntv.id AS CHAR) SEPARATOR "," ) AS tv_id,
GROUP_CONCAT( DISTINCT ntv.value SEPARATOR ", " ) AS tv_value
FROM `mod2_site_content` sc
LEFT JOIN `mod2_document_groups` dg ON sc.id = dg.document
LEFT JOIN(
SELECT DISTINCT tv.id, tv.value, tv.contentid
FROM `mod2_site_tmplvar_contentvalues` tv
WHERE (((tv.value LIKE '%proud%'))) ) AS ntv ON sc.id = ntv.contentid
WHERE ((sc.id IN (63,308,64,65,66,67,68,69,70,71,72,73,97)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.type='document') AND (ISNULL(dg.document_group) OR (dg.document_group IN (1,2,4))))
GROUP BY sc.id
HAVING (((sc.pagetitle LIKE '%proud%') OR (sc.longtitle LIKE '%proud%') OR (sc.description LIKE '%proud%') OR (sc.alias LIKE '%proud%') OR (sc.introtext LIKE '%proud%') OR (sc.menutitle LIKE '%proud%') OR (sc.content LIKE '%proud%') OR (tv_value LIKE '%proud%')))
ORDER BY sc.publishedon,sc.pagetitle
Case 2
The results are not correct. When you are not logged, you shouldn’t get the document #64 as result.
This is an issue.
This issue is due to the fact that, when the user is not logged, I don’t check that the document is or not in the documents_group table.
This is clearly an issue.
Here is the select statement:
SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.menutitle, sc.content, sc.publishedon,
GROUP_CONCAT( DISTINCT CAST(ntv.id AS CHAR) SEPARATOR "," ) AS tv_id,
GROUP_CONCAT( DISTINCT ntv.value SEPARATOR ", " ) AS tv_value
FROM `mod2_site_content` sc
LEFT JOIN(
SELECT DISTINCT tv.id, tv.value, tv.contentid
FROM `mod2_site_tmplvar_contentvalues` tv
WHERE (((tv.value LIKE '%proud%'))) ) AS ntv ON sc.id = ntv.contentid
WHERE ((sc.id IN (63,308,64,65,66,67,68,69,70,71,72,73,97)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.type='document') AND (sc.privateweb=0))
GROUP BY sc.id
HAVING (((sc.pagetitle LIKE '%proud%') OR (sc.longtitle LIKE '%proud%') OR (sc.description LIKE '%proud%') OR (sc.alias LIKE '%proud%') OR (sc.introtext LIKE '%proud%') OR (sc.menutitle LIKE '%proud%') OR (sc.content LIKE '%proud%') OR (tv_value LIKE '%proud%')))
ORDER BY sc.publishedon,sc.pagetitle
I have remove the link between admDocGrp and the "web" web user group. So you can run these examples on
this demo page
Thanks a lot for this important feedback