');
foreach my $item (@prefs) {
if ($item->{'action'} eq 'login') {
@@ -164,6 +195,8 @@ sub process_changes {
$output = &modify_autoenroll($dom,%domconfig);
} elsif ($action eq 'autoupdate') {
$output = &modify_autoupdate($dom,%domconfig);
+ } elsif ($action eq 'directorysrch') {
+ $output = &modify_directorysrch($dom,%domconfig);
}
return $output;
}
@@ -173,9 +206,12 @@ sub print_config_box {
$r->print('
- '.&mt($item->{text}).' '.
- &Apache::loncommon::help_open_topic($item->{'help'}).'
- ');
+ '.&mt($item->{text}).' ');
+#
+# FIXME - put the help link back in when the help files exist
+# '.&mt($item->{text}).' '.
+# &Apache::loncommon::help_open_topic($item->{'help'}).'
+# ');
if (($action eq 'autoupdate') || ($action eq 'rolecolors')) {
my $colspan = ($action eq 'rolecolors')?' colspan="2"':'';
$r->print('
@@ -235,7 +271,7 @@ sub print_config_box {
');
- if ($action eq 'login') {
+ if (($action eq 'login') || ($action eq 'directorysrch')) {
$r->print('
'.$item->{'header'}->[0]->{'col1'}.' ');
} else {
@@ -251,6 +287,8 @@ sub print_config_box {
$r->print(&print_quotas($dom,$settings));
} elsif ($action eq 'autoenroll') {
$r->print(&print_autoenroll($dom,$settings));
+ } elsif ($action eq 'directorysrch') {
+ $r->print(&print_directorysrch($dom,$settings));
}
}
$r->print('
@@ -522,13 +560,14 @@ sub display_color_options {
' ';
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
- $itemcount ++;
+ $itemcount ++;
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.
''.$choices->{$img}.' ';
- my $imgfile;
+ my ($imgfile, $img_import);
if ($designs->{$img} ne '') {
$imgfile = $designs->{$img};
+ $img_import = ($imgfile =~ m{^/adm/});
} else {
$imgfile = $defaults->{$img};
}
@@ -578,6 +617,9 @@ sub display_color_options {
if (!$is_custom->{$img}) {
$datatable .= &mt('Default in use:').' ';
}
+ if ($img_import) {
+ $datatable.= ' ';
+ }
$datatable.= ' ';
@@ -700,21 +742,11 @@ ENDCOL
sub print_quotas {
my ($dom,$settings) = @_;
my $datatable;
- my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
- my $othertitle = "All users";
- my @types;
- if (ref($order) eq 'ARRAY') {
- @types = @{$order};
- }
- if (@types == 0) {
- if (ref($usertypes) eq 'HASH') {
- @types = sort(keys(%{$usertypes}));
- }
- }
+ my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
my $typecount = 0;
my $css_class;
- if (@types > 0) {
- foreach my $type (@types) {
+ if (@{$types} > 0) {
+ foreach my $type (@{$types}) {
if (defined($usertypes->{$type})) {
$typecount ++;
$css_class = $typecount%2?' class="LC_odd_row"':'';
@@ -726,7 +758,6 @@ sub print_quotas {
'" size="5" /> Mb ';
}
}
- $othertitle = "Other users";
}
my $defaultquota = '20';
if (ref($settings) eq 'HASH') {
@@ -835,34 +866,22 @@ sub print_autoupdate {
$classlistsoff.'value="0" />'.&mt('No').''.
'';
} else {
- my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
- my @types;
- if (ref($order) eq 'ARRAY') {
- @types = @{$order};
- }
- if (@types == 0) {
- if (ref($usertypes) eq 'HASH') {
- @types = sort(keys(%{$usertypes}));
- }
- }
- my $othertitle = &mt('All users');
- if (keys(%{$usertypes}) > 0) {
- $othertitle = &mt('Other users');
- }
- my @fields = ('lastname','firstname','middlename','gen','email','id');
+ my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+ my @fields = ('lastname','firstname','middlename','gen',
+ 'permanentemail','id');
my %fieldtitles = &Apache::lonlocal::texthash (
id => 'Student/Employee ID',
- email => 'E-mail address',
+ permanentemail => 'E-mail address',
lastname => 'Last Name',
firstname => 'First Name',
middlename => 'Middle Name',
gen => 'Generation',
);
my $numrows = 0;
- if (@types > 0) {
+ if (@{$types} > 0) {
$datatable =
&usertype_update_row($settings,$usertypes,\%fieldtitles,
- \@fields,\@types,\$numrows);
+ \@fields,$types,\$numrows);
}
$datatable .=
&usertype_update_row($settings,{'default' => $othertitle},
@@ -872,6 +891,157 @@ sub print_autoupdate {
return $datatable;
}
+sub print_directorysrch {
+ my ($dom,$settings) = @_;
+ my $srchon = ' ';
+ my $srchoff = ' checked="checked" ';
+ my $exacton = '';
+ my $containson = ' checked="checked" ';
+ my $specifyon = '';
+ my $localon = ' ';
+ my $localoff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'available'} eq '1') {
+ $srchon = $srchoff;
+ $srchoff = ' ';
+ }
+ if ($settings->{'localonly'} eq '1') {
+ $localon = $localoff;
+ $localoff = ' ';
+ }
+ if ($settings->{'searchtypes'} eq 'exact') {
+ $exacton = $containson;
+ $containson = ' ';
+ }
+ if ($settings->{'searchtypes'} eq 'specify') {
+ $specifyon = $containson;
+ $containson = ' ';
+ }
+ }
+ my ($searchtitles,$titleorder) = &sorted_searchtitles();
+ my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+
+ my $numinrow = 4;
+ my $datatable=''.
+ ''.&mt('Directory search available?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Search latitude').' '.
+ ''.
+ ' '.&mt('Exact match only').' '.
+ ' '.&mt('Contains is a match').' '.
+ ' '.&mt('Specifiable type').
+ ' '.
+ ''.
+ ''.&mt('Other domains can search').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Users allowed to search').' ('.$dom.')'.
+ ' ';
+
+ $datatable .= ''.
+ ''.&mt('Supported search methods').
+ ' ';
+ return $datatable;
+}
+
+sub sorted_inst_types {
+ my ($dom) = @_;
+ my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
+ my $othertitle = "All users";
+ my @types;
+ if (ref($order) eq 'ARRAY') {
+ @types = @{$order};
+ }
+ if (@types == 0) {
+ if (ref($usertypes) eq 'HASH') {
+ @types = sort(keys(%{$usertypes}));
+ }
+ }
+ if (keys(%{$usertypes}) > 0) {
+ $othertitle = &mt('Other users');
+ }
+ return ($othertitle,$usertypes,\@types);
+}
+
+sub sorted_searchtitles {
+ my %searchtitles = &Apache::lonlocal::texthash(
+ 'uname' => 'username',
+ 'lastname' => 'last name',
+ 'lastfirst' => 'last name, first name',
+ );
+ my @titleorder = ('uname','lastname','lastfirst');
+ return (\%searchtitles,\@titleorder);
+}
+
sub usertype_update_row {
my ($settings,$usertypes,$fieldtitles,$fields,$types,$rownums) = @_;
my $datatable;
@@ -1052,6 +1222,15 @@ sub modify_colors {
}
my ($width,$height) = &thumb_dimensions();
foreach my $img (@images) {
+ if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
+ && !defined($domconfig->{$role}{$img})
+ && !$env{'form.'.$role.'_del_'.$img}
+ && $env{'form.'.$role.'_import_'.$img}) {
+ # import the old configured image from the .tab setting
+ # if they haven't provided a new one
+ $domconfig->{$role}{$img} =
+ $env{'form.'.$role.'_import_'.$img};
+ }
if ($env{'form.'.$role.'_'.$img.'.filename'} ne '') {
my $error;
if ($configuserok eq 'ok') {
@@ -1091,6 +1270,7 @@ sub modify_colors {
$dom,$confname,$img,$width,$height);
if ($result eq 'ok') {
$confhash->{$role}{$img} = $logourl;
+ $changes{$role}{'images'}{$img} = 1;
}
}
}
@@ -1253,7 +1433,7 @@ sub check_dimensions {
}
chomp($imageinfo);
my ($fullsize) =
- ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)\s+/);
+ ($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)/);
if ($fullsize) {
($fullwidth,$fullheight) = split(/x/,$fullsize);
}
@@ -1599,7 +1779,7 @@ sub modify_autoenroll {
}
} elsif ($autorun) {
if ($env{'form.autoenroll_run'} ne '1') {
- $changes{'run'} = 1;
+ $changes{'run'} = 1;
}
}
if ($currautoenroll{'sender_uname'} ne $sender_uname) {
@@ -1647,7 +1827,7 @@ sub modify_autoupdate {
my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
my %fieldtitles = &Apache::lonlocal::texthash (
id => 'Student/Employee ID',
- email => 'E-mail address',
+ permanentemail => 'E-mail address',
lastname => 'Last Name',
firstname => 'First Name',
middlename => 'Middle Name',
@@ -1750,6 +1930,150 @@ sub modify_autoupdate {
}
return $resulttext;
}
+
+sub modify_directorysrch {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,%changes);
+ my %currdirsrch;
+ if (ref($domconfig{'directorysrch'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'directorysrch'}})) {
+ $currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
+ }
+ }
+ my %title = ( available => 'Directory search available',
+ cansearch => 'Users permitted to search',
+ localonly => 'Other domains can search',
+ searchby => 'Search types',
+ searchtypes => 'Search latitude');
+ my @offon = ('off','on');
+ my @otherdoms = ('Yes','No');
+
+ my @cansearch = &Apache::loncommon::get_env_multiple('form.cansearch');
+ my @searchby = &Apache::loncommon::get_env_multiple('form.searchby');
+
+ if (ref($currdirsrch{'cansearch'}) eq 'ARRAY') {
+ foreach my $type (@{$currdirsrch{'cansearch'}}) {
+ if (!grep(/^\Q$type\E$/,@cansearch)) {
+ push(@{$changes{'cansearch'}},$type);
+ }
+ }
+ foreach my $type (@cansearch) {
+ if (!grep(/^\Q$type\E$/,@{$currdirsrch{'cansearch'}})) {
+ push(@{$changes{'cansearch'}},$type);
+ }
+ }
+ } else {
+ push(@{$changes{'cansearch'}},@cansearch);
+ }
+
+ if (ref($currdirsrch{'searchby'}) eq 'ARRAY') {
+ foreach my $by (@{$currdirsrch{'searchby'}}) {
+ if (!grep(/^\Q$by\E$/,@searchby)) {
+ push(@{$changes{'searchby'}},$by);
+ }
+ }
+ foreach my $by (@searchby) {
+ if (!grep(/^\Q$by\E$/,@{$currdirsrch{'searchby'}})) {
+ push(@{$changes{'searchby'}},$by);
+ }
+ }
+ } else {
+ push(@{$changes{'searchby'}},@searchby);
+ }
+
+ my %dirsrch_hash = (
+ directorysrch => { available => $env{'form.dirsrch_available'},
+ cansearch => \@cansearch,
+ localonly => $env{'form.dirsrch_localonly'},
+ searchby => \@searchby,
+ searchtypes => $env{'form.searchtypes'},
+ }
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%dirsrch_hash,
+ $dom);
+ if ($putresult eq 'ok') {
+ if (exists($currdirsrch{'available'})) {
+ if ($currdirsrch{'available'} ne $env{'form.dirsrch_available'}) {
+ $changes{'available'} = 1;
+ }
+ } else {
+ if ($env{'form.dirsrch_available'} eq '1') {
+ $changes{'available'} = 1;
+ }
+ }
+ if (exists($currdirsrch{'localonly'})) {
+ if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
+ $changes{'localonly'} = 1;
+ }
+ } else {
+ if ($env{'form.dirsrch_localonly'} eq '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) {
+ $resulttext = &mt('Changes made:').'';
+ if ($changes{'available'}) {
+ $resulttext .= ''.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").' ';
+ }
+ if ($changes{'localonly'}) {
+ $resulttext .= ''.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").' ';
+ }
+
+ if (ref($changes{'cansearch'}) eq 'ARRAY') {
+ my ($othertitle,$usertypes,$types) = &sorted_inst_types($dom);
+ my $chgtext;
+ foreach my $type (@cansearch) {
+ if (defined($usertypes->{$type})) {
+ $chgtext .= $usertypes->{$type}.'; ';
+ }
+ }
+ if (grep(/^default$/,@cansearch)) {
+ $chgtext .= $othertitle;
+ } else {
+ $chgtext =~ s/\; $//;
+ }
+ $resulttext .= ''.&mt("$title{'cansearch'} ([_1]) set to: [_2]",$dom,$chgtext).' ';
+ }
+ if (ref($changes{'searchby'}) eq 'ARRAY') {
+ my ($searchtitles,$titleorder) = &sorted_searchtitles();
+ my $chgtext;
+ foreach my $type (@{$titleorder}) {
+ if (grep(/^\Q$type\E$/,@searchby)) {
+ if (defined($searchtitles->{$type})) {
+ $chgtext .= $searchtitles->{$type}.'; ';
+ }
+ }
+ }
+ $chgtext =~ s/\; $//;
+ $resulttext .= ''.&mt("$title{'searchby'} set to: [_1]",$chgtext).' ';
+ }
+ if ($changes{'searchtypes'}) {
+ my %srchtypes_desc = (
+ exact => 'Exact match only',
+ contains => 'Contains is a match',
+ specify => 'Match type specifiable',
+ );
+ $resulttext .= ''.&mt("$title{'searchtypes'} set to: \"$srchtypes_desc{$env{'form.searchtypes'}}\"").' ';
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to institution directory search settings');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ return $resulttext;
+}
1;