3 * FusionForge : Exit functions
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * exit_error() - Exit PHP with error
27 * @param string Error text
28 * @param string toptab for navigation bar
30 function exit_error($text = "", $toptab = '') {
31 global $HTML, $group_id;
32 $HTML->header(array('title'=>_('Exiting with error'), 'group'=>$group_id, 'toptab'=>$toptab));
33 echo $HTML->error_msg(htmlspecialchars($text));
34 $HTML->footer(array());
39 * exit_permission_denied() - Exit with permission denied error
41 * @param string $reason_descr
42 * @param string toptab needed for navigation
44 function exit_permission_denied($reason_descr = '', $toptab = '') {
45 if(!session_loggedin()) {
49 $reason_descr=_('Permission denied. This project\'s administrator will have to grant you permission to view this page.');
51 exit_error($reason_descr, $toptab);
56 * exit_not_logged_in() - Exit with not logged in error
58 function exit_not_logged_in() {
59 //instead of a simple error page, now take them to the login page
60 session_redirect ("/account/login.php?triggered=1&return_to=".urlencode(getStringFromServer('REQUEST_URI')));
64 * exit_no_group() - Exit with no group chosen error
65 * @param string toptab
67 function exit_no_group() {
68 exit_error(_('Permission denied. No project was chosen, project does not exist or you can\'t access it.'), '');
72 * exit_missing_param() - Exit with missing required parameters error
74 * @param string URL : usually $_SERVER['HTTP_REFERER']
75 * @param array array of missing parameters
76 * @param string toptab needed for navigation
78 function exit_missing_param($url = '', $missing_params = array(), $toptab = '') {
79 if (!empty($missing_params)) {
80 $error = _('Missing required parameters : ');
81 foreach ($missing_params as $missing_param) {
82 $error .= $missing_param.' ';
85 $error = sprintf(_('Missing required parameters.'));
87 $redirect_url = util_find_relative_referer($url);
88 if (!empty($redirect_url)) {
89 if (strpos($redirect_url,'?')) {
90 session_redirect($redirect_url.'&error_msg='.urlencode($error));
92 session_redirect($redirect_url.'?error_msg='.urlencode($error));
94 exit_error($error, $toptab);
99 * exit_disabled() - Exit with disabled feature error.
101 * @param string toptab needed for navigation
103 function exit_disabled($toptab = 'summary') {
104 exit_error(_('The Site Administrator has turned off this feature.'), $toptab);
108 * exit_form_double_submit() - Exit with double submit error.
110 * @param string toptab needed for navigation
112 function exit_form_double_submit($toptab = '') {
113 exit_error(_('You Attempted To Double-submit this item. Please avoid double-clicking.'), $toptab);
118 // c-file-style: "bsd"