ManniAT
  • Posts: 15
  • Joined: 15/06/2009
Hi,

it would be great to have the "Exclude from Captcha" available in Roles.
Or even better via Ranks.
Both offer the ability to exclude users just by adding them to a Role.

A use I have ATM is a WoW Forum I'm implementing.
Guild-Memebers are "trusted" and therefore they should be excluded from Captcha.
This could also be used for "intern users" "employees" and so forth.

The other thing (ranks) I've with my providers forum.
For my first 15 (I think) posts I had to fill a captcha - after these posts captcha was removed.

Roles
++ User can be member of different roles
-- Doesn't work via ladder system

Rank
++ Works via Ladder System
-- Could be diffcult to manage if a ladder system is implemented

Some details about the "WoW Site".
We have a forum (for introduction / recruitment) where public posting is allowed.
To protect the things we set Captch on this forum.
Unfortunately this means that also Guild Members have to fill the captcha.

ATM I use a hack - I check if the member has poll access to disable the captcha.
This works as if the "access mask" would have a flag "no captch" (which by the way would also be a possible solution - without ladder of course).

Manfred
Sponsor
ManniAT
  • Posts: 15
  • Joined: 15/06/2009
Unfortunately I just saw that Captcha is a "host setting".
So I can't even say - these are "internal forums" - no captcha needed...

That's what I thought first - "interal forum"==access only for "trusted members" - no captcha needed.
ManniAT
  • Posts: 15
  • Joined: 15/06/2009
Since the system (as it works ATM) is not useable for me I did a short hack.
Thanks to the clear structure of YAF it was a work of minutes 🙂
All modifications are made in YAF.Core.Context.UserPageBase.cs

And maybe (I didn't check) there is an easier way to determie Group Membership as the one I use - maybe it's somewhere in cache or so...

The Result of my hack:
You create a group (Role) NoCaptcha.
Every member of this Role is exluded from Captcha check.

There are three easy things to do (code):

Add a property for Group membership:
//MANNIAT CHANGED - add value to disable captcha via group membership
#region IsUserInNoCaptchaGroup
private bool m_bIsUserInNoCaptchaGroup;
public bool IsUserInNoCaptchaGroup {
	get { return m_bIsUserInNoCaptchaGroup; }
}
#endregion


Next set the property in the method InitUserAndPage (near the beginning of the method):
if (user != null && YafContext.Current.Get<HttpSessionStateBase>()["UserUpdated"] == null)  {
    RoleMembershipHelper.UpdateForumUser(user, this.PageBoardID);
    YafContext.Current.Get<HttpSessionStateBase>()["UserUpdated"] = true;
    }
  //MANNIAT CHANGED - add value to disable captcha via group membership
  if(user != null && Roles.IsUserInRole(user.UserName, "NoCaptcha")) {
	  m_bIsUserInNoCaptchaGroup = true;
  }

I included some original code to make it easier to find the insert position.

Last not least change the existing property IsCaptchaExcluded (aroung line 480 in 1.9.5.5):
public bool IsCaptchaExcluded {
  get  {
   if (this._userFlags != null) {
//MANNIAT CHANGED - added "|| m_bIsUserInNoCaptchaGroup" to disable captcha via group membership
      return this._userFlags.IsCaptchaExcluded || m_bIsUserInNoCaptchaGroup;
    }

    return false;
   }
 }


This hack is not perfect (hardcoded group and so forth) but at least it was easy to implement and (most important) it works 🙂

Manfred
Users browsing this topic
    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.

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved