{'message_body'} =~ s/\n/\
\n/g;
+ }
+
+ #Build the action URLs
+ my $nextInvitation = $friends->getPreviousInvitation($invitation); #Messages sorted descending so next is actually previous
+ if( $nextInvitation->{inviteId} ) {
+ $var->{'hasNext' } = "true";
+ $var->{'next_message_url'} = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$nextInvitation->{inviteId});
+ }
+
+ my $prevInvitation = $friends->getNextInvitation($invitation); #Messages sorted descending so previous is actually next
+ if( $prevInvitation->{inviteId} ) {
+ $var->{'hasPrevious' } = "true";
+ $var->{'prev_message_url'} = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$prevInvitation->{inviteId});
+ }
+
+ $var->{'form_header' } = WebGUI::Form::formHeader($session,{
+ action => $self->getUrl("module=inbox;do=approveDenyInvitations;inviteId=".$inviteId)
+ });
+ $var->{'form_footer' } = WebGUI::Form::formFooter($session);
+
+ $var->{'form_accept' } = WebGUI::Form::submit($session,{
+ name =>"accept",
+ value =>$i18n->get("accept button label")
+ });
+
+ $var->{'form_deny' } = WebGUI::Form::submit($session,{
+ name =>"deny",
+ value =>$i18n->get("deny button label")
+ });
+
+ return $self->processTemplate($var,$self->getViewInvitationTemplateId);
+}
+
+#-------------------------------------------------------------------
+
=head2 www_viewMessage ( )
The page on which users view their messages
@@ -804,6 +1080,7 @@ sub www_viewMessage {
if($errorMsg) {
my $backUrl = $var->{'view_inbox_url'};
+ $var->{'isInvitation'} = "true";
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
}
@@ -812,7 +1089,7 @@ sub www_viewMessage {
$var->{'message_id' } = $messageId;
$var->{'message_subject' } = $message->get("subject");
$var->{'message_dateStamp' } = $message->get("dateStamp");
- $var->{'message_dateStemp_human'} = $session->datetime->epochToHuman($var->{'message_dateStamp'});
+ $var->{'message_dateStamp_human'} = $session->datetime->epochToHuman($var->{'message_dateStamp'});
$var->{'message_status' } = $message->getStatus;
$var->{'message_body' } = $message->get("message");
@@ -848,13 +1125,13 @@ sub www_viewMessage {
$var->{'reply_url'} = $self->getUrl("module=inbox;do=sendMessage;messageId=".$messageId);
}
- my $nextMessage = $inbox->getNextMessage($message);
+ my $nextMessage = $inbox->getPreviousMessage($message); #Message are displayed in descending order so next is actually previous
if( defined $nextMessage ) {
$var->{'hasNext' } = "true";
$var->{'next_message_url'} = $self->getUrl("module=inbox;do=viewMessage;messageId=".$nextMessage->getId);
}
- my $prevMessage = $inbox->getPreviousMessage($message);
+ my $prevMessage = $inbox->getNextMessage($message); #Messages are displayed in descending order so previous is actually next
if(defined $prevMessage) {
$var->{'hasPrevious' } = "true";
$var->{'prev_message_url'} = $self->getUrl("module=inbox;do=viewMessage;messageId=".$prevMessage->getId);
diff --git a/lib/WebGUI/Account/Profile.pm b/lib/WebGUI/Account/Profile.pm
index 6adbe4854..ba14b5670 100644
--- a/lib/WebGUI/Account/Profile.pm
+++ b/lib/WebGUI/Account/Profile.pm
@@ -32,7 +32,7 @@ These subroutines are available from this package:
=head2 appendCommonVars ( var )
- Appends common template variables that all inbox templates use
+ Appends common template variables that all profile templates use
=head3 var
@@ -47,11 +47,12 @@ sub appendCommonVars {
my $user = $session->user;
my $pageUrl = $session->url->page;
- $var->{'user_full_name' } = $user->getWholeName;
- $var->{'user_member_since' } = $user->dateCreated;
- $var->{'view_profile_url' } = $user->getProfileUrl($pageUrl);
- $var->{'edit_profile_url' } = $self->getUrl("module=profile;do=edit");
- $var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'}
+ $var->{'user_full_name' } = $user->getWholeName;
+ $var->{'user_member_since' } = $user->dateCreated;
+ $var->{'view_profile_url' } = $user->getProfileUrl($pageUrl);
+ $var->{'edit_profile_url' } = $self->getUrl("module=profile;do=edit");
+ $var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'};
+ $var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend');
}
#-------------------------------------------------------------------
@@ -104,6 +105,14 @@ sub editSettingsForm {
label => $i18n->get("profile view template label"),
hoverHelp => $i18n->get("profile view template hoverHelp")
);
+ $f->template(
+ name => "profileErrorTemplateId",
+ value => $self->getErrorTemplateId,
+ namespace => "Account/Profile/Error",
+ label => $i18n->get("profile error template label"),
+ hoverHelp => $i18n->get("profile error template hoverHelp")
+ );
+
return $f->printRowsOnly;
}
@@ -128,6 +137,7 @@ sub editSettingsFormSave {
$setting->set("profileDisplayLayoutTemplateId", $form->process("profileDisplayLayoutTemplateId","template"));
$setting->set("profileEditTemplateId", $form->process("profileEditTemplateId","template"));
$setting->set("profileViewTempalteId", $form->process("profileViewTemplateId","template"));
+ $setting->set("profileErrorTemplateId",$form->process("profileErrorTemplateId","template"));
}
@@ -194,6 +204,20 @@ sub getEditTemplateId {
return $self->session->setting->get("profileEditTemplateId") || "75CmQgpcCSkdsL-oawdn3Q";
}
+#-------------------------------------------------------------------
+
+=head2 getErrorTemplateId ( )
+
+This method returns the template ID used to display the error page.
+
+=cut
+
+sub getErrorTemplateId {
+ my $self = shift;
+ return $self->session->setting->get("profileErrorTemplateId") || "MBmWlA_YEA2I6D29OMGtRg";
+}
+
+
#-------------------------------------------------------------------
=head2 getLayoutTemplateId ( )
@@ -205,9 +229,9 @@ This method returns the template ID for the account layout.
sub getLayoutTemplateId {
my $self = shift;
my $session = $self->session;
- my $method = $session->form->get("do");
- my $uid = $session->form->get("uid");
-
+ my $method = $self->method;
+ my $uid = $self->uid;
+
return $self->getEditLayoutTemplateId if($method eq "edit" || $uid eq "");
return $session->setting->get("profileLayoutTemplateId") || $self->SUPER::getLayoutTemplateId;
}
@@ -240,114 +264,6 @@ sub getViewTemplateId {
#-------------------------------------------------------------------
-=head2 saveProfileFields ( session, user, profile )
-
-Saves profile data to a user's profile. Does not validate any of the data.
-
-=head3 session
-
-WebGUI session object
-
-=head3 user
-
-User object. Profile data will be placed in this user's profile.
-
-=head3 profile
-
-Hash ref of profile data to save.
-
-=cut
-
-sub saveProfileFields {
- my $class = shift;
- my $session = shift;
- my $u = shift;
- my $profile = shift;
-
- foreach my $fieldName (keys %{$profile}) {
- $u->profileField($fieldName,${$profile}{$fieldName});
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 validateProfileFields ( session, fields )
-
-Class method which validates profile data from the session form variables. Returns an data structure which contains the following
-
-{
- profile => Hash reference containing all of the profile fields and their values
- errors => Array reference of error messages to be displayed
- errorCategory => Category in which the first error was thrown
- warnings => Array reference of warnings to be displayed
- errorFields => Array reference of the fieldIds that threw an error
- warningFields => Array reference of the fieldIds that threw a warning
-}
-
-=head3 session
-
-WebGUI session object
-
-=head3 fields
-
-An array reference of profile fields to validate.
-
-=cut
-
-sub validateProfileFields {
- my $class = shift;
- my $session = shift;
- my $fields = shift;
-
- my $i18n = WebGUI::International->new($session, 'Account_Profile');
-
- my $data = {};
- my $errors = [];
- my $warnings = [];
- my $errorCat = undef;
- my $errorFields = [];
- my $warnFields = [];
-
- foreach my $field (@{$fields}) {
- my $fieldId = $field->getId;
- my $fieldLabel = $field->getLabel;
- my $fieldValue = $field->formProcess;
- my $isValid = $field->isValid($fieldValue);
-
- $data->{$fieldId} = (ref $fieldValue eq "ARRAY") ? $fieldValue->[0] : $fieldValue;
-
- if(!$isValid) {
- $errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
- push (@{$errors}, sprintf($i18n->get("required error"),$fieldLabel));
- push(@{$errorFields},$fieldId);
- }
- #The language field is special and must be always be valid or WebGUI will croak
- elsif($fieldId eq "language" && !(exists $i18n->getLanguages()->{$data->{$fieldId}})) {
- $errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
- $session->log->warn("language $fieldValue does not exist");
- push (@{$errors}, sprintf($i18n->get("language not installed error"),$data->{$fieldId}));
- push(@{$errorFields},$fieldId);
- }
- #Duplicate emails throw warnings
- elsif($fieldId eq "email" && $field->isDuplicate($fieldValue)) {
- $errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
- push (@{$warnings},$i18n->get("email already in use error"));
- push(@{$warnFields},$fieldId);
- }
- }
-
- return {
- profile => $data,
- errors => $errors,
- warnings => $warnings,
- errorCategory => $errorCat,
- errorFields => $errorFields,
- warningFields => $warnFields,
- };
-}
-
-#-------------------------------------------------------------------
-
=head2 www_edit ( )
The edit page for the user's profile.
@@ -369,6 +285,10 @@ sub www_edit {
my @errorFields = ();
@errorFields = (@{$errors->{errorFields}},@{$errors->{warningFields}}) if($hasErrors);
+ $var->{'profile_errors' } = [];
+ map{ push(@{$var->{'profile_errors'}},{ error_message => $_ }) } @{$errors->{errors}} if($hasErrors);
+ $var->{'hasErrors' } = scalar(@{$var->{'profile_errors'}}) > 0;
+
my @categories = ();
foreach my $category (@{WebGUI::ProfileCategory->getCategories($session)}) {
next unless $category->isEditable;
@@ -415,6 +335,7 @@ sub www_edit {
'profile_category_shortLabel' => $shortCategoryLabel,
'profile_category_index' => $categoryIndex,
'profile_fields_loop' => \@fields,
+ 'profile_errors' => $var->{'profile_errors'},
});
#This value will determine whether or not a valid category is active or not
$active ||= $isActive;
@@ -431,11 +352,8 @@ sub www_edit {
});
$var->{'profile_form_footer' } = WebGUI::Form::formFooter($session);
- $var->{'profile_errors' } = [];
- map{ push(@{$var->{'profile_errors'}},{ error_message => $_ }) } @{$errors->{errors}} if($hasErrors);
-
$self->appendCommonVars($var);
-
+
return $self->processTemplate($var,$self->getEditTemplateId);
}
@@ -453,7 +371,7 @@ sub www_editSave {
my $session = $self->session;
my $fields = WebGUI::ProfileField->getEditableFields($session);
- my $retHash = $self->validateProfileFields($session,$fields);
+ my $retHash = $session->user->validateProfileDataFromForm($fields);
push (@{$retHash->{errors}},@{$retHash->{warnings}});
unless(scalar(@{$retHash->{errors}})) {
@@ -476,9 +394,8 @@ The display page of the .
sub www_view {
my $self = shift;
my $session = $self->session;
- my $i18n = WebGUI::International->new($session, 'Account_Profile');
my $var = {};
- my $uid = $session->form->get("uid");
+ my $uid = $self->uid;
my $selected = $session->form->get("selected"); #Allow users to template tabs or other category dividers
my $active = 0; #Whether or not a category is selected
@@ -487,15 +404,23 @@ sub www_view {
#Ensure uid is passed in if they want to view a profile. This controls the tab state.
return $self->www_edit unless ($uid);
- my $user = WebGUI::User->new($session,$uid);
+ my $user = WebGUI::User->new($session,$uid);
+
+ $self->appendCommonVars($var);
+
+ #Overwrite these
+ $var->{'user_full_name' } = $user->getWholeName;
+ $var->{'user_member_since' } = $user->dateCreated;
#Check user privileges
- #return $session->style->userStyle($vars->{displayTitle}.'. '.$i18n->get(862)) if($u->profileField("publicProfile") < 1 && ($session->user->userId ne $session->form->process("uid") || $session->user->isAdmin));
- #return $session->privilege->insufficient() if(!$session->user->isRegistered);
-
- if($user->isVisitor) {
- $var->{'restricted' } = "true";
- $var->{'error_message'} = $i18n->get("visitor profile restricted");
+ unless ($user->profileIsViewable($session->user)) {
+ my $i18n = WebGUI::International->new($session,'Account_Profile');
+ return $self->showError(
+ $var,
+ $i18n->get("profile not public error"),
+ $var->{'back_url'},
+ $self->getErrorTemplateId
+ );
}
my @categories = ();
@@ -549,6 +474,8 @@ sub www_view {
#If not category is selected, set the first category as the active one
$categories[0]->{profile_category_isActive} = 1 unless($active);
+ my $privacySetting = $user->profileField("publicProfile") || "none";
+ $var->{'profile_privacy_'.$privacySetting } = "true";
$var->{'profile_category_loop' } = \@categories;
$var->{'profile_user_id' } = $user->userId;
@@ -556,12 +483,6 @@ sub www_view {
$var->{'acceptsPrivateMessages'} = $user->acceptsPrivateMessages($session->user->userId);
$var->{'acceptsFriendsRequests'} = $user->acceptsFriendsRequests($session->user);
- $self->appendCommonVars($var);
-
- #Overwrite these
- $var->{'user_full_name' } = $user->getWholeName;
- $var->{'user_member_since' } = $user->dateCreated;
-
return $self->processTemplate($var,$self->getViewTemplateId);
}
diff --git a/lib/WebGUI/Account/Shop.pm b/lib/WebGUI/Account/Shop.pm
new file mode 100644
index 000000000..1eb720fbe
--- /dev/null
+++ b/lib/WebGUI/Account/Shop.pm
@@ -0,0 +1,297 @@
+package WebGUI::Account::Shop;
+
+use strict;
+
+use WebGUI::Exception;
+use WebGUI::International;
+use WebGUI::Pluggable;
+use WebGUI::Utility;
+use base qw/WebGUI::Account/;
+
+=head1 NAME
+
+Package WebGUI::Account::Shop
+
+=head1 DESCRIPTION
+
+Shop Features built into the Account system
+
+=head1 SYNOPSIS
+
+use WebGUI::Account::Shop;
+
+=head1 METHODS
+
+These methods are available from this class:
+
+=cut
+
+#-------------------------------------------------------------------
+
+=head2 appendCommonVars ( var )
+
+ Appends common template variables that shop templates will use
+
+=head3 var
+
+ The hash reference to append template variables to
+
+=cut
+
+sub appendCommonVars {
+ my $self = shift;
+ my $var = shift;
+
+ $self->SUPER::appendCommonVars($var);
+
+ my $session = $self->session;
+ my $user = $session->user;
+ my $method = $session->form->get("do");
+
+ $var->{'manage_purchases_url' } = $self->getUrl("module=shop;do=managePurchases");
+ $var->{'managesPurchasesIsActive'} = WebGUI::Utility::isIn($method,("","managePurchases","view","viewTransaction"));
+}
+
+#-------------------------------------------------------------------
+
+=head2 canView ( )
+
+ Returns whether or not the user can view the the tab for this module
+
+=cut
+
+sub canView {
+ my $self = shift;
+ return ($self->uid eq "");
+}
+
+#-------------------------------------------------------------------
+
+=head2 editSettingsForm ( )
+
+ Creates form elements for user settings page custom to this account module
+
+=cut
+
+sub editSettingsForm {
+ my $self = shift;
+ my $session = $self->session;
+ my $i18n = WebGUI::International->new($session,'Account_Shop');
+ my $shopi18n = WebGUI::International->new($session,'Shop');
+ my $f = WebGUI::HTMLForm->new($session);
+
+ $f->template(
+ name => "shopStyleTemplateId",
+ value => $self->getStyleTemplateId,
+ namespace => "style",
+ label => $i18n->get("shop style template label"),
+ hoverHelp => $i18n->get("shop style template hoverHelp")
+ );
+ $f->template(
+ name => "shopLayoutTemplateId",
+ value => $self->getLayoutTemplateId,
+ namespace => "Account/Layout",
+ label => $i18n->get("shop layout template label"),
+ hoverHelp => $i18n->get("shop layout template hoverHelp")
+ );
+ $f->template(
+ name => "shopMyPurchasesTemplateId",
+ value => $self->session->setting->get("shopMyPurchasesTemplateId"),
+ namespace => "Shop/MyPurchases",
+ label => $shopi18n->get("my purchases template"),
+ hoverHelp => $shopi18n->get("my purchases template help")
+ );
+ $f->template(
+ name => "shopMyPurchasesDetailTemplateId",
+ value => $self->session->setting->get("shopMyPurchasesDetailTemplateId"),
+ namespace => "Shop/MyPurchasesDetail",
+ label => $shopi18n->get("my purchases detail template"),
+ hoverHelp => $shopi18n->get("my purchases detail template help")
+ );
+
+ return $f->printRowsOnly;
+}
+
+#-------------------------------------------------------------------
+
+=head2 editSettingsFormSave ( )
+
+ Creates form elements for the settings page custom to this account module
+
+=cut
+
+sub editSettingsFormSave {
+ my $self = shift;
+ my $session = $self->session;
+ my $setting = $session->setting;
+ my $form = $session->form;
+
+ $setting->set("shopStyleTemplateId", $form->process("shopStyleTemplateId","template"));
+ $setting->set("shopLayoutTemplateId", $form->process("shopLayoutTemplateId","template"));
+ $setting->set("shopMyPurchasesTemplateId", $form->process("shopMyPurchasesTemplateId","template"));
+ $setting->set("shopMyPurchasesDetailTemplateId", $form->process("shopMyPurchasesDetailTemplateId","template"));
+}
+
+#-------------------------------------------------------------------
+
+=head2 getLayoutTemplateId ( )
+
+This method returns the templateId for the layout of your new module.
+
+=cut
+
+sub getLayoutTemplateId {
+ my $self = shift;
+ return $self->session->setting->get("shopLayoutTemplateId") || "aUDsJ-vB9RgP-AYvPOy8FQ";
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 getStyleTemplateId ( )
+
+This method returns the template ID for the main style.
+
+=cut
+
+sub getStyleTemplateId {
+ my $self = shift;
+ return $self->session->setting->get("shopStyleTemplateId") || $self->SUPER::getStyleTemplateId;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_managePurchases ( )
+
+The main view page for editing the user's profile.
+
+=cut
+
+sub www_managePurchases {
+ my $self = shift;
+ my $session = $self->session;
+ my $url = $session->url;
+
+ my $var = {};
+
+ # build list
+ foreach my $id (@{WebGUI::Shop::Transaction->getTransactionIdsForUser($session)}) {
+ my $transaction = WebGUI::Shop::Transaction->new($session, $id);
+ push @{$var->{transactions}}, {
+ %{$transaction->get},
+ viewDetailUrl => $self->getUrl('op=account;module=shop;do=viewTransaction;transactionId='.$id),
+ amount => sprintf("%.2f", $transaction->get('amount')),
+ };
+ }
+
+ $self->appendCommonVars($var);
+
+ return $self->processTemplate($var,$session->setting->get("shopMyPurchasesTemplateId"));
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_view ( )
+
+The main view page for editing the user's profile.
+
+=cut
+
+sub www_view {
+ my $self = shift;
+
+ #Use the view class as the driver for now. This will likely grow
+ return $self->www_managePurchases();
+
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_viewTransaction ( )
+
+The main view page for editing the user's profile.
+
+=cut
+
+sub www_viewTransaction {
+ my $self = shift;
+ my $session = $self->session;
+
+ my $transactionId = $session->form->get('transactionId');
+ my $transaction = shift || WebGUI::Shop::Transaction->new($session,$transactionId);
+ my $notice = shift;
+
+ return $session->insufficient unless ($transaction->get('userId') eq $session->user->userId);
+
+ my $i18n = WebGUI::International->new($session, 'Shop');
+ my $i18n = WebGUI::International->new($session, 'Shop');
+ my ($style, $url) = $session->quick(qw(style url));
+
+ my %var = (
+ %{$transaction->get},
+ notice => $notice,
+ cancelRecurringUrl => $url->page('shop=transaction;method=cancelRecurring;transactionId='.$transaction->getId),
+ amount => sprintf("%.2f", $transaction->get('amount')),
+ inShopCreditDeduction => sprintf("%.2f", $transaction->get('inShopCreditDeduction')),
+ taxes => sprintf("%.2f", $transaction->get('taxes')),
+ shippingPrice => sprintf("%.2f", $transaction->get('shippingPrice')),
+ shippingAddress => $transaction->formatAddress({
+ name => $transaction->get('shippingAddressName'),
+ address1 => $transaction->get('shippingAddress1'),
+ address2 => $transaction->get('shippingAddress2'),
+ address3 => $transaction->get('shippingAddress3'),
+ city => $transaction->get('shippingCity'),
+ state => $transaction->get('shippingState'),
+ code => $transaction->get('shippingCode'),
+ country => $transaction->get('shippingCountry'),
+ phoneNumber => $transaction->get('shippingPhoneNumber'),
+ }),
+ paymentAddress => $transaction->formatAddress({
+ name => $transaction->get('paymentAddressName'),
+ address1 => $transaction->get('paymentAddress1'),
+ address2 => $transaction->get('paymentAddress2'),
+ address3 => $transaction->get('paymentAddress3'),
+ city => $transaction->get('paymentCity'),
+ state => $transaction->get('paymentState'),
+ code => $transaction->get('paymentCode'),
+ country => $transaction->get('paymentCountry'),
+ phoneNumber => $transaction->get('paymentPhoneNumber'),
+ }),
+ );
+
+ # items
+ my @items = ();
+ foreach my $item (@{$transaction->getItems}) {
+ my $address = '';
+ if ($transaction->get('shippingAddressId') ne $item->get('shippingAddressId')) {
+ $address = $transaction->formatAddress({
+ name => $item->get('shippingAddressName'),
+ address1 => $item->get('shippingAddress1'),
+ address2 => $item->get('shippingAddress2'),
+ address3 => $item->get('shippingAddress3'),
+ city => $item->get('shippingCity'),
+ state => $item->get('shippingState'),
+ code => $item->get('shippingCode'),
+ country => $item->get('shippingCountry'),
+ phoneNumber => $item->get('shippingPhoneNumber'),
+ });
+ }
+ push @items, {
+ %{$item->get},
+ viewItemUrl => $url->page('shop=transaction;method=viewItem;transactionId='.$transaction->getId.';itemId='.$item->getId),
+ price => sprintf("%.2f", $item->get('price')),
+ itemShippingAddress => $address,
+ orderStatus => $i18n->get($item->get('orderStatus')),
+ };
+ }
+ $var{items} = \@items;
+
+ $self->appendCommonVars(\%var);
+
+ # render
+ return $self->processTemplate(\%var,$session->setting->get("shopMyPurchasesDetailTemplateId"));
+}
+
+
+
+1;
diff --git a/lib/WebGUI/Account/User.pm b/lib/WebGUI/Account/User.pm
index 46f3b4d42..37185c1bf 100644
--- a/lib/WebGUI/Account/User.pm
+++ b/lib/WebGUI/Account/User.pm
@@ -6,6 +6,8 @@ use WebGUI::Exception;
use WebGUI::International;
use WebGUI::Pluggable;
use WebGUI::Utility;
+use WebGUI::Operation::Auth;
+
use base qw/WebGUI::Account/;
=head1 NAME
@@ -26,6 +28,18 @@ These subroutines are available from this package:
=cut
+#-------------------------------------------------------------------
+
+=head2 canView ( )
+
+ Returns whether or not the user can view the inbox tab
+
+=cut
+
+sub canView {
+ my $self = shift;
+ return ($self->uid eq "");
+}
#-------------------------------------------------------------------
@@ -42,13 +56,24 @@ sub editSettingsForm {
my $i18n = WebGUI::International->new($session,'Account_User');
my $f = WebGUI::HTMLForm->new($session);
-# $f->template(
-# name => "profileStyleTemplateId",
-# value => $self->getStyleTemplateId,
-# namespace => "style",
-# label => $i18n->get("profile style template label"),
-# hoverHelp => $i18n->get("profile style template hoverHelp")
-# );
+ $f->template(
+ name => "userAccountStyleTemplateId",
+ value => $self->session->setting->get("userAccountStyleTemplateId"),
+ namespace => "style",
+ label => $i18n->get("user style template label"),
+ hoverHelp => $i18n->get("user style template hoverHelp")
+ );
+ $f->template(
+ name => "userAccountLayoutTemplateId",
+ value => $self->session->setting->get("userAccountLayoutTemplateId"),
+ namespace => "Account/Layout",
+ label => $i18n->get("layout template label"),
+ hoverHelp => $i18n->get("layout template hoverHelp")
+ );
+ $f->raw(q{
%s
%s!, - $i18n->get('add to friends'), - $i18n->get('does not want to be a friend'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $session->style->userStyle($output); - } - - my $output = join '', - sprintf("', - sprintf($i18n->get('add to friends description'), - $protoFriend->getWholeName), - '
', - WebGUI::Form::formHeader($session), - WebGUI::Form::hidden($session, - { - name => 'op', - value => 'addFriendSave', - } - ), - WebGUI::Form::hidden($session, - { - name => 'userId', - value => $friendId, - } - ), - WebGUI::Form::textarea($session, - { - name => 'comments', - value => sprintf($i18n->get('default friend comments'), $protoFriend->getFirstName, $session->user->getFirstName), - } - ), - WebGUI::Form::Submit($session, - { - value => $i18n->get('add') - } - ), - WebGUI::Form::Button($session, - { - value => $i18n->get('cancel', 'WebGUI'), - extras => q|onclick="history.go(-1);" class="backwardButton"|, - } - ), - WebGUI::Form::formFooter($session), - ; - return $session->style->userStyle($output); + my $uid = $session->form->process("userId"); + my $instance = WebGUI::Content::Account->createInstance($session,"friends"); + return $instance->displayContent($instance->callMethod("sendFriendsRequest",[],$uid)); } -#------------------------------------------------------------------- - -=head2 www_addFriendSave ( ) - -Post process the form, check for required fields, handle inviting users who are already -members (determined by email address) and send the email. - -=cut - -sub www_addFriendSave { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $friendId = $session->form->get('userId'); - my $protoFriend = WebGUI::User->new($session, $friendId); - my $i18n = WebGUI::International->new($session, 'Friends'); - - my $friends = WebGUI::Friends->new($session); - if($friends->isFriend($friendId) || $friends->isInvited($friendId)) { - return www_addFriend($session); - } - - # Check for non-existant user id. - if ((!$protoFriend->username) || (!$protoFriend->profileField('ableToBeFriend'))) { - my $output = sprintf qq!%s
%s!, - $i18n->get('add to friends'), - $i18n->get('does not want to be a friend'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $session->style->userStyle($output); - } - - my $friends = WebGUI::Friends->new($session); - $friends->sendAddRequest($friendId, $session->form->get('comments')); - - # display result - my $output = sprintf( - q!%s
!, - $i18n->get('add to friends'), - sprintf($i18n->get('add to friends confirmation'), $protoFriend->getWholeName), - $session->url->append($session->url->getRequestedUrl, 'op=viewProfile;uid='.$friendId), - sprintf($i18n->get('add to friends profile'), $protoFriend->getFirstName), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'), - ); - return $session->style->userStyle($output); -} #------------------------------------------------------------------- =head2 www_friendRequest ( ) -Form for the friend to accept or deny the request. +DEPRECATED - See WebGUI::Account::Inbox::viewInvitation =cut sub www_friendRequest { my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $i18n = WebGUI::International->new($session, 'Friends'); - - my $inviteId = $session->form->get('inviteId'); - my $friends = WebGUI::Friends->new($session); - - my $invitation = $friends->getAddRequest($inviteId); - - ##Invalid invite ID - unless (exists $invitation->{friendId}) { ##No userId corresponds to the inviteId - my $output = sprintf qq!%s
%s!, - $i18n->get('invalid invite code'), - $i18n->get('invalid invite code message'), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); - } - - ##Already a friend (check friendId already in the group) - if ($friends->isFriend($invitation->{inviterId})) { - my $output = sprintf qq!%s
%s!, - $i18n->get('invalid invite code'), - $i18n->get('already a friend'), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); - } - - ##Someone else's invite (check friendId vs current userId). - if ($session->user->userId ne $invitation->{friendId}) { ##This isn't your invitation, dude. - my $output = sprintf qq!%s
%s!, - $i18n->get('invalid invite code'), - $i18n->get('not the right user'), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); - } - - ##Everything looks good. Make the form! - my $inviter = WebGUI::User->new($session, $invitation->{inviterId}); - my $output = join '', - sprintf("', - sprintf($i18n->get('friend request description'), - $inviter->getWholeName), - '
', - WebGUI::Form::formHeader($session), - WebGUI::Form::hidden($session, - { - name => 'op', - value => 'friendRequestSave', - } - ), - WebGUI::Form::hidden($session, - { - name => 'inviteId', - value => $inviteId, - } - ), - WebGUI::Form::textarea($session, - { - name => 'comments', - value => $invitation->{comments}, - extras => 'disabled=disabled', - } - ), - WebGUI::Form::Submit($session, ##Approve - { - name => 'doWhat', - value => $i18n->get('572', 'WebGUI'), - } - ), - WebGUI::Form::Submit($session, ##Deny - { - name => 'doWhat', - value => $i18n->get('574', 'WebGUI'), - } - ), - WebGUI::Form::formFooter($session), - ; - return $session->style->userStyle($output); -} - -#------------------------------------------------------------------- - -=head2 www_friendRequestSave ( ) - -Handle form data from the friend's response to the invitation - -=cut - -sub www_friendRequestSave { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $i18n = WebGUI::International->new($session, 'Friends'); - my $doWhat = $session->form->get('doWhat'); - my $inviteId = $session->form->get('inviteId'); - my $friends = WebGUI::Friends->new($session); - my $invite = $friends->getAddRequest($inviteId); - my $inviter = WebGUI::User->new($session, $invite->{inviterId}); - ##Invalid invite ID - if (!$invite->{inviterId}) { ##No userId corresponds to the inviteId - my $output = sprintf qq!%s
%s!, - $i18n->get('invalid invite code'), - $i18n->get('invalid invite code message'), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); - } - - ##If deny, change the status of the request to denied. - if ($doWhat ne $i18n->get('572', 'WebGUI')) { ##request denied - $friends->rejectAddRequest($inviteId); - ##Return screen that says they denied the request. - my $output = sprintf qq!%s
%s!, - $i18n->get('friend request'), - sprintf($i18n->get('you have not been added'), $inviter->getWholeName), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); - } - - ##If accepted, - # set the status to accepted. - $friends->approveAddRequest($inviteId); - - # Return screen that says they accepted the request. - my $output = sprintf qq!%s
%s!, - $i18n->get('friend request'), - sprintf($i18n->get('you have been added'), $inviter->getWholeName), - $session->url->page("op=viewInbox"), - $i18n->get('354', 'WebGUI'); - return $session->style->userStyle($output); + my $instance = WebGUI::Content::Account->createInstance($session,"inbox"); + return $instance->displayContent($instance->callMethod("viewInvitation")); } #------------------------------------------------------------------- =head2 www_manageFriends ( ) -Display the list of friends and allow the user to remove friends or -send private messages to a subset of them. + +DEPRECATED - See WebGUI::Account::Friends::view =cut sub www_manageFriends { my $session = shift; - my ($user, $url, $style) = $session->quick(qw(user url style)); - return $session->privilege->insufficient() unless ($user->isRegistered); - my $i18n = WebGUI::International->new($session, 'Friends'); - - ##You have no friends! - my $friends = $user->friends->getUsers; - unless (scalar(@{$friends})) { - my $output = sprintf qq!%s
%s!, - $i18n->get('my friends'), - $i18n->get('no friends'), - $url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $style->userStyle($output); - } - - # show the friend manager - my %var = ( - "account.options" => WebGUI::Operation::Shared::accountOptions($session), - formHeader => WebGUI::Form::formHeader($session) - . WebGUI::Form::hidden($session, { name => 'op', value => 'sendMessageToFriends', }), - removeFriendButton => WebGUI::Form::button($session, { value => $i18n->get('remove'), extras => q|onclick="confirmRemovalOfFriends(form);"|, }), - subjectForm => WebGUI::Form::text($session, { name=>"subject" }), - sendMessageButton => WebGUI::Form::Submit($session, { value => $i18n->get('send message'), }), - messageForm => WebGUI::Form::textarea($session, { name=>"message" }), - formFooter => WebGUI::Form::formFooter($session), - ); - foreach my $userId (@{ $friends}) { - my $friend = WebGUI::User->new($session, $userId); - push(@{$var{friends}}, { - name => $friend->getWholeName, - profileUrl => $url->append($url->getRequestedUrl, 'op=viewProfile;uid='.$userId), - status => ($friend->isOnline ? $i18n->get('online') : $i18n->get('offline')), - checkboxForm => WebGUI::Form::checkbox($session, { name => 'userId', value => $userId, }), - }); - } - my $template = WebGUI::Asset->new( - $session, - $session->setting->get("manageFriendsTemplateId"), - "WebGUI::Asset::Template", - ); - return $style->userStyle($template->process(\%var)); -} - - -#------------------------------------------------------------------- - -=head2 www_removeFriends () - -Removes friends from the current user's friends list. - -=cut - -sub www_removeFriends { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - my @users = $session->form->param("userId"); - WebGUI::Friends->new($session)->delete(\@users); - return www_manageFriends($session); -} - - -#------------------------------------------------------------------- - -=head2 www_sendMessageToFriends () - -Sends a message to selected friends. - -=cut - -sub www_sendMessageToFriends { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - my @users = $session->form->param("userId"); - my $friends = WebGUI::Friends->new($session); - $friends->sendMessage($session->form->process("subject", "text"), $session->form->process("message","textarea"), \@users); - return www_manageFriends($session); + my $instance = WebGUI::Content::Account->createInstance($session,"friends"); + return $instance->displayContent($instance->callMethod("view")); } 1; diff --git a/lib/WebGUI/Operation/Inbox.pm b/lib/WebGUI/Operation/Inbox.pm index 89bbe5a9f..b0753035f 100644 --- a/lib/WebGUI/Operation/Inbox.pm +++ b/lib/WebGUI/Operation/Inbox.pm @@ -79,18 +79,23 @@ sub _appendPrivateMessageForm { name=>"message", value=>$form->get("message") || "", }); - - my $messageId = $form->get("messageId") || $message->getId; + + my $messageId = ""; + if($form->get("messageId")) { + $messageId = $form->get("messageId"); + } + elsif(defined $message) { + $messageId = $message->getId; + } + $vars->{'form_header' } = WebGUI::Form::formHeader($session,{ - action => $session->url->page->("op=account;module=inbox;do=sendMessageSave;messageId=$messageId;userId=$userTo->userId"), + action => $session->url->page("op=account;module=inbox;do=sendMessageSave;messageId=$messageId;userId=".$userTo->userId), extras => q{name="messageForm"} }); $vars->{ submit_button } = WebGUI::Form::submit($session,{}); $vars->{ submit_label } = $i18n->get("private message submit label"); $vars->{ form_footer } = WebGUI::Form::formFooter($session, {}); - - } #------------------------------------------------------------------- @@ -99,263 +104,42 @@ sub _appendPrivateMessageForm { returns a hashref with internationalized values for message status. -DEPRECATED: Use WebGUI::Inbox::Message->statusCodes +DEPRECATED: Do not use this method in new code. Use WebGUI::Inbox::Message->statusCodes =cut sub _status { my $session = shift; return WebGUI::Inbox::Message->statusCodes($session); - #my $i18n = WebGUI::International->new($session); - #return { - # "pending" =>$i18n->get(552), - # "completed" =>$i18n->get(350), - # "unread" =>$i18n->get("private message status unread"), - # "read" =>$i18n->get("private message status read"), - # "replied" =>$i18n->get("private message status replied"), - #}; } #------------------------------------------------------------------- =head2 www_sendPrivateMessage ( ) -DEPRECATED: Use WebGUI::Account::Inbox - -Form for sending private messages +DEPRECATED: See WebGUI::Account::Inbox::sendMessage =cut sub www_sendPrivateMessage { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $i18n = WebGUI::International->new($session); - my $form = $session->form; - my $user = $session->user; - my $style = $session->style; - my $settings = $session->setting; - - my $templateId = $settings->get("sendPrivateMessageTemplateId"); - my $uid = $form->get("uid"); - my $userTo = WebGUI::User->new($session,$uid); - - my $vars = {}; - $vars->{title} = $i18n->get('private message title'); - - if($uid eq "") { - $vars->{'error_msg'} = $i18n->get('private message no user'); - return $style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars)); - - } - elsif($uid eq $user->userId) { - $vars->{'error_msg'} = $i18n->get('private message no self error'); - return $style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars)); - } - - unless($userTo->acceptsPrivateMessages($user->userId)) { - $vars->{'error_msg'} = $i18n->get('private message blocked error'); - return $style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars)); - } - - _appendPrivateMessageForm($session,$vars,$userTo); - - $vars->{ accountOptions } = WebGUI::Operation::Shared::accountOptions($session); - - return $style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars)); + my $session = shift; + my $uid = $session->form->get("uid"); + my $instance = WebGUI::Content::Account->createInstance($session,"inbox"); + return $instance->displayContent($instance->callMethod("sendMessage",[],$uid)); } -#------------------------------------------------------------------- - -=head2 www_sendPrivateMessageSave ( ) - -DEPRECATED: Use WebGUI::Account::Inbox - -Post process the form, check for required fields, handle inviting users who are already -members (determined by email address) and send the email. - -=cut - -sub www_sendPrivateMessageSave { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $i18n = WebGUI::International->new($session); - my $form = $session->form; - my $user = $session->user; - my $style = $session->style; - - my $uid = $form->get("uid"); - my $userTo = WebGUI::User->new($session,$uid); - - if($uid eq "") { - my $output = sprintf qq|%s
%s|, - $i18n->get('private message error'), - $i18n->get('private message no user'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $style->userStyle($output); - } elsif($uid eq $user->userId) { - my $output = sprintf qq|%s
%s|, - $i18n->get('private message error'), - $i18n->get('private message no self error'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $style->userStyle($output); - } - - my $isReply = 0; - if($form->get("messageId")) { - my $message = WebGUI::Inbox->new($session)->getMessage($form->get("messageId")); - # Ensure that the user sending the message was sent by the user being replied to - # and that the user reponding is the user the message was sent to - if($message->get("sentBy") eq $uid && $message->get("userId") eq $user->userId) { - $isReply = 1; - $message->setStatus("replied"); - } - } - - my $message = WebGUI::Inbox->new($session)->addPrivateMessage({ - message => $form->get("message"), - subject => $form->get("subject"), - userId => $uid, - status => 'unread', - sentBy => $user->userId - },$isReply); - - unless(defined $message) { - my $output = sprintf qq|%s
%s|, - $i18n->get('private message error'), - $i18n->get('private message blocked error'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $style->userStyle($output); - } - - - my $output = sprintf qq!%s
%s!, - $i18n->get('private message sent'), - $session->url->getBackToSiteURL(), - $i18n->get('493', 'WebGUI'); - return $session->style->userStyle($output); - -} - - #------------------------------------------------------------------- =head2 www_viewInbox ( ) -DEPRECATED: Use WebGUI::Account::Inbox - -Templated display all messages for the current user. +DEPRECATED: See WebGUI::Account::Inbox::view =cut sub www_viewInbox { my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - my $i18n = WebGUI::International->new($session); - my $vars = {}; - my @msg = (); - my $rpp = 50; - - #Deal with page number - my $pn = $session->form->get("pn") || 1; - my $pn_url = ""; - $pn_url = ";pn=$pn"; - - #Deal with sort order - my $sortBy = $session->form->get("sortBy"); - my $sort_url = ""; - $sort_url = ";sortBy=$sortBy" if($sortBy); - - #Cache the base url - my $inboxUrl = $session->url->page('op=viewInbox'); - - $vars->{ title } = $i18n->get(159); - $vars->{'subject_label' } = $i18n->get(351); - $vars->{'subject_url' } = $inboxUrl.$pn_url.";sortBy=subject"; - - $vars->{'status_label' } = $i18n->get(553); - $vars->{'status_url' } = $inboxUrl.$pn_url.";sortBy=status"; - - $vars->{'from_label' } = $i18n->get("private message from label"); - $vars->{'from_url' } = $inboxUrl.$pn_url.";sortBy=sentBy"; - - $vars->{'dateStamp_label'} = $i18n->get(352); - $vars->{'dateStamp_url' } = $inboxUrl.$pn_url.";sortBy=dateStamp"; - - my $adminUser = WebGUI::User->new($session,3)->username; - my $messages = WebGUI::Inbox->new($session)->getMessagesForUser($session->user,$rpp,$pn,$sortBy); - foreach my $message (@$messages) { - next if($message->get('status') eq 'deleted'); - - my $hash = {}; - $hash->{ message_url } = $session->url->page('op=viewInboxMessage;messageId='.$message->getId); - $hash->{ subject } = $message->get("subject"); - $hash->{ status_class } = $message->get("status"); - $hash->{ status } = _status($session)->{$hash->{ status_class }}; - - #Get the username of the person who sent the message - my $sentBy = $message->get("sentBy"); - #Assume it's the admin user for speed purposes - admin user is cached above the loop - my $from = $adminUser; - #If it wasn't the admin user, get the username of the person who sent it - if($sentBy ne "3") { - my $u = WebGUI::User->new($session,$sentBy); - #If the user that sent the message is valid, get the username - #This case would happen if the user was deleted after sending a private message - if($u->isRegistered) { - $from = $u->username; - } - } - - $hash->{ from } = $from; - $hash->{ dateStamp } = $session->datetime->epochToHuman($message->get("dateStamp")); - push(@msg,$hash); - } - my $msgCount = scalar(@{$messages}); - - #Pagination has to exist on every page regardless if there are more messages or not. - if($pn > 1 ) { - $vars->{'prev_url' } = $inboxUrl.';pn='.($pn-1).$sort_url; - $vars->{'prev_label' } = $i18n->get("private message prev label"); - } - if (scalar(@msg) >= $rpp) { - $vars->{'next_url' } = $inboxUrl.';pn='.($pn+1).$sort_url; - $vars->{'next_label' } = $i18n->get("private message next label"); - } - - $vars->{'messages' } = \@msg; - $vars->{'noresults' } = $i18n->get(353) unless ($msgCount > 0); - $vars->{'accountOptions'} = WebGUI::Operation::Shared::accountOptions($session); - my $templateId = $session->setting->get("viewInboxTemplateId"); - return $session->style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars)); -} - -#------------------------------------------------------------------- - -=head2 www_deletePrivateMessage ( ) - -DEPRECATED: Use WebGUI::Account::Inbox - -Mark a private message in the inbox as deleted. - -=cut - -sub www_deletePrivateMessage { - my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - #Get the message - my $message = WebGUI::Inbox->new($session)->getMessage($session->form->param("messageId")); - if(defined $message) { - # set the message status to 'deleted' - $message->setStatus("deleted"); - } - return www_viewInbox($session); + my $instance = WebGUI::Content::Account->createInstance($session,"inbox"); + return $instance->displayContent($instance->callMethod("view")); } #------------------------------------------------------------------- @@ -370,68 +154,8 @@ Templated display of a single message for the user. sub www_viewInboxMessage { my $session = shift; - return $session->privilege->insufficient() unless ($session->user->isRegistered); - - #Get the message - my $message = WebGUI::Inbox->new($session)->getMessage($session->form->param("messageId")); - - #Make sure users can only read their own messages - my $userId = $message->get("userId"); - my $groupId = $message->get("groupId"); - return $session->privilege->insufficient() unless ( - $session->user->userId eq $userId - || (defined $groupId && $session->user->isInGroup($groupId)) - ); - - my $i18n = WebGUI::International->new($session); - my $vars = {}; - $vars->{ title } = $i18n->get("private message reply title"); - $vars->{ from_label } = $i18n->get("private message from label"); - $vars->{ date_label } = $i18n->get("private message date label"); - - - if (defined $message) { - my $origStatus = $message->get("status"); - $message->setStatus("read") if($origStatus eq "unread"); - $vars->{'message_subject' } = $message->get("subject"); - $vars->{'dateStamp'} =$session->datetime->epochToHuman($message->get("dateStamp")); - $vars->{'status' } = _status($session)->{$message->get("status")}; - $vars->{ message } = $message->get("message"); - $vars->{ delete_text } = $i18n->get("private message delete text"); - $vars->{ delete_url } = '?op=deletePrivateMessage;messageId=' . $message->getId; - unless ($vars->{message} =~ /\{message} =~ s/(http\S*)/\$1\<\/a\>/g; - } - unless ($vars->{message} =~ /\{message} =~ s/\n/\
\n/g;
- }
-
- #Get the username of the person who sent the message
- my $sentBy = $message->get("sentBy");
- #Assume it's the admin user who sent the message
- my $from = WebGUI::User->new($session,3)->username;
- #If the user actually exists, get the username
- if($sentBy ne "1" && $sentBy ne "3") {
- $from = WebGUI::User->new($session,$sentBy)->username;
- }
-
- $vars->{ from } = $from;
-
-
- #If the person didn't send the message to themselves (for admin only) and the user still exsists (check visitor case)
- if($sentBy ne $session->user->userId &&
- $sentBy ne "1" &&
- $origStatus ne "pending" &&
- $origStatus ne "completed") {
- my $u = WebGUI::User->new($session,$sentBy);
- $vars->{'canReply'} = "true";
- _appendPrivateMessageForm($session,$vars,$u,$message);
- }
-
- }
- $vars->{'accountOptions'} = WebGUI::Operation::Shared::accountOptions($session);
- my $templateId = $session->setting->get("viewInboxMessageTemplateId");
- return $session->style->userStyle(WebGUI::Asset::Template->new($session,$templateId)->process($vars));
+ my $instance = WebGUI::Content::Account->createInstance($session,"inbox");
+ return $instance->displayContent($instance->callMethod("viewMessage"));
}
1;
diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm
index 4abf01362..eae334075 100644
--- a/lib/WebGUI/Operation/Profile.pm
+++ b/lib/WebGUI/Operation/Profile.pm
@@ -24,6 +24,7 @@ use WebGUI::ProfileField;
use WebGUI::ProfileCategory;
use WebGUI::Operation::Shared;
use WebGUI::Operation::Friends;
+use WebGUI::Account::Profile;
=head1 NAME
@@ -92,12 +93,9 @@ email address to check for duplication
sub isDuplicateEmail {
my $session = shift;
my $email = shift;
- my ($otherEmail)
- = $session->db->quickArray(
- 'select count(*) from userProfileData where email = ? and userId <> ?',
- [$email, $session->user->userId]
- );
- return ($otherEmail > 0);
+
+ my $field = WebGUI::ProfileField->new($session,'email');
+ return $field->isDuplicate($email);
}
#-------------------------------------------------------------------
@@ -107,7 +105,7 @@ sub isDuplicateEmail {
Saves profile data to a user's profile. Does not validate any of the data.
DEPRECATED - This method is deprecated, and should not be used in new code. Use
-the saveProfileFields method from WebGUI::Account::Profile instead
+the updateProfileFields method in WebGUI::User
=head3 session
@@ -127,8 +125,7 @@ sub saveProfileFields {
my $session = shift;
my $u = shift;
my $profile = shift;
-
- WebGUI::Account::Profile->saveProfileFields($session,$u,$profile);
+ $u->updateProfileFields($profile);
}
#-------------------------------------------------------------------
@@ -139,7 +136,7 @@ Validates profile data from the session form variables. Returns processed data,
and errors.
DEPRECATED - This method is deprecated, and should not be used in new code. Use
-the validateProfileData method from WebGUI::Account::Profile instead
+the validateProfileDataFromForm method from WebGUI::User instead
There are two levels of validation:
@@ -159,48 +156,38 @@ warning if it is a duplicate.
=cut
sub validateProfileData {
- my $session = shift;
- my $opts = shift || {};
- my $regOnly = $opts->{regOnly};
- my %data = ();
- my $error = "";
- my $warning = "";
- my $i18n = WebGUI::International->new($session);
- my $fields = $regOnly ? WebGUI::ProfileField->getRegistrationFields($session)
+ my $session = shift;
+ my $opts = shift || {};
+ my $regOnly = $opts->{regOnly};
+
+ my $error = "";
+ my $warning = "";
+ my $fields = $regOnly ? WebGUI::ProfileField->getRegistrationFields($session)
: WebGUI::ProfileField->getEditableFields($session);
- foreach my $field (@$fields) {
- my $fieldValue = $field->formProcess;
- if (ref $fieldValue eq "ARRAY") {
- $data{$field->getId} = $$fieldValue[0];
- } else {
- $data{$field->getId} = $fieldValue;
- }
- if ($field->isRequired && $data{$field->getId} eq "") {
- $error .= '