diff --git a/controllers/admin_controller.php b/controllers/admin_controller.php index 6012925..786585f 100644 --- a/controllers/admin_controller.php +++ b/controllers/admin_controller.php @@ -201,13 +201,11 @@ function invite() { $this->plugins->log->add($_SESSION['user_id'], 'invite', $id, 'admin_add', $email); } - $to = $email; - $link = $this->config->url . 'users/add/' . $id . '/?email=' . urlencode($email); - // Load template into $body variable $to = array('email' => $email); $subject = '[' . $this->config->name . '] Your ' . $this->config->name . ' invite is here!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/admin_invite.html"), array('link' => $link, 'app' => array('config' => $this->config))); + $link = $this->config->url . 'users/add/' . $id . '/?email=' . urlencode($email); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/admin_invite.html"), array('link' => $link, 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body); diff --git a/controllers/comments_controller.php b/controllers/comments_controller.php index 9d1da3e..c948d58 100644 --- a/controllers/comments_controller.php +++ b/controllers/comments_controller.php @@ -18,13 +18,12 @@ function add() { $to = array('name' => $item->user->username, 'email' => $item->user->email); $subject = '[' . $this->config->name . '] Someone left a ' . strtolower($this->config->items['comments']['name']) . ' on your ' . strtolower($this->config->items['titles']['name']) . ' on ' . $this->config->name . '!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/item_comment.html"), array('link' => substr($this->config->url, 0, -1) . $this->url_for('items', 'show', $item->id), 'app' => array('config' => $this->config), 'user' => $item->user)); + $link = substr($this->config->url, 0, -1) . $this->url_for('items', 'show', $item->id); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/item_comment.html"), array('link' => $link, 'app' => $this, 'user' => $item->user)); // Email user $this->email->send_email($to, $subject, $body); - } else { - ECHO 'NO'; } // Log new comment diff --git a/controllers/friends_controller.php b/controllers/friends_controller.php index 6629314..922ef6f 100644 --- a/controllers/friends_controller.php +++ b/controllers/friends_controller.php @@ -23,7 +23,7 @@ function add($friend_id) { $to = array('email' => $email, 'friend' => $friend); $link = $this->config->url . 'users/show/' . $user->id; $subject = '[' . $this->config->name . '] Your ' . $this->config->name . ' invite is here!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/follower_new.html"), array('link' => $link, 'app' => array('config' => $this->config))); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/follower_new.html"), array('link' => $link, 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body); diff --git a/controllers/invites_controller.php b/controllers/invites_controller.php index 13c093e..4526c5f 100644 --- a/controllers/invites_controller.php +++ b/controllers/invites_controller.php @@ -86,11 +86,10 @@ function add() { $admin = User::get_by_id($this->config->admin_users[0]); - $link = $this->config->url . 'signup/' . $id; - - $to = array('email' => $_POST['email']); + $to = array('email' => $_POST['email']); $subject = '[' . $this->config->name . '] An invitation from ' . $user->username; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/invite_friend.html"), array('link' => $link, 'user' => $user, 'app' => array('config' => $this->config))); + $link = $this->config->url . 'signup/' . $id; + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/invite_friend.html"), array('user' => $user, 'link' => $link, 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body); diff --git a/controllers/likes_controller.php b/controllers/likes_controller.php index 45264ce..2431047 100644 --- a/controllers/likes_controller.php +++ b/controllers/likes_controller.php @@ -14,7 +14,8 @@ function add($item_id) { $to = array('name' => $item->user->username, 'email' => $item->user->email); $subject = '[' . $this->config->name . '] Someone clicked ' . strtolower($this->config->items['likes']['name']) . ' on your ' . strtolower($this->config->items['name']) . ' on ' . $this->config->name . '!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/item_like.html"), array('link' => substr($this->config->url, 0, -1) . $this->url_for('items', 'show', $item->id), 'app' => array('config' => $this->config), 'user' => $item->user)); + $link = substr($this->config->url, 0, -1) . $this->url_for('items', 'show', $item->id); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/item_like.html"), array('user' => $item->user, 'link' => $link, 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body); diff --git a/controllers/users_controller.php b/controllers/users_controller.php index 8281279..6e5f42e 100644 --- a/controllers/users_controller.php +++ b/controllers/users_controller.php @@ -250,7 +250,7 @@ function reset($code = null) { $to = array('email' => $_POST['email']); $link = substr($this->config->url, 0, -1).$this->url_for('users', 'reset', $code); $subject = '[' . $this->config->name . '] Password reset'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/password_reset.html"), array('link' => $link, 'user' => $user, 'app' => array('config' => $this->config))); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/password_reset.html"), array('user' => $user, 'link' => $link, 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body); @@ -453,7 +453,7 @@ private function signup_code() { $to = array('name' => $_POST['username'], 'email' => $_POST['email']); $subject = '[' . $this->config->name . '] Your ' . $this->config->name . ' invite is here!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/signup.html"), array('username' => $_POST['username'], 'app' => array('config' => $this->config))); + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/signup.html"), array('username' => $_POST['username'], 'app' => $this)); $this->email->send_email($to, $subject, $body); @@ -582,9 +582,9 @@ private function signup_beta() { // There was an error // Propagate get vars to be picked up by the form - $this->uri['params']['email'] = $_POST['email']; - $this->uri['params']['username'] = $_POST['username']; - $this->code = $_POST['code']; + $this->uri['params']['email'] = $_POST['email']; + $this->uri['params']['username'] = $_POST['username']; + $this->code = $_POST['code']; // Show error message Application::flash('error', $error); @@ -641,9 +641,9 @@ private function signup_full() { $admin = User::get_by_id($this->config->admin_users[0]); - $to = array('name' => $_POST['username'], 'email' => $_POST['email']); - $subject = '[' . $this->config->name . '] Welcome to ' . $this->config->name . '!'; - $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/signup.html"), array('username' => $_POST['username'], 'app' => array('config' => $this->config))); + $to = array('name' => $_POST['username'], 'email' => $_POST['email']); + $subject = '[' . $this->config->name . '] Welcome to ' . $this->config->name . '!'; + $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/signup.html"), array('username' => $_POST['username'], 'app' => $this)); // Email user $this->email->send_email($to, $subject, $body, TRUE); diff --git a/lib/email.php b/lib/email.php index 890dd35..a828e0b 100644 --- a/lib/email.php +++ b/lib/email.php @@ -24,6 +24,7 @@ public function send_email($to, $subject, $body, $debug = FALSE) { if ($debug == TRUE) { $to = htmlentities($to); echo "$to
$subject
$body
$headers"; + exit; } else { mail($to, $subject, $body, $headers); }