--- loncom/lonnet/perl/lonnet.pm 2006/06/07 18:41:57 1.745 +++ loncom/lonnet/perl/lonnet.pm 2006/06/07 21:38:25 1.747 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.745 2006/06/07 18:41:57 raeburn Exp $ +# $Id: lonnet.pm,v 1.747 2006/06/07 21:38:25 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4555,18 +4555,13 @@ sub is_locked { $env{'user.domain'},$env{'user.name'}); my ($tmp)=keys(%locked); if ($tmp=~/^error:/) { undef(%locked); } - if (ref($locked{$file_name}) eq 'ARRAY') { $is_locked = 'false'; foreach my $entry (@{$locked{$file_name}}) { if (ref($entry) eq 'ARRAY') { - if ($$entry[0] eq 'access' || $$entry[0] eq 'accesscount') { - next; - } else { - $is_locked = 'true'; - last; - } + $is_locked = 'true'; + last; } } } else { @@ -4687,15 +4682,8 @@ sub get_access_controls { } if (ref($value) eq "ARRAY") { foreach my $stored_what (@{$value}) { - if (ref($stored_what) eq 'ARRAY') { - if ($$stored_what[0] eq 'access') { - if (!defined($access{$file_name})) { - %{$access{$file_name}} = (); - } - $access{$file_name}{$$stored_what[1]}=$$stored_what[2]; - } else { - next; - } + if (ref($stored_what) eq 'HASH') { + $access{$file_name} = $$stored_what{'access'}; } } } @@ -4720,13 +4708,10 @@ sub get_marked_as_readonly { if (ref($value) eq "ARRAY"){ foreach my $stored_what (@{$value}) { my $cmp2=$stored_what; - if (ref($stored_what)) { - if ($$stored_what[0] eq 'access' || - $$stored_what[0] eq 'accesscount') { - next; - } else { - $cmp2=join('',@{$stored_what}); - } + if (ref($stored_what eq 'HASH')) { + next; + } elsif (ref($stored_what eq 'ARRAY')) { + $cmp2=join('',@{$stored_what}); } if ($cmp1 eq $cmp2) { push(@readonly_files, $file_name); @@ -4754,16 +4739,12 @@ sub get_marked_as_readonly_hash { if (ref($value) eq "ARRAY"){ foreach my $stored_what (@{$value}) { if (ref($stored_what) eq 'ARRAY') { - if ($$stored_what[0] eq 'access' || - $$stored_what[0] eq 'accesscount') { - next; + if ($stored_what eq $what) { + $readonly_files{$file_name} = 'locked'; + } elsif (!defined($what)) { + $readonly_files{$file_name} = 'locked'; } } - if ($stored_what eq $what) { - $readonly_files{$file_name} = 'locked'; - } elsif (!defined($what)) { - $readonly_files{$file_name} = 'locked'; - } } } } @@ -4789,16 +4770,13 @@ sub unmark_as_readonly { if (ref($current_locks) eq "ARRAY"){ foreach my $locker (@{$current_locks}) { my $compare=$locker; - if (ref($locker) eq 'ARRAY') { - if ($$locker[0] eq 'access' || - $$locker[0] eq 'accesscount') { - push(@new_locks,$locker); - next; - } + if (!ref($locker) eq 'ARRAY') { + push(@new_locks,$locker); + } else { $compare=join('',@{$locker}); - } - if ($compare ne $symb_crs) { - push(@new_locks, $locker); + if ($compare ne $symb_crs) { + push(@new_locks, $locker); + } } } if (scalar(@new_locks) > 0) { @@ -7821,6 +7799,45 @@ removeuploadedurl(): convience function Args: url: a full /uploaded/... url to delete +=item * + +get_portfile_permissions(): + Args: + domain: domain of user or course contain the portfolio files + user: name of user or num of course contain the portfolio files + Returns: + hashref of a dump of the proper file_permissions.db + + +=item * + +get_access_controls(): + +Args: + current_permissions: the hash ref returned from get_portfile_permissions() + group: (optional) the group you want the files associated with + file: (optional) the file you want access info on + +Returns: + a hash containing + keys of 'control type' (possiblities?) + values are XML contianing settings + +Internal notes: + + access controls are stored in file_permissions.db as array of arrays and a hash. + array refs -> are locks + hash refs -> all other types of controls + and will contain keys + + 'access' -> hash where keys are access controls and + values are settings (in XML) + + 'accesscount' -> scalar - equal to the next number to + use as the first part of an access + control key when defining a new + control. + =back =head2 HTTP Helper Routines