Diff for /loncom/interface/lonuserutils.pm between versions 1.102 and 1.103

version 1.102, 2009/10/31 14:27:48 version 1.103, 2009/11/04 15:35:56
Line 91  sub modifyuserrole { Line 91  sub modifyuserrole {
     if ($setting eq 'course' || $context eq 'course') {      if ($setting eq 'course' || $context eq 'course') {
         $scope = '/'.$cid;          $scope = '/'.$cid;
         $scope =~ s/\_/\//g;          $scope =~ s/\_/\//g;
         if ($role ne 'cc' && $sec ne '') {          if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) {
             $scope .='/'.$sec;              $scope .='/'.$sec;
         }          }
     } elsif ($context eq 'domain') {      } elsif ($context eq 'domain') {
Line 295  sub hidden_input { Line 295  sub hidden_input {
 }  }
   
 sub print_upload_manager_header {  sub print_upload_manager_header {
     my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_;      my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype)=@_;
     my $javascript;      my $javascript;
     #      #
     if (! exists($env{'form.upfile_associate'})) {      if (! exists($env{'form.upfile_associate'})) {
Line 332  sub print_upload_manager_header { Line 332  sub print_upload_manager_header {
     my $javascript_validations =      my $javascript_validations =
         &javascript_validations('upload',$krbdefdom,$password_choice,undef,          &javascript_validations('upload',$krbdefdom,$password_choice,undef,
                                 $env{'request.role.domain'},$context,                                  $env{'request.role.domain'},$context,
                                 $groupslist);                                  $groupslist,$crstype);
     my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');      my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
     $r->print('<p>'      $r->print('<p>'
              .&mt('Total number of records found in file: [_1]'               .&mt('Total number of records found in file: [_1]'
Line 365  sub print_upload_manager_header { Line 365  sub print_upload_manager_header {
 ###############################################################  ###############################################################
 sub javascript_validations {  sub javascript_validations {
     my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,      my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
         $context,$groupslist)=@_;          $context,$groupslist,$crstype)=@_;
     my %param = (      my %param = (
                   kerb_def_dom => $krbdefdom,                    kerb_def_dom => $krbdefdom,
                   curr_authtype => $curr_authtype,                    curr_authtype => $curr_authtype,
Line 386  sub javascript_validations { Line 386  sub javascript_validations {
         if (($context eq 'course') || ($context eq 'domain')) {          if (($context eq 'course') || ($context eq 'domain')) {
             if ($context eq 'course') {              if ($context eq 'course') {
                 if ($env{'request.course.sec'} eq '') {                  if ($env{'request.course.sec'} eq '') {
                     $setsection_call = 'setSections(document.'.$param{'formname'}.');';                      $setsection_call = 'setSections(document.'.$param{'formname'}."'$crstype'".');';
                     $setsections_js =                      $setsections_js =
                         &setsections_javascript($param{'formname'},$groupslist,                          &setsections_javascript($param{'formname'},$groupslist,
                                                 $mode);                                                  $mode,'',$crstype);
                 } else {                  } else {
                     $setsection_call = "'ok'";                      $setsection_call = "'ok'";
                 }                  }
Line 830  sub print_upload_manager_footer { Line 830  sub print_upload_manager_footer {
                .'&nbsp;'.&mt('Add a domain role').'</label>'                 .'&nbsp;'.&mt('Add a domain role').'</label>'
                .'&nbsp;&nbsp;&nbsp;<label>'                 .'&nbsp;&nbsp;&nbsp;<label>'
                .'<input type="radio" name="roleaction" value="course" />'                 .'<input type="radio" name="roleaction" value="course" />'
                .'&nbsp;'.&mt('Add a course role').'</label>'                 .'&nbsp;'.&mt('Add a course/community role').'</label>'
                .'</span>';                 .'</span>';
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
         $Str .= &Apache::lonhtmlcommon::row_title(          $Str .= &Apache::lonhtmlcommon::row_title(
Line 899  sub print_upload_manager_footer { Line 899  sub print_upload_manager_footer {
            .'<hr />';             .'<hr />';
     if ($context eq 'course') {      if ($context eq 'course') {
         $Str .= '<p class="LC_info">'          $Str .= '<p class="LC_info">'
                .&mt('Note: For large courses, this operation may be time consuming.')                 .&mt('Note: This operation may be time consuming when adding several users.')
                .'</p>';                 .'</p>';
     }      }
     $Str .= '<p><input type="button"'      $Str .= '<p><input type="button"'
Line 979  sub print_upload_manager_form { Line 979  sub print_upload_manager_form {
         &Apache::loncommon::get_kerberos_defaults($defdom);          &Apache::loncommon::get_kerberos_defaults($defdom);
     #      #
     &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,      &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context,
                                  $permission);                                   $permission,$crstype);
     my $i;      my $i;
     my $keyfields;      my $keyfields;
     if ($total>=0) {      if ($total>=0) {
Line 1202  sub default_role_selector { Line 1202  sub default_role_selector {
            $options .= '  <option value="'.$role.'">'.$plrole.'</option>';             $options .= '  <option value="'.$role.'">'.$plrole.'</option>';
         }          }
         my $courseform = &Apache::loncommon::selectcourse_link          my $courseform = &Apache::loncommon::selectcourse_link
             ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course');              ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course/Community');
         $cb_jscript =           $cb_jscript = 
             &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform');              &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community');
         $coursepick = &Apache::loncommon::start_data_table().          $coursepick = &Apache::loncommon::start_data_table().
                       &Apache::loncommon::start_data_table_header_row().                        &Apache::loncommon::start_data_table_header_row().
                       '<th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th>'.                        '<th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th>'.
                       '<th>'.$lt{'grs'}.'</th>'.                        '<th>'.$lt{'grs'}.'</th>'.
                       &Apache::loncommon::end_data_table_header_row().                        &Apache::loncommon::end_data_table_header_row().
                       &Apache::loncommon::start_data_table_row()."\n".                        &Apache::loncommon::start_data_table_row()."\n".
                       '<td><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'studentform','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n".                        '<td><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'studentform','dccourse','dcdomain','coursedesc','','','','crstype'".')" /></td>'."\n".
                       '<td><select name="courserole">'."\n".                        '<td><select name="courserole">'."\n".
                       &default_course_roles($context,$checkpriv,'Course',%customroles)."\n".                        &default_course_roles($context,$checkpriv,'Course',%customroles)."\n".
                       '</select></td><td>'.                        '</select></td><td>'.
Line 1229  sub default_role_selector { Line 1229  sub default_role_selector {
                       $env{'request.role.domain'}.'" />'.                        $env{'request.role.domain'}.'" />'.
                       '<input type="hidden" name="dccourse" value="" />'.                        '<input type="hidden" name="dccourse" value="" />'.
                       '<input type="hidden" name="dcdomain" value="" />'.                        '<input type="hidden" name="dcdomain" value="" />'.
                         '<input type="hidden" name="crstype" value="" />'.
                       '</td></tr></table></td>'.                        '</td></tr></table></td>'.
                       &Apache::loncommon::end_data_table_row().                        &Apache::loncommon::end_data_table_row().
                       &Apache::loncommon::end_data_table()."\n";                        &Apache::loncommon::end_data_table()."\n";
Line 1705  sub section_group_filter { Line 1706  sub section_group_filter {
             $env{'form.'.$name{$item}} = 'all';              $env{'form.'.$name{$item}} = 'all';
         }          }
         if ($item eq 'sec') {          if ($item eq 'sec') {
             if ($env{'form.showrole'} eq 'cc') {              if (($env{'form.showrole'} eq 'cc') || ($env{'form.showrole'} eq 'co')) {
                 $env{'form.'.$name{$item}} = 'none';                  $env{'form.'.$name{$item}} = 'none';
             }              }
             my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);              my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
Line 3090  END Line 3091  END
         } else {          } else {
             opener.document.$callingform.retainsec.value = formname.retainsec.value;              opener.document.$callingform.retainsec.value = formname.retainsec.value;
         }          }
         setSections(formname);          setSections(formname,'$crstype');
         if (seccheck == 'ok') {          if (seccheck == 'ok') {
             opener.document.$callingform.newsecs.value = formname.sections.value;              opener.document.$callingform.newsecs.value = formname.sections.value;
         }          }
Line 3150  ENDJS Line 3151  ENDJS
                  fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.',                   fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.',
                  forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',                   forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',
                  reta => "Retain each user's current section affiliations?",                    reta => "Retain each user's current section affiliations?", 
                  dnap => '(Does not apply to student roles).',                    dnap => '(Does not apply to student roles).',
             );              );
     my ($date_items,$headertext);      my ($date_items,$headertext);
     if ($env{'form.bulkaction'} eq 'chgsec') {      if ($env{'form.bulkaction'} eq 'chgsec') {
Line 3172  ENDJS Line 3173  ENDJS
     if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {      if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {
         my ($cnum,$cdom) = &get_course_identity();          my ($cnum,$cdom) = &get_course_identity();
         my $crstype = &Apache::loncommon::course_type();          my $crstype = &Apache::loncommon::course_type();
           if ($crstype eq 'Community') {
               $lt{'fors'} = &mt('For member roles changing the section, will result in a section switch as members may only be in one section of a community at a time.');
               $lt{'forn'} = &mt('For a role in a community that is not a member role, a user may have roles in more than one section of a community at a time.');
               $lt{'dnap'} = &mt('(Does not apply to member roles).'); 
           }
         my $info;          my $info;
         if ($env{'form.showrole'} eq 'st') {          if ($env{'form.showrole'} eq 'st') {
             $output .= '<p>'.$lt{'fors'}.'</p>';               $output .= '<p>'.$lt{'fors'}.'</p>'; 
Line 3288  sub results_header_row { Line 3294  sub results_header_row {
         if ($viewablesec ne '') {          if ($viewablesec ne '') {
             if ($env{'form.showrole'} eq 'st') {              if ($env{'form.showrole'} eq 'st') {
                 $constraint = &mt('only users in section "[_1]"',$viewablesec);                  $constraint = &mt('only users in section "[_1]"',$viewablesec);
             } elsif ($env{'form.showrole'} ne 'cc') {              } elsif (($env{'form.showrole'} ne 'cc') && ($env{'form.showrole'} ne 'co')) {
                 $constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec);                  $constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec);
             }              }
             if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) {              if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) {
Line 3642  sub print_first_users_upload_form { Line 3648  sub print_first_users_upload_form {
            ."</p>\n";             ."</p>\n";
   
     $str .= &Apache::lonhtmlcommon::start_pick_box()      $str .= &Apache::lonhtmlcommon::start_pick_box()
            .&Apache::lonhtmlcommon::row_title(&mt('File'))             .&Apache::lonhtmlcommon::row_title(&mt('File'));
            .'<p class="LC_info">'."\n"      if (&Apache::lonlocal::current_language() ne 'en') {
            .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n"          if ($context eq 'course') { 
            .'</p>'."\n"              $str .= '<p class="LC_info">'."\n"
            .&Apache::loncommon::upfile_select_html()                     .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n"
                      .'</p>'."\n";
           }
       }
       $str .= &Apache::loncommon::upfile_select_html()
            .&Apache::lonhtmlcommon::row_closure()             .&Apache::lonhtmlcommon::row_closure()
            .&Apache::lonhtmlcommon::row_title(             .&Apache::lonhtmlcommon::row_title(
                 '<label for="noFirstLine">'                  '<label for="noFirstLine">'
Line 4134  sub upfile_drop_add { Line 4144  sub upfile_drop_add {
                                         $role = 'cr_'.$env{'user.domain'}.'_'.                                          $role = 'cr_'.$env{'user.domain'}.'_'.
                                                 $env{'user.name'}.'_'.$role;                                                  $env{'user.name'}.'_'.$role;
                                     }                                      }
                                     if ($role ne 'cc') {                                       if (($role ne 'cc') && ($role ne 'co')) { 
                                         if (@secs > 1) {                                          if (@secs > 1) {
                                             $multiple = 1;                                              $multiple = 1;
                                             foreach my $sec (@secs) {                                              foreach my $sec (@secs) {
Line 4495  sub update_user_list { Line 4505  sub update_user_list {
                 }                  }
             } elsif ($choice eq 'chgsec') {              } elsif ($choice eq 'chgsec') {
                 my (@newsecs,$revresult,$nochg,@retained);                  my (@newsecs,$revresult,$nochg,@retained);
                 if ($role ne 'cc') {                  if (($role ne 'cc') && ($role ne 'co')) {
                     @newsecs = split(/,/,$env{'form.newsecs'});                      @newsecs = split(/,/,$env{'form.newsecs'});
                 }                  }
                 # remove existing section if not to be retained.                     # remove existing section if not to be retained.   
Line 4750  sub get_groupslist { Line 4760  sub get_groupslist {
 }  }
   
 sub setsections_javascript {  sub setsections_javascript {
     my ($formname,$groupslist,$mode,$checkauth) = @_;      my ($formname,$groupslist,$mode,$checkauth,$crstype) = @_;
     my ($checkincluded,$finish,$rolecode,$setsection_js);      my ($checkincluded,$finish,$rolecode,$setsection_js);
     if ($mode eq 'upload') {      if ($mode eq 'upload') {
         $checkincluded = 'formname.name == "'.$formname.'"';          $checkincluded = 'formname.name == "'.$formname.'"';
Line 4789  sub setsections_javascript { Line 4799  sub setsections_javascript {
     }      }
     my %alerts = &Apache::lonlocal::texthash(      my %alerts = &Apache::lonlocal::texthash(
                     secd => 'Section designations do not apply to Course Coordinator roles.',                      secd => 'Section designations do not apply to Course Coordinator roles.',
                       sedn => 'Section designations do not apply to Coordinator roles.',
                     accr => 'A course coordinator role will be added with access to all sections.',                      accr => 'A course coordinator role will be added with access to all sections.',
                       acor => 'A coordinator role will be added with access to all sections',
                     inea => 'In each course, each user may only have one student role at a time.',                      inea => 'In each course, each user may only have one student role at a time.',
                       inec => 'In each community, each user may only have on member role at a time.',
                     youh => 'You had selected ',                      youh => 'You had selected ',
                     secs => 'sections.',                      secs => 'sections.',
                     plmo => 'Please modify your selections so they include no more than one section.',                      plmo => 'Please modify your selections so they include no more than one section.',
Line 4801  sub setsections_javascript { Line 4814  sub setsections_javascript {
                  );                                   );                
     $setsection_js .= <<"ENDSECCODE";      $setsection_js .= <<"ENDSECCODE";
   
 function setSections(formname) {  function setSections(formname,crstype) {
     var re1 = /^currsec_/;      var re1 = /^currsec_/;
     var groups = new Array($groupslist);      var groups = new Array($groupslist);
     for (var i=0;i<formname.elements.length;i++) {      for (var i=0;i<formname.elements.length;i++) {
Line 4810  function setSections(formname) { Line 4823  function setSections(formname) {
         if (checkcurr != null) {          if (checkcurr != null) {
             if ($checkincluded) {              if ($checkincluded) {
                 $rolecode                  $rolecode
                 if (role == 'cc') {                  if (role == 'cc' || role == 'co') {
                     alert("$alerts{'secd'}\\n$alerts{'accr'}");                      if (role == 'cc') {
                 }                          alert("$alerts{'secd'}\\n$alerts{'accr'}");
                 else {                      } else {
                           alert("$alerts{'sedn'}\\n$alerts{'acor'}");
                       }
                   } else {
                     var sections = '';                      var sections = '';
                     var numsec = 0;                      var numsec = 0;
                     var sections;                      var sections;
Line 4849  function setSections(formname) { Line 4865  function setSections(formname) {
                     }                      }
   
                     if ((role == 'st') && (numsec > 1)) {                      if ((role == 'st') && (numsec > 1)) {
                         alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}")                          if (crstype == 'Community') {
                               alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
                           } else {
                               alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
                           }
                         return;                          return;
                     }                      }
                     else {                      else {
Line 5123  sub dc_setcourse_js { Line 5143  sub dc_setcourse_js {
     my ($formname,$mode,$context) = @_;      my ($formname,$mode,$context) = @_;
     my ($dc_setcourse_code,$authen_check);      my ($dc_setcourse_code,$authen_check);
     my $cctext = &Apache::lonnet::plaintext('cc');      my $cctext = &Apache::lonnet::plaintext('cc');
       my $cotext = &Apache::lonnet::plaintext('co');
     my %alerts = &sectioncheck_alerts();      my %alerts = &sectioncheck_alerts();
     my $role = 'role';      my $role = 'role';
     if ($mode eq 'upload') {      if ($mode eq 'upload') {
Line 5169  function setCourse() { Line 5190  function setCourse() {
             numsections = numsections + newsecs.length;              numsections = numsections + newsecs.length;
         }          }
         if ((userrole == 'st') && (numsections > 1)) {          if ((userrole == 'st') && (numsections > 1)) {
             alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")              if (document.$formname.crstype.value == 'Community') {
                   alert("$alerts{'inco'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")
               } else {
                   alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")
               }
             return;              return;
         }          }
         for (var j=0; j<newsecs.length; j++) {          for (var j=0; j<newsecs.length; j++) {
Line 5181  function setCourse() { Line 5206  function setCourse() {
                 var groups = document.$formname.groups.value.split(/,/g);                  var groups = document.$formname.groups.value.split(/,/g);
                 for (var k=0; k<groups.length; k++) {                  for (var k=0; k<groups.length; k++) {
                     if (newsecs[j] == groups[k]) {                      if (newsecs[j] == groups[k]) {
                         alert("'"+newsecs[j]+"' $alerts{'mayt'}.\\n$alerts{'secn'}. $alerts{'plsc'}.");                          if (document.$formname.crstype.value == 'Community') {
                               alert("'"+newsecs[j]+"' $alerts{'mayc'}.\\n$alerts{'secn'}. $alerts{'plsc'}.");
                           } else {
                               alert("'"+newsecs[j]+"' $alerts{'mayt'}.\\n$alerts{'secn'}. $alerts{'plsc'}.");
                           }
                         return;                          return;
                     }                      }
                 }                  }
Line 5191  function setCourse() { Line 5220  function setCourse() {
             alert("$alerts{'secd'} $cctext $alerts{'role'}.\\n$alerts{'accr'}.");              alert("$alerts{'secd'} $cctext $alerts{'role'}.\\n$alerts{'accr'}.");
             section = "";              section = "";
         }          }
           if ((userrole == 'co') && (numsections > 0)) {
               alert("$alerts{'secd'} $cotext $alerts{'role'}.\\n$alerts{'accr'}.");
               section = "";
           }
 SCRIPTTOP  SCRIPTTOP
     if ($mode ne 'upload') {      if ($mode ne 'upload') {
         $dc_setcourse_code .= (<<"ENDSCRIPT");          $dc_setcourse_code .= (<<"ENDSCRIPT");
         var coursename = "_$env{'request.role.domain'}"+"_"+course+"_"+userrole          var coursename = "_$env{'request.role.domain'}"+"_"+course+"_"+userrole
         var numcourse = getIndex(document.$formname.dccourse);          var numcourse = getIndex(document.$formname.dccourse);
         if (numcourse == "-1") {          if (numcourse == "-1") {
             alert("$alerts{'thwa'}");              if (document.$formname.type == 'Community') {
                   alert("$alerts{'thwc'}");
               } else {
                   alert("$alerts{'thwa'}");
               }
             return;              return;
         }          }
         else {          else {
Line 5306  ENDSCRIPT Line 5343  ENDSCRIPT
   
 sub sectioncheck_alerts {  sub sectioncheck_alerts {
     my %alerts = &Apache::lonlocal::texthash(      my %alerts = &Apache::lonlocal::texthash(
                     curd => 'You must select a course in the current domain',                      curd => 'You must select a course or community in the current domain',
                     inea => 'In each course, each user may only have one student role at a time',                      inea => 'In each course, each user may only have one student role at a time',
                       inco => 'In each community, each user may only have one member role at a time', 
                     youh => 'You had selected',                      youh => 'You had selected',
                     sect => 'sections',                      sect => 'sections',
                     plsm => 'Please modify your selections so they include no more than one section',                      plsm => 'Please modify your selections so they include no more than one section',
                     mayn => 'may not be used as the name for a section, as it is a reserved word',                      mayn => 'may not be used as the name for a section, as it is a reserved word',
                     plsc => 'Please choose a different section name',                      plsc => 'Please choose a different section name',
                     mayt => 'may not be used as the name for a section, as it is the name of a course group',                      mayt => 'may not be used as the name for a section, as it is the name of a course group',
                       mayc => 'may not be used as the name for a section, as it is the name of a community group',
                     secn => 'Section names and group names must be distinct',                      secn => 'Section names and group names must be distinct',
                     secd => 'Section designations do not apply to ',                      secd => 'Section designations do not apply to ',
                     role => 'roles',                      role => 'roles',
                     accr => 'role will be added with access to all sections',                      accr => 'role will be added with access to all sections',
                     thwa => 'There was a problem with your course selection'                      thwa => 'There was a problem with your course selection',
                       thwc => 'There was a problem with your community selection',
                  );                   );
     return %alerts;      return %alerts;
 }  }

Removed from v.1.102  
changed lines
  Added in v.1.103


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