Skip to content

Commit

Permalink
Don't delete exceptions and completions when saving.
Browse files Browse the repository at this point in the history
Conflicts:
	kronolith/templates/dynamic/edit.inc
	kronolith/templates/dynamic/task.inc
	nag/lib/Task.php
  • Loading branch information
yunosh committed Jun 1, 2015
1 parent 26f6bf4 commit 109fc94
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 21 deletions.
4 changes: 4 additions & 0 deletions kronolith/js/kronolith.js
Expand Up @@ -6605,6 +6605,10 @@ KronolithCore = {
} else {
$(prefix + 'RepeatLength').down('input[name=recur_end_type][value=none]').setValue(true);
}
$(prefix + 'Exceptions').setValue(recur.ex || '');
if ($(prefix + 'Completions')) {
$(prefix + 'Completions').setValue(recur.co || '');
}
this.toggleRecurrence(event, scheme);
},

Expand Down
19 changes: 13 additions & 6 deletions kronolith/lib/Event.php
Expand Up @@ -3156,12 +3156,19 @@ static public function readRecurrenceForm($start, $timezone,
break;
}

if ($exceptions = Horde_Util::getFormData('exceptions')) {
foreach ($exceptions as $exception) {
$recurrence->addException(
(int)substr($exception, 0, 4),
(int)substr($exception, 4, 2),
(int)substr($exception, 6, 2));
foreach (array('exceptions', 'completions') as $what) {
if ($data = Horde_Util::getFormData($what)) {
if (!is_array($data)) {
$data = explode(',', $data);
}
foreach ($data as $date) {
list($year, $month, $mday) = sscanf($date, '%04d%02d%02d');
if ($what == 'exceptions') {
$recurrence->addException($year, $month, $mday);
} else {
$recurrence->addCompletion($year, $month, $mday);
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions kronolith/templates/dynamic/edit.inc
Expand Up @@ -141,6 +141,7 @@
</div>

<div id="kronolithEventTabRecur" class="kronolithTabsOption" style="display:none">
<input type="hidden" id="kronolithEventExceptions" name="exceptions" />
<div id="kronolithEventRepeatType" style="display:none">
<?php printf(_("%s Don't repeat %s or repeat %s daily, %s weekly, %s monthly %s or %s yearly %s"),
'<label for="kronolithEventLinkNone"><input type="radio" name="recur" value="' . Horde_Date_Recurrence::RECUR_NONE . '" checked="checked" id="kronolithEventLinkNone" />', '</label>',
Expand Down
2 changes: 2 additions & 0 deletions kronolith/templates/dynamic/task.inc
Expand Up @@ -96,6 +96,8 @@
</div>

<div id="kronolithTaskTabRecur" class="kronolithTabsOption" style="display:none">
<input type="hidden" id="kronolithTaskExceptions" name="exceptions" />
<input type="hidden" id="kronolithTaskCompletions" name="completions" />
<div id="kronolithTaskRepeatType" style="display:none">
<?php printf(_("%s Don't repeat %s or repeat %s daily, %s weekly, %s monthly %s or %s yearly %s"),
'<label for="kronolithTaskLinkNone"><input type="radio" name="recur" value="' . Horde_Date_Recurrence::RECUR_NONE . '" checked="checked" id="kronolithTaskLinkNone" />', '</label>',
Expand Down
16 changes: 10 additions & 6 deletions nag/lib/Form/Type/NagRecurrence.php
Expand Up @@ -107,12 +107,16 @@ public function getInfo(&$vars, &$var, &$info)
break;
}

if ($vars->exceptions) {
foreach ($vars->exceptions as $exception) {
$recurrence->addException(
(int)substr($exception, 0, 4),
(int)substr($exception, 4, 2),
(int)substr($exception, 6, 2));
foreach (array('exceptions', 'completions') as $what) {
if ($vars->$what) {
foreach ($vars->$what as $date) {
list($year, $month, $mday) = sscanf($date, '%04d%02d%02d');
if ($what == 'exceptions') {
$recurrence->addException($year, $month, $mday);
} else {
$recurrence->addCompletion($year, $month, $mday);
}
}
}
}

Expand Down
17 changes: 8 additions & 9 deletions nag/lib/Task.php
Expand Up @@ -555,15 +555,14 @@ public function toggleComplete()
$this->completed_date = null;
$this->completed = false;
if ($this->recurs()) {
/* What do we want do delete here? All completions?
* The latest completion? Any completion in the
* future?. */
foreach ($this->recurrence->getCompletions() as $completion) {
$this->recurrence->deleteCompletion(
substr($completion, 0, 4),
substr($completion, 4, 2),
substr($completion, 6, 2));
}
/* Only delete the latest completion. */
$completions = $this->recurrence->getCompletions();
sort($completions);
list($year, $month, $mday) = sscanf(
end($completions),
'%04d%02d%02d'
);
$this->recurrence->deleteCompletion($year, $month, $mday);
}
return;
}
Expand Down
16 changes: 16 additions & 0 deletions nag/lib/Ui/VarRenderer/Nag.php
Expand Up @@ -368,6 +368,22 @@ public function _renderVarInput_NagRecurrence($form, $var, $vars)
Horde::label('recur_count', _("recurrences"))
);

/* Exceptions and completions. */
if ($recur) {
foreach ($recur->getExceptions() as $exception) {
$html .= sprintf(
'<input type="hidden" name="exceptions[]" value="%s" />',
$exception
);
}
foreach ($recur->getCompletions() as $completion) {
$html .= sprintf(
'<input type="hidden" name="completions[]" value="%s" />',
$completion
);
}
}

return $html;
}

Expand Down

0 comments on commit 109fc94

Please sign in to comment.