From 46379113a118e8c4c8ed26026f2d2a610380a368 Mon Sep 17 00:00:00 2001 From: Philipp Kapfer Date: Thu, 30 May 2013 17:37:47 +0200 Subject: [PATCH] Changed dependency check messages from warnings to notes Added check for duplicate dependency check messages to display only the first --- apps/files_external/lib/config.php | 41 +++++++++++++++++++++++++++--- apps/files_external/lib/ftp.php | 2 +- apps/files_external/lib/google.php | 2 +- apps/files_external/lib/smb.php | 2 +- apps/files_external/lib/webdav.php | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index ebc83c7af84..2112266efc4 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -524,17 +524,50 @@ class OC_Mount_Config { * check dependencies */ public static function checkDependencies() { - $txt=''; + $dependencyMessages = array(); foreach (OC_Mount_Config::$backends as $class => $backend) { if (isset($backend['has_dependencies']) and $backend['has_dependencies'] === true) { $result = $class::checkDependencies(); - if ($result !== true) { - $txt.=$result.'
'; + if ($result !== true and OC_Mount_Config::findFirstSentence($dependencyMessages, $result) < 0) { + $dependencyMessages[] = $result; } } } - return $txt; + if (count($dependencyMessages) > 0) { + return implode('
', $dependencyMessages); + } + return ''; + } + + /** + * Finds the first string in an array that has the same first sentence (or part thereof) + * as a given comparison string + * @param $arr array An array of strings + * @param $str string The string to find + * @return int The position of the first occurrence or -1 if not found + */ + private static function findFirstSentence($arr, $str) { + foreach ($arr as $i => $item) { + $itemPos = strpos($item, '.'); + $strPos = strpos($str, '.'); + + if ($itemPos < 0 && $strPos < 0) { + $itemPos = strpos($item, ','); + $strPos = strpos($str, ','); + + if ($itemPos < 0 && $strPos < 0) { + $itemPos = strlen($item); + $strPos = strlen($str); + } + } + + if ($itemPos === $strPos and strncasecmp($item, $str, $itemPos) === 0) { + return $i; + } + } + + return -1; } /** diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 43635f7f94e..a6a775ff6d1 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -25,7 +25,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ return(true); } else { $l = new \OC_L10N('files_external'); - return $l->t('Warning: The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it.'); + return $l->t('Note: The FTP support in PHP is not enabled or installed. Mounting of FTP shares is not possible. Please ask your system administrator to install it.'); } } diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 936153b35a5..cfb7005c4c7 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -49,7 +49,7 @@ class Google extends \OC\Files\Storage\Common { return true; } else { $l = new \OC_L10N('files_external'); - return $l->t('Warning: The cURL support in PHP is not enabled or installed. Mounting of Google Drive is not possible. Please ask your system administrator to install it.'); + return $l->t('Note: The cURL support in PHP is not enabled or installed. Mounting of Google Drive is not possible. Please ask your system administrator to install it.'); } } diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index bfe494e867e..6fb262323ff 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -28,7 +28,7 @@ class SMB extends \OC\Files\Storage\StreamWrapper{ } } $l = new \OC_L10N('files_external'); - return $l->t('Warning: "smbclient" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it.'); + return $l->t('Note: "smbclient" is not installed. Mounting of CIFS/SMB shares is not possible. Please ask your system administrator to install it.'); } public function __construct($params) { diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index ac6663133d0..0ea7a085041 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -31,7 +31,7 @@ class DAV extends \OC\Files\Storage\Common { return true; } else { $l = new \OC_L10N('files_external'); - return $l->t('Warning: The cURL support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV is not possible. Please ask your system administrator to install it.'); + return $l->t('Note: The cURL support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV is not possible. Please ask your system administrator to install it.'); } } -- 2.39.5