Diff for /loncom/auth/lonroles.pm between versions 1.372 and 1.376

version 1.372, 2023/11/17 17:02:21 version 1.376, 2025/02/23 05:16:01
Line 181  document.body.addEventListener('click', Line 181  document.body.addEventListener('click',
 </script>  </script>
 ENDREDIR  ENDREDIR
     }      }
       $r->print('<div class="LC_landmark" role="main">'."\n");
     return;      return;
 }  }
   
Line 210  $msg Line 211  $msg
 // ]]>  // ]]>
 </script>  </script>
 $link  $link
   </div>
 $end_page  $end_page
 END  END
     return;      return;
Line 682  sub handler { Line 684  sub handler {
      $env{'environment.key.'.$cdom.'_'.$cnum},       $env{'environment.key.'.$cdom.'_'.$cnum},
      $authdom,$authnum)) {       $authdom,$authnum)) {
 # there is no valid key  # there is no valid key
                                my $swinfo=&Apache::lonmenu::rawconfig();
                                my $crumbtext = 'User Roles';
                                my $show_course=&Apache::loncommon::show_course();
                                if ($show_course) {
                                    $crumbtext = 'Courses';
                                }
      if ($env{'form.newkey'}) {       if ($env{'form.newkey'}) {
 # student attempts to register a new key  # student attempts to register a new key
  &Apache::loncommon::content_type($r,'text/html');   &Apache::loncommon::content_type($r,'text/html');
  &Apache::loncommon::no_cache($r);   &Apache::loncommon::no_cache($r);
  $r->send_http_header;   $r->send_http_header;
  my $swinfo=&Apache::lonmenu::rawconfig();                                   my $pagetitle = 'Verifying Access Key to Unlock this Course';
                                    my $brcrum =[{href=>"/adm/roles",text=>$crumbtext},
                                                 {href=>"/adm/roles",text=>'Verify Access Key'}];
  my $start_page=&Apache::loncommon::start_page   my $start_page=&Apache::loncommon::start_page
     ('Verifying Access Key to Unlock this Course');      ($pagetitle, undef,{bread_crumbs=>$brcrum,});
  my $end_page=&Apache::loncommon::end_page();   my $end_page=&Apache::loncommon::end_page();
  my $buttontext=&mt('Enter Course');                                   my ($buttontext,$message,$inputitem,$accessheader);
  my $message=&mt('Successfully registered key');  
                                  my $ip = &Apache::lonnet::get_requestor_ip();                                   my $ip = &Apache::lonnet::get_requestor_ip();
  my $assignresult=   my $assignresult=
      &Apache::lonnet::assign_access_key(       &Apache::lonnet::assign_access_key(
Line 703  sub handler { Line 712  sub handler {
      $env{'user.name'},       $env{'user.name'},
                                                      &mt('Assigned from [_1] at [_2] for [_3]'                                                       &mt('Assigned from [_1] at [_2] for [_3]'
                                                         ,$ip                                                          ,$ip
                                                         ,&Apache::lonlocal::locallocaltime()                                                          ,&Apache::lonlocal::locallocaltime($now)
                                                         ,$trolecode)                                                          ,$trolecode)
                                                      );                                                       );
  unless ($assignresult eq 'ok') {   if ($assignresult eq 'ok') {
      $assignresult=~s/^error\:\s*//;                                       $buttontext=&mt('Enter Course');
      $message=&mt($assignresult).                                       $message=&mt('Successfully registered key');
      '<br /><a href="/adm/logout">'.                                       $accessheader = &mt('Access key validation complete');
      &mt('Logout').'</a>';                                   } else {
      $buttontext=&mt('Re-Enter Key');                                       $buttontext=&mt('Submit');
  }                                       $assignresult=~s/^error\:\s*//;
  $r->print(<<ENDENTEREDKEY);                                       $accessheader = &mt('Access key validation incomplete');
                                        $message = &mt('Key: [_1]',
                                                   &HTML::Entities::encode($env{'form.newkey'},
                                                                           '\':<>&"')).' <br />'.
                                                   &mt('Result').': '.&mt($assignresult);
                                        my $labeltext = &mt('Enter access key');
                                        $inputitem = '<label>'.$labeltext.':'.
                                            '<input type="text" size="20" name="newkey" value="'.
                                            $env{'form.newkey'}.'" /></label>';
                                    }
                                    $r->print(<<"ENDREGKEY");
 $start_page  $start_page
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
 $swinfo  $swinfo
 // ]]>  // ]]>
 </script>  </script>
 <form action="" method="post">  <div class="LC_landmark" role="contentinfo">
   <h2 class="LC_heading_2">$accessheader</h2>
   <p>$message</p>
   </div>
   <div class="LC_landmark" role="main">
   <form action="/adm/roles" method="post">
 <input type="hidden" name="selectrole" value="1" />  <input type="hidden" name="selectrole" value="1" />
 <input type="hidden" name="$trolecode" value="1" />  <input type="hidden" name="$trolecode" value="1" />
 <span class="LC_fontsize_large">$message</span><br />  $inputitem
 <input type="submit" value="$buttontext" />  <input type="submit" value="$buttontext" />
 </form>  </form>
   </div>
 $end_page  $end_page
 ENDENTEREDKEY  ENDREGKEY
                                  return OK;                                   return OK;
      } else {       } else {
 # print form to enter a new key  # print form to enter a new key
  &Apache::loncommon::content_type($r,'text/html');   &Apache::loncommon::content_type($r,'text/html');
  &Apache::loncommon::no_cache($r);   &Apache::loncommon::no_cache($r);
  $r->send_http_header;   $r->send_http_header;
  my $swinfo=&Apache::lonmenu::rawconfig();                                   my $pagetitle = 'Enter Access Key to Unlock this Course';
                                    my $brcrum =[{href=>"/adm/roles",text=>$crumbtext},
                                                 {href=>"/adm/roles",text=>'Enter Access Key'}];
  my $start_page=&Apache::loncommon::start_page   my $start_page=&Apache::loncommon::start_page
     ('Enter Access Key to Unlock this Course');      ($pagetitle,undef,{bread_crumbs=>$brcrum,});
  my $end_page=&Apache::loncommon::end_page();   my $end_page=&Apache::loncommon::end_page();
                                    my $accessheader = &mt('Access to this course requires an access key');
                                    my $preamble = &mt('Once you have successfully entered a valid key, you will no longer be prompted for one when entering the course.');
                                    my $labeltext = &mt('Enter access key');
                                    my $submittext = &mt('Submit');
  $r->print(<<ENDENTERKEY);   $r->print(<<ENDENTERKEY);
 $start_page  $start_page
 <script type="text/javascript">  <script type="text/javascript">
Line 745  $start_page Line 776  $start_page
 $swinfo  $swinfo
 // ]]>  // ]]>
 </script>  </script>
   <div class="LC_landmark" role="main">
   <h2 class="LC_heading_2">$accessheader</h2>
   <p>$preamble</p>
 <form action="" method="post">  <form action="" method="post">
 <input type="hidden" name="selectrole" value="1" />  <input type="hidden" name="selectrole" value="1" />
 <input type="hidden" name="$trolecode" value="1" />  <input type="hidden" name="$trolecode" value="1" />
 <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />  <label>$labeltext:
 <input type="submit" value="Enter key" />  <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" /></label>
   <input type="submit" value="$submittext" />
 </form>  </form>
   </div>
 $end_page  $end_page
 ENDENTERKEY  ENDENTERKEY
  return OK;   return OK;
Line 806  ENDENTERKEY Line 842  ENDENTERKEY
 </script>  </script>
 ENDCLOSE  ENDCLOSE
                         &start_loading_course($r,$title,$only_body);                          &start_loading_course($r,$title,$only_body);
                           if ($only_body) {
                               $r->print('<h1 class="LC_visually_hidden">'.$title.'</h1>');
                           }
                         my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);                          my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);
                         &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Loading ...'));                          &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Loading ...'));
                         $r->rflush();                          $r->rflush();
Line 956  ENDCLOSE Line 995  ENDCLOSE
                                                   $env{'course.'.$cdom.'_'.$cnum.'.description'}).                                                    $env{'course.'.$cdom.'_'.$cnum.'.description'}).
                                               '</p>'.                                                '</p>'.
                                               '<p><a href="'.$furl.'">'.&mt('Please try again.').'</a></p>'.                                                '<p><a href="'.$furl.'">'.&mt('Please try again.').'</a></p>'.
                                                 '</div>'.
                                               &Apache::loncommon::end_page());                                                &Apache::loncommon::end_page());
                                 }                                  }
     } else {      } else {
Line 1237  ENDCLOSE Line 1277  ENDCLOSE
         $start_page=&Apache::loncommon::start_page($pagetitle,undef,          $start_page=&Apache::loncommon::start_page($pagetitle,undef,
                                                   {bread_crumbs=>$brcrum,crstype=>'Placement'});                                                    {bread_crumbs=>$brcrum,crstype=>'Placement'});
     } else {      } else {
         my $crumbsright;          my ($crumbsright,$crumbs_style);
         unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {          unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
             $funcs = &get_roles_functions($showcount,$cattype,$domdefs{'userapprovals'});              $funcs = &get_roles_functions($showcount,$cattype,$domdefs{'userapprovals'});
             if ($env{'browser.mobile'}) {              if ($env{'browser.mobile'}) {
                 $crumbsright = $funcs;                  $crumbsright = $funcs;
                 undef($funcs);                  undef($funcs);
                   $crumbs_style = 'overflow: visible;';
             }              }
         }          }
         $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum,          $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum,
                                                                      bread_crumbs_component=>$crumbsright});                                                                       bread_crumbs_component=>$crumbsright,
                                                                        bread_crumbs_style=>$crumbs_style,});
     }      }
     &js_escape(\$standby);      &js_escape(\$standby);
     my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';      my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
Line 1354  ENDHEADER Line 1396  ENDHEADER
         }          }
     }      }
     if ($nochoose) {      if ($nochoose) {
  $r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".   $r->print("<div class=\"LC_landmark\" role=\"main\">
                     <h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".
   &mt('This action is currently not authorized.').'</span>');    &mt('This action is currently not authorized.').'</span>');
         if ($error && $norolelist) {          if ($error && $norolelist) {
             $r->print('<br /><br /><h4><span class="LC_error">'.              $r->print('<br /><br /><h3 class="LC_heading_3"><span class="LC_error">'.
                       &mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.').                        &mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.').
                      '</span></h4>'.                       '</span></h3>'.
                      '<h4><span class="LC_error">'.                       '<h3 class="LC_heading_3"><span class="LC_error">'.
                      &mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.').                       &mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.').
                      '</span></h4>');                       '</span></h3>');
         }          }
         $r->print(&Apache::loncommon::end_page());          $r->print('</div>'.&Apache::loncommon::end_page());
  return OK;   return OK;
     } else {      } else {
         if ($updateresult || $reqauthor || $hotlist) {          if ($updateresult || $reqauthor || $hotlist) {
Line 1959  sub roletable_headers { Line 2002  sub roletable_headers {
                  .&Apache::loncommon::start_data_table('LC_textsize_mobile')                   .&Apache::loncommon::start_data_table('LC_textsize_mobile')
                  .&Apache::loncommon::start_data_table_header_row()                   .&Apache::loncommon::start_data_table_header_row()
         );          );
         if (!$nochoose) { $r->print('<th>&nbsp;</th>'); }          if (!$nochoose) { $r->print('<th><span class="LC_visually_hidden">'.&mt('Action').'</span></th>'); }
         $r->print('<th>'.&mt('User Role').'</th>'          $r->print('<th>'.&mt('User Role').'</th>'
                  .'<th>'.&mt('Extent').'</th>'                   .'<th>'.&mt('Extent').'</th>'
                  .'<th>'.&mt('Start').'</th>'                   .'<th>'.&mt('Start').'</th>'
Line 2245  sub build_roletext { Line 2288  sub build_roletext {
                         $trolecode."','".$buttonname.'\');" /></td>';                          $trolecode."','".$buttonname.'\');" /></td>';
         }          }
     }      }
     if (($trolecode !~ m/^(dc|ca|au|aa)\./)  && (!$skipcal)) {      if (($trolecode !~ m/^(ca|aa)\./) && ($trest ne '') && (!$skipcal)) {
  $tremark.=&Apache::lonannounce::showday(time,1,   $tremark.=&Apache::lonannounce::showday(time,1,
  &Apache::lonannounce::readcalendar($tdom.'_'.$trest));   &Apache::lonannounce::readcalendar($tdom.'_'.$trest));
     }      }
Line 3454  sub get_roles_functions { Line 3497  sub get_roles_functions {
         foreach my $link (@links) {          foreach my $link (@links) {
             $funcs .= &Apache::lonhtmlcommon::add_item_funclist(              $funcs .= &Apache::lonhtmlcommon::add_item_funclist(
                           '<a href="'.$link->[0].'" class="LC_menubuttons_link">'.                            '<a href="'.$link->[0].'" class="LC_menubuttons_link">'.
                           '<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].'" />'.                            '<img src="/res/adm/pages/'.$link->[1].'.png" class="LC_icon" alt="'.$link->[2].' '.&mt('icon').'" aria-hidden="true" />'.
                           $link->[2].'</a>');                            $link->[2].'</a>');
         }          }
         $funcs .= &Apache::lonhtmlcommon::end_funclist();          $funcs .= &Apache::lonhtmlcommon::end_funclist();
Line 3632  sub ltienroll { Line 3675  sub ltienroll {
                 &LONCAPA::ltiutils::batchaddroster($item);                  &LONCAPA::ltiutils::batchaddroster($item);
             }              }
         }          }
           $rosterupdates = []; 
     }      }
       return OK;
 }  }
   
 sub set_deeplink_target {  sub set_deeplink_target {

Removed from v.1.372  
changed lines
  Added in v.1.376


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