diff --git a/README.md b/README.md index 42a4a05..4d0edc6 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Kanban-inspired app for keeping track of things that need to get done +A Kanban-inspired app for keeping track of things that need to get done. +The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit. **Shipped version:** 1.0.2~ynh2 diff --git a/README_fr.md b/README_fr.md index 9f81316..d2ce45a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Application inspirée de Kanban pour garder une trace des choses à faire +A Kanban-inspired app for keeping track of things that need to get done. +The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit. **Version incluse :** 1.0.2~ynh2 diff --git a/conf/Mailer.php b/conf/Mailer.php new file mode 100644 index 0000000..402d822 --- /dev/null +++ b/conf/Mailer.php @@ -0,0 +1,164 @@ +loadStrings($lang); + } + + /** + * Send email to one or more users in the provided list. + * + * @param $emails List of email addresses (must have at least one). + * @param $data Object containing template type and replacements for template. + */ + public function sendMail($emails, $data) { + $this->initMail(); + + if (count($emails) < 1) { + return ''; + } + + foreach($emails as $user) { + $this->mail->addAddress($user); + } + + $this->mail->Subject = $this->strings->mail_subject; + $this->mail->msgHTML($this->parseTemplate($data)); + + if (!$this->mail->send()) { + return $this->strings->mail_error; + } + + return $this->strings->mail_sent; // @codeCoverageIgnore + } + + private function parseTemplate(EmailData $data) { + $template = $this->getTemplate($data->type); + + $template = str_replace('%hostUrl%', $data->hostUrl, $template); + $template = str_replace('%boardId%', $data->boardId, $template); + + $template = str_replace('%username%', $data->username, $template); + $template = str_replace('%boardName%', $data->boardName, $template); + + $template = str_replace('%comment%', $data->comment, $template); + $template = str_replace('%taskName%', $data->taskName, $template); + + $template = + str_replace('%taskDescription%', $data->taskDescription, $template); + $template = str_replace('%taskDueDate%', $data->taskDueDate, $template); + $template = str_replace('%taskAssignees%', $data->taskAssignees, $template); + $template = + str_replace('%taskCategories%', $data->taskCategories, $template); + $template = str_replace('%taskPoints%', $data->taskPoints, $template); + $template = + str_replace('%taskColumnName%', $data->taskColumnName, $template); + $template = str_replace('%taskPosition%', $data->taskPosition, $template); + + return $template; + } + + /** + * @codeCoverageIgnore + */ + private function getTemplate($type) { + $template = ''; + + switch($type) { + case 'newBoard': + $template = $this->strings->mail_template_newBoard; + break; + + case 'newComment': + $template = $this->strings->mail_template_newComment; + break; + + case 'newTask': + $template = $this->strings->mail_template_newTask; + + case 'editBoard': + $template = $this->strings->mail_template_editBoard; + break; + + case 'editComment': + $template = $this->strings->mail_template_editComment; + break; + + case 'editTask': + $template = $this->strings->mail_template_editTask; + break; + + case 'removeBoard': + $template = $this->strings->mail_template_removeBoard; + break; + + case 'removeComment': + $template = $this->strings->mail_template_removeComment; + break; + + case 'removeTask': + $template = $this->strings->mail_template_removeTask; + break; + } + + $template .= $this->strings->mail_template_openBoardLink; + + return $template; + } + + private function initMail() { + $this->mail = new PHPMailer(); + $this->mail->isSendmail(); + + $this->mail->setFrom(Mailer::FROM_EMAIL, Mailer::FROM_NAME); + $this->mail->CharSet = PHPMailer::CHARSET_UTF8; + + // @codeCoverageIgnoreStart + if (!Mailer::USE_SENDMAIL) { + $this->mail->isSMTP(); + + $this->mail->Host = Mailer::SMTP_HOST; + $this->mail->Port = Mailer::SMTP_PORT; + $this->mail->Username = Mailer::SMTP_USER; + $this->mail->Password = Mailer::SMTP_PASS; + + $this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $this->mail->SMTPAuth = true; + } + // @codeCoverageIgnoreEnd + } + + private function loadStrings($lang) { + $json = '{}'; + + try { + $json = + file_get_contents(__DIR__ . '/../../strings/' . $lang . '_api.json'); + } catch (Exception $ex) { + $ex->getMessage(); + + $json = file_get_contents(__DIR__ . '/../../json/' . $lang . '_api.json'); + } + + $this->strings = json_decode($json); + } +} diff --git a/conf/nginx.conf b/conf/nginx.conf index 800bead..1ba5ff7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,6 +8,8 @@ location __PATH__/ { client_max_body_size 100M; client_body_buffer_size 128k; + proxy_set_header Authorization $http_authorization; + proxy_pass_header Authorization; try_files $uri $uri/ @__NAME__; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..8abe306 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,2 @@ +A Kanban-inspired app for keeping track of things that need to get done. +The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit. \ No newline at end of file diff --git a/scripts/install b/scripts/install index 02f478e..a46ce18 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" +chmod 777 "$final_path/api" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -84,12 +85,23 @@ ynh_add_nginx_config #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=3 +ynh_script_progression --message="Configuring PHP-FPM..." --weight=4 # Create a dedicated PHP-FPM config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=2 + +dir="__DIR__" +ynh_add_config --template="../conf/Mailer.php" --destination="$final_path/api/helpers/Mailer.php" + +chmod 400 "$final_path/api/helpers/Mailer.php" +chown $app:$app "$final_path/api/helpers/Mailer.php" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================