Ejemplo n.º 1
0
        public HttpResponseMessage UnlockUser(DTO.UserDetails user)
        {
            var apiResponse = new DTO.ApiResponse <bool>();

            try
            {
                var userController = new DotNetNuke.Entities.Users.UserController();

                var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, user.Id);
                if (dnnUser != null)
                {
                    DotNetNuke.Entities.Users.UserController.UnLockUser(dnnUser);
                    DotNetNuke.Common.Utilities.DataCache.RemoveCache("MembershipUser_" + dnnUser.Username);
                    DotNetNuke.Common.Utilities.DataCache.ClearUserCache(PortalSettings.PortalId, dnnUser.Username);

                    apiResponse.Success = true;
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage ViewUser(DTO.UserDetails user)
        {
            var apiResponse = new DTO.ApiResponse <string>();

            try
            {
                var userController = new DotNetNuke.Entities.Users.UserController();

                var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, user.Id);
                if (dnnUser != null)
                {
                    apiResponse.CustomObject = DotNetNuke.Common.Globals.UserProfileURL(dnnUser.UserID);
                    apiResponse.Success      = true;
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
Ejemplo n.º 3
0
        public HttpResponseMessage ManageUser(DTO.UserDetails user)
        {
            var apiResponse = new DTO.ApiResponse <string>();

            try
            {
                var userController = new DotNetNuke.Entities.Users.UserController();

                var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, user.Id);
                if (dnnUser != null)
                {
                    var objModules = new DotNetNuke.Entities.Modules.ModuleController();
                    var objModule  = objModules.GetModuleByDefinition(PortalSettings.PortalId, "User Accounts");
                    if (objModule != null)
                    {
                        apiResponse.CustomObject = DotNetNuke.Common.Globals.NavigateURL(objModule.TabID, false, PortalSettings, "Edit", new string[] { "UserId=" + dnnUser.UserID.ToString(), "mid=" + objModule.ModuleID.ToString() });
                        apiResponse.Success      = true;
                    }
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvEventList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                Playngo_ClientZone_DownloadFile Event = e.Row.DataItem as Playngo_ClientZone_DownloadFile;

                if (Event != null && Event.ID > 0)
                {
                    HyperLink  hlEdit               = e.Row.FindControl("hlEdit") as HyperLink;
                    HyperLink  hlMobileEdit         = e.Row.FindControl("hlMobileEdit") as HyperLink;
                    LinkButton btnRemove            = e.Row.FindControl("btnRemove") as LinkButton;
                    LinkButton btnMobileRemove      = e.Row.FindControl("btnMobileRemove") as LinkButton;
                    HyperLink  hlNewsletter         = e.Row.FindControl("hlNewsletter") as HyperLink;
                    Literal    liNewsletterClientID = e.Row.FindControl("liNewsletterClientID") as Literal;
                    HyperLink  hlRegisters          = e.Row.FindControl("hlRegisters") as HyperLink;


                    HyperLink hlRepeats         = e.Row.FindControl("hlRepeats") as HyperLink;
                    Literal   liRepeatsClientID = e.Row.FindControl("liRepeatsClientID") as Literal;


                    HyperLink HLEventTitle = e.Row.FindControl("HLEventTitle") as HyperLink;
                    //设置按钮的CommandArgument
                    btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Event.ID.ToString();
                    //设置删除按钮的提示
                    if (Event.Status == (Int32)EnumStatus.Recycle)
                    {
                        btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                        btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    }
                    else
                    {
                        btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                        btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    }

                    hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("ID", Event.ID.ToString(), "Downloads-Edit");



                    HLEventTitle.Text = Event.Title;
                    //HLEventTitle.NavigateUrl = CommonFriendlyUrls.EventFriendlyUrl(Event, this);  //Globals.NavigateURL("", "Token=Info", "EventID=" + Convert.ToString( Event.ID));

                    //获取用户名称
                    DotNetNuke.Entities.Users.UserInfo createUser = new DotNetNuke.Entities.Users.UserController().GetUser(PortalId, Event.CreateUser);
                    e.Row.Cells[3].Text = createUser != null && createUser.UserID > 0 ? createUser.Username : "";
                    //文章状态
                    e.Row.Cells[6].Text = EnumHelper.GetEnumTextVal(Event.Status, typeof(EnumStatus));

                    //格式化3种时间为短日期格式
                    e.Row.Cells[4].Text = Event.ReleaseDate.ToShortDateString();
                    e.Row.Cells[5].Text = Event.StartTime.ToShortDateString();
                    //e.Row.Cells[6].Text = Event.CreateTime.ToShortDateString();
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// WindowsAuthorization checks whether the user credentials are valid
        /// Windows credentials
        /// </summary>
        /// <param name="loginStatus">The log in status</param>
        /// <history>
        ///     [cnurse]	03/15/2006
        /// </history>
        private UserInfo WindowsAuthorization(UserLoginStatus loginStatus)
        {
            string strMessage = Null.NullString;

            UserInfo objUser = UserController.GetUserByName(PortalSettings.PortalId, txtUsername.Text, false);
            AuthenticationController objAuthentication = new AuthenticationController();

            DotNetNuke.Security.Authentication.UserInfo objAuthUser = objAuthentication.ProcessFormAuthentication(txtUsername.Text, txtPassword.Text);
            int _userID = -1;

            if ((objAuthUser != null) && (objUser == null))
            {
                // Add this user into DNN database for better performance on next logon
                UserCreateStatus createStatus;
                DotNetNuke.Security.Authentication.UserController objAuthUsers = new DotNetNuke.Security.Authentication.UserController();
                createStatus = objAuthUsers.AddDNNUser(objAuthUser);
                _userID      = objAuthUser.UserID;

                // Windows/DNN password validation should be same, check this status here
                strMessage = UserController.GetUserCreateStatus(createStatus);
            }
            else if ((objAuthUser != null) && (objUser != null))
            {
                // User might has been imported by Admin or automatically added with random password
                // update DNN password to match with authenticated password from AD
                if (objUser.Membership.Password != txtPassword.Text)
                {
                    UserController.ChangePassword(objUser, objUser.Membership.Password, txtPassword.Text);
                }
                _userID = objUser.UserID;
            }

            if (_userID > 0)
            {
                // Authenticated with DNN
                objUser = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, "", PortalSettings.PortalName, ipAddress, ref loginStatus);
                if (loginStatus != UserLoginStatus.LOGIN_SUCCESS)
                {
                    strMessage = Localization.GetString("LoginFailed", this.LocalResourceFile);
                }
            }
            else
            {
                objUser = null;
            }

            AddLocalizedModuleMessage(strMessage, ModuleMessageType.RedError, !String.IsNullOrEmpty(strMessage));

            return(objUser);
        }
 protected string GetAuthorName(object authorId)
 {
     if (authorId != null)
     {
         string author = string.Empty;
         var    uc     = new DotNetNuke.Entities.Users.UserController();
         DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(authorId, CultureInfo.InvariantCulture));
         if (ui != null)
         {
             author = (authorId is DBNull ? string.Empty : ui.Username);
         }
         return(author);
     }
     return(string.Empty);
 }
Ejemplo n.º 7
0
        public HttpResponseMessage SendPasswordReset(DTO.UserDetails user)
        {
            var apiResponse = new DTO.ApiResponse <bool>();

            try
            {
                var userController = new DotNetNuke.Entities.Users.UserController();

                var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, user.Id);
                if (dnnUser != null)
                {
                    DotNetNuke.Entities.Users.UserController.ResetPasswordToken(dnnUser, DotNetNuke.Entities.Host.Host.AdminMembershipResetLinkValidity);

                    bool canSend = DotNetNuke.Services.Mail.Mail.SendMail(dnnUser, DotNetNuke.Services.Mail.MessageType.PasswordReminder, PortalSettings) == string.Empty;
                    var  message = String.Empty;

                    if (canSend)
                    {
                        apiResponse.Success = true;

                        // message = Localization.GetString("PasswordSent", LocalResourceFile);
                        // LogSuccess();
                    }
                    else
                    {
                        apiResponse.Success = false;
                        //message = Localization.GetString("OptionUnavailable", LocalResourceFile);
                        //moduleMessageType = ModuleMessage.ModuleMessageType.RedError;
                        //LogFailure(message);
                    }
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string sDisplayName = string.Empty;
            int    tUid         = -1;

            if (Request.Params["UID"] != null)
            {
                if (SimulateIsNumeric.IsNumeric(Request.Params["UID"]))
                {
                    tUid = Convert.ToInt32(Request.Params["UID"]);
                    DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                    DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tUid);
                    if (ui != null)
                    {
                        sDisplayName = UserProfiles.GetDisplayName(ModuleId, ui.UserID, ui.Username, ui.FirstName, ui.LastName, ui.DisplayName);
                    }
                }
            }
            else
            {
                tUid         = UserId;
                sDisplayName = UserProfiles.GetDisplayName(ModuleId, UserId, UserInfo.Username, UserInfo.FirstName, UserInfo.LastName, UserInfo.DisplayName);
            }
            lblHeader.Text = string.Format(Utilities.GetSharedResource("[RESX:ProfileForUser]"), sDisplayName);
            if (MainSettings.UseSkinBreadCrumb)
            {
                Environment.UpdateBreadCrumb(Page.Controls, "<a href=\"" + Utilities.NavigateUrl(TabId, "", new string[] { "afv=profile", "uid=" + tUid.ToString() }) + "\">" + lblHeader.Text + "</a>");
            }
            DotNetNuke.Framework.CDefault tempVar = this.BasePage;
            Environment.UpdateMeta(ref tempVar, "[VALUE] - " + lblHeader.Text, "[VALUE]", "[VALUE]");
            SettingsBase ctl = null;

            ctl = (SettingsBase)(new DotNetNuke.Modules.ActiveForums.Controls.UserProfile());
            ctl.ModuleConfiguration = this.ModuleConfiguration;
            if (!(this.Params == string.Empty))
            {
                ctl.Params = this.Params;
            }
            plhProfile.Controls.Add(ctl);
        }
Ejemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

            string sDisplayName = string.Empty;
            int tUid = -1;
            if (Request.Params["UID"] != null)
            {
                if (SimulateIsNumeric.IsNumeric(Request.Params["UID"]))
                {
                    tUid = Convert.ToInt32(Request.Params["UID"]);
                    DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                    DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tUid);
                    if (ui != null)
                    {
                        sDisplayName = UserProfiles.GetDisplayName(ModuleId, ui.UserID, ui.Username, ui.FirstName, ui.LastName, ui.DisplayName);
                    }

                }

            }
            else
            {
                tUid = UserId;
                sDisplayName = UserProfiles.GetDisplayName(ModuleId, UserId, UserInfo.Username, UserInfo.FirstName, UserInfo.LastName, UserInfo.DisplayName);
            }
            lblHeader.Text = string.Format(Utilities.GetSharedResource("[RESX:ProfileForUser]"), sDisplayName);
            if (MainSettings.UseSkinBreadCrumb)
            {
                Environment.UpdateBreadCrumb(Page.Controls, "<a href=\"" + Utilities.NavigateUrl(TabId, "", new string[] { "afv=profile", "uid=" + tUid.ToString() }) + "\">" + lblHeader.Text + "</a>");
            }
            DotNetNuke.Framework.CDefault tempVar = this.BasePage;
            Environment.UpdateMeta(ref tempVar, "[VALUE] - " + lblHeader.Text, "[VALUE]", "[VALUE]");
            SettingsBase ctl = null;
            ctl = (SettingsBase)(new DotNetNuke.Modules.ActiveForums.Controls.UserProfile());
            ctl.ModuleConfiguration = this.ModuleConfiguration;
            if (!(this.Params == string.Empty))
            {
                ctl.Params = this.Params;
            }
            plhProfile.Controls.Add(ctl);
        }
Ejemplo n.º 10
0
        private void ProcessLogin(int newUserId)
        {
            var currentUser = DNNUserController.Instance.GetCurrentUserInfo();

            //Log event
            var objEventLog = new EventLogController();

            objEventLog.AddLog("Username", currentUser.Username, PortalSettings, currentUser.UserID, EventLogController.EventLogType.USER_IMPERSONATED);

            //Remove user from cache
            DataCache.ClearUserCache(PortalSettings.PortalId, currentUser.Username);

            var objPortalSecurity = new PortalSecurity();

            objPortalSecurity.SignOut();

            var newUser = DNNUserController.Instance.GetUser(PortalSettings.PortalId, newUserId);

            DNNUserController.UserLogin(newUser.PortalID, newUser, PortalSettings.PortalName, HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"], false);
        }
Ejemplo n.º 11
0
        public Paciente InsertHistory(string Historial, int IdUser, int IdPortal, string UIPaciente)
        {
            Paciente p   = new Paciente("error", "error", DateTime.Now, "error", "error", "error", "error", 0, "error", "error", false);
            Paciente t_P = ConnectionDispensario.Modelos.Paciente.Select_Paciente_by_GUI(UIPaciente);

            if (t_P != null)
            {
                DotNetNuke.Entities.Users.UserController UC   = new DotNetNuke.Entities.Users.UserController();
                DotNetNuke.Entities.Users.UserInfo       t_UI = UC.GetUser(IdPortal, IdUser);
                if (t_UI != null)
                {
                    Historial H = new Historial(Historial.Replace("\n", "[LineJump]"), IdUser, t_P.ID);
                    if (H.Guardar() == true)
                    {
                        ConnectionDispensario.Statics.LogCatcher.AddLog("Se inserto correctamente", "Se inserto correctamente", null, null);
                        return(t_P);
                    }
                    else
                    {
                        ConnectionDispensario.Statics.LogCatcher.AddLog("No se pudo Guardar", "No se pudo Guardar", null, null);
                        return(p);
                    }
                }
                else
                {
                    ConnectionDispensario.Statics.LogCatcher.AddLog("No existe el usuario", "No existe el usuario", null, null);
                    return(p);
                }
            }
            else
            {
                ConnectionDispensario.Statics.LogCatcher.AddLog("No existe el Paciente", "No existe el Paciente", null, null);


                return(p);
            }
        }
Ejemplo n.º 12
0
		public string GetNewGrid()
		{
			//Roles
			string[] roles = GetSecureObjectList(Security, 0).Split(';');
			int[] roleIds = new int[roles.Length - 2 + 1];
			int i = 0;
			for (i = 0; i <= roles.Length - 2; i++)
			{
				if (! (string.IsNullOrEmpty(roles[i])))
				{
					roleIds[i] = Convert.ToInt32(roles[i]);
				}
			}
			Array.Sort(roleIds);
			string tmp = string.Empty;
			foreach (int n in roleIds)
			{
				tmp += n.ToString() + ";";
			}
			List<PermissionInfo> pl = new List<PermissionInfo>();

			//litNewGrid.Text = "Roles:" & tmp

			//litNewGrid.Text &= "<br />RolesNames:" & Permissions.GetRolesNVC(tmp)
			NameValueCollection nvc = Permissions.GetRolesNVC(tmp, PortalId);
			foreach (string key in nvc.AllKeys)
			{
				PermissionInfo pi = new PermissionInfo();
				pi.ObjectId = key;
				pi.ObjectName = nvc[key];
				pi.Type = ObjectType.RoleId;
				pl.Add(pi);
			}

			//Users
			string users = GetSecureObjectList(Security, 1);
			string userNames = string.Empty;
			if (! (string.IsNullOrEmpty(users)))
			{
				DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
				foreach (string uid in users.Split(';'))
				{
					if (! (string.IsNullOrEmpty(uid)))
					{
						DotNetNuke.Entities.Users.UserInfo u = uc.GetUser(PortalId, Convert.ToInt32(uid));
						if (u != null)
						{
							PermissionInfo pi = new PermissionInfo();
							pi.ObjectId = u.UserID.ToString();
							pi.ObjectName = u.DisplayName;
							pi.Type = ObjectType.UserId;
							pl.Add(pi);
						}

					}
				}
			}
			//Groups
			string groups = GetSecureObjectList(Security, 2);
			if (! (string.IsNullOrEmpty(groups)))
			{
				foreach (string g in groups.Split(';'))
				{
					if (! (string.IsNullOrEmpty(g)))
					{
						Social uc = new Social();
						string gType = g.Split(':')[1];
						int groupId = Convert.ToInt32(g.Split(':')[0]);
						string groupName = uc.ActiveSocialGetGroup(groupId);
						if (! (string.IsNullOrEmpty(groupName)))
						{
							PermissionInfo pi = new PermissionInfo();
							pi.ObjectId = g;
							pi.ObjectName = groupName;
							pi.Type = ObjectType.GroupId;
							pi.ObjectName += "-" + uc.ActiveSocialGetGroupType(Convert.ToInt32(gType), PortalId);
							pl.Add(pi);
						}
					}
				}
			}

			string[,] grid = new string[pl.Count + 1, 28];
			i = 0;
			foreach (PermissionInfo pi in pl)
			{
				grid[i, 0] = pi.ObjectId;
				grid[i, 1] = pi.ObjectName;
				grid[i, 2] = Convert.ToString(pi.Type);
                grid[i, 3] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.View));
                grid[i, 4] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Read));
                grid[i, 5] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Create));
                grid[i, 6] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Reply));
                grid[i, 7] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Edit));
                grid[i, 8] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Delete));
                grid[i, 9] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Lock));
                grid[i, 10] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Pin));
                grid[i, 11] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Attach));
                grid[i, 12] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Poll));
                grid[i, 13] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Block));
                grid[i, 14] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Trust));
                grid[i, 15] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Subscribe));
                grid[i, 16] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Announce));
                grid[i, 17] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Tag));
                grid[i, 18] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Categorize));
                grid[i, 19] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Prioritize));

                grid[i, 20] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModApprove));
                grid[i, 21] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModMove));
                grid[i, 22] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModSplit));
                grid[i, 23] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModDelete));
                grid[i, 24] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModUser));
                grid[i, 25] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModEdit));
                grid[i, 26] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModLock));
                grid[i, 27] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModPin));


				i += 1;
			}
			System.Type enumType = typeof(SecureActions);
			Array values = Enum.GetValues(enumType);
			StringBuilder sb = new StringBuilder();
			sb.Append("<table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\"><div class=\"afsecobjects\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
			sb.Append("<tr><td class=\"afsecobjecthd\" colspan=\"2\">" + Utilities.GetSharedResource("[RESX:SecureObjects]", true) + "</td></tr>");
			string tmpObjectName = string.Empty;
			int secRows = 0;
			for (int x = 0; x < pl.Count; x++)
			{
				sb.Append("<tr><td style=\"width:16px;\"></td><td class=\"afsecobject\" style=\"white-space:nowrap;\"><div class=\"afsecobjecttxt\" title=\"" + grid[x, 1] + "\" onmouseover=\"this.firstChild.style.display='';\" onmouseout=\"this.firstChild.style.display='none';\"><span style=\"width:16px;height:16px;float:right;display:none;\">");
				if ((Convert.ToInt32(grid[x, 2]) == 0 && Convert.ToInt32(grid[x, 0]) > 0) | Convert.ToInt32(grid[x, 2]) > 0)
				{
					if (! ReadOnly)
					{
						sb.Append("<img src=\"" + ImagePath + "mini_del.gif\" alt=\"Remove Object\" style=\"cursor:pointer;z-index:10;\" class=\"afminidel\" onclick=\"securityDelObject(this,'" + grid[x, 0] + "'," + grid[x, 2] + "," + PermissionsId + ");\" />");
					}
				}
				sb.Append("</span>" + grid[x, 1]);
				sb.Append("</div></td></tr>");
			}
			sb.Append("</table></div></td><td valign=\"top\" width=\"94%\"><div class=\"afsecactions\" style=\"overflow-x:auto;overflow-y:hidden;\">");
			//litNewObjects.Text = sb.ToString
			//sb = New StringBuilder

			sb.Append("<table cellpadding=0 cellspacing=0 border=0 width=\"100%\" id=\"tblSecGrid\">");
			sb.Append("<tr>");
			string keyText = string.Empty;
			for (int td = 3; td <= 27; td++)
			{
				keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(td - 3).ToString()));
				if (keyText.ToLowerInvariant() == "block")
				{
					sb.Append("<td class=\"afsecactionhd\" style=\"display:none;\">");
				}
				else
				{
					sb.Append("<td class=\"afsecactionhd\">");
				}


				sb.Append(keyText);
				sb.Append("</td>");
			}
			sb.Append("</tr>");
			for (int x = 0; x < pl.Count; x++)
			{
				sb.Append("<tr onmouseover=\"this.className='afgridrowover'\" onmouseout=\"this.className='afgridrow'\">");
				for (int r = 3; r <= 27; r++)
				{
					keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(r - 3).ToString()));
					bool bState = Convert.ToBoolean(grid[x, r]); //Permissions.HasPermission(ForumID, Integer.Parse(dr("ObjectId").ToString), key, Integer.Parse(dr("SecureType").ToString), dt)
					string sState = "<img src=\"" + ImagePath + "admin_stop.png\" alt=\"Disabled\" />";
					if (bState)
					{
						sState = "<img src=\"" + ImagePath + "admin_check.png\" alt=\"Enabled\" />";
					}
					if (keyText.ToLowerInvariant() == "block")
					{
						sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;display:none;\">");
					}
					else
					{
						sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;\">");
					}

					sb.Append("<div class=\"afsectoggle\" id=\"" + grid[x, 0] + grid[x, 2] + keyText + "\" ");
					if (! ReadOnly)
					{
						sb.Append("onclick=\"securityToggle(this," + PermissionsId + ",'" + grid[x, 0] + "','" + grid[x, 1] + "'," + grid[x, 2] + ",'" + keyText + "');\"");
					}
					sb.Append(">" + sState + "</div></td>");


				}
				sb.Append("</tr>");
			}
			sb.Append("</table></div></td></tr></table>");
			return sb.ToString();

		}
Ejemplo n.º 13
0
 private DotNetNuke.Entities.Users.UserInfo Getuser(int ID, int IdPortal)
 {
     DotNetNuke.Entities.Users.UserController UC = new DotNetNuke.Entities.Users.UserController();
     return(UC.GetUser(IdPortal, ID));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// cmdLogin_Click runs when the login button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	9/24/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    12/11/2005  Updated to reflect abstraction of Membership
        /// </history>
        protected void cmdLogin_Click(object sender, EventArgs e)
        {
            if ((UseCaptcha && ctlCaptcha.IsValid) || (!UseCaptcha))
            {
                //Try to validate user
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                UserInfo        objUser     = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, txtVerification.Text, PortalSettings.PortalName, ipAddress, ref loginStatus);

                if (objUser == null)  //Some kind of Login failure
                {
                    if (loginStatus == UserLoginStatus.LOGIN_FAILURE)
                    {
                        Hashtable settings = Entities.Portals.PortalSettings.GetSiteSettings(PortalId);
                        if (Convert.ToString(settings["WindowsAuthentication"]) == "True")
                        {
                            //Try Windows Authorization (user may be authorized in Windows, but not in DNN yet)
                            objUser = WindowsAuthorization(loginStatus);
                        }
                    }
                }

                if (objUser == null)
                {
                    switch (loginStatus)
                    {
                    case UserLoginStatus.LOGIN_USERNOTAPPROVED:

                        //Check if its the first time logging in to a verified site
                        if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                        {
                            if (!rowVerification1.Visible)
                            {
                                //Display Verification Rows so User can enter verification code
                                rowVerification1.Visible = true;
                                rowVerification2.Visible = true;
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(txtVerification.Text))
                                {
                                    AddModuleMessage("InvalidCode", ModuleMessageType.RedError, true);
                                }
                                else
                                {
                                    AddModuleMessage("EnterCode", ModuleMessageType.GreenSuccess, true);
                                }
                            }
                        }
                        else
                        {
                            AddModuleMessage("UserNotAuthorized", ModuleMessageType.RedError, true);
                        }
                        break;

                    case UserLoginStatus.LOGIN_USERLOCKEDOUT:

                        AddModuleMessage("UserLockedOut", ModuleMessageType.RedError, true);
                        // notify administrator about account lockout ( possible hack attempt )
                        ArrayList Custom = new ArrayList();
                        Custom.Add(txtUsername.Text);
                        Mail.SendMail(PortalSettings.Email, PortalSettings.Email, "", Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom), Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom), "", "", "", "", "", "");
                        break;

                    case UserLoginStatus.LOGIN_FAILURE:

                        AddModuleMessage("LoginFailed", ModuleMessageType.RedError, true);
                        break;
                    }
                }
                else //Login Success
                {
                    UserAuthorized(objUser, false);
                }
            }
        }
Ejemplo n.º 15
0
        public static List <ProfileUser> getProfileUser(int IdPortal, int IdUser)
        {
            DotNetNuke.Entities.Users.UserController UC = new DotNetNuke.Entities.Users.UserController();
            DotNetNuke.Entities.Users.UserInfo       UI = UC.GetUser(IdPortal, IdUser);
            DotNetNuke.Entities.Profile.ProfilePropertyDefinitionCollection C = UI.Profile.ProfileProperties;


            List <ProfileUser> PUV = null;

            if (C != null)
            {
                PUV = new List <ProfileUser>();

                /*
                 * for (int b = 0; b < C.Count; b++)
                 * {
                 *  if (C[b].PropertyValue!=null && C[b].PropertyValue.Trim() != "")
                 *  {
                 *      PUV.Add(new ProfileUser(C[b].PropertyName, C[b].PropertyValue));
                 *  }
                 * }*/



                if (C["FirstName"] != null)
                {
                    PUV.Add(new ProfileUser("Nombre", C["FirstName"].PropertyValue));
                }
                if (C["LastName"] != null)
                {
                    PUV.Add(new ProfileUser("Apellido", C["LastName"].PropertyValue));
                }
                if (C["Puesto"] != null)
                {
                    PUV.Add(new ProfileUser("Puesto", C["Puesto"].PropertyValue));
                }
                if (C["Telephone"] != null)
                {
                    PUV.Add(new ProfileUser("Teléfono", C["Telephone"].PropertyValue));
                }
                if (C["MP"] != null)
                {
                    PUV.Add(new ProfileUser("M.P.", C["MP"].PropertyValue));
                }
                if (C["ME"] != null)
                {
                    PUV.Add(new ProfileUser("M.E.", C["ME"].PropertyValue));
                }
                if (UI.IsInRole("Medico") == true)
                {
                    PUV.Add(new ProfileUser("Medico", "si"));
                }
                if (UI.IsInRole("Enfermero") == true)
                {
                    PUV.Add(new ProfileUser("Enfermero", "si"));
                }
                if (UI.IsInRole("Administrativo") == true)
                {
                    PUV.Add(new ProfileUser("Administrativo", "si"));
                }
            }
            return(PUV);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// UserAuthorized runs when the user has been authorized by the data store
        /// </summary>
        /// <param name="objUser">The logged in User</param>
        /// <history>
        ///     [cnurse]	03/15/2006
        /// </history>
        ///<param name="canProceed"></param>
        private void UserAuthorized(UserInfo objUser, bool canProceed)
        {
            bool   updatePassword = false;
            bool   updateProfile  = false;
            string strMessage;

            UserId = objUser.UserID;

            //Set the Page Culture(Language) based on the Users Preferred Locale
            if ((objUser.Profile != null) && (objUser.Profile.PreferredLocale != null))
            {
                Localization.SetLanguage(objUser.Profile.PreferredLocale);
            }
            else
            {
                Localization.SetLanguage(PortalSettings.DefaultLanguage);
            }

            //Check whether Password needs updating
            if (PasswordConfig.PasswordExpiry > 0)
            {
                DateTime expiryDate = objUser.Membership.LastPasswordChangeDate.AddDays(PasswordConfig.PasswordExpiry);
                if (expiryDate < DateTime.Today)
                {
                    //Password Expired
                    strMessage = string.Format(Localization.GetString("PasswordExpired", this.LocalResourceFile), expiryDate.ToLongDateString(), null);
                    AddLocalizedModuleMessage(strMessage, ModuleMessageType.YellowWarning, true);
                    updatePassword     = true;
                    pnlProceed.Visible = false;
                }
                if ((!updatePassword) && expiryDate < DateTime.Today.AddDays(PasswordConfig.PasswordExpiryReminder))
                {
                    //Password update reminder
                    strMessage = string.Format(Localization.GetString("PasswordExpiring", this.LocalResourceFile), expiryDate.ToLongDateString(), null);
                    AddLocalizedModuleMessage(strMessage, ModuleMessageType.YellowWarning, true);
                    updatePassword     = !canProceed;
                    pnlProceed.Visible = true;
                }
            }
            if ((!updatePassword) && objUser.Membership.UpdatePassword)
            {
                //Admin has forced password update
                AddModuleMessage("PasswordUpdate", ModuleMessageType.YellowWarning, true);
                updatePassword = true;
            }

            //Check whether Profile needs updating
            if (!updatePassword && this.RequireValidProfile)
            {
                //Admin has forced password update
                AddModuleMessage("ProfileUpdate", ModuleMessageType.YellowWarning, true);
                updateProfile = !ProfileController.ValidateProfile(PortalId, objUser.Profile);
            }

            if (updatePassword)
            {
                PageNo = 1;
            }
            else if (updateProfile)
            {
                //Admin has forced profile update
                AddModuleMessage("ProfileUpdate", ModuleMessageType.YellowWarning, true);
                PageNo = 2;
            }
            else
            {
                //Complete Login
                UserController.UserLogin(PortalId, objUser, PortalSettings.PortalName, ipAddress, chkCookie.Checked);

                // redirect browser
                Response.Redirect(RedirectURL, true);
            }

            ShowPanel();
        }
        public HttpResponseMessage SaveUser(DTO.UserDetails user)
        {
            var apiResponse = new DTO.ApiResponse <bool>();

            try
            {
                var userController = new DotNetNuke.Entities.Users.UserController();

                if (user.Id == -1)
                {
                    if (!DotNetNuke.Entities.Users.UserController.ValidatePassword(user.Password))
                    {
                        apiResponse.Success = false;
                        apiResponse.Message = "Invalid Password";

                        return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
                    }

                    //new user
                    var dnnUser = new DotNetNuke.Entities.Users.UserInfo();
                    dnnUser.Username    = user.UserName;
                    dnnUser.FirstName   = user.FirstName;
                    dnnUser.LastName    = user.LastName;
                    dnnUser.DisplayName = user.DisplayName;
                    dnnUser.Email       = user.EmailAddress;

                    dnnUser.PortalID = PortalSettings.PortalId;

                    dnnUser.Membership.Password = user.Password;
                    dnnUser.Membership.Approved = true;

                    DotNetNuke.Entities.Users.UserController.CreateUser(ref dnnUser);
                    apiResponse.Success = true;
                }
                else
                {
                    //existing user
                    var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, user.Id);
                    if (dnnUser != null)
                    {
                        //dnnUser.Username = user.UserName;
                        dnnUser.FirstName   = user.FirstName;
                        dnnUser.LastName    = user.LastName;
                        dnnUser.DisplayName = user.DisplayName;
                        dnnUser.Email       = user.EmailAddress;
                        //dnnUser.Membership.Password = user.Password;

                        DotNetNuke.Entities.Users.UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
                        apiResponse.Success = true;
                    }
                }
            }
            catch (Exception err)
            {
                apiResponse.Success = false;
                apiResponse.Message = err.Message;

                Exceptions.LogException(err);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, apiResponse));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvFieldList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_PowerForms_Field Fielditem = e.Row.DataItem as DNNGo_PowerForms_Field;

                if (Fielditem != null && Fielditem.ID > 0)
                {
                    #region "编辑&删除按钮"
                    HyperLink  hlEdit          = e.Row.FindControl("hlEdit") as HyperLink;
                    HyperLink  hlMobileEdit    = e.Row.FindControl("hlMobileEdit") as HyperLink;
                    LinkButton btnRemove       = e.Row.FindControl("btnRemove") as LinkButton;
                    LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton;
                    //设置按钮的CommandArgument
                    btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Fielditem.ID.ToString();
                    //设置删除按钮的提示
                    //if (Field.Status == (Int32)EnumFieldStatus.Recycle)
                    //{
                    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    //}
                    //else
                    //{
                    //    btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //    btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    //}

                    hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("FieldID", Fielditem.ID.ToString(), "AddNewField");


                    #endregion


                    #region "移动分类按钮"
                    LinkButton lbSortUp         = e.Row.FindControl("lbSortUp") as LinkButton;
                    LinkButton lbSortDown       = e.Row.FindControl("lbSortDown") as LinkButton;
                    LinkButton lbMobileSortUp   = e.Row.FindControl("lbMobileSortUp") as LinkButton;
                    LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton;
                    lbSortUp.CommandArgument                     =
                        lbSortDown.CommandArgument               =
                            lbMobileSortUp.CommandArgument       =
                                lbMobileSortDown.CommandArgument = Fielditem.ID.ToString();
                    #endregion


                    e.Row.Cells[4].Text = EnumHelper.GetEnumTextVal(Fielditem.FieldType, typeof(EnumViewControlType));

                    //获取用户名称
                    DotNetNuke.Entities.Users.UserInfo uInfo = new DotNetNuke.Entities.Users.UserController().GetUser(PortalId, Fielditem.LastUser);
                    e.Row.Cells[7].Text = uInfo != null && uInfo.UserID > 0 ?  uInfo.Username:"******";

                    e.Row.Cells[8].Text = EnumHelper.GetEnumTextVal(Fielditem.Status, typeof(EnumStatus));

                    if (Fielditem.GroupID > 0)
                    {
                        DNNGo_PowerForms_Group Group = DNNGo_PowerForms_Group.FindByKeyForEdit(Fielditem.GroupID);
                        if (Group != null && Group.ID > 0)
                        {
                            e.Row.Cells[3].Text = Group.Name;
                        }
                        else
                        {
                            e.Row.Cells[3].Text = String.Empty;
                        }
                    }
                    else
                    {
                        e.Row.Cells[3].Text = String.Empty;
                    }
                }
            }
        }
 protected string GetAuthorName(object authorId)
 {
     if (authorId != null)
     {
         string author = string.Empty;
         var uc = new DotNetNuke.Entities.Users.UserController();
         DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(authorId, CultureInfo.InvariantCulture));
         if (ui != null)
         {
             author = (authorId is DBNull ? string.Empty : ui.Username);
         }
         return author;
     }
     return string.Empty;
 }
Ejemplo n.º 20
0
        private string ParseContent(DataRow dr, string tempate, int rowcount)
        {
            var sOutput = tempate;

            var replyId = dr.GetInt("ReplyId");
            var topicId = dr.GetInt("TopicId");
            var postId = replyId == 0 ? topicId : replyId;
            var contentId = dr.GetInt("ContentId");
            var dateCreated = dr.GetDateTime("DateCreated");
            var dateUpdated = dr.GetDateTime("DateUpdated");
            var authorId = dr.GetInt("AuthorId");
            var username = dr.GetString("Username");
            var firstName = dr.GetString("FirstName");
            var lastName = dr.GetString("LastName");
            var displayName = dr.GetString("DisplayName");
            var userTopicCount = dr.GetInt("TopicCount");
            var userReplyCount = dr.GetInt("ReplyCount");
            var postCount = userTopicCount + userReplyCount;
            var userCaption = dr.GetString("UserCaption");
            var body = dr.GetString("Body");
            var subject = dr.GetString("Subject");
            var tags = dr.GetString("Tags");
            var signature = dr.GetString("Signature");
            var ipAddress = dr.GetString("IPAddress");
            var memberSince = dr.GetDateTime("MemberSince");
            var avatarDisabled = dr.GetBoolean("AvatarDisabled");
            var userRoles = dr.GetString("UserRoles");
            var isUserOnline = dr.GetBoolean("IsUserOnline");
            var replyStatusId = dr.GetInt("StatusId");
            var totalPoints = _enablePoints ? dr.GetInt("UserTotalPoints") : 0;
            var answerCount = dr.GetInt("AnswerCount");
            var rewardPoints = dr.GetInt("RewardPoints");
            var dateLastActivity = dr.GetDateTime("DateLastActivity");
            var signatureDisabled = dr.GetBoolean("SignatureDisabled");

            DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
            DotNetNuke.Entities.Users.UserInfo author = uc.GetUser(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().PortalId, authorId);

            // Populate the user object with the post author info.
            var up = new User
            {
                UserId = authorId,
                UserName = username,
                FirstName = firstName.Replace("&amp;#", "&#"),
                LastName = lastName.Replace("&amp;#", "&#"),
                DisplayName = displayName.Replace("&amp;#", "&#"),
                Profile =
                {
                    UserCaption = userCaption,
                    Signature = signature,
                    DateCreated = memberSince,
                    AvatarDisabled = avatarDisabled,
                    Roles = userRoles,
                    ReplyCount = userReplyCount,
                    TopicCount = userTopicCount,
                    AnswerCount = answerCount,
                    RewardPoints = rewardPoints,
                    DateLastActivity = dateLastActivity,
                    PrefBlockAvatars = UserPrefHideAvatars,
                    PrefBlockSignatures = UserPrefHideSigs,
                    IsUserOnline = isUserOnline,
                    SignatureDisabled = signatureDisabled
                }
            };
            if (author != null) up.Email = author.Email;

            //Perform Profile Related replacements
            sOutput = TemplateUtils.ParseProfileTemplate(sOutput, up, PortalId, ModuleId, ImagePath, CurrentUserType, true, UserPrefHideAvatars, UserPrefHideSigs, ipAddress, UserId, TimeZoneOffset);

            // Replace Tags Control
            if (string.IsNullOrWhiteSpace(tags))
                sOutput = TemplateUtils.ReplaceSubSection(sOutput, string.Empty, "[AF:CONTROL:TAGS]", "[/AF:CONTROL:TAGS]");
            else
            {
                sOutput = sOutput.Replace("[AF:CONTROL:TAGS]", string.Empty);
                sOutput = sOutput.Replace("[/AF:CONTROL:TAGS]", string.Empty);
                var tagList = string.Empty;
                foreach (var tag in tags.Split(','))
                {
                    if (tagList != string.Empty)
                        tagList += ", ";

                    tagList += "<a href=\"" + Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ViewType + "=search", ParamKeys.Tags + "=" + HttpUtility.UrlEncode(tag) }) + "\">" + tag + "</a>";
                }
                sOutput = sOutput.Replace("[AF:LABEL:TAGS]", tagList);
            }

            // Use a string builder from here on out.

            var sbOutput = new StringBuilder(sOutput);

            if (_bModSplit)
            {
                sbOutput = sbOutput.Replace("[SPLITCHECKBOX]", "<div class=\"split-checkbox\" style=\"display:none;\"><input type=\"checkbox\" onChange=\"amaf_splitCheck(this);\" value=\"" + replyId + "\" /></div>");
            }
            else
            {
                sbOutput = sbOutput.Replace("[SPLITCHECKBOX]", string.Empty);
            }

            // Row CSS Classes
            if (rowcount % 2 == 0)
            {
                sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo1");
                sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply1");
                sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply1");
            }
            else
            {
                sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply2");
                sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo2");
                sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply2");
            }

            // Description
            if (replyId == 0)
            {
                sbOutput.Replace("[POSTID]", topicId.ToString());
                _topicDescription = Utilities.StripHTMLTag(body).Trim();
                _topicDescription = _topicDescription.Replace(System.Environment.NewLine, string.Empty);
                if (_topicDescription.Length > 255)
                    _topicDescription = _topicDescription.Substring(0, 255);
            }
            else
            {
                sbOutput.Replace("[POSTID]", replyId.ToString());
            }

            sbOutput.Replace("[FORUMID]", ForumId.ToString());
            sbOutput.Replace("[REPLYID]", replyId.ToString());
            sbOutput.Replace("[TOPICID]", topicId.ToString());
            sbOutput.Replace("[POSTDATE]", GetDate(dateCreated));
            sbOutput.Replace("[DATECREATED]", GetDate(dateCreated));

            // Parse Roles -- This should actually be taken care of in ParseProfileTemplate
            //if (sOutput.Contains("[ROLES:"))
            //    sOutput = TemplateUtils.ParseRoles(sOutput, (up.UserId == -1) ? string.Empty : up.Profile.Roles);

            // Delete Action
            if (_bModDelete || ((_bDelete && authorId == UserId && !_bLocked) && ((replyId == 0 && _replyCount == 0) || replyId > 0)))
            {
                if (_useListActions)
                    sbOutput.Replace("[ACTIONS:DELETE]", "<li onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i>&nbsp;[RESX:Delete]</li>");
                else
                    sbOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0);\" class=\"af-actions\" onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i>&nbsp;[RESX:Delete]</a>");
            }
            else
            {
                sbOutput.Replace("[ACTIONS:DELETE]", string.Empty);
            }

            // Edit Action
            if (_bModEdit || (_bEdit && authorId == UserId && (_editInterval == 0 || SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, dateCreated, DateTime.Now) < _editInterval)))
            {
                var sAction = "re";
                if (replyId == 0)
                    sAction = "te";

                //var editParams = new[] { ParamKeys.ViewType + "=post", "action=" + sAction, ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, "postid=" + postId };
                var editParams = new List<string>() { ParamKeys.ViewType + "=post", "action=" + sAction, ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, "postid=" + postId };
                if (SocialGroupId > 0) editParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId);
                if (_useListActions)
                    sbOutput.Replace("[ACTIONS:EDIT]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", editParams) + "';\" title=\"[RESX:Edit]\"><i class=\"fa fa-pencil fa-fw fa-blue\"></i>&nbsp;[RESX:Edit]</li>");
                else
                    sbOutput.Replace("[ACTIONS:EDIT]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", editParams) + "\" title=\"[RESX:Edit]\"><i class=\"fa fa-pencil fa-fw fa-blue\"></i>&nbsp;[RESX:Edit]</a>");
            }
            else
            {
                sbOutput.Replace("[ACTIONS:EDIT]", string.Empty);
            }

            // Reply and Quote Actions
            if (!_bLocked && CanReply)
            {
                var quoteParams = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.QuoteId + "=" + postId };
                var replyParams = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId };
                if (SocialGroupId > 0)
                {
                    quoteParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId);
                    replyParams.Add(ParamKeys.GroupIdName + "=" + SocialGroupId);
                }
                if (_useListActions)
                {
                    sbOutput.Replace("[ACTIONS:QUOTE]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", quoteParams) + "';\" title=\"[RESX:Quote]\"><i class=\"fa fa-quote-left fa-fw fa-blue\"></i>&nbsp;[RESX:Quote]</li>");
                    sbOutput.Replace("[ACTIONS:REPLY]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", replyParams) + "';\" title=\"[RESX:Reply]\"><i class=\"fa fa-reply fa-fw fa-blue\"></i>&nbsp;[RESX:Reply]</li>");
                }
                else
                {
                    sbOutput.Replace("[ACTIONS:QUOTE]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", quoteParams) + "\" title=\"[RESX:Quote]\"><i class=\"fa fa-quote-left fa-fw fa-blue\"></i>&nbsp;[RESX:Quote]</a>");
                    sbOutput.Replace("[ACTIONS:REPLY]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", replyParams) + "\" title=\"[RESX:Reply]\"><i class=\"fa fa-reply fa-fw fa-blue\"></i>&nbsp;[RESX:Reply]</a>");
                }
            }
            else
            {
                sbOutput.Replace("[ACTIONS:QUOTE]", string.Empty);
                sbOutput.Replace("[ACTIONS:REPLY]", string.Empty);
            }

            if (_bModMove)
            {
                sbOutput.Replace("[ACTIONS:MOVE]", "<li onclick=\"javascript:amaf_openMove([TOPICID])\"';\" title=\"[RESX:Move]\"><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i>&nbsp;[RESX:Move]</li>");
            }
            else
            {
                sbOutput = sbOutput.Replace("[ACTIONS:MOVE]", string.Empty);
            }

            sbOutput = sbOutput.Replace("[TOPICID]", TopicId.ToString());

            // Status
            if (_statusId <= 0 || (_statusId == 3 && replyStatusId == 0))
            {
                sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty);
            }
            else if (replyStatusId == 1)
            {
                // Answered
                if (_useListActions)
                    sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</li>");
                else
                    sbOutput.Replace("[ACTIONS:ANSWER]", "<span class=\"af-actions af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</span>");
            }
            else
            {
                // Not Answered
                if ((UserId == _topicAuthorId && !_bLocked) || _bModEdit)
                {
                    // Can mark answer
                    if (_useListActions)
                        sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-markanswer\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + ");\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</li>");
                    else
                        sbOutput.Replace("[ACTIONS:ANSWER]", "<a class=\"af-actions af-markanswer\" href=\"#\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + "); return false;\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</a>");
                }
                else
                {
                    // Display Nothing
                    sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty);
                }
            }

            // User Edit Date
            if (dateUpdated == dateCreated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate())
            {
                sbOutput.Replace("[EDITDATE]", string.Empty);
            }
            else
            {
                sbOutput.Replace("[EDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset));
            }

            // Mod Edit Date
            if (_bModEdit)
            {
                if (dateCreated == dateUpdated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate())
                    sbOutput.Replace("[MODEDITDATE]", string.Empty);
                else
                    sbOutput.Replace("[MODEDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset));
            }
            else
            {
                sbOutput.Replace("[MODEDITDATE]", string.Empty);
            }

            if (_allowLikes)
            {
                Image likeImage = new Image();
                var likesController = new LikesController();
                var likes = likesController.GetForPost(contentId);

                bool youLike = likes.Where(o => o.UserId == UserId)
                    .Select(o => o.Checked)
                    .FirstOrDefault();
                string image = string.Empty;
                if (youLike)
                    image = "fa-thumbs-o-up";
                else
                    image = "fa-thumbs-up";

                likeImage.ImageUrl = image;
                if (CanReply)
                {
                    sbOutput = sbOutput.Replace("[LIKES]", "<i class=\"fa " + image + "\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>");
                    sbOutput = sbOutput.Replace("[LIKESx2]", "<i class=\"fa " + image + " fa-2x\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>");
                    sbOutput = sbOutput.Replace("[LIKESx3]", "<i class=\"fa " + image + " fa-3x\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" > " + likes.Count.ToString() + "</i>");
                }
                else
                {
                    sbOutput = sbOutput.Replace("[LIKES]", "<i class=\"fa " + image + "\" /> " + likes.Count.ToString());
                    sbOutput = sbOutput.Replace("[LIKESx2]", "<i class=\"fa " + image + " fa-2x\" /> " + likes.Count.ToString());
                    sbOutput = sbOutput.Replace("[LIKESx3]", "<i class=\"fa " + image + " fa-3x\" /> " + likes.Count.ToString());
                    //sbOutput = sbOutput.Replace("[LIKES]", "<img src=\"" + image + "\" onclick=\"amaf_likePost(" + UserId + "," + contentId + ")\" /> " + likes.Count.ToString());
                }
            }
            else
            {
                sbOutput = sbOutput.Replace("[LIKES]", string.Empty);
                sbOutput = sbOutput.Replace("[LIKESx2]", string.Empty);
                sbOutput = sbOutput.Replace("[LIKESx3]", string.Empty);
            }

            // Poll Results
            if (sOutput.Contains("[POLLRESULTS]"))
            {
                if (_topicType == 1)
                {
                    var polls = new Polls();
                    sbOutput.Replace("[POLLRESULTS]", polls.PollResults(topicId, ImagePath));
                }
                else
                {
                    sbOutput.Replace("[POLLRESULTS]", string.Empty);
                }
            }

            // Mod Alert
            //var alertParams = new[] { ParamKeys.ViewType + "=modreport", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId };
            var alertParams = new List<string> { ParamKeys.ViewType + "=modreport", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId };
            if (SocialGroupId > 0) alertParams.Add(String.Format("{0}={1}", ParamKeys.GroupIdName, SocialGroupId));
            if (Request.IsAuthenticated)
            {
                if (_useListActions)
                    sbOutput.Replace("[ACTIONS:ALERT]", "<li onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", alertParams) + "';\" title=\"[RESX:Alert]\"><i class=\"fa fa-bell-o fa-fw fa-blue\"></i>&nbsp;[RESX:Alert]</li>");
                else
                    sbOutput.Replace("[ACTIONS:ALERT]", "<a class=\"af-actions\" href=\"" + Utilities.NavigateUrl(TabId, "", alertParams) + "\" title=\"[RESX:Alert]\"><i class=\"fa fa-bell-o fa-fw fa-blue\"></i>&nbsp;[RESX:Alert]</a>");
            }
            else
            {
                sbOutput.Replace("[ACTIONS:ALERT]", string.Empty);
            }

            // Process Body
            if (string.IsNullOrEmpty(body))
                body = " <br />";

            var sBody = Utilities.ManageImagePath(body);

            sBody = sBody.Replace("[", "&#91;");
            sBody = sBody.Replace("]", "&#93;");
            if (sBody.ToUpper().Contains("&#91;CODE&#93;"))
            {
                sBody = Regex.Replace(sBody, "(&#91;CODE&#93;)", "[CODE]", RegexOptions.IgnoreCase);
                sBody = Regex.Replace(sBody, "(&#91;\\/CODE&#93;)", "[/CODE]", RegexOptions.IgnoreCase);

            }
            //sBody = sBody.Replace("&lt;CODE&gt;", "<CODE>")
            if (Regex.IsMatch(sBody, "\\[CODE([^>]*)\\]", RegexOptions.IgnoreCase))
            {
                var objCode = new CodeParser();
                sBody = CodeParser.ParseCode(Utilities.HTMLDecode(sBody));
            }
            sBody = Utilities.StripExecCode(sBody);
            if (MainSettings.AutoLinkEnabled)
                sBody = Utilities.AutoLinks(sBody, Request.Url.Host);

            if (sBody.Contains("<%@"))
                sBody = sBody.Replace("<%@ ", "&lt;&#37;@ ");

            if (body.ToLowerInvariant().Contains("runat"))
                sBody = Regex.Replace(sBody, "runat", "&#114;&#117;nat", RegexOptions.IgnoreCase);

            sbOutput.Replace("[BODY]", sBody);

            // Subject
            sbOutput.Replace("[SUBJECT]", subject);

            // Attachments
            sbOutput.Replace("[ATTACHMENTS]", GetAttachments(contentId, true, PortalId, ModuleId));

            // Switch back from the string builder to a normal string before we perform the image/thumbnail replacements.

            sOutput = sbOutput.ToString();

            // Legacy attachment functionality, uses "attachid"
            // &#91;IMAGE:38&#93;
            if (sOutput.Contains("&#91;IMAGE:"))
            {
                var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/";
                const string pattern = "(&#91;IMAGE:(.+?)&#93;)";
                sOutput = Regex.Replace(sOutput, pattern, match => "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" class=\"afimg\" />");
            }

            // Legacy attachment functionality, uses "attachid"
            // &#91;THUMBNAIL:38&#93;
            if (sOutput.Contains("&#91;THUMBNAIL:"))
            {
                var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/";
                const string pattern = "(&#91;THUMBNAIL:(.+?)&#93;)";
                sOutput = Regex.Replace(sOutput, pattern, match =>
                {
                    var thumbId = match.Groups[2].Value.Split(':')[0];
                    var parentId = match.Groups[2].Value.Split(':')[1];
                    return "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + "\" border=\"0\" class=\"afimg\" /></a>";
                });
            }

            return sOutput;
        }
Ejemplo n.º 21
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum        fi = null;

            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                case "moddel":
                {
                    if (bModDelete)
                    {
                        int delAction  = ms.DeleteBehavior;
                        int tmpForumId = -1;
                        int tmpTopicId = -1;
                        int tmpReplyId = -1;
                        tmpForumId = Convert.ToInt32(e.Parameters[1]);
                        tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                        tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                        Author auth = null;
                        if (fi.ModDeleteTemplateId > 0)
                        {
                            try
                            {
                                //Email.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                Email.SendEmailToModerators(fi.ModDeleteTemplateId, PortalId, tmpForumId, tmpTopicId, tmpReplyId, ForumModuleId, ForumTabId, string.Empty);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                        {
                            TopicsController tc = new TopicsController();
                            TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                            if (ti != null)
                            {
                                auth = ti.Author;
                            }
                            tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                        }
                        else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                        {
                            ReplyController rc = new ReplyController();
                            ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                            if (ri != null)
                            {
                                auth = ri.Author;
                            }
                            rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                        }
                    }
                    break;
                }

                case "modreject":
                {
                    int tmpForumId  = 0;
                    int tmpTopicId  = 0;
                    int tmpReplyId  = 0;
                    int tmpAuthorId = 0;
                    tmpForumId  = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId  = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId  = Convert.ToInt32(e.Parameters[3]);
                    tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                    ModController mc = new ModController();
                    mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                    if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                    {
                        DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                        DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tmpAuthorId);
                        if (ui != null)
                        {
                            Author au = new Author();
                            au.AuthorId    = tmpAuthorId;
                            au.DisplayName = ui.DisplayName;
                            au.Email       = ui.Email;
                            au.FirstName   = ui.FirstName;
                            au.LastName    = ui.LastName;
                            au.Username    = ui.Username;
                            Email.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                        }
                    }

                    break;
                }

                case "modappr":
                {
                    int tmpForumId = -1;
                    int tmpTopicId = -1;
                    int tmpReplyId = -1;
                    tmpForumId = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                    string sSubject = string.Empty;
                    string sBody    = string.Empty;
                    if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                    {
                        TopicsController tc = new TopicsController();
                        TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                        if (ti != null)
                        {
                            sSubject      = ti.Content.Subject;
                            sBody         = ti.Content.Body;
                            ti.IsApproved = true;
                            tc.TopicSave(PortalId, ti);
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       sUrl     = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                {
                                    amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }
                    else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                    {
                        ReplyController rc = new ReplyController();
                        ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                        if (ri != null)
                        {
                            ri.IsApproved = true;
                            sSubject      = ri.Content.Subject;
                            sBody         = ri.Content.Body;
                            rc.Reply_Save(PortalId, ri);
                            TopicsController tc = new TopicsController();
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                            TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId);
                                if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                {
                                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }


                    break;
                }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }
Ejemplo n.º 22
0
        // ///
        // /// CusomtUpgrade315:
        // /// This upgrade deals with changing the author info as stored from username to userid
        // /// because of this user folders where files are stored will change from the user's username to the
        // /// user's id. The sql script will handle updating the tables, but we need this upgrade function
        // /// to change the name of the folder where each users files have been stored.
        // ///
        // /// cycle through all the repository modules. if they are using user folders, get the root location, then
        // /// rename all the user folders
        // ///
        public static string CustomUpgrade315()
        {
            string    m_message    = "";
            Hashtable settings     = null;
            string    m_foldername = null;

            string[] m_Folders    = null;
            string   m_Folder     = null;
            string   m_userFolder = null;
            string   m_newFolder  = null;

            DotNetNuke.Entities.Users.UserController m_userController = new DotNetNuke.Entities.Users.UserController();
            DotNetNuke.Entities.Users.UserInfo       m_userInfo       = null;

            try {
                PortalSettings          _portalSettings          = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
                DesktopModuleController _desktopModuleController = new DesktopModuleController();

                if ((DesktopModuleController.GetDesktopModuleByModuleName("Repository", Null.NullInteger) == null))
                {
                    return("No existing Repository modules found - no upgrade required");
                }

                RepositoryController repositories = new RepositoryController();
                ArrayList            arrModules   = new ArrayList();
                ModuleInfo           objModule    = null;
                arrModules = repositories.GetRepositoryModules(_portalSettings.PortalId);

                foreach (ModuleInfo objModule_loopVariable in arrModules)
                {
                    objModule = objModule_loopVariable;
                    // get the module settings
                    settings = objModule.ModuleSettings;

                    // if this module is using UserFolders...

                    if (!string.IsNullOrEmpty(Convert.ToString(settings["userfolders"])))
                    {
                        // then get the base folder name
                        if (!string.IsNullOrEmpty(Convert.ToString(settings["folderlocation"])))
                        {
                            m_foldername = Convert.ToString(settings["folderlocation"]);

                            // look in the base folder for any user folders
                            m_Folders = Directory.GetDirectories(m_foldername);

                            foreach (string m_Folder_loopVariable in m_Folders)
                            {
                                m_Folder     = m_Folder_loopVariable;
                                m_userFolder = m_Folder.Substring(m_Folder.LastIndexOf("\\") + 1);
                                m_userInfo   = DotNetNuke.Entities.Users.UserController.GetUserByName(objModule.PortalID, m_userFolder);

                                if ((m_userInfo != null))
                                {
                                    // we have a user folder, change the folder name to be the userid
                                    m_newFolder = m_Folder.Substring(0, m_Folder.LastIndexOf("\\") + 1) + m_userInfo.UserID.ToString();
                                    Directory.Move(m_Folder, m_newFolder);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                m_message += "EXCEPTION: " + ex.Message + " - " + ex.StackTrace.ToString();
            }

            m_message += "All DRM3 Modules upgraded to 3.1.5";
            return(m_message);
        }
Ejemplo n.º 23
0
        private string ToRss(
			IEnumerable<DocRollerInfo> lai, 
			string language, 
			string title,
			string description
			)
        {
            //CultureInfo culture = new CultureInfo(language);
            //string channel = string.Empty;

            const string eol = "";
            string channel_tpl = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + eol +
                "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">" + eol +
                    "<channel>" + eol +
                    "<title>[TITLE]</title>" + eol +
                    "<link>[LINK]</link>" + eol +
                    "<atom:link href=\"[LINK]\" rel=\"self\" type=\"application/rss+xml\" />" + eol +
                    "<description>[DESCRIPTION]</description>" + eol +
                    "<language>[LANGUAGE]</language>" + eol +
                    "<pubDate>[PUBDATE]</pubDate>" + eol +
                    "<lastBuildDate>[LAST_BUILD_DATE]</lastBuildDate>" + eol +
                    // <docs>http://blogs.law.harvard.edu/tech/rss</docs>
                    "<generator>[GENERATOR]</generator>" + eol +
                    "<managingEditor>[MANAGING_EDITOR]</managingEditor>" + eol +
                    "<webMaster>[WEBMASTER]</webMaster>" + eol +
                    "[ITEM_LIST]" + eol +
                    "</channel>" + eol +
                    "</rss>";

            string item_tpl = "<item>" + eol +
                "<title>[TITLE]</title>" + eol +
                    "<pubDate>[PUBDATE]</pubDate>" + eol +
                    "<link>[LINK]</link>" + eol +
                    "<description>[DESCRIPTION]</description>" + eol +
                    //<category>url</category>
                    "<guid>[GUID]</guid>" + eol +
                    "</item>" + eol;

            // временно!!!
            // channel_tpl = channel_tpl.Replace("[TITLE]", this.ModuleConfiguration.ModuleTitle);
            channel_tpl = channel_tpl.Replace ("[TITLE]", title);

            // временно!!!
            channel_tpl = channel_tpl.Replace ("[DESCRIPTION]", description);
            // из description страницы по TabId?

            channel_tpl = channel_tpl.Replace ("[LANGUAGE]", language);

            channel_tpl = channel_tpl.Replace ("[LINK]",
                                               Server.HtmlEncode (
                //"http://" + PortalSettings.PortalAlias.HTTPAlias +
                EditUrl ("RSS"))
                                               );

            // CultureInfo ci = new CultureInfo("en-US");
            // Console.WriteLine("{0,-30}{1}\n", msgCulture, ci.DisplayName);

            DateTime.Now.ToString ("R").Replace ("GMT", "+0300");

            channel_tpl = channel_tpl.Replace ("[PUBDATE]", FormatDateTime_RFC822 (DateTime.Now));
            channel_tpl = channel_tpl.Replace ("[LAST_BUILD_DATE]", FormatDateTime_RFC822 (DateTime.Now));

            // Get Admin
            DotNetNuke.Entities.Users.UserController uctrl = new DotNetNuke.Entities.Users.UserController ();
            DotNetNuke.Entities.Users.UserInfo admin = uctrl.GetUser (PortalId, PortalSettings.AdministratorId);

            string adminInfo = string.Format ("{0} ({1} {2})",
                                              admin.Email, admin.FirstName, admin.LastName);

            // почта должна дополняться реальным именем [email protected] (vasya pupkin)
            channel_tpl = channel_tpl.Replace ("[WEBMASTER]", adminInfo);
            channel_tpl = channel_tpl.Replace ("[MANAGING_EDITOR]", adminInfo);

            channel_tpl = channel_tpl.Replace ("[GENERATOR]",
                                               //String.Format("{0} v{1}", ModuleConfiguration.ModuleName, ModuleConfiguration.Version));
                                               String.Format ("AnnoView v{0}", ModuleConfiguration.DesktopModule.Version));

            string itemListStr = string.Empty;
                // временно отлючено
            foreach (DocRollerInfo item in lai)
            {
                string itemStr = item_tpl;

                itemStr = itemStr.Replace ("[TITLE]", item.Content);

                var url = "";
                var descr = "";

                if (item.Tab != null) {
                    url = "/default.aspx?TabId=" + item.Tab.TabID;
                    var tc = new TabController ();
                    descr = tc.GetTab (item.Tab.TabID, PortalId, true).Description;
                }
                    if (item.DesktopModule != null)
                    url ="/default.aspx?DesktopModuleId="+ item.DesktopModule.DesktopModuleID;
                if (item.TabModule != null)
                    url =string.Format ("/default.aspx?tabid={0}&mid={1}", item.TabModule.TabID, item.TabModule.ModuleID);
                if (item.Journal != null)
                    url ="/default.aspx?JournalId="+ item.Journal.JournalID;

                itemStr = itemStr.Replace ("[LINK]", Server.HtmlEncode (
                    "http://" + PortalSettings.PortalAlias.HTTPAlias +
                    url));

                itemStr = itemStr.Replace ("[DESCRIPTION]", descr);

                                           /*);
                itemStr = itemStr.Replace ("[DESCRIPTION]",
                                           ai.Description
                                           .Replace ("&amp;nbsp;", " ") // необязательно!
                                           .Replace ("&amp;#160;", " ") //
                                           .Replace ("href=&quot;/Portals/",
                          String.Format ("href=&quot;http://{0}/Portals/",
                               PortalSettings.PortalAlias.HTTPAlias))
                                           .Replace ("href=&quot;/LinkClick.aspx",
                          String.Format ("href=&quot;http://{0}/LinkClick.aspx",
                               PortalSettings.PortalAlias.HTTPAlias))

                                           // TODO: Add Rege.Replace to &quot;htt..&quot; to UrlEncode
                                           // this will replace cyrillic letters in Url to %XX codes

                                           );*/

                itemStr = itemStr.Replace ("[PUBDATE]", FormatDateTime_RFC822 (item.CreatedOnDate));
                itemStr = itemStr.Replace ("[GUID]", // CHECK
                                           Server.HtmlEncode (
                    //"http://" + PortalSettings.PortalAlias.HTTPAlias +
                    Globals.NavigateURL () +
                    String.Format ("&Mid={0}&ItemId={1}", this.ModuleId, item.ContentItemID))
                                           );

                itemListStr += itemStr;
            }

            //itemListStr = item_tpl; // for testing only!
            channel_tpl = channel_tpl.Replace ("[ITEM_LIST]", itemListStr);

            return channel_tpl;
        }
Ejemplo n.º 24
0
        public string GetNewGrid()
        {
            //Roles
            string[] roles   = GetSecureObjectList(Security, 0).Split(';');
            int[]    roleIds = new int[roles.Length - 2 + 1];
            int      i       = 0;

            for (i = 0; i <= roles.Length - 2; i++)
            {
                if (!(string.IsNullOrEmpty(roles[i])))
                {
                    roleIds[i] = Convert.ToInt32(roles[i]);
                }
            }
            Array.Sort(roleIds);
            string tmp = string.Empty;

            foreach (int n in roleIds)
            {
                tmp += n.ToString() + ";";
            }
            List <PermissionInfo> pl = new List <PermissionInfo>();

            //litNewGrid.Text = "Roles:" & tmp

            //litNewGrid.Text &= "<br />RolesNames:" & Permissions.GetRolesNVC(tmp)
            NameValueCollection nvc = Permissions.GetRolesNVC(tmp, PortalId);

            foreach (string key in nvc.AllKeys)
            {
                PermissionInfo pi = new PermissionInfo();
                pi.ObjectId   = key;
                pi.ObjectName = nvc[key];
                pi.Type       = ObjectType.RoleId;
                pl.Add(pi);
            }

            //Users
            string users     = GetSecureObjectList(Security, 1);
            string userNames = string.Empty;

            if (!(string.IsNullOrEmpty(users)))
            {
                DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                foreach (string uid in users.Split(';'))
                {
                    if (!(string.IsNullOrEmpty(uid)))
                    {
                        DotNetNuke.Entities.Users.UserInfo u = uc.GetUser(PortalId, Convert.ToInt32(uid));
                        if (u != null)
                        {
                            PermissionInfo pi = new PermissionInfo();
                            pi.ObjectId   = u.UserID.ToString();
                            pi.ObjectName = u.DisplayName;
                            pi.Type       = ObjectType.UserId;
                            pl.Add(pi);
                        }
                    }
                }
            }
            //Groups
            string groups = GetSecureObjectList(Security, 2);

            if (!(string.IsNullOrEmpty(groups)))
            {
                foreach (string g in groups.Split(';'))
                {
                    if (!(string.IsNullOrEmpty(g)))
                    {
                        Social uc        = new Social();
                        string gType     = g.Split(':')[1];
                        int    groupId   = Convert.ToInt32(g.Split(':')[0]);
                        string groupName = uc.ActiveSocialGetGroup(groupId);
                        if (!(string.IsNullOrEmpty(groupName)))
                        {
                            PermissionInfo pi = new PermissionInfo();
                            pi.ObjectId    = g;
                            pi.ObjectName  = groupName;
                            pi.Type        = ObjectType.GroupId;
                            pi.ObjectName += "-" + uc.ActiveSocialGetGroupType(Convert.ToInt32(gType), PortalId);
                            pl.Add(pi);
                        }
                    }
                }
            }

            string[,] grid = new string[pl.Count + 1, 28];
            i = 0;
            foreach (PermissionInfo pi in pl)
            {
                grid[i, 0]  = pi.ObjectId;
                grid[i, 1]  = pi.ObjectName;
                grid[i, 2]  = Convert.ToString(pi.Type);
                grid[i, 3]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.View));
                grid[i, 4]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Read));
                grid[i, 5]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Create));
                grid[i, 6]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Reply));
                grid[i, 7]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Edit));
                grid[i, 8]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Delete));
                grid[i, 9]  = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Lock));
                grid[i, 10] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Pin));
                grid[i, 11] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Attach));
                grid[i, 12] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Poll));
                grid[i, 13] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Block));
                grid[i, 14] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Trust));
                grid[i, 15] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Subscribe));
                grid[i, 16] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Announce));
                grid[i, 17] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Tag));
                grid[i, 18] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Categorize));
                grid[i, 19] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.Prioritize));

                grid[i, 20] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModApprove));
                grid[i, 21] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModMove));
                grid[i, 22] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModSplit));
                grid[i, 23] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModDelete));
                grid[i, 24] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModUser));
                grid[i, 25] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModEdit));
                grid[i, 26] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModLock));
                grid[i, 27] = Convert.ToString(PermValue((int)pi.Type, pi.ObjectId, Security.ModPin));


                i += 1;
            }
            System.Type   enumType = typeof(SecureActions);
            Array         values   = Enum.GetValues(enumType);
            StringBuilder sb       = new StringBuilder();

            sb.Append("<table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\"><div class=\"afsecobjects\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
            sb.Append("<tr><td class=\"afsecobjecthd\" colspan=\"2\">" + Utilities.GetSharedResource("[RESX:SecureObjects]", true) + "</td></tr>");
            string tmpObjectName = string.Empty;
            int    secRows       = 0;

            for (int x = 0; x < pl.Count; x++)
            {
                sb.Append("<tr><td style=\"width:16px;\"></td><td class=\"afsecobject\" style=\"white-space:nowrap;\"><div class=\"afsecobjecttxt\" title=\"" + grid[x, 1] + "\" onmouseover=\"this.firstChild.style.display='';\" onmouseout=\"this.firstChild.style.display='none';\"><span style=\"width:16px;height:16px;float:right;display:none;\">");
                if ((Convert.ToInt32(grid[x, 2]) == 0 && Convert.ToInt32(grid[x, 0]) > 0) | Convert.ToInt32(grid[x, 2]) > 0)
                {
                    if (!ReadOnly)
                    {
                        sb.Append("<img src=\"" + ImagePath + "mini_del.gif\" alt=\"Remove Object\" style=\"cursor:pointer;z-index:10;\" class=\"afminidel\" onclick=\"securityDelObject(this,'" + grid[x, 0] + "'," + grid[x, 2] + "," + PermissionsId + ");\" />");
                    }
                }
                sb.Append("</span>" + grid[x, 1]);
                sb.Append("</div></td></tr>");
            }
            sb.Append("</table></div></td><td valign=\"top\" width=\"94%\"><div class=\"afsecactions\" style=\"overflow-x:auto;overflow-y:hidden;\">");
            //litNewObjects.Text = sb.ToString
            //sb = New StringBuilder

            sb.Append("<table cellpadding=0 cellspacing=0 border=0 width=\"100%\" id=\"tblSecGrid\">");
            sb.Append("<tr>");
            string keyText = string.Empty;

            for (int td = 3; td <= 27; td++)
            {
                keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(td - 3).ToString()));
                if (keyText.ToLowerInvariant() == "block")
                {
                    sb.Append("<td class=\"afsecactionhd\" style=\"display:none;\">");
                }
                else
                {
                    sb.Append("<td class=\"afsecactionhd\">");
                }


                sb.Append(keyText);
                sb.Append("</td>");
            }
            sb.Append("</tr>");
            for (int x = 0; x < pl.Count; x++)
            {
                sb.Append("<tr onmouseover=\"this.className='afgridrowover'\" onmouseout=\"this.className='afgridrow'\">");
                for (int r = 3; r <= 27; r++)
                {
                    keyText = Convert.ToString(Enum.Parse(enumType, values.GetValue(r - 3).ToString()));
                    bool   bState = Convert.ToBoolean(grid[x, r]);                   //Permissions.HasPermission(ForumID, Integer.Parse(dr("ObjectId").ToString), key, Integer.Parse(dr("SecureType").ToString), dt)
                    string sState = "<img src=\"" + ImagePath + "admin_stop.png\" alt=\"Disabled\" />";
                    if (bState)
                    {
                        sState = "<img src=\"" + ImagePath + "admin_check.png\" alt=\"Enabled\" />";
                    }
                    if (keyText.ToLowerInvariant() == "block")
                    {
                        sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;display:none;\">");
                    }
                    else
                    {
                        sb.Append("<td class=\"afsecactionelem\" style=\"text-align:center;\">");
                    }

                    sb.Append("<div class=\"afsectoggle\" id=\"" + grid[x, 0] + grid[x, 2] + keyText + "\" ");
                    if (!ReadOnly)
                    {
                        sb.Append("onclick=\"securityToggle(this," + PermissionsId + ",'" + grid[x, 0] + "','" + grid[x, 1] + "'," + grid[x, 2] + ",'" + keyText + "');\"");
                    }
                    sb.Append(">" + sState + "</div></td>");
                }
                sb.Append("</tr>");
            }
            sb.Append("</table></div></td></tr></table>");
            return(sb.ToString());
        }
Ejemplo n.º 25
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum fi = null;
            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                    case "moddel":
                        {
                            if (bModDelete)
                            {
                                int delAction = ms.DeleteBehavior;
                                int tmpForumId = -1;
                                int tmpTopicId = -1;
                                int tmpReplyId = -1;
                                tmpForumId = Convert.ToInt32(e.Parameters[1]);
                                tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                                tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                                Author auth = null;
                                if (fi.ModDeleteTemplateId > 0)
                                {
                                    try
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                    }
                                    catch (Exception ex)
                                    {

                                    }

                                }
                                if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                                {
                                    TopicsController tc = new TopicsController();
                                    TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                                    if (ti != null)
                                    {
                                        auth = ti.Author;
                                    }
                                    tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                                }
                                else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                                {
                                    ReplyController rc = new ReplyController();
                                    ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                                    if (ri != null)
                                    {
                                        auth = ri.Author;
                                    }
                                    rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                                }

                            }
                            break;
                        }
                    case "modreject":
                        {
                            int tmpForumId = 0;
                            int tmpTopicId = 0;
                            int tmpReplyId = 0;
                            int tmpAuthorId = 0;
                            tmpForumId = Convert.ToInt32(e.Parameters[1]);
                            tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                            tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                            tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                            ModController mc = new ModController();
                            mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                            if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                            {
                                DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                                DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tmpAuthorId);
                                if (ui != null)
                                {
                                    Author au = new Author();
                                    au.AuthorId = tmpAuthorId;
                                    au.DisplayName = ui.DisplayName;
                                    au.Email = ui.Email;
                                    au.FirstName = ui.FirstName;
                                    au.LastName = ui.LastName;
                                    au.Username = ui.Username;
                                    Email oEmail = new Email();
                                    oEmail.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                                }

                            }

                            break;
                        }
                    case "modappr":
                        {
                            int tmpForumId = -1;
                            int tmpTopicId = -1;
                            int tmpReplyId = -1;
                            tmpForumId = Convert.ToInt32(e.Parameters[1]);
                            tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                            tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                            string sSubject = string.Empty;
                            string sBody = string.Empty;
                            if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                            {
                                TopicsController tc = new TopicsController();
                                TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                                if (ti != null)
                                {
                                    sSubject = ti.Content.Subject;
                                    sBody = ti.Content.Body;
                                    ti.IsApproved = true;
                                    tc.TopicSave(PortalId, ti);
                                    tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                                    //TODO: Add Audit log for who approved topic
                                    if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                                    }

                                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                                    try
                                    {
                                        ControlUtils ctlUtils = new ControlUtils();
                                        string sUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                        if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                        {
                                            sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                        }
                                        Social amas = new Social();
                                        if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                        {
                                            amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                        }
                                        else
                                        {
                                            amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                        }

                                    }
                                    catch (Exception ex)
                                    {
                                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                                    }
                                }
                            }
                            else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                            {
                                ReplyController rc = new ReplyController();
                                ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                                if (ri != null)
                                {
                                    ri.IsApproved = true;
                                    sSubject = ri.Content.Subject;
                                    sBody = ri.Content.Body;
                                    rc.Reply_Save(PortalId, ri);
                                    TopicsController tc = new TopicsController();
                                    tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                                    TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                                    //TODO: Add Audit log for who approved topic
                                    if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                                    }

                                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                                    try
                                    {
                                        ControlUtils ctlUtils = new ControlUtils();
                                        string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId);
                                        if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                        {
                                            fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                        }
                                        Social amas = new Social();
                                        if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                        {
                                            amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                        }
                                        else
                                        {
                                            amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                                    }

                                }

                            }

                            break;
                        }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }