Annotation of loncom/interface/lonremote.pm, revision 1.34.4.1

1.1       www         1: # The LearningOnline Network
                      2: # User Authentication Module
                      3: #
1.34.4.1! raeburn     4: # $Id: lonremote.pm,v 1.34 2009/10/01 23:02:11 raeburn Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.11      www        28: ###
1.1       www        29: 
                     30: package Apache::lonremote;
                     31: 
                     32: use strict;
                     33: use Apache::Constants qw(:common);
                     34: use Apache::loncommon();
1.18      albertel   35: use Apache::lonnet;
1.1       www        36: use Apache::lonmenu();
1.11      www        37: use Apache::lonlocal;
1.1       www        38: 
                     39: sub launchremote {
1.2       www        40:     my ($r,$lowerurl)=@_;
1.3       www        41:     &Apache::lonnet::put('environment',{'remote' => 'on'});
1.24      raeburn    42:     &Apache::lonnet::appenv({'environment.remote' => 'on'});
1.1       www        43: # -------------------------------------------------------- Menu script and info
1.31      bisitz     44:     my $brcrum = [{href=>"/adm/preferences",text=>"Set User Preferences"},
                     45:                   {href=>"/adm/remote?url=/adm/preferences&action=launch",text=>"Launch Remote Control"}];
1.18      albertel   46:     my $windowinfo=&Apache::lonmenu::open($env{'browser.os'});
1.4       www        47:     my $startupremote=&Apache::lonmenu::startupremote($lowerurl);
1.31      bisitz     48:     my $start_page = &Apache::loncommon::start_page('Launch Remote Control',
                     49:                                                     $startupremote,
                     50:                                                     {'bread_crumbs' => $brcrum,});
1.19      albertel   51:     my $end_page   = &Apache::loncommon::end_page();
1.14      albertel   52:     my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);
1.4       www        53:     my $setflags=&Apache::lonmenu::setflags();
                     54:     my $maincall=&Apache::lonmenu::maincall();
1.31      bisitz     55:     my $message='<p class="LC_info">'
                     56:                .&mt('Launching of the Remote Control menu will fail if pop-up window filters are active.'
                     57:                    .' To use the Remote Control, disable the filter for this site.')
                     58:                .'</p>';
1.2       www        59:     $r->print(<<ENDLAUNCH);
1.19      albertel   60: $start_page
1.4       www        61: $setflags
                     62: $windowinfo
1.14      albertel   63: $message
                     64: $remoteinfo
1.5       www        65: $maincall
1.19      albertel   66: $end_page
1.2       www        67: ENDLAUNCH
                     68: }
                     69: 
                     70: sub collapseremote {
                     71:     my ($r,$lowerurl)=@_;
                     72: # -------------------------------------------------------- Menu script and info
1.26      raeburn    73:     my $brcrum = [{href=>"/adm/preferences",text=>"Set User Preferences"},
                     74:                   {href=>"/adm/remote?url=/adm/preferences&action=collapse",text=>"Collapse Remote Control"}];
                     75:     my $start_page = 
                     76:         &Apache::loncommon::start_page('Collapse Remote Control',
                     77:                                        undef,
                     78:                                        {'bread_crumbs' => $brcrum,
                     79:                                         'no_inline_link' => 1,});
1.20      albertel   80:     my $end_page  =  &Apache::loncommon::end_page();
1.4       www        81:     my $windowinfo=&Apache::lonmenu::close();
1.28      bisitz     82: #    my $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />';
1.30      raeburn    83:     my $message='<div class="LC_warning"><b>'.&mt('The external menu (Remote Control) has been disabled, and you will be working with the smaller inline menu.').'</b></div>'."\n".
                     84:                 '<p>'.&mt('You may have either closed the Remote Control window, or it was blocked by a pop-up window filter in your browser.').'<br />'."\n".
                     85:                 &mt('To use the Remote Control, disable the filter for this site, and re-launch the Remote Control.').'</p>'."\n".
1.32      bisitz     86:                 '<table><tr><td><fieldset><legend>'.&mt('Actions').'</legend><table><tr>'."\n".
1.30      raeburn    87:                 '<td class="LC_menubuttons_text" align="left">'.
1.33      raeburn    88:                 '<a class="LC_menubuttons_link" href="/adm/remote?action=launch"><img alt="Launch Remote Control" src="/res/adm/pages/remotecontrol.png" class="LC_noBorder" />'.
1.30      raeburn    89:                 &mt('Re-launch Remote Control').'</a></td><td>'.('&nbsp;'x3).'</td>'.
1.34      raeburn    90:                 '<td class="LC_menubuttons_text" align="right">'.
1.30      raeburn    91:                 '<a class="LC_menubuttons_link" href="'.$lowerurl.'"><img alt="Launch Remote Control" src="/res/adm/pages/forw.png" class="LC_noBorder" />'.
                     92:                 &mt('Continue without Remote Control').'</a></td></tr></table>'.
                     93:                 '</fieldset></td></tr></table>'."\n".
                     94:                 '<p>'.&mt('Assuming no pop-up blocking, the Remote Control can be launched at any time from the [_1]Set User Preferences[_2] page, linked to in the [_3]Main Menu[_2].','<a href="/adm/preferences">','</a>','<a href="/adm/menu">').'</span></p>';
1.2       www        95:     $r->print(<<ENDCOLLAPSE);
1.19      albertel   96: $start_page
1.4       www        97: $windowinfo
1.12      albertel   98: $message
1.19      albertel   99: $end_page
1.2       www       100: ENDCOLLAPSE
1.30      raeburn   101:     &Apache::lonnet::put('environment',{'remote' => 'off'});
                    102:     &Apache::lonnet::appenv({'environment.remote' => 'off'});
1.1       www       103: }
                    104: 
1.34.4.1! raeburn   105: sub no_remote_launch {
        !           106:     my ($r)=@_;
        !           107:     my $brcrum = [{href=>"/adm/preferences",text=>"Set User Preferences"},
        !           108:                   {href=>"/adm/remote?url=/adm/preferences&action=launch",text=>"Launch Remote Control"}];
        !           109:     my $start_page = &Apache::loncommon::start_page('Remote Control Unavailable','',
        !           110:                                                     {'bread_crumbs' => $brcrum,});
        !           111:     my $end_page = &Apache::loncommon::end_page();
        !           112:     my $message='<p class="LC_info">'
        !           113:                .&mt('Launching of the Remote Control menu is unavailable in courses with customized menu collections.')
        !           114:                .'</p>';
        !           115:     $r->print(<<ENDLAUNCH);
        !           116: $start_page
        !           117: $message
        !           118: $end_page
        !           119: ENDLAUNCH
        !           120:     return;
        !           121: }
        !           122: 
1.1       www       123: sub handler {
                    124:     my $r = shift;
1.5       www       125:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    126:                                             ['action','url']);
1.18      albertel  127:     unless ($env{'form.action'}) {
                    128: 	if ($env{'environment.remote'} ne 'off') {
                    129: 	    $env{'form.action'}='collapse';
1.2       www       130:         } else {
1.18      albertel  131: 	    $env{'form.action'}='launch';
1.2       www       132:         }
                    133:     }
1.5       www       134: 
1.18      albertel  135:     my $lowerurl=$env{'form.url'};
1.6       www       136:     unless ($lowerurl) { $lowerurl='/adm/menu'; }
1.9       albertel  137: 
1.10      www       138:     &Apache::loncommon::content_type($r,'text/html');
1.9       albertel  139:     $r->send_http_header;
                    140:     return OK if $r->header_only;
1.5       www       141: 
1.18      albertel  142:     if ($env{'form.action'} eq 'launch') {
1.34.4.1! raeburn   143:         my $nolaunch;
        !           144:         if ($env{'request.course.id'}) {
        !           145:             my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect();
        !           146:             if ($menucoll) {
        !           147:                 $nolaunch = 1;
        !           148:             }
        !           149:         }
        !           150:         if ($nolaunch) {
        !           151:             &no_remote_launch($r);
        !           152:         } else {
        !           153: 	    &launchremote($r,$lowerurl);
        !           154:         }
1.2       www       155:     } else {
1.4       www       156:         &collapseremote($r,$lowerurl);
1.2       www       157:     }
1.1       www       158:     return OK;
                    159: }
                    160: 
                    161: 1;
                    162: __END__
                    163: 
                    164: 

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