From 11d18075fac0910ad1583f6ca5c623471ad1be1a Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Sat, 15 Nov 2008 02:39:23 +0000 Subject: [PATCH] Account release candidate - final changes before merge --- docs/upgrades/upgrade_7.6.1-7.6.2.pl | 59 +- lib/WebGUI/Account.pm | 266 +++++++- lib/WebGUI/Account/Friends.pm | 487 +++++++++++++- lib/WebGUI/Account/Inbox.pm | 331 +++++++++- lib/WebGUI/Account/Profile.pm | 195 ++---- lib/WebGUI/Account/Shop.pm | 297 +++++++++ lib/WebGUI/Account/User.pm | 67 +- lib/WebGUI/Account/_NewModule.skeleton | 145 +++++ lib/WebGUI/Asset/Post.pm | 4 +- lib/WebGUI/Asset/Shortcut.pm | 2 +- lib/WebGUI/Auth.pm | 30 +- lib/WebGUI/Auth/LDAP.pm | 47 +- lib/WebGUI/Auth/WebGUI.pm | 13 +- lib/WebGUI/Content/Account.pm | 161 ++--- lib/WebGUI/Form/File.pm | 8 - lib/WebGUI/Friends.pm | 74 ++- lib/WebGUI/Inbox.pm | 22 +- lib/WebGUI/Inbox/Message.pm | 12 +- lib/WebGUI/Macro/FileUrl.pm | 13 +- lib/WebGUI/Macro/NewMail.pm | 2 +- lib/WebGUI/Macro/User.pm | 27 +- lib/WebGUI/Operation.pm | 7 - lib/WebGUI/Operation/Friends.pm | 346 +--------- lib/WebGUI/Operation/Inbox.pm | 318 +-------- lib/WebGUI/Operation/Profile.pm | 204 ++---- lib/WebGUI/Operation/Settings.pm | 74 +-- lib/WebGUI/Operation/Shared.pm | 65 +- lib/WebGUI/ProfileField.pm | 14 +- lib/WebGUI/Shop/Transaction.pm | 9 +- lib/WebGUI/Storage.pm | 5 +- lib/WebGUI/User.pm | 140 +++- lib/WebGUI/i18n/English/Account_Friends.pm | 238 +++++++ lib/WebGUI/i18n/English/Account_Inbox.pm | 84 ++- lib/WebGUI/i18n/English/Account_Profile.pm | 71 +- lib/WebGUI/i18n/English/Account_Shop.pm | 40 ++ lib/WebGUI/i18n/English/Account_User.pm | 27 +- lib/WebGUI/i18n/English/WebGUI.pm | 12 +- www/extras/account/account.css | 724 +++++++++++++++++++++ www/extras/account/images/new.png | Bin 0 -> 452 bytes www/extras/account/images/next.gif | Bin 0 -> 857 bytes www/extras/account/images/no_photo.gif | Bin 0 -> 390 bytes www/extras/account/images/old.png | Bin 0 -> 536 bytes www/extras/account/images/prev.gif | Bin 0 -> 170 bytes www/extras/account/images/save_changes.gif | Bin 0 -> 1589 bytes www/extras/account/inbox.js | 64 ++ 45 files changed, 3379 insertions(+), 1325 deletions(-) create mode 100644 lib/WebGUI/Account/Shop.pm create mode 100644 lib/WebGUI/Account/_NewModule.skeleton create mode 100644 lib/WebGUI/i18n/English/Account_Shop.pm create mode 100644 www/extras/account/account.css create mode 100644 www/extras/account/images/new.png create mode 100644 www/extras/account/images/next.gif create mode 100644 www/extras/account/images/no_photo.gif create mode 100644 www/extras/account/images/old.png create mode 100644 www/extras/account/images/prev.gif create mode 100644 www/extras/account/images/save_changes.gif create mode 100644 www/extras/account/inbox.js diff --git a/docs/upgrades/upgrade_7.6.1-7.6.2.pl b/docs/upgrades/upgrade_7.6.1-7.6.2.pl index 7cae6ebd9..6f564de79 100644 --- a/docs/upgrades/upgrade_7.6.1-7.6.2.pl +++ b/docs/upgrades/upgrade_7.6.1-7.6.2.pl @@ -80,6 +80,11 @@ sub upgradeAccount { title => "^International(title,Account_Friends);", className => "WebGUI::Account::Friends" }, + { + identifier => "shop", + title => "^International(title,Account_Shop);", + className => "WebGUI::Account::Shop" + }, { identifier => "user", title => "^International(title,Account_User);", @@ -100,23 +105,44 @@ sub upgradeAccount { $session->config->set( "contentHandlers", \@newHandlers ); } - #Add the settings for the profile + #Add the settings for the profile module $setting->add("profileStyleTemplateId",""); #Use the userStyle by default $setting->add("profileLayoutTemplateId","N716tpSna0iIQTKxS4gTWA"); $setting->add("profileEditLayoutTemplateId","FJbUTvZ2nUTn65LpW6gjsA"); $setting->add("profileEditTemplateId","75CmQgpcCSkdsL-oawdn3Q"); $setting->add("profileViewTempalteId","2CS-BErrjMmESOtGT90qOg"); + $setting->add("profileErrorTempalteId","MBmWlA_YEA2I6D29OMGtRg"); - #Add the settings for the inbox + #Add the settings for the inbox module $setting->add("inboxStyleTemplateId",""); #Use the userStyle by default $setting->add("inboxLayoutTempalteId","N716tpSna0iIQTKxS4gTWA"); $setting->add("inboxViewTemplateId","c8xrwVuu5QE0XtF9DiVzLw"); $setting->add("inboxViewMessageTemplateId","0n4HtbXaWa_XJHkFjetnLQ"); $setting->add("inboxSendMessageTemplateId","6uQEULvXFgCYlRWnYzZsuA"); $setting->add("inboxErrorTemplateId","ErEzulFiEKDkaCDVmxUavw"); - $setting->add("inboxInvitationErrorTemplateId","5A8Hd9zXvByTDy4x-H28qw"); $setting->add("inboxMessageConfirmationTemplateId","DUoxlTBXhVS-Zl3CFDpt9g"); + #Invitations $setting->add("inboxManageInvitationsTemplateId","1Q4Je3hKCJzeo0ZBB5YB8g"); + $setting->add("inboxViewInvitationTemplateId","VBkY05f-E3WJS50WpdKd1Q"); + $setting->add("inboxInvitationConfirmTemplateId","5A8Hd9zXvByTDy4x-H28qw"); + + #Add the settings for the friends module + $setting->add("friendsStyleTemplateId",""); #Use the userStyle by default + $setting->add("friendsLayoutTempalteId","N716tpSna0iIQTKxS4gTWA"); + $setting->add("friendsViewTemplateId","1Yn_zE_dSiNuaBGNLPbxtw"); + $setting->add("friendsEditTemplateId","AZFU33p0jpPJ-E6qLSWZng"); + $setting->add("friendsSendRequestTemplateId","AGJBGviWGAwjnwziiPjvDg"); + $setting->add("friendsErrorTemplateId","7Ijdd8SW32lVgg2H8R-Aqw"); + $setting->add("friendsConfirmTemplateId","K8F0j_cq_jgo8dvWY_26Ag"); + $setting->add("friendsRemoveConfirmTemplateId","G5V6neXIDiFXN05oL-U3AQ"); + + #Add the settings for the user module + $setting->add("userAccountStyleTemplateId",""); #Use the userStyle by default + $setting->add("userAccountLayoutTemplateId","9ThW278DWLV0-Svf68ljFQ"); + + #Add the settings for the shop module + $setting->add("shopStyleTemplateId",""); #Use the userStyle by default + $setting->add("shopLayoutTemplateId","aUDsJ-vB9RgP-AYvPOy8FQ"); #Add inbox changes $session->db->write(q{ @@ -179,6 +205,33 @@ sub upgradeAccount { $session->db->write(q{update userProfileCategory set shortLabel='WebGUI::International::get("work info short","WebGUI");' where profileCategoryId='6'}); $session->db->write(q{update userProfileCategory set shortLabel='WebGUI::International::get("demographic info short","WebGUI");' where profileCategoryId='7'}); + $session->db->write(q{alter table userProfileData modify publicProfile char(10) default 'none'}); + $session->db->write(q{update userProfileData set publicProfile='none' where publicProfile='0' || publicProfile is NULL || publicProfile=''}); + $session->db->write(q{update userProfileData set publicProfile='all' where publicProfile='1'}); + $session->db->write(q{REPLACE INTO `userProfileField` VALUES ('publicProfile','WebGUI::International::get(861)',1,0,'RadioList','{ all=>WebGUI::International::get(\'public label\',\'Account_Profile\'), friends=>WebGUI::International::get(\'friends only label\',\'Account_Profile\'), none=>WebGUI::International::get(\'private label\',\'Account_Profile\')}','[\"none\"]',8,'4',1,1,0,0,0,'')}) + + + #Clean up old templates and settings + my $oldtemplates = { + editUserProfileTemplate => 'Operation/Profile/Edit', + viewUserProfileTemplate => 'Operation/Profile/View', + manageFriendsTemplateId => 'friends/manage', + sendPrivateMessageTemplateId => 'Inbox/SendPrivateMessage', + viewInboxTemplateId => 'Inbox', + viewInboxMessageTemplateId => 'Inbox/Message', + }; + + foreach my $setting (keys %{$oldtemplates}) { + #Remove the setting + $session->db->write("delete from settings where name=?",[$setting]); + #Remove all the templates with the related namespace + my $assets = $session->db->buildArrayRef("select distinct assetId from template where namespace=?",[$oldtemplates->{$setting}]); + #Purge the template + foreach my $assetId (@{$assets}) { + WebGUI::Asset->newByDynamicClass($session,$assetId)->purge; + } + } + print "DONE!\n" unless $quiet; } diff --git a/lib/WebGUI/Account.pm b/lib/WebGUI/Account.pm index 82cc50d6a..3f1901ff6 100644 --- a/lib/WebGUI/Account.pm +++ b/lib/WebGUI/Account.pm @@ -4,6 +4,7 @@ use strict; use Class::InsideOut qw{ :std }; use WebGUI::Exception; +use Carp qw(croak); use WebGUI::International; use WebGUI::Pluggable; use WebGUI::Utility; @@ -29,7 +30,254 @@ These subroutines are available from this package: =cut readonly session => my %session; -public store => my %store; #This is an all purpose hash to store stuff in: $store{id $self}->{something} = "something" +readonly module => my %module; +public method => my %method; +public uid => my %uid; +public store => my %store; #This is an all purpose hash to store stuff in: $store{id $self}->{something} = "something" + +#------------------------------------------------------------------- + +=head2 appendAccountLinks ( session , var) + + Class method which appends common links to preform various account tasks + +=head3 session + + WebGUI::Session object + +=head3 var + + hash ref to append template variables to + +=cut + +sub appendAccountLinks { + my $class = shift; + my $session = shift; + my $var = shift; + + return unless $var; + + my $i18n = WebGUI::International->new($session); + my $format = q{%s}; + my @array = (); + + #Turn Admin On + if ($session->user->isInGroup(12)) { + if ($session->var->isAdminOn) { + $var->{'admin_mode_url' } = $session->url->page('op=switchOffAdmin'); + $var->{'admin_mode_text'} = $i18n->get(12); + } + else { + $var->{'admin_mode_url' } = $session->url->page('op=switchOnAdmin'); + $var->{'admin_mode_text'} = $i18n->get(63); + } + push(@array,{ + 'options.display' => sprintf($format,$var->{'admin_mode_url'},$var->{'admin_mode_text'}) + }); + } + + #Pluggin - delete eventually + push(@array, {'options.display' => ''.$i18n->get('my purchases', 'Shop').''}); + + #Pluggin - delete eventually + if ($session->setting->get('userInvitationsEnabled')) { + push @array, { + 'options.display' => sprintf('%s', $session->url->page('op=inviteUser'), $i18n->get('invite a friend')), + }; + } + + #Logout + $var->{'logout_url' } = $session->url->page('op=auth;method=logout'); + $var->{'logout_text'} = $i18n->get(64); + push(@array,{ + 'options.display' => sprintf($format,$var->{'logout_url'},$var->{'logout_text'}) + }); + + #Deactivate Account + if ($session->setting->get("selfDeactivation") && !$session->user->isAdmin){ + $var->{'self_deactivation_url' } = $session->url->page('op=auth;method=deactivateAccount'); + $var->{'self_deactivation_text'} = $i18n->get(65); + push(@array,{ + 'options.display' => sprintf($format,$var->{'self_deactivation_url' },$var->{'self_deactivation_text'}) + }); + } + + #Return to site + $var->{'return_to_site_url' } = $session->url->getBackToSiteURL; + $var->{'return_to_site_link'} = $i18n->get(493); + push(@array,{ + 'options.display' => sprintf($format,$var->{'return_to_site_url'},$var->{'return_to_site_link'}) + }); + + $var->{'account.options'} = \@array; +} + + +#------------------------------------------------------------------- + +=head2 appendCommonVars ( var ) + + Appends common template variables that all most templates will use + +=head3 var + + The hash reference to append template variables to + +=cut + +sub appendCommonVars { + my $self = shift; + my $var = shift; + my $session = $self->session; + my $user = $session->user; + + $var->{'user_full_name' } = $user->getWholeName; + $var->{'user_member_since' } = $user->dateCreated; + $var->{'view_profile_url' } = $user->getProfileUrl; + $var->{'gateway_url' } = $session->url->page("op=account"); + $var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'} +} + + +#------------------------------------------------------------------- + +=head2 callMethod ( [ method, args, uid ] ) + +Calls the method passed in + +=method + +Method to call. If no method is passed in, the view method is called + +=args + +array reference of arguments to pass to the method being called. + +=uid + +uid to set in the object. + +=cut + +sub callMethod { + my $self = shift; + my $method = shift || "view"; + my $args = shift; + my $uid = shift; + + my $module = $self->module; + + $method = "www_".$method; + + unless ($self->can($method)) { + WebGUI::Error::MethodNotFound->throw( + error => qq{Could not locate method $method in the $module module of the account system}, + method => $method + ); + return undef; + } + + #Set the method in the object + $self->method($method); + #Set the uid in the object + $self->uid($uid); + + #Try to call the method + my $output = eval { $self->$method(@{$args}) }; + + #Croak on error + if($@) { + croak "Unable to run $method on $module: $@"; + return undef; + } + + #Return the output from the method call + return $output; +} + +#------------------------------------------------------------------- + +=head2 displayContent ( content[, withoutStyle] ) + +Wraps the content in the style and layout of the account pluggin + +=content + +Content to wrap in the pluggin style and layout + +=withoutStyle + +Return the layout without the style wrapper + +=cut + +sub displayContent { + my $self = shift; + my $content = shift; + my $noStyle = shift; + my $session = $self->session; + + #Wrap content into the layout + my $var = {}; + $var->{content} = $content; + + my $configs = $session->config->get("account"); + my $method = $self->method || "view"; + + # Get fieldsets for avaiable account methods in the order they exist in the config file and append them to the template + my @pluggins = (); + foreach my $account (@{$configs}) { + #Instantiate the pluggin + my $instance = undef; + my $identifier = $account->{identifier}; + #Use the currently instantiated pluggin if we are checking this pluggin + if($account->{identifier} eq $self->module) { + $instance = $self; + } + else { + #Eval it as we don't want to fail if there's a problem with another method in the config file + $instance = eval { WebGUI::Content::Account->createInstance($session,$identifier) }; + if (my $e = WebGUI::Error->caught) { + $session->log->warn("Couldn't instantiate Account Pluggin ".$account->{className}." ... skipping"); + next; + } + elsif(!$instance->isa('WebGUI::Account')) { + $session->log->warn((ref $instance)." is not a subclass of WebGUI::Account ... skipping"); + next; + } + #Set the current uid state in the instance + $instance->uid($self->uid); + } + + #Skip this module if the user can't view it + next unless ($instance->canView); + + #Push the tab variables onto the template + my %hash = %{$account}; + my $identifier = $account->{identifier}; + + $hash{'is_'.$identifier } = "true"; + $hash{'is_method_'.$self->method } = "true"; + $hash{'url' } = $instance->getUrl("module=$identifier",1); + $hash{'isActive' } = "true" if($identifier eq $self->module); + WebGUI::Macro::process(\$hash{'title'}); + push(@pluggins,\%hash); + + #Append common display variables to the main template + $instance->appendCommonVars($var); + } + $var->{'account_loop'} = \@pluggins; + + #Process the layout template + my $output = $self->processTemplate($var,$self->getLayoutTemplateId); + + return $output if($noStyle); + #Wrap the layout in the user style + $session->http->setCacheControl("none"); + return $session->style->process($output,$self->getStyleTemplateId); +} + #------------------------------------------------------------------- @@ -130,10 +378,10 @@ sub getUrl { } } else { - $pairs = q{op=account;module=}.$form->get("module").q{;do=}.$form->get("do"); + $pairs = q{op=account;module=}.$self->module.q{;do=}.$self->method; } - my $uid = $form->get("uid"); + my $uid = $self->uid; $pairs .= ";uid=".$uid if($appendUID && $uid); return $session->url->page($pairs); @@ -141,7 +389,7 @@ sub getUrl { #------------------------------------------------------------------- -=head2 new ( $session ) +=head2 new ( session, module [,method ,uid] ) Constructor. @@ -149,11 +397,16 @@ Constructor. A WebGUI::Session object. +=head3 module + +The module being called + =cut sub new { my $class = shift; my $session = shift; + my $module = shift; unless (ref $session eq 'WebGUI::Session') { WebGUI::Error::InvalidObject->throw( @@ -165,8 +418,13 @@ sub new { my $self = register $class; my $id = id $self; + $session { $id } = $session; + $module { $id } = $module; $store { $id } = {}; + $method { $id } = "view"; + $uid { $id } = undef; + return $self; } diff --git a/lib/WebGUI/Account/Friends.pm b/lib/WebGUI/Account/Friends.pm index 77e4fe034..68ecf8d89 100644 --- a/lib/WebGUI/Account/Friends.pm +++ b/lib/WebGUI/Account/Friends.pm @@ -26,6 +26,52 @@ These subroutines are available from this package: =cut +#------------------------------------------------------------------- + +=head2 appendCommonVars ( var ) + + Appends common template variables that all inbox templates use + +=head3 var + + The hash reference to append template variables to + +=cut + +sub appendCommonVars { + my $self = shift; + my $var = shift; + my $session = $self->session; + 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' } = $session->url->page("op=account"); + $var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'} +} + +#------------------------------------------------------------------- + +=head2 canView ( ) + + Whether or not the current user can view this user's friends + +=cut + +sub canView { + my $self = shift; + my $session = $self->session; + my $uid = $self->uid; + + return 1 if (($session->user->userId eq $uid || $uid eq "") && $session->user->profileField('ableToBeFriend')); + + my $user = WebGUI::User->new($session,$uid); + return 0 if($user->isVisitor); #This should never happen but let's make sure + return 0 unless ($user->profileField('ableToBeFriend')); #User doesn't have friends enabled + return WebGUI::User->new($session,$uid)->profileIsViewable($session->user); #User's profile isn't viewable by this user +} #------------------------------------------------------------------- @@ -38,17 +84,68 @@ These subroutines are available from this package: sub editSettingsForm { my $self = shift; my $session = $self->session; - my $setting = $session->setting; my $i18n = WebGUI::International->new($session,'Account_Friends'); 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 => "friendsStyleTemplateId", + value => $self->getStyleTemplateId, + namespace => "style", + label => $i18n->get("friends style template label"), + hoverHelp => $i18n->get("friends style template hoverHelp") + ); + $f->template( + name => "friendsLayoutTempalteId", + value => $self->getLayoutTemplateId, + namespace => "Account/Layout", + label => $i18n->get("friends layout template label"), + hoverHelp => $i18n->get("friends layout template hoverHelp") + ); + $f->template( + name => "friendsViewTemplateId", + value => $self->getViewTemplateId, + namespace => "Account/Friends/View", + label => $i18n->get("friends view template label"), + hoverHelp => $i18n->get("friends view template hoverHelp") + ); + $f->template( + name => "friendsEditTemplateId", + value => $self->getEditTemplateId, + namespace => "Account/Friends/Edit", + label => $i18n->get("friends edit template label"), + hoverHelp => $i18n->get("friends edit template hoverHelp") + ); + $f->template( + name => "friendsSendRequestTemplateId", + value => $self->getSendRequestTemplateId, + namespace => "Account/Friends/SendRequest", + label => $i18n->get("friends send request template label"), + hoverHelp => $i18n->get("friends send request template hoverHelp") + ); + + $f->template( + name => "friendsErrorTemplateId", + value => $self->getErrorTemplateId, + namespace => "Account/Friends/Error", + label => $i18n->get("friends error template label"), + hoverHelp => $i18n->get("friends error template hoverHelp") + ); + + $f->template( + name => "friendsConfirmTemplateId", + value => $self->getConfirmTemplateId, + namespace => "Account/Friends/Confirm", + label => $i18n->get("friends confirm template label"), + hoverHelp => $i18n->get("friends confirm template hoverHelp") + ); + + $f->template( + name => "friendsRemoveConfirmTemplateId", + value => $self->getRemoveConfirmTemplateId, + namespace => "Account/Friends/Confirm", + label => $i18n->get("friends remove confirm template label"), + hoverHelp => $i18n->get("friends remove confirm template hoverHelp") + ); return $f->printRowsOnly; } @@ -62,19 +159,60 @@ sub editSettingsForm { =cut sub editSettingsFormSave { + my $self = shift; + my $session = $self->session; + my $setting = $session->setting; + my $form = $session->form; + + $setting->set("friendsStyleTemplateId", $form->process("friendsStyleTemplateId","template")); + $setting->set("friendsLayoutTempalteId", $form->process("friendsLayoutTempalteId","template")); + $setting->set("friendsViewTemplateId", $form->process("friendsViewTemplateId","template")); + $session->set("friendsEditTemplateId",$form->process("friendsEditTemplateId","template")); + $session->set("friendsSendRequestTemplateId",$form->process("friendsSendRequestTemplateId","template")); + $session->set("friendsErrorTemplateId",$form->process("friendsErrorTemplateId","template")); + $session->set("friendsConfirmTemplateId",$form->process("friendsConfirmTemplateId","template")); + $session->set("friendsRemoveConfirmTemplateId",$form->process("friendsRemoveConfirmTemplateId","template")); + } #------------------------------------------------------------------- -=head2 getDisplayTemplateId ( ) +=head2 getConfirmTemplateId ( ) -This method returns the template ID for the account layout. +This method returns the template ID for the confirmation screen. =cut -sub getDisplayTemplateId { +sub getConfirmTemplateId { my $self = shift; - return $self->session->setting->get("friendsDisplayTempalteId") || "defaultAssetId"; + return $self->session->setting->get("friendsConfirmTemplateId") || "K8F0j_cq_jgo8dvWY_26Ag"; +} + + +#------------------------------------------------------------------- + +=head2 getEditTemplateId ( ) + +This method returns the template ID for editing friends. + +=cut + +sub getEditTemplateId { + my $self = shift; + return $self->session->setting->get("friendsEditTemplateId") || "AZFU33p0jpPJ-E6qLSWZng"; +} + +#------------------------------------------------------------------- + +=head2 getErrorTemplateId ( ) + +This method returns the template ID for displaying errors. + +=cut + +sub getErrorTemplateId { + my $self = shift; + return $self->session->setting->get("friendsErrorTemplateId") || "7Ijdd8SW32lVgg2H8R-Aqw"; } #------------------------------------------------------------------- @@ -91,6 +229,33 @@ sub getLayoutTemplateId { } +#------------------------------------------------------------------- + +=head2 getConfirmTemplateId ( ) + +This method returns the template ID for the confirmation screen. + +=cut + +sub getRemoveConfirmTemplateId { + my $self = shift; + return $self->session->setting->get("friendsRemoveConfirmTemplateId") || "G5V6neXIDiFXN05oL-U3AQ"; +} + + +#------------------------------------------------------------------- + +=head2 getSendRequestTemplateId ( ) + +This method returns the template ID for the send request page. + +=cut + +sub getSendRequestTemplateId { + my $self = shift; + return $self->session->setting->get("friendsSendRequestTemplateId") || "AGJBGviWGAwjnwziiPjvDg"; +} + #------------------------------------------------------------------- =head2 getStyleTemplateId ( ) @@ -114,40 +279,310 @@ This method returns the template ID for the main view. sub getViewTemplateId { my $self = shift; - return $self->session->setting->get("friendsViewTemplateId") || "defaultAssetId"; + return $self->session->setting->get("friendsViewTemplateId") || "1Yn_zE_dSiNuaBGNLPbxtw"; +} + + +#------------------------------------------------------------------- + +=head2 www_removeFriend ( ) + +This is a confirmation page of whether or not the user wishes to remove the selected user from friend + +=cut + +sub www_removeFriend { + my $self = shift; + my $session = $self->session; + my $friendId = $session->form->get("friendId"); + my $var = {}; + + $self->appendCommonVars($var); + my $friend = WebGUI::Friends->new($session); + + my $errorMsg = ""; + if (!$friendId) { + my $i18n = WebGUI::International->new($session,"Account_Friends"); + $errorMsg = $i18n->get("no friend selected"); + } + elsif(!$friend->isFriend($friendId)){ + my $i18n = WebGUI::International->new($session,"Account_Friends"); + $errorMsg = $i18n->get("not a friend error"); + } + + if($errorMsg ne "") { + my $backUrl = $self->getUrl("module=friends"); + return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId); + } + + my $user = WebGUI::User->new($session,$friendId); + $var->{'user_full_name'} = $user->getWholeName; + + $var->{'yes_url' } = $self->getUrl("module=friends;do=removeFriendConfirm;friendId=".$friendId); + $var->{'no_url' } = $self->getUrl("module=friends"); + + return $self->processTemplate($var,$self->getRemoveConfirmTemplateId); +} + + +#------------------------------------------------------------------- + +=head2 www_removeFriend ( ) + +This is a confirmation page of whether or not the user wishes to remove the selected user from friend + +=cut + +sub www_removeFriendConfirm { + my $self = shift; + my $session = $self->session; + my $friendId = $session->form->get("friendId"); + my $var = {}; + my $i18n = WebGUI::International->new($session,"Account_Friends"); + + + $self->appendCommonVars($var); + my $friend = WebGUI::Friends->new($session); + + my $errorMsg = ""; + if (!$friendId) { + $errorMsg = $i18n->get("no friend selected"); + } + elsif(!$friend->isFriend($friendId)){ + $errorMsg = $i18n->get("not a friend error"); + } + + if($errorMsg ne "") { + my $backUrl = $self->getUrl("module=friends"); + return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId); + } + + my $user = WebGUI::User->new($session,$friendId); + my $msg = sprintf($i18n->get("friend removed"),$user->getWholeName); + + $friend->delete([$friendId]); + + return $self->www_view($msg); + } #------------------------------------------------------------------- -=head2 www_display ( ) +=head2 www_sendFriendsRequest ( ) -The main view page for displaying the user's profile. +The page which allows users to submit friends requests. =cut -sub www_display { - my $self = shift; - my $session = $self->session; - my $var = {}; +sub www_sendFriendsRequest { + my $self = shift; + my $session = $self->session; + my $var = {}; + my $uid = $self->uid; + + my $user = WebGUI::User->new($session,$uid); + my $i18n = WebGUI::International->new($session,'Account_Friends'); + + unless ($user->acceptsFriendsRequests($session->user)) { + my $errorMsg = $i18n->get('does not want to be a friend'); + my $friend = WebGUI::Friends->new($session); + if($friend->isFriend($uid)) { + $errorMsg = $i18n->get("error user is already friend"); + } + elsif($friend->isInvited($uid)) { + $errorMsg = $i18n->get("error user is already invited"); + } + return $self->showError($var,$errorMsg,$session->user->getProfileUrl,$self->getErrorTemplateId); + } + + $self->appendCommonVars($var); + + #Overwrite these + $var->{'user_full_name' } = $user->getWholeName; + $var->{'user_member_since' } = $user->dateCreated; + + my $defaultComment = sprintf( + $i18n->get('default friend comments'), + $user->getFirstName, + $session->user->getFirstName + ); + $var->{'form_message_text'} = WebGUI::Form::textarea($session, { + name =>"message", + value =>$defaultComment, + width =>600, + height =>200 + }); + + $var->{'form_message_rich'} = WebGUI::Form::HTMLArea($session, { + name => "message", + value => $defaultComment, + width => "600", + }); + + $var->{'form_header' } = WebGUI::Form::formHeader($session,{ + action => $self->getUrl("module=friends;do=sendFriendsRequestSave;uid=$uid"), + extras => q{name="messageForm"} + }); + + $var->{'submit_button' } = WebGUI::Form::submit($session,{}); + $var->{'form_footer' } = WebGUI::Form::formFooter($session, {}); + + $var->{'cancel_url' } = $user->getProfileUrl; + + return $self->processTemplate($var,$self->getSendRequestTemplateId); +} + + +#------------------------------------------------------------------- + +=head2 www_sendFriendsRequestSave ( ) + +This method allows users to save friends requests + +=cut + +sub www_sendFriendsRequestSave { + my $self = shift; + my $session = $self->session; + my $var = {}; + my $uid = $self->uid; + + my $user = WebGUI::User->new($session,$uid); + + #Errors fall through to the view page. + unless ($user->acceptsFriendsRequests($session->user)) { + return $self->www_sendFriendsRequest; + } + + my $inboxUrl = WebGUI::Account::Inbox->getViewInvitationUrl($session); + my $friends = WebGUI::Friends->new($session); + $friends->sendAddRequest($uid, $session->form->get('message'),$inboxUrl); + + $self->appendCommonVars($var); + + #Overwrite this + $var->{'user_full_name' } = $user->getWholeName; + $var->{'user_profile_url' } = $user->getProfileUrl; + + return $self->processTemplate($var,$self->getConfirmTemplateId); - return $self->processTemplate($var,$self->getDisplayTemplateId); } #------------------------------------------------------------------- =head2 www_view ( ) -The main view page for editing the user's profile. +The main view page for editing your friends. =cut sub www_view { - my $self = shift; - my $session = $self->session; - my $var = {}; + my $self = shift; + my $msg = shift; + my $session = $self->session; + my $var = {}; - return $self->processTemplate($var,$self->getViewTemplateId); + my $uid = $self->uid; + my $user = ($uid) ? WebGUI::User->new($session,$uid) : $session->user; + + $self->appendCommonVars($var); + + my $displayView = $uid ne ""; + $var->{'can_edit' } = $session->user->userId eq $user->userId; + $var->{'display_message'} = $msg; + + #Override these + $var->{'user_full_name' } = $user->getWholeName; + $var->{'user_member_since' } = $user->dateCreated; + + unless ($user->profileField('ableToBeFriend') && $user->profileIsViewable($session->user)) { + my $i18n = WebGUI::International->new($session,"Account_Friends"); + my $errorMsg = ""; + if($var->{'can_edit'}) { + $errorMsg = $i18n->get("friends is off"); + } + else { + $errorMsg = $i18n->get("no access"); + } + my $backUrl = $self->getUrl("op=account"); + return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId); + } + + #Deal with rows per page + my $rpp = $session->form->get("rpp") || 25; + my $rpp_url = ";rpp=$rpp"; + + #Cache the base url + my $friendsUrl = $self->getUrl("op=account;module=friends;do=view"); + + #Note for anyone who attempts to sort this list by the user's whole name: + #You can do this, but the only way to do it efficiently is to join + #the users, userProfileData, and groupings table. This will break if the groups API + #changes in WebGUI 8, so we decided to leave it sorted by username only. + + #Create the paginator + my $friends = $user->friends->getUserList(1); + my @friendIds = keys %{$friends}; + my $p = WebGUI::Paginator->new( + $session, + $friendsUrl.$rpp_url, + $rpp + ); + $p->setDataByArrayRef(\@friendIds); + + #Export page to template + my @friends = (); + foreach my $friendId ( @{$p->getPageData} ) { + my $friend = WebGUI::User->new($session,$friendId); + next if($friend->isVisitor); + #If you have friends turned off you shouldn't show up when other people view your friends friends + next if($displayView && !$friend->profileField('ableToBeFriend')); + + my $hash = {}; + $hash->{'friend_full_name' } = $friend->getWholeName; + $hash->{'isViewable' } = $friend->profileIsViewable; + $hash->{'friend_id' } = $friend->userId; + $hash->{'friend_member_since' } = $friend->dateCreated; + $hash->{'friend_member_since_human'} = $session->datetime->epochToHuman($friend->dateCreated); + $hash->{'friend_isOnline' } = $friend->isOnline; + if($hash->{'isViewable'}) { + $hash->{'friend_profile_url'} = $friend->getProfileUrl; + if($friend->profileField("photo")) { + my $store = WebGUI::Storage::Image->get($session,$friend->profileField("photo")); + my $file = $store->getFiles->[0]; + $hash->{'friend_photo_url' } = $store->getUrl($file); + $hash->{'friend_photo_url_thumb'} = $store->getThumbnailUrl($file); + } + } + + $hash->{'acceptsPrivateMessages'} = $friend->acceptsPrivateMessages($session->user->userId); + if ($displayView) { + if($friend->acceptsFriendsRequests($session->user)) { + $hash->{'friend_request_url'} = $self->getUrl("module=friends;do=sendFriendsRequest;uid=".$friend->userId); + } + } + else { + $hash->{'remove_url'} = $self->getUrl("module=friends;do=removeFriend;friendId=".$friend->userId); + } + push(@friends,$hash); + } + my $friendCount = $p->getRowCount; + + $var->{'friends_loop' } = \@friends; + $var->{'has_friends' } = $friendCount > 0; + $var->{'friends_total' } = $friendCount; + + tie my %rpps, "Tie::IxHash"; + %rpps = (25 => "25", 50 => "50", 100=>"100"); + $var->{'message_rpp' } = WebGUI::Form::selectBox($session,{ + name =>"rpp", + options => \%rpps, + value => $session->form->get("rpp") || 25, + extras => q{onchange="location.href='}.$friendsUrl.q{;rpp='+this.options[this.selectedIndex].value"} + }); + + my $templateId = ($displayView) ? $self->getViewTemplateId : $self->getEditTemplateId; + return $self->processTemplate($var,$templateId); } - 1; diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 7f36efd1f..f5b2fa181 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -46,17 +46,18 @@ These subroutines are available from this package: sub appendCommonVars { my $self = shift; - my $var = shift; - my $inbox = shift; my $session = $self->session; + my $var = shift; + my $inbox = shift || WebGUI::Inbox->new($session); my $user = $session->user; - $var->{'user_full_name' } = $user->getWholeName; - $var->{'user_member_since' } = $user->dateCreated; - $var->{'view_profile_url' } = $user->getProfileUrl; + $self->SUPER::appendCommonVars($var); + $var->{'view_inbox_url' } = $self->getUrl("module=inbox;do=view"); $var->{'view_invitations_url'} = $self->getUrl("module=inbox;do=manageInvitations"); $var->{'unread_message_count'} = $inbox->getUnreadMessageCount; + $var->{'invitation_count' } = $self->getInvitationCount; + $var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend'); } @@ -70,7 +71,7 @@ sub appendCommonVars { sub canView { my $self = shift; - return ($self->session->form->get("uid") eq ""); + return ($self->uid eq ""); } #------------------------------------------------------------------- @@ -145,11 +146,18 @@ sub editSettingsForm { hoverHelp => $i18n->get("inbox manage invitations template hoverHelp") ); $f->template( - name => "inboxInvitationErrorTemplateId", - value => $self->getInvitationErrorTemplateId, - namespace => "Account/Inbox/Error", - label => $i18n->get("invitation error message template label"), - hoverHelp => $i18n->get("invitation error message template hoverHelp") + name => "inboxViewInvitationTemplateId", + value => $self->getViewInvitationTemplateId, + namespace => "Account/Inbox/ViewInvitation", + label => $i18n->get("inbox view invitation template label"), + hoverHelp => $i18n->get("inbox view invitation template hoverHelp") + ); + $f->template( + name => "inboxInvitationConfirmTemplateId", + value => $self->getInvitationConfirmTemplateId, + namespace => "Account/Inbox/Confirm", + label => $i18n->get("invitation confirm message template label"), + hoverHelp => $i18n->get("invitation confirm message template hoverHelp") ); return $f->printRowsOnly; @@ -179,7 +187,8 @@ sub editSettingsFormSave { $session->set("inboxErrorTemplateId",$form->process("inboxErrorTemplateId","template")); #Invitations Settings $session->set("inboxManageInvitationsTemplateId",$form->process("inboxManageInvitationsTemplateId","template")); - $session->set("inboxInvitationErrorTemplateId",$form->process("inboxInvitationErrorTemplateId","template")); + $session->set("inboxViewInvitationTemplateId",$form->process("inboxViewInvitationTemplateId","template")); + $session->set("inboxInvitationConfirmTemplateId",$form->process("inboxInvitationConfirmTemplateId","template")); } #------------------------------------------------------------------- @@ -195,20 +204,37 @@ sub getInboxErrorTemplateId { return $self->session->setting->get("inboxErrorTemplateId") || "ErEzulFiEKDkaCDVmxUavw"; } +#------------------------------------------------------------------- + +=head2 getInvitationCount ( ) + +This method returns the total number of invitations in the invitation box. + +=cut + +sub getInvitationCount { + my $self = shift; + my $session = $self->session; + return $session->db->quickScalar( + q{select count(*) from friendInvitations where friendId=?}, + [$session->user->userId] + ); +} #------------------------------------------------------------------- -=head2 getInvitationErrorTemplateId ( ) +=head2 getInvitationConfirmTemplateId ( ) This method returns the template ID for invitation errors. =cut -sub getInvitationErrorTemplateId { +sub getInvitationConfirmTemplateId { my $self = shift; - return $self->session->setting->get("inboxInvitationErrorTemplateId") || "5A8Hd9zXvByTDy4x-H28qw"; + return $self->session->setting->get("inboxInvitationConfirmTemplateId") || "5A8Hd9zXvByTDy4x-H28qw"; } + #------------------------------------------------------------------- =head2 getLayoutTemplateId ( ) @@ -222,6 +248,7 @@ sub getLayoutTemplateId { return $self->session->setting->get("inboxLayoutTempalteId") || $self->SUPER::getLayoutTemplateId; } + #------------------------------------------------------------------- =head2 getManageInvitationsTemplateId ( ) @@ -295,6 +322,40 @@ sub getUserProfileUrl { return $self->store->{$userId}; } +#------------------------------------------------------------------- + +=head2 getViewInvitationTemplateId ( ) + +This method returns the id for the view message template. + +=cut + +sub getViewInvitationTemplateId { + my $self = shift; + return $self->session->setting->get("inboxViewInvitationTemplateId") || "VBkY05f-E3WJS50WpdKd1Q"; +} + +#------------------------------------------------------------------- + +=head2 getViewInvitationUrl ( session ) + +Class method which returns the base url for viewing invitations + +=head3 session + +session object + +=cut + +sub getViewInvitationUrl { + my $class = shift; + my $session = shift; + my $url = $session->url; + + return $url->append($url->getSiteURL,"op=account;module=inbox;do=viewInvitation"); +} + + #------------------------------------------------------------------- =head2 getViewMessageTemplateId ( ) @@ -323,6 +384,54 @@ sub getViewTemplateId { #------------------------------------------------------------------- +=head2 www_approveDenyInvitations ( ) + +Approves or denies invitations passed in. + +=cut + +sub www_approveDenyInvitations { + my $self = shift; + my $session = $self->session; + my $form = $session->form; + + my @messages = $form->process("inviteId","checkList"); + my $approve = $form->get("accept"); + my $deny = $form->get("deny"); + + my $friends = WebGUI::Friends->new($session); + + my @users = (); + + foreach my $inviteId (@messages) { + my $invite = $friends->getAddRequest($inviteId); + my $inviter = WebGUI::User->new($session, $invite->{inviterId}); + next unless ($invite->{inviterId}); #Not sure how this could ever happen, but check for it + next unless ($session->user->userId eq $invite->{friendId}); #Protect against malicious stuff + if($deny) { + $friends->rejectAddRequest($inviteId); + } + elsif($approve) { + $friends->approveAddRequest($inviteId); + } + push (@users, { + 'friend_name' => $inviter->getWholeName, + 'is_denied' => ($deny ne ""), + 'is_approved' => ($approve ne ""), + }); + } + my $var = {}; + $var->{'friends_loop'} = \@users; + + #Append common vars + $self->appendCommonVars($var,WebGUI::Inbox->new($session)); + + #Return a confirm message + return $self->processTemplate($var,$self->getInvitationConfirmTemplateId); +} + +#------------------------------------------------------------------- + =head2 www_deleteMessage ( ) Deletes a single messages passed in @@ -389,15 +498,84 @@ The page on which users can manage their friends requests =cut sub www_manageInvitations { - my $self = shift; - my $session = $self->session; - my $user = $session->user; + my $self = shift; + my $session = $self->session; + my $user = $session->user; + my $var = {}; + my $i18n = WebGUI::International->new($session,'Account_Inbox'); + + #Deal with rows per page + my $rpp = $session->form->get("rpp") || 25; + my $rpp_url = ";rpp=$rpp"; + + #Cache the base url + my $inboxUrl = $self->getUrl("op=account;module=inbox;do=manageInvitations"); - my $var = {}; + #Create the paginator + my $sql = q{ select * from friendInvitations where friendId=? order by dateSent desc }; + my $p = WebGUI::Paginator->new( + $session, + $inboxUrl.$rpp_url, + $rpp + ); + $p->setDataByQuery($sql,undef,undef,[$user->userId]); + + #Export page to template + my @msg = (); + foreach my $row ( @{$p->getPageData} ) { + my $inviter = WebGUI::User->new($session,$row->{inviterId}); + next if($inviter->isVisitor); # Inviter account got deleted + + my $epoch = WebGUI::DateTime->new(mysql => $row->{dateSent} )->epoch; + + my $hash = {}; + $hash->{'invite_id' } = $row->{inviteId}; + $hash->{'message_url' } = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$row->{inviteId}); + $hash->{'from_id' } = $row->{inviterId}; + $hash->{'from_url' } = $inviter->getProfileUrl; #Get the profile url of this user which may be cached. + $hash->{'from' } = $inviter->getWholeName; + $hash->{'dateStamp' } = $epoch; + $hash->{'dateStamp_formatted'} = $session->datetime->epochToHuman($epoch); + $hash->{'form_checkbox' } = WebGUI::Form::checkbox($session,{ + name => "inviteId", + value => $row->{inviteId} + }); + push(@msg,$hash); + } + my $msgCount = $p->getRowCount; + + $var->{'message_loop' } = \@msg; + $var->{'has_messages' } = $msgCount > 0; + $var->{'message_total' } = $msgCount; - #Add common template variable for displaying the inbox - my $inbox = WebGUI::Inbox->new($session); - $self->appendCommonVars($var,$inbox); + $var->{'form_start' } = WebGUI::Form::formHeader($session,{ + action => $self->getUrl("module=inbox;do=approveDenyInvitations") + }); + $var->{'form_end' } = 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") + }); + + tie my %rpps, "Tie::IxHash"; + %rpps = (25 => "25", 50 => "50", 100=>"100"); + $var->{'message_rpp' } = WebGUI::Form::selectBox($session,{ + name =>"rpp", + options => \%rpps, + value => $session->form->get("rpp") || 25, + extras => q{onchange="location.href='}.$inboxUrl.q{;rpp='+this.options[this.selectedIndex].value"} + }); + + #Append common vars + $self->appendCommonVars($var,WebGUI::Inbox->new($session)); + #Append pagination vars + $p->appendTemplateVars($var); return $self->processTemplate($var,$self->getManageInvitationsTemplateId); } @@ -453,6 +631,7 @@ sub www_sendMessage { $errorMsg = $i18n->get("system message error"); } if($errorMsg) { + $var->{'isInbox'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } @@ -478,6 +657,7 @@ sub www_sendMessage { $errorMsg = $i18n->get("no self error"); } if($errorMsg) { + $var->{'isInbox'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } @@ -530,6 +710,7 @@ sub www_sendMessage { unless($activeFriendCount) { my $i18n = WebGUI::International->new($session,'Account_Inbox'); $errorMsg = $i18n->get("no friends error"); + $var->{'isInbox'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } @@ -553,8 +734,10 @@ sub www_sendMessage { $var->{'message_body' } = $form->get('message'); $var->{'form_message_text'} = WebGUI::Form::textarea($session, { - name =>"message", - value =>$var->{'message_body'} || "", + name =>"message", + value =>$var->{'message_body'} || "", + width =>600, + height =>200 }); $var->{'form_message_rich'} = WebGUI::Form::HTMLArea($session, { @@ -771,6 +954,99 @@ sub www_view { #------------------------------------------------------------------- +=head2 www_viewInvitation ( ) + +The page on which users view their messages + +=cut + +sub www_viewInvitation { + my $self = shift; + my $session = $self->session; + my $user = $session->user; + + my $var = {}; + my $inviteId = shift || $session->form->get("inviteId"); + my $errorMsg = shift; + my $i18n = WebGUI::International->new($session,'Account_Inbox'); + + + my $friends = WebGUI::Friends->new($session); + my $invitation = $friends->getAddRequest($inviteId); + my $inviter = WebGUI::User->new($session,$invitation->{inviterId}); + + #Add common template variable for displaying the inbox + $self->appendCommonVars($var,WebGUI::Inbox->new($session)); + + #Handle Errors + if (!($invitation->{inviteId})) { #Invitation is invalid + $errorMsg = $i18n->get("invitation does not exist"); + } + elsif ($inviter->isVisitor) { #Inviter user account was deleted + $errorMsg = $i18n->get("inviter no longer exists"); + } + elsif ($session->user->userId ne $invitation->{friendId}) { #User trying to view someone else's invitation + $errorMsg = $i18n->get("no access to invitation"); + } + + if($errorMsg) { + my $backUrl = $var->{'view_invitations_url'}; + $var->{'isInvitation'} = "true"; + return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); + } + + my $epoch = WebGUI::DateTime->new(mysql => $invitation->{dateSent} )->epoch; + + $var->{'invite_id' } = $inviteId; + $var->{'message_from_id' } = $inviter->userId; + $var->{'message_from' } = $inviter->getWholeName; + $var->{'message_from_url' } = $inviter->getProfileUrl; + $var->{'message_dateStamp' } = $epoch; + $var->{'message_dateStamp_human'} = $session->datetime->epochToHuman($epoch); + $var->{'message_body' } = $invitation->{comments}; + + unless ($var->{'message_body'} =~ /\{'message_body'} =~ s/(http\S*)/\$1\<\/a\>/g; + } + unless ($var->{'message_body'} =~ /\
{'message_body'} =~ /\
{'message_body'} =~ /\

{'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{ }); + $f->readOnly ( + value => $i18n->get("templates in auth method message"), + ); return $f->printRowsOnly; } @@ -62,6 +87,13 @@ sub editSettingsForm { =cut sub editSettingsFormSave { + my $self = shift; + my $session = $self->session; + my $setting = $session->setting; + my $form = $session->form; + + $setting->set("userAccountStyleTemplateId", $form->process("userAccountStyleTemplateId","template")); + $setting->set("userAccountLayoutTemplateId", $form->process("userAccountLayoutTemplateId","template")); } #------------------------------------------------------------------- @@ -74,7 +106,7 @@ This method returns the template ID for the account layout. sub getLayoutTemplateId { my $self = shift; - return $self->session->setting->get("userLayoutTempalteId") || $self->SUPER::getLayoutTemplateId; + return $self->session->setting->get("userAccountLayoutTemplateId") || "9ThW278DWLV0-Svf68ljFQ"; } @@ -88,21 +120,9 @@ This method returns the template ID for the main style. sub getStyleTemplateId { my $self = shift; - return $self->session->setting->get("userStyleTemplateId") || $self->SUPER::getStyleTemplateId; + return $self->session->setting->get("userAccountStyleTemplateId") || $self->SUPER::getStyleTemplateId; } -#------------------------------------------------------------------- - -=head2 getViewTemplateId ( ) - -This method returns the template ID for the main view. - -=cut - -sub getViewTemplateId { - my $self = shift; - return $self->session->setting->get("userViewTemplateId") || "defaultAssetId"; -} #------------------------------------------------------------------- @@ -115,9 +135,10 @@ The main view page for editing the user's profile. sub www_view { my $self = shift; my $session = $self->session; - my $var = {}; - return $self->processTemplate($var,$self->getViewTemplateId); + my $auth = WebGUI::Operation::Auth::getInstance($session); + + return $auth->displayAccount; } diff --git a/lib/WebGUI/Account/_NewModule.skeleton b/lib/WebGUI/Account/_NewModule.skeleton new file mode 100644 index 000000000..7c665f462 --- /dev/null +++ b/lib/WebGUI/Account/_NewModule.skeleton @@ -0,0 +1,145 @@ +package WebGUI::Account::NewModule; + +use strict; + +use WebGUI::Exception; +use WebGUI::International; +use WebGUI::Pluggable; +use WebGUI::Utility; +use base qw/WebGUI::Account/; + +=head1 NAME + +Package WebGUI::Account::NewAsset + +=head1 DESCRIPTION + +Describe your New Account Module's functionality and features here. + +=head1 SYNOPSIS + +use WebGUI::Account::NewModule; + + +=head1 METHODS + +These methods are available from this class: + +=cut + +#------------------------------------------------------------------- + +=head2 canView ( ) + + Returns whether or not the user can view the the tab for this module + +=cut + +sub canView { + my $self = shift; + return 1; +} + +#------------------------------------------------------------------- + +=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_NewModule'); + my $f = WebGUI::HTMLForm->new($session); + + $f->template( + name => "moduleStyleTemplateId", + value => $self->getStyleTemplateId, + namespace => "style", + label => $i18n->get("style template label"), + hoverHelp => $i18n->get("style template hoverHelp") + ); + $f->template( + name => "moduleLayoutTemplateId", + value => $self->getLayoutTemplateId, + namespace => "Account/Layout", + label => $i18n->get("layout template label"), + hoverHelp => $i18n->get("layout template hoverHelp") + ); + $f->template( + name => "moduleViewTemplateId", + value => $self->session->setting->get("moduleViewTemplateId"), + namespace => "Account/NewModule/View", + label => $i18n->get("view template label"), + hoverHelp => $i18n->get("view template hoverHelp") + ); + + 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("moduleStyleTemplateId", $form->process("moduleStyleTemplateId","template")); + $setting->set("moduleLayoutTemplateId", $form->process("moduleLayoutTemplateId","template")); + $setting->set("moduleViewTemplateId", $form->process("moduleViewTemplateId","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("moduleLayoutTempalteId") || $self->SUPER::getLayoutTemplateId; +} + + +#------------------------------------------------------------------- + +=head2 getStyleTemplateId ( ) + +This method returns the template ID for the main style. + +=cut + +sub getStyleTemplateId { + my $self = shift; + return $self->session->setting->get("moduleStyleTemplateId") || $self->SUPER::getStyleTemplateId; +} + +#------------------------------------------------------------------- + +=head2 www_view ( ) + +The main view page for editing the user's profile. + +=cut + +sub www_view { + my $self = shift; + my $session = $self->session; + my $var = {}; + + return $self->processTemplate($var,$session->setting->get("moduleViewTemplateId")); +} + + +1; diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index ddb7d4531..399b0c465 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -424,7 +424,7 @@ Formats the url to view a users profile. sub getPosterProfileUrl { my $self = shift; - return $self->getUrl("op=viewProfile;uid=".$self->get("ownerUserId")); + return WebGUI::User->new($self->session,$self->get("ownerUserId"))->getProfileUrl; } #------------------------------------------------------------------- @@ -534,7 +534,7 @@ sub getTemplateVars { $var{"userId"} = $self->get("ownerUserId"); $var{"user.isPoster"} = $self->isPoster; $var{"avatar.url"} = $self->getAvatarUrl; - $var{"userProfile.url"} = $self->getUrl("op=viewProfile;uid=".$self->get("ownerUserId")); + $var{"userProfile.url"} = $self->getPosterProfileUrl; $var{"dateSubmitted.human"} =$self->session->datetime->epochToHuman($self->get("creationDate")); $var{"dateUpdated.human"} =$self->session->datetime->epochToHuman($self->get("revisionDate")); $var{'title.short'} = $self->chopTitle; diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 0497f6151..41921b3d7 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -847,7 +847,7 @@ sub www_saveUserPrefs { my $field = WebGUI::ProfileField->new($self->session,$fieldId); next unless $field; $data{$field->getId} = $field->formProcess; - if ($field->getId eq 'email' && WebGUI::Operation::Profile::isDuplicateEmail($self->session,$data{$field->getId})) { + if ($field->getId eq 'email' && $field->isDuplicate($data{$field->getId})) { return '

  • '.$i18n->get(1072).'
  • '; } if ($field->isRequired && !$data{$field->getId}) { diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 0b8cf4fd6..d8b7c421a 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -30,6 +30,7 @@ use WebGUI::Operation::Shared; use WebGUI::Operation::Profile; use WebGUI::Workflow::Instance; use WebGUI::Inbox; +use WebGUI::Exception; # Profile field name for the number of times the showMessageOnLogin has been # seen. @@ -270,7 +271,7 @@ Password entered by the user. This is only used in for sending the user a notif =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::User::validateProfileDataFromForm($fields); =cut @@ -290,7 +291,7 @@ sub createAccountSave { $u->username($username); $u->authMethod($self->authMethod); $u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma")); - WebGUI::Operation::Profile::saveProfileFields($self->session,$u,$profile) if($profile); + $u->updateProfileFields($profile) if ($profile); $self->saveParams($userId,$self->authMethod,$properties); if ($self->getSetting("sendWelcomeMessage")){ @@ -460,10 +461,10 @@ Array ref of template vars from subclass =cut sub displayAccount { - my $self = shift; - my $method = $_[0]; - my $vars = $_[1]; - + my $self = shift; + my $method = shift; + my $vars = shift; + my $i18n = WebGUI::International->new($self->session); $vars->{title} = $i18n->get(61); @@ -477,8 +478,21 @@ sub displayAccount { $vars->{'account.form.submit'} = WebGUI::Form::submit($self->session,{}); $vars->{'account.form.footer'} = WebGUI::Form::formFooter($self->session,); - $vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions($self->session); - return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars); + #Appends 'account.options' loop along with some new links + WebGUI::Account->appendAccountLinks($self->session,$vars); + + ########### ACCOUNT SHUNT + #The following is a shunt which allows the displayAccount page to be displayed in the + #Account system. This shunt will be replaced in WebGUI 8 when the API can be broken + my $output = WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars); + #If the account system is calling this method, just return the template + my $op = $self->session->form->get("op"); + if($op eq "account") { + return $output; + } + #Otherwise wrap the template into the account layout + my $instance = WebGUI::Content::Account->createInstance($self->session,"user"); + return $instance->displayContent($output,1); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth/LDAP.pm b/lib/WebGUI/Auth/LDAP.pm index bbf23d7d2..a4fdf252b 100644 --- a/lib/WebGUI/Auth/LDAP.pm +++ b/lib/WebGUI/Auth/LDAP.pm @@ -304,9 +304,18 @@ sub createAccountSave { #Check that username is valid and not a duplicate in the system. $error .= $self->error if(!$self->validUsername($username)); #Validate profile data. - my ($profile, $temp, $warning) = WebGUI::Operation::Profile::validateProfileData($self->session); + my $fields = WebGUI::ProfileField->getEditableFields($self->session); + my $retHash = $self->user->validateProfileDataFromForm($fields); + my $profile = $retHash->{profile}; + my $temp = ""; + my $warning = ""; + + my $format = "
  • %s
  • "; + map { $warning .= sprintf($format,$_) } @{$retHash->{warnings}}; + map { $temp .= sprintf($format,$_) } @{$retHash->{errors}}; + $error .= $temp; - return $self->createAccount("
  • ".$error."") unless ($error eq ""); + return $self->createAccount("
  • ".$error."
  • ") unless ($error eq ""); #If Email address is not unique, a warning is displayed if($warning ne "" && !$self->session->form->process("confirm")){ return $self->createAccount('
  • '.$i18n->get(1078).'
  • ', 1); @@ -336,18 +345,30 @@ sub deactivateAccountConfirm { #------------------------------------------------------------------- sub displayAccount { - my $self = shift; - my $vars; - return $self->displayLogin($_[0]) if ($self->isVisitor); + my $self = shift; + my $vars; + return $self->displayLogin($_[0]) if ($self->isVisitor); my $i18n = WebGUI::International->new($self->session); - $vars->{displayTitle} = '

    '.$i18n->get(61).'

    '; - $vars->{'account.message'} = $i18n->get(856); - if($self->session->setting->get("useKarma")){ - $vars->{'account.form.karma'} = $self->session->user->profileField("karma"); - $vars->{'account.form.karma.label'} = $i18n->get(537); - } - $vars->{'account.options'} = WebGUI::Operation::Shared::accountOptions($self->session); - return WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars); + $vars->{displayTitle} = '

    '.$i18n->get(61).'

    '; + $vars->{'account.message'} = $i18n->get(856); + if($self->session->setting->get("useKarma")){ + $vars->{'account.form.karma'} = $self->session->user->profileField("karma"); + $vars->{'account.form.karma.label'} = $i18n->get(537); + } + WebGUI::Account->appendAccountLinks($self->session,$vars); + + ########### ACCOUNT SHUNT + #The following is a shunt which allows the displayAccount page to be displayed in the + #Account system. This shunt will be replaced in WebGUI 8 when the API can be broken + my $output = WebGUI::Asset::Template->new($self->session,$self->getAccountTemplateId)->process($vars); + #If the account system is calling this method, just return the template + my $op = $self->session->form->get("op"); + if($op eq "account") { + return $output; + } + #Otherwise wrap the template into the account layout + my $instance = WebGUI::Content::Account->createInstance($self->session,"user"); + return $instance->displayContent($output,1); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index f93aa1b0b..5b28c7e41 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -229,7 +229,18 @@ sub createAccountSave { } } $error .= $self->error unless($self->_isValidPassword($password,$passConfirm)); - my ($profile, $temp, $warning) = WebGUI::Operation::Profile::validateProfileData($self->session, {regOnly => 1}); + + my $fields = WebGUI::ProfileField->getRegistrationFields($session); + my $retHash = $self->user->validateProfileDataFromForm($fields); + my $profile = $retHash->{profile}; + my $temp = ""; + my $warning = ""; + + my $format = "
  • %s
  • "; + map { $warning .= sprintf($format,$_) } @{$retHash->{warnings}}; + map { $temp .= sprintf($format,$_) } @{$retHash->{errors}}; + + $error .= $temp; unless ($error eq "") { diff --git a/lib/WebGUI/Content/Account.pm b/lib/WebGUI/Content/Account.pm index 619687ca7..6978381e0 100644 --- a/lib/WebGUI/Content/Account.pm +++ b/lib/WebGUI/Content/Account.pm @@ -16,7 +16,7 @@ package WebGUI::Content::Account; use strict; use WebGUI::Session; -use WebGUI::Exception::Account; +use WebGUI::Exception; use Carp qw(croak); =head1 NAME @@ -56,6 +56,65 @@ These subroutines are available from this package: =cut + +#------------------------------------------------------------------- + +=head2 createInstance ( session, module ) + +Creates an instance of an account pluggin + +=session + +WebGUI::Session object + +=module + +Module the method is in. Defaults to the profileModuleIdentifier in the config file + +=cut + +sub createInstance { + my $class = shift; + my $session = shift; + my $module = shift || $session->config->get("profileModuleIdentifier"); + + #Get the account config to work with + my $configs = $session->config->get("account"); + my $config = __PACKAGE__->getAccountConfig($session,$module,$configs); + + #Throw an error if the config file isn't found + unless (defined $config) { + WebGUI::Error->throw( error => qq{Could not locate module $module in the account system}); + return undef; + } + + #Visitor cannot access the acccount system + return $session->privilege->insufficient if($session->user->isVisitor); + + #Create Pluggin Object + #Don't eval this as pluggable will croak and we want the calling module to handle the exception + my $pluggin = WebGUI::Pluggable::instanciate( + $config->{className}, + "new", + [ $session, $module ] + ); + + #Check to make sure pluggin is a subclass of WebGUI::Account + unless($pluggin->isa('WebGUI::Account')) { + my $plugginType = ref $pluggin; + WebGUI::Error::InvalidObject->throw( + expected => 'WebGUI::Account', + got => $plugginType, + error => '$plugginType is not a subclass of WebGUI::Accout' + ); + return undef; + } + + return $pluggin; +} + + + #------------------------------------------------------------------- =head2 getAccountConfig ( op, configs ) @@ -99,97 +158,21 @@ sub handler { my $form = $session->form; my $setting = $session->setting; - my $op = $form->get("op"); - return undef unless ($op eq "account"); + #Pass through if it's not the account op + return undef unless ($form->get("op") eq "account"); - my $output = undef; + my $module = $form->get("module"); + my $method = $form->get("do"); + my $uid = $form->get("uid"); - my $module = $form->get("module") || $session->config->get("profileModuleIdentifier"); + my $instance = __PACKAGE__->createInstance($session,$module); + + #Let the content handler handle trapping errors + my $output = $instance->callMethod($method,[],$uid); + return undef unless (defined $output); + + return $instance->displayContent($output); - my $configs = $session->config->get("account"); - my $config = __PACKAGE__->getAccountConfig($session,$module,$configs); - - if (defined $config) { - #Visitor cannot do anything to the profile. - return $session->privilege->insufficient if($session->user->isVisitor); - - #Create Pluggin Object - #Don't eval this as pluggable will croak and we want WebGUI::URL::Content to handle the exception - my $pluggin = WebGUI::Pluggable::instanciate($config->{className}, "new", [ $session ] ); - - #Check to make sure pluggin is a subclass of WebGUI::Account - unless($pluggin->isa('WebGUI::Account')) { - my $plugginType = ref $pluggin; - WebGUI::Error::InvalidObject->throw( - expected => 'WebGUI::Account', - got => $plugginType, - error => '$plugginType is not a subclass of WebGUI::Accout' - ); - } - - #Check to see if the user has permission to see what they are calling - return $session->privilege->insufficient unless ($pluggin->canView); - - #Process the method call - my $method = $form->get("do") || "view"; - $method = "www_".$method; - - if($pluggin->can($method)) { - $output = $pluggin->$method; - } - else { - WebGUI::Error::MethodNotFound->throw( - error => "Couldn't call non-existant method $method", - method => $method - ); - } - - #Wrap content returned from method call into the layout - my $var = {}; - $var->{content} = $output; - - # Get fieldsets for avaiable account methods in the order they exist in the config file - my @pluggins = (); - foreach my $account (@{$configs}) { - #Instantiate the pluggin - #Use the currently instantiated pluggin if we are checking this pluggin - my $instance = undef; - if($account->{identifier} eq $module) { - $instance = $pluggin; - } - else { - $instance = eval { WebGUI::Pluggable::instanciate($account->{className}, "new", [ $session ] ) }; - if (my $e = WebGUI::Error->caught) { - $session->log->warn("Couldn't instantiate Account Pluggin ".$account->{className}." ... skipping"); - next; - } - elsif(!$pluggin->isa('WebGUI::Account')) { - $session->log->warn((ref $instance)." is not a subclass of WebGUI::Account ... skipping"); - next; - } - } - #Skip this module if the user can't view this - next unless ($instance->canView); - - #Push the tab variables onto the template - my %hash = %{$account}; - my $identifier = $account->{identifier}; - $hash{'is_'.$identifier} = "true"; - $hash{'url' } = $instance->getUrl("module=$identifier",1); - $hash{'isActive' } = "true" if($identifier eq $module); - WebGUI::Macro::process(\$hash{'title'}); - push(@pluggins,\%hash); - } - $var->{'account_loop'} = \@pluggins; - - my $layoutId = $pluggin->getLayoutTemplateId; - #Process the layout template - $output = $pluggin->processTemplate($var,$layoutId); - #Wrap the layout in the user style - $output = $session->style->userStyle($output); - } - - return $output; } diff --git a/lib/WebGUI/Form/File.pm b/lib/WebGUI/Form/File.pm index 0c1e82542..076c0d3d4 100644 --- a/lib/WebGUI/Form/File.pm +++ b/lib/WebGUI/Form/File.pm @@ -174,11 +174,6 @@ deleting the file if it was specified. sub getValue { my $self = shift; my $value = $self->get("value"); - my $log = $self->session->log; - $log->warn("file is: ".$self->session->form->get($self->get("name")."_file")); - $log->warn("value is: ".$value); - $log->warn("action is: ".$self->session->form->param($self->privateName('action'))); - my $storage = WebGUI::Storage->get($self->session,$value); if (defined $storage) { foreach my $file (@{$storage->getFiles}) { @@ -200,8 +195,6 @@ sub getValue { } $storage->addFileFromFormPost($self->get("name")."_file",1000); my @files = @{ $storage->getFiles }; - $log->warn("storageId: ".$storage->getId); - $log->warn("number of files: ".scalar(@files)); if (scalar(@files) < 1) { $storage->delete; return undef; @@ -212,7 +205,6 @@ sub getValue { return $id; } } - $log->warn("returning: ".$value); return $value; } diff --git a/lib/WebGUI/Friends.pm b/lib/WebGUI/Friends.pm index 2b7d98242..5aa7e6acd 100644 --- a/lib/WebGUI/Friends.pm +++ b/lib/WebGUI/Friends.pm @@ -149,6 +149,61 @@ sub getAllPendingAddRequests { } +#------------------------------------------------------------------- + +=head2 getNextInvitation ( invitation ) + +Returns the invitation that was sent to the user just after the invitation passed in. + +=cut + +sub getNextInvitation { + my $self = shift; + my $invitation = shift; + + my $sql = q{ + select + * + from + friendInvitations + where + friendId = ? + and dateSent > ? + order by dateSent asc + limit 1 + }; + my $bindvars = [$self->user->userId,$invitation->{dateSent}]; + return $self->session->db->quickHashRef($sql,$bindvars); +} + + +#------------------------------------------------------------------- + +=head2 getPreviousInvitation ( invitation ) + +Returns the invitation that was sent to the user just before the invitation passed in. + +=cut + +sub getPreviousInvitation { + my $self = shift; + my $invitation = shift; + + my $sql = q{ + select + * + from + friendInvitations + where + friendId = ? + and dateSent < ? + order by dateSent desc + limit 1 + }; + my $bindvars = [$self->user->userId,$invitation->{dateSent}]; + return $self->session->db->quickHashRef($sql,$bindvars); +} + #------------------------------------------------------------------- =head2 isFriend ( userId ) @@ -193,7 +248,7 @@ sub isInvited { inviterId = ? and friendId = ? }, - [$session->user->userId,$userId]); + [$self->user->userId,$userId]); return $isInvited; } @@ -268,12 +323,19 @@ The user to invite to be a friend. The message to lure them to accept. +=head inviteUrl + +The url to view the friend request + =cut sub sendAddRequest { - my $self = shift; - my $userId = shift; - my $comments = shift; + my $self = shift; + my $userId = shift; + my $comments = shift; + my $url = $self->session->url; + my $inviteUrl = shift || $url->append($url->getSiteURL,'op=account'); + my $i18n = WebGUI::International->new($self->session, "Friends"); # No sneaky attack paths... @@ -281,7 +343,9 @@ sub sendAddRequest { # Create the invitation url. my $inviteId = $self->session->id->generate(); - my $inviteUrl = $self->session->url->append($self->session->url->getSiteURL, 'op=friendRequest;inviteId='.$inviteId); + + $inviteUrl = $url->append($inviteUrl,'inviteId='.$inviteId); + # Build the message my $messageText = sprintf $i18n->get("invitation approval email"), $self->user->getWholeName, $self->session->url->getSiteURL, $comments, $inviteUrl; diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index a15f92a13..162a615f3 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -154,7 +154,7 @@ sub getMessage { =head2 getNextMessage ( message [, userId] ) -Returns the next message for the user +Returns the message that was send after the message passed in for the user =head3 message @@ -167,15 +167,15 @@ The WebGUI::User object of the user to retrieve the message for. Defaults to th =cut sub getNextMessage { - my $self = shift; + my $self = shift; my $session = $self->session; my $message = shift; my $user = shift || $session->user; - - my $sql = $self->getMessageSql($user,{ - whereClause => "ibox.dateStamp < ".$message->get("dateStamp"), + + my $sql = $self->getMessageSql($user,{ + whereClause => "ibox.dateStamp > ".$message->get("dateStamp"), sortBy => "ibox.dateStamp", - sortDir => "desc", + sortDir => "asc", limit => 1 }); @@ -188,7 +188,7 @@ sub getNextMessage { =head2 getPreviousMessage ( message [, userId] ) -Returns the previous message for the user +Returns the message that was sent before the message passed in for the user =head3 message @@ -205,11 +205,11 @@ sub getPreviousMessage { my $session = $self->session; my $message = shift; my $user = shift || $session->user; - - my $sql = $self->getMessageSql($user,{ - whereClause => "ibox.dateStamp > ".$message->get("dateStamp"), + + my $sql = $self->getMessageSql($user,{ + whereClause => "ibox.dateStamp < ".$message->get("dateStamp"), sortBy => "ibox.dateStamp", - sortDir => "asc", + sortDir => "desc", limit => 1 }); diff --git a/lib/WebGUI/Inbox/Message.pm b/lib/WebGUI/Inbox/Message.pm index 37af5703c..0abd30ad6 100644 --- a/lib/WebGUI/Inbox/Message.pm +++ b/lib/WebGUI/Inbox/Message.pm @@ -378,9 +378,12 @@ The id of the user that completed this task. Defaults to the current user. sub setCompleted { my $self = shift; my $userId = shift || $self->session->user->userId; - $self->{_properties}{status} = "completed"; + $self->{_properties}{status} = "completed"; $self->{_properties}{completedBy} = $userId; $self->{_properties}{completedOn} = time(); + $self->{_inbox}{status} = "completed"; + $self->{_inbox}{completedBy} = $userId; + $self->{_inbox}{completedOn} = time(); $self->session->db->setRow("inbox","messageId",$self->{_inbox}); #Completed messages should also be marked read $self->setRead($userId); @@ -498,7 +501,12 @@ sub setStatus { $self->setReplied($userId); } - $self->{_properties}{status} = ( $status ne "pending") ? "active" : "pending"; + #Only let completed stuff go back to pending + if ( $status eq "pending" && $self->{_properties}{status} eq "completed") { + $self->{_properties}{status} = "pending"; + $self->{_inbox}{status} = "pending" + } + $self->session->db->setRow("inbox","messageId",$self->{_inbox}); return undef; } diff --git a/lib/WebGUI/Macro/FileUrl.pm b/lib/WebGUI/Macro/FileUrl.pm index 556f23b4d..5c412db7c 100644 --- a/lib/WebGUI/Macro/FileUrl.pm +++ b/lib/WebGUI/Macro/FileUrl.pm @@ -52,6 +52,10 @@ the asset and simply return the url of the first file it finds If id is passed in and the isStorageId flag is set, you may pass in filename to specify the name of the file you'd like returned. +head3 isImage + +If id is passed in and the isImage flag is set, the first image will be returned + =cut sub process { @@ -60,11 +64,18 @@ sub process { my $id = shift; my $isStorageId = shift; my $filename = shift; + my $isImage = shift; my $i18n = WebGUI::International->new($session, 'Macro_FileUrl'); #Handle storageId case if($isStorageId && $id) { - my $store = WebGUI::Storage->get($session,$id); + my $store = undef; + if($isImage) { + $store = WebGUI::Storage::Image->get($session,$id); + } + else { + $store = WebGUI::Storage->get($session,$id); + } $filename = $store->getFiles->[0] unless ($filename); return "" unless ($filename); return $store->getUrl($filename); diff --git a/lib/WebGUI/Macro/NewMail.pm b/lib/WebGUI/Macro/NewMail.pm index 2debd1531..1ba2b6a61 100644 --- a/lib/WebGUI/Macro/NewMail.pm +++ b/lib/WebGUI/Macro/NewMail.pm @@ -29,7 +29,7 @@ sub _createURL { my $session = shift; my $text = shift; my $class = shift; - my $url = '
    url->page("op=account;module=inbox").'"'; $url .= ' class="'.$class.'"' if($class); $url .= '>'.$text.''; return $url; diff --git a/lib/WebGUI/Macro/User.pm b/lib/WebGUI/Macro/User.pm index af451c7d1..6e90d01f6 100644 --- a/lib/WebGUI/Macro/User.pm +++ b/lib/WebGUI/Macro/User.pm @@ -18,19 +18,34 @@ Package WebGUI::Macro::User =head1 DESCRIPTION -Macro for displaying information from the current User's profile. +Macro for displaying information from the a User's profile. -=head2 process( field ) +=head2 process( field [, userId] ) -process takes a single parameter, the name of a field in the current user's User Profile from -the data stored in $session . If the field does not exist, undef is returned. +This macro tries to return the profile field passed in for the user +passed in. If not user is passed in, the current user in session +will be used. + +=head3 field + + =cut #------------------------------------------------------------------- sub process { - my $session = shift; - return $session->user->profileField(shift); + my $session = shift; + my $field = shift; + my $userId = shift; + + return undef unless ($field); + + my $user = ($userId) + ? WebGUI::User->new($session,$userId) + : $session->user + ; + + return $user->profileField($field); } diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index 12ab28ab5..10e528fc6 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -135,20 +135,14 @@ sub getOperations { 'viewInbox' => 'Inbox', 'viewInboxMessage' => 'Inbox', 'sendPrivateMessage' => 'Inbox', - 'sendPrivateMessageSave' => 'Inbox', - 'deletePrivateMessage' => 'Inbox', 'inviteUser' => 'Invite', 'inviteUserSave' => 'Invite', 'acceptInvite' => 'Invite', 'addFriend' => 'Friends', - 'addFriendSave' => 'Friends', 'friendRequest' => 'Friends', - 'friendRequestSave' => 'Friends', 'manageFriends' => 'Friends', - 'removeFriends' => 'Friends', - 'sendMessageToFriends' => 'Friends', 'copyLDAPLink' => 'LDAPLink', 'deleteLDAPLink' => 'LDAPLink', @@ -159,7 +153,6 @@ sub getOperations { 'viewLoginHistory' => 'LoginHistory', 'editProfile' => 'Profile', - 'editProfileSave' => 'Profile', 'viewProfile' => 'Profile', 'deleteProfileCategory' => 'ProfileSettings', diff --git a/lib/WebGUI/Operation/Friends.pm b/lib/WebGUI/Operation/Friends.pm index 6334aab51..350ce1096 100644 --- a/lib/WebGUI/Operation/Friends.pm +++ b/lib/WebGUI/Operation/Friends.pm @@ -25,373 +25,53 @@ Package WebGUI::Operation::Friends Operation handler for handling the friends network. +DEPRECATED - Do not use this package in new code. + =cut #------------------------------------------------------------------- =head2 www_addFriend ( ) -Form for inviting a user to become your friend. +DEPRECATED - See WebGUI::Account::Friends::sendFriendsRequest =cut sub www_addFriend { 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)) { - my $returnToProfile = sprintf($i18n->get('add to friends profile'),$protoFriend->getFirstName); - my $backUrl = $session->url->append($session->url->getRequestedUrl, 'op=viewProfile;uid='.$friendId); - return $session->style->userStyle( - sprintf($i18n->get("error user is already friend"),$backUrl,$returnToProfile) - ); - } - elsif($friends->isInvited($friendId)) { - my $returnToProfile = sprintf($i18n->get('add to friends profile'),$protoFriend->getFirstName); - my $backUrl = $session->url->append($session->url->getRequestedUrl, 'op=viewProfile;uid='.$friendId); - return $session->style->userStyle( - sprintf($i18n->get("error user is already invited"),$backUrl,$returnToProfile) - ); - } - - # Check for non-existant user id. - if ((!$protoFriend->username) || (!$protoFriend->profileField('ableToBeFriend'))) { - my $output = sprintf qq!

    %s

    \n

    %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("

    %s

    \n", $i18n->get('add to friends')), - '

    ', - 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

    \n

    %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

    %s

    %s

    %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

    \n

    %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

    \n

    %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

    \n

    %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("

    %s

    \n", $i18n->get('friend request')), - '

    ', - 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

    \n

    %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

    \n

    %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

    \n

    %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

    \n

    %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

    \n

    %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

    \n

    %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

    \n

    %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} =~ /\
    {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 .= '

  • '.$field->getLabel.' '.$i18n->get(451).'
  • '; - } elsif ($field->getId eq "email" && isDuplicateEmail($session,$data{$field->getId}) && WebGUI::ProfileField->new($session, "email")->isRequired() ) { - $warning .= '
  • '.$i18n->get(1072).'
  • '; - } - if ($field->getId eq "language" && $fieldValue ne "") { - unless (exists $i18n->getLanguages()->{$fieldValue}) { - $error .= '
  • '.$field->getLabel.' '.$i18n->get(451).'
  • '; - } - } - } - return (\%data, $error, $warning); + + my $retHash = $session->user->validateProfileDataFromForm($fields); + + use Data::Dumper; + print Dumper($retHash)."\n\n\n"; + + my $warnings = $retHash->{warnings}; + my $errors = $retHash->{errors}; + + my $format = "
  • %s
  • "; + my $warning = ""; + my $error = ""; + map { $warning .= sprintf($format,$_) }@{$warnings}; + map { $error .= sprintf($format,$_) }@{$errors}; + + return ($retHash->{profile},$error,$warning); } #------------------------------------------------------------------- =head2 www_editProfile ( session ) -Provide a form where user profile data can be entered or edited. The subroutine -makes a large set of template variables which are passed to a template for presentation -and styling. The default template is PBtmpl0000000000000051 and is not user -selectable. - -DEPRECATED - Use WebGUI::Account::Profile::www_edit - -Calls www_editProfileSave on submission. +DEPRECATED - This method is deprecated, and should not be used in new code. +Use WebGUI::Account::Profile::www_edit =head3 session @@ -209,91 +196,18 @@ A reference to the current session. =cut sub www_editProfile { - my $session = shift; - return WebGUI::Operation::Auth::www_auth($session,"init") if($session->user->isVisitor); - my $i18n = WebGUI::International->new($session); - my $vars = {}; - $vars->{displayTitle} .= $i18n->get(338); - $vars->{'profile.message'} = $_[0] if($_[0]); - $vars->{'profile.form.header'} = "\n\n".WebGUI::Form::formHeader($session,{}); - $vars->{'profile.form.footer'} = WebGUI::Form::formFooter($session,); - - $vars->{'profile.form.hidden'} = WebGUI::Form::hidden($session,{"name"=>"op","value"=>"editProfileSave"}); - $vars->{'profile.form.hidden'} .= WebGUI::Form::hidden($session,{"name"=>"uid","value"=>$session->user->userId}); - my @array = (); - foreach my $category (@{WebGUI::ProfileCategory->getCategories($session)}) { - next unless $category->isEditable; - my @temp = (); - foreach my $field (@{$category->getFields}) { - next unless ($field->isEditable); - next if $field->getId =~ /contentPositions/; - push(@temp, { - 'profile.form.element' => $field->formField, - 'profile.form.element.label' => $field->getLabel, - 'profile.form.element.subtext' => $field->isRequired ? "*" : undef, - 'profile.form.element.extras' => $field->getExtras, - }); - } - push(@array, { - 'profile.form.category' => $category->getLabel, - 'profile.form.category.loop' => \@temp - }); - } - $vars->{'profile.form.elements'} = \@array; - $vars->{'profile.form.submit'} = WebGUI::Form::submit($session,{}); - $vars->{'profile.form.cancel'} = WebGUI::Form::button($session,{ - value => $i18n->get('cancel'), - extras=>q|onclick="history.go(-1);" class="backwardButton"|, - }); - $vars->{'profile.accountOptions'} = WebGUI::Operation::Shared::accountOptions($session); - return $session->style->userStyle(WebGUI::Asset::Template->new($session, $session->setting->get('editUserProfileTemplate'))->process($vars)); + my $session = shift; + my $instance = WebGUI::Content::Account->createInstance($session,"profile"); + return $instance->displayContent($instance->callMethod("edit")); } -#------------------------------------------------------------------- - -=head2 www_editProfileSave ( session ) - -Validates all data submitted by www_editProfile. If errors or warnings are present, -they are concatenated and sent back to www_editProfile for display and to let the user -correct their mistakes. - -If no mistakes are present, saves the data to the user's profile, updates the session user -object. - -Returns the user to WebGUI::Operation::Auth::www_auth when done. - - -DEPRECATED: Use WebGUI::Account::Profile::www_editSave - -=head3 session - -A reference to the current session. - -=cut - -sub www_editProfileSave { - my $session = shift; - my ($profile, $error, $warning); - return WebGUI::Operation::Auth::www_auth($session, "init") if ($session->user->isVisitor); - ($profile, $error, $warning) = validateProfileData($session); - $error .= $warning; - return www_editProfile($session, '
      '.$error.'
    ') if($error ne ""); - foreach my $fieldName (keys %{$profile}) { - $session->user->profileField($fieldName,$profile->{$fieldName}); - } - return WebGUI::Operation::Auth::www_auth($session); -} #------------------------------------------------------------------- =head2 www_viewProfile ( session ) -View the profile data for a user by the userId specified by the form variable C. -Validates that the user requesting the profile data is allowed to see it. -Similarly to www_editProfile, this method is templated. The default template -is PBtmpl0000000000000052. The template is not user selectable. - -DEPRECATED: Use WebGUI::Account::Profile::www_view +DEPRECATED: This method is deprecated, and should not be used in new code. +Use WebGUI::Account::Profile::www_view =head3 session @@ -302,46 +216,10 @@ A reference to the current session. =cut sub www_viewProfile { - my $session = shift; - my $u = WebGUI::User->new($session,$session->form->process("uid")); - my $i18n = WebGUI::International->new($session); - my $vars = {}; - $vars->{displayTitle} = $i18n->get(347).' '.$u->username; - - return $session->privilege->notMember() if($u->username eq ""); - - 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); - - my @array = (); - foreach my $category (@{WebGUI::ProfileCategory->getCategories($session)}) { - next unless ($category->get("visible")); - push(@array, {'profile.category' => $category->getLabel}); - foreach my $field (@{$category->getFields}) { - next unless ($field->get("visible")); - next if ($field->get("fieldName") eq "email" && !$u->profileField("publicEmail")); - push @array, { - 'profile.label' => $field->getLabel, - 'profile.value' => $field->formField(undef,2,$u), - 'profile.extras' => $field->getExtras, - }; - } - } - $vars->{'profile.elements'} = \@array; - - if ($session->user->userId eq $session->form->process("uid")) { - $vars->{'profile.accountOptions'} = WebGUI::Operation::Shared::accountOptions($session); - } - else { - ## TODO: Make this more legible code, maybe refactor into a method - push @{$vars->{'profile.accountOptions'}}, { - 'options.display' => '
    userId).'">'.$i18n->get('add to friends list', 'Friends').'', - }, { - 'options.display' => ''.$i18n->get('send private message').'', - }; - } - - return $session->style->userStyle(WebGUI::Asset::Template->new($session, $session->setting->get('viewUserProfileTemplate'))->process($vars)); + my $session = shift; + my $uid = $session->form->process("uid"); + my $instance = WebGUI::Content::Account->createInstance($session,"profile"); + return $instance->displayContent($instance->callMethod("view",[],$uid)); } diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 1c4e83f00..83bc16eb5 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -226,34 +226,7 @@ sub definition { namespace=>"AdminConsole", defaultValue=>$setting->get("AdminConsoleTemplate") }); - # messaging settings - push(@fields, { - tab=>"messaging", - fieldType=>"template", - name=>"viewInboxTemplateId", - label=>$i18n->get('view inbox template'), - hoverHelp=>$i18n->get('view inbox template description'), - namespace=>"Inbox", - defaultValue=>$setting->get("viewInboxTemplateId"), - }); - push(@fields, { - tab=>"messaging", - fieldType=>"template", - name=>"viewInboxMessageTemplateId", - label=>$i18n->get('view inbox message template'), - hoverHelp=>$i18n->get('view inbox message template description'), - namespace=>"Inbox/Message", - defaultValue=>$setting->get("viewInboxMessageTemplateId"), - }); - push(@fields, { - tab=>"messaging", - fieldType=>"template", - name=>"sendPrivateMessageTemplateId", - label=>$i18n->get('send private message template'), - hoverHelp=>$i18n->get('send private message template description'), - namespace=>"Inbox/SendPrivateMessage", - defaultValue=>$setting->get("sendPrivateMessageTemplateId"), - }); + # messaging settings push(@fields, { tab=>"messaging", fieldType=>"text", @@ -444,15 +417,6 @@ sub definition { namespace=>"userInvite/Email", defaultValue=>$setting->get("userInvitationsEmailTemplateId"), }); - push(@fields, { - tab => "user", - fieldType => "template", - defaultValue => "managefriends_________", - namespace => "friends/manage", - name => "manageFriendsTemplateId", - label => $i18n->get("manage friends template", "Friends"), - hoverHelp => $i18n->get("manage friends template help", "Friends"), - }); push @fields, { tab => "user", name => "showMessageOnLogin", @@ -485,24 +449,7 @@ sub definition { hoverHelp => $i18n->get( 'showMessageOnLoginBody description' ), defaultValue => $setting->get('showMessageOnLoginBody'), }; - push @fields, { - tab => "user", - name => 'viewUserProfileTemplate', - fieldType => 'template', - namespace => 'Operation/Profile/View', - label => $i18n->get( 'user profile view template' ), - hoverHelp => $i18n->get( 'user profile view template description' ), - defaultValue => $setting->get('viewUserProfileTemplate'), - }; - push @fields, { - tab => "user", - name => 'editUserProfileTemplate', - fieldType => 'template', - namespace => 'Operation/Profile/Edit', - label => $i18n->get( 'user profile edit template' ), - hoverHelp => $i18n->get( 'user profile edit template description' ), - defaultValue => $setting->get('editUserProfileTemplate'), - }; + # auth settings my $options; foreach (@{$session->config->get("authMethods")}) { @@ -638,14 +585,18 @@ sub www_editSettings { #Create the instance my $className = $account->{className}; my $instance = eval { WebGUI::Pluggable::instanciate($className,"new",[ $session ]) }; - - if ( my $e = WebGUI::Error->caught ) { + if ( $@ ) { $session->log->warn("Could not instantiate account pluggin $className...skipping"); next; } #Get the content of the settings form from the instance - my $settingsForm = $instance->editSettingsForm; + my $settingsForm = eval { $instance->editSettingsForm }; + if( $@ ) { + $session->log->warn("Error calling editSettingsForm in $className...skipping : ".$@); + next; + } + #If editUserSettingsForm is empty, skip it next if $settingsForm eq ""; @@ -710,7 +661,12 @@ sub www_saveSettings { next; } #Save the settings - $instance->editSettingsFormSave; + eval { $instance->editSettingsFormSave }; + + if( my $e = WebGUI::Error->caught ) { + $session->log->warn("Error calling editSettingsFormSave in $className...skipping : ".$e->error); + next; + } } diff --git a/lib/WebGUI/Operation/Shared.pm b/lib/WebGUI/Operation/Shared.pm index f2354d022..8b11d46b5 100644 --- a/lib/WebGUI/Operation/Shared.pm +++ b/lib/WebGUI/Operation/Shared.pm @@ -27,71 +27,18 @@ Shared routines for WebGUI Operations. TODO: DOCUMENT ME +DEPRECATED - USE WebGUI::Account::User->appendAccountOptions + =cut #------------------------------------------------------------------- sub accountOptions { my $session = shift; - my $i18n = WebGUI::International->new($session); - my @array; - my $op = $session->form->process("op"); - if ($session->user->isInGroup(12)) { - my %hash; - if ($session->var->isAdminOn) { - $hash{'options.display'} .= ''.$i18n->get(12).''; - } else { - $hash{'options.display'} .= ''.$i18n->get(63).''; - } - push(@array,\%hash); - } - unless ($op eq "displayAccount"){ - my %hash; - $hash{'options.display'} = ''.$i18n->get(342).''; - push(@array,\%hash); - } - unless ($op eq "editProfile"){ - my %hash; - $hash{'options.display'} = ''.$i18n->get(341).''; - push(@array,\%hash); - } - unless ($op eq "viewProfile"){ - my %hash; - $hash{'options.display'} = ''.$i18n->get(343).''; - push(@array,\%hash); - } - unless ($op eq "viewInbox"){ - my %hash; - $hash{'options.display'} = ''.$i18n->get(354).''; - push(@array,\%hash); - } - push(@array, {'options.display' => ''.$i18n->get('my purchases', 'Shop').''}); - - if ($session->setting->get('userInvitationsEnabled')) { - push @array, { - 'options.display' => sprintf('%s', $session->url->page('op=inviteUser'), $i18n->get('invite a friend')), - }; - } - unless ($op eq "manageFriends") { - push @array, { - 'options.display' => sprintf('%s', $session->url->page('op=manageFriends'), $i18n->get('see my friends', 'Friends')), - }; - } - my %logout; - $logout{'options.display'} = ''.$i18n->get(64).''; - push(@array,\%logout); - if ($session->setting->get("selfDeactivation") && !$session->user->isAdmin){ - my %hash; - $hash{'options.display'} = ''.$i18n->get(65).''; - push(@array,\%hash); - } - { ##Return to site link - my %hash; - $hash{'options.display'} = ''.$i18n->get(493).''; - push(@array,\%hash); - } - - return \@array; + my $vars = {}; + WebGUI::Account->appendAccountLinks($session,$vars); + + return $vars->{'account.options'}; } diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index ec4a493d2..690b0cd61 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -484,15 +484,13 @@ value to check for duplicates against =cut sub isDuplicate { - my $self = shift; - my $session = $self->session; - - my $fieldId = $self->getId; - my $value = shift; - - my $sql = qq{select count(*) from userProfileData where $fieldId = ? and userId <> ?}; - my ($duplicate) = $session->db->quickArray($sql,[$value, $session->user->userId]); + my $self = shift; + my $session = $self->session; + my $fieldId = $self->getId; + my $value = shift; + my $sql = qq{select count(*) from userProfileData where $fieldId = ? and userId <> ?}; + my $duplicate = $session->db->quickScalar($sql,[$value, $session->user->userId]); return ($duplicate > 0); } diff --git a/lib/WebGUI/Shop/Transaction.pm b/lib/WebGUI/Shop/Transaction.pm index f9599cacd..6f977ac15 100644 --- a/lib/WebGUI/Shop/Transaction.pm +++ b/lib/WebGUI/Shop/Transaction.pm @@ -519,7 +519,12 @@ Displays the default thank you page. sub thankYou { my ($self) = @_; my $i18n = WebGUI::International->new($self->session,'Shop'); - return $self->www_viewMy($self->session, $self, $i18n->get('thank you message')); + #return $self->www_viewMy($self->session, $self, $i18n->get('thank you message')); + + #Otherwise wrap the template into the account layout + my $args = [$self,$i18n->get('thank you message')]; + my $instance = WebGUI::Content::Account->createInstance($self->session,"shop"); + return $instance->displayContent($instance->callMethod("viewTransaction",$args)); } @@ -821,6 +826,8 @@ STOP Display a quick list of the user's transactions, with links for more detailed information about each one in the list. +DEPRECATED - Use WebGUI::Account::Shop + =cut sub www_manageMy { diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 0f07d3b35..228a0b066 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -226,13 +226,10 @@ sub addFileFromFormPost { require Apache2::Upload; my $filename; my $attachmentCount = 1; - $self->session->log->warn("trying to uplaod: ".$formVariableName); foreach my $upload ($self->session->request->upload($formVariableName)) { - $self->session->errorHandler->warn("Trying to get " . $upload->filename); + $self->session->errorHandler->info("Trying to get " . $upload->filename); return $filename if $attachmentCount > $attachmentLimit; my $tempFilename = $upload->filename(); - $self->session->log->warn("templFile is: ".$tempFilename); - next unless $tempFilename; next unless $upload->size > 0; next if ($upload->size > 1024 * $self->session->setting->get("maxAttachmentSize")); diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 57c63ab34..64a6fd55b 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -129,7 +129,7 @@ sub acceptsPrivateMessages { return $sentBy->isInGroup($friendsGroup->getId); } - return 1; + return 0; } #------------------------------------------------------------------- @@ -145,16 +145,19 @@ WebGUI::User object to check to see if user will accept requests from. =cut sub acceptsFriendsRequests { - my $self = shift; - my $user = shift; + my $self = shift; + my $session = $self->session; + my $user = shift; return 0 unless ($user && ref $user eq "WebGUI::User"); #Sanity checks return 0 if($self->isVisitor); #Visitors can't have friends return 0 if($self->userId eq $user->userId); #Can't be your own friend (why would you want to be?) - my $friends = WebGUI::Friends->new($self->session,$self); - return 0 if ($friends->isFriend($user->userId)); #Already a friend - return 0 if ($friends->isInvited($user->userId)); #Invitation already sent + my $me = WebGUI::Friends->new($session,$self); + my $friend = WebGUI::Friends->new($session,$user); + + return 0 if ($me->isFriend($user->userId)); #Already a friend + return 0 if ($me->isInvited($user->userId) || $friend->isInvited($self->userId)); #Invitation sent by one or the other return $self->profileField('ableToBeFriend'); #Return profile setting } @@ -802,6 +805,37 @@ sub profileField { return $self->{_profile}{$fieldName}; } +#------------------------------------------------------------------- + +=head2 profileIsViewable ( user ) + +Returns whether or not the user's profile is viewable by the user passed in + +=head3 user + +The user to test to see if the profile is viewable for. If no user is passed in, +the current user in session will be tested + +=cut + +sub profileIsViewable { + my $self = shift; + my $user = shift || $self->session->user; + my $userId = $user->userId; + + return 0 if ($self->isVisitor); #Can't view visitor's profile + return 1 if ($self->userId eq $userId); #Users can always view their own profile + + my $profileSetting = $self->profileField('publicProfile'); + + return 0 if ($profileSetting eq "none"); + return 1 if ($profileSetting eq "all"); + + my $friendsGroup = $self->friends; + return $user->isInGroup($friendsGroup->getId); +} + + #------------------------------------------------------------------- =head2 referringAffiliate ( [ value ] ) @@ -890,6 +924,28 @@ sub uncache { $cache->delete; } + +#------------------------------------------------------------------- + +=head2 updateProfileFields ( profile ) + +Saves profile data to a user's profile. Does not validate any of the data. + +=head3 profile + +Hash ref of key/value pairs of data in the users's profile to update. + +=cut + +sub updateProfileFields { + my $self = shift; + my $profile = shift; + + foreach my $fieldName (keys %{$profile}) { + $self->profileField($fieldName,$profile->{$fieldName}); + } +} + #------------------------------------------------------------------- =head2 username ( [ value ] ) @@ -929,6 +985,78 @@ sub userId { #------------------------------------------------------------------- +=head2 validateProfileDataFromForm ( fields ) + +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 fields + +An array reference of profile field Ids to validate. + +=cut + +sub validateProfileDataFromForm { + my $self = shift; + my $session = $self->session; + my $fields = shift; + + my $i18n = my $i18n = WebGUI::International->new($session); + + 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); + push (@{$errors}, sprintf($i18n->get("language not available 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(1072)); + push(@{$warnFields},$fieldId); + } + } + + return { + profile => $data, + errors => $errors, + warnings => $warnings, + errorCategory => $errorCat, + errorFields => $errorFields, + warningFields => $warnFields, + }; +} + +#------------------------------------------------------------------- + =head2 validUserId ( userId ) Returns true if the userId exists in the users table. diff --git a/lib/WebGUI/i18n/English/Account_Friends.pm b/lib/WebGUI/i18n/English/Account_Friends.pm index 83a41ffba..3e757b109 100644 --- a/lib/WebGUI/i18n/English/Account_Friends.pm +++ b/lib/WebGUI/i18n/English/Account_Friends.pm @@ -9,6 +9,244 @@ our $I18N = { context => q{Tab label for Friends Account pluggin}, }, + 'friends style template label' => { + message => q|Style Template|, + lastUpdated => 1119068809 + }, + + 'friends style template hoverHelp' => { + message => q|Select a style template from the list to enclose friends in.|, + lastUpdated => 1119068809 + }, + + 'friends layout template label' => { + message => q|Edit Layout Template|, + lastUpdated => 1119068809 + }, + + 'friends layout template hoverHelp' => { + message => q{Choose a layout from the list to display the various account pluggins that are editable by the current user as well as the contents of the one currently chosen}, + lastUpdated => 1119068809 + }, + + 'friends view template label' => { + message => q|View Template|, + lastUpdated => 1119068809 + }, + + 'friends view template hoverHelp' => { + message => q|Choose the main template for viewing friends|, + lastUpdated => 1119068809 + }, + + 'friends edit template label' => { + message => q|Edit Template|, + lastUpdated => 1119068809 + }, + + 'friends edit template hoverHelp' => { + message => q|Choose the template for editing friends|, + lastUpdated => 1119068809 + }, + + 'friends send request template label' => { + message => q|Send Friends Request Template|, + lastUpdated => 1119068809 + }, + + 'friends send request template hoverHelp' => { + message => q|Choose the template for sending friends requests|, + lastUpdated => 1119068809 + }, + + 'friends confirm template label' => { + message => q|Friends Request Confirm Template|, + lastUpdated => 1119068809 + }, + + 'friends confirm template hoverHelp' => { + message => q|Choose the template for displaying confirmation that a friends request has been sent|, + lastUpdated => 1119068809 + }, + + 'friends remove confirm template label' => { + message => q|Friends Removal Confirm Template|, + lastUpdated => 1119068809 + }, + + 'friends remove confirm template hoverHelp' => { + message => q|Choose the template for displaying confirmation that you wish to remove a friend|, + lastUpdated => 1119068809 + }, + + 'friends error template label' => { + message => q|Error Template|, + lastUpdated => 1119068809 + }, + + 'friends error template hoverHelp' => { + message => q|Choose the template for displaying friends errors|, + lastUpdated => 1119068809 + }, + + 'back label' => { + message => q{back to site}, + lastUpdated => 1119068809 + }, + + 'edit my profile' => { + message => q|edit my profile|, + lastUpdated => 1068703399 + }, + + 'profile as others label' => { + message => q{view my profile as others see it}, + lastUpdated => 1119068809 + }, + + 'error label' => { + message => q{Error}, + lastUpdated => 1225724810, + }, + + 'member since' => { + message => q{Member Since }, + lastUpdated => 1119068809 + }, + + 'add to network label' => { + message => q{Add to Network}, + lastUpdated => 1119068809 + }, + + 'back to profile label' => { + message => q{back to profile}, + lastUpdated => 1225724810, + }, + + 'adding user message' => { + message => q{You are adding %s to your network.}, + lastUpdated => 1225724810, + }, + + 'sending to message' => { + message => q{The following message will be sent along with your invitation:}, + lastUpdated => 1225724810, + }, + + 'default friend comments' => { + message => q{%s, +I'd like you to be a part of my friends network. + +Thanks, +%s}, + lastUpdated => 1225724810, + }, + + 'send invite button label' => { + message => q{Send Invitation}, + lastUpdated => 1225724810, + }, + + 'cancel button label' => { + message => q{Cancel}, + lastUpdated => 1225724810, + }, + + 'error user is already friend' => { + message => q{This user is already a member of your friends network}, + lastUpdated => 1181493546, + }, + + 'error user is already invited' => { + message => q{You have already sent an invitation for this user to join your friends network}, + lastUpdated => 1181493546, + }, + + 'does not want to be a friend' => { + message => q{This user prefers not to be added as a friend.}, + lastUpdated => 1186264488, + }, + + '' => { + message => q{}, + lastUpdated => 1225724810, + }, + + 'back to user profile' => { + message => q{back to users profile}, + lastUpdated => 1225724810, + }, + + 'message sent label' => { + message => q{Friends Request Sent}, + lastUpdated => 1181019679, + }, + + 'add to friends confirmation' => { + message => q{An email has been sent to %s for your request to be added to your friends network.}, + lastUpdated => 1186030776, + }, + + 'send private message label' => { + message => q{Send Private Message}, + lastUpdated => 1186030776, + }, + + 'send private message label' => { + message => q{Send Private Message}, + lastUpdated => 1186030776, + }, + + 'remove from friends label' => { + message => q{Remove From Friends}, + lastUpdated => 1186030776, + }, + + 'no friend selected' =>{ + message => q{You have not selected friend to be removed from your friends list}, + lastUpdated => 1186030776, + }, + + 'not a friend error' =>{ + message => q{The user you have selected to remove is not in your friends list.}, + lastUpdated => 1186030776, + }, + + 'remove confirm label' =>{ + message => q{Remove Friend Confirmation}, + lastUpdated => 1186030776, + }, + + 'remove confirm message' =>{ + message => q{Are you sure you want remove %s from your friends list?}, + lastUpdated => 1186030776, + }, + + 'remove confirm yes' =>{ + message => q{yes, remove this user}, + lastUpdated => 1186030776, + }, + + 'remove confirm no' =>{ + message => q{no, I made a mistake}, + lastUpdated => 1186030776, + }, + + 'friend removed' =>{ + message => q{%s was removed from your friends list}, + lastUpdated => 1186030776, + }, + + 'no access' =>{ + message => q{You do not have permission to view this user's friends list}, + lastUpdated => 1186030776, + }, + + 'friends is off' =>{ + message => q{You do not have friends enabled. In order to see this page you must edit your profile and enable the friends setting.}, + lastUpdated => 1186030776, + }, }; diff --git a/lib/WebGUI/i18n/English/Account_Inbox.pm b/lib/WebGUI/i18n/English/Account_Inbox.pm index 39d2732c4..5de408122 100644 --- a/lib/WebGUI/i18n/English/Account_Inbox.pm +++ b/lib/WebGUI/i18n/English/Account_Inbox.pm @@ -79,13 +79,23 @@ our $I18N = { lastUpdated => 1119068809 }, - 'invitation error message template label' => { - message => q|Inbox Error Message Template|, + 'invitation confirm message template label' => { + message => q|Invitation Confirmation Message Template|, lastUpdated => 1119068809 }, - 'invitation error message template hoverHelp' => { - message => q|Choose the template for viewing inbox errors|, + 'invitation confirm message template hoverHelp' => { + message => q|Choose the template for viewing invitation confirmations|, + lastUpdated => 1119068809 + }, + + 'inbox view invitation template label' => { + message => q|View Invitation Template|, + lastUpdated => 1119068809 + }, + + 'inbox view invitation template hoverHelp' => { + message => q|Choose the template for viewing an invitation|, lastUpdated => 1119068809 }, @@ -279,6 +289,72 @@ our $I18N = { lastUpdated => 1181019679, }, + 'error label' => { + message => q{Error}, + lastUpdated => 1225724810, + }, + + 'invitation label' => { + message => q{Invitation}, + lastUpdated => 1225724810, + }, + + 'invitation count' => { + message => q{invitations}, + lastUpdated => 1225724810, + }, + + 'invitation message' => { + message => q{%s has invited you to join their friends newtork}, + lastUpdated => 1225724810, + }, + + 'no invitations' => { + message => q{You have no outstanding friends invitations}, + lastUpdated => 1225724810, + }, + + 'accept button label' => { + message => q{Accept}, + lastUpdated => 1225724810, + }, + + 'deny button label' => { + message => q{Deny}, + lastUpdated => 1225724810, + }, + + 'invitation confirm label' => { + message => q{Invitation Notices Sent}, + lastUpdated => 1225724810, + }, + + 'invitation confirm message' => { + message => q{The following users were notified:}, + lastUpdated => 1225724810, + }, + + 'invitations back label' => { + message => q{back to invitations}, + lastUpdated => 1225724810, + }, + + 'invitation does not exist' => { + message => q{The invitation you are trying to view has already been approved or denied.}, + lastUpdated => 1119068809 + }, + + 'no access to invitation' => { + message => q{You do not have permission to view this invitation.}, + lastUpdated => 1119068809 + }, + + 'inviter no longer exists' => { + message => q{The user who sent this invitation is no longer a member of the site.}, + lastUpdated => 1119068809 + }, + + }; 1; diff --git a/lib/WebGUI/i18n/English/Account_Profile.pm b/lib/WebGUI/i18n/English/Account_Profile.pm index 27153da32..22f952d89 100644 --- a/lib/WebGUI/i18n/English/Account_Profile.pm +++ b/lib/WebGUI/i18n/English/Account_Profile.pm @@ -59,20 +59,16 @@ our $I18N = { lastUpdated => 1119068809 }, - 'required error' => { - message => q|%s is required.|, - lastUpdated => 1031514049 - }, + 'profile error template label' => { + message => q|Error Template|, + lastUpdated => 1119068809 + }, - 'language not installed error' => { - message => q|%s is not installed. Please select another language|, - lastUpdated => 1031514049 - }, + 'profile error template hoverHelp' => { + message => q|Choose the template to use for displaying profile errors to the user|, + lastUpdated => 1119068809 + }, - 'email already in use error' => { - message => q|The email address is already in use. Please use a different email address.|, - lastUpdated => 1068703399 - }, 'visitor profile restricted' => { message => q|The visitor profile is restricted|, @@ -110,9 +106,56 @@ our $I18N = { }, 'back label' => { - message => q{go back}, + message => q{back to site}, lastUpdated => 1119068809 - } + }, + + 'profile not public error' => { + message => q|This user's profile is not public.|, + lastUpdated => 1043881275 + }, + + 'friends only' => { + message => q|Your profile is viewable to Friends|, + lastUpdated => 1043881275 + }, + + 'private profile' => { + message => q|Your profile is Private|, + lastUpdated => 1043881275 + }, + + 'public profile' => { + message => q|Your profile is Public|, + lastUpdated => 1043881275 + }, + + 'private label' => { + message => q|Private|, + lastUpdated => 1043881275 + }, + + 'public label' => { + message => q|Public|, + lastUpdated => 1043881275 + }, + + 'friends only label' => { + message => q|Friends Only|, + lastUpdated => 1043881275 + }, + + 'error label' => { + message => q{Error}, + lastUpdated => 1225724810, + }, + + 'back to profile label' => { + message => q{back to profile}, + lastUpdated => 1225724810, + }, + + }; 1; diff --git a/lib/WebGUI/i18n/English/Account_Shop.pm b/lib/WebGUI/i18n/English/Account_Shop.pm new file mode 100644 index 000000000..d1671d31b --- /dev/null +++ b/lib/WebGUI/i18n/English/Account_Shop.pm @@ -0,0 +1,40 @@ +package WebGUI::i18n::English::Account_Shop; +use strict; + +our $I18N = { + + 'title' => { + message => q{Shop}, + lastUpdated => 1225724810, + context => q{Tab label for User Account pluggin}, + }, + + 'shop style template label' => { + message => q|Style Template|, + lastUpdated => 1119068809 + }, + + 'shop style template hoverHelp' => { + message => q|Select a style template from the list to enclose the shop tab in.|, + lastUpdated => 1119068809 + }, + + 'shop layout template label' => { + message => q|Layout Template|, + lastUpdated => 1119068809 + }, + + 'shop layout template hoverHelp' => { + message => q{Choose a layout template in which to enclose the content from the various methods within the shop tab}, + lastUpdated => 1119068809 + }, + + 'manage purchases label' => { + message => q{Manage Purchases}, + lastUpdated => 1119068809 + }, + + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Account_User.pm b/lib/WebGUI/i18n/English/Account_User.pm index c18edc6ea..b3163d192 100644 --- a/lib/WebGUI/i18n/English/Account_User.pm +++ b/lib/WebGUI/i18n/English/Account_User.pm @@ -4,11 +4,36 @@ use strict; our $I18N = { 'title' => { - message => q{User}, + message => q{Account}, lastUpdated => 1225724810, context => q{Tab label for User Account pluggin}, }, + 'user style template label' => { + message => q|Style Template|, + lastUpdated => 1119068809 + }, + + 'user style template hoverHelp' => { + message => q|Select a style template from the list to enclose the account tab in.|, + lastUpdated => 1119068809 + }, + + 'user layout template label' => { + message => q|Layout Template|, + lastUpdated => 1119068809 + }, + + 'user layout template hoverHelp' => { + message => q{Choose a layout template in which to enclose the content from the various methods within the account tab}, + lastUpdated => 1119068809 + }, + + 'templates in auth method message' => { + message => q{The display templates for this module can be found in the settings
    for the authentications modules you have installed on your site.
    }, + lastUpdated => 1119068809 + }, + }; diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 68abf64aa..c934cffe3 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -254,6 +254,16 @@ our $I18N = { lastUpdated => 1031514049 }, + 'required error' => { + message => q{%s is required.}, + lastUpdated => 1031514049 + }, + + 'language not available error' => { + message => q|%s is not available. Please select another language|, + lastUpdated => 1031514049 + }, + '454' => { message => q|Last Updated|, lastUpdated => 1031514049 @@ -330,7 +340,7 @@ our $I18N = { }, '861' => { - message => q|Make profile public?|, + message => q|Profile Privacy Setting|, lastUpdated => 1043879954 }, diff --git a/www/extras/account/account.css b/www/extras/account/account.css new file mode 100644 index 000000000..d75c73806 --- /dev/null +++ b/www/extras/account/account.css @@ -0,0 +1,724 @@ + +/* general */ + + body { + margin:0; + padding:0; + font: 11px Verdana; + } + a { + cursor: pointer; + } + button { + cursor: pointer; + } + img { + border: none; + } + .button { + float:right; + padding-right:10px; + } + .centered { + text-align: center; + } + .account_message { + width: 600px; + height: 300px; + border: solid #BECEF8 1px; + margin-left: 50px; + margin-bottom: 20px; + overflow:-moz-scrollbars-vertical; + overflow-x:hidden; + overflow-y:scroll; + background-color: white; + text-align: left; + } + .profileMember { + text-align:right; + margin-right:20px; + font-size:9px; + } + .member { + font: 9px Verdana, Arial, Helvetica, sans-serif; + color:#000000; + text-align:center; + } + .photostyle { + border:solid #9BB4F4 2px; + margin-bottom:5px; + margin-top:5px + } + #rightalign { + float: right; + } + /*.send { + padding-right: 75px; + }*/ + + .Profile_registration { + + } + .Profile_registration td { + font-size:9pt; + font-family:arial; + } + .Profile_registration .tabs a { + text-decoration:none; + background-color:#FEEBC7; + margin-right:10px; + padding:0px 10px 1px 10px; + color:#FDC55B; + font-weight:bold; + border:solid #FDBA42 1px; + } + .Profile_registration .tabs a.active { + background:#FDBA42; + color:black; + } + .Profile_registration .header { + font-size:10px; + font-weight:bold; + text-align:left; + color:#fff; + background-color:#818997; + border-top:solid #FE9515 3px; + text-align:right; + } + .Profile_registration .header a { + color:white; + text-decoration:none; + } + .Profile_registration .help a { + font-weight:bold; + text-decoration:none; + } + + .Profile_registration .inputText { + font-size:10px; + margin-right:1px; + } + .Profile_registration .label { + font-weight:bold; + font-size:9pt; + text-align:right; + white-space:nowrap; + width:1%; + } + .Profile_registration .labelLeft { + font-weight:bold; + font-size:9pt; + text-align:right; + white-space:nowrap; + width:1%; + text-align: left; + vertical-align: top; + } + .Profile_registration .smallLabel { + font-size:8px; + text-align:center; + } + .Profile_registration .smallText { + font-size:9px; + } + .Profile_registration .yourselfBG { + border:solid #CEDBF8 1px; + background-color:#EEF2FD; + color:black; + padding: 2px; + } + /*.Profile_registration .yourselfBG a { + font-weight:bold; + color:#0054ff; + text-decoration:none; + }*/ + .Profile_registration .bar { + background-color:#DDE6FB; + border:solid #BECEF8 1px; + text-align:center; + color:#0B2259; + font-size:14px; + font-weight:bold; + } + + .Profile_registration .bar a { + color:#0B2259; + font-size:10px; + font-weight:bold; + } + +/* profile errors */ + +#profileErrors { + background-color: #ff0000; + font-weight: bold; + color: #ffffff; + text-align: center; +} + +.profilefield_required_off { +} +.profilefield_required { + background-color: #ffffbb; +} +.profilefield_error { + background-color: #FF9494; +} + +/* bio, addtonetwork, network */ + + .bordered { + border-bottom: dashed #BECEF8 2px; + padding-bottom: 10px; + } + .friendpic { + border: solid #BECEF8 1px; + } + .invitemsg { + width: 600px; + height: 150px; + } + ol.Profile_interests { + font-size:15px; + font-weight:bold; + color:#0B2259; + list-style-type:none; + margin:0px; + padding:0px; + padding:5px 5px; + } + ol.Profile_interests li { + margin-bottom:15px; + } + ol.Profile_interests span { + font-weight:normal; + font-size:12px; + color:black; + } + .pBio { + border-bottom:solid #DDE6FB 1px; + margin:0px; + margin-bottom:5px; + padding-bottom:5px; + } + .pBio div { + background-color:#DDE6FB; + padding:2px 5px; + margin-bottom:2px; + } + .program { + font-size: 9px; + } + +/* edit box */ + + .editBox { + font-size:9px; + font-weight:bold; + background:white url(images/edit_box_bg.jpg) no-repeat bottom left; + border:solid #8DABF1 2px; + padding:5px; + width:590px; + -moz-box-sizing:border-box; + font-family:verdana; + z-index:100; + position:absolute; + top:100px; + left:100px; + display:block; + } + .editBox input, .editBox select { + font-size:9px; + } + +/* inbox */ + +.Profile_registration .inboxTitle { + background-color:#DDE6FB; + border:solid #BECEF8 1px; + text-align:center; + font-size:10px; + font-weight:bold; + color:#0B2259; + text-decoration: underline; +} + +/* inbox threads */ + + .evenThread { + background-color: #e1e8fb; + border-bottom: 1px solid #bfcef9; + padding: 4px; + text-align:center; + } + .oddThread { + background-color: #eef2fd; + border-bottom: 1px solid #bfcef9; + padding: 4px; + text-align: center; + } +/* inbox forms */ + +.inbox_from { + color: black; + text-decoration: none; + font-weight: normal; +} + +.inbox_subject { + width: 530px; +} + +.inbox_messageTo { + width: 530px; + height: 50px; + border: solid #BECEF8 1px; + overflow:-moz-scrollbars-vertical; + overflow-x:hidden; + overflow-y:scroll; + background-color: white; +} + +/* inbox contacts */ + .datacells { + border-bottom: dashed #BECEF8 1px; + } + .inbox_contactsTbl { + font-size:9pt; + font-family:arial; + background-color:#EEF2FD; + } + #contacts { + height: 275px; + overflow: auto; + } + +/* pagination */ +.Profile_pagination { + text-align:right; + font-size:10px; +} +.Profile_pagination a { + font-weight:bold; + font-size:10px; + border:solid #BECEF8 1px; + padding:1px 5px; + text-decoration:none; + background-color:#EEF2FD; +} + +.Profile_pagination a:hover { + background-color:#FE9515; + color:white; +} + +.Profile_pagination .prevNext { + border: none; + background-color: transparent; + color: black; +} + +.Profile_pagination .prevNext:hover { + border: none; + background-color: transparent; + color: black; +} + +.Profile_pagination .active { + font-weight:bold; + font-size:10px; + border:solid #BECEF8 1px; + padding:1px 5px; + text-decoration:none; + background-color:#FE9515; + color:white; +} + +/* TABS - outer */ + +.bottombutton { + border: none; + float:right; + padding-right:2px; + padding-top: 2px; + position: relative; +} +.content { + padding:10px; + +} +.subContent { + border: solid #ffa700 6px; +} +.topbutton { + border: none; + float:right; + clear:both; + padding-right:2px; + padding-top: 2px; + position: relative; +} + +ul.topTabs, +ul.topTabs li { + margin:0px; + padding:0px; + list-style-type:none; + position:relative;zoom:1; + width:auto; + + Xposition:relative; +} +ul.topTabs li { + display:block; + float:left; + margin-right: 5px; +} +ul.topTabs li b { + display:block; + position:relative; + top:-1px; + border-top:solid #ffa700 1px; + background-color: #faee9a; + padding:4px 8px; +} +ul.topTabs a { + display:block; + color:#ffa700; + font-size:12px; + font-family: Arial, Helvetica, sans-serif; + text-decoration:none; + background-color:#faee9a; + border-left: solid #ffa700 1px; + border-right: solid #ffa700 1px; +} +ul.topTabs a:hover, +ul.topTabs a:hover b, +ul.topTabs a.selected, +ul.topTabs a.selected b { + background-color:#ffa700; + color:#fff; +} + +/* TABS - YUI */ + +.cleardiv { + clear: both; + margin: 0px 0px 0px 0px; + padding: 0px; +} + +.view { + border: none; + font: bold 10px Verdana; + color: #0b2258; + text-decoration:none; + position: absolute; + right: 4px; + top:4px; +} + +.profile_displayView { + -x-system-font:none; + border:medium none; + color:#0B2258; + display:inline; + float:right; + font-family:Verdana; + font-size:10px; + font-size-adjust:none; + font-stretch:normal; + font-style:normal; + font-variant:normal; + font-weight:bold; + line-height:normal; + padding-right:8px; + padding-top:3px; +} + +.profile_displaySubContent { + border: solid #ffa700 6px; + border-top: solid #ffa700 18px; +} + +/* view profile */ + +.profile_fieldLabel { +background: #DDE6FB; +border: 1px solid white; +} +.profile_fieldData { +margin-left: 5px; +} + + /* +Copyright (c) 2008, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.6.0 +*/ +/* .yui-navset defaults to .yui-navset-top */ +.yui-skin-sam .yui-navset .yui-nav, +.yui-skin-sam .yui-navset .yui-navset-top .yui-nav { /* protect nested tabviews from other orientations */ + border:solid #eef2fd; /* color between tab list and content */ + border-width:0 0 5px; + Xposition:relative; + zoom:1; +} + +.yui-skin-sam .yui-navset .yui-nav li, +.yui-skin-sam .yui-navset .yui-navset-top .yui-nav li { + margin:0 0.3em 0 0; /* space between tabs */ + padding:5px 0 0; /* gecko: make room for overflow */ + zoom:1; +} + +.yui-skin-sam .yui-navset .yui-nav .selected, +.yui-skin-sam .yui-navset .yui-navset-top .yui-nav .selected { + margin:0 0.3em -1px 0; /* for overlap */ +} + +.yui-skin-sam .yui-navset .yui-nav a, +.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a { + background:#9bb4f4; /* tab background */ + border:solid #eef2fd; + border-width:0 1px; + color:#eef2fd; + position:relative; + text-decoration:none; + font-size:12px; + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; +} + +.yui-skin-sam .yui-navset .yui-nav a em, +.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a em { + border:solid #eef2fd; + border-width:1px 0 0; + cursor:hand; + padding:0.25em .75em; + left:0; right: 0; bottom: 0; /* protect from other orientations */ + top:-1px; /* for 1px rounded corners */ + position:relative; +} + +.yui-skin-sam .yui-navset .yui-nav .selected a, +.yui-skin-sam .yui-navset .yui-nav .selected a:focus, /* no focus effect for selected */ +.yui-skin-sam .yui-navset .yui-nav .selected a:hover { /* no hover effect for selected */ + background:#eef2fd; /* selected tab background */ + color:#0a2359; + font-size:12px; + font-family: Arial, Helvetica, sans-serif; + text-decoration:none; + font-weight: bold; +} + +.yui-skin-sam .yui-navset .yui-nav a:hover, +.yui-skin-sam .yui-navset .yui-nav a:focus { + background:#eef2fd; /* selected tab background */ + color:#0a2359; + outline:0; + font-size:12px; + font-family: Arial, Helvetica, sans-serif; + text-decoration:none; + font-weight: bold; + +} + +.yui-skin-sam .yui-navset .yui-nav .selected a, +.yui-skin-sam .yui-navset .yui-nav .selected a em { + border-color:#eef2fd; /* selected tab border color */ +} + +.yui-skin-sam .yui-navset .yui-content { + background:#edf5ff; /* content background color */ +} + +.yui-skin-sam .yui-navset .yui-content, +.yui-skin-sam .yui-navset .yui-navset-top .yui-content { + border:5px solid #eef2fd; /* content border */ + padding:0.75em 1em; /* content padding */ +} + +/* left and right orientations */ +.yui-skin-sam .yui-navset-left .yui-nav, +.yui-skin-sam .yui-navset .yui-navset-left .yui-nav, +.yui-skin-sam .yui-navset .yui-navset-right .yui-nav, +.yui-skin-sam .yui-navset-right .yui-nav { + border-width:0 5px 0 0; + Xposition:absolute; /* from tabview-core; have to reiterate for skin-sam due to pos:rel on skin-sam yui-nav */ + top:0; bottom:0; /* stretch to fill content height */ +} + +.yui-skin-sam .yui-navset .yui-navset-right .yui-nav, +.yui-skin-sam .yui-navset-right .yui-nav { + border-width:0 0 0 5px; +} + +.yui-skin-sam .yui-navset-left .yui-nav li, +.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li, +.yui-skin-sam .yui-navset-right .yui-nav li { + margin:0 0 0.3em; /* space between tabs */ + padding:0 0 0 1px; /* gecko: make room for overflow */ +} + +.yui-skin-sam .yui-navset-right .yui-nav li { + padding:0 1px 0 0; /* gecko: make room for overflow */ +} + +.yui-skin-sam .yui-navset-left .yui-nav .selected, +.yui-skin-sam .yui-navset .yui-navset-left .yui-nav .selected { + margin:0 -1px 0.16em 0; +} + +.yui-skin-sam .yui-navset-right .yui-nav .selected { + margin:0 0 0.16em -1px; +} + +.yui-skin-sam .yui-navset-left .yui-nav a, +.yui-skin-sam .yui-navset-right .yui-nav a { + border-width:1px 0; +} + +.yui-skin-sam .yui-navset-left .yui-nav a em, +.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em, +.yui-skin-sam .yui-navset-right .yui-nav a em { + border-width:0 0 0 1px; + padding:0.2em .75em; + top:auto; + left:-1px; /* for 1px rounded corners */ +} + +.yui-skin-sam .yui-navset-right .yui-nav a em { + border-width:0 1px 0 0; + left:auto; + right:-1px; /* for 1px rounded corners */ +} + +.yui-skin-sam .yui-navset-left .yui-nav a, +.yui-skin-sam .yui-navset-left .yui-nav .selected a, +.yui-skin-sam .yui-navset-left .yui-nav a:hover, +.yui-skin-sam .yui-navset-right .yui-nav a, +.yui-skin-sam .yui-navset-right .yui-nav .selected a, +.yui-skin-sam .yui-navset-right .yui-nav a:hover, +.yui-skin-sam .yui-navset-bottom .yui-nav a, +.yui-skin-sam .yui-navset-bottom .yui-nav .selected a, +.yui-skin-sam .yui-navset-bottom .yui-nav a:hover { + background-image:none; /* no left-right or bottom-top gradient */ +} + +.yui-skin-sam .yui-navset-left .yui-content { + border:1px solid #eef2fd; /* content border */ +} + +/* bottom orientation */ +.yui-skin-sam .yui-navset-bottom .yui-nav, +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav { + border-width:5px 0 0; /* color between tab list and content */ +} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected, +.yui-skin-sam .yui-navset-bottom .yui-nav .selected { + margin:-1px 0.3em 0 0; /* for overlap */ +} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li, +.yui-skin-sam .yui-navset-bottom .yui-nav li { + padding:0 0 1px 0; /* gecko: make room for overflow */ + vertical-align:top; +} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li a, +.yui-skin-sam .yui-navset-bottom .yui-nav li a { +} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav a em, +.yui-skin-sam .yui-navset-bottom .yui-nav a em { + border-width:0 0 1px; + top:auto; + bottom:-1px; /* for 1px rounded corners */ +} + +.yui-skin-sam .yui-navset-bottom .yui-content, +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-content { + border:1px solid #eef2fd; /* content border */ +} + + +.yui-skin-sam { + background-color: #ffa700; + padding: 10px 5 5 5px; + display:block; +} + +/* +Copyright (c) 2008, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.6.0 +*/ +.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{margin:0 0.5em 0 0;} + +.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{margin:0 0 0.5em;} + +.yui-navset .yui-content .yui-hidden{display:none;} + +.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{width:6em;} + +.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{width:auto;}.yui-navset .yui-navset-left,.yui-navset-left{padding:0 0 0 6em;} + +.yui-navset-right {padding:0 6em 0 0;} + +.yui-navset-top,.yui-navset-bottom{padding:auto;} + +.yui-nav,.yui-nav li{margin:0;padding:0;list-style:none;} + +.yui-navset li em{font-style:normal;}.yui-navset{position:relative;zoom:1;} + +.yui-navset .yui-content{zoom:1;} + +.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{display:inline-block;display:-moz-inline-stack;*display:inline;vertical-align:bottom;cursor:pointer;zoom:1;} + +.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{display:block;} + +.yui-navset .yui-nav a{position:relative;} + +.yui-navset .yui-nav li a,.yui-navset-top .yui-nav li a,.yui-navset-bottom .yui-nav li a{display:block;display:inline-block;vertical-align:bottom;zoom:1;} + +.yui-navset-left .yui-nav li a,.yui-navset-right .yui-nav li a{display:block;} + +.yui-navset-bottom .yui-nav li a{vertical-align:text-top;} + +.yui-navset .yui-nav li a em,.yui-navset-top .yui-nav li a em,.yui-navset-bottom .yui-nav li a em{display:block;} + +.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{position:absolute;z-index:1;} + +.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{position:static;} + +.yui-navset .yui-navset-left .yui-nav,.yui-navset-left .yui-nav{left:0;right:auto;} + +.yui-navset .yui-navset-right .yui-nav,.yui-navset-right .yui-nav{right:0;left:auto;} + +.yui-skin-sam .yui-navset .yui-nav .selected a em{padding:0.35em 0.75em;} + +.yui-skin-sam .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 5px 0 0;Xposition:absolute;top:0;bottom:0;} + +.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 0 0 5px;} + +.yui-skin-sam .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset-right .yui-nav li{margin:0 0 0.16em;padding:0 0 0 1px;} + +.yui-skin-sam .yui-navset-right .yui-nav li{padding:0 1px 0 0;} + +.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav a{border-width:1px 0;} + +.yui-skin-sam .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 0 0 1px;padding:0.2em .75em;top:auto;left:-1px;} + +.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 1px 0 0;left:auto;right:-1px;} + +.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-left .yui-nav .selected a,.yui-skin-sam .yui-navset-left .yui-nav a:hover,.yui-skin-sam .yui-navset-right .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav .selected a,.yui-skin-sam .yui-navset-right .yui-nav a:hover,.yui-skin-sam .yui-navset-bottom .yui-nav a,.yui-skin-sam .yui-navset-bottom .yui-nav .selected a,.yui-skin-sam .yui-navset-bottom .yui-nav a:hover{background-image:none;} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected,.yui-skin-sam .yui-navset-bottom .yui-nav .selected{margin:-1px 0.16em 0 0;} + +.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li,.yui-skin-sam .yui-navset-bottom .yui-nav li{padding:0 0 1px 0;vertical-align:top;} + + diff --git a/www/extras/account/images/new.png b/www/extras/account/images/new.png new file mode 100644 index 0000000000000000000000000000000000000000..45d7f067655e815caedbff0accf14d685c0ff16c GIT binary patch literal 452 zcmV;#0XzPQP)@qr@y7eVu5YK!j_>Bbly>^dZ_LIb(`R%sMbMzs)}d8YywQe z3}ec_nD473NxU*haQ^VO*1;XvYZ+qzeIx`h-wdoJ4|}aRjwv}H98%$)1ZF*0!&>sN zH$8w0x-I0Ock!!PYSOGNxf~Eh5pOAl-iLd9hL6rk&ShYZYphvv>{Y7?vKYL*Li;yl zI4$gqIj*^SZ^f}!$*ke7HOUU|5m8t1i=dxuJdX1?vL-5@vNan z{FDjg05M+{US(~tmOQdVxd*<#`5jn-JnZG0*#GQyy|QgXISwk#CRC#VMR~balZMH3 u3Ns$Vj7EruLzpl`LOFX&|Nb|A3ormeM$bB?>xCl#0000;<*x*Red8x|aF=Frvfh!AjOXk(U@kYKpz#KI*Y=itMTaEP&kiA!gNhl7(V RH;><{n3J2H9&BK+1^_N`K7jxL literal 0 HcmV?d00001 diff --git a/www/extras/account/images/no_photo.gif b/www/extras/account/images/no_photo.gif new file mode 100644 index 0000000000000000000000000000000000000000..cd34a822f2fccfc638a9edbd7540ede72e5b699c GIT binary patch literal 390 zcmV;10eSvMNk%w1VKM+R0K@)#UE+_WAn!>hAQ^+UWfK z{^{)V_W1hs_WJ(*|MvI#+TiTV)8xm{;`sUd*WK#gDJuo z(%I<7&*A_7|HRGUA^8LV00000EC2ui05SkF000I5U?+}bX`X1Ru56ora4gSsZQppV z?|fem6~iRrE7}NwjA!Wy7@si>fJq%djhF{@>w#Q*6|NZZ)h)#6NBJf|yVdJi#7+0c zV{JORagQnWVh(*U41j2Z9|wkF9fOLCTNi^9kXwy?T9r(QQ<_VNf0_!2XPy&-1&^K^ zeWjiraB&c?OACDiv`u{yxg3MJM18ZKwur9;h##Sgg2@4z2FV{6nhDY$29TrIACOku z%XHi@oq*$siRjrqLRUvkqzY* kQaRvchXf1%B+^;X&c=Xj8W%O7FoOc6kfJIBdfSn;10^3#$Yh6@MUDDD0~B3Gh2@r>hsT7J(f^PHK^ydrYhWc zDga~VSo@#_Rt_CVPjR$0)zP(7dj2I@qlVhL2chMB#k4xqYvG|{p;QC9V?d%E=#2VZ zzB(}Zr>dXt=@2Mf3$ry#2$7A)<47ie{ACGqqY1Ra;z0@1=>%f;7Ru#vHtf1CGHGD{ z5=`JHP(v*}^oDf@c&_=0R4Rqy^Y>=fsG*h~dM%+>5gzbZ@fWeTi^z;5v2*_3JUIxg z=ZdhWl159=i}{T!b@!qgBr^JPd_<6I*3xUXAaw@;*}=k08n^m5n#mk%&02cRAqI)9 zGhlW&`A*bK)~E^QjYE|BHt${l69X`DD^f!(V{?d7O6=*+GTsk(3cmui^w1mTW310N z|Aq9>Yk8iRTiQGwiACGc*>0gL7BOQ-)Iv1UX5Q$y5*0__wI=XVbgwDPUcv-Dl%9D0M6(>s{jB1 literal 0 HcmV?d00001 diff --git a/www/extras/account/images/save_changes.gif b/www/extras/account/images/save_changes.gif new file mode 100644 index 0000000000000000000000000000000000000000..897b100d48de61aa1c07977f5401bce03eea5952 GIT binary patch literal 1589 zcmV-52Fm$INk%w1VO{_g0Oo%HX=!PQh=|qK;pph-)YQ~TS%OnyiQ(blnxeORhNGIA znv#-|^6~Y;$JMm7w8zKC_V)I{#m_=hesy(q;^gZ1`1tbj^J;gO($(DB+S=UR-iMN` zpr*Rc&dz>`rt$OegN>;C`S-QE$wo#+{{H--p`psn)ig$Rt+T`A;o;`y=I-w7^7Qes zxW>P~zwq$zd&_eMrZWo2b)Xk52$H{1DXvoRN?CkE}-{IQa*|4_4mY%fc41ejE#u{3jj4|l$Dm3XImp$TYe)~n4zMhmRo0_XCtPc zr&_9&H2@0(iV98(9Tr}@yuH3&U|>~gU}R||zsbtWyGvdqWKz&dOVC_ZTuWd|yH6bp zP6~(t6F@gy=;`X~>0nD-Vqjb(V(j+!_~>BqB-!;`#jc6@hfax-8w3CZFr)wr3Nj1Vo}lL9k|Yf&`?aB#0n7PXY{4ejwQJV~p+Fd@(d>@&n2kzz7nE*o`4c0uRHR zh(I7BfsQg^!u&YB!9(;g4V*&{)7&`>4H*bHn4scM1^^v0Xo%3|0tOiH;p31X0mp>{ zG^W4@fddE{94DO6g$yYaSYQ_*7-*mbUCK(XrM<19ZZnHA03FL!2t(c&_#n&m|(_^K%g)M4Q7DQ1rTPOpdSuA_@ILS z0T-B|!jnUEv4;;-Rw;o2X80h%6j}OU0tz%F$-@b1sBpmvD)7*S8fKu-g$hFI7^MjY zoN$B+CIFGb0U7`iz#V@)5C9N)z@WkaIczWm4mfW-1G+2F zy21q#tgwP-@t$DszAIp`0fP~IF#rtTbnu4;0k|;08X`!5!VChK6)_EcP{3gS9C0v< z0|FR3NPz`1ctF?4(kAi73<%IL17Ih6Ai*0n7%+njGgE3c0xk?JPy!5uXt2QJ5Zs_V7uR1O0viCK^A0-K-_sA0_~Z*8K0rEb zumSAqoWF|_5J;_nSA}R$!UQD{FvC6Wzyn4<V84w*aAi(`fpa(>#zy%7J z001UP!3qK(3lyY-9W2N}3vRH3APiv#KM2AJD8L2fQG}xiP=p7#@P$QSLJ{u3ggV^e n0d;sG40XuE9{TWyKm=k7A5er2Xy6NuNTL##$iyc8ArJsNbY1vd literal 0 HcmV?d00001 diff --git a/www/extras/account/inbox.js b/www/extras/account/inbox.js new file mode 100644 index 000000000..16823857a --- /dev/null +++ b/www/extras/account/inbox.js @@ -0,0 +1,64 @@ +YAHOO.util.Event.onDOMReady(function() { + if(YAHOO.util.Dom.inDocument("friends")) { + + var isUserCheckBox = function ( element ) { + if(element.name == "friend") return true; + return false; + } + + var removeUser = function (evt, obj) { + YAHOO.util.Event.stopEvent(evt); + var userId = obj.userId; + var checkBox = YAHOO.util.Dom.get("friend_"+userId+"_id"); + checkBox.checked = false; + updateUsers(evt,obj.dialog); + } + + var updateUsers = function ( evt , dialog ) { + YAHOO.util.Event.stopEvent(evt); + var toElement = YAHOO.util.Dom.get("messageTo"); + toElement.innerHTML = ""; // Clear the current stuff + YAHOO.util.Dom.removeClass(toElement,"inbox_messageTo"); + + var checkBoxes = YAHOO.util.Dom.getElementsBy(isUserCheckBox,"INPUT","contacts"); + for (var i = 0; i < checkBoxes.length; i++) { + if(checkBoxes[i].checked) { + var friendName = YAHOO.util.Dom.get("friend_"+checkBoxes[i].value+"_name").innerHTML; + var firstPart = document.createTextNode(friendName + " ( "); + var link = document.createElement("A"); + link.setAttribute('href', '#'); + link.innerHTML = removeText; + YAHOO.util.Event.addListener(link,"click",removeUser,{ userId: checkBoxes[i].value, dialog: dialog }); + var lastPart = document.createTextNode(" ); "); + toElement.appendChild(firstPart); + toElement.appendChild(link); + toElement.appendChild(lastPart); + } + } + YAHOO.util.Dom.addClass(toElement,"inbox_messageTo"); + dialog.hide(); + } + + var showUsers = function (evt, dialog) { + YAHOO.util.Event.stopEvent(evt); + dialog.show(); + } + + // Instantiate the Dialog + var dialog1 = new YAHOO.widget.Dialog("friends", { + width : "340px", + fixedcenter : true, + visible : false, + constraintoviewport : false + }); + + // Render the Dialog + dialog1.render(); + + YAHOO.util.Event.addListener("show_friends", "click", showUsers, dialog1); + YAHOO.util.Event.addListener("cancel_top", "click", dialog1.hide, dialog1, true); + YAHOO.util.Event.addListener("cancel_bottom", "click", dialog1.hide, dialog1, true); + YAHOO.util.Event.addListener("update_top", "click", updateUsers, dialog1); + YAHOO.util.Event.addListener("update_bottom", "click", updateUsers, dialog1); + } +}); \ No newline at end of file