mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-02-20 01:21:20 +01:00
PHP8 fixes, CS fixes, short array syntax, tests
This commit is contained in:
@@ -597,7 +597,7 @@ class acl extends rcube_plugin
|
||||
|
||||
$out = $this->list_rights();
|
||||
|
||||
$out = preg_replace(array('/^<table[^>]+>/', '/<\/table>$/'), '', $out);
|
||||
$out = preg_replace(['/^<table[^>]+>/', '/<\/table>$/'], '', $out);
|
||||
|
||||
$this->rc->output->command('acl_list_update', $out);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* to or remove them from outgoing messages.
|
||||
*
|
||||
* Enable the plugin in config.inc.php and add your desired headers:
|
||||
* $config['additional_message_headers'] = array('User-Agent' => 'My-Very-Own-Webmail');
|
||||
* $config['additional_message_headers'] = ['User-Agent' => 'My-Very-Own-Webmail'];
|
||||
*
|
||||
* @author Ziba Scott
|
||||
* @website http://roundcube.net
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-attachment_reminder/
|
||||
*/
|
||||
|
||||
$messages = array();
|
||||
$messages['missingattachment'] = "Missing attachment?";
|
||||
$messages['forgotattachment'] = "Did you forget to attach a file?";
|
||||
$messages['reminderoption'] = "Remind about forgotten attachments";
|
||||
|
||||
@@ -78,7 +78,7 @@ class enigma extends rcube_plugin
|
||||
|
||||
// register handler for keys/certs management
|
||||
$this->register_action('plugin.enigmakeys', [$this, 'preferences_ui']);
|
||||
// $this->register_action('plugin.enigmacerts', array($this, 'preferences_ui'));
|
||||
// $this->register_action('plugin.enigmacerts', [$this, 'preferences_ui']);
|
||||
|
||||
$this->load_ui();
|
||||
|
||||
@@ -371,7 +371,7 @@ class enigma extends rcube_plugin
|
||||
$field_id = 'rcmfd_enigma_password_time';
|
||||
$select = new html_select(['name' => '_enigma_password_time', 'id' => $field_id, 'class' => 'custom-select']);
|
||||
|
||||
foreach (array(1, 5, 10, 15, 30) as $m) {
|
||||
foreach ([1, 5, 10, 15, 30] as $m) {
|
||||
$label = $this->gettext(['name' => 'nminutes', 'vars' => ['m' => $m]]);
|
||||
$select->add($label, $m);
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ class enigma_driver_gnupg extends enigma_driver
|
||||
}
|
||||
|
||||
$unique = ['user_id' => $this->rc->user->ID, 'context' => 'enigma', 'filename' => $filename];
|
||||
$result = $db->insert_or_update($table, $unique, array('mtime', 'data'), array($mtime, $data));
|
||||
$result = $db->insert_or_update($table, $unique, ['mtime', 'data'], [$mtime, $data]);
|
||||
|
||||
if ($db->is_error($result)) {
|
||||
rcube::raise_error([
|
||||
|
||||
@@ -1200,7 +1200,7 @@ class enigma_ui
|
||||
|
||||
if ($mode && ($status instanceof enigma_error)) {
|
||||
$code = $status->getCode();
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
|
||||
if ($code == enigma_error::KEYNOTFOUND) {
|
||||
if ($email = $status->getData('missing')) {
|
||||
|
||||
@@ -12,9 +12,9 @@ $config['krb_authentication_host'] = '';
|
||||
// GSSAPI security context.
|
||||
// Single value or an array with per-protocol values. Example:
|
||||
//
|
||||
// $config['krb_authentication_context'] = array(
|
||||
// $config['krb_authentication_context'] = [
|
||||
// 'imap' => 'imap/host.fqdn@REALM.NAME',
|
||||
// 'smtp' => 'smtp/host.fqdn@REALM.NAME',
|
||||
// 'sieve' => 'sieve/host.fqdn@REALM.NAME',
|
||||
// );
|
||||
// ];
|
||||
$config['krb_authentication_context'] = 'principal@REALM.NAME';
|
||||
|
||||
@@ -76,7 +76,7 @@ class markasjunk_cmd_learn
|
||||
preg_match_all('/%h:([\w_-]+)/', $tmp_command, $header_names, PREG_SET_ORDER);
|
||||
foreach ($header_names as $header) {
|
||||
$val = null;
|
||||
if ($msg = $storage->conn->fetchHeader($src_mbox, $uid, true, false, array($header[1]))) {
|
||||
if ($msg = $storage->conn->fetchHeader($src_mbox, $uid, true, false, [$header[1]])) {
|
||||
$val = !empty($msg->{$header[1]}) ? $msg->{$header[1]} : $msg->others[$header[1]];
|
||||
}
|
||||
|
||||
|
||||
@@ -105,10 +105,10 @@ class rcube_cpanel_webmail_password
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* curl_auth_post('john:Secr3t', 'https://example.org', array(
|
||||
* curl_auth_post('john:Secr3t', 'https://example.org', [
|
||||
* 'param' => 'value',
|
||||
* 'param' => 'value'
|
||||
* ));
|
||||
* ]);
|
||||
* </code>
|
||||
*
|
||||
* @param string $userpwd user name and password separated by a colon
|
||||
|
||||
@@ -176,7 +176,7 @@ class rcube_pwned_password
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
if (self::ENHANCED_PRIVACY_CURL == 1) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Add-Padding: true'));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Add-Padding: true']);
|
||||
}
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
@@ -91,7 +91,8 @@ class redundant_attachments extends filesystem_attachments
|
||||
*/
|
||||
private function _key($args)
|
||||
{
|
||||
$uname = $args['path'] ?: $args['name'];
|
||||
$uname = !empty($args['path']) ? $args['path'] : $args['name'];
|
||||
|
||||
return $args['group'] . md5(microtime() . $uname . $_SESSION['user_id']);
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ class redundant_attachments extends filesystem_attachments
|
||||
|
||||
$this->_load_drivers();
|
||||
|
||||
$data = $args['path'] ? file_get_contents($args['path']) : $args['data'];
|
||||
$data = !empty($args['path']) ? file_get_contents($args['path']) : $args['data'];
|
||||
|
||||
$args['data'] = null;
|
||||
|
||||
@@ -193,8 +194,9 @@ class redundant_attachments extends filesystem_attachments
|
||||
// attempt to get file from local file system
|
||||
$args = parent::get($args);
|
||||
|
||||
if ($args['path'] && ($args['status'] = file_exists($args['path'])))
|
||||
return $args;
|
||||
if (!empty($args['path']) && ($args['status'] = file_exists($args['path']))) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
$this->_load_drivers();
|
||||
|
||||
|
||||
@@ -7,44 +7,50 @@
|
||||
* and display them in the message view.
|
||||
*
|
||||
* Enable the plugin in config.inc.php and add your desired headers:
|
||||
* $config['show_additional_headers'] = array('User-Agent');
|
||||
* $config['show_additional_headers'] = ['User-Agent'];
|
||||
*
|
||||
* @author Thomas Bruederli
|
||||
* @license GNU GPLv3+
|
||||
*/
|
||||
class show_additional_headers extends rcube_plugin
|
||||
{
|
||||
public $task = 'mail';
|
||||
public $task = 'mail';
|
||||
|
||||
function init()
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
|
||||
$this->add_hook('storage_init', array($this, 'storage_init'));
|
||||
$this->add_hook('message_headers_output', array($this, 'message_headers'));
|
||||
} else if ($rcmail->action == '') {
|
||||
// with enabled_caching we're fetching additional headers before show/preview
|
||||
$this->add_hook('storage_init', array($this, 'storage_init'));
|
||||
}
|
||||
}
|
||||
function init()
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
|
||||
function storage_init($p)
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
if ($add_headers = (array)$rcmail->config->get('show_additional_headers', array()))
|
||||
$p['fetch_headers'] = trim($p['fetch_headers'].' ' . strtoupper(join(' ', $add_headers)));
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
function message_headers($p)
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
foreach ((array)$rcmail->config->get('show_additional_headers', array()) as $header) {
|
||||
if ($value = $p['headers']->get($header))
|
||||
$p['output'][$header] = array('title' => $header, 'value' => $value);
|
||||
if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
|
||||
$this->add_hook('storage_init', [$this, 'storage_init']);
|
||||
$this->add_hook('message_headers_output', [$this, 'message_headers']);
|
||||
}
|
||||
else if ($rcmail->action == '') {
|
||||
// with enabled_caching we're fetching additional headers before show/preview
|
||||
$this->add_hook('storage_init', [$this, 'storage_init']);
|
||||
}
|
||||
}
|
||||
|
||||
return $p;
|
||||
}
|
||||
function storage_init($p)
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
|
||||
if ($add_headers = (array) $rcmail->config->get('show_additional_headers', [])) {
|
||||
$p['fetch_headers'] = trim($p['fetch_headers']. ' ' . strtoupper(join(' ', $add_headers)));
|
||||
}
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
function message_headers($p)
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
|
||||
foreach ((array) $rcmail->config->get('show_additional_headers', []) as $header) {
|
||||
if ($value = $p['headers']->get($header)) {
|
||||
$p['output'][$header] = ['title' => $header, 'value' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,3 @@ class ShowAdditionalHeaders_Plugin extends PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf('rcube_plugin', $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
private $prefs = null;
|
||||
private $identities_level = 0;
|
||||
private $abook = array();
|
||||
private $abook = [];
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->add_hook('user_create', array($this, 'create_user'));
|
||||
$this->add_hook('identity_create', array($this, 'create_identity'));
|
||||
$this->add_hook('user_create', [$this, 'create_user']);
|
||||
$this->add_hook('identity_create', [$this, 'create_identity']);
|
||||
}
|
||||
|
||||
public function create_user($p)
|
||||
@@ -29,9 +29,11 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
// read prefs and add email address
|
||||
$this->read_squirrel_prefs($p['user']);
|
||||
if (($this->identities_level == 0 || $this->identities_level == 2)
|
||||
|
||||
if (
|
||||
($this->identities_level == 0 || $this->identities_level == 2)
|
||||
&& $rcmail->config->get('squirrelmail_set_alias')
|
||||
&& $this->prefs['email_address']
|
||||
&& !empty($this->prefs['email_address'])
|
||||
) {
|
||||
$p['user_email'] = $this->prefs['email_address'];
|
||||
}
|
||||
@@ -45,45 +47,49 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
// prefs are set in create_user()
|
||||
if ($this->prefs) {
|
||||
if ($this->prefs['full_name']) {
|
||||
if (!empty($this->prefs['full_name'])) {
|
||||
$p['record']['name'] = $this->prefs['full_name'];
|
||||
}
|
||||
|
||||
if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) {
|
||||
if (
|
||||
($this->identities_level == 0 || $this->identities_level == 2)
|
||||
&& !empty($this->prefs['email_address'])
|
||||
) {
|
||||
$p['record']['email'] = $this->prefs['email_address'];
|
||||
}
|
||||
|
||||
if ($this->prefs['___signature___']) {
|
||||
if (!empty($this->prefs['___signature___'])) {
|
||||
$p['record']['signature'] = $this->prefs['___signature___'];
|
||||
}
|
||||
|
||||
if ($this->prefs['reply_to']) {
|
||||
if (!empty($this->prefs['reply_to'])) {
|
||||
$p['record']['reply-to'] = $this->prefs['reply_to'];
|
||||
}
|
||||
|
||||
if (($this->identities_level == 0 || $this->identities_level == 1)
|
||||
if (
|
||||
($this->identities_level == 0 || $this->identities_level == 1)
|
||||
&& isset($this->prefs['identities']) && $this->prefs['identities'] > 1
|
||||
) {
|
||||
for ($i = 1; $i < $this->prefs['identities']; $i++) {
|
||||
unset($ident_data);
|
||||
$ident_data = array('name' => '', 'email' => ''); // required data
|
||||
$ident_data = ['name' => '', 'email' => '']; // required data
|
||||
|
||||
if ($this->prefs['full_name'.$i]) {
|
||||
if (!empty($this->prefs['full_name'.$i])) {
|
||||
$ident_data['name'] = $this->prefs['full_name'.$i];
|
||||
}
|
||||
|
||||
if ($this->identities_level == 0 && $this->prefs['email_address'.$i]) {
|
||||
if ($this->identities_level == 0 && !empty($this->prefs['email_address'.$i])) {
|
||||
$ident_data['email'] = $this->prefs['email_address'.$i];
|
||||
}
|
||||
else {
|
||||
$ident_data['email'] = $p['record']['email'];
|
||||
}
|
||||
|
||||
if ($this->prefs['reply_to'.$i]) {
|
||||
if (!empty($this->prefs['reply_to'.$i])) {
|
||||
$ident_data['reply-to'] = $this->prefs['reply_to'.$i];
|
||||
}
|
||||
|
||||
if ($this->prefs['___sig'.$i.'___']) {
|
||||
if (!empty($this->prefs['___sig'.$i.'___'])) {
|
||||
$ident_data['signature'] = $this->prefs['___sig'.$i.'___'];
|
||||
}
|
||||
|
||||
@@ -94,8 +100,8 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
// copy address book
|
||||
$contacts = $rcmail->get_address_book(null, true);
|
||||
$addresses = array();
|
||||
$groups = array();
|
||||
$addresses = [];
|
||||
$groups = [];
|
||||
|
||||
if ($contacts && !empty($this->abook)) {
|
||||
foreach ($this->abook as $rec) {
|
||||
@@ -106,25 +112,31 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
// create group for addresses
|
||||
if (count($emails) > 1) {
|
||||
if (!($group_id = $groups[$rec['name']])) {
|
||||
if ($group = $contacts->create_group($rec['name'])) {
|
||||
$group_id = $group['id'];
|
||||
$groups[$rec['name']] = $group_id;
|
||||
}
|
||||
if (!empty($groups[$rec['name']])) {
|
||||
$group_id = $groups[$rec['name']];
|
||||
}
|
||||
else if ($group = $contacts->create_group($rec['name'])) {
|
||||
$group_id = $group['id'];
|
||||
$groups[$rec['name']] = $group_id;
|
||||
}
|
||||
}
|
||||
|
||||
// create contacts
|
||||
foreach ($emails as $email) {
|
||||
if (!($contact_id = $addresses[$email]) && rcube_utils::check_email(rcube_utils::idn_to_ascii($email))) {
|
||||
$contact_id = null;
|
||||
|
||||
if (!empty($addresses[$email])) {
|
||||
$contact_id = $addresses[$email];
|
||||
}
|
||||
else if (rcube_utils::check_email(rcube_utils::idn_to_ascii($email))) {
|
||||
$rec['email'] = rcube_utils::idn_to_utf8($email);
|
||||
if ($contact_id = $contacts->insert($rec, true)) {
|
||||
$addresses[$email] = $contact_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($group_id && $contact_id) {
|
||||
$contacts->add_to_group($group_id, array($contact_id));
|
||||
if (!empty($group_id) && !empty($contact_id)) {
|
||||
$contacts->add_to_group($group_id, [$contact_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,9 +181,9 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
$sigbase = slashify($srcdir) . $uname . '.si';
|
||||
|
||||
if (is_readable($prefsfile)) {
|
||||
$this->prefs = array();
|
||||
$this->prefs = [];
|
||||
foreach (file($prefsfile) as $line) {
|
||||
list($key, $value) = explode('=', $line);
|
||||
list($key, $value) = rcube_utils::explode('=', $line);
|
||||
$this->prefs[$key] = $this->convert_charset(rtrim($value), $file_charset);
|
||||
}
|
||||
|
||||
@@ -193,19 +205,17 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
|
||||
// parse address book file
|
||||
if (filesize($abookfile)) {
|
||||
|
||||
foreach (file($abookfile) as $line) {
|
||||
|
||||
$line = $this->convert_charset(rtrim($line), $file_charset);
|
||||
$line = str_getcsv($line, "|");
|
||||
|
||||
$rec = array(
|
||||
$rec = [
|
||||
'name' => $line[0],
|
||||
'firstname' => $line[1],
|
||||
'surname' => $line[2],
|
||||
'email' => $line[3],
|
||||
'notes' => $line[4],
|
||||
);
|
||||
];
|
||||
|
||||
if ($rec['name'] && $rec['email']) {
|
||||
$this->abook[] = $rec;
|
||||
@@ -215,8 +225,8 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
}
|
||||
}
|
||||
// Database backend
|
||||
else if ($rcmail->config->get('squirrelmail_driver') == 'sql') {
|
||||
$this->prefs = array();
|
||||
else if ($rcmail->config->get('squirrelmail_driver') == 'sql') {
|
||||
$this->prefs = [];
|
||||
|
||||
// connect to squirrelmail database
|
||||
$db = rcube_db::factory($rcmail->config->get('squirrelmail_dsn'));
|
||||
@@ -230,7 +240,7 @@ class squirrelmail_usercopy extends rcube_plugin
|
||||
$db_charset = $rcmail->config->get('squirrelmail_db_charset');
|
||||
|
||||
if ($db_charset) {
|
||||
$db->query('SET NAMES '.$db_charset);
|
||||
$db->query('SET NAMES ' . $db_charset);
|
||||
}
|
||||
|
||||
$sql_result = $db->query('SELECT * FROM ' . $db->quote_identifier($userprefs_table)
|
||||
|
||||
@@ -20,4 +20,3 @@ class SquirrelmailUsercopy_Plugin extends PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf('rcube_plugin', $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,4 @@
|
||||
For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-subscriptions_option/
|
||||
*/
|
||||
|
||||
$labels = array();
|
||||
$labels['useimapsubscriptions'] = 'Use IMAP Subscriptions';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* Add it to the plugins list in config.inc.php to enable the user option
|
||||
* The user option can be hidden and set globally by adding 'use_subscriptions'
|
||||
* to the 'dont_override' configure line:
|
||||
* $config['dont_override'] = array('use_subscriptions');
|
||||
* $config['dont_override'] = ['use_subscriptions'];
|
||||
* and then set the global preference
|
||||
* $config['use_subscriptions'] = true; // or false
|
||||
*
|
||||
@@ -26,35 +26,54 @@ class subscriptions_option extends rcube_plugin
|
||||
{
|
||||
public $task = 'mail|settings';
|
||||
|
||||
/**
|
||||
* Plugin initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$dont_override = rcmail::get_instance()->config->get('dont_override', array());
|
||||
$dont_override = rcmail::get_instance()->config->get('dont_override', []);
|
||||
|
||||
if (!in_array('use_subscriptions', $dont_override)) {
|
||||
$this->add_hook('preferences_list', array($this, 'settings_blocks'));
|
||||
$this->add_hook('preferences_save', array($this, 'save_prefs'));
|
||||
$this->add_hook('preferences_list', [$this, 'prefs_list']);
|
||||
$this->add_hook('preferences_save', [$this, 'prefs_save']);
|
||||
}
|
||||
$this->add_hook('storage_folders', array($this, 'mailboxes_list'));
|
||||
$this->add_hook('folders_list', array($this, 'folders_list'));
|
||||
|
||||
$this->add_hook('storage_folders', [$this, 'mailboxes_list']);
|
||||
$this->add_hook('folders_list', [$this, 'folders_list']);
|
||||
}
|
||||
|
||||
function settings_blocks($args)
|
||||
/**
|
||||
* Hook to inject plugin-specific user settings
|
||||
*
|
||||
* @param array $args Hook arguments
|
||||
*
|
||||
* @return array Modified hook arguments
|
||||
*/
|
||||
function prefs_list($args)
|
||||
{
|
||||
if ($args['section'] == 'server') {
|
||||
$this->add_texts('localization/', false);
|
||||
$use_subscriptions = rcmail::get_instance()->config->get('use_subscriptions', true);
|
||||
$field_id = 'rcmfd_use_subscriptions';
|
||||
$checkbox = new html_checkbox(array('name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1));
|
||||
$checkbox = new html_checkbox(['name' => '_use_subscriptions', 'id' => $field_id, 'value' => 1]);
|
||||
|
||||
$args['blocks']['main']['options']['use_subscriptions'] = array(
|
||||
'title' => html::label($field_id, rcube::Q($this->gettext('useimapsubscriptions'))),
|
||||
'content' => $checkbox->show($use_subscriptions?1:0),
|
||||
);
|
||||
$args['blocks']['main']['options']['use_subscriptions'] = [
|
||||
'title' => html::label($field_id, rcube::Q($this->gettext('useimapsubscriptions'))),
|
||||
'content' => $checkbox->show($use_subscriptions ? 1 : 0),
|
||||
];
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
function save_prefs($args)
|
||||
/**
|
||||
* Hook to save plugin-specific user settings
|
||||
*
|
||||
* @param array $args Hook arguments
|
||||
*
|
||||
* @return array Modified hook arguments
|
||||
*/
|
||||
function prefs_save($args)
|
||||
{
|
||||
if ($args['section'] == 'server') {
|
||||
$rcmail = rcmail::get_instance();
|
||||
@@ -63,10 +82,12 @@ class subscriptions_option extends rcube_plugin
|
||||
$args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']);
|
||||
|
||||
// if the use_subscriptions preference changes, flush the folder cache
|
||||
if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) ||
|
||||
(!$use_subscriptions && isset($_POST['_use_subscriptions']))) {
|
||||
$storage = $rcmail->get_storage();
|
||||
$storage->clear_cache('mailboxes');
|
||||
if (
|
||||
($use_subscriptions && !isset($_POST['_use_subscriptions']))
|
||||
|| (!$use_subscriptions && isset($_POST['_use_subscriptions']))
|
||||
) {
|
||||
$storage = $rcmail->get_storage();
|
||||
$storage->clear_cache('mailboxes');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class SubscriptionsOption_Plugin extends PHPUnit\Framework\TestCase
|
||||
class SubscriptionsOption_Plugin extends ActionTestCase
|
||||
{
|
||||
|
||||
function setUp()
|
||||
@@ -19,5 +19,60 @@ class SubscriptionsOption_Plugin extends PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf('subscriptions_option', $plugin);
|
||||
$this->assertInstanceOf('rcube_plugin', $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test prefs_list() method
|
||||
*/
|
||||
function test_prefs_list()
|
||||
{
|
||||
$rcube = rcube::get_instance();
|
||||
$plugin = new subscriptions_option($rcube->plugins);
|
||||
|
||||
html::$doctype = 'html5';
|
||||
|
||||
$args = ['section' => 'server', 'blocks' => ['main' => ['options' => []]]];
|
||||
|
||||
$result = $plugin->prefs_list($args);
|
||||
|
||||
$this->assertSame(
|
||||
'<label for="rcmfd_use_subscriptions">Use IMAP Subscriptions</label>',
|
||||
$result['blocks']['main']['options']['use_subscriptions']['title']
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<input name="_use_subscriptions" id="rcmfd_use_subscriptions" value="1" checked type="checkbox">',
|
||||
$result['blocks']['main']['options']['use_subscriptions']['content']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test prefs_save() method
|
||||
*/
|
||||
function test_prefs_save()
|
||||
{
|
||||
self::initStorage();
|
||||
|
||||
$rcube = rcube::get_instance();
|
||||
$plugin = new subscriptions_option($rcube->plugins);
|
||||
|
||||
$_POST = ['_use_subscriptions' => 1];
|
||||
$args = ['section' => 'server', 'prefs' => []];
|
||||
|
||||
$result = $plugin->prefs_save($args);
|
||||
|
||||
$this->assertSame(true, $result['prefs']['use_subscriptions']);
|
||||
|
||||
$storage = $rcube->storage;
|
||||
$storage->registerFunction('clear_cache', true);
|
||||
|
||||
$_POST = [];
|
||||
$args = ['section' => 'server', 'prefs' => []];
|
||||
|
||||
$result = $plugin->prefs_save($args);
|
||||
|
||||
$this->assertSame(false, $result['prefs']['use_subscriptions']);
|
||||
$this->assertCount(1, $storage->methodCalls);
|
||||
$this->assertSame('clear_cache', $storage->methodCalls[0]['name']);
|
||||
$this->assertSame(['mailboxes'], $storage->methodCalls[0]['args']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-userinfo/
|
||||
*/
|
||||
|
||||
$labels = array();
|
||||
$labels['userinfo'] = 'User info';
|
||||
$labels['infoforuser'] = 'Info for $user';
|
||||
$labels['created'] = 'Created';
|
||||
|
||||
@@ -12,26 +12,26 @@ class userinfo extends rcube_plugin
|
||||
|
||||
function init()
|
||||
{
|
||||
$this->add_texts('localization/', array('userinfo'));
|
||||
$this->add_hook('settings_actions', array($this, 'settings_actions'));
|
||||
$this->register_action('plugin.userinfo', array($this, 'infostep'));
|
||||
$this->add_texts('localization/', ['userinfo']);
|
||||
$this->add_hook('settings_actions', [$this, 'settings_actions']);
|
||||
$this->register_action('plugin.userinfo', [$this, 'infostep']);
|
||||
}
|
||||
|
||||
function settings_actions($args)
|
||||
{
|
||||
$args['actions'][] = array(
|
||||
$args['actions'][] = [
|
||||
'action' => 'plugin.userinfo',
|
||||
'class' => 'userinfo',
|
||||
'label' => 'userinfo',
|
||||
'domain' => 'userinfo',
|
||||
);
|
||||
];
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
function infostep()
|
||||
{
|
||||
$this->register_handler('plugin.body', array($this, 'infohtml'));
|
||||
$this->register_handler('plugin.body', [$this, 'infohtml']);
|
||||
|
||||
$rcmail = rcmail::get_instance();
|
||||
$rcmail->output->set_pagetitle($this->gettext('userinfo'));
|
||||
@@ -44,7 +44,7 @@ class userinfo extends rcube_plugin
|
||||
$user = $rcmail->user;
|
||||
$identity = $user->get_identity();
|
||||
|
||||
$table = new html_table(array('cols' => 2, 'class' => 'propform'));
|
||||
$table = new html_table(['cols' => 2, 'class' => 'propform']);
|
||||
|
||||
$table->add('title', html::label('', rcube::Q($this->gettext('userid'))));
|
||||
$table->add('', rcube::Q($user->ID));
|
||||
@@ -64,11 +64,12 @@ class userinfo extends rcube_plugin
|
||||
$table->add('title', html::label('', rcube::Q($this->gettext('defaultidentity'))));
|
||||
$table->add('', rcube::Q($identity['name'] . ' <' . $identity['email'] . '>'));
|
||||
|
||||
$legend = rcube::Q($this->gettext(array('name' => 'infoforuser', 'vars' => array('user' => $user->get_username()))));
|
||||
$legend = rcube::Q($this->gettext(['name' => 'infoforuser', 'vars' => ['user' => $user->get_username()]]));
|
||||
$out = html::tag('fieldset', '', html::tag('legend', '', $legend) . $table->show());
|
||||
|
||||
return html::div(array('class' => 'box formcontent'),
|
||||
html::div(array('class' => 'boxtitle'), $this->gettext('userinfo'))
|
||||
. html::div(array('class' => 'boxcontent'), $out));
|
||||
return html::div(['class' => 'box formcontent'],
|
||||
html::div(['class' => 'boxtitle'], $this->gettext('userinfo'))
|
||||
. html::div(['class' => 'boxcontent'], $out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-vcard_attachments/
|
||||
*/
|
||||
|
||||
$labels = array();
|
||||
$labels['addvcardmsg'] = 'Add vCard to addressbook';
|
||||
$labels['vcardsavefailed'] = 'Unable to save vCard';
|
||||
$labels['attachvcard'] = 'Attach vCard';
|
||||
|
||||
@@ -19,5 +19,32 @@ class VcardAttachments_Plugin extends PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf('vcard_attachments', $plugin);
|
||||
$this->assertInstanceOf('rcube_plugin', $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test is_vcard()
|
||||
*/
|
||||
function test_is_vcard()
|
||||
{
|
||||
$rcube = rcube::get_instance();
|
||||
$plugin = new vcard_attachments($rcube->plugins);
|
||||
|
||||
$part = new rcube_message_part();
|
||||
$this->assertFalse(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
|
||||
$part->mimetype = 'text/vcard';
|
||||
$this->assertTrue(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
|
||||
$part->mimetype = 'text/x-vcard';
|
||||
$this->assertTrue(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
|
||||
$part->mimetype = 'text/directory';
|
||||
$this->assertFalse(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
|
||||
$part->ctype_parameters['profile'] = 'vcard';
|
||||
$this->assertTrue(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
|
||||
$part->ctype_parameters['profile'] = 'unknown';
|
||||
$part->filename = 'vcard.vcf';
|
||||
$this->assertTrue(invokeMethod($plugin, 'is_vcard', [$part]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@ class vcard_attachments extends rcube_plugin
|
||||
|
||||
private $abook;
|
||||
private $message;
|
||||
private $vcard_parts = array();
|
||||
private $vcard_bodies = array();
|
||||
private $vcard_parts = [];
|
||||
private $vcard_bodies = [];
|
||||
|
||||
/**
|
||||
* Plugin initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
@@ -25,25 +28,25 @@ class vcard_attachments extends rcube_plugin
|
||||
$this->add_texts('localization', !$rcmail->output->ajax_call);
|
||||
$this->include_stylesheet($skin_path . '/style.css');
|
||||
$this->include_script('vcardattach.js');
|
||||
$this->add_button(
|
||||
array(
|
||||
$this->add_button([
|
||||
'type' => 'link-menuitem',
|
||||
'label' => 'vcard_attachments.forwardvcard',
|
||||
'command' => 'attach-vcard',
|
||||
'class' => 'icon vcard',
|
||||
'classact' => 'icon vcard active',
|
||||
'innerclass' => 'icon vcard',
|
||||
),
|
||||
'contactmenu');
|
||||
],
|
||||
'contactmenu'
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
|
||||
$this->add_hook('message_load', array($this, 'message_load'));
|
||||
$this->add_hook('message_objects', array($this, 'message_objects'));
|
||||
$this->add_hook('template_object_messagebody', array($this, 'html_output'));
|
||||
$this->add_hook('message_load', [$this, 'message_load']);
|
||||
$this->add_hook('message_objects', [$this, 'message_objects']);
|
||||
$this->add_hook('template_object_messagebody', [$this, 'html_output']);
|
||||
}
|
||||
else if ($rcmail->action == 'upload') {
|
||||
$this->add_hook('attachment_from_uri', array($this, 'attach_vcard'));
|
||||
$this->add_hook('attachment_from_uri', [$this, 'attach_vcard']);
|
||||
}
|
||||
else if ($rcmail->action == 'compose' && !$rcmail->output->framed) {
|
||||
$skin_path = $this->local_skin_path();
|
||||
@@ -52,8 +55,7 @@ class vcard_attachments extends rcube_plugin
|
||||
$this->add_texts('localization', true);
|
||||
$this->include_stylesheet($skin_path . '/style.css');
|
||||
$this->include_script('vcardattach.js');
|
||||
$this->add_button(
|
||||
array(
|
||||
$this->add_button([
|
||||
'type' => 'link',
|
||||
'label' => 'vcard_attachments.vcard',
|
||||
'command' => 'attach-vcard',
|
||||
@@ -61,10 +63,11 @@ class vcard_attachments extends rcube_plugin
|
||||
'classact' => $btn_class . ' vcard',
|
||||
'title' => 'vcard_attachments.attachvcard',
|
||||
'innerclass' => 'inner',
|
||||
),
|
||||
'compose-contacts-toolbar');
|
||||
],
|
||||
'compose-contacts-toolbar'
|
||||
);
|
||||
|
||||
$this->add_hook('message_compose', array($this, 'message_compose'));
|
||||
$this->add_hook('message_compose', [$this, 'message_compose']);
|
||||
}
|
||||
else if (!$rcmail->output->framed && (!$rcmail->action || $rcmail->action == 'list')) {
|
||||
$skin_path = $this->local_skin_path();
|
||||
@@ -73,7 +76,7 @@ class vcard_attachments extends rcube_plugin
|
||||
}
|
||||
}
|
||||
|
||||
$this->register_action('plugin.savevcard', array($this, 'save_vcard'));
|
||||
$this->register_action('plugin.savevcard', [$this, 'save_vcard']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,13 +132,14 @@ class vcard_attachments extends rcube_plugin
|
||||
$vid = rcube::JQ($part.':'.$idx);
|
||||
|
||||
// add box below message body
|
||||
$p['content'][] = html::p(array('class' => 'vcardattachment aligned-buttons boxinformation'),
|
||||
html::span(null, rcube::Q($display)) .
|
||||
html::tag('button', array(
|
||||
$p['content'][] = html::p(['class' => 'vcardattachment aligned-buttons boxinformation'],
|
||||
html::span(null, rcube::Q($display))
|
||||
. html::tag('button', [
|
||||
'onclick' => "return plugin_vcard_save_contact('$vid')",
|
||||
'title' => $this->gettext('addvcardmsg'),
|
||||
'class' => 'import',
|
||||
), rcube::Q($rcmail->gettext('import')))
|
||||
], rcube::Q($rcmail->gettext('import'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,8 +159,11 @@ class vcard_attachments extends rcube_plugin
|
||||
*/
|
||||
function message_compose($p)
|
||||
{
|
||||
if (rcube_utils::get_input_value('_attach_vcard', rcube_utils::INPUT_GET) == '1' && ($uri = rcube_utils::get_input_value('_uri', rcube_utils::INPUT_GET))) {
|
||||
if ($attachment = $this->attach_vcard(array('compose_id' => $p['compose_id'], 'uri' => $uri))) {
|
||||
if (
|
||||
rcube_utils::get_input_value('_attach_vcard', rcube_utils::INPUT_GET) == '1'
|
||||
&& ($uri = rcube_utils::get_input_value('_uri', rcube_utils::INPUT_GET))
|
||||
) {
|
||||
if ($attachment = $this->attach_vcard(['compose_id' => $p['compose_id'], 'uri' => $uri])) {
|
||||
$p['attachments'][] = $attachment;
|
||||
};
|
||||
}
|
||||
@@ -195,7 +202,7 @@ class vcard_attachments extends rcube_plugin
|
||||
$message = new rcube_message($uid, $mbox);
|
||||
|
||||
if ($uid && $mime_id) {
|
||||
list($mime_id, $index) = explode(':', $mime_id);
|
||||
list($mime_id, $index) = rcube_utils::explode(':', $mime_id);
|
||||
$part = $message->get_part_content($mime_id, null, true);
|
||||
}
|
||||
|
||||
@@ -220,6 +227,7 @@ class vcard_attachments extends rcube_plugin
|
||||
|
||||
// compare e-mail address
|
||||
$existing = $CONTACTS->search('email', $email, 1, false);
|
||||
|
||||
// compare display name
|
||||
if (!$existing->count && $vcard->displayname) {
|
||||
$existing = $CONTACTS->search('name', $vcard->displayname, 1, false);
|
||||
@@ -232,7 +240,7 @@ class vcard_attachments extends rcube_plugin
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null));
|
||||
$plugin = $rcmail->plugins->exec_hook('contact_create', ['record' => $contact, 'source' => null]);
|
||||
$contact = $plugin['record'];
|
||||
|
||||
if (!$plugin['abort'] && $CONTACTS->insert($contact))
|
||||
@@ -253,9 +261,9 @@ class vcard_attachments extends rcube_plugin
|
||||
*
|
||||
* @param rcube_message_part Part object
|
||||
*
|
||||
* @return boolean True if part is of type vcard
|
||||
* @return bool True if part is of type vcard
|
||||
*/
|
||||
function is_vcard($part)
|
||||
private static function is_vcard($part)
|
||||
{
|
||||
return (
|
||||
// Content-Type: text/vcard;
|
||||
@@ -264,10 +272,9 @@ class vcard_attachments extends rcube_plugin
|
||||
$part->mimetype == 'text/x-vcard' ||
|
||||
// Content-Type: text/directory; profile=vCard;
|
||||
($part->mimetype == 'text/directory' && (
|
||||
($part->ctype_parameters['profile'] &&
|
||||
strtolower($part->ctype_parameters['profile']) == 'vcard')
|
||||
(!empty($part->ctype_parameters['profile']) && strtolower($part->ctype_parameters['profile']) == 'vcard')
|
||||
// Content-Type: text/directory; (with filename=*.vcf)
|
||||
|| ($part->filename && preg_match('/\.vcf$/i', $part->filename))
|
||||
|| (!empty($part->filename) && preg_match('/\.vcf$/i', $part->filename))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -305,13 +312,14 @@ class vcard_attachments extends rcube_plugin
|
||||
if (preg_match('|^vcard://(.+)$|', $args['uri'], $m)) {
|
||||
list($source, $cid, $email) = explode('-', $m[1]);
|
||||
|
||||
$vcard = $this->get_contact_vcard($source, $cid, $filename);
|
||||
$params = array(
|
||||
'filename' => $filename,
|
||||
'mimetype' => 'text/vcard',
|
||||
);
|
||||
$vcard = $this->get_contact_vcard($source, $cid, $filename);
|
||||
|
||||
if ($vcard) {
|
||||
$params = [
|
||||
'filename' => $filename,
|
||||
'mimetype' => 'text/vcard',
|
||||
];
|
||||
|
||||
$args['attachment'] = rcmail_action_mail_compose::save_attachment($vcard, null, $args['compose_id'], $params);
|
||||
}
|
||||
}
|
||||
@@ -336,11 +344,11 @@ class vcard_attachments extends rcube_plugin
|
||||
$vcard->reset();
|
||||
|
||||
foreach ($contact as $key => $values) {
|
||||
list($field, $section) = explode(':', $key);
|
||||
list($field, $section) = rcube_utils::explode(':', $key);
|
||||
// avoid unwanted casting of DateTime objects to an array
|
||||
// (same as in rcube_contacts::convert_save_data())
|
||||
if (is_object($values) && is_a($values, 'DateTime')) {
|
||||
$values = array($values);
|
||||
$values = [$values];
|
||||
}
|
||||
|
||||
foreach ((array) $values as $value) {
|
||||
|
||||
@@ -16,14 +16,17 @@ class virtuser_file extends rcube_plugin
|
||||
private $file;
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* Plugin initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->app = rcmail::get_instance();
|
||||
$this->app = rcmail::get_instance();
|
||||
$this->file = $this->app->config->get('virtuser_file');
|
||||
|
||||
if ($this->file) {
|
||||
$this->add_hook('user2email', array($this, 'user2email'));
|
||||
$this->add_hook('email2user', array($this, 'email2user'));
|
||||
$this->add_hook('user2email', [$this, 'user2email']);
|
||||
$this->add_hook('email2user', [$this, 'email2user']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +36,7 @@ class virtuser_file extends rcube_plugin
|
||||
function user2email($p)
|
||||
{
|
||||
$r = $this->findinvirtual('/\s' . preg_quote($p['user'], '/') . '\s*$/');
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
for ($i=0; $i<count($r); $i++) {
|
||||
$arr = preg_split('/\s+/', $r[$i]);
|
||||
@@ -41,14 +44,14 @@ class virtuser_file extends rcube_plugin
|
||||
if (count($arr) > 0 && strpos($arr[0], '@')) {
|
||||
$result[] = rcube_utils::idn_to_ascii(trim(str_replace('\\@', '@', $arr[0])));
|
||||
|
||||
if ($p['first']) {
|
||||
if (!empty($p['first'])) {
|
||||
$p['email'] = $result[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$p['email'] = empty($result) ? NULL : $result;
|
||||
$p['email'] = empty($result) ? null : $result;
|
||||
|
||||
return $p;
|
||||
}
|
||||
@@ -75,28 +78,33 @@ class virtuser_file extends rcube_plugin
|
||||
/**
|
||||
* Find matches of the given pattern in virtuser file
|
||||
*
|
||||
* @param string Regular expression to search for
|
||||
* @param string $pattern Regular expression to search for
|
||||
*
|
||||
* @return array Matching entries
|
||||
*/
|
||||
private function findinvirtual($pattern)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
$virtual = null;
|
||||
|
||||
if ($this->file)
|
||||
if ($this->file) {
|
||||
$virtual = file($this->file);
|
||||
}
|
||||
|
||||
if (empty($virtual))
|
||||
if (empty($virtual)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// check each line for matches
|
||||
foreach ($virtual as $line) {
|
||||
$line = trim($line);
|
||||
if (empty($line) || $line[0]=='#')
|
||||
if (empty($line) || $line[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match($pattern, $line))
|
||||
if (preg_match($pattern, $line)) {
|
||||
$result[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* The email query could optionally select identity data columns in specified order:
|
||||
* name, organization, reply-to, bcc, signature, html_signature
|
||||
*
|
||||
* $config['virtuser_query'] = array('email' => '', 'user' => '', 'host' => '', 'alias' => '');
|
||||
* $config['virtuser_query'] = ['email' => '', 'user' => '', 'host' => '', 'alias' => ''];
|
||||
*
|
||||
* The email query can return more than one record to create more identities.
|
||||
* This requires identities_level option to be set to value less than 2.
|
||||
@@ -38,20 +38,20 @@ class virtuser_query extends rcube_plugin
|
||||
|
||||
if (!empty($this->config)) {
|
||||
if (is_string($this->config)) {
|
||||
$this->config = array('email' => $this->config);
|
||||
$this->config = ['email' => $this->config];
|
||||
}
|
||||
|
||||
if ($this->config['email']) {
|
||||
$this->add_hook('user2email', array($this, 'user2email'));
|
||||
if (!empty($this->config['email'])) {
|
||||
$this->add_hook('user2email', [$this, 'user2email']);
|
||||
}
|
||||
if ($this->config['user']) {
|
||||
$this->add_hook('email2user', array($this, 'email2user'));
|
||||
if (!empty($this->config['user'])) {
|
||||
$this->add_hook('email2user', [$this, 'email2user']);
|
||||
}
|
||||
if ($this->config['host']) {
|
||||
$this->add_hook('authenticate', array($this, 'user2host'));
|
||||
if (!empty($this->config['host'])) {
|
||||
$this->add_hook('authenticate', [$this, 'user2host']);
|
||||
}
|
||||
if ($this->config['alias']) {
|
||||
$this->add_hook('authenticate', array($this, 'alias2user'));
|
||||
if (!empty($this->config['alias'])) {
|
||||
$this->add_hook('authenticate', [$this, 'alias2user']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,26 +64,26 @@ class virtuser_query extends rcube_plugin
|
||||
$dbh = $this->get_dbh();
|
||||
|
||||
$sql_result = $dbh->query(preg_replace('/%u/', $dbh->escape($p['user']), $this->config['email']));
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
while ($sql_arr = $dbh->fetch_array($sql_result)) {
|
||||
if (strpos($sql_arr[0], '@')) {
|
||||
if ($p['extended'] && count($sql_arr) > 1) {
|
||||
$result[] = array(
|
||||
if (!empty($p['extended']) && count($sql_arr) > 1) {
|
||||
$result[] = [
|
||||
'email' => rcube_utils::idn_to_ascii($sql_arr[0]),
|
||||
'name' => (string) $sql_arr[1],
|
||||
'organization' => (string) $sql_arr[2],
|
||||
'reply-to' => (string) rcube_utils::idn_to_ascii($sql_arr[3]),
|
||||
'bcc' => (string) rcube_utils::idn_to_ascii($sql_arr[4]),
|
||||
'signature' => (string) $sql_arr[5],
|
||||
'html_signature' => (int) $sql_arr[6],
|
||||
);
|
||||
'name' => isset($sql_arr[1]) ? $sql_arr[1] : '',
|
||||
'organization' => isset($sql_arr[2]) ? $sql_arr[2] : '',
|
||||
'reply-to' => isset($sql_arr[3]) ? rcube_utils::idn_to_ascii($sql_arr[3]) : '',
|
||||
'bcc' => isset($sql_arr[4]) ? rcube_utils::idn_to_ascii($sql_arr[4]) : '',
|
||||
'signature' => isset($sql_arr[5]) ? $sql_arr[5] : '',
|
||||
'html_signature' => isset($sql_arr[6]) ? intval($sql_arr[6]) : 0,
|
||||
];
|
||||
}
|
||||
else {
|
||||
$result[] = $sql_arr[0];
|
||||
}
|
||||
|
||||
if ($p['first']) {
|
||||
if (!empty($p['first'])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -161,5 +161,4 @@ class virtuser_query extends rcube_plugin
|
||||
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,5 +17,3 @@ $config['zipdownload_selection'] = '50MB';
|
||||
|
||||
// Charset to use for filenames inside the zip
|
||||
$config['zipdownload_charset'] = 'ISO-8859-1';
|
||||
|
||||
?>
|
||||
@@ -14,7 +14,6 @@
|
||||
For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-zipdownload/
|
||||
*/
|
||||
|
||||
$labels = array();
|
||||
$labels['downloadall'] = 'Download all attachments';
|
||||
$labels['download'] = 'Download...';
|
||||
$labels['downloadmbox'] = 'Mbox format (.zip)';
|
||||
|
||||
@@ -20,4 +20,3 @@ class Zipdownload_Plugin extends PHPUnit\Framework\TestCase
|
||||
$this->assertInstanceOf('rcube_plugin', $plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class zipdownload extends rcube_plugin
|
||||
public $task = 'mail';
|
||||
|
||||
private $charset = 'ASCII';
|
||||
private $names = array();
|
||||
private $names = [];
|
||||
private $default_limit = '50MB';
|
||||
|
||||
// RFC4155: mbox date format
|
||||
@@ -30,11 +30,13 @@ class zipdownload extends rcube_plugin
|
||||
{
|
||||
// check requirements first
|
||||
if (!class_exists('ZipArchive', false)) {
|
||||
rcmail::raise_error(array(
|
||||
'code' => 520,
|
||||
'file' => __FILE__,
|
||||
'line' => __LINE__,
|
||||
'message' => "php_zip extension is required for the zipdownload plugin"), true, false);
|
||||
rcmail::raise_error([
|
||||
'code' => 520,
|
||||
'file' => __FILE__,
|
||||
'line' => __LINE__,
|
||||
'message' => "php-zip extension is required for the zipdownload plugin"
|
||||
], true, false
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,11 +47,11 @@ class zipdownload extends rcube_plugin
|
||||
|
||||
if ($rcmail->config->get('zipdownload_attachments', 1) > -1 && ($rcmail->action == 'show' || $rcmail->action == 'preview')) {
|
||||
$this->add_texts('localization');
|
||||
$this->add_hook('template_object_messageattachments', array($this, 'attachment_ziplink'));
|
||||
$this->add_hook('template_object_messageattachments', [$this, 'attachment_ziplink']);
|
||||
}
|
||||
|
||||
$this->register_action('plugin.zipdownload.attachments', array($this, 'download_attachments'));
|
||||
$this->register_action('plugin.zipdownload.messages', array($this, 'download_messages'));
|
||||
$this->register_action('plugin.zipdownload.attachments', [$this, 'download_attachments']);
|
||||
$this->register_action('plugin.zipdownload.messages', [$this, 'download_messages']);
|
||||
|
||||
if (!$rcmail->action && $rcmail->config->get('zipdownload_selection', $this->default_limit)) {
|
||||
$this->add_texts('localization');
|
||||
@@ -66,20 +68,21 @@ class zipdownload extends rcube_plugin
|
||||
|
||||
// only show the link if there is more than the configured number of attachments
|
||||
if (substr_count($p['content'], '<li') > $rcmail->config->get('zipdownload_attachments', 1)) {
|
||||
$href = $rcmail->url(array(
|
||||
'_action' => 'plugin.zipdownload.attachments',
|
||||
'_mbox' => $rcmail->output->env['mailbox'],
|
||||
'_uid' => $rcmail->output->env['uid'],
|
||||
), false, false, true);
|
||||
$href = $rcmail->url([
|
||||
'_action' => 'plugin.zipdownload.attachments',
|
||||
'_mbox' => $rcmail->output->get_env('mailbox'),
|
||||
'_uid' => $rcmail->output->get_env('uid'),
|
||||
], false, false, true);
|
||||
|
||||
$link = html::a(array('href' => $href, 'class' => 'button zipdownload'),
|
||||
$link = html::a(
|
||||
['href' => $href, 'class' => 'button zipdownload'],
|
||||
rcube::Q($this->gettext('downloadall'))
|
||||
);
|
||||
|
||||
// append link to attachments list, slightly different in some skins
|
||||
switch (rcmail::get_instance()->config->get('skin')) {
|
||||
case 'classic':
|
||||
$p['content'] = str_replace('</ul>', html::tag('li', array('class' => 'zipdownload'), $link) . '</ul>', $p['content']);
|
||||
$p['content'] = str_replace('</ul>', html::tag('li', ['class' => 'zipdownload'], $link) . '</ul>', $p['content']);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -102,25 +105,30 @@ class zipdownload extends rcube_plugin
|
||||
$this->add_label('download');
|
||||
|
||||
$rcmail = rcmail::get_instance();
|
||||
$menu = array();
|
||||
$ul_attr = array('role' => 'menu', 'aria-labelledby' => 'aria-label-zipdownloadmenu');
|
||||
$menu = [];
|
||||
$ul_attr = ['role' => 'menu', 'aria-labelledby' => 'aria-label-zipdownloadmenu'];
|
||||
|
||||
if ($rcmail->config->get('skin') != 'classic') {
|
||||
$ul_attr['class'] = 'toolbarmenu menu';
|
||||
}
|
||||
|
||||
foreach (array('eml', 'mbox', 'maildir') as $type) {
|
||||
$menu[] = html::tag('li', null, $rcmail->output->button(array(
|
||||
foreach (['eml', 'mbox', 'maildir'] as $type) {
|
||||
$menu[] = html::tag('li', null, $rcmail->output->button([
|
||||
'command' => "download-$type",
|
||||
'label' => "zipdownload.download$type",
|
||||
'class' => "download $type disabled",
|
||||
'classact' => "download $type active",
|
||||
'type' => 'link',
|
||||
)));
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
$rcmail->output->add_footer(html::div(array('id' => 'zipdownload-menu', 'class' => 'popupmenu', 'aria-hidden' => 'true'),
|
||||
html::tag('h2', array('class' => 'voice', 'id' => 'aria-label-zipdownloadmenu'), "Message Download Options Menu") .
|
||||
html::tag('ul', $ul_attr, implode('', $menu))));
|
||||
$rcmail->output->add_footer(
|
||||
html::div(['id' => 'zipdownload-menu', 'class' => 'popupmenu', 'aria-hidden' => 'true'],
|
||||
html::tag('h2', ['class' => 'voice', 'id' => 'aria-label-zipdownloadmenu'], "Message Download Options Menu")
|
||||
. html::tag('ul', $ul_attr, implode('', $menu))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +142,7 @@ class zipdownload extends rcube_plugin
|
||||
$rcmail->request_security_check(rcube_utils::INPUT_GET);
|
||||
|
||||
$tmpfname = rcube_utils::temp_filename('zipdownload');
|
||||
$tempfiles = array($tmpfname);
|
||||
$tempfiles = [$tmpfname];
|
||||
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));
|
||||
|
||||
// open zip file
|
||||
@@ -142,8 +150,8 @@ class zipdownload extends rcube_plugin
|
||||
$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
|
||||
|
||||
foreach ($message->attachments as $part) {
|
||||
$pid = $part->mime_id;
|
||||
$part = $message->mime_parts[$pid];
|
||||
$pid = $part->mime_id;
|
||||
$part = $message->mime_parts[$pid];
|
||||
$disp_name = $this->_create_displayname($part);
|
||||
|
||||
$tmpfn = rcube_utils::temp_filename('zipattach');
|
||||
@@ -193,7 +201,7 @@ class zipdownload extends rcube_plugin
|
||||
*/
|
||||
private function _create_displayname($part)
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
$rcmail = rcmail::get_instance();
|
||||
$filename = $part->filename;
|
||||
|
||||
if ($filename === null || $filename === '') {
|
||||
@@ -239,10 +247,10 @@ class zipdownload extends rcube_plugin
|
||||
$limit = $limit !== true ? parse_bytes($limit) : -1;
|
||||
$delimiter = $imap->get_hierarchy_delimiter();
|
||||
$tmpfname = rcube_utils::temp_filename('zipdownload');
|
||||
$tempfiles = array($tmpfname);
|
||||
$tempfiles = [$tmpfname];
|
||||
$folders = count($messageset) > 1;
|
||||
$timezone = new DateTimeZone('UTC');
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
$size = 0;
|
||||
|
||||
// collect messages metadata (and check size limit)
|
||||
@@ -293,10 +301,10 @@ class zipdownload extends rcube_plugin
|
||||
if ($limit > 0 && $size > $limit) {
|
||||
unlink($tmpfname);
|
||||
|
||||
$msg = $this->gettext(array(
|
||||
$msg = $this->gettext([
|
||||
'name' => 'sizelimiterror',
|
||||
'vars' => array('$size' => rcmail_action::show_bytes($limit))
|
||||
));
|
||||
'vars' => ['$size' => rcmail_action::show_bytes($limit)]
|
||||
]);
|
||||
|
||||
$rcmail->output->show_message($msg, 'error');
|
||||
$rcmail->output->send('iframe');
|
||||
@@ -367,7 +375,7 @@ class zipdownload extends rcube_plugin
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
|
||||
$rcmail->output->download_headers($filename, array('length' => filesize($tmpfname)));
|
||||
$rcmail->output->download_headers($filename, ['length' => filesize($tmpfname)]);
|
||||
|
||||
readfile($tmpfname);
|
||||
}
|
||||
@@ -377,7 +385,7 @@ class zipdownload extends rcube_plugin
|
||||
*/
|
||||
private function _convert_filename($str)
|
||||
{
|
||||
$str = strtr($str, array(':' => '', '/' => '-'));
|
||||
$str = strtr($str, [':' => '', '/' => '-']);
|
||||
|
||||
return rcube_charset::convert($str, RCUBE_CHARSET, $this->charset);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
class StorageMock
|
||||
{
|
||||
public $methodCalls = [];
|
||||
|
||||
protected $mocks = [];
|
||||
|
||||
public function registerFunction($name, $result = null)
|
||||
@@ -38,6 +40,7 @@ class StorageMock
|
||||
foreach ($this->mocks as $idx => $mock) {
|
||||
if ($mock[0] == $name) {
|
||||
$result = $mock[1];
|
||||
$this->methodCalls[] = ['name' => $name, 'args' => $arguments];
|
||||
unset($this->mocks[$idx]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user