Run on registration and alert on new user have been converted to a single workflow.
This commit is contained in:
parent
5956fce2f1
commit
3e60294bb6
33 changed files with 315 additions and 50 deletions
|
|
@ -28,6 +28,7 @@ use WebGUI::Utility;
|
|||
use WebGUI::User;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Operation::Profile;
|
||||
use WebGUI::Workflow::Instance;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -267,10 +268,15 @@ sub createAccountSave {
|
|||
$self->session->var->start($userId,$self->session->getId);
|
||||
$self->_logLogin($userId,"success");
|
||||
$self->session->http->setStatus(201,"Account Registration Successful");
|
||||
my $command = $self->session->setting->get("runOnRegistration");
|
||||
WebGUI::Macro::process($self->session,\$command);
|
||||
system($command) if ($self->session->setting->get("runOnRegistration") ne "");
|
||||
WebGUI::MessageLog::addInternationalizedEntry('',$self->session->setting->get("onNewUserAlertGroup"),'',536) if ($self->session->setting->get("alertOnNewUser"));
|
||||
if ($self->session->setting->get("runOnRegistration")) {
|
||||
WebGUI::Workflow::Instance->create($self->session, {
|
||||
workflowId=>$self->session->setting->get("runOnRegistration"),
|
||||
methodName=>"new",
|
||||
className=>"WebGUI::User",
|
||||
parameters=>$self->session->userId,
|
||||
priority=>1
|
||||
});
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,19 +53,23 @@ The identifier for this field. Defaults to "workflowId".
|
|||
|
||||
=head4 type
|
||||
|
||||
The type of workflows to list based upon the object type that will be passed to them "none", "versiontag", etc. If this is omitted, the entire list of workflows will be returned.
|
||||
The type of workflows to list based upon the object type that will be passed to them "none", "WebGUI::VersionTag", etc. If this is omitted, the entire list of workflows will be returned.
|
||||
|
||||
=head4 label
|
||||
|
||||
A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to getName().
|
||||
|
||||
=head4 none
|
||||
|
||||
If set to 1 then a "None" option will appear in the list of workflows, which will store a null value in the field. Defaults to 0.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Workflow_Cron');
|
||||
my $i18n = WebGUI::International->new($session, 'Workflow');
|
||||
push(@{$definition}, {
|
||||
formName=>{
|
||||
defaultValue=>$i18n->get("topicName")
|
||||
|
|
@ -76,9 +80,12 @@ sub definition {
|
|||
name=>{
|
||||
defaultValue=>"workflowId"
|
||||
},
|
||||
namespace=>{
|
||||
type=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
none=>{
|
||||
defaulValue=>0
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -94,6 +101,7 @@ Renders a template picker control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $workflowList = WebGUI::Workflow->getList($self->session, $self->get("type"));
|
||||
$workflowList->{""} = "None";
|
||||
$self->set("options", $workflowList);
|
||||
$self->setManageIcons();
|
||||
return $self->SUPER::toHtml();
|
||||
|
|
@ -124,7 +132,7 @@ Adds code to the subtext field of the form so that buttons for managing or editi
|
|||
sub setManageIcons {
|
||||
my $self = shift;
|
||||
my $returnUrl = ";proceed=goBackToPage;returnUrl=".$self->session->url->escape($self->session->asset->getUrl) if $self->session->asset;
|
||||
my $buttons = $self->session->icon->edit("op=editWorkflow".$returnUrl);
|
||||
my $buttons = $self->session->icon->edit("op=editWorkflow;workflowId=".$self->get("workflowId").$returnUrl) if ($self->get("workflowId"));
|
||||
$buttons .= $self->session->icon->manage("op=manageWorkflows".$returnUrl);
|
||||
$self->set("subtext",$buttons . $self->get("subtext"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,16 +344,6 @@ our $HELP = {
|
|||
description => '824 description',
|
||||
namespace => 'WebGUI',
|
||||
},
|
||||
{
|
||||
title => '534',
|
||||
description => '534 description',
|
||||
namespace => 'WebGUI',
|
||||
},
|
||||
{
|
||||
title => '535',
|
||||
description => '535 description',
|
||||
namespace => 'WebGUI',
|
||||
},
|
||||
{
|
||||
title => '400',
|
||||
description => '400 description',
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ sub new {
|
|||
|
||||
=head2 send ( )
|
||||
|
||||
Sends the message via SMTP.
|
||||
Sends the message via SMTP. Returns 1 if successful.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -202,6 +202,7 @@ sub send {
|
|||
close(MAIL) or $self->session->errorHandler->error("Couldn't close connection to mail server: ".$self->session->setting->get("smtpServer"));
|
||||
} else {
|
||||
$self->session->errorHandler->error("Couldn't connect to mail server: ".$self->session->setting->get("smtpServer"));
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
my $smtp = Net::SMTP->new($self->session->setting->get("smtpServer")); # connect to an SMTP server
|
||||
|
|
@ -216,8 +217,10 @@ sub send {
|
|||
$smtp->quit; # Close the SMTP connection
|
||||
} else {
|
||||
$self->session->errorHandler->error("Couldn't connect to mail server: ".$self->session->setting->get("smtpServer"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -232,7 +232,9 @@ sub www_editSettings {
|
|||
-hoverHelp=>$i18n->get('118 description'),
|
||||
-value=>$session->setting->get("anonymousRegistration")
|
||||
);
|
||||
$tabform->getTab("user")->text(
|
||||
$tabform->getTab("user")->workflow(
|
||||
-none=>1,
|
||||
-type=>"WebGUI::User",
|
||||
-name=>"runOnRegistration",
|
||||
-label=>$i18n->get(559),
|
||||
-hoverHelp=>$i18n->get('559 description'),
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ sub getList {
|
|||
my $session = shift;
|
||||
my $type = shift;
|
||||
my $sql = "select workflowId, title from Workflow where enabled=1";
|
||||
$sql .= " where type=?" if ($type);
|
||||
return $session->db->buildHashRef($sql, $type);
|
||||
$sql .= " and type=?" if ($type);
|
||||
return $session->db->buildHashRef($sql, [$type]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
109
lib/WebGUI/Workflow/Activity/NotifyAboutUser.pm
Normal file
109
lib/WebGUI/Workflow/Activity/NotifyAboutUser.pm
Normal 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;
|
||||
|
||||
|
||||
95
lib/WebGUI/Workflow/Activity/RunCommandAsUser.pm
Normal file
95
lib/WebGUI/Workflow/Activity/RunCommandAsUser.pm
Normal 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;
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ use strict;
|
|||
|
||||
our $LANGUAGE = {
|
||||
label => 'English',
|
||||
toolbar => 'metal',
|
||||
toolbar => 'shiny',
|
||||
languageAbbreviation => 'en', # used by plugins such as javascript helpers and third-party perl modules
|
||||
locale => 'US' # same as above
|
||||
};
|
||||
|
|
|
|||
|
|
@ -457,11 +457,6 @@ Be aware that any database links you create here will be available to all conten
|
|||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'536' => {
|
||||
message => q|A new user named ^@; has joined the site.|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'379' => {
|
||||
message => q|Group ID|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
@ -512,11 +507,6 @@ Be aware that any database links you create here will be available to all conten
|
|||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'535' => {
|
||||
message => q|Group To Alert On New User|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'87' => {
|
||||
message => q|Edit Group|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
@ -802,11 +792,6 @@ to add or remove users from their groups.
|
|||
lastUpdated => 1036046598
|
||||
},
|
||||
|
||||
'534' => {
|
||||
message => q|Alert on new user?|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'400' => {
|
||||
message => q|Prevent Proxy Caching|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
@ -3519,16 +3504,6 @@ Optionally, if you are running a sendmail server on the same machine as WebGUI,
|
|||
lastUpdated => 1120239343,
|
||||
},
|
||||
|
||||
'534 description' => {
|
||||
message => q|Should someone be alerted when a new user registers anonymously?|,
|
||||
lastUpdated => 1120239343,
|
||||
},
|
||||
|
||||
'535 description' => {
|
||||
message => q|What group should be alerted when a new user registers?|,
|
||||
lastUpdated => 1120239343,
|
||||
},
|
||||
|
||||
'400 description' => {
|
||||
message => q|Some companies have proxy servers that cause problems with WebGUI. If you're experiencing problems with WebGUI, and you have a proxy server, you may want to set this setting to <i>Yes</i>. Beware that WebGUI's URLs will not be as user-friendly after this feature is turned on.|,
|
||||
lastUpdated => 1120239343,
|
||||
|
|
@ -3550,8 +3525,8 @@ Optionally, if you are running a sendmail server on the same machine as WebGUI,
|
|||
},
|
||||
|
||||
'559 description' => {
|
||||
message => q|If there is a command line specified here, it will be executed each time a user registers anonymously.|,
|
||||
lastUpdated => 1120239343,
|
||||
message => q|If there is a workflow chosen here, it will be executed each time a user registers anonymously.|,
|
||||
lastUpdated => 1141956483,
|
||||
},
|
||||
|
||||
'539 description' => {
|
||||
|
|
|
|||
48
lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutUser.pm
Normal file
48
lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutUser.pm
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package WebGUI::i18n::English::Workflow_Activity_NotifyAboutUser;
|
||||
|
||||
our $I18N = {
|
||||
'message help' => {
|
||||
message => q|Type the message you want to send. Feel free to use macros for additional parameters.|,
|
||||
context => q|the hover help for the message field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'message' => {
|
||||
message => q|Message|,
|
||||
context => q|a label for the message field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'subject help' => {
|
||||
message => q|The subject of the message that will be sent.|,
|
||||
context => q|the hover help for the subject field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'subject' => {
|
||||
message => q|Subject|,
|
||||
context => q|a label for the subject field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'to help' => {
|
||||
message => q|The email address to send the message to. You may put in mutliple email addresses seperated by commas.|,
|
||||
context => q|the hover help for the to field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'to' => {
|
||||
message => q|To|,
|
||||
context => q|a label for the to field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'topicName' => {
|
||||
message => q|Notify About User|,
|
||||
context => q|The name of this workflow activity.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package WebGUI::i18n::English::Workflow_Activity_RunCommandAsUser;
|
||||
|
||||
our $I18N = {
|
||||
'command help' => {
|
||||
message => q|Type the command you wish to run here. Feel free to use macros for additional parameters.|,
|
||||
context => q|the hover help for the command field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'command' => {
|
||||
message => q|Command|,
|
||||
context => q|a label for the command to be run|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'topicName' => {
|
||||
message => q|Run Command As User|,
|
||||
context => q|The name of this workflow activity.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue