MDL-16322 - switch calls to print_error to throw exceptions in portfolio callers

This commit is contained in:
mjollnir_ 2008-09-04 10:38:44 +00:00
parent 9f3ef2238d
commit 3bb8a2c75c
4 changed files with 7 additions and 8 deletions

View 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) {

View 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;

View 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'))) {

View 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;