Welcome Guest! To enable all features please Login or Register.
Options
View
Go to last post Go to first unread
Offline niemiro  
#1 Posted : Sunday, March 4, 2012 1:02:01 PM(UTC)
niemiro


Rank: YAF Forumling

Reputation:

Joined: 5/3/2010(UTC)
Posts: 4

Hello all!

I am hoping that this isn't too big a job. Basically, I want to create a single forum of my board which allows read access only to thread starters and moderators. I still want anyone to be able to create threads, just not read each other's threads.

I have looked around the source code a little, and I see that I need to call YafBuildLink.AccessDenied(). However, I don't know where I need to call this from (I see lots of places which look like they might be suitable), and I don't know how to check if the user is the thread starter.

Any help any of you could offer would be very greatly appreciated.
Sponsor
Offline niemiro  
#2 Posted : Saturday, March 10, 2012 2:30:38 AM(UTC)
niemiro


Rank: YAF Forumling

Reputation:

Joined: 5/3/2010(UTC)
Posts: 4

Hello,

I still need a little bit of help here, and any you could offer would be very greatly appreciated. I am thinking about editing the posts.ascx.cs file, and in the Page_Load event, changing this:

Code:

else if (!this.PageContext.ForumReadAccess)
{
	YafBuildLink.AccessDenied();
}


to this:

Code:

else if (!this.PageContext.ForumReadAccess || (this.PageContext.PageForumID == 3 && !this.PageContext.ForumModeratorAccess && !Thread_Starter))
{
	YafBuildLink.AccessDenied();
}


However, I am still having trouble working out the thread starter: "!Thread_Starter"

Please help me Smile
Online tha_watcha  
#3 Posted : Saturday, March 10, 2012 4:45:50 AM(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

Medals: Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.

Joined: 3/6/2010(UTC)
Posts: 2,928

Thanks: 64 times
Was thanked: 1000 time(s) in 861 post(s)
Simply change the forum read access and add a check if the current user matches the topic starter user id

Code:

if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get<IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }
            
           // Check if user is topic starter
            if (this.PageContext.PageUserID != this._topic["UserID"].ToType<int>())
            {
                 YafBuildLink.AccessDenied();
            }
Offline johntigner  
#4 Posted : Tuesday, April 3, 2012 10:30:52 PM(UTC)
johntigner


Rank: YAF Forumling

Reputation:

Joined: 4/2/2012(UTC)
Posts: 4

Basically i'm a newbie to Yaf and need some help. .......I was wondering if someone could help me understand how to implement this code.

Thanks
Offline johntigner  
#5 Posted : Thursday, April 19, 2012 6:48:27 AM(UTC)
johntigner


Rank: YAF Forumling

Reputation:

Joined: 4/2/2012(UTC)
Posts: 4

After I put the code in, now only the threadstarter can open the topic. admin and moderators or no one else can open the topic.
Someone please help
Online tha_watcha  
#6 Posted : Thursday, April 19, 2012 7:05:50 AM(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

Medals: Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.

Joined: 3/6/2010(UTC)
Posts: 2,928

Thanks: 64 times
Was thanked: 1000 time(s) in 861 post(s)
Originally Posted by: johntigner Go to Quoted Post
After I put the code in, now only the threadstarter can open the topic. admin and moderators or no one else can open the topic.
Someone please help


Then you need to check if the user is an admin or a mod

Code:

// Check if user is topic starter or admin or forum moderator
            if (this.PageContext.PageUserID != this._topic["UserID"].ToType<int>() && (!this.PageContext.IsAdmin || !this.PageContext.IsForumModerator))
            {
                YafBuildLink.AccessDenied();
            }


Offline johntigner  
#7 Posted : Friday, April 27, 2012 1:29:57 PM(UTC)
johntigner


Rank: YAF Forumling

Reputation:

Joined: 4/2/2012(UTC)
Posts: 4

`Thanks watcha this code is better it blocks everyone but the thread starter and the admins ..... i created the role moderator with is mod checked ...if i assign a user the moderator role they cannot open the topic ... only the thread_starter and admin can open the topics .... mods have mod acess in the forum.

Please tell me what i,m doing wrong ...... i donnot want the moderators to be able to change the Yaf confirugations
Online tha_watcha  
#8 Posted : Saturday, April 28, 2012 9:03:41 AM(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

Medals: Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.

Joined: 3/6/2010(UTC)
Posts: 2,928

Thanks: 64 times
Was thanked: 1000 time(s) in 861 post(s)
Originally Posted by: johntigner Go to Quoted Post
`Thanks watcha this code is better it blocks everyone but the thread starter and the admins ..... i created the role moderator with is mod checked ...if i assign a user the moderator role they cannot open the topic ... only the thread_starter and admin can open the topics .... mods have mod acess in the forum.

Please tell me what i,m doing wrong ...... i donnot want the moderators to be able to change the Yaf confirugations


sorry code was wrong try this...

Code:

// Check if user is topic starter or admin or forum moderator
            if (this.PageContext.PageUserID != this._topic["UserID"].ToType<int>() && !this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess)
            {
                YafBuildLink.AccessDenied();
            }
Offline johntigner  
#9 Posted : Friday, May 4, 2012 7:18:04 AM(UTC)
johntigner


Rank: YAF Forumling

Reputation:

Joined: 4/2/2012(UTC)
Posts: 4

Thanks for your code update i will replace with the new code tomorrow and send you an update.

Just one other thing Even though unauthorized people cannot read the topic, they can still see the topic title .....Can we hide the topic titles as well?

Thank You For All Your Help
John



Offline kdtbzvn  
#10 Posted : Monday, July 23, 2012 9:34:18 PM(UTC)
kdtbzvn


Rank: YAF Lover

Reputation:

Joined: 7/23/2012(UTC)
Posts: 30

Thanks: 6 times
I understand, thank you very much for the information above.
Rss Feed  Atom Feed
Users browsing this topic
guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error