#!/usr/bin/perl -w
#

package RT;
use strict;
use vars qw($VERSION $Handle $Nobody $SystemUser $item);

use lib "/opt/rt/lib";
use lib "/opt/rt/etc";

#This drags in  RT's config.pm
use config;
use Carp;

use RT::Handle;
use RT::User;
use RT::CurrentUser;

#connect to the db
$RT::Handle = new RT::Handle($RT::DatabaseType);
$RT::Handle->Connect();


#Put together a current user object so we can create a User object
my $CurrentUser = new RT::CurrentUser();


#now that we bootstrapped that little bit, we can use the standard RT cli
# helpers  to do what we need

use RT::Interface::CLI  qw(CleanEnv LoadConfig DBConnect 
			   GetCurrentUser GetMessageContent);

#Clean out all the nasties from the environment
CleanEnv();

#Load etc/config.pm and drop privs
LoadConfig();

#Connect to the database and get RT::SystemUser and RT::Nobody loaded
DBConnect();


$CurrentUser->LoadByName('RT_System');

# {{{ ScripActions

my @ScripActions = (
		       {
			Name => 'NotifyOldOwner',
			Description =>  'Sends a message to the old owner of stollen ticket',
			ExecModule => 'NotifyOldOwner',
			Argument =>  'OldOwner',
		       },
		       
		       
		      );

# }}}
print "Creating ScripActions...";

use RT::ScripAction;
for $item (@ScripActions) {
    my $new_entry = new RT::ScripAction($CurrentUser);
    my $return = $new_entry->Create(%$item);
    print $return.".";
}

print "done.\n";

$RT::Handle->Disconnect();


1;

