mirror of
https://github.com/friendica/friendica
synced 2025-05-04 21:44:10 +02:00
Move Config::get() to DI::config()->get()
This commit is contained in:
parent
5d294e8be8
commit
6c36fd9e01
126 changed files with 581 additions and 596 deletions
|
@ -33,7 +33,7 @@ class APContact
|
|||
return false;
|
||||
}
|
||||
|
||||
$xrd_timeout = Config::get('system', 'xrd_timeout');
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
|
||||
$webfinger = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
|
||||
|
||||
|
|
|
@ -919,7 +919,7 @@ class Contact
|
|||
*/
|
||||
|
||||
/// @todo Check for contact vitality via probing
|
||||
$archival_days = Config::get('system', 'archival_days', 32);
|
||||
$archival_days = DI::config()->get('system', 'archival_days', 32);
|
||||
|
||||
$expiry = $contact['term-date'] . ' + ' . $archival_days . ' days ';
|
||||
if (DateTimeFormat::utcNow() > DateTimeFormat::utc($expiry)) {
|
||||
|
@ -2322,7 +2322,7 @@ class Contact
|
|||
|
||||
// NOTREACHED
|
||||
}
|
||||
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != Protocol::DFRN)) {
|
||||
} elseif (DI::config()->get('system', 'dfrn_only') && ($ret['network'] != Protocol::DFRN)) {
|
||||
$result['message'] = DI::l10n()->t('This site is not configured to allow communications with other networks.') . EOL;
|
||||
$result['message'] .= DI::l10n()->t('No compatible communication protocols or feeds were discovered.') . EOL;
|
||||
return $result;
|
||||
|
@ -2352,7 +2352,7 @@ class Contact
|
|||
return $result;
|
||||
}
|
||||
|
||||
if ($protocol === Protocol::OSTATUS && Config::get('system', 'ostatus_disabled')) {
|
||||
if ($protocol === Protocol::OSTATUS && DI::config()->get('system', 'ostatus_disabled')) {
|
||||
$result['message'] .= DI::l10n()->t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
|
||||
$ret['notify'] = '';
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ class GContact
|
|||
}
|
||||
|
||||
// check supported networks
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
if (DI::config()->get('system', 'diaspora_enabled')) {
|
||||
$diaspora = Protocol::DIASPORA;
|
||||
} else {
|
||||
$diaspora = Protocol::DFRN;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
if (!DI::config()->get('system', 'ostatus_disabled')) {
|
||||
$ostatus = Protocol::OSTATUS;
|
||||
} else {
|
||||
$ostatus = Protocol::DFRN;
|
||||
|
@ -424,11 +424,11 @@ class GContact
|
|||
|
||||
$network = [Protocol::DFRN, Protocol::ACTIVITYPUB];
|
||||
|
||||
if (Config::get('system', 'diaspora_enabled')) {
|
||||
if (DI::config()->get('system', 'diaspora_enabled')) {
|
||||
$network[] = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
if (!DI::config()->get('system', 'ostatus_disabled')) {
|
||||
$network[] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ class GContact
|
|||
|
||||
$done[] = DI::baseUrl() . '/poco';
|
||||
|
||||
if (strlen(Config::get('system', 'directory'))) {
|
||||
if (strlen(DI::config()->get('system', 'directory'))) {
|
||||
$x = Network::fetchUrl(Search::getGlobalDirectory() . '/pubsites');
|
||||
if (!empty($x)) {
|
||||
$j = json_decode($x);
|
||||
|
@ -1235,7 +1235,7 @@ class GContact
|
|||
*/
|
||||
public static function discoverGsUsers()
|
||||
{
|
||||
$requery_days = intval(Config::get('system', 'poco_requery_days'));
|
||||
$requery_days = intval(DI::config()->get('system', 'poco_requery_days'));
|
||||
|
||||
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ class GServer
|
|||
}
|
||||
|
||||
// When a nodeinfo is present, we don't need to dig further
|
||||
$xrd_timeout = Config::get('system', 'xrd_timeout');
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = Network::curl($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
|
||||
if ($curlResult->isTimeout()) {
|
||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => Strings::normaliseLink($url)]);
|
||||
|
@ -726,7 +726,7 @@ class GServer
|
|||
*/
|
||||
private static function validHostMeta(string $url)
|
||||
{
|
||||
$xrd_timeout = Config::get('system', 'xrd_timeout');
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = Network::curl($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
|
@ -1348,7 +1348,7 @@ class GServer
|
|||
|
||||
$no_of_queries = 5;
|
||||
|
||||
$requery_days = intval(Config::get('system', 'poco_requery_days'));
|
||||
$requery_days = intval(DI::config()->get('system', 'poco_requery_days'));
|
||||
|
||||
if ($requery_days == 0) {
|
||||
$requery_days = 7;
|
||||
|
@ -1388,7 +1388,7 @@ class GServer
|
|||
*/
|
||||
private static function discoverFederation()
|
||||
{
|
||||
$last = Config::get('poco', 'last_federation_discovery');
|
||||
$last = DI::config()->get('poco', 'last_federation_discovery');
|
||||
|
||||
if ($last) {
|
||||
$next = $last + (24 * 60 * 60);
|
||||
|
@ -1412,7 +1412,7 @@ class GServer
|
|||
}
|
||||
|
||||
// Disvover Mastodon servers
|
||||
$accesstoken = Config::get('system', 'instances_social_key');
|
||||
$accesstoken = DI::config()->get('system', 'instances_social_key');
|
||||
|
||||
if (!empty($accesstoken)) {
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
|
|
|
@ -104,7 +104,7 @@ class Item
|
|||
public static function isLegacyMode()
|
||||
{
|
||||
if (is_null(self::$legacy_mode)) {
|
||||
self::$legacy_mode = (Config::get("system", "post_update_version") < 1279);
|
||||
self::$legacy_mode = (DI::config()->get("system", "post_update_version") < 1279);
|
||||
}
|
||||
|
||||
return self::$legacy_mode;
|
||||
|
@ -1451,7 +1451,7 @@ class Item
|
|||
$uid = intval($item['uid']);
|
||||
|
||||
// check for create date and expire time
|
||||
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
|
||||
$expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0);
|
||||
|
||||
$user = DBA::selectFirst('user', ['expire'], ['uid' => $uid]);
|
||||
if (DBA::isResult($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
|
||||
|
@ -1879,7 +1879,7 @@ class Item
|
|||
unset($item['owner-name']);
|
||||
unset($item['owner-avatar']);
|
||||
|
||||
$like_no_comment = Config::get('system', 'like_no_comment');
|
||||
$like_no_comment = DI::config()->get('system', 'like_no_comment');
|
||||
|
||||
DBA::transaction();
|
||||
$ret = DBA::insert('item', $item);
|
||||
|
@ -2585,7 +2585,7 @@ class Item
|
|||
$URLSearchString = "^\[\]";
|
||||
|
||||
// All hashtags should point to the home server if "local_tags" is activated
|
||||
if (Config::get('system', 'local_tags')) {
|
||||
if (DI::config()->get('system', 'local_tags')) {
|
||||
$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
"#[url=".DI::baseUrl()."/search?tag=$2]$2[/url]", $item["body"]);
|
||||
|
||||
|
@ -2842,7 +2842,7 @@ class Item
|
|||
*/
|
||||
public static function fixPrivatePhotos($s, $uid, $item = null, $cid = 0)
|
||||
{
|
||||
if (Config::get('system', 'disable_embedded')) {
|
||||
if (DI::config()->get('system', 'disable_embedded')) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
@ -3420,7 +3420,7 @@ class Item
|
|||
if ($rendered_hash == ''
|
||||
|| $rendered_html == ""
|
||||
|| $rendered_hash != hash("md5", $item["body"])
|
||||
|| Config::get("system", "ignore_cache")
|
||||
|| DI::config()->get("system", "ignore_cache")
|
||||
) {
|
||||
self::addRedirToImageTags($item);
|
||||
|
||||
|
@ -3439,7 +3439,7 @@ class Item
|
|||
}
|
||||
|
||||
// Only compare the HTML when we forcefully ignore the cache
|
||||
if (Config::get("system", "ignore_cache") && ($rendered_html != $item["rendered-html"])) {
|
||||
if (DI::config()->get("system", "ignore_cache") && ($rendered_html != $item["rendered-html"])) {
|
||||
$update = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -541,7 +541,7 @@ class Photo
|
|||
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
|
||||
$albums = DI::cache()->get($key);
|
||||
if (is_null($albums) || $update) {
|
||||
if (!Config::get("system", "no_count", false)) {
|
||||
if (!DI::config()->get("system", "no_count", false)) {
|
||||
/// @todo This query needs to be renewed. It is really slow
|
||||
// At this time we just store the data in the cache
|
||||
$albums = q("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
|
||||
|
|
|
@ -183,7 +183,7 @@ class Profile
|
|||
$a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['profile_uid'], 'system', 'mobile_theme');
|
||||
$a->profile['network'] = Protocol::DFRN;
|
||||
|
||||
DI::page()['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
|
||||
DI::page()['title'] = $a->profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
|
||||
|
||||
if (!$profiledata && !DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) {
|
||||
$a->setCurrentTheme($a->profile['theme']);
|
||||
|
@ -211,7 +211,7 @@ class Profile
|
|||
);
|
||||
}
|
||||
|
||||
$block = ((Config::get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
|
||||
$block = ((DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
|
||||
|
||||
/**
|
||||
* @todo
|
||||
|
@ -1231,7 +1231,7 @@ class Profile
|
|||
*/
|
||||
public static function searchProfiles($start = 0, $count = 100, $search = null)
|
||||
{
|
||||
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
|
||||
$publish = (DI::config()->get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
|
||||
$total = 0;
|
||||
|
||||
if (!empty($search)) {
|
||||
|
|
|
@ -501,7 +501,7 @@ class User
|
|||
throw new Exception(DI::l10n()->t('Empty passwords are not allowed.'));
|
||||
}
|
||||
|
||||
if (!Config::get('system', 'disable_password_exposed', false) && self::isPasswordExposed($password)) {
|
||||
if (!DI::config()->get('system', 'disable_password_exposed', false) && self::isPasswordExposed($password)) {
|
||||
throw new Exception(DI::l10n()->t('The new password has been exposed in a public data dump, please choose another.'));
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ class User
|
|||
*/
|
||||
public static function isNicknameBlocked($nickname)
|
||||
{
|
||||
$forbidden_nicknames = Config::get('system', 'forbidden_nicknames', '');
|
||||
$forbidden_nicknames = DI::config()->get('system', 'forbidden_nicknames', '');
|
||||
|
||||
// if the config variable is empty return false
|
||||
if (empty($forbidden_nicknames)) {
|
||||
|
@ -588,7 +588,7 @@ class User
|
|||
{
|
||||
$return = ['user' => null, 'password' => ''];
|
||||
|
||||
$using_invites = Config::get('system', 'invitation_only');
|
||||
$using_invites = DI::config()->get('system', 'invitation_only');
|
||||
|
||||
$invite_id = !empty($data['invite_id']) ? Strings::escapeTags(trim($data['invite_id'])) : '';
|
||||
$username = !empty($data['username']) ? Strings::escapeTags(trim($data['username'])) : '';
|
||||
|
@ -604,7 +604,7 @@ class User
|
|||
$language = !empty($data['language']) ? Strings::escapeTags(trim($data['language'])) : 'en';
|
||||
|
||||
$publish = !empty($data['profile_publish_reg']);
|
||||
$netpublish = $publish && Config::get('system', 'directory');
|
||||
$netpublish = $publish && DI::config()->get('system', 'directory');
|
||||
|
||||
if ($password1 != $confirm) {
|
||||
throw new Exception(DI::l10n()->t('Passwords do not match. Password unchanged.'));
|
||||
|
@ -655,8 +655,8 @@ class User
|
|||
// collapse multiple spaces in name
|
||||
$username = preg_replace('/ +/', ' ', $username);
|
||||
|
||||
$username_min_length = max(1, min(64, intval(Config::get('system', 'username_min_length', 3))));
|
||||
$username_max_length = max(1, min(64, intval(Config::get('system', 'username_max_length', 48))));
|
||||
$username_min_length = max(1, min(64, intval(DI::config()->get('system', 'username_min_length', 3))));
|
||||
$username_max_length = max(1, min(64, intval(DI::config()->get('system', 'username_max_length', 48))));
|
||||
|
||||
if ($username_min_length > $username_max_length) {
|
||||
Logger::log(DI::l10n()->t('system.username_min_length (%s) and system.username_max_length (%s) are excluding each other, swapping values.', $username_min_length, $username_max_length), Logger::WARNING);
|
||||
|
@ -674,7 +674,7 @@ class User
|
|||
}
|
||||
|
||||
// So now we are just looking for a space in the full name.
|
||||
$loose_reg = Config::get('system', 'no_regfullname');
|
||||
$loose_reg = DI::config()->get('system', 'no_regfullname');
|
||||
if (!$loose_reg) {
|
||||
$username = mb_convert_case($username, MB_CASE_TITLE, 'UTF-8');
|
||||
if (strpos($username, ' ') === false) {
|
||||
|
@ -693,14 +693,14 @@ class User
|
|||
throw new Exception(DI::l10n()->t('The nickname was blocked from registration by the nodes admin.'));
|
||||
}
|
||||
|
||||
if (Config::get('system', 'block_extended_register', false) && DBA::exists('user', ['email' => $email])) {
|
||||
if (DI::config()->get('system', 'block_extended_register', false) && DBA::exists('user', ['email' => $email])) {
|
||||
throw new Exception(DI::l10n()->t('Cannot use that email.'));
|
||||
}
|
||||
|
||||
// Disallow somebody creating an account using openid that uses the admin email address,
|
||||
// since openid bypasses email verification. We'll allow it if there is not yet an admin account.
|
||||
if (Config::get('config', 'admin_email') && strlen($openid_url)) {
|
||||
$adminlist = explode(',', str_replace(' ', '', strtolower(Config::get('config', 'admin_email'))));
|
||||
if (DI::config()->get('config', 'admin_email') && strlen($openid_url)) {
|
||||
$adminlist = explode(',', str_replace(' ', '', strtolower(DI::config()->get('config', 'admin_email'))));
|
||||
if (in_array(strtolower($email), $adminlist)) {
|
||||
throw new Exception(DI::l10n()->t('Cannot use that email.'));
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ class User
|
|||
}
|
||||
|
||||
$fields = ['def_gid' => $def_gid];
|
||||
if (Config::get('system', 'newuser_private') && $def_gid) {
|
||||
if (DI::config()->get('system', 'newuser_private') && $def_gid) {
|
||||
$fields['allow_gid'] = '<' . $def_gid . '>';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue