MDL-16322 - switch calls to print_error to throw exceptions in portfolio callers
authormjollnir_ <mjollnir_>
Thu, 4 Sep 2008 10:38:44 +0000 (10:38 +0000)
committermjollnir_ <mjollnir_>
Thu, 4 Sep 2008 10:38:44 +0000 (10:38 +0000)
lib/portfoliolib.php
mod/assignment/lib.php
mod/forum/lib.php
mod/resource/lib.php

index 0e5396b..f9d44fe 100644 (file)
@@ -206,7 +206,7 @@ function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null,
         $a = new StdClass;
         $a->cancel = $CFG->wwwroot . '/portfolio/add.php?cancel=1';
         $a->finish = $CFG->wwwroot . '/portfolio/add.php?id=' . $SESSION->portfolioexport;
-        print_error('alreadyexporting', 'portfolio', null, $a);
+        throw new portfolio_exception('alreadyexporting', 'portfolio', null, $a);
     }
 
     if (empty($callbackfile)) {
@@ -292,8 +292,7 @@ function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null,
             $linkoutput .= '">' . $addstr .'</a>';
         break;
         default:
-            debugging('asdfd');
-            print_error('invalidaddformat', 'portfolio', '', $format);
+            debugging(get_string('invalidaddformat', 'portfolio', $format));
     }
     $output = (in_array($format, array(PORTFOLIO_ADD_FULL_FORM, PORTFOLIO_ADD_ICON_FORM)) ? $formoutput : $linkoutput);
     if ($return) {
index c8f6326..787dcf0 100644 (file)
@@ -3153,11 +3153,11 @@ class assignment_portfolio_caller extends portfolio_module_caller_base {
         global $DB, $CFG;
 
         if (! $this->cm = get_coursemodule_from_id('assignment', $callbackargs['assignmentid'])) {
-            print_error('invalidcoursemodule');
+            throw new portfolio_caller_exception('invalidcoursemodule');
         }
 
         if (! $assignment = $DB->get_record("assignment", array("id"=>$this->cm->instance))) {
-            print_error('invalidid', 'assignment');
+            throw new portfolio_caller_exception('invalidid', 'assignment');
         }
 
         $this->assignmentfile = $CFG->dirroot . '/mod/assignment/type/' . $assignment->assignmenttype . '/assignment.class.php';
@@ -3165,7 +3165,7 @@ class assignment_portfolio_caller extends portfolio_module_caller_base {
         $assignmentclass = "assignment_$assignment->assignmenttype";
         $this->assignment= new $assignmentclass($this->cm->id, $assignment, $this->cm);
         if (!$this->assignment->portfolio_exportable()) {
-            print_error('notexportable', 'portfolio', $this->get_return_url());
+            throw new portfolio_caller_exception('notexportable', 'portfolio', $this->get_return_url());
         }
         $this->userid = $callbackargs['userid'];
         $this->file = (array_key_exists('file', $callbackargs)) ? $callbackargs['file'] : null;
index 45fadf3..1aef9a7 100644 (file)
@@ -7206,7 +7206,7 @@ class forum_portfolio_caller extends portfolio_module_caller_base {
                 throw new portfolio_caller_exception('attachmentsnopost', 'forum');
             }
             if (!$f = $fs->get_file_by_id($this->attachment)) {
-                print_error('noattachments', 'forum');
+                throw new portfolio_caller_exception('noattachments', 'forum');
             }
             $this->postfiles = array($f);
             if (in_array($f->get_mimetype(), array('image/gif', 'image/jpeg', 'image/png'))) {
index 1d9964b..16d0c57 100644 (file)
@@ -715,7 +715,7 @@ class resource_portfolio_caller extends portfolio_module_caller_base {
         global $CFG;
         global $DB;
         if (!array_key_exists('id', $callbackargs) || !$this->cm = get_coursemodule_from_instance('resource', $callbackargs['id'])) {
-            print_error('invalidid');
+            throw new portfolio_caller_exception('invalidid');
         }
         $this->cm->type = $DB->get_field('resource', 'type', array('id' => $this->cm->instance));
         $resourceclass = 'resource_'. $this->cm->type;