diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 3e682e56c..688fae965 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -422,3 +422,41 @@ function isValidDate($dateString) return false; } } + + +// ------------------------------------------------------------------------ +// Collection of utility functions for form validation purposes +// ------------------------------------------------------------------------ + +/** + * check if string can be converted to a date + */ +function is_valid_date($dateString) +{ + try + { + return (new DateTime($dateString)) !== false; + } + catch(Exception $e) + { + return false; + } +} + +/** + * check if given permissions are met + */ +function has_write_permissions($value, $permissions = '') +{ + if (!$permissions) + $permissions = $value; // TODO(chris): ?? + $permissions = explode(',', $permissions); + + $CI =& get_instance(); + $CI->load->library('PermissionLib'); + return $CI->permissionlib->hasAtLeastOne( + $permissions, + 'sometable', + 'w' + ); +} diff --git a/application/language/english/form_validation_lang.php b/application/language/english/form_validation_lang.php new file mode 100644 index 000000000..9e942f8e5 --- /dev/null +++ b/application/language/english/form_validation_lang.php @@ -0,0 +1,42 @@ +