summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-10-07 08:45:18 -0400
committerFrederic Guillot <fred@kanboard.net>2016-10-07 08:45:18 -0400
commit096b000c59842d0d2995ce66b84f9ca87370473f (patch)
tree4dcc1eb4473626b6390a5d4b9002d43c92e8e015
parent4cc856344f0105fe893c384eeec6b14036321651 (diff)
Add restriction to disable task drag and drop for a project
-rw-r--r--app/Helper/ProjectRoleHelper.php24
-rw-r--r--app/Locale/bs_BA/translations.php1
-rw-r--r--app/Locale/cs_CZ/translations.php1
-rw-r--r--app/Locale/da_DK/translations.php1
-rw-r--r--app/Locale/de_DE/translations.php1
-rw-r--r--app/Locale/el_GR/translations.php1
-rw-r--r--app/Locale/es_ES/translations.php1
-rw-r--r--app/Locale/fi_FI/translations.php1
-rw-r--r--app/Locale/fr_FR/translations.php1
-rw-r--r--app/Locale/hu_HU/translations.php1
-rw-r--r--app/Locale/id_ID/translations.php1
-rw-r--r--app/Locale/it_IT/translations.php1
-rw-r--r--app/Locale/ja_JP/translations.php1
-rw-r--r--app/Locale/ko_KR/translations.php1
-rw-r--r--app/Locale/my_MY/translations.php1
-rw-r--r--app/Locale/nb_NO/translations.php1
-rw-r--r--app/Locale/nl_NL/translations.php1
-rw-r--r--app/Locale/pl_PL/translations.php1
-rw-r--r--app/Locale/pt_BR/translations.php1
-rw-r--r--app/Locale/pt_PT/translations.php1
-rw-r--r--app/Locale/ru_RU/translations.php1
-rw-r--r--app/Locale/sr_Latn_RS/translations.php1
-rw-r--r--app/Locale/sv_SE/translations.php1
-rw-r--r--app/Locale/th_TH/translations.php1
-rw-r--r--app/Locale/tr_TR/translations.php1
-rw-r--r--app/Locale/zh_CN/translations.php1
-rw-r--r--app/Model/ProjectRoleRestrictionModel.php2
-rw-r--r--tests/units/Model/ProjectRoleRestrictionModelTest.php2
28 files changed, 50 insertions, 3 deletions
diff --git a/app/Helper/ProjectRoleHelper.php b/app/Helper/ProjectRoleHelper.php
index 87f7fed2..5c80d42b 100644
--- a/app/Helper/ProjectRoleHelper.php
+++ b/app/Helper/ProjectRoleHelper.php
@@ -62,7 +62,7 @@ class ProjectRoleHelper extends Base
}
}
- return empty($sortableColumns);
+ return empty($sortableColumns) && $this->isAllowedToMoveTask($project_id, $role);
}
return true;
@@ -97,7 +97,7 @@ class ProjectRoleHelper extends Base
}
}
- return empty($sortableColumns);
+ return empty($sortableColumns) && $this->isAllowedToMoveTask($project_id, $role);
}
return true;
@@ -263,4 +263,24 @@ class ProjectRoleHelper extends Base
return true;
}
+
+ /**
+ * Check if the role can move task in the given project
+ *
+ * @param int $project_id
+ * @param string $role
+ * @return bool
+ */
+ protected function isAllowedToMoveTask($project_id, $role)
+ {
+ $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
+
+ foreach ($projectRestrictions as $restriction) {
+ if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_MOVE) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/app/Locale/bs_BA/translations.php b/app/Locale/bs_BA/translations.php
index 7815b334..d91f8428 100644
--- a/app/Locale/bs_BA/translations.php
+++ b/app/Locale/bs_BA/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/cs_CZ/translations.php b/app/Locale/cs_CZ/translations.php
index d86cd9ff..35668d11 100644
--- a/app/Locale/cs_CZ/translations.php
+++ b/app/Locale/cs_CZ/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index 4116e442..af011f95 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index 4e1050de..d22fc64e 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/el_GR/translations.php b/app/Locale/el_GR/translations.php
index 70316741..3e06c22f 100644
--- a/app/Locale/el_GR/translations.php
+++ b/app/Locale/el_GR/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index af17522c..cef9030a 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 53150c64..cffaa0c3 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 2de18abf..b428ec10 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -1276,4 +1276,5 @@ return array(
'Do you really want to remove this project restriction: "%s"?' => 'Voulez-vous vraiment supprimer cette restriction de projet : « %s » ?',
'Duplicate to multiple projects' => 'Dupliquer vers plusieurs projets',
'This field is required' => 'Ce champ est requis',
+ 'Moving a task is not permitted' => 'Déplaçer une tâche n\'est pas autorisé',
);
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index 124f31ef..bd8714eb 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/id_ID/translations.php b/app/Locale/id_ID/translations.php
index ecbc5bf7..78b465ab 100644
--- a/app/Locale/id_ID/translations.php
+++ b/app/Locale/id_ID/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index 98485ceb..0cd91de1 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index 643c29b5..015868d8 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/ko_KR/translations.php b/app/Locale/ko_KR/translations.php
index c403a3f3..00407b41 100644
--- a/app/Locale/ko_KR/translations.php
+++ b/app/Locale/ko_KR/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/my_MY/translations.php b/app/Locale/my_MY/translations.php
index 85fd07e3..944bc800 100644
--- a/app/Locale/my_MY/translations.php
+++ b/app/Locale/my_MY/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/nb_NO/translations.php b/app/Locale/nb_NO/translations.php
index 203cfcd6..c81dde89 100644
--- a/app/Locale/nb_NO/translations.php
+++ b/app/Locale/nb_NO/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php
index d53956e0..4a98592a 100644
--- a/app/Locale/nl_NL/translations.php
+++ b/app/Locale/nl_NL/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 1c9544a3..6ebd1683 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index 5d7f3eee..322f091d 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/pt_PT/translations.php b/app/Locale/pt_PT/translations.php
index 707ed694..655285b9 100644
--- a/app/Locale/pt_PT/translations.php
+++ b/app/Locale/pt_PT/translations.php
@@ -1275,4 +1275,5 @@ return array(
'Do you really want to remove this project restriction: "%s"?' => 'Tem a certeza que quer remover a restrição de projeto: "%s"?',
'Duplicate to multiple projects' => 'Duplicar para vários projetos',
'This field is required' => 'Este campo é obrigatório',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index 60ba63ca..36096aed 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php
index 5aa5c20f..ac7e581b 100644
--- a/app/Locale/sr_Latn_RS/translations.php
+++ b/app/Locale/sr_Latn_RS/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index 05558601..3ed3d61f 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index e45d39f0..6e9cc690 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php
index 1cc8389e..79d03822 100644
--- a/app/Locale/tr_TR/translations.php
+++ b/app/Locale/tr_TR/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index f2e75f3c..4a7e6c5b 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -1275,4 +1275,5 @@ return array(
// 'Do you really want to remove this project restriction: "%s"?' => '',
// 'Duplicate to multiple projects' => '',
// 'This field is required' => '',
+ // 'Moving a task is not permitted' => '',
);
diff --git a/app/Model/ProjectRoleRestrictionModel.php b/app/Model/ProjectRoleRestrictionModel.php
index dc8abf79..8ccdcf9c 100644
--- a/app/Model/ProjectRoleRestrictionModel.php
+++ b/app/Model/ProjectRoleRestrictionModel.php
@@ -16,6 +16,7 @@ class ProjectRoleRestrictionModel extends Base
const RULE_TASK_CREATION = 'task_creation';
const RULE_TASK_OPEN_CLOSE = 'task_open_close';
+ const RULE_TASK_MOVE = 'task_move';
/**
* Get rules
@@ -27,6 +28,7 @@ class ProjectRoleRestrictionModel extends Base
return array(
self::RULE_TASK_CREATION => t('Task creation is not permitted'),
self::RULE_TASK_OPEN_CLOSE => t('Closing or opening a task is not permitted'),
+ self::RULE_TASK_MOVE => t('Moving a task is not permitted'),
);
}
diff --git a/tests/units/Model/ProjectRoleRestrictionModelTest.php b/tests/units/Model/ProjectRoleRestrictionModelTest.php
index 07473061..af0f9bf9 100644
--- a/tests/units/Model/ProjectRoleRestrictionModelTest.php
+++ b/tests/units/Model/ProjectRoleRestrictionModelTest.php
@@ -90,7 +90,7 @@ class ProjectRoleRestrictionModelTest extends Base
$projectRoleRestrictionModel = new ProjectRoleRestrictionModel($this->container);
$rules = $projectRoleRestrictionModel->getRules();
- $this->assertCount(2, $rules);
+ $this->assertCount(3, $rules);
$this->assertArrayHasKey(ProjectRoleRestrictionModel::RULE_TASK_OPEN_CLOSE, $rules);
}
}