summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-05-10 13:56:03 -0400
committerFrederic Guillot <fred@kanboard.net>2015-05-10 13:56:03 -0400
commitb51d41f331b0948add637d5f0f7093b96c268dd0 (patch)
tree600a3fde61ce149656b2fc33ae0a9799173337ab
parent94a5b12e68fc5e5f6aee7bf1d6d25427421aba7a (diff)
Recurring tasks (#847): Fix php error (substract is not always defined)
-rwxr-xr-xapp/Model/TaskDuplication.php26
1 files changed, 10 insertions, 16 deletions
diff --git a/app/Model/TaskDuplication.php b/app/Model/TaskDuplication.php
index f3ce4f7b..ada3b6d6 100755
--- a/app/Model/TaskDuplication.php
+++ b/app/Model/TaskDuplication.php
@@ -2,6 +2,8 @@
namespace Model;
+use DateTime;
+use DateInterval;
use Event\TaskEvent;
/**
@@ -174,24 +176,18 @@ class TaskDuplication extends Base
* @access private
* @param array $values
*/
- private function recurrenceDateDue(&$values)
+ private function recurrenceDateDue(array &$values)
{
- if ($values['date_due'] && $values['recurrence_factor'])
- {
- if ($values['recurrence_basedate'])
- {
+ if (! empty($values['date_due']) && $values['recurrence_factor'] != 0) {
+
+ if ($values['recurrence_basedate'] == Task::RECURE_BASEDATE_TRIGGERDATE) {
$values['date_due'] = time();
}
$factor = abs($values['recurrence_factor']);
+ $subtract = $values['recurrence_factor'] < 0;
- if ($values['recurrence_factor'] < 0)
- {
- $subtract=TRUE;
- }
-
- switch ($values['recurrence_timeframe'])
- {
+ switch ($values['recurrence_timeframe']) {
case Task::RECURE_MONTHS:
$interval = 'P' . $factor . 'M';
break;
@@ -200,14 +196,12 @@ class TaskDuplication extends Base
break;
default:
$interval = 'P' . $factor . 'D';
- break;
}
- $date_due = new \DateTime();
-
+ $date_due = new DateTime();
$date_due->setTimestamp($values['date_due']);
- $subtract ? $date_due->sub(new \DateInterval($interval)) : $date_due->add(new \DateInterval($interval));
+ $subtract ? $date_due->sub(new DateInterval($interval)) : $date_due->add(new DateInterval($interval));
$values['date_due'] = $date_due->getTimestamp();
}