Преглед изворни кода

Send welcome email upon activation.

Alan Lam пре 8 година
родитељ
комит
4d76816d39
3 измењених фајлова са 96 додато и 0 уклоњено
  1. 3 0
      controllers/user_activation.php
  2. 72 0
      emails/welcome.html
  3. 21 0
      engine/user.php

+ 3 - 0
controllers/user_activation.php

@@ -9,6 +9,9 @@ if($user && $user->activated == 0) {
 	$user->verify_token = null;
 	$success = $user->commit();
 	if(!$success) throw new Exception("Email verification failed. Please try again later.");
+
+	$user->sendWelcomeEmail();
+
 	Core::addAlert("success", "Email address verified. You can now log in to your account.");
 }
 else {

+ 72 - 0
emails/welcome.html

@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+		<title>Check Policy</title>
+		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+	</head>
+	<body>
+		<table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
+			<tr>
+				<td>
+					<table border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc;">
+						<tr>
+							<td align="center" style="padding: 40px 0 40px 0; border-bottom: 1px solid #cccccc;">
+								<a href="">
+									<img src="../public/img/logo.png" width="386" height="80" style="display: block;" alt="Check Policy logo" />
+								</a>
+							</td>
+						</tr>
+						<tr>
+							<td style="padding: 40px 30px 40px 30px;">
+								<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+									<tr>
+										<td style="padding: 0 0 20px 0; font-family: Arial, sans-serif;">
+											<b>Hi {name},</b>
+										</td>
+									</tr>
+									<tr>
+										<td style="padding: 0 0 20px 0; font-family: Arial, sans-serif; font-size: 24px;">
+											<b>Thanks for verifying your email address!</b>
+										</td>
+									</tr>
+									<tr>
+										<td style="padding: 0 0 20px 0; font-family: Arial, sans-serif;">
+											Welcome to Check Policy! Before you can take part in tests, you will need to provide us with some ID. You can do so by tapping the following link:
+										</td>
+									</tr>
+									<tr>
+										<td style="padding: 0 0 20px 0; font-family: Arial, sans-serif;">
+											<a href="{link}">{link}</a>
+										</td>
+									</tr>
+									<tr>
+										<td style="font-family: Arial, sans-serif;">
+											Check Policy Team
+										</td>
+									</tr>
+								</table>
+							</td>
+						</tr>
+						<tr>
+							<td bgcolor="#4CAF50" style="padding: 40px 30px 40px 30px;">
+								<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+									<tr>
+										<td style="font-family: Arial, sans-serif;">
+											<b><font color="#ffffff">&copy; Check Policy 2018</font></b>
+										</td>
+										<td align="right" style="font-family: Arial, sans-serif;">
+											<a href="https://www.facebook.com/checkpolicy" style="color: #ffffff;">
+												<font color="#ffffff">Facebook</font>
+											</a>
+										</td>
+									</tr>
+								</table>
+							</td>
+						</tr>
+					</table>
+				</td>
+			</tr>
+		</table>
+	</body>
+</html>

+ 21 - 0
engine/user.php

@@ -76,6 +76,27 @@ class User extends Model {
 		return true;
 	}
 
+	public function sendWelcomeEmail() {
+
+		$mail = new Email();
+
+		$mail->loadHtmlTemplate("welcome");
+		$mail->setValues([
+			"name" => $this->first_name,
+			"link" => PROTOCOL . "://" . DOMAIN . "/account/submit-id"
+		]);
+
+		$mail->setFrom("noreply@check-policy.co.uk", "Check Policy");
+		$mail->addAddress($this->email, $this->getDisplayName());
+
+		$mail->setSubject("Welcome to Check Policy");
+
+		$mail->send();
+
+		return true;
+
+	}
+
 	public function canAdmin() {
 		return $this->level >= User::LEVEL_ADMIN;
 	}