--- loncom/interface/loncommon.pm 2010/08/07 19:23:50 1.972
+++ loncom/interface/loncommon.pm 2010/10/27 01:04:10 1.984
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.972 2010/08/07 19:23:50 raeburn Exp $
+# $Id: loncommon.pm,v 1.984 2010/10/27 01:04:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1072,7 +1072,7 @@ END
=pod
-=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height)
+=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid)
Returns a string corresponding to an HTML link to the given help
$topic, where $topic corresponds to the name of a .tex file in
@@ -1090,12 +1090,16 @@ a new window using Javascript. (Default
$width and $height are optional numerical parameters that will
override the width and height of the popped up window, which may
-be useful for certain help topics with big pictures included.
+be useful for certain help topics with big pictures included.
+
+$imgid is the id of the img tag used for the help icon. This may be
+used in a javascript call to switch the image src. See
+lonhtmlcommon::htmlareaselectactive() for an example.
=cut
sub help_open_topic {
- my ($topic, $text, $stayOnPage, $width, $height) = @_;
+ my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_;
$text = "" if (not defined $text);
$stayOnPage = 0 if (not defined $stayOnPage);
$width = 350 if (not defined $width);
@@ -1124,10 +1128,13 @@ sub help_open_topic {
# (Always) Add the graphic
my $title = &mt('Online Help');
my $helpicon=&lonhttpdurl("/adm/help/help.png");
+ if ($imgid ne '') {
+ $imgid = ' id="'.$imgid.'"';
+ }
$template.=' '
.'';
if ($text ne "") {
$template.='';
@@ -3404,7 +3411,7 @@ sub get_previous_attempt {
}
$prevattempts=&start_data_table().&start_data_table_header_row();
$prevattempts.='
'.&mt('History').' | ';
- my %typeparts;
+ my (%typeparts,%lasthidden);
my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'});
foreach my $key (sort(keys(%lasthash))) {
my ($ign,@parts) = split(/\./,$key);
@@ -3415,6 +3422,9 @@ sub get_previous_attempt {
unless ($showsurv) {
my $id = join(',',@parts);
$typeparts{$ign.'.'.$id} = $lasthash{$key};
+ if (($lasthash{$key} eq 'anonsurvey') || ($lasthash{$key} eq 'anonsurveycred')) {
+ $lasthidden{$ign.'.'.$id} = 1;
+ }
}
delete($lasthash{$key});
} else {
@@ -3429,7 +3439,6 @@ sub get_previous_attempt {
}
}
$prevattempts.=&end_data_table_header_row();
- my %lasthidden;
if ($getattempt eq '') {
for ($version=1;$version<=$returnhash{'version'};$version++) {
my @hidden;
@@ -3437,11 +3446,6 @@ sub get_previous_attempt {
foreach my $id (keys(%typeparts)) {
if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
push(@hidden,$id);
- $lasthidden{$id} = 1;
- } elsif ($lasthidden{$id}) {
- if (exists($returnhash{$version.':'.$id.'.award'})) {
- delete($lasthidden{$id});
- }
}
}
}
@@ -3821,7 +3825,9 @@ sub findallcourses {
$udom = $env{'user.domain'};
}
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname);
+ my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
+ my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,'.',undef,
+ $extra);
if (!%roles) {
%roles = (
cc => 1,
@@ -4695,7 +4701,7 @@ sub bodytag {
sub dc_courseid_toggle {
my ($dc_info) = @_;
- return ' '.
+ return ' '.
''.
&mt('(More ...)').''.
''.$dc_info.'
';
@@ -5426,6 +5432,14 @@ span.LC_parm_symb {
color: #AAAAAA;
}
+ul.LC_parm_parmlist li {
+ display: inline-block;
+ padding: 0.3em 0.8em;
+ vertical-align: top;
+ width: 150px;
+ border-top:1px solid $lg_border_color;
+}
+
td.LC_parm_overview_level_menu,
td.LC_parm_overview_map_menu,
td.LC_parm_overview_parm_selectors,
@@ -6034,11 +6048,6 @@ fieldset > legend {
font-style: normal;
}
-/* Preliminary fix to hide nav_bar inside bookmarks window */
-#LC_bookmarks #LC_nav_bar {
- display:none;
-}
-
ol.LC_primary_menu {
float: right;
margin: 0;
@@ -6069,6 +6078,30 @@ ol.LC_primary_menu a.LC_new_message {
color: darkred;
}
+ol.LC_docs_parameters {
+ margin-left: 0;
+ padding: 0;
+ list-style: none;
+}
+
+ol.LC_docs_parameters li {
+ margin: 0;
+ padding-right: 20px;
+ display: inline;
+}
+
+ol.LC_docs_parameters li:before {
+ content: "\\002022 \\0020";
+}
+
+li.LC_docs_parameters_title {
+ font-weight: bold;
+}
+
+ol.LC_docs_parameters li.LC_docs_parameters_title:before {
+ content: "";
+}
+
ul#LC_secondary_menu {
clear: both;
color: $fontmenu;
@@ -6472,6 +6505,10 @@ ul.LC_funclist li {
padding: 0px 4px
}
+.LC_hidden {
+ display: none;
+}
+
END
}
@@ -6645,7 +6682,7 @@ $args - additional optional args support
should it have jsmath forced on by the
current page
bread_crumbs -> Array containing breadcrumbs
- bread_crumbs_components -> if exists show it as headline else show only the breadcrumbs
+ bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs
=back
@@ -6848,18 +6885,20 @@ sub simple_error_page {
}
sub start_data_table_row {
- my ($add_class) = @_;
+ my ($add_class, $id) = @_;
$row_count[0]++;
my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
$css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
- return ''."\n";;
+ $id = (' id="'.$id.'"') unless ($id eq '');
+ return '
'."\n";
}
sub continue_data_table_row {
- my ($add_class) = @_;
+ my ($add_class, $id) = @_;
my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
- $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');;
- return '
'."\n";;
+ $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
+ $id = (' id="'.$id.'"') unless ($id eq '');
+ return '
'."\n";
}
sub end_data_table_row {
@@ -7022,7 +7061,8 @@ role status: active, previous or future.
sub check_user_status {
my ($udom,$uname,$cdom,$crs,$role,$sec) = @_;
- my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
+ my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
+ my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname,'.',undef,$extra);
my @uroles = keys %userinfo;
my $srchstr;
my $active_chk = 'none';
@@ -8256,14 +8296,83 @@ sub get_env_multiple {
sub ask_for_embedded_content {
my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
- my $upload_output = '
- ';
+ if ($num) {
+ $upload_output = '';
+ }
return $upload_output;
}
@@ -8333,8 +8449,7 @@ sub upload_embedded {
$dir_root,$port_path,$disk_quota,
$current_disk_usage,$uname,$udom);
if ($state eq 'will_exceed_quota'
- || $state eq 'file_locked'
- || $state eq 'file_exists' ) {
+ || $state eq 'file_locked') {
$output .= $msg;
next;
}
@@ -8361,18 +8476,25 @@ sub upload_embedded {
$env{'form.embedded_item_'.$i.'.filename'}=$fname;
if ($context eq 'portfolio') {
- my $result=
- &Apache::lonnet::userfileupload('embedded_item_'.$i,'',
- $dirpath.$path);
- if ($result !~ m|^/uploaded/|) {
- $output .= ''
- .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
- ,$result,$orig_uploaded_filename,$env{'form.embedded_orig_'.$i})
- .'
';
- next;
+ my $result;
+ if ($state eq 'existingfile') {
+ $result=
+ &Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile',
+ $dirpath.$path,);
} else {
- $output .= ''.&mt('Uploaded [_1]',''.
- $path.$fname.'').'
';
+ $result=
+ &Apache::lonnet::userfileupload('embedded_item_'.$i,'',
+ $dirpath.$path);
+ if ($result !~ m|^/uploaded/|) {
+ $output .= ''
+ .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
+ ,$result,$orig_uploaded_filename,$env{'form.embedded_orig_'.$i})
+ .'
';
+ next;
+ } else {
+ $output .= ''.&mt('Uploaded [_1]',''.
+ $path.$fname.'').'
';
+ }
}
} else {
# Save the file
@@ -8445,7 +8567,7 @@ sub check_for_upload {
my $found_file = 0;
my $locked_file = 0;
foreach my $line (@dir_list) {
- my ($file_name)=split(/\&/,$line,2);
+ my ($file_name,$rest)=split(/\&/,$line,2);
if ($file_name eq $fname){
$file_name = $path.$file_name;
if ($group ne '') {
@@ -8454,6 +8576,20 @@ sub check_for_upload {
$found_file = 1;
if (&Apache::lonnet::is_locked($file_name,$udom,$uname) eq 'true') {
$locked_file = 1;
+ } else {
+ my @info = split(/\&/,$rest);
+ my $currsize = $info[6]/1000;
+ if ($currsize < $filesize) {
+ my $extra = $filesize - $currsize;
+ if (($current_disk_usage + $extra) > $disk_quota) {
+ my $msg = ''.
+ &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded if existing (smaller) file with same name (size = [_3] kilobytes) is replaced.',
+ ''.$fname.'',$filesize,$currsize).''.
+ '
'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
+ $disk_quota,$current_disk_usage);
+ return ('will_exceed_quota',$msg);
+ }
+ }
}
}
}
@@ -8471,11 +8607,9 @@ sub check_for_upload {
return ('file_locked',$msg);
} else {
my $msg = '';
- $msg .= &mt('Unable to upload [_1]. A file by that name was found in [_2].',''.$fname.'',$port_path.$env{'form.currentpath'});
+ $msg .= &mt(' A file by that name: [_1] was found in [_2].',''.$fname.'',$port_path.$env{'form.currentpath'});
$msg .= '';
- $msg .= '
';
- $msg .= &mt('To upload, rename or delete existing [_1] in [_2].',''.$fname.'', $port_path.$env{'form.currentpath'});
- return ('file_exists',$msg);
+ return ('existingfile',$msg);
}
}
}
@@ -10612,15 +10746,20 @@ sub init_user_environment {
$env{'browser.interface'}=$form->{'interface'};
}
+ my %is_adv = ( is_adv => $env{'user.adv'} );
+ my %domdef = &Apache::lonnet::get_domain_defaults($domain);
+
foreach my $tool ('aboutme','blog','portfolio') {
$userenv{'availabletools.'.$tool} =
- &Apache::lonnet::usertools_access($username,$domain,$tool,'reload');
+ &Apache::lonnet::usertools_access($username,$domain,$tool,'reload',
+ undef,\%userenv,\%domdef,\%is_adv);
}
foreach my $crstype ('official','unofficial','community') {
$userenv{'canrequest.'.$crstype} =
&Apache::lonnet::usertools_access($username,$domain,$crstype,
- 'reload','requestcourses');
+ 'reload','requestcourses',
+ \%userenv,\%domdef,\%is_adv);
}
$env{'user.environment'} = "$lonids/$cookie.id";