%# RT::Extension::ReferenceIDoitObjects
%#
%# Copyright 2011-12 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'};
## 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>