Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Disable pages and extra for users  (Read 4074 times)

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Disable pages and extra for users
« on: May 29, 2008, 03:11:38 PM »

I am looking to make users only add category and articles
I donít want users to make new pages and extras.
is there any easy way to do this?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Disable pages and extra for users
« Reply #1 on: May 29, 2008, 06:31:03 PM »

I am looking to make users only add category and articles
I donít want users to make new pages and extras.
is there any easy way to do this?

Perhaps you would control the text-links to New & Edit Pages and Extras with a user-type check string so that they are only visible to specific user types.... something like...if (user type)... these links... else (other user type).
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: Disable pages and extra for users
« Reply #2 on: May 29, 2008, 08:30:56 PM »

Thanks keyrock but I donít know how to do this. :/
Maybe a small example can help me, if is not a big trouble.
Logged

centered

  • Guest
Re: Disable pages and extra for users
« Reply #3 on: May 29, 2008, 08:36:37 PM »

You can always look in the admin function and comment out the pages and extras lines
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: Disable pages and extra for users
« Reply #4 on: May 29, 2008, 09:21:13 PM »

OK thanks equilni and keyrocks
i do it like this

Code: [Select]
if (get_identity($_SESSION['id'], 'site_owner') == 'YES'){
 echo '<p>'.l('extra_contents').': <a href="extra_new/" title="'.l('add_new').'">'.l('add_new').'</a>';
if (stats('articles',2) > 0) {echo $link.'extra_contents/" title="'.l('view').'">'.l('view').'</a>';}
echo '</p>';
echo '<p>'.l('pages').': <a href="page_new/" title="'.l('add_new').'">'.l('add_new').'</a>';
 if (stats('articles',3) > 0) {echo $link.'pages/" title="'.l('view').'">'.l('view').'</a>';}
}

but if some one try it like this
http://localhost/page_new
can still add a page ..how can i solve this
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: Disable pages and extra for users
« Reply #5 on: May 29, 2008, 10:36:53 PM »

For starters change in function center() this code:
Code: [Select]
case 'extra_new': form_articles('extra_new'); return; break;
case 'page_new': form_articles('page_new'); return; break;
case 'editcomment': edit_comment(); return; break;
case 'files':
$permit_upload = retrieve('permit_upload', 'users', 'id', $_SESSION['id']);
if ($permit_upload == 'YES' || get_identity($_SESSION['id'], 'level') == '1') {
files(); return; break;
}else{
echo l('mu_noaccess'); return; break;
}
to something like this:
Code: [Select]
case 'extra_new':
if (get_identity($_SESSION['id'], 'site_owner') == 'YES')
{
form_articles('extra_new');
}
else
{
echo l('mu_noaccess');
}
return; break;
case 'page_new':
if (get_identity($_SESSION['id'], 'site_owner') == 'YES')
{
form_articles('page_new');
}
else
{
echo l('mu_noaccess');
}
return; break;
case 'editcomment': edit_comment(); return; break;
case 'files':
$permit_upload = retrieve('permit_upload', 'users', 'id', $_SESSION['id']);
if ($permit_upload == 'YES' || get_identity($_SESSION['id'], 'level') == '1') {
files(); return; break;
}else{
echo l('mu_noaccess'); return; break;
}
And probably some more places to change similarly here and may be in processing as well.

P.S. Just a writeup - zero testing ;)
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: Disable pages and extra for users
« Reply #6 on: May 30, 2008, 01:10:59 AM »

@codetwist

Yeap that did the trick  :)

with the above code and yours is working.

Thanks dudes
Logged

Andrew

  • Newbie
  • *
  • Karma: 1
  • Posts: 9
Re: Disable pages and extra for users
« Reply #7 on: October 27, 2009, 02:36:07 PM »

Great advice in this thread. I went ahead and used your tips and disabled categories, pages and extras for all except site owner. Making the following changes in function center() of snewsMU.php

case 'admin_category':
            if (get_identity($_SESSION['id'], 'site_owner') == 'YES')
            {
               form_categories();
            }
            else
            {
               echo l('mu_noaccess');

            }  return; break;
         case 'articles': admin_articles('article_view'); return; break;
         case 'extra_contents': admin_articles('extra_view'); return; break;
         case 'pages': admin_articles('page_view'); return; break;
         case 'admin_article': form_articles(''); return; break;
         case 'article_new': form_articles('article_new'); return; break;
         case 'extra_new':
            if (get_identity($_SESSION['id'], 'site_owner') == 'YES')
            {
               form_articles('extra_new');
            }
            else
            {
               echo l('mu_noaccess');

            } return; break;
         case 'page_new':
            if (get_identity($_SESSION['id'], 'site_owner') == 'YES')
            {
               form_articles('page_new');
            }
            else
            {
               echo l('mu_noaccess');

            }  return; break;

Many thanks! And backing up was a good idea because it took me a few goes to get it right.

p.s. tried to use the code tags but couldn't work out how to change color within them.
« Last Edit: October 27, 2009, 02:40:38 PM by Andrew »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Disable pages and extra for users
« Reply #8 on: October 27, 2009, 10:25:27 PM »

Great advice in this thread.
p.s. tried to use the code tags but couldn't work out how to change color within them.

Just add an opening php-tag after the opening code tag... and a closing php-tag before the closing code tag.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU