Diff for /loncom/xml/lonxml.pm between versions 1.216 and 1.217

version 1.216, 2002/12/03 22:04:43 version 1.217, 2002/12/06 17:49:48
Line 101  use Apache::File(); Line 101  use Apache::File();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonfeedback();  use Apache::lonfeedback();
 use Apache::lonmsg();  use Apache::lonmsg();
   use Apache::lonmenu();
   use Apache::loncacc();
   
 #==================================================   Main subroutine: xmlparse    #==================================================   Main subroutine: xmlparse  
 #debugging control, to turn on debugging modify the correct handler  #debugging control, to turn on debugging modify the correct handler
Line 373  sub fontsettings() { Line 375  sub fontsettings() {
     return $headerstring;      return $headerstring;
 }  }
   
   
   ##
   ## switchmenu - modeled on lonmenu::switchmenu, but better. 
   ## Helper function for registerurl
   ##
   sub switchmenu {
       my ($row,$col,$imgsrc,$texttop,$textbot,$action,$description)=@_;
       return(<<ENDSMENU);
       menu.switchbutton($row,$col,'$imgsrc','$texttop','$textbot','$action','$description');
   ENDSMENU
   }
   
 sub registerurl {  sub registerurl {
     my $forcereg=shift;      my $forcereg=shift;
     my $target = shift;      my $target = shift;
Line 421  ENDGRDS Line 435  ENDGRDS
 ENDPARM  ENDPARM
             }              }
  }   }
           ###
           ### Determine whether or not to display the 'cstr' button for this
           ### resource
           ###
           my $editbutton = '';
           if ($ENV{'user.author'}) {
               if ($ENV{'request.role'}=~/^(ca|au)/) {
                   # Set defaults for authors
                   my ($top,$bottom) = ('con-','struct');
                   my $action = "go('/priv/".$ENV{'user.name'}."');";
                   my $cadom  = $ENV{'request.role.domain'};
                   my $caname = $ENV{'user.name'};
                   my $desc = "Enter my resource construction space";
                   # Set defaults for co-authors
                   if ($ENV{'request.role'} =~ /^ca/) { 
                       ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
                       ($top,$bottom) = ('co con-','struct');
                       $action = 'go("/priv/'.$caname.'");';
                       $desc = "Enter construction space as co-author";
                   }
                   # Check that we are on the correct machine
                   my $home = &Apache::lonnet::homeserver($caname,$cadom);
                   if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
                       $editbutton=&switchmenu
                           (6,1,$top,,$bottom,$action,$desc);
                   }
               }
               ##
               ## Determine if user can edit url.
               ##
               my $cfile='';
               my $cfuname='';
               my $cfudom='';
               if ($ENV{'request.filename'}) {
                   my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
                   $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
                   # Chech that the user has permission to edit this resource
                   ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
                   if (defined($cfudom)) {
                       if (&Apache::lonnet::homeserver($cfuname,$cfudom) 
                           eq $Apache::lonnet::perlvar{'lonHostID'}) {
                           $cfile=$file;
                       }
                   }
               }        
               # Finally, turn the button on or off
               if ($cfile) {
                   $editbutton=&switchmenu
                       (6,1,'cstr.gif','edit','resource',
                        'go("'.$cfile.'");',"Edit this resource");
               } elsif ($editbutton eq '') {
                   $editbutton = '    menu.clearbut(6,1);';
               }
           }
           ###
           ###
  $result = (<<ENDREGTHIS);   $result = (<<ENDREGTHIS);
             
 <script language="JavaScript">  <script language="JavaScript">
Line 456  ENDPARM Line 526  ENDPARM
           menu.switchbutton            menu.switchbutton
                                (9,3,'anot.gif','anno-','tations','annotate()','Make notes and annotations about this resource');                                 (9,3,'anot.gif','anno-','tations','annotate()','Make notes and annotations about this resource');
           $hwkadd            $hwkadd
             $editbutton
     }      }
   
     function LONCAPAstale() {      function LONCAPAstale() {

Removed from v.1.216  
changed lines
  Added in v.1.217


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