diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-02-04 16:03:29 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-02-04 16:03:29 -0500 |
commit | d5c4c18ea0bd6c0d1a9d0104c1c17748a35f85a7 (patch) | |
tree | 313e42064e41c0b4da565d98992f5aa2933dd8ed /app | |
parent | 8eac12188865f380439a40549e6e6ed58c3f405c (diff) |
Add email address field for projects
Diffstat (limited to 'app')
33 files changed, 114 insertions, 9 deletions
diff --git a/app/Api/Procedure/ProjectProcedure.php b/app/Api/Procedure/ProjectProcedure.php index a580c8d9..e8a34cd3 100644 --- a/app/Api/Procedure/ProjectProcedure.php +++ b/app/Api/Procedure/ProjectProcedure.php @@ -32,6 +32,13 @@ class ProjectProcedure extends BaseProcedure return $this->formatProject($project); } + public function getProjectByEmail($email) + { + $project = $this->formatProject($this->projectModel->getByEmail($email)); + ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectByEmail', $project['id']); + return $this->formatProject($project); + } + public function getAllProjects() { return $this->formatProjects($this->projectModel->getAll()); diff --git a/app/Helper/AppHelper.php b/app/Helper/AppHelper.php index 3b48d7d3..3cefd1c5 100644 --- a/app/Helper/AppHelper.php +++ b/app/Helper/AppHelper.php @@ -12,6 +12,11 @@ use Kanboard\Core\Base; */ class AppHelper extends Base { + public function isAjax() + { + return $this->request->isAjax(); + } + /** * Render Javascript component * diff --git a/app/Locale/bs_BA/translations.php b/app/Locale/bs_BA/translations.php index 3174d450..9dfe2a3e 100644 --- a/app/Locale/bs_BA/translations.php +++ b/app/Locale/bs_BA/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/cs_CZ/translations.php b/app/Locale/cs_CZ/translations.php index e152db9f..8ab5aa7f 100644 --- a/app/Locale/cs_CZ/translations.php +++ b/app/Locale/cs_CZ/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index a38a20d7..eeb02e1d 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 13cdf6bf..9d1ff3bf 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/el_GR/translations.php b/app/Locale/el_GR/translations.php index c2760407..a4750705 100644 --- a/app/Locale/el_GR/translations.php +++ b/app/Locale/el_GR/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 3fa4c3a8..f84f1db1 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index f37abc55..40fddda4 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index ce2e8a46..54df0379 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -961,7 +961,7 @@ return array( 'Do you really want to close all tasks of this column?' => 'Voulez-vous vraiment fermer toutes les tâches de cette colonne ?', '%d task(s) in the column "%s" and the swimlane "%s" will be closed.' => '%d tâche(s) dans la colonne « %s » et la swimlane « %s » seront fermées.', 'Close all tasks of this column' => 'Fermer toutes les tâches de cette colonne', - 'No plugin has registered a project notification method. You can still configure individual notifications in your user profile.' => 'Aucun plugin n\'a enregistré une méthode de notification de projet. Vous pouvez toujours configurer les notifications individuelles dans votre profil d\'utilisateur.', + 'No plugin has registered a project notification method. You can still configure individual notifications in your user profile.' => 'Aucun plugin n\'a enregistré une méthode de notification de projet. Vous pouvez toujours configurer les notifications individuelles dans votre profil utilisateur.', 'My dashboard' => 'Mon tableau de bord', 'My profile' => 'Mon profil', 'Project owner: ' => 'Responsable du projet : ', @@ -1311,4 +1311,6 @@ return array( 'Your profile must have a valid email address.' => 'Votre profil doit avoir une adresse e-mail valide.', 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => 'Malheureusement, nous ne pouvons pas réinitialiser votre mot de passe. Avez-vous saisi un nom d\'utilisateur valide ? Avez-vous une adresse e-mail dans votre profil ?', 'TRL - Turkish Lira' => 'TRL - Livre turque', + 'The project email is optional and could be used by several plugins.' => 'L\'adresse email d\'un projet est optionnel et pourrait être utilisé par plusieurs extensions.', + 'The email project must be unique across all projects' => 'L\'adresse email d\'un projet doit être unique pour tous les projets', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 57bea247..2ad209a7 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/id_ID/translations.php b/app/Locale/id_ID/translations.php index 4c2bab4f..938c6bd7 100644 --- a/app/Locale/id_ID/translations.php +++ b/app/Locale/id_ID/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 8a73ceeb..6d4ceaf9 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 8ce0c9fa..1c69d809 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/ko_KR/translations.php b/app/Locale/ko_KR/translations.php index b3fe859e..1bf45633 100644 --- a/app/Locale/ko_KR/translations.php +++ b/app/Locale/ko_KR/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/my_MY/translations.php b/app/Locale/my_MY/translations.php index 0d694782..588829d2 100644 --- a/app/Locale/my_MY/translations.php +++ b/app/Locale/my_MY/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/nb_NO/translations.php b/app/Locale/nb_NO/translations.php index 7f563358..04d7c718 100644 --- a/app/Locale/nb_NO/translations.php +++ b/app/Locale/nb_NO/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 37427071..3bc9e51d 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index a3b0018d..fdca3f07 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 0de6ab2b..e709bb4a 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/pt_PT/translations.php b/app/Locale/pt_PT/translations.php index 6bf04605..b70d97d9 100644 --- a/app/Locale/pt_PT/translations.php +++ b/app/Locale/pt_PT/translations.php @@ -1311,4 +1311,6 @@ return array( 'Your profile must have a valid email address.' => 'O seu perfil deve ter um endereço de email válido.', 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => 'Infelizmente, não conseguimos redefinir a sua password. Colocou um utilizador válido? Tem um endereço de email definido no seu perfil?', 'TRL - Turkish Lira' => 'TRL - Lira Turca', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index d9b9d4d2..680340b1 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 2f22774e..75678bca 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 17e60c03..3f901a09 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index f8ecd0d2..26497b0a 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 7c8a7453..c3947fed 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 76c51a62..5f45188b 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -1311,4 +1311,6 @@ return array( // 'Your profile must have a valid email address.' => '', // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '', // 'TRL - Turkish Lira' => '', + // 'The project email is optional and could be used by several plugins.' => '', + // 'The email project must be unique across all projects' => '', ); diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php index aba5eee2..080217cb 100644 --- a/app/Model/ProjectModel.php +++ b/app/Model/ProjectModel.php @@ -106,6 +106,22 @@ class ProjectModel extends Base } /** + * Get a project by the email address + * + * @access public + * @param string $email + * @return array|boolean + */ + public function getByEmail($email) + { + if (empty($email)) { + return false; + } + + return $this->db->table(self::TABLE)->eq('email', $email)->findOne(); + } + + /** * Fetch project data by using the token * * @access public diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 7771440e..ca9f45ad 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,12 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 120; +const VERSION = 121; + +function version_121(PDO $pdo) +{ + $pdo->exec('ALTER TABLE projects ADD COLUMN email VARCHAR(255)'); +} function version_120(PDO $pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 8054340c..cbea908f 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,12 @@ use PDO; use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; -const VERSION = 99; +const VERSION = 100; + +function version_100(PDO $pdo) +{ + $pdo->exec('ALTER TABLE "projects" ADD COLUMN email VARCHAR(255)'); +} function version_99(PDO $pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 87630b1a..a68ed418 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,12 @@ use Kanboard\Core\Security\Token; use Kanboard\Core\Security\Role; use PDO; -const VERSION = 110; +const VERSION = 111; + +function version_111(PDO $pdo) +{ + $pdo->exec('ALTER TABLE "projects" ADD COLUMN email TEXT'); +} function version_110(PDO $pdo) { diff --git a/app/Template/project_edit/show.php b/app/Template/project_edit/show.php index 46cdb8fa..074f1d37 100644 --- a/app/Template/project_edit/show.php +++ b/app/Template/project_edit/show.php @@ -1,6 +1,12 @@ -<div class="page-header"> - <h2><?= $this->text->e($project['name']) ?> > <?= t('Edit project') ?></h2> -</div> +<?php if ($this->app->isAjax()): ?> + <div class="page-header"> + <h2><?= $this->text->e($project['name']) ?> > <?= t('Edit project') ?></h2> + </div> +<?php else: ?> + <div class="page-header"> + <h2><?= t('Edit project') ?></h2> + </div> +<?php endif ?> <form method="post" action="<?= $this->url->href('ProjectEditController', 'update', array('project_id' => $project['id'], 'redirect' => 'edit')) ?>" autocomplete="off"> <?= $this->form->csrf() ?> <?= $this->form->hidden('id', $values) ?> @@ -11,12 +17,16 @@ <?= $this->form->label(t('Name'), 'name') ?> <?= $this->form->text('name', $values, $errors, array('required', 'maxlength="50"', 'autofocus', 'tabindex="1"')) ?> + <?= $this->form->label(t('Email'), 'email') ?> + <?= $this->form->email('email', $values, $errors, array('maxlength="255"', 'tabindex="2"')) ?> + <p class="form-help"><?= t('The project email is optional and could be used by several plugins.') ?></p> + <?= $this->form->label(t('Identifier'), 'identifier') ?> - <?= $this->form->text('identifier', $values, $errors, array('maxlength="50"', 'tabindex="2"')) ?> + <?= $this->form->text('identifier', $values, $errors, array('maxlength="50"', 'tabindex="3"')) ?> <p class="form-help"><?= t('The project identifier is optional and must be alphanumeric, example: MYPROJECT.') ?></p> <?= $this->form->label(t('Description'), 'description') ?> - <?= $this->form->textEditor('description', $values, $errors, array('tabindex' => 3)) ?> + <?= $this->form->textEditor('description', $values, $errors, array('tabindex' => 4)) ?> </fieldset> <fieldset> diff --git a/app/Validator/ProjectValidator.php b/app/Validator/ProjectValidator.php index 5b10026c..8d8053a3 100644 --- a/app/Validator/ProjectValidator.php +++ b/app/Validator/ProjectValidator.php @@ -34,6 +34,8 @@ class ProjectValidator extends BaseValidator new Validators\MaxLength('end_date', t('The maximum length is %d characters', 10), 10), new Validators\AlphaNumeric('identifier', t('This value must be alphanumeric')) , new Validators\Unique('identifier', t('The identifier must be unique'), $this->db->getConnection(), ProjectModel::TABLE), + new Validators\Email('email', t('Email address invalid')) , + new Validators\Unique('email', t('The email project must be unique across all projects'), $this->db->getConnection(), ProjectModel::TABLE), ); } |