diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /lib/classes/DataFieldTimeEntry.class.php | |
current code from svn, revision 62608
Diffstat (limited to 'lib/classes/DataFieldTimeEntry.class.php')
| -rw-r--r-- | lib/classes/DataFieldTimeEntry.class.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/classes/DataFieldTimeEntry.class.php b/lib/classes/DataFieldTimeEntry.class.php new file mode 100644 index 0000000..96e5835 --- /dev/null +++ b/lib/classes/DataFieldTimeEntry.class.php @@ -0,0 +1,50 @@ +<?php +# Lifter002: DONE +# Lifter007: TEST + +/** + * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> + * @author Marcus Lunzenauer <mlunzena@uos.de> + * @author Martin Gieseking <mgieseki@uos.de> + * @license GPL2 or any later version + */ +class DataFieldTimeEntry extends DataFieldEntry +{ + protected $template = 'time.php'; + + /** + * Sets the value from a post request + * + * @param mixed $submitted_value The value from request + */ + public function setValueFromSubmit($value) + { + if ($value) { + parent::setValueFromSubmit($value); + } + } + + /** + * Checks if the datafield is empty (was not set) + * + * @return bool true if empty, else false + */ + public function isEmpty() + { + return $this->getValue() == ':'; + } + + /** + * Returns whether the datafield contents are valid + * + * @return boolean indicating whether the datafield contents are valid + */ + public function isValid() + { + $parts = explode(':', $this->value); + + return parent::isValid() + && $parts[0] >= 0 && $parts[0] <= 24 + && $parts[1] >= 0 && $parts[1] <= 59; + } +} |
