[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm

banghart lon-capa-cvs@mail.lon-capa.org
Mon, 31 Oct 2005 01:49:21 -0000


banghart		Sun Oct 30 20:49:21 2005 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  	Flailing wildly. Moved copyright default setting outside loop
  	of fields. Added courserestricted tag. Still confused.
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.119 loncom/interface/lonmeta.pm:1.120
--- loncom/interface/lonmeta.pm:1.119	Wed Oct 26 19:37:51 2005
+++ loncom/interface/lonmeta.pm	Sun Oct 30 20:49:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.119 2005/10/26 23:37:51 banghart Exp $
+# $Id: lonmeta.pm,v 1.120 2005/10/31 01:49:21 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -247,7 +247,9 @@
          'notes' => 'Notes',
          'abstract' => 'Abstract',
          'lowestgradelevel' => 'Lowest Grade Level',
-         'highestgradelevel' => 'Highest Grade Level');
+         'highestgradelevel' => 'Highest Grade Level',
+         'courserestricted' => 'Course Restricting Metadata');
+         
     if (! defined($file_type) || $file_type ne 'portfolio') {
         %fields = 
         (%fields,
@@ -313,7 +315,8 @@
             $r->print('Select your course<br />');
             $r->print('<select name="metacourse" >');
         }
-        $r->print('<option value="'.$key.'">');
+        $key =~ m/(^.+)\.description$/;
+        $r->print('<option value="'.$1.'">');
         $r->print($courses{$key});
         $r->print('</option>');
     }
@@ -1050,7 +1053,7 @@
 	my @fields;
 	if ($file_type eq 'portfolio') {
 	    @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
-	                'highestgradelevel');
+	                'highestgradelevel','courserestricted');
 	} else {
 	    @fields = ('author','title','subject','keywords','abstract','notes',
                  'copyright','customdistributionfile','language',
@@ -1058,24 +1061,36 @@
                  'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
                  'obsolete','obsoletereplacement');
         }
+        my $metacourse;
+        if ($env{'form.metacourse'} ) {
+            $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'};
+            $metacourse = $env{'form.metacourse'};
+         } else {
+            if (! $Apache::lonpublisher::metadatafields{'courserestricted'}) {
+                $Apache::lonpublisher::metadatafields{'courserestricted'}=
+                    'none';
+                $metacourse = 'none';
+            } else {
+                $metacourse = $Apache::lonpublisher::metadatafields{'courserestricted'};
+            }
+        }
+        if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
+                $Apache::lonpublisher::metadatafields{'copyright'}=
+                'default';
+        }
+        &Apache::lonnet::logthis($metacourse.' is the restriction');
         foreach (@fields) {
             if (defined($env{'form.new_'.$_})) {
                 $Apache::lonpublisher::metadatafields{$_}=
                     $env{'form.new_'.$_};
             }
-            if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
-                $Apache::lonpublisher::metadatafields{'copyright'}=
-                    'default';
-            }
-            if ($env{'form.metacourse'}) {
+            if ($metacourse ne 'none') {
                 # handle restrictions here
-                $env{'form.metacourse'} =~ m/(^.+)\.description$/;
-                my $key_base = $1;
-                if ($env{$key_base.'.metadata.'.$_.'.options'} =~ m/active/) {
+                if ($env{$metacourse.'.metadata.'.$_.'.options'} =~ m/active/) {
                     $output.=('<p>'.$lt{$_}.': '.
                             &prettyinput($_,
 				   $Apache::lonpublisher::metadatafields{$_},
-				   'new_'.$_,'defaultmeta',undef,undef,undef,undef,$key_base).'</p>');
+				   'new_'.$_,'defaultmeta',undef,undef,undef,undef,$metacourse).'</p>');
                 }
             } else {
                 $output.=('<p>'.$lt{$_}.': '.