diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index fcfee915e..00db59dff 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -1,6 +1,7 @@ + * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author John Molakvoæ * @author Matthias Heinisch @@ -96,8 +97,9 @@ public function index(): TemplateResponse { $defaultProfile = $this->config->getAppValue(Application::APP_ID, 'defaultProfile', 'HOME'); $supportedNetworks = $this->socialApiService->getSupportedNetworks(); - // allow users to retrieve avatars from social networks (default: yes) - $syncAllowedByAdmin = $this->config->getAppValue(Application::APP_ID, 'allowSocialSync', 'yes'); + // Allow users to retrieve avatars from social networks (default: yes). Disabled if internet connection is not available. + $syncAllowedByAdmin = (($this->config->getAppValue(Application::APP_ID, 'allowSocialSync', 'yes') === 'yes') + && $this->config->getSystemValueBool('has_internet_connection', true)) ? 'yes' : 'no'; // automated background syncs for social avatars (default: no) $bgSyncEnabledByUser = $this->config->getUserValue($userId, Application::APP_ID, 'enableSocialSync', 'no'); diff --git a/lib/Cron/SocialUpdateRegistration.php b/lib/Cron/SocialUpdateRegistration.php index da8f24c0d..70024e933 100644 --- a/lib/Cron/SocialUpdateRegistration.php +++ b/lib/Cron/SocialUpdateRegistration.php @@ -4,6 +4,7 @@ /** * @copyright 2017 Georg Ehrke + * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author Georg Ehrke * @author Roeland Jago Douma @@ -84,9 +85,9 @@ public function __construct( */ protected function run($arguments) { - // check if admin allows for social updates: - $syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); - if (!($syncAllowedByAdmin === 'yes')) { + // Social updates must be enabled by admin and internet connection must be available. + if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') + || !$this->config->getSystemValueBool('has_internet_connection', true)) { return; } diff --git a/lib/Service/SocialApiService.php b/lib/Service/SocialApiService.php index 26a9adb22..633e6a862 100644 --- a/lib/Service/SocialApiService.php +++ b/lib/Service/SocialApiService.php @@ -4,6 +4,7 @@ /** * @copyright Copyright (c) 2020 Matthias Heinisch + * @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/ * * @author Matthias Heinisch * @@ -92,8 +93,9 @@ public function __construct( * @return {array} array of the supported social networks */ public function getSupportedNetworks() : array { - $syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); - if ($syncAllowedByAdmin !== 'yes') { + // Check if admin allows for social updates and internet connection is available. + if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') + || !$this->config->getSystemValueBool('has_internet_connection', true)) { return []; } return $this->socialProvider->getSupportedNetworks(); @@ -369,10 +371,10 @@ protected function sortContacts(array $a, array $b) { */ public function updateAddressbooks(string $userId, string $offsetBook = null, string $offsetContact = null, string $network = null) : JSONResponse { - // double check! - $syncAllowedByAdmin = $this->config->getAppValue($this->appName, 'allowSocialSync', 'yes'); - $bgSyncEnabledByUser = $this->config->getUserValue($userId, $this->appName, 'enableSocialSync', 'no'); - if (($syncAllowedByAdmin !== 'yes') || ($bgSyncEnabledByUser !== 'yes')) { + // Forbid if social sync is disabled by admin or by user or no internet connection is available. + if (($this->config->getAppValue($this->appName, 'allowSocialSync', 'yes') !== 'yes') + || ($this->config->getUserValue($userId, $this->appName, 'enableSocialSync', 'no') !== 'yes') + || !$this->config->getSystemValueBool('has_internet_connection', true)) { return new JSONResponse([], Http::STATUS_FORBIDDEN); } diff --git a/src/components/AppNavigation/ContactsSettings.vue b/src/components/AppNavigation/ContactsSettings.vue index 9cb402f67..d490ef2cd 100644 --- a/src/components/AppNavigation/ContactsSettings.vue +++ b/src/components/AppNavigation/ContactsSettings.vue @@ -1,5 +1,6 @@