version 1.119, 2009/11/16 04:03:05
|
version 1.120, 2009/11/23 21:45:18
|
Line 303 sub handler {
|
Line 303 sub handler {
|
col2 => 'Value'}], |
col2 => 'Value'}], |
}, |
}, |
'coursecategories' => |
'coursecategories' => |
{ text => 'Cataloging of courses', |
{ text => 'Cataloging of courses/communities', |
help => 'Domain_Configuration_Cataloging_Courses', |
help => 'Domain_Configuration_Cataloging_Courses', |
header => [{col1 => 'Category settings', |
header => [{col1 => 'Category settings', |
col2 => '',}, |
col2 => '',}, |
Line 325 sub handler {
|
Line 325 sub handler {
|
header => [{col1 => 'Setting', |
header => [{col1 => 'Setting', |
col2 => 'Value',}], |
col2 => 'Value',}], |
}, |
}, |
|
'privacy' => |
|
{text => 'User Privacy', |
|
help => 'Domain_Configuration_User_Privacy', |
|
header => [{col1 => 'Setting', |
|
col2 => 'Value',}], |
|
}, |
); |
); |
my %servers = &dom_servers($dom); |
my %servers = &dom_servers($dom); |
if (keys(%servers) > 1) { |
if (keys(%servers) > 1) { |
Line 2595 sub print_coursecategories {
|
Line 2601 sub print_coursecategories {
|
my $toggle_cats_dom = ' checked="checked" '; |
my $toggle_cats_dom = ' checked="checked" '; |
my $can_cat_crs = ' '; |
my $can_cat_crs = ' '; |
my $can_cat_dom = ' checked="checked" '; |
my $can_cat_dom = ' checked="checked" '; |
|
my $toggle_catscomm_comm = ' '; |
|
my $toggle_catscomm_dom = ' checked="checked" '; |
|
my $can_catcomm_comm = ' '; |
|
my $can_catcomm_dom = ' checked="checked" '; |
|
|
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if ($settings->{'togglecats'} eq 'crs') { |
if ($settings->{'togglecats'} eq 'crs') { |
$toggle_cats_crs = $toggle_cats_dom; |
$toggle_cats_crs = $toggle_cats_dom; |
Line 2604 sub print_coursecategories {
|
Line 2615 sub print_coursecategories {
|
$can_cat_crs = $can_cat_dom; |
$can_cat_crs = $can_cat_dom; |
$can_cat_dom = ' '; |
$can_cat_dom = ' '; |
} |
} |
|
if ($settings->{'togglecatscomm'} eq 'comm') { |
|
$toggle_catscomm_comm = $toggle_catscomm_dom; |
|
$toggle_catscomm_dom = ' '; |
|
} |
|
if ($settings->{'categorizecomm'} eq 'comm') { |
|
$can_catcomm_comm = $can_catcomm_dom; |
|
$can_catcomm_dom = ' '; |
|
} |
} |
} |
my %title = &Apache::lonlocal::texthash ( |
my %title = &Apache::lonlocal::texthash ( |
togglecats => 'Show/Hide a course in the catalog', |
togglecats => 'Show/Hide a course in catalog', |
categorize => 'Assign a category to a course', |
togglecatscomm => 'Show/Hide a community in catalog', |
|
categorize => 'Assign a category to a course', |
|
categorizecomm => 'Assign a category to a community', |
); |
); |
my %level = &Apache::lonlocal::texthash ( |
my %level = &Apache::lonlocal::texthash ( |
dom => 'Set in "Modify Course" (Domain)', |
dom => 'Set in Domain', |
crs => 'Set in "Modify Parameters" (Course)', |
crs => 'Set in Course', |
|
comm => 'Set in Community', |
); |
); |
$datatable = '<tr class="LC_odd_row">'. |
$datatable = '<tr class="LC_odd_row">'. |
'<td>'.$title{'togglecats'}.'</td>'. |
'<td>'.$title{'togglecats'}.'</td>'. |
Line 2627 sub print_coursecategories {
|
Line 2649 sub print_coursecategories {
|
$can_cat_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
$can_cat_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
'<label><input type="radio" name="categorize"'. |
'<label><input type="radio" name="categorize"'. |
$can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'. |
$can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'. |
|
'</tr><tr class="LC_odd_row">'. |
|
'<td>'.$title{'togglecatscomm'}.'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="togglecatscomm"'. |
|
$toggle_catscomm_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
|
'<label><input type="radio" name="togglecatscomm"'. |
|
$toggle_catscomm_comm.' value="comm" />'.$level{'comm'}.'</label></span></td>'. |
|
'</tr><tr>'. |
|
'<td>'.$title{'categorizecomm'}.'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak">'. |
|
'<label><input type="radio" name="categorizecomm"'. |
|
$can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
|
'<label><input type="radio" name="categorizecomm"'. |
|
$can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'. |
'</tr>'; |
'</tr>'; |
$$rowtotal += 2; |
$$rowtotal += 4; |
} else { |
} else { |
my $css_class; |
my $css_class; |
my $itemcount = 1; |
my $itemcount = 1; |
Line 2650 sub print_coursecategories {
|
Line 2686 sub print_coursecategories {
|
if (ref($cats[0]) eq 'ARRAY') { |
if (ref($cats[0]) eq 'ARRAY') { |
my $numtop = @{$cats[0]}; |
my $numtop = @{$cats[0]}; |
my $maxnum = $numtop; |
my $maxnum = $numtop; |
if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) { |
my %default_names = ( |
|
instcode => &mt('Official courses'), |
|
communities => &mt('Communities'), |
|
); |
|
|
|
if ((!grep(/^instcode$/,@{$cats[0]})) || |
|
($cathash->{'instcode::0'} eq '') || |
|
(!grep(/^communities$/,@{$cats[0]})) || |
|
($cathash->{'communities::0'} eq '')) { |
$maxnum ++; |
$maxnum ++; |
} |
} |
my $lastidx; |
my $lastidx; |
Line 2671 sub print_coursecategories {
|
Line 2715 sub print_coursecategories {
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
} |
} |
$datatable .= '</select></td><td>'; |
$datatable .= '</select></td><td>'; |
if ($parent eq 'instcode') { |
if ($parent eq 'instcode' || $parent eq 'communities') { |
$datatable .= '<span class="LC_nobreak">'.&mt('Official courses') |
$datatable .= '<span class="LC_nobreak">' |
.'</span><br /><span class="LC_nobreak">(' |
.$default_names{$parent}.'</span>'; |
.&mt('with institutional codes').')</span></td>' |
if ($parent eq 'instcode') { |
.'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />' |
$datatable .= '<br /><span class="LC_nobreak">(' |
.&mt('Display').'</label> ' |
.&mt('with institutional codes') |
.'<label><input type="radio" name="instcode" value="0" />' |
.')</span></td><td'.$colattrib.'>'; |
.&mt('Do not display').'</label></span></td>'; |
} else { |
|
$datatable .= '<table><tr><td>'; |
|
} |
|
$datatable .= '<span class="LC_nobreak">' |
|
.'<label><input type="radio" name="' |
|
.$parent.'" value="1" checked="checked" />' |
|
.&mt('Display').'</label>'; |
|
if ($parent eq 'instcode') { |
|
$datatable .= ' '; |
|
} else { |
|
$datatable .= '</span></td></tr><tr><td>' |
|
.'<span class="LC_nobreak">'; |
|
} |
|
$datatable .= '<label><input type="radio" name="' |
|
.$parent.'" value="0" />' |
|
.&mt('Do not display').'</label></span>'; |
|
if ($parent eq 'communities') { |
|
$datatable .= '</td></tr></table>'; |
|
} |
|
$datatable .= '</td>'; |
} else { |
} else { |
$datatable .= $parent |
$datatable .= $parent |
.' <label><input type="checkbox" name="deletecategory" ' |
.' <label><input type="checkbox" name="deletecategory" ' |
Line 2706 sub print_coursecategories {
|
Line 2769 sub print_coursecategories {
|
.'<input type="text" size="20" name="addcategory_name" value="" /></td>' |
.'<input type="text" size="20" name="addcategory_name" value="" /></td>' |
.'</tr>'."\n"; |
.'</tr>'."\n"; |
$itemcount ++; |
$itemcount ++; |
if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) { |
foreach my $default ('instcode','communities') { |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) { |
my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"'; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'. |
my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"'; |
'<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>'; |
$datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'. |
for (my $k=0; $k<=$maxnum; $k++) { |
'<span class="LC_nobreak"><select name="'.$default.'_pos"'.$chgstr.'>'; |
my $vpos = $k+1; |
for (my $k=0; $k<=$maxnum; $k++) { |
my $selstr; |
my $vpos = $k+1; |
if ($k == $maxnum) { |
my $selstr; |
$selstr = ' selected="selected" '; |
if ($k == $maxnum) { |
|
$selstr = ' selected="selected" '; |
|
} |
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
} |
} |
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
$datatable .= '</select></span></td>'. |
|
'<td><span class="LC_nobreak">'. |
|
$default_names{$default}.'</span>'; |
|
if ($default eq 'instcode') { |
|
$datatable .= '<br /><span class="LC_nobreak">(' |
|
.&mt('with institutional codes').')</span>'; |
|
} |
|
$datatable .= '</td>' |
|
.'<td><span class="LC_nobreak"><label><input type="radio" name="'.$default.'" value="1" />' |
|
.&mt('Display').'</label> ' |
|
.'<label><input type="radio" name="'.$default.'" value="0" checked="checked"/>' |
|
.&mt('Do not display').'</label></span></td></tr>'; |
} |
} |
$datatable .= '</select></span></td><td><span class="LC_nobreak">' |
|
.&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">(' |
|
.&mt('with institutional codes').')</span></td>' |
|
.'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />' |
|
.&mt('Display').'</label> ' |
|
.'<label><input type="radio" name="instcode" value="0" checked="checked"/>' |
|
.&mt('Do not display').'</label></span></td></tr>'; |
|
} |
} |
} |
} |
} else { |
} else { |
Line 2814 sub coursecategories_javascript {
|
Line 2884 sub coursecategories_javascript {
|
$jstext = ' var categories = Array(1);'."\n". |
$jstext = ' var categories = Array(1);'."\n". |
' categories[0] = Array("instcode_pos");'."\n"; |
' categories[0] = Array("instcode_pos");'."\n"; |
} |
} |
|
my $instcode_reserved = &mt('The name: "instcode" is a reserved category'); |
|
my $communities_reserved = &mt('The name: "communities" is a reserved category'); |
|
my $choose_again = '\\n'.&mt('Please use a different name for the new top level category'); |
$output = <<"ENDSCRIPT"; |
$output = <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 2873 $jstext
|
Line 2946 $jstext
|
} |
} |
return; |
return; |
} |
} |
|
|
|
function categoryCheck(form) { |
|
if (form.elements['addcategory_name'].value == 'instcode') { |
|
alert('$instcode_reserved\\n$choose_again'); |
|
return false; |
|
} |
|
if (form.elements['addcategory_name'].value == 'communities') { |
|
alert('$communities_reserved\\n$choose_again'); |
|
return false; |
|
} |
|
return true; |
|
} |
|
|
// ]]> |
// ]]> |
</script> |
</script> |
|
|
Line 2882 ENDSCRIPT
|
Line 2968 ENDSCRIPT
|
|
|
sub initialize_categories { |
sub initialize_categories { |
my ($itemcount) = @_; |
my ($itemcount) = @_; |
my $datatable; |
my ($datatable,$css_class,$chgstr); |
my $css_class = $itemcount%2?' class="LC_odd_row"':''; |
my %default_names = ( |
my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"'; |
instcode => 'Official courses (with institutional codes)', |
|
communities => 'Communities', |
$datatable = '<tr '.$css_class.'><td><span class="LC_nobreak">' |
); |
.'<select name="instcode_pos"><option value="0" selected="selected">1</option>' |
my $select0 = ' selected="selected"'; |
.'<option value="1">2</option></select> ' |
my $select1 = ''; |
.&mt('Official courses (with institutional codes)') |
foreach my $default ('instcode','communities') { |
.'</span></td><td><span class="LC_nobreak">' |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
.'<label><input type="radio" name="instcode" value="1" checked="checked" />' |
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"'; |
.&mt('Display').'</label> <label>' |
if ($default eq 'communities') { |
.'<input type="radio" name="instcode" value="0" />'.&mt('Do not display') |
$select1 = $select0; |
|
$select0 = ''; |
|
} |
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
|
.'<select name="'.$default.'_pos">' |
|
.'<option value="0"'.$select0.'>1</option>' |
|
.'<option value="1"'.$select1.'>2</option>' |
|
.'<option value="2">3</option></select> ' |
|
.$default_names{$default} |
|
.'</span></td><td><span class="LC_nobreak">' |
|
.'<label><input type="radio" name="'.$default.'" value="1" checked="checked" />' |
|
.&mt('Display').'</label> <label>' |
|
.'<input type="radio" name="'.$default.'" value="0" />'.&mt('Do not display') |
.'</label></span></td></tr>'; |
.'</label></span></td></tr>'; |
$itemcount ++; |
$itemcount ++; |
|
} |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"'; |
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"'; |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
.'<select name="addcategory_pos"'.$chgstr.'><option value="0">1</option>' |
.'<select name="addcategory_pos"'.$chgstr.'>' |
.'<option value="1" selected="selected">2</option></select> ' |
.'<option value="0">1</option>' |
|
.'<option value="1">2</option>' |
|
.'<option value="2" selected="selected">3</option></select> ' |
.&mt('Add category').'</td><td>'.&mt('Name:') |
.&mt('Add category').'</td><td>'.&mt('Name:') |
.' <input type="text" size="20" name="addcategory_name" value="" /></td></tr>'; |
.' <input type="text" size="20" name="addcategory_name" value="" /></td></tr>'; |
return $datatable; |
return $datatable; |
Line 5398 sub modify_coursecategories {
|
Line 5499 sub modify_coursecategories {
|
$changes{'categorize'} = 1; |
$changes{'categorize'} = 1; |
$domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'}; |
$domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'}; |
} |
} |
|
if ($domconfig{'coursecategories'}{'togglecatscomm'} ne $env{'form.togglecatscomm'}) { |
|
$changes{'togglecatscomm'} = 1; |
|
$domconfig{'coursecategories'}{'togglecatscomm'} = $env{'form.togglecatscomm'}; |
|
} |
|
if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) { |
|
$changes{'categorizecomm'} = 1; |
|
$domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'}; |
|
} |
} else { |
} else { |
$changes{'togglecats'} = 1; |
$changes{'togglecats'} = 1; |
$changes{'categorize'} = 1; |
$changes{'categorize'} = 1; |
Line 5405 sub modify_coursecategories {
|
Line 5514 sub modify_coursecategories {
|
togglecats => $env{'form.togglecats'}, |
togglecats => $env{'form.togglecats'}, |
categorize => $env{'form.categorize'}, |
categorize => $env{'form.categorize'}, |
}; |
}; |
|
$changes{'togglecatscomm'} = 1; |
|
$changes{'categorizecomm'} = 1; |
|
$domconfig{'coursecategories'} = { |
|
togglecats => $env{'form.togglecatscomm'}, |
|
categorize => $env{'form.categorizecomm'}, |
|
}; |
} |
} |
if (ref($cathash) eq 'HASH') { |
if (ref($cathash) eq 'HASH') { |
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) { |
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) { |
push (@deletecategory,'instcode::0'); |
push (@deletecategory,'instcode::0'); |
} |
} |
|
if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) { |
|
push(@deletecategory,'communities::0'); |
|
} |
} |
} |
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail); |
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail); |
if (ref($cathash) eq 'HASH') { |
if (ref($cathash) eq 'HASH') { |
Line 5459 sub modify_coursecategories {
|
Line 5577 sub modify_coursecategories {
|
$adds{$newitem} = 1; |
$adds{$newitem} = 1; |
} |
} |
} |
} |
|
if ($env{'form.communities'} eq '1') { |
|
if (ref($cathash) eq 'HASH') { |
|
my $newitem = 'communities::0'; |
|
if ($cathash->{$newitem} eq '') { |
|
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'}; |
|
$adds{$newitem} = 1; |
|
} |
|
} else { |
|
my $newitem = 'communities::0'; |
|
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'}; |
|
$adds{$newitem} = 1; |
|
} |
|
} |
if ($env{'form.addcategory_name'} ne '') { |
if ($env{'form.addcategory_name'} ne '') { |
my $newitem = &escape($env{'form.addcategory_name'}).'::0'; |
if (($env{'form.addcategory_name'} ne 'instcode') && |
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'}; |
($env{'form.addcategory_name'} ne 'communities')) { |
$adds{$newitem} = 1; |
my $newitem = &escape($env{'form.addcategory_name'}).'::0'; |
|
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'}; |
|
$adds{$newitem} = 1; |
|
} |
} |
} |
my $putresult; |
my $putresult; |
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) { |
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) { |
Line 5499 sub modify_coursecategories {
|
Line 5633 sub modify_coursecategories {
|
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom); |
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom); |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
my %title = ( |
my %title = ( |
togglecats => 'Show/Hide a course in the catalog', |
togglecats => 'Show/Hide a course in catalog', |
categorize => 'Category assigned to course', |
categorize => 'Assign a category to a course', |
|
togglecatscomm => 'Show/Hide a community in catalog', |
|
categorizecomm => 'Assign a category to a community', |
); |
); |
my %level = ( |
my %level = ( |
dom => 'set from "Modify Course" (Domain)', |
dom => 'set in Domain ("Modify Course/Community")', |
crs => 'set from "Parameters" (Course)', |
crs => 'set in Course ("Course Configuration")', |
|
comm => 'set in Community ("Community Configuration")', |
); |
); |
$resulttext = &mt('Changes made:').'<ul>'; |
$resulttext = &mt('Changes made:').'<ul>'; |
if ($changes{'togglecats'}) { |
if ($changes{'togglecats'}) { |
Line 5513 sub modify_coursecategories {
|
Line 5650 sub modify_coursecategories {
|
if ($changes{'categorize'}) { |
if ($changes{'categorize'}) { |
$resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>'; |
$resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>'; |
} |
} |
|
if ($changes{'togglecatscomm'}) { |
|
$resulttext .= '<li>'.&mt("$title{'togglecatscomm'} $level{$env{'form.togglecatscomm'}}").'</li>'; |
|
} |
|
if ($changes{'categorizecomm'}) { |
|
$resulttext .= '<li>'.&mt("$title{'categorizecomm'} $level{$env{'form.categorizecomm'}}").'</li>'; |
|
} |
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) { |
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) { |
my $cathash; |
my $cathash; |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
Line 5562 sub modify_coursecategories {
|
Line 5705 sub modify_coursecategories {
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
&mt('An error occurred: [_1]',$putresult).'</span>'; |
} |
} |
} else { |
} else { |
$resulttext = &mt('No changes made to course categories'); |
$resulttext = &mt('No changes made to course and community categories'); |
} |
} |
return $resulttext; |
return $resulttext; |
} |
} |