Hide categories from other users
Posted: 06 Jul 2013, 15:16
I was searching for a solution for this in the forum with no definitive answer. So I decided to create my own modification that seems to work.
In models->categories.php
I added to the sql query
. " AND (cc.accessuserid LIKE '%".$user->id ."%' or cc.accessuserid = '-1' or cc.accessuserid = '0')" after line 197
So it looks like this:
if ($subcategories) {
$query = " SELECT cc.id, cc.title, cc.alias, cc.access as cataccess, cc.accessuserid as cataccessuserid, COUNT(c.id) AS numdoc"
. " FROM #__phocadownload_categories AS cc"
. " LEFT JOIN #__phocadownload AS c ON c.catid = cc.id AND c.published = 1 AND c.textonly = 0"
. ($pQ == 1 ? ((count($joins)>0?( " LEFT JOIN " .implode( " LEFT JOIN ", $joins )):"")):"") // GWE MOD
. " WHERE " . implode( " AND ", $wheres )
. " AND (cc.accessuserid LIKE '%".$user->id ."%' or cc.accessuserid = '-1' or cc.accessuserid = '0')" // FSW MOD
. " GROUP BY cc.id"
. " ORDER BY cc.".$categoryOrdering;
This solved my problem maybe it will help others.
Are there any security issues or conflicts that you can see with using this modification?
In models->categories.php
I added to the sql query
. " AND (cc.accessuserid LIKE '%".$user->id ."%' or cc.accessuserid = '-1' or cc.accessuserid = '0')" after line 197
So it looks like this:
if ($subcategories) {
$query = " SELECT cc.id, cc.title, cc.alias, cc.access as cataccess, cc.accessuserid as cataccessuserid, COUNT(c.id) AS numdoc"
. " FROM #__phocadownload_categories AS cc"
. " LEFT JOIN #__phocadownload AS c ON c.catid = cc.id AND c.published = 1 AND c.textonly = 0"
. ($pQ == 1 ? ((count($joins)>0?( " LEFT JOIN " .implode( " LEFT JOIN ", $joins )):"")):"") // GWE MOD
. " WHERE " . implode( " AND ", $wheres )
. " AND (cc.accessuserid LIKE '%".$user->id ."%' or cc.accessuserid = '-1' or cc.accessuserid = '0')" // FSW MOD
. " GROUP BY cc.id"
. " ORDER BY cc.".$categoryOrdering;
This solved my problem maybe it will help others.
Are there any security issues or conflicts that you can see with using this modification?