Annotation of loncom/interface/lonmenu.pm, revision 1.13
1.1 www 1: # The LearningOnline Network with CAPA
2: # Routines to control the menu
3: #
1.13 ! harris41 4: # $Id: lonmenu.pm,v 1.12 2002/01/06 01:29:53 harris41 Exp $
1.11 albertel 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.1 www 28: # (TeX Conversion Module
29: #
30: # 05/29/00,05/30 Gerd Kortemeyer)
31: #
1.8 www 32: # 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer
1.1 www 33:
34: package Apache::lonmenu;
35:
36: use strict;
1.2 www 37: use Apache::lonnet;
38: use Apache::File;
39: use vars qw(@desklines $readdesk);
40:
1.1 www 41: # =============================================================== Open the menu
42:
43: sub open {
44: return(<<ENDOPEN);
45: <script>
46: window.status='MenuControl:nologout';
47: menu=window.open("/res/adm/pages/menu.html","LONCAPAmenu",
48: "height=350,width=150,scrollbars=no,menubar=no");
49: </script>
50: ENDOPEN
51: }
52:
1.2 www 53: # ============================================================ Switch Menu Item
54:
55: sub switchmenu {
56: my ($row,$col,$imgsrc,$texttop,$textbot,$action)=@_;
57: return(<<ENDSMENU);
58: <script>
59: swmenu=window.open('','LONCAPAmenu');
60: swmenu.switchbutton($row,$col,"$imgsrc","$texttop","$textbot","$action");
61: </script>
62: ENDSMENU
63: }
64:
65: # ================================================================== Raw Config
66:
1.3 www 67: sub clear {
68: my ($row,$col)=@_;
69: return qq(swmenu.clearbut($row,$col););
70: }
71:
1.2 www 72: sub switch {
73: my ($uname,$udom,$row,$col,$img,$top,$bot,$act)=@_;
74: $act=~s/\$uname/$uname/g;
75: $act=~s/\$udom/$udom/g;
76: return "\n".
1.3 www 77: qq(swmenu.switchbutton($row,$col,"$img","$top","$bot","$act"););
1.2 www 78: }
79:
80: sub secondlevel {
81: my $output='';
82: my
83: ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act)=@_;
84: if ($prt eq 'any') {
85: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
86: } elsif ($prt=~/^r(\w+)/) {
87: if ($rol eq $1) {
88: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
89: }
90: }
91: return $output;
92: }
93:
94: sub rawconfig {
95: my $output="swmenu=window.open('','LONCAPAmenu');";
96: my $uname=$ENV{'user.name'};
97: my $udom=$ENV{'user.domain'};
98: my $adv=$ENV{'user.adv'};
1.4 www 99: my $author=$ENV{'user.author'};
1.5 www 100: my $crs='';
101: if ($ENV{'request.course.id'}) {
102: $crs='/'.$ENV{'request.course.id'};
1.7 www 103: if ($ENV{'request.course.sec'}) {
104: $crs.='_'.$ENV{'request.course.sec'};
105: }
1.8 www 106: $crs=~s/\_/\//g;
1.5 www 107: }
1.2 www 108: my $pub=($ENV{'request.state'} eq 'published');
109: my $con=($ENV{'request.state'} eq 'construct');
110: my $rol=$ENV{'request.role'};
1.13 ! harris41 111: foreach (@desklines) {
1.2 www 112: my ($row,$col,$pro,$prt,$img,$top,$bot,$act)=split(/\:/,$_);
1.3 www 113: $prt=~s/\$uname/$uname/g;
114: $prt=~s/\$udom/$udom/g;
1.5 www 115: $prt=~s/\$crs/$crs/g;
1.3 www 116: if ($pro eq 'clear') {
1.4 www 117: $output.=&clear($row,$col);
1.3 www 118: } elsif ($pro eq 'any') {
1.2 www 119: $output.=&secondlevel(
120: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
121: } elsif ($pro eq 'smp') {
122: unless ($adv) {
123: $output.=&secondlevel(
124: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
125: }
126: } elsif ($pro eq 'adv') {
127: if ($adv) {
128: $output.=&secondlevel(
129: $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act);
130: }
131: } elsif (($pro=~/p(\w+)/) && ($prt)) {
132: if (&Apache::lonnet::allowed($1,$prt)) {
133: $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act);
1.4 www 134: }
135: } elsif ($pro eq 'author') {
136: if ($author) {
1.6 www 137: if (($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) {
138: my ($cadom,$caname)=
139: ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
140: $output.=switch($caname,$cadom,
141: $row,$col,$img,$top,$bot,$act);
142: } elsif ($prt eq 'any') {
143: $output.=switch($ENV{'user.name'},$ENV{'user.domain'},
144: $row,$col,$img,$top,$bot,$act);
145: }
1.2 www 146: }
147: }
1.13 ! harris41 148: }
1.2 www 149: return $output;
150: }
151:
152: # ======================================================================= Close
1.1 www 153:
154: sub close {
155: return(<<ENDCLOSE);
156: <script>
157: window.status='MenuControl:nologout';
158: menu=window.open("/adm/rat/empty.html","LONCAPAmenu",
159: "height=350,width=150,scrollbars=no,menubar=no");
160: menu.close();
161: </script>
162: ENDCLOSE
163: }
164:
165: # ====================================================================== Footer
166:
167: sub footer {
168:
169: }
170:
1.2 www 171: # ================================================================ Main Program
172:
1.12 harris41 173: BEGIN {
1.10 albertel 174: unless ($readdesk) {
175: {
176: my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
177: '/mydesk.tab');
178: while (my $configline=<$config>) {
179: chomp($configline);
180: $desklines[$#desklines+1]=$configline;
1.2 www 181: }
1.10 albertel 182: }
183: }
1.2 www 184: }
1.1 www 185: 1;
186: __END__
187:
188:
189:
190:
191:
192:
193:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>