'.$titles{'numsaved'}.' | '.
''.
'{'instdata'};
+ my %instdata;
+ if (ref($settings->{'instdata'}) eq 'ARRAY') {
+ map { $instdata{$_} = 1; } @{$settings->{'instdata'}};
+ }
+ $hashref = \%instdata;
}
} elsif ($context eq 'privacy') {
my ($key,$inner) = split(/_/,$role);
@@ -12015,7 +12051,7 @@ sub modifiable_userdata_row {
}
} elsif (ref($settings->{$context}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
- $hashref = $settings->{'lti_instdata'};
+ $hashref = $settings->{$context}->{$role};
}
if ($role eq 'emailusername') {
if ($statustype) {
@@ -12096,6 +12132,8 @@ sub modifiable_userdata_row {
} else {
if ($context eq 'lti') {
$prefix = 'lti';
+ } elsif ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
} elsif ($context eq 'privacy') {
$prefix = 'privacy';
}
@@ -12988,7 +13026,6 @@ sub check_exempt_addresses {
sub color_font_choices {
my %choices =
&Apache::lonlocal::texthash (
- img => "Header",
bgs => "Background colors",
links => "Link colors",
images => "Images",
@@ -13043,13 +13080,15 @@ sub modify_ipaccess {
foreach my $idx (@items) {
my $itemid = $itemids{$idx};
next unless ($itemid);
- my %current;
- unless ($idx eq 'add') {
+ my ($position,%current);
+ if ($idx eq 'add') {
+ $position = $env{'form.ipaccess_pos_add'};
+ } else {
+ $position = $env{'form.ipaccess_pos_'.$itemid};
if (ref($domconfig{'ipaccess'}{$itemid}) eq 'HASH') {
%current = %{$domconfig{'ipaccess'}{$itemid}};
}
}
- my $position = $env{'form.ipaccess_pos_'.$itemid};
$position =~ s/\D+//g;
if ($position ne '') {
$allpos[$position] = $itemid;
@@ -13300,13 +13339,15 @@ sub modify_authordefaults {
'copyright' => 'default',
'sourceavail' => 'closed',
'nocodemirror' => 'off',
+ 'daxecollapse' => 'off',
'domcoordacc' => 'on',
- 'editors' => ['edit','xml'].
+ 'editors' => ['edit','xml'],
'authorquota' => 500,
'webdav' => 0,
+ 'archive' => 'off',
);
my %titles = &authordefaults_titles();
- foreach my $item ('nocodemirror','domcoordacc') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','archive') {
if ($env{'form.'.$item} =~ /^(0|1)$/) {
$confhash{$item} = $env{'form.'.$item};
}
@@ -13326,7 +13367,7 @@ sub modify_authordefaults {
}
}
$confhash{'editors'} = \@editors;
-
+
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my @insttypes;
if (ref($types) eq 'ARRAY') {
@@ -13350,13 +13391,13 @@ sub modify_authordefaults {
$save_quotas{'webdav'}{'_LC_adv'} = $env{'form.webdav_LC_adv'};
}
if (ref($domconfig{'authordefaults'}) eq 'HASH') {
- foreach my $item ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail','archive') {
if ($domconfig{'authordefaults'}{$item} ne $confhash{$item}) {
$changes{$item} = 1;
}
}
if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') {
- my @diffs =
+ my @diffs =
&Apache::loncommon::compare_arrays($confhash{'editors'},
$domconfig{'authordefaults'}{'editors'});
unless (@diffs == 0) {
@@ -13372,8 +13413,8 @@ sub modify_authordefaults {
}
} else {
my @offon = ('off','on');
- foreach my $item ('nocodemirror','domcoordacc') {
- if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','archive') {
+ if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
$changes{$item} = 1;
}
}
@@ -13382,6 +13423,12 @@ sub modify_authordefaults {
$changes{$item} = 1;
}
}
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $staticdefaults{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
}
foreach my $key ('authorquota','webdav') {
if (ref($curr_quotas{$key}) eq 'HASH') {
@@ -13410,7 +13457,7 @@ sub modify_authordefaults {
}
if (ref($curr_quotas{'webdav'}) eq 'HASH') {
if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
- if ($save_quotas{'webdav'}{'_LC_adv'} ne $curr_quotas{'webdav'}{'_LC_adv'}) {
+ if ($save_quotas{'webdav'}{'_LC_adv'} ne $curr_quotas{'webdav'}{'_LC_adv'}) {
$changes{'webdav_LC_adv'} = 1;
}
} elsif (exists($curr_quotas{'webdav'}{'_LC_adv'})) {
@@ -13430,7 +13477,7 @@ sub modify_authordefaults {
if (keys(%changes)) {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
if ((exists($changes{'authorquota'})) || (exists($changes{'webdav'})) ||
- ($changes{'webdav_LC_adv'})) {
+ ($changes{'webdav_LC_adv'})) {
if ((exists($changes{'authorquota'})) && (ref($save_quotas{'authorquota'}) eq 'HASH')) {
$domdefaults{'authorquota'} = $save_quotas{'authorquota'};
}
@@ -13441,7 +13488,7 @@ sub modify_authordefaults {
}
$resulttext = &mt('Changes made:').'';
my $authoroverride;
- foreach my $key ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ foreach my $key ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail') {
if (exists($changes{$key})) {
$domdefaults{$key} = $confhash{$key};
my $shown;
@@ -13449,21 +13496,21 @@ sub modify_authordefaults {
$resulttext .= '- '.&mt('Defaults which can be overridden by Author').'
';
$authoroverride = 1;
}
- if (($key eq 'nocodemirror') || ($key eq 'domcoordacc')) {
+ if (($key eq 'nocodemirror') || ($key eq 'daxecollapse') || ($key eq 'domcoordacc')) {
$shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
} elsif ($key eq 'copyright') {
$shown = &Apache::loncommon::copyrightdescription($confhash{$key});
} elsif ($key eq 'sourceavail') {
$shown = &Apache::loncommon::source_copyrightdescription($confhash{$key});
}
- $resulttext .= '- '.&mt('[_1] set to: [_2]',$titles{$key},$shown).'
';
+ $resulttext .= '- '.&mt('[_1] set to: [_2]',$titles{$key},$shown).'
';
}
}
if ($authoroverride) {
$resulttext .= ' ';
}
my $domcoordoverride;
- foreach my $key ('editors','authorquota','webdav','webdav_LC_adv') {
+ foreach my $key ('editors','authorquota','webdav','webdav_LC_adv','archive') {
if (exists($changes{$key})) {
my $shown;
unless ($domcoordoverride) {
@@ -13495,13 +13542,17 @@ sub modify_authordefaults {
} else {
$shown = $titles{'none'};
}
+ } elsif ($key eq 'archive') {
+ $domdefaults{$key} = $confhash{$key};
+ $shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
}
$resulttext .= '- '.&mt('[_1] set to: [_2]',$titles{$key},$shown).'
';
- }
+ }
}
if ($domcoordoverride) {
$resulttext .= ' ';
}
+ $resulttext .= '';
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -13570,11 +13621,15 @@ sub modify_colors {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
- @images = ('img');
+ @images = ();
@bgs = ('pgbg','tabbg','sidebg');
}
my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
- unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $env{'form.'.$role.'_font'} = lc($env{'form.'.$role.'_font'});
+ if ($env{'form.'.$role.'_font'} =~ /^\w+/) {
+ $env{'form.'.$role.'_font'} = '#'.$env{'form.'.$role.'_font'};
+ }
+ unless ($env{'form.'.$role.'_font'} eq lc($defaults{'font'})) {
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
}
if ($role eq 'login') {
@@ -13592,7 +13647,7 @@ sub modify_colors {
if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
$env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
}
- unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
+ unless ($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
$confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
}
@@ -14705,6 +14760,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.'').'';
}
+ $resulttext .= '';
}
}
}
@@ -15016,7 +15072,6 @@ sub lti_security_results {
off => &mt('Encryption of stored external tool secrets defined in domain disabled'),
},
);
-
}
my @types= ('crs','dom');
if ($context eq 'lti') {
@@ -15112,6 +15167,28 @@ sub lti_security_results {
}
} elsif ($item eq 'linkprot') {
next;
+ } elsif ($item eq 'suggested') {
+ if ((ref($secchanges->{'suggested'}) eq 'HASH') &&
+ (ref($newsec->{'suggested'}) eq 'HASH')) {
+ my $suggestions;
+ foreach my $id (sort { $a <=> $b } keys(%{$secchanges->{'suggested'}})) {
+ if (ref($newsec->{'suggested'}->{$id}) eq 'HASH') {
+ my $name = $newsec->{'suggested'}->{$id}->{'name'};
+ my $info = $newsec->{'suggested'}->{$id}->{'info'};
+ $suggestions .= ''.&mt('Launcher: [_1]',$name).' '.
+ &mt('Recommend: [_1]',''.$info.' ').
+ '';
+ } else {
+ $suggestions .= ''.&mt('Recommendations deleted for Launcher: [_1]',
+ $newsec->{'suggested'}->{$id}).'';
+ }
+ }
+ if ($suggestions) {
+ $output .= ''.&mt('Hints in Courses for Link Protector Configuration').
+ ''.
+ '';
+ }
+ }
}
}
if ($needs_update) {
@@ -15716,7 +15793,7 @@ sub modify_lti {
}
}
if (ref($currltisec{'linkprot'}) eq 'HASH') {
- foreach my $id (%{$currltisec{'linkprot'}}) {
+ foreach my $id (keys(%{$currltisec{'linkprot'}})) {
next if ($id !~ /^\d+$/);
unless (exists($linkprotchg{$id})) {
if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') {
@@ -15738,17 +15815,75 @@ sub modify_lti {
if ($proterror) {
$errors .= ''.$proterror.'';
}
+
+ my (%delsuggested,%suggids,@suggested);;
+ if (ref($currltisec{'suggested'}) eq 'HASH') {
+ my $maxnum = $env{'form.linkprot_suggested_maxnum'};
+ my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_suggested_del');
+ for (my $i=0; $i<$maxnum; $i++) {
+ my $itemid = $env{'form.linkprot_suggested_id_'.$i};
+ $itemid =~ s/\D+//g;
+ if ($itemid) {
+ if (ref($currltisec{'suggested'}->{$itemid}) eq 'HASH') {
+ push(@suggested,$i);
+ $suggids{$i} = $itemid;
+ if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
+ if (ref($currltisec{'suggested'}{$itemid}) eq 'HASH') {
+ $delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'};
+ }
+ } else {
+ if ($env{'form.linkprot_suggested_name_'.$i} eq '') {
+ $delsuggested{$itemid} = $currltisec{'suggested'}{$itemid}{'name'};
+ } else {
+ $env{'form.linkprot_suggested_name_'.$i} =~ s/(`)/'/g;
+ $env{'form.linkprot_suggested_info_'.$i} =~ s/(`)/'/g;
+ $newltisec{'suggested'}{$itemid}{'name'} = $env{'form.linkprot_suggested_name_'.$i};
+ $newltisec{'suggested'}{$itemid}{'info'} = $env{'form.linkprot_suggested_info_'.$i};
+ if (($currltisec{'suggested'}{$itemid}{'name'} ne $newltisec{'suggested'}{$itemid}{'name'}) ||
+ ($currltisec{'suggested'}{$itemid}{'info'} ne $newltisec{'suggested'}{$itemid}{'info'})) {
+ $secchanges{'suggested'}{$itemid} = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ foreach my $key (keys(%delsuggested)) {
+ $newltisec{'suggested'}{$key} = $delsuggested{$key};
+ $secchanges{'suggested'}{$key} = 1;
+ }
+ if (($env{'form.linkprot_suggested_add'}) &&
+ ($env{'form.linkprot_suggested_name_add'} ne '')) {
+ $env{'form.linkprot_suggested_name_add'} =~ s/(`)/'/g;
+ $env{'form.linkprot_suggested_info_add'} =~ s/(`)/'/g;
+ my ($newsuggid,$errormsg) = &get_lti_id($dom,$env{'form.linkprot_suggested_name_add'},'suggested');
+ if ($newsuggid) {
+ $newltisec{'suggested'}{$newsuggid}{'name'} = $env{'form.linkprot_suggested_name_add'};
+ $newltisec{'suggested'}{$newsuggid}{'info'} = $env{'form.linkprot_suggested_info_add'};
+ $secchanges{'suggested'}{$newsuggid} = 1;
+ } else {
+ my $error = &mt('Failed to acquire unique ID for new Link Protectors in Courses Suggestion');
+ if ($errormsg) {
+ $error .= ' ('.$errormsg.')';
+ }
+ $errors .= ''.$error.'';
+ }
+ }
my (@items,%deletions,%itemids);
if ($env{'form.lti_add'}) {
my $consumer = $env{'form.lti_consumer_add'};
$consumer =~ s/(`)/'/g;
- ($newid,my $error) = &get_lti_id($dom,$consumer);
+ ($newid,my $errormsg) = &get_lti_id($dom,$consumer,'lti');
if ($newid) {
$itemids{'add'} = $newid;
push(@items,'add');
$changes{$newid} = 1;
} else {
my $error = &mt('Failed to acquire unique ID for new LTI configuration');
+ if ($errormsg) {
+ $error .= ' ('.$errormsg.')';
+ }
$errors .= ''.$error.'';
}
}
@@ -15852,9 +15987,9 @@ sub modify_lti {
}
my @possinstdata = &Apache::loncommon::get_env_multiple('form.lti_instdata_'.$idx);
if (@possinstdata) {
- foreach my $field (@possinstdata) {
+ foreach my $field (sort(@possinstdata)) {
if (exists($fieldtitles{$field})) {
- push(@{$confhash{$itemid}{'instdata'}});
+ push(@{$confhash{$itemid}{'instdata'}},$field);
}
}
}
@@ -16016,7 +16151,7 @@ sub modify_lti {
}
}
unless ($changes{$itemid}) {
- foreach my $field ('makeuser','lcmenu') {
+ foreach my $field ('makeuser','lcmenu','instdata') {
if (ref($currlti{$field}) eq 'ARRAY') {
if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
@@ -16230,8 +16365,10 @@ sub modify_lti {
$resulttext .= ''.&mt('Institutional data will be used when creating a new user for: [_1]',
join(', ',map { $fieldtitles{$_}; } @{$confhash{$itemid}{'instdata'}})).'';
} else {
- $resulttext .= ''.&mt('No institutional data used when creating a new user.').'';
+ $resulttext .= ''.&mt('No institutional data used when creating a new user').'';
}
+ } else {
+ $resulttext .= ''.&mt('No institutional data used when creating a new user').'';
}
foreach my $item ('topmenu','inlinemenu') {
$resulttext .= ''.$lt{$item}.': ';
@@ -16342,7 +16479,8 @@ sub modify_lti {
}
$resulttext .= '';
if (ref($lastactref) eq 'HASH') {
- if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
+ if (($secchanges{'encrypt'}) || ($secchanges{'private'}) || (exists($secchanges{'suggested'}))) {
+ &Apache::lonnet::get_domain_defaults($dom,1);
$lastactref->{'domdefaults'} = 1;
}
}
@@ -16381,23 +16519,26 @@ sub get_priv_creds {
}
sub get_lti_id {
- my ($domain,$consumer) = @_;
- # get lock on lti db
+ my ($domain,$consumer,$dbname) = @_;
+ unless (($dbname eq 'lti') || ($dbname eq 'suggested')) {
+ return ('','invalid db');
+ }
+ # get lock on db
my $lockhash = {
lock => $env{'user.name'}.
':'.$env{'user.domain'},
};
my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain);
+ my $gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain);
my ($id,$error);
while (($gotlock ne 'ok') && ($tries<10)) {
$tries ++;
sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('lti',$lockhash,$domain);
+ $gotlock = &Apache::lonnet::newput_dom($dbname,$lockhash,$domain);
}
if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('lti',$domain);
+ my %currids = &Apache::lonnet::dump_dom($dbname,$domain);
if ($currids{'lock'}) {
delete($currids{'lock'});
if (keys(%currids)) {
@@ -16409,14 +16550,14 @@ sub get_lti_id {
$id = 1;
}
if ($id) {
- unless (&Apache::lonnet::newput_dom('lti',{ $id => $consumer },$domain) eq 'ok') {
+ unless (&Apache::lonnet::newput_dom($dbname,{ $id => $consumer },$domain) eq 'ok') {
$error = 'nostore';
}
} else {
$error = 'nonumber';
}
}
- my $dellockoutcome = &Apache::lonnet::del_dom('lti',['lock'],$domain);
+ my $dellockoutcome = &Apache::lonnet::del_dom($dbname,['lock'],$domain);
} else {
$error = 'nolock';
}
@@ -17689,8 +17830,6 @@ sub modify_privacy {
extdom => {},
},
'othdom' => {},
- 'priv' => {},
- 'unpriv' => {},
);
foreach my $item (@items) {
if (@instdoms > 1) {
@@ -17721,39 +17860,6 @@ sub modify_privacy {
$changes{'approval'} = 1;
}
}
- foreach my $status ('priv','unpriv') {
- my @possibles = sort(&Apache::loncommon::get_env_multiple('form.privacy_'.$status.'_'.$item));
- my @newvalues;
- foreach my $field (@possibles) {
- if (grep(/^\Q$field\E$/,@fields)) {
- $privacyhash{$status}{$item}{$field} = 1;
- push(@newvalues,$field);
- }
- }
- @newvalues = sort(@newvalues);
- if (ref($current{$status}) eq 'HASH') {
- if (ref($current{$status}{$item}) eq 'HASH') {
- my @currvalues = sort(keys(%{$current{$status}{$item}}));
- my @diffs = &Apache::loncommon::compare_arrays(\@currvalues,\@newvalues);
- if (@diffs > 0) {
- $changes{$status} = 1;
- }
- }
- } else {
- my @stdfields;
- foreach my $field (@fields) {
- if ($field eq 'id') {
- next if ($status eq 'unpriv');
- next if (($status eq 'priv') && ($item eq 'community'));
- }
- push(@stdfields,$field);
- }
- my @diffs = &Apache::loncommon::compare_arrays(\@stdfields,\@newvalues);
- if (@diffs > 0) {
- $changes{$status} = 1;
- }
- }
- }
}
if ((@instdoms > 1) || (keys(%by_location) > 0)) {
my @statuses;
@@ -17777,6 +17883,8 @@ sub modify_privacy {
if (@diffs > 0) {
$changes{'othdom'} = 1;
}
+ } elsif (@newvalues > 0) {
+ $changes{'othdom'} = 1;
}
} else {
my @stdfields = ('lastname','firstname','middlename','generation','permanentemail');
@@ -17806,7 +17914,7 @@ sub modify_privacy {
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made: ').'';
- foreach my $key ('approval','notify','othdom','priv','unpriv') {
+ foreach my $key ('approval','notify','othdom') {
if ($changes{$key}) {
$resulttext .= '- '.$titles{$key}.':
';
if ($key eq 'approval') {
@@ -17857,18 +17965,6 @@ sub modify_privacy {
$resulttext .= ' ';
}
}
- } else {
- foreach my $item (@items) {
- if (ref($privacyhash{$key}{$item}) eq 'HASH') {
- $resulttext .= '- '.$names{$item}.': ';
- if (keys(%{$privacyhash{$key}{$item}})) {
- $resulttext .= join(', ', map { $fieldnames{$_}; } (sort(keys(%{$privacyhash{$key}{$item}}))));
- } else {
- $resulttext .= &mt('none');
- }
- $resulttext .= '
';
- }
- }
}
$resulttext .= ' ';
}
@@ -17931,7 +18027,6 @@ sub modify_passwords {
min => 'Minimum password length',
max => 'Maximum password length',
chars => 'Required characters',
- expire => 'Password expiration (days)',
numsaved => 'Number of previous passwords to save',
reset => 'Resetting Forgotten Password',
intauth => 'Encryption of Stored Passwords (Internal Auth)',
@@ -18315,7 +18410,7 @@ sub modify_passwords {
$resulttext .= ''.&mt('[_1] set to "[_2]"',$titles{$key.'_'.$item},$value).'';
}
} elsif ($key eq 'rules') {
- foreach my $rule ('min','max','expire','numsaved') {
+ foreach my $rule ('min','max','numsaved') {
if ($confighash{'passwords'}{$rule} eq '') {
if ($rule eq 'min') {
$resulttext .= ''.&mt('[_1] not set.',$titles{$rule});
@@ -18410,7 +18505,7 @@ sub password_rule_changes {
(ref($changes) eq 'HASH'));
my (@rules,%staticdefaults);
if ($prefix eq 'passwords') {
- @rules = ('min','max','expire','numsaved');
+ @rules = ('min','max','numsaved');
} elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
@rules = ('min','max');
}
@@ -18418,12 +18513,7 @@ sub password_rule_changes {
foreach my $rule (@rules) {
$env{'form.'.$prefix.'_'.$rule} =~ s/^\s+|\s+$//g;
my $ruleok;
- if ($rule eq 'expire') {
- if (($env{'form.'.$prefix.'_'.$rule} =~ /^\d+(|\.\d*)$/) &&
- ($env{'form.'.$prefix.'_'.$rule} ne '0')) {
- $ruleok = 1;
- }
- } elsif ($rule eq 'min') {
+ if ($rule eq 'min') {
if ($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) {
if ($env{'form.'.$prefix.'_'.$rule} >= $staticdefaults{$rule}) {
$ruleok = 1;
@@ -19652,21 +19742,27 @@ sub modify_usermodification {
}
}
}
- my @contexts = ('author','course');
+ my @contexts = ('author','coauthor','course');
my %context_title = (
author => 'In author context',
+ coauthor => 'As co-author manager',
course => 'In course context',
);
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %roles = (
author => ['ca','aa'],
+ coauthor => ['ca','aa'],
course => ['st','ep','ta','in','cr'],
);
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
foreach my $context (@contexts) {
+ my $prefix = 'canmodify';
+ if ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
+ }
foreach my $role (@{$roles{$context}}) {
- my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
+ my @modifiable = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$role);
foreach my $item (@fields) {
if (grep(/^\Q$item\E$/,@modifiable)) {
$modifyhash{$context}{$role}{$item} = 1;
@@ -21046,12 +21142,17 @@ sub modify_coursedefaults {
mysqltables => 172800,
domexttool => 1,
crsauthor => 1,
+ crseditors => ['edit','xml'],
);
my %texoptions = (
MathJax => 'MathJax',
mimetex => &mt('Convert to Images'),
tth => &mt('TeX to HTML'),
);
+
+ my @editors = ('edit','xml','daxe');
+ my %editornames = &crseditor_titles();
+
$defaultshash{'coursedefaults'} = {};
if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
@@ -21237,10 +21338,12 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
- my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor);
+ my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor,
+ %posscrseditors);
map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
map { $newcrsauthor{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crsauthor');
+ map { $posscrseditors{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crseditors');
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
%olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
} else {
@@ -21274,6 +21377,27 @@ sub modify_coursedefaults {
}
}
}
+ my @newcrseditors = ();
+ foreach my $editor (@editors) {
+ if ($posscrseditors{$editor}) {
+ push(@newcrseditors,$editor);
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($domconfig{'coursedefaults'}{'crseditors'},
+ \@newcrseditors);
+ if (@diffs) {
+ $changes{'crseditors'} = 1;
+ }
+ } else {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($staticdefaults{'crseditors'},
+ \@newcrseditors);
+ unless (@diffs == 0) {
+ $changes{'crseditors'} = 1;
+ }
+ }
foreach my $type (@types) {
unless ($newdomexttool{$type}) {
$newdomexttool{$type} = 0;
@@ -21297,6 +21421,7 @@ sub modify_coursedefaults {
$defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
$defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
$defaultshash{'coursedefaults'}{'crsauthor'} = \%newcrsauthor;
+ $defaultshash{'coursedefaults'}{'crseditors'} = \@newcrseditors;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -21380,6 +21505,11 @@ sub modify_coursedefaults {
}
}
}
+ if ($changes{'crseditors'}) {
+ if (ref($defaultshash{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ $domdefaults{'crseditors'}=join(',',@{$defaultshash{'coursedefaults'}{'crseditors'}});
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -21559,6 +21689,16 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.$status{$item}{'default'}.'';
}
+ } elsif ($item eq 'crseditors') {
+ if (ref($defaultshash{'coursedefaults'}{$item}) eq 'ARRAY') {
+ my $shown;
+ if (@{$defaultshash{'coursedefaults'}{$item}}) {
+ $shown = join(', ', map { $editornames{$_} } @{$defaultshash{'coursedefaults'}{$item}});
+ } else {
+ $shown = &mt('None');
+ }
+ $resulttext .= ''.&mt('Available editors for course/community resources: [_1]',$shown).'';
+ }
}
}
$resulttext .= '';
|