]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15830 & MDL-15832: added a new intermediate abstract caller class for modules...
authormjollnir_ <mjollnir_>
Fri, 25 Jul 2008 15:17:23 +0000 (15:17 +0000)
committermjollnir_ <mjollnir_>
Fri, 25 Jul 2008 15:17:23 +0000 (15:17 +0000)
lang/en_utf8/portfolio.php
lib/portfoliolib.php
mod/assignment/lib.php
mod/assignment/type/online/assignment.class.php
mod/forum/lib.php
portfolio/type/boxnet/lib.php
portfolio/type/download/lib.php

index 64a38d735f1de7879657793217809442ef70ca16..f4210cba63ba67b644ac924e232aaea90bead1e5 100644 (file)
@@ -17,7 +17,6 @@ $string['err_uniquename'] = 'Portfolio name must be unique (per plugin)';
 $string['exporting'] = 'Exporting to portfolio';
 $string['exportcomplete'] = 'Portfolio export complete!';
 $string['failedtosendpackage'] = 'Failed to send your data to the selected portfolio system!';
-$string['format_html'] = 'HTML';
 $string['format_file'] = 'File';
 $string['format_mbkp'] = 'Moodle Backup';
 $string['hidden'] = 'Hidden';
@@ -26,6 +25,7 @@ $string['instanceismisconfigured'] = 'Portfolio instance is misconfigured, skipp
 $string['instancenotsaved'] = 'Failed to save portfolio';
 $string['instancenotdelete'] = 'Failed to delete portfolio';
 $string['instancesaved'] = 'Portfolio saved successfully';
+$string['invalidformat'] = 'Something is exporting an invalid format, $a';
 $string['manageportfolios'] = 'Manage portfolios';
 $string['manageyourportfolios'] = 'Manage your portfolios';
 $string['noavailableplugins'] = 'Sorry, but there are no available portfolios for you to export to';
index 3187319af69b276d15758406e495e86d890c43a7..1e99a1c02c2ebcd13c5c443107a519d560c3d9d8 100644 (file)
@@ -76,13 +76,6 @@ define('PORTFOLIO_STAGE_FINISHED', 7);
 // in the portfolio module, called format_{$value}
 // ****                         **** //
 
-/**
-* html - this is the second most basic fallback
-* after {@link PORTFOLIO_FORMAT_FILE}
-* for export. This should always be supported
-* in remote systems
-*/
-define('PORTFOLIO_FORMAT_HTML', 'html');
 
 /**
 * file - the most basic fallback format.
@@ -305,8 +298,8 @@ function portfolio_instances($visibleonly=true, $useronly=true) {
 function portfolio_supported_formats() {
     return array(
         PORTFOLIO_FORMAT_FILE,
-        PORTFOLIO_FORMAT_HTML,
-        PORTFOLIO_FORMAT_MBKP,
+        /*PORTFOLIO_FORMAT_MBKP, */ // later
+        /*PORTFOLIO_FORMAT_PIOP, */ // also later
     );
 }
 
@@ -719,6 +712,21 @@ abstract class portfolio_caller_base {
     public abstract function check_permissions();
 }
 
+abstract class portfolio_module_caller_base extends portfolio_caller_base {
+
+    protected $cm;
+
+    public function get_navigation() {
+        $extranav = array('name' => $this->cm->name, 'link' => $this->get_return_url());
+        return array($extranav, $this->cm);
+    }
+
+    public function get_return_url() {
+        global $CFG;
+        return $CFG->wwwroot . '/mod/' . $this->cm->modname . '/view.php?id=' . $this->cm->id;
+    }
+}
+
 /**
 * the base class for portfolio plguins
 * all plugins must subclass this.
@@ -1673,6 +1681,13 @@ final class portfolio_exporter {
             $callerobj = $this->caller;
         }
         $formats = array_intersect($this->instance->supported_formats(), $this->caller->supported_formats());
+        $allsupported = portfolio_supported_formats();
+        foreach ($formats as $key => $format) {
+            if (!in_array($format, $allsupported)) {
+                debugging(get_string('invalidformat', 'portfolio', $format));
+                unset($formats[$key]);
+            }
+        }
         $expectedtime = $this->instance->expected_time($this->caller->expected_time());
         if (count($formats) == 0) {
             // something went wrong, we should not have gotten this far.
index b0efd129fe67886d5bd6ea8150de103a387d45c9..accfbd55c3fd39264520e44a248354d8c74c5050 100644 (file)
@@ -3115,7 +3115,7 @@ function assignment_get_extra_capabilities() {
 }
 
 require_once($CFG->libdir . '/portfoliolib.php');
-class assignment_portfolio_caller extends portfolio_caller_base {
+class assignment_portfolio_caller extends portfolio_module_caller_base {
 
     private $assignment;
     private $assignmentfile;
@@ -3125,7 +3125,7 @@ class assignment_portfolio_caller extends portfolio_caller_base {
     public function __construct($callbackargs) {
         global $DB, $CFG;
 
-        if (! $cm = get_coursemodule_from_id('assignment', $callbackargs['assignmentid'])) {
+        if (! $this->cm = get_coursemodule_from_id('assignment', $callbackargs['assignmentid'])) {
             print_error('invalidcoursemodule');
         }
 
@@ -3163,22 +3163,9 @@ class assignment_portfolio_caller extends portfolio_caller_base {
     }
 
     public static function supported_formats() {
-        // try and cheat
-        if (isset($this) && $this->assignment->assignment->assignmenttype == 'online') {
-            return array(PORTFOLIO_FORMAT_HTML);
-        }
         return array(PORTFOLIO_FORMAT_FILE);
     }
 
-    public function get_return_url() {
-        global $CFG;
-        return $CFG->wwwroot . '/mod/assignment/view.php?id=' . $this->assignment->cm->id;
-    }
-
-    public function get_navigation() {
-        $extranav = array('name' => $this->assignment->cm->name, 'link' => $this->get_return_url());
-        return array($extranav, $this->assignment->cm);
-    }
 
     public function expected_time() {
         return PORTFOLIO_TIME_MODERATE; // @TODO check uploaded file size
index b5316370ac0600e362a6f5816c5391f3a5e6ad4f..bf06d2159152d70944545fa39382c6a51ee93148 100644 (file)
@@ -107,7 +107,7 @@ class assignment_online extends assignment_base {
                         'userid' => $USER->id,
                         'assignmentid' => $this->cm->id,
                     );
-                    portfolio_add_button('assignment_portfolio_caller', $p, '/mod/assignment/lib.php'));
+                    portfolio_add_button('assignment_portfolio_caller', $p, '/mod/assignment/lib.php');
                 } else if (!has_capability('mod/assignment:submit', $context)) { //fix for #4604
                     echo '<div style="text-align:center">'. get_string('guestnosubmit', 'assignment').'</div>';
                 } else if ($this->isopen()){    //fix for #4206
index 47b0732e2d4a27ad1f5f239206ccfb22e44fe9a2..bf750673e7503da20452d7543848fd695f206be3 100644 (file)
@@ -6897,9 +6897,8 @@ function forum_get_extra_capabilities() {
 }
 
 require_once($CFG->libdir . '/portfoliolib.php');
-class forum_portfolio_caller extends portfolio_caller_base {
+class forum_portfolio_caller extends portfolio_module_caller_base {
 
-    private $cm;
     private $post;
     private $forum;
     private $discussion;
@@ -6960,8 +6959,6 @@ class forum_portfolio_caller extends portfolio_caller_base {
     }
 
     static function supported_formats() {
-        // we always have to support the possibility here that we have attachments
-        // and HTML is a subset of FILE anyway.
         return array(PORTFOLIO_FORMAT_FILE);
     }
 
@@ -6975,10 +6972,6 @@ class forum_portfolio_caller extends portfolio_caller_base {
         return true;
     }
 
-    function get_navigation() {
-        $extranav = array('name' => $this->cm->name, 'link' => $this->get_return_url());
-        return array($extranav, $this->cm);
-    }
 }
 
 ?>
index e8c2a48db50625c82b4a2fe42b3da08fcea48b0e..0b0a2fb5ddb04aa166e9fec9ca7b6f12204761aa 100644 (file)
@@ -11,7 +11,7 @@ class portfolio_plugin_boxnet extends portfolio_plugin_base {
     private $folders;
 
     public static function supported_formats() {
-        return array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_HTML);
+        return array(PORTFOLIO_FORMAT_FILE);
     }
 
     public function prepare_package($tempdir) {
index 70318574271386783c4013718c5544e966bdd3f8..7775d75a647f6ebc6682f4f12dd1be259a3ba1b2 100644 (file)
@@ -8,7 +8,7 @@ class portfolio_plugin_download extends portfolio_plugin_base {
     protected $exportconfig;
 
     public static function supported_formats() {
-        return array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_HTML);
+        return array(PORTFOLIO_FORMAT_FILE);
         // @todo more later, like moodle backup for example
     }