Diff for /loncom/interface/lonuserutils.pm between versions 1.55 and 1.56

version 1.55, 2008/05/19 17:10:19 version 1.56, 2008/05/29 00:43:21
Line 1926  END Line 1926  END
     }      }
     if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {      if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
         my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();          my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
         my $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");  
         my $singconfirm = &mt(' for a single user?');  
         my $multconfirm = &mt(' for multiple users?');  
         my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);          my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
         my %lt = &Apache::lonlocal::texthash(           my $verify_action_js = &bulkaction_javascript($formname);
               acwi => 'Access will be set to start immediately',  
               asyo => 'as you did not select an end date in the pop-up window',  
               accw => 'Access will be set to continue indefinitely',  
               asyd => 'as you did not select an end date in the pop-up window',  
               sewi => "Sections will be switched to 'No section'",  
               ayes => "as you either selected the 'No section' option",  
               oryo => 'or you did not select a section in the pop-up window',  
               arol => 'A role with no section will be added',  
               swbs => 'Sections will be switched to:',  
               rwba => 'Roles will be added for section(s):',  
         );  
         $r->print(<<END);          $r->print(<<END);
   
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
 $check_uncheck_js  $check_uncheck_js
   
 function verify_action (field) {  $verify_action_js
     var numchecked = 0;  
     var singconf = '$singconfirm';  
     var multconf = '$multconfirm';  
     if (field.length > 0) {  
         for (i = 0; i < field.length; i++) {  
             if (field[i].checked == true) {  
                numchecked ++;  
             }  
         }  
     } else {  
         if (field.checked == true) {  
             numchecked ++;  
         }  
     }  
     if (numchecked == 0) {  
         alert("$alert");  
     }   
     else {  
         var message = document.$formname.bulkaction[document.$formname.bulkaction.selectedIndex].text;  
         var choice = document.$formname.bulkaction[document.$formname.bulkaction.selectedIndex].value;  
         if (numchecked == 1) {   
             message += singconf;  
         }   
         else {  
             message += multconf;   
         }  
         if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') {  
             var datemsg = '';  
             if ((document.$formname.startdate_month.value == '') &&   
                 (document.$formname.startdate_day.value  == '') &&  
                 (document.$formname.startdate_year.value == '')) {  
                 datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n";  
             }  
             if ((document.$formname.enddate_month.value == '') &&  
                 (document.$formname.enddate_day.value  == '') &&  
                 (document.$formname.enddate_year.value == '')) {  
                 datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n";  
             }  
             if (datemsg != '') {  
                 message += "\\n"+datemsg;  
             }  
         }  
         if (choice == 'chgsec') {  
             var rolefilter = document.$formname.showrole.options[document.$formname.showrole.selectedIndex].value;  
             var retained =  document.$formname.retainsec.value;  
             var secshow = document.$formname.newsecs.value;  
             if (secshow == '') {  
                 if (rolefilter == 'st' || retained == 0 || retained == "") {  
                     message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";   
                 } else {  
                     message += "\\n\\n$lt{'arol'}\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";  
                 }  
             } else {  
                 if (rolefilter == 'st' || retained == 0 || retained == "") {  
                     message += "\\n\\n$lt{'swbs'} "+secshow+".\\n";  
                 } else {  
                     message += "\\n\\n$lt{'rwba'} "+secshow+".\\n";  
                 }  
             }  
         }  
         if (confirm(message)) {  
             document.$formname.phase.value = 'bulkchange';  
             document.$formname.submit();  
         }  
     }  
 }  
   
 function username_display_launch(username,domain) {  function username_display_launch(username,domain) {
     var target;      var target;
Line 2074  END Line 1994  END
                        'clicker'    => "clicker id",                         'clicker'    => "clicker id",
                        'photo'      => "photo",                         'photo'      => "photo",
                        'extent'     => "extent",                         'extent'     => "extent",
                        'go'         => "go",  
                        'pr'         => "Proceed",                         'pr'         => "Proceed",
                        'ca'         => "check all",                         'ca'         => "check all",
                        'ua'         => "uncheck all",                         'ua'         => "uncheck all",
                        'ac'         => "Action to take for selected users",                         'ac'         => "Action to take for selected users",
                        'link'       => "Behavior of username links",                         'link'       => "Behavior of clickable username link for each user",
                        'aboutme'    => "Display a user's personal page",                         'aboutme'    => "Display a user's personal page",
                        'owin'       => "Open in a new window",                         'owin'       => "Open in a new window",
                        'modify'     => "Modify a user's information",                         'modify'     => "Modify a user's information",
Line 2127  END Line 2046  END
     if ($mode ne 'autoenroll') {      if ($mode ne 'autoenroll') {
         $results_description = &results_header_row($rolefilter,$statusmode,          $results_description = &results_header_row($rolefilter,$statusmode,
                                                    $context,$permission,$mode);                                                     $context,$permission,$mode);
         $r->print('<b>'.$results_description.'</b><br />');          $r->print('<b>'.$results_description.'</b><br /><br />');
     }      }
     my ($output,$actionselect,%canchange,%canchangesec);      my ($output,$actionselect,%canchange,%canchangesec);
     if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {      if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
Line 2142  END Line 2061  END
 <input type="hidden" name="srchterm" value="" />  <input type="hidden" name="srchterm" value="" />
 <input type="hidden" name="srchdomain" value="" />   <input type="hidden" name="srchdomain" value="" /> 
 END  END
             $output = '<p>';  
             my @linkdests = ('aboutme');  
             if ($permission->{'cusr'}) {  
                 unshift (@linkdests,'modify');  
             }  
             $output .= '<span class="LC_nobreak">'.$lt{'link'}.':&nbsp;';  
             my $usernamelink = $env{'form.usernamelink'};  
             if ($usernamelink eq '') {  
                 $usernamelink = 'aboutme';  
             }  
             foreach my $item (@linkdests) {  
                 my $checkedstr = '';  
                 if ($item eq $usernamelink) {  
                     $checkedstr = ' checked="checked" ';  
                 }  
                 $output .= '<label><input type="radio" name="usernamelink" value="'.$item.'"'.$checkedstr.'>&nbsp;'.$lt{$item}.'</label>&nbsp;&nbsp;';  
             }  
             my $checkwin;  
             if ($env{'form.userwin'}) {   
                 $checkwin = 'checked = "checked"';   
             }  
             $output .= '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="userwin" value="1" $checkwin />'.$lt{'owin'}.'</span><br />';  
             if ($actionselect) {              if ($actionselect) {
                 $output .= <<"END";                  $output .= <<"END";
 $lt{'ac'}:&nbsp;$actionselect <input type="button" value="$lt{'go'}" onclick="javascript:opendatebrowser(this.form,'$formname','go')" /></p>  <div class="LC_left_float"><fieldset><legend><b>$lt{'ac'}</b></legend>
 <p><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> &nbsp;  $actionselect
 <input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.$formname.actionlist)" /><br /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action(document.$formname.actionlist)" />  <br/><br /><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> &nbsp;
   <input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.$formname.actionlist)" /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action('actionlist')" /></fieldset></div>
 END  END
                 my @allroles;                  my @allroles;
                 if ($env{'form.showrole'} eq 'Any') {                  if ($env{'form.showrole'} eq 'Any') {
Line 2210  END Line 2108  END
                     }                      }
                 }                  }
             }              }
               $output .= '<div class="LC_left_float"><fieldset><legend><b>'.$lt{'link'}.'</b></legend>'.
                          '<table><tr>';
               my @linkdests = ('aboutme');
               if ($permission->{'cusr'}) {
                   unshift (@linkdests,'modify');
               }
               $output .= '<td>';
               my $usernamelink = $env{'form.usernamelink'};
               if ($usernamelink eq '') {
                   $usernamelink = 'aboutme';
               }
               foreach my $item (@linkdests) {
                   my $checkedstr = '';
                   if ($item eq $usernamelink) {
                       $checkedstr = ' checked="checked" ';
                   }
                   $output .= '<span class="LC_nobreak"><label><input type="radio" name="usernamelink" value="'.$item.'"'.$checkedstr.'>&nbsp;'.$lt{$item}.'</label></span><br />';
               }
               my $checkwin;
               if ($env{'form.userwin'}) {
                   $checkwin = 'checked = "checked"';
               }
               $output .= '</td><td valign="top"><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1" '.$checkwin.'/>'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>';
         }          }
         $output .= "\n<p>\n".          $output .= "\n".'<div class="LC_clear_float_footer">&nbsp;</div>'."\n".
                   &Apache::loncommon::start_data_table().                    &Apache::loncommon::start_data_table().
                   &Apache::loncommon::start_data_table_header_row();                    &Apache::loncommon::start_data_table_header_row();
         if ($mode eq 'autoenroll') {          if ($mode eq 'autoenroll') {
Line 2607  END Line 2528  END
     }      }
 }  }
   
   sub bulkaction_javascript {
       my ($formname,$caller) = @_;
       my $docstart = 'document';
       if ($caller eq 'popup') {
           $docstart = 'opener.document';
       }
       my %lt = &Apache::lonlocal::texthash(
                 acwi => 'Access will be set to start immediately',
                 asyo => 'as you did not select an end date in the pop-up window',
                 accw => 'Access will be set to continue indefinitely',
                 asyd => 'as you did not select an end date in the pop-up window',
                 sewi => "Sections will be switched to 'No section'",
                 ayes => "as you either selected the 'No section' option",
                 oryo => 'or you did not select a section in the pop-up window',
                 arol => 'A role with no section will be added',
                 swbs => 'Sections will be switched to:',
                 rwba => 'Roles will be added for section(s):',
               );
       my $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");
       my $noaction = &mt("You need to select an action to take for the user(s) you have selected"); 
       my $singconfirm = &mt(' for a single user?');
       my $multconfirm = &mt(' for multiple users?');
       my $output = <<"ENDJS";
   function verify_action (field) {
       var numchecked = 0;
       var singconf = '$singconfirm';
       var multconf = '$multconfirm';
       if ($docstart.$formname.elements[field].length > 0) {
           for (i=0; i<$docstart.$formname.elements[field].length; i++) {
               if ($docstart.$formname.elements[field][i].checked == true) {
                  numchecked ++;
               }
           }
       } else {
           if ($docstart.$formname.elements[field].checked == true) {
               numchecked ++;
           }
       }
       if (numchecked == 0) {
           alert("$alert");
           return;
       } else {
           var message = $docstart.$formname.bulkaction[$docstart.$formname.bulkaction.selectedIndex].text;
           var choice = $docstart.$formname.bulkaction[$docstart.$formname.bulkaction.selectedIndex].value;
           if (choice == '') {
               alert("$noaction");
               return;
           } else {
               if (numchecked == 1) {
                   message += singconf;
               } else {
                   message += multconf;
               }
   ENDJS
       if ($caller ne 'popup') {
           $output .= <<"NEWWIN";
               if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate' || choice == 'chgsec') {
                   opendatebrowser(document.$formname,'$formname','go');
                   return;
   
               } else {
                   if (confirm(message)) {
                       document.$formname.phase.value = 'bulkchange';
                       document.$formname.submit();
                       return;
                   }
               }
   NEWWIN
       } else {
           $output .= <<"POPUP";
               if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') {
                   var datemsg = '';
                   if (($docstart.$formname.startdate_month.value == '') &&
                       ($docstart.$formname.startdate_day.value  == '') &&
                       ($docstart.$formname.startdate_year.value == '')) {
                       datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n";
                   }
                   if (($docstart.$formname.enddate_month.value == '') &&
                       ($docstart.$formname.enddate_day.value  == '') &&
                       ($docstart.$formname.enddate_year.value == '')) {
                       datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n";
                   }
                   if (datemsg != '') {
                       message += "\\n"+datemsg;
                   }
               }
               if (choice == 'chgsec') {
                   var rolefilter = $docstart.$formname.showrole.options[$docstart.$formname.showrole.selectedIndex].value;
                   var retained =  $docstart.$formname.retainsec.value;
                   var secshow = $docstart.$formname.newsecs.value;
                   if (secshow == '') {
                       if (rolefilter == 'st' || retained == 0 || retained == "") {
                           message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";
                       } else {
                           message += "\\n\\n$lt{'arol'}\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";
                       }
                   } else {
                       if (rolefilter == 'st' || retained == 0 || retained == "") {
                           message += "\\n\\n$lt{'swbs'} "+secshow+".\\n";
                       } else {
                           message += "\\n\\n$lt{'rwba'} "+secshow+".\\n";
                       }
                   }
               }
               if (confirm(message)) {
                   $docstart.$formname.phase.value = 'bulkchange';
                   $docstart.$formname.submit();
                   window.close();
               }
   POPUP
       }
       $output .= '
           }
       }
   }
   ';
       return $output;
   }
   
 sub print_username_link {  sub print_username_link {
     my ($mode,$in) = @_;      my ($mode,$in) = @_;
     my $output;      my $output;
Line 2691  sub select_actions { Line 2731  sub select_actions {
         }          }
     }      }
     if ($options) {      if ($options) {
         $output = '<select name="bulkaction" onchange="javascript:opendatebrowser(this.form,'."'$formname','change'".')" />'."\n".          $output = '<select name="bulkaction">'."\n".
                   '<option value="" selected="selected">'.                    '<option value="" selected="selected">'.
                   &mt('Please select').'</option>'."\n".$options."\n".'</select>';                    &mt('Please select').'</option>'."\n".$options."\n".'</select>';
         if ($choices{'dates'}) {          if ($choices{'dates'}) {
Line 2707  sub select_actions { Line 2747  sub select_actions {
                 '<input type="hidden" name="enddate_year" value="" />'."\n".                  '<input type="hidden" name="enddate_year" value="" />'."\n".
                 '<input type="hidden" name="enddate_hour" value="" />'."\n".                  '<input type="hidden" name="enddate_hour" value="" />'."\n".
                 '<input type="hidden" name="enddate_minute" value="" />'."\n".                  '<input type="hidden" name="enddate_minute" value="" />'."\n".
                 '<input type="hidden" name="enddate_second" value="" />'."\n";                  '<input type="hidden" name="enddate_second" value="" />'."\n".
                   '<input type="hidden" name="no_end_date" value="" />'."\n";
             if ($context eq 'course') {              if ($context eq 'course') {
                 $output .= '<input type="hidden" name="makedatesdefault" value="" />'."\n";                  $output .= '<input type="hidden" name="makedatesdefault" value="" />'."\n";
             }              }
Line 2733  sub date_section_javascript { Line 2774  sub date_section_javascript {
     $output .= <<"ENDONE";      $output .= <<"ENDONE";
     function opendatebrowser(callingform,formname,calledby) {      function opendatebrowser(callingform,formname,calledby) {
         var bulkaction = callingform.bulkaction.options[callingform.bulkaction.selectedIndex].value;          var bulkaction = callingform.bulkaction.options[callingform.bulkaction.selectedIndex].value;
         if (bulkaction == 'revoke' || bulkaction == 'delete' || bulkaction == '') {  
             if (calledby == 'go') {  
                 if (bulkaction == 'revoke') {  
                     alert("$nopopup{'revoke'}");  
                 }  
                 if (bulkaction == 'delete') {  
                     alert("$nopopup{'delete'}");   
                 }  
                 if (bulkaction == '') {  
                     alert("$nopopup{'none'}");  
                 }  
             }  
             return;  
         }  
         var url = '/adm/createuser?';          var url = '/adm/createuser?';
         var type = '';          var type = '';
         var showrole = callingform.showrole.options[callingform.showrole.selectedIndex].value;          var showrole = callingform.showrole.options[callingform.showrole.selectedIndex].value;
Line 2800  END Line 2827  END
         setSections(formname);          setSections(formname);
         if (seccheck == 'ok') {          if (seccheck == 'ok') {
             opener.document.$callingform.newsecs.value = formname.sections.value;              opener.document.$callingform.newsecs.value = formname.sections.value;
             window.close();  
         }          }
         return;  
 END  END
     } else {      } else {
         if ($context eq 'course') {          if ($context eq 'course') {
Line 2836  END Line 2861  END
     opener.document.$callingform.enddate_hour.value =  formname.enddate_hour.options[formname.enddate_hour.selectedIndex].value;      opener.document.$callingform.enddate_hour.value =  formname.enddate_hour.options[formname.enddate_hour.selectedIndex].value;
     opener.document.$callingform.enddate_minute.value =  formname.enddate_minute.value;      opener.document.$callingform.enddate_minute.value =  formname.enddate_minute.value;
     opener.document.$callingform.enddate_second.value = formname.enddate_second.value;      opener.document.$callingform.enddate_second.value = formname.enddate_second.value;
     window.close();      if (formname.no_end_date.checked) {
           opener.document.$callingform.no_end_date.value = '1';
       } else {
           opener.document.$callingform.no_end_date.value = '0';
       }
 END  END
     }      }
     $output .= '      my $verify_action_js = &bulkaction_javascript($callingform,'popup');
       $output .= <<"ENDJS";
       verify_action('actionlist');
 }  }
   
   $verify_action_js
   
 </script>  </script>
 ';  ENDJS
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                  chac => 'Access dates to apply for selected users',                   chac => 'Access dates to apply for selected users',
                  chse => 'Changes in section affiliation to apply to selected users',                   chse => 'Changes in section affiliation to apply to selected users',
Line 2899  END Line 2933  END
         $output .= $info.$secbox;          $output .= $info.$secbox;
     }      }
     $output .= '<p>'.      $output .= '<p>'.
 &mt('Use "Save" to update the main window with your selections.').'<br /><br />'.  '<input type="button" name="dateselection" value="'.&mt('Make changes').'" onclick="javascript:saveselections(this.form)" /></p>'."\n".
 '<input type="button" name="dateselection" value="'.&mt('Save').'" onclick="javascript:saveselections(this.form)" /></p>'."\n".  
 '</form>';  '</form>';
     return $output;      return $output;
 }  }

Removed from v.1.55  
changed lines
  Added in v.1.56


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>