--- loncom/interface/loncommon.pm 2013/07/03 05:03:12 1.1135 +++ loncom/interface/loncommon.pm 2013/07/11 18:24:31 1.1138 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1135 2013/07/03 05:03:12 raeburn Exp $ +# $Id: loncommon.pm,v 1.1138 2013/07/11 18:24:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2349,6 +2349,8 @@ Outputs: =item * $clientos +=item * $clientmobile + =back =back @@ -2367,6 +2369,7 @@ sub decode_user_agent { my $clientversion='0'; my $clientmathml=''; my $clientunicode='0'; + my $clientmobile=0; for (my $i=0;$i<=$#browsertype;$i++) { my ($bname,$match,$notmatch,$vreg,$minv,$univ)=split(/\:/,$browsertype[$i]); if (($httpbrowser=~/$match/i) && ($httpbrowser!~/$notmatch/i)) { @@ -2389,8 +2392,11 @@ sub decode_user_agent { ($httpbrowser=~/powerpc/i)) { $clientos='mac'; } if ($httpbrowser=~/win/i) { $clientos='win'; } if ($httpbrowser=~/embed/i) { $clientos='pda'; } + if ($httpbrowser=~/(Android|iPod|iPad|iPhone|webOS|Blackberry|Windows Phone|Opera m(?:ob|in)|Fennec)/i) { + $clientmobile=lc($1); + } return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, - $clientunicode,$clientos,); + $clientunicode,$clientos,$clientmobile); } ############################################################### @@ -7312,6 +7318,11 @@ ADDMETA .'' .$inhibitprint .$head_extra; + if ($env{'browser.mobile'}) { + $result .= ' + +'; + } return $result.''; } @@ -7697,7 +7708,7 @@ sub modal_adhoc_inner { my $innerwidth=$width-20; $content=&js_ready( &start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). - &start_scrollbox($width.'px',$innerwidth.'px',$height.'px'). + &start_scrollbox($width.'px',$innerwidth.'px',$height.'px','modal'). $content. &end_scrollbox(). &end_page() @@ -7917,20 +7928,76 @@ sub validate_page { sub start_scrollbox { - my ($outerwidth,$width,$height,$id,$bgcolor)=@_; + my ($outerwidth,$width,$height,$id,$bgcolor,$cursor) = @_; unless ($outerwidth) { $outerwidth='520px'; } unless ($width) { $width='500px'; } unless ($height) { $height='200px'; } my ($table_id,$div_id,$tdcol); if ($id ne '') { $table_id = " id='table_$id'"; - $div_id = " id='div_$id'"; + $div_id = ' id="div_'.$id.'"'; } if ($bgcolor ne '') { $tdcol = "background-color: $bgcolor;"; } + my $nicescroll_js; + if ($env{'browser.mobile'}) { + my %options; + if (ref($cursor) eq 'HASH') { + %options = %{$cursor}; + } + unless ($options{'railalign'} =~ /^left|right$/) { + $options{'railalign'} = 'left'; + } + unless ($options{'cursorcolor'} =~ /^\#\w+$/) { + my $function = &get_users_function(); + $options{'cursorcolor'} = &designparm($function.'.sidebg',$env{'request.role.domain'}); + unless ($options{'cursorcolor'} =~ /^\#\w+$/) { + $options{'cursorcolor'} = '#00F'; + } + } + if ($options{'cursoropacity'} =~ /^[\d.]+$/) { + unless ($options{'cursoropacity'} >= 0.0 && $options{'cursoropacity'} <=1.0) { + $options{'cursoropacity'}='1.0'; + } + } else { + $options{'cursoropacity'}='1.0'; + } + if ($options{'cursorfixedheight'} eq 'none') { + delete($options{'cursorfixedheight'}); + } else { + unless ($options{'cursorfixedheight'} =~ /^\d+$/) { $options{'cursorfixedheight'}='50'; } + } + unless ($options{'railoffset'} =~ /^{[\w\:\d]+}$/) { + delete($options{'railoffset'}); + } + my @niceoptions; + while (my($key,$value) = each(%options)) { + if ($value =~ /^\{.+\}$/) { + push(@niceoptions,$key.':'.$value); + } else { + push(@niceoptions,$key.':"'.$value.'"'); + } + } + $nicescroll_js = ' + +'; + } + return <<"END"; -
+$nicescroll_js + +
+
END } @@ -8568,7 +8635,9 @@ Incoming parameters: 1. user's username 2. user's domain 3. quota name - portfolio, author, or course - (if no quota name provided, defaults to portfolio). + (if no quota name provided, defaults to portfolio). +4. crstype - official, unofficial or community, if quota name is + course Returns: 1. Disk quota (in Mb) assigned to student. @@ -8590,7 +8659,7 @@ defined for the user's institutional sta sub get_user_quota { - my ($uname,$udom,$quotaname) = @_; + my ($uname,$udom,$quotaname,$crstype) = @_; my ($quota,$quotatype,$settingstatus,$defquota); if (!defined($udom)) { $udom = $env{'user.domain'}; @@ -8641,7 +8710,12 @@ sub get_user_quota { if ($quota eq '' || wantarray) { if ($quotaname eq 'course') { my %domdefs = &Apache::lonnet::get_domain_defaults($udom); - $defquota = $domdefs{'uploadquota'}; + if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'community')) { + $defquota = $domdefs{$crstype.'quota'}; + } + if ($defquota eq '') { + $defquota = 500; + } } else { ($defquota,$settingstatus) = &default_quota($udom,$inststatus,$quotaname); } @@ -8763,15 +8837,19 @@ sub default_quota { =pod -=item * &excess_filesize_authorspace() +=item * &excess_filesize_warning() Returns warning message if upload of file to authoring space, or copying -of existing file within authoring space will cause quota to be exceeded. +of existing file within authoring space will cause quota for the authoring +space to be exceeded, + +Same, if upload of a file directly to a course/community via Course Editor +will cause quota for uploaded content for the course to be exceeded. Inputs: 6 -1. username +1. username or coursenum 2. domain -3. directory path for top level of current authoring space +3. context ('author' or 'course') 4. filename of file for which action is being requested 5. filesize (kB) of file 6. action being taken: copy or upload. @@ -8781,11 +8859,19 @@ Returns: 1 scalar: HTML to display conta =cut -sub excess_filesize_authorspace { - my ($uname,$udom,$authorspace,$filename,$filesize,$action) = @_; - my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB +sub excess_filesize_warning { + my ($uname,$udom,$context,$filename,$filesize,$action) = @_; + my $current_disk_usage = 0; + my $disk_quota = &get_user_quota($uname,$udom,$context); #expressed in MB + if ($context eq 'author') { + my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$udom/$uname"; + $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); + } else { + foreach my $subdir ('docs','supplemental') { + $current_disk_usage += &Apache::lonnet::diskusage($udom,$uname,"userfiles/$subdir",1); + } + } $disk_quota = int($disk_quota * 1000); - my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); if (($current_disk_usage + $filesize) > $disk_quota) { return '

'. &mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", @@ -8800,6 +8886,8 @@ sub excess_filesize_authorspace { ############################################### + + sub get_secgrprole_info { my ($cdom,$cnum,$needroles,$type) = @_; my %sections_count = &get_sections($cdom,$cnum); @@ -14158,7 +14246,7 @@ sub init_user_environment { # ------------------------------------ Check browser type and MathML capability my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml, - $clientunicode,$clientos) = &decode_user_agent($r); + $clientunicode,$clientos,$clientmobile) = &decode_user_agent($r); # ------------------------------------------------------------- Get environment @@ -14189,6 +14277,7 @@ sub init_user_environment { "browser.mathml" => $clientmathml, "browser.unicode" => $clientunicode, "browser.os" => $clientos, + "browser.mobile" => $clientmobile, "server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'}, "request.course.fn" => '', "request.course.uri" => '',