[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm

raeburn raeburn at source.lon-capa.org
Fri Mar 16 14:32:47 EDT 2012


raeburn		Fri Mar 16 18:32:47 2012 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  - Right to see ID behind anonymous posting is separate from right to delete
    and undelete postings for discussion boardss in groups.
  - New routine: &can_see_hidden() used to determine if user can hide/unhide
    or delete/undelete postings by other users.
  
  
-------------- next part --------------
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.346 loncom/interface/lonfeedback.pm:1.347
--- loncom/interface/lonfeedback.pm:1.346	Fri Mar 16 02:59:01 2012
+++ loncom/interface/lonfeedback.pm	Fri Mar 16 18:32:47 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.346 2012/03/16 02:59:01 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.347 2012/03/16 18:32:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -277,14 +277,10 @@
     $visit ++;
 
     my $seeid;
-    if (($group ne '') && ($mode eq 'board') && 
-        ($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);
+    if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+        $seeid = 1;
     }
+    my $seehidden = &can_see_hidden($mode,$ressymb,undef,$group,$cdom,$cnum,$crs);
 
 # Is voting on discussions available
     my $realsymb = &get_realsymb($ressymb);
@@ -311,7 +307,7 @@
     $discinfo{$visitkey} = $visit;
 
     &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,$canvote,$prevread,$sortposts,$encsymb,$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 $manifestfile;
@@ -467,7 +463,7 @@
                          "\n".'<table width="100%" class="LC_discussion">';
             $discussion .= &action_links_bar($colspan,$ressymb,$visible,
                                              $newpostsflag,$group,
-                                             $prevread,$markondisp);
+                                             $prevread,$markondisp,$seehidden);
             my $escsymb=&escape($ressymb);
             my $numhidden = keys(%notshown);
             if ($numhidden > 0) {
@@ -671,7 +667,7 @@
 END
             $discussion .= &action_links_bar($colspan,$ressymb,$visible,
                                              $newpostsflag,$group,
-                                             $prevread,$markondisp);
+                                             $prevread,$markondisp,$seehidden);
             $discussion .= "</table></form>\n";
         } 
         if ($outputtarget eq 'export') {
@@ -788,6 +784,38 @@
     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)=@_;
@@ -828,7 +856,8 @@
 }
 
 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 colspan="'.$colspan.'">'.
                      '<table width="100%"><tr>'.
                      '<td class="LC_disc_action_left">';
@@ -861,7 +890,7 @@
     }
     $discussion .= &group_args($group);
     $discussion .= '">'.&mt('Export').'</a>';
-    if (&Apache::lonnet::allowed('rin',$env{'request.course.id'})) {
+    if ($seehidden) {
         $discussion .= '  ';
         $discussion .='<a href="/adm/feedback?undeleteall='.$escsymb;
         if ($newpostsflag) {
@@ -968,7 +997,7 @@
 }
 
 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,$canvote,$prevread,$sortposts,$ressymb,$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 @index=();
     my $skip_group_check = 0;
@@ -1031,7 +1060,7 @@
                 my $idx=$id;
                 next if ($contrib{$idx.':deleted'});
                 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 '') {
                         push(@theselikes,$likes{$symb.':'.$idx.':likes'});
                         if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
@@ -1108,7 +1137,7 @@
 	    } else {
 		$$replies[$$depth[$idx]]=1;
 	    }
-            unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) {
+            unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx})) {
 		$$visible++;
                 if ($contrib{$idx.':history'}) {
                     if ($contrib{$idx.':history'} =~ /:/) {
@@ -1133,7 +1162,7 @@
 		    $$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
 		}
                 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
@@ -1223,14 +1252,14 @@
                                     if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
                                         $sender.=' '.
                                          &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group));
-                                        unless ($seeid) {
+                                        unless ($seehidden) {
                                             my $grpargs = &group_args($group);
                                             $sender.=" <a href=\"javascript:verifydelete('studentdelete','$escsymb','$idx','$$newpostsflag','$prevread','$grpargs')";
                                             $sender .= '">'.&mt('Delete').'</a>';
                                         }
                                     }
                                 }
-			        if ($seeid) {
+			        if ($seehidden) {
 			            if ($hiddens{$idx}) {
                                         unless ($studenthidden) {
  		                           $sender.=' '.
@@ -1456,7 +1485,7 @@
                             if ($contrib{$idx.':history'}) {
                                 my @postversions = ();
                                 $$discussionitems[$idx] .= '  '.&mt('This post has been edited by the author.');
-                                if ($seeid) {
+                                if ($seehidden) {
                                     $$discussionitems[$idx] .= '  '.
                                          &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group));
                                 }
@@ -1542,13 +1571,13 @@
 
 
 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 $start=$numver;
     my $end=$numver + 1;
     %{$$imsfiles{$idx}}=();
     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.');
            return $discussion;
        } 
@@ -2465,24 +2494,11 @@
     $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;
     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);
-    if (($group ne '') &&
-        ($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 $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum);
     my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
                                          $cdom,$cnum);
     my %namesort = ();
@@ -2498,7 +2514,7 @@
         for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
             my $hidden=($contrib{'hidden'}=~/\.$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'}:'')))) {
                     my %names = &Apache::lonnet::get('environment',['firstname','lastname'],$contrib{$idx.':senderdomain'},$contrib{$idx.':sendername'});
                     my $lastname = $names{'lastname'};
@@ -2523,7 +2539,7 @@
                     }
                 }
             }
-        }
+        }       
     }
 
     my $start_page = &Apache::loncommon::start_page('Discussion options');
@@ -3804,6 +3820,9 @@
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['like','unlike','modal','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 $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+  my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+
   my %attachmax = (
                     text => &mt('(128 KB max size)'),
                     num  => 131072,
@@ -3859,24 +3878,14 @@
 
       $r->print(&Apache::loncommon::start_page('Discussion Post Versions',undef,\%parms));
 
-      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'});
-      ($symb)=&get_feedurl_and_clean_symb($symb);
+      ($symb, my $feedurl)=&get_feedurl_and_clean_symb($symb);
       my $ressymb = &wrap_symb($symb);
       my $seeid;
-      if (($group ne '') && (($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);
+      if (&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
+          $seeid = 1;
       }
+      my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum);
       if ($idx > 0) {
           my %messages = ();
           my %subjects = ();
@@ -3885,9 +3894,8 @@
           my %imsfiles = ();
           my ($screenname,$plainname,$showaboutme);
           my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
-                           $env{'course.'.$env{'request.course.id'}.'.domain'},
-                           $env{'course.'.$env{'request.course.id'}.'.num'});
-          $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname,\$showaboutme));
+                                               $cdom,$cnum);
+          $r->print(&get_post_contents(\%contrib,$idx,$seeid,$seehidden,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname,\$showaboutme));
       }
       $r->print(&Apache::loncommon::end_page());
       return OK;
@@ -4025,37 +4033,32 @@
       my $entry=$env{'form.hide'}?$env{'form.hide'}:$env{'form.unhide'};
       my ($symb,$idx)=split(/\:\:\:/,$entry);
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
+      my $ressymb = &wrap($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);
-
-      if ($env{'form.hide'} && !$seeid && !(&editing_allowed($env{'form.hide'},$group))) {
-          &redirect_back($r,$feedurl,&mt('Deletion not permitted').'<br />',                 '0','0','','',$env{'form.previous'},'','','','',
-                 undef,undef,$group,);
+      my $seehidden = &can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum);
+      unless (($seehidden) || (&editing_allowed($env{'form.hide'},$group))) {
+          &redirect_back($r,$feedurl,&mt('Hiding not permitted').'<br />',
+                         '0','0','','',$env{'form.previous'},'','','','',
+                         undef,undef,$group,);
           return OK;
       }
 
       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 $currenthidden=$contrib{'hidden'};
       my $currentstudenthidden=$contrib{'studenthidden'};
 
       if ($env{'form.hide'}) {
 	  $currenthidden.='.'.$idx.'.';
-	  unless ($seeid) {
+	  unless ($seehidden) {
 	      $currentstudenthidden.='.'.$idx.'.';
 	  }
       } else {
 	  $currenthidden=~s/\.$idx\.//g;
       }
       my %newhash=('hidden' => $currenthidden);
-      if ( ($env{'form.hide'}) && (!$seeid) ) {
+      if ( ($env{'form.hide'}) && (!$seehidden) ) {
 	  $newhash{'studenthidden'} = $currentstudenthidden;
       }
       if ($env{'form.hide'}) {
@@ -4064,13 +4067,11 @@
           ($changelast,$newlast) = &get_discussion_info($idx,%contrib);
           if ($changelast) {
               &Apache::lonnet::put('discussiontimes',{$symb => $newlast},
-                     $env{'course.'.$env{'request.course.id'}.'.domain'},
-                     $env{'course.'.$env{'request.course.id'}.'.num'});
+                                   $cdom,$cnum);
           }
       }
       &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
-                           $env{'course.'.$env{'request.course.id'}.'.domain'},
-			   $env{'course.'.$env{'request.course.id'}.'.num'});
+                            $cdom,$cnum);
 
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
 		     '0','0','','',$env{'form.previous'},undef,undef,undef,
@@ -4091,8 +4092,7 @@
           }
           if (&discussion_vote_available($status,$realsymb)) {
               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);
               if (($contrib{$idx.':sendername'} eq $env{'user.name'}) && 
                   ($contrib{$idx.':senderdomain'} eq $env{'user.domain'})) {
                   $result = &mt("Vote not registered. No voting for your own posts.");
@@ -4104,10 +4104,8 @@
 # and the $idx to identify the entry
 #
                   my $prefix=$symb.':'.$idx.':';
-                  my %likes=&Apache::lonnet::dump('disclikes',
-                                  $env{'course.'.$env{'request.course.id'}.'.domain'},
-                                  $env{'course.'.$env{'request.course.id'}.'.num'},
-                                  '^'.$prefix);
+                  my %likes=&Apache::lonnet::dump('disclikes',$cdom,$cnum,
+                                                  '^'.$prefix);
 
 # Get current like or unlike status for the $idx for this user.
                   my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
@@ -4169,10 +4167,7 @@
                                    $prefix.'likers'   => $likes{$prefix.'likers'},
                                    $prefix.'unlikers' => $likes{$prefix.'unlikers'});
 # Store data in db-file "disclikes"
-                      if (&Apache::lonnet::put('disclikes',
-                                               \%newhash,
-                                               $env{'course.'.$env{'request.course.id'}.'.domain'},
-                                               $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
+                      if (&Apache::lonnet::put('disclikes',\%newhash,$cdom,$cnum) eq 'ok') {
 # Also store with the person who posted the liked/unliked entry
                           if ($env{'form.like'}) {
                               &storediscussionlikes(1,$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
@@ -4214,18 +4209,24 @@
 # --------------------------------------------------------------- Hide for good
       my ($symb,$idx)=split(/\:\:\:/,$env{'form.deldisc'});
       ($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'},
-                          $env{'course.'.$env{'request.course.id'}.'.domain'},
-		          $env{'course.'.$env{'request.course.id'}.'.num'});
+                                           $cdom,$cnum);
       my ($changelast,$newlast) = &get_discussion_info($idx,%contrib);
       if ($changelast) {
           &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.");
       &Apache::lonnet::store(\%newhash,$symb,$env{'request.course.id'},
-			   $env{'course.'.$env{'request.course.id'}.'.domain'},
-			   $env{'course.'.$env{'request.course.id'}.'.num'});
+                             $cdom,$cnum);
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
 		     '0','0','','',$env{'form.previous'},undef,undef,undef,
                      undef,undef,undef,$group);
@@ -4255,8 +4256,7 @@
       my $idx = $env{'form.idx'};
       if ($idx) {
           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);
           $attachmenturls = $contrib{$idx.':attachmenturl'};
       }
       &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,
@@ -4273,6 +4273,7 @@
           $mode='problem';
           $status=$Apache::inputtags::status[-1];
       }
+       
       my $discussion = &list_discussion($mode,$status,$symb); 
       my $start_page = 
 	  &Apache::loncommon::start_page('Resource Feedback and Discussion');
@@ -4285,11 +4286,11 @@
       &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 (&Apache::lonnet::allowed('rin',$env{'request.course.id'})) {
+      if (&can_see_hidden('',$ressymb,$feedurl,$group,$cdom,$cnum)) {
            if (&Apache::lonnet::store({'deleted' => ''},$symb,$env{'request.course.id'},
-                     $env{'course.'.$env{'request.course.id'}.'.domain'},
-                     $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
+                                      $cdom,$cnum) eq 'ok') {
                $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Undeleted all entries")));
            } else {
                $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Failed to undelete entries"),1));
@@ -4493,6 +4494,7 @@
     }
     return $ressymb;
 }
+
 sub dewrapper {
     my ($feedurl)=@_;
     if ($$feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {


More information about the LON-CAPA-cvs mailing list