- my $search = RT::Scrips->new($CurrentUser);
- $search->Limit(FIELD => 'Queue', VALUE => 0);
- while (my $item = $search->Next) {
- my ($c, $a, $t) = map {lc $item->$_->Name}
- ('ScripConditionObj', 'ScripActionObj', 'TemplateObj');
- if ( exists $scrip{$c}{$a} and $item->Creator == 1 ) {
- warn "Deleting duplicate scrip $c $a [$t]\n";
- my ($val, $msg) = $item->Delete;
- warn "error deleting scrip: $msg\n" if !$val;
- }
- elsif ( exists $Delete_Scrips{$c}{$a}{$t} and $item->Creator == 1 ) {
- warn "Deleting obsolete scrip $c $a [$t]\n";
- my ($val, $msg) = $item->Delete;
- warn "error deleting scrip: $msg\n" if !$val;
- }
- else {
- $scrip{$c}{$a} = $item->id;
+ foreach my $criterion ('LimitToGlobal', 'LimitToNotAdded') {
+ my $search = RT::Scrips->new($CurrentUser);
+ $search->$criterion;
+
+ while (my $item = $search->Next) {
+ my ($c, $a, $t) = map {lc $item->$_->Name}
+ ('ScripConditionObj', 'ScripActionObj', 'TemplateObj');
+ if ( exists $scrip{$c}{$a} and $item->Creator == 1 ) {
+ warn "Deleting duplicate scrip $c $a [$t]\n";
+ my ($val, $msg) = $item->Delete;
+ warn "error deleting scrip: $msg\n" if !$val;
+ }
+ elsif ( exists $Delete_Scrips{$c}{$a}{$t} and $item->Creator == 1 ) {
+ warn "Deleting obsolete scrip $c $a [$t]\n";
+ my ($val, $msg) = $item->Delete;
+ warn "error deleting scrip: $msg\n" if !$val;
+ }
+ else {
+ $scrip{$c}{$a} = $item->id;
+ }