version 1.290.2.7.2.3, 2012/03/09 15:09:39
|
version 1.290.2.7.2.4, 2012/04/30 03:51:40
|
Line 82 sub discussion_visible {
|
Line 82 sub discussion_visible {
|
return 1; |
return 1; |
} |
} |
|
|
|
sub discussion_vote_available { |
|
my ($status,$symb)=@_; |
|
my $canvote=&Apache::lonnet::EXT('resource.0.discussvote',$symb); |
|
if ((lc($canvote) eq 'yes') || |
|
((lc($canvote) eq 'notended') && (&discussion_open($status,$symb)))) { |
|
return 1; |
|
} |
|
} |
|
|
|
sub get_realsymb { |
|
my ($symb) = @_; |
|
my $realsymb = $symb; |
|
if ($symb=~/^bulletin___/) { |
|
my $filename=(&Apache::lonnet::decode_symb($symb))[2]; |
|
$filename=~s{^adm/wrapper/}{}; |
|
$realsymb=&Apache::lonnet::symbread($filename); |
|
} |
|
return $realsymb; |
|
} |
|
|
sub list_discussion { |
sub list_discussion { |
my ($mode,$status,$ressymb,$imsextras,$group)=@_; |
my ($mode,$status,$ressymb,$imsextras,$group)=@_; |
unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); } |
unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); } |
Line 257 sub list_discussion {
|
Line 277 sub list_discussion {
|
$visit ++; |
$visit ++; |
|
|
my $seeid; |
my $seeid; |
if (($group ne '') && ($mode eq 'board') && |
if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { |
($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { |
$seeid = 1; |
if (&check_group_priv($group,'dgp') eq 'ok') { |
|
$seeid = 1; |
|
} |
|
} else { |
|
$seeid=&Apache::lonnet::allowed('rin',$crs); |
|
} |
} |
|
my $seehidden = &can_see_hidden($mode,$ressymb,undef,$group,$cdom,$cnum,$crs); |
|
# Is voting on discussions available |
|
my $realsymb = &get_realsymb($ressymb); |
|
my $canvote = &discussion_vote_available($status,$realsymb); |
|
|
my @discussionitems=(); |
my @discussionitems=(); |
my %shown = (); |
my %shown = (); |
my @posteridentity=(); |
my @posteridentity=(); |
Line 291 sub list_discussion {
|
Line 311 sub list_discussion {
|
$discinfo{$visitkey} = $visit; |
$discinfo{$visitkey} = $visit; |
|
|
&Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'}); |
&Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'}); |
&build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); |
&build_posting_display(\%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,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group); |
|
|
my $discussion=''; |
my $discussion=''; |
my $manifestfile; |
my $manifestfile; |
Line 450 imscp_v1p1.xsd http://www.imsglobal.org/
|
Line 470 imscp_v1p1.xsd http://www.imsglobal.org/
|
"\n".'<table class="LC_discussion">'; |
"\n".'<table class="LC_discussion">'; |
$discussion .= &action_links_bar($colspan,$ressymb,$visible, |
$discussion .= &action_links_bar($colspan,$ressymb,$visible, |
$newpostsflag,$group, |
$newpostsflag,$group, |
$prevread,$markondisp); |
$prevread,$markondisp,$seehidden); |
my $escsymb=&escape($ressymb); |
my $escsymb=&escape($ressymb); |
my $numhidden = keys(%notshown); |
my $numhidden = keys(%notshown); |
if ($numhidden > 0) { |
if ($numhidden > 0) { |
Line 664 END
|
Line 684 END
|
END |
END |
$discussion .= &action_links_bar($colspan,$ressymb,$visible, |
$discussion .= &action_links_bar($colspan,$ressymb,$visible, |
$newpostsflag,$group, |
$newpostsflag,$group, |
$prevread,$markondisp); |
$prevread,$markondisp,$seehidden); |
$discussion .= " |
$discussion .= " |
</table> |
</table> |
<br /><br /></form>\n"; |
<br /><br /></form>\n"; |
Line 764 END
|
Line 784 END
|
$discussion.= &send_feedback_link($ressymb,$target); |
$discussion.= &send_feedback_link($ressymb,$target); |
if ($env{'request.role.adv'}) { |
if ($env{'request.role.adv'}) { |
my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb); |
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 (defined($close) && $close ne '' && $close < time) { |
$discussion .= ' '.&mt('(Closed for [_1] roles)', |
if ($canvote eq 'notended') { |
&Apache::lonnet::plaintext('st',$crstype)); |
$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)); |
|
} |
} |
} |
} |
} |
} else { |
} else { |
Line 777 END
|
Line 803 END
|
return $discussion; |
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 { |
sub discussion_link { |
my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title) = @_; |
my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title) = @_; |
my $link = '<a href="/adm/feedback?'.$cmd.'='.&escape($ressymb).':::'.$item; |
my $link = '<a href="/adm/feedback?'.$cmd.'='.&escape($ressymb).':::'.$item; |
Line 810 sub send_message_link {
|
Line 869 sub send_message_link {
|
} |
} |
|
|
sub action_links_bar { |
sub action_links_bar { |
my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp) = @_; |
my ($colspan,$ressymb,$visible,$newpostsflag,$group,$prevread,$markondisp, |
|
$seehidden) = @_; |
my $discussion = '<tr><td class="LC_disc_action_links_bar" colspan="'.$colspan.'">'. |
my $discussion = '<tr><td class="LC_disc_action_links_bar" colspan="'.$colspan.'">'. |
'<table width="100%" class="LC_disc_action_table"><tr>'. |
'<table width="100%" class="LC_disc_action_table"><tr>'. |
'<td class="LC_disc_action_left">'; |
'<td class="LC_disc_action_left">'; |
Line 840 sub action_links_bar {
|
Line 900 sub action_links_bar {
|
$discussion .= '&previous='.$prevread; |
$discussion .= '&previous='.$prevread; |
} |
} |
$discussion .= &group_args($group); |
$discussion .= &group_args($group); |
$discussion .= '">'.&mt('Export').'?</a> </td>'; |
$discussion .= '">'.&mt('Export').'</a>'; |
|
if ($seehidden) { |
|
$discussion .= ' '; |
|
$discussion .='<a href="/adm/feedback?undeleteall='.$escsymb; |
|
if ($newpostsflag) { |
|
$discussion .= '&previous='.$prevread; |
|
} |
|
$discussion .= &group_args($group); |
|
$discussion .= '">'.&mt('Undelete all deleted entries').'</a>'; |
|
} |
|
$discussion.='</td>'; |
if ($newpostsflag) { |
if ($newpostsflag) { |
if (!$markondisp) { |
if (!$markondisp) { |
$discussion .='<td class="LC_disc_action_right"><a href="/adm/preferences?action=changediscussions'; |
$discussion .='<td class="LC_disc_action_right"><a href="/adm/preferences?action=changediscussions'; |
Line 938 ENDDISCUSS
|
Line 1008 ENDDISCUSS
|
} |
} |
|
|
sub build_posting_display { |
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,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_; |
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 @original=(); |
my @index=(); |
my @index=(); |
my $skip_group_check = 0; |
my $skip_group_check = 0; |
Line 948 sub build_posting_display {
|
Line 1018 sub build_posting_display {
|
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
my (%likes,%userlikes,%userunlikes,@theselikes,$oneplus,$twoplus,$oneminus,$twominus); |
# And these are the likes/unlikes |
# And these are the likes/unlikes |
my %likes=&Apache::lonnet::dump('disclikes', |
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; |
|
if ($seeid || $canvote) { |
|
%likes=&Apache::lonnet::dump('disclikes', |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
'^'.$symb.':'); |
'^'.$symb.':'); |
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; |
|
# Array with likes to figure out averages, etc. |
# Array with likes to figure out averages, etc. |
my @theselikes=(); |
@theselikes=(); |
# Hashes containing likes and unlikes for this user. |
# Hashes containing likes and unlikes for this user. |
my %userlikes=(); |
%userlikes=(); |
my %userunlikes=(); |
%userunlikes=(); |
|
} |
# Is the user allowed to see the real name behind anonymous postings? |
# Is the user allowed to see the real name behind anonymous postings? |
my $see_anonymous = |
my $see_anonymous = |
&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
Line 990 sub build_posting_display {
|
Line 1063 sub build_posting_display {
|
&filter_regexp($rolefilter,$sectionpick,$statusfilter); |
&filter_regexp($rolefilter,$sectionpick,$statusfilter); |
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; |
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; |
} |
} |
|
if ($seeid || $canvote) { |
# We need to go through this twice, first to get the likes/dislikes, then to actually build the display |
# 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++) { |
for (my $id=1;$id<=$contrib{'version'};$id++) { |
my $idx=$id; |
my $idx=$id; |
next if ($contrib{$idx.':deleted'}); |
next if ($contrib{$idx.':deleted'}); |
next if ($contrib{$idx.':hidden'}); |
next if ($contrib{$idx.':hidden'}); |
unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) { |
unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) { |
if ($likes{$symb.':'.$idx.':likes'} ne '') { |
if ($likes{$symb.':'.$idx.':likes'} ne '') { |
push(@theselikes,$likes{$symb.':'.$idx.':likes'}); |
push(@theselikes,$likes{$symb.':'.$idx.':likes'}); |
if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') { |
if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') { |
if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) { |
if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) { |
$userlikes{$idx} = 1; |
$userlikes{$idx} = 1; |
|
} |
} |
} |
} |
if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') { |
if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') { |
if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) { |
if (exists($likes{$symb.':'.$idx.':unlikers'}{$thisuser})) { |
$userunlikes{$idx} = 1; |
$userunlikes{$idx} = 1; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
# Figure out average likes and standard deviation if there are enough |
# Figure out average likes and standard deviation if there are enough |
# discussions to warrant that |
# discussions to warrant that |
my $ave=0; |
my $ave=0; |
my $stddev=10000; |
my $stddev=10000; |
if ($#theselikes>1) { |
if ($#theselikes>1) { |
my $sum=0; |
my $sum=0; |
my $num=$#theselikes+1; |
my $num=$#theselikes+1; |
foreach my $thislike (@theselikes) { |
foreach my $thislike (@theselikes) { |
$sum+=$thislike; |
$sum+=$thislike; |
} |
} |
$ave=$sum/$num; |
$ave=$sum/$num; |
my $sumsq=0; |
my $sumsq=0; |
foreach my $thislike (@theselikes) { |
foreach my $thislike (@theselikes) { |
$sumsq+=($thislike-$ave)*($thislike-$ave); |
$sumsq+=($thislike-$ave)*($thislike-$ave); |
|
} |
|
$stddev=sqrt($sumsq/$num); |
} |
} |
$stddev=sqrt($sumsq/$num); |
|
} |
|
# Now we know the average likes $ave and the standard deviation $stddev |
# Now we know the average likes $ave and the standard deviation $stddev |
# Get the boundaries for markup |
# Get the boundaries for markup |
my $oneplus=$ave+$stddev; |
$oneplus=$ave+$stddev; |
my $twoplus=$ave+2.*$stddev; |
$twoplus=$ave+2.*$stddev; |
my $oneminus=$ave-$stddev; |
$oneminus=$ave-$stddev; |
my $twominus=$ave-2.*$stddev; |
$twominus=$ave-2.*$stddev; |
|
} |
# |
# |
# This is now the real loop. Go through all entries, pick up what we need |
# This is now the real loop. Go through all entries, pick up what we need |
# |
# |
Line 1069 sub build_posting_display {
|
Line 1144 sub build_posting_display {
|
} else { |
} else { |
$$replies[$$depth[$idx]]=1; |
$$replies[$$depth[$idx]]=1; |
} |
} |
unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) { |
unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) { |
$$visible++; |
$$visible++; |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'} =~ /:/) { |
if ($contrib{$idx.':history'} =~ /:/) { |
Line 1094 sub build_posting_display {
|
Line 1169 sub build_posting_display {
|
$$anonhash{$key}=&mt('Anonymous').' '.$anoncnt; |
$$anonhash{$key}=&mt('Anonymous').' '.$anoncnt; |
} |
} |
my ($message,$subject,$vgrlink,$ctlink); |
my ($message,$subject,$vgrlink,$ctlink); |
&get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver); |
&get_post_contents(\%contrib,$idx,$seeid,$seehidden,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver); |
|
|
|
|
# Set up for sorting by subject |
# Set up for sorting by subject |
Line 1184 sub build_posting_display {
|
Line 1259 sub build_posting_display {
|
$sender .= &group_args($group); |
$sender .= &group_args($group); |
$sender .= '" '.$target.'>'.&mt('Edit').'</a>'; |
$sender .= '" '.$target.'>'.&mt('Edit').'</a>'; |
|
|
unless ($seeid) { |
unless ($seehidden) { |
my $grpargs = &group_args($group); |
my $grpargs = &group_args($group); |
$sender.=" <a href=\"javascript:verifydelete('studentdelete','$escsymb','$idx','$$newpostsflag','$prevread','$grpargs')"; |
$sender.=" <a href=\"javascript:verifydelete('studentdelete','$escsymb','$idx','$$newpostsflag','$prevread','$grpargs')"; |
$sender .= '">'.&mt('Delete').'</a>'; |
$sender .= '">'.&mt('Delete').'</a>'; |
} |
} |
} |
} |
} |
} |
if ($seeid) { |
if ($seehidden) { |
if ($hiddens{$idx}) { |
if ($hiddens{$idx}) { |
unless ($studenthidden) { |
unless ($studenthidden) { |
$sender.=' <a href="/adm/feedback?unhide='. |
$sender.=' <a href="/adm/feedback?unhide='. |
Line 1312 sub build_posting_display {
|
Line 1387 sub build_posting_display {
|
} else { |
} else { |
if ($message) { |
if ($message) { |
my $spansize = 2; |
my $spansize = 2; |
|
my ($uname,$udom); |
if ($showonlyunread && $prevread > $posttime) { |
if ($showonlyunread && $prevread > $posttime) { |
$$notshown{$idx} = 1; |
$$notshown{$idx} = 1; |
} elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) { |
} elsif ($showunmark && $$dischash{$readkey}=~/\.$idx\./) { |
$$notshown{$idx} = 1; |
$$notshown{$idx} = 1; |
} else { |
} else { |
# apply filters |
# apply filters |
my $uname = $contrib{$idx.':sendername'}; |
$uname = $contrib{$idx.':sendername'}; |
my $udom = $contrib{$idx.':senderdomain'}; |
$udom = $contrib{$idx.':senderdomain'}; |
my $poster = $uname.':'.$udom; |
my $poster = $uname.':'.$udom; |
if ($env{'form.totposters'} ne '') { |
if ($env{'form.totposters'} ne '') { |
if ($totposters == 0) { |
if ($totposters == 0) { |
Line 1387 sub build_posting_display {
|
Line 1463 sub build_posting_display {
|
$$discussionitems[$idx].='<td align="right"> '. |
$$discussionitems[$idx].='<td align="right"> '. |
$ctlink.'</td>'; |
$ctlink.'</td>'; |
} |
} |
|
if ($seeid || $canvote) { |
# Figure out size based on likes |
# Figure out size based on likes |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
my $likesize="100"; |
my $likesize="100"; |
if ($thislikes>$twoplus) { |
if ($thislikes>$twoplus) { |
$likesize="200"; |
$likesize="200"; |
} elsif ($thislikes>$oneplus) { |
} elsif ($thislikes>$oneplus) { |
$likesize="150"; |
$likesize="150"; |
} |
} |
if ($thislikes<$twominus) { |
if ($thislikes<$twominus) { |
$likesize="50"; |
$likesize="50"; |
} elsif ($thislikes<$oneminus) { |
} elsif ($thislikes<$oneminus) { |
$likesize="75"; |
$likesize="75"; |
|
} |
} |
} |
# Actually glue in the message itself |
# Actually glue in the message itself |
$$discussionitems[$idx].= '</tr></table><blockquote>'. |
$$discussionitems[$idx].= '</tr></table><blockquote>'. |
"<div style='font-size:$likesize%'>". |
"<div style='font-size:$likesize%'>". |
$message. |
$message. |
'</div></blockquote>'; |
'</div></blockquote>'; |
|
if ($canvote) { |
|
my $ownpost; |
|
if (($uname eq $env{'user.name'}) && |
|
($udom eq $env{'user.domain'})) { |
|
$ownpost = 1; |
|
} |
# Put in the like and unlike buttons |
# Put in the like and unlike buttons |
if ($userlikes{$idx}) { |
if ($ownpost || (($hiddens{$idx}) && ($seehidden))) { |
$$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />'; |
my $novote; |
} else { |
if ($ownpost) { |
$$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); |
$novote = &mt('No voting for your own posts.'); |
} |
} else { |
if ($userunlikes{$idx}) { |
$novote = &mt('No voting for hidden posts.'); |
$$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsdown_gray.png" alt="'.&mt('You unlike this posting').'" />'; |
} |
} else { |
$$discussionitems[$idx].= |
$$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); |
'<a href="javascript:alert('."'$novote'".');" style="text-decoration: none;">'. |
|
'<img border="0" src="/res/adm/pages/thumbsup_novote.png" alt="'.$novote.'" /> '. |
|
'<img border="0" src="/res/adm/pages/thumbsdown_novote.png" alt="'.$novote.'" /></a>'; |
|
} else { |
|
if ($userlikes{$idx}) { |
|
$$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsup_gray.png" alt="'.&mt('You like this posting').'" />'; |
|
} else { |
|
$$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); |
|
} |
|
if ($userunlikes{$idx}) { |
|
$$discussionitems[$idx].='<img border="0" src="/res/adm/pages/thumbsdown_gray.png" alt="'.&mt('You unlike this posting').'" />'; |
|
} else { |
|
$$discussionitems[$idx].=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); |
|
} |
|
} |
} |
} |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
if ($seeid || $canvote) { |
if ($thislikes>0) { |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
$$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')'; |
if ($thislikes>0) { |
} elsif ($thislikes<0) { |
$$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')'; |
$$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')'; |
} elsif ($thislikes<0) { |
|
$$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')'; |
|
} |
} |
} |
|
# If there is any history to this post, inform the reader |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'}) { |
my @postversions = (); |
my @postversions = (); |
$$discussionitems[$idx] .= &mt('This post has been edited by the author.'); |
$$discussionitems[$idx] .= &mt('This post has been edited by the author.'); |
if ($seeid) { |
if ($seehidden) { |
$$discussionitems[$idx] .= ' <a href="/adm/feedback?allversions='.$escsymb.':::'.$idx; |
$$discussionitems[$idx] .= ' <a href="/adm/feedback?allversions='.$escsymb.':::'.$idx; |
$$discussionitems[$idx] .= &group_args($group); |
$$discussionitems[$idx] .= &group_args($group); |
$$discussionitems[$idx] .= '">'.&mt('Display all versions').'</a>'; |
$$discussionitems[$idx] .= '">'.&mt('Display all versions').'</a>'; |
Line 1505 sub filter_regexp {
|
Line 1606 sub filter_regexp {
|
|
|
|
|
sub get_post_contents { |
sub get_post_contents { |
my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_; |
my ($contrib,$idx,$seeid,$seehidden,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$showaboutme,$numver) = @_; |
my $discussion = ''; |
my $discussion = ''; |
my $start=$numver; |
my $start=$numver; |
my $end=$numver + 1; |
my $end=$numver + 1; |
%{$$imsfiles{$idx}}=(); |
%{$$imsfiles{$idx}}=(); |
if ($type eq 'allversions') { |
if ($type eq 'allversions') { |
unless($seeid) { |
unless($seehidden) { |
$discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); |
$discussion=&mt('You do not have privileges to view all versions of posts.').' '.&mt('Please select a different role.'); |
return $discussion; |
return $discussion; |
} |
} |
Line 1721 END
|
Line 1822 END
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { |
unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { |
|
my $numoldver = 0; |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'}) { |
if ($contrib{$idx.':history'} =~ /:/) { |
if ($contrib{$idx.':history'} =~ /:/) { |
my @oldversions = split(/:/,$contrib{$idx.':history'}); |
my @oldversions = split(/:/,$contrib{$idx.':history'}); |
Line 1729 END
|
Line 1831 END
|
$numoldver = 1; |
$numoldver = 1; |
} |
} |
} |
} |
if ($env{'form.replydisc'}) { |
if ($idx > 0) { |
if ($contrib{$idx.':history'}) { |
my (%msgversions,%subversions,$htmldecode); |
if ($contrib{$idx.':history'} =~ /:/) { |
$htmldecode = 0; |
my @oldversions = split(/:/,$contrib{$idx.':history'}); |
if ($env{'form.replydisc'}) { |
$numoldver = @oldversions; |
$htmldecode = 1; |
} else { |
|
$numoldver = 1; |
|
} |
|
} |
} |
if ($idx > 0) { |
&get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); |
my %msgversions = (); |
&get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode, |
&get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); |
$numoldver); |
|
$subject = $subversions{$numoldver}; |
|
if ($env{'form.replydisc'}) { |
$quote = $msgversions{$numoldver}; |
$quote = $msgversions{$numoldver}; |
} |
$subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"'); |
if ($idx > 0) { |
} else { |
my %subversions = (); |
|
&get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver); |
|
$subject = &mt('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); |
|
$comment = $msgversions{$numoldver}; |
$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'})) { |
if (defined($contrib{$idx.':replyto'})) { |
$parentmsg = $contrib{$idx.':replyto'}; |
$parentmsg = $contrib{$idx.':replyto'}; |
} |
} |
Line 2407 sub print_showposters {
|
Line 2498 sub print_showposters {
|
$r->send_http_header; |
$r->send_http_header; |
|
|
&Apache::lonenc::check_encrypt(\$symb); |
&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; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $group = $env{'form.group'}; |
my $group = $env{'form.group'}; |
my $ressymb = &wrap_symb($symb); |
my $ressymb = &wrap_symb($symb); |
if (($group ne '') && |
my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum); |
($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|)) { |
|
if (&check_group_priv($group,'dgp') eq 'ok') { |
|
$seeid = 1; |
|
} |
|
} else { |
|
$seeid=&Apache::lonnet::allowed('rin',$crs); |
|
} |
|
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$cdom,$cnum); |
$cdom,$cnum); |
my %namesort = (); |
my %namesort = (); |
Line 2440 sub print_showposters {
|
Line 2518 sub print_showposters {
|
for (my $idx=1;$idx<=$contrib{'version'};$idx++) { |
for (my $idx=1;$idx<=$contrib{'version'};$idx++) { |
my $hidden=($contrib{'hidden'}=~/\.$idx\./); |
my $hidden=($contrib{'hidden'}=~/\.$idx\./); |
my $deleted=($contrib{'deleted'}=~/\.$idx\./); |
my $deleted=($contrib{'deleted'}=~/\.$idx\./); |
unless ((($hidden) && (!$seeid)) || ($deleted)) { |
unless ((($hidden) && (!$seehidden)) || ($deleted)) { |
if ((!$contrib{$idx.':anonymous'}) || (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) { |
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 %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'}); |
my $lastname = $names{'lastname'}; |
my $lastname = $names{'lastname'}; |
Line 2739 sub no_redirect_back {
|
Line 2817 sub no_redirect_back {
|
'add_entries' => \%onload,); |
'add_entries' => \%onload,); |
|
|
if ($feedurl !~ m{^/adm/feedback}) { |
if ($feedurl !~ m{^/adm/feedback}) { |
$body_options{'rediect'} = [2,$feedurl]; |
$body_options{'redirect'} = [2,$feedurl]; |
} |
} |
my $start_page= |
my $start_page= |
&Apache::loncommon::start_page('Feedback not sent',undef, |
&Apache::loncommon::start_page('Feedback not sent',undef, |
Line 2810 sub screen_header {
|
Line 2888 sub screen_header {
|
my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); |
my ($blocked,$blocktext) = &Apache::loncommon::blocking_status('boards'); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $realsymb = $symb; |
my $realsymb = &get_realsymb($symb); |
if ($symb=~/^bulletin___/) { |
|
my $filename=(&Apache::lonnet::decode_symb($symb))[2]; |
|
$filename=~s|^adm/wrapper/||; |
|
$realsymb=&Apache::lonnet::symbread($filename); |
|
} |
|
if (!$blocked && &discussion_open(undef,$realsymb) && |
if (!$blocked && &discussion_open(undef,$realsymb) && |
(&Apache::lonnet::allowed('pch', |
(&Apache::lonnet::allowed('pch', |
$env{'request.course.id'}. |
$env{'request.course.id'}. |
Line 2981 sub storefeedbacklikes {
|
Line 3054 sub storefeedbacklikes {
|
sub adddiscuss { |
sub adddiscuss { |
my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_; |
my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_; |
my $status=''; |
my $status=''; |
my $realsymb; |
my $realsymb = &get_realsymb($symb); |
if ($symb=~/^bulletin___/) { |
|
my $filename=(&Apache::lonnet::decode_symb($symb))[2]; |
|
$filename=~s|^adm/wrapper/||; |
|
$realsymb=&Apache::lonnet::symbread($filename); |
|
} |
|
my ($cnum,$cdom); |
my ($cnum,$cdom); |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
} |
} |
|
my $realsymb; |
if (&discussion_open(undef,$realsymb) && |
if (&discussion_open(undef,$realsymb) && |
(&Apache::lonnet::allowed('pch',$env{'request.course.id'}. |
(&Apache::lonnet::allowed('pch',$env{'request.course.id'}. |
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || |
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) || |
Line 3084 sub adddiscuss {
|
Line 3153 sub adddiscuss {
|
$newrecord{'subnumber'}=$record{'subnumber'}+1; |
$newrecord{'subnumber'}=$record{'subnumber'}+1; |
$status.='<br />'.&mt('Registering').': '. |
$status.='<br />'.&mt('Registering').': '. |
&Apache::lonnet::cstore(\%newrecord,'_discussion'); |
&Apache::lonnet::cstore(\%newrecord,'_discussion'); |
|
&updatekarma(); |
} |
} |
} else { |
} else { |
$status.='Failed.'; |
$status.='Failed.'; |
Line 3102 sub getdiscussionrecords {
|
Line 3172 sub getdiscussionrecords {
|
return %record; |
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" |
# Store discussion "likes" |
|
|
sub storediscussionlikes { |
sub storediscussionlikes { |
my ($likes,$uname,$udom,$course)=@_; |
my ($chglikes,$chgunlikes,$uname,$udom,$course,$context)=@_; |
unless ($likes) { $likes=0; } |
|
if ($likes>0) { $likes=1; } |
|
if ($likes<0) { $likes=-1; } |
|
unless ($uname) { $uname=$env{'user.name'}; } |
unless ($uname) { $uname=$env{'user.name'}; } |
unless ($udom) { $udom=$env{'user.domain'}; } |
unless ($udom) { $udom=$env{'user.domain'}; } |
unless ($course) { $course=$env{'request.course.id'}; } |
unless ($course) { $course=$env{'request.course.id'}; } |
my %record=&getdiscussionrecords($uname,$udom,$course); |
my %record=&getdiscussionrecords($uname,$udom,$course); |
my $totallikes=$record{'totallikes'}; |
my $totallikes=$record{'totallikes'}; |
my $totalvotes=$record{'totalvotes'}; |
my $totalunlikes=$record{'totalunlikes'}; |
$totallikes+=$likes; |
$totallikes += $chglikes; |
$totalvotes++; |
$totalunlikes += $chgunlikes; |
my %newrecord=('likes_user' => $env{'user.name'}, |
my %newrecord=('likes_user' => $env{'user.name'}, |
'likes_domain' => $env{'user.domain'}, |
'likes_domain' => $env{'user.domain'}, |
'likes' => $likes, |
'totallikes' => $totallikes, |
'totallikes' => $totallikes, |
'totalunlikes' => $totalunlikes, |
'totalvotes' => $totalvotes); |
'context' => $context); |
my $status=&Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname); |
my $status=&Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname); |
|
if ($status eq 'ok') { |
|
&updatekarma($uname,$udom,$course); |
|
} |
return $status; |
return $status; |
} |
} |
|
|
Line 3652 sub handler {
|
Line 3788 sub handler {
|
# --------------------------- Get query string for limited number of parameters |
# --------------------------- Get query string for limited number of parameters |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['like','unlike','hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); |
['like','unlike','hide','unhide','deldisc','undeleteall','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']); |
my $group = $env{'form.group'}; |
my $group = $env{'form.group'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my %attachmax = ( |
my %attachmax = ( |
text => &mt('(128 KB max size)'), |
text => &mt('(128 KB max size)'), |
num => 131072, |
num => 131072, |
); |
); |
if ($env{'form.editdisc'}) { |
if ($env{'form.editdisc'}) { |
if (!(&editing_allowed($env{'form.editdisc'},$env{'form.group'}))) { |
if (!(&editing_allowed($env{'form.editdisc'},$group))) { |
my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); |
my $feedurl=&Apache::lonnet::clutter($url); |
my $feedurl=&Apache::lonnet::clutter($url); |
Line 3708 sub handler {
|
Line 3846 sub handler {
|
{'bread_crumbs' => $brcrum,}) |
{'bread_crumbs' => $brcrum,}) |
); |
); |
|
|
my $crs='/'.$env{'request.course.id'}; |
|
if ($env{'request.course.sec'}) { |
|
$crs.='_'.$env{'request.course.sec'}; |
|
} |
|
$crs=~s|_|/|g; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my ($symb,$idx)=split(/\:\:\:/,$env{'form.allversions'}); |
my ($symb,$idx)=split(/\:\:\:/,$env{'form.allversions'}); |
($symb)=&get_feedurl_and_clean_symb($symb); |
($symb, my $feedurl)=&get_feedurl_and_clean_symb($symb); |
my $ressymb = &wrap_symb($symb); |
my $ressymb = &wrap_symb($symb); |
my $group = $env{'form.group'}; |
|
my $seeid; |
my $seeid; |
if (($group ne '') && (($ressymb =~ m|^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$|))) { |
if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) { |
if (&check_group_priv($group,'dgp') eq 'ok') { |
$seeid = 1; |
$seeid = 1; |
|
} |
|
} else { |
|
$seeid = &Apache::lonnet::allowed('rin',$crs); |
|
} |
} |
|
my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum); |
if ($idx > 0) { |
if ($idx > 0) { |
my %messages = (); |
my %messages = (); |
my %subjects = (); |
my %subjects = (); |
Line 3735 sub handler {
|
Line 3862 sub handler {
|
my %imsfiles = (); |
my %imsfiles = (); |
my ($screenname,$plainname,$showaboutme); |
my ($screenname,$plainname,$showaboutme); |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$r->print(&get_post_contents(\%contrib,$idx,$seeid,$seehidden,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname,\$showaboutme)); |
$r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname,\$showaboutme)); |
|
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
Line 3879 ENDREDIR
|
Line 4005 ENDREDIR
|
my $entry=$env{'form.hide'}?$env{'form.hide'}:$env{'form.unhide'}; |
my $entry=$env{'form.hide'}?$env{'form.hide'}:$env{'form.unhide'}; |
my ($symb,$idx)=split(/\:\:\:/,$entry); |
my ($symb,$idx)=split(/\:\:\:/,$entry); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
|
my $ressymb = &wrap_symb($symb); |
|
|
my $crs='/'.$env{'request.course.id'}; |
my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum); |
if ($env{'request.course.sec'}) { |
unless (($seehidden) || (&editing_allowed($env{'form.hide'},$group))) { |
$crs.='_'.$env{'request.course.sec'}; |
&redirect_back($r,$feedurl,&mt('Hiding not permitted').'<br />', |
} |
'0','0','','',$env{'form.previous'},'','','','', |
$crs=~s/\_/\//g; |
undef,undef,$group,); |
my $seeid=&Apache::lonnet::allowed('rin',$crs); |
|
|
|
if ($env{'form.hide'} && !$seeid && !(&editing_allowed($env{'form.hide'},$env{'form.group'}))) { |
|
&redirect_back($r,$feedurl,&mt('Deletion not permitted').'<br />', '0','0','','',$env{'form.previous'},'','','','', |
|
undef,undef,$group,); |
|
return OK; |
return OK; |
} |
} |
|
|
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
|
|
my $currenthidden=$contrib{'hidden'}; |
my $currenthidden=$contrib{'hidden'}; |
my $currentstudenthidden=$contrib{'studenthidden'}; |
my $currentstudenthidden=$contrib{'studenthidden'}; |
|
|
if ($env{'form.hide'}) { |
if ($env{'form.hide'}) { |
$currenthidden.='.'.$idx.'.'; |
$currenthidden.='.'.$idx.'.'; |
unless ($seeid) { |
unless ($seehidden) { |
$currentstudenthidden.='.'.$idx.'.'; |
$currentstudenthidden.='.'.$idx.'.'; |
} |
} |
} else { |
} else { |
$currenthidden=~s/\.$idx\.//g; |
$currenthidden=~s/\.$idx\.//g; |
} |
} |
my %newhash=('hidden' => $currenthidden); |
my %newhash=('hidden' => $currenthidden); |
if ( ($env{'form.hide'}) && (!$seeid) ) { |
if ( ($env{'form.hide'}) && (!$seehidden) ) { |
$newhash{'studenthidden'} = $currentstudenthidden; |
$newhash{'studenthidden'} = $currentstudenthidden; |
} |
} |
if ($env{'form.hide'}) { |
if ($env{'form.hide'}) { |
Line 3918 ENDREDIR
|
Line 4039 ENDREDIR
|
($changelast,$newlast) = &get_discussion_info($idx,%contrib); |
($changelast,$newlast) = &get_discussion_info($idx,%contrib); |
if ($changelast) { |
if ($changelast) { |
&Apache::lonnet::put('discussiontimes',{$symb => $newlast}, |
&Apache::lonnet::put('discussiontimes',{$symb => $newlast}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
} |
} |
} |
} |
&Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'}, |
my $result; |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
if (&Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$cdom,$cnum) eq 'ok') { |
|
my $prefix=$symb.':'.$idx.':'; |
|
my %likes=&Apache::lonnet::dump('disclikes',$cdom,$cnum, |
|
'^'.$prefix); |
|
my ($totallikes,$totalunlikes); |
|
if (ref($likes{$prefix.'likers'}) eq 'HASH') { |
|
$totallikes = scalar(keys(%{$likes{$prefix.'likers'}})); |
|
} |
|
if (ref($likes{$prefix.'unlikers'}) eq 'HASH') { |
|
$totalunlikes = scalar(keys(%{$likes{$prefix.'unlikers'}})); |
|
} |
|
if ($totallikes || $totalunlikes) { |
|
my ($chglikes,$chgunlikes,$context); |
|
if ($env{'form.hide'}) { |
|
$chglikes = -1 * $totallikes; |
|
$chgunlikes = -1 * $totalunlikes; |
|
$context = 'hide'; |
|
} else { |
|
$chglikes = $totallikes; |
|
$chgunlikes = $totalunlikes; |
|
$context = 'unhide'; |
|
} |
|
&storediscussionlikes($chglikes,$chgunlikes, |
|
$contrib{$idx.':sendername'}, |
|
$contrib{$idx.':senderdomain'}, |
|
$env{'request.course.id'}, |
|
$context); |
|
|
&redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />', |
} |
'0','0','','',$env{'form.previous'},undef,undef,undef, |
$result = &mt('Changed discussion status'); |
|
} else { |
|
$result = &mt('Discussion status unchanged'); |
|
} |
|
&redirect_back($r,$feedurl,$result.'<br />','0','0','','', |
|
$env{'form.previous'},undef,undef,undef, |
undef,undef,undef,$group); |
undef,undef,undef,$group); |
return OK; |
return OK; |
} elsif (($env{'form.like'}) || ($env{'form.unlike'})) { |
} elsif (($env{'form.like'}) || ($env{'form.unlike'})) { |
Line 3935 ENDREDIR
|
Line 4086 ENDREDIR
|
my $entry=$env{'form.like'}?$env{'form.like'}:$env{'form.unlike'}; |
my $entry=$env{'form.like'}?$env{'form.like'}:$env{'form.unlike'}; |
my ($symb,$idx)=split(/\:\:\:/,$entry); |
my ($symb,$idx)=split(/\:\:\:/,$entry); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
|
my $result; |
|
if ($idx > 0) { |
|
my $realsymb = &get_realsymb($symb); |
|
my $status='OPEN'; |
|
if ($Apache::lonhomework::parsing_a_problem || |
|
$Apache::lonhomework::parsing_a_task) { |
|
$status=$Apache::inputtags::status[-1]; |
|
} |
|
if (&discussion_vote_available($status,$realsymb)) { |
|
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
|
$cdom,$cnum); |
|
my $ownpost; |
|
if (($contrib{$idx.':sendername'} eq $env{'user.name'}) && |
|
($contrib{$idx.':senderdomain'} eq $env{'user.domain'})) { |
|
$ownpost = 1; |
|
} |
|
if ($ownpost || $contrib{$idx.':hidden'} || $contrib{$idx.':deleted'}) { |
|
$result = &mt('Vote not registered.').' '; |
|
} |
|
if ($ownpost) { |
|
$result .= &mt('No voting for your own posts.'); |
|
} elsif ($contrib{$idx.':hidden'}) { |
|
$result .= &mt('No voting for hidden posts.'); |
|
} elsif ($contrib{$idx.':deleted'}) { |
|
$result .= &mt('No voting for deleted posts.'); |
|
} else { |
# |
# |
# Likes and unlikes are in db-file "disclikes" of the course |
# Likes and unlikes are in db-file "disclikes" of the course |
# The prefix is the $symb to identify the resource discussion, |
# The prefix is the $symb to identify the resource discussion, |
# and the $idx to identify the entry |
# and the $idx to identify the entry |
# |
# |
my $prefix=$symb.':'.$idx.':'; |
my $prefix=$symb.':'.$idx.':'; |
my %contrib=&Apache::lonnet::dump('disclikes', |
my %likes=&Apache::lonnet::dump('disclikes',$cdom,$cnum, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
'^'.$prefix); |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
'^'.$prefix); |
|
# Get current like or unlike status for the $idx for this user. |
|
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; |
|
my ($userlikes,$userunlikes); |
|
if (ref($contrib{$prefix.'likers'}) eq 'HASH') { |
|
if (exists($contrib{$prefix.'likers'}{$thisuser})) { |
|
$userlikes = 1; |
|
} |
|
} |
|
if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') { |
|
if (exists($contrib{$prefix.'unlikers'}{$thisuser})) { |
|
$userunlikes = 1; |
|
} |
|
} |
|
|
|
|
# Get current like or unlike status for the $idx for this user. |
|
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; |
|
my ($userlikes,$userunlikes); |
|
if (ref($likes{$prefix.'likers'}) eq 'HASH') { |
|
if (exists($likes{$prefix.'likers'}{$thisuser})) { |
|
$userlikes = 1; |
|
} |
|
} |
|
if (ref($likes{$prefix.'unlikers'}) eq 'HASH') { |
|
if (exists($likes{$prefix.'unlikers'}{$thisuser})) { |
|
$userunlikes = 1; |
|
} |
|
} |
# Get the current "likes" count |
# Get the current "likes" count |
my $likes=$contrib{$prefix.'likes'}; |
my $likescount=$likes{$prefix.'likes'}; |
# Find out if they already voted |
# Find out if they already voted |
# Users cannot like a post twice, or unlike it twice. |
# Users cannot like a post twice, or unlike it twice. |
# They can change their mind, though. |
# They can change their mind, though. |
my $alreadyflag=0; |
my $alreadyflag=0; |
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'}; |
my $votetype; |
if ($env{'form.like'}) { |
if ($env{'form.like'}) { |
if ($userlikes) { |
if ($userlikes) { |
$alreadyflag=1; |
$alreadyflag=1; |
} elsif ($userunlikes) { |
} elsif ($userunlikes) { |
delete($contrib{$prefix.'unlikers'}{$thisuser}); |
delete($likes{$prefix.'unlikers'}{$thisuser}); |
$likes++; |
$votetype = 'switch'; |
} else { |
$likescount++; |
if (ref($contrib{$prefix.'likers'}) eq 'HASH') { |
} else { |
$contrib{$prefix.'likers'}{$thisuser} = 1; |
if (ref($likes{$prefix.'likers'}) eq 'HASH') { |
} else { |
$likes{$prefix.'likers'}{$thisuser} = 1; |
$contrib{$prefix.'likers'} = {$thisuser => 1}; |
} else { |
} |
$likes{$prefix.'likers'} = {$thisuser => 1}; |
$likes++; |
} |
} |
$likescount++; |
} else { |
} |
if ($userunlikes) { |
} else { |
$alreadyflag=1; |
if ($userunlikes) { |
} elsif ($userlikes) { |
$alreadyflag=1; |
delete($contrib{$prefix.'likers'}{$thisuser}); |
} elsif ($userlikes) { |
$likes--; |
delete($likes{$prefix.'likers'}{$thisuser}); |
} else { |
$votetype = 'switch'; |
if (ref($contrib{$prefix.'unlikers'}) eq 'HASH') { |
$likescount--; |
$contrib{$prefix.'unlikers'}{$thisuser} = 1; |
} else { |
} else { |
if (ref($likes{$prefix.'unlikers'}) eq 'HASH') { |
$contrib{$prefix.'unlikers'} = {$thisuser => 1}; |
$likes{$prefix.'unlikers'}{$thisuser} = 1; |
} |
} else { |
$likes--; |
$likes{$prefix.'unlikers'} = {$thisuser => 1}; |
} |
} |
} |
$likescount--; |
my $result; |
} |
|
} |
# $alreadyflag would be 1 if they tried to double-like or double-unlike |
# $alreadyflag would be 1 if they tried to double-like or double-unlike |
unless ($alreadyflag) { |
if ($alreadyflag) { |
my %newhash=($prefix.'likes' => $likes, |
if ($env{'form.like'}) { |
$prefix.'likers' => $contrib{$prefix.'likers'}, |
$result= &mt("'Like' already registered"); |
$prefix.'unlikers' => $contrib{$prefix.'unlikers'}); |
} else { |
|
$result= &mt("'Unlike' already registered"); |
|
} |
|
} else { |
|
my %newhash=($prefix.'likes' => $likescount, |
|
$prefix.'likers' => $likes{$prefix.'likers'}, |
|
$prefix.'unlikers' => $likes{$prefix.'unlikers'}); |
# Store data in db-file "disclikes" |
# Store data in db-file "disclikes" |
if (&Apache::lonnet::put('disclikes', |
if (&Apache::lonnet::put('disclikes',\%newhash,$cdom,$cnum) eq 'ok') { |
\%newhash, |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
|
# Also store with the person who posted the liked/unliked entry |
# Also store with the person who posted the liked/unliked entry |
if ($env{'form.like'}) { |
my ($chglike,$chgunlike); |
&storediscussionlikes(1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'}); |
if ($env{'form.like'}) { |
$result=&mt("Registered 'Like'"); |
if ($votetype eq 'switch') { |
} else { |
$chglike = 0; |
&storediscussionlikes(-1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'}); |
$chgunlike = -1; |
$result=&mt("Registered 'Unlike'"); |
} else { |
|
$chglike = 1; |
|
$chgunlike = 0; |
|
} |
|
&storediscussionlikes($chglike,$chgunlike, |
|
$contrib{$idx.':sendername'}, |
|
$contrib{$idx.':senderdomain'}, |
|
$env{'request.course.id'},'like'); |
|
$result=&mt("Registered 'Like'"); |
|
} else { |
|
if ($votetype eq 'switch') { |
|
$chglike = -1; |
|
$chgunlike = 0; |
|
} else { |
|
$chglike = 0; |
|
$chgunlike = 1; |
|
} |
|
&storediscussionlikes($chglike,$chgunlike, |
|
$contrib{$idx.':sendername'}, |
|
$contrib{$idx.':senderdomain'}, |
|
$env{'request.course.id'},'unlike'); |
|
$result=&mt("Registered 'Unlike'"); |
|
} |
|
} else { |
|
# Oops, something went wrong |
|
$result=&mt("Failed to register vote"); |
|
} |
|
} |
} |
} |
} else { |
} else { |
# Oops, something went wrong |
$result=&mt('Voting unavailable for this discussion'); |
$result=&mt("Failed to register vote"); |
|
} |
} |
|
} else { |
|
$result=&mt('Invalid post number'); |
} |
} |
&redirect_back($r,$feedurl,$result.'<br />', |
&redirect_back($r,$feedurl,$result.'<br />', |
'0','0','','',$env{'form.previous'},undef,undef,undef, |
'0','0','','',$env{'form.previous'},undef,undef,undef, |
Line 4041 ENDREDIR
|
Line 4247 ENDREDIR
|
# --------------------------------------------------------------- Hide for good |
# --------------------------------------------------------------- Hide for good |
my ($symb,$idx)=split(/\:\:\:/,$env{'form.deldisc'}); |
my ($symb,$idx)=split(/\:\:\:/,$env{'form.deldisc'}); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb); |
|
my $ressymb=&wrap_symb($symb); |
|
unless (&can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum)) { |
|
&redirect_back($r,$feedurl,&mt('Deletion not permitted').'<br />', |
|
'0','0','','',$env{'form.previous'},'','','','', |
|
undef,undef,$group); |
|
return OK; |
|
} |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
my ($changelast,$newlast) = &get_discussion_info($idx,%contrib); |
my ($changelast,$newlast) = &get_discussion_info($idx,%contrib); |
if ($changelast) { |
if ($changelast) { |
&Apache::lonnet::put('discussiontimes',{$symb => $newlast}, |
&Apache::lonnet::put('discussiontimes',{$symb => $newlast}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); |
$cdom,$cnum); |
} |
} |
my %newhash=('deleted' => $contrib{'deleted'}.".$idx."); |
my %newhash=('deleted' => $contrib{'deleted'}.".$idx."); |
&Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'}, |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
my $result; |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
if (&Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'}, |
&redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />', |
$cdom,$cnum) eq 'ok') { |
'0','0','','',$env{'form.previous'},undef,undef,undef, |
$result = &mt('Changed discussion status'); |
|
my $prefix=$symb.':'.$idx.':'; |
|
my %likes=&Apache::lonnet::dump('disclikes',$cdom,$cnum, |
|
'^'.$prefix); |
|
my ($totallikes,$totalunlikes); |
|
if (ref($likes{$prefix.'likers'}) eq 'HASH') { |
|
$totallikes = scalar(keys(%{$likes{$prefix.'likers'}})); |
|
} |
|
if (ref($likes{$prefix.'unlikers'}) eq 'HASH') { |
|
$totalunlikes = scalar(keys(%{$likes{$prefix.'unlikers'}})); |
|
} |
|
if ($totallikes || $totalunlikes) { |
|
my $chglikes = -1 * $totallikes; |
|
my $chgunlikes = -1 * $totalunlikes; |
|
&storediscussionlikes($chglikes,$chgunlikes, |
|
$contrib{$idx.':sendername'}, |
|
$contrib{$idx.':senderdomain'}, |
|
$env{'request.course.id'}, |
|
'delete'); |
|
} |
|
} else { |
|
$result = &mt('Discussion status unchanged'); |
|
} |
|
&redirect_back($r,$feedurl,$result.'<br />','0','0','','', |
|
$env{'form.previous'},undef,undef,undef, |
undef,undef,undef,$group); |
undef,undef,undef,$group); |
return OK; |
return OK; |
} elsif ($env{'form.preview'}) { |
} elsif ($env{'form.preview'}) { |
Line 4082 ENDREDIR
|
Line 4318 ENDREDIR
|
my $idx = $env{'form.idx'}; |
my $idx = $env{'form.idx'}; |
if ($idx) { |
if ($idx) { |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
$attachmenturls = $contrib{$idx.':attachmenturl'}; |
$attachmenturls = $contrib{$idx.':attachmenturl'}; |
} |
} |
&modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx, |
&modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx, |
Line 4107 ENDREDIR
|
Line 4342 ENDREDIR
|
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
$r->print($start_page.$discussion.$end_page); |
$r->print($start_page.$discussion.$end_page); |
return OK; |
return OK; |
|
} elsif ($env{'form.undeleteall'}) { |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.undeleteall'}); |
|
my $ressymb=&wrap_symb($symb); |
|
$r->print(&Apache::loncommon::start_page('Undelete all deleted discussion entries')); |
|
if (&can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum)) { |
|
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'}, |
|
$cdom,$cnum); |
|
$contrib{'deleted'} =~ s/^\.//; |
|
$contrib{'deleted'} =~ s/\.$//; |
|
if ($contrib{'deleted'} ne '') { |
|
if (&Apache::lonnet::store({'deleted' => ''},$symb,$env{'request.course.id'}, |
|
$cdom,$cnum) eq 'ok') { |
|
my %likes=&Apache::lonnet::dump('disclikes',$cdom,$cnum,'^'.$symb.':'); |
|
my @ids = split(/\.\./,$contrib{'deleted'}); |
|
my (%chglikes,%chgunlikes); |
|
foreach my $idx (@ids) { |
|
my $uname = $contrib{$idx.':sendername'}; |
|
my $udom = $contrib{$idx.':senderdomain'}; |
|
my ($totallikes,$totalunlikes); |
|
if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') { |
|
$totallikes = scalar(keys(%{$likes{$symb.':'.$idx.':likers'}})); |
|
} |
|
if (ref($likes{$symb.':'.$idx.':unlikers'}) eq 'HASH') { |
|
$totalunlikes = scalar(keys(%{$likes{$symb.':'.$idx.':unlikers'}})); |
|
} |
|
if ($totallikes || $totalunlikes) { |
|
$chglikes{$uname.':'.$udom} += $totallikes; |
|
$chgunlikes{$uname.':'.$udom} += $totalunlikes; |
|
} |
|
} |
|
foreach my $user (keys(%chglikes)) { |
|
my ($uname,$udom) = split(/:/,$user); |
|
&storediscussionlikes($chglikes{$user},$chgunlikes{$user}, |
|
$uname,$udom,$env{'request.course.id'}, |
|
'undelete'); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Undeleted all entries"))); |
|
} else { |
|
$r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Failed to undelete entries"),1)); |
|
} |
|
} else { |
|
$r->print(&Apache::lonhtmlcommon::confirm_success(&mt("No entries to undelete"),1)); |
|
} |
|
$r->print("<br /><a href='$feedurl'>".&mt("Return and reload")."</a>"); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
} else { |
} else { |
# ------------------------------------------------------------- Normal feedback |
# ------------------------------------------------------------- Normal feedback |
my $feedurl=$env{'form.postdata'}; |
my $feedurl=$env{'form.postdata'}; |
Line 4121 ENDREDIR
|
Line 4405 ENDREDIR
|
} elsif ($env{'form.editdisc'}) { |
} elsif ($env{'form.editdisc'}) { |
$symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
$symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0]; |
} elsif ($env{'form.origpage'}) { |
} elsif ($env{'form.origpage'}) { |
$symb=""; |
$symb=""; |
} else { |
} else { |
$symb=&Apache::lonnet::symbread($feedurl); |
$symb=&Apache::lonnet::symbread($feedurl); |
} |
} |
Line 4301 sub wrap_symb {
|
Line 4585 sub wrap_symb {
|
} |
} |
return $ressymb; |
return $ressymb; |
} |
} |
|
|
sub dewrapper { |
sub dewrapper { |
my ($feedurl)=@_; |
my ($feedurl)=@_; |
if ($$feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { |
if ($$feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) { |
Line 4454 None
|
Line 4739 None
|
|
|
=item discussion_visible() |
=item discussion_visible() |
|
|
|
=item discussion_vote_available() |
|
|
|
=item get_realsymb() |
|
|
=item list_discussion() |
=item list_discussion() |
|
|
|
=item can_see_hidden() |
|
|
|
=item discussion_link() |
|
|
=item send_feedback_link() |
=item send_feedback_link() |
|
|
=item send_message_link() |
=item send_message_link() |