3 * FusionForge : Exit functions
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010-2011, Franck Villaume - Capgemini
7 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * exit_error() - Exit PHP with error
28 * @param string Error text
29 * @param string toptab for navigation bar
31 function exit_error($text = "", $toptab = '') {
32 global $HTML, $group_id;
33 $HTML->header(array('title'=>_('Exiting with error'), 'group'=>$group_id, 'toptab'=>$toptab));
34 echo $HTML->error_msg(htmlspecialchars($text));
35 $HTML->footer(array());
40 * exit_permission_denied() - Exit with permission denied error
42 * @param string $reason_descr
43 * @param string toptab needed for navigation
45 function exit_permission_denied($reason_descr = '', $toptab = '') {
46 if(!session_loggedin()) {
50 $reason_descr=_('Permission denied. This project\'s administrator will have to grant you permission to view this page.');
52 exit_error($reason_descr, $toptab);
57 * exit_not_logged_in() - Exit with not logged in error
59 function exit_not_logged_in() {
60 //instead of a simple error page, now take them to the login page
61 session_redirect ("/account/login.php?triggered=1&return_to=".urlencode(getStringFromServer('REQUEST_URI')));
65 * exit_no_group() - Exit with no group chosen error
66 * @param string toptab
68 function exit_no_group() {
69 exit_error(_('Permission denied. No project was chosen, project does not exist or you can\'t access it.'), '');
73 * exit_missing_param() - Exit with missing required parameters error
75 * @param string URL : usually $_SERVER['HTTP_REFERER']
76 * @param array array of missing parameters
77 * @param string toptab needed for navigation
79 function exit_missing_param($url = '', $missing_params = array(), $toptab = '') {
80 if (!empty($missing_params)) {
81 $error = _('Missing required parameters : ');
82 foreach ($missing_params as $missing_param) {
83 $error .= $missing_param.' ';
86 $error = sprintf(_('Missing required parameters.'));
88 $redirect_url = util_find_relative_referer($url);
89 if (!empty($redirect_url)) {
90 if (strpos($redirect_url,'?')) {
91 session_redirect($redirect_url.'&error_msg='.urlencode($error));
93 session_redirect($redirect_url.'?error_msg='.urlencode($error));
95 exit_error($error, $toptab);
100 * exit_disabled() - Exit with disabled feature error.
102 * @param string toptab needed for navigation
104 function exit_disabled($toptab = 'summary') {
105 exit_error(_('The Site Administrator has turned off this feature.'), $toptab);
109 * exit_project_disabled() - Exit with disabled feature error (by project admin).
111 * @param string toptab needed for navigation
113 function exit_project_disabled($toptab = 'summary') {
114 exit_error(_('The Project Administrator has turned off this feature.'), $toptab);
118 * exit_form_double_submit() - Exit with double submit error.
120 * @param string toptab needed for navigation
122 function exit_form_double_submit($toptab = '') {
123 exit_error(_('You Attempted To Double-submit this item. Please avoid double-clicking.'), $toptab);
128 // c-file-style: "bsd"