예제 #1
0
 /// <summary>
 /// Checks the if thread is already bookmarked.
 /// </summary>
 /// <param name="userID">User ID.</param>
 /// <param name="threadID">Thread ID.</param>
 /// <returns>true if the thread is bookmarked</returns>
 public static bool CheckIfThreadIsAlreadyBookmarked(int userID, int threadID)
 {
     var qf = new QueryFactory();
     var q = qf.Create()
                 .Select(BookmarkFields.ThreadID)
                 .Where((BookmarkFields.ThreadID == threadID).And(BookmarkFields.UserID == userID));
     var dao = new TypedListDAO();
     return dao.GetScalar<int?>(q, null) != null;
 }
예제 #2
0
        /// <summary>
        /// Gets the total number of threads in support queues. Only the count of threads which are in the forums in the list of
        /// accessable forums are returned.
        /// </summary>
        /// <param name="accessableForums">A list of accessable forums IDs, which the user has permission to access.</param>
        /// <returns>total number of threads in support queues</returns>
        public static int GetTotalNumberOfThreadsInSupportQueues(List<int> accessableForums)
        {
            // return 0, if the user does not have a valid list of forums to access
            if(accessableForums == null || accessableForums.Count <= 0)
            {
                return 0;
            }

            var qf = new QueryFactory();
            var q = qf.Create()
                        .Select(SupportQueueThreadFields.ThreadID.Count().As("NumberOfThreadsInQueues"))
                        .From(qf.SupportQueueThread.InnerJoin(qf.Thread).On(SupportQueueThreadFields.ThreadID == ThreadFields.ThreadID))
                        .Where(ThreadFields.ForumID == accessableForums);
            var dao = new TypedListDAO();
            return dao.GetScalar<int>(q, null);
        }
예제 #3
0
 /// <summary>
 /// Gets the row count for the set of threads in which the user specified participated with one or more messages for the page specified.
 /// Threads which aren't visible for the calling user are filtered out.
 /// </summary>
 /// <param name="accessableForums">A list of accessable forums IDs, which the user calling the method has permission to access.</param>
 /// <param name="participantUserID">The participant user ID of the user of which the threads have to be obtained.</param>
 /// <param name="forumsWithThreadsFromOthers">The forums with threads from others.</param>
 /// <param name="callingUserID">The calling user ID.</param>
 /// <returns>a dataView of the threads requested</returns>
 public static int GetRowCountLastThreadsForUserAsDataView(List<int> accessableForums, int participantUserID,
     List<int> forumsWithThreadsFromOthers, int callingUserID)
 {
     // return null, if the user does not have a valid list of forums to access
     if(accessableForums == null || accessableForums.Count <= 0)
     {
         return 0;
     }
     var qf = new QueryFactory();
     var q = qf.Create()
                     .Select(ThreadGuiHelper.BuildQueryProjectionForAllThreadsWithStats(qf))
                     .From(ThreadGuiHelper.BuildFromClauseForAllThreadsWithStats(qf))
                     .Where((ThreadFields.ForumID == accessableForums)
                             .And(ThreadFields.ThreadID.In(qf.Create()
                                                                 .Select(MessageFields.ThreadID)
                                                                 .Where(MessageFields.PostedByUserID == participantUserID)))
                             .And(ThreadGuiHelper.CreateThreadFilter(forumsWithThreadsFromOthers, callingUserID)));
     var dao = new TypedListDAO();
     return dao.GetScalar<int>(qf.Create().Select(Functions.CountRow()).From(q), null);
 }
예제 #4
0
		/// <summary>
		/// Checks if the message with the ID specified is first message in thread with id specified.
		/// </summary>
		/// <param name="threadID">The thread ID.</param>
		/// <param name="messageID">The message ID.</param>
		/// <returns>true if message is first message in thread, false otherwise</returns>
		public static bool CheckIfMessageIsFirstInThread(int threadID, int messageID)
		{
			// use a scalar query, which obtains the first MessageID in a given thread. We sort on posting date ascending, and simply read
			// the first messageid. If that's not available or not equal to messageID, the messageID isn't the first post in the thread, otherwise it is.
			var qf = new QueryFactory();
			var q = qf.Create()
						.Select(MessageFields.MessageID)
						.Where(MessageFields.ThreadID == threadID)
						.OrderBy(MessageFields.PostingDate.Ascending())
						.Limit(1);
			var dao = new TypedListDAO();
			var firstMessageId = dao.GetScalar<int?>(q, null);
			if(firstMessageId.HasValue)
			{
				return firstMessageId.Value == messageID;
			}
			// not found.
			return false;
		}