]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16134 - fixing regression introduced by conversion to exceptions
authormjollnir_ <mjollnir_>
Wed, 20 Aug 2008 09:11:20 +0000 (09:11 +0000)
committermjollnir_ <mjollnir_>
Wed, 20 Aug 2008 09:11:20 +0000 (09:11 +0000)
lib/portfoliolib.php

index 09923654ecf870fb1905fa7084bf8a44a7fceb6e..c3f6e3dfcf1f53d36371b66103b8bff4b7aca038 100644 (file)
@@ -1287,13 +1287,20 @@ abstract class portfolio_plugin_base {
         if (!portfolio_static_function($plugin, 'allows_multiple')) {
             // check we don't have one already
             if ($DB->record_exists('portfolio_instance', array('plugin' => $plugin))) {
-                throw new portfolio_exception('multipledisallowed', 'portfolio', $plugin);
+                throw new portfolio_exception('multipledisallowed', 'portfolio', '', $plugin);
             }
         }
         $newid = $DB->insert_record('portfolio_instance', $new);
         require_once($CFG->dirroot . '/portfolio/type/' . $plugin . '/lib.php');
         $classname = 'portfolio_plugin_'  . $plugin;
         $obj = new $classname($newid);
+        // the form contains extra hidden fields used by the controller and stuff
+        // unset them here to avoid an exception
+        foreach ((array)$config as $key => $value) {
+            if (!in_array($key, $obj->get_allowed_config())) {
+                unset($config->{$key});
+            }
+        }
         $obj->set_config($config);
         return $obj;
     }
@@ -1507,7 +1514,7 @@ abstract class portfolio_plugin_base {
             return true;
         }
         $a = (object)array('property' => $field, 'class' => get_class($this));
-        throw new portfolio_export_exception($this->get('exporter'), 'invalidproperty', 'portfolio', $a);
+        throw new portfolio_export_exception($this->get('exporter'), 'invalidproperty', 'portfolio', '', $a);
 
     }