--- loncom/interface/domainprefs.pm 2013/12/23 14:34:35 1.160.6.29 +++ loncom/interface/domainprefs.pm 2013/12/27 16:40:08 1.160.6.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.29 2013/12/23 14:34:35 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.30 2013/12/27 16:40:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -103,8 +103,8 @@ $datatable - HTML containing form eleme In the case of course requests, radio buttons are displayed for each institutional affiliate type (and also default, and _LC_adv) for each of the course types -(official, unofficial and community). In each case the radio buttons allow the -selection of one of four values: +(official, unofficial, community, and textbook). In each case the radio buttons +allow the selection of one of four values: 0, approval, validate, autolimit=N (where N is blank, or a positive integer). which have the following effects: @@ -327,7 +327,9 @@ sub handler { header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, {col1 => 'Setting', - col2 => 'Value'}], + col2 => 'Value'}, + {col1 => 'Available textbooks', + col2 => ''}], }, 'requestauthor' => {text => 'Request authoring space', @@ -418,6 +420,16 @@ sub handler { &common_domprefs_js(). &Apache::loncommon::javascript_array_indexof(); } + if (grep(/^requestcourses$/,@actions)) { + my $javascript_validations; + my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); + $js .= < +$javascript_validations + +$coursebrowserjs +END + } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { # check if domconfig user exists for the domain. @@ -499,7 +511,7 @@ sub process_changes { $output = &modify_rolecolors($r,$dom,$confname,$roles, $lastactref,%domconfig); } elsif ($action eq 'quotas') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'autoenroll') { $output = &modify_autoenroll($dom,$lastactref,%domconfig); } elsif ($action eq 'autoupdate') { @@ -523,9 +535,9 @@ sub process_changes { } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'requestauthor') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); } elsif ($action eq 'usersessions') { @@ -647,7 +659,7 @@ sub print_config_box { - '. + '. &print_usermodification('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; } elsif ($action eq 'coursecategories') { @@ -663,14 +675,25 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
- '. + '. &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); $rowtotal ++; } else { $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); } } elsif ($action eq 'requestcourses') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); + $output .= &print_requestmail($dom,$action,$settings,\$rowtotal). + &print_studentcode($settings,\$rowtotal).' +
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
+ + + + + + + + '. + &print_textbookcourses($dom,$settings,\$rowtotal); } elsif ($action eq 'requestauthor') { $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); } elsif ($action eq 'usersessions') { @@ -1530,7 +1553,7 @@ sub print_quotas { my $typecount = 0; my ($css_class,%titles); if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community'); + @usertools = ('official','unofficial','community','textbook'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); @@ -1976,6 +1999,216 @@ sub print_requestmail { return $datatable; } +sub print_studentcode { + my ($settings,$rowtotal) = @_; + my $rownum = 0; + my ($output,%current); + my @crstypes = ('official','unofficial','community','textbook'); + if (ref($settings->{'uniquecode'}) eq 'HASH') { + foreach my $type (@crstypes) { + $current{$type} = $settings->{'uniquecode'}{$type}; + } + } + $output .= ''. + ''. + ''; + $$rowtotal ++; + return $output; +} + +sub print_textbookcourses { + my ($dom,$settings,$rowtotal) = @_; + my $rownum = 0; + my $css_class; + my $itemcount = 1; + my $maxnum = 0; + my $bookshash; + if (ref($settings) eq 'HASH') { + $bookshash = $settings->{'textbooks'}; + } + my %ordered; + if (ref($bookshash) eq 'HASH') { + foreach my $item (keys(%{$bookshash})) { + if (ref($bookshash->{$item}) eq 'HASH') { + my $num = $bookshash->{$item}{'order'}; + $ordered{$num} = $item; + } + } + } + my $confname = $dom.'-domainconfig'; + my $switchserver = &check_switchserver($dom,$confname); + my $maxnum = scalar(keys(%ordered)); + my $datatable = &textbookcourses_javascript(\%ordered); + if (keys(%ordered)) { + my @items = sort { $a <=> $b } keys(%ordered); + for (my $i=0; $i<@items; $i++) { + $css_class = $itemcount%2?' class="LC_odd_row"':''; + my $key = $ordered{$items[$i]}; + my %coursehash=&Apache::lonnet::coursedescription($key); + my $coursetitle = $coursehash{'description'}; + my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum); + if (ref($bookshash->{$key}) eq 'HASH') { + $subject = $bookshash->{$key}->{'subject'}; + $title = $bookshash->{$key}->{'title'}; + $author = $bookshash->{$key}->{'author'}; + $image = $bookshash->{$key}->{'image'}; + if ($image ne '') { + my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); + my $imagethumb = "$path/tn-".$imagefile; + $imgsrc = ''.&mt('Textbook image').''; + } + } + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"'; + $datatable .= ''. + ''."\n"; + $itemcount ++; + } + } + $css_class = $itemcount%2?' class="LC_odd_row"':''; + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"'; + $datatable .= ''."\n". + ''."\n". + ''."\n"; + $itemcount ++; + return $datatable; +} + +sub textbookcourses_javascript { + my ($textbooks) = @_; + return unless(ref($textbooks) eq 'HASH'); + my $num = scalar(keys(%{$textbooks})); + my @jsarray; + foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) { + push(@jsarray,$textbooks->{$item}); + } + my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n"; + return <<"ENDSCRIPT"; + + +ENDSCRIPT +} + sub print_autoenroll { my ($dom,$settings,$rowtotal) = @_; my $autorun = &Apache::lonnet::auto_run(undef,$dom), @@ -2474,9 +2707,10 @@ sub print_coursedefaults { \%choices,$itemcount); } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,$def_official_credits,$def_unofficial_credits,%curruploadquota); + my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits, + %curruploadquota); my $currusecredits = 0; - my @types = ('official','unofficial','community'); + my @types = ('official','unofficial','community','textbook'); if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; if (ref($settings->{'uploadquota'}) eq 'HASH') { @@ -2487,7 +2721,9 @@ sub print_coursedefaults { if (ref($settings->{'coursecredits'}) eq 'HASH') { $def_official_credits = $settings->{'coursecredits'}->{'official'}; $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; - if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) { + $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'}; + if (($def_official_credits ne '') || ($def_unofficial_credits ne '') || + ($def_textbook_credits ne '')) { $currusecredits = 1; } } @@ -2537,6 +2773,11 @@ sub print_coursedefaults { &mt('Default credits for unofficial courses [_1]', ''). + '
'. + ''. + &mt('Default credits for textbook courses [_1]', + ''). ''."\n"; %defaultchecked = ('coursecredits' => 'off'); @toggles = ('coursecredits'); @@ -3327,6 +3568,7 @@ sub tool_titles { official => 'Official courses (with institutional codes)', unofficial => 'Unofficial courses', community => 'Communities', + textbook => 'Textbook courses', ); return %titles; } @@ -3336,6 +3578,7 @@ sub courserequest_titles { official => 'Official', unofficial => 'Unofficial', community => 'Communities', + textbook => 'Textbook', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -5803,21 +6046,25 @@ sub check_switchserver { } sub modify_quotas { - my ($dom,$action,$lastactref,%domconfig) = @_; + my ($r,$dom,$action,$lastactref,%domconfig) = @_; my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash, - %limithash,$toolregexp,%conditions,$resulttext,%changes); + %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok, + $author_ok,$switchserver,$errors); if ($action eq 'quotas') { $context = 'tools'; } else { $context = $action; } if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community'); + @usertools = ('official','unofficial','community','textbook'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); $toolregexp = join('|',@usertools); %conditions = &courserequest_conditions(); + $confname = $dom.'-domainconfig'; + my $servadm = $r->dir_config('lonAdmEMail'); + ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); } elsif ($context eq 'requestauthor') { @usertools = ('author'); %titles = &authorrequest_titles(); @@ -5856,6 +6103,36 @@ sub modify_quotas { my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify'); @approvalnotify = sort(@approvalnotify); $confhash{'notify'}{'approval'} = join(',',@approvalnotify); + my @crstypes = ('official','unofficial','community','textbook'); + my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode'); + foreach my $type (@hasuniquecode) { + if (grep(/^\Q$type\E$/,@crstypes)) { + $confhash{'uniquecode'}{$type} = 1; + } + } + my ($newbook,@allpos); + if ($context eq 'requestcourses') { + if ($env{'form.addbook'}) { + if (($env{'form.addbook_cnum'} =~ /^$match_courseid$/) && + ($env{'form.addbook_cdom'} =~ /^$match_domain$/)) { + if (&Apache::lonnet::homeserver($env{'form.addbook_cnum'}, + $env{'form.addbook_cdom'}) eq 'no_host') { + $errors .= '
  • '.&mt('Invalid LON-CAPA course for textbook'). + '
  • '; + } else { + $newbook = $env{'form.addbook_cdom'}.'_'.$env{'form.addbook_cnum'}; + my $position = $env{'form.addbook_pos'}; + $position =~ s/\D+//g; + if ($position ne '') { + $allpos[$position] = $newbook; + } + } + } else { + $errors .= '
  • '.&mt('Invalid LON-CAPA course for textbook'). + '
  • '; + } + } + } if (ref($domconfig{$action}) eq 'HASH') { if (ref($domconfig{$action}{'notify'}) eq 'HASH') { if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) { @@ -5866,10 +6143,131 @@ sub modify_quotas { $changes{'notify'}{'approval'} = 1; } } + if (ref($domconfig{$action}{'uniquecode'}) eq 'HASH') { + if (ref($confhash{'uniquecode'}) eq 'HASH') { + foreach my $crstype (keys(%{$domconfig{$action}{'uniquecode'}})) { + unless ($confhash{'uniquecode'}{$crstype}) { + $changes{'uniquecode'} = 1; + } + } + unless ($changes{'uniquecode'}) { + foreach my $crstype (keys(%{$confhash{'uniquecode'}})) { + unless ($domconfig{$action}{'uniquecode'}{$crstype}) { + $changes{'uniquecode'} = 1; + } + } + } + } else { + $changes{'uniquecode'} = 1; + } + } elsif (ref($confhash{'uniquecode'}) eq 'HASH') { + $changes{'uniquecode'} = 1; + } + if ($context eq 'requestcourses') { + if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { + my %deletions; + my @todelete = &Apache::loncommon::get_env_multiple('form.book_del'); + if (@todelete) { + map { $deletions{$_} = 1; } @todelete; + } + my %imgdeletions; + my @todeleteimages = &Apache::loncommon::get_env_multiple('form.book_image_del'); + if (@todeleteimages) { + map { $imgdeletions{$_} = 1; } @todeleteimages; + } + my $maxnum = $env{'form.book_maxnum'}; + for (my $i=0; $i<=$maxnum; $i++) { + my $key = $env{'form.book_id_'.$i}; + if (ref($domconfig{$action}{'textbooks'}{$key}) eq 'HASH') { + if ($deletions{$key}) { + if ($domconfig{$action}{'textbooks'}{$key}{'image'}) { + #FIXME need to obsolete item in RES space + } + next; + } else { + my $newpos = $env{'form.'.$key}; + $newpos =~ s/\D+//g; + foreach my $item ('subject','title','author') { + $confhash{'textbooks'}{$key}{$item} = $env{'form.book_'.$item.'_'.$i}; + if ($domconfig{$action}{'textbooks'}{$key}{$item} ne $confhash{'textbooks'}{$key}{$item}) { + $changes{'textbooks'}{$key} = 1; + } + } + $allpos[$newpos] = $key; + } + if ($imgdeletions{$key}) { + $changes{'textbooks'}{$key} = 1; + #FIXME need to obsolete item in RES space + } elsif ($env{'form.book_image_'.$i.'.filename'}) { + my ($cdom,$cnum) = split(/_/,$key); + my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,'book_image_'.$i, + $cdom,$cnum,$configuserok, + $switchserver,$author_ok); + if ($imgurl) { + $confhash{'textbooks'}{$key}{'image'} = $imgurl; + $changes{'textbooks'}{$key} = 1; + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } + } elsif ($domconfig{$action}{'textbooks'}{$key}{'image'}) { + $confhash{'textbooks'}{$key}{'image'} = + $domconfig{$action}{'textbooks'}{$key}{'image'}; + } + } + } + } + } } else { if ($confhash{'notify'}{'approval'}) { $changes{'notify'}{'approval'} = 1; } + if (ref($confhash{'uniquecode'} eq 'HASH')) { + $changes{'uniquecode'} = 1; + } + } + if ($context eq 'requestcourses') { + if ($newbook) { + $changes{'textbooks'}{$newbook} = 1; + foreach my $item ('subject','title','author') { + $env{'form.addbook_'.$item} =~ s/(`)/'/g; + if ($env{'form.addbook_'.$item}) { + $confhash{'textbooks'}{$newbook}{$item} = $env{'form.addbook_'.$item}; + } + } + if ($env{'form.addbook_image.filename'} ne '') { + my ($cdom,$cnum) = split(/_/,$newbook); + my ($imageurl,$error) = + &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok, + $switchserver,$author_ok); + if ($imageurl) { + $confhash{'textbooks'}{$newbook}{'image'} = $imageurl; + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } + } + } + if (@allpos > 0) { + my $idx = 0; + foreach my $item (@allpos) { + if ($item ne '') { + $confhash{'textbooks'}{$item}{'order'} = $idx; + if (ref($domconfig{$action}) eq 'HASH') { + if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { + if (ref($domconfig{$action}{'textbooks'}{$item}) eq 'HASH') { + if ($domconfig{$action}{'textbooks'}{$item}{'order'} ne $idx) { + $changes{'textbooks'}{$item} = 1; + } + } + } + } + $idx ++; + } + } + } } } else { $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'}; @@ -6011,7 +6409,9 @@ sub modify_quotas { $domdefaults{'requestauthor'} = \%confhash; } else { foreach my $key (keys(%confhash)) { - $domdefaults{$key} = $confhash{$key}; + unless (($context eq 'requestcourses') && ($key eq 'textbooks')) { + $domdefaults{$key} = $confhash{$key}; + } } } @@ -6148,6 +6548,42 @@ sub modify_quotas { } } } + if ($action eq 'requestcourses') { + my @offon = ('off','on'); + if ($changes{'uniquecode'}) { + if (ref($confhash{'uniquecode'}) eq 'HASH') { + my $codestr = join(' ',map{ &mt($_); } sort(keys(%{$confhash{'uniquecode'}}))); + $resulttext .= '
  • '. + &mt('Generation of six character code as course identifier for distribution to students set to on for: [_1].',''.$codestr.''). + '
  • '; + } else { + $resulttext .= '
  • '.&mt('Generation of six character code as course identifier for distribution to students set to off.'). + '
  • '; + } + } + if (ref($changes{'textbooks'}) eq 'HASH') { + $resulttext .= '
  • '.&mt('Available textbooks updated').'
  • '; + } + } $resulttext .= ''; if (keys(%newenv)) { &Apache::lonnet::appenv(\%newenv); @@ -6165,9 +6601,40 @@ sub modify_quotas { $resulttext = ''. &mt('An error occurred: [_1]',$putresult).''; } + if ($errors) { + $resulttext .= '

    '.&mt('The following errors occurred when modifying Textbook settings.'). + '

    '; + } return $resulttext; } +sub process_textbook_image { + my ($r,$dom,$confname,$caller,$cdom,$cnum,$configuserok,$switchserver,$author_ok) = @_; + my $filename = $env{'form.'.$caller.'.filename'}; + my ($error,$url); + my ($width,$height) = (50,50); + if ($configuserok eq 'ok') { + if ($switchserver) { + $error = &mt('Upload of textbook image is not permitted to this server: [_1]', + $switchserver); + } elsif ($author_ok eq 'ok') { + my ($result,$imageurl) = + &publishlogo($r,'upload',$caller,$dom,$confname, + "textbooks/$dom/$cnum/cover",$width,$height); + if ($result eq 'ok') { + $url = $imageurl; + } else { + $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result); + } + } else { + $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok); + } + } else { + $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok); + } + return ($url,$error); +} + sub modify_autoenroll { my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,%changes); @@ -8052,8 +8519,8 @@ sub modify_coursedefaults { my %defaultchecked = ('canuse_pdfforms' => 'off'); my @toggles = ('canuse_pdfforms'); my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', - 'uploadquota_community'); - my @types = ('official','unofficial','community'); + 'uploadquota_community','uploadquota_textbook'); + my @types = ('official','unofficial','community','textbook'); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, @@ -8118,21 +8585,25 @@ sub modify_coursedefaults { } } my $officialcreds = $env{'form.official_credits'}; - $officialcreds =~ s/^[^\d\.]//g; + $officialcreds =~ s/[^\d.]+//g; my $unofficialcreds = $env{'form.unofficial_credits'}; - $unofficialcreds =~ s/^[^\d\.]//g; + $unofficialcreds =~ s/[^\d.]+//g; + my $textbookcreds = $env{'form.textbook_credits'}; + $textbookcreds =~ s/[^\d.]+//g; if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') && ($env{'form.coursecredits'} eq '1')) { $changes{'coursecredits'} = 1; } else { if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) { + ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) || + ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) { $changes{'coursecredits'} = 1; } } $defaultshash{'coursedefaults'}{'coursecredits'} = { official => $officialcreds, unofficial => $unofficialcreds, + textbook => $textbookcreds, } } my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, @@ -8150,6 +8621,8 @@ sub modify_coursedefaults { $defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; $domdefaults{'unofficialcredits'} = $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; + $domdefaults{'textbookcredits'} = + $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'}; } } if ($changes{'uploadquota'}) { @@ -8180,6 +8653,8 @@ sub modify_coursedefaults { $resulttext .= '
  • '.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').''. '
  • '; @@ -8189,12 +8664,14 @@ sub modify_coursedefaults { } elsif ($item eq 'coursecredits') { if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { if (($domdefaults{'officialcredits'} eq '') && - ($domdefaults{'unofficialcredits'} eq '')) { + ($domdefaults{'unofficialcredits'} eq '') && + ($domdefaults{'textbookcredits'} eq '')) { $resulttext .= '
  • '.&mt('Student credits not in use for courses in this domain').'
  • '; } else { $resulttext .= '
  • '.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').''. '
  • '; }
    '.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
    '.&mt('Generate unique six character code as course identifier?').''; + foreach my $type (@crstypes) { + my $check = ' '; + if ($current{$type}) { + $check = ' checked="checked" '; + } + $output .= ''.(' 'x2).' '; + } + $output .= '
    ' + .''.(' 'x2). + ''. + ''.&mt('Subject:').' '. + (' 'x2). + ''.&mt('Title:').' '. + (' 'x2). + ''.&mt('Author(s):').' '. + (' 'x2). + ''.&mt('Thumbnail:'); + if ($image) { + $datatable .= ''. + $imgsrc. + ' '. + ' '.&mt('Replace:').' '; + } + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ' '. + ''.&mt('LON-CAPA course:').' '. + $coursetitle.'
    '."\n". + ''."\n". + ' '."\n". + ''.&mt('Add').''. + ''.&mt('Subject:').' '."\n". + (' 'x2). + ''.&mt('Title:').' '."\n". + (' 'x2). + ''.&mt('Author(s):').' '."\n". + (' 'x2). + ''.&mt('Image:').' '; + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ''."\n". + ''.&mt('LON-CAPA course:').' '. + &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom'). + ''. + &Apache::loncommon::selectcourse_link + ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course'); + '