RichP714
  •  RichP714
  • 100% (Exalted)
  • YAF All-the-Time Topic Starter
2010-06-30T21:44:29Z
We have a 'newbie' role, that has limited access. Once a user passes X posts, we want to change their role to 'member' which adds access to a few topics.

There's no method to automate this; I want to add a column to members.ascx which shows what group the members are in.

This way, if I sort by numposts, I can view if they are in the right role, and if not, change their access.

I've tried adding (from editusersgroups.ascx)"
Quote:


<asp:Label ID="GroupID" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "GroupID") %>'></asp:Label>
<b>
<%# DataBinder.Eval(Container.DataItem, "Name") %></b></td>



but that doesn't work.

Is this possible?
Enjoy!

Running YAF 1.9.5.5 final at: http://thecarversite.com 
Sponsor
bbobb
  •  bbobb
  • 100% (Exalted)
  • YAF Developer
2010-06-30T22:20:17Z
Does it really needed?
RichP714
  •  RichP714
  • 100% (Exalted)
  • YAF All-the-Time Topic Starter
2010-06-30T23:58:39Z
It would save me alot of work; currently, I sort by posts, then enter the profile of those members that are above X, and make sure they're not in the 'newbie' broup anymore (that I'vce moved them to 'member' group)

It would save me from having to view each members profile to verify their group (it gets tedious after awhile, opening SO many profiles, when I COULD be just looking at a member list with one column showing 'group'
Enjoy!

Running YAF 1.9.5.5 final at: http://thecarversite.com 
RichP714
  •  RichP714
  • 100% (Exalted)
  • YAF All-the-Time Topic Starter
2010-07-03T05:13:31Z
I also tried adding the following as a column, oit also doesn't work (no data shows) but there's no error either.

Any ideas?

<asp:Repeater ID="Groups" runat="server">
<ItemTemplate>
<span runat="server" style ='<%# DataBinder.Eval(Container.DataItem,"Style") %>' >
<%# DataBinder.Eval(Container.DataItem,"Name") %></span>
</ItemTemplate>
<SeparatorTemplate>
,
</SeparatorTemplate>
</asp:Repeater>

Enjoy!

Running YAF 1.9.5.5 final at: http://thecarversite.com 
Kamyar
2010-07-03T13:35:55Z
Login as admin, go to Admin->Database->Run SQL Query
paste the following code inside the SQL Command section:
Create function [dbo].[yaf_user_getgroupnames]
(
@UserID INT
) returns VARCHAR(MAX)
BEGIN
	DECLARE @Output VARCHAR(MAX)
		SELECT @Output = COALESCE(@Output+', ', '') + f.Name from [dbo].[yaf_Group] f 
		inner join [dbo].[yaf_UserGroup] e on f.GroupID=e.GroupID and e.UserID = @UserID
	RETURN @Output
END
click "Run Query". You should get "No Results Returned." in the Result Section.
Now paste this code in the specified section again:
ALTER procedure [dbo].[yaf_user_list](@BoardID int,@UserID int=null,@Approved bit=null,@GroupID int=null,@RankID int=null,@StyledNicks bit = null) as
begin	
	if @UserID is not null
		 select 
			a.*,
			a.NumPosts,
			CultureUser = a.Culture,			
			b.RankID,						
			RankName = b.Name,
			Style = case(@StyledNicks)
			when 1 then  ISNULL(( SELECT TOP 1 f.Style FROM [dbo].[yaf_UserGroup] e 
			join [dbo].[yaf_Group] f on f.GroupID=e.GroupID WHERE e.UserID=a.UserID AND LEN(f.Style) > 2 ORDER BY f.SortOrder), b.Style)  
			else ''	 end, 
			NumDays = datediff(d,a.Joined,GETUTCDATE() )+1,
			NumPostsForum = (select count(1) from [dbo].[yaf_Message] x where (x.Flags & 24)=16),
			HasAvatarImage = (select count(1) from [dbo].[yaf_User] x where x.UserID=a.UserID and AvatarImage is not null),
			IsAdmin	= IsNull(c.IsAdmin,0),
			IsGuest	= IsNull(a.Flags & 4,0),
			IsHostAdmin	= IsNull(a.Flags & 1,0),
			IsForumModerator	= IsNull(c.IsForumModerator,0),
			IsModerator		= IsNull(c.IsModerator,0)
		from 
			[dbo].[yaf_User] a
			join [dbo].[yaf_Rank] b on b.RankID=a.RankID			
			left join [dbo].[yaf_vaccess] c on c.UserID=a.UserID
		where 
			a.UserID = @UserID and
			a.BoardID = @BoardID and
			IsNull(c.ForumID,0) = 0 and
			(@Approved is null or (@Approved=0 and (a.Flags & 2)=0) or (@Approved=1 and (a.Flags & 2)=2))
		order by 
			a.Name 
	else if @GroupID is null and @RankID is null
		select 
			a.*,
			a.NumPosts,
			CultureUser = a.Culture,	
			Style = case(@StyledNicks)
			when 1 then  ISNULL(( SELECT TOP 1 f.Style FROM [dbo].[yaf_UserGroup] e 
			join [dbo].[yaf_Group] f on f.GroupID=e.GroupID WHERE e.UserID=a.UserID AND LEN(f.Style) > 2 ORDER BY f.SortOrder), b.Style)  
			else ''	 end, 	
			IsAdmin = (select count(1) from [dbo].[yaf_UserGroup] x join [dbo].[yaf_Group] y on y.GroupID=x.GroupID where x.UserID=a.UserID and (y.Flags & 1)<>0),
			IsGuest	= IsNull(a.Flags & 4,0),
			IsHostAdmin	= IsNull(a.Flags & 1,0),
			b.RankID,
			RankName = b.Name,
			(dbo.yaf_user_getgroupnames (a.UserID)) as GroupNames
		from 
			[dbo].[yaf_User] a
			join [dbo].[yaf_Rank] b on b.RankID=a.RankID			
		where 
			a.BoardID = @BoardID and
			(@Approved is null or (@Approved=0 and (a.Flags & 2)=0) or (@Approved=1 and (a.Flags & 2)=2))
		order by 
			a.Name
	else
		select 
			a.*,
			a.NumPosts,
			CultureUser = a.Culture,
			IsAdmin = (select count(1) from [dbo].[yaf_UserGroup] x join [dbo].[yaf_Group] y on y.GroupID=x.GroupID where x.UserID=a.UserID and (y.Flags & 1)<>0),
			IsGuest	= IsNull(a.Flags & 4,0),
			IsHostAdmin	= IsNull(a.Flags & 1,0),
			b.RankID,
			RankName = b.Name,
			Style = case(@StyledNicks)
			when 1 then  ISNULL(( SELECT TOP 1 f.Style FROM [dbo].[yaf_UserGroup] e 
			join [dbo].[yaf_Group] f on f.GroupID=e.GroupID WHERE e.UserID=a.UserID AND LEN(f.Style) > 2 ORDER BY f.SortOrder), b.Style)  
			else ''	 end 
		from 
			[dbo].[yaf_User] a
			join [dbo].[yaf_Rank] b on b.RankID=a.RankID			
		where 
			a.BoardID = @BoardID and
			(@Approved is null or (@Approved=0 and (a.Flags & 2)=0) or (@Approved=1 and (a.Flags & 2)=2)) and
			(@GroupID is null or exists(select 1 from [dbo].[yaf_UserGroup] x where x.UserID=a.UserID and x.GroupID=@GroupID)) and
			(@RankID is null or a.RankID=@RankID)
		order by 
			a.Name
end
You should get "No Results Returned." in the Result Section again.
Now download the attached file, unrar and overwrite the users.ascx file in YAF Root\Pages\Admin\users.ascx with the file I have provided. Compile the solution and hopefully, you're good to go. goto Admin->Users And Roles->Users and click search. You should see all the group names users are registered to under the Roles tab.
Please note that I have used "dbo" as {databaseOwner} and "yaf" as {objectQualifier} in db queries. If yours are different, please change the " [dbo].[yaf_ " parts to the ones that suits you.
Also, for convenience I have provided the queries in 2 text files in the attached file as well.
File Attachment(s):
UserGroups.rar (3kb) downloaded 38 time(s).

If at first you don’t succeed, call it version 1.0
RichP714
  •  RichP714
  • 100% (Exalted)
  • YAF All-the-Time Topic Starter
2010-07-03T20:34:40Z
Many thanks for going out of your way to help me; this will save me quite a bit of time!
Enjoy!

Running YAF 1.9.5.5 final at: http://thecarversite.com 

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