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

version 1.54, 2008/05/12 17:52:08 version 1.55, 2008/05/19 17:10:19
Line 1863  sub process_date_info { Line 1863  sub process_date_info {
 }  }
   
 sub show_users_list {  sub show_users_list {
     my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist)=@_;      my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_;
       if ($formname eq '') {
           $formname = 'studentform';
       }
     #      #
     # Variables for excel output      # Variables for excel output
     my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);      my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);
Line 1878  sub show_users_list { Line 1881  sub show_users_list {
     } else {      } else {
         push(@sortable,'extent');          push(@sortable,'extent');
     }      }
       if ($mode eq 'pickauthor') {
           @sortable = ('username','fullname','email','status');
       }
     if (!grep(/^\Q$sortby\E$/,@sortable)) {      if (!grep(/^\Q$sortby\E$/,@sortable)) {
         $sortby = 'username';          $sortby = 'username';
     }      }
Line 1918  function photowindow(photolink) { Line 1924  function photowindow(photolink) {
 END  END
         }          }
     }      }
     if ($mode ne 'autoenroll') {      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 $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");
         my $singconfirm = &mt(' for a single user?');          my $singconfirm = &mt(' for a single user?');
Line 1960  function verify_action (field) { Line 1966  function verify_action (field) {
         alert("$alert");          alert("$alert");
     }       } 
     else {      else {
         var message = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].text;          var message = document.$formname.bulkaction[document.$formname.bulkaction.selectedIndex].text;
         var choice = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].value;          var choice = document.$formname.bulkaction[document.$formname.bulkaction.selectedIndex].value;
         if (numchecked == 1) {           if (numchecked == 1) { 
             message += singconf;              message += singconf;
         }           } 
Line 1970  function verify_action (field) { Line 1976  function verify_action (field) {
         }          }
         if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') {          if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') {
             var datemsg = '';              var datemsg = '';
             if ((document.studentform.startdate_month.value == '') &&               if ((document.$formname.startdate_month.value == '') && 
                 (document.studentform.startdate_day.value  == '') &&                  (document.$formname.startdate_day.value  == '') &&
                 (document.studentform.startdate_year.value == '')) {                  (document.$formname.startdate_year.value == '')) {
                 datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n";                  datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n";
             }              }
             if ((document.studentform.enddate_month.value == '') &&              if ((document.$formname.enddate_month.value == '') &&
                 (document.studentform.enddate_day.value  == '') &&                  (document.$formname.enddate_day.value  == '') &&
                 (document.studentform.enddate_year.value == '')) {                  (document.$formname.enddate_year.value == '')) {
                 datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n";                  datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n";
             }              }
             if (datemsg != '') {              if (datemsg != '') {
Line 1985  function verify_action (field) { Line 1991  function verify_action (field) {
             }              }
         }          }
         if (choice == 'chgsec') {          if (choice == 'chgsec') {
             var rolefilter = document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value;              var rolefilter = document.$formname.showrole.options[document.$formname.showrole.selectedIndex].value;
             var retained =  document.studentform.retainsec.value;              var retained =  document.$formname.retainsec.value;
             var secshow = document.studentform.newsecs.value;              var secshow = document.$formname.newsecs.value;
             if (secshow == '') {              if (secshow == '') {
                 if (rolefilter == 'st' || retained == 0 || retained == "") {                  if (rolefilter == 'st' || retained == 0 || retained == "") {
                     message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n";                       message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n"; 
Line 2003  function verify_action (field) { Line 2009  function verify_action (field) {
             }              }
         }          }
         if (confirm(message)) {          if (confirm(message)) {
             document.studentform.phase.value = 'bulkchange';              document.$formname.phase.value = 'bulkchange';
             document.studentform.submit();              document.$formname.submit();
         }          }
     }      }
 }  }
   
 function username_display_launch(username,domain) {  function username_display_launch(username,domain) {
     var target;      var target;
     for (var i=0; i<document.studentform.usernamelink.length; i++) {      for (var i=0; i<document.$formname.usernamelink.length; i++) {
         if (document.studentform.usernamelink[i].checked) {          if (document.$formname.usernamelink[i].checked) {
             target = document.studentform.usernamelink[i].value;              target = document.$formname.usernamelink[i].value;
         }          }
     }      }
     if (target == 'modify') {      if (target == 'modify') {
         if (document.studentform.userwin.checked == true) {          if (document.$formname.userwin.checked == true) {
             var url = '/adm/createuser?srchterm='+username+'&srchdomain='+domain+'&phase=get_user_info&action=singleuser&srchin=dom&srchby=uname&srchtype=exact&popup=1';              var url = '/adm/createuser?srchterm='+username+'&srchdomain='+domain+'&phase=get_user_info&action=singleuser&srchin=dom&srchby=uname&srchtype=exact&popup=1';
             var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';              var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
             modifywin = window.open(url,'',options,1);              modifywin = window.open(url,'',options,1);
             modifywin.focus();              modifywin.focus();
             return;              return;
         } else {          } else {
             document.studentform.srchterm.value=username;              document.$formname.srchterm.value=username;
             document.studentform.srchdomain.value=domain;              document.$formname.srchdomain.value=domain;
             document.studentform.phase.value='get_user_info';              document.$formname.phase.value='get_user_info';
             document.studentform.action.value = 'singleuser';              document.$formname.action.value = 'singleuser';
             document.studentform.submit();              document.$formname.submit();
         }          }
     }      }
     if (target == 'aboutme') {      if (target == 'aboutme') {
         if (document.studentform.userwin.checked == true) {          if (document.$formname.userwin.checked == true) {
             var url = '/adm/'+domain+'/'+username+'/aboutme?popup=1';              var url = '/adm/'+domain+'/'+username+'/aboutme?popup=1';
             var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';              var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
             aboutmewin = window.open(url,'',options,1);              aboutmewin = window.open(url,'',options,1);
Line 2083  END Line 2089  END
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
         $lt{'extent'} = &mt('Author');           $lt{'extent'} = &mt('Author'); 
     }      }
     my @cols = ('username','domain','id','fullname');      my @cols;
     if ($context eq 'course') {      if ($mode eq 'pickauthor') {
         push(@cols,'section');          @cols = ('username','fullname','status','email');
     }      } else {
     if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {           @cols = ('username','domain','id','fullname');
         push(@cols,('start','end'));          if ($context eq 'course') {
     }              push(@cols,'section');
     if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {          }
         push(@cols,'role');          if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) { 
     }              push(@cols,('start','end'));
     if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||          }
                                 $env{'form.roletype'} eq 'course')) {          if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
         push (@cols,'extent');              push(@cols,'role');
     }          }
     if (($statusmode eq 'Any') &&           if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
         (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {                                      $env{'form.roletype'} eq 'course')) {
         push(@cols,'status');              push (@cols,'extent');
     }          }
     if ($context eq 'course') {          if (($statusmode eq 'Any') && 
         push(@cols,'groups');              (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
               push(@cols,'status');
           }
           if ($context eq 'course') {
               push(@cols,'groups');
           }
           push(@cols,'email');
     }      }
     push(@cols,'email');  
   
     my $rolefilter = $env{'form.showrole'};      my $rolefilter = $env{'form.showrole'};
     if ($env{'form.showrole'} eq 'cr') {      if ($env{'form.showrole'} eq 'cr') {
Line 2119  END Line 2130  END
         $r->print('<b>'.$results_description.'</b><br />');          $r->print('<b>'.$results_description.'</b><br />');
     }      }
     my ($output,$actionselect,%canchange,%canchangesec);      my ($output,$actionselect,%canchange,%canchangesec);
     if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {      if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
         if ($mode ne 'autoenroll') {          if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
             if ($permission->{'cusr'}) {              if ($permission->{'cusr'}) {
                 $actionselect = &select_actions($context,$setting,$statusmode);                  $actionselect = &select_actions($context,$setting,$statusmode,$formname);
             }              }
             $r->print(<<END);              $r->print(<<END);
 <input type="hidden" name="srchby"  value="uname" />  <input type="hidden" name="srchby"  value="uname" />
Line 2155  END Line 2166  END
             $output .= '&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="userwin" value="1" $checkwin />'.$lt{'owin'}.'</span><br />';              $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,'studentform','go')" /></p>  $lt{'ac'}:&nbsp;$actionselect <input type="button" value="$lt{'go'}" onclick="javascript:opendatebrowser(this.form,'$formname','go')" /></p>
 <p><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.actionlist)" /> &nbsp;  <p><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> &nbsp;
 <input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.actionlist)" /><br /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action(document.studentform.actionlist)" />  <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)" />
 END  END
                 my @allroles;                  my @allroles;
                 if ($env{'form.showrole'} eq 'Any') {                  if ($env{'form.showrole'} eq 'Any') {
Line 2205  END Line 2216  END
                   &Apache::loncommon::start_data_table_header_row();                    &Apache::loncommon::start_data_table_header_row();
         if ($mode eq 'autoenroll') {          if ($mode eq 'autoenroll') {
             $output .= "              $output .= "
  <th><a href=\"javascript:document.studentform.sortby.value='type';document.studentform.submit();\">$lt{'type'}</a></th>   <th><a href=\"javascript:document.$formname.sortby.value='type';document.$formname.submit();\">$lt{'type'}</a></th>
             ";              ";
         } else {          } else {
             $output .= "\n".'<th>'.&mt('Count').'</th>'."\n";              if ($mode eq 'pickauthor') {
                   $output .= "\n".'<th>&nbsp;</th>'."\n";
               } else { 
                   $output .= "\n".'<th>'.&mt('Count').'</th>'."\n";
               }
             if ($actionselect) {              if ($actionselect) {
                 $output .= '<th>'.&mt('Select').'</th>'."\n";                  $output .= '<th>'.&mt('Select').'</th>'."\n";
             }              }
         }          }
         foreach my $item (@cols) {          foreach my $item (@cols) {
             $output .= "<th><a href=\"javascript:document.studentform.sortby.value='$item';document.studentform.submit();\">$lt{$item}</a></th>\n";              $output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n";
         }          }
         my %role_types = &role_type_names();          my %role_types = &role_type_names();
         if ($context eq 'course' && $mode ne 'autoenroll') {          if ($context eq 'course' && $mode ne 'autoenroll') {
Line 2229  END Line 2244  END
                     $clickerchg = 'off';                      $clickerchg = 'off';
                 }                  }
                 $output .= '    <th>'."\n".'     '.                  $output .= '    <th>'."\n".'     '.
                     '<a href="javascript:document.studentform.displayclickers.value='.                      '<a href="javascript:document.'.$formname.'.displayclickers.value='.
                       "'".$clickerchg."'".';document.studentform.submit();">'.                        "'".$clickerchg."'".';document.'.$formname.'.submit();">'.
                       $clicker_options{$clickerchg}.'</a>&nbsp;'.$lt{'clicker'}."\n".                        $clicker_options{$clickerchg}.'</a>&nbsp;'.$lt{'clicker'}."\n".
                       '    </th>'."\n";                        '    </th>'."\n";
   
Line 2245  END Line 2260  END
                         $photochg = 'off';                          $photochg = 'off';
                     }                      }
                     $output .= '    <th>'."\n".'     '.                      $output .= '    <th>'."\n".'     '.
                 '<a href="javascript:document.studentform.displayphotos.value='.                  '<a href="javascript:document.'.$formname.'.displayphotos.value='.
                       "'".$photochg."'".';document.studentform.submit();">'.                        "'".$photochg."'".';document.'.$formname.'.submit();">'.
                       $photo_options{$photochg}.'</a>&nbsp;'.$lt{'photo'}."\n".                        $photo_options{$photochg}.'</a>&nbsp;'.$lt{'photo'}."\n".
                       '    </th>'."\n";                        '    </th>'."\n";
                 }                  }
Line 2445  END Line 2460  END
         } else {          } else {
             $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});              $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
         }          }
         if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {          if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
             $r->print(&Apache::loncommon::start_data_table_row());              $r->print(&Apache::loncommon::start_data_table_row());
             my $checkval;              my $checkval;
             if ($mode eq 'autoenroll') {              if ($mode eq 'autoenroll') {
Line 2467  END Line 2482  END
                 }                  }
                 $r->print("<td>$cellentry</td>\n");                  $r->print("<td>$cellentry</td>\n");
             } else {              } else {
                 $r->print("<td>$rowcount</td>\n");                  if ($mode ne 'pickauthor') {  
                       $r->print("<td>$rowcount</td>\n");
                   }
                 if ($actionselect) {                  if ($actionselect) {
                     my $showcheckbox;                      my $showcheckbox;
                     if ($role =~ /^cr\//) {                      if ($role =~ /^cr\//) {
Line 2501  END Line 2518  END
                     } else {                      } else {
                         $r->print('<td>&nbsp;</td>');                          $r->print('<td>&nbsp;</td>');
                     }                      }
                   } elsif ($mode eq 'pickauthor') {
                           $r->print('<td><input type="button" name="chooseauthor" onclick="javascript:gochoose('."'$in{'username'}'".');" value="'.&mt('Select').'" /></td>');
                 }                  }
             }              }
             foreach my $item (@cols) {              foreach my $item (@cols) {
Line 2568  END Line 2587  END
             $row++;              $row++;
         }          }
     }      }
     if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {      if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
             $r->print(&Apache::loncommon::end_data_table().'<br />');              $r->print(&Apache::loncommon::end_data_table().'<br />');
     } elsif ($mode eq 'excel') {      } elsif ($mode eq 'excel') {
         $excel_workbook->close();          $excel_workbook->close();
Line 2611  sub role_type_names { Line 2630  sub role_type_names {
 }  }
   
 sub select_actions {  sub select_actions {
     my ($context,$setting,$statusmode) = @_;      my ($context,$setting,$statusmode,$formname) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 revoke   => "Revoke user roles",                  revoke   => "Revoke user roles",
                 delete   => "Delete user roles",                  delete   => "Delete user roles",
Line 2672  sub select_actions { Line 2691  sub select_actions {
         }          }
     }      }
     if ($options) {      if ($options) {
         $output = '<select name="bulkaction" onchange="javascript:opendatebrowser(this.form,'."'studentform','change'".')" />'."\n".          $output = '<select name="bulkaction" onchange="javascript:opendatebrowser(this.form,'."'$formname','change'".')" />'."\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'}) {

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


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