update
This commit is contained in:
parent
585bb285bf
commit
1b33990d86
|
|
@ -1,15 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "local/email_config",
|
"name": "local/email_config",
|
||||||
"type": "roundcube-plugin",
|
"type": "roundcube-plugin",
|
||||||
"description": "Email Configuration Plugin - Opens external email config interface",
|
"description": "Email Configuration - Manage OOO and Forwarding",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Custom Plugin",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.0.0",
|
||||||
"roundcube/plugin-installer": ">=0.1.3"
|
"roundcube/plugin-installer": ">=0.1.3"
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* Email Configuration Plugin - Client Side
|
|
||||||
*/
|
|
||||||
if (window.rcmail) {
|
|
||||||
rcmail.addEventListener('init', function(evt) {
|
|
||||||
rcmail.register_command('email_config_open', function() {
|
|
||||||
rcmail.http_post('plugin.email_config_generate_url', {},
|
|
||||||
rcmail.set_busy(true, 'loading'));
|
|
||||||
}, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
rcmail.addEventListener('responseafterplugin.email_config_generate_url', function(response) {
|
|
||||||
rcmail.set_busy(false);
|
|
||||||
if (response && response.url) {
|
|
||||||
window.open(response.url, '_blank');
|
|
||||||
} else {
|
|
||||||
rcmail.display_message('Failed to generate configuration URL', 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Email Configuration Plugin
|
|
||||||
* Opens external email config interface with signed authentication
|
|
||||||
*/
|
|
||||||
class email_config extends rcube_plugin
|
class email_config extends rcube_plugin
|
||||||
{
|
{
|
||||||
public $task = 'settings|mail';
|
public $task = 'settings';
|
||||||
private $secret_key = 'SHARED_SECRET_KEY_987654321';
|
|
||||||
private $config_url = 'http://localhost:3009';
|
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
// Register actions
|
$this->add_texts('localization/', false);
|
||||||
$this->register_action('plugin.email_config', array($this, 'email_config_init'));
|
|
||||||
$this->register_action('plugin.email_config_generate_url', array($this, 'generate_signed_url'));
|
|
||||||
|
|
||||||
// Add button to toolbar in mail view
|
|
||||||
if ($this->rcmail->task == 'mail') {
|
|
||||||
$this->add_button(array(
|
|
||||||
'command' => 'email_config_open',
|
|
||||||
'label' => 'Email Config',
|
|
||||||
'title' => 'Configure auto-reply and forwarding',
|
|
||||||
'type' => 'link',
|
|
||||||
'class' => 'button email-config',
|
|
||||||
), 'toolbar');
|
|
||||||
|
|
||||||
$this->include_script('email_config.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to settings menu
|
|
||||||
if ($this->rcmail->task == 'settings') {
|
|
||||||
$this->add_hook('settings_actions', array($this, 'settings_actions'));
|
$this->add_hook('settings_actions', array($this, 'settings_actions'));
|
||||||
}
|
$this->register_action('plugin.email_config', array($this, 'email_config_init'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function settings_actions($args)
|
function settings_actions($args)
|
||||||
|
|
@ -39,56 +15,61 @@ class email_config extends rcube_plugin
|
||||||
$args['actions'][] = array(
|
$args['actions'][] = array(
|
||||||
'action' => 'plugin.email_config',
|
'action' => 'plugin.email_config',
|
||||||
'class' => 'email-config',
|
'class' => 'email-config',
|
||||||
'label' => 'Email Configuration',
|
'label' => 'email_config',
|
||||||
'title' => 'Configure email rules',
|
'domain' => 'email_config',
|
||||||
);
|
);
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
function email_config_init()
|
function email_config_init()
|
||||||
{
|
{
|
||||||
|
$rcmail = rcube::get_instance();
|
||||||
$this->register_handler('plugin.body', array($this, 'email_config_form'));
|
$this->register_handler('plugin.body', array($this, 'email_config_form'));
|
||||||
$this->rcmail->output->set_pagetitle('Email Configuration');
|
$rcmail->output->set_pagetitle('Email Configuration');
|
||||||
$this->rcmail->output->send('plugin');
|
$rcmail->output->send('plugin');
|
||||||
}
|
}
|
||||||
|
|
||||||
function email_config_form()
|
function email_config_form()
|
||||||
{
|
{
|
||||||
$email = $this->rcmail->user->get_username();
|
$rcmail = rcube::get_instance();
|
||||||
$url = $this->generate_url($email);
|
$email = $rcmail->user->get_username();
|
||||||
|
$secret_key = 'SHARED_SECRET_KEY_987654321';
|
||||||
|
$config_url = 'http://localhost:3008';
|
||||||
|
$expires = time() + 3600;
|
||||||
|
$data = $email . '|' . $expires;
|
||||||
|
$signature = hash_hmac('sha256', $data, $secret_key);
|
||||||
|
$url = $config_url . '/?email=' . urlencode($email) . '&expires=' . $expires . '&signature=' . $signature;
|
||||||
|
|
||||||
$out = html::div(array('class' => 'box'),
|
$out = '
|
||||||
html::p(null, 'Manage your email configuration including out-of-office auto-replies and forwarding rules.') .
|
<div class="box" style="max-width: 600px; margin: 40px auto; padding: 30px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
|
||||||
html::p(null,
|
<div style="text-align: center; margin-bottom: 30px;">
|
||||||
html::a(array(
|
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" style="margin: 0 auto 20px;">
|
||||||
'href' => $url,
|
<path d="M20 4H4C2.9 4 2.01 4.9 2.01 6L2 18C2 19.1 2.9 20 4 20H20C21.1 20 22 19.1 22 18V6C22 4.9 21.1 4 20 4ZM20 8L12 13L4 8V6L12 11L20 6V8Z" fill="#4A90E2"/>
|
||||||
'target' => '_blank',
|
</svg>
|
||||||
'class' => 'button mainaction',
|
<h2 style="margin: 0; color: #333; font-size: 24px; font-weight: 600;">Email Rules Configuration</h2>
|
||||||
), 'Open Email Configuration')
|
</div>
|
||||||
)
|
|
||||||
);
|
<div style="background: #f8f9fa; padding: 20px; border-radius: 6px; margin-bottom: 25px;">
|
||||||
|
<p style="margin: 0 0 8px 0; color: #666; font-size: 14px;">Signed in as:</p>
|
||||||
|
<p style="margin: 0; color: #333; font-size: 16px; font-weight: 500;">' . htmlspecialchars($email) . '</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="color: #666; line-height: 1.6; margin-bottom: 25px; text-align: center;">
|
||||||
|
Configure out-of-office auto-replies and email forwarding rules for your account.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<a href="' . htmlspecialchars($url) . '" target="_blank"
|
||||||
|
style="display: inline-block; background: #4A90E2; color: white; padding: 12px 32px;
|
||||||
|
border-radius: 6px; text-decoration: none; font-weight: 500; font-size: 16px;
|
||||||
|
transition: background 0.2s; box-shadow: 0 2px 4px rgba(74,144,226,0.3);"
|
||||||
|
onmouseover="this.style.background=\'#357ABD\'"
|
||||||
|
onmouseout="this.style.background=\'#4A90E2\'">
|
||||||
|
Open Email Configuration →
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_signed_url()
|
|
||||||
{
|
|
||||||
$email = $this->rcmail->user->get_username();
|
|
||||||
$url = $this->generate_url($email);
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo json_encode(array('success' => true, 'url' => $url));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function generate_url($email)
|
|
||||||
{
|
|
||||||
$expires = time() + 3600; // 1 hour validity
|
|
||||||
$data = $email . '|' . $expires;
|
|
||||||
$signature = hash_hmac('sha256', $data, $this->secret_key);
|
|
||||||
|
|
||||||
return $this->config_url . '/?email=' . urlencode($email)
|
|
||||||
. '&expires=' . $expires
|
|
||||||
. '&signature=' . $signature;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
$labels['email_config'] = 'Email Configuration';
|
||||||
|
$messages = array();
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
$labels['email_config'] = 'Email Configuration';
|
||||||
|
$messages = array();
|
||||||
Loading…
Reference in New Issue