'.
''.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').' | '.
''."\n".
- ''."\n";
+ ''."\n";
for (my $i=0; $i<@fields; $i++) {
$rem = $i%($numperrow);
if ($rem == 0) {
@@ -5699,22 +5074,16 @@ sub print_selfcreation {
$$rowtotal ++;
} elsif ($position eq 'middle') {
my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom);
- my @posstypes;
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ $usertypes->{'default'} = $othertitle;
if (ref($types) eq 'ARRAY') {
- @posstypes = @{$types};
- }
- unless (grep(/^default$/,@posstypes)) {
- push(@posstypes,'default');
- }
- my %usertypeshash;
- if (ref($usertypes) eq 'HASH') {
- %usertypeshash = %{$usertypes};
- }
- $usertypeshash{'default'} = $othertitle;
- foreach my $status (@posstypes) {
- $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
- $numinrow,$$rowtotal,\%usertypeshash);
- $$rowtotal ++;
+ push(@{$types},'default');
+ $usertypes->{'default'} = $othertitle;
+ foreach my $status (@{$types}) {
+ $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
+ $numinrow,$$rowtotal,$usertypes);
+ $$rowtotal ++;
+ }
}
} else {
my %choices = &Apache::lonlocal::texthash (
@@ -5732,30 +5101,29 @@ sub print_selfcreation {
my $onclick = "toggleDisplay(this.form,'emailoptions');";
my $additional = '';
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my (@ordered,%usertypeshash);
- if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') {
- @ordered = @{$domdefaults{'inststatusguest'}};
- }
- if (@ordered) {
- unless (grep(/^default$/,@ordered)) {
- push(@ordered,'default');
- }
- if (ref($usertypes) eq 'HASH') {
- %usertypeshash = %{$usertypes};
- }
- $usertypeshash{'default'} = $othertitle;
- $additional .= ' ';
- foreach my $status (@ordered) {
- $additional .= ''.$usertypeshash{$status}.' | ';
- }
- $additional .= ' ';
- foreach my $status (@ordered) {
- $additional .= ''.&email_as_username($rowtotal,$processing,$status).' | ';
+ my $usertypes = {};
+ my $order = [];
+ if ((ref($domdefaults{'inststatustypes'}) eq 'HASH') && (ref($domdefaults{'inststatusguest'}) eq 'ARRAY')) {
+ $usertypes = $domdefaults{'inststatustypes'};
+ $order = $domdefaults{'inststatusguest'};
+ }
+ if (ref($order) eq 'ARRAY') {
+ push(@{$order},'default');
+ if (@{$order} > 1) {
+ $usertypes->{'default'} = &mt('Other users');
+ $additional .= '';
+ foreach my $status (@{$order}) {
+ $additional .= ''.$usertypes->{$status}.' | ';
+ }
+ $additional .= ' ';
+ foreach my $status (@{$order}) {
+ $additional .= ''.&email_as_username($rowtotal,$processing,$status).' | ';
+ }
+ $additional .= ' ';
+ } else {
+ $usertypes->{'default'} = &mt('All users');
+ $additional .= &email_as_username($rowtotal,$processing);
}
- $additional .= '
';
- } else {
- $usertypeshash{'default'} = $othertitle;
- $additional .= &email_as_username($rowtotal,$processing);
}
$additional .= ' '."\n";
@@ -5766,10 +5134,12 @@ sub print_selfcreation {
$$rowtotal ++;
my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
$numinrow = 1;
- foreach my $status (@ordered) {
- $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
- $numinrow,$$rowtotal,\%usertypeshash,$infofields,$infotitles);
- $$rowtotal ++;
+ if (ref($order) eq 'ARRAY') {
+ foreach my $status (@{$order}) {
+ $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
+ $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles);
+ $$rowtotal ++;
+ }
}
my ($emailrules,$emailruleorder) =
&Apache::lonnet::inst_userrules($dom,'email');
@@ -6155,7 +5525,7 @@ sub print_defaults {
1 => 'Yes, allow login then update passwd file using default cost (if higher)',
2 => 'Yes, disallow login if stored cost is less than domain default',
);
- $datatable .= '';
+ $datatable .= '';
foreach my $option (@options) {
my $checked = ' ';
my $onclick;
@@ -6506,7 +5876,7 @@ sub print_coursecategories {
''.$lt{$type}.' ';
}
- $datatable .= '';
+ $datatable .= '';
$itemcount ++;
}
$$rowtotal += $itemcount;
@@ -6717,7 +6087,7 @@ sub print_coursecategories {
$datatable .= &initialize_categories($itemcount);
}
} else {
- $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.' | '
+ $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.' | '
.&initialize_categories($itemcount);
}
$$rowtotal += $itemcount;
@@ -6765,7 +6135,7 @@ sub print_serverstatuses {
''.
''.
- ''."\n";
+ ''."\n";
}
$$rowtotal += $rownum;
return $datatable;
@@ -6990,7 +6360,7 @@ sub initialize_categories {
my $select1 = '';
foreach my $default ('instcode','communities') {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';
+ $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','0'".');"';
if ($default eq 'communities') {
$select1 = $select0;
$select0 = '';
@@ -7015,8 +6385,9 @@ sub initialize_categories {
.''
.''
.' '
- .&mt('Add category').''.&mt('Name:')
- .' | ';
+ .&mt('Add category').'>'.&mt('Name:')
+ .' '
+ .'';
return $datatable;
}
@@ -7071,7 +6442,7 @@ sub build_category_rows {
pop(@{$path});
}
} else {
- $text .= &mt('Add subcategory:').' '.&mt('Add subcategory:').'';
+ $text .= ''.&mt('Add subcategory:').' | ';
}
}
}
@@ -7237,13 +6608,11 @@ sub modifiable_userdata_row {
}
sub insttypes_row {
- my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rowtotal,$onclick,
- $customcss,$rowstyle) = @_;
+ my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rownum) = @_;
my %lt = &Apache::lonlocal::texthash (
cansearch => 'Users allowed to search',
statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
lockablenames => 'User preference to lock name',
- overrides => "Override domain's helpdesk settings based on requester's affiliation",
);
my $showdom;
if ($context eq 'cansearch') {
@@ -7253,22 +6622,9 @@ sub insttypes_row {
if ($context eq 'statustocreate') {
$class = 'LC_right_item';
}
- my $css_class;
- if ($$rowtotal%2) {
- $css_class = 'LC_odd_row';
- }
- if ($customcss) {
- $css_class .= ' '.$customcss;
- }
- $css_class =~ s/^\s+//;
- if ($css_class) {
- $css_class = ' class="'.$css_class.'"';
- }
- if ($rowstyle) {
- $css_class .= ' style="'.$rowstyle.'"';
- }
- if ($onclick) {
- $onclick = 'onclick="'.$onclick.'" ';
+ my $css_class = ' class="LC_odd_row"';
+ if ($rownum ne '') {
+ $css_class = ($rownum%2? ' class="LC_odd_row"':'');
}
my $output = ''.
''.$lt{$context}.$showdom.
@@ -7290,10 +6646,6 @@ sub insttypes_row {
if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
$check = ' checked="checked" ';
}
- } elsif (ref($settings->{$context}) eq 'HASH') {
- if (ref($settings->{$context}->{$types->[$i]}) eq 'HASH') {
- $check = ' checked="checked" ';
- }
} elsif ($context eq 'statustocreate') {
$check = ' checked="checked" ';
}
@@ -7308,38 +6660,29 @@ sub insttypes_row {
$rem = @{$types}%($numinrow);
}
my $colsleft = $numinrow - $rem;
- if ($context eq 'overrides') {
- if ($colsleft > 1) {
- $output .= ' | ';
- } else {
- $output .= ' | ';
- }
- $output .= ' ';
+ if ($rem == 0) {
+ $output .= ' | ';
+ }
+ if ($colsleft > 1) {
+ $output .= '';
} else {
- if (($rem == 0) && (@{$types} > 0)) {
- $output .= ' | ';
- }
- if ($colsleft > 1) {
- $output .= '';
- } else {
- $output .= ' | ';
- }
- my $defcheck = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'ARRAY') {
- if (grep(/^default$/,@{$settings->{$context}})) {
- $defcheck = ' checked="checked" ';
- }
- } elsif ($context eq 'statustocreate') {
+ $output .= ' | ';
+ }
+ my $defcheck = ' ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^default$/,@{$settings->{$context}})) {
$defcheck = ' checked="checked" ';
}
+ } elsif ($context eq 'statustocreate') {
+ $defcheck = ' checked="checked" ';
}
- $output .= '';
}
- $output .= ' | ';
+ $output .= ''.
+ ' ';
return $output;
}
@@ -8779,20 +8122,16 @@ sub modify_quotas {
#FIXME need to obsolete item in RES space
} elsif ($env{'form.'.$type.'_image_'.$i.'.filename'}) {
my ($cdom,$cnum) = split(/_/,$key);
- if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
- $errors .= ''.&mt('Image not saved: could not find textbook course').'';
- } else {
- my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i,
- $cdom,$cnum,$type,$configuserok,
- $switchserver,$author_ok);
- if ($imgurl) {
- $confhash{$type}{$key}{'image'} = $imgurl;
- $changes{$type}{$key} = 1;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.'';
- }
+ my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i,
+ $cdom,$cnum,$type,$configuserok,
+ $switchserver,$author_ok);
+ if ($imgurl) {
+ $confhash{$type}{$key}{'image'} = $imgurl;
+ $changes{$type}{$key} = 1;
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.'';
}
} elsif ($domconfig{$action}{$type}{$key}{'image'}) {
$confhash{$type}{$key}{'image'} =
@@ -9326,7 +8665,7 @@ sub process_textbook_image {
} elsif ($author_ok eq 'ok') {
my ($result,$imageurl) =
&publishlogo($r,'upload',$caller,$dom,$confname,
- "$type/$cdom/$cnum/cover",$width,$height);
+ "$type/$dom/$cnum/cover",$width,$height);
if ($result eq 'ok') {
$url = $imageurl;
} else {
@@ -9341,590 +8680,6 @@ sub process_textbook_image {
return ($url,$error);
}
-sub modify_ltitools {
- my ($r,$dom,$action,$lastactref,%domconfig) = @_;
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- my ($newid,@allpos,%changes,%confhash,%encconfig,$errors,$resulttext);
- my $confname = $dom.'-domainconfig';
- my $servadm = $r->dir_config('lonAdmEMail');
- my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
- my (%posslti,%possfield);
- my @courseroles = ('cc','in','ta','ep','st');
- my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
- map { $posslti{$_} = 1; } @ltiroles;
- my @allfields = ('fullname','firstname','lastname','email','user','roles');
- map { $possfield{$_} = 1; } @allfields;
- my %lt = <itools_names();
- if ($env{'form.ltitools_add'}) {
- my $title = $env{'form.ltitools_add_title'};
- $title =~ s/(`)/'/g;
- ($newid,my $error) = &get_ltitools_id($dom,$title);
- if ($newid) {
- my $position = $env{'form.ltitools_add_pos'};
- $position =~ s/\D+//g;
- if ($position ne '') {
- $allpos[$position] = $newid;
- }
- $changes{$newid} = 1;
- foreach my $item ('title','url','key','secret') {
- $env{'form.ltitools_add_'.$item} =~ s/(`)/'/g;
- if ($env{'form.ltitools_add_'.$item}) {
- if (($item eq 'key') || ($item eq 'secret')) {
- $encconfig{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- } else {
- $confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') {
- $confhash{$newid}{'version'} = $env{'form.ltitools_add_version'};
- }
- if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') {
- $confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'};
- }
- foreach my $item ('width','height','linktext','explanation') {
- $env{'form.ltitools_add_'.$item} =~ s/^\s+//;
- $env{'form.ltitools_add_'.$item} =~ s/\s+$//;
- if (($item eq 'width') || ($item eq 'height')) {
- if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- } else {
- if ($env{'form.ltitools_add_'.$item} ne '') {
- $confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item};
- }
- }
- }
- if ($env{'form.ltitools_add_target'} eq 'window') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
- $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
- } else {
- $confhash{$newid}{'display'}{'target'} = 'iframe';
- }
- foreach my $item ('passback','roster') {
- if ($env{'form.ltitools_add_'.$item}) {
- $confhash{$newid}{$item} = 1;
- }
- }
- if ($env{'form.ltitools_add_image.filename'} ne '') {
- my ($imageurl,$error) =
- &process_ltitools_image($r,$dom,$confname,'ltitools_add_image',$newid,
- $configuserok,$switchserver,$author_ok);
- if ($imageurl) {
- $confhash{$newid}{'image'} = $imageurl;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.'';
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields');
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_add_roles_'.$role};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$newid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$newid}{'roles'}{'co'} = $choice;
- }
- }
- }
- } else {
- $confhash{$newid}{'fields'}{$field} = 1;
- }
- }
- }
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
- foreach my $item (@courseconfig) {
- $confhash{$newid}{'crsconf'}{$item} = 1;
- }
- if ($env{'form.ltitools_add_custom'}) {
- my $name = $env{'form.ltitools_add_custom_name'};
- my $value = $env{'form.ltitools_add_custom_value'};
- $value =~ s/(`)/'/g;
- $name =~ s/(`)/'/g;
- $confhash{$newid}{'custom'}{$name} = $value;
- }
- } else {
- my $error = &mt('Failed to acquire unique ID for new external tool');
- $errors .= ''.$error.'';
- }
- }
- if (ref($domconfig{$action}) eq 'HASH') {
- my %deletions;
- my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del');
- if (@todelete) {
- map { $deletions{$_} = 1; } @todelete;
- }
- my %customadds;
- my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd');
- if (@newcustom) {
- map { $customadds{$_} = 1; } @newcustom;
- }
- my %imgdeletions;
- my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del');
- if (@todeleteimages) {
- map { $imgdeletions{$_} = 1; } @todeleteimages;
- }
- my $maxnum = $env{'form.ltitools_maxnum'};
- for (my $i=0; $i<=$maxnum; $i++) {
- my $itemid = $env{'form.ltitools_id_'.$i};
- $itemid =~ s/\D+//g;
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($deletions{$itemid}) {
- if ($domconfig{$action}{$itemid}{'image'}) {
- #FIXME need to obsolete item in RES space
- }
- $changes{$itemid} = $domconfig{$action}{$itemid}{'title'};
- next;
- } else {
- my $newpos = $env{'form.ltitools_'.$itemid};
- $newpos =~ s/\D+//g;
- foreach my $item ('title','url') {
- $confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- foreach my $item ('key','secret') {
- $encconfig{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if ($domconfig{$action}{$itemid}{$item} ne $encconfig{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
- }
- if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') {
- $confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i};
- }
- if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') {
- $confhash{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i};
- }
- foreach my $size ('width','height') {
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) {
- $confhash{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne $confhash{$itemid}{'display'}{$size}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$size} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- foreach my $item ('linktext','explanation') {
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/^\s+//;
- $env{'form.ltitools_'.$item.'_'.$i} =~ s/\s+$//;
- if ($env{'form.ltitools_'.$item.'_'.$i} ne '') {
- $confhash{$itemid}{'display'}{$item} = $env{'form.ltitools_'.$item.'_'.$i};
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne $confhash{$itemid}{'display'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- } elsif (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{$item} ne '') {
- $changes{$itemid} = 1;
- }
- }
- }
- if ($env{'form.ltitools_target_'.$i} eq 'window') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
- $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
- } else {
- $confhash{$itemid}{'display'}{'target'} = 'iframe';
- }
- if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'display'}{'target'} ne $confhash{$itemid}{'display'}{'target'}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- foreach my $extra ('passback','roster') {
- if ($env{'form.ltitools_'.$extra.'_'.$i}) {
- $confhash{$itemid}{$extra} = 1;
- }
- if ($domconfig{$action}{$itemid}{$extra} ne $confhash{$itemid}{$extra}) {
- $changes{$itemid} = 1;
- }
- }
- my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
- foreach my $item ('label','title','target','linktext','explanation') {
- if (grep(/^\Q$item\E$/,@courseconfig)) {
- $confhash{$itemid}{'crsconf'}{$item} = 1;
- if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'crsconf'}{$item} ne $confhash{$itemid}{'crsconf'}{$item}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
- foreach my $field (@fields) {
- if ($possfield{$field}) {
- if ($field eq 'roles') {
- foreach my $role (@courseroles) {
- my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i};
- if (($choice ne '') && ($posslti{$choice})) {
- $confhash{$itemid}{'roles'}{$role} = $choice;
- if ($role eq 'cc') {
- $confhash{$itemid}{'roles'}{'co'} = $choice;
- }
- }
- if (ref($domconfig{$action}{$itemid}{'roles'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'roles'}{$role} ne $confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- } elsif ($confhash{$itemid}{'roles'}{$role}) {
- $changes{$itemid} = 1;
- }
- }
- } else {
- $confhash{$itemid}{'fields'}{$field} = 1;
- if (ref($domconfig{$action}{$itemid}{'fields'}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'fields'}{$field} ne $confhash{$itemid}{'fields'}{$field}) {
- $changes{$itemid} = 1;
- }
- } else {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- $allpos[$newpos] = $itemid;
- }
- if ($imgdeletions{$itemid}) {
- $changes{$itemid} = 1;
- #FIXME need to obsolete item in RES space
- } elsif ($env{'form.ltitools_image_'.$i.'.filename'}) {
- my ($imgurl,$error) = &process_ltitools_image($r,$dom,$confname,'ltitools_image_'.$i,
- $itemid,$configuserok,$switchserver,
- $author_ok);
- if ($imgurl) {
- $confhash{$itemid}{'image'} = $imgurl;
- $changes{$itemid} = 1;
- }
- if ($error) {
- &Apache::lonnet::logthis($error);
- $errors .= ''.$error.'';
- }
- } elsif ($domconfig{$action}{$itemid}{'image'}) {
- $confhash{$itemid}{'image'} =
- $domconfig{$action}{$itemid}{'image'};
- }
- if ($customadds{$i}) {
- my $name = $env{'form.ltitools_custom_name_'.$i};
- $name =~ s/(`)/'/g;
- $name =~ s/^\s+//;
- $name =~ s/\s+$//;
- my $value = $env{'form.ltitools_custom_value_'.$i};
- $value =~ s/(`)/'/g;
- $value =~ s/^\s+//;
- $value =~ s/\s+$//;
- if ($name ne '') {
- $confhash{$itemid}{'custom'}{$name} = $value;
- $changes{$itemid} = 1;
- }
- }
- my %customdels;
- my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i);
- if (@customdeletions) {
- $changes{$itemid} = 1;
- }
- map { $customdels{$_} = 1; } @customdeletions;
- if (ref($domconfig{$action}{$itemid}{'custom'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}{'custom'}})) {
- unless ($customdels{$key}) {
- if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') {
- $confhash{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i};
- }
- if ($domconfig{$action}{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) {
- $changes{$itemid} = 1;
- }
- }
- }
- }
- unless ($changes{$itemid}) {
- foreach my $key (keys(%{$domconfig{$action}{$itemid}})) {
- if (ref($domconfig{$action}{$itemid}{$key}) eq 'HASH') {
- if (ref($confhash{$itemid}{$key}) eq 'HASH') {
- foreach my $innerkey (keys(%{$domconfig{$action}{$itemid}{$key}})) {
- unless (exists($confhash{$itemid}{$key}{$innerkey})) {
- $changes{$itemid} = 1;
- last;
- }
- }
- } elsif (keys(%{$domconfig{$action}{$itemid}{$key}}) > 0) {
- $changes{$itemid} = 1;
- }
- }
- last if ($changes{$itemid});
- }
- }
- }
- }
- }
- if (@allpos > 0) {
- my $idx = 0;
- foreach my $itemid (@allpos) {
- if ($itemid ne '') {
- $confhash{$itemid}{'order'} = $idx;
- if (ref($domconfig{$action}) eq 'HASH') {
- if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
- if ($domconfig{$action}{$itemid}{'order'} ne $idx) {
- $changes{$itemid} = 1;
- }
- }
- }
- $idx ++;
- }
- }
- }
- my %ltitoolshash = (
- $action => { %confhash }
- );
- my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash,
- $dom);
- if ($putresult eq 'ok') {
- my %ltienchash = (
- $action => { %encconfig }
- );
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);
- if (keys(%changes) > 0) {
- my $cachetime = 24*60*60;
- my %ltiall = %confhash;
- foreach my $id (keys(%ltiall)) {
- if (ref($encconfig{$id}) eq 'HASH') {
- foreach my $item ('key','secret') {
- $ltiall{$id}{$item} = $encconfig{$id}{$item};
- }
- }
- }
- &Apache::lonnet::do_cache_new('ltitools',$dom,\%ltiall,$cachetime);
- if (ref($lastactref) eq 'HASH') {
- $lastactref->{'ltitools'} = 1;
- }
- $resulttext = &mt('Changes made:').'';
- my %bynum;
- foreach my $itemid (sort(keys(%changes))) {
- my $position = $confhash{$itemid}{'order'};
- $bynum{$position} = $itemid;
- }
- foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
- my $itemid = $bynum{$pos};
- if (ref($confhash{$itemid}) ne 'HASH') {
- $resulttext .= '- '.&mt('Deleted: [_1]',$changes{$itemid}).'
';
- } else {
- $resulttext .= '- '.$confhash{$itemid}{'title'}.'';
- if ($confhash{$itemid}{'image'}) {
- $resulttext .= ' '.
- '';
- }
- $resulttext .= '
';
- my $position = $pos + 1;
- $resulttext .= '- '.&mt('Order: [_1]',$position).'
';
- foreach my $item ('version','msgtype','url') {
- if ($confhash{$itemid}{$item} ne '') {
- $resulttext .= '- '.$lt{$item}.': '.$confhash{$itemid}{$item}.'
';
- }
- }
- if ($encconfig{$itemid}{'key'} ne '') {
- $resulttext .= '- '.$lt{'key'}.': '.$encconfig{$itemid}{'key'}.'
';
- }
- if ($encconfig{$itemid}{'secret'} ne '') {
- $resulttext .= '- '.$lt{'secret'}.': ';
- my $num = length($encconfig{$itemid}{'secret'});
- $resulttext .= ('*'x$num).'
';
- }
- $resulttext .= '- '.&mt('Configurable in course:');
- my @possconfig = ('label','title','target','linktext','explanation');
- my $numconfig = 0;
- if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') {
- foreach my $item (@possconfig) {
- if ($confhash{$itemid}{'crsconf'}{$item}) {
- $numconfig ++;
- $resulttext .= ' "'.$lt{'crs'.$item}.'"';
- }
- }
- }
- if (!$numconfig) {
- $resulttext .= &mt('None');
- }
- $resulttext .= '
';
- foreach my $item ('passback','roster') {
- $resulttext .= '- '.$lt{$item}.' ';
- if ($confhash{$itemid}{$item}) {
- $resulttext .= &mt('Yes');
- } else {
- $resulttext .= &mt('No');
- }
- $resulttext .= '
';
- }
- if (ref($confhash{$itemid}{'display'}) eq 'HASH') {
- my $displaylist;
- if ($confhash{$itemid}{'display'}{'target'}) {
- $displaylist = &mt('Display target').': '.
- $confhash{$itemid}{'display'}{'target'}.',';
- }
- foreach my $size ('width','height') {
- if ($confhash{$itemid}{'display'}{$size}) {
- $displaylist .= (' 'x2).$lt{$size}.': '.
- $confhash{$itemid}{'display'}{$size}.',';
- }
- }
- if ($displaylist) {
- $displaylist =~ s/,$//;
- $resulttext .= '- '.$displaylist.'
';
- }
- foreach my $item ('linktext','explanation') {
- if ($confhash{$itemid}{'display'}{$item}) {
- $resulttext .= '- '.$lt{$item}.': '.$confhash{$itemid}{'display'}{$item}.'
';
- }
- }
- }
- if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
- my $fieldlist;
- foreach my $field (@allfields) {
- if ($confhash{$itemid}{'fields'}{$field}) {
- $fieldlist .= (' 'x2).$lt{$field}.',';
- }
- }
- if ($fieldlist) {
- $fieldlist =~ s/,$//;
- $resulttext .= '- '.&mt('Data sent').':'.$fieldlist.'
';
- }
- }
- if (ref($confhash{$itemid}{'roles'}) eq 'HASH') {
- my $rolemaps;
- foreach my $role (@courseroles) {
- if ($confhash{$itemid}{'roles'}{$role}) {
- $rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='.
- $confhash{$itemid}{'roles'}{$role}.',';
- }
- }
- if ($rolemaps) {
- $rolemaps =~ s/,$//;
- $resulttext .= '- '.&mt('Role mapping:').$rolemaps.'
';
- }
- }
- if (ref($confhash{$itemid}{'custom'}) eq 'HASH') {
- my $customlist;
- if (keys(%{$confhash{$itemid}{'custom'}})) {
- foreach my $key (sort(keys(%{$confhash{$itemid}{'custom'}}))) {
- $customlist .= $key.':'.$confhash{$itemid}{'custom'}{$key}.(' 'x2);
- }
- }
- if ($customlist) {
- $resulttext .= '- '.&mt('Custom items').':'.$customlist.'
';
- }
- }
- $resulttext .= ' ';
- }
- }
- $resulttext .= ' ';
- } else {
- $resulttext = &mt('No changes made.');
- }
- } else {
- $errors .= ''.&mt('Failed to save changes').'';
- }
- if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
- }
- return $resulttext;
-}
-
-sub process_ltitools_image {
- my ($r,$dom,$confname,$caller,$itemid,$configuserok,$switchserver,$author_ok) = @_;
- my $filename = $env{'form.'.$caller.'.filename'};
- my ($error,$url);
- my ($width,$height) = (21,21);
- if ($configuserok eq 'ok') {
- if ($switchserver) {
- $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
- $switchserver);
- } elsif ($author_ok eq 'ok') {
- my ($result,$imageurl,$madethumb) =
- &publishlogo($r,'upload',$caller,$dom,$confname,
- "ltitools/$itemid/icon",$width,$height);
- if ($result eq 'ok') {
- if ($madethumb) {
- my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
- my $imagethumb = "$path/tn-".$imagefile;
- $url = $imagethumb;
- } else {
- $url = $imageurl;
- }
- } else {
- $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
- }
- } else {
- $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok);
- }
- } else {
- $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok);
- }
- return ($url,$error);
-}
-
-sub get_ltitools_id {
- my ($cdom,$title) = @_;
- # get lock on ltitools db
- my $lockhash = {
- lock => $env{'user.name'}.
- ':'.$env{'user.domain'},
- };
- my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- my ($id,$error);
-
- while (($gotlock ne 'ok') && ($tries<10)) {
- $tries ++;
- sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- }
- if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
- if ($currids{'lock'}) {
- delete($currids{'lock'});
- if (keys(%currids)) {
- my @curr = sort { $a <=> $b } keys(%currids);
- if ($curr[-1] =~ /^\d+$/) {
- $id = 1 + $curr[-1];
- }
- } else {
- $id = 1;
- }
- if ($id) {
- unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
- $error = 'nostore';
- }
- } else {
- $error = 'nonumber';
- }
- }
- my $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
- } else {
- $error = 'nolock';
- }
- return ($id,$error);
-}
-
sub modify_autoenroll {
my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%changes);
@@ -10550,57 +9305,17 @@ sub modify_contacts {
my $value = $env{'form.helpform_'.$field};
$value =~ s/^\s+|\s+$//g;
if (grep(/^\Q$value\E$/,@{$possoptions->{$field}})) {
- $contacts_hash{'contacts'}{'helpform'}{$field} = $value;
+ $contacts_hash{contacts}{'helpform'}{$field} = $value;
if ($field eq 'screenshot') {
$env{'form.helpform_maxsize'} =~ s/^\s+|\s+$//g;
if ($env{'form.helpform_maxsize'} =~ /^\d+\.?\d*$/) {
- $contacts_hash{'contacts'}{'helpform'}{'maxsize'} = $env{'form.helpform_maxsize'};
+ $contacts_hash{contacts}{'helpform'}{'maxsize'} = $env{'form.helpform_maxsize'};
}
}
}
}
}
}
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my (@statuses,%usertypeshash,@overrides);
- if ((ref($types) eq 'ARRAY') && (@{$types} > 0)) {
- @statuses = @{$types};
- if (ref($usertypes) eq 'HASH') {
- %usertypeshash = %{$usertypes};
- }
- }
- if (@statuses) {
- my @possoverrides = &Apache::loncommon::get_env_multiple('form.overrides');
- foreach my $type (@possoverrides) {
- if (($type ne '') && (grep(/^\Q$type\E$/,@statuses))) {
- push(@overrides,$type);
- }
- }
- if (@overrides) {
- foreach my $type (@overrides) {
- my @standard = &Apache::loncommon::get_env_multiple('form.override_'.$type);
- foreach my $item (@contacts) {
- if (grep(/^\Q$item\E$/,@standard)) {
- $contacts_hash{'contacts'}{'overrides'}{$type}{$item} = 1;
- $newsetting{'override_'.$type}{$item} = 1;
- } else {
- $contacts_hash{'contacts'}{'overrides'}{$type}{$item} = 0;
- $newsetting{'override_'.$type}{$item} = 0;
- }
- }
- $contacts_hash{'contacts'}{'overrides'}{$type}{'others'} = $env{'form.override_'.$type.'_others'};
- $contacts_hash{'contacts'}{'overrides'}{$type}{'bcc'} = $env{'form.override_'.$type.'_bcc'};
- $newsetting{'override_'.$type}{'others'} = $env{'form.override_'.$type.'_others'};
- $newsetting{'override_'.$type}{'bcc'} = $env{'form.override_'.$type.'_bcc'};
- if (($env{'form.override_'.$type.'_includestr'} ne '') && ($env{'form.override_'.$type.'_includeloc'} =~ /^s|b$/)) {
- $includestr{$type} = $env{'form.override_'.$type.'_includestr'};
- $includeloc{$type} = $env{'form.override_'.$type.'_includeloc'};
- $contacts_hash{'contacts'}{'overrides'}{$type}{'include'} = $includeloc{$type}.':'.&escape($includestr{$type});
- $newsetting{'override_'.$type}{'include'} = $contacts_hash{'contacts'}{'overrides'}{$type}{'include'};
- }
- }
- }
- }
if (keys(%currsetting) > 0) {
foreach my $item (@contacts) {
if ($to{$item} ne $currsetting{$item}) {
@@ -10655,33 +9370,6 @@ sub modify_contacts {
}
}
}
- if (@statuses) {
- if (ref($currsetting{'overrides'}) eq 'HASH') {
- foreach my $key (keys(%{$currsetting{'overrides'}})) {
- if (ref($currsetting{'overrides'}{$key}) eq 'HASH') {
- if (ref($newsetting{'override_'.$key}) eq 'HASH') {
- foreach my $item (@contacts,'bcc','others','include') {
- if ($currsetting{'overrides'}{$key}{$item} ne $newsetting{'override_'.$key}{$item}) {
- push(@{$changes{'overrides'}},$key);
- last;
- }
- }
- } else {
- push(@{$changes{'overrides'}},$key);
- }
- }
- }
- foreach my $key (@overrides) {
- unless (exists($currsetting{'overrides'}{$key})) {
- push(@{$changes{'overrides'}},$key);
- }
- }
- } else {
- foreach my $key (@overrides) {
- push(@{$changes{'overrides'}},$key);
- }
- }
- }
} else {
my %default;
$default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
@@ -10796,60 +9484,6 @@ sub modify_contacts {
$resulttext .= '';
}
}
- if (ref($changes{'overrides'}) eq 'ARRAY') {
- my @deletions;
- foreach my $type (@{$changes{'overrides'}}) {
- if ($usertypeshash{$type}) {
- if (grep(/^\Q$type\E/,@overrides)) {
- $resulttext .= ''.&mt("Overrides based on requester's affiliation set for [_1]",
- $usertypeshash{$type}).'- ';
- if (ref($newsetting{'override_'.$type}) eq 'HASH') {
- my @text;
- foreach my $item (@contacts) {
- if ($newsetting{'override_'.$type}{$item}) {
- push(@text,$short_titles->{$item});
- }
- }
- if ($newsetting{'override_'.$type}{'others'} ne '') {
- push(@text,$newsetting{'override_'.$type}{'others'});
- }
-
- if (@text) {
- $resulttext .= &mt('Helpdesk e-mail sent to: [_1]',
- ''.join(', ',@text).'');
- }
- if ($newsetting{'override_'.$type}{'bcc'} ne '') {
- my $bcctext;
- if (@text) {
- $bcctext = ' '.&mt('with Bcc to');
- } else {
- $bcctext = '(Bcc)';
- }
- $resulttext .= $bcctext.': '.$newsetting{'override_'.$type}{'bcc'}.'';
- } elsif (!@text) {
- $resulttext .= &mt('Helpdesk e-mail sent to no one');
- }
- $resulttext .= '
';
- if ($newsetting{'override_'.$type}{'include'} ne '') {
- my ($loc,$str) = split(/:/,$newsetting{'override_'.$type}{'include'});
- if ($loc eq 'b') {
- $resulttext .= '- '.&mt('Text automatically added to e-mail body:').' '.&unescape($str).'
';
- } elsif ($loc eq 's') {
- $resulttext .= '- '.&mt('Text automatically added to e-mail subject:').' '.&unescape($str).'
';
- }
- }
- }
- $resulttext .= ' ';
- } else {
- push(@deletions,$usertypeshash{$type});
- }
- }
- }
- if (@deletions) {
- $resulttext .= ''.&mt("Overrides based on requester's affiliation discontinued for: [_1]",
- join(', ',@deletions)).'';
- }
- }
my @offon = ('off','on');
if ($changes{'reporterrors'}) {
$resulttext .= ''.
@@ -10905,6 +9539,7 @@ sub modify_contacts {
&mt('Max size for file uploaded to help form by logged-in user set to [_1] MB.',
$contacts_hash{'contacts'}{'helpform'}{'maxsize'}).
'';
+
}
}
$resulttext .= '';
@@ -14934,7 +13569,7 @@ sub devalidate_remote_domconfs {
my %servers = &Apache::lonnet::internet_dom_servers($dom);
my %thismachine;
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
- my @posscached = ('domainconfig','domdefaults','ltitools','usersessions','directorysrch');
+ my @posscached = ('domainconfig','domdefaults','usersessions','directorysrch');
if (keys(%servers)) {
foreach my $server (keys(%servers)) {
next if ($thismachine{$server});
|
|