Fixed errors in phpBB3 module.
This commit is contained in:
parent
0fb9189f02
commit
7b0115c5cb
40
AppUser.pm
40
AppUser.pm
@ -59,14 +59,10 @@ BEGIN {
|
||||
|
||||
## @cmethod AppUser new(%args)
|
||||
# Create a new AppUser object. This will create an AppUser object that may be
|
||||
# passed to the Auth class to provide application-specific user handling. The
|
||||
# following arguments must be provided:
|
||||
# passed to the Auth class to provide application-specific user handling.
|
||||
#
|
||||
# - cgi, a reference to a CGI object.
|
||||
# - dbh, a reference to the DBI object to issue database queries through.
|
||||
# - settings, a reference to the global settings object.
|
||||
# @param args A hash of arguments to initialise the UserApp object with.
|
||||
# @return A new AuthMethod object.
|
||||
# @return A new AppUser object.
|
||||
sub new {
|
||||
my $invocant = shift;
|
||||
my $class = ref($invocant) || $invocant;
|
||||
@ -74,15 +70,37 @@ sub new {
|
||||
@_,
|
||||
};
|
||||
|
||||
# Ensure that we have objects that we need
|
||||
return set_error("cgi object not set") unless($self -> {"cgi"});
|
||||
return set_error("dbh object not set") unless($self -> {"dbh"});
|
||||
return set_error("settings object not set") unless($self -> {"settings"});
|
||||
|
||||
return bless $self, $class;
|
||||
}
|
||||
|
||||
|
||||
## @method $ init($cgi, $dbh, $settings)
|
||||
# Initialise the AppUser's references to other system objects. This allows the
|
||||
# setup of the object to be deferred from construction. If the cgi, dbh, and
|
||||
# settings objects have been passed into new(), calling this function is not
|
||||
# required to use the object.
|
||||
#
|
||||
# @param cgi A reference to the system-wide cgi object.
|
||||
# @param dbh A reference to the system DBI object.
|
||||
# @param settings A reference to the global settings.
|
||||
# @return undef on success, otherwise an error message
|
||||
sub init {
|
||||
my $self = shift;
|
||||
|
||||
$self -> {"cgi"} = shift;
|
||||
$self -> {"dbh"} = shift;
|
||||
$self -> {"settings"} = shift;
|
||||
|
||||
# Check things are set.
|
||||
return "cgi object not set" unless($self -> {"cgi"});
|
||||
return "dbh object not set" unless($self -> {"dbh"});
|
||||
return "settings object not set" unless($self -> {"settings"});
|
||||
|
||||
# All good, return nothing...
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Constants access
|
||||
|
||||
|
37
Auth.pm
37
Auth.pm
@ -46,7 +46,7 @@ BEGIN {
|
||||
## @cmethod Auth new(%args)
|
||||
# Create a new Auth object. This will create an Auth object that may be (for example)
|
||||
# passed to SessionHandler to provide user authentication. The arguments to this
|
||||
# constructor must include:
|
||||
# constructor may include:
|
||||
#
|
||||
# - cgi, a reference to a CGI object.
|
||||
# - dbh, a reference to the DBI object to issue database queries through.
|
||||
@ -62,23 +62,46 @@ sub new {
|
||||
@_,
|
||||
};
|
||||
|
||||
return bless $self, $class;
|
||||
}
|
||||
|
||||
|
||||
## @method $ init($cgi, $dbh, $app, $settings)
|
||||
# Initialise the Auth's references to other system objects. This allows the
|
||||
# setup of the object to be deferred from construction. If the cgi, dbh, app,
|
||||
# and settings objects have been passed into new(), calling this function is
|
||||
# not required to use the object.
|
||||
#
|
||||
# @param cgi A reference to the system-wide cgi object.
|
||||
# @param dbh A reference to the system DBI object.
|
||||
# @param app A reference to an AppUser object.
|
||||
# @param settings A reference to the global settings.
|
||||
# @return undef on success, otherwise an error message
|
||||
sub init {
|
||||
my $self = shift;
|
||||
|
||||
$self -> {"cgi"} = shift;
|
||||
$self -> {"dbh"} = shift;
|
||||
$self -> {"app"} = shift;
|
||||
$self -> {"settings"} = shift;
|
||||
|
||||
# Ensure that we have objects that we need
|
||||
return set_error("cgi object not set") unless($self -> {"cgi"});
|
||||
return set_error("dbh object not set") unless($self -> {"dbh"});
|
||||
return set_error("settings object not set") unless($self -> {"settings"});
|
||||
return set_error("app object not set") unless($self -> {"app"});
|
||||
return "cgi object not set" unless($self -> {"cgi"});
|
||||
return "dbh object not set" unless($self -> {"dbh"});
|
||||
return "settings object not set" unless($self -> {"settings"});
|
||||
return "app object not set" unless($self -> {"app"});
|
||||
|
||||
# Create the authmethods object to handle invocation of individual methods
|
||||
$self -> {"methods"} = AuthMethods -> new(cgi => $self -> {"cgi"},
|
||||
dbh => $self -> {"dbh"},
|
||||
settings => $self -> {"settings"},
|
||||
app => $self -> {"app"})
|
||||
or return set_error("Unable to create AuthMethods object: ".$Auth::Methods -> errstr);
|
||||
or "Unable to create AuthMethods object: ".$Auth::Methods -> errstr;
|
||||
|
||||
$self -> {"ANONYMOUS"} = $self -> {"app"} -> anonymous_user();
|
||||
$self -> {"ADMINTYPE"} = $self -> {"app"} -> adminuser_type();
|
||||
|
||||
return bless $self, $class;
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
4
Utils.pm
4
Utils.pm
@ -30,6 +30,10 @@
|
||||
# @todo The documentation for the modules is still a work in progress: some
|
||||
# areas need to be fleshed out substantially, and the addition of
|
||||
# examples or test cases would be very helpful.
|
||||
#
|
||||
# @todo Each webapp using these modules has essentially the same index.cgi
|
||||
# with very little variation. Find some way to make an Application
|
||||
# class that the index can create that wraps all that commonality.
|
||||
|
||||
## @class
|
||||
# System-wide utility functions. The functions in this file may be useful at
|
||||
|
@ -42,7 +42,7 @@ use WWW::Mechanize; # Needed to register via phpBB's registration form
|
||||
use Utils qw(path_join);
|
||||
|
||||
# Globals...
|
||||
our ($ANONYMOUS $errstr %fmt_map);
|
||||
our ($ANONYMOUS, $errstr, %fmt_map);
|
||||
|
||||
BEGIN {
|
||||
$ANONYMOUS = 1; # ID of the anonymous user, should be 1 unless you Know What You're Doing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user