optional "Link copies to the template" toggle, default off (v0.3.1)
This commit is contained in:
@@ -69,6 +69,8 @@ class RecoRecoModel extends Base
|
||||
$lastDay = isset($meta['recoreco_last_day']) && $meta['recoreco_last_day'] == 1;
|
||||
$daysBefore = isset($meta['recoreco_days_before']) ? (int) $meta['recoreco_days_before'] : 0;
|
||||
$targetColumn = isset($meta['recoreco_target_column']) ? (int) $meta['recoreco_target_column'] : (int) $task['column_id'];
|
||||
// Default off: only keep the duplicate link when explicitly turned on.
|
||||
$linkCopies = isset($meta['recoreco_link_copies']) && $meta['recoreco_link_copies'] == 1;
|
||||
|
||||
$cursor = (int) $task['date_due'];
|
||||
$synced = isset($meta['recoreco_synced_due']) ? (int) $meta['recoreco_synced_due'] : null;
|
||||
@@ -89,7 +91,7 @@ class RecoRecoModel extends Base
|
||||
$fireTime = $cursor - $daysBefore * 86400;
|
||||
|
||||
while ($fireTime <= $now && $spawned < self::CATCHUP_CAP) {
|
||||
$this->spawn($task, $targetColumn);
|
||||
$this->spawn($task, $targetColumn, $linkCopies);
|
||||
|
||||
$next = $this->calculator()->occurrenceFrom($anchor, $frequency, $lastDay, $cursor, false);
|
||||
|
||||
@@ -126,7 +128,7 @@ class RecoRecoModel extends Base
|
||||
$this->taskMetadataModel->save($task_id, array('recoreco_synced_due' => $cursor));
|
||||
}
|
||||
|
||||
private function spawn(array $template, $targetColumn)
|
||||
private function spawn(array $template, $targetColumn, $linkCopies)
|
||||
{
|
||||
// The template's date_due is already the occurrence (setDue), so duplicate() copies it onto
|
||||
// the clone. duplicate() copies fields + tags + links + subtasks, but NO metadata, so the
|
||||
@@ -146,6 +148,18 @@ class RecoRecoModel extends Base
|
||||
// Reset the "[DUPLICATE]" prefix back to the source title (no events).
|
||||
$this->taskModificationModel->update(array('id' => $newId, 'title' => $template['title']), false);
|
||||
|
||||
// Kanboard's duplicate() adds an "is a duplicate of" task link between the template and the
|
||||
// clone. Kept when recoreco_link_copies is on (a running count + one-click navigation to
|
||||
// each copy); stripped when off (the default), to avoid piling up links on frequent
|
||||
// schedules. getAll() returns the opposite task as $link['task_id'] and the row id as 'id'.
|
||||
if (! $linkCopies) {
|
||||
foreach ($this->taskLinkModel->getAll($newId) as $link) {
|
||||
if ((int) $link['task_id'] === (int) $template['id']) {
|
||||
$this->taskLinkModel->remove($link['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the clone: white icon + cannot itself be made recurring; record its source template.
|
||||
$this->taskMetadataModel->save($newId, array(
|
||||
'recoreco_clone' => 1,
|
||||
|
||||
Reference in New Issue
Block a user