Skip to content

Commit 948f9f4

Browse files
committed
Allow styled New User Welcome message instead of plain text
1 parent 770bc40 commit 948f9f4

9 files changed

Lines changed: 87 additions & 11 deletions

File tree

framework/conf/config.php.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ define("USER_REGISTRATION_NOTIF_SUBJECT",'New User Registration From Website');
5858
define("USER_REGISTRATION_ADMIN_EMAIL",'');
5959
define("USER_REGISTRATION_SEND_WELCOME",'0');
6060
define("USER_REGISTRATION_WELCOME_SUBJECT",'Welcome to our website!');
61-
define("USER_REGISTRATION_WELCOME_MSG",'');
61+
define("USER_REGISTRATION_WELCOME_MSG_HTML",exponent_unhtmlentities(''));
6262
define("USE_LDAP",'0');
6363
define("LDAP_SERVER",'not_configured');
6464
define("LDAP_BASE_CONTEXT",'not_configured');

framework/conf/extensions/registration.defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
if (!defined('USER_REGISTRATION_ADMIN_EMAIL')) define('USER_REGISTRATION_ADMIN_EMAIL','');
2525
if (!defined('USER_REGISTRATION_SEND_WELCOME')) define('USER_REGISTRATION_SEND_WELCOME','0');
2626
if (!defined('USER_REGISTRATION_WELCOME_SUBJECT')) define('USER_REGISTRATION_WELCOME_SUBJECT','Welcome to our website!');
27-
if (!defined('USER_REGISTRATION_WELCOME_MSG')) define('USER_REGISTRATION_WELCOME_MSG','');
27+
if (!defined('USER_REGISTRATION_WELCOME_MSG_HTML')) define('USER_REGISTRATION_WELCOME_MSG_HTML','');
2828

2929
if (!defined('USE_LDAP')) define('USE_LDAP','0');
3030
if (!defined('LDAP_SERVER')) define('LDAP_SERVER','not_configured');

framework/modules/administration/views/administration/configure_site.bootstrap3.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{group label="New User Welcome Message"|gettext}
109109
{control type="checkbox" postfalse=1 name="sc[USER_REGISTRATION_SEND_WELCOME]" label="Send an email to the user after registering?"|gettext checked=$smarty.const.USER_REGISTRATION_SEND_WELCOME value=1}
110110
{control type="text" name="sc[USER_REGISTRATION_WELCOME_SUBJECT]" label="Welcome Email Subject"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_SUBJECT}
111-
{control type="textarea" name="sc[USER_REGISTRATION_WELCOME_MSG]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG}
111+
{control type="html" name="sc[USER_REGISTRATION_WELCOME_MSG_HTML]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG_HTML description='You may use variables %1$s for first name, %2$s for last name, or %3$s for username.'|gettext}
112112
{/group}
113113
{if function_exists('ldap_connect')}
114114
{group label="LDAP Authentication"|gettext}

framework/modules/administration/views/administration/configure_site.bootstrap4.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{group label="New User Welcome Message"|gettext}
109109
{control type="checkbox" postfalse=1 name="sc[USER_REGISTRATION_SEND_WELCOME]" label="Send an email to the user after registering?"|gettext checked=$smarty.const.USER_REGISTRATION_SEND_WELCOME value=1}
110110
{control type="text" name="sc[USER_REGISTRATION_WELCOME_SUBJECT]" label="Welcome Email Subject"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_SUBJECT}
111-
{control type="textarea" name="sc[USER_REGISTRATION_WELCOME_MSG]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG}
111+
{control type="html" name="sc[USER_REGISTRATION_WELCOME_MSG_HTML]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG_HTML description='You may use variables %1$s for first name, %2$s for last name, or %3$s for username.'|gettext}
112112
{/group}
113113
{if function_exists('ldap_connect')}
114114
{group label="LDAP Authentication"|gettext}

framework/modules/administration/views/administration/configure_site.bootstrap5.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{group label="New User Welcome Message"|gettext}
109109
{control type="checkbox" postfalse=1 name="sc[USER_REGISTRATION_SEND_WELCOME]" label="Send an email to the user after registering?"|gettext checked=$smarty.const.USER_REGISTRATION_SEND_WELCOME value=1}
110110
{control type="text" name="sc[USER_REGISTRATION_WELCOME_SUBJECT]" label="Welcome Email Subject"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_SUBJECT}
111-
{control type="textarea" name="sc[USER_REGISTRATION_WELCOME_MSG]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG}
111+
{control type="html" name="sc[USER_REGISTRATION_WELCOME_MSG_HTML]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG_HTML description='You may use variables %1$s for first name, %2$s for last name, or %3$s for username.'|gettext}
112112
{/group}
113113
{if function_exists('ldap_connect')}
114114
{group label="LDAP Authentication"|gettext}

framework/modules/administration/views/administration/configure_site.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{group label="New User Welcome Message"|gettext}
109109
{control type="checkbox" postfalse=1 name="sc[USER_REGISTRATION_SEND_WELCOME]" label="Send an email to the user after registering?"|gettext checked=$smarty.const.USER_REGISTRATION_SEND_WELCOME value=1}
110110
{control type="text" name="sc[USER_REGISTRATION_WELCOME_SUBJECT]" label="Welcome Email Subject"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_SUBJECT}
111-
{control type="textarea" name="sc[USER_REGISTRATION_WELCOME_MSG]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG}
111+
{control type="html" name="sc[USER_REGISTRATION_WELCOME_MSG_HTML]" label="Welcome Email Content"|gettext value=$smarty.const.USER_REGISTRATION_WELCOME_MSG_HTML description='You may use variables %1$s for first name, %2$s for last name, or %3$s for username.'|gettext}
112112
{/group}
113113
{if function_exists('ldap_connect')}
114114
{group label="LDAP Authentication"|gettext}

framework/modules/users/controllers/usersController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,12 @@ public function update() {
338338
//signup email stuff
339339
if (USER_REGISTRATION_SEND_WELCOME && !empty($u->email)) {
340340
$msg = $u->firstname . ", \n\n";
341-
$msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $u->firstname, $u->lastname, $u->username);
341+
$msg .= sprintf(USER_REGISTRATION_WELCOME_MSG_HTML, $u->firstname, $u->lastname, $u->username);
342342

343343
$mail = new expMail();
344344
$mail->quickSend(array(
345-
'text_message' => $msg,
345+
'html_message'=>$msg,
346+
'text_message'=>expString::html2text($msg),
346347
'to' => array(trim($u->email) => trim(user::getUserAttribution($u->id))),
347348
'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),
348349
'subject' => USER_REGISTRATION_WELCOME_SUBJECT,
@@ -1881,11 +1882,12 @@ public function import_users_add() {
18811882
$usersdone[] = $userinfo['username'];
18821883
if (USER_REGISTRATION_SEND_WELCOME && $this->params['sendemail'] && !empty($newuser->email)) {
18831884
$msg = $newuser->firstname . ", \n\n";
1884-
$msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $newuser->firstname, $newuser->lastname, $newuser->username);
1885+
$msg .= sprintf(USER_REGISTRATION_WELCOME_MSG_HTML, $newuser->firstname, $newuser->lastname, $newuser->username);
18851886
$msg .= "/n/nYour new password is: ".$userinfo['clearpassword'];
18861887
$mail = new expMail();
18871888
$mail->quickSend(array(
1888-
'text_message' => $msg,
1889+
'html_message'=>$msg,
1890+
'text_message'=>expString::html2text($msg),
18891891
'to' => array(trim($newuser->email) => trim(user::getUserAttribution($newuser->id))),
18901892
'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)),
18911893
'subject' => USER_REGISTRATION_WELCOME_SUBJECT,

install/upgrades/fix_siteurl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static function name() { return "Set Site URL"; }
3737
* generic description of upgrade script
3838
* @return string
3939
*/
40-
function description() { return "To prevent a Host Header Injection, we need to know our site url. This script site url."; }
40+
function description() { return "To prevent a Host Header Injection, we need to know our site url. This script adds the site url."; }
4141

4242
/**
4343
* additional test(s) to see if upgrade script should be run
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
##################################################
4+
#
5+
# Copyright (c) 2004-2025 OIC Group, Inc.
6+
#
7+
# This file is part of Exponent
8+
#
9+
# Exponent is free software; you can redistribute
10+
# it and/or modify it under the terms of the GNU
11+
# General Public License as published by the Free
12+
# Software Foundation; either version 2 of the
13+
# License, or (at your option) any later version.
14+
#
15+
# GPL: http://www.gnu.org/licenses/gpl.txt
16+
#
17+
##################################################
18+
19+
/**
20+
* This is the class upgrade_newusermsg
21+
*
22+
* @package Installation
23+
* @subpackage Upgrade
24+
*/
25+
class upgrade_newusermsg extends upgradescript
26+
{
27+
protected $from_version = '0.0.0'; // version number lower than first released version, 2.0.0
28+
protected $to_version = '2.7.2';
29+
public $priority = 78; // set this to a low priority
30+
31+
/**
32+
* name/title of upgrade script
33+
* @return string
34+
*/
35+
static function name()
36+
{
37+
return "Upgrade New User Message";
38+
}
39+
40+
/**
41+
* generic description of upgrade script
42+
* @return string
43+
*/
44+
function description()
45+
{
46+
return "The New User Welcome Message may now be styled. Previously it was plain text.";
47+
}
48+
49+
/**
50+
* additional test(s) to see if upgrade script should be run
51+
* @return bool
52+
*/
53+
function needed()
54+
{
55+
$tmp = (empty(USER_REGISTRATION_WELCOME_MSG_HTML) && !empty(USER_REGISTRATION_WELCOME_MSG));
56+
$tmp1 = !defined('USER_REGISTRATION_WELCOME_MSG_HTML');
57+
return (!defined('USER_REGISTRATION_WELCOME_MSG_HTML') || (empty(USER_REGISTRATION_WELCOME_MSG_HTML) && !empty(USER_REGISTRATION_WELCOME_MSG)));
58+
}
59+
60+
/**
61+
* reads in and corrects the modstate table, esp. since it has no index and allows duplicate entries
62+
* we will assume that all old school modules have been upgraded at this point
63+
*
64+
* @return string
65+
*/
66+
function upgrade()
67+
{
68+
expSettings::change('USER_REGISTRATION_WELCOME_MSG_HTML', USER_REGISTRATION_WELCOME_MSG);
69+
70+
return gt('New User Welcome Message was Upgraded.');
71+
}
72+
}
73+
74+
?>

0 commit comments

Comments
 (0)