Page 1 of 1
Uploads - how to show only those categories that user have access to?
Posted: Tue Dec 29, 2009 10:04 am
by Aleksi
Hi,
As the topic says, is there a way to get the uploads module "categorysummary"-action to only list those categories that my user has access to?
Thanks,
Aleksi
Re: Uploads - how to show only those categories that user have access to?
Posted: Tue Dec 29, 2009 5:04 pm
by Dr.CSS
Using FEU and CC you can do this...
Re: Uploads - how to show only those categories that user have access to?
Posted: Tue Dec 29, 2009 5:48 pm
by Aleksi
That doesn't really solve my problem, I have FEU and CC installed, but still I have no clue how I could use those to filter category listing from uploads module. help still needed
Aleksi
Re: Uploads - how to show only those categories that user have access to?
Posted: Wed Dec 30, 2009 2:41 am
by Dr.CSS
If ccuser loggedin & member of this group
this uploads category
else if member of this group
this category
else if etc. etc.
I believe there is an example of this in one of those modules Help, FEU or CC...
Re: Uploads - how to show only those categories that user have access to?
Posted: Wed Dec 30, 2009 6:29 am
by Aleksi
Yep, but still that doesn't solve the problem. That would of course work on the case where I would have predefined categories for my users, but this is not the case. My client needs to be able to modify and create new categories that will be automatically listed.
Basic access control is ok because uploads module takes care about that with FEU, but it feels really stupid to list categories which are not relevant for my user.
So I'm using categorysummary action to list all the categories, this will now list all, no matter if the user has an access or not. I Know that the problem/answer lies on the template I'm using. I just have no idea what parameters I have to use to check if the current user have proper access to some category.
the part from the template which creates the list looks like this,
Code: Select all
{foreach from=$items item=entry}
{$entry->namelink}
{/foreach}
So some help is still needed
Aleksi
Re: Uploads - how to show only those categories that user have access to?
Posted: Thu Dec 31, 2009 4:05 am
by jmcgin51
have you looked at the Admin panel in Uploads, where there is an option to select which FEU groups can access selected files? Not sure if this will solve your problem, but might lead you closer.
Re: Uploads - how to show only those categories that user have access to?
Posted: Thu Dec 31, 2009 8:28 am
by Aleksi
Yep, the basic user rights management with FEU works great, that is not a problem.
I just need to know how I can check if the user has an access to some category when I'm creating the list from my template.
So some help is still needed, anyone?
-Aleksi
Re: Uploads - how to show only those categories that user have access to?
Posted: Thu Dec 31, 2009 6:17 pm
by Dr.CSS
Re: Uploads - how to show only those categories that user have access to?
Posted: Sun Jan 03, 2010 8:38 pm
by Aleksi
Thanks for the info, but still missing the solution.
I can't figure out what parameter I need to use to check from the uploads module if the user has access to the category or not, so I could build a proper category listing for my user.
So if someone has an idea, help would be highly appreciated.
-Aleksi
Re: Uploads - how to show only those categories that user have access to?
Posted: Mon Jan 04, 2010 1:25 pm
by mr_to
hi all
ii don't know if this can help
ii try to display all categorie for user logged in uploads module
needed modules
front end users
custom contents
and uploads
$customcontent_groups display a list of groups off the user logged
this work if the user is only in one group
{cms_module module="Uploads" category=$customcontent_groups mode="summary" }
if the user is in more than one group
oops !!!!
need to write a user tag !!!
Regards
Re: Uploads - how to show only those categories that user have access to?
Posted: Tue Jan 12, 2010 1:05 pm
by andershz
I have previously made a UDT that returns the list of (listable) Uploads categories a FEU user has access to, (or not).
Code: Select all
#list_feu_upload_cats. UDT to return the list of Uploads categories a FEU user has access to, (or not).
#$params['userid']; # The numeric FEU user id.
#$params['permit']; #1 -> return permitted categories, 0 -> return not permitted categories.
#$params['prefix'] ; # An optional prefix to add to each returned category name.
global $gCms;
$db =& $gCms->GetDb();
$ug = array(); #List of groups the user belongs to.
$cg = array(); #List of groups having access to a category.
$test = array(); # The intersection of ug and cg.
$cn = array(); #List of categories the user has access to, (or not).
$permit = $params['permit']; #1 -> return permitted categories, 0 -> return not permitted categories.
#Find all groups the user belongs to.
$sql = 'SELECT groupid FROM ' . cms_db_prefix() . 'module_feusers_belongs WHERE userid="' . $params['userid'] .'";';
$dbresult =& $db->Execute($sql);
while ($dbresult && $row = $dbresult->FetchRow()) {
$ug[] = $row['groupid'];
}
#Find all category names and the list of groups having access to each category.
$sql = 'SELECT upload_category_name,upload_category_groups FROM ' . cms_db_prefix() . 'module_uploads_categories WHERE upload_category_listable="1";';
$dbresult =& $db->Execute($sql);
#For each category, match the list of groups having access with the list of groups the user belongs to.
while ($dbresult && $row = $dbresult->FetchRow()) {
$cg = split( '[,]', $row['upload_category_groups']);
$test = array_intersect( $ug, $cg);
if ( (count($test) > 0 && $permit > 0) || (count($test) == 0 && $permit == 0) ) {
$cn[] = $params['prefix'] . $row['upload_category_name'];
}
}
echo join( $cn, ','); #Return list of categories.
A slight modification would give this UDT that checks if a FEU user has access to a Uploads category.
Code: Select all
#check_feu_upload_cat. UDT to check if a FEU user has access to a Uploads category.
#$params['userid']; # The numeric FEU user id.
#$params['cat'] ; # The category name.
global $gCms;
$db =& $gCms->GetDb();
$ok=0;
$ug = array(); #List of groups the user belongs to.
$cg = array(); #List of groups having access to a category.
$test = array(); # The intersection of ug and cg.
#Find all groups the user belongs to.
$sql = 'SELECT groupid FROM ' . cms_db_prefix() . 'module_feusers_belongs WHERE userid="' . $params['userid'] .'";';
$dbresult =& $db->Execute($sql);
while ($dbresult && $row = $dbresult->FetchRow()) {
$ug[] = $row['groupid'];
}
#Find list of groups having access to a category.
$sql = 'SELECT upload_category_groups FROM ' . cms_db_prefix() . 'module_uploads_categories WHERE upload_category_name="' . $params['cat'] . '";';
$dbresult =& $db->Execute($sql);
#Match the list of groups having access with the list of groups the user belongs to.
if ($dbresult && $row = $dbresult->FetchRow()) {
$cg = split( '[,]', $row['upload_category_groups']);
$test = array_intersect( $ug, $cg);
if ( count($test) > 0 ) {
$ok=1;
}
}
echo $ok;
It could be used for instance like this to set $permit=1 if the user has access to the category 'my_category_name', otherwise set $permit=0.
Code: Select all
{if $ccuser->loggedin()}
{capture assign=permit}
{check_feu_upload_cat userid=$customcontent_loggedin cat='my_category_name'}
{/capture}
{/if}
Of course, future changes to the FEUsers or Uploads database table structure may break this.