File: responses_admin.php

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (119 lines) | stat: -rw-r--r-- 4,962 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
 * Site Admin page to edit canned responces for project rejection
 *
 * This page is linked from approve-pending.php
 *
 * Copyright 1999-2001 (c) VA Linux Systems
 *
 * @version   $Id: responses_admin.php 4591 2005-08-28 14:51:51Z ogi $
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

require_once('pre.php');
require_once('common/include/account.php');
require_once('www/include/canned_responses.php');
require_once('www/admin/admin_utils.php');
require_once('www/project/admin/project_admin_utils.php');

site_admin_header(array('title'=>$Language->getText('admin_responses','title')));

function check_select_value($value, $type) {
	global $Language;
	if( $value == "100" ) {
		print("<span style=\"color:red\"><strong>".$Language->getText('admin_responses','you_cant',array($GLOBALS['type']))."</strong></span><br />\n");
	}
}
?>

<form method="post" action="<?php echo $PHP_SELF; ?>">
<?php echo $Language->getText('admin_responses','existing_responses'); ?><?php echo get_canned_responses(); ?>
<!-- Reinhard Spisser: commenting localization, since otherwise it will not work -->
<!--
<input name="action" type="submit" value="<?php echo $Language->getText('admin','edit'); ?>"/>
<input name="action" type="submit" value="<?php echo $Language->getText('admin','delete'); ?>" />
--->
<input name="action" type="submit" value="Edit"/>
<input name="action" type="submit" value="Delete" />
<input type="checkbox" name="sure" value="<?php echo $Language->getText('admin','yes'); ?>" />
<?php  echo $Language->getText('admin_responses','yes_im_sure'); ?>
</form>

<br /><br />

<?php

if( $action == "Edit" ) {
	// Edit Response
	check_select_value($response_id, $action);
	if( $action2 ) {
		db_query("UPDATE canned_responses SET response_title='$response_title', response_text='$response_text' WHERE response_id='$response_id'");
		print(" <strong>" .$Language->getText('admin_responses','edit_response')."</strong> ");
	} else {
		$res = db_query("SELECT * FROM canned_responses WHERE response_id='$response_id'");
		$row = db_fetch_array($res);
		$response_title=$row[1];
		$response_text=$row[2];
?>

<?php echo $Language->getText('admin_responses','edit_response_other'); ?><br />
<form method="post" action="<?php echo $PHP_SELF; ?>">
<?php echo $Language->getText('admin_responses','response_title'); ?><input type="text" name="response_title" size="30" maxlength="25" value="<?php echo $response_title; ?>" /><br />
<?php echo $Language->getText('admin_responses','response_text'); ?><br />
<textarea name="response_text" cols="50" rows="10"><?php echo $response_text; ?></textarea>
<input type="hidden" name="response_id" value="<?php echo $response_id; ?>" />
<input type="hidden" name="action2" value="<?php echo $Language->getText('admin_responses','go'); ?>" />
<input type="hidden" name="action" value="Edit">
<input type="submit" name="actionsubmit" value="<?php echo $Language->getText('admin','edit'); ?>" />
</form>

<?php
	}
} else if ( $action == "Delete" ) {
	// Delete Response
	check_select_value($response_id, $action);
	if( $sure == "yes" ) {
		db_query("DELETE FROM canned_responses WHERE response_id='$response_id'");
		print(" <strong>" .$Language->getText('admin_responses','deleted_resposes')."</strong> ");
	} else {
		print( $Language->getText('admin_responses','not_sure_dont_click')."<br />");
		print("<em>" .$Language->getText('admin_responses','by_the_way')."</em><br />\n");
	}
} else if ( $action == "Create" ) {
	// New Response
	add_canned_response($response_title, $response_text);
	print(" <strong>" .$Language->getText('admin_responses','add_response')."</strong> ");
} else {
?>

<?php echo $Language->getText('admin_responses','create_new_response'); ?><br />
<form method="post" action="<?php echo $PHP_SELF; ?>">
<?php echo $Language->getText('admin_responses','response_title'); ?><input type="text" name="response_title" size="30" maxlength="25" /><br />
<?php echo $Language->getText('admin_responses','response_text'); ?><br />
<textarea name="response_text" cols="50" rows="10"></textarea>
<br />
<input type="hidden" name="action" value="Create">
<input type="submit" name="actions" value="<?php echo $Language->getText('admin_responses','create'); ?>" />
</form>

<?php
}

site_admin_footer(array());

?>