Ejemplo n.º 1
0
        public void GivenThereIsAPageCalled(string pageName, Table permissions)
        {
            var reset = false;
            var tabController = new TabController();
            var tab = tabController.GetTabByName(pageName, PortalId);
            if (tab == null)
            {
                tab = new TabInfo
                {
                    TabName = pageName,
                    PortalID = 0
                };
                tab.TabID = tabController.AddTab(tab);
                foreach (var row in permissions.Rows)
                {
                    var roleId = -1;
                    var roleController = new RoleController();
                    if (row[0] == "All Users")
                    {
                        roleId = -1;
                    }
                    else
                    {
                        var role = roleController.GetRoleByName(PortalId, row[0]);
                        if (role == null)
                        {
                            if (roleController.GetRoleByName(Null.NullInteger, row[0]) == null)
                            {
                                role = new RoleInfo { RoleName = row[0], RoleGroupID = Null.NullInteger };
                                roleId = roleController.AddRole(role);
                            }
                        }
                    }
                    var permissionController = new PermissionController();
                    var permission = permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", row[1]);
                    var tabPermission = new TabPermissionInfo
                    {
                        PermissionID = 3,
                        TabID = tab.TabID,
                        AllowAccess = true,
                        RoleID = roleId
                    };
                    tab.TabPermissions.Add(tabPermission);
                }

                tabController.UpdateTab(tab);
                reset = true;
            }
            Page = tab;
            if (reset)
            {
                Config.Touch();
            }
        }
    static public AP_StaffBroker_Staff CreateStaffMember(int PortalId, DotNetNuke.Entities.Users.UserInfo User1in, DotNetNuke.Entities.Users.UserInfo User2in, short staffTypeIn)
    {
        //Create Married Staff


        DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
        if (rc.GetRoleByName(PortalId, "Staff") == null)
        {
            DotNetNuke.Security.Roles.RoleInfo insert = new DotNetNuke.Security.Roles.RoleInfo();
            insert.Description    = "Staff Members";
            insert.RoleName       = "Staff";
            insert.AutoAssignment = false;
            insert.IsPublic       = false;
            insert.RoleGroupID    = -1;
            insert.PortalID       = PortalId;
            rc.AddRole(insert);
        }

        rc.AddUserRole(PortalId, User1in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);
        rc.AddUserRole(PortalId, User2in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);



        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var searchStaff          = from c in d.AP_StaffBroker_Staffs where c.Active && (c.UserId1 == User1in.UserID || c.UserId2 == User1in.UserID || c.UserId1 == User2in.UserID || c.UserId2 == User2in.UserID) select c;

        if (searchStaff.Count() > 0)
        {
            return(searchStaff.First());
        }



        AP_StaffBroker_Staff rtn = new AP_StaffBroker_Staff();

        rtn.UserId1     = User1in.UserID;
        rtn.UserId2     = User2in.UserID;
        rtn.PortalId    = PortalId;
        rtn.Active      = true;
        rtn.DisplayName = User1in.FirstName + " & " + User2in.FirstName + " " + User1in.LastName;

        rtn.StaffTypeId = staffTypeIn;
        rtn.CostCenter  = "";

        d.AP_StaffBroker_Staffs.InsertOnSubmit(rtn);
        d.SubmitChanges();



        return(rtn);
    }
Ejemplo n.º 3
0
        public HttpResponseMessage EditRole(NewRoleDTO roleName)
        {
            try
            {
                if ((roleName.RoleId != -1))
                {
                    _roleID = roleName.RoleId;
                }
                DotNetNuke.Security.Roles.RoleController oDnnRoleController = new DotNetNuke.Security.Roles.RoleController();
                RoleInfo oRole = new RoleInfo();
                oRole.PortalID       = PortalSettings.PortalId;
                oRole.RoleName       = roleName.Name;
                oRole.IsPublic       = false;
                oRole.Status         = RoleStatus.Approved;
                oRole.AutoAssignment = false;
                oRole.RoleGroupID    = roleName.RoleGroup;
                oRole.Status         = (RoleStatus)roleName.Status;
                oRole.Description    = "";
                oRole.IsSystemRole   = false;


                if (_roleID == -1)
                {
                    var rolename = oRole.RoleName.ToUpper();
                    if (DotNetNuke.Security.Roles.RoleController.Instance.GetRole(oRole.PortalID,
                                                                                  r => rolename.Equals(r.RoleName, StringComparison.InvariantCultureIgnoreCase)) == null)
                    {
                        oDnnRoleController.AddRole(oRole);
                    }
                }
                else
                {
                    oRole.RoleID = roleName.RoleId;
                    DotNetNuke.Security.Roles.RoleController.Instance.UpdateRole(oRole);
                }
                DataCache.ClearCache();
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the update Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// 	[jlucarino]	2/23/2009	Added CreatedByUserID and LastModifiedByUserID
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    float sglServiceFee = 0;
                    var intBillingPeriod = 1;
                    var strBillingFrequency = "N";

                    if (cboBillingFrequency.SelectedItem.Value == "N" && !String.IsNullOrEmpty(txtServiceFee.Text))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("IncompatibleFee", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                    if (!String.IsNullOrEmpty(txtServiceFee.Text) && !String.IsNullOrEmpty(txtBillingPeriod.Text) && cboBillingFrequency.SelectedItem.Value != "N")
                    {
                        sglServiceFee = float.Parse(txtServiceFee.Text);
                        intBillingPeriod = int.Parse(txtBillingPeriod.Text);
                        strBillingFrequency = cboBillingFrequency.SelectedItem.Value;
                    }
                    float sglTrialFee = 0;
                    var intTrialPeriod = 1;
                    var strTrialFrequency = "N";

                    if (sglServiceFee != 0 && !String.IsNullOrEmpty(txtTrialFee.Text) && !String.IsNullOrEmpty(txtTrialPeriod.Text) && cboTrialFrequency.SelectedItem.Value != "N")
                    {
                        sglTrialFee = float.Parse(txtTrialFee.Text);
                        intTrialPeriod = int.Parse(txtTrialPeriod.Text);
                        strTrialFrequency = cboTrialFrequency.SelectedItem.Value;
                    }
                    var objRoleController = new RoleController();
                    var objRoleInfo = new RoleInfo();
                    objRoleInfo.PortalID = PortalId;
                    objRoleInfo.RoleID = _roleID;
                    objRoleInfo.RoleGroupID = int.Parse(cboRoleGroups.SelectedValue);
                    objRoleInfo.RoleName = txtRoleName.Text;
                    objRoleInfo.Description = txtDescription.Text;
                    objRoleInfo.ServiceFee = sglServiceFee;
                    objRoleInfo.BillingPeriod = intBillingPeriod;
                    objRoleInfo.BillingFrequency = strBillingFrequency;
                    objRoleInfo.TrialFee = sglTrialFee;
                    objRoleInfo.TrialPeriod = intTrialPeriod;
                    objRoleInfo.TrialFrequency = strTrialFrequency;
                    objRoleInfo.IsPublic = chkIsPublic.Checked;
                    objRoleInfo.AutoAssignment = chkAutoAssignment.Checked;
                    objRoleInfo.RSVPCode = txtRSVPCode.Text;
                    objRoleInfo.IconFile = ctlIcon.Url;
                    if (_roleID == -1)
                    {
                        if (objRoleController.GetRoleByName(PortalId, objRoleInfo.RoleName) == null)
                        {
                            objRoleController.AddRole(objRoleInfo);
                        }
                        else
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateRole", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                    }
                    else
                    {
                        objRoleController.UpdateRole(objRoleInfo);
                    }
					
                    //Clear Roles Cache
                    DataCache.RemoveCache("GetRoles");

                    Response.Redirect(Globals.NavigateURL());
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 5
0
        private int CreateRole( int PortalId, string roleName, string description, float serviceFee, int billingPeriod, string billingFrequency, float trialFee, int trialPeriod, string trialFrequency, bool isPublic, bool isAuto )
        {
            RoleInfo objRoleInfo = new RoleInfo();
            RoleController objRoleController = new RoleController();
            int RoleId = 0;

            //First check if the role exists
            objRoleInfo = objRoleController.GetRoleByName( PortalId, roleName );

            if( objRoleInfo == null )
            {
                objRoleInfo = new RoleInfo();
                objRoleInfo.PortalID = PortalId;
                objRoleInfo.RoleName = roleName;
                objRoleInfo.RoleGroupID = Null.NullInteger;
                objRoleInfo.Description = description;
                objRoleInfo.ServiceFee = Convert.ToSingle( ( ( serviceFee < 0 ) ? 0 : serviceFee ) );
                objRoleInfo.BillingPeriod = billingPeriod;
                objRoleInfo.BillingFrequency = billingFrequency;
                objRoleInfo.TrialFee = Convert.ToSingle( ( ( trialFee < 0 ) ? 0 : trialFee ) );
                objRoleInfo.TrialPeriod = trialPeriod;
                objRoleInfo.TrialFrequency = trialFrequency;
                objRoleInfo.IsPublic = isPublic;
                objRoleInfo.AutoAssignment = isAuto;
                RoleId = objRoleController.AddRole( objRoleInfo );
            }
            else
            {
                RoleId = objRoleInfo.RoleID;
            }

            return RoleId;
        }
    public static AP_StaffBroker_Staff CreateStaffMember(int PortalId, DotNetNuke.Entities.Users.UserInfo User1in, string SpouseName, DateTime SpouseDOB, short staffTypeIn = 1)
    {
        DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
        if (rc.GetRoleByName(PortalId, "Staff") == null)
        {
            DotNetNuke.Security.Roles.RoleInfo insert = new DotNetNuke.Security.Roles.RoleInfo();
            insert.Description = "Staff Members";
            insert.RoleName = "Staff";
            insert.AutoAssignment = false;
            insert.IsPublic = false;
            insert.RoleGroupID = -1;
            insert.PortalID = PortalId;
            rc.AddRole(insert);
        }

        rc.AddUserRole(PortalId, User1in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);

        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var searchStaff = from c in d.AP_StaffBroker_Staffs where c.Active && (c.UserId1 == User1in.UserID || c.UserId2 == User1in.UserID) select c;
        if (searchStaff.Count() > 0)
            return searchStaff.First();
        //Create Married to Non-Staff
        AP_StaffBroker_Staff rtn = new AP_StaffBroker_Staff();
        rtn.UserId1 = User1in.UserID;
        rtn.UserId2 = -1;
        rtn.DisplayName = User1in.FirstName + " " + User1in.LastName;

        rtn.StaffTypeId = staffTypeIn;
        rtn.CostCenter = "";
        rtn.PortalId = PortalId;
        rtn.Active = true;
        d.AP_StaffBroker_Staffs.InsertOnSubmit(rtn);
        d.SubmitChanges();
        //Now add Spouse data
        AddProfileValue(PortalId, rtn.StaffId, "SpouseDOB", SpouseDOB.ToShortDateString());
        AddProfileValue(PortalId, rtn.StaffId, "SpouseName", SpouseName);

        return rtn;
    }
        public HttpResponseMessage EditRole(NewRoleDTO roleName)
        {
            try
            {
                if ((roleName.RoleId != -1))
                {
                    _roleID = roleName.RoleId;
                }
                DotNetNuke.Security.Roles.RoleController oDnnRoleController = new DotNetNuke.Security.Roles.RoleController();
                RoleInfo oRole = new RoleInfo();
                oRole.PortalID = PortalSettings.PortalId;
                oRole.RoleName = roleName.Name;
                oRole.IsPublic = false;
                oRole.Status = RoleStatus.Approved;
                oRole.AutoAssignment = false;
                oRole.RoleGroupID = roleName.RoleGroup;
                oRole.Status = (RoleStatus)roleName.Status;
                oRole.Description = "";
                oRole.IsSystemRole = false;

                if (_roleID == -1)
                {
                    var rolename = oRole.RoleName.ToUpper();
                    if (DotNetNuke.Security.Roles.RoleController.Instance.GetRole(oRole.PortalID,
                        r => rolename.Equals(r.RoleName, StringComparison.InvariantCultureIgnoreCase)) == null)
                    {
                        oDnnRoleController.AddRole(oRole);
                    }
                }
                else
                {
                    oRole.RoleID = roleName.RoleId;
                    DotNetNuke.Security.Roles.RoleController.Instance.UpdateRole(oRole);
                }
                DataCache.ClearCache();
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }
        }
Ejemplo n.º 8
0
        private void Create_Click(object sender, EventArgs e)
        {
            RoleController roleController = new RoleController();
            Security.PortalSecurity ps = new Security.PortalSecurity();
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);

            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
            if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null)
            {
                reqGroupName.Visible = true;
                return;
            }
            List<RoleInfo> modRoles = new List<RoleInfo>();
            foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId))
            {
                if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess)
                {
                    modRoles.Add(roleController.GetRole(modulePermissionInfo.RoleID, PortalId));
                }
            }
            RoleInfo roleInfo = new RoleInfo()
            {
                PortalID = PortalId,
                RoleName = txtGroupName.Text,
                Description = txtDescription.Text,
                SecurityMode = SecurityMode.SocialGroup,
                Status = RoleStatus.Approved,
                IsPublic = rdAccessTypePublic.Checked
            };
            var userRoleStatus = RoleStatus.Pending;
            if (GroupModerationEnabled)
            {
                roleInfo.Status = RoleStatus.Pending;
                userRoleStatus = RoleStatus.Pending;
            }
            else
            {
                userRoleStatus = RoleStatus.Approved;
            }

            var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo)));
            if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP"))
            {
                roleInfo.Status = RoleStatus.Approved;
                userRoleStatus = RoleStatus.Approved;
            }
            roleInfo.RoleGroupID = DefaultRoleGroupId;

            roleInfo.RoleID = roleController.AddRole(roleInfo);
            roleInfo = roleController.GetRole(roleInfo.RoleID, PortalId);
            roleInfo.Settings.Add("URL", Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
            roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName);
            roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());

            TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
            if (inpFile.PostedFile.ContentLength > 0)
            {
                IFileManager _fileManager = FileManager.Instance;
                IFolderManager _folderManager = FolderManager.Instance;
                var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);

                IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                if (groupFolder == null)
                {
                    groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                }
                if (groupFolder != null)
                {
                    var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
                    var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
                    roleInfo.IconFile = "FileID=" + fileInfo.FileId;
                    roleController.UpdateRole(roleInfo);
                }
            }

            Components.Notifications notifications = new Components.Notifications();


            roleController.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate);
            if (roleInfo.Status == RoleStatus.Pending)
            {
                //Send notification to Group Moderators to approve/reject group.
                notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);
            }
            else
            {
                //Send notification to Group Moderators informing of new group.
                notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);

                //Add entry to journal.
                GroupUtilities.CreateJournalEntry(roleInfo, UserInfo);
            }

            Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
        }
Ejemplo n.º 9
0
        private void GivenThereIsAUserWithThisRole(string userName, string password, string roleName)
        {
            var reset = false;
            var user = UserController.GetUserByName(PortalId, userName);
            if (user == null)
            {
                user = new UserInfo
                           {
                               PortalID = PortalId,
                               Username = userName,
                               IsSuperUser = false,
                               Email = string.Format("{0}@dnn.com", userName),
                               FirstName = string.Format("{0} FN", userName),
                               LastName = string.Format("{0} LN", userName),
                               DisplayName = string.Format("{0} DN", userName),
                               Membership = { Password = password }
                           };
                UserController.CreateUser(ref user);
                reset = true;
            }
            else if (user.IsDeleted)
            {
                UserController.RestoreUser(ref user);
                reset = true;
            }
            user.Membership.Password = password;
            var roles = user.Roles.Where(r => r == roleName);
            if (!roles.Any())
            {
                var roleController = new RoleController();
                var role = roleController.GetRoleByName(PortalId, roleName);
                if (role == null)
                {
                    role = new RoleInfo { RoleName = roleName, PortalID = PortalId, RoleGroupID = -1 };
                    role.RoleID = roleController.AddRole(role);
                }
                RoleController.AddUserRole(user, role, PortalSettings.Current, DateTime.Now, Null.NullDate, user.UserID, false);
                reset = true;
            }

            User = user;
            HttpContext.Current.Items["UserInfo"] = user;
            if (reset)
            {
                Config.Touch();
            }
        }