YAFLogo

Posted by: niemiro - Sunday, 4 March 2012 20:02:01
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.

Posted by: niemiro - Saturday, 10 March 2012 09:30:38
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=csharp]else if (!this.PageContext.ForumReadAccess) { YafBuildLink.AccessDenied(); }[/code] to this: [code=csharp]else if (!this.PageContext.ForumReadAccess || (this.PageContext.PageForumID == 3 && !this.PageContext.ForumModeratorAccess && !Thread_Starter)) { YafBuildLink.AccessDenied(); }[/code] However, I am still having trouble working out the thread starter: "!Thread_Starter" Please help me :)

Posted by: tha_watcha - Saturday, 10 March 2012 11:45:50
Simply change the forum read access and add a check if the current user matches the topic starter user id [code=csharp]if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess) { // attempt to get permission by redirecting to login... this.Get().HandleRequest(ViewPermissions.RegisteredUsers); } else if (!this.PageContext.ForumReadAccess) { YafBuildLink.AccessDenied(); } // Check if user is topic starter if (this.PageContext.PageUserID != this._topic["UserID"].ToType()) { YafBuildLink.AccessDenied(); }[/code]

Posted by: johntigner - Wednesday, 4 April 2012 06:30:52
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

Posted by: johntigner - Thursday, 19 April 2012 14:48:27
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

Posted by: tha_watcha - Thursday, 19 April 2012 15:05:50
[quote=johntigner;54276]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[/quote] Then you need to check if the user is an admin or a mod [code=csharp]// Check if user is topic starter or admin or forum moderator if (this.PageContext.PageUserID != this._topic["UserID"].ToType() && (!this.PageContext.IsAdmin || !this.PageContext.IsForumModerator)) { YafBuildLink.AccessDenied(); }[/code]

Posted by: johntigner - Friday, 27 April 2012 21:29:57
`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

Posted by: tha_watcha - Saturday, 28 April 2012 17:03:41
[quote=johntigner;54387]`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[/quote] sorry code was wrong try this... [code=csharp]// Check if user is topic starter or admin or forum moderator if (this.PageContext.PageUserID != this._topic["UserID"].ToType() && !this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess) { YafBuildLink.AccessDenied(); }[/code]

Posted by: johntigner - Friday, 4 May 2012 15:18:04
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

Posted by: kdtbzvn - Tuesday, 24 July 2012 05:34:18
I understand, thank you very much for the information above.