';
+ $count ++;
+ $$rowtotal += $count;
+ }
return $datatable;
}
@@ -11704,30 +11795,76 @@ sub modify_helpsettings {
my %defaultchecked = ('submitbugs' => 'on');
my @offon = ('off','on');
my @toggles = ('submitbugs');
+ my %current = ('submitbugs' => '');
if (ref($domconfig{'helpsettings'}) eq 'HASH') {
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '0') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ %current = %{$domconfig{'helpsettings'}};
+ }
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '0') {
$changes{$item} = 1;
}
- } elsif ($defaultchecked{$item} eq 'off') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '1') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '1') {
$changes{$item} = 1;
}
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
}
- if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
- $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ }
+
+ my @modify = &Apache::loncommon::get_env_multiple('form.modifycusthelp');
+ my $confname = $dom.'-domainconfig';
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ if (@modify) {
+ foreach my $num (@modify) {
+ my $rolename = $env{'form.custhelprole'.$num};
+ if ($rolename ne '') {
+ if (exists($existing{'rolesdef_'.$rolename})) {
+ my $prefix = 'custhelp'.$num;
+ my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
+ my %currprivs;
+ ($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) =
+ split(/\_/,$existing{'rolesdef_'.$rolename});
+ foreach my $level ('c','d','s') {
+ if ($newprivs{$level} ne $currprivs{$level}) {
+ $changes{'customrole'}{$rolename} = 1;
+ my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
+ $newprivs{'c'},$confname,$dom);
+ last;
+ }
+ }
+ }
+ }
+ }
+ }
+ if ($env{'form.newcusthelp'} ne '') {
+ my $prefix = 'custhelp'.$env{'form.newcusthelp'};
+ my $rolename = $env{'form.newcusthelpname'};
+ $rolename=~s/[^A-Za-z0-9]//gs;
+ if ($rolename ne '') {
+ unless(exists($existing{'rolesdef_'.$rolename})) {
+ my $errmsg;
+ my $result = &Apache::lonuserutils::store_custom_role($rolename,$prefix,
+ $confname,$dom);
+ if ($result eq 'ok') {
+ $changes{'newcustomrole'} = $rolename;
+ } else {
+ $errmsg = ': '.$result;
+ }
}
}
}
+
my $putresult;
if (keys(%changes) > 0) {
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
@@ -11738,6 +11875,16 @@ sub modify_helpsettings {
$resulttext .= '
'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
&Apache::loncommon::modal_link('http://bugs.loncapa.org',
&mt('LON-CAPA bug tracker'),600,500)).'