[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm

raeburn raeburn at source.lon-capa.org
Mon Jan 23 19:19:17 EST 2017


raeburn		Tue Jan 24 00:19:17 2017 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport  1.286, 1.288, 1.289
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.77 loncom/interface/domainprefs.pm:1.160.6.78
--- loncom/interface/domainprefs.pm:1.160.6.77	Sun Jan 22 13:28:05 2017
+++ loncom/interface/domainprefs.pm	Tue Jan 24 00:19:15 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.77 2017/01/22 13:28:05 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.78 2017/01/24 00:19:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -19,7 +19,8 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with LON-CAPA; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA#
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
 # /home/httpd/html/adm/gpl.txt
 #
 # http://www.lon-capa.org/
@@ -314,10 +315,14 @@
                     modify => \&modify_directorysrch,
                   },
         'contacts' =>
-                  { text => 'Contact Information',
+                  { text => 'E-mail addresses and helpform',
                     help => 'Domain_Configuration_Contact_Info',
-                    header => [{col1 => 'Setting',
-                                col2 => 'Value',}],
+                    header => [{col1 => 'Default e-mail addresses',
+                                col2 => 'Value',},
+                               {col1 => 'Recipient(s) for notifications',
+                                col2 => 'Value',},
+                               {col1 => 'Ask helpdesk form settings',
+                                col2 => 'Value',},],
                     print => \&print_contacts,
                     modify => \&modify_contacts,
                   },
@@ -457,7 +462,7 @@
                   print => \&print_usersessions,
                   modify => \&modify_usersessions,
                  },
-         'loadbalancing' =>
+        'loadbalancing' =>
                  {text  => 'Dedicated Load Balancer(s)',
                   help  => 'Domain_Configuration_Load_Balancing',
                   header => [{col1 => 'Balancers',
@@ -521,6 +526,9 @@
 $coursebrowserjs
 END
         }
+        if (grep(/^contacts$/, at actions)) {
+            $js .= &contacts_javascript();
+        }
         &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
     } else {
 # check if domconfig user exists for the domain.
@@ -705,7 +713,7 @@
         if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
             ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
             ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') ||
-            ($action eq 'helpsettings')) {
+            ($action eq 'helpsettings') || ($action eq 'contacts')) {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
             $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
@@ -735,7 +743,8 @@
             $rowtotal ++;
         if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
             ($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
-            ($action eq 'usersessions') || ($action eq 'coursecategories')) {
+            ($action eq 'usersessions') || ($action eq 'coursecategories') ||
+            ($action eq 'contacts')) {
             if ($action eq 'coursecategories') {
                 $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
                 $colspan = ' colspan="2"';
@@ -919,8 +928,7 @@
         if ($action eq 'quotas') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
         } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || 
-                 ($action eq 'contacts') || ($action eq 'serverstatuses') ||
-                 ($action eq 'loadbalancing')) {
+                 ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) {
             $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
@@ -2783,104 +2791,255 @@
 }
 
 sub print_contacts {
-    my ($dom,$settings,$rowtotal) = @_;
+    my ($position,$dom,$settings,$rowtotal) = @_;
     my $datatable;
     my @contacts = ('adminemail','supportemail');
-    my (%checked,%to,%otheremails,%bccemails);
-    my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
-                    'requestsmail','updatesmail','idconflictsmail');
-    foreach my $type (@mailings) {
-        $otheremails{$type} = '';
-    }
-    $bccemails{'helpdeskmail'} = '';
-    if (ref($settings) eq 'HASH') {
-        foreach my $item (@contacts) {
-            if (exists($settings->{$item})) {
-                $to{$item} = $settings->{$item};
+    my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield,
+        $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions, at mailings);
+    if ($position eq 'top') {
+        if (ref($settings) eq 'HASH') {
+            foreach my $item (@contacts) {
+                if (exists($settings->{$item})) {
+                    $to{$item} = $settings->{$item};
+                }
             }
         }
+    } elsif ($position eq 'middle') {
+        @mailings = ('errormail','packagesmail','lonstatusmail','requestsmail',
+                     'updatesmail','idconflictsmail');
         foreach my $type (@mailings) {
-            if (exists($settings->{$type})) {
-                if (ref($settings->{$type}) eq 'HASH') {
-                    foreach my $item (@contacts) {
-                        if ($settings->{$type}{$item}) {
-                            $checked{$type}{$item} = ' checked="checked" ';
+            $otheremails{$type} = '';
+        }
+    } else {
+        @mailings = ('helpdeskmail','otherdomsmail');
+        foreach my $type (@mailings) {
+            $otheremails{$type} = '';
+        }
+        $bccemails{'helpdeskmail'} = '';
+        $bccemails{'otherdomsmail'} = '';
+        $includestr{'helpdeskmail'} = '';
+        $includestr{'otherdomsmail'} = '';
+        ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
+    }
+    if (ref($settings) eq 'HASH') {
+        unless ($position eq 'top') {
+            foreach my $type (@mailings) {
+                if (exists($settings->{$type})) {
+                    if (ref($settings->{$type}) eq 'HASH') {
+                        foreach my $item (@contacts) {
+                            if ($settings->{$type}{$item}) {
+                                $checked{$type}{$item} = ' checked="checked" ';
+                            }
                         }
+                        $otheremails{$type} = $settings->{$type}{'others'};
+                        if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+                            $bccemails{$type} = $settings->{$type}{'bcc'};
+                            if ($settings->{$type}{'include'} ne '') {
+                                ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+                                $includestr{$type} = &unescape($includestr{$type});
+                            }
+                        }
+                    }
+                } elsif ($type eq 'lonstatusmail') {
+                    $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+                }
+            }
+        }
+        if ($position eq 'bottom') {
+            foreach my $type (@mailings) {
+                $bccemails{$type} = $settings->{$type}{'bcc'};
+                if ($settings->{$type}{'include'} ne '') {
+                    ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+                    $includestr{$type} = &unescape($includestr{$type});
+                }
+            }
+            if (ref($settings->{'helpform'}) eq 'HASH') {
+                if (ref($fields) eq 'ARRAY') {
+                    foreach my $field (@{$fields}) {
+                        $currfield{$field} = $settings->{'helpform'}{$field};
                     }
-                    $otheremails{$type} = $settings->{$type}{'others'};
-                    if ($type eq 'helpdeskmail') {
-                        $bccemails{$type} = $settings->{$type}{'bcc'};
+                }
+                if (exists($settings->{'helpform'}{'maxsize'})) {
+                    $maxsize = $settings->{'helpform'}{'maxsize'};
+                } else {
+                    $maxsize = '1.0';
+                }
+            } else {
+                if (ref($fields) eq 'ARRAY') {
+                    foreach my $field (@{$fields}) {
+                        $currfield{$field} = 'yes';
                     }
                 }
-            } elsif ($type eq 'lonstatusmail') {
-                $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+                $maxsize = '1.0';
             }
         }
     } else {
-        $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
-        $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
-        $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
-        $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
-        $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
-        $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; 
-        $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
-        $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
-        $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" ';
+        if ($position eq 'top') {
+            $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
+            $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
+            $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
+            $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
+            $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+            $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+            $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
+            $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" ';
+        } elsif ($position eq 'bottom') {
+            $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+            $checked{'otherdomsmail'}{'supportemail'} = ' checked="checked" ';
+            if (ref($fields) eq 'ARRAY') {
+                foreach my $field (@{$fields}) {
+                    $currfield{$field} = 'yes';
+                }
+            }
+            $maxsize = '1.0';
+        }
     }
     my ($titles,$short_titles) = &contact_titles();
     my $rownum = 0;
     my $css_class;
-    foreach my $item (@contacts) {
-        $css_class = $rownum%2?' class="LC_odd_row"':'';
-        $datatable .= '<tr'.$css_class.'>'. 
-                  '<td><span class="LC_nobreak">'.$titles->{$item}.
-                  '</span></td><td class="LC_right_item">'.
-                  '<input type="text" name="'.$item.'" value="'.
-                  $to{$item}.'" /></td></tr>';
-        $rownum ++;
+    if ($position eq 'top') {
+        foreach my $item (@contacts) {
+            $css_class = $rownum%2?' class="LC_odd_row"':'';
+            $datatable .= '<tr'.$css_class.'>'. 
+                          '<td><span class="LC_nobreak">'.$titles->{$item}.
+                          '</span></td><td class="LC_right_item">'.
+                          '<input type="text" name="'.$item.'" value="'.
+                          $to{$item}.'" /></td></tr>';
+            $rownum ++;
+        }
+    } else {
+        foreach my $type (@mailings) {
+            $css_class = $rownum%2?' class="LC_odd_row"':'';
+            $datatable .= '<tr'.$css_class.'>'.
+                          '<td><span class="LC_nobreak">'.
+                          $titles->{$type}.': </span></td>'.
+                          '<td class="LC_left_item">';
+            if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+                $datatable .= '<fieldset><legend>'.&mt('E-mail recipient(s)').'</legend>';
+            }
+            $datatable .= '<span class="LC_nobreak">';
+            foreach my $item (@contacts) {
+                $datatable .= '<label>'.
+                              '<input type="checkbox" name="'.$type.'"'.
+                              $checked{$type}{$item}.
+                              ' value="'.$item.'" />'.$short_titles->{$item}.
+                              '</label> ';
+            }
+            $datatable .= '</span><br />'.&mt('Others').':  '.
+                          '<input type="text" name="'.$type.'_others" '.
+                          'value="'.$otheremails{$type}.'"  />';
+            my %locchecked;
+            if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+                foreach my $loc ('s','b') {
+                    if ($includeloc{$type} eq $loc) {
+                        $locchecked{$loc} = ' checked="checked"';
+                        last;
+                    }
+                }
+                $datatable .= '<br />'.&mt('Bcc:').(' 'x6).
+                              '<input type="text" name="'.$type.'_bcc" '.
+                              'value="'.$bccemails{$type}.'"  /></fieldset>'.
+                              '<fieldset><legend>'.&mt('Optional added text').'</legend>'.
+                              &mt('Text automatically added to e-mail:').' '.
+                              '<input type="text" name="'.$type.'_includestr" value="'.$includestr{$type}.'" /><br >'.
+                              '<span class="LC_nobreak">'.&mt('Location:').' '.
+                              '<label><input type="radio" name="'.$type.'_includeloc" value="s"'.$locchecked{'s'}.' />'.&mt('in subject').'</label>'.
+                              (' 'x2).
+                              '<label><input type="radio" name="'.$type.'_includeloc" value="b"'.$locchecked{'b'}.' />'.&mt('in body').'</label>'.
+                              '</span></fieldset>';
+            }
+            $datatable .= '</td></tr>'."\n";
+            $rownum ++;
+        }
     }
-    foreach my $type (@mailings) {
+    if ($position eq 'middle') {
+        my %choices;
+        $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',
+                                       &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+                                       &mt('LON-CAPA core group - MSU'),600,500));
+        $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',
+                                        &Apache::loncommon::modal_link('http://loncapa.org/core.html',
+                                        &mt('LON-CAPA core group - MSU'),600,500));
+        my @toggles = ('reporterrors','reportupdates');
+        my %defaultchecked = ('reporterrors'  => 'on',
+                              'reportupdates' => 'on');
+        (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+                                                   \%choices,$rownum);
+        $datatable .= $reports;
+    } elsif ($position eq 'bottom') {
         $css_class = $rownum%2?' class="LC_odd_row"':'';
         $datatable .= '<tr'.$css_class.'>'.
-                      '<td><span class="LC_nobreak">'.
-                      $titles->{$type}.': </span></td>'.
-                      '<td class="LC_left_item">'.
-                      '<span class="LC_nobreak">';
-        foreach my $item (@contacts) {
-            $datatable .= '<label>'.
-                          '<input type="checkbox" name="'.$type.'"'.
-                          $checked{$type}{$item}.
-                          ' value="'.$item.'" />'.$short_titles->{$item}.
-                          '</label> ';
-        }
-        $datatable .= '</span><br />'.&mt('Others').':  '.
-                      '<input type="text" name="'.$type.'_others" '.
-                      'value="'.$otheremails{$type}.'"  />';
-        if ($type eq 'helpdeskmail') {
-            $datatable .= '<br />'.&mt('Bcc:').(' 'x6).
-                          '<input type="text" name="'.$type.'_bcc" '.
-                          'value="'.$bccemails{$type}.'"  />';
+                      '<td>'.&mt('Extra helpdesk form fields:').'<br />'.
+                      &mt('(e-mail, subject, and description always shown)').
+                      '</td><td class="LC_left_item">';
+        if ((ref($fields) eq 'ARRAY') && (ref($fieldtitles) eq 'HASH') &&
+            (ref($fieldoptions) eq 'HASH') && (ref($possoptions) eq 'HASH')) {
+            $datatable .= '<table><tr><th>'.&mt('Field').'</th><th>'.&mt('Status').'</th></tr>';
+            foreach my $field (@{$fields}) {
+                $datatable .= '<tr><td>'.$fieldtitles->{$field};
+                if (($field eq 'screenshot') || ($field eq 'cc')) {
+                    $datatable .= ' '.&mt('(logged-in users)');
+                }
+                $datatable .='</td><td>';
+                my $clickaction;
+                if ($field eq 'screenshot') {
+                    $clickaction = ' onclick="screenshotSize(this);"';
+                }
+                if (ref($possoptions->{$field}) eq 'ARRAY') {
+                    foreach my $option (@{$possoptions->{$field}}) {
+                        my $checked;
+                        if ($currfield{$field} eq $option) {
+                            $checked = ' checked="checked"';
+                        }
+                        $datatable .= '<span class="LC_nobreak"><label>'.
+                                      '<input type="radio" name="helpform_'.$field.'" '.
+                                      'value="'.$option.'"'.$checked.$clickaction.' />'.$fieldoptions->{$option}.
+                                      '</label></span>'.(' 'x2);
+                    }
+                }
+                if ($field eq 'screenshot') {
+                    my $display;
+                    if ($currfield{$field} eq 'no') {
+                        $display = ' style="display:none"';
+                    }
+                    $datatable .= '</td></tr><tr id="help_screenshotsize"'.$display.' />'.
+                                  '<td>'.&mt('Maximum size for upload (MB)').'</td><td>'.
+                                  '<input type="text" size="5" name="helpform_maxsize" value="'.$maxsize.'" />';
+                }
+                $datatable .= '</td></tr>';
+            }
+            $datatable .= '</table>';
         }
         $datatable .= '</td></tr>'."\n";
         $rownum ++;
     }
-    my %choices;
-    $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',
-                                   &Apache::loncommon::modal_link('http://loncapa.org/core.html',
-                                   &mt('LON-CAPA core group - MSU'),600,500));
-    $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',
-                                    &Apache::loncommon::modal_link('http://loncapa.org/core.html',
-                                    &mt('LON-CAPA core group - MSU'),600,500));
-    my @toggles = ('reporterrors','reportupdates');
-    my %defaultchecked = ('reporterrors'  => 'on',
-                          'reportupdates' => 'on');
-    (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
-                                               \%choices,$rownum);
-    $datatable .= $reports;
     $$rowtotal += $rownum;
     return $datatable;
 }
 
+sub contacts_javascript {
+    return <<"ENDSCRIPT";
+
+<script type="text/javascript">
+// <![CDATA[
+
+function screenshotSize(field) {
+    if (document.getElementById('help_screenshotsize')) {
+        if (field.value == 'no') {
+            document.getElementById('help_screenshotsize').style.display="none";
+        } else {
+            document.getElementById('help_screenshotsize').style.display="";
+        }
+    }
+    return;
+}
+
+// ]]>
+</script>
+
+ENDSCRIPT
+}
+
 sub print_helpsettings {
     my ($position,$dom,$settings,$rowtotal) = @_;
     my $confname = $dom.'-domainconfig';
@@ -4590,14 +4749,15 @@
 
 sub contact_titles {
     my %titles = &Apache::lonlocal::texthash (
-                   'supportemail' => 'Support E-mail address',
-                   'adminemail'   => 'Default Server Admin E-mail address',
-                   'errormail'    => 'Error reports to be e-mailed to',
-                   'packagesmail' => 'Package update alerts to be e-mailed to',
-                   'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
-                   'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
-                   'requestsmail' => 'E-mail from course requests requiring approval',
-                   'updatesmail'  => 'E-mail from nightly check of LON-CAPA module integrity/updates',
+                   'supportemail'    => 'Support E-mail address',
+                   'adminemail'      => 'Default Server Admin E-mail address',
+                   'errormail'       => 'Error reports to be e-mailed to',
+                   'packagesmail'    => 'Package update alerts to be e-mailed to',
+                   'helpdeskmail'    => "Helpdesk requests for this domain's users",
+                   'otherdomsmail'   => 'Helpdesk requests for other (unconfigured) domains',
+                   'lonstatusmail'   => 'E-mail from nightly status check (warnings/errors)',
+                   'requestsmail'    => 'E-mail from course requests requiring approval',
+                   'updatesmail'     => 'E-mail from nightly check of LON-CAPA module integrity/updates',
                    'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID',
                  );
     my %short_titles = &Apache::lonlocal::texthash (
@@ -4607,6 +4767,34 @@
     return (\%titles,\%short_titles);
 }
 
+sub helpform_fields {
+    my %titles =  &Apache::lonlocal::texthash (
+                       'username'   => 'Name',
+                       'user'       => 'Username/domain',
+                       'phone'      => 'Phone',
+                       'cc'         => 'Cc e-mail',
+                       'course'     => 'Course Details',
+                       'section'    => 'Sections',
+                       'screenshot' => 'File upload',
+    );
+    my @fields = ('username','phone','user','course','section','cc','screenshot');
+    my %possoptions = (
+                        username     => ['yes','no','req'],
+                        phone        => ['yes','no','req'],
+                        user         => ['yes','no'],
+                        cc           => ['yes','no'],
+                        course       => ['yes','no'],
+                        section      => ['yes','no'],
+                        screenshot   => ['yes','no'],
+                      );
+    my %fieldoptions = &Apache::lonlocal::texthash (
+                         'yes'  => 'Optional',
+                         'req'  => 'Required',
+                         'no'   => "Not shown",
+    );
+    return (\@fields,\%titles,\%fieldoptions,\%possoptions);
+}
+
 sub tool_titles {
     my %titles = &Apache::lonlocal::texthash (
                      aboutme    => 'Personal web page',
@@ -6614,7 +6802,6 @@
                         $errors .= '<li><span class="LC_error">'.$puberror.'</span></li>';
                         if ((grep(/^\Q$lang\E$/, at currlangs)) &&
                             (!grep(/^\Q$lang\E$/, at delurls))) {
-
                             $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
                         }
                     }
@@ -6708,7 +6895,6 @@
             $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
         }
     }
-
     &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'});
 
     my $defaulthelpfile = '/adm/loginproblems.html';
@@ -8842,9 +9028,9 @@
             }
         }
         if (exists($currdirsrch{'lcavailable'})) {
-             if ($currdirsrch{'lcavailable'} ne $env{'form.dirsrch_domavailable'}) {
-                 $changes{'lcavailable'} = 1;
-             }
+            if ($currdirsrch{'lcavailable'} ne $env{'form.dirsrch_domavailable'}) {
+                $changes{'lcavailable'} = 1;
+            }
         } else {
             if ($env{'form.dirsrch_lcavailable'} eq '1') {
                 $changes{'lcavailable'} = 1;
@@ -8949,11 +9135,12 @@
             $currsetting{$key} = $domconfig{'contacts'}{$key};
         }
     }
-    my (%others,%to,%bcc);
+    my (%others,%to,%bcc,%includestr,%includeloc);
     my @contacts = ('supportemail','adminemail');
-    my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
-                    'requestsmail','updatesmail','idconflictsmail');
+    my @mailings = ('errormail','packagesmail','helpdeskmail','otherdomsmail',
+                    'lonstatusmail','requestsmail','updatesmail','idconflictsmail');
     my @toggles = ('reporterrors','reportupdates');
+    my ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
     foreach my $type (@mailings) {
         @{$newsetting{$type}} = 
             &Apache::loncommon::get_env_multiple('form.'.$type);
@@ -8963,12 +9150,17 @@
             } else {
                 $contacts_hash{contacts}{$type}{$item} = 0;
             }
-        }  
+        }
         $others{$type} = $env{'form.'.$type.'_others'};
         $contacts_hash{contacts}{$type}{'others'} = $others{$type};
-        if ($type eq 'helpdeskmail') {
+        if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
             $bcc{$type} = $env{'form.'.$type.'_bcc'};
             $contacts_hash{contacts}{$type}{'bcc'} = $bcc{$type};
+            if (($env{'form.'.$type.'_includestr'} ne '') && ($env{'form.'.$type.'_includeloc'} =~ /^s|b$/)) {
+                $includestr{$type} = $env{'form.'.$type.'_includestr'};
+                $includeloc{$type} = $env{'form.'.$type.'_includeloc'};
+                $contacts_hash{contacts}{$type}{'include'} = $includeloc{$type}.':'.&escape($includestr{$type});
+            }
         }
     }
     foreach my $item (@contacts) {
@@ -8980,6 +9172,23 @@
             $contacts_hash{'contacts'}{$item} = $env{'form.'.$item};
         }
     }
+    if ((ref($fields) eq 'ARRAY') && (ref($possoptions) eq 'HASH')) {
+        foreach my $field (@{$fields}) {
+            if (ref($possoptions->{$field}) eq 'ARRAY') {
+                my $value = $env{'form.helpform_'.$field};
+                $value =~ s/^\s+|\s+$//g;
+                if (grep(/^\Q$value\E$/,@{$possoptions->{$field}})) {
+                    $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'};
+                        }
+                    }
+                }
+            }
+        }
+    }
     if (keys(%currsetting) > 0) {
         foreach my $item (@contacts) {
             if ($to{$item} ne $currsetting{$item}) {
@@ -8999,10 +9208,39 @@
             if ($others{$type} ne $currsetting{$type}{'others'}) {
                 push(@{$changes{$type}},'others');
             }
-            if ($type eq 'helpdeskmail') {   
+            if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
                 if ($bcc{$type} ne $currsetting{$type}{'bcc'}) {
                     push(@{$changes{$type}},'bcc'); 
                 }
+                my ($currloc,$currstr) = split(/:/,$currsetting{$type}{'include'},2);
+                if (($includeloc{$type} ne $currloc) || (&escape($includestr{$type}) ne $currstr)) {
+                    push(@{$changes{$type}},'include');
+                }
+            }
+        }
+        if (ref($fields) eq 'ARRAY') {
+            if (ref($currsetting{'helpform'}) eq 'HASH') {
+                foreach my $field (@{$fields}) {
+                    if ($currsetting{'helpform'}{$field} ne $contacts_hash{'contacts'}{'helpform'}{$field}) {
+                        push(@{$changes{'helpform'}},$field);
+                    }
+                    if (($field eq 'screenshot') && ($contacts_hash{'contacts'}{'helpform'}{'screenshot'} ne 'no')) {
+                        if ($currsetting{'helpform'}{'maxsize'} ne $contacts_hash{'contacts'}{'helpform'}{'maxsize'}) {
+                            push(@{$changes{'helpform'}},'maxsize');
+                        }
+                    }
+                }
+            } else {
+                foreach my $field (@{$fields}) {
+                    if ($contacts_hash{'contacts'}{'helpform'}{$field} ne 'yes') {
+                        push(@{$changes{'helpform'}},$field);
+                    }
+                    if (($field eq 'screenshot') && ($contacts_hash{'contacts'}{'helpform'}{'screenshot'} ne 'no')) {
+                        if ($contacts_hash{'contacts'}{'helpform'}{'maxsize'} != 1) {
+                            push(@{$changes{'helpform'}},'maxsize');
+                        }
+                    }
+                }
             }
         }
     } else {
@@ -9012,26 +9250,41 @@
         $default{'errormail'} = 'adminemail';
         $default{'packagesmail'} = 'adminemail';
         $default{'helpdeskmail'} = 'supportemail';
+        $default{'otherdomsmail'} = 'supportemail';
         $default{'lonstatusmail'} = 'adminemail';
         $default{'requestsmail'} = 'adminemail';
         $default{'updatesmail'} = 'adminemail';
         foreach my $item (@contacts) {
            if ($to{$item} ne $default{$item}) {
-              $changes{$item} = 1;
+               $changes{$item} = 1;
            }
         }
         foreach my $type (@mailings) {
             if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) {
-               
                 push(@{$changes{$type}},@{$newsetting{$type}});
             }
             if ($others{$type} ne '') {
                 push(@{$changes{$type}},'others');
             }
-            if ($type eq 'helpdeskmail') {
+            if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
                 if ($bcc{$type} ne '') {
                     push(@{$changes{$type}},'bcc');
                 }
+                if (($includeloc{$type} =~ /^b|s$/) && ($includestr{$type} ne '')) {
+                    push(@{$changes{$type}},'include');
+                }
+            }
+        }
+        if (ref($fields) eq 'ARRAY') {
+            foreach my $field (@{$fields}) {
+                if ($contacts_hash{'contacts'}{'helpform'}{$field} ne 'yes') {
+                    push(@{$changes{'helpform'}},$field);
+                }
+                if (($field eq 'screenshot') && ($contacts_hash{'contacts'}{'helpform'}{'screenshot'} ne 'no')) {
+                    if ($contacts_hash{'contacts'}{'helpform'}{'maxsize'} != 1) {
+                        push(@{$changes{'helpform'}},'maxsize');
+                    }
+                }
             }
         }
     }
@@ -9063,7 +9316,11 @@
             }
             foreach my $type (@mailings) {
                 if (ref($changes{$type}) eq 'ARRAY') {
-                    $resulttext .= '<li>'.$titles->{$type}.': ';
+                    if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+                        $resulttext .= '<li>'.$titles->{$type}.' -- '.&mt('sent to').': ';
+                    } else {
+                        $resulttext .= '<li>'.$titles->{$type}.': ';
+                    }
                     my @text;
                     foreach my $item (@{$newsetting{$type}}) {
                         push(@text,$short_titles->{$item});
@@ -9071,12 +9328,31 @@
                     if ($others{$type} ne '') {
                         push(@text,$others{$type});
                     }
-                    $resulttext .= '<span class="LC_cusr_emph">'.
-                                   join(', ', at text).'</span>';
-                    if ($type eq 'helpdeskmail') {
+                    if (@text) {
+                        $resulttext .= '<span class="LC_cusr_emph">'.
+                                       join(', ', at text).'</span>';
+                    }
+                    if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
                         if ($bcc{$type} ne '') {
-                            $resulttext .= ' '.&mt('with Bcc to').': <span class="LC_cusr_emph">'.$bcc{$type}.'</span>';
+                            my $bcctext;
+                            if (@text) {
+                                $bcctext = ' '.&mt('with Bcc to');
+                            } else {
+                                $bcctext = '(Bcc)';
+                            }
+                            $resulttext .= $bcctext.': <span class="LC_cusr_emph">'.$bcc{$type}.'</span>';
+                        } elsif (!@text) {
+                            $resulttext .= &mt('No one');
                         }
+                        if ($includestr{$type} ne '') {
+                            if ($includeloc{$type} eq 'b') {
+                                $resulttext .= '<br />'.&mt('Text automatically added to e-mail body:').' '.$includestr{$type};
+                            } elsif ($includeloc{$type} eq 's') {
+                                $resulttext .= '<br />'.&mt('Text automatically added to e-mail subject:').' '.$includestr{$type};
+                            }
+                        }
+                    } elsif (!@text) {
+                        $resulttext .= &mt('No recipients');
                     }
                     $resulttext .= '</li>';
                 }
@@ -9098,9 +9374,50 @@
                                         &mt('LON-CAPA core group - MSU'),600,500)).
                                 '</li>';
             }
+            if ((ref($changes{'helpform'}) eq 'ARRAY') && (ref($fields) eq 'ARRAY')) {
+                my (@optional, at required, at unused,$maxsizechg);
+                foreach my $field (@{$changes{'helpform'}}) {
+                    if ($field eq 'maxsize') {
+                        $maxsizechg = 1;
+                        next;
+                    }
+                    if ($contacts_hash{'contacts'}{'helpform'}{$field} eq 'yes') {
+                        push(@optional,$field);
+                    } elsif ($contacts_hash{'contacts'}{'helpform'}{$field} eq 'no') {
+                        push(@unused,$field);
+                    } elsif ($contacts_hash{'contacts'}{'helpform'}{$field} eq 'req') {
+                        push(@required,$field);
+                    }
+                }
+                if (@optional) {
+                    $resulttext .= '<li>'.
+                                   &mt('Help form fields changed to "Optional": [_1].',
+                                       '<span class="LC_cusr_emph">'.join(', ',map { $fieldtitles->{$_}; } @optional)).'</span>'.
+                                   '</li>';
+                }
+                if (@required) {
+                    $resulttext .= '<li>'.
+                                   &mt('Help form fields changed to "Required": [_1].',
+                                       '<span class="LC_cusr_emph">'.join(', ',map { $fieldtitles->{$_}; } @required)).'</span>'.
+                                   '</li>';
+                }
+                if (@unused) {
+                    $resulttext .= '<li>'.
+                                   &mt('Help form fields changed to "Not shown": [_1].',
+                                       '<span class="LC_cusr_emph">'.join(', ',map { $fieldtitles->{$_}; } @unused)).'</span>'.
+                                   '</li>';
+                }
+                if ($maxsizechg) {
+                    $resulttext .= '<li>'.
+                                   &mt('Max size for file uploaded to help form by logged-in user set to [_1] MB.',
+                                       $contacts_hash{'contacts'}{'helpform'}{'maxsize'}).
+                                   '</li>';
+
+                }
+            }
             $resulttext .= '</ul>';
         } else {
-            $resulttext = &mt('No changes made to contact information');
+            $resulttext = &mt('No changes made to contacts and form settings');
         }
     } else {
         $resulttext = '<span class="LC_error">'.


More information about the LON-CAPA-cvs mailing list