Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(HR Streams) filter StreamModalities end field from json input
Browse files Browse the repository at this point in the history
Change-Id: Icc8795d56593bf92d1a254d0aaa7f9bdb413929f
Reviewed-on: http://gerrit.tine20.com/customers/18545
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
  • Loading branch information
paulmhh committed Nov 24, 2020
1 parent 83bd916 commit 65a148a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/tine20/HumanResources/Json/StreamTests.php
Expand Up @@ -40,6 +40,8 @@ public function testVirtualProperties()
Stream::FLD_STREAM_MODALITIES => [
[
StreamModality::FLD_START => Tinebase_DateTime::now()->toString('Y-m-d'),
// set end date to test filtering
StreamModality::FLD_END => Tinebase_DateTime::now()->addWeek(10)->toString('Y-m-d'),
StreamModality::FLD_INTERVAL => StreamModality::INT_WEEKLY,
StreamModality::FLD_NUM_INTERVAL => 10,
StreamModality::FLD_HOURS_INTERVAL => 16,
Expand Down
16 changes: 16 additions & 0 deletions tine20/HumanResources/Model/Stream.php
Expand Up @@ -158,4 +158,20 @@ class HumanResources_Model_Stream extends Tinebase_Record_NewAbstract
]
],
];

/**
* can be reimplemented by subclasses to modify values during setFromJson
* @param array $_data the json decoded values
* @return void
*/
protected function _setFromJson(array &$_data)
{
if (isset($_data[self::FLD_STREAM_MODALITIES]) && is_array($_data[self::FLD_STREAM_MODALITIES])) {
foreach ($_data[self::FLD_STREAM_MODALITIES] as &$streamModality) {
if (isset($streamModality[HumanResources_Model_StreamModality::FLD_END])) {
unset($streamModality[HumanResources_Model_StreamModality::FLD_END]);
}
}
}
}
}

0 comments on commit 65a148a

Please sign in to comment.