Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add signature template to new_user_dialog plugin #8983

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions plugins/new_user_dialog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# RoundCube New User Dialog Plugin
When a new user is created, this plugin checks the default identity and sets a session flag in case it is incomplete. An overlay box will appear on the screen until the user has reviewed/completed his identity.

## Configuration
Optional you can specify the default signature, `@EMAIL@` is replaced by the user email.

```
$config['new_user_dialog_signature_text'] = '
Your Name
E-Mail : @EMAIL@
Website: some.domain
Phone: 01234/567890
';
```
4 changes: 4 additions & 0 deletions plugins/new_user_dialog/new_user_dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class new_user_dialog extends rcube_plugin

function init()
{
$rcmail = rcmail::get_instance();
$this->load_config();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FOr better performance loading config file should be done only when it's needed, i.e. not in init().

$this->add_hook('identity_create', [$this, 'create_identity']);
$this->add_hook('render_page', [$this, 'render_page']);
$this->register_action('plugin.newusersave', [$this, 'save_data']);
$this->signature_text = $rcmail->config->get('new_user_dialog_signature_text');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-existing property warning. This can be a normal variable if you move it to render_page().

}

/**
Expand Down Expand Up @@ -89,6 +92,7 @@ function render_page($p)
'name' => '_signature',
'rows' => '5',
],
$out = str_replace('@EMAIL@', rcube_utils::idn_to_utf8($identity['email']) , $this->signature_text ?? ''),
$identity['signature']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. If signature already exists (which could be set by another plugin) it should be used. $out variable is not needed here.

Also, it was missing before, but I think the content need to be encoded with rcube::Q().

));

Expand Down