%# RT::Extension::ReferenceIDoitObjects
%#
%# Copyright (C) 2011-14 synetics GmbH, <http://i-doit.org/>
%#
%# This program is free software: you can redistribute it and/or modify
%# it under the terms of the GNU Affero General Public License as
%# published by the Free Software Foundation, either version 3 of the
%# License, or (at your option) any later version.
%#
%# This program is distributed in the hope that it will be useful,
%# but WITHOUT ANY WARRANTY; without even the implied warranty of
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%# GNU Affero General Public License for more details.
%#
%# You should have received a copy of the GNU Affero General Public License
%# along with this program. If not, see <http://www.gnu.org/licenses/>.
%#
%# Request Tracker (RT) is Copyright Best Practical Solutions, LLC.
<%INIT>
my $ARGSRef = $ARGS{'ARGSRef'};
## Mandator:
my $IDoitMandator = 'i-doit mandator';
my $cf = RT::CustomField->new($RT::SystemUser);
$cf->LoadByNameAndQueue(Name => $IDoitMandator, Queue => '0');
unless ($cf->id) {
my $msg = loc(sprintf('Custom field "%s" does not exist.', $IDoitMandator));
RT::Logger->error($msg);
$$skip_create = 1;
push @{$results}, $msg;
}
my $cfIDoitMandator = 'CustomField-' . $cf->id;
## Try to fetch mandator from HTTP GET:
if ($$ARGSRef{'IDoitMandator'}) {
$$ARGSRef{$cfIDoitMandator} = $$ARGSRef{'IDoitMandator'};
}
## Try to fetch default mandator:
if ((!$$ARGSRef{$cfIDoitMandator}) || ($$ARGSRef{$cfIDoitMandator} =~ /^[ \t]*$/)) {
my $IDoitDefaultMandator = RT->Config->Get('IDoitDefaultMandator');
unless ($IDoitDefaultMandator) {
my $msg = loc('Default mandator is not configured.');
RT::Logger->error($msg);
$$skip_create = 1;
push @{$results}, $msg;
}
$$ARGSRef{$cfIDoitMandator} = $IDoitDefaultMandator;
}
## Objects:
my $IDoitObjects = 'i-doit objects';
$cf = RT::CustomField->new($RT::SystemUser);
$cf->LoadByNameAndQueue(Name => $IDoitObjects, Queue => '0');
unless ($cf->id) {
my $msg = loc(sprintf('Custom field "%s" does not exist.', $IDoitObjects));
RT::Logger->error($msg);
$$skip_create = 1;
push @{$results}, $msg;
}
my $cfIDoitObjects = 'CustomField-' . $cf->id;
## Try to fetch objects from HTTP GET:
if ($$ARGSRef{'IDoitObjects'}) {
$$ARGSRef{$cfIDoitObjects} = $$ARGSRef{'IDoitObjects'};
}
</%INIT>
<%ARGS>
$skip_create => undef
$results => undef
</%ARGS>