Example #1
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() }));
            }
        }
Example #2
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));
                }
            }
        }
Example #3
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;
        }
Example #4
0
 protected bool ShowTrial(int roleID)
 {
     var objRoles = new RoleController();
     bool showTrial = Null.NullBoolean;
     RoleInfo objRole = objRoles.GetRole(roleID, PortalSettings.PortalId);
     if (objRole.TrialFrequency == "N" || (objRole.IsPublic && objRole.ServiceFee == 0.0))
     {
         showTrial = Null.NullBoolean;
     }
     else if (objRole.IsPublic && objRole.TrialFee == 0.0)
     {
         //Use Trial?
         UserRoleInfo objUserRole = objRoles.GetUserRole(PortalId, UserInfo.UserID, roleID);
         if ((objUserRole == null) || (!objUserRole.IsTrialUsed))
         {
             showTrial = true;
         }
     }
     return showTrial;
 }
Example #5
0
        private void Subscribe(int roleID, bool cancel)
        {
            var objRoles = new RoleController();
            RoleInfo objRole = objRoles.GetRole(roleID, PortalSettings.PortalId);

            if (objRole.IsPublic && objRole.ServiceFee == 0.0)
            {
                objRoles.UpdateUserRole(PortalId, UserInfo.UserID, roleID, cancel);

                //Raise SubscriptionUpdated Event
                OnSubscriptionUpdated(new SubscriptionUpdatedEventArgs(cancel, objRole.RoleName));
            }
            else
            {
                if (!cancel)
                {
                    Response.Redirect("~/admin/Sales/PayPalSubscription.aspx?tabid=" + TabId + "&RoleID=" + roleID, true);
                }
                else
                {
                    Response.Redirect("~/admin/Sales/PayPalSubscription.aspx?tabid=" + TabId + "&RoleID=" + roleID + "&cancel=1", true);
                }
            }
        }
        private bool CheckSecurity()
        {
            bool boolPassedSecurity = false;
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            HelpDesk_Task objHelpDesk_Tasks = (from HelpDesk_Tasks in objHelpDeskDALDataContext.HelpDesk_Tasks
                                                       where HelpDesk_Tasks.TaskID == Convert.ToInt32(Request.QueryString["TaskID"])
                                                       select HelpDesk_Tasks).FirstOrDefault();
            if (objHelpDesk_Tasks == null)
            {
                pnlEditTask.Visible = false;
                Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
            }

            // User not logged in
            if (UserId == -1)
            {
                // Must have the valid password
                if (Request.QueryString["TP"] != null)
                {
                    // Check the password for this Ticket
                    if (objHelpDesk_Tasks.TicketPassword == Convert.ToString(Request.QueryString["TP"]))
                    {
                        boolPassedSecurity = true;
                    }
                    else
                    {
                        boolPassedSecurity = false;
                    }
                }
            }

            // User is logged in
            if (UserId > -1)
            {
                // Is user an Admin?
                string strAdminRoleID = GetAdminRole();
                if (UserInfo.IsInRole(strAdminRoleID) || UserInfo.IsInRole("Administrators") || UserInfo.IsSuperUser)
                {
                    boolPassedSecurity = true;
                    CommentsControl.ViewOnly = false;
                }

                // Is user the Requestor?
                if (UserId == objHelpDesk_Tasks.RequesterUserID)
                {
                    boolPassedSecurity = true;
                }

                //Is user in the Assigned Role?
                RoleController objRoleController = new RoleController();
                RoleInfo objRoleInfo = objRoleController.GetRole(objHelpDesk_Tasks.AssignedRoleID, PortalId);
                if (objRoleInfo != null)
                {
                    if (UserInfo.IsInRole(objRoleInfo.RoleName))
                    {
                        boolPassedSecurity = true;
                        CommentsControl.ViewOnly = false;
                    }
                }

                // Does user have a valid temporary password?
                if (Request.QueryString["TP"] != null)
                {
                    // Check the password for this Ticket
                    if (objHelpDesk_Tasks.TicketPassword == Convert.ToString(Request.QueryString["TP"]))
                    {
                        boolPassedSecurity = true;
                    }
                    else
                    {
                        boolPassedSecurity = false;
                    }
                }
            }

            return boolPassedSecurity;
        }
        private ModulePermissionInfo AddModulePermission(int moduleId, PermissionInfo permission, int roleId)
        {
            RoleController objRoles = new RoleController();
            string roleName = Null.NullString;
            ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
            objModulePermission.ModuleID = moduleId;
            objModulePermission.PermissionID = permission.PermissionID;
            objModulePermission.RoleID = roleId;
            objModulePermission.PermissionKey = permission.PermissionKey;
            objModulePermission.AllowAccess = false;

            if (roleId == int.Parse(Globals.glbRoleUnauthUser))
            {
                roleName = Globals.glbRoleUnauthUserName;
            }
            else if (roleId == int.Parse(Globals.glbRoleAllUsers))
            {
                roleName = Globals.glbRoleAllUsersName;
            }
            else
            {
                RoleInfo objRole = objRoles.GetRole(objModulePermission.RoleID, PortalSettings.PortalId);
                if (objRole != null)
                {
                    roleName = objRole.RoleName;
                }
            }
            if (!(string.IsNullOrEmpty(roleName)))
            {
                if (PortalSettings.ActiveTab.AdministratorRoles.IndexOf(roleName) != -1)
                {
                    objModulePermission.AllowAccess = true;
                }
            }
            return objModulePermission;
        }
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/13/2006
        /// </history>
        protected void Page_Load( Object sender, EventArgs e )
        {
            try
            {
                if( ( Request.QueryString["Services"] != null ) )
                {
                    Services = int.Parse( Request.QueryString["Services"] );
                }

                // free subscriptions
                if( ( Request.QueryString["RoleID"] != null ) )
                {
                    RoleID = int.Parse( Request.QueryString["RoleID"] );

                    RoleController objRoles = new RoleController();

                    RoleInfo objRole = objRoles.GetRole( RoleID, PortalSettings.PortalId );

                    if( objRole.IsPublic && objRole.ServiceFee == 0.0 )
                    {
                        objRoles.UpdateUserRole( PortalId, UserInfo.UserID, RoleID, Convert.ToBoolean( ( Request.QueryString["cancel"] != null ) ? true : false ) );

                        if( PortalSettings.UserTabId != - 1 )
                        {
                            // user defined tab
                            Response.Redirect( Globals.NavigateURL( PortalSettings.UserTabId ), true );
                        }
                        else
                        {
                            // admin tab
                            Response.Redirect( Globals.NavigateURL( TabId, "profile", "UserID=" + UserInfo.UserID ), true );
                        }
                    }
                    else
                    {
                        // EVENTLOGGER
                    }
                }

                // If this is the first visit to the page, bind the role data to the datalist
                if( Page.IsPostBack == false )
                {
                    //Localize the Headers
                    Localization.LocalizeDataGrid(ref grdServices, this.LocalResourceFile);
                }
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        private void SaveMetadata()
        {
            var security = new DotNetNuke.Security.PortalSecurity();
            var ctlRole = new RoleController();
            var role = ctlRole.GetRole(GroupId, PortalId);

            var settingKey = security.InputFilter(txtSettingKey.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup);
            var settingValue = security.InputFilter(txtSettingValue.Text.Trim(), PortalSecurity.FilterFlag.NoScripting);

            if (role.Settings.ContainsKey(settingKey))
            {
                // update the existing key
                role.Settings[settingKey] = settingValue;
            }
            else
            {
                // add a new key
                role.Settings.Add(settingKey, settingValue);
            }

            TestableRoleController.Instance.UpdateRoleSettings(role, true);
        }
        private void GetRecipients(out List<string> objRoleNames, out List<UserInfo> objUsers)
        {
            objRoleNames = new List<string>();
            objUsers = new List<UserInfo>();

            if (!String.IsNullOrEmpty(txtEmail.Text))
            {
                Array arrEmail = txtEmail.Text.Split(';');
                foreach (string strEmail in arrEmail)
                {
                    var objUser = new UserInfo {UserID = Null.NullInteger, Email = strEmail, DisplayName = strEmail};
                    objUsers.Add(objUser);
                }
            }

            var roleController = new RoleController();
            objRoleNames.AddRange(recipients.Value.Split(',').Where(value => value.StartsWith("role-")).Select(value => roleController.GetRole(int.Parse(value.Substring(5)), PortalId).RoleName).Where(roleName => !string.IsNullOrWhiteSpace(roleName)));
            objUsers.AddRange(recipients.Value.Split(',').Where(value => value.StartsWith("user-")).Select(value => UserController.GetUserById(PortalId, int.Parse(value.Substring(5)))).Where(user => user != null));
        }
Example #11
0
        private void SaveSettings()
        {
            var ctlRole = new RoleController();
            RoleInfo role = ctlRole.GetRole(GroupId, PortalId);
            var sec = new PortalSecurity();

            role.RoleName = sec.InputFilter(txtGroupName.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup);

            SaveSetting(ref role, FeatureController.KEY_COUNTRY, cboCountry.SelectedValue);
            SaveSetting(ref role, FeatureController.KEY_COUNTRYFULL, cboCountry.SelectedItem.Text);

            SaveSetting(ref role, FeatureController.KEY_REGION, sec.InputFilter(ParseRegionSaveSetting(), PortalSecurity.FilterFlag.NoMarkup));
            if (role.Settings[FeatureController.KEY_REGION] == cboRegion.SelectedValue)
            {
                SaveSetting(ref role, FeatureController.KEY_REGIONFULL, cboRegion.SelectedItem.Text);
            }
            else
            {
                SaveSetting(ref role, FeatureController.KEY_REGIONFULL, sec.InputFilter(txtRegion.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));
            }

            SaveSetting(ref role, FeatureController.KEY_CITY, sec.InputFilter(txtCity.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_DEFAULTLANGUAGE, cboDefaultLanguage.SelectedValue);

            SaveSetting(ref role, FeatureController.KEY_WEBSITEURL, sec.InputFilter(txtWebsiteUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_FACEBOOKURL, sec.InputFilter(txtFacebookUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_TWITTERURL, sec.InputFilter(txtTwitterUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_LINKEDINURL, sec.InputFilter(txtLinkedInUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_GOOGLEPLUSURL, sec.InputFilter(txtGooglePlusUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_MEETUPURL, sec.InputFilter(txtMeetUpUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            SaveSetting(ref role, FeatureController.KEY_YOUTUBEURL, sec.InputFilter(txtYouTubeUrl.Text.Trim(), PortalSecurity.FilterFlag.NoMarkup));

            // update the role to save the name change
            ctlRole.UpdateRole(role);

            // save the settings
            TestableRoleController.Instance.UpdateRoleSettings(role, true);
        }
Example #12
0
        private void Create_Click(object sender, EventArgs e)
        {
            RoleController roleController = new RoleController();
            Security.PortalSecurity ps = new Security.PortalSecurity();
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);

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

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

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

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

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

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


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

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

            Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
        }
Example #13
0
        private void SendAdminNotification(UserInfo newUser, string notificationType, PortalSettings portalSettings)
        {
            var notification = new Notification
            {
                NotificationTypeID = NotificationsController.Instance.GetNotificationType(notificationType).NotificationTypeId,                
                IncludeDismissAction = true,
                SenderUserID = portalSettings.AdministratorId
            };
            notification.Subject = GetNotificationSubject(notificationType, newUser.Profile.PreferredLocale, newUser, portalSettings);
            notification.Body = GetNotificationBody(notificationType, newUser.Profile.PreferredLocale, newUser, portalSettings);
            var roleController = new RoleController();
            var adminrole = roleController.GetRole(portalSettings.AdministratorRoleId, portalSettings.PortalId);
            var roles = new List<RoleInfo>();
            roles.Add(adminrole);
            NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, roles, new List<UserInfo>());

        }
        // Emails

        #region NotifyAssignedGroupOfAssignment
        private void NotifyAssignedGroupOfAssignment()
        {
            RoleController objRoleController = new RoleController();
            string strAssignedRole = String.Format("{0}", objRoleController.GetRole(Convert.ToInt32(ddlAssigned.SelectedValue), PortalId).RoleName);
            string strLinkUrl = Utils.FixURLLink(DotNetNuke.Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "EditTask", "mid=" + ModuleId.ToString(), String.Format(@"&TaskID={0}", Request.QueryString["TaskID"])), PortalSettings.PortalAlias.HTTPAlias);

            string strSubject = "[" + Localization.GetString(String.Format("ddlStatusAdmin{0}.Text", ddlStatus.SelectedValue), LocalResourceFile) + "] " + String.Format(Localization.GetString("HelpDeskTicketAtHasBeenAssigned.Text", LocalResourceFile), Request.QueryString["TaskID"], PortalSettings.PortalAlias.HTTPAlias, strAssignedRole);
            string strBody = String.Format(Localization.GetString("ANewHelpDeskTicketHasBeenAssigned.Text", LocalResourceFile), Request.QueryString["TaskID"], txtDescription.Text);
            strBody = strBody + Environment.NewLine;
            strBody = strBody + String.Format(Localization.GetString("YouMaySeeStatusHere.Text", LocalResourceFile), strLinkUrl);

            // Get all users in the AssignedRole Role
            ArrayList colAssignedRoleUsers = objRoleController.GetUsersByRoleName(PortalId, strAssignedRole);

            foreach (UserInfo objUserInfo in colAssignedRoleUsers)
            {
                DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, objUserInfo.Email, "", strSubject, strBody, "", "HTML", "", "", "", "");
            }

            Log.InsertLog(Convert.ToInt32(Request.QueryString["TaskID"]), UserId, String.Format(Localization.GetString("AssignedTicketTo.Text", LocalResourceFile), UserInfo.DisplayName, strAssignedRole));
        }
        // Display Ticket Data

        #region DisplayTicketData
        private void DisplayTicketData()
        {
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            HelpDesk_Task objHelpDesk_Tasks = (from HelpDesk_Tasks in objHelpDeskDALDataContext.HelpDesk_Tasks
                                                       where HelpDesk_Tasks.TaskID == Convert.ToInt32(Request.QueryString["TaskID"])
                                                       select HelpDesk_Tasks).FirstOrDefault();

            // Name is editable only if user is Anonymous
            if (objHelpDesk_Tasks.RequesterUserID == -1)
            {
                txtEmail.Visible = true;
                txtName.Visible = true;
                lblEmail.Visible = false;
                lblName.Visible = false;
                txtEmail.Text = objHelpDesk_Tasks.RequesterEmail;
                txtName.Text = objHelpDesk_Tasks.RequesterName;
            }
            else
            {
                txtEmail.Visible = false;
                txtName.Visible = false;
                lblEmail.Visible = true;
                lblName.Visible = true;


				UserInfo objRequester = //UserController.GetUser(PortalId, objHelpDesk_Tasks.RequesterUserID, false);
					UserController.GetUserById (PortalId, objHelpDesk_Tasks.RequesterUserID);

                if (objRequester != null)
                {
					lblEmail.Text = objRequester.Email; // UserController.GetUser(PortalId, objHelpDesk_Tasks.RequesterUserID, false).Email;
					lblName.Text = objRequester.DisplayName; // UserController.GetUser(PortalId, objHelpDesk_Tasks.RequesterUserID, false).DisplayName;
                }
                else
                {
                    lblName.Text = "[User Deleted]";
                }
            }

            lblTask.Text = objHelpDesk_Tasks.TaskID.ToString();
            lblCreated.Text = String.Format(Localization.GetString("Created.Text", LocalResourceFile), objHelpDesk_Tasks.CreatedDate.ToShortDateString(), objHelpDesk_Tasks.CreatedDate.ToShortTimeString());
            ddlStatus.SelectedValue = objHelpDesk_Tasks.Status;
            ddlPriority.SelectedValue = objHelpDesk_Tasks.Priority;
            txtDescription.Text = objHelpDesk_Tasks.Description;
            txtPhone.Text = objHelpDesk_Tasks.RequesterPhone;
            txtDueDate.Text = (objHelpDesk_Tasks.DueDate.HasValue) ? objHelpDesk_Tasks.DueDate.Value.ToShortDateString() : "";
            txtStart.Text = (objHelpDesk_Tasks.EstimatedStart.HasValue) ? objHelpDesk_Tasks.EstimatedStart.Value.ToShortDateString() : "";
            txtComplete.Text = (objHelpDesk_Tasks.EstimatedCompletion.HasValue) ? objHelpDesk_Tasks.EstimatedCompletion.Value.ToShortDateString() : "";
            txtEstimate.Text = (objHelpDesk_Tasks.EstimatedHours.HasValue) ? objHelpDesk_Tasks.EstimatedHours.Value.ToString() : "";

            ListItem TmpRoleListItem = ddlAssigned.Items.FindByValue(objHelpDesk_Tasks.AssignedRoleID.ToString());
            if (TmpRoleListItem == null)
            {
                // Value was not found so add it
                RoleController objRoleController = new RoleController();
                RoleInfo objRoleInfo = objRoleController.GetRole(objHelpDesk_Tasks.AssignedRoleID, PortalId);

                if (objRoleInfo != null)
                {
                    ListItem RoleListItem = new ListItem();
                    RoleListItem.Text = objRoleInfo.RoleName;
                    RoleListItem.Value = objHelpDesk_Tasks.AssignedRoleID.ToString();
                    ddlAssigned.Items.Add(RoleListItem);

                    ddlAssigned.SelectedValue = objHelpDesk_Tasks.AssignedRoleID.ToString();
                }
                else
                {
                    // Role no longer exists in Portal
                    ddlAssigned.SelectedValue = "-1";
                }
            }
            else
            {
                // The Value already exists so set it
                ddlAssigned.SelectedValue = objHelpDesk_Tasks.AssignedRoleID.ToString();
            }
        }
        // Tags

        #region DisplayCategoryTree
        private void DisplayCategoryTree()
        {
            bool boolUserAssignedToTask = false;
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            HelpDesk_Task objHelpDesk_Tasks = (from HelpDesk_Tasks in objHelpDeskDALDataContext.HelpDesk_Tasks
                                                       where HelpDesk_Tasks.TaskID == Convert.ToInt32(Request.QueryString["TaskID"])
                                                       select HelpDesk_Tasks).FirstOrDefault();

            //Is user in the Assigned Role?
            RoleController objRoleController = new RoleController();
            RoleInfo objRoleInfo = objRoleController.GetRole(objHelpDesk_Tasks.AssignedRoleID, PortalId);

            if (objRoleInfo != null)
            {
                if (UserInfo.IsInRole(objRoleInfo.RoleName))
                {
                    boolUserAssignedToTask = true;
                }
            }

            if (boolUserAssignedToTask || UserInfo.IsInRole(GetAdminRole()) || UserInfo.IsInRole("Administrators") || UserInfo.IsSuperUser)
            {
                // Show all Tags
                TagsTreeExistingTasks.Visible = true;
                TagsTreeExistingTasks.TagID = Convert.ToInt32(Request.QueryString["TaskID"]);
                TagsTreeExistingTasks.DisplayType = "Administrator";
                TagsTreeExistingTasks.Expand = false;
            }
            else
            {
                // Show only Visible Tags
                TagsTreeExistingTasks.Visible = true;
                TagsTreeExistingTasks.TagID = Convert.ToInt32(Request.QueryString["TaskID"]);
                TagsTreeExistingTasks.DisplayType = "Requestor";
                TagsTreeExistingTasks.Expand = false;
            }

            // Select Existing values
            if (objHelpDesk_Tasks.HelpDesk_TaskCategories.Select(x => x.CategoryID).ToArray<int>().Count() > 0)
            {
                int[] ArrStrCategories = objHelpDesk_Tasks.HelpDesk_TaskCategories.Select(x => x.CategoryID).ToArray<int>();
                int?[] ArrIntHelpDesk = Array.ConvertAll<int, int?>(ArrStrCategories, new Converter<int, int?>(ConvertToNullableInt));

                TagsTreeExistingTasks.SelectedCategories = ArrIntHelpDesk;
            }

            // Set visibility of Tags
            bool RequestorR7_HelpDesk = (TagsTreeExistingTasks.DisplayType == "Administrator") ? false : true;

            int CountOfHelpDesk = (from WebserverCategories in CategoriesTable.GetCategoriesTable(PortalId, RequestorR7_HelpDesk)
                                     where WebserverCategories.PortalID == PortalId
                                     where WebserverCategories.Level == 1
                                     select WebserverCategories).Count();

            imgTags.Visible = (CountOfHelpDesk > 0);
            lbltxtTags.Visible = (CountOfHelpDesk > 0);
        }
Example #17
0
        private void UseTrial(int roleID)
        {
            var objRoles = new RoleController();
            RoleInfo objRole = objRoles.GetRole(roleID, PortalSettings.PortalId);

            if (objRole.IsPublic && objRole.TrialFee == 0.0)
            {
                objRoles.UpdateUserRole(PortalId, UserInfo.UserID, roleID, false);

                //Raise SubscriptionUpdated Event
                OnSubscriptionUpdated(new SubscriptionUpdatedEventArgs(false, objRole.RoleName));
            }
            else
            {
                Response.Redirect("~/admin/Sales/PayPalSubscription.aspx?tabid=" + TabId + "&RoleID=" + roleID, true);
            }
        }
        protected string GetInitialEntries()
            {
            int id;
            UserInfo user;
            RoleInfo role;
            var entities = new StringBuilder("[");
            var roleController = new RoleController();

            foreach (var value in (Request.QueryString["users"] ?? string.Empty).Split(','))
                if (int.TryParse(value, out id) && (user = UserController.GetUserById(PortalId, id)) != null)
                    entities.AppendFormat(@"{{ id: ""user-{0}"", name: ""{1}"" }},", user.UserID, user.DisplayName.Replace("\"", ""));
            foreach (var value in (Request.QueryString["roles"] ?? string.Empty).Split(','))
                if (int.TryParse(value, out id) && (role = roleController.GetRole(id, PortalId)) != null)
                    entities.AppendFormat(@"{{ id: ""role-{0}"", name: ""{1}"" }},", role.RoleID, role.RoleName.Replace("\"", ""));

            return entities.Append(']').ToString();
            }
Example #19
0
        override protected void OnInit(EventArgs e) 
        {

            jQuery.RequestDnnPluginsRegistration();
			jQuery.RegisterFileUpload(Page);
            ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
            
            ClientResourceManager.RegisterScript(Page, "~/DesktopModules/Journal/Scripts/journal.js");
            ClientResourceManager.RegisterScript(Page, "~/DesktopModules/Journal/Scripts/journalcomments.js");
			ClientResourceManager.RegisterScript(Page, "~/DesktopModules/Journal/Scripts/mentionsInput.js");
			ClientResourceManager.RegisterScript(Page, "~/Resources/Shared/Scripts/json2.js");

            if (!Request.IsAuthenticated || (!UserInfo.IsSuperUser && UserInfo.IsInRole("Unverified Users")))
            {
                ShowEditor = false;
            } 
            else
            {
                ShowEditor = EditorEnabled;
            }

            if (Settings.ContainsKey(Constants.DefaultPageSize))
            {
                PageSize = Convert.ToInt16(Settings[Constants.DefaultPageSize]);
            }
            if (Settings.ContainsKey(Constants.MaxCharacters))
            {
                MaxMessageLength = Convert.ToInt16(Settings[Constants.MaxCharacters]);
            }
            if (Settings.ContainsKey(Constants.AllowPhotos))
            {
                AllowPhotos = Convert.ToBoolean(Settings[Constants.AllowPhotos]);
            }
            if (Settings.ContainsKey(Constants.AllowFiles))
            {
                AllowFiles = Convert.ToBoolean(Settings[Constants.AllowFiles]);
            }
            ctlJournalList.Enabled = true;
            ctlJournalList.ProfileId = -1;
            ctlJournalList.PageSize = PageSize;
            ctlJournalList.ModuleId = ModuleId;
            
            var moduleController = new ModuleController();
            ModuleInfo moduleInfo = moduleController.GetModule(ModuleId);

            foreach (var module in moduleController.GetTabModules(TabId).Values) 
            {
                if (module.ModuleDefinition.FriendlyName == "Social Groups") 
                {
                    if (GroupId == -1 && FilterMode == JournalMode.Auto) 
                    {
                        ShowEditor = false;
                        ctlJournalList.Enabled = false;
                    }

                    if (GroupId > 0) 
                    {
                        var roleController = new RoleController();
                        RoleInfo roleInfo = roleController.GetRole(GroupId, moduleInfo.OwnerPortalID);
                        if (roleInfo != null) 
                        {
                            if (UserInfo.IsInRole(roleInfo.RoleName)) 
                            {
                                ShowEditor = true;
                                CanComment = true;
                            } else 
                            {
                                ShowEditor = false;
                                CanComment = false;
                            }
                            
                            if (roleInfo.IsPublic == false && ShowEditor == false) 
                            {
                                ctlJournalList.Enabled = false;                               
                            }
                            if (roleInfo.IsPublic && ShowEditor == false) 
                            {
                                ctlJournalList.Enabled = true;
                            }
                            if (roleInfo.IsPublic && ShowEditor) 
                            {
                                ctlJournalList.Enabled = true;
                            }
                        } 
                        else 
                        {
                            ShowEditor = false;
                            ctlJournalList.Enabled = false;
                        }
                    }
                   
                }
            }

            if (!String.IsNullOrEmpty(Request.QueryString["userId"])) 
            {
                ctlJournalList.ProfileId = Convert.ToInt32(Request.QueryString["userId"]);
                if (!UserInfo.IsSuperUser && ctlJournalList.ProfileId != UserId)
                {
                    ShowEditor = ShowEditor && AreFriends(UserController.GetUserById(PortalId, ctlJournalList.ProfileId), UserInfo);                    
                }
            } 
            else if (GroupId > 0) 
            {
                ctlJournalList.SocialGroupId = Convert.ToInt32(Request.QueryString["groupId"]);
            }
            
            InitializeComponent();
            base.OnInit(e);
        }
Example #20
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdPurchase.Click += cmdPurchase_Click;
            cmdCancel.Click += cmdCancel_Click;

            try
            {
                double dblTotal;
                string strCurrency;

                if ((Request.QueryString["RoleID"] != null))
                {
                    RoleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                if (Page.IsPostBack == false)
                {
                    var objRoles = new RoleController();
                    if (RoleID != -1)
                    {
                        RoleInfo objRole = objRoles.GetRole(RoleID, PortalSettings.PortalId);

                        if (objRole.RoleID != -1)
                        {
                            lblServiceName.Text = objRole.RoleName;
                            if (!Null.IsNull(objRole.Description))
                            {
                                lblDescription.Text = objRole.Description;
                            }
                            if (RoleID == PortalSettings.AdministratorRoleId)
                            {
                                if (!Null.IsNull(PortalSettings.HostFee))
                                {
                                    lblFee.Text = PortalSettings.HostFee.ToString("#,##0.00");
                                }
                            }
                            else
                            {
                                if (!Null.IsNull(objRole.ServiceFee))
                                {
                                    lblFee.Text = objRole.ServiceFee.ToString("#,##0.00");
                                }
                            }
                            if (!Null.IsNull(objRole.BillingFrequency))
                            {
                                var ctlEntry = new ListController();
                                ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", objRole.BillingFrequency);
                                lblFrequency.Text = entry.Text;
                            }
                            txtUnits.Text = "1";
                            if (objRole.BillingFrequency == "1") //one-time fee
                            {
                                txtUnits.Enabled = false;
                            }
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }

                    //Store URL Referrer to return to portal
                    if (Request.UrlReferrer != null)
                    {
                        ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "";
                    }
                }
                if (RoleID == PortalSettings.AdministratorRoleId)
                {
                    strCurrency = Host.HostCurrency;
                }
                else
                {
                    strCurrency = PortalSettings.Currency;
                }
                dblTotal = Convert.ToDouble(lblFee.Text)*Convert.ToDouble(txtUnits.Text);
                lblTotal.Text = dblTotal.ToString("#.##");

                lblFeeCurrency.Text = strCurrency;
                lblTotalCurrency.Text = strCurrency;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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);

            jQuery.RequestDnnPluginsRegistration();

            cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged;
            cboTrialFrequency.SelectedIndexChanged += OnTrialFrequencyIndexChanged;
            cmdDelete.Click += OnDeleteClick;
            cmdManage.Click += OnManageClick;
            cmdUpdate.Click += OnUpdateClick;
            txtRSVPCode.TextChanged += OnRsvpCodeChanged;

            try
            {
                if ((Request.QueryString["RoleID"] != null))
                {
                    _roleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                var objPortalController = new PortalController();
                var objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId);
                if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId)))
                {
					//Warn users about fee based roles if we have a Processor Id
                    lblProcessorWarning.Visible = true;
                }
                else
                {
                    divServiceFee.Visible = true;
                    divBillingPeriod.Visible = true;
                    divTrialFee.Visible = true;
                    divTrialPeriod.Visible = true;
                }
                if (Page.IsPostBack == false)
                {
                    cmdCancel.NavigateUrl = Globals.NavigateURL();

                    var objUser = new RoleController();

                    var ctlList = new ListController();
                    var colFrequencies = ctlList.GetListEntryInfoCollection("Frequency", "");

                    cboBillingFrequency.DataSource = colFrequencies;
                    cboBillingFrequency.DataBind();
                    cboBillingFrequency.Items.FindByValue("N").Selected = true;

                    cboTrialFrequency.DataSource = colFrequencies;
                    cboTrialFrequency.DataBind();
                    cboTrialFrequency.Items.FindByValue("N").Selected = true;

                    BindGroups();

                    ctlIcon.FileFilter = Globals.glbImageFileTypes;
                    if (_roleID != -1)
                    {
                        lblRoleName.Visible = true;
                        txtRoleName.Visible = false;
                        valRoleName.Enabled = false;

                        var objRoleInfo = objUser.GetRole(_roleID, PortalSettings.PortalId);
                        if (objRoleInfo != null)
                        {
                            lblRoleName.Text = objRoleInfo.RoleName;
                            txtDescription.Text = objRoleInfo.Description;
                            if (cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()).Selected = true;
                            }
                            if (objRoleInfo.BillingFrequency != "N")
                            {
                                txtServiceFee.Text = objRoleInfo.ServiceFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtBillingPeriod.Text = objRoleInfo.BillingPeriod.ToString();
                                if (cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency) != null)
                                {
                                    cboBillingFrequency.ClearSelection();
                                    cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency).Selected = true;
                                }
                            }
                            if (objRoleInfo.TrialFrequency != "N")
                            {
                                txtTrialFee.Text = objRoleInfo.TrialFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtTrialPeriod.Text = objRoleInfo.TrialPeriod.ToString();
                                if (cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency) != null)
                                {
                                    cboTrialFrequency.ClearSelection();
                                    cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency).Selected = true;
                                }
                            }
                            chkIsPublic.Checked = objRoleInfo.IsPublic;
                            chkAutoAssignment.Checked = objRoleInfo.AutoAssignment;
                            txtRSVPCode.Text = objRoleInfo.RSVPCode;
                            if (!String.IsNullOrEmpty(txtRSVPCode.Text))
                            {
                                lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId;
                            }
                            ctlIcon.Url = objRoleInfo.IconFile;

                            UpdateFeeTextBoxes();
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL("Security Roles"));
                        }
                        if (_roleID == PortalSettings.AdministratorRoleId || _roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdDelete.Visible = false;
                            ActivateControls(false);
                        }
                        if (_roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdManage.Visible = false;
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        cmdManage.Visible = false;
                        lblRoleName.Visible = false;
                        txtRoleName.Visible = true;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        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);
            }
        }
Example #23
0
        private bool ExecuteDeleteCommand()
        {
            try
            {
                var ctlRole = new RoleController();
                var role = ctlRole.GetRole(GroupId, PortalId);

                var result = role.Settings.Remove(SettingKey);

                RoleProvider.Instance().UpdateRoleSettings(role);

                return result;
            }
            catch(Exception ex)
            {
                Exceptions.LogException(ex);
                return false;
            }
        }
        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");
        }
Example #25
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);
            }
        }
        private void LoadRolesDropDown()
        {
            RoleController objRoleController = new RoleController();
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            List<HelpDesk_Role> colHelpDesk_Roles = (from HelpDesk_Roles in objHelpDeskDALDataContext.HelpDesk_Roles
                                                             where HelpDesk_Roles.PortalID == PortalId
                                                             select HelpDesk_Roles).ToList();

            // Create a ListItemCollection to hold the Roles 
            ListItemCollection colListItemCollection = new ListItemCollection();

            // Add the Roles to the List
            foreach (HelpDesk_Role objHelpDesk_Role in colHelpDesk_Roles)
            {
                try
                {
                    RoleInfo objRoleInfo = objRoleController.GetRole(Convert.ToInt32(objHelpDesk_Role.RoleID), PortalId);

                    ListItem RoleListItem = new ListItem();
                    RoleListItem.Text = objRoleInfo.RoleName;
                    RoleListItem.Value = objHelpDesk_Role.RoleID.ToString();
                    ddlAssigned.Items.Add(RoleListItem);
                }
                catch
                {
                    // Role no longer exists in Portal
                    ListItem RoleListItem = new ListItem();
                    RoleListItem.Text = Localization.GetString("DeletedRole.Text", LocalResourceFile);
                    RoleListItem.Value = objHelpDesk_Role.RoleID.ToString();
                    ddlAssigned.Items.Add(RoleListItem);
                }
            }

            // Add UnAssigned
            ListItem UnassignedRoleListItem = new ListItem();
            UnassignedRoleListItem.Text = Localization.GetString("Unassigned.Text", LocalResourceFile);
            UnassignedRoleListItem.Value = "-1";
            ddlAssigned.Items.Add(UnassignedRoleListItem);

        }
        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");
        }
Example #28
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (GroupId > 0)
            {
                RoleController roleController = new RoleController();
                Security.PortalSecurity ps = new Security.PortalSecurity();

                txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
                txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
                
                var roleInfo = roleController.GetRole(GroupId, PortalId);
                if (roleInfo != null)
                {

                    if (txtGroupName.Visible) //if this is visible assume that we're editing the groupname
                    {
                        if (txtGroupName.Text != roleInfo.RoleName)
                        {
                            if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null)
                            {
                                lblInvalidGroupName.Visible = true;
                                return;
                            }
                        }
                    }

                    if(!roleInfo.IsSystemRole)
                    {
                        roleInfo.RoleName = txtGroupName.Text;
                    }
                    
                    roleInfo.Description = txtDescription.Text;
                    roleInfo.IsPublic = rdAccessTypePublic.Checked;

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

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

                }

                Response.Redirect(Globals.NavigateURL(TabId, "", new String[] { "groupid=" + GroupId.ToString() }));
            }
        }
 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);
     }
 }
Example #30
0
 protected bool ShowSubscribe(int roleID)
 {
     var objRoles = new RoleController();
     bool showSubscribe = Null.NullBoolean;
     RoleInfo objRole = objRoles.GetRole(roleID, PortalSettings.PortalId);
     if (objRole.IsPublic)
     {
         var objPortals = new PortalController();
         PortalInfo objPortal = objPortals.GetPortal(PortalSettings.PortalId);
         if (objRole.ServiceFee == 0.0)
         {
             showSubscribe = true;
         }
         else if (objPortal != null && !string.IsNullOrEmpty(objPortal.ProcessorUserId))
         {
             showSubscribe = true;
         }
     }
     return showSubscribe;
 }