]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16423 - fixing bugs in last commit (portfolio_add_button refactor)
authormjollnir_ <mjollnir_>
Wed, 10 Sep 2008 16:43:33 +0000 (16:43 +0000)
committermjollnir_ <mjollnir_>
Wed, 10 Sep 2008 16:43:33 +0000 (16:43 +0000)
lib/portfoliolib.php

index c39b7700acd5d2e61c6dd9ee3c2bd4a6ed702849..e0672347f3846cdedddadf79a269289a0c8fe9b7 100644 (file)
@@ -82,6 +82,7 @@ class portfolio_add_button {
             $a->finish = $CFG->wwwroot . '/portfolio/add.php?id=' . $SESSION->portfolioexport;
             throw new portfolio_button_exception('alreadyexporting', 'portfolio', null, $a);
         }
+        $this->instances = portfolio_instances();
         if (empty($options)) {
             return true;
         }
@@ -91,7 +92,6 @@ class portfolio_add_button {
             }
             $this->{$key} = $value;
         }
-        $this->instances = portfolio_instances();
     }
 
     /*
@@ -157,7 +157,7 @@ class portfolio_add_button {
     *                    this is whole string, not key.  optional, defaults to 'Add to portfolio';
     */
     public function render($format=null, $addstr=null) {
-        echo $this->tohtml($format, $addstr);
+        echo $this->to_html($format, $addstr);
     }
 
     /*
@@ -174,8 +174,8 @@ class portfolio_add_button {
         if (!$this->is_renderable()) {
             return;
         }
-        if (empty($this->callbackclass) || $this->callbackfile) {
-            throw new portfolio_button_exception('mustcallsetcallbackoptions', 'portfolio');
+        if (empty($this->callbackclass) || empty($this->callbackfile)) {
+            throw new portfolio_button_exception('mustsetcallbackoptions', 'portfolio');
         }
         if (empty($this->formats)) {
             // use the caller defaults
@@ -264,7 +264,7 @@ class portfolio_add_button {
             // eg forum_print_attachments
             return false;
         }
-        if (!$this->instances) {
+        if (empty($this->instances) || count($this->instances) == 0) {
             return false;
         }
         return true;