%# RT::Extension::MandatoryFields
%#
%# Copyright 2011 synetics GmbH, http://i-doit.org/
%#
%# This program is free software; you can redistribute it and/or modify it under
%# the same terms as Perl itself.
%#
%# Request Tracker (RT) is Copyright Best Practical Solutions, LLC.

<%INIT>
my $ARGSRef = $ARGS{'ARGSRef'};

if ( $$ARGSRef{'QuickCreate'} ) {
    my %mandatoryFields = RT->Config->Get('MandatoryFields');

    my @supportedFields = (
        ## Message details
        'Requestors',
        'Subject',
        'Content',
        ## Meta data
        'Queue',
        'Owner'
    );

    for my $field (@supportedFields) {
        if ((exists $mandatoryFields{$field}) &&
            ($mandatoryFields{$field} eq 'true') &&
            ((!$$ARGSRef{$field}) || ($$ARGSRef{$field} =~ /^[ \t]*$/))) {
            $$skip_create = 1;
            push @{$results}, loc('[_1]: mandatory field', loc($field));
        }
    }
}
</%INIT>

<%ARGS>
$skip_create => undef
$results => undef
</%ARGS>
