$string['invalidconfigproperty'] = 'Could not find that config property ($a->property of $a->class)';
$string['manageportfolios'] = 'Manage portfolios';
$string['manageyourportfolios'] = 'Manage your portfolios';
+$string['multipledisallowed'] = 'Trying to create another instance of a plugin that has disallowed multiple instances ($a)';
$string['noavailableplugins'] = 'Sorry, but there are no available portfolios for you to export to';
$string['nocallbackfile'] = 'Something in the module you\'re trying to export from is broken - couldn\'t find a required file ($a)';
$string['nocommonformats'] = 'No common formats between any available portfolio plugin and the calling location $a';
* you shouldn't need to override it
* unless you're doing something really funky
*
+ * @param string $plugin portfolio plugin to create
+ * @param string $name name of new instance
+ * @param array $config what the admin config form returned
+ *
* @return object subclass of portfolio_plugin_base
*/
public static function create_instance($plugin, $name, $config) {
'plugin' => $plugin,
'name' => $name,
);
+ 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);
+ }
+ }
$newid = $DB->insert_record('portfolio_instance', $new);
require_once($CFG->dirroot . '/portfolio/type/' . $plugin . '/lib.php');
$classname = 'portfolio_plugin_' . $plugin;
public $exporter;
function setUp() {
+ $u = new StdClass;
+ $u->id = 100000000000;
$this->plugin = new mock_plugin();
$this->caller = new mock_caller();
$this->exporter = new portfolio_exporter(&$this->plugin, &$this->caller, '', array());
+ $this->exporter->set('user', $u);
$partialplugin = &new partialmock_plugin($this);
// Write a new text file
portfolio_plugin_base::create_instance('download', 'download1', array());
portfolio_plugin_base::create_instance('download', 'download2', array());
} catch (portfolio_exception $e) {
- $this->assertEqual('invalidinstance', $e->errorcode);
+ $this->assertEqual('multipledisallowed', $e->errorcode);
$gotexception = true;
}
$this->assertTrue($gotexception);