Run on registration and alert on new user have been converted to a single workflow.

This commit is contained in:
JT Smith 2006-03-10 03:48:23 +00:00
parent 5956fce2f1
commit 3e60294bb6
33 changed files with 315 additions and 50 deletions

View file

@ -0,0 +1,109 @@
package WebGUI::Workflow::Activity::NotifyAboutUser;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2006 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Mail::Send;
=head1 NAME
Package WebGUI::Workflow::Activity::NotifyAboutUser
=head1 DESCRIPTION
Takes a user object and sends out a message. Can use macros in message.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_NotifyAboutUser");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
to => {
fieldType=>"text",
label=>$i18n->get("to"),
defaultValue=>$session->setting->get("companyEmail"),
hoverHelp=>$i18n->get("to help")
},
subject => {
fieldType=>"text",
label=>$i18n->get("subject"),
defaultValue=>undef,
hoverHelp=>$i18n->get("subject help")
},
message => {
fieldType=>"textarea",
label=>$i18n->get("message"),
defaultValue=>undef,
hoverHelp=>$i18n->get("message help")
},
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( [ object ] )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $user = shift;
$self->session->user({user=>$user});
my $message = $self->get("message");
WebGUI::Macro::process(\$message);
my $mail = WebGUI::Mail::Send->new($self->session, {
to=>$self->get("to"),
subject=>$self->get("subject")
});
$mail->addText($message);
return $mail->send;
}
1;

View file

@ -0,0 +1,95 @@
package WebGUI::Workflow::Activity::RunCommandAsUser;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2006 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::International;
use WebGUI::Macro;
=head1 NAME
Package WebGUI::Workflow::Activity::RunCommandAsUser
=head1 DESCRIPTION
This activity will tell the session to switch to the user object passed in as the current user, and then execute a command on the command line of the local operating system. It processes macros so feel free to use macros in the command line.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_RunCommandAsUser");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
commandLine => {
fieldType=>"text",
label=>$i18n->get("command"),
defaultValue=>undef,
hoverHelp=>$i18n->get("command help")
},
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( [ object ] )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $user = shift;
my $cmd = $self->get("command");
$self->session->user({user=>$user});
WebGUI::Macro::process(\$cmd);
if (system($cmd)) {
return 0;
} else {
return 1;
}
}
1;