Project

General

Profile

« Previous | Next » 

Revision 560

Added by Matthias almost 17 years ago

Updated form modul with features from the advanced form modul

View differences:

upgrade-script.php
198 198
}
199 199

  
200 200

  
201
//******************************************************************************
202
//The following lines upgrades the form modul from 2.6.x to the andvanced version from 2.7.x
203
//******************************************************************************
201 204

  
205
$database = new database(DB_URL);
202 206

  
207
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
208

  
209
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
210
	echo 'Database Field success_email_subject added successfully<br />';
211
}
212
echo mysql_error().'<br />';
213

  
214
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_text` TEXT NOT NULL AFTER `success_message`")) {
215
	echo 'Database Field success_email_text added successfully<br />';
216
}
217
echo mysql_error().'<br />';
218

  
219
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_from` VARCHAR(255) NOT NULL AFTER `success_message`")) {
220
	echo 'Database Field success_email_from added successfully<br />';
221
}
222
echo mysql_error().'<br />';
223

  
224
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_to` TEXT NOT NULL AFTER `success_message`")) {
225
	echo 'Database Field success_email_to added successfully<br />';
226
}
227
echo mysql_error().'<br />';
228

  
229
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_page` TEXT NOT NULL AFTER `success_message`")) {
230
	echo 'Database Field success_page added successfully<br />';
231
}
232
echo mysql_error().'<br />';
233

  
234
echo "<BR><B>Deleting field success_message from table mod_form_settings</B><BR>";
235

  
236
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` DROP `success_message`")) {
237
	echo 'Database field success_message droped successfully<br>';
238
}
239
echo mysql_error().'<br />';
240

  
241

  
242
// UPDATING DATA INTO FIELDS
243
echo "<BR>";
244

  
245
// These are the default setting
246
$success_page = 'none';
247
$success_email_to = '';
248
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
249
$success_email_text = addslashes($success_email_text);
250
$success_email_subject = 'You have submitted a form';
251

  
252
// Insert default settings into database
253
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
254
while($result = $query_dates->fetchRow()) {
255
	
256
	echo "<B>Add default settings data to database for form section_id= ".$result['section_id']."</b><BR>";
257
	$section_id = $result['section_id'];
258

  
259
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_page` = '$success_page' WHERE `section_id` = $section_id")) {
260
		echo 'Database data success_page added successfully<br>';
261
	}
262
	echo mysql_error().'<br />';
263
	
264
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_to` = '$success_email_to' WHERE `section_id` = $section_id")) {
265
		echo 'Database data success_email_to added successfully<br>';
266
	}
267
	echo mysql_error().'<br />';
268
	
269
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_text` = '$success_email_text' WHERE `section_id` = $section_id")) {
270
		echo 'Database data success_email_text added successfully<br>';
271
	}
272
	echo mysql_error().'<br />';
273
	
274
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_subject` = '$success_email_subject' WHERE `section_id` = $section_id")) {
275
		echo 'Database data success_email_subject added successfully<br>';
276
	}
277
	echo mysql_error().'<br />';
278
	
279
}
280

  
281
// copy field email_to to success_email_from
282
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings where section_id != 0 and page_id != 0");
283
while($result = $query_dates->fetchRow()) {
284
	
285
	echo "<B>Copying field email_to to success_email_from for form section_id= ".$result['section_id']."</B><BR>";
286
	$section_id = $result['section_id'];
287

  
288
	$success_email_from = $result['email_to'];
289
	if($database->query("UPDATE `".TABLE_PREFIX."mod_form_settings` SET `success_email_from` = '$success_email_from' WHERE `section_id` = $section_id")) {
290
		echo 'Copyied field email_to to success_email_from successfully<br>';
291
	}
292
	echo mysql_error().'<br />';
293
}
294

  
295
//******************************************************************************
296
//End of upgrade script for the form modul
297
//******************************************************************************
298

  
203 299
echo "<br /><br />Done<br />";
204 300

  
205 301
?>

Also available in: Unified diff