version 1.160.6.45, 2014/05/05 23:34:42
|
version 1.160.6.46, 2014/05/09 15:23:28
|
Line 369 sub handler {
|
Line 369 sub handler {
|
col2 => 'Value'}, |
col2 => 'Value'}, |
{col1 => 'Available textbooks', |
{col1 => 'Available textbooks', |
col2 => ''}, |
col2 => ''}, |
|
{col1 => 'Available templates', |
|
col2 => ''}, |
{col1 => 'Validation (not official courses)', |
{col1 => 'Validation (not official courses)', |
col2 => 'Value'},], |
col2 => 'Value'},], |
print => \&print_quotas, |
print => \&print_quotas, |
Line 753 sub print_config_box {
|
Line 755 sub print_config_box {
|
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'. |
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'. |
&print_textbookcourses($dom,$settings,\$rowtotal).' |
&textbookcourses_javascript($settings). |
|
&print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).' |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_info_row"> |
|
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td> |
|
<td class="LC_right_item">'.&mt($item->{'header'}->[3]->{'col2'}).'</td> </tr>'. |
|
&print_textbookcourses($dom,'templates',$settings,\$rowtotal).' |
</table> |
</table> |
</td> |
</td> |
</tr> |
</tr> |
Line 761 sub print_config_box {
|
Line 774 sub print_config_box {
|
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item"'.$colspan.' valign="top">'.&mt($item->{'header'}->[3]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.' valign="top">'.&mt($item->{'header'}->[4]->{'col1'}).'</td> |
<td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[3]->{'col2'}).'</td> |
<td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[4]->{'col2'}).'</td> |
</tr>'. |
</tr>'. |
&print_validation_rows('requestcourses',$dom,$settings,\$rowtotal); |
&print_validation_rows('requestcourses',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'requestauthor') { |
} elsif ($action eq 'requestauthor') { |
Line 2075 sub print_studentcode {
|
Line 2088 sub print_studentcode {
|
} |
} |
|
|
sub print_textbookcourses { |
sub print_textbookcourses { |
my ($dom,$settings,$rowtotal) = @_; |
my ($dom,$type,$settings,$rowtotal) = @_; |
my $rownum = 0; |
my $rownum = 0; |
my $css_class; |
my $css_class; |
my $itemcount = 1; |
my $itemcount = 1; |
my $maxnum = 0; |
my $maxnum = 0; |
my $bookshash; |
my $bookshash; |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
$bookshash = $settings->{'textbooks'}; |
$bookshash = $settings->{$type}; |
} |
} |
my %ordered; |
my %ordered; |
if (ref($bookshash) eq 'HASH') { |
if (ref($bookshash) eq 'HASH') { |
Line 2095 sub print_textbookcourses {
|
Line 2108 sub print_textbookcourses {
|
} |
} |
my $confname = $dom.'-domainconfig'; |
my $confname = $dom.'-domainconfig'; |
my $switchserver = &check_switchserver($dom,$confname); |
my $switchserver = &check_switchserver($dom,$confname); |
$maxnum = scalar(keys(%ordered)); |
my $maxnum = scalar(keys(%ordered)); |
my $datatable = &textbookcourses_javascript(\%ordered); |
my $datatable; |
if (keys(%ordered)) { |
if (keys(%ordered)) { |
my @items = sort { $a <=> $b } keys(%ordered); |
my @items = sort { $a <=> $b } keys(%ordered); |
for (my $i=0; $i<@items; $i++) { |
for (my $i=0; $i<@items; $i++) { |
Line 2108 sub print_textbookcourses {
|
Line 2121 sub print_textbookcourses {
|
if (ref($bookshash->{$key}) eq 'HASH') { |
if (ref($bookshash->{$key}) eq 'HASH') { |
$subject = $bookshash->{$key}->{'subject'}; |
$subject = $bookshash->{$key}->{'subject'}; |
$title = $bookshash->{$key}->{'title'}; |
$title = $bookshash->{$key}->{'title'}; |
$author = $bookshash->{$key}->{'author'}; |
if ($type eq 'textbooks') { |
$image = $bookshash->{$key}->{'image'}; |
$author = $bookshash->{$key}->{'author'}; |
if ($image ne '') { |
$image = $bookshash->{$key}->{'image'}; |
my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); |
if ($image ne '') { |
my $imagethumb = "$path/tn-".$imagefile; |
my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); |
$imgsrc = '<img src="'.$imagethumb.'" alt="'.&mt('Textbook image').'" />'; |
my $imagethumb = "$path/tn-".$imagefile; |
|
$imgsrc = '<img src="'.$imagethumb.'" alt="'.&mt('Textbook image').'" />'; |
|
} |
} |
} |
} |
} |
my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"'; |
my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"'; |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
.'<select name="'.$key.'"'.$chgstr.'>'; |
.'<select name="'.$type.'_'.$key.'"'.$chgstr.'>'; |
for (my $k=0; $k<=$maxnum; $k++) { |
for (my $k=0; $k<=$maxnum; $k++) { |
my $vpos = $k+1; |
my $vpos = $k+1; |
my $selstr; |
my $selstr; |
Line 2128 sub print_textbookcourses {
|
Line 2143 sub print_textbookcourses {
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
} |
} |
$datatable .= '</select>'.(' 'x2). |
$datatable .= '</select>'.(' 'x2). |
'<label><input type="checkbox" name="book_del" value="'.$key.'" />'. |
'<label><input type="checkbox" name="'.$type.'_del" value="'.$key.'" />'. |
&mt('Delete?').'</label></span></td>'. |
&mt('Delete?').'</label></span></td>'. |
'<td colspan="2">'. |
'<td colspan="2">'. |
'<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="book_subject_'.$i.'" value="'.$subject.'" /></span> '. |
'<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="'.$type.'_subject_'.$i.'" value="'.$subject.'" /></span> '. |
(' 'x2). |
|
'<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="book_title_'.$i.'" value="'.$title.'" /></span> '. |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="book_author_'.$i.'" value="'.$author.'" /></span> '. |
|
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.&mt('Thumbnail:'); |
'<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="'.$type.'_title_'.$i.'" value="'.$title.'" /></span> '; |
if ($image) { |
if ($type eq 'textbooks') { |
$datatable .= '<span class="LC_nobreak">'. |
$datatable .= (' 'x2). |
$imgsrc. |
'<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="'.$type.'_author_'.$i.'" value="'.$author.'" /></span> '. |
'<label><input type="checkbox" name="book_image_del"'. |
(' 'x2). |
' value="'.$key.'" />'.&mt('Delete?').'</label></span> '. |
'<span class="LC_nobreak">'.&mt('Thumbnail:'); |
'<span class="LC_nobreak"> '.&mt('Replace:').' '; |
if ($image) { |
} |
$datatable .= '<span class="LC_nobreak">'. |
if ($switchserver) { |
$imgsrc. |
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
'<label><input type="checkbox" name="'.$type.'_image_del"'. |
} else { |
' value="'.$key.'" />'.&mt('Delete?').'</label></span> '. |
$datatable .= '<input type="file" name="book_image_'.$i.'" value="" />'; |
'<span class="LC_nobreak"> '.&mt('Replace:').' '; |
|
} |
|
if ($switchserver) { |
|
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
|
} else { |
|
$datatable .= '<input type="file" name="'.$type.'_image_'.$i.'" value="" />'; |
|
} |
} |
} |
$datatable .= '<input type="hidden" name="book_id_'.$i.'" value="'.$key.'" /></span> '. |
$datatable .= '<input type="hidden" name="'.$type.'_id_'.$i.'" value="'.$type.'_'.$key.'" /></span> '. |
'<span class="LC_nobreak">'.&mt('LON-CAPA course:').' '. |
'<span class="LC_nobreak">'.&mt('LON-CAPA course:').' '. |
$coursetitle.'</span></td></tr>'."\n"; |
$coursetitle.'</span></td></tr>'."\n"; |
$itemcount ++; |
$itemcount ++; |
} |
} |
} |
} |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"'; |
my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"'; |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
'<input type="hidden" name="book_maxnum" value="'.$maxnum.'" />'."\n". |
'<input type="hidden" name="'.$type.'_maxnum" value="'.$maxnum.'" />'."\n". |
'<select name="addbook_pos"'.$chgstr.'>'; |
'<select name="'.$type.'_addbook_pos"'.$chgstr.'>'; |
for (my $k=0; $k<$maxnum+1; $k++) { |
for (my $k=0; $k<$maxnum+1; $k++) { |
my $vpos = $k+1; |
my $vpos = $k+1; |
my $selstr; |
my $selstr; |
Line 2170 sub print_textbookcourses {
|
Line 2187 sub print_textbookcourses {
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
} |
} |
$datatable .= '</select> '."\n". |
$datatable .= '</select> '."\n". |
'<input type="checkbox" name="addbook" value="1" />'.&mt('Add').'</td>'."\n". |
'<input type="checkbox" name="'.$type.'_addbook" value="1" />'.&mt('Add').'</td>'."\n". |
'<td colspan="2">'. |
'<td colspan="2">'. |
'<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="addbook_subject" value="" /></span> '."\n". |
'<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="'.$type.'_addbook_subject" value="" /></span> '."\n". |
(' 'x2). |
|
'<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="addbook_title" value="" /></span> '."\n". |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="addbook_author" value="" /></span> '."\n". |
|
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.&mt('Image:').' '; |
'<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="'.$type.'_addbook_title" value="" /></span> '."\n". |
if ($switchserver) { |
(' 'x2); |
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
if ($type eq 'textbooks') { |
} else { |
$datatable .= '<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="'.$type.'_addbook_author" value="" /></span> '."\n". |
$datatable .= '<input type="file" name="addbook_image" value="" />'; |
(' 'x2). |
|
'<span class="LC_nobreak">'.&mt('Image:').' '; |
|
if ($switchserver) { |
|
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
|
} else { |
|
$datatable .= '<input type="file" name="'.$type.'_addbook_image" value="" />'; |
|
} |
} |
} |
$datatable .= '</span>'."\n". |
$datatable .= '</span>'."\n". |
'<span class="LC_nobreak">'.&mt('LON-CAPA course:').' '. |
'<span class="LC_nobreak">'.&mt('LON-CAPA course:').' '. |
&Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom'). |
&Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). |
'<input type="text" size="25" name="addbook_cnum" value="" />'. |
'<input type="text" size="25" name="'.$type.'_addbook_cnum" value="" />'. |
&Apache::loncommon::selectcourse_link |
&Apache::loncommon::selectcourse_link |
('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course'); |
('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'); |
'</span></td>'."\n". |
'</span></td>'."\n". |
'</tr>'."\n"; |
'</tr>'."\n"; |
$itemcount ++; |
$itemcount ++; |
Line 2197 sub print_textbookcourses {
|
Line 2216 sub print_textbookcourses {
|
} |
} |
|
|
sub textbookcourses_javascript { |
sub textbookcourses_javascript { |
my ($textbooks) = @_; |
my ($settings) = @_; |
return unless(ref($textbooks) eq 'HASH'); |
return unless(ref($settings) eq 'HASH'); |
my $num = scalar(keys(%{$textbooks})); |
my (%ordered,%total,%jstext); |
my @jsarray; |
foreach my $type ('textbooks','templates') { |
foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) { |
$total{$type} = 0; |
push(@jsarray,$textbooks->{$item}); |
if (ref($settings->{$type}) eq 'HASH') { |
|
foreach my $item (keys(%{$settings->{$type}})) { |
|
if (ref($settings->{$type}->{$item}) eq 'HASH') { |
|
my $num = $settings->{$type}->{$item}{'order'}; |
|
$ordered{$type}{$num} = $item; |
|
} |
|
} |
|
$total{$type} = scalar(keys(%{$settings->{$type}})); |
|
} |
|
my @jsarray = (); |
|
foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) { |
|
push(@jsarray,$ordered{$type}{$item}); |
|
} |
|
$jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n"; |
} |
} |
my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n"; |
|
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
function reorderBooks(form,item) { |
function reorderBooks(form,item,caller) { |
var changedVal; |
var changedVal; |
$jstext |
$jstext{'textbooks'}; |
var newpos = 'addbook_pos'; |
$jstext{'templates'}; |
|
var newpos; |
|
var maxh; |
|
if (caller == 'textbooks') { |
|
newpos = 'textbooks_addbook_pos'; |
|
maxh = 1 + $total{'textbooks'}; |
|
} else { |
|
newpos = 'templates_addbook_pos'; |
|
maxh = 1 + $total{'templates'}; |
|
} |
var current = new Array; |
var current = new Array; |
var maxh = 1 + $num; |
|
var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value; |
var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value; |
if (item == newpos) { |
if (item == newpos) { |
changedVal = newitemVal; |
changedVal = newitemVal; |
Line 2221 $jstext
|
Line 2260 $jstext
|
changedVal = form.elements[item].options[form.elements[item].selectedIndex].value; |
changedVal = form.elements[item].options[form.elements[item].selectedIndex].value; |
current[newitemVal] = newpos; |
current[newitemVal] = newpos; |
} |
} |
for (var i=0; i<textbooks.length; i++) { |
if (caller == 'textbooks') { |
var elementName = textbooks[i]; |
for (var i=0; i<textbooks.length; i++) { |
if (elementName != item) { |
var elementName = 'textbooks_'+textbooks[i]; |
if (form.elements[elementName]) { |
if (elementName != item) { |
var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value; |
if (form.elements[elementName]) { |
current[currVal] = elementName; |
var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value; |
|
current[currVal] = elementName; |
|
} |
|
} |
|
} |
|
} |
|
if (caller == 'templates') { |
|
for (var i=0; i<templates.length; i++) { |
|
var elementName = 'templates_'+templates[i]; |
|
if (elementName != item) { |
|
if (form.elements[elementName]) { |
|
var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value; |
|
current[currVal] = elementName; |
|
} |
} |
} |
} |
} |
} |
} |
Line 6812 sub modify_quotas {
|
Line 6864 sub modify_quotas {
|
$confhash{'uniquecode'}{$type} = 1; |
$confhash{'uniquecode'}{$type} = 1; |
} |
} |
} |
} |
my ($newbook,@allpos); |
my (%newbook,%allpos); |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
if ($env{'form.addbook'}) { |
foreach my $type ('textbooks','templates') { |
if (($env{'form.addbook_cnum'} =~ /^$match_courseid$/) && |
@{$allpos{$type}} = (); |
($env{'form.addbook_cdom'} =~ /^$match_domain$/)) { |
my $invalid; |
if (&Apache::lonnet::homeserver($env{'form.addbook_cnum'}, |
if ($type eq 'textbooks') { |
$env{'form.addbook_cdom'}) eq 'no_host') { |
$invalid = &mt('Invalid LON-CAPA course for textbook'); |
$errors .= '<li><span class="LC_error">'.&mt('Invalid LON-CAPA course for textbook'). |
} else { |
'</span></li>'; |
$invalid = &mt('Invalid LON-CAPA course for template'); |
} else { |
} |
$newbook = $env{'form.addbook_cdom'}.'_'.$env{'form.addbook_cnum'}; |
if ($env{'form.'.$type.'_addbook'}) { |
my $position = $env{'form.addbook_pos'}; |
if (($env{'form.'.$type.'_addbook_cnum'} =~ /^$match_courseid$/) && |
$position =~ s/\D+//g; |
($env{'form.'.$type.'_addbook_cdom'} =~ /^$match_domain$/)) { |
if ($position ne '') { |
if (&Apache::lonnet::homeserver($env{'form.'.$type.'_addbook_cnum'}, |
$allpos[$position] = $newbook; |
$env{'form.'.$type.'_addbook_cdom'}) eq 'no_host') { |
|
$errors .= '<li><span class="LC_error">'.$invalid.'</span></li>'; |
|
} else { |
|
$newbook{$type} = $env{'form.'.$type.'_addbook_cdom'}.'_'.$env{'form.'.$type.'_addbook_cnum'}; |
|
my $position = $env{'form.'.$type.'_addbook_pos'}; |
|
$position =~ s/\D+//g; |
|
if ($position ne '') { |
|
$allpos{$type}[$position] = $newbook{$type}; |
|
} |
} |
} |
|
} else { |
|
$errors .= '<li><span class="LC_error">'.$invalid.'</span></li>'; |
} |
} |
} else { |
|
$errors .= '<li><span class="LC_error">'.&mt('Invalid LON-CAPA course for textbook'). |
|
'</span></li>'; |
|
} |
} |
} |
} |
|
|
} |
} |
if (ref($domconfig{$action}) eq 'HASH') { |
if (ref($domconfig{$action}) eq 'HASH') { |
if (ref($domconfig{$action}{'notify'}) eq 'HASH') { |
if (ref($domconfig{$action}{'notify'}) eq 'HASH') { |
Line 6867 sub modify_quotas {
|
Line 6925 sub modify_quotas {
|
$changes{'uniquecode'} = 1; |
$changes{'uniquecode'} = 1; |
} |
} |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { |
foreach my $type ('textbooks','templates') { |
my %deletions; |
if (ref($domconfig{$action}{$type}) eq 'HASH') { |
my @todelete = &Apache::loncommon::get_env_multiple('form.book_del'); |
my %deletions; |
if (@todelete) { |
my @todelete = &Apache::loncommon::get_env_multiple('form.'.$type.'_del'); |
map { $deletions{$_} = 1; } @todelete; |
if (@todelete) { |
} |
map { $deletions{$_} = 1; } @todelete; |
my %imgdeletions; |
} |
my @todeleteimages = &Apache::loncommon::get_env_multiple('form.book_image_del'); |
my %imgdeletions; |
if (@todeleteimages) { |
my @todeleteimages = &Apache::loncommon::get_env_multiple('form.'.$type.'_image_del'); |
map { $imgdeletions{$_} = 1; } @todeleteimages; |
if (@todeleteimages) { |
} |
map { $imgdeletions{$_} = 1; } @todeleteimages; |
my $maxnum = $env{'form.book_maxnum'}; |
} |
for (my $i=0; $i<=$maxnum; $i++) { |
my $maxnum = $env{'form.'.$type.'_maxnum'}; |
my $key = $env{'form.book_id_'.$i}; |
for (my $i=0; $i<=$maxnum; $i++) { |
if (ref($domconfig{$action}{'textbooks'}{$key}) eq 'HASH') { |
my $itemid = $env{'form.'.$type.'_id_'.$i}; |
if ($deletions{$key}) { |
my ($key) = ($itemid =~ /^\Q$type\E_(\w+)$/); |
if ($domconfig{$action}{'textbooks'}{$key}{'image'}) { |
if (ref($domconfig{$action}{$type}{$key}) eq 'HASH') { |
#FIXME need to obsolete item in RES space |
if ($deletions{$key}) { |
} |
if ($domconfig{$action}{$type}{$key}{'image'}) { |
next; |
#FIXME need to obsolete item in RES space |
} 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; |
|
} |
} |
|
next; |
|
} else { |
|
my $newpos = $env{'form.'.$itemid}; |
|
$newpos =~ s/\D+//g; |
|
foreach my $item ('subject','title','author') { |
|
next if (($item eq 'author') && ($type eq 'templates')); |
|
$confhash{$type}{$key}{$item} = $env{'form.'.$type.'_'.$item.'_'.$i}; |
|
if ($domconfig{$action}{$type}{$key}{$item} ne $confhash{$type}{$key}{$item}) { |
|
$changes{$type}{$key} = 1; |
|
} |
|
} |
|
$allpos{$type}[$newpos] = $key; |
} |
} |
$allpos[$newpos] = $key; |
if ($imgdeletions{$key}) { |
} |
$changes{$type}{$key} = 1; |
if ($imgdeletions{$key}) { |
#FIXME need to obsolete item in RES space |
$changes{'textbooks'}{$key} = 1; |
} elsif ($env{'form.'.$type.'_image_'.$i.'.filename'}) { |
#FIXME need to obsolete item in RES space |
my ($cdom,$cnum) = split(/_/,$key); |
} elsif ($env{'form.book_image_'.$i.'.filename'}) { |
my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i, |
my ($cdom,$cnum) = split(/_/,$key); |
$cdom,$cnum,$type,$configuserok, |
my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,'book_image_'.$i, |
$switchserver,$author_ok); |
$cdom,$cnum,$configuserok, |
if ($imgurl) { |
$switchserver,$author_ok); |
$confhash{$type}{$key}{'image'} = $imgurl; |
if ($imgurl) { |
$changes{$type}{$key} = 1; |
$confhash{'textbooks'}{$key}{'image'} = $imgurl; |
} |
$changes{'textbooks'}{$key} = 1; |
if ($error) { |
|
&Apache::lonnet::logthis($error); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} elsif ($domconfig{$action}{$type}{$key}{'image'}) { |
|
$confhash{$type}{$key}{'image'} = |
|
$domconfig{$action}{$type}{$key}{'image'}; |
} |
} |
if ($error) { |
|
&Apache::lonnet::logthis($error); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} elsif ($domconfig{$action}{'textbooks'}{$key}{'image'}) { |
|
$confhash{'textbooks'}{$key}{'image'} = |
|
$domconfig{$action}{'textbooks'}{$key}{'image'}; |
|
} |
} |
} |
} |
} |
} |
Line 6931 sub modify_quotas {
|
Line 6993 sub modify_quotas {
|
} |
} |
} |
} |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
if ($newbook) { |
foreach my $type ('textbooks','templates') { |
$changes{'textbooks'}{$newbook} = 1; |
if ($newbook{$type}) { |
foreach my $item ('subject','title','author') { |
$changes{$type}{$newbook{$type}} = 1; |
$env{'form.addbook_'.$item} =~ s/(`)/'/g; |
foreach my $item ('subject','title','author') { |
if ($env{'form.addbook_'.$item}) { |
next if (($item eq 'author') && ($type eq 'template')); |
$confhash{'textbooks'}{$newbook}{$item} = $env{'form.addbook_'.$item}; |
$env{'form.'.$type.'_addbook_'.$item} =~ s/(`)/'/g; |
} |
if ($env{'form.'.$type.'_addbook_'.$item}) { |
} |
$confhash{$type}{$newbook{$type}}{$item} = $env{'form.'.$type.'_addbook_'.$item}; |
if ($env{'form.addbook_image.filename'} ne '') { |
} |
my ($cdom,$cnum) = split(/_/,$newbook); |
} |
my ($imageurl,$error) = |
if ($type eq 'textbooks') { |
&process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok, |
if ($env{'form.'.$type.'_addbook_image.filename'} ne '') { |
$switchserver,$author_ok); |
my ($cdom,$cnum) = split(/_/,$newbook{$type}); |
if ($imageurl) { |
my ($imageurl,$error) = |
$confhash{'textbooks'}{$newbook}{'image'} = $imageurl; |
&process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type, |
} |
$configuserok,$switchserver,$author_ok); |
if ($error) { |
if ($imageurl) { |
&Apache::lonnet::logthis($error); |
$confhash{$type}{$newbook{$type}}{'image'} = $imageurl; |
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
} |
|
if ($error) { |
|
&Apache::lonnet::logthis($error); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} |
} |
} |
} |
} |
} |
if (@{$allpos{$type}} > 0) { |
if (@allpos > 0) { |
my $idx = 0; |
my $idx = 0; |
foreach my $item (@{$allpos{$type}}) { |
foreach my $item (@allpos) { |
if ($item ne '') { |
if ($item ne '') { |
$confhash{$type}{$item}{'order'} = $idx; |
$confhash{'textbooks'}{$item}{'order'} = $idx; |
if (ref($domconfig{$action}) eq 'HASH') { |
if (ref($domconfig{$action}) eq 'HASH') { |
if (ref($domconfig{$action}{$type}) eq 'HASH') { |
if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { |
if (ref($domconfig{$action}{$type}{$item}) eq 'HASH') { |
if (ref($domconfig{$action}{'textbooks'}{$item}) eq 'HASH') { |
if ($domconfig{$action}{$type}{$item}{'order'} ne $idx) { |
if ($domconfig{$action}{'textbooks'}{$item}{'order'} ne $idx) { |
$changes{$type}{$item} = 1; |
$changes{'textbooks'}{$item} = 1; |
} |
} |
} |
} |
} |
} |
} |
|
$idx ++; |
} |
} |
$idx ++; |
|
} |
} |
} |
} |
} |
} |
Line 7184 sub modify_quotas {
|
Line 7251 sub modify_quotas {
|
$domdefaults{'requestauthor'} = \%confhash; |
$domdefaults{'requestauthor'} = \%confhash; |
} else { |
} else { |
foreach my $key (keys(%confhash)) { |
foreach my $key (keys(%confhash)) { |
unless (($context eq 'requestcourses') && ($key eq 'textbooks')) { |
unless (($context eq 'requestcourses') && (($key eq 'textbooks') || ($key eq 'templates'))) { |
$domdefaults{$key} = $confhash{$key}; |
$domdefaults{$key} = $confhash{$key}; |
} |
} |
} |
} |
Line 7336 sub modify_quotas {
|
Line 7403 sub modify_quotas {
|
'</li>'; |
'</li>'; |
} |
} |
} |
} |
if (ref($changes{'textbooks'}) eq 'HASH') { |
foreach my $type ('textbooks','templates') { |
$resulttext .= '<li>'.&mt('Available textbooks updated').'<ul>'; |
if (ref($changes{$type}) eq 'HASH') { |
foreach my $key (sort(keys(%{$changes{'textbooks'}}))) { |
$resulttext .= '<li>'.&mt("Available $type updated").'<ul>'; |
my %coursehash = &Apache::lonnet::coursedescription($key); |
foreach my $key (sort(keys(%{$changes{$type}}))) { |
my $coursetitle = $coursehash{'description'}; |
my %coursehash = &Apache::lonnet::coursedescription($key); |
my $position = $confhash{'textbooks'}{$key}{'order'} + 1; |
my $coursetitle = $coursehash{'description'}; |
$resulttext .= '<li>'; |
my $position = $confhash{$type}{$key}{'order'} + 1; |
foreach my $item ('subject','title','author') { |
$resulttext .= '<li>'; |
my $name = $item.':'; |
foreach my $item ('subject','title','author') { |
$name =~ s/^(\w)/\U$1/; |
next if (($item eq 'author') && ($type eq 'templates')); |
$resulttext .= &mt($name).' '.$confhash{'textbooks'}{$key}{$item}.'<br />'; |
my $name = $item.':'; |
} |
$name =~ s/^(\w)/\U$1/; |
$resulttext .= ' '.&mt('Order: [_1]',$position).'<br />'; |
$resulttext .= &mt($name).' '.$confhash{$type}{$key}{$item}.'<br />'; |
if ($confhash{'textbooks'}{$key}{'image'}) { |
} |
$resulttext .= ' '.&mt('Image: [_1]', |
$resulttext .= ' '.&mt('Order: [_1]',$position).'<br />'; |
'<img src="'.$confhash{'textbooks'}{$key}{'image'}.'"'. |
if ($type eq 'textbooks') { |
' alt="Textbook cover" />').'<br />'; |
if ($confhash{$type}{$key}{'image'}) { |
|
$resulttext .= ' '.&mt('Image: [_1]', |
|
'<img src="'.$confhash{$type}{$key}{'image'}.'"'. |
|
' alt="Textbook cover" />').'<br />'; |
|
} |
|
} |
|
$resulttext .= ' '.&mt('LON-CAPA Course: [_1]',$coursetitle).'</li>'; |
} |
} |
$resulttext .= ' '.&mt('LON-CAPA Course: [_1]',$coursetitle).'</li>'; |
$resulttext .= '</ul></li>'; |
} |
} |
$resulttext .= '</ul></li>'; |
|
} |
} |
if (ref($changes{'validation'}) eq 'HASH') { |
if (ref($changes{'validation'}) eq 'HASH') { |
if ((ref($validationitemsref) eq 'ARRAY') && (ref($validationnamesref) eq 'HASH')) { |
if ((ref($validationitemsref) eq 'ARRAY') && (ref($validationnamesref) eq 'HASH')) { |
Line 7404 sub modify_quotas {
|
Line 7476 sub modify_quotas {
|
} |
} |
|
|
sub process_textbook_image { |
sub process_textbook_image { |
my ($r,$dom,$confname,$caller,$cdom,$cnum,$configuserok,$switchserver,$author_ok) = @_; |
my ($r,$dom,$confname,$caller,$cdom,$cnum,$type,$configuserok,$switchserver,$author_ok) = @_; |
my $filename = $env{'form.'.$caller.'.filename'}; |
my $filename = $env{'form.'.$caller.'.filename'}; |
my ($error,$url); |
my ($error,$url); |
my ($width,$height) = (50,50); |
my ($width,$height) = (50,50); |
Line 7415 sub process_textbook_image {
|
Line 7487 sub process_textbook_image {
|
} elsif ($author_ok eq 'ok') { |
} elsif ($author_ok eq 'ok') { |
my ($result,$imageurl) = |
my ($result,$imageurl) = |
&publishlogo($r,'upload',$caller,$dom,$confname, |
&publishlogo($r,'upload',$caller,$dom,$confname, |
"textbooks/$dom/$cnum/cover",$width,$height); |
"$type/$dom/$cnum/cover",$width,$height); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$url = $imageurl; |
$url = $imageurl; |
} else { |
} else { |