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 uid => my %uid;
|
||||
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 )
|
||||
|
|
@ -139,6 +141,9 @@ sub displayContent {
|
|||
my $noStyle = shift;
|
||||
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
|
||||
my $var = {};
|
||||
$var->{content} = $content;
|
||||
|
|
@ -344,6 +349,7 @@ sub new {
|
|||
$store { $id } = {};
|
||||
$method { $id } = "view";
|
||||
$uid { $id } = undef;
|
||||
$bare { $id } = 0;
|
||||
|
||||
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 ( )
|
||||
|
||||
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';
|
||||
push @{ $var->{group_loop} }, {
|
||||
groupId => $groupId,
|
||||
groupName => $group->getName,
|
||||
groupName => $group->name,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ finish($session);
|
|||
sub installFriendManagerSettings {
|
||||
my $session = shift;
|
||||
print "Installing FriendManager into settings...";
|
||||
$session->setting->add('groupIdAdminFriends', '3');
|
||||
$session->setting->add('friendManagerViewTemplate', '64tqS80D53Z0JoAs2cX2VQ');
|
||||
$session->setting->add('groupsToManageFriends', '2');
|
||||
$session->setting->add('groupIdAdminFriends', '3');
|
||||
$session->setting->add('friendManagerViewTemplateId', '64tqS80D53Z0JoAs2cX2VQ');
|
||||
$session->setting->add('groupsToManageFriends', '2');
|
||||
print "\tDone";
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue