fix User deprecations

This commit is contained in:
Doug Bell 2010-11-04 12:19:55 -05:00
parent 5e5e65c112
commit e128c041d9
2 changed files with 27 additions and 23 deletions

View file

@ -18,6 +18,14 @@ init() is deprecated. Use www_view()
isAdmin, isVisitor, isRegistered are all deprecated. use user->is* instead isAdmin, isVisitor, isRegistered are all deprecated. use user->is* instead
setCallable and isCallable are deprecated. use www_ prefix instead. setCallable and isCallable are deprecated. use www_ prefix instead.
WebGUI::User
==========================
updateProfileFields is deprecated. Use update
profileField is deprecated. Use get() and update()
authInstance is deprecated. Instead instantiate the auth method and give it a
user or userId
WebGUI::Macro::AdminBar WebGUI::Macro::AdminBar
========================== ==========================
There is no Admin Bar for normal pages. Only the admin mode can see the admin bar. There is no Admin Bar for normal pages. Only the admin mode can see the admin bar.

View file

@ -24,6 +24,7 @@ use WebGUI::Inbox;
use Scalar::Util qw( weaken ); use Scalar::Util qw( weaken );
use Net::CIDR::Lite; use Net::CIDR::Lite;
use WebGUI::Friends; use WebGUI::Friends;
use Carp qw( carp );
=head1 NAME =head1 NAME
@ -31,7 +32,8 @@ Package WebGUI::User
=head1 DESCRIPTION =head1 DESCRIPTION
This package provides an object-oriented way of managing WebGUI users as well as getting/setting a users's profile data. This package provides an object-oriented way of managing WebGUI users as well
as getting/setting a users's profile data.
=head1 SYNOPSIS =head1 SYNOPSIS
@ -206,6 +208,7 @@ Returns an instance of the authentication object for this user.
# DEPRECATED. Remove in 9.0 # DEPRECATED. Remove in 9.0
sub authInstance { sub authInstance {
carp "WebGUI::User::authInstance is deprecated. Instantiate the auth method directly instead.";
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
@ -229,8 +232,6 @@ sub authInstance {
=head2 authMethod ( [ value ] ) =head2 authMethod ( [ value ] )
DEPRECATED! Use get("authMethod") and update({ authMethod => "value })
Returns the authentication method for this user. Returns the authentication method for this user.
=head3 value =head3 value
@ -351,8 +352,6 @@ sub canViewField {
=head2 dateCreated ( ) =head2 dateCreated ( )
DEPRECATED! Use get("dateCreated") instead
Returns the epoch for when this user was created. Returns the epoch for when this user was created.
=cut =cut
@ -1041,8 +1040,6 @@ sub karma {
=head2 lastUpdated ( ) =head2 lastUpdated ( )
DEPRECATED! Use get("lastUpdated")
Returns the epoch for when this user was last modified. Returns the epoch for when this user was last modified.
=cut =cut
@ -1192,7 +1189,9 @@ The value to set the profile field name to.
=cut =cut
# DEPRECATED! Remove in 9.0
sub profileField { sub profileField {
carp "WebGUI::User::profileField is deprecated. Use get() and update() instead\n";
my $self = shift; my $self = shift;
my $fieldName = shift; my $fieldName = shift;
my $value = shift; my $value = shift;
@ -1239,8 +1238,6 @@ sub profileIsViewable {
=head2 referringAffiliate ( [ value ] ) =head2 referringAffiliate ( [ value ] )
DEPRECATED! Use get("referringAffiliate") and update({ referringAffiliate => "value" })
Returns the unique identifier of the affiliate that referred this user to the site. Returns the unique identifier of the affiliate that referred this user to the site.
=head3 value =head3 value
@ -1313,8 +1310,6 @@ sub setProfileFieldPrivacySetting {
=head2 status ( [ value ] ) =head2 status ( [ value ] )
DEPRECATED! Use get("status") and enable() and disable() instead
Returns the status of the user. Returns the status of the user.
=head3 value =head3 value
@ -1360,8 +1355,8 @@ sub uncache {
=head2 update ( properties ) =head2 update ( properties )
Update properties for the user. C<properties> is a hash reference of user properties Update properties for the user. C<properties> is a hash reference or a list of
and/or profile fields. name => value pairs of user properties and/or profile fields.
Valid user properties: Valid user properties:
@ -1379,10 +1374,19 @@ Anything else is a profile field.
=cut =cut
sub update { sub update {
my ( $self, $properties ) = @_; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $db = $session->db; my $db = $session->db;
# Allow name => value and hashref
my $properties = {};
if ( @_ == 1 ) {
$properties = shift;
}
else {
$properties = { @_ };
}
# Make a safe copy of properties, we'll be deleting from it # Make a safe copy of properties, we'll be deleting from it
$properties = { %$properties }; $properties = { %$properties };
$self->uncache; $self->uncache;
@ -1450,18 +1454,12 @@ Hash ref of key/value pairs of data in the users's profile to update.
=cut =cut
sub updateProfileFields { deprecate updateProfileFields => 'update';
my $self = shift;
my $profile = shift;
$self->update($profile);
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 username ( [ value ] ) =head2 username ( [ value ] )
DEPRECATED! Use get("username") and update({ username => "value" }) instead.
Returns the username. Returns the username.
=head3 value =head3 value
@ -1483,8 +1481,6 @@ sub username {
=head2 userId ( ) =head2 userId ( )
DEPRECATED: Use getId() instead!
Returns the userId for this user. Returns the userId for this user.
=cut =cut