+$nicescroll_js
+
+
+
END
}
@@ -7938,6 +7962,87 @@ sub end_scrollbox {
return ' |
';
}
+sub nicescroll_javascript {
+ my ($id,$cursor,$needjsready,$framecheck,$location) = @_;
+ 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.'"');
+ }
+ }
+ my $nicescroll_js = '
+$(document).ready(
+ function() {
+ $("#'.$id.'").niceScroll({'.join(',',@niceoptions).'});
+ }
+);
+';
+ if ($framecheck) {
+ $nicescroll_js .= '
+function expand_div(caller) {
+ if (top === self) {
+ document.getElementById("'.$id.'").style.width = "auto";
+ document.getElementById("'.$id.'").style.height = "auto";
+ } else {
+ try {
+ if (parent.frames) {
+ if (parent.frames.length > 1) {
+ var framesrc = parent.frames[1].location.href;
+ var currsrc = framesrc.replace(/\#.*$/,"");
+ if ((caller == "search") || (currsrc == "'.$location.'")) {
+ document.getElementById("'.$id.'").style.width = "auto";
+ document.getElementById("'.$id.'").style.height = "auto";
+ }
+ }
+ }
+ } catch (e) {
+ return;
+ }
+ }
+ return;
+}
+';
+ }
+ if ($needjsready) {
+ $nicescroll_js = '
+\n";
+ } else {
+ $nicescroll_js = &Apache::lonhtmlcommon::scripttag($nicescroll_js);
+ }
+ return $nicescroll_js;
+}
+
sub simple_error_page {
my ($r,$title,$msg) = @_;
my $page =
@@ -8568,7 +8673,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 +8697,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 +8748,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);
}
@@ -8670,6 +8782,7 @@ Retrieves default quota assigned for sto
given an (optional) user's institutional status.
Incoming parameters:
+
1. domain
2. (Optional) institutional status(es). This is a : separated list of
status types (e.g., faculty, staff, student etc.)
@@ -8680,6 +8793,7 @@ Incoming parameters:
(if no quota name provided, defaults to portfolio).
Returns:
+
1. Default disk quota (in Mb) for user portfolios in the domain.
2. (Optional) institutional type which determined the value of the
default quota.
@@ -8693,8 +8807,6 @@ If the user's status includes multiple t
the largest default quota which applies to the user determines the
default quota returned.
-=back
-
=cut
###############################################
@@ -8743,6 +8855,11 @@ sub default_quota {
$defquota = $quotahash{'quotas'}{'default'};
}
$settingstatus = 'default';
+ if ($defquota eq '') {
+ if ($quotaname eq 'author') {
+ $defquota = 500;
+ }
+ }
}
} else {
$settingstatus = 'default';
@@ -8763,29 +8880,43 @@ 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.
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded,
- otherwise return null.
+ otherwise return null.
+
+=back
=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 +8931,8 @@ sub excess_filesize_authorspace {
###############################################
+
+
sub get_secgrprole_info {
my ($cdom,$cnum,$needroles,$type) = @_;
my %sections_count = &get_sections($cdom,$cnum);
@@ -14158,7 +14291,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,$clientinfo) = &decode_user_agent($r);
# ------------------------------------------------------------- Get environment
@@ -14189,6 +14322,8 @@ sub init_user_environment {
"browser.mathml" => $clientmathml,
"browser.unicode" => $clientunicode,
"browser.os" => $clientos,
+ "browser.mobile" => $clientmobile,
+ "browser.info" => $clientinfo,
"server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'},
"request.course.fn" => '',
"request.course.uri" => '',