diff --git a/docs/upgrades/packages-7.7.6/root_import_account_friendmanager.wgpkg b/docs/upgrades/packages-7.7.6/root_import_account_friendmanager.wgpkg new file mode 100644 index 000000000..956a30869 Binary files /dev/null and b/docs/upgrades/packages-7.7.6/root_import_account_friendmanager.wgpkg differ diff --git a/docs/upgrades/upgrade_7.7.5-7.7.6.pl b/docs/upgrades/upgrade_7.7.5-7.7.6.pl index 06f90a60a..02ff94694 100644 --- a/docs/upgrades/upgrade_7.7.5-7.7.6.pl +++ b/docs/upgrades/upgrade_7.7.5-7.7.6.pl @@ -22,6 +22,7 @@ use Getopt::Long; use WebGUI::Session; use WebGUI::Storage; use WebGUI::Asset; +use WebGUI::Utility; my $toVersion = "7.7.6"; my $quiet; @@ -44,6 +45,8 @@ installSMSUserProfileFields($session); installSMSSettings($session); upgradeSMSMailQueue($session); addPayDrivers($session); +installFriendManagerSettings($session); +installFriendManagerConfig($session); finish($session); @@ -231,6 +234,35 @@ sub addPayDrivers { print "DONE!\n" unless $quiet; } +sub installFriendManagerSettings { + my $session = shift; + print "\tInstalling FriendManager into settings..."; + $session->setting->add('groupIdAdminFriends', '3'); + $session->setting->add('fmViewTemplateId', '64tqS80D53Z0JoAs2cX2VQ'); + $session->setting->add('fmEditTemplateId', 'lG2exkH9FeYvn4pA63idNg'); + $session->setting->add('groupsToManageFriends', '2'); + $session->setting->add('overrideAbleToBeFriend', 0); + print "\tDone\n"; +} + +sub installFriendManagerConfig { + my $session = shift; + my $config = $session->config; + my $account = $config->get('account'); + my @classes = map { $_->{className} } @{ $account }; + return if isIn('WebGUI::Account::FriendManager', @classes); + print "\tInstalling FriendManager into config file..."; + push @{ $account }, + { + identifier => 'friendManager', + title => '^International(title,Account_FriendManager);', + className => 'WebGUI::Account::FriendManager', + } + ; + $config->set('account', $account); + print "\tDone\n"; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index b02bcef56..64e529421 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -700,6 +700,11 @@ "title" : "^International(title,Account_User);", "className" : "WebGUI::Account::User" }, + { + "identifier" : "friendManager", + "title" : "^International(title,Account_FriendManager);", + "className" : "WebGUI::Account::FriendManager" + }, ], # Specify which of the modules in the above list is used diff --git a/lib/WebGUI/Account.pm b/lib/WebGUI/Account.pm index 907cff3e3..5727469bd 100644 --- a/lib/WebGUI/Account.pm +++ b/lib/WebGUI/Account.pm @@ -87,8 +87,6 @@ Optionally set bare to be true, or false. =cut -public bare => my %bare; - #------------------------------------------------------------------- =head2 store ( [ hashRef ] ) @@ -102,7 +100,9 @@ A hash reference of data to store. =cut public store => my %store; #This is an all purpose hash to store stuff in: $self->store->{something} = "something" - +public bare => my %bare; #This flag indicates that neither the layout nor style template should be applied + #to the output of the method. Think JSON/XML, etc. + #------------------------------------------------------------------- =head2 appendCommonVars ( var ) @@ -211,6 +211,9 @@ sub displayContent { ##Don't do any templating if we're sending back data like JSON or XML. return $content if $self->bare; + ##Don't do any templating if we're sending back data like JSON or XML. + return $content if $self->bare; + #Wrap content into the layout my $var = {}; $var->{content} = $content; @@ -437,6 +440,7 @@ sub new { $store { $id } = {}; $method { $id } = "view"; $uid { $id } = undef; + $bare { $id } = 0; return $self; } diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 03c7f130a..c70516aca 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -49,16 +49,16 @@ sub appendCommonVars { my $session = $self->session; my $var = shift; my $inbox = shift || WebGUI::Inbox->new($session); - my $user = $session->user; + my $user = $self->getUser; my $method = $self->method; $self->SUPER::appendCommonVars($var); - $var->{'view_inbox_url' } = $self->getUrl("module=inbox;do=view"); + $var->{'view_inbox_url' } = $self->getUrl("module=inbox;do=view", 'useUid'); $var->{'view_invitations_url' } = $self->getUrl("module=inbox;do=manageInvitations"); - $var->{'unread_message_count' } = $inbox->getUnreadMessageCount; + $var->{'unread_message_count' } = $inbox->getUnreadMessageCount($user->userId); $var->{'invitation_count' } = $self->getInvitationCount; - $var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend'); + $var->{'invitations_enabled' } = $user->profileField('ableToBeFriend'); $var->{'user_invitations_enabled'} = $session->setting->get("inboxInviteUserEnabled"); $var->{'invite_friend_url' } = $self->getUrl("module=inbox;do=inviteUser"); @@ -77,7 +77,9 @@ Returns whether or not the user can view the inbox tab sub canView { my $self = shift; - return ($self->uid eq ""); + my $session = $self->session; + return $self->uid eq "" + || $self->uid ne "" && $session->user->isInGroup($session->setting->get('groupIdAdminUser')); } #------------------------------------------------------------------- @@ -1321,7 +1323,8 @@ The main view page for editing the user's profile. sub www_view { my $self = shift; my $session = $self->session; - my $user = $session->user; + my $user = $self->getUser; + my $var = {}; $self->store->{tab} = "inbox"; @@ -1343,7 +1346,7 @@ sub www_view { my $userFilter_url = ";userFilter=$userFilter"; #Cache the base url - my $inboxUrl = $self->getUrl; + my $inboxUrl = $self->getUrl('', 'useUid'); my $urlFrag = $sortDir_url . $rpp_url . $userFilter_url; @@ -1366,7 +1369,7 @@ sub www_view { if ($userFilter ne 'all') { $messageOptions->{whereClause} = sprintf 'ibox.sentBy=%s', $session->db->quote($session->form->get('userFilter')); } - my $p = $inbox->getMessagesPaginator($session->user, $messageOptions); + my $p = $inbox->getMessagesPaginator($user, $messageOptions); #Export page to template my @msg = (); @@ -1376,7 +1379,7 @@ sub www_view { my $hash = {}; $hash->{'message_id' } = $message->getId; - $hash->{'message_url' } = $self->getUrl("module=inbox;do=viewMessage;messageId=".$message->getId); + $hash->{'message_url' } = $self->getUrl("module=inbox;do=viewMessage;messageId=".$message->getId,'useUid'); $hash->{'subject' } = $message->get("subject"); $hash->{'status_class' } = $message->get("status"); $hash->{'status' } = $message->getStatus; @@ -1543,7 +1546,7 @@ The page on which users view their messages sub www_viewMessage { my $self = shift; my $session = $self->session; - my $user = $session->user; + my $user = $self->getUser; my $var = {}; my $messageId = shift || $session->form->get("messageId"); diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index cee28c382..201ff5330 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -98,18 +98,22 @@ WebGUI::User object to test against. Defaults to the current user. sub canRead { my $self = shift; + my $session = $self->session; my $message = shift; - my $user = shift || $self->session->user; + my $user = shift || $session->user; unless (ref $message eq "WebGUI::Inbox::Message") { - $self->session->log->warn("Message passed in was either empty or not a valid WebGUI::Inbox::Message. Got: ".(ref $message)); + $session->log->warn("Message passed in was either empty or not a valid WebGUI::Inbox::Message. Got: ".(ref $message)); return 0 } - my $userId = $message->get("userId"); + my $userId = $message->get("userId"); my $groupId = $message->get("groupId"); - return ($user->userId eq $userId || (defined $groupId && $user->isInGroup($groupId))); + return ($user->userId eq $userId + || (defined $groupId && $user->isInGroup($groupId)) + || ($user->isInGroup($session->setting->get('groupIdAdminUser'))) + ); } diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index e734aaea5..26cf5240a 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -3749,7 +3749,6 @@ LongTruncOk=1

lastUpdated => 0, }, - 'settings groupIdAdminAdSpace label' => { message => q{AdSpace}, lastUpdated => 0, @@ -3791,6 +3790,15 @@ LongTruncOk=1

}, + 'settings groupIdAdminFriends label' => { + message => q{Friends}, + lastUpdated => 0, + }, + 'settings groupIdAdminFriends hoverHelp' => { + message => q{Group to manage friends.}, + lastUpdated => 0, + }, + 'settings groupIdAdminGraphics label' => { message => q{Graphics}, lastUpdated => 0, @@ -4387,6 +4395,12 @@ Users may override this setting in their profile. message => q|The email address that this site would use to send an SMS message.|, lastUpdated => 1235695517, }, + + 'Select One' => { + message => q|Select One|, + context => q|Label in dropdown lists, indicating that the user should use the list to select 1 entry. It is implied that if nothing is chosen, that nothing will happen.|, + lastUpdated => 1239057119, + }, };