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

banghart lon-capa-cvs@mail.lon-capa.org
Fri, 21 Oct 2005 19:20:59 -0000


banghart		Fri Oct 21 15:20:59 2005 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  	Remove superfluous field names.
  	Read course info and display only active course metadata
  	May even work to some extent.
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.114 loncom/interface/lonmeta.pm:1.115
--- loncom/interface/lonmeta.pm:1.114	Wed Oct 19 17:53:16 2005
+++ loncom/interface/lonmeta.pm	Fri Oct 21 15:20:58 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.114 2005/10/19 21:53:16 banghart Exp $
+# $Id: lonmeta.pm,v 1.115 2005/10/21 19:20:58 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -237,23 +237,8 @@
 # The field names
 sub fieldnames {
     my $file_type=shift;
-    my %fields;
-    %fields = 
-        (%fields,
-         'title' => 'Title',
-         'author' =>'Author(s)',
-         'authorspace' => 'Author Space',
-         'modifyinguser' => 'Last Modifying User',
-         'subject' => 'Subject',
-         'keywords' => 'Keyword(s)',
-         'notes' => 'Notes',
-         'abstract' => 'Abstract',
-         'lowestgradelevel' => 'Lowest Grade Level',
-         'highestgradelevel' => 'Highest Grade Level');
-    if ($file_type eq 'portfolio') {
-        %fields = 
-        (%fields,
-         'title' => 'Title',
+    my %fields = 
+        ('title' => 'Title',
          'author' =>'Author(s)',
          'authorspace' => 'Author Space',
          'modifyinguser' => 'Last Modifying User',
@@ -263,21 +248,6 @@
          'abstract' => 'Abstract',
          'lowestgradelevel' => 'Lowest Grade Level',
          'highestgradelevel' => 'Highest Grade Level');
-    }
-    if ($file_type eq 'restrictedportfolio') {
-        %fields = 
-        (%fields,
-         'metadata.title' => 'Title',
-         'metadata.author' =>'Author(s)',
-         'metadata.authorspace' => 'Author Space',
-         'metadata.modifyinguser' => 'Last Modifying User',
-         'metadata.subject' => 'Subject',
-         'metadata.keywords' => 'Keyword(s)',
-         'metadata.notes' => 'Notes',
-         'metadata.abstract' => 'Abstract',
-         'metadata.lowestgradelevel' => 'Lowest Grade Level',
-         'metadata.highestgradelevel' => 'Highest Grade Level');
-    }        
     if (! defined($file_type) || $file_type ne 'portfolio') {
         %fields = 
         (%fields,
@@ -1033,18 +1003,12 @@
         $r->print('<script language="JavaScript">'.
                   &Apache::loncommon::browser_and_searcher_javascript().
                   '</script>');
-        if (($file_type eq 'portfolio') && $env{'form.metacourse'}) {
-            $file_type = 'restrictedportfolio';
-        }
         my %lt=&fieldnames($file_type);
 	my $output;
 	my @fields;
 	if ($file_type eq 'portfolio') {
 	    @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
 	                'highestgradelevel');
-	} elsif ($file_type eq 'restrictedportfolio') {
-	    @fields =  ('metadata.author','metadata.title','metadata.subject','metadata.keywords','metadata.abstract','metadata.notes','metadata.lowestgradelevel',
-	                'metadata.highestgradelevel');
 	} else {
 	    @fields = ('author','title','subject','keywords','abstract','notes',
                  'copyright','customdistributionfile','language',
@@ -1061,20 +1025,28 @@
                 $Apache::lonpublisher::metadatafields{'copyright'}=
                     'default';
             }
-            $output.=('<p>'.$lt{$_}.': '.
-                      &prettyinput($_,
+            if ($env{'form.metacourse'}) {
+                # handle restrictions here
+                $env{'form.metacourse'} =~ m/(^.+)\.description$/;
+                my $key_base = $1;
+                if ($env{$key_base.'.metadata.'.$_.'.options'} =~ m/active/) {
+                    $output.=('<p>'.$lt{$_}.': '.
+                            &prettyinput($_,
 				   $Apache::lonpublisher::metadatafields{$_},
 				   'new_'.$_,'defaultmeta').'</p>');
- 
+                }
+            } else {
+                $output.=('<p>'.$lt{$_}.': '.
+                            &prettyinput($_,
+				   $Apache::lonpublisher::metadatafields{$_},
+				   'new_'.$_,'defaultmeta').'</p>');
+            }
         }
         if ($env{'form.store'}) {
             my $mfh;
             my $formname='store'; 
             my $file_content;
             foreach my $meta_field (keys %env) {
-                if ($meta_field=~m/^form.instmeta_(.+)_(\d+)$/) {
-                    $r->print('Found a field<br>');
-                }
                 if (&Apache::loncommon::get_env_multiple('form.keywords')) {
                 $Apache::lonpublisher::metadatafields{'coursekeyword'} = 
                         join (', ', &Apache::loncommon::get_env_multiple('form.keywords'));
@@ -1109,7 +1081,6 @@
                 $env{'form.'.$formname.'.filename'}=$new_fn;
                 &Apache::lonnet::userfileupload('uploaddoc','',
 	        	 'portfolio'.$env{'form.currentpath'});
-	        my $status =&Apache::lonnet::userfileupload($formname,'','portfolio');
                 if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') {
                     $r->print('<p><font color="red">'.
                       &mt('Could not write metadata').', '.