Goal: Hide the display of all files not relevant to graphic design users.
1. Create a new group called design_group.
2. Add your design users to the design_group.
3.
4.
5. Make note of the keyword ID number assigned to this field. (You can find it in the nativeadmin GUI on the Database /Data Fields page).
6.
7.
9.
10.
12. Replace every instance of 137 with the correct keyword ID number for your new Audience keyword. (The lines where these appear are set in bold face.)The code is comprised of two Xinet Portal stored procedures, that when used together filter Search results directly within the Search Engine, namely sp_RunSearchPostFilter(), which filters Browse and Search results and sp_NavigatorPostFilter(), which filters Navigator results. This method works better with Portal 4 (and later) than the PHP method described beginning on page 758 because it is faster: filtering takes place within the Search Engine, and properly updates Search and Browse paging counts as well as the Navigator’s file- and directory-item counts.In code example, shown below, the first procedure, sp_RunSearchPostFilter, employs an IF statement that includes g.GroupName='design_group' which tells the Portal Search Engine to apply the filter if the user’s Primary Group is design_group. If the group matches, the DELETE statement filters the results. You can change this specific part of the DELETE statement to suit your needs:This code means whenever Field137 does not have a value of Design or Public, or if it is null, that file will be filtered out.The second procedure, sp_NavigatorPostFilter, provides these three functions:Like the first procedure, the IF statement checks for design_group, and filters items. It then updates the file and dir counts with two UPDATE statements. You can change this specific part of each UPDATE statement to suit your needs:Remember to change both UPDATE statements, or your navigator counts will be incorrect.SET @prep=CONCAT("DELETE r FROM ", vResultTable, " r
LEFT JOIN file f ON r.FileID=f.FileID
LEFT OUTER JOIN keyword1 k ON r.FileID=k.FileID WHERE
IFNULL(NOT (k.Field137='Design' OR k.Field137='Public'),1);");SET @prep=CONCAT("DELETE r FROM ", vResultTable, " r
LEFT JOIN file f ON r.FileID=f.FileID
LEFT OUTER JOIN keyword1 k ON r.FileID=k.FileID WHERE
IFNULL(NOT (k.Field137='Design' OR k.Field137='Public'),1);");
PREPARE sprep FROM @prep;SET @prep=CONCAT("UPDATE ", vResultTable," t
SET t.FileItems=(SELECT COUNT(*) FROM file f
JOIN path p ON (f.PathID=p.PathID)
LEFT JOIN keyword1 k ON (f.FileID=k.FileID)
WHERE p.FileID=t.FileID AND f.Dir=0 AND (f.Online OR IF
(t.ShowArch,f.Archived,0))AND (!(f.finderflags & 16384))
AND
(IFNULL(k.Field137='Design' OR k.Field137='Public',0)) );");SET @prep=CONCAT("UPDATE ", vResultTable," t
SET t.DirItems=(SELECT COUNT(*) FROM file f
JOIN path p ON (f.PathID=p.PathID)
LEFT JOIN keyword1 k ON (f.FileID=k.FileID) WHERE
p.FileID=t.FileID AND f.Dir=1 AND (f.Online
OR IF(t.ShowArch,f.Archived,0))
AND (!(f.finderflags & 16384))
AND
(IFNULL(k.Field137='Design' OR k.Field137='Public',0)) );");