diff --git a/doc/themes.md b/doc/themes.md index 94e66d48d..577d6a5da 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -129,7 +129,7 @@ The selected 1st part will be saved in the database by the theme_post function. // if the one specific submit button was pressed then proceed if (isset($_POST['duepuntozero-settings-submit'])){ // and save the selection key into the personal config of the user - PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); + DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); } } diff --git a/mod/network.php b/mod/network.php index 51c3ccd9f..28d849e7a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -959,7 +959,7 @@ function network_tabs(App $a) // save selected tab, but only if not in file mode if (empty($_GET['file'])) { - PConfig::set(local_user(), 'network.view', 'tab.selected', [ + DI::pConfig()->set(local_user(), 'network.view', 'tab.selected', [ $all_active, $post_active, $conv_active, $new_active, $starred_active, $bookmarked_active ]); } diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 63b95da4b..c22572d97 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -50,7 +50,7 @@ function ostatus_subscribe_content(App $a) return $o . L10n::t('Couldn\'t fetch friends for contact.'); } - PConfig::set($uid, 'ostatus', 'legacy_friends', $curlResult->getBody()); + DI::pConfig()->set($uid, 'ostatus', 'legacy_friends', $curlResult->getBody()); } $friends = json_decode(DI::pConfig()->get($uid, 'ostatus', 'legacy_friends')); diff --git a/mod/profiles.php b/mod/profiles.php index 56552049d..9c394b33b 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -338,7 +338,7 @@ function profiles_post(App $a) { $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); - PConfig::set(local_user(), 'system', 'detailled_profile', !empty($_POST['detailed_profile']) ? 1: 0); + DI::pConfig()->set(local_user(), 'system', 'detailled_profile', !empty($_POST['detailed_profile']) ? 1: 0); $changes = []; if ($is_default) { diff --git a/mod/settings.php b/mod/settings.php index 976d7fa6d..2713b35df 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -233,13 +233,13 @@ function settings_post(App $a) BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors'); if (!empty($_POST['general-submit'])) { - PConfig::set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer'])); - PConfig::set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw'])); - PConfig::set(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); - PConfig::set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title'])); - PConfig::set(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); - PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']); - PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); + DI::pConfig()->set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer'])); + DI::pConfig()->set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw'])); + DI::pConfig()->set(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); + DI::pConfig()->set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title'])); + DI::pConfig()->set(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); + DI::pConfig()->set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']); + DI::pConfig()->set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); } elseif (!empty($_POST['imap-submit'])) { $mail_server = $_POST['mail_server'] ?? ''; $mail_port = $_POST['mail_port'] ?? ''; @@ -314,7 +314,7 @@ function settings_post(App $a) BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features'); foreach ($_POST as $k => $v) { if (strpos($k, 'feature_') === 0) { - PConfig::set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0)); + DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0)); } } info(L10n::t('Features updated') . EOL); @@ -352,20 +352,20 @@ function settings_post(App $a) } if ($mobile_theme !== '') { - PConfig::set(local_user(), 'system', 'mobile_theme', $mobile_theme); + DI::pConfig()->set(local_user(), 'system', 'mobile_theme', $mobile_theme); } - PConfig::set(local_user(), 'system', 'nowarn_insecure' , $nowarn_insecure); - PConfig::set(local_user(), 'system', 'update_interval' , $browser_update); - PConfig::set(local_user(), 'system', 'itemspage_network' , $itemspage_network); - PConfig::set(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network); - PConfig::set(local_user(), 'system', 'no_smilies' , $nosmile); - PConfig::set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week); - PConfig::set(local_user(), 'system', 'ignore_info' , $noinfo); - PConfig::set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll); - PConfig::set(local_user(), 'system', 'no_auto_update' , $no_auto_update); - PConfig::set(local_user(), 'system', 'bandwidth_saver' , $bandwidth_saver); - PConfig::set(local_user(), 'system', 'no_smart_threading' , $no_smart_threading); + DI::pConfig()->set(local_user(), 'system', 'nowarn_insecure' , $nowarn_insecure); + DI::pConfig()->set(local_user(), 'system', 'update_interval' , $browser_update); + DI::pConfig()->set(local_user(), 'system', 'itemspage_network' , $itemspage_network); + DI::pConfig()->set(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network); + DI::pConfig()->set(local_user(), 'system', 'no_smilies' , $nosmile); + DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week); + DI::pConfig()->set(local_user(), 'system', 'ignore_info' , $noinfo); + DI::pConfig()->set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll); + DI::pConfig()->set(local_user(), 'system', 'no_auto_update' , $no_auto_update); + DI::pConfig()->set(local_user(), 'system', 'bandwidth_saver' , $bandwidth_saver); + DI::pConfig()->set(local_user(), 'system', 'no_smart_threading' , $no_smart_threading); if (in_array($theme, Theme::getAllowedList())) { if ($theme == $a->user['theme']) { @@ -568,16 +568,16 @@ function settings_post(App $a) $str_group_deny = !empty($_POST['group_deny']) ? $aclFormatter->toString($_POST['group_deny']) : ''; $str_contact_deny = !empty($_POST['contact_deny']) ? $aclFormatter->toString($_POST['contact_deny']) : ''; - PConfig::set(local_user(), 'expire', 'items', $expire_items); - PConfig::set(local_user(), 'expire', 'notes', $expire_notes); - PConfig::set(local_user(), 'expire', 'starred', $expire_starred); - PConfig::set(local_user(), 'expire', 'photos', $expire_photos); - PConfig::set(local_user(), 'expire', 'network_only', $expire_network_only); + DI::pConfig()->set(local_user(), 'expire', 'items', $expire_items); + DI::pConfig()->set(local_user(), 'expire', 'notes', $expire_notes); + DI::pConfig()->set(local_user(), 'expire', 'starred', $expire_starred); + DI::pConfig()->set(local_user(), 'expire', 'photos', $expire_photos); + DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only); - PConfig::set(local_user(), 'system', 'suggestme', $suggestme); + DI::pConfig()->set(local_user(), 'system', 'suggestme', $suggestme); - PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly); - PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif); + DI::pConfig()->set(local_user(), 'system', 'email_textonly', $email_textonly); + DI::pConfig()->set(local_user(), 'system', 'detailed_notif', $detailed_notif); if ($page_flags == User::PAGE_FLAGS_PRVGROUP) { $hidewall = 1; diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index c096c178f..39a262d43 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -19,21 +19,6 @@ use Friendica\DI; */ class PConfig { - /** - * @brief Sets a configuration value for a user - * - * @param int $uid The user_id - * @param string $cat The category of the configuration value - * @param string $key The configuration key to set - * @param mixed $value The value to store - * - * @return bool Operation success - */ - public static function set(int $uid, string $cat, string $key, $value) - { - return DI::pConfig()->set($uid, $cat, $key, $value); - } - /** * @brief Deletes the given key from the users's configuration. * diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index fdacd2b2b..ae9bd944c 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -159,7 +159,7 @@ class UserImport } $newuid = self::lastInsertId(); - PConfig::set($newuid, 'system', 'previous_addr', $old_handle); + DI::pConfig()->set($newuid, 'system', 'previous_addr', $old_handle); foreach ($account['profile'] as &$profile) { foreach ($profile as $k => &$v) { diff --git a/src/Model/FileTag.php b/src/Model/FileTag.php index eecaf5063..f52bda0ad 100644 --- a/src/Model/FileTag.php +++ b/src/Model/FileTag.php @@ -223,12 +223,12 @@ class FileTag } if ($saved != $filetags_updated) { - PConfig::set($uid, 'system', 'filetags', $filetags_updated); + DI::pConfig()->set($uid, 'system', 'filetags', $filetags_updated); } return true; } elseif (strlen($file_new)) { - PConfig::set($uid, 'system', 'filetags', $file_new); + DI::pConfig()->set($uid, 'system', 'filetags', $file_new); } return true; @@ -260,7 +260,7 @@ class FileTag $saved = DI::pConfig()->get($uid, 'system', 'filetags'); if (!strlen($saved) || !stristr($saved, '[' . self::encode($file) . ']')) { - PConfig::set($uid, 'system', 'filetags', $saved . '[' . self::encode($file) . ']'); + DI::pConfig()->set($uid, 'system', 'filetags', $saved . '[' . self::encode($file) . ']'); } info(L10n::t('Item filed')); @@ -313,7 +313,7 @@ class FileTag if (!DBA::isResult($r)) { $saved = DI::pConfig()->get($uid, 'system', 'filetags'); - PConfig::set($uid, 'system', 'filetags', str_replace($pattern, '', $saved)); + DI::pConfig()->set($uid, 'system', 'filetags', str_replace($pattern, '', $saved)); } return true; diff --git a/src/Module/Invite.php b/src/Module/Invite.php index b56aaf5ae..c84795abb 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -69,7 +69,7 @@ class Invite extends BaseModule if (!is_site_admin()) { $invites_remaining--; if ($invites_remaining >= 0) { - PConfig::set(local_user(), 'system', 'invites_remaining', $invites_remaining); + DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining); } else { return; } @@ -92,7 +92,7 @@ class Invite extends BaseModule if ($res) { $total++; $current_invites++; - PConfig::set(local_user(), 'system', 'sent_invites', $current_invites); + DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites); if ($current_invites > $max_invites) { notice(L10n::t('Invitation limit exceeded. Please contact your site administrator.') . EOL); return; diff --git a/src/Module/Register.php b/src/Module/Register.php index 2ea4373b9..e791bf393 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -293,7 +293,7 @@ class Register extends BaseModule if (intval(Config::get('config', 'register_policy')) === self::OPEN) { if ($using_invites && $invite_id) { Model\Register::deleteByHash($invite_id); - PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites); + DI::pConfig()->set($user['uid'], 'system', 'invites_remaining', $num_invites); } // Only send a password mail when the password wasn't manually provided @@ -339,7 +339,7 @@ class Register extends BaseModule // invite system if ($using_invites && $invite_id) { Model\Register::deleteByHash($invite_id); - PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites); + DI::pConfig()->set($user['uid'], 'system', 'invites_remaining', $num_invites); } // send email to admins diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index 81140c1ac..187d6a15a 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -37,7 +37,7 @@ class Index extends BaseSettingsModule if (!$has_secret && !$verified) { $Google2FA = new Google2FA(); - PConfig::set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); + DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index 948952254..6b3abe9a7 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -58,7 +58,7 @@ class Verify extends BaseSettingsModule $valid = $google2fa->verifyKey(DI::pConfig()->get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? ''); if ($valid) { - PConfig::set(local_user(), '2fa', 'verified', true); + DI::pConfig()->set(local_user(), '2fa', 'verified', true); Session::set('2fa', true); notice(L10n::t('Two-factor authentication successfully activated.')); diff --git a/update.php b/update.php index 55fd82b2e..b583a64b9 100644 --- a/update.php +++ b/update.php @@ -8,6 +8,7 @@ use Friendica\Core\PConfig; use Friendica\Core\Update; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Model\Item; @@ -139,7 +140,7 @@ function update_1191() if ($key === 'show_on_profile') { if ($value) { - PConfig::set($uid, feature, forumlist_profile, $value); + DI::pConfig()->set($uid, feature, forumlist_profile, $value); } PConfig::delete($uid, $family, $key); @@ -147,7 +148,7 @@ function update_1191() if ($key === 'show_on_network') { if ($value) { - PConfig::set($uid, feature, forumlist_widget, $value); + DI::pConfig()->set($uid, feature, forumlist_widget, $value); } PConfig::delete($uid, $family, $key); diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php index a5054dab9..188cbe5f7 100644 --- a/view/theme/duepuntozero/config.php +++ b/view/theme/duepuntozero/config.php @@ -29,7 +29,7 @@ function theme_post(App $a) } if (isset($_POST['duepuntozero-settings-submit'])) { - PConfig::set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); + DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); } } diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 1ea2d9973..8dcdb84ed 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -17,16 +17,16 @@ function theme_post(App $a) } if (isset($_POST['frio-settings-submit'])) { - PConfig::set(local_user(), 'frio', 'scheme', $_POST['frio_scheme'] ?? ''); - PConfig::set(local_user(), 'frio', 'nav_bg', $_POST['frio_nav_bg'] ?? ''); - PConfig::set(local_user(), 'frio', 'nav_icon_color', $_POST['frio_nav_icon_color'] ?? ''); - PConfig::set(local_user(), 'frio', 'link_color', $_POST['frio_link_color'] ?? ''); - PConfig::set(local_user(), 'frio', 'background_color', $_POST['frio_background_color'] ?? ''); - PConfig::set(local_user(), 'frio', 'contentbg_transp', $_POST['frio_contentbg_transp'] ?? ''); - PConfig::set(local_user(), 'frio', 'background_image', $_POST['frio_background_image'] ?? ''); - PConfig::set(local_user(), 'frio', 'bg_image_option', $_POST['frio_bg_image_option'] ?? ''); - PConfig::set(local_user(), 'frio', 'css_modified', time()); - PConfig::set(local_user(), 'frio', 'enable_compose', $_POST['frio_enable_compose'] ?? 0); + DI::pConfig()->set(local_user(), 'frio', 'scheme', $_POST['frio_scheme'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'nav_bg', $_POST['frio_nav_bg'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'nav_icon_color', $_POST['frio_nav_icon_color'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'link_color', $_POST['frio_link_color'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'background_color', $_POST['frio_background_color'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'contentbg_transp', $_POST['frio_contentbg_transp'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'background_image', $_POST['frio_background_image'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'bg_image_option', $_POST['frio_bg_image_option'] ?? ''); + DI::pConfig()->set(local_user(), 'frio', 'css_modified', time()); + DI::pConfig()->set(local_user(), 'frio', 'enable_compose', $_POST['frio_enable_compose'] ?? 0); } } diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index de67074a9..ce9354481 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -30,10 +30,10 @@ function theme_post(App $a) { } if (isset($_POST['quattro-settings-submit'])){ - PConfig::set(local_user(), 'quattro', 'align', $_POST['quattro_align']); - PConfig::set(local_user(), 'quattro', 'color', $_POST['quattro_color']); - PConfig::set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']); - PConfig::set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']); + DI::pConfig()->set(local_user(), 'quattro', 'align', $_POST['quattro_align']); + DI::pConfig()->set(local_user(), 'quattro', 'color', $_POST['quattro_color']); + DI::pConfig()->set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']); + DI::pConfig()->set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']); } } diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 193b7246e..106303b92 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -51,13 +51,13 @@ function theme_post(App $a) } if (isset($_POST['vier-settings-submit'])) { - PConfig::set(local_user(), 'vier', 'style', $_POST['vier_style']); - PConfig::set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']); - PConfig::set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']); - PConfig::set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']); - PConfig::set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']); - PConfig::set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']); - PConfig::set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']); + DI::pConfig()->set(local_user(), 'vier', 'style', $_POST['vier_style']); + DI::pConfig()->set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']); + DI::pConfig()->set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']); + DI::pConfig()->set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']); + DI::pConfig()->set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']); + DI::pConfig()->set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']); + DI::pConfig()->set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']); } }