diff --git a/.eslintrc.js b/.eslintrc.js index 40c9ee7fc8..545cb60910 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -86,170 +86,128 @@ module.exports = { 'wrap-iife': ['error', 'inside'], // TODO rules to be removed/fixed later as fixes are not compatible with IE11 - 'guard-for-in': 'off', // refactor to "for of" - 'no-restricted-globals': 'off', - 'no-restricted-properties': 'off', - 'no-var': 'off', - 'one-var': 'off', - 'prefer-const': 'off', - 'prefer-exponentiation-operator': 'off', - 'prefer-rest-params': 'off', - 'prefer-spread': 'off', - 'semi-style': 'off', - 'unicorn/no-array-for-each': 'off', - 'unicorn/no-for-loop': 'off', // autofixes to "for of" - 'unicorn/prefer-code-point': 'off', - 'unicorn/prefer-includes': 'off', - 'unicorn/prefer-node-protocol': 'off', // needs Node 14+ - 'unicorn/prefer-number-properties': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', - 'unicorn/prefer-prototype-methods': 'off', - 'unicorn/prefer-reflect-apply': 'off', - 'unicorn/prefer-spread': 'off', - 'unicorn/prefer-top-level-await': 'off', // needs Node 14+ - 'vars-on-top': 'off', + 'guard-for-in': 'off', // refactor to "for of" (32 matches) + 'no-restricted-globals': 'off', // (72 matches) + 'no-var': 'off', // (986 matches) + 'one-var': 'off', // (489 matches) + 'prefer-rest-params': 'off', // (3 matches) + 'prefer-spread': 'off', // (2 matches) + 'unicorn/no-array-for-each': 'off', // (2 matches) + 'unicorn/no-for-loop': 'off', // autofixes to "for of" // (3 matches) + 'unicorn/prefer-code-point': 'off', // (21 matches) + 'unicorn/prefer-includes': 'off', // (34 matches) + 'unicorn/prefer-number-properties': 'off', // (24 matches) + 'unicorn/prefer-optional-catch-binding': 'off', // (25 matches) + 'unicorn/prefer-spread': 'off', // (7 matches) + 'vars-on-top': 'off', // (448 matches) // TODO - 'space-infix-ops': 'off', - 'space-before-function-paren': 'off', - 'no-undef': 'off', - 'no-shadow': 'off', - 'key-spacing': 'off', - 'block-spacing': 'off', - 'camelcase': 'off', - 'object-curly-spacing': 'off', - 'unicorn/prevent-abbreviations': 'off', // eslint-disable-line no-dupe-keys - 'no-var': 'off', // eslint-disable-line no-dupe-keys - 'one-var-declaration-per-line': 'off', - 'curly': 'off', // eslint-disable-line no-dupe-keys - 'space-in-parens': 'off', - 'space-before-blocks': 'off', - 'nonblock-statement-body-position': 'off', - 'brace-style': 'off', - 'eqeqeq': 'off', - 'array-bracket-spacing': 'off', - 'one-var': 'off', // eslint-disable-line no-dupe-keys - 'keyword-spacing': 'off', - 'yoda': 'off', - 'no-unused-expressions': 'off', - 'padding-line-between-statements': 'off', // eslint-disable-line no-dupe-keys - 'no-use-before-define': 'off', - 'prefer-arrow-callback': 'off', - 'no-sequences': 'off', - 'vars-on-top': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/no-null': 'off', // eslint-disable-line no-dupe-keys - 'block-scoped-var': 'off', - 'object-curly-newline': 'off', - 'no-return-assign': 'off', - 'unicorn/explicit-length-check': 'off', - 'unicorn/switch-case-braces': 'off', - 'no-mixed-operators': 'off', - 'no-cond-assign': 'off', - 'padded-blocks': 'off', - 'switch-colon-spacing': 'off', - 'comma-dangle': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-module': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-number-properties': 'off', // eslint-disable-line no-dupe-keys - 'strict': 'off', // eslint-disable-line no-dupe-keys - 'no-redeclare': 'off', - 'no-extra-semi': 'off', - 'function-paren-newline': 'off', - 'unicorn/no-this-assignment': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/no-nested-ternary': 'off', - 'unicorn/no-negated-condition': 'off', // eslint-disable-line no-dupe-keys - 'computed-property-spacing': 'off', - 'no-restricted-globals': 'off', // eslint-disable-line no-dupe-keys - 'quote-props': 'off', - 'no-multiple-empty-lines': 'off', - 'wrap-iife': 'off', // eslint-disable-line no-dupe-keys - 'no-multi-assign': 'off', - 'no-multi-spaces': 'off', // eslint-disable-line no-dupe-keys - 'newline-per-chained-call': 'off', - 'unicorn/prefer-query-selector': 'off', - 'unicorn/better-regex': 'off', - 'unicorn/prefer-string-replace-all': 'off', - 'no-void': 'off', - 'prefer-rest-params': 'off', // eslint-disable-line no-dupe-keys - 'no-bitwise': 'off', - 'spaced-comment': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-string-slice': 'off', - 'unicorn/catch-error-name': 'off', // eslint-disable-line no-dupe-keys - 'no-useless-escape': 'off', - 'guard-for-in': 'off', // eslint-disable-line no-dupe-keys - 'object-property-newline': 'off', - 'unicorn/consistent-function-scoping': 'off', - 'unicorn/prefer-regexp-test': 'off', - 'unicorn/prefer-optional-catch-binding': 'off', // eslint-disable-line no-dupe-keys - 'dot-notation': 'off', - 'unicorn/prefer-includes': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-spread': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-reflect-apply': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/no-array-callback-reference': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-dom-node-append': 'off', - 'unicorn/numeric-separators-style': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-add-event-listener': 'off', - 'unicorn/no-lonely-if': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-date-now': 'off', - 'unicorn/prefer-code-point': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-logical-operator-over-ternary': 'off', - 'no-unneeded-ternary': 'off', - 'no-empty': 'off', - 'new-cap': 'off', - 'function-call-argument-newline': 'off', - 'unicorn/filename-case': 'off', - 'no-else-return': 'off', - 'unicorn/prefer-ternary': 'off', - 'new-parens': 'off', - 'no-fallthrough': 'off', - 'operator-linebreak': 'off', - 'space-unary-ops': 'off', - 'radix': 'off', - 'unicorn/no-array-method-this-argument': 'off', - 'no-floating-decimal': 'off', - 'array-callback-return': 'off', - 'prefer-spread': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-string-starts-ends-with': 'off', - 'unicorn/require-array-join-separator': 'off', - 'unicorn/prefer-at': 'off', - 'unicorn/no-typeof-undefined': 'off', - 'unicorn/prefer-dom-node-remove': 'off', - 'no-throw-literal': 'off', - 'no-loop-func': 'off', - 'prefer-exponentiation-operator': 'off', // eslint-disable-line no-dupe-keys - 'no-restricted-properties': 'off', // eslint-disable-line no-dupe-keys - 'operator-assignment': 'off', - 'no-alert': 'off', - 'unicorn/escape-case': 'off', - 'unicorn/prefer-dom-node-dataset': 'off', - 'unicorn/empty-brace-spaces': 'off', - 'unicorn/no-for-loop': 'off', // eslint-disable-line no-dupe-keys - 'lines-around-directive': 'off', - 'unicorn/no-hex-escape': 'off', - 'no-script-url': 'off', - 'no-extend-native': 'off', - 'no-shadow-restricted-names': 'off', - 'unicorn/prefer-math-trunc': 'off', - 'no-labels': 'off', - 'unicorn/prefer-modern-math-apis': 'off', - 'no-eval': 'off', - 'unicorn/new-for-builtins': 'off', - 'unicorn/no-array-for-each': 'off', // eslint-disable-line no-dupe-keys - 'unicorn/prefer-modern-dom-apis': 'off', - 'no-extra-boolean-cast': 'off', - 'no-control-regex': 'off', - 'no-label-var': 'off', - 'global-require': 'off', - 'prefer-regex-literals': 'off', - 'no-array-constructor': 'off', - 'unicorn/no-new-array': 'off', - 'no-debugger': 'off', - 'no-whitespace-before-property': 'off', - 'no-constant-condition': 'off', - 'no-implied-eval': 'off', - 'unicorn/no-document-cookie': 'off', - 'unicorn/prefer-default-parameters': 'off', - 'unicorn/prefer-negative-index': 'off', - 'no-regex-spaces': 'off', + 'array-callback-return': 'off', // (7 matches) + 'block-scoped-var': 'off', // (391 matches) + 'block-spacing': 'off', // (7 matches) + 'brace-style': 'off', // (1139 matches) + 'camelcase': 'off', // (1886 matches) + 'comma-dangle': 'off', // eslint-disable-line no-dupe-keys -- (131 matches) + 'curly': 'off', // eslint-disable-line no-dupe-keys -- (1211 matches) + 'dot-notation': 'off', // (36 matches) + 'eqeqeq': 'off', // (921 matches) + 'function-call-argument-newline': 'off', // (20 matches) + 'function-paren-newline': 'off', // (109 matches) + 'guard-for-in': 'off', // eslint-disable-line no-dupe-keys -- (32 matches) + 'key-spacing': 'off', // (233 matches) + 'keyword-spacing': 'off', // (15 matches) + 'new-cap': 'off', // (16 matches) + 'newline-per-chained-call': 'off', // (38 matches) + 'new-parens': 'off', // (1 match) + 'no-alert': 'off', // (3 matches) + 'no-bitwise': 'off', // (45 matches) + 'no-cond-assign': 'off', // (142 matches) + 'no-constant-condition': 'off', // (1 match) + 'no-debugger': 'off', // (1 match) + 'no-else-return': 'off', // (15 matches) + 'no-empty': 'off', // (15 matches) + 'no-eval': 'off', // (2 matches) + 'no-extend-native': 'off', // (3 matches) + 'no-extra-semi': 'off', // (122 matches) + 'no-fallthrough': 'off', // (10 matches) + 'no-implied-eval': 'off', // (1 match) + 'no-loop-func': 'off', // (5 matches) + 'no-mixed-operators': 'off', // (8 matches) + 'no-multi-assign': 'off', // (18 matches) + 'no-multiple-empty-lines': 'off', // (85 matches) + 'no-multi-spaces': 'off', // eslint-disable-line no-dupe-keys -- (69 matches) + 'nonblock-statement-body-position': 'off', // (1158 matches) + 'no-redeclare': 'off', // (37 matches) + 'no-regex-spaces': 'off', // (1 match) + 'no-restricted-globals': 'off', // eslint-disable-line no-dupe-keys -- (72 matches) + 'no-return-assign': 'off', // (1 match) + 'no-script-url': 'off', // (3 matches) + 'no-sequences': 'off', // (5 matches) + 'no-shadow': 'off', // (85 matches) + 'no-undef': 'off', // (2472 matches) + 'no-unneeded-ternary': 'off', // (22 matches) + 'no-unused-expressions': 'off', // (15 matches) + 'no-use-before-define': 'off', // (495 matches) + 'no-useless-escape': 'off', // (18 matches) + 'no-var': 'off', // eslint-disable-line no-dupe-keys -- (986 matches) + 'no-whitespace-before-property': 'off', // (1 match) + 'object-curly-newline': 'off', // (82 matches) + 'object-curly-spacing': 'off', // (667 matches) + 'object-property-newline': 'off', // (40 matches) + 'one-var': 'off', // eslint-disable-line no-dupe-keys -- (489 matches) + 'one-var-declaration-per-line': 'off', // (501 matches) + 'operator-assignment': 'off', // (4 matches) + 'operator-linebreak': 'off', // (14 matches) + 'padded-blocks': 'off', // (7 matches) + 'padding-line-between-statements': 'off', // eslint-disable-line no-dupe-keys -- (301 matches) + 'prefer-arrow-callback': 'off', // (423 matches) + 'prefer-rest-params': 'off', // eslint-disable-line no-dupe-keys -- (3 matches) + 'prefer-spread': 'off', // eslint-disable-line no-dupe-keys -- (2 matches) + 'quote-props': 'off', // (86 matches) + 'radix': 'off', // (12 matches) + 'space-before-blocks': 'off', // (13 matches) + 'space-before-function-paren': 'off', // (1409 matches) + 'spaced-comment': 'off', // eslint-disable-line no-dupe-keys -- (47 matches) + 'space-infix-ops': 'off', // (485 matches) + 'space-unary-ops': 'off', // (7 matches) + 'unicorn/better-regex': 'off', // (42 matches) + 'unicorn/consistent-function-scoping': 'off', // (19 matches) + 'unicorn/empty-brace-spaces': 'off', // (5 matches) + 'unicorn/escape-case': 'off', // (4 matches) + 'unicorn/explicit-length-check': 'off', // (219 matches) + 'unicorn/filename-case': 'off', // (3 matches) + 'unicorn/new-for-builtins': 'off', // (2 matches) + 'unicorn/no-array-for-each': 'off', // eslint-disable-line no-dupe-keys -- (2 matches) + 'unicorn/no-document-cookie': 'off', // (1 match) + 'unicorn/no-for-loop': 'off', // eslint-disable-line no-dupe-keys -- (3 matches) + 'unicorn/no-hex-escape': 'off', // (2 matches) + 'unicorn/no-nested-ternary': 'off', // (2 matches) + 'unicorn/no-new-array': 'off', // (1 match) + 'unicorn/no-typeof-undefined': 'off', // (3 matches) + 'unicorn/prefer-add-event-listener': 'off', // (28 matches) + 'unicorn/prefer-at': 'off', // (7 matches) + 'unicorn/prefer-code-point': 'off', // eslint-disable-line no-dupe-keys -- (21 matches) + 'unicorn/prefer-date-now': 'off', // (25 matches) + 'unicorn/prefer-default-parameters': 'off', // (1 match) + 'unicorn/prefer-dom-node-append': 'off', // (28 matches) + 'unicorn/prefer-dom-node-dataset': 'off', // (1 match) + 'unicorn/prefer-dom-node-remove': 'off', // (4 matches) + 'unicorn/prefer-includes': 'off', // eslint-disable-line no-dupe-keys -- (34 matches) + 'unicorn/prefer-logical-operator-over-ternary': 'off', // (23 matches) + 'unicorn/prefer-modern-dom-apis': 'off', // (2 matches) + 'unicorn/prefer-negative-index': 'off', // (1 match) + 'unicorn/prefer-number-properties': 'off', // eslint-disable-line no-dupe-keys -- (24 matches) + 'unicorn/prefer-optional-catch-binding': 'off', // eslint-disable-line no-dupe-keys -- (25 matches) + 'unicorn/prefer-query-selector': 'off', // (61 matches) + 'unicorn/prefer-regexp-test': 'off', // (31 matches) + 'unicorn/prefer-spread': 'off', // eslint-disable-line no-dupe-keys -- (7 matches) + 'unicorn/prefer-string-replace-all': 'off', // (43 matches) + 'unicorn/prefer-string-slice': 'off', // (39 matches) + 'unicorn/prefer-string-starts-ends-with': 'off', // (2 matches) + 'unicorn/prefer-ternary': 'off', // (16 matches) + 'unicorn/require-array-join-separator': 'off', // (5 matches) + 'unicorn/switch-case-braces': 'off', // (161 matches) + 'vars-on-top': 'off', // eslint-disable-line no-dupe-keys -- (448 matches) }, reportUnusedDisableDirectives: true, globals: { diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index fc9e5ff878..9af5160864 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -91,15 +91,13 @@ 'binary_operator_spaces' => ['default' => 'at_least_single_space'], 'blank_line_before_statement' => false, 'class_attributes_separation' => false, - 'control_structure_continuation_position' => false, 'explicit_string_variable' => false, 'fully_qualified_strict_types' => [ 'import_symbols' => false, ], 'general_phpdoc_annotation_remove' => false, - 'method_argument_space' => false, + 'method_argument_space' => ['on_multiline' => 'ignore'], 'modernize_types_casting' => false, - 'new_with_parentheses' => false, 'no_blank_lines_after_phpdoc' => false, 'no_break_comment' => false, 'no_extra_blank_lines' => false, @@ -108,7 +106,6 @@ 'phpdoc_summary' => false, 'single_line_comment_spacing' => false, 'ternary_to_null_coalescing' => false, - 'visibility_required' => false, // TODO - risky 'no_unset_on_property' => false, diff --git a/bin/cleandb.sh b/bin/cleandb.sh index a1e8bfe48e..d3fa516f87 100755 --- a/bin/cleandb.sh +++ b/bin/cleandb.sh @@ -24,8 +24,7 @@ require INSTALL_PATH . 'program/include/clisetup.php'; if (!empty($_SERVER['argv'][1])) { $days = intval($_SERVER['argv'][1]); -} -else { +} else { $days = 7; } diff --git a/bin/deluser.sh b/bin/deluser.sh index 2861cd625b..eb1dc67717 100755 --- a/bin/deluser.sh +++ b/bin/deluser.sh @@ -109,8 +109,7 @@ $db->query('DELETE FROM ' . $db->table_name('users', true) . ' WHERE `user_id` = if ($db->is_error()) { $rcmail->plugins->exec_hook('user_delete_rollback', $plugin); _die('DB error occurred: ' . $db->is_error()); -} -else { +} else { // inform plugins about executed user deletion $plugin = $rcmail->plugins->exec_hook('user_delete_commit', $plugin); @@ -118,8 +117,7 @@ else { unset($plugin['abort']); $db->rollbackTransaction(); $rcmail->plugins->exec_hook('user_delete_rollback', $plugin); - } - else { + } else { $db->endTransaction(); echo "Successfully deleted user $user->ID\n"; } diff --git a/bin/identity.sh b/bin/identity.sh index 380d5f4851..fa87d77ae8 100755 --- a/bin/identity.sh +++ b/bin/identity.sh @@ -50,8 +50,7 @@ if (isset($subcommand_executables[$program_name])) { $program = $subcommand_executables[$program_name]; $program($options); -} -else { +} else { echo "Available sub-commands:\n"; echo "add - create a new identity for a user\n"; echo "delete - delete an identity (mark as deleted)\n"; @@ -88,8 +87,7 @@ function get_identity_attr($options) $attrValue = $identity[$attribute]; echo "$attrValue\n"; - } - else { + } else { rcube::raise_error('Invalid attribute name. Available attributes: identity_id, user_id, changed, del, standard, name, ' . 'organization, email, reply-to, bcc, signature, html_signature.', false, true); } diff --git a/bin/install-jsdeps.sh b/bin/install-jsdeps.sh index 9261fa5e54..c4b3a777c6 100755 --- a/bin/install-jsdeps.sh +++ b/bin/install-jsdeps.sh @@ -39,11 +39,9 @@ $WGET = trim(shell_exec('which wget')); if (($CACHEDIR = getenv('CACHEDIR')) && is_writable($CACHEDIR)) { // use $CACHEDIR -} -elseif (is_writable(INSTALL_PATH . 'temp/js_cache') || @mkdir(INSTALL_PATH . 'temp/js_cache', 0774, true)) { +} elseif (is_writable(INSTALL_PATH . 'temp/js_cache') || @mkdir(INSTALL_PATH . 'temp/js_cache', 0774, true)) { $CACHEDIR = INSTALL_PATH . 'temp/js_cache'; -} -else { +} else { $CACHEDIR = sys_get_temp_dir(); } @@ -124,8 +122,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null) if ($CURL) { exec(sprintf('%s -L -s %s -o %s', $CURL, escapeshellarg($url), $cache_file), $out, $retval); - } - else { + } else { exec(sprintf('%s -q %s -O %s', $WGET, escapeshellarg($url), $cache_file), $out, $retval); } @@ -138,8 +135,7 @@ function fetch_from_source($package, $useCache = true, &$filetype = null) if ($CURL) { exec(sprintf('%s -L -H %s -s %s -o %s', $CURL, escapeshellarg($header), escapeshellarg($url), $cache_file), $out, $retval); - } - else { + } else { exec(sprintf('%s --header %s -q %s -O %s', $WGET, escapeshellarg($header), escapeshellarg($url), $cache_file), $out, $retval); } } @@ -206,8 +202,7 @@ function compose_destfile($package, $srcfile) if (file_put_contents(INSTALL_PATH . $package['dest'], $header . file_get_contents($srcfile))) { echo 'Wrote file ' . INSTALL_PATH . $package['dest'] . "\n"; - } - else { + } else { rcube::raise_error('Failed to write destination file ' . INSTALL_PATH . $package['dest'], false, true); } } @@ -310,8 +305,7 @@ function delete_destfile($package) if (file_exists($destdir)) { if (\PHP_OS === 'Windows') { exec(sprintf('rd /s /q %s', escapeshellarg($destdir))); - } - else { + } else { exec(sprintf('rm -rf %s', escapeshellarg($destdir))); } } @@ -321,17 +315,16 @@ function delete_destfile($package) //////////////// Execution $args = rcube_utils::get_opt([ - 'f' => 'force:bool', - 'd' => 'delete:bool', - 'g' => 'get:bool', - 'e' => 'extract:bool', - ]) - + [ - 'force' => false, - 'delete' => false, - 'get' => false, - 'extract' => false, - ]; + 'f' => 'force:bool', + 'd' => 'delete:bool', + 'g' => 'get:bool', + 'e' => 'extract:bool', +]) + [ + 'force' => false, + 'delete' => false, + 'get' => false, + 'extract' => false, +]; $WHAT = isset($args[0]) ? $args[0] : null; $useCache = !$args['force'] && !$args['get']; @@ -356,8 +349,7 @@ foreach ($SOURCES['dependencies'] as $package) { if ($args['get']) { $srcfile = fetch_from_source($package, $useCache, $filetype); - } - else { + } else { $srcfile = extract_filetype($package, $filetype); } @@ -370,8 +362,7 @@ foreach ($SOURCES['dependencies'] as $package) { if ($filetype === 'zip') { extract_zipfile($package, $srcfile); - } - else { + } else { compose_destfile($package, $srcfile); } diff --git a/bin/installto.sh b/bin/installto.sh index 30530ae59e..b7643bfb6d 100755 --- a/bin/installto.sh +++ b/bin/installto.sh @@ -48,8 +48,7 @@ if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), ' if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '==')) { echo "Target installation already in version $oldversion. Do you want to update again? (y/N)\n"; -} -else { +} else { echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; } @@ -143,7 +142,6 @@ if (strtolower($input) == 'y') { echo "Running update script at target...\n"; system("cd $target_dir && bin/update.sh --version=$oldversion" . ($accept ? ' -y' : '')); echo "All done.\n"; -} -else { +} else { echo "Update cancelled. See ya!\n"; } diff --git a/bin/moduserprefs.sh b/bin/moduserprefs.sh index eb27a6b06c..5b83eb00ca 100755 --- a/bin/moduserprefs.sh +++ b/bin/moduserprefs.sh @@ -35,17 +35,16 @@ function print_usage() // get arguments $args = rcube_utils::get_opt([ - 'u' => 'user', - 'd' => 'delete:bool', - 't' => 'type', - 'c' => 'config', + 'u' => 'user', + 'd' => 'delete:bool', + 't' => 'type', + 'c' => 'config', ]); if (empty($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') { print_usage(); exit; -} -elseif (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) { +} elseif (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) { echo "Missing required parameters.\n"; print_usage(); exit; diff --git a/bin/msgexport.sh b/bin/msgexport.sh index aee52dcb82..7fb84eec88 100755 --- a/bin/msgexport.sh +++ b/bin/msgexport.sh @@ -61,8 +61,7 @@ function export_mailbox($mbox, $filename) return; } vputs("Writing to $filename\n"); - } - else { + } else { $out = \STDOUT; } @@ -90,8 +89,7 @@ $args = rcube_utils::get_opt($opts) + ['host' => 'localhost', 'mbox' => 'INBOX'] if (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') { print_usage(); exit; -} -elseif (!$args['host']) { +} elseif (!$args['host']) { vputs("Missing required parameters.\n"); print_usage(); exit; @@ -113,8 +111,7 @@ if (!empty($a_host['host'])) { $host = $a_host['host']; $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false; $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143); -} -else { +} else { $host = $args['host']; $imap_port = 143; $imap_ssl = false; @@ -133,8 +130,7 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) foreach ($mailboxes as $mbox) { if (!empty($args['file'])) { $filename = preg_replace('/\.[a-z0-9]{3,4}$/i', '', $args['file']) . asciiwords($mbox) . '.mbox'; - } - elseif ($args['mbox'] == '*') { + } elseif ($args['mbox'] == '*') { $filename = asciiwords($mbox) . '.mbox'; } @@ -144,7 +140,6 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) export_mailbox($mbox, $filename); } -} -else { +} else { vputs("IMAP login failed.\n"); } diff --git a/bin/msgimport.sh b/bin/msgimport.sh index 5a2143d601..06201fcf85 100755 --- a/bin/msgimport.sh +++ b/bin/msgimport.sh @@ -36,13 +36,11 @@ $args = rcube_utils::get_opt($opts) + ['host' => 'localhost', 'mbox' => 'INBOX'] if (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] == 'help') { print_usage(); exit; -} -elseif (empty($args['host']) || empty($args['file'])) { +} elseif (empty($args['host']) || empty($args['file'])) { echo "Missing required parameters.\n"; print_usage(); exit; -} -elseif (!is_file($args['file'])) { +} elseif (!is_file($args['file'])) { rcube::raise_error('Cannot read message file.', false, true); } @@ -64,8 +62,7 @@ if (!empty($a_host['host'])) { $host = $a_host['host']; $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl', 'imaps', 'tls'])) ? true : false; $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143); -} -else { +} else { $host = $args['host']; $imap_port = 143; $imap_ssl = false; @@ -88,8 +85,7 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) if (!empty($message)) { if ($IMAP->save_message($args['mbox'], rtrim($message))) { $count++; - } - else { + } else { rcube::raise_error("Failed to save message to {$args['mbox']}", false, true); } $message = ''; @@ -108,11 +104,9 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) // upload message from file if ($count) { echo "$count messages successfully added to {$args['mbox']}.\n"; - } - else { + } else { echo "Adding messages failed!\n"; } -} -else { +} else { rcube::raise_error('IMAP login failed.', false, true); } diff --git a/bin/update.sh b/bin/update.sh index e88257bd93..a3c2c94e9f 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -32,8 +32,7 @@ if (empty($opts['version'])) { if (($input = trim(fgets(\STDIN))) && preg_match('/^[0-9.]+[a-z0-9-]*$/', $input)) { $opts['version'] = $input; - } - else { + } else { $opts['version'] = RCMAIL_VERSION; } } @@ -122,14 +121,12 @@ if ($RCI->configured) { @unlink(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php'); } } - } - else { + } else { echo "Failed to write config file(s)!\n"; echo 'Grant write privileges to the current user or update the files manually ' . "according to the above messages.\n"; } - } - else { + } else { echo "Please update your config files manually according to the above messages.\n"; } } @@ -230,8 +227,7 @@ if ($RCI->configured) { // remove old repos if (isset($_repo['url']) && strpos($_repo['url'], 'git://git.kolab.org') === 0) { unset($composer_data['repositories'][$k]); - } - elseif ( + } elseif ( $_repo['type'] == 'package' && !empty($_repo['package']['name']) && $_repo['package']['name'] == 'Net_SMTP' @@ -253,8 +249,7 @@ if ($RCI->configured) { // write updated composer.json back to disk if ($composer_json && is_writable(INSTALL_PATH . 'composer.json')) { $success &= (bool) file_put_contents(INSTALL_PATH . 'composer.json', $composer_json); - } - else { + } else { echo "WARNING: unable to update composer.json!\n"; echo "Please replace the 'require' section in your composer.json with the following:\n"; @@ -291,8 +286,7 @@ if ($RCI->configured) { echo "This instance of Roundcube is up-to-date.\n"; echo "Have fun!\n"; } -} -else { +} else { echo "This instance of Roundcube is not yet configured!\n"; echo "Open http://url-to-roundcube/installer/ in your browser and follow the instructions.\n"; } diff --git a/bin/updatecss.sh b/bin/updatecss.sh index 775c1a59ce..9d61d15e85 100755 --- a/bin/updatecss.sh +++ b/bin/updatecss.sh @@ -38,8 +38,7 @@ if (empty($opts['dir'])) { // Check if directory exists elseif (!file_exists($opts['dir'])) { rcube::raise_error("Specified directory doesn't exist.", false, true); -} -else { +} else { $dirs = [$opts['dir']]; } @@ -83,8 +82,7 @@ function get_images($dir) $filepath = "$dir/$file"; $images[$file] = substr(md5_file($filepath), 0, 4) . '.' . filesize($filepath); echo "Image: $filepath ({$images[$file]})\n"; - } - elseif ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) { + } elseif ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) { foreach (get_images($dir . '/' . $file) as $img => $sum) { $images[$file . '/' . $img] = $sum; } @@ -104,8 +102,7 @@ function get_files($dir) while ($file = readdir($dh)) { if (preg_match('/^(.+)\.(css|html)$/', $file, $m)) { $files[] = $file; - } - elseif ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) { + } elseif ($file != '.' && $file != '..' && is_dir($dir . '/' . $file)) { foreach (get_files($dir . '/' . $file) as $f) { $files[] = $file . '/' . $f; } diff --git a/bin/updatedb.sh b/bin/updatedb.sh index 517e5e7116..ebf9dc290f 100755 --- a/bin/updatedb.sh +++ b/bin/updatedb.sh @@ -25,9 +25,9 @@ require_once INSTALL_PATH . 'program/include/clisetup.php'; // get arguments $opts = rcube_utils::get_opt([ - 'v' => 'version', - 'd' => 'dir', - 'p' => 'package', + 'v' => 'version', + 'd' => 'dir', + 'p' => 'package', ]); if (empty($opts['dir'])) { diff --git a/config/defaults.inc.php b/config/defaults.inc.php index d6c4b5ce8c..fa46b0eb04 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -54,10 +54,10 @@ // This can be used in a setup with replicated databases and a DB master // where read/write access to cache tables should not go to master. $config['db_table_dsn'] = [ -// 'cache' => 'r', -// 'cache_index' => 'r', -// 'cache_thread' => 'r', -// 'cache_messages' => 'r', + // 'cache' => 'r', + // 'cache_index' => 'r', + // 'cache_thread' => 'r', + // 'cache_messages' => 'r', ]; // It is possible to specify database variable values e.g. some limits here. @@ -1038,8 +1038,8 @@ // A static list of canned responses which are immutable for the user $config['compose_responses_static'] = [ -// ['name' => 'Canned Response 1', 'text' => 'Static Response One'], -// ['name' => 'Canned Response 2', 'text' => 'Static Response Two'], + // ['name' => 'Canned Response 1', 'text' => 'Static Response One'], + // ['name' => 'Canned Response 2', 'text' => 'Static Response Two'], ]; // List of HKP key servers for PGP public key lookups in Enigma/Mailvelope diff --git a/config/mimetypes.php b/config/mimetypes.php index fb38f8cf77..b906503c3d 100644 --- a/config/mimetypes.php +++ b/config/mimetypes.php @@ -8,49 +8,49 @@ */ return [ - 'xls' => 'application/vnd.ms-excel', - 'xlm' => 'application/vnd.ms-excel', - 'xla' => 'application/vnd.ms-excel', - 'xlc' => 'application/vnd.ms-excel', - 'xlt' => 'application/vnd.ms-excel', - 'xlw' => 'application/vnd.ms-excel', - 'pdf' => 'application/pdf', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pps' => 'application/vnd.ms-powerpoint', - 'pot' => 'application/vnd.ms-powerpoint', - 'doc' => 'application/msword', - 'dot' => 'application/msword', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'otf' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'otm' => 'application/vnd.oasis.opendocument.text-master', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web', - 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xps' => 'application/vnd.ms-xpsdocument', - 'rar' => 'application/x-rar-compressed', - '7z' => 'application/x-7z-compressed', - 's7z' => 'application/x-7z-compressed', - 'vcf' => 'text/vcard', - 'ics' => 'text/calendar', + 'xls' => 'application/vnd.ms-excel', + 'xlm' => 'application/vnd.ms-excel', + 'xla' => 'application/vnd.ms-excel', + 'xlc' => 'application/vnd.ms-excel', + 'xlt' => 'application/vnd.ms-excel', + 'xlw' => 'application/vnd.ms-excel', + 'pdf' => 'application/pdf', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pps' => 'application/vnd.ms-powerpoint', + 'pot' => 'application/vnd.ms-powerpoint', + 'doc' => 'application/msword', + 'dot' => 'application/msword', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'otf' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'otm' => 'application/vnd.oasis.opendocument.text-master', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xps' => 'application/vnd.ms-xpsdocument', + 'rar' => 'application/x-rar-compressed', + '7z' => 'application/x-7z-compressed', + 's7z' => 'application/x-7z-compressed', + 'vcf' => 'text/vcard', + 'ics' => 'text/calendar', ]; diff --git a/index.php b/index.php index 343bc60f37..e64d5b198c 100644 --- a/index.php +++ b/index.php @@ -107,12 +107,12 @@ } $auth = $RCMAIL->plugins->exec_hook('authenticate', [ - 'host' => $RCMAIL->autoselect_host(), - 'user' => trim(rcube_utils::get_input_string('_user', rcube_utils::INPUT_POST)), - 'pass' => rcube_utils::get_input_string('_pass', rcube_utils::INPUT_POST, true, $pass_charset), - 'valid' => $request_valid, - 'error' => null, - 'cookiecheck' => true, + 'host' => $RCMAIL->autoselect_host(), + 'user' => trim(rcube_utils::get_input_string('_user', rcube_utils::INPUT_POST)), + 'pass' => rcube_utils::get_input_string('_pass', rcube_utils::INPUT_POST, true, $pass_charset), + 'valid' => $request_valid, + 'error' => null, + 'cookiecheck' => true, ]); // Login @@ -152,12 +152,10 @@ // send redirect $RCMAIL->output->redirect($redir, 0, true); - } - else { + } else { if (!$auth['valid']) { $error_code = rcmail::ERROR_INVALID_REQUEST; - } - else { + } else { $error_code = is_numeric($auth['error']) ? $auth['error'] : $RCMAIL->login_error(); } @@ -171,8 +169,7 @@ if (!empty($auth['error']) && !is_numeric($auth['error'])) { $error_message = $auth['error']; - } - else { + } else { $error_message = !empty($error_labels[$error_code]) ? $error_labels[$error_code] : 'loginfailed'; } @@ -182,9 +179,9 @@ $RCMAIL->log_login($auth['user'], true, $error_code); $RCMAIL->plugins->exec_hook('login_failed', [ - 'code' => $error_code, - 'host' => $auth['host'], - 'user' => $auth['user'], + 'code' => $error_code, + 'host' => $auth['host'], + 'user' => $auth['user'], ]); if (!isset($_SESSION['user_id'])) { @@ -245,10 +242,10 @@ } $plugin = $RCMAIL->plugins->exec_hook('unauthenticated', [ - 'task' => 'login', - 'error' => $session_error, - // Return 401 only on failed logins (#7010) - 'http_code' => empty($session_error) && !empty($error_message) ? 401 : 200, + 'task' => 'login', + 'error' => $session_error, + // Return 401 only on failed logins (#7010) + 'http_code' => empty($session_error) && !empty($error_message) ? 401 : 200, ]); $RCMAIL->set_task($plugin['task']); @@ -258,8 +255,7 @@ } $RCMAIL->output->send($plugin['task']); -} -else { +} else { // CSRF prevention $RCMAIL->request_security_check(); diff --git a/installer/check.php b/installer/check.php index 98f5ead66c..d6467560fc 100644 --- a/installer/check.php +++ b/installer/check.php @@ -109,8 +109,7 @@ define('MIN_PHP_VERSION', '7.3.0'); if (version_compare(\PHP_VERSION, MIN_PHP_VERSION, '>=')) { $RCI->pass('Version', 'PHP ' . \PHP_VERSION . ' detected'); -} -else { +} else { $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . \PHP_VERSION . ' detected'); } ?> @@ -126,8 +125,7 @@ foreach ($required_php_exts as $name => $ext) { if (extension_loaded($ext)) { $RCI->pass($name); - } - else { + } else { $_ext = $ext_dir . '/' . $prefix . $ext . '.' . \PHP_SHLIB_SUFFIX; $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : ''; $RCI->fail($name, $msg, $source_urls[$name]); @@ -143,8 +141,7 @@ foreach ($optional_php_exts as $name => $ext) { if (extension_loaded($ext)) { $RCI->pass($name); - } - else { + } else { $_ext = $ext_dir . '/' . $prefix . $ext . '.' . \PHP_SHLIB_SUFFIX; $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : ''; $RCI->na($name, $msg, $source_urls[$name]); @@ -164,8 +161,7 @@ if (extension_loaded($ext)) { $RCI->pass($database); $found_db_driver = true; - } - else { + } else { $_ext = $ext_dir . '/' . $prefix . $ext . '.' . \PHP_SHLIB_SUFFIX; $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : ''; $RCI->na($database, $msg, $source_urls[$ext]); @@ -186,8 +182,7 @@ foreach ($required_libs as $classname => $vendor) { if (class_exists($classname)) { $RCI->pass($classname); - } - else { + } else { $RCI->fail($classname, "Failed to load class $classname from $vendor", $source_urls[$classname]); } echo '
'; @@ -196,8 +191,7 @@ foreach ($optional_libs as $classname => $vendor) { if (class_exists($classname)) { $RCI->pass($classname); - } - else { + } else { $RCI->na($classname, "Recommended to install $classname from $vendor", $source_urls[$classname]); } echo '
'; @@ -215,15 +209,12 @@ if ($val === '-NOTEMPTY-') { if (empty($status)) { $RCI->fail($var, 'empty value detected'); - } - else { + } else { $RCI->pass($var); } - } - elseif (filter_var($status, \FILTER_VALIDATE_BOOLEAN) == $val) { + } elseif (filter_var($status, \FILTER_VALIDATE_BOOLEAN) == $val) { $RCI->pass($var); - } - else { + } else { $RCI->fail($var, "is '$status', should be '$val'"); } echo '
'; @@ -239,8 +230,7 @@ if ($val === '-NOTEMPTY-') { if (empty($status)) { $RCI->optfail($var, 'Could be set'); - } - else { + } else { $RCI->pass($var); } echo '
'; @@ -251,19 +241,15 @@ try { $tz = new DateTimeZone($status); $RCI->pass($var); - } - catch (Exception $e) { + } catch (Exception $e) { $RCI->optfail($var, empty($status) ? 'not set' : "invalid value detected: $status"); } - } - else { + } else { $RCI->pass($var); } - } - elseif (filter_var($status, \FILTER_VALIDATE_BOOLEAN) == $val) { + } elseif (filter_var($status, \FILTER_VALIDATE_BOOLEAN) == $val) { $RCI->pass($var); - } - else { + } else { $RCI->optfail($var, "is '$status', could be '$val'"); } echo '
'; diff --git a/installer/config.php b/installer/config.php index 17e2e214cb..0a1cdc783a 100644 --- a/installer/config.php +++ b/installer/config.php @@ -34,8 +34,7 @@ } echo '

'; - } - else { + } else { $save_button = ''; if (($dir = sys_get_temp_dir()) && @is_writable($dir)) { echo ''; diff --git a/installer/index.php b/installer/index.php index 2664c9e6a0..90fe4127dc 100644 --- a/installer/index.php +++ b/installer/index.php @@ -123,8 +123,7 @@ echo '

We changed the configuration files structure and your installation needs to be updated accordingly.

'; echo '

Please run the bin/update.sh script from the command line or set

  $rcube_config[\'enable_installer\'] = true;

'; echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.

'; - } - else { + } else { echo '

The installer is disabled!

'; echo '

To enable it again, set $config[\'enable_installer\'] = true; in RCUBE_CONFIG_DIR/config.inc.php

'; } diff --git a/installer/test.php b/installer/test.php index d356d34ae3..d3b4065c18 100644 --- a/installer/test.php +++ b/installer/test.php @@ -27,12 +27,10 @@ $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'defaults.inc.php'); if (!empty($config)) { $RCI->pass('defaults.inc.php'); - } - else { + } else { $RCI->fail('defaults.inc.php', 'Syntax error'); } -} -else { +} else { $RCI->fail('defaults.inc.php', 'Unable to read default config file?'); } @@ -42,12 +40,10 @@ $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'config.inc.php'); if (!empty($config)) { $RCI->pass('config.inc.php'); - } - else { + } else { $RCI->fail('config.inc.php', 'Syntax error'); } -} -else { +} else { $RCI->fail('config.inc.php', 'Unable to read file. Did you create the config file?'); } @@ -111,8 +107,7 @@ if (is_writable(realpath($dirpath))) { $RCI->pass($dir); $pass = true; - } - else { + } else { $RCI->fail($dir, 'not writeable for the webserver'); } echo '
'; @@ -138,18 +133,15 @@ $RCI->pass('DSN (write)'); echo '
'; $db_working = true; - } - else { + } else { $RCI->fail('DSN (write)', $db_error_msg); echo '

Make sure that the configured database exists and that the user has write privileges
'; echo 'DSN: ' . rcube::Q($RCI->config['db_dsnw']) . '

'; } - } - else { + } else { $RCI->fail('DSN (write)', 'not set'); } -} -else { +} else { $RCI->fail('DSN (write)', 'Could not read config file'); } @@ -160,8 +152,7 @@ echo '

Please try to initialize the database manually as described in the INSTALL guide. Make sure that the configured database exists and that the user as write privileges

'; } -} -elseif ($db_working && !empty($_POST['updatedb'])) { +} elseif ($db_working && !empty($_POST['updatedb'])) { if (!$RCI->update_db($_POST['version'])) { echo '

Database schema update failed.

'; } @@ -177,8 +168,7 @@ . ''; $db_working = false; - } - elseif ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { + } elseif ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) { $RCI->fail('DB Schema', 'Database schema differs'); echo ''; @@ -192,8 +182,7 @@ . ''; $db_working = false; - } - else { + } else { $RCI->pass('DB Schema'); echo '
'; } @@ -215,8 +204,7 @@ $RCI->pass('DB Write'); $DB->query('DELETE FROM ' . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') . ' WHERE `sess_id` = ?', $insert_id); - } - else { + } else { $RCI->fail('DB Write', $RCI->get_error()); } echo '
'; @@ -237,8 +225,7 @@ // sometimes db and web servers are on separate hosts, so allow a 30 minutes delta if (abs($tz_diff) > 1800) { $RCI->fail('DB Time', "Database time differs {$tz_diff}s from PHP time"); - } - else { + } else { $RCI->pass('DB Time'); } } @@ -253,13 +240,11 @@ $RCI->fail('Fileinfo/mime_content_type configuration'); if (!empty($RCI->config['mime_magic'])) { echo '

Try setting the mime_magic config option to null.

'; - } - else { + } else { echo '

Check the Fileinfo functions of your PHP installation.
'; echo 'The path to the magic.mime file can be set using the mime_magic config option in Roundcube.

'; } -} -else { +} else { $RCI->pass('Fileinfo/mime_content_type configuration'); echo '
'; } @@ -269,8 +254,7 @@ $RCI->fail('Mimetype to file extension mapping'); echo '

Please set a valid path to your webserver\'s mime.types file to the mime_types config option.
'; echo 'If you can\'t find such a file, download it from svn.apache.org.

'; -} -else { +} else { $RCI->pass('Mimetype to file extension mapping'); echo '
'; } @@ -279,8 +263,7 @@ if (!empty($smtp_hosts)) { $smtp_host_field = new html_select(['name' => '_smtp_host', 'id' => 'smtp_host']); $smtp_host_field->add($smtp_hosts, $smtp_hosts); -} -else { +} else { $smtp_host_field = new html_inputfield(['name' => '_smtp_host', 'id' => 'smtp_host']); } @@ -290,15 +273,13 @@ if ($user == '%u') { $user_field = new html_inputfield(['name' => '_smtp_user', 'id' => 'smtp_user']); $user = $user_field->show(isset($_POST['_smtp_user']) ? $_POST['_smtp_user'] : ''); -} -else { +} else { $user = html::quote($user); } if ($pass == '%p') { $pass_field = new html_passwordfield(['name' => '_smtp_pass', 'id' => 'smtp_pass']); $pass = $pass_field->show(); -} -else { +} else { $pass = html::quote($pass); } @@ -375,12 +356,10 @@ if ($status) { $RCI->pass('SMTP send'); - } - else { + } else { $RCI->fail('SMTP send', implode('; ', $smtp_response)); } - } - else { + } else { $RCI->fail('SMTP send', 'Invalid sender or recipient'); } @@ -416,8 +395,7 @@ if (!empty($default_hosts)) { $host_field = new html_select(['name' => '_host', 'id' => 'imaphost']); $host_field->add($default_hosts, $default_hosts); -} -else { +} else { $host_field = new html_inputfield(['name' => '_host', 'id' => 'imaphost']); } @@ -463,7 +441,7 @@ $imap_host = rcube_utils::idn_to_ascii($imap_host); $imap_user = rcube_utils::idn_to_ascii($_POST['_user']); - $imap = new rcube_imap; + $imap = new rcube_imap(); $imap->set_options([ 'auth_type' => $RCI->getprop('imap_auth_type'), 'debug' => $RCI->getprop('imap_debug'), @@ -473,8 +451,7 @@ if ($imap->connect($imap_host, $imap_user, $_POST['_pass'], $imap_port, $imap_ssl)) { $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no')); $imap->close(); - } - else { + } else { $RCI->fail('IMAP connect', $RCI->get_error()); } } diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index b3ac02d5e3..6542ba1bad 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -34,7 +34,7 @@ class acl extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->rc = rcmail::get_instance(); @@ -49,7 +49,7 @@ function init() /** * Handler for plugin actions (AJAX) */ - function acl_actions() + public function acl_actions() { $action = trim(rcube_utils::get_input_string('_act', rcube_utils::INPUT_GPC)); @@ -62,11 +62,9 @@ function acl_actions() if ($action == 'save') { $this->action_save(); - } - elseif ($action == 'delete') { + } elseif ($action == 'delete') { $this->action_delete(); - } - elseif ($action == 'list') { + } elseif ($action == 'list') { $this->action_list(); } @@ -77,7 +75,7 @@ function acl_actions() /** * Handler for user login autocomplete request */ - function acl_autocomplete() + public function acl_autocomplete() { $this->load_config(); @@ -147,7 +145,7 @@ function acl_autocomplete() * * @return array Hook arguments array */ - function folder_form($args) + public function folder_form($args) { $mbox_imap = $args['options']['name'] ?? ''; $myrights = $args['options']['rights'] ?? ''; @@ -201,9 +199,9 @@ function folder_form($args) $this->rc->output->set_env('acl_users_source', (bool) $this->rc->config->get('acl_users_source')); $this->rc->output->set_env('mailbox', $mbox_imap); $this->rc->output->add_handlers([ - 'acltable' => [$this, 'templ_table'], - 'acluser' => [$this, 'templ_user'], - 'aclrights' => [$this, 'templ_rights'], + 'acltable' => [$this, 'templ_table'], + 'acluser' => [$this, 'templ_user'], + 'aclrights' => [$this, 'templ_rights'], ]); $this->rc->output->set_env('autocomplete_max', (int) $this->rc->config->get('autocomplete_max', 15)); @@ -225,7 +223,7 @@ function folder_form($args) * * @return string HTML Content */ - function templ_table($attrib) + public function templ_table($attrib) { if (empty($attrib['id'])) { $attrib['id'] = 'acl-table'; @@ -245,7 +243,7 @@ function templ_table($attrib) * * @return string HTML Content */ - function templ_rights($attrib) + public function templ_rights($attrib) { // Get supported rights $supported = $this->rights_supported(); @@ -314,7 +312,7 @@ function templ_rights($attrib) * * @return string HTML Content */ - function templ_user($attrib) + public function templ_user($attrib) { // Create username input $class = !empty($attrib['class']) ? $attrib['class'] : ''; @@ -409,8 +407,7 @@ private function list_rights($attrib = []) foreach ($supported as $sup) { $items[$sup] = $sup; } - } - else { + } else { $items = [ 'read' => 'lrs', 'write' => 'wi', @@ -450,8 +447,7 @@ private function list_rights($attrib = []) if (!empty($this->specials) && in_array($user, $this->specials)) { $username = $this->gettext($user); - } - else { + } else { $username = $this->resolve_acl_identifier($user, $title); } @@ -509,11 +505,9 @@ private function action_save() if ($prefix && strpos($user, $prefix) === 0) { $username = $user; - } - elseif (!empty($this->specials) && in_array($user, $this->specials)) { + } elseif (!empty($this->specials) && in_array($user, $this->specials)) { $username = $this->gettext($user); - } - elseif (!empty($user)) { + } elseif (!empty($user)) { if (!strpos($user, '@') && ($realm = $this->get_realm())) { $user .= '@' . rcube_utils::idn_to_ascii(preg_replace('/^@/', '', $realm)); } @@ -538,12 +532,12 @@ private function action_save() if ($this->rc->storage->set_acl($mbox, $user, $acl)) { $display = $this->resolve_acl_identifier($username, $title); $this->rc->output->command('acl_update', [ - 'id' => rcube_utils::html_identifier($user), - 'username' => $username, - 'title' => $title, - 'display' => $display, - 'acl' => implode('', $acl), - 'old' => $oldid, + 'id' => rcube_utils::html_identifier($user), + 'username' => $username, + 'title' => $title, + 'display' => $display, + 'acl' => implode('', $acl), + 'old' => $oldid, ]); $result++; } @@ -552,8 +546,7 @@ private function action_save() if ($result) { $this->rc->output->show_message($oldid ? 'acl.updatesuccess' : 'acl.createsuccess', 'confirmation'); - } - else { + } else { $this->rc->output->show_message($oldid ? 'acl.updateerror' : 'acl.createerror', 'error'); } } @@ -572,16 +565,14 @@ private function action_delete() $u = trim($u); if ($this->rc->storage->delete_acl($mbox, $u)) { $this->rc->output->command('acl_remove_row', rcube_utils::html_identifier($u)); - } - else { + } else { $error = true; } } if (empty($error)) { $this->rc->output->show_message('acl.deletesuccess', 'confirmation'); - } - else { + } else { $this->rc->output->show_message('acl.deleteerror', 'error'); } } @@ -616,7 +607,7 @@ private function action_list() * * @return string HTML content */ - function acl2text($rights) + public function acl2text($rights) { if (empty($rights)) { return ''; @@ -650,7 +641,7 @@ function acl2text($rights) * * @return int Comparison result, 2 - full match, 1 - partial match, 0 - no match */ - function acl_compare($acl1, $acl2) + public function acl_compare($acl1, $acl2) { if (!is_array($acl1)) { $acl1 = str_split($acl1); @@ -684,7 +675,7 @@ function acl_compare($acl1, $acl2) * * @return array List of supported access rights abbreviations */ - function rights_supported() + public function rights_supported() { if ($this->supported !== null) { return $this->supported; @@ -694,8 +685,7 @@ function rights_supported() if (is_array($capa) && !empty($capa)) { $rights = strtolower($capa[0]); - } - else { + } else { $rights = 'cd'; } diff --git a/plugins/acl/tests/Acl.php b/plugins/acl/tests/Acl.php index 0b326f4795..5fd2f13327 100644 --- a/plugins/acl/tests/Acl.php +++ b/plugins/acl/tests/Acl.php @@ -2,7 +2,7 @@ class Acl_Plugin extends ActionTestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../acl.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new acl($rcube->plugins); diff --git a/plugins/additional_message_headers/additional_message_headers.php b/plugins/additional_message_headers/additional_message_headers.php index 8f79cd37e4..e003c016f1 100644 --- a/plugins/additional_message_headers/additional_message_headers.php +++ b/plugins/additional_message_headers/additional_message_headers.php @@ -18,7 +18,7 @@ class additional_message_headers extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->add_hook('message_before_send', [$this, 'message_headers']); } @@ -30,7 +30,7 @@ function init() * * @return array Modified hook arguments */ - function message_headers($args) + public function message_headers($args) { $this->load_config(); diff --git a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php index b390894414..3cd2256477 100644 --- a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php +++ b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php @@ -2,7 +2,7 @@ class AdditionalMessageHeaders_Plugin extends ActionTestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../additional_message_headers.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test the plugin */ - function test_plugin() + public function test_plugin() { $rcube = rcube::get_instance(); $plugin = new additional_message_headers($rcube->plugins); diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php index b37ecb7ead..5d69ae8db4 100644 --- a/plugins/archive/archive.php +++ b/plugins/archive/archive.php @@ -23,7 +23,7 @@ class archive extends rcube_plugin /** * Plugin initialization. */ - function init() + public function init() { $rcmail = rcmail::get_instance(); @@ -56,13 +56,11 @@ function init() // set env variables for client $rcmail->output->set_env('archive_folder', $this->archive_folder); - $rcmail->output->set_env('archive_type', $rcmail->config->get('archive_type','')); - } - elseif ($rcmail->task == 'mail') { + $rcmail->output->set_env('archive_type', $rcmail->config->get('archive_type', '')); + } elseif ($rcmail->task == 'mail') { // handler for ajax request $this->register_action('plugin.move2archive', [$this, 'move_messages']); - } - elseif ($rcmail->task == 'settings') { + } elseif ($rcmail->task == 'settings') { $this->add_hook('preferences_list', [$this, 'prefs_table']); $this->add_hook('preferences_save', [$this, 'prefs_save']); @@ -78,14 +76,13 @@ function init() /** * Hook to give the archive folder a localized name in the mailbox list */ - function render_mailboxlist($p) + public function render_mailboxlist($p) { // set localized name for the configured archive folder if ($this->archive_folder && !rcmail::get_instance()->config->get('show_real_foldernames')) { if (isset($p['list'][$this->archive_folder])) { $p['list'][$this->archive_folder]['name'] = $this->gettext('archivefolder'); - } - else { + } else { // search in subfolders $this->_mod_folder_name($p['list'], $this->archive_folder, $this->gettext('archivefolder')); } @@ -103,8 +100,7 @@ private function _mod_folder_name(&$list, $folder, $new_name) if ($item['id'] == $folder) { $list[$idx]['name'] = $new_name; return true; - } - elseif (!empty($item['folders'])) { + } elseif (!empty($item['folders'])) { if ($this->_mod_folder_name($list[$idx]['folders'], $folder, $new_name)) { return true; } @@ -118,7 +114,7 @@ private function _mod_folder_name(&$list, $folder, $new_name) * Plugin action to move the submitted list of messages to the archive subfolders * according to the user settings and their headers. */ - function move_messages() + public function move_messages() { $rcmail = rcmail::get_instance(); @@ -162,8 +158,7 @@ function move_messages() if (!$this->archive_folder || $mbox === $this->archive_folder || strpos($mbox, $archive_prefix) === 0) { $count = count($uids); continue; - } - elseif (!$archive_type || $archive_type == 'folder') { + } elseif (!$archive_type || $archive_type == 'folder') { $folder = $this->archive_folder; if ($archive_type == 'folder') { @@ -175,8 +170,7 @@ function move_messages() $this->subfolder_worker($folder); $count += $this->move_messages_worker($uids, $mbox, $folder, $read_on_move); - } - else { + } else { if ($uids == '*') { $index = $storage->index(null, $sort_col, $sort_ord); $uids = $index->get(); @@ -247,8 +241,7 @@ function move_messages() // FIXME: send updated message rows instead of reloading the entire list $rcmail->output->command('refresh_list'); $addrows = false; - } - else { + } else { $addrows = true; } @@ -260,8 +253,7 @@ function move_messages() if ($from_show_action) { if ($next = rcube_utils::get_input_string('_next_uid', rcube_utils::INPUT_GPC)) { $rcmail->output->command('show_message', $next); - } - else { + } else { $rcmail->output->command('command', 'list'); } @@ -316,8 +308,7 @@ function move_messages() if ($this->result['reload']) { $rcmail->output->show_message($this->gettext('archivedreload'), 'confirmation'); - } - else { + } else { $rcmail->output->show_message($this->gettext('archived'), 'confirmation'); if (!$read_on_move) { @@ -393,7 +384,7 @@ private function subfolder_worker($folder) * * @return array Modified hook arguments */ - function prefs_table($args) + public function prefs_table($args) { $this->add_texts('localization'); @@ -407,16 +398,15 @@ function prefs_table($args) // load folders list when needed if ($args['current']) { $select = rcmail_action::folder_selector([ - 'noselection' => '---', - 'realnames' => true, - 'maxlength' => 30, - 'folder_filter' => 'mail', - 'folder_rights' => 'w', - 'onchange' => "if ($(this).val() == 'INBOX') $(this).val('')", - 'class' => 'custom-select', + 'noselection' => '---', + 'realnames' => true, + 'maxlength' => 30, + 'folder_filter' => 'mail', + 'folder_rights' => 'w', + 'onchange' => "if ($(this).val() == 'INBOX') $(this).val('')", + 'class' => 'custom-select', ]); - } - else { + } else { $select = new html_select(); } @@ -449,8 +439,7 @@ function prefs_table($args) ], ]; } - } - elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { + } elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { $chbox = new html_checkbox(['name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1]); $args['blocks']['main']['options']['read_on_archive'] = [ 'title' => html::label('ff_read_on_archive', rcube::Q($this->gettext('readonarchive'))), @@ -468,15 +457,14 @@ function prefs_table($args) * * @return array Modified hook arguments */ - function prefs_save($args) + public function prefs_save($args) { $rcmail = rcmail::get_instance(); $dont_override = $rcmail->config->get('dont_override', []); if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) { $args['prefs']['archive_type'] = rcube_utils::get_input_string('_archive_type', rcube_utils::INPUT_POST); - } - elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { + } elseif ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) { $args['prefs']['read_on_archive'] = (bool) rcube_utils::get_input_value('_read_on_archive', rcube_utils::INPUT_POST); } diff --git a/plugins/archive/tests/Archive.php b/plugins/archive/tests/Archive.php index 17091341cc..c958727479 100644 --- a/plugins/archive/tests/Archive.php +++ b/plugins/archive/tests/Archive.php @@ -2,7 +2,7 @@ class Archive_Plugin extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../archive.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new archive($rcube->plugins); @@ -24,7 +24,7 @@ function test_constructor() /** * Test prefs_table() method */ - function test_prefs_table() + public function test_prefs_table() { $rcube = rcube::get_instance(); $plugin = new archive($rcube->plugins); @@ -49,7 +49,7 @@ function test_prefs_table() /** * Test prefs_save() method */ - function test_prefs_save() + public function test_prefs_save() { $rcube = rcube::get_instance(); $plugin = new archive($rcube->plugins); diff --git a/plugins/attachment_reminder/attachment_reminder.php b/plugins/attachment_reminder/attachment_reminder.php index 1c3328e569..d9b61908c6 100644 --- a/plugins/attachment_reminder/attachment_reminder.php +++ b/plugins/attachment_reminder/attachment_reminder.php @@ -34,7 +34,7 @@ class attachment_reminder extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $rcmail = rcube::get_instance(); @@ -63,7 +63,7 @@ function init() * * @return array Hook arguments */ - function prefs_list($args) + public function prefs_list($args) { if ($args['section'] == 'compose') { $this->add_texts('localization/'); @@ -87,7 +87,7 @@ function prefs_list($args) * * @return array Hook arguments */ - function prefs_save($args) + public function prefs_save($args) { if ($args['section'] == 'compose') { $dont_override = rcube::get_instance()->config->get('dont_override', []); diff --git a/plugins/attachment_reminder/tests/AttachmentReminder.php b/plugins/attachment_reminder/tests/AttachmentReminder.php index b4d595482d..3d4c5a79a2 100644 --- a/plugins/attachment_reminder/tests/AttachmentReminder.php +++ b/plugins/attachment_reminder/tests/AttachmentReminder.php @@ -2,7 +2,7 @@ class AttachmentReminder_Plugin extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../attachment_reminder.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new attachment_reminder($rcube->plugins); @@ -24,7 +24,7 @@ function test_constructor() /** * Test prefs_list() method */ - function test_prefs_list() + public function test_prefs_list() { $rcube = rcube::get_instance(); $plugin = new attachment_reminder($rcube->plugins); @@ -46,7 +46,7 @@ function test_prefs_list() /** * Test prefs_save() method */ - function test_prefs_save() + public function test_prefs_save() { $rcube = rcube::get_instance(); $plugin = new attachment_reminder($rcube->plugins); diff --git a/plugins/autologon/autologon.php b/plugins/autologon/autologon.php index 30a7d34e19..5b9a4599fb 100644 --- a/plugins/autologon/autologon.php +++ b/plugins/autologon/autologon.php @@ -27,7 +27,7 @@ public function init() * * @return array Hook arguments */ - function startup($args) + public function startup($args) { // change action to login if (empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost()) { @@ -44,7 +44,7 @@ function startup($args) * * @return array Hook arguments */ - function authenticate($args) + public function authenticate($args) { if (!empty($_GET['_autologin']) && $this->is_localhost()) { $args['user'] = 'me'; diff --git a/plugins/autologon/tests/Autologon.php b/plugins/autologon/tests/Autologon.php index 318a46e9fc..f79b4f5d3b 100644 --- a/plugins/autologon/tests/Autologon.php +++ b/plugins/autologon/tests/Autologon.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new autologon($rcube->plugins); diff --git a/plugins/autologout/tests/Autologout.php b/plugins/autologout/tests/Autologout.php index b9dfa9bab8..0da48abf90 100644 --- a/plugins/autologout/tests/Autologout.php +++ b/plugins/autologout/tests/Autologout.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new autologout($rcube->plugins); diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php index 5054e9f367..017ffcda5b 100644 --- a/plugins/database_attachments/database_attachments.php +++ b/plugins/database_attachments/database_attachments.php @@ -37,12 +37,12 @@ class database_attachments extends filesystem_attachments protected $cache; // A prefix for the cache key used in the session and in the key field of the cache table - const PREFIX = 'ATTACH'; + public const PREFIX = 'ATTACH'; /** * Save a newly uploaded attachment */ - function upload($args) + public function upload($args) { $args['status'] = false; @@ -69,7 +69,7 @@ function upload($args) /** * Save an attachment from a non-upload source (draft or forward) */ - function save($args) + public function save($args) { $args['status'] = false; @@ -101,7 +101,7 @@ function save($args) * Remove an attachment from storage * This is triggered by the remove attachment button on the compose screen */ - function remove($args) + public function remove($args) { $cache = $this->get_cache(); $status = $cache->remove($args['id']); @@ -116,7 +116,7 @@ function remove($args) * For this plugin, $this->get() will check the file and * return it's contents */ - function display($args) + public function display($args) { return $this->get($args); } @@ -125,7 +125,7 @@ function display($args) * When displaying or sending the attachment the file contents are fetched * using this method. This is also called by the attachment_display hook. */ - function get($args) + public function get($args) { $cache = $this->get_cache(); $data = $cache->get($args['id']); @@ -133,8 +133,7 @@ function get($args) if ($data !== null && $data !== false) { $args['data'] = base64_decode($data); $args['status'] = true; - } - else { + } else { $args['status'] = false; } @@ -144,7 +143,7 @@ function get($args) /** * Delete all temp files associated with this user */ - function cleanup($args) + public function cleanup($args) { // check if cache object exist, it may be empty on session_destroy (#1489726) if ($cache = $this->get_cache()) { diff --git a/plugins/database_attachments/tests/DatabaseAttachments.php b/plugins/database_attachments/tests/DatabaseAttachments.php index d6a38f83d5..6ac0baffe2 100644 --- a/plugins/database_attachments/tests/DatabaseAttachments.php +++ b/plugins/database_attachments/tests/DatabaseAttachments.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new database_attachments($rcube->plugins); diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php index e35b9b74a5..8409515665 100644 --- a/plugins/debug_logger/debug_logger.php +++ b/plugins/debug_logger/debug_logger.php @@ -63,7 +63,7 @@ class debug_logger extends rcube_plugin { protected $runlog; - function init() + public function init() { require_once __DIR__ . '/runlog/runlog.php'; @@ -98,20 +98,19 @@ function init() $this->add_hook('authenticate', [$this, 'authenticate']); } - function authenticate($args) + public function authenticate($args) { $this->runlog->note('Authenticating ' . $args['user'] . '@' . $args['host']); return $args; } - function console($args) + public function console($args) { $note = $args['args'][0]; if (!empty($args['args'][1])) { $type = $args['args'][1]; - } - else { + } else { // This could be extended to detect types based on the // file which called console. For now only rcube_imap/rcube_storage is supported $bt = debug_backtrace(); @@ -151,7 +150,7 @@ function console($args) return $args; } - function __destruct() + public function __destruct() { if ($this->runlog) { $this->runlog->end(); diff --git a/plugins/debug_logger/runlog/runlog.php b/plugins/debug_logger/runlog/runlog.php index 4044ebe99c..815e5036e3 100644 --- a/plugins/debug_logger/runlog/runlog.php +++ b/plugins/debug_logger/runlog/runlog.php @@ -20,7 +20,7 @@ class runlog public $timestamp = 'd-M-Y H:i:s O'; public $max_line_size = 150; - function __construct() + public function __construct() { $this->start_time = microtime(true); } @@ -76,7 +76,7 @@ public function end() } $end_txt = sprintf("end: $name - %0.4f seconds $tag_report", $this->run_log[$lastk]['duration']); $this->print_to_console($end_txt, $this->run_log[$lastk]['tag']); - $this->print_to_file($end_txt, $this->run_log[$lastk]['tag']); + $this->print_to_file($end_txt, $this->run_log[$lastk]['tag']); } } @@ -164,7 +164,7 @@ public function print_to_file($msg, $tag = false) $buffer = sprintf('[%s] %s', date($this->timestamp, time()), $buffer); } if (strlen($buffer) > $this->max_line_size) { - $buffer = substr($buffer,0,$this->max_line_size - 3) . '...'; + $buffer = substr($buffer, 0, $this->max_line_size - 3) . '...'; } fwrite($this->file_handles['master'], $buffer . "\n"); } @@ -181,8 +181,7 @@ public function print_to_console($msg, $tag = false) } echo "$msg\n"; } - } - else { + } else { echo $this->get_indent(); if ($tag) { echo "$tag: "; @@ -201,7 +200,7 @@ private function get_indent() return $buf; } - function __destruct() + public function __destruct() { foreach ($this->file_handles as $handle) { fclose($handle); diff --git a/plugins/debug_logger/tests/DebugLogger.php b/plugins/debug_logger/tests/DebugLogger.php index c497e53263..a07b7fb0e9 100644 --- a/plugins/debug_logger/tests/DebugLogger.php +++ b/plugins/debug_logger/tests/DebugLogger.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new debug_logger($rcube->plugins); diff --git a/plugins/emoticons/emoticons.php b/plugins/emoticons/emoticons.php index 72af3b3e0b..df2ece5c0b 100644 --- a/plugins/emoticons/emoticons.php +++ b/plugins/emoticons/emoticons.php @@ -20,7 +20,7 @@ class emoticons extends rcube_plugin /** * Plugin initialization. */ - function init() + public function init() { $rcube = rcube::get_instance(); @@ -37,7 +37,7 @@ function init() * 'message_part_after' hook handler to replace common * plain text emoticons with emoji */ - function message_part_after($args) + public function message_part_after($args) { if ($args['type'] == 'plain') { $this->load_config(); @@ -56,7 +56,7 @@ function message_part_after($args) /** * 'html_editor' hook handler, where we enable emoticons in TinyMCE */ - function html_editor($args) + public function html_editor($args) { $rcube = rcube::get_instance(); @@ -73,7 +73,7 @@ function html_editor($args) /** * 'preferences_list' hook handler */ - function preferences_list($args) + public function preferences_list($args) { $rcube = rcube::get_instance(); $dont_override = $rcube->config->get('dont_override', []); @@ -86,11 +86,10 @@ function preferences_list($args) $checkbox = new html_checkbox(['name' => '_' . $field_id, 'id' => $field_id, 'value' => 1]); $args['blocks']['main']['options']['emoticons_display'] = [ - 'title' => html::label($field_id, $this->gettext('emoticonsdisplay')), - 'content' => $checkbox->show(intval($rcube->config->get('emoticons_display', false))), + 'title' => html::label($field_id, $this->gettext('emoticonsdisplay')), + 'content' => $checkbox->show(intval($rcube->config->get('emoticons_display', false))), ]; - } - elseif ($args['section'] == 'compose' && !in_array('emoticons_compose', $dont_override)) { + } elseif ($args['section'] == 'compose' && !in_array('emoticons_compose', $dont_override)) { $this->load_config(); $this->add_texts('localization'); @@ -98,8 +97,8 @@ function preferences_list($args) $checkbox = new html_checkbox(['name' => '_' . $field_id, 'id' => $field_id, 'value' => 1]); $args['blocks']['main']['options']['emoticons_compose'] = [ - 'title' => html::label($field_id, $this->gettext('emoticonscompose')), - 'content' => $checkbox->show(intval($rcube->config->get('emoticons_compose', true))), + 'title' => html::label($field_id, $this->gettext('emoticonscompose')), + 'content' => $checkbox->show(intval($rcube->config->get('emoticons_compose', true))), ]; } @@ -109,12 +108,11 @@ function preferences_list($args) /** * 'preferences_save' hook handler */ - function preferences_save($args) + public function preferences_save($args) { if ($args['section'] == 'mailview') { $args['prefs']['emoticons_display'] = (bool) rcube_utils::get_input_value('_emoticons_display', rcube_utils::INPUT_POST); - } - elseif ($args['section'] == 'compose') { + } elseif ($args['section'] == 'compose') { $args['prefs']['emoticons_compose'] = (bool) rcube_utils::get_input_value('_emoticons_compose', rcube_utils::INPUT_POST); } diff --git a/plugins/emoticons/tests/Emoticons.php b/plugins/emoticons/tests/Emoticons.php index 9b898fee29..8c99dfd729 100644 --- a/plugins/emoticons/tests/Emoticons.php +++ b/plugins/emoticons/tests/Emoticons.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new emoticons($rcube->plugins); diff --git a/plugins/enigma/bin/import_keys.sh b/plugins/enigma/bin/import_keys.sh index e8d7ca21dc..1e007ac437 100755 --- a/plugins/enigma/bin/import_keys.sh +++ b/plugins/enigma/bin/import_keys.sh @@ -28,10 +28,10 @@ $rcmail = rcube::get_instance(); // get arguments $args = rcube_utils::get_opt([ - 'u' => 'user', - 'h' => 'host', - 'd' => 'dir', - 'x' => 'dry-run', + 'u' => 'user', + 'h' => 'host', + 'd' => 'dir', + 'x' => 'dry-run', ]); if (!empty($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'help') { @@ -90,11 +90,9 @@ function get_host($args) $hosts = $rcmail->config->get('imap_host', ''); if (is_string($hosts)) { $args['host'] = $hosts; - } - elseif (is_array($hosts) && count($hosts) == 1) { + } elseif (is_array($hosts) && count($hosts) == 1) { $args['host'] = reset($hosts); - } - else { + } else { rcube::raise_error('Specify a host name', true); } @@ -160,9 +158,9 @@ function import_dir($user_id, $dir, $dry_run = false) if ($datasize > $maxsize) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to save $file. Size exceeds max_allowed_packet.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to save $file. Size exceeds max_allowed_packet.", + ], true, false); continue; } @@ -180,9 +178,9 @@ function import_dir($user_id, $dir, $dry_run = false) if ($db->is_error($result)) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to save $file into database.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to save $file into database.", + ], true, false); } } } diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php index deb2ac5cb5..03f448913e 100644 --- a/plugins/enigma/enigma.php +++ b/plugins/enigma/enigma.php @@ -31,7 +31,7 @@ class enigma extends rcube_plugin /** * Plugin initialization. */ - function init() + public function init() { $this->rc = rcube::get_instance(); @@ -67,8 +67,7 @@ function init() } $this->password_handler(); - } - elseif ($this->rc->task == 'settings') { + } elseif ($this->rc->task == 'settings') { // add hooks for Enigma settings $this->add_hook('settings_actions', [$this, 'settings_actions']); $this->add_hook('preferences_sections_list', [$this, 'preferences_sections_list']); @@ -87,8 +86,7 @@ function init() } $this->password_handler(); - } - elseif ($this->rc->task == 'cli') { + } elseif ($this->rc->task == 'cli') { $this->add_hook('user_delete_commit', [$this, 'user_delete']); } @@ -98,7 +96,7 @@ function init() /** * Plugin environment initialization. */ - function load_env() + public function load_env() { if ($this->env_loaded) { return; @@ -121,7 +119,7 @@ function load_env() /** * Plugin UI initialization. */ - function load_ui($all = false) + public function load_ui($all = false) { if (!$this->ui) { // load config/localization @@ -140,7 +138,7 @@ function load_ui($all = false) /** * Plugin engine initialization. */ - function load_engine() + public function load_engine() { if ($this->engine) { return $this->engine; @@ -160,7 +158,7 @@ function load_engine() * * @return array Modified parameters */ - function part_structure($p) + public function part_structure($p) { $this->load_engine(); @@ -175,7 +173,7 @@ function part_structure($p) * * @return array Modified parameters */ - function part_body($p) + public function part_body($p) { $this->load_engine(); @@ -190,7 +188,7 @@ function part_body($p) * * @return array Modified parameters */ - function settings_actions($args) + public function settings_actions($args) { // add labels $this->add_texts('localization/'); @@ -223,7 +221,7 @@ function settings_actions($args) * * @return array Modified parameters */ - function preferences_sections_list($p) + public function preferences_sections_list($p) { $p['list']['enigma'] = [ 'id' => 'enigma', 'section' => $this->gettext('encryption'), @@ -240,7 +238,7 @@ function preferences_sections_list($p) * * @return array Modified parameters */ - function preferences_list($p) + public function preferences_list($p) { if ($p['section'] != 'encryption') { return $p; @@ -256,9 +254,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_encryption'; $input = new html_checkbox([ - 'name' => '_enigma_encryption', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_encryption', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_encryption'] = [ @@ -275,9 +273,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_signatures'; $input = new html_checkbox([ - 'name' => '_enigma_signatures', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_signatures', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_signatures'] = [ @@ -294,9 +292,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_decryption'; $input = new html_checkbox([ - 'name' => '_enigma_decryption', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_decryption', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_decryption'] = [ @@ -313,9 +311,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_sign_all'; $input = new html_checkbox([ - 'name' => '_enigma_sign_all', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_sign_all', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_sign_all'] = [ @@ -332,9 +330,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_encrypt_all'; $input = new html_checkbox([ - 'name' => '_enigma_encrypt_all', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_encrypt_all', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_encrypt_all'] = [ @@ -351,9 +349,9 @@ function preferences_list($p) $field_id = 'rcmfd_enigma_attach_pubkey'; $input = new html_checkbox([ - 'name' => '_enigma_attach_pubkey', - 'id' => $field_id, - 'value' => 1, + 'name' => '_enigma_attach_pubkey', + 'id' => $field_id, + 'value' => 1, ]); $p['blocks']['main']['options']['enigma_attach_pubkey'] = [ @@ -394,7 +392,7 @@ function preferences_list($p) * * @return array Modified parameters */ - function preferences_save($p) + public function preferences_save($p) { if ($p['section'] == 'encryption') { $p['prefs']['enigma_signatures'] = (bool) rcube_utils::get_input_value('_enigma_signatures', rcube_utils::INPUT_POST); @@ -412,7 +410,7 @@ function preferences_save($p) /** * Handler for keys/certs management UI template. */ - function preferences_ui() + public function preferences_ui() { $this->load_ui(); @@ -429,7 +427,7 @@ function preferences_ui() * * @return array Modified parameters */ - function identity_form($p) + public function identity_form($p) { if (isset($p['form']['encryption']) && !empty($p['record']['identity_id'])) { $content = ''; @@ -457,8 +455,7 @@ function identity_form($p) if (count($listing)) { $content .= html::p(null, $this->gettext(['name' => 'identitymatchingprivkeys', 'vars' => ['nr' => count($listing)]])); $content .= html::tag('ul', 'keylist', implode("\n", $listing)); - } - else { + } else { $content .= html::p(null, $this->gettext('identitynoprivkeys')); } } @@ -490,7 +487,7 @@ function identity_form($p) * * @return array Modified parameters */ - function status_message($p) + public function status_message($p) { $this->load_ui(); @@ -501,7 +498,7 @@ function status_message($p) * Handler for message_load hook. * Check message bodies and attachments for keys/certs. */ - function message_load($p) + public function message_load($p) { $this->load_ui(); @@ -513,7 +510,7 @@ function message_load($p) * This callback function adds a box below the message content * if there is a key/cert attachment available */ - function message_output($p) + public function message_output($p) { $this->load_ui(); @@ -523,7 +520,7 @@ function message_output($p) /** * Handler for attached keys/certs import */ - function import_file() + public function import_file() { $this->load_ui(); @@ -533,7 +530,7 @@ function import_file() /** * Handle password submissions */ - function password_handler() + public function password_handler() { $this->load_engine(); @@ -543,7 +540,7 @@ function password_handler() /** * Handle message_ready hook (encryption/signing) */ - function message_ready($p) + public function message_ready($p) { $this->load_ui(); @@ -553,7 +550,7 @@ function message_ready($p) /** * Handle message_compose_body hook */ - function message_compose($p) + public function message_compose($p) { $this->load_ui(); @@ -563,7 +560,7 @@ function message_compose($p) /** * Handler for refresh hook. */ - function refresh($p) + public function refresh($p) { // calling enigma_engine constructor to remove passwords // stored in session after expiration time @@ -575,7 +572,7 @@ function refresh($p) /** * Handle delete_user_commit hook */ - function user_delete($p) + public function user_delete($p) { $this->load_engine(); diff --git a/plugins/enigma/lib/enigma_driver.php b/plugins/enigma/lib/enigma_driver.php index 1970447f73..187c9a88d4 100644 --- a/plugins/enigma/lib/enigma_driver.php +++ b/plugins/enigma/lib/enigma_driver.php @@ -16,22 +16,22 @@ abstract class enigma_driver { - const SUPPORT_RSA = 'RSA'; - const SUPPORT_ECC = 'ECC'; + public const SUPPORT_RSA = 'RSA'; + public const SUPPORT_ECC = 'ECC'; /** * Class constructor. * * @param string $user User name (email address) */ - abstract function __construct($user); + abstract public function __construct($user); /** * Driver initialization. * * @return mixed NULL on success, enigma_error on failure */ - abstract function init(); + abstract public function init(); /** * Encryption (and optional signing). @@ -42,7 +42,7 @@ abstract function init(); * * @return mixed Encrypted message or enigma_error on failure */ - abstract function encrypt($text, $keys, $sign_key = null); + abstract public function encrypt($text, $keys, $sign_key = null); /** * Decryption (and sig verification if sig exists). @@ -53,7 +53,7 @@ abstract function encrypt($text, $keys, $sign_key = null); * * @return mixed Decrypted message or enigma_error on failure */ - abstract function decrypt($text, $keys = [], &$signature = null); + abstract public function decrypt($text, $keys = [], &$signature = null); /** * Signing. @@ -64,7 +64,7 @@ abstract function decrypt($text, $keys = [], &$signature = null); * * @return mixed True on success or enigma_error on failure */ - abstract function sign($text, $key, $mode = null); + abstract public function sign($text, $key, $mode = null); /** * Signature verification. @@ -74,7 +74,7 @@ abstract function sign($text, $key, $mode = null); * * @return mixed Signature information (enigma_signature) or enigma_error */ - abstract function verify($text, $signature); + abstract public function verify($text, $signature); /** * Key/Cert file import. @@ -85,7 +85,7 @@ abstract function verify($text, $signature); * * @return mixed Import status array or enigma_error */ - abstract function import($content, $isfile = false, $passwords = []); + abstract public function import($content, $isfile = false, $passwords = []); /** * Key/Cert export. @@ -96,7 +96,7 @@ abstract function import($content, $isfile = false, $passwords = []); * * @return mixed Key content or enigma_error */ - abstract function export($key, $with_private = false, $passwords = []); + abstract public function export($key, $with_private = false, $passwords = []); /** * Keys listing. @@ -105,7 +105,7 @@ abstract function export($key, $with_private = false, $passwords = []); * * @return mixed Array of enigma_key objects or enigma_error */ - abstract function list_keys($pattern = ''); + abstract public function list_keys($pattern = ''); /** * Single key information. @@ -114,7 +114,7 @@ abstract function list_keys($pattern = ''); * * @return mixed Key (enigma_key) object or enigma_error */ - abstract function get_key($keyid); + abstract public function get_key($keyid); /** * Key pair generation. @@ -123,7 +123,7 @@ abstract function get_key($keyid); * * @return mixed Key (enigma_key) object or enigma_error */ - abstract function gen_key($data); + abstract public function gen_key($data); /** * Key deletion. @@ -132,7 +132,7 @@ abstract function gen_key($data); * * @return mixed True on success or enigma_error */ - abstract function delete_key($keyid); + abstract public function delete_key($keyid); /** * Returns a name of the hash algorithm used for the last @@ -140,7 +140,7 @@ abstract function delete_key($keyid); * * @return string Hash algorithm name e.g. sha1 */ - abstract function signature_algorithm(); + abstract public function signature_algorithm(); /** * Returns a list of supported features. diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php index 8ec7a49d03..57d41239df 100644 --- a/plugins/enigma/lib/enigma_driver_gnupg.php +++ b/plugins/enigma/lib/enigma_driver_gnupg.php @@ -32,7 +32,7 @@ class enigma_driver_gnupg extends enigma_driver * * @param rcube_user $user User object */ - function __construct($user) + public function __construct($user) { $this->rc = rcmail::get_instance(); $this->user = $user; @@ -44,7 +44,7 @@ function __construct($user) * * @return enigma_error|null NULL on success, enigma_error on failure */ - function init() + public function init() { $homedir = $this->rc->config->get('enigma_pgp_homedir'); $debug = $this->rc->config->get('enigma_debug'); @@ -107,8 +107,7 @@ function init() // Create Crypt_GPG object try { $this->gpg = new Crypt_GPG($options); - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } @@ -124,7 +123,7 @@ function init() * * @return string|enigma_error Encrypted message or enigma_error on failure */ - function encrypt($text, $keys, $sign_key = null) + public function encrypt($text, $keys, $sign_key = null) { try { foreach ($keys as $key) { @@ -143,8 +142,7 @@ function encrypt($text, $keys, $sign_key = null) } return $this->gpg->encrypt($text, true); - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -158,7 +156,7 @@ function encrypt($text, $keys, $sign_key = null) * * @return mixed Decrypted message or enigma_error on failure */ - function decrypt($text, $keys = [], &$signature = null) + public function decrypt($text, $keys = [], &$signature = null) { try { foreach ($keys as $key => $password) { @@ -182,8 +180,7 @@ function decrypt($text, $keys = [], &$signature = null) } return $result['data']; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -197,7 +194,7 @@ function decrypt($text, $keys = [], &$signature = null) * * @return mixed True on success or enigma_error on failure */ - function sign($text, $key, $mode = null) + public function sign($text, $key, $mode = null) { try { $this->gpg->addSignKey($key->reference, $key->password); @@ -208,8 +205,7 @@ function sign($text, $key, $mode = null) $this->last_sig_algorithm = $sigInfo->getHashAlgorithmName(); return $res; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -222,13 +218,12 @@ function sign($text, $key, $mode = null) * * @return enigma_signature|enigma_error Signature information or enigma_error */ - function verify($text, $signature) + public function verify($text, $signature) { try { $verified = $this->gpg->verify($text, $signature); return $this->parse_signature($verified[0]); - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -252,16 +247,14 @@ public function import($content, $isfile = false, $passwords = []) if ($isfile) { $result = $this->gpg->importKeyFile($content); - } - else { + } else { $result = $this->gpg->importKey($content); } $this->db_save(); return $result; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -291,8 +284,7 @@ public function export($keyid, $with_private = false, $passwords = []) } return $key; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -315,8 +307,7 @@ public function list_keys($pattern = '') } return $result; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -352,9 +343,9 @@ public function gen_key($data) try { $debug = $this->rc->config->get('enigma_debug'); $keygen = new Crypt_GPG_KeyGenerator([ - 'homedir' => $this->homedir, - // 'binary' => '/usr/bin/gpg2', - 'debug' => $debug ? [$this, 'debug'] : false, + 'homedir' => $this->homedir, + // 'binary' => '/usr/bin/gpg2', + 'debug' => $debug ? [$this, 'debug'] : false, ]); $key = $keygen @@ -363,8 +354,7 @@ public function gen_key($data) ->generateKey($data['user'], $data['email']); return $this->parse_key($key); - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -440,8 +430,7 @@ protected function delete_privkey($keyid) try { $this->gpg->deletePrivateKey($keyid); return true; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -454,8 +443,7 @@ protected function delete_pubkey($keyid) try { $this->gpg->deletePublicKey($keyid); return true; - } - catch (Exception $e) { + } catch (Exception $e) { return $this->get_error_from_exception($e); } } @@ -474,19 +462,15 @@ protected function get_error_from_exception($e) if ($e instanceof Crypt_GPG_KeyNotFoundException) { $error = enigma_error::KEYNOTFOUND; $data['id'] = $e->getKeyId(); - } - elseif ($e instanceof Crypt_GPG_BadPassphraseException) { + } elseif ($e instanceof Crypt_GPG_BadPassphraseException) { $error = enigma_error::BADPASS; $data['bad'] = $e->getBadPassphrases(); $data['missing'] = $e->getMissingPassphrases(); - } - elseif ($e instanceof Crypt_GPG_NoDataException) { + } elseif ($e instanceof Crypt_GPG_NoDataException) { $error = enigma_error::NODATA; - } - elseif ($e instanceof Crypt_GPG_DeletePrivateKeyException) { + } elseif ($e instanceof Crypt_GPG_DeletePrivateKeyException) { $error = enigma_error::DELKEY; - } - else { + } else { $error = enigma_error::INTERNAL; } @@ -562,8 +546,7 @@ protected function parse_key($key) if (method_exists($subkey, 'getCreationDateTime')) { $skey->created = $subkey->getCreationDateTime(); $skey->expires = $subkey->getExpirationDateTime(); - } - else { + } else { $skey->created = $subkey->getCreationDate(); $skey->expires = $subkey->getExpirationDate(); @@ -617,9 +600,9 @@ protected function db_sync() if ($data === null || $data === false) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to sync $file ({$record['file_id']}). Decode error.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to sync $file ({$record['file_id']}). Decode error.", + ], true, false); continue; } @@ -640,15 +623,14 @@ protected function db_sync() if ($this->debug) { $this->debug("SYNC: Fetched file: $file"); } - } - else { + } else { // error @unlink($tmpfile); rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to sync $file.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to sync $file.", + ], true, false); } } } @@ -714,9 +696,9 @@ protected function db_save($is_empty = false) if ($datasize > $maxsize) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to save $file. Size exceeds max_allowed_packet.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to save $file. Size exceeds max_allowed_packet.", + ], true, false); continue; } @@ -726,9 +708,9 @@ protected function db_save($is_empty = false) if ($db->is_error($result)) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to save $file into database.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to save $file into database.", + ], true, false); break; } @@ -748,9 +730,9 @@ protected function db_save($is_empty = false) if ($db->is_error($result)) { rcube::raise_error([ - 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, - 'message' => "Enigma: Failed to delete $file from database.", - ], true, false); + 'code' => 605, 'line' => __LINE__, 'file' => __FILE__, + 'message' => "Enigma: Failed to delete $file from database.", + ], true, false); break; } diff --git a/plugins/enigma/lib/enigma_driver_phpssl.php b/plugins/enigma/lib/enigma_driver_phpssl.php index 74952cc1c6..089878b55b 100644 --- a/plugins/enigma/lib/enigma_driver_phpssl.php +++ b/plugins/enigma/lib/enigma_driver_phpssl.php @@ -20,7 +20,7 @@ class enigma_driver_phpssl extends enigma_driver private $homedir; private $user; - function __construct($user) + public function __construct($user) { $rcmail = rcmail::get_instance(); $this->rc = $rcmail; @@ -33,7 +33,7 @@ function __construct($user) * * @return mixed NULL on success, enigma_error on failure */ - function init() + public function init() { $homedir = $this->rc->config->get('enigma_smime_homedir', INSTALL_PATH . '/plugins/enigma/home'); @@ -72,13 +72,13 @@ function init() } - function encrypt($text, $keys, $sign_key = null) {} + public function encrypt($text, $keys, $sign_key = null) {} - function decrypt($text, $keys = [], &$signature = null) {} + public function decrypt($text, $keys = [], &$signature = null) {} - function sign($text, $key, $mode = null) {} + public function sign($text, $key, $mode = null) {} - function verify($struct, $message) + public function verify($struct, $message) { // use common temp dir $msg_file = rcube_utils::temp_filename('enigmsg'); @@ -87,8 +87,7 @@ function verify($struct, $message) $fh = fopen($msg_file, 'w'); if ($struct->mime_id) { $message->get_part_body($struct->mime_id, false, 0, $fh); - } - else { + } else { $this->rc->storage->get_raw_body($message->uid, $fh); } fclose($fh); @@ -107,8 +106,7 @@ function verify($struct, $message) if ($sig === true) { $sig = $this->parse_sig_cert($cert_file, $validity); - } - else { + } else { $errorstr = $this->get_openssl_error(); $sig = new enigma_error(enigma_error::INTERNAL, $errorstr); } diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index be46247e70..64783315b6 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -35,21 +35,21 @@ class enigma_engine public $signatures = []; public $encrypted_parts = []; - const ENCRYPTED_PARTIALLY = 100; + public const ENCRYPTED_PARTIALLY = 100; - const SIGN_MODE_BODY = 1; - const SIGN_MODE_SEPARATE = 2; - const SIGN_MODE_MIME = 4; + public const SIGN_MODE_BODY = 1; + public const SIGN_MODE_SEPARATE = 2; + public const SIGN_MODE_MIME = 4; - const ENCRYPT_MODE_BODY = 1; - const ENCRYPT_MODE_MIME = 2; - const ENCRYPT_MODE_SIGN = 4; + public const ENCRYPT_MODE_BODY = 1; + public const ENCRYPT_MODE_MIME = 2; + public const ENCRYPT_MODE_SIGN = 4; /** * Plugin initialization. */ - function __construct($enigma) + public function __construct($enigma) { $this->rc = rcmail::get_instance(); $this->enigma = $enigma; @@ -65,7 +65,7 @@ function __construct($enigma) /** * PGP driver initialization. */ - function load_pgp_driver() + public function load_pgp_driver() { if ($this->pgp_driver) { return; @@ -79,10 +79,9 @@ function load_pgp_driver() if (!$this->pgp_driver) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Enigma plugin: Unable to load PGP driver: $driver", - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Enigma plugin: Unable to load PGP driver: $driver", + ], true, true); } // Initialise driver @@ -96,7 +95,7 @@ function load_pgp_driver() /** * S/MIME driver initialization. */ - function load_smime_driver() + public function load_smime_driver() { if ($this->smime_driver) { return; @@ -110,10 +109,9 @@ function load_smime_driver() if (!$this->smime_driver) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Enigma plugin: Unable to load S/MIME driver: $driver", - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Enigma plugin: Unable to load S/MIME driver: $driver", + ], true, true); } // Initialise driver @@ -132,7 +130,7 @@ function load_smime_driver() * * @return enigma_error On error returns error object */ - function sign_message(&$message, $mode = null) + public function sign_message(&$message, $mode = null) { $mime = new enigma_mime_message($message, enigma_mime_message::PGP_SIGNED); $from = $mime->getFromAddress(); @@ -169,8 +167,7 @@ function sign_message(&$message, $mode = null) default: if ($mime->isMultipart()) { $pgp_mode = Crypt_GPG::SIGN_MODE_DETACHED; - } - else { + } else { $pgp_mode = Crypt_GPG::SIGN_MODE_CLEAR; } } @@ -192,8 +189,7 @@ function sign_message(&$message, $mode = null) $text_charset = str_replace(";\r\n format=flowed", '', $text_charset); } - } - else { + } else { // here we'll build PGP/MIME message $body = $mime->getOrigBody(); } @@ -217,8 +213,7 @@ function sign_message(&$message, $mode = null) if (!empty($text_charset)) { $message->setParam('text_charset', $text_charset); } - } - else { + } else { $mime->addPGPSignature($body, $this->pgp_driver->signature_algorithm()); $message = $mime; } @@ -233,7 +228,7 @@ function sign_message(&$message, $mode = null) * * @return enigma_error On error returns error object */ - function encrypt_message(&$message, $mode = null, $is_draft = false) + public function encrypt_message(&$message, $mode = null, $is_draft = false) { $mime = new enigma_mime_message($message, enigma_mime_message::PGP_ENCRYPTED); @@ -280,8 +275,7 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) foreach ((array) $recipients as $email) { if ($email == $from && $sign_key) { $key = $sign_key; - } - else { + } else { $key = $this->find_key($email); } @@ -295,11 +289,9 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) // select mode if ($mode & self::ENCRYPT_MODE_BODY) { $encrypt_mode = $mode; - } - elseif ($mode & self::ENCRYPT_MODE_MIME) { + } elseif ($mode & self::ENCRYPT_MODE_MIME) { $encrypt_mode = $mode; - } - else { + } else { $encrypt_mode = $mime->isMultipart() ? self::ENCRYPT_MODE_MIME : self::ENCRYPT_MODE_BODY; } @@ -308,8 +300,7 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) // in this mode we'll replace text part // with the one containing encrypted message $body = $message->getTXTBody(); - } - else { + } else { // here we'll build PGP/MIME message $body = $mime->getOrigBody(); } @@ -330,8 +321,7 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) // replace message body if ($encrypt_mode == self::ENCRYPT_MODE_BODY) { $message->setTXTBody($body); - } - else { + } else { $mime->setPGPEncryptedBody($body); $message = $mime; } @@ -344,7 +334,7 @@ function encrypt_message(&$message, $mode = null, $is_draft = false) * * @return bool True on success, False on failure */ - function attach_public_key(&$message) + public function attach_public_key(&$message) { $headers = $message->headers(); $from = rcube_mime::decode_address_list($headers['From'], 1, false, null, true); @@ -373,7 +363,7 @@ function attach_public_key(&$message) * * @return array Modified parameters */ - function part_structure($p, $body = null) + public function part_structure($p, $body = null) { static $got_content = false; @@ -401,20 +391,16 @@ function part_structure($p, $body = null) if ($p['mimetype'] == 'text/plain' || $p['mimetype'] == 'application/pgp') { $this->parse_plain($p, $body); $got_content = true; - } - elseif ($p['mimetype'] == 'multipart/signed') { + } elseif ($p['mimetype'] == 'multipart/signed') { $this->parse_signed($p, $body); $got_content = true; - } - elseif ($p['mimetype'] == 'multipart/encrypted') { + } elseif ($p['mimetype'] == 'multipart/encrypted') { $this->parse_encrypted($p); $got_content = true; - } - elseif ($p['mimetype'] == 'application/pkcs7-mime') { + } elseif ($p['mimetype'] == 'application/pkcs7-mime') { $this->parse_encrypted($p); $got_content = true; - } - else { + } else { $got_content = !empty($p['structure']->type) && $p['structure']->type === 'content'; } @@ -428,7 +414,7 @@ function part_structure($p, $body = null) * * @return array Modified parameters */ - function part_body($p) + public function part_body($p) { // encrypted attachment, see parse_plain_encrypted() if (!empty($p['part']->need_decryption) && $p['part']->body === null) { @@ -455,7 +441,7 @@ function part_body($p) * @param array &$p Reference to hook's parameters * @param string $body Part body (will be set if used internally) */ - function parse_plain(&$p, $body = null) + public function parse_plain(&$p, $body = null) { $part = $p['structure']; @@ -516,11 +502,9 @@ function parse_plain(&$p, $body = null) if ($mode === 'signed') { $body .= $line; - } - elseif ($mode === 'encrypted') { + } elseif ($mode === 'encrypted') { $body .= $line; - } - else { + } else { $prefix .= $line; } } @@ -529,8 +513,7 @@ function parse_plain(&$p, $body = null) if ($mode === 'signed') { $this->parse_plain_signed($p, $body, $prefix); - } - elseif ($mode === 'encrypted') { + } elseif ($mode === 'encrypted') { $this->parse_plain_encrypted($p, $body, $prefix); } } @@ -541,7 +524,7 @@ function parse_plain(&$p, $body = null) * @param array &$p Reference to hook's parameters * @param string $body Part body (will be set if used internally) */ - function parse_signed(&$p, $body = null) + public function parse_signed(&$p, $body = null) { $struct = $p['structure']; @@ -567,7 +550,7 @@ function parse_signed(&$p, $body = null) * * @param array &$p Reference to hook's parameters */ - function parse_encrypted(&$p) + public function parse_encrypted(&$p) { $struct = $p['structure']; @@ -628,11 +611,9 @@ private function parse_plain_signed(&$p, $body, $prefix = '') while (($line = fgets($fd, 1024)) !== false) { if ($part->body === null) { $part->body = ''; - } - elseif (preg_match('/^-----BEGIN PGP SIGNATURE-----/', $line)) { + } elseif (preg_match('/^-----BEGIN PGP SIGNATURE-----/', $line)) { break; - } - else { + } else { $part->body .= $line; } } @@ -756,8 +737,7 @@ private function parse_plain_encrypted(&$p, $body, $prefix = '') $items = explode('.', $part->mime_id); array_pop($items); $parent = implode('.', $items); - } - else { + } else { $parent = 0; } @@ -843,10 +823,10 @@ private function parse_pgp_encrypted(&$p) // Parse the structure (there may be encrypted/signed parts inside $this->part_structure([ - 'object' => $p['object'], - 'structure' => $struct, - 'mimetype' => $struct->mimetype, - ], $body); + 'object' => $p['object'], + 'structure' => $struct, + 'mimetype' => $struct->mimetype, + ], $body); // Attach the decryption message to all parts $this->decryptions[$struct->mime_id] = $result; @@ -856,8 +836,7 @@ private function parse_pgp_encrypted(&$p) $this->signatures[$sp->mime_id] = $signature; } } - } - else { + } else { $this->decryptions[$part->mime_id] = $result; // Make sure decryption status message will be displayed @@ -1011,7 +990,7 @@ private function pgp_encrypt(&$msg_body, $keys, $sign_key = null, $sign_pass = n * * @return mixed Array of keys or enigma_error */ - function list_keys($pattern = '') + public function list_keys($pattern = '') { $this->load_pgp_driver(); $result = $this->pgp_driver->list_keys($pattern); @@ -1031,7 +1010,7 @@ function list_keys($pattern = '') * * @return enigma_key The key */ - function find_key($email, $can_sign = false) + public function find_key($email, $can_sign = false) { if ($can_sign && array_key_exists($email, $this->cache)) { return $this->cache[$email]; @@ -1080,7 +1059,7 @@ function find_key($email, $can_sign = false) * * @return mixed enigma_key or enigma_error */ - function get_key($keyid) + public function get_key($keyid) { $this->load_pgp_driver(); $result = $this->pgp_driver->get_key($keyid); @@ -1099,7 +1078,7 @@ function get_key($keyid) * * @return enigma_error|bool True on success */ - function delete_key($keyid) + public function delete_key($keyid) { $this->load_pgp_driver(); $result = $this->pgp_driver->delete_key($keyid); @@ -1118,7 +1097,7 @@ function delete_key($keyid) * * @return mixed enigma_key or enigma_error */ - function generate_key($data) + public function generate_key($data) { $this->load_pgp_driver(); $result = $this->pgp_driver->gen_key($data); @@ -1138,15 +1117,14 @@ function generate_key($data) * * @return mixed Import status data array or enigma_error */ - function import_key($content, $isfile = false) + public function import_key($content, $isfile = false) { $this->load_pgp_driver(); $result = $this->pgp_driver->import($content, $isfile, $this->get_passwords()); if ($result instanceof enigma_error) { self::raise_error($result, __LINE__); - } - else { + } else { $result['imported'] = $result['public_imported'] + $result['private_imported']; $result['unchanged'] = $result['public_unchanged'] + $result['private_unchanged']; } @@ -1163,7 +1141,7 @@ function import_key($content, $isfile = false) * * @return mixed Key content or enigma_error */ - function export_key($key, $fp = null, $include_private = false) + public function export_key($key, $fp = null, $include_private = false) { $this->load_pgp_driver(); $result = $this->pgp_driver->export($key, $include_private, $this->get_passwords()); @@ -1175,8 +1153,7 @@ function export_key($key, $fp = null, $include_private = false) if ($fp) { fwrite($fp, $result); - } - else { + } else { return $result; } } @@ -1184,7 +1161,7 @@ function export_key($key, $fp = null, $include_private = false) /** * Registers password for specified key/cert sent by the password prompt. */ - function password_handler() + public function password_handler() { $keyid = rcube_utils::get_input_string('_keyid', rcube_utils::INPUT_POST); $passwd = rcube_utils::get_input_string('_passwd', rcube_utils::INPUT_POST, true); @@ -1197,7 +1174,7 @@ function password_handler() /** * Saves key/cert password in user session */ - function save_password($keyid, $password) + public function save_password($keyid, $password) { // we store passwords in session for specified time if (!empty($_SESSION['enigma_pass'])) { @@ -1215,7 +1192,7 @@ function save_password($keyid, $password) /** * Returns currently stored passwords */ - function get_passwords() + public function get_passwords() { if (!empty($_SESSION['enigma_pass'])) { $config = $this->rc->decrypt($_SESSION['enigma_pass']); @@ -1231,8 +1208,7 @@ function get_passwords() if ($threshold && $value[1] < $threshold) { unset($config[$key]); $modified = true; - } - else { + } else { $keys[$key] = $value[0]; } } @@ -1273,8 +1249,7 @@ private function get_part_body($msg, $part) if (!empty($reset)) { $part->size = 0; } - } - else { + } else { $body = $msg->get_part_body($part->mime_id, false); } @@ -1435,8 +1410,7 @@ public static function delete_dir($dir) if (is_dir($filename)) { self::delete_dir($filename); - } - else { + } else { unlink($filename); } } @@ -1465,12 +1439,11 @@ protected static function raise_error($result, $line, $abort = false) { if ($result->getCode() != enigma_error::BADPASS) { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => $line, - 'message' => 'Enigma plugin: ' . $result->getMessage(), - ], true, $abort - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => $line, + 'message' => 'Enigma plugin: ' . $result->getMessage(), + ], true, $abort); } } diff --git a/plugins/enigma/lib/enigma_error.php b/plugins/enigma/lib/enigma_error.php index 0866763192..59a509e1c0 100644 --- a/plugins/enigma/lib/enigma_error.php +++ b/plugins/enigma/lib/enigma_error.php @@ -21,35 +21,35 @@ class enigma_error private $data = []; // error codes - const OK = 0; - const INTERNAL = 1; - const NODATA = 2; - const KEYNOTFOUND = 3; - const DELKEY = 4; - const BADPASS = 5; - const EXPIRED = 6; - const UNVERIFIED = 7; - const NOMDC = 8; - - - function __construct($code = null, $message = '', $data = []) + public const OK = 0; + public const INTERNAL = 1; + public const NODATA = 2; + public const KEYNOTFOUND = 3; + public const DELKEY = 4; + public const BADPASS = 5; + public const EXPIRED = 6; + public const UNVERIFIED = 7; + public const NOMDC = 8; + + + public function __construct($code = null, $message = '', $data = []) { $this->code = $code; $this->message = $message; $this->data = $data; } - function getCode() + public function getCode() { return $this->code; } - function getMessage() + public function getMessage() { return $this->message; } - function getData($name = null) + public function getData($name = null) { if ($name) { return $this->data[$name] ?? null; diff --git a/plugins/enigma/lib/enigma_key.php b/plugins/enigma/lib/enigma_key.php index 69a9347bb8..e3e2c11adb 100644 --- a/plugins/enigma/lib/enigma_key.php +++ b/plugins/enigma/lib/enigma_key.php @@ -23,20 +23,20 @@ class enigma_key public $reference; public $password; - const TYPE_UNKNOWN = 0; - const TYPE_KEYPAIR = 1; - const TYPE_PUBLIC = 2; + public const TYPE_UNKNOWN = 0; + public const TYPE_KEYPAIR = 1; + public const TYPE_PUBLIC = 2; - const CAN_ENCRYPT = 1; - const CAN_SIGN = 2; - const CAN_CERTIFY = 4; - const CAN_AUTHENTICATE = 8; + public const CAN_ENCRYPT = 1; + public const CAN_SIGN = 2; + public const CAN_CERTIFY = 4; + public const CAN_AUTHENTICATE = 8; /** * Keys list sorting callback for usort() */ - static function cmp($a, $b) + public static function cmp($a, $b) { return strcmp($a->name, $b->name); } @@ -46,12 +46,11 @@ static function cmp($a, $b) * * @return int One of self::TYPE_* constant values */ - function get_type() + public function get_type() { if (!empty($this->subkeys[0]) && $this->subkeys[0]->has_private) { return self::TYPE_KEYPAIR; - } - elseif (!empty($this->subkeys[0])) { + } elseif (!empty($this->subkeys[0])) { return self::TYPE_PUBLIC; } @@ -63,7 +62,7 @@ function get_type() * * @return bool */ - function is_revoked() + public function is_revoked() { foreach ($this->subkeys as $subkey) { if (!$subkey->revoked) { @@ -79,7 +78,7 @@ function is_revoked() * * @return bool */ - function is_valid() + public function is_valid() { foreach ($this->users as $user) { if ($user->valid) { @@ -95,7 +94,7 @@ function is_valid() * * @return bool */ - function is_private() + public function is_private() { foreach ($this->subkeys as $subkey) { if ($subkey->has_private) { @@ -114,7 +113,7 @@ function is_private() * * @return enigma_subkey|null Subkey object */ - function find_subkey($email, $mode) + public function find_subkey($email, $mode) { foreach ($this->users as $user) { if (strcasecmp($user->email, $email) === 0 && $user->valid && !$user->revoked) { @@ -137,7 +136,7 @@ function find_subkey($email, $mode) * * @return string Key short ID */ - static function format_id($id) + public static function format_id($id) { // E.g. 04622F2089E037A5 => 89E037A5 @@ -151,7 +150,7 @@ static function format_id($id) * * @return string Formatted fingerprint (with spaces) */ - static function format_fingerprint($fingerprint) + public static function format_fingerprint($fingerprint) { if (!$fingerprint) { return ''; diff --git a/plugins/enigma/lib/enigma_mime_message.php b/plugins/enigma/lib/enigma_mime_message.php index 3183048f80..3f2a3853fa 100644 --- a/plugins/enigma/lib/enigma_mime_message.php +++ b/plugins/enigma/lib/enigma_mime_message.php @@ -16,8 +16,8 @@ class enigma_mime_message extends Mail_mime { - const PGP_SIGNED = 1; - const PGP_ENCRYPTED = 2; + public const PGP_SIGNED = 1; + public const PGP_ENCRYPTED = 2; protected $type; protected $message; @@ -33,7 +33,7 @@ class enigma_mime_message extends Mail_mime * @param Mail_mime $message Original message * @param int $type Output message type */ - function __construct($message, $type) + public function __construct($message, $type) { $this->message = $message; $this->type = $type; @@ -204,14 +204,13 @@ public function get($params = null, $filename = null, $skip_head = false) if (!empty($this->signature)) { $message->addSubpart($this->signature, [ - 'filename' => 'signature.asc', - 'content_type' => 'application/pgp-signature', - 'disposition' => 'attachment', - 'description' => 'OpenPGP digital signature', + 'filename' => 'signature.asc', + 'content_type' => 'application/pgp-signature', + 'disposition' => 'attachment', + 'description' => 'OpenPGP digital signature', ]); } - } - elseif ($this->type == self::PGP_ENCRYPTED) { + } elseif ($this->type == self::PGP_ENCRYPTED) { $params = [ 'preamble' => 'This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)', 'content_type' => 'multipart/encrypted; protocol="application/pgp-encrypted"', @@ -221,23 +220,22 @@ public function get($params = null, $filename = null, $skip_head = false) $message = new Mail_mimePart('', $params); $message->addSubpart('Version: 1', [ - 'content_type' => 'application/pgp-encrypted', - 'description' => 'PGP/MIME version identification', + 'content_type' => 'application/pgp-encrypted', + 'description' => 'PGP/MIME version identification', ]); $message->addSubpart($this->encrypted, [ - 'content_type' => 'application/octet-stream', - 'description' => 'PGP/MIME encrypted message', - 'disposition' => 'inline', - 'filename' => 'encrypted.asc', + 'content_type' => 'application/octet-stream', + 'description' => 'PGP/MIME encrypted message', + 'disposition' => 'inline', + 'filename' => 'encrypted.asc', ]); } // Use saved boundary if (!empty($this->build_params['boundary'])) { $boundary = $this->build_params['boundary']; - } - else { + } else { $boundary = null; } @@ -251,8 +249,7 @@ public function get($params = null, $filename = null, $skip_head = false) } $this->headers = array_merge($this->headers, $headers); - } - else { + } else { $output = $message->encode($boundary, $skip_head); if ($this->isError($output)) { @@ -286,13 +283,11 @@ protected function contentHeaders() // multipart message: and boundary if (!empty($this->build_params['boundary'])) { $boundary = $this->build_params['boundary']; - } - elseif (!empty($this->headers['Content-Type']) + } elseif (!empty($this->headers['Content-Type']) && preg_match('/boundary="([^"]+)"/', $this->headers['Content-Type'], $m) ) { $boundary = $m[1]; - } - else { + } else { $boundary = '=_' . md5(rand() . microtime()); } @@ -306,8 +301,7 @@ protected function contentHeaders() if ($this->micalg) { $headers['Content-Type'] .= ";{$eol} micalg=pgp-" . $this->micalg; } - } - elseif ($this->type == self::PGP_ENCRYPTED) { + } elseif ($this->type == self::PGP_ENCRYPTED) { $headers['Content-Type'] = "multipart/encrypted;$eol" . " protocol=\"application/pgp-encrypted\";$eol" . " boundary=\"$boundary\""; diff --git a/plugins/enigma/lib/enigma_subkey.php b/plugins/enigma/lib/enigma_subkey.php index fdf430f344..6f7f6b7442 100644 --- a/plugins/enigma/lib/enigma_subkey.php +++ b/plugins/enigma/lib/enigma_subkey.php @@ -33,7 +33,7 @@ class enigma_subkey * * @return string Key ID */ - function get_short_id() + public function get_short_id() { // E.g. 04622F2089E037A5 => 89E037A5 return enigma_key::format_id($this->id); @@ -44,7 +44,7 @@ function get_short_id() * * @return string Formatted fingerprint */ - function get_fingerprint() + public function get_fingerprint() { return enigma_key::format_fingerprint($this->fingerprint); } @@ -54,7 +54,7 @@ function get_fingerprint() * * @return string Algorithm name */ - function get_algorithm() + public function get_algorithm() { // http://tools.ietf.org/html/rfc4880#section-9.1 switch ($this->algorithm) { @@ -83,7 +83,7 @@ function get_algorithm() * * @return bool */ - function is_expired() + public function is_expired() { $now = new DateTime('now'); @@ -97,7 +97,7 @@ function is_expired() * * @return string|int|null */ - function get_creation_date($asInt = false) + public function get_creation_date($asInt = false) { if (empty($this->created)) { return $asInt ? 0 : null; @@ -117,7 +117,7 @@ function get_creation_date($asInt = false) * * @return string|null */ - function get_expiration_date() + public function get_expiration_date() { if (empty($this->expires)) { return null; diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php index 872a36a795..bc425534a7 100644 --- a/plugins/enigma/lib/enigma_ui.php +++ b/plugins/enigma/lib/enigma_ui.php @@ -31,7 +31,7 @@ class enigma_ui * @param enigma $enigma_plugin The plugin instance * @param string $home Home directory */ - function __construct($enigma_plugin, $home = '') + public function __construct($enigma_plugin, $home = '') { $this->enigma = $enigma_plugin; $this->rc = $enigma_plugin->rc; @@ -41,7 +41,7 @@ function __construct($enigma_plugin, $home = '') /** * UI initialization and requests handlers. */ - function init() + public function init() { $this->add_js(); @@ -88,9 +88,9 @@ function init() } $this->rc->output->add_handlers([ - 'keyslist' => [$this, 'tpl_keys_list'], - 'countdisplay' => [$this, 'tpl_keys_rowcount'], - 'searchform' => [$this->rc->output, 'search_form'], + 'keyslist' => [$this, 'tpl_keys_list'], + 'countdisplay' => [$this, 'tpl_keys_rowcount'], + 'searchform' => [$this->rc->output, 'search_form'], ]); $this->rc->output->set_pagetitle($this->enigma->gettext('enigmakeys')); @@ -119,7 +119,7 @@ function init() /** * Adds CSS style file to the page header. */ - function add_css() + public function add_css() { if ($this->css_loaded) { return; @@ -133,7 +133,7 @@ function add_css() /** * Adds javascript file to the page header. */ - function add_js() + public function add_js() { if ($this->js_loaded) { return; @@ -152,7 +152,7 @@ function add_js() * @param enigma_error $status Error object with key info * @param array $params Optional prompt parameters */ - function password_prompt($status, $params = []) + public function password_prompt($status, $params = []) { $data = array_merge($status->getData('missing') ?: [], $status->getData('bad') ?: []); @@ -180,8 +180,7 @@ function password_prompt($status, $params = []) if (preg_match('/^(send|plugin.enigmaimport|plugin.enigmakeys)$/', $this->rc->action)) { $this->rc->output->command('enigma_password_request', $data); - } - else { + } else { $this->rc->output->set_env('enigma_password_request', $data); } @@ -200,7 +199,7 @@ function password_prompt($status, $params = []) * * @return string HTML content */ - function tpl_keys_list($attrib) + public function tpl_keys_list($attrib) { // add id to message list table if not specified if (empty($attrib['id'])) { @@ -245,11 +244,9 @@ private function key_list() if (!is_array($list)) { $this->rc->output->show_message('enigma.keylisterror', 'error'); - } - elseif (empty($list)) { + } elseif (empty($list)) { $this->rc->output->show_message('enigma.nokeysfound', 'notice'); - } - else { + } else { // Save the size $listsize = count($list); @@ -263,9 +260,9 @@ private function key_list() // Add rows foreach ($list as $key) { $this->rc->output->command('enigma_add_list_row', [ - 'name' => rcube::Q($key->name), - 'id' => $key->id, - 'flags' => $key->is_private() ? 'p' : '', + 'name' => rcube::Q($key->name), + 'id' => $key->id, + 'flags' => $key->is_private() ? 'p' : '', ]); } } @@ -286,7 +283,7 @@ private function key_list() * * @return string HTML output */ - function tpl_keys_rowcount($attrib) + public function tpl_keys_rowcount($attrib) { if (empty($attrib['id'])) { $attrib['id'] = 'rcmcountdisplay'; @@ -304,14 +301,13 @@ private function get_rowcount_text($all = 0, $curr_count = 0, $page = 1) { if (!$curr_count) { $out = $this->enigma->gettext('nokeysfound'); - } - else { + } else { $pagesize = $this->rc->config->get('pagesize', 100); $first = ($page - 1) * $pagesize; $out = $this->enigma->gettext([ - 'name' => 'keysfromto', - 'vars' => ['from' => $first + 1, 'to' => $first + $curr_count, 'count' => $all], + 'name' => 'keysfromto', + 'vars' => ['from' => $first + 1, 'to' => $first + $curr_count, 'count' => $all], ]); } @@ -330,8 +326,7 @@ private function key_info() if ($res instanceof enigma_key) { $this->data = $res; - } - else { // error + } else { // error $this->rc->output->show_message('enigma.keyopenerror', 'error'); $this->rc->output->command('parent.enigma_loadframe'); $this->rc->output->send('iframe'); @@ -353,7 +348,7 @@ private function key_info() * * @return string HTML output */ - function tpl_key_name($attrib) + public function tpl_key_name($attrib) { return rcube::Q($this->data->name); } @@ -365,7 +360,7 @@ function tpl_key_name($attrib) * * @return string HTML output */ - function tpl_key_data($attrib) + public function tpl_key_data($attrib) { $out = ''; $table = new html_table(['cols' => 2]); @@ -383,8 +378,7 @@ function tpl_key_data($attrib) $type = null; if ($keytype == enigma_key::TYPE_KEYPAIR) { $type = $this->enigma->gettext('typekeypair'); - } - elseif ($keytype == enigma_key::TYPE_PUBLIC) { + } elseif ($keytype == enigma_key::TYPE_PUBLIC) { $type = $this->enigma->gettext('typepublickey'); } @@ -496,14 +490,14 @@ private function key_export() if ($code == enigma_error::BADPASS) { $this->password_prompt($status, [ - 'input_keys' => $keys, - 'input_priv' => 1, - 'input_task' => 'settings', - 'input_action' => 'plugin.enigmakeys', - 'input_a' => 'export', - 'action' => '?', - 'iframe' => true, - 'nolock' => true, + 'input_keys' => $keys, + 'input_priv' => 1, + 'input_task' => 'settings', + 'input_action' => 'plugin.enigmakeys', + 'input_a' => 'export', + 'action' => '?', + 'iframe' => true, + 'nolock' => true, ]); fclose($fp); $this->rc->output->send('iframe'); @@ -541,8 +535,7 @@ private function key_import() if (rcube_utils::get_input_value('_generated', rcube_utils::INPUT_POST)) { $this->rc->output->command('enigma_key_create_success'); $this->rc->output->show_message('enigma.keygeneratesuccess', 'confirmation'); - } - else { + } else { $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation', ['new' => $result['imported'], 'old' => $result['unchanged']]); @@ -550,14 +543,12 @@ private function key_import() $this->rc->output->command('enigma_list', 1, false); } } - } - else { + } else { $this->rc->output->show_message('enigma.keysimportfailed', 'error'); } $this->rc->output->send(); - } - elseif (!empty($_FILES['_file']['tmp_name']) && is_uploaded_file($_FILES['_file']['tmp_name'])) { + } elseif (!empty($_FILES['_file']['tmp_name']) && is_uploaded_file($_FILES['_file']['tmp_name'])) { $this->enigma->load_engine(); $result = $this->enigma->engine->import_key($_FILES['_file']['tmp_name'], true); @@ -571,22 +562,19 @@ private function key_import() ['new' => $result['imported'], 'old' => $result['unchanged']]); $this->rc->output->command('parent.enigma_import_success'); - } - elseif ($result instanceof enigma_error && $result->getCode() == enigma_error::BADPASS) { + } elseif ($result instanceof enigma_error && $result->getCode() == enigma_error::BADPASS) { $this->password_prompt($result); - } - else { + } else { $this->rc->output->show_message('enigma.keysimportfailed', 'error'); } $this->rc->output->send('iframe'); - } - elseif (!empty($_FILES['_file']['error'])) { + } elseif (!empty($_FILES['_file']['error'])) { rcmail_action::upload_error($_FILES['_file']['error']); $this->rc->output->send('iframe'); } $this->rc->output->add_handlers([ - 'importform' => [$this, 'tpl_key_import_form'], + 'importform' => [$this, 'tpl_key_import_form'], ]); $this->rc->output->send('enigma.keyimport'); @@ -598,7 +586,7 @@ private function key_import() private function key_import_search() { $this->rc->output->add_handlers([ - 'importform' => [$this, 'tpl_key_import_form'], + 'importform' => [$this, 'tpl_key_import_form'], ]); $this->rc->output->send('enigma.keysearch'); @@ -611,24 +599,24 @@ private function key_import_search() * * @return string HTML output */ - function tpl_key_import_form($attrib) + public function tpl_key_import_form($attrib) { $attrib += ['id' => 'rcmKeyImportForm']; if (empty($attrib['part']) || $attrib['part'] == 'import') { $title = $this->enigma->gettext('keyimportlabel'); $upload = new html_inputfield([ - 'type' => 'file', - 'name' => '_file', - 'id' => 'rcmimportfile', - 'size' => 30, - 'class' => 'form-control', + 'type' => 'file', + 'name' => '_file', + 'id' => 'rcmimportfile', + 'size' => 30, + 'class' => 'form-control', ]); $max_filesize = rcmail_action::upload_init(); $upload_button = new html_button([ - 'class' => 'button import', - 'onclick' => "return rcmail.command('plugin.enigma-import','',this,event)", + 'class' => 'button import', + 'onclick' => "return rcmail.command('plugin.enigma-import','',this,event)", ]); $form = html::div(null, html::p(null, rcube::Q($this->enigma->gettext('keyimporttext'), 'show')) @@ -639,8 +627,7 @@ function tpl_key_import_form($attrib) if (empty($attrib['part'])) { $form = html::tag('fieldset', '', html::tag('legend', null, $title) . $form); - } - else { + } else { $this->rc->output->set_pagetitle($title); } @@ -656,8 +643,8 @@ function tpl_key_import_form($attrib) 'id' => 'rcmimportsearch', 'size' => 30, 'class' => 'form-control']); $search_button = new html_button([ - 'class' => 'button search', - 'onclick' => "return rcmail.command('plugin.enigma-import-search','',this,event)", + 'class' => 'button search', + 'onclick' => "return rcmail.command('plugin.enigma-import-search','',this,event)", ]); $form = html::div(null, @@ -668,8 +655,7 @@ function tpl_key_import_form($attrib) if (empty($attrib['part'])) { $form = html::tag('fieldset', '', html::tag('legend', null, $title) . $form); - } - else { + } else { $this->rc->output->set_pagetitle($title); } @@ -677,8 +663,8 @@ function tpl_key_import_form($attrib) } $this->rc->output->add_label('selectimportfile', 'importwait', 'nopubkeyfor', 'nopubkeyforsender', - 'encryptnoattachments','encryptedsendialog','searchpubkeyservers', 'importpubkeys', - 'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired', + 'encryptnoattachments', 'encryptedsendialog', 'searchpubkeyservers', 'importpubkeys', + 'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired', 'keyrevoked', 'keyimportsuccess', 'keyservererror'); $this->rc->output->add_gui_object('importform', $attrib['id']); @@ -722,17 +708,16 @@ private function key_generate() $this->enigma->load_engine(); $result = $this->enigma->engine->generate_key([ - 'user' => $ident[1]['name'], - 'email' => $ident[1]['mailto'], - 'password' => $pass, - 'size' => $size, + 'user' => $ident[1]['name'], + 'email' => $ident[1]['mailto'], + 'password' => $pass, + 'size' => $size, ]); if ($result instanceof enigma_key) { $this->rc->output->command('enigma_key_create_success'); $this->rc->output->show_message('enigma.keygeneratesuccess', 'confirmation'); - } - else { + } else { $this->rc->output->show_message('enigma.keygenerateerror', 'error'); } @@ -761,7 +746,7 @@ private function key_create() * * @return string HTML output */ - function tpl_key_create_form($attrib) + public function tpl_key_create_form($attrib) { $attrib += ['id' => 'rcmKeyCreateForm']; $table = new html_table(['cols' => 2]); @@ -900,10 +885,10 @@ private function compose_ui_options($wrap = false) ) . html::div('form-check col-6', $chbox->show($this->rc->config->get('enigma_sign_all') ? 1 : 0, [ - 'name' => '_enigma_sign', - 'id' => 'enigmasignopt', - 'class' => 'form-check-input', - 'disabled' => in_array('sign', $locks), + 'name' => '_enigma_sign', + 'id' => 'enigmasignopt', + 'class' => 'form-check-input', + 'disabled' => in_array('sign', $locks), ]) ) ); @@ -914,10 +899,10 @@ private function compose_ui_options($wrap = false) ) . html::div('form-check col-6', $chbox->show($this->rc->config->get('enigma_encrypt_all') ? 1 : 0, [ - 'name' => '_enigma_encrypt', - 'id' => 'enigmaencryptopt', - 'class' => 'form-check-input', - 'disabled' => in_array('encrypt', $locks), + 'name' => '_enigma_encrypt', + 'id' => 'enigmaencryptopt', + 'class' => 'form-check-input', + 'disabled' => in_array('encrypt', $locks), ]) ) ); @@ -928,10 +913,10 @@ private function compose_ui_options($wrap = false) ) . html::div('form-check col-6', $chbox->show($this->rc->config->get('enigma_attach_pubkey') ? 1 : 0, [ - 'name' => '_enigma_attachpubkey', - 'id' => 'enigmaattachpubkeyopt', - 'class' => 'form-check-input', - 'disabled' => in_array('pubkey', $locks), + 'name' => '_enigma_attachpubkey', + 'id' => 'enigmaattachpubkeyopt', + 'class' => 'form-check-input', + 'disabled' => in_array('pubkey', $locks), ]) ) ); @@ -953,7 +938,7 @@ private function compose_ui_options($wrap = false) * * @return array Modified parameters */ - function status_message($p) + public function status_message($p) { // skip: not a message part if ($p['part'] instanceof rcube_message) { @@ -989,25 +974,20 @@ function status_message($p) if ($code == enigma_error::KEYNOTFOUND) { $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), $this->enigma->gettext('decryptnokey'))); - } - elseif ($code == enigma_error::BADPASS) { + } elseif ($code == enigma_error::BADPASS) { $missing = $status->getData('missing'); $label = 'decrypt' . (!empty($missing) ? 'no' : 'bad') . 'pass'; $msg = rcube::Q($this->enigma->gettext($label)); $this->password_prompt($status); - } - elseif ($code == enigma_error::NOMDC) { + } elseif ($code == enigma_error::NOMDC) { $msg = rcube::Q($this->enigma->gettext('decryptnomdc')); - } - else { + } else { $msg = rcube::Q($this->enigma->gettext('decrypterror')); } - } - elseif ($status === enigma_engine::ENCRYPTED_PARTIALLY) { + } elseif ($status === enigma_engine::ENCRYPTED_PARTIALLY) { $attrib['class'] = 'boxwarning enigmawarning encrypted'; $msg = rcube::Q($this->enigma->gettext('decryptpartial')); - } - else { + } else { $attrib['class'] = 'boxconfirmation enigmanotice encrypted'; $msg = rcube::Q($this->enigma->gettext('decryptok')); } @@ -1037,29 +1017,24 @@ function status_message($p) $msg = str_replace('$sender', $sender, $this->enigma->gettext('sigunverified')); $msg = str_replace('$keyid', $sig->id, $msg); $msg = rcube::Q($msg); - } - elseif ($sig->valid) { + } elseif ($sig->valid) { $attrib['class'] = ($sig->partial ? 'boxwarning enigmawarning' : 'boxconfirmation enigmanotice') . ' signed'; $label = 'sigvalid' . ($sig->partial ? 'partial' : ''); $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext($label))); - } - else { + } else { $attrib['class'] = 'boxwarning enigmawarning signed'; if ($sender) { $msg = rcube::Q(str_replace('$sender', $sender, $this->enigma->gettext('siginvalid'))); - } - else { + } else { $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->id), $this->enigma->gettext('signokey'))); } } - } - elseif ($sig && $sig->getCode() == enigma_error::KEYNOTFOUND) { + } elseif ($sig && $sig->getCode() == enigma_error::KEYNOTFOUND) { $attrib['class'] = 'boxwarning enigmawarning signed'; $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')), $this->enigma->gettext('signokey'))); - } - else { + } else { $attrib['class'] = 'boxwarning enigmaerror signed'; $msg = rcube::Q($this->enigma->gettext('sigerror')); } @@ -1071,8 +1046,7 @@ function status_message($p) if ($count = count($messages)) { if ($count == 2 && $messages[0]['class'] == $messages[1]['class']) { $p['prefix'] .= html::div($messages[0], $messages[0]['msg'] . ' ' . $messages[1]['msg']); - } - else { + } else { foreach ($messages as $msg) { $p['prefix'] .= html::div($msg, $msg['msg']); } @@ -1092,7 +1066,7 @@ function status_message($p) * Handler for message_load hook. * Check message bodies and attachments for keys/certs. */ - function message_load($p) + public function message_load($p) { $engine = $this->enigma->load_engine(); @@ -1125,7 +1099,7 @@ function message_load($p) * This callback function adds a box below the message content * if there is a key/cert attachment available */ - function message_output($p) + public function message_output($p) { foreach ($this->keys_parts as $part) { // remove part's body @@ -1159,7 +1133,7 @@ function message_output($p) /** * Handle message_ready hook (encryption/signing/attach public key) */ - function message_ready($p) + public function message_ready($p) { // The message might have been already encrypted by Mailvelope if (strpos((string) $p['message']->getParam('ctype'), 'multipart/encrypted') === 0) { @@ -1195,8 +1169,7 @@ function message_ready($p) $mode = !$savedraft && $sign_enable ? enigma_engine::ENCRYPT_MODE_SIGN : null; $status = $engine->encrypt_message($p['message'], $mode, $savedraft); $mode = 'encrypt'; - } - elseif (!$savedraft && $sign_enable) { + } elseif (!$savedraft && $sign_enable) { $engine = $this->enigma->load_engine(); $status = $engine->sign_message($p['message'], enigma_engine::SIGN_MODE_MIME); $mode = 'sign'; @@ -1210,29 +1183,25 @@ function message_ready($p) if ($email = $status->getData('missing')) { $vars = ['email' => $email]; $msg = 'enigma.' . $mode . 'nokey'; - } - else { + } else { $msg = 'enigma.' . ($encrypt_enable ? 'encryptnoprivkey' : 'signnokey'); } - } - elseif ($code == enigma_error::BADPASS) { + } elseif ($code == enigma_error::BADPASS) { $this->password_prompt($status); - } - else { + } else { $msg = 'enigma.' . $mode . 'error'; } if (!empty($msg)) { if (!empty($vars) && !empty($vars['email'])) { $this->rc->output->command('enigma_key_not_found', [ - 'email' => $vars['email'], - 'text' => $this->rc->gettext(['name' => $msg, 'vars' => $vars]), - 'title' => $this->enigma->gettext('keynotfound'), - 'button' => $this->enigma->gettext('findkey'), - 'mode' => $mode, + 'email' => $vars['email'], + 'text' => $this->rc->gettext(['name' => $msg, 'vars' => $vars]), + 'title' => $this->enigma->gettext('keynotfound'), + 'button' => $this->enigma->gettext('findkey'), + 'mode' => $mode, ]); - } - else { + } else { $this->rc->output->show_message($msg, 'error', $vars); } } @@ -1248,7 +1217,7 @@ function message_ready($p) * Display error when the message cannot be encrypted * and provide a way to try again with a password. */ - function message_compose($p) + public function message_compose($p) { $engine = $this->enigma->load_engine(); @@ -1273,8 +1242,7 @@ function message_compose($p) if ($code == enigma_error::KEYNOTFOUND) { $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')), $this->enigma->gettext('decryptnokey'))); - } - else { + } else { $msg = rcube::Q($this->enigma->gettext('decrypterror')); } } @@ -1298,7 +1266,7 @@ function message_compose($p) /** * Handler for keys/certs import request action */ - function import_file() + public function import_file() { $uid = rcube_utils::get_input_string('_uid', rcube_utils::INPUT_POST); $mbox = rcube_utils::get_input_string('_mbox', rcube_utils::INPUT_POST); @@ -1315,13 +1283,13 @@ function import_file() if ($status instanceof enigma_error) { if ($status->getCode() == enigma_error::BADPASS) { $this->password_prompt($status, [ - 'input_uid' => $uid, - 'input_mbox' => $mbox, - 'input_part' => $mime_id, - 'input_task' => 'mail', - 'input_action' => 'plugin.enigmaimport', - 'action' => '?', - 'iframe' => true, + 'input_uid' => $uid, + 'input_mbox' => $mbox, + 'input_part' => $mime_id, + 'input_task' => 'mail', + 'input_action' => 'plugin.enigmaimport', + 'action' => '?', + 'iframe' => true, ]); $this->rc->output->send($this->rc->output->type == 'html' ? 'iframe' : null); return; @@ -1337,8 +1305,7 @@ function import_file() if (!empty($part) && is_array($result = $engine->import_key($part))) { $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation', ['new' => $result['imported'], 'old' => $result['unchanged']]); - } - else { + } else { $this->rc->output->show_message('enigma.keysimportfailed', 'error'); } diff --git a/plugins/enigma/tests/Enigma.php b/plugins/enigma/tests/Enigma.php index 8923da4445..8831ebd4d6 100644 --- a/plugins/enigma/tests/Enigma.php +++ b/plugins/enigma/tests/Enigma.php @@ -10,7 +10,7 @@ protected function setUp(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new enigma($rcube->plugins); diff --git a/plugins/enigma/tests/EnigmaDriverGnupg.php b/plugins/enigma/tests/EnigmaDriverGnupg.php index 12677553b9..553cce800b 100644 --- a/plugins/enigma/tests/EnigmaDriverGnupg.php +++ b/plugins/enigma/tests/EnigmaDriverGnupg.php @@ -2,7 +2,7 @@ class Enigma_EnigmaDriverGnupg extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_driver.php'; include_once __DIR__ . '/../lib/enigma_driver_gnupg.php'; @@ -11,7 +11,7 @@ static function setUpBeforeClass(): void /** * Test constructor */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new enigma_driver_gnupg($rcube->user); diff --git a/plugins/enigma/tests/EnigmaEngine.php b/plugins/enigma/tests/EnigmaEngine.php index 0e4bf0996d..1a63f41223 100644 --- a/plugins/enigma/tests/EnigmaEngine.php +++ b/plugins/enigma/tests/EnigmaEngine.php @@ -2,7 +2,7 @@ class Enigma_EnigmaEngine extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../enigma.php'; include_once __DIR__ . '/../lib/enigma_engine.php'; @@ -11,7 +11,7 @@ static function setUpBeforeClass(): void /** * Test password_handler() */ - function test_password_handler() + public function test_password_handler() { $rcube = rcube::get_instance(); $plugin = new enigma($rcube->plugins); diff --git a/plugins/enigma/tests/EnigmaError.php b/plugins/enigma/tests/EnigmaError.php index f3ce16a011..8d4f893916 100644 --- a/plugins/enigma/tests/EnigmaError.php +++ b/plugins/enigma/tests/EnigmaError.php @@ -2,7 +2,7 @@ class Enigma_EnigmaError extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_error.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test constructor */ - function test_constructor() + public function test_constructor() { $error = new enigma_error(enigma_error::EXPIRED, 'message', ['test1' => 'test2']); diff --git a/plugins/enigma/tests/EnigmaKey.php b/plugins/enigma/tests/EnigmaKey.php index 7aa0bb3ba3..9e1cea3060 100644 --- a/plugins/enigma/tests/EnigmaKey.php +++ b/plugins/enigma/tests/EnigmaKey.php @@ -2,7 +2,7 @@ class Enigma_EnigmaKey extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_key.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test "empty" key */ - function test_empty_key() + public function test_empty_key() { $key = new enigma_key(); diff --git a/plugins/enigma/tests/EnigmaMimeMessage.php b/plugins/enigma/tests/EnigmaMimeMessage.php index 644bd0127c..228c71e711 100644 --- a/plugins/enigma/tests/EnigmaMimeMessage.php +++ b/plugins/enigma/tests/EnigmaMimeMessage.php @@ -2,7 +2,7 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_mime_message.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test isMultipart() */ - function test_is_multipart() + public function test_is_multipart() { $mime = new Mail_mime(); $message1 = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED); @@ -30,7 +30,7 @@ function test_is_multipart() /** * Test getFromAddress() */ - function test_get_from_address() + public function test_get_from_address() { $mime = new Mail_mime(); $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED); @@ -46,7 +46,7 @@ function test_get_from_address() /** * Test getRecipients() */ - function test_get_recipients() + public function test_get_recipients() { $mime = new Mail_mime(); $mime->setFrom('test1@domain.com'); @@ -64,7 +64,7 @@ function test_get_recipients() /** * Test getOrigBody() */ - function test_get_orig_body() + public function test_get_orig_body() { $mime = new Mail_mime(); $mime->setTXTBody('test body'); @@ -81,7 +81,7 @@ function test_get_orig_body() /** * Test get() */ - function test_get() + public function test_get() { $mime = new Mail_mime(); $mime->setTXTBody('test body'); diff --git a/plugins/enigma/tests/EnigmaSignature.php b/plugins/enigma/tests/EnigmaSignature.php index 6cdb416bc7..5dccab4cc0 100644 --- a/plugins/enigma/tests/EnigmaSignature.php +++ b/plugins/enigma/tests/EnigmaSignature.php @@ -2,7 +2,7 @@ class Enigma_EnigmaSignature extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_signature.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test constructor */ - function test_constructor() + public function test_constructor() { $error = new enigma_signature(); diff --git a/plugins/enigma/tests/EnigmaSubkey.php b/plugins/enigma/tests/EnigmaSubkey.php index 139368c8be..26b4f7642e 100644 --- a/plugins/enigma/tests/EnigmaSubkey.php +++ b/plugins/enigma/tests/EnigmaSubkey.php @@ -2,7 +2,7 @@ class Enigma_EnigmaSubkey extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_subkey.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test constructor */ - function test_constructor() + public function test_constructor() { $error = new enigma_subkey(); diff --git a/plugins/enigma/tests/EnigmaUserid.php b/plugins/enigma/tests/EnigmaUserid.php index 23eab4f898..4e26cfd413 100644 --- a/plugins/enigma/tests/EnigmaUserid.php +++ b/plugins/enigma/tests/EnigmaUserid.php @@ -2,7 +2,7 @@ class Enigma_EnigmaUserid extends PHPUnit\Framework\TestCase { - static function setUpBeforeClass(): void + public static function setUpBeforeClass(): void { include_once __DIR__ . '/../lib/enigma_userid.php'; } @@ -10,7 +10,7 @@ static function setUpBeforeClass(): void /** * Test constructor */ - function test_constructor() + public function test_constructor() { $error = new enigma_userid(); diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php index d8f0b5b92a..f1ff027315 100644 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ b/plugins/example_addressbook/example_addressbook_backend.php @@ -60,7 +60,7 @@ public function __construct($name) * * @return ?array Group properties as hash array, null in case of error. */ - function get_group($group_id) + public function get_group($group_id) { foreach ($this->db_groups as $group) { if ($group['ID'] == $group_id) { @@ -90,7 +90,7 @@ public function reset() $this->filter = null; } - function list_groups($search = null, $mode = 0) + public function list_groups($search = null, $mode = 0) { if (is_string($search) && strlen($search)) { $result = []; @@ -194,7 +194,7 @@ public function get_record($id, $assoc = false) * * @return array List of assigned groups, indexed by group ID */ - function get_record_groups($id) + public function get_record_groups($id) { $result = []; @@ -214,34 +214,34 @@ function get_record_groups($id) /** * Setter for the current group */ - function set_group($gid) + public function set_group($gid) { $this->group_id = $gid; } - function create_group($name) + public function create_group($name) { $result = false; return $result; } - function delete_group($gid) + public function delete_group($gid) { return false; } - function rename_group($gid, $newname, &$newid) + public function rename_group($gid, $newname, &$newid) { return $newname; } - function add_to_group($group_id, $ids) + public function add_to_group($group_id, $ids) { return false; } - function remove_from_group($group_id, $ids) + public function remove_from_group($group_id, $ids) { return false; } diff --git a/plugins/example_addressbook/tests/ExampleAddressbook.php b/plugins/example_addressbook/tests/ExampleAddressbook.php index c9196cb5c9..ecd1a5d7e1 100644 --- a/plugins/example_addressbook/tests/ExampleAddressbook.php +++ b/plugins/example_addressbook/tests/ExampleAddressbook.php @@ -11,7 +11,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new example_addressbook($rcube->plugins); @@ -25,7 +25,7 @@ function test_constructor() /** * Test address_sources() */ - function test_address_sources() + public function test_address_sources() { $rcube = rcube::get_instance(); $plugin = new example_addressbook($rcube->plugins); diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php index f22b5cc8d3..db220f90b0 100644 --- a/plugins/filesystem_attachments/filesystem_attachments.php +++ b/plugins/filesystem_attachments/filesystem_attachments.php @@ -30,17 +30,16 @@ class filesystem_attachments extends rcube_plugin public $task = '?(?!login).*'; public $initialized = false; - function init() + public function init() { // Find filesystem_attachments-based plugins, we can use only one foreach ($this->api->loaded_plugins() as $plugin_name) { $plugin = $this->api->get_plugin($plugin_name); if (($plugin instanceof self) && $plugin->initialized) { rcube::raise_error([ - 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Can use only one plugin for attachments/file uploads! Using '$plugin_name', ignoring others.", - ], true, false - ); + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Can use only one plugin for attachments/file uploads! Using '$plugin_name', ignoring others.", + ], true, false); return; } } @@ -70,7 +69,7 @@ function init() /** * Save a newly uploaded attachment */ - function upload($args) + public function upload($args) { $args['status'] = false; $group = $args['group']; @@ -91,7 +90,7 @@ function upload($args) /** * Save an attachment from a non-upload source (draft or forward) */ - function save($args) + public function save($args) { $group = $args['group']; $args['status'] = false; @@ -103,8 +102,7 @@ function save($args) fwrite($fp, $args['data']); fclose($fp); $args['path'] = $tmp_path; - } - else { + } else { return $args; } } @@ -119,7 +117,7 @@ function save($args) * Remove an attachment from storage * This is triggered by the remove attachment button on the compose screen */ - function remove($args) + public function remove($args) { $args['status'] = $this->verify_path($args['path']) && @unlink($args['path']); return $args; @@ -130,7 +128,7 @@ function remove($args) * For this plugin, the file is already in place, just check for * the existence of the proper metadata */ - function display($args) + public function display($args) { $args['status'] = $this->verify_path($args['path']) && file_exists($args['path']); return $args; @@ -141,7 +139,7 @@ function display($args) * on disk for use. This stub function is kept here to make this * class handy as a parent class for other plugins which may need it. */ - function get($args) + public function get($args) { if (!$this->verify_path($args['path'])) { $args['path'] = null; @@ -153,7 +151,7 @@ function get($args) /** * Delete all temp files associated with this user session */ - function cleanup($args) + public function cleanup($args) { $rcube = rcube::get_instance(); $group = $args['group'] ?? null; @@ -204,23 +202,21 @@ protected static function verify_path($path) // We allow that, but we'll let to know the user about the misconfiguration. if ($file_path == sys_get_temp_dir()) { rcube::raise_error([ - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Detected 'temp_dir' change. " - . "Access to '$temp_dir' restricted by filesystem permissions or open_basedir", - ], true, false - ); + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Detected 'temp_dir' change. " + . "Access to '$temp_dir' restricted by filesystem permissions or open_basedir", + ], true, false); return true; } rcube::raise_error([ - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => sprintf("%s can't read %s (not in temp_dir)", - $rcmail->get_user_name(), substr($path, 0, 512)), - ], true, false - ); + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => sprintf("%s can't read %s (not in temp_dir)", + $rcmail->get_user_name(), substr($path, 0, 512)), + ], true, false); return false; } diff --git a/plugins/filesystem_attachments/tests/FilesystemAttachments.php b/plugins/filesystem_attachments/tests/FilesystemAttachments.php index 6107305124..53596835e0 100644 --- a/plugins/filesystem_attachments/tests/FilesystemAttachments.php +++ b/plugins/filesystem_attachments/tests/FilesystemAttachments.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new filesystem_attachments($rcube->plugins); diff --git a/plugins/help/help.php b/plugins/help/help.php index 64d9e5ed46..17a99b3387 100644 --- a/plugins/help/help.php +++ b/plugins/help/help.php @@ -18,7 +18,7 @@ class help extends rcube_plugin // we've got no ajax handlers public $noajax = true; - function init() + public function init() { $this->load_config(); $this->add_texts('localization/', false); @@ -35,7 +35,7 @@ function init() $this->add_hook('error_page', [$this, 'error_page']); } - function startup($args) + public function startup($args) { $rcmail = rcmail::get_instance(); @@ -59,31 +59,29 @@ function startup($args) $this->include_stylesheet($this->local_skin_path() . '/help.css'); } - function action() + public function action() { $rcmail = rcmail::get_instance(); if ($rcmail->action == 'about') { $rcmail->output->set_pagetitle($this->gettext('about')); - } - elseif ($rcmail->action == 'license') { + } elseif ($rcmail->action == 'license') { $rcmail->output->set_pagetitle($this->gettext('license')); - } - else { + } else { $rcmail->output->set_pagetitle($this->gettext('help')); } // register UI objects $rcmail->output->add_handlers([ - 'helpcontent' => [$this, 'help_content'], - 'tablink' => [$this, 'tablink'], + 'helpcontent' => [$this, 'help_content'], + 'tablink' => [$this, 'tablink'], ]); $rcmail->output->set_env('help_links', $this->help_metadata()); $rcmail->output->send(!empty($_GET['_content']) ? 'help.content' : 'help.help'); } - function help_content($attrib) + public function help_content($attrib) { $rcmail = rcmail::get_instance(); // $rcmail->output->set_env('content', $content); @@ -91,14 +89,13 @@ function help_content($attrib) if (!empty($_GET['_content'])) { if ($rcmail->action == 'about') { return file_get_contents($this->home . '/content/about.html'); - } - elseif ($rcmail->action == 'license') { + } elseif ($rcmail->action == 'license') { return file_get_contents($this->home . '/content/license.html'); } } } - function tablink($attrib) + public function tablink($attrib) { $rcmail = rcmail::get_instance(); @@ -115,7 +112,7 @@ function tablink($attrib) return $rcmail->output->button($attrib); } - function help_metadata() + public function help_metadata() { $rcmail = rcmail::get_instance(); $content = []; @@ -123,8 +120,7 @@ function help_metadata() // About if (is_readable($this->home . '/content/about.html')) { $content['about'] = 'self'; - } - else { + } else { $default = $rcmail->url(['_task' => 'settings', '_action' => 'about', '_framed' => 1]); $content['about'] = $rcmail->config->get('help_about_url', $default); $content['about'] = $this->resolve_language($content['about']); @@ -133,8 +129,7 @@ function help_metadata() // License if (is_readable($this->home . '/content/license.html')) { $content['license'] = 'self'; - } - else { + } else { $content['license'] = $rcmail->config->get('help_license_url', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html'); $content['license'] = $this->resolve_language($content['license']); } @@ -148,8 +143,7 @@ function help_metadata() [$task] = explode('/', $rel); if (!empty($index_map[$rel])) { $src .= $index_map[$rel]; - } - elseif (!empty($index_map[$task])) { + } elseif (!empty($index_map[$task])) { $src .= $index_map[$task]; } @@ -158,7 +152,7 @@ function help_metadata() return $content; } - function error_page($args) + public function error_page($args) { $rcmail = rcmail::get_instance(); diff --git a/plugins/help/tests/Help.php b/plugins/help/tests/Help.php index db6b72953a..3234a3e080 100644 --- a/plugins/help/tests/Help.php +++ b/plugins/help/tests/Help.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new help($rcube->plugins); @@ -22,7 +22,7 @@ function test_constructor() /** * Test help_metadata() */ - function test_help_metadata() + public function test_help_metadata() { $rcube = rcube::get_instance(); $plugin = new help($rcube->plugins); diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php index 1d8932fe06..b275c6ced8 100644 --- a/plugins/hide_blockquote/hide_blockquote.php +++ b/plugins/hide_blockquote/hide_blockquote.php @@ -20,7 +20,7 @@ class hide_blockquote extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $rcmail = rcmail::get_instance(); @@ -37,8 +37,7 @@ function init() // set env variable for client $rcmail->output->set_env('blockquote_limit', $limit); - } - elseif ($rcmail->task == 'settings') { + } elseif ($rcmail->task == 'settings') { $dont_override = $rcmail->config->get('dont_override', []); if (!in_array('hide_blockquote_limit', $dont_override)) { $this->add_hook('preferences_list', [$this, 'prefs_table']); @@ -54,7 +53,7 @@ function init() * * @return array Modified hook arguments */ - function prefs_table($args) + public function prefs_table($args) { if ($args['section'] != 'mailview') { return $args; @@ -66,10 +65,10 @@ function prefs_table($args) $limit = (int) $rcmail->config->get('hide_blockquote_limit'); $field_id = 'hide_blockquote_limit'; $input = new html_inputfield([ - 'name' => '_' . $field_id, - 'id' => $field_id, - 'size' => 5, - 'class' => 'form-control', + 'name' => '_' . $field_id, + 'id' => $field_id, + 'size' => 5, + 'class' => 'form-control', ]); $args['blocks']['main']['options']['hide_blockquote_limit'] = [ @@ -87,7 +86,7 @@ function prefs_table($args) * * @return array Modified hook arguments */ - function prefs_save($args) + public function prefs_save($args) { if ($args['section'] == 'mailview') { $args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST); diff --git a/plugins/hide_blockquote/tests/HideBlockquote.php b/plugins/hide_blockquote/tests/HideBlockquote.php index 364d658cf6..f5bd627948 100644 --- a/plugins/hide_blockquote/tests/HideBlockquote.php +++ b/plugins/hide_blockquote/tests/HideBlockquote.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new hide_blockquote($rcube->plugins); @@ -24,7 +24,7 @@ function test_constructor() /** * Test prefs_table() method */ - function test_prefs_table() + public function test_prefs_table() { $rcube = rcube::get_instance(); $plugin = new hide_blockquote($rcube->plugins); @@ -47,7 +47,7 @@ function test_prefs_table() /** * Test prefs_save() method */ - function test_prefs_save() + public function test_prefs_save() { $rcube = rcube::get_instance(); $plugin = new hide_blockquote($rcube->plugins); diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index 39ed72c582..537604bbb7 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -20,7 +20,7 @@ class http_authentication extends rcube_plugin { private $redirect_query; - function init() + public function init() { $this->add_hook('startup', [$this, 'startup']); $this->add_hook('authenticate', [$this, 'authenticate']); @@ -28,7 +28,7 @@ function init() $this->add_hook('login_after', [$this, 'login']); } - function startup($args) + public function startup($args) { if (!empty($_SERVER['PHP_AUTH_USER'])) { $rcmail = rcmail::get_instance(); @@ -50,7 +50,7 @@ function startup($args) return $args; } - function authenticate($args) + public function authenticate($args) { // Load plugin's config file $this->load_config(); @@ -79,7 +79,7 @@ function authenticate($args) return $args; } - function logout($args) + public function logout($args) { // redirect to configured URL in order to clear HTTP auth credentials if (!empty($_SERVER['PHP_AUTH_USER']) && $args['user'] == $_SERVER['PHP_AUTH_USER']) { @@ -90,14 +90,14 @@ function logout($args) } } - static function shutdown() + public static function shutdown() { // There's no need to store password (even if encrypted) in session // We'll set it back on startup (#1486553) rcmail::get_instance()->session->remove('password'); } - function login($args) + public function login($args) { // Redirect to the previous QUERY_STRING if ($this->redirect_query) { diff --git a/plugins/http_authentication/tests/HttpAuthentication.php b/plugins/http_authentication/tests/HttpAuthentication.php index b968daa7ce..99700a4108 100644 --- a/plugins/http_authentication/tests/HttpAuthentication.php +++ b/plugins/http_authentication/tests/HttpAuthentication.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new http_authentication($rcube->plugins); diff --git a/plugins/identicon/identicon.php b/plugins/identicon/identicon.php index 2eb5de6097..4c77bcf7ac 100644 --- a/plugins/identicon/identicon.php +++ b/plugins/identicon/identicon.php @@ -25,7 +25,7 @@ class identicon extends rcube_plugin /** * Plugin initialization. */ - function init() + public function init() { $this->add_hook('contact_photo', [$this, 'contact_photo']); } @@ -33,7 +33,7 @@ function init() /** * 'contact_photo' hook handler to inject an identicon image */ - function contact_photo($args) + public function contact_photo($args) { // pre-conditions, exit if photo already exists or invalid input if (!empty($args['url']) || !empty($args['data']) @@ -60,8 +60,7 @@ function contact_photo($args) if (!empty($args['attrib']['bg-color'])) { $bgcolor = $args['attrib']['bg-color']; - } - else { + } else { $bgcolor = rcube_utils::get_input_string('_bgcolor', rcube_utils::INPUT_GET); } @@ -73,8 +72,7 @@ function contact_photo($args) $mimetype = $identicon->getMimetype(); $args['url'] = sprintf('data:%s;base64,%s', $mimetype, $icon); } - } - else { + } else { // send the icon to the browser if ($identicon->sendOutput()) { exit; diff --git a/plugins/identicon/identicon_engine.php b/plugins/identicon/identicon_engine.php index a938a112ad..cdcf00080d 100644 --- a/plugins/identicon/identicon_engine.php +++ b/plugins/identicon/identicon_engine.php @@ -20,15 +20,15 @@ class identicon_engine '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#607D8B', ]; private $grid = [ - 0, 1, 2, 1, 0, - 3, 4, 5, 4, 3, - 6, 7, 8, 7, 6, - 9, 10, 11, 10, 9, + 0, 1, 2, 1, 0, + 3, 4, 5, 4, 3, + 6, 7, 8, 7, 6, + 9, 10, 11, 10, 9, 12, 13, 14, 13, 12, ]; - const GRID_SIZE = 5; - const ICON_SIZE = 150; + public const GRID_SIZE = 5; + public const ICON_SIZE = 150; /** @@ -55,8 +55,7 @@ public function __construct($ident, $size = null, $bgcolor = null) $bgcolor = "#{$bgcolor}"; } $this->bgcolor = $bgcolor; - } - elseif ($bgcolor === 'transparent') { + } elseif ($bgcolor === 'transparent') { $this->bgcolor = $bgcolor; } } @@ -132,8 +131,7 @@ private function generate() // really generate the image using supported methods if (function_exists('imagepng')) { $this->generateGD(); - } - else { + } else { // log an error $error = [ 'code' => 500, @@ -158,8 +156,7 @@ private function generateGD() if ($this->bgcolor === 'transparent') { $bgcolor = imagecolorallocatealpha($image, 0, 0, 0, 127); imagesavealpha($image, true); - } - else { + } else { $bgcolor = $this->toRGB($this->bgcolor); $bgcolor = imagecolorallocate($image, $bgcolor[0], $bgcolor[1], $bgcolor[2]); } diff --git a/plugins/identicon/tests/Identicon.php b/plugins/identicon/tests/Identicon.php index 777cfe52ff..dd30515519 100644 --- a/plugins/identicon/tests/Identicon.php +++ b/plugins/identicon/tests/Identicon.php @@ -10,7 +10,7 @@ public static function setUpBeforeCLass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new identicon($rcube->plugins); diff --git a/plugins/identicon/tests/IdenticonEngine.php b/plugins/identicon/tests/IdenticonEngine.php index b92e1c1063..8b8513c902 100644 --- a/plugins/identicon/tests/IdenticonEngine.php +++ b/plugins/identicon/tests/IdenticonEngine.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Test icon generation */ - function test_icon_generation() + public function test_icon_generation() { if (!function_exists('imagepng')) { $this->markTestSkipped(); diff --git a/plugins/identity_select/identity_select.php b/plugins/identity_select/identity_select.php index f248012270..fee22c0040 100644 --- a/plugins/identity_select/identity_select.php +++ b/plugins/identity_select/identity_select.php @@ -24,7 +24,7 @@ class identity_select extends rcube_plugin public $task = 'mail'; - function init() + public function init() { $this->add_hook('identity_select', [$this, 'select']); $this->add_hook('storage_init', [$this, 'storage_init']); @@ -33,7 +33,7 @@ function init() /** * Adds additional headers to supported headers list */ - function storage_init($p) + public function storage_init($p) { $rcmail = rcmail::get_instance(); @@ -42,8 +42,7 @@ function storage_init($p) if (isset($p['fetch_headers'])) { $p['fetch_headers'] .= ' ' . $add_headers; - } - else { + } else { $p['fetch_headers'] = $add_headers; } } @@ -54,7 +53,7 @@ function storage_init($p) /** * Identity selection */ - function select($p) + public function select($p) { if ($p['selected'] !== null || empty($p['message']->headers)) { return $p; diff --git a/plugins/identity_select/tests/IdentitySelect.php b/plugins/identity_select/tests/IdentitySelect.php index e9b63e2b62..1d2fc36807 100644 --- a/plugins/identity_select/tests/IdentitySelect.php +++ b/plugins/identity_select/tests/IdentitySelect.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new identity_select($rcube->plugins); diff --git a/plugins/jqueryui/config.inc.php.dist b/plugins/jqueryui/config.inc.php.dist index c349f5e698..fc689916e9 100644 --- a/plugins/jqueryui/config.inc.php.dist +++ b/plugins/jqueryui/config.inc.php.dist @@ -5,6 +5,6 @@ $config['jquery_ui_i18n'] = ['datepicker']; // map Roundcube skins with jquery-ui themes here $config['jquery_ui_skin_map'] = [ - 'larry' => 'larry', - 'default' => 'elastic', + 'larry' => 'larry', + 'default' => 'elastic', ]; diff --git a/plugins/jqueryui/jqueryui.php b/plugins/jqueryui/jqueryui.php index 3258b8b3f4..1313d2e4ee 100644 --- a/plugins/jqueryui/jqueryui.php +++ b/plugins/jqueryui/jqueryui.php @@ -68,8 +68,7 @@ public function init() foreach ($jquery_ui_i18n as $package) { if (self::asset_exists("js/i18n/$package-$lang_l.js", false)) { $this->include_script("js/i18n/$package-$lang_l.js"); - } - elseif ($lang_s != 'en' && self::asset_exists("js/i18n/$package-$lang_s.js", false)) { + } elseif ($lang_s != 'en' && self::asset_exists("js/i18n/$package-$lang_s.js", false)) { $this->include_script("js/i18n/$package-$lang_s.js"); } } @@ -78,12 +77,12 @@ public function init() // Date format for datepicker $date_format = $date_format_localized = $rcmail->config->get('date_format', 'Y-m-d'); $date_format = strtr($date_format, [ - 'y' => 'y', - 'Y' => 'yy', - 'm' => 'mm', - 'n' => 'm', - 'd' => 'dd', - 'j' => 'd', + 'y' => 'y', + 'Y' => 'yy', + 'm' => 'mm', + 'n' => 'm', + 'd' => 'dd', + 'j' => 'd', ]); $replaces = ['Y' => 'yyyy', 'y' => 'yy', 'm' => 'mm', 'd' => 'dd', 'j' => 'd', 'n' => 'm']; diff --git a/plugins/jqueryui/tests/Jqueryui.php b/plugins/jqueryui/tests/Jqueryui.php index f6dfd732e8..079d028ed2 100644 --- a/plugins/jqueryui/tests/Jqueryui.php +++ b/plugins/jqueryui/tests/Jqueryui.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new jqueryui($rcube->plugins); diff --git a/plugins/krb_authentication/krb_authentication.php b/plugins/krb_authentication/krb_authentication.php index 76004443d0..ed6bb6a67d 100644 --- a/plugins/krb_authentication/krb_authentication.php +++ b/plugins/krb_authentication/krb_authentication.php @@ -18,7 +18,7 @@ class krb_authentication extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->add_hook('startup', [$this, 'startup']); $this->add_hook('authenticate', [$this, 'authenticate']); @@ -31,15 +31,14 @@ function init() /** * Startup hook handler */ - function startup($args) + public function startup($args) { if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) { // handle login action if (empty($_SESSION['user_id'])) { $args['action'] = 'login'; $this->redirect_query = $_SERVER['QUERY_STRING']; - } - else { + } else { $_SESSION['password'] = null; } } @@ -50,7 +49,7 @@ function startup($args) /** * Authenticate hook handler */ - function authenticate($args) + public function authenticate($args) { if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) { // Load plugin's config file @@ -78,7 +77,7 @@ function authenticate($args) /** * login_after hook handler */ - function login($args) + public function login($args) { // Redirect to the previous QUERY_STRING if ($this->redirect_query) { @@ -92,7 +91,7 @@ function login($args) /** * Storage_connect hook handler */ - function storage_connect($args) + public function storage_connect($args) { if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) { $args['gssapi_context'] = $this->gssapi_context('imap'); @@ -106,7 +105,7 @@ function storage_connect($args) /** * managesieve_connect hook handler */ - function managesieve_connect($args) + public function managesieve_connect($args) { if ( (!isset($args['auth_type']) || $args['auth_type'] == 'GSSAPI') @@ -123,7 +122,7 @@ function managesieve_connect($args) /** * smtp_connect hook handler */ - function smtp_connect($args) + public function smtp_connect($args) { if ( (!isset($args['smtp_auth_type']) || $args['smtp_auth_type'] == 'GSSAPI') diff --git a/plugins/krb_authentication/tests/KrbAuthentication.php b/plugins/krb_authentication/tests/KrbAuthentication.php index b4424a949b..192a30c24c 100644 --- a/plugins/krb_authentication/tests/KrbAuthentication.php +++ b/plugins/krb_authentication/tests/KrbAuthentication.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new krb_authentication($rcube->plugins); diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index bf158fe88d..5fad848af6 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -34,15 +34,15 @@ class rcube_sieve public $script; // rcube_sieve_script object public $current; // name of currently loaded script - const ERROR_CONNECTION = 1; - const ERROR_LOGIN = 2; - const ERROR_NOT_EXISTS = 3; // script not exists - const ERROR_INSTALL = 4; // script installation - const ERROR_ACTIVATE = 5; // script activation - const ERROR_DELETE = 6; // script deletion - const ERROR_INTERNAL = 7; // internal error - const ERROR_DEACTIVATE = 8; // script activation - const ERROR_OTHER = 255; // other/unknown error + public const ERROR_CONNECTION = 1; + public const ERROR_LOGIN = 2; + public const ERROR_NOT_EXISTS = 3; // script not exists + public const ERROR_INSTALL = 4; // script installation + public const ERROR_ACTIVATE = 5; // script activation + public const ERROR_DELETE = 6; // script deletion + public const ERROR_INTERNAL = 7; // internal error + public const ERROR_DEACTIVATE = 8; // script activation + public const ERROR_OTHER = 255; // other/unknown error /** @@ -186,8 +186,7 @@ public function save_script($name, $content = null) if ($res === 1) { if (count($matches) > 2) { $this->errorLines[] = ['line' => $matches[1], 'msg' => $matches[2]]; - } - else { + } else { $this->errorLines[] = ['line' => $matches[1], 'msg' => null]; } } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 842c61e67d..a7eaed9b92 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -61,15 +61,15 @@ class rcube_sieve_engine 1 => 'notifyimportancehigh', ]; - const VERSION = '9.5'; - const PROGNAME = 'Roundcube (Managesieve)'; - const PORT = 4190; + public const VERSION = '9.5'; + public const PROGNAME = 'Roundcube (Managesieve)'; + public const PORT = 4190; /** * Class constructor */ - function __construct($plugin) + public function __construct($plugin) { $this->rc = rcube::get_instance(); $this->plugin = $plugin; @@ -79,15 +79,15 @@ function __construct($plugin) /** * Loads configuration, initializes plugin (including sieve connection) */ - function start($mode = null) + public function start($mode = null) { // register UI objects $this->rc->output->add_handlers([ - 'filterslist' => [$this, 'filters_list'], - 'filtersetslist' => [$this, 'filtersets_list'], - 'filterform' => [$this, 'filter_form'], - 'filtersetform' => [$this, 'filterset_form'], - 'filterseteditraw' => [$this, 'filterset_editraw'], + 'filterslist' => [$this, 'filters_list'], + 'filtersetslist' => [$this, 'filtersets_list'], + 'filterform' => [$this, 'filter_form'], + 'filtersetform' => [$this, 'filterset_form'], + 'filterseteditraw' => [$this, 'filterset_editraw'], ]); $this->disabled_actions = (array) $this->rc->config->get('managesieve_disabled_actions'); @@ -110,8 +110,7 @@ function start($mode = null) if ($mode != 'vacation' && $mode != 'forward') { if (!empty($_GET['_set']) || !empty($_POST['_set'])) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_GPC, true); - } - elseif (!empty($_SESSION['managesieve_current'])) { + } elseif (!empty($_SESSION['managesieve_current'])) { $script_name = $_SESSION['managesieve_current']; } } @@ -140,8 +139,7 @@ function start($mode = null) // to disable 'Add filter' button set env variable $this->rc->output->set_env('filterconnerror', true); $this->script = []; - } - else { + } else { $this->exts = $this->sieve->get_extensions(); $this->init_script(); $this->rc->output->set_env('currentset', $this->sieve->current); @@ -169,17 +167,17 @@ public function connect($username, $password) $host = rcube_utils::parse_host($host); $plugin = $this->rc->plugins->exec_hook('managesieve_connect', [ - 'user' => $username, - 'password' => $password, - 'host' => $host, - 'auth_type' => $this->rc->config->get('managesieve_auth_type'), - 'disabled' => $this->rc->config->get('managesieve_disabled_extensions'), - 'debug' => $this->rc->config->get('managesieve_debug', false), - 'auth_cid' => $this->rc->config->get('managesieve_auth_cid'), - 'auth_pw' => $this->rc->config->get('managesieve_auth_pw'), - 'socket_options' => $this->rc->config->get('managesieve_conn_options'), - 'gssapi_context' => null, - 'gssapi_cn' => null, + 'user' => $username, + 'password' => $password, + 'host' => $host, + 'auth_type' => $this->rc->config->get('managesieve_auth_type'), + 'disabled' => $this->rc->config->get('managesieve_disabled_extensions'), + 'debug' => $this->rc->config->get('managesieve_debug', false), + 'auth_cid' => $this->rc->config->get('managesieve_auth_cid'), + 'auth_pw' => $this->rc->config->get('managesieve_auth_pw'), + 'socket_options' => $this->rc->config->get('managesieve_conn_options'), + 'gssapi_context' => null, + 'gssapi_cn' => null, ]); [$host, $scheme, $port] = rcube_utils::parse_host_uri($plugin['host']); @@ -222,12 +220,11 @@ public function connect($username, $password) if ($error) { rcube::raise_error([ - 'code' => 403, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Unable to connect to managesieve on $host:$port", - ], true, false - ); + 'code' => 403, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Unable to connect to managesieve on $host:$port", + ], true, false); } return $error; @@ -249,11 +246,9 @@ protected function load_script($script_name = null) // get (first) active script if (!empty($this->active)) { $script_name = $this->active[0]; - } - elseif ($list) { + } elseif ($list) { $script_name = $list[0]; - } - else { + } else { // if script does not exist create one with default content $this->create_default_script(); } @@ -269,7 +264,7 @@ protected function load_script($script_name = null) /** * User interface actions handler */ - function actions() + public function actions() { $error = $this->start(); @@ -288,17 +283,14 @@ function actions() if ($result === true) { $this->rc->output->show_message('managesieve.filterdeleted', 'confirmation'); $this->rc->output->command('managesieve_updatelist', 'del', ['id' => $fid]); - } - else { + } else { $this->rc->output->show_message('managesieve.filterdeleteerror', 'error'); } } - } - else { + } else { $this->rc->output->show_message('managesieve.disabledaction', 'error'); } - } - elseif ($action == 'move' && !$error) { + } elseif ($action == 'move' && !$error) { if (isset($this->script[$fid])) { $to = (int) rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST); $rule = $this->script[$fid]; @@ -310,8 +302,7 @@ function actions() // add at target position if ($to >= count($this->script)) { $this->script[] = $rule; - } - else { + } else { $script = []; foreach ($this->script as $idx => $r) { if ($idx == $to) { @@ -331,13 +322,11 @@ function actions() $this->rc->output->show_message('managesieve.moved', 'confirmation'); $this->rc->output->command('managesieve_updatelist', 'list', ['list' => $result, 'clear' => true, 'set' => $to]); - } - else { + } else { $this->rc->output->show_message('managesieve.moveerror', 'error'); } } - } - elseif ($action == 'act' && !$error) { + } elseif ($action == 'act' && !$error) { if (isset($this->script[$fid])) { $rule = $this->script[$fid]; $disabled = !empty($rule['disabled']); @@ -351,24 +340,20 @@ function actions() if ($result === true) { if ($rule['disabled']) { $this->rc->output->show_message('managesieve.deactivated', 'confirmation'); - } - else { + } else { $this->rc->output->show_message('managesieve.activated', 'confirmation'); } $this->rc->output->command('managesieve_updatelist', 'update', ['id' => $fid, 'disabled' => $rule['disabled']]); - } - else { + } else { if ($rule['disabled']) { $this->rc->output->show_message('managesieve.deactivateerror', 'error'); - } - else { + } else { $this->rc->output->show_message('managesieve.activateerror', 'error'); } } } - } - elseif ($action == 'setact' && !$error) { + } elseif ($action == 'setact' && !$error) { if (!in_array('enable_disable_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->activate_script($script_name); @@ -379,16 +364,13 @@ function actions() $this->rc->output->show_message('managesieve.setactivated', 'confirmation'); $this->rc->output->command('managesieve_updatelist', 'setact', ['name' => $script_name, 'active' => true, 'all' => !$kep14]); - } - else { + } else { $this->rc->output->show_message('managesieve.setactivateerror', 'error'); } - } - else { + } else { $this->rc->output->show_message('managesieve.disabledaction', 'error'); } - } - elseif ($action == 'deact' && !$error) { + } elseif ($action == 'deact' && !$error) { if (!in_array('enable_disable_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->deactivate_script($script_name); @@ -398,16 +380,13 @@ function actions() $this->rc->output->show_message('managesieve.setdeactivated', 'confirmation'); $this->rc->output->command('managesieve_updatelist', 'setact', ['name' => $script_name, 'active' => false]); - } - else { + } else { $this->rc->output->show_message('managesieve.setdeactivateerror', 'error'); } - } - else { + } else { $this->rc->output->show_message('managesieve.disabledaction', 'error'); } - } - elseif ($action == 'setdel' && !$error) { + } elseif ($action == 'setdel' && !$error) { if (!in_array('delete_set', $this->disabled_actions)) { $script_name = rcube_utils::get_input_string('_set', rcube_utils::INPUT_POST, true); $result = $this->remove_script($script_name); @@ -416,16 +395,13 @@ function actions() $this->rc->output->show_message('managesieve.setdeleted', 'confirmation'); $this->rc->output->command('managesieve_updatelist', 'setdel', ['name' => $script_name]); $this->rc->session->remove('managesieve_current'); - } - else { + } else { $this->rc->output->show_message('managesieve.setdeleteerror', 'error'); } - } - else { + } else { $this->rc->output->show_message('managesieve.disabledaction', 'error'); } - } - elseif ($action == 'setget') { + } elseif ($action == 'setget') { if (!in_array('download_set', $this->disabled_actions)) { $this->rc->request_security_check(rcube_utils::INPUT_GET); @@ -439,35 +415,30 @@ function actions() exit; } - } - elseif ($action == 'list') { + } elseif ($action == 'list') { $result = $this->list_rules(); $this->rc->output->command('managesieve_updatelist', 'list', ['list' => $result]); - } - elseif ($action == 'ruleadd') { + } elseif ($action == 'ruleadd') { $rid = rcube_utils::get_input_string('_rid', rcube_utils::INPUT_POST); $id = $this->genid(); $content = $this->rule_div($fid, $id, false, !empty($_SESSION['managesieve-compact-form'])); $this->rc->output->command('managesieve_rulefill', $content, $id, $rid); - } - elseif ($action == 'actionadd') { + } elseif ($action == 'actionadd') { $aid = rcube_utils::get_input_string('_aid', rcube_utils::INPUT_POST); $id = $this->genid(); $content = $this->action_div($fid, $id, false); $this->rc->output->command('managesieve_actionfill', $content, $id, $aid); - } - elseif ($action == 'addresses') { + } elseif ($action == 'addresses') { $aid = rcube_utils::get_input_string('_aid', rcube_utils::INPUT_POST); $this->rc->output->command('managesieve_vacation_addresses_update', $aid, $this->user_emails()); } $this->rc->output->send(); - } - elseif ($this->rc->task == 'mail') { + } elseif ($this->rc->task == 'mail') { // Initialize the form $rules = rcube_utils::get_input_value('r', rcube_utils::INPUT_GET); if (!empty($rules)) { @@ -497,7 +468,7 @@ function actions() $this->send(); } - function saveraw() + public function saveraw() { // Init plugin and handle managesieve connection $error = $this->start(); @@ -512,8 +483,7 @@ function saveraw() if (count($errorLines) > 0) { $this->rc->output->set_env('sieve_errors', $errorLines); } - } - else { + } else { $this->rc->output->show_message('managesieve.setupdated', 'confirmation'); $this->rc->output->command('parent.managesieve_updatelist', 'refresh'); } @@ -521,38 +491,36 @@ function saveraw() $this->send(); } - function save() + public function save() { // Init plugin and handle managesieve connection $error = $this->start(); // get request size limits (#1488648) $max_post = max([ - ini_get('max_input_vars'), - ini_get('suhosin.request.max_vars'), - ini_get('suhosin.post.max_vars'), + ini_get('max_input_vars'), + ini_get('suhosin.request.max_vars'), + ini_get('suhosin.post.max_vars'), ]); $max_depth = max([ - ini_get('suhosin.request.max_array_depth'), - ini_get('suhosin.post.max_array_depth'), + ini_get('suhosin.request.max_array_depth'), + ini_get('suhosin.post.max_array_depth'), ]); // check request size limit if ($max_post && count($_POST, \COUNT_RECURSIVE) >= $max_post) { rcube::raise_error([ - 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Request size limit exceeded (one of max_input_vars/suhosin.request.max_vars/suhosin.post.max_vars)', - ], true, false - ); + 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Request size limit exceeded (one of max_input_vars/suhosin.request.max_vars/suhosin.post.max_vars)', + ], true, false); $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); } // check request depth limits elseif ($max_depth && count($_POST['_header']) > $max_depth) { rcube::raise_error([ - 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Request size limit exceeded (one of suhosin.request.max_array_depth/suhosin.post.max_array_depth)', - ], true, false - ); + 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Request size limit exceeded (one of suhosin.request.max_array_depth/suhosin.post.max_array_depth)', + ], true, false); $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); } // filters set add action @@ -567,23 +535,17 @@ function save() if (in_array('new_set', $this->disabled_actions)) { $error = 'managesieve.disabledaction'; - } - elseif (!$name) { + } elseif (!$name) { $this->errors['name'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (mb_strlen($name) > 128) { + } elseif (mb_strlen($name) > 128) { $this->errors['name'] = $this->plugin->gettext('nametoolong'); - } - elseif (!empty($exceptions) && in_array($name, (array) $exceptions)) { + } elseif (!empty($exceptions) && in_array($name, (array) $exceptions)) { $this->errors['name'] = $this->plugin->gettext('namereserved'); - } - elseif (!empty($kolab) && in_array($name_uc, ['MASTER', 'USER', 'MANAGEMENT'])) { + } elseif (!empty($kolab) && in_array($name_uc, ['MASTER', 'USER', 'MANAGEMENT'])) { $this->errors['name'] = $this->plugin->gettext('namereserved'); - } - elseif (in_array($name, $list)) { + } elseif (in_array($name, $list)) { $this->errors['name'] = $this->plugin->gettext('setexist'); - } - elseif ($from == 'file') { + } elseif ($from == 'file') { // from file if (is_uploaded_file($_FILES['_file']['tmp_name'])) { $file = file_get_contents($_FILES['_file']['tmp_name']); @@ -594,13 +556,11 @@ function save() if (!$this->save_script($name)) { $this->errors['file'] = $this->plugin->gettext('setcreateerror'); } - } - else { + } else { // upload failed rcmail_action::upload_error($_FILES['_file']['error']); } - } - elseif (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) { + } elseif (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) { $error = 'managesieve.setcreateerror'; } @@ -614,11 +574,9 @@ function save() $this->rc->output->show_message('managesieve.setcreated', 'confirmation'); $this->rc->output->command('parent.managesieve_updatelist', 'setadd', ['name' => $name, 'index' => $index]); - } - elseif (!empty($msg)) { + } elseif (!empty($msg)) { $this->rc->output->command('display_message', $msg, 'error'); - } - elseif ($error) { + } elseif ($error) { $this->rc->output->show_message($error, 'error'); } } @@ -696,8 +654,7 @@ function save() if ($name == '') { $this->errors['name'] = $this->plugin->gettext('cannotbeempty'); - } - else { + } else { foreach ($this->script as $idx => $rule) { if ($rule['name'] == $name && $idx != $fid) { $this->errors['name'] = $this->plugin->gettext('ruleexist'); @@ -710,8 +667,7 @@ function save() // rules if ($join == 'any') { $this->form['tests'][0]['test'] = 'true'; - } - else { + } else { foreach ($headers as $idx => $header) { // targets are indexed differently (assume form order) $target = $this->strip_value($targets[$idx], true); @@ -730,16 +686,13 @@ function save() if ($sizetarget === '') { $this->errors['tests'][$i]['sizetarget'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (!preg_match('/^[0-9]+(K|M|G)?$/i', $sizetarget . $sizeitem, $m)) { + } elseif (!preg_match('/^[0-9]+(K|M|G)?$/i', $sizetarget . $sizeitem, $m)) { $this->errors['tests'][$i]['sizetarget'] = $this->plugin->gettext('forbiddenchars'); $this->form['tests'][$i]['item'] = $sizeitem; - } - else { + } else { $this->form['tests'][$i]['arg'] .= $m[1]; } - } - elseif ($header == 'spamtest') { + } elseif ($header == 'spamtest') { $spamtestop = $this->strip_value($spamtestops[$idx]); $spamtesttarget = $this->strip_value($spamtesttargets[$idx]); $comparator = 'i;ascii-numeric'; @@ -755,12 +708,10 @@ function save() if ($spamtesttarget === '') { $this->errors['tests'][$i]['spamtesttarget'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (!preg_match('/^([0-9]|10)$/i', $spamtesttarget)) { + } elseif (!preg_match('/^([0-9]|10)$/i', $spamtesttarget)) { $this->errors['tests'][$i]['spamtesttarget'] = $this->plugin->gettext('forbiddenchars'); } - } - elseif ($header == 'currentdate') { + } elseif ($header == 'currentdate') { $datepart = $this->strip_value($dateparts[$idx]); $type = preg_replace('/^not/', '', $operator); @@ -777,15 +728,13 @@ function save() if ($type != 'exists') { if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (strpos($type, 'count-') === 0) { + } elseif (strpos($type, 'count-') === 0) { foreach ($target as $arg) { if (preg_match('/[^0-9]/', $arg)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); } } - } - elseif (strpos($type, 'value-') === 0) { + } elseif (strpos($type, 'value-') === 0) { // Some date/time formats do not support i;ascii-numeric comparator if ($comparator == 'i;ascii-numeric' && in_array($datepart, ['date', 'time', 'iso8601', 'std11'])) { $comparator = ''; @@ -801,8 +750,7 @@ function save() } } } - } - elseif ($header == 'date') { + } elseif ($header == 'date') { $datepart = $this->strip_value($dateparts[$idx]); $dateheader = $this->strip_value($dateheaders[$idx]); $index = $this->strip_value($indexes[$idx]); @@ -822,8 +770,7 @@ function save() if (empty($dateheader)) { $dateheader = 'Date'; - } - elseif (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $dateheader)) { + } elseif (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $dateheader)) { $this->errors['tests'][$i]['dateheader'] = $this->plugin->gettext('forbiddenchars'); } @@ -837,15 +784,13 @@ function save() if ($type != 'exists') { if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (strpos($type, 'count-') === 0) { + } elseif (strpos($type, 'count-') === 0) { foreach ($target as $arg) { if (preg_match('/[^0-9]/', $arg)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); } } - } - elseif (strpos($type, 'value-') === 0) { + } elseif (strpos($type, 'value-') === 0) { // Some date/time formats do not support i;ascii-numeric comparator if ($comparator == 'i;ascii-numeric' && in_array($datepart, ['date', 'time', 'iso8601', 'std11'])) { $comparator = ''; @@ -861,8 +806,7 @@ function save() } } } - } - elseif ($header == 'body') { + } elseif ($header == 'body') { $trans = $this->strip_value($body_trans[$idx]); $trans_type = $this->strip_value($body_types[$idx], true); $type = preg_replace('/^not/', '', $operator); @@ -883,16 +827,14 @@ function save() if (empty($target) && $type != 'exists') { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (preg_match('/^(value|count)-/', $type)) { + } elseif (preg_match('/^(value|count)-/', $type)) { foreach ($target as $target_value) { if (preg_match('/[^0-9]/', $target_value)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); } } } - } - elseif ($header == 'message') { + } elseif ($header == 'message') { $test = $this->strip_value($message[$idx]); if (preg_match('/^not/', $test)) { @@ -919,8 +861,7 @@ function save() $this->errors['tests'][$i]['duplicate_uniqueid'] = $this->plugin->gettext('duplicate.conflict.err'); } } - } - else { + } else { $cust_header = $headers = $this->strip_value($cust_headers[$idx]); $mod = $this->strip_value($mods[$idx]); $mod_type = $this->strip_value($mod_types[$idx]); @@ -947,8 +888,7 @@ function save() if ($header == '...' || $header == 'string') { if (!count($headers)) { $this->errors['tests'][$i]['header'] = $this->plugin->gettext('cannotbeempty'); - } - elseif ($header == '...') { + } elseif ($header == '...') { foreach ($headers as $hr) { // RFC2822: printable ASCII except colon if (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $hr)) { @@ -977,8 +917,7 @@ function save() if ($type == 'exists') { $this->form['tests'][$i]['test'] = 'exists'; $this->form['tests'][$i]['arg'] = $header; - } - else { + } else { if ($mod == 'address' || $mod == 'envelope') { $found = false; if (empty($this->errors['tests'][$i]['header'])) { @@ -1000,8 +939,7 @@ function save() if (empty($target)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (preg_match('/^(value|count)-/', $type)) { + } elseif (preg_match('/^(value|count)-/', $type)) { foreach ($target as $target_value) { if (preg_match('/[^0-9]/', $target_value)) { $this->errors['tests'][$i]['target'] = $this->plugin->gettext('forbiddenchars'); @@ -1086,8 +1024,7 @@ function save() if ($target === '') { $this->errors['actions'][$i]['target'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (!rcube_utils::check_email($target)) { + } elseif (!rcube_utils::check_email($target)) { $this->errors['actions'][$i]['target'] = $this->plugin->gettext(!empty($domains) ? 'forbiddenchars' : 'noemailwarning'); } @@ -1117,8 +1054,7 @@ function save() if (empty($this->form['actions'][$i]['name'])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (!preg_match('/^[0-9a-z_-]+$/i', $this->form['actions'][$i]['name'])) { + } elseif (!preg_match('/^[0-9a-z_-]+$/i', $this->form['actions'][$i]['name'])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('forbiddenchars'); } @@ -1137,12 +1073,10 @@ function save() if (!empty($this->form['actions'][$i]['last'])) { $this->errors['actions'][$i]['index'] = $this->plugin->gettext('lastindexempty'); } - } - elseif (!preg_match('/^[0-9]+$/i', $this->form['actions'][$i]['index'])) { + } elseif (!preg_match('/^[0-9]+$/i', $this->form['actions'][$i]['index'])) { $this->errors['actions'][$i]['index'] = $this->plugin->gettext('forbiddenchars'); } - } - else { + } else { if (empty($this->form['actions'][$i]['value'])) { $this->errors['actions'][$i]['value'] = $this->plugin->gettext('cannotbeempty'); } @@ -1167,8 +1101,7 @@ function save() if (empty($address)) { unset($this->form['actions'][$i]['addresses'][$aidx]); - } - elseif (!rcube_utils::check_email($address)) { + } elseif (!rcube_utils::check_email($address)) { $this->errors['actions'][$i]['addresses'] = $this->plugin->gettext('noemailwarning'); break; } @@ -1196,8 +1129,7 @@ function save() if (empty($varnames[$idx])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('cannotbeempty'); - } - elseif (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) { + } elseif (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) { $this->errors['actions'][$i]['name'] = $this->plugin->gettext('forbiddenchars'); } @@ -1244,8 +1176,7 @@ function save() if (!isset($this->script[$fid])) { $fid = $this->sieve->script->add_rule($this->form); $new = true; - } - else { + } else { $fid = $this->sieve->script->update_rule($fid, $this->form); } @@ -1262,17 +1193,14 @@ function save() 'disabled' => $this->form['disabled'], ]; $this->rc->output->command('parent.managesieve_updatelist', isset($new) ? 'add' : 'update', $args); - } - else { + } else { $this->rc->output->command('managesieve_dialog_close'); $this->rc->output->send('iframe'); } - } - else { + } else { $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); } - } - else { + } else { $this->rc->output->show_message('managesieve.filterformerror', 'warning'); } } @@ -1286,15 +1214,12 @@ protected function send() if (isset($_GET['_framed']) || isset($_POST['_framed'])) { if (isset($_GET['_newset']) || isset($_POST['_newset'])) { $this->rc->output->send('managesieve.setedit'); - } - elseif (isset($_GET['_seteditraw']) || isset($_POST['_seteditraw'])) { + } elseif (isset($_GET['_seteditraw']) || isset($_POST['_seteditraw'])) { $this->rc->output->send('managesieve.seteditraw'); - } - else { + } else { $this->rc->output->send('managesieve.filteredit'); } - } - else { + } else { $this->rc->output->set_pagetitle($this->plugin->gettext('filters')); $this->rc->output->send('managesieve.managesieve'); } @@ -1303,7 +1228,7 @@ protected function send() /** * Return the filters list as HTML table */ - function filters_list($attrib) + public function filters_list($attrib) { // add id to message list table if not specified if (empty($attrib['id'])) { @@ -1331,7 +1256,7 @@ function filters_list($attrib) /** * Return the filters list as ') !== false); } - function test_build_regexp_tests() + public function test_build_regexp_tests() { $error = null; $vacation = new rcube_sieve_vacation(true); @@ -52,7 +52,7 @@ function test_build_regexp_tests() $this->assertSame('managesieve.invaliddateformat', $error); } - function test_parse_regexp_tests() + public function test_parse_regexp_tests() { $tests = [ [ diff --git a/plugins/markasjunk/drivers/amavis_blacklist.php b/plugins/markasjunk/drivers/amavis_blacklist.php index 70108df207..33d5da9d4d 100644 --- a/plugins/markasjunk/drivers/amavis_blacklist.php +++ b/plugins/markasjunk/drivers/amavis_blacklist.php @@ -55,10 +55,9 @@ private function _do_list($uids, $spam) if (is_file($config_file) && !$rcube->config->load_from_file($config_file)) { rcube::raise_error([ - 'code' => 527, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Failed to load config from $config_file", - ], true, false - ); + 'code' => 527, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Failed to load config from $config_file", + ], true, false); return false; } @@ -72,18 +71,16 @@ private function _do_list($uids, $spam) // check DB connections and exit on failure if ($err_str = $db->is_error()) { rcube::raise_error([ - 'code' => 603, - 'type' => 'db', - 'message' => $err_str, - ], false, true - ); + 'code' => 603, + 'type' => 'db', + 'message' => $err_str, + ], false, true); } $sql_result = $db->query('SELECT `id` FROM `users` WHERE `email` = ?', $this->user_email); if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) { $rid = $res_array['id']; - } - else { + } else { if ($debug) { rcube::write_log('markasjunk', $this->user_email . ' not found in users table'); } @@ -104,8 +101,7 @@ private function _do_list($uids, $spam) if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) { $sid = $res_array['id']; - } - else { + } else { if ($debug) { rcube::write_log('markasjunk', "$email not found in mailaddr table - add it"); } @@ -114,8 +110,7 @@ private function _do_list($uids, $spam) if ($sql_result) { $sid = $db->insert_id(); - } - else { + } else { if ($debug) { rcube::write_log('markasjunk', "Cannot add $email to mailaddr table: " . $db->is_error($sql_result)); } @@ -141,8 +136,7 @@ private function _do_list($uids, $spam) if ($wb) { $sql_result = $db->query('UPDATE `wblist` SET `wb` = ? WHERE `sid` = ? AND `rid` = ?', $newwb, $sid, $rid); - } - else { + } else { $sql_result = $db->query('INSERT INTO `wblist` (`sid`, `rid`, `wb`) VALUES (?, ?, ?)', $sid, $rid, $newwb); } diff --git a/plugins/markasjunk/drivers/cmd_learn.php b/plugins/markasjunk/drivers/cmd_learn.php index aa10b562ed..bb69c5cdd9 100644 --- a/plugins/markasjunk/drivers/cmd_learn.php +++ b/plugins/markasjunk/drivers/cmd_learn.php @@ -87,8 +87,7 @@ private function _do_salearn($uids, $spam, $src_mbox) if (!empty($val)) { $tmp_command = str_replace('%h:' . $header, escapeshellarg($val), $tmp_command); - } - else { + } else { if ($debug) { rcube::write_log('markasjunk', "header {$header} not found in message {$src_mbox}/{$uid}"); } diff --git a/plugins/markasjunk/drivers/email_learn.php b/plugins/markasjunk/drivers/email_learn.php index 532f7fcc59..fda1f7e878 100644 --- a/plugins/markasjunk/drivers/email_learn.php +++ b/plugins/markasjunk/drivers/email_learn.php @@ -70,15 +70,15 @@ private function _do_emaillearn($uids, $spam) $OUTPUT = $this->rcube->output; $SENDMAIL = new rcmail_sendmail(null, [ - 'sendmail' => true, - 'from' => $from, - 'mailto' => $mailto, - 'dsn_enabled' => false, - 'charset' => 'UTF-8', - 'error_handler' => static function (...$args) use ($OUTPUT) { - call_user_func_array([$OUTPUT, 'show_message'], $args); - $OUTPUT->send(); - }, + 'sendmail' => true, + 'from' => $from, + 'mailto' => $mailto, + 'dsn_enabled' => false, + 'charset' => 'UTF-8', + 'error_handler' => static function (...$args) use ($OUTPUT) { + call_user_func_array([$OUTPUT, 'show_message'], $args); + $OUTPUT->send(); + }, ]); if ($attach) { @@ -127,8 +127,7 @@ private function _do_emaillearn($uids, $spam) '', RCUBE_CHARSET ); } - } - else { + } else { $headers = [ 'Resent-From' => $from_string, 'Resent-To' => $mailto, @@ -138,8 +137,8 @@ private function _do_emaillearn($uids, $spam) // create the bounce message $MAIL_MIME = new rcmail_resend_mail([ - 'bounce_message' => $MESSAGE, - 'bounce_headers' => $headers, + 'bounce_message' => $MESSAGE, + 'bounce_headers' => $headers, ]); } diff --git a/plugins/markasjunk/drivers/sa_blacklist.php b/plugins/markasjunk/drivers/sa_blacklist.php index 44d4dd8491..a7039016cf 100644 --- a/plugins/markasjunk/drivers/sa_blacklist.php +++ b/plugins/markasjunk/drivers/sa_blacklist.php @@ -70,10 +70,9 @@ private function _do_list($uids, $spam) if (is_file($config_file) && !$rcube->config->load_from_file($config_file)) { rcube::raise_error([ - 'code' => 527, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Failed to load config from $config_file", - ], true, false - ); + 'code' => 527, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Failed to load config from $config_file", + ], true, false); return false; } @@ -85,11 +84,10 @@ private function _do_list($uids, $spam) // check DB connections and exit on failure if ($err_str = $db->is_error()) { rcube::raise_error([ - 'code' => 603, - 'type' => 'db', - 'message' => $err_str, - ], false, true - ); + 'code' => 603, + 'type' => 'db', + 'message' => $err_str, + ], false, true); } foreach ($uids as $uid) { @@ -133,8 +131,7 @@ private function _do_list($uids, $spam) rcube::write_log('markasjunk', $this->sa_user . ' blocklist ' . $email); } } - } - else { + } else { // delete any blocklisting for this address $db->query( "DELETE FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND " diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php index c022f7bb71..ea7d4739cc 100644 --- a/plugins/markasjunk/markasjunk.php +++ b/plugins/markasjunk/markasjunk.php @@ -76,48 +76,47 @@ public function init() if ($toolbar) { // add the buttons to the main toolbar $this->add_button([ - 'command' => 'plugin.markasjunk.junk', - 'type' => 'link', - 'class' => 'button buttonPas junk disabled', - 'classact' => 'button junk', - 'classsel' => 'button junk pressed', - 'title' => 'markasjunk.buttonjunk', - 'innerclass' => 'inner', - 'label' => 'junk', - ], 'toolbar'); + 'command' => 'plugin.markasjunk.junk', + 'type' => 'link', + 'class' => 'button buttonPas junk disabled', + 'classact' => 'button junk', + 'classsel' => 'button junk pressed', + 'title' => 'markasjunk.buttonjunk', + 'innerclass' => 'inner', + 'label' => 'junk', + ], 'toolbar'); $this->add_button([ - 'command' => 'plugin.markasjunk.not_junk', - 'type' => 'link', - 'class' => 'button buttonPas notjunk disabled', - 'classact' => 'button notjunk', - 'classsel' => 'button notjunk pressed', - 'title' => 'markasjunk.buttonnotjunk', - 'innerclass' => 'inner', - 'label' => 'markasjunk.notjunk', - ], 'toolbar'); - } - else { + 'command' => 'plugin.markasjunk.not_junk', + 'type' => 'link', + 'class' => 'button buttonPas notjunk disabled', + 'classact' => 'button notjunk', + 'classsel' => 'button notjunk pressed', + 'title' => 'markasjunk.buttonnotjunk', + 'innerclass' => 'inner', + 'label' => 'markasjunk.notjunk', + ], 'toolbar'); + } else { // add the buttons to the mark message menu $this->add_button([ - 'command' => 'plugin.markasjunk.junk', - 'type' => 'link-menuitem', - 'label' => 'markasjunk.asjunk', - 'id' => 'markasjunk', - 'class' => 'icon junk disabled', - 'classact' => 'icon junk active', - 'innerclass' => 'icon junk', - ], 'markmenu'); + 'command' => 'plugin.markasjunk.junk', + 'type' => 'link-menuitem', + 'label' => 'markasjunk.asjunk', + 'id' => 'markasjunk', + 'class' => 'icon junk disabled', + 'classact' => 'icon junk active', + 'innerclass' => 'icon junk', + ], 'markmenu'); $this->add_button([ - 'command' => 'plugin.markasjunk.not_junk', - 'type' => 'link-menuitem', - 'label' => 'markasjunk.asnotjunk', - 'id' => 'markasnotjunk', - 'class' => 'icon notjunk disabled', - 'classact' => 'icon notjunk active', - 'innerclass' => 'icon notjunk', - ], 'markmenu'); + 'command' => 'plugin.markasjunk.not_junk', + 'type' => 'link-menuitem', + 'label' => 'markasjunk.asnotjunk', + 'id' => 'markasnotjunk', + 'class' => 'icon notjunk disabled', + 'classact' => 'icon notjunk active', + 'innerclass' => 'icon notjunk', + ], 'markmenu'); } // add markasjunk folder settings to the env for JS @@ -155,8 +154,7 @@ public function mark_message() if ($result) { if ($dest_mbox && ($mbox_name !== $dest_mbox || $multifolder)) { $this->rcube->output->command('markasjunk_move', $dest_mbox, $this->_messageset_to_uids($messageset, $multifolder)); - } - else { + } else { $this->rcube->output->command('command', 'list', $mbox_name); } @@ -170,8 +168,7 @@ public function set_flags($p) { if (!empty($p['message_flags'])) { $p['message_flags'] = array_merge((array) $p['message_flags'], $this->flags); - } - else { + } else { $p['message_flags'] = $this->flags; } @@ -249,8 +246,7 @@ private function _call_driver($action, &$uids = null, $source_mbox = null, $dest if ($action == 'spam') { $this->driver->spam($uids, $source_mbox, $dest_mbox); - } - elseif ($action == 'ham') { + } elseif ($action == 'ham') { $this->driver->ham($uids, $source_mbox, $dest_mbox); } @@ -290,15 +286,13 @@ private function _init_flags() if ($spam_flag === false) { unset($this->flags['JUNK']); - } - elseif (!empty($spam_flag)) { + } elseif (!empty($spam_flag)) { $this->flags['JUNK'] = $spam_flag; } if ($ham_flag === false) { unset($this->flags['NONJUNK']); - } - elseif (!empty($ham_flag)) { + } elseif (!empty($ham_flag)) { $this->flags['NONJUNK'] = $ham_flag; } @@ -321,24 +315,22 @@ private function _init_driver() if (!is_readable($driver)) { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "markasjunk plugin: Unable to open driver file $driver", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "markasjunk plugin: Unable to open driver file $driver", + ], true, false); } include_once $driver; if (!class_exists($class, false) || !method_exists($class, 'spam') || !method_exists($class, 'ham')) { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "markasjunk plugin: Broken driver: $driver", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "markasjunk plugin: Broken driver: $driver", + ], true, false); } // call the relevant function from the driver diff --git a/plugins/markasjunk/tests/Markasjunk.php b/plugins/markasjunk/tests/Markasjunk.php index fb5041aab7..3bb7b27b96 100644 --- a/plugins/markasjunk/tests/Markasjunk.php +++ b/plugins/markasjunk/tests/Markasjunk.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new markasjunk($rcube->plugins); @@ -22,7 +22,7 @@ function test_constructor() /** * Test driver loading */ - function test_init_driver() + public function test_init_driver() { $rcube = rcube::get_instance(); $plugin = new markasjunk($rcube->plugins); diff --git a/plugins/new_user_dialog/new_user_dialog.php b/plugins/new_user_dialog/new_user_dialog.php index 9334558b75..ef52054302 100644 --- a/plugins/new_user_dialog/new_user_dialog.php +++ b/plugins/new_user_dialog/new_user_dialog.php @@ -17,7 +17,7 @@ class new_user_dialog extends rcube_plugin public $noframe = true; - function init() + public function init() { $this->add_hook('identity_create', [$this, 'create_identity']); $this->add_hook('render_page', [$this, 'render_page']); @@ -27,7 +27,7 @@ function init() /** * Check newly created identity at first login */ - function create_identity($p) + public function create_identity($p) { // set session flag when a new user was created and the default identity seems to be incomplete if (!empty($p['login']) && empty($p['complete']) && !empty($p['record']['standard'])) { @@ -40,7 +40,7 @@ function create_identity($p) * Callback function when HTML page is rendered * We'll add an overlay box here. */ - function render_page($p) + public function render_page($p) { $rcmail = rcmail::get_instance(); @@ -139,7 +139,7 @@ function render_page($p) * Check fields and save to default identity if valid. * Afterwards the session flag is removed and we're done. */ - function save_data() + public function save_data() { $rcmail = rcmail::get_instance(); $identity = $rcmail->user->get_identity(); @@ -155,8 +155,7 @@ function save_data() if ($ident_level == 4) { $disabled = ['name', 'email', 'organization']; - } - elseif (in_array($ident_level, [1, 3])) { + } elseif (in_array($ident_level, [1, 3])) { $disabled = ['email']; } @@ -166,11 +165,9 @@ function save_data() if (empty($save_data['name']) || empty($save_data['email'])) { $rcmail->output->show_message('formincomplete', 'error'); - } - elseif (!rcube_utils::check_email($save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']))) { + } elseif (!rcube_utils::check_email($save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']))) { $rcmail->output->show_message('emailformaterror', 'error', ['email' => $save_data['email']]); - } - else { + } else { // execute hook $plugin = $rcmail->plugins->exec_hook('identity_update', [ 'id' => $identity['identity_id'], diff --git a/plugins/new_user_dialog/tests/NewUserDialog.php b/plugins/new_user_dialog/tests/NewUserDialog.php index 84a24c5f75..7e67381c21 100644 --- a/plugins/new_user_dialog/tests/NewUserDialog.php +++ b/plugins/new_user_dialog/tests/NewUserDialog.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new new_user_dialog($rcube->plugins); diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php index 11b4ab00cb..247e95e8ef 100644 --- a/plugins/new_user_identity/new_user_identity.php +++ b/plugins/new_user_identity/new_user_identity.php @@ -20,7 +20,7 @@ class new_user_identity extends rcube_plugin /** * Plugin initialization. API hooks binding. */ - function init() + public function init() { $this->rc = rcmail::get_instance(); @@ -31,7 +31,7 @@ function init() /** * 'user_create' hook handler. */ - function lookup_user_name($args) + public function lookup_user_name($args) { if ($this->init_ldap($args['host'], $args['user'])) { $results = $this->ldap->search('*', $args['user'], true); @@ -75,7 +75,7 @@ function lookup_user_name($args) * 'login_after' hook handler. This is where we create identities for * all user email addresses. */ - function login_after($args) + public function login_after($args) { $this->load_config(); @@ -85,8 +85,8 @@ function login_after($args) $identities = $this->rc->user->list_emails(); $ldap_entry = $this->lookup_user_name([ - 'user' => $this->rc->user->data['username'], - 'host' => $this->rc->user->data['mail_host'], + 'user' => $this->rc->user->data['username'], + 'host' => $this->rc->user->data['mail_host'], ]); if (empty($ldap_entry['email_list'])) { @@ -149,7 +149,7 @@ private function init_ldap($host, $user) class new_user_identity_ldap_backend extends rcube_ldap { - function __construct($p, $debug, $mail_domain, $search) + public function __construct($p, $debug, $mail_domain, $search) { parent::__construct($p, $debug, $mail_domain); $this->prop['search_fields'] = (array) $search; diff --git a/plugins/new_user_identity/tests/NewUserIdentity.php b/plugins/new_user_identity/tests/NewUserIdentity.php index 8cb60940c6..dbe2e389db 100644 --- a/plugins/new_user_identity/tests/NewUserIdentity.php +++ b/plugins/new_user_identity/tests/NewUserIdentity.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new new_user_identity($rcube->plugins); diff --git a/plugins/newmail_notifier/newmail_notifier.php b/plugins/newmail_notifier/newmail_notifier.php index bd69b4e467..fc1326ddf6 100644 --- a/plugins/newmail_notifier/newmail_notifier.php +++ b/plugins/newmail_notifier/newmail_notifier.php @@ -39,7 +39,7 @@ class newmail_notifier extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->rc = rcmail::get_instance(); @@ -47,8 +47,7 @@ function init() if ($this->rc->task == 'settings') { $this->add_hook('preferences_list', [$this, 'prefs_list']); $this->add_hook('preferences_save', [$this, 'prefs_save']); - } - else { // if ($this->rc->task == 'mail') { + } else { // if ($this->rc->task == 'mail') { // add script when not in ajax and not in frame and only in main window if ($this->rc->output->type == 'html' && empty($_REQUEST['_framed']) && $this->rc->action == '') { $this->add_texts('localization/'); @@ -83,7 +82,7 @@ function init() /** * Handler for user preferences form (preferences_list hook) */ - function prefs_list($args) + public function prefs_list($args) { if ($args['section'] != 'mailbox') { return $args; @@ -146,7 +145,7 @@ function prefs_list($args) /** * Handler for user preferences save (preferences_save hook) */ - function prefs_save($args) + public function prefs_save($args) { if ($args['section'] != 'mailbox') { return $args; @@ -178,7 +177,7 @@ function prefs_save($args) /** * Handler for new message action (new_messages hook) */ - function notify($args) + public function notify($args) { // Already notified or unexpected input if ($this->notified || empty($args['diff']['new'])) { diff --git a/plugins/newmail_notifier/tests/NewmailNotifier.php b/plugins/newmail_notifier/tests/NewmailNotifier.php index f579cbf79b..6e56d98cb9 100644 --- a/plugins/newmail_notifier/tests/NewmailNotifier.php +++ b/plugins/newmail_notifier/tests/NewmailNotifier.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new newmail_notifier($rcube->plugins); diff --git a/plugins/password/drivers/chpasswd.php b/plugins/password/drivers/chpasswd.php index 3c539e4006..a2f70f5804 100644 --- a/plugins/password/drivers/chpasswd.php +++ b/plugins/password/drivers/chpasswd.php @@ -42,12 +42,11 @@ public function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $cmd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/dbmail.php b/plugins/password/drivers/dbmail.php index db69fcae98..2fa97f09d0 100644 --- a/plugins/password/drivers/dbmail.php +++ b/plugins/password/drivers/dbmail.php @@ -32,7 +32,7 @@ class rcube_dbmail_password { - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { $curdir = RCUBE_PLUGINS_DIR . 'password/helpers'; $username = escapeshellarg($username); @@ -47,12 +47,11 @@ function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/directadmin.php b/plugins/password/drivers/directadmin.php index 8d618f383a..5974d424e5 100644 --- a/plugins/password/drivers/directadmin.php +++ b/plugins/password/drivers/directadmin.php @@ -30,7 +30,7 @@ class rcube_directadmin_password public function save($curpass, $passwd) { $rcmail = rcmail::get_instance(); - $Socket = new HTTPSocket; + $Socket = new HTTPSocket(); $da_user = $_SESSION['username']; $da_curpass = $curpass; @@ -45,14 +45,14 @@ public function save($curpass, $passwd) $da_host = str_replace('%h', $_SESSION['imap_host'], $da_host); $da_host = str_replace('%d', $rcmail->user->get_username('domain'), $da_host); - $Socket->connect($da_host,$da_port); + $Socket->connect($da_host, $da_port); $Socket->set_method('POST'); $Socket->query('/CMD_CHANGE_EMAIL_PASSWORD', [ - 'email' => $da_user, - 'oldpassword' => $da_curpass, - 'password1' => $da_newpass, - 'password2' => $da_newpass, - 'api' => '1', + 'email' => $da_user, + 'oldpassword' => $da_curpass, + 'password1' => $da_newpass, + 'password2' => $da_newpass, + 'api' => '1', ]); $response = $Socket->fetch_parsed_body(); @@ -88,37 +88,37 @@ public function save($curpass, $passwd) */ class HTTPSocket { - var $version = '3.0.2'; + public $version = '3.0.2'; // all vars are private except $error, $query_cache, and $doFollowLocationHeader - var $method = 'GET'; - - var $remote_host; - var $remote_port; - var $remote_uname; - var $remote_passwd; - - var $result; - var $result_header; - var $result_body; - var $result_status_code; - - var $lastTransferSpeed; - var $bind_host; - var $error = []; - var $warn = []; - var $query_cache = []; - var $doFollowLocationHeader = true; - var $redirectURL; - var $max_redirects = 5; - var $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://'; - var $extra_headers = []; + public $method = 'GET'; + + public $remote_host; + public $remote_port; + public $remote_uname; + public $remote_passwd; + + public $result; + public $result_header; + public $result_body; + public $result_status_code; + + public $lastTransferSpeed; + public $bind_host; + public $error = []; + public $warn = []; + public $query_cache = []; + public $doFollowLocationHeader = true; + public $redirectURL; + public $max_redirects = 5; + public $ssl_setting_message = 'DirectAdmin appears to be using SSL. Change your script to connect to ssl://'; + public $extra_headers = []; /** * Create server "connection". */ - function connect($host, $port = '') + public function connect($host, $port = '') { if (!is_numeric($port)) { $port = 2222; @@ -128,7 +128,7 @@ function connect($host, $port = '') $this->remote_port = $port; } - function bind($ip = '') + public function bind($ip = '') { if ($ip == '') { $ip = $_SERVER['SERVER_ADDR']; @@ -142,7 +142,7 @@ function bind($ip = '') * * @param string|null $method request method. supports GET, POST, and HEAD. default is GET */ - function set_method($method = 'GET') + public function set_method($method = 'GET') { $this->method = strtoupper($method); } @@ -153,7 +153,7 @@ function set_method($method = 'GET') * @param string|null $uname username. default is null * @param string|null $passwd password. default is null */ - function set_login($uname = '', $passwd = '') + public function set_login($uname = '', $passwd = '') { if (strlen($uname) > 0) { $this->remote_uname = $uname; @@ -170,7 +170,7 @@ function set_login($uname = '', $passwd = '') * @param string $request containing properly formatted server API. See DA API docs and examples. Http:// URLs O.K. too. * @param string|array $content query to pass to url */ - function query($request, $content = '') + public function query($request, $content = '') { $this->error = $this->warn = []; $this->result_status_code = null; @@ -178,13 +178,12 @@ function query($request, $content = '') $is_ssl = false; // is our request a http:// ... ? - if (preg_match('!^http://!i',$request) || preg_match('!^https://!i',$request)) { + if (preg_match('!^http://!i', $request) || preg_match('!^https://!i', $request)) { $location = parse_url($request); - if (preg_match('!^https://!i',$request)) { - $this->connect('https://' . $location['host'],$location['port']); - } - else { - $this->connect('http://' . $location['host'],$location['port']); + if (preg_match('!^https://!i', $request)) { + $this->connect('https://' . $location['host'], $location['port']); + } else { + $this->connect('http://' . $location['host'], $location['port']); } $this->set_login($location['user'], $location['pass']); @@ -232,7 +231,7 @@ function query($request, $content = '') $pairs[] = "$key=" . urlencode($value); } - $content = implode('&',$pairs); + $content = implode('&', $pairs); unset($pairs); } @@ -251,7 +250,7 @@ function query($request, $content = '') } curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); - curl_setopt($ch, \CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, \CURLOPT_USERAGENT, "HTTPSocket/$this->version"); curl_setopt($ch, \CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, \CURLOPT_TIMEOUT, 100); @@ -328,7 +327,7 @@ function query($request, $content = '') } } - function getTransferSpeed() + public function getTransferSpeed() { return $this->lastTransferSpeed; } @@ -341,7 +340,7 @@ function getTransferSpeed() * * @return string result body */ - function get($location, $asArray = false) + public function get($location, $asArray = false) { $this->query($location); @@ -364,7 +363,7 @@ function get($location, $asArray = false) * * @return int status code */ - function get_status_code() + public function get_status_code() { return $this->result_status_code; } @@ -375,7 +374,7 @@ function get_status_code() * @param string $key header name * @param string $value header value */ - function add_header($key, $value) + public function add_header($key, $value) { $this->extra_headers[$key] = $value; } @@ -383,7 +382,7 @@ function add_header($key, $value) /** * Clears any extra headers. */ - function clear_headers() + public function clear_headers() { $this->extra_headers = []; } @@ -393,7 +392,7 @@ function clear_headers() * * @return string result */ - function fetch_result() + public function fetch_result() { return $this->result; } @@ -405,7 +404,7 @@ function fetch_result() * * @return array result header */ - function fetch_header($header = '') + public function fetch_header($header = '') { $array_headers = preg_split("/\r\n/", $this->result_header); @@ -432,7 +431,7 @@ function fetch_header($header = '') * * @return string result body */ - function fetch_body() + public function fetch_body() { return $this->result_body; } @@ -442,7 +441,7 @@ function fetch_body() * * @return array result parsed */ - function fetch_parsed_body() + public function fetch_parsed_body() { parse_str($this->result_body, $x); return $x; @@ -451,7 +450,7 @@ function fetch_parsed_body() /** * Set a specific message on how to change the SSL setting, in the event that it's not set correctly. */ - function set_ssl_setting_message($str) + public function set_ssl_setting_message($str) { $this->ssl_setting_message = $str; } diff --git a/plugins/password/drivers/domainfactory.php b/plugins/password/drivers/domainfactory.php index 03b71aa38a..41cc0a04bb 100644 --- a/plugins/password/drivers/domainfactory.php +++ b/plugins/password/drivers/domainfactory.php @@ -30,7 +30,7 @@ class rcube_domainfactory_password { - function save($curpass, $passwd, $username) + public function save($curpass, $passwd, $username) { if ($ch = curl_init()) { // initial login @@ -78,16 +78,13 @@ function save($curpass, $passwd, $username) return ['code' => PASSWORD_ERROR, 'message' => $error_message]; } } - } - else { + } else { return PASSWORD_CONNECT_ERROR; } - } - else { + } else { return PASSWORD_CONNECT_ERROR; } - } - else { + } else { return PASSWORD_CONNECT_ERROR; } diff --git a/plugins/password/drivers/dovecot_passwdfile.php b/plugins/password/drivers/dovecot_passwdfile.php index 91e4c16212..47f95e6a40 100644 --- a/plugins/password/drivers/dovecot_passwdfile.php +++ b/plugins/password/drivers/dovecot_passwdfile.php @@ -52,11 +52,9 @@ public function save($currpass, $newpass, $username) if (empty($fp)) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Unable to read password file $mailuserfile.", - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Unable to read password file $mailuserfile.", + ], true, false); return PASSWORD_CONNECT_ERROR; } @@ -85,11 +83,9 @@ public function save($currpass, $newpass, $username) fclose($fp); rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Failed to save file $mailuserfile.", - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Failed to save file $mailuserfile.", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/expect.php b/plugins/password/drivers/expect.php index bcc06ae968..0c1c324e3c 100644 --- a/plugins/password/drivers/expect.php +++ b/plugins/password/drivers/expect.php @@ -61,12 +61,11 @@ public function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $cmd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/gearman.php b/plugins/password/drivers/gearman.php index 0369c1c402..b591fe193d 100644 --- a/plugins/password/drivers/gearman.php +++ b/plugins/password/drivers/gearman.php @@ -28,7 +28,7 @@ class rcube_gearman_password { - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { if (extension_loaded('gearman')) { $rcmail = rcmail::get_instance(); @@ -49,21 +49,18 @@ function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Gearman authentication failed for user $username", - ], true, false - ); - } - else { + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Gearman authentication failed for user $username", + ], true, false); + } else { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => 'Password plugin: PECL Gearman module not loaded', - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'Password plugin: PECL Gearman module not loaded', + ], true, false); } return PASSWORD_ERROR; diff --git a/plugins/password/drivers/hmail.php b/plugins/password/drivers/hmail.php index b01bd0ed7b..96923e2a8d 100644 --- a/plugins/password/drivers/hmail.php +++ b/plugins/password/drivers/hmail.php @@ -33,25 +33,22 @@ public function save($curpass, $passwd, $username) $remote = $rcmail->config->get('hmailserver_remote_dcom', false); if ($remote) { $obApp = new COM('hMailServer.Application', $rcmail->config->get('hmailserver_server')); - } - else { + } else { $obApp = new COM('hMailServer.Application'); } - } - catch (Exception $e) { + } catch (Exception $e) { rcube::write_log('errors', 'Plugin password (hmail driver): ' . trim(strip_tags($e->getMessage()))); rcube::write_log('errors', 'Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.'); return PASSWORD_ERROR; } - if (strstr($username,'@')) { + if (strstr($username, '@')) { [, $domain] = explode('@', $username); - } - else { - $domain = $rcmail->config->get('username_domain',false); + } else { + $domain = $rcmail->config->get('username_domain', false); if (!$domain) { - rcube::write_log('errors','Plugin password (hmail driver): $config[\'username_domain\'] is not defined.'); + rcube::write_log('errors', 'Plugin password (hmail driver): $config[\'username_domain\'] is not defined.'); return PASSWORD_ERROR; } $username = $username . '@' . $domain; @@ -66,8 +63,7 @@ public function save($curpass, $passwd, $username) $obAccount->Save(); return PASSWORD_SUCCESS; - } - catch (Exception $e) { + } catch (Exception $e) { rcube::write_log('errors', 'Plugin password (hmail driver): ' . trim(strip_tags($e->getMessage()))); rcube::write_log('errors', 'Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.'); diff --git a/plugins/password/drivers/httpapi.php b/plugins/password/drivers/httpapi.php index 05180a80de..6e0a07ebb6 100644 --- a/plugins/password/drivers/httpapi.php +++ b/plugins/password/drivers/httpapi.php @@ -44,7 +44,7 @@ class rcube_httpapi_password * * @return int PASSWORD_SUCCESS|PASSWORD_ERROR|PASSWORD_CONNECT_ERROR */ - function save($curpass, $newpass, $username) + public function save($curpass, $newpass, $username) { $rcmail = rcmail::get_instance(); $client = password::get_http_client(); @@ -77,17 +77,13 @@ function save($curpass, $newpass, $username) if ($method == 'POST') { $params['form_params'] = $vars; - } - elseif ($method == 'GET') { + } elseif ($method == 'GET') { $params['query'] = $vars; - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Invalid httpapi method', - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Invalid httpapi method', + ], true, false); return PASSWORD_CONNECT_ERROR; } @@ -97,14 +93,11 @@ function save($curpass, $newpass, $username) $response_code = $response->getStatusCode(); $result = $response->getBody(); - } - catch (Exception $e) { + } catch (Exception $e) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: ' . $e->getMessage(), - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: ' . $e->getMessage(), + ], true, false); return PASSWORD_CONNECT_ERROR; } @@ -112,12 +105,10 @@ function save($curpass, $newpass, $username) // Non-2xx response codes mean the password change failed if ($response_code < 200 || $response_code > 299) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Unexpected response code {$response_code}: " - . substr($result, 0, 1024), - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Unexpected response code {$response_code}: " + . substr($result, 0, 1024), + ], true, false); return ($response_code == 404 || $response_code > 499) ? PASSWORD_CONNECT_ERROR : PASSWORD_ERROR; } @@ -125,11 +116,9 @@ function save($curpass, $newpass, $username) // If configured, check the body of the response if ($expect && !preg_match($expect, $result)) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Unexpected response body: ' . substr($result, 0, 1024), - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Unexpected response body: ' . substr($result, 0, 1024), + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/kpasswd.php b/plugins/password/drivers/kpasswd.php index 39c5d617e4..691eaf5766 100644 --- a/plugins/password/drivers/kpasswd.php +++ b/plugins/password/drivers/kpasswd.php @@ -33,12 +33,11 @@ public function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $cmd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index c912be850d..0c3d542d73 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -40,8 +40,7 @@ public function save($curpass, $passwd) // Building user DN if ($userDN = $rcmail->config->get('password_ldap_userDN_mask')) { $userDN = rcube_ldap_simple_password::substitute_vars($userDN); - } - else { + } else { $userDN = $this->search_userdn($rcmail); } @@ -156,7 +155,7 @@ public function save($curpass, $passwd) * Use search_base and search_filter defined in config file. * Return the found DN. */ - function search_userdn($rcmail) + public function search_userdn($rcmail) { $binddn = $rcmail->config->get('password_ldap_searchDN'); $bindpw = $rcmail->config->get('password_ldap_searchPW'); diff --git a/plugins/password/drivers/ldap_exop.php b/plugins/password/drivers/ldap_exop.php index 5842b70bec..2cc5a4866a 100644 --- a/plugins/password/drivers/ldap_exop.php +++ b/plugins/password/drivers/ldap_exop.php @@ -31,16 +31,14 @@ class rcube_ldap_exop_password extends rcube_ldap_simple_password { - function save($curpass, $passwd) + public function save($curpass, $passwd) { if (!function_exists('ldap_exop_passwd')) { rcube::raise_error([ - 'code' => 100, 'type' => 'ldap', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'ldap_exop_passwd not supported', - ], - true - ); + 'code' => 100, 'type' => 'ldap', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'ldap_exop_passwd not supported', + ], true); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/ldap_ppolicy.php b/plugins/password/drivers/ldap_ppolicy.php index a0a7b0cd9e..b756dc7ef3 100644 --- a/plugins/password/drivers/ldap_ppolicy.php +++ b/plugins/password/drivers/ldap_ppolicy.php @@ -87,9 +87,9 @@ public function save($currpass, $newpass, $username) return PASSWORD_CONNECT_ERROR; default: rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Failed to execute command: $cmd. Output: $result. Error: $stderr", - ], true, false); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Failed to execute command: $cmd. Output: $result. Error: $stderr", + ], true, false); } } diff --git a/plugins/password/drivers/ldap_samba_ad.php b/plugins/password/drivers/ldap_samba_ad.php index 59db98d310..f90f14cbbf 100644 --- a/plugins/password/drivers/ldap_samba_ad.php +++ b/plugins/password/drivers/ldap_samba_ad.php @@ -32,16 +32,14 @@ class rcube_ldap_samba_ad_password extends rcube_ldap_simple_password { - function save($curpass, $passwd) + public function save($curpass, $passwd) { if (!function_exists('ldap_mod_replace')) { rcube::raise_error([ - 'code' => 100, 'type' => 'ldap', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'ldap_mod_replace() not supported', - ], - true - ); + 'code' => 100, 'type' => 'ldap', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'ldap_mod_replace() not supported', + ], true); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php index fe943fb318..1839b5c374 100644 --- a/plugins/password/drivers/ldap_simple.php +++ b/plugins/password/drivers/ldap_simple.php @@ -113,7 +113,7 @@ public function save($curpass, $passwd) /** * Connect and bind to LDAP server */ - function connect($curpass) + public function connect($curpass) { $rcmail = rcmail::get_instance(); @@ -129,12 +129,10 @@ function connect($curpass) $this->_debug('S: NOT OK'); rcube::raise_error([ - 'code' => 100, 'type' => 'ldap', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Could not connect to LDAP server', - ], - true - ); + 'code' => 100, 'type' => 'ldap', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Could not connect to LDAP server', + ], true); return PASSWORD_CONNECT_ERROR; } @@ -161,11 +159,9 @@ function connect($curpass) // Build user DN if (!empty($plugin['user_dn'])) { $user_dn = $plugin['user_dn']; - } - elseif ($user_dn = $rcmail->config->get('password_ldap_userDN_mask')) { + } elseif ($user_dn = $rcmail->config->get('password_ldap_userDN_mask')) { $user_dn = self::substitute_vars($user_dn); - } - else { + } else { $user_dn = $this->search_userdn($rcmail, $ds); } @@ -227,7 +223,7 @@ function connect($curpass) * Use search_base and search_filter defined in config file * Return the found DN */ - function search_userdn($rcmail, $ds) + public function search_userdn($rcmail, $ds) { $search_user = $rcmail->config->get('password_ldap_searchDN'); $search_pass = $rcmail->config->get('password_ldap_searchPW'); @@ -308,8 +304,7 @@ public static function substitute_vars($str) $str = str_replace('%dc', $dc, $str); $str = str_replace('%domain', $parts[1], $str); $str = str_replace('%d', $parts[1], $str); - } - elseif (count($parts) == 1) { + } elseif (count($parts) == 1) { $str = str_replace('%name', $parts[0], $str); $str = str_replace('%n', $parts[0], $str); } diff --git a/plugins/password/drivers/mailcow.php b/plugins/password/drivers/mailcow.php index c2c301a390..28d1959898 100644 --- a/plugins/password/drivers/mailcow.php +++ b/plugins/password/drivers/mailcow.php @@ -27,7 +27,7 @@ class rcube_mailcow_password { - function save($curpass, $passwd, $username) + public function save($curpass, $passwd, $username) { $rcmail = rcmail::get_instance(); @@ -59,24 +59,21 @@ function save($curpass, $passwd, $username) 'json' => $cowdata, ]); - $cowreply = json_decode($response->getBody(),true); + $cowreply = json_decode($response->getBody(), true); if ($cowreply[0]['type'] == 'success') { return PASSWORD_SUCCESS; } return PASSWORD_ERROR; - } - catch (Exception $e) { + } catch (Exception $e) { $result = $e->getMessage(); } rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Problem with Mailcow API: $result", - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Problem with Mailcow API: $result", + ], true, false); return PASSWORD_CONNECT_ERROR; } diff --git a/plugins/password/drivers/miab.php b/plugins/password/drivers/miab.php index 2c4b9b5c20..1dba6d0d74 100644 --- a/plugins/password/drivers/miab.php +++ b/plugins/password/drivers/miab.php @@ -62,17 +62,14 @@ public function save($currpass, $newpass, $username) ) { return PASSWORD_SUCCESS; } - } - catch (Exception $e) { + } catch (Exception $e) { $result = $e->getMessage(); } rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Unable to change password. $result", - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Unable to change password. $result", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/modoboa.php b/plugins/password/drivers/modoboa.php index 7d7af142c2..a506e251b9 100644 --- a/plugins/password/drivers/modoboa.php +++ b/plugins/password/drivers/modoboa.php @@ -36,7 +36,7 @@ class rcube_modoboa_password { - function save($curpass, $passwd) + public function save($curpass, $passwd) { // Init config access $rcmail = rcmail::get_instance(); diff --git a/plugins/password/drivers/pam.php b/plugins/password/drivers/pam.php index addd471ab3..490785638e 100644 --- a/plugins/password/drivers/pam.php +++ b/plugins/password/drivers/pam.php @@ -25,7 +25,7 @@ class rcube_pam_password { - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { $error = ''; @@ -34,25 +34,21 @@ function save($currpass, $newpass, $username) if (pam_chpass($username, $currpass, $newpass)) { return PASSWORD_SUCCESS; } - } - else { + } else { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: PAM authentication failed for user $username: $error", - ], true, false - ); - } - } - else { - rcube::raise_error([ 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: PECL-PAM module not loaded', - ], true, false - ); + 'message' => "Password plugin: PAM authentication failed for user $username: $error", + ], true, false); + } + } else { + rcube::raise_error([ + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'Password plugin: PECL-PAM module not loaded', + ], true, false); } return PASSWORD_ERROR; diff --git a/plugins/password/drivers/plesk.php b/plugins/password/drivers/plesk.php index 84e3422e38..8a382614e9 100644 --- a/plugins/password/drivers/plesk.php +++ b/plugins/password/drivers/plesk.php @@ -51,7 +51,7 @@ class rcube_plesk_password * * @return int PASSWORD_SUCCESS|PASSWORD_ERROR */ - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { // get config $rcmail = rcmail::get_instance(); @@ -62,7 +62,7 @@ function save($currpass, $newpass, $username) $path = $rcmail->config->get('password_plesk_rpc_path'); // create plesk-object - $plesk = new plesk_rpc; + $plesk = new plesk_rpc(); $plesk->init($host, $port, $path, $user, $pass); // try to change password and return the status @@ -106,7 +106,7 @@ class plesk_rpc * * @return void */ - function init($host, $port, $path, $user, $pass) + public function init($host, $port, $path, $user, $pass) { $headers = [ sprintf('HTTP_AUTH_LOGIN: %s', $user), @@ -117,11 +117,11 @@ function init($host, $port, $path, $user, $pass) $url = sprintf('https://%s:%s/%s', $host, $port, $path); $this->curl = curl_init(); - curl_setopt($this->curl, \CURLOPT_CONNECTTIMEOUT , 5); - curl_setopt($this->curl, \CURLOPT_SSL_VERIFYHOST , 0); - curl_setopt($this->curl, \CURLOPT_SSL_VERIFYPEER , false); - curl_setopt($this->curl, \CURLOPT_HTTPHEADER , $headers); - curl_setopt($this->curl, \CURLOPT_URL , $url); + curl_setopt($this->curl, \CURLOPT_CONNECTTIMEOUT, 5); + curl_setopt($this->curl, \CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($this->curl, \CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($this->curl, \CURLOPT_HTTPHEADER, $headers); + curl_setopt($this->curl, \CURLOPT_URL, $url); } /** @@ -131,7 +131,7 @@ function init($host, $port, $path, $user, $pass) * * @return string Response body */ - function send_request($packet) + public function send_request($packet) { curl_setopt($this->curl, \CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl, \CURLOPT_POSTFIELDS, $packet); @@ -143,7 +143,7 @@ function send_request($packet) /** * close curl */ - function destroy() + public function destroy() { curl_close($this->curl); } @@ -155,7 +155,7 @@ function destroy() * * @return object SimpleXML object */ - function domain_info($domain) + public function domain_info($domain) { // build xml $request = new SimpleXMLElement(''); @@ -198,7 +198,7 @@ function domain_info($domain) * * @return int Domain ID */ - function get_domain_id($domain) + public function get_domain_id($domain) { if ($xml = $this->domain_info($domain)) { return intval($xml->site->get->result->id); @@ -213,7 +213,7 @@ function get_domain_id($domain) * * @return bool */ - function change_mailbox_password($mailbox, $newpass) + public function change_mailbox_password($mailbox, $newpass) { [$user, $domain] = explode('@', $mailbox); $domain_id = $this->get_domain_id($domain); diff --git a/plugins/password/drivers/poppassd.php b/plugins/password/drivers/poppassd.php index 09131af6d3..700af10b36 100644 --- a/plugins/password/drivers/poppassd.php +++ b/plugins/password/drivers/poppassd.php @@ -27,7 +27,7 @@ class rcube_poppassd_password { - function format_error_result($code, $line) + public function format_error_result($code, $line) { if (preg_match('/^\d\d\d\s+(\S.*)\s*$/', $line, $matches)) { return ['code' => $code, 'message' => $matches[1]]; @@ -36,7 +36,7 @@ function format_error_result($code, $line) return $code; } - function save($curpass, $passwd, $username) + public function save($curpass, $passwd, $username) { $rcmail = rcmail::get_instance(); $poppassd = new Net_Socket(); diff --git a/plugins/password/drivers/pw_usermod.php b/plugins/password/drivers/pw_usermod.php index 0dfbc9f1ce..da93f43ac3 100644 --- a/plugins/password/drivers/pw_usermod.php +++ b/plugins/password/drivers/pw_usermod.php @@ -44,12 +44,11 @@ public function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $cmd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/pwned.php b/plugins/password/drivers/pwned.php index 573f8a8496..8d409637ec 100644 --- a/plugins/password/drivers/pwned.php +++ b/plugins/password/drivers/pwned.php @@ -57,22 +57,22 @@ class rcube_pwned_password { // API URL. Note: the trailing slash is mandatory. - const API_URL = 'https://api.pwnedpasswords.com/range/'; + public const API_URL = 'https://api.pwnedpasswords.com/range/'; // See https://www.troyhunt.com/enhancing-pwned-passwords-privacy-with-padding/ - const ENHANCED_PRIVACY_CURL = 1; + public const ENHANCED_PRIVACY_CURL = 1; // Score constants, these directly correspond to the score that is returned. - const SCORE_LISTED = 1; - const SCORE_ERROR = 2; - const SCORE_NOT_LISTED = 3; + public const SCORE_LISTED = 1; + public const SCORE_ERROR = 2; + public const SCORE_NOT_LISTED = 3; /** * Rule description. * * @return array human-readable description of the check rule. */ - function strength_rules() + public function strength_rules() { $rc = rcmail::get_instance(); $href = 'https://haveibeenpwned.com/Passwords'; @@ -91,7 +91,7 @@ function strength_rules() * * @return array password score (1 to 3) and (optional) reason message */ - function check_strength($passwd) + public function check_strength($passwd) { $score = $this->check_pwned($passwd); $message = null; @@ -100,8 +100,7 @@ function check_strength($passwd) $rc = rcmail::get_instance(); if ($score === self::SCORE_LISTED) { $message = $rc->gettext('password.pwned_isdisclosed'); - } - else { + } else { $message = $rc->gettext('password.pwned_fetcherror'); } } @@ -116,7 +115,7 @@ function check_strength($passwd) * * @return int score, one of the SCORE_* constants (between 1 and 3). */ - function check_pwned($passwd) + public function check_pwned($passwd) { // initialize with error score $result = self::SCORE_ERROR; @@ -124,8 +123,7 @@ function check_pwned($passwd) if (!$this->can_retrieve()) { // Log the fact that we cannot check because of configuration error. rcube::raise_error("Need curl or allow_url_fopen to check password strength with 'pwned'", true, true); - } - else { + } else { [$prefix, $suffix] = $this->hash_split($passwd); $suffixes = $this->retrieve_suffixes(self::API_URL . $prefix); @@ -138,7 +136,7 @@ function check_pwned($passwd) return $result; } - function hash_split($passwd) + public function hash_split($passwd) { $hash = strtolower(sha1($passwd)); $prefix = substr($hash, 0, 5); @@ -147,32 +145,31 @@ function hash_split($passwd) return [$prefix, $suffix]; } - function can_retrieve() + public function can_retrieve() { return $this->can_curl() || $this->can_fopen(); } - function can_curl() + public function can_curl() { return function_exists('curl_init'); } - function can_fopen() + public function can_fopen() { return ini_get('allow_url_fopen'); } - function retrieve_suffixes($url) + public function retrieve_suffixes($url) { if ($this->can_curl()) { return $this->retrieve_curl($url); - } - else { + } else { return $this->retrieve_fopen($url); } } - function retrieve_curl($url) + public function retrieve_curl($url) { $ch = curl_init(); curl_setopt($ch, \CURLOPT_URL, $url); @@ -186,7 +183,7 @@ function retrieve_curl($url) return $output; } - function retrieve_fopen($url) + public function retrieve_fopen($url) { $output = ''; $ch = fopen($url, 'r'); @@ -198,7 +195,7 @@ function retrieve_fopen($url) return $output; } - function check_suffix_in_list($candidate, $list) + public function check_suffix_in_list($candidate, $list) { // initialize to error in case there are no lines at all $result = self::SCORE_ERROR; @@ -215,8 +212,7 @@ function check_suffix_in_list($candidate, $list) // valid line, not matching the current password $result = self::SCORE_NOT_LISTED; - } - else { + } else { // invalid line return self::SCORE_ERROR; } diff --git a/plugins/password/drivers/sasl.php b/plugins/password/drivers/sasl.php index 937936ed3a..d9c40bf8a1 100644 --- a/plugins/password/drivers/sasl.php +++ b/plugins/password/drivers/sasl.php @@ -34,7 +34,7 @@ class rcube_sasl_password { - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { $curdir = RCUBE_PLUGINS_DIR . 'password/helpers'; $username = escapeshellarg($username); @@ -50,12 +50,11 @@ function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/smb.php b/plugins/password/drivers/smb.php index 3c48db4295..68b21db85e 100644 --- a/plugins/password/drivers/smb.php +++ b/plugins/password/drivers/smb.php @@ -60,12 +60,11 @@ public function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $cmd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/sql.php b/plugins/password/drivers/sql.php index 0f52bde034..df2a85ba06 100644 --- a/plugins/password/drivers/sql.php +++ b/plugins/password/drivers/sql.php @@ -34,7 +34,7 @@ class rcube_sql_password * * @return int Result */ - function save($curpass, $passwd) + public function save($curpass, $passwd) { $rcmail = rcmail::get_instance(); @@ -45,8 +45,7 @@ function save($curpass, $passwd) if ($dsn = $rcmail->config->get('password_db_dsn')) { $db = rcube_db::factory(self::parse_dsn($dsn), '', false); $db->set_debug((bool) $rcmail->config->get('sql_debug')); - } - else { + } else { $db = $rcmail->get_dbh(); } @@ -62,7 +61,7 @@ function save($curpass, $passwd) return PASSWORD_CRYPT_ERROR; } - $sql = str_replace('%P', $db->quote($password), $sql); + $sql = str_replace('%P', $db->quote($password), $sql); } // old password - default hash method @@ -73,7 +72,7 @@ function save($curpass, $passwd) return PASSWORD_CRYPT_ERROR; } - $sql = str_replace('%O', $db->quote($password), $sql); + $sql = str_replace('%O', $db->quote($password), $sql); } // Handle clear text passwords securely (#1487034) @@ -83,8 +82,7 @@ function save($curpass, $passwd) if ($var == '%p') { $sql = preg_replace('/%p/', '?', $sql, 1); $sql_vars[] = (string) $passwd; - } - else { // %o + } else { // %o $sql = preg_replace('/%o/', '?', $sql, 1); $sql_vars[] = (string) $curpass; } @@ -101,8 +99,7 @@ function save($curpass, $passwd) $domain_part = rcube_utils::idn_to_ascii($domain_part); $username = rcube_utils::idn_to_ascii($username); $host = rcube_utils::idn_to_ascii($host); - } - else { + } else { $domain_part = rcube_utils::idn_to_utf8($domain_part); $username = rcube_utils::idn_to_utf8($username); $host = rcube_utils::idn_to_utf8($host); @@ -117,12 +114,11 @@ function save($curpass, $passwd) $res = $db->query($sql, $sql_vars); if (!$db->is_error()) { - if (strtolower(substr(trim($sql),0,6)) == 'select') { + if (strtolower(substr(trim($sql), 0, 6)) == 'select') { if ($db->fetch_array($res)) { return PASSWORD_SUCCESS; } - } - else { + } else { // Note: Don't be tempted to check affected_rows = 1. For some queries // (e.g. INSERT ... ON DUPLICATE KEY UPDATE) the result can be 2. if ($db->affected_rows($res) > 0) { diff --git a/plugins/password/drivers/tinycp.php b/plugins/password/drivers/tinycp.php index 564bbd2472..694916b389 100644 --- a/plugins/password/drivers/tinycp.php +++ b/plugins/password/drivers/tinycp.php @@ -44,22 +44,18 @@ public function save($currpass, $newpass, $username) $tcp = new TinyCPConnector($tinycp_host, $tinycp_port); $tcp->Auth($tinycp_user, $tinycp_pass); $tcp->mail___mailserver___email_pass_change2($username, $newpass); - } - catch (Exception $e) { + } catch (Exception $e) { $error_message = $e->getMessage(); } - } - else { + } else { $error_message = 'Missing configuration value(s). '; } if ($error_message) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password driver: $error_message", - ], - true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password driver: $error_message", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/virtualmin.php b/plugins/password/drivers/virtualmin.php index 874d2ec0c2..7c550aaa93 100644 --- a/plugins/password/drivers/virtualmin.php +++ b/plugins/password/drivers/virtualmin.php @@ -32,7 +32,7 @@ class rcube_virtualmin_password { - function save($currpass, $newpass, $username) + public function save($currpass, $newpass, $username) { $curdir = RCUBE_PLUGINS_DIR . 'password/helpers'; $username = escapeshellarg($username); @@ -42,16 +42,14 @@ function save($currpass, $newpass, $username) if ($returnvalue == 0 && count($output_domain) == 1) { $domain = trim($output_domain[0]); - } - else { + } else { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $curdir/chgvirtualminpasswd " - . "or domain for mail-user '$username' not known to Virtualmin", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $curdir/chgvirtualminpasswd " + . "or domain for mail-user '$username' not known to Virtualmin", + ], true, false); return PASSWORD_ERROR; } @@ -66,12 +64,11 @@ function save($currpass, $newpass, $username) } rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => "Password plugin: Unable to execute $curdir/chgvirtualminpasswd", - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $curdir/chgvirtualminpasswd", + ], true, false); return PASSWORD_ERROR; } diff --git a/plugins/password/drivers/vpopmaild.php b/plugins/password/drivers/vpopmaild.php index c2eced376b..220408a1c5 100644 --- a/plugins/password/drivers/vpopmaild.php +++ b/plugins/password/drivers/vpopmaild.php @@ -27,7 +27,7 @@ class rcube_vpopmaild_password { - function save($curpass, $passwd, $username) + public function save($curpass, $passwd, $username) { $rcmail = rcmail::get_instance(); $vpopmaild = new Net_Socket(); @@ -39,7 +39,7 @@ function save($curpass, $passwd, $username) return PASSWORD_CONNECT_ERROR; } - $vpopmaild->setTimeout($rcmail->config->get('password_vpopmaild_timeout'),0); + $vpopmaild->setTimeout($rcmail->config->get('password_vpopmaild_timeout'), 0); $result = $vpopmaild->readLine(); if (!preg_match('/^\+OK/', $result)) { diff --git a/plugins/password/drivers/ximss.php b/plugins/password/drivers/ximss.php index 54ba61a363..218124b934 100644 --- a/plugins/password/drivers/ximss.php +++ b/plugins/password/drivers/ximss.php @@ -34,7 +34,7 @@ class rcube_ximss_password { - function save($pass, $newpass, $username) + public function save($pass, $newpass, $username) { $rcmail = rcmail::get_instance(); @@ -74,13 +74,11 @@ function save($pass, $newpass, $username) if (isset($resp->response[0]['errorNum'])) { return PASSWORD_CONNECT_ERROR; } - } - elseif ($id == 'A002') { + } elseif ($id == 'A002') { if (isset($resp->response[0]['errorNum'])) { return PASSWORD_ERROR; } - } - elseif ($id == 'A003') { + } elseif ($id == 'A003') { if (isset($resp->response[0]['errorNum'])) { // There was a problem during logout (This is probably harmless) } diff --git a/plugins/password/drivers/xmail.php b/plugins/password/drivers/xmail.php index 3231ec2069..30cde550f0 100644 --- a/plugins/password/drivers/xmail.php +++ b/plugins/password/drivers/xmail.php @@ -35,12 +35,12 @@ class rcube_xmail_password { - function save($currpass, $newpass) + public function save($currpass, $newpass) { $rcmail = rcmail::get_instance(); [$user, $domain] = explode('@', $_SESSION['username']); - $xmail = new XMail; + $xmail = new XMail(); $xmail->hostname = $rcmail->config->get('xmail_host'); $xmail->username = $rcmail->config->get('xmail_user'); @@ -49,12 +49,11 @@ function save($currpass, $newpass) if (!$xmail->connect()) { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => 'Password plugin: Unable to connect to mail server', - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'Password plugin: Unable to connect to mail server', + ], true, false); return PASSWORD_CONNECT_ERROR; } @@ -62,12 +61,11 @@ function save($currpass, $newpass) if (!$xmail->send("userpasswd\t" . $domain . "\t" . $user . "\t" . $newpass . "\n")) { $xmail->close(); rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => 'Password plugin: Unable to change password', - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'Password plugin: Unable to change password', + ], true, false); return PASSWORD_ERROR; } @@ -79,22 +77,22 @@ function save($currpass, $newpass) class XMail { - var $socket; - var $hostname = 'localhost'; - var $username = 'xmail'; - var $password = ''; - var $port = 6017; + public $socket; + public $hostname = 'localhost'; + public $username = 'xmail'; + public $password = ''; + public $port = 6017; - function send($msg) + public function send($msg) { - socket_write($this->socket,$msg); - if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ),0,1) != '+') { + socket_write($this->socket, $msg); + if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ), 0, 1) != '+') { return false; } return true; } - function connect() + public function connect() { $this->socket = socket_create(\AF_INET, \SOCK_STREAM, 0); if ($this->socket < 0) { @@ -107,7 +105,7 @@ function connect() return false; } - if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ),0,1) != '+') { + if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ), 0, 1) != '+') { socket_close($this->socket); return false; } @@ -119,7 +117,7 @@ function connect() return true; } - function close() + public function close() { $this->send("quit\n"); socket_close($this->socket); diff --git a/plugins/password/drivers/zxcvbn.php b/plugins/password/drivers/zxcvbn.php index 7979bd5244..a0b7a4d2d1 100644 --- a/plugins/password/drivers/zxcvbn.php +++ b/plugins/password/drivers/zxcvbn.php @@ -27,7 +27,7 @@ class rcube_zxcvbn_password { - function strength_rules() + public function strength_rules() { $rcmail = rcmail::get_instance(); $rules = [ @@ -45,16 +45,15 @@ function strength_rules() * * @return array Score (1 to 5) and Reason */ - function check_strength($passwd) + public function check_strength($passwd) { if (!class_exists('ZxcvbnPhp\Zxcvbn')) { rcube::raise_error([ - 'code' => 600, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => 'Password plugin: Zxcvbn library not found.', - ], true, false - ); + 'code' => 600, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'Password plugin: Zxcvbn library not found.', + ], true, false); return; } diff --git a/plugins/password/password.php b/plugins/password/password.php index aea561a4ec..f4b44a5e4b 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -52,7 +52,7 @@ class password extends rcube_plugin private $rc; - function init() + public function init() { $this->rc = rcmail::get_instance(); @@ -88,7 +88,7 @@ function init() } } - function settings_actions($args) + public function settings_actions($args) { // register as settings action $args['actions'][] = [ @@ -102,7 +102,7 @@ function settings_actions($args) return $args; } - function password_init() + public function password_init() { $this->register_handler('plugin.body', [$this, 'password_form']); @@ -110,23 +110,21 @@ function password_init() if (rcube_utils::get_input_value('_first', rcube_utils::INPUT_GET)) { $this->rc->output->command('display_message', $this->gettext('firstloginchange'), 'notice'); - } - elseif (!empty($_SESSION['password_expires'])) { + } elseif (!empty($_SESSION['password_expires'])) { if ($_SESSION['password_expires'] == 1) { $this->rc->output->command('display_message', $this->gettext('passwdexpired'), 'error'); - } - else { + } else { $this->rc->output->command('display_message', $this->gettext([ - 'name' => 'passwdexpirewarning', - 'vars' => ['expirationdatetime' => $_SESSION['password_expires']], - ]), 'warning'); + 'name' => 'passwdexpirewarning', + 'vars' => ['expirationdatetime' => $_SESSION['password_expires']], + ]), 'warning'); } } $this->rc->output->send('plugin'); } - function password_save() + public function password_save() { $this->register_handler('plugin.body', [$this, 'password_form']); @@ -138,8 +136,7 @@ function password_save() if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd']) || !strlen($_POST['_newpasswd'])) { $this->rc->output->command('display_message', $this->gettext('nopassword'), 'error'); - } - else { + } else { $charset = strtoupper($this->rc->config->get('password_charset', 'UTF-8')); $rc_charset = strtoupper($this->rc->output->get_charset()); @@ -164,15 +161,12 @@ function password_save() // other passwords validity checks elseif ($conpwd != $newpwd) { $this->rc->output->command('display_message', $this->gettext('passwordinconsistency'), 'error'); - } - elseif ($confirm && ($res = $this->_compare($sesspwd, $curpwd, PASSWORD_COMPARE_CURRENT))) { + } elseif ($confirm && ($res = $this->_compare($sesspwd, $curpwd, PASSWORD_COMPARE_CURRENT))) { $this->rc->output->command('display_message', $res, 'error'); - } - elseif ($required_length && strlen($newpwd) < $required_length) { + } elseif ($required_length && strlen($newpwd) < $required_length) { $this->rc->output->command('display_message', $this->gettext( ['name' => 'passwordshort', 'vars' => ['length' => $required_length]]), 'error'); - } - elseif ($res = $this->_check_strength($newpwd)) { + } elseif ($res = $this->_check_strength($newpwd)) { $this->rc->output->command('display_message', $res, 'error'); } // password is the same as the old one, warn user, return error @@ -185,8 +179,8 @@ function password_save() // allow additional actions after password change (e.g. reset some backends) $plugin = $this->rc->plugins->exec_hook('password_change', [ - 'old_pass' => $curpwd, - 'new_pass' => $newpwd, + 'old_pass' => $curpwd, + 'new_pass' => $newpwd, ]); // Reset session password @@ -204,8 +198,7 @@ function password_save() // Remove expiration date/time $this->rc->session->remove('password_expires'); - } - else { + } else { $this->rc->output->command('display_message', $res, 'error'); } } @@ -214,7 +207,7 @@ function password_save() $this->rc->output->send('plugin'); } - function password_form() + public function password_form() { // add some labels to client $this->rc->output->add_label( @@ -234,10 +227,10 @@ function password_form() // show current password selection $field_id = 'curpasswd'; $input_curpasswd = new html_passwordfield([ - 'name' => '_curpasswd', - 'id' => $field_id, - 'size' => 20, - 'autocomplete' => 'off', + 'name' => '_curpasswd', + 'id' => $field_id, + 'size' => 20, + 'autocomplete' => 'off', ]); $table->add('title', html::label($field_id, rcube::Q($this->gettext('curpasswd')))); @@ -247,10 +240,10 @@ function password_form() // show new password selection $field_id = 'newpasswd'; $input_newpasswd = new html_passwordfield([ - 'name' => '_newpasswd', - 'id' => $field_id, - 'size' => 20, - 'autocomplete' => 'off', + 'name' => '_newpasswd', + 'id' => $field_id, + 'size' => 20, + 'autocomplete' => 'off', ]); $table->add('title', html::label($field_id, rcube::Q($this->gettext('newpasswd')))); @@ -259,10 +252,10 @@ function password_form() // show confirm password selection $field_id = 'confpasswd'; $input_confpasswd = new html_passwordfield([ - 'name' => '_confpasswd', - 'id' => $field_id, - 'size' => 20, - 'autocomplete' => 'off', + 'name' => '_confpasswd', + 'id' => $field_id, + 'size' => 20, + 'autocomplete' => 'off', ]); $table->add('title', html::label($field_id, rcube::Q($this->gettext('confpasswd')))); @@ -295,9 +288,9 @@ function password_form() } $submit_button = $this->rc->output->button([ - 'command' => 'plugin.password-save', - 'class' => 'button mainaction submit', - 'label' => 'save', + 'command' => 'plugin.password-save', + 'class' => 'button mainaction submit', + 'label' => 'save', ]); $form_buttons = html::p(['class' => 'formbuttons footerleft'], $submit_button); @@ -326,11 +319,9 @@ private function _compare($curpwd, $newpwd, $type) if (!$driver) { $result = $this->gettext('internalerror'); - } - elseif (method_exists($driver, 'compare')) { + } elseif (method_exists($driver, 'compare')) { $result = $driver->compare($curpwd, $newpwd, $type); - } - else { + } else { switch ($type) { case PASSWORD_COMPARE_CURRENT: $result = $curpwd != $newpwd ? $this->gettext('passwordincorrect') : null; @@ -352,8 +343,7 @@ private function _strength_rules() if (($driver = $this->_load_driver('strength')) && method_exists($driver, 'strength_rules')) { $result = $driver->strength_rules(); - } - elseif ($this->rc->config->get('password_minimum_score') > 1) { + } elseif ($this->rc->config->get('password_minimum_score') > 1) { $result = $this->gettext('passwordweak'); } @@ -374,8 +364,7 @@ private function _check_strength($passwd) if (($driver = $this->_load_driver('strength')) && method_exists($driver, 'check_strength')) { [$score, $reason] = $driver->check_strength($passwd); - } - else { + } else { $score = (!preg_match('/[0-9]/', $passwd) || !preg_match('/[^A-Za-z0-9]/', $passwd)) ? 1 : 5; } @@ -443,10 +432,9 @@ private function _load_driver($type = 'password') if (!file_exists($file)) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Driver file does not exist ($file)", - ], true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Driver file does not exist ($file)", + ], true, false); return false; } @@ -454,26 +442,25 @@ private function _load_driver($type = 'password') if (!class_exists($class, false) || (!method_exists($class, 'save') && !method_exists($class, 'check_strength'))) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Broken driver $driver", - ], true, false - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Broken driver $driver", + ], true, false); return false; } - $this->drivers[$type] = new $class; + $this->drivers[$type] = new $class(); } return $this->drivers[$type]; } - function user_create($args) + public function user_create($args) { $this->newuser = true; return $args; } - function login_after($args) + public function login_after($args) { if ($this->newuser && $this->check_host_login_exceptions()) { $this->rc->user->save_prefs(['newuserpassword' => true]); @@ -597,16 +584,13 @@ public static function hash_password($password, $method = '', $prefixed = true) case 'sha': if (function_exists('sha1')) { $crypted = pack('H*', sha1($password)); - } - elseif (function_exists('hash')) { + } elseif (function_exists('hash')) { $crypted = hash('sha1', $password, true); - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Your PHP installation does not have the hash() nor sha1() function', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Your PHP installation does not have the hash() nor sha1() function', + ], true, true); } $crypted = base64_encode($crypted); @@ -619,17 +603,14 @@ public static function hash_password($password, $method = '', $prefixed = true) if (function_exists('sha1')) { $salt = substr(pack('H*', sha1($salt . $password)), 0, 4); $crypted = sha1($password . $salt, true); - } - elseif (function_exists('hash')) { + } elseif (function_exists('hash')) { $salt = substr(pack('H*', hash('sha1', $salt . $password)), 0, 4); $crypted = hash('sha1', $password . $salt, true); - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Your PHP installation does not have the hash() nor sha1() function', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Your PHP installation does not have the hash() nor sha1() function', + ], true, true); } $crypted = base64_encode($crypted . $salt); @@ -643,13 +624,11 @@ public static function hash_password($password, $method = '', $prefixed = true) if (function_exists('hash')) { $salt = substr(pack('H*', hash('sha256', $salt . $password)), 0, 4); $crypted = hash('sha256', $password . $salt, true); - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Your PHP installation does not have the hash() function', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Your PHP installation does not have the hash() function', + ], true, true); } $crypted = base64_encode($crypted . $salt); @@ -662,13 +641,11 @@ public static function hash_password($password, $method = '', $prefixed = true) if (function_exists('hash')) { $salt = substr(pack('H*', hash('sha512', $salt . $password)), 0, 4); $crypted = hash('sha512', $password . $salt, true); - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Your PHP installation does not have the hash() function', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Your PHP installation does not have the hash() function', + ], true, true); } $crypted = base64_encode($crypted . $salt); @@ -681,8 +658,7 @@ public static function hash_password($password, $method = '', $prefixed = true) if (function_exists('hash')) { $salt = substr(pack('H*', hash('md5', $salt . $password)), 0, 4); $crypted = hash('md5', $password . $salt, true); - } - else { + } else { $salt = substr(pack('H*', md5($salt . $password)), 0, 4); $crypted = md5($password . $salt, true); } @@ -695,13 +671,11 @@ public static function hash_password($password, $method = '', $prefixed = true) if (function_exists('hash')) { $crypted = hash('md4', rcube_charset::convert($password, RCUBE_CHARSET, 'UTF-16LE')); $crypted = strtoupper($crypted); - } - else { + } else { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Your PHP installation does not have hash() function', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Your PHP installation does not have hash() function', + ], true, true); } break; @@ -724,9 +698,9 @@ public static function hash_password($password, $method = '', $prefixed = true) if (!$pipe) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Failed to execute command: $command", - ], true, false); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Failed to execute command: $command", + ], true, false); return false; } @@ -744,9 +718,9 @@ public static function hash_password($password, $method = '', $prefixed = true) if (!preg_match('/^\{' . $method . '\}/', $crypted)) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Failed to execute command: $command. Error: $stderr", - ], true, false); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Failed to execute command: $command. Error: $stderr", + ], true, false); return false; } @@ -784,19 +758,16 @@ public static function hash_password($password, $method = '', $prefixed = true) default: rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Password plugin: Hash method not supported.', - ], true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Password plugin: Hash method not supported.', + ], true, true); } if ($crypted === null || $crypted === false) { rcube::raise_error([ - 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, - 'message' => "Password plugin: Failed to hash password ($method). Check for configuration issues.", - ], - true, true - ); + 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Failed to hash password ($method). Check for configuration issues.", + ], true, true); } if ($prefixed && $prefixed !== true) { @@ -831,9 +802,9 @@ public static function username($format = null) } return strtr($format, [ - '%l' => $rcmail->user->get_username('local'), - '%d' => $rcmail->user->get_username('domain'), - '%u' => $_SESSION['username'], + '%l' => $rcmail->user->get_username('local'), + '%d' => $rcmail->user->get_username('domain'), + '%u' => $_SESSION['username'], ]); } diff --git a/plugins/password/tests/Password.php b/plugins/password/tests/Password.php index 637e75d3b3..4ee84bf79f 100644 --- a/plugins/password/tests/Password.php +++ b/plugins/password/tests/Password.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new password($rcube->plugins); @@ -22,7 +22,7 @@ function test_constructor() /** * A dummy test testing PHP syntax on password drivers */ - function test_all_drivers() + public function test_all_drivers() { if ($files = glob(__DIR__ . '/../drivers/*.php')) { foreach ($files as $file) { @@ -36,7 +36,7 @@ function test_all_drivers() /** * cpanel driver test */ - function test_driver_cpanel() + public function test_driver_cpanel() { $driver_class = $this->load_driver('cpanel'); @@ -81,7 +81,7 @@ function test_driver_cpanel() * * @return string driver's class name, example: "rcube_chpasswd_password" */ - function load_driver($driver) + public function load_driver($driver) { include_once __DIR__ . "/../drivers/$driver.php"; $driver_class = "rcube_{$driver}_password"; @@ -92,7 +92,7 @@ function load_driver($driver) /** * Test hash_password() */ - function test_hash_password() + public function test_hash_password() { $pass = password::hash_password('test', 'clear'); $this->assertSame('test', $pass); diff --git a/plugins/reconnect/reconnect.php b/plugins/reconnect/reconnect.php index dbf2818ecc..a2d1f112a3 100644 --- a/plugins/reconnect/reconnect.php +++ b/plugins/reconnect/reconnect.php @@ -15,7 +15,7 @@ class reconnect extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->add_hook('storage_connect', [$this, 'storage_connect']); } @@ -23,7 +23,7 @@ function init() /** * Storage_connect hook handler */ - function storage_connect($args) + public function storage_connect($args) { $rcmail = rcmail::get_instance(); diff --git a/plugins/redundant_attachments/redundant_attachments.php b/plugins/redundant_attachments/redundant_attachments.php index 006451dece..aa796cd8af 100644 --- a/plugins/redundant_attachments/redundant_attachments.php +++ b/plugins/redundant_attachments/redundant_attachments.php @@ -37,7 +37,7 @@ class redundant_attachments extends filesystem_attachments { // A prefix for the cache key used in the session and in the key field of the cache table - const PREFIX = 'ATTACH'; + public const PREFIX = 'ATTACH'; // rcube_cache instance for SQL DB private $cache; @@ -99,7 +99,7 @@ private function _key($args) /** * Save a newly uploaded attachment */ - function upload($args) + public function upload($args) { $args = parent::upload($args); @@ -125,7 +125,7 @@ function upload($args) /** * Save an attachment from a non-upload source (draft or forward) */ - function save($args) + public function save($args) { $args = parent::save($args); @@ -156,7 +156,7 @@ function save($args) * Remove an attachment from storage * This is triggered by the remove attachment button on the compose screen */ - function remove($args) + public function remove($args) { parent::remove($args); @@ -180,7 +180,7 @@ function remove($args) * For this plugin, $this->get() will check the file and * return it's contents */ - function display($args) + public function display($args) { return $this->get($args); } @@ -189,7 +189,7 @@ function display($args) * When displaying or sending the attachment the file contents are fetched * using this method. This is also called by the attachment_display hook. */ - function get($args) + public function get($args) { // attempt to get file from local file system $args = parent::get($args); @@ -219,7 +219,7 @@ function get($args) /** * Delete all temp files associated with this user */ - function cleanup($args) + public function cleanup($args) { $this->_load_drivers(); diff --git a/plugins/redundant_attachments/tests/RedundantAttachments.php b/plugins/redundant_attachments/tests/RedundantAttachments.php index ad0834a2c8..7249755240 100644 --- a/plugins/redundant_attachments/tests/RedundantAttachments.php +++ b/plugins/redundant_attachments/tests/RedundantAttachments.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new redundant_attachments($rcube->plugins); diff --git a/plugins/show_additional_headers/show_additional_headers.php b/plugins/show_additional_headers/show_additional_headers.php index 55eb5e9263..ef3c8f89cb 100644 --- a/plugins/show_additional_headers/show_additional_headers.php +++ b/plugins/show_additional_headers/show_additional_headers.php @@ -19,15 +19,14 @@ class show_additional_headers extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $rcmail = rcmail::get_instance(); if ($rcmail->action == 'show' || $rcmail->action == 'preview') { $this->add_hook('storage_init', [$this, 'storage_init']); $this->add_hook('message_headers_output', [$this, 'message_headers']); - } - elseif ($rcmail->action == '') { + } elseif ($rcmail->action == '') { // with enabled_caching we're fetching additional headers before show/preview $this->add_hook('storage_init', [$this, 'storage_init']); } @@ -41,7 +40,7 @@ function init() * * @return array Modified hook parameters */ - function storage_init($p) + public function storage_init($p) { $rcmail = rcmail::get_instance(); $add_headers = $rcmail->config->get('show_additional_headers', []); @@ -50,8 +49,7 @@ function storage_init($p) $add_headers = strtoupper(implode(' ', (array) $add_headers)); if (isset($p['fetch_headers'])) { $p['fetch_headers'] .= ' ' . $add_headers; - } - else { + } else { $p['fetch_headers'] = $add_headers; } } @@ -67,7 +65,7 @@ function storage_init($p) * * @return array Modified hook parameters */ - function message_headers($p) + public function message_headers($p) { $rcmail = rcmail::get_instance(); $add_headers = $rcmail->config->get('show_additional_headers', []); @@ -78,8 +76,7 @@ function message_headers($p) foreach ($value as $idx => $v) { $p['output']["$header:$idx"] = ['title' => $header, 'value' => $v]; } - } - else { + } else { $p['output'][$header] = ['title' => $header, 'value' => $value]; } } diff --git a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php index 21337bccc3..40a6aa8e17 100644 --- a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php +++ b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new show_additional_headers($rcube->plugins); diff --git a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php index e3d99e0f19..b623274301 100644 --- a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php +++ b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php @@ -81,8 +81,7 @@ public function create_identity($p) if ($this->identities_level == 0 && !empty($this->prefs['email_address' . $i])) { $ident_data['email'] = $this->prefs['email_address' . $i]; - } - else { + } else { $ident_data['email'] = $p['record']['email']; } @@ -115,8 +114,7 @@ public function create_identity($p) if (count($emails) > 1) { if (!empty($groups[$rec['name']])) { $group_id = $groups[$rec['name']]; - } - elseif ($group = $contacts->create_group($rec['name'])) { + } elseif ($group = $contacts->create_group($rec['name'])) { $group_id = $group['id']; $groups[$rec['name']] = $group_id; } @@ -128,8 +126,7 @@ public function create_identity($p) if (!empty($addresses[$email])) { $contact_id = $addresses[$email]; - } - elseif (rcube_utils::check_email(rcube_utils::idn_to_ascii($email))) { + } elseif (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; diff --git a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php index 13b75c015f..049a39f682 100644 --- a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php +++ b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new squirrelmail_usercopy($rcube->plugins); diff --git a/plugins/subscriptions_option/subscriptions_option.php b/plugins/subscriptions_option/subscriptions_option.php index 5385047951..959e163e26 100644 --- a/plugins/subscriptions_option/subscriptions_option.php +++ b/plugins/subscriptions_option/subscriptions_option.php @@ -29,7 +29,7 @@ class subscriptions_option extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $dont_override = rcmail::get_instance()->config->get('dont_override', []); @@ -49,7 +49,7 @@ function init() * * @return array Modified hook arguments */ - function prefs_list($args) + public function prefs_list($args) { if ($args['section'] == 'server') { $this->add_texts('localization/', false); @@ -73,7 +73,7 @@ function prefs_list($args) * * @return array Modified hook arguments */ - function prefs_save($args) + public function prefs_save($args) { if ($args['section'] == 'server') { $rcmail = rcmail::get_instance(); @@ -94,7 +94,7 @@ function prefs_save($args) return $args; } - function mailboxes_list($args) + public function mailboxes_list($args) { $rcmail = rcmail::get_instance(); @@ -114,7 +114,7 @@ function mailboxes_list($args) return $args; } - function folders_list($args) + public function folders_list($args) { $rcmail = rcmail::get_instance(); diff --git a/plugins/subscriptions_option/tests/SubscriptionsOption.php b/plugins/subscriptions_option/tests/SubscriptionsOption.php index dc849fb35e..29b51dfaf2 100644 --- a/plugins/subscriptions_option/tests/SubscriptionsOption.php +++ b/plugins/subscriptions_option/tests/SubscriptionsOption.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new subscriptions_option($rcube->plugins); @@ -22,7 +22,7 @@ function test_constructor() /** * Test prefs_list() method */ - function test_prefs_list() + public function test_prefs_list() { $rcube = rcube::get_instance(); $plugin = new subscriptions_option($rcube->plugins); @@ -47,7 +47,7 @@ function test_prefs_list() /** * Test prefs_save() method */ - function test_prefs_save() + public function test_prefs_save() { self::initStorage(); diff --git a/plugins/userinfo/tests/Userinfo.php b/plugins/userinfo/tests/Userinfo.php index bc39fa7f76..cbe3819ed3 100644 --- a/plugins/userinfo/tests/Userinfo.php +++ b/plugins/userinfo/tests/Userinfo.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new userinfo($rcube->plugins); diff --git a/plugins/userinfo/userinfo.php b/plugins/userinfo/userinfo.php index 41125d0b2b..b999585e12 100644 --- a/plugins/userinfo/userinfo.php +++ b/plugins/userinfo/userinfo.php @@ -10,14 +10,14 @@ class userinfo extends rcube_plugin public $noajax = true; public $noframe = true; - function init() + public function init() { $this->add_texts('localization/', ['userinfo']); $this->add_hook('settings_actions', [$this, 'settings_actions']); $this->register_action('plugin.userinfo', [$this, 'infostep']); } - function settings_actions($args) + public function settings_actions($args) { $args['actions'][] = [ 'action' => 'plugin.userinfo', @@ -29,7 +29,7 @@ function settings_actions($args) return $args; } - function infostep() + public function infostep() { $this->register_handler('plugin.body', [$this, 'infohtml']); @@ -38,7 +38,7 @@ function infostep() $rcmail->output->send('plugin'); } - function infohtml() + public function infohtml() { $rcmail = rcmail::get_instance(); $user = $rcmail->user; diff --git a/plugins/vcard_attachments/tests/VcardAttachments.php b/plugins/vcard_attachments/tests/VcardAttachments.php index 4008a3f857..f7405572b9 100644 --- a/plugins/vcard_attachments/tests/VcardAttachments.php +++ b/plugins/vcard_attachments/tests/VcardAttachments.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new vcard_attachments($rcube->plugins); @@ -22,7 +22,7 @@ function test_constructor() /** * Test is_vcard() */ - function test_is_vcard() + public function test_is_vcard() { $rcube = rcube::get_instance(); $plugin = new vcard_attachments($rcube->plugins); diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php index 1647edd1eb..093ff9bcfa 100644 --- a/plugins/vcard_attachments/vcard_attachments.php +++ b/plugins/vcard_attachments/vcard_attachments.php @@ -19,7 +19,7 @@ class vcard_attachments extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $rcmail = rcmail::get_instance(); @@ -37,17 +37,14 @@ function init() ], 'contactmenu' ); - } - else { + } else { if ($rcmail->action == 'show' || $rcmail->action == 'preview') { $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']); - } - elseif ($rcmail->action == 'upload') { + } elseif ($rcmail->action == 'upload') { $this->add_hook('attachment_from_uri', [$this, 'attach_vcard']); - } - elseif ($rcmail->action == 'compose' && !$rcmail->output->framed) { + } elseif ($rcmail->action == 'compose' && !$rcmail->output->framed) { $this->add_texts('localization', true); $this->include_stylesheet($this->local_skin_path() . '/style.css'); $this->include_script('vcardattach.js'); @@ -64,8 +61,7 @@ function init() ); $this->add_hook('message_compose', [$this, 'message_compose']); - } - elseif (!$rcmail->output->framed && (!$rcmail->action || $rcmail->action == 'list')) { + } elseif (!$rcmail->output->framed && (!$rcmail->action || $rcmail->action == 'list')) { $this->include_stylesheet($this->local_skin_path() . '/style.css'); $this->include_script('vcardattach.js'); } @@ -77,7 +73,7 @@ function init() /** * Check message bodies and attachments for vcards */ - function message_load($p) + public function message_load($p) { $this->message = $p['object']; @@ -104,7 +100,7 @@ function message_load($p) * This callback function adds a box above the message content * if there is a vcard attachment available */ - function message_objects($p) + public function message_objects($p) { $rcmail = rcmail::get_instance(); $contacts = []; @@ -131,8 +127,7 @@ function message_objects($p) if (count($contacts) == 1) { $display = array_first($contacts); $attr['onclick'] = "return plugin_vcard_import('" . rcube::JQ(key($contacts)) . "')"; - } - else { + } else { $display = $this->gettext(['name' => 'contactsattached', 'vars' => ['num' => count($contacts)]]); $attr['onclick'] = 'return plugin_vcard_import()'; @@ -156,7 +151,7 @@ function message_objects($p) /** * This callback function adds a vCard to the message when attached from the Address book */ - function message_compose($p) + public function message_compose($p) { if ( rcube_utils::get_input_string('_attach_vcard', rcube_utils::INPUT_GET) == '1' @@ -172,7 +167,7 @@ function message_compose($p) * This callback function removes message part's content * for parts that are vcards */ - function html_output($p) + public function html_output($p) { foreach ($this->vcard_parts as $part) { // remove part's body @@ -187,7 +182,7 @@ function html_output($p) /** * Handler for request action */ - function save_vcard() + public function save_vcard() { $this->add_texts('localization'); @@ -238,8 +233,7 @@ function save_vcard() // skip entries without an e-mail address or invalid if (empty($email) || !$CONTACTS->validate($contact, true)) { $valid = false; - } - else { + } else { // We're using UTF8 internally $email = rcube_utils::idn_to_utf8($email); @@ -263,8 +257,7 @@ function save_vcard() if (!$plugin['abort'] && $CONTACTS->insert($contact)) { // do nothing - } - else { + } else { $errors++; } } @@ -272,8 +265,7 @@ function save_vcard() if ($errors || empty($vcards)) { $rcmail->output->command('display_message', $this->gettext('vcardsavefailed'), 'error'); - } - else { + } else { $rcmail->output->command('display_message', $this->gettext('importedsuccessfully'), 'confirmation'); } @@ -400,7 +392,7 @@ private function get_contact_vcard($source, $cid, &$filename = null) /** * Helper function to convert contact name into filename */ - static private function parse_filename($str) + private static function parse_filename($str) { $str = preg_replace('/[\t\n\r\0\x0B:\/]+\s*/', ' ', $str); diff --git a/plugins/virtuser_file/tests/VirtuserFile.php b/plugins/virtuser_file/tests/VirtuserFile.php index 1ed763ebb0..5f2afd8a8c 100644 --- a/plugins/virtuser_file/tests/VirtuserFile.php +++ b/plugins/virtuser_file/tests/VirtuserFile.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new virtuser_file($rcube->plugins); diff --git a/plugins/virtuser_file/virtuser_file.php b/plugins/virtuser_file/virtuser_file.php index 4d36d3831e..72b48b955f 100644 --- a/plugins/virtuser_file/virtuser_file.php +++ b/plugins/virtuser_file/virtuser_file.php @@ -19,7 +19,7 @@ class virtuser_file extends rcube_plugin /** * Plugin initialization */ - function init() + public function init() { $this->app = rcmail::get_instance(); $this->file = $this->app->config->get('virtuser_file'); @@ -33,7 +33,7 @@ function init() /** * User > Email */ - function user2email($p) + public function user2email($p) { $r = $this->findinvirtual('/\s' . preg_quote($p['user'], '/') . '\s*$/'); $result = []; @@ -59,7 +59,7 @@ function user2email($p) /** * Email > User */ - function email2user($p) + public function email2user($p) { $r = $this->findinvirtual('/^' . preg_quote($p['email'], '/') . '\s/'); diff --git a/plugins/virtuser_query/tests/VirtuserQuery.php b/plugins/virtuser_query/tests/VirtuserQuery.php index 2a36d8eb30..3c9846ace9 100644 --- a/plugins/virtuser_query/tests/VirtuserQuery.php +++ b/plugins/virtuser_query/tests/VirtuserQuery.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new virtuser_query($rcube->plugins); diff --git a/plugins/virtuser_query/virtuser_query.php b/plugins/virtuser_query/virtuser_query.php index 3812c33d84..4574d3e7ba 100644 --- a/plugins/virtuser_query/virtuser_query.php +++ b/plugins/virtuser_query/virtuser_query.php @@ -31,7 +31,7 @@ class virtuser_query extends rcube_plugin private $app; private $db; - function init() + public function init() { $this->app = rcmail::get_instance(); $this->config = $this->app->config->get('virtuser_query'); @@ -59,7 +59,7 @@ function init() /** * User > Email */ - function user2email($p) + public function user2email($p) { $dbh = $this->get_dbh(); @@ -78,8 +78,7 @@ function user2email($p) 'signature' => $sql_arr[5] ?? '', 'html_signature' => isset($sql_arr[6]) ? intval($sql_arr[6]) : 0, ]; - } - else { + } else { $result[] = $sql_arr[0]; } @@ -97,7 +96,7 @@ function user2email($p) /** * EMail > User */ - function email2user($p) + public function email2user($p) { $dbh = $this->get_dbh(); @@ -113,7 +112,7 @@ function email2user($p) /** * User > Host */ - function user2host($p) + public function user2host($p) { $dbh = $this->get_dbh(); @@ -129,7 +128,7 @@ function user2host($p) /** * Alias > User */ - function alias2user($p) + public function alias2user($p) { $dbh = $this->get_dbh(); @@ -145,7 +144,7 @@ function alias2user($p) /** * Initialize database handler */ - function get_dbh() + public function get_dbh() { if (!$this->db) { if ($dsn = $this->app->config->get('virtuser_query_dsn')) { @@ -153,8 +152,7 @@ function get_dbh() $this->db = rcube_db::factory($dsn); $this->db->set_debug((bool) $this->app->config->get('sql_debug')); $this->db->db_connect('r'); // connect in read mode - } - else { + } else { $this->db = $this->app->get_dbh(); } } diff --git a/plugins/zipdownload/tests/Browser/MailTest.php b/plugins/zipdownload/tests/Browser/MailTest.php index df217cdab3..230b7e40ba 100644 --- a/plugins/zipdownload/tests/Browser/MailTest.php +++ b/plugins/zipdownload/tests/Browser/MailTest.php @@ -109,7 +109,7 @@ private function getFilesFromZip($filename) sleep(2); } - $zip = new \ZipArchive; + $zip = new \ZipArchive(); $files = []; if ($zip->open($filename)) { diff --git a/plugins/zipdownload/tests/Zipdownload.php b/plugins/zipdownload/tests/Zipdownload.php index 2e6115f5ef..8848b1743a 100644 --- a/plugins/zipdownload/tests/Zipdownload.php +++ b/plugins/zipdownload/tests/Zipdownload.php @@ -10,7 +10,7 @@ public static function setUpBeforeClass(): void /** * Plugin object construction test */ - function test_constructor() + public function test_constructor() { $rcube = rcube::get_instance(); $plugin = new zipdownload($rcube->plugins); diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index 16382043de..65aa9a0a64 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -21,7 +21,7 @@ class zipdownload extends rcube_plugin private $default_limit = '50MB'; // RFC4155: mbox date format - const MBOX_DATE_FORMAT = 'D M d H:i:s Y'; + public const MBOX_DATE_FORMAT = 'D M d H:i:s Y'; /** * Plugin initialization @@ -31,12 +31,11 @@ public function init() // check requirements first if (!class_exists('ZipArchive', false)) { rcmail::raise_error([ - 'code' => 520, - 'file' => __FILE__, - 'line' => __LINE__, - 'message' => 'php-zip extension is required for the zipdownload plugin', - ], true, false - ); + 'code' => 520, + 'file' => __FILE__, + 'line' => __LINE__, + 'message' => 'php-zip extension is required for the zipdownload plugin', + ], true, false); return; } @@ -214,8 +213,7 @@ private function _create_displayname($part) [$filename, $ext] = preg_split('/\\.(?=[^\\.]*$)/', $displayname); $displayname = $filename . '(' . ($this->names[$displayname]++) . ').' . $ext; $this->names[$displayname] = 1; - } - else { + } else { $this->names[$displayname] = 1; } @@ -275,8 +273,7 @@ private function _download_messages($messageset) ); $messages[$uid . ':' . $mbox] = $header; - } - else { // maildir + } else { // maildir $subject = rcube_mime::decode_header($headers->subject, $headers->charset); $subject = $this->_filename_from_subject(mb_substr($subject, 0, 16)); $subject = $this->_convert_filename($subject); @@ -293,8 +290,8 @@ private function _download_messages($messageset) unlink($tmpfname); $msg = $this->gettext([ - 'name' => 'sizelimiterror', - 'vars' => ['$size' => rcmail_action::show_bytes($limit)], + 'name' => 'sizelimiterror', + 'vars' => ['$size' => rcmail_action::show_bytes($limit)], ]); $rcmail->output->show_message($msg, 'error'); @@ -328,8 +325,7 @@ private function _download_messages($messageset) $imap->get_raw_body($uid, $tmpfp); stream_filter_remove($filter); fwrite($tmpfp, "\r\n"); - } - else { // maildir + } else { // maildir $tmpfn = rcube_utils::temp_filename('zipmessage'); $fp = fopen($tmpfn, 'w'); $imap->get_raw_body($uid, $fp); diff --git a/program/actions/contacts/copy.php b/program/actions/contacts/copy.php index ed90a2caf6..2ef1cf95c8 100644 --- a/program/actions/contacts/copy.php +++ b/program/actions/contacts/copy.php @@ -74,20 +74,18 @@ public function run($args = []) $email = $CONTACTS->get_col_values('email', $a_record, true); if (!empty($email)) { $result = $TARGET->search('email', $email[0], 1, true, true); - } - elseif (!empty($a_record['name'])) { + } elseif (!empty($a_record['name'])) { $result = $TARGET->search('name', $a_record['name'], 1, true, true); - } - else { + } else { $result = new rcube_result_set(); } // insert contact record if (!$result->count) { $plugin = $rcmail->plugins->exec_hook('contact_create', [ - 'record' => $a_record, - 'source' => $target, - 'group' => $target_group, + 'record' => $a_record, + 'source' => $target, + 'group' => $target_group, ]); if (!$plugin['abort']) { @@ -95,13 +93,11 @@ public function run($args = []) $ids[] = $insert_id; $success++; } - } - elseif ($plugin['result']) { + } elseif ($plugin['result']) { $ids = array_merge($ids, $plugin['result']); $success++; } - } - else { + } else { $record = $result->first(); $ids[] = $record['ID']; $errormsg = empty($email) ? 'contactnameexists' : 'contactexists'; @@ -111,9 +107,9 @@ public function run($args = []) // assign to group if ($target_group && $TARGET->groups && !empty($ids)) { $plugin = $rcmail->plugins->exec_hook('group_addmembers', [ - 'group_id' => $target_group, - 'ids' => $ids, - 'source' => $target, + 'group_id' => $target_group, + 'ids' => $ids, + 'source' => $target, ]); if (!$plugin['abort']) { @@ -128,8 +124,7 @@ public function run($args = []) if (($cnt = $TARGET->add_to_group($target_group, $plugin['ids'])) && $cnt > $success) { $success = $cnt; } - } - elseif (!empty($plugin['result'])) { + } elseif (!empty($plugin['result'])) { $success = $plugin['result']; } @@ -139,8 +134,7 @@ public function run($args = []) if (!$success) { $rcmail->output->show_message($errormsg, 'error'); - } - else { + } else { $rcmail->output->show_message('copysuccess', 'confirmation', ['nr' => $success]); } diff --git a/program/actions/contacts/delete.php b/program/actions/contacts/delete.php index 5269349a7b..69e71d3437 100644 --- a/program/actions/contacts/delete.php +++ b/program/actions/contacts/delete.php @@ -52,8 +52,8 @@ public function run($args = []) } $plugin = $rcmail->plugins->exec_hook('contact_delete', [ - 'id' => $cid, - 'source' => $source, + 'id' => $cid, + 'source' => $source, ]); $deleted = !$plugin['abort'] ? $CONTACTS->delete($cid, $undo_time < 1) : $plugin['result']; @@ -61,11 +61,9 @@ public function run($args = []) if (!$deleted) { if (!empty($plugin['message'])) { $error = $plugin['message']; - } - elseif (($error = $CONTACTS->get_error()) && !empty($error['message'])) { + } elseif (($error = $CONTACTS->get_error()) && !empty($error['message'])) { $error = $error['message']; - } - else { + } else { $error = 'contactdelerror'; } @@ -75,8 +73,7 @@ public function run($args = []) $rcmail->output->show_message($error, 'error'); $rcmail->output->command('list_contacts', $source, $group); $rcmail->output->send(); - } - else { + } else { $delcnt += $deleted; // store deleted contacts IDs in session for undo action @@ -95,8 +92,7 @@ public function run($args = []) ); $rcmail->output->show_message($msg, 'confirmation', null, true, $undo_time); - } - else { + } else { $rcmail->output->show_message('contactdeleted', 'confirmation'); } @@ -131,12 +127,10 @@ public function run($args = []) $res->records = array_values($records); $records = $res; - } - else { + } else { unset($records); } - } - elseif (isset($CONTACTS)) { + } elseif (isset($CONTACTS)) { // count contacts for this user $result = $CONTACTS->count(); $pages = ceil(($result->count + $delcnt) / $page_size); diff --git a/program/actions/contacts/edit.php b/program/actions/contacts/edit.php index f0a9641393..22de5ec461 100644 --- a/program/actions/contacts/edit.php +++ b/program/actions/contacts/edit.php @@ -52,8 +52,7 @@ public function run($args = []) if (empty(self::$contact)) { $rcmail->output->show_message('contactnotfound', 'error'); } - } - else { + } else { $source = rcube_utils::get_input_string('_source', rcube_utils::INPUT_GPC); if (strlen($source)) { @@ -79,12 +78,12 @@ public function run($args = []) } $rcmail->output->add_handlers([ - 'contactedithead' => [$this, 'contact_edithead'], - 'contacteditform' => [$this, 'contact_editform'], - 'contactphoto' => [$this, 'contact_photo'], - 'photouploadform' => [$this, 'upload_photo_form'], - 'sourceselector' => [$this, 'source_selector'], - 'filedroparea' => [$this, 'photo_drop_area'], + 'contactedithead' => [$this, 'contact_edithead'], + 'contacteditform' => [$this, 'contact_editform'], + 'contactphoto' => [$this, 'contact_photo'], + 'photouploadform' => [$this, 'upload_photo_form'], + 'sourceselector' => [$this, 'source_selector'], + 'filedroparea' => [$this, 'photo_drop_area'], ]); $rcmail->output->set_pagetitle($rcmail->gettext($rcmail->action == 'add' ? 'addcontact' : 'editcontact')); @@ -200,7 +199,7 @@ public static function upload_photo_form($attrib) $attrib['prefix'] = $hidden->show(); $input_attr = ['name' => '_photo', 'accept' => 'image/*']; - $rcmail->output->add_label('addphoto','replacephoto'); + $rcmail->output->add_label('addphoto', 'replacephoto'); return self::upload_form($attrib, 'uploadform', 'upload-photo', $input_attr); } @@ -260,10 +259,10 @@ public static function photo_drop_area($attrib) if (!empty($attrib['id'])) { $rcmail->output->add_gui_object('filedrop', $attrib['id']); $rcmail->output->set_env('filedrop', [ - 'action' => 'upload-photo', - 'fieldname' => '_photo', - 'single' => 1, - 'filter' => '^image/.+', + 'action' => 'upload-photo', + 'fieldname' => '_photo', + 'single' => 1, + 'filter' => '^image/.+', ]); } } diff --git a/program/actions/contacts/group_addmembers.php b/program/actions/contacts/group_addmembers.php index 020d5000d2..f1554d3715 100644 --- a/program/actions/contacts/group_addmembers.php +++ b/program/actions/contacts/group_addmembers.php @@ -44,9 +44,9 @@ public function run($args = []) if ($gid && $ids) { $plugin = $rcmail->plugins->exec_hook('group_addmembers', [ - 'group_id' => $gid, - 'ids' => $ids, - 'source' => $source, + 'group_id' => $gid, + 'ids' => $ids, + 'source' => $source, ]); $contacts->set_group($gid); @@ -62,20 +62,17 @@ public function run($args = []) } $result = $contacts->add_to_group($gid, $plugin['ids']); - } - else { + } else { $result = $plugin['result']; } } if ($result) { $rcmail->output->show_message('contactaddedtogroup', 'confirmation'); - } - elseif (!empty($plugin['abort']) || $contacts->get_error()) { + } elseif (!empty($plugin['abort']) || $contacts->get_error()) { $error = !empty($plugin['message']) ? $plugin['message'] : 'errorsaving'; $rcmail->output->show_message($error, 'error'); - } - else { + } else { $message = !empty($plugin['message']) ? $plugin['message'] : 'nogroupassignmentschanged'; $rcmail->output->show_message($message); } diff --git a/program/actions/contacts/group_create.php b/program/actions/contacts/group_create.php index 3f161d658d..47c8ea1082 100644 --- a/program/actions/contacts/group_create.php +++ b/program/actions/contacts/group_create.php @@ -40,14 +40,13 @@ public function run($args = []) if ($name = trim(rcube_utils::get_input_string('_name', rcube_utils::INPUT_POST, true))) { $plugin = $rcmail->plugins->exec_hook('group_create', [ - 'name' => $name, - 'source' => $source, + 'name' => $name, + 'source' => $source, ]); if (empty($plugin['abort'])) { $created = $contacts->create_group($plugin['name']); - } - else { + } else { $created = $plugin['result']; } } @@ -55,8 +54,7 @@ public function run($args = []) if (!empty($created)) { $rcmail->output->show_message('groupcreated', 'confirmation'); $rcmail->output->command('insert_contact_group', ['source' => $source] + $created); - } - elseif (empty($created)) { + } elseif (empty($created)) { $error = !empty($plugin['message']) ? $plugin['message'] : 'errorsaving'; $rcmail->output->show_message($error, 'error'); } diff --git a/program/actions/contacts/group_delete.php b/program/actions/contacts/group_delete.php index 0fe2ecb541..341fd6677a 100644 --- a/program/actions/contacts/group_delete.php +++ b/program/actions/contacts/group_delete.php @@ -40,14 +40,13 @@ public function run($args = []) if ($gid = rcube_utils::get_input_string('_gid', rcube_utils::INPUT_POST)) { $plugin = $rcmail->plugins->exec_hook('group_delete', [ - 'group_id' => $gid, - 'source' => $source, + 'group_id' => $gid, + 'source' => $source, ]); if (empty($plugin['abort'])) { $deleted = $contacts->delete_group($gid); - } - else { + } else { $deleted = $plugin['result']; } } @@ -55,8 +54,7 @@ public function run($args = []) if (!empty($deleted)) { $rcmail->output->show_message('groupdeleted', 'confirmation'); $rcmail->output->command('remove_group_item', ['source' => $source, 'id' => $gid]); - } - else { + } else { $error = !empty($plugin['message']) ? $plugin['message'] : 'errorsaving'; $rcmail->output->show_message($error, 'error'); } diff --git a/program/actions/contacts/group_delmembers.php b/program/actions/contacts/group_delmembers.php index ccc7320fd6..cadaf09a9a 100644 --- a/program/actions/contacts/group_delmembers.php +++ b/program/actions/contacts/group_delmembers.php @@ -43,15 +43,14 @@ public function run($args = []) if ($gid && $ids) { $plugin = $rcmail->plugins->exec_hook('group_delmembers', [ - 'group_id' => $gid, - 'ids' => $ids, - 'source' => $source, + 'group_id' => $gid, + 'ids' => $ids, + 'source' => $source, ]); if (empty($plugin['abort'])) { $result = $contacts->remove_from_group($gid, $plugin['ids']); - } - else { + } else { $result = $plugin['result']; } } @@ -59,8 +58,7 @@ public function run($args = []) if (!empty($result)) { $rcmail->output->show_message('contactremovedfromgroup', 'confirmation'); $rcmail->output->command('remove_group_contacts', ['source' => $source, 'gid' => $gid]); - } - else { + } else { $error = !empty($plugin['message']) ? $plugin['message'] : 'errorsaving'; $rcmail->output->show_message($error, 'error'); } diff --git a/program/actions/contacts/group_rename.php b/program/actions/contacts/group_rename.php index 16d5ceee5b..e49b034242 100644 --- a/program/actions/contacts/group_rename.php +++ b/program/actions/contacts/group_rename.php @@ -44,15 +44,14 @@ public function run($args = []) ) { $newgid = null; $plugin = $rcmail->plugins->exec_hook('group_rename', [ - 'group_id' => $gid, - 'name' => $name, - 'source' => $source, + 'group_id' => $gid, + 'name' => $name, + 'source' => $source, ]); if (empty($plugin['abort'])) { $newname = $contacts->rename_group($gid, $plugin['name'], $newgid); - } - else { + } else { $newname = $plugin['result']; } } @@ -60,13 +59,12 @@ public function run($args = []) if (!empty($newname)) { $rcmail->output->show_message('grouprenamed', 'confirmation'); $rcmail->output->command('update_contact_group', [ - 'source' => $source, - 'id' => $gid, - 'name' => $newname, - 'newid' => $newgid ?? null, + 'source' => $source, + 'id' => $gid, + 'name' => $newname, + 'newid' => $newgid ?? null, ]); - } - else { + } else { $error = !empty($plugin['message']) ? $plugin['message'] : 'errorsaving'; $rcmail->output->show_message($error, 'error'); } diff --git a/program/actions/contacts/import.php b/program/actions/contacts/import.php index 5d05efab87..9ddbc04d6a 100644 --- a/program/actions/contacts/import.php +++ b/program/actions/contacts/import.php @@ -20,7 +20,7 @@ class rcmail_action_contacts_import extends rcmail_action_contacts_index { - const UPLOAD_ERR_CSV_FIELDS = 101; + public const UPLOAD_ERR_CSV_FIELDS = 101; protected static $stats; @@ -62,21 +62,18 @@ public function run($args = []) if ($CONTACTS->readonly) { $rcmail->output->show_message('addresswriterror', 'error'); - } - else { + } else { $filepaths = []; if ($has_map) { $filepaths = $_SESSION['contactcsvimport']['files']; - } - else { + } else { foreach ((array) $_FILES['_file']['tmp_name'] as $i => $filepath) { // Process uploaded file if there is no error $err = $_FILES['_file']['error'][$i]; if ($err) { $upload_error = $err; - } - else { + } else { $filepaths[] = $filepath; } } @@ -107,8 +104,7 @@ public function run($args = []) $csv->import($file_content, false, $skip_head); unlink($filepath); - } - else { + } else { // save uploaded file for the real import in the next step $temp_csv = rcube_utils::temp_filename('csvimpt'); if (move_uploaded_file($filepath, $temp_csv) && file_exists($temp_csv)) { @@ -124,8 +120,7 @@ public function run($args = []) } $csvs[] = $temp_csv; - } - else { + } else { $upload_error = \UPLOAD_ERR_CANT_WRITE; } @@ -157,10 +152,9 @@ public function run($args = []) // Re-enable the import button $rcmail->output->command('parent.import_state_set', 'error'); - } - elseif (count($vcards) > 0) { + } elseif (count($vcards) > 0) { // import vcards - self::$stats = new stdClass; + self::$stats = new stdClass(); self::$stats->names = []; self::$stats->skipped_names = []; self::$stats->count = count($vcards); @@ -227,8 +221,7 @@ public function run($args = []) // insert record and send response if (empty($plugin['abort'])) { $success = $CONTACTS->insert($a_record); - } - else { + } else { $success = $plugin['result']; } @@ -244,8 +237,7 @@ public function run($args = []) self::$stats->inserted++; self::$stats->names[] = $a_record['name'] ?: $email; - } - else { + } else { self::$stats->errors++; } } @@ -254,12 +246,10 @@ public function run($args = []) $_SESSION['contactcsvimport'] = null; $rcmail->output->command('parent.import_state_set', self::$stats->inserted ? 'reload' : 'ok'); - } - else { + } else { if ($upload_error == self::UPLOAD_ERR_CSV_FIELDS) { $rcmail->output->show_message('csvfilemismatch', 'error'); - } - else { + } else { self::upload_error($upload_error); } @@ -270,14 +260,13 @@ public function run($args = []) $rcmail->output->set_pagetitle($rcmail->gettext('importcontacts')); $rcmail->output->add_handlers([ - 'importstep' => [$this, $importstep], + 'importstep' => [$this, $importstep], ]); // render page if ($rcmail->output->template_exists('contactimport')) { $rcmail->output->send('contactimport'); - } - else { + } else { $rcmail->output->send('importcontacts'); // deprecated } } @@ -299,12 +288,12 @@ public static function import_form($attrib) $hint = $rcmail->gettext(['id' => 'importfile', 'name' => 'maxuploadsize', 'vars' => ['size' => $max_filesize]]); $table = new html_table(['cols' => 2]); $upload = new html_inputfield([ - 'type' => 'file', - 'name' => '_file[]', - 'id' => 'rcmimportfile', - 'size' => 40, - 'multiple' => 'multiple', - 'class' => 'form-control-file', + 'type' => 'file', + 'name' => '_file[]', + 'id' => 'rcmimportfile', + 'size' => 40, + 'multiple' => 'multiple', + 'class' => 'form-control-file', ]); $table->add('title', html::label('rcmimportfile', $rcmail->gettext('importfromfile'))); @@ -313,10 +302,10 @@ public static function import_form($attrib) // addressbook selector if (count($writable_books) > 1) { $select = new html_select([ - 'name' => '_target', - 'id' => 'rcmimporttarget', - 'is_escaped' => true, - 'class' => 'custom-select', + 'name' => '_target', + 'id' => 'rcmimporttarget', + 'is_escaped' => true, + 'class' => 'custom-select', ]); foreach ($writable_books as $book) { @@ -325,8 +314,7 @@ public static function import_form($attrib) $table->add('title', html::label('rcmimporttarget', $rcmail->gettext('importtarget'))); $table->add(null, $select->show($target)); - } - else { + } else { $abook = new html_hiddenfield(['name' => '_target', 'value' => key($writable_books)]); $form .= $abook->show(); } @@ -336,10 +324,10 @@ public static function import_form($attrib) // selector for group import options if (count($writable_books) >= 1 || $writable_books[0]->groups) { $select = new html_select([ - 'name' => '_groups', - 'id' => 'rcmimportgroups', - 'is_escaped' => true, - 'class' => 'custom-select', + 'name' => '_groups', + 'id' => 'rcmimportgroups', + 'is_escaped' => true, + 'class' => 'custom-select', ]); $select->add($rcmail->gettext('none'), '0'); $select->add($rcmail->gettext('importgroupsall'), '1'); @@ -360,7 +348,7 @@ public static function import_form($attrib) $_SESSION['contactcsvimport'] = null; $rcmail->output->set_env('writable_source', !empty($writable_books)); - $rcmail->output->add_label('selectimportfile','importwait'); + $rcmail->output->add_label('selectimportfile', 'importwait'); $rcmail->output->add_gui_object('importform', $attrib['id']); $attrib = [ diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index 070960b581..f25c02b111 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -332,12 +332,12 @@ public function run($args = []) // register UI objects $rcmail->output->add_handlers([ - 'directorylist' => [$this, 'directory_list'], - 'savedsearchlist' => [$this, 'savedsearch_list'], - 'addresslist' => [$this, 'contacts_list'], - 'addresslisttitle' => [$this, 'contacts_list_title'], - 'recordscountdisplay' => [$this, 'rowcount_display'], - 'searchform' => [$rcmail->output, 'search_form'], + 'directorylist' => [$this, 'directory_list'], + 'savedsearchlist' => [$this, 'savedsearch_list'], + 'addresslist' => [$this, 'contacts_list'], + 'addresslisttitle' => [$this, 'contacts_list_title'], + 'recordscountdisplay' => [$this, 'rowcount_display'], + 'searchform' => [$rcmail->output, 'search_form'], ]); // Disable qr-code if imagick, iconv or BaconQrCode is not installed @@ -369,8 +369,7 @@ public static function contact_source($source = null, $init_env = false, $writab // set list properties and session vars if (!empty($_GET['_page'])) { $contacts->set_page($_SESSION['page'] = intval($_GET['_page'])); - } - else { + } else { $contacts->set_page($_SESSION['page'] ?? 1); } @@ -403,8 +402,7 @@ public static function contact_source($source = null, $init_env = false, $writab if (isset(self::$CONTACT_COLTYPES[$col])) { self::$CONTACT_COLTYPES[$col] = array_merge(self::$CONTACT_COLTYPES[$col], $colprop); - } - else { + } else { self::$CONTACT_COLTYPES[$col] = $colprop; } } @@ -496,7 +494,7 @@ public static function directory_list($attrib) } $rcmail->output->set_env('contactgroups', $jsdata); - $rcmail->output->set_env('collapsed_abooks', (string) $rcmail->config->get('collapsed_abooks','')); + $rcmail->output->set_env('collapsed_abooks', (string) $rcmail->config->get('collapsed_abooks', '')); $rcmail->output->add_gui_object('folderlist', $attrib['id']); $rcmail->output->include_script('treelist.js'); @@ -573,7 +571,7 @@ public static function contact_groups($args) ); // append collapse/expand toggle and open a new