Commit | Line | Data |
---|---|---|
87fcac8d | 1 | <?php |
2 | /** | |
3 | * Moodle - Modular Object-Oriented Dynamic Learning Environment | |
4 | * http://moodle.org | |
5 | * Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com | |
6 | * | |
7 | * This program is free software: you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation, either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | * | |
0972665f | 20 | * @package core |
87fcac8d | 21 | * @subpackage portfolio |
22 | * @author Penny Leach <penny@catalyst.net.nz> | |
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL | |
24 | * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com | |
25 | * | |
26 | * This file contains all the portfolio exception classes. | |
27 | */ | |
28 | ||
0972665f PS |
29 | defined('MOODLE_INTERNAL') || die(); |
30 | ||
87fcac8d | 31 | /** |
32 | * top level portfolio exception. | |
33 | * sometimes caught and rethrown as {@see portfolio_export_exception} | |
34 | */ | |
35 | class portfolio_exception extends moodle_exception {} | |
36 | ||
37 | /** | |
38 | * exception to throw during an export - will clean up session and tempdata | |
39 | */ | |
40 | class portfolio_export_exception extends portfolio_exception { | |
41 | ||
42 | /** | |
43 | * constructor. | |
44 | * @param object $exporter instance of portfolio_exporter (will handle null case) | |
45 | * @param string $errorcode language string key | |
46 | * @param string $module language string module (optional, defaults to moodle) | |
47 | * @param string $continue url to continue to (optional, defaults to wwwroot) | |
48 | * @param mixed $a language string data (optional, defaults to null) | |
49 | */ | |
50 | public function __construct($exporter, $errorcode, $module=null, $continue=null, $a=null) { | |
ea95cf9c | 51 | global $CFG; |
bf81b168 SM |
52 | // This static variable is necessary because sometimes the code below |
53 | // which tries to obtain a continue link can cause one of these | |
54 | // exceptions to be thrown. This would create an infinite loop (until | |
55 | // PHP hits its stack limit). Using this static lets us make the | |
56 | // nested constructor finish immediately without attempting to call | |
57 | // methods that might fail. | |
58 | static $inconstructor = false; | |
11e7b506 | 59 | |
bf81b168 SM |
60 | if (!$inconstructor && !empty($exporter) && |
61 | $exporter instanceof portfolio_exporter) { | |
62 | $inconstructor = true; | |
63 | try { | |
64 | if (empty($continue)) { | |
65 | $caller = $exporter->get('caller'); | |
66 | if (!empty($caller) && $caller instanceof portfolio_caller_base) { | |
67 | $continue = $exporter->get('caller')->get_return_url(); | |
68 | } | |
87fcac8d | 69 | } |
bf81b168 SM |
70 | // this was previously only called if we were in cron, |
71 | // but I think if there's always an exception, we should clean up | |
72 | // rather than force the user to resolve the export later. | |
73 | $exporter->process_stage_cleanup(); | |
74 | } catch(Exception $e) { | |
75 | // Ooops, we had an exception trying to get caller | |
76 | // information. Ignore it. | |
87fcac8d | 77 | } |
bf81b168 | 78 | $inconstructor = false; |
87fcac8d | 79 | } |
80 | parent::__construct($errorcode, $module, $continue, $a); | |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
85 | * exception for callers to throw when they have a problem. | |
86 | * usually caught and rethrown as {@see portfolio_export_exception} | |
87 | */ | |
88 | class portfolio_caller_exception extends portfolio_exception {} | |
89 | ||
90 | /** | |
91 | * exception for portfolio plugins to throw when they have a problem. | |
92 | * usually caught and rethrown as {@see portfolio_export_exception} | |
93 | */ | |
94 | class portfolio_plugin_exception extends portfolio_exception {} | |
95 | ||
ce09fecc | 96 | /** |
97 | * exception for interacting with the button class | |
98 | */ | |
99 | class portfolio_button_exception extends portfolio_exception {} | |
59dd457e PL |
100 | |
101 | /** | |
102 | * leap2a exception - for invalid api calls | |
103 | */ | |
104 | class portfolio_format_leap2a_exception extends portfolio_exception {} |