1
+ /* Yet Another Forum.NET
2
+ * Copyright (C) 2006-2013 Jaben Cargman
3
+ * http://www.yetanotherforum.net/
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License
7
+ * as published by the Free Software Foundation; either version 2
8
+ * of the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
+ */
19
+
20
+ namespace YAF . DotNetNuke . Components . Controllers
21
+ {
22
+ #region Using
23
+
24
+ using System ;
25
+ using System . Collections . Generic ;
26
+ using System . Data ;
27
+
28
+ using global ::DotNetNuke . Data ;
29
+ using global ::DotNetNuke . Security . Roles ;
30
+
31
+ using YAF . Classes . Data ;
32
+ using YAF . DotNetNuke . Components . Objects ;
33
+ using YAF . Types . Extensions ;
34
+ using YAF . Types . Interfaces . Data ;
35
+
36
+ #endregion
37
+
38
+ /// <summary>
39
+ /// Module Data Controller to Handle SQL Stuff
40
+ /// </summary>
41
+ public class Data
42
+ {
43
+ #region Public Methods
44
+
45
+ /// <summary>
46
+ /// Get The Latest Post from SQL
47
+ /// </summary>
48
+ /// <param name="boardId">The Board Id of the Board</param>
49
+ /// <param name="numOfPostsToRetrieve">How many post should been retrieved</param>
50
+ /// <param name="pageUserId">Current Users Id</param>
51
+ /// <param name="useStyledNicks">if set to <c>true</c> [use styled nicks].</param>
52
+ /// <param name="showNoCountPosts">if set to <c>true</c> [show no count posts].</param>
53
+ /// <param name="findLastRead">if set to <c>true</c> [find last read].</param>
54
+ /// <returns>
55
+ /// Returns the Table of Latest Posts
56
+ /// </returns>
57
+ public static DataTable TopicLatest (
58
+ object boardId ,
59
+ object numOfPostsToRetrieve ,
60
+ object pageUserId ,
61
+ bool useStyledNicks ,
62
+ bool showNoCountPosts ,
63
+ bool findLastRead = false )
64
+ {
65
+ using ( var cmd = DbHelpers . GetCommand ( "topic_latest" ) )
66
+ {
67
+ cmd . CommandType = CommandType . StoredProcedure ;
68
+ cmd . Parameters . AddWithValue ( "BoardID" , boardId ) ;
69
+ cmd . Parameters . AddWithValue ( "NumPosts" , numOfPostsToRetrieve ) ;
70
+ cmd . Parameters . AddWithValue ( "PageUserID" , pageUserId ) ;
71
+ cmd . Parameters . AddWithValue ( "StyledNicks" , useStyledNicks ) ;
72
+ cmd . Parameters . AddWithValue ( "ShowNoCountPosts" , showNoCountPosts ) ;
73
+ cmd . Parameters . AddWithValue ( "FindLastRead" , findLastRead ) ;
74
+
75
+ return LegacyDb . DbAccess . GetData ( cmd ) ;
76
+ }
77
+ }
78
+
79
+ /// <summary>
80
+ /// Add active access row for the current user outside of YAF
81
+ /// </summary>
82
+ /// <param name="boardId">The board id.</param>
83
+ /// <param name="userId">The user id.</param>
84
+ /// <param name="isGuest">if set to <c>true</c> [is guest].</param>
85
+ /// <returns>
86
+ /// Returns the Table of the Active Access User Table
87
+ /// </returns>
88
+ public static DataTable ActiveAccessUser ( object boardId , object userId , bool isGuest )
89
+ {
90
+ using ( var cmd = DbHelpers . GetCommand ( "pageaccess" ) )
91
+ {
92
+ cmd . CommandType = CommandType . StoredProcedure ;
93
+ cmd . Parameters . AddWithValue ( "BoardID" , boardId ) ;
94
+ cmd . Parameters . AddWithValue ( "UserID" , userId ) ;
95
+ cmd . Parameters . AddWithValue ( "IsGuest" , isGuest ) ;
96
+ cmd . Parameters . AddWithValue ( "UTCTIMESTAMP" , DateTime . UtcNow ) ;
97
+
98
+ return LegacyDb . DbAccess . GetData ( cmd ) ;
99
+ }
100
+ }
101
+
102
+ /// <summary>
103
+ /// Get all <see cref="Messages"/> From The Forum
104
+ /// </summary>
105
+ /// <returns>
106
+ /// Message List
107
+ /// </returns>
108
+ public static List < Messages > YafDnnGetMessages ( )
109
+ {
110
+ List < Messages > messagesList = new List < Messages > ( ) ;
111
+
112
+ using ( IDataReader dr = DataProvider . Instance ( ) . ExecuteReader ( "YafDnn_Messages" ) )
113
+ {
114
+ while ( dr . Read ( ) )
115
+ {
116
+ Messages message = new Messages
117
+ {
118
+ Message = Convert . ToString ( dr [ "Message" ] ) ,
119
+ MessageId = dr [ "MessageID" ] . ToType < int > ( ) ,
120
+ TopicId = dr [ "TopicID" ] . ToType < int > ( ) ,
121
+ Posted = Convert . ToDateTime ( dr [ "Posted" ] )
122
+ } ;
123
+
124
+ messagesList . Add ( message ) ;
125
+ }
126
+ }
127
+
128
+ return messagesList ;
129
+ }
130
+
131
+ /// <summary>
132
+ /// Get all <see cref="Messages"/> From The Forum
133
+ /// </summary>
134
+ /// <returns>
135
+ /// Topics List
136
+ /// </returns>
137
+ public static List < Topics > YafDnnGetTopics ( )
138
+ {
139
+ List < Topics > topicsList = new List < Topics > ( ) ;
140
+
141
+ using ( IDataReader dr = DataProvider . Instance ( ) . ExecuteReader ( "YafDnn_Topics" ) )
142
+ {
143
+ while ( dr . Read ( ) )
144
+ {
145
+ Topics topic = new Topics
146
+ {
147
+ TopicName = Convert . ToString ( dr [ "Topic" ] ) ,
148
+ TopicId = dr [ "TopicID" ] . ToType < int > ( ) ,
149
+ ForumId = dr [ "ForumID" ] . ToType < int > ( ) ,
150
+ Posted = Convert . ToDateTime ( dr [ "Posted" ] )
151
+ } ;
152
+
153
+ topicsList . Add ( topic ) ;
154
+ }
155
+ }
156
+
157
+ return topicsList ;
158
+ }
159
+
160
+ /// <summary>
161
+ /// Gets the YAF board roles.
162
+ /// </summary>
163
+ /// <param name="boardId">The board id.</param>
164
+ /// <returns>Returns the YAF Board Roles</returns>
165
+ public static List < RoleInfo > GetYafBoardRoles ( int boardId )
166
+ {
167
+ List < RoleInfo > roles = new List < RoleInfo > ( ) ;
168
+
169
+ using ( IDataReader dr = DataProvider . Instance ( ) . ExecuteReader ( "yaf_group_list" , boardId , null ) )
170
+ {
171
+ while ( dr . Read ( ) )
172
+ {
173
+ RoleInfo role = new RoleInfo
174
+ {
175
+ RoleName = Convert . ToString ( dr [ "Name" ] ) ,
176
+ RoleID = dr [ "GroupID" ] . ToType < int > ( ) ,
177
+ } ;
178
+
179
+ roles . Add ( role ) ;
180
+ }
181
+ }
182
+
183
+ return roles ;
184
+ }
185
+
186
+ /// <summary>
187
+ /// Gets the YAF board access masks.
188
+ /// </summary>
189
+ /// <param name="boardId">The board id.</param>
190
+ /// <returns>Returns the YAF Board access masks</returns>
191
+ public static List < RoleInfo > GetYafBoardAccessMasks ( int boardId )
192
+ {
193
+ List < RoleInfo > roles = new List < RoleInfo > ( ) ;
194
+
195
+ using ( IDataReader dr = DataProvider . Instance ( ) . ExecuteReader ( "yaf_accessmask_list" , boardId , null , 0 ) )
196
+ {
197
+ while ( dr . Read ( ) )
198
+ {
199
+ RoleInfo role = new RoleInfo
200
+ {
201
+ RoleName = Convert . ToString ( dr [ "Name" ] ) ,
202
+ RoleID = dr [ "AccessMaskID" ] . ToType < int > ( ) ,
203
+ RoleGroupID = dr [ "Flags" ] . ToType < int > ( )
204
+ } ;
205
+
206
+ roles . Add ( role ) ;
207
+ }
208
+ }
209
+
210
+ return roles ;
211
+ }
212
+
213
+ /// <summary>
214
+ /// Gets the YAF user roles.
215
+ /// </summary>
216
+ /// <param name="boardId">The board id.</param>
217
+ /// <param name="yafUserId">The YAF user id.</param>
218
+ /// <returns>Returns List of YAF user roles</returns>
219
+ public static List < RoleInfo > GetYafUserRoles ( int boardId , int yafUserId )
220
+ {
221
+ List < RoleInfo > roles = new List < RoleInfo > ( ) ;
222
+
223
+ using ( IDataReader dr = DataProvider . Instance ( ) . ExecuteReader ( "yaf_usergroup_list" , yafUserId ) )
224
+ {
225
+ while ( dr . Read ( ) )
226
+ {
227
+ RoleInfo role = new RoleInfo
228
+ {
229
+ RoleName = Convert . ToString ( dr [ "Name" ] ) ,
230
+ RoleID = dr [ "GroupID" ] . ToType < int > ( ) ,
231
+ } ;
232
+
233
+ roles . Add ( role ) ;
234
+ }
235
+ }
236
+
237
+ return roles ;
238
+ }
239
+
240
+ #endregion
241
+ }
242
+ }
0 commit comments