Project

General

Profile

« Previous | Next » 

Revision 638

Added by thorn almost 17 years ago

Allow a user-supplied From-Name in form-settings for email und success-email.

View differences:

trunk/CHANGELOG
23 23
!	added possibility to select the default backend language during installation process
24 24
!	Re-introduced Changeset 593 (filename in pages/ from page_title instead of menu_title)
25 25
#	Fixed some bugs in the Javascript Admin modul
26
28-Jan-2008 Thomas Hornik
26
28-Jan-2008 Thomas Hornik
27
+	Allow a user-supplied From-Name in form-settings for email und success-email.
27 28
!	changeset 627: menu_link and search/search.php needs some minor changes, too.
28 29
+	Added Text-CAPTCHA on request. The captcha-text will be stored in temp/.captcha_text.txt
29 30
27-Jan-2008 Christian Sommer
trunk/wb/framework/class.wb.php
295 295
	}
296 296

  
297 297
	// Validate send email
298
	function mail($fromaddress, $toaddress, $subject, $message) {
298
	function mail($fromaddress, $toaddress, $subject, $message, $fromname='') {
299 299
		/* 
300 300
			INTEGRATED OPEN SOURCE PHPMAILER CLASS FOR SMTP SUPPORT AND MORE
301 301
			SOME SERVICE PROVIDERS DO NOT SUPPORT SENDING MAIL VIA PHP AS IT DOES NOT PROVIDE SMTP AUTHENTICATION
......
313 313
		
314 314
		// create PHPMailer object and define default settings
315 315
		$myMail = new wbmailer();
316
      
316

  
317 317
		// set user defined from address
318 318
		if ($fromaddress!='') {
319
			if($fromname!='') $myMail->FromName = $fromname;         // FROM-NAME
319 320
			$myMail->From = $fromaddress;                            // FROM:
320 321
			$myMail->AddReplyTo($fromaddress);                       // REPLY TO:
321 322
		}
trunk/wb/framework/class.wbmailer.php
89 89
			$this->CharSet='utf-8';
90 90
		}
91 91

  
92
		// set default sender name
93
		if (isset($_SESSION['DISPLAY_NAME'])) {
94
			$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
95
		} else {
96
			$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
97
		}
92
		// set default sender name
93
		if($this->FromName == 'Root User') {
94
			if(isset($_SESSION['DISPLAY_NAME'])) {
95
				$this->FromName = $_SESSION['DISPLAY_NAME'];            // FROM NAME: display name of user logged in
96
			} else {
97
				$this->FromName = $db_wbmailer_default_sendername;			// FROM NAME: set default name
98
			}
99
		}
98 100

  
99 101
		/* 
100 102
			some mail provider (lets say mail.com) reject mails send out by foreign mail 
trunk/wb/modules/form/install.php
53 53
		. ' `footer` TEXT NOT NULL ,'
54 54
		. ' `email_to` TEXT NOT NULL ,'
55 55
		. ' `email_from` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
56
		. ' `email_fromname` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
56 57
		. ' `email_subject` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
57 58
		. ' `success_page` TEXT NOT NULL ,'
58 59
		. ' `success_email_to` TEXT NOT NULL ,'
59 60
		. ' `success_email_from` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
61
		. ' `success_email_fromname` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
60 62
		. ' `success_email_text` TEXT NOT NULL ,'
61 63
		. ' `success_email_subject` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
62 64
		. ' `stored_submissions` INT NOT NULL DEFAULT \'0\' ,'
trunk/wb/modules/form/modify_settings.php
151 151
		</td>
152 152
	</tr>
153 153
	<tr>
154
		<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td>
155
		<td class="setting_name">
156
			<input type="text" name="email_fromname" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['email_fromname'])); ?>" />
157
		</td>
158
	</tr>
159
	<tr>
154 160
		<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td>
155 161
		<td class="setting_name">
156 162
			<input type="text" name="email_subject" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['email_subject'])); ?>" />
......
190 196
		</td>
191 197
	</tr>
192 198
	<tr>
199
		<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td>
200
		<td class="setting_name">
201
			<input type="text" name="success_email_fromname" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['success_email_fromname'])); ?>" />
202
		</td>
203
	</tr>
204
	<tr>
193 205
		<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td>
194 206
		<td class="setting_name">
195 207
			<input type="text" name="success_email_subject" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['success_email_subject'])); ?>" />
trunk/wb/modules/form/view.php
340 340
				// Set the email from field to what the user entered in the specified field
341 341
				$email_from = $wb->add_slashes($_POST[$email_from]);
342 342
			}
343
			$email_fromname = $fetch_settings['email_fromname'];
343 344
			$email_subject = $fetch_settings['email_subject'];
344 345
			$success_page = $fetch_settings['success_page'];
345 346
			$success_email_to = $fetch_settings['success_email_to'];
......
348 349
				$success_email_to = $wb->add_slashes($_POST[$success_email_to]);
349 350
			}
350 351
			$success_email_from = $fetch_settings['success_email_from'];
352
			$success_email_fromname = $fetch_settings['success_email_fromname'];
351 353
			$success_email_text = $fetch_settings['success_email_text'];
352 354
			$success_email_subject = $fetch_settings['success_email_subject'];		
353 355
			$max_submissions = $fetch_settings['max_submissions'];
......
445 447
					// Now send the email
446 448
					if($email_to != '') {
447 449
						if($email_from != '') {
448
							if($wb->mail($email_from,$email_to,$email_subject,$email_body)) {
450
							if($wb->mail($email_from,$email_to,$email_subject,$email_body,$email_fromname)) {
449 451
								$success = true;
450 452
							}
451 453
						} else {
452
							if($wb->mail('',$email_to,$email_subject,$email_body)) { 
454
							if($wb->mail('',$email_to,$email_subject,$email_body,$email_fromname)) { 
453 455
								$success = true; 
454 456
							}
455 457
						}
456 458
					}				
457 459
					if($success_email_to != '') {
458 460
						if($success_email_from != '') {
459
							if($wb->mail($success_email_from,$success_email_to,$success_email_subject,$success_email_text)) {
461
							if($wb->mail($success_email_from,$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
460 462
								$success = true;
461 463
							}
462 464
						} else {
463
							if($wb->mail('',$success_email_to,$success_email_subject,$success_email_text)) {
465
							if($wb->mail('',$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
464 466
								$success = true;
465 467
							}
466 468
						}
trunk/wb/modules/form/save_settings.php
47 47
} else {
48 48
	$email_from = $admin->add_slashes($_POST['email_from_field']);
49 49
}
50
$email_fromname = $admin->add_slashes($_POST['email_fromname']);
50 51
$email_subject = $admin->add_slashes($_POST['email_subject']);
51 52
$success_page = $_POST['success_page'];
52 53
$success_email_to = $admin->add_slashes($_POST['success_email_to']);
53 54
$success_email_from = $admin->add_slashes($_POST['success_email_from']);
55
$success_email_fromname = $admin->add_slashes($_POST['success_email_fromname']);
54 56
$success_email_text = $admin->add_slashes($_POST['success_email_text']);
55 57
$success_email_subject = $admin->add_slashes($_POST['success_email_subject']);
56 58
if(!is_numeric($_POST['max_submissions'])) {
......
69 71
}
70 72

  
71 73
// Update settings
72
$database->query("UPDATE ".TABLE_PREFIX."mod_form_settings SET header = '$header', field_loop = '$field_loop', footer = '$footer', email_to = '$email_to', email_from = '$email_from', email_subject = '$email_subject', success_page = '$success_page', success_email_to = '$success_email_to', success_email_from = '$success_email_from', success_email_text = '$success_email_text', success_email_subject = '$success_email_subject', max_submissions = '$max_submissions', stored_submissions = '$stored_submissions', use_captcha = '$use_captcha' WHERE section_id = '$section_id'");
74
$database->query("UPDATE ".TABLE_PREFIX."mod_form_settings SET header = '$header', field_loop = '$field_loop', footer = '$footer', email_to = '$email_to', email_from = '$email_from', email_fromname = '$email_fromname', email_subject = '$email_subject', success_page = '$success_page', success_email_to = '$success_email_to', success_email_from = '$success_email_from', success_email_fromname = '$success_email_fromname', success_email_text = '$success_email_text', success_email_subject = '$success_email_subject', max_submissions = '$max_submissions', stored_submissions = '$stored_submissions', use_captcha = '$use_captcha' WHERE section_id = '$section_id'");
73 75

  
74 76
// Check if there is a db error, otherwise say successful
75 77
if($database->is_error()) {
trunk/wb/modules/form/add.php
39 39
</table>';
40 40
$email_to = $admin->get_email();
41 41
$email_from = '';
42
$email_fromname = '';
42 43
$email_subject = 'Results from form on website...';
43 44
$success_page = 'none';
44 45
$success_email_to = '';
45 46
$success_email_from = $admin->get_email();
47
$success_email_fromname = '';
46 48
$success_email_text = 'Thank you for submitting your form on '.WEBSITE_TITLE;
47 49
$success_email_text = addslashes($success_email_text);
48 50
$success_email_subject = 'You have submitted a form';
49 51
$max_submissions = 50;
50 52
$stored_submissions = 50;
51 53
$use_captcha = true;
52
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_settings (page_id,section_id,header,field_loop,footer,email_to,email_from,email_subject,success_page,success_email_to,success_email_from,success_email_text,success_email_subject,max_submissions,stored_submissions,use_captcha) VALUES ('$page_id','$section_id','$header','$field_loop','$footer','$email_to','$email_from','$email_subject','$success_page','$success_email_to','$success_email_from','$success_email_text','$success_email_subject','$max_submissions','$stored_submissions','$use_captcha')");
54
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_settings (page_id,section_id,header,field_loop,footer,email_to,email_from,email_fromname,email_subject,success_page,success_email_to,success_email_from,success_email_fromname,success_email_text,success_email_subject,max_submissions,stored_submissions,use_captcha) VALUES ('$page_id','$section_id','$header','$field_loop','$footer','$email_to','$email_from','$email_fromname','$email_subject','$success_page','$success_email_to','$success_email_from','$success_email_fromname','$success_email_text','$success_email_subject','$max_submissions','$stored_submissions','$use_captcha')");
53 55

  
54 56
?>

Also available in: Unified diff