Skip to content

Commit

Permalink
Mail: Changes regarding mail table and date duration filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Sep 20, 2018
1 parent fcc27bc commit b4c210f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 42 deletions.
79 changes: 38 additions & 41 deletions Services/Form/classes/class.ilDateDurationInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ilDateDurationInputGUI extends ilSubEnabledFormPropertyGUI implements ilTa
protected $toggle_fulltime_txt = '';
protected $toggle_fulltime_checked = false;

protected $empty_boundaries = false;
protected $allowOpenIntervals = false;

/**
* Constructor
Expand Down Expand Up @@ -249,7 +249,7 @@ public function setValueByArray($a_values)
$format = $incoming['tgl'] ? 0 : $this->getDatePickerTimeFormat();
$this->toggle_fulltime_checked = (bool)$incoming['tgl'];

if ($this->emptyBoundariesAllowed()) {
if ($this->openIntervalsAllowed()) {
if (is_string($incoming['start']) && trim($incoming['start']) !== '') {
$this->setStart(ilCalendarUtil::parseIncomingDate($incoming["start"], $format));
} else {
Expand Down Expand Up @@ -304,39 +304,39 @@ public function checkInput()
// always done to make sure there are no obsolete values left
$this->setStart(null);
$this->setEnd(null);

$valid_start = false;
if(trim($start))
{
if (trim($start)) {
$parsed = ilCalendarUtil::parseIncomingDate($start, $format);
if($parsed)
{
if ($parsed) {
$this->setStart($parsed);
$valid_start = true;
}
}
else if(!$this->getRequired() && !trim($end))
{
$valid_start = true;
} else if($this->emptyBoundariesAllowed() && !strlen(trim($start))) {
$valid_start = true;
}
} else {
if (!$this->getRequired() && !trim($end)) {
$valid_start = true;
} else {
if ($this->openIntervalsAllowed() && !strlen(trim($start))) {
$valid_start = true;
}
}
}

$valid_end = false;
if(trim($end))
{
$parsed = ilCalendarUtil::parseIncomingDate($end, $format);
if($parsed)
{
if (trim($end)) {
$parsed = ilCalendarUtil::parseIncomingDate($end, $format);
if ($parsed) {
$this->setEnd($parsed);
$valid_end = true;
}
}
else if(!$this->getRequired() && !trim($start))
{
$valid_end = true;
} else if($this->emptyBoundariesAllowed() && !strlen(trim($end))) {
$valid_end = true;
}
} else {
if (!$this->getRequired() && !trim($start)) {
$valid_end = true;
} else {
if ($this->openIntervalsAllowed() && !strlen(trim($end))) {
$valid_end = true;
}
}
}

if($this->getStartYear())
Expand All @@ -363,7 +363,7 @@ public function checkInput()
$valid = false;
}

if ($this->emptyBoundariesAllowed()) {
if ($this->openIntervalsAllowed()) {
if (!$this->getStart()) {
$_POST[$this->getPostVar()]["start"] = null;
}
Expand All @@ -375,24 +375,21 @@ public function checkInput()
} elseif (!$valid) {
$this->invalid_input_start = $start;
$this->invalid_input_end = $end;

$_POST[$this->getPostVar()]["start"] = null;
$_POST[$this->getPostVar()]["end"] = null;

$this->setAlert($lng->txt("form_msg_wrong_date"));
}
else
{
if(
} else {
if (
!$this->getStart() ||
!$this->getEnd()
)
{
) {
$_POST[$this->getPostVar()]["start"] = null;
$_POST[$this->getPostVar()]["end"] = null;
}
}

if($valid)
{
$valid = $this->checkSubItemsInput();
Expand Down Expand Up @@ -604,16 +601,16 @@ public function hideSubForm()
/**
* @return bool
*/
public function emptyBoundariesAllowed(): bool
public function openIntervalsAllowed(): bool
{
return $this->empty_boundaries;
return $this->allowOpenIntervals;
}

/**
* @param bool $empty_boundaries
* @param bool $allowOpenInterval
*/
public function setEmptyBoundaries(bool $empty_boundaries)
public function setAllowOpenIntervals(bool $allowOpenInterval)
{
$this->empty_boundaries = $empty_boundaries;
$this->allowOpenIntervals = $allowOpenInterval;
}
}
2 changes: 1 addition & 1 deletion Services/Mail/classes/class.ilMailFolderTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ public function initFilter()
}

$duration = new \ilDateDurationInputGUI($this->lng->txt('mail_filter_period'), 'period');
$duration->setEmptyBoundaries(true);
$duration->setAllowOpenIntervals(true);
$duration->setStartText($this->lng->txt('mail_filter_period_from'));
$duration->setEndText($this->lng->txt('mail_filter_period_until'));
$duration->setStart(new ilDateTime(null, IL_CAL_UNIX));
Expand Down

0 comments on commit b4c210f

Please sign in to comment.