[LON-CAPA-cvs] cvs: loncom /auth lonwebdavauth.pm /interface domainprefs.pm loncommon.pm loncreateuser.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Fri Jun 1 07:39:33 EDT 2012


raeburn		Fri Jun  1 11:39:33 2012 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm loncommon.pm domainprefs.pm 
    /loncom/auth	lonwebdavauth.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - webDAV access can be controlled by user status and/or overridden for
    specific users.
  
  
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.360 loncom/interface/loncreateuser.pm:1.361
--- loncom/interface/loncreateuser.pm:1.360	Wed Apr 25 21:22:01 2012
+++ loncom/interface/loncreateuser.pm	Fri Jun  1 11:39:24 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.360 2012/04/25 21:22:01 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.361 2012/06/01 11:39:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -223,6 +223,7 @@
     my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",
+                   'webdav'     => "WebDAV access to authoring spaces (if SSL and author/co-author)",
                    'portfolio'  => "Personal User Portfolio",
                    'avai'       => "Available",
                    'cusa'       => "availability",
@@ -248,8 +249,9 @@
         $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
     } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
-                          'tools.aboutme','tools.portfolio','tools.blog');
-        @usertools = ('aboutme','blog','portfolio');
+                          'tools.aboutme','tools.portfolio','tools.blog',
+                          'tools.webdav');
+        @usertools = ('aboutme','blog','webdav','portfolio');
     }
     foreach my $item (@usertools) {
         my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
@@ -356,7 +358,7 @@
             $currdisp = ($curr_access?&mt('Yes'):&mt('No'));
             $custdisp = '<span class="LC_nobreak"><label>'.
                         '<input type="radio" name="'.$context.'_'.$item.'"'.
-                        ' value="1"'. $tool_on.'/>'.&mt('On').'</label> <label>'.
+                        ' value="1" '.$tool_on.'/>'.&mt('On').'</label> <label>'.
                         '<input type="radio" name="'.$context.'_'.$item.'" value="0" '.
                         $tool_off.'/>'.&mt('Off').'</label></span>';
             $custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp.
@@ -1256,7 +1258,7 @@
             if (&Apache::lonnet::allowed('mut',$env{'request.role.domain'})) {
                 my %lt=&Apache::lonlocal::texthash(
                     'utav'  => "User Tools Availability",
-                    'yodo'  => "You do not have privileges to modify Portfolio, Blog or Personal Information Page settings for this user.",
+                    'yodo'  => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.",
                     'ifch'  => "If a change is required, contact a domain coordinator for the domain",
                 );
                 $user_tools_text = <<ENDNOTOOLSPRIV;
@@ -2312,7 +2314,7 @@
 
     my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
-    my @usertools = ('aboutme','blog','portfolio');
+    my @usertools = ('aboutme','blog','webdav','portfolio');
     my @requestcourses = ('official','unofficial','community');
     my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
@@ -2465,10 +2467,10 @@
         my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation',
              'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
-             'tools.blog','tools.portfolio','requestcourses.official',
-             'requestcourses.unofficial','requestcourses.community',
-             'reqcrsotherdom.official','reqcrsotherdom.unofficial',
-             'reqcrsotherdom.community'],
+             'tools.blog','tools.webdav','tools.portfolio',
+             'requestcourses.official','requestcourses.unofficial',
+             'requestcourses.community','reqcrsotherdom.official',
+             'reqcrsotherdom.unofficial','reqcrsotherdom.community'],
               $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) { 
@@ -2918,6 +2920,7 @@
          'permanentemail' => 'Permanent e-mail address',
          'quota'          => 'Disk space allocated to portfolio files',
          'blog'           => 'Blog Availability',
+         'webdav'         => 'WebDAV Availability',
          'aboutme'        => 'Personal Information Page Availability',
          'portfolio'      => 'Portfolio Availability',
          'official'       => 'Can Request Official Courses',
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1080 loncom/interface/loncommon.pm:1.1081
--- loncom/interface/loncommon.pm:1.1080	Mon May 28 20:31:17 2012
+++ loncom/interface/loncommon.pm	Fri Jun  1 11:39:24 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1080 2012/05/28 20:31:17 raeburn Exp $
+# $Id: loncommon.pm,v 1.1081 2012/06/01 11:39:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -13718,7 +13718,7 @@
             %domdef = &Apache::lonnet::get_domain_defaults($domain);
         }
 
-        foreach my $tool ('aboutme','blog','portfolio') {
+        foreach my $tool ('aboutme','blog','webdav','portfolio') {
             $userenv{'availabletools.'.$tool} = 
                 &Apache::lonnet::usertools_access($username,$domain,$tool,'reload',
                                                   undef,\%userenv,\%domdef,\%is_adv);
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.161 loncom/interface/domainprefs.pm:1.162
--- loncom/interface/domainprefs.pm:1.161	Wed May 30 16:29:20 2012
+++ loncom/interface/domainprefs.pm	Fri Jun  1 11:39:24 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.161 2012/05/30 16:29:20 raeburn Exp $
+# $Id: domainprefs.pm,v 1.162 2012/06/01 11:39:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -247,7 +247,7 @@
                                   col2 => 'Value'}],
                     },
         'quotas' => 
-                    { text => 'User blogs, personal information pages, portfolios',
+                    { text => 'Blogs, personal web pages, webDAV, portfolios',
                       help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',
@@ -1377,7 +1377,7 @@
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();
     } else {
-        @usertools = ('aboutme','blog','portfolio');
+        @usertools = ('aboutme','blog','webdav','portfolio');
         %titles = &tool_titles();
     }
     if (ref($types) eq 'ARRAY') {
@@ -3003,8 +3003,9 @@
 
 sub tool_titles {
     my %titles = &Apache::lonlocal::texthash (
-                     aboutme    => 'Personal Information Page',
+                     aboutme    => 'Personal web page',
                      blog       => 'Blog',
+                     webdav     => 'WebDAV',
                      portfolio  => 'Portfolio',
                      official   => 'Official courses (with institutional codes)',
                      unofficial => 'Unofficial courses',
@@ -5221,7 +5222,7 @@
         $toolregexp = join('|', at usertools);
         %conditions = &courserequest_conditions();
     } else {
-        @usertools = ('aboutme','blog','portfolio');
+        @usertools = ('aboutme','blog','webdav','portfolio');
         %titles = &tool_titles();
     }
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
Index: loncom/auth/lonwebdavauth.pm
diff -u loncom/auth/lonwebdavauth.pm:1.1 loncom/auth/lonwebdavauth.pm:1.2
--- loncom/auth/lonwebdavauth.pm:1.1	Mon Feb 27 03:06:33 2012
+++ loncom/auth/lonwebdavauth.pm	Fri Jun  1 11:39:29 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Authentication Handler for webDAV access to Authoring Space.
 #
-# $Id: lonwebdavauth.pm,v 1.1 2012/02/27 03:06:33 raeburn Exp $
+# $Id: lonwebdavauth.pm,v 1.2 2012/06/01 11:39:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -169,7 +169,11 @@
             if ($now-$sesstime < $timetolive) {
                 if (&Apache::lonnet::homeserver($uname,$udom) eq $uhome) {
                     &Apache::lonnet::transfer_profile_to_env($sessiondir,$handle);
-                    return OK;
+                    if (&Apache::lonnet::usertools_access($uname,$udom,'webdav')) {
+                        return OK;
+                    } else {
+                        return FORBIDDEN;
+                    }
                 }
             }
         }
@@ -207,11 +211,15 @@
                 $handle = &init_webdav_env($sessiondir,$uname,$udom,
                                            $uhome,$now,$timetolive);
                 if ($handle ne '') {
-                    my $cookie = "lonDAV=$handle; path=/webdav/; secure; HttpOnly;";
-                    $r->header_out('Set-cookie' => $cookie);
-                    $r->send_http_header;
+                    if (&Apache::lonnet::usertools_access($uname,$udom,'webdav')) {
+                        my $cookie = "lonDAV=$handle; path=/webdav/; secure; HttpOnly;";
+                        $r->header_out('Set-cookie' => $cookie);
+                        $r->send_http_header;
+                        return OK;
+                    } else {
+                        return FORBIDDEN;
+                    }
                 }
-                return OK;
             }
         }
     }
@@ -257,20 +265,36 @@
             $disk_env{'user.name'} = $uname;
             $disk_env{'user.domain'} = $udom;
             $disk_env{'user.home'} = $uhome;
+            my %userenv = &Apache::lonnet::get('environment',['inststatus','tools.webdav'],
+                                               $udom,$uname);
+            my ($tmp) = keys(%userenv);
+            if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
+                $disk_env{'environment.inststatus'} = $userenv{'inststatus'};
+                $disk_env{'environment.tools.webdav'} = $userenv{'tools.webdav'};
+            }
             $disk_env{'user.environment'} = $sessionfile;
             my $possroles = ['au','ca','aa'];
             my @possdoms = &Apache::lonnet::current_machine_domains();
             my %cstr_roles =
                 &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
                                               undef,$possroles,\@possdoms);
-            foreach my $item (keys(%cstr_roles)) {
-                my ($aname,$adom,$role) = split(/:/,$item);
-                if ($role eq 'au') {
-                    $disk_env{"user.role.$role./$adom/"} = $cstr_roles{$item};
-                } else {
-                    $disk_env{"user.role.$role./$adom/$aname"} = $cstr_roles{$item};
+            if (keys(%cstr_roles) > 0) {
+                $disk_env{'user.adv'} = 1;
+                $disk_env{'user.author'} = 1;
+                foreach my $item (keys(%cstr_roles)) {
+                    my ($aname,$adom,$role) = split(/:/,$item);
+                    if ($role eq 'au') {
+                        $disk_env{"user.role.$role./$adom/"} = $cstr_roles{$item};
+                    } else {
+                        $disk_env{"user.role.$role./$adom/$aname"} = $cstr_roles{$item};
+                    }
                 }
             }
+            my %is_adv = ( is_adv => $disk_env{'user.adv'} );
+            my %domdef = &Apache::lonnet::get_domain_defaults($udom);
+            $disk_env{'environment.availabletools.webdav'} =
+                &Apache::lonnet::usertools_access($uname,$udom,'webdav','reload',undef,
+                                                  \%userenv,\%domdef,\%is_adv);
             @env{keys(%disk_env)} = @disk_env{keys(%disk_env)};
             untie(%disk_env);
         }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1176 loncom/lonnet/perl/lonnet.pm:1.1177
--- loncom/lonnet/perl/lonnet.pm:1.1176	Wed May 30 20:29:45 2012
+++ loncom/lonnet/perl/lonnet.pm	Fri Jun  1 11:39:33 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1176 2012/05/30 20:29:45 raeburn Exp $
+# $Id: lonnet.pm,v 1.1177 2012/06/01 11:39:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1957,7 +1957,7 @@
         } else {
             $domdefaults{'defaultquota'} = $domconfig{'quotas'};
         } 
-        my @usertools = ('aboutme','blog','portfolio');
+        my @usertools = ('aboutme','blog','webdav','portfolio');
         foreach my $item (@usertools) {
             if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
                 $domdefaults{$item} = $domconfig{'quotas'}{$item};
@@ -5647,6 +5647,7 @@
         %tools = (
                       aboutme   => 1,
                       blog      => 1,
+                      webdav    => 1,
                       portfolio => 1,
                  );
     }
@@ -5745,7 +5746,7 @@
             }
         }
     } else {
-        if ($context eq 'tools') {
+        if (($context eq 'tools') && ($tool ne 'webdav')) {
             $access = 1;
         } else {
             $access = 0;


More information about the LON-CAPA-cvs mailing list