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