1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Bug action group include file
19 *
20 * @package MantisBT
21 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
24 *
25 * @uses access_api.php
26 * @uses bug_api.php
27 * @uses config_api.php
28 * @uses gpc_api.php
29 * @uses lang_api.php
30 * @uses print_api.php
31 */
32
33if( !defined( 'BUG_ACTIONGROUP_INC_ALLOW' ) ) {
34	return;
35}
36
37require_api( 'access_api.php' );
38require_api( 'bug_api.php' );
39require_api( 'config_api.php' );
40require_api( 'gpc_api.php' );
41require_api( 'lang_api.php' );
42require_api( 'print_api.php' );
43
44/**
45 * Prints the title for the custom action page.
46 * @return void
47 */
48function action_update_severity_print_title() {
49	echo lang_get( 'update_severity_title' );
50}
51
52/**
53 * Prints the field within the custom action form.  This has an entry for
54 * every field the user need to supply + the submit button.  The fields are
55 * added as rows in a table that is already created by the calling code.
56 * A row has two columns.
57 * @return void
58 */
59function action_update_severity_print_fields() {
60?>
61	<tr>
62		<th class="category">
63			<?php echo lang_get( 'update_severity_msg' ); ?>
64		</th>
65		<td>
66			<select name="severity" class="input-sm">';
67				<?php print_enum_string_option_list( 'severity' ); ?>
68			</select>
69		</td>
70	</tr>
71<?php
72}
73
74/**
75 * Validates the action on the specified bug id.
76 *
77 * @param integer $p_bug_id A bug identifier.
78 * @return string|null On failure: the reason why the action could not be validated. On success: null.
79 */
80function action_update_severity_validate( $p_bug_id ) {
81	$t_update_severity_threshold = config_get( 'update_bug_threshold' );
82	$t_bug_id = $p_bug_id;
83
84	if( bug_is_readonly( $t_bug_id ) ) {
85		return lang_get( 'actiongroup_error_issue_is_readonly' );
86	}
87
88	if( !access_has_bug_level( $t_update_severity_threshold, $t_bug_id ) ) {
89		return lang_get( 'access_denied' );
90	}
91
92	return null;
93}
94
95/**
96 * Executes the custom action on the specified bug id.
97 *
98 * @param integer $p_bug_id The bug id to execute the custom action on.
99 * @return null Previous validation ensures that this function doesn't fail. Therefore we can always return null to indicate no errors occurred.
100 */
101function action_update_severity_process( $p_bug_id ) {
102	$f_severity = gpc_get_string( 'severity' );
103	bug_set_field( $p_bug_id, 'severity', $f_severity );
104	return null;
105}
106