In current 1.0-git (master) and in 0.9.5 I see that $isHTML is set to false if we pre-define body content by hooks 'message_compose' and/or 'message_compose_body' regardless whether or not user preference is 'HTML':
./program/steps/mail/compose.inc ::: lines 643 ff.
else if ($COMPOSE['param']['body']) { $body = $COMPOSE['param']['body']; $isHtml = false; }
Is there a special reason for this behavior? I guess it is a bug. At least it prevents me to pre-define HTML compose bodies. If there is a special reason for this fallback to text bodies then please note that the HTML Editor select box is set accordingly; it is set accordingly to user's preference.
I have already contacted Alec and he replied:
"$COMPOSE['param']s in general are for text only, because they are URL parameters. If you want to inject any body use message_compose_body hook. Feel free to propose fix/better solution via pull request."
I think Alec is not right.
$COMPOSE['param'] is also set by the hook 'message_compose'. See ./program/steps/mail/compose.inc ::: lines 450 ff.
// pipe compose parameters thru plugins $plugin = $RCMAIL->plugins->exec_hook('message_compose', $COMPOSE); $COMPOSE['param'] = array_merge($COMPOSE['param'], $plugin['param']);
So, the simple solution to allow plugin developers to pre-define HTML bodies is:
./program/steps/mail/compose.inc ::: lines 643 ff.
else if ($COMPOSE['param']['body']) { $body = $COMPOSE['param']['body']; $isHtml = $COMPOSE['param']['html'] ? true : false; }
Rosali wrote:
In current 1.0-git (master) and in 0.9.5 I see that $isHTML is set to false if we pre-define body content by hooks 'message_compose' and/or 'message_compose_body' regardless whether or not user preference is 'HTML':
./program/steps/mail/compose.inc ::: lines 643 ff.
else if ($COMPOSE['param']['body']) { $body = $COMPOSE['param']['body']; $isHtml = false; }
Is there a special reason for this behavior? I guess it is a bug.
I don't think there's a special reason for that. The compose parameters are extracted from urls like mailto:foo@bar.com?subject=Test&body=Hit+me
Thus assuming plain text makes sense. Then later we added the plugin hooks and didn't think any further... That's all.
I have already contacted Alec and he replied:
"$COMPOSE['param']s in general are for text only, because they are URL parameters. If you want to inject any body use message_compose_body hook.
That's right, the message_compose_body will let you overwrite the compose mode.
So, the simple solution to allow plugin developers to pre-define HTML bodies is:
./program/steps/mail/compose.inc ::: lines 643 ff.
else if ($COMPOSE['param']['body']) { $body = $COMPOSE['param']['body']; $isHtml = $COMPOSE['param']['html'] ? true : false; }
Yup, I think it doesn't break anything if we add that here, too. Done in https://github.com/roundcube/roundcubemail/commit/e957bfe
Regards, Thomas