Beispiel #1
0
        /// <summary>
        /// Handles page load event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // this needs to be done just once, not during postbacks
            if (this.IsPostBack)
            {
                return;
            }

            // create page links
            this.CreatePageLinks();

            this.Save.Text = this.GetText("COMMON", "SAVE");
            this.Cancel.Text = this.GetText("COMMON", "CANCEL");


            // bind data
            this.BindData();
            // is this editing of existing role or creation of new one?
            if (this.Request.QueryString.GetFirstOrDefault("i") == null)
            {
                return;
            }

            // we are not creating new role
            this.NewGroupRow.Visible = false;

            // get data about edited role
            using (
                DataTable dt = LegacyDb.group_list(this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("i")))
            {
                // get it as row
                DataRow row = dt.Rows[0];

                // get role flags
                var flags = new GroupFlags(row["Flags"]);

                // set controls to role values
                this.Name.Text = (string)row["Name"];

                this.IsAdminX.Checked = flags.IsAdmin;
                this.IsAdminX.Enabled = !flags.IsGuest;

                this.IsStartX.Checked = flags.IsStart;
                this.IsStartX.Enabled = !flags.IsGuest;

                this.IsModeratorX.Checked = flags.IsModerator;
                this.IsModeratorX.Enabled = !flags.IsGuest;

                this.PMLimit.Text = row["PMLimit"].ToString();
                this.PMLimit.Enabled = !flags.IsGuest;

                this.StyleTextBox.Text = row["Style"].ToString();

                this.Priority.Text = row["SortOrder"].ToString();

                this.UsrAlbums.Text = row["UsrAlbums"].ToString();
                this.UsrAlbums.Enabled = !flags.IsGuest;

                this.UsrAlbumImages.Text = row["UsrAlbumImages"].ToString();
                this.UsrAlbumImages.Enabled = !flags.IsGuest;

                this.UsrSigChars.Text = row["UsrSigChars"].ToString();
                this.UsrSigChars.Enabled = !flags.IsGuest;

                this.UsrSigBBCodes.Text = row["UsrSigBBCodes"].ToString();
                this.UsrSigBBCodes.Enabled = !flags.IsGuest;

                this.UsrSigHTMLTags.Text = row["UsrSigHTMLTags"].ToString();
                this.UsrSigHTMLTags.Enabled = !flags.IsGuest;

                this.Description.Text = row["Description"].ToString();

                this.IsGuestX.Checked = flags.IsGuest;

                // IsGuest flag can be set for only one role. if it isn't for this, disable that row
                if (flags.IsGuest)
                {
                    this.IsGuestTR.Visible = true;
                    this.IsGuestX.Enabled = !flags.IsGuest;
                    this.AccessList.Visible = false;
                }

            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles page load event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // this needs to be done just once, not during postbacks
            if (this.IsPostBack)
            {
                return;
            }

            // A new group case
            if (PageContext.PersonalGroupsNumber >= PageContext.UsrPersonalGroups && this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("i") == null)
            {
                YafBuildLink.AccessDenied();
            }

            // the calling user is not the owner
            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u") == null || this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u").ToType<int>() != PageContext.PageUserID)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("i") != null)
            {
                if (!ValidationHelper.IsValidInt(this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("i")))
                {
                    YafBuildLink.AccessDenied();
                }

                DataTable dt = CommonDb.group_byuserlist(
                    PageContext.PageModuleID,
                    PageContext.PageBoardID,
                    this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("i").ToType<int>(),
                    this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("u").ToType<int>(),
                    true);
                
                if (dt != null && dt.Rows.Count > 0)
                {
                }
                else
                {
                    YafBuildLink.AccessDenied();
                }
            }

            // create page links
            this.CreatePageLinks();

            // bind data
            this.BindData();

            // is this editing of existing role or creation of new one?
            if (this.Request.QueryString.GetFirstOrDefault("i") == null)
            {
                return;
            }

            // we are not creating new role
            this.NewGroupRow.Visible = false;

            // get data about edited role
            using (
                DataTable dt = CommonDb.group_byuserlist(PageContext.PageModuleID, this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("i"), PageContext.PageUserID, true))
            {
                // get it as row
                DataRow row = dt.Rows[0];

                // get role flags
                var flags = new GroupFlags(row["Flags"]);
                this.IsHiddenX.Checked = flags.IsHidden;

                // this.IsHiddenX.Enabled = !flags.IsGuest;
                // set controls to role values
                this.Name.Text = (string)row["Name"];
                this.StyleTextBox.Text = row["Style"].ToString();
                this.Priority.Text = row["SortOrder"].ToString();
                this.Description.Text = row["Description"].ToString();
                this.PersonalGroupsNumber = row["UsrPersonalGroups"].ToType<int>();
                this.PersonalForumsNumber = row["UsrPersonalForums"].ToType<int>();
                this.PersonalAccessMasksNumber = row["UsrPersonalMasks"].ToType<int>();
            }
        }
        /// <summary>
        /// Sets up the user roles from the "start" settings for a given group/role
        /// </summary>
        /// <param name="pageBoardID">
        /// Current BoardID
        /// </param>
        /// <param name="userName">
        /// </param>
        public static void SetupUserRoles(int pageBoardID, [NotNull] string userName)
        {
            using (DataTable dt = LegacyDb.group_list(pageBoardID, DBNull.Value))
            {
                foreach (DataRow row in dt.Rows)
                {
                    var roleFlags = new GroupFlags(row["Flags"]);

                    // see if the "Is Start" flag is set for this group and NOT the "Is Guest" flag (those roles aren't synced)
                    if (roleFlags.IsStart && !roleFlags.IsGuest)
                    {
                        // add the user to this role in membership
                        string roleName = row["Name"].ToString();

                        if (roleName.IsSet())
                        {
                            AddUserToRole(userName, roleName);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Syncs the ASP.NET roles with YAF group based on YAF (not bi-directional)
        /// </summary>
        /// <param name="pageBoardID">
        /// </param>
        public static void SyncRoles(int pageBoardID)
        {
            // get all the groups in YAF DB and create them if they do not exist as a role in membership
            using (DataTable dt = LegacyDb.group_list(pageBoardID, DBNull.Value))
            {
                foreach (DataRow row in dt.Rows)
                {
                    var name = (string)row["Name"];
                    var roleFlags = new GroupFlags(row["Flags"]);

                    // testing if this role is a "Guest" role...
                    // if it is, we aren't syncing it.
                    if (name.IsSet() && !roleFlags.IsGuest && !RoleExists(name))
                    {
                        CreateRole(name);
                    }
                }

                /* get all the roles and create them in the YAF DB if they do not exist
                foreach ( string role in Roles.GetAllRoles() )
                {
                    int nGroupID = 0;
                    string filter = string.Format( "Name='{0}'", role );
                    DataRow [] rows = dt.Select( filter );

                    if ( rows.Length == 0 )
                    {
                    // sets new roles to default "Read Only" access
                    nGroupID = ( int ) YAF.Classes.Data.DB.group_save( DBNull.Value, pageBoardID, role, false, false, false, false, 1 );
                    }
                    else
                    {
                    nGroupID = ( int ) rows [0] ["GroupID"];
                    }
                }
                        */
            }
        }
Beispiel #5
0
        /// <summary>
        /// Handles page load event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            // this needs to be done just once, not during postbacks
            if (this.IsPostBack)
            {
                return;
            }

            // create page links
            this.CreatePageLinks();

            this.Save.Text = this.GetText("COMMON", "SAVE");
            this.Cancel.Text = this.GetText("COMMON", "CANCEL");

            if (Config.LargeForumTree && this.Request.QueryString.GetFirstOrDefault("i") != null)
            {
                string args = "&links=1";
                int? groupId = null;
                if (this.Request.QueryString.GetFirstOrDefault("i") !=null)
                {
                    groupId = this.Request.QueryString.GetFirstOrDefault("i").ToType<int>();
                    args = args + "&amdd={0}".FormatWith(groupId);
                }

                this.treeRow.Visible = true;
                YafContext.Current.PageElements.RegisterJQueryUI();
                YafContext.Current.PageElements.RegisterJsResourceInclude("fancytree", "js/jquery.fancytree-all.min.js");
                YafContext.Current.PageElements.RegisterCssIncludeResource("css/fancytree/{0}/ui.fancytree.css".FormatWith(YafContext.Current.Get<YafBoardSettings>().FancyTreeTheme));
                YafContext.Current.PageElements.RegisterJsResourceInclude("ftreeeditgroupjs",
                   "js/fancytree.vzf.nodesadminsetgroupaccess.js");

                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "fancytreeeditgroupscr",
                     "fancyTreeSetNodesGroupAccessLazyJS('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');"
                        .FormatWith(
                        Config.JQueryAlias,
                        "treegroupaccess",
                        PageContext.PageUserID,
                        PageContext.PageBoardID,
                        groupId,                                        
                        args,
                        string.Empty,
                        "{0}resource.ashx?".FormatWith(YafForumInfo.ForumClientFileRoot),
                        "&forumUrl={0}".FormatWith(HttpUtility.UrlDecode(YafBuildLink.GetBasePath()))));
            }

            // bind data
            this.BindData();
            // is this editing of existing role or creation of new one?
            if (this.Request.QueryString.GetFirstOrDefault("i") == null)
            {
                return;
            }

            // we are not creating new role
            this.NewGroupRow.Visible = false;

            // get data about edited role
            using (
                DataTable dt = CommonDb.group_list(this.PageContext.PageModuleID, this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("i"), 0, 1000000))
            {
                // get it as row
                DataRow row = dt.Rows[0];

                // get role flags
                var flags = new GroupFlags(row["Flags"]);

                // set controls to role values
                this.Name.Text = (string)row["Name"];

                this.IsAdminX.Checked = flags.IsAdmin;
                this.IsAdminX.Enabled = !flags.IsGuest;

                this.IsStartX.Checked = flags.IsStart;
                this.IsStartX.Enabled = !flags.IsGuest;

                this.IsModeratorX.Checked = flags.IsModerator;
                this.IsModeratorX.Enabled = !flags.IsGuest;

                this.IsHiddenX.Checked = flags.IsHidden;
                // this.IsHiddenX.Enabled = !flags.IsGuest;

                this.PMLimit.Text = row["PMLimit"].ToString();
                this.PMLimit.Enabled = !flags.IsGuest;

                this.StyleTextBox.Text = row["Style"].ToString();

                this.Priority.Text = row["SortOrder"].ToString();

                this.UsrAlbums.Text = row["UsrAlbums"].ToString();
                this.UsrAlbums.Enabled = !flags.IsGuest;

                this.UsrAlbumImages.Text = row["UsrAlbumImages"].ToString();
                this.UsrAlbumImages.Enabled = !flags.IsGuest;

                this.UsrSigChars.Text = row["UsrSigChars"].ToString();
                this.UsrSigChars.Enabled = !flags.IsGuest;

                this.UsrSigBBCodes.Text = row["UsrSigBBCodes"].ToString();
                this.UsrSigBBCodes.Enabled = !flags.IsGuest;

                this.UsrSigHTMLTags.Text = row["UsrSigHTMLTags"].ToString();
                this.UsrSigHTMLTags.Enabled = !flags.IsGuest;

                this.PersonalGroupsNumber.Text = row["UsrPersonalGroups"].ToString();
                this.PersonalGroupsNumber.Enabled = !flags.IsGuest;

                this.PersonalForumsNumber.Text = row["UsrPersonalForums"].ToString();
                this.PersonalForumsNumber.Enabled = !flags.IsGuest;

                this.PersonalAccessMasksNumber.Text = row["UsrPersonalMasks"].ToString();
                this.PersonalAccessMasksNumber.Enabled = !flags.IsGuest;

               // this.UserNickStyleEditor.Styles = row["Style"].ToString();

                this.Description.Text = row["Description"].ToString();

                this.IsGuestX.Checked = flags.IsGuest;

                // IsGuest flag can be set for only one role. if it isn't for this, disable that row
                if (flags.IsGuest)
                {
                    this.IsGuestTR.Visible = true;
                    this.IsGuestX.Enabled = !flags.IsGuest;
                    this.AccessList.Visible = false;
                }

            }
        }