--- loncom/interface/loncommon.pm 2012/03/04 15:42:52 1.1057 +++ loncom/interface/loncommon.pm 2012/03/24 23:35:25 1.1061 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1057 2012/03/04 15:42:52 foxr Exp $ +# $Id: loncommon.pm,v 1.1061 2012/03/24 23:35:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4017,18 +4017,25 @@ sub findallcourses { if ($tstart) { next if ($tstart > $now); } - my ($cdom,$cnum,$sec,$cnumpart,$secpart,$role,$realsec); + my ($cdom,$cnum,$sec,$cnumpart,$secpart,$role); (undef,$cdom,$cnumpart,$secpart) = split(/\//,$entry); + my $value = $trole.'/'.$cdom.'/'; if ($secpart eq '') { ($cnum,$role) = split(/_/,$cnumpart); $sec = 'none'; - $realsec = ''; + $value .= $cnum.'/'; } else { $cnum = $cnumpart; ($sec,$role) = split(/_/,$secpart); - $realsec = $sec; + $value .= $cnum.'/'.$sec; + } + if (ref($courses{$cdom.'_'.$cnum}{$sec}) eq 'ARRAY') { + unless (grep(/^\Q$value\E$/,@{$courses{$cdom.'_'.$cnum}{$sec}})) { + push(@{$courses{$cdom.'_'.$cnum}{$sec}},$value); + } + } else { + @{$courses{$cdom.'_'.$cnum}{$sec}} = ($value); } - $courses{$cdom.'_'.$cnum}{$sec} = $trole.'/'.$cdom.'/'.$cnum.'/'.$realsec; } } else { foreach my $key (keys(%env)) { @@ -4046,11 +4053,19 @@ sub findallcourses { if ($now>$endtime) { $active=0; } } if ($active) { + my $value = $role.'/'.$cdom.'/'.$cnum.'/'; if ($sec eq '') { $sec = 'none'; + } else { + $value .= $sec; + } + if (ref($courses{$cdom.'_'.$cnum}{$sec}) eq 'ARRAY') { + unless (grep(/^\Q$value\E$/,@{$courses{$cdom.'_'.$cnum}{$sec}})) { + push(@{$courses{$cdom.'_'.$cnum}{$sec}},$value); + } + } else { + @{$courses{$cdom.'_'.$cnum}{$sec}} = ($value); } - $courses{$cdom.'_'.$cnum}{$sec} = - $role.'/'.$cdom.'/'.$cnum.'/'.$sec; } } } @@ -4143,34 +4158,38 @@ sub blockcheck { if ($otheruser) { # Resource belongs to user other than current user. # Assemble privs for that user, and check for 'evb' priv. - my ($trole,$tdom,$tnum,$tsec); - my $entry = $live_courses{$course}{$sec}; - if ($entry =~ /^cr/) { - ($trole,$tdom,$tnum,$tsec) = - ($entry =~ m|^(cr/$match_domain/$match_username/\w+)\./($match_domain)/($match_username)/?(\w*)$|); - } else { - ($trole,$tdom,$tnum,$tsec) = split(/\//,$entry); - } - my ($spec,$area,$trest,%allroles,%userroles); - $area = '/'.$tdom.'/'.$tnum; - $trest = $tnum; - if ($tsec ne '') { - $area .= '/'.$tsec; - $trest .= '/'.$tsec; - } - $spec = $trole.'.'.$area; - if ($trole =~ /^cr/) { - &Apache::lonnet::custom_roleprivs(\%allroles,$trole, - $tdom,$spec,$trest,$area); - } else { - &Apache::lonnet::standard_roleprivs(\%allroles,$trole, - $tdom,$spec,$trest,$area); - } - my ($author,$adv) = &Apache::lonnet::set_userprivs(\%userroles,\%allroles); - if ($userroles{'user.priv.'.$checkrole} =~ /evb\&([^\:]*)/) { - if ($1) { - $no_userblock = 1; - last; + my (%allroles,%userroles); + if (ref($live_courses{$course}{$sec}) eq 'ARRAY') { + foreach my $entry (@{$live_courses{$course}{$sec}}) { + my ($trole,$tdom,$tnum,$tsec); + if ($entry =~ /^cr/) { + ($trole,$tdom,$tnum,$tsec) = + ($entry =~ m|^(cr/$match_domain/$match_username/\w+)\./($match_domain)/($match_username)/?(\w*)$|); + } else { + ($trole,$tdom,$tnum,$tsec) = split(/\//,$entry); + } + my ($spec,$area,$trest); + $area = '/'.$tdom.'/'.$tnum; + $trest = $tnum; + if ($tsec ne '') { + $area .= '/'.$tsec; + $trest .= '/'.$tsec; + } + $spec = $trole.'.'.$area; + if ($trole =~ /^cr/) { + &Apache::lonnet::custom_roleprivs(\%allroles,$trole, + $tdom,$spec,$trest,$area); + } else { + &Apache::lonnet::standard_roleprivs(\%allroles,$trole, + $tdom,$spec,$trest,$area); + } + } + my ($author,$adv) = &Apache::lonnet::set_userprivs(\%userroles,\%allroles); + if ($userroles{'user.priv.'.$checkrole} =~ /evb\&([^\:]*)/) { + if ($1) { + $no_userblock = 1; + last; + } } } } else { @@ -4253,39 +4272,39 @@ sub parse_block_record { } sub blocking_status { - my ($activity,$uname,$udom) = @_; - my %setters; + my ($activity,$uname,$udom) = @_; + my %setters; - # check for active blocking - my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom); +# check for active blocking + my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom); - my $blocked = $startblock && $endblock ? 1 : 0; + my $blocked = $startblock && $endblock ? 1 : 0; - # caller just wants to know whether a block is active - if (!wantarray) { return $blocked; } - - # build a link to a popup window containing the details - my $querystring = "?activity=$activity"; - # $uname and $udom decide whose portfolio the user is trying to look at - $querystring .= "&udom=$udom" if $udom; - $querystring .= "&uname=$uname" if $uname; - - my $output .= <<'END_MYBLOCK'; - function openWindow(url, wdwName, w, h, toolbar,scrollbar) { - var options = "width=" + w + ",height=" + h + ","; - options += "resizable=yes,scrollbars="+scrollbar+",status=no,"; - options += "menubar=no,toolbar="+toolbar+",location=no,directories=no"; - var newWin = window.open(url, wdwName, options); - newWin.focus(); - } +# caller just wants to know whether a block is active + if (!wantarray) { return $blocked; } + +# build a link to a popup window containing the details + my $querystring = "?activity=$activity"; +# $uname and $udom decide whose portfolio the user is trying to look at + $querystring .= "&udom=$udom" if $udom; + $querystring .= "&uname=$uname" if $uname; + + my $output .= <<'END_MYBLOCK'; +function openWindow(url, wdwName, w, h, toolbar,scrollbar) { + var options = "width=" + w + ",height=" + h + ","; + options += "resizable=yes,scrollbars="+scrollbar+",status=no,"; + options += "menubar=no,toolbar="+toolbar+",location=no,directories=no"; + var newWin = window.open(url, wdwName, options); + newWin.focus(); +} END_MYBLOCK - $output = Apache::lonhtmlcommon::scripttag($output); + $output = Apache::lonhtmlcommon::scripttag($output); - my $popupUrl = "/adm/blockingstatus/$querystring"; - my $text = mt('Communication Blocked'); + my $popupUrl = "/adm/blockingstatus/$querystring"; + my $text = mt('Communication Blocked'); - $output .= <<"END_BLOCK"; + $output .= <<"END_BLOCK";
@@ -4296,7 +4315,7 @@ END_MYBLOCK END_BLOCK - return ($blocked, $output); + return ($blocked, $output); } ############################################### @@ -4995,7 +5014,7 @@ sub standard_css { my $mono = 'monospace'; my $data_table_head = $sidebg; my $data_table_light = '#FAFAFA'; - my $data_table_dark = '#F0F0F0'; + my $data_table_dark = '#E0E0E0'; my $data_table_darker = '#CCCCCC'; my $data_table_highlight = '#FFFF00'; my $mail_new = '#FFBB77'; @@ -6082,6 +6101,7 @@ div.LC_edit_problem_footer { font-weight: normal; font-size: medium; margin: 2px; + background-color: $sidebg; } div.LC_edit_problem_header, @@ -6098,6 +6118,7 @@ div.LC_edit_problem_header_title { font-size: larger; background: $tabbg; padding: 3px; + margin: 0 0 5px 0; } table.LC_edit_problem_header_title { @@ -9986,12 +10007,12 @@ sub archive_row { my ($is_dir,$item,$currdir,$depth,$count) = @_; my ($name) = ($item =~ m{([^/]+)$}); my %choices = &Apache::lonlocal::texthash ( - 'display' => 'Add as File', + 'display' => 'Add as file', 'dependency' => 'Include as dependency', 'discard' => 'Discard', ); if ($is_dir) { - $choices{'display'} = &mt('Add as Folder'); + $choices{'display'} = &mt('Add as folder'); } my $output = &start_data_table_row().''.$count.''."\n"; my $offset = 0; @@ -10004,7 +10025,7 @@ sub archive_row { if ($is_dir) { $output .= ' onclick="javascript:propagateCheck(this.form,'."'$count'".');"'; if ($action eq 'display') { - $text = &mt('Add as Folder'); + $text = &mt('Add as folder'); } } else { $output .= ' onclick="javascript:dependencyCheck(this.form,'."$count,$offset".');"'; @@ -10018,6 +10039,10 @@ sub archive_row { ''."\n". ''."\n". '
'; + } elsif ($action eq 'display') { + $output .= ''; } $output .= ''; } @@ -10046,9 +10071,9 @@ sub archive_options_form { '

'. '
'. ''.&mt('Content actions for all').''. - ''. - '  '. '  '. @@ -10065,6 +10090,7 @@ sub archive_options_form { sub archive_javascript { my ($startcount,$numitems,$titles,$children) = @_; return unless ((ref($titles) eq 'HASH') && (ref($children) eq 'HASH')); + my $maintitle = $env{'form.comment'}; my $scripttag = < // 0) { - var startelement = $startcount + ((count-1) * 6); - for (var j=1; j<5; j++) { - if (j != 3) { + var startelement = $startcount + ((count-1) * 7); + for (var j=1; j<6; j++) { + if ((j != 2) && (j != 4)) { var item = startelement + j; if (form.elements[item].type == 'radio') { if (form.elements[item].checked) { @@ -10110,6 +10136,7 @@ var parents = new Array(numitems); for (var i=0; i 0) { dependencyCheck(form,count,offset); - var item = (offset+$startcount)+6*(count-1); + var item = (offset+$startcount)+7*(count-1); form.elements[item].checked = true; if(Object.prototype.toString.call(parents[count]) === '[object Array]') { if (parents[count].length > 0) { @@ -10143,17 +10170,17 @@ function containerCheck(form,count,offse function dependencyCheck(form,count,offset) { if (count > 0) { - var chosen = (offset+$startcount)+6*(count-1); - var depitem = $startcount + ((count-1) * 6) + 3; + var chosen = (offset+$startcount)+7*(count-1); + var depitem = $startcount + ((count-1) * 7) + 4; var currtype = form.elements[depitem].type; if (form.elements[chosen].value == 'dependency') { document.getElementById('arc_depon_'+count).style.display='block'; form.elements[depitem].options.length = 0; form.elements[depitem].options[0] = new Option('Select','',true,true); for (var i=1; i 0) { - var item = (1+offset+$startcount)+6*(count-1); + var item = (2+offset+$startcount)+7*(count-1); var picked = form.elements[item].options[form.elements[item].selectedIndex].value; if (Object.prototype.toString.call(parents[count]) === '[object Array]') { if (parents[count].length > 0) { @@ -10190,7 +10218,7 @@ function propagateSelect(form,count,offs function containerSelect(form,count,offset,picked) { if (count > 0) { - var item = (offset+$startcount)+6*(count-1); + var item = (1+offset+$startcount)+7*(count-1); if (form.elements[item].type == 'radio') { if (form.elements[item].value == 'dependency') { if (form.elements[item+1].type == 'select-one') { @@ -10213,6 +10241,26 @@ function containerSelect(form,count,offs } } +function titleCheck(form,count,offset) { + if (count > 0) { + var chosen = (offset+$startcount)+7*(count-1); + var depitem = $startcount + ((count-1) * 7) + 2; + var currtype = form.elements[depitem].type; + if (form.elements[chosen].value == 'display') { + document.getElementById('arc_title_'+count).style.display='block'; + if ((count==1) && ((parents[count].length > 0) || (numitems == 1))) { + document.getElementById('archive_title_'+count).value=maintitle; + } + } else { + document.getElementById('arc_title_'+count).style.display='none'; + if (currtype == 'text') { + document.getElementById('archive_title_'+count).value=''; + } + } + } + return; +} + // ]]> END @@ -10279,8 +10327,12 @@ sub process_extracted_files { } } } elsif ($env{'form.archive_'.$i} eq 'display') { - my ($title,$url,$outer); + my ($docstitle,$title,$url,$outer); ($title) = ($path =~ m{/([^/]+)$}); + $docstitle = $env{'form.archive_title_'.$i}; + if ($docstitle eq '') { + $docstitle = $title; + } $outer = 0; if (ref($dirorder{$i}) eq 'ARRAY') { if (@{$dirorder{$i}} > 0) { @@ -10306,7 +10358,7 @@ sub process_extracted_files { $folders{$i}.'.'.$containers{$i}; my $newidx = &LONCAPA::map::getresidx(); $LONCAPA::map::resources[$newidx]= - $title.':'.$url.':false:normal:res'; + $docstitle.':'.$url.':false:normal:res'; push(@LONCAPA::map::order,$newidx); my ($outtext,$errtext) = &LONCAPA::map::storemap('/uploaded/'.$docudom.'/'. @@ -10331,7 +10383,7 @@ sub process_extracted_files { $newdest{$i} = "$prefix$dir/$docstype/$mapinner{$outer}/$newidx"; } $LONCAPA::map::resources[$newidx]= - $title.':'.$url.':false:normal:res'; + $docstitle.':'.$url.':false:normal:res'; push(@LONCAPA::map::order, $newidx); my ($outtext,$errtext)= &LONCAPA::map::storemap('/uploaded/'.$docudom.'/'.