');
+ } else {
+ $r->print(''.$lt{'nopr'}.' ');
+ }
+}
+
+sub display_versionchanges {
+ my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'reso' => 'Resource',
+ 'revd' => 'Last revised',
+ 'newv' => 'New version',
+ 'veru' => 'Version used',
+ 'noup' => 'No updated versions',
+ );
+ my $rowColor;
+ if (keys(%{$changed}) > 0) {
+ $r->print(''.$lt{'reso'}.' '.$lt{'revd'}.' '.$lt{'newv'}.' '.$lt{'veru'}.' ');
+
+
+ my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
+ my $changenum = 0;
+ foreach my $item (@changes) {
+ if ($changenum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
+ my $linkurl=&Apache::lonnet::clutter($url);
+ $linkurl .= '?symb='.&Apache::lonnet::escape($item);
+
+ $r->print(''.$$res_title{$item}.' '.$$changed{$item}{'revdate'}.' '.$$changed{$item}{'current'}.' '.$$changed{$item}{'version'}.' ');
+ $changenum ++;
+ }
+ } else {
+ $r->print(''.$lt{'noup'}.' '.$interval.' ');
+ }
+ return;
+}
+
+sub display_coursediscussion {
+ my ($r,$newdiscussions,$unread,$countunread,$res_title,$rowColor1,
+ $rowColor2) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'loca' => 'Location',
+ 'type' => 'Type',
+ 'numn' => 'Number of new posts',
+ 'noun' => 'No unread posts in course discussions',
+ 'tmlp' => 'Time of last post',
+ );
+ my $rowColor;
+ if (@{$newdiscussions} > 0) {
+ $r->print(''.$lt{'loca'}.
+ ' '.$lt{'type'}.
+ ' ');
+ if ($countunread eq 'on') {
+ $r->print(''.$lt{'tmlp'}.' '.
+ ''.$lt{'numn'}.
+ ' ');
+ } else {
+ $r->print(''.$lt{'tmlp'}.
+ ' ');
+ }
+ $r->print(" \n");
+ @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
+ @{$newdiscussions};
+ my $rowNum = 0;
+ foreach my $ressymb (@{$newdiscussions}) {
+ my $forum_title = $$unread{$ressymb}{'title'};
+ my $type = 'Resource';
+ my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
+ if ($feedurl =~ /bulletinboard/) {
+ $type = 'Bulletin Board';
+ }
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ my $lastpost = &Apache::lonnavmaps::timeToHumanString(
+ $$unread{$ressymb}{'lastpost'});
+ $r->print(''.$forum_title.' '.$type.' ');
+ if ($countunread eq 'on') {
+ my $unreadnum = $$unread{$ressymb}{'unreadcount'};
+ $r->print(''.$lastpost.' '.
+ '',$unreadnum.' ');
+ } else {
+ $r->print(''.$lastpost.' ');
+ }
+ $r->print(" \n");
+ $rowNum ++;
+ }
+ } else {
+ $r->print(' '.
+ $lt{'noun'}.' ');
+ }
+}
+
+sub display_coursenormalmail {
+ my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
+ my $rowColor;
+ if ($msgcount > 0) {
+ $r->print(''.&mt('Number').' '.&mt('Subject').' '.&mt('Sender').' '.&mt('Date/Time').' ');
+ my $rowNum = 0;
+ my $mailcount = 1;
+ foreach my $msg (@{$newmsgs}) {
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ $r->print(''.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
+ $rowNum ++;
+ $mailcount ++;
+ }
+ } else {
+ $r->print(''.&mt('No new course messages').' ');
+ }
+}
+
+sub display_coursecritmail {
+ my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
+ my $rowColor;
+ if ($critmsgcount > 0) {
+ $r->print(''.&mt('Number').' '.&mt('Subject').' '.&mt('Sender').' '.&mt('Date/Time').' ');
+ my $rowNum = 0;
+ my $mailcount = 1;
+ foreach my $msg (@{$critmsgs}) {
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ $r->print(''.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
+ $rowNum ++;
+ $mailcount ++;
+ }
+ } else {
+ $r->print(''.&mt('No unread critical messages in course').' ');
+ }
}
sub cmp_title {
- my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle));
+ my ($a,$b,$res_title) = @_;
+ my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
$atitle=~s/^\s*//;
$btitle=~s/^\s*//;
return $atitle cmp $btitle;
}
+sub get_display_settings {
+ my ($uname,$udom,$cid) = @_;
+ my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
+ my ($tmp) = keys(%settings);
+ if ($tmp=~/^error:/) {
+ %settings = ();
+ unless ($tmp eq 'error: 2 tie(GDBM) Failed while attempting dump') {
+ &logthis('Error retrieving whatsnew settings: '.$tmp.' for '.
+ $uname.':'.$udom.' for course: '.$cid);
+ }
+ }
+ return %settings;
+}
+
+sub store_display_settings {
+ my ($uname,$udom,$cid,$checkallowed) = @_;
+ my %whatsnew_settings;
+ my $result;
+ foreach my $key (keys(%{$checkallowed})) {
+ if (exists($env{'form.display_'.$key})) {
+ unless ($env{'form.display_'.$key} eq '') {
+ $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
+ }
+ }
+ }
+ if (keys(%whatsnew_settings)) {
+ $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
+ $udom,$uname);
+ } else {
+ $result = 'ok';
+ }
+ return $result;
+}
+
+sub store_interval_setting {
+ my ($uname,$udom,$cid,$interval_titles) = @_;
+ my %interval_settings = ();
+ my $result;
+ if (defined($env{'form.interval'})) {
+ $interval_settings{$cid.':interval'} = $env{'form.interval'};
+ my $outcome = &Apache::lonnet::put('nohist_whatsnew',
+ \%interval_settings,$udom,$uname);
+ if ($outcome eq 'ok') {
+ $result = &mt('Interval set to version changes [_1]',
+ ''.$$interval_titles{$env{'form.interval'}}.' ');
+
+ } else {
+ &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
+ ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
+ $result = &mt('Unable to set interval to [_1] due to [_2].',
+ ''.$$interval_titles{$env{'form.interval'}}.' ',
+ ''.$outcome.' . ');
+ }
+ }
+ return $result;
+}
+
+sub store_discussion_setting {
+ my ($uname,$udom,$cid) = @_;
+ my %discussion_settings;
+ my $result;
+ if (defined($env{'form.countunread'})) {
+ $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
+ my $outcome = &Apache::lonnet::put('nohist_whatsnew',
+ \%discussion_settings,$udom,$uname);
+ if ($outcome eq 'ok') {
+ $result = &mt('Count unread posts in discussions display set to [_1]',
+ ''.$env{'form.countunread'}.' ');
+
+ } else {
+ &Apache::lonnet::logthis('Error storing whatsnew countunread setting'.
+ ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
+ $result = &mt('Unable to set "number unread posts display" to [_1]'.
+ ' due to [_2].',
+ ''.$env{'form.countunread'}.' ',
+ ''.$outcome.' . ');
+ }
+ }
+ return $result;
+}
+
+sub store_courseinit_setting {
+ my ($uname,$udom,$cid,$initpage) = @_;
+ my %courseinit_settings;
+ my $page_control;
+ my $result;
+ if (defined($env{'form.courseinit_control'})) {
+ if ($env{'form.courseinit_control'} eq 'userpref') {
+ $courseinit_settings{$cid.':courseinit'} = '';
+ $page_control = 'global preferences';
+ } else {
+ if (defined($env{'form.courseinit_page'})) {
+ $courseinit_settings{$cid.':courseinit'} =
+ $env{'form.courseinit_page'};
+ $page_control = 'course specific setting';
+ }
+ }
+ if ($page_control) {
+ my $outcome = &Apache::lonnet::put('nohist_whatsnew',
+ \%courseinit_settings,$udom,$uname);
+ if ($outcome eq 'ok') {
+ if ($page_control eq 'global preferences') {
+ $result = &mt('Page displayed after role selection in course now set by [_1]',"user's global preferences .");
+ } else {
+ $result = &mt('Page displayed after role selection in this course set to [_1]',''.$$initpage{$env{'form.courseinit_page'}}.' .');
+ }
+ } else {
+ &Apache::lonnet::logthis('Error storing whatsnew courseinit '.
+ 'setting: '.$outcome.' for '.$uname.
+ ':'.$udom.' in course '.$cid);
+ if ($page_control eq 'global preferences') {
+ $result = &mt('Unable to set control of page display to [_1]'.
+ ' due to [_2].',
+ ''.$page_control.' ',
+ ''.$outcome.' . ');
+ } else {
+ $result = &mt('Unable to set page display, after role selection, for this course to [_1] due to [_2].',
+ ''.$$initpage{$env{'form.courseinit_page'}}.' ',
+ ''.$outcome.' . ');
+ }
+ }
+ }
+ }
+ return $result;
+}
+
+sub start_box {
+ my ($r,$tabbg,$show,$heading,$caller,$refpage) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ chth => 'Change thresholds?',
+ chin => 'Change interval?',
+ chop => 'Change options?',
+ );
+ my $showhide;
+ if ($$show{$caller}) {
+ $showhide = 'Hide ';
+
+ } else {
+ $showhide = 'Show ';
+ }
+
+ $r->print('
+
+
+
+
+
+
+
+
+ '.$$heading{$caller}.'
+ '.$showhide.'
+
+
+
+ ');
+ if (($caller eq 'abovethreshold') && ($$show{$caller})) {
+ $r->print('
+
+ '.$lt{'chth'}.'
+ ');
+ } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
+ $r->print('
+
+ '.$lt{'chin'}.'
+ ');
+ } elsif ($caller eq 'coursediscussion') {
+ $r->print('
+
+ '.$lt{'chop'}.'
+ ');
+ }
+ $r->print('
+
+
+
+');
+ return;
+}
+
+sub end_box {
+ my ($r) = shift;
+ $r->print('
+
+
+
+
+
+
+
');
+ return;
+}
+
+1;