コード例 #1
0
ファイル: EmailController.cs プロジェクト: haimon74/KanNaim
		/// <summary>
		/// Sends an e-mail based on the <paramref name="templateForm"/> to the specified <paramref name="user"/>.
		/// No action is taken if the user's e-mail is null or empty. The e-mail is sent on a 
		/// background thread, so if an error occurs on that thread no exception bubbles to the caller (the error, however, is
		/// recorded in the error log). If <paramref name="sendOnBackgroundThread"/> is true, the e-mail is sent on a background 
		/// thread and the function returns immediately. An exception is thrown if an error occurs while sending the e-mail, 
		/// unless <paramref name="sendOnBackgroundThread"/> is true, in which case the error is logged but the exception does 
		/// not propagate back to the UI thread.
		/// </summary>
		/// <param name="user">The user to receive the e-mail.</param>
		/// <param name="templateForm">The template form specifying the type of e-mail to send.</param>
		/// <param name="sendOnBackgroundThread">If set to <c>true</c> send e-mail on a background thread. This causes any errors
		/// to be silently handled by the error logging system, so if it is important for any errors to propogate to the UI,
		/// such as when testing the e-mail function in the Site Administration area, set to <c>false</c>.</param>
		public static void SendNotificationEmail(UserEntity user, EmailTemplateForm templateForm, bool sendOnBackgroundThread)
		{
			if (String.IsNullOrEmpty(user.Email))
				return;

			EmailTemplate emailTemplate = GetEmailTemplate(templateForm, user);

			MailAddress emailRecipient = new MailAddress(user.Email, user.UserName);

			SendEmail(emailRecipient, emailTemplate.Subject, emailTemplate.Body, sendOnBackgroundThread);
		}
コード例 #2
0
		private void ReportSuccess(UserEntity user)
		{
			string title = Resources.GalleryServerPro.CreateAccount_Success_Header_Text;

			string detailPendingNotification = String.Concat("<p>", Resources.GalleryServerPro.CreateAccount_Success_Detail1_Text, "</p>");
			detailPendingNotification += String.Concat(@"<p>", String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.CreateAccount_Success_Pending_Notification_Detail2_Text, user.Email), "</p>");
			detailPendingNotification += String.Concat(@"<p>", Resources.GalleryServerPro.CreateAccount_Success_Pending_Notification_Detail3_Text, "</p>");

			string detailPendingApproval = String.Concat("<p>", Resources.GalleryServerPro.CreateAccount_Success_Detail1_Text, "</p>");
			detailPendingApproval += String.Concat(@"<p>", String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.CreateAccount_Success_Pending_Approval_Detail2_Text), "</p>");
			detailPendingApproval += String.Concat(@"<p>", Resources.GalleryServerPro.CreateAccount_Success_Pending_Approval_Detail3_Text, "</p>");

			string detailActivated = string.Format(@"<p>{0}</p><p><a href=""{1}"">{2}</a></p>",
			                                       Resources.GalleryServerPro.CreateAccount_Success_Detail1_Text,
			                                       Util.GetCurrentPageUrl(),
			                                       Resources.GalleryServerPro.CreateAccount_Gallery_Link_Text);

			if (EnableEmailVerification)
			{
				DisplaySuccessMessage(title, detailPendingNotification);
			}
			else if (RequireAdminApproval)
			{
				DisplaySuccessMessage(title, detailPendingApproval);
			}
			else
			{
				UserController.LogOnUser(user.UserName);

				if (EnableUserAlbum && (UserController.GetUserAlbumId(user.UserName) > int.MinValue))
				{
					detailActivated += String.Format(@"<p><a href=""{0}"">{1}</a></p>",
																					 Util.GetUrl(PageId.album, "aid={0}", UserController.GetUserAlbumId(user.UserName)),
																					 Resources.GalleryServerPro.CreateAccount_User_Album_Link_Text);
				}

				DisplaySuccessMessage(title, detailActivated);
			}

			pnlCreateUser.Visible = false;
		}
コード例 #3
0
ファイル: EmailController.cs プロジェクト: haimon74/KanNaim
		/// <summary>
		/// Sends an e-mail based on the <paramref name="templateForm"/> to the specified <paramref name="user"/>.
		/// No action is taken if the user's e-mail is null or empty. The e-mail is sent on a 
		/// background thread, so if an error occurs on that thread no exception bubbles to the caller (the error, however, is
		/// recorded in the error log).
		/// </summary>
		/// <param name="user">The user to receive the e-mail.</param>
		/// <param name="templateForm">The template form specifying the type of e-mail to send.</param>
		public static void SendNotificationEmail(UserEntity user, EmailTemplateForm templateForm)
		{
			SendNotificationEmail(user, templateForm, true);
		}
コード例 #4
0
ファイル: EmailController.cs プロジェクト: haimon74/KanNaim
		/// <summary>
		/// Gets the email template. Replacement parameters in the template are replaced with their appropriate values. The data
		/// in the template can be used to construct an e-mail.
		/// </summary>
		/// <param name="template">The template to retrieve.</param>
		/// <param name="user">The user associated with the template.</param>
		/// <returns>Returns an e-mail template.</returns>
		public static EmailTemplate GetEmailTemplate(EmailTemplateForm template, UserEntity user)
		{
			EmailTemplate emailTemplate = new EmailTemplate();
			emailTemplate.EmailTemplateId = template;

			string filePath = Util.GetPath(String.Format(CultureInfo.InvariantCulture, "/templates/{0}.txt", template));

			// Step 1: Get subject and body from text file and assign to fields.
			using (StreamReader sr = File.OpenText(filePath))
			{
				while (sr.Peek() >= 0)
				{
					string lineText = sr.ReadLine().Trim();

					if (lineText == "[Subject]")
						emailTemplate.Subject = sr.ReadLine();

					if (lineText == "[Body]")
						emailTemplate.Body = sr.ReadToEnd();
				}
			}

			// Step 2: Update replacement parameters with real values.
			emailTemplate.Body = emailTemplate.Body.Replace("{CurrentPageUrlFull}", Util.GetCurrentPageUrlFull());
			emailTemplate.Body = emailTemplate.Body.Replace("{UserName}", user.UserName);
			emailTemplate.Body = emailTemplate.Body.Replace("{Email}", String.IsNullOrEmpty(user.Email) ? Resources.GalleryServerPro.Email_Template_No_Email_For_User_Replacement_Text : user.Email);

			if (emailTemplate.Body.Contains("{VerificationUrl}"))
				emailTemplate.Body = emailTemplate.Body.Replace("{VerificationUrl}", GenerateVerificationLink(user.UserName));

			if (emailTemplate.Body.Contains("{Password}"))
				emailTemplate.Body = emailTemplate.Body.Replace("{Password}", UserController.GetPassword(user.UserName));

			if (emailTemplate.Body.Contains("{ManageUserUrl}"))
				emailTemplate.Body = emailTemplate.Body.Replace("{ManageUserUrl}", GenerateManageUserLink(user.UserName));

			return emailTemplate;
		}
コード例 #5
0
ファイル: manageusers.ascx.cs プロジェクト: haimon74/KanNaim
		/// <summary>
		/// Select the checkboxes corresponding to the roles to which the specified user belong. This method assumes the checkboxlist 
		/// has already been created and databound with the objectdatasource.
		/// </summary>
		/// <param name="user">An instance of <see cref="UserEntity"/> that represents a user in the application.</param>
		private void BindRolePermissionCheckboxes(UserEntity user)
		{
			cblAvailableRolesForExistingUser.ClearSelection();
			string[] rolesForUser = RoleController.GetRolesForUser(user.UserName);
			foreach (ListItem checkbox in cblAvailableRolesForExistingUser.Items)
			{
				string checkboxRoleName = Util.HtmlDecode(checkbox.Value);
				if (Array.Exists(rolesForUser, delegate(string roleName)
				                               	{
				                               		return (roleName == checkboxRoleName);
				                               	}))
				{
					checkbox.Selected = true;
				}

				if (RoleController.IsRoleAnAlbumOwnerRole(checkboxRoleName))
				{
					checkbox.Attributes["class"] = "gsp_j_eaor";
				}
			}
		}
コード例 #6
0
ファイル: manageusers.ascx.cs プロジェクト: haimon74/KanNaim
		private void BindUserInfoControls(UserEntity user, bool updateWriteableControls)
		{
			lblUserName.Text = Util.HtmlEncode(user.UserName);

			if (updateWriteableControls)
			{
				txtComment.Text = user.Comment;
				txtEmail.Text = user.Email;
				rbApprovedYes.Checked = user.IsApproved;
				rbApprovedNo.Checked = !user.IsApproved;

				ProfileEntity profile = ProfileController.GetProfile(user.UserName);
				rbUserAlbumYes.Checked = profile.EnableUserAlbum;
				rbUserAlbumNo.Checked = !profile.EnableUserAlbum;
			}

			try
			{
				lblCreationDate.Text = String.Format(CultureInfo.CurrentCulture, "{0:F} (GMT)", user.CreationDate);
				lblLastActivityDate.Text = String.Format(CultureInfo.CurrentCulture, "{0:F} (GMT)", user.LastActivityDate);
				lblLastLogOnDate.Text = String.Format(CultureInfo.CurrentCulture, "{0:F} (GMT)", user.LastLoginDate);
				lblLastPasswordChangedDate.Text = String.Format(CultureInfo.CurrentCulture, "{0:F} (GMT)", user.LastPasswordChangedDate);
			}
			catch (NotSupportedException) { /* Ignore if provider does not support one or more properties */}
		}
コード例 #7
0
ファイル: manageusers.ascx.cs プロジェクト: haimon74/KanNaim
		private void CheckForLockedUser(UserEntity user)
		{
			if (!user.IsLockedOut) return;

			string msgHeader = Resources.GalleryServerPro.Admin_Manage_Users_Locked_User_Hdr;
			string msgDetail = String.Format(CultureInfo.CurrentCulture, "{0} <a href=\"javascript:unlockUser()\">{1}</a>", Resources.GalleryServerPro.Admin_Manage_Users_Locked_User_Dtl, Resources.GalleryServerPro.Admin_Manage_Users_Unlock_User_Hyperlink_Text);

			GalleryServerPro.Web.Controls.usermessage msgBox = (GalleryServerPro.Web.Controls.usermessage)LoadControl(Util.GetUrl("/controls/usermessage.ascx"));
			msgBox.IconStyle = GalleryServerPro.Web.MessageStyle.Information;
			msgBox.MessageTitle = msgHeader;
			msgBox.MessageDetail = msgDetail;
			phEditUserMessage.Controls.Add(msgBox);
		}