ooo/forward plugin
This commit is contained in:
parent
929adcdbc9
commit
585bb285bf
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "local/email_config",
|
||||||
|
"type": "roundcube-plugin",
|
||||||
|
"description": "Email Configuration Plugin - Opens external email config interface",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Custom Plugin",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.0.0",
|
||||||
|
"roundcube/plugin-installer": ">=0.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* 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');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Email Configuration Plugin
|
||||||
|
* Opens external email config interface with signed authentication
|
||||||
|
*/
|
||||||
|
class email_config extends rcube_plugin
|
||||||
|
{
|
||||||
|
public $task = 'settings|mail';
|
||||||
|
private $secret_key = 'SHARED_SECRET_KEY_987654321';
|
||||||
|
private $config_url = 'http://localhost:3009';
|
||||||
|
|
||||||
|
function init()
|
||||||
|
{
|
||||||
|
// Register actions
|
||||||
|
$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'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function settings_actions($args)
|
||||||
|
{
|
||||||
|
$args['actions'][] = array(
|
||||||
|
'action' => 'plugin.email_config',
|
||||||
|
'class' => 'email-config',
|
||||||
|
'label' => 'Email Configuration',
|
||||||
|
'title' => 'Configure email rules',
|
||||||
|
);
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
function email_config_init()
|
||||||
|
{
|
||||||
|
$this->register_handler('plugin.body', array($this, 'email_config_form'));
|
||||||
|
$this->rcmail->output->set_pagetitle('Email Configuration');
|
||||||
|
$this->rcmail->output->send('plugin');
|
||||||
|
}
|
||||||
|
|
||||||
|
function email_config_form()
|
||||||
|
{
|
||||||
|
$email = $this->rcmail->user->get_username();
|
||||||
|
$url = $this->generate_url($email);
|
||||||
|
|
||||||
|
$out = html::div(array('class' => 'box'),
|
||||||
|
html::p(null, 'Manage your email configuration including out-of-office auto-replies and forwarding rules.') .
|
||||||
|
html::p(null,
|
||||||
|
html::a(array(
|
||||||
|
'href' => $url,
|
||||||
|
'target' => '_blank',
|
||||||
|
'class' => 'button mainaction',
|
||||||
|
), 'Open Email Configuration')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue