Add hostname to email templates and update readme.

This commit is contained in:
kiswa 2015-03-23 18:12:38 -04:00
parent 8b8c4fe617
commit 823504b3c9
10 changed files with 53 additions and 29 deletions

View File

@ -22,7 +22,7 @@ $app->post('/boards', function() use($app, $jsonResponse) {
foreach($board->sharedUser as $user) {
$body = getNewBoardEmailBody($board->id, $user->username, $board->name);
$subject = 'New board created!';
$subject = 'TaskBoard: New board created!';
$recipient = $user->username;
$email = $user->email;
@ -49,7 +49,7 @@ $app->post('/boards/update', function() use($app, $jsonResponse) {
foreach($board->sharedUser as $user) {
$body = geEditBoardEmailBody($board->id, $user->username, $board->name);
$subject = 'Board updated!';
$subject = 'TaskBoard: Board updated!';
$recipient = $user->username;
$email = $user->email;

View File

@ -44,7 +44,7 @@ $app->post('/boards/:id/items', function($id) use($app, $jsonResponse) {
$item->points,
$item->position
);
$subject = 'New item created!';
$subject = 'TaskBoard: New item created!';
$recipient = $user->username;
$email = $user->email;
@ -101,7 +101,7 @@ $app->post('/items/:itemId', function($itemId) use ($app, $jsonResponse) {
$item->points,
$item->position
);
$subject = 'Item edited';
$subject = 'TaskBoard: Item edited';
$recipient = $user->username;
$email = $user->email;
@ -180,7 +180,7 @@ $app->post('/items/:itemId/comment', function($itemId) use ($app, $jsonResponse)
$item->title,
$comment->text
);
$subject = 'New comment';
$subject = 'TaskBoard: New comment';
$recipient = $user->username;
$email = $user->email;
@ -222,7 +222,7 @@ $app->post('/comments/:commentId', function($commentId) use ($app, $jsonResponse
$item->title,
$comment->text
);
$subject = 'Edit comment';
$subject = 'TaskBoard: Comment updated';
$recipient = $user->username;
$email = $user->email;

View File

@ -1,10 +1,17 @@
<?php
require_once('mailConfig.php');
function getHostName() {
$headers = apache_request_headers();
foreach($headers as $header => $value) {
if (strtolower($header) == 'host') {
return $value;
}
}
}
function createMailObject() {
global $MAIL_HOST, $MAIL_USERNAME, $MAIL_PASSWORD, $MAIL_SMTPSECURE, $MAIL_PORT, $MAIL_FROM, $MAIL_FROMNAME;
$mail = new PHPMailer;
@ -36,23 +43,28 @@ function sendEmail($email, $recipient, $subject, $body) {
function getNewBoardEmailBody($boardid, $username, $boardname) {
$message = file_get_contents('mail_templates/newBoard.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
return $message;
}
function getEditBoardEmailBody($boardid, $username, $boardname) {
$message = file_get_contents('mail_templates/editBoard.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
return $message;
}
function getNewItemEmailBody($boardid, $username, $boardname, $title, $description, $assignee, $category, $dueDate, $points, $position)
{
$message = file_get_contents('mail_templates/newItem.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
@ -63,12 +75,14 @@ function getNewItemEmailBody($boardid, $username, $boardname, $title, $descripti
$message = str_replace('%duedate%', $dueDate, $message);
$message = str_replace('%points%', $points, $message);
$message = str_replace('%position%', $position, $message);
return $message;
}
function getEditItemEmailBody($boardid, $username, $boardname, $title, $description, $assignee, $category, $dueDate, $points, $position)
{
$message = file_get_contents('mail_templates/editItem.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
@ -79,27 +93,32 @@ function getEditItemEmailBody($boardid, $username, $boardname, $title, $descript
$message = str_replace('%duedate%', $dueDate, $message);
$message = str_replace('%points%', $points, $message);
$message = str_replace('%position%', $position, $message);
return $message;
}
function getNewCommentEmailBody($boardid, $username, $boardname, $title, $comment)
{
$message = file_get_contents('mail_templates/newComment.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
$message = str_replace('%title%', $title, $message);
$message = str_replace('%comment%', $comment, $message);
return $message;
}
function getEditCommentEmailBody($boardid, $username, $boardname, $title, $comment)
{
$message = file_get_contents('mail_templates/editComment.html');
$message = str_replace('%hostname%', getHostName(), $message);
$message = str_replace('%boardid%', $boardid, $message);
$message = str_replace('%username%', $username, $message);
$message = str_replace('%boardname%', $boardname, $message);
$message = str_replace('%title%', $title, $message);
$message = str_replace('%comment%', $comment, $message);
return $message;
}
}

View File

@ -2,6 +2,6 @@
<html>
<body>
%username% updated board %boardname%!
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -5,6 +5,6 @@
%title%<br>
%comment%<br>
<br>
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -9,7 +9,7 @@
%category%<br>
%points%<br>
%position%<br>
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -2,6 +2,6 @@
<html>
<body>
%username% created new board %boardname%!<br>
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -5,6 +5,6 @@
%title%<br>
%comment%<br>
<br>
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -9,7 +9,7 @@
%category%<br>
%points%<br>
%position%<br>
<a href="http://localhost/#/boards/%boardid%">Navigate to board!</a>
<a href="http://%hostname%/#/boards/%boardid%">Navigate to board!</a>
</body>
</html>
</html>

View File

@ -16,7 +16,7 @@ The goal of TaskBoard is to provide a simple and clean interface to a functional
2. Back end
* RESTful API written in PHP, using [Slim Framework](http://www.slimframework.com/) for routing and [RedBeanPHP](http://www.redbeanphp.com/) for database ORM.
* RESTful API written in PHP, using [Slim Framework](http://www.slimframework.com/) for routing and [RedBeanPHP](http://www.redbeanphp.com/) for database ORM. Also uses [PHPMailer](https://github.com/PHPMailer/PHPMailer) for sending emails.
* Token-based authentication.
@ -50,6 +50,12 @@ Installing TaskBoard is as easy as 1, 2, 3!
##Features
###Email
TaskBoard will email you (if you supply it with an email address) about changes in the following cases: Board Created, Board Updated, Item Created, Item Edited, Item Comment Created, and Item Comment Edited.
For now, it emails all users assigned to the related Board. There will be further work done on this to allow more fine-grained control of emails.
###Settings
The settings page allows normal users to see what boards they have access to and edit their user settings.
@ -103,13 +109,12 @@ Count was done from parent directory of TaskBoard as `./cloc-1.62.pl TaskBoard -
Language | Files | Blank Lines | Comments | Code
-------------------|-------:|-------------:|---------:|---------:
Javascript | 23 | 208 | 34 | 2004
HTML | 17 | 10 | 10 | 1044
PHP | 6 | 166 | 57 | 908
CSS | 1 | 13 | 34 | 673
Javascript | 23 | 216 | 34 | 2062
PHP | 8 | 217 | 54 | 1156
HTML | 24 | 12 | 11 | 1148
CSS | 1 | 13 | 31 | 686
Bourne Again Shell | 4 | 10 | 0 | 53
XML | 1 | 0 | 0 | 12
__SUM:__ | __52__ | __407__ | __135__ | __4694__
Counts Last Updated: Mar. 20, 2015
__SUM:__ | __61__ | __468__ | __130__ | __5117__
Counts Last Updated: Mar. 23, 2015