Uploads - how to show only those categories that user have access to?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Aleksi
New Member
New Member
Posts: 9
Joined: Mon Jan 26, 2009 8:04 pm

Uploads - how to show only those categories that user have access to?

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Uploads - how to show only those categories that user have access to?

Post by Dr.CSS »

Using FEU and CC you can do this...
Aleksi
New Member
New Member
Posts: 9
Joined: Mon Jan 26, 2009 8:04 pm

Re: Uploads - how to show only those categories that user have access to?

Post 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
Last edited by Anonymous on Tue Dec 29, 2009 7:52 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Uploads - how to show only those categories that user have access to?

Post 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...
Aleksi
New Member
New Member
Posts: 9
Joined: Mon Jan 26, 2009 8:04 pm

Re: Uploads - how to show only those categories that user have access to?

Post 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
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Uploads - how to show only those categories that user have access to?

Post 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.
Aleksi
New Member
New Member
Posts: 9
Joined: Mon Jan 26, 2009 8:04 pm

Re: Uploads - how to show only those categories that user have access to?

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Uploads - how to show only those categories that user have access to?

Post by Dr.CSS »

Maybe this document can help...

http://calguy1000.com/downloads.html
Aleksi
New Member
New Member
Posts: 9
Joined: Mon Jan 26, 2009 8:04 pm

Re: Uploads - how to show only those categories that user have access to?

Post 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
User avatar
mr_to
New Member
New Member
Posts: 2
Joined: Mon Jan 04, 2010 11:11 am

Re: Uploads - how to show only those categories that user have access to?

Post 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
andershz
Forum Members
Forum Members
Posts: 49
Joined: Fri Nov 21, 2008 9:30 pm
Location: Sweden

Re: Uploads - how to show only those categories that user have access to?

Post 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.
Last edited by andershz on Sun Jan 24, 2010 10:10 am, edited 1 time in total.
Post Reply

Return to “Modules/Add-Ons”