--- loncom/interface/lonuserutils.pm 2007/11/06 18:23:14 1.3
+++ loncom/interface/lonuserutils.pm 2007/12/11 01:17:16 1.13
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.3 2007/11/06 18:23:14 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.13 2007/12/11 01:17:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,7 +35,8 @@ use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::lonlocal;
-use LONCAPA();
+use Apache::longroup;
+use LONCAPA qw(:DEFAULT :match);
###############################################################
###############################################################
@@ -85,28 +86,39 @@ sub modifystudent {
sub modifyuserrole {
my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass,
$first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role,
- $end,$start) = @_;
- my ($scope,$userresult,$authresult,$roleresult);
+ $end,$start,$checkid) = @_;
+ my ($scope,$userresult,$authresult,$roleresult,$idresult);
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
$scope =~ s/\_/\//g;
if ($role ne 'cc' && $sec ne '') {
$scope .='/'.$sec;
}
- } elsif ($setting eq 'domain') {
+ } elsif ($context eq 'domain') {
$scope = '/'.$env{'request.role.domain'}.'/';
- } elsif ($setting eq 'construction_space') {
+ } elsif ($context eq 'author') {
$scope = '/'.$env{'user.domain'}.'/'.$env{'user.name'};
}
if ($context eq 'domain') {
my $uhome = &Apache::lonnet::homeserver($uname,$udom);
if ($uhome ne 'no_host') {
- if (($changeauth) && (&Apache::lonnet::allowed('mau',$udom))) {
+ if (($changeauth eq 'Yes') && (&Apache::lonnet::allowed('mau',$udom))) {
if ((($umode =~ /^krb4|krb5|internal$/) && $upass ne '') ||
($umode eq 'localauth')) {
$authresult = &Apache::lonnet::modifyuserauth($udom,$uname,$umode,$upass);
}
}
+ if (($forceid) && (&Apache::lonnet::allowed('mau',$udom)) &&
+ ($env{'form.recurseid'}) && ($checkid)) {
+ my %userupdate = (
+ lastname => $last,
+ middlename => $middle,
+ firstname => $first,
+ generation => $gene,
+ id => $uid,
+ );
+ $idresult = &propagate_id_change($uname,$udom,\%userupdate);
+ }
}
}
$userresult =
@@ -114,14 +126,83 @@ sub modifyuserrole {
$middle,$last,$gene,$forceid,$desiredhome,
$email,$role,$start,$end);
if ($userresult eq 'ok') {
- if ($role ne '') {
+ if ($role ne '') {
$roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope,
$role,$end,$start);
}
}
- return ($userresult,$authresult,$roleresult);
+ return ($userresult,$authresult,$roleresult,$idresult);
+}
+
+sub propagate_id_change {
+ my ($uname,$udom,$user) = @_;
+ my (@types,@roles);
+ @types = ('active','future');
+ @roles = ('st');
+ my $idresult;
+ my %roleshash = &Apache::lonnet::get_my_roles($uname,
+ $udom,'userroles',\@types,\@roles);
+ my %args = (
+ one_time => 1,
+ );
+ foreach my $item (keys(%roleshash)) {
+ my ($cnum,$cdom,$role) = split(/:/,$item);
+ my ($start,$end) = split(/:/,$roleshash{$item});
+ if (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my $result = &update_classlist($cdom,$cnum,$udom,$uname,$user);
+ my %coursehash =
+ &Apache::lonnet::coursedescription($cdom.'_'.$cnum,\%args);
+ my $cdesc = $coursehash{'description'};
+ if ($cdesc eq '') {
+ $cdesc = $cdom.'_'.$cnum;
+ }
+ if ($result eq 'ok') {
+ $idresult .= &mt('Classlist update for "[_1]" in "[_2]".',$uname.':'.$udom,$cdesc).'
'."\n";
+ } else {
+ $idresult .= &mt('Error: "[_1]" during classlist update for "[_2]" in "[_3]".',$result,$uname.':'.$udom,$cdesc).'
'."\n";
+ }
+ }
+ }
+ return $idresult;
}
+sub update_classlist {
+ my ($cdom,$cnum,$udom,$uname,$user) = @_;
+ my ($uid,$classlistentry);
+ my $fullname =
+ &Apache::lonnet::format_name($user->{'firstname'},$user->{'middlename'},
+ $user->{'lastname'},$user->{'generation'},
+ 'lastname');
+ my %classhash = &Apache::lonnet::get('classlist',[$uname.':'.$udom],
+ $cdom,$cnum);
+ my @classinfo = split(/:/,$classhash{$uname.':'.$udom});
+ my $ididx=&Apache::loncoursedata::CL_ID() - 2;
+ my $nameidx=&Apache::loncoursedata::CL_FULLNAME() - 2;
+ for (my $i=0; $i<@classinfo; $i++) {
+ if ($i == $ididx) {
+ if (defined($user->{'id'})) {
+ $classlistentry .= $user->{'id'}.':';
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
+ } elsif ($i == $nameidx) {
+ $classlistentry .= $fullname.':';
+ } else {
+ $classlistentry .= $classinfo[$i].':';
+ }
+ }
+ $classlistentry =~ s/:$//;
+ my $reply=&Apache::lonnet::cput('classlist',
+ {"$uname:$udom" => $classlistentry},
+ $cdom,$cnum);
+ if (($reply eq 'ok') || ($reply eq 'delayed')) {
+ return 'ok';
+ } else {
+ return 'error: '.$reply;
+ }
+}
+
+
###############################################################
###############################################################
# build a role type and role selection form
@@ -130,7 +211,7 @@ sub domain_roles_select {
# domain context
#
# Role types
- my @roletypes = ('domain','construction_space','course');
+ my @roletypes = ('domain','author','course');
my %lt = &role_type_names();
#
# build up the menu information to be passed to
@@ -152,22 +233,28 @@ sub domain_roles_select {
my @roles;
if ($roletype eq 'domain') {
@roles = &domain_roles();
- } elsif ($roletype eq 'construction_space') {
+ } elsif ($roletype eq 'author') {
@roles = &construction_space_roles();
} else {
@roles = &course_roles('domain');
+ unshift(@roles,'cr');
}
my $order = ['Any',@roles];
$select_menus{$roletype}->{'order'} = $order;
foreach my $role (@roles) {
- $select_menus{$roletype}->{'select2'}->{$role} =
- &Apache::lonnet::plaintext($role);
+ if ($role eq 'cr') {
+ $select_menus{$roletype}->{'select2'}->{$role} =
+ &mt('Custom role');
+ } else {
+ $select_menus{$roletype}->{'select2'}->{$role} =
+ &Apache::lonnet::plaintext($role);
+ }
}
$select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any');
}
my $result = &Apache::loncommon::linked_select_forms
('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'},
- 'roletype','showrole',\%select_menus,['domain','construction_space','course']);
+ 'roletype','showrole',\%select_menus,['domain','author','course']);
return $result;
}
@@ -572,7 +659,7 @@ sub print_upload_manager_footer {
my $formname;
if ($context eq 'course') {
$formname = 'document.studentform';
- } elsif ($context eq 'construction_space') {
+ } elsif ($context eq 'author') {
$formname = 'document.studentform';
} elsif ($context eq 'domain') {
$formname = 'document.studentform';
@@ -623,7 +710,7 @@ sub print_upload_manager_footer {
$Str .= '
'.&mt('role').': '. + $options.' | '. + ''.&mt('section').': |
\n".'
'."\n".
- &mt('(only do if you know what you are doing.)')."
\n"; + if ($context eq 'course' || $context eq 'domain') { + $Str .= &forceid_change($context); + } $Str .= '
\n".'
'."\n".
+ &mt('(only do if you know what you are doing.)')."
\n";
+ if ($context eq 'domain') {
+ $output .= '
'.&list_submit_button(&mt('Update Display')). "\n
\n"); + if ($env{'form.coursepick'}) { + $r->print('\n". + if ($mode ne 'autoenroll') { + $output = '
';
+ my @linkdests = ('aboutme');
+ if ($permission->{'cusr'}) {
+ push (@linkdests,'modify');
+ $output .= ''.$lt{'link'}.': ';
+ my $usernamelink = $env{'form.usernamelink'};
+ if ($usernamelink eq '') {
+ $usernamelink = 'aboutme';
+ }
+ foreach my $item (@linkdests) {
+ my $checkedstr = '';
+ if ($item eq $usernamelink) {
+ $checkedstr = ' checked="checked" ';
+ }
+ $output .= '
';
+ } else {
+ $output .= &mt("Click on a username to view the user's personal page.").'
';
+ }
+ if ($actionselect) {
+ $output .= <<"END";
+$lt{'ac'}: $actionselect
+ +END + } + } + $output .= "\n
\n". &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row()); + &Apache::loncommon::start_data_table_header_row(); if ($mode eq 'autoenroll') { - $r->print(" + $output .= "
\n"); - } elsif ($context eq 'construction_space') { + } elsif ($context eq 'author') { $r->print('
\n"); } else { $r->print('
\n");
@@ -2399,6 +2949,7 @@ sub upfile_drop_add {
# Get information about course groups
%curr_groups = &Apache::longroup::coursegroups();
}
+ my (%curr_rules,%got_rules,%alerts);
# Get new users list
foreach (@userdata) {
my %entries=&Apache::loncommon::record_sep($_);
@@ -2430,7 +2981,7 @@ sub upfile_drop_add {
$entries{$fields{'username'}},$fname,$mname,$lname,$gen).
'');
} else {
- my $username = $entries{$fields{'username'}};
+ my $username = $entries{$fields{'username'}};
my $sec;
if ($context eq 'course' || $setting eq 'course') {
# determine section number
@@ -2501,6 +3052,50 @@ sub upfile_drop_add {
\$lname,\$gen,\$sec,\$role) {
$$_ =~ s/(\s+$|^\s+)//g;
}
+ # check against rules
+ my $checkid = 0;
+ my $newuser = 0;
+ my (%rulematch,%inst_results,%idinst_results);
+ my $uhome=&Apache::lonnet::homeserver($username,$domain);
+ if ($uhome eq 'no_host') {
+ $checkid = 1;
+ $newuser = 1;
+ my $checkhash;
+ my $checks = { 'username' => 1 };
+ $checkhash->{$username.':'.$domain} = { 'newuser' => 1, };
+ &Apache::loncommon::user_rule_check($checkhash,$checks,
+ \%alerts,\%rulematch,\%inst_results,\%curr_rules,
+ \%got_rules);
+ if (ref($alerts{'username'}) eq 'HASH') {
+ if (ref($alerts{'username'}{$domain}) eq 'HASH') {
+ next if ($alerts{'username'}{$domain}{$username});
+ }
+ }
+ } else {
+# FIXME check if user info can be updated.
+ }
+ if ($id ne '') {
+ if (!$newuser) {
+ my %idhash = &Apache::lonnet::idrget($domain,($username));
+ if ($idhash{$username} ne $id) {
+ $checkid = 1;
+ }
+ }
+ if ($checkid) {
+ my $checkhash;
+ my $checks = { 'id' => 1 };
+ $checkhash->{$username.':'.$domain} = { 'newuser' => $newuser,
+ 'id' => $id };
+ &Apache::loncommon::user_rule_check($checkhash,$checks,
+ \%alerts,\%rulematch,\%idinst_results,\%curr_rules,
+ \%got_rules);
+ if (ref($alerts{'id'}) eq 'HASH') {
+ if (ref($alerts{'id'}{$domain}) eq 'HASH') {
+ next if ($alerts{'id'}{$domain}{$id});
+ }
+ }
+ }
+ }
if ($password || $env{'form.login'} eq 'loc') {
my ($userresult,$authresult,$roleresult);
if ($role eq 'st') {
@@ -2519,7 +3114,7 @@ sub upfile_drop_add {
$id,$amode,$password,$fname,
$mname,$lname,$gen,$sec,
$env{'form.forceid'},$desiredhost,
- $email,$role,$enddate,$startdate);
+ $email,$role,$enddate,$startdate,$checkid);
}
$flushc =
&user_change_result($r,$userresult,$authresult,
@@ -2530,7 +3125,7 @@ sub upfile_drop_add {
$r->print('
'.
&mt('[_1]: Unable to enroll. No password specified.',$username)
);
- } elsif ($context eq 'construction_space') {
+ } elsif ($context eq 'author') {
$r->print('
'.
&mt('[_1]: Unable to add co-author. No password specified.',$username)
);
@@ -2544,9 +3139,7 @@ sub upfile_drop_add {
}
} # end of foreach (@userdata)
# Flush the course logs so reverse user roles immediately updated
- if ($context eq 'course' || ($context eq 'domain' && $setting eq 'course')) {
- &Apache::lonnet::flushcourselogs();
- }
+ &Apache::lonnet::flushcourselogs();
$r->print("
\n".&mt('Processed [_1] user(s).',$counts{'user'}). "
\n"); if ($counts{'role'} > 0) { @@ -2558,6 +3151,7 @@ sub upfile_drop_add { &mt('Authentication changed for [_1] existing users.', $counts{'auth'})."\n"); } + $r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules)); $r->print(''); @@ -2588,6 +3182,46 @@ sub upfile_drop_add { } # end of unless } +sub print_namespacing_alerts { + my ($domain,$alerts,$curr_rules) = @_; + my $output; + if (ref($alerts) eq 'HASH') { + if (keys(%{$alerts}) > 0) { + if (ref($alerts->{'username'}) eq 'HASH') { + foreach my $dom (sort(keys(%{$alerts->{'username'}}))) { + my $count; + if (ref($alerts->{'username'}{$dom}) eq 'HASH') { + $count = keys(%{$alerts->{'username'}{$dom}}); + } + my $domdesc = &Apache::lonnet::domain($domain,'description'); + if (ref($curr_rules->{$dom}) eq 'HASH') { + $output .= &Apache::loncommon::instrule_disallow_msg( + 'username',$domdesc,$count,'upload'); + } + $output .= &Apache::loncommon::user_rule_formats($dom, + $domdesc,$curr_rules->{$dom}{'username'}, + 'username'); + } + } + if (ref($alerts->{'id'}) eq 'HASH') { + foreach my $dom (sort(keys(%{$alerts->{'id'}}))) { + my $count; + if (ref($alerts->{'id'}{$dom}) eq 'HASH') { + $count = keys(%{$alerts->{'id'}{$dom}}); + } + my $domdesc = &Apache::lonnet::domain($domain,'description'); + if (ref($curr_rules->{$dom}) eq 'HASH') { + $output .= &Apache::loncommon::instrule_disallow_msg( + 'id',$domdesc,$count,'upload'); + } + $output .= &Apache::loncommon::user_rule_formats($dom, + $domdesc,$curr_rules->{$dom}{'id'},'id'); + } + } + } + } +} + sub user_change_result { my ($r,$userresult,$authresult,$roleresult,$counts,$flushc,$username, $userchg) = @_; @@ -2652,36 +3286,226 @@ sub print_expire_menu { # ================================================================== Phase four -sub expire_user_list { - my ($r,$context) = @_; +sub update_user_list { + my ($r,$context,$setting,$choice) = @_; + my $now = time; my $count=0; - my @droplist = &Apache::loncommon::get_env_multiple('form.droplist'); - foreach (@droplist) { - my ($uname,$udom)=split(/\:/,$_); - # drop student - my $result = &modifystudent($udom,$uname,$env{'request.course.id'}); + my @changelist; + if ($choice ne '') { + @changelist = &Apache::loncommon::get_env_multiple('form.actionlist'); + } else { + @changelist = &Apache::loncommon::get_env_multiple('form.droplist'); + } + my %result_text = ( ok => { 'revoke' => 'Revoked', + 'delete' => 'Deleted', + 'reenable' => 'Re-enabled', + 'activate' => 'Activated', + }, + error => {'revoke' => 'revoking', + 'delete' => 'deleting', + 'reenable' => 're-enabling', + 'activate' => 'activating', + }, + ); + my ($startdate,$enddate); + if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { + ($startdate,$enddate) = &get_dates_from_form(); + } + foreach my $item (@changelist) { + my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype,@sections, + $scopestem); + if ($context eq 'course') { + ($uname,$udom,$role,$sec,$type,$locktype) = split(/\:/,$item,-1); + $cid = $env{'request.course.id'}; + $scopestem = '/'.$cid; + $scopestem =~s/\_/\//g; + if ($sec eq '') { + $scope = $scopestem; + } else { + $scope = $scopestem.'/'.$sec; + } + } elsif ($context eq 'author') { + ($uname,$udom,$role) = split(/\:/,$item,-1); + $scope = '/'.$env{'user.domain'}.'/'.$env{'user.name'}; + } elsif ($context eq 'domain') { + if ($setting eq 'domain') { + ($role,$uname,$udom) = split(/\:/,$item,-1); + $scope = '/'.$env{'request.role.domain'}.'/'; + } elsif ($setting eq 'author') { + ($uname,$udom,$role,$scope) = split(/\:/,$item); + } elsif ($setting eq 'course') { + ($uname,$udom,$role,$cid,$sec,$type,$locktype) = + split(/\:/,$item); + $scope = '/'.$cid; + $scope =~s/\_/\//g; + if ($sec ne '') { + $scope .= '/'.$sec; + } + } + } + my $plrole = &Apache::lonnet::plaintext($role); + my ($uid,$first,$middle,$last,$gene,$sec); + my $start = $env{'form.'.$item.'_start'}; + my $end = $env{'form.'.$item.'_end'}; + # revoke or delete user role + if ($choice eq 'revoke') { + $end = $now; + if ($role eq 'st') { + $result = + &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); + } else { + $result = + &Apache::lonnet::revokerole($udom,$uname,$scope,$role); + } + } elsif ($choice eq 'delete') { + $start = -1; + $end = -1; + if ($role eq 'st') { +# FIXME - how does role deletion affect classlist? + &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); + } else { + $result = + &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now, + 0,1); + } + } else { + #reenable, activate, change access dates or change section + if ($choice ne 'chgsec') { + $start = $startdate; + $end = $enddate; + } + if ($choice eq 'reenable') { + if ($role eq 'st') { + $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); + } else { + $result = + &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, + $now); + } + } elsif ($choice eq 'activate') { + if ($role eq 'st') { + $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); + } else { + $result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, + $now); + } + } elsif ($choice eq 'chgdates') { + if ($role eq 'st') { + $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); + } else { + $result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end, + $start); + } + } elsif ($choice eq 'chgsec') { + my (@newsecs,$revresult,$nochg,@retained); + if ($role ne 'cc') { + @newsecs = split(/,/,$env{'form.newsecs'}); + } + # remove existing section if not to be retained. + if (!$env{'form.retainsec'}) { + if ($sec eq '') { + if (@newsecs == 0) { + $result = &mt('No change in section assignment (none)'); + $nochg = 1; + } + } else { + if (!grep(/^\Q$sec\E$/,@newsecs)) { + $revresult = + &Apache::lonnet::revokerole($udom,$uname,$scope,$role); + } else { + push(@retained,$sec); + } + } + } else { + push(@retained,$sec); + } + # add new sections + if (@newsecs == 0) { + if (!$nochg) { + if ($sec ne '') { + if ($role eq 'st') { + $result = + &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid); + } else { + my $newscope = $scopestem; + $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start); + } + } + } + } else { + foreach my $newsec (@newsecs) { + if (!grep(/^\Q$newsec\E$/,@retained)) { + if ($role eq 'st') { + $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid); + } else { + my $newscope = $scopestem; + if ($newsec ne '') { + $newscope .= '/'.$newsec; + } + $result = &Apache::lonnet::assignrole($udom,$uname, + $newscope,$role,$end,$start); + } + } + } + } + } + } if ($result eq 'ok' || $result eq 'ok:') { - $r->print(&mt('Dropped [_1]',$uname.'@'.$udom).''.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,users].",$count).'
'); + if ($count > 0) { + if ($choice eq 'revoke') { + $r->print(''.&mt('Re-enabling will re-activate data for the role.
')); + } + # Flush the course logs so reverse user roles immediately updated + &Apache::lonnet::flushcourselogs(); + } + if ($env{'form.makedatesdefault'}) { + if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { + $r->print(&make_dates_default($startdate,$enddate)); } } - $r->print(''.&mt('Dropped [_1] user(s).',$count).'
'); - $r->print(''.&mt('Re-enrollment will re-activate data.')) if ($count);
}
-sub section_check_js {
- my $groupslist;
- my %curr_groups = &Apache::longroup::coursegroups();
- if (%curr_groups) {
- $groupslist = join('","',sort(keys(%curr_groups)));
+sub classlist_drop {
+ my ($scope,$uname,$udom,$now,$action) = @_;
+ my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
+ my $cid=$cdom.'_'.$cnum;
+ my $user = $uname.':'.$udom;
+ if ($action eq 'drop') {
+ if (!&active_student_roles($cnum,$cdom,$uname,$udom)) {
+ my $result =
+ &Apache::lonnet::cput('classlist',
+ { $user => $now },
+ $env{'course.'.$cid.'.domain'},
+ $env{'course.'.$cid.'.num'});
+ return &mt('Drop from classlist: [_1]',
+ ''.$result.'').'
';
+ }
}
+}
+
+sub active_student_roles {
+ my ($cnum,$cdom,$uname,$udom) = @_;
+ my %roles =
+ &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+ ['future','active'],['st']);
+ return exists($roles{"$cnum:$cdom:st"});
+}
+
+sub section_check_js {
+ my $groupslist= &get_groupslist();
return <<"END";
function validate(caller) {
- var groups = new Array("$groupslist");
+ var groups = new Array($groupslist);
var secname = caller.value;
if ((secname == 'all') || (secname == 'none')) {
alert("'"+secname+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
@@ -2728,5 +3552,144 @@ sub set_login {
return $response;
}
+sub course_sections {
+ my ($sections_count,$role) = @_;
+ my $output = '';
+ my @sections = (sort {$a <=> $b} keys %{$sections_count});
+ if (scalar(@sections) == 1) {
+ $output = '