Author |
Message |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sat Sep 18, 2004 11:19 pm |
|
A while back I wrote this little script to allow certain topics to be read by registered users only. Let me know if it still works ![Wink](modules/Forums/images/smiles/icon_wink.gif) Code:<?
/**************************************************************************/
/* Place this file in your includes folder. */
/* This will restrict the selected topics to registered users. */
/* */
/* Assign Topic ID's to be restricted by adding this code for each Topic. */
/* As in */
/* $restrictedTopics[] = 1; */
/* $restrictedTopics[] = 5; */
/* The above 2 lines would restrict topic 1 and 5. */
/* Next, add a case() statement for each blocked topic, or let them all */
/* default to $hometext. That way you can assign a separate Text Message */
/* for each blocked Topic. */
/* */
/* Next, dependent on what version of nuke you are using, you will add */
/* this line: */
/* include("includes/restrictedTopics.php"); */
/* to modules/News/index.php and modules/News/article.php */
/* */
/* In index.php, find these lines (around line 91): */
/* $notes = stripslashes($notes); */
/* $introcount = strlen($hometext); */
/* and change them to: */
/* $notes = stripslashes($notes); */
/* include("includes/restrictedTopics.php"); */
/* $introcount = strlen($hometext); */
/* */
/* Likewise, in article.php find these lines (around line 60): */
/* $ratings = $row[ratings]; */
/* if ($aid == "") { */
/* and change them to: */
/* $ratings = $row[ratings]; */
/* include("includes/restrictedTopics.php"); */
/* if ($aid == "") { */
/* */
/* That should do it! */
/**************************************************************************/
$restrictedTopics[] = 1;
if (!is_admin($admin) AND !is_user($user) AND in_array($topic,$restrictedTopics)) {
switch($topic) {
case (1):
$hometext = 'Only registered users may view this story.';
break;
default:
$hometext = 'Only registered users may view this story.';
break;
}
$notes = '';
$bodytext = '';
$articlecomm = -1;
$fullcount = -1;
$acomm = -1;
$c_count = -1;
}
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
spcdata
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/53e3b36c42d23fde975fc.gif)
Joined: Jan 24, 2004
Posts: 81
Location: Sweden
|
Posted:
Sun Sep 19, 2004 9:11 am |
|
Hi Raven!
I have tested this on nuke 7.5 and it works just fine
It's a good one ![Exclamation](modules/Forums/images/smiles/icon_exclaim.gif) |
_________________ /spcdata |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
spcdata
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Sep 19, 2004 9:53 am |
|
I forget...there is a litle change in news/index.php
Look like this now:
Code:$notes = stripslashes($row['notes']);
include("includes/restrictedTopics.php");
$acomm = intval($row['acomm']);
$score = intval($row['score']);
$ratings = intval($row['ratings']);
if ($catid > 0) {
$row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_stories_cat WHERE catid='$catid'"));
$cattitle = stripslashes(check_html($row2['title'], "nohtml"));
}
getTopics($s_sid);
formatTimestamp($time);
$subject = stripslashes(check_html($subject, "nohtml"));
$introcount = strlen($hometext);
|
But it does not matter i you put it after "$notes" or directly above "$introcount" |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Sep 19, 2004 10:00 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bfnuke
Hangin' Around
![](modules/Forums/images/avatars/0c9f947943e3b0e59eb21.jpg)
Joined: Feb 01, 2006
Posts: 43
|
Posted:
Fri Feb 10, 2006 1:20 pm |
|
this would be perfect for what I want to do to restrict topics. I just tested on the 7.6 distro, but it doesnt' seem to work. Maybe I put it in the wrong place.. Raven, can you check to see if it still works ![Wink](modules/Forums/images/smiles/icon_wink.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Feb 13, 2006 10:27 pm |
|
I tested it and it works perfectly ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dingfelder
Hangin' Around
![](modules/Forums/images/avatars/Animaniacs/Animaniacs_-_Flavio.gif)
Joined: Jan 18, 2005
Posts: 45
Location: New Zealand
|
Posted:
Sat Mar 25, 2006 2:39 am |
|
can this be made to work with specific user groups instead of just registered users? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Mar 25, 2006 5:14 am |
|
Probably. You'd have to read the groups table and match that back to the users. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
mercman
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/Animaniacs/Animaniacs_-_Brain.gif)
Joined: Nov 29, 2006
Posts: 64
Location: TN, USA
|
Posted:
Sat Apr 12, 2008 9:54 am |
|
Hi all!
Does anyone know if this has been updated for use with the new v2.20.x distro?
I'd love to be able to set news articles for viewing by my registered users only. |
_________________ -Merc |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Apr 12, 2008 2:36 pm |
|
This was never a part of any distro, so the answer is no. If you're after an all or nothing approach, you could just make a generic module to show in Home and add a link to your News module for registered users only. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
mercman
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Apr 12, 2008 2:39 pm |
|
Raven,
Thanks for the reply!
Making a generic module is just a "leeetle bit" beyond me at this point. ![worship](modules/Forums/images/smiles/icon_worship.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Apr 12, 2008 3:01 pm |
|
It could be any module. In other words, place one of your other modules in Home via the Administrator Control Panel and allow all to view it. The make your News module visible in Modules block and set the Who Can View to Registered Users Only. |
Last edited by Raven on Sat Apr 12, 2008 5:12 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
mercman
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Apr 12, 2008 3:34 pm |
|
Hmm... interesting idea.
I'll have to try it on my beta site.
Thanks! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
mercman
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Apr 13, 2008 7:09 pm |
|
Raven,
You are a genius!!
Thank you for pointing me in the right direction.
First, I created a module with a simple vertical marquee message.
This worked fine, but I already had a "Anonymous Users Only" block for this message and I got tired of looking at it, and figured my members would as well.
Then comes this bright idea
What about an empty module??
If it worked, I could keep my message blocks in place (the one indicated above for Anonymous Users Only and the one for Registered Users Only), remove the News module from Home and restrict it, place the 'empty' module in Home and the changes would otherwise be transparent!!!
So I created my index.php using this code:
Code:
<?php
if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
define('INDEX_FILE', true);
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 0;
include("footer.php");
?>
|
Dropped the index.php into a folder named "Front Door", dropped the folder into my nukeroot/modules folder, went into the admin menu and activated the 'Front Door' module and put it into Home, and finally set the News module to Restricted Users Only.
Works Like A Charm!
I've not seen a single error in any theme, and no empty tables on the Home page!!
See it Only registered users can see links on this board! Get registered or login! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Apr 13, 2008 8:17 pm |
|
Very nice!
![Image Image](http://www.ravenphpscripts.com/images/forums/DavidCarradine.jpg) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sun Apr 13, 2008 9:08 pm |
|
This is funny because I just committed a change this weekend for the upcoming 2.3.0 release of RavenNuke(tm) to allow index.php to take module permissions into account even when they are in home. So, you could still set News as your Home module, but set it as Registered Users Only (there is a slight trick to doing that, but since 2.3.0 isn't due out for awhile, why divulge now - lol). Anonymous users would then not see the main module content (i.e., News) until they logged in. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
mercman
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 14, 2008 11:34 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|