Fixed whitespace screwing up POD
This commit is contained in:
parent
a880b058a5
commit
448448e451
2 changed files with 182 additions and 187 deletions
|
|
@ -72,28 +72,28 @@ Validates the username passed in.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub _isValidUsername {
|
sub _isValidUsername {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $username = shift;
|
my $username = shift;
|
||||||
my $error = "";
|
my $error = "";
|
||||||
|
|
||||||
return 1 if($self->userId ne "1" && $self->session->user->username eq $username);
|
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
return 1 if($self->userId ne "1" && $self->session->user->username eq $username);
|
||||||
|
|
||||||
if ($username =~ /^\s/ || $username =~ /\s$/) {
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
$error .= '<li>'.$i18n->get(724).'</li>';
|
|
||||||
}
|
if ($username =~ /^\s/ || $username =~ /\s$/) {
|
||||||
if ($username eq "") {
|
$error .= '<li>'.$i18n->get(724).'</li>';
|
||||||
$error .= '<li>'.$i18n->get(725).'</li>';
|
}
|
||||||
}
|
if ($username eq "") {
|
||||||
$self->error($error);
|
$error .= '<li>'.$i18n->get(725).'</li>';
|
||||||
return $error eq "";
|
}
|
||||||
|
$self->error($error);
|
||||||
|
return $error eq "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub _logLogin {
|
sub _logLogin {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->db->write("insert into userLoginLog values (".$self->session->db->quote($_[0]).",".$self->session->db->quote($_[1]).",".$self->session->datetime->time().","
|
$self->session->db->write("insert into userLoginLog values (".$self->session->db->quote($_[0]).",".$self->session->db->quote($_[1]).",".$self->session->datetime->time().","
|
||||||
.$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).",".$self->session->db->quote($self->session->env->get("HTTP_USER_AGENT")).")");
|
.$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).",".$self->session->db->quote($self->session->env->get("HTTP_USER_AGENT")).")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ Creates elements for the add user form specific to this Authentication Method.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addUserForm {
|
sub addUserForm {
|
||||||
#Added for interface purposes only. Needs to be implemented in the subclass.
|
#Added for interface purposes only. Needs to be implemented in the subclass.
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -118,8 +118,8 @@ Saves user elements unique to this authentication method
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addUserFormSave {
|
sub addUserFormSave {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->saveParams(($_[1] || $self->userId),$self->authMethod,$_[0]);
|
$self->saveParams(($_[1] || $self->userId),$self->authMethod,$_[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -131,24 +131,24 @@ Superclass method that performs standard login routines. This method returns tr
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub authenticate {
|
sub authenticate {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $username = shift;
|
my $username = shift;
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
my $user = $self->session->db->quickHashRef("select userId,authMethod,status from users where username=".$self->session->db->quote($username));
|
my $user = $self->session->db->quickHashRef("select userId,authMethod,status from users where username=".$self->session->db->quote($username));
|
||||||
my $uid = $user->{userId};
|
my $uid = $user->{userId};
|
||||||
#If userId does not exist or is not active, fail login
|
#If userId does not exist or is not active, fail login
|
||||||
if(!$uid){
|
if (!$uid) {
|
||||||
$self->error($i18n->get(68));
|
$self->error($i18n->get(68));
|
||||||
return 0;
|
return 0;
|
||||||
} elsif($user->{status} ne 'Active'){
|
} elsif($user->{status} ne 'Active') {
|
||||||
$self->error($i18n->get(820));
|
$self->error($i18n->get(820));
|
||||||
$self->_logLogin($uid, "failure");
|
$self->_logLogin($uid, "failure");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#Set User Id
|
#Set User Id
|
||||||
$self->user(WebGUI::User->new($self->session,$uid));
|
$self->user(WebGUI::User->new($self->session,$uid));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -164,9 +164,9 @@ Gets or sets the authMethod in the Auth Object
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub authMethod {
|
sub authMethod {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{authMethod} if(!$_[0]);
|
return $self->{authMethod} if(!$_[0]);
|
||||||
$self->{authMethod} = $_[0];
|
$self->{authMethod} = $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -178,11 +178,11 @@ Superclass method that performs general functionality for creating new accounts.
|
||||||
=head3 method
|
=head3 method
|
||||||
|
|
||||||
Auth method that the form for creating users should call
|
Auth method that the form for creating users should call
|
||||||
|
|
||||||
=head3 vars
|
=head3 vars
|
||||||
|
|
||||||
Array ref of template vars from subclass
|
Array ref of template vars from subclass
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub createAccount {
|
sub createAccount {
|
||||||
|
|
@ -200,10 +200,10 @@ sub createAccount {
|
||||||
$vars->{'create.form.profile'} = WebGUI::Operation::Profile::getRequiredProfileFields($self->session);
|
$vars->{'create.form.profile'} = WebGUI::Operation::Profile::getRequiredProfileFields($self->session);
|
||||||
|
|
||||||
$vars->{'create.form.submit'} = WebGUI::Form::submit($self->session,{});
|
$vars->{'create.form.submit'} = WebGUI::Form::submit($self->session,{});
|
||||||
$vars->{'create.form.footer'} = WebGUI::Form::formFooter($self->session,);
|
$vars->{'create.form.footer'} = WebGUI::Form::formFooter($self->session,);
|
||||||
|
|
||||||
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
|
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
|
||||||
$vars->{'login.label'} = $i18n->get(58);
|
$vars->{'login.label'} = $i18n->get(58);
|
||||||
|
|
||||||
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
|
$vars->{'login.url'} = $self->session->url->page('op=auth;method=init');
|
||||||
$vars->{'login.label'} = $i18n->get(58);
|
$vars->{'login.label'} = $i18n->get(58);
|
||||||
|
|
@ -220,19 +220,19 @@ Superclass method that performs general functionality for saving new accounts.
|
||||||
=head3 username
|
=head3 username
|
||||||
|
|
||||||
Username for the account being created
|
Username for the account being created
|
||||||
|
|
||||||
=head3 properties
|
=head3 properties
|
||||||
|
|
||||||
Properties from the subclass that should be saved as authentication parameters
|
Properties from the subclass that should be saved as authentication parameters
|
||||||
|
|
||||||
=head3 password
|
=head3 password
|
||||||
|
|
||||||
Password entered by the user. This is only used in for sending the user a notification by email of his/her username/password
|
Password entered by the user. This is only used in for sending the user a notification by email of his/her username/password
|
||||||
|
|
||||||
=head3 profile
|
=head3 profile
|
||||||
|
|
||||||
Hashref of profile values returned by the function WebGUI::Operation::Profile::validateProfileData($self->session)
|
Hashref of profile values returned by the function WebGUI::Operation::Profile::validateProfileData($self->session)
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub createAccountSave {
|
sub createAccountSave {
|
||||||
|
|
@ -288,7 +288,7 @@ Superclass method that displays a confirm message for deactivating a user's acco
|
||||||
=head3 method
|
=head3 method
|
||||||
|
|
||||||
Auth method that the form for creating users should call
|
Auth method that the form for creating users should call
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub deactivateAccount {
|
sub deactivateAccount {
|
||||||
|
|
@ -297,7 +297,7 @@ sub deactivateAccount {
|
||||||
return $self->session->privilege->vitalComponent() if($self->userId eq '1' || $self->userId eq '3');
|
return $self->session->privilege->vitalComponent() if($self->userId eq '1' || $self->userId eq '3');
|
||||||
return $self->session->privilege->adminOnly() if(!$self->session->setting->get("selfDeactivation"));
|
return $self->session->privilege->adminOnly() if(!$self->session->setting->get("selfDeactivation"));
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
my %var;
|
my %var;
|
||||||
$var{title} = $i18n->get(42);
|
$var{title} = $i18n->get(42);
|
||||||
$var{question} = $i18n->get(60);
|
$var{question} = $i18n->get(60);
|
||||||
$var{'yes.url'} = $self->session->url->page('op=auth;method='.$method);
|
$var{'yes.url'} = $self->session->url->page('op=auth;method='.$method);
|
||||||
|
|
@ -312,7 +312,7 @@ sub deactivateAccount {
|
||||||
=head2 deactivateAccount ( method )
|
=head2 deactivateAccount ( method )
|
||||||
|
|
||||||
Superclass method that performs general functionality for deactivating accounts.
|
Superclass method that performs general functionality for deactivating accounts.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub deactivateAccountConfirm {
|
sub deactivateAccountConfirm {
|
||||||
|
|
@ -333,8 +333,8 @@ Removes the user's authentication parameters from the database for all authentic
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub deleteParams {
|
sub deleteParams {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->db->write("delete from authentication where userId=".$self->session->db->quote($self->userId));
|
$self->session->db->write("delete from authentication where userId=".$self->session->db->quote($self->userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -346,33 +346,33 @@ Superclass method that performs general functionality for viewing editable field
|
||||||
=head3 method
|
=head3 method
|
||||||
|
|
||||||
Auth method that the form for updating a user's account should call
|
Auth method that the form for updating a user's account should call
|
||||||
|
|
||||||
=head3 vars
|
=head3 vars
|
||||||
|
|
||||||
Array ref of template vars from subclass
|
Array ref of template vars from subclass
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub displayAccount {
|
sub displayAccount {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $method = $_[0];
|
my $method = $_[0];
|
||||||
my $vars = $_[1];
|
my $vars = $_[1];
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
$vars->{title} = $i18n->get(61);
|
$vars->{title} = $i18n->get(61);
|
||||||
|
|
||||||
$vars->{'account.form.header'} = WebGUI::Form::formHeader($self->session,{});
|
$vars->{'account.form.header'} = WebGUI::Form::formHeader($self->session,{});
|
||||||
$vars->{'account.form.header'} .= WebGUI::Form::hidden($self->session,{"name"=>"op","value"=>"auth"});
|
$vars->{'account.form.header'} .= WebGUI::Form::hidden($self->session,{"name"=>"op","value"=>"auth"});
|
||||||
$vars->{'account.form.header'} .= WebGUI::Form::hidden($self->session,{"name"=>"method","value"=>$method});
|
$vars->{'account.form.header'} .= WebGUI::Form::hidden($self->session,{"name"=>"method","value"=>$method});
|
||||||
if($self->session->setting->get("useKarma")){
|
if ($self->session->setting->get("useKarma")) {
|
||||||
$vars->{'account.form.karma'} = $self->session->user->karma;
|
$vars->{'account.form.karma'} = $self->session->user->karma;
|
||||||
$vars->{'account.form.karma.label'} = $i18n->get(537);
|
$vars->{'account.form.karma.label'} = $i18n->get(537);
|
||||||
}
|
}
|
||||||
$vars->{'account.form.submit'} = WebGUI::Form::submit($self->session,{});
|
$vars->{'account.form.submit'} = WebGUI::Form::submit($self->session,{});
|
||||||
$vars->{'account.form.footer'} = WebGUI::Form::formFooter($self->session,);
|
$vars->{'account.form.footer'} = WebGUI::Form::formFooter($self->session,);
|
||||||
|
|
||||||
$vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions($self->session);
|
$vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions($self->session);
|
||||||
return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars);
|
return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -384,11 +384,11 @@ Superclass method that performs general functionality for creating new accounts.
|
||||||
=head3 method
|
=head3 method
|
||||||
|
|
||||||
Auth method that the form for performing the login routine should call
|
Auth method that the form for performing the login routine should call
|
||||||
|
|
||||||
=head3 vars
|
=head3 vars
|
||||||
|
|
||||||
Array ref of template vars from subclass
|
Array ref of template vars from subclass
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub displayLogin {
|
sub displayLogin {
|
||||||
|
|
@ -429,7 +429,7 @@ Creates user form elements specific to this Auth Method.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub editUserForm {
|
sub editUserForm {
|
||||||
#Added for interface purposes only. Needs to be implemented in the subclass.
|
#Added for interface purposes only. Needs to be implemented in the subclass.
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -441,8 +441,8 @@ Saves user elements unique to this authentication method
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub editUserFormSave {
|
sub editUserFormSave {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->saveParams($self->userId,$self->authMethod,$_[0]);
|
$self->saveParams($self->userId,$self->authMethod,$_[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -454,9 +454,9 @@ Sets or returns the error currently stored in the object
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub error {
|
sub error {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{error} if (!$_[0]);
|
return $self->{error} if (!$_[0]);
|
||||||
$self->{error} = $_[0];
|
$self->{error} = $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -504,7 +504,7 @@ Returns a hash reference with the user's authentication information. This metho
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getParams {
|
sub getParams {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $userId = $_[0] || $self->userId;
|
my $userId = $_[0] || $self->userId;
|
||||||
my $authMethod = $_[1] || $self->authMethod;
|
my $authMethod = $_[1] || $self->authMethod;
|
||||||
return $self->session->db->buildHashRef("select fieldName, fieldData from authentication where userId=".$self->session->db->quote($userId)." and authMethod=".$self->session->db->quote($authMethod));
|
return $self->session->db->buildHashRef("select fieldName, fieldData from authentication where userId=".$self->session->db->quote($userId)." and authMethod=".$self->session->db->quote($authMethod));
|
||||||
|
|
@ -539,8 +539,8 @@ Override this method in your subclass to change the initialization for custom au
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub init {
|
sub init {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->displayLogin;
|
return $self->displayLogin;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -552,8 +552,8 @@ Returns whether or not a method is callable
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub isCallable {
|
sub isCallable {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return isIn($_[0],@{$self->{callable}})
|
return isIn($_[0],@{$self->{callable}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -567,20 +567,20 @@ Authentication should always happen in the subclass routine.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub login {
|
sub login {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($cmd, $uid, $u, $authMethod,$msg,$userData,$expireDate);
|
my ($cmd, $uid, $u, $authMethod,$msg,$userData,$expireDate);
|
||||||
|
|
||||||
#Create a new user
|
#Create a new user
|
||||||
$uid = $self->userId;
|
$uid = $self->userId;
|
||||||
$u = WebGUI::User->new($self->session,$uid);
|
$u = WebGUI::User->new($self->session,$uid);
|
||||||
$self->session->user({user=>$u});
|
$self->session->user({user=>$u});
|
||||||
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
|
$u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma"));
|
||||||
$self->_logLogin($uid,"success");
|
$self->_logLogin($uid,"success");
|
||||||
if ($self->session->scratch->get("redirectAfterLogin")) {
|
if ($self->session->scratch->get("redirectAfterLogin")) {
|
||||||
$self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin"));
|
$self->session->http->setRedirect($self->session->scratch->get("redirectAfterLogin"));
|
||||||
$self->session->scratch->delete("redirectAfterLogin");
|
$self->session->scratch->delete("redirectAfterLogin");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -593,11 +593,11 @@ Superclass method that performs standard logout routines.
|
||||||
|
|
||||||
sub logout {
|
sub logout {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->var->end($self->session->var->get("sessionId"));
|
$self->session->var->end($self->session->var->get("sessionId"));
|
||||||
$self->session->user({userId=>'1'});
|
$self->session->user({userId=>'1'});
|
||||||
my $u = WebGUI::User->new($self->session,1);
|
my $u = WebGUI::User->new($self->session,1);
|
||||||
$self->{user} = $u;
|
$self->{user} = $u;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -609,16 +609,16 @@ Constructor.
|
||||||
=head3 session
|
=head3 session
|
||||||
|
|
||||||
=head3 authMethod
|
=head3 authMethod
|
||||||
|
|
||||||
This object's authentication method
|
This object's authentication method
|
||||||
|
|
||||||
=head3 userId
|
=head3 userId
|
||||||
|
|
||||||
userId for the user requesting authentication. This defaults to $self->session->user->userId
|
userId for the user requesting authentication. This defaults to $self->session->user->userId
|
||||||
|
|
||||||
=head3 callable
|
=head3 callable
|
||||||
|
|
||||||
Array reference of methods allowed to be called externally;
|
Array reference of methods allowed to be called externally;
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
@ -650,13 +650,11 @@ Sets or returns the Profile hash for a user.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub profile {
|
sub profile {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{profile} if ($_[0]);
|
return $self->{profile} if ($_[0]);
|
||||||
$self->{profile} = $_[0];
|
$self->{profile} = $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
sub session {
|
sub session {
|
||||||
|
|
@ -678,9 +676,9 @@ Array reference containing a list of methods for this authentication instance th
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub setCallable {
|
sub setCallable {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my @callable = @{$self->{callable}};
|
my @callable = @{$self->{callable}};
|
||||||
@callable = (@callable,@{$_[0]});
|
@callable = (@callable,@{$_[0]});
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -704,12 +702,12 @@ A hash reference containing parameter names and values to be saved.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub saveParams {
|
sub saveParams {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($uid, $authMethod, $data) = @_;
|
my ($uid, $authMethod, $data) = @_;
|
||||||
foreach (keys %{$data}) {
|
foreach (keys %{$data}) {
|
||||||
$self->session->db->write("delete from authentication where userId=".$self->session->db->quote($uid)." and authMethod=".$self->session->db->quote($authMethod)." and fieldName=".$self->session->db->quote($_));
|
$self->session->db->write("delete from authentication where userId=".$self->session->db->quote($uid)." and authMethod=".$self->session->db->quote($authMethod)." and fieldName=".$self->session->db->quote($_));
|
||||||
$self->session->db->write("insert into authentication (userId,authMethod,fieldData,fieldName) values (".$self->session->db->quote($uid).",".$self->session->db->quote($authMethod).",".$self->session->db->quote($data->{$_}).",".$self->session->db->quote($_).")");
|
$self->session->db->write("insert into authentication (userId,authMethod,fieldData,fieldName) values (".$self->session->db->quote($uid).",".$self->session->db->quote($authMethod).",".$self->session->db->quote($data->{$_}).",".$self->session->db->quote($_).")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -721,9 +719,9 @@ Sets or Returns the user object stored in the wobject
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub user {
|
sub user {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{user} if (!$_[0]);
|
return $self->{user} if (!$_[0]);
|
||||||
$self->{user} = $_[0];
|
$self->{user} = $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -735,9 +733,9 @@ Returns the userId currently stored in the object
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub userId {
|
sub userId {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $u = $self->user;
|
my $u = $self->user;
|
||||||
return $u->userId;
|
return $u->userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -749,9 +747,9 @@ Returns the username currently stored in the object
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub username {
|
sub username {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $u = $self->user;
|
my $u = $self->user;
|
||||||
return $u->username;
|
return $u->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -763,21 +761,21 @@ Validates the a username.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub validUsername {
|
sub validUsername {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $username = shift;
|
my $username = shift;
|
||||||
WebGUI::Macro::negate(\$username);
|
WebGUI::Macro::negate(\$username);
|
||||||
my $error = "";
|
my $error = "";
|
||||||
|
|
||||||
if($self->_isDuplicateUsername($username)){
|
if ($self->_isDuplicateUsername($username)) {
|
||||||
$error .= $self->error;
|
$error .= $self->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$self->_isValidUsername($username)){
|
if (!$self->_isValidUsername($username)) {
|
||||||
$error .= $self->error;
|
$error .= $self->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->error($error);
|
$self->error($error);
|
||||||
return $error eq "";
|
return $error eq "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -789,9 +787,9 @@ Sets or Returns a warning in the object
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub warning {
|
sub warning {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{warning} if (!$_[0]);
|
return $self->{warning} if (!$_[0]);
|
||||||
$self->{warning} = $_[0];
|
$self->{warning} = $_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package WebGUI::Storage;
|
package WebGUI::Storage;
|
||||||
|
|
||||||
=head1 LEGAL
|
=head1 LEGAL
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||||
|
|
@ -234,21 +234,21 @@ sub addFileFromFormPost {
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 addFileFromHashref ( filename, hashref )
|
=head2 addFileFromHashref ( filename, hashref )
|
||||||
|
|
||||||
Stores a hash reference as a file and returns a URL compliant filename. Retrieve the data with getFileContentsAsHashref.
|
Stores a hash reference as a file and returns a URL compliant filename. Retrieve the data with getFileContentsAsHashref.
|
||||||
|
|
||||||
=head3 filename
|
=head3 filename
|
||||||
|
|
||||||
The name of the file to create.
|
The name of the file to create.
|
||||||
|
|
||||||
=head3 hashref
|
=head3 hashref
|
||||||
|
|
||||||
A hash reference containing the data you wish to persist to the filesystem.
|
A hash reference containing the data you wish to persist to the filesystem.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addFileFromHashref {
|
sub addFileFromHashref {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = $self->session->url->makeCompliant(shift);
|
my $filename = $self->session->url->makeCompliant(shift);
|
||||||
|
|
@ -289,17 +289,17 @@ sub addFileFromScalar {
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 copy ( [ storage ] )
|
=head2 copy ( [ storage ] )
|
||||||
|
|
||||||
Copies a storage location and it's contents. Returns a new storage location object. Note that this does not copy privileges or other special filesystem properties.
|
Copies a storage location and it's contents. Returns a new storage location object. Note that this does not copy privileges or other special filesystem properties.
|
||||||
|
|
||||||
=head3 storage
|
=head3 storage
|
||||||
|
|
||||||
Optionally pass in a storage object to copy the data to.
|
Optionally pass in a storage object to copy the data to.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub copy {
|
sub copy {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newStorage = shift || WebGUI::Storage->create($self->session);
|
my $newStorage = shift || WebGUI::Storage->create($self->session);
|
||||||
|
|
@ -323,7 +323,7 @@ sub copy {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 create ( session )
|
=head2 create ( session )
|
||||||
|
|
||||||
Creates a new storage location on the file system.
|
Creates a new storage location on the file system.
|
||||||
|
|
||||||
=head3 session
|
=head3 session
|
||||||
|
|
@ -336,16 +336,16 @@ sub create {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my $id = $session->id->generate();
|
my $id = $session->id->generate();
|
||||||
my $self = $class->get($session,$id);
|
my $self = $class->get($session,$id);
|
||||||
$self->_makePath;
|
$self->_makePath;
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 createTemp ( session )
|
=head2 createTemp ( session )
|
||||||
|
|
||||||
Creates a temporary storage location on the file system.
|
Creates a temporary storage location on the file system.
|
||||||
|
|
||||||
=head3 session
|
=head3 session
|
||||||
|
|
@ -362,7 +362,7 @@ sub createTemp {
|
||||||
my $self = {_session=>$session, _id => $id, _part1 => 'temp', _part2 => $1};
|
my $self = {_session=>$session, _id => $id, _part1 => 'temp', _part2 => $1};
|
||||||
bless $self, ref($class)||$class;
|
bless $self, ref($class)||$class;
|
||||||
$self->_makePath;
|
$self->_makePath;
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -393,17 +393,17 @@ sub delete {
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 deleteFile ( filename )
|
=head2 deleteFile ( filename )
|
||||||
|
|
||||||
Deletes a file from it's storage location.
|
Deletes a file from it's storage location.
|
||||||
|
|
||||||
=head3 filename
|
=head3 filename
|
||||||
|
|
||||||
The name of the file to delete.
|
The name of the file to delete.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub deleteFile {
|
sub deleteFile {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
|
|
@ -421,7 +421,7 @@ Returns a WebGUI::Storage object.
|
||||||
|
|
||||||
A reference to the current sesion.
|
A reference to the current sesion.
|
||||||
|
|
||||||
=head3 id
|
=head3 id
|
||||||
|
|
||||||
The unique identifier for this file system storage location.
|
The unique identifier for this file system storage location.
|
||||||
|
|
||||||
|
|
@ -494,17 +494,17 @@ sub getFileContentsAsScalar {
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getFileExtension ( filename )
|
=head2 getFileExtension ( filename )
|
||||||
|
|
||||||
Returns the extension or type of this file.
|
Returns the extension or type of this file.
|
||||||
|
|
||||||
=head3 filename
|
=head3 filename
|
||||||
|
|
||||||
The filename of the file you wish to find out the type for.
|
The filename of the file you wish to find out the type for.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getFileExtension {
|
sub getFileExtension {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
|
|
@ -516,7 +516,7 @@ sub getFileExtension {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getFileIconUrl ( filename )
|
=head2 getFileIconUrl ( filename )
|
||||||
|
|
||||||
Returns the icon associated with this type of file.
|
Returns the icon associated with this type of file.
|
||||||
|
|
||||||
|
|
@ -539,13 +539,13 @@ sub getFileIconUrl {
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getFileSize ( filename )
|
=head2 getFileSize ( filename )
|
||||||
|
|
||||||
Returns the size of this file.
|
Returns the size of this file.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getFileSize {
|
sub getFileSize {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
|
|
@ -586,17 +586,17 @@ sub getFiles {
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getFileContentsAsHashref ( filename )
|
=head2 getFileContentsAsHashref ( filename )
|
||||||
|
|
||||||
Returns a hash reference from the file. Must be used in conjunction with a file that was saved using the addFileFromHashref method.
|
Returns a hash reference from the file. Must be used in conjunction with a file that was saved using the addFileFromHashref method.
|
||||||
|
|
||||||
=head3 filename
|
=head3 filename
|
||||||
|
|
||||||
The file to retrieve the data from.
|
The file to retrieve the data from.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getHashref {
|
sub getHashref {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
|
|
@ -685,9 +685,8 @@ sub getUrl {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 renameFile ( filename, newFilename )
|
=head2 renameFile ( filename, newFilename )
|
||||||
|
|
||||||
Renames an file's filename. Returns true if the rename succeeded and false
|
Renames an file's filename. Returns true if the rename succeeded and false
|
||||||
|
|
@ -696,13 +695,13 @@ if it didn't.
|
||||||
=head3 filename
|
=head3 filename
|
||||||
|
|
||||||
The name of the file you wish to rename.
|
The name of the file you wish to rename.
|
||||||
|
|
||||||
=head3 newFilename
|
=head3 newFilename
|
||||||
|
|
||||||
Define the new filename a specified file.
|
Define the new filename a specified file.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub renameFile {
|
sub renameFile {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
|
|
@ -817,5 +816,3 @@ sub untar {
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue