Checkpoint. Too many changes to enumerate.
This commit is contained in:
parent
537bd17224
commit
3c7e7ab231
4 changed files with 57 additions and 5 deletions
|
|
@ -34,7 +34,9 @@ readonly module => my %module;
|
||||||
public method => my %method;
|
public method => my %method;
|
||||||
public uid => my %uid;
|
public uid => my %uid;
|
||||||
public store => my %store; #This is an all purpose hash to store stuff in: $self->store->{something} = "something"
|
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 )
|
=head2 appendCommonVars ( var )
|
||||||
|
|
@ -139,6 +141,9 @@ sub displayContent {
|
||||||
my $noStyle = shift;
|
my $noStyle = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
|
|
||||||
|
##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
|
#Wrap content into the layout
|
||||||
my $var = {};
|
my $var = {};
|
||||||
$var->{content} = $content;
|
$var->{content} = $content;
|
||||||
|
|
@ -344,6 +349,7 @@ sub new {
|
||||||
$store { $id } = {};
|
$store { $id } = {};
|
||||||
$method { $id } = "view";
|
$method { $id } = "view";
|
||||||
$uid { $id } = undef;
|
$uid { $id } = undef;
|
||||||
|
$bare { $id } = 0;
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,52 @@ sub editSettingsFormSave {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_getFriendsAsJson ( )
|
||||||
|
|
||||||
|
For each user in a group, count how many friends they have and return that data
|
||||||
|
as JSON.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_getFriendsAsJson {
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
return $session->privilege->insufficient
|
||||||
|
unless $session->user->isInGroup($session->setting->get('groupIdAdminFriends'));
|
||||||
|
my $form = $session->form;
|
||||||
|
my $groupId = $form->get('groupId');
|
||||||
|
if (! $groupId) {;
|
||||||
|
$session->log->warn("No groupId: >$groupId<");
|
||||||
|
return '{}';
|
||||||
|
}
|
||||||
|
my $group = WebGUI::Group->new($session, $groupId);
|
||||||
|
return '{}' if $group->getId eq 'new';
|
||||||
|
if ($group->getId eq 'new') {;
|
||||||
|
$session->log->warn("New group created");
|
||||||
|
return '{}';
|
||||||
|
}
|
||||||
|
my @records = ();
|
||||||
|
USER: foreach my $userId (@{ $group->getUsers} ) {
|
||||||
|
my $user = WebGUI::User->new($session, $userId);
|
||||||
|
next USER unless $user;
|
||||||
|
my $friendsCount = scalar $user->friends->getUsers();
|
||||||
|
push @records, {
|
||||||
|
userId => $userId,
|
||||||
|
username => $user->username,
|
||||||
|
friends => $friendsCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
my %results;
|
||||||
|
$results{totalRecords} = scalar @records;
|
||||||
|
$results{records} = \@records;
|
||||||
|
#$results{'sort'} = undef;
|
||||||
|
$session->http->setMimeType('application/json');
|
||||||
|
my $json = JSON::to_json(\%results);
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_view ( )
|
=head2 www_view ( )
|
||||||
|
|
||||||
The main view page for editing the user's profile.
|
The main view page for editing the user's profile.
|
||||||
|
|
@ -127,7 +173,7 @@ sub www_view {
|
||||||
next GROUP unless $group->getId || $group->getId eq 'new';
|
next GROUP unless $group->getId || $group->getId eq 'new';
|
||||||
push @{ $var->{group_loop} }, {
|
push @{ $var->{group_loop} }, {
|
||||||
groupId => $groupId,
|
groupId => $groupId,
|
||||||
groupName => $group->getName,
|
groupName => $group->name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ finish($session);
|
||||||
sub installFriendManagerSettings {
|
sub installFriendManagerSettings {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
print "Installing FriendManager into settings...";
|
print "Installing FriendManager into settings...";
|
||||||
$session->setting->add('groupIdAdminFriends', '3');
|
$session->setting->add('groupIdAdminFriends', '3');
|
||||||
$session->setting->add('friendManagerViewTemplate', '64tqS80D53Z0JoAs2cX2VQ');
|
$session->setting->add('friendManagerViewTemplateId', '64tqS80D53Z0JoAs2cX2VQ');
|
||||||
$session->setting->add('groupsToManageFriends', '2');
|
$session->setting->add('groupsToManageFriends', '2');
|
||||||
print "\tDone";
|
print "\tDone";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue