protected void ShowSettings()
        {
            //get the tracking ID
            if (ModuleSettings.ContainsKey("GoogleTrackingId"))
                txtAnalyticsTrackingId.Text = (string)ModuleSettings["GoogleTrackingId"];

            if (ModuleSettings.ContainsKey("LocalHostAddress"))
            {
                txtLocalHostName.Text = (string)ModuleSettings["LocalHostAddress"];
            }
            
            //populate the drop down box
            RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            ArrayList roles = rc.GetPortalRoles(this.PortalId);
            //put in a dummy role to allow no restriction on role
            RoleInfo dummyRole = new RoleInfo();
            dummyRole.RoleID = -1;
            dummyRole.RoleName = "[Do Not Hide Tracking]";
            roles.Insert(0, dummyRole);
            ddlSecurityGroups.DataSource = roles;
            ddlSecurityGroups.DataValueField = "RoleID";
            ddlSecurityGroups.DataTextField = "RoleName";
            ddlSecurityGroups.DataBind();

            //get the security group
            if (ModuleSettings.ContainsKey("HideTrackingFromRole"))
            {
                foreach(ListItem item in ddlSecurityGroups.Items)
                {
                    string value = (string)ModuleSettings["HideTrackingFromRole"];
                    if (item.Text == value)
                        ddlSecurityGroups.SelectedValue = item.Value;
                }
            }
        }
        private static bool DeleteUserRoleInternal(int portalId, int userId, int roleId)
        {
            var roleController = new RoleController();
            var user = UserController.GetUserById(portalId, userId);
            var userRole = roleController.GetUserRole(portalId, userId, roleId);
            var portalController = new PortalController();
            bool delete = true;
            var portal = portalController.GetPortal(portalId);
            if (portal != null && userRole != null)
            {
                if (CanRemoveUserFromRole(portal, userId, roleId))
                {
                    provider.RemoveUserFromRole(portalId, user, userRole);
                    var objEventLog = new EventLogController();
                    objEventLog.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.ROLE_UPDATED);

                    //Remove the UserInfo from the Cache, as it has been modified
                    DataCache.ClearUserCache(portalId, user.Username);
                    TestableRoleController.Instance.ClearRoleCache(portalId);
                }
                else
                {
                    delete = false;
                }
            }
            return delete;
        }
Beispiel #3
0
        public HttpResponseMessage EditRoleGroup(NewRoleGroupDTO roleGroupName)
        {
            try
            {
                DotNetNuke.Security.Roles.RoleController oDnnRoleController = new DotNetNuke.Security.Roles.RoleController();
                RoleGroupInfo oRoleGroup = new RoleGroupInfo();
                oRoleGroup.PortalID      = this.PortalSettings.PortalId;
                oRoleGroup.RoleGroupName = "DVC_" + roleGroupName.Name;
                oRoleGroup.RoleGroupID   = roleGroupName.RoleGroupID;
                oRoleGroup.Description   = "";


                if (oRoleGroup.RoleGroupID == -1)
                {
                    DotNetNuke.Security.Roles.RoleController.AddRoleGroup(oRoleGroup);
                }
                else
                {
                    DotNetNuke.Security.Roles.RoleController.UpdateRoleGroup(oRoleGroup);
                }
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #4
0
        public void AuthoriseClient()
        {
            if (_userInfo != null)
            {
                _userInfo.Membership.Approved = true;
                UserController.UpdateUser(PortalSettings.Current.PortalId, _userInfo);

                if (_userInfo.IsInRole("Unverified Users"))
                {
                    var rc             = new DotNetNuke.Security.Roles.RoleController();
                    var ri             = rc.GetRoleByName(PortalId, "Unverified Users");
                    var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
                    if (ri != null)
                    {
                        RoleController.DeleteUserRole(_userInfo, ri, portalSettings, false);
                    }

                    ri = rc.GetRoleByName(PortalId, "Registered Users");
                    if (ri != null)
                    {
                        RoleController.AddUserRole(_userInfo, ri, portalSettings, RoleStatus.Approved, DateTime.Now, DateTime.Now.AddYears(99), false, false);
                    }

                    ri = rc.GetRoleByName(PortalId, "Subscribers");
                    if (ri != null)
                    {
                        RoleController.AddUserRole(_userInfo, ri, portalSettings, RoleStatus.Approved, DateTime.Now, DateTime.Now.AddYears(99), false, false);
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// BindData gets the roles from the Database and binds them to the DataGrid
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    01/05/2006  Updated to reflect Use of Role Groups
        /// </history>
        private void BindData()
        {
            // Get the portal's roles from the database
            RoleController objRoles = new RoleController();
            ArrayList arrRoles;

            if( RoleGroupId < - 1 )
            {
                arrRoles = objRoles.GetPortalRoles( PortalId );
            }
            else
            {
                arrRoles = objRoles.GetRolesByGroup( PortalId, RoleGroupId );
            }
            grdRoles.DataSource = arrRoles;

            if( RoleGroupId < 0 )
            {
                lnkEditGroup.Visible = false;
                cmdDelete.Visible = false;
            }
            else
            {
                lnkEditGroup.Visible = true;
                lnkEditGroup.NavigateUrl = EditUrl( "RoleGroupId", RoleGroupId.ToString(), "EditGroup" );
                cmdDelete.Visible = !( arrRoles.Count > 0 );
                ClientAPI.AddButtonConfirm( cmdDelete, Localization.GetString( "DeleteItem" ) );
            }

            Localization.LocalizeDataGrid( ref grdRoles, this.LocalResourceFile );

            grdRoles.DataBind();
        }
        public override ArrayList GetGroups()
        {
            //Dim adsiConfig As Authentication.ADSI.Configuration = Authentication.ADSI.Configuration.GetConfig(_portalSettings.PortalId)
            // Normally number of roles in DNN less than groups in Authentication,
            // so start from DNN roles to get better performance
            try
            {
                // Obtain search object
                //Dim rootDomain As DirectoryEntry = GetRootDomain()
                //Dim objSearch As New ADSI.Search(rootDomain)

                ArrayList colGroup = new ArrayList();
                RoleController objRoleController = new RoleController();
                ArrayList lstRoles = objRoleController.GetPortalRoles( _portalSettings.PortalId );
                RoleInfo objRole;

                foreach( RoleInfo tempLoopVar_objRole in lstRoles )
                {
                    objRole = tempLoopVar_objRole;
                    // Auto assignment roles have been added by DNN, so don't need to get them
                    if( ! objRole.AutoAssignment )
                    {
                        // It's possible in multiple domains network that search result return more than one group with the same name (i.e Administrators)
                        // We better check them all
                        DirectoryEntry entry;
                        foreach( DirectoryEntry tempLoopVar_entry in Utilities.GetGroupEntriesByName( objRole.RoleName ) )
                        {
                            entry = tempLoopVar_entry;
                            GroupInfo group = new GroupInfo();

                            group.PortalID = objRole.PortalID;
                            group.RoleID = objRole.RoleID;
                            group.GUID = entry.NativeGuid;
                            group.Location = Utilities.GetEntryLocation( entry );
                            group.RoleName = objRole.RoleName;
                            group.Description = objRole.Description;
                            group.ServiceFee = objRole.ServiceFee;
                            group.BillingFrequency = objRole.BillingFrequency;
                            group.TrialPeriod = objRole.TrialPeriod;
                            group.TrialFrequency = objRole.TrialFrequency;
                            group.BillingPeriod = objRole.BillingPeriod;
                            group.TrialFee = objRole.TrialFee;
                            group.IsPublic = objRole.IsPublic;
                            group.AutoAssignment = objRole.AutoAssignment;
                            // Populate member with distingushed name
                            PopulateMembership( group, entry );

                            colGroup.Add( group );
                        }
                    }
                }

                return colGroup;
            }
            catch( COMException exc )
            {
                Exceptions.LogException( exc );
                return null;
            }
        }
 public void GetStaffNames(int portalid, string term)
 {
     term = term.ToLower();
     var result = new DotNetNuke.Security.Roles.RoleController().GetUsersByRole(portalid, "Staff")
         .Where(w => w.DisplayName.ToLower().Contains(term) && w.IsDeleted==false)
         .Select(s => new { label = s.DisplayName, value = s.UserID })
         .OrderBy(o => o.label);
     string json = JsonConvert.SerializeObject(result);
     HttpContext.Current.Response.ContentType = "application/json";
     HttpContext.Current.Response.Write(json);
 }
Beispiel #8
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (GroupId > 0)
            {
                RoleController roleController = new RoleController();
                Security.PortalSecurity ps = new Security.PortalSecurity();
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                var roleInfo = roleController.GetRole(GroupId, PortalId);
                if (roleInfo != null)
                {
                    roleInfo.Description = txtDescription.Text;
                    roleInfo.IsPublic = rdAccessTypePublic.Checked;
                    if (roleInfo.Settings.ContainsKey("URL"))
                    {
                        roleInfo.Settings["URL"] = Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() });
                    } else
                    {
                        roleInfo.Settings.Add("URL", Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
                    }
                    if (roleInfo.Settings.ContainsKey("ReviewMembers"))
                    {
                        roleInfo.Settings["ReviewMembers"] = chkMemberApproved.Checked.ToString();
                    } else
                    {
                        roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());
                    }
                    TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
                    roleController.UpdateRole(roleInfo);

                    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);
                        }
                    }

                }
                Response.Redirect(Globals.NavigateURL(TabId, "", new String[] { "groupid=" + GroupId.ToString() }));
            }
        }
Beispiel #9
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();
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DataBind binds the data to the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/13/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void DataBind()
        {
            if (Request.IsAuthenticated)
            {
                RoleController roleController = new RoleController();
                grdServices.DataSource = roleController.GetUserRoles(UserInfo, false);
                grdServices.DataBind();

                //if no service available then hide options
                ServicesRow.Visible = (grdServices.Items.Count > 0);
            }
        }
Beispiel #11
0
 public void AddClientEditorRole()
 {
     if (_userInfo != null)
     {
         if (!_userInfo.IsInRole(StoreSettings.ClientEditorRole))
         {
             var rc = new DotNetNuke.Security.Roles.RoleController();
             var ri = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
             if (ri != null) rc.AddUserRole(PortalId, _userInfo.UserID, ri.RoleID, Null.NullDate, Null.NullDate);
             if (StoreSettings.Current.Get("sendclientroleemail") == "True") NBrightBuyUtils.SendEmail(_userInfo.Email, "addclientrole.html", _clientInfo, "", "", _userInfo.Profile.PreferredLocale);
         }
     }
 }
    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);
    }
Beispiel #13
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += cmdCancel_Click;
            cmdDelete.Click += cmdDelete_Click;
            cmdUpdate.Click += cmdUpdate_Click;

            try
            {
                if ((Request.QueryString["RoleGroupID"] != null))
                {
                    RoleGroupID = Int32.Parse(Request.QueryString["RoleGroupID"]);
                }
                if (Page.IsPostBack == false)
                {
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
                    var objRoles = new RoleController();
                    if (RoleGroupID != -1)
                    {
                        RoleGroupInfo objRoleGroupInfo = RoleController.GetRoleGroup(PortalId, RoleGroupID);
                        if (objRoleGroupInfo != null)
                        {
                            txtRoleGroupName.Text = objRoleGroupInfo.RoleGroupName;
                            txtDescription.Text = objRoleGroupInfo.Description;

                            //Check if Group has any roles assigned
                            int roleCount = objRoles.GetRolesByGroup(PortalId, RoleGroupID).Count;

                            if (roleCount > 0)
                            {
                                cmdDelete.Visible = false;
                            }
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL("Security Roles"));
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #14
0
 public void RemoveClientEditorRole()
 {
     if (_userInfo != null)
     {
         if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
         {
             var rc             = new DotNetNuke.Security.Roles.RoleController();
             var ri             = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
             var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
             if (ri != null)
             {
                 RoleController.DeleteUserRole(_userInfo, ri, portalSettings, false);
             }
         }
     }
 }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DotNetNuke.Framework.jQuery.RegisterDnnJQueryPlugins(this.Page);

            imgGroup.Src = Page.ResolveUrl("~/DesktopModules/SocialGroups/Images/") + "sample-group-profile.jpg";
            if (!Page.IsPostBack && GroupId > 0)
            {
                RoleController roleController = new RoleController();
                var roleInfo = roleController.GetRole(GroupId, PortalId);

                if (roleInfo != null)
                {
                    if (!UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        if (roleInfo.CreatedByUserID != UserInfo.UserID)
                        {
                            Response.Redirect(ModuleContext.NavigateUrl(TabId, "", false, new String[] { "groupid=" + GroupId.ToString() }));
                        }
                    }

                    txtGroupName.Visible = !roleInfo.IsSystemRole;
                    reqGroupName.Enabled = !roleInfo.IsSystemRole;

                    if(!roleInfo.IsSystemRole)
                        txtGroupName.Text = roleInfo.RoleName;
                    else
                        litGroupName.Text = roleInfo.RoleName;
                    
                    txtDescription.Text = roleInfo.Description;
                    rdAccessTypePrivate.Checked = !roleInfo.IsPublic;
                    rdAccessTypePublic.Checked = roleInfo.IsPublic;
                    

                    if (roleInfo.Settings.ContainsKey("ReviewMembers"))
                    {
                        chkMemberApproved.Checked = Convert.ToBoolean(roleInfo.Settings["ReviewMembers"].ToString());
                    }
                    imgGroup.Src = roleInfo.PhotoURL;
                }
                else
                {
                    Response.Redirect(ModuleContext.NavigateUrl(TabId, "", false));
                }
            }
        }
Beispiel #16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdDelete_Click runs when the delete Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnDeleteClick(object sender, EventArgs e)
        {
            try
            {
                var objUser = new RoleController();

                objUser.DeleteRole(_roleID, PortalSettings.PortalId);

                //Clear Roles Cache
                DataCache.RemoveCache("GetRoles");

                Response.Redirect(Globals.NavigateURL());
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #17
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));
            }
        }
Beispiel #18
0
        internal virtual Notification AddGroupOwnerNotification(string notificationTypeName, int tabId, int moduleId, RoleInfo group, UserInfo initiatingUser) 
        {
            var notificationType = NotificationsController.Instance.GetNotificationType(notificationTypeName);

            var tokenReplace = new GroupItemTokenReplace(group);
            
            var subject = Localization.GetString(notificationTypeName + ".Subject", Constants.SharedResourcesPath);
            var body = Localization.GetString(notificationTypeName + ".Body", Constants.SharedResourcesPath);
            subject = subject.Replace("[DisplayName]", initiatingUser.DisplayName);
            subject = subject.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
            subject = tokenReplace.ReplaceGroupItemTokens(subject);
            body = body.Replace("[DisplayName]", initiatingUser.DisplayName);
            body = body.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
            body = tokenReplace.ReplaceGroupItemTokens(body);
            var roleCreator = UserController.GetUserById(group.PortalID, group.CreatedByUserID);

            var roleOwners = new List<UserInfo>();

            var rc = new RoleController();
            foreach (UserInfo userInfo in rc.GetUsersByRoleName(group.PortalID, group.RoleName)) {
                var userRoleInfo = rc.GetUserRole(group.PortalID, userInfo.UserID, group.RoleID);
                if (userRoleInfo.IsOwner && userRoleInfo.UserID != group.CreatedByUserID)
                {
                    roleOwners.Add(UserController.GetUserById(group.PortalID, userRoleInfo.UserID));
                }
            }
            roleOwners.Add(roleCreator);
            


            //Need to add from sender details
            var notification = new Notification
            {
                NotificationTypeID = notificationType.NotificationTypeId,
                Subject = subject,
                Body = body,
                IncludeDismissAction = true,
                SenderUserID = initiatingUser.UserID,
                Context = String.Format("{0}:{1}:{2}:{3}", tabId, moduleId, group.RoleID, initiatingUser.UserID)
            };
            NotificationsController.Instance.SendNotification(notification, initiatingUser.PortalID, null, roleOwners);

            return notification;
        }
Beispiel #19
0
 public void AddClientEditorRole()
 {
     if (_userInfo != null)
     {
         if (!_userInfo.IsInRole(StoreSettings.ClientEditorRole))
         {
             var rc = new DotNetNuke.Security.Roles.RoleController();
             var ri = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
             if (ri != null)
             {
                 rc.AddUserRole(PortalId, _userInfo.UserID, ri.RoleID, Null.NullDate, Null.NullDate);
             }
             if (StoreSettings.Current.Get("sendclientroleemail") == "True")
             {
                 NBrightBuyUtils.SendEmail(_userInfo.Email, "addclientrole.html", _clientInfo, "", "", _userInfo.Profile.PreferredLocale);
             }
         }
     }
 }
        private void BindRoles()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<select id=\"drpSecRoles\" class=\"amcptxtbx\" style=\"width:150px;\">");
            sb.Append("<option value=\"\">[RESX:DropDownDefault]</option>");
            sb.Append("<option value=\"-1\">All Users</option>");
            sb.Append("<option value=\"-3\">Unauthenticated Users</option>");
            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            foreach (DotNetNuke.Security.Roles.RoleInfo ri in rc.GetPortalRoles(PortalId))
            {
                sb.Append("<option value=\"" + ri.RoleID + "\">" + ri.RoleName + "</option>");
            }
            //drpSecRoles.DataTextField = "RoleName"
            //drpSecRoles.DataValueField = "RoleId"
            //drpSecRoles.DataSource = rc.GetPortalRoles(PortalId)
            //drpSecRoles.DataBind()
            //drpSecRoles.Items.Insert(0, New ListItem("[RESX:DropDownDefault]", ""))
            //drpSecRoles.Items.Insert(1, New ListItem("All Users", "-1"))
            //drpSecRoles.Items.Insert(2, New ListItem("Unauthenticated Users", "-3"))
            //drpSecRoles.Items.Insert(3, New ListItem("Topic Author", "-10"))
            string sGroups = string.Empty;

#if !SKU_LITE
            if (System.IO.File.Exists(Server.MapPath("~/bin/active.modules.social.dll")))
            {
                Social social = new Social();
                using (IDataReader dr = social.ActiveSocialListGroups(PortalId))
                {
                    while (dr.Read())
                    {
                        sb.Append("<optgroup label=\"" + dr["GroupName"].ToString() + "\">");
                        sb.Append("<option value=\"" + dr["GroupId"].ToString() + ":0\">Group Admin</option>");
                        sb.Append("<option value=\"" + dr["GroupId"].ToString() + ":1\">Group Member</option>");
                        sb.Append("</optgroup>");
                    }
                    dr.Close();
                }
            }
#endif
            sb.Append("</select>");
            litRoles.Text = sb.ToString();
        }
Beispiel #21
0
        public File CreateGroupFolder(int roleID, int portalID, UserInfo currentUser)
        {
            FileController ctrl = new FileController();
            File rootGroupFolder = new File();

            //rootGroupFolder.ChildCount = 0;
            rootGroupFolder.CreatedByUserID = currentUser.UserID;
            rootGroupFolder.CreatedByUserName = currentUser.DisplayName;
            rootGroupFolder.CreatedDate = System.DateTime.Now;
            rootGroupFolder.IsInTrash = false;
            rootGroupFolder.IsFolder = true;
            rootGroupFolder.ItemType = 0;
            rootGroupFolder.LastModifiedByUserID = currentUser.UserID;
            rootGroupFolder.LastModifiedByUserName = currentUser.DisplayName;
            rootGroupFolder.LastModifiedDate = System.DateTime.Now;
            RoleController ctrlRole = new RoleController();
            RoleInfo role = ctrlRole.GetRole(roleID, portalID);
            rootGroupFolder.Name = role.RoleName;
            rootGroupFolder.ParentID = GetRootGroupsFolder(portalID, currentUser.UserID).ID;
            rootGroupFolder.PortalID = portalID;
            rootGroupFolder.RoleID = roleID;

            ctrl.Create(rootGroupFolder);

            Permission permission = new Permission();
            permission.CanAddFiles = true;
            permission.CanAddFolders = true;
            permission.CanDelete = false;
            permission.CanModify = false;
            permission.CanModifyPermission = false;
            permission.CanSee = true;
            permission.FileID = rootGroupFolder.ID;
            permission.ModuleID = 0;
            permission.PortalID = portalID;
            permission.RoleID = role.RoleID;
            permission.RoleName = role.RoleName;

            PermissionController ctrlPerm = new PermissionController();
            ctrlPerm.Create(permission);

            return rootGroupFolder;
        }
Beispiel #22
0
 public void AddClientEditorRole()
 {
     if (_userInfo != null)
     {
         if (!_userInfo.IsInRole(StoreSettings.ClientEditorRole))
         {
             var rc = new DotNetNuke.Security.Roles.RoleController();
             var ri = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
             if (ri != null)
             {
                 rc.AddUserRole(PortalId, _userInfo.UserID, ri.RoleID, Null.NullDate, Null.NullDate);
             }
             if (StoreSettings.Current.Get("sendclientroleemail") == "True")
             {
                 var emailBody = "";
                 emailBody = NBrightBuyUtils.RazorTemplRender("AddClientRole.cshtml", 0, "", _clientInfo, "/DesktopModules/NBright/NBrightBuy", StoreSettings.Current.Get("themefolder"), _userInfo.Profile.PreferredLocale, StoreSettings.Current.Settings());
                 NBrightBuyUtils.SendEmail(emailBody, _userInfo.Email, "ClientRole", _clientInfo, StoreSettings.Current.SettingsInfo.GetXmlProperty("genxml/textbox/storecompany"), StoreSettings.Current.ManagerEmail, _userInfo.Profile.PreferredLocale);
             }
         }
     }
 }
Beispiel #23
0
        public HttpResponseMessage Roles_List()
        {
            int v_Current_Portal_ID = this.ActiveModule.PortalID;

            List <Entities.Role_Info> v_Return_List = new List <Entities.Role_Info>();

            DotNetNuke.Security.Roles.RoleController v_Roles_Controller = new DotNetNuke.Security.Roles.RoleController();
            ArrayList v_Roles_List = v_Roles_Controller.GetPortalRoles(v_Current_Portal_ID);

            foreach (DotNetNuke.Security.Roles.RoleInfo v_Roles_Info in v_Roles_List)
            {
                Entities.Role_Info v_Role_Info_Json = new Entities.Role_Info();
                v_Role_Info_Json.RoleName = v_Roles_Info.RoleName;
                v_Role_Info_Json.ID       = v_Roles_Info.RoleID;
                v_Return_List.Add(v_Role_Info_Json);
            }

            string v_json_resulted = Newtonsoft.Json.JsonConvert.SerializeObject(v_Return_List);

            return(Request.CreateResponse(HttpStatusCode.OK, v_json_resulted));
        }
        public HttpResponseMessage ApproveGroup(NotificationDTO postData)
        {
            try
            {
                var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, UserInfo.UserID);
                if (recipient == null) return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient");

                var notification = NotificationsController.Instance.GetNotification(postData.NotificationId);
                ParseKey(notification.Context);
                if (_roleInfo == null)
                {
                    return  Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate role");
                }
                if (!IsMod())
                {
                    return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized!");
                }
                var roleController = new RoleController();
                _roleInfo.Status = RoleStatus.Approved;
                roleController.UpdateRole(_roleInfo);
                var roleCreator = UserController.GetUserById(PortalSettings.PortalId, _roleInfo.CreatedByUserID);
                //Update the original creator's role
                roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, _roleInfo.RoleID, RoleStatus.Approved, true, false);
                GroupUtilities.CreateJournalEntry(_roleInfo, roleCreator);

                var notifications = new Notifications();
                var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId);
                notifications.AddGroupNotification(Constants.GroupApprovedNotification, _tabId, _moduleId, _roleInfo, siteAdmin, new List<RoleInfo> { _roleInfo });
                NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId);

                return Request.CreateResponse(HttpStatusCode.OK, new {Result = "success"});
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }
        }
Beispiel #25
0
        public ActionResult ApproveGroup(int notificationId)
        {
            try
            {
                var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID);
                if (recipient == null) return Json(new { Result = "error" });

                var notification = NotificationsController.Instance.GetNotification(notificationId);
                ParseKey(notification.Context);
                if (roleInfo == null)
                {
                    return Json(new { Result = "error" });
                }
                if (!IsMod())
                {
                    return Json(new { Result = "access denied" });
                }
                var roleController = new RoleController();
                roleInfo.Status = RoleStatus.Approved;
                roleController.UpdateRole(roleInfo);
                var roleCreator = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID);
                //Update the original creator's role
                roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, roleInfo.RoleID, RoleStatus.Approved, true, false);
                GroupUtilities.CreateJournalEntry(roleInfo, roleCreator);

                var notifications = new Notifications();
                var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId);
                notifications.AddGroupNotification(Constants.GroupApprovedNotification, TabId, ModuleId, roleInfo, siteAdmin, new List<RoleInfo> { roleInfo });
                NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId);

                return Json(new { Result = "success" });
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return Json(new { Result = "error" });
            }
        }
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load( Object sender, EventArgs e )
        {
            try
            {
                if( ! Page.IsPostBack )
                {
                    RoleController objRoleController = new RoleController();
                    chkRoles.DataSource = objRoleController.GetPortalRoles( PortalId );
                    chkRoles.DataBind();

                    //Dim FileList As ArrayList = GetFileList(PortalId)
                    //cboAttachment.DataSource = FileList
                    //cboAttachment.DataBind()
                    //cmdUpload.NavigateUrl =Common.Globals.NavigateURL("File Manager")

                    txtFrom.Text = UserInfo.Email;
                }
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
Beispiel #27
0
    protected void BT_CreateUsersManquants_Click(object sender, EventArgs e)
    {
        DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
        TXT_Result.Text = "";
        List <Member> membres = DataMapping.ListMembers(max: 10000);

        foreach (Member membre in membres)
        {
            if (membre.userid == 0 && membre.email != "")
            {
                UserInfo ui = UserController.GetUserByName(Globals.GetPortalSettings().PortalId, membre.email);
                if (ui == null)
                {
                    if (DataMapping.UpdateOrCreateUser(membre.id, membre.email))
                    {
                        TXT_Result.Text += "<br/>Creation : " + membre.surname + " " + membre.name;
                    }
                    else
                    {
                        TXT_Result.Text += "<br/>Erreur création user : "******" " + membre.name;
                    }
                }
                else
                {
                    if (DataMapping.UpdateMemberDNNUserID(membre.id, ui.UserID))
                    {
                        TXT_Result.Text += "<br/>L'utilisateur DNN existe déjà donc mise à jour : " + membre.surname + " " + membre.name;
                    }
                    else
                    {
                        TXT_Result.Text += "<br/>L'utilisateur DNN existe déjà mais n'a pas pu être mis à jour : " + membre.surname + " " + membre.name;
                    }
                }
            }
        }
    }
        /// <summary>
        /// DataBind binds the data to the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/13/2006  Created
        /// </history>
        public override void DataBind()
        {
            if( Services == 1 )
            {
                RoleController objRoles = new RoleController();
                grdServices.DataSource = objRoles.GetUserRoles( PortalId );
                grdServices.DataBind();

                if( grdServices.Items.Count != 0 )
                {
                    lblServices.Text = string.Format( Localization.GetString( "PleaseRegister", this.LocalResourceFile ), Globals.GetPortalDomainName( PortalAlias.HTTPAlias, Request, true ) + "/" + Globals.glbDefaultPage, TabId );
                }
                else
                {
                    grdServices.Visible = false;
                    lblServices.Text = Localization.GetString( "MembershipNotOffered", this.LocalResourceFile );
                }
                lblServices.Visible = true;

                grdServices.Columns[0].Visible = false; // subscribe
                grdServices.Columns[9].Visible = false; // expiry date
            }
            else
            {
                if( Request.IsAuthenticated )
                {
                    RoleController objRoles = new RoleController();

                    grdServices.DataSource = objRoles.GetUserRoles( PortalId, UserInfo.UserID, false );
                    grdServices.DataBind();

                    // if no service available then hide options
                    //ServicesRow.Visible = (grdServices.Items.Count > 0)
                }
            }
        }
 private void ParseKey(string key)
 {
     _tabId = -1;
     _moduleId = -1;
     _roleId = -1;
     _memberId = -1;
     _roleInfo = null;
     if (!String.IsNullOrEmpty(key))
     {
         string[] keys = key.Split(':');
         _tabId = Convert.ToInt32(keys[0]);
         _moduleId = Convert.ToInt32(keys[1]);
         _roleId = Convert.ToInt32(keys[2]);
         if (keys.Length > 3)
         {
             _memberId = Convert.ToInt32(keys[3]);
         }
     }
     if (_roleId > 0)
     {
         var roleController = new RoleController();
         _roleInfo = roleController.GetRole(_roleId, PortalSettings.PortalId);
     }
 }
        public HttpResponseMessage ApproveMember(NotificationDTO postData)
        {
            try
            {
                var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, UserInfo.UserID);
                if (recipient == null) return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient");

                var notification = NotificationsController.Instance.GetNotification(postData.NotificationId);
                ParseKey(notification.Context);
                if (_memberId <= 0)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate Member");
                }

                if (_roleInfo == null)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate Role");
                }

                var member = UserController.GetUserById(PortalSettings.PortalId, _memberId);

                if (member != null)
                {
                    var roleController = new RoleController();
                    var memberRoleInfo = roleController.GetUserRole(PortalSettings.PortalId, _memberId, _roleInfo.RoleID);
                    memberRoleInfo.Status = RoleStatus.Approved;
                    roleController.UpdateUserRole(PortalSettings.PortalId, _memberId, _roleInfo.RoleID, RoleStatus.Approved, false, false);
                    
                    var notifications = new Notifications();
                    var groupOwner = UserController.GetUserById(PortalSettings.PortalId, _roleInfo.CreatedByUserID);
                    notifications.AddMemberNotification(Constants.MemberApprovedNotification, _tabId, _moduleId, _roleInfo, groupOwner, member);
                    NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId);

                    return Request.CreateResponse(HttpStatusCode.OK, new {Result = "success"});
                }
            } catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }

            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unknown Error");
        }
        public HttpResponseMessage LeaveGroup(RoleDTO postData)
        {
            var success = false;

            try
            {
                if (UserInfo.UserID >= 0 && postData.RoleId > 0)
                {
                    var roleController = new RoleController();
                    _roleInfo = roleController.GetRole(postData.RoleId, PortalSettings.PortalId);

                    if (_roleInfo != null)
                    {
                        if (UserInfo.IsInRole(_roleInfo.RoleName))
                        {
                            RoleController.DeleteUserRole(UserInfo, _roleInfo, PortalSettings, false);
                        }
                        success = true;
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }

            if(success)
            {
                return Request.CreateResponse(HttpStatusCode.OK, new {Result = "success"});
            }
            
            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unknown Error");
        }
        public HttpResponseMessage JoinGroup(RoleDTO postData)
        {
            try
            {
                if (UserInfo.UserID >= 0 && postData.RoleId > 0)
                {
                    var roleController = new RoleController();
                    _roleInfo = roleController.GetRole(postData.RoleId, PortalSettings.PortalId);
                    if (_roleInfo != null)
                    {

                        var requireApproval = false;

                        if(_roleInfo.Settings.ContainsKey("ReviewMembers"))
                            requireApproval = Convert.ToBoolean(_roleInfo.Settings["ReviewMembers"]);


                        if ((_roleInfo.IsPublic || UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) && !requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, _roleInfo.RoleID, Null.NullDate);
                            roleController.UpdateRole(_roleInfo);

                            var url = Globals.NavigateURL(postData.GroupViewTabId, "", new[] { "groupid=" + _roleInfo.RoleID });
                            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success", URL = url });
                        
                        }
                        if (_roleInfo.IsPublic && requireApproval)
                        {
                            roleController.AddUserRole(PortalSettings.PortalId, UserInfo.UserID, _roleInfo.RoleID, RoleStatus.Pending, false, Null.NullDate, Null.NullDate);
                            var notifications = new Notifications();
                            notifications.AddGroupOwnerNotification(Constants.MemberPendingNotification, _tabId, _moduleId, _roleInfo, UserInfo);
                            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success", URL = string.Empty });
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
            }

            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unknown Error");
        }
        private IList<UserRoleInfo> GetPagedDataSource()
        {
            var objRoleController = new RoleController();
            var roleName = RoleId != Null.NullInteger ? Role.RoleName : Null.NullString;
            var userName = UserId != Null.NullInteger ? User.Username : Null.NullString;

            var userList = objRoleController.GetUserRoles(PortalId, userName, roleName);
            _totalRecords = userList.Count;
            _totalPages = _totalRecords%PageSize == 0 ? _totalRecords/PageSize : _totalRecords/PageSize + 1;

            return userList.Skip((CurrentPage - 1 )*PageSize).Take(PageSize).ToList();
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetDates gets the expiry/effective Dates of a Users Role membership
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    01/20/2006  Added support for Effective Date
        /// </history>
        /// -----------------------------------------------------------------------------
        private void GetDates(int UserId, int RoleId)
        {
            DateTime? expiryDate = null;
            DateTime? effectiveDate = null;

            var objRoles = new RoleController();
            UserRoleInfo objUserRole = objRoles.GetUserRole(PortalId, UserId, RoleId);
            if (objUserRole != null)
            {
                if (Null.IsNull(objUserRole.EffectiveDate) == false)
                {
                    effectiveDate = objUserRole.EffectiveDate;
                }
                if (Null.IsNull(objUserRole.ExpiryDate) == false)
                {
                    expiryDate = objUserRole.ExpiryDate;
                }
            }
            else //new role assignment
            {
                RoleInfo objRole = TestableRoleController.Instance.GetRole(PortalId, r => r.RoleID == RoleId);

                if (objRole.BillingPeriod > 0)
                {
                    switch (objRole.BillingFrequency)
                    {
                        case "D":
                            expiryDate = DateTime.Now.AddDays(objRole.BillingPeriod);
                            break;
                        case "W":
                            expiryDate = DateTime.Now.AddDays(objRole.BillingPeriod*7);
                            break;
                        case "M":
                            expiryDate = DateTime.Now.AddMonths(objRole.BillingPeriod);
                            break;
                        case "Y":
                            expiryDate = DateTime.Now.AddYears(objRole.BillingPeriod);
                            break;
                    }
                }
            }
            effectiveDatePicker.SelectedDate = effectiveDate;
            expiryDatePicker.SelectedDate = expiryDate;
        }
        public void cmdDeleteUserRole_click(object sender, ImageClickEventArgs e)
        {
            if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false)
            {
                return;
            }
            try
            {
                var cmdDeleteUserRole = (ImageButton) sender;
                int roleId = Convert.ToInt32(cmdDeleteUserRole.Attributes["roleId"]);
                int userId = Convert.ToInt32(cmdDeleteUserRole.Attributes["userId"]);

                var roleController = new RoleController();
                RoleInfo role = TestableRoleController.Instance.GetRole(PortalId, r => r.RoleID == roleId);
                if (!RoleController.DeleteUserRole(UserController.GetUserById(PortalId, userId), role, PortalSettings, chkNotify.Checked))
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("RoleRemoveError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                }
                BindGrid();
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("RoleRemoveError", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                UserInfo objUserInfo = null;
                int intUserID = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }
                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }
                string strProcessorUserId = "";
                var objPortalController = new PortalController();
                PortalInfo objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }
                Dictionary<string, string> settings = PortalController.GetPortalSettingsDictionary(PortalSettings.PortalId);
                string strPayPalURL;
                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    // Sandbox mode
                    if (settings.ContainsKey("paypalsandbox") && !String.IsNullOrEmpty(settings["paypalsandbox"]) && settings["paypalsandbox"] == "true")
                    {
                        strPayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
                    }
                    else
                    {
                        strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";
                    }

                    if (Request.QueryString["cancel"] != null)
                    {
                        //build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";
                        var objRoles = new RoleController();
                        RoleInfo objRole = objRoles.GetRole(intRoleId, PortalSettings.PortalId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }

                            //explicitely format numbers using en-US so numbers are correctly built
                            var enFormat = new CultureInfo("en-US");
                            string strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string strTrial = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);
                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")
                            {
                                //build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                //build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " every " + intBillingPeriod + " " + GetBillingFrequencyCode(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }
                        var ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region);
                                strPayPalURL += "&address1=" +
                                                Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") +
                                                                       objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch (Exception ex)
                        {
                            //issue getting user address
                            DnnLog.Error(ex);
                        }

                        //Return URL
                        if (settings.ContainsKey("paypalsubscriptionreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptionreturn"]))
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Cancellation URL
                        if (settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"]))
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptioncancelreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Instant Payment Notification URL
                        if (settings.ContainsKey("paypalsubscriptionnotifyurl") && !string.IsNullOrEmpty(settings["paypalsubscriptionnotifyurl"]))
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionnotifyurl"]);
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }
                        strPayPalURL += "&sra=1"; //reattempt on failure
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    if ((settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"])))
                    {
                        strPayPalURL = settings["paypalsubscriptioncancelreturn"];
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
Beispiel #37
0
        private void GetControl(string view, string options)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    plhLoader.Controls.Clear();
                }
                ForumBase ctl = null;
                if (view.ToUpperInvariant() == "FORUMVIEW")
                {
                    ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView());
                }
                else if (view.ToUpperInvariant() == "ADVANCED")
                {
                    ctl = (ForumBase)(LoadControl("~/desktopmodules/activeforums/advanced.ascx"));
                }
                else if ((view.ToUpperInvariant() == Views.Topics.ToUpperInvariant()) || (view.ToUpperInvariant() == "topics".ToUpperInvariant()))
                {
                    ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicsView());
                }
                else if ((view.ToUpperInvariant() == Views.Topic.ToUpperInvariant()) || (view.ToUpperInvariant() == "topic".ToUpperInvariant()))
                {
                    ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicView());
                }
                else if (view.ToUpperInvariant() == "USERSETTINGS".ToUpperInvariant())
                {
                    string ctlPath = string.Empty;
                    ctlPath = "~/DesktopModules/ActiveForums/controls/af_profile.ascx";
                    if (!(System.IO.File.Exists(Server.MapPath(ctlPath))))
                    {
                        ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView());
                    }
                    else
                    {
                        ctl = (ForumBase)(LoadControl(ctlPath));
                    }
                }
                else
                {
                    string ctlPath = string.Empty;
                    ctlPath = "~/DesktopModules/ActiveForums/controls/af_" + view + ".ascx";
                    if (!(System.IO.File.Exists(Server.MapPath(ctlPath))))
                    {
                        ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView());
                    }
                    else
                    {
                        ctl = (ForumBase)(LoadControl(ctlPath));
                    }

                }
                if (ForumId > 0 & ForumInfo != null)
                {
                    ctl.ForumInfo = ForumInfo;
                }
                ctl.ID = view;
                ctl.ForumId = ForumId;
                ctl.ForumModuleId = ForumModuleId;
                if (ForumTabId == -1)
                {
                    ForumTabId = TabId;
                }
                ctl.ForumTabId = ForumTabId;
                ctl.ForumGroupId = ForumGroupId;
                ctl.DefaultForumViewTemplateId = DefaultForumViewTemplateId;
                ctl.DefaultTopicsViewTemplateId = DefaultTopicsViewTemplateId;
                ctl.DefaultTopicViewTemplateId = DefaultTopicViewTemplateId;
                ctl.UseTemplatePath = UseTemplatePath;
                ctl.TemplatePath = TemplatePath;
                ctl.ParentForumId = ParentForumId;
                if (string.IsNullOrEmpty(ForumIds))
                {
                    ForumIds = UserForumsList;
                }

                if (SocialGroupId > 0)
                {
                    ForumController fc = new ForumController();
                    ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId);

                    if (string.IsNullOrEmpty(ForumIds))
                    {
                        RoleController rc = new RoleController();
                        RoleInfo role = rc.GetRole(SocialGroupId, PortalId);
                        //Create new forum
                        bool isPrivate = false;
                        if (!role.IsPublic)
                        {
                            isPrivate = true;
                        }
                        Entities.Modules.ModuleController objModules = new Entities.Modules.ModuleController();
                        Hashtable htSettings = objModules.GetTabModuleSettings(TabModuleId);

                        fc.CreateGroupForum(PortalId, ModuleId, SocialGroupId, Convert.ToInt32(htSettings["ForumGroupTemplate"].ToString()), role.RoleName + " Discussions", role.Description, isPrivate, htSettings["ForumConfig"].ToString());
                        ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId);
                    }
                }
                ctl.ForumIds = ForumIds;
                ctl.SocialGroupId = SocialGroupId;

                //ctl.PostID = PostID
                ctl.ModuleConfiguration = this.ModuleConfiguration;
                if (!(options == string.Empty))
                {
                    ctl.Params = options;
                }
                ControlsConfig cc = new ControlsConfig();
                cc.AppPath = Page.ResolveUrl("~/DesktopModules/ActiveForums/");
                cc.ThemePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme + "/");
                cc.TemplatePath = cc.ThemePath + "templates/";
                cc.SiteId = PortalId;
                cc.PageId = TabId;
                cc.InstanceId = ModuleId;
                cc.User = ForumUser;
                cc.DefaultViewRoles = Permissions.GetRoleIds(this.ModuleConfiguration.AuthorizedViewRoles.Split(';'), PortalId);
                cc.AdminRoles = Permissions.GetRoleIds(this.ModuleConfiguration.AuthorizedEditRoles.Split(';'), PortalId);
                cc.ProfileLink = ""; //GetProfileLink()
                cc.MembersLink = ""; // GetMembersLink()
                this.ControlConfig = cc;
                ctl.ControlConfig = cc;
                LinkControls(ctl.Controls);
                if (!(plhLoader.Controls.Contains(ctl)))
                {
                    plhLoader.Controls.Add(ctl);
                }
                string sOut = null;
                sOut = System.Environment.NewLine + "<!--  © 2004 - 2013 DNN Corp.,  All Rights Reserved -->" + System.Environment.NewLine;
                sOut += "<!-- Active Forums 5.0  -->" + System.Environment.NewLine;

                Literal lit = new Literal();
                lit.Text = sOut;
                plhLoader.Controls.Add(lit);
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.SortAscending.CssClass = this.SortFilesDescending ? "ButtonNormal" : "ButtonSelected";
            this.SortDescending.CssClass = !this.SortFilesDescending ? "ButtonNormal" : "ButtonSelected";

            this.extensionWhiteList = HostController.Instance.GetString("FileExtensions").ToLower();

            if (!string.IsNullOrEmpty(this.request.QueryString["mode"]))
            {
                this.currentSettings.SettingMode =
                    (SettingsMode)Enum.Parse(typeof(SettingsMode), this.request.QueryString["mode"]);
            }

            ProviderConfiguration providerConfiguration = ProviderConfiguration.GetProviderConfiguration("htmlEditor");
            Provider objProvider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];

            var settingsDictionary = Utility.GetEditorHostSettings();
            var portalRoles = new RoleController().GetPortalRoles(this._portalSettings.PortalId);

            switch (this.currentSettings.SettingMode)
            {
                case SettingsMode.Default:
                    // Load Default Settings
                    this.currentSettings = SettingsUtil.GetDefaultSettings(
                        this._portalSettings,
                        this._portalSettings.HomeDirectoryMapPath,
                        objProvider.Attributes["ck_configFolder"],
                        portalRoles);
                    break;
                case SettingsMode.Portal:
                    this.currentSettings = SettingsUtil.LoadPortalOrPageSettings(
                        this._portalSettings,
                        this.currentSettings,
                        settingsDictionary,
                        string.Format("DNNCKP#{0}#", this.request.QueryString["PortalID"]),
                        portalRoles);
                    break;
                case SettingsMode.Page:
                    this.currentSettings = SettingsUtil.LoadPortalOrPageSettings(
                        this._portalSettings,
                        this.currentSettings,
                        settingsDictionary,
                        string.Format("DNNCKT#{0}#", this.request.QueryString["tabid"]),
                        portalRoles);
                    break;
                case SettingsMode.ModuleInstance:
                    this.currentSettings = SettingsUtil.LoadModuleSettings(
                        this._portalSettings,
                        this.currentSettings,
                        string.Format(
                            "DNNCKMI#{0}#INS#{1}#", this.request.QueryString["mid"], this.request.QueryString["ckId"]),
                        int.Parse(this.request.QueryString["mid"]),
                        portalRoles);
                    break;
            }

            if (this.currentSettings.BrowserMode.Equals(Constants.Browser.StandardBrowser)
                && HttpContext.Current.Request.IsAuthenticated)
            {
                string command = null;

                try
                {
                    if (this.request.QueryString["Command"] != null)
                    {
                        command = this.request.QueryString["Command"];
                    }
                }
                catch (Exception)
                {
                    command = null;
                }

                try
                {
                    if (this.request.QueryString["Type"] != null)
                    {
                        this.browserModus = this.request.QueryString["Type"];
                        this.lblModus.Text = string.Format("Browser-Modus: {0}", this.browserModus);

                        if (!this.IsPostBack)
                        {
                            this.OverrideFile.Checked = this.currentSettings.OverrideFileOnUpload;

                            this.title.InnerText = string.Format("{0} - WatchersNET.FileBrowser", this.lblModus.Text);

                            this.AnchorList.Visible = this.currentSettings.UseAnchorSelector;
                            this.LabelAnchor.Visible = this.currentSettings.UseAnchorSelector;

                            this.ListViewState.Value = this.currentSettings.FileListViewMode.ToString();

                            // Set default link mode
                            switch (this.currentSettings.DefaultLinkMode)
                            {
                                case LinkMode.RelativeURL:
                                    this.rblLinkType.SelectedValue = "relLink";
                                    break;
                                case LinkMode.AbsoluteURL:
                                    this.rblLinkType.SelectedValue = "absLnk";
                                    break;
                                case LinkMode.RelativeSecuredURL:
                                    this.rblLinkType.SelectedValue = "lnkClick";
                                    break;
                                case LinkMode.AbsoluteSecuredURL:
                                    this.rblLinkType.SelectedValue = "lnkAbsClick";
                                    break;
                            }

                            switch (this.browserModus)
                            {
                                case "Link":
                                    this.BrowserMode.Visible = true;

                                    if (this.currentSettings.ShowPageLinksTabFirst)
                                    {
                                        this.BrowserMode.SelectedValue = "page";
                                        this.panLinkMode.Visible = false;
                                        this.panPageMode.Visible = true;

                                        this.TrackClicks.Visible = false;
                                        this.lblModus.Text = string.Format(
                                            "Browser-Modus: {0}", string.Format("Page {0}", this.browserModus));
                                        this.title.InnerText = string.Format(
                                            "{0} - WatchersNET.FileBrowser", this.lblModus.Text);

                                        this.RenderTabs();
                                    }
                                    else
                                    {
                                        this.BrowserMode.SelectedValue = "file";
                                        this.panPageMode.Visible = false;
                                    }

                                    break;
                                case "Image":
                                    this.BrowserMode.Visible = false;
                                    this.panPageMode.Visible = false;
                                    break;
                                case "Flash":
                                    this.BrowserMode.Visible = false;
                                    this.panPageMode.Visible = false;
                                    break;
                                default:
                                    this.BrowserMode.Visible = false;
                                    this.panPageMode.Visible = false;
                                    break;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    this.browserModus = null;
                }

                if (command != null)
                {
                    if (!command.Equals("FileUpload") && !command.Equals("FlashUpload")
                        && !command.Equals("ImageUpload"))
                    {
                        return;
                    }

                    var uploadedFile =
                        HttpContext.Current.Request.Files[HttpContext.Current.Request.Files.AllKeys[0]];

                    if (uploadedFile != null)
                    {
                        this.UploadFile(uploadedFile, command);
                    }
                }
                else
                {
                    if (!this.IsPostBack)
                    {
                        this.SetLanguage();

                        this.GetLanguageList();

                        var startFolder = this.StartingDir();

                        if (!Utility.IsInRoles(this._portalSettings.AdministratorRoleName, this._portalSettings))
                        {
                            // Hide physical file Path
                            this.lblCurrentDir.Visible = false;
                            this.lblCurrent.Visible = false;
                        }

                        this.FillFolderTree(startFolder);

                        bool folderSelected = false;

                        if (!string.IsNullOrEmpty(ckFileUrl))
                        {
                            try
                            {
                                folderSelected = this.SelectFolderFile(ckFileUrl);
                                ckFileUrl = null;
                            }
                            catch (Exception)
                            {
                                folderSelected = false;
                                ckFileUrl = null;
                            }
                        }

                        if (!folderSelected)
                        {
                            this.lblCurrentDir.Text = startFolder.PhysicalPath;

                            this.ShowFilesIn(startFolder);
                        }
                    }

                    this.FillQualityPrecentages();
                }
            }
            else
            {
                var errorScript = string.Format(
                    "javascript:alert('{0}');self.close();",
                    Localization.GetString("Error1.Text", this.ResXFile, this.LanguageCode));

                this.Response.Write("<script type=\"text/javascript\">");
                this.Response.Write(errorScript);
                this.Response.Write("</script>");

                this.Response.End();
            }
        }
        /// <summary>
        /// Load All Editor Settings
        /// </summary>
        /// <param name="currentMode">The current mode.</param>
        /// <param name="changeMode">if set to <c>true</c> [change mode].</param>
        private void LoadSettings(int currentMode, bool changeMode = true)
        {
            this.CurrentSettingsMode = (SettingsMode)Enum.Parse(typeof(SettingsMode), currentMode.ToString());

            this.lnkRemoveAll.Visible = !currentMode.Equals(0);
            this.lnkRemoveChild.Visible = !currentMode.Equals(0);
            this.CopyToAllChild.Visible = !currentMode.Equals(0);

            this.lnkRemove.Text = string.Format(
                Localization.GetString("Remove.Text", this.ResXFile, this.LangCode),
                this.rBlSetMode.Items[currentMode].Text);
            this.lnkRemoveAll.Text =
                string.Format(
                    Localization.GetString("RemoveAll.Text", this.ResXFile, this.LangCode),
                    this.rBlSetMode.Items[currentMode].Text);

            this.lnkRemove.ToolTip = string.Format(
                Localization.GetString("Remove.Help", this.ResXFile, this.LangCode),
                this.rBlSetMode.Items[currentMode].Text);
            this.lnkRemoveAll.ToolTip =
                string.Format(
                    Localization.GetString("RemoveAll.Help", this.ResXFile, this.LangCode),
                    this.rBlSetMode.Items[currentMode].Text);

            this.LoadDefaultSettings();

            var settingsDictionary = Utility.GetEditorHostSettings();
            var portalRoles = new RoleController().GetPortalRoles(this._portalSettings.PortalId);

            var portalKey = string.Format("DNNCKP#{0}#", this._portalSettings.PortalId);
            var pageKey = string.Format("DNNCKT#{0}#", this.CurrentOrSelectedTabId);
            var moduleKey = string.Format("DNNCKMI#{0}#INS#{1}#", this.ModuleId, this.moduleInstanceName);

            var providerConfiguration = ProviderConfiguration.GetProviderConfiguration("htmlEditor");
            var objProvider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];

            var currentSettings = SettingsUtil.GetDefaultSettings(
                this._portalSettings,
                this._portalSettings.HomeDirectoryMapPath,
                objProvider.Attributes["ck_configFolder"],
                portalRoles);

            switch (this.CurrentSettingsMode)
            {
                case SettingsMode.Portal:
                    {
                        // Load Portal Settings ?!
                        if (SettingsUtil.CheckExistsPortalOrPageSettings(settingsDictionary, portalKey))
                        {
                            currentSettings = new EditorProviderSettings();

                            currentSettings = SettingsUtil.LoadPortalOrPageSettings(
                                this._portalSettings, currentSettings, settingsDictionary, portalKey, portalRoles);

                            // Set Current Mode to Portal
                            currentSettings.SettingMode = SettingsMode.Portal;

                            this.lnkRemove.Enabled = true;
                        }
                        else
                        {
                            this.lnkRemove.Enabled = false;
                        }
                    }

                    break;
                case SettingsMode.Page:
                    {
                        // Load Page Settings ?!
                        if (SettingsUtil.CheckExistsPortalOrPageSettings(settingsDictionary, pageKey))
                        {
                            currentSettings = new EditorProviderSettings();

                            currentSettings = SettingsUtil.LoadPortalOrPageSettings(
                                this._portalSettings, currentSettings, settingsDictionary, pageKey, portalRoles);

                            // Set Current Mode to Page
                            currentSettings.SettingMode = SettingsMode.Page;

                            this.lnkRemove.Enabled = true;
                        }
                        else
                        {
                            this.lnkRemove.Enabled = false;
                        }

                        var currentTab = new TabController().GetTab(
                            this.CurrentOrSelectedTabId, this._portalSettings.PortalId, false);

                        this.lnkRemoveChild.Enabled = currentTab.HasChildren;

                        this.lnkRemoveChild.Text = Localization.GetString(
                                "RemovePageChild.Text", this.ResXFile, this.LangCode);
                        this.lnkRemoveChild.ToolTip = Localization.GetString(
                            "RemovePageChild.Help", this.ResXFile, this.LangCode);

                        this.CopyToAllChild.Enabled = currentTab.HasChildren;

                        this.CopyToAllChild.Text = Localization.GetString(
                                "CopyPageChild.Text", this.ResXFile, this.LangCode);
                        this.CopyToAllChild.ToolTip = Localization.GetString(
                            "CopyPageChild.Help", this.ResXFile, this.LangCode);
                    }

                    break;
                case SettingsMode.ModuleInstance:
                    {
                        // Load Module Settings ?!
                        if (SettingsUtil.CheckExistsModuleInstanceSettings(moduleKey, this.ModuleId))
                        {
                            currentSettings = new EditorProviderSettings();

                            currentSettings = SettingsUtil.LoadModuleSettings(
                                this._portalSettings, currentSettings, moduleKey, this.ModuleId, portalRoles);

                            currentSettings.SettingMode = SettingsMode.ModuleInstance;

                            this.lnkRemove.Enabled = true;
                        }
                        else
                        {
                            this.lnkRemove.Enabled = false;
                        }

                        this.lnkRemoveChild.Enabled = true;

                        this.lnkRemoveChild.Text = Localization.GetString(
                            "RemoveModuleChild.Text", this.ResXFile, this.LangCode);
                        this.lnkRemoveChild.ToolTip = Localization.GetString(
                            "RemoveModuleChild.Help", this.ResXFile, this.LangCode);
                    }

                    break;
            }

            if (currentSettings != null)
            {
                this.FillSettings(currentSettings, changeMode);
            }
        }
Beispiel #40
0
    protected void BT_Refresh_AAR_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(Config.GetConnectionString());

        try
        {
            conn.Open();

            int annee = Functions.GetRotaryYear();

            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            RoleInfo  uri   = rc.GetRoleByName(Globals.GetPortalSettings().PortalId, Const.ROLE_ADMIN_CLUB);
            ArrayList users = rc.GetUsersByRoleName(PortalId, Const.ROLE_ADMIN_CLUB);
            foreach (UserInfo user in users)
            {
                rc.DeleteUserRole(Globals.GetPortalSettings().PortalId, user.UserID, uri.RoleID);
            }

            SqlCommand     sql = new SqlCommand("SELECT nim,name FROM " + Const.TABLE_PREFIX + "rya WHERE rotary_year IN (" + annee + "," + (annee + 1) + ")", conn);
            SqlDataAdapter da  = new SqlDataAdapter(sql);
            DataSet        ds  = new DataSet();
            da.Fill(ds);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
cestbon:

                Member membre = DataMapping.GetMemberByNim((int)row["nim"]);
                if (membre != null)
                {
                    if (membre.userid == 0)
                    {
                        TXT_Result.Text += "<br/>Le membre : " + row["name"] + " n'a pas de user DNN";
                        if (DataMapping.UpdateOrCreateUser(membre.id, membre.email))
                        {
                            TXT_Result.Text += "<br/>et a été créé";
                            goto cestbon;
                        }
                        else
                        {
                            TXT_Result.Text += "<br/>et n'a pas été créé";
                        }
                    }
                    else
                    {
                        UserInfo ui = UserController.GetUserByName(Globals.GetPortalSettings().PortalId, membre.email);
                        if (ui != null)
                        {
                            rc.AddUserRole(Globals.GetPortalSettings().PortalId, ui.UserID, uri.RoleID, Null.NullDate, Null.NullDate);
                            TXT_Result.Text += "<br/>Ajout role admin club : " + row["name"];
                        }
                    }
                }
            }
        }
        catch (Exception ee)
        {
            TXT_Result.Text += ee.ToString();
        }
        finally
        {
            conn.Close();
        }
    }
Beispiel #41
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// BindData gets the roles from the Database and binds them to the DataGrid
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    01/05/2006  Updated to reflect Use of Role Groups
        /// </history>
        /// -----------------------------------------------------------------------------
        private void BindData()
        {
            //Get the portal's roles from the database
            var objRoles = new RoleController();

            var arrRoles = _roleGroupId < -1 ? objRoles.GetPortalRoles(PortalId) : objRoles.GetRolesByGroup(PortalId, _roleGroupId);
            grdRoles.DataSource = arrRoles;

            if (_roleGroupId < 0)
            {
                lnkEditGroup.Visible = false;
                cmdDelete.Visible = false;
            }
            else
            {
                lnkEditGroup.Visible = true;
                lnkEditGroup.NavigateUrl = EditUrl("RoleGroupId", _roleGroupId.ToString(), "EditGroup");
                cmdDelete.Visible = arrRoles.Count == 0;
            }
            Localization.LocalizeDataGrid(ref grdRoles, LocalResourceFile);

            grdRoles.DataBind();
        }
Beispiel #42
0
        /// <summary>
        /// Gets the edit rights for user roles and binds them to the respective list control
        /// </summary>
        private void BindRights()
        {
            // declare variables
            ArrayList arrAvailableAuthViewRoles = new ArrayList();
            ArrayList arrAvailableNotifyRoles   = new ArrayList();
            ArrayList arrAssignedAuthViewRoles  = new ArrayList();
            ArrayList arrAssignedNotifyRoles    = new ArrayList();
            Array     arrAuthViewRoles          = null;
            Array     arrAuthNotifyRoles        = null;

            // add an entry of All Users for the View roles
            arrAvailableAuthViewRoles.Add(new ListItem("All Users", DotNetNuke.Common.Globals.glbRoleAllUsersName));

            // add an entry of Unauthenticated Users for the View roles
            arrAvailableAuthViewRoles.Add(new ListItem("Unauthenticated Users", DotNetNuke.Common.Globals.glbRoleUnauthUserName));

            // process portal roles
            DotNetNuke.Security.Roles.RoleController objRoles = new DotNetNuke.Security.Roles.RoleController();

            var arrRoles = objRoles.GetPortalRoles(PortalId).OfType <RoleInfo>();

            foreach (var objRole in arrRoles)
            {
                arrAvailableAuthViewRoles.Add(new ListItem(objRole.RoleName, objRole.RoleName));
                arrAvailableNotifyRoles.Add(new ListItem(objRole.RoleName, objRole.RoleName));
            }

            // populate view roles
            if (this.mSettingsModel.ContentEditorRoles.Equals(StrUseDNNSettings))
            {
                arrAuthViewRoles = this.mSettingsModel.ContentEditorRoles.Split(new string[] { StrUseDNNSettings }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                arrAuthViewRoles = this.mSettingsModel.ContentEditorRoles.Split(
                    new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0]
                                   .Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            }

            // populate the notify roles
            if (!string.IsNullOrWhiteSpace(this.mSettingsModel.CommentNotifyRoles))
            {
                if (this.mSettingsModel.CommentNotifyRoles.StartsWith("UseDNNSettings;"))
                {
                    this.mSettingsModel.CommentNotifyRoles = this.mSettingsModel.CommentNotifyRoles.Replace("UseDNNSettings;", string.Empty);
                    arrAuthNotifyRoles = this.mSettingsModel.CommentNotifyRoles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string curRole in arrAuthNotifyRoles)
                    {
                        if (curRole.Equals("View"))
                        {
                            this.NotifyMethodViewRoles.Checked = true;
                        }
                        else if (curRole.Equals("Edit"))
                        {
                            this.NotifyMethodEditRoles.Checked = true;
                        }
                    }
                }
                else
                {
                    arrAuthNotifyRoles = this.mSettingsModel.CommentNotifyRoles.Split(new char[] { '|' })[0].Split(new char[] { ';' });
                }
            }

            if (arrAuthViewRoles != null)
            {
                foreach (string strRole in arrAuthViewRoles)
                {
                    if (!string.IsNullOrEmpty(strRole))
                    {
                        foreach (ListItem objListItem in arrAvailableAuthViewRoles)
                        {
                            if (objListItem.Value == strRole)
                            {
                                arrAssignedAuthViewRoles.Add(objListItem);
                                arrAvailableAuthViewRoles.Remove(objListItem);
                                break;
                            }
                        }
                    }
                }
            }

            if (arrAuthNotifyRoles != null)
            {
                foreach (string strRole in arrAuthNotifyRoles)
                {
                    if (!string.IsNullOrEmpty(strRole))
                    {
                        foreach (ListItem objListItem in arrAvailableNotifyRoles)
                        {
                            if (objListItem.Value == strRole)
                            {
                                arrAssignedNotifyRoles.Add(objListItem);
                                arrAvailableNotifyRoles.Remove(objListItem);
                                break;
                            }
                        }
                    }
                }
            }

            int x = arrAvailableAuthViewRoles.Count; // TODO Do we need this?
            int y = arrAssignedAuthViewRoles.Count;  // TODO Do we need this?

            this.ContentEditors.Available = arrAvailableAuthViewRoles;
            this.ContentEditors.Assigned  = arrAssignedAuthViewRoles;

            this.NotifyRoles.Assigned  = arrAssignedNotifyRoles;
            this.NotifyRoles.Available = arrAvailableNotifyRoles;
        }
Beispiel #43
0
    protected void BT_Maj_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(Config.GetConnectionString());

        try
        {
            conn.Open();
            TXT_Result.Text = "<br/>";
            /****** Script de la commande SelectTopNRows à partir de SSMS  ******/
            SqlCommand     sql = new SqlCommand("SELECT * FROM [admin_club] where open_passwd !='' and fonction like 'new_%' and cric !='' and cric is not null", conn);
            SqlDataAdapter da  = new SqlDataAdapter(sql);
            DataSet        ds  = new DataSet();
            da.Fill(ds);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                sql = new SqlCommand("SELECT id FROM " + Const.TABLE_PREFIX + "members WHERE nim=@nim", conn);
                sql.Parameters.AddWithValue("nim", row["nim"]);
                string id  = "" + sql.ExecuteScalar();
                int    idn = 0;
                int.TryParse(id, out idn);
                if (idn != 0)
                {
                    Member member = DataMapping.GetMember(idn);
                    if (member.userid == 0)
                    {
                        UserInfo ui = UserController.GetUserByName(Globals.GetPortalSettings().PortalId, member.email);
                        if (ui == null && member != null)
                        {
                            TXT_Result.Text += "Creation : " + member.surname + " " + member.name + "<br/>";
                            ui             = new UserInfo();
                            ui.Username    = member.email;
                            ui.FirstName   = member.name;
                            ui.LastName    = member.surname;
                            ui.DisplayName = member.name + " " + member.surname;
                            ui.Email       = member.email;
                            ui.IsSuperUser = false;
                            ui.PortalID    = Globals.GetPortalSettings().PortalId;

                            UserMembership mb = new UserMembership(ui);
                            mb.Approved    = true;
                            mb.CreatedDate = System.DateTime.Now;
                            mb.IsOnLine    = false;

                            string password = "" + DateTime.Now.Ticks;
                            password = "" + row["open_passwd"];
                            //password = "******";
                            mb.Password = password;

                            ui.Membership = mb;


                            if (UserCreateStatus.Success == UserController.CreateUser(ref ui))
                            {
                                DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
                                RoleInfo uri = rc.GetRoleByName(Globals.GetPortalSettings().PortalId, Const.ROLE_MEMBERS);
                                rc.AddUserRole(Globals.GetPortalSettings().PortalId, ui.UserID, uri.RoleID, Null.NullDate, Null.NullDate);


                                TXT_Result.Text += DataMapping.UpdateMemberDNNUserID(member.id, ui.UserID) + "<br/>";
                            }
                        }
                    }
                }
                else
                {
                    TXT_Result.Text += "NIM inconnu : " + row["nim"] + " " + row["surname"] + " " + row["name"] + "<br/>";
                }
            }
        }
        catch (Exception ee)
        {
            TXT_Result.Text += ee.ToString();
        }
        finally
        {
            conn.Close();
        }
    }
        /// <summary>
        /// 绑定数据项
        /// </summary>
        private void BindDataItem()
        {
            Playngo_ClientZone_Event Event = EventItem;
            TemplateFormat           xf    = new TemplateFormat(this);

            //验证文章是否存在
            if (EventID > 0 && (Event == null || EventID != Event.ID))
            {
                //需要给出提示,载入文章错误
                mTips.LoadMessage("LoadingEventError", EnumTips.Error, this, new String[] { "" });
                Response.Redirect(xUrl("Events"), false);
            }

            if (Event == null)
            {
                Event = new Playngo_ClientZone_Event();
            }



            //这里需要验证一下权限,当作者进入到别人的文章时,需要跳到列表页面
            if (Event != null && Event.ID > 0 && (!IsAdministrator && !IsAdmin) && Event.CreateUser != UserId)
            {
                //需要给出提示,你无权编辑其他作者的文章
                mTips.LoadMessage("NoPermissionEventAlert", EnumTips.Warning, this, new String[] { Event.Title });
                Response.Redirect(xUrl("Events"), false);
            }


            if (Event != null && Event.ID > 0)
            {
                liLastUpdated.Text = Event.LastTime.ToString("MM/dd/yyyy hh:mm tt", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }

            //导出CSV链接
            hlExportCSV.NavigateUrl = xf.GoDownloadCSVToEventUrl(Event);


            txtTitle.Text       = Common.RestoreEscape(Event.Title);
            txtContentText.Text = HttpUtility.HtmlDecode(Event.ContentText);


            txtAddress.Text   = Event.Address;
            txtLocationX.Text = Event.LocationX;
            txtLocationY.Text = Event.LocationY;



            cbIncludeNotification.Checked = Event.NotifyInclude == 1;
            WebHelper.SelectedListByValue(ddlNotificationStatus, Event.NotifyStatus);
            cbNotifySubscribers.Checked = Event.NotifySubscribers == 1;


            txtStartDate.Text = Event.StartTime.ToString("MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            txtStartTime.Text = Event.StartTime.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);

            txtReleaseDate.Text = Event.ReleaseDate.ToString("MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            txtReleaseTime.Text = Event.ReleaseDate.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);

            txtDisableDate.Text = Event.EndTime.ToString("MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            txtDisableTime.Text = Event.EndTime.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);



            //增加权限用户
            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            WebHelper.BindList(cblPermissionsRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName");
            WebHelper.SelectedListMultiByValue(cblPermissionsRoles, Event.Per_Roles);

            cbPermissionsAllUsers.Checked = Event.Per_AllUsers == 0;



            //区域
            cbAllJurisdictions.Checked = Event.Per_AllJurisdictions == 0;
            WebHelper.BindList(cblJurisdictions, Playngo_ClientZone_Jurisdiction.GetAllCheckList(ModuleId), "Name", "ID");
            WebHelper.SelectedListMultiByValue(cblJurisdictions, Event.Per_Jurisdictions);



            Event.CreateUser = Event.CreateUser == 0 ? UserId : Event.CreateUser;
            UserInfo CreateUserInfo = UserController.GetUserById(PortalId, Event.CreateUser);

            hfEventAuthor.Value     = Event.CreateUser.ToString();
            lbEventAuthor.Text      = CreateUserInfo != null && CreateUserInfo.UserID > 0 ? CreateUserInfo.DisplayName : "None";
            imgEventAuthor.ImageUrl = ViewUserPic(CreateUserInfo);


            WebHelper.SelectedListByValue(ddlEventStatus, Event.Status); //管理员看到的文章状态
        }