From 62827e6cf470449c117624058fb36ad94804bcc0 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 5 May 2020 14:25:42 +0200 Subject: Time tracking related plugins --- .../Validator/SubtaskTimeTrackingValidator.php | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 plugins/Timetrackingeditor/Validator/SubtaskTimeTrackingValidator.php (limited to 'plugins/Timetrackingeditor/Validator/SubtaskTimeTrackingValidator.php') diff --git a/plugins/Timetrackingeditor/Validator/SubtaskTimeTrackingValidator.php b/plugins/Timetrackingeditor/Validator/SubtaskTimeTrackingValidator.php new file mode 100644 index 00000000..6bddc47a --- /dev/null +++ b/plugins/Timetrackingeditor/Validator/SubtaskTimeTrackingValidator.php @@ -0,0 +1,73 @@ +commonValidationRules())); + + return array( + $v->execute(), + $v->getErrors() + ); + } + + /** + * Validate modification + * + * @access public + * @param array $values Form values + * @return array $valid, $errors [0] = Success or not, [1] = List of errors + */ + public function validateModification(array $values) + { + $rules = array ( + new Validators\Required('id', t('The Timetracking id is required')) + ); + + $v = new Validator($values, array_merge($rules, $this->commonValidationRules())); + + return array( + $v->execute(), + $v->getErrors() + ); + } + + /** + * Common validation rules, valid for creation and modification + * + * @access private + */ + private function commonValidationRules() + { + $rules = array( + new Validators\Required('task_id', t('The Task id is required')), + new Validators\Required('opposite_subtask_id', t('The subtask is required')), + new Validators\Required('start', t('The Start Date is required')), + new Validators\Required('time_spent', t('The Time spent is required')), + ); + return $rules; + } +} -- cgit v1.2.3