Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2018 John Molakvoæ <[email protected]>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author John Molakvoæ <[email protected]>
* @author Matthias Heinisch <[email protected]>
Expand Down Expand Up @@ -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');

Expand Down
7 changes: 4 additions & 3 deletions lib/Cron/SocialUpdateRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* @copyright 2017 Georg Ehrke <[email protected]>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triple copyright and no https? 😛

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* @author Georg Ehrke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 8 additions & 6 deletions lib/Service/SocialApiService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2020 Matthias Heinisch <[email protected]>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Matthias Heinisch <[email protected]>
*
Expand Down Expand Up @@ -89,8 +90,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();
Expand Down Expand Up @@ -364,10 +366,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);
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/AppNavigation/SettingsSection.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
- @copyright Copyright (c) 2018 John Molakvoæ <[email protected]>
- @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
-
- @author John Molakvoæ <[email protected]>
- @author Matthias Heinisch <[email protected]>
Expand All @@ -24,7 +25,7 @@
<template>
<div>
<SettingsSortContacts class="settings-section" />
<CheckboxRadioSwitch :checked="enableSocialSync"
<CheckboxRadioSwitch v-if="allowSocialSync" :checked="enableSocialSync"
:loading="enableSocialSyncLoading"
:disabled="enableSocialSyncLoading"
class="social-sync__checkbox"
Expand Down