version 1.23, 2007/07/25 20:12:26
|
version 1.25, 2007/08/26 15:31:03
|
Line 271 sub print_config_box {
|
Line 271 sub print_config_box {
|
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row">'); |
<tr class="LC_info_row">'); |
if ($action eq 'login') { |
if (($action eq 'login') || ($action eq 'directorysrch')) { |
$r->print(' |
$r->print(' |
<td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>'); |
<td class="LC_left_item" colspan="2">'.$item->{'header'}->[0]->{'col1'}.'</td>'); |
} else { |
} else { |
Line 895 sub print_directorysrch {
|
Line 895 sub print_directorysrch {
|
my ($dom,$settings) = @_; |
my ($dom,$settings) = @_; |
my $srchon = ' '; |
my $srchon = ' '; |
my $srchoff = ' checked="checked" '; |
my $srchoff = ' checked="checked" '; |
my $exacton = ''; |
my ($exacton,$containson,$beginson); |
my $containson = ' checked="checked" '; |
my $localon = ' '; |
my $specifyon = ''; |
my $localoff = ' checked="checked" '; |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if ($settings->{'available'} eq '1') { |
if ($settings->{'available'} eq '1') { |
$srchon = $srchoff; |
$srchon = $srchoff; |
$srchoff = ' '; |
$srchoff = ' '; |
} |
} |
if ($settings->{'searchtypes'} eq 'exact') { |
if ($settings->{'localonly'} eq '1') { |
$exacton = $containson; |
$localon = $localoff; |
$containson = ' '; |
$localoff = ' '; |
} |
} |
if ($settings->{'searchtypes'} eq 'specify') { |
if (ref($settings->{'searchtypes'}) eq 'ARRAY') { |
$specifyon = $containson; |
foreach my $type (@{$settings->{'searchtypes'}}) { |
$containson = ' '; |
if ($type eq 'exact') { |
|
$exacton = ' checked="checked" '; |
|
} elsif ($type eq 'contains') { |
|
$containson = ' checked="checked" '; |
|
} elsif ($type eq 'begins') { |
|
$beginson = ' checked="checked" '; |
|
} |
|
} |
|
} else { |
|
if ($settings->{'searchtypes'} eq 'exact') { |
|
$exacton = ' checked="checked" '; |
|
} elsif ($settings->{'searchtypes'} eq 'contains') { |
|
$containson = ' checked="checked" '; |
|
} elsif ($settings->{'searchtypes'} eq 'specify') { |
|
$exacton = ' checked="checked" '; |
|
$containson = ' checked="checked" '; |
|
} |
} |
} |
} |
} |
my ($searchtitles,$titleorder) = &sorted_searchtitles(); |
my ($searchtitles,$titleorder) = &sorted_searchtitles(); |
Line 917 sub print_directorysrch {
|
Line 933 sub print_directorysrch {
|
|
|
my $numinrow = 4; |
my $numinrow = 4; |
my $datatable='<tr class="LC_odd_row">'. |
my $datatable='<tr class="LC_odd_row">'. |
'<td>'.&mt('Directory search available?').'</td>'. |
'<td colspan="2">'.&mt('Directory search available?').'</td>'. |
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
'<input type="radio" name="dirsrch_available"'. |
'<input type="radio" name="dirsrch_available"'. |
$srchon.' value="1" />'.&mt('Yes').'</label> '. |
$srchon.' value="1" />'.&mt('Yes').'</label> '. |
'<label><input type="radio" name="dirsrch_available"'. |
'<label><input type="radio" name="dirsrch_available"'. |
$srchoff.' value="0" />'.&mt('No').'</label></span></td>'. |
$srchoff.' value="0" />'.&mt('No').'</label></span></td>'. |
'</tr><tr>'. |
'</tr><tr>'. |
'<td>'.&mt('Search latitude').'</td>'. |
'<td colspan="2">'.&mt('Other domains can search?').'</td>'. |
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
'<input type="radio" name="searchtypes"'. |
'<input type="radio" name="dirsrch_localonly"'. |
$exacton.' value="exact" />'.&mt('Exact match only').'</label> '. |
$localoff.' value="0" />'.&mt('Yes').'</label> '. |
'<label><input type="radio" name="searchtypes"'. |
'<label><input type="radio" name="dirsrch_localonly"'. |
$containson.' value="contains" />'.&mt('Contains is a match').'</label>'. |
$localon.' value="1" />'.&mt('No').'</label></span></td>'. |
' <label><input type="radio" name="searchtypes"'. |
'</tr>'; |
$specifyon.' value="specify" />'.&mt('Specifiable type'). |
$datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom, |
'</label></span></td></tr>'. |
$numinrow,$othertitle); |
'<tr class="LC_odd_row">'. |
$datatable .= '<tr>'. |
'<td>'.&mt('Users permitted to search'). |
'<td>'.&mt('Supported search methods'). |
'</td><td class="LC_left_item"><table>'; |
'</td><td class="LC_left_item" colspan="2"><table><tr>'; |
|
foreach my $title (@{$titleorder}) { |
|
if (defined($searchtitles->{$title})) { |
|
my $check = ' '; |
|
if (ref($settings->{'searchby'}) eq 'ARRAY') { |
|
if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) { |
|
$check = ' checked="checked" '; |
|
} |
|
} |
|
$datatable .= '<td class="LC_left_item">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="searchby" '. |
|
'value="'.$title.'"'.$check.'/>'. |
|
$searchtitles->{$title}.'</label></span></td>'; |
|
} |
|
} |
|
$datatable .= '</tr></table></td></tr><tr class="LC_odd_row">'. |
|
'<td>'.&mt('Search latitude').'</td>'. |
|
'<td class="LC_left_item" colspan="2">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="searchtypes" '. |
|
$exacton.' value="exact" />'.&mt('Exact match'). |
|
'</label> '. |
|
'<label><input type="checkbox" name="searchtypes" '. |
|
$beginson.' value="begins" />'.&mt('Begins with'). |
|
'</label> '. |
|
'<label><input type="checkbox" name="searchtypes" '. |
|
$containson.' value="contains" />'.&mt('Contains'). |
|
'</label></span></td></tr>'; |
|
return $datatable; |
|
} |
|
|
|
sub users_cansearch_row { |
|
my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_; |
|
my $output = '<tr class="LC_odd_row">'. |
|
'<td>'.&mt('Users allowed to search').' ('.$dom.')'. |
|
'</td><td class="LC_left_item" colspan="2"><table>'; |
for (my $i=0; $i<@{$types}; $i++) { |
for (my $i=0; $i<@{$types}; $i++) { |
if (defined($usertypes->{$types->[$i]})) { |
if (defined($usertypes->{$types->[$i]})) { |
my $rem = $i%($numinrow); |
my $rem = $i%($numinrow); |
if ($rem == 0) { |
if ($rem == 0) { |
if ($i > 0) { |
if ($i > 0) { |
$datatable .= '</tr>'; |
$output .= '</tr>'; |
} |
} |
$datatable .= '<tr>'; |
$output .= '<tr>'; |
} |
} |
my $check = ' '; |
my $check = ' '; |
if (ref($settings->{'cansearch'}) eq 'ARRAY') { |
if (ref($settings->{'cansearch'}) eq 'ARRAY') { |
Line 951 sub print_directorysrch {
|
Line 1003 sub print_directorysrch {
|
$check = ' checked="checked" '; |
$check = ' checked="checked" '; |
} |
} |
} |
} |
$datatable .= '<td class="LC_left_item">'. |
$output .= '<td class="LC_left_item">'. |
'<span class="LC_nobreak"><label>'. |
'<span class="LC_nobreak"><label>'. |
'<input type="checkbox" name="cansearch" '. |
'<input type="checkbox" name="cansearch" '. |
'value="'.$types->[$i].'"'.$check.'/>'. |
'value="'.$types->[$i].'"'.$check.'/>'. |
$usertypes->{$types->[$i]}.'</label></span></td>'; |
$usertypes->{$types->[$i]}.'</label></span></td>'; |
} |
} |
} |
} |
|
|
my $rem = @{$types}%($numinrow); |
my $rem = @{$types}%($numinrow); |
my $colsleft = $numinrow - $rem; |
my $colsleft = $numinrow - $rem; |
if ($colsleft > 1) { |
if ($colsleft > 1) { |
$datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'; |
$output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'; |
} else { |
} else { |
$datatable .= '<td class="LC_left_item">'; |
$output .= '<td class="LC_left_item">'; |
} |
} |
my $defcheck = ' '; |
my $defcheck = ' '; |
if (ref($settings->{'cansearch'}) eq 'ARRAY') { |
if (ref($settings->{'cansearch'}) eq 'ARRAY') { |
Line 972 sub print_directorysrch {
|
Line 1024 sub print_directorysrch {
|
$defcheck = ' checked="checked" '; |
$defcheck = ' checked="checked" '; |
} |
} |
} |
} |
$datatable .= '<span class="LC_nobreak"><label>'. |
$output .= '<span class="LC_nobreak"><label>'. |
'<input type="checkbox" name="cansearch" '. |
'<input type="checkbox" name="cansearch" '. |
'value="default"'.$defcheck.'/>'. |
'value="default"'.$defcheck.'/>'. |
$othertitle.'</label></span></td>'. |
$othertitle.'</label></span></td>'. |
'</tr></table></td></tr>'; |
'</tr></table></td></tr>'; |
|
return $output; |
$datatable .= '<tr>'. |
|
'<td>'.&mt('Supported search methods'). |
|
'</td><td class="LC_left_item"><table><tr>'; |
|
foreach my $title (@{$titleorder}) { |
|
if (defined($searchtitles->{$title})) { |
|
my $check = ' '; |
|
if (ref($settings->{'searchby'}) eq 'ARRAY') { |
|
if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) { |
|
$check = ' checked="checked" '; |
|
} |
|
} |
|
$datatable .= '<td class="LC_left_item">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="searchby" '. |
|
'value="'.$title.'"'.$check.'/>'. |
|
$searchtitles->{$title}.'</label></span></td>'; |
|
} |
|
} |
|
$datatable .= '</tr></table></td></tr>'; |
|
return $datatable; |
|
} |
} |
|
|
sub sorted_inst_types { |
sub sorted_inst_types { |
Line 1029 sub sorted_searchtitles {
|
Line 1061 sub sorted_searchtitles {
|
return (\%searchtitles,\@titleorder); |
return (\%searchtitles,\@titleorder); |
} |
} |
|
|
|
sub sorted_searchtypes { |
|
my %srchtypes_desc = ( |
|
exact => 'is exact match', |
|
contains => 'contains ..', |
|
begins => 'begins with ..', |
|
); |
|
my @srchtypeorder = ('exact','begins','contains'); |
|
return (\%srchtypes_desc,\@srchtypeorder); |
|
} |
|
|
sub usertype_update_row { |
sub usertype_update_row { |
my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_; |
my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_; |
my $datatable; |
my $datatable; |
Line 1929 sub modify_directorysrch {
|
Line 1971 sub modify_directorysrch {
|
} |
} |
my %title = ( available => 'Directory search available', |
my %title = ( available => 'Directory search available', |
cansearch => 'Users permitted to search', |
cansearch => 'Users permitted to search', |
|
localonly => 'Other domains can search', |
searchby => 'Search types', |
searchby => 'Search types', |
searchtypes => 'Search latitude'); |
searchtypes => 'Search latitude'); |
|
|
my @offon = ('off','on'); |
my @offon = ('off','on'); |
|
my @otherdoms = ('Yes','No'); |
|
|
|
my @searchtypes = &Apache::loncommon::get_env_multiple('form.searchtypes'); |
my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch'); |
my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch'); |
my @searchby = &Apache::loncommon::get_env_multiple('form.searchby'); |
my @searchby = &Apache::loncommon::get_env_multiple('form.searchby'); |
|
|
Line 1966 sub modify_directorysrch {
|
Line 2010 sub modify_directorysrch {
|
} else { |
} else { |
push(@{$changes{'searchby'}},@searchby); |
push(@{$changes{'searchby'}},@searchby); |
} |
} |
|
|
|
if (ref($currdirsrch{'searchtypes'}) eq 'ARRAY') { |
|
foreach my $type (@{$currdirsrch{'searchtypes'}}) { |
|
if (!grep(/^\Q$type\E$/,@searchtypes)) { |
|
push(@{$changes{'searchtypes'}},$type); |
|
} |
|
} |
|
foreach my $type (@searchtypes) { |
|
if (!grep(/^\Q$type\E$/,@{$currdirsrch{'searchtypes'}})) { |
|
push(@{$changes{'searchtypes'}},$type); |
|
} |
|
} |
|
} else { |
|
if (exists($currdirsrch{'searchtypes'})) { |
|
foreach my $type (@searchtypes) { |
|
if ($type ne $currdirsrch{'searchtypes'}) { |
|
push(@{$changes{'searchtypes'}},$type); |
|
} |
|
} |
|
if (!grep(/^\Q$currdirsrch{'searchtypes'}\E/,@searchtypes)) { |
|
push(@{$changes{'searchtypes'}},$currdirsrch{'searchtypes'}); |
|
} |
|
} else { |
|
push(@{$changes{'searchtypes'}},@searchtypes); |
|
} |
|
} |
|
|
my %dirsrch_hash = ( |
my %dirsrch_hash = ( |
directorysrch => { available => $env{'form.dirsrch_available'}, |
directorysrch => { available => $env{'form.dirsrch_available'}, |
cansearch => \@cansearch, |
cansearch => \@cansearch, |
|
localonly => $env{'form.dirsrch_localonly'}, |
searchby => \@searchby, |
searchby => \@searchby, |
searchtypes => $env{'form.searchtypes'}, |
searchtypes => \@searchtypes, |
} |
} |
); |
); |
my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash, |
my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash, |
Line 1986 sub modify_directorysrch {
|
Line 2057 sub modify_directorysrch {
|
$changes{'available'} = 1; |
$changes{'available'} = 1; |
} |
} |
} |
} |
if (exists($currdirsrch{'searchtypes'})) { |
if (exists($currdirsrch{'localonly'})) { |
if ($currdirsrch{'searchtypes'} ne $env{'form.searchtypes'}) { |
if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) { |
$changes{'searchtypes'} = 1; |
$changes{'localonly'} = 1; |
} |
} |
} else { |
} else { |
if ($env{'form.searchtypes'}) { |
if ($env{'form.dirsrch_localonly'} eq '1') { |
$changes{'searchtypes'} = 1; |
$changes{'localonly'} = 1; |
} |
} |
} |
} |
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
Line 2000 sub modify_directorysrch {
|
Line 2071 sub modify_directorysrch {
|
if ($changes{'available'}) { |
if ($changes{'available'}) { |
$resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>'; |
$resulttext .= '<li>'.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").'</li>'; |
} |
} |
|
if ($changes{'localonly'}) { |
|
$resulttext .= '<li>'.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").'</li>'; |
|
} |
|
|
if (ref($changes{'cansearch'}) eq 'ARRAY') { |
if (ref($changes{'cansearch'}) eq 'ARRAY') { |
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom); |
my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom); |
my $chgtext; |
my $chgtext; |
Line 2013 sub modify_directorysrch {
|
Line 2088 sub modify_directorysrch {
|
} else { |
} else { |
$chgtext =~ s/\; $//; |
$chgtext =~ s/\; $//; |
} |
} |
$resulttext .= '<li>'.&mt("$title{'cansearch'} set to: [_1]",$chgtext).'</li>'; |
$resulttext .= '<li>'.&mt("$title{'cansearch'} ([_1]) set to: [_2]",$dom,$chgtext).'</li>'; |
} |
} |
if (ref($changes{'searchby'}) eq 'ARRAY') { |
if (ref($changes{'searchby'}) eq 'ARRAY') { |
my ($searchtitles,$titleorder) = &sorted_searchtitles(); |
my ($searchtitles,$titleorder) = &sorted_searchtitles(); |
Line 2028 sub modify_directorysrch {
|
Line 2103 sub modify_directorysrch {
|
$chgtext =~ s/\; $//; |
$chgtext =~ s/\; $//; |
$resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>'; |
$resulttext .= '<li>'.&mt("$title{'searchby'} set to: [_1]",$chgtext).'</li>'; |
} |
} |
if ($changes{'searchtypes'}) { |
if (ref($changes{'searchtypes'}) eq 'ARRAY') { |
my %srchtypes_desc = ( |
my ($srchtypes_desc,$srchtypeorder) = &sorted_searchtypes(); |
exact => 'Exact match only', |
my $chgtext; |
contains => 'Contains is a match', |
foreach my $type (@{$srchtypeorder}) { |
specify => 'Match type specifiable', |
if (grep(/^\Q$type\E$/,@searchtypes)) { |
); |
if (defined($srchtypes_desc->{$type})) { |
$resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"$srchtypes_desc{$env{'form.searchtypes'}}\"").'</li>'; |
$chgtext .= $srchtypes_desc->{$type}.'; '; |
|
} |
|
} |
|
} |
|
$chgtext =~ s/\; $//; |
|
$resulttext .= '<li>'.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'</li>'; |
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
} else { |
} else { |
Line 2048 sub modify_directorysrch {
|
Line 2128 sub modify_directorysrch {
|
} |
} |
|
|
1; |
1; |
|
|