Example #1
0
        // *********************************************************************
        //  GetAllUsers
        //
        /// <summary>
        /// Returns all the users currently in the system.
        /// </summary>
        /// <param name="pageIndex">Page position in which to return user's for, e.g. position of result set</param>
        /// <param name="pageSize">Size of a given page, e.g. size of result set.</param>
        /// <param name="sortBy">How the returned user's are to be sorted.</param>
        /// <param name="sortOrder">Direction in which to sort</param>
        /// <returns>A collection of user.</returns>
        /// 
        // ********************************************************************/
        public static UserCollection GetAllUsers( int pageIndex, int pageSize )
        {
            UserCollection users, users1;
            users = new UserCollection();
            users1 = new UserCollection();
            Person[] us = UserList.GetUserList();
            string[] un = new string[ us.Length ];
            for( int i = 0; i < us.Length; i++ )
            {
                un[ i ] = us[ i ].LastName.ToString();
            }

            Array.Sort( un, us );

            foreach( Person u in us )
            {
                User usr = new User();
                usr.DisplayName = u.FullName;
                usr.Username = u.ID.ToString();
                users.Add( usr );
            }
            users1.AddRange( users.GetRange( pageIndex * pageSize, Math.Min( pageSize, users.Count - pageIndex * pageSize ) ) );

            return users1;
        }
Example #2
0
        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// This event handler adds the children controls and is resonsible
        /// for determining the template type used for the control.
        /// </summary>
        /// 
        // ********************************************************************/
        protected override void CreateChildControls()
        {
            // Do we have a user?
            if (HttpContext.Current.Request.IsAuthenticated)
            {
                user = Users.GetLoggedOnUser();
            }

            skinName = Globals.Skin;

            // Apply Template
            ApplyTemplates();

            // Viewstate is disabled
            EnableViewState = false;
        }
Example #3
0
        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// This event handler adds the children controls and is resonsible
        /// for determining the template type used for the control.
        /// </summary>
        /// 
        // ********************************************************************/
        protected override void CreateChildControls()
        {
            // Do we have a user?
            if (Page.Request.IsAuthenticated)
            {
                user = Users.GetLoggedOnUser();
            }
            // Set the siteStyle for the page
            skinName = Globals.Skin;

            // Viewstate is disabled
            this.EnableViewState = false;

            // Apply Template
            ApplyTemplates();
        }
        // *********************************************************************
        //  SkinnedForumWebControl
        //
        /// <summary>
        /// Constructor
        /// </summary>
        // ***********************************************************************/
        public SkinnedForumWebControl()
        {
            // Attempt to get the current user
            user = Users.GetLoggedOnUser();

            // Set the siteStyle for the page
                skinName = Globals.Skin;

            // If we have an instance of context, let's attempt to
            // get the ForumID so we can save the user from writing
            // the code
            if (null != Context) {
                GetPostIDFromRequest();
                GetForumIDFromRequest();
                GetReturnURLFromRequest();
            }
        }
Example #5
0
        // *********************************************************************
        //  ForumRepeaterControl
        //
        /// <summary>
        /// Constructor
        /// </summary>
        // ***********************************************************************/
        public ForumRepeaterControl()
        {
            // If we're in design-time we simply return
            if (null == HttpContext.Current)
                return;

            // Attempt to get the current user
            user = Users.GetLoggedOnUser();

            // Set the siteStyle for the page
            skinName = Globals.Skin;

            // If we have an instance of context, let's attempt to
            // get the ForumID so we can save the user from writing
            // the code
            if (null != Context) {
                GetPostIDFromRequest();
                GetForumIDFromRequest();
            }
        }
Example #6
0
        // *********************************************************************
        //  GetUserInfo
        //
        /// <summary>
        /// Вернуть информацию о конкретном форуме.
        /// </summary>
        /// <param name="username">The user whose information you are interested in.</param>
        /// <param name="updateIsOnline">Updates user's online datetime stamp.</param>
        /// <returns>Instance of User with details about a given forum user.</returns>
        /// <remarks>
        /// If the specified user is not found, a UserNotFoundException exception is thrown. Feel
        /// free to call this multiple times during the request as the value is stored in Context once
        /// read from the data source.
        /// </remarks>
        // ***********************************************************************/
        public static User GetUserInfo( String username )
        {
            User user = new User();
            UlterSystems.PortalLib.BusinessObjects.Person UlterUser = new UlterSystems.PortalLib.BusinessObjects.Person();
            UlterUser.Load( Int32.Parse( username ) );
            user.Username = username;
            user.DisplayName = UlterUser.FirstName.ToString() + "&nbsp;" + UlterUser.LastName.ToString();
            user.IsApproved = !UlterUser.IsInRole( "ForumBannedUser" );
            user.IsAdministrator = UlterUser.IsInRole( "ForumAdministrator" );

            return user;
        }
Example #7
0
 // *********************************************************************
 //  ValidUser
 //
 /// <summary>
 /// Determines if the user is a valid user.
 /// </summary>
 /// <param name="user">The user to check.  Note that the Username and Password properties of the
 /// User object must be set.</param>
 /// <returns>A boolean: true if the user's Username/password are valid; false if they are not,
 /// or if the user has been banned.</returns>
 /// 
 // ********************************************************************/
 public static bool ValidUser( User user )
 {
     // Create Instance of the IDataProviderBase
     if( DBManager.GetInternetUsersCount( user.Username, user.Password ) == 1 )
         return true;
     else
         return false;
 }
Example #8
0
        // *********************************************************************
        //  UpdateUserInfoFromAdminPage
        //
        /// <summary>
        /// Updates a user's system-level information.
        /// </summary>
        /// <param name="user">A user object containing information to be updated.  The Username
        /// property specifies what user should be updated.</param>
        /// <remarks>This method updates a user's system-level information: their approved status, their
        /// trusted status, etc.  To update a user's personal information (such as their password,
        /// signature, homepage Url, etc.), use the UpdateUserInfo method.  <seealso cref="UpdateUserInfo"/></remarks>
        /// 
        // ********************************************************************/
        public static void UpdateUserInfoFromAdminPage( User user )
        {
            Role bannedUsersRole = Role.GetRole( "ForumBannedUser" );
            if( bannedUsersRole == null )
                throw new InvalidOperationException( string.Format( "Can't get ForumBannedUser role." ) );

            if( !( user.IsApproved ) && GetUserInfo( user.Username ).IsApproved )
            {
                //banning
                bannedUsersRole.AddUser( Int32.Parse( user.Username ) );
            }
            else if( ( user.IsApproved ) && !GetUserInfo( user.Username ).IsApproved )
            {
                //unbanning
                bannedUsersRole.RemoveUser( Int32.Parse( user.Username ) );
            }
        }
Example #9
0
        /***********************************************************************
        // CreateChildControls
        //
        /// <summary>
        /// Create the child controls of this control
        /// </summary>
        ***********************************************************************/
        protected override void CreateChildControls()
        {
            _defaultPostNewMessageText = HttpContext.GetLocalResourceObject(Globals.SkinsDir + "CreateEditPost", "_defaultPostNewMessageText").ToString();
            _defaultEditMessageText = HttpContext.GetLocalResourceObject(Globals.SkinsDir + "CreateEditPost", "_defaultEditMessageText").ToString();
            _defaultReplyToMessageText = HttpContext.GetLocalResourceObject(Globals.SkinsDir + "CreateEditPost", "_defaultReplyToMessageText").ToString();
            _defaultPreviewMessageText = HttpContext.GetLocalResourceObject(Globals.SkinsDir + "CreateEditPost", "_defaultPreviewMessageText").ToString();

            // Create an instance of the user control used to format the display
            Control postForm;

            // Get the current user
            user = Users.GetLoggedOnUser();

            if (!user.IsApproved && !user.IsAdministrator)
            {
                HttpContext.Current.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.ProblemPosting));
                HttpContext.Current.Response.End();
            }

            // Attempt to load the control. If this fails, we're done
            try
            {
                postForm = Page.LoadControl(Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + Globals.Skin + "/Skins/Skin-Post.ascx");
            }
            catch (FileNotFoundException)
            {
                throw new Exception("The user control skins/Skins/Skin-Post.ascx was not found. Please ensure this file exists in your skins directory");
            }

            // Set the ID
            postForm.ID = "PostForm";

            // Optionally display reply, post, and preview
            if (Mode != CreateEditPostMode.EditPost)
            {
                DisplayReply(postForm);
                DisplayPost(postForm);
                DisplayPreview(postForm);
            }
            else
            {
                DisplayEdit(postForm);
                DisplayPreview(postForm);
            }

            // All done. Add the control to the control collection
            Controls.Add(postForm);
        }
Example #10
0
        // *********************************************************************
        //  HandleDataBindingForAuthorDetails
        //
        /// <summary>
        /// Databinds the name of the author.
        /// </summary>
        /// <remarks>
        /// Used only if a user defined template is not provided.
        /// </remarks>
        /// 
        // ********************************************************************/
        private void HandleDataBindingForAuthorDetails(Object sender, EventArgs e)
        {
            TableCell userInfo = (TableCell)sender;
            DataListItem container = (DataListItem)userInfo.NamingContainer;
            Post post = (Post)container.DataItem;
            User user;
            Image image = new Image();

            // Get the user object - note, we are using
            // the cache under the covers, so this doesn't
            // result in a db lookup for each request
            user = Users.GetUserInfo(post.Username);

            // Build user info table
            Table table = new Table();

            // Add table to placeholder
            userInfo.Controls.Add(table);
        }
Example #11
0
        /// <summary>
        /// Builds and returns an instance of the User class based on the current row of an
        /// aptly populated SqlDataReader object.
        /// </summary>
        /// <param name="dr">The SqlDataReader object that contains, at minimum, the following
        /// columns: Signature, Email, FakeEmail, Url, Password, Username, Administrator,
        /// Trusted, Timezone, DateCreated, LastLogin, and ForumView.</param>
        /// <returns>An instance of the User class that represents the current row of the passed 
        /// in SqlDataReader, dr.</returns>
        private User PopulateUserFromSqlDataReader(SqlDataReader dr)
        {
            User user = new User();
            user.Username = Convert.ToString(dr["UserID"]);

            UlterSystems.PortalLib.BusinessObjects.Person uss = new UlterSystems.PortalLib.BusinessObjects.Person();
            //uss.LoadByDomainName(user.Username);
            uss.Load(Int32.Parse(user.Username));
            user.DisplayName = uss.FullName;
                user.IsApproved = !uss.IsInRole( "ForumBannedUser" );
                user.IsAdministrator = uss.IsInRole( "ForumAdministrator" );
            try
            {

                //user.IsApproved = !Convert.ToBoolean(dr["IsBanned"]); ;

                //user.IsModerator = Convert.ToBoolean(dr["IsForumAdmin"]);
            }
            catch (IndexOutOfRangeException)
            {
                return user;
            }

            return user;
        }
Example #12
0
        /// <summary>
        /// Retrieves information about a particular user.
        /// </summary>
        /// <param name="Username">The name of the User whose information you are interested in.</param>
        /// <returns>A User object.</returns>
        /// <remarks>If a Username is passed in that is NOT found in the database, a UserNotFoundException
        /// exception is thrown.</remarks>
        public User GetUserInfo(String username, bool updateIsOnline)
        {
            // Create Instance of Connection and Command Object
            SqlConnection myConnection = new SqlConnection(Globals.DatabaseConnectionString);
            SqlCommand myCommand = new SqlCommand("dbo.forums_GetUserInfo", myConnection);
            SqlParameter param;

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            // Add Parameters to SPROC
            //param = new SqlParameter("@UserName", SqlDbType.NVarChar, 50);
            //param.Value = username;
            //myCommand.Parameters.Add(param);
            myCommand.Parameters.Add("@UserID", SqlDbType.Int).Value = int.Parse(username);

            // Add Parameters to SPROC
            param = new SqlParameter("@UpdateIsOnline", SqlDbType.Bit);
            param.Value = updateIsOnline;
            myCommand.Parameters.Add(param);

            // Execute the command
            myConnection.Open();
            SqlDataReader dr = myCommand.ExecuteReader();
            User us = new User();
            if (!dr.Read())
            {

                // we didn't get a user, handle it
                throw new Components.UserNotFoundException("User not found for Username " + username);
            }
            else
            {

                us = PopulateUserFromSqlDataReader(dr);

                //locGreetings.Text = String.Format(locGreetings.Text, curUser.FullName);

                dr.Close();
                myConnection.Close();
            }

            return us;
        }
Example #13
0
        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// This event handler adds the children controls. FIrst we apply templates
        /// for this control. We then determine how we render the post items, either threaded
        /// or flat. We also apply templates defined for each of the post item types.
        /// </summary>
        /// 
        // ********************************************************************/
        protected override void CreateChildControls()
        {
            // Attempt to get the user name
            if (Page.Request.IsAuthenticated)
            {
                user = Users.GetLoggedOnUser();
            }

            // Set the siteStyle for the page
            skinName = Globals.Skin;

            // Set the view mode
            SetViewMode();

            // Call CreateChildControls
            base.CreateChildControls();
        }