-
-
+
+
+
-
-
-
-
- $lt{'cuse'} :
-
-
+
+ $lt{'cuse'} :
END
if ($newpostsflag) {
$discussion .=
@@ -576,27 +608,20 @@ END
}
}
$discussion .= <
-
-
- $lt{'chgt'} ?
-
-
-
+ $lt{'chgt'}
END
if ($sortposts) {
my %sort_types = ();
my %role_types = ();
my %status_types = ();
- &sort_filter_names(\%sort_types,\%role_types,\%status_types);
+ &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype);
- $discussion .= ''.&mt('Sorted by').' : '.$sort_types{$sortposts}.' ';
+ $discussion .= ''.&mt('Sorted by').' : '.$sort_types{$sortposts}.' ';
if (defined($env{'form.totposters'})) {
$discussion .= &mt('Posts by').':';
if ($totposters > 0) {
foreach my $poster (@posters) {
- $poster =~ s/:/\@/;
$discussion .= ' '.$poster.',';
}
$discussion =~ s/,$//;
@@ -609,13 +634,17 @@ END
$filterchoice = ''.&mt('sections').' - '.$env{'form.sectionpick'};
$filterchoice .= ' ';
}
+ if (@grouppick > 0) {
+ $filterchoice = ''.&mt('groups').' - '.$env{'form.grouppick'};
+ $filterchoice .= ' ';
+ }
if (@rolefilter > 0) {
$filterchoice .= ''.&mt('roles').' -';
- foreach (@rolefilter) {
- $filterchoice .= ' '.$role_types{$_}.',';
+ foreach my $role (@rolefilter) {
+ $filterchoice .= ' '.$role_types{$role}.',';
}
$filterchoice =~ s/,$//;
- $filterchoice .= '     ';
+ $filterchoice .= ' '.(' ' x8);
}
if ($statusfilter) {
$filterchoice .= ''.&mt('status').' - '.$status_types{$statusfilter};
@@ -623,15 +652,16 @@ END
if ($filterchoice) {
$discussion .= ''.&mt('Filters').' : '.$filterchoice;
}
- $discussion .= ' ';
}
+ $discussion .= '';
+
}
if ($dischash{$toggkey}) {
- my $storebutton = &mt('Store read/unread changes');
+ my $storebutton = &mt('Save read/unread changes');
$discussion.=''.
- ' '."\n".
+ ' '."\n".
' '."\n".
+ ' onclick="this.form.submit();" />'."\n".
' ';
}
$discussion .= (<
-
-
END
+ $discussion .= &action_links_bar($colspan,$ressymb,$visible,
+ $newpostsflag,$group,
+ $prevread,$markondisp,$seehidden);
+ $discussion .= "
\n";
}
if ($outputtarget eq 'export') {
if ($manifestok) {
@@ -664,22 +696,34 @@ END
#Create zip file in prtspool
- my $imszipfile = '/prtspool/'.
- $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
- time.'_'.rand(1000000000).'.zip';
- my $cwd = &getcwd();
- my $imszip = '/home/httpd/'.$imszipfile;
- chdir $tempexport;
- open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
- close(OUTPUT);
- chdir $cwd;
- $discussion .= 'Download the zip file from Discussion Posting Archive ';
- if ($copyresult) {
- $discussion .= 'The following errors occurred during export - '.$copyresult;
+ if (($env{'user.name'} =~ /^$match_username$/)
+ && ($env{'user.domain'} =~ /^$match_domain$/)) {
+ my $now = time();
+ my $imszipfile = '/prtspool/'.
+ join('_',$env{'user.name'},$env{'user.domain'},$now).
+ '_'.rand(1000000000).'.zip';
+ my $zip = Archive::Zip->new();
+ $zip->addTree($tempexport);
+ my $imszip = '/home/httpd/'.$imszipfile;
+ if ($zip->writeToFileNamed($imszip) == AZ_OK) {
+ $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',
+ '',' ').' ';
+ } else {
+ $discussion .= &mt('Failed to create zip file').' ';
+ }
+ if ($copyresult) {
+ $discussion .= ''.
+ &mt('The following errors occurred during export:').
+ ' '.$copyresult;
+ }
+ } else {
+ $discussion .= ''.
+ &mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating the zip file.').'
';
}
}
} else {
- $discussion .= ' Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file. ';
+ $discussion .= ''.
+ &mt('Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.').'
';
}
return $discussion;
}
@@ -687,93 +731,335 @@ END
if ($discussiononly) {
my $now = time;
my $attachnum = 0;
- my $newattachmsg = '';
- my @currnewattach = ();
- my @currdelold = ();
+ my $currnewattach = [];
+ my $currdelold = [];
my $comment = '';
my $subject = '';
if ($env{'form.origpage'}) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);
- $subject = &Apache::lonnet::unescape($env{'form.subject'});
- $comment = &Apache::lonnet::unescape($env{'form.comment'});
+ $subject = &unescape($env{'form.subject'});
+ $comment = &unescape($env{'form.comment'});
my @keepold = ();
- &process_attachments(\@currnewattach,\@currdelold,\@keepold);
- if (@currnewattach > 0) {
- $attachnum += @currnewattach;
+ &process_attachments($currnewattach,$currdelold,\@keepold);
+ if (@{$currnewattach} > 0) {
+ $attachnum += @{$currnewattach};
}
}
- if (&discussion_open($status)) {
- $discussion.=(<
-
-
-
-
-
-
-Note: in anonymous discussion, your name is visible only
-to course faculty
-Title:
-
-ENDDISCUSS
- if ($env{'form.origpage'}) {
- $discussion.=' '."\n";
- foreach (@currnewattach) {
- $discussion.=' '."\n";
- }
- }
- $discussion.="\n";
- if ($outputtarget ne 'tex') {
- $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);
- if (@currnewattach > 0) {
- $newattachmsg .= 'New attachments ';
- if (@currnewattach > 1) {
- $newattachmsg .= '';
- foreach my $item (@currnewattach) {
- $item =~ m#.*/([^/]+)$#;
- $newattachmsg .= ''.$1.' '."\n";
- }
- $newattachmsg .= ' '."\n";
- } else {
- $currnewattach[0] =~ m#.*/([^/]+)$#;
- $newattachmsg .= ''.$1.' '."\n";
- }
+ if ((&discussion_open($status)) && ($outputtarget ne 'tex')) {
+ if (($group ne '') && ($mode eq 'board')) {
+ if ((&check_group_priv($group,'pgd') eq 'ok') &&
+ ($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) {
+ $discussion .=
+ &postingform_display($mode,$ressymb,$now,$subject,
+ $comment,$outputtarget,$attachnum,
+ $currnewattach,$currdelold,
+ $group,$crstype);
}
- $discussion.=$newattachmsg;
- $discussion.=&generate_preview_button();
- }
+ } else {
+ if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+
+ $discussion.=
+ &postingform_display($mode,$ressymb,$now,$subject,
+ $comment,$outputtarget,$attachnum,
+ $currnewattach,$currdelold,'',$crstype);
+ } else {
+ $discussion.= ''.
+ &mt('This discussion is closed.').' ';
+ }
+ }
}
- } else {
- $discussion.='';
+ if (!(&discussion_open($status)) && ($outputtarget ne 'tex')) {
+ $discussion.= ''.
+ &mt('This discussion is closed.').' ';
+ }
+ } elsif ($outputtarget ne 'tex') {
+ $discussion.='';
if (&discussion_open($status) &&
&Apache::lonnet::allowed('pch',
$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
- if ($outputtarget ne 'tex') {
- $discussion.='
'.
- ' '.
- &mt('Post Discussion').' ';
+ $discussion.= &send_feedback_link($ressymb);
+ if ($env{'request.role.adv'}) {
+ my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
+ my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);
+ if (defined($close) && $close ne '' && $close < time) {
+ if ($canvote eq 'notended') {
+ $discussion .= ' '.&mt('(Posting and voting closed for [_1] roles)',
+ &Apache::lonnet::plaintext('st',$crstype));
+ } else {
+ $discussion .= ' '.&mt('(Closed for [_1] roles)',
+ &Apache::lonnet::plaintext('st',$crstype));
+ }
+ }
}
- }
- $discussion.='
'.
- &mt('Send Message').'
';
+ } else {
+ $discussion.= ''.&mt('This discussion is closed.').' ';
+ }
+ $discussion.= &send_message_link($ressymb).'';
+ }
+ return $discussion;
+}
+
+sub can_see_hidden {
+ my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_;
+ my $seehidden;
+ if ($env{'request.course.id'}) {
+ unless ($cdom ne '' && $cnum ne '') {
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ if ($crs eq '') {
+ $crs = '/'.$env{'request.course.id'};
+ if ($env{'request.course.sec'}) {
+ $crs.='_'.$env{'request.course.sec'};
+ }
+ $crs=~s{_}{/}g;
+ }
+ if ($mode eq '') {
+ $mode='board';
+ if ($feedurl =~ /$LONCAPA::assess_re/) {
+ $mode='problem';
+ }
+ }
+ if (($group ne '') && ($mode eq 'board') &&
+ ($ressymb =~ m{^bulletin___\d+\Q___adm/wrapper/adm/$cdom/$cnum/\E\d+/bulletinboard$})) {
+ if (&check_group_priv($group,'dgp') eq 'ok') {
+ $seehidden = 1;
+ }
+ } else {
+ $seehidden=&Apache::lonnet::allowed('rin',$crs);
+ }
+ }
+ return $seehidden;
+}
+
+sub discussion_link {
+ my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_;
+ my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
+ if ($flag) { $link .= '&previous='.$prev; }
+ if ($adds) { $link .= $adds; }
+ my $width=600;
+ my $height=600;
+ if (($cmd eq 'hide') || ($cmd eq 'unhide') || ($cmd eq 'like') || ($cmd eq 'unlike')) {
+ $width=300;
+ $height=200;
+ }
+ return &Apache::loncommon::modal_link($link,$linktext,$width,$height,undef,undef,$title);
+}
+
+
+sub send_feedback_link {
+ my ($ressymb) = @_;
+ return ''.
+ &discussion_link($ressymb,
+ ' ',
+ 'replydisc').
+ ' ';
+}
+
+sub send_message_link {
+ my ($ressymb) = @_;
+ my $output = ''.
+ &discussion_link($ressymb,
+ ' ',
+ 'sendmessageonly').
+ ' ';
+ return $output;
+}
+
+sub action_links_bar {
+ my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp,
+ $seehidden) = @_;
+ my $discussion = ''.
+ ' ';
return $discussion;
}
+sub postingform_display {
+ my ($mode,$ressymb,$now,$subject,$comment,$outputtarget,$attachnum,
+ $currnewattach,$currdelold,$group,$crstype) = @_;
+ my $newattachmsg;
+ my %lt = &Apache::lonlocal::texthash(
+ 'note' => 'Note: in anonymous discussion, your name is visible only to course faculty',
+ 'title' => 'Title',
+ 'podi' => 'Post Discussion',
+ 'poan' => 'Post Anonymous Discussion',
+ 'newa' => 'New attachments',
+ );
+ if ($crstype eq 'Community') {
+ $lt{'note'} = &mt('Note: in anonymous discussion, your name is visible only to community facilitators');
+ }
+ my ($postingform,$textareaclass);
+ if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+ $postingform = &Apache::lonhtmlcommon::htmlareaselectactive();
+ $textareaclass = 'class="LC_richDefaultOff"';
+ if ($env{'request.course.id'}) {
+ unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
+ undef($textareaclass);
+ }
+ }
+ }
+ $postingform .= (<
+
+
+
+
+$lt{'note'}
+$lt{'title'}:
+
+ENDDISCUSS
+ if ($env{'form.origpage'}) {
+ $postingform .= ' '."\n";
+ foreach my $att (@{$currnewattach}) {
+ $postingform .= ' '."\n";
+ }
+ }
+ if (exists($env{'form.ref'})) {
+ $postingform .= ' ';
+ }
+ if ($group ne '') {
+ $postingform .=' ';
+ }
+ my $blockblog = &Apache::loncommon::blocking_status('blogs');
+ if (!$blockblog) {
+ $postingform .= &add_blog_checkbox($crstype);
+ }
+ $postingform .= "\n";
+ $postingform .= &generate_attachments_button('',$attachnum,$ressymb,
+ $now,$currnewattach,
+ $currdelold,'',$mode,
+ $blockblog);
+ if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
+ $newattachmsg = ''.$lt{'newa'}.' ';
+ if (@{$currnewattach} > 1) {
+ $newattachmsg .= '';
+ foreach my $item (@{$currnewattach}) {
+ $item =~ m#.*/([^/]+)$#;
+ $newattachmsg .= ''.$1.' '."\n";
+ }
+ $newattachmsg .= ' '."\n";
+ } else {
+ $$currnewattach[0] =~ m#.*/([^/]+)$#;
+ $newattachmsg .= ''.$1.' '."\n";
+ }
+ }
+ $postingform .= $newattachmsg;
+ $postingform .= &generate_preview_button();
+ return $postingform;
+}
+
sub build_posting_display {
- my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt) = @_;
+ my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$seehidden,$canvote,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
my @original=();
my @index=();
+ my $skip_group_check = 0;
my $symb=&Apache::lonenc::check_decrypt($ressymb);
- my $escsymb=&Apache::lonnet::escape($ressymb);
+ my $escsymb=&escape($ressymb);
+# These are the discussion contributions
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
-
+ my (%likes,%userlikes,%userunlikes,@theselikes,$oneplus,$twoplus,$oneminus,$twominus);
+ my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
+ if ($seeid || $canvote) {
+# And these are the likes/unlikes
+ %likes=&Apache::lonnet::dump('disclikes',
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'},
+ '^'.$symb.':');
+# Array with likes to figure out averages, etc.
+ @theselikes=();
+# Hashes containing likes and unlikes for this user.
+ %userlikes=();
+ %userunlikes=();
+ }
+# Is the user allowed to see the real name behind anonymous postings?
+ my $see_anonymous =
+ &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
+
+ if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) {
+ $skip_group_check = 1;
+ }
+# Deletions and hiddens are just lists. Split them up into a hash for quicker lookup
+ my (%deletions,%hiddens);
+ if ($contrib{'deleted'}) {
+ my $deleted = $contrib{'deleted'};
+ $deleted =~ s/^\.//;
+ $deleted =~ s/\.$//;
+ %deletions = map { $_ => 1 } (split(/\.\./,$deleted));
+ }
+ if ($contrib{'hidden'}) {
+ my $hidden = $contrib{'hidden'};
+ $hidden =~ s/^\.//;
+ $hidden =~ s/\.$//;
+ %hiddens = map { $_ => 1 } (split(/\.\./,$hidden));
+ }
+# Versions if store/restore are used to actually store the messages.
if ($contrib{'version'}) {
my $oldest = $contrib{'1:timestamp'};
if ($prevread eq '0') {
@@ -781,22 +1067,99 @@ sub build_posting_display {
}
my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp);
if ($sortposts) {
- ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter);
+ ($skiptest,$roleregexp,$secregexp,$statusregexp) =
+ &filter_regexp($rolefilter,$sectionpick,$statusfilter);
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
- }
+ }
+ my %votestyle;
+ if ($seeid || $canvote) {
+# We need to go through this twice, first to get the likes/dislikes, then to actually build the display
+ for (my $id=1;$id<=$contrib{'version'};$id++) {
+ my $idx=$id;
+ next if ($contrib{$idx.':deleted'});
+ next if ($contrib{$idx.':hidden'});
+ unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
+ push(@theselikes,$likes{$symb.':'.$idx.':likes'});
+ if ($likes{$symb.':'.$idx.':likes'} ne '') {
+ if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
+ if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {
+ $userlikes{$idx} = 1;
+ }
+ }
+ if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') {
+ if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) {
+ $userunlikes{$idx} = 1;
+ }
+ }
+ }
+ }
+ }
+# Figure out average likes and standard deviation if there are enough
+# discussions to warrant that
+ my $ave=0;
+ my $stddev=10000;
+ if ($#theselikes>1) {
+ my $sum=0;
+ my $num=$#theselikes+1;
+ foreach my $thislike (@theselikes) {
+ $sum+=$thislike;
+ }
+ $ave=$sum/$num;
+ my $sumsq=0;
+ foreach my $thislike (@theselikes) {
+ $sumsq+=($thislike-$ave)*($thislike-$ave);
+ }
+ $stddev=sqrt($sumsq/$num);
+ }
+# Now we know the average likes $ave and the standard deviation $stddev
+# Get the boundaries for markup
+ $oneplus=$ave+$stddev;
+ $twoplus=$ave+2.*$stddev;
+ $oneminus=$ave-$stddev;
+ $twominus=$ave-2.*$stddev;
+ if ($#theselikes>1) {
+ foreach my $class ('twoplus','oneplus','zero','oneminus','twominus') {
+ my $fontstyle = $env{'course.'.$env{'request.course.id'}.'.discussion_post_fonts_'.$class};
+ if ($fontstyle ne '') {
+ my ($size,$weight,$style,$other) = split(/,/,$fontstyle);
+ if ($size ne '') {
+ $votestyle{$class} .= 'font-size: '.$size.';';
+ }
+ if ($weight ne '') {
+ $votestyle{$class} .= 'font-weight: '.$weight.';';
+ }
+ if ($style ne '') {
+ $votestyle{$class} .= 'font-style: '.$style.';';
+ }
+ if ($other ne '') {
+ $votestyle{$class} .= $other;
+ }
+ if ($votestyle{$class} ne '') {
+ $votestyle{$class} = 'style="'.$votestyle{$class}.'"';
+ }
+ }
+ }
+ }
+ }
+#
+# This is now the real loop. Go through all entries, pick up what we need
+#
for (my $id=1;$id<=$contrib{'version'};$id++) {
my $idx=$id;
+ next if ($contrib{$idx.':deleted'});
+ next if ($contrib{$idx.':hidden'});
+# If we get here, we are actually going to display the message - we don't know where and we don't know if we display
+# previous edits, but it counts as one entry
my $posttime = $contrib{$idx.':timestamp'};
if ($prevread <= $posttime) {
$$newpostsflag = 1;
}
- my $hidden=($contrib{'hidden'}=~/\.$idx\./);
my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./);
- my $deleted=($contrib{'deleted'}=~/\.$idx\./);
my $origindex='0.';
my $numoldver=0;
if ($contrib{$idx.':replyto'}) {
- if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+ if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) ||
+ ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
# this is a follow-up message
$original[$idx]=$original[$contrib{$idx.':replyto'}];
$$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;
@@ -816,11 +1179,11 @@ sub build_posting_display {
} else {
$$replies[$$depth[$idx]]=1;
}
- unless ((($hidden) && (!$seeid)) || ($deleted)) {
+ unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) {
$$visible++;
if ($contrib{$idx.':history'}) {
if ($contrib{$idx.':history'} =~ /:/) {
- my @oldversions = split/:/,$contrib{$idx.':history'};
+ my @oldversions = split(/:/,$contrib{$idx.':history'});
$numoldver = @oldversions;
} else {
$numoldver = 1;
@@ -831,7 +1194,7 @@ sub build_posting_display {
my %subjects = ();
my %attachtxt = ();
my %allattachments = ();
- my ($screenname,$plainname);
+ my ($screenname,$plainname,$showaboutme);
my $sender = &mt('Anonymous');
# Anonymous users getting number within a discussion
# Since idx is in static order, this should give the same sequence every time.
@@ -841,7 +1204,7 @@ sub build_posting_display {
$$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
}
my ($message,$subject,$vgrlink,$ctlink);
- &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver);
+ &get_post_contents(\%contrib,$idx,$seeid,$seehidden,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver);
# Set up for sorting by subject
@@ -850,7 +1213,7 @@ sub build_posting_display {
$message.=$attachtxt{$numoldver};
$subject=$subjects{$numoldver};
if ($message) {
- if ($hidden) {
+ if ($hiddens{$idx}) {
$message=''.$message.' ';
if ($studenthidden) {
$message .=' Deleted by poster (student).';
@@ -859,35 +1222,44 @@ sub build_posting_display {
if ($subject eq '') {
if (defined($$subjectsort{'__No subject'})) {
- push @{$$subjectsort{'__No subject'}}, $idx;
+ push(@{$$subjectsort{'__No subject'}}, $idx);
} else {
@{$$subjectsort{'__No subject'}} = ("$idx");
}
} else {
if (defined($$subjectsort{$subject})) {
- push @{$$subjectsort{$subject}}, $idx;
+ push(@{$$subjectsort{$subject}}, $idx);
} else {
@{$$subjectsort{$subject}} = ("$idx");
}
}
- if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
- $sender=&Apache::loncommon::aboutmewrapper(
- $plainname,
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'}).' ('.
- $contrib{$idx.':sendername'}.' at '.
- $contrib{$idx.':senderdomain'}.')';
+ if (!$contrib{$idx.':anonymous'} || $see_anonymous) {
+ if ($showaboutme) {
+ $sender = &Apache::loncommon::aboutmewrapper(
+ $plainname,
+ $contrib{$idx.':sendername'},
+ $contrib{$idx.':senderdomain'});
+ } else {
+ $sender = $plainname;
+ }
+ if ($see_anonymous) {
+ $sender .= ' ('.$contrib{$idx.':sendername'}.':'.
+ $contrib{$idx.':senderdomain'}.')';
+ }
+ $sender = ''.$sender.' ';
if ($contrib{$idx.':anonymous'}) {
$sender.=' ['.$$anonhash{$key}.'] '.
$screenname;
}
-
+ if ($see_anonymous) {
+ $sender.=&Apache::loncommon::student_image_tag($contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
+ }
# Set up for sorting by domain, then username
unless (defined($$usernamesort{$contrib{$idx.':senderdomain'}})) {
%{$$usernamesort{$contrib{$idx.':senderdomain'}}} = ();
}
if (defined($$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}})) {
- push @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}}, $idx;
+ push(@{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}}, $idx);
} else {
@{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}} = ("$idx");
}
@@ -907,61 +1279,57 @@ sub build_posting_display {
%{$$namesort{$lastname}} = ();
}
if (defined($$namesort{$lastname}{$firstname})) {
- push @{$$namesort{$lastname}{$firstname}}, $idx;
+ push(@{$$namesort{$lastname}{$firstname}}, $idx);
} else {
@{$$namesort{$lastname}{$firstname}} = ("$idx");
}
- if (&editing_allowed()) {
- if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
- $sender.=' '.&mt('Edit').' ';
- unless ($seeid) {
- $sender.=" ';
- }
+ if ($outputtarget ne 'tex') {
+# Add karma stars
+ my $karma=&userkarma($contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
+ for (my $i=1;$i<=$karma;$i++) {
+ $sender.=' ';
}
- }
- if ($seeid) {
- if ($hidden) {
- unless ($studenthidden) {
- $sender.=' ';
}
- $sender .= '">'.&mt('Make Visible').' ';
}
- } else {
- $sender.=' '.&mt('Hide').' ';
- }
- $sender.=' '.&mt('Delete').' ';
+ if ($seehidden) {
+ if ($hiddens{$idx}) {
+ unless ($studenthidden) {
+ $sender.=' '.
+ &discussion_link($ressymb,&mt('Make Visible'),'unhide',$idx,$$newpostsflag,$prevread,&group_args($group));
+ }
+ } else {
+ $sender.=' '.
+ &discussion_link($ressymb,&mt('Hide'),'hide',$idx,$$newpostsflag,$prevread,&group_args($group));
+ }
+ my $grpargs = &group_args($group);
+ $sender.=
+ " ";
+ $sender .= &mt('Delete').' ';
+ }
}
- } else {
+ } else {
if ($screenname) {
$sender=''.$screenname.' ';
} else {
$sender=''.$$anonhash{$key}.' ';
}
+ $sender = ''.$sender.' ';
# Set up for sorting by domain, then username for anonymous
unless (defined($$usernamesort{'__anon'})) {
%{$$usernamesort{'__anon'}} = ();
}
if (defined($$usernamesort{'__anon'}{'__anon'})) {
- push @{$$usernamesort{'__anon'}{'__anon'}}, $idx;
+ push(@{$$usernamesort{'__anon'}{'__anon'}}, $idx);
} else {
@{$$usernamesort{'__anon'}{'__anon'}} = ("$idx");
}
@@ -970,37 +1338,42 @@ sub build_posting_display {
%{$$namesort{'__anon'}} = ();
}
if (defined($$namesort{'__anon'}{'__anon'})) {
- push @{$$namesort{'__anon'}{'__anon'}}, $idx;
+ push(@{$$namesort{'__anon'}{'__anon'}}, $idx);
} else {
@{$$namesort{'__anon'}{'__anon'}} = ("$idx");
}
}
- if (&discussion_open($status) &&
- &Apache::lonnet::allowed('pch',
- $env{'request.course.id'}.
- ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
- $sender.=' ';
+ } else {
+ $ctlink = ''.&mt('Mark read').'? ';
}
- $sender .= '" '.$target.'>'.&mt('Reply').'';
- }
- if ($viewgrades) {
- $vgrlink=&Apache::loncommon::submlink('Submissions',
- $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb);
- }
- if ($$dischash{$readkey}=~/\.$idx\./) {
- $ctlink = ''.&mt('Mark unread').'? ';
- } else {
- $ctlink = ''.&mt('Mark read').'? ';
}
}
#figure out at what position this needs to print
}
if ($outputtarget eq 'export' || $message) {
my $thisindex=$idx;
- if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+ if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) ||
+ ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
$thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);
}
$$alldiscussion{$thisindex}=$idx;
@@ -1010,7 +1383,7 @@ sub build_posting_display {
if ($outputtarget eq 'export') {
%{$$imsitems{$idx}} = ();
$$imsitems{$idx}{'isvisible'}='true';
- if ($hidden) {
+ if ($hiddens{$idx}) {
$$imsitems{$idx}{'isvisible'}='false';
}
$$imsitems{$idx}{'title'}=$subjects{$numoldver};
@@ -1018,7 +1391,7 @@ sub build_posting_display {
$$imsitems{$idx}{'attach'}=$attachtxt{$numoldver};
$$imsitems{$idx}{'timestamp'}=$contrib{$idx.':timestamp'};
$$imsitems{$idx}{'sender'}=$plainname.' ('.
- $contrib{$idx.':sendername'}.' at '.
+ $contrib{$idx.':sendername'}.':'.
$contrib{$idx.':senderdomain'}.')';
$$imsitems{$idx}{'isanonymous'}='false';
if ($contrib{$idx.':anonymous'}) {
@@ -1032,16 +1405,17 @@ sub build_posting_display {
} else {
if ($message) {
my $spansize = 2;
+ my ($uname,$udom);
if ($showonlyunread && $prevread > $posttime) {
$$notshown{$idx} = 1;
} elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) {
$$notshown{$idx} = 1;
} else {
# apply filters
- my $uname = $contrib{$idx.':sendername'};
- my $udom = $contrib{$idx.':senderdomain'};
+ $uname = $contrib{$idx.':sendername'};
+ $udom = $contrib{$idx.':senderdomain'};
my $poster = $uname.':'.$udom;
- if (defined($env{'form.totposters'})) {
+ if ($env{'form.totposters'} ne '') {
if ($totposters == 0) {
$$shown{$idx} = 0;
} elsif ($totposters > 0) {
@@ -1066,6 +1440,23 @@ sub build_posting_display {
}
}
}
+ if ($$shown{$idx} && !$skip_group_check) {
+ my $showflag = 0;
+ if (ref($$classgroups{$poster}{active}) eq 'HASH') {
+ foreach my $grp (@{$grouppick}) {
+ if (grep/^\Q$grp\E$/,
+ keys(%{$$classgroups{$poster}{active}})) {
+ $showflag = 1;
+ last;
+ }
+ }
+ }
+ if ($showflag) {
+ $$shown{$idx} = 1;
+ } else {
+ $$shown{$idx} = 0;
+ }
+ }
} else {
$$shown{$idx} = 1;
}
@@ -1073,34 +1464,91 @@ sub build_posting_display {
unless ($$notshown{$idx} == 1) {
if ($prevread > 0 && $prevread <= $posttime) {
$$newitem{$idx} = 1;
- $$discussionitems[$idx] .= '
-
- NEW ';
+ $$discussionitems[$idx] .= ''.&mt('NEW').' ';
} else {
$$newitem{$idx} = 0;
- $$discussionitems[$idx] .= '
-
- ';
- }
- $$discussionitems[$idx] .= ' '.
- ''.$subject.' '.
- $sender.' '.$vgrlink.' ('.
- &Apache::lonlocal::locallocaltime($posttime).') ';
+ }
+ $$discussionitems[$idx] .= ''.$subject.' '.
+ $sender.' '.$vgrlink.' ('.
+ &Apache::lonlocal::locallocaltime($posttime).')';
if ($$dischash{$toggkey}) {
- $$discussionitems[$idx].=' '.
- $ctlink.' ';
+ $$discussionitems[$idx].=' '.$ctlink;
+ }
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ my $likestyle;
+ if ($seeid || $canvote) {
+# Figure out size based on likes
+ my $class = 'zero';
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ if ($thislikes>$twoplus) {
+ $class = 'twoplus';
+ } elsif ($thislikes>$oneplus) {
+ $class = 'oneplus';
+ }
+ if ($thislikes<$twominus) {
+ $class = 'twominus';
+ } elsif ($thislikes<$oneminus) {
+ $class = 'oneminus';
+ }
+ $likestyle = $votestyle{$class};
+ }
+# Actually glue in the message itself
+ $$discussionitems[$idx].= ''.
+ "".
+ $message.
+ '
';
+ if ($canvote) {
+ my $ownpost;
+ if (($uname eq $env{'user.name'}) &&
+ ($udom eq $env{'user.domain'})) {
+ $ownpost = 1;
+ }
+# Put in the like and unlike buttons
+ if ($ownpost || (($hiddens{$idx}) && ($seehidden))) {
+ my $novote;
+ if ($ownpost) {
+ $novote = &mt('No voting for your own posts.');
+ } else {
+ $novote = &mt('No voting for hidden posts.');
+ }
+ &html_escape(\$novote);
+ $$discussionitems[$idx].=
+ ''.
+ ' '.
+ ' ';
+
+ } else {
+ if ($userlikes{$idx}) {
+ $$discussionitems[$idx].=' ';
+ } else {
+ $$discussionitems[$idx].=' '.&discussion_link($ressymb,' ','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
+ }
+ if ($userunlikes{$idx}) {
+ $$discussionitems[$idx].=' ';
+ } else {
+ $$discussionitems[$idx].=' '.&discussion_link($ressymb,' ','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
+ }
+ }
+ }
+ if ($seeid || $canvote) {
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ if ($thislikes>0) {
+ $$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')';
+ } elsif ($thislikes<0) {
+ $$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')';
+ }
}
- $$discussionitems[$idx].= '
'.
- $message.' ';
+# If there is any history to this post, inform the reader
if ($contrib{$idx.':history'}) {
my @postversions = ();
- $$discussionitems[$idx] .= &mt('This post has been edited by the author.');
- if ($seeid) {
- $$discussionitems[$idx] .= ' '.&mt('Display all versions').' ';
+ $$discussionitems[$idx] .= ' '.&mt('This post has been edited by the author.');
+ if ($seehidden) {
+ $$discussionitems[$idx] .= ' '.
+ &discussion_link($ressymb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group));
}
$$discussionitems[$idx].=' '.&mt('Earlier version(s) were posted on: ');
if ($contrib{$idx.':history'} =~ m/:/) {
- @postversions = split/:/,$contrib{$idx.':history'};
+ @postversions = split(/:/,$contrib{$idx.':history'});
} else {
@postversions = ("$contrib{$idx.':history'}");
}
@@ -1109,12 +1557,19 @@ sub build_posting_display {
$$discussionitems[$idx] .= ''.$version.'. - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' ';
}
}
+# end of unless ($$notshown ...)
}
+# end of if ($message) ...
}
+# end of the else-branch of target being export
}
+# end of unless hidden or deleted
}
+# end of the loop over all discussion entries
}
+# end of "if there actually are any discussions
}
+# end of subroutine "build_posting_display"
}
sub filter_regexp {
@@ -1123,9 +1578,9 @@ sub filter_regexp {
my $skiptest = 1;
if (@{$rolefilter} > 0) {
my @okrolefilter = ();
- foreach (@{$rolefilter}) {
- unless ($_ eq '') {
- push @okrolefilter, $_;
+ foreach my $role (@{$rolefilter}) {
+ unless ($role eq '') {
+ push(@okrolefilter, $role);
}
}
if (@okrolefilter > 0) {
@@ -1143,9 +1598,9 @@ sub filter_regexp {
}
if (@{$sectionpick} > 0) {
my @oksectionpick = ();
- foreach (@{$sectionpick}) {
- unless ($_ eq '') {
- push @oksectionpick, $_;
+ foreach my $sec (@{$sectionpick}) {
+ unless ($sec eq '') {
+ push(@oksectionpick, $sec);
}
}
if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) {
@@ -1159,6 +1614,7 @@ sub filter_regexp {
$secregexp .= '[^:]*';
}
}
+
if (defined($statusfilter) && $statusfilter ne '') {
if ($statusfilter eq 'all') {
$statusregexp = '[^:]+';
@@ -1172,14 +1628,14 @@ sub filter_regexp {
sub get_post_contents {
- my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;
+ my ($contrib,$idx,$seeid,$seehidden,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_;
my $discussion = '';
my $start=$numver;
my $end=$numver + 1;
%{$$imsfiles{$idx}}=();
if ($type eq 'allversions') {
- unless($seeid) {
- $discussion=&mt('You do not have privileges to view all versions of posts.').&mt('Please select a different role');
+ unless($seehidden) {
+ $discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.');
return $discussion;
}
}
@@ -1190,13 +1646,20 @@ sub get_post_contents {
$$contrib{$idx.':sendername'},
$$contrib{$idx.':senderdomain'});
$$screenname=$$contrib{$idx.':screenname'};
-
- my $sender=&Apache::loncommon::aboutmewrapper(
+ $$showaboutme = &Apache::lonnet::usertools_access($$contrib{$idx.':sendername'},
+ $$contrib{$idx.':senderdomain'},
+ 'aboutme');
+ my $sender = $$plainname;
+ if ($$showaboutme) {
+ $sender = &Apache::loncommon::aboutmewrapper(
$$plainname,
$$contrib{$idx.':sendername'},
- $$contrib{$idx.':senderdomain'}).' ('.
- $$contrib{$idx.':sendername'}.' at '.
- $$contrib{$idx.':senderdomain'}.')';
+ $$contrib{$idx.':senderdomain'});
+ }
+ if ($seeid) {
+ $sender .= ' ('.$$contrib{$idx.':sendername'}.':'.
+ $$contrib{$idx.':senderdomain'}.')';
+ }
my $attachmenturls = $$contrib{$idx.':attachmenturl'};
my @postversions = ();
if ($type eq 'allversions' || $type eq 'export') {
@@ -1206,7 +1669,7 @@ sub get_post_contents {
}
&get_post_versions($messages,$$contrib{$idx.':message'},1);
&get_post_versions($subjects,$$contrib{$idx.':subject'},1);
- push @postversions,$$contrib{$idx.':timestamp'};
+ push(@postversions,$$contrib{$idx.':timestamp'});
$end = @postversions;
} else {
&get_post_versions($messages,$$contrib{$idx.':message'},1,$numver);
@@ -1223,7 +1686,9 @@ sub get_post_contents {
my ($timesent,$attachmsg);
my %currattach = ();
$timesent = &Apache::lonlocal::locallocaltime($postversions[$i]);
- &newline_to_br(\$messages->{$i});
+ unless (&contains_block_html($messages->{$i})) {
+ &newline_to_br(\$messages->{$i});
+ }
$$messages{$i}=&Apache::lontexconvert::msgtexconverted($$messages{$i});
$$subjects{$i}=~s/\n/\ /g;
$$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i});
@@ -1233,18 +1698,18 @@ sub get_post_contents {
if ($type eq 'export') {
$$imsfiles{$idx}{$i} = '';
if ($attachmsg) {
- $$attachtxt{$i} = ' Attachments: ';
- foreach (sort keys %currattach) {
- if ($$allattachments{$_}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
+ $$attachtxt{$i} = ' '.&mt('Attachments').': ';
+ foreach my $key (sort(keys(%currattach))) {
+ if ($$allattachments{$key}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
my $fname = $1.$3.'/'.$4;
- $$imsfiles{$idx}{$i} .= ''."\n";
+ $$imsfiles{$idx}{$i} .= ' '."\n";
$$attachtxt{$i}.= ''.$4.' ';
}
}
}
} else {
if ($attachmsg) {
- $$attachtxt{$i} = ' Attachments:'.$attachmsg.' ';
+ $$attachtxt{$i} = ' '.&mt('Attachments').':'.$attachmsg.' ';
} else {
$$attachtxt{$i} = '';
}
@@ -1268,11 +1733,11 @@ END
sub replicate_attachments {
my ($attachrefs,$tempexport) = @_;
my $response;
- foreach my $id (keys %{$attachrefs}) {
+ foreach my $id (keys(%{$attachrefs})) {
if ($$attachrefs{$id}{'filename'} =~ m-^/uploaded/([^/]+)/([^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
my $path = $tempexport;
my $tail = $1.'/'.$2.$4;
- my @extras = split/\//,$tail;
+ my @extras = split(/\//,$tail);
my $destination = $tempexport.'/'.$1.'/'.$2.$4.'/'.$5;
if (!-e $destination) {
my $i= 0;
@@ -1291,11 +1756,11 @@ sub replicate_attachments {
print $attachcopy $content;
close($attachcopy);
} else {
- $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$!.' '."\n";
+ $response .= &mt('Error copying file attachment - [_1] to IMS package',$5).': '.$!.' '."\n";
}
} else {
&Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode");
- $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$rtncode.' '."\n";
+ $response .= &mt('Error copying file attachment - [_1] to IMS package: ',$5).$rtncode.' '."\n";
}
}
}
@@ -1304,13 +1769,20 @@ sub replicate_attachments {
}
sub mail_screen {
- my ($r,$feedurl,$options) = @_;
+ my ($r,$feedurl,$options,$caller_symb,$attachmaxtext) = @_;
if (exists($env{'form.origpage'})) {
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog','group','ref']);
}
- my $title=&Apache::lonnet::gettitle($feedurl);
- if (!$title) { $title = $feedurl; }
+ my %lt = &Apache::lonlocal::texthash(
+ 'myqu' => 'Question/comment/feedback:',
+ 'reta' => 'Retained attachments',
+ 'atta' => 'Attachment',
+ );
+ if ($env{'form.editdisc'} || $env{'form.replydisc'}){
+ $lt{'myqu'} = &mt('Post Discussion');
+ }
+ my $restitle = &get_resource_title($caller_symb,$feedurl);
my $quote='';
my $subject = '';
my $comment = '';
@@ -1374,63 +1846,49 @@ END
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
+ my $numoldver = 0;
if ($contrib{$idx.':history'}) {
if ($contrib{$idx.':history'} =~ /:/) {
- my @oldversions = split/:/,$contrib{$idx.':history'};
+ my @oldversions = split(/:/,$contrib{$idx.':history'});
$numoldver = @oldversions;
} else {
$numoldver = 1;
}
}
- if ($env{'form.replydisc'}) {
- if ($contrib{$idx.':history'}) {
- if ($contrib{$idx.':history'} =~ /:/) {
- my @oldversions = split/:/,$contrib{$idx.':history'};
- $numoldver = @oldversions;
- } else {
- $numoldver = 1;
- }
- }
- my $message;
- if ($idx > 0) {
- my %msgversions = ();
- &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
- $message = $msgversions{$numoldver};
+ if ($idx > 0) {
+ my (%msgversions,%subversions,$htmldecode);
+ $htmldecode = 0;
+ if ($env{'form.replydisc'}) {
+ $htmldecode = 1;
}
- &newline_to_br(\$message);
- $quote=''.&Apache::lontexconvert::msgtexconverted($message).' ';
- if ($idx > 0) {
- my %subversions = ();
- &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver);
- $subject = 'Re: '.$subversions{$numoldver};
- }
- $subject = &HTML::Entities::encode($subject,'<>&"');
- } else {
- $attachmenturls = $contrib{$idx.':attachmenturl'};
- if ($idx > 0) {
- my %msgversions = ();
- &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
+ &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver);
+ &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode,
+ $numoldver);
+ $subject = $subversions{$numoldver};
+ if ($env{'form.replydisc'}) {
+ $quote = $msgversions{$numoldver};
+ $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"');
+ } else {
$comment = $msgversions{$numoldver};
- my %subversions = ();
- &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver);
- $subject = $subversions{$numoldver};
}
+ }
+ if ($env{'form.editdisc'}) {
+ $attachmenturls = $contrib{$idx.':attachmenturl'};
if (defined($contrib{$idx.':replyto'})) {
$parentmsg = $contrib{$idx.':replyto'};
}
unless (exists($env{'form.origpage'})) {
- my $anonflag = 0;
+ my $anonflag = 'nonanon';
if ($contrib{$idx.':anonymous'}) {
- $anonflag = 1;
+ $anonflag = 'anon';
}
$anonscript = (<
//
+
END
+ my ($textareaheader,$textareaclass);
+ if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+ $textareaheader = &Apache::lonhtmlcommon::htmlareaselectactive();
+ $textareaclass = 'class="LC_richDefaultOff"';
+ if ($env{'request.course.id'}) {
+ unless (($env{'course.'.$env{'request.course.id'}.'.allow_limited_html_in_feedback'} =~ /^\s*yes\s*$/i) || ($env{'form.sendmessageonly'})) {
+ undef($textareaclass);
+ }
+ }
+ }
+
+ # Breadcrumbs
+ my $brcrum = [{'href' => '',
+ 'text' => 'Resource Feedback and Discussion'}];
+
my %onload = ('onload' => 'window.focus();setposttype();');
+ my %parms=('add_entries' => \%onload);
+ if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; }
my $start_page=
- &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,
- {'add_entries' => \%onload});
+ &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms);
+ if ($quote ne '') {
+ $quote = &HTML::Entities::decode($quote);
+ unless (&contains_block_html($quote)) {
+ &newline_to_br(\$quote);
+ }
+ $quote=&Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title(&mt('Quote')).
+ &Apache::lontexconvert::msgtexconverted($quote).
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box();
+ }
+ my $header='';
+ unless ($env{'form.modal'}) {
+ $header="$restitle ";
+ }
$r->print(<$title
+$lt{'myqu'}
+$header
END
if ($env{'form.editdisc'} || $env{'form.replydisc'}) {
my $now = time;
my $ressymb = $symb;
+ &Apache::lonenc::check_encrypt(\$ressymb);
my $postidx = '';
if ($env{'form.editdisc'}) {
$postidx = $idx;
@@ -1580,10 +2082,10 @@ END
if (@currnewattach > 0) {
$attachnum += @currnewattach;
}
- $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver));
+ my $blockblog = &Apache::loncommon::blocking_status('blogs');
if ($attachnum > 0) {
if (@currnewattach > 0) {
- $newattachmsg .= 'New attachments ';
+ $newattachmsg .= ''.&mt('New attachments').' ';
if (@currnewattach > 1) {
$newattachmsg .= '';
foreach my $item (@currnewattach) {
@@ -1597,15 +2099,15 @@ END
}
}
if ($attachmsg) {
- $r->print("Retained attachments :$attachmsg \n");
+ $r->print("$lt{'reta'} :$attachmsg \n");
}
if ($newattachmsg) {
- $r->print("$newattachmsg ");
+ $r->print("$newattachmsg");
}
}
+ $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver,'',$blockblog));
}
$r->print(&generate_preview_button().
- &Apache::lonhtmlcommon::htmlareaselectactive('comment').
&Apache::loncommon::end_page());
}
@@ -1625,14 +2127,14 @@ sub print_display_options {
'actn' => 'Action',
'deff' => 'Default for all discussions',
'prca' => 'Preferences can be set for this discussion that determine ....',
- 'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and',
+ 'whpo' => 'Which posts are displayed when you display this discussion board or resource, and',
'unwh' => 'Under what circumstances posts are identified as "NEW", and',
'wipa' => 'Whether individual posts can be marked as read/unread',
'allposts' => 'All posts',
'unread' => 'New posts only',
'unmark' => 'Posts not marked read',
'ondisp' => 'Once displayed',
- 'onmark' => 'Once marked not NEW ',
+ 'onmark' => 'Once marked not NEW',
'toggon' => 'Shown',
'toggoff' => 'Not shown',
'disa' => 'Posts displayed?',
@@ -1643,6 +2145,11 @@ sub print_display_options {
'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
'ywbr' => 'You will be returned to the previous page if you click OK.'
);
+ my %js_lt = &Apache::lonlocal::texthash(
+ 'yhni' => 'You have not indicated that you wish to change any of the discussion settings',
+ 'ywbr' => 'You will be returned to the previous page if you click OK.'
+ );
+ &js_escape(\%js_lt);
my $dispchangeA = $lt{'unread'};
my $dispchangeB = $lt{'unmark'};
@@ -1736,7 +2243,7 @@ function setDisp() {
if (chktotal > 0) {
document.modifydisp.submit()
} else {
- if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}")) {
+ if(confirm("$js_lt{'yhni'}. \\n$js_lt{'ywbr'}")) {
if (prev > 0) {
location.href = "$feedurl?previous=$previous"
} else {
@@ -1755,7 +2262,7 @@ END
&Apache::loncommon::end_page();
$r->print(<
+
$end_page
-END
+ ");
return;
}
@@ -1820,8 +2336,18 @@ sub print_sortfilter_options {
my @sections;
my $section_sel = '';
my $numvisible = 5;
+ my @groups;
+ my $group_sel = '';
+ my $numgroupvis = 5;
my %sectioncount = &Apache::loncommon::get_sections();
-
+ my @courseroles = qw(st ad ep ta in);
+ my $crstype = &Apache::loncommon::course_type();
+ my $ccrole = 'cc';
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ }
+ push(@courseroles,$ccrole);
+
if ($env{'request.course.sec'} !~ /^\s*$/) { #Restrict section choice to current section
@sections = ('all',$env{'request.course.sec'});
$numvisible = 2;
@@ -1833,10 +2359,36 @@ sub print_sortfilter_options {
unshift(@sections,'all'); # Put 'all' at the front of the list
}
- foreach (@sections) {
- $section_sel .= " $_\n";
+ foreach my $sec (@sections) {
+ $section_sel .= " $sec \n";
+ }
+
+ if (&check_group_priv() eq 'ok') {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ @groups = sort {$a cmp $b} keys(%curr_groups);
+ if (scalar(@groups) < 4) {
+ $numgroupvis = scalar(@groups) + 1;
+ }
+ unshift(@groups,'all'); # Put 'all' at the front of the list
+ } else {
+ my @coursegroups = split(/:/,$env{'request.course.groups'});
+ if (@coursegroups > 0) {
+ @coursegroups = sort {$a cmp $b} @coursegroups;
+ @groups = ('all',@coursegroups);
+ if (scalar(@groups) < 4) {
+ $numgroupvis = scalar(@groups) + 1;
+ }
+ } else {
+ @groups = ('all');
+ $numgroupvis = 1;
+ }
+ }
+ foreach my $group (@groups) {
+ $group_sel .= " $group \n";
}
-
+
my $function = &Apache::loncommon::get_users_function();
my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
$env{'user.domain'});
@@ -1849,14 +2401,16 @@ sub print_sortfilter_options {
'spur' => 'Specific user roles',
'sprs' => 'Specific role status',
'spse' => 'Specific sections',
+ 'spgr' => 'Specific groups',
'psub' => 'Pick specific users (by name)',
- 'shal' => 'Show a list of current posters'
+ 'shal' => 'Show a list of current posters',
+ 'stor' => 'Save changes',
);
my %sort_types = ();
my %role_types = ();
my %status_types = ();
- &sort_filter_names(\%sort_types,\%role_types,\%status_types);
+ &sort_filter_names(\%sort_types,\%role_types,\%status_types,$crstype);
my $js = <
@@ -1880,6 +2434,17 @@ function verifyFilter() {
if (secnum == 0) {
document.modifyshown.sectionpick.options[0].selected = true
}
+
+ var grpnum = 0
+ for (var i=0; i
@@ -1892,73 +2457,91 @@ END
$r->print(<
+
$end_page
-END
+");
}
sub print_showposters {
@@ -1968,24 +2551,28 @@ sub print_showposters {
$r->send_http_header;
&Apache::lonenc::check_encrypt(\$symb);
- my $crs='/'.$env{'request.course.id'};
- if ($env{'request.course.sec'}) {
- $crs.='_'.$env{'request.course.sec'};
- }
- $crs=~s/\_/\//g;
- my $seeid=&Apache::lonnet::allowed('rin',$crs);
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $group = $env{'form.group'};
+ my $ressymb = &wrap_symb($symb);
+ my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum);
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
+ $cdom,$cnum);
my %namesort = ();
my %postcounts = ();
+ my %lt = &Apache::lonlocal::texthash(
+ sele => 'Select',
+ full => 'Fullname',
+ usdo => 'Username:domain',
+ post => 'Posts',
+ );
if ($contrib{'version'}) {
for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
my $hidden=($contrib{'hidden'}=~/\.$idx\./);
my $deleted=($contrib{'deleted'}=~/\.$idx\./);
- unless ((($hidden) && (!$seeid)) || ($deleted)) {
- if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
+ unless ((($hidden) && (!$seehidden)) || ($deleted)) {
+ if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) {
my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
my $lastname = $names{'lastname'};
my $firstname = $names{'firstname'};
@@ -2002,44 +2589,44 @@ sub print_showposters {
$postcounts{$poster} ++;
if (defined($namesort{$lastname}{$firstname})) {
if (!grep/^$poster$/,@{$namesort{$lastname}{$firstname}}) {
- push @{$namesort{$lastname}{$firstname}}, $poster;
+ push(@{$namesort{$lastname}{$firstname}}, $poster);
}
} else {
@{$namesort{$lastname}{$firstname}} = ("$poster");
}
}
}
- }
+ }
}
my $start_page = &Apache::loncommon::start_page('Discussion options');
my $table_start =&Apache::loncommon::start_data_table();
$r->print(<
+
$end_page
END
@@ -2122,36 +2710,39 @@ sub get_post_attachments {
sub fail_redirect {
my ($r,$feedurl) = @_;
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
+ my %lt = &Apache::lonlocal::texthash(
+ 'sorr' => 'Sorry, no recipients ...',
+ );
my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
$r->print(&Apache::loncommon::start_page('Feedback not sent',undef,
{'redirect' => [2,$feedurl],
'only_body' => 1,}));
$r->print(<
-Sorry, no recipients ...
+$lt{'sorr'}
ENDFAILREDIR
$r->print(&Apache::loncommon::end_page());
}
sub redirect_back {
- my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
+ my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_;
my $sorttag = '';
my $roletag = '';
my $statustag = '';
my $sectag = '';
+ my $grptag = '';
my $userpicktag = '';
my $qrystr = '';
my $prevtag = '';
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
-
&dewrapper(\$feedurl);
if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
if ($previous > 0) {
$qrystr = 'previous='.$previous;
if ($feedurl =~ /\?register=1/) {
- $feedurl .= '&'.$qrystr;
+ $feedurl .= '&'.$qrystr;
} else {
$feedurl .= '?'.$qrystr;
}
@@ -2160,68 +2751,94 @@ sub redirect_back {
if (defined($sort)) {
my $sortqry = 'sortposts='.$sort;
if (($feedurl =~ /\?register=1/) || ($feedurl =~ /\?previous=/)) {
- $feedurl .= '&'.$sortqry;
+ $feedurl .= '&'.$sortqry;
} else {
$feedurl .= '?'.$sortqry;
}
$sorttag = ' ';
if (defined($numpicks)) {
my $userpickqry = 'totposters='.$numpicks;
- $feedurl .= '&'.$userpickqry;
+ $feedurl .= '&'.$userpickqry;
$userpicktag = ' ';
} else {
if (ref($sectionpick) eq 'ARRAY') {
- $feedurl .= '§ionpick=';
+ $feedurl .= '§ionpick=';
$sectag .= ' ';
} else {
- $feedurl .= '§ionpick='.$sectionpick;
+ $feedurl .= '§ionpick='.$sectionpick;
$sectag = ' ';
}
+ if (ref($grouppick) eq 'ARRAY') {
+ $feedurl .= '&grouppick=';
+ $sectag .= ' ';
+ } else {
+ $feedurl .= '&grouppick='.$grouppick;
+ $grptag = ' ';
+ }
if (ref($rolefilter) eq 'ARRAY') {
- $feedurl .= '&rolefilter=';
+ $feedurl .= '&rolefilter=';
$roletag .= ' ';
} else {
- $feedurl .= '&rolefilter='.$rolefilter;
+ $feedurl .= '&rolefilter='.$rolefilter;
$roletag = ' ';
}
- $feedurl .= '&statusfilter='.$statusfilter;
+ $feedurl .= '&statusfilter='.$statusfilter;
$statustag =' ';
}
}
- $feedurl=&Apache::lonenc::check_encrypt($feedurl);
+ my $grouptag;
+ if ($group ne '') {
+ $grouptag = ' ';
+ my $refarg;
+ if (exists($env{'form.ref'})) {
+ $refarg = '&ref='.$env{'form.ref'};
+ $grouptag .= ' ';
+ }
+ if ($feedurl =~ /\?/) {
+ $feedurl .= '&group='.$group.$refarg;
+ } else {
+ $feedurl .= '?group='.$group.$refarg;
+ }
+ }
+ &Apache::lonenc::check_encrypt(\$feedurl);
my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
- my %onload;
- if ($env{'environment.remote'} ne 'off') {
- $onload{'onload'} =
- "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
+ my %parms=('only_body' => 1);
+ if ($env{'form.modal'}) {
+ $parms{'add_entries'}={'onLoad' => 'document.forms.reldt.submit()'};
+ } else {
+ $parms{'redirect'}=[0,$feedurl];
}
my $start_page=
- &Apache::loncommon::start_page('New posts marked as read',undef,
- {'redirect' => [2,$feedurl],
- 'only_body' => 1,
- 'add_entries' => \%onload});
+ &Apache::loncommon::start_page('Feedback sent',undef,\%parms);
my $end_page = &Apache::loncommon::end_page();
-
$r->print(<
$typestyle
Sent $sendsomething message(s), and $sendposts post(s).
$blog
+$toolarge
$status
$end_page
ENDREDIR
@@ -2237,20 +2856,16 @@ ENDREDIR
sub no_redirect_back {
my ($r,$feedurl) = @_;
- my $nofeed=&mt('Sorry, no feedback possible on this resource ...');
+ my $nofeed=&mt('Sorry, no feedback possible on this resource ...');
my %onload;
- if ($env{'environment.remote'} ne 'off') {
- $onload{'onload'} =
- "if (window.name!='loncapaclient') { self.window.close(); }";
- }
my %body_options = ('only_body' => 1,
'bgcolor' => '#FFFFFF',
'add_entries' => \%onload,);
if ($feedurl !~ m{^/adm/feedback}) {
- $body_options{'rediect'} = [2,$feedurl];
+ $body_options{'redirect'} = [2,$feedurl];
}
my $start_page=
&Apache::loncommon::start_page('Feedback not sent',undef,
@@ -2258,7 +2873,7 @@ sub no_redirect_back {
my $end_page = &Apache::loncommon::end_page();
- $feedurl=&Apache::lonenc::check_encrypt($feedurl);
+ &Apache::lonenc::check_encrypt(\$feedurl);
my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
$r->print (< '.
- &mt('Feedback to resource author').' ';
+ ' '.
+ &mt('Feedback to resource author').' ';
+ }
+ my %optionhash=();
+ foreach my $type ('question','comment','policy') {
+ $optionhash{$type}=$env{'course.'.$env{'request.course.id'}.'.'.$type.'.email.text'};
}
if (&feedback_available(1)) {
$msgoptions.=
- ' '.
- &mt('Question about resource content').'
';
+ ' '.
+ ($optionhash{'question'}?$optionhash{'question'}:&mt('Question about resource content')).' ';
}
if (&feedback_available(0,1)) {
$msgoptions.=
- ' '.
- &mt('Question/Comment/Feedback about course content').
- '
';
+ ' '.
+ ($optionhash{'comment'}?$optionhash{'comment'}:$crscontent).
+ ' ';
}
if (&feedback_available(0,0,1)) {
$msgoptions.=
- ' '.
- &mt('Question/Comment/Feedback about course policy').
- '
';
+ ' '.
+ ($optionhash{'policy'}?$optionhash{'policy'}:$crspolicy).
+ ' ';
}
}
if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) {
- if (&discussion_open(undef,$symb) &&
- &Apache::lonnet::allowed('pch',
- $env{'request.course.id'}.
- ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+ my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards');
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $realsymb = &get_realsymb($symb);
+ if (!$blocked && &discussion_open(undef,$realsymb) &&
+ (&Apache::lonnet::allowed('pch',
+ $env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
+ (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) {
$discussoptions=' '.
- &mt('Contribution to course discussion of resource');
- $discussoptions.=' '.
- &mt('Anonymous contribution to course discussion of resource').
- ' ('.&mt('name only visible to course faculty').') '.
+ $contribdisc.
+ ' '.
+ $anoncontrib.
+ ' ('.$namevis.') '.
''.&mt('Change Screenname').' ';
+ my $blockblog = &Apache::loncommon::blocking_status('blogs');
+ if (!$blockblog) {
+ $discussoptions.= &add_blog_checkbox($crstype);
+ }
}
- $discussoptions.=' '.
- &mt('Add to my public course blog').' ';
}
- if ($msgoptions) { $msgoptions=' '.&mt('Sending Messages').' '.$msgoptions; }
+ if ($msgoptions) {
+ $msgoptions=' '
+ .' '.&mt('Send Feedback').' '.&Apache::lonhtmlcommon::coursepreflink(&mt('Feedback Settings'),'feedback').' '.
+ ''.$msgoptions.' ';
+ }
if ($discussoptions) {
- $discussoptions=' '.&mt('Discussion Contributions').' '.$discussoptions; }
- return $msgoptions.$discussoptions;
+ $discussoptions=' '
+ .' '.&mt('Discussion Contributions').' '.&Apache::lonhtmlcommon::coursepreflink(&mt('Discussion Settings'),'discussion').' '.
+ ''.$discussoptions.' ';
+ }
+ return &Apache::loncommon::start_data_table().$msgoptions.$discussoptions.&Apache::loncommon::end_data_table();
}
sub resource_output {
@@ -2332,9 +2981,7 @@ sub resource_output {
}
sub clear_out_html {
- my ($message,$override,$ignore_htmlarea)=@_;
- if (!$ignore_htmlarea
- && !&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }
+ my ($message,$override)=@_;
# Always allow the -tag
my %html=(M=>1);
# Check if more is allowed
@@ -2343,181 +2990,166 @@ sub clear_out_html {
($override)) {
# allows
#
- #
+ #
%html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
- BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
- M=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1,
- H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
+ BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, PRE=>1, DIV=>1, IMG=>1,
+ M=>1, CHEM=>1, ALGEBRA=>1, SUB=>1, SUP=>1, SPAN=>1,
+ H1=>1, H2=>1, H3=>1, H4=>1, H5=>1, H6=>1,
+ TABLE=>1, TR=>1, TD=>1, TH=>1, TBODY=>1);
}
# Do the substitution of everything that is not explicitly allowed
- $message =~ s/\<(\/?\s*(\w*)[^\>\<]*)/
+ $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
{($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge;
- $message =~ s/(\\s*(\w*)[^\<\>]*)\>/
+ $message =~ s/(\\s*(\w+)[^\<\>]*)\>/
{($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge;
return $message;
}
sub assemble_email {
- my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
+ my ($message,$prevattempts,$usersaw,$useranswer)=@_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'prev' => 'Previous attempts of student (if applicable)',
+ 'orig' => 'Original screen output (if applicable)',
+ 'corr' => 'Correct Answer(s) (if applicable)',
+ );
+ if (&Apache::loncommon::course_type() eq 'Community') {
+ $lt{'prev'} = &mt('Previous attempts of member (if applicable)');
+ }
my $email=<<"ENDEMAIL";
$message
ENDEMAIL
my $citations=<<"ENDCITE";
-Previous attempts of student (if applicable)
+$lt{'prev'}
$prevattempts
-Original screen output (if applicable)
+$lt{'orig'}
$usersaw
-Correct Answer(s) (if applicable)
+$lt{'corr'}
$useranswer
ENDCITE
return ($email,$citations);
}
-sub secapply {
- my $rec=shift;
- my $defaultflag=shift;
- $rec=~s/\s+//g;
- $rec=~s/\@/\:/g;
- my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
- if ($sections) {
- foreach (split(/\;/,$sections)) {
- if (($_ eq $env{'request.course.sec'}) ||
- ($defaultflag && ($_ eq '*'))) {
- return $adr;
- }
- }
- } else {
- return $rec;
- }
- return '';
-}
-
-=pod
-
-=over 4
-
-=item *
-
-decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag);
-
-Arguments
- $feedurl - /res/ url of resource (only need if $author is true)
- $author,$question,$course,$policy - all true/false parameters
- if true will attempt to find the addresses of user that should receive
- this type of feedback (author - feedback to author of resource $feedurl,
- $question 'Resource Content Questions', $course 'Course Content Question',
- $policy 'Course Policy')
- (Additionally it also checks $env for whether the corresponding form.
- element exists, for ease of use in a html response context)
-
- $defaultflag - (internal should be left blank) if true gather addresses
- that aren't for a section even if I have a section
- (used for reccursion internally, first we look for
- addresses for our specific section then we recurse
- and look for non section addresses)
-
-Returns
- $typestyle - string of html text, describing what addresses were found
- %to - a hash, which keys are addresses of users to send messages to
- the keys will look like name:domain
-
-=cut
-
-sub decide_receiver {
- my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
- my $typestyle='';
- my %to=();
- if ($env{'form.author'}||$author) {
- $typestyle.='Submitting as Author Feedback ';
- $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
- $to{$2.':'.$1}=1;
- }
- if ($env{'form.question'}||$question) {
- $typestyle.='Submitting as Question ';
- foreach (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.question.email'})
- ) {
- my $rec=&secapply($_,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ($env{'form.course'}||$course) {
- $typestyle.='Submitting as Comment ';
- foreach (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.comment.email'})
- ) {
- my $rec=&secapply($_,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ($env{'form.policy'}||$policy) {
- $typestyle.='Submitting as Policy Feedback ';
- foreach (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.policy.email'})
- ) {
- my $rec=&secapply($_,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ((scalar(%to) eq '0') && (!$defaultflag)) {
- ($typestyle,%to)=
- &decide_receiver($feedurl,$author,$question,$course,$policy,1);
- }
- return ($typestyle,%to);
-}
sub feedback_available {
my ($question,$course,$policy)=@_;
- my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
+ my ($typestyle,%to)=&Apache::lonmsg::decide_receiver('',0,$question,
+ $course,$policy);
return scalar(%to);
}
sub send_msg {
- my ($title,$feedurl,$email,$citations,$attachmenturl,%to)=@_;
- my $status='';
- my $sendsomething=0;
- if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
- unless ($title=~/\w/) { $title=&mt('Feedback'); }
- foreach (keys %to) {
- if ($_) {
- my $declutter=&Apache::lonnet::declutter($feedurl);
- unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
- $title.' ['.$declutter.']',$email,$citations,$feedurl,
- $attachmenturl)=~/ok/) {
- $status.=' '.&mt('Error sending message to').' '.$_.' ';
- } else {
- $sendsomething++;
- }
+ my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,%to)=@_;
+ my $status='';
+ my $sendsomething=0;
+ my $restitle = &get_resource_title($symb,$feedurl);
+ if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
+ unless ($title=~/\w/) { $title=&mt('Feedback'); }
+ foreach my $key (keys(%to)) {
+ if ($key) {
+ my ($user,$domain) = split(/\:/,$key,2);
+ if (!defined($user)) {
+ $status.=' '.&mt('Error sending message to [_1], no user specified.',$key);
+ } elsif (!defined($domain)) {
+ $status.=' '.&mt('Error sending message to [_1], no domain specified.',$key);
+ } else {
+ unless (&Apache::lonmsg::user_normal_msg($user,$domain,
+ $title.' ['.$restitle.']',$email,$citations,$feedurl,
+ $attachmenturl,undef,undef,$symb,$restitle)=~/ok/) {
+ $status.=' '.&mt('Error sending message to').' '.$key.' ';
+ } else {
+ $sendsomething++;
+ }
+ }
+ }
}
- }
- my %record=&Apache::lonnet::restore('_feedback');
- my ($temp)=keys %record;
- unless ($temp=~/^error\:/) {
- my %newrecord=();
- $newrecord{'resource'}=$feedurl;
- $newrecord{'subnumber'}=$record{'subnumber'}+1;
- unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
- $status.=' '.&mt('Not registered').' ';
- }
+# Records of number of feedback messages are kept under the "symb" called "_feedback"
+# There are two entries within the framework of a course:
+# - the URLs for which feedback was provided
+# - the total number of contributions
+ if ($sendsomething) {
+ my %record=&getfeedbackrecords();
+ my ($temp)=keys(%record);
+ unless ($temp=~/^error\:/) {
+ my %newrecord=();
+ $newrecord{'resource'}=$feedurl;
+ $newrecord{'subnumber'}=$record{'subnumber'}+1;
+ unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
+ $status.=' '.&mt('Not registered').' ';
+ }
+ }
}
-
- return ($status,$sendsomething);
+ return ($status,$sendsomething);
}
+# Routine to get the complete feedback records
+
+sub getfeedbackrecords {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=&Apache::lonnet::restore('_feedback',$course,$udom,$uname);
+ return %record;
+}
+
+# Routine to get feedback statistics
+
+sub getfeedbackstats {
+ my %record=&getfeedbackrecords(@_);
+ return ($record{'subnumber'},$record{'points'},$record{'totallikes'});
+}
+
+# Store feedback credit
+
+sub storefeedbackpoints {
+ my ($points,$uname,$udom,$course)=@_;
+ unless ($points) { $points=0; }
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=('grader_user' => $env{'user.name'},
+ 'grader_domain' => $env{'user.domain'},
+ 'points' => $points);
+ return &Apache::lonnet::cstore(\%record,'_feedback',$course,$udom,$uname);
+}
+
+# Store feedback "likes"
+
+sub storefeedbacklikes {
+ my ($likes,$uname,$udom,$course)=@_;
+ unless ($likes) { $likes=0; }
+ if ($likes>0) { $likes=1; }
+ if ($likes<0) { $likes=-1; }
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=&getfeedbackrecords($uname,$udom,$course);
+ my $totallikes=$record{'totallikes'};
+ $totallikes+=$likes;
+ my %newrecord=('likes_user' => $env{'user.name'},
+ 'likes_domain' => $env{'user.domain'},
+ 'likes' => $likes,
+ 'totallikes' => $totallikes);
+ return &Apache::lonnet::cstore(\%newrecord,'_feedback',$course,$udom,$uname);
+}
+
+
sub adddiscuss {
- my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
+ my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
my $status='';
- my $realsymb;
- if ($symb=~/^bulletin___/) {
- my $filename=(&Apache::lonnet::decode_symb($symb))[2];
- $filename=~s|^adm/wrapper/||;
- $realsymb=&Apache::lonnet::symbread($filename);
+ my $realsymb = &get_realsymb($symb);
+ my ($cnum,$cdom);
+ if ($env{'request.course.id'}) {
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
}
if (&discussion_open(undef,$realsymb) &&
- &Apache::lonnet::allowed('pch',$env{'request.course.id'}.
- ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+ (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
+ (($group ne '') && (&check_group_priv($group,'pgd') eq 'ok') &&
+ ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})))) {
my %contrib=('message' => $email,
'sendername' => $env{'user.name'},
@@ -2536,10 +3168,11 @@ sub adddiscuss {
$contrib{'anonymous'}='true';
}
if (($symb) && ($email)) {
+ my $now = time;
if ($env{'form.editdisc'}) {
$contrib{'ip'}=$ENV{'REMOTE_ADDR'};
$contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};
- $contrib{'timestamp'} = time;
+ $contrib{'timestamp'} = $now;
$contrib{'history'} = '';
my $numoldver = 0;
my ($oldsymb,$oldidx)=split(/\:\:\:/,$env{'form.editdisc'});
@@ -2554,7 +3187,7 @@ sub adddiscuss {
}
if (defined($oldcontrib{$oldidx.':history'})) {
if ($oldcontrib{$oldidx.':history'} =~ /:/) {
- my @oldversions = split/:/,$oldcontrib{$oldidx.':history'};
+ my @oldversions = split(/:/,$oldcontrib{$oldidx.':history'});
$numoldver = @oldversions;
} else {
$numoldver = 1;
@@ -2590,20 +3223,21 @@ sub adddiscuss {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
}
- my %storenewentry=($symb => time);
+ my %storenewentry=($symb => $now);
$status.=' '.&mt('Updating discussion time').': '.
&Apache::lonnet::put('discussiontimes',\%storenewentry,
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
}
- my %record=&Apache::lonnet::restore('_discussion');
- my ($temp)=keys %record;
+ my %record=&getdiscussionrecords();
+ my ($temp)=keys(%record);
unless ($temp=~/^error\:/) {
my %newrecord=();
$newrecord{'resource'}=$symb;
$newrecord{'subnumber'}=$record{'subnumber'}+1;
$status.=' '.&mt('Registering').': '.
&Apache::lonnet::cstore(\%newrecord,'_discussion');
+ &updatekarma();
}
} else {
$status.='Failed.';
@@ -2611,30 +3245,209 @@ sub adddiscuss {
return $status.' ';
}
+
+# Routine to get the complete discussion records
+
+sub getdiscussionrecords {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=&Apache::lonnet::restore('_discussion',$course,$udom,$uname);
+ return %record;
+}
+
+# Routine to get discussion statistics
+
+sub getdiscussionstats {
+ my %record=&getdiscussionrecords(@_);
+ my $totalvotes = $record{'totallikes'} + $record{'totalunlikes'};
+ return ($record{'subnumber'},$record{'points'},$record{'totallikes'},$totalvotes);
+}
+
+# Calculate discussion karma
+
+sub calcdiscussionkarma {
+ my ($subs,$pts,$likes,$votes)=&getdiscussionstats(@_);
+ my $karma=0;
+ if ($votes>0) {
+ $karma=int(.1+5.*(1.-exp(-$subs/10.))*$likes/$votes);
+ if ($karma<0) { $karma=0; }
+ if ($karma>5) { $karma=5; }
+ }
+ return $karma;
+}
+
+# Update karma
+
+sub updatekarma {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my $karma=&calcdiscussionkarma($uname,$udom,$course);
+ &Apache::lonnet::cstore({ 'karma' => $karma },'_discussion',$course,$udom,$uname);
+ &Apache::lonnet::do_cache_new('karma',$uname.':'.$udom.':'.$course,$karma,3600);
+ return $karma;
+}
+
+# Retrieve karma
+
+sub userkarma {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my $hashkey=$uname.':'.$udom.':'.$course;
+ my ($karma,$cached)=&Apache::lonnet::is_cached_new('karma',$hashkey);
+ if ($cached) {
+ return $karma;
+ }
+ my %userdisc=&getdiscussionrecords($uname,$udom,$course);
+ $karma=$userdisc{'karma'};
+ &Apache::lonnet::do_cache_new('karma',$hashkey,$karma,3600);
+ return $karma;
+}
+
+# Store discussion credit
+
+sub storediscussionpoints {
+ my ($points,$uname,$udom,$course)=@_;
+ unless ($points) { $points=0; }
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=('grader_user' => $env{'user.name'},
+ 'grader_domain' => $env{'user.domain'},
+ 'points' => $points);
+ return &Apache::lonnet::cstore(\%record,'_discussion',$course,$udom,$uname);
+}
+
+# Store discussion "likes"
+
+sub storediscussionlikes {
+ my ($chglikes,$chgunlikes,$uname,$udom,$course,$context)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my %record=&getdiscussionrecords($uname,$udom,$course);
+ my $totallikes=$record{'totallikes'};
+ my $totalunlikes=$record{'totalunlikes'};
+ $totallikes += $chglikes;
+ $totalunlikes += $chgunlikes;
+ my %newrecord=('likes_user' => $env{'user.name'},
+ 'likes_domain' => $env{'user.domain'},
+ 'totallikes' => $totallikes,
+ 'totalunlikes' => $totalunlikes,
+ 'context' => $context);
+ my $status=&Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
+ if ($status eq 'ok') {
+ &updatekarma($uname,$udom,$course);
+ }
+ return $status;
+}
+
+sub get_discussion_info {
+ my ($idx,%contrib) = @_;
+ my $changelast = 0;
+ my $count = 0;
+ my $hiddenflag = 0;
+ my $deletedflag = 0;
+ my ($hidden,$deleted,%info,$newlastdisc);
+ my $version = $contrib{'version'};
+ if ($version) {
+ for (my $id=$version; $id>0; $id--) {
+ my $vkeys=$contrib{$id.':keys'};
+ my @keys=split(/:/,$vkeys);
+ if (grep(/^hidden$/,@keys)) {
+ if (!$hiddenflag) {
+ $hidden = $contrib{$id.':hidden'};
+ $hiddenflag = 1;
+ }
+ } elsif (grep(/^deleted$/,@keys)) {
+ if (!$deletedflag) {
+ $deleted = $contrib{$id.':deleted'};
+ $deletedflag = 1;
+ }
+ } else {
+ if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./)) {
+ $count++;
+ $info{$count}{'id'} = $id;
+ $info{$count}{'timestamp'}=$contrib{$id.':timestamp'};
+ }
+ }
+ }
+ if ($info{'1'}{'id'} == $idx) {
+ $changelast = 1;
+ if ($count > 1) {
+ $newlastdisc = $info{'2'}{'timestamp'};
+ } else {
+ $newlastdisc = 0;
+ }
+ }
+ }
+ return ($changelast,$newlastdisc);
+}
+
# ----------------------------------------------------------- Preview function
sub show_preview {
my ($r) = @_;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
+ my $start_page=
+ &Apache::loncommon::start_page('Preview',undef,
+ {'only_body' => 1,});
+
my $message=&clear_out_html($env{'form.comment'});
&newline_to_br(\$message);
$message=&Apache::lonspeller::markeduptext($message);
$message=&Apache::lontexconvert::msgtexconverted($message);
- my $subject=&clear_out_html($env{'form.subject'},undef,1);
+ my $subject=&clear_out_html($env{'form.subject'});
$subject=~s/\n/\ /g;
$subject=&Apache::lontexconvert::msgtexconverted($subject);
- my $start_page=
- &Apache::loncommon::start_page('Preview',undef,
- {'only_body' => 1,});
my $end_page = &Apache::loncommon::end_page();
- $r->print($start_page.''.
- 'Subject: '.$subject.' '.
- $message.'
'.$end_page);
+ $r->print($start_page
+ .''.&mt('Preview').' '
+ .&Apache::lonhtmlcommon::start_pick_box()
+ .&Apache::lonhtmlcommon::row_title(&mt('Subject'))
+ .$subject
+ .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(&mt('Message'))
+ .$message
+ .&Apache::lonhtmlcommon::row_closure(1)
+ .&Apache::lonhtmlcommon::end_pick_box()
+ .$end_page
+ );
+}
+
+sub contains_block_html {
+ my ($message)=@_;
+ return ($message =~ m{
+ <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div)
+ \s*
+ (\w+\=['"]\w+['"])*
+ \s*
+ (
+ \s*/>|
+ >.*\1\s*>
+ )}xs
+ );
}
+sub tidy_html {
+ my ($message)=@_;
+# my $tidy = HTML::Tidy::libXML->new();
+# my $xhtml = $tidy->clean($message, 'utf-8', 1);
+# $xhtml =~ m/(.*)<\/body>/is;
+# my $clean = $1;
+# # remove any empty block-level tags
+# $clean =~ s/<(table|p|div|tbody|blockquote|m|pre|algebra|center|ol|ul|span|h1|h2|h3|h4|h5|h6)\s*\/>//i;
+# $message=$clean;
+ return $message;
+}
sub newline_to_br {
my ($message)=@_;
@@ -2663,19 +3476,49 @@ sub generate_preview_button {
unless ($fieldname) { $fieldname='comment'; }
my $pre=&mt("Show Preview and Check Spelling");
return(<
ENDPREVIEW
}
sub modify_attachments {
- my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;
- my $orig_subject = &Apache::lonnet::unescape($env{'form.subject'});
- my $subject=&clear_out_html($orig_subject,undef,1);
+ my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls,
+ $attachmaxtext,$toolarge)=@_;
+
+ my %lt = &Apache::lonlocal::texthash(
+ 'subj' => 'Subject',
+ 'chth' => 'Check the checkboxes for any you wish to remove.',
+ 'thef' => 'The following attachments have been uploaded for inclusion with this posting.',
+ 'adda' => 'Add a new attachment to this post',
+ 'stch' => 'Save Changes',
+ 'clic' => 'Add/remove attachments',
+ );
+ my $js = <
+ function setAction () {
+ document.modattachments.action = document.modattachments.origpage.value;
+ document.modattachments.submit();
+ }
+
+
+END
+
+ # Breadcrumbs
+ my $brcrum = [{'href' => '',
+ 'text' => 'Discussion Post Attachments'}];
+ my %parms=('only_body' => 1);
+ if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; }
+
+ my $start_page =
+ &Apache::loncommon::start_page('Discussion Post Attachments',$js,\%parms);
+
+ my $orig_subject = &unescape($env{'form.subject'});
+ my $subject=&clear_out_html($orig_subject);
$subject=~s/\n/\ /g;
$subject=&Apache::lontexconvert::msgtexconverted($subject);
my $timestamp=$env{'form.timestamp'};
@@ -2688,55 +3531,54 @@ sub modify_attachments {
&extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);
}
&Apache::lonenc::check_encrypt(\$symb);
- my $js = <
- function setAction () {
- document.modattachments.action = document.modattachments.origpage.value;
- document.modattachments.submit();
- }
-
-END
- my $start_page =
- &Apache::loncommon::start_page('Discussion Post Attachments',$js);
my $end_page =
&Apache::loncommon::end_page();
$r->print(<
-
@@ -2746,14 +3588,14 @@ END
END
- foreach (@{$currnewattach}) {
- $r->print(' '."\n");
+ foreach my $item (@{$currnewattach}) {
+ $r->print(' '."\n");
}
- foreach (@{$currdelold}) {
- $r->print(' '."\n");
+ foreach my $item (@{$currdelold}) {
+ $r->print(' '."\n");
}
$r->print(<
+
$end_page
END
@@ -2773,14 +3615,14 @@ sub process_attachments {
my @currnew = ();
foreach my $newone (@{$currnewattach}) {
my $delflag = 0;
- foreach (@currdelnew) {
- if ($newone eq $_) {
+ foreach my $item (@currdelnew) {
+ if ($newone eq $item) {
$delflag = 1;
last;
}
}
unless ($delflag) {
- push @currnew, $newone;
+ push(@currnew, $newone);
}
}
@{$currnewattach} = @currnew;
@@ -2789,14 +3631,22 @@ sub process_attachments {
}
sub generate_attachments_button {
- my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,$numoldver,$mode) = @_;
+ my ($idx,$attachnum,$ressymb,$now,$currnewattach,$deloldattach,
+ $numoldver,$mode,$blockblog) = @_;
my $origpage = $ENV{'REQUEST_URI'};
my $att=$attachnum.' '.&mt("attachments");
+ my %lt = &Apache::lonlocal::texthash(
+ 'clic' => 'Add/remove attachments',
+ );
my $response = (<