From: mjollnir_ Date: Tue, 2 Sep 2008 16:21:14 +0000 (+0000) Subject: MDL-14591 - added a get_name static method to portfolio plugins and use this as a... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0f71f48bcb49b1a834814427006fc6591445a604;p=moodle.git MDL-14591 - added a get_name static method to portfolio plugins and use this as a default title for adding new instances. also fixed a small bug in 'cleanup' function. nico - your flickr plugin is missing a string for the name --- diff --git a/lang/en_utf8/portfolio_boxnet.php b/lang/en_utf8/portfolio_boxnet.php index fc04ab299b..783d347ede 100644 --- a/lang/en_utf8/portfolio_boxnet.php +++ b/lang/en_utf8/portfolio_boxnet.php @@ -11,6 +11,7 @@ $string['noauthtoken'] = 'Could not retrieve an authentication token for use in $string['noticket'] = 'Could not retrieve a ticket from box.net to begin the authentication session'; $string['notarget'] = 'You must specify either an existing folder or a new folder to upload into'; $string['password'] = 'Your box.net password (will not be stored)'; +$string['pluginname'] = 'Box.net internet storage'; $string['sharedfolder'] = 'Shared'; $string['targetfolder'] = 'Target folder'; $string['username'] = 'Your box.net username (will not be stored)'; diff --git a/lang/en_utf8/portfolio_download.php b/lang/en_utf8/portfolio_download.php index 3f7e50bbf0..f2a3b9864b 100644 --- a/lang/en_utf8/portfolio_download.php +++ b/lang/en_utf8/portfolio_download.php @@ -1,5 +1,6 @@ diff --git a/lang/en_utf8/portfolio_mahara.php b/lang/en_utf8/portfolio_mahara.php index c19aa4d78e..95d646a8eb 100644 --- a/lang/en_utf8/portfolio_mahara.php +++ b/lang/en_utf8/portfolio_mahara.php @@ -15,4 +15,5 @@ $string['pf_description'] = 'Allow users to push Moodle content to this host
  • Dependency: You must also publish the SSO (Identify Provider) service to $a.
  • ' . '
  • Dependency: You must also subscribe to the SSO (Service Provider) service on $a
  • ' . '
  • Dependency: You must also enable the mnet authentication plugin.

  • '; +$string['pluginname'] = 'Mahara ePortfolio'; ?> diff --git a/lib/adminlib.php b/lib/adminlib.php index 1e7edc4b7e..000cd145e6 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4699,7 +4699,7 @@ class admin_setting_manageportfolio extends admin_setting { $row .= ' ' . get_string($i->get('visible') ? 'hide' : 'show') . '' . "\n"; } - $table->data[] = array($i->get('name'), $i->get('plugin'), $row); + $table->data[] = array($i->get('name'), $i->get_name() . ' (' . $i->get('plugin') . ')', $row); if (!in_array($i->get('plugin'), $alreadyplugins)) { $alreadyplugins[] = $i->get('plugin'); } @@ -4717,7 +4717,7 @@ class admin_setting_manageportfolio extends admin_setting { continue; } - $instancehtml .= '' . s($p) . '
    ' . "\n"; + $instancehtml .= '' . portfolio_static_function($p, 'get_name') . ' (' . s($p) . ')' . '
    ' . "\n"; $addable++; } diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index 1cbf181884..0e5396bb20 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -1017,6 +1017,8 @@ abstract class portfolio_plugin_base { */ public abstract function is_push(); + public static abstract function get_name(); + /** * check sanity of plugin * if this function returns something non empty, ALL instances of your plugin @@ -1734,7 +1736,7 @@ final class portfolio_admin_form extends moodleform { } } - if (is_array($insane)) { + if (isset($insane) && is_array($insane)) { $insane = array_shift($insane); } if (isset($insane) && is_string($insane)) { // something went wrong, warn... @@ -1752,7 +1754,10 @@ final class portfolio_admin_form extends moodleform { $data[$config] = $this->instance->get_config($config); } $this->set_data($data); + } else { + $this->set_data(array('name' => portfolio_static_function($this->plugin, 'get_name'))); } + $this->add_action_buttons(true, get_string('save', 'portfolio')); } @@ -2162,7 +2167,10 @@ final class portfolio_exporter { unset($SESSION->portfolioexport); return true; } - $this->get('instance')->cleanup(); + if ($this->get('instance')) { + // might not be set - before export really starts + $this->get('instance')->cleanup(); + } $DB->delete_records('portfolio_tempdata', array('id' => $this->id)); $fs = get_file_storage(); $fs->delete_area_files(SYSCONTEXTID, 'portfolio_exporter', $this->id); diff --git a/portfolio/type/boxnet/lib.php b/portfolio/type/boxnet/lib.php index 108a27645c..a2726cc078 100644 --- a/portfolio/type/boxnet/lib.php +++ b/portfolio/type/boxnet/lib.php @@ -10,6 +10,10 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base { private $folders; private $accounttree; + public static function get_name() { + return get_string('pluginname', 'portfolio_boxnet'); + } + public function prepare_package() { return true; // don't do anything else for this plugin, we want to send all files as they are. } diff --git a/portfolio/type/download/lib.php b/portfolio/type/download/lib.php index f09ff5961c..2296a54fcd 100644 --- a/portfolio/type/download/lib.php +++ b/portfolio/type/download/lib.php @@ -7,6 +7,10 @@ class portfolio_plugin_download extends portfolio_plugin_pull_base { protected $exportconfig; + public static function get_name() { + return get_string('pluginname', 'portfolio_download'); + } + public static function allows_multiple() { return false; } diff --git a/portfolio/type/flickr/lib.php b/portfolio/type/flickr/lib.php index 139c797526..dbf3a25194 100755 --- a/portfolio/type/flickr/lib.php +++ b/portfolio/type/flickr/lib.php @@ -6,6 +6,10 @@ class portfolio_plugin_flickr extends portfolio_plugin_push_base { private $flickr; + public static function get_name() { + return get_string('pluginname', 'portfolio_flickr'); + } + public function prepare_package() { $this->flickr = new phpFlickr($this->get_config('apikey'), $this->get_config('sharedsecret')); return true; // don't do anything else for this plugin, we want to send all files as they are. diff --git a/portfolio/type/mahara/lib.php b/portfolio/type/mahara/lib.php index b0ef8c87e8..93f58145cc 100644 --- a/portfolio/type/mahara/lib.php +++ b/portfolio/type/mahara/lib.php @@ -20,6 +20,10 @@ class portfolio_plugin_mahara extends portfolio_plugin_pull_base { private $sendtype; // whatever mahara has said it can handle (immediate or queued) private $filesmanifest; // manifest of files to send to mahara (set during prepare_package and sent later) + public static function get_name() { + return get_string('pluginname', 'portfolio_mahara'); + } + public static function get_allowed_config() { return array('mnethostid'); }