sNews Forum

sNews 1.6 (previous version) => sNewsMU (sNews Multi User version) => MU general => Topic started by: sibas on May 29, 2008, 03:11:38 pm

Title: Disable pages and extra for users
Post by: sibas 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?
Title: Re: Disable pages and extra for users
Post by: Keyrocks 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).
Title: Re: Disable pages and extra for users
Post by: sibas 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.
Title: Re: Disable pages and extra for users
Post by: centered on May 29, 2008, 08:36:37 pm
You can always look in the admin function and comment out the pages and extras lines
Title: Re: Disable pages and extra for users
Post by: sibas 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
Title: Re: Disable pages and extra for users
Post by: codetwist 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 ;)
Title: Re: Disable pages and extra for users
Post by: sibas on May 30, 2008, 01:10:59 am
@codetwist

Yeap that did the trick  :)

with the above code and yours is working.

Thanks dudes
Title: Re: Disable pages and extra for users
Post by: Andrew 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.
Title: Re: Disable pages and extra for users
Post by: Keyrocks 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.