mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:00:16 +00:00
Merge branch 'develop' into reuse
This commit is contained in:
commit
dc2d894a26
10 changed files with 1133 additions and 2307 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
require_once __DIR__ . '/bin/dev/php-cs-fixer/vendor/autoload.php';
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
$finder = PhpCsFixer\Finder::create()
|
||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
->notPath('addon')
|
->notPath('addon')
|
||||||
|
@ -41,10 +43,10 @@ return $config
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'blank_line_after_namespace' => true,
|
'blank_line_after_namespace' => true,
|
||||||
'braces' => [
|
'braces_position' => [
|
||||||
'position_after_anonymous_constructs' => 'same',
|
'anonymous_classes_opening_brace' => 'same_line',
|
||||||
'position_after_control_structures' => 'same',
|
'control_structures_opening_brace' => 'same_line',
|
||||||
'position_after_functions_and_oop_constructs' => 'next',
|
'functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
|
||||||
],
|
],
|
||||||
'elseif' => true,
|
'elseif' => true,
|
||||||
'encoding' => true,
|
'encoding' => true,
|
||||||
|
@ -58,10 +60,9 @@ return $config
|
||||||
'syntax' => 'long',
|
'syntax' => 'long',
|
||||||
],
|
],
|
||||||
'lowercase_keywords' => true,
|
'lowercase_keywords' => true,
|
||||||
'method_argument_space' => [],
|
|
||||||
'no_closing_tag' => true,
|
'no_closing_tag' => true,
|
||||||
'no_spaces_after_function_name' => true,
|
'no_spaces_after_function_name' => true,
|
||||||
'no_spaces_inside_parenthesis' => true,
|
'spaces_inside_parentheses' => false,
|
||||||
'no_trailing_whitespace' => true,
|
'no_trailing_whitespace' => true,
|
||||||
'no_trailing_whitespace_in_comment' => true,
|
'no_trailing_whitespace_in_comment' => true,
|
||||||
'no_unused_imports' => true,
|
'no_unused_imports' => true,
|
||||||
|
@ -74,7 +75,7 @@ return $config
|
||||||
'visibility_required' => [
|
'visibility_required' => [
|
||||||
'elements' => ['property', 'method']
|
'elements' => ['property', 'method']
|
||||||
],
|
],
|
||||||
'new_with_braces' => true,
|
'new_with_parentheses' => true,
|
||||||
])
|
])
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
->setIndent("\t");
|
->setIndent("\t");
|
||||||
|
|
82
.php_cs.dist
82
.php_cs.dist
|
@ -1,82 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* SPDX-FileCopyrightText: 2010 - 2024 the Friendica project
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
|
||||||
**/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
require_once __DIR__ . '/bin/dev/php-cs-fixer/vendor/autoload.php';
|
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
|
||||||
->in(__DIR__)
|
|
||||||
->notPath('addon')
|
|
||||||
->notPath('bin/dev')
|
|
||||||
->notPath('config')
|
|
||||||
->notPath('doc')
|
|
||||||
->notPath('images')
|
|
||||||
->notPath('mods')
|
|
||||||
->notPath('spec')
|
|
||||||
->notPath('vendor')
|
|
||||||
->notPath('view/asset')
|
|
||||||
->notPath('lang')
|
|
||||||
->notPath('view/smarty3/compiled');
|
|
||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
|
||||||
return $config
|
|
||||||
->setRules([
|
|
||||||
'@PSR1' => true,
|
|
||||||
'@PSR2' => true,
|
|
||||||
'@PSR12' => true,
|
|
||||||
'align_multiline_comment' => true,
|
|
||||||
'array_indentation' => true,
|
|
||||||
'array_syntax' => [
|
|
||||||
'syntax' => 'short',
|
|
||||||
],
|
|
||||||
'binary_operator_spaces' => [
|
|
||||||
'default' => 'single_space',
|
|
||||||
'operators' => [
|
|
||||||
'=>' => 'align_single_space_minimal',
|
|
||||||
'=' => 'align_single_space_minimal',
|
|
||||||
'??' => 'align_single_space_minimal',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'blank_line_after_namespace' => true,
|
|
||||||
'braces' => [
|
|
||||||
'position_after_anonymous_constructs' => 'same',
|
|
||||||
'position_after_control_structures' => 'same',
|
|
||||||
'position_after_functions_and_oop_constructs' => 'next',
|
|
||||||
],
|
|
||||||
'elseif' => true,
|
|
||||||
'encoding' => true,
|
|
||||||
'full_opening_tag' => true,
|
|
||||||
'function_declaration' => [
|
|
||||||
'closure_function_spacing' => 'one',
|
|
||||||
],
|
|
||||||
'indentation_type' => true,
|
|
||||||
'line_ending' => true,
|
|
||||||
'list_syntax' => [
|
|
||||||
'syntax' => 'long',
|
|
||||||
],
|
|
||||||
'lowercase_keywords' => true,
|
|
||||||
'method_argument_space' => [],
|
|
||||||
'no_closing_tag' => true,
|
|
||||||
'no_spaces_after_function_name' => true,
|
|
||||||
'no_spaces_inside_parenthesis' => true,
|
|
||||||
'no_trailing_whitespace' => true,
|
|
||||||
'no_trailing_whitespace_in_comment' => true,
|
|
||||||
'no_unused_imports' => true,
|
|
||||||
'single_blank_line_at_eof' => true,
|
|
||||||
'single_class_element_per_statement' => true,
|
|
||||||
'single_import_per_statement' => true,
|
|
||||||
'single_line_after_imports' => true,
|
|
||||||
'switch_case_space' => true,
|
|
||||||
'ternary_operator_spaces' => false,
|
|
||||||
'visibility_required' => [
|
|
||||||
'elements' => ['property', 'method']
|
|
||||||
],
|
|
||||||
'new_with_braces' => true,
|
|
||||||
])
|
|
||||||
->setFinder($finder)
|
|
||||||
->setIndent("\t");
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"friendsofphp/php-cs-fixer": "^2.18"
|
"friendsofphp/php-cs-fixer": "^3.46"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1714
bin/dev/php-cs-fixer/composer.lock
generated
1714
bin/dev/php-cs-fixer/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -135,8 +135,7 @@
|
||||||
"mockery/mockery": "^1.3",
|
"mockery/mockery": "^1.3",
|
||||||
"mikey179/vfsstream": "^1.6",
|
"mikey179/vfsstream": "^1.6",
|
||||||
"phpunit/phpunit": "^9",
|
"phpunit/phpunit": "^9",
|
||||||
"dms/phpunit-arraysubset-asserts": "^0.3.1",
|
"dms/phpunit-arraysubset-asserts": "^0.3.1"
|
||||||
"friendsofphp/php-cs-fixer": "^3.46"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "phpunit",
|
"test": "phpunit",
|
||||||
|
@ -145,13 +144,11 @@
|
||||||
"cs:install": "@composer install --working-dir=bin/dev/php-cs-fixer",
|
"cs:install": "@composer install --working-dir=bin/dev/php-cs-fixer",
|
||||||
"cs:check": [
|
"cs:check": [
|
||||||
"@cs:install",
|
"@cs:install",
|
||||||
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff"
|
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer check --diff"
|
||||||
],
|
],
|
||||||
"cs:fix": [
|
"cs:fix": [
|
||||||
"@cs:install",
|
"@cs:install",
|
||||||
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
|
"bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix"
|
||||||
],
|
]
|
||||||
"cs:check-v3": "vendor/bin/php-cs-fixer check --diff",
|
|
||||||
"cs:fix-v3": "vendor/bin/php-cs-fixer fix"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1569
composer.lock
generated
1569
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -245,6 +245,17 @@ class Contact
|
||||||
return DBA::update('contact', $fields, $condition, $old_fields);
|
return DBA::update('contact', $fields, $condition, $old_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $id Contact ID
|
||||||
|
* @param array $fields Array of selected fields, empty for all
|
||||||
|
* @return array|boolean Contact record if it exists, false otherwise
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function getAccountById(int $id, array $fields = [])
|
||||||
|
{
|
||||||
|
return DBA::selectFirst('account-user-view', $fields, ['id' => $id]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $id Contact ID
|
* @param integer $id Contact ID
|
||||||
* @param array $fields Array of selected fields, empty for all
|
* @param array $fields Array of selected fields, empty for all
|
||||||
|
@ -2361,7 +2372,8 @@ class Contact
|
||||||
|
|
||||||
if ($default_avatar && Proxy::isLocalImage($avatar)) {
|
if ($default_avatar && Proxy::isLocalImage($avatar)) {
|
||||||
$fields = [
|
$fields = [
|
||||||
'avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
|
'avatar' => $avatar,
|
||||||
|
'avatar-date' => DateTimeFormat::utcNow(),
|
||||||
'photo' => $avatar,
|
'photo' => $avatar,
|
||||||
'thumb' => self::getDefaultAvatar($contact, Proxy::SIZE_THUMB),
|
'thumb' => self::getDefaultAvatar($contact, Proxy::SIZE_THUMB),
|
||||||
'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)
|
'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Conversations extends BaseModule
|
||||||
throw new NotFoundException($this->t('Contact not found.'));
|
throw new NotFoundException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = Model\Contact::getById($pcid);
|
$contact = Model\Contact::getAccountById($pcid);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
throw new NotFoundException($this->t('Contact not found.'));
|
throw new NotFoundException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
@ -97,13 +97,15 @@ class Conversations extends BaseModule
|
||||||
|
|
||||||
Nav::setSelected('contact');
|
Nav::setSelected('contact');
|
||||||
|
|
||||||
$options = [
|
if (!$contact['ap-posting-restricted']) {
|
||||||
'lockstate' => ACL::getLockstateForUserId($this->userSession->getLocalUserId()) ? 'lock' : 'unlock',
|
$options = [
|
||||||
'acl' => ACL::getFullSelectorHTML($this->page, $this->userSession->getLocalUserId(), true, []),
|
'lockstate' => ACL::getLockstateForUserId($this->userSession->getLocalUserId()) ? 'lock' : 'unlock',
|
||||||
'bang' => '',
|
'acl' => ACL::getFullSelectorHTML($this->page, $this->userSession->getLocalUserId(), true, []),
|
||||||
'content' => ($contact['contact-type'] == ModelContact::TYPE_COMMUNITY ? '!' : '@') . ($contact['addr'] ?: $contact['url']),
|
'bang' => '',
|
||||||
];
|
'content' => ($contact['contact-type'] == ModelContact::TYPE_COMMUNITY ? '!' : '@') . ($contact['addr'] ?: $contact['url']),
|
||||||
$o = $this->conversation->statusEditor($options);
|
];
|
||||||
|
$o = $this->conversation->statusEditor($options);
|
||||||
|
}
|
||||||
|
|
||||||
$o .= Contact::getTabsHTML($contact, Contact::TAB_CONVERSATIONS);
|
$o .= Contact::getTabsHTML($contact, Contact::TAB_CONVERSATIONS);
|
||||||
$o .= Model\Contact::getThreadsFromId($contact['id'], $this->userSession->getLocalUserId(), 0, 0, $request['last_created'] ?? '');
|
$o .= Model\Contact::getThreadsFromId($contact['id'], $this->userSession->getLocalUserId(), 0, 0, $request['last_created'] ?? '');
|
||||||
|
|
|
@ -421,13 +421,14 @@ class Register extends BaseModule
|
||||||
}
|
}
|
||||||
public static function getPolicy(): int
|
public static function getPolicy(): int
|
||||||
{
|
{
|
||||||
|
$admins = User::getAdminList(['login_date']);
|
||||||
$days = DI::config()->get('system', 'admin_inactivity_limit');
|
$days = DI::config()->get('system', 'admin_inactivity_limit');
|
||||||
if ($days == 0) {
|
if ($days == 0 || empty($admins)) {
|
||||||
return intval(DI::config()->get('config', 'register_policy'));
|
return intval(DI::config()->get('config', 'register_policy'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$inactive_since = DateTimeFormat::utc('now - ' . $days . ' day');
|
$inactive_since = DateTimeFormat::utc('now - ' . $days . ' day');
|
||||||
foreach (User::getAdminList(['login_date']) as $admin) {
|
foreach ($admins as $admin) {
|
||||||
if (strtotime($admin['login_date']) > strtotime($inactive_since)) {
|
if (strtotime($admin['login_date']) > strtotime($inactive_since)) {
|
||||||
return intval(DI::config()->get('config', 'register_policy'));
|
return intval(DI::config()->get('config', 'register_policy'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,30 +142,30 @@ class Acl extends BaseModule
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case self::TYPE_MENTION_CONTACT_CIRCLE:
|
case self::TYPE_MENTION_CONTACT_CIRCLE:
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `network` != ?", '', Protocol::OSTATUS
|
["NOT `self` AND NOT `blocked` AND `network` != ?", Protocol::OSTATUS
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::TYPE_MENTION_CONTACT:
|
case self::TYPE_MENTION_CONTACT:
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["NOT `self` AND NOT `blocked` AND `notify` != ?", ''
|
["NOT `self` AND NOT `blocked`",
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::TYPE_MENTION_GROUP:
|
case self::TYPE_MENTION_GROUP:
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `contact-type` = ?", '', Contact::TYPE_COMMUNITY
|
["NOT `self` AND NOT `blocked` AND (NOT `ap-posting-restricted` OR `ap-posting-restricted` IS NULL) AND `contact-type` = ?", Contact::TYPE_COMMUNITY
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::TYPE_PRIVATE_MESSAGE:
|
case self::TYPE_PRIVATE_MESSAGE:
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `network` IN (?, ?, ?)", '', Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA
|
["NOT `self` AND NOT `blocked` AND `network` IN (?, ?, ?)", Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact_count = $this->database->count('contact', $condition);
|
$contact_count = $this->database->count('account-user-view', $condition);
|
||||||
|
|
||||||
$resultTotal = $circle_count + $contact_count;
|
$resultTotal = $circle_count + $contact_count;
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class Acl extends BaseModule
|
||||||
|
|
||||||
$contacts = [];
|
$contacts = [];
|
||||||
if ($type != self::TYPE_MENTION_CIRCLE) {
|
if ($type != self::TYPE_MENTION_CIRCLE) {
|
||||||
$contacts = Contact::selectToArray([], $condition, ['order' => ['name']]);
|
$contacts = Contact::selectAccountToArray([], $condition, ['order' => ['name']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = [];
|
$groups = [];
|
||||||
|
|
Loading…
Reference in a new issue