version 1.24, 2007/07/28 21:23:53
|
version 1.25, 2007/08/26 15:31:03
|
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 $specifyon = ''; |
|
my $localon = ' '; |
my $localon = ' '; |
my $localoff = ' checked="checked" '; |
my $localoff = ' checked="checked" '; |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
Line 909 sub print_directorysrch {
|
Line 907 sub print_directorysrch {
|
$localon = $localoff; |
$localon = $localoff; |
$localoff = ' '; |
$localoff = ' '; |
} |
} |
if ($settings->{'searchtypes'} eq 'exact') { |
if (ref($settings->{'searchtypes'}) eq 'ARRAY') { |
$exacton = $containson; |
foreach my $type (@{$settings->{'searchtypes'}}) { |
$containson = ' '; |
if ($type eq 'exact') { |
} |
$exacton = ' checked="checked" '; |
if ($settings->{'searchtypes'} eq 'specify') { |
} elsif ($type eq 'contains') { |
$specifyon = $containson; |
$containson = ' checked="checked" '; |
$containson = ' '; |
} 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 930 sub print_directorysrch {
|
Line 940 sub print_directorysrch {
|
'<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 colspan="2">'.&mt('Search latitude').'</td>'. |
'<td colspan="2">'.&mt('Other domains can search?').'</td>'. |
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="searchtypes"'. |
|
$exacton.' value="exact" />'.&mt('Exact match only').'</label> '. |
|
'<label><input type="radio" name="searchtypes"'. |
|
$containson.' value="contains" />'.&mt('Contains is a match').'</label>'. |
|
' <label><input type="radio" name="searchtypes"'. |
|
$specifyon.' value="specify" />'.&mt('Specifiable type'). |
|
'</label></span></td></tr>'. |
|
'<tr class="LC_odd_row">'. |
|
'<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="dirsrch_localonly"'. |
'<input type="radio" name="dirsrch_localonly"'. |
$localoff.' value="0" />'.&mt('Yes').'</label> '. |
$localoff.' value="0" />'.&mt('Yes').'</label> '. |
'<label><input type="radio" name="dirsrch_localonly"'. |
'<label><input type="radio" name="dirsrch_localonly"'. |
$localon.' value="1" />'.&mt('No').'</label></span></td>'. |
$localon.' value="1" />'.&mt('No').'</label></span></td>'. |
'</tr><tr>'. |
'</tr>'; |
|
$datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom, |
|
$numinrow,$othertitle); |
|
$datatable .= '<tr>'. |
|
'<td>'.&mt('Supported search methods'). |
|
'</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>'.&mt('Users allowed to search').' ('.$dom.')'. |
'</td><td class="LC_left_item" colspan="2"><table>'; |
'</td><td class="LC_left_item" colspan="2"><table>'; |
for (my $i=0; $i<@{$types}; $i++) { |
for (my $i=0; $i<@{$types}; $i++) { |
Line 954 sub print_directorysrch {
|
Line 993 sub print_directorysrch {
|
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 964 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 985 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 class="LC_odd_row">'. |
|
'<td>'.&mt('Supported search methods'). |
|
'</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>'; |
|
return $datatable; |
|
} |
} |
|
|
sub sorted_inst_types { |
sub sorted_inst_types { |
Line 1042 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 1948 sub modify_directorysrch {
|
Line 1977 sub modify_directorysrch {
|
my @offon = ('off','on'); |
my @offon = ('off','on'); |
my @otherdoms = ('Yes','No'); |
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 1980 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'}, |
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 2010 sub modify_directorysrch {
|
Line 2066 sub modify_directorysrch {
|
$changes{'localonly'} = 1; |
$changes{'localonly'} = 1; |
} |
} |
} |
} |
if (exists($currdirsrch{'searchtypes'})) { |
|
if ($currdirsrch{'searchtypes'} ne $env{'form.searchtypes'}) { |
|
$changes{'searchtypes'} = 1; |
|
} |
|
} else { |
|
if ($env{'form.searchtypes'}) { |
|
$changes{'searchtypes'} = 1; |
|
} |
|
} |
|
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
$resulttext = &mt('Changes made:').'<ul>'; |
$resulttext = &mt('Changes made:').'<ul>'; |
if ($changes{'available'}) { |
if ($changes{'available'}) { |
Line 2056 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 2076 sub modify_directorysrch {
|
Line 2128 sub modify_directorysrch {
|
} |
} |
|
|
1; |
1; |
|
|