UPDATED: news: set permission for user by category

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
streever

UPDATED: news: set permission for user by category

Post by streever »

NOTE:
I want to test this but am not sure what variable to use for USER in my list below. Is it $user_group == 'name of group'?
NOTE THE SECOND:
I did figure out the group variable: it's $group

I am running into a syntax problem with the if statement: anyone have any help? What syntax should I use? look below the original message to see what my code is like.

-----
Hi all,

I know this isn't inside the news module.

But I think it'd be easy to modify it in the following way:

I want to set a line of code in the TEMPLATE file of the ADMIN--this line says, "{if user == x}css style to hide the category that they aren't allowed to see{endif}

Meanwhile each category has it's own CSS stlye (which I hard-code in the template)

Does this make sense? I think it does. I think it will work.

Please let me know if I'm reinventing the wheel & this already exists (and I'm just not finding it) or if there is a better way. I'll be doing the same thing with CALENDAR.

Thanks,

David

----

WHERE I AM AT:
//Load the current articles
if ( $group != admin )
{
$entryarray = array();

$dbresult = '';

$query1 = "SELECT n.*, nc.long_name FROM ".cms_db_prefix()."module_news n LEFT OUTER JOIN ".cms_db_prefix()."module_news_categories nc ON n.news_category_id = nc.news_category_id ";
$query2 = "SELECT count(n.news_id) AS count FROM ".cms_db_prefix()."module_news n LEFT OUTER JOIN ".cms_db_prefix()."module_news_categories nc ON n.news_category_id = nc.news_category_id ";
$parms = array()
if ($curcategory != '')
  {
    $query1 .= " WHERE nc.long_name LIKE ?";
    $query2 .= " WHERE nc.long_name LIKE ?";
    if( $allcategories == 'yes' )
      {
$parms[] = $curcategory.'%';
      }
    else
      {
$parms[] = $curcategory;
      }
  }
$query1 .= ' ORDER by '.$sortby;
$query1 .= " LIMIT $startelement,$pagelimit";


this is my code right now

see it says if you aren't admin, then it does the standard article spit-out
I want to set several: one for each group that I have--that spits out only the category which is appropriate.

I feel close but need a little help. Please get back to me!
Last edited by streever on Tue Oct 02, 2007 9:36 pm, edited 1 time in total.
streever

Re: UPDATED: news: set permission for user by category

Post by streever »

also:
I know this may seem weird
it has to be hard-coded into the template

but it's the only solution I can think of unless CMSMS adds more complex controls for groups/etc. I don't mind adding it manually, it's a one-time (or at most once a year time...) thing.

I know this won't be an ideal solution for everyone, but it will help me, and 2 of my clients. I am sure it will help a lot of other users!
streever

Re: UPDATED: news: set permission for user by category

Post by streever »

Does anyone have any feedback on this?

i'm very, very close, but just am having a hard time telling the script to pull only x category: I need to figure out how to say,

"if %group == groupname
display from rows when category=x
else
if %group == groupname
display from rows when category=x
else

etc etc.... this is all it has to say, it seems so simple, but of course I don't know everything about the original page.

I'm running into an error with my syntax on the articles php page--that's where the issue is--so if anyone has any info, let me know.

Thanks!!
streever

Re: UPDATED: news: set permission for user by category

Post by streever »

Hey all,

for anyone following this, this is what I've gotten to now:
I tried to nest the call to categories in an if statement, and that returns an error: the page loads nothing, and labels one of the OTHER if statements as incorrect.

So, I'm revising the way that I write the if statement--I hope to have that part working later today, and will post the code when I get it working.

Then I'll be on to figuring out how to just pull one category.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: UPDATED: news: set permission for user by category

Post by Dr.CSS »

You might have wanted to put this under Modules/Add-Ons...
streever

Re: UPDATED: news: set permission for user by category

Post by streever »

hmmm can i move it now? or should i just re-post?
streever

Re: UPDATED: news: set permission for user by category

Post by streever »

does anyone know where I can find an example of the proper syntax for if statements? I looked at the guts of the pages, but I can't reproduce it.

Should I read smarty documentation on if?
alby

Re: UPDATED: news: set permission for user by category

Post by alby »

streever wrote: does anyone know where I can find an example of the proper syntax for if statements? I looked at the guts of the pages, but I can't reproduce it.

Should I read smarty documentation on if?
If you use if statement in template/page you must use smarty sintax, if you use in php/udt you must use php sintax

Alby
Locked

Return to “CMSMS Core”