version 1.98.2.1, 2009/12/14 22:24:31
|
version 1.98.2.2, 2010/08/09 23:39:43
|
Line 72 sub handler {
|
Line 72 sub handler {
|
['mdc','versionchanges',0], |
['mdc','versionchanges',0], |
['vcl','newroles',1], |
['vcl','newroles',1], |
['vcl','oldroles',1], |
['vcl','oldroles',1], |
|
['whn','crslogin',1], |
) { |
) { |
my ($perm,$key,$check_section) = @{ $perm_check }; |
my ($perm,$key,$check_section) = @{ $perm_check }; |
my $scope = $env{'request.course.id'}; |
my $scope = $env{'request.course.id'}; |
Line 143 sub handler {
|
Line 144 sub handler {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
("What's New?",#'Course_Action_Items_Intervals' |
("What's New?",#'Course_Action_Items_Intervals' |
)); |
)); |
|
} elsif ($command eq 'chgcrslogininterval' && $checkallowed{'crslogin'}) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage, |
|
text=>"Change interval"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
|
("What's New?",#'Course_Action_Items_Intervals' |
|
)); |
} else { |
} else { |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
$r->print(&Apache::lonhtmlcommon::breadcrumbs |
("What's New?",#'Course_Action_Items_Display' |
("What's New?",#'Course_Action_Items_Display' |
Line 188 sub display_main_box {
|
Line 196 sub display_main_box {
|
604800 => 'roles which expired since last week', |
604800 => 'roles which expired since last week', |
86400 => 'roles which expired since yesterday', |
86400 => 'roles which expired since yesterday', |
); |
); |
|
my %crslogins = ( |
|
-1 => 'last login for anyone who has ever logged in', |
|
2592000 => 'last login for users in last 30 days', |
|
604800 => 'last login for users in last 7 days', |
|
86400 => 'last login for users in last 24 hours', |
|
); |
my %interval_titles = ( |
my %interval_titles = ( |
versions => \%versions, |
versions => \%versions, |
newroles => \%newroles, |
newroles => \%newroles, |
oldroles => \%oldroles, |
oldroles => \%oldroles, |
|
crslogin => \%crslogins, |
); |
); |
my %initpage = &Apache::lonlocal::texthash ( |
my %initpage = &Apache::lonlocal::texthash ( |
firstres => "first resource in the $lctype", |
firstres => "first resource in the $lctype", |
Line 220 sub display_main_box {
|
Line 235 sub display_main_box {
|
} elsif (($command eq 'chgoldroleinterval') |
} elsif (($command eq 'chgoldroleinterval') |
&& $checkallowed->{'oldroles'}) { |
&& $checkallowed->{'oldroles'}) { |
&display_interval_config($r,$refpage,\%interval_titles,'oldroles'); |
&display_interval_config($r,$refpage,\%interval_titles,'oldroles'); |
|
} elsif (($command eq 'chgcrslogininterval') |
|
&& $checkallowed->{'crslogin'}) { |
|
&display_interval_config($r,$refpage,\%interval_titles,'crslogin'); |
} else { |
} else { |
&display_actions_box($r,$command,$refpage,\%threshold_titles, |
&display_actions_box($r,$command,$refpage,\%threshold_titles, |
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed); |
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed); |
Line 245 sub display_header {
|
Line 263 sub display_header {
|
|
|
my $scripttag; |
my $scripttag; |
unless ($command eq 'chgthreshold' || $command eq 'chginterval' || |
unless ($command eq 'chgthreshold' || $command eq 'chginterval' || |
$command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') { |
$command eq 'chgoldroleinterval' || |
|
$command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') { |
$scripttag = <<"END"; |
$scripttag = <<"END"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function change_display(caller,change) { |
function change_display(caller,change) { |
Line 264 END
|
Line 283 END
|
} |
} |
$scripttag.='document.visible.submit(); |
$scripttag.='document.visible.submit(); |
} |
} |
|
|
|
function togglelogins() { |
|
var total = document.visible.logincount.value; |
|
var sumrow = document.visible.loginrow.value; |
|
if (total == 0) { |
|
return; |
|
} |
|
var showlogindetails = 0; |
|
for (var i=0; i<document.visible.logindetails.length; i++) { |
|
if (document.visible.logindetails[i].checked) { |
|
showlogindetails = document.visible.logindetails[i].value; |
|
} |
|
} |
|
var detval = "none"; |
|
var sumval = ""; |
|
if (showlogindetails == 1) { |
|
detval = ""; |
|
sumval = "none"; |
|
} |
|
for (var j=0; j<total; j++) { |
|
var counter = j+1; |
|
var itemid = "logindet_"+counter; |
|
personele = document.getElementById(itemid); |
|
if (personele != null) { |
|
personele.style.display = detval; |
|
} |
|
} |
|
var detheaderele = document.getElementById("logintitledet"); |
|
if (detheaderele != null) { |
|
detheaderele.style.display = detval; |
|
} |
|
for (var k=0; k<sumrow; k++) { |
|
var counter = k+1; |
|
var itemid = "loginsum_"+counter; |
|
logincatele = document.getElementById(itemid); |
|
if (logincatele != null) { |
|
logincatele.style.display = sumval; |
|
} |
|
} |
|
var sumheaderele = document.getElementById("logintitlesum"); |
|
if (sumheaderele != null) { |
|
sumheaderele.style.display = sumval; |
|
} |
|
return; |
|
} |
</script> |
</script> |
'; |
'; |
} |
} |
Line 316 sub display_actions_box {
|
Line 380 sub display_actions_box {
|
my %expired; |
my %expired; |
my $activecount; |
my $activecount; |
my %activated; |
my %activated; |
|
my %loggedin; |
|
my $logincount; |
my %res_title = (); |
my %res_title = (); |
my %show = (); |
my %show = (); |
my $needitems = 0; |
my $needitems = 0; |
Line 448 sub display_actions_box {
|
Line 514 sub display_actions_box {
|
$headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); |
$headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); |
} |
} |
|
|
|
$timediff{'crslogin'} = $display_settings{$cid.':crslogininterval'}; |
|
unless (defined($timediff{'crslogin'})) { $timediff{'crslogin'} = 604800; } |
|
$interval{'crslogin'} = $interval_titles->{'crslogin'}->{$timediff{'crslogin'}}; |
|
|
|
if ($timediff{'crslogin'} == -1) { |
|
$headings{'crslogin'} = &mt('Last login for anyone who has ever logged in'); |
|
} elsif ($timediff{'crslogin'} == 2592000) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 30 days'); |
|
} elsif ($timediff{'crslogin'} == 604800) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 7 days'); |
|
} elsif ($timediff{'crslogin'} == 86400) { |
|
$headings{'crslogin'} = &mt('Last login for users in last 24 hours'); |
|
} |
|
|
my $now = time; |
my $now = time; |
if ($timediff{'versions'} == -1) { |
if ($timediff{'versions'} == -1) { |
$timediff{'versions'} = time; |
$timediff{'versions'} = time; |
Line 462 sub display_actions_box {
|
Line 542 sub display_actions_box {
|
if ($timediff{'oldroles'} == -1) { |
if ($timediff{'oldroles'} == -1) { |
$timediff{'oldroles'} = time; |
$timediff{'oldroles'} = time; |
} |
} |
|
|
my $expiredstart = $now - $timediff{'oldroles'}; |
my $expiredstart = $now - $timediff{'oldroles'}; |
|
|
|
if ($timediff{'crslogin'} == -1) { |
|
$timediff{'crslogin'} = time; |
|
} |
|
|
|
my $crsloginstart = $now - $timediff{'crslogin'}; |
|
|
my $countunread = $display_settings{$cid.':countunread'}; |
my $countunread = $display_settings{$cid.':countunread'}; |
unless (defined($countunread)) { |
unless (defined($countunread)) { |
$countunread = 'on'; |
$countunread = 'on'; |
Line 479 sub display_actions_box {
|
Line 566 sub display_actions_box {
|
|
|
my @actionorder; |
my @actionorder; |
if ($custommenu) { |
if ($custommenu) { |
@actionorder = ('coursenormalmail','coursecritmail','newroles','oldroles'); |
@actionorder = ('coursenormalmail','coursecritmail','newroles','oldroles','crslogin'); |
} else { |
} else { |
@actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles'); |
@actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles'); |
} |
} |
Line 520 sub display_actions_box {
|
Line 607 sub display_actions_box {
|
if ($show{'newroles'}) { |
if ($show{'newroles'}) { |
$activecount = &getactivated(\%activated,$activatedstart,'active'); |
$activecount = &getactivated(\%activated,$activatedstart,'active'); |
} |
} |
|
if ($show{'crslogin'}) { |
|
$logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart); |
|
} |
|
|
$r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a> |
$r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a> |
<a href="javascript:changeAll('show');">$lt{'shal'}</a> |
<a href="javascript:changeAll('show');">$lt{'shal'}</a> |
<form method="post" name="visible" action="/adm/whatsnew">\n|); |
<form method="post" name="visible" action="/adm/whatsnew">\n|); |
Line 530 sub display_actions_box {
|
Line 621 sub display_actions_box {
|
} |
} |
} |
} |
|
|
$r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /></form><table class="LC_double_column"><tr><td class="LC_left_col">'); |
$r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /><table class="LC_double_column"><tr><td class="LC_left_col">'); |
|
|
my $displayed = 0; |
my $displayed = 0; |
my $totalboxes = 0; |
my $totalboxes = 0; |
Line 551 sub display_actions_box {
|
Line 642 sub display_actions_box {
|
if ($displayed == $halfway) { |
if ($displayed == $halfway) { |
$r->print('</td><td> </td><td class="LC_right_col" >'); |
$r->print('</td><td> </td><td class="LC_right_col" >'); |
} |
} |
&display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror); |
&display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror,\%loggedin,$logincount); |
$displayed ++; |
$displayed ++; |
} |
} |
} |
} |
$r->print(' |
$r->print(' |
</td> |
</td></form> |
</tr> |
</tr> |
</table> |
</table> |
'); |
'); |
Line 639 sub display_interval_config {
|
Line 730 sub display_interval_config {
|
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />'); |
} elsif ($context eq 'newroles') { |
} elsif ($context eq 'newroles') { |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />'); |
|
} elsif ($context eq 'crslogin') { |
|
$r->print('<br />'.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).'<br />'); |
} else { |
} else { |
$r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />'); |
$r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />'); |
} |
} |
Line 804 sub display_launcher {
|
Line 897 sub display_launcher {
|
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, |
$tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, |
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, |
$newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, |
$interval,$countunread,$expired,$expirecount,$activated,$activecount, |
$interval,$countunread,$expired,$expirecount,$activated,$activecount, |
$crstype,$itemserror) = @_; |
$crstype,$itemserror,$loggedin,$logincount) = @_; |
|
|
if ($$checkallowed{$action}) { |
if ($$checkallowed{$action}) { |
&start_box($r,$show,$headings,$action,$refpage,$action); |
&start_box($r,$show,$headings,$action,$refpage,$action); |
Line 831 sub display_launcher {
|
Line 924 sub display_launcher {
|
} elsif ($action eq 'oldroles') { # EXPIRED ROLES |
} elsif ($action eq 'oldroles') { # EXPIRED ROLES |
&display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, |
&display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, |
$crstype); |
$crstype); |
|
} elsif ($action eq 'crslogin') { #LAST LOGIN |
|
&display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, |
|
$crstype); |
|
|
} |
} |
} |
} |
&end_box($r); |
&end_box($r); |
Line 1428 sub getrolechanges {
|
Line 1525 sub getrolechanges {
|
return $rolechgcount; |
return $rolechgcount; |
} |
} |
|
|
|
sub getloggedin { |
|
my ($cdom,$crs,$lastlogins,$starttime) = @_; |
|
my $context = 'course'; |
|
my ($permission,$allowed) = |
|
&Apache::lonuserutils::get_permission($context); |
|
my $viewablesec = &Apache::lonuserutils::viewable_section($permission); |
|
my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs); |
|
my $logincount = 0; |
|
my ($tmp) = keys(%crslogins); |
|
unless ($tmp =~ /^(con_lost|error|no_such_host)/i) { |
|
if (keys(%crslogins) > 0) { |
|
foreach my $key (keys(%crslogins)) { |
|
my ($uname,$udom,$section,$role) = split(/:/,$key); |
|
my $eventtime = $crslogins{$key}; |
|
if ($eventtime > $starttime) { |
|
if (($viewablesec ne '') && ($section ne '')) { |
|
next if ($viewablesec ne $section); |
|
} |
|
my %chginfo = ( |
|
'section' => $section, |
|
'uname' => $uname, |
|
'udom' => $udom, |
|
'role' => $role, |
|
); |
|
$logincount ++; |
|
push (@{$lastlogins->{$eventtime}},\%chginfo); |
|
} |
|
} |
|
} |
|
} |
|
return $logincount; |
|
} |
|
|
sub checkversions { |
sub checkversions { |
my ($cdom,$crs,$navmap,$changed,$starttime) = @_; |
my ($cdom,$crs,$navmap,$changed,$starttime) = @_; |
my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs); |
my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs); |
Line 1684 sub display_rolechanges {
|
Line 1814 sub display_rolechanges {
|
} |
} |
return; |
return; |
} |
} |
|
|
|
sub display_crslogins { |
|
my ($r,$logincount,$loggedin,$interval,$crstype) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
'user' => 'User', |
|
'role' => 'Role', |
|
'sec' => 'Section', |
|
'number' => 'Total number of logins', |
|
); |
|
if ($logincount) { |
|
$r->print('<tr class="LC_info_row" style="display:none" id="logintitledet">'. |
|
'<td class="LC_left_item">'.$lt{'user'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'role'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'sec'}.'</td></tr>'. |
|
'<tr class="LC_info_row" id="logintitlesum">'. |
|
'<td class="LC_left_item">'.$lt{'number'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'role'}.'</td>'. |
|
'<td class="LC_left_item">'.$lt{'sec'}.'</td></tr>'); |
|
my (%bylastname,%counts); |
|
if (ref($loggedin) eq 'HASH') { |
|
my @logins = sort { $b <=> $a } (keys(%{$loggedin})); |
|
my $numlogin = 0; |
|
foreach my $item (@logins) { |
|
if (ref($loggedin->{$item}) eq 'ARRAY') { |
|
foreach my $user (@{$loggedin->{$item}}) { |
|
if (ref($user) eq 'HASH') { |
|
my $section; |
|
my $role = |
|
&Apache::lonnet::plaintext($user->{'role'},$crstype); |
|
my $status = &mt($user->{'status'}); |
|
if ($user->{'section'} eq '') { |
|
$section = &mt('none'); |
|
} else { |
|
$section = $user->{'section'}; |
|
} |
|
$counts{$user->{'role'}}{$section} ++; |
|
my $uname = $user->{'uname'}; |
|
my $udom = $user->{'udom'}; |
|
my $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); |
|
my $link = |
|
&Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); |
|
push(@{$bylastname{$fullname}}, |
|
'<td>'.$link.'</td>'. |
|
'<td>'.$role.'</td>'. |
|
'<td>'.$section.'</td>'); |
|
} |
|
} |
|
} |
|
} |
|
foreach my $person (sort(keys(%bylastname))) { |
|
if (ref($bylastname{$person}) eq 'ARRAY') { |
|
foreach my $item (@{$bylastname{$person}}) { |
|
$numlogin ++; |
|
my $css_class = $numlogin%2?' class="LC_odd_row"':''; |
|
$r->print('<tr'.$css_class.' style="display:none;" id="logindet_'.$numlogin.'">'.$item.'</td></tr>'); |
|
} |
|
} |
|
} |
|
my $numrow = 0; |
|
foreach my $role (sort(keys(%counts))) { |
|
my $showrole = &Apache::lonnet::plaintext($role,$crstype); |
|
if (ref($counts{$role}) eq 'HASH') { |
|
foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) { |
|
$numrow ++; |
|
my $css_class = $numrow%2?' class="LC_odd_row"':''; |
|
$r->print('<tr '.$css_class.' id="loginsum_'.$numrow.'">'. |
|
'<td>'.$counts{$role}{$sec}.'</td>'. |
|
'<td>'.$showrole.'</td>'. |
|
'<td>'.$sec.'</td></tr>'); |
|
} |
|
} |
|
} |
|
$r->print('<input type="hidden" name="logincount" value="'.$numlogin. |
|
'" /><input type="hidden" name="loginrow" value="'.$numrow. |
|
'" />'); |
|
} |
|
} else { |
|
$r->print('<tr class="LC_empty_row"><td>'. |
|
&mt('There are no '.$interval). |
|
'<input type="hidden" name="logincount" value="'.$logincount. |
|
'." /></td></tr>'); |
|
} |
|
return; |
|
} |
|
|
sub display_coursediscussion { |
sub display_coursediscussion { |
my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; |
my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; |
Line 1845 sub store_interval_setting {
|
Line 2059 sub store_interval_setting {
|
$interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'}; |
$interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'}; |
} elsif ($context eq 'newroles') { |
} elsif ($context eq 'newroles') { |
$interval_settings{$cid.':newroleinterval'} = $env{'form.interval'}; |
$interval_settings{$cid.':newroleinterval'} = $env{'form.interval'}; |
|
} elsif ($context eq 'crslogin') { |
|
$interval_settings{$cid.':crslogininterval'} = $env{'form.interval'}; |
} else { |
} else { |
$interval_settings{$cid.':interval'} = $env{'form.interval'}; |
$interval_settings{$cid.':interval'} = $env{'form.interval'}; |
} |
} |
Line 2000 sub start_box {
|
Line 2216 sub start_box {
|
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
<td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
</tr>'); |
</tr>'); |
} |
} |
|
} elsif (($caller eq 'crslogin') && ($$show{$caller})) { |
|
if ($$show{$caller}) { |
|
$r->print(' |
|
<tr> |
|
<td class="LC_subheader" align="left"><span class="LC_nobreak"><label><input type="radio" name="logindetails" value="0" checked="checked" onclick="javascript:togglelogins();" /> '.&mt('Summary').'</label><label><input type="radio" name="logindetails" value="1" onclick="javascript:togglelogins();" /> '.&mt('Details').'</label></span></td><td class="LC_subheader"><a href="/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td> |
|
</tr>'); |
|
} |
} |
} |
|
|
$r->print(' |
$r->print(' |
<tr> |
<tr> |
<td colspan="2"> |
<td colspan="2"> |