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 $text 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
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 URL, usually $_SERVER['HTTP_REFERER']
75 * @param array $missing_params 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_project_disabled() - Exit with disabled feature error (by project admin).
110 * @param string $toptab needed for navigation
112 function exit_project_disabled($toptab = 'summary') {
113 exit_error(_('The Project Administrator has turned off this feature.'), $toptab);
117 * exit_form_double_submit() - Exit with double submit error.
119 * @param string $toptab needed for navigation
121 function exit_form_double_submit($toptab = '') {
122 exit_error(_('You Attempted To Double-submit this item. Please avoid double-clicking.'), $toptab);
127 // c-file-style: "bsd"