Skip to content

Commit

Permalink
Merge pull request #227 from RestyaPlatform/feature/card-due-notifica…
Browse files Browse the repository at this point in the history
…tion

Fixes #181: Notification needed for card overdue
  • Loading branch information
S. Sivachidambaram committed Feb 10, 2016
2 parents 13060cd + cc2a87b commit 99d1343
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 14 deletions.
9 changes: 1 addition & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ module.exports = function(grunt) {
dest: 'client/js/default.cache.js'
}
},
less_formatter: {
options: {
files: {
src: ['client/css/custom.less', 'client/css/custom-responsive.less']
}
}
},
jsbeautifier: {
'pre-merge': {
src: source_js_files,
Expand Down Expand Up @@ -270,7 +263,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-complexity');
grunt.loadNpmTasks('grunt-docco');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('format', ['jsbeautifier:default', 'prettify', 'exec', 'less_formatter']);
grunt.registerTask('format', ['jsbeautifier:default', 'prettify', 'exec']);
grunt.registerTask('pre-commit', ['jshint', 'phplint', 'jsbeautifier:pre-merge']);
grunt.registerTask('build', 'Build task', function(env) {
grunt.config.set('config', grunt.file.readJSON('build/' + env + '.json'));
Expand Down
12 changes: 12 additions & 0 deletions client/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"Comments": "Comments",
"Computer": "Computer",
"Confirm Password": "Confirm Password",
"Connect With Zapier": "Connect With Zapier",
"Connected Applications": "Connected Applications",
"Convert to Card": "Convert to Card",
"Copy": "Copy",
Expand Down Expand Up @@ -206,6 +207,7 @@
"Enter abc music notation. May choose from": "Enter abc music notation. May choose from",
"Enter organization name": "Enter organization name",
"Enter your email and we will send new password.": "Enter your email and we will send new password.",
"File extension not supported. It supports only csv.": "File extension not supported. It supports only csv.",
"File extension not supported. It supports only jpg, png, bmp and gif.": "File extension not supported. It supports only jpg, png, bmp and gif.",
"Filter Cards": "Filter Cards",
"Flickr": "Flickr",
Expand All @@ -215,7 +217,10 @@
"Gantt": "Gantt",
"Grid": "Grid",
"Guest": "Guest",
"Hide Activities": "Hide Activities",
"Hide Card Id": "Hide Card Id",
"Hide Comments": "Hide Comments",
"Hide Logged User Activities": "Hide Logged User Activities",
"ID": "ID",
"IP": "IP",
"If any new activities done in the board, then script will post the activities as a comment to corresponding channels in Slack.": "If any new activities done in the board, then script will post the activities as a comment to corresponding channels in Slack.",
Expand All @@ -228,6 +233,7 @@
"Import Board from Trello": "Import Board from Trello",
"Import from GitHub": "Import from GitHub",
"Import your GitHub repositories as boards and issues as card for the board.": "Import your GitHub repositories as boards and issues as card for the board.",
"Imported successfully.": "Imported successfully.",
"Importing": "Importing",
"In this board": "In this board",
"Inactive": "Inactive",
Expand Down Expand Up @@ -294,6 +300,7 @@
"No repositories found": "No repositories found",
"None": "None",
"Normal": "Normal",
"Not imported, Try again.": "Not imported, Try again.",
"Notifications": "Notifications",
"Oauth Clients": "Oauth Clients",
"Oauth client deleted successfully.": "Oauth client deleted successfully.",
Expand Down Expand Up @@ -372,6 +379,7 @@
"Select List": "Select List",
"Select Template": "Select Template",
"Select Visibility": "Select Visibility",
"Select csv file": "Select csv file",
"Send": "Send",
"Send to board": "Send to board",
"Set cover image to card": "Set cover image to card",
Expand Down Expand Up @@ -449,6 +457,7 @@
"Username. Minimum 3 characters": "Username. Minimum 3 characters",
"Users": "Users",
"Users Count": "Users Count",
"Users Import": "Users Import",
"Version": "Version",
"View all activity": "View all activity",
"View in iOS App": "View in iOS App",
Expand All @@ -458,6 +467,7 @@
"Vote": "Vote",
"Voters": "Voters",
"Votes": "Votes",
"We will create a access token which you should use in zapier to connect restya account.": "We will create a access token which you should use in zapier to connect restya account.",
"We will create default lists for each board which are New, Assigned, In Progress, Feedback, Closed.": "We will create default lists for each board which are New, Assigned, In Progress, Feedback, Closed.",
"We will create users with default password restya and email as empty for each repository users from GitHub.": "We will create users with default password restya and email as empty for each repository users from GitHub.",
"We will fetch your Slack channels and create a mapping with your assigned board names and store it in localStorage.": "We will fetch your Slack channels and create a mapping with your assigned board names and store it in localStorage.",
Expand All @@ -470,10 +480,12 @@
"You can use search operators like @member, #label, is:archived, and has:attachments to refine your search.": "You can use search operators like @member, #label, is:archived, and has:attachments to refine your search.",
"You have successfully registered with our site and your activation mail has been sent to your mail inbox.": "You have successfully registered with our site and your activation mail has been sent to your mail inbox.",
"You may be able to view it by %s": "You may be able to view it by %s",
"Your Zapier Access token is ": "Your Zapier Access token is ",
"Your activation has been confirmed. You can now login to the site.": "Your activation has been confirmed. You can now login to the site.",
"Your email address for this board": "Your email address for this board",
"Your emailed cards appear in...": "Your emailed cards appear in...",
"Your old password is incorrect, please try again.": "Your old password is incorrect, please try again.",
"Zapier": "Zapier",
"abc Notation": "abc Notation",
"activities": "activities",
"attachments": "attachments",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"grunt-contrib-less": "~0.11.2",
"grunt-contrib-jst": "~0.6.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-less-formatter": "~0.1.0",
"grunt-jsbeautifier": "~0.2.7",
"grunt-prettify": "~0.4.0",
"grunt-contrib-cssmin": "~0.6.1",
Expand Down
4 changes: 2 additions & 2 deletions server/php/R/r.php
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,8 @@ function r_post($r_resource_cmd, $r_resource_vars, $r_resource_filters, $r_post)
$result = pg_query_params($db_lnk, 'UPDATE ' . $table_name . ' SET is_subscribed = True Where board_id = $1 and user_id = $2 RETURNING *', $qry_val_arr);
}
}
$_response = pg_fetch_assoc($result);
$response = convertBooleanValues($table_name, $_response);
$_response = pg_fetch_assoc($result);
$response = convertBooleanValues($table_name, $_response);
break;

case '/boards/?/copy': //boards copy
Expand Down
58 changes: 58 additions & 0 deletions server/php/shell/card_due_notification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Cron to card due date
*
* PHP version 5
*
* @category PHP
* @package Restyaboard
* @subpackage Core
* @author Restya <[email protected]>
* @copyright 2014-2016 Restya
* @license http://restya.com/ Restya Licence
* @link http://restya.com/
*/
$app_path = dirname(dirname(__FILE__));
require_once $app_path . '/config.inc.php';
require_once $app_path . '/libs/core.php';
global $_server_domain_url;
if (file_exists(APP_PATH . '/tmp/cache/site_url_for_shell.php')) {
include_once APP_PATH . '/tmp/cache/site_url_for_shell.php';
}
if ($db_lnk) {
$qry_val_arr = array();
$result = pg_query_params($db_lnk, "SELECT * FROM cards_listing WHERE due_date::DATE = (select DATE 'tomorrow')", $qry_val_arr);
while ($card = pg_fetch_assoc($result)) {
$cards_users = json_decode($card['cards_users']);
if (!empty($cards_users)) {
foreach ($cards_users as $cards_user) {
$mail_content = '';
if (!empty($cards_user->profile_picture_path)) {
$hash = md5(SECURITYSALT . 'User' . $cards_user->user_id . 'png' . 'small_thumb' . SITE_NAME);
$profile_picture_path = $_server_domain_url . '/img/small_thumb/User/' . $cards_user->user_id . '.' . $hash . '.png';
$user_avatar = '<img style="margin-right: 10px;vertical-align: middle;" src="' . $profile_picture_path . '" alt="[Image: ' . $cards_user->full_name . ']" class="img-rounded img-responsive">' . "\n";
} else if (!empty($cards_user->initials)) {
$user_avatar = '<i style="border-radius:4px;text-shadow:#6f6f6f 0.02em 0.02em 0.02em;width:32px;height:32px;line-height:32px;font-size:16px;display:inline-block;font-style:normal;text-align:center;text-transform:uppercase;color:#f47564 !important;background-color:#ffffff !important;border:1px solid #d7d9db;margin-right: 10px;">' . $cards_user->initials . '</i>' . "\n";
}
$date = date_create($card['due_date']);
$message = '<a href="' . $_server_domain_url . '/#/board/' . $card['board_id'] . '/card/' . $card['id'] . '">' . $card['name'] . '</a> on <a href="' . $_server_domain_url . '/#/board/' . $card['board_id'] . '">' . $card['board_name'] . '</a> is due ' . date_format($date, "M d") . ' at ' . date_format($date, "h:i a");
$br = '<div style="line-height:40px;">&nbsp;</div>';
$mail_content.= '<div style="display:table">' . "\n";
$mail_content.= '<div style="float:left">' . $user_avatar . '</div>' . "\n";
$mail_content.= '<div style="vertical-align: middle;display:table-cell;">' . $message . '</div>' . "\n";
$mail_content.= '</div>' . "\n";
$mail_content.= $br . "\n";
$users[$cards_user->email][] = $mail_content;
}
}
}
if (!empty($users)) {
foreach ($users as $key => $val) {
$to_mail = $key;
foreach ($val as $CONTENT) {
$emailFindReplace['##CONTENT##'] = $CONTENT;
sendMail('due_date_notification', $emailFindReplace, $to_mail);
}
}
}
}
23 changes: 23 additions & 0 deletions server/php/shell/card_due_notification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# lock logic for semaphore - http://mywiki.wooledge.org/BashFAQ/045
path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
lockdir="${path}/card_due_notification.lock"
echo >&2 "$(date '+%Y-%m-%d %H:%M:%S') #################################################"
if mkdir "$lockdir"
then # directory did not exist, but was created successfully
echo >&2 "successfully acquired lock: $lockdir"

##########################################################################################################

# -----------------------------------------------------------------
# RESTYABOARD --->
# ==========
php ${path}/card_due_notification.php

##########################################################################################################
rmdir "$lockdir"
else
echo >&2 "cannot acquire lock, giving up on $lockdir"
exit 0
fi
46 changes: 43 additions & 3 deletions sql/upgrade-0.1.6-0.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,19 @@ CREATE OR REPLACE VIEW "boards_listing" AS
LEFT JOIN users users ON ((users.id = board.user_id)))
LEFT JOIN organizations organizations ON ((organizations.id = board.organization_id)));


CREATE OR REPLACE VIEW "cards_users_listing" AS
SELECT u.username,
u.profile_picture_path,
cu.id,
cu.created,
cu.modified,
cu.card_id,
cu.user_id,
u.initials,
u.full_name,
u.email
FROM (cards_users cu
LEFT JOIN users u ON ((u.id = cu.user_id)));

CREATE OR REPLACE VIEW "cards_listing" AS
SELECT cards.id,
Expand Down Expand Up @@ -916,7 +928,8 @@ CREATE OR REPLACE VIEW "cards_listing" AS
cards_users_listing.card_id,
cards_users_listing.user_id,
cards_users_listing.initials,
cards_users_listing.full_name
cards_users_listing.full_name,
cards_users_listing.email
FROM cards_users_listing cards_users_listing
WHERE (cards_users_listing.card_id = cards.id)
ORDER BY cards_users_listing.id) cc) AS cards_users,
Expand Down Expand Up @@ -1597,4 +1610,31 @@ INSERT INTO "oauth_scopes" ("scope", "is_default") VALUES ('read', 't'),('write'

INSERT INTO "acl_links" ("id", "created", "modified", "name", "url", "method", "slug", "group_id", "is_allow_only_to_admin", "is_allow_only_to_user") VALUES ('141', now(), now(), 'Users import', '/users/import', 'POST', 'users_import', '6', '1', '0');

INSERT INTO "acl_links_roles" ("created", "modified", "acl_link_id", "role_id") VALUES (now(), now(), '141', '1');
INSERT INTO "acl_links_roles" ("created", "modified", "acl_link_id", "role_id") VALUES (now(), now(), '141', '1');

INSERT INTO "email_templates" ("id", "created", "modified", "from_email", "reply_to_email", "name", "description", "subject", "email_text_content", "email_variables", "display_name") VALUES
(7, '2016-01-10 06:15:49.891', '2016-01-10 06:15:49.891', '##SITE_NAME## Restyaboard <##FROM_EMAIL##>', '##REPLY_TO_EMAIL##', 'due_date_notification', 'We will send this mail, One day before when the card due date end.', 'Restyaboard / Due date notification', '<html>
<head></head>
<body style="margin:0">
<header style="display:block;width:100%;padding-left:0;padding-right:0; border-bottom:solid 1px #dedede; float:left;background-color: #f7f7f7;">
<div style="border: 1px solid #EEEEEE;">
<h1 style="text-align:center;margin:10px 15px 5px;"> <a href="##SITE_URL##" title="##SITE_NAME##"><img src="##SITE_URL##/img/logo.png" alt="[Restyaboard]" title="##SITE_NAME##"></a> </h1>
</div>
</header>
<main style="width:100%;padding-top:10px; padding-bottom:10px; margin:0 auto; float:left;">
<div style="background-color:#f3f5f7;padding:10px;border: 1px solid #EEEEEE;">
<div style="width: 500px;background-color: #f3f5f7;margin:0 auto;">
<pre style="font-family: Arial, Helvetica, sans-serif; font-size: 13px;line-height:20px;">
<h2 style="font-size:16px; font-family:Arial, Helvetica, sans-serif; margin: 7px 0px 0px 43px;padding:35px 0px 0px 0px;">Due soon…</h2>
<p style="white-space: normal; width: 100%;margin: 10px 0px 0px; font-family:Arial, Helvetica, sans-serif;">##CONTENT##</p>
</pre>
</div>
</div>
</main>
<footer style="width:100%;padding-left:0;margin:0px auto;border-top: solid 1px #dedede; padding-bottom:10px; background:#fff;clear: both;padding-top: 10px;border-bottom: solid 1px #dedede;background-color: #f7f7f7;">
<h6 style="text-align:center;margin:5px 15px;">
<a href="http://restya.com/board" title="Open source. Trello like kanban board." rel="generator" style="font-size: 11px;text-align: center;text-decoration: none;color: #000;font-family: arial; padding-left:10px;">Powered by Restyaboard</a>
</h6>
</footer>
</body>
</html>', 'SITE_URL, SITE_NAME, CONTENT', 'Due Date Notification');

0 comments on commit 99d1343

Please sign in to comment.