-
-
Save TITAN-UZ/4f5b4ebd37e8252406dbc26932b15c48 to your computer and use it in GitHub Desktop.
Устанавливает дату начала и окончания события на аналогичное значение в другом поле. Если задана дата начала, и не задана дата финиша, выставляет дату финиша равной дате начала и наоборот. Так же следит за тем, чтобы дата начала не была позже даты финиша.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| switch ($modx->event->name) { | |
| case 'OnDocFormSave': | |
| if ($resource->get('template') === 5) { // event | |
| $start = $resource->getTVValue('event.start'); | |
| $finish = $resource->getTVValue('event.finish'); | |
| if ($start && $finish) { // o both empty or both filled, that means OK | |
| return; | |
| } | |
| if (!$start && $finish != '') { | |
| $start = $finish; | |
| } | |
| if (!$finish && $start != '') { | |
| $finish = $start; | |
| } | |
| $resource->setTVValue('event.start', $start); | |
| $resource->setTVValue('event.finish', $finish); | |
| } | |
| break; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment