Hello,
I'm currently working on an update for UserImport (MODX Revolution Add-On) to support email notification of imported users. For this purpose I created a custom ExtJS form which holds the mail subject and the mailbody. The mailbody is a textarea field. Saving the form writes both fields to corresponding system settings.
If I enter plain text I can save the form.
If It contains HTML tags the values are saved but ExtJS seems to hang while reading the processor response.
The following error (from Chrome console):
Uncaught SyntaxError: Invalid regular expression: missing /
at doDecode (ext-all.js:21)
at Object.decode (ext-all.js:21)
at Ext.form.Action.Submit.handleResponse (utilities.js:300)
at Ext.form.Action.Submit.processResponse (ext-all.js:21)
at Ext.form.Action.Submit.success (ext-all.js:21)
at o (ext-all.js:21)
at Ext.data.Connection.s (ext-all.js:21)
at HTMLIFrameElement.I (ext-all.js:21)
doDecode @ ext-all.js:21
(anonymous) @ ext-all.js:21
handleResponse @ utilities.js:300
processResponse @ ext-all.js:21
success @ ext-all.js:21
o @ ext-all.js:21
s @ ext-all.js:21
I @ ext-all.js:21
This is the processor response:
({"success":true,"data":{"hasheader":"1","batchsize":"0","delimiter":";","enclosure":"\"","usergroups":"","autousername":"0","setimportmarker":"1","notifyusers":"1","role":"0","mailsubject":"Notification: Your New User Account!","mailbody":"Hello,<br>\r\n<br>\r\nwe'd like to inform you, that your user credentials were imported into our system and a new user account was created for you!<br> \r\n<br>\r\n<strong>Here are your new account credentials:<\/strong><br>\r\n<br>\r\nName: [[+fullname]]<br>\r\nEmail: [[+email]]<br>\r\nYour username: [[+username]]<br>\r\nYour password: [[+password]]<br>","action":"mgr\/settings\/update","file":{"name":"","type":"","tmp_name":"","error":4,"size":0}}}</strong>)
Please note the </strong> tag on the end of the string! I don't know where this is coming from!
Here is the update.class.php processor:
class SettingsUpdateProcessor extends modProcessor {
public function process() {
$settings = array(
'delimiter',
'enclosure',
'autousername',
'setimportmarker',
'notifyusers',
'mailsubject',
'mailbody',
);
foreach ($settings as $key) {
$value = $this->getProperty($key);
if (isset($value)) {
$setting = $this->modx->getObject('modSystemSetting', 'userimport.'.$key);
if ($setting != null) {
$setting->set('value', $value);
$setting->save();
} else {
$this->modx->log(modX::LOG_LEVEL_ERROR, '[UserImport] SettingsUpdateProcessor: '.$key.' setting could not be found');
}
}
}
// refresh part of cache (MODx 2.1.x)
$cacheRefreshOptions = array('system_settings' => array());
$this->modx->cacheManager->refresh($cacheRefreshOptions);
$response['success'] = true;
$response['data'] = $this->getProperties();
return $this->modx->toJSON($response);
}
}
return 'SettingsUpdateProcessor';
and here the ExtJS part with the textarea:
{
xtype: 'textarea'
,name: 'mailbody'
,id: 'mailbody'
,growMin: 250
,grow: true
,fieldLabel: _('userimport.notification_template_mail_body')
,description: MODx.expandHelp ? '' : _('userimport.notification_template_mail_body_desc')
,anchor: '100%'
}
What am I doing wrong? Any idea?
[ed. note: gadgetto last edited this post 7 years, 2 months ago.]