diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 2fa900e75..5aaf47dd8 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -3,7 +3,8 @@
$config = new PhpCsFixer\Config();
return $config->setRules([
- '@PHP74Migration' => true,
+ '@PHP83Migration' => true,
'@PSR12' => true,
'single_quote' => true,
+ 'nullable_type_declaration_for_default_null_value' => true,
]);
diff --git a/lib/Horde.php b/lib/Horde.php
index d35faad46..7519b3b51 100644
--- a/lib/Horde.php
+++ b/lib/Horde.php
@@ -1,4 +1,5 @@
setRaw(true)->add(array('_t' => $now, '_h' => ''));
+ $url->setRaw(true)->add(['_t' => $now, '_h' => '']);
$url->add(
'_h',
Horde_Url::uriB64Encode(
@@ -275,7 +282,7 @@ public static function signQueryString($queryString, $now = null)
}
if ($queryString instanceof Horde_Url) {
- $queryString->setRaw(true)->add(array('_t' => $now, '_h' => ''));
+ $queryString->setRaw(true)->add(['_t' => $now, '_h' => '']);
$parse_url = parse_url($queryString);
$queryString->add('_h', Horde_Url::uriB64Encode(hash_hmac('sha1', $parse_url['query'] . '=', $GLOBALS['conf']['secret_key'], true)));
return $queryString;
@@ -331,7 +338,7 @@ public static function verifySignedQueryString($data, $now = null)
*
* @return string The escaped string.
*/
- public static function escapeJson($data, array $options = array())
+ public static function escapeJson($data, array $options = [])
{
$json = Horde_Serialize::serialize($data, Horde_Serialize::JSON);
if (empty($options['nodelimit'])) {
@@ -389,7 +396,7 @@ public static function isConnectionSecure()
public static function requireSecureConnection()
{
if (!self::isConnectionSecure()) {
- throw new Horde_Exception(Horde_Core_Translation::t("The encryption features require a secure web connection."));
+ throw new Horde_Exception(Horde_Core_Translation::t('The encryption features require a secure web connection.'));
}
}
@@ -448,7 +455,7 @@ public static function getDriverConfig($backend, $type = 'sql')
return (!is_null($type) && isset($conf[$type]))
? $conf[$type]
- : array();
+ : [];
}
/**
@@ -469,11 +476,14 @@ public static function getDriverConfig($backend, $type = 'sql')
*
* @throws Horde_Exception
*/
- public static function assertDriverConfig($params, $driver, $fields,
- $name = null,
- $file = 'conf.php',
- $variable = '$conf')
- {
+ public static function assertDriverConfig(
+ $params,
+ $driver,
+ $fields,
+ $name = null,
+ $file = 'conf.php',
+ $variable = '$conf'
+ ) {
global $registry;
// Don't generate a fatal error if we fail during or before
@@ -485,19 +495,25 @@ public static function assertDriverConfig($params, $driver, $fields,
if (!is_array($params) || !count($params)) {
throw new Horde_Exception(
- sprintf(Horde_Core_Translation::t("No configuration information specified for %s."), $name) . "\n\n" .
- sprintf(Horde_Core_Translation::t("The file %s should contain some %s settings."),
+ sprintf(Horde_Core_Translation::t('No configuration information specified for %s.'), $name) . "\n\n" .
+ sprintf(
+ Horde_Core_Translation::t('The file %s should contain some %s settings.'),
$fileroot . '/config/' . $file,
- sprintf("%s['%s']['params']", $variable, $driver)));
+ sprintf("%s['%s']['params']", $variable, $driver)
+ )
+ );
}
foreach ($fields as $field) {
if (!isset($params[$field])) {
throw new Horde_Exception(
- sprintf(Horde_Core_Translation::t("Required \"%s\" not specified in %s configuration."), $field, $name) . "\n\n" .
- sprintf(Horde_Core_Translation::t("The file %s should contain a %s setting."),
+ sprintf(Horde_Core_Translation::t('Required "%s" not specified in %s configuration.'), $field, $name) . "\n\n" .
+ sprintf(
+ Horde_Core_Translation::t('The file %s should contain a %s setting.'),
$fileroot . '/config/' . $file,
- sprintf("%s['%s']['params']['%s']", $variable, $driver, $field)));
+ sprintf("%s['%s']['params']['%s']", $variable, $driver, $field)
+ )
+ );
}
}
}
@@ -523,18 +539,17 @@ public static function assertDriverConfig($params, $driver, $fields,
*
* @return Horde_Url The URL with the session id appended (if needed).
*/
- public static function url($uri, $full = false, $opts = array())
+ public static function url($uri, $full = false, $opts = [])
{
if (is_array($opts)) {
- $append_session = isset($opts['append_session'])
- ? $opts['append_session']
- : 0;
+ $append_session = $opts['append_session']
+ ?? 0;
if (!empty($opts['force_ssl'])) {
$full = true;
}
} else {
$append_session = $opts;
- $opts = array();
+ $opts = [];
}
$puri = parse_url($uri);
@@ -564,28 +579,27 @@ public static function url($uri, $full = false, $opts = array())
!preg_match($schemeRegexp, $webroot)) {
/* Store connection parameters in local variables. */
$server_name = $GLOBALS['conf']['server']['name'];
- $server_port = isset($GLOBALS['conf']['server']['port'])
- ? $GLOBALS['conf']['server']['port']
- : '';
+ $server_port = $GLOBALS['conf']['server']['port']
+ ?? '';
$protocol = 'http';
switch ($GLOBALS['conf']['use_ssl']) {
- case self::SSL_ALWAYS:
- $protocol = 'https';
- break;
-
- case self::SSL_AUTO:
- if ($GLOBALS['browser']->usingSSLConnection()) {
+ case self::SSL_ALWAYS:
$protocol = 'https';
- }
- break;
+ break;
- case self::SSL_ONLY_LOGIN:
- if (!empty($opts['force_ssl'])) {
- $protocol = 'https';
- $server_port = '';
- }
- break;
+ case self::SSL_AUTO:
+ if ($GLOBALS['browser']->usingSSLConnection()) {
+ $protocol = 'https';
+ }
+ break;
+
+ case self::SSL_ONLY_LOGIN:
+ if (!empty($opts['force_ssl'])) {
+ $protocol = 'https';
+ $server_port = '';
+ }
+ break;
}
/* If using a non-standard port, add to the URL. */
@@ -621,7 +635,7 @@ public static function url($uri, $full = false, $opts = array())
$url = $webroot . '/' . $puri['path'];
}
} else {
- $url .= '/' . ($webroot ? $webroot . '/' : '') . (isset($puri['path']) ? $puri['path'] : '');
+ $url .= '/' . ($webroot ? $webroot . '/' : '') . ($puri['path'] ?? '');
}
if (isset($puri['query'])) {
@@ -687,11 +701,17 @@ public static function externalUrl($url, $tag = false)
*
* @return string The full tag.
*/
- public static function link($url = '', $title = '', $class = '',
- $target = '', $onclick = '', $title2 = '',
- $accesskey = '', $attributes = array(),
- $escape = true)
- {
+ public static function link(
+ $url = '',
+ $title = '',
+ $class = '',
+ $target = '',
+ $onclick = '',
+ $title2 = '',
+ $accesskey = '',
+ $attributes = [],
+ $escape = true
+ ) {
if (!($url instanceof Horde_Url)) {
$url = new Horde_Url($url);
}
@@ -714,8 +734,10 @@ public static function link($url = '', $title = '', $class = '',
if (!empty($title)) {
if ($escape) {
$title = str_replace(
- array("\r", "\n"), '',
- htmlspecialchars(nl2br(htmlspecialchars($title))));
+ ["\r", "\n"],
+ '',
+ htmlspecialchars(nl2br(htmlspecialchars($title)))
+ );
/* Remove double encoded entities. */
$title = preg_replace('/&([a-z]+|(#\d+));/i', '&\\1;', $title);
}
@@ -743,10 +765,15 @@ public static function link($url = '', $title = '', $class = '',
* @return string The full tag.
*/
public static function linkTooltip(
- $url, $status = '', $class = '', $target = '', $onclick = '',
- $title = '', $accesskey = '', $attributes = array()
- )
- {
+ $url,
+ $status = '',
+ $class = '',
+ $target = '',
+ $onclick = '',
+ $title = '',
+ $accesskey = '',
+ $attributes = []
+ ) {
if (strlen($title)) {
$attributes['nicetitle'] = Horde_Serialize::serialize(
preg_split(
@@ -790,11 +817,11 @@ public static function linkTooltip(
public static function widget($params)
{
$params = array_merge(
- array(
+ [
'class' => '',
'target' => '',
'onclick' => '',
- 'nocheck' => false),
+ 'nocheck' => false],
$params
);
@@ -826,17 +853,19 @@ public static function widget($params)
*
* @return Horde_Url The requested URL.
*/
- public static function selfUrl($script_params = false, $nocache = true,
- $full = false, $force_ssl = false)
- {
+ public static function selfUrl(
+ $script_params = false,
+ $nocache = true,
+ $full = false,
+ $force_ssl = false
+ ) {
if (!strncmp(PHP_SAPI, 'cgi', 3)) {
// When using CGI PHP, SCRIPT_NAME may contain the path to
// the PHP binary instead of the script being run; use
// PHP_SELF instead.
$url = $_SERVER['PHP_SELF'];
} else {
- $url = isset($_SERVER['SCRIPT_NAME']) ?
- $_SERVER['SCRIPT_NAME'] :
+ $url = $_SERVER['SCRIPT_NAME'] ??
$_SERVER['PHP_SELF'];
}
if (isset($_SERVER['REQUEST_URI'])) {
@@ -857,7 +886,7 @@ public static function selfUrl($script_params = false, $nocache = true,
}
}
- $url = self::url($url, $full, array('force_ssl' => $force_ssl));
+ $url = self::url($url, $full, ['force_ssl' => $force_ssl]);
return ($nocache && $GLOBALS['browser']->hasQuirk('cache_same_url'))
? $url->unique()
@@ -884,11 +913,10 @@ public static function selfUrl($script_params = false, $nocache = true,
*
* @return Horde_Url The self URL.
*/
- public static function selfUrlParams(array $opts = array())
+ public static function selfUrlParams(array $opts = [])
{
- $vars = isset($opts['vars'])
- ? $opts['vars']
- : $GLOBALS['injector']->createInstance('Horde_Variables');
+ $vars = $opts['vars']
+ ?? $GLOBALS['injector']->createInstance('Horde_Variables');
$url = self::selfUrl(
false,
@@ -950,10 +978,13 @@ public static function getTempDir()
* @return string Returns the full path-name to the temporary file or
* false if a temporary file could not be created.
*/
- public static function getTempFile($prefix = 'Horde', $delete = true,
- $dir = '', $secure = false,
- $session_remove = false)
- {
+ public static function getTempFile(
+ $prefix = 'Horde',
+ $delete = true,
+ $dir = '',
+ $secure = false,
+ $session_remove = false
+ ) {
if (empty($dir) || !is_dir($dir)) {
$dir = self::getTempDir();
}
@@ -977,15 +1008,15 @@ public static function getTempFile($prefix = 'Horde', $delete = true,
public static function webServerID()
{
switch (PHP_SAPI) {
- case 'apache':
- return 'apache1';
+ case 'apache':
+ return 'apache1';
- case 'apache2filter':
- case 'apache2handler':
- return 'apache2';
+ case 'apache2filter':
+ case 'apache2handler':
+ return 'apache2';
- default:
- return PHP_SAPI;
+ default:
+ return PHP_SAPI;
}
}
@@ -1001,9 +1032,10 @@ public static function webServerID()
* string if no key can be found.
*/
public static function getAccessKey(
- $label, $nocheck = false, $shutdown = false
- )
- {
+ $label,
+ $nocheck = false,
+ $shutdown = false
+ ) {
/* Shutdown call for translators? */
if ($shutdown) {
if (!count(self::$_labels)) {
@@ -1014,7 +1046,7 @@ public static function getAccessKey(
sort($labels);
$used = array_keys(self::$_used);
sort($used);
- $remaining = str_replace($used, array(), 'abcdefghijklmnopqrstuvwxyz');
+ $remaining = str_replace($used, [], 'abcdefghijklmnopqrstuvwxyz');
self::log('Access key information for ' . $script);
self::log('Used labels: ' . implode(',', $labels));
self::log('Used keys: ' . implode('', $used));
@@ -1109,13 +1141,15 @@ public static function highlightAccessKey($label, $accessKey)
* @return string The title, and if appropriate, the accesskey attributes
* for the element.
*/
- public static function getAccessKeyAndTitle($label, $nocheck = false,
- $return_array = false)
- {
+ public static function getAccessKeyAndTitle(
+ $label,
+ $nocheck = false,
+ $return_array = false
+ ) {
$ak = self::getAccessKey($label, $nocheck);
- $attributes = array('title' => self::stripAccessKey($label));
+ $attributes = ['title' => self::stripAccessKey($label)];
if (!empty($ak)) {
- $attributes['title'] .= sprintf(Horde_Core_Translation::t(" (Accesskey %s)"), strtoupper($ak));
+ $attributes['title'] .= sprintf(Horde_Core_Translation::t(' (Accesskey %s)'), strtoupper($ak));
$attributes['accesskey'] = $ak;
}
@@ -1148,10 +1182,12 @@ public static function label($for, $label, $ak = null)
}
$label = self::highlightAccessKey($label, $ak);
- return sprintf('',
- $for,
- !empty($ak) ? ' accesskey="' . $ak . '"' : '',
- $label);
+ return sprintf(
+ '',
+ $for,
+ !empty($ak) ? ' accesskey="' . $ak . '"' : '',
+ $label
+ );
}
/**
@@ -1186,7 +1222,7 @@ public static function wrapInlineScript($script)
*
* @return Horde_Url The URL to the cache page.
*/
- public static function getCacheUrl($type, $params = array())
+ public static function getCacheUrl($type, $params = [])
{
$url = $GLOBALS['registry']
->getserviceLink('cache', 'horde')
@@ -1195,7 +1231,7 @@ public static function getCacheUrl($type, $params = array())
$url .= '/' . $key . '=' . rawurlencode(strval($val));
}
- return self::url($url, true, array('append_session' => -1));
+ return self::url($url, true, ['append_session' => -1]);
}
/**
@@ -1219,11 +1255,11 @@ public static function getCacheUrl($type, $params = array())
*
* @return string The javascript needed to call the popup code.
*/
- public static function popupJs($url, $options = array())
+ public static function popupJs($url, $options = [])
{
$GLOBALS['page_output']->addScriptPackage('Horde_Core_Script_Package_Popup');
- $params = new stdClass;
+ $params = new stdClass();
if (!$url instanceof Horde_Url) {
$url = new Horde_Url($url);
@@ -1232,7 +1268,7 @@ public static function popupJs($url, $options = array())
if (!empty($url->parameters)) {
if (!isset($options['params'])) {
- $options['params'] = array();
+ $options['params'] = [];
}
foreach (array_merge($url->parameters, $options['params']) as $key => $val) {
$options['params'][$key] = addcslashes($val, '"');
@@ -1242,13 +1278,13 @@ public static function popupJs($url, $options = array())
if (!empty($options['menu'])) {
$params->menu = 1;
}
- foreach (array('height', 'onload', 'params', 'width') as $key) {
+ foreach (['height', 'onload', 'params', 'width'] as $key) {
if (!empty($options[$key])) {
$params->$key = $options[$key];
}
}
- return 'void(HordePopup.popup(' . self::escapeJson($params, array('nodelimit' => true, 'urlencode' => !empty($options['urlencode']))) . '));';
+ return 'void(HordePopup.popup(' . self::escapeJson($params, ['nodelimit' => true, 'urlencode' => !empty($options['urlencode'])]) . '));';
}
/**
@@ -1307,13 +1343,13 @@ public static function sidebar($app = null)
}
$menu = new Horde_Menu();
- $registry->callAppMethod($app, 'menu', array(
- 'args' => array($menu)
- ));
+ $registry->callAppMethod($app, 'menu', [
+ 'args' => [$menu],
+ ]);
$sidebar = $menu->render();
- $registry->callAppMethod($app, 'sidebar', array(
- 'args' => array($sidebar)
- ));
+ $registry->callAppMethod($app, 'sidebar', [
+ 'args' => [$sidebar],
+ ]);
return $sidebar;
}
@@ -1331,8 +1367,9 @@ public static function permissionDeniedError($app, $perm, $error = null)
{
try {
$GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook('perms_denied', 'horde', array($app, $perm));
- } catch (Horde_Exception_HookNotSet $e) {}
+ ->callHook('perms_denied', 'horde', [$app, $perm]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
if (!is_null($error)) {
$GLOBALS['notification']->push($error, 'horde.warning');
@@ -1345,7 +1382,7 @@ public static function permissionDeniedError($app, $perm, $error = null)
public static function __callStatic($name, $arguments)
{
return call_user_func_array(
- array('Horde_Deprecated', $name),
+ ['Horde_Deprecated', $name],
$arguments
);
}
diff --git a/lib/Horde/Config.php b/lib/Horde/Config.php
index 2d87f1d69..c3ad49bcd 100644
--- a/lib/Horde/Config.php
+++ b/lib/Horde/Config.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_HttpClient')
- ->create(array(
+ ->create([
'request.timeout' => 60,
- 'request.userAgent' => 'Horde ' . $GLOBALS['registry']->getVersion('horde', true)
- ))
+ 'request.userAgent' => 'Horde ' . $GLOBALS['registry']->getVersion('horde', true),
+ ])
->get($this->_versionUrl);
if ($response->code != 200) {
throw new Horde_Exception('Unexpected response from server.');
@@ -138,15 +139,15 @@ public function checkVersions()
throw new Horde_Exception('Unexpected response from server.');
}
- $versions = array();
+ $versions = [];
foreach ($result as $package) {
uksort($package['versions'], 'version_compare');
$version = end($package['versions']);
- $versions[str_replace('pear-horde/', '', $package['name'])] = array(
+ $versions[str_replace('pear-horde/', '', $package['name'])] = [
'version' => $version['version'],
- 'url' => 'https://pear.horde.org/'
- );
+ 'url' => 'https://pear.horde.org/',
+ ];
}
return $versions;
@@ -212,7 +213,7 @@ public function readXMLConfig($custom_conf = null)
}
/* Parse the config file. */
- $this->_xmlConfigTree = array();
+ $this->_xmlConfigTree = [];
$root = $dom->documentElement;
if ($root->hasChildNodes()) {
$this->_parseLevel($this->_xmlConfigTree, $root->childNodes, '');
@@ -224,7 +225,7 @@ public function readXMLConfig($custom_conf = null)
$dom->load($additional);
$root = $dom->documentElement;
if ($root->hasChildNodes()) {
- $tree = array();
+ $tree = [];
$this->_parseLevel($tree, $root->childNodes, '');
$this->_xmlConfigTree = array_replace_recursive($this->_xmlConfigTree, $tree);
}
@@ -305,9 +306,9 @@ public function writePHPConfig($formvars, &$php = null)
$configFile = $this->configFile();
if (file_exists($configFile)) {
if (@copy($configFile, $path . '/conf.bak.php')) {
- $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Successfully saved the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.success');
+ $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t('Successfully saved the backup configuration file %s.'), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.success');
} else {
- $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Could not save the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.warning');
+ $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t('Could not save the backup configuration file %s.'), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.warning');
}
}
if ($fp = @fopen($configFile, 'w')) {
@@ -315,7 +316,7 @@ public function writePHPConfig($formvars, &$php = null)
fwrite($fp, $php);
fclose($fp);
$GLOBALS['registry']->rebuild();
- $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("Successfully wrote %s"), Horde_Util::realPath($configFile)), 'horde.success');
+ $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t('Successfully wrote %s'), Horde_Util::realPath($configFile)), 'horde.success');
return true;
}
@@ -390,7 +391,7 @@ protected function _generatePHPConfig($section, $prefix, $formvars)
} elseif (isset($configitem['switch'])) {
$val = $formvars->getExists($configname, $wasset);
if (!$wasset) {
- $val = isset($configitem['default']) ? $configitem['default'] : null;
+ $val = $configitem['default'] ?? null;
}
if (isset($configitem['switch'][$val])) {
$value = $val;
@@ -405,74 +406,74 @@ protected function _generatePHPConfig($section, $prefix, $formvars)
((array_key_exists('is_default', $configitem) && $configitem['is_default'])
|| !array_key_exists('is_default', $configitem))) {
- $val = isset($configitem['default']) ? $configitem['default'] : null;
+ $val = $configitem['default'] ?? null;
}
$type = $configitem['_type'];
switch ($type) {
- case 'multienum':
- if (is_array($val)) {
- $encvals = array();
- foreach ($val as $v) {
- $encvals[] = $this->_quote($v);
- }
- $arrayval = "'" . implode('\', \'', $encvals) . "'";
- if ($arrayval == "''") {
+ case 'multienum':
+ if (is_array($val)) {
+ $encvals = [];
+ foreach ($val as $v) {
+ $encvals[] = $this->_quote($v);
+ }
+ $arrayval = "'" . implode('\', \'', $encvals) . "'";
+ if ($arrayval == "''") {
+ $arrayval = '';
+ }
+ } else {
$arrayval = '';
}
- } else {
- $arrayval = '';
- }
- $value = 'array(' . $arrayval . ')';
- break;
-
- case 'boolean':
- if (is_bool($val)) {
- $value = $val ? 'true' : 'false';
- } else {
- $value = ($val == 'on') ? 'true' : 'false';
- }
- break;
+ $value = 'array(' . $arrayval . ')';
+ break;
- case 'stringlist':
- $values = explode(',', $val);
- if (!is_array($values)) {
- $value = "array('" . $this->_quote(trim($values)) . "')";
- } else {
- $encvals = array();
- foreach ($values as $v) {
- $encvals[] = $this->_quote(trim($v));
+ case 'boolean':
+ if (is_bool($val)) {
+ $value = $val ? 'true' : 'false';
+ } else {
+ $value = ($val == 'on') ? 'true' : 'false';
}
- $arrayval = "'" . implode('\', \'', $encvals) . "'";
- if ($arrayval == "''") {
- $arrayval = '';
+ break;
+
+ case 'stringlist':
+ $values = explode(',', $val);
+ if (!is_array($values)) {
+ $value = "array('" . $this->_quote(trim($values)) . "')";
+ } else {
+ $encvals = [];
+ foreach ($values as $v) {
+ $encvals[] = $this->_quote(trim($v));
+ }
+ $arrayval = "'" . implode('\', \'', $encvals) . "'";
+ if ($arrayval == "''") {
+ $arrayval = '';
+ }
+ $value = 'array(' . $arrayval . ')';
}
- $value = 'array(' . $arrayval . ')';
- }
- break;
-
- case 'int':
- if (strlen($val)) {
- $value = (int)$val;
- }
- break;
-
- case 'octal':
- $value = sprintf('0%o', octdec($val));
- break;
+ break;
- case 'header':
- case 'description':
- break;
-
- default:
- if ($val != '') {
- $value = $val;
- if ($quote && $value != 'true' && $value != 'false') {
- $value = "'" . $this->_quote($value) . "'";
+ case 'int':
+ if (strlen($val)) {
+ $value = (int)$val;
}
- }
- break;
+ break;
+
+ case 'octal':
+ $value = sprintf('0%o', octdec($val));
+ break;
+
+ case 'header':
+ case 'description':
+ break;
+
+ default:
+ if ($val != '') {
+ $value = $val;
+ if ($quote && $value != 'true' && $value != 'false') {
+ $value = "'" . $this->_quote($value) . "'";
+ }
+ }
+ break;
}
} else {
$this->_generatePHPConfig($configitem, $prefixedname, $formvars);
@@ -514,244 +515,244 @@ protected function _parseLevel(&$conf, $children, $ctx)
: $ctx . '|' . $name;
switch ($node->tagName) {
- case 'configdescription':
- if (empty($name)) {
- $name = uniqid(mt_rand());
- }
+ case 'configdescription':
+ if (empty($name)) {
+ $name = uniqid(mt_rand());
+ }
- $conf[$name] = array(
- '_type' => 'description',
- 'desc' => $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($this->_default($curctx, $this->_getNodeOnlyText($node)), 'linkurls')
- );
- break;
+ $conf[$name] = [
+ '_type' => 'description',
+ 'desc' => $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($this->_default($curctx, $this->_getNodeOnlyText($node)), 'linkurls'),
+ ];
+ break;
- case 'configheader':
- if (empty($name)) {
- $name = uniqid(mt_rand());
- }
+ case 'configheader':
+ if (empty($name)) {
+ $name = uniqid(mt_rand());
+ }
- $conf[$name] = array(
- '_type' => 'header',
- 'desc' => $this->_default($curctx, $this->_getNodeOnlyText($node))
- );
- break;
+ $conf[$name] = [
+ '_type' => 'header',
+ 'desc' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
+ ];
+ break;
- case 'configswitch':
- $values = $this->_getSwitchValues($node, $ctx);
- list($default, $isDefault) = $quote
- ? $this->__default($curctx, $this->_getNodeOnlyText($node))
- : $this->__defaultRaw($curctx, $this->_getNodeOnlyText($node));
+ case 'configswitch':
+ $values = $this->_getSwitchValues($node, $ctx);
+ [$default, $isDefault] = $quote
+ ? $this->__default($curctx, $this->_getNodeOnlyText($node))
+ : $this->__defaultRaw($curctx, $this->_getNodeOnlyText($node));
- if ($default === '') {
- $default = key($values);
- }
+ if ($default === '') {
+ $default = key($values);
+ }
- if (is_bool($default)) {
- $default = $default ? 'true' : 'false';
- }
+ if (is_bool($default)) {
+ $default = $default ? 'true' : 'false';
+ }
- $conf[$name] = array(
- 'desc' => $desc,
- 'switch' => $values,
- 'default' => $default,
- 'is_default' => $isDefault,
- 'quote' => $quote
- );
- break;
+ $conf[$name] = [
+ 'desc' => $desc,
+ 'switch' => $values,
+ 'default' => $default,
+ 'is_default' => $isDefault,
+ 'quote' => $quote,
+ ];
+ break;
- case 'configenum':
- $values = $this->_getEnumValues($node);
- list($default, $isDefault) = $quote
- ? $this->__default($curctx, $this->_getNodeOnlyText($node))
- : $this->__defaultRaw($curctx, $this->_getNodeOnlyText($node));
+ case 'configenum':
+ $values = $this->_getEnumValues($node);
+ [$default, $isDefault] = $quote
+ ? $this->__default($curctx, $this->_getNodeOnlyText($node))
+ : $this->__defaultRaw($curctx, $this->_getNodeOnlyText($node));
- if ($default === '') {
- $default = key($values);
- }
+ if ($default === '') {
+ $default = key($values);
+ }
- if (is_bool($default)) {
- $default = $default ? 'true' : 'false';
- }
+ if (is_bool($default)) {
+ $default = $default ? 'true' : 'false';
+ }
- $conf[$name] = array(
- '_type' => 'enum',
- 'required' => $required,
- 'quote' => $quote,
- 'values' => $values,
- 'desc' => $desc,
- 'default' => $default,
- 'is_default' => $isDefault
- );
- break;
+ $conf[$name] = [
+ '_type' => 'enum',
+ 'required' => $required,
+ 'quote' => $quote,
+ 'values' => $values,
+ 'desc' => $desc,
+ 'default' => $default,
+ 'is_default' => $isDefault,
+ ];
+ break;
- case 'configlist':
- list($default, $isDefault) = $this->__default($curctx, null);
+ case 'configlist':
+ [$default, $isDefault] = $this->__default($curctx, null);
- if (is_null($default)) {
- $default = $this->_getNodeOnlyText($node);
- } elseif (is_array($default)) {
- $default = implode(', ', $default);
- }
+ if (is_null($default)) {
+ $default = $this->_getNodeOnlyText($node);
+ } elseif (is_array($default)) {
+ $default = implode(', ', $default);
+ }
- $conf[$name] = array(
- '_type' => 'stringlist',
- 'required' => $required,
- 'desc' => $desc,
- 'default' => $default,
- 'is_default' => $isDefault
- );
- break;
+ $conf[$name] = [
+ '_type' => 'stringlist',
+ 'required' => $required,
+ 'desc' => $desc,
+ 'default' => $default,
+ 'is_default' => $isDefault,
+ ];
+ break;
- case 'configmultienum':
- $default = $this->_getNodeOnlyText($node);
- if (strlen($default)) {
- $default = explode(',', $default);
- } else {
- $default = array();
- }
- list($default, $isDefault) = $this->__default($curctx, $default);
-
- $conf[$name] = array(
- '_type' => 'multienum',
- 'required' => $required,
- 'values' => $this->_getEnumValues($node),
- 'desc' => $desc,
- 'default' => Horde_Array::valuesToKeys($default),
- 'is_default' => $isDefault
- );
- break;
+ case 'configmultienum':
+ $default = $this->_getNodeOnlyText($node);
+ if (strlen($default)) {
+ $default = explode(',', $default);
+ } else {
+ $default = [];
+ }
+ [$default, $isDefault] = $this->__default($curctx, $default);
+
+ $conf[$name] = [
+ '_type' => 'multienum',
+ 'required' => $required,
+ 'values' => $this->_getEnumValues($node),
+ 'desc' => $desc,
+ 'default' => Horde_Array::valuesToKeys($default),
+ 'is_default' => $isDefault,
+ ];
+ break;
- case 'configpassword':
- $conf[$name] = array(
- '_type' => 'password',
- 'required' => $required,
- 'desc' => $desc,
- 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
- 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node))
- );
- break;
+ case 'configpassword':
+ $conf[$name] = [
+ '_type' => 'password',
+ 'required' => $required,
+ 'desc' => $desc,
+ 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
+ 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node)),
+ ];
+ break;
- case 'configstring':
- $conf[$name] = array(
- '_type' => 'text',
- 'required' => $required,
- 'desc' => $desc,
- 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
- 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node))
- );
-
- if ($conf[$name]['default'] === false) {
- $conf[$name]['default'] = 'false';
- } elseif ($conf[$name]['default'] === true) {
- $conf[$name]['default'] = 'true';
- }
- break;
+ case 'configstring':
+ $conf[$name] = [
+ '_type' => 'text',
+ 'required' => $required,
+ 'desc' => $desc,
+ 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
+ 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node)),
+ ];
+
+ if ($conf[$name]['default'] === false) {
+ $conf[$name]['default'] = 'false';
+ } elseif ($conf[$name]['default'] === true) {
+ $conf[$name]['default'] = 'true';
+ }
+ break;
- case 'configboolean':
- $default = $this->_getNodeOnlyText($node);
- $default = !(empty($default) || $default === 'false');
-
- $conf[$name] = array(
- '_type' => 'boolean',
- 'required' => $required,
- 'desc' => $desc,
- 'default' => $this->_default($curctx, $default),
- 'is_default' => $this->_isDefault($curctx, $default)
- );
- break;
+ case 'configboolean':
+ $default = $this->_getNodeOnlyText($node);
+ $default = !(empty($default) || $default === 'false');
+
+ $conf[$name] = [
+ '_type' => 'boolean',
+ 'required' => $required,
+ 'desc' => $desc,
+ 'default' => $this->_default($curctx, $default),
+ 'is_default' => $this->_isDefault($curctx, $default),
+ ];
+ break;
- case 'configinteger':
- $values = $this->_getEnumValues($node);
-
- $conf[$name] = array(
- '_type' => 'int',
- 'required' => $required,
- 'values' => $values,
- 'desc' => $desc,
- 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
- 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node))
- );
-
- if ($node->getAttribute('octal') == 'true' &&
- $conf[$name]['default'] != '') {
- $conf[$name]['_type'] = 'octal';
- $conf[$name]['default'] = sprintf('0%o', $this->_default($curctx, octdec($this->_getNodeOnlyText($node))));
- }
- break;
+ case 'configinteger':
+ $values = $this->_getEnumValues($node);
+
+ $conf[$name] = [
+ '_type' => 'int',
+ 'required' => $required,
+ 'values' => $values,
+ 'desc' => $desc,
+ 'default' => $this->_default($curctx, $this->_getNodeOnlyText($node)),
+ 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node)),
+ ];
+
+ if ($node->getAttribute('octal') == 'true' &&
+ $conf[$name]['default'] != '') {
+ $conf[$name]['_type'] = 'octal';
+ $conf[$name]['default'] = sprintf('0%o', $this->_default($curctx, octdec($this->_getNodeOnlyText($node))));
+ }
+ break;
- case 'configldap':
- $conf[$node->getAttribute('switchname')] = $this->_configLDAP($ctx, $node);
- break;
+ case 'configldap':
+ $conf[$node->getAttribute('switchname')] = $this->_configLDAP($ctx, $node);
+ break;
- case 'configldapuser':
- $conf = array_merge($conf, $this->_configLDAPUser($ctx, $node));
- break;
+ case 'configldapuser':
+ $conf = array_merge($conf, $this->_configLDAPUser($ctx, $node));
+ break;
- case 'configphp':
- $conf[$name] = array(
- '_type' => 'php',
- 'required' => $required,
- 'quote' => false,
- 'desc' => $desc,
- 'default' => $this->_defaultRaw($curctx, $this->_getNodeOnlyText($node)),
- 'is_default' => $this->_isDefaultRaw($curctx, $this->_getNodeOnlyText($node))
- );
- break;
+ case 'configphp':
+ $conf[$name] = [
+ '_type' => 'php',
+ 'required' => $required,
+ 'quote' => false,
+ 'desc' => $desc,
+ 'default' => $this->_defaultRaw($curctx, $this->_getNodeOnlyText($node)),
+ 'is_default' => $this->_isDefaultRaw($curctx, $this->_getNodeOnlyText($node)),
+ ];
+ break;
- case 'configsecret':
- $conf[$name] = array(
- '_type' => 'text',
- 'required' => true,
- 'desc' => $desc,
- 'default' => $this->_default($curctx, strval(new Horde_Support_Randomid())),
- 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node))
- );
- break;
+ case 'configsecret':
+ $conf[$name] = [
+ '_type' => 'text',
+ 'required' => true,
+ 'desc' => $desc,
+ 'default' => $this->_default($curctx, strval(new Horde_Support_Randomid())),
+ 'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node)),
+ ];
+ break;
- case 'configsql':
- $conf[$node->getAttribute('switchname')] = $this->configSQL($ctx, $node);
- break;
+ case 'configsql':
+ $conf[$node->getAttribute('switchname')] = $this->configSQL($ctx, $node);
+ break;
- case 'confignosql':
- $conf[$node->getAttribute('switchname')] = $this->configNoSQL($ctx, $node);
- break;
+ case 'confignosql':
+ $conf[$node->getAttribute('switchname')] = $this->configNoSQL($ctx, $node);
+ break;
- case 'configvfs':
- $conf[$node->getAttribute('switchname')] = $this->_configVFS($ctx, $node);
- break;
+ case 'configvfs':
+ $conf[$node->getAttribute('switchname')] = $this->_configVFS($ctx, $node);
+ break;
- case 'configsection':
- $conf[$name] = array();
- $cur = &$conf[$name];
- if ($node->hasChildNodes()) {
- $this->_parseLevel($cur, $node->childNodes, $curctx);
- }
- break;
+ case 'configsection':
+ $conf[$name] = [];
+ $cur = &$conf[$name];
+ if ($node->hasChildNodes()) {
+ $this->_parseLevel($cur, $node->childNodes, $curctx);
+ }
+ break;
- case 'configtab':
- $key = uniqid(mt_rand());
+ case 'configtab':
+ $key = uniqid(mt_rand());
- $conf[$key] = array(
- 'tab' => $name,
- 'desc' => $desc
- );
+ $conf[$key] = [
+ 'tab' => $name,
+ 'desc' => $desc,
+ ];
- if ($node->hasChildNodes()) {
- $this->_parseLevel($conf, $node->childNodes, $ctx);
- }
- break;
+ if ($node->hasChildNodes()) {
+ $this->_parseLevel($conf, $node->childNodes, $ctx);
+ }
+ break;
- case 'configplaceholder':
- $conf[uniqid(mt_rand())] = 'placeholder';
- break;
+ case 'configplaceholder':
+ $conf[uniqid(mt_rand())] = 'placeholder';
+ break;
- default:
- $conf[$name] = array();
- $cur = &$conf[$name];
- if ($node->hasChildNodes()) {
- $this->_parseLevel($cur, $node->childNodes, $curctx);
- }
- break;
+ default:
+ $conf[$name] = [];
+ $cur = &$conf[$name];
+ if ($node->hasChildNodes()) {
+ $this->_parseLevel($cur, $node->childNodes, $curctx);
+ }
+ break;
}
}
}
@@ -770,56 +771,58 @@ protected function _parseLevel(&$conf, $children, $ctx)
*
* @return array An associative array with the LDAP configuration tree.
*/
- protected function _configLDAP($ctx, $node = null,
- $switchname = 'driverconfig')
- {
+ protected function _configLDAP(
+ $ctx,
+ $node = null,
+ $switchname = 'driverconfig'
+ ) {
if ($node) {
$xpath = new DOMXPath($node->ownerDocument);
}
$host = $node
? explode(',', ($xpath->evaluate('string(configstring[@name="hostspec"])', $node) ?: ''))
- : array();
+ : [];
$host = $this->_default($ctx . '|hostspec', $host);
- $fields = array(
- 'hostspec' => array(
+ $fields = [
+ 'hostspec' => [
'_type' => 'stringlist',
'required' => true,
'desc' => 'LDAP server(s)/hostname(s)',
'default' => is_array($host) ? implode(',', $host) : $host,
- ),
+ ],
- 'port' => array(
+ 'port' => [
'_type' => 'int',
'required' => false,
'desc' => 'Port on which LDAP is listening, if non-standard',
'default' => $this->_default(
$ctx . '|port',
$node ? ($xpath->evaluate('string(configinteger[@name="port"])', $node) ?: null) : null
- )
- ),
+ ),
+ ],
- 'tls' => array(
+ 'tls' => [
'_type' => 'boolean',
'required' => false,
'desc' => 'Use TLS to connect to the server?',
'default' => $this->_default(
$ctx . '|tls',
$node ? ($xpath->evaluate('string(configboolean[@name="tls"])', $node) ?: false) : false
- )
- ),
+ ),
+ ],
- 'timeout' => array(
+ 'timeout' => [
'_type' => 'int',
'required' => false,
'desc' => 'Connection timeout',
'default' => $this->_default(
$ctx . '|timeout',
$node ? ($xpath->evaluate('string(configinteger[@name="timeout"])', $node) ?: 5) : 5
- )
- ),
+ ),
+ ],
- 'version' => array(
+ 'version' => [
'_type' => 'int',
'required' => true,
'quote' => false,
@@ -828,61 +831,62 @@ protected function _configLDAP($ctx, $node = null,
$ctx . '|version',
$node ? ($xpath->evaluate('normalize-space(configswitch[@name="version"]/text())', $node) ?: 3) : 3
),
- 'switch' => array(
- '2' => array(
+ 'switch' => [
+ '2' => [
'desc' => '2 (deprecated)',
- 'fields' => array()
- ),
- '3' => array(
+ 'fields' => [],
+ ],
+ '3' => [
'desc' => '3',
- 'fields' => array()
- )
- ),
- ),
+ 'fields' => [],
+ ],
+ ],
+ ],
- 'bindas' => array(
+ 'bindas' => [
'desc' => 'Bind to LDAP as which user?',
'default' => $this->_default(
$ctx . '|bindas',
$node ? ($xpath->evaluate('normalize-space(configswitch[@name="bindas"]/text())', $node) ?: 'admin') : 'admin'
),
- 'switch' => array(
- 'anon' => array(
+ 'switch' => [
+ 'anon' => [
'desc' => 'Bind anonymously',
- 'fields' => $this->_configLDAPUser($ctx, $node)
- ),
- 'user' => array(
+ 'fields' => $this->_configLDAPUser($ctx, $node),
+ ],
+ 'user' => [
'desc' => 'Bind as the currently logged-in user',
- 'fields' => $this->_configLDAPUser($ctx, $node)
- ),
- 'admin' => array(
+ 'fields' => $this->_configLDAPUser($ctx, $node),
+ ],
+ 'admin' => [
'desc' => 'Bind with administrative/system credentials',
'fields' => array_merge(
- array(
- 'binddn' => array(
+ [
+ 'binddn' => [
'_type' => 'text',
'required' => true,
'desc' => 'DN used to bind to LDAP',
'default' => $this->_default(
$ctx . '|binddn',
$node ? ($xpath->evaluate('string(configsection/configstring[@name="binddn"])', $node) ?: '') : ''
- )
- ),
- 'bindpw' => array(
+ ),
+ ],
+ 'bindpw' => [
'_type' => 'text',
'required' => true,
'desc' => 'Password for bind DN',
'default' => $this->_default(
$ctx . '|bindpw',
- $node ? ($xpath->evaluate('string(configsection/configstring[@name="bindpw"])', $node) ?: '') : '')
- )
- ),
+ $node ? ($xpath->evaluate('string(configsection/configstring[@name="bindpw"])', $node) ?: '') : ''
+ ),
+ ],
+ ],
$this->_configLDAPUser($ctx, $node)
),
- ),
- )
- ),
- );
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->getAttribute('excludebind')) {
$excludes = explode(',', $node->getAttribute('excludebind'));
@@ -892,67 +896,68 @@ protected function _configLDAP($ctx, $node = null,
}
if (isset($node) && $node->getAttribute('baseconfig') == 'true') {
- return array(
+ return [
'desc' => 'Use LDAP?',
'default' => $this->_default(
$ctx . '|' . $node->getAttribute('switchname'),
$node ? ($xpath->evaluate('normalize-space(text())', $node) ?: false) : false
),
- 'switch' => array(
- 'false' => array(
+ 'switch' => [
+ 'false' => [
'desc' => 'No',
- 'fields' => array()
- ),
- 'true' => array(
+ 'fields' => [],
+ ],
+ 'true' => [
'desc' => 'Yes',
- 'fields' => $fields
- ),
- )
- );
+ 'fields' => $fields,
+ ],
+ ],
+ ];
}
- $standardFields = array(
- 'basedn' => array(
+ $standardFields = [
+ 'basedn' => [
'_type' => 'text',
'required' => true,
'desc' => 'Base DN',
'default' => $this->_default(
$ctx . '|basedn',
$node ? ($xpath->evaluate('string(configstring[@name="basedn"])', $node) ?: '') : ''
- )
- ),
- 'scope' => array(
+ ),
+ ],
+ 'scope' => [
'_type' => 'enum',
'required' => true,
'desc' => 'Search scope',
'default' => $this->_default(
$ctx . '|scope',
- $node ? ($xpath->evaluate('normalize-space(configenum[@name="scope"]/text())', $node) ?: '') : ''),
- 'values' => array(
+ $node ? ($xpath->evaluate('normalize-space(configenum[@name="scope"]/text())', $node) ?: '') : ''
+ ),
+ 'values' => [
'sub' => 'Subtree search',
- 'one' => 'One level'),
- ),
- );
+ 'one' => 'One level'],
+ ],
+ ];
- list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
- $config = array(
+ [$default, $isDefault] = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
+ $config = [
'desc' => 'Driver configuration',
'default' => $default,
'is_default' => $isDefault,
- 'switch' => array(
- 'horde' => array(
+ 'switch' => [
+ 'horde' => [
'desc' => 'Horde defaults',
'fields' => $standardFields,
- ),
- 'custom' => array(
+ ],
+ 'custom' => [
'desc' => 'Custom parameters',
'fields' => $fields + $standardFields,
- )
- )
- );
+ ],
+ ],
+ ];
if (isset($node) && $node->hasChildNodes()) {
- $cur = array();
+ $cur = [];
$this->_parseLevel($cur, $node->childNodes, $ctx);
$config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur);
$config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur);
@@ -980,64 +985,66 @@ protected function _configLDAPUser($ctx, $node = null)
$xpath = new DOMXPath($node->ownerDocument);
}
- return array(
- 'user' => array(
- 'basedn' => array(
+ return [
+ 'user' => [
+ 'basedn' => [
'_type' => 'text',
'required' => false,
'desc' => 'Base DN for searching the user\'s DN',
'default' => $this->_default(
$ctx . '|user|basedn',
$node ? ($xpath->evaluate('string(configsection/configstring[@name="basedn"])', $node) ?: '') : ''
- )
- ),
- 'uid' => array(
+ ),
+ ],
+ 'uid' => [
'_type' => 'text',
'required' => true,
'desc' => 'The username search key (set to samaccountname for AD).',
'default' => $this->_default(
$ctx . '|user|uid',
$node ? ($xpath->evaluate('string(configsection/configstring[@name="uid"])', $node) ?: 'uid') : 'uid'
- )
- ),
- 'filter_type' => array(
+ ),
+ ],
+ 'filter_type' => [
'required' => false,
'desc' => 'How to specify a filter for the user lists.',
'default' => $this->_default(
$ctx . '|user|filter_type',
- $node ? ($xpath->evaluate('normalize-space(configsection/configswitch[@name="filter_type"]/text())', $node) ?: 'objectclass') : 'objectclass'),
- 'switch' => array(
- 'filter' => array(
+ $node ? ($xpath->evaluate('normalize-space(configsection/configswitch[@name="filter_type"]/text())', $node) ?: 'objectclass') : 'objectclass'
+ ),
+ 'switch' => [
+ 'filter' => [
'desc' => 'LDAP filter string',
- 'fields' => array(
- 'filter' => array(
+ 'fields' => [
+ 'filter' => [
'_type' => 'text',
'required' => true,
'desc' => 'The LDAP filter string used to search for users.',
'default' => $this->_default(
$ctx . '|user|filter',
$node ? ($xpath->evaluate('string(configsection/configstring[@name="filter"])', $node) ?: '(objectClass=*)') : '(objectClass=*)'
- )
- ),
- ),
- ),
- 'objectclass' => array(
+ ),
+ ],
+ ],
+ ],
+ 'objectclass' => [
'desc' => 'List of objectClasses',
- 'fields' => array(
- 'objectclass' => array(
+ 'fields' => [
+ 'objectclass' => [
'_type' => 'stringlist',
'required' => true,
'desc' => 'The objectclass filter used to search for users. Can be a single objectclass or a comma-separated list.',
'default' => implode(', ', $this->_default(
$ctx . '|user|objectclass',
- $node ? ($xpath->evaluate('string(configsection/configlist[@name="objectclass"])', $node) ?: array('*')) : array('*')))
- ),
- ),
- ),
- ),
- ),
- ),
- );
+ $node ? ($xpath->evaluate('string(configsection/configlist[@name="objectclass"])', $node) ?: ['*']) : ['*']
+ )),
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
}
/**
@@ -1054,76 +1061,78 @@ protected function _configLDAPUser($ctx, $node = null)
*
* @return array An associative array with the SQL configuration tree.
*/
- public function configNoSQL($ctx, $node = null,
- $switchname = 'driverconfig')
- {
+ public function configNoSQL(
+ $ctx,
+ $node = null,
+ $switchname = 'driverconfig'
+ ) {
if ($node) {
$xpath = new DOMXPath($node->ownerDocument);
}
- $custom_fields = array(
+ $custom_fields = [
'required' => true,
'desc' => 'What database backend should we use?',
'default' => $this->_default(
$ctx . '|phptype',
$node ? $node->getAttribute('default') : ''
),
- 'switch' => array(
- 'false' => array(
+ 'switch' => [
+ 'false' => [
'desc' => '[None]',
- 'fields' => array()
- ),
- 'mongo' => array(
+ 'fields' => [],
+ ],
+ 'mongo' => [
'desc' => 'MongoDB',
- 'fields' => array(
- 'hostspec' => array(
+ 'fields' => [
+ 'hostspec' => [
'_type' => 'text',
'required' => false,
'desc' => 'Server specification (format: "mongodb://[username:password@]host1[:port1][,host2[:port2:],...]/db"; see http://www.php.net/manual/en/mongoclient.construct.php for further details)',
'default' => $this->_default(
$ctx . '|hostspec',
$node ? ($xpath->evaluate('string(configstring[@name="hostspec"])', $node) ?: '') : ''
- )
- ),
- 'dbname' => array(
+ ),
+ ],
+ 'dbname' => [
'_type' => 'text',
'required' => false,
'desc' => 'Database name to use',
'default' => $this->_default(
$ctx . '|dbname',
$node ? ($xpath->evaluate('string(configstring[@name="dbname"])', $node) ?: '') : ''
- )
- )
- )
- )
- )
- );
+ ),
+ ],
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->getAttribute('baseconfig') == 'true') {
return $custom_fields;
}
- list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
- $config = array(
+ [$default, $isDefault] = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
+ $config = [
'desc' => 'NoSQL driver configuration',
'default' => $default,
'is_default' => $isDefault,
- 'switch' => array(
- 'horde' => array(
+ 'switch' => [
+ 'horde' => [
'desc' => 'Horde defaults',
- 'fields' => array()
- ),
- 'custom' => array(
+ 'fields' => [],
+ ],
+ 'custom' => [
'desc' => 'Custom parameters',
- 'fields' => array(
- 'phptype' => $custom_fields
- )
- )
- )
- );
+ 'fields' => [
+ 'phptype' => $custom_fields,
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->hasChildNodes()) {
- $cur = array();
+ $cur = [];
$this->_parseLevel($cur, $node->childNodes, $ctx);
$config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur);
$config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur);
@@ -1152,86 +1161,88 @@ public function configSQL($ctx, $node = null, $switchname = 'driverconfig')
$xpath = new DOMXPath($node->ownerDocument);
}
- $hostspec = array(
+ $hostspec = [
'_type' => 'text',
'required' => true,
'desc' => 'Database server/host',
'default' => $this->_default(
$ctx . '|hostspec',
$node ? ($xpath->evaluate('string(configstring[@name="hostspec"])', $node) ?: '') : ''
- )
- );
+ ),
+ ];
- $username = array(
+ $username = [
'_type' => 'text',
'required' => true,
'desc' => 'Username to connect to the database as',
'default' => $this->_default(
$ctx . '|username',
$node ? ($xpath->evaluate('string(configstring[@name="username"])', $node) ?: '') : ''
- )
- );
+ ),
+ ];
- $password = array(
+ $password = [
'_type' => 'text',
'required' => false,
'desc' => 'Password to connect with',
'default' => $this->_default(
$ctx . '|password',
- $node ? ($xpath->evaluate('string(configstring[@name="password"])', $node) ?: '') : ''
- )
- );
+ $node ? ($xpath->evaluate('string(configstring[@name="password"])', $node) ?: '') : ''
+ ),
+ ];
- $database = array(
+ $database = [
'_type' => 'text',
'required' => true,
'desc' => 'Database name to use',
'default' => $this->_default(
$ctx . '|database',
$node ? ($xpath->evaluate('string(configstring[@name="database"])', $node) ?: '') : ''
- )
- );
+ ),
+ ];
- $socket = array(
+ $socket = [
'_type' => 'text',
'required' => false,
'desc' => 'Location of UNIX socket',
'default' => $this->_default(
$ctx . '|socket',
$node ? ($xpath->evaluate('string(configstring[@name="socket"])', $node) ?: '') : ''
- )
- );
+ ),
+ ];
- $port = array(
+ $port = [
'_type' => 'int',
'required' => false,
'desc' => 'Port the DB is running on, if non-standard',
'default' => $this->_default(
$ctx . '|port',
- $node ? ($xpath->evaluate('string(configinteger[@name="port"])', $node) ?: null) : null)
- );
+ $node ? ($xpath->evaluate('string(configinteger[@name="port"])', $node) ?: null) : null
+ ),
+ ];
- $protocol = array(
+ $protocol = [
'desc' => 'How should we connect to the database?',
'default' => $this->_default(
$ctx . '|protocol',
- $node ? ($xpath->evaluate('normalize-space(configswitch[@name="protocol"]/text())', $node) ?: 'unix') : 'unix'),
- 'switch' => array(
- 'unix' => array(
+ $node ? ($xpath->evaluate('normalize-space(configswitch[@name="protocol"]/text())', $node) ?: 'unix') : 'unix'
+ ),
+ 'switch' => [
+ 'unix' => [
'desc' => 'UNIX Sockets',
- 'fields' => array(
- 'socket' => $socket
- )
- ),
- 'tcp' => array(
+ 'fields' => [
+ 'socket' => $socket,
+ ],
+ ],
+ 'tcp' => [
'desc' => 'TCP/IP',
- 'fields' => array(
+ 'fields' => [
'hostspec' => $hostspec,
- 'port' => $port
- )
- )
- )
- );
+ 'port' => $port,
+ ],
+ ],
+ ],
+ ];
$mysql_protocol = $protocol;
$mysql_protocol['switch']['tcp']['fields']['port']['default'] =
@@ -1243,69 +1254,72 @@ public function configSQL($ctx, $node = null, $switchname = 'driverconfig')
$pgsql_protocol = $protocol;
$pgsql_protocol['switch']['unix']['fields']['port'] = $port;
- $charset = array(
+ $charset = [
'_type' => 'text',
'required' => true,
'desc' => 'Internally used charset',
'default' => $this->_default(
$ctx . '|charset',
- $node ? ($xpath->evaluate('string(configstring[@name="charset"])', $node) ?: 'utf-8') : 'utf-8')
- );
+ $node ? ($xpath->evaluate('string(configstring[@name="charset"])', $node) ?: 'utf-8') : 'utf-8'
+ ),
+ ];
- $ssl = array(
+ $ssl = [
'_type' => 'boolean',
'required' => false,
'desc' => 'Use SSL to connect to the server?',
'default' => $this->_default(
$ctx . '|ssl',
- $node ? ($xpath->evaluate('string(configboolean[@name="ssl"])', $node) ?: false) : false),
- 'switch' => array(
- 'false' => array('desc' => 'No', 'fields' => array()),
- 'true' => array(
+ $node ? ($xpath->evaluate('string(configboolean[@name="ssl"])', $node) ?: false) : false
+ ),
+ 'switch' => [
+ 'false' => ['desc' => 'No', 'fields' => []],
+ 'true' => [
'desc' => 'Yes',
- 'fields' => array(
- 'ca' => array(
+ 'fields' => [
+ 'ca' => [
'_type' => 'text',
'required' => false,
'desc' => 'Certification Authority to use for SSL connections',
'default' => $this->_default(
$ctx . '|ca',
$node ? ($xpath->evaluate('string(configstring[@name="ca"])', $node) ?: '') : ''
- )
- )
- )
- )
- )
- );
+ ),
+ ],
+ ],
+ ],
+ ],
+ ];
- list($default, $isDefault) = $this->__default(
+ [$default, $isDefault] = $this->__default(
$ctx . '|logqueries',
$node
? ($xpath->evaluate('string(configboolean[@name="logqueries"])', $node) ?: false)
- : false);
- $logqueries = array(
+ : false
+ );
+ $logqueries = [
'_type' => 'boolean',
'required' => false,
'desc' => 'Should Horde log all queries. If selected, queries will be logged at the DEBUG level to your configured logger.',
'default' => $default,
'is_default' => $isDefault,
- );
+ ];
- $custom_fields = array(
+ $custom_fields = [
'required' => true,
'desc' => 'What database backend should we use?',
'default' => $this->_default(
$ctx . '|phptype',
$node ? $node->getAttribute('default') : ''
),
- 'switch' => array(
- 'false' => array(
+ 'switch' => [
+ 'false' => [
'desc' => '[None]',
- 'fields' => array()
- ),
- 'mysql' => array(
+ 'fields' => [],
+ ],
+ 'mysql' => [
'desc' => 'MySQL / PDO',
- 'fields' => array(
+ 'fields' => [
'username' => $username,
'password' => $password,
'protocol' => $mysql_protocol,
@@ -1314,11 +1328,11 @@ public function configSQL($ctx, $node = null, $switchname = 'driverconfig')
'ssl' => $ssl,
'splitread' => $this->_configSQLSplitRead($ctx, $node, 'mysql'),
'logqueries' => $logqueries,
- )
- ),
- 'mysqli' => array(
+ ],
+ ],
+ 'mysqli' => [
'desc' => 'MySQL (mysqli)',
- 'fields' => array(
+ 'fields' => [
'username' => $username,
'password' => $password,
'protocol' => $mysql_protocol,
@@ -1327,72 +1341,77 @@ public function configSQL($ctx, $node = null, $switchname = 'driverconfig')
'ssl' => $ssl,
'splitread' => $this->_configSQLSplitRead($ctx, $node, 'mysqli'),
'logqueries' => $logqueries,
- )
- ),
- 'oci8' => array(
+ ],
+ ],
+ 'oci8' => [
'desc' => 'Oracle',
- 'fields' => array(
+ 'fields' => [
'username' => $username,
'password' => $password,
'charset' => $charset,
- 'method' => array(
+ 'method' => [
'desc' => 'How should the database connection be specified',
'default' => $this->_default(
$ctx . '|method',
- $node ? ($xpath->evaluate('normalize-space(configswitch[@name="method"]/text())', $node) ?: 'easy') : 'easy'),
- 'switch' => array(
- 'tns' => array(
+ $node ? ($xpath->evaluate('normalize-space(configswitch[@name="method"]/text())', $node) ?: 'easy') : 'easy'
+ ),
+ 'switch' => [
+ 'tns' => [
'desc' => 'TNS',
- 'fields' => array(
- 'tns' => array(
+ 'fields' => [
+ 'tns' => [
'_type' => 'text',
'required' => true,
'desc' => 'Connect name from tnsnames.ora',
'default' => $this->_default(
$ctx . '|tns',
- $node ? ($xpath->evaluate('string(configstring[@name="tns"])', $node) ?: false) : false),
- ),
- ),
- ),
- 'easy' => array(
+ $node ? ($xpath->evaluate('string(configstring[@name="tns"])', $node) ?: false) : false
+ ),
+ ],
+ ],
+ ],
+ 'easy' => [
'desc' => 'Easy Connect',
- 'fields' => array(
+ 'fields' => [
'hostspec' => $hostspec,
'port' => $port,
- 'service' => array(
+ 'service' => [
'_type' => 'text',
'required' => false,
'desc' => 'Service name',
'default' => $this->_default(
$ctx . '|service',
- $node ? ($xpath->evaluate('string(configstring[@name="service"])', $node) ?: false) : false),
- ),
- 'type' => array(
+ $node ? ($xpath->evaluate('string(configstring[@name="service"])', $node) ?: false) : false
+ ),
+ ],
+ 'type' => [
'_type' => 'text',
'required' => false,
'desc' => 'Server type',
'default' => $this->_default(
$ctx . '|type',
- $node ? ($xpath->evaluate('string(configstring[@name="type"])', $node) ?: false) : false),
- ),
- 'instance' => array(
+ $node ? ($xpath->evaluate('string(configstring[@name="type"])', $node) ?: false) : false
+ ),
+ ],
+ 'instance' => [
'_type' => 'text',
'required' => false,
'desc' => 'Instance name',
'default' => $this->_default(
$ctx . '|instance',
- $node ? ($xpath->evaluate('string(configstring[@name="instance"])', $node) ?: false) : false),
- ),
- ),
- ),
- ),
- ),
+ $node ? ($xpath->evaluate('string(configstring[@name="instance"])', $node) ?: false) : false
+ ),
+ ],
+ ],
+ ],
+ ],
+ ],
'logqueries' => $logqueries,
- ),
- ),
- 'pgsql' => array(
+ ],
+ ],
+ 'pgsql' => [
'desc' => 'PostgreSQL',
- 'fields' => array(
+ 'fields' => [
'username' => $username,
'password' => $password,
'protocol' => $pgsql_protocol,
@@ -1400,52 +1419,52 @@ public function configSQL($ctx, $node = null, $switchname = 'driverconfig')
'charset' => $charset,
'splitread' => $this->_configSQLSplitRead($ctx, $node, 'pgsql'),
'logqueries' => $logqueries,
- )
- ),
- 'sqlite' => array(
+ ],
+ ],
+ 'sqlite' => [
'desc' => 'SQLite',
- 'fields' => array(
- 'database' => array(
+ 'fields' => [
+ 'database' => [
'_type' => 'text',
'required' => true,
'desc' => 'Absolute path to the database file',
'default' => $this->_default(
$ctx . '|database',
$node ? ($xpath->evaluate('string(configstring[@name="database"])', $node) ?: '') : ''
- )
- ),
+ ),
+ ],
'charset' => $charset,
'logqueries' => $logqueries,
- )
- )
- )
- );
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->getAttribute('baseconfig') == 'true') {
return $custom_fields;
}
- list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
- $config = array(
+ [$default, $isDefault] = $this->__default($ctx . '|' . (isset($node) ? $node->getAttribute('switchname') : $switchname), 'horde');
+ $config = [
'desc' => 'Driver configuration',
'default' => $default,
'is_default' => $isDefault,
- 'switch' => array(
- 'horde' => array(
+ 'switch' => [
+ 'horde' => [
'desc' => 'Horde defaults',
- 'fields' => array()
- ),
- 'custom' => array(
+ 'fields' => [],
+ ],
+ 'custom' => [
'desc' => 'Custom parameters',
- 'fields' => array(
- 'phptype' => $custom_fields
- )
- )
- )
- );
+ 'fields' => [
+ 'phptype' => $custom_fields,
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->hasChildNodes()) {
- $cur = array();
+ $cur = [];
$this->_parseLevel($cur, $node->childNodes, $ctx);
$config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur);
$config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur);
@@ -1477,24 +1496,25 @@ protected function _configSQLSplitRead($ctx, $node, $phptype)
$splitread_fields = $this->configSQL($ctx . '|read');
$splitread_fields = $splitread_fields['switch']['custom']['fields']['phptype']['switch'][$phptype]['fields'];
- return array(
+ return [
'_type' => 'boolean',
'required' => false,
'desc' => 'Split reads to a different server?',
'default' => $this->_default(
$ctx . '|splitread',
- $node ? ($xpath->evaluate('normalize-space(configswitch[@name="splitread"]/text())', $node) ?: 'false') : 'false'),
- 'switch' => array(
- 'false' => array(
+ $node ? ($xpath->evaluate('normalize-space(configswitch[@name="splitread"]/text())', $node) ?: 'false') : 'false'
+ ),
+ 'switch' => [
+ 'false' => [
'desc' => 'Disabled',
- 'fields' => array()
- ),
- 'true' => array(
+ 'fields' => [],
+ ],
+ 'true' => [
'desc' => 'Enabled',
- 'fields' => array('read' => $splitread_fields)
- )
- )
- );
+ 'fields' => ['read' => $splitread_fields],
+ ],
+ ],
+ ];
}
/**
@@ -1515,107 +1535,108 @@ protected function _configVFS($ctx, $node)
$sql = $this->configSQL($ctx . '|params');
$default = $node->getAttribute('default');
$default = empty($default) ? 'horde' : $default;
- list($default, $isDefault) = $this->__default($ctx . '|' . $node->getAttribute('switchname'), $default);
+ [$default, $isDefault] = $this->__default($ctx . '|' . $node->getAttribute('switchname'), $default);
$xpath = new DOMXPath($node->ownerDocument);
- $config = array(
+ $config = [
'desc' => 'What VFS driver should we use?',
'default' => $default,
'is_default' => $isDefault,
- 'switch' => array(
- 'None' => array(
+ 'switch' => [
+ 'None' => [
'desc' => 'None',
- 'fields' => array()
- ),
- 'File' => array(
+ 'fields' => [],
+ ],
+ 'File' => [
'desc' => 'Files on the local system',
- 'fields' => array(
- 'params' => array(
- 'vfsroot' => array(
+ 'fields' => [
+ 'params' => [
+ 'vfsroot' => [
'_type' => 'text',
'desc' => 'Where on the real filesystem should Horde use as root of the virtual filesystem?',
'default' => $this->_default(
$ctx . '|params|vfsroot',
$xpath->evaluate('string(configsection/configstring[@name="vfsroot"])', $node) ?: '/tmp'
- )
- )
- )
- )
- ),
- 'Nosql' => array(
+ ),
+ ],
+ ],
+ ],
+ ],
+ 'Nosql' => [
'desc' => 'NoSQL database',
- 'fields' => array(
- 'params' => array(
- 'driverconfig' => $nosql
- )
- )
- ),
- 'Sql' => array(
+ 'fields' => [
+ 'params' => [
+ 'driverconfig' => $nosql,
+ ],
+ ],
+ ],
+ 'Sql' => [
'desc' => 'SQL database',
- 'fields' => array(
- 'params' => array(
- 'driverconfig' => $sql
- )
- )
- ),
- 'Ssh2' => array(
+ 'fields' => [
+ 'params' => [
+ 'driverconfig' => $sql,
+ ],
+ ],
+ ],
+ 'Ssh2' => [
'desc' => 'SSH2 (SFTP)',
- 'fields' => array(
- 'params' => array(
- 'hostspec' => array(
+ 'fields' => [
+ 'params' => [
+ 'hostspec' => [
'_type' => 'text',
'required' => true,
'desc' => 'SSH server/host',
'default' => $this->_default(
$ctx . '|hostspec',
$xpath->evaluate('string(configsection/configstring[@name="hostspec"])', $node) ?: ''
- )
- ),
- 'port' => array(
+ ),
+ ],
+ 'port' => [
'_type' => 'text',
'required' => false,
'desc' => 'Port number on which SSH listens',
'default' => $this->_default(
$ctx . '|port',
$xpath->evaluate('string(configsection/configstring[@name="port"])', $node) ?: '22'
- )
- ),
- 'username' => array(
+ ),
+ ],
+ 'username' => [
'_type' => 'text',
'required' => true,
'desc' => 'Username to connect to the SSH server',
'default' => $this->_default(
$ctx . '|username',
$xpath->evaluate('string(configsection/configstring[@name="username"])', $node) ?: ''
- )
- ),
- 'password' => array(
+ ),
+ ],
+ 'password' => [
'_type' => 'text',
'required' => true,
'desc' => 'Password with which to connect',
'default' => $this->_default(
$ctx . '|password',
$xpath->evaluate('string(configsection/configstring[@name="password"])', $node) ?: ''
- )
- ),
- 'vfsroot' => array(
+ ),
+ ],
+ 'vfsroot' => [
'_type' => 'text',
'desc' => 'Where on the real filesystem should Horde use as root of the virtual filesystem?',
'default' => $this->_default(
$ctx . '|vfsroot',
- $xpath->evaluate('string(configsection/configstring[@name="vfsroot"])', $node) ?: '/tmp')
- )
- )
- )
- )
- )
- );
+ $xpath->evaluate('string(configsection/configstring[@name="vfsroot"])', $node) ?: '/tmp'
+ ),
+ ],
+ ],
+ ],
+ ],
+ ],
+ ];
if (isset($node) && $node->getAttribute('baseconfig') != 'true') {
- $config['switch']['horde'] = array(
+ $config['switch']['horde'] = [
'desc' => 'Horde defaults',
- 'fields' => array()
- );
+ 'fields' => [],
+ ];
}
$cases = $this->_getSwitchValues($node, $ctx . '|params');
foreach ($cases as $case => $fields) {
@@ -1641,7 +1662,7 @@ protected function _configVFS($ctx, $node)
*/
protected function _default($ctx, $default)
{
- list ($ptr,) = $this->__default($ctx, $default);
+ [$ptr, ] = $this->__default($ctx, $default);
return $ptr;
}
@@ -1658,7 +1679,7 @@ protected function _default($ctx, $default)
*/
protected function _isDefault($ctx, $default)
{
- list (,$isDefault) = $this->__default($ctx, $default);
+ [, $isDefault] = $this->__default($ctx, $default);
return $isDefault;
}
@@ -1685,13 +1706,13 @@ protected function __default($ctx, $default)
for ($i = 0, $ctx_count = count($ctx); $i < $ctx_count; ++$i) {
if (!isset($ptr[$ctx[$i]])) {
- return array($default, true);
+ return [$default, true];
}
$ptr = $ptr[$ctx[$i]];
}
- return array($ptr, false);
+ return [$ptr, false];
}
/**
@@ -1710,7 +1731,7 @@ protected function __default($ctx, $default)
*/
protected function _defaultRaw($ctx, $default)
{
- list ($ptr,) = $this->__defaultRaw($ctx, $default);
+ [$ptr, ] = $this->__defaultRaw($ctx, $default);
return $ptr;
}
@@ -1727,7 +1748,7 @@ protected function _defaultRaw($ctx, $default)
*/
protected function _isDefaultRaw($ctx, $default)
{
- list (,$isDefault) = $this->__defaultRaw($ctx, $default);
+ [, $isDefault] = $this->__defaultRaw($ctx, $default);
return $isDefault;
}
@@ -1756,8 +1777,8 @@ protected function __defaultRaw($ctx, $default)
$pattern = '/^\$conf\[\'' . implode("'\]\['", $ctx) . '\'\] = (.*);\r?$/m';
return preg_match($pattern, $this->getPHPConfig(), $matches)
- ? array($matches[1], false)
- : array($default, true);
+ ? [$matches[1], false]
+ : [$default, true];
}
/**
@@ -1799,7 +1820,7 @@ protected function _getNodeOnlyText($node)
*/
protected function _getEnumValues($node)
{
- $values = array();
+ $values = [];
if (!$node->hasChildNodes()) {
return $values;
@@ -1809,7 +1830,7 @@ protected function _getEnumValues($node)
if ($vnode->nodeType == XML_ELEMENT_NODE &&
$vnode->tagName == 'values') {
if (!$vnode->hasChildNodes()) {
- return array();
+ return [];
}
foreach ($vnode->childNodes as $value) {
@@ -1841,7 +1862,7 @@ protected function _getEnumValues($node)
*/
protected function _getSwitchValues(&$node, $curctx)
{
- $values = array();
+ $values = [];
if (!$node->hasChildNodes()) {
return $values;
@@ -1850,10 +1871,10 @@ protected function _getSwitchValues(&$node, $curctx)
foreach ($node->childNodes as $case) {
if ($case->nodeType == XML_ELEMENT_NODE) {
$name = $case->getAttribute('name');
- $values[$name] = array(
+ $values[$name] = [
'desc' => $case->getAttribute('desc'),
- 'fields' => array()
- );
+ 'fields' => [],
+ ];
if ($case->hasChildNodes()) {
$this->_parseLevel($values[$name]['fields'], $case->childNodes, $curctx);
}
@@ -1880,15 +1901,15 @@ protected function _handleSpecials($node)
$app = $GLOBALS['registry']->hasInterface($app);
}
} catch (Horde_Exception $e) {
- return array();
+ return [];
}
if (!$app) {
- return array();
+ return [];
}
try {
- return $GLOBALS['registry']->callAppMethod($app, 'configSpecialValues', array('args' => array($node->getAttribute('name')), 'noperms' => true));
+ return $GLOBALS['registry']->callAppMethod($app, 'configSpecialValues', ['args' => [$node->getAttribute('name')], 'noperms' => true]);
} catch (Horde_Exception $e) {
- return array();
+ return [];
}
}
diff --git a/lib/Horde/Config/Form.php b/lib/Horde/Config/Form.php
index 718b4c2f4..2168e1d37 100644
--- a/lib/Horde/Config/Form.php
+++ b/lib/Horde/Config/Form.php
@@ -1,4 +1,5 @@
setSection($configitem['tab'], $configitem['desc']);
} elseif (isset($configitem['switch'])) {
$selected = $this->_vars->getExists($varname, $wasset);
- $var_params = array();
+ $var_params = [];
$select_option = true;
if (is_bool($configitem['default'])) {
$configitem['default'] = $configitem['default'] ? 'true' : 'false';
@@ -101,7 +102,7 @@ protected function _buildVariables($config, $prefix = '')
$name = '$conf[' . implode('][', explode('|', $prefixedname)) . ']';
$desc = $configitem['desc'];
- $v = $this->addVariable($name, $varname, 'enum', true, false, $desc, array($var_params, $select_option));
+ $v = $this->addVariable($name, $varname, 'enum', true, false, $desc, [$var_params, $select_option]);
if (array_key_exists('default', $configitem)) {
$v->setDefault($configitem['default']);
if ($this->_fillvars) {
@@ -122,8 +123,8 @@ protected function _buildVariables($config, $prefix = '')
}
$var_params = ($type == 'multienum' || $type == 'enum')
- ? array($configitem['values'])
- : array();
+ ? [$configitem['values']]
+ : [];
if ($type == 'header' || $type == 'description') {
$name = $configitem['desc'];
@@ -142,17 +143,17 @@ protected function _buildVariables($config, $prefix = '')
$v->setDefault($configitem['default']);
if ($this->_fillvars) {
switch ($type) {
- case 'boolean':
- if ($configitem['default']) {
- $this->_vars->set($varname, 'on');
- }
- break;
- case 'int':
- $this->_vars->set($varname, (string)$configitem['default']);
- break;
- default:
- $this->_vars->set($varname, $configitem['default']);
- break;
+ case 'boolean':
+ if ($configitem['default']) {
+ $this->_vars->set($varname, 'on');
+ }
+ break;
+ case 'int':
+ $this->_vars->set($varname, (string)$configitem['default']);
+ break;
+ default:
+ $this->_vars->set($varname, $configitem['default']);
+ break;
}
}
}
diff --git a/lib/Horde/Core/ActiveSync/Auth.php b/lib/Horde/Core/ActiveSync/Auth.php
index 835408b54..e82552cfa 100644
--- a/lib/Horde/Core/ActiveSync/Auth.php
+++ b/lib/Horde/Core/ActiveSync/Auth.php
@@ -1,4 +1,5 @@
_registry->calendar->listUids($calendar, $startstamp, $endstamp);
} catch (Exception $e) {
- return array();
+ return [];
}
}
@@ -118,9 +119,9 @@ public function calendar_listUids($startstamp, $endstamp, $calendar)
*
* @return Horde_ActiveSync_Message_Appointment The requested event.
*/
- public function calendar_export($uid, array $options = array(), $calendar = null)
+ public function calendar_export($uid, array $options = [], $calendar = null)
{
- $calendar = empty($calendar) ? null : array($calendar);
+ $calendar = empty($calendar) ? null : [$calendar];
return $this->_registry->calendar->export($uid, 'activesync', $options, $calendar);
}
@@ -134,10 +135,14 @@ public function calendar_export($uid, array $options = array(), $calendar = null
* @return string The event's UID.
*/
public function calendar_import(
- Horde_ActiveSync_Message_Appointment $content, $calendar = null)
- {
+ Horde_ActiveSync_Message_Appointment $content,
+ $calendar = null
+ ) {
return $this->_registry->calendar->import(
- $content, 'activesync', $calendar);
+ $content,
+ 'activesync',
+ $calendar
+ );
}
/**
@@ -153,16 +158,21 @@ public function calendar_import(
* @todo Remove for H6 and make calendar_import return this structure.
*/
public function calendar_import16(
- Horde_ActiveSync_Message_Appointment $content, $calendar = null)
- {
+ Horde_ActiveSync_Message_Appointment $content,
+ $calendar = null
+ ) {
$result = $this->_registry->calendar->import(
- $content, 'activesync', $calendar, true);
+ $content,
+ 'activesync',
+ $calendar,
+ true
+ );
if (!is_array($result)) {
- $result = array(
+ $result = [
'uid' => $result,
- 'atchash' => false
- );
+ 'atchash' => false,
+ ];
}
return $result;
@@ -188,9 +198,10 @@ public function calendar_import_vevent(Horde_Icalendar_vEvent $vEvent)
* @param Horde_Icalendar_vEvent $vEvent The event data.
* @param string $attendee The attendee.
*/
- public function calendar_import_attendee(Horde_Icalendar_vEvent $vEvent,
- $attendee)
- {
+ public function calendar_import_attendee(
+ Horde_Icalendar_vEvent $vEvent,
+ $attendee
+ ) {
if ($this->_registry->hasMethod('calendar/updateAttendee')) {
// If the mail interface (i.e., IMP) provides a mime driver for
// iTips, check if we are allowed to autoupdate. If we have no
@@ -215,7 +226,7 @@ public function calendar_import_attendee(Horde_Icalendar_vEvent $vEvent,
}
try {
- $this->_registry->calendar->updateAttendee($vEvent, $attendee);
+ $this->_registry->calendar->updateAttendee($vEvent, $attendee);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
}
@@ -266,7 +277,11 @@ public function calendar_delete($uid, $calendar = null, $instanceid = null)
public function calendar_getActionTimestamp($uid, $action, $calendar = null)
{
return $this->_registry->calendar->getActionTimestamp(
- $uid, $action, $calendar, $this->hasFeature('modseq', 'calendar'));
+ $uid,
+ $action,
+ $calendar,
+ $this->hasFeature('modseq', 'calendar')
+ );
}
/**
@@ -307,13 +322,16 @@ public function calendar_getAttachment($filereference)
{
if (!$this->_registry->hasMethod(
'getAttachment',
- $this->_registry->hasInterface('calendar'))) {
+ $this->_registry->hasInterface('calendar')
+ )) {
return false;
}
$fileinfo = explode(':', $filereference, 4);
try {
return $this->_registry->calendar->getAttachment(
- $fileinfo[1], $fileinfo[2], $fileinfo[3]
+ $fileinfo[1],
+ $fileinfo[2],
+ $fileinfo[3]
);
} catch (Horde_Exception $e) {
return false;
@@ -348,7 +366,7 @@ public function contacts_listUids($source = null)
*
* @return Horde_ActiveSync_Message_Contact The contact object.
*/
- public function contacts_export($uid, array $options = array())
+ public function contacts_export($uid, array $options = [])
{
return $this->_registry->contacts->export($uid, 'activesync', null, null, $options);
}
@@ -403,7 +421,11 @@ public function contacts_delete($uid)
public function contacts_getActionTimestamp($uid, $action, $addressbook = null)
{
return $this->_registry->contacts->getActionTimestamp(
- $uid, $action, $addressbook, $this->hasFeature('modseq', 'contacts'));
+ $uid,
+ $action,
+ $addressbook,
+ $this->hasFeature('modseq', 'contacts')
+ );
}
/**
@@ -417,7 +439,7 @@ public function getRecipientCache($max = 100)
{
if (!$this->_registry->hasInterface('mail') ||
!$this->_registry->hasInterface('contacts')) {
- return array();
+ return [];
}
$cache = $GLOBALS['injector']->getInstance('Horde_Cache');
$cache_key = 'HCASC:' . $this->_registry->getAuth() . ':' . $max;
@@ -444,35 +466,35 @@ public function getRecipientCache($max = 100)
*
* @return array The search results.
*/
- public function contacts_search($query, array $options = array())
+ public function contacts_search($query, array $options = [])
{
if ((!$gal = $this->contacts_getGal()) && empty($options['recipient_cache_search'])) {
- return array();
+ return [];
}
if (!empty($options['recipient_cache_search'])) {
$sources = array_keys($this->_registry->contacts->sources(false, true));
- $return_fields = array('name', 'alias', 'email');
+ $return_fields = ['name', 'alias', 'email'];
foreach ($sources as $source) {
- $fields[$source] = array('email');
+ $fields[$source] = ['email'];
}
} else {
- $sources = array($gal);
- $fields = array();
- $return_fields = array('name', 'alias', 'email', 'firstname', 'lastname',
+ $sources = [$gal];
+ $fields = [];
+ $return_fields = ['name', 'alias', 'email', 'firstname', 'lastname',
'company', 'homePhone', 'workPhone', 'cellPhone', 'title',
- 'office');
+ 'office'];
}
if (!empty($options['pictures'])) {
$return_fields[] = 'photo';
}
- $opts = array(
+ $opts = [
'matchBegin' => true,
'forceSource' => true,
'sources' => $sources,
'returnFields' => $return_fields,
- 'fields' => $fields
- );
+ 'fields' => $fields,
+ ];
return $this->_registry->contacts->search($query, $opts);
}
@@ -498,11 +520,11 @@ public function contacts_search($query, array $options = array())
*
* @return array The search results, keyed by the $query.
*/
- public function resolveRecipient($query, array $opts = array())
+ public function resolveRecipient($query, array $opts = [])
{
if (!empty($opts['starttime'])) {
try {
- return array($query => $this->_registry->calendar->lookupFreeBusy($query, true));
+ return [$query => $this->_registry->calendar->lookupFreeBusy($query, true)];
} catch (Horde_Exception $e) {
return false; // ?
}
@@ -513,23 +535,23 @@ public function resolveRecipient($query, array $opts = array())
if (!in_array($gal, $sources)) {
$sources[] = $gal;
}
- $fields = array();
+ $fields = [];
foreach ($sources as $source) {
- $fields[$source] = array('email');
+ $fields[$source] = ['email'];
}
- $returnFields = array('name', 'email', 'alias', 'smimePublicKey');
+ $returnFields = ['name', 'email', 'alias', 'smimePublicKey'];
if (!empty($opts['pictures'])) {
- $returnFields[$source]['photo'];
+ $returnFields[$source]['photo'];
}
- $options = array(
+ $options = [
'matchBegin' => true,
'sources' => $sources,
'returnFields' => $returnFields,
- 'fields' => $fields
- );
+ 'fields' => $fields,
+ ];
if (isset($opts['maxAmbiguous']) && $opts['maxAmbiguous'] == 0) {
- $options['customStrict'] = array('email', 'name', 'alias');
+ $options['customStrict'] = ['email', 'name', 'alias'];
}
return $this->_registry->contacts->search($query, $options);
}
@@ -596,23 +618,23 @@ public function files_browse($path)
throw new Horde_ActiveSync_Exception($e);
}
- $files = array();
+ $files = [];
// An explicit file requested?
if (!empty($results['data'])) {
$data = new Horde_Stream();
$data->add($results['data']);
- $files[] = array(
+ $files[] = [
'linkid' => $original_path,
'name' => $results['name'],
'content-length' => $results['contentlength'],
'modified' => new Horde_Date($results['mtime']),
'created' => new Horde_Date($results['mtime']), // No creation date?
'is_folder' => false,
- 'data' => $data);
+ 'data' => $data];
} else {
foreach ($results as $id => $result) {
- $file = array('name' => $result['name']);
+ $file = ['name' => $result['name']];
$file['is_folder'] = $result['browseable'];
$file['modified'] = new Horde_Date($result['modified']);
$file['created'] = clone $file['modified'];
@@ -647,7 +669,7 @@ public function tasks_listUids($tasklist = null)
*
* @return Horde_ActiveSync_Message_Task The task message object
*/
- public function tasks_export($uid, array $options = array())
+ public function tasks_export($uid, array $options = [])
{
return $this->_registry->tasks->export($uid, 'activesync', $options);
}
@@ -698,7 +720,11 @@ public function tasks_delete($id)
public function tasks_getActionTimestamp($uid, $action, $tasklist = null)
{
return $this->_registry->tasks->getActionTimestamp(
- $uid, $action, $tasklist, $this->hasFeature('modseq', 'tasks'));
+ $uid,
+ $action,
+ $tasklist,
+ $this->hasFeature('modseq', 'tasks')
+ );
}
/**
@@ -736,7 +762,7 @@ public function notes_listUids($notepad = null)
* @return Horde_ActiveSync_Message_Note The note message object
* @since 5.1
*/
- public function notes_export($uid, array $options = array())
+ public function notes_export($uid, array $options = [])
{
return $this->_registry->notes->export($uid, 'activesync', $options);
}
@@ -792,7 +818,11 @@ public function notes_delete($id)
public function notes_getActionTimestamp($uid, $action, $notepad = null)
{
return $this->_registry->notes->getActionTimestamp(
- $uid, $action, $notepad, $this->hasFeature('modseq', 'notes'));
+ $uid,
+ $action,
+ $notepad,
+ $this->hasFeature('modseq', 'notes')
+ );
}
/**
@@ -812,7 +842,7 @@ public function horde_listApis()
unset($apis[$key]);
}
}
- $active_apis = array();
+ $active_apis = [];
foreach ($apis as $api) {
if (!$this->_registry->isInactive($this->_registry->hasInterface($api))) {
$active_apis[] = $api;
@@ -951,17 +981,17 @@ public function filters_setVacation(array $setting)
foreach ($setting['oofmsgs'] as $msg) {
if ($msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOEXTERNALKNOWN ||
$msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOEXTERNALUNKNOWN) {
- $vacation = array(
+ $vacation = [
'reason' => $msg['replymessage'],
- 'subject' => Horde_Core_Translation::t('Out Of Office')
- );
+ 'subject' => Horde_Core_Translation::t('Out Of Office'),
+ ];
break;
}
if ($msg['appliesto'] == Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL) {
- $vacation = array(
+ $vacation = [
'reason' => $msg['replymessage'],
- 'subject' => Horde_Core_Translation::t('Out Of Office')
- );
+ 'subject' => Horde_Core_Translation::t('Out Of Office'),
+ ];
}
}
if (!empty($setting['starttime'])) {
@@ -1006,10 +1036,12 @@ public function mail_getMaillog($mid)
* @param string $folder The sent-mail folder. @since Horde_Core 2.27.0
*/
public function mail_logMaillog(
- $action, $mid, $recipients = null, $folder = null
- )
- {
- $data = array();
+ $action,
+ $mid,
+ $recipients = null,
+ $folder = null
+ ) {
+ $data = [];
if (!empty($recipients)) {
$data['recipients'] = $recipients;
}
@@ -1049,7 +1081,7 @@ public function mail_getMaillogChanges($ts)
try {
return $this->_registry->mail->getMaillogChanges($ts);
} catch (Horde_Exception $e) {
- return array();
+ return [];
}
}
}
@@ -1082,7 +1114,7 @@ public function mail_ensureMessageFlags(array $flags)
*/
public function getChanges($collection, $from_ts, $to_ts, $server_id)
{
- if (!in_array($collection, array('calendar', 'contacts', 'tasks', 'notes'))) {
+ if (!in_array($collection, ['calendar', 'contacts', 'tasks', 'notes'])) {
throw new InvalidArgumentException('collection must be one of calendar, contacts, tasks or notes');
}
@@ -1095,26 +1127,28 @@ public function getChanges($collection, $from_ts, $to_ts, $server_id)
if ($this->hasFeature('modseq', $collection)) {
$this->_logger->meta(sprintf(
'Fetching changes for %s using MODSEQ.',
- $collection));
+ $collection
+ ));
try {
return $this->_registry->{$collection}->getChangesByModSeq($from_ts, $to_ts, $server_id);
} catch (Exception $e) {
- return array('add' => array(),
- 'modify' => array(),
- 'delete' => array());
+ return ['add' => [],
+ 'modify' => [],
+ 'delete' => []];
}
}
// Older API, use timestamps.
$this->_logger->meta(sprintf(
'Fetching changes for %s using TIMESTAMPS.',
- $collection));
+ $collection
+ ));
try {
return $this->_registry->{$collection}->getChanges($from_ts, $to_ts, false, $server_id);
} catch (Exception $e) {
- return array('add' => array(),
- 'modify' => array(),
- 'delete' => array());
+ return ['add' => [],
+ 'modify' => [],
+ 'delete' => []];
}
}
@@ -1137,20 +1171,23 @@ protected function _ensureCalendar($source)
$calendars = unserialize(
$this->_registry->horde->getPreference(
$this->_registry->hasInterface('calendar'),
- 'sync_calendars'));
+ 'sync_calendars'
+ )
+ );
if (empty($calendars)) {
$calendars = $this->_registry->calendar->listCalendars(true, Horde_Perms::EDIT);
$default_calendar = $this->_registry->horde->getPreference(
$this->_registry->hasInterface('calendar'),
- 'default_share');
+ 'default_share'
+ );
if (empty($calendars[$default_calendar])) {
- return array();
+ return [];
} else {
- $calendars = array($default_calendar);
+ $calendars = [$default_calendar];
}
}
} else {
- $calendars = array($source);
+ $calendars = [$source];
}
return $calendars;
@@ -1170,32 +1207,32 @@ protected function _ensureCalendar($source)
*/
public function softDelete($collection, $from_ts, $to_ts, $source = null)
{
- $results = array();
+ $results = [];
switch ($collection) {
- case 'calendar':
- $calendars = $this->_ensureCalendar($source);
-
- // Need to use listEvents instead of listUids since we must
- // ignore recurring events when softdeleting or else we run
- // the risk of removing a still active recurrence.
- $events = $this->_registry->calendar->listEvents(
- $from_ts,
- $to_ts,
- $calendars, // Calendars
- false, // showRecurrence
- false, // alarmsOnly
- false, // showRemote
- true, // hideExceptions
- false // coverDates
- );
+ case 'calendar':
+ $calendars = $this->_ensureCalendar($source);
+
+ // Need to use listEvents instead of listUids since we must
+ // ignore recurring events when softdeleting or else we run
+ // the risk of removing a still active recurrence.
+ $events = $this->_registry->calendar->listEvents(
+ $from_ts,
+ $to_ts,
+ $calendars, // Calendars
+ false, // showRecurrence
+ false, // alarmsOnly
+ false, // showRemote
+ true, // hideExceptions
+ false // coverDates
+ );
- foreach ($events as $day) {
- foreach ($day as $e) {
- if (empty($e->recurrence)) {
- $results[] = $e->uid;
+ foreach ($events as $day) {
+ foreach ($day as $e) {
+ if (empty($e->recurrence)) {
+ $results[] = $e->uid;
+ }
}
}
- }
}
return $results;
@@ -1221,58 +1258,58 @@ public function getFolders($collection, $multiplex)
$folders = false;
if (empty($this->_folderCache[$collection])) {
switch ($collection) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- if ($this->_registry->hasMethod('calendar/sources') &&
- $this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex') &&
- !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_CALENDAR)) {
-
- $folders = $this->_registry->calendar->sources(true, true);
- $default = $this->_registry->calendar->getDefaultShare();
- } else {
- $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::APPOINTMENTS_FOLDER_UID;
- }
- break;
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ if ($this->_registry->hasMethod('calendar/sources') &&
+ $this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex') &&
+ !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_CALENDAR)) {
+
+ $folders = $this->_registry->calendar->sources(true, true);
+ $default = $this->_registry->calendar->getDefaultShare();
+ } else {
+ $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::APPOINTMENTS_FOLDER_UID;
+ }
+ break;
- case Horde_ActiveSync::CLASS_CONTACTS:
- if ($this->_registry->hasMethod('contacts/sources') &&
- $this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex') &&
- !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_CONTACTS)) {
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ if ($this->_registry->hasMethod('contacts/sources') &&
+ $this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex') &&
+ !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_CONTACTS)) {
- $folders = $this->_registry->contacts->sources(true, true);
- $default = $this->_registry->contacts->getDefaultShare();
- } else {
- $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID;
- }
- break;
+ $folders = $this->_registry->contacts->sources(true, true);
+ $default = $this->_registry->contacts->getDefaultShare();
+ } else {
+ $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID;
+ }
+ break;
- case Horde_ActiveSync::CLASS_TASKS:
- if ($this->_registry->hasMethod('tasks/sources') &&
- $this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex') &&
- !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_TASKS)) {
+ case Horde_ActiveSync::CLASS_TASKS:
+ if ($this->_registry->hasMethod('tasks/sources') &&
+ $this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex') &&
+ !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_TASKS)) {
- $folders = $this->_registry->tasks->sources(true, true);
- $default = $this->_registry->tasks->getDefaultShare();
- } else {
- $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::TASKS_FOLDER_UID;
- }
- break;
+ $folders = $this->_registry->tasks->sources(true, true);
+ $default = $this->_registry->tasks->getDefaultShare();
+ } else {
+ $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::TASKS_FOLDER_UID;
+ }
+ break;
- case Horde_ActiveSync::CLASS_NOTES:
- if ($this->_registry->hasMethod('notes/sources') &&
- $this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex') &&
- !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_NOTES)) {
+ case Horde_ActiveSync::CLASS_NOTES:
+ if ($this->_registry->hasMethod('notes/sources') &&
+ $this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex') &&
+ !($multiplex & Horde_ActiveSync_Device::MULTIPLEX_NOTES)) {
- $folders = $this->_registry->notes->sources(true, true);
- $default = $this->_registry->notes->getDefaultShare();
- } else {
- $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::NOTES_FOLDER_UID;
- }
+ $folders = $this->_registry->notes->sources(true, true);
+ $default = $this->_registry->notes->getDefaultShare();
+ } else {
+ $this->_folderCache[$collection] = Horde_Core_ActiveSync_Driver::NOTES_FOLDER_UID;
+ }
}
if (!empty($folders) && is_array($folders)) {
- $results = array();
+ $results = [];
foreach ($folders as $id => $folder) {
- $results[$id] = array('display' => $folder, 'primary' => ($id == $default));
+ $results[$id] = ['display' => $folder, 'primary' => ($id == $default)];
}
$this->_folderCache[$collection] = $results;
} elseif (is_array($folders)) {
@@ -1299,47 +1336,47 @@ public function getFolders($collection, $multiplex)
public function createFolder($class, $foldername)
{
switch ($class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- // @todo Remove hasMethod checks in H6.
- if (!$this->_registry->hasMethod('calendar/addCalendar') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Creating calendars not supported by the calendar API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- return $this->_registry->calendar->addCalendar($foldername, array('synchronize' => true));
-
- case Horde_ActiveSync::CLASS_CONTACTS:
- // @todo Remove hasMethod check in H6
- if (!$this->_registry->hasMethod('contacts/addAddressbook') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Creating addressbooks not supported by the contacts API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- return $this->_registry->contacts->addAddressbook($foldername, array('synchronize' => true));
-
- case Horde_ActiveSync::CLASS_NOTES:
- // @todo Remove hasMethod checks in H6.
- if (!$this->_registry->hasMethod('notes/addNotepad') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Creating notepads not supported by the notes API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- return $this->_registry->notes->addNotepad($foldername, array('synchronize' => true));
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ // @todo Remove hasMethod checks in H6.
+ if (!$this->_registry->hasMethod('calendar/addCalendar') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Creating calendars not supported by the calendar API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ return $this->_registry->calendar->addCalendar($foldername, ['synchronize' => true]);
- case Horde_ActiveSync::CLASS_TASKS:
- if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Creating notepads not supported by the notes API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- return $this->_registry->tasks->addTasklist($foldername, '', '', array('synchronize' => true));
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ // @todo Remove hasMethod check in H6
+ if (!$this->_registry->hasMethod('contacts/addAddressbook') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Creating addressbooks not supported by the contacts API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ return $this->_registry->contacts->addAddressbook($foldername, ['synchronize' => true]);
+
+ case Horde_ActiveSync::CLASS_NOTES:
+ // @todo Remove hasMethod checks in H6.
+ if (!$this->_registry->hasMethod('notes/addNotepad') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Creating notepads not supported by the notes API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ return $this->_registry->notes->addNotepad($foldername, ['synchronize' => true]);
+
+ case Horde_ActiveSync::CLASS_TASKS:
+ if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Creating notepads not supported by the notes API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ return $this->_registry->tasks->addTasklist($foldername, '', '', ['synchronize' => true]);
}
}
@@ -1357,63 +1394,63 @@ public function createFolder($class, $foldername)
public function changeFolder($class, $id, $name)
{
switch ($class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- // @todo Remove hasMethod check
- if (!$this->_registry->hasMethod('calendar/getCalendar') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Updating calendars not supported by the calendar API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $calendar = $this->_registry->calendar->getCalendar($id);
- $info = array(
- 'name' => $name,
- 'color' => $calendar->background(),
- 'description' => $calendar->description()
- );
- $this->_registry->calendar->updateCalendar($id, $info);
- break;
-
- case Horde_ActiveSync::CLASS_CONTACTS:
- // @todo remove hasMethod check
- if (!$this->_registry->hasMethod('contacts/updateAddressbook') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Updating addressbooks not supported by the contacts API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->contacts->updateAddressbook($id, array('name' => $name));
- break;
-
- case Horde_ActiveSync::CLASS_NOTES:
- // @todo remove hasMethod check
- if (!$this->_registry->hasMethod('notes/updateNotepad') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Updating notepads not supported by the notes API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->notes->updateNotepad($id, array('name' => $name));
- break;
-
- case Horde_ActiveSync::CLASS_TASKS:
- if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Updating notepads not supported by the notes API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $share = $this->_registry->tasks->getTasklist($id);
- $info = array(
- 'name' => $name,
- 'color' => $share->get('color'),
- 'desc' => $share->get('desc')
- );
- $this->_registry->tasks->updateTasklist($id, $info);
- break;
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ // @todo Remove hasMethod check
+ if (!$this->_registry->hasMethod('calendar/getCalendar') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Updating calendars not supported by the calendar API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $calendar = $this->_registry->calendar->getCalendar($id);
+ $info = [
+ 'name' => $name,
+ 'color' => $calendar->background(),
+ 'description' => $calendar->description(),
+ ];
+ $this->_registry->calendar->updateCalendar($id, $info);
+ break;
+
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ // @todo remove hasMethod check
+ if (!$this->_registry->hasMethod('contacts/updateAddressbook') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Updating addressbooks not supported by the contacts API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->contacts->updateAddressbook($id, ['name' => $name]);
+ break;
+
+ case Horde_ActiveSync::CLASS_NOTES:
+ // @todo remove hasMethod check
+ if (!$this->_registry->hasMethod('notes/updateNotepad') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Updating notepads not supported by the notes API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->notes->updateNotepad($id, ['name' => $name]);
+ break;
+
+ case Horde_ActiveSync::CLASS_TASKS:
+ if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Updating notepads not supported by the notes API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $share = $this->_registry->tasks->getTasklist($id);
+ $info = [
+ 'name' => $name,
+ 'color' => $share->get('color'),
+ 'desc' => $share->get('desc'),
+ ];
+ $this->_registry->tasks->updateTasklist($id, $info);
+ break;
}
}
@@ -1428,48 +1465,48 @@ public function changeFolder($class, $id, $name)
public function deleteFolder($class, $id)
{
switch ($class) {
- case Horde_ActiveSync::CLASS_TASKS:
- if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Deleting addressbooks not supported by the contacts API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->tasks->deleteTasklist($id);
- break;
-
- case Horde_ActiveSync::CLASS_CONTACTS:
- if (!$this->_registry->hasMethod('contacts/deleteAddressbook') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Deleting addressbooks not supported by the contacts API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->contacts->deleteAddressbook($id);
- break;
-
- case Horde_ActiveSync::CLASS_CALENDAR:
- if (!$this->_registry->hasMethod('calendar/deleteCalendar') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Deleting calendars not supported by the calendar API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->calendar->deleteCalendar($id);
- break;
-
- case Horde_ActiveSync::CLASS_NOTES :
- if (!$this->_registry->hasMethod('notes/deleteNotepad') ||
- !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
- throw new Horde_ActiveSync_Exception(
- 'Deleting notepads not supported by the notes API.',
- Horde_ActiveSync_Exception::UNSUPPORTED
- );
- }
- $this->_registry->notes->deleteNotepad($id);
- break;
+ case Horde_ActiveSync::CLASS_TASKS:
+ if (!$this->_registry->horde->getPreference($this->_registry->hasInterface('tasks'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Deleting addressbooks not supported by the contacts API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->tasks->deleteTasklist($id);
+ break;
+
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ if (!$this->_registry->hasMethod('contacts/deleteAddressbook') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('contacts'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Deleting addressbooks not supported by the contacts API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->contacts->deleteAddressbook($id);
+ break;
+
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ if (!$this->_registry->hasMethod('calendar/deleteCalendar') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('calendar'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Deleting calendars not supported by the calendar API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->calendar->deleteCalendar($id);
+ break;
+
+ case Horde_ActiveSync::CLASS_NOTES:
+ if (!$this->_registry->hasMethod('notes/deleteNotepad') ||
+ !$this->_registry->horde->getPreference($this->_registry->hasInterface('notes'), 'activesync_no_multiplex')) {
+ throw new Horde_ActiveSync_Exception(
+ 'Deleting notepads not supported by the notes API.',
+ Horde_ActiveSync_Exception::UNSUPPORTED
+ );
+ }
+ $this->_registry->notes->deleteNotepad($id);
+ break;
}
}
diff --git a/lib/Horde/Core/ActiveSync/Driver.php b/lib/Horde/Core/ActiveSync/Driver.php
index c2c9f8d59..3df645511 100644
--- a/lib/Horde/Core/ActiveSync/Driver.php
+++ b/lib/Horde/Core/ActiveSync/Driver.php
@@ -1,4 +1,5 @@
display names. Populated in the const'r
@@ -42,7 +43,7 @@ class Horde_Core_ActiveSync_Driver extends Horde_ActiveSync_Driver_Base
*
* @var array
*/
- protected $_displayMap = array();
+ protected $_displayMap = [];
/**
* Cache message stats
@@ -63,7 +64,7 @@ class Horde_Core_ActiveSync_Driver extends Horde_ActiveSync_Driver_Base
*
* @var array
*/
- protected $_folders = array();
+ protected $_folders = [];
/**
* Imap client adapter
@@ -91,19 +92,19 @@ class Horde_Core_ActiveSync_Driver extends Horde_ActiveSync_Driver_Base
*
* @var array
*/
- protected $_verbs = array();
+ protected $_verbs = [];
/**
* Class => Id map
*
* @var array
*/
- protected $_classMap = array(
+ protected $_classMap = [
Horde_ActiveSync::CLASS_TASKS => self::TASKS_FOLDER_UID,
Horde_ActiveSync::CLASS_CALENDAR => self::APPOINTMENTS_FOLDER_UID,
Horde_ActiveSync::CLASS_CONTACTS => self::CONTACTS_FOLDER_UID,
- Horde_ActiveSync::CLASS_NOTES => self::NOTES_FOLDER_UID
- );
+ Horde_ActiveSync::CLASS_NOTES => self::NOTES_FOLDER_UID,
+ ];
/**
* Const'r
@@ -126,7 +127,7 @@ class Horde_Core_ActiveSync_Driver extends Horde_ActiveSync_Driver_Base
* data, such as mailbox search results.
* @since 2.12.0
*/
- public function __construct(array $params = array())
+ public function __construct(array $params = [])
{
parent::__construct($params);
if (empty($this->_params['connector']) ||
@@ -152,12 +153,12 @@ public function __construct(array $params = array())
}
// Build the displaymap
- $this->_displayMap = array(
+ $this->_displayMap = [
self::APPOINTMENTS_FOLDER_UID => Horde_ActiveSync_Translation::t('Calendar'),
self::CONTACTS_FOLDER_UID => Horde_ActiveSync_Translation::t('Contacts'),
self::TASKS_FOLDER_UID => Horde_ActiveSync_Translation::t('Tasks'),
self::NOTES_FOLDER_UID => Horde_ActiveSync_Translation::t('Notes'),
- );
+ ];
}
/**
@@ -190,11 +191,13 @@ public function authenticate($username, $password, $domain = null)
{
global $injector, $conf;
- $this->_logger->info(sprintf(
- '%sHorde_Core_ActiveSync_Driver::authenticate() attempt for %s%s',
- str_repeat('-', 10),
- $username,
- str_repeat('-', 10))
+ $this->_logger->info(
+ sprintf(
+ '%sHorde_Core_ActiveSync_Driver::authenticate() attempt for %s%s',
+ str_repeat('-', 10),
+ $username,
+ str_repeat('-', 10)
+ )
);
// First try transparent/X509. Happens for authtype == 'cert' || 'basic_cert'
@@ -206,20 +209,25 @@ public function authenticate($username, $password, $domain = null)
if ($username != $GLOBALS['registry']->getAuth()) {
$injector->getInstance('Horde_Log_Logger')->notice(sprintf(
'Access granted based on transparent authentication of user %s, but ActiveSync client is requesting access for %s.',
- $GLOBALS['registry']->getAuth(), $username));
+ $GLOBALS['registry']->getAuth(),
+ $username
+ ));
$GLOBALS['registry']->clearAuth();
return false;
}
- $this->_logger->info(sprintf(
- 'Access granted based on transparent authentication for %s. Client certificate name: %s',
- $GLOBALS['registry']->getAuth(), $username)
+ $this->_logger->info(
+ sprintf(
+ 'Access granted based on transparent authentication for %s. Client certificate name: %s',
+ $GLOBALS['registry']->getAuth(),
+ $username
+ )
);
}
// Now check Basic. Happens for authtype == 'basic' || 'basic_cert'
if ($conf['activesync']['auth']['type'] != 'cert') {
try {
- $authResult = $this->_auth->authenticate($username, array('password' => $password));
+ $authResult = $this->_auth->authenticate($username, ['password' => $password]);
} catch (Horde_Auth_Exception $e) {
if ($e->getCode() == Horde_Auth::REASON_MESSAGE) {
// This error code would only happen if it's an error
@@ -229,10 +237,10 @@ public function authenticate($username, $password, $domain = null)
// TODO: Remove BC shim
if (defined('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE')) {
- return constant('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE');
- }
+ return constant('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE');
+ }
- return false;
+ return false;
}
}
@@ -249,9 +257,11 @@ public function authenticate($username, $password, $domain = null)
if ($perms->exists('horde:activesync')) {
// Check permissions to ActiveSync
if (!$this->_getPolicyValue('activesync', $perms->getPermissions('horde:activesync', $username))) {
- $this->_logger->info(sprintf(
- 'Access denied for user %s per policy settings.',
- $username)
+ $this->_logger->info(
+ sprintf(
+ 'Access denied for user %s per policy settings.',
+ $username
+ )
);
return Horde_ActiveSync::AUTH_REASON_USER_DENIED;
}
@@ -268,9 +278,11 @@ public function authenticate($username, $password, $domain = null)
public function clearAuthentication()
{
$this->_connector->clearAuth();
- $this->_logger->info(sprintf(
- 'User %s logged off',
- $this->_user)
+ $this->_logger->info(
+ sprintf(
+ 'User %s logged off',
+ $this->_user
+ )
);
return true;
}
@@ -287,7 +299,7 @@ public function clearAuthentication()
public function setup($user)
{
parent::setup($user);
- $this->_modCache = array();
+ $this->_modCache = [];
return true;
}
@@ -325,10 +337,15 @@ public function getFolderList()
{
$this->_logger->meta('Horde_Core_ActiveSync_Driver::getFolderList()');
$folderlist = $this->getFolders();
- $folders = array();
+ $folders = [];
foreach ($folderlist as $f) {
$folders[] = $this->statFolder(
- $f->serverid, $f->parentid, $f->displayname, $f->_serverid, $f->type);
+ $f->serverid,
+ $f->parentid,
+ $f->displayname,
+ $f->_serverid,
+ $f->type
+ );
}
return $folders;
@@ -349,9 +366,9 @@ public function getFolders()
} catch (Exception $e) {
$this->_logger->err($e->getMessage());
$this->_endBuffer();
- return array();
+ return [];
}
- $folders = array();
+ $folders = [];
if (array_search('calendar', $supported) !== false) {
$temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_CALENDAR, $multiplex);
@@ -360,11 +377,11 @@ public function getFolders()
try {
$temp_folder = $this->_getFolder(
Horde_ActiveSync::CLASS_CALENDAR . ':' . $id,
- array(
+ [
'class' => Horde_ActiveSync::CLASS_CALENDAR,
'primary' => $folder['primary'],
- 'display' => $folder['display']
- )
+ 'display' => $folder['display'],
+ ]
);
if (!empty($temp_folder)) {
$folders[] = $temp_folder;
@@ -395,11 +412,11 @@ public function getFolders()
try {
$temp_folder = $this->_getFolder(
Horde_ActiveSync::CLASS_CONTACTS . ':' . $id,
- array(
+ [
'class' => Horde_ActiveSync::CLASS_CONTACTS,
'primary' => $folder['primary'],
- 'display' => $folder['display']
- )
+ 'display' => $folder['display'],
+ ]
);
if (!empty($temp_folder)) {
$folders[] = $temp_folder;
@@ -428,23 +445,23 @@ public function getFolders()
$temp = $this->_connector->getFolders(Horde_ActiveSync::CLASS_TASKS, $multiplex);
if (is_array($temp)) {
foreach ($temp as $id => $folder) {
- try {
- $temp_folder = $this->_getFolder(
+ try {
+ $temp_folder = $this->_getFolder(
Horde_ActiveSync::CLASS_TASKS . ':' . $id,
- array(
- 'class' => Horde_ActiveSync::CLASS_TASKS,
- 'primary' => $folder['primary'],
- 'display' => $folder['display']
- )
+ [
+ 'class' => Horde_ActiveSync::CLASS_TASKS,
+ 'primary' => $folder['primary'],
+ 'display' => $folder['display'],
+ ]
);
if (!empty($temp_folder)) {
$folders[] = $temp_folder;
} else {
$this->_logger->meta('Unable to find a useable tasks folder.');
}
- } catch (Horde_ActiveSync_Exception $e) {
+ } catch (Horde_ActiveSync_Exception $e) {
$this->_logger->meta('Unable to find a useable tasks folder.');
- }
+ }
}
} else {
try {
@@ -467,11 +484,11 @@ public function getFolders()
try {
$temp_folder = $this->_getFolder(
Horde_ActiveSync::CLASS_NOTES . ':' . $id,
- array(
+ [
'class' => Horde_ActiveSync::CLASS_NOTES,
'primary' => $folder['primary'],
- 'display' => $folder['display']
- )
+ 'display' => $folder['display'],
+ ]
);
if (!empty($temp_folder)) {
$folders[] = $temp_folder;
@@ -496,7 +513,7 @@ public function getFolders()
}
if ($this->_version > Horde_ActiveSync::VERSION_TWELVEONE &&
$GLOBALS['registry']->hasInterface('contacts')) {
- $folders[] = $this->_getFolder('RI', array('class' => 'RI'));
+ $folders[] = $this->_getFolder('RI', ['class' => 'RI']);
}
// Always return at least the "dummy" IMAP folders since some
@@ -507,7 +524,7 @@ public function getFolders()
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
$this->_endBuffer();
- return array();
+ return [];
}
$this->_endBuffer();
@@ -534,7 +551,7 @@ public function getFolders()
* @return Horde_ActiveSync_Message_Folder The folder object.
* @throws Horde_ActiveSync_Exception
*/
- protected function _getFolder($id, array $params = array())
+ protected function _getFolder($id, array $params = [])
{
if (empty($id)) {
throw new Horde_ActiveSync_Exception();
@@ -542,40 +559,44 @@ protected function _getFolder($id, array $params = array())
// First check for legacy/multiplexed IDs.
switch ($id) {
- case self::APPOINTMENTS_FOLDER_UID:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT,
- $this->_displayMap[self::APPOINTMENTS_FOLDER_UID]);
-
- case self::CONTACTS_FOLDER_UID:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- Horde_ActiveSync::FOLDER_TYPE_CONTACT,
- $this->_displayMap[self::CONTACTS_FOLDER_UID]);
-
- case self::TASKS_FOLDER_UID:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- Horde_ActiveSync::FOLDER_TYPE_TASK,
- $this->_displayMap[self::TASKS_FOLDER_UID]);
-
- case self::NOTES_FOLDER_UID:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- Horde_ActiveSync::FOLDER_TYPE_NOTE,
- $this->_displayMap[self::NOTES_FOLDER_UID]);
- case 'RI':
- return $this->_buildNonMailFolder(
- 'RI',
- 0,
- Horde_ActiveSync::FOLDER_TYPE_RECIPIENT_CACHE,
- 'RI'
- );
+ case self::APPOINTMENTS_FOLDER_UID:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT,
+ $this->_displayMap[self::APPOINTMENTS_FOLDER_UID]
+ );
+
+ case self::CONTACTS_FOLDER_UID:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ Horde_ActiveSync::FOLDER_TYPE_CONTACT,
+ $this->_displayMap[self::CONTACTS_FOLDER_UID]
+ );
+
+ case self::TASKS_FOLDER_UID:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ Horde_ActiveSync::FOLDER_TYPE_TASK,
+ $this->_displayMap[self::TASKS_FOLDER_UID]
+ );
+
+ case self::NOTES_FOLDER_UID:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ Horde_ActiveSync::FOLDER_TYPE_NOTE,
+ $this->_displayMap[self::NOTES_FOLDER_UID]
+ );
+ case 'RI':
+ return $this->_buildNonMailFolder(
+ 'RI',
+ 0,
+ Horde_ActiveSync::FOLDER_TYPE_RECIPIENT_CACHE,
+ 'RI'
+ );
}
// Either an email folder or a non-multiplexed non-email folder.
@@ -595,34 +616,34 @@ protected function _getFolder($id, array $params = array())
// Non-Multiplexed non-email collection?
$primary = !empty($params['primary']);
switch ($params['class']) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- $primary ? Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT : Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT,
- $params['display']
- );
- case Horde_ActiveSync::CLASS_CONTACTS:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- $primary ? Horde_ActiveSync::FOLDER_TYPE_CONTACT : Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT,
- $params['display']
- );
- case Horde_ActiveSync::CLASS_TASKS:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- $primary ? Horde_ActiveSync::FOLDER_TYPE_TASK : Horde_ActiveSync::FOLDER_TYPE_USER_TASK,
- $params['display']
- );
- case Horde_ActiveSync::CLASS_NOTES:
- return $this->_buildNonMailFolder(
- $id,
- 0,
- $primary ? Horde_ActiveSync::FOLDER_TYPE_NOTE : Horde_ActiveSync::FOLDER_TYPE_USER_NOTE,
- $params['display']
- );
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ $primary ? Horde_ActiveSync::FOLDER_TYPE_APPOINTMENT : Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT,
+ $params['display']
+ );
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ $primary ? Horde_ActiveSync::FOLDER_TYPE_CONTACT : Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT,
+ $params['display']
+ );
+ case Horde_ActiveSync::CLASS_TASKS:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ $primary ? Horde_ActiveSync::FOLDER_TYPE_TASK : Horde_ActiveSync::FOLDER_TYPE_USER_TASK,
+ $params['display']
+ );
+ case Horde_ActiveSync::CLASS_NOTES:
+ return $this->_buildNonMailFolder(
+ $id,
+ 0,
+ $primary ? Horde_ActiveSync::FOLDER_TYPE_NOTE : Horde_ActiveSync::FOLDER_TYPE_USER_NOTE,
+ $params['display']
+ );
}
}
@@ -639,18 +660,23 @@ public function getFolder($id)
$folders = $this->getFolders();
foreach ($folders as $folder) {
if ($folder->_serverid == $id) {
- $this->_logger->meta(sprintf(
- 'Returning folder %s (%s type %s) from Horde_Core_ActiveSync_Driver::getFolder()',
- $id,
- $folder->serverid,
- $folder->type)
+ $this->_logger->meta(
+ sprintf(
+ 'Returning folder %s (%s type %s) from Horde_Core_ActiveSync_Driver::getFolder()',
+ $id,
+ $folder->serverid,
+ $folder->type
+ )
);
return $folder;
}
}
- throw new Horde_ActiveSync_Exception(sprintf(
- 'Folder: %s not found!', $id)
+ throw new Horde_ActiveSync_Exception(
+ sprintf(
+ 'Folder: %s not found!',
+ $id
+ )
);
}
@@ -670,34 +696,34 @@ protected function _parseFolderId($id, $checkEmail = false)
}
if (strpos($id, ':') === false) {
switch ($id) {
- case self::APPOINTMENTS_FOLDER_UID:
- return Horde_ActiveSync::CLASS_CALENDAR;
- case self::CONTACTS_FOLDER_UID:
- return Horde_ActiveSync::CLASS_CONTACTS;
- case self::TASKS_FOLDER_UID:
- return Horde_ActiveSync::CLASS_TASKS;
- case self::NOTES_FOLDER_UID:
- return Horde_ActiveSync::CLASS_NOTES;
- default:
- return Horde_ActiveSync::CLASS_EMAIL;
+ case self::APPOINTMENTS_FOLDER_UID:
+ return Horde_ActiveSync::CLASS_CALENDAR;
+ case self::CONTACTS_FOLDER_UID:
+ return Horde_ActiveSync::CLASS_CONTACTS;
+ case self::TASKS_FOLDER_UID:
+ return Horde_ActiveSync::CLASS_TASKS;
+ case self::NOTES_FOLDER_UID:
+ return Horde_ActiveSync::CLASS_NOTES;
+ default:
+ return Horde_ActiveSync::CLASS_EMAIL;
}
} else {
$parts = explode(':', $id, 2);
if (count($parts) == 2) {
switch ($parts[self::FOLDER_PART_CLASS]) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- case Horde_ActiveSync::CLASS_TASKS:
- case Horde_ActiveSync::CLASS_CONTACTS:
- case Horde_ActiveSync::CLASS_NOTES:
- if ($checkEmail) {
- $folders = $this->_getMailFolders();
- foreach ($folders as $folder) {
- if ($folder->_serverid == $id) {
- return Horde_ActiveSync::CLASS_EMAIL;
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ case Horde_ActiveSync::CLASS_TASKS:
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ case Horde_ActiveSync::CLASS_NOTES:
+ if ($checkEmail) {
+ $folders = $this->_getMailFolders();
+ foreach ($folders as $folder) {
+ if ($folder->_serverid == $id) {
+ return Horde_ActiveSync::CLASS_EMAIL;
+ }
}
}
- }
- return $parts;
+ return $parts;
}
}
return Horde_ActiveSync::CLASS_EMAIL;
@@ -721,9 +747,15 @@ protected function _parseFolderId($id, $checkEmail = false)
*/
public function changeFolder($old_name, $new_name, $parent, $uid = null, $type = null)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::changeFolder(%s, %s, %s, %s, %s)',
- $old_name, $new_name, $parent, $uid, $type)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::changeFolder(%s, %s, %s, %s, %s)',
+ $old_name,
+ $new_name,
+ $parent,
+ $uid,
+ $type
+ )
);
// For FOLDERUPDATE requests, the EAS Folder type is not passed by
@@ -738,55 +770,57 @@ public function changeFolder($old_name, $new_name, $parent, $uid = null, $type =
}
switch ($type) {
- case Horde_ActiveSync::CLASS_EMAIL:
- case Horde_ActiveSync::FOLDER_TYPE_USER_MAIL:
- if (!$old_name) {
- try {
- $serverid = $this->_imap->createMailbox($new_name, $parent);
- $this->_logger->meta(sprintf(
- 'New IMAP folder created: %s',
- $serverid)
- );
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err($e->getMessage());
- throw $e;
- }
- } else {
- try {
- $serverid = $this->_imap->renameMailbox($old_name, $new_name, $parent);
- $uid = $this->_getFolderUidForBackendId($serverid, Horde_ActiveSync::FOLDER_TYPE_USER_MAIL, $old_name);
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err($e->getMessage());
- throw $e;
+ case Horde_ActiveSync::CLASS_EMAIL:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_MAIL:
+ if (!$old_name) {
+ try {
+ $serverid = $this->_imap->createMailbox($new_name, $parent);
+ $this->_logger->meta(
+ sprintf(
+ 'New IMAP folder created: %s',
+ $serverid
+ )
+ );
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ throw $e;
+ }
+ } else {
+ try {
+ $serverid = $this->_imap->renameMailbox($old_name, $new_name, $parent);
+ $uid = $this->_getFolderUidForBackendId($serverid, Horde_ActiveSync::FOLDER_TYPE_USER_MAIL, $old_name);
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ throw $e;
+ }
}
- }
- return $this->getFolder($serverid);
-
- case Horde_ActiveSync::CLASS_TASKS:
- case Horde_ActiveSync::FOLDER_TYPE_USER_TASK:
- $class = Horde_ActiveSync::CLASS_TASKS;
- $type = Horde_ActiveSync::FOLDER_TYPE_USER_TASK;
- break;
-
- case Horde_ActiveSync::CLASS_CALENDAR:
- case Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT:
- $class = Horde_ActiveSync::CLASS_CALENDAR;
- $type = Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT;
- break;
-
- case Horde_ActiveSync::CLASS_CONTACTS:
- case Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT:
- $class = Horde_ActiveSync::CLASS_CONTACTS;
- $type = Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT;
- break;
- case Horde_ActiveSync::CLASS_NOTES:
- case Horde_ActiveSync::FOLDER_TYPE_USER_NOTE:
- $class = Horde_ActiveSync::CLASS_NOTES;
- $type = Horde_ActiveSync::FOLDER_TYPE_USER_NOTE;
- break;
-
- default:
- throw new Horde_ActiveSync_Exception('Unsupported EAS Collection Class.');
+ return $this->getFolder($serverid);
+
+ case Horde_ActiveSync::CLASS_TASKS:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_TASK:
+ $class = Horde_ActiveSync::CLASS_TASKS;
+ $type = Horde_ActiveSync::FOLDER_TYPE_USER_TASK;
+ break;
+
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT:
+ $class = Horde_ActiveSync::CLASS_CALENDAR;
+ $type = Horde_ActiveSync::FOLDER_TYPE_USER_APPOINTMENT;
+ break;
+
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT:
+ $class = Horde_ActiveSync::CLASS_CONTACTS;
+ $type = Horde_ActiveSync::FOLDER_TYPE_USER_CONTACT;
+ break;
+ case Horde_ActiveSync::CLASS_NOTES:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_NOTE:
+ $class = Horde_ActiveSync::CLASS_NOTES;
+ $type = Horde_ActiveSync::FOLDER_TYPE_USER_NOTE;
+ break;
+
+ default:
+ throw new Horde_ActiveSync_Exception('Unsupported EAS Collection Class.');
}
if (!$old_name) {
@@ -814,7 +848,10 @@ public function changeFolder($old_name, $new_name, $parent, $uid = null, $type =
}
return $this->_buildNonMailFolder(
- $class . ':' . $id, Horde_ActiveSync::FOLDER_ROOT, $type, $new_name
+ $class . ':' . $id,
+ Horde_ActiveSync::FOLDER_ROOT,
+ $type,
+ $new_name
);
}
@@ -829,8 +866,11 @@ public function changeFolder($old_name, $new_name, $parent, $uid = null, $type =
*/
public function deleteFolder($id, $parent = Horde_ActiveSync::FOLDER_ROOT)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::deleteFolder(%s)', $id)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::deleteFolder(%s)',
+ $id
+ )
);
$parts = $this->_parseFolderId($id);
@@ -843,24 +883,24 @@ public function deleteFolder($id, $parent = Horde_ActiveSync::FOLDER_ROOT)
}
switch ($folder_class) {
- case Horde_ActiveSync::CLASS_EMAIL:
- case Horde_ActiveSync::FOLDER_TYPE_USER_MAIL:
- try {
- $this->_imap->deleteMailbox($folder_id);
- } catch (Horde_ActiveSync_Exception $e) {
- if ($this->_isSpecialMailbox($folder_id)) {
- throw new Horde_ActiveSync_Exception_DeletionNotSupported($e);
+ case Horde_ActiveSync::CLASS_EMAIL:
+ case Horde_ActiveSync::FOLDER_TYPE_USER_MAIL:
+ try {
+ $this->_imap->deleteMailbox($folder_id);
+ } catch (Horde_ActiveSync_Exception $e) {
+ if ($this->_isSpecialMailbox($folder_id)) {
+ throw new Horde_ActiveSync_Exception_DeletionNotSupported($e);
+ }
+ $this->_logger->err($e->getMessage());
+ throw $e;
}
- $this->_logger->err($e->getMessage());
- throw $e;
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_TASKS:
- case Horde_ActiveSync::CLASS_CALENDAR:
- case Horde_ActiveSync::CLASS_CONTACTS:
- case Horde_ActiveSync::CLASS_NOTES:
- $this->_connector->deleteFolder($folder_class, $folder_id);
+ case Horde_ActiveSync::CLASS_TASKS:
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ case Horde_ActiveSync::CLASS_NOTES:
+ $this->_connector->deleteFolder($folder_class, $folder_id);
}
}
@@ -889,7 +929,7 @@ public function deleteFolder($id, $parent = Horde_ActiveSync::FOLDER_ROOT)
*/
public function statFolder($id, $parent = '0', $mod = null, $serverid = null, $type = null)
{
- $folder = array();
+ $folder = [];
$folder['id'] = $id;
$folder['mod'] = empty($mod) ? $id : $mod;
$folder['parent'] = $parent;
@@ -952,292 +992,306 @@ public function statFolder($id, $parent = '0', $mod = null, $serverid = null, $t
* to better define the available properties.
*/
public function getServerChanges(
- $folder, $from_ts, $to_ts, $cutoffdate, $ping, $ignoreFirstSync = false, $maxitems = 100, $refreshFilter = false)
- {
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::getServerChanges(%s, %u, %u, %u, %d, %s, %u, %s)',
- $folder->serverid(),
- $from_ts,
- $to_ts,
- $cutoffdate,
- $ping,
- $ignoreFirstSync,
- $maxitems,
- $refreshFilter)
+ $folder,
+ $from_ts,
+ $to_ts,
+ $cutoffdate,
+ $ping,
+ $ignoreFirstSync = false,
+ $maxitems = 100,
+ $refreshFilter = false
+ ) {
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::getServerChanges(%s, %u, %u, %u, %d, %s, %u, %s)',
+ $folder->serverid(),
+ $from_ts,
+ $to_ts,
+ $cutoffdate,
+ $ping,
+ $ignoreFirstSync,
+ $maxitems,
+ $refreshFilter
+ )
);
- $changes = array(
- 'add' => array(),
- 'delete' => array(),
- 'modify' => array(),
- 'soft' => array()
- );
+ $changes = [
+ 'add' => [],
+ 'delete' => [],
+ 'modify' => [],
+ 'soft' => [],
+ ];
ob_start();
switch ($folder->collectionClass()) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- if ($folder->serverid() == self::APPOINTMENTS_FOLDER_UID) {
- $server_id = null;
- } else {
- $parts = $this->_parseFolderId($folder->serverid());
- $server_id = $parts[self::FOLDER_PART_ID];
- }
-
- if ($from_ts == 0 && !$ignoreFirstSync) {
- // Can't use History if it's a first sync
- $startstamp = (int)$cutoffdate;
- $endstamp = time() + 32140800; //60 * 60 * 24 * 31 * 12 == one year
- try {
- $changes['add'] = $this->_connector->calendar_listUids($startstamp, $endstamp, $server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ if ($folder->serverid() == self::APPOINTMENTS_FOLDER_UID) {
+ $server_id = null;
+ } else {
+ $parts = $this->_parseFolderId($folder->serverid());
+ $server_id = $parts[self::FOLDER_PART_ID];
}
- $folder->setSoftDeleteTimes($cutoffdate, time());
- } else {
- try {
- $changes = $this->_connector->getChanges('calendar', $from_ts, $to_ts, $server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
- }
-
- // Softdelete. We check this once per close-to 24 hour period,or
- // if the FILTERTYPE range changes. We introduce an element of
- // randomness in the time to help avoid a large number of
- // clients performing a softdelete at once. It's 23 hours + some
- // random number of minutes < 60.
- //
- // @todo We need to populate additional events if the FILTERTYPE
- // is expanded, but we need to persist the previous FILTERTYPE
- // so we know exactly which events we already have and which
- // we don't (since we don't track the UIDs themselves).
- if (!$ping) {
- if (!$refreshFilter) {
- $sd = $folder->getSoftDeleteTimes();
- if ($sd[0] + 82800 + mt_rand(0, 3600) < time()) {
- $from = $sd[1];
- }
- } else {
- // Force refresh the FILTERTYPE.
- $from = 0;
+
+ if ($from_ts == 0 && !$ignoreFirstSync) {
+ // Can't use History if it's a first sync
+ $startstamp = (int)$cutoffdate;
+ $endstamp = time() + 32140800; //60 * 60 * 24 * 31 * 12 == one year
+ try {
+ $changes['add'] = $this->_connector->calendar_listUids($startstamp, $endstamp, $server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
}
- if (isset($from)) {
- $this->_logger->meta('Polling for SOFTDELETE items in calendar collection');
- $changes['soft'] = $this->_connector->softDelete(
- 'calendar', $from, $cutoffdate, $server_id
- );
- $folder->setSoftDeleteTimes($cutoffdate, time());
+ $folder->setSoftDeleteTimes($cutoffdate, time());
+ } else {
+ try {
+ $changes = $this->_connector->getChanges('calendar', $from_ts, $to_ts, $server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
+
+ // Softdelete. We check this once per close-to 24 hour period,or
+ // if the FILTERTYPE range changes. We introduce an element of
+ // randomness in the time to help avoid a large number of
+ // clients performing a softdelete at once. It's 23 hours + some
+ // random number of minutes < 60.
+ //
+ // @todo We need to populate additional events if the FILTERTYPE
+ // is expanded, but we need to persist the previous FILTERTYPE
+ // so we know exactly which events we already have and which
+ // we don't (since we don't track the UIDs themselves).
+ if (!$ping) {
+ if (!$refreshFilter) {
+ $sd = $folder->getSoftDeleteTimes();
+ if ($sd[0] + 82800 + mt_rand(0, 3600) < time()) {
+ $from = $sd[1];
+ }
+ } else {
+ // Force refresh the FILTERTYPE.
+ $from = 0;
+ }
+ if (isset($from)) {
+ $this->_logger->meta('Polling for SOFTDELETE items in calendar collection');
+ $changes['soft'] = $this->_connector->softDelete(
+ 'calendar',
+ $from,
+ $cutoffdate,
+ $server_id
+ );
+ $folder->setSoftDeleteTimes($cutoffdate, time());
+ }
}
}
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_CONTACTS:
- // Multiplexed or multiple?
- if ($folder->serverid() == self::CONTACTS_FOLDER_UID) {
- $server_id = null;
- } else {
- $parts = $this->_parseFolderId($folder->serverid());
- $server_id = $parts[self::FOLDER_PART_ID];
- }
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ // Multiplexed or multiple?
+ if ($folder->serverid() == self::CONTACTS_FOLDER_UID) {
+ $server_id = null;
+ } else {
+ $parts = $this->_parseFolderId($folder->serverid());
+ $server_id = $parts[self::FOLDER_PART_ID];
+ }
- // Can't use History for first sync
- if ($from_ts == 0 && !$ignoreFirstSync) {
- try {
- $changes['add'] = $this->_connector->contacts_listUids($server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+ // Can't use History for first sync
+ if ($from_ts == 0 && !$ignoreFirstSync) {
+ try {
+ $changes['add'] = $this->_connector->contacts_listUids($server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
+ } else {
+ try {
+ $changes = $this->_connector->getChanges('contacts', $from_ts, $to_ts, $server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
}
- } else {
- try {
- $changes = $this->_connector->getChanges('contacts', $from_ts, $to_ts, $server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+ break;
+
+ case Horde_ActiveSync::CLASS_TASKS:
+ // Multiplexed or multiple?
+ if ($folder->serverid() == self::TASKS_FOLDER_UID) {
+ $server_id = null;
+ } else {
+ $parts = $this->_parseFolderId($folder->serverid());
+ $server_id = $parts[self::FOLDER_PART_ID];
}
- }
- break;
- case Horde_ActiveSync::CLASS_TASKS:
- // Multiplexed or multiple?
- if ($folder->serverid() == self::TASKS_FOLDER_UID) {
- $server_id = null;
- } else {
- $parts = $this->_parseFolderId($folder->serverid());
- $server_id = $parts[self::FOLDER_PART_ID];
- }
+ // Can't use History for first sync
+ if ($from_ts == 0 && !$ignoreFirstSync) {
+ try {
+ $changes['add'] = $this->_connector->tasks_listUids($server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
+ } else {
+ try {
+ $changes = $this->_connector->getChanges('tasks', $from_ts, $to_ts, $server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
+ }
+ break;
- // Can't use History for first sync
- if ($from_ts == 0 && !$ignoreFirstSync) {
- try {
- $changes['add'] = $this->_connector->tasks_listUids($server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+ case Horde_ActiveSync::CLASS_NOTES:
+ // Multiplexed or multiple?
+ if ($folder->serverid() == self::NOTES_FOLDER_UID) {
+ $server_id = null;
+ } else {
+ $parts = $this->_parseFolderId($folder->serverid());
+ $server_id = $parts[self::FOLDER_PART_ID];
}
- } else {
- try {
- $changes = $this->_connector->getChanges('tasks', $from_ts, $to_ts, $server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+
+ // Can't use History for first sync
+ if ($from_ts == 0 && !$ignoreFirstSync) {
+ try {
+ $changes['add'] = $this->_connector->notes_listUids($server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
+ } else {
+ try {
+ $changes = $this->_connector->getChanges('notes', $from_ts, $to_ts, $server_id);
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
+ }
}
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_NOTES:
- // Multiplexed or multiple?
- if ($folder->serverid() == self::NOTES_FOLDER_UID) {
- $server_id = null;
- } else {
- $parts = $this->_parseFolderId($folder->serverid());
- $server_id = $parts[self::FOLDER_PART_ID];
- }
+ case 'RI':
+ $folder->setChanges($this->_connector->getRecipientCache($maxitems));
+ $changes = [
+ 'add' => $folder->added(),
+ 'delete' => $folder->removed(),
+ 'modify' => [],
+ 'soft' => []];
+ break;
- // Can't use History for first sync
- if ($from_ts == 0 && !$ignoreFirstSync) {
- try {
- $changes['add'] = $this->_connector->notes_listUids($server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
+ case Horde_ActiveSync::CLASS_EMAIL:
+ if (empty($this->_imap) ||
+ $folder->serverid() == 'OUTBOX') {
$this->_endBuffer();
- return array();
+ return [];
}
- } else {
- try {
- $changes = $this->_connector->getChanges('notes', $from_ts, $to_ts, $server_id);
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
- }
- }
- break;
-
- case 'RI':
- $folder->setChanges($this->_connector->getRecipientCache($maxitems));
- $changes = array(
- 'add' => $folder->added(),
- 'delete' => $folder->removed(),
- 'modify' => array(),
- 'soft' => array());
- break;
-
- case Horde_ActiveSync::CLASS_EMAIL:
- if (empty($this->_imap) ||
- $folder->serverid() == 'OUTBOX') {
- $this->_endBuffer();
- return array();
- }
- $this->_logger->meta(sprintf(
- '%s IMAP PREVIOUS MODSEQ: %d',
- $folder->serverid(),
- $folder->modseq())
- );
- if ($ping) {
- try {
- $ping_res = $this->_imap->ping($folder);
- if ($ping_res) {
- $changes['add'] = array(1);
+ $this->_logger->meta(
+ sprintf(
+ '%s IMAP PREVIOUS MODSEQ: %d',
+ $folder->serverid(),
+ $folder->modseq()
+ )
+ );
+ if ($ping) {
+ try {
+ $ping_res = $this->_imap->ping($folder);
+ if ($ping_res) {
+ $changes['add'] = [1];
+ }
+ } catch (Horde_ActiveSync_Exeption_StaleState $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_ActiveSync_Exception_FolderGone $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
}
- } catch (Horde_ActiveSync_Exeption_StaleState $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_ActiveSync_Exception_FolderGone $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
- }
- } else {
- // SOFTDELETE, but only if we aren't refreshing FILTERTYPE.
- // @todo - Move the soft delete check(s) into the AS library.
- $soft = false;
- if (!$refreshFilter) {
- $sd = $folder->getSoftDeleteTimes();
- if (empty($sd[0]) && empty($sd[1]) && !empty($cutoffdate)) {
- // No SOFTDELETE performed, this is likely the first
- // sync so we must prime the SOFTDELETE values.
- $folder->setSoftDeleteTimes((int)$cutoffdate, time());
- } else {
- if ($sd[1] + 82800 + mt_rand(0, 3600) < time()) {
- $soft = true;
+ } else {
+ // SOFTDELETE, but only if we aren't refreshing FILTERTYPE.
+ // @todo - Move the soft delete check(s) into the AS library.
+ $soft = false;
+ if (!$refreshFilter) {
+ $sd = $folder->getSoftDeleteTimes();
+ if (empty($sd[0]) && empty($sd[1]) && !empty($cutoffdate)) {
+ // No SOFTDELETE performed, this is likely the first
+ // sync so we must prime the SOFTDELETE values.
+ $folder->setSoftDeleteTimes((int)$cutoffdate, time());
} else {
- $soft = false;
+ if ($sd[1] + 82800 + mt_rand(0, 3600) < time()) {
+ $soft = true;
+ } else {
+ $soft = false;
+ }
}
}
- }
- try {
- $folder = $this->_imap->getMessageChanges(
- $folder,
- array(
- 'sincedate' => (int)$cutoffdate,
- 'protocolversion' => $this->_version,
- 'softdelete' => $soft,
- 'refreshfilter' => $refreshFilter
- )
- );
- // Poll the maillog for reply/forward state changes.
- if (empty($GLOBALS['conf']['activesync']['no_maillogsync'])) {
- $folder = $this->_getMaillogChanges($folder, $from_ts);
+ try {
+ $folder = $this->_imap->getMessageChanges(
+ $folder,
+ [
+ 'sincedate' => (int)$cutoffdate,
+ 'protocolversion' => $this->_version,
+ 'softdelete' => $soft,
+ 'refreshfilter' => $refreshFilter,
+ ]
+ );
+ // Poll the maillog for reply/forward state changes.
+ if (empty($GLOBALS['conf']['activesync']['no_maillogsync'])) {
+ $folder = $this->_getMaillogChanges($folder, $from_ts);
+ }
+ } catch (Horde_ActiveSync_Exception_StaleState $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_ActiveSync_Exception_FolderGone $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception_AuthenticationFailure $e) {
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return [];
}
- } catch (Horde_ActiveSync_Exception_StaleState $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_ActiveSync_Exception_FolderGone $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception_AuthenticationFailure $e) {
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return array();
+ $changes['add'] = $folder->added();
+ $changes['delete'] = $folder->removed();
+ $changes['modify'] = $folder->changed();
+ $changes['soft'] = $folder->getSoftDeleted();
}
- $changes['add'] = $folder->added();
- $changes['delete'] = $folder->removed();
- $changes['modify'] = $folder->changed();
- $changes['soft'] = $folder->getSoftDeleted();
- }
}
// Short circuit initial sync.
@@ -1249,17 +1303,17 @@ public function getServerChanges(
return $add;
}
- $results = array();
+ $results = [];
foreach ($changes['add'] as $add) {
$type = ($folder->collectionClass() == Horde_ActiveSync::CLASS_EMAIL &&
$folder->serverid() == $this->getSpecialFolderNameByType(self::SPECIAL_DRAFTS))
? Horde_ActiveSync::CHANGE_TYPE_DRAFT
: Horde_ActiveSync::CHANGE_TYPE_CHANGE;
- $results[] = array(
+ $results[] = [
'id' => $add,
'type' => $type,
- 'flags' => Horde_ActiveSync::FLAG_NEWMESSAGE
- );
+ 'flags' => Horde_ActiveSync::FLAG_NEWMESSAGE,
+ ];
}
// For CLASS_EMAIL, all changes are a change in flags, categories or
@@ -1268,34 +1322,34 @@ public function getServerChanges(
$flags = $folder->flags();
$categories = $folder->categories();
foreach ($changes['modify'] as $uid) {
- $results[] = array(
+ $results[] = [
'id' => $uid,
'type' => Horde_ActiveSync::CHANGE_TYPE_FLAGS,
'flags' => $flags[$uid],
- 'categories' => $categories[$uid]
- );
+ 'categories' => $categories[$uid],
+ ];
}
} else {
foreach ($changes['modify'] as $change) {
- $results[] = array(
+ $results[] = [
'id' => $change,
- 'type' => Horde_ActiveSync::CHANGE_TYPE_CHANGE
- );
+ 'type' => Horde_ActiveSync::CHANGE_TYPE_CHANGE,
+ ];
}
}
// Server Deletions and Softdeletions
foreach ($changes['delete'] as $deleted) {
- $results[] = array(
+ $results[] = [
'id' => $deleted,
- 'type' => Horde_ActiveSync::CHANGE_TYPE_DELETE);
+ 'type' => Horde_ActiveSync::CHANGE_TYPE_DELETE];
}
if (!empty($changes['soft'])) {
foreach ($changes['soft'] as $deleted) {
- $results[] = array(
+ $results[] = [
'id' => $deleted,
- 'type' => Horde_ActiveSync::CHANGE_TYPE_SOFTDELETE
- );
+ 'type' => Horde_ActiveSync::CHANGE_TYPE_SOFTDELETE,
+ ];
}
}
@@ -1327,10 +1381,12 @@ public function getServerChanges(
*/
public function getMessage($folderid, $id, array $collection)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::getMessage(%s, %s)',
- $folderid,
- $id)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::getMessage(%s, %s)',
+ $folderid,
+ $id
+ )
);
ob_start();
$message = false;
@@ -1343,222 +1399,225 @@ public function getMessage($folderid, $id, array $collection)
}
switch ($folder_class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- // Explicitly set the calendar to search if we are not using
- // multiplexed collections since multiple calendars may have
- // the same event UID.
- $folder_id = is_array($folder_split) ? $folder_split[self::FOLDER_PART_ID] : null;
- try {
- $message = $this->_connector->calendar_export($id, array(
- 'protocolversion' => $this->_version,
- 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'],
- 'bodyprefs' => $collection['bodyprefs'],
- 'mimesupport' => $collection['mimesupport']), $folder_id);
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ // Explicitly set the calendar to search if we are not using
+ // multiplexed collections since multiple calendars may have
+ // the same event UID.
+ $folder_id = is_array($folder_split) ? $folder_split[self::FOLDER_PART_ID] : null;
+ try {
+ $message = $this->_connector->calendar_export($id, [
+ 'protocolversion' => $this->_version,
+ 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'],
+ 'bodyprefs' => $collection['bodyprefs'],
+ 'mimesupport' => $collection['mimesupport']], $folder_id);
- // Nokia MfE requires the optional UID element.
- if (!$message->getUid()) {
- $message->setUid($id);
+ // Nokia MfE requires the optional UID element.
+ if (!$message->getUid()) {
+ $message->setUid($id);
+ }
+ } catch (Horde_Exception_NotFound $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception($e->getMessage());
}
- } catch (Horde_Exception_NotFound $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception($e->getMessage());
- }
- break;
+ break;
- case 'RI':
- $id = explode(':', $id);
- try {
- $recipients = $this->_connector->contacts_search($id[0], array('recipient_cache_search' => true));
- } catch (Horde_Exception_NotFound $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception($e->getMessage());
- }
- if (is_array($recipients) && count($recipients)) {
- $row = array_pop(array_pop($recipients));
- if (!count($row)) {
- $row = array();
+ case 'RI':
+ $id = explode(':', $id);
+ try {
+ $recipients = $this->_connector->contacts_search($id[0], ['recipient_cache_search' => true]);
+ } catch (Horde_Exception_NotFound $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception($e->getMessage());
}
- } else {
- $row = array();
- }
- $message = Horde_ActiveSync::messageFactory('RecipientInformation');
- $message->alias = !empty($row['alias']) ? $row['alias'] : $id[0];
- $message->email1address = !empty($row['email']) ? $row['email'] : $id[0];
- $message->fileas = empty($row['name']) ? $id[0] : $row['name'];
- $message->weightedrank = $id[1] + 1;
- break;
-
- case Horde_ActiveSync::CLASS_CONTACTS:
- try {
- $message = $this->_connector->contacts_export($id, array(
- 'protocolversion' => $this->_version,
- 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'],
- 'bodyprefs' => $collection['bodyprefs'],
- 'mimesupport' => $collection['mimesupport'],
- 'device' => $this->_device));
- } catch (Horde_Exception_NotFound $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception($e->getMessage());
- }
- break;
+ if (is_array($recipients) && count($recipients)) {
+ $row = array_pop(array_pop($recipients));
+ if (!count($row)) {
+ $row = [];
+ }
+ } else {
+ $row = [];
+ }
+ $message = Horde_ActiveSync::messageFactory('RecipientInformation');
+ $message->alias = !empty($row['alias']) ? $row['alias'] : $id[0];
+ $message->email1address = !empty($row['email']) ? $row['email'] : $id[0];
+ $message->fileas = empty($row['name']) ? $id[0] : $row['name'];
+ $message->weightedrank = $id[1] + 1;
+ break;
- case Horde_ActiveSync::CLASS_TASKS:
- try {
- $message = $this->_connector->tasks_export($id, array(
- 'protocolversion' => $this->_version,
- 'truncation' => $collection['truncation'],
- 'bodyprefs' => $collection['bodyprefs'],
- 'mimesupport' => $collection['mimesupport']));
- } catch (Horde_Exception_NotFound $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception($e->getMessage);
- }
- break;
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ try {
+ $message = $this->_connector->contacts_export($id, [
+ 'protocolversion' => $this->_version,
+ 'truncation' => empty($collection['truncation']) ? Horde_ActiveSync::TRUNCATION_9 : $collection['truncation'],
+ 'bodyprefs' => $collection['bodyprefs'],
+ 'mimesupport' => $collection['mimesupport'],
+ 'device' => $this->_device]);
+ } catch (Horde_Exception_NotFound $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception($e->getMessage());
+ }
+ break;
- case Horde_ActiveSync::CLASS_NOTES:
- try {
- $message = $this->_connector->notes_export($id, array(
- 'protocolversion' => $this->_version,
- 'truncation' => $collection['truncation'],
- 'bodyprefs' => $collection['bodyprefs'],
- 'mimesupport' => $collection['mimesupport']));
- } catch (Horde_Exception_NotFound $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw $e;
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception($e->getMessage);
- }
- break;
+ case Horde_ActiveSync::CLASS_TASKS:
+ try {
+ $message = $this->_connector->tasks_export($id, [
+ 'protocolversion' => $this->_version,
+ 'truncation' => $collection['truncation'],
+ 'bodyprefs' => $collection['bodyprefs'],
+ 'mimesupport' => $collection['mimesupport']]);
+ } catch (Horde_Exception_NotFound $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception($e->getMessage);
+ }
+ break;
- case Horde_ActiveSync::CLASS_EMAIL:
- // Get the message from the IMAP server.
- try {
- $messages = $this->_imap->getMessages(
- $folderid,
- array($id),
- array(
+ case Horde_ActiveSync::CLASS_NOTES:
+ try {
+ $message = $this->_connector->notes_export($id, [
'protocolversion' => $this->_version,
- 'truncation' => !empty($collection['truncation'])
+ 'truncation' => $collection['truncation'],
+ 'bodyprefs' => $collection['bodyprefs'],
+ 'mimesupport' => $collection['mimesupport']]);
+ } catch (Horde_Exception_NotFound $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw $e;
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception($e->getMessage);
+ }
+ break;
+
+ case Horde_ActiveSync::CLASS_EMAIL:
+ // Get the message from the IMAP server.
+ try {
+ $messages = $this->_imap->getMessages(
+ $folderid,
+ [$id],
+ [
+ 'protocolversion' => $this->_version,
+ 'truncation' => !empty($collection['truncation'])
+ ? $collection['truncation']
+ : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : false),
+ 'bodyprefs' => $collection['bodyprefs'],
+ 'bodypartprefs' => !empty($collection['bodypartprefs'])
+ ? $collection['bodypartprefs']
+ : false,
+ 'mimesupport' => $collection['mimesupport'],
+ ]
+ );
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $context = 'Protocol Version: ' . $this->_version . "\r\n"
+ . 'Truncation: ' . (!empty($collection['truncation'])
? $collection['truncation']
- : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : false),
- 'bodyprefs' => $collection['bodyprefs'],
- 'bodypartprefs' => !empty($collection['bodypartprefs'])
- ? $collection['bodypartprefs']
- : false,
- 'mimesupport' => $collection['mimesupport']
- )
- );
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err($e->getMessage());
- $context = 'Protocol Version: ' . $this->_version . "\r\n"
- . 'Truncation: ' . (!empty($collection['truncation'])
- ? $collection['truncation']
- : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : 'false') ). "\r\n"
- . 'BodyPrefs: ' . print_r($collection['bodyprefs'], true) . "\r\n"
- . 'BodyPartPrefs: ' . (!empty($collection['bodypartprefs'])
- ? print_r($collection['bodypartprefs'], true)
- : 'false') . "\r\n"
- . 'MimeSupport: ' . $collection['mimesupport'];
-
- $this->_logger->err($context);
+ : (!empty($collection['mimetruncation']) ? $collection['mimetruncation'] : 'false')). "\r\n"
+ . 'BodyPrefs: ' . print_r($collection['bodyprefs'], true) . "\r\n"
+ . 'BodyPartPrefs: ' . (!empty($collection['bodypartprefs'])
+ ? print_r($collection['bodypartprefs'], true)
+ : 'false') . "\r\n"
+ . 'MimeSupport: ' . $collection['mimesupport'];
- $this->_endBuffer();
- throw $e;
- }
- if (empty($messages)) {
- $this->_endBuffer();
- throw new Horde_Exception_NotFound();
- }
- $msg = array_pop($messages);
+ $this->_logger->err($context);
- // Check for verb status from the Maillog.
- if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEEN) {
- $last = null;
- if (!empty($msg->messageid)) {
- $last = $this->_getLastVerb($msg->messageid);
+ $this->_endBuffer();
+ throw $e;
}
- if (!empty($last)) {
- switch ($last['action']) {
- case 'reply':
- case 'reply_list':
- $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_SENDER;
- break;
- case 'reply_all':
- $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_ALL;
- break;
- case 'forward':
- $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_FORWARD;
+ if (empty($messages)) {
+ $this->_endBuffer();
+ throw new Horde_Exception_NotFound();
+ }
+ $msg = array_pop($messages);
+
+ // Check for verb status from the Maillog.
+ if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEEN) {
+ $last = null;
+ if (!empty($msg->messageid)) {
+ $last = $this->_getLastVerb($msg->messageid);
}
- $msg->lastverbexecutiontime = new Horde_Date($last['ts']);
- } else {
- // No maillog found, double check the IMAP flags.
- // We favor the Maillog since EAS allows for a complete log
- // of actions - and it requires a timestamp.
- if ($msg->answered) {
- $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_SENDER;
- $msg->lastverbexecutiontime = new Horde_Date(time());
- } elseif ($msg->forwarded) {
- $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_FORWARD;
- $msg->lastverbexecutiontime = new Horde_Date(time());
+ if (!empty($last)) {
+ switch ($last['action']) {
+ case 'reply':
+ case 'reply_list':
+ $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_SENDER;
+ break;
+ case 'reply_all':
+ $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_ALL;
+ break;
+ case 'forward':
+ $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_FORWARD;
+ }
+ $msg->lastverbexecutiontime = new Horde_Date($last['ts']);
+ } else {
+ // No maillog found, double check the IMAP flags.
+ // We favor the Maillog since EAS allows for a complete log
+ // of actions - and it requires a timestamp.
+ if ($msg->answered) {
+ $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_REPLY_SENDER;
+ $msg->lastverbexecutiontime = new Horde_Date(time());
+ } elseif ($msg->forwarded) {
+ $msg->lastverbexecuted = Horde_ActiveSync_Message_Mail::VERB_FORWARD;
+ $msg->lastverbexecutiontime = new Horde_Date(time());
+ }
}
}
- }
- // Is this from the draft folder?
- if ($this->_version >= Horde_ActiveSync::VERSION_SIXTEEN &&
- !empty($collection['type']) &&
- $collection['type'] == Horde_ActiveSync::FOLDER_TYPE_DRAFTS) {
- $msg->isdraft = true;
- }
+ // Is this from the draft folder?
+ if ($this->_version >= Horde_ActiveSync::VERSION_SIXTEEN &&
+ !empty($collection['type']) &&
+ $collection['type'] == Horde_ActiveSync::FOLDER_TYPE_DRAFTS) {
+ $msg->isdraft = true;
+ }
- $this->_endBuffer();
+ $this->_endBuffer();
- // Should we import an iTip response if we have one and we are in
- // the INBOX?
- if ($folderid == 'INBOX' &&
- $this->_version >= Horde_ActiveSync::VERSION_TWELVE &&
- $msg->contentclass == 'urn:content-classes:calendarmessage') {
-
- switch ($msg->messageclass) {
- case 'IPM.Schedule.Meeting.Resp.Pos':
- case 'IPM.Schedule.Meeting.Resp.Neg':
- case 'IPM.Schedule.Meeting.Resp.Tent':
- $addr = new Horde_Mail_Rfc822_Address($msg->from);
- $rq = $msg->meetingrequest;
- $this->_connector->calendar_import_attendee(
- $rq->getvEvent(),
- $addr->bare_address);
+ // Should we import an iTip response if we have one and we are in
+ // the INBOX?
+ if ($folderid == 'INBOX' &&
+ $this->_version >= Horde_ActiveSync::VERSION_TWELVE &&
+ $msg->contentclass == 'urn:content-classes:calendarmessage') {
+
+ switch ($msg->messageclass) {
+ case 'IPM.Schedule.Meeting.Resp.Pos':
+ case 'IPM.Schedule.Meeting.Resp.Neg':
+ case 'IPM.Schedule.Meeting.Resp.Tent':
+ $addr = new Horde_Mail_Rfc822_Address($msg->from);
+ $rq = $msg->meetingrequest;
+ $this->_connector->calendar_import_attendee(
+ $rq->getvEvent(),
+ $addr->bare_address
+ );
+ }
}
- }
- return $msg;
+ return $msg;
- default:
- $this->_endBuffer();
- throw new Horde_ActiveSync_Exception(sprintf(
- 'Unsupported type: %s', $folder_class));
+ default:
+ $this->_endBuffer();
+ throw new Horde_ActiveSync_Exception(sprintf(
+ 'Unsupported type: %s',
+ $folder_class
+ ));
}
$this->_endBuffer();
@@ -1580,16 +1639,16 @@ public function getMessage($folderid, $id, array $collection)
* array('content-type' => {the content-type of the attachement},
* 'data' => {the raw attachment data})
*/
- public function getAttachment($name, array $options = array())
+ public function getAttachment($name, array $options = [])
{
- $options = array_merge(array('stream' => true), $options);
- list($mailbox, $uid, $part) = explode(':', $name);
+ $options = array_merge(['stream' => true], $options);
+ [$mailbox, $uid, $part] = explode(':', $name);
$atc = $this->_imap->getAttachment($mailbox, $uid, $part);
- return array(
+ return [
'content-type' => $atc->getType(),
- 'data' => $atc->getContents(array('stream' => $options['stream']))
- );
+ 'data' => $atc->getContents(['stream' => $options['stream']]),
+ ];
}
/**
@@ -1606,15 +1665,17 @@ public function getAttachment($name, array $options = array())
* @return Horde_ActiveSync_Message_Base The message requested.
*/
public function itemOperationsFetchMailbox(
- $longid, array $bodyprefs, $mimesupport = 0)
- {
- list($mailbox, $uid) = explode(':', $longid);
+ $longid,
+ array $bodyprefs,
+ $mimesupport = 0
+ ) {
+ [$mailbox, $uid] = explode(':', $longid);
return $this->getMessage(
$mailbox,
$uid,
- array(
+ [
'bodyprefs' => $bodyprefs,
- 'mimesupport' => $mimesupport)
+ 'mimesupport' => $mimesupport]
);
}
@@ -1704,11 +1765,13 @@ public function statMessage($folderid, $id)
*/
public function deleteMessage($folderid, array $ids, $instanceids = false)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::deleteMessage() %s: %s %s',
- $folderid,
- print_r($ids, true),
- $instanceids)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::deleteMessage() %s: %s %s',
+ $folderid,
+ print_r($ids, true),
+ $instanceids
+ )
);
$parts = $this->_parseFolderId($folderid);
@@ -1723,104 +1786,108 @@ public function deleteMessage($folderid, array $ids, $instanceids = false)
$results = $ids;
switch ($class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- if ($instanceids) {
- $instanceid = reset($ids);
- $ids = key($ids);
- } else {
- $instanceid = false;
- }
- try {
- $this->_logger->meta(sprintf(
- 'calendar_delete: %s %s %s',
- print_r($ids, true), $folder_id, $instanceid)
- );
- $this->_connector->calendar_delete($ids, $folder_id, $instanceid);
- } catch (Horde_Exception $e) {
- // Since we don't get back successfully deleted ids and we can
- // can pass an array of ids to delete, we need to see what ids
- // were deleted if there was an error.
- // @todo For Horde 6, the API should return successfully
- // deleted ids.
- $this->_logger->err($e->getMessage());
- $success = array();
- foreach ($ids as $uid) {
- if ($mod_time = $this->_connector->calendar_getActionTimestamp($uid, 'delete', $folder_id)) {
- $success[] = $uid;
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ if ($instanceids) {
+ $instanceid = reset($ids);
+ $ids = key($ids);
+ } else {
+ $instanceid = false;
+ }
+ try {
+ $this->_logger->meta(
+ sprintf(
+ 'calendar_delete: %s %s %s',
+ print_r($ids, true),
+ $folder_id,
+ $instanceid
+ )
+ );
+ $this->_connector->calendar_delete($ids, $folder_id, $instanceid);
+ } catch (Horde_Exception $e) {
+ // Since we don't get back successfully deleted ids and we can
+ // can pass an array of ids to delete, we need to see what ids
+ // were deleted if there was an error.
+ // @todo For Horde 6, the API should return successfully
+ // deleted ids.
+ $this->_logger->err($e->getMessage());
+ $success = [];
+ foreach ($ids as $uid) {
+ if ($mod_time = $this->_connector->calendar_getActionTimestamp($uid, 'delete', $folder_id)) {
+ $success[] = $uid;
+ }
}
+ $results = $success;
}
- $results = $success;
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_CONTACTS:
- try {
- $this->_connector->contacts_delete($ids);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- // Since we don't get back successfully deleted ids and we can
- // can pass an array of ids to delete, we need to see what ids
- // were deleted if there was an error.
- // @todo For Horde 6, the API should return successfully
- // deleted ids.
- $this->_logger->err($e->getMessage());
- $success = array();
- foreach ($ids as $uid) {
- if ($mod_time = $this->_connector->contacts_getActionTimestamp($uid, 'delete', $folder_id)) {
- $success[] = $uid;
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ try {
+ $this->_connector->contacts_delete($ids);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ // Since we don't get back successfully deleted ids and we can
+ // can pass an array of ids to delete, we need to see what ids
+ // were deleted if there was an error.
+ // @todo For Horde 6, the API should return successfully
+ // deleted ids.
+ $this->_logger->err($e->getMessage());
+ $success = [];
+ foreach ($ids as $uid) {
+ if ($mod_time = $this->_connector->contacts_getActionTimestamp($uid, 'delete', $folder_id)) {
+ $success[] = $uid;
+ }
}
+ $results = $success;
}
- $results = $success;
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_TASKS:
- try {
- $this->_connector->tasks_delete($ids);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- // Since we don't get back successfully deleted ids and we can
- // can pass an array of ids to delete, we need to see what ids
- // were deleted if there was an error.
- // @todo For Horde 6, the API should return successfully
- // deleted ids.
- $this->_logger->err($e->getMessage());
- $success = array();
- foreach ($ids as $uid) {
- if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
- $success[] = $uid;
+ case Horde_ActiveSync::CLASS_TASKS:
+ try {
+ $this->_connector->tasks_delete($ids);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ // Since we don't get back successfully deleted ids and we can
+ // can pass an array of ids to delete, we need to see what ids
+ // were deleted if there was an error.
+ // @todo For Horde 6, the API should return successfully
+ // deleted ids.
+ $this->_logger->err($e->getMessage());
+ $success = [];
+ foreach ($ids as $uid) {
+ if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
+ $success[] = $uid;
+ }
}
+ $results = $success;
}
- $results = $success;
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_NOTES:
- try {
- $this->_connector->notes_delete($ids);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- // Since we don't get back successfully deleted ids and we can
- // can pass an array of ids to delete, we need to see what ids
- // were deleted if there was an error.
- // @todo For Horde 6, the API should return successfully
- // deleted ids.
- $success = array();
- foreach ($ids as $uid) {
- if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
- $success[] = $uid;
+ case Horde_ActiveSync::CLASS_NOTES:
+ try {
+ $this->_connector->notes_delete($ids);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ // Since we don't get back successfully deleted ids and we can
+ // can pass an array of ids to delete, we need to see what ids
+ // were deleted if there was an error.
+ // @todo For Horde 6, the API should return successfully
+ // deleted ids.
+ $success = [];
+ foreach ($ids as $uid) {
+ if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
+ $success[] = $uid;
+ }
}
+ $results = $success;
+ }
+ break;
+ default:
+ // Must be mail folder
+ try {
+ $results = $this->_imap->deleteMessages($ids, $folderid);
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_logger->err($e->getMessage());
}
- $results = $success;
- }
- break;
- default:
- // Must be mail folder
- try {
- $results = $this->_imap->deleteMessages($ids, $folderid);
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err($e->getMessage());
- }
}
$this->_endBuffer();
@@ -1843,11 +1910,13 @@ public function deleteMessage($folderid, array $ids, $instanceids = false)
*/
public function moveMessage($folderid, array $ids, $newfolderid)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::moveMessage(%s, [%s], %s)',
- $folderid,
- implode(',', $ids),
- $newfolderid)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::moveMessage(%s, [%s], %s)',
+ $folderid,
+ implode(',', $ids),
+ $newfolderid
+ )
);
$parts = $this->_parseFolderId($folderid);
@@ -1858,26 +1927,26 @@ public function moveMessage($folderid, array $ids, $newfolderid)
$folder_class = $parts;
$folder_id = null;
}
- $move_res = array();
+ $move_res = [];
ob_start();
switch ($folder_class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- $parts = $this->_parseFolderId($newfolderid);
- if (is_array($parts)) {
- $newfolderid = $parts[self::FOLDER_PART_ID];
- }
- if ($res = $this->_connector->calendar_move(array_pop($ids), $folder_id, $newfolderid)) {
- $move_res[$res] = $res;
- }
- break;
- case Horde_ActiveSync::CLASS_CONTACTS:
- case Horde_ActiveSync::CLASS_TASKS:
- case Horde_ActiveSync::CLASS_NOTES:
- $this->_endBuffer();
- // Not supported, so just drop through to return the empty array.
- break;
- default:
- $move_res = $this->_imap->moveMessage($folderid, $ids, $newfolderid);
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ $parts = $this->_parseFolderId($newfolderid);
+ if (is_array($parts)) {
+ $newfolderid = $parts[self::FOLDER_PART_ID];
+ }
+ if ($res = $this->_connector->calendar_move(array_pop($ids), $folder_id, $newfolderid)) {
+ $move_res[$res] = $res;
+ }
+ break;
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ case Horde_ActiveSync::CLASS_TASKS:
+ case Horde_ActiveSync::CLASS_NOTES:
+ $this->_endBuffer();
+ // Not supported, so just drop through to return the empty array.
+ break;
+ default:
+ $move_res = $this->_imap->moveMessage($folderid, $ids, $newfolderid);
}
$this->_endBuffer();
@@ -1911,10 +1980,12 @@ public function moveMessage($folderid, array $ids, $newfolderid)
*/
public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $message, $device)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::changeMessage(%s, %s ...)',
- $folderid,
- $id)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::changeMessage(%s, %s ...)',
+ $folderid,
+ $id
+ )
);
// Short circuit OUTBOX modifications to work around broken clients.
@@ -1924,211 +1995,214 @@ public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $mes
ob_start();
- $folder_split = $this->_parseFolderId($folderid);
- if (is_array($folder_split)) {
- $folder_class = $folder_split[self::FOLDER_PART_CLASS];
- $server_id = $folder_split[self::FOLDER_PART_ID];
- } else {
- $folder_class = $folder_split;
- $server_id = null;
- }
-
- $stat = false;
-
- switch ($folder_class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- if (!$id) {
- try {
- // @todo, remove 'import16' hack for H6
- $results = $this->_connector->calendar_import16($message, $server_id);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = array(
- 'mod' => $this->getSyncStamp($folderid),
- 'id' => $results['uid'],
- 'flags' => 1,
- 'atchash' => $results['atchash']
- );
- } else {
- // ActiveSync messages do NOT contain the serverUID value, put
- // it in ourselves so we can have it during import/change.
- $message->setServerUID($id);
- try {
- $results = $this->_connector->calendar_replace($id, $message, $server_id);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = $this->_smartStatMessage($folderid, $id, false);
- // @todo Remove this check in H6, when the API always returns.
- if (!empty($results)) {
- $stat['atchash'] = !empty($results['atchash'])
- ? $results['atchash']
- : false;
- }
- }
- break;
+ $folder_split = $this->_parseFolderId($folderid);
+ if (is_array($folder_split)) {
+ $folder_class = $folder_split[self::FOLDER_PART_CLASS];
+ $server_id = $folder_split[self::FOLDER_PART_ID];
+ } else {
+ $folder_class = $folder_split;
+ $server_id = null;
+ }
- case Horde_ActiveSync::CLASS_CONTACTS:
- if (!$id) {
- try {
- $id = $this->_connector->contacts_import($message, $server_id);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1);
- } else {
- try {
- $this->_connector->contacts_replace($id, $message);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = $this->_smartStatMessage($folderid, $id, false);
- }
- break;
+ $stat = false;
- case Horde_ActiveSync::CLASS_TASKS:
- if (!$id) {
- try {
- $id = $this->_connector->tasks_import($message, $server_id);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1);
- } else {
- try {
- $this->_connector->tasks_replace($id, $message);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
+ switch ($folder_class) {
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ if (!$id) {
+ try {
+ // @todo, remove 'import16' hack for H6
+ $results = $this->_connector->calendar_import16($message, $server_id);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = [
+ 'mod' => $this->getSyncStamp($folderid),
+ 'id' => $results['uid'],
+ 'flags' => 1,
+ 'atchash' => $results['atchash'],
+ ];
+ } else {
+ // ActiveSync messages do NOT contain the serverUID value, put
+ // it in ourselves so we can have it during import/change.
+ $message->setServerUID($id);
+ try {
+ $results = $this->_connector->calendar_replace($id, $message, $server_id);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = $this->_smartStatMessage($folderid, $id, false);
+ // @todo Remove this check in H6, when the API always returns.
+ if (!empty($results)) {
+ $stat['atchash'] = !empty($results['atchash'])
+ ? $results['atchash']
+ : false;
+ }
}
- $stat = $this->_smartStatMessage($folderid, $id, false);
- }
- break;
+ break;
- case Horde_ActiveSync::CLASS_NOTES:
- if (!$id) {
- try {
- $id = $this->_connector->notes_import($message, $server_id);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
- }
- $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1);
- } else {
- try {
- $this->_connector->notes_replace($id, $message);
- } catch (Horde_Exception $e) {
- $this->_logger->err($e->getMessage());
- $this->_endBuffer();
- return false;
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ if (!$id) {
+ try {
+ $id = $this->_connector->contacts_import($message, $server_id);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = ['mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1];
+ } else {
+ try {
+ $this->_connector->contacts_replace($id, $message);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = $this->_smartStatMessage($folderid, $id, false);
}
- $stat = $this->_smartStatMessage($folderid, $id, false);
- }
- break;
-
- default:
- if ($message instanceof Horde_ActiveSync_Message_Mail) {
- $stat = array(
- 'id' => $id,
- 'mod' => 0,
- 'flags' => array(),
- 'categories' => false
- );
-
- // Check for draft sync.
- if ($this->_version >= Horde_ActiveSync::VERSION_SIXTEEN &&
- $folderid == $this->getSpecialFolderNameByType(self::SPECIAL_DRAFTS)) {
+ break;
- // @todo Does this only happen on drafts?
- if ($message->send) {
- $this->_logger->err('NOT YET SUPPORTED.');
- return $stat;
+ case Horde_ActiveSync::CLASS_TASKS:
+ if (!$id) {
+ try {
+ $id = $this->_connector->tasks_import($message, $server_id);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = ['mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1];
+ } else {
+ try {
+ $this->_connector->tasks_replace($id, $message);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
}
+ $stat = $this->_smartStatMessage($folderid, $id, false);
+ }
+ break;
- // Are we addding/changing a draft email?
- if ($message->airsyncbasebody) {
- $draft_folder = $this->getSpecialFolderNameByType(
- self::SPECIAL_DRAFTS
- );
- $draft = new Horde_Core_ActiveSync_Mail_Draft(
- $this->_imap,
- $this->_user,
- $this->_version
- );
- $draft->setDraftMessage($message);
+ case Horde_ActiveSync::CLASS_NOTES:
+ if (!$id) {
+ try {
+ $id = $this->_connector->notes_import($message, $server_id);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = ['mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1];
+ } else {
+ try {
+ $this->_connector->notes_replace($id, $message);
+ } catch (Horde_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $this->_endBuffer();
+ return false;
+ }
+ $stat = $this->_smartStatMessage($folderid, $id, false);
+ }
+ break;
- // Do we need an existing Draft message?
- if ($id && !empty($message->airsyncbaseattachments)) {
- $draft->getExistingDraftMessage($draft_folder, $id);
+ default:
+ if ($message instanceof Horde_ActiveSync_Message_Mail) {
+ $stat = [
+ 'id' => $id,
+ 'mod' => 0,
+ 'flags' => [],
+ 'categories' => false,
+ ];
+
+ // Check for draft sync.
+ if ($this->_version >= Horde_ActiveSync::VERSION_SIXTEEN &&
+ $folderid == $this->getSpecialFolderNameByType(self::SPECIAL_DRAFTS)) {
+
+ // @todo Does this only happen on drafts?
+ if ($message->send) {
+ $this->_logger->err('NOT YET SUPPORTED.');
+ return $stat;
}
- // Append the message and return results.
- $results = $draft->append($draft_folder);
- $stat['id'] = $results['uid'];
- $stat['atchash'] = $results['atchash'];
- $stat['conversationid'] = bin2hex($message->subject);
- $stat['conversationindex'] = time();
+ // Are we addding/changing a draft email?
+ if ($message->airsyncbasebody) {
+ $draft_folder = $this->getSpecialFolderNameByType(
+ self::SPECIAL_DRAFTS
+ );
+ $draft = new Horde_Core_ActiveSync_Mail_Draft(
+ $this->_imap,
+ $this->_user,
+ $this->_version
+ );
+ $draft->setDraftMessage($message);
- return $stat;
- }
- }
+ // Do we need an existing Draft message?
+ if ($id && !empty($message->airsyncbaseattachments)) {
+ $draft->getExistingDraftMessage($draft_folder, $id);
+ }
- if ($message->read !== '') {
- $this->setReadFlag($folderid, $id, $message->read);
- $stat['flags'] = array_merge(
- $stat['flags'],
- array('read' => $message->read)
- );
+ // Append the message and return results.
+ $results = $draft->append($draft_folder);
+ $stat['id'] = $results['uid'];
+ $stat['atchash'] = $results['atchash'];
+ $stat['conversationid'] = bin2hex($message->subject);
+ $stat['conversationindex'] = time();
- // Do RFC 3798 MDN checks. If $message->read is being set to
- // FLAG_READ_SEEN, then we *might* be able to send one.
- if ($message->read == Horde_ActiveSync_Message_Mail::FLAG_READ_SEEN) {
- $this->_logger->meta('Checking for MDN');
- $mdn = new Horde_Core_ActiveSync_Mdn(
- $folderid, $id, $this->_imap, $this->_connector
+ return $stat;
+ }
+ }
+
+ if ($message->read !== '') {
+ $this->setReadFlag($folderid, $id, $message->read);
+ $stat['flags'] = array_merge(
+ $stat['flags'],
+ ['read' => $message->read]
);
- if ($mdn->mdnCheck()) {
- $this->_logger->meta('Sending MDN');
+
+ // Do RFC 3798 MDN checks. If $message->read is being set to
+ // FLAG_READ_SEEN, then we *might* be able to send one.
+ if ($message->read == Horde_ActiveSync_Message_Mail::FLAG_READ_SEEN) {
+ $this->_logger->meta('Checking for MDN');
+ $mdn = new Horde_Core_ActiveSync_Mdn(
+ $folderid,
+ $id,
+ $this->_imap,
+ $this->_connector
+ );
+ if ($mdn->mdnCheck()) {
+ $this->_logger->meta('Sending MDN');
+ }
}
}
- }
- if ($message->propertyExists('flag')) {
- if (!$message->flag) {
- $message->flag = Horde_ActiveSync::messageFactory('Flag');
+ if ($message->propertyExists('flag')) {
+ if (!$message->flag) {
+ $message->flag = Horde_ActiveSync::messageFactory('Flag');
+ }
+ $this->_imap->setMessageFlag($folderid, $id, $message->flag);
+ $stat['flags'] = array_merge(
+ $stat['flags'],
+ ['flagged' => $message->flag->flagstatus]
+ );
}
- $this->_imap->setMessageFlag($folderid, $id, $message->flag);
- $stat['flags'] = array_merge(
- $stat['flags'],
- array('flagged' => $message->flag->flagstatus)
- );
- }
- if ($message->propertyExists('categories') &&
- $message->categories) {
- // We *try* to make sure the category is added as a custom
- // IMAP flag. This might fail in some edge cases, like e.g.
- // with non-ascii characters.
- $this->_connector->mail_ensureMessageFlags($message->categories);
- $this->_imap->categoriesToFlags($folderid, $message->categories, $id);
- $stat['categories'] = $message->categories;
+ if ($message->propertyExists('categories') &&
+ $message->categories) {
+ // We *try* to make sure the category is added as a custom
+ // IMAP flag. This might fail in some edge cases, like e.g.
+ // with non-ascii characters.
+ $this->_connector->mail_ensureMessageFlags($message->categories);
+ $this->_imap->categoriesToFlags($folderid, $message->categories, $id);
+ $stat['categories'] = $message->categories;
+ }
+ } else {
+ $this->_endBuffer();
+ return false;
}
- } else {
- $this->_endBuffer();
- return false;
- }
}
$this->_endBuffer();
@@ -2159,52 +2233,52 @@ public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $mes
public function getSearchResults($type, array $query)
{
switch (Horde_String::lower($type)) {
- case 'gal':
- return $this->_searchGal($query);
- case 'mailbox':
- if (!empty($this->_cache)) {
- $clear_cache = !empty($query['rebuildresults']);
- unset($query['rebuildresults']);
- $cache_key = $GLOBALS['registry']->getAuth() . ':HCASD:' . hash('md5', serialize($query));
- if ($clear_cache) {
- $this->_cache->expire($cache_key);
+ case 'gal':
+ return $this->_searchGal($query);
+ case 'mailbox':
+ if (!empty($this->_cache)) {
+ $clear_cache = !empty($query['rebuildresults']);
+ unset($query['rebuildresults']);
+ $cache_key = $GLOBALS['registry']->getAuth() . ':HCASD:' . hash('md5', serialize($query));
+ if ($clear_cache) {
+ $this->_cache->expire($cache_key);
+ }
}
- }
- if (!empty($this->_cache) && $this->_cache->exists($cache_key, 0)) {
- $results = json_decode($this->_cache->get($cache_key, 0), true);
- } else {
- try {
- $results = $this->_searchMailbox($query);
- if (!empty($this->_cache)) {
- $this->_cache->set($cache_key, json_encode($results));
+ if (!empty($this->_cache) && $this->_cache->exists($cache_key, 0)) {
+ $results = json_decode($this->_cache->get($cache_key, 0), true);
+ } else {
+ try {
+ $results = $this->_searchMailbox($query);
+ if (!empty($this->_cache)) {
+ $this->_cache->set($cache_key, json_encode($results));
+ }
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_logger->err($e->getMessage());
+ $results = [];
}
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err($e->getMessage());
- $results = array();
}
- }
- $count = count($results);
- if (!empty($query['range'])) {
- $range = explode('-', $query['range']);
- $results = array_slice($results, $range[0], $range[1] - $range[0] + 1);
- }
- return array(
- 'rows' => $results,
- 'total' => $count,
- 'status' => Horde_ActiveSync_Request_Search::STORE_STATUS_SUCCESS);
+ $count = count($results);
+ if (!empty($query['range'])) {
+ $range = explode('-', $query['range']);
+ $results = array_slice($results, $range[0], $range[1] - $range[0] + 1);
+ }
+ return [
+ 'rows' => $results,
+ 'total' => $count,
+ 'status' => Horde_ActiveSync_Request_Search::STORE_STATUS_SUCCESS];
- case 'documentlibrary':
- foreach ($query['query'][0] as $q) {
- if (!empty($q['DocumentLibrary:LinkId'])) {
- $results = $this->_connector->files_browse($q['DocumentLibrary:LinkId']);
+ case 'documentlibrary':
+ foreach ($query['query'][0] as $q) {
+ if (!empty($q['DocumentLibrary:LinkId'])) {
+ $results = $this->_connector->files_browse($q['DocumentLibrary:LinkId']);
+ }
}
- }
- return array(
- 'rows' => $results,
- 'total' => count($results),
- 'status' => Horde_ActiveSync_Request_Search::STORE_STATUS_SUCCESS
- );
+ return [
+ 'rows' => $results,
+ 'total' => count($results),
+ 'status' => Horde_ActiveSync_Request_Search::STORE_STATUS_SUCCESS,
+ ];
}
}
@@ -2229,14 +2303,18 @@ public function getSearchResults($type, array $query)
* @throws Horde_ActiveSync_Exception
*/
public function sendMail(
- $rfc822, $forward = false, $reply = false, $parent = false, $save = true,
- Horde_ActiveSync_Message_SendMail $message = null)
- {
+ $rfc822,
+ $forward = false,
+ $reply = false,
+ $parent = false,
+ $save = true,
+ ?Horde_ActiveSync_Message_SendMail $message = null
+ ) {
// Ignore if we do not support email operations.
// @TODO: This assumes the only way to not have an imap object is
// if we turn off email support. We should probably make this a flag.
if (empty($this->_imap)) {
- $this->_logger->notice("No IMAP object. Ignoring.");
+ $this->_logger->notice('No IMAP object. Ignoring.');
return true;
}
@@ -2257,7 +2335,7 @@ public function sendMail(
if ($forward || $reply) {
$source = $message->source;
if ($source->longid) {
- list($folderid, $itemid) = explode(':', $source, 2);
+ [$folderid, $itemid] = explode(':', $source, 2);
} elseif ($forward === true || $reply === true) {
$folderid = $source->folderid;
$itemid = $source->itemid;
@@ -2269,7 +2347,7 @@ public function sendMail(
if (!empty($message) && !empty($message->forwardees)) {
$fowardees = $message->forwardees;
} else {
- $forwardees = array();
+ $forwardees = [];
}
$mailer->setForward($folderid, $itemid, $forwardees);
} elseif (!empty($forward)) {
@@ -2289,15 +2367,19 @@ public function sendMail(
try {
$mailer->send();
- $this->_logger->meta(sprintf(
- 'Message-ID: \'%s\' successfully sent.',
- $mailer->headers['Message-ID'])
+ $this->_logger->meta(
+ sprintf(
+ 'Message-ID: \'%s\' successfully sent.',
+ $mailer->headers['Message-ID']
+ )
);
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
- $this->_logger->err(sprintf(
- 'Message headers: %s',
- $mailer->headers->toString())
+ $this->_logger->err(
+ sprintf(
+ 'Message headers: %s',
+ $mailer->headers->toString()
+ )
);
$this->_endBuffer();
throw $e;
@@ -2306,21 +2388,25 @@ public function sendMail(
if ($save) {
$sf = $this->getSpecialFolderNameByType(self::SPECIAL_SENT);
if (!empty($sf)) {
- $this->_logger->meta(sprintf(
- 'Preparing to copy Message-ID: \'%s\' to \'%s\'.',
- $mailer->headers['Message-ID'],
- $sf)
+ $this->_logger->meta(
+ sprintf(
+ 'Preparing to copy Message-ID: \'%s\' to \'%s\'.',
+ $mailer->headers['Message-ID'],
+ $sf
+ )
);
- $flags = array(Horde_Imap_Client::FLAG_SEEN);
+ $flags = [Horde_Imap_Client::FLAG_SEEN];
// Ignore issues sending to sent, in case the folder isn't
// available.
try {
$this->_imap->appendMessage($sf, $mailer->getSentMail(), $flags);
- $this->_logger->meta(sprintf(
- 'Message-ID: \'%s\' appended to \'%s\'.',
- $mailer->headers['Message-ID'],
- $sf)
+ $this->_logger->meta(
+ sprintf(
+ 'Message-ID: \'%s\' appended to \'%s\'.',
+ $mailer->headers['Message-ID'],
+ $sf
+ )
);
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
@@ -2330,11 +2416,13 @@ public function sendMail(
// Attempt to write forward/reply state.
if ($this->_version > Horde_ActiveSync::VERSION_TWELVEONE && $mailer->id) {
- $this->_logger->meta(sprintf(
- 'Logging LASTVERBEXECUTED to Maillog: %s, %s, %s',
- $mailer->reply ? 'reply' : 'forward',
- $mailer->imapMessage->getHeaders()->getValue('Message-ID'),
- $mailer->headers->getValue('To'))
+ $this->_logger->meta(
+ sprintf(
+ 'Logging LASTVERBEXECUTED to Maillog: %s, %s, %s',
+ $mailer->reply ? 'reply' : 'forward',
+ $mailer->imapMessage->getHeaders()->getValue('Message-ID'),
+ $mailer->headers->getValue('To')
+ )
);
$this->_connector->mail_logMaillog(
$mailer->reply ? 'reply' : 'forward',
@@ -2358,7 +2446,10 @@ public function sendMail(
: ($mailer->forward ? 'forward' : 'new');
try {
$this->_connector->mail_logRecipient(
- $action, $mailer->headers->getValue('To'), $mailer->headers->getValue('Message-ID'));
+ $action,
+ $mailer->headers->getValue('To'),
+ $mailer->headers->getValue('Message-ID')
+ );
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
}
@@ -2417,10 +2508,10 @@ public function statMailMessage($folderid, $id)
// I can't think of a time when we would actually need to hit the
// server. As long as 'mod' is 0, this should be fine as we don't
// track flag conflicts.
- return array(
+ return [
'id' => $id,
'mod' => 0,
- 'flags' => false);
+ 'flags' => false];
}
/**
@@ -2442,23 +2533,25 @@ public function getCurrentPolicy($device = false)
*
* @return mixed The value of the provisiong support flag.
*/
- public function getProvisioning(Horde_ActiveSync_Device $device = null)
+ public function getProvisioning(?Horde_ActiveSync_Device $device = null)
{
if (!empty($device)) {
try {
$hooks = $GLOBALS['injector']->getInstance('Horde_Core_Hooks');
- $result = $hooks->callHook('activesync_provisioning_check', 'horde', array($device, $this->_user));
+ $result = $hooks->callHook('activesync_provisioning_check', 'horde', [$device, $this->_user]);
if ($result !== -1) {
return $result;
}
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
}
$provisioning = $GLOBALS['injector']
->getInstance('Horde_Perms')
->getPermissions(
'horde:activesync:provisioning',
- $this->_user);
+ $this->_user
+ );
return $this->_getPolicyValue('provisioning', $provisioning);
}
@@ -2491,74 +2584,74 @@ public function getSettings(array $settings, $device)
{
global $injector, $prefs, $registry;
- $res = array();
+ $res = [];
foreach ($settings as $key => $setting) {
switch ($key) {
- case 'oof':
- if (!$vacation = $this->_connector->filters_getVacation()) {
- $res['oof'] = array(
+ case 'oof':
+ if (!$vacation = $this->_connector->filters_getVacation()) {
+ $res['oof'] = [
+ 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
+ 'oofstate' => Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED,
+ 'oofmsgs' => [],
+ ];
+ break;
+ }
+ $res['oof'] = [
'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
- 'oofstate' => Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED,
- 'oofmsgs' => array()
- );
+ 'oofstate' => ($vacation['disabled']
+ ? Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED
+ : Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED),
+ 'oofmsgs' => [],
+ ];
+ // If we have start/end it's a timebased vacation in EAS-speak.
+ if (!empty($vacation['end']) && !$vacation['disabled']) {
+ $res['oof']['oofstate'] = Horde_ActiveSync_Request_Settings::OOF_STATE_TIMEBASED;
+ $res['oof']['starttime'] = new Horde_Date($vacation['start']);
+ $res['oof']['endtime'] = new Horde_Date($vacation['end']);
+ }
+ // Horde's filter API doesn't support internal/external so
+ // always send as internal since that's what most clients
+ // fall back to as well.
+ $res['oof']['oofmsgs'][] = [
+ 'appliesto' => Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL,
+ 'replymessage' => $vacation['reason'],
+ 'enabled' => !$vacation['disabled'],
+ 'bodytype' => $setting['bodytype'],
+ 'subject' => $vacation['subject'],
+ ];
break;
- }
- $res['oof'] = array(
- 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
- 'oofstate' => ($vacation['disabled']
- ? Horde_ActiveSync_Request_Settings::OOF_STATE_DISABLED
- : Horde_ActiveSync_Request_Settings::OOF_STATE_ENABLED),
- 'oofmsgs' => array()
- );
- // If we have start/end it's a timebased vacation in EAS-speak.
- if (!empty($vacation['end']) && !$vacation['disabled']) {
- $res['oof']['oofstate'] = Horde_ActiveSync_Request_Settings::OOF_STATE_TIMEBASED;
- $res['oof']['starttime'] = new Horde_Date($vacation['start']);
- $res['oof']['endtime'] = new Horde_Date($vacation['end']);
- }
- // Horde's filter API doesn't support internal/external so
- // always send as internal since that's what most clients
- // fall back to as well.
- $res['oof']['oofmsgs'][] = array(
- 'appliesto' => Horde_ActiveSync_Request_Settings::SETTINGS_APPLIESTOINTERNAL,
- 'replymessage' => $vacation['reason'],
- 'enabled' => !$vacation['disabled'],
- 'bodytype' => $setting['bodytype'],
- 'subject' => $vacation['subject'],
- );
- break;
- case 'userinformation':
- $identities = $injector
- ->getInstance('Horde_Core_Factory_Identity')
- ->create($registry->getAuth());
- $as_ident = $prefs->getValue('activesync_identity');
- if ($as_ident != 'horde') {
- $identities->setDefault($prefs->getValue('activesync_identity'));
- } else {
- $as_ident = $identities->getDefault();
- }
- $default_email = $identities->getValue('from_addr');
- $email_addresses = array($default_email);
- $accounts = array();
- if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEENONE) {
- $identity = $identities->get();
- $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : array();
- $emails[] = $identity['from_addr'];
- $accounts[] = array('fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id']);
- foreach ($identities as $id => $identity) {
- if ($id != $as_ident) {
- $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : array();
- $emails[] = $identity['from_addr'];
- $accounts[] = array('fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id'], 'id' => $id);
+ case 'userinformation':
+ $identities = $injector
+ ->getInstance('Horde_Core_Factory_Identity')
+ ->create($registry->getAuth());
+ $as_ident = $prefs->getValue('activesync_identity');
+ if ($as_ident != 'horde') {
+ $identities->setDefault($prefs->getValue('activesync_identity'));
+ } else {
+ $as_ident = $identities->getDefault();
+ }
+ $default_email = $identities->getValue('from_addr');
+ $email_addresses = [$default_email];
+ $accounts = [];
+ if ($this->_version >= Horde_ActiveSync::VERSION_FOURTEENONE) {
+ $identity = $identities->get();
+ $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : [];
+ $emails[] = $identity['from_addr'];
+ $accounts[] = ['fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id']];
+ foreach ($identities as $id => $identity) {
+ if ($id != $as_ident) {
+ $emails = !empty($identity['alias_addr']) ? $identity['alias_addr'] : [];
+ $emails[] = $identity['from_addr'];
+ $accounts[] = ['fullname' => $identity['fullname'], 'emailaddresses' => array_reverse($emails), 'accountname' => $identity['id'], 'id' => $id];
+ }
}
}
- }
- $res['userinformation'] = array(
- 'emailaddresses' => $email_addresses,
- 'primarysmtpaddress' => $default_email,
- 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
- 'accounts' => $accounts
- );
+ $res['userinformation'] = [
+ 'emailaddresses' => $email_addresses,
+ 'primarysmtpaddress' => $default_email,
+ 'status' => Horde_ActiveSync_Request_Settings::STATUS_SUCCESS,
+ 'accounts' => $accounts,
+ ];
}
}
@@ -2578,17 +2671,17 @@ public function getSettings(array $settings, $device)
*/
public function setSettings(array $settings, $device)
{
- $res = array();
+ $res = [];
foreach ($settings as $key => $setting) {
switch ($key) {
- case 'oof':
- try {
- $this->_connector->filters_setVacation($setting);
- $res['oof'] = Horde_ActiveSync_Request_Settings::STATUS_SUCCESS;
- } catch (Horde_Exception $e) {
- $res['oof'] = Horde_ActiveSync_Request_Settings::STATUS_ERROR;
- }
- break;
+ case 'oof':
+ try {
+ $this->_connector->filters_setVacation($setting);
+ $res['oof'] = Horde_ActiveSync_Request_Settings::STATUS_SUCCESS;
+ } catch (Horde_Exception $e) {
+ $res['oof'] = Horde_ActiveSync_Request_Settings::STATUS_ERROR;
+ }
+ break;
}
}
@@ -2609,7 +2702,7 @@ public function setSettings(array $settings, $device)
* ActiveSync server will use to build the response, or
* the raw XML response contained in the raw_xml key.
*/
- public function autoDiscover($params = array(), $version = 1)
+ public function autoDiscover($params = [], $version = 1)
{
$hooks = $GLOBALS['injector']->getInstance('Horde_Core_Hooks');
$url = parse_url((string)Horde::url(null, true));
@@ -2617,7 +2710,7 @@ public function autoDiscover($params = array(), $version = 1)
if ($version == 2) {
if (Horde_String::lower($params['protocol']) == 'autodiscoverv1') {
$params['url'] = $url['scheme'] . '://' . $url['host'] . '/Autodiscover/Autodiscover.xml';
- } else if (Horde_String::lower($params['protocol']) == 'activesync') {
+ } elseif (Horde_String::lower($params['protocol']) == 'activesync') {
$params['url'] = $url['scheme'] . '://' . $url['host'] . '/Microsoft-Server-ActiveSync';
}
return $params;
@@ -2634,9 +2727,10 @@ public function autoDiscover($params = array(), $version = 1)
$params['culture'] = 'en:en';
$params['username'] = $this->getUsernameFromEmail($params['email']);
try {
- $xml = $hooks->callHook('activesync_autodiscover_xml', 'horde', array($params));
- return array('raw_xml' => $xml);
- } catch (Horde_Exception_HookNotSet $e) {}
+ $xml = $hooks->callHook('activesync_autodiscover_xml', 'horde', [$params]);
+ return ['raw_xml' => $xml];
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
// Bring in the host configuration if needed.
if (!empty($GLOBALS['conf']['activesync']['outlookdiscovery'])) {
@@ -2659,8 +2753,9 @@ public function autoDiscover($params = array(), $version = 1)
}
try {
- $params = $hooks->callHook('activesync_autodiscover_parameters', 'horde', array($params));
- } catch (Horde_Exception_HookNotSet $e) {}
+ $params = $hooks->callHook('activesync_autodiscover_parameters', 'horde', [$params]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
return $params;
}
@@ -2676,23 +2771,24 @@ public function autoDiscover($params = array(), $version = 1)
public function getUsernameFromEmail($email)
{
switch ($GLOBALS['conf']['activesync']['autodiscovery']) {
- case 'full':
- return $email;
- case 'user':
- if (strpos($email, '@') !== false) {
- return substr($email, 0, strpos($email, '@'));
- } else {
+ case 'full':
return $email;
- }
- case 'hook':
- try {
- return $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook('activesync_get_autodiscover_username', 'horde', array($email));
- } catch (Horde_Exception_HookNotSet $e) {
+ case 'user':
+ if (strpos($email, '@') !== false) {
+ return substr($email, 0, strpos($email, '@'));
+ } else {
+ return $email;
+ }
+ // no break
+ case 'hook':
+ try {
+ return $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
+ ->callHook('activesync_get_autodiscover_username', 'horde', [$email]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ return $email;
+ }
+ default:
return $email;
- }
- default:
- return $email;
}
}
@@ -2726,9 +2822,9 @@ public function getUsernameFromEmail($email)
* - availability: (string) A EAS style FB string.
* - picture: (Horde_ActiveSync_Message_ResolveRecipientsPicture)
*/
- public function resolveRecipient($type, $search, array $opts = array())
+ public function resolveRecipient($type, $search, array $opts = [])
{
- $return = array();
+ $return = [];
if ($type == 'certificate') {
$results = $this->_connector->resolveRecipient($search, $opts);
@@ -2739,7 +2835,8 @@ public function resolveRecipient($type, $search, array $opts = array())
foreach ($results[$search] as $result) {
if (!empty($opts['pictures'])) {
$picture = new Horde_ActiveSync_Message_ResolveRecipientsPicture(
- array('protocolversion' => $this->_version, 'logger' => $this->_logger));
+ ['protocolversion' => $this->_version, 'logger' => $this->_logger]
+ );
if (empty($result['photo'])) {
$picture->status = Horde_ActiveSync_Status::NO_PICTURE;
} elseif (!empty($opts['maxpictures']) &&
@@ -2754,24 +2851,24 @@ public function resolveRecipient($type, $search, array $opts = array())
++$picture_count;
}
}
- $entry = array(
+ $entry = [
'displayname' => $result['name'],
'emailaddress' => $result['email'],
- 'entries' => !empty($result['smimePublicKey']) ? array($this->_mungeCert($result['smimePublicKey'])) : array(),
+ 'entries' => !empty($result['smimePublicKey']) ? [$this->_mungeCert($result['smimePublicKey'])] : [],
'type' => $result['source'] == $gal ? Horde_ActiveSync::RESOLVE_RESULT_GAL : Horde_ActiveSync::RESOLVE_RESULT_ADDRESSBOOK,
- 'picture' => !empty($picture) ? $picture : null
- );
+ 'picture' => !empty($picture) ? $picture : null,
+ ];
$return[] = $entry;
}
}
} else {
- $options = array(
+ $options = [
'maxcerts' => 0,
'maxambiguous' => $opts['maxambiguous'],
'maxsize' => !empty($opts['maxsize']) ? $opts['maxsize'] : null,
'maxpictures' => !empty($opts['maxpictures']) ? $opts['maxpictures'] : null,
- 'pictures' => !empty($opts['pictures'])
- );
+ 'pictures' => !empty($opts['pictures']),
+ ];
$entry = current($this->resolveRecipient('certificate', $search, $options));
// These are empty if we do not have a AVAILABILITY request.
@@ -2939,14 +3036,14 @@ public function meetingResponse(array $response)
$cn = $ident->getValue('fullname');
$email = $ident->getValue('from_addr');
switch ($response['response']) {
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_ACCEPTED:
- $itip_response = 'ACCEPTED';
- break;
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_TENTATIVE:
- $itip_response = 'TENTATIVE';
- break;
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_DECLINED:
- $itip_response = 'DECLINED';
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_ACCEPTED:
+ $itip_response = 'ACCEPTED';
+ break;
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_TENTATIVE:
+ $itip_response = 'TENTATIVE';
+ break;
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_DECLINED:
+ $itip_response = 'DECLINED';
}
$vEvent->updateAttendee($email, $itip_response);
@@ -2968,13 +3065,13 @@ public function meetingResponse(array $response)
$comment = Horde_Text_Filter::filter(
$comment,
'Html2text',
- array('charset' => 'UTF-8', 'nestingLimit' => 1000)
+ ['charset' => 'UTF-8', 'nestingLimit' => 1000]
);
}
} else {
$comment = '';
}
- // Start building the iTip response email.
+ // Start building the iTip response email.
try {
$organizer = parse_url($vEvent->getAttribute('ORGANIZER'));
$organizer = $organizer['path'];
@@ -2986,7 +3083,7 @@ public function meetingResponse(array $response)
$ident = $injector->getInstance('Horde_Core_Factory_Identity')
->create($event->creator);
if (!$ident->getValue('from_addr')) {
- throw new Horde_ActiveSync_Exception(_("You do not have an email address configured in your Personal Information Preferences."));
+ throw new Horde_ActiveSync_Exception(_('You do not have an email address configured in your Personal Information Preferences.'));
}
$resource = new Horde_Itip_Resource_Identity(
$ident,
@@ -2994,21 +3091,21 @@ public function meetingResponse(array $response)
(string)$ident->getFromAddress()
);
switch ($response['response']) {
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_ACCEPTED:
- $type = new Horde_Itip_Response_Type_Accept($resource, $comment);
- break;
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_DECLINED:
- $type = new Horde_Itip_Response_Type_Decline($resource, $comment);
- break;
- case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_TENTATIVE:
- $type = new Horde_Itip_Response_Type_Tentative($resource, $comment);
- break;
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_ACCEPTED:
+ $type = new Horde_Itip_Response_Type_Accept($resource, $comment);
+ break;
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_DECLINED:
+ $type = new Horde_Itip_Response_Type_Decline($resource, $comment);
+ break;
+ case Horde_ActiveSync_Request_MeetingResponse::RESPONSE_TENTATIVE:
+ $type = new Horde_Itip_Response_Type_Tentative($resource, $comment);
+ break;
}
try {
// Send the reply.
Horde_Itip::factory($vEvent, $resource)->sendMultiPartResponse(
$type,
- new Horde_Core_Itip_Response_Options_Horde('UTF-8', array()),
+ new Horde_Core_Itip_Response_Options_Horde('UTF-8', []),
$injector->getInstance('Horde_Mail')
);
$this->_logger->meta('Reply sent.');
@@ -3022,7 +3119,7 @@ public function meetingResponse(array $response)
// Failure to remove it from the server will result in an inconsistent
// sync state.
try {
- $this->_imap->deleteMessages(array($response['requestid']), $response['folderid']);
+ $this->_imap->deleteMessages([$response['requestid']], $response['folderid']);
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
}
@@ -3052,14 +3149,16 @@ public function createDeviceCallback(Horde_ActiveSync_Device $device)
$this->_logger->meta(sprintf(
'Maximum number of devices of %d reached for %s.',
$max_devices,
- $registry->getAuth()));
+ $registry->getAuth()
+ ));
return Horde_ActiveSync_Status::MAXIMUM_DEVICES_REACHED;
}
}
try {
return $injector->getInstance('Horde_Core_Hooks')
- ->callHook('activesync_create_device', 'horde', array($device));
- } catch (Horde_Exception_HookNotSet $e) {}
+ ->callHook('activesync_create_device', 'horde', [$device]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
return true;
}
@@ -3078,8 +3177,9 @@ public function deviceCallback(Horde_ActiveSync_Device $device)
{
try {
return $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook('activesync_device_check', 'horde', array($device));
- } catch (Horde_Exception_HookNotSet $e) {}
+ ->callHook('activesync_device_check', 'horde', [$device]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
return true;
}
@@ -3096,12 +3196,13 @@ public function modifyDeviceCallback(Horde_ActiveSync_Device $device)
{
try {
$device = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook('activesync_device_modify', 'horde', array($device));
+ ->callHook('activesync_device_modify', 'horde', [$device]);
if (!($device instanceof Horde_ActiveSync_Device)) {
$this->_logger->err('activesync_device_modify hook must return device object.');
throw new Exception();
}
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
return $device;
}
@@ -3112,7 +3213,7 @@ public function modifyDeviceCallback(Horde_ActiveSync_Device $device)
* @deprecated Will be removed in H6 - this is provided via
* self::resolveRecipients().
*/
- public function getFreebusy($user, array $options = array())
+ public function getFreebusy($user, array $options = [])
{
throw new Horde_ActiveSync_Exception('Not supported');
}
@@ -3131,9 +3232,12 @@ public function getFreebusy($user, array $options = array())
*/
public function getSyncStamp($collection, $last = null)
{
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::getSyncStamp(%s, %d);',
- $collection, $last)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::getSyncStamp(%s, %d);',
+ $collection,
+ $last
+ )
);
// For FolderSync (empty $collection) or Email collections, we don't care.
@@ -3150,7 +3254,7 @@ public function getSyncStamp($collection, $last = null)
$id = null;
}
- if (!in_array($class, array(Horde_ActiveSync::CLASS_CALENDAR, Horde_ActiveSync::CLASS_NOTES, Horde_ActiveSync::CLASS_CONTACTS, Horde_ActiveSync::CLASS_TASKS))) {
+ if (!in_array($class, [Horde_ActiveSync::CLASS_CALENDAR, Horde_ActiveSync::CLASS_NOTES, Horde_ActiveSync::CLASS_CONTACTS, Horde_ActiveSync::CLASS_TASKS])) {
return time();
}
@@ -3181,11 +3285,11 @@ public function setDevice(Horde_ActiveSync_Device $device)
{
parent::setDevice($device);
// @todo remove is_callable for Horde 6(?)
- if (!empty($this->_imap) && is_callable(array($this->_imap, 'setOptions'))) {
- $options = array(
+ if (!empty($this->_imap) && is_callable([$this->_imap, 'setOptions'])) {
+ $options = [
Horde_ActiveSync_Imap_Message::OPTIONS_DECODE_TNEF =>
- !$this->_device->hasQuirk(Horde_ActiveSync_Device::QUIRK_SUPPORTS_TNEF)
- );
+ !$this->_device->hasQuirk(Horde_ActiveSync_Device::QUIRK_SUPPORTS_TNEF),
+ ];
$this->_imap->setOptions($options);
}
}
@@ -3224,10 +3328,12 @@ protected function _buildNonMailFolder($id, $parent, $type, $name)
protected function _smartStatMessage($folderid, $id, $hint)
{
ob_start();
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::_smartStatMessage(%s, %s)',
- $folderid,
- $id)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::_smartStatMessage(%s, %s)',
+ $folderid,
+ $id
+ )
);
$statKey = $folderid . $id;
$mod = false;
@@ -3240,63 +3346,63 @@ protected function _smartStatMessage($folderid, $id, $hint)
// and pass the folderid.
// First, see if we are using a multiplexed id.
switch ($folderid) {
- case self::APPOINTMENTS_FOLDER_UID:
- $mod = $this->_connector->calendar_getActionTimestamp($id, 'modify');
- break;
-
- case self::CONTACTS_FOLDER_UID:
- $mod = $this->_connector->contacts_getActionTimestamp($id, 'modify');
- break;
-
- case self::TASKS_FOLDER_UID:
- $mod = $this->_connector->tasks_getActionTimestamp($id, 'modify');
- break;
-
- case self::NOTES_FOLDER_UID:
- $mod = $this->_connector->notes_getActionTimestamp($id, 'modify');
- break;
- default:
- // Not using non-email multiplexed collection.
- $folder_parts = $this->_parseFolderId($folderid);
- if (count($folder_parts) == 2) {
- $folder_class = $folder_parts[self::FOLDER_PART_CLASS];
- $serverid = $folder_parts[self::FOLDER_PART_ID];
- } else {
- $folder_class = false;
- $serverid = null;
- }
- switch ($folder_class) {
- case Horde_ActiveSync::CLASS_CALENDAR:
- $mod = $this->_connector->calendar_getActionTimestamp($id, 'modify', $serverid);
+ case self::APPOINTMENTS_FOLDER_UID:
+ $mod = $this->_connector->calendar_getActionTimestamp($id, 'modify');
break;
- case Horde_ActiveSync::CLASS_CONTACTS:
- $mod = $this->_connector->contacts_getActionTimestamp($id, 'modify', $serverid);
+
+ case self::CONTACTS_FOLDER_UID:
+ $mod = $this->_connector->contacts_getActionTimestamp($id, 'modify');
break;
- case Horde_ActiveSync::CLASS_TASKS:
- $mod = $this->_connector->tasks_getActionTimestamp($id, 'modify', $serverid);
+
+ case self::TASKS_FOLDER_UID:
+ $mod = $this->_connector->tasks_getActionTimestamp($id, 'modify');
break;
- case Horde_ActiveSync::CLASS_NOTES:
- $mod = $this->_connector->notes_getActionTimestamp($id, 'modify', $serverid);
+
+ case self::NOTES_FOLDER_UID:
+ $mod = $this->_connector->notes_getActionTimestamp($id, 'modify');
break;
default:
- try {
- return $this->statMailMessage($folderid, $id);
- } catch (Horde_ActiveSync_Exception $e) {
- $this->_endBuffer();
- return false;
+ // Not using non-email multiplexed collection.
+ $folder_parts = $this->_parseFolderId($folderid);
+ if (count($folder_parts) == 2) {
+ $folder_class = $folder_parts[self::FOLDER_PART_CLASS];
+ $serverid = $folder_parts[self::FOLDER_PART_ID];
+ } else {
+ $folder_class = false;
+ $serverid = null;
}
+ switch ($folder_class) {
+ case Horde_ActiveSync::CLASS_CALENDAR:
+ $mod = $this->_connector->calendar_getActionTimestamp($id, 'modify', $serverid);
+ break;
+ case Horde_ActiveSync::CLASS_CONTACTS:
+ $mod = $this->_connector->contacts_getActionTimestamp($id, 'modify', $serverid);
+ break;
+ case Horde_ActiveSync::CLASS_TASKS:
+ $mod = $this->_connector->tasks_getActionTimestamp($id, 'modify', $serverid);
+ break;
+ case Horde_ActiveSync::CLASS_NOTES:
+ $mod = $this->_connector->notes_getActionTimestamp($id, 'modify', $serverid);
+ break;
+ default:
+ try {
+ return $this->statMailMessage($folderid, $id);
+ } catch (Horde_ActiveSync_Exception $e) {
+ $this->_endBuffer();
+ return false;
+ }
- }
+ }
}
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
$this->_endBuffer();
- return array('id' => '', 'mod' => 0, 'flags' => 1);
+ return ['id' => '', 'mod' => 0, 'flags' => 1];
}
$this->_modCache[$statKey] = $mod;
}
- $message = array();
+ $message = [];
$message['id'] = $id;
$message['mod'] = $mod;
$message['flags'] = 1;
@@ -3305,29 +3411,31 @@ protected function _smartStatMessage($folderid, $id, $hint)
return $message;
}
- /**
- * Return the list of mail server folders.
- *
- * @return array An array of Horde_ActiveSync_Message_Folder objects.
- */
+ /**
+ * Return the list of mail server folders.
+ *
+ * @return array An array of Horde_ActiveSync_Message_Folder objects.
+ */
protected function _getMailFolders()
{
if (empty($this->_mailFolders)) {
if (empty($this->_imap)) {
- $this->_mailFolders = array($this->_buildDummyFolder(self::SPECIAL_INBOX));
+ $this->_mailFolders = [$this->_buildDummyFolder(self::SPECIAL_INBOX)];
$this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_TRASH);
$this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_SENT);
$this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_DRAFTS);
$this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_OUTBOX);
} else {
$this->_logger->meta('Polling Horde_Core_ActiveSync_Driver::_getMailFolders()');
- $folders = array();
+ $folders = [];
try {
$imap_folders = $this->_imap->getMailboxes(true);
} catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err(sprintf(
- 'Problem loading mail folders from IMAP server: %s',
- $e->getMessage())
+ $this->_logger->err(
+ sprintf(
+ 'Problem loading mail folders from IMAP server: %s',
+ $e->getMessage()
+ )
);
throw $e;
}
@@ -3343,8 +3451,11 @@ protected function _getMailFolders()
$folders[] = $this->_getMailFolder((string)$id, $imap_folders, $folder);
++$cnt;
} catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err(sprintf(
- 'Problem retrieving %s mail folder', $id)
+ $this->_logger->err(
+ sprintf(
+ 'Problem retrieving %s mail folder',
+ $id
+ )
);
}
}
@@ -3367,31 +3478,31 @@ protected function _buildDummyFolder($id)
$folder = new Horde_ActiveSync_Message_Folder();
$folder->parentid = '0';
switch ($id) {
- case self::SPECIAL_TRASH:
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
- $folder->serverid = $folder->_serverid = 'Trash';
- $folder->displayname = Horde_Core_Translation::t("Trash");
- break;
- case self::SPECIAL_SENT:
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
- $folder->serverid = $folder->_serverid = 'Sent';
- $folder->displayname = Horde_Core_Translation::t("Sent");
- break;
- case self::SPECIAL_INBOX:
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_INBOX;
- $folder->serverid = $folder->_serverid = 'INBOX';
- $folder->displayname = Horde_Core_Translation::t("Inbox");
- break;
- case self::SPECIAL_DRAFTS:
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
- $folder->serverid = $folder->_serverid = 'DRAFTS';
- $folder->displayname = Horde_Core_Translation::t("Drafts");
- break;
- case self::SPECIAL_OUTBOX:
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_OUTBOX;
- $folder->serverid = $folder->_serverid = 'OUTBOX';
- $folder->displayname = Horde_Core_Translation::t("Outbox");
- break;
+ case self::SPECIAL_TRASH:
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
+ $folder->serverid = $folder->_serverid = 'Trash';
+ $folder->displayname = Horde_Core_Translation::t('Trash');
+ break;
+ case self::SPECIAL_SENT:
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
+ $folder->serverid = $folder->_serverid = 'Sent';
+ $folder->displayname = Horde_Core_Translation::t('Sent');
+ break;
+ case self::SPECIAL_INBOX:
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_INBOX;
+ $folder->serverid = $folder->_serverid = 'INBOX';
+ $folder->displayname = Horde_Core_Translation::t('Inbox');
+ break;
+ case self::SPECIAL_DRAFTS:
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
+ $folder->serverid = $folder->_serverid = 'DRAFTS';
+ $folder->displayname = Horde_Core_Translation::t('Drafts');
+ break;
+ case self::SPECIAL_OUTBOX:
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_OUTBOX;
+ $folder->serverid = $folder->_serverid = 'OUTBOX';
+ $folder->displayname = Horde_Core_Translation::t('Outbox');
+ break;
}
return $folder;
@@ -3437,9 +3548,11 @@ protected function _getMailFolder($sid, array $fl, array $f)
try {
$specialFolders = $this->_imap->getSpecialMailboxes();
} catch (Horde_ActiveSync_Exception $e) {
- $this->_logger->err(sprintf(
- 'Problem retrieving special folders: %s',
- $e->getMessage())
+ $this->_logger->err(
+ sprintf(
+ 'Problem retrieving special folders: %s',
+ $e->getMessage()
+ )
);
throw $e;
}
@@ -3447,33 +3560,33 @@ protected function _getMailFolder($sid, array $fl, array $f)
// Check for known, supported special folders.
foreach ($specialFolders as $key => $value) {
if (!is_array($value)) {
- $value = array($value);
+ $value = [$value];
}
foreach ($value as $mailbox) {
if (!is_null($mailbox)) {
switch ($key) {
- case self::SPECIAL_SENT:
- if ($sid == $mailbox->value) {
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
- $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
- return $folder;
- }
- break;
- case self::SPECIAL_TRASH:
- if ($sid == $mailbox->value) {
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
- $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
- return $folder;
- }
- break;
+ case self::SPECIAL_SENT:
+ if ($sid == $mailbox->value) {
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
+ $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
+ return $folder;
+ }
+ break;
+ case self::SPECIAL_TRASH:
+ if ($sid == $mailbox->value) {
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
+ $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
+ return $folder;
+ }
+ break;
- case self::SPECIAL_DRAFTS:
- if ($sid == $mailbox->value) {
- $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
- $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
- return $folder;
- }
- break;
+ case self::SPECIAL_DRAFTS:
+ if ($sid == $mailbox->value) {
+ $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
+ $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
+ return $folder;
+ }
+ break;
}
}
}
@@ -3508,23 +3621,24 @@ protected function _searchMailbox(array $query)
protected function _searchGal(array $query)
{
ob_start();
- $return = array(
- 'rows' => array(),
+ $return = [
+ 'rows' => [],
'status' => Horde_ActiveSync_Request_Search::STORE_STATUS_SUCCESS,
- 'total' => 0
- );
+ 'total' => 0,
+ ];
// If no perms to the GAL, return zero results.
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->exists('horde:activesync:no_gal') &&
$perms->getPermissions('horde:activesync:no_gal', $this->_user)) {
- return $return;
+ return $return;
}
try {
$results = $this->_connector->contacts_search(
$query['query'],
- array('pictures' => !empty($query[Horde_ActiveSync_Request_Search::SEARCH_PICTURE])));
+ ['pictures' => !empty($query[Horde_ActiveSync_Request_Search::SEARCH_PICTURE])]
+ );
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e);
$this->_endBuffer();
@@ -3539,8 +3653,11 @@ protected function _searchGal(array $query)
return $return;
}
$return['total'] = $count;
- $this->_logger->meta(sprintf(
- 'Horde_Core_ActiveSync_Driver::_searchGal() found %d matches.', $count)
+ $this->_logger->meta(
+ sprintf(
+ 'Horde_Core_ActiveSync_Driver::_searchGal() found %d matches.',
+ $count
+ )
);
if (!empty($query['range'])) {
@@ -3560,7 +3677,7 @@ protected function _searchGal(array $query)
continue;
}
- $entry = array(
+ $entry = [
Horde_ActiveSync::GAL_ALIAS => !empty($row['alias']) ? $row['alias'] : '',
Horde_ActiveSync::GAL_DISPLAYNAME => $row['name'],
Horde_ActiveSync::GAL_EMAILADDRESS => !empty($row['email']) ? $row['email'] : '',
@@ -3572,7 +3689,7 @@ protected function _searchGal(array $query)
Horde_ActiveSync::GAL_MOBILEPHONE => !empty($row['cellPhone']) ? $row['cellPhone'] : '',
Horde_ActiveSync::GAL_TITLE => !empty($row['title']) ? $row['title'] : '',
Horde_ActiveSync::GAL_OFFICE => !empty($row['office']) ? $row['office'] : '',
- );
+ ];
if (!empty($query[Horde_ActiveSync_Request_Search::SEARCH_PICTURE])) {
$picture = Horde_ActiveSync::messageFactory('GalPicture');
if (empty($row['photo'])) {
@@ -3617,8 +3734,8 @@ protected function _endBuffer()
*/
protected function _mungeCert($cert)
{
- $cert = str_replace("-----BEGIN CERTIFICATE-----", '', $cert);
- $cert = str_replace("-----END CERTIFICATE-----", '', $cert);
+ $cert = str_replace('-----BEGIN CERTIFICATE-----', '', $cert);
+ $cert = str_replace('-----END CERTIFICATE-----', '', $cert);
$cert = str_replace("\r\n", '', $cert);
return $cert;
@@ -3635,7 +3752,7 @@ protected function _mungeCert($cert)
protected function _getPolicyFromPerms($deviceinfo = false)
{
$prefix = 'horde:activesync:provisioning:';
- $policy = array();
+ $policy = [];
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if (!$perms->exists('horde:activesync:provisioning')) {
return $policy;
@@ -3657,41 +3774,41 @@ protected function _getPolicyValue($policy, $allowed)
{
if (is_array($allowed)) {
switch ($policy) {
- case 'activesync':
- case 'max_devices':
- case Horde_ActiveSync_Policies::POLICY_ATC:
- case Horde_ActiveSync_Policies::POLICY_PIN:
- case Horde_ActiveSync_Policies::POLICY_COMPLEXITY:
- case Horde_ActiveSync_Policies::POLICY_MAXFAILEDATTEMPTS:
- case Horde_ActiveSync_Policies::POLICY_CODEFREQ:
- case Horde_ActiveSync_Policies::POLICY_AEFVALUE:
- case Horde_ActiveSync_Policies::POLICY_MAXATCSIZE:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_SDCARD:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_CAMERA:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_SMS:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_WIFI:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_BLUETOOTH:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_POPIMAP:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_BROWSER:
- case Horde_ActiveSync_Policies::POLICY_ALLOW_HTML:
- case Horde_ActiveSync_Policies::POLICY_MAX_EMAIL_AGE:
- case Horde_ActiveSync_Policies::POLICY_DEVICE_ENCRYPTION:
- case Horde_ActiveSync_Policies::POLICY_ENCRYPTION:
- $allowed = max($allowed);
- break;
- case Horde_ActiveSync_Policies::POLICY_MINLENGTH:
- case Horde_ActiveSync_Policies::POLICY_ROAMING_NOPUSH:
- $allowed = min($allowed);
- break;
- case 'provisioning':
- if (array_search('false', $allowed) !== false) {
- $allowed = Horde_ActiveSync::PROVISIONING_NONE;
- } elseif (array_search('allow', $allowed) !== false) {
- $allowed = Horde_ActiveSync::PROVISIONING_LOOSE;
- } elseif (array_search('true', $allowed) !== false) {
- $allowed = Horde_ActiveSync::PROVISIONING_FORCE;
- }
- break;
+ case 'activesync':
+ case 'max_devices':
+ case Horde_ActiveSync_Policies::POLICY_ATC:
+ case Horde_ActiveSync_Policies::POLICY_PIN:
+ case Horde_ActiveSync_Policies::POLICY_COMPLEXITY:
+ case Horde_ActiveSync_Policies::POLICY_MAXFAILEDATTEMPTS:
+ case Horde_ActiveSync_Policies::POLICY_CODEFREQ:
+ case Horde_ActiveSync_Policies::POLICY_AEFVALUE:
+ case Horde_ActiveSync_Policies::POLICY_MAXATCSIZE:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_SDCARD:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_CAMERA:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_SMS:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_WIFI:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_BLUETOOTH:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_POPIMAP:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_BROWSER:
+ case Horde_ActiveSync_Policies::POLICY_ALLOW_HTML:
+ case Horde_ActiveSync_Policies::POLICY_MAX_EMAIL_AGE:
+ case Horde_ActiveSync_Policies::POLICY_DEVICE_ENCRYPTION:
+ case Horde_ActiveSync_Policies::POLICY_ENCRYPTION:
+ $allowed = max($allowed);
+ break;
+ case Horde_ActiveSync_Policies::POLICY_MINLENGTH:
+ case Horde_ActiveSync_Policies::POLICY_ROAMING_NOPUSH:
+ $allowed = min($allowed);
+ break;
+ case 'provisioning':
+ if (array_search('false', $allowed) !== false) {
+ $allowed = Horde_ActiveSync::PROVISIONING_NONE;
+ } elseif (array_search('allow', $allowed) !== false) {
+ $allowed = Horde_ActiveSync::PROVISIONING_LOOSE;
+ } elseif (array_search('true', $allowed) !== false) {
+ $allowed = Horde_ActiveSync::PROVISIONING_FORCE;
+ }
+ break;
}
}
@@ -3739,8 +3856,8 @@ protected function _getMaillogChanges(Horde_ActiveSync_Folder_Imap $folder, $ts)
}
$changes = $this->_connector->mail_getMaillogChanges($ts);
- $flags = array();
- $s_changes = array();
+ $flags = [];
+ $s_changes = [];
foreach ($changes as $mid) {
try {
$uid = $this->_imap->getUidFromMid($mid, $folder);
@@ -3754,15 +3871,15 @@ protected function _getMaillogChanges(Horde_ActiveSync_Folder_Imap $folder, $ts)
$verb = $this->_getLastVerb($mid);
if (!empty($verb)) {
switch ($verb['action']) {
- case 'reply':
- case 'reply_list':
- $flags[$uid] = array(Horde_ActiveSync::CHANGE_REPLY_STATE => $verb['ts']);
- break;
- case 'reply_all':
- $flags[$uid] = array(Horde_ActiveSync::CHANGE_REPLYALL_STATE => $verb['ts']);
- break;
- case 'forward':
- $flags[$uid] = array(Horde_ActiveSync::CHANGE_FORWARD_STATE => $verb['ts']);
+ case 'reply':
+ case 'reply_list':
+ $flags[$uid] = [Horde_ActiveSync::CHANGE_REPLY_STATE => $verb['ts']];
+ break;
+ case 'reply_all':
+ $flags[$uid] = [Horde_ActiveSync::CHANGE_REPLYALL_STATE => $verb['ts']];
+ break;
+ case 'forward':
+ $flags[$uid] = [Horde_ActiveSync::CHANGE_FORWARD_STATE => $verb['ts']];
}
}
}
@@ -3784,7 +3901,7 @@ protected function _getLastVerb($mid)
{
if (!array_key_exists($mid, $this->_verbs)) {
$log = $this->_connector->mail_getMaillog($mid);
- $last = array();
+ $last = [];
foreach ($log as $entry) {
if (empty($last) || $last['ts'] < $entry['ts']) {
$last = $entry;
diff --git a/lib/Horde/Core/ActiveSync/Imap/Factory.php b/lib/Horde/Core/ActiveSync/Imap/Factory.php
index d09231d22..ca5e014e6 100644
--- a/lib/Horde/Core/ActiveSync/Imap/Factory.php
+++ b/lib/Horde/Core/ActiveSync/Imap/Factory.php
@@ -1,4 +1,5 @@
mail->mailboxList(array('reload' => true, 'unsub' => !$subscriptions)) as $mbox) {
+ foreach ($registry->mail->mailboxList(['reload' => true, 'unsub' => !$subscriptions]) as $mbox) {
if (isset($mbox['subscribed'])) {
/* IMP 7. Guaranteed that return will match what was
* asked for in 'unsub' argument. */
@@ -85,7 +86,8 @@ public function getMailboxes($force = false)
} catch (Horde_Exception $e) {
Horde::log(sprintf(
'Error retrieving mailbox list: %s',
- $e->getMessage()), 'ERR');
+ $e->getMessage()
+ ), 'ERR');
throw new Horde_ActiveSync_Exception($e);
}
}
@@ -93,9 +95,10 @@ public function getMailboxes($force = false)
$this->_mailboxlist = $injector->getInstance('Horde_Core_Hooks')->callHook(
'activesync_mailboxlist',
'horde',
- array($this->_mailboxlist)
+ [$this->_mailboxlist]
);
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
return $this->_mailboxlist;
}
@@ -116,7 +119,8 @@ public function getSpecialMailboxes()
} catch (Horde_Exception $e) {
Horde::log(sprintf(
'Error retrieving specialmailbox list: %s',
- $e->getMessage()), 'ERR');
+ $e->getMessage()
+ ), 'ERR');
throw new Horde_ActiveSync_Exception($e);
}
@@ -143,25 +147,25 @@ public function getMsgFlags()
{
global $registry;
- $msgFlags = array();
+ $msgFlags = [];
$flags = unserialize($registry->horde->getPreference($registry->hasInterface('mail'), 'msgflags'));
// Remove any system flags, as these should never be user (un)set.
- $system_flags = array(
+ $system_flags = [
Horde_Imap_Client::FLAG_ANSWERED,
Horde_Imap_Client::FLAG_DELETED,
Horde_Imap_Client::FLAG_DRAFT,
Horde_Imap_Client::FLAG_FLAGGED,
Horde_Imap_Client::FLAG_RECENT,
- Horde_Imap_Client::FLAG_SEEN
- );
+ Horde_Imap_Client::FLAG_SEEN,
+ ];
foreach ($system_flags as $flag) {
unset($flags[$flag]);
}
foreach ($flags as $flag) {
if ($flag->imapflag) {
- $msgFlags[Horde_String::lower($flag->imapflag)] = $flag->label;
+ $msgFlags[Horde_String::lower($flag->imapflag)] = $flag->label;
}
}
diff --git a/lib/Horde/Core/ActiveSync/Logger/Factory.php b/lib/Horde/Core/ActiveSync/Logger/Factory.php
index 59bc62ef7..1cd741c27 100644
--- a/lib/Horde/Core/ActiveSync/Logger/Factory.php
+++ b/lib/Horde/Core/ActiveSync/Logger/Factory.php
@@ -1,4 +1,5 @@
- * @package Core
- */
+/**
+* Horde_Core_ActiveSync_Logger_Factory:: Implements a factory/builder for
+* providing a Horde_Log_Logger object correctly configured for the
+* debug settings and the device properties.
+*
+* @license http://www.horde.org/licenses/gpl GPLv2
+* @copyright 2010-2017 Horde LLC (http://www.horde.org/)
+* @author Michael J Rubinsky
+* @package Core
+*/
class Horde_Core_ActiveSync_Logger_Factory implements Horde_ActiveSync_Interface_LoggerFactory
{
-
/**
* Factory for a log object. Attempts to create a device specific file if
* custom logging is requested.
@@ -33,53 +33,55 @@ class Horde_Core_ActiveSync_Logger_Factory implements Horde_ActiveSync_Interface
*
* @return Horde_Log_Logger The logger object, correctly configured.
*/
- public function create($properties = array())
+ public function create($properties = [])
{
global $conf;
$logger = false;
switch ($conf['activesync']['logging']['type']) {
- case 'onefile':
- if (empty($properties['DeviceId'])) {
- $properties['DeviceId'] = 'UNKNOWN';
- }
- $device_id = Horde_String::upper($properties['DeviceId']);
- $format = "%timestamp% $device_id %levelName%: %message%" . PHP_EOL;
- $formatter = new Horde_Log_Formatter_Simple(array('format' => $format));
- $stream = fopen($conf['activesync']['logging']['path'], 'a');
- if ($stream) {
- $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream($stream, false, $formatter));
- }
- break;
- case 'perdevice':
- if (!empty($properties['DeviceId'])) {
- $stream = fopen($conf['activesync']['logging']['path'] . '/' . Horde_String::upper($properties['DeviceId']) . '.txt', 'a');
+ case 'onefile':
+ if (empty($properties['DeviceId'])) {
+ $properties['DeviceId'] = 'UNKNOWN';
+ }
+ $device_id = Horde_String::upper($properties['DeviceId']);
+ $format = "%timestamp% $device_id %levelName%: %message%" . PHP_EOL;
+ $formatter = new Horde_Log_Formatter_Simple(['format' => $format]);
+ $stream = fopen($conf['activesync']['logging']['path'], 'a');
if ($stream) {
- $formatter = new Horde_ActiveSync_Log_Formatter();
- $logger = new Horde_ActiveSync_Log_Logger(new Horde_ActiveSync_Log_Handler($stream, false, $formatter));
+ $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream($stream, false, $formatter));
}
- }
- break;
- case 'perrequest':
- if (!empty($properties['DeviceId'])) {
- $dir = sprintf('%s/%s',
- $conf['activesync']['logging']['path'],
- Horde_String::upper($properties['DeviceId'])
- );
- if (!is_dir($dir)) {
- mkdir($dir, 0755, true);
+ break;
+ case 'perdevice':
+ if (!empty($properties['DeviceId'])) {
+ $stream = fopen($conf['activesync']['logging']['path'] . '/' . Horde_String::upper($properties['DeviceId']) . '.txt', 'a');
+ if ($stream) {
+ $formatter = new Horde_ActiveSync_Log_Formatter();
+ $logger = new Horde_ActiveSync_Log_Logger(new Horde_ActiveSync_Log_Handler($stream, false, $formatter));
+ }
}
- $path = sprintf('%s/%s-%s-%s.txt',
- $dir,
- time(),
- getmypid(),
- (!empty($properties['Cmd']) ? $properties['Cmd'] : 'UnknownCmd')
- );
- $stream = fopen($path, 'a');
- if ($stream) {
- $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream($stream));
+ break;
+ case 'perrequest':
+ if (!empty($properties['DeviceId'])) {
+ $dir = sprintf(
+ '%s/%s',
+ $conf['activesync']['logging']['path'],
+ Horde_String::upper($properties['DeviceId'])
+ );
+ if (!is_dir($dir)) {
+ mkdir($dir, 0o755, true);
+ }
+ $path = sprintf(
+ '%s/%s-%s-%s.txt',
+ $dir,
+ time(),
+ getmypid(),
+ (!empty($properties['Cmd']) ? $properties['Cmd'] : 'UnknownCmd')
+ );
+ $stream = fopen($path, 'a');
+ if ($stream) {
+ $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream($stream));
+ }
}
- }
}
if (!$logger) {
$logger = new Horde_Log_Logger(new Horde_Log_Handler_Null());
diff --git a/lib/Horde/Core/ActiveSync/Mail.php b/lib/Horde/Core/ActiveSync/Mail.php
index 23ff952f5..21a992b80 100644
--- a/lib/Horde/Core/ActiveSync/Mail.php
+++ b/lib/Horde/Core/ActiveSync/Mail.php
@@ -1,4 +1,5 @@
';
+ public const HTML_BLOCKQUOTE = '';
/**
* The headers used when sending the email.
@@ -131,7 +132,7 @@ class Horde_Core_ActiveSync_Mail
* @var array
* @since 2.31.0
*/
- protected $_forwardees = array();
+ protected $_forwardees = [];
/**
* Const'r
@@ -141,8 +142,10 @@ class Horde_Core_ActiveSync_Mail
* @param integer $eas_version EAS version in use.
*/
public function __construct(
- Horde_ActiveSync_Imap_Adapter $imap, $user, $eas_version)
- {
+ Horde_ActiveSync_Imap_Adapter $imap,
+ $user,
+ $eas_version
+ ) {
$this->_imap = $imap;
$this->_user = $user;
$this->_version = $eas_version;
@@ -151,19 +154,19 @@ public function __construct(
public function &__get($property)
{
switch ($property) {
- case 'imapMessage':
- if (!isset($this->_imapMessage)) {
- $this->_getImapMessage();
- }
- return $this->_imapMessage;
- case 'replacemime':
- case 'id':
- case 'reply':
- case 'forward':
- case 'headers':
- case 'parentFolder':
- $property = '_' . $property;
- return $this->$property;
+ case 'imapMessage':
+ if (!isset($this->_imapMessage)) {
+ $this->_getImapMessage();
+ }
+ return $this->_imapMessage;
+ case 'replacemime':
+ case 'id':
+ case 'reply':
+ case 'forward':
+ case 'headers':
+ case 'parentFolder':
+ $property = '_' . $property;
+ return $this->$property;
}
}
@@ -210,7 +213,7 @@ public function setRawMessage(Horde_ActiveSync_Rfc822 $raw)
* message.
* @throws Horde_ActiveSync_Exception
*/
- public function setForward($parent, $id, $params = array())
+ public function setForward($parent, $id, $params = [])
{
if (!empty($this->_reply)) {
throw new Horde_ActiveSync_Exception('Cannot set both Forward and Reply.');
@@ -262,14 +265,14 @@ public function send()
protected function _callPreSendHook()
{
$hooks = $GLOBALS['injector']->getInstance('Horde_Core_Hooks');
- $params = array(
+ $params = [
'raw' => $this->_raw,
'imap_msg' => $this->imapMessage,
'parent' => $this->_parentFolder,
'reply' => $this->_reply,
- 'forward' => $this->_forward);
+ 'forward' => $this->_forward];
try {
- if (!$result = $hooks->callHook('activesync_email_presend', 'horde', array($params))) {
+ if (!$result = $hooks->callHook('activesync_email_presend', 'horde', [$params])) {
throw new Horde_ActiveSync_Exception('There was an issue running the activesync_email_presend hook.');
}
if ($result instanceof Horde_ActiveSync_Mime) {
@@ -289,8 +292,8 @@ public function getSentMail()
if (!empty($this->_mailer)) {
return $this->_mailer->getRaw();
}
- $stream = new Horde_Stream_Temp(array('max_memory' => 262144));
- $stream->add($this->_headers->toString(array('charset' => 'UTF-8')) . $this->_raw->getMessage(), true);
+ $stream = new Horde_Stream_Temp(['max_memory' => 262144]);
+ $stream->add($this->_headers->toString(['charset' => 'UTF-8']) . $this->_raw->getMessage(), true);
return $stream;
}
@@ -302,7 +305,7 @@ public function getSentMail()
protected function _sendRaw()
{
$recipients = '';
- $h_array = $this->_headers->toArray(array('charset' => 'UTF-8'));
+ $h_array = $this->_headers->toArray(['charset' => 'UTF-8']);
if (!empty($h_array['To'])) {
$recipients = $h_array['To'];
}
@@ -400,15 +403,16 @@ protected function _sendSmart()
*/
protected function _buildSmartReply()
{
- $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
+ $mail = new Horde_Mime_Mail($this->_headers->toArray(['charset' => 'UTF-8']));
$base_part = $this->imapMessage->getStructure();
$plain_id = $base_part->findBody('plain');
$html_id = $base_part->findBody('html');
try {
- $body_data = $this->imapMessage->getMessageBodyData(array(
+ $body_data = $this->imapMessage->getMessageBodyData(
+ [
'protocolversion' => $this->_version,
- 'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true))
+ 'bodyprefs' => [Horde_ActiveSync::BODYPREF_TYPE_MIME => true]]
);
} catch (Horde_Exception_NotFound $e) {
throw new Horde_ActiveSync_Exception($e->getMessage());
@@ -451,15 +455,15 @@ protected function _buildSmartForward()
// Forwarded message
$rfc822Stream = $this->imapMessage->getFullMsg(true);
$rfc822Part = new Horde_Mime_Part();
- $rfc822Part->setType("message/rfc822");
+ $rfc822Part->setType('message/rfc822');
$rfc822Part->setContents($rfc822Stream);
- $rfc822Part->setName(Horde_Core_Translation::t("Forwarded Message"));
+ $rfc822Part->setName(Horde_Core_Translation::t('Forwarded Message'));
// Incoming message to append to forward.
$mime_message = $this->_raw->getMimeObject();
// Outgoing message
- $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
+ $mail = new Horde_Mime_Mail($this->_headers->toArray(['charset' => 'UTF-8']));
$mail->setBody($this->_getSmartPlainText($mime_message));
$mail->setHtmlBody($this->_getSmartHtmlText($mime_message));
@@ -487,8 +491,11 @@ protected function _buildSmartForward()
* @return string The plaintext part of the email message that is being sent.
*/
protected function _getPlainPart(
- $plain_id, Horde_Mime_Part $mime_message, array $body_data, Horde_Mime_Part $base_part)
- {
+ $plain_id,
+ Horde_Mime_Part $mime_message,
+ array $body_data,
+ Horde_Mime_Part $base_part
+ ) {
$smart_text = $this->_getSmartPlainText($mime_message);
if ($this->_forward) {
return $smart_text . $this->_forwardText($body_data, $base_part->getPart($plain_id));
@@ -516,7 +523,8 @@ protected function _getSmartPlainText(Horde_Mime_Part $mime_message)
} else {
$smart_text = Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($id)->getContents(),
- $mime_message->getCharset());
+ $mime_message->getCharset()
+ );
}
return $smart_text;
@@ -557,11 +565,14 @@ protected function _getSmartHtmlText(Horde_Mime_Part $mime_message)
$smart_text = self::text2html(
Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($mime_message->findBody('plain'))->getContents(),
- $mime_message->getCharset()));
+ $mime_message->getCharset()
+ )
+ );
} else {
$smart_text = Horde_ActiveSync_Utils::ensureUtf8(
$mime_message->getPart($id)->getContents(),
- $mime_message->getCharset());
+ $mime_message->getCharset()
+ );
}
return $smart_text;
@@ -577,7 +588,7 @@ protected function _getImapMessage()
if (empty($this->_id) || empty($this->_parentFolder)) {
return;
}
- $this->_imapMessage = array_pop($this->_imap->getImapMessage($this->_parentFolder, $this->_id, array('headers' => true)));
+ $this->_imapMessage = array_pop($this->_imap->getImapMessage($this->_parentFolder, $this->_id, ['headers' => true]));
if (empty($this->_imapMessage)) {
throw new Horde_Exception_NotFound('The forwarded/replied message was not found.');
}
@@ -661,7 +672,7 @@ protected function _replyText(array $body_data, Horde_Mime_Part $part, $html = f
return self::HTML_BLOCKQUOTE . $msg . '
';
}
return empty($msg)
- ? '[' . Horde_Core_Translation::t("No message body text") . ']'
+ ? '[' . Horde_Core_Translation::t('No message body text') . ']'
: $msg;
}
@@ -718,7 +729,7 @@ protected function _tidyHtml($html)
return Horde_Text_Filter::filter(
$html,
'Cleanhtml',
- array('body_only' => true)
+ ['body_only' => true]
);
} else {
// If no tidy, use Horde_Dom.
@@ -739,15 +750,15 @@ public static function text2html($msg)
return Horde_Text_Filter::filter(
$msg,
'Text2html',
- array(
+ [
'flowed' => self::HTML_BLOCKQUOTE,
- 'parselevel' => Horde_Text_Filter_Text2html::MICRO)
+ 'parselevel' => Horde_Text_Filter_Text2html::MICRO]
);
}
public static function html2text($msg)
{
- return Horde_Text_Filter::filter($msg, 'Html2text', array('nestingLimit' => 1000));
+ return Horde_Text_Filter::filter($msg, 'Html2text', ['nestingLimit' => 1000]);
}
}
diff --git a/lib/Horde/Core/ActiveSync/Mail/Draft.php b/lib/Horde/Core/ActiveSync/Mail/Draft.php
index 3ad0f6480..9b53246a9 100644
--- a/lib/Horde/Core/ActiveSync/Mail/Draft.php
+++ b/lib/Horde/Core/ActiveSync/Mail/Draft.php
@@ -1,4 +1,5 @@
addPart($this->_textPart);
// Add Mime headers
- $base->addMimeHeaders(array(
- 'headers' => $this->_headers)
+ $base->addMimeHeaders(
+ [
+ 'headers' => $this->_headers]
);
foreach ($this->_atcAdd as $atc) {
@@ -106,15 +108,15 @@ public function append($folderid)
$atc_map[$atc->displayname] = $atc->clientid;
}
- $stream = $base->toString(array(
+ $stream = $base->toString([
'stream' => true,
- 'headers' => $this->_headers->toString()
- ));
+ 'headers' => $this->_headers->toString(),
+ ]);
$new_uid = $this->_imap->appendMessage(
$folderid,
$stream,
- array('\draft', '\seen')
+ ['\draft', '\seen']
);
foreach ($base as $part) {
@@ -127,13 +129,13 @@ public function append($folderid)
// If we pulled down an existing Draft, delete it now since the
// new one will replace it.
if (!empty($this->_imapMessage)) {
- $this->_imap->deleteMessages(array($this->_draftUid), $folderid);
+ $this->_imap->deleteMessages([$this->_draftUid], $folderid);
}
- return array(
+ return [
'uid' => $new_uid,
- 'atchash' => $atc_hash
- );
+ 'atchash' => $atc_hash,
+ ];
}
/**
@@ -192,16 +194,16 @@ protected function _handleAttachments()
// New attachments
foreach ($this->_draftMessage->airsyncbaseattachments as $atc) {
switch (get_class($atc)) {
- case 'Horde_ActiveSync_Message_AirSyncBaseAdd':
- $atc_mime = new Horde_Mime_Part();
- $atc_mime->setType($atc->contenttype);
- $atc_mime->setName($atc->displayname);
- $atc_mime->setContents($atc->content);
- $this->_atcAdd[] = $atc_mime;
- break;
- case 'Horde_ActiveSync_Message_AirSyncBaseDelete':
- list($mailbox, $uid, $part) = explode(':', $atc->filereference, 3);
- $this->_atcDelete[] = $part;
+ case 'Horde_ActiveSync_Message_AirSyncBaseAdd':
+ $atc_mime = new Horde_Mime_Part();
+ $atc_mime->setType($atc->contenttype);
+ $atc_mime->setName($atc->displayname);
+ $atc_mime->setContents($atc->content);
+ $this->_atcAdd[] = $atc_mime;
+ break;
+ case 'Horde_ActiveSync_Message_AirSyncBaseDelete':
+ [$mailbox, $uid, $part] = explode(':', $atc->filereference, 3);
+ $this->_atcDelete[] = $part;
}
}
}
@@ -217,15 +219,18 @@ protected function _handleAttachments()
*/
public function getExistingDraftMessage($folderid, $uid)
{
- $imap_msg = $this->_imap->getImapMessage($folderid,$uid);
+ $imap_msg = $this->_imap->getImapMessage($folderid, $uid);
if (empty($imap_msg[$uid])) {
- throw new Horde_ActiveSync_Exception(sprintf(
- 'Unable to fetch %d from %s.',
- $uid, $folderid)
+ throw new Horde_ActiveSync_Exception(
+ sprintf(
+ 'Unable to fetch %d from %s.',
+ $uid,
+ $folderid
+ )
);
}
$this->_imapMessage = $imap_msg[$uid];
$this->_draftUid = $uid;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Horde/Core/ActiveSync/Mdn.php b/lib/Horde/Core/ActiveSync/Mdn.php
index 0e80d7ab6..59075311a 100644
--- a/lib/Horde/Core/ActiveSync/Mdn.php
+++ b/lib/Horde/Core/ActiveSync/Mdn.php
@@ -1,4 +1,5 @@
_imap = $imap;
$this->_mailbox = $mailbox;
$this->_uid = $uid;
@@ -50,15 +53,15 @@ public function __construct(
public function __call($method, $args)
{
switch ($method) {
- case 'headers':
- if (empty($this->_msg)) {
- return false;
- }
- return $this->_msg->getHeaders();
- case 'mailbox':
- return $this->_mailbox;
- case 'uid':
- return $this->_uid;
+ case 'headers':
+ if (empty($this->_msg)) {
+ return false;
+ }
+ return $this->_msg->getHeaders();
+ case 'mailbox':
+ return $this->_mailbox;
+ case 'uid':
+ return $this->_uid;
}
}
@@ -84,7 +87,7 @@ public function mdnCheck()
*/
protected function _msgCheck()
{
- $msgs = $this->_imap->getImapMessage($this->_mailbox, $this->_uid, array('headers' => true));
+ $msgs = $this->_imap->getImapMessage($this->_mailbox, $this->_uid, ['headers' => true]);
if (!count($msgs)) {
return false;
}
@@ -115,4 +118,4 @@ protected function _sysCheck()
return true;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Horde/Core/Ajax/Application.php b/lib/Horde/Core/Ajax/Application.php
index 0d228dc9e..cc0041f0a 100644
--- a/lib/Horde/Core/Ajax/Application.php
+++ b/lib/Horde/Core/Ajax/Application.php
@@ -1,4 +1,5 @@
_app = $app;
@@ -122,11 +126,11 @@ protected function _init()
public function __get($name)
{
switch ($name) {
- case 'app':
- return $this->_app;
+ case 'app':
+ return $this->_app;
- case 'vars':
- return $this->_vars;
+ case 'vars':
+ return $this->_vars;
}
}
@@ -172,14 +176,14 @@ public function doAction()
/* Look for action in helpers. */
if ($ob = $this->_getHandler()) {
- $this->data = call_user_func(array($ob, $this->_action));
+ $this->data = call_user_func([$ob, $this->_action]);
} else {
/* Look for action in application hook. */
try {
$this->data = $hooks->callHook(
'ajaxaction_handle',
$this->_app,
- array($this, $this->_action)
+ [$this, $this->_action]
);
} catch (Horde_Exception $e) {
/* DEPRECATED hook. @deprecated */
@@ -187,7 +191,7 @@ public function doAction()
$this->data = $hooks->callHook(
'ajaxaction',
$this->_app,
- array($this->_action, $this->_vars)
+ [$this->_action, $this->_vars]
);
} catch (Horde_Exception $e) {
throw new Horde_Exception('Handler for action "' . $this->_action . '" does not exist.');
@@ -199,9 +203,10 @@ public function doAction()
$this->data = $hooks->callHook(
'ajaxaction_data',
$this->_app,
- array($this->_action, $this->data)
+ [$this->_action, $this->data]
);
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
}
/**
@@ -214,7 +219,7 @@ public function doAction()
public function addTask($name, $data, $app = null)
{
if (empty($this->tasks)) {
- $this->tasks = new stdClass;
+ $this->tasks = new stdClass();
}
$name = (is_null($app) ? $this->_app : $app) . ':' . $name;
@@ -254,7 +259,7 @@ public function callAction($action)
{
foreach ($this->_handlers as $ob) {
if ($ob->has($action)) {
- return call_user_func(array($ob, $action));
+ return call_user_func([$ob, $action]);
}
}
}
diff --git a/lib/Horde/Core/Ajax/Application/Handler.php b/lib/Horde/Core/Ajax/Application/Handler.php
index 011a5805c..258f9c054 100644
--- a/lib/Horde/Core/Ajax/Application/Handler.php
+++ b/lib/Horde/Core/Ajax/Application/Handler.php
@@ -1,4 +1,5 @@
_base->vars;
+ case 'vars':
+ return $this->_base->vars;
}
}
diff --git a/lib/Horde/Core/Ajax/Application/Handler/Chunk.php b/lib/Horde/Core/Ajax/Application/Handler/Chunk.php
index 52fa3418c..808a17b4c 100644
--- a/lib/Horde/Core/Ajax/Application/Handler/Chunk.php
+++ b/lib/Horde/Core/Ajax/Application/Handler/Chunk.php
@@ -1,4 +1,5 @@
vars->chunk);
- $result = new stdClass;
+ $result = new stdClass();
if (!empty($chunk)) {
Horde::startBuffer();
try {
diff --git a/lib/Horde/Core/Ajax/Application/Handler/Email.php b/lib/Horde/Core/Ajax/Application/Handler/Email.php
index ab584bdb2..fd269cf41 100644
--- a/lib/Horde/Core/Ajax/Application/Handler/Email.php
+++ b/lib/Horde/Core/Ajax/Application/Handler/Email.php
@@ -1,4 +1,5 @@
vars->email);
if (is_null($ob->mailbox)) {
- throw new Horde_Exception(Horde_Core_Translation::t("No valid email address found"));
+ throw new Horde_Exception(Horde_Core_Translation::t('No valid email address found'));
}
if (is_null($ob->host) && !is_null($this->defaultDomain)) {
$ob->host = $this->defaultDomain;
}
- $ret = new stdClass;
+ $ret = new stdClass();
$ret->email = $ob->bare_address;
return $ret;
diff --git a/lib/Horde/Core/Ajax/Application/Handler/Groups.php b/lib/Horde/Core/Ajax/Application/Handler/Groups.php
index b662a7f5e..3406f4a94 100644
--- a/lib/Horde/Core/Ajax/Application/Handler/Groups.php
+++ b/lib/Horde/Core/Ajax/Application/Handler/Groups.php
@@ -1,4 +1,5 @@
pushApp($this->vars->app);
- $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create($this->vars->imple, array(), true);
+ $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create($this->vars->imple, [], true);
$result = $imple->handle($this->vars);
diff --git a/lib/Horde/Core/Ajax/Application/Handler/Noop.php b/lib/Horde/Core/Ajax/Application/Handler/Noop.php
index 4dc95c9ff..2e3db0dff 100644
--- a/lib/Horde/Core/Ajax/Application/Handler/Noop.php
+++ b/lib/Horde/Core/Ajax/Application/Handler/Noop.php
@@ -1,4 +1,5 @@
$this->getDomId(),
- 'observe' => $this->_observe
- );
+ 'observe' => $this->_observe,
+ ];
$args['params'] = is_array($result)
? array_merge($result, $this->_impleParams())
: $result;
- $page_output->addInlineScript(array(
+ $page_output->addInlineScript([
'HordeImple.add(' .
Horde_Serialize::serialize($args, Horde_Serialize::JSON) .
- ')'
- ), true);
+ ')',
+ ], true);
}
/**
@@ -151,10 +152,10 @@ final public function getImpleUrl()
*/
final protected function _impleParams()
{
- return array(
+ return [
'app' => $GLOBALS['registry']->getApp(),
- 'imple' => get_class($this)
- );
+ 'imple' => get_class($this),
+ ];
}
/**
@@ -165,10 +166,10 @@ final protected function _impleParams()
*/
protected function _jsOnDoAction($js)
{
- $GLOBALS['page_output']->addInlineScript(array(
+ $GLOBALS['page_output']->addInlineScript([
'document.observe("' . get_class($this) . ':do", function(e) {' .
- $js . '});'
- ));
+ $js . '});',
+ ]);
}
/**
@@ -179,10 +180,10 @@ protected function _jsOnDoAction($js)
*/
protected function _jsOnComplete($js)
{
- $GLOBALS['page_output']->addInlineScript(array(
+ $GLOBALS['page_output']->addInlineScript([
'document.observe("' . get_class($this) . ':complete", function(e) {' .
- $js . '});'
- ));
+ $js . '});',
+ ]);
}
/**
diff --git a/lib/Horde/Core/Ajax/Imple/AutoCompleter.php b/lib/Horde/Core/Ajax/Imple/AutoCompleter.php
index 404273de0..a03797a14 100644
--- a/lib/Horde/Core/Ajax/Imple/AutoCompleter.php
+++ b/lib/Horde/Core/Ajax/Imple/AutoCompleter.php
@@ -1,4 +1,5 @@
addScriptPackage('Horde_Core_Script_Package_Autocomplete');
- $page_output->addInlineJsVars(array(
- 'HordeImple.AutoCompleter' => new stdClass
- ));
+ $page_output->addInlineJsVars([
+ 'HordeImple.AutoCompleter' => new stdClass(),
+ ]);
self::$_initAc = true;
}
- $page_output->addInlineScript(array(
- 'HordeImple.AutoCompleter["' . $this->getDomId() . '"]=' . $this->_getAutoCompleter()->generate($this)
- ), true);
+ $page_output->addInlineScript([
+ 'HordeImple.AutoCompleter["' . $this->getDomId() . '"]=' . $this->_getAutoCompleter()->generate($this),
+ ], true);
return false;
}
@@ -56,12 +57,12 @@ protected function _handle(Horde_Variables $vars)
{
// Avoid errors if 'input' isn't set and short-circuit empty searches.
if (!isset($vars->input)) {
- $result = array();
+ $result = [];
} else {
$input = $vars->get($vars->input);
$result = strlen($input)
? $this->_handleAutoCompleter($input)
- : array();
+ : [];
}
return new Horde_Core_Ajax_Response_Prototypejs($result);
diff --git a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Ajax.php b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Ajax.php
index 362be9810..5bf493afb 100644
--- a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Ajax.php
+++ b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Ajax.php
@@ -1,4 +1,5 @@
array(',', ';')
- ), $params));
+ parent::__construct(array_merge([
+ 'tokens' => [',', ';'],
+ ], $params));
}
/**
@@ -50,7 +51,7 @@ public function generate(Horde_Core_Ajax_Imple_AutoCompleter $ac)
return 'new Ajax.Autocompleter(' .
Horde_Serialize::serialize($dom_id, Horde_Serialize::JSON) . ',' .
- Horde_Serialize::serialize(strval($ac->getImpleUrl()->setRaw(true)->add(array('input' => $dom_id))), Horde_Serialize::JSON) . ',' .
+ Horde_Serialize::serialize(strval($ac->getImpleUrl()->setRaw(true)->add(['input' => $dom_id])), Horde_Serialize::JSON) . ',' .
'{' . implode(',', $this->_getOpts($ac)) . '})';
}
@@ -61,7 +62,7 @@ public function generate(Horde_Core_Ajax_Imple_AutoCompleter $ac)
*/
protected function _getOpts(Horde_Core_Ajax_Imple_AutoCompleter $ac)
{
- $opts = array();
+ $opts = [];
if (!isset($this->params['indicator'])) {
$this->params['indicator'] = $ac->getDomId() . '_loading_img';
diff --git a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Base.php b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Base.php
index 658ff78de..c2b5a022b 100644
--- a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Base.php
+++ b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Base.php
@@ -1,4 +1,5 @@
params = $params;
}
@@ -38,6 +39,6 @@ public function __construct(array $params = array())
* @param Horde_Core_Ajax_Imple_AutoCompleter $ac The underlying imple
* object.
*/
- abstract function generate(Horde_Core_Ajax_Imple_AutoCompleter $ac);
+ abstract public function generate(Horde_Core_Ajax_Imple_AutoCompleter $ac);
}
diff --git a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Local.php b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Local.php
index a5102329f..645eb2d43 100644
--- a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Local.php
+++ b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Local.php
@@ -1,4 +1,5 @@
_search = $search;
- parent::__construct(array_merge(array(
+ parent::__construct(array_merge([
'fullSearch' => 1,
'partialSearch' => 1,
'score' => 1,
- 'tokens' => array(',', ';')
- ), $params));
+ 'tokens' => [',', ';'],
+ ], $params));
}
/**
diff --git a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Pretty.php b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Pretty.php
index cb51e4c67..1c2f0cf9a 100644
--- a/lib/Horde/Core/Ajax/Imple/AutoCompleter/Pretty.php
+++ b/lib/Horde/Core/Ajax/Imple/AutoCompleter/Pretty.php
@@ -1,4 +1,5 @@
strval(Horde_Themes::img('delete-small.png')),
- 'triggerContainer' => strval(new Horde_Support_Randomid())
- ), $params)
+ 'triggerContainer' => strval(new Horde_Support_Randomid()),
+ ],
+ $params
+ )
);
- $this->_raw = array_merge($this->_raw, array(
+ $this->_raw = array_merge($this->_raw, [
'displayFilter',
'filterCallback',
'onAdd',
'onRemove',
- 'beforeUpdate'
- ));
+ 'beforeUpdate',
+ ]);
$GLOBALS['page_output']->addScriptFile('prettyautocomplete.js', 'horde');
}
diff --git a/lib/Horde/Core/Ajax/Imple/ContactAutoCompleter.php b/lib/Horde/Core/Ajax/Imple/ContactAutoCompleter.php
index b3bb51ddf..f0697543e 100644
--- a/lib/Horde/Core/Ajax/Imple/ContactAutoCompleter.php
+++ b/lib/Horde/Core/Ajax/Imple/ContactAutoCompleter.php
@@ -1,4 +1,5 @@
'function (v) { return v + ", "; }',
'onType' => 'function (e) { return e.include("<") ? "" : e; }',
- 'tokens' => array(',')
- );
+ 'tokens' => [','],
+ ];
}
/**
*/
protected function _handleAutoCompleter($input)
{
- return array_map('strval', $this->getAddressList($input, array(
- 'levenshtein' => true
- ))->base_addresses);
+ return array_map('strval', $this->getAddressList($input, [
+ 'levenshtein' => true,
+ ])->base_addresses);
}
/**
@@ -64,19 +65,19 @@ protected function _handleAutoCompleter($input)
*
* @return Horde_Mail_Rfc822_List Expand results.
*/
- public function getAddressList($str = '', array $opts = array())
+ public function getAddressList($str = '', array $opts = [])
{
$searchpref = $this->_getAddressbookSearchParams();
try {
- $search = $GLOBALS['registry']->call('contacts/search', array($str, array(
+ $search = $GLOBALS['registry']->call('contacts/search', [$str, [
'fields' => $searchpref->fields,
- 'returnFields' => array('email', 'name'),
+ 'returnFields' => ['email', 'name'],
'rfc822Return' => true,
'sources' => $searchpref->sources,
'count_only' => !empty($opts['count_only']),
- 'emailSearch' => true
- )));
+ 'emailSearch' => true,
+ ]]);
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
return new Horde_Mail_Rfc822_List();
@@ -90,7 +91,7 @@ public function getAddressList($str = '', array $opts = array())
return $search;
}
- $sort_list = array();
+ $sort_list = [];
foreach ($search->base_addresses as $val) {
$sort_list[strval($val)] = @levenshtein($str, $val);
}
diff --git a/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php b/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php
index 32c124dad..88f2bda73 100644
--- a/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php
+++ b/lib/Horde/Core/Ajax/Imple/Geocoder/Geonames.php
@@ -1,4 +1,5 @@
location) {
$url = new Horde_Url('https://secure.geonames.org/searchJSON');
- $url->add(array(
- 'q' => $vars->location
- ));
+ $url->add([
+ 'q' => $vars->location,
+ ]);
} elseif ($vars->lat && $vars->lon) {
$url = new Horde_Url('https://secure.geonames.org/findNearestJSON');
- $url->add(array(
+ $url->add([
'lat' => $vars->lat,
- 'lng' => $vars->lon
- ));
+ 'lng' => $vars->lon,
+ ]);
} else {
throw new Horde_Exception('Incorrect parameters');
}
@@ -54,16 +55,16 @@ protected function _handle(Horde_Variables $vars)
throw new Horde_Exception('Missing required key parameter');
}
- $url->add(array(
- 'username' => $vars->key
- ));
+ $url->add([
+ 'username' => $vars->key,
+ ]);
$response = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create()->get($url);
- return new Horde_Core_Ajax_Response_Prototypejs(array(
+ return new Horde_Core_Ajax_Response_Prototypejs([
'results' => $response->getBody(),
- 'status' => 200
- ));
+ 'status' => 200,
+ ]);
}
}
diff --git a/lib/Horde/Core/Ajax/Imple/InPlaceEditor.php b/lib/Horde/Core/Ajax/Imple/InPlaceEditor.php
index ab1f27c7b..c6f5323a0 100644
--- a/lib/Horde/Core/Ajax/Imple/InPlaceEditor.php
+++ b/lib/Horde/Core/Ajax/Imple/InPlaceEditor.php
@@ -1,4 +1,5 @@
20,
'dataid' => '',
- 'rows' => 2
- ), $params);
+ 'rows' => 2,
+ ], $params);
parent::__construct($params);
}
@@ -43,35 +44,35 @@ protected function _attach($init)
$page_output->addScriptFile('scriptaculous/effects.js', 'horde');
$page_output->addScriptFile('inplaceeditor.js', 'horde');
- $value_url = $this->getImpleUrl()->add(array(
+ $value_url = $this->getImpleUrl()->add([
'id' => $this->_params['dataid'],
- 'input' => 'value'
- ))->setRaw(true);
- $load_url = $value_url->copy()->add(array(
- 'action' => 'load'
- ))->setRaw(true);
- $config = new stdClass;
- $config->config = array(
+ 'input' => 'value',
+ ])->setRaw(true);
+ $load_url = $value_url->copy()->add([
+ 'action' => 'load',
+ ])->setRaw(true);
+ $config = new stdClass();
+ $config->config = [
'cancelClassName' => '',
- 'cancelText' => Horde_Core_Translation::t("Cancel"),
- 'emptyText' => Horde_Core_Translation::t("Click to add caption..."),
- 'okText' => Horde_Core_Translation::t("Ok")
- );
- $config->ids = new stdClass;
- $config->ids->{$this->getDomId()} = array(
+ 'cancelText' => Horde_Core_Translation::t('Cancel'),
+ 'emptyText' => Horde_Core_Translation::t('Click to add caption...'),
+ 'okText' => Horde_Core_Translation::t('Ok'),
+ ];
+ $config->ids = new stdClass();
+ $config->ids->{$this->getDomId()} = [
'load_url' => (string)$load_url,
'rows' => $this->_params['rows'],
- 'value_url' => (string)$value_url
- );
+ 'value_url' => (string)$value_url,
+ ];
if (!empty($this->_params['width'])) {
$config->ids->{$this->getDomId()}['width'] = $this->_params['width'];
}
- $page_output->addInlineJsVars(array(
- 'HordeImple.InPlaceEditor' . $this->getDomId() => $config
- ));
- $page_output->addInlineScript(array(
+ $page_output->addInlineJsVars([
+ 'HordeImple.InPlaceEditor' . $this->getDomId() => $config,
+ ]);
+ $page_output->addInlineScript([
'$H(HordeImple.InPlaceEditor' . $this->getDomId() . '.ids).each(function(pair) {
new InPlaceEditor(pair.key, pair.value.value_url, Object.extend(HordeImple.InPlaceEditor' . $this->getDomId() . '.config, {
htmlResponse: false,
@@ -88,8 +89,8 @@ protected function _attach($init)
rows: pair.value.rows,
autoWidth: true
}));
- })'
- ), true);
+ })',
+ ], true);
}
return false;
diff --git a/lib/Horde/Core/Ajax/Imple/SpellChecker.php b/lib/Horde/Core/Ajax/Imple/SpellChecker.php
index fc5d4ec69..116a45b2d 100644
--- a/lib/Horde/Core/Ajax/Imple/SpellChecker.php
+++ b/lib/Horde/Core/Ajax/Imple/SpellChecker.php
@@ -1,4 +1,5 @@
nlsconfig->spelling);
asort($key_list, SORT_LOCALE_STRING);
- $params['locales'] = array();
+ $params['locales'] = [];
foreach ($key_list as $lcode) {
- $params['locales'][] = array(
+ $params['locales'][] = [
'l' => $registry->nlsconfig->languages[$lcode],
's' => $lcode == $language,
- 'v' => $lcode
- );
+ 'v' => $lcode,
+ ];
}
}
@@ -55,26 +56,26 @@ protected function _attach($init)
$page_output->addScriptFile('spellchecker.js', 'horde');
$page_output->addScriptPackage('Horde_Core_Script_Package_Keynavlist');
- $page_output->addInlineJsVars(array(
- 'HordeImple.SpellChecker' => new stdClass
- ));
+ $page_output->addInlineJsVars([
+ 'HordeImple.SpellChecker' => new stdClass(),
+ ]);
}
$dom_id = $this->getDomId();
- $opts = array(
+ $opts = [
'locales' => $this->_params['locales'],
'statusButton' => $dom_id,
'target' => $this->_params['targetId'],
- 'url' => strval($this->getImpleUrl()->setRaw(true)->add(array('input' => $this->_params['targetId'])))
- );
+ 'url' => strval($this->getImpleUrl()->setRaw(true)->add(['input' => $this->_params['targetId']])),
+ ];
if (isset($this->_params['states'])) {
$opts['bs'] = $this->_params['states'];
}
- $page_output->addInlineScript(array(
- 'HordeImple.SpellChecker.' . $dom_id . '=new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON) . ')'
- ), true);
+ $page_output->addInlineScript([
+ 'HordeImple.SpellChecker.' . $dom_id . '=new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON) . ')',
+ ], true);
return false;
}
@@ -87,7 +88,7 @@ protected function _handle(Horde_Variables $vars)
{
global $injector;
- $args = array('html' => !empty($vars->html));
+ $args = ['html' => !empty($vars->html)];
if (isset($vars->locale)) {
$args['locale'] = $vars->locale;
}
@@ -99,10 +100,10 @@ protected function _handle(Horde_Variables $vars)
);
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
- return array(
- 'bad' => array(),
- 'suggestions' => array()
- );
+ return [
+ 'bad' => [],
+ 'suggestions' => [],
+ ];
}
}
diff --git a/lib/Horde/Core/Ajax/Imple/UserAutoCompleter.php b/lib/Horde/Core/Ajax/Imple/UserAutoCompleter.php
index 5d7fc1b53..8bf2a301a 100644
--- a/lib/Horde/Core/Ajax/Imple/UserAutoCompleter.php
+++ b/lib/Horde/Core/Ajax/Imple/UserAutoCompleter.php
@@ -1,4 +1,5 @@
array(','))
+ ['tokens' => [',']]
);
}
diff --git a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter.php b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter.php
index 2a8ef9681..1d5b32479 100644
--- a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter.php
+++ b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter.php
@@ -1,4 +1,5 @@
_params['id'] . '_loading_img';
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(
- array(
+ [
'window.weatherupdate = window.weatherupdate || {}',
'window.weatherupdate["' . $this->_params['instance'] . '"] = {
value: false,
@@ -51,13 +52,13 @@ protected function _getAutoCompleter()
'$("button' . $this->_params['instance'] . '").observe("click", function(e) {
window.weatherupdate["' . $this->_params['instance'] . '"].update();
e.stop();
- })'
- )
+ })',
+ ]
);
- return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax(array(
+ return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax([
'minChars' => 3,
- 'tokens' => array(),
+ 'tokens' => [],
'domParent' => 'horde-content',
'filterCallback' => 'function(c) {
if (c) {
@@ -81,8 +82,8 @@ protected function _getAutoCompleter()
}
});
return c;
- }'
- ));
+ }',
+ ]);
}
/**
@@ -92,4 +93,4 @@ protected function _handleAutoCompleter($input)
return $GLOBALS['injector']->getInstance('Horde_Weather')->autocompleteLocation($input);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Base.php b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Base.php
index 691a7aa7a..55d5ccf30 100644
--- a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Base.php
+++ b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Base.php
@@ -1,4 +1,5 @@
_params['id'] . '_loading_img';
$injector->getInstance('Horde_PageOutput')->addInlineScript(
- array(
+ [
'window.weatherupdate = window.weatherupdate || {}',
'window.weatherupdate["' . $this->_params['instance'] . '"] = {
value: false,
@@ -61,13 +61,13 @@ protected function _getAutoCompleterForBlock($block)
'$("button' . $this->_params['instance'] . '").observe("click", function(e) {
window.weatherupdate["' . $this->_params['instance'] . '"].update();
e.stop();
- })'
- )
+ })',
+ ]
);
- return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax(array(
+ return new Horde_Core_Ajax_Imple_AutoCompleter_Ajax([
'minChars' => 3,
- 'tokens' => array(),
+ 'tokens' => [],
'domParent' => 'horde-content',
'filterCallback' => 'function(c) {
if (c) {
@@ -93,7 +93,7 @@ protected function _getAutoCompleterForBlock($block)
}
});
return c;
- }'
- ));
+ }',
+ ]);
}
}
diff --git a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Metar.php b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Metar.php
index f47b7f87a..74c780090 100644
--- a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Metar.php
+++ b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Metar.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Cache'),
'cache_lifetime' => $conf['weather']['params']['lifetime'],
'http_client' => $injector->createInstance('Horde_Core_Factory_HttpClient')->create(),
- 'db' => $injector->getInstance('Horde_Db_Adapter'))
+ 'db' => $injector->getInstance('Horde_Db_Adapter')]
);
return $weather->autocompleteLocation($input);
diff --git a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Weather.php b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Weather.php
index 6eeeac15b..e2b42a4e0 100644
--- a/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Weather.php
+++ b/lib/Horde/Core/Ajax/Imple/WeatherLocationAutoCompleter/Weather.php
@@ -1,4 +1,5 @@
response = $this->data;
- $stack = $notification->notify(array(
+ $stack = $notification->notify([
// @todo: Make this configurable for H6
- 'listeners' => array('status', 'audio', 'webnotification'),
- 'raw' => true
- ));
+ 'listeners' => ['status', 'audio', 'webnotification'],
+ 'raw' => true,
+ ]);
if (!empty($stack)) {
- $ob->msgs = array();
+ $ob->msgs = [];
foreach ($stack as $val) {
- $ob->msgs[] = array_filter(array(
+ $ob->msgs[] = array_filter([
'flags' => $val->flags,
'message' => $val->message,
'type' => $val->type,
- 'webnotify' => isset($val->webnotify) ? $val->webnotify : null
- ));
+ 'webnotify' => $val->webnotify ?? null,
+ ]);
}
}
@@ -130,7 +131,7 @@ protected function _jsonData()
$this->jsfiles[] = strval($val->url);
}
$page_output->hsl->clear();
- foreach ($page_output->css->getStylesheetUrls(array('nobase' => true)) as $val) {
+ foreach ($page_output->css->getStylesheetUrls(['nobase' => true]) as $val) {
$this->cssfiles[] = strval($val->url);
}
diff --git a/lib/Horde/Core/Ajax/Response/HordeCore/JsonHtml.php b/lib/Horde/Core/Ajax/Response/HordeCore/JsonHtml.php
index c2691bad8..b8ffcc6dc 100644
--- a/lib/Horde/Core/Ajax/Response/HordeCore/JsonHtml.php
+++ b/lib/Horde/Core/Ajax/Response/HordeCore/JsonHtml.php
@@ -1,4 +1,5 @@
message = strval($GLOBALS['registry']->getLogoutUrl(array(
- 'reason' => $this->_error
- ))->add('url', Horde::url('', false, array(
+ $msg = new stdClass();
+ $msg->message = strval($GLOBALS['registry']->getLogoutUrl([
+ 'reason' => $this->_error,
+ ])->add('url', Horde::url('', false, [
'app' => $this->_app,
- 'append_session' => -1
- ))));
+ 'append_session' => -1,
+ ])));
$msg->type = 'horde.noauth';
- $ob = new stdClass;
- $ob->msgs = array($msg);
+ $ob = new stdClass();
+ $ob->msgs = [$msg];
$ob->response = false;
return $ob;
diff --git a/lib/Horde/Core/Ajax/Response/HordeCore/Reload.php b/lib/Horde/Core/Ajax/Response/HordeCore/Reload.php
index ba1edbeb6..a6489b279 100644
--- a/lib/Horde/Core/Ajax/Response/HordeCore/Reload.php
+++ b/lib/Horde/Core/Ajax/Response/HordeCore/Reload.php
@@ -1,4 +1,5 @@
reload = is_null($this->data)
? true
: $this->data;
diff --git a/lib/Horde/Core/Ajax/Response/HordeCore/SessionTimeout.php b/lib/Horde/Core/Ajax/Response/HordeCore/SessionTimeout.php
index 5c239bfee..430ddb4c3 100644
--- a/lib/Horde/Core/Ajax/Response/HordeCore/SessionTimeout.php
+++ b/lib/Horde/Core/Ajax/Response/HordeCore/SessionTimeout.php
@@ -1,4 +1,5 @@
message = strval($GLOBALS['registry']->getLogoutUrl(array(
- 'reason' => Horde_Auth::REASON_SESSION
- ))->add('url', Horde::url('', false, array(
+ $msg = new stdClass();
+ $msg->message = strval($GLOBALS['registry']->getLogoutUrl([
+ 'reason' => Horde_Auth::REASON_SESSION,
+ ])->add('url', Horde::url('', false, [
'app' => $this->_app,
- 'append_session' => -1
- ))));
+ 'append_session' => -1,
+ ])));
$msg->type = 'horde.ajaxtimeout';
- $ob = new stdClass;
- $ob->msgs = array($msg);
+ $ob = new stdClass();
+ $ob->msgs = [$msg];
$ob->response = false;
return $ob;
diff --git a/lib/Horde/Core/Ajax/Response/Notifications.php b/lib/Horde/Core/Ajax/Response/Notifications.php
index 9241825ec..6e8682b7d 100644
--- a/lib/Horde/Core/Ajax/Response/Notifications.php
+++ b/lib/Horde/Core/Ajax/Response/Notifications.php
@@ -1,4 +1,5 @@
charset = $charset;
diff --git a/lib/Horde/Core/Alarm/Handler/Desktop.php b/lib/Horde/Core/Alarm/Handler/Desktop.php
index bf38d24d2..53ecc1e2e 100644
--- a/lib/Horde/Core/Alarm/Handler/Desktop.php
+++ b/lib/Horde/Core/Alarm/Handler/Desktop.php
@@ -1,4 +1,5 @@
getView() != Horde_Registry::VIEW_DYNAMIC) {
if (!isset($params['js_notify'])) {
@@ -74,14 +75,21 @@ public function notify(array $alarm)
if ($registry->getView() == Horde_Registry::VIEW_DYNAMIC) {
$alarm['params']['desktop']['icon'] = $icon;
- $notification->push($alarm['title'], 'horde.alarm', array(
- 'alarm' => $alarm
- ));
- } else {
- $js = sprintf('if(window.Notification){if (window.Notification.permission != "granted") {window.Notification.requestPermission(function(){if (window.Notification.permission == "granted") { new window.Notification("%s", {body: "%s", icon: "%s" }); } }) } else { new window.Notification("%s", {body: "%s", icon: "%s" }); } };',
- $alarm['title'], $alarm['params']['desktop']['subtitle'], $icon, $alarm['title'], $alarm['params']['desktop']['subtitle'], $icon);
+ $notification->push($alarm['title'], 'horde.alarm', [
+ 'alarm' => $alarm,
+ ]);
+ } else {
+ $js = sprintf(
+ 'if(window.Notification){if (window.Notification.permission != "granted") {window.Notification.requestPermission(function(){if (window.Notification.permission == "granted") { new window.Notification("%s", {body: "%s", icon: "%s" }); } }) } else { new window.Notification("%s", {body: "%s", icon: "%s" }); } };',
+ $alarm['title'],
+ $alarm['params']['desktop']['subtitle'],
+ $icon,
+ $alarm['title'],
+ $alarm['params']['desktop']['subtitle'],
+ $icon
+ );
call_user_func($this->_jsNotify, $js);
- }
+ }
}
/**
@@ -91,7 +99,7 @@ public function notify(array $alarm)
*/
public function getDescription()
{
- return Horde_Alarm_Translation::t("Desktop notification (with certain browsers)");
+ return Horde_Alarm_Translation::t('Desktop notification (with certain browsers)');
}
}
diff --git a/lib/Horde/Core/Alarm/Handler/Desktop/Icon.php b/lib/Horde/Core/Alarm/Handler/Desktop/Icon.php
index f35584270..6b6c8db20 100644
--- a/lib/Horde/Core/Alarm/Handler/Desktop/Icon.php
+++ b/lib/Horde/Core/Alarm/Handler/Desktop/Icon.php
@@ -1,4 +1,5 @@
linkByPackage(
- $app, 'show', $params
+ $app,
+ 'show',
+ $params
);
}
$notification->push(
$alarm['title'],
'horde.alarm',
- array('alarm' => $alarm)
+ ['alarm' => $alarm]
);
if (!empty($alarm['params']['notify']['sound']) &&
!isset($this->_soundPlayed[$alarm['params']['notify']['sound']])) {
@@ -53,7 +56,7 @@ public function notify(array $alarm)
$notification->push(
$alarm['params']['notify']['sound'],
'audio',
- array('id' => $alarm['id'])
+ ['id' => $alarm['id']]
);
$this->_soundPlayed[$alarm['params']['notify']['sound']] = true;
}
@@ -66,7 +69,7 @@ public function notify(array $alarm)
*/
public function getDescription()
{
- return Horde_Core_Translation::t("Inline");
+ return Horde_Core_Translation::t('Inline');
}
/**
@@ -83,12 +86,12 @@ public function getDescription()
*/
public function getParameters()
{
- return array(
- 'sound' => array(
+ return [
+ 'sound' => [
'type' => 'sound',
- 'desc' => Horde_Core_Translation::t("Play a sound?"),
- 'required' => false
- )
- );
+ 'desc' => Horde_Core_Translation::t('Play a sound?'),
+ 'required' => false,
+ ],
+ ];
}
}
diff --git a/lib/Horde/Core/Auth/Application.php b/lib/Horde/Core/Auth/Application.php
index 17aef637d..64ca7d021 100644
--- a/lib/Horde/Core/Auth/Application.php
+++ b/lib/Horde/Core/Auth/Application.php
@@ -1,4 +1,5 @@
true,
'authenticate' => true,
'exists' => true,
@@ -77,8 +78,8 @@ class Horde_Core_Auth_Application extends Horde_Auth_Base
'resetpassword' => true,
'transparent' => true,
'update' => true,
- 'validate' => true
- );
+ 'validate' => true,
+ ];
/**
* Constructor.
@@ -90,7 +91,7 @@ class Horde_Core_Auth_Application extends Horde_Auth_Base
*
* @throws InvalidArgumentException
*/
- public function __construct(array $params = array())
+ public function __construct(array $params = [])
{
if (!isset($params['app'])) {
throw new InvalidArgumentException('Missing app parameter.');
@@ -129,8 +130,8 @@ public function authenticate($userId, $credentials, $login = true)
}
try {
- list($userId, $credentials) = $this->runHook(trim($userId), $credentials, 'preauthenticate', 'authenticate');
- } catch (Horde_Auth_Exception $e) {
+ [$userId, $credentials] = $this->runHook(trim($userId), $credentials, 'preauthenticate', 'authenticate');
+ } catch (Horde_Auth_Exception $e) {
return false;
}
@@ -167,7 +168,7 @@ protected function _authenticate($userId, $credentials)
$credentials['auth_ob'] = $this;
- $GLOBALS['registry']->callAppMethod($this->_app, 'authAuthenticate', array('args' => array($userId, $credentials), 'noperms' => true));
+ $GLOBALS['registry']->callAppMethod($this->_app, 'authAuthenticate', ['args' => [$userId, $credentials], 'noperms' => true]);
}
/**
@@ -184,7 +185,7 @@ public function validateAuth()
try {
return $this->hasCapability('validate')
- ? $GLOBALS['registry']->callAppMethod($this->_app, 'authValidate', array('noperms' => true))
+ ? $GLOBALS['registry']->callAppMethod($this->_app, 'authValidate', ['noperms' => true])
: parent::validateAuth();
} catch (Horde_Exception_AuthenticationFailure $e) {
return false;
@@ -207,7 +208,7 @@ public function addUser($userId, $credentials)
}
if ($this->hasCapability('add')) {
- $GLOBALS['registry']->callAppMethod($this->_app, 'authAddUser', array('args' => array($userId, $credentials)));
+ $GLOBALS['registry']->callAppMethod($this->_app, 'authAddUser', ['args' => [$userId, $credentials]]);
} else {
parent::addUser($userId, $credentials);
}
@@ -287,7 +288,7 @@ public function updateUser($oldID, $newID, $credentials)
}
if ($this->hasCapability('update')) {
- $GLOBALS['registry']->callAppMethod($this->_app, 'authUpdateUser', array('args' => array($oldID, $newID, $credentials)));
+ $GLOBALS['registry']->callAppMethod($this->_app, 'authUpdateUser', ['args' => [$oldID, $newID, $credentials]]);
} else {
parent::updateUser($oldID, $newID, $credentials);
}
@@ -306,7 +307,7 @@ public function removeUser($userId)
$this->_base->removeUser($userId);
} else {
if ($this->hasCapability('remove')) {
- $GLOBALS['registry']->callAppMethod($this->_app, 'authRemoveUser', array('args' => array($userId)));
+ $GLOBALS['registry']->callAppMethod($this->_app, 'authRemoveUser', ['args' => [$userId]]);
} else {
parent::removeUser($userId);
}
@@ -342,7 +343,7 @@ public function listNames()
{
$factory = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Identity');
- $names = array();
+ $names = [];
foreach ($this->listUsers() as $user) {
$names[$user] = $factory->create($user)->getName();
}
@@ -364,7 +365,7 @@ public function exists($userId)
}
return $this->hasCapability('exists')
- ? $GLOBALS['registry']->callAppMethod($this->_app, 'authUserExists', array('args' => array($userId)))
+ ? $GLOBALS['registry']->callAppMethod($this->_app, 'authUserExists', ['args' => [$userId]])
: parent::exists($userId);
}
@@ -385,7 +386,7 @@ public function transparent()
$credentials = $registry->getAuthCredential();
}
- list($userId, $credentials) = $this->runHook($userId, $credentials, 'preauthenticate', 'transparent');
+ [$userId, $credentials] = $this->runHook($userId, $credentials, 'preauthenticate', 'transparent');
$this->setCredential('userId', $userId);
$this->setCredential('credentials', $credentials);
@@ -393,7 +394,7 @@ public function transparent()
if ($this->_base) {
$result = $this->_base->transparent();
} elseif ($this->hasCapability('transparent')) {
- $result = $registry->callAppMethod($this->_app, 'authTransparent', array('args' => array($this), 'noperms' => true));
+ $result = $registry->callAppMethod($this->_app, 'authTransparent', ['args' => [$this], 'noperms' => true]);
} else {
/* If this application contains neither transparent nor
* authenticate capabilities, it does not require any
@@ -420,7 +421,7 @@ public function resetPassword($userId)
}
return $this->hasCapability('resetpassword')
- ? $GLOBALS['registry']->callAppMethod($this->_app, 'authResetPassword', array('args' => array($userId)))
+ ? $GLOBALS['registry']->callAppMethod($this->_app, 'authResetPassword', ['args' => [$userId]])
: parent::resetPassword();
}
@@ -439,7 +440,7 @@ public function hasCapability($capability)
}
// The follow capabilities are not determined by the Application,
// but by 'Horde'.
- if (in_array(Horde_String::lower($capability), array('badlogincount', 'lock'))) {
+ if (in_array(Horde_String::lower($capability), ['badlogincount', 'lock'])) {
return parent::hasCapability($capability);
} elseif (!isset($this->_appCapabilities)) {
$this->_appCapabilities = $GLOBALS['registry']->getApiInstance($this->_app, 'application')->auth;
@@ -558,7 +559,7 @@ public function getLoginParams()
{
return ($this->_base && method_exists($this->_base, 'getLoginParams'))
? $this->_base->getLoginParams()
- : $GLOBALS['registry']->callAppMethod($this->_app, 'authLoginParams', array('noperms' => true));
+ : $GLOBALS['registry']->callAppMethod($this->_app, 'authLoginParams', ['noperms' => true]);
}
/**
@@ -590,11 +591,11 @@ public function runHook($userId, $credentials, $type, $method = null)
{
if (!is_array($credentials)) {
$credentials = empty($credentials)
- ? array()
- : array($credentials);
+ ? []
+ : [$credentials];
}
- $ret_array = array($userId, $credentials);
+ $ret_array = [$userId, $credentials];
if ($type == 'preauthenticate') {
$credentials['authMethod'] = $method;
@@ -602,7 +603,7 @@ public function runHook($userId, $credentials, $type, $method = null)
try {
$result = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook($type, $this->_app, array($userId, $credentials));
+ ->callHook($type, $this->_app, [$userId, $credentials]);
} catch (Horde_Exception_HookNotSet $e) {
return $ret_array;
} catch (Horde_Exception $e) {
@@ -644,7 +645,7 @@ protected function _setAuth()
{
global $registry;
- if ($registry->isAuthenticated(array('app' => $this->_app, 'notransparent' => true))) {
+ if ($registry->isAuthenticated(['app' => $this->_app, 'notransparent' => true])) {
return true;
}
@@ -661,16 +662,16 @@ protected function _setAuth()
$credentials = $this->getCredential('credentials');
try {
- list(,$credentials) = $this->runHook($userId, $credentials, 'postauthenticate');
+ [, $credentials] = $this->runHook($userId, $credentials, 'postauthenticate');
} catch (Horde_Auth_Exception $e) {
return false;
}
- $registry->setAuth($userId, $credentials, array(
+ $registry->setAuth($userId, $credentials, [
'app' => $this->_app,
'change' => $this->getCredential('change'),
- 'language' => $language
- ));
+ 'language' => $language,
+ ]);
/* Only set the view mode on initial authentication */
if (!$GLOBALS['session']->exists('horde', 'view')) {
@@ -681,7 +682,7 @@ protected function _setAuth()
isset($GLOBALS['notification']) &&
($expire = $this->_base->getCredential('expire'))) {
$toexpire = ($expire - time()) / 86400;
- $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::ngettext("%d day until your password expires.", "%d days until your password expires.", $toexpire), $toexpire), 'horde.warning');
+ $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::ngettext('%d day until your password expires.', '%d days until your password expires.', $toexpire), $toexpire), 'horde.warning');
}
return true;
@@ -719,63 +720,63 @@ protected function _setView()
/* $mode now contains the user's preference for view based on the
* login screen parameters and configuration. */
switch ($mode) {
- case 'auto':
- if ($browser->hasFeature('ajax')) {
- $mode = $browser->isMobile()
- ? 'smartmobile'
- : 'dynamic';
- } else {
- $mode = $browser->isMobile()
- ? 'mobile'
- : 'basic';
- }
- break;
+ case 'auto':
+ if ($browser->hasFeature('ajax')) {
+ $mode = $browser->isMobile()
+ ? 'smartmobile'
+ : 'dynamic';
+ } else {
+ $mode = $browser->isMobile()
+ ? 'mobile'
+ : 'basic';
+ }
+ break;
- case 'basic':
- if (!$browser->hasFeature('javascript')) {
- $notification->push(Horde_Core_Translation::t("Your browser does not support javascript. Using minimal view instead."), 'horde.warning');
- $mode = 'mobile';
- }
- break;
+ case 'basic':
+ if (!$browser->hasFeature('javascript')) {
+ $notification->push(Horde_Core_Translation::t('Your browser does not support javascript. Using minimal view instead.'), 'horde.warning');
+ $mode = 'mobile';
+ }
+ break;
+
+ case 'dynamic':
+ if (!$browser->hasFeature('ajax')) {
+ if ($browser->hasFeature('javascript')) {
+ $notification->push(Horde_Core_Translation::t('Your browser does not support the dynamic view. Using basic view instead.'), 'horde.warning');
+ $mode = 'basic';
+ } else {
+ $notification->push(Horde_Core_Translation::t('Your browser does not support the dynamic view. Using minimal view instead.'), 'horde.warning');
+ $mode = 'mobile';
+ }
+ }
+ break;
- case 'dynamic':
- if (!$browser->hasFeature('ajax')) {
- if ($browser->hasFeature('javascript')) {
- $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using basic view instead."), 'horde.warning');
- $mode = 'basic';
- } else {
- $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using minimal view instead."), 'horde.warning');
+ case 'smartmobile':
+ if (!$browser->hasFeature('ajax')) {
+ $notification->push(Horde_Core_Translation::t('Your browser does not support the dynamic view. Using minimal view instead.'), 'horde.warning');
$mode = 'mobile';
}
- }
- break;
+ break;
- case 'smartmobile':
- if (!$browser->hasFeature('ajax')) {
- $notification->push(Horde_Core_Translation::t("Your browser does not support the dynamic view. Using minimal view instead."), 'horde.warning');
+ case 'mobile':
+ default:
$mode = 'mobile';
- }
- break;
-
- case 'mobile':
- default:
- $mode = 'mobile';
- break;
+ break;
}
if (($browser->getBrowser() == 'msie') &&
($browser->getMajor() < 8) &&
($mode != 'mobile')) {
- $notification->push(Horde_Core_Translation::t("You are using an old, unsupported version of Internet Explorer. You need at least Internet Explorer 8. If you already run IE8 or higher, disable the Compatibility View. Minimal view will be used until you upgrade your browser."));
+ $notification->push(Horde_Core_Translation::t('You are using an old, unsupported version of Internet Explorer. You need at least Internet Explorer 8. If you already run IE8 or higher, disable the Compatibility View. Minimal view will be used until you upgrade your browser.'));
$mode = 'mobile';
}
- $registry_map = array(
+ $registry_map = [
'basic' => Horde_Registry::VIEW_BASIC,
'dynamic' => Horde_Registry::VIEW_DYNAMIC,
'mobile' => Horde_Registry::VIEW_MINIMAL,
- 'smartmobile' => Horde_Registry::VIEW_SMARTMOBILE
- );
+ 'smartmobile' => Horde_Registry::VIEW_SMARTMOBILE,
+ ];
$this->_view = $mode;
$registry->setView($registry_map[$mode]);
diff --git a/lib/Horde/Core/Auth/Composite.php b/lib/Horde/Core/Auth/Composite.php
index 994b12100..2767f6fef 100644
--- a/lib/Horde/Core/Auth/Composite.php
+++ b/lib/Horde/Core/Auth/Composite.php
@@ -1,4 +1,5 @@
_params['auth_driver']->getLoginParams();
}
- return array(
- 'js_code' => array(),
- 'js_files' => array(),
- 'params' => array()
- );
+ return [
+ 'js_code' => [],
+ 'js_files' => [],
+ 'params' => [],
+ ];
}
}
diff --git a/lib/Horde/Core/Auth/Imsp.php b/lib/Horde/Core/Auth/Imsp.php
index 6df95bfa2..8a4901271 100644
--- a/lib/Horde/Core/Auth/Imsp.php
+++ b/lib/Horde/Core/Auth/Imsp.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, $credentials, 'preauthenticate', 'admin');
+ [$userId, $credentials] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, $credentials, 'preauthenticate', 'admin');
parent::addUser($userId, $credentials);
}
@@ -41,15 +42,19 @@ public function addUser($userId, $credentials)
*
* @throws Horde_Auth_Exception
*/
- public function updateUser($oldID, $newID, $credentials, $olddn = null,
- $newdn = null)
- {
+ public function updateUser(
+ $oldID,
+ $newID,
+ $credentials,
+ $olddn = null,
+ $newdn = null
+ ) {
$auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
- list($oldID, $old_credentials) = $auth->runHook($oldID, $credentials, 'preauthenticate', 'admin');
- list($newID, $new_credentials) = $auth->runHook($newID, $credentials, 'preauthenticate', 'admin');
- $olddn = isset($old_credentials['dn']) ? $old_credentials['dn'] : null;
- $newdn = isset($new_credentials['dn']) ? $new_credentials['dn'] : null;
+ [$oldID, $old_credentials] = $auth->runHook($oldID, $credentials, 'preauthenticate', 'admin');
+ [$newID, $new_credentials] = $auth->runHook($newID, $credentials, 'preauthenticate', 'admin');
+ $olddn = $old_credentials['dn'] ?? null;
+ $newdn = $new_credentials['dn'] ?? null;
parent::updateUser($oldID, $newID, $new_credentials, $olddn, $newdn);
}
@@ -64,7 +69,7 @@ public function updateUser($oldID, $newID, $credentials, $olddn = null,
*/
public function removeUser($userId, $dn = null)
{
- list($userId, $credentials) = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, array(), 'preauthenticate', 'admin');
+ [$userId, $credentials] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, [], 'preauthenticate', 'admin');
parent::removeUser($userId, isset($credentials['ldap']) ? $credentials['ldap']['dn'] : null);
}
diff --git a/lib/Horde/Core/Auth/Msad.php b/lib/Horde/Core/Auth/Msad.php
index ef71c1577..a8bc7d421 100644
--- a/lib/Horde/Core/Auth/Msad.php
+++ b/lib/Horde/Core/Auth/Msad.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, $credentials, 'preauthenticate', 'admin');
+ [$userId, $credentials] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, $credentials, 'preauthenticate', 'admin');
parent::addUser($userId, $credentials);
}
@@ -39,10 +40,14 @@ public function addUser($userId, $credentials)
*
* @throws Horde_Auth_Exception
*/
- public function updateUser($oldID, $newID, $credentials, $olddn = null,
- $newdn = null)
- {
- list($oldId, $credentials) = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($oldId, $credentials, 'preauthenticate', 'admin');
+ public function updateUser(
+ $oldID,
+ $newID,
+ $credentials,
+ $olddn = null,
+ $newdn = null
+ ) {
+ [$oldId, $credentials] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($oldId, $credentials, 'preauthenticate', 'admin');
parent::updateUser($oldID, $newID, $credentials, $olddn, $newdn);
}
@@ -57,7 +62,7 @@ public function updateUser($oldID, $newID, $credentials, $olddn = null,
*/
public function removeUser($userId, $dn = null)
{
- list($userId, $credentials) = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, array(), 'preauthenticate', 'admin');
+ [$userId, $credentials] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->runHook($userId, [], 'preauthenticate', 'admin');
parent::removeUser($userId, isset($credentials['ldap']) ? $credentials['ldap']['dn'] : $dn);
}
diff --git a/lib/Horde/Core/Auth/Shibboleth.php b/lib/Horde/Core/Auth/Shibboleth.php
index aa05eadfe..954aa24d5 100644
--- a/lib/Horde/Core/Auth/Shibboleth.php
+++ b/lib/Horde/Core/Auth/Shibboleth.php
@@ -1,4 +1,5 @@
_preSignup($info);
// Attempt to add the user to the system.
- $auth->addUser($info['user_name'], array('password' => $info['password']));
+ $auth->addUser($info['user_name'], ['password' => $info['password']]);
// Attempt to add/update any extra data handed in.
if (!empty($info['extra'])) {
@@ -43,13 +44,14 @@ public function addSignup(&$info)
$injector->getInstance('Horde_Core_Hooks')->callHook(
'signup_addextra',
'horde',
- array(
+ [
$info['user_name'],
$info['extra'],
- $info['password']
- )
+ $info['password'],
+ ]
);
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
}
}
@@ -77,10 +79,10 @@ public function queueSignup(&$info)
if (!empty($info['extra'])) {
$signup->setData($info['extra']);
}
- $signup->setData(array_merge($signup->getData(), array(
+ $signup->setData(array_merge($signup->getData(), [
'dateReceived' => time(),
'password' => $info['password'],
- )));
+ ]));
$this->_queueSignup($signup);
@@ -88,29 +90,30 @@ public function queueSignup(&$info)
$injector->getInstance('Horde_Core_Hooks')->callHook(
'signup_queued',
'horde',
- array(
+ [
$info['user_name'],
- $info
- )
+ $info,
+ ]
);
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
if (!empty($conf['signup']['email'])) {
- $link = Horde::url($registry->get('webroot', 'horde') . '/admin/signup_confirm.php', true, -1)->setRaw(true)->add(array(
+ $link = Horde::url($registry->get('webroot', 'horde') . '/admin/signup_confirm.php', true, -1)->setRaw(true)->add([
'u' => $signup->getName(),
- 'h' => hash_hmac('sha1', $signup->getName(), $conf['secret_key'])
- ));
- $message = sprintf(Horde_Core_Translation::t("A new account for the user \"%s\" has been requested through the signup form."), $signup->getName())
+ 'h' => hash_hmac('sha1', $signup->getName(), $conf['secret_key']),
+ ]);
+ $message = sprintf(Horde_Core_Translation::t('A new account for the user "%s" has been requested through the signup form.'), $signup->getName())
. "\n\n"
- . Horde_Core_Translation::t("Approve the account:")
+ . Horde_Core_Translation::t('Approve the account:')
. "\n" . $link->copy()->add('a', 'approve') . "\n"
- . Horde_Core_Translation::t("Deny the account:")
+ . Horde_Core_Translation::t('Deny the account:')
. "\n" . $link->copy()->add('a', 'deny');
- $mail = new Horde_Mime_Mail(array(
+ $mail = new Horde_Mime_Mail([
'body' => $message,
- 'Subject' => sprintf(Horde_Core_Translation::t("Account signup request for \"%s\""), $signup->getName()),
+ 'Subject' => sprintf(Horde_Core_Translation::t('Account signup request for "%s"'), $signup->getName()),
'To' => $conf['signup']['email'],
- 'From' => $conf['signup']['email']));
+ 'From' => $conf['signup']['email']]);
$mail->send($injector->getInstance('Horde_Mail'));
}
}
@@ -132,15 +135,16 @@ protected function _preSignup(&$info)
$info = $injector->getInstance('Horde_Core_Hooks')->callHook(
'signup_preprocess',
'horde',
- array($info)
+ [$info]
);
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
// Check to see if the username already exists in the auth backend or
// the signup queue.
if ($auth->exists($info['user_name']) ||
$this->exists($info['user_name'])) {
- throw new Horde_Exception(sprintf(Horde_Core_Translation::t("Username \"%s\" already exists."), $info['user_name']));
+ throw new Horde_Exception(sprintf(Horde_Core_Translation::t('Username "%s" already exists.'), $info['user_name']));
}
}
diff --git a/lib/Horde/Core/Auth/Signup/Form.php b/lib/Horde/Core/Auth/Signup/Form.php
index 6ca0c6247..73ccde342 100644
--- a/lib/Horde/Core/Auth/Signup/Form.php
+++ b/lib/Horde/Core/Auth/Signup/Form.php
@@ -1,4 +1,5 @@
setButtons(Horde_Core_Translation::t("Sign up"));
+ $this->setButtons(Horde_Core_Translation::t('Sign up'));
$this->addHidden('', 'url', 'text', false);
@@ -36,28 +37,35 @@ public function __construct(&$vars)
try {
$extra = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
->callHook('signup_getextra', 'horde');
- } catch (Horde_Exception_HookNotSet $e) {}
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
if (!empty($extra)) {
if (!isset($extra['user_name'])) {
- $this->addVariable(Horde_Core_Translation::t("Choose a username"), 'user_name', 'text', true);
+ $this->addVariable(Horde_Core_Translation::t('Choose a username'), 'user_name', 'text', true);
}
if (!isset($extra['password'])) {
- $this->addVariable(Horde_Core_Translation::t("Choose a password"), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t("Type your password twice to confirm"));
+ $this->addVariable(Horde_Core_Translation::t('Choose a password'), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t('Type your password twice to confirm'));
}
foreach ($extra as $field_name => $field) {
- $readonly = isset($field['readonly']) ? $field['readonly'] : null;
- $desc = isset($field['desc']) ? $field['desc'] : null;
- $required = isset($field['required']) ? $field['required'] : false;
- $field_params = isset($field['params']) ? $field['params'] : array();
+ $readonly = $field['readonly'] ?? null;
+ $desc = $field['desc'] ?? null;
+ $required = $field['required'] ?? false;
+ $field_params = $field['params'] ?? [];
- $this->addVariable($field['label'], 'extra[' . $field_name . ']',
- $field['type'], $required, $readonly,
- $desc, $field_params);
+ $this->addVariable(
+ $field['label'],
+ 'extra[' . $field_name . ']',
+ $field['type'],
+ $required,
+ $readonly,
+ $desc,
+ $field_params
+ );
}
} else {
- $this->addVariable(Horde_Core_Translation::t("Choose a username"), 'user_name', 'text', true);
- $this->addVariable(Horde_Core_Translation::t("Choose a password"), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t("Type your password twice to confirm"));
+ $this->addVariable(Horde_Core_Translation::t('Choose a username'), 'user_name', 'text', true);
+ $this->addVariable(Horde_Core_Translation::t('Choose a password'), 'password', 'passwordconfirm', true, false, Horde_Core_Translation::t('Type your password twice to confirm'));
}
}
@@ -84,7 +92,7 @@ public function getInfo($vars, &$info)
/**
* Get the renderer for this form
*/
- function getRenderer($params = array())
+ public function getRenderer($params = [])
{
$renderer = new Horde_Core_Ui_ModalFormRenderer($params);
return $renderer;
diff --git a/lib/Horde/Core/Auth/Signup/Null.php b/lib/Horde/Core/Auth/Signup/Null.php
index 33f764fa5..212b5974a 100644
--- a/lib/Horde/Core/Auth/Signup/Null.php
+++ b/lib/Horde/Core/Auth/Signup/Null.php
@@ -1,4 +1,5 @@
_params = array_merge(
$this->_params,
- array('table' => 'horde_signups'),
- Horde::getDriverConfig('signup', 'Sql'));
+ ['table' => 'horde_signups'],
+ Horde::getDriverConfig('signup', 'Sql')
+ );
}
/**
@@ -47,12 +49,12 @@ protected function _queueSignup($signup)
. ' (user_name, signup_date, signup_host, signup_data) VALUES (?, ?, ?, ?) ';
$remote = $registry->remoteHost();
- $values = array(
+ $values = [
$signup->getName(),
time(),
$remote->addr,
- serialize($signup->getData())
- );
+ serialize($signup->getData()),
+ ];
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->insert($query, $values);
}
@@ -73,7 +75,7 @@ public function exists($user)
$query = 'SELECT 1 FROM ' . $this->_params['table'] .
' WHERE user_name = ?';
- $values = array($user);
+ $values = [$user];
return (bool)$GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->selectValue($query, $values);
}
@@ -92,11 +94,11 @@ public function getQueuedSignup($username)
{
$query = 'SELECT * FROM ' . $this->_params['table'] .
' WHERE user_name = ?';
- $values = array($username);
+ $values = [$username];
$result = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->selectOne($query, $values);
if (empty($result)) {
- throw new Horde_Exception(sprintf(Horde_Core_Translation::t("User \"%s\" does not exist."), $username));
+ throw new Horde_Exception(sprintf(Horde_Core_Translation::t('User "%s" does not exist.'), $username));
}
$object = new Horde_Core_Auth_Signup_SqlObject($result['user_name']);
$object->setData($result);
@@ -118,7 +120,7 @@ public function getQueuedSignups()
$result = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->select($query);
- $signups = array();
+ $signups = [];
foreach ($result as $signup) {
$object = new Horde_Core_Auth_Signup_SqlObject($signup['user_name']);
$object->setData($signup);
@@ -139,7 +141,7 @@ public function removeQueuedSignup($username)
{
$query = 'DELETE FROM ' . $this->_params['table'] .
' WHERE user_name = ?';
- $values = array($username);
+ $values = [$username];
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->delete($query, $values);
}
diff --git a/lib/Horde/Core/Auth/Signup/SqlObject.php b/lib/Horde/Core/Auth/Signup/SqlObject.php
index 3f14ad5e7..6dddc499f 100644
--- a/lib/Horde/Core/Auth/Signup/SqlObject.php
+++ b/lib/Horde/Core/Auth/Signup/SqlObject.php
@@ -1,4 +1,5 @@
_base->getError($msg);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Horde/Core/Auth/X509.php b/lib/Horde/Core/Auth/X509.php
index 11758b2a7..2617a767c 100644
--- a/lib/Horde/Core/Auth/X509.php
+++ b/lib/Horde/Core/Auth/X509.php
@@ -1,4 +1,5 @@
_app = $app;
@@ -114,7 +115,7 @@ public function getName()
*/
public function getParams()
{
- return $this->_call('_params', array());
+ return $this->_call('_params', []);
}
/**
@@ -124,7 +125,7 @@ public function getParams()
*/
protected function _params()
{
- return array();
+ return [];
}
/**
@@ -246,8 +247,8 @@ protected function _ajaxUpdate(Horde_Variables $vars)
protected function _ajaxUpdateUrl()
{
$ajax_url = $GLOBALS['registry']->getServiceLink('ajax')
- ->add(array('app' => $this->getApp(),
- 'blockid' => get_class($this)));
+ ->add(['app' => $this->getApp(),
+ 'blockid' => get_class($this)]);
$ajax_url->pathInfo = 'blockUpdate';
return $ajax_url;
@@ -265,10 +266,10 @@ protected function _ajaxUpdateUrl()
protected function _call($name, $default, $args = null)
{
try {
- $pushed = $GLOBALS['registry']->pushApp($this->getApp(), array(
+ $pushed = $GLOBALS['registry']->pushApp($this->getApp(), [
'check_perms' => true,
- 'logintasks' => false
- ));
+ 'logintasks' => false,
+ ]);
} catch (Horde_Exception $e) {
return $default;
}
@@ -276,7 +277,7 @@ protected function _call($name, $default, $args = null)
try {
$ret = is_null($args)
? $this->$name()
- : call_user_func(array($this, $name), $args);
+ : call_user_func([$this, $name], $args);
} catch (Horde_Exception $e) {
$ret = $default;
}
diff --git a/lib/Horde/Core/Block/Collection.php b/lib/Horde/Core/Block/Collection.php
index 5aeab64e2..ccc01ffba 100644
--- a/lib/Horde/Core/Block/Collection.php
+++ b/lib/Horde/Core/Block/Collection.php
@@ -1,4 +1,5 @@
getValue($this->_layout));
if (empty($layout)) {
- $layout = array();
+ $layout = [];
if (isset($GLOBALS['conf']['portal']['fixed_blocks'])) {
foreach ($GLOBALS['conf']['portal']['fixed_blocks'] as $block) {
- list($app, $type) = explode(':', $block, 2);
- $layout[] = array(
- array(
+ [$app, $type] = explode(':', $block, 2);
+ $layout[] = [
+ [
'app' => $app,
- 'params' => array(
+ 'params' => [
'type2' => $type,
- 'params' => false
- ),
+ 'params' => false,
+ ],
'height' => 1,
- 'width' => 1
- )
- );
+ 'width' => 1,
+ ],
+ ];
}
}
}
@@ -154,7 +155,7 @@ public function getBlock($app, $name, $params = null)
*/
public function getBlocksList()
{
- $blocks = array();
+ $blocks = [];
$this->_loadBlocks();
@@ -177,7 +178,7 @@ public function getBlocksList()
*/
public function getFixedBlocks()
{
- $layout = array();
+ $layout = [];
return $layout;
@@ -193,9 +194,12 @@ public function getFixedBlocks()
*
* @return string The select tag with all available blocks.
*/
- public function getBlocksWidget($cur_app = null, $cur_block = null,
- $onchange = false, $readonly = false)
- {
+ public function getBlocksWidget(
+ $cur_app = null,
+ $cur_block = null,
+ $onchange = false,
+ $readonly = false
+ ) {
$widget = '';
}
if ($this->isRemovable($row, $col)) {
$icons .= Horde::link(
- $this->getActionUrl('removeBlock', $row, $col), Horde_Core_Translation::t("Remove"),
- '', '',
+ $this->getActionUrl('removeBlock', $row, $col),
+ Horde_Core_Translation::t('Remove'),
+ '',
+ '',
'return window.confirm(\''
- . addslashes(Horde_Core_Translation::t("Really delete this block?")) . '\')')
- . Horde_Themes_Image::tag('delete.png', array('alt' => Horde_Core_Translation::t("Remove")))
+ . addslashes(Horde_Core_Translation::t('Really delete this block?')) . '\')'
+ )
+ . Horde_Themes_Image::tag('delete.png', ['alt' => Horde_Core_Translation::t('Remove')])
. '';
}
diff --git a/lib/Horde/Core/Block/Layout/Manager.php b/lib/Horde/Core/Block/Layout/Manager.php
index b1a177430..5cfc150ac 100644
--- a/lib/Horde/Core/Block/Layout/Manager.php
+++ b/lib/Horde/Core/Block/Layout/Manager.php
@@ -1,4 +1,5 @@
_layout);
- $emptyrows = array();
+ $emptyrows = [];
for ($row = 0; $row < $rows; $row++) {
$cols = count($this->_layout[$row]);
@@ -137,7 +138,7 @@ public function __construct(Horde_Core_Block_Collection $collection)
}
// Fill all rows up to the same length.
- $layout = array();
+ $layout = [];
for ($row = 0; $row < $rows; ++$row) {
$cols = count($this->_layout[$row]);
if ($cols < $this->_columns) {
@@ -182,97 +183,98 @@ public function unserialize($data)
public function handle($action, $row, $col, $url = null)
{
switch ($action) {
- case 'moveUp':
- case 'moveDown':
- case 'moveLeft':
- case 'moveRight':
- case 'expandUp':
- case 'expandDown':
- case 'expandLeft':
- case 'expandRight':
- case 'shrinkLeft':
- case 'shrinkRight':
- case 'shrinkUp':
- case 'shrinkDown':
- case 'removeBlock':
- try {
- call_user_func(array($this, $action), $row, $col);
- $this->_updated = true;
- } catch (Horde_Exception $e) {
- $GLOBALS['notification']->push($e);
- }
- break;
-
- // Save the changes made to a block.
- case 'save':
- // Save the changes made to a block and continue editing.
- case 'save-resume':
- // Check form token.
- $GLOBALS['session']->checkToken(Horde_Util::getFormData('token'));
-
- // Get requested block type.
- list($newapp, $newtype) = explode(':', Horde_Util::getFormData('app'));
-
- // Is this a new block?
- $new = false;
- if ($this->isEmpty($row, $col) ||
- !$this->rowExists($row) ||
- !$this->colExists($col)) {
- // Check permissions.
- $max_blocks = $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_blocks');
- if (($max_blocks !== true) &&
- ($max_blocks <= count($this))) {
- Horde::permissionDeniedError(
- 'horde',
- 'max_blocks',
- sprintf(Horde_Core_Translation::ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks)
- );
- break;
+ case 'moveUp':
+ case 'moveDown':
+ case 'moveLeft':
+ case 'moveRight':
+ case 'expandUp':
+ case 'expandDown':
+ case 'expandLeft':
+ case 'expandRight':
+ case 'shrinkLeft':
+ case 'shrinkRight':
+ case 'shrinkUp':
+ case 'shrinkDown':
+ case 'removeBlock':
+ try {
+ call_user_func([$this, $action], $row, $col);
+ $this->_updated = true;
+ } catch (Horde_Exception $e) {
+ $GLOBALS['notification']->push($e);
}
+ break;
- $new = true;
- // Make sure there is somewhere to put it.
- $this->addBlock($row, $col);
- }
+ // Save the changes made to a block.
+ case 'save':
+ // Save the changes made to a block and continue editing.
+ case 'save-resume':
+ // Check form token.
+ $GLOBALS['session']->checkToken(Horde_Util::getFormData('token'));
+
+ // Get requested block type.
+ [$newapp, $newtype] = explode(':', Horde_Util::getFormData('app'));
+
+ // Is this a new block?
+ $new = false;
+ if ($this->isEmpty($row, $col) ||
+ !$this->rowExists($row) ||
+ !$this->colExists($col)) {
+ // Check permissions.
+ $max_blocks = $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_blocks');
+ if (($max_blocks !== true) &&
+ ($max_blocks <= count($this))) {
+ Horde::permissionDeniedError(
+ 'horde',
+ 'max_blocks',
+ sprintf(Horde_Core_Translation::ngettext('You are not allowed to create more than %d block.', 'You are not allowed to create more than %d blocks.', $max_blocks), $max_blocks)
+ );
+ break;
+ }
- // Or an existing one?
- $exists = false;
- $changed = false;
- if (!$new) {
- // Get target block info.
- $info = $this->getBlockInfo($row, $col);
- $exists = $this->isBlock($row, $col);
- // Has a different block been selected?
- if ($exists &&
- ($info['app'] != $newapp ||
- $info['block'] != $newtype)) {
- $changed = true;
+ $new = true;
+ // Make sure there is somewhere to put it.
+ $this->addBlock($row, $col);
}
- }
- if ($new || $changed) {
- // Change app or type.
- $info = array('app' => $newapp,
- 'block' => $newtype);
- $params = $this->_collection->getParams($newapp, $newtype);
- foreach ($params as $newparam) {
- $info['params'][$newparam] = $this->_collection->getDefaultValue($newapp, $newtype, $newparam);
+ // Or an existing one?
+ $exists = false;
+ $changed = false;
+ if (!$new) {
+ // Get target block info.
+ $info = $this->getBlockInfo($row, $col);
+ $exists = $this->isBlock($row, $col);
+ // Has a different block been selected?
+ if ($exists &&
+ ($info['app'] != $newapp ||
+ $info['block'] != $newtype)) {
+ $changed = true;
+ }
+ }
+
+ if ($new || $changed) {
+ // Change app or type.
+ $info = ['app' => $newapp,
+ 'block' => $newtype];
+ $params = $this->_collection->getParams($newapp, $newtype);
+ foreach ($params as $newparam) {
+ $info['params'][$newparam] = $this->_collection->getDefaultValue($newapp, $newtype, $newparam);
+ }
+ $this->setBlockInfo($row, $col, $info);
+ } elseif ($exists) {
+ // Change values.
+ $this->setBlockInfo($row, $col, ['params' => Horde_Util::getFormData('params', [])]);
+ }
+ $this->_updated = true;
+ if ($action == 'save') {
+ break;
}
- $this->setBlockInfo($row, $col, $info);
- } elseif ($exists) {
- // Change values.
- $this->setBlockInfo($row, $col, array('params' => Horde_Util::getFormData('params', array())));
- }
- $this->_updated = true;
- if ($action == 'save') {
- break;
- }
- // Make a block the current block for editing.
- case 'edit':
- $this->_currentBlock = array($row, $col);
- $url = null;
- break;
+ // Make a block the current block for editing.
+ // no break
+ case 'edit':
+ $this->_currentBlock = [$row, $col];
+ $url = null;
+ break;
}
if (!empty($url)) {
@@ -316,9 +318,11 @@ public function getBlock($row, $col)
$this->_blocks[$row][$col] = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_BlockCollection')
->create()
- ->getBlock($field['app'],
- $field['params']['type2'],
- $field['params']['params']);
+ ->getBlock(
+ $field['app'],
+ $field['params']['type2'],
+ $field['params']['params']
+ );
}
return $this->_blocks[$row][$col];
@@ -341,7 +345,7 @@ public function getBlockAt($row, $col)
if ($this->isEmpty($row, $col)) {
return null;
} elseif (!$this->isCovered($row, $col)) {
- return array($row, $col);
+ return [$row, $col];
}
/* This is a covered field. */
@@ -349,14 +353,14 @@ public function getBlockAt($row, $col)
if (!$this->isCovered($test, $col) &&
!$this->isEmpty($test, $col) &&
$test + $this->getHeight($test, $col) - 1 == $row) {
- return array($test, $col);
+ return [$test, $col];
}
}
for ($test = $col - 1; $test >= 0; $test--) {
if (!$this->isCovered($row, $test) &&
!$this->isEmpty($test, $col) &&
$test + $this->getWidth($row, $test) - 1 == $col) {
- return array($row, $test);
+ return [$row, $test];
}
}
}
@@ -384,11 +388,11 @@ public function getBlockInfo($row, $col)
throw new Horde_Exception('No block exists at the requested position');
}
- return array(
+ return [
'app' => $this->_layout[$row][$col]['app'],
'block' => $this->_layout[$row][$col]['params']['type2'],
- 'params' => $this->_layout[$row][$col]['params']['params']
- );
+ 'params' => $this->_layout[$row][$col]['params']['params'],
+ ];
}
/**
@@ -404,7 +408,7 @@ public function getBlockInfo($row, $col)
*
* @throws Horde_Exception
*/
- public function setBlockInfo($row, $col, $info = array())
+ public function setBlockInfo($row, $col, $info = [])
{
if (!isset($this->_layout[$row][$col])) {
throw new Horde_Exception('No block exists at the requested position');
@@ -535,59 +539,59 @@ public function getControl($type, $row, $col)
$url = $this->getActionUrl($action, $row, $col);
switch ($type[0]) {
- case 'expand':
- $title = Horde_Core_Translation::t("Expand");
- $img = 'large_' . $type[1];
- break;
-
- case 'shrink':
- $title = Horde_Core_Translation::t("Shrink");
- $img = 'large_';
-
- switch ($type[1]) {
- case 'up':
- $img .= 'down';
+ case 'expand':
+ $title = Horde_Core_Translation::t('Expand');
+ $img = 'large_' . $type[1];
break;
- case 'down':
- $img .= 'up';
- break;
+ case 'shrink':
+ $title = Horde_Core_Translation::t('Shrink');
+ $img = 'large_';
- case 'left':
- $img .= 'right';
- break;
+ switch ($type[1]) {
+ case 'up':
+ $img .= 'down';
+ break;
- case 'right':
- $img .= 'left';
- break;
- }
- break;
+ case 'down':
+ $img .= 'up';
+ break;
- case 'move':
- switch ($type[1]) {
- case 'up':
- $title = Horde_Core_Translation::t("Move Up");
- break;
+ case 'left':
+ $img .= 'right';
+ break;
- case 'down':
- $title = Horde_Core_Translation::t("Move Down");
+ case 'right':
+ $img .= 'left';
+ break;
+ }
break;
- case 'left':
- $title = Horde_Core_Translation::t("Move Left");
- break;
+ case 'move':
+ switch ($type[1]) {
+ case 'up':
+ $title = Horde_Core_Translation::t('Move Up');
+ break;
- case 'right':
- $title = Horde_Core_Translation::t("Move Right");
- break;
- }
+ case 'down':
+ $title = Horde_Core_Translation::t('Move Down');
+ break;
- $img = $type[1];
- break;
+ case 'left':
+ $title = Horde_Core_Translation::t('Move Left');
+ break;
+
+ case 'right':
+ $title = Horde_Core_Translation::t('Move Right');
+ break;
+ }
+
+ $img = $type[1];
+ break;
}
return Horde::link($url, $title) .
- Horde_Themes_Image::tag('block/' . $img . '.png', array('alt' => $title)) . '';
+ Horde_Themes_Image::tag('block/' . $img . '.png', ['alt' => $title]) . '';
}
/**
@@ -673,11 +677,11 @@ public function addBlock($row, $col)
$this->addCol($col);
}
- $this->_layout[$row][$col] = array('app' => null,
+ $this->_layout[$row][$col] = ['app' => null,
'height' => 1,
'width' => 1,
- 'params' => array('type2' => null,
- 'params' => array()));
+ 'params' => ['type2' => null,
+ 'params' => []]];
}
/**
@@ -815,10 +819,20 @@ public function moveUp($row, $col)
$in_way[1] == $col &&
$this->getWidth($in_way[0], $in_way[1]) == $width) {
// We need to swap the blocks.
- $rec1 = Horde_Array::getRectangle($this->_layout, $row, $col,
- $this->getHeight($row, $col), $this->getWidth($row, $col));
- $rec2 = Horde_Array::getRectangle($this->_layout, $in_way[0], $in_way[1],
- $this->getHeight($in_way[0], $in_way[1]), $this->getWidth($in_way[0], $in_way[1]));
+ $rec1 = Horde_Array::getRectangle(
+ $this->_layout,
+ $row,
+ $col,
+ $this->getHeight($row, $col),
+ $this->getWidth($row, $col)
+ );
+ $rec2 = Horde_Array::getRectangle(
+ $this->_layout,
+ $in_way[0],
+ $in_way[1],
+ $this->getHeight($in_way[0], $in_way[1]),
+ $this->getWidth($in_way[0], $in_way[1])
+ );
for ($j = 0; $j < count($rec1); $j++) {
for ($k = 0; $k < count($rec1[$j]); $k++) {
$this->_layout[$in_way[0] + $j][$in_way[1] + $k] = $rec1[$j][$k];
@@ -879,10 +893,20 @@ public function moveDown($row, $col)
$in_way[1] == $col &&
$this->getWidth($in_way[0], $in_way[1]) == $width) {
// We need to swap the blocks.
- $rec1 = Horde_Array::getRectangle($this->_layout, $row, $col,
- $this->getHeight($row, $col), $this->getWidth($row, $col));
- $rec2 = Horde_Array::getRectangle($this->_layout, $in_way[0], $in_way[1],
- $this->getHeight($in_way[0], $in_way[1]), $this->getWidth($in_way[0], $in_way[1]));
+ $rec1 = Horde_Array::getRectangle(
+ $this->_layout,
+ $row,
+ $col,
+ $this->getHeight($row, $col),
+ $this->getWidth($row, $col)
+ );
+ $rec2 = Horde_Array::getRectangle(
+ $this->_layout,
+ $in_way[0],
+ $in_way[1],
+ $this->getHeight($in_way[0], $in_way[1]),
+ $this->getWidth($in_way[0], $in_way[1])
+ );
for ($j = 0; $j < count($rec2); $j++) {
for ($k = 0; $k < count($rec2[$j]); $k++) {
$this->_layout[$row + $j][$col + $k] = $rec2[$j][$k];
@@ -929,9 +953,9 @@ public function moveDown($row, $col)
*
* @return boolean True if all rows could be moved down.
*/
- function moveDownBelow($row)
+ public function moveDownBelow($row)
{
- $moved = array();
+ $moved = [];
for ($y = count($this->_layout) - 1; $y > $row; $y--) {
for ($x = 0; $x < $this->_columns; $x++) {
$block = $this->getBlockAt($y, $x);
@@ -972,10 +996,20 @@ public function moveLeft($row, $col)
$in_way[0] == $row &&
$this->getHeight($in_way[0], $in_way[1]) == $height) {
// We need to swap the blocks.
- $rec1 = Horde_Array::getRectangle($this->_layout, $row, $col,
- $this->getHeight($row, $col), $this->getWidth($row, $col));
- $rec2 = Horde_Array::getRectangle($this->_layout, $in_way[0], $in_way[1],
- $this->getHeight($in_way[0], $in_way[1]), $this->getWidth($in_way[0], $in_way[1]));
+ $rec1 = Horde_Array::getRectangle(
+ $this->_layout,
+ $row,
+ $col,
+ $this->getHeight($row, $col),
+ $this->getWidth($row, $col)
+ );
+ $rec2 = Horde_Array::getRectangle(
+ $this->_layout,
+ $in_way[0],
+ $in_way[1],
+ $this->getHeight($in_way[0], $in_way[1]),
+ $this->getWidth($in_way[0], $in_way[1])
+ );
for ($j = 0; $j < count($rec1); $j++) {
for ($k = 0; $k < count($rec1[$j]); $k++) {
$this->_layout[$in_way[0] + $j][$in_way[1] + $k] = $rec1[$j][$k];
@@ -1039,10 +1073,20 @@ public function moveRight($row, $col)
$in_way[0] == $row &&
$this->getHeight($in_way[0], $in_way[1]) == $height) {
// We need to swap the blocks.
- $rec1 = Horde_Array::getRectangle($this->_layout, $row, $col,
- $this->getHeight($row, $col), $this->getWidth($row, $col));
- $rec2 = Horde_Array::getRectangle($this->_layout, $in_way[0], $in_way[1],
- $this->getHeight($in_way[0], $in_way[1]), $this->getWidth($in_way[0], $in_way[1]));
+ $rec1 = Horde_Array::getRectangle(
+ $this->_layout,
+ $row,
+ $col,
+ $this->getHeight($row, $col),
+ $this->getWidth($row, $col)
+ );
+ $rec2 = Horde_Array::getRectangle(
+ $this->_layout,
+ $in_way[0],
+ $in_way[1],
+ $this->getHeight($in_way[0], $in_way[1]),
+ $this->getWidth($in_way[0], $in_way[1])
+ );
for ($j = 0; $j < count($rec2); $j++) {
for ($k = 0; $k < count($rec2[$j]); $k++) {
$this->_layout[$row + $j][$col + $k] = $rec2[$j][$k];
@@ -1091,7 +1135,7 @@ public function moveRight($row, $col)
*/
public function moveRightAfter($col)
{
- $moved = array();
+ $moved = [];
for ($x = $this->_columns - 1; $x > $col; $x--) {
for ($y = 0; $y < count($this->_layout); $y++) {
$block = $this->getBlockAt($y, $x);
diff --git a/lib/Horde/Core/Block/Layout/View.php b/lib/Horde/Core/Block/Layout/View.php
index a67e8bfc3..0ba209e9c 100644
--- a/lib/Horde/Core/Block/Layout/View.php
+++ b/lib/Horde/Core/Block/Layout/View.php
@@ -1,4 +1,5 @@
';
$bc = $GLOBALS['injector']->getInstance('Horde_Core_Factory_BlockCollection')->create();
- $covered = array();
- $js = array();
+ $covered = [];
+ $js = [];
foreach ($this->_layout as $row_num => $row) {
$width = floor(100 / count($row));
$html .= '
';
@@ -87,7 +88,7 @@ public function toHtml()
$colspan = $item['width'];
for ($i = 0; $i < $item['height']; $i++) {
if (!isset($covered[$row_num + $i])) {
- $covered[$row_num + $i] = array();
+ $covered[$row_num + $i] = [];
}
for ($j = 0; $j < $item['width']; $j++) {
$covered[$row_num + $i][$col_num + $j] = true;
@@ -104,9 +105,8 @@ public function toHtml()
if ($block->updateable &&
$GLOBALS['browser']->hasFeature('xmlhttpreq')) {
- $refresh_time = isset($item['params']['params']['_refresh_time'])
- ? $item['params']['params']['_refresh_time']
- : $interval;
+ $refresh_time = $item['params']['params']['_refresh_time']
+ ?? $interval;
if (!empty($refresh_time)) {
$js[] = 'HordeBlocks.addUpdateableBlock(' .
@@ -120,7 +120,7 @@ public function toHtml()
$html .= '| | ';
}
} catch (Horde_Exception $e) {
- $header = Horde_Core_Translation::t("Error");
+ $header = Horde_Core_Translation::t('Error');
$content = $e->getMessage();
ob_start();
include $tplDir . '/portal/block.inc';
@@ -155,15 +155,15 @@ public function getApplications()
public function getStylesheets()
{
$css = $GLOBALS['injector']->getInstance('Horde_PageOutput')->css;
- $stylesheets = array();
+ $stylesheets = [];
foreach ($this->getApplications() as $app) {
- $app_css = $css->getStylesheets('', array(
+ $app_css = $css->getStylesheets('', [
'app' => $app,
'nohorde' => !in_array('horde', $this->getApplications()),
'sub' => 'block',
- 'subonly' => true
- ));
+ 'subonly' => true,
+ ]);
if (!empty($app_css)) {
$stylesheets = array_merge($stylesheets, $app_css);
diff --git a/lib/Horde/Core/Block/Upgrade.php b/lib/Horde/Core/Block/Upgrade.php
index 7830160f0..3f0933956 100644
--- a/lib/Horde/Core/Block/Upgrade.php
+++ b/lib/Horde/Core/Block/Upgrade.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Hooks')
- ->callHook('browser_modify', 'horde', array($this));
- } catch (Horde_Exception_HookNotSet $e) {}
+ ->callHook('browser_modify', 'horde', [$this]);
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
}
}
diff --git a/lib/Horde/Core/Bundle.php b/lib/Horde/Core/Bundle.php
index 91eee7563..9e6dcc4bc 100644
--- a/lib/Horde/Core/Bundle.php
+++ b/lib/Horde/Core/Bundle.php
@@ -1,4 +1,5 @@
true, 'authentication' => 'none'));
+ Horde_Registry::appInit('horde', ['nocompress' => true, 'authentication' => 'none']);
$this->_config = new Horde_Config();
umask($umask);
}
@@ -78,7 +79,8 @@ public function configDb()
$vars,
'sql',
'phptype',
- $sql_config['switch']['custom']['fields']['phptype']);
+ $sql_config['switch']['custom']['fields']['phptype']
+ );
$this->writeConfig($vars);
}
diff --git a/lib/Horde/Core/Cache/Session.php b/lib/Horde/Core/Cache/Session.php
index 63aaeed84..da023f4ad 100644
--- a/lib/Horde/Core/Cache/Session.php
+++ b/lib/Horde/Core/Cache/Session.php
@@ -1,4 +1,5 @@
'horde',
'maxsize' => 5000,
- 'storage_key' => 'sess_cache'
- ),
+ 'storage_key' => 'sess_cache',
+ ],
$params
));
}
@@ -148,7 +149,7 @@ public function clear()
foreach (array_keys($this->_stored) as $key) {
$this->_params['cache']->expire($key);
}
- $this->_stored = array();
+ $this->_stored = [];
$this->_saveStored();
}
@@ -162,11 +163,11 @@ protected function _getCid($key, $in_session)
return $this->_params['storage_key'] . '/' . $key;
}
- return implode('|', array(
+ return implode('|', [
$this->_params['app'],
$session->getToken(),
- $key
- ));
+ $key,
+ ]);
}
/**
diff --git a/lib/Horde/Core/Cache/SessionObjects.php b/lib/Horde/Core/Cache/SessionObjects.php
index 374addc9a..5b8a3cd09 100644
--- a/lib/Horde/Core/Cache/SessionObjects.php
+++ b/lib/Horde/Core/Cache/SessionObjects.php
@@ -1,4 +1,5 @@
'horde',
'cache' => new Horde_Cache_Storage_Null(),
/* Sanity checking. */
'maxsize' => 1048576,
- 'storage_key' => 'sess_obcache'
- ));
+ 'storage_key' => 'sess_obcache',
+ ]);
}
/**
diff --git a/lib/Horde/Core/Cli.php b/lib/Horde/Core/Cli.php
index f3ba9c9ce..c29583297 100644
--- a/lib/Horde/Core/Cli.php
+++ b/lib/Horde/Core/Cli.php
@@ -1,4 +1,5 @@
$case_field) {
$values[$case] = $case_field['desc'];
}
} else {
switch ($field['_type']) {
- case 'boolean':
- $values = array(true => 'Yes', false => 'No');
- $default = (int)$default;
- break;
- case 'enum':
- $values = $field['values'];
- break;
+ case 'boolean':
+ $values = [true => 'Yes', false => 'No'];
+ $default = (int)$default;
+ break;
+ case 'enum':
+ $values = $field['values'];
+ break;
}
if (!empty($field['required'])) {
$question .= $this->red('*');
diff --git a/lib/Horde/Core/Controller/NotAuthorized.php b/lib/Horde/Core/Controller/NotAuthorized.php
index acc5f5b4f..8426db2e2 100644
--- a/lib/Horde/Core/Controller/NotAuthorized.php
+++ b/lib/Horde/Core/Controller/NotAuthorized.php
@@ -1,4 +1,5 @@
setHeader('HTTP/1.0 401 ', 'Not Authorized');
$response->setBody('401 Not Authorized401 Not Authorized
');
}
diff --git a/lib/Horde/Core/Controller/NotFound.php b/lib/Horde/Core/Controller/NotFound.php
index ec77d9d76..f55918d1f 100644
--- a/lib/Horde/Core/Controller/NotFound.php
+++ b/lib/Horde/Core/Controller/NotFound.php
@@ -1,4 +1,5 @@
setHeader('HTTP/1.0 404 ', 'Not Found');
$response->setBody('404 File Not Found404 File Not Found
');
}
diff --git a/lib/Horde/Core/Controller/RequestConfiguration.php b/lib/Horde/Core/Controller/RequestConfiguration.php
index de05b65b9..980edbe97 100644
--- a/lib/Horde/Core/Controller/RequestConfiguration.php
+++ b/lib/Horde/Core/Controller/RequestConfiguration.php
@@ -1,4 +1,5 @@
_classNames = array(
+ $this->_classNames = [
'controller' => 'Horde_Core_Controller_NotFound',
'settings' => 'Horde_Controller_SettingsExporter_Default',
- );
+ ];
}
/**
diff --git a/lib/Horde/Core/Controller/RequestMapper.php b/lib/Horde/Core/Controller/RequestMapper.php
index baca01425..990281c13 100644
--- a/lib/Horde/Core/Controller/RequestMapper.php
+++ b/lib/Horde/Core/Controller/RequestMapper.php
@@ -1,4 +1,5 @@
listApps(null, false, null) as $app)
- {
+ foreach ($registry->listApps(null, false, null) as $app) {
$default = [
'scheme' => $scheme,
'host' => $host,
'path' => '',
- 'app' => $app
+ 'app' => $app,
];
$applicationUrl = array_merge($default, parse_url($registry->get('webroot', $app)));
$applicationUrl['path'] = $this->_normalize($applicationUrl['path']);
// sort out cases with wrong host or scheme
- if ($scheme != $applicationUrl['scheme']) { continue; }
- if ($host != $applicationUrl['host']) { continue; }
+ if ($scheme != $applicationUrl['scheme']) {
+ continue;
+ }
+ if ($host != $applicationUrl['host']) {
+ continue;
+ }
// does the path match at all?
- if (substr($request->getPath(),0, strlen($applicationUrl['path'])) == $applicationUrl['path']) {
+ if (substr($request->getPath(), 0, strlen($applicationUrl['path'])) == $applicationUrl['path']) {
$matches[] = $applicationUrl;
}
}
@@ -125,10 +129,11 @@ protected function _identifyApp($scheme, $request, $host, $registry)
return $matches;
}
// Longest match path *should* always be the right app
- usort($matches, function($a, $b)
- {
- return strlen($a['path']) <=> strlen($b['path']);
- }
+ usort(
+ $matches,
+ function ($a, $b) {
+ return strlen($a['path']) <=> strlen($b['path']);
+ }
);
return array_pop($matches);
}
@@ -193,7 +198,7 @@ public function getRequestConfiguration(Horde_Injector $injector)
// Load application routes.
$mapper = $this->_mapper;
- $mapper->environ = array('REQUEST_METHOD' => $request->getMethod());
+ $mapper->environ = ['REQUEST_METHOD' => $request->getMethod()];
include $routeFile;
if (file_exists($fileroot . '/config/routes.local.php')) {
include $fileroot . '/config/routes.local.php';
diff --git a/lib/Horde/Core/Controller/SettingsFinder.php b/lib/Horde/Core/Controller/SettingsFinder.php
index 0f837077d..408b2880d 100644
--- a/lib/Horde/Core/Controller/SettingsFinder.php
+++ b/lib/Horde/Core/Controller/SettingsFinder.php
@@ -1,4 +1,5 @@
getAuth(),
- $key
- ));
+ $key,
+ ]);
}
}
diff --git a/lib/Horde/Core/Dav/Auth.php b/lib/Horde/Core/Dav/Auth.php
index 573261ceb..a0bafbb8c 100644
--- a/lib/Horde/Core/Dav/Auth.php
+++ b/lib/Horde/Core/Dav/Auth.php
@@ -1,4 +1,5 @@
_auth->getCredential('userId');
try {
$user = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
- ->callHook('davusername', 'horde', array($user, false));
+ ->callHook('davusername', 'horde', [$user, false]);
} catch (Horde_Exception_HookNotSet $e) {
}
return $user;
diff --git a/lib/Horde/Core/Db/Migration.php b/lib/Horde/Core/Db/Migration.php
index f89fc4716..b95805ab2 100644
--- a/lib/Horde/Core/Db/Migration.php
+++ b/lib/Horde/Core/Db/Migration.php
@@ -1,4 +1,5 @@
getRegistry();
foreach (glob($pear->get('data_dir') . '/*/migration') as $dir) {
$package = $registry->getPackage(
- basename(dirname($dir)), 'pear.horde.org');
+ basename(dirname($dir)),
+ 'pear.horde.org'
+ );
if ($package == false) {
Horde::log("Ignoring package in directory $dir", Horde_Log::WARN);
continue;
@@ -156,16 +159,16 @@ public function __construct($basedir = null, $pearconf = null)
*
* @return Horde_Db_Migration_Migrator A migrator for the specified module.
*/
- public function getMigrator($app, Horde_Log_Logger $logger = null)
+ public function getMigrator($app, ?Horde_Log_Logger $logger = null)
{
$app = Horde_String::lower($app);
$db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
return new Horde_Db_Migration_Migrator(
$db,
$logger,
- array(
+ [
'migrationsPath' => $this->dirs[array_search($app, $this->_lower)],
- 'schemaTableName' => $db->tableAliasFor($app . '_schema_info'))
- );
+ 'schemaTableName' => $db->tableAliasFor($app . '_schema_info')]
+ );
}
}
diff --git a/lib/Horde/Core/Editor/Ckeditor.php b/lib/Horde/Core/Editor/Ckeditor.php
index 258fbee4e..e9b714e99 100644
--- a/lib/Horde/Core/Editor/Ckeditor.php
+++ b/lib/Horde/Core/Editor/Ckeditor.php
@@ -1,4 +1,5 @@
$registry);
- $adapter_params = array('factory' => new Horde_Core_ActiveSync_Imap_Factory());
+ $params = ['registry' => $registry];
+ $adapter_params = ['factory' => new Horde_Core_ActiveSync_Imap_Factory()];
// Force emailsync to off if we don't have a mail API.
if (!$registry->hasInterface('mail')) {
$conf['activesync']['emailsync'] = false;
}
- $driver_params = array(
+ $driver_params = [
'connector' => new Horde_Core_ActiveSync_Connector($params),
'imap' => !empty($conf['activesync']['emailsync'])
? new Horde_ActiveSync_Imap_Adapter($adapter_params)
@@ -26,7 +27,7 @@ public function create(Horde_Injector $injector)
'ping' => $conf['activesync']['ping'],
'state' => $injector->getInstance('Horde_ActiveSyncState'),
'auth' => $this->_getAuth(),
- 'cache' => $injector->getInstance('Horde_Cache'));
+ 'cache' => $injector->getInstance('Horde_Cache')];
return new Horde_Core_ActiveSync_Driver($driver_params);
}
@@ -40,9 +41,9 @@ protected function _getAuth()
{
global $conf, $injector;
- $params = array(
+ $params = [
'base_driver' => $injector->getInstance('Horde_Core_Factory_Auth')->create(),
- );
+ ];
if ($conf['activesync']['auth']['type'] != 'basic') {
$x_params = $conf['activesync']['auth']['params'];
diff --git a/lib/Horde/Core/Factory/ActiveSyncServer.php b/lib/Horde/Core/Factory/ActiveSyncServer.php
index 53cd5bc08..87ab585f9 100644
--- a/lib/Horde/Core/Factory/ActiveSyncServer.php
+++ b/lib/Horde/Core/Factory/ActiveSyncServer.php
@@ -1,4 +1,5 @@
setLogger(new Horde_ActiveSync_Log_Factory(array(
+ $server->setLogger(
+ new Horde_ActiveSync_Log_Factory([
'type' => $conf['activesync']['logging']['type'],
'path' => !empty($conf['activesync']['logging']['path'])
? $conf['activesync']['logging']['path']
: '',
- 'level' => $level))
+ 'level' => $level])
);
if (!empty($conf['openssl']['cafile'])) {
$server->setRootCertificatePath($conf['openssl']['cafile']);
diff --git a/lib/Horde/Core/Factory/ActiveSyncState.php b/lib/Horde/Core/Factory/ActiveSyncState.php
index 123309387..c7b1f9767 100644
--- a/lib/Horde/Core/Factory/ActiveSyncState.php
+++ b/lib/Horde/Core/Factory/ActiveSyncState.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Nosql')->create('horde', 'activesync');
- return new Horde_ActiveSync_State_Mongo(array(
- 'connection' => $nosql
- ));
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'activesync');
+ return new Horde_ActiveSync_State_Mongo([
+ 'connection' => $nosql,
+ ]);
- case 'sql':
- return new Horde_ActiveSync_State_Sql(array(
- 'db' => $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'activesync')
- ));
+ case 'sql':
+ return new Horde_ActiveSync_State_Sql([
+ 'db' => $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'activesync'),
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/Ajax.php b/lib/Horde/Core/Factory/Ajax.php
index f5b8af61c..5806dad4f 100644
--- a/lib/Horde/Core/Factory/Ajax.php
+++ b/lib/Horde/Core/Factory/Ajax.php
@@ -1,4 +1,5 @@
_injector
- ->getInstance('Horde_Core_Factory_Db')
- ->create('horde', 'alarms');
- } catch (Horde_Exception $e) {
- $driver = 'null';
- $params = Horde::getDriverConfig('alarms', $driver);
- }
- break;
+ case 'sql':
+ try {
+ $params['db'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', 'alarms');
+ } catch (Horde_Exception $e) {
+ $driver = 'null';
+ $params = Horde::getDriverConfig('alarms', $driver);
+ }
+ break;
}
$params['logger'] = $this->_injector->getInstance('Horde_Log_Logger');
- $params['loader'] = array($this, 'load');
+ $params['loader'] = [$this, 'load'];
- $this->_ttl = isset($params['ttl'])
- ? $params['ttl']
- : 300;
+ $this->_ttl = $params['ttl']
+ ?? 300;
$class = $this->_getDriverName($driver, 'Horde_Alarm');
$this->_alarm = new $class($params);
@@ -92,21 +92,21 @@ public function create()
$this->_alarm->addHandler(
'desktop',
- new Horde_Core_Alarm_Handler_Desktop(array(
+ new Horde_Core_Alarm_Handler_Desktop([
'icon' => new Horde_Core_Alarm_Handler_Desktop_Icon('alerts/alarm.png'),
- 'js_notify' => array(
+ 'js_notify' => [
$this->_injector->getInstance('Horde_PageOutput'),
- 'addInlineScript'
- )
- ))
+ 'addInlineScript',
+ ],
+ ])
);
$this->_alarm->addHandler(
'mail',
- new Horde_Alarm_Handler_Mail(array(
+ new Horde_Alarm_Handler_Mail([
'identity' => $this->_injector->getInstance('Horde_Core_Factory_Identity'),
'mail' => $this->_injector->getInstance('Horde_Mail'),
- ))
+ ])
);
return $this->_alarm;
@@ -138,13 +138,13 @@ public function load($user = null, $preload = true)
$cache = $session->get('horde', 'factory_alarm');
if (is_null($cache)) {
- $save = array();
+ $save = [];
$changed = ($registry->getAuth() !== false);
try {
$apps = $registry->listApps(null, false, Horde_Perms::READ);
} catch (Horde_Exception $e) {
- $apps = array();
+ $apps = [];
}
} else {
$apps = $cache;
@@ -165,10 +165,11 @@ public function load($user = null, $preload = true)
: time();
try {
- foreach ($registry->callAppMethod($app, 'listAlarms', array('args' => array($time, $user), 'noperms' => true)) as $alarm) {
+ foreach ($registry->callAppMethod($app, 'listAlarms', ['args' => [$time, $user], 'noperms' => true]) as $alarm) {
$this->_alarm->set($alarm, true);
}
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
}
if ($changed) {
diff --git a/lib/Horde/Core/Factory/Auth.php b/lib/Horde/Core/Factory/Auth.php
index 6a582fb8b..b38e7cfff 100644
--- a/lib/Horde/Core/Factory/Auth.php
+++ b/lib/Horde/Core/Factory/Auth.php
@@ -1,4 +1,5 @@
_instances[$app])) {
- $this->_instances[$app] = new Horde_Core_Auth_Application(array_filter(array(
+ $this->_instances[$app] = new Horde_Core_Auth_Application(array_filter([
'app' => $app,
'base' => ($app === 'horde') ? $this->_create($GLOBALS['conf']['auth']['driver']) : null,
- 'logger' => $this->_injector->getInstance('Horde_Log_Logger')
- )));
+ 'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
+ ]));
}
return $this->_instances[$app];
@@ -98,78 +99,78 @@ protected function _create($driver, $orig_params = null)
$lc_driver = Horde_String::lower($driver);
switch ($lc_driver) {
- case 'horde_core_auth_composite':
- // Both of these params are required, but we need to skip if
- // non-existent to return a useful error message later.
- if (!empty($params['admin_driver'])) {
- $params['admin_driver'] = $this->_create($params['admin_driver']['driver'], $params['admin_driver']['params']);
- }
- if (!empty($params['auth_driver'])) {
- $params['auth_driver'] = $this->_create($params['auth_driver']['driver'], $params['auth_driver']['params']);
- }
- break;
-
- case 'horde_auth_cyrsql':
- $imap_config = array(
- 'hostspec' => empty($params['cyrhost']) ? null : $params['cyrhost'],
- 'password' => $params['cyrpass'],
- 'port' => empty($params['cyrport']) ? null : $params['cyrport'],
- 'secure' => ($params['secure'] == 'none') ? null : $params['secure'],
- 'username' => $params['cyradmin'],
- );
-
- try {
- $ob = new Horde_Imap_Client_Socket($imap_config);
- $ob->login();
- $params['imap'] = $ob;
- } catch (Horde_Imap_Client_Exception $e) {
- throw new Horde_Auth_Exception($e);
- }
-
- $params['db'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Db')
- ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
- break;
-
- case 'horde_auth_http_remote':
- $params['client'] = $this->_injector->getInstance('Horde_Core_Factory_HttpClient')->create();
- break;
-
- case 'horde_core_auth_application':
- if (isset($this->_instances[$params['app']])) {
- return $this->_instances[$params['app']];
- }
- break;
-
- case 'horde_core_auth_imsp':
- $params['imsp'] = $this->_injector->getInstance('Horde_Core_Factory_Imsp')->create();
- break;
-
- case 'horde_auth_kolab':
- $params['kolab'] = $this->_injector
- ->getInstance('Horde_Kolab_Session');
- break;
-
- case 'horde_core_auth_ldap':
- case 'horde_core_auth_msad':
- $params['ldap'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Ldap')
- ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
- break;
- case 'horde_core_auth_x509':
- if (!empty($params['password_source']) && $params['password_source'] == 'unified') {
- $params['password'] = $params['unified_password'];
- unset($params['password_source'], $params['unified_password']);
- }
- // @TODO: Add filters
- break;
-
- case 'horde_auth_customsql':
- case 'horde_auth_sql':
- $params['db'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Db')
- ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
- break;
+ case 'horde_core_auth_composite':
+ // Both of these params are required, but we need to skip if
+ // non-existent to return a useful error message later.
+ if (!empty($params['admin_driver'])) {
+ $params['admin_driver'] = $this->_create($params['admin_driver']['driver'], $params['admin_driver']['params']);
+ }
+ if (!empty($params['auth_driver'])) {
+ $params['auth_driver'] = $this->_create($params['auth_driver']['driver'], $params['auth_driver']['params']);
+ }
+ break;
+
+ case 'horde_auth_cyrsql':
+ $imap_config = [
+ 'hostspec' => empty($params['cyrhost']) ? null : $params['cyrhost'],
+ 'password' => $params['cyrpass'],
+ 'port' => empty($params['cyrport']) ? null : $params['cyrport'],
+ 'secure' => ($params['secure'] == 'none') ? null : $params['secure'],
+ 'username' => $params['cyradmin'],
+ ];
+
+ try {
+ $ob = new Horde_Imap_Client_Socket($imap_config);
+ $ob->login();
+ $params['imap'] = $ob;
+ } catch (Horde_Imap_Client_Exception $e) {
+ throw new Horde_Auth_Exception($e);
+ }
+
+ $params['db'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
+ break;
+
+ case 'horde_auth_http_remote':
+ $params['client'] = $this->_injector->getInstance('Horde_Core_Factory_HttpClient')->create();
+ break;
+
+ case 'horde_core_auth_application':
+ if (isset($this->_instances[$params['app']])) {
+ return $this->_instances[$params['app']];
+ }
+ break;
+
+ case 'horde_core_auth_imsp':
+ $params['imsp'] = $this->_injector->getInstance('Horde_Core_Factory_Imsp')->create();
+ break;
+
+ case 'horde_auth_kolab':
+ $params['kolab'] = $this->_injector
+ ->getInstance('Horde_Kolab_Session');
+ break;
+
+ case 'horde_core_auth_ldap':
+ case 'horde_core_auth_msad':
+ $params['ldap'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Ldap')
+ ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
+ break;
+ case 'horde_core_auth_x509':
+ if (!empty($params['password_source']) && $params['password_source'] == 'unified') {
+ $params['password'] = $params['unified_password'];
+ unset($params['password_source'], $params['unified_password']);
+ }
+ // @TODO: Add filters
+ break;
+
+ case 'horde_auth_customsql':
+ case 'horde_auth_sql':
+ $params['db'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', is_null($orig_params) ? 'auth' : $orig_params);
+ break;
}
$params['default_user'] = $GLOBALS['registry']->getAuth();
diff --git a/lib/Horde/Core/Factory/AuthSignup.php b/lib/Horde/Core/Factory/AuthSignup.php
index c218e9098..ecb49d37d 100644
--- a/lib/Horde/Core/Factory/AuthSignup.php
+++ b/lib/Horde/Core/Factory/AuthSignup.php
@@ -1,4 +1,5 @@
listApps()
: array_intersect($registry->listApps(), $apps);
sort($apps);
- $sig = hash('md5', json_encode(array($apps, $layout)));
+ $sig = hash('md5', json_encode([$apps, $layout]));
if (!isset($this->_instances[$sig])) {
$this->_instances[$sig] =
diff --git a/lib/Horde/Core/Factory/Browser.php b/lib/Horde/Core/Factory/Browser.php
index 88d543d36..37d27f26e 100644
--- a/lib/Horde/Core/Factory/Browser.php
+++ b/lib/Horde/Core/Factory/Browser.php
@@ -1,4 +1,5 @@
true,
- 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper')
- );
+ 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper'),
+ ];
if (isset($conf['cache']['default_lifetime'])) {
$params['lifetime'] = $conf['cache']['default_lifetime'];
}
@@ -56,50 +57,50 @@ public function create(Horde_Injector $injector)
$sparams = Horde::getDriverConfig('cache', $driver);
switch ($driver) {
- case 'hashtable':
- // DEPRECATED
- case 'memcache':
- $sparams['hashtable'] = $injector->getInstance('Horde_Core_HashTable_Wrapper');
- $driver = 'Horde_Cache_Storage_Hashtable';
- unset($sparams['driverconfig'], $sparams['umask']);
- break;
-
- case 'nosql':
- $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache');
- if ($nosql instanceof Horde_Mongo_Client) {
- $sparams['mongo_db'] = $nosql;
- $driver = 'Horde_Cache_Storage_Mongo';
- } else {
- $driver = 'Horde_Cache_Storage_Null';
- }
- unset($sparams['driverconfig'], $sparams['umask']);
- break;
+ case 'hashtable':
+ // DEPRECATED
+ case 'memcache':
+ $sparams['hashtable'] = $injector->getInstance('Horde_Core_HashTable_Wrapper');
+ $driver = 'Horde_Cache_Storage_Hashtable';
+ unset($sparams['driverconfig'], $sparams['umask']);
+ break;
+
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $sparams['mongo_db'] = $nosql;
+ $driver = 'Horde_Cache_Storage_Mongo';
+ } else {
+ $driver = 'Horde_Cache_Storage_Null';
+ }
+ unset($sparams['driverconfig'], $sparams['umask']);
+ break;
- case 'sql':
- $sparams['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'cache');
- unset($sparams['driverconfig'], $sparams['umask']);
- break;
+ case 'sql':
+ $sparams['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'cache');
+ unset($sparams['driverconfig'], $sparams['umask']);
+ break;
}
$storage = $this->storage = $this->_getStorage($driver, $sparams);
if (!empty($conf['cache']['use_memorycache']) &&
- in_array($driver, array('file', 'sql'))) {
+ in_array($driver, ['file', 'sql'])) {
switch (Horde_String::lower($conf['cache']['use_memorycache'])) {
- case 'hashtable':
- case 'memcache':
- $storage = new Horde_Cache_Storage_Stack(array(
- 'stack' => array(
- $this->_getStorage(
- $conf['cache']['use_memorycache'],
- array(
- 'hashtable' => $injector->getInstance('Horde_Core_HashTable_Wrapper')
- )
- ),
- $storage
- )
- ));
- break;
+ case 'hashtable':
+ case 'memcache':
+ $storage = new Horde_Cache_Storage_Stack([
+ 'stack' => [
+ $this->_getStorage(
+ $conf['cache']['use_memorycache'],
+ [
+ 'hashtable' => $injector->getInstance('Horde_Core_HashTable_Wrapper'),
+ ]
+ ),
+ $storage,
+ ],
+ ]);
+ break;
}
}
@@ -122,15 +123,15 @@ public function getDriverName()
: Horde_String::lower($conf['cache']['driver']);
switch ($driver) {
- case 'none':
- $driver = 'null';
- break;
-
- case 'xcache':
- if (Horde_Cli::runningFromCLI()) {
+ case 'none':
$driver = 'null';
- }
- break;
+ break;
+
+ case 'xcache':
+ if (Horde_Cli::runningFromCLI()) {
+ $driver = 'null';
+ }
+ break;
}
return $driver;
diff --git a/lib/Horde/Core/Factory/Crypt.php b/lib/Horde/Core/Factory/Crypt.php
index 385baef1c..677cdae81 100644
--- a/lib/Horde/Core/Factory/Crypt.php
+++ b/lib/Horde/Core/Factory/Crypt.php
@@ -1,4 +1,5 @@
$registry->getEmailCharset(),
- 'temp' => Horde::getTempDir()
- ), $params);
+ 'temp' => Horde::getTempDir(),
+ ], $params);
return Horde_Crypt::factory($driver, $params);
}
diff --git a/lib/Horde/Core/Factory/CssCache.php b/lib/Horde/Core/Factory/CssCache.php
index 924883fc5..3fcfa69f9 100644
--- a/lib/Horde/Core/Factory/CssCache.php
+++ b/lib/Horde/Core/Factory/CssCache.php
@@ -1,4 +1,5 @@
_getDriverName($driver, 'Horde_Data');
$params['browser'] = $this->_injector->getInstance('Horde_Browser');
$params['vars'] = $this->_injector->getInstance('Horde_Variables');
$params['http'] = $this->_injector
->getInstance('Horde_Core_Factory_HttpClient')
- ->create(array('request.verifyPeer' => false));
+ ->create(['request.verifyPeer' => false]);
return new $class($this->_injector->getInstance('Horde_Core_Data_Storage'), $params);
}
diff --git a/lib/Horde/Core/Factory/DavServer.php b/lib/Horde/Core/Factory/DavServer.php
index f7686c4b1..8dcde963c 100644
--- a/lib/Horde/Core/Factory/DavServer.php
+++ b/lib/Horde/Core/Factory/DavServer.php
@@ -1,4 +1,5 @@
$injector
->getInstance('Horde_Core_Factory_Auth')
- ->create()
- )
+ ->create(),
+ ]
),
$injector->getInstance('Horde_Core_Factory_Identity_DavUsernameHook')
);
@@ -51,8 +52,8 @@ public function create(Horde_Injector $injector)
$server = new DAV\Server(
new Horde_Dav_RootCollection(
$registry,
- array($principals, $caldav, $carddav),
- isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null
+ [$principals, $caldav, $carddav],
+ $conf['mime']['magic_db'] ?? null
)
);
$server->debugExceptions = false;
@@ -64,7 +65,7 @@ public function create(Horde_Injector $injector)
if (!empty($conf['dav_root'])) {
$candidates = explode(';', $conf['dav_root']);
// Ensure longer hits overrule shorter hits regardless of input order
- usort($candidates, function($a, $b) { return strlen($a) <=> strlen($b);});
+ usort($candidates, function ($a, $b) { return strlen($a) <=> strlen($b);});
foreach ($candidates as $davBaseTest) {
if (!empty($_SERVER['REQUEST_URI']) && (strpos($_SERVER['REQUEST_URI'], $davBaseTest) === 0)) {
$davBaseUri = $davBaseTest;
diff --git a/lib/Horde/Core/Factory/DavStorage.php b/lib/Horde/Core/Factory/DavStorage.php
index 208800a0f..afd6e7e1e 100644
--- a/lib/Horde/Core/Factory/DavStorage.php
+++ b/lib/Horde/Core/Factory/DavStorage.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Db')
- ->create('horde', 'davstorage');
- break;
+ case 'Sql':
+ $class = 'Horde_Dav_Storage_Sql';
+ $params['db'] = $injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', 'davstorage');
+ break;
- default:
- throw new Horde_Exception('A storage backend for DAV has not been configured.');
- break;
+ default:
+ throw new Horde_Exception('A storage backend for DAV has not been configured.');
+ break;
}
return new $class($params);
diff --git a/lib/Horde/Core/Factory/Db.php b/lib/Horde/Core/Factory/Db.php
index 991b353a2..9cc1003ef 100644
--- a/lib/Horde/Core/Factory/Db.php
+++ b/lib/Horde/Core/Factory/Db.php
@@ -1,4 +1,5 @@
_instances[$sig])) {
try {
$this->_createDb($config, $sig);
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
}
if ($pushed) {
@@ -161,23 +163,23 @@ protected function _createDb($config, $sig = null, $cache = true)
throw new Horde_Exception('The database configuration is missing.');
} else {
switch ($config['phptype']) {
- case 'mysqli':
- $class = 'Horde_Db_Adapter_Mysqli';
- break;
-
- case 'mysql':
- $class = extension_loaded('pdo_mysql')
- ? 'Horde_Db_Adapter_Pdo_Mysql'
- : 'Horde_Db_Adapter_Mysql';
- break;
-
- case 'oci8':
- $class = 'Horde_Db_Adapter_Oci8';
- break;
-
- default:
- $class = 'Horde_Db_Adapter_Pdo_' . Horde_String::ucfirst($config['phptype']);
- break;
+ case 'mysqli':
+ $class = 'Horde_Db_Adapter_Mysqli';
+ break;
+
+ case 'mysql':
+ $class = extension_loaded('pdo_mysql')
+ ? 'Horde_Db_Adapter_Pdo_Mysql'
+ : 'Horde_Db_Adapter_Mysql';
+ break;
+
+ case 'oci8':
+ $class = 'Horde_Db_Adapter_Oci8';
+ break;
+
+ default:
+ $class = 'Horde_Db_Adapter_Pdo_' . Horde_String::ucfirst($config['phptype']);
+ break;
}
}
diff --git a/lib/Horde/Core/Factory/DbBase.php b/lib/Horde/Core/Factory/DbBase.php
index 0df0550cf..2f0efa3dd 100644
--- a/lib/Horde/Core/Factory/DbBase.php
+++ b/lib/Horde/Core/Factory/DbBase.php
@@ -1,4 +1,5 @@
!empty($config['persistent']),
- 'ssl' => !empty($config['ssl'])
- ));
+ 'ssl' => !empty($config['ssl']),
+ ]);
if ($db instanceof PEAR_Error) {
if ($pushed) {
diff --git a/lib/Horde/Core/Factory/Dns.php b/lib/Horde/Core/Factory/Dns.php
index 8a0f4fca2..d68b0415a 100644
--- a/lib/Horde/Core/Factory/Dns.php
+++ b/lib/Horde/Core/Factory/Dns.php
@@ -1,4 +1,5 @@
$tmpdir . '/horde_dns.cache' . gethostname(),
'cache_size' => 100000,
'cache_type' => 'file',
- );
+ ];
} else {
- $config = array();
+ $config = [];
}
$resolver = new Net_DNS2_Resolver($config);
@@ -26,7 +27,8 @@ public function create(Horde_Injector $injector)
if (is_readable('/etc/resolv.conf')) {
try {
$resolver->setServers('/etc/resolv.conf');
- } catch (Net_DNS2_Exception $e) {}
+ } catch (Net_DNS2_Exception $e) {
+ }
}
return $resolver;
diff --git a/lib/Horde/Core/Factory/Editor.php b/lib/Horde/Core/Factory/Editor.php
index 7f3b55df0..4f6787255 100644
--- a/lib/Horde/Core/Factory/Editor.php
+++ b/lib/Horde/Core/Factory/Editor.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Core_Factory_HttpClient')->create(),
- 'http_request' => $injector->getInstance('Horde_Controller_Request_Http')
- )
+ 'http_request' => $injector->getInstance('Horde_Controller_Request_Http'),
+ ]
);
/* Check for facebook session */
diff --git a/lib/Horde/Core/Factory/Group.php b/lib/Horde/Core/Factory/Group.php
index a8ad17c0a..6d8e6306e 100644
--- a/lib/Horde/Core/Factory/Group.php
+++ b/lib/Horde/Core/Factory/Group.php
@@ -1,4 +1,5 @@
contacts;
- break;
-
- case 'Kolab':
- $class = 'Horde_Group_Kolab';
- $params['ldap'] = $injector
- ->getInstance('Horde_Core_Factory_Ldap')
- ->create('horde', 'group');
- break;
-
- case 'Ldap':
- $class = 'Horde_Core_Group_Ldap';
- $params['ldap'] = $injector
- ->getInstance('Horde_Core_Factory_Ldap')
- ->create('horde', 'group');
- break;
-
- case 'Sql':
- $class = 'Horde_Group_Sql';
- $params['db'] = $injector
- ->getInstance('Horde_Core_Factory_Db')
- ->create('horde', 'group');
- break;
-
- default:
- $class = $this->_getDriverName($driver, 'Horde_Group');
- break;
+ case 'Contactlists':
+ $class = 'Horde_Group_Contactlists';
+ $params['api'] = $GLOBALS['registry']->contacts;
+ break;
+
+ case 'Kolab':
+ $class = 'Horde_Group_Kolab';
+ $params['ldap'] = $injector
+ ->getInstance('Horde_Core_Factory_Ldap')
+ ->create('horde', 'group');
+ break;
+
+ case 'Ldap':
+ $class = 'Horde_Core_Group_Ldap';
+ $params['ldap'] = $injector
+ ->getInstance('Horde_Core_Factory_Ldap')
+ ->create('horde', 'group');
+ break;
+
+ case 'Sql':
+ $class = 'Horde_Group_Sql';
+ $params['db'] = $injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', 'group');
+ break;
+
+ default:
+ $class = $this->_getDriverName($driver, 'Horde_Group');
+ break;
}
return new $class($params);
diff --git a/lib/Horde/Core/Factory/HashTable.php b/lib/Horde/Core/Factory/HashTable.php
index 7dd43f988..e68105ba5 100644
--- a/lib/Horde/Core/Factory/HashTable.php
+++ b/lib/Horde/Core/Factory/HashTable.php
@@ -1,4 +1,5 @@
$logger,
- 'memcache' => $injector->getInstance('Horde_Memcache')
- ));
+ 'memcache' => $injector->getInstance('Horde_Memcache'),
+ ]);
}
$driver = empty($conf['hashtable']['driver'])
@@ -46,72 +47,72 @@ public function create(Horde_Injector $injector)
$params = Horde::getDriverConfig('hashtable', $driver);
switch ($lc_driver) {
- case 'memcache':
- return new Horde_HashTable_Memcache(array(
- 'logger' => $logger,
- 'memcache' => new Horde_Memcache(array_merge($params, array(
- 'logger' => $logger
- )))
- ));
-
- case 'predis':
- $params = array_merge(array(
- 'hostspec' => array(),
- 'password' => null,
- 'database' => null,
- 'port' => '',
- 'protocol' => 'tcp',
- ), $params);
- $redis_params = array();
-
- $common = array_filter(array(
- 'password' => strlen($params['password']) ? $params['password'] : null,
- 'persistent' => !empty($params['persistent']),
- 'database' => !empty($params['database']) ? $params['database'] : null
- ));
-
- switch ($params['protocol']) {
- case 'tcp':
- foreach ($params['hostspec'] as $key => $val) {
- $redis_params[] = array_merge($common, array_filter(array(
- 'host' => trim($val),
- 'port' => isset($params['port'][$key]) ? trim($params['port'][$key]) : null,
- 'scheme' => 'tcp'
- )));
+ case 'memcache':
+ return new Horde_HashTable_Memcache([
+ 'logger' => $logger,
+ 'memcache' => new Horde_Memcache(array_merge($params, [
+ 'logger' => $logger,
+ ])),
+ ]);
+
+ case 'predis':
+ $params = array_merge([
+ 'hostspec' => [],
+ 'password' => null,
+ 'database' => null,
+ 'port' => '',
+ 'protocol' => 'tcp',
+ ], $params);
+ $redis_params = [];
+
+ $common = array_filter([
+ 'password' => strlen($params['password']) ? $params['password'] : null,
+ 'persistent' => !empty($params['persistent']),
+ 'database' => !empty($params['database']) ? $params['database'] : null,
+ ]);
+
+ switch ($params['protocol']) {
+ case 'tcp':
+ foreach ($params['hostspec'] as $key => $val) {
+ $redis_params[] = array_merge($common, array_filter([
+ 'host' => trim($val),
+ 'port' => isset($params['port'][$key]) ? trim($params['port'][$key]) : null,
+ 'scheme' => 'tcp',
+ ]));
+ }
+ break;
+
+ case 'unix':
+ $redis_params[] = array_merge($common, [
+ 'path' => trim($params['socket']),
+ 'scheme' => 'unix',
+ ]);
+ break;
}
- break;
-
- case 'unix':
- $redis_params[] = array_merge($common, array(
- 'path' => trim($params['socket']),
- 'scheme' => 'unix'
- ));
- break;
- }
-
- /* No need to use complex clustering if not needed. */
- if (count($redis_params) === 1) {
- $redis_params = reset($redis_params);
- }
-
- $redis_replication_options = array();
- if (!empty($params['replication'])) {
- $redis_replication_options = array(
- 'replication' => $params['replication'],
- 'service' => !empty($params['service']) ? $params['service'] : null,
- );
- }
-
- return new Horde_HashTable_Predis(array(
- 'logger' => $logger,
- 'predis' => new Predis\Client($redis_params, $redis_replication_options)
- ));
-
- case 'memory':
- default:
- return new Horde_HashTable_Memory(array(
- 'logger' => $logger
- ));
+
+ /* No need to use complex clustering if not needed. */
+ if (count($redis_params) === 1) {
+ $redis_params = reset($redis_params);
+ }
+
+ $redis_replication_options = [];
+ if (!empty($params['replication'])) {
+ $redis_replication_options = [
+ 'replication' => $params['replication'],
+ 'service' => !empty($params['service']) ? $params['service'] : null,
+ ];
+ }
+
+ return new Horde_HashTable_Predis([
+ 'logger' => $logger,
+ 'predis' => new Predis\Client($redis_params, $redis_replication_options),
+ ]);
+
+ case 'memory':
+ default:
+ return new Horde_HashTable_Memory([
+ 'logger' => $logger,
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/History.php b/lib/Horde/Core/Factory/History.php
index b0f35f138..55f9aa4f4 100644
--- a/lib/Horde/Core/Factory/History.php
+++ b/lib/Horde/Core/Factory/History.php
@@ -1,4 +1,5 @@
getInstance('Horde_Registry')->getAuth();
switch (Horde_String::lower($driver)) {
- case 'nosql':
- $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'history');
- if ($nosql instanceof Horde_History_Mongo) {
- $history = new Horde_History_Mongo(
- $user,
- array('mongo_db' => $nosql)
- );
- }
- break;
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'history');
+ if ($nosql instanceof Horde_History_Mongo) {
+ $history = new Horde_History_Mongo(
+ $user,
+ ['mongo_db' => $nosql]
+ );
+ }
+ break;
- case 'sql':
- try {
- $history = new Horde_History_Sql(
- $user,
- $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'history')
- );
- } catch (Exception $e) {}
- break;
+ case 'sql':
+ try {
+ $history = new Horde_History_Sql(
+ $user,
+ $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'history')
+ );
+ } catch (Exception $e) {
+ }
+ break;
}
if (is_null($history)) {
diff --git a/lib/Horde/Core/Factory/HttpClient.php b/lib/Horde/Core/Factory/HttpClient.php
index 56fde6b43..869f8f7f3 100644
--- a/lib/Horde/Core/Factory/HttpClient.php
+++ b/lib/Horde/Core/Factory/HttpClient.php
@@ -1,4 +1,5 @@
_instances[$key])) {
- $params = array(
+ $params = [
'user' => is_null($user) ? $registry->getAuth() : $user,
- );
+ ];
if (isset($prefs) && ($params['user'] == $registry->getAuth())) {
$params['prefs'] = $prefs;
} else {
- $params['prefs'] = $this->_injector->getInstance('Horde_Core_Factory_Prefs')->create($registry->getApp() ?: 'horde', array(
+ $params['prefs'] = $this->_injector->getInstance('Horde_Core_Factory_Prefs')->create($registry->getApp() ?: 'horde', [
'cache' => false,
- 'user' => $user
- ));
+ 'user' => $user,
+ ]);
}
$this->_instances[$key] = new $class($params);
diff --git a/lib/Horde/Core/Factory/Identity/DavUsernameHook.php b/lib/Horde/Core/Factory/Identity/DavUsernameHook.php
index 0e73ee0e3..f0217b14e 100644
--- a/lib/Horde/Core/Factory/Identity/DavUsernameHook.php
+++ b/lib/Horde/Core/Factory/Identity/DavUsernameHook.php
@@ -1,4 +1,5 @@
_injector->getInstance('Horde_Core_Hooks')
- ->callHook('davusername', 'horde', array($user, true));
+ ->callHook('davusername', 'horde', [$user, true]);
} catch (Horde_Exception_HookNotSet $e) {
}
return parent::create($user, $driver);
diff --git a/lib/Horde/Core/Factory/Identity/UsernameHook.php b/lib/Horde/Core/Factory/Identity/UsernameHook.php
index 606ca2bd3..41d47cf2a 100644
--- a/lib/Horde/Core/Factory/Identity/UsernameHook.php
+++ b/lib/Horde/Core/Factory/Identity/UsernameHook.php
@@ -1,4 +1,5 @@
_getDriverName($driver, 'Horde_Image');
- $context = array(
+ $context = [
'tmpdir' => Horde::getTempdir(),
- 'logger' => $this->_injector->getInstance('Horde_Log_Logger')
- );
+ 'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
+ ];
switch ($driver) {
- case 'Im':
- $context['convert'] = $conf['image']['convert'];
- $context['identify'] = $conf['image']['identify'];
- break;
+ case 'Im':
+ $context['convert'] = $conf['image']['convert'];
+ $context['identify'] = $conf['image']['identify'];
+ break;
}
return new $class($params, $context);
diff --git a/lib/Horde/Core/Factory/Imple.php b/lib/Horde/Core/Factory/Imple.php
index accf636a3..55020525b 100644
--- a/lib/Horde/Core/Factory/Imple.php
+++ b/lib/Horde/Core/Factory/Imple.php
@@ -1,4 +1,5 @@
_getDriverName($driver, 'Horde_Core_Ajax_Imple');
$ob = new $class($params);
diff --git a/lib/Horde/Core/Factory/Imsp.php b/lib/Horde/Core/Factory/Imsp.php
index 930b62343..67ec38df7 100644
--- a/lib/Horde/Core/Factory/Imsp.php
+++ b/lib/Horde/Core/Factory/Imsp.php
@@ -1,4 +1,5 @@
_instances[$signature])) {
$this->_instances[$signature] = self::_factory($driver, $params);
}
@@ -75,7 +76,7 @@ public function create($driver = null, array $params = array())
* @return mixed The Horde_Imsp object or Horde_Imsp_Client object.
* @throws Horde_Exception
*/
- protected function _factory($driver = null, array $params = array())
+ protected function _factory($driver = null, array $params = [])
{
$driver = basename($driver);
diff --git a/lib/Horde/Core/Factory/ImspAuth.php b/lib/Horde/Core/Factory/ImspAuth.php
index a116d8f14..947b79430 100644
--- a/lib/Horde/Core/Factory/ImspAuth.php
+++ b/lib/Horde/Core/Factory/ImspAuth.php
@@ -1,4 +1,5 @@
_injector->setInstance(
- 'Horde_Kolab_Server_Configuration', $configuration
+ 'Horde_Kolab_Server_Configuration',
+ $configuration
);
}
@@ -147,12 +149,12 @@ private function _setupSchema()
private function _setupStructure()
{
$configuration = $this->getConfiguration();
- $driver = isset($configuration['structure']['driver'])
- ? $configuration['structure']['driver']
- : 'Horde_Kolab_Server_Structure_Kolab';
+ $driver = $configuration['structure']['driver']
+ ?? 'Horde_Kolab_Server_Structure_Kolab';
$this->_injector->bindImplementation(
- 'Horde_Kolab_Server_Structure_Interface', $driver
+ 'Horde_Kolab_Server_Structure_Interface',
+ $driver
);
}
@@ -190,7 +192,8 @@ public function getConnection()
$configuration['hostspec'] = $configuration['host_master'];
$ldap_write = new Horde_Ldap($configuration);
return new Horde_Kolab_Server_Connection_Splittedldap(
- $ldap_read, $ldap_write
+ $ldap_read,
+ $ldap_write
);
}
@@ -199,13 +202,13 @@ public function getConnection()
);
}
- $data = isset($configuration['data'])
- ? $configuration['data']
- : array();
+ $data = $configuration['data']
+ ?? [];
return new Horde_Kolab_Server_Connection_Mock(
new Horde_Kolab_Server_Connection_Mock_Ldap(
- $configuration, $data
+ $configuration,
+ $data
)
);
}
@@ -249,19 +252,22 @@ public function getServer()
if (isset($configuration['map'])) {
$server = new Horde_Kolab_Server_Decorator_Map(
- $server, $configuration['map']
+ $server,
+ $configuration['map']
);
}
if (isset($configuration['debug']) || isset($configuration['log'])) {
$server = new Horde_Kolab_Server_Decorator_Log(
- $server, $this->_injector->getInstance('Horde_Log_Logger')
+ $server,
+ $this->_injector->getInstance('Horde_Log_Logger')
);
}
if (isset($configuration['debug']) || isset($configuration['count'])) {
$server = new Horde_Kolab_Server_Decorator_Count(
- $server, $this->_injector->getInstance('Horde_Log_Logger')
+ $server,
+ $this->_injector->getInstance('Horde_Log_Logger')
);
}
diff --git a/lib/Horde/Core/Factory/KolabSession.php b/lib/Horde/Core/Factory/KolabSession.php
index f4d37b95b..6975775f7 100644
--- a/lib/Horde/Core/Factory/KolabSession.php
+++ b/lib/Horde/Core/Factory/KolabSession.php
@@ -1,4 +1,5 @@
_injector->getInstance('Horde_Log_Logger')
+ $validator,
+ $this->_injector->getInstance('Horde_Log_Logger')
);
}
@@ -71,7 +74,7 @@ public function createSessionValidator(
public function createSession()
{
if (!empty($GLOBALS['conf']['kolab']['enabled']) &&
- !isset($GLOBALS['conf']['kolab']['users'])) {
+ !isset($GLOBALS['conf']['kolab']['users'])) {
$session = new Horde_Kolab_Session_Base(
$this->_injector->getInstance('Horde_Kolab_Server_Composite'),
$GLOBALS['conf']['kolab']
@@ -87,7 +90,8 @@ public function createSession()
if (isset($GLOBALS['conf']['kolab']['session']['debug'])) {
$session = new Horde_Kolab_Session_Decorator_Logged(
- $session, $this->_injector->getInstance('Horde_Log_Logger')
+ $session,
+ $this->_injector->getInstance('Horde_Log_Logger')
);
}
diff --git a/lib/Horde/Core/Factory/KolabStorage.php b/lib/Horde/Core/Factory/KolabStorage.php
index 42e4b1ce2..a2f99d0d1 100644
--- a/lib/Horde/Core/Factory/KolabStorage.php
+++ b/lib/Horde/Core/Factory/KolabStorage.php
@@ -1,4 +1,5 @@
_injector->setInstance(
- 'Horde_Kolab_Storage_Configuration', $configuration
+ 'Horde_Kolab_Storage_Configuration',
+ $configuration
);
}
@@ -82,53 +84,53 @@ public function create()
? $configuration['cache']
: 'Mock';
switch ($cache) {
- case 'Horde':
- $cacheob = $this->_injector->getInstance('Horde_Cache');
- break;
- case 'Mock':
- default:
- $cacheob = new Horde_Cache(
- new Horde_Cache_Storage_Mock(), array('compress' => true)
- );
+ case 'Horde':
+ $cacheob = $this->_injector->getInstance('Horde_Cache');
+ break;
+ case 'Mock':
+ default:
+ $cacheob = new Horde_Cache(
+ new Horde_Cache_Storage_Mock(),
+ ['compress' => true]
+ );
}
- $params = array(
+ $params = [
'driver' => 'horde',
- 'params' => array(
+ 'params' => [
'host' => $configuration['server'],
'username' => $GLOBALS['registry']->getAuth(),
'password' => $GLOBALS['registry']->getAuthCredential('password'),
'port' => $configuration['port'],
'secure' => $configuration['secure'],
- 'debug' => isset($configuration['debug'])
- ? $configuration['debug']
- : null,
- 'cache' => array(
+ 'debug' => $configuration['debug']
+ ?? null,
+ 'cache' => [
'backend' => new Horde_Imap_Client_Cache_Backend_Cache(
- array('cacheob' => $cacheob)
- )
- )
- ),
- 'queries' => array(
- 'list' => array(
- Horde_Kolab_Storage_List_Tools::QUERY_BASE => array(
- 'cache' => true
- ),
- Horde_Kolab_Storage_List_Tools::QUERY_ACL => array(
- 'cache' => true
+ ['cacheob' => $cacheob]
),
- Horde_Kolab_Storage_List_Tools::QUERY_SHARE => array(
- 'cache' => true
- ),
- )
- ),
- 'queryset' => array(
- 'data' => array('queryset' => 'horde'),
- ),
+ ],
+ ],
+ 'queries' => [
+ 'list' => [
+ Horde_Kolab_Storage_List_Tools::QUERY_BASE => [
+ 'cache' => true,
+ ],
+ Horde_Kolab_Storage_List_Tools::QUERY_ACL => [
+ 'cache' => true,
+ ],
+ Horde_Kolab_Storage_List_Tools::QUERY_SHARE => [
+ 'cache' => true,
+ ],
+ ],
+ ],
+ 'queryset' => [
+ 'data' => ['queryset' => 'horde'],
+ ],
'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
- 'log' => array('debug'),
+ 'log' => ['debug'],
'cache' => $this->_injector->getInstance('Horde_Cache'),
- );
+ ];
// Check if the history system is enabled
// @todo remove interface_exists check in H6.
@@ -137,7 +139,7 @@ public function create()
$history = $this->_injector->getInstance('Horde_History');
$params['history'] = $history;
$params['history_prefix_generator'] = new Horde_Core_Kolab_Storage_HistoryPrefix();
- } catch(Horde_Exception $e) {
+ } catch (Horde_Exception $e) {
}
}
diff --git a/lib/Horde/Core/Factory/LanguageDetect.php b/lib/Horde/Core/Factory/LanguageDetect.php
index 9873c28bb..651de1486 100644
--- a/lib/Horde/Core/Factory/LanguageDetect.php
+++ b/lib/Horde/Core/Factory/LanguageDetect.php
@@ -1,4 +1,5 @@
'sq',
'arabic' => 'ar',
// azeri
@@ -90,8 +91,8 @@ class Horde_Core_Factory_LanguageDetect extends Horde_Core_Factory_Base
'urdu' => 'ur',
'uzbek' => 'uz',
'vietnamese' => 'vi',
- 'welsh' => 'cy'
- );
+ 'welsh' => 'cy',
+ ];
/**
* Return a Text_LanguageDetect instance.
diff --git a/lib/Horde/Core/Factory/Ldap.php b/lib/Horde/Core/Factory/Ldap.php
index eacd4abad..43d94a234 100644
--- a/lib/Horde/Core/Factory/Ldap.php
+++ b/lib/Horde/Core/Factory/Ldap.php
@@ -1,4 +1,5 @@
_instances[$sig])) {
return $this->_instances[$sig];
@@ -78,7 +79,8 @@ public function create($app = 'horde', $backend = null)
$GLOBALS['registry']->getAuth()) {
$this->_instances[$sig]->bind(
$this->_instances[$sig]->findUserDN($GLOBALS['registry']->getAuth()),
- $GLOBALS['registry']->getAuthCredential('password'));
+ $GLOBALS['registry']->getAuthCredential('password')
+ );
}
} catch (Horde_Exception_NotFound $notfound) {
}
diff --git a/lib/Horde/Core/Factory/Lock.php b/lib/Horde/Core/Factory/Lock.php
index e2e5ef4f7..b2a82c52f 100644
--- a/lib/Horde/Core/Factory/Lock.php
+++ b/lib/Horde/Core/Factory/Lock.php
@@ -1,4 +1,5 @@
getInstance('Horde_Log_Logger');
switch (Horde_String::lower($driver)) {
- case 'none':
- $driver = 'null';
- break;
-
- case 'nosql':
- $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache');
- if ($nosql instanceof Horde_Mongo_Client) {
- $params['mongo_db'] = $nosql;
- $driver = 'mongo';
- }
- break;
-
- case 'sql':
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'lock');
- break;
+ case 'none':
+ $driver = 'null';
+ break;
+
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $params['mongo_db'] = $nosql;
+ $driver = 'mongo';
+ }
+ break;
+
+ case 'sql':
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'lock');
+ break;
}
$class = $this->_getDriverName($driver, 'Horde_Lock');
diff --git a/lib/Horde/Core/Factory/Logger.php b/lib/Horde/Core/Factory/Logger.php
index ad88e50a7..bbe2e6eca 100644
--- a/lib/Horde/Core/Factory/Logger.php
+++ b/lib/Horde/Core/Factory/Logger.php
@@ -1,4 +1,5 @@
$conf['log']['params']['template']));
- break;
+ case 'file':
+ case 'stream':
+ $append = ($conf['log']['type'] == 'file')
+ ? ($conf['log']['params']['append'] ? 'a+' : 'w+')
+ : null;
+ $format = $conf['log']['params']['format']
+ ?? 'default';
+
+ switch ($format) {
+ case 'custom':
+ $formatter = new Horde_Log_Formatter_Simple(['format' => $conf['log']['params']['template']]);
+ break;
+
+ case 'default':
+ default:
+ // Use Horde_Log defaults.
+ $formatter = null;
+ break;
+
+ case 'xml':
+ $formatter = new Horde_Log_Formatter_Xml();
+ break;
+ }
- case 'default':
- default:
- // Use Horde_Log defaults.
- $formatter = null;
+ try {
+ $handler = new Horde_Log_Handler_Stream($conf['log']['name'], $append, $formatter);
+ } catch (Horde_Log_Exception $e) {
+ $this->error = $e;
+ return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
+ }
+ try {
+ $handler->setOption('ident', $conf['log']['ident']);
+ } catch (Horde_Log_Exception $e) {
+ }
break;
- case 'xml':
- $formatter = new Horde_Log_Formatter_Xml();
+ case 'syslog':
+ try {
+ $handler = new Horde_Log_Handler_Syslog();
+ if (!empty($conf['log']['name'])) {
+ $handler->setOption('facility', $conf['log']['name']);
+ }
+ if (!empty($conf['log']['ident'])) {
+ $handler->setOption('ident', $conf['log']['ident']);
+ }
+ } catch (Horde_Log_Exception $e) {
+ $this->error = $e;
+ return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
+ }
break;
- }
-
- try {
- $handler = new Horde_Log_Handler_Stream($conf['log']['name'], $append, $formatter);
- } catch (Horde_Log_Exception $e) {
- $this->error = $e;
- return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
- }
- try {
- $handler->setOption('ident', $conf['log']['ident']);
- } catch (Horde_Log_Exception $e) {
- }
- break;
- case 'syslog':
- try {
- $handler = new Horde_Log_Handler_Syslog();
- if (!empty($conf['log']['name'])) {
- $handler->setOption('facility', $conf['log']['name']);
- }
- if (!empty($conf['log']['ident'])) {
- $handler->setOption('ident', $conf['log']['ident']);
- }
- } catch (Horde_Log_Exception $e) {
- $this->error = $e;
+ case 'null':
+ default:
+ // Use default null handler.
return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
- }
- break;
-
- case 'null':
- default:
- // Use default null handler.
- return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
}
switch ($conf['log']['priority']) {
- case 'WARNING':
- // Bug #12109
- $priority = 'WARN';
- break;
-
- default:
- $priority = defined('Horde_Log::' . $conf['log']['priority'])
- ? $conf['log']['priority']
- : 'NOTICE';
- break;
+ case 'WARNING':
+ // Bug #12109
+ $priority = 'WARN';
+ break;
+
+ default:
+ $priority = defined('Horde_Log::' . $conf['log']['priority'])
+ ? $conf['log']['priority']
+ : 'NOTICE';
+ break;
}
$handler->addFilter(constant('Horde_Log::' . $priority));
@@ -133,8 +133,8 @@ public static function available()
public static function queue(Horde_Core_Log_Object $ob)
{
if (!isset(self::$_queue)) {
- self::$_queue = array();
- register_shutdown_function(array(__CLASS__, 'processQueue'));
+ self::$_queue = [];
+ register_shutdown_function([__CLASS__, 'processQueue']);
}
self::$_queue[] = $ob;
@@ -160,7 +160,7 @@ public static function processQueue($logger = null)
} catch (Exception $e) {
}
- self::$_queue = array();
+ self::$_queue = [];
}
}
diff --git a/lib/Horde/Core/Factory/LoginTasks.php b/lib/Horde/Core/Factory/LoginTasks.php
index a28ef8b68..01cf98aa5 100644
--- a/lib/Horde/Core/Factory/LoginTasks.php
+++ b/lib/Horde/Core/Factory/LoginTasks.php
@@ -1,4 +1,5 @@
getConfig();
+ [$transport, $params] = $this->getConfig();
} else {
$transport = $config['transport'];
$params = $config['params'];
@@ -91,9 +92,8 @@ public function getConfig()
$transport = isset($conf['mailer']['type'])
? Horde_String::lower($conf['mailer']['type'])
: 'null';
- $params = isset($conf['mailer']['params'])
- ? $conf['mailer']['params']
- : array();
+ $params = $conf['mailer']['params']
+ ?? [];
/* Add username/password options now, regardless of current value of
* 'auth'. Will remove in create() if final config doesn't require
@@ -114,7 +114,7 @@ public function getConfig()
unset($params['password_auth'], $params['username_auth']);
}
- return array($transport, $params);
+ return [$transport, $params];
}
}
diff --git a/lib/Horde/Core/Factory/MailBase.php b/lib/Horde/Core/Factory/MailBase.php
index 4a7c77cb2..663c52a4c 100644
--- a/lib/Horde/Core/Factory/MailBase.php
+++ b/lib/Horde/Core/Factory/MailBase.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Core_Log_Wrapper'))));
+ : new Horde_Memcache(array_merge($GLOBALS['conf']['memcache'], ['logger' => $injector->getInstance('Horde_Core_Log_Wrapper')]));
}
}
diff --git a/lib/Horde/Core/Factory/MimeViewer.php b/lib/Horde/Core/Factory/MimeViewer.php
index 68afc69b6..bd94fbf86 100644
--- a/lib/Horde/Core/Factory/MimeViewer.php
+++ b/lib/Horde/Core/Factory/MimeViewer.php
@@ -1,4 +1,5 @@
getApp();
+ $app = $opts['app']
+ ?? $GLOBALS['registry']->getApp();
- $type = isset($opts['type'])
- ? $opts['type']
- : $mime->getType();
+ $type = $opts['type']
+ ?? $mime->getType();
- list($driver, $params) = $this->getViewerConfig($type, $app);
+ [$driver, $params] = $this->getViewerConfig($type, $app);
return new $driver($mime, $params);
}
@@ -77,78 +76,78 @@ public function getViewerConfig($type, $app)
? $config['driver']
: $config['app'] . '_Mime_Viewer_' . $config['driver'];
- $params = array_merge($config, array(
+ $params = array_merge($config, [
'charset' => 'UTF-8',
// TODO: Logging
// 'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
- 'temp_file' => array('Horde', 'getTempFile'),
- 'text_filter' => array($this->_injector->getInstance('Horde_Core_Factory_TextFilter'), 'filter')
- ));
+ 'temp_file' => ['Horde', 'getTempFile'],
+ 'text_filter' => [$this->_injector->getInstance('Horde_Core_Factory_TextFilter'), 'filter'],
+ ]);
switch ($config['driver']) {
- case 'Deb':
- case 'Rpm':
- $params['monospace'] = 'fixed';
- break;
-
- case 'Html':
- $params['browser'] = $GLOBALS['browser'];
- $params['dns'] = $this->_injector->getInstance('Net_DNS2_Resolver');
- $params['external_callback'] = array('Horde', 'externalUrl');
- break;
-
- case 'Ooo':
- $params['temp_dir'] = Horde::getTempDir();
- $params['zip'] = Horde_Compress::factory('Zip');
- break;
-
- case 'Rar':
- $params['monospace'] = 'fixed';
- $params['rar'] = Horde_Compress::factory('Rar');
- break;
-
- case 'Report':
- case 'Security':
- $params['viewer_callback'] = array($this, 'getViewerCallback');
- break;
-
- case 'Syntaxhighlighter':
- if ($config['app'] == 'horde') {
- $driver = 'Horde_Core_Mime_Viewer_Syntaxhighlighter';
- }
- $params['registry'] = $GLOBALS['registry'];
- break;
-
- case 'Tgz':
- $params['gzip'] = Horde_Compress::factory('Gzip');
- $params['monospace'] = 'fixed';
- $params['tar'] = Horde_Compress::factory('Tar');
- break;
-
- case 'Tnef':
- $params['tnef'] = Horde_Compress::factory('Tnef');
- break;
-
- case 'Vcard':
- if ($config['app'] == 'horde') {
- $driver = 'Horde_Core_Mime_Viewer_Vcard';
- }
- $params['browser'] = $GLOBALS['browser'];
- $params['notification'] = $GLOBALS['notification'];
- $params['prefs'] = $GLOBALS['prefs'];
- $params['registry'] = $GLOBALS['registry'];
- break;
-
- case 'Zip':
- $params['monospace'] = 'fixed';
- $params['zip'] = Horde_Compress::factory('Zip');
- break;
+ case 'Deb':
+ case 'Rpm':
+ $params['monospace'] = 'fixed';
+ break;
+
+ case 'Html':
+ $params['browser'] = $GLOBALS['browser'];
+ $params['dns'] = $this->_injector->getInstance('Net_DNS2_Resolver');
+ $params['external_callback'] = ['Horde', 'externalUrl'];
+ break;
+
+ case 'Ooo':
+ $params['temp_dir'] = Horde::getTempDir();
+ $params['zip'] = Horde_Compress::factory('Zip');
+ break;
+
+ case 'Rar':
+ $params['monospace'] = 'fixed';
+ $params['rar'] = Horde_Compress::factory('Rar');
+ break;
+
+ case 'Report':
+ case 'Security':
+ $params['viewer_callback'] = [$this, 'getViewerCallback'];
+ break;
+
+ case 'Syntaxhighlighter':
+ if ($config['app'] == 'horde') {
+ $driver = 'Horde_Core_Mime_Viewer_Syntaxhighlighter';
+ }
+ $params['registry'] = $GLOBALS['registry'];
+ break;
+
+ case 'Tgz':
+ $params['gzip'] = Horde_Compress::factory('Gzip');
+ $params['monospace'] = 'fixed';
+ $params['tar'] = Horde_Compress::factory('Tar');
+ break;
+
+ case 'Tnef':
+ $params['tnef'] = Horde_Compress::factory('Tnef');
+ break;
+
+ case 'Vcard':
+ if ($config['app'] == 'horde') {
+ $driver = 'Horde_Core_Mime_Viewer_Vcard';
+ }
+ $params['browser'] = $GLOBALS['browser'];
+ $params['notification'] = $GLOBALS['notification'];
+ $params['prefs'] = $GLOBALS['prefs'];
+ $params['registry'] = $GLOBALS['registry'];
+ break;
+
+ case 'Zip':
+ $params['monospace'] = 'fixed';
+ $params['zip'] = Horde_Compress::factory('Zip');
+ break;
}
- return array(
+ return [
$this->_getDriverName($driver, 'Horde_Mime_Viewer'),
- $params
- );
+ $params,
+ ];
}
/**
@@ -165,10 +164,12 @@ public function getViewerConfig($type, $app)
* @return Horde_Mime_Viewer_Base The newly created instance.
* @throws Horde_Mime_Viewer_Exception
*/
- public function getViewerCallback(Horde_Mime_Viewer_Base $viewer,
- Horde_Mime_Part $mime, $type)
- {
- return $this->create($mime, array('type' => $type));
+ public function getViewerCallback(
+ Horde_Mime_Viewer_Base $viewer,
+ Horde_Mime_Part $mime,
+ $type
+ ) {
+ return $this->create($mime, ['type' => $type]);
}
/**
@@ -184,11 +185,10 @@ public function getViewerCallback(Horde_Mime_Viewer_Base $viewer,
* @return Horde_Themes_Image An object which contains the URI
* and filesystem location of the image.
*/
- public function getIcon($mime, array $opts = array())
+ public function getIcon($mime, array $opts = [])
{
- $app = isset($opts['app'])
- ? $opts['app']
- : $GLOBALS['registry']->getApp();
+ $app = $opts['app']
+ ?? $GLOBALS['registry']->getApp();
$type = ($mime instanceof Horde_Mime_Part)
? $mime->getType()
@@ -197,10 +197,10 @@ public function getIcon($mime, array $opts = array())
$config = $this->_getDriver($type, $app);
if (!isset($config['icon'])) {
- $config['icon'] = array(
+ $config['icon'] = [
'app' => 'horde',
- 'icon' => 'text.png'
- );
+ 'icon' => 'text.png',
+ ];
}
return Horde_Themes::img('mime/' . $config['icon']['icon'], $config['icon']['app']);
@@ -228,13 +228,13 @@ private function _loadConfig($app)
try {
$aconfig = $registry->loadConfigFile('mime_drivers.php', 'mime_drivers', $app)->config['mime_drivers'];
} catch (Horde_Exception $e) {
- $aconfig = array();
+ $aconfig = [];
}
- $config = array(
- 'config' => array(),
- 'handles' => array()
- );
+ $config = [
+ 'config' => [],
+ 'handles' => [],
+ ];
foreach ($aconfig as $key => $val) {
if (empty($val['disable'])) {
@@ -249,7 +249,7 @@ private function _loadConfig($app)
/* Make sure there is a default entry. */
if (($app == 'horde') && !isset($config['config']['default'])) {
- $config['config']['default'] = array();
+ $config['config']['default'] = [];
}
$this->_config[$app] = $config;
@@ -269,18 +269,18 @@ private function _getDriver($type, $app)
/* Start with default driver, and then merge in wildcard and exact
* match configs. */
- $config = array();
- list($ptype,) = explode('/', $type, 2);
+ $config = [];
+ [$ptype, ] = explode('/', $type, 2);
$wild = $ptype . '/*';
- $app_list = array(
- array('horde', 'default', 'config'),
- array($app, 'default', 'config'),
- array('horde', $wild, 'handles'),
- array($app, $wild, 'handles'),
- array('horde', $type, 'handles'),
- array($app, $type, 'handles')
- );
+ $app_list = [
+ ['horde', 'default', 'config'],
+ [$app, 'default', 'config'],
+ ['horde', $wild, 'handles'],
+ [$app, $wild, 'handles'],
+ ['horde', $type, 'handles'],
+ [$app, $type, 'handles'],
+ ];
if ($app == 'horde') {
unset($app_list[1], $app_list[3], $app_list[5]);
}
@@ -293,22 +293,22 @@ private function _getDriver($type, $app)
if ($driver) {
$tmp = $this->_config[$val[0]]['config'][$driver];
if (isset($tmp['icons'])) {
- foreach (array($type, $wild, 'default') as $val2) {
+ foreach ([$type, $wild, 'default'] as $val2) {
if (isset($tmp['icons'][$val2])) {
- $tmp['icon'] = array(
+ $tmp['icon'] = [
'app' => $val[0],
- 'icon' => $tmp['icons'][$val2]
- );
+ 'icon' => $tmp['icons'][$val2],
+ ];
break;
}
}
unset($tmp['icons']);
}
- $config = array_merge(array_replace_recursive($config, $tmp), array(
+ $config = array_merge(array_replace_recursive($config, $tmp), [
'app' => $val[0],
- 'driver' => $driver
- ));
+ 'driver' => $driver,
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/Nosql.php b/lib/Horde/Core/Factory/Nosql.php
index e346faf2d..a9afff169 100644
--- a/lib/Horde/Core/Factory/Nosql.php
+++ b/lib/Horde/Core/Factory/Nosql.php
@@ -1,4 +1,5 @@
_instances[$sig])) {
return $this->_instances[$sig];
@@ -68,7 +69,8 @@ public function create($app = 'horde', $backend = null)
$e = null;
try {
$this->_instances[$sig] = $this->createNosql($config);
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
if ($pushed) {
$GLOBALS['registry']->popApp();
@@ -98,15 +100,15 @@ public function createNosql($config)
}
switch ($config['phptype']) {
- case 'mongo':
- $ob = new Horde_Mongo_Client(empty($config['hostspec']) ? 'localhost' : $config['hostspec']);
- if (isset($config['dbname']) && strlen($config['dbname'])) {
- $ob->dbname = $config['dbname'];
- }
- return $ob;
-
- default:
- throw new Horde_Exception(sprintf('Nosql driver %s doesn\'t exist.', $config['phptype']));
+ case 'mongo':
+ $ob = new Horde_Mongo_Client(empty($config['hostspec']) ? 'localhost' : $config['hostspec']);
+ if (isset($config['dbname']) && strlen($config['dbname'])) {
+ $ob->dbname = $config['dbname'];
+ }
+ return $ob;
+
+ default:
+ throw new Horde_Exception(sprintf('Nosql driver %s doesn\'t exist.', $config['phptype']));
}
}
diff --git a/lib/Horde/Core/Factory/NosqlBase.php b/lib/Horde/Core/Factory/NosqlBase.php
index 70f560bf0..d1c83a1d7 100644
--- a/lib/Horde/Core/Factory/NosqlBase.php
+++ b/lib/Horde/Core/Factory/NosqlBase.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Db')
- ->create('horde', 'perms');
- } catch (Horde_Exception $e) {
- $driver = 'Null';
- }
- break;
+ case 'sql':
+ try {
+ $params['db'] = $injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', 'perms');
+ } catch (Horde_Exception $e) {
+ $driver = 'Null';
+ }
+ break;
}
$params['cache'] = new Horde_Cache(
- new Horde_Cache_Storage_Stack(array(
- 'stack' => array(
+ new Horde_Cache_Storage_Stack([
+ 'stack' => [
new Horde_Cache_Storage_Memory(),
- $injector->getInstance('Horde_Cache')
- )
- ))
+ $injector->getInstance('Horde_Cache'),
+ ],
+ ])
);
$params['logger'] = $injector->getInstance('Horde_Log_Logger');
diff --git a/lib/Horde/Core/Factory/PermsCore.php b/lib/Horde/Core/Factory/PermsCore.php
index d3f0d01d3..c4962ba90 100644
--- a/lib/Horde/Core/Factory/PermsCore.php
+++ b/lib/Horde/Core/Factory/PermsCore.php
@@ -1,4 +1,5 @@
_injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'prefs');
- if ($nosql instanceof Horde_Mongo_Client) {
- $driver = 'mongo';
- }
- break;
+ case 'nosql':
+ $nosql = $this->_injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'prefs');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $driver = 'mongo';
+ }
+ break;
}
$driver = $this->_getDriverName($driver, 'Horde_Prefs_Storage');
} catch (Horde_Exception $e) {
@@ -90,13 +91,13 @@ public function create($scope = 'horde', array $opts = array())
$params = $opts['driver_params'];
}
- $opts = array_merge(array(
+ $opts = array_merge([
'cache' => true,
'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
'password' => '',
- 'sizecallback' => ((isset($conf['prefs']['maxsize'])) ? array($this, 'sizeCallback') : null),
- 'user' => ''
- ), $opts);
+ 'sizecallback' => ((isset($conf['prefs']['maxsize'])) ? [$this, 'sizeCallback'] : null),
+ 'user' => '',
+ ], $opts);
/* If $params['user_hook'] is defined, use it to retrieve the value to
* use for the username. */
@@ -107,10 +108,10 @@ function_exists($params['user_hook'])) {
/* To determine signature, don't serialize the logger or size
* callback, since they may contain unserializable components. */
- $sig_opts = array_merge($opts, array(
+ $sig_opts = array_merge($opts, [
'logger' => get_class($opts['logger']),
- 'sizecallback' => !is_null($opts['sizecallback'])
- ));
+ 'sizecallback' => !is_null($opts['sizecallback']),
+ ]);
ksort($sig_opts);
$sig = hash('md5', serialize($sig_opts) . '|' . $registry->getAuth());
@@ -121,39 +122,39 @@ function_exists($params['user_hook'])) {
try {
switch ($driver) {
- case 'Horde_Prefs_Storage_Ldap':
- $params['ldap'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Ldap')
- ->create('horde', 'prefs');
- break;
+ case 'Horde_Prefs_Storage_Ldap':
+ $params['ldap'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Ldap')
+ ->create('horde', 'prefs');
+ break;
- case 'Horde_Prefs_Storage_Mongo':
- $params['mongo_db'] = $nosql;
- break;
+ case 'Horde_Prefs_Storage_Mongo':
+ $params['mongo_db'] = $nosql;
+ break;
- case 'Horde_Prefs_Storage_Session':
- $driver = 'Horde_Prefs_Storage_Null';
- break;
+ case 'Horde_Prefs_Storage_Session':
+ $driver = 'Horde_Prefs_Storage_Null';
+ break;
- case 'Horde_Prefs_Storage_Sql':
- $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'prefs');
- break;
+ case 'Horde_Prefs_Storage_Sql':
+ $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'prefs');
+ break;
- case 'Horde_Prefs_Storage_KolabImap':
- if ($registry->isAdmin()) {
- throw new Horde_Exception('The IMAP based Kolab preferences backend is unavailable for system administrators.');
- }
- $params['kolab'] = $this->_injector
- ->getInstance('Horde_Kolab_Storage');
- $params['logger'] = $opts['logger'];
- break;
-
- case 'Horde_Prefs_Storage_Imsp':
- $imspParams = $conf['imsp'];
- $imspParams['username'] = $registry->getAuth('bare');
- $imspParams['password'] = $registry->getAuthCredential('password');
- $params['imsp'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Imsp')->create('Options', $imspParams);
+ case 'Horde_Prefs_Storage_KolabImap':
+ if ($registry->isAdmin()) {
+ throw new Horde_Exception('The IMAP based Kolab preferences backend is unavailable for system administrators.');
+ }
+ $params['kolab'] = $this->_injector
+ ->getInstance('Horde_Kolab_Storage');
+ $params['logger'] = $opts['logger'];
+ break;
+
+ case 'Horde_Prefs_Storage_Imsp':
+ $imspParams = $conf['imsp'];
+ $imspParams['username'] = $registry->getAuth('bare');
+ $imspParams['password'] = $registry->getAuthCredential('password');
+ $params['imsp'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Imsp')->create('Options', $imspParams);
}
$this->storage = new $driver($opts['user'], $params);
} catch (Horde_Exception $e) {
@@ -164,11 +165,11 @@ function_exists($params['user_hook'])) {
}
$config_driver = new Horde_Core_Prefs_Storage_Configuration($opts['user']);
- $hooks_driver = new Horde_Core_Prefs_Storage_Hooks($opts['user'], array('conf_ob' => $config_driver));
+ $hooks_driver = new Horde_Core_Prefs_Storage_Hooks($opts['user'], ['conf_ob' => $config_driver]);
$drivers = $driver
- ? array($config_driver, $this->storage, $hooks_driver)
- : array($config_driver, $hooks_driver);
+ ? [$config_driver, $this->storage, $hooks_driver]
+ : [$config_driver, $hooks_driver];
if ($driver && $opts['cache']) {
$opts['cache'] = $this->_getCache($opts['user'], false);
@@ -187,7 +188,7 @@ function_exists($params['user_hook'])) {
$this->_instances[$sig] = new Horde_Prefs(
$scope,
- array($config_driver, $hooks_driver),
+ [$config_driver, $hooks_driver],
$opts
);
}
@@ -206,7 +207,7 @@ protected function _notifyError($e)
if (!$GLOBALS['session']->get('horde', 'no_prefs')) {
$GLOBALS['session']->set('horde', 'no_prefs', true);
if (isset($GLOBALS['notification'])) {
- $GLOBALS['notification']->push(Horde_Core_Translation::t("The preferences backend is currently unavailable and your preferences have not been loaded. You may continue to use the system with default preferences."));
+ $GLOBALS['notification']->push(Horde_Core_Translation::t('The preferences backend is currently unavailable and your preferences have not been loaded. You may continue to use the system with default preferences.'));
Horde::log($e);
}
}
@@ -224,10 +225,10 @@ protected function _getCache($user, $fallback)
{
global $injector;
- $params = array(
+ $params = [
'app' => 'horde',
- 'storage_key' => 'horde_prefs_cache'
- );
+ 'storage_key' => 'horde_prefs_cache',
+ ];
if ($fallback) {
$params['cache'] = new Horde_Cache_Storage_Null();
@@ -238,19 +239,19 @@ protected function _getCache($user, $fallback)
return new Horde_Prefs_Cache_HordeCache(
$user,
- array(
+ [
'cache' => new Horde_Cache(
new Horde_Core_Cache_Session($params),
- array(
+ [
/* Don't enable compression here. Data is either
* compressed in the main Horde_Cache object (if
* oversized) or is compressed within the session
* (if stored in session cache). */
'compress' => false,
- 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper')
- )
- )
- )
+ 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper'),
+ ]
+ ),
+ ]
);
}
@@ -259,7 +260,7 @@ protected function _getCache($user, $fallback)
*/
public function clearCache()
{
- $this->_instances = array();
+ $this->_instances = [];
}
/**
@@ -276,7 +277,7 @@ public function sizeCallback($pref, $size)
return false;
}
- $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("The preference \"%s\" could not be saved because its data exceeds the maximum allowable size"), $pref), 'horde.error');
+ $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t('The preference "%s" could not be saved because its data exceeds the maximum allowable size'), $pref), 'horde.error');
return true;
}
diff --git a/lib/Horde/Core/Factory/QueueStorage.php b/lib/Horde/Core/Factory/QueueStorage.php
index 11361ed01..25278736b 100644
--- a/lib/Horde/Core/Factory/QueueStorage.php
+++ b/lib/Horde/Core/Factory/QueueStorage.php
@@ -1,4 +1,5 @@
setPath(isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']);
+ $request->setPath($_SERVER['REDIRECT_URL'] ?? $_SERVER['REQUEST_URI']);
return $request;
}
}
diff --git a/lib/Horde/Core/Factory/Secret.php b/lib/Horde/Core/Factory/Secret.php
index 98e0630cc..0d3f3fcf9 100644
--- a/lib/Horde/Core/Factory/Secret.php
+++ b/lib/Horde/Core/Factory/Secret.php
@@ -1,4 +1,5 @@
$conf['cookie']['domain'],
'cookie_path' => $conf['cookie']['path'],
'cookie_ssl' => $conf['use_ssl'] == 1,
- 'session_name' => $conf['session']['name']
- ));
+ 'session_name' => $conf['session']['name'],
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/Secret/Cbc.php b/lib/Horde/Core/Factory/Secret/Cbc.php
index ef3046e67..6185b18ce 100644
--- a/lib/Horde/Core/Factory/Secret/Cbc.php
+++ b/lib/Horde/Core/Factory/Secret/Cbc.php
@@ -1,4 +1,5 @@
$conf['cookie']['domain'],
'cookie_path' => $conf['cookie']['path'],
'cookie_ssl' => $conf['use_ssl'] == 1,
'iv' => $conf['secret_key'],
- 'session_name' => $conf['session']['name']
- ));
+ 'session_name' => $conf['session']['name'],
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/SessionHandler.php b/lib/Horde/Core/Factory/SessionHandler.php
index 7edbeaee9..3ecf0876a 100644
--- a/lib/Horde/Core/Factory/SessionHandler.php
+++ b/lib/Horde/Core/Factory/SessionHandler.php
@@ -1,4 +1,5 @@
getInstance('Horde_HashTable');
- $driver = 'hashtable';
- break;
-
- case 'nosql':
- $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'sessionhandler');
- if ($nosql instanceof Horde_Mongo_Client) {
- $params['mongo_db'] = $nosql;
- $driver = 'Horde_SessionHandler_Storage_Mongo';
- }
- break;
-
- case 'sql':
- $factory = $injector->getInstance('Horde_Core_Factory_Db');
- $config = $factory->getConfig('sessionhandler');
- unset($config['umask'], $config['driverconfig']);
- $params['db'] = $factory->createDb($config);
- break;
+ case 'builtin':
+ $noset = true;
+ break;
+
+ case 'hashtable':
+ // DEPRECATED
+ case 'memcache':
+ $params['hashtable'] = $injector->getInstance('Horde_HashTable');
+ $driver = 'hashtable';
+ break;
+
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'sessionhandler');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $params['mongo_db'] = $nosql;
+ $driver = 'Horde_SessionHandler_Storage_Mongo';
+ }
+ break;
+
+ case 'sql':
+ $factory = $injector->getInstance('Horde_Core_Factory_Db');
+ $config = $factory->getConfig('sessionhandler');
+ unset($config['umask'], $config['driverconfig']);
+ $params['db'] = $factory->createDb($config);
+ break;
}
$class = $this->_getDriverName($driver, 'Horde_SessionHandler_Storage');
@@ -75,25 +76,25 @@ public function create(Horde_Injector $injector)
if ((!empty($conf['sessionhandler']['hashtable']) ||
!empty($conf['sessionhandler']['memcache'])) &&
- !in_array($driver, array('builtin', 'hashtable'))) {
- $storage = new Horde_SessionHandler_Storage_Stack(array(
- 'stack' => array(
- new Horde_SessionHandler_Storage_Hashtable(array(
- 'hashtable' => $injector->getInstance('Horde_HashTable')
- )),
- $this->storage
- )
- ));
+ !in_array($driver, ['builtin', 'hashtable'])) {
+ $storage = new Horde_SessionHandler_Storage_Stack([
+ 'stack' => [
+ new Horde_SessionHandler_Storage_Hashtable([
+ 'hashtable' => $injector->getInstance('Horde_HashTable'),
+ ]),
+ $this->storage,
+ ],
+ ]);
}
return new Horde_SessionHandler(
$storage,
- array(
+ [
'logger' => $injector->getInstance('Horde_Log_Logger'),
'no_md5' => true,
'noset' => $noset,
- 'parse' => array($this, 'readSessionData')
- )
+ 'parse' => [$this, 'readSessionData'],
+ ]
);
}
@@ -118,7 +119,7 @@ public function readSessionData($session_data)
* search for the needed auth entries and swap the old session data
* back. */
$old_sess = $_SESSION;
- $_SESSION = array();
+ $_SESSION = [];
if (session_id()) {
$new_sess = false;
@@ -127,12 +128,12 @@ public function readSessionData($session_data)
$stub = new Horde_Support_Stub();
session_set_save_handler(
- array($this, '_returnTrue'),
- array($this, '_returnTrue'),
- array($stub, 'read'),
- array($stub, 'write'),
- array($this, '_returnTrue'),
- array($this, '_returnTrue')
+ [$this, '_returnTrue'],
+ [$this, '_returnTrue'],
+ [$stub, 'read'],
+ [$stub, 'write'],
+ [$this, '_returnTrue'],
+ [$this, '_returnTrue']
);
ob_start();
@@ -155,13 +156,13 @@ public function readSessionData($session_data)
$_SESSION = $old_sess;
return isset($data['userId'])
- ? array(
+ ? [
'apps' => $apps,
'browser' => $data['browser'],
'remoteAddr' => $data['remoteAddr'],
'timestamp' => $data['timestamp'],
- 'userid' => $data['userId']
- )
+ 'userid' => $data['userId'],
+ ]
: false;
}
diff --git a/lib/Horde/Core/Factory/Share.php b/lib/Horde/Core/Factory/Share.php
index d7b92a578..100330f63 100644
--- a/lib/Horde/Core/Factory/Share.php
+++ b/lib/Horde/Core/Factory/Share.php
@@ -1,4 +1,5 @@
_getDriverName($driver, 'Horde_Share');
$ob = new $class($app, $registry->getAuth(), $this->_injector->getInstance('Horde_Perms'), $this->_injector->getInstance('Horde_Group'));
$cb = new Horde_Core_Share_FactoryCallback($app, $driver);
- $ob->setShareCallback(array($cb, 'create'));
+ $ob->setShareCallback([$cb, 'create']);
$ob->setLogger($this->_injector->getInstance('Horde_Log_Logger'));
if (!empty($conf['share']['cache'])) {
@@ -77,10 +78,10 @@ public function create($app = null, $driver = null)
$ob->setListCache($listCache);
if (empty($this->_toCache)) {
- register_shutdown_function(array($this, 'shutdown'));
+ register_shutdown_function([$this, 'shutdown']);
}
- $this->_toCache[$sig] = array($app, $cache_sig);
+ $this->_toCache[$sig] = [$app, $cache_sig];
}
$this->_instances[$sig] = $ob;
diff --git a/lib/Horde/Core/Factory/SpellChecker.php b/lib/Horde/Core/Factory/SpellChecker.php
index 731c0572a..12754b601 100644
--- a/lib/Horde/Core/Factory/SpellChecker.php
+++ b/lib/Horde/Core/Factory/SpellChecker.php
@@ -1,4 +1,5 @@
array()),
+ ['localDict' => []],
Horde::getDriverConfig('spell', null),
$args
);
@@ -50,7 +51,8 @@ public function create(array $args = array(), $input = null)
if (!is_null($input)) {
try {
$args['locale'] = $this->_injector->getInstance('Horde_Core_Factory_LanguageDetect')->getLanguageCode($input);
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
}
if (empty($args['locale']) && isset($language)) {
@@ -64,7 +66,8 @@ public function create(array $args = array(), $input = null)
$args['localDict'],
$registry->loadConfigFile('spelling.php', 'ignore_list', 'horde')->config['ignore_list']
);
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
$classname = 'Horde_SpellChecker_' . Horde_String::ucfirst(basename($conf['spell']['driver']));
if (!class_exists($classname)) {
diff --git a/lib/Horde/Core/Factory/Template.php b/lib/Horde/Core/Factory/Template.php
index a2c72350a..798d68e11 100644
--- a/lib/Horde/Core/Factory/Template.php
+++ b/lib/Horde/Core/Factory/Template.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Cache'),
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- ));
+ 'logger' => $injector->getInstance('Horde_Log_Logger'),
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/TextFilter.php b/lib/Horde/Core/Factory/TextFilter.php
index ecc3e2f70..ce73aa16b 100644
--- a/lib/Horde/Core/Factory/TextFilter.php
+++ b/lib/Horde/Core/Factory/TextFilter.php
@@ -1,4 +1,5 @@
_getDriver($driver, $params);
+ [$driver, $params] = $this->_getDriver($driver, $params);
$driver = $this->_getDriverName($driver, 'Horde_Text_Filter');
return new $driver($params);
}
@@ -52,18 +53,18 @@ public function create($driver, array $params = array())
*
* @return string The transformed text.
*/
- public function filter($text, $filters = array(), $params = array())
+ public function filter($text, $filters = [], $params = [])
{
if (!is_array($filters)) {
- $filters = array($filters);
- $params = array($params);
+ $filters = [$filters];
+ $params = [$params];
}
- $filter_list = array();
+ $filter_list = [];
$params = array_values($params);
foreach (array_values($filters) as $num => $filter) {
- list($driver, $driv_param) = $this->_getDriver($filter, isset($params[$num]) ? $params[$num] : array());
+ [$driver, $driv_param] = $this->_getDriver($filter, $params[$num] ?? []);
$filter_list[$driver] = $driv_param;
}
@@ -85,42 +86,42 @@ protected function _getDriver($driver, $params)
$lc_driver = Horde_String::lower($driver);
switch ($lc_driver) {
- case 'bbcode':
- $driver = 'Horde_Core_Text_Filter_Bbcode';
- break;
+ case 'bbcode':
+ $driver = 'Horde_Core_Text_Filter_Bbcode';
+ break;
- case 'emails':
- $driver = 'Horde_Core_Text_Filter_Emails';
- break;
+ case 'emails':
+ $driver = 'Horde_Core_Text_Filter_Emails';
+ break;
- case 'emoticons':
- $driver = 'Horde_Core_Text_Filter_Emoticons';
- break;
+ case 'emoticons':
+ $driver = 'Horde_Core_Text_Filter_Emoticons';
+ break;
- case 'highlightquotes':
- $driver = 'Horde_Core_Text_Filter_Highlightquotes';
- break;
+ case 'highlightquotes':
+ $driver = 'Horde_Core_Text_Filter_Highlightquotes';
+ break;
- case 'linkurls':
- if (!isset($params['callback'])) {
- $params['callback'] = 'Horde::externalUrl';
- }
- break;
+ case 'linkurls':
+ if (!isset($params['callback'])) {
+ $params['callback'] = 'Horde::externalUrl';
+ }
+ break;
- case 'text2html':
- $param_copy = $params;
- foreach (array('emails', 'linkurls', 'space2html') as $val) {
- if (!isset($params[$val])) {
- $tmp = $this->_getDriver($val, $param_copy);
- $params[$val] = array(
- $tmp[0] => $tmp[1]
- );
+ case 'text2html':
+ $param_copy = $params;
+ foreach (['emails', 'linkurls', 'space2html'] as $val) {
+ if (!isset($params[$val])) {
+ $tmp = $this->_getDriver($val, $param_copy);
+ $params[$val] = [
+ $tmp[0] => $tmp[1],
+ ];
+ }
}
- }
- break;
+ break;
}
- return array($driver, $params);
+ return [$driver, $params];
}
}
diff --git a/lib/Horde/Core/Factory/ThemesCache.php b/lib/Horde/Core/Factory/ThemesCache.php
index 2095bf142..aaf576501 100644
--- a/lib/Horde/Core/Factory/ThemesCache.php
+++ b/lib/Horde/Core/Factory/ThemesCache.php
@@ -1,4 +1,5 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
*/
-class Horde_Core_Factory_ThemesCache
-extends Horde_Core_Factory_Base
-implements Horde_Shutdown_Task
+class Horde_Core_Factory_ThemesCache extends Horde_Core_Factory_Base implements Horde_Shutdown_Task
{
/**
* Instances.
*
* @var array
*/
- private $_instances = array();
+ private $_instances = [];
/**
* Return the Horde_Themes_Cache:: instance.
@@ -44,7 +43,7 @@ class Horde_Core_Factory_ThemesCache
*/
public function create($app, $theme)
{
- $sig = implode('|', array($app, $theme));
+ $sig = implode('|', [$app, $theme]);
if (!isset($this->_instances[$sig])) {
$cache = empty($GLOBALS['conf']['cachethemes'])
@@ -85,7 +84,7 @@ public function create($app, $theme)
*/
public function expireCache($app, $theme)
{
- $sig = implode('|', array($app, $theme));
+ $sig = implode('|', [$app, $theme]);
$cache = $this->_injector->getInstance('Horde_Cache');
diff --git a/lib/Horde/Core/Factory/Timezone.php b/lib/Horde/Core/Factory/Timezone.php
index e491e2fa6..d3cca75cf 100644
--- a/lib/Horde/Core/Factory/Timezone.php
+++ b/lib/Horde/Core/Factory/Timezone.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Cache'),
'location' => $GLOBALS['conf']['timezone']['location'],
- 'temp' => Horde::getTempDir()
- ));
+ 'temp' => Horde::getTempDir(),
+ ]);
}
}
diff --git a/lib/Horde/Core/Factory/Token.php b/lib/Horde/Core/Factory/Token.php
index 33297347f..777cdb3b4 100644
--- a/lib/Horde/Core/Factory/Token.php
+++ b/lib/Horde/Core/Factory/Token.php
@@ -1,4 +1,5 @@
getInstance('Horde_Log_Logger');
@@ -24,21 +25,21 @@ public function create(Horde_Injector $injector)
$params['secret'] = $session->get('horde', 'token_secret_key');
switch (Horde_String::lower($driver)) {
- case 'none':
- $driver = 'null';
- break;
-
- case 'nosql':
- $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'token');
- if ($nosql instanceof Horde_Mongo_Client) {
- $params['mongo_db'] = $nosql;
- $driver = 'Horde_Token_Mongo';
- }
- break;
-
- case 'sql':
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'token');
- break;
+ case 'none':
+ $driver = 'null';
+ break;
+
+ case 'nosql':
+ $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'token');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $params['mongo_db'] = $nosql;
+ $driver = 'Horde_Token_Mongo';
+ }
+ break;
+
+ case 'sql':
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'token');
+ break;
}
if (isset($conf['urls']['token_lifetime'])) {
diff --git a/lib/Horde/Core/Factory/Topbar.php b/lib/Horde/Core/Factory/Topbar.php
index ee5352881..e3312d748 100644
--- a/lib/Horde/Core/Factory/Topbar.php
+++ b/lib/Horde/Core/Factory/Topbar.php
@@ -1,4 +1,5 @@
_instances[$id])) {
switch ($lc_renderer) {
- case 'html':
- $renderer = 'Horde_Core_Tree_Renderer_Html';
- break;
+ case 'html':
+ $renderer = 'Horde_Core_Tree_Renderer_Html';
+ break;
- case 'javascript':
- $renderer = 'Horde_Core_Tree_Renderer_Javascript';
- break;
+ case 'javascript':
+ $renderer = 'Horde_Core_Tree_Renderer_Javascript';
+ break;
- case 'simplehtml':
- $renderer = 'Horde_Core_Tree_Renderer_Simplehtml';
- break;
+ case 'simplehtml':
+ $renderer = 'Horde_Core_Tree_Renderer_Simplehtml';
+ break;
}
$params['name'] = $name;
if (empty($params['nosession'])) {
- $params['session'] = array(
- 'get' => array(__CLASS__, 'getSession'),
- 'set' => array(__CLASS__, 'setSession')
- );
+ $params['session'] = [
+ 'get' => [__CLASS__, 'getSession'],
+ 'set' => [__CLASS__, 'setSession'],
+ ];
}
$this->_instances[$id] = Horde_Tree_Renderer::factory($renderer, $params);
diff --git a/lib/Horde/Core/Factory/Twitter.php b/lib/Horde/Core/Factory/Twitter.php
index cd356654f..fee91d553 100644
--- a/lib/Horde/Core/Factory/Twitter.php
+++ b/lib/Horde/Core/Factory/Twitter.php
@@ -1,4 +1,5 @@
$consumer_key,
'secret' => $consumer_secret,
'requestTokenUrl' => Horde_Service_Twitter::REQUEST_TOKEN_URL,
'authorizeTokenUrl' => Horde_Service_Twitter::USER_AUTHORIZE_URL,
'accessTokenUrl' => Horde_Service_Twitter::ACCESS_TOKEN_URL,
'signatureMethod' => new Horde_Oauth_SignatureMethod_HmacSha1(),
- 'callbackUrl' => $GLOBALS['registry']->getServiceLink('twitter')
- );
+ 'callbackUrl' => $GLOBALS['registry']->getServiceLink('twitter'),
+ ];
/* Create the Consumer */
$auth = new Horde_Service_Twitter_Auth_Oauth(new Horde_Oauth_Consumer($params));
diff --git a/lib/Horde/Core/Factory/UrlShortener.php b/lib/Horde/Core/Factory/UrlShortener.php
index 2e1c29b42..f162a3b88 100644
--- a/lib/Horde/Core/Factory/UrlShortener.php
+++ b/lib/Horde/Core/Factory/UrlShortener.php
@@ -1,4 +1,5 @@
_injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'vfs');
- if ($nosql instanceof Horde_Mongo_Client) {
- $vfs['params']['mongo_db'] = $nosql;
- $vfs['type'] = 'mongo';
- }
- break;
+ case 'nosql':
+ $nosql = $this->_injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'vfs');
+ if ($nosql instanceof Horde_Mongo_Client) {
+ $vfs['params']['mongo_db'] = $nosql;
+ $vfs['type'] = 'mongo';
+ }
+ break;
- case 'sql':
- case 'sqlfile':
- case 'musql':
- $config = Horde::getDriverConfig('vfs', 'sql');
- unset($config['umask'], $config['vfsroot']);
- $vfs['params']['db'] = $this->_injector
- ->getInstance('Horde_Core_Factory_Db')
- ->create('horde', $config);
- break;
+ case 'sql':
+ case 'sqlfile':
+ case 'musql':
+ $config = Horde::getDriverConfig('vfs', 'sql');
+ unset($config['umask'], $config['vfsroot']);
+ $vfs['params']['db'] = $this->_injector
+ ->getInstance('Horde_Core_Factory_Db')
+ ->create('horde', $config);
+ break;
}
return $vfs;
diff --git a/lib/Horde/Core/Factory/View.php b/lib/Horde/Core/Factory/View.php
index b57e3d7f1..e7165e8b7 100644
--- a/lib/Horde/Core/Factory/View.php
+++ b/lib/Horde/Core/Factory/View.php
@@ -1,4 +1,5 @@
getInstance('Horde_Registry');
- $view = new Horde_View(array('templatePath' => $registry->get('templates', $registry->getApp())));
+ $view = new Horde_View(['templatePath' => $registry->get('templates', $registry->getApp())]);
$view->addHelper('Tag');
$view->addHelper('Text');
return $view;
diff --git a/lib/Horde/Core/Factory/Weather.php b/lib/Horde/Core/Factory/Weather.php
index 90eff10ac..51929aad0 100644
--- a/lib/Horde/Core/Factory/Weather.php
+++ b/lib/Horde/Core/Factory/Weather.php
@@ -1,4 +1,5 @@
$injector->getInstance('Horde_Cache'),
'cache_lifetime' => $conf['weather']['params']['lifetime'],
- 'http_client' => $injector->createInstance('Horde_Core_Factory_HttpClient')->create()
- );
+ 'http_client' => $injector->createInstance('Horde_Core_Factory_HttpClient')->create(),
+ ];
$driver = $conf['weather']['provider'];
switch ($driver) {
- case 'WeatherUnderground':
- case 'Wwo':
- case 'Owm':
- $params['apikey'] = $conf['weather']['params']['key'];
- if (!empty($conf['weather']['params']['apiversion'])) {
- $params['apiVersion'] = $conf['weather']['params']['apiversion'];
- }
- break;
- case 'Metar':
- $params['db'] = $injector->getInstance('Horde_Db_Adapter');
- break;
+ case 'WeatherUnderground':
+ case 'Wwo':
+ case 'Owm':
+ $params['apikey'] = $conf['weather']['params']['key'];
+ if (!empty($conf['weather']['params']['apiversion'])) {
+ $params['apiVersion'] = $conf['weather']['params']['apiversion'];
+ }
+ break;
+ case 'Metar':
+ $params['db'] = $injector->getInstance('Horde_Db_Adapter');
+ break;
}
$class = $this->_getDriverName($driver, 'Horde_Service_Weather');
diff --git a/lib/Horde/Core/Group/Ldap.php b/lib/Horde/Core/Group/Ldap.php
index 67861bc99..32e0364d0 100644
--- a/lib/Horde/Core/Group/Ldap.php
+++ b/lib/Horde/Core/Group/Ldap.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Hooks')->callHook('groupldap', 'horde', array($name, $email))
+ $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook('groupldap', 'horde', [$name, $email])
);
} catch (Horde_Exception_HookNotSet $e) {
return parent::create($name, $email);
diff --git a/lib/Horde/Core/HashTable/PersistentSession.php b/lib/Horde/Core/HashTable/PersistentSession.php
index c317ce377..e445a1f63 100644
--- a/lib/Horde/Core/HashTable/PersistentSession.php
+++ b/lib/Horde/Core/HashTable/PersistentSession.php
@@ -1,4 +1,5 @@
$session->getToken(),
- 'vfspath' => self::VFS_PATH
- ));
+ 'vfspath' => self::VFS_PATH,
+ ]);
$this->gc(86400);
}
/**
*/
- public function set($key, $val, array $opts = array())
+ public function set($key, $val, array $opts = [])
{
global $session;
diff --git a/lib/Horde/Core/HashTable/Vfs.php b/lib/Horde/Core/HashTable/Vfs.php
index be98ee95b..1b226a9c9 100644
--- a/lib/Horde/Core/HashTable/Vfs.php
+++ b/lib/Horde/Core/HashTable/Vfs.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Vfs')->create();
- } catch (Horde_Vfs_Exception $e) {}
+ } catch (Horde_Vfs_Exception $e) {
+ }
if (!isset($vfs) || ($vfs instanceof Horde_Vfs_Null)) {
- $vfs = new Horde_Vfs_File(array('vfsroot' => Horde::getTempDir()));
+ $vfs = new Horde_Vfs_File(['vfsroot' => Horde::getTempDir()]);
}
- parent::__construct(array_merge($params, array(
+ parent::__construct(array_merge($params, [
'logger' => $injector->getInstance('Horde_Core_Log_Wrapper'),
- 'vfs' => $vfs
- )));
+ 'vfs' => $vfs,
+ ]));
}
/**
@@ -84,14 +85,14 @@ protected function _get($keys)
return parent::_get($keys);
}
- $out = array();
+ $out = [];
foreach ($keys as $key) {
try {
if (method_exists($this->_vfs, 'readStream')) {
- $data = new Horde_Stream_Existing(array(
- 'stream' => $this->_vfs->readStream($this->_params['vfspath'], $key)
- ));
+ $data = new Horde_Stream_Existing([
+ 'stream' => $this->_vfs->readStream($this->_params['vfspath'], $key),
+ ]);
$data->rewind();
} else {
$data = new Horde_Stream_Temp();
diff --git a/lib/Horde/Core/HashTable/Wrapper.php b/lib/Horde/Core/HashTable/Wrapper.php
index 00be0d8c2..afbc6bbc6 100644
--- a/lib/Horde/Core/HashTable/Wrapper.php
+++ b/lib/Horde/Core/HashTable/Wrapper.php
@@ -1,4 +1,5 @@
getInstance('Horde_HashTable'), $name),
+ [$GLOBALS['injector']->getInstance('Horde_HashTable'), $name],
$arguments
);
}
diff --git a/lib/Horde/Core/History.php b/lib/Horde/Core/History.php
index 445f7bcf8..317fab347 100644
--- a/lib/Horde/Core/History.php
+++ b/lib/Horde/Core/History.php
@@ -1,4 +1,5 @@
getAuth()
@@ -87,7 +88,7 @@ public function getHistory($guid)
/**
* @see Horde_History::getByTimestamp()
*/
- public function getByTimestamp($cmp, $ts, array $filters = array(), $parent = null)
+ public function getByTimestamp($cmp, $ts, array $filters = [], $parent = null)
{
return $this->_history->getByTimestamp($cmp, $ts, $filters, $parent);
}
@@ -95,7 +96,7 @@ public function getByTimestamp($cmp, $ts, array $filters = array(), $parent = nu
/**
* @see Horde_History:getByModSeq()
*/
- public function getByModSeq($start, $end, $filters = array(), $parent = null)
+ public function getByModSeq($start, $end, $filters = [], $parent = null)
{
return $this->_history->getByModSeq($start, $end, $filters, $parent);
}
@@ -159,7 +160,7 @@ protected function _log(Horde_History_Log $history, array $attributes, $replaceA
// Horde_History class to satisfy any typehints.
}
- public function _getByTimestamp($cmp, $ts, array $filters = array(), $parent = null)
+ public function _getByTimestamp($cmp, $ts, array $filters = [], $parent = null)
{
// NOOP
}
diff --git a/lib/Horde/Core/Hooks.php b/lib/Horde/Core/Hooks.php
index cade7a9a5..93ff38d99 100644
--- a/lib/Horde/Core/Hooks.php
+++ b/lib/Horde/Core/Hooks.php
@@ -1,4 +1,5 @@
hookExists($hook, $app)) {
throw new Horde_Exception_HookNotSet();
@@ -57,7 +58,7 @@ public function callHook($hook, $app = 'horde', array $args = array())
'DEBUG'
);
return call_user_func_array(
- array($this->_apps[$app], $hook),
+ [$this->_apps[$app], $hook],
$args
);
} catch (Horde_Exception $e) {
@@ -87,8 +88,9 @@ public function hookExists($hook, $app = 'horde')
if (!class_exists($hook_class, false)) {
try {
$registry->loadConfigFile('hooks.php', null, $app);
- $this->_apps[$app] = new $hook_class;
- } catch (Horde_Exception $e) {}
+ $this->_apps[$app] = new $hook_class();
+ } catch (Horde_Exception $e) {
+ }
}
}
diff --git a/lib/Horde/Core/HordeMap.php b/lib/Horde/Core/HordeMap.php
index fd8b440fc..fb4739b09 100644
--- a/lib/Horde/Core/HordeMap.php
+++ b/lib/Horde/Core/HordeMap.php
@@ -1,4 +1,5 @@
array(
+ $params = array_merge([
+ 'conf' => [
'language' => $language,
'markerImage' => strval(Horde_Themes::img('map/marker.png')),
'markerBackground' => strval(Horde_Themes::img('map/marker-shadow.png')),
'useMarkerLayer' => true,
- ),
+ ],
'driver' => 'Horde',
'geocoder' => $conf['maps']['geocoder'],
'jsuri' => $registry->get('jsuri', 'horde') . '/map/',
'ssl' => $browser->usingSSLConnection(),
- ), $params);
+ ], $params);
// If providers were not specified, use global. We don't merge them
// above to allow overriding the global completely.
@@ -65,24 +66,24 @@ public static function init(array $params = array())
foreach ($params['providers'] as $layer) {
switch ($layer) {
- case 'Google':
- $params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
- break;
+ case 'Google':
+ $params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
+ break;
}
}
if (!empty($params['geocoder'])) {
switch ($params['geocoder']) {
- case 'Google':
- $params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
- break;
+ case 'Google':
+ $params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
+ break;
}
}
$page_output->addScriptFile('map/map.js', 'horde');
- $page_output->addInlineScript(array(
- 'HordeMap.initialize(' . Horde_Serialize::serialize($params, HORDE_SERIALIZE::JSON) . ');'
- ));
+ $page_output->addInlineScript([
+ 'HordeMap.initialize(' . Horde_Serialize::serialize($params, HORDE_SERIALIZE::JSON) . ');',
+ ]);
}
}
diff --git a/lib/Horde/Core/Imsp/Utils.php b/lib/Horde/Core/Imsp/Utils.php
index 2e301db81..e3a8db870 100644
--- a/lib/Horde/Core/Imsp/Utils.php
+++ b/lib/Horde/Core/Imsp/Utils.php
@@ -1,4 +1,5 @@
getInstance('Horde_Core_Factory_Imsp')->create('Book', $serverInfo['params']);
$books = $imsp->getAddressBookList();
$bCount = count($books);
@@ -101,9 +102,9 @@ public static function createBook(array $source, $newName)
*/
public function synchShares($share_obj, array $serverInfo)
{
- $found_shares = array();
- $return = array('added' => array(), 'removed' => array());
- $params = array();
+ $found_shares = [];
+ $return = ['added' => [], 'removed' => []];
+ $params = [];
$imsp = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imsp')->create('Book', $serverInfo['params']);
$abooks = $imsp->getAddressBookList();
@@ -128,8 +129,8 @@ public function synchShares($share_obj, array $serverInfo)
}
}
if (!$found) {
- $shareparams = array('name' => $abook_uid,
- 'source' => 'imsp');
+ $shareparams = ['name' => $abook_uid,
+ 'source' => 'imsp'];
$params['uid'] = hash('md5', mt_rand());
$params['name'] = $abook_uid . ' (IMSP)';
@@ -140,9 +141,11 @@ public function synchShares($share_obj, array $serverInfo)
} else {
$shareparams['default'] = false;
}
- if (self::_isOwner($abook_uid,
- $serverInfo['params']['username'],
- $params['acl'])) {
+ if (self::_isOwner(
+ $abook_uid,
+ $serverInfo['params']['username'],
+ $params['acl']
+ )) {
$params['owner'] = $GLOBALS['registry']->getAuth();
} else {
// TODO: What to do for the owner when it's not current user?
@@ -160,15 +163,15 @@ public function synchShares($share_obj, array $serverInfo)
}
// Now prune any shares that no longer exist on the IMSP server.
- $existing = $share_obj->listShares($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::READ));
+ $existing = $share_obj->listShares($GLOBALS['registry']->getAuth(), ['perm' => Horde_Perms::READ]);
foreach ($existing as $share) {
$temp = unserialize($share->get('params'));
if (is_array($temp)) {
$sourceType = $temp['source'];
if ($sourceType == 'imsp' &&
array_search($temp['name'], $found_shares) === false) {
- $share_obj->removeShare($share);
- $return['removed'][] = $share->getName();
+ $share_obj->removeShare($share);
+ $return['removed'][] = $share->getName();
}
}
}
@@ -224,19 +227,19 @@ protected static function _isOwner($bookName, $username, $acl)
*/
protected static function _setPerms(&$share, $acl)
{
- $hPerms = 0;
- if (strpos($acl, 'w') !== false) {
- $hPerms |= Horde_Perms::EDIT;
- }
- if (strpos($acl, 'r') !== false) {
- $hPerms |= Horde_Perms::READ;
- }
- if (strpos($acl, 'd') !== false) {
- $hPerms |= Horde_Perms::DELETE;
- }
- if (strpos($acl, 'l') !== false) {
- $hPerms |= Horde_Perms::SHOW;
- }
+ $hPerms = 0;
+ if (strpos($acl, 'w') !== false) {
+ $hPerms |= Horde_Perms::EDIT;
+ }
+ if (strpos($acl, 'r') !== false) {
+ $hPerms |= Horde_Perms::READ;
+ }
+ if (strpos($acl, 'd') !== false) {
+ $hPerms |= Horde_Perms::DELETE;
+ }
+ if (strpos($acl, 'l') !== false) {
+ $hPerms |= Horde_Perms::SHOW;
+ }
$share->addUserPermission($GLOBALS['registry']->getAuth(), $hPerms);
}
diff --git a/lib/Horde/Core/Itip/Response/Options/Horde.php b/lib/Horde/Core/Itip/Response/Options/Horde.php
index 80aff4542..065588cdf 100644
--- a/lib/Horde/Core/Itip/Response/Options/Horde.php
+++ b/lib/Horde/Core/Itip/Response/Options/Horde.php
@@ -1,4 +1,5 @@
getType());
if (empty($app)) {
Horde::log(sprintf(
- 'Unsupported app type: %s', $data->getType()), 'WARN');
+ 'Unsupported app type: %s',
+ $data->getType()
+ ), 'WARN');
return false;
}
@@ -44,7 +46,7 @@ public static function getPrefix(Horde_Kolab_Storage_Data $data)
->create($app)
->listAllShares();
- foreach($all_shares as $id => $share) {
+ foreach ($all_shares as $id => $share) {
if ($folder == $share->get('folder')) {
$share_id = $id;
break;
@@ -75,13 +77,13 @@ protected static function _type2app($type)
global $registry;
if (!isset(self::$_mapping)) {
- self::$_mapping = array(
+ self::$_mapping = [
'contact' => $registry->hasInterface('contacts'),
'distribution-list' => $registry->hasInterface('contacts'),
'event' => $registry->hasInterface('calendar'),
'note' => $registry->hasInterface('notes'),
- 'task' => $registry->hasInterface('tasks')
- );
+ 'task' => $registry->hasInterface('tasks'),
+ ];
}
return !empty(self::$_mapping[$type])
@@ -89,4 +91,4 @@ protected static function _type2app($type)
: false;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Horde/Core/Log/Logger.php b/lib/Horde/Core/Log/Logger.php
index 47c857a33..84103cad3 100644
--- a/lib/Horde/Core/Log/Logger.php
+++ b/lib/Horde/Core/Log/Logger.php
@@ -1,4 +1,5 @@
details)) {
$text .= ' ' . $event->details;
}
- $trace = array(
+ $trace = [
'file' => $event->getFile(),
- 'line' => $event->getLine()
- );
+ 'line' => $event->getLine(),
+ ];
if (empty($options['notracelog']) &&
class_exists('Horde_Support_Backtrace')) {
@@ -149,7 +153,7 @@ class_exists('Horde_Support_Backtrace')) {
} elseif (is_object($event)) {
$text = strval($event);
if (!is_string($text)) {
- $text = is_callable(array($event, 'getMessage'))
+ $text = is_callable([$event, 'getMessage'])
? $event->getMessage()
: '';
}
@@ -164,11 +168,11 @@ class_exists('Horde_Support_Backtrace')) {
: 0;
while ($frame < $trace_count) {
if (isset($trace[$frame]['class'])) {
- if (!in_array($trace[$frame]['class'], array('Horde_Log_Logger', 'Horde_Core_Log_Logger'))) {
+ if (!in_array($trace[$frame]['class'], ['Horde_Log_Logger', 'Horde_Core_Log_Logger'])) {
break;
}
} elseif (isset($trace[$frame]['function']) &&
- !in_array($trace[$frame]['function'], array('call_user_func', 'call_user_func_array'))) {
+ !in_array($trace[$frame]['function'], ['call_user_func', 'call_user_func_array'])) {
break;
}
++$frame;
@@ -190,12 +194,10 @@ class_exists('Horde_Support_Backtrace')) {
' [pid ' . getmypid();
if (isset($options['file']) || isset($trace['file'])) {
- $file = isset($options['file'])
- ? $options['file']
- : $trace['file'];
- $line = isset($options['line'])
- ? $options['line']
- : $trace['line'];
+ $file = $options['file']
+ ?? $trace['file'];
+ $line = $options['line']
+ ?? $trace['line'];
$this->_message .= ' on line ' . $line . ' of "' . $file . '"]';
} else {
@@ -211,13 +213,13 @@ class_exists('Horde_Support_Backtrace')) {
public function __get($name)
{
switch ($name) {
- case 'backtrace':
- case 'logged':
- case 'message':
- case 'priority':
- case 'timestamp':
- $varname = '_' . $name;
- return $this->$varname;
+ case 'backtrace':
+ case 'logged':
+ case 'message':
+ case 'priority':
+ case 'timestamp':
+ $varname = '_' . $name;
+ return $this->$varname;
}
}
@@ -226,28 +228,28 @@ public function __get($name)
public function __set($name, $value)
{
switch ($name) {
- case 'logged':
- if ($value && $this->_exception instanceof HordeException) {
- $this->_exception->logged = true;
- }
- $this->_logged = $value;
- break;
-
- case 'message':
- $this->_message = strval($value);
- break;
-
- case 'priority':
- if (is_integer($value)) {
- $this->_priority = $value;
- } elseif (defined('Horde_Log::' . $value)) {
- $this->_priority = constant('Horde_Log::' . $value);
- }
- break;
+ case 'logged':
+ if ($value && $this->_exception instanceof HordeException) {
+ $this->_exception->logged = true;
+ }
+ $this->_logged = $value;
+ break;
+
+ case 'message':
+ $this->_message = strval($value);
+ break;
+
+ case 'priority':
+ if (is_integer($value)) {
+ $this->_priority = $value;
+ } elseif (defined('Horde_Log::' . $value)) {
+ $this->_priority = constant('Horde_Log::' . $value);
+ }
+ break;
- case 'timestamp':
- $this->_timestamp = intval($value);
- break;
+ case 'timestamp':
+ $this->_timestamp = intval($value);
+ break;
}
}
@@ -260,10 +262,10 @@ public function toArray()
{
global $conf;
- $out = array(
+ $out = [
'level' => $this->priority,
- 'message' => $this->message
- );
+ 'message' => $this->message,
+ ];
if (!empty($conf['log']['time_format'])) {
$out['timestamp'] = date($conf['log']['time_format'], $this->timestamp);
diff --git a/lib/Horde/Core/Log/Wrapper.php b/lib/Horde/Core/Log/Wrapper.php
index f027ec11f..636342df1 100644
--- a/lib/Horde/Core/Log/Wrapper.php
+++ b/lib/Horde/Core/Log/Wrapper.php
@@ -1,4 +1,5 @@
getInstance('Horde_Log_Logger'), $name),
+ [$GLOBALS['injector']->getInstance('Horde_Log_Logger'), $name],
$arguments
);
}
diff --git a/lib/Horde/Core/LoginTasks.php b/lib/Horde/Core/LoginTasks.php
index 30904ff4e..994038c5a 100644
--- a/lib/Horde/Core/LoginTasks.php
+++ b/lib/Horde/Core/LoginTasks.php
@@ -1,4 +1,5 @@
getAppDrivers($this->_app, 'LoginTasks_SystemTask'), $GLOBALS['registry']->getAppDrivers($this->_app, 'LoginTasks_Task')) as $val) {
$tasks[$val] = $this->_app;
@@ -83,12 +84,12 @@ public function getLastRun()
try {
$lasttask_pref = @unserialize($GLOBALS['prefs']->getValue('last_logintasks'));
} catch (Horde_Prefs_Exception $e) {
- return array();
+ return [];
}
return is_array($lasttask_pref)
? $lasttask_pref
- : array();
+ : [];
}
/**
diff --git a/lib/Horde/Core/LoginTasks/SystemTask/Upgrade.php b/lib/Horde/Core/LoginTasks/SystemTask/Upgrade.php
index 48c566fd9..157a21614 100644
--- a/lib/Horde/Core/LoginTasks/SystemTask/Upgrade.php
+++ b/lib/Horde/Core/LoginTasks/SystemTask/Upgrade.php
@@ -1,4 +1,5 @@
_toupgrade[] = $val;
@@ -114,7 +115,7 @@ public function skip()
{
/* Skip task until we are authenticated. */
return ($this->_auth &&
- !$GLOBALS['registry']->isAuthenticated(array('app' => $this->_app)));
+ !$GLOBALS['registry']->isAuthenticated(['app' => $this->_app]));
}
/**
@@ -136,17 +137,16 @@ protected function _pref($action)
$upgrade = @unserialize($prefs->getValue('upgrade_tasks'));
switch ($action) {
- case 'get':
- $val = isset($upgrade[$key])
- ? $upgrade[$key]
- : null;
- break;
-
- case 'set':
- $val = $registry->getVersion($this->_app, true);
- $upgrade[$key] = $val;
- $prefs->setValue('upgrade_tasks', serialize($upgrade));
- break;
+ case 'get':
+ $val = $upgrade[$key]
+ ?? null;
+ break;
+
+ case 'set':
+ $val = $registry->getVersion($this->_app, true);
+ $upgrade[$key] = $val;
+ $prefs->setValue('upgrade_tasks', serialize($upgrade));
+ break;
}
return $val;
diff --git a/lib/Horde/Core/Mime/Headers/Received.php b/lib/Horde/Core/Mime/Headers/Received.php
index b4703db6c..1050a15a5 100644
--- a/lib/Horde/Core/Mime/Headers/Received.php
+++ b/lib/Horde/Core/Mime/Headers/Received.php
@@ -1,4 +1,5 @@
Horde hop (conforms
diff --git a/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php b/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php
index 08f9edd56..dd247bd4f 100644
--- a/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php
+++ b/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php
@@ -1,4 +1,5 @@
true,
'info' => false,
'inline' => true,
- 'raw' => false
- );
+ 'raw' => false,
+ ];
/**
* URL that can be used as a callback for displaying images.
@@ -45,14 +46,14 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
*
* @throws InvalidArgumentException
*/
- public function __construct(Horde_Mime_Part $part, array $conf = array())
+ public function __construct(Horde_Mime_Part $part, array $conf = [])
{
- $this->_required = array_merge($this->_required, array(
+ $this->_required = array_merge($this->_required, [
'browser',
'notification',
'prefs',
- 'registry'
- ));
+ 'registry',
+ ]);
parent::__construct($part, $conf);
}
@@ -96,11 +97,11 @@ protected function _renderInline()
$data = $this->_mimepart->getContents();
$html = '';
- $title = Horde_Core_Translation::t("vCard");
+ $title = Horde_Core_Translation::t('vCard');
$iCal = new Horde_Icalendar();
if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
- $notification->push(Horde_Core_Translation::t("There was an error reading the contact data."), 'horde.error');
+ $notification->push(Horde_Core_Translation::t('There was an error reading the contact data.'), 'horde.error');
}
if (Horde_Util::getFormData('import') &&
@@ -111,19 +112,24 @@ protected function _renderInline()
foreach ($iCal->getComponents() as $c) {
if ($c->getType() == 'vcard') {
try {
- $registry->call('contacts/import', array($c, null, $source));
+ $registry->call('contacts/import', [$c, null, $source]);
++$count;
} catch (Horde_Exception $e) {
- $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
+ $notification->push(Horde_Core_Translation::t('There was an error importing the contact data:') . ' ' . $e->getMessage(), 'horde.error');
}
}
}
- $notification->push(sprintf(Horde_Core_Translation::ngettext(
- "%d contact was successfully added to your address book.",
- "%d contacts were successfully added to your address book.",
- $count),
- $count),
- 'horde.success');
+ $notification->push(
+ sprintf(
+ Horde_Core_Translation::ngettext(
+ '%d contact was successfully added to your address book.',
+ '%d contacts were successfully added to your address book.',
+ $count
+ ),
+ $count
+ ),
+ 'horde.success'
+ );
}
$html .= '';
@@ -139,46 +145,55 @@ protected function _renderInline()
if (($fullname = $vc->getAttributeDefault('FN', false)) === false) {
$fullname = count($addresses)
? $addresses[0]['value']
- : Horde_Core_Translation::t("[No Label]");
+ : Horde_Core_Translation::t('[No Label]');
}
$html .= htmlspecialchars($fullname) . '';
$n = $vc->printableName();
if (!empty($n)) {
- $html .= $this->_row(Horde_Core_Translation::t("Name"), $n);
+ $html .= $this->_row(Horde_Core_Translation::t('Name'), $n);
}
try {
- $html .= $this->_row(Horde_Core_Translation::t("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
- } catch (Horde_Icalendar_Exception $e) {}
+ $html .= $this->_row(Horde_Core_Translation::t('Alias'), implode("\n", $vc->getAttributeValues('ALIAS')));
+ } catch (Horde_Icalendar_Exception $e) {
+ }
try {
$birthdays = $vc->getAttributeValues('BDAY');
$birthday = new Horde_Date($birthdays[0]);
$html .= $this->_row(
- Horde_Core_Translation::t("Birthday"),
- $birthday->strftime($prefs->getValue('date_format')));
- } catch (Horde_Icalendar_Exception $e) {}
+ Horde_Core_Translation::t('Birthday'),
+ $birthday->strftime($prefs->getValue('date_format'))
+ );
+ } catch (Horde_Icalendar_Exception $e) {
+ }
$photos = $vc->getAllAttributes('PHOTO');
foreach ($photos as $p => $photo) {
if (isset($photo['params']['VALUE']) &&
Horde_String::upper($photo['params']['VALUE']) == 'URI') {
- $html .= $this->_row(Horde_Core_Translation::t("Photo"),
- '
',
- false);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Photo'),
+ '
',
+ false
+ );
} elseif (isset($photo['params']['ENCODING']) &&
Horde_String::upper($photo['params']['ENCODING']) == 'B' &&
isset($photo['params']['TYPE'])) {
if ($browser->hasFeature('datauri') === true ||
$browser->hasFeature('datauri') >= strlen($photo['value'])) {
- $html .= $this->_row(Horde_Core_Translation::t("Photo"),
- '
',
- false);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Photo'),
+ '
',
+ false
+ );
} elseif ($this->_imageUrl) {
- $html .= $this->_row(Horde_Core_Translation::t("Photo"),
- '
',
- false);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Photo'),
+ '
',
+ false
+ );
}
}
}
@@ -187,45 +202,45 @@ protected function _renderInline()
foreach ($labels as $label) {
if (isset($label['params']['TYPE'])) {
if (!is_array($label['params']['TYPE'])) {
- $label['params']['TYPE'] = array($label['params']['TYPE']);
+ $label['params']['TYPE'] = [$label['params']['TYPE']];
}
} else {
$label['params']['TYPE'] = array_keys($label['params']);
}
- $types = array();
+ $types = [];
foreach ($label['params']['TYPE'] as $type) {
- switch(Horde_String::upper($type)) {
- case 'HOME':
- $types[] = Horde_Core_Translation::t("Home Address");
- break;
-
- case 'WORK':
- $types[] = Horde_Core_Translation::t("Work Address");
- break;
-
- case 'DOM':
- $types[] = Horde_Core_Translation::t("Domestic Address");
- break;
-
- case 'INTL':
- $types[] = Horde_Core_Translation::t("International Address");
- break;
-
- case 'POSTAL':
- $types[] = Horde_Core_Translation::t("Postal Address");
- break;
-
- case 'PARCEL':
- $types[] = Horde_Core_Translation::t("Parcel Address");
- break;
-
- case 'PREF':
- $types[] = Horde_Core_Translation::t("Preferred Address");
- break;
+ switch (Horde_String::upper($type)) {
+ case 'HOME':
+ $types[] = Horde_Core_Translation::t('Home Address');
+ break;
+
+ case 'WORK':
+ $types[] = Horde_Core_Translation::t('Work Address');
+ break;
+
+ case 'DOM':
+ $types[] = Horde_Core_Translation::t('Domestic Address');
+ break;
+
+ case 'INTL':
+ $types[] = Horde_Core_Translation::t('International Address');
+ break;
+
+ case 'POSTAL':
+ $types[] = Horde_Core_Translation::t('Postal Address');
+ break;
+
+ case 'PARCEL':
+ $types[] = Horde_Core_Translation::t('Parcel Address');
+ break;
+
+ case 'PREF':
+ $types[] = Horde_Core_Translation::t('Preferred Address');
+ break;
}
}
if (!count($types)) {
- $types = array(Horde_Core_Translation::t("Address"));
+ $types = [Horde_Core_Translation::t('Address')];
}
$html .= $this->_row(implode('/', $types), $label['value']);
}
@@ -234,21 +249,21 @@ protected function _renderInline()
foreach ($adrs as $item) {
if (isset($item['params']['TYPE'])) {
if (!is_array($item['params']['TYPE'])) {
- $item['params']['TYPE'] = array($item['params']['TYPE']);
+ $item['params']['TYPE'] = [$item['params']['TYPE']];
}
} else {
$item['params']['TYPE'] = array_keys($item['params']);
}
$address = $item['values'];
- $a = array();
- $a_list = array(
+ $a = [];
+ $a_list = [
Horde_Icalendar_Vcard::ADR_STREET,
Horde_Icalendar_Vcard::ADR_LOCALITY,
Horde_Icalendar_Vcard::ADR_REGION,
Horde_Icalendar_Vcard::ADR_POSTCODE,
- Horde_Icalendar_Vcard::ADR_COUNTRY
- );
+ Horde_Icalendar_Vcard::ADR_COUNTRY,
+ ];
foreach ($a_list as $val) {
if (isset($address[$val])) {
@@ -256,40 +271,40 @@ protected function _renderInline()
}
}
- $types = array();
+ $types = [];
foreach ($item['params']['TYPE'] as $type) {
- switch(Horde_String::upper($type)) {
- case 'HOME':
- $types[] = Horde_Core_Translation::t("Home Address");
- break;
-
- case 'WORK':
- $types[] = Horde_Core_Translation::t("Work Address");
- break;
-
- case 'DOM':
- $types[] = Horde_Core_Translation::t("Domestic Address");
- break;
-
- case 'INTL':
- $types[] = Horde_Core_Translation::t("International Address");
- break;
-
- case 'POSTAL':
- $types[] = Horde_Core_Translation::t("Postal Address");
- break;
-
- case 'PARCEL':
- $types[] = Horde_Core_Translation::t("Parcel Address");
- break;
-
- case 'PREF':
- $types[] = Horde_Core_Translation::t("Preferred Address");
- break;
+ switch (Horde_String::upper($type)) {
+ case 'HOME':
+ $types[] = Horde_Core_Translation::t('Home Address');
+ break;
+
+ case 'WORK':
+ $types[] = Horde_Core_Translation::t('Work Address');
+ break;
+
+ case 'DOM':
+ $types[] = Horde_Core_Translation::t('Domestic Address');
+ break;
+
+ case 'INTL':
+ $types[] = Horde_Core_Translation::t('International Address');
+ break;
+
+ case 'POSTAL':
+ $types[] = Horde_Core_Translation::t('Postal Address');
+ break;
+
+ case 'PARCEL':
+ $types[] = Horde_Core_Translation::t('Parcel Address');
+ break;
+
+ case 'PREF':
+ $types[] = Horde_Core_Translation::t('Preferred Address');
+ break;
}
}
if (!count($types)) {
- $types = array(Horde_Core_Translation::t("Address"));
+ $types = [Horde_Core_Translation::t('Address')];
}
$html .= $this->_row(implode('/', $types), implode("\n", $a));
}
@@ -299,36 +314,44 @@ protected function _renderInline()
foreach ($numbers as $number) {
if (isset($number['params']['TYPE'])) {
if (!is_array($number['params']['TYPE'])) {
- $number['params']['TYPE'] = array($number['params']['TYPE']);
+ $number['params']['TYPE'] = [$number['params']['TYPE']];
}
foreach ($number['params']['TYPE'] as $type) {
$number['params'][Horde_String::upper($type)] = true;
}
}
if (isset($number['params']['FAX'])) {
- $html .= $this->_row(Horde_Core_Translation::t("Fax"), $number['value']);
+ $html .= $this->_row(Horde_Core_Translation::t('Fax'), $number['value']);
} else {
if (isset($number['params']['HOME'])) {
- $html .= $this->_row(Horde_Core_Translation::t("Home Phone"),
- $number['value']);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Home Phone'),
+ $number['value']
+ );
} elseif (isset($number['params']['WORK'])) {
- $html .= $this->_row(Horde_Core_Translation::t("Work Phone"),
- $number['value']);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Work Phone'),
+ $number['value']
+ );
} elseif (isset($number['params']['CELL'])) {
- $html .= $this->_row(Horde_Core_Translation::t("Cell Phone"),
- $number['value']);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Cell Phone'),
+ $number['value']
+ );
} else {
- $html .= $this->_row(Horde_Core_Translation::t("Phone"),
- $number['value']);
+ $html .= $this->_row(
+ Horde_Core_Translation::t('Phone'),
+ $number['value']
+ );
}
}
}
- $emails = array();
+ $emails = [];
foreach ($addresses as $address) {
if (isset($address['params']['TYPE'])) {
if (!is_array($address['params']['TYPE'])) {
- $address['params']['TYPE'] = array($address['params']['TYPE']);
+ $address['params']['TYPE'] = [$address['params']['TYPE']];
}
foreach ($address['params']['TYPE'] as $type) {
$address['params'][Horde_String::upper($type)] = true;
@@ -338,7 +361,8 @@ protected function _renderInline()
if ($registry->hasMethod('mail/compose')) {
$email .= $registry->call(
'mail/compose',
- array(array('to' => $address['value'])));
+ [['to' => $address['value']]]
+ );
} else {
$email .= 'mailto:' . htmlspecialchars($address['value']);
}
@@ -351,41 +375,47 @@ protected function _renderInline()
}
if (count($emails)) {
- $html .= $this->_row(Horde_Core_Translation::t("Email"), implode("\n", $emails), false);
+ $html .= $this->_row(Horde_Core_Translation::t('Email'), implode("\n", $emails), false);
}
try {
$title = $vc->getAttributeValues('TITLE');
- $html .= $this->_row(Horde_Core_Translation::t("Title"), $title[0]);
- } catch (Horde_Icalendar_Exception $e) {}
+ $html .= $this->_row(Horde_Core_Translation::t('Title'), $title[0]);
+ } catch (Horde_Icalendar_Exception $e) {
+ }
try {
$role = $vc->getAttributeValues('ROLE');
- $html .= $this->_row(Horde_Core_Translation::t("Role"), $role[0]);
- } catch (Horde_Icalendar_Exception $e) {}
+ $html .= $this->_row(Horde_Core_Translation::t('Role'), $role[0]);
+ } catch (Horde_Icalendar_Exception $e) {
+ }
try {
$org = $vc->getAttributeValues('ORG');
- $html .= $this->_row(Horde_Core_Translation::t("Company"), $org[0]);
+ $html .= $this->_row(Horde_Core_Translation::t('Company'), $org[0]);
if (isset($org[1])) {
- $html .= $this->_row(Horde_Core_Translation::t("Department"), $org[1]);
+ $html .= $this->_row(Horde_Core_Translation::t('Department'), $org[1]);
}
- } catch (Horde_Icalendar_Exception $e) {}
+ } catch (Horde_Icalendar_Exception $e) {
+ }
try {
$notes = $vc->getAttributeValues('NOTE');
- $html .= $this->_row(Horde_Core_Translation::t("Notes"), $notes[0]);
- } catch (Horde_Icalendar_Exception $e) {}
+ $html .= $this->_row(Horde_Core_Translation::t('Notes'), $notes[0]);
+ } catch (Horde_Icalendar_Exception $e) {
+ }
try {
$url = $vc->getAttributeValues('URL');
$html .= $this->_row(
- Horde_Core_Translation::t("URL"),
+ Horde_Core_Translation::t('URL'),
'' . htmlspecialchars($url[0])
. '',
- false);
- } catch (Horde_Icalendar_Exception $e) {}
+ false
+ );
+ } catch (Horde_Icalendar_Exception $e) {
+ }
}
$html .= '
';
@@ -400,13 +430,13 @@ protected function _renderInline()
. '" value="' . htmlspecialchars($val) . '" />';
}
- $sources = $registry->call('contacts/sources', array(true));
+ $sources = $registry->call('contacts/sources', [true]);
if (count($sources) > 1) {
$html .=
''
+ . Horde_Core_Translation::t('Add to address book:') . '" />'
. ' '
+ . Horde_Core_Translation::t('Address Book') . ''
. '';
foreach ($sources as $key => $label) {
$selected = ($key == $prefs->getValue('add_source'))
@@ -420,7 +450,7 @@ protected function _renderInline()
reset($sources);
$html .=
''
+ . Horde_Core_Translation::t('Add to my address book') . '" />'
. '';
}
@@ -429,7 +459,7 @@ protected function _renderInline()
}
Horde::startBuffer();
- $notification->notify(array('listeners' => 'status'));
+ $notification->notify(['listeners' => 'status']);
return $this->_renderReturn(
Horde::endBuffer() . $html,
diff --git a/lib/Horde/Core/Nosql.php b/lib/Horde/Core/Nosql.php
index 41616d25a..e90e237bd 100644
--- a/lib/Horde/Core/Nosql.php
+++ b/lib/Horde/Core/Nosql.php
@@ -1,4 +1,5 @@
callAppMethod($app, 'nosqlDrivers');
} catch (Horde_Exception $e) {
- return array();
+ return [];
}
/* Handle framework-level drivers here. */
if ($app == 'horde') {
- $backends = array(
- 'Horde_ActiveSync_State_Mongo' => function() use ($injector) {
+ $backends = [
+ 'Horde_ActiveSync_State_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_ActiveSyncState');
},
- 'Horde_Cache_Storage_Mongo' => function() use ($injector) {
+ 'Horde_Cache_Storage_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Core_Factory_Cache')->storage;
},
- 'Horde_History_Mongo' => function() use ($injector) {
+ 'Horde_History_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_History');
},
- 'Horde_Lock_Mongo' => function() use ($injector) {
+ 'Horde_Lock_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Lock');
},
- 'Horde_Prefs_Storage_Mongo' => function() use ($injector) {
+ 'Horde_Prefs_Storage_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Core_Factory_Prefs')->storage;
},
- 'Horde_SessionHandler_Storage_Mongo' => function() use ($injector) {
+ 'Horde_SessionHandler_Storage_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Core_Factory_SessionHandler')->storage;
},
- 'Horde_Token_Mongo' => function() use ($injector) {
+ 'Horde_Token_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Token');
},
- 'Horde_Vfs_Mongo' => function() use ($injector) {
+ 'Horde_Vfs_Mongo' => function () use ($injector) {
return $injector->getInstance('Horde_Core_Factory_Vfs')->create();
},
- );
+ ];
foreach ($backends as $key => $func) {
try {
diff --git a/lib/Horde/Core/Notification/Event/Status.php b/lib/Horde/Core/Notification/Event/Status.php
index 400cce834..e32354b12 100644
--- a/lib/Horde/Core/Notification/Event/Status.php
+++ b/lib/Horde/Core/Notification/Event/Status.php
@@ -1,4 +1,5 @@
type) {
- case 'horde.alarm':
- $alarm = $this->flags['alarm'];
- $text = $alarm['title'];
-
- if (!empty($alarm['params']['notify']['show'])) {
- try {
- $text = Horde::link(Horde::url($GLOBALS['registry']->linkByPackage($alarm['params']['notify']['show']['__app'], 'show', $alarm['params']['notify']['show'])), $alarm['text']) . $text . '';
- } catch (Horde_Exception $e) {
- return $e->getMessage();
- }
- }
-
- if (!empty($alarm['user']) &&
- $GLOBALS['browser']->hasFeature('xmlhttpreq')) {
- try {
- $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/snooze.php', true);
- } catch (Horde_Exception $e) {
- return $e->getMessage();
+ case 'horde.alarm':
+ $alarm = $this->flags['alarm'];
+ $text = $alarm['title'];
+
+ if (!empty($alarm['params']['notify']['show'])) {
+ try {
+ $text = Horde::link(Horde::url($GLOBALS['registry']->linkByPackage($alarm['params']['notify']['show']['__app'], 'show', $alarm['params']['notify']['show'])), $alarm['text']) . $text . '';
+ } catch (Horde_Exception $e) {
+ return $e->getMessage();
+ }
}
- $opts = array(
- '-1' => Horde_Core_Translation::t("Dismiss"),
- '5' => Horde_Core_Translation::t("5 minutes"),
- '15' => Horde_Core_Translation::t("15 minutes"),
- '60' => Horde_Core_Translation::t("1 hour"),
- '360' => Horde_Core_Translation::t("6 hours"),
- '1440' => Horde_Core_Translation::t("1 day")
- );
- $id = 'snooze_' . hash('md5', $alarm['id']);
- $text .= ' [' . Horde_Core_Translation::t("Snooze...") . ' ';
- $first = true;
- foreach ($opts as $minutes => $desc) {
- if (!$first) {
- $text .= ', ';
+
+ if (!empty($alarm['user']) &&
+ $GLOBALS['browser']->hasFeature('xmlhttpreq')) {
+ try {
+ $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/snooze.php', true);
+ } catch (Horde_Exception $e) {
+ return $e->getMessage();
+ }
+ $opts = [
+ '-1' => Horde_Core_Translation::t('Dismiss'),
+ '5' => Horde_Core_Translation::t('5 minutes'),
+ '15' => Horde_Core_Translation::t('15 minutes'),
+ '60' => Horde_Core_Translation::t('1 hour'),
+ '360' => Horde_Core_Translation::t('6 hours'),
+ '1440' => Horde_Core_Translation::t('1 day'),
+ ];
+ $id = 'snooze_' . hash('md5', $alarm['id']);
+ $text .= ' [' . Horde_Core_Translation::t('Snooze...') . ' ';
+ $first = true;
+ foreach ($opts as $minutes => $desc) {
+ if (!$first) {
+ $text .= ', ';
+ }
+ $text .= Horde::link('#', '', '', '', 'new Ajax.Request(\'' . $url . '\',{parameters:{alarm:\'' . $alarm['id'] . '\',snooze:' . $minutes . '},onSuccess:function(){Element.remove(this);}.bind(this.parentNode.parentNode.parentNode)});return false;') . $desc . '';
+ $first = false;
}
- $text .= Horde::link('#', '', '', '', 'new Ajax.Request(\'' . $url . '\',{parameters:{alarm:\'' . $alarm['id'] . '\',snooze:' . $minutes . '},onSuccess:function(){Element.remove(this);}.bind(this.parentNode.parentNode.parentNode)});return false;') . $desc . '';
- $first = false;
+ $text .= ']';
}
- $text .= ']';
- }
-
- $img = 'alerts/alarm.png';
- $label = Horde_Core_Translation::t("Alarm");
- break;
-
- case 'horde.error':
- $img = 'alerts/error.png';
- $label = Horde_Core_Translation::t("Error");
- break;
-
- case 'horde.message':
- $img = 'alerts/message.png';
- $label = Horde_Core_Translation::t("Message");
- break;
-
- case 'horde.success':
- $img = 'alerts/success.png';
- $label = Horde_Core_Translation::t("Success");
- break;
-
- case 'horde.warning':
- $img = 'alerts/warning.png';
- $label = Horde_Core_Translation::t("Warning");
- break;
-
- default:
- return parent::__toString();
+
+ $img = 'alerts/alarm.png';
+ $label = Horde_Core_Translation::t('Alarm');
+ break;
+
+ case 'horde.error':
+ $img = 'alerts/error.png';
+ $label = Horde_Core_Translation::t('Error');
+ break;
+
+ case 'horde.message':
+ $img = 'alerts/message.png';
+ $label = Horde_Core_Translation::t('Message');
+ break;
+
+ case 'horde.success':
+ $img = 'alerts/success.png';
+ $label = Horde_Core_Translation::t('Success');
+ break;
+
+ case 'horde.warning':
+ $img = 'alerts/warning.png';
+ $label = Horde_Core_Translation::t('Warning');
+ break;
+
+ default:
+ return parent::__toString();
}
- return Horde_Themes_Image::tag($img, array('alt' => $label)) .
+ return Horde_Themes_Image::tag($img, ['alt' => $label]) .
'' .
(is_null($text) ? parent::__toString() : $text) .
'
';
diff --git a/lib/Horde/Core/Notification/Event/Webnotification.php b/lib/Horde/Core/Notification/Event/Webnotification.php
index 7f0f5e7bf..86027e7e2 100644
--- a/lib/Horde/Core/Notification/Event/Webnotification.php
+++ b/lib/Horde/Core/Notification/Event/Webnotification.php
@@ -1,4 +1,5 @@
webnotify = $opts;
diff --git a/lib/Horde/Core/Notification/Handler.php b/lib/Horde/Core/Notification/Handler.php
index b56f6fd5e..92e57350e 100644
--- a/lib/Horde/Core/Notification/Handler.php
+++ b/lib/Horde/Core/Notification/Handler.php
@@ -1,4 +1,5 @@
_apps) {
foreach ($this->_apps as $key => $val) {
@@ -63,12 +63,12 @@ public function attachAllAppHandlers()
return;
}
- $this->_apps = array();
+ $this->_apps = [];
try {
$apps = $registry->listApps(null, false, Horde_Perms::READ);
} catch (Horde_Exception $e) {
- $apps = array();
+ $apps = [];
}
foreach ($apps as $app) {
@@ -100,12 +100,13 @@ public function addAppHandler($app)
$registry->callAppMethod(
$app,
'setupNotification',
- array(
- 'args' => array($this),
- 'noperms' => true
- )
+ [
+ 'args' => [$this],
+ 'noperms' => true,
+ ]
);
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
}
}
diff --git a/lib/Horde/Core/Notification/Handler/Decorator/Base.php b/lib/Horde/Core/Notification/Handler/Decorator/Base.php
index 03df0b1a9..d0f0b8039 100644
--- a/lib/Horde/Core/Notification/Handler/Decorator/Base.php
+++ b/lib/Horde/Core/Notification/Handler/Decorator/Base.php
@@ -1,4 +1,5 @@
pushApp($this->_app, array(
+ $pushed = $registry->pushApp($this->_app, [
'check_perms' => true,
- 'logintasks' => false
- ));
+ 'logintasks' => false,
+ ]);
} catch (Exception $e) {
return;
}
@@ -81,17 +82,16 @@ protected function _push(Horde_Notification_Event $event, $options)
public function notify(
Horde_Notification_Handler $handler,
Horde_Notification_Listener $listener
- )
- {
+ ) {
global $registry;
$error = null;
try {
- $pushed = $registry->pushApp($this->_app, array(
+ $pushed = $registry->pushApp($this->_app, [
'check_perms' => true,
- 'logintasks' => false
- ));
+ 'logintasks' => false,
+ ]);
} catch (Exception $e) {
return;
}
@@ -118,8 +118,7 @@ public function notify(
protected function _notify(
Horde_Notification_Handler $handler,
Horde_Notification_Listener $listener
- )
- {
+ ) {
parent::notify($handler, $listener);
}
diff --git a/lib/Horde/Core/Notification/Handler/Decorator/Hordelog.php b/lib/Horde/Core/Notification/Handler/Decorator/Hordelog.php
index 504c1dc83..4a5088c61 100644
--- a/lib/Horde/Core/Notification/Handler/Decorator/Hordelog.php
+++ b/lib/Horde/Core/Notification/Handler/Decorator/Hordelog.php
@@ -1,4 +1,5 @@
addInlineScript(array(
- 'window.HordeCore.showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ')'
- ), true);
+ $GLOBALS['page_output']->addInlineScript([
+ 'window.HordeCore.showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ')',
+ ], true);
}
}
diff --git a/lib/Horde/Core/Notification/Listener/SmartmobileStatus.php b/lib/Horde/Core/Notification/Listener/SmartmobileStatus.php
index 46a6a7f06..48cb01c02 100644
--- a/lib/Horde/Core/Notification/Listener/SmartmobileStatus.php
+++ b/lib/Horde/Core/Notification/Listener/SmartmobileStatus.php
@@ -1,4 +1,5 @@
getInstance('Horde_PageOutput')->addInlineScript(array(
+ $GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript([
'$(function() {HordeMobile.showNotifications(' .
Horde_Serialize::serialize($events, Horde_Serialize::JSON) .
- ');});'
- ));
+ ');});',
+ ]);
}
}
diff --git a/lib/Horde/Core/Notification/Listener/Webnotification.php b/lib/Horde/Core/Notification/Listener/Webnotification.php
index 5477b5f87..abe85e4df 100644
--- a/lib/Horde/Core/Notification/Listener/Webnotification.php
+++ b/lib/Horde/Core/Notification/Listener/Webnotification.php
@@ -1,4 +1,5 @@
set('horde', 'notify/' . $key, $value);
}
} else {
- $this->_cached[] = array($key, $value);
+ $this->_cached[] = [$key, $value];
}
}
@@ -65,7 +65,7 @@ public function exists($key)
*/
public function clear($key)
{
- $this->_cached = array();
+ $this->_cached = [];
$GLOBALS['session']->remove('horde', 'notify/' . $key);
}
@@ -80,7 +80,7 @@ public function push($listener, Horde_Notification_Event $event)
$events[] = $event;
$session->set('horde', 'notify/' . $listener, $events, Horde_Session::TYPE_OBJECT);
} else {
- $this->_cached[] = array($listener, $event);
+ $this->_cached[] = [$listener, $event];
}
}
@@ -90,7 +90,7 @@ protected function _processCached()
{
if (!empty($this->_cached) && $GLOBALS['session']->isActive()) {
$cached = $this->_cached;
- $this->_cached = array();
+ $this->_cached = [];
foreach ($cached as $val) {
if ($val[1] instanceof Horde_Notification_Event) {
diff --git a/lib/Horde/Core/Perms.php b/lib/Horde/Core/Perms.php
index c4fb09a7c..fe69b682d 100644
--- a/lib/Horde/Core/Perms.php
+++ b/lib/Horde/Core/Perms.php
@@ -1,4 +1,5 @@
_registry = $registry;
$this->_perms = $perms;
}
@@ -67,7 +69,7 @@ public function getAvailable($name)
if (empty($name)) {
/* No name passed, so top level permissions are requested. These
* can only be applications. */
- $apps = $this->_registry->listApps(array('notoolbar', 'active', 'hidden'), true);
+ $apps = $this->_registry->listApps(['notoolbar', 'active', 'hidden'], true);
foreach (array_keys($apps) as $app) {
$apps[$app] = $this->_registry->get('name', $app) . ' (' . $app . ')';
}
@@ -99,7 +101,7 @@ public function getAvailable($name)
return false;
}
- $perms_list = array();
+ $perms_list = [];
foreach (array_keys($children) as $perm_key) {
$perms_list[$perm_key] = $perms['title'][$name . ':' . $perm_key];
}
@@ -118,7 +120,7 @@ public function getAvailable($name)
public function getTitle($name)
{
if ($name === Horde_Perms::ROOT) {
- return Horde_Core_Translation::t("All Permissions");
+ return Horde_Core_Translation::t('All Permissions');
}
$levels = explode(':', $name);
@@ -153,7 +155,8 @@ public function getType($name)
if (isset($info['type']) && isset($info['type'][$name])) {
$type = $info['type'][$name];
}
- } catch (Horde_Perms_Exception $e) {}
+ } catch (Horde_Perms_Exception $e) {
+ }
}
return $type;
}
@@ -174,7 +177,8 @@ public function getParams($name)
if (isset($info['params']) && isset($info['params'][$name])) {
$params = $info['params'][$name];
}
- } catch (Horde_Perms_Exception $e) {}
+ } catch (Horde_Perms_Exception $e) {
+ }
}
return $params;
}
@@ -191,9 +195,11 @@ public function getParams($name)
*/
public function newPermission($name)
{
- return $this->_perms->newPermission($name,
- $this->getType($name),
- $this->getParams($name));
+ return $this->_perms->newPermission(
+ $name,
+ $this->getType($name),
+ $this->getParams($name)
+ );
}
/**
@@ -209,19 +215,19 @@ public function getApplicationPermissions($app)
try {
$app_perms = $this->_registry->callAppMethod($app, 'perms');
} catch (Horde_Exception $e) {
- $app_perms = array();
+ $app_perms = [];
}
if (empty($app_perms)) {
- $perms = array();
+ $perms = [];
} else {
- $perms = array(
- 'title' => array(),
- 'tree' => array(
- $app => array()
- ),
- 'type' => array()
- );
+ $perms = [
+ 'title' => [],
+ 'tree' => [
+ $app => [],
+ ],
+ 'type' => [],
+ ];
foreach ($app_perms as $key => $val) {
$ptr = &$perms['tree'][$app];
@@ -265,11 +271,10 @@ public function getApplicationPermissions($app)
*
* @return mixed The specified permissions.
*/
- public function hasAppPermission($permission, $opts = array())
+ public function hasAppPermission($permission, $opts = [])
{
- $app = isset($opts['app'])
- ? $opts['app']
- : $this->_registry->getApp();
+ $app = $opts['app']
+ ?? $this->_registry->getApp();
if ($this->_perms->exists($app . ':' . $permission)) {
$perms = $this->_perms->getPermissions($app . ':' . $permission, $this->_registry->getAuth());
@@ -277,15 +282,16 @@ public function hasAppPermission($permission, $opts = array())
return false;
}
- $args = array(
+ $args = [
$permission,
$perms,
- isset($opts['opts']) ? $opts['opts'] : array()
- );
+ $opts['opts'] ?? [],
+ ];
try {
- return $this->_registry->callAppMethod($app, 'hasPermission', array('args' => $args));
- } catch (Horde_Exception $e) {}
+ return $this->_registry->callAppMethod($app, 'hasPermission', ['args' => $args]);
+ } catch (Horde_Exception $e) {
+ }
}
return true;
diff --git a/lib/Horde/Core/Perms/Ui.php b/lib/Horde/Core/Perms/Ui.php
index a09dd8698..6429a8de2 100644
--- a/lib/Horde/Core/Perms/Ui.php
+++ b/lib/Horde/Core/Perms/Ui.php
@@ -1,4 +1,5 @@
_perms = $perms;
$this->_corePerms = $corePerms;
}
@@ -73,48 +75,48 @@ public function renderTree($current = Horde_Perms::ROOT)
/* Get the perms tree. */
$nodes = $this->_perms->getTree();
- $perms_node = array('icon' => Horde_Themes::img('perms.png'));
+ $perms_node = ['icon' => Horde_Themes::img('perms.png')];
$add = Horde::url('admin/perms/addchild.php');
- $add_img = Horde_Themes_Image::tag('plus.png', array('alt' => Horde_Core_Translation::t("Add Permission")));
+ $add_img = Horde_Themes_Image::tag('plus.png', ['alt' => Horde_Core_Translation::t('Add Permission')]);
$edit = Horde::url('admin/perms/edit.php');
$delete = Horde::url('admin/perms/delete.php');
- $edit_img = Horde_Themes_Image::tag('edit.png', array('alt' => Horde_Core_Translation::t("Edit Permission")));
- $delete_img = Horde_Themes_Image::tag('delete.png', array('alt' => Horde_Core_Translation::t("Delete Permission")));
- $blank_img = Horde_Themes_Image::tag('blank.gif', array('attr' => array('width' => 16, 'height' => 16)));
+ $edit_img = Horde_Themes_Image::tag('edit.png', ['alt' => Horde_Core_Translation::t('Edit Permission')]);
+ $delete_img = Horde_Themes_Image::tag('delete.png', ['alt' => Horde_Core_Translation::t('Delete Permission')]);
+ $blank_img = Horde_Themes_Image::tag('blank.gif', ['attr' => ['width' => 16, 'height' => 16]]);
/* Set up the tree. */
- $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('perms_ui', 'Javascript', array(
+ $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('perms_ui', 'Javascript', [
'alternate' => true,
- 'hideHeaders' => true
- ));
- $tree->setHeader(array(
- array(
- 'class' => 'horde-tree-spacer'
- )
- ));
+ 'hideHeaders' => true,
+ ]);
+ $tree->setHeader([
+ [
+ 'class' => 'horde-tree-spacer',
+ ],
+ ]);
foreach ($nodes as $perm_id => $node) {
$node_class = ($current == $perm_id)
- ? array('class' => 'selected')
- : array();
+ ? ['class' => 'selected']
+ : [];
if ($perm_id == Horde_Perms::ROOT) {
- $add_link = $add->add('perm_id', $perm_id)->link(array('class' => 'permsAdd', 'title' => Horde_Core_Translation::t("Add New Permission"))) . $add_img . '';
- $base_node_params = array('icon' => Horde_Themes::img('administration.png'));
+ $add_link = $add->add('perm_id', $perm_id)->link(['class' => 'permsAdd', 'title' => Horde_Core_Translation::t('Add New Permission')]) . $add_img . '';
+ $base_node_params = ['icon' => Horde_Themes::img('administration.png')];
- $tree->addNode(array(
+ $tree->addNode([
'id' => $perm_id,
- 'label' => Horde_Core_Translation::t("All Permissions"),
+ 'label' => Horde_Core_Translation::t('All Permissions'),
'expanded' => true,
'params' => $base_node_params + $node_class,
- 'right' => array($add_link)
- ));
+ 'right' => [$add_link],
+ ]);
} else {
$parent_id = $this->_perms->getParent($node);
- $perms_extra = array();
+ $perms_extra = [];
$parents = explode(':', $node);
- if (!in_array($parents[0], $GLOBALS['registry']->listApps(array('notoolbar', 'active', 'hidden')))) {
+ if (!in_array($parents[0], $GLOBALS['registry']->listApps(['notoolbar', 'active', 'hidden']))) {
// This backend has permissions for an application that is
// not installed. Perhaps the application has been removed
// or the backend is shared with other Horde installations.
@@ -131,29 +133,29 @@ public function renderTree($current = Horde_Perms::ROOT)
if (isset($app_perms['tree']) &&
is_array(Horde_Array::getElement($app_perms['tree'], $parents))) {
- $add_link = $add->add('perm_id', $perm_id)->link(array('class' => 'permsAdd', 'title' => Horde_Core_Translation::t("Add Child Permission"))) . $add_img . '';
+ $add_link = $add->add('perm_id', $perm_id)->link(['class' => 'permsAdd', 'title' => Horde_Core_Translation::t('Add Child Permission')]) . $add_img . '';
$perms_extra[] = $add_link;
} else {
$perms_extra[] = $blank_img;
}
- $edit_link = $edit->add('perm_id', $perm_id)->link(array('class' => 'permsEdit', 'title' => Horde_Core_Translation::t("Edit Permission"))) . $edit_img . '';
+ $edit_link = $edit->add('perm_id', $perm_id)->link(['class' => 'permsEdit', 'title' => Horde_Core_Translation::t('Edit Permission')]) . $edit_img . '';
$perms_extra[] = $edit_link;
- $delete_link = $delete->add('perm_id', $perm_id)->link(array('class' => 'permsDelete', 'title' => Horde_Core_Translation::t("Delete Permission"))) . $delete_img . '';
+ $delete_link = $delete->add('perm_id', $perm_id)->link(['class' => 'permsDelete', 'title' => Horde_Core_Translation::t('Delete Permission')]) . $delete_img . '';
$perms_extra[] = $delete_link;
$name = $this->_corePerms->getTitle($node);
$expanded = isset($nodes[$current]) &&
strpos($nodes[$current], $node) === 0 &&
$nodes[$current] != $node;
- $tree->addNode(array(
+ $tree->addNode([
'id' => $perm_id,
'parent' => $parent_id,
'label' => $name,
'expanded' => $expanded,
'params' => $perms_node + $node_class,
- 'right' => $perms_extra
- ));
+ 'right' => $perms_extra,
+ ]);
}
}
@@ -197,8 +199,8 @@ public function setupAddForm($permission, $force_choice = null)
/* Initialise form if required. */
$this->_formInit();
- $this->_form->setTitle(sprintf(Horde_Core_Translation::t("Add a child permission to \"%s\""), $this->_corePerms->getTitle($permission->getName())));
- $this->_form->setButtons(Horde_Core_Translation::t("Add"));
+ $this->_form->setTitle(sprintf(Horde_Core_Translation::t('Add a child permission to "%s"'), $this->_corePerms->getTitle($permission->getName())));
+ $this->_form->setButtons(Horde_Core_Translation::t('Add'));
$this->_vars->set('perm_id', $this->_perms->getPermissionId($permission));
$this->_form->addHidden('', 'perm_id', 'text', false);
@@ -206,12 +208,12 @@ public function setupAddForm($permission, $force_choice = null)
$child_perms = $this->_corePerms->getAvailable($permission->getName());
if ($child_perms === false) {
/* False, so no childs are to be added below this level. */
- $this->_form->addVariable(Horde_Core_Translation::t("Permission"), 'child', 'invalid', true, false, null, array(Horde_Core_Translation::t("No children can be added to this permission.")));
+ $this->_form->addVariable(Horde_Core_Translation::t('Permission'), 'child', 'invalid', true, false, null, [Horde_Core_Translation::t('No children can be added to this permission.')]);
} elseif (is_array($child_perms)) {
if (!empty($force_choice)) {
/* Choice array available, but choice being forced. */
$this->_vars->set('child', $force_choice);
- $this->_form->addVariable(Horde_Core_Translation::t("Permissions"), 'child', 'enum', true, true, null, array($child_perms));
+ $this->_form->addVariable(Horde_Core_Translation::t('Permissions'), 'child', 'enum', true, true, null, [$child_perms]);
} else {
/* Choice array available, so set up enum field. */
$prefix = $permission->getName() . ':';
@@ -221,7 +223,7 @@ public function setupAddForm($permission, $force_choice = null)
unset($child_perms[substr($name, $length)]);
}
}
- $this->_form->addVariable(Horde_Core_Translation::t("Permissions"), 'child', 'enum', true, false, null, array($child_perms));
+ $this->_form->addVariable(Horde_Core_Translation::t('Permissions'), 'child', 'enum', true, false, null, [$child_perms]);
}
}
}
@@ -254,7 +256,7 @@ public function setupEditForm($permission)
/* Initialise form if required. */
$this->_formInit();
- $this->_form->setButtons(Horde_Core_Translation::t("Update"), true);
+ $this->_form->setButtons(Horde_Core_Translation::t('Update'), true);
$this->_vars->set('perm_id', $this->_perms->getPermissionId($permission));
$this->_form->addHidden('', 'perm_id', 'text', false);
@@ -264,7 +266,7 @@ public function setupEditForm($permission)
/* Default permissions. */
$perm_val = $permission->getDefaultPermissions();
- $this->_form->setSection('default', Horde_Core_Translation::t("All Authenticated Users"), Horde_Themes_Image::tag('perms.png'), false);
+ $this->_form->setSection('default', Horde_Core_Translation::t('All Authenticated Users'), Horde_Themes_Image::tag('perms.png'), false);
/* We MUST use 'deflt' for the variable name because 'default' is a
* reserved word in JavaScript. */
@@ -273,8 +275,8 @@ public function setupEditForm($permission)
$cols = Horde_Perms::getPermsArray();
/* Define a single matrix row for default perms. */
- $matrix = array(Horde_Perms::integerToArray($perm_val));
- $this->_form->addVariable('', 'deflt', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
+ $matrix = [Horde_Perms::integerToArray($perm_val)];
+ $this->_form->addVariable('', 'deflt', 'matrix', false, false, null, [$cols, [0 => ''], $matrix]);
} else {
$var = $this->_form->addVariable('', 'deflt', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
@@ -282,12 +284,12 @@ public function setupEditForm($permission)
/* Guest permissions. */
$perm_val = $permission->getGuestPermissions();
- $this->_form->setSection('guest', Horde_Core_Translation::t("Guest Permissions"), '', false);
+ $this->_form->setSection('guest', Horde_Core_Translation::t('Guest Permissions'), '', false);
if ($this->_type == 'matrix') {
/* Define a single matrix row for guest perms. */
- $matrix = array(Horde_Perms::integerToArray($perm_val));
- $this->_form->addVariable('', 'guest', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
+ $matrix = [Horde_Perms::integerToArray($perm_val)];
+ $this->_form->addVariable('', 'guest', 'matrix', false, false, null, [$cols, [0 => ''], $matrix]);
} else {
$var = $this->_form->addVariable('', 'guest', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
@@ -295,12 +297,12 @@ public function setupEditForm($permission)
/* Object creator permissions. */
$perm_val = $permission->getCreatorPermissions();
- $this->_form->setSection('creator', Horde_Core_Translation::t("Creator Permissions"), Horde_Themes_Image::tag('user.png'), false);
+ $this->_form->setSection('creator', Horde_Core_Translation::t('Creator Permissions'), Horde_Themes_Image::tag('user.png'), false);
if ($this->_type == 'matrix') {
/* Define a single matrix row for creator perms. */
- $matrix = array(Horde_Perms::integerToArray($perm_val));
- $this->_form->addVariable('', 'creator', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
+ $matrix = [Horde_Perms::integerToArray($perm_val)];
+ $this->_form->addVariable('', 'creator', 'matrix', false, false, null, [$cols, [0 => ''], $matrix]);
} else {
$var = $this->_form->addVariable('', 'creator', $this->_type, false, false, null, $params);
$var->setDefault($perm_val);
@@ -308,14 +310,14 @@ public function setupEditForm($permission)
/* Users permissions. */
$perm_val = $permission->getUserPermissions();
- $this->_form->setSection('users', Horde_Core_Translation::t("Individual Users"), Horde_Themes_Image::tag('user.png'), false);
+ $this->_form->setSection('users', Horde_Core_Translation::t('Individual Users'), Horde_Themes_Image::tag('user.png'), false);
$auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
- $user_list = array();
+ $user_list = [];
if ($auth->hasCapability('list')) {
/* The auth driver has list capabilities so set up an array which
* the matrix field type will recognise to set up an enum box for
* adding new users to the permissions matrix. */
- $new_users = array();
+ $new_users = [];
try {
$user_list = $auth->listNames();
@@ -337,19 +339,19 @@ public function setupEditForm($permission)
/* Set up the matrix array, breaking up each permission integer
* into an array. The keys of this array will be the row
* headers. */
- $rows = array();
- $matrix = array();
+ $rows = [];
+ $matrix = [];
foreach ($perm_val as $u_id => $u_perms) {
- $rows[$u_id] = isset($user_list[$u_id]) ? $user_list[$u_id] : $u_id;
+ $rows[$u_id] = $user_list[$u_id] ?? $u_id;
$matrix[$u_id] = Horde_Perms::integerToArray($u_perms);
}
- $this->_form->addVariable('', 'u', 'matrix', false, false, null, array($cols, $rows, $matrix, $new_users));
+ $this->_form->addVariable('', 'u', 'matrix', false, false, null, [$cols, $rows, $matrix, $new_users]);
} else {
if ($new_users) {
if (is_array($new_users)) {
$u_n = Horde_Util::getFormData('u_n');
$u_n = empty($u_n['u']) ? null : $u_n['u'];
- $user_html = '';
+ $user_html = '';
foreach ($new_users as $new_user => $name) {
$user_html .= '
_genID('htmlhelper_' . $var->getVarName()) . ' class="control"> |
' . "\n";
}
@@ -336,26 +369,30 @@ protected function _renderVarInput_longtext($form, &$var, &$vars)
protected function _renderVarInput_countedtext($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- (int)$var->type->getCols(),
- (int)$var->type->getRows(),
- $this->_getActionScripts($form, $var),
- $var->isDisabled() ? ' disabled="disabled"' : '',
- htmlspecialchars($var->getValue($vars)));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ (int)$var->type->getCols(),
+ (int)$var->type->getRows(),
+ $this->_getActionScripts($form, $var),
+ $var->isDisabled() ? ' disabled="disabled"' : '',
+ htmlspecialchars($var->getValue($vars))
+ );
}
protected function _renderVarInput_address($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- (int)$var->type->getCols(),
- (int)$var->type->getRows(),
- $this->_getActionScripts($form, $var),
- $var->isDisabled() ? ' disabled="disabled"' : '',
- htmlspecialchars($var->getValue($vars)));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ (int)$var->type->getCols(),
+ (int)$var->type->getRows(),
+ $this->_getActionScripts($form, $var),
+ $var->isDisabled() ? ' disabled="disabled"' : '',
+ htmlspecialchars($var->getValue($vars))
+ );
}
protected function _renderVarInput_addresslink($form, &$var, &$vars)
@@ -380,20 +417,24 @@ protected function _renderVarInput_country($form, &$var, &$vars)
protected function _renderVarInput_date($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($var->getValue($vars)),
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($var->getValue($vars)),
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_time($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($var->getValue($vars)),
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($var->getValue($vars)),
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_hourminutesecond($form, &$var, &$vars)
@@ -401,27 +442,31 @@ protected function _renderVarInput_hourminutesecond($form, &$var, &$vars)
$time = $var->type->getTimeParts($var->getValue($vars));
/* Output hours. */
- $hours = array('' => Horde_Core_Translation::t("hh"));
+ $hours = ['' => Horde_Core_Translation::t('hh')];
for ($i = 0; $i <= 23; $i++) {
$hours[$i] = $i;
}
- $html = sprintf('%s',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- $this->_getActionScripts($form, $var),
- $this->selectOptions($hours, ($time['hour'] === '') ? '' : $time['hour']));
+ $html = sprintf(
+ '%s',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($hours, ($time['hour'] === '') ? '' : $time['hour'])
+ );
/* Output minutes. */
- $minutes = array('' => Horde_Core_Translation::t("mm"));
+ $minutes = ['' => Horde_Core_Translation::t('mm')];
for ($i = 0; $i <= 59; $i++) {
$m = sprintf('%02d', $i);
$minutes[$m] = $m;
}
- $html .= sprintf('%s',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- $this->_getActionScripts($form, $var),
- $this->selectOptions($minutes, ($time['minute'] === '') ? '' : sprintf('%02d', $time['minute'])));
+ $html .= sprintf(
+ '%s',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($minutes, ($time['minute'] === '') ? '' : sprintf('%02d', $time['minute']))
+ );
/* Return if seconds are not required. */
if (!$var->type->getProperty('show_seconds')) {
@@ -429,35 +474,37 @@ protected function _renderVarInput_hourminutesecond($form, &$var, &$vars)
}
/* Output seconds. */
- $seconds = array('' => Horde_Core_Translation::t("ss"));
+ $seconds = ['' => Horde_Core_Translation::t('ss')];
for ($i = 0; $i <= 59; $i++) {
$s = sprintf('%02d', $i);
$seconds[$s] = $s;
}
- return $html . sprintf('%s',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- $this->_getActionScripts($form, $var),
- $this->selectOptions($seconds, ($time['second'] === '') ? '' : sprintf('%02d', $time['second'])));
+ return $html . sprintf(
+ '%s',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($seconds, ($time['second'] === '') ? '' : sprintf('%02d', $time['second']))
+ );
}
protected function _renderVarInput_monthyear($form, &$var, &$vars)
{
- $dates = array();
- $dates['month'] = array('' => Horde_Core_Translation::t("MM"),
- 1 => Horde_Core_Translation::t("January"),
- 2 => Horde_Core_Translation::t("February"),
- 3 => Horde_Core_Translation::t("March"),
- 4 => Horde_Core_Translation::t("April"),
- 5 => Horde_Core_Translation::t("May"),
- 6 => Horde_Core_Translation::t("June"),
- 7 => Horde_Core_Translation::t("July"),
- 8 => Horde_Core_Translation::t("August"),
- 9 => Horde_Core_Translation::t("September"),
- 10 => Horde_Core_Translation::t("October"),
- 11 => Horde_Core_Translation::t("November"),
- 12 => Horde_Core_Translation::t("December"));
- $dates['year'] = array('' => Horde_Core_Translation::t("YYYY"));
+ $dates = [];
+ $dates['month'] = ['' => Horde_Core_Translation::t('MM'),
+ 1 => Horde_Core_Translation::t('January'),
+ 2 => Horde_Core_Translation::t('February'),
+ 3 => Horde_Core_Translation::t('March'),
+ 4 => Horde_Core_Translation::t('April'),
+ 5 => Horde_Core_Translation::t('May'),
+ 6 => Horde_Core_Translation::t('June'),
+ 7 => Horde_Core_Translation::t('July'),
+ 8 => Horde_Core_Translation::t('August'),
+ 9 => Horde_Core_Translation::t('September'),
+ 10 => Horde_Core_Translation::t('October'),
+ 11 => Horde_Core_Translation::t('November'),
+ 12 => Horde_Core_Translation::t('December')];
+ $dates['year'] = ['' => Horde_Core_Translation::t('YYYY')];
if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
$dates['year'][$i] = $i;
@@ -467,16 +514,20 @@ protected function _renderVarInput_monthyear($form, &$var, &$vars)
$dates['year'][$i] = $i;
}
}
- return sprintf('%s',
- $var->type->getMonthVar($var),
- $var->type->getMonthVar($var),
- $this->_getActionScripts($form, $var),
- $this->selectOptions($dates['month'], $vars->get($var->type->getMonthVar($var)))) .
- sprintf('%s',
- $var->type->getYearVar($var),
- $var->type->getYearVar($var),
- $this->_getActionScripts($form, $var),
- $this->selectOptions($dates['year'], $vars->get($var->type->getYearVar($var))));
+ return sprintf(
+ '%s',
+ $var->type->getMonthVar($var),
+ $var->type->getMonthVar($var),
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($dates['month'], $vars->get($var->type->getMonthVar($var)))
+ ) .
+ sprintf(
+ '%s',
+ $var->type->getYearVar($var),
+ $var->type->getYearVar($var),
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($dates['year'], $vars->get($var->type->getYearVar($var)))
+ );
}
protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
@@ -489,37 +540,37 @@ protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(
"document.observe('Horde_Calendar:select', " .
- "function(e) {" .
- "var elt = e.element();" .
+ 'function(e) {' .
+ 'var elt = e.element();' .
"elt.up().previous('SELECT[name$=\"[month]\"]').setValue(e.memo.getMonth() + 1);" .
"elt.up().previous('SELECT[name$=\"[day]\"]').setValue(e.memo.getDate());" .
"elt.up().previous('SELECT[name$=\"[year]\"]').setValue(e.memo.getFullYear());" .
- "});",
+ '});',
true
);
- $dates = array(
- 'month' => array(
- '' => Horde_Core_Translation::t("MM"),
- '1' => Horde_Core_Translation::t("January"),
- '2' => Horde_Core_Translation::t("February"),
- '3' => Horde_Core_Translation::t("March"),
- '4' => Horde_Core_Translation::t("April"),
- '5' => Horde_Core_Translation::t("May"),
- '6' => Horde_Core_Translation::t("June"),
- '7' => Horde_Core_Translation::t("July"),
- '8' => Horde_Core_Translation::t("August"),
- '9' => Horde_Core_Translation::t("September"),
- '10' => Horde_Core_Translation::t("October"),
- '11' => Horde_Core_Translation::t("November"),
- '12' => Horde_Core_Translation::t("December")
- )
- );
- $dates['day'] = array('' => Horde_Core_Translation::t("DD"));
+ $dates = [
+ 'month' => [
+ '' => Horde_Core_Translation::t('MM'),
+ '1' => Horde_Core_Translation::t('January'),
+ '2' => Horde_Core_Translation::t('February'),
+ '3' => Horde_Core_Translation::t('March'),
+ '4' => Horde_Core_Translation::t('April'),
+ '5' => Horde_Core_Translation::t('May'),
+ '6' => Horde_Core_Translation::t('June'),
+ '7' => Horde_Core_Translation::t('July'),
+ '8' => Horde_Core_Translation::t('August'),
+ '9' => Horde_Core_Translation::t('September'),
+ '10' => Horde_Core_Translation::t('October'),
+ '11' => Horde_Core_Translation::t('November'),
+ '12' => Horde_Core_Translation::t('December'),
+ ],
+ ];
+ $dates['day'] = ['' => Horde_Core_Translation::t('DD')];
for ($i = 1; $i <= 31; $i++) {
$dates['day'][$i] = $i;
}
- $dates['year'] = array('' => Horde_Core_Translation::t("YYYY"));
+ $dates['year'] = ['' => Horde_Core_Translation::t('YYYY')];
if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
$dates['year'][$i] = $i;
@@ -533,20 +584,22 @@ protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
// TODO: use NLS to get the order right for the Rest Of The
// World.
$html = '';
- $date_parts = array('month', 'day', 'year');
+ $date_parts = ['month', 'day', 'year'];
foreach ($date_parts as $part) {
- $html .= sprintf('%s',
- htmlspecialchars($var->getVarName() . '[' . $part . ']'),
- $this->_genID($var->getVarName(), false) . $part,
- $this->_getActionScripts($form, $var),
- $this->selectOptions($dates[$part], $date[$part]));
+ $html .= sprintf(
+ '%s',
+ htmlspecialchars($var->getVarName() . '[' . $part . ']'),
+ $this->_genID($var->getVarName(), false) . $part,
+ $this->_getActionScripts($form, $var),
+ $this->selectOptions($dates[$part], $date[$part])
+ );
}
if ($var->type->getProperty('picker') &&
$GLOBALS['browser']->hasFeature('javascript')) {
Horde_Core_Ui_JsCalendar::init();
$imgId = $this->_genID($var->getVarName(), false) . 'goto';
- $html .= Horde::link('#', Horde_Core_Translation::t("Select a date"), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde_Themes_Image::tag('calendar.png', array('alt' => Horde_Core_Translation::t("Calendar"), 'attr' => array('id' => $imgId))) . "\n";
+ $html .= Horde::link('#', Horde_Core_Translation::t('Select a date'), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde_Themes_Image::tag('calendar.png', ['alt' => Horde_Core_Translation::t('Calendar'), 'attr' => ['id' => $imgId]]) . "\n";
}
return $html;
@@ -563,7 +616,7 @@ protected function _renderVarInput_sound(&$form, &$var, &$vars)
$value = htmlspecialchars($var->getValue($vars));
$html = '';
if (!$var->isRequired()) {
- $html .= '';
+ $html .= '';
}
foreach ($var->type->getSounds() as $sound) {
$sound = htmlspecialchars($sound);
@@ -592,9 +645,14 @@ protected function _renderVarInput_colorpicker($form, &$var, &$vars)
if ($browser->hasFeature('javascript')) {
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addScriptFile('colorpicker.js', 'horde');
$html .= ' '
- . Horde::link('#', Horde_Core_Translation::t("Color Picker"), '', '',
- 'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;')
- . Horde_Themes_Image::tag('colorpicker.png', array('alt' => Horde_Core_Translation::t("Color Picker"), 'attr' => array('height' => 16))) . '';
+ . Horde::link(
+ '#',
+ Horde_Core_Translation::t('Color Picker'),
+ '',
+ '',
+ 'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;'
+ )
+ . Horde_Themes_Image::tag('colorpicker.png', ['alt' => Horde_Core_Translation::t('Color Picker'), 'attr' => ['height' => 16]]) . '';
}
return $html;
}
@@ -606,11 +664,13 @@ protected function _renderVarInput_sorter($form, &$var, &$vars)
$page = $GLOBALS['injector']->getInstance('Horde_PageOutput');
$page->addScriptFile('sorter.js', 'horde');
$page->addInlineScript(
- sprintf(
+ sprintf(
'%1$s = new Horde_Form_Sorter(\'%1$s\', \'%2$s\', \'%3$s\');%1$s.setHidden();',
$instance,
$this->_genID($var->getVarName(), false),
- $var->type->getHeader()));
+ $var->type->getHeader()
+ )
+ );
return '_genID($var->getVarName() . '_array') . '/>' .
@@ -619,8 +679,8 @@ protected function _renderVarInput_sorter($form, &$var, &$vars)
'[list]" onchange="' . $instance . '.deselectHeader();" ' .
$this->_genID($var->getVarName() . '_list') . '>' .
$var->type->getOptions($var->getValue($vars)) . '' .
- Horde::link('#', Horde_Core_Translation::t("Move up"), '', '', $instance . '.moveColumnUp(); return false;') . Horde_Themes_Image::tag('nav/up.png', array('alt' => Horde_Core_Translation::t("Move up"))) . '
' .
- Horde::link('#', Horde_Core_Translation::t("Move up"), '', '', $instance . '.moveColumnDown(); return false;') . Horde_Themes_Image::tag('nav/down.png', array('alt' => Horde_Core_Translation::t("Move down"))) . '
';
+ Horde::link('#', Horde_Core_Translation::t('Move up'), '', '', $instance . '.moveColumnUp(); return false;') . Horde_Themes_Image::tag('nav/up.png', ['alt' => Horde_Core_Translation::t('Move up')]) . '
' .
+ Horde::link('#', Horde_Core_Translation::t('Move up'), '', '', $instance . '.moveColumnDown(); return false;') . Horde_Themes_Image::tag('nav/down.png', ['alt' => Horde_Core_Translation::t('Move down')]) . '';
}
protected function _renderVarInput_assign($form, &$var, &$vars)
@@ -636,20 +696,28 @@ protected function _renderVarInput_assign($form, &$var, &$vars)
return '' .
'| ' .
- sprintf('',
- $name, $size, $width,
- $lhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0);"' : '') .
+ sprintf(
+ '',
+ $name,
+ $size,
+ $width,
+ $lhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0);"' : ''
+ ) .
$var->type->getOptions(0, $form->getName(), $var->getVarName()) .
' | ' .
'' .
- Horde_Themes_Image::tag('rhand.png', array('alt' => Horde_Core_Translation::t("Add"))) .
+ Horde_Themes_Image::tag('rhand.png', ['alt' => Horde_Core_Translation::t('Add')]) .
' ' .
- Horde_Themes_Image::tag('lhand.png', array('alt' => Horde_Core_Translation::t("Remove"))) .
+ Horde_Themes_Image::tag('lhand.png', ['alt' => Horde_Core_Translation::t('Remove')]) .
' | ' .
- sprintf('',
- $name, $size, $width,
- $rhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 1);"' : '') .
+ sprintf(
+ '',
+ $name,
+ $size,
+ $width,
+ $rhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 1);"' : ''
+ ) .
$var->type->getOptions(1, $form->getName(), $var->getVarName()) .
' |
';
}
@@ -667,12 +735,14 @@ protected function _renderVarInput_enum($form, &$var, &$vars)
if (!empty($prompt)) {
$prompt = '' . ($htmlchars ? $prompt : htmlspecialchars($prompt)) . '';
}
- return sprintf('%s%s',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- $this->_getActionScripts($form, $var),
- $prompt,
- $this->selectOptions($values, $var->getValue($vars), $htmlchars));
+ return sprintf(
+ '%s%s',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ $this->_getActionScripts($form, $var),
+ $prompt,
+ $this->selectOptions($values, $var->getValue($vars), $htmlchars)
+ );
}
protected function _renderVarInput_mlenum($form, &$var, &$vars)
@@ -686,25 +756,29 @@ protected function _renderVarInput_mlenum($form, &$var, &$vars)
if (!is_array($selected)) {
foreach ($values as $key_1 => $values_2) {
if (isset($values_2[$selected])) {
- $selected = array('1' => $key_1, '2' => $selected);
+ $selected = ['1' => $key_1, '2' => $selected];
break;
}
}
}
/* Hidden tag to store the current first level. */
- $html = sprintf('',
- $hvarname,
- htmlspecialchars($selected['1']),
- $this->_genID($varname . '_old'));
+ $html = sprintf(
+ '',
+ $hvarname,
+ htmlspecialchars($selected['1']),
+ $this->_genID($varname . '_old')
+ );
/* First level. */
$values_1 = Horde_Array::valuesToKeys(array_keys($values));
- $html .= sprintf('',
- $this->_genID($varname . '_1'),
- $hvarname,
- 'if (this.value) { document.' . $form->getName() . '.formname.value=\'\';' . 'document.' . $form->getName() . '.submit() }',
- ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
+ $html .= sprintf(
+ '',
+ $this->_genID($varname . '_1'),
+ $hvarname,
+ 'if (this.value) { document.' . $form->getName() . '.formname.value=\'\';' . 'document.' . $form->getName() . '.submit() }',
+ ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : '')
+ );
if (!empty($prompts)) {
$html .= '' . htmlspecialchars($prompts[0]) . '';
}
@@ -712,14 +786,16 @@ protected function _renderVarInput_mlenum($form, &$var, &$vars)
$html .= '';
/* Second level. */
- $html .= sprintf('',
- $this->_genID($varname . '_2'),
- $hvarname,
- ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
+ $html .= sprintf(
+ '',
+ $this->_genID($varname . '_2'),
+ $hvarname,
+ ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : '')
+ );
if (!empty($prompts)) {
$html .= '' . htmlspecialchars($prompts[1]) . '';
}
- $values_2 = array();
+ $values_2 = [];
if (!empty($selected['1'])) {
$values_2 = &$values[$selected['1']];
}
@@ -733,12 +809,14 @@ protected function _renderVarInput_multienum($form, &$var, &$vars)
if (!$wasset) {
$selected = $var->getDefault();
}
- return sprintf('%s',
- (int)$var->type->size,
- htmlspecialchars($var->getVarName()),
- $this->_getActionScripts($form, $var),
- $this->_multiSelectOptions($values, $selected)) .
- "
\n" . Horde_Core_Translation::t("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.") . "\n";
+ return sprintf(
+ '%s',
+ (int)$var->type->size,
+ htmlspecialchars($var->getVarName()),
+ $this->_getActionScripts($form, $var),
+ $this->_multiSelectOptions($values, $selected)
+ ) .
+ "
\n" . Horde_Core_Translation::t('To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.') . "\n";
}
protected function _renderVarInput_keyval_multienum($form, &$var, &$vars)
@@ -748,29 +826,34 @@ protected function _renderVarInput_keyval_multienum($form, &$var, &$vars)
protected function _renderVarInput_radio($form, &$var, &$vars)
{
- return $this->_radioButtons($var->getVarName(),
- $var->getValues(),
- $var->getValue($vars),
- $this->_getActionScripts($form, $var));
+ return $this->_radioButtons(
+ $var->getVarName(),
+ $var->getValues(),
+ $var->getValue($vars),
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_set($form, &$var, &$vars)
{
- $html = $this->_checkBoxes($var->getVarName(),
- $var->getValues(),
- $var->getValue($vars),
- $this->_getActionScripts($form, $var));
+ $html = $this->_checkBoxes(
+ $var->getVarName(),
+ $var->getValues(),
+ $var->getValue($vars),
+ $this->_getActionScripts($form, $var)
+ );
if ($var->type->getProperty('checkAll')) {
$form_name = $form->getName();
$var_name = $var->getVarName() . '[]';
$function_name = 'select' . $form_name . $var->getVarName();
- $enable = Horde_Core_Translation::t("Select all");
- $disable = Horde_Core_Translation::t("Select none");
- $invert = Horde_Core_Translation::t("Invert selection");
+ $enable = Horde_Core_Translation::t('Select all');
+ $disable = Horde_Core_Translation::t('Select none');
+ $invert = Horde_Core_Translation::t('Invert selection');
$GLOBALS['injector']
->getInstance('Horde_PageOutput')
- ->addInlineScript(sprintf('
+ ->addInlineScript(sprintf(
+ '
function %s()
{
for (var i = 0; i < document.%s.elements.length; i++) {
@@ -785,13 +868,16 @@ function %s()
}
}
}',
- $function_name, $form_name, $var_name));
+ $function_name,
+ $form_name,
+ $var_name
+ ));
$html .= <<$enable,
-$disable,
-$invert
-EOT;
+ $enable,
+ $disable,
+ $invert
+ EOT;
}
return $html;
@@ -809,13 +895,15 @@ protected function _renderVarInput_html($form, &$var, &$vars)
protected function _renderVarInput_email($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($var->getValue($vars)),
- $var->type->getSize() ? ' size="' . $var->type->getSize() . '"' : '',
- $var->type->allowMulti() ? ' multiple="multiple"' : '',
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($var->getValue($vars)),
+ $var->type->getSize() ? ' size="' . $var->type->getSize() . '"' : '',
+ $var->type->allowMulti() ? ' multiple="multiple"' : '',
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_matrix($form, &$var, &$vars)
@@ -839,16 +927,20 @@ protected function _renderVarInput_matrix($form, &$var, &$vars)
if ($new_input) {
$html .= '';
if (is_array($new_input)) {
- $html .= sprintf('%s%s ',
- $this->_genID($varname . '_n_r'),
- htmlspecialchars($var->getVarName()),
- Horde_Core_Translation::t("-- select --"),
- $this->selectOptions($new_input, $var_array['n']['r'] ?? null));
+ $html .= sprintf(
+ '%s%s ',
+ $this->_genID($varname . '_n_r'),
+ htmlspecialchars($var->getVarName()),
+ Horde_Core_Translation::t('-- select --'),
+ $this->selectOptions($new_input, $var_array['n']['r'] ?? null)
+ );
} elseif ($new_input == true) {
- $html .= sprintf('',
- $this->_genID($varname . '_n_r'),
- htmlspecialchars($var->getVarName()),
- $var_array['n']['r']);
+ $html .= sprintf(
+ '',
+ $this->_genID($varname . '_n_r'),
+ htmlspecialchars($var->getVarName()),
+ $var_array['n']['r']
+ );
}
$html .= ' | ';
foreach ($cols as $col_id => $col_title) {
@@ -871,31 +963,37 @@ protected function _renderVarInput_matrix($form, &$var, &$vars)
protected function _renderVarInput_password($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($var->getValue($vars)),
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($var->getValue($vars)),
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_emailconfirm($form, &$var, &$vars)
{
$email = $var->getValue($vars);
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($email['original']),
- $this->_getActionScripts($form, $var)) .
- ' ' . sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($email['confirm']),
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($email['original']),
+ $this->_getActionScripts($form, $var)
+ ) .
+ ' ' . sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($email['confirm']),
+ $this->_getActionScripts($form, $var)
+ );
}
/**
* Render two input fields to confirm a password
- *
+ *
* Used in admin/user and possibly more places
*
* @param Horde_Form $form
@@ -906,16 +1004,20 @@ protected function _renderVarInput_emailconfirm($form, &$var, &$vars)
protected function _renderVarInput_passwordconfirm($form, &$var, &$vars)
{
$password = $var->getValue($vars) ?? ['confirm' => '', 'original' => ''];
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($password['original']),
- $this->_getActionScripts($form, $var)) .
- ' ' . sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- htmlspecialchars($password['confirm']),
- $this->_getActionScripts($form, $var));
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($password['original']),
+ $this->_getActionScripts($form, $var)
+ ) .
+ ' ' . sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ htmlspecialchars($password['confirm']),
+ $this->_getActionScripts($form, $var)
+ );
}
protected function _renderVarInput_boolean($form, &$var, &$vars)
@@ -924,8 +1026,11 @@ protected function _renderVarInput_boolean($form, &$var, &$vars)
. ' id="' . $this->_genID($var->getVarName(), false) . '"' . ($var->getValue($vars) ? ' checked="checked"' : '')
. ($var->isDisabled() ? ' disabled="disabled" ' : '');
if ($var->hasAction()) {
- $html .= $this->_genActionScript($form, $var->_action,
- $var->getVarName());
+ $html .= $this->_genActionScript(
+ $form,
+ $var->_action,
+ $var->getVarName()
+ );
}
return $html . ' />';
}
@@ -935,8 +1040,11 @@ protected function _renderVarInput_creditcard($form, &$var, &$vars)
$html = 'hasAction()) {
- $html .= $this->_genActionScript($form, $var->_action,
- $var->getVarName());
+ $html .= $this->_genActionScript(
+ $form,
+ $var->_action,
+ $var->getVarName()
+ );
}
return $html . ' />';
}
@@ -948,7 +1056,8 @@ protected function _renderVarInput_obrowser($form, &$var, &$vars)
$fieldId = $this->_genID(uniqid(mt_rand()), false) . 'id';
$GLOBALS['injector']
->getInstance('Horde_PageOutput')
- ->addInlineScript(sprintf('
+ ->addInlineScript(sprintf(
+ '
var obrowserWindowName;
function obrowserCallback(name, oid)
{
@@ -959,19 +1068,22 @@ function obrowserCallback(name, oid)
return "Invalid window name supplied";
}
}',
- $fieldId));
+ $fieldId
+ ));
- $html .= sprintf('',
- htmlspecialchars($varname),
- $fieldId,
- $this->_getActionScripts($form, $var),
- htmlspecialchars($varvalue));
+ $html .= sprintf(
+ '',
+ htmlspecialchars($varname),
+ $fieldId,
+ $this->_getActionScripts($form, $var),
+ htmlspecialchars($varvalue)
+ );
if (!empty($varvalue)) {
$html .= $varvalue;
}
if ($GLOBALS['browser']->hasFeature('javascript')) {
- $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', Horde_Core_Translation::t("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde_Themes_Image::tag('tree/leaf.png', array('alt' => Horde_Core_Translation::t("Object"))) . "\n";
+ $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', Horde_Core_Translation::t('Select an object'), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', ['urlencode' => true]) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde_Themes_Image::tag('tree/leaf.png', ['alt' => Horde_Core_Translation::t('Object')]) . "\n";
}
return $html;
@@ -984,23 +1096,27 @@ protected function _renderVarInput_dblookup($form, &$var, &$vars)
protected function _renderVarInput_figlet($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- strlen($var->type->getText()),
- htmlspecialchars($var->getValue($vars))) .
- '
' . Horde_Core_Translation::t("Enter the letters below:") . '
' .
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ strlen($var->type->getText()),
+ htmlspecialchars($var->getValue($vars))
+ ) .
+ '
' . Horde_Core_Translation::t('Enter the letters below:') . '
' .
$this->_renderVarDisplay_figlet($form, $var, $vars);
}
protected function _renderVarInput_captcha($form, &$var, &$vars)
{
- return sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- strlen($var->type->getText()),
- htmlspecialchars($var->getValue($vars))) .
- '
' . Horde_Core_Translation::t("Enter the letters below:") . '
' .
+ return sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ strlen($var->type->getText()),
+ htmlspecialchars($var->getValue($vars))
+ ) .
+ '
' . Horde_Core_Translation::t('Enter the letters below:') . '
' .
$this->_renderVarDisplay_captcha($form, $var, $vars);
}
@@ -1021,9 +1137,9 @@ protected function _renderVarDisplay_email($form, &$var, &$vars)
$email_val = $var->getValue($vars);
if ($var->type->getProperty('link_compose')) {
- $addrs = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822')->parseAddressList($email_val, array(
- 'limit' => $var->type->getProperty('allow_multi') ? 0 : 1
- ));
+ $addrs = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822')->parseAddressList($email_val, [
+ 'limit' => $var->type->getProperty('allow_multi') ? 0 : 1,
+ ]);
$link = '';
foreach ($addrs as $addr) {
@@ -1035,7 +1151,7 @@ protected function _renderVarDisplay_email($form, &$var, &$vars)
$address = $addr->writeAddress(true);
try {
- $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+ $mail_link = $GLOBALS['registry']->call('mail/compose', [['to' => addslashes($address)]]);
} catch (Horde_Exception $e) {
$mail_link = 'mailto:' . urlencode($address);
}
@@ -1049,11 +1165,11 @@ protected function _renderVarDisplay_email($form, &$var, &$vars)
return $link;
} else {
- $addrs = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822')->parseAddressList($email_val, array(
- 'limit' => $var->type->getProperty('allow_multi') ? 0 : 1
- ));
+ $addrs = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822')->parseAddressList($email_val, [
+ 'limit' => $var->type->getProperty('allow_multi') ? 0 : 1,
+ ]);
- $display = array();
+ $display = [];
foreach ($addrs as $addr) {
$display_email = $var->type->getProperty('strip_domain')
? $addr->mailbox . ' (at) ' . str_replace('.', ' (dot) ', $addr->host)
@@ -1082,7 +1198,7 @@ protected function _renderVarDisplay_octal($form, &$var, &$vars)
protected function _renderVarDisplay_boolean($form, &$var, &$vars)
{
- return $var->getValue($vars) ? Horde_Core_Translation::t("Yes") : Horde_Core_Translation::t("No");
+ return $var->getValue($vars) ? Horde_Core_Translation::t('Yes') : Horde_Core_Translation::t('No');
}
protected function _renderVarDisplay_enum($form, &$var, &$vars)
@@ -1090,7 +1206,7 @@ protected function _renderVarDisplay_enum($form, &$var, &$vars)
$values = $var->getValues();
$value = $var->getValue($vars);
if (count($values) == 0) {
- return Horde_Core_Translation::t("No values");
+ return Horde_Core_Translation::t('No values');
} elseif (isset($values[$value]) && $value != '') {
return htmlspecialchars($values[$value]);
}
@@ -1100,7 +1216,7 @@ protected function _renderVarDisplay_radio($form, &$var, &$vars)
{
$values = $var->getValues();
if (count($values) == 0) {
- return Horde_Core_Translation::t("No values");
+ return Horde_Core_Translation::t('No values');
} elseif (isset($values[$var->getValue($vars)])) {
return htmlspecialchars($values[$var->getValue($vars)]);
}
@@ -1111,9 +1227,9 @@ protected function _renderVarDisplay_multienum($form, &$var, &$vars)
$values = $var->getValues();
$on = $var->getValue($vars);
if (!count($values) || !count($on)) {
- return Horde_Core_Translation::t("No values");
+ return Horde_Core_Translation::t('No values');
} else {
- $display = array();
+ $display = [];
foreach ($values as $value => $name) {
if (in_array($value, $on)) {
$display[] = $name;
@@ -1128,9 +1244,9 @@ protected function _renderVarDisplay_keyval_multienum($form, &$var, &$vars)
$values = $var->getValues();
$on = $var->getValue($vars);
if (!count($values) || !count($on)) {
- return Horde_Core_Translation::t("No values");
+ return Horde_Core_Translation::t('No values');
} else {
- $display = array();
+ $display = [];
foreach ($values as $name) {
if (in_array($name, $on)) {
$display[] = $name;
@@ -1145,9 +1261,9 @@ protected function _renderVarDisplay_set($form, &$var, &$vars)
$values = $var->getValues();
$on = $var->getValue($vars);
if (!count($values) || !count($on)) {
- return Horde_Core_Translation::t("No values");
+ return Horde_Core_Translation::t('No values');
} else {
- $display = array();
+ $display = [];
foreach ($values as $value => $name) {
if (in_array($value, $on)) {
$display[] = $name;
@@ -1172,11 +1288,11 @@ protected function _renderVarDisplay_image($form, &$var, &$vars)
if (isset($image['img']['vfs_id'])) {
/* Calling an image from VFS. */
- $img->add(array(
+ $img->add([
'f' => $image['img']['vfs_id'],
'p' => $image['img']['vfs_path'],
- 's' => 'vfs'
- ));
+ 's' => 'vfs',
+ ]);
} else {
/* Calling an image from a tmp directory (uploads). */
$img->add('f', $image['img']['file']);
@@ -1193,9 +1309,9 @@ protected function _renderVarDisplay_phone($form, &$var, &$vars)
$html = htmlspecialchars($number);
if ($number && $registry->hasMethod('telephony/dial')) {
- $url = $registry->call('telephony/dial', array($number));
- $label = sprintf(Horde_Core_Translation::t("Dial %s"), $number);
- $html .= ' ' . Horde::link($url, $label) . Horde_Themes_Image::tag('phone.png', array('alt' => $label)) . '';
+ $url = $registry->call('telephony/dial', [$number]);
+ $label = sprintf(Horde_Core_Translation::t('Dial %s'), $number);
+ $html .= ' ' . Horde::link($url, $label) . Horde_Themes_Image::tag('phone.png', ['alt' => $label]) . '';
}
return $html;
@@ -1209,8 +1325,8 @@ protected function _renderVarDisplay_cellphone($form, &$var, &$vars)
$number = $var->getValue($vars);
if ($number && $registry->hasMethod('sms/compose')) {
- $url = $registry->link('sms/compose', array('to' => $number));
- $html .= ' ' . Horde::link($url, Horde_Core_Translation::t("Send SMS")) . Horde_Themes_Image::tag('mobile.png', array('alt' => Horde_Core_Translation::t("Send SMS"))) . '';
+ $url = $registry->link('sms/compose', ['to' => $number]);
+ $html .= ' ' . Horde::link($url, Horde_Core_Translation::t('Send SMS')) . Horde_Themes_Image::tag('mobile.png', ['alt' => Horde_Core_Translation::t('Send SMS')]) . '';
}
return $html;
@@ -1228,94 +1344,94 @@ protected function _renderVarDisplay_address($form, &$var, &$vars, $text = true)
$google_icon = 'map.png';
if (!empty($info['country'])) {
switch ($info['country']) {
- case 'uk':
- /* Multimap.co.uk generated map */
- $mapurl = 'http://www.multimap.com/map/browse.cgi?pc='
- . urlencode($info['zip']);
- $desc = Horde_Core_Translation::t("Multimap UK map");
- $icon = 'map.png';
- break;
-
- case 'au':
- /* Whereis.com.au generated map */
- $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
- $desc = Horde_Core_Translation::t("Whereis Australia map");
- $icon = 'map.png';
- /* See if it's the street number & name. */
- if (isset($info['streetNumber']) &&
- isset($info['streetName'])) {
- $mapurl .= '&streetNumber='
- . urlencode($info['streetNumber']) . '&streetName='
- . urlencode($info['streetName']);
- }
- /* Look for "Suburb, State". */
- if (isset($info['city'])) {
- $mapurl .= '&suburb=' . urlencode($info['city']);
- }
- /* Look for "State <4 digit postcode>". */
- if (isset($info['state'])) {
- $mapurl .= '&state=' . urlencode($info['state']);
- }
- break;
-
- case 'us':
- case 'ca':
- /* American/Canadian address style. */
- /* Mapquest generated map */
- $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
- $desc = Horde_Core_Translation::t("MapQuest map");
- $icon = 'map.png';
- if (!empty($info['street'])) {
- $mapurl .= '&address=' . urlencode($info['street']);
- }
- if (!empty($info['city'])) {
- $mapurl .= '&city=' . urlencode($info['city']);
- }
- if (!empty($info['state'])) {
- $mapurl .= '&state=' . urlencode($info['state']);
- }
- if (!empty($info['zip'])) {
- if ($info['country'] == 'ca') {
- $mapurl .= '&country=CA';
+ case 'uk':
+ /* Multimap.co.uk generated map */
+ $mapurl = 'http://www.multimap.com/map/browse.cgi?pc='
+ . urlencode($info['zip']);
+ $desc = Horde_Core_Translation::t('Multimap UK map');
+ $icon = 'map.png';
+ break;
+
+ case 'au':
+ /* Whereis.com.au generated map */
+ $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
+ $desc = Horde_Core_Translation::t('Whereis Australia map');
+ $icon = 'map.png';
+ /* See if it's the street number & name. */
+ if (isset($info['streetNumber']) &&
+ isset($info['streetName'])) {
+ $mapurl .= '&streetNumber='
+ . urlencode($info['streetNumber']) . '&streetName='
+ . urlencode($info['streetName']);
}
- $mapurl .= '&zipcode=' . urlencode($info['zip']);
- }
- break;
+ /* Look for "Suburb, State". */
+ if (isset($info['city'])) {
+ $mapurl .= '&suburb=' . urlencode($info['city']);
+ }
+ /* Look for "State <4 digit postcode>". */
+ if (isset($info['state'])) {
+ $mapurl .= '&state=' . urlencode($info['state']);
+ }
+ break;
- default:
- if (!count($info)) {
+ case 'us':
+ case 'ca':
+ /* American/Canadian address style. */
+ /* Mapquest generated map */
+ $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
+ $desc = Horde_Core_Translation::t('MapQuest map');
+ $icon = 'map.png';
+ if (!empty($info['street'])) {
+ $mapurl .= '&address=' . urlencode($info['street']);
+ }
+ if (!empty($info['city'])) {
+ $mapurl .= '&city=' . urlencode($info['city']);
+ }
+ if (!empty($info['state'])) {
+ $mapurl .= '&state=' . urlencode($info['state']);
+ }
+ if (!empty($info['zip'])) {
+ if ($info['country'] == 'ca') {
+ $mapurl .= '&country=CA';
+ }
+ $mapurl .= '&zipcode=' . urlencode($info['zip']);
+ }
+ break;
+
+ default:
+ if (!count($info)) {
+ break;
+ }
+ /* European address style. */
+ $google_icon = 'map_eu.png';
+ /* Mapquest generated map. */
+ $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
+ $desc2 = Horde_Core_Translation::t('MapQuest map');
+ $icon2 = 'map_eu.png';
+ if (!empty($info['street'])) {
+ $mapurl2 .= '&address=' . urlencode($info['street']);
+ }
+ if (!empty($info['zip'])) {
+ $mapurl2 .= '&zipcode=' . urlencode($info['zip']);
+ }
+ if (!empty($info['city'])) {
+ $mapurl2 .= '&city=' . urlencode($info['city']);
+ }
break;
- }
- /* European address style. */
- $google_icon = 'map_eu.png';
- /* Mapquest generated map. */
- $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
- $desc2 = Horde_Core_Translation::t("MapQuest map");
- $icon2 = 'map_eu.png';
- if (!empty($info['street'])) {
- $mapurl2 .= '&address=' . urlencode($info['street']);
- }
- if (!empty($info['zip'])) {
- $mapurl2 .= '&zipcode=' . urlencode($info['zip']);
- }
- if (!empty($info['city'])) {
- $mapurl2 .= '&city=' . urlencode($info['city']);
- }
- break;
}
}
$html = $text ? nl2br(htmlspecialchars($address)) : '';
if (!empty($mapurl)) {
- $html .= ' ' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde_Themes_Image::tag($icon, array('alt' => $desc)) . '';
+ $html .= ' ' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde_Themes_Image::tag($icon, ['alt' => $desc]) . '';
}
if (!empty($mapurl2)) {
- $html .= ' ' . Horde::link(Horde::externalUrl($mapurl2), $desc2, null, '_blank') . Horde_Themes_Image::tag($icon2, array('alt' => $desc2)) . '';
+ $html .= ' ' . Horde::link(Horde::externalUrl($mapurl2), $desc2, null, '_blank') . Horde_Themes_Image::tag($icon2, ['alt' => $desc2]) . '';
}
/* Google generated map. */
if ($address) {
- $html .= ' ' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), Horde_Core_Translation::t("Google Maps"), null, '_blank') . Horde_Themes_Image::tag($google_icon, array('alt' => Horde_Core_Translation::t("Google Maps"))) . '';
+ $html .= ' ' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), Horde_Core_Translation::t('Google Maps'), null, '_blank') . Horde_Themes_Image::tag($google_icon, ['alt' => Horde_Core_Translation::t('Google Maps')]) . '';
}
return $html;
@@ -1425,7 +1541,7 @@ protected function _renderVarDisplay_link($form, &$var, &$vars)
{
$values = $var->type->values;
if (!isset($values[0])) {
- $values = array($values);
+ $values = [$values];
}
$count = count($values);
@@ -1446,9 +1562,8 @@ protected function _renderVarDisplay_link($form, &$var, &$vars)
if (!isset($values[$i]['accesskey'])) {
$values[$i]['accesskey'] = '';
}
- $class = isset($values[$i]['class'])
- ? $values[$i]['class']
- : 'widget';
+ $class = $values[$i]['class']
+ ?? 'widget';
if ($i > 0) {
$html .= ' | ';
}
@@ -1487,9 +1602,13 @@ protected function _renderVarDisplay_captcha($form, &$var, &$vars)
$captcha = Text_CAPTCHA::factory('Image');
}
- $image = $captcha->init(150, 60, $var->type->getText(),
- array('font_path' => dirname($var->type->getFont()) . '/',
- 'font_file' => basename($var->type->getFont())));
+ $image = $captcha->init(
+ 150,
+ 60,
+ $var->type->getText(),
+ ['font_path' => dirname($var->type->getFont()) . '/',
+ 'font_file' => basename($var->type->getFont())]
+ );
if (is_a($image, 'PEAR_Error')) {
return $image->getMessage();
}
@@ -1497,8 +1616,8 @@ protected function _renderVarDisplay_captcha($form, &$var, &$vars)
$cid = hash('md5', $var->type->getText());
$cache = $GLOBALS['injector']->getInstance('Horde_Cache');
- $cache->set($cid, serialize(array('data' => $captcha->getCAPTCHAAsJPEG(),
- 'ctype' => 'image/jpeg')));
+ $cache->set($cid, serialize(['data' => $captcha->getCAPTCHAAsJPEG(),
+ 'ctype' => 'image/jpeg']));
$url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/cacheview.php')->add('cid', $cid);
@@ -1509,28 +1628,32 @@ protected function _renderVarDisplay_captcha($form, &$var, &$vars)
protected function _renderVarInput_selectFiles($form, &$var, &$vars)
{
/* Needed for gollem js calls */
- $html = sprintf('',
- 'selectlist_selectid',
- 'selectlist_selectid',
- $var->type->getProperty('selectid')) .
+ $html = sprintf(
+ '',
+ 'selectlist_selectid',
+ 'selectlist_selectid',
+ $var->type->getProperty('selectid')
+ ) .
sprintf('', 'actionID', 'actionID') .
/* Form field. */
- sprintf('',
- htmlspecialchars($var->getVarName()),
- $this->_genID($var->getVarName(), false),
- $var->type->getProperty('selectid'));
+ sprintf(
+ '',
+ htmlspecialchars($var->getVarName()),
+ $this->_genID($var->getVarName(), false),
+ $var->type->getProperty('selectid')
+ );
/* Open window link. */
- $param = array($var->type->getProperty('link_text'),
+ $param = [$var->type->getProperty('link_text'),
$var->type->getProperty('link_style'),
$form->getName(),
$var->type->getProperty('icon'),
- $var->type->getProperty('selectid'));
+ $var->type->getProperty('selectid')];
$html .= $GLOBALS['registry']->call('files/selectlistLink', $param) . "
\n";
if ($var->type->getProperty('selectid')) {
- $param = array($var->type->getProperty('selectid'));
+ $param = [$var->type->getProperty('selectid')];
$files = $GLOBALS['registry']->call('files/selectlistResults', $param);
if ($files) {
$html .= '';
@@ -1539,8 +1662,8 @@ protected function _renderVarInput_selectFiles($form, &$var, &$vars)
$filename = current($file);
if ($GLOBALS['registry']->hasMethod('files/getViewLink')) {
$filename = basename($filename);
- $url = $GLOBALS['registry']->call('files/getViewLink', array($dir, $filename));
- $filename = Horde::link($url, Horde_Core_Translation::t("Preview"), null, 'form_file_view') . htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename)) . '';
+ $url = $GLOBALS['registry']->call('files/getViewLink', [$dir, $filename]);
+ $filename = Horde::link($url, Horde_Core_Translation::t('Preview'), null, 'form_file_view') . htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename)) . '';
} else {
if (!empty($dir) && ($dir != '.')) {
$filename = $dir . '/' . $filename;
@@ -1565,9 +1688,11 @@ protected function _renderVarInput_category($form, &$var, &$vars)
. Horde_Prefs_CategoryManager::getSelect($var->getVarName(), $var->getValue($vars));
}
- public function selectOptions(&$values, $selectedValue = false,
- $htmlchars = false)
- {
+ public function selectOptions(
+ &$values,
+ $selectedValue = false,
+ $htmlchars = false
+ ) {
$result = '';
$sel = false;
foreach ($values as $value => $display) {
@@ -1596,7 +1721,7 @@ public function selectOptions(&$values, $selectedValue = false,
protected function _multiSelectOptions(&$values, $selectedValues)
{
if (!is_array($selectedValues)) {
- $selectedValues = array();
+ $selectedValues = [];
} else {
$selectedValues = array_flip($selectedValues);
}
@@ -1606,7 +1731,7 @@ protected function _multiSelectOptions(&$values, $selectedValues)
$selected = isset($selectedValues[$value])
? ' selected="selected"'
: '';
- $result .= " " . htmlspecialchars($display) . "\n";
+ $result .= ' " . htmlspecialchars($display) . "\n";
}
return $result;
@@ -1616,21 +1741,23 @@ protected function _checkBoxes($name, $values, $checkedValues, $actions = '')
{
$result = '';
if (!is_array($checkedValues)) {
- $checkedValues = array();
+ $checkedValues = [];
}
$i = 0;
foreach ($values as $value => $display) {
$checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
- $result .= sprintf('
',
- htmlspecialchars($name),
- $i,
- htmlspecialchars($name),
- htmlspecialchars($value),
- $checked,
- $actions,
- htmlspecialchars($name),
- $i,
- htmlspecialchars($display));
+ $result .= sprintf(
+ '
',
+ htmlspecialchars($name),
+ $i,
+ htmlspecialchars($name),
+ htmlspecialchars($value),
+ $checked,
+ $actions,
+ htmlspecialchars($name),
+ $i,
+ htmlspecialchars($display)
+ );
$i++;
}
@@ -1643,16 +1770,18 @@ protected function _radioButtons($name, $values, $checkedValue = null, $actions
$i = 0;
foreach ($values as $value => $display) {
$checked = (!is_null($checkedValue) && $value == $checkedValue) ? ' checked="checked"' : '';
- $result .= sprintf('
',
- htmlspecialchars($name),
- $i,
- htmlspecialchars($name),
- htmlspecialchars($value),
- $checked,
- $actions,
- htmlspecialchars($name),
- $i,
- htmlspecialchars($display));
+ $result .= sprintf(
+ '
',
+ htmlspecialchars($name),
+ $i,
+ htmlspecialchars($name),
+ htmlspecialchars($value),
+ $checked,
+ $actions,
+ htmlspecialchars($name),
+ $i,
+ htmlspecialchars($display)
+ );
$i++;
}
@@ -1670,7 +1799,7 @@ protected function _genActionScript($form, $action, $varname)
$html = '';
$triggers = $action->getTrigger();
if (!is_array($triggers)) {
- $triggers = array($triggers);
+ $triggers = [$triggers];
}
$js = $action->getActionScript($form, $this, $varname);
foreach ($triggers as $trigger) {
@@ -1691,7 +1820,7 @@ protected function _getActionScripts($form, &$var)
$action = &$var->_action;
$triggers = $action->getTrigger();
if (!is_array($triggers)) {
- $triggers = array($triggers);
+ $triggers = [$triggers];
}
$js = $action->getActionScript($form, $this, $varname);
foreach ($triggers as $trigger) {
diff --git a/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php b/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php
index 26fef026b..da786c271 100644
--- a/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php
+++ b/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php
@@ -1,4 +1,5 @@
getValue($vars);
$actions = $this->_getActionScripts($form, $var);
$function_name = 'select' . $form_name . $var->getVarName();
- $enable = Horde_Core_Translation::t("Select all");
- $disable = Horde_Core_Translation::t("Select none");
- $invert = Horde_Core_Translation::t("Invert selection");
+ $enable = Horde_Core_Translation::t('Select all');
+ $disable = Horde_Core_Translation::t('Select none');
+ $invert = Horde_Core_Translation::t('Invert selection');
$page = $GLOBALS['injector']->getInstance('Horde_PageOutput');
$page->addScriptFile('tables.js', 'horde');
- $page->addInlineScript(sprintf('
+ $page->addInlineScript(sprintf(
+ '
function %s()
{
for (var i = 0; i < document.%s.elements.length; i++) {
@@ -42,15 +44,18 @@ function %s()
}
}
}',
- $function_name, $form_name, $var_name));
+ $function_name,
+ $form_name,
+ $var_name
+ ));
$html = <<$enable,
-$disable,
-$invert
-
-| |
-EOT;
+ $enable,
+ $disable,
+ $invert
+
+ | |
+ EOT;
foreach ($header as $col_title) {
$html .= sprintf('%s | ', $col_title);
@@ -58,18 +63,20 @@ function %s()
$html .= '
';
if (!is_array($checkedValues)) {
- $checkedValues = array();
+ $checkedValues = [];
}
$i = 0;
foreach ($values as $value => $displays) {
$checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
$html .= '' .
- sprintf(' | ',
- $name,
- $name,
- $value,
- $checked,
- $actions);
+ sprintf(
+ ' | ',
+ $name,
+ $name,
+ $value,
+ $checked,
+ $actions
+ );
foreach ($displays as $col) {
$html .= sprintf(' %s | ', $col);
}
@@ -101,7 +108,7 @@ protected function _renderVarDisplay_tableset($form, &$var, &$vars)
$html .= '
';
if (!is_array($checkedValues)) {
- $checkedValues = array();
+ $checkedValues = [];
}
$i = 0;
foreach ($values as $value => $displays) {
diff --git a/lib/Horde/Core/Ui/Widget.php b/lib/Horde/Core/Ui/Widget.php
index 973158ec4..1a9ca15b3 100644
--- a/lib/Horde/Core/Ui/Widget.php
+++ b/lib/Horde/Core/Ui/Widget.php
@@ -1,4 +1,5 @@
_name = $name;
$this->_vars = &$vars;
@@ -87,7 +88,7 @@ public function __construct($name, $vars, $config = array())
public function preserve($var, $value = null)
{
if (!is_array($var)) {
- $var = array($var => $value);
+ $var = [$var => $value];
}
foreach ($var as $key => $value) {
diff --git a/lib/Horde/Core/View/Helper/Accesskey.php b/lib/Horde/Core/View/Helper/Accesskey.php
index ac8167999..1d1b6767b 100644
--- a/lib/Horde/Core/View/Helper/Accesskey.php
+++ b/lib/Horde/Core/View/Helper/Accesskey.php
@@ -1,4 +1,5 @@
$alt,
- 'attr' => $attr
- ));
+ 'attr' => $attr,
+ ]);
}
}
diff --git a/lib/Horde/Core/View/Helper/Label.php b/lib/Horde/Core/View/Helper/Label.php
index 8c26a26a5..1d6ed0117 100644
--- a/lib/Horde/Core/View/Helper/Label.php
+++ b/lib/Horde/Core/View/Helper/Label.php
@@ -1,4 +1,5 @@
response;
- header('Content-Type: text/' . $ct . '; charset=UTF-8');
- echo $s_data;
- break;
+ case 'html':
+ case 'plain':
+ case 'xml':
+ $s_data = is_string($data) ? $data : $data->response;
+ header('Content-Type: text/' . $ct . '; charset=UTF-8');
+ echo $s_data;
+ break;
- default:
- echo $data;
+ default:
+ echo $data;
}
exit;
@@ -97,7 +98,7 @@ public static function prepareResponse($data = null, $notify = false)
$response->response = $data;
if ($notify) {
- $stack = $GLOBALS['notification']->notify(array('listeners' => 'status', 'raw' => true));
+ $stack = $GLOBALS['notification']->notify(['listeners' => 'status', 'raw' => true]);
if (!empty($stack)) {
$response->msgs = $stack;
}
@@ -122,10 +123,10 @@ public static function prepareResponse($data = null, $notify = false)
*/
public static function img($src, $alt = '', $attr = '')
{
- return Horde_Themes_Image::tag($src, array(
+ return Horde_Themes_Image::tag($src, [
'alt' => $alt,
- 'attr' => $attr
- ));
+ 'attr' => $attr,
+ ]);
}
/**
@@ -136,13 +137,13 @@ public static function img($src, $alt = '', $attr = '')
* @deprecated Use Horde_Themes_Image::tag()
* @see img()
*/
- public static function fullSrcImg($src, array $opts = array())
+ public static function fullSrcImg($src, array $opts = [])
{
- return Horde_Themes_Image::tag($src, array_filter(array(
- 'attr' => isset($opts['attr']) ? $opts['attr'] : null,
+ return Horde_Themes_Image::tag($src, array_filter([
+ 'attr' => $opts['attr'] ?? null,
'fullsrc' => true,
- 'imgopts' => $opts
- )));
+ 'imgopts' => $opts,
+ ]));
}
/**
@@ -182,7 +183,7 @@ public static function base64ImgData($in, $limit = null)
* @throws Horde_Exception Thrown on error from hook code.
* @throws Horde_Exception_HookNotSet Thrown if hook is not active.
*/
- public static function callHook($hook, $args = array(), $app = 'horde')
+ public static function callHook($hook, $args = [], $app = 'horde')
{
return $GLOBALS['injector']->getInstance('Horde_Core_Hooks')
->callHook($hook, $app, $args);
@@ -226,9 +227,12 @@ public static function hookExists($hook, $app = 'horde')
* $var_names is an array.
* @throws Horde_Exception
*/
- public static function loadConfiguration($config_file, $var_names = null,
- $app = null, $show_output = false)
- {
+ public static function loadConfiguration(
+ $config_file,
+ $var_names = null,
+ $app = null,
+ $show_output = false
+ ) {
global $registry;
$app_conf = $registry->loadConfigFile($config_file, $var_names, $app);
@@ -253,7 +257,7 @@ public static function loadConfiguration($config_file, $var_names = null,
*
* @param array $params
*/
- public static function initMap(array $params = array())
+ public static function initMap(array $params = [])
{
Horde_Core_HordeMap::init($params);
}
diff --git a/lib/Horde/ErrorHandler.php b/lib/Horde/ErrorHandler.php
index ce264a325..8956e478d 100644
--- a/lib/Horde/ErrorHandler.php
+++ b/lib/Horde/ErrorHandler.php
@@ -1,4 +1,5 @@
clearAuthApp($error->application);
+ case 'Horde_Exception_AuthenticationFailure':
+ $auth_app = !$registry->clearAuthApp($error->application);
- if ($auth_app &&
- $registry->isAuthenticated(array('app' => $error->application, 'notransparent' => true))) {
- break;
- }
+ if ($auth_app &&
+ $registry->isAuthenticated(['app' => $error->application, 'notransparent' => true])) {
+ break;
+ }
- try {
- Horde::log($error, 'NOTICE');
- } catch (Exception $e) {}
+ try {
+ Horde::log($error, 'NOTICE');
+ } catch (Exception $e) {
+ }
- if (Horde_Cli::runningFromCLI()) {
- $cli = new Horde_Cli();
- $cli->fatal($error);
- }
+ if (Horde_Cli::runningFromCLI()) {
+ $cli = new Horde_Cli();
+ $cli->fatal($error);
+ }
- $params = array();
+ $params = [];
- if ($registry->getAuth()) {
- $params['app'] = $error->application;
- }
+ if ($registry->getAuth()) {
+ $params['app'] = $error->application;
+ }
- switch ($error->getCode()) {
- case Horde_Auth::REASON_MESSAGE:
- $params['msg'] = $error->getMessage();
- $params['reason'] = $error->getCode();
- break;
- }
+ switch ($error->getCode()) {
+ case Horde_Auth::REASON_MESSAGE:
+ $params['msg'] = $error->getMessage();
+ $params['reason'] = $error->getCode();
+ break;
+ }
- $logout_url = $registry->getLogoutUrl($params);
+ $logout_url = $registry->getLogoutUrl($params);
- /* Clear authentication here. Otherwise, there might be
- * issues on the login page since we would otherwise need
- * to do session token checking (which might not be
- * available, so logout won't happen, etc...) */
- if ($auth_app && array_key_exists('app', $params)) {
- $registry->clearAuth();
- }
+ /* Clear authentication here. Otherwise, there might be
+ * issues on the login page since we would otherwise need
+ * to do session token checking (which might not be
+ * available, so logout won't happen, etc...) */
+ if ($auth_app && array_key_exists('app', $params)) {
+ $registry->clearAuth();
+ }
- $logout_url->redirect();
+ $logout_url->redirect();
}
}
try {
Horde::log($error, 'EMERG');
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
try {
$cli = Horde_Cli::runningFromCLI();
@@ -89,7 +92,7 @@ public static function fatal($error)
header('Content-type: text/html; charset=UTF-8');
header('HTTP/1.1 500: Internal Server Error');
}
-
+
try {
$admin = (isset($registry) && $registry->isAdmin());
$errorHtml = self::getHtmlForError($error, $admin);
@@ -125,33 +128,34 @@ public static function errorHandler($errno, $errstr, $errfile, $errline)
return;
}
- $options = array();
+ $options = [];
try {
switch ($errno) {
- case E_WARNING:
- case E_USER_WARNING:
- case E_RECOVERABLE_ERROR:
- $priority = Horde_Log::WARN;
- break;
-
- case E_NOTICE:
- case E_USER_NOTICE:
- $priority = Horde_Log::NOTICE;
- break;
-
- case E_STRICT:
- $options['notracelog'] = true;
- $priority = Horde_Log::DEBUG;
- break;
-
- default:
- $priority = Horde_Log::DEBUG;
- break;
+ case E_WARNING:
+ case E_USER_WARNING:
+ case E_RECOVERABLE_ERROR:
+ $priority = Horde_Log::WARN;
+ break;
+
+ case E_NOTICE:
+ case E_USER_NOTICE:
+ $priority = Horde_Log::NOTICE;
+ break;
+
+ case E_STRICT:
+ $options['notracelog'] = true;
+ $priority = Horde_Log::DEBUG;
+ break;
+
+ default:
+ $priority = Horde_Log::DEBUG;
+ break;
}
Horde::log(new ErrorException('PHP ERROR: ' . $errstr, 0, $errno, $errfile, $errline), $priority, $options);
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
}
/**
@@ -173,7 +177,7 @@ public static function catchFatalError()
/**
* Returns html for an error
- *
+ *
* @param string|Throwable $error The error as string message or Throwable
* @param bool $isAdmin If true will also output the complete trace
* If $error is a Throwable its complete content will also be included in the output
@@ -188,10 +192,10 @@ public static function getHtmlForError($error, bool $isAdmin = false): string
$message = $error;
}
$fatalErrorHasOccoured = Horde_Core_Translation::t('A fatal error has occurred');
- if ($isAdmin){
+ if ($isAdmin) {
$detailsHtml = self::getErrorDetailsAsHtml($error);
} else {
- $detailsHtml = '' . Horde_Core_Translation::t("Details have been logged for the administrator.") . '
';
+ $detailsHtml = '' . Horde_Core_Translation::t('Details have been logged for the administrator.') . '
';
}
return <<
@@ -211,7 +215,7 @@ public static function getHtmlForError($error, bool $isAdmin = false): string
/**
* Get the details of an error as html. This should usually only be output to admin users
- *
+ *
* @param string|Throwable $error The error as string message or Throwable
* @return string The details of that error as html
*/
diff --git a/lib/Horde/Exception/AuthenticationFailure.php b/lib/Horde/Exception/AuthenticationFailure.php
index b31bceb1d..cd146544e 100644
--- a/lib/Horde/Exception/AuthenticationFailure.php
+++ b/lib/Horde/Exception/AuthenticationFailure.php
@@ -1,4 +1,5 @@
loadXML($data);
- break;
+ case self::SOURCE_RAW:
+ $dom->loadXML($data);
+ break;
- case self::SOURCE_FILE:
- if (!@is_file($data)) {
- throw new Horde_Exception(Horde_Core_Translation::t("Help file not found."));
- }
- $dom->load($data);
- break;
+ case self::SOURCE_FILE:
+ if (!@is_file($data)) {
+ throw new Horde_Exception(Horde_Core_Translation::t('Help file not found.'));
+ }
+ $dom->load($data);
+ break;
}
/* Get list of active entries. */
@@ -72,17 +73,17 @@ protected function _processXml(DOMElement $node, $views)
foreach ($node->childNodes as $val) {
if ($val instanceof DOMElement) {
switch ($val->tagName) {
- case 'entry':
- $this->_xml[] = $val;
- break;
-
- case 'view':
- if (!empty($views) &&
- $val->hasChildNodes() &&
- in_array($val->getAttribute('id'), $views)) {
- $this->_processXml($val, array());
- }
- break;
+ case 'entry':
+ $this->_xml[] = $val;
+ break;
+
+ case 'view':
+ if (!empty($views) &&
+ $val->hasChildNodes() &&
+ in_array($val->getAttribute('id'), $views)) {
+ $this->_processXml($val, []);
+ }
+ break;
}
}
}
@@ -105,29 +106,29 @@ public function lookup($id)
foreach ($entry->childNodes as $child) {
if ($child instanceof DOMElement) {
switch ($child->tagName) {
- case 'heading':
- $out .= '' . $this->_processNode($child) . '
';
- break;
+ case 'heading':
+ $out .= '' . $this->_processNode($child) . '
';
+ break;
- case 'para':
- $out .= '' . $this->_processNode($child) . '
';
- break;
+ case 'para':
+ $out .= '' . $this->_processNode($child) . '
';
+ break;
- case 'raw':
- $out .= '' . htmlspecialchars($this->_processNode($child)) . '
';
- break;
+ case 'raw':
+ $out .= '' . htmlspecialchars($this->_processNode($child)) . '
';
+ break;
- case 'tip':
- $out .= '' . $this->_processNode($child) . '';
- break;
+ case 'tip':
+ $out .= '' . $this->_processNode($child) . '';
+ break;
- case 'title':
- $out .= '' . $this->_processNode($child) . '
';
- break;
+ case 'title':
+ $out .= '' . $this->_processNode($child) . '
';
+ break;
- case 'warn':
- $out .= '' . $this->_processNode($child) . '';
- break;
+ case 'warn':
+ $out .= '' . $this->_processNode($child) . '';
+ break;
}
}
}
@@ -151,41 +152,41 @@ protected function _processNode(DOMElement $node)
foreach ($node->childNodes as $child) {
if ($child instanceof DOMElement) {
switch ($child->tagName) {
- case 'ref':
- $out .= Horde::link(Horde::selfUrl()->add(array(
- 'module' => $child->getAttribute('module'),
- 'show' => 'entry',
- 'topic' => $child->getAttribute('entry')
- ))) . $child->textContent . '';
- break;
-
- case 'text':
- $out .= $child->textContent;
- break;
-
- case 'eref':
- $out .= Horde::link($child->getAttribute('url'), null, '', '_blank') . $child->textContent . '';
- break;
-
- case 'href':
- $out .= Horde::link(Horde::url($GLOBALS['registry']->get('webroot', $child->getAttribute('app') . '/' . $child->getAttribute('url'))), null, '', '_blank') . $child->textContent . '';
- break;
-
- case 'b':
- $out .= '' . $this->_processNode($child) . '';
- break;
-
- case 'i':
- $out .= '' . $this->_processNode($child) . '';
- break;
-
- case 'pre':
- $out .= '' . $this->_processNode($child) . '
';
- break;
-
- case 'css':
- $out .= '' . $this->_processNode($child) . '';
- break;
+ case 'ref':
+ $out .= Horde::link(Horde::selfUrl()->add([
+ 'module' => $child->getAttribute('module'),
+ 'show' => 'entry',
+ 'topic' => $child->getAttribute('entry'),
+ ])) . $child->textContent . '';
+ break;
+
+ case 'text':
+ $out .= $child->textContent;
+ break;
+
+ case 'eref':
+ $out .= Horde::link($child->getAttribute('url'), null, '', '_blank') . $child->textContent . '';
+ break;
+
+ case 'href':
+ $out .= Horde::link(Horde::url($GLOBALS['registry']->get('webroot', $child->getAttribute('app') . '/' . $child->getAttribute('url'))), null, '', '_blank') . $child->textContent . '';
+ break;
+
+ case 'b':
+ $out .= '' . $this->_processNode($child) . '';
+ break;
+
+ case 'i':
+ $out .= '' . $this->_processNode($child) . '';
+ break;
+
+ case 'pre':
+ $out .= '' . $this->_processNode($child) . '
';
+ break;
+
+ case 'css':
+ $out .= '' . $this->_processNode($child) . '';
+ break;
}
} else {
$out .= $child->textContent;
@@ -205,7 +206,7 @@ protected function _processNode(DOMElement $node)
*/
public function search($keyword)
{
- $results = array();
+ $results = [];
foreach ($this->_xml as $elt) {
if (stripos($elt->textContent, $keyword) !== false) {
@@ -224,7 +225,7 @@ public function search($keyword)
*/
public function topics()
{
- $topics = array();
+ $topics = [];
foreach ($this->_xml as $elt) {
$topics[$elt->getAttribute('id')] = $elt->getElementsByTagName('title')->item(0)->textContent;
@@ -250,8 +251,8 @@ public static function link($module, $topic)
}
$url = $GLOBALS['registry']->getServiceLink('help', $module)->add('topic', $topic);
- return $url->link(array('title' => Horde_Core_Translation::t("Help"), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, array('urlencode' => true)) . 'return false;'))
- . Horde_Themes_Image::tag('help.png', array('alt' => Horde_Core_Translation::t("Help"))) . '';
+ return $url->link(['title' => Horde_Core_Translation::t('Help'), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, ['urlencode' => true]) . 'return false;'])
+ . Horde_Themes_Image::tag('help.png', ['alt' => Horde_Core_Translation::t('Help')]) . '';
}
}
diff --git a/lib/Horde/Menu.php b/lib/Horde/Menu.php
index 8ac98a70d..76c2e7aec 100644
--- a/lib/Horde/Menu.php
+++ b/lib/Horde/Menu.php
@@ -1,4 +1,5 @@
_menu[] = array(
+ public function add(
+ $url,
+ $text,
+ $icon = '',
+ $icon_path = null,
+ $target = '',
+ $onclick = null,
+ $class = null
+ ) {
+ $this->_menu[] = [
'url' => ($url instanceof Horde_Url) ? $url : new Horde_Url($url),
'text' => $text,
'icon' => $icon,
'icon_path' => $icon_path,
'target' => $target,
'onclick' => $onclick,
- 'class' => $class
- );
+ 'class' => $class,
+ ];
}
/**
@@ -82,7 +89,7 @@ public function addArray($item)
$item['url'] = new Horde_Url($item['url']);
}
- $this->_menu[] = array_merge(array(
+ $this->_menu[] = array_merge([
'class' => null,
'icon' => '',
'icon_path' => null,
@@ -90,7 +97,7 @@ public function addArray($item)
'target' => '',
'text' => '',
'container' => '',
- ), $item);
+ ], $item);
}
/**
@@ -127,13 +134,13 @@ protected function _render()
continue;
}
- $row = array(
+ $row = [
'cssClass' => $m['icon'],
'url' => $m['url'],
'label' => $m['text'],
'target' => $m['target'],
'onclick' => $m['onclick'],
- );
+ ];
/* Item class and selected indication. */
if (!isset($m['class'])) {
@@ -187,7 +194,7 @@ public function getSiteLinks()
}
}
- return array();
+ return [];
}
/**
diff --git a/lib/Horde/PageOutput.php b/lib/Horde/PageOutput.php
index 8cc1726d3..0ff1c9d85 100644
--- a/lib/Horde/PageOutput.php
+++ b/lib/Horde/PageOutput.php
@@ -1,4 +1,5 @@
smartmobileInit)) {
- echo Horde::wrapInlineScript(array(
+ echo Horde::wrapInlineScript([
'var horde_jquerymobile_init = function() {' .
- implode('', $this->smartmobileInit) . '};'
- ));
- $this->smartmobileInit = array();
+ implode('', $this->smartmobileInit) . '};',
+ ]);
+ $this->smartmobileInit = [];
}
$out = $injector->getInstance('Horde_Core_JavascriptCache')->process($this->hsl, $full);
@@ -277,18 +278,18 @@ public function addInlineScript($script, $onload = false, $top = false)
*
* @return array|void Returns the variable list of 'ret_vars' option is true.
*/
- public function addInlineJsVars($data, $opts = array())
+ public function addInlineJsVars($data, $opts = [])
{
- $out = array();
+ $out = [];
if ($opts === true) {
- $opts = array('onload' => true);
+ $opts = ['onload' => true];
}
- $opts = array_merge(array(
+ $opts = array_merge([
'onload' => false,
'ret_vars' => false,
- 'top' => false
- ), $opts);
+ 'top' => false,
+ ], $opts);
foreach ($data as $key => $val) {
if ($key[0] == '-') {
@@ -319,23 +320,23 @@ public function outputInlineScript($raw = false)
return;
}
- $script = array();
+ $script = [];
foreach ($this->inlineScript as $key => $val) {
$val = implode('', $val);
if (!$raw && $key) {
switch ($key) {
- case 'prototype':
- // @todo Remove 'dom' which is here for BC only.
- case 'dom':
- $script[] = 'document.observe("dom:loaded",function(){' . $val . '});';
- break;
- case 'jquery':
- $script[] = '$(function(){' . $val . '});';
- break;
- default:
- throw new RuntimeException('Unknown JS framework: ' . $key);
+ case 'prototype':
+ // @todo Remove 'dom' which is here for BC only.
+ case 'dom':
+ $script[] = 'document.observe("dom:loaded",function(){' . $val . '});';
+ break;
+ case 'jquery':
+ $script[] = '$(function(){' . $val . '});';
+ break;
+ default:
+ throw new RuntimeException('Unknown JS framework: ' . $key);
}
} else {
$script[] = $val;
@@ -346,7 +347,7 @@ public function outputInlineScript($raw = false)
? implode('', $script)
: Horde::wrapInlineScript($script);
- $this->inlineScript = array();
+ $this->inlineScript = [];
}
/**
@@ -354,14 +355,14 @@ public function outputInlineScript($raw = false)
*/
public function includeFavicon()
{
- $img = strval(Horde_Themes::img('favicon.ico', array(
- 'nohorde' => true
- )));
+ $img = strval(Horde_Themes::img('favicon.ico', [
+ 'nohorde' => true,
+ ]));
if (!$img) {
- $img = strval(Horde_Themes::img('favicon.ico', array(
- 'app' => 'horde'
- )));
+ $img = strval(Horde_Themes::img('favicon.ico', [
+ 'app' => 'horde',
+ ]));
}
echo '';
@@ -376,10 +377,10 @@ public function includeFavicon()
*/
public function addMetaTag($name, $content, $http_equiv = true)
{
- $this->metaTags[$name] = array(
+ $this->metaTags[$name] = [
'c' => $content,
- 'h' => $http_equiv
- );
+ 'h' => $http_equiv,
+ ];
}
/**
@@ -415,7 +416,7 @@ public function outputMetaTags()
'="' . $key . "\" />\n";
}
- $this->metaTags = array();
+ $this->metaTags = [];
}
/**
@@ -426,12 +427,12 @@ public function outputMetaTags()
*
* @param array $opts Non-default tag elements.
*/
- public function addLinkTag(array $opts = array())
+ public function addLinkTag(array $opts = [])
{
- $opts = array_merge(array(
+ $opts = array_merge([
'rel' => 'alternate',
- 'type' => 'application/rss+xml'
- ), $opts);
+ 'type' => 'application/rss+xml',
+ ], $opts);
$out = 'linkTags);
- $this->linkTags = array();
+ $this->linkTags = [];
}
/**
@@ -488,9 +489,10 @@ public function addThemeStylesheet($file)
* Horde_Themes_Css::getStylesheetUrls().
* @param boolean $full Return a full URL? @since Horde_Core 2.28.0
*/
- public function includeStylesheetFiles(array $opts = array(),
- $full = false)
- {
+ public function includeStylesheetFiles(
+ array $opts = [],
+ $full = false
+ ) {
foreach ($this->css->getStylesheetUrls($opts) as $val) {
echo '';
}
@@ -550,16 +552,16 @@ public function disableCompression()
* - title: (string)
* - view: (integer)
*/
- public function header(array $opts = array())
+ public function header(array $opts = [])
{
global $injector, $language, $registry, $session;
- $view = new Horde_View(array(
- 'templatePath' => $registry->get('templates', 'horde') . '/common'
- ));
+ $view = new Horde_View([
+ 'templatePath' => $registry->get('templates', 'horde') . '/common',
+ ]);
$view->outputJs = !$this->deferScripts;
- $view->stylesheetOpts = array();
+ $view->stylesheetOpts = [];
$this->_view = empty($opts['view'])
? ($registry->hasView($registry->getView()) ? $registry->getView() : Horde_Registry::VIEW_BASIC)
@@ -570,76 +572,77 @@ public function header(array $opts = array())
}
switch ($this->_view) {
- case $registry::VIEW_BASIC:
- $this->_addBasicScripts();
- break;
-
- case $registry::VIEW_DYNAMIC:
- $this->ajax = true;
- $this->growler = true;
-
- $this->_addBasicScripts();
- $this->addScriptPackage('Horde_Core_Script_Package_Popup');
- break;
-
- case $registry::VIEW_MINIMAL:
- $view->stylesheetOpts['subonly'] = true;
-
- $view->minimalView = true;
-
- $this->sidebar = $this->topbar = false;
- break;
-
- case $registry::VIEW_SMARTMOBILE:
- $smobile_files = array(
- ($this->debug ? 'jquery.mobile/jquery.js' : 'jquery.mobile/jquery.min.js'),
- 'growler-jquery.js',
- 'horde-jquery.js',
- 'smartmobile.js',
- 'horde-jquery-init.js',
- ($this->debug ? 'jquery.mobile/jquery.mobile.js' : 'jquery.mobile/jquery.mobile.min.js')
- );
- foreach ($smobile_files as $val) {
- $ob = $this->addScriptFile(new Horde_Script_File_JsFramework($val, 'horde'));
- $ob->cache = 'package_smartmobile';
- }
+ case $registry::VIEW_BASIC:
+ $this->_addBasicScripts();
+ break;
+
+ case $registry::VIEW_DYNAMIC:
+ $this->ajax = true;
+ $this->growler = true;
+
+ $this->_addBasicScripts();
+ $this->addScriptPackage('Horde_Core_Script_Package_Popup');
+ break;
+
+ case $registry::VIEW_MINIMAL:
+ $view->stylesheetOpts['subonly'] = true;
+
+ $view->minimalView = true;
+
+ $this->sidebar = $this->topbar = false;
+ break;
+
+ case $registry::VIEW_SMARTMOBILE:
+ $smobile_files = [
+ ($this->debug ? 'jquery.mobile/jquery.js' : 'jquery.mobile/jquery.min.js'),
+ 'growler-jquery.js',
+ 'horde-jquery.js',
+ 'smartmobile.js',
+ 'horde-jquery-init.js',
+ ($this->debug ? 'jquery.mobile/jquery.mobile.js' : 'jquery.mobile/jquery.mobile.min.js'),
+ ];
+ foreach ($smobile_files as $val) {
+ $ob = $this->addScriptFile(new Horde_Script_File_JsFramework($val, 'horde'));
+ $ob->cache = 'package_smartmobile';
+ }
- $this->smartmobileInit = array_merge(array(
- '$.mobile.page.prototype.options.backBtnText = "' . Horde_Core_Translation::t("Back") .'";',
- '$.mobile.dialog.prototype.options.closeBtnText = "' . Horde_Core_Translation::t("Close") .'";',
- '$.mobile.listview.prototype.options.filterPlaceholder = "' . Horde_Core_Translation::t("Filter items...") . '";',
- '$.mobile.loader.prototype.options.text = "' . Horde_Core_Translation::t("loading") . '";'
- ),
- isset($opts['smartmobileinit']) ? $opts['smartmobileinit'] : array(),
- $this->smartmobileInit
- );
+ $this->smartmobileInit = array_merge(
+ [
+ '$.mobile.page.prototype.options.backBtnText = "' . Horde_Core_Translation::t('Back') .'";',
+ '$.mobile.dialog.prototype.options.closeBtnText = "' . Horde_Core_Translation::t('Close') .'";',
+ '$.mobile.listview.prototype.options.filterPlaceholder = "' . Horde_Core_Translation::t('Filter items...') . '";',
+ '$.mobile.loader.prototype.options.text = "' . Horde_Core_Translation::t('loading') . '";',
+ ],
+ $opts['smartmobileinit'] ?? [],
+ $this->smartmobileInit
+ );
- $this->addInlineJsVars(array(
- 'HordeMobile.conf' => array(
- 'ajax_url' => $registry->getServiceLink('ajax', $registry->getApp())->url,
- 'logout_url' => strval($registry->getServiceLink('logout')),
- 'sid' => SID,
- 'token' => $session->getToken()
- )
- ));
+ $this->addInlineJsVars([
+ 'HordeMobile.conf' => [
+ 'ajax_url' => $registry->getServiceLink('ajax', $registry->getApp())->url,
+ 'logout_url' => strval($registry->getServiceLink('logout')),
+ 'sid' => SID,
+ 'token' => $session->getToken(),
+ ],
+ ]);
- $this->addMetaTag('viewport', 'width=device-width, initial-scale=1', false);
+ $this->addMetaTag('viewport', 'width=device-width, initial-scale=1', false);
- $view->stylesheetOpts['subonly'] = true;
+ $view->stylesheetOpts['subonly'] = true;
- $this->addStylesheet(
- $registry->get('jsfs', 'horde') . '/jquery.mobile/jquery.mobile.min.css',
- $registry->get('jsuri', 'horde') . '/jquery.mobile/jquery.mobile.min.css'
- );
+ $this->addStylesheet(
+ $registry->get('jsfs', 'horde') . '/jquery.mobile/jquery.mobile.min.css',
+ $registry->get('jsuri', 'horde') . '/jquery.mobile/jquery.mobile.min.css'
+ );
- $view->smartmobileView = true;
+ $view->smartmobileView = true;
- // Force JS to load at top of page, so we don't see flicker when
- // mobile styles are applied.
- $view->outputJs = true;
+ // Force JS to load at top of page, so we don't see flicker when
+ // mobile styles are applied.
+ $view->outputJs = true;
- $this->sidebar = $this->topbar = false;
- break;
+ $this->sidebar = $this->topbar = false;
+ break;
}
$view->stylesheetOpts['sub'] = Horde_Themes::viewDir($this->_view);
@@ -648,7 +651,7 @@ public function header(array $opts = array())
$this->addScriptFile(new Horde_Script_File_JsFramework('hordecore.js', 'horde'));
/* Configuration used in core javascript files. */
- $js_conf = array_filter(array(
+ $js_conf = array_filter([
/* URLs */
'URI_AJAX' => $registry->getServiceLink('ajax', $registry->getApp())->url,
'URI_DLOAD' => strval($registry->getServiceLink('download', $registry->getApp())),
@@ -662,36 +665,36 @@ public function header(array $opts = array())
/* Other config. */
'growler_log' => $this->topbar,
'popup_height' => 610,
- 'popup_width' => 820
- ));
+ 'popup_width' => 820,
+ ]);
/* Gettext strings used in core javascript files. */
- $js_text = array(
- 'ajax_error' => Horde_Core_Translation::t("Error when communicating with the server."),
- 'ajax_recover' => Horde_Core_Translation::t("The connection to the server has been restored."),
- 'ajax_timeout' => Horde_Core_Translation::t("There has been no contact with the server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored."),
- 'snooze' => sprintf(Horde_Core_Translation::t("You can snooze it for %s or %s dismiss %s it entirely"), '#{time}', '#{dismiss_start}', '#{dismiss_end}'),
- 'snooze_select' => array(
- '0' => Horde_Core_Translation::t("Select..."),
- '5' => Horde_Core_Translation::t("5 minutes"),
- '15' => Horde_Core_Translation::t("15 minutes"),
- '60' => Horde_Core_Translation::t("1 hour"),
- '360' => Horde_Core_Translation::t("6 hours"),
- '1440' => Horde_Core_Translation::t("1 day")
- ),
- 'dismissed' => Horde_Core_Translation::t("The alarm was dismissed.")
- );
+ $js_text = [
+ 'ajax_error' => Horde_Core_Translation::t('Error when communicating with the server.'),
+ 'ajax_recover' => Horde_Core_Translation::t('The connection to the server has been restored.'),
+ 'ajax_timeout' => Horde_Core_Translation::t('There has been no contact with the server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored.'),
+ 'snooze' => sprintf(Horde_Core_Translation::t('You can snooze it for %s or %s dismiss %s it entirely'), '#{time}', '#{dismiss_start}', '#{dismiss_end}'),
+ 'snooze_select' => [
+ '0' => Horde_Core_Translation::t('Select...'),
+ '5' => Horde_Core_Translation::t('5 minutes'),
+ '15' => Horde_Core_Translation::t('15 minutes'),
+ '60' => Horde_Core_Translation::t('1 hour'),
+ '360' => Horde_Core_Translation::t('6 hours'),
+ '1440' => Horde_Core_Translation::t('1 day'),
+ ],
+ 'dismissed' => Horde_Core_Translation::t('The alarm was dismissed.'),
+ ];
if ($this->topbar) {
- $js_text['growlerclear'] = Horde_Core_Translation::t("Clear All");
- $js_text['growlerinfo'] = Horde_Core_Translation::t("This is the notification log.");
- $js_text['growlernoalerts'] = Horde_Core_Translation::t("No Alerts");
+ $js_text['growlerclear'] = Horde_Core_Translation::t('Clear All');
+ $js_text['growlerinfo'] = Horde_Core_Translation::t('This is the notification log.');
+ $js_text['growlernoalerts'] = Horde_Core_Translation::t('No Alerts');
}
- $this->addInlineJsVars(array(
+ $this->addInlineJsVars([
'HordeCore.conf' => $js_conf,
- 'HordeCore.text' => $js_text
- ), array('top' => true));
+ 'HordeCore.text' => $js_text,
+ ], ['top' => true]);
}
if ($this->growler) {
@@ -758,10 +761,10 @@ protected function _addBasicScripts()
{
global $prefs;
- $base_js = array(
+ $base_js = [
'prototype.js',
- 'horde.js'
- );
+ 'horde.js',
+ ];
foreach ($base_js as $val) {
$ob = $this->addScriptFile(new Horde_Script_File_JsFramework($val, 'horde'));
@@ -788,35 +791,35 @@ public function outputSmartmobileFiles()
* @param array $opts Options:
* - NONE currently
*/
- public function footer(array $opts = array())
+ public function footer(array $opts = [])
{
global $browser, $notification, $registry;
- $view = new Horde_View(array(
- 'templatePath' => $registry->get('templates', 'horde') . '/common'
- ));
+ $view = new Horde_View([
+ 'templatePath' => $registry->get('templates', 'horde') . '/common',
+ ]);
if (!$browser->isMobile()) {
- $notification->notify(array('listeners' => array('audio')));
+ $notification->notify(['listeners' => ['audio']]);
}
$view->outputJs = $this->deferScripts;
$view->pageOutput = $this;
switch ($this->_view) {
- case $registry::VIEW_MINIMAL:
- $view->minimalView = true;
- break;
-
- case $registry::VIEW_SMARTMOBILE:
- $view->smartmobileView = true;
- break;
-
- case $registry::VIEW_BASIC:
- $view->basicView = true;
- if ($this->sidebar) {
- $view->sidebar = Horde::sidebar();
- }
- break;
+ case $registry::VIEW_MINIMAL:
+ $view->minimalView = true;
+ break;
+
+ case $registry::VIEW_SMARTMOBILE:
+ $view->smartmobileView = true;
+ break;
+
+ case $registry::VIEW_BASIC:
+ $view->basicView = true;
+ if ($this->sidebar) {
+ $view->sidebar = Horde::sidebar();
+ }
+ break;
}
echo $view->render('footer');
diff --git a/lib/Horde/Registry.php b/lib/Horde/Registry.php
index 7c60d9a92..47b7c5e1f 100644
--- a/lib/Horde/Registry.php
+++ b/lib/Horde/Registry.php
@@ -1,4 +1,5 @@
null,
- 'cfile' => array(),
- 'conf' => array(),
- 'existing' => array(),
- 'ob' => array()
- );
+ 'cfile' => [],
+ 'conf' => [],
+ 'existing' => [],
+ 'ob' => [],
+ ];
/**
* Interfaces list.
*
* @var array
*/
- protected $_interfaces = array();
+ protected $_interfaces = [];
/**
* The last modified time of the newest modified registry file.
@@ -218,13 +219,13 @@ class Horde_Registry implements Horde_Shutdown_Task
* @return Horde_Registry_Application The application object.
* @throws Horde_Exception
*/
- public static function appInit($app, array $args = array())
+ public static function appInit($app, array $args = [])
{
if (isset($GLOBALS['registry'])) {
return $GLOBALS['registry']->getApiInstance($app, 'application');
}
- $args = array_merge(array(
+ $args = array_merge([
'admin' => false,
'authentication' => null,
'cli' => null,
@@ -236,13 +237,13 @@ public static function appInit($app, array $args = array())
'session_control' => null,
'timezone' => false,
'user_admin' => null,
- ), $args);
+ ], $args);
/* CLI initialization. */
if ($args['cli']) {
/* Make sure no one runs from the web. */
if (!Horde_Cli::runningFromCLI()) {
- throw new Horde_Exception(Horde_Core_Translation::t("Script must be run from the command line"));
+ throw new Horde_Exception(Horde_Core_Translation::t('Script must be run from the command line'));
}
/* Load the CLI environment - make sure there's no time limit,
@@ -264,23 +265,23 @@ public static function appInit($app, array $args = array())
// Registry.
$s_ctrl = 0;
switch ($args['session_control']) {
- case 'netscape':
- // Chicken/egg: Browser object doesn't exist yet.
- // Can't use Horde_Core_Browser since it depends on registry to be
- // configured.
- $browser = new Horde_Browser();
- if ($browser->isBrowser('mozilla')) {
- $args['session_cache_limiter'] = 'private, must-revalidate';
- }
- break;
+ case 'netscape':
+ // Chicken/egg: Browser object doesn't exist yet.
+ // Can't use Horde_Core_Browser since it depends on registry to be
+ // configured.
+ $browser = new Horde_Browser();
+ if ($browser->isBrowser('mozilla')) {
+ $args['session_cache_limiter'] = 'private, must-revalidate';
+ }
+ break;
- case 'none':
- $s_ctrl = self::SESSION_NONE;
- break;
+ case 'none':
+ $s_ctrl = self::SESSION_NONE;
+ break;
- case 'readonly':
- $s_ctrl = self::SESSION_READONLY;
- break;
+ case 'readonly':
+ $s_ctrl = self::SESSION_READONLY;
+ break;
}
$classname = __CLASS__;
@@ -292,14 +293,14 @@ public static function appInit($app, array $args = array())
do {
try {
- $registry->pushApp($app, array(
+ $registry->pushApp($app, [
'check_perms' => ($args['authentication'] != 'none'),
'logintasks' => !$args['nologintasks'],
- 'notransparent' => !empty($args['notransparent'])
- ));
+ 'notransparent' => !empty($args['notransparent']),
+ ]);
if ($args['admin'] && !$registry->isAdmin()) {
- throw new Horde_Exception(Horde_Core_Translation::t("Not an admin"));
+ throw new Horde_Exception(Horde_Core_Translation::t('Not an admin'));
}
$e = null;
@@ -320,26 +321,27 @@ public static function appInit($app, array $args = array())
$appob->appInitFailure($e);
switch ($e->getCode()) {
- case self::AUTH_FAILURE:
- $failure = new Horde_Exception_AuthenticationFailure($e->getMessage());
- $failure->application = $app;
- throw $failure;
-
- case self::NOT_ACTIVE:
- /* Try redirect to Horde if an app is not active. */
- if (!$args['cli'] && $app != 'horde') {
- $GLOBALS['notification']->push($e, 'horde.error');
- Horde::url($registry->getInitialPage('horde'))->redirect();
- }
+ case self::AUTH_FAILURE:
+ $failure = new Horde_Exception_AuthenticationFailure($e->getMessage());
+ $failure->application = $app;
+ throw $failure;
+
+ case self::NOT_ACTIVE:
+ /* Try redirect to Horde if an app is not active. */
+ if (!$args['cli'] && $app != 'horde') {
+ $GLOBALS['notification']->push($e, 'horde.error');
+ Horde::url($registry->getInitialPage('horde'))->redirect();
+ }
- /* Shouldn't reach here, but fall back to permission denied
- * error if we can't even access Horde. */
- // Fall-through
+ /* Shouldn't reach here, but fall back to permission denied
+ * error if we can't even access Horde. */
+ // Fall-through
- case self::PERMISSION_DENIED:
- $failure = new Horde_Exception_AuthenticationFailure($e->getMessage(), Horde_Auth::REASON_MESSAGE);
- $failure->application = $app;
- throw $failure;
+ // no break
+ case self::PERMISSION_DENIED:
+ $failure = new Horde_Exception_AuthenticationFailure($e->getMessage(), Horde_Auth::REASON_MESSAGE);
+ $failure->application = $app;
+ throw $failure;
}
throw $e;
@@ -355,22 +357,22 @@ public static function appInit($app, array $args = array())
if ($args['user_admin']) {
if (empty($GLOBALS['conf']['auth']['admins'])) {
- throw new Horde_Exception(Horde_Core_Translation::t("Admin authentication requested, but no admin users defined in configuration."));
+ throw new Horde_Exception(Horde_Core_Translation::t('Admin authentication requested, but no admin users defined in configuration.'));
}
$registry->setAuth(
reset($GLOBALS['conf']['auth']['admins']),
- array(),
- array('no_convert' => true)
+ [],
+ ['no_convert' => true]
);
}
if ($args['permission']) {
- $admin_opts = array(
+ $admin_opts = [
'permission' => $args['permission'][0],
- 'permlevel' => (isset($args['permission'][1]) ? $args['permission'][1] : Horde_Perms::SHOW)
- );
+ 'permlevel' => ($args['permission'][1] ?? Horde_Perms::SHOW),
+ ];
if (!$registry->isAdmin($admin_opts)) {
- throw new Horde_Exception_PermissionDenied(Horde_Core_Translation::t("Permission denied."));
+ throw new Horde_Exception_PermissionDenied(Horde_Core_Translation::t('Permission denied.'));
}
}
@@ -385,7 +387,7 @@ public static function appInit($app, array $args = array())
*
* @throws Horde_Exception
*/
- public function __construct($session_flags = 0, array $args = array())
+ public function __construct($session_flags = 0, array $args = [])
{
/* Set a valid timezone. */
date_default_timezone_set(
@@ -398,7 +400,7 @@ public function __construct($session_flags = 0, array $args = array())
/* Define factories. By default, uses the 'create' method in the given
* classname (string). If other function needed, define as the second
* element in an array. */
- $factories = array(
+ $factories = [
'Horde_ActiveSyncBackend' => 'Horde_Core_Factory_ActiveSyncBackend',
'Horde_ActiveSyncServer' => 'Horde_Core_Factory_ActiveSyncServer',
'Horde_ActiveSyncState' => 'Horde_Core_Factory_ActiveSyncState',
@@ -406,10 +408,10 @@ public function __construct($session_flags = 0, array $args = array())
'Horde_Browser' => 'Horde_Core_Factory_Browser',
'Horde_Cache' => 'Horde_Core_Factory_Cache',
'Horde_Controller_Request' => 'Horde_Core_Factory_Request',
- 'Horde_Controller_RequestConfiguration' => array(
+ 'Horde_Controller_RequestConfiguration' => [
'Horde_Core_Controller_RequestMapper',
'getRequestConfiguration',
- ),
+ ],
'Horde_Core_Auth_Signup' => 'Horde_Core_Factory_AuthSignup',
'Horde_Core_CssCache' => 'Horde_Core_Factory_CssCache',
'Horde_Core_JavascriptCache' => 'Horde_Core_Factory_JavascriptCache',
@@ -452,20 +454,20 @@ public function __construct($session_flags = 0, array $args = array())
'Net_DNS2_Resolver' => 'Horde_Core_Factory_Dns',
'Text_LanguageDetect' => 'Horde_Core_Factory_LanguageDetect',
Horde\Core\Middleware\AuthHttpBasic::class => Horde\Core\Factory\AuthHttpBasicFactory::class,
- Horde\Log\Logger::class => Horde\Core\Factory\LoggerFactory::class
- );
+ Horde\Log\Logger::class => Horde\Core\Factory\LoggerFactory::class,
+ ];
/* Define implementations. */
- $implementations = array(
- 'Horde_Controller_ResponseWriter' => 'Horde_Controller_ResponseWriter_Web'
- );
+ $implementations = [
+ 'Horde_Controller_ResponseWriter' => 'Horde_Controller_ResponseWriter_Web',
+ ];
/* Setup injector. */
$GLOBALS['injector'] = $injector = new Horde_Injector(new Horde_Injector_TopLevel());
foreach ($factories as $key => $val) {
if (is_string($val)) {
- $val = array($val, 'create');
+ $val = [$val, 'create'];
}
$injector->bindFactory($key, $val[0], $val[1]);
}
@@ -507,10 +509,10 @@ public function __construct($session_flags = 0, array $args = array())
$GLOBALS['browser'] = $injector->getInstance('Horde_Browser');
/* Get modified time of registry files. */
- $regfiles = array(
+ $regfiles = [
HORDE_BASE . '/config/registry.php',
- HORDE_BASE . '/config/registry.d'
- );
+ HORDE_BASE . '/config/registry.d',
+ ];
if (file_exists(HORDE_BASE . '/config/registry.local.php')) {
$regfiles[] = HORDE_BASE . '/config/registry.local.php';
}
@@ -549,7 +551,7 @@ public function __construct($session_flags = 0, array $args = array())
/* Stop system if Horde is inactive. */
if ($this->applications['horde']['status'] == 'inactive') {
- throw new Horde_Exception(Horde_Core_Translation::t("This system is currently deactivated."));
+ throw new Horde_Exception(Horde_Core_Translation::t('This system is currently deactivated.'));
}
/* Initialize language configuration object. */
@@ -565,13 +567,13 @@ public function __construct($session_flags = 0, array $args = array())
* default. */
$nclass = null;
switch ($this->getView()) {
- case self::VIEW_DYNAMIC:
- $nclass = 'Horde_Core_Notification_Listener_DynamicStatus';
- break;
+ case self::VIEW_DYNAMIC:
+ $nclass = 'Horde_Core_Notification_Listener_DynamicStatus';
+ break;
- case self::VIEW_SMARTMOBILE:
- $nclass = 'Horde_Core_Notification_Listener_SmartmobileStatus';
- break;
+ case self::VIEW_SMARTMOBILE:
+ $nclass = 'Horde_Core_Notification_Listener_SmartmobileStatus';
+ break;
}
$GLOBALS['notification'] = $injector->getInstance('Horde_Notification');
if (empty($args['nonotificationinit'])) {
@@ -596,9 +598,9 @@ public function __construct($session_flags = 0, array $args = array())
public function setAuthenticationSetting($authentication)
{
$this->_args['authentication'] = $authentication;
- $this->_cache['cfile'] = $this->_cache['ob'] = array();
- $this->_cache['isauth'] = array();
- $this->_appsInit = array();
+ $this->_cache['cfile'] = $this->_cache['ob'] = [];
+ $this->_cache['isauth'] = [];
+ $this->_appsInit = [];
while ($this->popApp());
}
@@ -656,7 +658,7 @@ public function rebuild()
$app = $this->getApp();
- $this->applications = $this->_apiList = $this->_cache['conf'] = $this->_cache['ob'] = $this->_interfaces = array();
+ $this->applications = $this->_apiList = $this->_cache['conf'] = $this->_cache['ob'] = $this->_interfaces = [];
$session->remove('horde', 'nls/');
$session->remove('horde', 'registry/');
@@ -690,23 +692,24 @@ protected function _loadApplications()
}
$cache = new Horde_Cache(
- new $cstorage(array(
+ new $cstorage([
'no_gc' => true,
- 'prefix' => 'horde_registry_cache_'
- )),
- array(
+ 'prefix' => 'horde_registry_cache_',
+ ]),
+ [
'lifetime' => 0,
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- )
+ 'logger' => $injector->getInstance('Horde_Log_Logger'),
+ ]
);
if (($cid = $this->_cacheId()) &&
($cdata = $cache->get($cid, 0))) {
try {
- list($this->applications, $this->_interfaces) =
+ [$this->applications, $this->_interfaces] =
$injector->getInstance('Horde_Pack')->unpack($cdata);
return;
- } catch (Horde_Pack_Exception $e) {}
+ } catch (Horde_Pack_Exception $e) {
+ }
}
}
@@ -721,10 +724,10 @@ protected function _loadApplications()
/* Need to determine hash of generated data, since it is possible that
* there is dynamic data in the config files. This only needs to
* be done once per session. */
- $packed_data = $injector->getInstance('Horde_Pack')->pack(array(
+ $packed_data = $injector->getInstance('Horde_Pack')->pack([
$this->applications,
- $this->_interfaces
- ));
+ $this->_interfaces,
+ ]);
$cid = $this->_cacheId($packed_data);
if (!$cache->exists($cid, 0)) {
@@ -750,12 +753,12 @@ protected function _cacheId($hash = null)
}
/* Generate cache ID. */
- return implode('|', array(
+ return implode('|', [
gethostname() ?: php_uname(),
__FILE__,
$this->_regmtime,
- $hash
- ));
+ $hash,
+ ]);
}
/**
@@ -772,7 +775,7 @@ protected function _loadApi($app)
}
$api = null;
- $status = array('active', 'notoolbar', 'hidden');
+ $status = ['active', 'notoolbar', 'hidden'];
$status[] = $this->isAdmin()
? 'admin'
: 'noadmin';
@@ -813,11 +816,11 @@ public function getApiInstance($app, $type)
if (!isset($this->_cache['ob'][$app])) {
$autoloader = $GLOBALS['injector']->getInstance('Horde_Autoloader');
- $app_mappers = array(
+ $app_mappers = [
'Controller' => 'controllers',
'Helper' => 'helpers',
- 'SettingsExporter' => 'settings'
- );
+ 'SettingsExporter' => 'settings',
+ ];
$applicationMapper = new Horde_Autoloader_ClassPathMapper_Application($this->get('fileroot', $app) . '/app');
foreach ($app_mappers as $key => $val) {
$applicationMapper->addMapping($key, $val);
@@ -883,11 +886,13 @@ public function getApiInstance($app, $type)
* @return array List of apps registered with Horde. If no
* applications are defined returns an empty array.
*/
- public function listApps($filter = null, $assoc = false,
- $perms = Horde_Perms::SHOW)
- {
+ public function listApps(
+ $filter = null,
+ $assoc = false,
+ $perms = Horde_Perms::SHOW
+ ) {
if (is_null($filter)) {
- $filter = array('notoolbar', 'active');
+ $filter = ['notoolbar', 'active'];
}
if (!$this->isAdmin() &&
in_array('active', $filter) &&
@@ -895,14 +900,14 @@ public function listApps($filter = null, $assoc = false,
$filter[] = 'noadmin';
}
- $apps = array();
+ $apps = [];
foreach ($this->applications as $app => $params) {
if (in_array($params['status'], $filter)) {
/* Topbar apps can only be displayed if the parent app is
* active. */
if (($params['status'] == 'topbar') &&
$this->isInactive($params['app'])) {
- continue;
+ continue;
}
if ((is_null($perms) || $this->hasPermission($app, $perms))) {
@@ -922,9 +927,9 @@ public function listApps($filter = null, $assoc = false,
public function listAllApps()
{
// Default to all installed (but possibly not configured) applications.
- return $this->listApps(array(
- 'active', 'admin', 'noadmin', 'hidden', 'inactive', 'notoolbar'
- ), false, null);
+ return $this->listApps([
+ 'active', 'admin', 'noadmin', 'hidden', 'inactive', 'notoolbar',
+ ], false, null);
}
/**
@@ -953,10 +958,10 @@ public function isInactive($app)
public function listAPIs()
{
if (empty($this->_apiList) && !empty($this->_interfaces)) {
- $apis = array();
+ $apis = [];
foreach (array_keys($this->_interfaces) as $interface) {
- list($api,) = explode('/', $interface, 2);
+ [$api, ] = explode('/', $interface, 2);
$apis[$api] = true;
}
@@ -977,13 +982,13 @@ public function listAPIs()
*/
public function listMethods($api = null)
{
- $methods = array();
+ $methods = [];
foreach (array_keys($this->applications) as $app) {
if (isset($this->applications[$app]['provides'])) {
$provides = $this->applications[$app]['provides'];
if (!is_array($provides)) {
- $provides = array($provides);
+ $provides = [$provides];
}
foreach ($provides as $method) {
@@ -1068,19 +1073,19 @@ protected function _doHasSearch($method, $app, $func)
if (($lookup = $this->_methodLookup($method)) === false) {
return false;
}
- list($app, $call) = $lookup;
+ [$app, $call] = $lookup;
} else {
$call = $method;
}
if ($api_ob = $this->_loadApi($app)) {
switch ($func) {
- case 'links':
- $links = $api_ob->links();
- return isset($links[$call]) ? $app : false;
+ case 'links':
+ $links = $api_ob->links();
+ return isset($links[$call]) ? $app : false;
- case 'methods':
- return in_array($call, $api_ob->methods()) ? $app : false;
+ case 'methods':
+ return in_array($call, $api_ob->methods()) ? $app : false;
}
}
@@ -1098,7 +1103,7 @@ protected function _doHasSearch($method, $app, $func)
* @return mixed Return from method call.
* @throws Horde_Exception
*/
- public function call($method, $args = array())
+ public function call($method, $args = [])
{
if (($lookup = $this->_methodLookup($method)) === false) {
throw new Horde_Exception('The method "' . $method . '" is not defined in the Horde Registry.');
@@ -1119,9 +1124,12 @@ public function call($method, $args = array())
* @return mixed Return from application call.
* @throws Horde_Exception_PushApp
*/
- public function callByPackage($app, $call, array $args = array(),
- array $options = array())
- {
+ public function callByPackage(
+ $app,
+ $call,
+ array $args = [],
+ array $options = []
+ ) {
/* Note: calling hasMethod() makes sure that we've cached
* $app's services and included the API file, so we don't try
* to do it again explicitly in this method. */
@@ -1132,7 +1140,7 @@ public function callByPackage($app, $call, array $args = array(),
/* Load the API now. */
$methods = ($api_ob = $this->_loadApi($app))
? $api_ob->methods()
- : array();
+ : [];
/* Make sure that the function actually exists. */
if (!in_array($call, $methods)) {
@@ -1142,12 +1150,12 @@ public function callByPackage($app, $call, array $args = array(),
/* Switch application contexts now, if necessary, before
* including any files which might do it for us. Return an
* error immediately if pushApp() fails. */
- $pushed = $this->pushApp($app, array(
- 'check_perms' => !in_array($call, $api_ob->noPerms()) && empty($options['noperms']) && $this->currentProcessAuth()
- ));
+ $pushed = $this->pushApp($app, [
+ 'check_perms' => !in_array($call, $api_ob->noPerms()) && empty($options['noperms']) && $this->currentProcessAuth(),
+ ]);
try {
- $result = call_user_func_array(array($api_ob, $call), $args);
+ $result = call_user_func_array([$api_ob, $call], $args);
if ($result instanceof PEAR_Error) {
$result = new Horde_Exception_Wrapped($result);
}
@@ -1185,7 +1193,7 @@ public function callByPackage($app, $call, array $args = array(),
* is a fatal error.
* @throws Horde_Exception_PushApp
*/
- public function callAppMethod($app, $call, array $options = array())
+ public function callAppMethod($app, $call, array $options = [])
{
/* Load the API now. */
try {
@@ -1207,12 +1215,12 @@ public function callAppMethod($app, $call, array $options = array())
/* Switch application contexts now, if necessary, before
* including any files which might do it for us. Return an
* error immediately if pushApp() fails. */
- $pushed = $this->pushApp($app, array(
- 'check_perms' => empty($options['noperms']) && $this->currentProcessAuth()
- ));
+ $pushed = $this->pushApp($app, [
+ 'check_perms' => empty($options['noperms']) && $this->currentProcessAuth(),
+ ]);
try {
- $result = call_user_func_array(array($api, $call), empty($options['args']) ? array() : $options['args']);
+ $result = call_user_func_array([$api, $call], empty($options['args']) ? [] : $options['args']);
} catch (Horde_Exception $e) {
$result = $e;
}
@@ -1242,7 +1250,7 @@ public function callAppMethod($app, $call, array $options = array())
* @return string The link for that method.
* @throws Horde_Exception
*/
- public function link($method, $args = array(), $extra = '')
+ public function link($method, $args = [], $extra = '')
{
if (($lookup = $this->_methodLookup($method)) === false) {
throw new Horde_Exception('The link "' . $method . '" is not defined in the Horde Registry.');
@@ -1262,11 +1270,11 @@ public function link($method, $args = array(), $extra = '')
* @return string The link for that method.
* @throws Horde_Exception
*/
- public function linkByPackage($app, $call, $args = array(), $extra = '')
+ public function linkByPackage($app, $call, $args = [], $extra = '')
{
$links = ($api_ob = $this->_loadApi($app))
? $api_ob->links()
- : array();
+ : [];
/* Make sure the link is defined. */
if (!isset($links[$call])) {
@@ -1322,11 +1330,11 @@ public function linkByPackage($app, $call, $args = array(), $extra = '')
*/
protected function _methodLookup($method)
{
- list($interface, $call) = explode('/', $method, 2);
+ [$interface, $call] = explode('/', $method, 2);
if (!empty($this->_interfaces[$method])) {
- return array($this->_interfaces[$method], $call);
+ return [$this->_interfaces[$method], $call];
} elseif (!empty($this->_interfaces[$interface])) {
- return array($this->_interfaces[$interface], $call);
+ return [$this->_interfaces[$interface], $call];
}
return false;
@@ -1349,7 +1357,7 @@ public function applicationFilePath($path, $app = null)
}
if (!isset($this->applications[$app])) {
- throw new Horde_Exception(sprintf(Horde_Core_Translation::t("\"%s\" is not configured in the Horde Registry."), $app));
+ throw new Horde_Exception(sprintf(Horde_Core_Translation::t('"%s" is not configured in the Horde Registry.'), $app));
}
return str_replace('%application%', $this->applications[$app]['fileroot'], $path);
@@ -1384,7 +1392,7 @@ public function showService($type)
{
global $conf;
- if (!in_array($type, array('help', 'problem', 'logout', 'login', 'prefs'))) {
+ if (!in_array($type, ['help', 'problem', 'logout', 'login', 'prefs'])) {
return true;
}
@@ -1393,15 +1401,15 @@ public function showService($type)
}
switch ($conf['menu']['links'][$type]) {
- case 'all':
- return true;
+ case 'all':
+ return true;
- case 'authenticated':
- return (bool)$this->getAuth();
+ case 'authenticated':
+ return (bool)$this->getAuth();
- default:
- case 'never':
- return false;
+ default:
+ case 'never':
+ return false;
}
}
@@ -1431,82 +1439,83 @@ public function showService($type)
*/
public function getServiceLink($type, $app = null, $full = false)
{
- $opts = array('app' => 'horde');
+ $opts = ['app' => 'horde'];
switch ($type) {
- case 'ajax':
- if (is_null($app)) {
- $app = 'horde';
- }
- return Horde::url('services/ajax.php/' . $app . '/', $full, $opts)
- ->add('token', $GLOBALS['session']->getToken());
+ case 'ajax':
+ if (is_null($app)) {
+ $app = 'horde';
+ }
+ return Horde::url('services/ajax.php/' . $app . '/', $full, $opts)
+ ->add('token', $GLOBALS['session']->getToken());
- case 'cache':
- $opts['append_session'] = -1;
- return Horde::url('services/cache.php', $full, $opts);
+ case 'cache':
+ $opts['append_session'] = -1;
+ return Horde::url('services/cache.php', $full, $opts);
- case 'download':
- return Horde::url('services/download/', $full, $opts)
- ->add('app', $app);
+ case 'download':
+ return Horde::url('services/download/', $full, $opts)
+ ->add('app', $app);
- case 'emailconfirm':
- return Horde::url('services/confirm.php', $full, $opts);
+ case 'emailconfirm':
+ return Horde::url('services/confirm.php', $full, $opts);
- case 'go':
- return Horde::url('services/go.php', $full, $opts);
+ case 'go':
+ return Horde::url('services/go.php', $full, $opts);
- case 'help':
- return Horde::url('services/help/', $full, $opts)
- ->add('module', $app);
+ case 'help':
+ return Horde::url('services/help/', $full, $opts)
+ ->add('module', $app);
- case 'imple':
- return Horde::url('services/imple.php', $full, $opts);
+ case 'imple':
+ return Horde::url('services/imple.php', $full, $opts);
- case 'login':
- return Horde::url('login.php', $full, $opts);
+ case 'login':
+ return Horde::url('login.php', $full, $opts);
- case 'logintasks':
- return Horde::url('services/logintasks.php', $full, $opts)
- ->add('app', $app);
+ case 'logintasks':
+ return Horde::url('services/logintasks.php', $full, $opts)
+ ->add('app', $app);
- case 'logout':
- return $this->getLogoutUrl(array(
- 'reason' => Horde_Auth::REASON_LOGOUT
- ));
+ case 'logout':
+ return $this->getLogoutUrl([
+ 'reason' => Horde_Auth::REASON_LOGOUT,
+ ]);
- case 'pixel':
- return Horde::url('services/images/pixel.php', $full, $opts);
+ case 'pixel':
+ return Horde::url('services/images/pixel.php', $full, $opts);
- case 'prefs':
- if (!in_array($GLOBALS['conf']['prefs']['driver'], array('', 'none'))) {
- $url = Horde::url('services/prefs.php', $full, $opts);
- if (!is_null($app)) {
- $url->add('app', $app);
+ case 'prefs':
+ if (!in_array($GLOBALS['conf']['prefs']['driver'], ['', 'none'])) {
+ $url = Horde::url('services/prefs.php', $full, $opts);
+ if (!is_null($app)) {
+ $url->add('app', $app);
+ }
+ return $url;
}
- return $url;
- }
- break;
+ break;
- case 'portal':
- return ($this->getView() == Horde_Registry::VIEW_SMARTMOBILE)
- ? Horde::url('services/portal/smartmobile.php', $full, $opts)
- : Horde::url('services/portal/', $full, $opts);
- break;
+ case 'portal':
+ return ($this->getView() == Horde_Registry::VIEW_SMARTMOBILE)
+ ? Horde::url('services/portal/smartmobile.php', $full, $opts)
+ : Horde::url('services/portal/', $full, $opts);
+ break;
- case 'problem':
- return Horde::url('services/problem.php', $full, $opts)
- ->add(
- 'return_url',
- Horde_Util::getFormData(
- 'location', Horde::signUrl(Horde::selfUrl(true, true, true))
- )
- );
+ case 'problem':
+ return Horde::url('services/problem.php', $full, $opts)
+ ->add(
+ 'return_url',
+ Horde_Util::getFormData(
+ 'location',
+ Horde::signUrl(Horde::selfUrl(true, true, true))
+ )
+ );
- case 'sidebar':
- return Horde::url('services/sidebar.php', $full, $opts);
+ case 'sidebar':
+ return Horde::url('services/sidebar.php', $full, $opts);
- case 'twitter':
- return Horde::url('services/twitter/', true);
+ case 'twitter':
+ return Horde::url('services/twitter/', true);
}
throw new BadFunctionCallException('Invalid service requested: ' . print_r(debug_backtrace(false), true));
@@ -1537,7 +1546,7 @@ public function getServiceLink($type, $app = null, $full = false)
* @return boolean Whether or not the _appStack was modified.
* @throws Horde_Exception_PushApp
*/
- public function pushApp($app, array $options = array())
+ public function pushApp($app, array $options = [])
{
global $injector, $notification, $language, $session;
@@ -1549,7 +1558,7 @@ public function pushApp($app, array $options = array())
if ($this->isInactive($app)) {
throw new Horde_Exception_PushApp(
sprintf(
- Horde_Core_Translation::t("%s is not activated."),
+ Horde_Core_Translation::t('%s is not activated.'),
$this->applications[$app]['name']
),
self::NOT_ACTIVE,
@@ -1578,10 +1587,10 @@ public function pushApp($app, array $options = array())
}
if (!$error &&
- !$this->hasPermission($app, Horde_Perms::READ, array('notransparent' => !empty($options['notransparent'])))) {
+ !$this->hasPermission($app, Horde_Perms::READ, ['notransparent' => !empty($options['notransparent'])])) {
$error = '%s is not authorized for %s (Host: %s).';
- if ($this->isAuthenticated(array('app' => $app))) {
+ if ($this->isAuthenticated(['app' => $app])) {
$error_log = '%s does not have READ permission for %s (Host: %s)';
$error_type = self::PERMISSION_DENIED;
}
@@ -1748,13 +1757,15 @@ public function getApp()
*
* @return bool Whether access is allowed.
*/
- public function hasPermission($app, $perms = Horde_Perms::READ,
- array $params = array())
- {
+ public function hasPermission(
+ $app,
+ $perms = Horde_Perms::READ,
+ array $params = []
+ ) {
/* Always do isAuthenticated() check first. You can be an admin, but
* application auth != Horde admin auth. And there can *never* be
* non-SHOW access to an application that requires authentication. */
- if (!$this->isAuthenticated(array('app' => $app, 'notransparent' => !empty($params['notransparent']))) &&
+ if (!$this->isAuthenticated(['app' => $app, 'notransparent' => !empty($params['notransparent'])]) &&
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create($app)->requireAuth() &&
($perms != Horde_Perms::SHOW)) {
return false;
@@ -1778,14 +1789,14 @@ public function importConfig($app)
{
/* Make sure Horde is always loaded. */
if (!isset($this->_cache['conf']['horde'])) {
- $this->_cache['conf']['horde'] = new Horde_Registry_Hordeconfig(array('app' => 'horde'));
+ $this->_cache['conf']['horde'] = new Horde_Registry_Hordeconfig(['app' => 'horde']);
}
if (!isset($this->_cache['conf'][$app])) {
- $this->_cache['conf'][$app] = new Horde_Registry_Hordeconfig_Merged(array(
- 'aconfig' => new Horde_Registry_Hordeconfig(array('app' => $app)),
- 'hconfig' => $this->_cache['conf']['horde']
- ));
+ $this->_cache['conf'][$app] = new Horde_Registry_Hordeconfig_Merged([
+ 'aconfig' => new Horde_Registry_Hordeconfig(['app' => $app]),
+ 'hconfig' => $this->_cache['conf']['horde'],
+ ]);
}
$GLOBALS['conf'] = $this->_cache['conf'][$app]->toArray();
@@ -1817,15 +1828,15 @@ public function loadPrefs($app = null)
return;
}
- $opts = array(
- 'user' => $user
- );
+ $opts = [
+ 'user' => $user,
+ ];
} else {
/* If there is no logged in user, return an empty Horde_Prefs
* object with just default preferences. */
- $opts = array(
- 'driver' => 'Horde_Prefs_Storage_Null'
- );
+ $opts = [
+ 'driver' => 'Horde_Prefs_Storage_Null',
+ ];
}
$prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create($app, $opts);
@@ -1884,22 +1895,21 @@ public function get($parameter, $app = null)
$pval = $this->applications[$app][$parameter];
} else {
switch ($parameter) {
- case 'icon':
- $pval = Horde_Themes::img($app . '.png', $app);
- if ((string)$pval == '') {
- $pval = Horde_Themes::img('app-unknown.png', 'horde');
- }
- break;
+ case 'icon':
+ $pval = Horde_Themes::img($app . '.png', $app);
+ if ((string)$pval == '') {
+ $pval = Horde_Themes::img('app-unknown.png', 'horde');
+ }
+ break;
- case 'initial_page':
- $pval = null;
- break;
+ case 'initial_page':
+ $pval = null;
+ break;
- default:
- $pval = isset($this->applications['horde'][$parameter])
- ? $this->applications['horde'][$parameter]
- : null;
- break;
+ default:
+ $pval = $this->applications['horde'][$parameter]
+ ?? null;
+ break;
}
}
@@ -1969,18 +1979,18 @@ public function hasFeature($id, $app = null)
public function hasView($view, $app = null)
{
switch ($view) {
- case self::VIEW_BASIC:
- // For now, consider all apps to have BASIC view.
- return true;
+ case self::VIEW_BASIC:
+ // For now, consider all apps to have BASIC view.
+ return true;
- case self::VIEW_DYNAMIC:
- return $this->hasFeature('dynamicView', $app);
+ case self::VIEW_DYNAMIC:
+ return $this->hasFeature('dynamicView', $app);
- case self::VIEW_MINIMAL:
- return $this->hasFeature('minimalView', $app);
+ case self::VIEW_MINIMAL:
+ return $this->hasFeature('minimalView', $app);
- case self::VIEW_SMARTMOBILE:
- return $this->hasFeature('smartmobileView', $app);
+ case self::VIEW_SMARTMOBILE:
+ return $this->hasFeature('smartmobileView', $app);
}
}
@@ -2011,7 +2021,7 @@ public function getView()
/**
* Returns a list of available drivers for a library that are available
* in an application.
- *
+ *
* @todo support namespaced prefixes with multiple levels
*
*
@@ -2022,7 +2032,7 @@ public function getView()
*/
public function getAppDrivers($app, $prefix)
{
- $classes = array();
+ $classes = [];
$fileprefix = strtr($prefix, '_', '/');
$fileroot = $this->get('fileroot', $app);
@@ -2031,7 +2041,7 @@ public function getAppDrivers($app, $prefix)
$pushed = $this->pushApp($app);
} catch (Horde_Exception $e) {
if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
- return array();
+ return [];
}
throw $e;
}
@@ -2048,7 +2058,8 @@ public function getAppDrivers($app, $prefix)
}
}
}
- } catch (UnexpectedValueException $e) {}
+ } catch (UnexpectedValueException $e) {
+ }
}
if (is_dir($fileroot . '/src/' . $fileprefix)) {
try {
@@ -2062,7 +2073,8 @@ public function getAppDrivers($app, $prefix)
}
}
}
- } catch (UnexpectedValueException $e) {}
+ } catch (UnexpectedValueException $e) {
+ }
}
if ($pushed) {
@@ -2088,14 +2100,15 @@ public function getInitialPage($app = null)
if (($url = $this->callAppMethod($app, 'getInitialPage')) !== null) {
return $url;
}
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
if (($webroot = $this->get('webroot', $app)) !== null) {
return $webroot . '/' . strval($this->get('initial_page', $app));
}
throw new Horde_Exception(sprintf(
- Horde_Core_Translation::t("\"%s\" is not configured in the Horde Registry."),
+ Horde_Core_Translation::t('"%s" is not configured in the Horde Registry.'),
is_null($app) ? $this->getApp() : $app
));
}
@@ -2114,7 +2127,8 @@ public function clearAuth($destroy = true)
foreach ($this->getAuthApps() as $app) {
try {
$this->callAppMethod($app, 'logout');
- } catch (Horde_Exception $e) {}
+ } catch (Horde_Exception $e) {
+ }
}
/* Do registered logout tasks. */
@@ -2126,7 +2140,7 @@ public function clearAuth($destroy = true)
$session->remove('horde', 'auth_app/');
$this->_cache['auth'] = null;
- $this->_cache['existing'] = $this->_cache['isauth'] = array();
+ $this->_cache['existing'] = $this->_cache['isauth'] = [];
if ($destroy) {
$session->destroy();
@@ -2148,7 +2162,7 @@ public function clearAuthApp($app)
return false;
}
- if ($this->isAuthenticated(array('app' => $app, 'notransparent' => true))) {
+ if ($this->isAuthenticated(['app' => $app, 'notransparent' => true])) {
$this->callAppMethod($app, 'logout');
$session->remove($app);
$session->remove('horde', 'auth_app/' . $app);
@@ -2176,11 +2190,10 @@ public function clearAuthApp($app)
*
* @return boolean Whether or not this is an admin user.
*/
- public function isAdmin(array $options = array())
+ public function isAdmin(array $options = [])
{
- $user = isset($options['user'])
- ? $options['user']
- : $this->getAuth();
+ $user = $options['user']
+ ?? $this->getAuth();
if ($user &&
@is_array($GLOBALS['conf']['auth']['admins']) &&
@@ -2189,7 +2202,7 @@ public function isAdmin(array $options = array())
}
return isset($options['permission'])
- ? $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission($options['permission'], $user, isset($options['permlevel']) ? $options['permlevel'] : Horde_Perms::EDIT)
+ ? $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission($options['permission'], $user, $options['permlevel'] ?? Horde_Perms::EDIT)
: false;
}
@@ -2206,7 +2219,7 @@ public function isAdmin(array $options = array())
*
* @return boolean Whether or not the user is authenticated.
*/
- public function isAuthenticated(array $opts = array())
+ public function isAuthenticated(array $opts = [])
{
global $injector, $session;
@@ -2274,7 +2287,7 @@ public function currentProcessAuth()
*
* @return Horde_Url The formatted URL.
*/
- public function getLogoutUrl(array $options = array())
+ public function getLogoutUrl(array $options = [])
{
if (!isset($options['reason'])) {
// TODO: This only returns the error for Horde-wide
@@ -2282,8 +2295,8 @@ public function getLogoutUrl(array $options = array())
$options['reason'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create()->getError();
}
- $params = array();
- if (!in_array($options['reason'], array(Horde_Auth::REASON_LOGOUT, Horde_Auth::REASON_MESSAGE))) {
+ $params = [];
+ if (!in_array($options['reason'], [Horde_Auth::REASON_LOGOUT, Horde_Auth::REASON_MESSAGE])) {
$params['url'] = Horde::signUrl(Horde::selfUrl(true, true, true));
}
@@ -2291,7 +2304,7 @@ public function getLogoutUrl(array $options = array())
($options['app'] == 'horde') ||
($options['reason'] == Horde_Auth::REASON_LOGOUT)) {
$params['horde_logout_token'] = $GLOBALS['session']->getToken();
- }
+ }
if (isset($options['app'])) {
$params['app'] = $options['app'];
@@ -2319,7 +2332,7 @@ public function getLogoutUrl(array $options = array())
* since the filename MUST be the last parameter added
* to the URL.
*/
- public function downloadUrl($filename, array $params = array())
+ public function downloadUrl($filename, array $params = [])
{
$url = $this->getServiceLink('download', $this->getApp())
/* Add parameters. */
@@ -2349,7 +2362,7 @@ public function convertUsername($userId, $toHorde)
{
try {
return $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->
- callHook('authusername', 'horde', array($userId, $toHorde));
+ callHook('authusername', 'horde', [$userId, $toHorde]);
} catch (Horde_Exception_HookNotSet $e) {
return $userId;
}
@@ -2392,21 +2405,21 @@ public function getAuth($format = null)
}
switch ($format) {
- case 'bare':
- return (($pos = strpos($user, '@')) === false)
- ? $user
- : substr($user, 0, $pos);
+ case 'bare':
+ return (($pos = strpos($user, '@')) === false)
+ ? $user
+ : substr($user, 0, $pos);
- case 'domain':
- return (($pos = strpos($user, '@')) === false)
- ? false
- : substr($user, $pos + 1);
+ case 'domain':
+ return (($pos = strpos($user, '@')) === false)
+ ? false
+ : substr($user, $pos + 1);
- default:
- /* Specifically cache this result, since it generally is called
- * many times in a page. */
- $this->_cache['auth'] = $user;
- return $user;
+ default:
+ /* Specifically cache this result, since it generally is called
+ * many times in a page. */
+ $this->_cache['auth'] = $user;
+ return $user;
}
}
@@ -2471,7 +2484,7 @@ public function setAuthCredential($credential, $value = null, $app = null)
}
if (!is_array($credentials)) {
- $credentials = array();
+ $credentials = [];
}
$credentials[$credential] = $value;
@@ -2546,7 +2559,7 @@ public function remoteHost()
{
global $injector;
- $out = new stdClass;
+ $out = new stdClass();
$dns = $injector->getInstance('Net_DNS2_Resolver');
$old_error = error_reporting(0);
@@ -2574,7 +2587,8 @@ public function remoteHost()
}
}
}
- } catch (Net_DNS2_Exception $e) {}
+ } catch (Net_DNS2_Exception $e) {
+ }
} elseif (!isset($out->host)) {
$out->host = gethostbyaddr($out->addr);
}
@@ -2604,7 +2618,7 @@ public function remoteHost()
* authusername hook.
* DEFAULT: false
*/
- public function setAuth($authId, $credentials, array $options = array())
+ public function setAuth($authId, $credentials, array $options = [])
{
global $browser, $injector, $session;
@@ -2640,7 +2654,7 @@ public function setAuth($authId, $credentials, array $options = array())
$session->set('horde', 'auth/userId', $username);
$this->_cache['auth'] = null;
- $this->_cache['existing'] = $this->_cache['isauth'] = array();
+ $this->_cache['existing'] = $this->_cache['isauth'] = [];
$this->setAuthCredential($credentials, null, $app);
@@ -2692,7 +2706,7 @@ public function checkExistingAuth($app = 'horde')
}
}
- foreach (array_unique(array('horde', $app)) as $val) {
+ foreach (array_unique(['horde', $app]) as $val) {
if (!isset($this->_cache['existing'][$val])) {
$auth = $injector->getInstance('Horde_Core_Factory_Auth')->create($val);
if (!$auth->validateAuth()) {
@@ -2737,19 +2751,19 @@ public function removeUser($userId)
public function removeUserData($user, $app = null)
{
if (!$this->isAdmin() && ($user != $this->getAuth())) {
- throw new Horde_Exception(Horde_Core_Translation::t("You are not allowed to remove user data."));
+ throw new Horde_Exception(Horde_Core_Translation::t('You are not allowed to remove user data.'));
}
$applist = empty($app)
? $this->listApps(
- array('notoolbar', 'hidden', 'active', 'admin', 'noadmin')
+ ['notoolbar', 'hidden', 'active', 'admin', 'noadmin']
)
- : array($app);
- $errApps = array();
+ : [$app];
+ $errApps = [];
if (!empty($applist)) {
$prefs_ob = $GLOBALS['injector']
->getInstance('Horde_Core_Factory_Prefs')
- ->create('horde', array('user' => $user));
+ ->create('horde', ['user' => $user]);
// Remove all preference at once, if possible.
if (empty($app)) {
@@ -2763,9 +2777,9 @@ public function removeUserData($user, $app = null)
foreach ($applist as $item) {
try {
- $this->callAppMethod($item, 'removeUserData', array(
- 'args' => array($user)
- ));
+ $this->callAppMethod($item, 'removeUserData', [
+ 'args' => [$user],
+ ]);
} catch (Exception $e) {
Horde::log($e);
$errApps[] = $item;
@@ -2784,7 +2798,7 @@ public function removeUserData($user, $app = null)
}
if (count($errApps)) {
- throw new Horde_Exception(sprintf(Horde_Core_Translation::t("The following applications encountered errors removing user data: %s"), implode(', ', array_unique($errApps))));
+ throw new Horde_Exception(sprintf(Horde_Core_Translation::t('The following applications encountered errors removing user data: %s'), implode(', ', array_unique($errApps))));
}
}
@@ -2907,7 +2921,7 @@ public function preferredLang($lang = null)
$partial_lang = $ll_LL;
} else {
$ll = $this->_mapLang(substr($lang, 0, 2));
- if ($this->nlsconfig->validLang($ll)) {
+ if ($this->nlsconfig->validLang($ll)) {
$partial_lang = $ll;
}
}
@@ -2965,10 +2979,10 @@ public function setLanguage($lang = null)
if ($changed) {
$this->rebuild();
- $this->_cache['cfile'] = array();
+ $this->_cache['cfile'] = [];
foreach ($this->listApps() as $app) {
- if ($this->isAuthenticated(array('app' => $app, 'notransparent' => true))) {
+ if ($this->isAuthenticated(['app' => $app, 'notransparent' => true])) {
$this->callAppMethod($app, 'changeLanguage');
}
}
diff --git a/lib/Horde/Registry/Api.php b/lib/Horde/Registry/Api.php
index 3613bdbed..77f45ea56 100644
--- a/lib/Horde/Registry/Api.php
+++ b/lib/Horde/Registry/Api.php
@@ -1,4 +1,5 @@
false,
'minimalView' => false,
@@ -48,15 +49,15 @@ class Horde_Registry_Application implements Horde_Shutdown_Task
// Notification Handler
'notificationHandler' => false,
// Alarm Handler
- 'alarmHandler' => false
- );
+ 'alarmHandler' => false,
+ ];
/**
* The init params used.
*
* @var array
*/
- public $initParams = array();
+ public $initParams = [];
/**
* The application's version.
@@ -77,7 +78,7 @@ class Horde_Registry_Application implements Horde_Shutdown_Task
*
* @var array
*/
- protected $_sessVars = array();
+ protected $_sessVars = [];
/**
* Constructor.
@@ -222,9 +223,9 @@ public function removeUserData($user)
* @return \Horde\Backup\Users List of per-user data.
* @throws Horde_Exception
*/
- public function backup(array $users = array())
+ public function backup(array $users = [])
{
- return new Backup\Users(new EmptyIterator(), function(){});
+ return new Backup\Users(new EmptyIterator(), function () {});
}
/**
@@ -251,7 +252,7 @@ public function restore(Backup\Collection $data)
*/
public function restoreDependencies()
{
- return array();
+ return [];
}
/**
@@ -268,10 +269,10 @@ protected function _backupPrefs(Backup\User $backup, $app)
global $injector;
$prefs = $injector->getInstance('Horde_Core_Factory_Prefs')
- ->create($app, array('user' => $backup->user));
+ ->create($app, ['user' => $backup->user]);
$prefs->retrieve();
$scope = $prefs->getScopeObject($app);
- $values = array();
+ $values = [];
foreach ($scope as $key => $value) {
if (!$scope->isDefault($key)) {
$values[$key] = $scope->get($key);
@@ -300,7 +301,7 @@ protected function _restorePrefs(Backup\Collection $data, $app)
global $injector;
$prefs = $injector->getInstance('Horde_Core_Factory_Prefs')
- ->create($app, array('user' => $data->getUser()));
+ ->create($app, ['user' => $data->getUser()]);
$prefs->retrieve();
$count = 0;
@@ -335,7 +336,7 @@ public function getInitialPage()
*/
public function perms()
{
- return array();
+ return [];
}
/**
@@ -347,7 +348,7 @@ public function perms()
*
* @return mixed The value of the specified permission.
*/
- public function hasPermission($permission, $allowed, $opts = array())
+ public function hasPermission($permission, $allowed, $opts = [])
{
return true;
}
@@ -376,7 +377,7 @@ public function hasPermission($permission, $allowed, $opts = array())
*/
public function download(Horde_Variables $vars)
{
- return array();
+ return [];
}
@@ -405,7 +406,7 @@ public function setupNotification(Horde_Notification_Handler $handler)
*/
public function listAlarms($time, $user = null)
{
- return array();
+ return [];
}
@@ -418,11 +419,11 @@ public function listAlarms($time, $user = null)
*/
public function authLoginParams()
{
- return array(
- 'js_code' => array(),
- 'js_files' => array(),
- 'params' => array()
- );
+ return [
+ 'js_code' => [],
+ 'js_files' => [],
+ 'params' => [],
+ ];
}
/**
@@ -522,7 +523,7 @@ public function authUserExists($userId)
*/
public function authUserList()
{
- return array();
+ return [];
}
/**
@@ -560,7 +561,7 @@ final public function updateSessVars()
foreach ($this->_sessVars as $key => $val) {
$GLOBALS['session']->set($this->_app, $key, $val);
}
- $this->_sessVars = array();
+ $this->_sessVars = [];
}
@@ -575,7 +576,7 @@ final public function updateSessVars()
*/
public function configSpecialValues($what)
{
- return array();
+ return [];
}
@@ -590,9 +591,11 @@ public function configSpecialValues($what)
*
* @throws Horde_Exception
*/
- public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null,
- array $params = array())
- {
+ public function topbarCreate(
+ Horde_Tree_Renderer_Base $tree,
+ $parent = null,
+ array $params = []
+ ) {
}
@@ -620,7 +623,7 @@ public function changeLanguage()
*/
public function nosqlDrivers()
{
- return array();
+ return [];
}
}
diff --git a/lib/Horde/Registry/Caller.php b/lib/Horde/Registry/Caller.php
index fc4014572..dcdf88c56 100644
--- a/lib/Horde/Registry/Caller.php
+++ b/lib/Horde/Registry/Caller.php
@@ -1,4 +1,5 @@
app, 'conf.php', 'conf');
$this->_config = $c->config['conf'];
} catch (Horde_Exception $e) {
- $this->_config = array();
+ $this->_config = [];
}
}
}
@@ -100,9 +100,8 @@ public function offsetExists($offset)
public function offsetGet($offset)
{
$this->_load($offset);
- return isset($this->_config[$offset])
- ? $this->_config[$offset]
- : null;
+ return $this->_config[$offset]
+ ?? null;
}
#[\ReturnTypeWillChange]
diff --git a/lib/Horde/Registry/Hordeconfig/Merged.php b/lib/Horde/Registry/Hordeconfig/Merged.php
index 25cab4d4c..d2a7bbe88 100644
--- a/lib/Horde/Registry/Hordeconfig/Merged.php
+++ b/lib/Horde/Registry/Hordeconfig/Merged.php
@@ -1,4 +1,5 @@
logoutTask();
}
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
}
- $this->_setTasks(array());
+ $this->_setTasks([]);
}
/**
diff --git a/lib/Horde/Registry/Logout/Task.php b/lib/Horde/Registry/Logout/Task.php
index ab062501f..06794407a 100644
--- a/lib/Horde/Registry/Logout/Task.php
+++ b/lib/Horde/Registry/Logout/Task.php
@@ -1,4 +1,5 @@
exists('horde', 'nls/' . $name)) {
@@ -53,63 +54,59 @@ public function __get($name)
}
switch ($name) {
- case 'aliases':
- case 'charsets':
- case 'encodings':
- case 'emails':
- case 'languages':
- case 'multibyte':
- case 'rtl':
- case 'spelling':
- $ret = isset($this->_config[$name])
- ? $this->_config[$name]
- : array();
- break;
-
- case 'charsets_sort':
- $ret = $this->charsets;
- natcasesort($ret);
- break;
-
- case 'curr_charset':
- /* Return charset for the current language. */
- $ret = isset($this->_config['charsets'][$language])
- ? $this->_config['charsets'][$language]
- : null;
- break;
-
- case 'curr_default':
- /* The default langauge, as specified by the config file. */
- $ret = isset($this->_config['defaults']['language'])
- ? $this->_config['defaults']['language']
- : null;
- break;
-
- case 'curr_emails':
- /* Return e-mail charset for the current language. */
- $ret = isset($this->_config['emails'][$language])
- ? $this->_config['emails'][$language]
- : null;
- break;
-
- case 'curr_multibyte':
- /* Is the current language charset multibyte? */
- $ret = isset($this->_config['multibyte'][$registry->getLanguageCharset()]);
- break;
-
- case 'curr_rtl':
- /* Is the current language RTL? */
- $ret = isset($this->_config['rtl'][$language]);
- break;
-
- case 'encodings_sort':
- $ret = $this->encodings;
- asort($ret);
- break;
-
- default:
- $ret = null;
- break;
+ case 'aliases':
+ case 'charsets':
+ case 'encodings':
+ case 'emails':
+ case 'languages':
+ case 'multibyte':
+ case 'rtl':
+ case 'spelling':
+ $ret = $this->_config[$name]
+ ?? [];
+ break;
+
+ case 'charsets_sort':
+ $ret = $this->charsets;
+ natcasesort($ret);
+ break;
+
+ case 'curr_charset':
+ /* Return charset for the current language. */
+ $ret = $this->_config['charsets'][$language]
+ ?? null;
+ break;
+
+ case 'curr_default':
+ /* The default langauge, as specified by the config file. */
+ $ret = $this->_config['defaults']['language']
+ ?? null;
+ break;
+
+ case 'curr_emails':
+ /* Return e-mail charset for the current language. */
+ $ret = $this->_config['emails'][$language]
+ ?? null;
+ break;
+
+ case 'curr_multibyte':
+ /* Is the current language charset multibyte? */
+ $ret = isset($this->_config['multibyte'][$registry->getLanguageCharset()]);
+ break;
+
+ case 'curr_rtl':
+ /* Is the current language RTL? */
+ $ret = isset($this->_config['rtl'][$language]);
+ break;
+
+ case 'encodings_sort':
+ $ret = $this->encodings;
+ asort($ret);
+ break;
+
+ default:
+ $ret = null;
+ break;
}
if (in_array($name, $cached)) {
@@ -140,7 +137,7 @@ public function validLang($lang)
} else {
// Locale length is limited to 255 characters.
foreach (explode(';', $locale) as $lc) {
- list($category, $catLocale) = explode('=', $lc);
+ [$category, $catLocale] = explode('=', $lc);
if (defined($category)) {
setlocale(constant($category), $catLocale);
}
diff --git a/lib/Horde/Registry/Registryconfig.php b/lib/Horde/Registry/Registryconfig.php
index f5db2fdf3..aa5829e04 100644
--- a/lib/Horde/Registry/Registryconfig.php
+++ b/lib/Horde/Registry/Registryconfig.php
@@ -1,4 +1,5 @@
applications['horde']['fileroot'])) {
- $this->applications['horde']['fileroot'] = isset($app_fileroot)
- ? $app_fileroot
- : HORDE_BASE;
+ $this->applications['horde']['fileroot'] = $app_fileroot
+ ?? HORDE_BASE;
}
if (!isset($app_fileroot)) {
$app_fileroot = $this->applications['horde']['fileroot'];
@@ -95,9 +95,8 @@ public function __construct($reg_ob)
$app_fileroot = rtrim($app_fileroot, '/') . '/';
if (!isset($this->applications['horde']['webroot'])) {
- $this->applications['horde']['webroot'] = isset($app_webroot)
- ? $app_webroot
- : $this->_detectWebroot();
+ $this->applications['horde']['webroot'] = $app_webroot
+ ?? $this->_detectWebroot();
}
if (!isset($app_webroot)) {
$app_webroot = $this->applications['horde']['webroot'];
@@ -201,7 +200,7 @@ protected function _detectWebroot($basedir = HORDE_BASE)
$webroot = preg_split(';/;', $_SERVER['PHP_SELF'], 2, PREG_SPLIT_NO_EMPTY);
$webroot = strstr(realpath($basedir), DIRECTORY_SEPARATOR . array_shift($webroot));
if ($webroot !== false) {
- return preg_replace(array('/\\\\/', ';/config$;'), array('/', ''), $webroot);
+ return preg_replace(['/\\\\/', ';/config$;'], ['/', ''], $webroot);
}
return ($webroot === false)
diff --git a/lib/Horde/Script/Cache.php b/lib/Horde/Script/Cache.php
index 4cc2ee0d4..cd9c6371a 100644
--- a/lib/Horde/Script/Cache.php
+++ b/lib/Horde/Script/Cache.php
@@ -1,4 +1,5 @@
_params = $params;
if (!rand(0, 999)) {
@@ -58,13 +59,13 @@ public function __construct(array $params = array())
*/
public function process(Horde_Script_List $hsl, $full = false)
{
- $out = new stdClass;
- $out->all = array();
- $out->jsvars = array();
- $out->script = array();
+ $out = new stdClass();
+ $out->all = [];
+ $out->jsvars = [];
+ $out->script = [];
$last_cache = null;
- $tmp = array();
+ $tmp = [];
foreach ($hsl as $val) {
$out->all[] = $url = strval($full ? $val->url_full : $val->url);
@@ -73,16 +74,16 @@ public function process(Horde_Script_List $hsl, $full = false)
$out->script = array_merge(
$out->script,
$this->_process($tmp, $full),
- array($url)
+ [$url]
);
- $tmp = array();
+ $tmp = [];
} else {
if (!is_null($last_cache) && ($last_cache != $val->cache)) {
$out->script = array_merge(
$out->script,
$this->_process($tmp, $full)
);
- $tmp = array();
+ $tmp = [];
}
$tmp[$val->hash] = $val;
}
diff --git a/lib/Horde/Script/Cache/File.php b/lib/Horde/Script/Cache/File.php
index 030b16a4f..64d739bc3 100644
--- a/lib/Horde/Script/Cache/File.php
+++ b/lib/Horde/Script/Cache/File.php
@@ -1,4 +1,5 @@
modified;
}
@@ -110,7 +111,7 @@ protected function _process($scripts, $full = false)
$js_url = (string)Horde::url($js_url, true, -1);
}
- $out = array($js_url);
+ $out = [$js_url];
if (file_exists($js_path)) {
return $out;
@@ -141,7 +142,7 @@ protected function _process($scripts, $full = false)
$temp = Horde_Util::getTempFile('staticjs', true, $js_fs);
if (!file_put_contents($temp, $jsmin->minify(), LOCK_EX) ||
- !chmod($temp, 0777 & ~umask()) ||
+ !chmod($temp, 0o777 & ~umask()) ||
!rename($temp, $js_path)) {
Horde::log('Could not write cached JS file to disk.', Horde_Log::EMERG);
} elseif ($this->_compress->sourcemap_support) {
diff --git a/lib/Horde/Script/Cache/HordeCache.php b/lib/Horde/Script/Cache/HordeCache.php
index 349e224e7..b17fd4843 100644
--- a/lib/Horde/Script/Cache/HordeCache.php
+++ b/lib/Horde/Script/Cache/HordeCache.php
@@ -1,4 +1,5 @@
modified;
}
@@ -60,9 +61,9 @@ protected function _process($scripts, $full = false)
: $this->_params['lifetime'];
// Do lifetime checking here, not on cache display page.
- $js_url = Horde::getCacheUrl('js', array('cid' => $sig));
+ $js_url = Horde::getCacheUrl('js', ['cid' => $sig]);
- $out = array($js_url);
+ $out = [$js_url];
if ($cache->exists($sig, $cache_lifetime)) {
return $out;
@@ -88,7 +89,7 @@ protected function _process($scripts, $full = false)
);
}
- $sourcemap_url = Horde::getCacheUrl('js', array('cid' => $sig . '.map'));
+ $sourcemap_url = Horde::getCacheUrl('js', ['cid' => $sig . '.map']);
$jsmin = $this->_compress->getMinifier($scripts, $sourcemap_url);
$cache->set($sig, $jsmin->minify());
diff --git a/lib/Horde/Script/Cache/Null.php b/lib/Horde/Script/Cache/Null.php
index a3572670c..9caa39b3d 100644
--- a/lib/Horde/Script/Cache/Null.php
+++ b/lib/Horde/Script/Cache/Null.php
@@ -1,4 +1,5 @@
url_full : $val->url);
diff --git a/lib/Horde/Script/Compress.php b/lib/Horde/Script/Compress.php
index f6a86b948..8731341e7 100644
--- a/lib/Horde/Script/Compress.php
+++ b/lib/Horde/Script/Compress.php
@@ -1,4 +1,5 @@
_params = array(
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- );
+ $this->_params = [
+ 'logger' => $injector->getInstance('Horde_Log_Logger'),
+ ];
switch ($driver) {
- case 'closure':
- $this->_driver = 'Horde_JavascriptMinify_Closure';
- $this->_params = array_merge($this->_params, array(
- 'closure' => $params['closurepath'],
- 'java' => $params['javapath']
- ));
- $this->_sourcemap = true;
- break;
-
- case 'none':
- $this->_driver = 'Horde_JavascriptMinify_Null';
- break;
-
- case 'php':
- /* Due to licensing issues, Jsmin might not be available. */
- $this->_driver = class_exists('Horde_JavascriptMinify_Jsmin')
- ? 'Horde_JavascriptMinify_Jsmin'
- : 'Horde_JavascriptMinify_Null';
- break;
-
- case 'uglifyjs':
- $this->_driver = 'Horde_JavascriptMinify_Uglifyjs';
- $this->_params = array_merge($this->_params, array(
- 'uglifyjs' => $params['uglifyjspath']
- ));
-
- if (isset($params['uglifyjscmdline'])) {
- $this->_params['cmdline'] = trim($params['uglifyjscmdline']);
- }
+ case 'closure':
+ $this->_driver = 'Horde_JavascriptMinify_Closure';
+ $this->_params = array_merge($this->_params, [
+ 'closure' => $params['closurepath'],
+ 'java' => $params['javapath'],
+ ]);
+ $this->_sourcemap = true;
+ break;
+
+ case 'none':
+ $this->_driver = 'Horde_JavascriptMinify_Null';
+ break;
- if (isset($params['uglifyjsversion'])) {
- switch ($params['uglifyjsversion']) {
- case 2:
- if ($this->_params['cmdline'] != '-c') {
- $this->_params['cmdline'] = '-c';
+ case 'php':
+ /* Due to licensing issues, Jsmin might not be available. */
+ $this->_driver = class_exists('Horde_JavascriptMinify_Jsmin')
+ ? 'Horde_JavascriptMinify_Jsmin'
+ : 'Horde_JavascriptMinify_Null';
+ break;
+
+ case 'uglifyjs':
+ $this->_driver = 'Horde_JavascriptMinify_Uglifyjs';
+ $this->_params = array_merge($this->_params, [
+ 'uglifyjs' => $params['uglifyjspath'],
+ ]);
+
+ if (isset($params['uglifyjscmdline'])) {
+ $this->_params['cmdline'] = trim($params['uglifyjscmdline']);
+ }
+
+ if (isset($params['uglifyjsversion'])) {
+ switch ($params['uglifyjsversion']) {
+ case 2:
+ if ($this->_params['cmdline'] != '-c') {
+ $this->_params['cmdline'] = '-c';
+ }
+ $this->_sourcemap = true;
+ break;
}
+ } else {
$this->_sourcemap = true;
- break;
}
- } else {
- $this->_sourcemap = true;
- }
- break;
-
- case 'yui':
- $this->_driver = 'Horde_JavascriptMinify_Yui';
- $this->_params = array_merge($this->_params, array(
- 'java' => $params['javapath'],
- 'yui' => $params['yuipath']
- ));
- break;
-
- default:
- /* Treat as a custom driver. */
- if (class_exists($driver)) {
- $this->_driver = $driver;
- $this->_params = array_merge($this->_params, $params);
- } else {
- $this->_driver = 'Horde_JavascriptMinify_Null';
- }
- break;
+ break;
+
+ case 'yui':
+ $this->_driver = 'Horde_JavascriptMinify_Yui';
+ $this->_params = array_merge($this->_params, [
+ 'java' => $params['javapath'],
+ 'yui' => $params['yuipath'],
+ ]);
+ break;
+
+ default:
+ /* Treat as a custom driver. */
+ if (class_exists($driver)) {
+ $this->_driver = $driver;
+ $this->_params = array_merge($this->_params, $params);
+ } else {
+ $this->_driver = 'Horde_JavascriptMinify_Null';
+ }
+ break;
}
}
@@ -131,8 +132,8 @@ public function __construct($driver, array $params = array())
public function __get($name)
{
switch ($name) {
- case 'sourcemap_support':
- return $this->_sourcemap;
+ case 'sourcemap_support':
+ return $this->_sourcemap;
}
}
@@ -146,16 +147,16 @@ public function __get($name)
*/
public function getMinifier($scripts, $sourcemap = null)
{
- $js_files = array();
+ $js_files = [];
foreach ($scripts as $val) {
switch ($this->_driver) {
- case 'Horde_JavascriptMinify_Null':
- break;
+ case 'Horde_JavascriptMinify_Null':
+ break;
- default:
- $val = $val->uncompressed;
- break;
+ default:
+ $val = $val->uncompressed;
+ break;
}
$js_files[strval($val->url_full)] = $val->full_path;
@@ -165,9 +166,9 @@ public function getMinifier($scripts, $sourcemap = null)
$js_files,
array_merge(
$this->_params,
- array(
- 'sourcemap' => $sourcemap
- )
+ [
+ 'sourcemap' => $sourcemap,
+ ]
)
);
}
diff --git a/lib/Horde/Script/File.php b/lib/Horde/Script/File.php
index c44039f7e..cb1466300 100644
--- a/lib/Horde/Script/File.php
+++ b/lib/Horde/Script/File.php
@@ -1,4 +1,5 @@
_app;
+ case 'app':
+ return $this->_app;
- case 'file':
- return $this->_file;
+ case 'file':
+ return $this->_file;
- case 'full_path':
- return $this->path . $this->_file;
+ case 'full_path':
+ return $this->path . $this->_file;
- case 'hash':
- return hash(
- 'md5',
- $this->_app . "\0" . $this->_file
- );
+ case 'hash':
+ return hash(
+ 'md5',
+ $this->_app . "\0" . $this->_file
+ );
- case 'modified':
- return filemtime($this->full_path);
+ case 'modified':
+ return filemtime($this->full_path);
- case 'path':
- return '/';
+ case 'path':
+ return '/';
- case 'priority':
- return $this->_priority;
+ case 'priority':
+ return $this->_priority;
- case 'tag':
- case 'tag_full':
- return '';
+ case 'tag':
+ case 'tag_full':
+ return '';
- case 'uncompressed':
- return $this;
+ case 'uncompressed':
+ return $this;
- case 'url':
- case 'url_full':
- return $this->_url($this->_file, ($name == 'url_full'));
+ case 'url':
+ case 'url_full':
+ return $this->_url($this->_file, ($name == 'url_full'));
}
}
@@ -142,11 +143,11 @@ public function __get($name)
public function __set($name, $value)
{
switch ($name) {
- case 'priority':
- if (in_array($value, array(self::PRIORITY_HIGH, self::PRIORITY_NORMAL, self::PRIORITY_LOW))) {
- $this->_priority = $value;
- }
- break;
+ case 'priority':
+ if (in_array($value, [self::PRIORITY_HIGH, self::PRIORITY_NORMAL, self::PRIORITY_LOW])) {
+ $this->_priority = $value;
+ }
+ break;
}
}
@@ -172,10 +173,13 @@ protected function _url($file, $full)
/* Add cache-busting version param. */
return empty($GLOBALS['conf']['cachejsparams']['url_version_param'])
? $url
- : $url->add('v', hash(
- 'md5',
- $GLOBALS['registry']->getVersion($this->app))
- );
+ : $url->add(
+ 'v',
+ hash(
+ 'md5',
+ $GLOBALS['registry']->getVersion($this->app)
+ )
+ );
}
}
diff --git a/lib/Horde/Script/File/External.php b/lib/Horde/Script/File/External.php
index fdd5fc46e..8c802af82 100644
--- a/lib/Horde/Script/File/External.php
+++ b/lib/Horde/Script/File/External.php
@@ -1,4 +1,5 @@
_url);
+ case 'hash':
+ return hash('md5', $this->_url);
- case 'modified':
- return 0;
+ case 'modified':
+ return 0;
- case 'path':
- return null;
+ case 'path':
+ return null;
- case 'url':
- case 'url_full':
- return $this->_url;
+ case 'url':
+ case 'url_full':
+ return $this->_url;
}
return parent::__get($name);
diff --git a/lib/Horde/Script/File/JsDir.php b/lib/Horde/Script/File/JsDir.php
index 22a476962..d838736af 100644
--- a/lib/Horde/Script/File/JsDir.php
+++ b/lib/Horde/Script/File/JsDir.php
@@ -1,4 +1,5 @@
get('jsfs', $this->_app) . '/';
+ case 'path':
+ return $GLOBALS['registry']->get('jsfs', $this->_app) . '/';
- case 'uncompressed':
- if (($pos = strripos($this->file, '.min.js')) !== false) {
- $cname = get_class();
- return new $cname(
- substr($this->file, 0, $pos) . '.js',
- $this->app
- );
- }
- break;
+ case 'uncompressed':
+ if (($pos = strripos($this->file, '.min.js')) !== false) {
+ $cname = get_class();
+ return new $cname(
+ substr($this->file, 0, $pos) . '.js',
+ $this->app
+ );
+ }
+ break;
- case 'url':
- case 'url_full':
- return $this->_url($GLOBALS['registry']->get('jsuri', $this->_app) . '/' . $this->_file, ($name == 'url_full'));
+ case 'url':
+ case 'url_full':
+ return $this->_url($GLOBALS['registry']->get('jsuri', $this->_app) . '/' . $this->_file, ($name == 'url_full'));
}
return parent::__get($name);
diff --git a/lib/Horde/Script/File/JsFramework.php b/lib/Horde/Script/File/JsFramework.php
index a8b846068..a72e8a14d 100644
--- a/lib/Horde/Script/File/JsFramework.php
+++ b/lib/Horde/Script/File/JsFramework.php
@@ -1,4 +1,5 @@
_files = array();
+ $this->_files = [];
}
/* Countable methods. */
@@ -98,7 +99,7 @@ public function next()
#[\ReturnTypeWillChange]
public function rewind()
{
- $files = array();
+ $files = [];
foreach ($this->_files as $val) {
$files[$val->priority][] = $val;
@@ -106,7 +107,7 @@ public function rewind()
ksort($files);
- $this->_tmp = array();
+ $this->_tmp = [];
foreach ($files as $val) {
$this->_tmp = array_merge($this->_tmp, $val);
}
diff --git a/lib/Horde/Script/Package.php b/lib/Horde/Script/Package.php
index 3b04dea18..d7838a8e7 100644
--- a/lib/Horde/Script/Package.php
+++ b/lib/Horde/Script/Package.php
@@ -1,4 +1,5 @@
_data = &$_SESSION;
}
@@ -111,18 +112,18 @@ public function __construct()
public function __get($name)
{
switch ($name) {
- case 'begin':
- return ($this->_active || $this->_relogin)
- ? $this->_data[self::BEGIN]
- : 0;
-
- case 'regenerate_due':
- return (isset($this->_data[self::REGENERATE]) &&
- (time() >= $this->_data[self::REGENERATE]));
-
- case 'regenerate_interval':
- // DEFAULT: 6 hours
- return 21600;
+ case 'begin':
+ return ($this->_active || $this->_relogin)
+ ? $this->_data[self::BEGIN]
+ : 0;
+
+ case 'regenerate_due':
+ return (isset($this->_data[self::REGENERATE]) &&
+ (time() >= $this->_data[self::REGENERATE]));
+
+ case 'regenerate_interval':
+ // DEFAULT: 6 hours
+ return 21600;
}
}
@@ -131,9 +132,9 @@ public function __get($name)
public function __set($name, $value)
{
switch ($name) {
- case 'session_data':
- $this->_data = &$value;
- break;
+ case 'session_data':
+ $this->_data = &$value;
+ break;
}
}
@@ -147,9 +148,11 @@ public function __set($name, $value)
*
* @throws Horde_Exception
*/
- public function setup($start = true, $cache_limiter = null,
- $session_id = null)
- {
+ public function setup(
+ $start = true,
+ $cache_limiter = null,
+ $session_id = null
+ ) {
global $conf, $injector;
ini_set('url_rewriter.tags', 0);
@@ -237,7 +240,7 @@ private function _start()
public function regenerate()
{
/* Load old encrypted data. */
- $encrypted = array();
+ $encrypted = [];
if (!empty($this->_data[self::ENCRYPTED])) {
foreach ($this->_data[self::ENCRYPTED] as $app => $val) {
foreach (array_keys($val) as $val2) {
@@ -276,7 +279,7 @@ public function clean()
// session data.
session_regenerate_id(true);
session_unset();
- $this->_data = array();
+ $this->_data = [];
$this->_start();
$GLOBALS['injector']->getInstance('Horde_Secret_Cbc')->setKey();
@@ -372,7 +375,7 @@ public function get($app, $name, $mask = 0)
}
if ($subkeys = $this->_subkeys($app, $name)) {
- $ret = array();
+ $ret = [];
foreach ($subkeys as $k => $v) {
$ret[$k] = $this->get($app, $v, $mask);
}
@@ -385,11 +388,11 @@ public function get($app, $name, $mask = 0)
}
switch ($mask) {
- case self::TYPE_ARRAY:
- return array();
+ case self::TYPE_ARRAY:
+ return [];
- case self::TYPE_OBJECT:
- return new stdClass;
+ case self::TYPE_OBJECT:
+ return new stdClass();
}
return null;
@@ -425,7 +428,7 @@ public function set($app, $name, $value, $mask = 0)
if (($mask & self::ENCRYPT) ||
is_object($value) || ($mask & self::TYPE_OBJECT) ||
is_array($value) || ($mask & self::TYPE_ARRAY)) {
- $opts = array('compress' => 0);
+ $opts = ['compress' => 0];
if (is_object($value) || ($mask & self::TYPE_OBJECT)) {
$opts['phpob'] = true;
}
@@ -498,7 +501,7 @@ private function _getKey($app, $name)
*/
private function _subkeys($app, $name)
{
- $ret = array();
+ $ret = [];
if ($name &&
isset($this->_data[$app]) &&
@@ -588,7 +591,7 @@ public function checkNonce($nonce)
/* Session object storage. */
/** @deprecated */
- const DATA = '_d';
+ public const DATA = '_d';
/**
* @deprecated Use Horde_Core_Cache_SessionObjects instead.
@@ -617,7 +620,8 @@ public function retrieve($id)
$ob = new Horde_Core_Cache_SessionObjects();
try {
return $injector->getInstance('Horde_Pack')->unpack($ob->get($id));
- } catch (Horde_Pack_Exception $e) {}
+ } catch (Horde_Pack_Exception $e) {
+ }
return null;
}
diff --git a/lib/Horde/Session/Null.php b/lib/Horde/Session/Null.php
index e732ddcec..51a5cb6a8 100644
--- a/lib/Horde/Session/Null.php
+++ b/lib/Horde/Session/Null.php
@@ -1,4 +1,5 @@
_data = array();
+ $this->_data = [];
}
/**
@@ -44,9 +45,11 @@ public function shutdown()
/**
*/
- public function setup($start = true, $cache_limiter = null,
- $session_id = null)
- {
+ public function setup(
+ $start = true,
+ $cache_limiter = null,
+ $session_id = null
+ ) {
global $conf;
// Set this here, since we actually do start a php session. Even though
@@ -120,7 +123,7 @@ public function close()
public function destroy()
{
session_unset();
- $this->_data = array();
+ $this->_data = [];
$this->_cleansession = true;
}
diff --git a/lib/Horde/Shutdown.php b/lib/Horde/Shutdown.php
index b7e8c00d8..bec5097e3 100644
--- a/lib/Horde/Shutdown.php
+++ b/lib/Horde/Shutdown.php
@@ -1,4 +1,5 @@
_tasks as $val) {
try {
$val->shutdown();
- } catch (Exception $e) {}
+ } catch (Exception $e) {
+ }
}
}
diff --git a/lib/Horde/Shutdown/Task.php b/lib/Horde/Shutdown/Task.php
index 4de5dbaf7..dfc240739 100644
--- a/lib/Horde/Shutdown/Task.php
+++ b/lib/Horde/Shutdown/Task.php
@@ -1,4 +1,5 @@
$options);
+ $options = ['app' => $options];
}
return new Horde_Themes_Image($name, $options);
@@ -67,10 +68,10 @@ public static function img($name = null, $options = array())
* @return Horde_Themes_Sound An object which contains the URI
* and filesystem location of the sound.
*/
- public static function sound($name = null, $options = array())
+ public static function sound($name = null, $options = [])
{
if (is_string($options)) {
- $options = array('app' => $options);
+ $options = ['app' => $options];
}
return new Horde_Themes_Sound($name, $options);
@@ -84,7 +85,7 @@ public static function sound($name = null, $options = array())
*/
public static function themeList()
{
- $out = array();
+ $out = [];
// Throws UnexpectedValueException
$di = new DirectoryIterator($GLOBALS['registry']->get('themesfs', 'horde'));
@@ -125,7 +126,7 @@ public static function soundList($app = null, $theme = null)
$cache = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($app, $theme);
- $sounds = array();
+ $sounds = [];
foreach ($cache->build() as $val) {
if ((strpos($val, 'sounds/') === 0) &&
(substr(strrchr($val, '.'), 1) == 'wav')) {
@@ -146,7 +147,7 @@ public static function soundList($app = null, $theme = null)
*/
public static function getFeedXsl()
{
- return $GLOBALS['registry']->get('themesuri', 'horde') . '/default/feed-rss.xsl';
+ return $GLOBALS['registry']->get('themesuri', 'horde') . '/default/feed-rss.xsl';
}
/**
@@ -163,20 +164,20 @@ public static function viewDir($view)
global $registry;
switch ($view) {
- case $registry::VIEW_BASIC:
- return 'basic';
+ case $registry::VIEW_BASIC:
+ return 'basic';
- case $registry::VIEW_DYNAMIC:
- return 'dynamic';
+ case $registry::VIEW_DYNAMIC:
+ return 'dynamic';
- case $registry::VIEW_MINIMAL:
- return 'minimal';
+ case $registry::VIEW_MINIMAL:
+ return 'minimal';
- case $registry::VIEW_SMARTMOBILE:
- return 'smartmobile';
+ case $registry::VIEW_SMARTMOBILE:
+ return 'smartmobile';
- default:
- return null;
+ default:
+ return null;
}
}
diff --git a/lib/Horde/Themes/Cache.php b/lib/Horde/Themes/Cache.php
index 42e520c43..5d020e859 100644
--- a/lib/Horde/Themes/Cache.php
+++ b/lib/Horde/Themes/Cache.php
@@ -1,4 +1,5 @@
_complete) {
- $this->_data = array();
+ $this->_data = [];
$this->_build('horde', 'default', self::HORDE_DEFAULT);
$this->_build('horde', $this->_theme, self::HORDE_THEME);
@@ -213,11 +214,11 @@ protected function _get($item)
*/
protected function _getOutput($app, $theme, $item)
{
- return array(
+ return [
'app' => $app,
'fs' => $GLOBALS['registry']->get('themesfs', $app) . '/' . $theme . '/' . $item,
- 'uri' => $GLOBALS['registry']->get('themesuri', $app) . '/' . $theme . '/' . $item
- );
+ 'uri' => $GLOBALS['registry']->get('themesuri', $app) . '/' . $theme . '/' . $item,
+ ];
}
/**
@@ -225,13 +226,13 @@ protected function _getOutput($app, $theme, $item)
public function getAll($item, $mask = 0)
{
if (!($entry = $this->_get($item))) {
- return array();
+ return [];
}
if ($mask) {
$entry &= $mask;
}
- $out = array();
+ $out = [];
if ($entry & self::APP_THEME) {
$out[] = $this->_getOutput($this->_app, $this->_theme, $item);
@@ -256,23 +257,22 @@ public function getCacheId()
global $conf, $registry;
if (!isset($this->_cacheid)) {
- $check = isset($conf['cachethemesparams']['check'])
- ? $conf['cachethemesparams']['check']
- : null;
+ $check = $conf['cachethemesparams']['check']
+ ?? null;
switch ($check) {
- case 'appversion':
- default:
- $id = array($registry->getVersion($this->_app));
- if ($this->_app != 'horde') {
- $id[] = $registry->getVersion('horde');
- }
- $this->_cacheid = 'v:' . implode('|', $id);
- break;
-
- case 'none':
- $this->_cacheid = '';
- break;
+ case 'appversion':
+ default:
+ $id = [$registry->getVersion($this->_app)];
+ if ($this->_app != 'horde') {
+ $id[] = $registry->getVersion('horde');
+ }
+ $this->_cacheid = 'v:' . implode('|', $id);
+ break;
+
+ case 'none':
+ $this->_cacheid = '';
+ break;
}
}
@@ -290,14 +290,14 @@ public function serialize()
public function __serialize(): array
{
- return array(
+ return [
'a' => $this->_app,
'c' => $this->_complete,
'd' => $this->_data,
'id' => $this->getCacheId(),
- 't' => $this->_theme
- );
-
+ 't' => $this->_theme,
+ ];
+
}
public function __unserialize(array $data): void
@@ -305,16 +305,16 @@ public function __unserialize(array $data): void
// Needed to generate cache ID.
if (isset($data['a'])) {
- $this->_app = $data['a'];
+ $this->_app = $data['a'];
}
if (isset($data['id']) && ($data['id'] != $this->getCacheId())) {
- throw new Exception('Cache invalidated for ' . $data['a'] . ': ' . $data['id'] . " != ".$this->getCacheId());
+ throw new Exception('Cache invalidated for ' . $data['a'] . ': ' . $data['id'] . ' != '.$this->getCacheId());
}
$this->_complete = $data['c'];
$this->_data = $data['d'];
- $this->_theme = $data['t'];
+ $this->_theme = $data['t'];
}
/**
*/
diff --git a/lib/Horde/Themes/Css.php b/lib/Horde/Themes/Css.php
index 90e62b98d..ddc9c563d 100644
--- a/lib/Horde/Themes/Css.php
+++ b/lib/Horde/Themes/Css.php
@@ -1,4 +1,5 @@
getValue('theme');
+ $theme = $opts['theme']
+ ?? $prefs->getValue('theme');
$css = $this->getStylesheets($theme, $opts);
if (!count($css)) {
- return array();
+ return [];
}
$cache_ob = empty($opts['nocache'])
@@ -127,7 +127,7 @@ public function getStylesheetUrls(array $opts = array())
* - uri: (string) URI of stylesheet.
*
*/
- public function getStylesheets($theme = '', array $opts = array())
+ public function getStylesheets($theme = '', array $opts = [])
{
global $injector, $prefs, $registry;
@@ -135,10 +135,10 @@ public function getStylesheets($theme = '', array $opts = array())
$theme = $prefs->getValue('theme');
}
- $add_css = $css_out = array();
+ $add_css = $css_out = [];
$css_list = empty($opts['nobase'])
? $this->getBaseStylesheetList()
- : array();
+ : [];
$css_list = array_unique(array_merge($css_list, array_keys($this->_cssThemeFiles)));
@@ -159,11 +159,11 @@ public function getStylesheets($theme = '', array $opts = array())
* by Horde code. */
foreach ($this->_cssFiles as $f => $u) {
if (file_exists($f)) {
- $css_out[] = array(
+ $css_out[] = [
'app' => null,
'fs' => $f,
- 'uri' => $u
- );
+ 'uri' => $u,
+ ];
}
}
@@ -181,21 +181,23 @@ public function getStylesheets($theme = '', array $opts = array())
/* Add user-defined additional stylesheets. */
$hooks = $injector->getInstance('Horde_Core_Hooks');
try {
- $add_css = array_merge($add_css, $hooks->callHook('cssfiles', 'horde', array($theme)));
- } catch (Horde_Exception_HookNotSet $e) {}
+ $add_css = array_merge($add_css, $hooks->callHook('cssfiles', 'horde', [$theme]));
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
if ($curr_app != 'horde') {
try {
- $add_css = array_merge($add_css, $hooks->callHook('cssfiles', $curr_app, array($theme)));
- } catch (Horde_Exception_HookNotSet $e) {}
+ $add_css = array_merge($add_css, $hooks->callHook('cssfiles', $curr_app, [$theme]));
+ } catch (Horde_Exception_HookNotSet $e) {
+ }
}
foreach ($add_css as $f => $u) {
- $css_out[] = array(
+ $css_out[] = [
'app' => $curr_app,
'fs' => $f,
- 'uri' => $u
- );
+ 'uri' => $u,
+ ];
}
return $css_out;
@@ -209,7 +211,7 @@ public function getStylesheets($theme = '', array $opts = array())
*/
public function getBaseStylesheetList()
{
- $css_list = array('screen.css');
+ $css_list = ['screen.css'];
if ($GLOBALS['registry']->nlsconfig->curr_rtl) {
$css_list[] = 'rtl.css';
@@ -217,23 +219,23 @@ public function getBaseStylesheetList()
/* Collect browser specific stylesheets if needed. */
switch ($GLOBALS['browser']->getBrowser()) {
- case 'msie':
- $ie_major = $GLOBALS['browser']->getMajor();
- if ($ie_major == 8) {
- $css_list[] = 'ie8.css';
- }
- break;
+ case 'msie':
+ $ie_major = $GLOBALS['browser']->getMajor();
+ if ($ie_major == 8) {
+ $css_list[] = 'ie8.css';
+ }
+ break;
- case 'opera':
- $css_list[] = 'opera.css';
- break;
+ case 'opera':
+ $css_list[] = 'opera.css';
+ break;
- case 'mozilla':
- $css_list[] = 'mozilla.css';
- break;
+ case 'mozilla':
+ $css_list[] = 'mozilla.css';
+ break;
- case 'webkit':
- $css_list[] = 'webkit.css';
+ case 'webkit':
+ $css_list[] = 'webkit.css';
}
return $css_list;
diff --git a/lib/Horde/Themes/Css/Cache.php b/lib/Horde/Themes/Css/Cache.php
index 7c5e0bc19..03a070d36 100644
--- a/lib/Horde/Themes/Css/Cache.php
+++ b/lib/Horde/Themes/Css/Cache.php
@@ -1,4 +1,5 @@
_params = $params;
if (!rand(0, 999)) {
diff --git a/lib/Horde/Themes/Css/Cache/File.php b/lib/Horde/Themes/Css/Cache/File.php
index 0d6c2ac87..03e96d41d 100644
--- a/lib/Horde/Themes/Css/Cache/File.php
+++ b/lib/Horde/Themes/Css/Cache/File.php
@@ -1,4 +1,5 @@
compress($css), LOCK_EX) ||
- !chmod($temp, 0777 & ~umask()) ||
+ !chmod($temp, 0o777 & ~umask()) ||
!rename($temp, $path)) {
Horde::log('Could not write cached CSS file to disk.', 'EMERG');
- return array();
+ return [];
}
}
- return array(
- Horde::url($registry->get('staticuri', 'horde') . '/' . $filename, true, array('append_session' => -1))
- );
+ return [
+ Horde::url($registry->get('staticuri', 'horde') . '/' . $filename, true, ['append_session' => -1]),
+ ];
}
/**
diff --git a/lib/Horde/Themes/Css/Cache/HordeCache.php b/lib/Horde/Themes/Css/Cache/HordeCache.php
index 74b4806ee..920535c25 100644
--- a/lib/Horde/Themes/Css/Cache/HordeCache.php
+++ b/lib/Horde/Themes/Css/Cache/HordeCache.php
@@ -1,4 +1,5 @@
set($sig, $compress->compress($css));
}
- return array(
- Horde::getCacheUrl('css', array('cid' => $sig))
- );
+ return [
+ Horde::getCacheUrl('css', ['cid' => $sig]),
+ ];
}
}
diff --git a/lib/Horde/Themes/Css/Cache/Null.php b/lib/Horde/Themes/Css/Cache/Null.php
index 58186774c..63424110e 100644
--- a/lib/Horde/Themes/Css/Cache/Null.php
+++ b/lib/Horde/Themes/Css/Cache/Null.php
@@ -1,4 +1,5 @@
(empty($conf['nobase64_img']) && $browser->hasFeature('dataurl')) ? array($this, 'dataurlCallback') : null,
- 'import' => array($this, 'importCallback'),
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- ));
+ $parser = new Horde_CssMinify_CssParser($files, [
+ 'dataurl' => (empty($conf['nobase64_img']) && $browser->hasFeature('dataurl')) ? [$this, 'dataurlCallback'] : null,
+ 'import' => [$this, 'importCallback'],
+ 'logger' => $injector->getInstance('Horde_Log_Logger'),
+ ]);
return $parser->minify();
}
@@ -62,7 +63,7 @@ public function dataurlCallback($uri)
public function importCallback($uri)
{
$ob = Horde_Themes_Element::fromUri($uri);
- return array($ob->uri, $ob->fs);
+ return [$ob->uri, $ob->fs];
}
}
diff --git a/lib/Horde/Themes/Element.php b/lib/Horde/Themes/Element.php
index 3cd31a99f..3b031bad0 100644
--- a/lib/Horde/Themes/Element.php
+++ b/lib/Horde/Themes/Element.php
@@ -1,4 +1,5 @@
app = empty($options['app'])
? $GLOBALS['registry']->getApp()
@@ -123,10 +124,10 @@ public function __get($name)
if (is_null($this->_name)) {
/* Return directory only. */
- $this->_data = array(
+ $this->_data = [
'fs' => $registry->get('themesfs', $this->app) . '/' . $theme . '/' . $this->_dirname,
- 'uri' => $registry->get('themesuri', $this->app) . '/' . $theme . '/' . $this->_dirname
- );
+ 'uri' => $registry->get('themesuri', $this->app) . '/' . $theme . '/' . $this->_dirname,
+ ];
} else {
$cache = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($this->app, $theme);
$mask = empty($this->_opts['nohorde'])
@@ -144,15 +145,15 @@ public function __get($name)
return null;
}
switch ($name) {
- case 'fs':
- case 'uri':
- return $this->_data[$name];
+ case 'fs':
+ case 'uri':
+ return $this->_data[$name];
- case 'fulluri':
- return Horde::url($this->_data['uri'], true);
+ case 'fulluri':
+ return Horde::url($this->_data['uri'], true);
- default:
- return null;
+ default:
+ return null;
}
}
@@ -167,12 +168,12 @@ public static function fromUri($uri)
{
global $registry;
- return new self('', array(
- 'data' => array(
+ return new self('', [
+ 'data' => [
'fs' => realpath($registry->get('fileroot', 'horde')) . preg_replace('/^' . preg_quote($registry->get('webroot', 'horde'), '/') . '/', '', $uri),
- 'uri' => $uri
- )
- ));
+ 'uri' => $uri,
+ ],
+ ]);
}
}
diff --git a/lib/Horde/Themes/Image.php b/lib/Horde/Themes/Image.php
index eba4f86a9..5862ce097 100644
--- a/lib/Horde/Themes/Image.php
+++ b/lib/Horde/Themes/Image.php
@@ -1,4 +1,5 @@
'',
- 'attr' => array(),
+ 'attr' => [],
'fullsrc' => false,
- 'imgopts' => array()
- ), $opts);
+ 'imgopts' => [],
+ ], $opts);
/* If browser does not support images, simply return the ALT text. */
if (!$browser->hasFeature('images')) {
@@ -99,7 +100,7 @@ public static function tag($src, array $opts = array())
$src = self::base64ImgData($src);
}
if ($opts['fullsrc'] && (substr($src, 0, 10) != 'data:image')) {
- $src = Horde::url($src, true, array('append_session' => -1));
+ $src = Horde::url($src, true, ['append_session' => -1]);
}
$img->addAttribute('src', $src);
diff --git a/lib/Horde/Themes/Sound.php b/lib/Horde/Themes/Sound.php
index f4e625a85..d0e902e7c 100644
--- a/lib/Horde/Themes/Sound.php
+++ b/lib/Horde/Themes/Sound.php
@@ -1,4 +1,5 @@
conf = $conf ?? $GLOBALS['conf'] ?? null;
// If we still have no array, give up.
diff --git a/src/Factory/LogHandlerFactory.php b/src/Factory/LogHandlerFactory.php
index e1818788d..f25ae837b 100644
--- a/src/Factory/LogHandlerFactory.php
+++ b/src/Factory/LogHandlerFactory.php
@@ -1,4 +1,5 @@
$conf['log']['params']['template']]);
+ case 'file':
+ case 'stream':
+ // TODO: Default context?
+
+ $append = ($conf['log']['type'] == 'file')
+ ? ($conf['log']['params']['append'] ? 'a+' : 'w+')
+ : null;
+ $format = $conf['log']['params']['format']
+ ?? 'default';
+
+ switch ($format) {
+ case 'custom':
+ $formatters[] = new SimpleFormatter(['format' => $conf['log']['params']['template']]);
+ break;
+
+ case 'default':
+ default:
+ // Use Horde_Log defaults.
+ break;
+
+ case 'xml':
+ $formatters[] = new XmlFormatter();
+ break;
+ }
+
+ $options = new Options();
+ $options->ident = (string) $conf['log']['ident'] ?? '';
+ // Let's not try and catch. Let it fail, the caller should care
+ $handler = new StreamHandler($conf['log']['name'], $append, $options, $formatters);
break;
- case 'default':
- default:
- // Use Horde_Log defaults.
+ case 'syslog':
+ $options = new SyslogOptions();
+ if (!empty($conf['log']['name'] && is_numeric($conf['log']['name']))) {
+ $options->facility = (int) $conf['log']['name'];
+ }
+ if (!empty($conf['log']['ident'])) {
+ $options->ident = (string) $conf['log']['ident'];
+ }
+ $handler = new SyslogHandler($options, $formatters, []);
break;
- case 'xml':
- $formatters[] = new XmlFormatter();
- break;
- }
-
- $options = new Options();
- $options->ident = (string) $conf['log']['ident'] ?? '';
- // Let's not try and catch. Let it fail, the caller should care
- $handler = new StreamHandler($conf['log']['name'], $append, $options, $formatters);
- break;
-
- case 'syslog':
- $options = new SyslogOptions();
- if (!empty($conf['log']['name'] && is_numeric($conf['log']['name']))) {
- $options->facility = (int) $conf['log']['name'];
- }
- if (!empty($conf['log']['ident'])) {
- $options->ident = (string) $conf['log']['ident'];
- }
- $handler = new SyslogHandler($options, $formatters, []);
- break;
-
- case 'null':
- default:
- // Use default null handler.
- return new NullHandler();
+ case 'null':
+ default:
+ // Use default null handler.
+ return new NullHandler();
}
switch ($conf['log']['priority']) {
- case 'WARNING':
- // Bug #12109
- $priority = 'WARN';
- break;
-
- default:
- $priority = defined('Horde_Log::' . $conf['log']['priority'])
- ? $conf['log']['priority']
- : 'NOTICE';
- break;
+ case 'WARNING':
+ // Bug #12109
+ $priority = 'WARN';
+ break;
+
+ default:
+ $priority = defined('Horde_Log::' . $conf['log']['priority'])
+ ? $conf['log']['priority']
+ : 'NOTICE';
+ break;
}
$handler->addFilter(new MaximumLevelFilter(constant('Horde_Log::' . $priority)));
return $handler;
@@ -134,7 +135,7 @@ public function createNullHandler(): NullHandler
return new NullHandler();
}
- public function createStreamHandler($streamOrUrl, string $mode = 'a+', array $formatters = null, array $filters = []): StreamHandler
+ public function createStreamHandler($streamOrUrl, string $mode = 'a+', ?array $formatters = null, array $filters = []): StreamHandler
{
$options = new Options();
$handler = new StreamHandler($streamOrUrl, $mode, $options, $formatters);
diff --git a/src/Factory/LoggerFactory.php b/src/Factory/LoggerFactory.php
index ce0cb95ea..dfeafbbd1 100644
--- a/src/Factory/LoggerFactory.php
+++ b/src/Factory/LoggerFactory.php
@@ -1,4 +1,5 @@
registry->isAdmin();
- $acceptsJson = in_array('application/json', array_map(fn($val) => strtolower($val), $request->getHeader('Accept')));
- if ($acceptsJson){
+ $acceptsJson = in_array('application/json', array_map(fn ($val) => strtolower($val), $request->getHeader('Accept')));
+ if ($acceptsJson) {
return $this->getJsonResponse($throwable, $isAdmin);
} else {
return $this->getHtmlResponse($throwable, $isAdmin);
diff --git a/src/Middleware/RedirectToLogin.php b/src/Middleware/RedirectToLogin.php
index 5fbed16bd..c031d0e4d 100644
--- a/src/Middleware/RedirectToLogin.php
+++ b/src/Middleware/RedirectToLogin.php
@@ -59,7 +59,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
// set baseurl: if no alternative login, use Horde login as baseurl
$baseUrl = $this->registry->getServiceLink('login');
};
-
+
$redirectUrl = (string) Horde::Url($baseUrl, true)->add('url', $signedRequestUrl);
return $this->responseFactory->createResponse(302)->withHeader('Location', $redirectUrl);