Page 1 of 1

News module; authorization for reading categories

Posted: Thu Dec 20, 2012 9:07 am
by sander
Dear people,

With joy and satisfaction I'm using CMSMS for a website in combination with an intranet. I'm using the FEUsers and CContent modules to filter the intranet content. Works fine though I'm having a problem:

In the news-module I have two categories, intern and extern news. Intern news only to show to internal users (based on ip-adres) or logged in users from the group 'medewerkers'. Extern news to show on the website.

I'm checking authorization of users for the content in the page-templates with the following code:

Code: Select all

{if ($ccuser->loggedin() && $ccuser->memberof('Intranet')) || $ccuser->ipmatches('192.168.1.1,192.168.1.2')}
The URL of a newsitem show as followed:
"http://host/news/182/77/extern-nieuwsbericht

The last paramater ('extern-nieuwsbericht') isn't used by cmsms and just for SEO-friendly URL's. The numbers are:
- 182 = newsitem id
- 77 = page-id on which the newsitem is presented

By changing the first parameter, you can walk through all published newsitems, independent of category.

I'd like to add the following logic to my active news-templates:

Code: Select all

{foreach from=$items item=entry}
{if $entry->category == 'intern'}
   {if $ipaddress == '192.168.1.1' || $ipaddress == '192.168.1.1' || ($ccuser->loggedin() && $ccuser->memberof('Intranet'))}
       {* internal item *}
       show newsitem
   {else}
      You don't have any rights
   {/if}
{else}
   {* external item *}
   show message
{/if}
{/foreach}
Problem: I can't get this to work. You know a solution? Using an UDT for example? Please share!

Thanks very much in advance!!!

Kind regards Sander

ps. Sorry for my bad English, I hope my point is clear ;-)